summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMarius Kintel <marius@kintel.net>2013-09-13 05:06:17 (GMT)
committerMarius Kintel <marius@kintel.net>2013-09-13 05:06:17 (GMT)
commitead8749e99238c18a3d7bb903f98bb7bca6a7685 (patch)
treebaa054dc0bd236e11a0ad29c41f092193a52245d /src
parent233406230281d8fefe24902fea52d916dfb3d88e (diff)
parentf82ff8272b9698e7c572d6c67a5b69bf26896933 (diff)
Merge pull request #476 from openscad/testfixes
Testfixes
Diffstat (limited to 'src')
-rw-r--r--src/CGALEvaluator.cc9
-rw-r--r--src/PlatformUtils.cc43
-rw-r--r--src/PlatformUtils.h2
-rw-r--r--src/export.h1
-rw-r--r--src/export_png.cc47
-rw-r--r--src/mainwin.cc32
-rw-r--r--src/openscad.cc29
7 files changed, 117 insertions, 46 deletions
diff --git a/src/CGALEvaluator.cc b/src/CGALEvaluator.cc
index adaec4a..ec01315 100644
--- a/src/CGALEvaluator.cc
+++ b/src/CGALEvaluator.cc
@@ -216,7 +216,7 @@ CGAL_Nef_polyhedron CGALEvaluator::applyResize(const CgaladvNode &node)
bbox_size.push_back( bb.ymax()-bb.ymin() );
bbox_size.push_back( bb.zmax()-bb.zmin() );
int newsizemax_index = 0;
- for (int i=0;i<3;i++) {
+ for (int i=0;i<N.dim;i++) {
if (node.newsize[i]) {
if (bbox_size[i]==NT3(0)) {
PRINT("WARNING: Resize in direction normal to flat object is not implemented");
@@ -229,8 +229,11 @@ CGAL_Nef_polyhedron CGALEvaluator::applyResize(const CgaladvNode &node)
newsizemax_index = i;
}
}
- NT3 autoscale = NT3( node.newsize[ newsizemax_index ] ) / bbox_size[ newsizemax_index ];
- for (int i=0;i<3;i++) {
+
+ NT3 autoscale = NT3( 1 );
+ if ( node.newsize[ newsizemax_index ] != 0 )
+ autoscale = NT3( node.newsize[ newsizemax_index ] ) / bbox_size[ newsizemax_index ];
+ for (int i=0;i<N.dim;i++) {
if (node.autosize[i] && node.newsize[i]==0)
scale[i] = autoscale;
}
diff --git a/src/PlatformUtils.cc b/src/PlatformUtils.cc
index 5dd007d..ccc2bc0 100644
--- a/src/PlatformUtils.cc
+++ b/src/PlatformUtils.cc
@@ -38,3 +38,46 @@ std::string PlatformUtils::libraryPath()
}
return boosty::stringy( path );
}
+
+#include "version_check.h"
+#define STRINGIFY(x) #x
+#define TOSTRING(x) STRINGIFY(x)
+std::string PlatformUtils::info()
+{
+ std::stringstream s;
+
+#if defined(__GNUG__) && !defined(__clang__)
+ std::string compiler_info( "GCC " + std::string(TOSTRING(__VERSION__)) );
+#elif defined(_MSC_VER)
+ std::string compiler_info( "MSVC " + std::string(TOSTRING(_MSC_FULL_VER)) );
+#elif defined(__clang__)
+ std::string compiler_info( "Clang " + std::string(TOSTRING(__clang_version__)) );
+#else
+ std::string compiler_info( "unknown compiler" );
+#endif
+
+#if defined( __MINGW64__ )
+ std::string mingwstatus("MingW64");
+#elif defined( __MINGW32__ )
+ std::string mingwstatus("MingW32");
+#else
+ std::string mingwstatus("No");
+#endif
+
+#ifndef OPENCSG_VERSION_STRING
+#define OPENCSG_VERSION_STRING "unknown, <1.3.2"
+#endif
+
+ s << "OpenSCAD Version: " << TOSTRING(OPENSCAD_VERSION)
+ << "\nCompiler: " << compiler_info
+ << "\nCompile date: " << __DATE__
+ << "\nBoost version: " << BOOST_LIB_VERSION
+ << "\nEigen version: " << EIGEN_WORLD_VERSION << "." << EIGEN_MAJOR_VERSION << "." << EIGEN_MINOR_VERSION
+ << "\nCGAL version: " << TOSTRING(CGAL_VERSION)
+ << "\nOpenCSG version: " << OPENCSG_VERSION_STRING
+ << "\nQt version: " << qVersion()
+ << "\nMingW build: " << mingwstatus;
+
+ return s.str();
+}
+
diff --git a/src/PlatformUtils.h b/src/PlatformUtils.h
index 089b3ca..18dd5fa 100644
--- a/src/PlatformUtils.h
+++ b/src/PlatformUtils.h
@@ -8,7 +8,7 @@ namespace PlatformUtils {
std::string documentsPath();
std::string libraryPath();
bool createLibraryPath();
-
+ std::string info();
}
#endif
diff --git a/src/export.h b/src/export.h
index a565561..5dae7e0 100644
--- a/src/export.h
+++ b/src/export.h
@@ -12,6 +12,7 @@ void export_off(CGAL_Nef_polyhedron *root_N, std::ostream &output);
void export_dxf(CGAL_Nef_polyhedron *root_N, std::ostream &output);
void export_png_with_cgal(CGAL_Nef_polyhedron *root_N, Camera &c, std::ostream &output);
void export_png_with_opencsg(Tree &tree, Camera &c, std::ostream &output);
+void export_png_with_throwntogether(Tree &tree, Camera &c, std::ostream &output);
#endif
diff --git a/src/export_png.cc b/src/export_png.cc
index c6c191c..744d681 100644
--- a/src/export_png.cc
+++ b/src/export_png.cc
@@ -41,26 +41,25 @@ void export_png_with_cgal(CGAL_Nef_polyhedron *root_N, Camera &cam, std::ostream
cam.eye = cam.center - radius*2*cameradir;
}
- //std::cerr << center << "\n";
- //std::cerr << radius << "\n";
-
glview->setCamera( cam );
glview->setRenderer(&cgalRenderer);
glview->paintGL();
glview->save(output);
}
+enum Previewer { OPENCSG, THROWN } previewer;
+
#ifdef ENABLE_OPENCSG
#include "OpenCSGRenderer.h"
#include <opencsg.h>
#endif
+#include "ThrownTogetherRenderer.h"
-void export_png_with_opencsg(Tree &tree, Camera &cam, std::ostream &output)
+void export_png_preview_common( Tree &tree, Camera &cam, std::ostream &output, Previewer previewer = OPENCSG )
{
-#ifdef ENABLE_OPENCSG
- CsgInfo csgInfo = CsgInfo();
- if ( !csgInfo.compile_chains( tree ) ) {
- fprintf(stderr,"Couldn't initialize OpenCSG chains\n");
+ CsgInfo csgInfo = CsgInfo();
+ if ( !csgInfo.compile_chains( tree ) ) {
+ fprintf(stderr,"Couldn't initialize CSG chains\n");
return;
}
@@ -71,7 +70,16 @@ void export_png_with_opencsg(Tree &tree, Camera &cam, std::ostream &output)
return;
}
- OpenCSGRenderer opencsgRenderer(csgInfo.root_chain, csgInfo.highlights_chain, csgInfo.background_chain, csgInfo.glview->shaderinfo);
+ Renderer *renderer;
+ if ( previewer == OPENCSG ) {
+#ifdef ENABLE_OPENCSG
+ OpenCSGRenderer openCSGRenderer(csgInfo.root_chain, csgInfo.highlights_chain, csgInfo.background_chain, csgInfo.glview->shaderinfo);
+ renderer = &openCSGRenderer;
+#endif
+ } else {
+ ThrownTogetherRenderer thrownTogetherRenderer( csgInfo.root_chain, csgInfo.highlights_chain, csgInfo.background_chain );
+ renderer = &thrownTogetherRenderer;
+ }
if (cam.type == Camera::NONE) {
cam.type = Camera::VECTOR;
@@ -86,15 +94,28 @@ void export_png_with_opencsg(Tree &tree, Camera &cam, std::ostream &output)
}
csgInfo.glview->setCamera( cam );
- csgInfo.glview->setRenderer(&opencsgRenderer);
- OpenCSG::setContext(0);
- OpenCSG::setOption(OpenCSG::OffscreenSetting, OpenCSG::FrameBufferObject);
+ csgInfo.glview->setRenderer( renderer );
+#ifdef ENABLE_OPENCSG
+ OpenCSG::setContext( 0 );
+ OpenCSG::setOption( OpenCSG::OffscreenSetting, OpenCSG::FrameBufferObject );
+#endif
csgInfo.glview->paintGL();
- csgInfo.glview->save(output);
+ csgInfo.glview->save( output );
+}
+
+void export_png_with_opencsg(Tree &tree, Camera &cam, std::ostream &output)
+{
+#ifdef ENABLE_OPENCSG
+ export_png_preview_common( tree, cam, output, OPENCSG );
#else
fprintf(stderr,"This openscad was built without OpenCSG support\n");
#endif
}
+void export_png_with_throwntogether(Tree &tree, Camera &cam, std::ostream &output)
+{
+ export_png_preview_common( tree, cam, output, THROWN );
+}
+
#endif // ENABLE_CGAL
diff --git a/src/mainwin.cc b/src/mainwin.cc
index 3d50d6f..783772c 100644
--- a/src/mainwin.cc
+++ b/src/mainwin.cc
@@ -101,10 +101,6 @@
#endif // ENABLE_CGAL
-#ifndef OPENCSG_VERSION_STRING
-#define OPENCSG_VERSION_STRING "unknown, <1.3.2"
-#endif
-
#include "boosty.h"
extern QString examplesdir;
@@ -1828,34 +1824,16 @@ MainWindow::helpManual()
QDesktopServices::openUrl(QUrl("http://www.openscad.org/documentation.html"));
}
-#define STRINGIFY(x) #x
-#define TOSTRING(x) STRINGIFY(x)
void MainWindow::helpLibrary()
{
- QString libinfo;
- libinfo.sprintf("Boost version: %s\n"
- "Eigen version: %d.%d.%d\n"
- "CGAL version: %s\n"
- "OpenCSG version: %s\n"
- "Qt version: %s\n\n",
- BOOST_LIB_VERSION,
- EIGEN_WORLD_VERSION, EIGEN_MAJOR_VERSION, EIGEN_MINOR_VERSION,
- TOSTRING(CGAL_VERSION),
- OPENCSG_VERSION_STRING,
- qVersion());
-
-#if defined( __MINGW64__ )
- libinfo += QString("Compiled for MingW64\n\n");
-#elif defined( __MINGW32__ )
- libinfo += QString("Compiled for MingW32\n\n");
-#endif
-
+ QString info( PlatformUtils::info().c_str() );
+ info += QString( qglview->getRendererInfo().c_str() );
if (!this->openglbox) {
- this->openglbox = new QMessageBox(QMessageBox::Information,
- "OpenGL Info", "OpenSCAD Detailed Library Info ",
+ this->openglbox = new QMessageBox(QMessageBox::Information,
+ "OpenGL Info", "OpenSCAD Detailed Library and Build Information",
QMessageBox::Ok, this);
}
- this->openglbox->setDetailedText(libinfo + QString(qglview->getRendererInfo().c_str()));
+ this->openglbox->setDetailedText( info );
this->openglbox->show();
}
diff --git a/src/openscad.cc b/src/openscad.cc
index 2fe5cde..fb5ee44 100644
--- a/src/openscad.cc
+++ b/src/openscad.cc
@@ -37,6 +37,7 @@
#include "handle_dep.h"
#include "parsersettings.h"
#include "rendersettings.h"
+#include "PlatformUtils.h"
#include <string>
#include <vector>
@@ -50,6 +51,7 @@
#include "csgterm.h"
#include "CSGTermEvaluator.h"
+#include "CsgInfo.h"
#include <QApplication>
#include <QString>
@@ -82,12 +84,13 @@ static void help(const char *progname)
{
int tab = int(strlen(progname))+8;
fprintf(stderr,"Usage: %s [ -o output_file [ -d deps_file ] ]\\\n"
- "%*s[ -m make_command ] [ -D var=val [..] ] [ --render ] \\\n"
+ "%*s[ -m make_command ] [ -D var=val [..] ] \\\n"
"%*s[ --camera=translatex,y,z,rotx,y,z,dist | \\\n"
"%*s --camera=eyex,y,z,centerx,y,z ] \\\n"
"%*s[ --imgsize=width,height ] [ --projection=(o)rtho|(p)ersp] \\\n"
+ "%*s[ --render | --preview[=throwntogether] ] \\\n"
"%*sfilename\n",
- progname, tab, "", tab, "", tab, "", tab, "", tab, "");
+ progname, tab, "", tab, "", tab, "", tab, "", tab, "", tab, "");
exit(1);
}
@@ -99,6 +102,23 @@ static void version()
exit(1);
}
+static void info()
+{
+ std::cout << PlatformUtils::info() << "\n\n";
+
+ CsgInfo csgInfo = CsgInfo();
+ try {
+ csgInfo.glview = new OffscreenView(512,512);
+ } catch (int error) {
+ fprintf(stderr,"Can't create OpenGL OffscreenView. Code: %i. Exiting.\n", error);
+ exit(1);
+ }
+
+ std::cout << csgInfo.glview->getRendererInfo() << "\n";
+
+ exit(0);
+}
+
std::string commandline_commands;
std::string currentdir;
QString examplesdir;
@@ -203,7 +223,9 @@ int main(int argc, char **argv)
desc.add_options()
("help,h", "help message")
("version,v", "print the version")
+ ("info", "print information about the building process")
("render", "if exporting a png image, do a full CGAL render")
+ ("preview", po::value<string>(), "if exporting a png image, do an OpenCSG(default) or ThrownTogether preview")
("camera", po::value<string>(), "parameters for camera when exporting png")
("imgsize", po::value<string>(), "=width,height for exporting png")
("projection", po::value<string>(), "(o)rtho or (p)erspective when exporting png")
@@ -235,6 +257,7 @@ int main(int argc, char **argv)
if (vm.count("help")) help(argv[0]);
if (vm.count("version")) version();
+ if (vm.count("info")) info();
if (vm.count("o")) {
// FIXME: Allow for multiple output files?
@@ -517,6 +540,8 @@ int main(int argc, char **argv)
else {
if (vm.count("render")) {
export_png_with_cgal(&root_N, camera, fstream);
+ } else if (vm.count("preview") && vm["preview"].as<string>() == "throwntogether" ) {
+ export_png_with_throwntogether(tree, camera, fstream);
} else {
export_png_with_opencsg(tree, camera, fstream);
}
contact: Jan Huwald // Impressum