cmdline throwntogether, integrate w chrysn tests, update resize tests

issue480
Don Bright 2013-09-12 00:17:17 -05:00
parent b53dde04e2
commit 6af6c311a1
17 changed files with 176 additions and 95 deletions

View File

@ -48,9 +48,6 @@ variable's value is an expression, so if this mechanism is used to assign
strings, care has to be taken that the shell does not consume quotation marks.
More than one \fB-D\fP options can be given.
.TP
.B \-v, \-\-version
Show version of program.
.TP
.B \-\-render
If exporting an image, use a full CGAL render. (Default is an OpenCSG compile)
.TP
@ -72,6 +69,13 @@ If exporting an image, specify the pixel width and height
.B \-\-projection=[o|p]
If exporting an image, specify whether to use orthographic or perspective
projection
.TP
.B \-v, \-\-version
Show version of program.
.TP
.B \-\-info
Show which versions of libraries were used to compile the program, and which
OpenGL details are discovered.
.SH COMMAND LINE EXAMPLES
.PP

View File

@ -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();
}

View File

@ -4,11 +4,10 @@
#include <string>
namespace PlatformUtils {
std::string documentsPath();
std::string libraryPath();
bool createLibraryPath();
std::string info();
}
#endif

View File

@ -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

View File

@ -96,5 +96,42 @@ void export_png_with_opencsg(Tree &tree, Camera &cam, std::ostream &output)
#endif
}
#include "ThrownTogetherRenderer.h"
void export_png_with_throwntogether(Tree &tree, Camera &cam, std::ostream &output)
{
CsgInfo csgInfo = CsgInfo();
if ( !csgInfo.compile_chains( tree ) ) {
fprintf(stderr,"Couldn't initialize OpenCSG chains\n");
return;
}
try {
csgInfo.glview = new OffscreenView( cam.pixel_width, cam.pixel_height );
} catch (int error) {
fprintf(stderr,"Can't create OpenGL OffscreenView. Code: %i.\n", error);
return;
}
ThrownTogetherRenderer thrownTogetherRenderer( csgInfo.root_chain,
csgInfo.highlights_chain, csgInfo.background_chain );
if (cam.type == Camera::NONE) {
cam.type = Camera::VECTOR;
double radius = 1.0;
if (csgInfo.root_chain) {
BoundingBox bbox = csgInfo.root_chain->getBoundingBox();
cam.center = (bbox.min() + bbox.max()) / 2;
radius = (bbox.max() - bbox.min()).norm() / 2;
}
Vector3d cameradir(1, 1, -0.5);
cam.eye = cam.center - radius*1.8*cameradir;
}
csgInfo.glview->setCamera( cam );
csgInfo.glview->setRenderer(&thrownTogetherRenderer);
csgInfo.glview->paintGL();
csgInfo.glview->save(output);
}
#endif // ENABLE_CGAL

View File

@ -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,18 @@ 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
std::string basicinfo = PlatformUtils::info();
QString info( basicinfo.c_str() );
info += QString(qglview->getRendererInfo().c_str());
if (!this->openglbox) {
this->openglbox = new QMessageBox(QMessageBox::Information,
"OpenGL Info", "OpenSCAD Detailed Library Info ",
QMessageBox::Ok, this);
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();
}

View File

@ -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;
@ -199,7 +219,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")
@ -231,6 +253,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?
@ -513,6 +536,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);
}

View File

@ -544,9 +544,9 @@ target_link_libraries(cgalcachetest tests-cgal ${TESTS-CGAL-LIBRARIES} ${GLEW_LI
# throwntogethertest
#
add_executable(throwntogethertest throwntogethertest.cc csgtestcore.cc ../src/OpenCSGRenderer.cc ../src/ThrownTogetherRenderer.cc ../src/renderer.cc ../src/rendersettings.cc)
set_target_properties(throwntogethertest PROPERTIES COMPILE_FLAGS "-DENABLE_OPENCSG -DENABLE_CGAL ${CGAL_CXX_FLAGS_INIT}")
target_link_libraries(throwntogethertest tests-offscreen tests-cgal ${OPENCSG_LIBRARY} ${TESTS-CGAL-LIBRARIES} ${GLEW_LIBRARY} ${COCOA_LIBRARY})
#add_executable(throwntogethertest throwntogethertest.cc csgtestcore.cc ../src/OpenCSGRenderer.cc ../src/ThrownTogetherRenderer.cc ../src/renderer.cc ../src/rendersettings.cc)
#set_target_properties(throwntogethertest PROPERTIES COMPILE_FLAGS "-DENABLE_OPENCSG -DENABLE_CGAL ${CGAL_CXX_FLAGS_INIT}")
#target_link_libraries(throwntogethertest tests-offscreen tests-cgal ${OPENCSG_LIBRARY} ${TESTS-CGAL-LIBRARIES} ${GLEW_LIBRARY} ${COCOA_LIBRARY})
#
# GUI binary tests
@ -836,6 +836,7 @@ string(REPLACE __cmake_current_source_dir__ ${CMAKE_CURRENT_SOURCE_DIR} TMP ${TM
string(REPLACE __python__ ${PYTHON_EXECUTABLE} TMP ${TMP})
string(REPLACE __header__ "Generated by cmake from ${CMAKE_CURRENT_SOURCE_DIR}/CTestCustom.template" TMP ${TMP})
string(REPLACE __cmake_system_name__ ${CMAKE_SYSTEM_NAME} TMP ${TMP})
string(REPLACE __gui_binpath__ ${GUI_BINPATH} TMP ${TMP})
if (MINGW_CROSS_ENV_DIR)
string(REPLACE __wine__ wine TMP ${TMP})
@ -864,7 +865,8 @@ add_cmdline_test(csgtermtest EXE ${GUI_BINPATH} ARGS -o SUFFIX term FILES
${CMAKE_SOURCE_DIR}/../testdata/scad/misc/allmodules.scad)
add_cmdline_test(cgalpngtest EXE ${GUI_BINPATH} ARGS --render -o SUFFIX png FILES ${CGALPNGTEST_FILES})
add_cmdline_test(opencsgtest EXE ${GUI_BINPATH} ARGS -o SUFFIX png FILES ${OPENCSGTEST_FILES})
add_cmdline_test(throwntogethertest SUFFIX png FILES ${THROWNTOGETHERTEST_FILES})
add_cmdline_test(throwntogethertest EXE ${GUI_BINPATH} ARGS --preview=throwntogether -o SUFFIX png FILES ${THROWNTOGETHERTEST_FILES})
#add_cmdline_test(throwntogethertest SUFFIX png FILES ${THROWNTOGETHERTEST_FILES})
# FIXME: We don't actually need to compare the output of cgalstlsanitytest
# with anything. It's self-contained and returns != 0 on error
add_cmdline_test(cgalstlsanitytest EXE ${CMAKE_SOURCE_DIR}/cgalstlsanitytest SUFFIX txt ARGS ${GUI_BINPATH} FILES ${CGALSTLSANITYTEST_FILES})

View File

@ -58,8 +58,8 @@ endif()
# Part 1. Pretty Printing
message("running 'opencsgtest --info' to generate sysinfo.txt")
execute_process(COMMAND __wine__ __cmake_current_binary_dir__/opencsgtest --info OUTPUT_FILE sysinfo.txt)
message("running '__gui_binpath__ --info' to generate sysinfo.txt")
execute_process(COMMAND __wine__ __gui_binpath__ --info OUTPUT_FILE sysinfo.txt)
set(CTEST_CUSTOM_POST_TEST ${CTEST_CUSTOM_POST_TEST} "__cmake_current_binary_dir__/test_pretty_print")
if ( ${debug_openscad_template} )

View File

@ -44,45 +44,11 @@ std::string commandline_commands;
//#define DEBUG
string info_dump(OffscreenView *glview)
{
assert(glview);
#ifdef __GNUG__
#define compiler_info "GCC " << __VERSION__
#elif defined(_MSC_VER)
#define compiler_info "MSVC " << _MSC_FULL_VER
#else
#define compiler_info "unknown compiler"
#endif
#ifndef OPENCSG_VERSION_STRING
#define OPENCSG_VERSION_STRING "unknown, <1.3.2"
#endif
std::stringstream out;
#define STRINGIFY(x) #x
#define TOSTRING(x) STRINGIFY(x)
out << "\nOpenSCAD Version: " << TOSTRING(OPENSCAD_VERSION)
<< "\nCompiled by: " << 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
<< "\n" << glview->getRendererInfo()
<< "\n";
return out.str();
}
po::variables_map parse_options(int argc, char *argv[])
{
po::options_description desc("Allowed options");
desc.add_options()
("help,h", "help message")//;
("info,i", "information on GLEW, OpenGL, OpenSCAD, and OS")//;
// po::options_description hidden("Hidden options");
// hidden.add_options()
@ -104,7 +70,6 @@ po::variables_map parse_options(int argc, char *argv[])
int csgtestcore(int argc, char *argv[], test_type_e test_type)
{
bool sysinfo_dump = false;
const char *filename, *outfilename = NULL;
po::variables_map vm;
try {
@ -112,13 +77,12 @@ int csgtestcore(int argc, char *argv[], test_type_e test_type)
} catch ( po::error e ) {
cerr << "error parsing options\n";
}
if (vm.count("info")) sysinfo_dump = true;
if (vm.count("input-file"))
filename = vm["input-file"].as< vector<string> >().begin()->c_str();
if (vm.count("output-file"))
outfilename = vm["output-file"].as< vector<string> >().begin()->c_str();
if ((!filename || !outfilename) && !sysinfo_dump) {
if ((!filename || !outfilename)) {
cerr << "Usage: " << argv[0] << " <file.scad> <output.png>\n";
exit(1);
}
@ -138,21 +102,16 @@ int csgtestcore(int argc, char *argv[], test_type_e test_type)
FileModule *root_module;
ModuleInstantiation root_inst("group");
if (sysinfo_dump)
root_module = parse("sphere();","",false);
else
root_module = parsefile(filename);
root_module = parsefile(filename);
if (!root_module) {
exit(1);
}
if (!sysinfo_dump) {
fs::path fpath = boosty::absolute(fs::path(filename));
fs::path fparent = fpath.parent_path();
fs::current_path(fparent);
top_ctx.setDocumentPath(fparent.string());
}
fs::path fpath = boosty::absolute(fs::path(filename));
fs::path fparent = fpath.parent_path();
fs::current_path(fparent);
top_ctx.setDocumentPath(fparent.string());
AbstractNode::resetIndexCounter();
AbstractNode *absolute_root_node = root_module->instantiate(&top_ctx, &root_inst);
@ -174,7 +133,6 @@ int csgtestcore(int argc, char *argv[], test_type_e test_type)
exit(1);
}
if (sysinfo_dump) cout << info_dump(csgInfo.glview);
Camera camera(Camera::VECTOR);
camera.center << 0,0,0;
double radius = 1.0;

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.4 KiB

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.3 KiB

After

Width:  |  Height:  |  Size: 4.7 KiB

View File

@ -230,42 +230,74 @@ group() {
}
}
color([1, 0.752941, 0.796078, 1]) {
multmatrix([[1, 0, 0, 10], [0, 1, 0, 0], [0, 0, 1, -10], [0, 0, 0, 1]]) {
multmatrix([[1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, -10], [0, 0, 0, 1]]) {
resize(newsize = [4,4,4], auto = [0,0,0]) {
resize(newsize = [5000,100,1000], auto = [0,0,0]) {
cube(size = [1, 1, 1], center = false);
}
}
}
multmatrix([[1, 0, 0, 10], [0, 1, 0, 10], [0, 0, 1, -10], [0, 0, 0, 1]]) {
multmatrix([[1, 0, 0, 10], [0, 1, 0, 0], [0, 0, 1, -10], [0, 0, 0, 1]]) {
resize(newsize = [-5,0,0], auto = [0,0,0]) {
cube(size = [1, 1, 1], center = false);
}
}
multmatrix([[1, 0, 0, 10], [0, 1, 0, 20], [0, 0, 1, -10], [0, 0, 0, 1]]) {
multmatrix([[1, 0, 0, 20], [0, 1, 0, 0], [0, 0, 1, -10], [0, 0, 0, 1]]) {
resize(newsize = [-5,0,0], auto = [0,0,0]) {
cube(size = [1, 1, 1], center = false);
}
}
multmatrix([[1, 0, 0, 10], [0, 1, 0, 30], [0, 0, 1, -10], [0, 0, 0, 1]]) {
multmatrix([[1, 0, 0, 30], [0, 1, 0, 0], [0, 0, 1, -10], [0, 0, 0, 1]]) {
resize(newsize = [0,0,0], auto = [0,0,0]) {
cube(size = [1, 1, 1], center = false);
}
}
multmatrix([[1, 0, 0, 10], [0, 1, 0, 40], [0, 0, 1, -10], [0, 0, 0, 1]]) {
multmatrix([[1, 0, 0, 40], [0, 1, 0, 0], [0, 0, 1, -10], [0, 0, 0, 1]]) {
resize(newsize = [0,0,0], auto = [0,0,0]) {
cube(size = [1, 1, 1], center = false);
}
}
multmatrix([[1, 0, 0, 10], [0, 1, 0, 50], [0, 0, 1, -10], [0, 0, 0, 1]]) {
multmatrix([[1, 0, 0, 50], [0, 1, 0, 0], [0, 0, 1, -10], [0, 0, 0, 1]]) {
resize(newsize = [0.5,0,7], auto = [0,0,0]) {
cube(size = [0.5, 1, 1000], center = false);
}
}
multmatrix([[1, 0, 0, 10], [0, 1, 0, 60], [0, 0, 1, -10], [0, 0, 0, 1]]) {
multmatrix([[1, 0, 0, 60], [0, 1, 0, 0], [0, 0, 1, -10], [0, 0, 0, 1]]) {
resize(newsize = [0,0,0.5], auto = [0,0,0]) {
cube(size = [6, 6, 1e+10], center = false);
}
}
}
color([0, 1, 0, 1]) {
multmatrix([[1, 0, 0, 20], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]) {
resize(newsize = [5,0,0], auto = [1,1,0]) {
cube(size = [9, 9, 9], center = false);
}
}
multmatrix([[1, 0, 0, 30], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]) {
resize(newsize = [6,0,0], auto = [1,1,1]) {
cube(size = [9, 9, 9], center = false);
}
}
multmatrix([[1, 0, 0, 40], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]) {
resize(newsize = [6,0,0], auto = [1,0,1]) {
cube(size = [9, 9, 9], center = false);
}
}
multmatrix([[1, 0, 0, 50], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]) {
resize(newsize = [5,0,20], auto = [0,1,1]) {
cube(size = [9, 9, 9], center = false);
}
}
multmatrix([[1, 0, 0, 60], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]) {
resize(newsize = [0,0,7], auto = [0,0,1]) {
cube(size = [9, 9, 9], center = false);
}
}
multmatrix([[1, 0, 0, 70], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]) {
resize(newsize = [6,0,0], auto = [1,1,0]) {
cube(size = [9, 9, 9], center = false);
}
}
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.2 KiB

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.0 KiB

After

Width:  |  Height:  |  Size: 5.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.2 KiB

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.0 KiB

After

Width:  |  Height:  |  Size: 5.5 KiB