From ef51ee8a7fc855bd06f82ac24fdcab5fa2a98815 Mon Sep 17 00:00:00 2001 From: don bright Date: Sun, 19 Aug 2012 16:36:49 -0500 Subject: use the CGAL triangulation with intersections enabled. attempt to fix issue #159 diff --git a/src/dxftess-cgal.cc b/src/dxftess-cgal.cc index f221e3a..9cd3bfd 100644 --- a/src/dxftess-cgal.cc +++ b/src/dxftess-cgal.cc @@ -24,7 +24,7 @@ typedef CGAL::Exact_predicates_inexact_constructions_kernel K; typedef CGAL::Triangulation_vertex_base_2 Vb; typedef CGAL::Delaunay_mesh_face_base_2 Fb; typedef CGAL::Triangulation_data_structure_2 Tds; -typedef CGAL::Constrained_Delaunay_triangulation_2 CDT; +typedef CGAL::Constrained_Delaunay_triangulation_2 CDT; //typedef CGAL::Delaunay_mesh_criteria_2 Criteria; typedef CDT::Vertex_handle Vertex_handle; -- cgit v0.10.1 From f16d3a65a1176475f0c71676d6bf0640fabe45c6 Mon Sep 17 00:00:00 2001 From: don bright Date: Sun, 19 Aug 2012 16:43:04 -0500 Subject: print only a single warning about intersecting vertices at dxf tessellation , instead of spamming it over and over. also mention that it might be due to intersecting lines, not just duplicate vertices (duplicate vertices being perhaps generated by cgal's tessellator when it deals with intersecting lines) diff --git a/src/dxftess-cgal.cc b/src/dxftess-cgal.cc index 9cd3bfd..506b34a 100644 --- a/src/dxftess-cgal.cc +++ b/src/dxftess-cgal.cc @@ -109,6 +109,7 @@ void dxf_tesselate(PolySet *ps, DxfData &dxf, double rot, bool up, bool /* do_tr Grid2d point_info(GRID_FINE); boost::unordered_map edge_to_triangle; boost::unordered_map edge_to_path; + int duplicate_vertices = 0; CGAL::Failure_behaviour old_behaviour = CGAL::set_error_behaviour(CGAL::THROW_EXCEPTION); try { @@ -131,7 +132,7 @@ void dxf_tesselate(PolySet *ps, DxfData &dxf, double rot, bool up, bool /* do_tr // ..maybe it would be better to assert here. But this would // break compatibility with the glu tesselator that handled such // cases just fine. - PRINT( "WARNING: Duplicate vertex found during Tessellation. Render may be incorrect." ); + duplicate_vertices++; continue; } @@ -165,6 +166,9 @@ void dxf_tesselate(PolySet *ps, DxfData &dxf, double rot, bool up, bool /* do_tr } } + if ( duplicate_vertices > 0 ) + PRINTB( "WARNING: duplicate vertices and/or intersecting lines found during DXF Tessellation. Render may be incorrect.", duplicate_vertices ); + } catch (CGAL::Assertion_exception e) { PRINTB("CGAL error in dxf_tesselate(): %s", e.what()); -- cgit v0.10.1 From 40149978574a58ac421373e58e1f77478fdd4f67 Mon Sep 17 00:00:00 2001 From: don bright Date: Sun, 19 Aug 2012 16:45:24 -0500 Subject: fix print statement diff --git a/src/dxftess-cgal.cc b/src/dxftess-cgal.cc index 506b34a..5ddcfbf 100644 --- a/src/dxftess-cgal.cc +++ b/src/dxftess-cgal.cc @@ -167,7 +167,7 @@ void dxf_tesselate(PolySet *ps, DxfData &dxf, double rot, bool up, bool /* do_tr } if ( duplicate_vertices > 0 ) - PRINTB( "WARNING: duplicate vertices and/or intersecting lines found during DXF Tessellation. Render may be incorrect.", duplicate_vertices ); + PRINT( "WARNING: duplicate vertices and/or intersecting lines found during DXF Tessellation. Render may be incorrect." ); } catch (CGAL::Assertion_exception e) { -- cgit v0.10.1 From b4c023d84bc8d2732eb0ae7349146e5c8b0fbd5f Mon Sep 17 00:00:00 2001 From: don bright Date: Sun, 19 Aug 2012 16:49:37 -0500 Subject: Capitalize 'duplicate' diff --git a/src/dxftess-cgal.cc b/src/dxftess-cgal.cc index 5ddcfbf..df04b5b 100644 --- a/src/dxftess-cgal.cc +++ b/src/dxftess-cgal.cc @@ -167,7 +167,7 @@ void dxf_tesselate(PolySet *ps, DxfData &dxf, double rot, bool up, bool /* do_tr } if ( duplicate_vertices > 0 ) - PRINT( "WARNING: duplicate vertices and/or intersecting lines found during DXF Tessellation. Render may be incorrect." ); + PRINT( "WARNING: Duplicate vertices and/or intersecting lines found during DXF Tessellation. Render may be incorrect." ); } catch (CGAL::Assertion_exception e) { -- cgit v0.10.1 From 5c779159c208ca3d88c88479ab29f9cd66574859 Mon Sep 17 00:00:00 2001 From: don bright Date: Tue, 8 Jan 2013 05:06:26 +0100 Subject: new test results (degenerate polygons produce output) diff --git a/tests/regression/cgalpngtest/polygon-intersect-expected.png b/tests/regression/cgalpngtest/polygon-intersect-expected.png index 6f4f437..54e8d6b 100644 Binary files a/tests/regression/cgalpngtest/polygon-intersect-expected.png and b/tests/regression/cgalpngtest/polygon-intersect-expected.png differ diff --git a/tests/regression/cgalpngtest/polygon-mesh-expected.png b/tests/regression/cgalpngtest/polygon-mesh-expected.png index 6f4f437..a8fe41a 100644 Binary files a/tests/regression/cgalpngtest/polygon-mesh-expected.png and b/tests/regression/cgalpngtest/polygon-mesh-expected.png differ diff --git a/tests/regression/cgalpngtest/polygon-self-intersect-expected.png b/tests/regression/cgalpngtest/polygon-self-intersect-expected.png index 6f4f437..b93b5fb 100644 Binary files a/tests/regression/cgalpngtest/polygon-self-intersect-expected.png and b/tests/regression/cgalpngtest/polygon-self-intersect-expected.png differ diff --git a/tests/regression/opencsgtest/polygon-intersect-expected.png b/tests/regression/opencsgtest/polygon-intersect-expected.png index 6f4f437..c0a3cc9 100644 Binary files a/tests/regression/opencsgtest/polygon-intersect-expected.png and b/tests/regression/opencsgtest/polygon-intersect-expected.png differ diff --git a/tests/regression/opencsgtest/polygon-mesh-expected.png b/tests/regression/opencsgtest/polygon-mesh-expected.png index 6f4f437..b907a74 100644 Binary files a/tests/regression/opencsgtest/polygon-mesh-expected.png and b/tests/regression/opencsgtest/polygon-mesh-expected.png differ diff --git a/tests/regression/opencsgtest/polygon-self-intersect-expected.png b/tests/regression/opencsgtest/polygon-self-intersect-expected.png index 6f4f437..899bb6f 100644 Binary files a/tests/regression/opencsgtest/polygon-self-intersect-expected.png and b/tests/regression/opencsgtest/polygon-self-intersect-expected.png differ diff --git a/tests/regression/throwntogethertest/polygon-intersect-expected.png b/tests/regression/throwntogethertest/polygon-intersect-expected.png index 81eb514..d889f06 100644 Binary files a/tests/regression/throwntogethertest/polygon-intersect-expected.png and b/tests/regression/throwntogethertest/polygon-intersect-expected.png differ diff --git a/tests/regression/throwntogethertest/polygon-mesh-expected.png b/tests/regression/throwntogethertest/polygon-mesh-expected.png index 81eb514..1c2751c 100644 Binary files a/tests/regression/throwntogethertest/polygon-mesh-expected.png and b/tests/regression/throwntogethertest/polygon-mesh-expected.png differ diff --git a/tests/regression/throwntogethertest/polygon-self-intersect-expected.png b/tests/regression/throwntogethertest/polygon-self-intersect-expected.png index 81eb514..ebce31e 100644 Binary files a/tests/regression/throwntogethertest/polygon-self-intersect-expected.png and b/tests/regression/throwntogethertest/polygon-self-intersect-expected.png differ -- cgit v0.10.1 From 1af090c7b3a56b24851712a1ae41321358a8aac4 Mon Sep 17 00:00:00 2001 From: don bright Date: Mon, 21 Jan 2013 14:25:14 +0100 Subject: add wrapper code from nop head, mod build scripts diff --git a/openscad.pro b/openscad.pro index b11f45b..a7088ec 100644 --- a/openscad.pro +++ b/openscad.pro @@ -344,3 +344,8 @@ INSTALLS += applications icons.path = $$PREFIX/share/pixmaps icons.files = icons/openscad.png INSTALLS += icons + +CONFIG(winconsole) { + include(winconsole.pri) +} + diff --git a/scripts/installer.nsi b/scripts/installer.nsi index 87ec18d..1841431 100644 --- a/scripts/installer.nsi +++ b/scripts/installer.nsi @@ -6,6 +6,7 @@ DirText "This will install OpenSCAD on your computer. Choose a directory" Section "install" SetOutPath $INSTDIR File openscad.exe +File openscad.com File /r /x mingw-cross-env examples File /r /x mingw-cross-env libraries ${registerExtension} "$INSTDIR\openscad.exe" ".scad" "OpenSCAD_File" diff --git a/scripts/release-common.sh b/scripts/release-common.sh index ae856df..de14cb1 100755 --- a/scripts/release-common.sh +++ b/scripts/release-common.sh @@ -166,7 +166,14 @@ fi case $OS in LINXWIN) # dont use paralell builds, it can error-out on parser_yacc. + + # make main openscad.exe cd $DEPLOYDIR && make $TARGET + + # make console pipe-able openscad.com - see winconsole.pri for info + i686-pc-mingw32-qmake CONFIG+=winconsole ../openscad.pro + make + cd $OPENSCADDIR ;; *) @@ -232,6 +239,7 @@ case $OS in #package cp win32deps/* openscad-$VERSION cp $TARGET/openscad.exe openscad-$VERSION + cp $TARGET/openscad.com openscad-$VERSION rm -f openscad-$VERSION.zip "$ZIP" $ZIPARGS openscad-$VERSION.zip openscad-$VERSION rm -rf openscad-$VERSION @@ -242,6 +250,7 @@ case $OS in echo "Creating binary package" cd $DEPLOYDIR cp $TARGET/openscad.exe openscad-$VERSION + cp $TARGET/openscad.com openscad-$VERSION rm -f OpenSCAD-$VERSION.zip "$ZIP" $ZIPARGS OpenSCAD-$VERSION.zip openscad-$VERSION cd $OPENSCADDIR diff --git a/src/winconsole.c b/src/winconsole.c new file mode 100644 index 0000000..2180e19 --- /dev/null +++ b/src/winconsole.c @@ -0,0 +1,146 @@ +// enable easy piping under windows command line, using the 'devenv' method +// http://stackoverflow.com/questions/493536/can-one-executable-be-both-a-console-and-gui-app +// http://blogs.msdn.com/b/oldnewthing/archive/2009/01/01/9259142.aspx +// http://blogs.msdn.com/b/junfeng/archive/2004/02/06/68531.aspx +// http://www.i18nguy.com/unicode/c-unicode.html + +/* + +Based on inkscapec by Jos Hirth work at http://kaioa.com +and Nop Head's OpenSCAD_cl at github.com + +Zero-clause BSD-style license (DGAF) + +Redistribution and use in source and binary forms, with or without +modification, are permitted. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +*/ + +#include +#include +#include +void HandleOutput(HANDLE hPipeRead); +DWORD WINAPI RedirThread(LPVOID lpvThreadParam); + +HANDLE hChildProcess=NULL; +HANDLE hStdIn=NULL; +BOOL bRunThread=TRUE; + +int main(int argc,char *argv[]){ + HANDLE hOutputReadTemp,hOutputRead,hOutputWrite; + HANDLE hInputWriteTemp,hInputRead,hInputWrite; + HANDLE hErrorWrite; + HANDLE hThread; + DWORD ThreadId; + SECURITY_ATTRIBUTES sa; + + sa.nLength=sizeof(SECURITY_ATTRIBUTES); + sa.lpSecurityDescriptor=NULL; + sa.bInheritHandle=TRUE; + + int i; + wchar_t cmd[32000]; + wcscat( cmd,L"\0" ); + wcscat( cmd,L"openscad.exe" ); + int wargc; + LPWSTR *wargv; + wargv = CommandLineToArgvW(GetCommandLineW(), &wargc); + if ( !wargv ) { + printf(" error in CommandLineToArgvW\n"); + return 1; + } + for(i=1;i Date: Tue, 22 Jan 2013 03:43:55 +0100 Subject: rewrite wrapper using popen. add 1 name to abt dialog diff --git a/src/AboutDialog.html b/src/AboutDialog.html index 34e8127..47493bb 100644 --- a/src/AboutDialog.html +++ b/src/AboutDialog.html @@ -115,7 +115,7 @@ Brett Sutton, hmnapier, Eero af Heurlin, caliston, 5263, ghost, 42loop, uniqx, Michael Thomson, Michael Ivko, Pierre Doucet, myglc2, Alan Cox, Peter Falke, Michael Ambrus, Gordon Wrigley, Ed Nisley, Stony Smith, Pasca Andrei, David Goodenough, William A Adams, mrrobinson, 1i7, -benhowes ... and many others +benhowes, Craig Trader, Miro Hrončok, ... and many others

Hosting & resources diff --git a/src/winconsole.c b/src/winconsole.c index 2180e19..296bb31 100644 --- a/src/winconsole.c +++ b/src/winconsole.c @@ -1,146 +1,71 @@ -// enable easy piping under windows command line, using the 'devenv' method -// http://stackoverflow.com/questions/493536/can-one-executable-be-both-a-console-and-gui-app -// http://blogs.msdn.com/b/oldnewthing/archive/2009/01/01/9259142.aspx -// http://blogs.msdn.com/b/junfeng/archive/2004/02/06/68531.aspx -// http://www.i18nguy.com/unicode/c-unicode.html - /* - -Based on inkscapec by Jos Hirth work at http://kaioa.com -and Nop Head's OpenSCAD_cl at github.com - -Zero-clause BSD-style license (DGAF) - -Redistribution and use in source and binary forms, with or without -modification, are permitted. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - + enable easy piping under windows command line, using the 'devenv' method + http://stackoverflow.com/questions/493536/can-one-executable-be-both-a-console-and-gui-app + http://blogs.msdn.com/b/oldnewthing/archive/2009/01/01/9259142.aspx + http://blogs.msdn.com/b/junfeng/archive/2004/02/06/68531.aspx + http://msdn.microsoft.com/en-us/library/aa298534%28v=vs.60%29.aspx + http://www.i18nguy.com/unicode/c-unicode.html + http://cournape.wordpress.com/2008/07/29/redirecting-stderrstdout-in-cmdexe/ + Open Group popen() documentation + See Also: inkscapec by Jos Hirth work at http://kaioa.com + and Nop Head's OpenSCAD_cl at github.com */ -#include -#include -#include -void HandleOutput(HANDLE hPipeRead); -DWORD WINAPI RedirThread(LPVOID lpvThreadParam); - -HANDLE hChildProcess=NULL; -HANDLE hStdIn=NULL; -BOOL bRunThread=TRUE; - -int main(int argc,char *argv[]){ - HANDLE hOutputReadTemp,hOutputRead,hOutputWrite; - HANDLE hInputWriteTemp,hInputRead,hInputWrite; - HANDLE hErrorWrite; - HANDLE hThread; - DWORD ThreadId; - SECURITY_ATTRIBUTES sa; - - sa.nLength=sizeof(SECURITY_ATTRIBUTES); - sa.lpSecurityDescriptor=NULL; - sa.bInheritHandle=TRUE; - - int i; - wchar_t cmd[32000]; - wcscat( cmd,L"\0" ); - wcscat( cmd,L"openscad.exe" ); - int wargc; - LPWSTR *wargv; - wargv = CommandLineToArgvW(GetCommandLineW(), &wargc); - if ( !wargv ) { - printf(" error in CommandLineToArgvW\n"); - return 1; - } - for(i=1;i +#include +#include +#define MAXCMDLEN 64000 +#define BUFFSIZE 42 + +int main( int argc, char * argv[] ) +{ + FILE *cmd_stdout; + char cmd[MAXCMDLEN]; + char buffer[BUFFSIZE]; + char *fgets_result; + int eof = 0; + int pclose_result; + int i; + int result = 0; + + strcat( cmd, "\0" ); + strcat( cmd, "openscad.exe" ); + for ( i = 1 ; i < argc ; ++i ) { + strcat( cmd, " " ); + strcat( cmd, argv[i] ); + } + strcat( cmd, " "); + strcat( cmd, " 2>&1"); // capture stderr and stdout + + cmd_stdout = _popen( cmd, "rt" ); + if ( cmd_stdout == NULL ) { + printf( "Error opening _popen for command: %s", cmd ); + perror( "Error message:" ); + return 1; + } + + while ( !eof ) + { + fgets_result = fgets( buffer, BUFFSIZE, cmd_stdout ); + if ( fgets_result == NULL ) { + if ( ferror( cmd_stdout ) ) { + printf("Error reading from stdout of %s\n", cmd); + result = 1; + } + if ( feof( cmd_stdout ) ) { + eof = 1; + } + } else { + fprintf( stdout, "%s", buffer ); + } + } + + pclose_result = _pclose( cmd_stdout ); + if ( pclose_result < 0 ) { + perror("Error while closing stdout for command:"); + result = 1; + } + + return result; } -- cgit v0.10.1 From 3eb13949975fe30c2bd5f66384ae8b3ad597900d Mon Sep 17 00:00:00 2001 From: don bright Date: Tue, 22 Jan 2013 03:57:27 +0100 Subject: documentation fixup diff --git a/src/winconsole.c b/src/winconsole.c index 296bb31..de8e682 100644 --- a/src/winconsole.c +++ b/src/winconsole.c @@ -1,14 +1,27 @@ /* - enable easy piping under windows command line, using the 'devenv' method + Enable easy piping under Windows(TM) command line. + + We use the 'devenv'(TM) method, which means we have two binary files: + + openscad.com, with IMAGE_SUBSYSTEM_WINDOWS_CUI flag set + openscad.exe, with IMAGE_SUBSYSTEM_WINDOWS_GUI flag set + + The .com version is a 'wrapper' for the .exe version. If you call + 'openscad' with no extension from a script or shell, the .com version + is prioritized by the OS and feeds the GUI stdout to the console. We use + pure C to minimize binary size when cross-compiling (~10kbytes). See Also: + http://stackoverflow.com/questions/493536/can-one-executable-be-both-a-console-and-gui-app http://blogs.msdn.com/b/oldnewthing/archive/2009/01/01/9259142.aspx http://blogs.msdn.com/b/junfeng/archive/2004/02/06/68531.aspx http://msdn.microsoft.com/en-us/library/aa298534%28v=vs.60%29.aspx - http://www.i18nguy.com/unicode/c-unicode.html http://cournape.wordpress.com/2008/07/29/redirecting-stderrstdout-in-cmdexe/ Open Group popen() documentation - See Also: inkscapec by Jos Hirth work at http://kaioa.com - and Nop Head's OpenSCAD_cl at github.com + inkscapec by Jos Hirth work at http://kaioa.com + Nop Head's OpenSCAD_cl at github.com + + TODO: + Work with unicode: http://www.i18nguy.com/unicode/c-unicode.html */ -- cgit v0.10.1 From ddebb3991cc9fa183841d64ba43c3768e5be03a8 Mon Sep 17 00:00:00 2001 From: don bright Date: Tue, 22 Jan 2013 05:25:42 +0100 Subject: add another to About dialog diff --git a/src/AboutDialog.html b/src/AboutDialog.html index 47493bb..6203e83 100644 --- a/src/AboutDialog.html +++ b/src/AboutDialog.html @@ -115,7 +115,7 @@ Brett Sutton, hmnapier, Eero af Heurlin, caliston, 5263, ghost, 42loop, uniqx, Michael Thomson, Michael Ivko, Pierre Doucet, myglc2, Alan Cox, Peter Falke, Michael Ambrus, Gordon Wrigley, Ed Nisley, Stony Smith, Pasca Andrei, David Goodenough, William A Adams, mrrobinson, 1i7, -benhowes, Craig Trader, Miro Hrončok, ... and many others +benhowes, 5263, Craig Trader, Miro Hrončok, ... and many others

Hosting & resources -- cgit v0.10.1 From 9f83c8ffe71c12f0134e54e897a5a828dd7ec512 Mon Sep 17 00:00:00 2001 From: don bright Date: Sun, 27 Jan 2013 20:06:08 +0100 Subject: fix bugs and rewrite GLEW finding code to be more clear. diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 87e5319..9f41682 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -289,8 +289,7 @@ if (NOT $ENV{GLEWDIR} STREQUAL "") elseif (NOT $ENV{OPENSCAD_LIBRARIES} STREQUAL "") set(GLEW_DIR "$ENV{OPENSCAD_LIBRARIES}") endif() -if (NOT GLEW_INCLUDE_DIR) - message(STATUS "OPENCSG_DIR: " ${OPENCSG_DIR}) +if (GLEW_DIR) find_path(GLEW_INCLUDE_DIR GL/glew.h HINTS ${GLEW_DIR}/include @@ -299,14 +298,15 @@ if (NOT GLEW_INCLUDE_DIR) NAMES GLEW glew HINTS ${GLEW_DIR}/lib ${GLEW_DIR}/lib64 NO_DEFAULT_PATH) - if (NOT GLEW_LIBRARY) - find_package(GLEW REQUIRED) - if (NOT GLEW_LIBRARY) - message(FATAL_ERROR "GLEW not found") - endif() + if (GLEW_INCLUDE_DIR AND GLEW_LIBRARY) + message(STATUS "GLEW include: " ${GLEW_INCLUDE_DIR}) + message(STATUS "GLEW library: " ${GLEW_LIBRARY}) + set(GLEW_FOUND 1) endif() - message(STATUS "GLEW include: " ${GLEW_INCLUDE_DIR}) - message(STATUS "GLEW library: " ${GLEW_LIBRARY}) +endif() + +if (NOT GLEW_FOUND) + find_package(GLEW REQUIRED) endif() inclusion(GLEW_DIR GLEW_INCLUDE_DIR) diff --git a/tests/FindGLEW.cmake b/tests/FindGLEW.cmake index 1d94ca2..f571fe2 100644 --- a/tests/FindGLEW.cmake +++ b/tests/FindGLEW.cmake @@ -10,56 +10,57 @@ # a few lines of this file are based on the LGPL code found at # http://openlibraries.org/browser/trunk/FindGLEW.cmake?rev=1383 -include(FindPkgConfig) +if (WIN32 AND MSVC) + if (WIN32_STATIC_BUILD) # passed from caller + set(GLEW_LIB_SEARCH_NAME glew32s.lib) # static, non-debug (Release) + else () + set(GLEW_LIB_SEARCH_NAME glew32.lib) # other. untested with OpenSCAD + endif() +else () # GCC + set(GLEW_LIB_SEARCH_NAME "libglew32s.a") +endif () -if (PKG_CONFIG_FOUND) - message("Doing pkg config glew check...") - pkg_check_modules(GLEW glew>=1.6) +if (WIN32) + find_path(GLEW_INCLUDE_DIR GL/glew.h + $ENV{PROGRAMFILES}/GLEW/include + ${PROJECT_SOURCE_DIR}/src/nvgl/glew/include + DOC "The directory where GL/glew.h resides") + find_library(GLEW_LIBRARY + NAMES ${GLEW_LIB_SEARCH_NAME} + PATHS + $ENV{PROGRAMFILES}/GLEW/lib + ${PROJECT_SOURCE_DIR}/src/nvgl/glew/bin + ${PROJECT_SOURCE_DIR}/src/nvgl/glew/lib + DOC "The GLEW library") +else() + find_path(GLEW_INCLUDE_DIR GL/glew.h + PATHS /usr/include /usr/local/include /usr/pkg/include + NO_DEFAULT_PATH + DOC "The directory where GL/glew.h resides") + find_library(GLEW_LIBRARY + NAMES GLEW glew + PATHS /usr/lib /usr/local/lib /usr/pkg/lib /lib /lib64 /usr/lib64 + NO_DEFAULT_PATH + DOC "The GLEW library") endif() -if (GLEW_LIBRARIES) - set(GLEW_INCLUDE_DIR "${GLEW_INCLUDE_DIRS}") - set(GLEW_LIBRARY ${GLEW_LDFLAGS}) +if (GLEW_INCLUDE_DIR AND GLEW_LIBRARY) + set(GLEW_FOUND 1 CACHE STRING "Set to 1 if GLEW is found, 0 otherwise") + message(STATUS "GLEW include found in " ${GLEW_INCLUDE_DIR} ) + message(STATUS "GLEW library found in " ${GLEW_LIBRARY} ) else() - if (WIN32 AND MSVC) - if (WIN32_STATIC_BUILD) # passed from caller - set(GLEW_LIB_SEARCH_NAME glew32s.lib) # static, non-debug (Release) - else () - set(GLEW_LIB_SEARCH_NAME glew32.lib) # other. untested with OpenSCAD - endif() - else () # GCC - set(GLEW_LIB_SEARCH_NAME "libglew32s.a") - endif () - - if (WIN32) - find_path(GLEW_INCLUDE_DIR GL/glew.h - $ENV{PROGRAMFILES}/GLEW/include - ${PROJECT_SOURCE_DIR}/src/nvgl/glew/include - DOC "The directory where GL/glew.h resides") - find_library(GLEW_LIBRARY - NAMES ${GLEW_LIB_SEARCH_NAME} - PATHS - $ENV{PROGRAMFILES}/GLEW/lib - ${PROJECT_SOURCE_DIR}/src/nvgl/glew/bin - ${PROJECT_SOURCE_DIR}/src/nvgl/glew/lib - DOC "The GLEW library") - else (WIN32) - find_path(GLEW_INCLUDE_DIR GL/glew.h - PATHS /usr/include /usr/local/include /usr/pkg/include - NO_DEFAULT_PATH - DOC "The directory where GL/glew.h resides") - find_library(GLEW_LIBRARY - NAMES GLEW glew - PATHS /usr/lib /usr/local/lib /usr/pkg/lib - NO_DEFAULT_PATH - DOC "The GLEW library") - endif (WIN32) + set(GLEW_FOUND 0 CACHE STRING "Set to 1 if GLEW is found, 0 otherwise") +endif() - if (GLEW_INCLUDE_DIR) - set(GLEW_FOUND 1 CACHE STRING "Set to 1 if GLEW is found, 0 otherwise") - message(STATUS "GLEW include found in " ${GLEW_INCLUDE_DIR} ) - message(STATUS "GLEW library found in " ${GLEW_LIBRARY} ) - else() - set(GLEW_FOUND 0 CACHE STRING "Set to 1 if GLEW is found, 0 otherwise") +if (NOT GLEW_FOUND) + message("Doing pkg config glew check...") + pkg_check_modules(GLEW glew>=1.6) + if (GLEW_FOUND) + set(GLEW_INCLUDE_DIR "${GLEW_INCLUDEDIR}") + set(GLEW_LIBRARY ${GLEW_LDFLAGS}) endif() endif() + +if (NOT GLEW_FOUND) + message(FATAL_ERROR "GLEW not found") +endif() -- cgit v0.10.1 From 6f0a0fff9ec271ec9da31f319f9dfabdae569d1e Mon Sep 17 00:00:00 2001 From: don bright Date: Sun, 27 Jan 2013 20:57:50 -0600 Subject: make it clear to the user that they can't rely on this behavior diff --git a/src/dxftess-cgal.cc b/src/dxftess-cgal.cc index e40f1d3..0197473 100644 --- a/src/dxftess-cgal.cc +++ b/src/dxftess-cgal.cc @@ -166,8 +166,10 @@ void dxf_tesselate(PolySet *ps, DxfData &dxf, double rot, bool up, bool /* do_tr } } - if ( duplicate_vertices > 0 ) - PRINT( "WARNING: Duplicate vertices and/or intersecting lines found during DXF Tessellation. Render may be incorrect." ); + if ( duplicate_vertices > 0 ) { + PRINT( "WARNING: Duplicate vertices and/or intersecting lines found during DXF Tessellation." ); + PRINT( "WARNING: Modify the polygon to be a Simple Polygon. Render is incomplete." ); + } } catch (const CGAL::Assertion_exception &e) { -- cgit v0.10.1 From d09e0e7f420da11c2cbc91a5afeeec98896f66bd Mon Sep 17 00:00:00 2001 From: don bright Date: Mon, 28 Jan 2013 05:15:38 +0100 Subject: fix pkg-config to actually work diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 9f41682..84e5099 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -299,8 +299,6 @@ if (GLEW_DIR) HINTS ${GLEW_DIR}/lib ${GLEW_DIR}/lib64 NO_DEFAULT_PATH) if (GLEW_INCLUDE_DIR AND GLEW_LIBRARY) - message(STATUS "GLEW include: " ${GLEW_INCLUDE_DIR}) - message(STATUS "GLEW library: " ${GLEW_LIBRARY}) set(GLEW_FOUND 1) endif() endif() @@ -309,6 +307,9 @@ if (NOT GLEW_FOUND) find_package(GLEW REQUIRED) endif() +message(STATUS "GLEW include: " ${GLEW_INCLUDE_DIR}) +message(STATUS "GLEW library: " ${GLEW_LIBRARY}) + inclusion(GLEW_DIR GLEW_INCLUDE_DIR) # Flex/Bison diff --git a/tests/FindGLEW.cmake b/tests/FindGLEW.cmake index f571fe2..8fa2ac2 100644 --- a/tests/FindGLEW.cmake +++ b/tests/FindGLEW.cmake @@ -46,18 +46,19 @@ endif() if (GLEW_INCLUDE_DIR AND GLEW_LIBRARY) set(GLEW_FOUND 1 CACHE STRING "Set to 1 if GLEW is found, 0 otherwise") - message(STATUS "GLEW include found in " ${GLEW_INCLUDE_DIR} ) - message(STATUS "GLEW library found in " ${GLEW_LIBRARY} ) else() set(GLEW_FOUND 0 CACHE STRING "Set to 1 if GLEW is found, 0 otherwise") endif() if (NOT GLEW_FOUND) - message("Doing pkg config glew check...") - pkg_check_modules(GLEW glew>=1.6) - if (GLEW_FOUND) - set(GLEW_INCLUDE_DIR "${GLEW_INCLUDEDIR}") - set(GLEW_LIBRARY ${GLEW_LDFLAGS}) + include(FindPkgConfig.cmake) + if (PKG_CONFIG_FOUND) + message(STATUS "Doing pkg config glew check...") + pkg_search_module(GLEW glew) + if (GLEW_FOUND) + set(GLEW_INCLUDE_DIR "${GLEW_INCLUDEDIR}") + set(GLEW_LIBRARY "-L${GLEW_LIBRARY_DIRS} -l${GLEW_LIBRARIES}") + endif() endif() endif() -- cgit v0.10.1 From d6f2cc1a1e6f7bc55d137d653242086c29a1bf32 Mon Sep 17 00:00:00 2001 From: don bright Date: Mon, 28 Jan 2013 06:38:50 +0100 Subject: if we are on linux/BSD and there's no X running, try Xvfb automatically. also workaround some Gallium bugs and Imagemagick bugs diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 87e5319..8822c92 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -42,6 +42,11 @@ if(${CMAKE_BUILD_TYPE} STREQUAL "Debug") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DDEBUG") endif() +# MCAD +if(NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/../libraries/MCAD/__init__.py) + message(FATAL_ERROR "MCAD not found. You can install from the OpenSCAD root as follows: \n git submodule update --init") +endif() + # # Windows # @@ -370,6 +375,19 @@ if (NOT SKIP_IMAGEMAGICK) endif() endif() +if ( "${ImageMagick_VERSION_STRING}" VERSION_LESS "6.5.9.4" ) + message(STATUS "ImageMagick version less than 6.5.9.4, cannot use -morphology comparison") + message(STATUS "ImageMagick Using older image comparison method") + set(COMPARATOR "old") +endif() + +execute_process(COMMAND ${ImageMagick_convert_EXECUTABLE} --version OUTPUT_VARIABLE IM_OUT ) +if ( ${IM_OUT} MATCHES "OpenMP" ) + # http://www.daniloaz.com/en/617/systems/high-cpu-load-when-converting-images-with-imagemagick + message(STATUS "ImageMagick: OpenMP bug workaround - setting MAGICK_THREAD_LIMIT=1") + set(CTEST_ENVIRONMENT "${CTEST_ENVIRONMENT};MAGICK_THREAD_LIMIT=1") +endif() + # Internal includes include_directories(../src) @@ -609,12 +627,6 @@ function(get_test_fullname TESTCMD FILENAME FULLNAME) set(${FULLNAME} ${${FULLNAME}} PARENT_SCOPE) endfunction() -# comparison method to use -if (NOT $ENV{COMPARATOR} STREQUAL "") - set(COMPARATOR "$ENV{COMPARATOR}") - message(STATUS "ImageMagick method modified with COMPARATOR: " ${COMPARATOR}) -endif() - # # This functions adds cmd-line tests given files. # Files are sent as the parameters following TESTSUFFIX @@ -649,31 +661,14 @@ macro(add_cmdline_test TESTCMD TESTSUFFIX) set( MINGW_CROSS_ARG "--mingw-cross-env" ) endif() add_test(NAME ${TEST_FULLNAME} ${CONFARG} ${CONFVAL} COMMAND ${PYTHON_EXECUTABLE} ${tests_SOURCE_DIR}/test_cmdline_tool.py ${MINGW_CROSS_ARG} --comparator=${COMPARATOR} -c ${ImageMagick_convert_EXECUTABLE} -s ${TESTSUFFIX} ${CMAKE_BINARY_DIR}/${TESTCMD} "${SCADFILE}") + set_property(TEST ${TEST_FULLNAME} PROPERTY ENVIRONMENT "${CTEST_ENVIRONMENT}") endif() endforeach() endmacro() enable_testing() -# set up custom pretty printing of results -set(INFOCMD "execute_process(COMMAND ${CMAKE_CURRENT_BINARY_DIR}/opencsgtest --info OUTPUT_FILE sysinfo.txt)") -if (MINGW_CROSS_ENV_DIR) - set(INFOCMD "execute_process(COMMAND wine ${CMAKE_CURRENT_BINARY_DIR}/opencsgtest --info OUTPUT_FILE sysinfo.txt)") -endif() -set(PRETTYCMD "\"${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/test_pretty_print.py --builddir=${CMAKE_CURRENT_BINARY_DIR}\"") -set(CTEST_CUSTOM_FILE ${CMAKE_CURRENT_BINARY_DIR}/CTestCustom.cmake) -set(CTEST_CUSTOM_TXT "\n - message(\"running 'opencsgtest --info' to generate sysinfo.txt\")\n - ${INFOCMD}\n - set(CTEST_CUSTOM_POST_TEST ${PRETTYCMD})\n -") -file(WRITE ${CTEST_CUSTOM_FILE} ${CTEST_CUSTOM_TXT}) - -foreach(FILE test_pretty_print.py) - configure_file(${CMAKE_CURRENT_SOURCE_DIR}/${FILE} - ${CMAKE_CURRENT_BINARY_DIR}/${FILE} COPYONLY) -endforeach() set_directory_properties(PROPERTIES TEST_INCLUDE_FILE "${CMAKE_SOURCE_DIR}/EnforceConfig.cmake") @@ -784,6 +779,36 @@ foreach(FILE ${EXAMPLE_FILES}) set_test_config(Examples ${TEST_FULLNAME}) endforeach() +# Workaround Gallium bugs +if ( ${CMAKE_SYSTEM_PROCESSOR} MATCHES "ppc") + message(STATUS "Workaround PPC bug https://bugs.freedesktop.org/show_bug.cgi?id=42540") + set(CTEST_ENVIRONMENT "${CTEST_ENVIRONMENT};GALLIUM_DRIVER=softpipe") + set(CTEST_ENVIRONMENT "${CTEST_ENVIRONMENT};DRAW_USE_LLVM=no") +endif() + +# Set up custom commands to run before & after Ctest run. +# 1. Start/stop Virtual Framebuffer for linux/bsd. 2. Pretty Print +# Please see the CTestCustom.template file for more info. + +file(READ ${CMAKE_CURRENT_SOURCE_DIR}/CTestCustom.template TMP) +string(REPLACE __cmake_current_binary_dir__ ${CMAKE_CURRENT_BINARY_DIR} TMP ${TMP}) +string(REPLACE __cmake_current_source_dir__ ${CMAKE_CURRENT_SOURCE_DIR} TMP ${TMP}) +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}) + +if (MINGW_CROSS_ENV_DIR) + string(REPLACE __wine__ wine TMP ${TMP}) +else() + string(REPLACE __wine__ " " TMP ${TMP}) +endif() + +message(STATUS "creating CTestCustom.cmake") +file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/CTestCustom.cmake ${TMP}) + +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/test_pretty_print.py + ${CMAKE_CURRENT_BINARY_DIR}/test_pretty_print.py COPYONLY) + # Add tests add_cmdline_test(echotest txt ${ECHO_FILES}) diff --git a/tests/CTestCustom.template b/tests/CTestCustom.template new file mode 100644 index 0000000..72e6443 --- /dev/null +++ b/tests/CTestCustom.template @@ -0,0 +1,68 @@ +# __header__ +# +# This template enables ctest to do things before and after the test runs. +# In our case, 1. Setup a virtual framebuffer, 2. pretty-print results +# +# As a template, this file is read inside of CMakeList.txt and certain +# words (__word__) are replaced with the cmake build dir/etc, at the time that +# cmake itself is run. Typically these are signified by two underscores (__) +# before and after the word in smallcase. +# +# The file then becomes CTestCustom.cmake inside the cmake build +# directory. It is 'run' at the time that ctest is run. + + +# Part 0. X11 and Virtual Framebuffer, for Linux/BSD. This is not used by +# Windows or Mac because they have alternate means of accessing OpenGL. + +set(debug_openscad_template 0) + +if( __cmake_system_name__ MATCHES "Linux|BSD") + set(DISPLAY_ENV $ENV{DISPLAY}) + if(DISPLAY_ENV) + message("X11 DISPLAY environment variable found. Assuming framebuffer exists at DISPLAY=${DISPLAY_ENV}") + else() + message("X11 DISPLAY environment variable not found. Calling virtualfb.sh") + execute_process( + COMMAND __cmake_current_source_dir__/virtualfb.sh start + OUTPUT_VARIABLE SVFB_OUT) + string(REGEX MATCH "DISPLAY=:[0-9.]*" VFB_DISPLAY_STR "${SVFB_OUT}") + string(REGEX MATCH ":[0-9.]*" VFB_DISPLAY "${VFB_DISPLAY_STR}") + string(REGEX MATCH "PID=[0-9.]*" VFB_PID_STR "${SVFB_OUT}") + string(REPLACE "PID=" "" VFB_PID "${VFB_PID_STR}") + + if (debug_openscad_template) + message("Output from virtualfb.sh script: ${SVFB_OUT}") + message("Display: ${VFB_DISPLAY}") + message("Process ID of vfb: ${VFB_PID}") + endif() + if ("${VFB_DISPLAY}" STREQUAL "" OR "${VFB_PID}" STREQUAL "") + message("Virtual framebuffer had a problem starting.") + execute_process("cat virtualfblog") + else() + message("Virtual framebuffer started. DISPLAY=${VFB_DISPLAY}, PID=${VFB_PID}") + endif() + + + # This line is the heart of the mechanism by which ctest is able to take + # the DISPLAY env variable of the Virtual Framebuffer it just started, and + # pass it on to its child processes (the tests from CTestTestfile.cmake + # in the build directory). + set(ENV{DISPLAY} "${VFB_DISPLAY}") + + set(CTEST_CUSTOM_POST_TEST "kill ${VFB_PID}") + endif() +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) +set(CTEST_CUSTOM_POST_TEST ${CTEST_CUSTOM_POST_TEST} "__python__ __cmake_current_source_dir__/test_pretty_print.py --builddir=__cmake_current_binary_dir__") + +if ( ${debug_openscad_template} ) + foreach(post_test ${CTEST_CUSTOM_POST_TEST} ) + message("Post test:" ${post_test}) + endforeach() +endif() diff --git a/tests/test_pretty_print.py b/tests/test_pretty_print.py index a2a04ed..ed86b65 100755 --- a/tests/test_pretty_print.py +++ b/tests/test_pretty_print.py @@ -62,13 +62,16 @@ def ezsearch(pattern,str): def read_gitinfo(): # won't work if run from outside of branch. - data = subprocess.Popen(['git','remote','-v'],stdout=subprocess.PIPE).stdout.read() - origin = ezsearch('^origin *?(.*?)\(fetch.*?$',data) - upstream = ezsearch('^upstream *?(.*?)\(fetch.*?$',data) - data = subprocess.Popen(['git','branch'],stdout=subprocess.PIPE).stdout.read() - branch = ezsearch('^\*(.*?)$',data) - out = 'Git branch: ' + branch + ' from origin ' + origin + '\n' - out += 'Git upstream: ' + upstream + '\n' + try: + data = subprocess.Popen(['git','remote','-v'],stdout=subprocess.PIPE).stdout.read() + origin = ezsearch('^origin *?(.*?)\(fetch.*?$',data) + upstream = ezsearch('^upstream *?(.*?)\(fetch.*?$',data) + data = subprocess.Popen(['git','branch'],stdout=subprocess.PIPE).stdout.read() + branch = ezsearch('^\*(.*?)$',data) + out = 'Git branch: ' + branch + ' from origin ' + origin + '\n' + out += 'Git upstream: ' + upstream + '\n' + except: + out = 'Problem running git' return out def read_sysinfo(filename): diff --git a/tests/virtualfb.sh b/tests/virtualfb.sh new file mode 100755 index 0000000..3c0cf0e --- /dev/null +++ b/tests/virtualfb.sh @@ -0,0 +1,22 @@ +#!/bin/sh + +if [ "`command -v Xvfb`" ]; then + VFB_BINARY=Xvfb +fi + +if [ "`command -v Xvnc`" ]; then + VFB_BINARY=Xvnc +fi + +if [ ! $VFB_BINARY ]; then + echo "$0 Failed, cannot find Xvfb or Xvnc" + exit 1 +fi + +DISPLAY=:98 +$VFB_BINARY $DISPLAY -screen 0 800x600x24 &> virtualfblog & +echo PID=$! " " +echo DISPLAY=$DISPLAY +# trap "kill -KILL $xpid ||:" EXIT +export DISPLAY +sleep 3 -- cgit v0.10.1 From 0bf593b74a3332ddcf87eb05bc2ca05e5899ddd1 Mon Sep 17 00:00:00 2001 From: Marius Kintel Date: Mon, 28 Jan 2013 17:56:12 -0500 Subject: sync diff --git a/doc/TODO.txt b/doc/TODO.txt index 62db614..be03e98 100644 --- a/doc/TODO.txt +++ b/doc/TODO.txt @@ -137,6 +137,8 @@ o Hollow donut problem o CGAL issues - CGAL doesn't handle almost planar polygons. Consider splitting into triangles ourselves. See WillamAdams/dodec.scad o Look at the EPEC kernel for improved performance (suggested by Giles) +o Look at performance: Is CGAL doing proper bounding box calculation before testing all primitives? + LANGUAGE && BUILTINS -------------------- @@ -190,6 +192,7 @@ o DXF Import/Export - Support for LEADER entity - Support for MTEXT entity ? - idea: DXF inline - convert from dxf to OpenSCAD syntax -> parametrize dxf content + - Progress when exporting large STLs o Mesh optimization on STL export - Remove super small triangles (all sides are short) - Replace super thin triangles (one h is short) @@ -220,10 +223,6 @@ o Consider decoupling DXF-specific functionality from the 2D subsystem o Visitation refactoring - Make AbstractNode members private/protected? -BUILD SYSTEM ------------- -o Fedora is reported to ship with byacc, which doesn't support bison extensions (e.g. %debuig). Look into this, either be yacc-compatible or force the build system to use bison. - DOCUMENTATION ------------- o Auto-generate API documentation instead of, in addition to or combined with, the wikibooks docs. -- cgit v0.10.1 From e565414de17fcbb895ada1d0e760d4b4526d013a Mon Sep 17 00:00:00 2001 From: Marius Kintel Date: Mon, 28 Jan 2013 17:56:41 -0500 Subject: cosmetics diff --git a/doc/release-checklist.txt b/doc/release-checklist.txt index 6d53ad9..c51c919 100644 --- a/doc/release-checklist.txt +++ b/doc/release-checklist.txt @@ -5,7 +5,7 @@ OpenSCAD Release Checklist o Update VERSION environment variable - export VERSION=2012.08 + export VERSION=2013.01 It will be used by the commands below, as well as these files: @@ -24,7 +24,7 @@ o build source package o Sanity check; build a binary or two and manually run some tests -o git push --tags +o git push --tags o Upload Source package $ ./scripts/googlecode_upload.py -s 'Source Code' -p openscad -l Featured,Type-Source openscad-$VERSION.src.tar.gz -- cgit v0.10.1 From c08760519354f9a65a8950d0f482d34180e8b376 Mon Sep 17 00:00:00 2001 From: Marius Kintel Date: Mon, 28 Jan 2013 17:58:36 -0500 Subject: Support reading binary STLs which happen to start with the string 'solid'. Fixes #258 diff --git a/src/import.cc b/src/import.cc index 40d34fa..6a6d925 100644 --- a/src/import.cc +++ b/src/import.cc @@ -119,7 +119,8 @@ PolySet *ImportNode::evaluate_polyset(class PolySetEvaluator *) const if (this->type == TYPE_STL) { handle_dep((std::string)this->filename); - std::ifstream f(this->filename.c_str(), std::ios::in | std::ios::binary); + // Open file and position at the end + std::ifstream f(this->filename.c_str(), std::ios::in | std::ios::binary | std::ios::ate); if (!f.good()) { PRINTB("WARNING: Can't open import file '%s'.", this->filename); return p; @@ -132,9 +133,20 @@ PolySet *ImportNode::evaluate_polyset(class PolySetEvaluator *) const boost::regex ex_vertex("vertex"); boost::regex ex_vertices("\\s*vertex\\s+([^\\s]+)\\s+([^\\s]+)\\s+([^\\s]+)"); + bool binary = false; + int file_size = f.tellg(); + f.seekg(80); + if (!f.eof()) { + int facenum = 0; + // FIXME: Assumes little endian + f.read((char *)&facenum, sizeof(int)); + if (file_size == 80 + 4 + 50*facenum) binary = true; + } + f.seekg(0); + char data[5]; f.read(data, 5); - if (!f.eof() && !memcmp(data, "solid", 5)) { + if (!binary && !f.eof() && !memcmp(data, "solid", 5)) { int i = 0; double vdata[3][3]; std::string line; @@ -174,6 +186,7 @@ PolySet *ImportNode::evaluate_polyset(class PolySetEvaluator *) const else { f.ignore(80-5+4); + // FIXME: Assumes little endian while (1) { #ifdef _MSC_VER #pragma pack(push,1) diff --git a/testdata/scad/features/import_bin_solid.stl b/testdata/scad/features/import_bin_solid.stl new file mode 100644 index 0000000..c1886db Binary files /dev/null and b/testdata/scad/features/import_bin_solid.stl differ diff --git a/testdata/scad/templates/import_stl-tests-template.scad b/testdata/scad/templates/import_stl-tests-template.scad index 685b868..2cc886d 100644 --- a/testdata/scad/templates/import_stl-tests-template.scad +++ b/testdata/scad/templates/import_stl-tests-template.scad @@ -1,4 +1,6 @@ import_stl("import.stl"); translate([2,0,0]) import("import.stl"); translate([4,0,0]) import("import_bin.stl"); +// Test binary STLs which happen to start with the string "solid" +translate([0,4,0]) import("import_bin_solid.stl"); translate([0,2,0]) import("@CMAKE_SOURCE_DIR@/../testdata/scad/features/import.stl"); diff --git a/tests/regression/cgalpngtest/import_stl-tests-expected.png b/tests/regression/cgalpngtest/import_stl-tests-expected.png index de7638a..c6a4b2d 100644 Binary files a/tests/regression/cgalpngtest/import_stl-tests-expected.png and b/tests/regression/cgalpngtest/import_stl-tests-expected.png differ diff --git a/tests/regression/dumptest/import_stl-tests-expected.txt b/tests/regression/dumptest/import_stl-tests-expected.txt index 947f137..0d46a6f 100644 --- a/tests/regression/dumptest/import_stl-tests-expected.txt +++ b/tests/regression/dumptest/import_stl-tests-expected.txt @@ -5,6 +5,9 @@ multmatrix([[1, 0, 0, 4], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]) { import(file = "import_bin.stl", layer = "", origin = [0, 0], scale = 1, convexity = 1, $fn = 0, $fa = 12, $fs = 2); } + multmatrix([[1, 0, 0, 0], [0, 1, 0, 4], [0, 0, 1, 0], [0, 0, 0, 1]]) { + import(file = "import_bin_solid.stl", layer = "", origin = [0, 0], scale = 1, convexity = 1, $fn = 0, $fa = 12, $fs = 2); + } multmatrix([[1, 0, 0, 0], [0, 1, 0, 2], [0, 0, 1, 0], [0, 0, 0, 1]]) { import(file = "import.stl", layer = "", origin = [0, 0], scale = 1, convexity = 1, $fn = 0, $fa = 12, $fs = 2); } diff --git a/tests/regression/opencsgtest/import_stl-tests-expected.png b/tests/regression/opencsgtest/import_stl-tests-expected.png index 0bd9ab6..583f3f6 100644 Binary files a/tests/regression/opencsgtest/import_stl-tests-expected.png and b/tests/regression/opencsgtest/import_stl-tests-expected.png differ diff --git a/tests/regression/throwntogethertest/import_stl-tests-expected.png b/tests/regression/throwntogethertest/import_stl-tests-expected.png index 0bd9ab6..583f3f6 100644 Binary files a/tests/regression/throwntogethertest/import_stl-tests-expected.png and b/tests/regression/throwntogethertest/import_stl-tests-expected.png differ -- cgit v0.10.1 From 600893dd74ba241eb65722e929d847dc5b0c282f Mon Sep 17 00:00:00 2001 From: don bright Date: Mon, 28 Jan 2013 22:20:55 -0600 Subject: fix bug report in glew finder diff --git a/tests/FindGLEW.cmake b/tests/FindGLEW.cmake index 8fa2ac2..674741d 100644 --- a/tests/FindGLEW.cmake +++ b/tests/FindGLEW.cmake @@ -35,23 +35,21 @@ if (WIN32) else() find_path(GLEW_INCLUDE_DIR GL/glew.h PATHS /usr/include /usr/local/include /usr/pkg/include - NO_DEFAULT_PATH DOC "The directory where GL/glew.h resides") find_library(GLEW_LIBRARY NAMES GLEW glew PATHS /usr/lib /usr/local/lib /usr/pkg/lib /lib /lib64 /usr/lib64 - NO_DEFAULT_PATH DOC "The GLEW library") endif() -if (GLEW_INCLUDE_DIR AND GLEW_LIBRARY) - set(GLEW_FOUND 1 CACHE STRING "Set to 1 if GLEW is found, 0 otherwise") -else() +if ("${GLEW_INCLUDE_DIR}" STREQUAL "" AND "${GLEW_LIBRARY}" STREQUAL "") set(GLEW_FOUND 0 CACHE STRING "Set to 1 if GLEW is found, 0 otherwise") +else() + set(GLEW_FOUND 1 CACHE STRING "Set to 1 if GLEW is found, 0 otherwise") endif() if (NOT GLEW_FOUND) - include(FindPkgConfig.cmake) + find_package(PkgConfig REQUIRED) if (PKG_CONFIG_FOUND) message(STATUS "Doing pkg config glew check...") pkg_search_module(GLEW glew) -- cgit v0.10.1 From 2eb5fddc538b211c71c40a252a0b5c9c790c9acf Mon Sep 17 00:00:00 2001 From: don bright Date: Tue, 29 Jan 2013 21:59:59 -0600 Subject: make boost random work with version less than 1.47 diff --git a/scripts/check-dependencies.sh b/scripts/check-dependencies.sh index eaed556..6a3e637 100755 --- a/scripts/check-dependencies.sh +++ b/scripts/check-dependencies.sh @@ -449,7 +449,7 @@ check_old_local() warnon= if [ "`uname | grep -i linux`" ]; then header_list="opencsg.h CGAL boost GL/glew.h gmp.h mpfr.h eigen2 eigen3" - liblist="libboost libopencsg libCGAL libglew" + liblist="libboost_system libboost_system-mt libopencsg libCGAL libglew" for i in $header_list $liblist; do if [ -e /usr/local/include/$i ]; then echo "Warning: you have a copy of "$i" under /usr/local/include" diff --git a/src/func.cc b/src/func.cc index 5dcb3e9..791e957 100644 --- a/src/func.cc +++ b/src/func.cc @@ -43,7 +43,7 @@ */ #include -#include +#include #ifdef __WIN32__ #include @@ -54,8 +54,8 @@ int process_id = _getpid(); int process_id = getpid(); #endif -boost::random::mt19937 deterministic_rng; -boost::random::mt19937 lessdeterministic_rng( std::time(0) + process_id ); +boost::mt19937 deterministic_rng; +boost::mt19937 lessdeterministic_rng( std::time(0) + process_id ); AbstractFunction::~AbstractFunction() { @@ -167,7 +167,7 @@ Value builtin_rands(const Context *, const std::vector&, const std: double min = std::min( args[0].toDouble(), args[1].toDouble() ); double max = std::max( args[0].toDouble(), args[1].toDouble() ); - boost::random::uniform_real_distribution<> distributor( min, max ); + boost::uniform_real<> distributor( min, max ); Value::VectorType vec; for (int i=0; i Date: Wed, 30 Jan 2013 07:06:54 +0100 Subject: enable building older versions of boost diff --git a/scripts/uni-build-dependencies.sh b/scripts/uni-build-dependencies.sh index 0c37605..a9e5cc8 100755 --- a/scripts/uni-build-dependencies.sh +++ b/scripts/uni-build-dependencies.sh @@ -176,15 +176,27 @@ build_boost() fi fi # We only need certain portions of boost - ./bootstrap.sh --prefix=$DEPLOYDIR --with-libraries=thread,program_options,filesystem,system,regex + if [ -e ./bootstrap.sh ]; then + BSTRAPBIN=./bootstrap.sh + else + BSTRAPBIN=./configure + fi + $BSTRAPBIN --prefix=$DEPLOYDIR --with-libraries=thread,program_options,filesystem,system,regex + if [ -e ./b2 ]; then + BJAMBIN=b2; + elif [ -e ./bjam ]; then + BJAMBIN=./bjam + elif [ -e ./Makefile ]; then + BJAMBIN=make + fi if [ $CXX ]; then if [ $CXX = "clang++" ]; then - ./b2 -j$NUMCPU toolset=clang install + $BJAMBIN -j$NUMCPU toolset=clang install # ./b2 -j$NUMCPU toolset=clang cxxflags="-stdlib=libc++" linkflags="-stdlib=libc++" install fi else - ./b2 -j$NUMCPU - ./b2 install + $BJAMBIN -j$NUMCPU + $BJAMBIN install fi } -- cgit v0.10.1 From b0acc7598068f946696369de1355714a5bdf14da Mon Sep 17 00:00:00 2001 From: Marius Kintel Date: Wed, 30 Jan 2013 11:47:25 -0500 Subject: typo diff --git a/setenv_mjau.sh b/setenv_mjau.sh index 677a47a..943ae6b 100644 --- a/setenv_mjau.sh +++ b/setenv_mjau.sh @@ -6,7 +6,7 @@ export QMAKESPEC=macx-g++ #export CGALDIR=$PWD/../install/CGAL-3.6 #export DYLD_LIBRARY_PATH=$OPENCSGDIR/lib -# Own own Qt +# Our own Qt export PATH=$OPENSCAD_LIBRARIES/bin:$PATH # ccache: -- cgit v0.10.1 From 6f205814bc516ba71b7b02185986206d099ac000 Mon Sep 17 00:00:00 2001 From: Marius Kintel Date: Wed, 30 Jan 2013 11:58:19 -0500 Subject: Make it possible to build without CGAL. Fixes #264 diff --git a/src/Preferences.cc b/src/Preferences.cc index e70a2a1..ec66094 100644 --- a/src/Preferences.cc +++ b/src/Preferences.cc @@ -30,7 +30,9 @@ #include #include #include "PolySetCache.h" +#ifdef ENABLE_CGAL #include "CGALCache.h" +#endif Preferences *Preferences::instance = NULL; @@ -75,7 +77,9 @@ Preferences::Preferences(QWidget *parent) : QMainWindow(parent) this->defaultmap["advanced/opencsg_show_warning"] = true; this->defaultmap["advanced/enable_opencsg_opengl1x"] = true; this->defaultmap["advanced/polysetCacheSize"] = uint(PolySetCache::instance()->maxSize()); +#ifdef ENABLE_CGAL this->defaultmap["advanced/cgalCacheSize"] = uint(CGALCache::instance()->maxSize()); +#endif this->defaultmap["advanced/openCSGLimit"] = 2000; this->defaultmap["advanced/forceGoldfeather"] = false; @@ -126,7 +130,9 @@ Preferences::Preferences(QWidget *parent) : QMainWindow(parent) // Advanced pane QValidator *validator = new QIntValidator(this); +#ifdef ENABLE_CGAL this->cgalCacheSizeEdit->setValidator(validator); +#endif this->polysetCacheSizeEdit->setValidator(validator); this->opencsgLimitEdit->setValidator(validator); @@ -198,7 +204,9 @@ void Preferences::on_cgalCacheSizeEdit_textChanged(const QString &text) { QSettings settings; settings.setValue("advanced/cgalCacheSize", text); +#ifdef ENABLE_CGAL CGALCache::instance()->setMaxSize(text.toULong()); +#endif } void Preferences::on_polysetCacheSizeEdit_textChanged(const QString &text) diff --git a/src/mainwin.cc b/src/mainwin.cc index 251c6e1..17b9ef7 100644 --- a/src/mainwin.cc +++ b/src/mainwin.cc @@ -89,6 +89,10 @@ #include "cgal.h" #include "cgalworker.h" +#else + +#include "PolySetEvaluator.h" + #endif // ENABLE_CGAL #ifndef OPENCSG_VERSION_STRING @@ -153,9 +157,11 @@ MainWindow::MainWindow(const QString &filename) { setupUi(this); +#ifdef ENABLE_CGAL this->cgalworker = new CGALWorker(); connect(this->cgalworker, SIGNAL(done(CGAL_Nef_polyhedron *)), this, SLOT(actionRenderCGALDone(CGAL_Nef_polyhedron *))); +#endif register_builtin(root_ctx); @@ -410,8 +416,10 @@ MainWindow::loadDesignSettings() } uint polySetCacheSize = Preferences::inst()->getValue("advanced/polysetCacheSize").toUInt(); PolySetCache::instance()->setMaxSize(polySetCacheSize); +#ifdef ENABLE_CGAL uint cgalCacheSize = Preferences::inst()->getValue("advanced/cgalCacheSize").toUInt(); CGALCache::instance()->setMaxSize(cgalCacheSize); +#endif } MainWindow::~MainWindow() @@ -677,8 +685,12 @@ void MainWindow::compileCSG(bool procevents) progress_report_prep(this->root_node, report_func, this); try { +#ifdef ENABLE_CGAL CGALEvaluator cgalevaluator(this->tree); PolySetCGALEvaluator psevaluator(cgalevaluator); +#else + PolySetEvaluator psevaluator(this->tree); +#endif CSGTermEvaluator csgrenderer(this->tree, &psevaluator); this->root_raw_term = csgrenderer.evaluateCSGTerm(*root_node, highlight_terms, background_terms); if (!root_raw_term) { @@ -687,7 +699,9 @@ void MainWindow::compileCSG(bool procevents) QApplication::processEvents(); } PolySetCache::instance()->print(); +#ifdef ENABLE_CGAL CGALCache::instance()->print(); +#endif } catch (const ProgressCancelException &e) { PRINT("CSG generation cancelled."); @@ -1196,8 +1210,9 @@ void MainWindow::actionRenderCGALDone(CGAL_Nef_polyhedron *root_N) if (root_N) { PolySetCache::instance()->print(); +#ifdef ENABLE_CGAL CGALCache::instance()->print(); - +#endif if (!root_N->isNull()) { if (root_N->dim == 2) { PRINT(" Top level object is a 2D object:"); diff --git a/src/svg.cc b/src/svg.cc index e5130b0..66e5797 100644 --- a/src/svg.cc +++ b/src/svg.cc @@ -1,3 +1,4 @@ +#ifdef ENABLE_CGAL #include "cgalutils.h" #include "svg.h" #include @@ -246,4 +247,4 @@ std::string dump_svg( const CGAL_Nef_polyhedron3 &N ) } // namespace - +#endif // ENABLE_CGAL -- cgit v0.10.1 From 97c8f40200c3b4c753fd8885576d9a86cd2b09ba Mon Sep 17 00:00:00 2001 From: 5263 Date: Wed, 30 Jan 2013 19:13:32 +0100 Subject: enable csg output when compiled without CGAL diff --git a/src/openscad.cc b/src/openscad.cc index 472b5d4..880aa0d 100644 --- a/src/openscad.cc +++ b/src/openscad.cc @@ -255,7 +255,6 @@ int main(int argc, char **argv) if (!filename) help(argv[0]); -#ifdef ENABLE_CGAL Context root_ctx; register_builtin(root_ctx); @@ -299,6 +298,7 @@ int main(int argc, char **argv) } } else { +#ifdef ENABLE_CGAL CGAL_Nef_polyhedron root_N = cgalevaluator.evaluateCGALMesh(*tree.root()); fs::current_path(original_path); @@ -373,12 +373,12 @@ int main(int argc, char **argv) fstream.close(); } } - } - delete root_node; #else - fprintf(stderr, "OpenSCAD has been compiled without CGAL support!\n"); - exit(1); + fprintf(stderr, "OpenSCAD has been compiled without CGAL support!\n"); + exit(1); #endif + } + delete root_node; } else if (useGUI) { -- cgit v0.10.1 From af0658a8fe441ebb0eb3d238e7055fd592343605 Mon Sep 17 00:00:00 2001 From: don bright Date: Thu, 31 Jan 2013 02:04:00 +0100 Subject: use ./b2 not b2 when building boost diff --git a/scripts/uni-build-dependencies.sh b/scripts/uni-build-dependencies.sh index a9e5cc8..3da11ec 100755 --- a/scripts/uni-build-dependencies.sh +++ b/scripts/uni-build-dependencies.sh @@ -183,7 +183,7 @@ build_boost() fi $BSTRAPBIN --prefix=$DEPLOYDIR --with-libraries=thread,program_options,filesystem,system,regex if [ -e ./b2 ]; then - BJAMBIN=b2; + BJAMBIN=./b2; elif [ -e ./bjam ]; then BJAMBIN=./bjam elif [ -e ./Makefile ]; then -- cgit v0.10.1 From 01aaec33573a49705c9028966df2cbd15c9c4c61 Mon Sep 17 00:00:00 2001 From: don bright Date: Thu, 31 Jan 2013 18:37:08 -0800 Subject: copy qt4 building script from macosx-build-deps to linux diff --git a/scripts/setenv-unibuild.sh b/scripts/setenv-unibuild.sh index 881526e..66fb7a9 100644 --- a/scripts/setenv-unibuild.sh +++ b/scripts/setenv-unibuild.sh @@ -130,5 +130,12 @@ if [ "`echo $* | grep qt5`" ]; then setenv_qt5 fi +if [ -e $DEPLOYDIR/include/Qt ]; then + echo "Qt found under $DEPLOYDIR ... " + QTDIR=$DEPLOYDIR + export QTDIR + echo "QTDIR modified to $DEPLOYDIR" +fi + clean_note diff --git a/scripts/uni-build-dependencies.sh b/scripts/uni-build-dependencies.sh index 0c37605..6550dcc 100755 --- a/scripts/uni-build-dependencies.sh +++ b/scripts/uni-build-dependencies.sh @@ -24,7 +24,6 @@ # # Prerequisites: # - wget or curl -# - Qt4 # - gcc # # Enable Clang (experimental, only works on linux): @@ -42,6 +41,31 @@ printUsage() echo } +build_qt4() +{ + version=$1 + if [ -e $DEPLOYDIR/include/Qt ]; then + echo "qt already installed. not building" + return + fi + echo "Building Qt" $version "..." + cd $BASEDIR/src + rm -rf qt-everywhere-opensource-src-$version + if [ ! -f qt-everywhere-opensource-src-$version.tar.gz ]; then + curl -O http://releases.qt-project.org/qt4/source/qt-everywhere-opensource-src-$version.tar.gz + fi + tar xzf qt-everywhere-opensource-src-$version.tar.gz + cd qt-everywhere-opensource-src-$version + ./configure -prefix $DEPLOYDIR -opensource -confirm-license -fast -no-qt3support -no-svg -no-phonon -no-audio-backend -no-multimedia -no-javascript-jit -no-script -no-scripttools -no-declarative -no-xmlpatterns -nomake demos -nomake examples -nomake docs -nomake translations -no-webkit + make -j $NUMCPU + make install + QTDIR=$DEPLOYDIR + export QTDIR + echo "----------" + echo " Please set QTDIR to $DEPLOYDIR ( or run '. scripts/setenv-unibuild.sh' ) + echo "----------" +} + build_bison() { version=$1 @@ -426,6 +450,11 @@ if [ $1 ]; then build_opencsg 1.3.2 exit fi + if [ $1 == "qt4" ]; then + # such a huge build, put here by itself + build_qt4 4.8.4 + exit + fi fi @@ -433,7 +462,6 @@ fi # Main build of libraries # edit version numbers here as needed. # - build_eigen 3.1.1 build_gmp 5.0.5 build_mpfr 3.1.1 -- cgit v0.10.1 From 684e023e849f5ab971d3901d1932ce21ddc3f8e2 Mon Sep 17 00:00:00 2001 From: don bright Date: Thu, 31 Jan 2013 18:47:02 -0800 Subject: detect if boost build fails, print msg and exit diff --git a/scripts/uni-build-dependencies.sh b/scripts/uni-build-dependencies.sh index 6550dcc..3b6a241 100755 --- a/scripts/uni-build-dependencies.sh +++ b/scripts/uni-build-dependencies.sh @@ -62,7 +62,7 @@ build_qt4() QTDIR=$DEPLOYDIR export QTDIR echo "----------" - echo " Please set QTDIR to $DEPLOYDIR ( or run '. scripts/setenv-unibuild.sh' ) + echo " Please set QTDIR to $DEPLOYDIR ( or run '. scripts/setenv-unibuild.sh' )" echo "----------" } @@ -208,7 +208,12 @@ build_boost() fi else ./b2 -j$NUMCPU - ./b2 install + if [ $? = 0 ]; then + ./b2 install + else + echo boost build failed + exit 1 + fi fi } @@ -465,7 +470,7 @@ fi build_eigen 3.1.1 build_gmp 5.0.5 build_mpfr 3.1.1 -build_boost 1.49.0 +build_boost 1.52.0 # NB! For CGAL, also update the actual download URL in the function build_cgal 4.0.2 build_glew 1.9.0 -- cgit v0.10.1 From 1f39090cc0f47893977f8abc33b5f1933a3c275e Mon Sep 17 00:00:00 2001 From: don bright Date: Thu, 31 Jan 2013 20:16:28 -0800 Subject: fix GLU issues caued by mesa split from glu. clarify test error msg diff --git a/scripts/uni-build-dependencies.sh b/scripts/uni-build-dependencies.sh index 3b6a241..6f84482 100755 --- a/scripts/uni-build-dependencies.sh +++ b/scripts/uni-build-dependencies.sh @@ -24,6 +24,7 @@ # # Prerequisites: # - wget or curl +# - OpenGL (gl.h) # - gcc # # Enable Clang (experimental, only works on linux): @@ -41,6 +42,26 @@ printUsage() echo } +build_glu() +{ + version=$1 + if [ -e $DEPLOYDIR/lib/libGLU.so ]; then + echo "GLU already installed. not building" + return + fi + echo "Building GLU" $version "..." + cd $BASEDIR/src + rm -rf glu-$version + if [ ! -f glu-$version.tar.gz ]; then + curl -O http://cgit.freedesktop.org/mesa/glu/snapshot/glu-$version.tar.gz + fi + tar xzf glu-$version.tar.gz + cd glu-$version + ./autogen.sh --prefix=$DEPLOYDIR + make -j$NUMCPU + make install +} + build_qt4() { version=$1 @@ -57,7 +78,7 @@ build_qt4() tar xzf qt-everywhere-opensource-src-$version.tar.gz cd qt-everywhere-opensource-src-$version ./configure -prefix $DEPLOYDIR -opensource -confirm-license -fast -no-qt3support -no-svg -no-phonon -no-audio-backend -no-multimedia -no-javascript-jit -no-script -no-scripttools -no-declarative -no-xmlpatterns -nomake demos -nomake examples -nomake docs -nomake translations -no-webkit - make -j $NUMCPU + make -j$NUMCPU make install QTDIR=$DEPLOYDIR export QTDIR @@ -228,14 +249,15 @@ build_cgal() cd $BASEDIR/src rm -rf CGAL-$version if [ ! -f CGAL-$version.tar.* ]; then - #4.0.2 - curl --insecure -O https://gforge.inria.fr/frs/download.php/31174/CGAL-$version.tar.bz2 - # 4.0 curl --insecure -O https://gforge.inria.fr/frs/download.php/30387/CGAL-$version.tar.gz - # 3.9 curl --insecure -O https://gforge.inria.fr/frs/download.php/29125/CGAL-$version.tar.gz + # 4.1 + curl --insecure -O https://gforge.inria.fr/frs/download.php/31640/CGAL-$version.tar.bz2 + # 4.0.2 curl --insecure -O https://gforge.inria.fr/frs/download.php/31174/CGAL-$version.tar.bz2 + # 4.0 curl --insecure -O https://gforge.inria.fr/frs/download.php/30387/CGAL-$version.tar.gz #4.0 + # 3.9 curl --insecure -O https://gforge.inria.fr/frs/download.php/29125/CGAL-$version.tar.gz #3.9 # 3.8 curl --insecure -O https://gforge.inria.fr/frs/download.php/28500/CGAL-$version.tar.gz # 3.7 curl --insecure -O https://gforge.inria.fr/frs/download.php/27641/CGAL-$version.tar.gz fi - tar jxf CGAL-$version.tar.bz2 + tar xf CGAL-$version.tar.bz2 cd CGAL-$version if [ "`echo $2 | grep use-sys-libs`" ]; then cmake -DCMAKE_INSTALL_PREFIX=$DEPLOYDIR -DWITH_CGAL_Qt3=OFF -DWITH_CGAL_Qt4=OFF -DWITH_CGAL_ImageIO=OFF -DCMAKE_BUILD_TYPE=Debug @@ -301,7 +323,7 @@ build_glew() build_opencsg() { - if [ -e $DEPLOYDIR/include/opencsg.h ]; then + if [ -e $DEPLOYDIR/lib/libopencsg.so ]; then echo "OpenCSG already installed. not building" return fi @@ -460,6 +482,11 @@ if [ $1 ]; then build_qt4 4.8.4 exit fi + if [ $1 == "glu" ]; then + # Mesa and GLU split in late 2012, so it's not on some systems + build_glu 9.0.0 + exit + fi fi @@ -472,7 +499,7 @@ build_gmp 5.0.5 build_mpfr 3.1.1 build_boost 1.52.0 # NB! For CGAL, also update the actual download URL in the function -build_cgal 4.0.2 +build_cgal 4.1 build_glew 1.9.0 build_opencsg 1.3.2 diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index d2daf43..fcf7d08 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -179,6 +179,11 @@ endif(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") set(CMAKE_INCLUDE_DIRECTORIES_BEFORE ON) find_package(OpenGL REQUIRED) +if ( "${OPENGL_glu_LIBRARY}" MATCHES "NOTFOUND" ) + # GLU and Mesa split in late 2012 so some systems dont have GLU + find_library(OPENGL_glu_LIBRARY GLU HINTS "$ENV{OPENSCAD_LIBRARIES}/lib" REQUIRED) + set( OPENGL_LIBRARY ${OPENGL_glu_LIBRARY} ${OPENGL_LIBRARY} ) +endif() if (MINGW_CROSS_ENV_DIR) mingw_cross_env_find_qt() diff --git a/tests/test_cmdline_tool.py b/tests/test_cmdline_tool.py index f29acc0..889c429 100755 --- a/tests/test_cmdline_tool.py +++ b/tests/test_cmdline_tool.py @@ -101,7 +101,7 @@ def compare_png(resultfilename): msg += '\n expected image: ' + expectedfilename + '\n' print >> sys.stderr, msg if not resultfilename: - print >> sys.stderr, "Error: OpenSCAD did not generate an image to test" + print >> sys.stderr, "Error: OpenSCAD error during test image generation" return False print >> sys.stderr, ' actual image: ', resultfilename -- cgit v0.10.1 From 78bfda369b7ee2dfbb59fd64df7a034abc2e1285 Mon Sep 17 00:00:00 2001 From: don bright Date: Fri, 1 Feb 2013 15:36:16 -0800 Subject: prevent CGAL Floating Point Rounding Mode restortaion errors on PPC64 machines by altering the cmake build mode from Debug to Release diff --git a/scripts/uni-build-dependencies.sh b/scripts/uni-build-dependencies.sh index 6f84482..d1c8652 100755 --- a/scripts/uni-build-dependencies.sh +++ b/scripts/uni-build-dependencies.sh @@ -259,10 +259,18 @@ build_cgal() fi tar xf CGAL-$version.tar.bz2 cd CGAL-$version + mkdir bin + cd bin + rm -rf ./* + if [ "`uname -a| grep ppc64`" ]; then + CGAL_BUILDTYPE="Release" # avoid assertion violation + else + CGAL_BUILDTYPE="Debug" + fi if [ "`echo $2 | grep use-sys-libs`" ]; then - cmake -DCMAKE_INSTALL_PREFIX=$DEPLOYDIR -DWITH_CGAL_Qt3=OFF -DWITH_CGAL_Qt4=OFF -DWITH_CGAL_ImageIO=OFF -DCMAKE_BUILD_TYPE=Debug + cmake -DCMAKE_INSTALL_PREFIX=$DEPLOYDIR -DWITH_CGAL_Qt3=OFF -DWITH_CGAL_Qt4=OFF -DWITH_CGAL_ImageIO=OFF -DCMAKE_BUILD_TYPE=$CGAL_BUILDTYPE .. else - cmake -DCMAKE_INSTALL_PREFIX=$DEPLOYDIR -DGMP_INCLUDE_DIR=$DEPLOYDIR/include -DGMP_LIBRARIES=$DEPLOYDIR/lib/libgmp.so -DGMPXX_LIBRARIES=$DEPLOYDIR/lib/libgmpxx.so -DGMPXX_INCLUDE_DIR=$DEPLOYDIR/include -DMPFR_INCLUDE_DIR=$DEPLOYDIR/include -DMPFR_LIBRARIES=$DEPLOYDIR/lib/libmpfr.so -DWITH_CGAL_Qt3=OFF -DWITH_CGAL_Qt4=OFF -DWITH_CGAL_ImageIO=OFF -DBOOST_ROOT=$DEPLOYDIR -DCMAKE_BUILD_TYPE=Debug + cmake -DCMAKE_INSTALL_PREFIX=$DEPLOYDIR -DGMP_INCLUDE_DIR=$DEPLOYDIR/include -DGMP_LIBRARIES=$DEPLOYDIR/lib/libgmp.so -DGMPXX_LIBRARIES=$DEPLOYDIR/lib/libgmpxx.so -DGMPXX_INCLUDE_DIR=$DEPLOYDIR/include -DMPFR_INCLUDE_DIR=$DEPLOYDIR/include -DMPFR_LIBRARIES=$DEPLOYDIR/lib/libmpfr.so -DWITH_CGAL_Qt3=OFF -DWITH_CGAL_Qt4=OFF -DWITH_CGAL_ImageIO=OFF -DBOOST_ROOT=$DEPLOYDIR -DCMAKE_BUILD_TYPE=$CGAL_BUILD_TYPE .. fi make -j$NUMCPU make install -- cgit v0.10.1 From 757820fe1c67290328c77802ea7718505b77f437 Mon Sep 17 00:00:00 2001 From: Justin C Date: Sat, 2 Feb 2013 02:11:42 -0800 Subject: missing NULL check when normalization exceeds limit for elements diff --git a/src/csgtermnormalizer.cc b/src/csgtermnormalizer.cc index e2474e9..81fab80 100644 --- a/src/csgtermnormalizer.cc +++ b/src/csgtermnormalizer.cc @@ -20,7 +20,7 @@ shared_ptr CSGTermNormalizer::normalize(const shared_ptr &root PRINTB("WARNING: Normalized tree is growing past %d elements. Aborting normalization.\n", this->limit); // Clean up any partially evaluated terms shared_ptr newroot = root, tmproot; - while (newroot != tmproot) { + while (newroot && newroot != tmproot) { tmproot = newroot; newroot = collapse_null_terms(tmproot); } -- cgit v0.10.1 From 96903036fdf6612d94f0211171da76f3a5450e3d Mon Sep 17 00:00:00 2001 From: Justin C Date: Sat, 2 Feb 2013 02:12:56 -0800 Subject: add test sample for issue #267 diff --git a/testdata/scad/bugs/issue267-normalization-crash.scad b/testdata/scad/bugs/issue267-normalization-crash.scad new file mode 100644 index 0000000..e4e3d87 --- /dev/null +++ b/testdata/scad/bugs/issue267-normalization-crash.scad @@ -0,0 +1,86 @@ +/* + * Reported by Justin Charette + * Causes a crash in CSGTermNormalizer::normalize() when CSG element count + * exceeds limit setting in preferences (verified with default value of 2000). + */ + + +$fn=20; + +/* donut (r1, r2, t) {{{ + r1 = radius of torus + r2 = radius of torus cross section (circle) + t = thickness of shell (t == 0 is +*/ +module donut (r1, r2, t=0) { + difference() { + rotate_extrude( convexity=6 ) { + translate([r1, 0, 0]) { + circle( r = r2 ); + } + } + // (t == 0 ? solid : hollow ) + if (t > 0) { + rotate_extrude( convexity=6 ) { + translate([r1, 0, 0]) { + circle( r = r2-t ); + } + } + } + } +} //}}} + +/* half donut (r1, r2, t, round) {{{ + r1 = radius of torus + r2 = radius of torus cross section (circle) + t = thickness of shell + round = trim ends of semi-torus so they are round +*/ +module half_donut (r1, r2, t=1, round=false) { + difference() { + donut( r1, r2, t ); + difference() { + translate( [0, -((r1+r2)/2+0.5), 0] ) + scale( [2*(r1+r2)+1, r1+r2+1, 2*r2+1] ) + square( 1, center=true ); + if (round) { + rotate( 90, [0, 1, 0] ) + cylinder( 2*(r1+r2)+2, r2, r2, center=true ); + } + } + } +} //}}} + +/* donut flange (r1, r2, a1, a2, a_step, t, round) {{{ + r1 = radius of torus + r2 = radius of torus cross section (circle) + a1 = starting angle of flange rotation + a2 = stopping angle of flange rotation + a_step = increment size of flange rotation + t = thickness of shell (t == 0 is solid, t in (0, r2) is hollow) + round = (true/false) to trim ends of semi-torus so they are round +*/ +module donut_flange (r1, r2, a1, a2, a_step=1, t=0, round=false) { + difference() { + union() { + for (a = [a1:a_step:a2]) { + rotate( a, [1, 0, 0] ) + half_donut( r1, r2, round ); + } + } + // (t == 0 ? solid : hollow ) + if (t > 0) { + union() { + for (a = [a1:a_step:a2]) { + rotate( a, [1, 0, 0] ) + half_donut( r1, r2-t, round ); + } + } + } + } +} //}}} + +donut( 20, 5 ); +donut_flange( 20, 5, 0, 50, 10, t=1, round=false ); + +// vim: set et sw=2 ts=2 sts=2 ai sta sr fdm=marker: -- cgit v0.10.1 From e357399fd9906604a83dee497b17e074a6fe8876 Mon Sep 17 00:00:00 2001 From: don bright Date: Sat, 2 Feb 2013 07:56:07 -0800 Subject: enable import STL to work on big-endian computers diff --git a/src/import.cc b/src/import.cc index 6a6d925..c17d915 100644 --- a/src/import.cc +++ b/src/import.cc @@ -52,6 +52,9 @@ namespace fs = boost::filesystem; using namespace boost::assign; // bring 'operator+=()' into scope #include "boosty.h" +#include +#include + class ImportModule : public AbstractModule { public: @@ -112,6 +115,69 @@ AbstractNode *ImportModule::evaluate(const Context *ctx, const ModuleInstantiati return node; } +#ifdef _MSC_VER +#pragma pack(push,1) +#endif +struct stl_data { + float i, j, k; + float x1, y1, z1; + float x2, y2, z2; + float x3, y3, z3; + unsigned short acount; +} +#ifdef __GNUC__ + __attribute__ ((packed)) +#endif +#ifdef _MSC_VER +#pragma pack(pop) +#endif +; + +#define STL_FACET_SIZE 4*3*4+2 +union stl_facet { + uint8_t data8[ STL_FACET_SIZE ]; + uint32_t data32[4*3]; + struct facet_data { + // assume 'float' is 'binary32' aka 'single' IEEE 32-bit + // floating point type. + float i, j, k; + float x1, y1, z1; + float x2, y2, z2; + float x3, y3, z3; + uint16_t acount; + } data; +}; + +void uint32_byte_swap( uint32_t &x ) +{ +/*#if defined(__GNUC__) || defined(__clang__) + x = __builtin_bswap32( x ); +#elif defined(_MSVC) + x = _byteswap_ulong( x ); +#else*/ + uint32_t b1 = ( 0x000000FF & x ) << 24; + uint32_t b2 = ( 0x0000FF00 & x ) << 8; + uint32_t b3 = ( 0x00FF0000 & x ) >> 8; + uint32_t b4 = ( 0xFF000000 & x ) >> 24; + x = b1 | b2 | b3 | b4; +//#endif +} + +void stl_endian_repair( uint32_t &x ) +{ +#ifdef BOOST_BIG_ENDIAN + uint32_byte_swap( x ); +#endif +} + +void read_stl_facet( std::ifstream &f, stl_facet &facet ) +{ + f.read( (char*)facet.data8, STL_FACET_SIZE ); + for ( int i = 0; i < 12; i++ ) { + stl_endian_repair( facet.data32[ i ] ); + } +} + PolySet *ImportNode::evaluate_polyset(class PolySetEvaluator *) const { PolySet *p = NULL; @@ -137,9 +203,9 @@ PolySet *ImportNode::evaluate_polyset(class PolySetEvaluator *) const int file_size = f.tellg(); f.seekg(80); if (!f.eof()) { - int facenum = 0; - // FIXME: Assumes little endian - f.read((char *)&facenum, sizeof(int)); + uint32_t facenum = 0; + f.read((char *)&facenum, sizeof(uint32_t)); + stl_endian_repair( facenum ); if (file_size == 80 + 4 + 50*facenum) binary = true; } f.seekg(0); @@ -186,32 +252,24 @@ PolySet *ImportNode::evaluate_polyset(class PolySetEvaluator *) const else { f.ignore(80-5+4); - // FIXME: Assumes little endian while (1) { -#ifdef _MSC_VER -#pragma pack(push,1) -#endif - struct { - float i, j, k; - float x1, y1, z1; - float x2, y2, z2; - float x3, y3, z3; - unsigned short acount; - } -#ifdef __GNUC__ - __attribute__ ((packed)) -#endif - stldata; -#ifdef _MSC_VER -#pragma pack(pop) -#endif - - f.read((char*)&stldata, sizeof(stldata)); +#ifdef BOOST_BIG_ENDIAN + stl_facet facet; + read_stl_facet( f, facet ); + if (f.eof()) break; + p->append_poly(); + p->append_vertex(facet.data.x1, facet.data.y1, facet.data.z1); + p->append_vertex(facet.data.x2, facet.data.y2, facet.data.z2); + p->append_vertex(facet.data.x3, facet.data.y3, facet.data.z3); +#else + stl_data stldata; + f.read((char *)&stldata, sizeof(stldata)); if (f.eof()) break; p->append_poly(); p->append_vertex(stldata.x1, stldata.y1, stldata.z1); p->append_vertex(stldata.x2, stldata.y2, stldata.z2); p->append_vertex(stldata.x3, stldata.y3, stldata.z3); +#endif } } } @@ -244,6 +302,7 @@ PolySet *ImportNode::evaluate_polyset(class PolySetEvaluator *) const } if (p) p->convexity = this->convexity; + std::cout << p->dump() << "\n"; return p; } -- cgit v0.10.1 From e9e62272a6cda04c453dd2d27b1a7e91be05f242 Mon Sep 17 00:00:00 2001 From: don bright Date: Sat, 2 Feb 2013 08:53:13 -0800 Subject: replace packed struct with union. remove some extraneous/debug code diff --git a/src/import.cc b/src/import.cc index c17d915..8980448 100644 --- a/src/import.cc +++ b/src/import.cc @@ -115,67 +115,45 @@ AbstractNode *ImportModule::evaluate(const Context *ctx, const ModuleInstantiati return node; } -#ifdef _MSC_VER -#pragma pack(push,1) -#endif -struct stl_data { - float i, j, k; - float x1, y1, z1; - float x2, y2, z2; - float x3, y3, z3; - unsigned short acount; -} -#ifdef __GNUC__ - __attribute__ ((packed)) -#endif -#ifdef _MSC_VER -#pragma pack(pop) -#endif -; - -#define STL_FACET_SIZE 4*3*4+2 +#define STL_FACET_NUMBYTES 4*3*4+2 +// as there is no 'float32_t' standard, we assume the systems 'float' +// is a 'binary32' aka 'single' standard IEEE 32-bit floating point type union stl_facet { - uint8_t data8[ STL_FACET_SIZE ]; + uint8_t data8[ STL_FACET_NUMBYTES ]; uint32_t data32[4*3]; struct facet_data { - // assume 'float' is 'binary32' aka 'single' IEEE 32-bit - // floating point type. float i, j, k; float x1, y1, z1; float x2, y2, z2; float x3, y3, z3; - uint16_t acount; + uint16_t attribute_byte_count; } data; }; void uint32_byte_swap( uint32_t &x ) { -/*#if defined(__GNUC__) || defined(__clang__) +#if defined(__GNUC__) || defined(__clang__) x = __builtin_bswap32( x ); -#elif defined(_MSVC) +#elif defined(_MSC_VER) x = _byteswap_ulong( x ); -#else*/ +#else uint32_t b1 = ( 0x000000FF & x ) << 24; uint32_t b2 = ( 0x0000FF00 & x ) << 8; uint32_t b3 = ( 0x00FF0000 & x ) >> 8; uint32_t b4 = ( 0xFF000000 & x ) >> 24; x = b1 | b2 | b3 | b4; -//#endif -} - -void stl_endian_repair( uint32_t &x ) -{ -#ifdef BOOST_BIG_ENDIAN - uint32_byte_swap( x ); #endif } void read_stl_facet( std::ifstream &f, stl_facet &facet ) { - f.read( (char*)facet.data8, STL_FACET_SIZE ); + f.read( (char*)facet.data8, STL_FACET_NUMBYTES ); +#ifdef BOOST_BIG_ENDIAN for ( int i = 0; i < 12; i++ ) { - stl_endian_repair( facet.data32[ i ] ); + uint32_byte_swap( facet.data32[ i ] ); } + // we ignore attribute byte count +#endif } PolySet *ImportNode::evaluate_polyset(class PolySetEvaluator *) const @@ -205,7 +183,9 @@ PolySet *ImportNode::evaluate_polyset(class PolySetEvaluator *) const if (!f.eof()) { uint32_t facenum = 0; f.read((char *)&facenum, sizeof(uint32_t)); - stl_endian_repair( facenum ); +#ifdef BOOST_BIG_ENDIAN + uint32_byte_swap( facenum ); +#endif if (file_size == 80 + 4 + 50*facenum) binary = true; } f.seekg(0); @@ -253,7 +233,6 @@ PolySet *ImportNode::evaluate_polyset(class PolySetEvaluator *) const { f.ignore(80-5+4); while (1) { -#ifdef BOOST_BIG_ENDIAN stl_facet facet; read_stl_facet( f, facet ); if (f.eof()) break; @@ -261,15 +240,6 @@ PolySet *ImportNode::evaluate_polyset(class PolySetEvaluator *) const p->append_vertex(facet.data.x1, facet.data.y1, facet.data.z1); p->append_vertex(facet.data.x2, facet.data.y2, facet.data.z2); p->append_vertex(facet.data.x3, facet.data.y3, facet.data.z3); -#else - stl_data stldata; - f.read((char *)&stldata, sizeof(stldata)); - if (f.eof()) break; - p->append_poly(); - p->append_vertex(stldata.x1, stldata.y1, stldata.z1); - p->append_vertex(stldata.x2, stldata.y2, stldata.z2); - p->append_vertex(stldata.x3, stldata.y3, stldata.z3); -#endif } } } @@ -302,7 +272,6 @@ PolySet *ImportNode::evaluate_polyset(class PolySetEvaluator *) const } if (p) p->convexity = this->convexity; - std::cout << p->dump() << "\n"; return p; } -- cgit v0.10.1 From 2eda86bf2f2540d4c9eda255c5fae58d71b5b31f Mon Sep 17 00:00:00 2001 From: Marius Kintel Date: Sat, 2 Feb 2013 13:28:00 -0500 Subject: Fix bug assuming negative doubles will overflow a size_t, which failed on ARM. Related to #259 diff --git a/src/control.cc b/src/control.cc index bdd0f40..44847f5 100644 --- a/src/control.cc +++ b/src/control.cc @@ -96,8 +96,10 @@ AbstractNode *ControlModule::evaluate(const Context*, const ModuleInstantiation size_t n = 0; if (inst->argvalues.size() > 0) { double v; - if (inst->argvalues[0].getDouble(v)) - n = v; + if (inst->argvalues[0].getDouble(v)) { + if (v < 0) return NULL; // Disallow negative child indices + n = trunc(v); + } } for (int i = Context::ctx_stack.size()-1; i >= 0; i--) { const Context *c = Context::ctx_stack[i]; -- cgit v0.10.1 From 52cb3b00c2ce6981e3d3e7588fb11ab44b7c962f Mon Sep 17 00:00:00 2001 From: don bright Date: Sat, 2 Feb 2013 20:04:05 +0100 Subject: start Xvfb on random DISPLAY number. diff --git a/tests/CTestCustom.template b/tests/CTestCustom.template index 72e6443..0e51e21 100644 --- a/tests/CTestCustom.template +++ b/tests/CTestCustom.template @@ -37,8 +37,10 @@ if( __cmake_system_name__ MATCHES "Linux|BSD") message("Process ID of vfb: ${VFB_PID}") endif() if ("${VFB_DISPLAY}" STREQUAL "" OR "${VFB_PID}" STREQUAL "") - message("Virtual framebuffer had a problem starting.") - execute_process("cat virtualfblog") + set(VFBLOG "virtualfb.log") + message("Virtual framebuffer had a problem starting. Printing ${VFBLOG}") + execute_process(COMMAND cat virtualfb.log OUTPUT_VARIABLE VFBLOGTXT) + message("Log: ${VFBLOGTXT}") else() message("Virtual framebuffer started. DISPLAY=${VFB_DISPLAY}, PID=${VFB_PID}") endif() diff --git a/tests/virtualfb.sh b/tests/virtualfb.sh index 3c0cf0e..e745765 100755 --- a/tests/virtualfb.sh +++ b/tests/virtualfb.sh @@ -13,8 +13,9 @@ if [ ! $VFB_BINARY ]; then exit 1 fi -DISPLAY=:98 -$VFB_BINARY $DISPLAY -screen 0 800x600x24 &> virtualfblog & +DISPLAY=`echo | awk 'BEGIN{srand();} {printf ":%.0f", rand()*1000+100};'` +#DISPLAY=:98 +$VFB_BINARY $DISPLAY -screen 0 800x600x24 &> virtualfb.log & echo PID=$! " " echo DISPLAY=$DISPLAY # trap "kill -KILL $xpid ||:" EXIT -- cgit v0.10.1 From c48520aa4a1316f42baea87d5c333d13f85caf56 Mon Sep 17 00:00:00 2001 From: don bright Date: Sat, 2 Feb 2013 20:17:36 +0100 Subject: clarify documentation for QT4 diff --git a/scripts/uni-build-dependencies.sh b/scripts/uni-build-dependencies.sh index d1c8652..bf3a2e8 100755 --- a/scripts/uni-build-dependencies.sh +++ b/scripts/uni-build-dependencies.sh @@ -27,11 +27,16 @@ # - OpenGL (gl.h) # - gcc # -# Enable Clang (experimental, only works on linux): +# If your system lacks qt4, build like this: +# +# ./scripts/uni-build-dependencies.sh qt4 +# . ./scripts/setenv-unibuild.sh +# +# If you want to try Clang compiler (experimental, only works on linux): # # . ./scripts/setenv-unibuild.sh clang # -# Enable Qt5 (experimental) +# If you want to try Qt5 (experimental) # # . ./scripts/setenv-unibuild.sh qt5 # -- cgit v0.10.1 From 27eac3ead0e2a9f6b35c41921b315ee2518f8142 Mon Sep 17 00:00:00 2001 From: don bright Date: Sat, 2 Feb 2013 20:28:12 +0100 Subject: clarify dependency on GLU in documentation diff --git a/scripts/uni-build-dependencies.sh b/scripts/uni-build-dependencies.sh index bf3a2e8..f149090 100755 --- a/scripts/uni-build-dependencies.sh +++ b/scripts/uni-build-dependencies.sh @@ -24,14 +24,20 @@ # # Prerequisites: # - wget or curl -# - OpenGL (gl.h) +# - OpenGL (GL/gl.h) +# - GLU (GL/glu.h) # - gcc +# - Qt4 # # If your system lacks qt4, build like this: # # ./scripts/uni-build-dependencies.sh qt4 # . ./scripts/setenv-unibuild.sh # +# If your system lacks glu, try to build like this: +# +# ./scripts/uni-build-dependencies.sh glu +# # If you want to try Clang compiler (experimental, only works on linux): # # . ./scripts/setenv-unibuild.sh clang -- cgit v0.10.1 From 61fffc0e5b92c9bda7e376983fdc90b498eed745 Mon Sep 17 00:00:00 2001 From: don bright Date: Sat, 2 Feb 2013 20:30:03 +0100 Subject: put boost back to 1.49 diff --git a/scripts/uni-build-dependencies.sh b/scripts/uni-build-dependencies.sh index f149090..bf5ca1c 100755 --- a/scripts/uni-build-dependencies.sh +++ b/scripts/uni-build-dependencies.sh @@ -516,7 +516,7 @@ fi build_eigen 3.1.1 build_gmp 5.0.5 build_mpfr 3.1.1 -build_boost 1.52.0 +build_boost 1.49.0 # NB! For CGAL, also update the actual download URL in the function build_cgal 4.1 build_glew 1.9.0 -- cgit v0.10.1 From 1a545b75f6bd05a0eca42e1f797aa4853aca88d6 Mon Sep 17 00:00:00 2001 From: don bright Date: Sat, 2 Feb 2013 15:44:25 -0800 Subject: workaround cmake 2.8.10 not allowing CTEST_CUSTOM_POST_TEST arguments diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index d2daf43..854fb44 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -569,6 +569,15 @@ set_target_properties(throwntogethertest PROPERTIES COMPILE_FLAGS "-DENABLE_OPEN target_link_libraries(throwntogethertest tests-offscreen tests-cgal ${OPENCSG_LIBRARY} ${TESTS-CGAL-LIBRARIES} ${GLEW_LIBRARY} ${COCOA_LIBRARY}) # +# Post-test pretty print +# + +add_executable(test_pretty_print test_pretty_print.cc) +set_target_properties(test_pretty_print PROPERTIES COMPILE_FLAGS + "-DPYBIN=${PYTHON_EXECUTABLE} -DPYSRC=test_pretty_print.py -DBUILDDIR=--builddir=${CMAKE_CURRENT_BINARY_DIR}" +) + +# # Tags tests as disabled. This is more convenient than removing them manually # from the lists of filenames # diff --git a/tests/CTestCustom.template b/tests/CTestCustom.template index 72e6443..8ab2f5b 100644 --- a/tests/CTestCustom.template +++ b/tests/CTestCustom.template @@ -24,8 +24,7 @@ if( __cmake_system_name__ MATCHES "Linux|BSD") else() message("X11 DISPLAY environment variable not found. Calling virtualfb.sh") execute_process( - COMMAND __cmake_current_source_dir__/virtualfb.sh start - OUTPUT_VARIABLE SVFB_OUT) + COMMAND __cmake_current_source_dir__/virtualfb.sh OUTPUT_VARIABLE SVFB_OUT) string(REGEX MATCH "DISPLAY=:[0-9.]*" VFB_DISPLAY_STR "${SVFB_OUT}") string(REGEX MATCH ":[0-9.]*" VFB_DISPLAY "${VFB_DISPLAY_STR}") string(REGEX MATCH "PID=[0-9.]*" VFB_PID_STR "${SVFB_OUT}") @@ -50,7 +49,7 @@ if( __cmake_system_name__ MATCHES "Linux|BSD") # in the build directory). set(ENV{DISPLAY} "${VFB_DISPLAY}") - set(CTEST_CUSTOM_POST_TEST "kill ${VFB_PID}") + set(CTEST_CUSTOM_POST_TEST "__cmake_current_source_dir__/virtualfb.sh") endif() endif() @@ -59,7 +58,7 @@ endif() message("running 'opencsgtest --info' to generate sysinfo.txt") execute_process(COMMAND __wine__ __cmake_current_binary_dir__/opencsgtest --info OUTPUT_FILE sysinfo.txt) -set(CTEST_CUSTOM_POST_TEST ${CTEST_CUSTOM_POST_TEST} "__python__ __cmake_current_source_dir__/test_pretty_print.py --builddir=__cmake_current_binary_dir__") +set(CTEST_CUSTOM_POST_TEST ${CTEST_CUSTOM_POST_TEST} "__cmake_current_binary_dir__/test_pretty_print") if ( ${debug_openscad_template} ) foreach(post_test ${CTEST_CUSTOM_POST_TEST} ) diff --git a/tests/test_pretty_print.cc b/tests/test_pretty_print.cc new file mode 100644 index 0000000..b400e21 --- /dev/null +++ b/tests/test_pretty_print.cc @@ -0,0 +1,22 @@ +/* Workaround for CTEST_CUSTOM_POST_TEST not allowing arguments + compile with + -DPYBIN=/usr/bin/python + -DPYSRC=/home/janedoe/openscad/tests/test_pretty_print.py + -DBUILDDIR=--builddir=/home/janedoe/openscad/tests/bin" +*/ + +#include + +#define PREQUOTE(x) #x +#define QUOTE(x) PREQUOTE(x) +int main( int argc, char * argv[] ) +{ + char *newargs[4]; + newargs[0] = const_cast(QUOTE( PYBIN )); + newargs[1] = const_cast(QUOTE( PYSRC )); + newargs[2] = const_cast(QUOTE( BUILDDIR )); + newargs[3] = NULL; + return execv( newargs[0], newargs ); +} + + diff --git a/tests/virtualfb.sh b/tests/virtualfb.sh index 3c0cf0e..e0d8320 100755 --- a/tests/virtualfb.sh +++ b/tests/virtualfb.sh @@ -1,22 +1,60 @@ #!/bin/sh -if [ "`command -v Xvfb`" ]; then - VFB_BINARY=Xvfb -fi +# Toggle the Virtual Framebuffer +# If started, stop. If stopped, start. -if [ "`command -v Xvnc`" ]; then - VFB_BINARY=Xvnc -fi +start() +{ + if [ "`command -v Xvfb`" ]; then + VFB_BINARY=Xvfb + fi + + if [ "`command -v Xvnc`" ]; then + VFB_BINARY=Xvnc + fi + + if [ ! $VFB_BINARY ]; then + echo "$0 Failed, cannot find Xvfb or Xvnc" + exit 1 + fi + + VFB_DISPLAY=`echo | awk 'BEGIN{srand();} {printf ":%.0f", rand()*1000+100};'` + $VFB_BINARY $VFB_DISPLAY -screen 0 800x600x24 &> ./virtualfb.log & + VFB_PID=$! + + echo $VFB_DISPLAY > ./virtualfb.DISPLAY + echo $VFB_PID > ./virtualfb.PID + + echo "Started virtual fb, PID=$VFB_PID , DISPLAY=$VFB_DISPLAY" + sleep 1 +} + +stop() +{ + VFB_PID=`cat ./virtualfb.PID` + VFB_DISPLAY=`cat ./virtualfb.DISPLAY` + + echo "Stopping virtual fb, PID=$VFB_PID, DISPLAY=$VFB_DISPLAY" + kill $VFB_PID + LOCKFILE=`echo "/tmp/.X"$VFB_DISPLAY"-lock"` + if [ -e $LOCKFILE ]; then + rm $LOCKFILE + fi + rm ./virtualfb.PID + rm ./virtualfb.DISPLAY +} + +isrunning() +{ + isrunning_result= + if [ -e ./virtualfb.PID ]; then isrunning_result=1 ; fi + if [ -e ./virtualfb.DISPLAY ]; then isrunning_result=1 ; fi +} -if [ ! $VFB_BINARY ]; then - echo "$0 Failed, cannot find Xvfb or Xvnc" - exit 1 +isrunning +if [ $isrunning_result ]; then + stop +else + start fi -DISPLAY=:98 -$VFB_BINARY $DISPLAY -screen 0 800x600x24 &> virtualfblog & -echo PID=$! " " -echo DISPLAY=$DISPLAY -# trap "kill -KILL $xpid ||:" EXIT -export DISPLAY -sleep 3 -- cgit v0.10.1 From 8c9c9adfe0f0fa5c1ade561a61f3f8add3600c22 Mon Sep 17 00:00:00 2001 From: don bright Date: Sun, 3 Feb 2013 01:21:47 +0100 Subject: improve Xvfb handling when ctest is cancelled partway through diff --git a/tests/virtualfb.sh b/tests/virtualfb.sh index e0d8320..d34a4f9 100755 --- a/tests/virtualfb.sh +++ b/tests/virtualfb.sh @@ -47,8 +47,12 @@ stop() isrunning() { isrunning_result= - if [ -e ./virtualfb.PID ]; then isrunning_result=1 ; fi - if [ -e ./virtualfb.DISPLAY ]; then isrunning_result=1 ; fi + if [ -e ./virtualfb.PID ]; then + VFB_PID=`cat ./virtualfb.PID` + if [ "`ps cax | awk ' { print $1 } ' | grep ^$VFB_PID\$`" ]; then + isrunning_result=1 + fi + fi } isrunning -- cgit v0.10.1 From b390d54471201731db1158fa21aa54fcef1f7582 Mon Sep 17 00:00:00 2001 From: don bright Date: Sun, 3 Feb 2013 01:39:43 +0100 Subject: fix bug in test_pretty_print.cc / Cmakefile The build needs to be after Python binary has been found because the Python binary path is passed to the .cc compile through a -D flag. diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 854fb44..611cb5f 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -569,15 +569,6 @@ set_target_properties(throwntogethertest PROPERTIES COMPILE_FLAGS "-DENABLE_OPEN target_link_libraries(throwntogethertest tests-offscreen tests-cgal ${OPENCSG_LIBRARY} ${TESTS-CGAL-LIBRARIES} ${GLEW_LIBRARY} ${COCOA_LIBRARY}) # -# Post-test pretty print -# - -add_executable(test_pretty_print test_pretty_print.cc) -set_target_properties(test_pretty_print PROPERTIES COMPILE_FLAGS - "-DPYBIN=${PYTHON_EXECUTABLE} -DPYSRC=test_pretty_print.py -DBUILDDIR=--builddir=${CMAKE_CURRENT_BINARY_DIR}" -) - -# # Tags tests as disabled. This is more convenient than removing them manually # from the lists of filenames # @@ -800,6 +791,15 @@ endif() # 1. Start/stop Virtual Framebuffer for linux/bsd. 2. Pretty Print # Please see the CTestCustom.template file for more info. +# +# Post-test pretty print +# + +add_executable(test_pretty_print test_pretty_print.cc) +set_target_properties(test_pretty_print PROPERTIES COMPILE_FLAGS + "-DPYBIN=${PYTHON_EXECUTABLE} -DPYSRC=test_pretty_print.py -DBUILDDIR=--builddir=${CMAKE_CURRENT_BINARY_DIR}" +) + file(READ ${CMAKE_CURRENT_SOURCE_DIR}/CTestCustom.template TMP) string(REPLACE __cmake_current_binary_dir__ ${CMAKE_CURRENT_BINARY_DIR} TMP ${TMP}) string(REPLACE __cmake_current_source_dir__ ${CMAKE_CURRENT_SOURCE_DIR} TMP ${TMP}) diff --git a/tests/test_pretty_print.cc b/tests/test_pretty_print.cc index b400e21..9959189 100644 --- a/tests/test_pretty_print.cc +++ b/tests/test_pretty_print.cc @@ -1,11 +1,12 @@ /* Workaround for CTEST_CUSTOM_POST_TEST not allowing arguments compile with - -DPYBIN=/usr/bin/python + -DPYBIN=/usr/bin/python -DPYSRC=/home/janedoe/openscad/tests/test_pretty_print.py -DBUILDDIR=--builddir=/home/janedoe/openscad/tests/bin" */ #include +//#include #define PREQUOTE(x) #x #define QUOTE(x) PREQUOTE(x) @@ -16,6 +17,7 @@ int main( int argc, char * argv[] ) newargs[1] = const_cast(QUOTE( PYSRC )); newargs[2] = const_cast(QUOTE( BUILDDIR )); newargs[3] = NULL; + //printf(":%s:%s:%s\n", newargs[0], newargs[1], newargs[2]); return execv( newargs[0], newargs ); } diff --git a/tests/virtualfb.sh b/tests/virtualfb.sh index d34a4f9..5abd804 100755 --- a/tests/virtualfb.sh +++ b/tests/virtualfb.sh @@ -34,7 +34,7 @@ stop() VFB_PID=`cat ./virtualfb.PID` VFB_DISPLAY=`cat ./virtualfb.DISPLAY` - echo "Stopping virtual fb, PID=$VFB_PID, DISPLAY=$VFB_DISPLAY" + echo "Stopping virtual fb, PID was $VFB_PID, DISPLAY was $VFB_DISPLAY" kill $VFB_PID LOCKFILE=`echo "/tmp/.X"$VFB_DISPLAY"-lock"` if [ -e $LOCKFILE ]; then -- cgit v0.10.1 From 3f7037b5242eed0175ca2c9780d7d02bd6943959 Mon Sep 17 00:00:00 2001 From: Marius Kintel Date: Mon, 4 Feb 2013 12:29:00 -0500 Subject: bugfix: We didn't always print a warning when CSG normalization created too many elements diff --git a/src/csgtermnormalizer.cc b/src/csgtermnormalizer.cc index 81fab80..461e965 100644 --- a/src/csgtermnormalizer.cc +++ b/src/csgtermnormalizer.cc @@ -7,6 +7,7 @@ */ shared_ptr CSGTermNormalizer::normalize(const shared_ptr &root) { + this->aborted = false; shared_ptr temp = root; while (1) { this->rootnode = temp; @@ -49,14 +50,16 @@ shared_ptr CSGTermNormalizer::normalizePass(shared_ptr term) while (term && match_and_replace(term)) { } this->nodecount++; if (nodecount > this->limit) { + PRINTB("WARNING: Normalized tree is growing past %d elements. Aborting normalization.\n", this->limit); + this->aborted = true; return shared_ptr(); } if (!term || term->type == CSGTerm::TYPE_PRIMITIVE) return term; if (term->left) term->left = normalizePass(term->left); - } while (term->type != CSGTerm::TYPE_UNION && + } while (!this->aborted && term->type != CSGTerm::TYPE_UNION && ((term->right && term->right->type != CSGTerm::TYPE_PRIMITIVE) || (term->left && term->left->type == CSGTerm::TYPE_UNION))); - term->right = normalizePass(term->right); + if (!this->aborted) term->right = normalizePass(term->right); // FIXME: Do we need to take into account any transformation of item here? return collapse_null_terms(term); diff --git a/src/csgtermnormalizer.h b/src/csgtermnormalizer.h index c331f11..f7a444f 100644 --- a/src/csgtermnormalizer.h +++ b/src/csgtermnormalizer.h @@ -17,6 +17,7 @@ private: shared_ptr collapse_null_terms(const shared_ptr &term); unsigned int count(const shared_ptr &term) const; + bool aborted; size_t limit; size_t nodecount; shared_ptr rootnode; -- cgit v0.10.1 From 03be37d16b585e64de87118053206aaae06e7cf8 Mon Sep 17 00:00:00 2001 From: Marius Kintel Date: Mon, 4 Feb 2013 14:08:23 -0500 Subject: Sync with latest commits diff --git a/RELEASE_NOTES b/RELEASE_NOTES index 4448e89..1e0a737 100644 --- a/RELEASE_NOTES +++ b/RELEASE_NOTES @@ -1,3 +1,17 @@ +OpenSCAD 2013.XX +================ + +Features: +o Console output is now enabled on Windows through the openscad.com executable +o Added basic syntax highlighting in the editor + +Bugfixes: +o OpenCSG rendering sometimes crashed when rendering large models +o We didn't always print a warning when CSG normalization created too many elements +o Binary STLs can now be read on big endian architectures +o Some binary STLs couldn't be read +o Fixed some issues related to ARM builds + OpenSCAD 2013.01 ================ -- cgit v0.10.1