mirror of https://github.com/vitalif/openscad
Merge branch 'master' into visitortests
commit
a898a518d0
|
@ -12,6 +12,7 @@ o if() and else() can now take any value type as parameter. false, 0, empty stri
|
|||
o Strings can now be lexographically compared using the <, <=, >, >= operators
|
||||
o The version() function will return the OpenSCAD version as a vector, e.g. [2011, 09]
|
||||
o The version_num() function will return the OpenSCAD version as a number, e.g. 20110923
|
||||
o Added PI constant.
|
||||
|
||||
Bugfixes:
|
||||
o square() crashed if any of the dimensions were zero
|
||||
|
@ -26,6 +27,7 @@ o dxf_linear_extrude() and dxf_rotate_extrude() are now deprecated.
|
|||
o The file, layer, origin and scale parameters to linear_extrude() and rotate_extrude()
|
||||
are now deprecated. Use an import() child instead.
|
||||
o import_dxf(), import_stl() and import_off() are now deprecated. Use import() instead.
|
||||
o When exporting geometry from the cmd-line, use the universal -o option. It will export to the correct file format based on the given suffix (dxf, stl, off).
|
||||
|
||||
OpenSCAD 2011.06
|
||||
================
|
||||
|
|
|
@ -115,6 +115,7 @@ private slots:
|
|||
void actionExportSTL();
|
||||
void actionExportOFF();
|
||||
void actionExportDXF();
|
||||
void actionExportCSG();
|
||||
void actionExportImage();
|
||||
void actionFlushCaches();
|
||||
|
||||
|
|
|
@ -178,6 +178,7 @@
|
|||
<addaction name="designActionExportSTL"/>
|
||||
<addaction name="designActionExportOFF"/>
|
||||
<addaction name="designActionExportDXF"/>
|
||||
<addaction name="designActionExportCSG"/>
|
||||
<addaction name="designActionExportImage"/>
|
||||
<addaction name="designActionFlushCaches"/>
|
||||
</widget>
|
||||
|
@ -657,6 +658,11 @@
|
|||
<string>Export as Image...</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="designActionExportCSG">
|
||||
<property name="text">
|
||||
<string>Export as CSG...</string>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
|
|
|
@ -285,6 +285,7 @@ MainWindow::MainWindow(const QString &filename)
|
|||
connect(this->designActionExportSTL, SIGNAL(triggered()), this, SLOT(actionExportSTL()));
|
||||
connect(this->designActionExportOFF, SIGNAL(triggered()), this, SLOT(actionExportOFF()));
|
||||
connect(this->designActionExportDXF, SIGNAL(triggered()), this, SLOT(actionExportDXF()));
|
||||
connect(this->designActionExportCSG, SIGNAL(triggered()), this, SLOT(actionExportCSG()));
|
||||
connect(this->designActionExportImage, SIGNAL(triggered()), this, SLOT(actionExportImage()));
|
||||
connect(this->designActionFlushCaches, SIGNAL(triggered()), this, SLOT(actionFlushCaches()));
|
||||
|
||||
|
@ -1475,6 +1476,38 @@ void MainWindow::actionExportDXF()
|
|||
#endif /* ENABLE_CGAL */
|
||||
}
|
||||
|
||||
void MainWindow::actionExportCSG()
|
||||
{
|
||||
setCurrentOutput();
|
||||
|
||||
if (!this->root_node) {
|
||||
PRINT("Nothing to export. Please try compiling first...");
|
||||
clearCurrentOutput();
|
||||
return;
|
||||
}
|
||||
|
||||
QString csg_filename = QFileDialog::getSaveFileName(this, "Export CSG File",
|
||||
this->fileName.isEmpty() ? "Untitled.csg" : QFileInfo(this->fileName).baseName()+".csg",
|
||||
"CSG Files (*.csg)");
|
||||
if (csg_filename.isEmpty()) {
|
||||
PRINTF("No filename specified. CSG export aborted.");
|
||||
clearCurrentOutput();
|
||||
return;
|
||||
}
|
||||
|
||||
std::ofstream fstream(csg_filename.toUtf8());
|
||||
if (!fstream.is_open()) {
|
||||
PRINTA("Can't open file \"%s\" for export", csg_filename);
|
||||
}
|
||||
else {
|
||||
fstream << this->tree.getString(*this->root_node) << "\n";
|
||||
fstream.close();
|
||||
PRINTF("CSG export finished.");
|
||||
}
|
||||
|
||||
clearCurrentOutput();
|
||||
}
|
||||
|
||||
void MainWindow::actionExportImage()
|
||||
{
|
||||
QImage img = this->glview->grabFrameBuffer();
|
||||
|
|
156
src/openscad.cc
156
src/openscad.cc
|
@ -70,7 +70,7 @@ namespace po = boost::program_options;
|
|||
|
||||
static void help(const char *progname)
|
||||
{
|
||||
fprintf(stderr, "Usage: %s [ { -s stl_file | -o off_file | -x dxf_file } [ -d deps_file ] ]\\\n"
|
||||
fprintf(stderr, "Usage: %s [ { -o output_file } [ -d deps_file ] ]\\\n"
|
||||
"%*s[ -m make_command ] [ -D var=val [..] ] filename\n",
|
||||
progname, int(strlen(progname))+8, "");
|
||||
exit(1);
|
||||
|
@ -126,18 +126,14 @@ int main(int argc, char **argv)
|
|||
QCoreApplication::setApplicationName("OpenSCAD");
|
||||
|
||||
const char *filename = NULL;
|
||||
const char *stl_output_file = NULL;
|
||||
const char *off_output_file = NULL;
|
||||
const char *dxf_output_file = NULL;
|
||||
const char *output_file = NULL;
|
||||
const char *deps_output_file = NULL;
|
||||
|
||||
po::options_description desc("Allowed options");
|
||||
desc.add_options()
|
||||
("help,h", "help message")
|
||||
("version,v", "print the version")
|
||||
("s,s", po::value<string>(), "stl-file")
|
||||
("o,o", po::value<string>(), "off-file")
|
||||
("x,x", po::value<string>(), "dxf-file")
|
||||
("o,o", po::value<string>(), "out-file")
|
||||
("d,d", po::value<string>(), "deps-file")
|
||||
("m,m", po::value<string>(), "makefile")
|
||||
("D,D", po::value<vector<string> >(), "var=val");
|
||||
|
@ -159,20 +155,10 @@ int main(int argc, char **argv)
|
|||
if (vm.count("help")) help(argv[0]);
|
||||
if (vm.count("version")) version();
|
||||
|
||||
if (vm.count("s")) {
|
||||
if (stl_output_file || off_output_file || dxf_output_file)
|
||||
help(argv[0]);
|
||||
stl_output_file = vm["s"].as<string>().c_str();
|
||||
}
|
||||
if (vm.count("o")) {
|
||||
if (stl_output_file || off_output_file || dxf_output_file)
|
||||
help(argv[0]);
|
||||
off_output_file = vm["o"].as<string>().c_str();
|
||||
}
|
||||
if (vm.count("x")) {
|
||||
if (stl_output_file || off_output_file || dxf_output_file)
|
||||
help(argv[0]);
|
||||
dxf_output_file = vm["x"].as<string>().c_str();
|
||||
// FIXME: Allow for multiple output files?
|
||||
if (output_file) help(argv[0]);
|
||||
output_file = vm["o"].as<string>().c_str();
|
||||
}
|
||||
if (vm.count("d")) {
|
||||
if (deps_output_file)
|
||||
|
@ -253,10 +239,24 @@ int main(int argc, char **argv)
|
|||
PolySetCGALEvaluator psevaluator(cgalevaluator);
|
||||
#endif
|
||||
|
||||
if (stl_output_file || off_output_file || dxf_output_file)
|
||||
if (output_file)
|
||||
{
|
||||
if (!filename)
|
||||
help(argv[0]);
|
||||
const char *stl_output_file = NULL;
|
||||
const char *off_output_file = NULL;
|
||||
const char *dxf_output_file = NULL;
|
||||
const char *csg_output_file = NULL;
|
||||
|
||||
QString suffix = QFileInfo(output_file).suffix().toLower();
|
||||
if (suffix == "stl") stl_output_file = output_file;
|
||||
else if (suffix == "off") off_output_file = output_file;
|
||||
else if (suffix == "dxf") dxf_output_file = output_file;
|
||||
else if (suffix == "csg") csg_output_file = output_file;
|
||||
else {
|
||||
fprintf(stderr, "Unknown suffix for output file %s\n", output_file);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (!filename) help(argv[0]);
|
||||
|
||||
#ifdef ENABLE_CGAL
|
||||
Context root_ctx;
|
||||
|
@ -304,68 +304,80 @@ int main(int argc, char **argv)
|
|||
|
||||
AbstractNode::resetIndexCounter();
|
||||
root_node = root_module->evaluate(&root_ctx, &root_inst);
|
||||
|
||||
tree.setRoot(root_node);
|
||||
CGAL_Nef_polyhedron root_N = cgalevaluator.evaluateCGALMesh(*tree.root());
|
||||
|
||||
QDir::setCurrent(original_path.absolutePath());
|
||||
|
||||
if (deps_output_file) {
|
||||
if (!write_deps(deps_output_file,
|
||||
stl_output_file ? stl_output_file : off_output_file)) {
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
if (stl_output_file) {
|
||||
if (root_N.dim != 3) {
|
||||
fprintf(stderr, "Current top level object is not a 3D object.\n");
|
||||
exit(1);
|
||||
}
|
||||
if (!root_N.p3->is_simple()) {
|
||||
fprintf(stderr, "Object isn't a valid 2-manifold! Modify your design.\n");
|
||||
exit(1);
|
||||
}
|
||||
std::ofstream fstream(stl_output_file);
|
||||
if (csg_output_file) {
|
||||
QDir::setCurrent(original_path.absolutePath());
|
||||
std::ofstream fstream(csg_output_file);
|
||||
if (!fstream.is_open()) {
|
||||
PRINTF("Can't open file \"%s\" for export", stl_output_file);
|
||||
PRINTF("Can't open file \"%s\" for export", csg_output_file);
|
||||
}
|
||||
else {
|
||||
export_stl(&root_N, fstream, NULL);
|
||||
fstream << tree.getString(*root_node) << "\n";
|
||||
fstream.close();
|
||||
}
|
||||
}
|
||||
else {
|
||||
CGAL_Nef_polyhedron root_N = cgalevaluator.evaluateCGALMesh(*tree.root());
|
||||
|
||||
QDir::setCurrent(original_path.absolutePath());
|
||||
|
||||
if (deps_output_file) {
|
||||
if (!write_deps(deps_output_file,
|
||||
stl_output_file ? stl_output_file : off_output_file)) {
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
if (off_output_file) {
|
||||
if (root_N.dim != 3) {
|
||||
fprintf(stderr, "Current top level object is not a 3D object.\n");
|
||||
exit(1);
|
||||
if (stl_output_file) {
|
||||
if (root_N.dim != 3) {
|
||||
fprintf(stderr, "Current top level object is not a 3D object.\n");
|
||||
exit(1);
|
||||
}
|
||||
if (!root_N.p3->is_simple()) {
|
||||
fprintf(stderr, "Object isn't a valid 2-manifold! Modify your design.\n");
|
||||
exit(1);
|
||||
}
|
||||
std::ofstream fstream(stl_output_file);
|
||||
if (!fstream.is_open()) {
|
||||
PRINTF("Can't open file \"%s\" for export", stl_output_file);
|
||||
}
|
||||
else {
|
||||
export_stl(&root_N, fstream, NULL);
|
||||
fstream.close();
|
||||
}
|
||||
}
|
||||
if (!root_N.p3->is_simple()) {
|
||||
fprintf(stderr, "Object isn't a valid 2-manifold! Modify your design.\n");
|
||||
exit(1);
|
||||
|
||||
if (off_output_file) {
|
||||
if (root_N.dim != 3) {
|
||||
fprintf(stderr, "Current top level object is not a 3D object.\n");
|
||||
exit(1);
|
||||
}
|
||||
if (!root_N.p3->is_simple()) {
|
||||
fprintf(stderr, "Object isn't a valid 2-manifold! Modify your design.\n");
|
||||
exit(1);
|
||||
}
|
||||
std::ofstream fstream(off_output_file);
|
||||
if (!fstream.is_open()) {
|
||||
PRINTF("Can't open file \"%s\" for export", off_output_file);
|
||||
}
|
||||
else {
|
||||
export_off(&root_N, fstream, NULL);
|
||||
fstream.close();
|
||||
}
|
||||
}
|
||||
std::ofstream fstream(off_output_file);
|
||||
if (!fstream.is_open()) {
|
||||
PRINTF("Can't open file \"%s\" for export", off_output_file);
|
||||
}
|
||||
else {
|
||||
export_off(&root_N, fstream, NULL);
|
||||
fstream.close();
|
||||
|
||||
if (dxf_output_file) {
|
||||
std::ofstream fstream(dxf_output_file);
|
||||
if (!fstream.is_open()) {
|
||||
PRINTF("Can't open file \"%s\" for export", dxf_output_file);
|
||||
}
|
||||
else {
|
||||
export_dxf(&root_N, fstream, NULL);
|
||||
fstream.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (dxf_output_file) {
|
||||
std::ofstream fstream(dxf_output_file);
|
||||
if (!fstream.is_open()) {
|
||||
PRINTF("Can't open file \"%s\" for export", dxf_output_file);
|
||||
}
|
||||
else {
|
||||
export_dxf(&root_N, fstream, NULL);
|
||||
fstream.close();
|
||||
}
|
||||
}
|
||||
|
||||
delete root_node;
|
||||
#else
|
||||
fprintf(stderr, "OpenSCAD has been compiled without CGAL support!\n");
|
||||
|
|
Loading…
Reference in New Issue