mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-07-13 17:41:47 +08:00
New --export-pov option (C++ only)
This commit is contained in:
parent
f49458506f
commit
0b79b971e8
@ -70,6 +70,13 @@ main(const int argc, const char **argv)
|
|||||||
TriangleMesh mesh = model->mesh();
|
TriangleMesh mesh = model->mesh();
|
||||||
Slic3r::IO::OBJ::write(mesh, outfile);
|
Slic3r::IO::OBJ::write(mesh, outfile);
|
||||||
printf("File exported to %s\n", outfile.c_str());
|
printf("File exported to %s\n", outfile.c_str());
|
||||||
|
} else if (cli_config.export_pov) {
|
||||||
|
std::string outfile = cli_config.output.value;
|
||||||
|
if (outfile.empty()) outfile = model->objects.front()->input_file + ".pov";
|
||||||
|
|
||||||
|
TriangleMesh mesh = model->mesh();
|
||||||
|
Slic3r::IO::POV::write(mesh, outfile);
|
||||||
|
printf("File exported to %s\n", outfile.c_str());
|
||||||
} else if (cli_config.export_svg) {
|
} else if (cli_config.export_svg) {
|
||||||
std::string outfile = cli_config.output.value;
|
std::string outfile = cli_config.output.value;
|
||||||
if (outfile.empty()) outfile = model->objects.front()->input_file + ".svg";
|
if (outfile.empty()) outfile = model->objects.front()->input_file + ".svg";
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
#include "IO.hpp"
|
#include "IO.hpp"
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
|
#include <fstream>
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
namespace Slic3r { namespace IO {
|
namespace Slic3r { namespace IO {
|
||||||
|
|
||||||
@ -44,4 +46,22 @@ OBJ::write(TriangleMesh& mesh, std::string output_file)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
POV::write(TriangleMesh& mesh, std::string output_file)
|
||||||
|
{
|
||||||
|
using namespace std;
|
||||||
|
ofstream pov;
|
||||||
|
pov.open(output_file.c_str(), ios::out | ios::trunc);
|
||||||
|
for (int i = 0; i < mesh.stl.stats.number_of_facets; ++i) {
|
||||||
|
const stl_facet &f = mesh.stl.facet_start[i];
|
||||||
|
pov << "triangle { ";
|
||||||
|
pov << "<" << f.vertex[0].x << "," << f.vertex[0].y << "," << f.vertex[0].z << ">,";
|
||||||
|
pov << "<" << f.vertex[1].x << "," << f.vertex[1].y << "," << f.vertex[1].z << ">,";
|
||||||
|
pov << "<" << f.vertex[2].x << "," << f.vertex[2].y << "," << f.vertex[2].z << ">";
|
||||||
|
pov << " }" << endl;
|
||||||
|
}
|
||||||
|
pov.close();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
} }
|
} }
|
||||||
|
@ -21,6 +21,12 @@ class OBJ
|
|||||||
static bool write(TriangleMesh& mesh, std::string output_file);
|
static bool write(TriangleMesh& mesh, std::string output_file);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class POV
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
static bool write(TriangleMesh& mesh, std::string output_file);
|
||||||
|
};
|
||||||
|
|
||||||
} }
|
} }
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -1359,10 +1359,16 @@ CLIConfigDef::CLIConfigDef()
|
|||||||
|
|
||||||
def = this->add("export_obj", coBool);
|
def = this->add("export_obj", coBool);
|
||||||
def->label = "Export SVG";
|
def->label = "Export SVG";
|
||||||
def->tooltip = "Export the model to OBJ.";
|
def->tooltip = "Export the model as OBJ.";
|
||||||
def->cli = "export-obj";
|
def->cli = "export-obj";
|
||||||
def->default_value = new ConfigOptionBool(false);
|
def->default_value = new ConfigOptionBool(false);
|
||||||
|
|
||||||
|
def = this->add("export_pov", coBool);
|
||||||
|
def->label = "Export POV";
|
||||||
|
def->tooltip = "Export the model as POV-Ray definition.";
|
||||||
|
def->cli = "export-pov";
|
||||||
|
def->default_value = new ConfigOptionBool(false);
|
||||||
|
|
||||||
def = this->add("export_svg", coBool);
|
def = this->add("export_svg", coBool);
|
||||||
def->label = "Export SVG";
|
def->label = "Export SVG";
|
||||||
def->tooltip = "Slice the model and export slices as SVG.";
|
def->tooltip = "Slice the model and export slices as SVG.";
|
||||||
|
@ -502,6 +502,7 @@ class CLIConfig
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ConfigOptionBool export_obj;
|
ConfigOptionBool export_obj;
|
||||||
|
ConfigOptionBool export_pov;
|
||||||
ConfigOptionBool export_svg;
|
ConfigOptionBool export_svg;
|
||||||
ConfigOptionBool info;
|
ConfigOptionBool info;
|
||||||
ConfigOptionString output;
|
ConfigOptionString output;
|
||||||
@ -515,6 +516,7 @@ class CLIConfig
|
|||||||
|
|
||||||
virtual ConfigOption* optptr(const t_config_option_key &opt_key, bool create = false) {
|
virtual ConfigOption* optptr(const t_config_option_key &opt_key, bool create = false) {
|
||||||
OPT_PTR(export_obj);
|
OPT_PTR(export_obj);
|
||||||
|
OPT_PTR(export_pov);
|
||||||
OPT_PTR(export_svg);
|
OPT_PTR(export_svg);
|
||||||
OPT_PTR(info);
|
OPT_PTR(info);
|
||||||
OPT_PTR(output);
|
OPT_PTR(output);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user