From 9f6819e68501de16563aeaaadd65dfc915092169 Mon Sep 17 00:00:00 2001 From: don bright Date: Sat, 18 Aug 2012 22:28:36 +0200 Subject: initial rework to enable eigen3 per issue #174. 1. enable eigen3 in qmake build system 2. convert Transform3d and cwise() per the eigen2->eigen3 porting faq online 3. get rid of 'using namespace boost::filesystem' as it conflicts with eigen3 diff --git a/common.pri b/common.pri index d6e8480..9e3555f 100644 --- a/common.pri +++ b/common.pri @@ -9,5 +9,8 @@ include(bison.pri) include(cgal.pri) include(opencsg.pri) include(glew.pri) -include(eigen2.pri) include(boost.pri) + +CONFIG(eigen2) { include(eigen2.pri) } +CONFIG(eigen3) { include(eigen3.pri) } + diff --git a/eigen2.pri b/eigen2.pri index 0bda55b..701f92a 100644 --- a/eigen2.pri +++ b/eigen2.pri @@ -1,5 +1,5 @@ eigen2 { - +message("hi 2") CONFIG(mingw-cross-env) { EIGEN2_INCLUDEPATH = mingw-cross-env/include/eigen2 } diff --git a/eigen3.pri b/eigen3.pri new file mode 100644 index 0000000..20d85fc --- /dev/null +++ b/eigen3.pri @@ -0,0 +1,43 @@ +eigen3 { + CONFIG(mingw-cross-env) { + EIGEN3_INCLUDEPATH = mingw-cross-env/include/eigen3 + } + + # Optionally specify location of Eigen3 using the + # OPENSCAD_LIBRARIES env. variable + isEmpty(EIGEN3_INCLUDEPATH) { + OPENSCAD_LIBRARIES_DIR = $$(OPENSCAD_LIBRARIES) + !isEmpty(OPENSCAD_LIBRARIES_DIR) { + exists($$OPENSCAD_LIBRARIES_DIR/include/eigen3) { + EIGEN3_INCLUDEPATH = $$OPENSCAD_LIBRARIES_DIR/include/eigen3 + } + } + } + + # Optionally specify location of Eigen3 using the + # EIGEN3DIR env. variable + isEmpty(EIGEN3_INCLUDEPATH) { + EIGEN3_DIR = $$(EIGEN3DIR) + !isEmpty(EIGEN3_DIR) { + EIGEN3_INCLUDEPATH = $$EIGEN3_DIR + message("EIGEN3 location: $$EIGEN3_INCLUDEPATH") + } + } + + isEmpty(EIGEN3_INCLUDEPATH) { + freebsd-g++: EIGEN3_INCLUDEPATH = /usr/local/include/eigen3 + macx: EIGEN3_INCLUDEPATH = /opt/local/include/eigen3 + linux*|hurd*: EIGEN3_INCLUDEPATH = /usr/include/eigen3 + netbsd*: EIGEN3_INCLUDEPATH = /usr/pkg/include/eigen3 + } + + # EIGEN3 being under 'include/eigen3' needs special prepending + QMAKE_INCDIR_QT = $$EIGEN3_INCLUDEPATH $$QMAKE_INCDIR_QT + + # disable Eigen SIMD optimizations for platforms where it breaks compilation + !macx { + !freebsd-g++ { + QMAKE_CXXFLAGS += -DEIGEN_DONT_ALIGN + } + } +} diff --git a/openscad.pro b/openscad.pro index f11a494..a76383c 100644 --- a/openscad.pro +++ b/openscad.pro @@ -4,6 +4,7 @@ # BOOSTDIR # CGALDIR # EIGEN2DIR +# EIGEN3DIR # GLEWDIR # OPENCSGDIR # OPENSCAD_LIBRARIES @@ -123,7 +124,12 @@ macx:CONFIG += mdi CONFIG += cgal CONFIG += opencsg CONFIG += boost -CONFIG += eigen2 +#macx { +unix { + CONFIG += eigen3 +} else { + CONFIG += eigen2 +} #Uncomment the following line to enable QCodeEdit #CONFIG += qcodeedit diff --git a/scripts/linux-build-dependencies.sh b/scripts/linux-build-dependencies.sh index aee423c..6f31d5d 100755 --- a/scripts/linux-build-dependencies.sh +++ b/scripts/linux-build-dependencies.sh @@ -248,6 +248,7 @@ build_eigen() rm -rf eigen-$version ## Directory name for v2.0.17 rm -rf eigen-eigen-b23437e61a07 + rm -rf eigen-eigen-43d9075b23ef # 3.1.1 if [ ! -f eigen-$version.tar.bz2 ]; then curl -LO http://bitbucket.org/eigen/eigen/get/$version.tar.bz2 mv $version.tar.bz2 eigen-$version.tar.bz2 @@ -255,13 +256,15 @@ build_eigen() tar xjf eigen-$version.tar.bz2 ## File name for v2.0.17 ln -s eigen-eigen-b23437e61a07 eigen-$version + ln -s eigen-eigen-43d9075b23ef eigen-$version # 3.1.1 cd eigen-$version - cmake -DCMAKE_INSTALL_PREFIX=$DEPLOYDIR + mkdir build + cd build + cmake -DCMAKE_INSTALL_PREFIX=$DEPLOYDIR .. make -j$NUMCPU make install } - OPENSCADDIR=$PWD if [ ! -f $OPENSCADDIR/openscad.pro ]; then echo "Must be run from the OpenSCAD source root directory" @@ -321,12 +324,13 @@ fi # build_eigen 2.0.17 -build_gmp 5.0.5 -build_mpfr 3.1.1 -build_boost 1.47.0 +#build_eigen 3.1.1 +#build_gmp 5.0.5 +#build_mpfr 3.1.1 +#build_boost 1.47.0 # NB! For CGAL, also update the actual download URL in the function -build_cgal 4.0.2 -build_glew 1.7.0 -build_opencsg 1.3.2 +#build_cgal 4.0.2 +#build_glew 1.7.0 +#build_opencsg 1.3.2 echo "OpenSCAD dependencies built and installed to " $BASEDIR diff --git a/src/csgterm.cc b/src/csgterm.cc index 0e68320..aed97b2 100644 --- a/src/csgterm.cc +++ b/src/csgterm.cc @@ -66,16 +66,29 @@ shared_ptr CSGTerm::createCSGTerm(type_e type, shared_ptr left // http://www.cc.gatech.edu/~turk/my_papers/pxpl_csg.pdf const BoundingBox &leftbox = left->getBoundingBox(); const BoundingBox &rightbox = right->getBoundingBox(); + Vector3d newmin, newmax; if (type == TYPE_INTERSECTION) { - BoundingBox newbox(leftbox.min().cwise().max(rightbox.min()), - leftbox.max().cwise().min(rightbox.max())); +#if EIGEN_WORLD_VERSION == 2 + newmin = leftbox.min().cwise().max( rightbox.min() ); + newmax = leftbox.max().cwise().min( rightbox.max() ); +#else + newmin = leftbox.min().array().cwiseMax( rightbox.min().array() ); + newmax = leftbox.max().array().cwiseMin( rightbox.max().array() ); +#endif + BoundingBox newbox( newmin, newmax ); if (newbox.isNull()) { return shared_ptr(); // Prune entire product } } else if (type == TYPE_DIFFERENCE) { - BoundingBox newbox(leftbox.min().cwise().max(rightbox.min()), - leftbox.max().cwise().min(rightbox.max())); +#if EIGEN_WORLD_VERSION == 2 + newmin = leftbox.min().cwise().max( rightbox.min() ); + newmax = leftbox.max().cwise().min( rightbox.max() ); +#else + newmin = leftbox.min().array().cwiseMax( rightbox.min().array() ); + newmax = leftbox.max().array().cwiseMin( rightbox.max().array() ); +#endif + BoundingBox newbox( newmin, newmax ); if (newbox.isNull()) { return left; // Prune the negative component } @@ -119,14 +132,27 @@ void CSGTerm::initBoundingBox() else { const BoundingBox &leftbox = this->left->getBoundingBox(); const BoundingBox &rightbox = this->right->getBoundingBox(); + Vector3d newmin, newmax; switch (this->type) { case TYPE_UNION: - this->bbox = this->m * BoundingBox(leftbox.min().cwise().min(rightbox.min()), - leftbox.max().cwise().max(rightbox.max())); +#if EIGEN_WORLD_VERSION == 2 + newmin = leftbox.min().cwise().min( rightbox.min() ); + newmax = leftbox.max().cwise().max( rightbox.max() ); +#else + newmin = leftbox.min().array().cwiseMin( rightbox.min().array() ); + newmax = leftbox.max().array().cwiseMax( rightbox.max().array() ); +#endif + this->bbox = this->m * BoundingBox( newmin, newmax ); break; case TYPE_INTERSECTION: - this->bbox = this->m * BoundingBox(leftbox.min().cwise().max(rightbox.min()), - leftbox.max().cwise().min(rightbox.max())); +#if EIGEN_WORLD_VERSION == 2 + newmin = leftbox.min().cwise().max( rightbox.min() ); + newmax = leftbox.max().cwise().min( rightbox.max() ); +#else + newmin = leftbox.min().array().cwiseMax( rightbox.min().array() ); + newmax = leftbox.max().array().cwiseMin( rightbox.max().array() ); +#endif + this->bbox = this->m * BoundingBox( newmin, newmax ); break; case TYPE_DIFFERENCE: this->bbox = this->m * leftbox; diff --git a/src/dxfdata.h b/src/dxfdata.h index 64853dc..80a23f6 100644 --- a/src/dxfdata.h +++ b/src/dxfdata.h @@ -30,6 +30,8 @@ public: #ifdef __APPLE__ std::vector > points; +#elif EIGEN_WORLD_VERSION == 3 + std::vector > points; #else std::vector points; #endif diff --git a/src/dxfdim.cc b/src/dxfdim.cc index 8f68ac6..4af3526 100644 --- a/src/dxfdim.cc +++ b/src/dxfdim.cc @@ -36,10 +36,10 @@ #include #include -using namespace boost::filesystem; boost::unordered_map dxf_dim_cache; boost::unordered_map dxf_cross_cache; +namespace fs = boost::filesystem; Value builtin_dxf_dim(const Context *ctx, const std::vector &argnames, const std::vector &args) { @@ -65,13 +65,14 @@ Value builtin_dxf_dim(const Context *ctx, const std::vector &argnam std::stringstream keystream; keystream << filename << "|" << layername << "|" << name << "|" << xorigin - << "|" << yorigin <<"|" << scale << "|" << last_write_time(filename) - << "|" << file_size(filename); + << "|" << yorigin <<"|" << scale << "|" << fs::last_write_time(filename) + << "|" << fs::file_size(filename); std::string key = keystream.str(); if (dxf_dim_cache.find(key) != dxf_dim_cache.end()) return dxf_dim_cache.find(key)->second; DxfData dxf(36, 0, 0, filename, layername, xorigin, yorigin, scale); +/* for (size_t i = 0; i < dxf.dims.size(); i++) { @@ -123,12 +124,13 @@ Value builtin_dxf_dim(const Context *ctx, const std::vector &argnam PRINTB("WARNING: Can't find dimension '%s' in '%s', layer '%s'!", name % filename % layername); +*/ return Value(); } Value builtin_dxf_cross(const Context *ctx, const std::vector &argnames, const std::vector &args) { - std::string filename; +/* std::string filename; std::string layername; double xorigin = 0; double yorigin = 0; @@ -186,7 +188,7 @@ Value builtin_dxf_cross(const Context *ctx, const std::vector &argn } PRINTB("WARNING: Can't find cross in '%s', layer '%s'!", filename % layername); - +*/ return Value(); } diff --git a/src/import.cc b/src/import.cc index dc40c8d..2f08b11 100644 --- a/src/import.cc +++ b/src/import.cc @@ -47,7 +47,7 @@ #include #include #include -using namespace boost::filesystem; +namespace fs = boost::filesystem; #include using namespace boost::assign; // bring 'operator+=()' into scope #include "boosty.h" diff --git a/src/linalg.h b/src/linalg.h index 65243dc..eb3d22d 100644 --- a/src/linalg.h +++ b/src/linalg.h @@ -12,7 +12,11 @@ typedef Eigen::AlignedBox BoundingBox; using Eigen::Matrix3f; using Eigen::Matrix3d; using Eigen::Matrix4d; -using Eigen::Transform3d; +#if EIGEN_WORLD_VERSION>=3 +#define Transform3d Eigen::Affine3d +#else +using Eigen::Transform3d +#endif BoundingBox operator*(const Transform3d &m, const BoundingBox &box); -- cgit v0.10.1 From 10c7607541e502f2d0ff7c2c49fd70809704c039 Mon Sep 17 00:00:00 2001 From: don bright Date: Sat, 18 Aug 2012 22:44:46 +0200 Subject: more eigen3 fixes. 1. finish converting 'using namespace boost::filsystem' to 'namespace fs = boost::filesystem'. 2. initial version of changes to CMakelists.txt for the regression test diff --git a/src/dxfdim.cc b/src/dxfdim.cc index 4af3526..dfe8c13 100644 --- a/src/dxfdim.cc +++ b/src/dxfdim.cc @@ -72,7 +72,6 @@ Value builtin_dxf_dim(const Context *ctx, const std::vector &argnam return dxf_dim_cache.find(key)->second; DxfData dxf(36, 0, 0, filename, layername, xorigin, yorigin, scale); -/* for (size_t i = 0; i < dxf.dims.size(); i++) { @@ -124,13 +123,12 @@ Value builtin_dxf_dim(const Context *ctx, const std::vector &argnam PRINTB("WARNING: Can't find dimension '%s' in '%s', layer '%s'!", name % filename % layername); -*/ return Value(); } Value builtin_dxf_cross(const Context *ctx, const std::vector &argnames, const std::vector &args) { -/* std::string filename; + std::string filename; std::string layername; double xorigin = 0; double yorigin = 0; @@ -149,8 +147,8 @@ Value builtin_dxf_cross(const Context *ctx, const std::vector &argn std::stringstream keystream; keystream << filename << "|" << layername << "|" << xorigin << "|" << yorigin - << "|" << scale << "|" << last_write_time(filename) - << "|" << file_size(filename); + << "|" << scale << "|" << fs::last_write_time(filename) + << "|" << fs::file_size(filename); std::string key = keystream.str(); if (dxf_cross_cache.find(key) != dxf_cross_cache.end()) @@ -188,7 +186,6 @@ Value builtin_dxf_cross(const Context *ctx, const std::vector &argn } PRINTB("WARNING: Can't find cross in '%s', layer '%s'!", filename % layername); -*/ return Value(); } diff --git a/src/handle_dep.cc b/src/handle_dep.cc index cbf7157..2d6f3ff 100644 --- a/src/handle_dep.cc +++ b/src/handle_dep.cc @@ -6,7 +6,7 @@ #include #include #include -using namespace boost::filesystem; +namespace fs = boost::filesystem; #include "boosty.h" boost::unordered_set dependencies; @@ -14,14 +14,14 @@ const char *make_command = NULL; void handle_dep(const std::string &filename) { - path filepath(filename); + fs::path filepath(filename); if ( boosty::is_absolute( filepath )) { dependencies.insert(filename); } else { - dependencies.insert((current_path() / filepath).string()); + dependencies.insert((fs::current_path() / filepath).string()); } - if (!exists(filepath) && make_command) { + if (!fs::exists(filepath) && make_command) { std::stringstream buf; buf << make_command << " '" << boost::regex_replace(filename, boost::regex("'"), "'\\''") << "'"; system(buf.str().c_str()); // FIXME: Handle error diff --git a/src/import.cc b/src/import.cc index 2f08b11..1073459 100644 --- a/src/import.cc +++ b/src/import.cc @@ -80,7 +80,7 @@ AbstractNode *ImportModule::evaluate(const Context *ctx, const ModuleInstantiati std::string filename = c.getAbsolutePath(v.isUndefined() ? "" : v.toString()); import_type_e actualtype = this->type; if (actualtype == TYPE_UNKNOWN) { - std::string extraw = boosty::extension_str( path(filename) ); + std::string extraw = boosty::extension_str( fs::path(filename) ); std::string ext = boost::algorithm::to_lower_copy( extraw ); if (ext == ".stl") actualtype = TYPE_STL; else if (ext == ".off") actualtype = TYPE_OFF; diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 5ec8be7..db9433f 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -157,8 +157,18 @@ endif() set(CMAKE_INCLUDE_DIRECTORIES_BEFORE OFF) + +# Eigen + +set( EIGEN_VERSION 3 ) +if( ${CMAKE_SYSTEM_NAME} MATCHES "Darwin" ) + set( EIGEN_VERSION 3 ) +endif() + # Eigen2 +if( ${EIGEN_VERSION} EQUAL 2) + # Turn off Eigen SIMD optimization if(NOT ${CMAKE_SYSTEM_NAME} MATCHES "Darwin") if(NOT ${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD") @@ -195,6 +205,45 @@ if (NOT EIGEN2_INCLUDE_DIR) endif() inclusion(EIGEN2_DIR EIGEN2_INCLUDE_DIR) +endif() # EIGEN_VERSION 2 + + +# Eigen3 + +if( ${EIGEN_VERSION} EQUAL 3) + +if (NOT $ENV{EIGEN3DIR} STREQUAL "") + set(EIGEN3_DIR "$ENV{EIGEN3DIR}") +elseif (NOT $ENV{OPENSCAD_LIBRARIES} STREQUAL "") + set(EIGEN3_DIR "$ENV{OPENSCAD_LIBRARIES}") +endif() + +if (NOT EIGEN3_INCLUDE_DIR) + if (EIGEN3_DIR) + set(EIGEN3_FIND_HINTS "${EIGEN3_DIR}/include/eigen3") + endif() + if (${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD") + set(EIGEN3_FIND_PATHS /usr/local/include/eigen3) + elseif (${CMAKE_SYSTEM_NAME} MATCHES "NetBSD") + set(EIGEN3_FIND_PATHS /usr/pkg/include/eigen3) + else() + set(EIGEN3_FIND_PATHS /opt/local/include/eigen3 /usr/include/eigen3) + endif() + find_path(EIGEN3_INCLUDE_DIR + Eigen/Core + HINTS ${EIGEN3_FIND_HINTS} + PATHS ${EIGEN3_FIND_PATHS}) + if (NOT EIGEN3_INCLUDE_DIR) + message(FATAL_ERROR "Eigen3 not found") + else() + message(STATUS "Eigen3 found in " ${EIGEN3_INCLUDE_DIR}) + endif() +endif() +inclusion(EIGEN3_DIR EIGEN3_INCLUDE_DIR) + +endif() # EIGEN_VERSION 3 + + # OpenCSG if (NOT $ENV{OPENCSGDIR} STREQUAL "") set(OPENCSG_DIR "$ENV{OPENCSGDIR}") -- cgit v0.10.1 From c4d68588a6f2f39ab60055a56fbc59b87ecee2e2 Mon Sep 17 00:00:00 2001 From: don bright Date: Sun, 19 Aug 2012 00:14:17 +0200 Subject: modify build system to auto-detect eigen3, and fallback to eigen2 diff --git a/common.pri b/common.pri index 9e3555f..d852885 100644 --- a/common.pri +++ b/common.pri @@ -10,7 +10,5 @@ include(cgal.pri) include(opencsg.pri) include(glew.pri) include(boost.pri) - -CONFIG(eigen2) { include(eigen2.pri) } -CONFIG(eigen3) { include(eigen3.pri) } +include(eigen.pri) diff --git a/eigen.pri b/eigen.pri new file mode 100644 index 0000000..4d9ab90 --- /dev/null +++ b/eigen.pri @@ -0,0 +1,75 @@ +# Detect eigen3 + eigen2, then use this priority list to determine +# which eigen to use: +# +# Priority +# 3. EIGEN3DIR / EIGEN2DIR if set +# 1. OPENSCAD_LIBRARIES eigen3 +# 2. OPENSCAD_LIBRARIES eigen2 +# 4. system's standard include paths for eigen3 +# 5. system's standard include paths for eigen2 + +eigen { + +# read environment variables +OPENSCAD_LIBRARIES_DIR = $$(OPENSCAD_LIBRARIES) +EIGEN2_DIR = $$(EIGEN2DIR) +EIGEN3_DIR = $$(EIGEN3DIR) + +CONFIG(mingw-cross-env) { + EIGEN_INCLUDEPATH = mingw-cross-env/include/eigen2 +} + +# Optionally specify location of Eigen3 using the +# OPENSCAD_LIBRARIES env. variable +!isEmpty(OPENSCAD_LIBRARIES_DIR) { + isEmpty(EIGEN_INCLUDEPATH) { + exists($$OPENSCAD_LIBRARIES_DIR/include/eigen3) { + EIGEN_INCLUDEPATH = $$OPENSCAD_LIBRARIES_DIR/include/eigen3 + } + } + isEmpty(EIGEN_INCLUDEPATH) { + exists($$OPENSCAD_LIBRARIES_DIR/include/eigen2) { + EIGEN_INCLUDEPATH = $$OPENSCAD_LIBRARIES_DIR/include/eigen2 + } + } +} + + +# Optionally specify location of Eigen using the +# EIGEN3DIR env. variable +!isEmpty(EIGEN3_DIR) { + EIGEN_INCLUDEPATH = $$EIGEN3_DIR + message("EIGEN3 location: $$EIGEN3_INCLUDEPATH") +} + +# Optionally specify location of Eigen using the +# EIGEN2DIR env. variable +!isEmpty(EIGEN2_DIR) { + EIGEN_INCLUDEPATH = $$EIGEN2_DIR + message("EIGEN2 location: $$EIGEN2_INCLUDEPATH") +} + +isEmpty(EIGEN_INCLUDEPATH) { + freebsd-g++: EIGEN_INCLUDEPATH = /usr/local/include/eigen3 + macx: EIGEN_INCLUDEPATH = /opt/local/include/eigen3 + linux*|hurd*: EIGEN_INCLUDEPATH = /usr/include/eigen3 + netbsd*: EIGEN_INCLUDEPATH = /usr/pkg/include/eigen3 + !exists($$EIGEN_INCLUDEPATH) { + freebsd-g++: EIGEN_INCLUDEPATH = /usr/local/include/eigen2 + macx: EIGEN_INCLUDEPATH = /opt/local/include/eigen2 + linux*|hurd*: EIGEN_INCLUDEPATH = /usr/include/eigen2 + netbsd*: EIGEN_INCLUDEPATH = /usr/pkg/include/eigen2 + } +} + +# disable Eigen SIMD optimizations for platforms where it breaks compilation +!macx { + !freebsd-g++ { + QMAKE_CXXFLAGS += -DEIGEN_DONT_ALIGN + } +} + +# EIGEN being under 'include/eigen[2-3]' needs special prepending +QMAKE_INCDIR_QT = $$EIGEN_INCLUDEPATH $$QMAKE_INCDIR_QT + +} # eigen diff --git a/eigen2.pri b/eigen2.pri deleted file mode 100644 index 701f92a..0000000 --- a/eigen2.pri +++ /dev/null @@ -1,44 +0,0 @@ -eigen2 { -message("hi 2") - CONFIG(mingw-cross-env) { - EIGEN2_INCLUDEPATH = mingw-cross-env/include/eigen2 - } - - # Optionally specify location of Eigen2 using the - # OPENSCAD_LIBRARIES env. variable - isEmpty(EIGEN2_INCLUDEPATH) { - OPENSCAD_LIBRARIES_DIR = $$(OPENSCAD_LIBRARIES) - !isEmpty(OPENSCAD_LIBRARIES_DIR) { - exists($$OPENSCAD_LIBRARIES_DIR/include/eigen2) { - EIGEN2_INCLUDEPATH = $$OPENSCAD_LIBRARIES_DIR/include/eigen2 - } - } - } - - # Optionally specify location of Eigen2 using the - # EIGEN2DIR env. variable - isEmpty(EIGEN2_INCLUDEPATH) { - EIGEN2_DIR = $$(EIGEN2DIR) - !isEmpty(EIGEN2_DIR) { - EIGEN2_INCLUDEPATH = $$EIGEN2_DIR - message("EIGEN2 location: $$EIGEN2_INCLUDEPATH") - } - } - - isEmpty(EIGEN2_INCLUDEPATH) { - freebsd-g++: EIGEN2_INCLUDEPATH = /usr/local/include/eigen2 - macx: EIGEN2_INCLUDEPATH = /opt/local/include/eigen2 - linux*|hurd*: EIGEN2_INCLUDEPATH = /usr/include/eigen2 - netbsd*: EIGEN2_INCLUDEPATH = /usr/pkg/include/eigen2 - } - - # eigen2 being under 'include/eigen2' needs special prepending - QMAKE_INCDIR_QT = $$EIGEN2_INCLUDEPATH $$QMAKE_INCDIR_QT - - # disable Eigen SIMD optimizations for platforms where it breaks compilation - !macx { - !freebsd-g++ { - QMAKE_CXXFLAGS += -DEIGEN_DONT_ALIGN - } - } -} diff --git a/eigen3.pri b/eigen3.pri deleted file mode 100644 index 20d85fc..0000000 --- a/eigen3.pri +++ /dev/null @@ -1,43 +0,0 @@ -eigen3 { - CONFIG(mingw-cross-env) { - EIGEN3_INCLUDEPATH = mingw-cross-env/include/eigen3 - } - - # Optionally specify location of Eigen3 using the - # OPENSCAD_LIBRARIES env. variable - isEmpty(EIGEN3_INCLUDEPATH) { - OPENSCAD_LIBRARIES_DIR = $$(OPENSCAD_LIBRARIES) - !isEmpty(OPENSCAD_LIBRARIES_DIR) { - exists($$OPENSCAD_LIBRARIES_DIR/include/eigen3) { - EIGEN3_INCLUDEPATH = $$OPENSCAD_LIBRARIES_DIR/include/eigen3 - } - } - } - - # Optionally specify location of Eigen3 using the - # EIGEN3DIR env. variable - isEmpty(EIGEN3_INCLUDEPATH) { - EIGEN3_DIR = $$(EIGEN3DIR) - !isEmpty(EIGEN3_DIR) { - EIGEN3_INCLUDEPATH = $$EIGEN3_DIR - message("EIGEN3 location: $$EIGEN3_INCLUDEPATH") - } - } - - isEmpty(EIGEN3_INCLUDEPATH) { - freebsd-g++: EIGEN3_INCLUDEPATH = /usr/local/include/eigen3 - macx: EIGEN3_INCLUDEPATH = /opt/local/include/eigen3 - linux*|hurd*: EIGEN3_INCLUDEPATH = /usr/include/eigen3 - netbsd*: EIGEN3_INCLUDEPATH = /usr/pkg/include/eigen3 - } - - # EIGEN3 being under 'include/eigen3' needs special prepending - QMAKE_INCDIR_QT = $$EIGEN3_INCLUDEPATH $$QMAKE_INCDIR_QT - - # disable Eigen SIMD optimizations for platforms where it breaks compilation - !macx { - !freebsd-g++ { - QMAKE_CXXFLAGS += -DEIGEN_DONT_ALIGN - } - } -} diff --git a/openscad.pro b/openscad.pro index a76383c..6532c79 100644 --- a/openscad.pro +++ b/openscad.pro @@ -124,12 +124,7 @@ macx:CONFIG += mdi CONFIG += cgal CONFIG += opencsg CONFIG += boost -#macx { -unix { - CONFIG += eigen3 -} else { - CONFIG += eigen2 -} +CONFIG += eigen #Uncomment the following line to enable QCodeEdit #CONFIG += qcodeedit diff --git a/scripts/linux-build-dependencies.sh b/scripts/linux-build-dependencies.sh index 6f31d5d..01e08be 100755 --- a/scripts/linux-build-dependencies.sh +++ b/scripts/linux-build-dependencies.sh @@ -246,17 +246,20 @@ build_eigen() echo "Building eigen" $version "..." cd $BASEDIR/src rm -rf eigen-$version - ## Directory name for v2.0.17 - rm -rf eigen-eigen-b23437e61a07 - rm -rf eigen-eigen-43d9075b23ef # 3.1.1 + EIGENDIR="none" + if [ $version = "2.0.17" ]; then EIGENDIR=eigen-eigen-b23437e61a07; fi + if [ $version = "3.1.1" ]; then EIGENDIR=eigen-eigen-43d9075b23ef; fi + if [ $EIGENDIR = "none" ]; then + echo Unknown eigen version. Please edit script. + exit 1 + fi + rm -rf ./$EIGENDIR if [ ! -f eigen-$version.tar.bz2 ]; then curl -LO http://bitbucket.org/eigen/eigen/get/$version.tar.bz2 mv $version.tar.bz2 eigen-$version.tar.bz2 fi tar xjf eigen-$version.tar.bz2 - ## File name for v2.0.17 - ln -s eigen-eigen-b23437e61a07 eigen-$version - ln -s eigen-eigen-43d9075b23ef eigen-$version # 3.1.1 + ln -s ./$EIGENDIR eigen-$version cd eigen-$version mkdir build cd build @@ -323,8 +326,8 @@ fi # edit version numbers here as needed. # -build_eigen 2.0.17 -#build_eigen 3.1.1 +#build_eigen 2.0.17 +build_eigen 3.1.1 #build_gmp 5.0.5 #build_mpfr 3.1.1 #build_boost 1.47.0 diff --git a/src/linalg.h b/src/linalg.h index eb3d22d..7f12a2e 100644 --- a/src/linalg.h +++ b/src/linalg.h @@ -12,10 +12,10 @@ typedef Eigen::AlignedBox BoundingBox; using Eigen::Matrix3f; using Eigen::Matrix3d; using Eigen::Matrix4d; -#if EIGEN_WORLD_VERSION>=3 +#if EIGEN_WORLD_VERSION >= 3 #define Transform3d Eigen::Affine3d #else -using Eigen::Transform3d +using Eigen::Transform3d; #endif BoundingBox operator*(const Transform3d &m, const BoundingBox &box); diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index db9433f..7df8885 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -159,15 +159,43 @@ set(CMAKE_INCLUDE_DIRECTORIES_BEFORE OFF) # Eigen +# First try to find Eigen3. If it's not there, fallback to Eigen2 -set( EIGEN_VERSION 3 ) -if( ${CMAKE_SYSTEM_NAME} MATCHES "Darwin" ) - set( EIGEN_VERSION 3 ) +# Eigen3 + +if (NOT $ENV{EIGEN3DIR} STREQUAL "") + set(EIGEN3_DIR "$ENV{EIGEN3DIR}") +elseif (NOT $ENV{OPENSCAD_LIBRARIES} STREQUAL "") + set(EIGEN3_DIR "$ENV{OPENSCAD_LIBRARIES}") endif() +if (NOT EIGEN3_INCLUDE_DIR) + if (EIGEN3_DIR) + set(EIGEN3_FIND_HINTS "${EIGEN3_DIR}/include/eigen3") + endif() + if (${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD") + set(EIGEN3_FIND_PATHS /usr/local/include/eigen3) + elseif (${CMAKE_SYSTEM_NAME} MATCHES "NetBSD") + set(EIGEN3_FIND_PATHS /usr/pkg/include/eigen3) + else() + set(EIGEN3_FIND_PATHS /opt/local/include/eigen3 /usr/include/eigen3) + endif() + find_path(EIGEN3_INCLUDE_DIR + Eigen/Core + HINTS ${EIGEN3_FIND_HINTS} + PATHS ${EIGEN3_FIND_PATHS}) + if (NOT EIGEN3_INCLUDE_DIR) + message(STATUS "Eigen3 not found, will attempt to find Eigen2") + else() + message(STATUS "Eigen3 found in " ${EIGEN3_INCLUDE_DIR}) + inclusion(EIGEN3_DIR EIGEN3_INCLUDE_DIR) + endif() +endif() + + # Eigen2 -if( ${EIGEN_VERSION} EQUAL 2) +if (NOT EIGEN3_INCLUDE_DIR) # Turn off Eigen SIMD optimization if(NOT ${CMAKE_SYSTEM_NAME} MATCHES "Darwin") @@ -205,44 +233,7 @@ if (NOT EIGEN2_INCLUDE_DIR) endif() inclusion(EIGEN2_DIR EIGEN2_INCLUDE_DIR) -endif() # EIGEN_VERSION 2 - - -# Eigen3 - -if( ${EIGEN_VERSION} EQUAL 3) - -if (NOT $ENV{EIGEN3DIR} STREQUAL "") - set(EIGEN3_DIR "$ENV{EIGEN3DIR}") -elseif (NOT $ENV{OPENSCAD_LIBRARIES} STREQUAL "") - set(EIGEN3_DIR "$ENV{OPENSCAD_LIBRARIES}") -endif() - -if (NOT EIGEN3_INCLUDE_DIR) - if (EIGEN3_DIR) - set(EIGEN3_FIND_HINTS "${EIGEN3_DIR}/include/eigen3") - endif() - if (${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD") - set(EIGEN3_FIND_PATHS /usr/local/include/eigen3) - elseif (${CMAKE_SYSTEM_NAME} MATCHES "NetBSD") - set(EIGEN3_FIND_PATHS /usr/pkg/include/eigen3) - else() - set(EIGEN3_FIND_PATHS /opt/local/include/eigen3 /usr/include/eigen3) - endif() - find_path(EIGEN3_INCLUDE_DIR - Eigen/Core - HINTS ${EIGEN3_FIND_HINTS} - PATHS ${EIGEN3_FIND_PATHS}) - if (NOT EIGEN3_INCLUDE_DIR) - message(FATAL_ERROR "Eigen3 not found") - else() - message(STATUS "Eigen3 found in " ${EIGEN3_INCLUDE_DIR}) - endif() -endif() -inclusion(EIGEN3_DIR EIGEN3_INCLUDE_DIR) - -endif() # EIGEN_VERSION 3 - +endif() # if (NOT EIGEN3_INCLUDE_DIR) # OpenCSG if (NOT $ENV{OPENCSGDIR} STREQUAL "") -- cgit v0.10.1 From 1e0ce9e46b9b17344f1b3e6cce3aed44d93885cd Mon Sep 17 00:00:00 2001 From: don bright Date: Sun, 19 Aug 2012 00:19:25 +0200 Subject: alter Mac OSX dependencies build script to get eigen version 3.1.1 This still allows the building of eigen, 2.0.17 just change the version number at the bottom of the file. Eigen3 requires an 'out of source' build. diff --git a/scripts/macosx-build-dependencies.sh b/scripts/macosx-build-dependencies.sh index f7b6b18..f009fce 100755 --- a/scripts/macosx-build-dependencies.sh +++ b/scripts/macosx-build-dependencies.sh @@ -265,20 +265,29 @@ build_eigen() echo "Building eigen" $version "..." cd $BASEDIR/src rm -rf eigen-$version - ## Directory name for v2.0.17 - rm -rf eigen-eigen-b23437e61a07 + + EIGENDIR="none" + if [ $version = "2.0.17" ]; then EIGENDIR=eigen-eigen-b23437e61a07; fi + if [ $version = "3.1.1" ]; then EIGENDIR=eigen-eigen-43d9075b23ef; fi + if [ $EIGENDIR = "none" ]; then + echo Unknown eigen version. Please edit script. + exit 1 + fi + rm -rf ./$EIGENDIR + if [ ! -f eigen-$version.tar.bz2 ]; then curl -LO http://bitbucket.org/eigen/eigen/get/$version.tar.bz2 mv $version.tar.bz2 eigen-$version.tar.bz2 fi tar xjf eigen-$version.tar.bz2 - ## File name for v2.0.17 - ln -s eigen-eigen-b23437e61a07 eigen-$version + ln -s ./$EIGENDIR eigen-$version cd eigen-$version + mkdir build + cd build if $OPTION_32BIT; then EIGEN_EXTRA_FLAGS=";i386" fi - cmake -DCMAKE_INSTALL_PREFIX=$DEPLOYDIR -DEIGEN_BUILD_LIB=ON -DBUILD_SHARED_LIBS=FALSE -DCMAKE_OSX_DEPLOYMENT_TARGET="$MAC_OSX_VERSION_MIN" -DCMAKE_OSX_ARCHITECTURES="x86_64$EIGEN_EXTRA_FLAGS" + cmake -DCMAKE_INSTALL_PREFIX=$DEPLOYDIR -DEIGEN_BUILD_LIB=ON -DBUILD_SHARED_LIBS=FALSE -DCMAKE_OSX_DEPLOYMENT_TARGET="$MAC_OSX_VERSION_MIN" -DCMAKE_OSX_ARCHITECTURES="x86_64$EIGEN_EXTRA_FLAGS" .. make -j4 make install } @@ -297,7 +306,7 @@ done echo "Using basedir:" $BASEDIR mkdir -p $SRCDIR $DEPLOYDIR -build_eigen 2.0.17 +build_eigen 3.1.1 build_gmp 5.0.5 build_mpfr 3.1.0 build_boost 1.47.0 -- cgit v0.10.1 From 526ed73ec20c222ab64824c95eae36da3bbf2e57 Mon Sep 17 00:00:00 2001 From: don bright Date: Sat, 18 Aug 2012 17:30:47 -0500 Subject: restore commented-out build commands diff --git a/scripts/linux-build-dependencies.sh b/scripts/linux-build-dependencies.sh index 01e08be..8bdba4c 100755 --- a/scripts/linux-build-dependencies.sh +++ b/scripts/linux-build-dependencies.sh @@ -326,14 +326,13 @@ fi # edit version numbers here as needed. # -#build_eigen 2.0.17 build_eigen 3.1.1 -#build_gmp 5.0.5 -#build_mpfr 3.1.1 -#build_boost 1.47.0 +build_gmp 5.0.5 +build_mpfr 3.1.1 +build_boost 1.50.0 # NB! For CGAL, also update the actual download URL in the function -#build_cgal 4.0.2 -#build_glew 1.7.0 -#build_opencsg 1.3.2 +build_cgal 4.0.2 +build_glew 1.7.0 +build_opencsg 1.3.2 echo "OpenSCAD dependencies built and installed to " $BASEDIR -- cgit v0.10.1 From e7ebf47d9b3afe36a1c68619ca6be78fa153aad1 Mon Sep 17 00:00:00 2001 From: don bright Date: Sat, 18 Aug 2012 17:50:45 -0500 Subject: fix bug in build script for boost diff --git a/scripts/linux-build-dependencies.sh b/scripts/linux-build-dependencies.sh index 8bdba4c..154545f 100755 --- a/scripts/linux-build-dependencies.sh +++ b/scripts/linux-build-dependencies.sh @@ -124,7 +124,7 @@ build_boost() # We only need certain portions of boost ./bootstrap.sh --prefix=$DEPLOYDIR --with-libraries=thread,program_options,filesystem,system,regex if [ $CXX ]; then - if [ $CXX = "clang" ]; then + if [ $CXX = "clang++" ]; then ./b2 -j$NUMCPU toolset=clang install # ./b2 -j$NUMCPU toolset=clang cxxflags="-stdlib=libc++" linkflags="-stdlib=libc++" install fi @@ -326,9 +326,9 @@ fi # edit version numbers here as needed. # -build_eigen 3.1.1 -build_gmp 5.0.5 -build_mpfr 3.1.1 +#build_eigen 3.1.1 +#build_gmp 5.0.5 +#build_mpfr 3.1.1 build_boost 1.50.0 # NB! For CGAL, also update the actual download URL in the function build_cgal 4.0.2 -- cgit v0.10.1 From 7a2f91e51de625716f4b852f83468c3aa22f0aac Mon Sep 17 00:00:00 2001 From: don bright Date: Sat, 18 Aug 2012 21:16:34 -0500 Subject: update eigen version in README. dont use alignment in dxfdata vector. diff --git a/README.md b/README.md index d91da32..1f9fb53 100644 --- a/README.md +++ b/README.md @@ -92,7 +92,7 @@ Follow the instructions for the platform you're compiling on below. * [boost (1.35 - 1.47)](http://www.boost.org/) * [OpenCSG (1.3.2)](http://www.opencsg.org/) * [GLEW (1.6 ->)](http://glew.sourceforge.net/) -* [Eigen2 (2.0.13->)](http://eigen.tuxfamily.org/) +* [Eigen (2.0.13->3.1.1)](http://eigen.tuxfamily.org/) * [GCC C++ Compiler (4.2 ->)](http://gcc.gnu.org/) * [Bison (2.4)](http://www.gnu.org/software/bison/) * [Flex (2.5.35)](http://flex.sourceforge.net/) diff --git a/src/dxfdata.h b/src/dxfdata.h index 80a23f6..64853dc 100644 --- a/src/dxfdata.h +++ b/src/dxfdata.h @@ -30,8 +30,6 @@ public: #ifdef __APPLE__ std::vector > points; -#elif EIGEN_WORLD_VERSION == 3 - std::vector > points; #else std::vector points; #endif -- cgit v0.10.1 From aa2c67d24925a8b9465d5a908662091b705cf7cc Mon Sep 17 00:00:00 2001 From: don bright Date: Sat, 18 Aug 2012 21:35:12 -0500 Subject: make EIGEN_DONT_ALIGN flag work. also remove warnings when using clang. diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 7df8885..4942259 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -67,6 +67,17 @@ if(WIN32 AND CMAKE_COMPILER_IS_GNUCXX) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fpermissive -frounding-math") endif() +# Clang compiler + +if(CMAKE_CXX_COMPILER MATCHES ".*clang.*") + # disable enormous amount of warnings about CGAL + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-parameter") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-variable") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-function") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-c++11-extensions") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-sign-compare") +endif() + # # Build test apps # @@ -159,6 +170,14 @@ set(CMAKE_INCLUDE_DIRECTORIES_BEFORE OFF) # Eigen + +# Turn off Eigen SIMD optimization +if(NOT ${CMAKE_SYSTEM_NAME} MATCHES "Darwin") + if(NOT ${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DEIGEN_DONT_ALIGN") + endif() +endif() + # First try to find Eigen3. If it's not there, fallback to Eigen2 # Eigen3 @@ -197,13 +216,6 @@ endif() if (NOT EIGEN3_INCLUDE_DIR) -# Turn off Eigen SIMD optimization -if(NOT ${CMAKE_SYSTEM_NAME} MATCHES "Darwin") - if(NOT ${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DEIGEN_DONT_ALIGN") - endif() -endif() - if (NOT $ENV{EIGEN2DIR} STREQUAL "") set(EIGEN2_DIR "$ENV{EIGEN2DIR}") elseif (NOT $ENV{OPENSCAD_LIBRARIES} STREQUAL "") -- cgit v0.10.1 From d656f556b85fb25903d5f18c6a9557d6ed0e6f7d Mon Sep 17 00:00:00 2001 From: don bright Date: Sat, 18 Aug 2012 23:02:39 -0500 Subject: debugging failed test: throwntogethertest polygons diff --git a/src/ThrownTogetherRenderer.cc b/src/ThrownTogetherRenderer.cc index 146d2e1..b22c6a5 100644 --- a/src/ThrownTogetherRenderer.cc +++ b/src/ThrownTogetherRenderer.cc @@ -30,7 +30,8 @@ #include "system-gl.h" -#include +//#include +#include ThrownTogetherRenderer::ThrownTogetherRenderer(CSGChain *root_chain, CSGChain *highlights_chain, @@ -62,7 +63,8 @@ void ThrownTogetherRenderer::renderCSGChain(CSGChain *chain, bool highlight, bool fberror) const { glDepthFunc(GL_LEQUAL); - boost::unordered_map,int> polySetVisitMark; + //boost::unordered_map,int> polySetVisitMark; + std::map,int> polySetVisitMark; for (size_t i = 0; i < chain->polysets.size(); i++) { if (polySetVisitMark[std::make_pair(chain->polysets[i].get(), &chain->matrices[i])]++ > 0) continue; diff --git a/src/dxfdata.cc b/src/dxfdata.cc index 4258a4c..080e780 100644 --- a/src/dxfdata.cc +++ b/src/dxfdata.cc @@ -85,7 +85,8 @@ DxfData::DxfData(double fn, double fs, double fa, Grid2d< std::vector > grid(GRID_COARSE); std::vector lines; // Global lines - boost::unordered_map< std::string, std::vector > blockdata; // Lines in blocks + //boost::unordered_map< std::string, std::vector > blockdata; // Lines in blocks + std::map< std::string, std::vector > blockdata; // Lines in blocks bool in_entities_section = false; bool in_blocks_section = false; @@ -123,7 +124,8 @@ DxfData::DxfData(double fn, double fs, double fa, for (int j = 0; j < 2; j++) coords[i][j] = 0; - typedef boost::unordered_map EntityList; + //typedef boost::unordered_map EntityList; + typedef std::map EntityList; EntityList unsupported_entities_list; // diff --git a/src/dxfdim.cc b/src/dxfdim.cc index dfe8c13..6f1b0ab 100644 --- a/src/dxfdim.cc +++ b/src/dxfdim.cc @@ -36,9 +36,11 @@ #include #include - -boost::unordered_map dxf_dim_cache; -boost::unordered_map dxf_cross_cache; +//boost::unordered_map dxf_dim_cache; +//boost::unordered_map dxf_cross_cache; +#include +std::map dxf_dim_cache; +std::map dxf_cross_cache; namespace fs = boost::filesystem; Value builtin_dxf_dim(const Context *ctx, const std::vector &argnames, const std::vector &args) diff --git a/src/dxfdim.h b/src/dxfdim.h index bd42109..5dc0ae0 100644 --- a/src/dxfdim.h +++ b/src/dxfdim.h @@ -1,10 +1,13 @@ #ifndef DXFDIM_H_ #define DXFDIM_H_ -#include +//#include +#include #include "value.h" -extern boost::unordered_map dxf_dim_cache; -extern boost::unordered_map dxf_cross_cache; +//extern boost::unordered_map dxf_dim_cache; +//extern boost::unordered_map dxf_cross_cache; +extern std::map dxf_dim_cache; +extern std::map dxf_cross_cache; #endif diff --git a/src/dxftess-cgal.cc b/src/dxftess-cgal.cc index f221e3a..d19ef61 100644 --- a/src/dxftess-cgal.cc +++ b/src/dxftess-cgal.cc @@ -30,7 +30,8 @@ typedef CGAL::Constrained_Delaunay_triangulation_2 CDT; typedef CDT::Vertex_handle Vertex_handle; typedef CDT::Point CDTPoint; -#include +//#include +#include template class DummyCriteria { public: @@ -71,8 +72,10 @@ struct point_info_t typedef std::pair edge_t; void mark_inner_outer(std::vector &tri, Grid2d &point_info, - boost::unordered_map &edge_to_triangle, - boost::unordered_map &edge_to_path, int idx, bool inner) + std::map &edge_to_triangle, + std::map &edge_to_path, int idx, bool inner) +// boost::unordered_map &edge_to_triangle, +// boost::unordered_map &edge_to_path, int idx, bool inner) { if (tri[idx].is_marked) return; @@ -107,8 +110,10 @@ void dxf_tesselate(PolySet *ps, DxfData &dxf, double rot, bool up, bool /* do_tr std::vector tri; Grid2d point_info(GRID_FINE); - boost::unordered_map edge_to_triangle; - boost::unordered_map edge_to_path; +// boost::unordered_map edge_to_triangle; +// boost::unordered_map edge_to_path; + std::map edge_to_triangle; + std::map edge_to_path; CGAL::Failure_behaviour old_behaviour = CGAL::set_error_behaviour(CGAL::THROW_EXCEPTION); try { diff --git a/src/handle_dep.cc b/src/handle_dep.cc index 2d6f3ff..0bebb70 100644 --- a/src/handle_dep.cc +++ b/src/handle_dep.cc @@ -8,8 +8,10 @@ #include namespace fs = boost::filesystem; #include "boosty.h" +#include -boost::unordered_set dependencies; +//boost::unordered_set dependencies; +std::set dependencies; const char *make_command = NULL; void handle_dep(const std::string &filename) diff --git a/src/surface.cc b/src/surface.cc index 2fa3717..eb6561e 100644 --- a/src/surface.cc +++ b/src/surface.cc @@ -42,6 +42,7 @@ #include #include using namespace boost::assign; // bring 'operator+=()' into scope +#include #include namespace fs = boost::filesystem; @@ -110,7 +111,8 @@ PolySet *SurfaceNode::evaluate_polyset(class PolySetEvaluator *) const PolySet *p = new PolySet(); int lines = 0, columns = 0; - boost::unordered_map,double> data; + //boost::unordered_map,double> data; + std::map,double> data; double min_val = 0; typedef boost::tokenizer > tokenizer; diff --git a/tests/csgtestcore.cc b/tests/csgtestcore.cc index acc7c31..0ab9c0a 100644 --- a/tests/csgtestcore.cc +++ b/tests/csgtestcore.cc @@ -357,6 +357,13 @@ int csgtestcore(int argc, char *argv[], test_type_e test_type) Vector3d camerapos = center - radius*1.8*cameradir; csgInfo.glview->setCamera(camerapos, center); +#include + if (csgInfo.background_chain) + std::cout << csgInfo.background_chain->dump( true ) << "\n"; + if (csgInfo.root_chain) + std::cout << csgInfo.root_chain->dump( true ) << "\n"; + if (csgInfo.highlights_chain) + std::cout << csgInfo.highlights_chain->dump( true ) << "\n"; OpenCSGRenderer opencsgRenderer(csgInfo.root_chain, csgInfo.highlights_chain, csgInfo.background_chain, csgInfo.glview->shaderinfo); ThrownTogetherRenderer thrownTogetherRenderer(csgInfo.root_chain, csgInfo.highlights_chain, csgInfo.background_chain); -- cgit v0.10.1 From 8f17a48e2c76e0a7a35032ff87df7b89cdcb8772 Mon Sep 17 00:00:00 2001 From: don bright Date: Sat, 18 Aug 2012 23:12:53 -0500 Subject: more debug diff --git a/src/ThrownTogetherRenderer.cc b/src/ThrownTogetherRenderer.cc index b22c6a5..21f3ae7 100644 --- a/src/ThrownTogetherRenderer.cc +++ b/src/ThrownTogetherRenderer.cc @@ -32,6 +32,8 @@ //#include #include +#include +using std::cout; ThrownTogetherRenderer::ThrownTogetherRenderer(CSGChain *root_chain, CSGChain *highlights_chain, @@ -70,6 +72,8 @@ void ThrownTogetherRenderer::renderCSGChain(CSGChain *chain, bool highlight, continue; const Transform3d &m = chain->matrices[i]; const Color4f &c = chain->colors[i]; + cout << "m\n" << m.matrix() << "\n"; + cout << "color\n" << c << "\n"; glPushMatrix(); glMultMatrixd(m.data()); PolySet::csgmode_e csgmode = chain->types[i] == CSGTerm::TYPE_DIFFERENCE ? PolySet::CSGMODE_DIFFERENCE : PolySet::CSGMODE_NORMAL; -- cgit v0.10.1 From 4ef470be1f147cb33d75117716ec83c84328da25 Mon Sep 17 00:00:00 2001 From: don bright Date: Sun, 19 Aug 2012 07:13:41 -0500 Subject: Revert "more debug" This reverts commit 8f17a48e2c76e0a7a35032ff87df7b89cdcb8772. diff --git a/src/ThrownTogetherRenderer.cc b/src/ThrownTogetherRenderer.cc index 21f3ae7..b22c6a5 100644 --- a/src/ThrownTogetherRenderer.cc +++ b/src/ThrownTogetherRenderer.cc @@ -32,8 +32,6 @@ //#include #include -#include -using std::cout; ThrownTogetherRenderer::ThrownTogetherRenderer(CSGChain *root_chain, CSGChain *highlights_chain, @@ -72,8 +70,6 @@ void ThrownTogetherRenderer::renderCSGChain(CSGChain *chain, bool highlight, continue; const Transform3d &m = chain->matrices[i]; const Color4f &c = chain->colors[i]; - cout << "m\n" << m.matrix() << "\n"; - cout << "color\n" << c << "\n"; glPushMatrix(); glMultMatrixd(m.data()); PolySet::csgmode_e csgmode = chain->types[i] == CSGTerm::TYPE_DIFFERENCE ? PolySet::CSGMODE_DIFFERENCE : PolySet::CSGMODE_NORMAL; -- cgit v0.10.1 From 94de600995a142bb0643b70f7717be3650072644 Mon Sep 17 00:00:00 2001 From: don bright Date: Sun, 19 Aug 2012 07:13:49 -0500 Subject: Revert "Revert "more debug"" This reverts commit 4ef470be1f147cb33d75117716ec83c84328da25. diff --git a/src/ThrownTogetherRenderer.cc b/src/ThrownTogetherRenderer.cc index b22c6a5..21f3ae7 100644 --- a/src/ThrownTogetherRenderer.cc +++ b/src/ThrownTogetherRenderer.cc @@ -32,6 +32,8 @@ //#include #include +#include +using std::cout; ThrownTogetherRenderer::ThrownTogetherRenderer(CSGChain *root_chain, CSGChain *highlights_chain, @@ -70,6 +72,8 @@ void ThrownTogetherRenderer::renderCSGChain(CSGChain *chain, bool highlight, continue; const Transform3d &m = chain->matrices[i]; const Color4f &c = chain->colors[i]; + cout << "m\n" << m.matrix() << "\n"; + cout << "color\n" << c << "\n"; glPushMatrix(); glMultMatrixd(m.data()); PolySet::csgmode_e csgmode = chain->types[i] == CSGTerm::TYPE_DIFFERENCE ? PolySet::CSGMODE_DIFFERENCE : PolySet::CSGMODE_NORMAL; -- cgit v0.10.1 From 5bba950304a9df2ed6b9a3429aed5c6e1959b46b Mon Sep 17 00:00:00 2001 From: don bright Date: Sun, 19 Aug 2012 07:13:57 -0500 Subject: Revert "Revert "Revert "more debug""" This reverts commit 94de600995a142bb0643b70f7717be3650072644. diff --git a/src/ThrownTogetherRenderer.cc b/src/ThrownTogetherRenderer.cc index 21f3ae7..b22c6a5 100644 --- a/src/ThrownTogetherRenderer.cc +++ b/src/ThrownTogetherRenderer.cc @@ -32,8 +32,6 @@ //#include #include -#include -using std::cout; ThrownTogetherRenderer::ThrownTogetherRenderer(CSGChain *root_chain, CSGChain *highlights_chain, @@ -72,8 +70,6 @@ void ThrownTogetherRenderer::renderCSGChain(CSGChain *chain, bool highlight, continue; const Transform3d &m = chain->matrices[i]; const Color4f &c = chain->colors[i]; - cout << "m\n" << m.matrix() << "\n"; - cout << "color\n" << c << "\n"; glPushMatrix(); glMultMatrixd(m.data()); PolySet::csgmode_e csgmode = chain->types[i] == CSGTerm::TYPE_DIFFERENCE ? PolySet::CSGMODE_DIFFERENCE : PolySet::CSGMODE_NORMAL; -- cgit v0.10.1 From 17e9fe2ea9f339acfcee9df111b2301000e11b18 Mon Sep 17 00:00:00 2001 From: don bright Date: Sun, 19 Aug 2012 07:17:06 -0500 Subject: cleaning up for pull request diff --git a/scripts/linux-build-dependencies.sh b/scripts/linux-build-dependencies.sh index 154545f..a5e2bcc 100755 --- a/scripts/linux-build-dependencies.sh +++ b/scripts/linux-build-dependencies.sh @@ -326,9 +326,9 @@ fi # edit version numbers here as needed. # -#build_eigen 3.1.1 -#build_gmp 5.0.5 -#build_mpfr 3.1.1 +build_eigen 3.1.1 +build_gmp 5.0.5 +build_mpfr 3.1.1 build_boost 1.50.0 # NB! For CGAL, also update the actual download URL in the function build_cgal 4.0.2 -- cgit v0.10.1 From 702525f69c0c9b7dbeb9f07efd4d9acaf9ead65d Mon Sep 17 00:00:00 2001 From: don bright Date: Sun, 19 Aug 2012 07:31:23 -0500 Subject: cleanup for pull request diff --git a/src/ThrownTogetherRenderer.cc b/src/ThrownTogetherRenderer.cc index b22c6a5..146d2e1 100644 --- a/src/ThrownTogetherRenderer.cc +++ b/src/ThrownTogetherRenderer.cc @@ -30,8 +30,7 @@ #include "system-gl.h" -//#include -#include +#include ThrownTogetherRenderer::ThrownTogetherRenderer(CSGChain *root_chain, CSGChain *highlights_chain, @@ -63,8 +62,7 @@ void ThrownTogetherRenderer::renderCSGChain(CSGChain *chain, bool highlight, bool fberror) const { glDepthFunc(GL_LEQUAL); - //boost::unordered_map,int> polySetVisitMark; - std::map,int> polySetVisitMark; + boost::unordered_map,int> polySetVisitMark; for (size_t i = 0; i < chain->polysets.size(); i++) { if (polySetVisitMark[std::make_pair(chain->polysets[i].get(), &chain->matrices[i])]++ > 0) continue; diff --git a/src/dxfdata.cc b/src/dxfdata.cc index 080e780..0e18dd0 100644 --- a/src/dxfdata.cc +++ b/src/dxfdata.cc @@ -39,7 +39,6 @@ #include #include #include -#include #include #include "value.h" @@ -85,8 +84,7 @@ DxfData::DxfData(double fn, double fs, double fa, Grid2d< std::vector > grid(GRID_COARSE); std::vector lines; // Global lines - //boost::unordered_map< std::string, std::vector > blockdata; // Lines in blocks - std::map< std::string, std::vector > blockdata; // Lines in blocks + boost::unordered_map< std::string, std::vector > blockdata; // Lines in blocks bool in_entities_section = false; bool in_blocks_section = false; @@ -124,8 +122,7 @@ DxfData::DxfData(double fn, double fs, double fa, for (int j = 0; j < 2; j++) coords[i][j] = 0; - //typedef boost::unordered_map EntityList; - typedef std::map EntityList; + typedef boost::unordered_map EntityList; EntityList unsupported_entities_list; // diff --git a/src/dxfdim.cc b/src/dxfdim.cc index 6f1b0ab..872637b 100644 --- a/src/dxfdim.cc +++ b/src/dxfdim.cc @@ -36,11 +36,8 @@ #include #include -//boost::unordered_map dxf_dim_cache; -//boost::unordered_map dxf_cross_cache; -#include -std::map dxf_dim_cache; -std::map dxf_cross_cache; +boost::unordered_map dxf_dim_cache; +boost::unordered_map dxf_cross_cache; namespace fs = boost::filesystem; Value builtin_dxf_dim(const Context *ctx, const std::vector &argnames, const std::vector &args) @@ -186,7 +183,6 @@ Value builtin_dxf_cross(const Context *ctx, const std::vector &argn return dxf_cross_cache[key] = Value(ret); } } - PRINTB("WARNING: Can't find cross in '%s', layer '%s'!", filename % layername); return Value(); } diff --git a/src/dxfdim.h b/src/dxfdim.h index 5dc0ae0..bd42109 100644 --- a/src/dxfdim.h +++ b/src/dxfdim.h @@ -1,13 +1,10 @@ #ifndef DXFDIM_H_ #define DXFDIM_H_ -//#include -#include +#include #include "value.h" -//extern boost::unordered_map dxf_dim_cache; -//extern boost::unordered_map dxf_cross_cache; -extern std::map dxf_dim_cache; -extern std::map dxf_cross_cache; +extern boost::unordered_map dxf_dim_cache; +extern boost::unordered_map dxf_cross_cache; #endif diff --git a/src/dxftess-cgal.cc b/src/dxftess-cgal.cc index d19ef61..fb5bf50 100644 --- a/src/dxftess-cgal.cc +++ b/src/dxftess-cgal.cc @@ -30,8 +30,7 @@ typedef CGAL::Constrained_Delaunay_triangulation_2 CDT; typedef CDT::Vertex_handle Vertex_handle; typedef CDT::Point CDTPoint; -//#include -#include +#include template class DummyCriteria { public: @@ -72,10 +71,8 @@ struct point_info_t typedef std::pair edge_t; void mark_inner_outer(std::vector &tri, Grid2d &point_info, - std::map &edge_to_triangle, - std::map &edge_to_path, int idx, bool inner) -// boost::unordered_map &edge_to_triangle, -// boost::unordered_map &edge_to_path, int idx, bool inner) + boost::unordered_map &edge_to_triangle, + boost::unordered_map &edge_to_path, int idx, bool inner) { if (tri[idx].is_marked) return; diff --git a/src/handle_dep.cc b/src/handle_dep.cc index 0bebb70..2d6f3ff 100644 --- a/src/handle_dep.cc +++ b/src/handle_dep.cc @@ -8,10 +8,8 @@ #include namespace fs = boost::filesystem; #include "boosty.h" -#include -//boost::unordered_set dependencies; -std::set dependencies; +boost::unordered_set dependencies; const char *make_command = NULL; void handle_dep(const std::string &filename) diff --git a/src/surface.cc b/src/surface.cc index eb6561e..2fa3717 100644 --- a/src/surface.cc +++ b/src/surface.cc @@ -42,7 +42,6 @@ #include #include using namespace boost::assign; // bring 'operator+=()' into scope -#include #include namespace fs = boost::filesystem; @@ -111,8 +110,7 @@ PolySet *SurfaceNode::evaluate_polyset(class PolySetEvaluator *) const PolySet *p = new PolySet(); int lines = 0, columns = 0; - //boost::unordered_map,double> data; - std::map,double> data; + boost::unordered_map,double> data; double min_val = 0; typedef boost::tokenizer > tokenizer; diff --git a/tests/csgtestcore.cc b/tests/csgtestcore.cc index 0ab9c0a..acc7c31 100644 --- a/tests/csgtestcore.cc +++ b/tests/csgtestcore.cc @@ -357,13 +357,6 @@ int csgtestcore(int argc, char *argv[], test_type_e test_type) Vector3d camerapos = center - radius*1.8*cameradir; csgInfo.glview->setCamera(camerapos, center); -#include - if (csgInfo.background_chain) - std::cout << csgInfo.background_chain->dump( true ) << "\n"; - if (csgInfo.root_chain) - std::cout << csgInfo.root_chain->dump( true ) << "\n"; - if (csgInfo.highlights_chain) - std::cout << csgInfo.highlights_chain->dump( true ) << "\n"; OpenCSGRenderer opencsgRenderer(csgInfo.root_chain, csgInfo.highlights_chain, csgInfo.background_chain, csgInfo.glview->shaderinfo); ThrownTogetherRenderer thrownTogetherRenderer(csgInfo.root_chain, csgInfo.highlights_chain, csgInfo.background_chain); -- cgit v0.10.1 From a9045315baac2e8bd24428668cfa88f116984af7 Mon Sep 17 00:00:00 2001 From: don bright Date: Sun, 19 Aug 2012 07:58:30 -0500 Subject: rewrite Eigen detection in CMakelists. cleanup files for pull request. diff --git a/eigen.pri b/eigen.pri index 4d9ab90..6f11a53 100644 --- a/eigen.pri +++ b/eigen.pri @@ -22,12 +22,12 @@ CONFIG(mingw-cross-env) { # Optionally specify location of Eigen3 using the # OPENSCAD_LIBRARIES env. variable !isEmpty(OPENSCAD_LIBRARIES_DIR) { - isEmpty(EIGEN_INCLUDEPATH) { + isEmpty(EIGEN_INCLUDEPATH) { exists($$OPENSCAD_LIBRARIES_DIR/include/eigen3) { EIGEN_INCLUDEPATH = $$OPENSCAD_LIBRARIES_DIR/include/eigen3 } } - isEmpty(EIGEN_INCLUDEPATH) { + isEmpty(EIGEN_INCLUDEPATH) { exists($$OPENSCAD_LIBRARIES_DIR/include/eigen2) { EIGEN_INCLUDEPATH = $$OPENSCAD_LIBRARIES_DIR/include/eigen2 } diff --git a/scripts/linux-build-dependencies.sh b/scripts/linux-build-dependencies.sh index a5e2bcc..be678d3 100755 --- a/scripts/linux-build-dependencies.sh +++ b/scripts/linux-build-dependencies.sh @@ -268,6 +268,7 @@ build_eigen() make install } + OPENSCADDIR=$PWD if [ ! -f $OPENSCADDIR/openscad.pro ]; then echo "Must be run from the OpenSCAD source root directory" @@ -329,7 +330,7 @@ fi build_eigen 3.1.1 build_gmp 5.0.5 build_mpfr 3.1.1 -build_boost 1.50.0 +build_boost 1.47.0 # NB! For CGAL, also update the actual download URL in the function build_cgal 4.0.2 build_glew 1.7.0 diff --git a/src/dxfdata.cc b/src/dxfdata.cc index 0e18dd0..4258a4c 100644 --- a/src/dxfdata.cc +++ b/src/dxfdata.cc @@ -39,6 +39,7 @@ #include #include #include +#include #include #include "value.h" diff --git a/src/dxfdim.cc b/src/dxfdim.cc index 872637b..1ed37fa 100644 --- a/src/dxfdim.cc +++ b/src/dxfdim.cc @@ -183,7 +183,9 @@ Value builtin_dxf_cross(const Context *ctx, const std::vector &argn return dxf_cross_cache[key] = Value(ret); } } + PRINTB("WARNING: Can't find cross in '%s', layer '%s'!", filename % layername); + return Value(); } diff --git a/src/dxftess-cgal.cc b/src/dxftess-cgal.cc index fb5bf50..f221e3a 100644 --- a/src/dxftess-cgal.cc +++ b/src/dxftess-cgal.cc @@ -107,10 +107,8 @@ void dxf_tesselate(PolySet *ps, DxfData &dxf, double rot, bool up, bool /* do_tr std::vector tri; Grid2d point_info(GRID_FINE); -// boost::unordered_map edge_to_triangle; -// boost::unordered_map edge_to_path; - std::map edge_to_triangle; - std::map edge_to_path; + boost::unordered_map edge_to_triangle; + boost::unordered_map edge_to_path; CGAL::Failure_behaviour old_behaviour = CGAL::set_error_behaviour(CGAL::THROW_EXCEPTION); try { diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 4942259..63e265f 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -178,74 +178,62 @@ if(NOT ${CMAKE_SYSTEM_NAME} MATCHES "Darwin") endif() endif() -# First try to find Eigen3. If it's not there, fallback to Eigen2 +# Priority +# 3. EIGEN3DIR / EIGEN2DIR if set +# 1. OPENSCAD_LIBRARIES eigen3 +# 2. OPENSCAD_LIBRARIES eigen2 +# 4. system's standard include paths for eigen3 +# 5. system's standard include paths for eigen2 -# Eigen3 +set(EIGEN3_DIR "$ENV{EIGEN3DIR}") +set(EIGEN2_DIR "$ENV{EIGEN2DIR}") +set(OPENSCAD_LIBDIR "$ENV{OPENSCAD_LIBRARIES}") -if (NOT $ENV{EIGEN3DIR} STREQUAL "") - set(EIGEN3_DIR "$ENV{EIGEN3DIR}") -elseif (NOT $ENV{OPENSCAD_LIBRARIES} STREQUAL "") - set(EIGEN3_DIR "$ENV{OPENSCAD_LIBRARIES}") +if (EIGEN3_DIR) + find_path(EIGEN_INCLUDE_DIR Eigen/Core HINTS "${EIGEN3_DIR}/include/eigen3" "${EIGEN3_DIR}") +endif() +if (EIGEN2_DIR) + find_path(EIGEN_INCLUDE_DIR Eigen/Core HINTS "${EIGEN2_DIR}/include/eigen2" "${EIGEN2_DIR}") endif() -if (NOT EIGEN3_INCLUDE_DIR) - if (EIGEN3_DIR) - set(EIGEN3_FIND_HINTS "${EIGEN3_DIR}/include/eigen3") - endif() +if (NOT EIGEN_INCLUDE_DIR) + find_path(EIGEN_INCLUDE_DIR Eigen/Core HINTS ${OPENSCAD_LIBDIR}/include/eigen3) +endif() +if (NOT EIGEN_INCLUDE_DIR) + find_path(EIGEN_INCLUDE_DIR Eigen/Core HINTS ${OPENSCAD_LIBDIR}/include/eigen2) +endif() + +if (NOT EIGEN_INCLUDE_DIR) if (${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD") - set(EIGEN3_FIND_PATHS /usr/local/include/eigen3) + find_path(EIGEN_INCLUDE_DIR Eigen/Core HINTS /usr/local/include/eigen3) elseif (${CMAKE_SYSTEM_NAME} MATCHES "NetBSD") - set(EIGEN3_FIND_PATHS /usr/pkg/include/eigen3) - else() - set(EIGEN3_FIND_PATHS /opt/local/include/eigen3 /usr/include/eigen3) - endif() - find_path(EIGEN3_INCLUDE_DIR - Eigen/Core - HINTS ${EIGEN3_FIND_HINTS} - PATHS ${EIGEN3_FIND_PATHS}) - if (NOT EIGEN3_INCLUDE_DIR) - message(STATUS "Eigen3 not found, will attempt to find Eigen2") + find_path(EIGEN_INCLUDE_DIR Eigen/Core HINTS /usr/pkg/include/eigen3) + elseif (${CMAKE_SYSTEM_NAME} MATCHES "Darwin") + find_path(EIGEN_INCLUDE_DIR Eigen/Core HINTS /opt/local/include/eigen3) else() - message(STATUS "Eigen3 found in " ${EIGEN3_INCLUDE_DIR}) - inclusion(EIGEN3_DIR EIGEN3_INCLUDE_DIR) + find_path(EIGEN_INCLUDE_DIR Eigen/Core HINTS /usr/include/eigen3) endif() endif() - -# Eigen2 - -if (NOT EIGEN3_INCLUDE_DIR) - -if (NOT $ENV{EIGEN2DIR} STREQUAL "") - set(EIGEN2_DIR "$ENV{EIGEN2DIR}") -elseif (NOT $ENV{OPENSCAD_LIBRARIES} STREQUAL "") - set(EIGEN2_DIR "$ENV{OPENSCAD_LIBRARIES}") -endif() - -if (NOT EIGEN2_INCLUDE_DIR) - if (EIGEN2_DIR) - set(EIGEN2_FIND_HINTS "${EIGEN2_DIR}/include/eigen2") - endif() +if (NOT EIGEN_INCLUDE_DIR) if (${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD") - set(EIGEN2_FIND_PATHS /usr/local/include/eigen2) + find_path(EIGEN_INCLUDE_DIR Eigen/Core HINTS /usr/local/include/eigen2) elseif (${CMAKE_SYSTEM_NAME} MATCHES "NetBSD") - set(EIGEN2_FIND_PATHS /usr/pkg/include/eigen2) + find_path(EIGEN_INCLUDE_DIR Eigen/Core HINTS /usr/pkg/include/eigen2) + elseif (${CMAKE_SYSTEM_NAME} MATCHES "Darwin") + find_path(EIGEN_INCLUDE_DIR Eigen/Core HINTS /opt/local/include/eigen2) else() - set(EIGEN2_FIND_PATHS /opt/local/include/eigen2 /usr/include/eigen2) - endif() - find_path(EIGEN2_INCLUDE_DIR - Eigen/Core - HINTS ${EIGEN2_FIND_HINTS} - PATHS ${EIGEN2_FIND_PATHS}) - if (NOT EIGEN2_INCLUDE_DIR) - message(FATAL_ERROR "Eigen2 not found") - else() - message(STATUS "Eigen2 found in " ${EIGEN2_INCLUDE_DIR}) + find_path(EIGEN_INCLUDE_DIR Eigen/Core HINTS /usr/include/eigen2) endif() endif() -inclusion(EIGEN2_DIR EIGEN2_INCLUDE_DIR) -endif() # if (NOT EIGEN3_INCLUDE_DIR) +if (NOT EIGEN_INCLUDE_DIR) + message(STATUS "Eigen not found") +else() + message(STATUS "Eigen found in " ${EIGEN_INCLUDE_DIR}) + inclusion(EIGEN_DIR EIGEN_INCLUDE_DIR) +endif() + # OpenCSG if (NOT $ENV{OPENCSGDIR} STREQUAL "") -- cgit v0.10.1 From 5d31f56d9313dcaa8f2304819b7d54ff9aaaf01a Mon Sep 17 00:00:00 2001 From: don bright Date: Sun, 19 Aug 2012 08:10:33 -0500 Subject: look for EIGENDIR env var. (also look for EIGEN2DIR for backwards compatability) diff --git a/common.pri b/common.pri index d852885..71aa510 100644 --- a/common.pri +++ b/common.pri @@ -9,6 +9,5 @@ include(bison.pri) include(cgal.pri) include(opencsg.pri) include(glew.pri) -include(boost.pri) include(eigen.pri) - +include(boost.pri) diff --git a/doc/testing.txt b/doc/testing.txt index 8ab1cee..bbd7c18 100644 --- a/doc/testing.txt +++ b/doc/testing.txt @@ -85,7 +85,7 @@ Some versions of Xvfb may fail, however. 1. Trouble finding libraries on unix - To help CMAKE find eigen2, OpenCSG, CGAL, Boost, and GLEW, you can use + To help CMAKE find eigen, OpenCSG, CGAL, Boost, and GLEW, you can use environment variables, just like for the main qmake & openscad.pro. Examples: OPENSCAD_LIBRARIES=$HOME cmake . @@ -93,7 +93,7 @@ Some versions of Xvfb may fail, however. Valid variables are as follows: - BOOSTDIR, CGALDIR, EIGEN2DIR, GLEWDIR, OPENCSGDIR, OPENSCAD_LIBRARIES + BOOSTDIR, CGALDIR, EIGENDIR, GLEWDIR, OPENCSGDIR, OPENSCAD_LIBRARIES When running, this might help find your locally built libraries (assuming you installed into $HOME) diff --git a/eigen.pri b/eigen.pri index 6f11a53..8037b6f 100644 --- a/eigen.pri +++ b/eigen.pri @@ -2,18 +2,18 @@ # which eigen to use: # # Priority -# 3. EIGEN3DIR / EIGEN2DIR if set +# 0. EIGENDIR if set (also EIGEN2DIR for backwards compatability) # 1. OPENSCAD_LIBRARIES eigen3 # 2. OPENSCAD_LIBRARIES eigen2 -# 4. system's standard include paths for eigen3 -# 5. system's standard include paths for eigen2 +# 3. system's standard include paths for eigen3 +# 4. system's standard include paths for eigen2 eigen { # read environment variables OPENSCAD_LIBRARIES_DIR = $$(OPENSCAD_LIBRARIES) EIGEN2_DIR = $$(EIGEN2DIR) -EIGEN3_DIR = $$(EIGEN3DIR) +EIGEN_DIR = $$(EIGENDIR) CONFIG(mingw-cross-env) { EIGEN_INCLUDEPATH = mingw-cross-env/include/eigen2 @@ -36,17 +36,14 @@ CONFIG(mingw-cross-env) { # Optionally specify location of Eigen using the -# EIGEN3DIR env. variable -!isEmpty(EIGEN3_DIR) { - EIGEN_INCLUDEPATH = $$EIGEN3_DIR - message("EIGEN3 location: $$EIGEN3_INCLUDEPATH") -} - -# Optionally specify location of Eigen using the -# EIGEN2DIR env. variable +# EIGENDIR env. variable (EIGEN2 for backwards compatability) !isEmpty(EIGEN2_DIR) { EIGEN_INCLUDEPATH = $$EIGEN2_DIR - message("EIGEN2 location: $$EIGEN2_INCLUDEPATH") + message("User set EIGEN location: $$EIGEN2_INCLUDEPATH") +} +!isEmpty(EIGEN_DIR) { + EIGEN_INCLUDEPATH = $$EIGEN_DIR + message("User set EIGEN location: $$EIGEN_INCLUDEPATH") } isEmpty(EIGEN_INCLUDEPATH) { diff --git a/openscad.pro b/openscad.pro index 6532c79..024b788 100644 --- a/openscad.pro +++ b/openscad.pro @@ -3,8 +3,7 @@ # MPFRDIR # BOOSTDIR # CGALDIR -# EIGEN2DIR -# EIGEN3DIR +# EIGENDIR # GLEWDIR # OPENCSGDIR # OPENSCAD_LIBRARIES diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 63e265f..a268df1 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -179,18 +179,19 @@ if(NOT ${CMAKE_SYSTEM_NAME} MATCHES "Darwin") endif() # Priority -# 3. EIGEN3DIR / EIGEN2DIR if set +# 3. EIGENDIR if set (EIGEN2DIR for backwards compatability) # 1. OPENSCAD_LIBRARIES eigen3 # 2. OPENSCAD_LIBRARIES eigen2 # 4. system's standard include paths for eigen3 # 5. system's standard include paths for eigen2 -set(EIGEN3_DIR "$ENV{EIGEN3DIR}") set(EIGEN2_DIR "$ENV{EIGEN2DIR}") +set(EIGEN_DIR "$ENV{EIGENDIR}") set(OPENSCAD_LIBDIR "$ENV{OPENSCAD_LIBRARIES}") -if (EIGEN3_DIR) - find_path(EIGEN_INCLUDE_DIR Eigen/Core HINTS "${EIGEN3_DIR}/include/eigen3" "${EIGEN3_DIR}") +if (EIGEN_DIR) + set(EIGEN_HINTS "${EIGEN_DIR}/include/eigen3" "${EIGEN_DIR}/include/eigen2" "${EIGEN_DIR}") + find_path(EIGEN_INCLUDE_DIR Eigen/Core HINTS "${EIGEN_HINTS}") endif() if (EIGEN2_DIR) find_path(EIGEN_INCLUDE_DIR Eigen/Core HINTS "${EIGEN2_DIR}/include/eigen2" "${EIGEN2_DIR}") -- cgit v0.10.1 From fc945bfdc4598d509b6f7d1cf6d13a401fd01aa2 Mon Sep 17 00:00:00 2001 From: don bright Date: Sun, 19 Aug 2012 08:27:49 -0500 Subject: fix small bugs in eigen build scripts diff --git a/eigen.pri b/eigen.pri index 8037b6f..b7fe366 100644 --- a/eigen.pri +++ b/eigen.pri @@ -39,7 +39,7 @@ CONFIG(mingw-cross-env) { # EIGENDIR env. variable (EIGEN2 for backwards compatability) !isEmpty(EIGEN2_DIR) { EIGEN_INCLUDEPATH = $$EIGEN2_DIR - message("User set EIGEN location: $$EIGEN2_INCLUDEPATH") + message("User set EIGEN location: $$EIGEN_INCLUDEPATH") } !isEmpty(EIGEN_DIR) { EIGEN_INCLUDEPATH = $$EIGEN_DIR diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index a268df1..fc8480a 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -188,13 +188,12 @@ endif() set(EIGEN2_DIR "$ENV{EIGEN2DIR}") set(EIGEN_DIR "$ENV{EIGENDIR}") set(OPENSCAD_LIBDIR "$ENV{OPENSCAD_LIBRARIES}") - if (EIGEN_DIR) - set(EIGEN_HINTS "${EIGEN_DIR}/include/eigen3" "${EIGEN_DIR}/include/eigen2" "${EIGEN_DIR}") - find_path(EIGEN_INCLUDE_DIR Eigen/Core HINTS "${EIGEN_HINTS}") + set(EIGHINT ${EIGEN_DIR}/include/eigen3 ${EIGEN_DIR}/include/eigen2 ${EIGEN_DIR}) + find_path(EIGEN_INCLUDE_DIR Eigen/Core HINTS ${EIGHINT}) endif() if (EIGEN2_DIR) - find_path(EIGEN_INCLUDE_DIR Eigen/Core HINTS "${EIGEN2_DIR}/include/eigen2" "${EIGEN2_DIR}") + find_path(EIGEN_INCLUDE_DIR Eigen/Core HINTS ${EIGEN2_DIR}/include/eigen2 ${EIGEN2_DIR}) endif() if (NOT EIGEN_INCLUDE_DIR) -- cgit v0.10.1 From 765f1a98dc124e1913b53ea8467908b8b8bda032 Mon Sep 17 00:00:00 2001 From: don bright Date: Sun, 19 Aug 2012 08:29:22 -0500 Subject: cleanup diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index fc8480a..9a23380 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -188,6 +188,7 @@ endif() set(EIGEN2_DIR "$ENV{EIGEN2DIR}") set(EIGEN_DIR "$ENV{EIGENDIR}") set(OPENSCAD_LIBDIR "$ENV{OPENSCAD_LIBRARIES}") + if (EIGEN_DIR) set(EIGHINT ${EIGEN_DIR}/include/eigen3 ${EIGEN_DIR}/include/eigen2 ${EIGEN_DIR}) find_path(EIGEN_INCLUDE_DIR Eigen/Core HINTS ${EIGHINT}) -- cgit v0.10.1 From 8712bea3053f95f606b7a294ad73a922a4bec1e0 Mon Sep 17 00:00:00 2001 From: Marius Kintel Date: Mon, 20 Aug 2012 08:53:27 -0400 Subject: Added support for Lion, added option to force LLVM compiler diff --git a/scripts/macosx-build-dependencies.sh b/scripts/macosx-build-dependencies.sh index f7b6b18..20ed1f2 100755 --- a/scripts/macosx-build-dependencies.sh +++ b/scripts/macosx-build-dependencies.sh @@ -6,8 +6,9 @@ # # This script must be run from the OpenSCAD source root directory # -# Usage: macosx-build-dependencies.sh [-6] +# Usage: macosx-build-dependencies.sh [-6l] # -6 Build only 64-bit binaries +# -l Force use of LLVM compiler # # Prerequisites: # - MacPorts: curl, cmake @@ -24,13 +25,15 @@ SRCDIR=$BASEDIR/src DEPLOYDIR=$BASEDIR/install MAC_OSX_VERSION_MIN=10.5 OPTION_32BIT=true +OPTION_LLVM=false export QMAKESPEC=macx-g++ printUsage() { - echo "Usage: $0 [-6]" + echo "Usage: $0 [-6l]" echo echo " -6 Build only 64-bit binaries" + echo " -l Force use of LLVM compiler" } # Hack warning: gmplib is built separately in 32-bit and 64-bit mode @@ -181,8 +184,11 @@ build_boost() if $OPTION_32BIT; then BOOST_EXTRA_FLAGS="-arch i386" fi - ./bjam cflags="-mmacosx-version-min=$MAC_OSX_VERSION_MIN -arch x86_64 $BOOST_EXTRA_FLAGS" linkflags="-mmacosx-version-min=$MAC_OSX_VERSION_MIN -arch x86_64 $BOOST_EXTRA_FLAGS" - ./bjam install + if $OPTION_LLVM; then + BOOST_TOOLSET="toolset=darwin-llvm" + echo "using darwin : llvm : llvm-g++ ;" >> tools/build/v2/user-config.jam + fi + ./b2 -d+2 $BOOST_TOOLSET cflags="-mmacosx-version-min=$MAC_OSX_VERSION_MIN -arch x86_64 $BOOST_EXTRA_FLAGS" linkflags="-mmacosx-version-min=$MAC_OSX_VERSION_MIN -arch x86_64 $BOOST_EXTRA_FLAGS" install install_name_tool -id $DEPLOYDIR/lib/libboost_thread.dylib $DEPLOYDIR/lib/libboost_thread.dylib install_name_tool -id $DEPLOYDIR/lib/libboost_program_options.dylib $DEPLOYDIR/lib/libboost_program_options.dylib install_name_tool -id $DEPLOYDIR/lib/libboost_filesystem.dylib $DEPLOYDIR/lib/libboost_filesystem.dylib @@ -288,13 +294,35 @@ if [ ! -f $OPENSCADDIR/openscad.pro ]; then exit 0 fi -while getopts '6' c +while getopts '6l' c do case $c in - 6) OPTION_32BIT=false + 6) OPTION_32BIT=false;; + l) OPTION_LLVM=true;; esac done +OSVERSION=`sw_vers -productVersion | cut -d. -f2` +if [[ $OSVERSION -ge 7 ]]; then + echo "Detected Lion or later" + export LION=1 + export CC=gcc + export CXX=g++ + export CPP=cpp + # Somehow, qmake in Qt-4.8.2 doesn't detect Lion's gcc and falls back into + # project file mode unless manually given a QMAKESPEC + export QMAKESPEC=macx-llvm +else + echo "Detected Snow Leopard or earlier" +fi + +if $OPTION_LLVM; then + echo "Using LLVM compiler" + export CC=llvm-gcc + export CXX=llvm-g++ + export QMAKESPEC=macx-llvm +fi + echo "Using basedir:" $BASEDIR mkdir -p $SRCDIR $DEPLOYDIR build_eigen 2.0.17 -- cgit v0.10.1 From 63882721d773eab3aa49454a3b33a8a524d72beb Mon Sep 17 00:00:00 2001 From: Marius Kintel Date: Mon, 20 Aug 2012 08:56:29 -0400 Subject: Added support for Mac OS X Lion diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 5ec8be7..ce7698e 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -6,6 +6,25 @@ if("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}.${CMAKE_PATCH_VERSION}" VERSIO # http://www.cmake.org/cmake/help/cmake-2-8-docs.html#policy:CMP0017 cmake_policy(SET CMP0017 NEW) endif() + +# Detect Lion and force gcc +IF (APPLE) + EXECUTE_PROCESS(COMMAND sw_vers -productVersion OUTPUT_VARIABLE MACOSX_VERSION) + IF (NOT ${MACOSX_VERSION} VERSION_LESS "10.7.0") + message("Detected Lion or later") + set(CMAKE_C_COMPILER "gcc") + set(CMAKE_CXX_COMPILER "g++") + ELSE() + message("Detected Snow Leopard or older") + if (USE_LLVM) + message("Using LLVM compiler") + set(CMAKE_C_COMPILER "llvm-gcc") + set(CMAKE_CXX_COMPILER "llvm-g++") + endif() + ENDIF() +ENDIF(APPLE) + + project(tests) set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}") -- cgit v0.10.1 From 0170923b9bb51e198c8a3ad1b98ca5ed74a6c77d Mon Sep 17 00:00:00 2001 From: Marius Kintel Date: Mon, 20 Aug 2012 10:00:44 -0400 Subject: Enable running the test suite on a Mac VM diff --git a/tests/OffscreenContext.mm b/tests/OffscreenContext.mm index 990d3a4..a0995fa 100644 --- a/tests/OffscreenContext.mm +++ b/tests/OffscreenContext.mm @@ -57,9 +57,11 @@ OffscreenContext *create_offscreen_context(int w, int h) NSOpenGLPixelFormatAttribute attributes[] = { NSOpenGLPFAPixelBuffer, NSOpenGLPFANoRecovery, - NSOpenGLPFAAccelerated, NSOpenGLPFADepthSize, 24, NSOpenGLPFAStencilSize, 8, +// Took out the acceleration requirement to be able to run the tests +// in a non-accelerated VM. +// NSOpenGLPFAAccelerated, (NSOpenGLPixelFormatAttribute) 0 }; NSOpenGLPixelFormat *pixFormat = [[[NSOpenGLPixelFormat alloc] initWithAttributes:attributes] autorelease]; -- cgit v0.10.1 From b5cc07098b354bbeec2eae3cf6834e28ad43913e Mon Sep 17 00:00:00 2001 From: Marius Kintel Date: Mon, 20 Aug 2012 19:15:14 -0400 Subject: collect library dependencies a bit to reduce duplication diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index ce7698e..34a76a9 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -417,73 +417,79 @@ set(OFFSCREEN_SOURCES add_library(tests-core STATIC ${CORE_SOURCES}) target_link_libraries(tests-core ${OPENGL_LIBRARY}) +set(TESTS-CORE-LIBRARIES ${QT_LIBRARIES} ${OPENGL_LIBRARY} ${Boost_LIBRARIES}) + add_library(tests-common STATIC ${COMMON_SOURCES}) target_link_libraries(tests-common tests-core) + add_library(tests-cgal STATIC ${CGAL_SOURCES}) set_target_properties(tests-cgal PROPERTIES COMPILE_FLAGS "-DENABLE_CGAL ${CGAL_CXX_FLAGS_INIT}") target_link_libraries(tests-cgal tests-common) +set(TESTS-CGAL-LIBRARIES ${CGAL_LIBRARY} ${CGAL_3RD_PARTY_LIBRARIES} ${GMP_LIBRARIES} ${MPFR_LIBRARIES} ${TESTS-CORE-LIBRARIES}) + add_library(tests-nocgal STATIC ${NOCGAL_SOURCES}) target_link_libraries(tests-nocgal tests-common) add_library(tests-offscreen STATIC ${OFFSCREEN_SOURCES}) # set_target_properties(tests-offscreen PROPERTIES COMPILE_FLAGS "-DENABLE_OPENCSG -DENABLE_CGAL ${CGAL_CXX_FLAGS_INIT}") +set(TESTS-NOCGAL-LIBRARIES ${TESTS-CORE-LIBRARIES}) # # echotest # add_executable(echotest echotest.cc) -target_link_libraries(echotest tests-nocgal tests-core ${QT_LIBRARIES} ${OPENGL_LIBRARY} ${Boost_LIBRARIES}) +target_link_libraries(echotest tests-nocgal ${TESTS-NOCGAL-LIBRARIES}) # # dumptest # add_executable(dumptest dumptest.cc) -target_link_libraries(dumptest tests-nocgal ${QT_LIBRARIES} ${OPENGL_LIBRARY} ${Boost_LIBRARIES}) +target_link_libraries(dumptest tests-nocgal ${TESTS-NOCGAL-LIBRARIES}) # # modulecachetest # add_executable(modulecachetest modulecachetest.cc) -target_link_libraries(modulecachetest tests-nocgal ${QT_LIBRARIES} ${OPENGL_LIBRARY} ${Boost_LIBRARIES}) +target_link_libraries(modulecachetest tests-nocgal ${TESTS-NOCGAL-LIBRARIES}) # # csgtexttest # add_executable(csgtexttest csgtexttest.cc CSGTextRenderer.cc CSGTextCache.cc) -target_link_libraries(csgtexttest tests-nocgal ${QT_LIBRARIES} ${OPENGL_LIBRARY} ${Boost_LIBRARIES}) +target_link_libraries(csgtexttest tests-nocgal ${TESTS-NOCGAL-LIBRARIES}) # # csgtermtest # add_executable(csgtermtest csgtermtest.cc ../src/CSGTermEvaluator.cc) -target_link_libraries(csgtermtest tests-nocgal ${QT_LIBRARIES} ${OPENGL_LIBRARY} ${Boost_LIBRARIES}) +target_link_libraries(csgtermtest tests-nocgal ${TESTS-NOCGAL-LIBRARIES}) # # cgaltest # add_executable(cgaltest cgaltest.cc) set_target_properties(cgaltest PROPERTIES COMPILE_FLAGS "-DENABLE_CGAL ${CGAL_CXX_FLAGS_INIT}") -target_link_libraries(cgaltest tests-cgal ${CGAL_LIBRARY} ${CGAL_3RD_PARTY_LIBRARIES} ${QT_LIBRARIES} ${OPENGL_LIBRARY} ${Boost_LIBRARIES}) +target_link_libraries(cgaltest tests-cgal ${TESTS-CGAL-LIBRARIES}) # # cgalstlsanitytest # add_executable(cgalstlsanitytest cgalstlsanitytest.cc) set_target_properties(cgalstlsanitytest PROPERTIES COMPILE_FLAGS "-DENABLE_CGAL ${CGAL_CXX_FLAGS_INIT}") -target_link_libraries(cgalstlsanitytest tests-cgal ${CGAL_LIBRARY} ${CGAL_3RD_PARTY_LIBRARIES} ${QT_LIBRARIES} ${OPENGL_LIBRARY} ${Boost_LIBRARIES}) +target_link_libraries(cgalstlsanitytest tests-cgal ${TESTS-CGAL-LIBRARIES}) # # cgalpngtest # add_executable(cgalpngtest cgalpngtest.cc bboxhelp.cc ../src/CGALRenderer.cc ../src/renderer.cc ../src/rendersettings.cc) set_target_properties(cgalpngtest PROPERTIES COMPILE_FLAGS "-DENABLE_CGAL ${CGAL_CXX_FLAGS_INIT}") -target_link_libraries(cgalpngtest tests-offscreen tests-cgal ${CGAL_LIBRARY} ${CGAL_3RD_PARTY_LIBRARIES} ${QT_LIBRARIES} ${GLEW_LIBRARY} ${COCOA_LIBRARY} ${OPENGL_LIBRARY} ${Boost_LIBRARIES}) +target_link_libraries(cgalpngtest tests-offscreen tests-cgal ${OPENCSG_LIBRARY} ${TESTS-CGAL-LIBRARIES} ${GLEW_LIBRARY} ${COCOA_LIBRARY}) # # cgalcachetest # add_executable(cgalcachetest cgalcachetest.cc bboxhelp.cc) set_target_properties(cgalcachetest PROPERTIES COMPILE_FLAGS "-DENABLE_CGAL ${CGAL_CXX_FLAGS_INIT}") -target_link_libraries(cgalcachetest tests-cgal ${CGAL_LIBRARY} ${CGAL_3RD_PARTY_LIBRARIES} ${QT_LIBRARIES} ${GLEW_LIBRARY} ${COCOA_LIBRARY} ${OPENGL_LIBRARY} ${Boost_LIBRARIES}) +target_link_libraries(cgalcachetest tests-cgal ${TESTS-CGAL-LIBRARIES} ${GLEW_LIBRARY} ${COCOA_LIBRARY}) # # opencsgtest @@ -491,7 +497,7 @@ target_link_libraries(cgalcachetest tests-cgal ${CGAL_LIBRARY} ${CGAL_3RD_PARTY_ add_executable(opencsgtest opencsgtest.cc csgtestcore.cc ../src/OpenCSGRenderer.cc ../src/ThrownTogetherRenderer.cc ../src/renderer.cc ../src/rendersettings.cc) set_target_properties(opencsgtest PROPERTIES COMPILE_FLAGS "-DENABLE_OPENCSG -DENABLE_CGAL ${CGAL_CXX_FLAGS_INIT}") -target_link_libraries(opencsgtest tests-offscreen tests-cgal ${CGAL_LIBRARY} ${CGAL_3RD_PARTY_LIBRARIES} ${QT_LIBRARIES} ${OPENCSG_LIBRARY} ${GLEW_LIBRARY} ${COCOA_LIBRARY} ${OPENGL_LIBRARY} ${Boost_LIBRARIES}) +target_link_libraries(opencsgtest tests-offscreen tests-cgal ${OPENCSG_LIBRARY} ${TESTS-CGAL-LIBRARIES} ${GLEW_LIBRARY} ${COCOA_LIBRARY}) # # throwntogethertest @@ -499,7 +505,7 @@ target_link_libraries(opencsgtest tests-offscreen tests-cgal ${CGAL_LIBRARY} ${C 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 ${CGAL_LIBRARY} ${CGAL_3RD_PARTY_LIBRARIES} ${QT_LIBRARIES} ${OPENCSG_LIBRARY} ${GLEW_LIBRARY} ${COCOA_LIBRARY} ${OPENGL_LIBRARY} ${Boost_LIBRARIES}) +target_link_libraries(throwntogethertest tests-offscreen tests-cgal ${OPENCSG_LIBRARY} ${TESTS-CGAL-LIBRARIES} ${GLEW_LIBRARY} ${COCOA_LIBRARY}) # # Tags tests as disabled. This is more convenient than removing them manually -- cgit v0.10.1 From f1d4a52f4cc01843f5d7c40499fcfe44cc82712f Mon Sep 17 00:00:00 2001 From: don bright Date: Tue, 21 Aug 2012 01:33:13 +0200 Subject: dont crash if there's infinity or NaN in transformation matrix diff --git a/src/CGALEvaluator.cc b/src/CGALEvaluator.cc index ee04e05..c84d21f 100644 --- a/src/CGALEvaluator.cc +++ b/src/CGALEvaluator.cc @@ -241,6 +241,15 @@ Response CGALEvaluator::visit(State &state, const TransformNode &node) // First union all children N = applyToChildren(node, CGE_UNION); + if ( matrix_contains_infinity( node.matrix ) ) { + PRINT("Warning: Transformation matrix contains Infinity - removing object."); + N.reset(); + } + if ( matrix_contains_nan( node.matrix ) ) { + PRINT("Warning: Transformation matrix contains Not-a-Number - removing object"); + N.reset(); + } + // Then apply transform // If there is no geometry under the transform, N will be empty and of dim 0, // just just silently ignore such nodes @@ -248,7 +257,7 @@ Response CGALEvaluator::visit(State &state, const TransformNode &node) // Unfortunately CGAL provides no transform method for CGAL_Nef_polyhedron2 // objects. So we convert in to our internal 2d data format, transform it, // tesselate it and create a new CGAL_Nef_polyhedron2 from it.. What a hack! - + Eigen::Matrix2f testmat; testmat << node.matrix(0,0), node.matrix(0,1), node.matrix(1,0), node.matrix(1,1); if (testmat.determinant() == 0) { diff --git a/src/linalg.cc b/src/linalg.cc index 30f23af..b0ea2b4 100644 --- a/src/linalg.cc +++ b/src/linalg.cc @@ -1,4 +1,5 @@ #include "linalg.h" +#include // FIXME: We can achieve better pruning by either: // o Recalculate the box based on the transformed object @@ -25,3 +26,23 @@ BoundingBox operator*(const Transform3d &m, const BoundingBox &box) return newbox; } +bool matrix_contains_infinity( const Eigen::Transform3d &m ) +{ + for (int i=0;i Date: Tue, 21 Aug 2012 01:40:06 +0200 Subject: improve test scad diff --git a/src/CGALEvaluator.cc b/src/CGALEvaluator.cc index c84d21f..75b9097 100644 --- a/src/CGALEvaluator.cc +++ b/src/CGALEvaluator.cc @@ -257,7 +257,7 @@ Response CGALEvaluator::visit(State &state, const TransformNode &node) // Unfortunately CGAL provides no transform method for CGAL_Nef_polyhedron2 // objects. So we convert in to our internal 2d data format, transform it, // tesselate it and create a new CGAL_Nef_polyhedron2 from it.. What a hack! - + Eigen::Matrix2f testmat; testmat << node.matrix(0,0), node.matrix(0,1), node.matrix(1,0), node.matrix(1,1); if (testmat.determinant() == 0) { diff --git a/testdata/scad/bugs/transform-nan-inf-tests.scad b/testdata/scad/bugs/transform-nan-inf-tests.scad index eff62fc..eb3cb0c 100644 --- a/testdata/scad/bugs/transform-nan-inf-tests.scad +++ b/testdata/scad/bugs/transform-nan-inf-tests.scad @@ -1,10 +1,10 @@ // Test translation by NaN and Infinity -// NaN test - cube(2) should not be rendered -cube(1); +// NaN test - cube() should not be rendered +sphere(); angle = asin(1.1); render() rotate([0, 0, angle]) -cube(2); +cube(); // FIXME: how do you test infinity? diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index ce7698e..66cd36e 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -670,6 +670,7 @@ list(APPEND CGALPNGTEST_FILES ${CMAKE_SOURCE_DIR}/../testdata/scad/misc/include- list(APPEND OPENCSGTEST_FILES ${CGALPNGTEST_FILES}) list(APPEND OPENCSGTEST_FILES ${CMAKE_SOURCE_DIR}/../testdata/scad/bugs/bbox-transform-bug.scad) list(APPEND OPENCSGTEST_FILES ${CMAKE_SOURCE_DIR}/../testdata/scad/bugs/intersection-prune-test.scad) +list(APPEND OPENCSGTEST_FILES ${CMAKE_SOURCE_DIR}/../testdata/scad/bugs/transform-nan-inf-tests.scad) list(APPEND THROWNTOGETHERTEST_FILES ${OPENCSGTEST_FILES}) list(APPEND CGALSTLSANITYTEST_FILES ${CMAKE_SOURCE_DIR}/../testdata/scad/misc/normal-nan.scad) -- cgit v0.10.1 From 358129cad65758b2e732558fa3bbae2fffaecf83 Mon Sep 17 00:00:00 2001 From: don bright Date: Tue, 21 Aug 2012 02:39:18 +0200 Subject: improve test scad. don't use dumptest(), 'nan' is a bit of a problem diff --git a/testdata/scad/bugs/transform-nan-inf-tests.scad b/testdata/scad/bugs/transform-nan-inf-tests.scad index eb3cb0c..b647d08 100644 --- a/testdata/scad/bugs/transform-nan-inf-tests.scad +++ b/testdata/scad/bugs/transform-nan-inf-tests.scad @@ -1,10 +1,12 @@ // Test translation by NaN and Infinity +// cube()s should not be rendered -// NaN test - cube() should not be rendered +// NaN sphere(); -angle = asin(1.1); -render() -rotate([0, 0, angle]) -cube(); +rotate([0, 0, asin(1.1) ]) cube(); -// FIXME: how do you test infinity? +// Infinity +translate([4,0,0]) { + sphere(); + rotate([0, 0, 1/0]) cube(); +} diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 66cd36e..bb7738a 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -666,11 +666,11 @@ list(APPEND DUMPTEST_FILES ${CMAKE_SOURCE_DIR}/../testdata/scad/misc/escape-test list(APPEND CGALPNGTEST_FILES ${FEATURES_FILES} ${SCAD_DXF_FILES} ${EXAMPLE_FILES}) list(APPEND CGALPNGTEST_FILES ${CMAKE_SOURCE_DIR}/../testdata/scad/misc/include-tests.scad - ${CMAKE_SOURCE_DIR}/../testdata/scad/misc/use-tests.scad) + ${CMAKE_SOURCE_DIR}/../testdata/scad/misc/use-tests.scad + ${CMAKE_SOURCE_DIR}/../testdata/scad/bugs/transform-nan-inf-tests.scad) list(APPEND OPENCSGTEST_FILES ${CGALPNGTEST_FILES}) list(APPEND OPENCSGTEST_FILES ${CMAKE_SOURCE_DIR}/../testdata/scad/bugs/bbox-transform-bug.scad) list(APPEND OPENCSGTEST_FILES ${CMAKE_SOURCE_DIR}/../testdata/scad/bugs/intersection-prune-test.scad) -list(APPEND OPENCSGTEST_FILES ${CMAKE_SOURCE_DIR}/../testdata/scad/bugs/transform-nan-inf-tests.scad) list(APPEND THROWNTOGETHERTEST_FILES ${OPENCSGTEST_FILES}) list(APPEND CGALSTLSANITYTEST_FILES ${CMAKE_SOURCE_DIR}/../testdata/scad/misc/normal-nan.scad) -- cgit v0.10.1 From 6a8254f8492f4b07ecbfd58f9f6313791b1f035a Mon Sep 17 00:00:00 2001 From: don bright Date: Tue, 21 Aug 2012 02:47:45 +0200 Subject: add images for tests diff --git a/tests/regression/cgalpngtest/transform-nan-inf-tests-expected.png b/tests/regression/cgalpngtest/transform-nan-inf-tests-expected.png new file mode 100644 index 0000000..2d9c3ba Binary files /dev/null and b/tests/regression/cgalpngtest/transform-nan-inf-tests-expected.png differ diff --git a/tests/regression/opencsgtest/transform-nan-inf-tests-expected.png b/tests/regression/opencsgtest/transform-nan-inf-tests-expected.png new file mode 100644 index 0000000..c756800 Binary files /dev/null and b/tests/regression/opencsgtest/transform-nan-inf-tests-expected.png differ diff --git a/tests/regression/throwntogethertest/transform-nan-inf-tests-expected.png b/tests/regression/throwntogethertest/transform-nan-inf-tests-expected.png new file mode 100644 index 0000000..b706711 Binary files /dev/null and b/tests/regression/throwntogethertest/transform-nan-inf-tests-expected.png differ -- cgit v0.10.1 From 69f90c13bb7826fc2da6f1f5c35ab3ac550fc6da Mon Sep 17 00:00:00 2001 From: don bright Date: Tue, 21 Aug 2012 02:54:53 +0200 Subject: clarify that 'infinity' is not 'really' tested currently. diff --git a/testdata/scad/bugs/transform-nan-inf-tests.scad b/testdata/scad/bugs/transform-nan-inf-tests.scad index b647d08..cb8a667 100644 --- a/testdata/scad/bugs/transform-nan-inf-tests.scad +++ b/testdata/scad/bugs/transform-nan-inf-tests.scad @@ -5,7 +5,7 @@ sphere(); rotate([0, 0, asin(1.1) ]) cube(); -// Infinity +// Infinity (as of 2012-08 this is detected as NaN) translate([4,0,0]) { sphere(); rotate([0, 0, 1/0]) cube(); -- cgit v0.10.1 From d831b44474b4b3220d884306fd29aaf0cb5810fe Mon Sep 17 00:00:00 2001 From: don bright Date: Tue, 21 Aug 2012 03:10:06 +0200 Subject: clarify warning message diff --git a/src/CGALEvaluator.cc b/src/CGALEvaluator.cc index 75b9097..ac6190f 100644 --- a/src/CGALEvaluator.cc +++ b/src/CGALEvaluator.cc @@ -241,12 +241,9 @@ Response CGALEvaluator::visit(State &state, const TransformNode &node) // First union all children N = applyToChildren(node, CGE_UNION); - if ( matrix_contains_infinity( node.matrix ) ) { - PRINT("Warning: Transformation matrix contains Infinity - removing object."); - N.reset(); - } - if ( matrix_contains_nan( node.matrix ) ) { - PRINT("Warning: Transformation matrix contains Not-a-Number - removing object"); + if ( matrix_contains_infinity( node.matrix ) || matrix_contains_nan( node.matrix ) ) { + // due to the way parse/eval works we can't currently distinguish between NaN and Inf + PRINT("Warning: Transformation matrix contains Not-a-Number and/or Infinity - removing object."); N.reset(); } -- cgit v0.10.1 From 7bca8b414b84dcd4bcb3ab55b01969df5300d363 Mon Sep 17 00:00:00 2001 From: Marius Kintel Date: Tue, 21 Aug 2012 21:06:56 -0400 Subject: minor code compacting diff --git a/src/openscad.cc b/src/openscad.cc index f508b80..49c39da 100644 --- a/src/openscad.cc +++ b/src/openscad.cc @@ -58,6 +58,7 @@ #include #include +#include #include "boosty.h" #ifdef _MSC_VER @@ -187,10 +188,8 @@ int main(int argc, char **argv) } if (vm.count("D")) { - const vector &commands = vm["D"].as >(); - - for (vector::const_iterator i = commands.begin(); i != commands.end(); i++) { - commandline_commands += *i; + BOOST_FOREACH(const string &cmd, vm["D"].as >()) { + commandline_commands += cmd; commandline_commands += ";\n"; } } -- cgit v0.10.1 From 37f14683aba8289a54ee9a49ddcec3c6ec25c2ce Mon Sep 17 00:00:00 2001 From: Marius Kintel Date: Tue, 21 Aug 2012 21:07:17 -0400 Subject: Compile fix for eigen3 diff --git a/src/linalg.cc b/src/linalg.cc index b0ea2b4..2f368f9 100644 --- a/src/linalg.cc +++ b/src/linalg.cc @@ -26,7 +26,7 @@ BoundingBox operator*(const Transform3d &m, const BoundingBox &box) return newbox; } -bool matrix_contains_infinity( const Eigen::Transform3d &m ) +bool matrix_contains_infinity( const Transform3d &m ) { for (int i=0;i Date: Tue, 21 Aug 2012 21:08:55 -0400 Subject: Extracted the about box contents to an external file for easier editing diff --git a/openscad.qrc b/openscad.qrc index beee19a..84745e9 100644 --- a/openscad.qrc +++ b/openscad.qrc @@ -5,5 +5,6 @@ icons/prefs3DView.png icons/prefsEditor.png icons/flattr.png + src/AboutDialog.html diff --git a/src/AboutDialog.html b/src/AboutDialog.html new file mode 100644 index 0000000..e2a6264 --- /dev/null +++ b/src/AboutDialog.html @@ -0,0 +1,77 @@ + + +

+


+

OpenSCAD is Copyright (C) 2009-2012 Marius Kintel <marius@kintel.net> and Clifford Wolf <clifford@clifford.at>

+


+

License

+


+

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

+


+

Please visit this link for a copy of the license: GPL 2.0

+


+

Tools & Libraries used

+


+

GNU GMP

+

GNU MPFR

+

CGAL

+

Eigen2

+

OpenCSG

+

OpenGL

+

GLEW

+

Qt Toolkit

+

Boost

+

Bison

+

Flex

+

CMake

+

LodePNG

+

MingW

+

MXE

+

Linux

+

Mac OSX

+

C++, GCC, clang

+

python

+

Nullsoft installer

+


+

Acknowledgements

+


+

OpenSCAD Github Project members (public):

+


+

Marius Kintel

+

Clifford Wolf

+

Giles Bathgate

+

Brad Pitcher

+


+

Debian maintainer:

+


+

Christian M. Amsüss

+


+

Patches:

+


+

meta23

+

jasonblewis

+

gregjurman

+

brianolson

+

tjhowse

+

logxen (Mark A Cooper)

+

iamwilhelm (Wil Chung)

+

clothbot (Andrew Plumb)

+

colah (Christopher Olah)

+

+

Bug reports:

+

+

nop head, Triffid Hunter, Len Trigg, Kliment Yanev, Christian Siefkes, Whosawhatsis, MichaelAtOz, mrhdias, ibyte8bits, Koen Kooi, Tomas Mudrunka, knuds, cadr, mshearn, Hans L, 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 ... and many others

+


+

Hosting & resources

+


+

Github source repository

+


+

Rock Linux mailing list

+


+

Thingiverse

+

+

Laurent Guerby and the GCC Compile Farm, with OSUOSL, IBM, IRILL, Intel, FSF France, and AMD.

+


+

Apologies to anyone accidentally left out.

diff --git a/src/AboutDialog.ui b/src/AboutDialog.ui index 93f1401..587d27e 100644 --- a/src/AboutDialog.ui +++ b/src/AboutDialog.ui @@ -19,89 +19,17 @@ true - - <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> -<html><head><meta name="qrichtext" content="1" /><style type="text/css"> -p, li { white-space: pre-wrap; } -</style></head><body style=" font-family:'Ubuntu'; font-size:11pt; font-weight:400; font-style:normal;"> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><a href="https://flattr.com/submit/auto?user_id=openscad&amp;url=http://openscad.org&amp;title=OpenSCAD&amp;language=&amp;tags=github&amp;category=software"><img src=":icons/flattr.png" /></a></p> -<p align="right" style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><a href="http://www.openscad.org"><span style=" text-decoration: underline; color:#0000ff;">OpenSCAD</span></a><span style=" font-family:'Lucida Grande'; font-size:10pt;"> is Copyright (C) 2009-2011 </span><a href="https://github.com/kintel"><span style=" text-decoration: underline; color:#0000ff;">Marius Kintel </span></a><span style=" font-family:'Lucida Grande'; font-size:10pt;"> &lt;marius@kintel.net&gt; and </span><a href="http://clifford.at"><span style=" text-decoration: underline; color:#0000ff;">Clifford Wolf</span></a><span style=" font-family:'Lucida Grande'; font-size:10pt;"> &lt;clifford@clifford.at&gt;</span></p> -<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Lucida Grande'; font-size:10pt;"><br /></p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Lucida Grande'; font-size:10pt; font-weight:600;">License</span></p> -<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Lucida Grande'; font-size:10pt; font-weight:600;"><br /></p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Lucida Grande'; font-size:10pt;">This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.</span></p> -<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Lucida Grande'; font-size:10pt;"><br /></p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Lucida Grande'; font-size:10pt;">Please visit this link for a copy of the license: </span><a href="http://www.gnu.org/licenses/gpl-2.0.html"><span style=" text-decoration: underline; color:#0000ff;">GPL 2.0</span></a></p> -<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Lucida Grande'; font-size:10pt;"><br /></p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Lucida Grande'; font-size:10pt; font-weight:600;">Tools &amp; Libraries used</span></p> -<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Lucida Grande'; font-size:10pt; font-weight:600;"><br /></p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><a href="http://gmplib.org/"><span style=" text-decoration: underline; color:#0000ff;">GNU GMP</span></a></p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><a href="http://www.mpfr.org/"><span style=" text-decoration: underline; color:#0000ff;">GNU MPFR</span></a></p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><a href="http://www.cgal.org"><span style=" text-decoration: underline; color:#0000ff;">CGAL</span></a></p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><a href="http://eigen.tuxfamily.org"><span style=" text-decoration: underline; color:#0000ff;">Eigen2</span></a></p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><a href="http://www.opencsg.org"><span style=" text-decoration: underline; color:#0000ff;">OpenCSG</span></a></p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><a href="http://www.opengl.org/"><span style=" text-decoration: underline; color:#0000ff;">OpenGL</span></a></p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><a href="http://glew.sourceforge.net"><span style=" text-decoration: underline; color:#0000ff;">GLEW</span></a></p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><a href="http://qt.nokia.com"><span style=" text-decoration: underline; color:#0000ff;">Qt Toolkit</span></a></p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><a href="http://www.boost.org"><span style=" text-decoration: underline; color:#0000ff;">Boost</span></a></p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><a href="http://www.gnu.org/software/bison/"><span style=" text-decoration: underline; color:#0000ff;">Bison</span></a></p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><a href="http://flex.sourceforge.net/"><span style=" text-decoration: underline; color:#0000ff;">Flex</span></a></p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><a href="http://www.cmake.org"><span style=" text-decoration: underline; color:#0000ff;">CMake</span></a></p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><a href="http://lodev.org/lodepng/"><span style=" text-decoration: underline; color:#0000ff;">LodePNG</span></a></p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><a href="http://www.mingw.org/"><span style=" text-decoration: underline; color:#0000ff;">MingW</span></a></p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><a href="http://www.mxe.cc"><span style=" text-decoration: underline; color:#0000ff;">MXE</span></a></p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><a href="http://www.linux.org"><span style=" text-decoration: underline; color:#0000ff;">Linux</span></a></p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><a href="http://www.apple.com/osx/"><span style=" text-decoration: underline; color:#0000ff;">Mac OSX</span></a></p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><a href="http://www.stroustrup.com/C++.html"><span style=" text-decoration: underline; color:#0000ff;">C++</span></a><span style=" font-family:'Lucida Grande'; font-size:10pt; font-weight:600;">, </span><a href="http://gcc.gnu.org/"><span style=" text-decoration: underline; color:#0000ff;">GCC</span></a><span style=" font-family:'Lucida Grande'; font-size:10pt; font-weight:600;">, </span><a href="http://clang.llvm.org/"><span style=" text-decoration: underline; color:#0000ff;">clang</span></a></p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><a href="http://www.python.org"><span style=" text-decoration: underline; color:#0000ff;">python</span></a></p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><a href="http://nsis.sourceforge.net/Main_Page"><span style=" text-decoration: underline; color:#0000ff;">Nullsoft installer</span></a></p> -<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; text-decoration: underline; color:#0000ff;"><br /></p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Lucida Grande'; font-size:10pt; font-weight:600;">Acknowledgements</span></p> -<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Lucida Grande'; font-size:10pt;"><br /></p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><a href="http://www.github.com/openscad"><span style=" text-decoration: underline; color:#0000ff;">OpenSCAD Github Project</span></a><span style=" font-family:'Lucida Grande'; font-size:10pt;"> members (public):</span></p> -<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><a href="https://github.com/kintel"><span style=" text-decoration: underline; color:#0000ff;">Marius Kintel </span></a></p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><a href="http://clifford.at"><span style=" text-decoration: underline; color:#0000ff;">Clifford Wolf</span></a><span style=" font-family:'Lucida Grande'; font-size:10pt;"> </span></p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><a href="http://www.github.com/GilesBathgate"><span style=" text-decoration: underline; color:#0000ff;">Giles Bathgate</span></a></p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><a href="https://github.com/brad"><span style=" text-decoration: underline; color:#0000ff;">Brad Pitcher</span></a></p> -<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; text-decoration: underline; color:#0000ff;"><br /></p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><a href="http://www.debian.org"><span style=" text-decoration: underline; color:#0000ff;">Debian </span></a>maintainer:</p> -<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; text-decoration: underline; color:#0000ff;"><br /></p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><a href="http://christian.amsuess.com/"><span style=" text-decoration: underline; color:#0000ff;">Christian M. Amsüss</span></a></p> -<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; text-decoration: underline; color:#0000ff;"><br /></p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Patches:</p> -<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><a href="https://github.com/meta23"><span style=" text-decoration: underline; color:#0000ff;">meta23</span></a></p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><a href="https://github.com/jasonblewis"><span style=" text-decoration: underline; color:#0000ff;">jasonblewis</span></a> </p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><a href="https://github.com/gregjurman"><span style=" text-decoration: underline; color:#0000ff;">gregjurman</span></a></p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><a href="https://github.com/brianolson"><span style=" text-decoration: underline; color:#0000ff;">brianolson</span></a></p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><a href="https://github.com/tjhowse"><span style=" text-decoration: underline; color:#0000ff;">tjhowse</span></a> </p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><a href="https://github.com/logxen"><span style=" text-decoration: underline; color:#0000ff;">logxen</span></a> (Mark A Cooper)</p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><a href="https://github.com/iamwilhelm"><span style=" text-decoration: underline; color:#0000ff;">iamwilhelm</span></a> (Wil Chung)</p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><a href="https://github.com/clothbot"><span style=" text-decoration: underline; color:#0000ff;">clothbot</span></a> (Andrew Plumb)</p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><a href="https://github.com/colah"><span style=" text-decoration: underline; color:#0000ff;">colah</span></a> (Christopher Olah)</p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" text-decoration: underline; color:#0000ff;"> </span></p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Bug reports:</p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"> </p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Lucida Grande'; font-size:10pt;">nop head, Triffid Hunter, Len Trigg, </span>Kliment Yanev, Christian Siefkes, Whosawhatsis, MichaelAtOz, mrhdias, ibyte8bits, Koen Kooi, Tomas Mudrunka, knuds, cadr, mshearn, Hans L, 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 ... and many others</p> -<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-style:italic;"><br /></p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Lucida Grande'; font-size:10pt; font-weight:600;">Hosting &amp; resources</span></p> -<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Lucida Grande'; font-size:10pt;"><br /></p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><a href="http://www.github.com"><span style=" text-decoration: underline; color:#0000ff;">Github</span></a><span style=" font-family:'Lucida Grande'; font-size:10pt;"> source repository</span></p> -<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><a href="http://rocklinux.net/pipermail/openscad/"><span style=" text-decoration: underline; color:#0000ff;">Rock Linux</span></a><span style=" font-family:'Lucida Grande'; font-size:10pt;"> mailing list</span></p> -<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; text-decoration: underline; color:#0000ff;"><br /></p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><a href="http://www.thingiverse.com"><span style=" text-decoration: underline; color:#0000ff;">Thingiverse</span></a></p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Lucida Grande'; font-size:10pt;"> </span></p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><a href="http://guerby.org/"><span style=" text-decoration: underline; color:#0000ff;">Laurent Guerby</span></a><span style=" font-family:'Lucida Grande'; font-size:10pt;"> and the </span><a href="http://gcc.gnu.org/wiki/CompileFarm"><span style=" text-decoration: underline; color:#0000ff;">GCC Compile Farm,</span></a><span style=" font-family:'Lucida Grande'; font-size:10pt;"> with </span><a href="http://osuosl.org/"><span style=" text-decoration: underline; color:#0000ff;">OSUOSL,</span></a><span style=" font-family:'Lucida Grande'; font-size:10pt;"> </span><a href="http://www.ibm.com"><span style=" text-decoration: underline; color:#0000ff;">IBM</span></a><span style=" font-family:'Lucida Grande'; font-size:10pt;">, </span><a href="http://www.irill.org"><span style=" text-decoration: underline; color:#0000ff;">IRILL,</span></a><span style=" font-family:'Lucida Grande'; font-size:10pt;"> </span><a href="http://www.intel.com"><span style=" text-decoration: underline; color:#0000ff;">Intel</span></a><span style=" font-family:'Lucida Grande'; font-size:10pt;">, </span><a href="http://www.fsffrance.org"><span style=" text-decoration: underline; color:#0000ff;">FSF France,</span></a><span style=" font-family:'Lucida Grande'; font-size:10pt;"> and </span><a href="http://www.amd.com"><span style=" text-decoration: underline; color:#0000ff;">AMD</span></a><span style=" font-family:'Lucida Grande'; font-size:10pt;">.</span></p> -<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Lucida Grande'; font-size:10pt;"><br /></p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Apologies to anyone accidentally left out. </p></body></html> + + + qrc:/src/AboutDialog.html + - + + + diff --git a/src/mainwin.cc b/src/mainwin.cc index dc738d7..491aa86 100644 --- a/src/mainwin.cc +++ b/src/mainwin.cc @@ -115,11 +115,11 @@ static char helptitle[] = #endif "\nhttp://www.openscad.org\n\n"; static char copyrighttext[] = - "Copyright (C) 2009-2011 Marius Kintel and Clifford Wolf \n" + "Copyright (C) 2009-2012 Marius Kintel and Clifford Wolf \n" "\n" - "This program is free software; you can redistribute it and/or modify" - "it under the terms of the GNU General Public License as published by" - "the Free Software Foundation; either version 2 of the License, or" + "This program is free software; you can redistribute it and/or modify " + "it under the terms of the GNU General Public License as published by " + "the Free Software Foundation; either version 2 of the License, or " "(at your option) any later version."; static void -- cgit v0.10.1 From f89b237ab6e06d1f3a8ebf5852c0e188cd6246b7 Mon Sep 17 00:00:00 2001 From: Marius Kintel Date: Tue, 21 Aug 2012 21:10:47 -0400 Subject: Updated mpfr, boost, glew diff --git a/scripts/macosx-build-dependencies.sh b/scripts/macosx-build-dependencies.sh index 2d7275c..73e4118 100755 --- a/scripts/macosx-build-dependencies.sh +++ b/scripts/macosx-build-dependencies.sh @@ -137,8 +137,8 @@ build_mpfr() fi tar xjf mpfr-$version.tar.bz2 cd mpfr-$version - curl -O http://www.mpfr.org/mpfr-$version/allpatches - patch -N -Z -p1 < allpatches +# curl -O http://www.mpfr.org/mpfr-$version/allpatches +# patch -N -Z -p1 < allpatches if $OPTION_32BIT; then mkdir build-i386 cd build-i386 @@ -238,12 +238,10 @@ build_glew() tar xzf glew-$version.tgz cd glew-$version mkdir -p $DEPLOYDIR/lib/pkgconfig - # To avoid running strip on a fat archive as this is not supported by strip - sed -ibak -e "s/\$(STRIP) -x lib\/\$(LIB.STATIC)//" Makefile if $OPTION_32BIT; then GLEW_EXTRA_FLAGS="-arch i386" fi - make GLEW_DEST=$DEPLOYDIR CFLAGS.EXTRA="-no-cpp-precomp -dynamic -fno-common -mmacosx-version-min=$MAC_OSX_VERSION_MIN $GLEW_EXTRA_FLAGS -arch x86_64" LDFLAGS.EXTRA="-mmacosx-version-min=$MAC_OSX_VERSION_MIN $GLEW_EXTRA_FLAGS -arch x86_64" install + make GLEW_DEST=$DEPLOYDIR CFLAGS.EXTRA="-no-cpp-precomp -dynamic -fno-common -mmacosx-version-min=$MAC_OSX_VERSION_MIN $GLEW_EXTRA_FLAGS -arch x86_64" LDFLAGS.EXTRA="-mmacosx-version-min=$MAC_OSX_VERSION_MIN $GLEW_EXTRA_FLAGS -arch x86_64" STRIP= install } build_opencsg() @@ -336,9 +334,9 @@ echo "Using basedir:" $BASEDIR mkdir -p $SRCDIR $DEPLOYDIR build_eigen 3.1.1 build_gmp 5.0.5 -build_mpfr 3.1.0 -build_boost 1.47.0 +build_mpfr 3.1.1 +build_boost 1.50.0 # NB! For CGAL, also update the actual download URL in the function build_cgal 4.0.2 -build_glew 1.7.0 +build_glew 1.9.0 build_opencsg 1.3.2 -- cgit v0.10.1 From 68da5cf2e896b6e482ef4919d23844c21e35124c Mon Sep 17 00:00:00 2001 From: Marius Kintel Date: Tue, 21 Aug 2012 23:21:02 -0400 Subject: Manual tests for module caching diff --git a/testdata/modulecache-tests/README.txt b/testdata/modulecache-tests/README.txt new file mode 100644 index 0000000..463261c --- /dev/null +++ b/testdata/modulecache-tests/README.txt @@ -0,0 +1,75 @@ +Some work is needed to include these into the automated test suite. +For now, run them manually according to these instructions: + +Compile OpenSCAD in debug mode. This will give console output related to module caching, e.g.: +/path/to/used.scad: 0x103612f70 +Module cache size: 1 modules + +Test1: +------ + +o Open use.scad +o Compile twice (F5) - check that module reference is the same + +Test2: +------ + +o Open use.scad +o Compile (F5) +o touch used.scad +o Compile (F5) - check that the module reference changed + +Test3: +------ + +o Open use-mcad.scad +o Compile (F5) +o Check that you get a rounded box + +Test4: +------ + +o Open usenonexsistingfile.scad +o Compile (F5) +o Verify that you get: WARNING: Can't open 'use' file 'nofile.scad'. + +Test5: +------ + +o Open moduleoverload.scad +o Compile (F5) +o Verify that you get a sphere rather than a cylinder + +Test6: +------ + +o Open recursivemain.scad +o Compile (F5) +o Verify that OpenSCAD won't hang or crash + +Test7: +------ + +o Open circularmain.scad +o Compile (F5) +o Verify that OpenSCAD won't hang or crash + +Test8: +------ + +o Open multiplemain.scad +o Compile (F5) - verify that you get a sphere and a cube of approximately the same size +o Edit multipleB.scad: + - cube(1.5*F(), center=true); + + cube(2.5*F(), center=true); +o Reload and Compile (F4) - verify that the cube got larger + +Test9: +------ + +o Open includefrommodule.scad +o Compile (F5) - Verify that you get a circular disc +o Edit radius.scad: Change RADIUS +o Compile (F5) - Verify that the disc changed size + +FIXME: Test circular include diff --git a/testdata/modulecache-tests/circularfirst.scad b/testdata/modulecache-tests/circularfirst.scad new file mode 100644 index 0000000..90052a9 --- /dev/null +++ b/testdata/modulecache-tests/circularfirst.scad @@ -0,0 +1 @@ +use diff --git a/testdata/modulecache-tests/circularmain.scad b/testdata/modulecache-tests/circularmain.scad new file mode 100644 index 0000000..feb9dde --- /dev/null +++ b/testdata/modulecache-tests/circularmain.scad @@ -0,0 +1 @@ +use diff --git a/testdata/modulecache-tests/circularsecond.scad b/testdata/modulecache-tests/circularsecond.scad new file mode 100644 index 0000000..feb9dde --- /dev/null +++ b/testdata/modulecache-tests/circularsecond.scad @@ -0,0 +1 @@ +use diff --git a/testdata/modulecache-tests/includefrommodule.scad b/testdata/modulecache-tests/includefrommodule.scad new file mode 100644 index 0000000..70bd804 --- /dev/null +++ b/testdata/modulecache-tests/includefrommodule.scad @@ -0,0 +1,3 @@ +use + +mymodule(); diff --git a/testdata/modulecache-tests/moduleoverload.scad b/testdata/modulecache-tests/moduleoverload.scad new file mode 100644 index 0000000..1928715 --- /dev/null +++ b/testdata/modulecache-tests/moduleoverload.scad @@ -0,0 +1,7 @@ +use + +module mymodule() { + sphere(); +} + +mymodule(); diff --git a/testdata/modulecache-tests/modulewithinclude.scad b/testdata/modulecache-tests/modulewithinclude.scad new file mode 100644 index 0000000..17ff74a --- /dev/null +++ b/testdata/modulecache-tests/modulewithinclude.scad @@ -0,0 +1,5 @@ +include + +module mymodule() { + cylinder(r=RADIUS); +} diff --git a/testdata/modulecache-tests/multipleA.scad b/testdata/modulecache-tests/multipleA.scad new file mode 100644 index 0000000..5f22471 --- /dev/null +++ b/testdata/modulecache-tests/multipleA.scad @@ -0,0 +1,6 @@ +use + +module A() +{ + sphere(r=F()); +} diff --git a/testdata/modulecache-tests/multipleB.scad b/testdata/modulecache-tests/multipleB.scad new file mode 100644 index 0000000..adee23c --- /dev/null +++ b/testdata/modulecache-tests/multipleB.scad @@ -0,0 +1,6 @@ +use + +module B() +{ + cube(1.5*F(), center=true); +} diff --git a/testdata/modulecache-tests/multiplecommon.scad b/testdata/modulecache-tests/multiplecommon.scad new file mode 100644 index 0000000..666c99f --- /dev/null +++ b/testdata/modulecache-tests/multiplecommon.scad @@ -0,0 +1 @@ +function F() = 20; diff --git a/testdata/modulecache-tests/multiplemain.scad b/testdata/modulecache-tests/multiplemain.scad new file mode 100644 index 0000000..6dd75a7 --- /dev/null +++ b/testdata/modulecache-tests/multiplemain.scad @@ -0,0 +1,5 @@ +use +use + +A(); +translate([40,0,0]) B(); diff --git a/testdata/modulecache-tests/mymodule-lib.scad b/testdata/modulecache-tests/mymodule-lib.scad new file mode 100644 index 0000000..9d68581 --- /dev/null +++ b/testdata/modulecache-tests/mymodule-lib.scad @@ -0,0 +1,3 @@ +module mymodule() { + cylinder(center=true); +} diff --git a/testdata/modulecache-tests/radius.scad b/testdata/modulecache-tests/radius.scad new file mode 100644 index 0000000..7620356 --- /dev/null +++ b/testdata/modulecache-tests/radius.scad @@ -0,0 +1 @@ +RADIUS = 5; diff --git a/testdata/modulecache-tests/recursive.scad b/testdata/modulecache-tests/recursive.scad new file mode 100644 index 0000000..5c117f4 --- /dev/null +++ b/testdata/modulecache-tests/recursive.scad @@ -0,0 +1 @@ +use diff --git a/testdata/modulecache-tests/recursivemain.scad b/testdata/modulecache-tests/recursivemain.scad new file mode 100644 index 0000000..5c117f4 --- /dev/null +++ b/testdata/modulecache-tests/recursivemain.scad @@ -0,0 +1 @@ +use diff --git a/testdata/modulecache-tests/simpleinclude.scad b/testdata/modulecache-tests/simpleinclude.scad new file mode 100644 index 0000000..9a09502 --- /dev/null +++ b/testdata/modulecache-tests/simpleinclude.scad @@ -0,0 +1 @@ +include diff --git a/testdata/modulecache-tests/simpleleaf.scad b/testdata/modulecache-tests/simpleleaf.scad new file mode 100644 index 0000000..b216b6c --- /dev/null +++ b/testdata/modulecache-tests/simpleleaf.scad @@ -0,0 +1 @@ +cylinder(h=25, r=12); diff --git a/testdata/modulecache-tests/use-mcad.scad b/testdata/modulecache-tests/use-mcad.scad new file mode 100644 index 0000000..b4b206a --- /dev/null +++ b/testdata/modulecache-tests/use-mcad.scad @@ -0,0 +1,3 @@ +use + +roundedBox([10,10,10], 2, $fn=16); diff --git a/testdata/modulecache-tests/use.scad b/testdata/modulecache-tests/use.scad new file mode 100644 index 0000000..693092a --- /dev/null +++ b/testdata/modulecache-tests/use.scad @@ -0,0 +1,3 @@ +use + +used(s()); diff --git a/testdata/modulecache-tests/used.scad b/testdata/modulecache-tests/used.scad new file mode 100644 index 0000000..cc301b5 --- /dev/null +++ b/testdata/modulecache-tests/used.scad @@ -0,0 +1,5 @@ +function s() = 20; + +module used(r) { + sphere(r); +} diff --git a/testdata/modulecache-tests/usenonexistingfile.scad b/testdata/modulecache-tests/usenonexistingfile.scad new file mode 100644 index 0000000..b5e4dd9 --- /dev/null +++ b/testdata/modulecache-tests/usenonexistingfile.scad @@ -0,0 +1 @@ +use -- cgit v0.10.1 From 787572c07a359ff677d81ec9f80c96e69a7d3ead Mon Sep 17 00:00:00 2001 From: Marius Kintel Date: Wed, 22 Aug 2012 00:13:19 -0400 Subject: Bugfix: rotate() with a vector argument with less that 3 elements used uninitialized variables, ending up being non-deterministic. Fixes #152 diff --git a/src/transform.cc b/src/transform.cc index 5b71346..0f678c5 100644 --- a/src/transform.cc +++ b/src/transform.cc @@ -98,7 +98,9 @@ AbstractNode *TransformModule::evaluate(const Context *ctx, const ModuleInstanti Value val_a = c.lookup_variable("a"); if (val_a.type() == Value::VECTOR) { - Eigen::AngleAxisd rotx, roty, rotz; + Eigen::AngleAxisd rotx(0, Vector3d::UnitX()); + Eigen::AngleAxisd roty(0, Vector3d::UnitY()); + Eigen::AngleAxisd rotz(0, Vector3d::UnitZ()); double a; if (val_a.toVector().size() > 0) { val_a.toVector()[0].getDouble(a); -- cgit v0.10.1 From 51b83ff8ddf75fe9ba7f489e827ed6b9261dca4f Mon Sep 17 00:00:00 2001 From: Marius Kintel Date: Wed, 22 Aug 2012 00:22:35 -0400 Subject: bugfix: There is a bug in the stdc++ library on Mac OS 10.5 which messes up some STL templates. This should fix it, courtesy of http://stackoverflow.com/questions/3484043/os-x-program-runs-on-dev-machine-crashing-horribly-on-others diff --git a/openscad.pro b/openscad.pro index 024b788..b5321cc 100644 --- a/openscad.pro +++ b/openscad.pro @@ -246,6 +246,7 @@ SOURCES += src/version_check.cc \ src/printutils.cc \ src/progress.cc \ src/parsersettings.cc \ + src/stl-utils.cc \ \ src/nodedumper.cc \ src/traverser.cc \ diff --git a/src/stl-utils.cc b/src/stl-utils.cc new file mode 100644 index 0000000..790fd17 --- /dev/null +++ b/src/stl-utils.cc @@ -0,0 +1,73 @@ +#if defined(__APPLE__) && defined(__GNUC__) + +#include + +// Workarounds for symbols that are missing from Leopard stdlibc++.dylib. +_GLIBCXX_BEGIN_NAMESPACE(std) +// From ostream_insert.h +template ostream& __ostream_insert(ostream&, const char*, streamsize); + +#ifdef _GLIBCXX_USE_WCHAR_T + template wostream& __ostream_insert(wostream&, const wchar_t*, streamsize); +#endif + +// From ostream.tcc +template ostream& ostream::_M_insert(long); +template ostream& ostream::_M_insert(unsigned long); +template ostream& ostream::_M_insert(bool); +#ifdef _GLIBCXX_USE_LONG_LONG + template ostream& ostream::_M_insert(long long); + template ostream& ostream::_M_insert(unsigned long long); +#endif +template ostream& ostream::_M_insert(double); +template ostream& ostream::_M_insert(long double); +template ostream& ostream::_M_insert(const void*); + +#ifdef _GLIBCXX_USE_WCHAR_T + template wostream& wostream::_M_insert(long); + template wostream& wostream::_M_insert(unsigned long); + template wostream& wostream::_M_insert(bool); + #ifdef _GLIBCXX_USE_LONG_LONG + template wostream& wostream::_M_insert(long long); + template wostream& wostream::_M_insert(unsigned long long); + #endif + template wostream& wostream::_M_insert(double); + template wostream& wostream::_M_insert(long double); + template wostream& wostream::_M_insert(const void*); +#endif + + +// From istream.tcc +template istream& istream::_M_extract(unsigned short&); +template istream& istream::_M_extract(unsigned int&); +template istream& istream::_M_extract(long&); +template istream& istream::_M_extract(unsigned long&); +template istream& istream::_M_extract(bool&); +#ifdef _GLIBCXX_USE_LONG_LONG + template istream& istream::_M_extract(long long&); + template istream& istream::_M_extract(unsigned long long&); +#endif +template istream& istream::_M_extract(float&); +template istream& istream::_M_extract(double&); +template istream& istream::_M_extract(long double&); +template istream& istream::_M_extract(void*&); + +#ifdef _GLIBCXX_USE_WCHAR_T + template wistream& wistream::_M_extract(unsigned short&); + template wistream& wistream::_M_extract(unsigned int&); + template wistream& wistream::_M_extract(long&); + template wistream& wistream::_M_extract(unsigned long&); + template wistream& wistream::_M_extract(bool&); + #ifdef _GLIBCXX_USE_LONG_LONG + template wistream& wistream::_M_extract(long long&); + template wistream& wistream::_M_extract(unsigned long long&); + #endif + template wistream& wistream::_M_extract(float&); + template wistream& wistream::_M_extract(double&); + template wistream& wistream::_M_extract(long double&); + template wistream& wistream::_M_extract(void*&); +#endif + +_GLIBCXX_END_NAMESPACE + +#endif -- cgit v0.10.1 From 15959bc32cc5ba649babac5636bb544e5e46868b Mon Sep 17 00:00:00 2001 From: don bright Date: Wed, 22 Aug 2012 12:07:46 +0200 Subject: stop crash bug reported by Giles Bathgate diff --git a/src/CGALEvaluator.cc b/src/CGALEvaluator.cc index ac6190f..86be59b 100644 --- a/src/CGALEvaluator.cc +++ b/src/CGALEvaluator.cc @@ -150,13 +150,18 @@ CGAL_Nef_polyhedron CGALEvaluator::applyHull(const CgaladvNode &node) } else if (dim == 3) { CGAL_Polyhedron P; - chN.p3->convert_to_Polyhedron(P); - std::transform(P.vertices_begin(), P.vertices_end(), std::back_inserter(points3d), - boost::bind(static_cast(&CGAL_Polyhedron::Vertex::point), _1)); + if (!chN.p3->is_simple()) { + PRINT("Object isn't a valid 2-manifold! Please modify your design. See http://en.wikibooks.org/wiki/OpenSCAD_User_Manual/STL_Import_and_Export"); + } + else { + chN.p3->convert_to_Polyhedron(P); + std::transform(P.vertices_begin(), P.vertices_end(), std::back_inserter(points3d), + boost::bind(static_cast(&CGAL_Polyhedron::Vertex::point), _1)); + } } chnode->progress_report(); } - + if (dim == 2) { std::list result; CGAL::convex_hull_2(points2d.begin(), points2d.end(),std:: back_inserter(result)); @@ -165,7 +170,8 @@ CGAL_Nef_polyhedron CGALEvaluator::applyHull(const CgaladvNode &node) } else if (dim == 3) { CGAL_Polyhedron P; - CGAL::convex_hull_3(points3d.begin(), points3d.end(), P); + if (points3d.size()>3) + CGAL::convex_hull_3(points3d.begin(), points3d.end(), P); N = CGAL_Nef_polyhedron(new CGAL_Nef_polyhedron3(P)); } return N; -- cgit v0.10.1 From 94f32b76470486d16a161824113197bb408f3617 Mon Sep 17 00:00:00 2001 From: don bright Date: Wed, 22 Aug 2012 12:08:23 +0200 Subject: cleanuyp diff --git a/src/CGALEvaluator.cc b/src/CGALEvaluator.cc index 86be59b..3cf2862 100644 --- a/src/CGALEvaluator.cc +++ b/src/CGALEvaluator.cc @@ -151,7 +151,7 @@ CGAL_Nef_polyhedron CGALEvaluator::applyHull(const CgaladvNode &node) else if (dim == 3) { CGAL_Polyhedron P; if (!chN.p3->is_simple()) { - PRINT("Object isn't a valid 2-manifold! Please modify your design. See http://en.wikibooks.org/wiki/OpenSCAD_User_Manual/STL_Import_and_Export"); + PRINT("Object isn't a valid 2-manifold! Please modify your design. See http://en.wikibooks.org/wiki/OpenSCAD_User_Manual/STL_Import_and_Export"); } else { chN.p3->convert_to_Polyhedron(P); @@ -161,7 +161,6 @@ CGAL_Nef_polyhedron CGALEvaluator::applyHull(const CgaladvNode &node) } chnode->progress_report(); } - if (dim == 2) { std::list result; CGAL::convex_hull_2(points2d.begin(), points2d.end(),std:: back_inserter(result)); -- cgit v0.10.1 From 59080526a488a8dfaafdb7ba26d59c29b7abfc13 Mon Sep 17 00:00:00 2001 From: don bright Date: Wed, 22 Aug 2012 12:10:21 +0200 Subject: cleanup diff --git a/src/CGALEvaluator.cc b/src/CGALEvaluator.cc index 3cf2862..064a36a 100644 --- a/src/CGALEvaluator.cc +++ b/src/CGALEvaluator.cc @@ -151,7 +151,7 @@ CGAL_Nef_polyhedron CGALEvaluator::applyHull(const CgaladvNode &node) else if (dim == 3) { CGAL_Polyhedron P; if (!chN.p3->is_simple()) { - PRINT("Object isn't a valid 2-manifold! Please modify your design. See http://en.wikibooks.org/wiki/OpenSCAD_User_Manual/STL_Import_and_Export"); + PRINT("Hull() currently requires a valid 2-manifold. Please modify your design. See http://en.wikibooks.org/wiki/OpenSCAD_User_Manual/STL_Import_and_Export"); } else { chN.p3->convert_to_Polyhedron(P); @@ -161,6 +161,7 @@ CGAL_Nef_polyhedron CGALEvaluator::applyHull(const CgaladvNode &node) } chnode->progress_report(); } + if (dim == 2) { std::list result; CGAL::convex_hull_2(points2d.begin(), points2d.end(),std:: back_inserter(result)); -- cgit v0.10.1 From 2ac32862901dc28fe4d360b7c444e679cad430d7 Mon Sep 17 00:00:00 2001 From: don bright Date: Wed, 22 Aug 2012 12:23:17 +0200 Subject: add line to hull test diff --git a/testdata/scad/features/hull3-tests.scad b/testdata/scad/features/hull3-tests.scad index 12c8a11..b6b3fe4 100644 --- a/testdata/scad/features/hull3-tests.scad +++ b/testdata/scad/features/hull3-tests.scad @@ -15,3 +15,14 @@ translate([25,0,0]) hull() { cylinder(r=5, h=5, center=true); } } + +// Don't Crash (issue 188) + +translate([-5,-5,-5]) { + hull() { + intersection(){ + cube([1,1,1]); + translate([-1,-1,-1]) cube([1,1,1]); + } +} + -- cgit v0.10.1 From 2eb62f91739157afc73f95d9992b4a1e2a2d7ddf Mon Sep 17 00:00:00 2001 From: don bright Date: Thu, 23 Aug 2012 00:18:10 +0200 Subject: color>1.0 warning (color([255,0,0]) per Joel Bodenmann rept to mail list diff --git a/src/color.cc b/src/color.cc index 4220396..acca652 100644 --- a/src/color.cc +++ b/src/color.cc @@ -64,8 +64,11 @@ AbstractNode *ColorModule::evaluate(const Context *ctx, const ModuleInstantiatio Value v = c.lookup_variable("c"); if (v.type() == Value::VECTOR) { - for (size_t i = 0; i < 4; i++) + for (size_t i = 0; i < 4; i++) { node->color[i] = i < v.toVector().size() ? v.toVector()[i].toDouble() : 1.0; + if (node->color[i] > 1) + PRINTB_NOCACHE("WARNING: color() expects numbers between 0.0 and 1.0. Value of %.1f is too large.", node->color[i]); + } } else if (v.type() == Value::STRING) { std::string colorname = v.toString(); boost::algorithm::to_lower(colorname); -- cgit v0.10.1 From 44d88f400141f67d57aa731c4829f804bf49d5b4 Mon Sep 17 00:00:00 2001 From: don bright Date: Thu, 23 Aug 2012 07:32:55 +0200 Subject: compile fix, boost>=1.44 can use boost filesystem v3 if you pass BOOST_FILESYSTEM_VERSION=3 as a compiler define but try to use boost filesystem v2 functions on these older boosts, (1.44, 1.45, etc) you get compilation errors. by changing the boost version detection for v3, we prevent the compile error. diff --git a/src/boosty.h b/src/boosty.h index 2e7d76b..87260ff 100644 --- a/src/boosty.h +++ b/src/boosty.h @@ -1,5 +1,6 @@ // boosty.h copyright 2012 don bright. released under the GPL 2, or later, // as described in the file named 'COPYING' in OpenSCAD's project root. +// permission is given to Marius Kintel & Clifford Wolf to change this license. #ifndef boosty_h_ #define boosty_h_ @@ -16,6 +17,7 @@ see also http://www.boost.org/doc/libs/1_48_0/libs/filesystem/v3/doc/index.htm + http://www.boost.org/doc/libs/1_45_0/libs/filesystem/v2/doc/index.htm http://www.boost.org/doc/libs/1_42_0/libs/filesystem/doc/index.htm http://www.boost.org/doc/libs/1_35_0/libs/filesystem/doc/index.htm include/boost/wave/util/filesystem_compatability.hpp @@ -29,7 +31,7 @@ namespace fs = boost::filesystem; namespace boosty { -#if BOOST_VERSION >= 104600 && BOOST_FILESYSTEM_VERSION >= 3 +#if BOOST_VERSION >= 104400 && BOOST_FILESYSTEM_VERSION >= 3 inline bool is_absolute( fs::path p ) { -- cgit v0.10.1 From 502ecbb6caa900520409bf85ad3ed1754248492d Mon Sep 17 00:00:00 2001 From: Marius Kintel Date: Sun, 2 Sep 2012 13:17:14 -0400 Subject: Block recursion on circular or recursive inclusions. Fixes #187 diff --git a/src/module.cc b/src/module.cc index fc849ff..cfd73cc 100644 --- a/src/module.cc +++ b/src/module.cc @@ -218,6 +218,9 @@ void Module::registerInclude(const std::string &filename) */ bool Module::handleDependencies() { + if (this->is_handling_dependencies) return false; + this->is_handling_dependencies = true; + bool changed = false; // Iterating manually since we want to modify the container while iterating Module::ModuleContainer::iterator iter = this->usedlibs.begin(); @@ -236,5 +239,7 @@ bool Module::handleDependencies() this->usedlibs.erase(curr); } } + + this->is_handling_dependencies = false; return changed; } diff --git a/src/module.h b/src/module.h index cd25287..879d249 100644 --- a/src/module.h +++ b/src/module.h @@ -59,7 +59,7 @@ public: class Module : public AbstractModule { public: - Module() { } + Module() : is_handling_dependencies(false) { } virtual ~Module(); virtual AbstractNode *evaluate(const Context *ctx, const ModuleInstantiation *inst) const; virtual std::string dump(const std::string &indent, const std::string &name) const; @@ -71,6 +71,7 @@ public: void registerInclude(const std::string &filename); typedef boost::unordered_map IncludeContainer; IncludeContainer includes; + bool is_handling_dependencies; bool handleDependencies(); std::vector assignments_var; -- cgit v0.10.1 From 66601933ab899b4d823a3c3b94cb0614e0e99d68 Mon Sep 17 00:00:00 2001 From: Marius Kintel Date: Sat, 8 Sep 2012 15:45:51 -0400 Subject: Enable opening of .csg files from from the GUI diff --git a/src/mainwin.cc b/src/mainwin.cc index 491aa86..6bdcd70 100644 --- a/src/mainwin.cc +++ b/src/mainwin.cc @@ -802,7 +802,8 @@ void MainWindow::actionNew() void MainWindow::actionOpen() { - QString new_filename = QFileDialog::getOpenFileName(this, "Open File", "", "OpenSCAD Designs (*.scad)"); + QString new_filename = QFileDialog::getOpenFileName(this, "Open File", "", + "OpenSCAD Designs (*.scad *.csg)"); #ifdef ENABLE_MDI if (!new_filename.isEmpty()) { new MainWindow(new_filename); -- cgit v0.10.1 From 3b6f16605c2dcdabca39dd0d61653cc8c72fa72d Mon Sep 17 00:00:00 2001 From: Marius Kintel Date: Sat, 8 Sep 2012 16:48:15 -0400 Subject: Fix bug where recently compiled module happened to receive the same pointer value as the module it replaced, causing dependency tracking not to work properly. Related to #75 diff --git a/src/ModuleCache.cc b/src/ModuleCache.cc index d03d121..c215342 100644 --- a/src/ModuleCache.cc +++ b/src/ModuleCache.cc @@ -75,17 +75,22 @@ Module *ModuleCache::evaluate(const std::string &filename) std::string text((std::istreambuf_iterator(ifs)), std::istreambuf_iterator()); print_messages_push(); - + + Module *oldmodule = NULL; cache_entry e = { NULL, cache_id }; if (this->entries.find(filename) != this->entries.end()) { - delete this->entries[filename].module; + oldmodule = this->entries[filename].module; } this->entries[filename] = e; std::string pathname = boosty::stringy(fs::path(filename).parent_path()); lib_mod = dynamic_cast(parse(text.c_str(), pathname.c_str(), false)); + PRINTB_NOCACHE(" compiled module: %p", lib_mod); if (lib_mod) { + // We defer deletion so we can ensure that the new module won't + // have the same address as the old + delete oldmodule; this->entries[filename].module = lib_mod; } else { this->entries.erase(filename); -- cgit v0.10.1 From fa9811c0f3314a0f343385c2cba7e691fa814b08 Mon Sep 17 00:00:00 2001 From: Marius Kintel Date: Sat, 6 Oct 2012 18:01:17 -0400 Subject: bugfix: parser errors wasn't treated correctly, causing cmd-line tools to return without an error code, as well as error highlighting in the editor being broken diff --git a/src/parser.y b/src/parser.y index b36c41b..c11f0f2 100644 --- a/src/parser.y +++ b/src/parser.y @@ -566,11 +566,11 @@ Module *parse(const char *text, const char *path, int debug) // PRINTB_NOCACHE("New module: %s %p", "root" % rootmodule); parserdebug = debug; - parserparse(); + int parserretval = parserparse(); lexerdestroy(); lexerlex_destroy(); - if (!rootmodule) return NULL; + if (parserretval != 0) return NULL; parser_error_pos = -1; return rootmodule; -- cgit v0.10.1 From c514f8041eca93bd3bb85b616be37a2d5ade3a48 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miro=20Hron=C4=8Dok?= Date: Sun, 7 Oct 2012 19:52:43 +0200 Subject: Fixed FSF address diff --git a/COPYING b/COPYING index 4f5b160..627c964 100644 --- a/COPYING +++ b/COPYING @@ -10,7 +10,7 @@ Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. - 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. -- cgit v0.10.1 From 0cea83a35d302929d22ddddbaa60280af62bf4dc Mon Sep 17 00:00:00 2001 From: Marius Kintel Date: Sun, 7 Oct 2012 15:24:08 -0400 Subject: Fixed weakness in parser causing modifier characters not to work in front of 'if' statements. Fixes #197 diff --git a/src/parser.y b/src/parser.y index c11f0f2..3e485ff 100644 --- a/src/parser.y +++ b/src/parser.y @@ -233,6 +233,22 @@ ifelse_statement: } ; module_instantiation: + '!' module_instantiation { + $$ = $2; + if ($$) $$->tag_root = true; + } | + '#' module_instantiation { + $$ = $2; + if ($$) $$->tag_highlight = true; + } | + '%' module_instantiation { + $$ = $2; + if ($$) $$->tag_background = true; + } | + '*' module_instantiation { + delete $2; + $$ = NULL; + } | single_module_instantiation ';' { $$ = $1; } | @@ -271,26 +287,7 @@ single_module_instantiation: $$->argexpr = $3->argexpr; free($1); delete $3; - } | - '!' single_module_instantiation { - $$ = $2; - if ($$) - $$->tag_root = true; - } | - '#' single_module_instantiation { - $$ = $2; - if ($$) - $$->tag_highlight = true; - } | - '%' single_module_instantiation { - $$ = $2; - if ($$) - $$->tag_background = true; - } | - '*' single_module_instantiation { - delete $2; - $$ = NULL; - }; + } expr: TOK_TRUE { diff --git a/testdata/scad/features/background-modifier.scad b/testdata/scad/features/background-modifier.scad index ec7b28d..5430472 100644 --- a/testdata/scad/features/background-modifier.scad +++ b/testdata/scad/features/background-modifier.scad @@ -2,3 +2,4 @@ difference() { sphere(r=10); %cylinder(h=30, r=6, center=true); } +%if (true) cube([25,6,3], center=true); diff --git a/testdata/scad/features/disable-modifier.scad b/testdata/scad/features/disable-modifier.scad index b47e074..2b75339 100644 --- a/testdata/scad/features/disable-modifier.scad +++ b/testdata/scad/features/disable-modifier.scad @@ -2,3 +2,4 @@ difference() { *sphere(r=10); cylinder(h=30, r=6, center=true); } +*if (true) cube([25,6,3], center=true); diff --git a/testdata/scad/features/highlight-and-background-modifier.scad b/testdata/scad/features/highlight-and-background-modifier.scad index 945d6b4..5dca703 100644 --- a/testdata/scad/features/highlight-and-background-modifier.scad +++ b/testdata/scad/features/highlight-and-background-modifier.scad @@ -1,8 +1,10 @@ difference() { sphere(r=10); %#cylinder(h=30, r=6, center=true); + %#if (true) cube([6,25,3], center=true); } translate([13,0,0]) difference() { sphere(r=10); #%cylinder(h=30, r=6, center=true); + #%if (true) cube([6,25,3], center=true); } diff --git a/testdata/scad/features/highlight-modifier.scad b/testdata/scad/features/highlight-modifier.scad index 1156a88..f228d08 100644 --- a/testdata/scad/features/highlight-modifier.scad +++ b/testdata/scad/features/highlight-modifier.scad @@ -2,3 +2,4 @@ difference() { sphere(r=10); #cylinder(h=30, r=6, center=true); } +#if (true) cube([25,6,3], center=true); diff --git a/testdata/scad/features/hull3-tests.scad b/testdata/scad/features/hull3-tests.scad index b6b3fe4..e3fc8e7 100644 --- a/testdata/scad/features/hull3-tests.scad +++ b/testdata/scad/features/hull3-tests.scad @@ -19,10 +19,10 @@ translate([25,0,0]) hull() { // Don't Crash (issue 188) translate([-5,-5,-5]) { - hull() { - intersection(){ - cube([1,1,1]); - translate([-1,-1,-1]) cube([1,1,1]); - } + hull() { + intersection() { + cube([1,1,1]); + translate([-1,-1,-1]) cube([1,1,1]); + } + } } - diff --git a/tests/regression/cgalpngtest/highlight-modifier-expected.png b/tests/regression/cgalpngtest/highlight-modifier-expected.png index 29a4117..e220aa1 100644 Binary files a/tests/regression/cgalpngtest/highlight-modifier-expected.png and b/tests/regression/cgalpngtest/highlight-modifier-expected.png differ diff --git a/tests/regression/cgalpngtest/root-modifier-if-expected.png b/tests/regression/cgalpngtest/root-modifier-if-expected.png new file mode 100644 index 0000000..1fe2aa5 Binary files /dev/null and b/tests/regression/cgalpngtest/root-modifier-if-expected.png differ diff --git a/tests/regression/dumptest/background-modifier-expected.txt b/tests/regression/dumptest/background-modifier-expected.txt index 6e9ca57..ed769b3 100644 --- a/tests/regression/dumptest/background-modifier-expected.txt +++ b/tests/regression/dumptest/background-modifier-expected.txt @@ -2,4 +2,7 @@ sphere($fn = 0, $fa = 12, $fs = 2, r = 10); %cylinder($fn = 0, $fa = 12, $fs = 2, h = 30, r1 = 6, r2 = 6, center = true); } + %group() { + cube(size = [25, 6, 3], center = true); + } diff --git a/tests/regression/dumptest/highlight-and-background-modifier-expected.txt b/tests/regression/dumptest/highlight-and-background-modifier-expected.txt index a525d68..20c82cc 100644 --- a/tests/regression/dumptest/highlight-and-background-modifier-expected.txt +++ b/tests/regression/dumptest/highlight-and-background-modifier-expected.txt @@ -1,11 +1,17 @@ difference() { sphere($fn = 0, $fa = 12, $fs = 2, r = 10); %cylinder($fn = 0, $fa = 12, $fs = 2, h = 30, r1 = 6, r2 = 6, center = true); + %group() { + cube(size = [6, 25, 3], center = true); + } } multmatrix([[1, 0, 0, 13], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]) { difference() { sphere($fn = 0, $fa = 12, $fs = 2, r = 10); %cylinder($fn = 0, $fa = 12, $fs = 2, h = 30, r1 = 6, r2 = 6, center = true); + %group() { + cube(size = [6, 25, 3], center = true); + } } } diff --git a/tests/regression/dumptest/highlight-modifier-expected.txt b/tests/regression/dumptest/highlight-modifier-expected.txt index c0f1da2..c6204bd 100644 --- a/tests/regression/dumptest/highlight-modifier-expected.txt +++ b/tests/regression/dumptest/highlight-modifier-expected.txt @@ -2,4 +2,7 @@ sphere($fn = 0, $fa = 12, $fs = 2, r = 10); cylinder($fn = 0, $fa = 12, $fs = 2, h = 30, r1 = 6, r2 = 6, center = true); } + group() { + cube(size = [25, 6, 3], center = true); + } diff --git a/tests/regression/dumptest/hull3-tests-expected.txt b/tests/regression/dumptest/hull3-tests-expected.txt index af48b7f..4c05e2c 100644 --- a/tests/regression/dumptest/hull3-tests-expected.txt +++ b/tests/regression/dumptest/hull3-tests-expected.txt @@ -17,4 +17,14 @@ } } } + multmatrix([[1, 0, 0, -5], [0, 1, 0, -5], [0, 0, 1, -5], [0, 0, 0, 1]]) { + hull() { + intersection() { + cube(size = [1, 1, 1], center = false); + multmatrix([[1, 0, 0, -1], [0, 1, 0, -1], [0, 0, 1, -1], [0, 0, 0, 1]]) { + cube(size = [1, 1, 1], center = false); + } + } + } + } diff --git a/tests/regression/dumptest/root-modifier-if-expected.txt b/tests/regression/dumptest/root-modifier-if-expected.txt new file mode 100644 index 0000000..dfcd15a --- /dev/null +++ b/tests/regression/dumptest/root-modifier-if-expected.txt @@ -0,0 +1,7 @@ + group() { + sphere($fn = 0, $fa = 12, $fs = 2, r = 5); + } + group() { + cube(size = [5, 5, 5], center = false); + } + diff --git a/tests/regression/opencsgtest/background-modifier-expected.png b/tests/regression/opencsgtest/background-modifier-expected.png index 24149d0..2505331 100644 Binary files a/tests/regression/opencsgtest/background-modifier-expected.png and b/tests/regression/opencsgtest/background-modifier-expected.png differ diff --git a/tests/regression/opencsgtest/highlight-and-background-modifier-expected.png b/tests/regression/opencsgtest/highlight-and-background-modifier-expected.png index 72d03c3..8febe76 100644 Binary files a/tests/regression/opencsgtest/highlight-and-background-modifier-expected.png and b/tests/regression/opencsgtest/highlight-and-background-modifier-expected.png differ diff --git a/tests/regression/opencsgtest/highlight-modifier-expected.png b/tests/regression/opencsgtest/highlight-modifier-expected.png index 78d0309..af01e5b 100644 Binary files a/tests/regression/opencsgtest/highlight-modifier-expected.png and b/tests/regression/opencsgtest/highlight-modifier-expected.png differ diff --git a/tests/regression/opencsgtest/root-modifier-if-expected.png b/tests/regression/opencsgtest/root-modifier-if-expected.png new file mode 100644 index 0000000..5b9a786 Binary files /dev/null and b/tests/regression/opencsgtest/root-modifier-if-expected.png differ diff --git a/tests/regression/throwntogethertest/background-modifier-expected.png b/tests/regression/throwntogethertest/background-modifier-expected.png index 79810f5..2505331 100644 Binary files a/tests/regression/throwntogethertest/background-modifier-expected.png and b/tests/regression/throwntogethertest/background-modifier-expected.png differ diff --git a/tests/regression/throwntogethertest/highlight-modifier-expected.png b/tests/regression/throwntogethertest/highlight-modifier-expected.png index a1ec8fe..7973d82 100644 Binary files a/tests/regression/throwntogethertest/highlight-modifier-expected.png and b/tests/regression/throwntogethertest/highlight-modifier-expected.png differ diff --git a/tests/regression/throwntogethertest/root-modifier-if-expected.png b/tests/regression/throwntogethertest/root-modifier-if-expected.png new file mode 100644 index 0000000..5b9a786 Binary files /dev/null and b/tests/regression/throwntogethertest/root-modifier-if-expected.png differ -- cgit v0.10.1 From 9c9781334aee87f32926cfd465839c4e5026a65d Mon Sep 17 00:00:00 2001 From: Marius Kintel Date: Mon, 8 Oct 2012 20:44:48 -0400 Subject: Added testcase for issue #204 diff --git a/testdata/scad/bugs/issue204.scad b/testdata/scad/bugs/issue204.scad new file mode 100644 index 0000000..f2e8152 --- /dev/null +++ b/testdata/scad/bugs/issue204.scad @@ -0,0 +1,5 @@ +// Causes a CGAL assertion in CGALEvaluator::process() +e=0.000; +for (m = [ [ [ 0, 1, 0], [ 0, 0, 1], [ 1, 0, 0] ], + [ [-1, 0, e], [ 0,-1, 0], [ 0, 0,-1] ] ] ) + multmatrix (m) cube([1,5,1], center=true); -- cgit v0.10.1 From 750e1f9f649e0908bf1d89c9e31d61ef0f56fe7f Mon Sep 17 00:00:00 2001 From: Marius Kintel Date: Mon, 8 Oct 2012 20:45:47 -0400 Subject: Catch exceptions as const references. Fixes #204 diff --git a/src/CGALEvaluator.cc b/src/CGALEvaluator.cc index 064a36a..5e16892 100644 --- a/src/CGALEvaluator.cc +++ b/src/CGALEvaluator.cc @@ -81,15 +81,13 @@ void CGALEvaluator::process(CGAL_Nef_polyhedron &target, const CGAL_Nef_polyhedr break; } } - catch (CGAL::Failure_exception e) { - // union && difference assert triggered by testdata/scad/bugs/rotate-diff-nonmanifold-crash.scad + catch (const CGAL::Failure_exception &e) { + // union && difference assert triggered by testdata/scad/bugs/rotate-diff-nonmanifold-crash.scad and testdata/scad/bugs/issue204.scad std::string opstr = op == CGE_UNION ? "union" : op == CGE_INTERSECTION ? "intersection" : op == CGE_DIFFERENCE ? "difference" : op == CGE_MINKOWSKI ? "minkowski" : "UNKNOWN"; PRINTB("CGAL error in CGAL_Nef_polyhedron's %s operator: %s", opstr % e.what()); - // Minkowski errors can result in corrupt polyhedrons - if (op == CGE_MINKOWSKI) { - target = src; - } + // Errors can result in corrupt polyhedrons, so put back the old one + target = src; } CGAL::set_error_behaviour(old_behaviour); } @@ -649,7 +647,7 @@ CGAL_Nef_polyhedron CGALEvaluator::evaluateCGALMesh(const PolySet &ps) N = new CGAL_Nef_polyhedron3(*P); } } - catch (CGAL::Assertion_exception e) { + catch (const CGAL::Assertion_exception &e) { PRINTB("CGAL error in CGAL_Nef_polyhedron3(): %s", e.what()); } CGAL::set_error_behaviour(old_behaviour); -- cgit v0.10.1 From 087b9bb7c3462894acd5d527f32c4b43bedf6fdb Mon Sep 17 00:00:00 2001 From: Marius Kintel Date: Mon, 8 Oct 2012 20:49:02 -0400 Subject: Catch exceptions as const references. Related to #204 diff --git a/src/CGAL_Nef_polyhedron.cc b/src/CGAL_Nef_polyhedron.cc index ba298ad..56232a3 100644 --- a/src/CGAL_Nef_polyhedron.cc +++ b/src/CGAL_Nef_polyhedron.cc @@ -101,7 +101,7 @@ PolySet *CGAL_Nef_polyhedron::convertToPolyset() this->p3->convert_to_Polyhedron(P); ps = createPolySetFromPolyhedron(P); } - catch (CGAL::Precondition_exception e) { + catch (const CGAL::Precondition_exception &e) { PRINTB("CGAL error in CGAL_Nef_polyhedron::convertToPolyset(): %s", e.what()); } CGAL::set_error_behaviour(old_behaviour); diff --git a/src/cgalutils.cc b/src/cgalutils.cc index e39c495..a1c7dc2 100644 --- a/src/cgalutils.cc +++ b/src/cgalutils.cc @@ -136,7 +136,7 @@ CGAL_Polyhedron *createPolyhedronFromPolySet(const PolySet &ps) CGAL_Build_PolySet builder(ps); P->delegate(builder); } - catch (CGAL::Assertion_exception e) { + catch (const CGAL::Assertion_exception &e) { PRINTB("CGAL error in CGAL_Build_PolySet: %s", e.what()); delete P; P = NULL; diff --git a/src/cgalworker.cc b/src/cgalworker.cc index 30bb1fe..96fead9 100644 --- a/src/cgalworker.cc +++ b/src/cgalworker.cc @@ -31,7 +31,7 @@ void CGALWorker::work() CGALEvaluator evaluator(*this->tree); root_N = new CGAL_Nef_polyhedron(evaluator.evaluateCGALMesh(*this->tree->root())); } - catch (ProgressCancelException e) { + catch (const ProgressCancelException &e) { PRINT("Rendering cancelled."); } diff --git a/src/dxfdata.cc b/src/dxfdata.cc index 4258a4c..2fd40ab 100644 --- a/src/dxfdata.cc +++ b/src/dxfdata.cc @@ -141,7 +141,7 @@ DxfData::DxfData(double fn, double fs, double fa, try { id = boost::lexical_cast(id_str); } - catch (boost::bad_lexical_cast &blc) { + catch (const boost::bad_lexical_cast &blc) { if (!stream.eof()) { PRINTB("WARNING: Illegal ID '%s' in `%s'", id_str % filename); } diff --git a/src/dxftess-cgal.cc b/src/dxftess-cgal.cc index f221e3a..d01c1d5 100644 --- a/src/dxftess-cgal.cc +++ b/src/dxftess-cgal.cc @@ -166,7 +166,7 @@ void dxf_tesselate(PolySet *ps, DxfData &dxf, double rot, bool up, bool /* do_tr } } - catch (CGAL::Assertion_exception e) { + catch (const CGAL::Assertion_exception &e) { PRINTB("CGAL error in dxf_tesselate(): %s", e.what()); CGAL::set_error_behaviour(old_behaviour); return; diff --git a/src/export.cc b/src/export.cc index 40ce6cb..80670ea 100644 --- a/src/export.cc +++ b/src/export.cc @@ -111,7 +111,7 @@ void export_stl(CGAL_Nef_polyhedron *root_N, std::ostream &output) setlocale(LC_NUMERIC, ""); // Set default locale } - catch (CGAL::Assertion_exception e) { + catch (const CGAL::Assertion_exception &e) { PRINTB("CGAL error in CGAL_Nef_polyhedron3::convert_to_Polyhedron(): %s", e.what()); } CGAL::set_error_behaviour(old_behaviour); @@ -125,7 +125,7 @@ void export_off(CGAL_Nef_polyhedron *root_N, std::ostream &output) root_N->p3->convert_to_Polyhedron(P); output << P; } - catch (CGAL::Assertion_exception e) { + catch (const CGAL::Assertion_exception &e) { PRINTB("CGAL error in CGAL_Nef_polyhedron3::convert_to_Polyhedron(): %s", e.what()); } CGAL::set_error_behaviour(old_behaviour); diff --git a/src/import.cc b/src/import.cc index 1073459..40d34fa 100644 --- a/src/import.cc +++ b/src/import.cc @@ -157,7 +157,7 @@ PolySet *ImportNode::evaluate_polyset(class PolySetEvaluator *) const vdata[i][v] = boost::lexical_cast(results[v+1]); } } - catch (boost::bad_lexical_cast &blc) { + catch (const boost::bad_lexical_cast &blc) { PRINTB("WARNING: Can't parse vertex line '%s'.", line); i = 10; continue; diff --git a/src/mainwin.cc b/src/mainwin.cc index 6bdcd70..4b0df70 100644 --- a/src/mainwin.cc +++ b/src/mainwin.cc @@ -709,7 +709,7 @@ void MainWindow::compileCSG(bool procevents) PolySetCache::instance()->print(); CGALCache::instance()->print(); } - catch (ProgressCancelException e) { + catch (const ProgressCancelException &e) { PRINT("CSG generation cancelled."); } progress_report_fin(); diff --git a/src/openscad.cc b/src/openscad.cc index 49c39da..df7adb3 100644 --- a/src/openscad.cc +++ b/src/openscad.cc @@ -153,7 +153,7 @@ int main(int argc, char **argv) try { po::store(po::command_line_parser(argc, argv).options(all_options).positional(p).run(), vm); } - catch(std::exception &e) { // Catches e.g. unknown options + catch(const std::exception &e) { // Catches e.g. unknown options fprintf(stderr, "%s\n", e.what()); help(argv[0]); } diff --git a/src/surface.cc b/src/surface.cc index 2fa3717..4339ead 100644 --- a/src/surface.cc +++ b/src/surface.cc @@ -134,7 +134,7 @@ PolySet *SurfaceNode::evaluate_polyset(class PolySetEvaluator *) const min_val = std::min(v-1, min_val); } } - catch (boost::bad_lexical_cast &blc) { + catch (const boost::bad_lexical_cast &blc) { if (!stream.eof()) { PRINTB("WARNING: Illegal value in '%s': %s", filename % blc.what()); } -- cgit v0.10.1 From 08e7ce3036065e28fa79c37e7f4f343e6e2cb37d Mon Sep 17 00:00:00 2001 From: Marius Kintel Date: Mon, 8 Oct 2012 21:05:23 -0400 Subject: Catch CGAL assertion for projection nodes. Fixes #202 diff --git a/src/PolySetCGALEvaluator.cc b/src/PolySetCGALEvaluator.cc index 3b272d2..bca9902 100644 --- a/src/PolySetCGALEvaluator.cc +++ b/src/PolySetCGALEvaluator.cc @@ -122,30 +122,36 @@ PolySet *PolySetCGALEvaluator::evaluatePolySet(const ProjectionNode &node) CGAL_Nef_polyhedron nef_poly; - if (node.cut_mode) - { - // intersect 'sum' with the x-y plane - CGAL_Nef_polyhedron3::Plane_3 xy_plane = CGAL_Nef_polyhedron3::Plane_3( 0,0,1,0 ); - *sum.p3 = sum.p3->intersection( xy_plane, CGAL_Nef_polyhedron3::PLANE_ONLY); - - // Visit each polygon in sum.p3 and union/intersect into a 2d polygon (with holes) - // For info on Volumes, Shells, Facets, and the 'visitor' pattern, please see - // http://www.cgal.org/Manual/latest/doc_html/cgal_manual/Nef_3/Chapter_main.html - NefShellVisitor_for_cut shell_visitor; - CGAL_Nef_polyhedron3::Volume_const_iterator i; - CGAL_Nef_polyhedron3::Shell_entry_const_iterator j; - CGAL_Nef_polyhedron3::SFace_const_handle sface_handle; - for ( i = sum.p3->volumes_begin(); i != sum.p3->volumes_end(); ++i ) { - for ( j = i->shells_begin(); j != i->shells_end(); ++j ) { - sface_handle = CGAL_Nef_polyhedron3::SFace_const_handle( j ); - sum.p3->visit_shell_objects( sface_handle , shell_visitor ); + if (node.cut_mode) { + CGAL::Failure_behaviour old_behaviour = CGAL::set_error_behaviour(CGAL::THROW_EXCEPTION); + try { + // intersect 'sum' with the x-y plane + CGAL_Nef_polyhedron3::Plane_3 xy_plane = CGAL_Nef_polyhedron3::Plane_3( 0,0,1,0 ); + *sum.p3 = sum.p3->intersection( xy_plane, CGAL_Nef_polyhedron3::PLANE_ONLY); + + // Visit each polygon in sum.p3 and union/intersect into a 2d polygon (with holes) + // For info on Volumes, Shells, Facets, and the 'visitor' pattern, please see + // http://www.cgal.org/Manual/latest/doc_html/cgal_manual/Nef_3/Chapter_main.html + NefShellVisitor_for_cut shell_visitor; + CGAL_Nef_polyhedron3::Volume_const_iterator i; + CGAL_Nef_polyhedron3::Shell_entry_const_iterator j; + CGAL_Nef_polyhedron3::SFace_const_handle sface_handle; + for ( i = sum.p3->volumes_begin(); i != sum.p3->volumes_end(); ++i ) { + for ( j = i->shells_begin(); j != i->shells_end(); ++j ) { + sface_handle = CGAL_Nef_polyhedron3::SFace_const_handle( j ); + sum.p3->visit_shell_objects( sface_handle , shell_visitor ); + } } + if (debug) std::cout << "shell visitor\n" << shell_visitor.dump() << "\nshell visitor end\n"; + + nef_poly.p2 = shell_visitor.output_nefpoly2d; + nef_poly.dim = 2; + if (debug) std::cout << "--\n" << nef_poly.dump_p2() << "\n"; + } + catch (const CGAL::Failure_exception &e) { + PRINTB("CGAL error in projection node: %s", e.what()); + return NULL; } - if (debug) std::cout << "shell visitor\n" << shell_visitor.dump() << "\nshell visitor end\n"; - - nef_poly.p2 = shell_visitor.output_nefpoly2d; - nef_poly.dim = 2; - if (debug) std::cout << "--\n" << nef_poly.dump_p2() << "\n"; // Extract polygons in the XY plane, ignoring all other polygons // FIXME: If the polyhedron is really thin, there might be unwanted polygons -- cgit v0.10.1 From eebc87fe1fda369c510f7a7cd22b605f2607612f Mon Sep 17 00:00:00 2001 From: Marius Kintel Date: Mon, 8 Oct 2012 22:22:27 -0400 Subject: Fixed broken debug output diff --git a/src/cgalutils.cc b/src/cgalutils.cc index a1c7dc2..e402139 100644 --- a/src/cgalutils.cc +++ b/src/cgalutils.cc @@ -81,7 +81,7 @@ public: const CGALPoint &p = vertices[i]; B.add_vertex(p); #ifdef GEN_SURFACE_DEBUG - printf("%d: %f %f %f\n", i, p[0], p[1], p[2]); + printf("%d: %f %f %f\n", i, p.x().to_double(), p.y().to_double(), p.z().to_double()); #endif } -- cgit v0.10.1 From 165c29e159ba660019fc4c5184819ca49adf8bda Mon Sep 17 00:00:00 2001 From: Marius Kintel Date: Tue, 9 Oct 2012 21:22:17 -0400 Subject: cosmetics diff --git a/src/func.cc b/src/func.cc index 6c5f070..e427bf2 100644 --- a/src/func.cc +++ b/src/func.cc @@ -63,9 +63,7 @@ Value Function::evaluate(const Context *ctx, { Context c(ctx); c.args(argnames, argexpr, call_argnames, call_argvalues); - if (expr) - return expr->evaluate(&c); - return Value(); + return expr ? expr->evaluate(&c) : Value(); } std::string Function::dump(const std::string &indent, const std::string &name) const -- cgit v0.10.1 From 65fc1d6b01ade5e76fe712f93e2e108194c3291b Mon Sep 17 00:00:00 2001 From: Marius Kintel Date: Tue, 9 Oct 2012 23:32:56 -0400 Subject: Detect recursive execution of functions to avoid a stack overflow crash. Fixes #200 diff --git a/src/context.cc b/src/context.cc index f48cd86..a2a8d13 100644 --- a/src/context.cc +++ b/src/context.cc @@ -43,6 +43,7 @@ std::vector Context::ctx_stack; Context::Context(const Context *parent, const Module *library) : parent(parent), inst_p(NULL) { + if (parent) recursioncount = parent->recursioncount; ctx_stack.push_back(this); if (parent) document_path = parent->document_path; if (library) { @@ -130,10 +131,26 @@ Value Context::lookup_variable(const std::string &name, bool silent) const return Value(); } +class RecursionGuard +{ +public: + RecursionGuard(const Context &c, const std::string &name) : c(c), name(name) { c.recursioncount[name]++; } + ~RecursionGuard() { if (--c.recursioncount[name] == 0) c.recursioncount.erase(name); } + bool recursion_detected() const { return (c.recursioncount[name] > 100); } +private: + const Context &c; + const std::string &name; +}; + Value Context::evaluate_function(const std::string &name, const std::vector &argnames, const std::vector &argvalues) const { + RecursionGuard g(*this, name); + if (g.recursion_detected()) { + PRINTB("Recursion detected calling function '%s'", name); + return Value(); + } if (this->functions_p && this->functions_p->find(name) != this->functions_p->end()) return this->functions_p->find(name)->second->evaluate(this, argnames, argvalues); if (this->usedlibs_p) { @@ -144,8 +161,7 @@ Value Context::evaluate_function(const std::string &name, } } } - if (this->parent) - return this->parent->evaluate_function(name, argnames, argvalues); + if (this->parent) return this->parent->evaluate_function(name, argnames, argvalues); PRINTB("WARNING: Ignoring unknown function '%s'.", name); return Value(); } diff --git a/src/context.h b/src/context.h index f085e01..de5f1ca 100644 --- a/src/context.h +++ b/src/context.h @@ -41,6 +41,8 @@ public: static std::vector ctx_stack; + mutable unordered_map recursioncount; + private: typedef unordered_map ValueMap; ValueMap constants; diff --git a/testdata/scad/misc/recursion-tests.scad b/testdata/scad/misc/recursion-tests.scad new file mode 100644 index 0000000..2a07b91 --- /dev/null +++ b/testdata/scad/misc/recursion-tests.scad @@ -0,0 +1,2 @@ +function crash() = crash(); +echo(crash()); diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 33f3547..68083ce 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -704,7 +704,8 @@ list(APPEND ECHO_FILES ${FUNCTION_FILES} ${CMAKE_SOURCE_DIR}/../testdata/scad/misc/string-test.scad ${CMAKE_SOURCE_DIR}/../testdata/scad/misc/string-indexing.scad ${CMAKE_SOURCE_DIR}/../testdata/scad/misc/vector-values.scad - ${CMAKE_SOURCE_DIR}/../testdata/scad/misc/search-tests.scad) + ${CMAKE_SOURCE_DIR}/../testdata/scad/misc/search-tests.scad + ${CMAKE_SOURCE_DIR}/../testdata/scad/misc/recursion-tests.scad) list(APPEND DUMPTEST_FILES ${MINIMAL_FILES} ${FEATURES_FILES} ${EXAMPLE_FILES}) list(APPEND DUMPTEST_FILES ${CMAKE_SOURCE_DIR}/../testdata/scad/misc/escape-test.scad diff --git a/tests/regression/echotest/recursion-tests-expected.txt b/tests/regression/echotest/recursion-tests-expected.txt new file mode 100644 index 0000000..f4897ee --- /dev/null +++ b/tests/regression/echotest/recursion-tests-expected.txt @@ -0,0 +1,2 @@ +Recursion detected calling function 'crash' +ECHO: undef -- cgit v0.10.1 From 56def4aef228564ea4abcc06d4873c961921cf7d Mon Sep 17 00:00:00 2001 From: don bright Date: Mon, 15 Oct 2012 20:17:12 -0500 Subject: projection: fallback to 'large thin box' if intersection with plane fails. also implement SVG debugging output for 2d + 3d Nef Polyhedrons. diff --git a/src/CGAL_Nef_polyhedron.h b/src/CGAL_Nef_polyhedron.h index 694b420..3157ff2 100644 --- a/src/CGAL_Nef_polyhedron.h +++ b/src/CGAL_Nef_polyhedron.h @@ -20,7 +20,8 @@ public: CGAL_Nef_polyhedron &operator-=(const CGAL_Nef_polyhedron &other); CGAL_Nef_polyhedron &minkowski(const CGAL_Nef_polyhedron &other); CGAL_Nef_polyhedron copy() const; - std::string dump_p2() const; + std::string dump_svg() const; + std::string dump() const; int weight() const; class PolySet *convertToPolyset(); class DxfData *convertToDxfData() const; diff --git a/src/CGAL_Nef_polyhedron_DxfData.cc b/src/CGAL_Nef_polyhedron_DxfData.cc index 411a340..922a7ec 100644 --- a/src/CGAL_Nef_polyhedron_DxfData.cc +++ b/src/CGAL_Nef_polyhedron_DxfData.cc @@ -28,6 +28,7 @@ #include "grid.h" #include "CGAL_Nef_polyhedron.h" #include "cgal.h" +#include "cgalutils.h" #ifdef ENABLE_CGAL @@ -77,29 +78,24 @@ DxfData *CGAL_Nef_polyhedron::convertToDxfData() const return dxfdata; } -// dump the 2 dimensional nef_poly. -std::string CGAL_Nef_polyhedron::dump_p2() const +std::string CGAL_Nef_polyhedron::dump() const { - std::stringstream out; - CGAL_Nef_polyhedron2::Explorer explorer = this->p2->explorer(); - CGAL_Nef_polyhedron2::Explorer::Vertex_const_iterator i; - out << "CGAL_Nef_polyhedron::p2 Vertices"; - for (i = explorer.vertices_begin(); i != explorer.vertices_end(); ++i) { - if ( explorer.is_standard( i ) ) { - CGAL_Nef_polyhedron2::Explorer::Point point = explorer.point( i ); - out << "\n Point x y: " - << CGAL::to_double(point.x()) << " " - << CGAL::to_double(point.y()); - } else { - CGAL_Nef_polyhedron2::Explorer::Ray ray = explorer.ray( i ); - CGAL_Nef_polyhedron2::Explorer::Point point = ray.point( 0 ); - out << "\n Ray x y dx dy: " - << CGAL::to_double(point.x()) << " " << CGAL::to_double(point.y()) << " " - << CGAL::to_double(ray.direction().dx()) << " " << CGAL::to_double(ray.direction().dy()); - } - } - out << "\nCGAL_Nef_polyhedron::p2 Vertices end"; - return out.str(); + if (this->dim==2) + return dump_cgal_nef_polyhedron2( *this->p2 ); + else if (this->dim==3) + return dump_cgal_nef_polyhedron3( *this->p3 ); + else + return std::string("Nef Polyhedron with dimension != 2 or 3"); +} + +std::string CGAL_Nef_polyhedron::dump_svg() const +{ + if (this->dim==2) + return dump_cgal_nef_polyhedron2_svg( *this->p2 ); + else if (this->dim==3) + return dump_cgal_nef_polyhedron3_svg( *this->p3 ); + else + return std::string(""); } #endif // ENABLE_CGAL diff --git a/src/PolySetCGALEvaluator.cc b/src/PolySetCGALEvaluator.cc index bca9902..19f5325 100644 --- a/src/PolySetCGALEvaluator.cc +++ b/src/PolySetCGALEvaluator.cc @@ -1,6 +1,7 @@ #include "PolySetCGALEvaluator.h" #include "cgal.h" #include "cgalutils.h" +#include #include "polyset.h" #include "CGALEvaluator.h" #include "projectionnode.h" @@ -15,33 +16,23 @@ #include "printutils.h" #include "openscad.h" // get_fragments_from_r() #include +#include -/* - -This Visitor is used in the 'cut' process. Essentially, one or more of -our 3d nef polyhedrons have been 'cut' by the xy-plane, forming a number -of polygons that are essentially 'flat'. This Visitor object, when -called repeatedly, collects those flat polygons together and forms a new -2d nef polyhedron out of them. It keeps track of the 'holes' so that -in the final resulting polygon, they are preserved properly. +typedef CGAL_Nef_polyhedron3::Point_3 Point_3; -The output polygon is stored in the output_nefpoly2d variable. +/* -For more information on 3d + 2d nef polyhedrons, facets, halffacets, -facet cycles, etc, please see these websites: +This class converts multiple 3d-CGAL Nef polyhedrons into a single 2d by +stripping off the z coordinate of each face vertex and doing unions and +intersections. It uses the 'visitor' pattern from the CGAL manual. +Output is in the 'output_nefpoly2d' variable. +See also http://www.cgal.org/Manual/latest/doc_html/cgal_manual/Nef_3/Chapter_main.html -http://www.cgal.org/Manual/latest/doc_html/cgal_manual/Nef_3_ref/Class_Nef_polyhedron_3-Traits---Halffacet.html - -The halffacet iteration 'circulator' code is based on OGL_helper.h - -Why do we throw out all 'down' half-facets? Imagine a triangle in 3d -space - it has one 'half face' for one 'side' and another 'half face' for the -other 'side'. If we iterated over both half-faces we would get the same vertex -coordinates twice. Instead, we only need one side, in our case, we -chose the 'up' side. +http://www.cgal.org/Manual/latest/doc_html/cgal_manual/Nef_3_ref/Class_Nef_polyhedron3.html +OGL_helper.h */ -class NefShellVisitor_for_cut { +class Flattener { public: std::stringstream out; CGAL_Nef_polyhedron2::Boundary boundary; @@ -49,7 +40,7 @@ public: shared_ptr output_nefpoly2d; CGAL::Direction_3 up; bool debug; - NefShellVisitor_for_cut(bool debug=false) + Flattener(bool debug=false) { output_nefpoly2d.reset( new CGAL_Nef_polyhedron2() ); boundary = CGAL_Nef_polyhedron2::INCLUDED; @@ -67,11 +58,11 @@ public: void visit( CGAL_Nef_polyhedron3::SFace_const_handle ) {} void visit( CGAL_Nef_polyhedron3::Halffacet_const_handle hfacet ) { if ( hfacet->plane().orthogonal_direction() != this->up ) { - if (debug) out << "down facing half-facet. skipping\n"; + out << "\ndown facing half-facet. skipping\n"; return; } - int numcontours = 0; + int contour_counter = 0; CGAL_Nef_polyhedron3::Halffacet_cycle_const_iterator i; CGAL_forall_facet_cycles_of( i, hfacet ) { CGAL_Nef_polyhedron3::SHalfedge_around_facet_const_circulator c1(i), c2(c1); @@ -82,14 +73,18 @@ public: contour.push_back( point2d ); } tmpnef2d.reset( new CGAL_Nef_polyhedron2( contour.begin(), contour.end(), boundary ) ); - if ( numcontours == 0 ) { - if (debug) out << " contour is a body. make union(). " << contour.size() << " points.\n" ; - *output_nefpoly2d += *tmpnef2d; + if ( contour_counter == 0 ) { + if (debug) out << "\ncontour is a body. make union(). " << contour.size() << " points.\n" ; + *(output_nefpoly2d) += *(tmpnef2d); } else { - if (debug) out << " contour is a hole. make intersection(). " << contour.size() << " points.\n"; - *output_nefpoly2d *= *tmpnef2d; + *(output_nefpoly2d) *= *(tmpnef2d); + if (debug) out << "\ncontour is a hole. make intersection(). " << contour.size() << " points.\n"; } - numcontours++; + out << "\n------- tmp: -------\n"; + if (debug) out << dump_cgal_nef_polyhedron2( *tmpnef2d ); + out << "\n------- output accumulator: -------\n"; + if (debug) out << dump_cgal_nef_polyhedron2( *output_nefpoly2d ); + contour_counter++; } // next facet cycle (i.e. next contour) } // visit() }; @@ -120,39 +115,74 @@ PolySet *PolySetCGALEvaluator::evaluatePolySet(const ProjectionNode &node) } } + // std::cout << "----- input dump \n" << sum.dump_svg() << "\n"; + CGAL_Nef_polyhedron nef_poly; if (node.cut_mode) { CGAL::Failure_behaviour old_behaviour = CGAL::set_error_behaviour(CGAL::THROW_EXCEPTION); + bool plane_intersect_fail = false; try { - // intersect 'sum' with the x-y plane CGAL_Nef_polyhedron3::Plane_3 xy_plane = CGAL_Nef_polyhedron3::Plane_3( 0,0,1,0 ); *sum.p3 = sum.p3->intersection( xy_plane, CGAL_Nef_polyhedron3::PLANE_ONLY); - - // Visit each polygon in sum.p3 and union/intersect into a 2d polygon (with holes) - // For info on Volumes, Shells, Facets, and the 'visitor' pattern, please see - // http://www.cgal.org/Manual/latest/doc_html/cgal_manual/Nef_3/Chapter_main.html - NefShellVisitor_for_cut shell_visitor; + } + catch (const CGAL::Failure_exception &e) { + PRINTB("CGAL error in projection node during plane intersection: %s", e.what()); + plane_intersect_fail = true; + } + if (plane_intersect_fail) { + try { + PRINT("Trying alternative intersection using very large thin box: "); + double inf = 1e8, eps = 0.1; + double x1 = -inf, x2 = +inf, y1 = -inf, y2 = +inf, z1 = 0, z2 = eps; + + std::vector pts; + pts.push_back( Point_3( x1, y1, z1 ) ); + pts.push_back( Point_3( x1, y2, z1 ) ); + pts.push_back( Point_3( x2, y2, z1 ) ); + pts.push_back( Point_3( x2, y1, z1 ) ); + pts.push_back( Point_3( x1, y1, z2 ) ); + pts.push_back( Point_3( x1, y2, z2 ) ); + pts.push_back( Point_3( x2, y2, z2 ) ); + pts.push_back( Point_3( x2, y1, z2 ) ); + + CGAL_Polyhedron bigbox; + CGAL::convex_hull_3( pts.begin(), pts.end(), bigbox ); + CGAL_Nef_polyhedron3 nef_bigbox( bigbox ); + *sum.p3 = nef_bigbox.intersection( *sum.p3 ); + } + catch (const CGAL::Failure_exception &e) { + PRINTB("CGAL error in projection node during bigbox intersection: %s", e.what()); + // fixme , can we just return empty polyset? + CGAL::set_error_behaviour(old_behaviour); + return NULL; + } + } + + // remove z coordinates to make CGAL_Nef_polyhedron2 + try { + Flattener flattener(true); CGAL_Nef_polyhedron3::Volume_const_iterator i; CGAL_Nef_polyhedron3::Shell_entry_const_iterator j; CGAL_Nef_polyhedron3::SFace_const_handle sface_handle; for ( i = sum.p3->volumes_begin(); i != sum.p3->volumes_end(); ++i ) { for ( j = i->shells_begin(); j != i->shells_end(); ++j ) { sface_handle = CGAL_Nef_polyhedron3::SFace_const_handle( j ); - sum.p3->visit_shell_objects( sface_handle , shell_visitor ); + sum.p3->visit_shell_objects( sface_handle , flattener ); } } - if (debug) std::cout << "shell visitor\n" << shell_visitor.dump() << "\nshell visitor end\n"; - - nef_poly.p2 = shell_visitor.output_nefpoly2d; + + std::cout << "------- flattener dump \n" << flattener.dump() << "\n"; + nef_poly.p2 = flattener.output_nefpoly2d; nef_poly.dim = 2; - if (debug) std::cout << "--\n" << nef_poly.dump_p2() << "\n"; - } - catch (const CGAL::Failure_exception &e) { - PRINTB("CGAL error in projection node: %s", e.what()); - return NULL; + } catch (const CGAL::Failure_exception &e) { + PRINTB("CGAL error in projection node while flattening: %s", e.what()); } + CGAL::set_error_behaviour(old_behaviour); + + std::cout << "------- 3d cut dump \n" << sum.dump_svg() << "\n"; + std::cout << "------- 2d output dump \n" << nef_poly.dump_svg() << "\n"; // Extract polygons in the XY plane, ignoring all other polygons // FIXME: If the polyhedron is really thin, there might be unwanted polygons // in the XY plane, causing the resulting 2D polygon to be self-intersection diff --git a/src/cgal.h b/src/cgal.h index e5e39dd..2ca82d3 100644 --- a/src/cgal.h +++ b/src/cgal.h @@ -54,6 +54,8 @@ typedef CGAL::Polyhedron_3 CGAL_Polyhedron; typedef CGAL_Polyhedron::HalfedgeDS CGAL_HDS; typedef CGAL::Polyhedron_incremental_builder_3 CGAL_Polybuilder; +typedef CGAL::Cartesian::Iso_cuboid_3 CGAL_Iso_cuboid_3; + #ifdef PREV_NDEBUG #define NDEBUG PREV_NDEBUG #endif diff --git a/src/cgalutils.cc b/src/cgalutils.cc index e402139..7ae6d7b 100644 --- a/src/cgalutils.cc +++ b/src/cgalutils.cc @@ -3,9 +3,11 @@ #include "cgalutils.h" #include "polyset.h" #include "printutils.h" - #include "cgal.h" - +#include +typedef CGAL::Point_3 CGAL_Point_3; +typedef CGAL::Point_2 CGAL_Point_2; +#include #include PolySet *createPolySetFromPolyhedron(const CGAL_Polyhedron &p) @@ -145,5 +147,296 @@ CGAL_Polyhedron *createPolyhedronFromPolySet(const PolySet &ps) return P; } + + + +CGAL::Point project_svg3( CGAL_Point_3 p, CGAL_Iso_cuboid_3 bbox ) +{ + // do extremely simple fake isometric projection, based on bounding box + double x = CGAL::to_double( p.x() ); + double y = CGAL::to_double( p.y() ); + double z = CGAL::to_double( p.z() ); + double screenw = 480; + double screenh = 480; + double xcenter = screenw / 2; + double ycenter = screenh / 2; + double xdist = ( 2 * CGAL::to_double( bbox.xmax() - bbox.xmin() ) ); + double ydist = ( 2 * CGAL::to_double( bbox.ymax() - bbox.ymin() ) ); + double zdist = ( 2 * CGAL::to_double( bbox.zmax() - bbox.zmin() ) ); + double xscale = (xdist==0) ? 1 : screenw / (xdist * 1.618); + double yscale = (ydist==0) ? 1 : screenh / (ydist * 1.618 * 3); + double zscale = (zdist==0) ? 1 : screenh / (zdist * 1.618); + double tx = xcenter + x * xscale + y * yscale; + double ty = ycenter - z * zscale - y * yscale; + return CGAL::Point( tx, ty, 0 ); +} + +CGAL::Point project_svg2( CGAL::Point p, CGAL_Iso_cuboid_3 bbox ) +{ + CGAL_Point_3 pnew( p.x(), 0, p.y() ); + return project_svg3( pnew, bbox ); +} + +// for debugging, not necessarily pretty or useful for users. +std::string dump_cgal_nef_polyhedron2_face_svg( + CGAL_Nef_polyhedron2::Explorer::Halfedge_around_face_const_circulator c1, + CGAL_Nef_polyhedron2::Explorer::Halfedge_around_face_const_circulator c2, + CGAL_Nef_polyhedron2::Explorer explorer ) +{ + std::stringstream out; + CGAL_For_all(c1, c2) { + if ( explorer.is_standard( explorer.target(c1) ) ) { + CGAL_Nef_polyhedron2::Explorer::Point source = explorer.point( explorer.source( c1 ) ); + CGAL_Nef_polyhedron2::Explorer::Point target = explorer.point( explorer.target( c1 ) ); + CGAL::Point tp1 = project_svg2( source ); + CGAL::Point tp2 = project_svg2( target ); + out << " \n"; + } + } + return out.str(); +} + +std::string dump_cgal_nef_polyhedron2_svg( const CGAL_Nef_polyhedron2 &N ) +{ + std::stringstream out; + CGAL_Nef_polyhedron2::Explorer explorer = N.explorer(); + CGAL_Nef_polyhedron2::Explorer::Face_const_iterator i; + out << "\n"; + out << "\n"; + out << ""; + for ( i = explorer.faces_begin(); i!= explorer.faces_end(); ++i ) { + CGAL_Nef_polyhedron2::Explorer::Halfedge_around_face_const_circulator c1 + = explorer.face_cycle( i ), c2 ( c1 ); + out << dump_cgal_nef_polyhedron2_face_svg( c1, c2, explorer ); + +/* + holes not implemented + CGAL_Nef_polyhedron2::Explorer::Hole_const_iterator j; + for ( j = explorer.holes_begin( i ); j!= explorer.holes_end( i ); ++j ) { + CGAL_Nef_polyhedron2::Explorer::Halfedge_around_face_const_circulator c3( j ), c4 ( c3 ); + out << dump_cgal_nef_polyhedron2_face_svg( c3, c4, explorer ); + } +*/ + } + out << ""; + std::string tmp = out.str(); + boost::replace_all( tmp, "'", "\"" ); + return tmp; +} + + +std::string dump_cgal_nef_polyhedron2_face( + CGAL_Nef_polyhedron2::Explorer::Halfedge_around_face_const_circulator c1, + CGAL_Nef_polyhedron2::Explorer::Halfedge_around_face_const_circulator c2, + CGAL_Nef_polyhedron2::Explorer explorer ) +{ + std::stringstream out; + CGAL_For_all(c1, c2) { + out << " On frame edge:" << explorer.is_frame_edge( c1 ); + out << " Mark: " << explorer.mark( c1 ); + if ( explorer.is_standard( explorer.target(c1) ) ) { + CGAL_Nef_polyhedron2::Explorer::Point source = explorer.point( explorer.source( c1 ) ); + CGAL_Nef_polyhedron2::Explorer::Point target = explorer.point( explorer.target( c1 ) ); + out << " Halfedge x y x2 y2: " + << CGAL::to_double(source.x()) << " " + << CGAL::to_double(source.y()) << " " + << CGAL::to_double(target.x()) << " " + << CGAL::to_double(target.y()) << "\n"; + } else { + CGAL_Nef_polyhedron2::Explorer::Ray ray = explorer.ray( explorer.target( c1 ) ); + out << " Ray x y dx dy: " + << CGAL::to_double(ray.point(0).x()) << " " + << CGAL::to_double(ray.point(0).y()) << " " + << CGAL::to_double(ray.point(1).x()) << " " + << CGAL::to_double(ray.point(1).y()) << "\n"; + } + } + return out.str(); +} + +std::string dump_cgal_nef_polyhedron2( const CGAL_Nef_polyhedron2 &N ) +{ + std::stringstream out; + CGAL_Nef_polyhedron2::Explorer explorer = N.explorer(); + CGAL_Nef_polyhedron2::Explorer::Face_const_iterator i; + out << "CGAL_Nef_polyhedron2 dump begin\n"; + for ( i = explorer.faces_begin(); i!= explorer.faces_end(); ++i ) { + out << " Face body:\n"; + CGAL_Nef_polyhedron2::Explorer::Halfedge_around_face_const_circulator c1 + = explorer.face_cycle( i ), c2 ( c1 ); + out << dump_cgal_nef_polyhedron2_face( c1, c2, explorer ); + + CGAL_Nef_polyhedron2::Explorer::Hole_const_iterator j; + for ( j = explorer.holes_begin( i ); j!= explorer.holes_end( i ); ++j ) { + out << " Face hole:\n"; + CGAL_Nef_polyhedron2::Explorer::Halfedge_around_face_const_circulator c3( j ), c4 ( c3 ); + out << dump_cgal_nef_polyhedron2_face( c3, c4, explorer ); + } + } + out << "CGAL_Nef_polyhedron2 dump end"; + return out.str(); +} + +// This uses the Shell Explorer pattern from the CGAL Manual to dump the 3d Nef Polyhedron information +// http://www.cgal.org/Manual/latest/doc_html/cgal_manual/Nef_3/Chapter_main.html#Subsection_29.7.2 +class NefPoly3_dumper_svg { +public: + std::stringstream out; + CGAL_Iso_cuboid_3 bbox; + NefPoly3_dumper_svg(const CGAL_Nef_polyhedron3& N) {} + void setbbox( CGAL_Iso_cuboid_3 bbox ) { this->bbox = bbox; } + void visit(CGAL_Nef_polyhedron3::Vertex_const_handle v) {} + void visit(CGAL_Nef_polyhedron3::Halfedge_const_handle ) {} + void visit(CGAL_Nef_polyhedron3::SHalfedge_const_handle ) {} + void visit(CGAL_Nef_polyhedron3::SHalfloop_const_handle shh ){} + void visit(CGAL_Nef_polyhedron3::SFace_const_handle ) {} + void visit( CGAL_Nef_polyhedron3::Halffacet_const_handle hfacet ) + { + int contour_count = 0; + out << " \n"; + CGAL_Nef_polyhedron3::Halffacet_cycle_const_iterator i; + CGAL_forall_facet_cycles_of( i, hfacet ) { + CGAL_Nef_polyhedron3::SHalfloop_const_handle shl_handle; + out << " \n"; + if ( contour_count == 0 ) { + out << " \n"; + } else { + out << " \n" ; + } + CGAL_Nef_polyhedron3::SHalfedge_around_facet_const_circulator c1(i), c2(c1); + CGAL_For_all( c1, c2 ) { + out << " source(), except thats what CGAL does internally + CGAL_Point_3 source = c1->source()->source()->point(); + CGAL_Point_3 target = c1->source()->target()->point(); + tp1 = project_svg ( source ); + tp2 = project_svg ( target ); + out << " " + << "x1='" << CGAL::to_double(tp1.x()) << "' " + << "y1='" << CGAL::to_double(tp1.y()) << "' " + << "x2='" << CGAL::to_double(tp2.x()) << "' " + << "y2='" << CGAL::to_double(tp2.y()) << "' " + << "stroke='red' />\n"; + } + contour_count++; + } // next facet cycle (i.e. next contour) + } // visit() + +}; + + +std::string dump_cgal_nef_polyhedron3_svg( const CGAL_Nef_polyhedron3 &N ) +{ + std::stringstream out; + out << "\n"; + out << "\n"; + out << ""; + out << "\n"; + + std::vector points; + CGAL_Nef_polyhedron3::Vertex_const_iterator vi; + for (vi = N.vertices_begin(); vi!=N.vertices_end(); ++vi) + points.push_back( vi->point() ); + CGAL_Iso_cuboid_3 bbox = CGAL::bounding_box( points.begin(), points.end() ); + + CGAL_Nef_polyhedron3::Volume_const_iterator c; + CGAL_forall_volumes(c,N) { + out << " \n"; + out << " \n"; + CGAL_Nef_polyhedron3::Shell_entry_const_iterator it; + CGAL_forall_shells_of(it,c) { + out << " \n"; + NefPoly3_dumper_svg dumper_svg(N); + dumper_svg.setbbox( bbox ); + N.visit_shell_objects(CGAL_Nef_polyhedron3::SFace_const_handle(it), dumper_svg ); + out << dumper_svg.out.str(); + out << " \n"; + } + out << " \n"; + } + out << "\n"; + out << ""; + std::string tmp = out.str(); + boost::replace_all( tmp, "'", "\"" ); + return tmp; +} + +// This uses the Shell Explorer pattern from the CGAL Manual to dump the 3d Nef Polyhedron information +// http://www.cgal.org/Manual/latest/doc_html/cgal_manual/Nef_3/Chapter_main.html#Subsection_29.7.2 +class NefPoly3_dumper { +public: + std::stringstream out; + NefPoly3_dumper(const CGAL_Nef_polyhedron3& N) {} + void visit(CGAL_Nef_polyhedron3::Vertex_const_handle v) {} + void visit(CGAL_Nef_polyhedron3::Halfedge_const_handle ) {} + void visit(CGAL_Nef_polyhedron3::SHalfedge_const_handle ) {} + void visit(CGAL_Nef_polyhedron3::SHalfloop_const_handle shh ) + { + out << " SHalfloop visit\n"; + out << " Mark: " << (*shh).mark() << "\n"; + } + void visit(CGAL_Nef_polyhedron3::SFace_const_handle ) {} + void visit( CGAL_Nef_polyhedron3::Halffacet_const_handle hfacet ) + { + int contour_count = 0; + out << " Halffacet visit\n"; + out << " Mark: " << (*hfacet).mark() << "\n"; + CGAL_Nef_polyhedron3::Halffacet_cycle_const_iterator i; + CGAL_forall_facet_cycles_of( i, hfacet ) { + CGAL_Nef_polyhedron3::SHalfloop_const_handle shl_handle; + out << " Halffacet cycle:\n"; + if ( contour_count == 0 ) { + out << " Body contour:\n"; + } else { + out << " Hole contour:\n" ; + } + CGAL_Nef_polyhedron3::SHalfedge_around_facet_const_circulator c1(i), c2(c1); + int count=0; + CGAL_For_all( c1, c2 ) { + out << " Halfedge vertex:"; + out << " Mark: " << (*c1).mark(); + count++; + CGAL_Point_3 point3d = c1->source()->source()->point(); + double x = CGAL::to_double( point3d.x() ); + double y = CGAL::to_double( point3d.y() ); + double z = CGAL::to_double( point3d.z() ); + out << " x:" << x << " y:" << y << " z:" << z <<"\n"; + } + out << " point count: " << count << "\n"; + contour_count++; + } // next facet cycle (i.e. next contour) + } // visit() + +}; + +std::string dump_cgal_nef_polyhedron3( const CGAL_Nef_polyhedron3 &N ) +{ + std::stringstream out; + out << "CGAL_Nef_polyhedron3 dump begin\n"; + CGAL_Nef_polyhedron3::Volume_const_iterator c; + CGAL_forall_volumes(c,N) { + out << " Processing volume...\n"; + out << " Mark: " << (*c).mark() << "\n"; + CGAL_Nef_polyhedron3::Shell_entry_const_iterator it; + CGAL_forall_shells_of(it,c) { + out << " Processing shell...\n"; + NefPoly3_dumper dumper(N); + N.visit_shell_objects(CGAL_Nef_polyhedron3::SFace_const_handle(it), dumper ); + out << dumper.out.str(); + out << " Processing shell end\n"; + } + out << " Processing volume end\n"; + } + out << "CGAL_Nef_polyhedron3 dump end\n"; + return out.str(); +} + + + #endif /* ENABLE_CGAL */ diff --git a/src/cgalutils.h b/src/cgalutils.h index a249697..2bf6566 100644 --- a/src/cgalutils.h +++ b/src/cgalutils.h @@ -5,5 +5,9 @@ class PolySet *createPolySetFromPolyhedron(const CGAL_Polyhedron &p); CGAL_Polyhedron *createPolyhedronFromPolySet(const class PolySet &ps); +std::string dump_cgal_nef_polyhedron2( const CGAL_Nef_polyhedron2 &N ); +std::string dump_cgal_nef_polyhedron3( const CGAL_Nef_polyhedron3 &N ); +std::string dump_cgal_nef_polyhedron2_svg( const CGAL_Nef_polyhedron2 &N ); +std::string dump_cgal_nef_polyhedron3_svg( const CGAL_Nef_polyhedron3 &N ); #endif -- cgit v0.10.1 From 8191c292b00af4fcfa22c7ab59db9e53e122e10c Mon Sep 17 00:00:00 2001 From: don bright Date: Mon, 15 Oct 2012 22:02:44 -0500 Subject: refactor to make svg in 2d and 3d use same transformation code diff --git a/src/cgalutils.cc b/src/cgalutils.cc index 7ae6d7b..b3a9407 100644 --- a/src/cgalutils.cc +++ b/src/cgalutils.cc @@ -6,7 +6,8 @@ #include "cgal.h" #include typedef CGAL::Point_3 CGAL_Point_3; -typedef CGAL::Point_2 CGAL_Point_2; +typedef CGAL::Point_2 > CGAL_Point_2; +typedef CGAL::Simple_cartesian::Iso_rectangle_2 CGAL_Iso_rectangle_2; #include #include @@ -150,7 +151,7 @@ CGAL_Polyhedron *createPolyhedronFromPolySet(const PolySet &ps) -CGAL::Point project_svg3( CGAL_Point_3 p, CGAL_Iso_cuboid_3 bbox ) +CGAL_Point_2 project_svg_3to2( CGAL_Point_3 p, CGAL_Iso_cuboid_3 bbox ) { // do extremely simple fake isometric projection, based on bounding box double x = CGAL::to_double( p.x() ); @@ -168,13 +169,16 @@ CGAL::Point project_svg3( CGAL_Point_3 p, CGAL_Iso_cuboid_3 bbox ) double zscale = (zdist==0) ? 1 : screenh / (zdist * 1.618); double tx = xcenter + x * xscale + y * yscale; double ty = ycenter - z * zscale - y * yscale; - return CGAL::Point( tx, ty, 0 ); + return CGAL_Point_2( tx, ty ); } -CGAL::Point project_svg2( CGAL::Point p, CGAL_Iso_cuboid_3 bbox ) +CGAL_Point_2 project_svg_2to2( CGAL_Point_2 p, CGAL_Iso_rectangle_2 bbox ) { - CGAL_Point_3 pnew( p.x(), 0, p.y() ); - return project_svg3( pnew, bbox ); + CGAL_Point_3 origin( 0, 0, 0 ); + CGAL_Iso_cuboid_3 bbox3d( bbox.xmin(), bbox.ymin(), origin.z(), + bbox.xmax(), bbox.ymax(), origin.z() ); + CGAL_Point_3 point3d( p.x(), origin.z() , p.y() ); + return project_svg_3to2( point3d, bbox3d ); } // for debugging, not necessarily pretty or useful for users. @@ -183,13 +187,23 @@ std::string dump_cgal_nef_polyhedron2_face_svg( CGAL_Nef_polyhedron2::Explorer::Halfedge_around_face_const_circulator c2, CGAL_Nef_polyhedron2::Explorer explorer ) { + std::vector points; + CGAL_For_all(c1, c2) + if ( explorer.is_standard( explorer.source( c1 ) ) ) { + points.push_back( explorer.point( explorer.source( c1 ) ) ); + std::cout << points.size() << " point size\n"; + } + CGAL_Iso_rectangle_2 bbox( 0,0,0,0 ); + if ( points.size() > 0 ) + bbox = CGAL::bounding_box( points.begin(), points.end() ); + std::stringstream out; CGAL_For_all(c1, c2) { if ( explorer.is_standard( explorer.target(c1) ) ) { - CGAL_Nef_polyhedron2::Explorer::Point source = explorer.point( explorer.source( c1 ) ); - CGAL_Nef_polyhedron2::Explorer::Point target = explorer.point( explorer.target( c1 ) ); - CGAL::Point tp1 = project_svg2( source ); - CGAL::Point tp2 = project_svg2( target ); + CGAL_Point_2 source = explorer.point( explorer.source( c1 ) ); + CGAL_Point_2 target = explorer.point( explorer.target( c1 ) ); + CGAL_Point_2 tp1 = project_svg_2to2( source, bbox ); + CGAL_Point_2 tp2 = project_svg_2to2( target, bbox ); out << " source(), except thats what CGAL does internally CGAL_Point_3 source = c1->source()->source()->point(); CGAL_Point_3 target = c1->source()->target()->point(); - tp1 = project_svg ( source ); - tp2 = project_svg ( target ); + CGAL_Point_2 tp1 = project_svg_3to2 ( source, bbox ); + CGAL_Point_2 tp2 = project_svg_3to2 ( target, bbox ); out << " " << "x1='" << CGAL::to_double(tp1.x()) << "' " << "y1='" << CGAL::to_double(tp1.y()) << "' " -- cgit v0.10.1 From ddbdd58d16a4e4f0fa15096736922985e458ff99 Mon Sep 17 00:00:00 2001 From: don bright Date: Thu, 18 Oct 2012 22:31:37 -0500 Subject: add OpenSCAD version to about dialog title. improve SVG debugging output for Nef3 and Nef2 polyhedra. diff --git a/src/AboutDialog.h b/src/AboutDialog.h index 34122a0..1ae6533 100644 --- a/src/AboutDialog.h +++ b/src/AboutDialog.h @@ -3,12 +3,16 @@ #include "ui_AboutDialog.h" +#define STRINGIFY(x) #x +#define TOSTRING(x) STRINGIFY(x) + class AboutDialog : public QDialog, public Ui::AboutDialog { Q_OBJECT; public: AboutDialog(QWidget *) { setupUi(this); + this->setWindowTitle( QString("About OpenSCAD ") + QString(TOSTRING( OPENSCAD_VERSION)) ); this->aboutText->setOpenExternalLinks(true); QUrl flattr_qurl(":icons/flattr.png" ); this->aboutText->loadResource( QTextDocument::ImageResource, flattr_qurl ); diff --git a/src/PolySetCGALEvaluator.cc b/src/PolySetCGALEvaluator.cc index 19f5325..2a002be 100644 --- a/src/PolySetCGALEvaluator.cc +++ b/src/PolySetCGALEvaluator.cc @@ -74,21 +74,78 @@ public: } tmpnef2d.reset( new CGAL_Nef_polyhedron2( contour.begin(), contour.end(), boundary ) ); if ( contour_counter == 0 ) { - if (debug) out << "\ncontour is a body. make union(). " << contour.size() << " points.\n" ; + out << "\n \n" ; *(output_nefpoly2d) += *(tmpnef2d); } else { *(output_nefpoly2d) *= *(tmpnef2d); - if (debug) out << "\ncontour is a hole. make intersection(). " << contour.size() << " points.\n"; + if (debug) out << "\n\n"; } - out << "\n------- tmp: -------\n"; - if (debug) out << dump_cgal_nef_polyhedron2( *tmpnef2d ); - out << "\n------- output accumulator: -------\n"; - if (debug) out << dump_cgal_nef_polyhedron2( *output_nefpoly2d ); + out << "\n\n"; + out << dump_cgal_nef_polyhedron2_svg( *tmpnef2d ); + out << "\n\n"; + out << dump_cgal_nef_polyhedron2_svg( *output_nefpoly2d ); contour_counter++; } // next facet cycle (i.e. next contour) } // visit() }; + + + +class Flattener2 { +public: + std::stringstream out; + CGAL_Nef_polyhedron2::Boundary boundary; + shared_ptr tmpnef2d; + shared_ptr output_nefpoly2d; + CGAL::Direction_3 up; + bool debug; + Flattener2(bool debug=false) + { + output_nefpoly2d.reset( new CGAL_Nef_polyhedron2() ); + boundary = CGAL_Nef_polyhedron2::INCLUDED; + up = CGAL::Direction_3(0,0,1); + this->debug = debug; + } + std::string dump() + { + return out.str(); + } + void visit( CGAL_Nef_polyhedron3::Vertex_const_handle ) {} + void visit( CGAL_Nef_polyhedron3::Halfedge_const_handle ) {} + void visit( CGAL_Nef_polyhedron3::SHalfedge_const_handle ) {} + void visit( CGAL_Nef_polyhedron3::SHalfloop_const_handle ) {} + void visit( CGAL_Nef_polyhedron3::SFace_const_handle ) {} + void visit( CGAL_Nef_polyhedron3::Halffacet_const_handle hfacet ) { + int contour_counter = 0; + CGAL_Nef_polyhedron3::Halffacet_cycle_const_iterator i; + CGAL_forall_facet_cycles_of( i, hfacet ) { + CGAL_Nef_polyhedron3::SHalfedge_around_facet_const_circulator c1(i), c2(c1); + std::list contour; + CGAL_For_all( c1, c2 ) { + CGAL_Nef_polyhedron3::Point_3 point3d = c1->source()->source()->point(); + CGAL_Nef_polyhedron2::Point point2d( point3d.x(), point3d.y() ); + contour.push_back( point2d ); + } + tmpnef2d.reset( new CGAL_Nef_polyhedron2( contour.begin(), contour.end(), boundary ) ); + out << "\n\n"; + out << dump_cgal_nef_polyhedron2_svg( *tmpnef2d ); + if ( contour_counter == 0 ) { + out << "\n \n" ; + *(output_nefpoly2d) += *(tmpnef2d); + } else { + out << "\n \n"; + *(output_nefpoly2d) *= *(tmpnef2d); + } + out << "\n\n"; + out << dump_cgal_nef_polyhedron2_svg( *output_nefpoly2d ); + contour_counter++; + } // next facet cycle (i.e. next contour) + } // visit() +}; + + + PolySetCGALEvaluator::PolySetCGALEvaluator(CGALEvaluator &cgalevaluator) : PolySetEvaluator(cgalevaluator.getTree()), cgalevaluator(cgalevaluator) { @@ -115,7 +172,7 @@ PolySet *PolySetCGALEvaluator::evaluatePolySet(const ProjectionNode &node) } } - // std::cout << "----- input dump \n" << sum.dump_svg() << "\n"; + // std::cout << sum.dump_svg() << std::flush; // input dump CGAL_Nef_polyhedron nef_poly; @@ -160,8 +217,9 @@ PolySet *PolySetCGALEvaluator::evaluatePolySet(const ProjectionNode &node) } // remove z coordinates to make CGAL_Nef_polyhedron2 + std::cout << ""; try { - Flattener flattener(true); + Flattener2 flattener(true); CGAL_Nef_polyhedron3::Volume_const_iterator i; CGAL_Nef_polyhedron3::Shell_entry_const_iterator j; CGAL_Nef_polyhedron3::SFace_const_handle sface_handle; @@ -171,8 +229,10 @@ PolySet *PolySetCGALEvaluator::evaluatePolySet(const ProjectionNode &node) sum.p3->visit_shell_objects( sface_handle , flattener ); } } + std::cout << flattener.out.str(); + std::cout << "" << std::flush; - std::cout << "------- flattener dump \n" << flattener.dump() << "\n"; + //std::cout << "------- flattener dump \n" << flattener.dump() << "\n"; nef_poly.p2 = flattener.output_nefpoly2d; nef_poly.dim = 2; } catch (const CGAL::Failure_exception &e) { @@ -181,8 +241,10 @@ PolySet *PolySetCGALEvaluator::evaluatePolySet(const ProjectionNode &node) CGAL::set_error_behaviour(old_behaviour); - std::cout << "------- 3d cut dump \n" << sum.dump_svg() << "\n"; - std::cout << "------- 2d output dump \n" << nef_poly.dump_svg() << "\n"; + //std::cout << sum.dump_svg() << std::flush; // cut dump + //std::cout << nef_poly.dump_svg() << std::flush; // post-flattener dump + + //std::cout << "------- 2d output dump \n" << nef_poly.dump_svg() << "\n"; // Extract polygons in the XY plane, ignoring all other polygons // FIXME: If the polyhedron is really thin, there might be unwanted polygons // in the XY plane, causing the resulting 2D polygon to be self-intersection diff --git a/src/cgal.h b/src/cgal.h index 2ca82d3..e5e39dd 100644 --- a/src/cgal.h +++ b/src/cgal.h @@ -54,8 +54,6 @@ typedef CGAL::Polyhedron_3 CGAL_Polyhedron; typedef CGAL_Polyhedron::HalfedgeDS CGAL_HDS; typedef CGAL::Polyhedron_incremental_builder_3 CGAL_Polybuilder; -typedef CGAL::Cartesian::Iso_cuboid_3 CGAL_Iso_cuboid_3; - #ifdef PREV_NDEBUG #define NDEBUG PREV_NDEBUG #endif diff --git a/src/cgalutils.cc b/src/cgalutils.cc index b3a9407..10c5bbc 100644 --- a/src/cgalutils.cc +++ b/src/cgalutils.cc @@ -6,8 +6,12 @@ #include "cgal.h" #include typedef CGAL::Point_3 CGAL_Point_3; -typedef CGAL::Point_2 > CGAL_Point_2; -typedef CGAL::Simple_cartesian::Iso_rectangle_2 CGAL_Iso_rectangle_2; +typedef CGAL_Kernel3::Iso_cuboid_3 CGAL_Iso_cuboid_3; + +typedef CGAL_Nef_polyhedron2::Explorer::Point CGAL_Point_2; +// Note- Explorer::Point is incompatible with CGAL::Point_2 +typedef CGAL_Kernel2::Iso_rectangle_2 CGAL_Iso_rectangle_2; + #include #include @@ -150,10 +154,9 @@ CGAL_Polyhedron *createPolyhedronFromPolySet(const PolySet &ps) - CGAL_Point_2 project_svg_3to2( CGAL_Point_3 p, CGAL_Iso_cuboid_3 bbox ) { - // do extremely simple fake isometric projection, based on bounding box + // do simple fake isometric projection, based on bounding box double x = CGAL::to_double( p.x() ); double y = CGAL::to_double( p.y() ); double z = CGAL::to_double( p.z() ); @@ -161,12 +164,12 @@ CGAL_Point_2 project_svg_3to2( CGAL_Point_3 p, CGAL_Iso_cuboid_3 bbox ) double screenh = 480; double xcenter = screenw / 2; double ycenter = screenh / 2; - double xdist = ( 2 * CGAL::to_double( bbox.xmax() - bbox.xmin() ) ); - double ydist = ( 2 * CGAL::to_double( bbox.ymax() - bbox.ymin() ) ); - double zdist = ( 2 * CGAL::to_double( bbox.zmax() - bbox.zmin() ) ); - double xscale = (xdist==0) ? 1 : screenw / (xdist * 1.618); - double yscale = (ydist==0) ? 1 : screenh / (ydist * 1.618 * 3); - double zscale = (zdist==0) ? 1 : screenh / (zdist * 1.618); + double xdist = ( CGAL::to_double( bbox.xmax() - bbox.xmin() ) ); + double ydist = ( CGAL::to_double( bbox.ymax() - bbox.ymin() ) ); + double zdist = ( CGAL::to_double( bbox.zmax() - bbox.zmin() ) ); + double xscale = (xdist==0) ? 1 : screenw / (xdist * 2 * 1.618); + double yscale = (ydist==0) ? 1 : screenh / (ydist * 2 * 1.618 * 3); + double zscale = (zdist==0) ? 1 : screenh / (zdist * 2 * 1.618); double tx = xcenter + x * xscale + y * yscale; double ty = ycenter - z * zscale - y * yscale; return CGAL_Point_2( tx, ty ); @@ -174,29 +177,41 @@ CGAL_Point_2 project_svg_3to2( CGAL_Point_3 p, CGAL_Iso_cuboid_3 bbox ) CGAL_Point_2 project_svg_2to2( CGAL_Point_2 p, CGAL_Iso_rectangle_2 bbox ) { - CGAL_Point_3 origin( 0, 0, 0 ); + // pass thru 3d projection by making 'y' into 'z'. +/* CGAL_Point_3 origin( 0, 0, 0 ); CGAL_Iso_cuboid_3 bbox3d( bbox.xmin(), bbox.ymin(), origin.z(), bbox.xmax(), bbox.ymax(), origin.z() ); CGAL_Point_3 point3d( p.x(), origin.z() , p.y() ); - return project_svg_3to2( point3d, bbox3d ); + return project_svg_3to2( point3d, bbox3d );*/ + double x = CGAL::to_double( p.x() ); + double y = CGAL::to_double( p.y() ); + double screenw = 480; + double screenh = 480; + double borderw = screenw * 0.1618; + double borderh = screenh * 0.1618; + double vizw = screenw - borderw*2; + double vizh = screenh - borderh*2; + double bboxw = 0 ; CGAL::to_double( bbox.xmax() - bbox.xmin() ); + double bboxh = 0 ; CGAL::to_double( bbox.ymax() - bbox.ymin() ); + double xinbox = CGAL::to_double( p.x() ) - CGAL::to_double( bbox.xmin() ); + double yinbox = CGAL::to_double( p.y() ) - CGAL::to_double( bbox.ymin() ); + double tx = borderw + ( xinbox / bboxw ) * ( vizw ); + double ty = borderh + ( yinbox / bboxh ) * ( vizh ); + std::cout << "\nx, y " << x << "," << y << "\n"; + std::cout << "xinb, yinb " << xinbox << "," << yinbox << "\n"; + std::cout << "vizw, vizh " << vizw << "," << vizh << "\n"; + std::cout << "tx, ty " << tx << "," << ty << "\n"; + return CGAL_Point_2( tx, ty ); } // for debugging, not necessarily pretty or useful for users. std::string dump_cgal_nef_polyhedron2_face_svg( CGAL_Nef_polyhedron2::Explorer::Halfedge_around_face_const_circulator c1, CGAL_Nef_polyhedron2::Explorer::Halfedge_around_face_const_circulator c2, - CGAL_Nef_polyhedron2::Explorer explorer ) + CGAL_Nef_polyhedron2::Explorer explorer, + CGAL_Iso_rectangle_2 &bbox, + std::string color ) { - std::vector points; - CGAL_For_all(c1, c2) - if ( explorer.is_standard( explorer.source( c1 ) ) ) { - points.push_back( explorer.point( explorer.source( c1 ) ) ); - std::cout << points.size() << " point size\n"; - } - CGAL_Iso_rectangle_2 bbox( 0,0,0,0 ); - if ( points.size() > 0 ) - bbox = CGAL::bounding_box( points.begin(), points.end() ); - std::stringstream out; CGAL_For_all(c1, c2) { if ( explorer.is_standard( explorer.target(c1) ) ) { @@ -204,38 +219,59 @@ std::string dump_cgal_nef_polyhedron2_face_svg( CGAL_Point_2 target = explorer.point( explorer.target( c1 ) ); CGAL_Point_2 tp1 = project_svg_2to2( source, bbox ); CGAL_Point_2 tp2 = project_svg_2to2( target, bbox ); - out << " \n"; + << " stroke='" << color << "' />\n"; + // crude "arrowhead" to indicate directionality + out << " \n"; + } } return out.str(); } +static int svgcounter=0; + std::string dump_cgal_nef_polyhedron2_svg( const CGAL_Nef_polyhedron2 &N ) { std::stringstream out; CGAL_Nef_polyhedron2::Explorer explorer = N.explorer(); + CGAL_Iso_rectangle_2 bbox = CGAL::bounding_box ( explorer.points_begin(), explorer.points_end() ); + + out << " \n"; + CGAL_Nef_polyhedron2::Explorer::Face_const_iterator i; - out << "\n"; - out << "\n"; - out << ""; + out << " \n"; + out << " \n"; + out << " \n"; + svgcounter+=480; + if ((svgcounter/480)%2==0) svgcounter += 24; for ( i = explorer.faces_begin(); i!= explorer.faces_end(); ++i ) { + out << " \n"; CGAL_Nef_polyhedron2::Explorer::Halfedge_around_face_const_circulator c1 = explorer.face_cycle( i ), c2 ( c1 ); - out << dump_cgal_nef_polyhedron2_face_svg( c1, c2, explorer ); + out << dump_cgal_nef_polyhedron2_face_svg( c1, c2, explorer, bbox, "red" ); + out << " \n"; -/* - holes not implemented CGAL_Nef_polyhedron2::Explorer::Hole_const_iterator j; for ( j = explorer.holes_begin( i ); j!= explorer.holes_end( i ); ++j ) { + out << " \n"; CGAL_Nef_polyhedron2::Explorer::Halfedge_around_face_const_circulator c3( j ), c4 ( c3 ); - out << dump_cgal_nef_polyhedron2_face_svg( c3, c4, explorer ); + out << dump_cgal_nef_polyhedron2_face_svg( c3, c4, explorer, bbox, "green" ); + out << " \n"; } -*/ } out << ""; std::string tmp = out.str(); @@ -302,7 +338,7 @@ class NefPoly3_dumper_svg { public: std::stringstream out; CGAL_Iso_cuboid_3 bbox; - NefPoly3_dumper_svg(const CGAL_Nef_polyhedron3& N) {} + NefPoly3_dumper_svg(const CGAL_Nef_polyhedron3& N) { } void setbbox( CGAL_Iso_cuboid_3 bbox ) { this->bbox = bbox; } void visit(CGAL_Nef_polyhedron3::Vertex_const_handle v) {} void visit(CGAL_Nef_polyhedron3::Halfedge_const_handle ) {} @@ -349,7 +385,7 @@ std::string dump_cgal_nef_polyhedron3_svg( const CGAL_Nef_polyhedron3 &N ) std::stringstream out; out << "\n"; out << "\n"; - out << ""; + out << "\n"; out << "\n"; std::vector points; -- cgit v0.10.1 From 30fad0d4e44017c715cd81b807bc14598418e8a5 Mon Sep 17 00:00:00 2001 From: don bright Date: Sun, 21 Oct 2012 12:10:06 -0500 Subject: remove old dump code. improve debugging svg output. diff --git a/src/CGAL_Nef_polyhedron.cc b/src/CGAL_Nef_polyhedron.cc index 56232a3..ad2e4e2 100644 --- a/src/CGAL_Nef_polyhedron.cc +++ b/src/CGAL_Nef_polyhedron.cc @@ -84,7 +84,8 @@ int CGAL_Nef_polyhedron::weight() const */ PolySet *CGAL_Nef_polyhedron::convertToPolyset() { - assert(!this->empty()); + if (this->empty()) + return new PolySet(); PolySet *ps = NULL; if (this->dim == 2) { ps = new PolySet(); diff --git a/src/CGAL_Nef_polyhedron.h b/src/CGAL_Nef_polyhedron.h index 3157ff2..e8c505b 100644 --- a/src/CGAL_Nef_polyhedron.h +++ b/src/CGAL_Nef_polyhedron.h @@ -20,7 +20,6 @@ public: CGAL_Nef_polyhedron &operator-=(const CGAL_Nef_polyhedron &other); CGAL_Nef_polyhedron &minkowski(const CGAL_Nef_polyhedron &other); CGAL_Nef_polyhedron copy() const; - std::string dump_svg() const; std::string dump() const; int weight() const; class PolySet *convertToPolyset(); diff --git a/src/CGAL_Nef_polyhedron_DxfData.cc b/src/CGAL_Nef_polyhedron_DxfData.cc index 922a7ec..26b9353 100644 --- a/src/CGAL_Nef_polyhedron_DxfData.cc +++ b/src/CGAL_Nef_polyhedron_DxfData.cc @@ -81,21 +81,11 @@ DxfData *CGAL_Nef_polyhedron::convertToDxfData() const std::string CGAL_Nef_polyhedron::dump() const { if (this->dim==2) - return dump_cgal_nef_polyhedron2( *this->p2 ); - else if (this->dim==3) - return dump_cgal_nef_polyhedron3( *this->p3 ); - else - return std::string("Nef Polyhedron with dimension != 2 or 3"); -} - -std::string CGAL_Nef_polyhedron::dump_svg() const -{ - if (this->dim==2) return dump_cgal_nef_polyhedron2_svg( *this->p2 ); else if (this->dim==3) return dump_cgal_nef_polyhedron3_svg( *this->p3 ); else - return std::string(""); + return std::string("Nef Polyhedron with dimension != 2 or 3"); } #endif // ENABLE_CGAL diff --git a/src/PolySetCGALEvaluator.cc b/src/PolySetCGALEvaluator.cc index 2a002be..11f19c1 100644 --- a/src/PolySetCGALEvaluator.cc +++ b/src/PolySetCGALEvaluator.cc @@ -34,7 +34,7 @@ OGL_helper.h */ class Flattener { public: - std::stringstream out; + std::ostringstream out; CGAL_Nef_polyhedron2::Boundary boundary; shared_ptr tmpnef2d; shared_ptr output_nefpoly2d; @@ -57,8 +57,12 @@ public: void visit( CGAL_Nef_polyhedron3::SHalfloop_const_handle ) {} void visit( CGAL_Nef_polyhedron3::SFace_const_handle ) {} void visit( CGAL_Nef_polyhedron3::Halffacet_const_handle hfacet ) { + out << " \n"; + out << " \n"; if ( hfacet->plane().orthogonal_direction() != this->up ) { out << "\ndown facing half-facet. skipping\n"; + out << " \n"; + std::cout << out.str(); return; } @@ -86,66 +90,12 @@ public: out << dump_cgal_nef_polyhedron2_svg( *output_nefpoly2d ); contour_counter++; } // next facet cycle (i.e. next contour) + out << " \n"; + std::cout << out.str(); } // visit() }; - - -class Flattener2 { -public: - std::stringstream out; - CGAL_Nef_polyhedron2::Boundary boundary; - shared_ptr tmpnef2d; - shared_ptr output_nefpoly2d; - CGAL::Direction_3 up; - bool debug; - Flattener2(bool debug=false) - { - output_nefpoly2d.reset( new CGAL_Nef_polyhedron2() ); - boundary = CGAL_Nef_polyhedron2::INCLUDED; - up = CGAL::Direction_3(0,0,1); - this->debug = debug; - } - std::string dump() - { - return out.str(); - } - void visit( CGAL_Nef_polyhedron3::Vertex_const_handle ) {} - void visit( CGAL_Nef_polyhedron3::Halfedge_const_handle ) {} - void visit( CGAL_Nef_polyhedron3::SHalfedge_const_handle ) {} - void visit( CGAL_Nef_polyhedron3::SHalfloop_const_handle ) {} - void visit( CGAL_Nef_polyhedron3::SFace_const_handle ) {} - void visit( CGAL_Nef_polyhedron3::Halffacet_const_handle hfacet ) { - int contour_counter = 0; - CGAL_Nef_polyhedron3::Halffacet_cycle_const_iterator i; - CGAL_forall_facet_cycles_of( i, hfacet ) { - CGAL_Nef_polyhedron3::SHalfedge_around_facet_const_circulator c1(i), c2(c1); - std::list contour; - CGAL_For_all( c1, c2 ) { - CGAL_Nef_polyhedron3::Point_3 point3d = c1->source()->source()->point(); - CGAL_Nef_polyhedron2::Point point2d( point3d.x(), point3d.y() ); - contour.push_back( point2d ); - } - tmpnef2d.reset( new CGAL_Nef_polyhedron2( contour.begin(), contour.end(), boundary ) ); - out << "\n\n"; - out << dump_cgal_nef_polyhedron2_svg( *tmpnef2d ); - if ( contour_counter == 0 ) { - out << "\n \n" ; - *(output_nefpoly2d) += *(tmpnef2d); - } else { - out << "\n \n"; - *(output_nefpoly2d) *= *(tmpnef2d); - } - out << "\n\n"; - out << dump_cgal_nef_polyhedron2_svg( *output_nefpoly2d ); - contour_counter++; - } // next facet cycle (i.e. next contour) - } // visit() -}; - - - PolySetCGALEvaluator::PolySetCGALEvaluator(CGALEvaluator &cgalevaluator) : PolySetEvaluator(cgalevaluator.getTree()), cgalevaluator(cgalevaluator) { @@ -210,7 +160,7 @@ PolySet *PolySetCGALEvaluator::evaluatePolySet(const ProjectionNode &node) } catch (const CGAL::Failure_exception &e) { PRINTB("CGAL error in projection node during bigbox intersection: %s", e.what()); - // fixme , can we just return empty polyset? + // can we just return empty polyset? CGAL::set_error_behaviour(old_behaviour); return NULL; } @@ -219,17 +169,21 @@ PolySet *PolySetCGALEvaluator::evaluatePolySet(const ProjectionNode &node) // remove z coordinates to make CGAL_Nef_polyhedron2 std::cout << ""; try { - Flattener2 flattener(true); + Flattener flattener(true); CGAL_Nef_polyhedron3::Volume_const_iterator i; CGAL_Nef_polyhedron3::Shell_entry_const_iterator j; CGAL_Nef_polyhedron3::SFace_const_handle sface_handle; for ( i = sum.p3->volumes_begin(); i != sum.p3->volumes_end(); ++i ) { + std::cout << "\n"; for ( j = i->shells_begin(); j != i->shells_end(); ++j ) { + std::cout << "\n"; sface_handle = CGAL_Nef_polyhedron3::SFace_const_handle( j ); sum.p3->visit_shell_objects( sface_handle , flattener ); + std::cout << "\n"; } + std::cout << "\n"; } - std::cout << flattener.out.str(); + //std::cout << flattener.out.str() << "\n"; std::cout << "" << std::flush; //std::cout << "------- flattener dump \n" << flattener.dump() << "\n"; diff --git a/src/cgalutils.cc b/src/cgalutils.cc index 10c5bbc..2932c9c 100644 --- a/src/cgalutils.cc +++ b/src/cgalutils.cc @@ -6,11 +6,11 @@ #include "cgal.h" #include typedef CGAL::Point_3 CGAL_Point_3; -typedef CGAL_Kernel3::Iso_cuboid_3 CGAL_Iso_cuboid_3; +typedef CGAL::Iso_cuboid_3 CGAL_Iso_cuboid_3; typedef CGAL_Nef_polyhedron2::Explorer::Point CGAL_Point_2; -// Note- Explorer::Point is incompatible with CGAL::Point_2 -typedef CGAL_Kernel2::Iso_rectangle_2 CGAL_Iso_rectangle_2; +// Iso_rectangle is different- CGAL_Kernel2::Point != CGAL_Nef2::Explorer::Point +typedef CGAL::Iso_rectangle_2< CGAL::Simple_cartesian > CGAL_Iso_rectangle_2; #include #include @@ -153,36 +153,87 @@ CGAL_Polyhedron *createPolyhedronFromPolySet(const PolySet &ps) } +std::string svg_header() +{ + std::stringstream out; + out << ""; + return out.str(); +} + +std::string svg_border() +{ + std::stringstream out; + out << " \n"; + out << " \n"; + out << " "; + return out.str(); +} + +std::string svg_axes() +{ + std::stringstream out; + out << " \n"; + out << " \n"; + out << " "; + return out.str(); +} + +CGAL_Iso_cuboid_3 bounding_box( const CGAL_Nef_polyhedron3 &N ) +{ + CGAL_Iso_cuboid_3 result(-1,-1,-1,1,1,1); + CGAL_Nef_polyhedron3::Vertex_const_iterator vi; + std::vector points; + CGAL_forall_vertices( vi, N ) + points.push_back( vi->point() ); + if (points.size()) + result = CGAL::bounding_box( points.begin(), points.end() ); + return result; +} + +CGAL_Iso_rectangle_2 bounding_box( const CGAL_Nef_polyhedron2 &N ) +{ + CGAL_Iso_rectangle_2 result(-1,-1,1,1); + CGAL_Nef_polyhedron2::Explorer explorer = N.explorer(); + CGAL_Nef_polyhedron2::Explorer::Vertex_const_iterator vi; + std::vector points; + for ( vi = explorer.vertices_begin(); vi != explorer.vertices_end(); ++vi ) + if ( explorer.is_standard( vi ) ) + points.push_back( explorer.point( vi ) ); + if (points.size()) + result = CGAL::bounding_box( points.begin(), points.end() ); + return result; +} CGAL_Point_2 project_svg_3to2( CGAL_Point_3 p, CGAL_Iso_cuboid_3 bbox ) { - // do simple fake isometric projection, based on bounding box + // do simple fake isometric projection double x = CGAL::to_double( p.x() ); double y = CGAL::to_double( p.y() ); double z = CGAL::to_double( p.z() ); double screenw = 480; double screenh = 480; - double xcenter = screenw / 2; - double ycenter = screenh / 2; - double xdist = ( CGAL::to_double( bbox.xmax() - bbox.xmin() ) ); - double ydist = ( CGAL::to_double( bbox.ymax() - bbox.ymin() ) ); - double zdist = ( CGAL::to_double( bbox.zmax() - bbox.zmin() ) ); - double xscale = (xdist==0) ? 1 : screenw / (xdist * 2 * 1.618); - double yscale = (ydist==0) ? 1 : screenh / (ydist * 2 * 1.618 * 3); - double zscale = (zdist==0) ? 1 : screenh / (zdist * 2 * 1.618); - double tx = xcenter + x * xscale + y * yscale; - double ty = ycenter - z * zscale - y * yscale; + double borderw = screenw * 0.1618; + double borderh = screenh * 0.1618; + double vizw = screenw - borderw*2; + double vizh = screenh - borderh*2; + double bboxx = CGAL::to_double( bbox.xmax() - bbox.xmin() ); + double bboxy = CGAL::to_double( bbox.ymax() - bbox.ymin() ); + double bboxz = CGAL::to_double( bbox.zmax() - bbox.zmin() ); + double xinbox = CGAL::to_double( p.x() ) - CGAL::to_double( bbox.xmin() ); + double yinbox = CGAL::to_double( p.y() ) - CGAL::to_double( bbox.ymin() ); + double zinbox = CGAL::to_double( p.z() ) - CGAL::to_double( bbox.zmin() ); + double tx = borderw + ( xinbox / ( bboxx==0?1:bboxx ) ) * ( vizw ); + double ty = screenh - borderh - ( zinbox / ( bboxz==0?1:bboxz ) ) * ( vizh ); + tx += ( yinbox / ( bboxy==0?1:bboxy ) ) / 3; + ty -= ( yinbox / ( bboxy==0?1:bboxy ) ) / 3; return CGAL_Point_2( tx, ty ); } CGAL_Point_2 project_svg_2to2( CGAL_Point_2 p, CGAL_Iso_rectangle_2 bbox ) { - // pass thru 3d projection by making 'y' into 'z'. -/* CGAL_Point_3 origin( 0, 0, 0 ); - CGAL_Iso_cuboid_3 bbox3d( bbox.xmin(), bbox.ymin(), origin.z(), - bbox.xmax(), bbox.ymax(), origin.z() ); - CGAL_Point_3 point3d( p.x(), origin.z() , p.y() ); - return project_svg_3to2( point3d, bbox3d );*/ double x = CGAL::to_double( p.x() ); double y = CGAL::to_double( p.y() ); double screenw = 480; @@ -191,16 +242,18 @@ CGAL_Point_2 project_svg_2to2( CGAL_Point_2 p, CGAL_Iso_rectangle_2 bbox ) double borderh = screenh * 0.1618; double vizw = screenw - borderw*2; double vizh = screenh - borderh*2; - double bboxw = 0 ; CGAL::to_double( bbox.xmax() - bbox.xmin() ); - double bboxh = 0 ; CGAL::to_double( bbox.ymax() - bbox.ymin() ); + double bboxw = CGAL::to_double( bbox.xmax() - bbox.xmin() ); + double bboxh = CGAL::to_double( bbox.ymax() - bbox.ymin() ); double xinbox = CGAL::to_double( p.x() ) - CGAL::to_double( bbox.xmin() ); double yinbox = CGAL::to_double( p.y() ) - CGAL::to_double( bbox.ymin() ); - double tx = borderw + ( xinbox / bboxw ) * ( vizw ); - double ty = borderh + ( yinbox / bboxh ) * ( vizh ); - std::cout << "\nx, y " << x << "," << y << "\n"; + double tx = borderw + ( xinbox / ( bboxw==0?1:bboxw ) ) * ( vizw ); + double ty = screenh - borderh - ( yinbox / ( bboxh==0?1:bboxh ) ) * ( vizh ); +/* std::cout << "\nx, y " << x << "," << y << "\n"; + std::cout << "bbw, bbh " << bboxw << "," << bboxh << "\n"; std::cout << "xinb, yinb " << xinbox << "," << yinbox << "\n"; std::cout << "vizw, vizh " << vizw << "," << vizh << "\n"; std::cout << "tx, ty " << tx << "," << ty << "\n"; +*/ return CGAL_Point_2( tx, ty ); } @@ -209,8 +262,8 @@ std::string dump_cgal_nef_polyhedron2_face_svg( CGAL_Nef_polyhedron2::Explorer::Halfedge_around_face_const_circulator c1, CGAL_Nef_polyhedron2::Explorer::Halfedge_around_face_const_circulator c2, CGAL_Nef_polyhedron2::Explorer explorer, - CGAL_Iso_rectangle_2 &bbox, - std::string color ) + std::string color, + CGAL_Iso_rectangle_2 bbox ) { std::stringstream out; CGAL_For_all(c1, c2) { @@ -231,47 +284,37 @@ std::string dump_cgal_nef_polyhedron2_face_svg( << " cy='" << CGAL::to_double(tp1.y()+ (tp2.y()-tp1.y())* 7/8) << "'" << " r='2'" << " fill='" << color << "' stroke='" << color << "' />\n"; - } } return out.str(); } -static int svgcounter=0; - std::string dump_cgal_nef_polyhedron2_svg( const CGAL_Nef_polyhedron2 &N ) { std::stringstream out; CGAL_Nef_polyhedron2::Explorer explorer = N.explorer(); - CGAL_Iso_rectangle_2 bbox = CGAL::bounding_box ( explorer.points_begin(), explorer.points_end() ); - out << " \n"; + CGAL_Iso_rectangle_2 bbox = bounding_box( N ); CGAL_Nef_polyhedron2::Explorer::Face_const_iterator i; - out << " \n"; - out << " \n"; - out << " \n"; - svgcounter+=480; - if ((svgcounter/480)%2==0) svgcounter += 24; + out << " \n"; + out << svg_border() << "\n" << svg_axes() << "\n"; + svg_counter+=480; + if ((svg_counter/480)%2==0) svg_counter += 24; for ( i = explorer.faces_begin(); i!= explorer.faces_end(); ++i ) { - out << " \n"; + out << " \n"; CGAL_Nef_polyhedron2::Explorer::Halfedge_around_face_const_circulator c1 = explorer.face_cycle( i ), c2 ( c1 ); - out << dump_cgal_nef_polyhedron2_face_svg( c1, c2, explorer, bbox, "red" ); - out << " \n"; + out << dump_cgal_nef_polyhedron2_face_svg( c1, c2, explorer, "red", bbox ); CGAL_Nef_polyhedron2::Explorer::Hole_const_iterator j; for ( j = explorer.holes_begin( i ); j!= explorer.holes_end( i ); ++j ) { - out << " \n"; + out << " \n"; CGAL_Nef_polyhedron2::Explorer::Halfedge_around_face_const_circulator c3( j ), c4 ( c3 ); - out << dump_cgal_nef_polyhedron2_face_svg( c3, c4, explorer, bbox, "green" ); - out << " \n"; + out << dump_cgal_nef_polyhedron2_face_svg( c3, c4, explorer, "green", bbox ); + out << " \n"; } + out << " \n"; } out << ""; std::string tmp = out.str(); @@ -280,66 +323,16 @@ std::string dump_cgal_nef_polyhedron2_svg( const CGAL_Nef_polyhedron2 &N ) } -std::string dump_cgal_nef_polyhedron2_face( - CGAL_Nef_polyhedron2::Explorer::Halfedge_around_face_const_circulator c1, - CGAL_Nef_polyhedron2::Explorer::Halfedge_around_face_const_circulator c2, - CGAL_Nef_polyhedron2::Explorer explorer ) -{ - std::stringstream out; - CGAL_For_all(c1, c2) { - out << " On frame edge:" << explorer.is_frame_edge( c1 ); - out << " Mark: " << explorer.mark( c1 ); - if ( explorer.is_standard( explorer.target(c1) ) ) { - CGAL_Nef_polyhedron2::Explorer::Point source = explorer.point( explorer.source( c1 ) ); - CGAL_Nef_polyhedron2::Explorer::Point target = explorer.point( explorer.target( c1 ) ); - out << " Halfedge x y x2 y2: " - << CGAL::to_double(source.x()) << " " - << CGAL::to_double(source.y()) << " " - << CGAL::to_double(target.x()) << " " - << CGAL::to_double(target.y()) << "\n"; - } else { - CGAL_Nef_polyhedron2::Explorer::Ray ray = explorer.ray( explorer.target( c1 ) ); - out << " Ray x y dx dy: " - << CGAL::to_double(ray.point(0).x()) << " " - << CGAL::to_double(ray.point(0).y()) << " " - << CGAL::to_double(ray.point(1).x()) << " " - << CGAL::to_double(ray.point(1).y()) << "\n"; - } - } - return out.str(); -} - -std::string dump_cgal_nef_polyhedron2( const CGAL_Nef_polyhedron2 &N ) -{ - std::stringstream out; - CGAL_Nef_polyhedron2::Explorer explorer = N.explorer(); - CGAL_Nef_polyhedron2::Explorer::Face_const_iterator i; - out << "CGAL_Nef_polyhedron2 dump begin\n"; - for ( i = explorer.faces_begin(); i!= explorer.faces_end(); ++i ) { - out << " Face body:\n"; - CGAL_Nef_polyhedron2::Explorer::Halfedge_around_face_const_circulator c1 - = explorer.face_cycle( i ), c2 ( c1 ); - out << dump_cgal_nef_polyhedron2_face( c1, c2, explorer ); - - CGAL_Nef_polyhedron2::Explorer::Hole_const_iterator j; - for ( j = explorer.holes_begin( i ); j!= explorer.holes_end( i ); ++j ) { - out << " Face hole:\n"; - CGAL_Nef_polyhedron2::Explorer::Halfedge_around_face_const_circulator c3( j ), c4 ( c3 ); - out << dump_cgal_nef_polyhedron2_face( c3, c4, explorer ); - } - } - out << "CGAL_Nef_polyhedron2 dump end"; - return out.str(); -} - // This uses the Shell Explorer pattern from the CGAL Manual to dump the 3d Nef Polyhedron information // http://www.cgal.org/Manual/latest/doc_html/cgal_manual/Nef_3/Chapter_main.html#Subsection_29.7.2 class NefPoly3_dumper_svg { public: std::stringstream out; CGAL_Iso_cuboid_3 bbox; - NefPoly3_dumper_svg(const CGAL_Nef_polyhedron3& N) { } - void setbbox( CGAL_Iso_cuboid_3 bbox ) { this->bbox = bbox; } + NefPoly3_dumper_svg(const CGAL_Nef_polyhedron3& N) + { + bbox = bounding_box( N ); + } void visit(CGAL_Nef_polyhedron3::Vertex_const_handle v) {} void visit(CGAL_Nef_polyhedron3::Halfedge_const_handle ) {} void visit(CGAL_Nef_polyhedron3::SHalfedge_const_handle ) {} @@ -383,17 +376,9 @@ public: std::string dump_cgal_nef_polyhedron3_svg( const CGAL_Nef_polyhedron3 &N ) { std::stringstream out; - out << "\n"; - out << "\n"; - out << "\n"; + out << svg_header << "\n" << svg_border() << "\n" << svg_axes() << "\n"; out << "\n"; - std::vector points; - CGAL_Nef_polyhedron3::Vertex_const_iterator vi; - for (vi = N.vertices_begin(); vi!=N.vertices_end(); ++vi) - points.push_back( vi->point() ); - CGAL_Iso_cuboid_3 bbox = CGAL::bounding_box( points.begin(), points.end() ); - CGAL_Nef_polyhedron3::Volume_const_iterator c; CGAL_forall_volumes(c,N) { out << " \n"; @@ -402,7 +387,6 @@ std::string dump_cgal_nef_polyhedron3_svg( const CGAL_Nef_polyhedron3 &N ) CGAL_forall_shells_of(it,c) { out << " \n"; NefPoly3_dumper_svg dumper_svg(N); - dumper_svg.setbbox( bbox ); N.visit_shell_objects(CGAL_Nef_polyhedron3::SFace_const_handle(it), dumper_svg ); out << dumper_svg.out.str(); out << " \n"; @@ -416,77 +400,6 @@ std::string dump_cgal_nef_polyhedron3_svg( const CGAL_Nef_polyhedron3 &N ) return tmp; } -// This uses the Shell Explorer pattern from the CGAL Manual to dump the 3d Nef Polyhedron information -// http://www.cgal.org/Manual/latest/doc_html/cgal_manual/Nef_3/Chapter_main.html#Subsection_29.7.2 -class NefPoly3_dumper { -public: - std::stringstream out; - NefPoly3_dumper(const CGAL_Nef_polyhedron3& N) {} - void visit(CGAL_Nef_polyhedron3::Vertex_const_handle v) {} - void visit(CGAL_Nef_polyhedron3::Halfedge_const_handle ) {} - void visit(CGAL_Nef_polyhedron3::SHalfedge_const_handle ) {} - void visit(CGAL_Nef_polyhedron3::SHalfloop_const_handle shh ) - { - out << " SHalfloop visit\n"; - out << " Mark: " << (*shh).mark() << "\n"; - } - void visit(CGAL_Nef_polyhedron3::SFace_const_handle ) {} - void visit( CGAL_Nef_polyhedron3::Halffacet_const_handle hfacet ) - { - int contour_count = 0; - out << " Halffacet visit\n"; - out << " Mark: " << (*hfacet).mark() << "\n"; - CGAL_Nef_polyhedron3::Halffacet_cycle_const_iterator i; - CGAL_forall_facet_cycles_of( i, hfacet ) { - CGAL_Nef_polyhedron3::SHalfloop_const_handle shl_handle; - out << " Halffacet cycle:\n"; - if ( contour_count == 0 ) { - out << " Body contour:\n"; - } else { - out << " Hole contour:\n" ; - } - CGAL_Nef_polyhedron3::SHalfedge_around_facet_const_circulator c1(i), c2(c1); - int count=0; - CGAL_For_all( c1, c2 ) { - out << " Halfedge vertex:"; - out << " Mark: " << (*c1).mark(); - count++; - CGAL_Point_3 point3d = c1->source()->source()->point(); - double x = CGAL::to_double( point3d.x() ); - double y = CGAL::to_double( point3d.y() ); - double z = CGAL::to_double( point3d.z() ); - out << " x:" << x << " y:" << y << " z:" << z <<"\n"; - } - out << " point count: " << count << "\n"; - contour_count++; - } // next facet cycle (i.e. next contour) - } // visit() - -}; - -std::string dump_cgal_nef_polyhedron3( const CGAL_Nef_polyhedron3 &N ) -{ - std::stringstream out; - out << "CGAL_Nef_polyhedron3 dump begin\n"; - CGAL_Nef_polyhedron3::Volume_const_iterator c; - CGAL_forall_volumes(c,N) { - out << " Processing volume...\n"; - out << " Mark: " << (*c).mark() << "\n"; - CGAL_Nef_polyhedron3::Shell_entry_const_iterator it; - CGAL_forall_shells_of(it,c) { - out << " Processing shell...\n"; - NefPoly3_dumper dumper(N); - N.visit_shell_objects(CGAL_Nef_polyhedron3::SFace_const_handle(it), dumper ); - out << dumper.out.str(); - out << " Processing shell end\n"; - } - out << " Processing volume end\n"; - } - out << "CGAL_Nef_polyhedron3 dump end\n"; - return out.str(); -} - - #endif /* ENABLE_CGAL */ diff --git a/src/cgalutils.h b/src/cgalutils.h index 2bf6566..3fb9360 100644 --- a/src/cgalutils.h +++ b/src/cgalutils.h @@ -9,5 +9,6 @@ std::string dump_cgal_nef_polyhedron2( const CGAL_Nef_polyhedron2 &N ); std::string dump_cgal_nef_polyhedron3( const CGAL_Nef_polyhedron3 &N ); std::string dump_cgal_nef_polyhedron2_svg( const CGAL_Nef_polyhedron2 &N ); std::string dump_cgal_nef_polyhedron3_svg( const CGAL_Nef_polyhedron3 &N ); +static int svg_counter = 0; #endif -- cgit v0.10.1 From ed27859e65b46a63a7dbd48227643b5e5b528f08 Mon Sep 17 00:00:00 2001 From: Marius Kintel Date: Tue, 21 Aug 2012 23:27:02 -0400 Subject: Now builds on clang-4.0 on Mac OS X Lion Conflicts: scripts/macosx-build-dependencies.sh diff --git a/scripts/macosx-build-dependencies.sh b/scripts/macosx-build-dependencies.sh index 73e4118..b7bd2bd 100755 --- a/scripts/macosx-build-dependencies.sh +++ b/scripts/macosx-build-dependencies.sh @@ -26,6 +26,9 @@ DEPLOYDIR=$BASEDIR/install MAC_OSX_VERSION_MIN=10.5 OPTION_32BIT=true OPTION_LLVM=false +OPTION_CLANG=false +OPTION_GCC=false +DETECTED_LION=false export QMAKESPEC=macx-g++ printUsage() @@ -187,6 +190,9 @@ build_boost() if $OPTION_LLVM; then BOOST_TOOLSET="toolset=darwin-llvm" echo "using darwin : llvm : llvm-g++ ;" >> tools/build/v2/user-config.jam + elif $OPTION_CLANG; then + BOOST_TOOLSET="toolset=clang" + echo "using clang ;" >> tools/build/v2/user-config.jam fi ./b2 -d+2 $BOOST_TOOLSET cflags="-mmacosx-version-min=$MAC_OSX_VERSION_MIN -arch x86_64 $BOOST_EXTRA_FLAGS" linkflags="-mmacosx-version-min=$MAC_OSX_VERSION_MIN -arch x86_64 $BOOST_EXTRA_FLAGS" install install_name_tool -id $DEPLOYDIR/lib/libboost_thread.dylib $DEPLOYDIR/lib/libboost_thread.dylib @@ -319,15 +325,46 @@ if [[ $OSVERSION -ge 7 ]]; then # Somehow, qmake in Qt-4.8.2 doesn't detect Lion's gcc and falls back into # project file mode unless manually given a QMAKESPEC export QMAKESPEC=macx-llvm + DETECTED_LION=true else echo "Detected Snow Leopard or earlier" fi +USING_LLVM=false +USING_GCC=false +USING_CLANG=false if $OPTION_LLVM; then echo "Using LLVM compiler" export CC=llvm-gcc export CXX=llvm-g++ export QMAKESPEC=macx-llvm + USING_LLCM=true +elif $OPTION_GCC; then + USING_GCC=true +elif $OPTION_CLANG; then + USING_CLANG=true +elif $DETECTED_LION; then + USING_GCC=true +fi + +if $USING_LLVM; then + echo "Using gcc LLVM compiler" + export CC=llvm-gcc + export CXX=llvm-g++ + export QMAKESPEC=macx-llvm +elif $USING_GCC; then + echo "Using gcc compiler" + export CC=gcc + export CXX=g++ + export CPP=cpp + # Somehow, qmake in Qt-4.8.2 doesn't detect Lion's gcc and falls back into + # project file mode unless manually given a QMAKESPEC + export QMAKESPEC=macx-llvm +elif $USING_CLANG; then + echo "Using clang compiler" + export CC=clang + export CXX=clang++ + export QMAKESPEC=unsupported/macx-clang fi echo "Using basedir:" $BASEDIR diff --git a/setenv_mac-clang.sh b/setenv_mac-clang.sh new file mode 100644 index 0000000..9a42dce --- /dev/null +++ b/setenv_mac-clang.sh @@ -0,0 +1,12 @@ +export OPENSCAD_LIBRARIES=$PWD/../libraries/install-clang +export DYLD_LIBRARY_PATH=$OPENSCAD_LIBRARIES/lib +export QMAKESPEC=unsupported/macx-clang + +#export OPENCSGDIR=$PWD/../OpenCSG-1.3.0 +#export CGALDIR=$PWD/../install/CGAL-3.6 +#export QCODEEDITDIR=$PWD/../qcodeedit-2.2.3/install +#export DYLD_LIBRARY_PATH=$OPENCSGDIR/lib:$QCODEEDITDIR/lib + +# ccache: +export PATH=/opt/local/libexec/ccache:$PATH +export CCACHE_BASEDIR=$PWD/.. -- cgit v0.10.1 From dadde5d754191cc0cc430d3079d8811147db4bc1 Mon Sep 17 00:00:00 2001 From: Marius Kintel Date: Mon, 22 Oct 2012 21:54:07 -0400 Subject: Minor clang updates Conflicts: scripts/macosx-build-dependencies.sh diff --git a/scripts/macosx-build-dependencies.sh b/scripts/macosx-build-dependencies.sh index b7bd2bd..f6b8161 100755 --- a/scripts/macosx-build-dependencies.sh +++ b/scripts/macosx-build-dependencies.sh @@ -212,8 +212,9 @@ build_cgal() cd $BASEDIR/src rm -rf CGAL-$version if [ ! -f CGAL-$version.tar.gz ]; then - # 4.0.2 - curl -O https://gforge.inria.fr/frs/download.php/31175/CGAL-$version.tar.gz + # 4.1-beta1 + curl -O https://gforge.inria.fr/frs/download.php/31348/CGAL-$version.tar.gz + # 4.0.2 curl -O https://gforge.inria.fr/frs/download.php/31175/CGAL-$version.tar.gz # 4.0 curl -O https://gforge.inria.fr/frs/download.php/30387/CGAL-$version.tar.gz # 3.9 curl -O https://gforge.inria.fr/frs/download.php/29125/CGAL-$version.tar.gz # 3.8 curl -O https://gforge.inria.fr/frs/download.php/28500/CGAL-$version.tar.gz @@ -372,8 +373,8 @@ mkdir -p $SRCDIR $DEPLOYDIR build_eigen 3.1.1 build_gmp 5.0.5 build_mpfr 3.1.1 -build_boost 1.50.0 +build_boost 1.51.0 # NB! For CGAL, also update the actual download URL in the function -build_cgal 4.0.2 +build_cgal 4.1-beta1 build_glew 1.9.0 build_opencsg 1.3.2 diff --git a/setenv_mac-clang.sh b/setenv_mac-clang.sh index 9a42dce..2bc9234 100644 --- a/setenv_mac-clang.sh +++ b/setenv_mac-clang.sh @@ -1,4 +1,4 @@ -export OPENSCAD_LIBRARIES=$PWD/../libraries/install-clang +export OPENSCAD_LIBRARIES=$PWD/../libraries/install export DYLD_LIBRARY_PATH=$OPENSCAD_LIBRARIES/lib export QMAKESPEC=unsupported/macx-clang -- cgit v0.10.1 From 85bc16fc9ffa69d5428d8322ba0cdc14f010aaaf Mon Sep 17 00:00:00 2001 From: Marius Kintel Date: Tue, 21 Aug 2012 21:12:53 -0400 Subject: Initial clang build support Conflicts: scripts/macosx-build-dependencies.sh diff --git a/scripts/macosx-build-dependencies.sh b/scripts/macosx-build-dependencies.sh index f6b8161..024020a 100755 --- a/scripts/macosx-build-dependencies.sh +++ b/scripts/macosx-build-dependencies.sh @@ -9,6 +9,7 @@ # Usage: macosx-build-dependencies.sh [-6l] # -6 Build only 64-bit binaries # -l Force use of LLVM compiler +# -c Force use of clang compiler # # Prerequisites: # - MacPorts: curl, cmake @@ -33,10 +34,11 @@ export QMAKESPEC=macx-g++ printUsage() { - echo "Usage: $0 [-6l]" + echo "Usage: $0 [-6lc]" echo echo " -6 Build only 64-bit binaries" echo " -l Force use of LLVM compiler" + echo " -c Force use of clang compiler" } # Hack warning: gmplib is built separately in 32-bit and 64-bit mode @@ -248,7 +250,7 @@ build_glew() if $OPTION_32BIT; then GLEW_EXTRA_FLAGS="-arch i386" fi - make GLEW_DEST=$DEPLOYDIR CFLAGS.EXTRA="-no-cpp-precomp -dynamic -fno-common -mmacosx-version-min=$MAC_OSX_VERSION_MIN $GLEW_EXTRA_FLAGS -arch x86_64" LDFLAGS.EXTRA="-mmacosx-version-min=$MAC_OSX_VERSION_MIN $GLEW_EXTRA_FLAGS -arch x86_64" STRIP= install + make GLEW_DEST=$DEPLOYDIR CC=$CC CFLAGS.EXTRA="-no-cpp-precomp -dynamic -fno-common -mmacosx-version-min=$MAC_OSX_VERSION_MIN $GLEW_EXTRA_FLAGS -arch x86_64" LDFLAGS.EXTRA="-mmacosx-version-min=$MAC_OSX_VERSION_MIN $GLEW_EXTRA_FLAGS -arch x86_64" STRIP= install } build_opencsg() @@ -308,24 +310,18 @@ if [ ! -f $OPENSCADDIR/openscad.pro ]; then exit 0 fi -while getopts '6l' c +while getopts '6lc' c do case $c in 6) OPTION_32BIT=false;; l) OPTION_LLVM=true;; + c) OPTION_CLANG=true;; esac done OSVERSION=`sw_vers -productVersion | cut -d. -f2` if [[ $OSVERSION -ge 7 ]]; then echo "Detected Lion or later" - export LION=1 - export CC=gcc - export CXX=g++ - export CPP=cpp - # Somehow, qmake in Qt-4.8.2 doesn't detect Lion's gcc and falls back into - # project file mode unless manually given a QMAKESPEC - export QMAKESPEC=macx-llvm DETECTED_LION=true else echo "Detected Snow Leopard or earlier" @@ -335,10 +331,6 @@ USING_LLVM=false USING_GCC=false USING_CLANG=false if $OPTION_LLVM; then - echo "Using LLVM compiler" - export CC=llvm-gcc - export CXX=llvm-g++ - export QMAKESPEC=macx-llvm USING_LLCM=true elif $OPTION_GCC; then USING_GCC=true -- cgit v0.10.1 From 5b92e171eae66a4be64cdd1b6ec114dbaf8e04e8 Mon Sep 17 00:00:00 2001 From: don bright Date: Mon, 22 Oct 2012 23:44:54 -0500 Subject: this svg-prints the 'marked' faces as dashed lines, revealing CGAL issues with mark() and union() operations on Nef Polyhedron 2 objects. diff --git a/src/PolySetCGALEvaluator.cc b/src/PolySetCGALEvaluator.cc index 11f19c1..78c4c5f 100644 --- a/src/PolySetCGALEvaluator.cc +++ b/src/PolySetCGALEvaluator.cc @@ -17,6 +17,7 @@ #include "openscad.h" // get_fragments_from_r() #include #include +#include typedef CGAL_Nef_polyhedron3::Point_3 Point_3; @@ -57,6 +58,7 @@ public: void visit( CGAL_Nef_polyhedron3::SHalfloop_const_handle ) {} void visit( CGAL_Nef_polyhedron3::SFace_const_handle ) {} void visit( CGAL_Nef_polyhedron3::Halffacet_const_handle hfacet ) { + out.str(""); out << " \n"; out << " \n"; if ( hfacet->plane().orthogonal_direction() != this->up ) { @@ -96,6 +98,96 @@ public: }; + +class Flattener2 { +public: + std::ostringstream out; + CGAL_Nef_polyhedron2::Boundary boundary; + shared_ptr tmpnef2d; + shared_ptr output_nefpoly2d; + CGAL::Direction_3 up; + bool debug; + Flattener2(bool debug=false) + { + output_nefpoly2d.reset( new CGAL_Nef_polyhedron2() ); + boundary = CGAL_Nef_polyhedron2::INCLUDED; + up = CGAL::Direction_3(0,0,1); + this->debug = debug; + } + std::string dump() + { + return out.str(); + } + void visit( CGAL_Nef_polyhedron3::Vertex_const_handle ) {} + void visit( CGAL_Nef_polyhedron3::Halfedge_const_handle ) {} + void visit( CGAL_Nef_polyhedron3::SHalfedge_const_handle ) {} + void visit( CGAL_Nef_polyhedron3::SHalfloop_const_handle ) {} + void visit( CGAL_Nef_polyhedron3::SFace_const_handle ) {} + void visit( CGAL_Nef_polyhedron3::Halffacet_const_handle hfacet ) { + out.str(""); + out << " \n"; + out << " \n"; + if ( hfacet->plane().orthogonal_direction() != this->up ) { + out << "\ndown facing half-facet. skipping\n"; + out << " \n"; + std::cout << out.str(); + return; + } + + bool skip=false; + CGAL_Nef_polyhedron3::Halffacet_cycle_const_iterator i; + CGAL_forall_facet_cycles_of( i, hfacet ) { + CGAL_Nef_polyhedron3::SHalfedge_around_facet_const_circulator c1(i), c2(c1); + CGAL_For_all( c1, c2 ) { + CGAL_Nef_polyhedron3::Point_3 point3d = c1->source()->source()->point(); + if (point3d.z()!=0) skip=true; + } + } + if (skip) { + out << "\n facet not on zero plane. skipping\n"; + out << " \n"; + std::cout << out.str(); + return; + } + + int contour_counter = 0; + CGAL_forall_facet_cycles_of( i, hfacet ) { + CGAL_Nef_polyhedron3::SHalfedge_around_facet_const_circulator c1(i), c2(c1); + std::vector contour; + CGAL_For_all( c1, c2 ) { + CGAL_Nef_polyhedron3::Point_3 point3d = c1->source()->source()->point(); + CGAL_Nef_polyhedron2::Explorer::Point point2d( point3d.x(), point3d.y() ); + contour.push_back( point2d ); + } + + tmpnef2d.reset( new CGAL_Nef_polyhedron2( contour.begin(), contour.end(), boundary ) ); + + out << "\n\n"; + out << dump_cgal_nef_polyhedron2_svg( *output_nefpoly2d ); + + if ( contour_counter == 0 ) { + out << "\n \n" ; + *(output_nefpoly2d) += *(tmpnef2d); + } else { + *(output_nefpoly2d) *= *(tmpnef2d); + if (debug) out << "\n\n"; + } + + out << "\n\n"; + out << dump_cgal_nef_polyhedron2_svg( *tmpnef2d ); + out << "\n\n"; + out << dump_cgal_nef_polyhedron2_svg( *output_nefpoly2d ); + + contour_counter++; + } // next facet cycle (i.e. next contour) + out << " \n"; + std::cout << out.str(); + } // visit() +}; + + + + PolySetCGALEvaluator::PolySetCGALEvaluator(CGALEvaluator &cgalevaluator) : PolySetEvaluator(cgalevaluator.getTree()), cgalevaluator(cgalevaluator) { @@ -169,7 +261,7 @@ PolySet *PolySetCGALEvaluator::evaluatePolySet(const ProjectionNode &node) // remove z coordinates to make CGAL_Nef_polyhedron2 std::cout << ""; try { - Flattener flattener(true); + Flattener2 flattener(true); CGAL_Nef_polyhedron3::Volume_const_iterator i; CGAL_Nef_polyhedron3::Shell_entry_const_iterator j; CGAL_Nef_polyhedron3::SFace_const_handle sface_handle; @@ -177,8 +269,10 @@ PolySet *PolySetCGALEvaluator::evaluatePolySet(const ProjectionNode &node) std::cout << "\n"; for ( j = i->shells_begin(); j != i->shells_end(); ++j ) { std::cout << "\n"; - sface_handle = CGAL_Nef_polyhedron3::SFace_const_handle( j ); - sum.p3->visit_shell_objects( sface_handle , flattener ); +// if (i->mark()==1) { + sface_handle = CGAL_Nef_polyhedron3::SFace_const_handle( j ); + sum.p3->visit_shell_objects( sface_handle , flattener ); +// } std::cout << "\n"; } std::cout << "\n"; diff --git a/src/cgalutils.cc b/src/cgalutils.cc index 2932c9c..347fdd5 100644 --- a/src/cgalutils.cc +++ b/src/cgalutils.cc @@ -161,6 +161,12 @@ std::string svg_header() return out.str(); } +std::string svg_label(std::string s) +{ + std::stringstream out; + out << "" << s << ""; + return out.str(); +} std::string svg_border() { std::stringstream out; @@ -263,6 +269,7 @@ std::string dump_cgal_nef_polyhedron2_face_svg( CGAL_Nef_polyhedron2::Explorer::Halfedge_around_face_const_circulator c2, CGAL_Nef_polyhedron2::Explorer explorer, std::string color, + bool mark, CGAL_Iso_rectangle_2 bbox ) { std::stringstream out; @@ -272,16 +279,21 @@ std::string dump_cgal_nef_polyhedron2_face_svg( CGAL_Point_2 target = explorer.point( explorer.target( c1 ) ); CGAL_Point_2 tp1 = project_svg_2to2( source, bbox ); CGAL_Point_2 tp2 = project_svg_2to2( target, bbox ); + double mod=0; + if (color=="green") mod=10; + out << " \n"; out << " \n"; + << " x1='" << CGAL::to_double(tp1.x()) + mod << "'" + << " y1='" << CGAL::to_double(tp1.y()) - mod << "'" + << " x2='" << CGAL::to_double(tp2.x()) + mod << "'" + << " y2='" << CGAL::to_double(tp2.y()) - mod << "'" + << " stroke='" << color << "'"; + if (mark) out << " stroke-dasharray='4 4' />\n"; + else out << " />\n"; // crude "arrowhead" to indicate directionality out << " \n"; } @@ -300,18 +312,22 @@ std::string dump_cgal_nef_polyhedron2_svg( const CGAL_Nef_polyhedron2 &N ) out << " \n"; out << svg_border() << "\n" << svg_axes() << "\n"; svg_counter+=480; - if ((svg_counter/480)%2==0) svg_counter += 24; + if ((svg_counter/480)%3==0) svg_counter += 24; + if ((svg_counter/480)%3==1) out << svg_label("old accumulator") << "\n"; + if ((svg_counter/480)%3==2) out << svg_label("new nef poly") << "\n"; + if ((svg_counter/480)%3==0) out << svg_label("new accumulator") << "\n"; + for ( i = explorer.faces_begin(); i!= explorer.faces_end(); ++i ) { - out << " \n"; + out << " \n"; CGAL_Nef_polyhedron2::Explorer::Halfedge_around_face_const_circulator c1 = explorer.face_cycle( i ), c2 ( c1 ); - out << dump_cgal_nef_polyhedron2_face_svg( c1, c2, explorer, "red", bbox ); + out << dump_cgal_nef_polyhedron2_face_svg( c1, c2, explorer, "red", i->mark(), bbox ); CGAL_Nef_polyhedron2::Explorer::Hole_const_iterator j; for ( j = explorer.holes_begin( i ); j!= explorer.holes_end( i ); ++j ) { - out << " \n"; + out << " \n"; CGAL_Nef_polyhedron2::Explorer::Halfedge_around_face_const_circulator c3( j ), c4 ( c3 ); - out << dump_cgal_nef_polyhedron2_face_svg( c3, c4, explorer, "green", bbox ); + out << dump_cgal_nef_polyhedron2_face_svg( c3, c4, explorer, "green", j->mark(), bbox ); out << " \n"; } out << " \n"; -- cgit v0.10.1 From ebe59a0e4d10f1757ff0bd4c1cc6fe8fc2c2ee67 Mon Sep 17 00:00:00 2001 From: Marius Kintel Date: Tue, 23 Oct 2012 20:40:45 -0400 Subject: Added test for circular includes diff --git a/testdata/modulecache-tests/README.txt b/testdata/modulecache-tests/README.txt index 463261c..277cff8 100644 --- a/testdata/modulecache-tests/README.txt +++ b/testdata/modulecache-tests/README.txt @@ -5,13 +5,13 @@ Compile OpenSCAD in debug mode. This will give console output related to module /path/to/used.scad: 0x103612f70 Module cache size: 1 modules -Test1: +Test1: Basic cache ------ o Open use.scad o Compile twice (F5) - check that module reference is the same -Test2: +Test2: Dependency tracking of USE ------ o Open use.scad @@ -19,42 +19,42 @@ o Compile (F5) o touch used.scad o Compile (F5) - check that the module reference changed -Test3: +Test3: MCAD ------ o Open use-mcad.scad o Compile (F5) o Check that you get a rounded box -Test4: +Test4: USE Non-existing file ------ o Open usenonexsistingfile.scad o Compile (F5) o Verify that you get: WARNING: Can't open 'use' file 'nofile.scad'. -Test5: +Test5: Overload USEd module ------ o Open moduleoverload.scad o Compile (F5) o Verify that you get a sphere rather than a cylinder -Test6: +Test6: Recursive USE ------ o Open recursivemain.scad o Compile (F5) o Verify that OpenSCAD won't hang or crash -Test7: +Test7: Circular USE ------ o Open circularmain.scad o Compile (F5) o Verify that OpenSCAD won't hang or crash -Test8: +Test8: Dependency tracking of common file USEd by multiple modules ------ o Open multiplemain.scad @@ -64,7 +64,7 @@ o Edit multipleB.scad: + cube(2.5*F(), center=true); o Reload and Compile (F4) - verify that the cube got larger -Test9: +Test9: Dependency tracking of file included from module ------ o Open includefrommodule.scad @@ -72,4 +72,10 @@ o Compile (F5) - Verify that you get a circular disc o Edit radius.scad: Change RADIUS o Compile (F5) - Verify that the disc changed size -FIXME: Test circular include +Test9: Circular include +------ + +o Open circularincludemain.scad +o Compile (F5) +o Verify that OpenSCAD won't hang or crash + diff --git a/testdata/modulecache-tests/circularincludefirst.scad b/testdata/modulecache-tests/circularincludefirst.scad new file mode 100644 index 0000000..f94606a --- /dev/null +++ b/testdata/modulecache-tests/circularincludefirst.scad @@ -0,0 +1 @@ +include diff --git a/testdata/modulecache-tests/circularincludemain.scad b/testdata/modulecache-tests/circularincludemain.scad new file mode 100644 index 0000000..b973956 --- /dev/null +++ b/testdata/modulecache-tests/circularincludemain.scad @@ -0,0 +1 @@ +include diff --git a/testdata/modulecache-tests/circularincludesecond.scad b/testdata/modulecache-tests/circularincludesecond.scad new file mode 100644 index 0000000..b973956 --- /dev/null +++ b/testdata/modulecache-tests/circularincludesecond.scad @@ -0,0 +1 @@ +include -- cgit v0.10.1 From b7cc740b78ea636868c560871437b3beed45cf2e Mon Sep 17 00:00:00 2001 From: Marius Kintel Date: Tue, 23 Oct 2012 20:41:50 -0400 Subject: Detect circular includes. Probably the final commit for #75 diff --git a/src/lexer.l b/src/lexer.l index 1e3bd5b..63b0047 100644 --- a/src/lexer.l +++ b/src/lexer.l @@ -80,6 +80,7 @@ void includefile(); fs::path sourcepath(); std::vector path_stack; std::vector openfiles; +std::vector openfilenames; std::string filename; std::string filepath; @@ -142,6 +143,7 @@ use[ \t\r\n>]*"<" { BEGIN(cond_use); } assert(!openfiles.empty()); fclose(openfiles.back()); openfiles.pop_back(); + openfilenames.pop_back(); } yypop_buffer_state(); if (!YY_CURRENT_BUFFER) @@ -227,10 +229,15 @@ void includefile() PRINTB("WARNING: Can't find 'include' file '%s'.", filename); } + std::string fullname = boosty::absolute(finfo).string(); + // Detect circular includes + BOOST_FOREACH(std::string &s, openfilenames) { + if (s == fullname) return; + } + filepath.clear(); path_stack.push_back(finfo.parent_path()); - std::string fullname = boosty::absolute(finfo).string(); handle_dep(fullname); currmodule->registerInclude(fullname); yyin = fopen(fullname.c_str(), "r"); @@ -240,6 +247,7 @@ void includefile() return; } openfiles.push_back(yyin); + openfilenames.push_back(fullname); filename.clear(); yypush_buffer_state(yy_create_buffer(yyin, YY_BUF_SIZE)); @@ -253,5 +261,6 @@ void lexerdestroy() { BOOST_FOREACH (FILE *f, openfiles) fclose(f); openfiles.clear(); + openfilenames.clear(); path_stack.clear(); } -- cgit v0.10.1 From 5467bc94116c7e3f22210ace64e0678fff4d4347 Mon Sep 17 00:00:00 2001 From: Marius Kintel Date: Tue, 23 Oct 2012 21:48:29 -0400 Subject: Make cmd-line overrides using -D work also for USEd modules. Fixes #211 diff --git a/doc/TODO.txt b/doc/TODO.txt index 7f8378d..c58a942 100644 --- a/doc/TODO.txt +++ b/doc/TODO.txt @@ -239,6 +239,7 @@ o Collect "all" available OpenSCAD scripts from the internets and run the integr MISSING TESTS: -------------- +o cmd-line -D variable override o all functions o mirror o scale diff --git a/src/ModuleCache.cc b/src/ModuleCache.cc index c215342..19a3f84 100644 --- a/src/ModuleCache.cc +++ b/src/ModuleCache.cc @@ -72,7 +72,9 @@ Module *ModuleCache::evaluate(const std::string &filename) PRINTB("WARNING: Can't open library file '%s'\n", filename); return NULL; } - std::string text((std::istreambuf_iterator(ifs)), std::istreambuf_iterator()); + std::stringstream textbuf; + textbuf << ifs.rdbuf(); + textbuf << "\n" << commandline_commands; print_messages_push(); @@ -84,7 +86,7 @@ Module *ModuleCache::evaluate(const std::string &filename) this->entries[filename] = e; std::string pathname = boosty::stringy(fs::path(filename).parent_path()); - lib_mod = dynamic_cast(parse(text.c_str(), pathname.c_str(), false)); + lib_mod = dynamic_cast(parse(textbuf.str().c_str(), pathname.c_str(), false)); PRINTB_NOCACHE(" compiled module: %p", lib_mod); if (lib_mod) { -- cgit v0.10.1 From ebf9ee0f9f525d91b34224565da2d594d500484f Mon Sep 17 00:00:00 2001 From: Marius Kintel Date: Tue, 23 Oct 2012 22:10:15 -0400 Subject: Support specifying an OPENSCADPATH environment variable which will have precedence over the hardcoded library paths. First step of issue #125 diff --git a/doc/TODO.txt b/doc/TODO.txt index c58a942..be70c26 100644 --- a/doc/TODO.txt +++ b/doc/TODO.txt @@ -240,6 +240,7 @@ o Collect "all" available OpenSCAD scripts from the internets and run the integr MISSING TESTS: -------------- o cmd-line -D variable override +o OPENSCADPATH env.variable o all functions o mirror o scale diff --git a/src/parsersettings.cc b/src/parsersettings.cc index 47859c7..3dda132 100644 --- a/src/parsersettings.cc +++ b/src/parsersettings.cc @@ -28,7 +28,15 @@ std::string locate_file(const std::string &filename) void parser_init(const std::string &applicationpath) { - // FIXME: Append paths from OPENSCADPATH before adding built-in paths + // Add path from OPENSCADPATH before adding built-in paths + const char *openscadpath = getenv("OPENSCADPATH"); + if (openscadpath) { + add_librarydir(boosty::absolute(fs::path(openscadpath)).string()); + } + + // FIXME: Support specifying more than one path in OPENSCADPATH + // FIXME: Add ~/.openscad/libraries + // FIXME: Add ~/Documents/OpenSCAD/libraries on Mac? std::string librarydir; fs::path libdir(applicationpath); -- cgit v0.10.1 From 3207b5abf9cbebca67eba575e6b05158756f7ce4 Mon Sep 17 00:00:00 2001 From: Marius Kintel Date: Tue, 23 Oct 2012 22:26:58 -0400 Subject: Updated RELEASE_NOTES diff --git a/RELEASE_NOTES b/RELEASE_NOTES index 32f3788..f629cd6 100644 --- a/RELEASE_NOTES +++ b/RELEASE_NOTES @@ -1,4 +1,4 @@ -OpenSCAD 2012.XX +OpenSCAD 2012.11 ================ Features: @@ -9,6 +9,9 @@ o Added Dot product operator: vec * vec o Added Matrix multiplication operator: vec * mat, mat * mat o Added search() function o Dependencies are now tracked - any changes in uses/included files will be detected and cause a recompile +o The OPENSCADPATH environment variable is now implemented will have precedence when searching for libraries +o .csg files can now be opened from the GUI +o linear_extrude() will now assume that the first parameter means 'height' if it's a number Bugfixes: o use'ing an non-existing file sometimes crashed under Windows @@ -19,6 +22,12 @@ o Fixed crashes in shared_ptr.hpp (or similar places) due bugs in cache manageme o scale() with a scale factor of zero could cause a crash o Fixed a number of issues related to use/include o Providing an unknown parameter on the cmd-line caused a crash +o cmd-line overrides using -D now also work for USEd modules +o Modifier characters can now be used in front of if statements +o rotate() with a vector argument with less that 3 elements used uninitialized variables, ending up being non-deterministic. +o .csg files will now have relative filenames whenever possible +o A lot of build script fixes +o Some other crash bugs fixes Deprecations: o The old include syntax "" without the include keyword is no -- cgit v0.10.1 From 45a99bfe3631d05b84e3dd86a0fa6f1e6debd8cd Mon Sep 17 00:00:00 2001 From: don bright Date: Wed, 24 Oct 2012 04:14:52 -0500 Subject: use target(), not source(), making 'simple' the 2d polygon created during the 'flattening' process from 3d to 2d. not sure why this works, but it does. diff --git a/src/PolySetCGALEvaluator.cc b/src/PolySetCGALEvaluator.cc index 78c4c5f..4491eed 100644 --- a/src/PolySetCGALEvaluator.cc +++ b/src/PolySetCGALEvaluator.cc @@ -1,7 +1,10 @@ #include "PolySetCGALEvaluator.h" #include "cgal.h" #include "cgalutils.h" + #include +#include + #include "polyset.h" #include "CGALEvaluator.h" #include "projectionnode.h" @@ -28,6 +31,14 @@ stripping off the z coordinate of each face vertex and doing unions and intersections. It uses the 'visitor' pattern from the CGAL manual. Output is in the 'output_nefpoly2d' variable. +Some key things to know about Nef Polyhedron2: + +1. The 'mark' on a face is important when doing unions/intersections +2. The 'mark' on a face is determined by the order of the points given + to the Nef2 constructor. +3. The points given to a constructor might be influenced by whether + they are 'is_simple' or not. + See also http://www.cgal.org/Manual/latest/doc_html/cgal_manual/Nef_3/Chapter_main.html http://www.cgal.org/Manual/latest/doc_html/cgal_manual/Nef_3_ref/Class_Nef_polyhedron3.html @@ -128,7 +139,7 @@ public: out << " \n"; out << " \n"; if ( hfacet->plane().orthogonal_direction() != this->up ) { - out << "\ndown facing half-facet. skipping\n"; + out << "\ndown facing half-facet. not skipping\n"; out << " \n"; std::cout << out.str(); return; @@ -137,14 +148,14 @@ public: bool skip=false; CGAL_Nef_polyhedron3::Halffacet_cycle_const_iterator i; CGAL_forall_facet_cycles_of( i, hfacet ) { - CGAL_Nef_polyhedron3::SHalfedge_around_facet_const_circulator c1(i), c2(c1); - CGAL_For_all( c1, c2 ) { - CGAL_Nef_polyhedron3::Point_3 point3d = c1->source()->source()->point(); + CGAL_Nef_polyhedron3::SHalfedge_around_facet_const_circulator c1a(i), c2a(c1a); + CGAL_For_all( c1a, c2a ) { + CGAL_Nef_polyhedron3::Point_3 point3d = c1a->source()->source()->point(); if (point3d.z()!=0) skip=true; } } if (skip) { - out << "\n facet not on zero plane. skipping\n"; + out << "\n facet not on zero plane. skipping\n"; out << " \n"; std::cout << out.str(); return; @@ -152,33 +163,53 @@ public: int contour_counter = 0; CGAL_forall_facet_cycles_of( i, hfacet ) { - CGAL_Nef_polyhedron3::SHalfedge_around_facet_const_circulator c1(i), c2(c1); - std::vector contour; - CGAL_For_all( c1, c2 ) { - CGAL_Nef_polyhedron3::Point_3 point3d = c1->source()->source()->point(); - CGAL_Nef_polyhedron2::Explorer::Point point2d( point3d.x(), point3d.y() ); - contour.push_back( point2d ); - } + if ( i.is_shalfedge() ) { + CGAL_Nef_polyhedron3::SHalfedge_around_facet_const_circulator c1(i), c2(c1); + std::vector contour; + CGAL_For_all( c1, c2 ) { + out << "around facet. c1 mark:" << c1->mark() << "\n"; + CGAL_Nef_polyhedron3::Point_3 point3d = c1->source()->target()->point(); + CGAL_Nef_polyhedron2::Explorer::Point point2d( point3d.x(), point3d.y() ); + out << "around facet. point3d:" << CGAL::to_double(point3d.x()) << "," << CGAL::to_double(point3d.y()) << "\n";; + out << "around facet. point2d:" << CGAL::to_double(point2d.x()) << "," << CGAL::to_double(point2d.y()) << "\n";; + if (contour.size()) out << "equality:" << (contour.back() == point2d) << "\n";; + out << "equality2 :" << ( c1->target()->source() == c1->source()->target() ) << "\n";; + contour.push_back( point2d ); + } - tmpnef2d.reset( new CGAL_Nef_polyhedron2( contour.begin(), contour.end(), boundary ) ); + // Type given to Polygon_2 has to match Nef2::Explorer::Point + // (which is not the same as CGAL_Kernel2::Point) + std::vector::iterator xx; + for ( xx=contour.begin(); xx!=contour.end(); ++xx ) { + out << "pdump: " << CGAL::to_double(xx->x()) << "," << CGAL::to_double(xx->y()) << "\n"; + } + out << "is simple 2:" << CGAL::is_simple_2( contour.begin(), contour.end() ) << "\n"; + //CGAL::Polygon_2 > plainpoly2( contour.begin(), contour.end() ); + //out << "clockwise orientation: " << plainpoly2.is_clockwise_oriented() << "\n"; + tmpnef2d.reset( new CGAL_Nef_polyhedron2( contour.begin(), contour.end(), boundary ) ); + // *(tmpnef2d) = tmpnef2d->regularization(); + // mark here. + + out << "\n\n"; + out << dump_cgal_nef_polyhedron2_svg( *output_nefpoly2d ); + + if ( contour_counter == 0 ) { + out << "\n \n" ; + *(output_nefpoly2d) += *(tmpnef2d); + } else { + *(output_nefpoly2d) *= *(tmpnef2d); + if (debug) out << "\n\n"; + } - out << "\n\n"; - out << dump_cgal_nef_polyhedron2_svg( *output_nefpoly2d ); + out << "\n\n"; + out << dump_cgal_nef_polyhedron2_svg( *tmpnef2d ); + out << "\n\n"; + out << dump_cgal_nef_polyhedron2_svg( *output_nefpoly2d ); - if ( contour_counter == 0 ) { - out << "\n \n" ; - *(output_nefpoly2d) += *(tmpnef2d); + contour_counter++; } else { - *(output_nefpoly2d) *= *(tmpnef2d); - if (debug) out << "\n\n"; + out << "trivial facet cycle skipped\n"; } - - out << "\n\n"; - out << dump_cgal_nef_polyhedron2_svg( *tmpnef2d ); - out << "\n\n"; - out << dump_cgal_nef_polyhedron2_svg( *output_nefpoly2d ); - - contour_counter++; } // next facet cycle (i.e. next contour) out << " \n"; std::cout << out.str(); diff --git a/src/cgalutils.cc b/src/cgalutils.cc index 347fdd5..94e990a 100644 --- a/src/cgalutils.cc +++ b/src/cgalutils.cc @@ -9,7 +9,8 @@ typedef CGAL::Point_3 CGAL_Point_3; typedef CGAL::Iso_cuboid_3 CGAL_Iso_cuboid_3; typedef CGAL_Nef_polyhedron2::Explorer::Point CGAL_Point_2; -// Iso_rectangle is different- CGAL_Kernel2::Point != CGAL_Nef2::Explorer::Point +// Iso_rectangle needs to match CGAL_Nef2::Explorer::Point +// which is different than CGAL_Kernel2::Point typedef CGAL::Iso_rectangle_2< CGAL::Simple_cartesian > CGAL_Iso_rectangle_2; #include -- cgit v0.10.1 From 1dbcd7f4689fd0ed84997e2fb80a1b77e06f6b26 Mon Sep 17 00:00:00 2001 From: don bright Date: Wed, 24 Oct 2012 05:45:40 -0500 Subject: use a thin box, union the intersection w top of box and bottom of box diff --git a/src/PolySetCGALEvaluator.cc b/src/PolySetCGALEvaluator.cc index 4491eed..99b5938 100644 --- a/src/PolySetCGALEvaluator.cc +++ b/src/PolySetCGALEvaluator.cc @@ -31,13 +31,24 @@ stripping off the z coordinate of each face vertex and doing unions and intersections. It uses the 'visitor' pattern from the CGAL manual. Output is in the 'output_nefpoly2d' variable. +Note that the input 3d Nef polyhedron, as used here, is typically of +two types. The first is the result of an intersection between +the 3d Nef polyhedron and the xy-plane, with all z set to 0. + +The second is the result of an intersection between the 3d nef +polyhedron and a very large, very thin box. This is used when CGAL +crashes during plane intersection. The thin box is used to 'simulate' +the xy plane. The result is that the 'top' of the box and the +'bottom' of the box will both contain 2d projections, quite similar +to what one would get at xy=0, but not exactly. these are then +unioned together. + Some key things to know about Nef Polyhedron2: 1. The 'mark' on a face is important when doing unions/intersections -2. The 'mark' on a face is determined by the order of the points given - to the Nef2 constructor. -3. The points given to a constructor might be influenced by whether - they are 'is_simple' or not. +2. The 'mark' can be non-deterministic based on the constructor. + Possible factors include whether 'is_simple_2' returns true on the + inputted points, and also perhaps the order of points fed to the constructor. See also http://www.cgal.org/Manual/latest/doc_html/cgal_manual/Nef_3/Chapter_main.html @@ -145,22 +156,22 @@ public: return; } - bool skip=false; CGAL_Nef_polyhedron3::Halffacet_cycle_const_iterator i; +/* bool skip=false; CGAL_forall_facet_cycles_of( i, hfacet ) { CGAL_Nef_polyhedron3::SHalfedge_around_facet_const_circulator c1a(i), c2a(c1a); CGAL_For_all( c1a, c2a ) { CGAL_Nef_polyhedron3::Point_3 point3d = c1a->source()->source()->point(); - if (point3d.z()!=0) skip=true; + if (CGAL::to_double(point3d.z())!=floor) skip=true; } } if (skip) { - out << "\n facet not on zero plane. skipping\n"; + out << "\n facet not on floor plane (z=" << floor <<"). skipping\n"; out << " \n"; std::cout << out.str(); return; } - +*/ int contour_counter = 0; CGAL_forall_facet_cycles_of( i, hfacet ) { if ( i.is_shalfedge() ) { @@ -168,6 +179,8 @@ public: std::vector contour; CGAL_For_all( c1, c2 ) { out << "around facet. c1 mark:" << c1->mark() << "\n"; + // c1->source() gives us an SVertex for the SHalfedge + // c1->source()->target() gives us a Vertex?? CGAL_Nef_polyhedron3::Point_3 point3d = c1->source()->target()->point(); CGAL_Nef_polyhedron2::Explorer::Point point2d( point3d.x(), point3d.y() ); out << "around facet. point3d:" << CGAL::to_double(point3d.x()) << "," << CGAL::to_double(point3d.y()) << "\n";; @@ -263,8 +276,9 @@ PolySet *PolySetCGALEvaluator::evaluatePolySet(const ProjectionNode &node) if (plane_intersect_fail) { try { PRINT("Trying alternative intersection using very large thin box: "); - double inf = 1e8, eps = 0.1; - double x1 = -inf, x2 = +inf, y1 = -inf, y2 = +inf, z1 = 0, z2 = eps; + double inf = 1e8, eps = 0.001; + double x1 = -inf, x2 = +inf, y1 = -inf, y2 = +inf, z1 = -eps, z2 = eps; + // dont use z of 0. there are bugs in CGAL. std::vector pts; pts.push_back( Point_3( x1, y1, z1 ) ); -- cgit v0.10.1 From a661315ab2fc2b1c2b478baa6a1ec75418fca400 Mon Sep 17 00:00:00 2001 From: Marius Kintel Date: Fri, 26 Oct 2012 10:44:50 -0400 Subject: Boost 1.51 requires chrono for thread diff --git a/scripts/macosx-build-dependencies.sh b/scripts/macosx-build-dependencies.sh index 024020a..cee1ce4 100755 --- a/scripts/macosx-build-dependencies.sh +++ b/scripts/macosx-build-dependencies.sh @@ -185,7 +185,7 @@ build_boost() tar xjf boost_$bversion.tar.bz2 cd boost_$bversion # We only need the thread and program_options libraries - ./bootstrap.sh --prefix=$DEPLOYDIR --with-libraries=thread,program_options,filesystem,system,regex + ./bootstrap.sh --prefix=$DEPLOYDIR --with-libraries=thread,program_options,filesystem,chrono,system,regex if $OPTION_32BIT; then BOOST_EXTRA_FLAGS="-arch i386" fi @@ -198,6 +198,8 @@ build_boost() fi ./b2 -d+2 $BOOST_TOOLSET cflags="-mmacosx-version-min=$MAC_OSX_VERSION_MIN -arch x86_64 $BOOST_EXTRA_FLAGS" linkflags="-mmacosx-version-min=$MAC_OSX_VERSION_MIN -arch x86_64 $BOOST_EXTRA_FLAGS" install install_name_tool -id $DEPLOYDIR/lib/libboost_thread.dylib $DEPLOYDIR/lib/libboost_thread.dylib + install_name_tool -change libboost_system.dylib $DEPLOYDIR/lib/libboost_system.dylib $DEPLOYDIR/lib/libboost_thread.dylib + install_name_tool -change libboost_chrono.dylib $DEPLOYDIR/lib/libboost_chrono.dylib $DEPLOYDIR/lib/libboost_thread.dylib install_name_tool -id $DEPLOYDIR/lib/libboost_program_options.dylib $DEPLOYDIR/lib/libboost_program_options.dylib install_name_tool -id $DEPLOYDIR/lib/libboost_filesystem.dylib $DEPLOYDIR/lib/libboost_filesystem.dylib install_name_tool -change libboost_system.dylib $DEPLOYDIR/lib/libboost_system.dylib $DEPLOYDIR/lib/libboost_filesystem.dylib -- cgit v0.10.1 From 4ecd9fa8a4ceeb49ec62a50197f4fa4da9276796 Mon Sep 17 00:00:00 2001 From: don bright Date: Sun, 28 Oct 2012 08:56:23 -0500 Subject: refactor, cleanup, put code where it belongs, make simple logging class diff --git a/openscad.pro b/openscad.pro index b5321cc..91bd735 100644 --- a/openscad.pro +++ b/openscad.pro @@ -214,7 +214,8 @@ HEADERS += src/version_check.h \ src/memory.h \ src/linalg.h \ src/system-gl.h \ - src/stl-utils.h + src/stl-utils.h \ + src/svg.h SOURCES += src/version_check.cc \ src/ProgressWidget.cc \ @@ -271,6 +272,7 @@ SOURCES += src/version_check.cc \ src/dxftess-glu.cc \ src/dxftess-cgal.cc \ src/CSGTermEvaluator.cc \ + src/svg.cc \ \ src/openscad.cc \ src/mainwin.cc diff --git a/src/CGAL_Nef_polyhedron_DxfData.cc b/src/CGAL_Nef_polyhedron_DxfData.cc index 26b9353..0d0b8f0 100644 --- a/src/CGAL_Nef_polyhedron_DxfData.cc +++ b/src/CGAL_Nef_polyhedron_DxfData.cc @@ -29,6 +29,7 @@ #include "CGAL_Nef_polyhedron.h" #include "cgal.h" #include "cgalutils.h" +#include "svg.h" #ifdef ENABLE_CGAL @@ -81,9 +82,9 @@ DxfData *CGAL_Nef_polyhedron::convertToDxfData() const std::string CGAL_Nef_polyhedron::dump() const { if (this->dim==2) - return dump_cgal_nef_polyhedron2_svg( *this->p2 ); + return OpenSCAD::dump_svg( *this->p2 ); else if (this->dim==3) - return dump_cgal_nef_polyhedron3_svg( *this->p3 ); + return OpenSCAD::dump_svg( *this->p3 ); else return std::string("Nef Polyhedron with dimension != 2 or 3"); } diff --git a/src/PolySetCGALEvaluator.cc b/src/PolySetCGALEvaluator.cc index 99b5938..f6fb1d4 100644 --- a/src/PolySetCGALEvaluator.cc +++ b/src/PolySetCGALEvaluator.cc @@ -22,123 +22,55 @@ #include #include -typedef CGAL_Nef_polyhedron3::Point_3 Point_3; +#include "svg.h" + /* -This class converts multiple 3d-CGAL Nef polyhedrons into a single 2d by -stripping off the z coordinate of each face vertex and doing unions and -intersections. It uses the 'visitor' pattern from the CGAL manual. -Output is in the 'output_nefpoly2d' variable. +ZRemover + +This class converts an already 'flat' Nef3 polyhedra into a Nef2 +polyhedron by stripping off the 'z' coordinate. -Note that the input 3d Nef polyhedron, as used here, is typically of -two types. The first is the result of an intersection between -the 3d Nef polyhedron and the xy-plane, with all z set to 0. +The class uses the 'visitor' pattern from the CGAL manual -- multiple 3d +Nef polys fed to this class, with the resulting Nef2 poly accumulating +in the 'output_nefpoly2d' member variable. -The second is the result of an intersection between the 3d nef -polyhedron and a very large, very thin box. This is used when CGAL -crashes during plane intersection. The thin box is used to 'simulate' -the xy plane. The result is that the 'top' of the box and the -'bottom' of the box will both contain 2d projections, quite similar -to what one would get at xy=0, but not exactly. these are then -unioned together. +Some notes on CGAL's Nef Polyhedron2: -Some key things to know about Nef Polyhedron2: +0. The method for iterating through CGAL Nef2 poly and Nef3 polys is different. + Nef2 requires 'Explorer', which uses it's own Point type that is not strictly + the same as Nef2::Point_2. Nef3, in contrast, uses straightforward + iterators and circulators using the standard Nef3::Point_3 type. +1. The 'mark' on a 2d Nef face is important when doing unions/intersections. + If the 'mark' of a face is wrong the resulting nef2 poly will be unexpected. +2. The 'mark' can be dependent on the points fed to the Nef2 constructor. + This is why we iterate through the 3d faces using the halfedge cycle + source()->target() instead of the ordinary source()->source(). The + the latter can generate sequences of points that will fail the + the CGAL::is_simple_2() test, resulting in improperly marked nef2 polys. -1. The 'mark' on a face is important when doing unions/intersections -2. The 'mark' can be non-deterministic based on the constructor. - Possible factors include whether 'is_simple_2' returns true on the - inputted points, and also perhaps the order of points fed to the constructor. +Debugging output is in heavily commented SVG format. See also http://www.cgal.org/Manual/latest/doc_html/cgal_manual/Nef_3/Chapter_main.html http://www.cgal.org/Manual/latest/doc_html/cgal_manual/Nef_3_ref/Class_Nef_polyhedron3.html OGL_helper.h */ -class Flattener { -public: - std::ostringstream out; - CGAL_Nef_polyhedron2::Boundary boundary; - shared_ptr tmpnef2d; - shared_ptr output_nefpoly2d; - CGAL::Direction_3 up; - bool debug; - Flattener(bool debug=false) - { - output_nefpoly2d.reset( new CGAL_Nef_polyhedron2() ); - boundary = CGAL_Nef_polyhedron2::INCLUDED; - up = CGAL::Direction_3(0,0,1); - this->debug = debug; - } - std::string dump() - { - return out.str(); - } - void visit( CGAL_Nef_polyhedron3::Vertex_const_handle ) {} - void visit( CGAL_Nef_polyhedron3::Halfedge_const_handle ) {} - void visit( CGAL_Nef_polyhedron3::SHalfedge_const_handle ) {} - void visit( CGAL_Nef_polyhedron3::SHalfloop_const_handle ) {} - void visit( CGAL_Nef_polyhedron3::SFace_const_handle ) {} - void visit( CGAL_Nef_polyhedron3::Halffacet_const_handle hfacet ) { - out.str(""); - out << " \n"; - out << " \n"; - if ( hfacet->plane().orthogonal_direction() != this->up ) { - out << "\ndown facing half-facet. skipping\n"; - out << " \n"; - std::cout << out.str(); - return; - } - int contour_counter = 0; - CGAL_Nef_polyhedron3::Halffacet_cycle_const_iterator i; - CGAL_forall_facet_cycles_of( i, hfacet ) { - CGAL_Nef_polyhedron3::SHalfedge_around_facet_const_circulator c1(i), c2(c1); - std::list contour; - CGAL_For_all( c1, c2 ) { - CGAL_Nef_polyhedron3::Point_3 point3d = c1->source()->source()->point(); - CGAL_Nef_polyhedron2::Point point2d( point3d.x(), point3d.y() ); - contour.push_back( point2d ); - } - tmpnef2d.reset( new CGAL_Nef_polyhedron2( contour.begin(), contour.end(), boundary ) ); - if ( contour_counter == 0 ) { - out << "\n \n" ; - *(output_nefpoly2d) += *(tmpnef2d); - } else { - *(output_nefpoly2d) *= *(tmpnef2d); - if (debug) out << "\n\n"; - } - out << "\n\n"; - out << dump_cgal_nef_polyhedron2_svg( *tmpnef2d ); - out << "\n\n"; - out << dump_cgal_nef_polyhedron2_svg( *output_nefpoly2d ); - contour_counter++; - } // next facet cycle (i.e. next contour) - out << " \n"; - std::cout << out.str(); - } // visit() -}; - - - -class Flattener2 { +class ZRemover { public: - std::ostringstream out; + logstream log; CGAL_Nef_polyhedron2::Boundary boundary; shared_ptr tmpnef2d; shared_ptr output_nefpoly2d; CGAL::Direction_3 up; - bool debug; - Flattener2(bool debug=false) + ZRemover() { output_nefpoly2d.reset( new CGAL_Nef_polyhedron2() ); boundary = CGAL_Nef_polyhedron2::INCLUDED; up = CGAL::Direction_3(0,0,1); - this->debug = debug; - } - std::string dump() - { - return out.str(); + log = logstream(5); } void visit( CGAL_Nef_polyhedron3::Vertex_const_handle ) {} void visit( CGAL_Nef_polyhedron3::Halfedge_const_handle ) {} @@ -146,86 +78,54 @@ public: void visit( CGAL_Nef_polyhedron3::SHalfloop_const_handle ) {} void visit( CGAL_Nef_polyhedron3::SFace_const_handle ) {} void visit( CGAL_Nef_polyhedron3::Halffacet_const_handle hfacet ) { - out.str(""); - out << " \n"; - out << " \n"; + log << " \n"; if ( hfacet->plane().orthogonal_direction() != this->up ) { - out << "\ndown facing half-facet. not skipping\n"; - out << " \n"; - std::cout << out.str(); + log << " \n"; + log << " \n"; return; } - CGAL_Nef_polyhedron3::Halffacet_cycle_const_iterator i; -/* bool skip=false; - CGAL_forall_facet_cycles_of( i, hfacet ) { - CGAL_Nef_polyhedron3::SHalfedge_around_facet_const_circulator c1a(i), c2a(c1a); - CGAL_For_all( c1a, c2a ) { - CGAL_Nef_polyhedron3::Point_3 point3d = c1a->source()->source()->point(); - if (CGAL::to_double(point3d.z())!=floor) skip=true; - } - } - if (skip) { - out << "\n facet not on floor plane (z=" << floor <<"). skipping\n"; - out << " \n"; - std::cout << out.str(); - return; - } -*/ + // possible optimization - throw out facets that are 'side facets' between + // the top & bottom of the big thin box. (i.e. mixture of z=-eps and z=eps) + + CGAL_Nef_polyhedron3::Halffacet_cycle_const_iterator fci; int contour_counter = 0; - CGAL_forall_facet_cycles_of( i, hfacet ) { - if ( i.is_shalfedge() ) { - CGAL_Nef_polyhedron3::SHalfedge_around_facet_const_circulator c1(i), c2(c1); + CGAL_forall_facet_cycles_of( fci, hfacet ) { + if ( fci.is_shalfedge() ) { + CGAL_Nef_polyhedron3::SHalfedge_around_facet_const_circulator c1(fci), cend(c1); std::vector contour; - CGAL_For_all( c1, c2 ) { - out << "around facet. c1 mark:" << c1->mark() << "\n"; - // c1->source() gives us an SVertex for the SHalfedge - // c1->source()->target() gives us a Vertex?? + CGAL_For_all( c1, cend ) { + // c1->source()->target() seems to work better than c1->source()->source() CGAL_Nef_polyhedron3::Point_3 point3d = c1->source()->target()->point(); CGAL_Nef_polyhedron2::Explorer::Point point2d( point3d.x(), point3d.y() ); - out << "around facet. point3d:" << CGAL::to_double(point3d.x()) << "," << CGAL::to_double(point3d.y()) << "\n";; - out << "around facet. point2d:" << CGAL::to_double(point2d.x()) << "," << CGAL::to_double(point2d.y()) << "\n";; - if (contour.size()) out << "equality:" << (contour.back() == point2d) << "\n";; - out << "equality2 :" << ( c1->target()->source() == c1->source()->target() ) << "\n";; contour.push_back( point2d ); } - // Type given to Polygon_2 has to match Nef2::Explorer::Point - // (which is not the same as CGAL_Kernel2::Point) - std::vector::iterator xx; - for ( xx=contour.begin(); xx!=contour.end(); ++xx ) { - out << "pdump: " << CGAL::to_double(xx->x()) << "," << CGAL::to_double(xx->y()) << "\n"; - } - out << "is simple 2:" << CGAL::is_simple_2( contour.begin(), contour.end() ) << "\n"; - //CGAL::Polygon_2 > plainpoly2( contour.begin(), contour.end() ); - //out << "clockwise orientation: " << plainpoly2.is_clockwise_oriented() << "\n"; - tmpnef2d.reset( new CGAL_Nef_polyhedron2( contour.begin(), contour.end(), boundary ) ); - // *(tmpnef2d) = tmpnef2d->regularization(); - // mark here. + assert(contour.size()>1); - out << "\n\n"; - out << dump_cgal_nef_polyhedron2_svg( *output_nefpoly2d ); + log << " \n"; + + tmpnef2d.reset( new CGAL_Nef_polyhedron2( contour.begin(), contour.end(), boundary ) ); if ( contour_counter == 0 ) { - out << "\n \n" ; + log << " \n" ; *(output_nefpoly2d) += *(tmpnef2d); } else { *(output_nefpoly2d) *= *(tmpnef2d); - if (debug) out << "\n\n"; + log << " \n"; } - out << "\n\n"; - out << dump_cgal_nef_polyhedron2_svg( *tmpnef2d ); - out << "\n\n"; - out << dump_cgal_nef_polyhedron2_svg( *output_nefpoly2d ); + log << "\n\n"; + log << OpenSCAD::dump_svg( *tmpnef2d ) << "\n"; + log << "\n\n"; + log << OpenSCAD::dump_svg( *output_nefpoly2d ) << "\n"; contour_counter++; } else { - out << "trivial facet cycle skipped\n"; + log << " \n"; } } // next facet cycle (i.e. next contour) - out << " \n"; - std::cout << out.str(); + log << " \n"; } // visit() }; @@ -235,11 +135,13 @@ public: PolySetCGALEvaluator::PolySetCGALEvaluator(CGALEvaluator &cgalevaluator) : PolySetEvaluator(cgalevaluator.getTree()), cgalevaluator(cgalevaluator) { - this->debug = false; } PolySet *PolySetCGALEvaluator::evaluatePolySet(const ProjectionNode &node) { + //openscad_loglevel = 6; + logstream log(5); + // Before projecting, union all children CGAL_Nef_polyhedron sum; BOOST_FOREACH (AbstractNode * v, node.getChildren()) { @@ -258,37 +160,31 @@ PolySet *PolySetCGALEvaluator::evaluatePolySet(const ProjectionNode &node) } } - // std::cout << sum.dump_svg() << std::flush; // input dump - CGAL_Nef_polyhedron nef_poly; if (node.cut_mode) { CGAL::Failure_behaviour old_behaviour = CGAL::set_error_behaviour(CGAL::THROW_EXCEPTION); - bool plane_intersect_fail = false; try { CGAL_Nef_polyhedron3::Plane_3 xy_plane = CGAL_Nef_polyhedron3::Plane_3( 0,0,1,0 ); *sum.p3 = sum.p3->intersection( xy_plane, CGAL_Nef_polyhedron3::PLANE_ONLY); } catch (const CGAL::Failure_exception &e) { PRINTB("CGAL error in projection node during plane intersection: %s", e.what()); - plane_intersect_fail = true; - } - if (plane_intersect_fail) { try { PRINT("Trying alternative intersection using very large thin box: "); double inf = 1e8, eps = 0.001; double x1 = -inf, x2 = +inf, y1 = -inf, y2 = +inf, z1 = -eps, z2 = eps; // dont use z of 0. there are bugs in CGAL. - std::vector pts; - pts.push_back( Point_3( x1, y1, z1 ) ); - pts.push_back( Point_3( x1, y2, z1 ) ); - pts.push_back( Point_3( x2, y2, z1 ) ); - pts.push_back( Point_3( x2, y1, z1 ) ); - pts.push_back( Point_3( x1, y1, z2 ) ); - pts.push_back( Point_3( x1, y2, z2 ) ); - pts.push_back( Point_3( x2, y2, z2 ) ); - pts.push_back( Point_3( x2, y1, z2 ) ); + std::vector pts; + pts.push_back( CGAL_Nef_polyhedron3::Point_3( x1, y1, z1 ) ); + pts.push_back( CGAL_Nef_polyhedron3::Point_3( x1, y2, z1 ) ); + pts.push_back( CGAL_Nef_polyhedron3::Point_3( x2, y2, z1 ) ); + pts.push_back( CGAL_Nef_polyhedron3::Point_3( x2, y1, z1 ) ); + pts.push_back( CGAL_Nef_polyhedron3::Point_3( x1, y1, z2 ) ); + pts.push_back( CGAL_Nef_polyhedron3::Point_3( x1, y2, z2 ) ); + pts.push_back( CGAL_Nef_polyhedron3::Point_3( x2, y2, z2 ) ); + pts.push_back( CGAL_Nef_polyhedron3::Point_3( x2, y1, z2 ) ); CGAL_Polyhedron bigbox; CGAL::convex_hull_3( pts.begin(), pts.end(), bigbox ); @@ -297,36 +193,37 @@ PolySet *PolySetCGALEvaluator::evaluatePolySet(const ProjectionNode &node) } catch (const CGAL::Failure_exception &e) { PRINTB("CGAL error in projection node during bigbox intersection: %s", e.what()); - // can we just return empty polyset? - CGAL::set_error_behaviour(old_behaviour); - return NULL; + sum.reset(); } } + CGAL::set_error_behaviour(old_behaviour); + + if (sum.empty()) { + PRINT("WARNING: Projection failed."); + return NULL; + } + // remove z coordinates to make CGAL_Nef_polyhedron2 - std::cout << ""; + log << ""; try { - Flattener2 flattener(true); + ZRemover zremover; CGAL_Nef_polyhedron3::Volume_const_iterator i; CGAL_Nef_polyhedron3::Shell_entry_const_iterator j; CGAL_Nef_polyhedron3::SFace_const_handle sface_handle; for ( i = sum.p3->volumes_begin(); i != sum.p3->volumes_end(); ++i ) { - std::cout << "\n"; + log << "\n"; for ( j = i->shells_begin(); j != i->shells_end(); ++j ) { - std::cout << "\n"; -// if (i->mark()==1) { - sface_handle = CGAL_Nef_polyhedron3::SFace_const_handle( j ); - sum.p3->visit_shell_objects( sface_handle , flattener ); -// } - std::cout << "\n"; + log << "\n"; + sface_handle = CGAL_Nef_polyhedron3::SFace_const_handle( j ); + sum.p3->visit_shell_objects( sface_handle , zremover ); + log << "\n"; } - std::cout << "\n"; + log << "\n"; } - //std::cout << flattener.out.str() << "\n"; - std::cout << "" << std::flush; + log << "\n"; - //std::cout << "------- flattener dump \n" << flattener.dump() << "\n"; - nef_poly.p2 = flattener.output_nefpoly2d; + nef_poly.p2 = zremover.output_nefpoly2d; nef_poly.dim = 2; } catch (const CGAL::Failure_exception &e) { PRINTB("CGAL error in projection node while flattening: %s", e.what()); @@ -334,10 +231,6 @@ PolySet *PolySetCGALEvaluator::evaluatePolySet(const ProjectionNode &node) CGAL::set_error_behaviour(old_behaviour); - //std::cout << sum.dump_svg() << std::flush; // cut dump - //std::cout << nef_poly.dump_svg() << std::flush; // post-flattener dump - - //std::cout << "------- 2d output dump \n" << nef_poly.dump_svg() << "\n"; // Extract polygons in the XY plane, ignoring all other polygons // FIXME: If the polyhedron is really thin, there might be unwanted polygons // in the XY plane, causing the resulting 2D polygon to be self-intersection @@ -424,7 +317,7 @@ PolySet *PolySetCGALEvaluator::evaluatePolySet(const ProjectionNode &node) PolySet *ps = nef_poly.convertToPolyset(); assert( ps != NULL ); ps->convexity = node.convexity; - if (debug) std::cout << "--\n" << ps->dump() << "\n"; + logstream(9) << ps->dump() << "\n"; return ps; } diff --git a/src/cgal.h b/src/cgal.h index e5e39dd..c3b52a3 100644 --- a/src/cgal.h +++ b/src/cgal.h @@ -33,6 +33,7 @@ using boost::uintmax_t; #include #include #include +#include #include #include @@ -54,6 +55,15 @@ typedef CGAL::Polyhedron_3 CGAL_Polyhedron; typedef CGAL_Polyhedron::HalfedgeDS CGAL_HDS; typedef CGAL::Polyhedron_incremental_builder_3 CGAL_Polybuilder; +typedef CGAL::Point_3 CGAL_Point_3; +typedef CGAL::Iso_cuboid_3 CGAL_Iso_cuboid_3; + +// The type given to Iso_rectangle_2 needs to match CGAL_Nef2::Explorer::Point +// which is different than a CGAL_Kernel2::Point. Hence the suffix 'e' +typedef CGAL_Nef_polyhedron2::Explorer::Point CGAL_Point_2e; +typedef CGAL::Iso_rectangle_2< CGAL::Simple_cartesian > CGAL_Iso_rectangle_2e; + + #ifdef PREV_NDEBUG #define NDEBUG PREV_NDEBUG #endif diff --git a/src/cgalutils.cc b/src/cgalutils.cc index 94e990a..601b6f3 100644 --- a/src/cgalutils.cc +++ b/src/cgalutils.cc @@ -4,17 +4,6 @@ #include "polyset.h" #include "printutils.h" #include "cgal.h" -#include -typedef CGAL::Point_3 CGAL_Point_3; -typedef CGAL::Iso_cuboid_3 CGAL_Iso_cuboid_3; - -typedef CGAL_Nef_polyhedron2::Explorer::Point CGAL_Point_2; -// Iso_rectangle needs to match CGAL_Nef2::Explorer::Point -// which is different than CGAL_Kernel2::Point -typedef CGAL::Iso_rectangle_2< CGAL::Simple_cartesian > CGAL_Iso_rectangle_2; - -#include -#include PolySet *createPolySetFromPolyhedron(const CGAL_Polyhedron &p) { @@ -154,45 +143,12 @@ CGAL_Polyhedron *createPolyhedronFromPolySet(const PolySet &ps) } -std::string svg_header() -{ - std::stringstream out; - out << ""; - return out.str(); -} - -std::string svg_label(std::string s) -{ - std::stringstream out; - out << "" << s << ""; - return out.str(); -} -std::string svg_border() -{ - std::stringstream out; - out << " \n"; - out << " \n"; - out << " "; - return out.str(); -} - -std::string svg_axes() -{ - std::stringstream out; - out << " \n"; - out << " \n"; - out << " "; - return out.str(); -} - CGAL_Iso_cuboid_3 bounding_box( const CGAL_Nef_polyhedron3 &N ) { CGAL_Iso_cuboid_3 result(-1,-1,-1,1,1,1); CGAL_Nef_polyhedron3::Vertex_const_iterator vi; std::vector points; + // can be optimized by rewriting bounding_box to accept vertices CGAL_forall_vertices( vi, N ) points.push_back( vi->point() ); if (points.size()) @@ -200,12 +156,13 @@ CGAL_Iso_cuboid_3 bounding_box( const CGAL_Nef_polyhedron3 &N ) return result; } -CGAL_Iso_rectangle_2 bounding_box( const CGAL_Nef_polyhedron2 &N ) +CGAL_Iso_rectangle_2e bounding_box( const CGAL_Nef_polyhedron2 &N ) { - CGAL_Iso_rectangle_2 result(-1,-1,1,1); - CGAL_Nef_polyhedron2::Explorer explorer = N.explorer(); + CGAL_Iso_rectangle_2e result(-1,-1,1,1); + CGAL_Nef_polyhedron2::Explorer explorer = N.explorer(); CGAL_Nef_polyhedron2::Explorer::Vertex_const_iterator vi; - std::vector points; + std::vector points; + // can be optimized by rewriting bounding_box to accept vertices for ( vi = explorer.vertices_begin(); vi != explorer.vertices_end(); ++vi ) if ( explorer.is_standard( vi ) ) points.push_back( explorer.point( vi ) ); @@ -214,208 +171,7 @@ CGAL_Iso_rectangle_2 bounding_box( const CGAL_Nef_polyhedron2 &N ) return result; } -CGAL_Point_2 project_svg_3to2( CGAL_Point_3 p, CGAL_Iso_cuboid_3 bbox ) -{ - // do simple fake isometric projection - double x = CGAL::to_double( p.x() ); - double y = CGAL::to_double( p.y() ); - double z = CGAL::to_double( p.z() ); - double screenw = 480; - double screenh = 480; - double borderw = screenw * 0.1618; - double borderh = screenh * 0.1618; - double vizw = screenw - borderw*2; - double vizh = screenh - borderh*2; - double bboxx = CGAL::to_double( bbox.xmax() - bbox.xmin() ); - double bboxy = CGAL::to_double( bbox.ymax() - bbox.ymin() ); - double bboxz = CGAL::to_double( bbox.zmax() - bbox.zmin() ); - double xinbox = CGAL::to_double( p.x() ) - CGAL::to_double( bbox.xmin() ); - double yinbox = CGAL::to_double( p.y() ) - CGAL::to_double( bbox.ymin() ); - double zinbox = CGAL::to_double( p.z() ) - CGAL::to_double( bbox.zmin() ); - double tx = borderw + ( xinbox / ( bboxx==0?1:bboxx ) ) * ( vizw ); - double ty = screenh - borderh - ( zinbox / ( bboxz==0?1:bboxz ) ) * ( vizh ); - tx += ( yinbox / ( bboxy==0?1:bboxy ) ) / 3; - ty -= ( yinbox / ( bboxy==0?1:bboxy ) ) / 3; - return CGAL_Point_2( tx, ty ); -} - -CGAL_Point_2 project_svg_2to2( CGAL_Point_2 p, CGAL_Iso_rectangle_2 bbox ) -{ - double x = CGAL::to_double( p.x() ); - double y = CGAL::to_double( p.y() ); - double screenw = 480; - double screenh = 480; - double borderw = screenw * 0.1618; - double borderh = screenh * 0.1618; - double vizw = screenw - borderw*2; - double vizh = screenh - borderh*2; - double bboxw = CGAL::to_double( bbox.xmax() - bbox.xmin() ); - double bboxh = CGAL::to_double( bbox.ymax() - bbox.ymin() ); - double xinbox = CGAL::to_double( p.x() ) - CGAL::to_double( bbox.xmin() ); - double yinbox = CGAL::to_double( p.y() ) - CGAL::to_double( bbox.ymin() ); - double tx = borderw + ( xinbox / ( bboxw==0?1:bboxw ) ) * ( vizw ); - double ty = screenh - borderh - ( yinbox / ( bboxh==0?1:bboxh ) ) * ( vizh ); -/* std::cout << "\nx, y " << x << "," << y << "\n"; - std::cout << "bbw, bbh " << bboxw << "," << bboxh << "\n"; - std::cout << "xinb, yinb " << xinbox << "," << yinbox << "\n"; - std::cout << "vizw, vizh " << vizw << "," << vizh << "\n"; - std::cout << "tx, ty " << tx << "," << ty << "\n"; -*/ - return CGAL_Point_2( tx, ty ); -} - -// for debugging, not necessarily pretty or useful for users. -std::string dump_cgal_nef_polyhedron2_face_svg( - CGAL_Nef_polyhedron2::Explorer::Halfedge_around_face_const_circulator c1, - CGAL_Nef_polyhedron2::Explorer::Halfedge_around_face_const_circulator c2, - CGAL_Nef_polyhedron2::Explorer explorer, - std::string color, - bool mark, - CGAL_Iso_rectangle_2 bbox ) -{ - std::stringstream out; - CGAL_For_all(c1, c2) { - if ( explorer.is_standard( explorer.target(c1) ) ) { - CGAL_Point_2 source = explorer.point( explorer.source( c1 ) ); - CGAL_Point_2 target = explorer.point( explorer.target( c1 ) ); - CGAL_Point_2 tp1 = project_svg_2to2( source, bbox ); - CGAL_Point_2 tp2 = project_svg_2to2( target, bbox ); - double mod=0; - if (color=="green") mod=10; - out << " \n"; - out << " \n"; - else out << " />\n"; - // crude "arrowhead" to indicate directionality - out << " \n"; - } - } - return out.str(); -} -std::string dump_cgal_nef_polyhedron2_svg( const CGAL_Nef_polyhedron2 &N ) -{ - std::stringstream out; - CGAL_Nef_polyhedron2::Explorer explorer = N.explorer(); - - CGAL_Iso_rectangle_2 bbox = bounding_box( N ); - - CGAL_Nef_polyhedron2::Explorer::Face_const_iterator i; - out << " \n"; - out << svg_border() << "\n" << svg_axes() << "\n"; - svg_counter+=480; - if ((svg_counter/480)%3==0) svg_counter += 24; - if ((svg_counter/480)%3==1) out << svg_label("old accumulator") << "\n"; - if ((svg_counter/480)%3==2) out << svg_label("new nef poly") << "\n"; - if ((svg_counter/480)%3==0) out << svg_label("new accumulator") << "\n"; - - for ( i = explorer.faces_begin(); i!= explorer.faces_end(); ++i ) { - out << " \n"; - CGAL_Nef_polyhedron2::Explorer::Halfedge_around_face_const_circulator c1 - = explorer.face_cycle( i ), c2 ( c1 ); - out << dump_cgal_nef_polyhedron2_face_svg( c1, c2, explorer, "red", i->mark(), bbox ); - - CGAL_Nef_polyhedron2::Explorer::Hole_const_iterator j; - for ( j = explorer.holes_begin( i ); j!= explorer.holes_end( i ); ++j ) { - out << " \n"; - CGAL_Nef_polyhedron2::Explorer::Halfedge_around_face_const_circulator c3( j ), c4 ( c3 ); - out << dump_cgal_nef_polyhedron2_face_svg( c3, c4, explorer, "green", j->mark(), bbox ); - out << " \n"; - } - out << " \n"; - } - out << ""; - std::string tmp = out.str(); - boost::replace_all( tmp, "'", "\"" ); - return tmp; -} - - -// This uses the Shell Explorer pattern from the CGAL Manual to dump the 3d Nef Polyhedron information -// http://www.cgal.org/Manual/latest/doc_html/cgal_manual/Nef_3/Chapter_main.html#Subsection_29.7.2 -class NefPoly3_dumper_svg { -public: - std::stringstream out; - CGAL_Iso_cuboid_3 bbox; - NefPoly3_dumper_svg(const CGAL_Nef_polyhedron3& N) - { - bbox = bounding_box( N ); - } - void visit(CGAL_Nef_polyhedron3::Vertex_const_handle v) {} - void visit(CGAL_Nef_polyhedron3::Halfedge_const_handle ) {} - void visit(CGAL_Nef_polyhedron3::SHalfedge_const_handle ) {} - void visit(CGAL_Nef_polyhedron3::SHalfloop_const_handle shh ){} - void visit(CGAL_Nef_polyhedron3::SFace_const_handle ) {} - void visit( CGAL_Nef_polyhedron3::Halffacet_const_handle hfacet ) - { - int contour_count = 0; - out << " \n"; - CGAL_Nef_polyhedron3::Halffacet_cycle_const_iterator i; - CGAL_forall_facet_cycles_of( i, hfacet ) { - CGAL_Nef_polyhedron3::SHalfloop_const_handle shl_handle; - out << " \n"; - if ( contour_count == 0 ) { - out << " \n"; - } else { - out << " \n" ; - } - CGAL_Nef_polyhedron3::SHalfedge_around_facet_const_circulator c1(i), c2(c1); - CGAL_For_all( c1, c2 ) { - out << " source(), except thats what CGAL does internally - CGAL_Point_3 source = c1->source()->source()->point(); - CGAL_Point_3 target = c1->source()->target()->point(); - CGAL_Point_2 tp1 = project_svg_3to2 ( source, bbox ); - CGAL_Point_2 tp2 = project_svg_3to2 ( target, bbox ); - out << " " - << "x1='" << CGAL::to_double(tp1.x()) << "' " - << "y1='" << CGAL::to_double(tp1.y()) << "' " - << "x2='" << CGAL::to_double(tp2.x()) << "' " - << "y2='" << CGAL::to_double(tp2.y()) << "' " - << "stroke='red' />\n"; - } - contour_count++; - } // next facet cycle (i.e. next contour) - } // visit() - -}; - - -std::string dump_cgal_nef_polyhedron3_svg( const CGAL_Nef_polyhedron3 &N ) -{ - std::stringstream out; - out << svg_header << "\n" << svg_border() << "\n" << svg_axes() << "\n"; - out << "\n"; - - CGAL_Nef_polyhedron3::Volume_const_iterator c; - CGAL_forall_volumes(c,N) { - out << " \n"; - out << " \n"; - CGAL_Nef_polyhedron3::Shell_entry_const_iterator it; - CGAL_forall_shells_of(it,c) { - out << " \n"; - NefPoly3_dumper_svg dumper_svg(N); - N.visit_shell_objects(CGAL_Nef_polyhedron3::SFace_const_handle(it), dumper_svg ); - out << dumper_svg.out.str(); - out << " \n"; - } - out << " \n"; - } - out << "\n"; - out << ""; - std::string tmp = out.str(); - boost::replace_all( tmp, "'", "\"" ); - return tmp; -} #endif /* ENABLE_CGAL */ diff --git a/src/cgalutils.h b/src/cgalutils.h index 3fb9360..9093c3f 100644 --- a/src/cgalutils.h +++ b/src/cgalutils.h @@ -5,10 +5,7 @@ class PolySet *createPolySetFromPolyhedron(const CGAL_Polyhedron &p); CGAL_Polyhedron *createPolyhedronFromPolySet(const class PolySet &ps); -std::string dump_cgal_nef_polyhedron2( const CGAL_Nef_polyhedron2 &N ); -std::string dump_cgal_nef_polyhedron3( const CGAL_Nef_polyhedron3 &N ); -std::string dump_cgal_nef_polyhedron2_svg( const CGAL_Nef_polyhedron2 &N ); -std::string dump_cgal_nef_polyhedron3_svg( const CGAL_Nef_polyhedron3 &N ); -static int svg_counter = 0; +CGAL_Iso_cuboid_3 bounding_box( const CGAL_Nef_polyhedron3 &N ); +CGAL_Iso_rectangle_2e bounding_box( const CGAL_Nef_polyhedron2 &N ); #endif diff --git a/src/func.cc b/src/func.cc index e427bf2..21c6f33 100644 --- a/src/func.cc +++ b/src/func.cc @@ -530,3 +530,4 @@ void register_builtin_functions() Builtins::init("version", new BuiltinFunction(&builtin_version)); Builtins::init("version_num", new BuiltinFunction(&builtin_version_num)); } + diff --git a/src/printutils.cc b/src/printutils.cc index a8b62aa..57c6b49 100644 --- a/src/printutils.cc +++ b/src/printutils.cc @@ -49,3 +49,6 @@ void PRINT_NOCACHE(const std::string &msg) outputhandler(msg, outputhandler_data); } } + + + diff --git a/src/printutils.h b/src/printutils.h index 521682c..935463e 100644 --- a/src/printutils.h +++ b/src/printutils.h @@ -3,7 +3,9 @@ #include #include +#include #include +#include #include typedef void (OutputHandlerFunc)(const std::string &msg, void *userdata); @@ -22,4 +24,26 @@ void PRINT(const std::string &msg); void PRINT_NOCACHE(const std::string &msg); #define PRINTB_NOCACHE(_fmt, _arg) do { PRINT_NOCACHE(str(boost::format(_fmt) % _arg)); } while (0) +// extremely simple logging, eventually replace with something like boost.log +// usage: logstream out(5); openscad_loglevel=6; out << "hi"; +static int openscad_loglevel = 0; +class logstream +{ +public: + std::ostream *out; + int loglevel; + logstream( int level = 0 ) { + loglevel = level; + out = &(std::cout); + } + template logstream & operator<<( T const &t ) { + if (out && loglevel <= openscad_loglevel) { + (*out) << t ; + out->flush(); + } + return *this; + } +}; + + #endif diff --git a/src/svg.cc b/src/svg.cc new file mode 100644 index 0000000..a40bd9f --- /dev/null +++ b/src/svg.cc @@ -0,0 +1,248 @@ +#include "cgalutils.h" +#include "svg.h" +#include +#include + +namespace OpenSCAD { + +std::string svg_header() +{ + std::stringstream out; + out << ""; + return out.str(); +} + +std::string svg_label(std::string s) +{ + std::stringstream out; + out << "" << s << ""; + return out.str(); +} + +std::string svg_border() +{ + std::stringstream out; + out << " \n"; + out << " \n"; + out << " "; + return out.str(); +} + +std::string svg_axes() +{ + std::stringstream out; + out << " \n"; + out << " \n"; + out << " "; + return out.str(); +} + +CGAL_Point_2e project_svg_3to2( CGAL_Point_3 p, CGAL_Iso_cuboid_3 bbox ) +{ + // do simple fake isometric projection + double x = CGAL::to_double( p.x() ); + double y = CGAL::to_double( p.y() ); + double z = CGAL::to_double( p.z() ); + double screenw = 480; + double screenh = 480; + double borderw = screenw * 0.1618; + double borderh = screenh * 0.1618; + double vizw = screenw - borderw*2; + double vizh = screenh - borderh*2; + double bboxx = CGAL::to_double( bbox.xmax() - bbox.xmin() ); + double bboxy = CGAL::to_double( bbox.ymax() - bbox.ymin() ); + double bboxz = CGAL::to_double( bbox.zmax() - bbox.zmin() ); + double xinbox = CGAL::to_double( p.x() ) - CGAL::to_double( bbox.xmin() ); + double yinbox = CGAL::to_double( p.y() ) - CGAL::to_double( bbox.ymin() ); + double zinbox = CGAL::to_double( p.z() ) - CGAL::to_double( bbox.zmin() ); + double tx = borderw + ( xinbox / ( bboxx==0?1:bboxx ) ) * ( vizw ); + double ty = screenh - borderh - ( zinbox / ( bboxz==0?1:bboxz ) ) * ( vizh ); + tx += ( yinbox / ( bboxy==0?1:bboxy ) ) / 3; + ty -= ( yinbox / ( bboxy==0?1:bboxy ) ) / 3; + return CGAL_Point_2e( tx, ty ); +} + +CGAL_Point_2e project_svg_2to2( CGAL_Point_2e p, CGAL_Iso_rectangle_2e bbox ) +{ + double x = CGAL::to_double( p.x() ); + double y = CGAL::to_double( p.y() ); + double screenw = 480; + double screenh = 480; + double borderw = screenw * 0.1618; + double borderh = screenh * 0.1618; + double vizw = screenw - borderw*2; + double vizh = screenh - borderh*2; + double bboxw = CGAL::to_double( bbox.xmax() - bbox.xmin() ); + double bboxh = CGAL::to_double( bbox.ymax() - bbox.ymin() ); + double xinbox = CGAL::to_double( p.x() ) - CGAL::to_double( bbox.xmin() ); + double yinbox = CGAL::to_double( p.y() ) - CGAL::to_double( bbox.ymin() ); + double tx = borderw + ( xinbox / ( bboxw==0?1:bboxw ) ) * ( vizw ); + double ty = screenh - borderh - ( yinbox / ( bboxh==0?1:bboxh ) ) * ( vizh ); +/* std::cout << "\nx, y " << x << "," << y << "\n"; + std::cout << "bbw, bbh " << bboxw << "," << bboxh << "\n"; + std::cout << "xinb, yinb " << xinbox << "," << yinbox << "\n"; + std::cout << "vizw, vizh " << vizw << "," << vizh << "\n"; + std::cout << "tx, ty " << tx << "," << ty << "\n"; +*/ + return CGAL_Point_2e( tx, ty ); +} + +// for debugging, not necessarily pretty or useful for users. +std::string dump_cgal_nef_polyhedron2_face_svg( + CGAL_Nef_polyhedron2::Explorer::Halfedge_around_face_const_circulator c1, + CGAL_Nef_polyhedron2::Explorer::Halfedge_around_face_const_circulator c2, + CGAL_Nef_polyhedron2::Explorer explorer, + std::string color, + bool mark, + CGAL_Iso_rectangle_2e bbox ) +{ + std::stringstream out; + CGAL_For_all(c1, c2) { + if ( explorer.is_standard( explorer.target(c1) ) ) { + CGAL_Point_2e source = explorer.point( explorer.source( c1 ) ); + CGAL_Point_2e target = explorer.point( explorer.target( c1 ) ); + CGAL_Point_2e tp1 = project_svg_2to2( source, bbox ); + CGAL_Point_2e tp2 = project_svg_2to2( target, bbox ); + double mod=0; + if (color=="green") mod=10; + out << " \n"; + out << " \n"; + else out << " />\n"; + // crude "arrowhead" to indicate directionality + out << " \n"; + } + } + return out.str(); +} + +std::string dump_svg( const CGAL_Nef_polyhedron2 &N ) +{ + std::stringstream out; + CGAL_Nef_polyhedron2::Explorer explorer = N.explorer(); + + CGAL_Iso_rectangle_2e bbox = bounding_box( N ); + + CGAL_Nef_polyhedron2::Explorer::Face_const_iterator i; + out << " \n"; + out << svg_border() << "\n" << svg_axes() << "\n"; + svg_cursor+=480; + if ((svg_cursor/480)%3==0) svg_cursor += 24; + if ((svg_cursor/480)%3==1) out << svg_label("old accumulator") << "\n"; + if ((svg_cursor/480)%3==2) out << svg_label("new nef poly") << "\n"; + if ((svg_cursor/480)%3==0) out << svg_label("new accumulator") << "\n"; + + for ( i = explorer.faces_begin(); i!= explorer.faces_end(); ++i ) { + out << " \n"; + CGAL_Nef_polyhedron2::Explorer::Halfedge_around_face_const_circulator c1 + = explorer.face_cycle( i ), c2 ( c1 ); + out << dump_cgal_nef_polyhedron2_face_svg( c1, c2, explorer, "red", i->mark(), bbox ); + + CGAL_Nef_polyhedron2::Explorer::Hole_const_iterator j; + for ( j = explorer.holes_begin( i ); j!= explorer.holes_end( i ); ++j ) { + out << " \n"; + CGAL_Nef_polyhedron2::Explorer::Halfedge_around_face_const_circulator c3( j ), c4 ( c3 ); + out << dump_cgal_nef_polyhedron2_face_svg( c3, c4, explorer, "green", j->mark(), bbox ); + out << " \n"; + } + out << " \n"; + } + out << ""; + std::string tmp = out.str(); + boost::replace_all( tmp, "'", "\"" ); + return tmp; +} + + +// This uses the Shell Explorer pattern from the CGAL Manual to dump the 3d Nef Polyhedron information +// http://www.cgal.org/Manual/latest/doc_html/cgal_manual/Nef_3/Chapter_main.html#Subsection_29.7.2 +class NefPoly3_dumper_svg { +public: + std::stringstream out; + CGAL_Iso_cuboid_3 bbox; + NefPoly3_dumper_svg(const CGAL_Nef_polyhedron3& N) + { + bbox = bounding_box( N ); + } + void visit(CGAL_Nef_polyhedron3::Vertex_const_handle v) {} + void visit(CGAL_Nef_polyhedron3::Halfedge_const_handle ) {} + void visit(CGAL_Nef_polyhedron3::SHalfedge_const_handle ) {} + void visit(CGAL_Nef_polyhedron3::SHalfloop_const_handle shh ){} + void visit(CGAL_Nef_polyhedron3::SFace_const_handle ) {} + void visit( CGAL_Nef_polyhedron3::Halffacet_const_handle hfacet ) + { + int contour_count = 0; + out << " \n"; + CGAL_Nef_polyhedron3::Halffacet_cycle_const_iterator i; + CGAL_forall_facet_cycles_of( i, hfacet ) { + CGAL_Nef_polyhedron3::SHalfloop_const_handle shl_handle; + out << " \n"; + if ( contour_count == 0 ) { + out << " \n"; + } else { + out << " \n" ; + } + CGAL_Nef_polyhedron3::SHalfedge_around_facet_const_circulator c1(i), c2(c1); + CGAL_For_all( c1, c2 ) { + out << " source(), except thats what CGAL does internally + CGAL_Point_3 source = c1->source()->source()->point(); + CGAL_Point_3 target = c1->source()->target()->point(); + CGAL_Point_2e tp1 = project_svg_3to2 ( source, bbox ); + CGAL_Point_2e tp2 = project_svg_3to2 ( target, bbox ); + out << " " + << "x1='" << CGAL::to_double(tp1.x()) << "' " + << "y1='" << CGAL::to_double(tp1.y()) << "' " + << "x2='" << CGAL::to_double(tp2.x()) << "' " + << "y2='" << CGAL::to_double(tp2.y()) << "' " + << "stroke='red' />\n"; + } + contour_count++; + } // next facet cycle (i.e. next contour) + } // visit() + +}; + + +std::string dump_svg( const CGAL_Nef_polyhedron3 &N ) +{ + std::stringstream out; + out << svg_header << "\n" << svg_border() << "\n" << svg_axes() << "\n"; + out << "\n"; + + CGAL_Nef_polyhedron3::Volume_const_iterator c; + CGAL_forall_volumes(c,N) { + out << " \n"; + out << " \n"; + CGAL_Nef_polyhedron3::Shell_entry_const_iterator it; + CGAL_forall_shells_of(it,c) { + out << " \n"; + NefPoly3_dumper_svg dumper_svg(N); + N.visit_shell_objects(CGAL_Nef_polyhedron3::SFace_const_handle(it), dumper_svg ); + out << dumper_svg.out.str(); + out << " \n"; + } + out << " \n"; + } + out << "\n"; + out << ""; + std::string tmp = out.str(); + boost::replace_all( tmp, "'", "\"" ); + return tmp; +} + +} // namespace + + diff --git a/src/svg.h b/src/svg.h new file mode 100644 index 0000000..c7c7e1a --- /dev/null +++ b/src/svg.h @@ -0,0 +1,34 @@ +#ifndef SVG_H_ +#define SVG_H_ + +#include "cgal.h" +#include +#include + +namespace OpenSCAD { + +static int svg_cursor = 0; + +std::string svg_header(); +std::string svg_label(std::string s); +std::string svg_border(); +std::string svg_axes(); +CGAL_Point_2e project_svg_3to2( CGAL_Point_3 p, CGAL_Iso_cuboid_3 bbox ); +CGAL_Point_2e project_svg_2to2( CGAL_Point_2e p, CGAL_Iso_rectangle_2e bbox ); + +std::string dump_cgal_nef_polyhedron2_face_svg( + CGAL_Nef_polyhedron2::Explorer::Halfedge_around_face_const_circulator c1, + CGAL_Nef_polyhedron2::Explorer::Halfedge_around_face_const_circulator c2, + CGAL_Nef_polyhedron2::Explorer explorer, + std::string color, + bool mark, + CGAL_Iso_rectangle_2e bbox ); +std::string dump_svg( const CGAL_Nef_polyhedron2 &N ); +class NefPoly3_dumper_svg; +std::string dump_svg( const CGAL_Nef_polyhedron3 &N ); + + +} // namespace + +#endif + -- cgit v0.10.1 From f39cb81549333c9305ac0330751bad6654838838 Mon Sep 17 00:00:00 2001 From: don bright Date: Sun, 28 Oct 2012 11:51:43 -0500 Subject: remove debugging. cleanup diff --git a/src/PolySetCGALEvaluator.cc b/src/PolySetCGALEvaluator.cc index f6fb1d4..781c4fc 100644 --- a/src/PolySetCGALEvaluator.cc +++ b/src/PolySetCGALEvaluator.cc @@ -160,6 +160,9 @@ PolySet *PolySetCGALEvaluator::evaluatePolySet(const ProjectionNode &node) } } + //std::cout << sum.dump(); + //std::cout.flush(); + CGAL_Nef_polyhedron nef_poly; if (node.cut_mode) { @@ -205,7 +208,7 @@ PolySet *PolySetCGALEvaluator::evaluatePolySet(const ProjectionNode &node) } // remove z coordinates to make CGAL_Nef_polyhedron2 - log << ""; + log << OpenSCAD::svg_header( 480, 100000 ) << "\n"; try { ZRemover zremover; CGAL_Nef_polyhedron3::Volume_const_iterator i; diff --git a/src/cgal.h b/src/cgal.h index c3b52a3..518d082 100644 --- a/src/cgal.h +++ b/src/cgal.h @@ -34,6 +34,7 @@ using boost::uintmax_t; #include #include #include +#include #include #include diff --git a/src/svg.cc b/src/svg.cc index a40bd9f..6f2cda9 100644 --- a/src/svg.cc +++ b/src/svg.cc @@ -5,10 +5,14 @@ namespace OpenSCAD { -std::string svg_header() + +// SVG code +// currently for debugging, not necessarily pretty or useful for users. + +std::string svg_header( int pixw, int pixh ) { std::stringstream out; - out << ""; return out.str(); } @@ -16,7 +20,7 @@ std::string svg_header() std::string svg_label(std::string s) { std::stringstream out; - out << "" << s << ""; + out << " " << s << ""; return out.str(); } @@ -42,26 +46,23 @@ std::string svg_axes() CGAL_Point_2e project_svg_3to2( CGAL_Point_3 p, CGAL_Iso_cuboid_3 bbox ) { - // do simple fake isometric projection - double x = CGAL::to_double( p.x() ); - double y = CGAL::to_double( p.y() ); - double z = CGAL::to_double( p.z() ); - double screenw = 480; - double screenh = 480; - double borderw = screenw * 0.1618; - double borderh = screenh * 0.1618; - double vizw = screenw - borderw*2; - double vizh = screenh - borderh*2; - double bboxx = CGAL::to_double( bbox.xmax() - bbox.xmin() ); - double bboxy = CGAL::to_double( bbox.ymax() - bbox.ymin() ); - double bboxz = CGAL::to_double( bbox.zmax() - bbox.zmin() ); - double xinbox = CGAL::to_double( p.x() ) - CGAL::to_double( bbox.xmin() ); - double yinbox = CGAL::to_double( p.y() ) - CGAL::to_double( bbox.ymin() ); - double zinbox = CGAL::to_double( p.z() ) - CGAL::to_double( bbox.zmin() ); - double tx = borderw + ( xinbox / ( bboxx==0?1:bboxx ) ) * ( vizw ); - double ty = screenh - borderh - ( zinbox / ( bboxz==0?1:bboxz ) ) * ( vizh ); - tx += ( yinbox / ( bboxy==0?1:bboxy ) ) / 3; - ty -= ( yinbox / ( bboxy==0?1:bboxy ) ) / 3; + NT screenw(480); + NT screenh(480); + NT screenxc = screenw / 2; + NT screenyc = screenh / 2; + NT bboxx = ( bbox.xmax() - bbox.xmin() ); + NT bboxy = ( bbox.ymax() - bbox.ymin() ); + NT bboxz = ( bbox.zmax() - bbox.zmin() ); + NT largest_dim = CGAL::max( CGAL::max( bboxx, bboxy ), bboxz ); + NT bboxxc = bboxx / 2 + bbox.xmin(); + NT bboxyc = bboxy / 2 + bbox.ymin(); + NT bboxzc = bboxz / 2 + bbox.zmin(); + NT xinbox = ( p.x() - bboxxc ) / largest_dim; + NT yinbox = ( p.y() - bboxyc ) / largest_dim; + NT zinbox = ( p.z() - bboxzc ) / largest_dim; + // do simple fake paralell projection + NT tx = screenxc + xinbox * screenw / 1.618 + yinbox * screenh / 3.2; + NT ty = screenyc - zinbox * screenh / 1.618 - yinbox * screenh / 3.2; return CGAL_Point_2e( tx, ty ); } @@ -81,16 +82,9 @@ CGAL_Point_2e project_svg_2to2( CGAL_Point_2e p, CGAL_Iso_rectangle_2e bbox ) double yinbox = CGAL::to_double( p.y() ) - CGAL::to_double( bbox.ymin() ); double tx = borderw + ( xinbox / ( bboxw==0?1:bboxw ) ) * ( vizw ); double ty = screenh - borderh - ( yinbox / ( bboxh==0?1:bboxh ) ) * ( vizh ); -/* std::cout << "\nx, y " << x << "," << y << "\n"; - std::cout << "bbw, bbh " << bboxw << "," << bboxh << "\n"; - std::cout << "xinb, yinb " << xinbox << "," << yinbox << "\n"; - std::cout << "vizw, vizh " << vizw << "," << vizh << "\n"; - std::cout << "tx, ty " << tx << "," << ty << "\n"; -*/ return CGAL_Point_2e( tx, ty ); } -// for debugging, not necessarily pretty or useful for users. std::string dump_cgal_nef_polyhedron2_face_svg( CGAL_Nef_polyhedron2::Explorer::Halfedge_around_face_const_circulator c1, CGAL_Nef_polyhedron2::Explorer::Halfedge_around_face_const_circulator c2, @@ -115,7 +109,7 @@ std::string dump_cgal_nef_polyhedron2_face_svg( << " x2='" << CGAL::to_double(tp2.x()) + mod << "'" << " y2='" << CGAL::to_double(tp2.y()) - mod << "'" << " stroke='" << color << "'"; - if (mark) out << " stroke-dasharray='4 4' />\n"; + if (!mark) out << " stroke-dasharray='4 4' />\n"; else out << " />\n"; // crude "arrowhead" to indicate directionality out << " \n"; + } else { + out << " \n"; } } return out.str(); @@ -139,10 +135,6 @@ std::string dump_svg( const CGAL_Nef_polyhedron2 &N ) out << " \n"; out << svg_border() << "\n" << svg_axes() << "\n"; svg_cursor+=480; - if ((svg_cursor/480)%3==0) svg_cursor += 24; - if ((svg_cursor/480)%3==1) out << svg_label("old accumulator") << "\n"; - if ((svg_cursor/480)%3==2) out << svg_label("new nef poly") << "\n"; - if ((svg_cursor/480)%3==0) out << svg_label("new accumulator") << "\n"; for ( i = explorer.faces_begin(); i!= explorer.faces_end(); ++i ) { out << " \n"; @@ -185,6 +177,8 @@ public: { int contour_count = 0; out << " \n"; + std::string color = "gold"; + if (!(*hfacet).mark()) color = "green"; CGAL_Nef_polyhedron3::Halffacet_cycle_const_iterator i; CGAL_forall_facet_cycles_of( i, hfacet ) { CGAL_Nef_polyhedron3::SHalfloop_const_handle shl_handle; @@ -207,7 +201,9 @@ public: << "y1='" << CGAL::to_double(tp1.y()) << "' " << "x2='" << CGAL::to_double(tp2.x()) << "' " << "y2='" << CGAL::to_double(tp2.y()) << "' " - << "stroke='red' />\n"; + << " stroke='" << color << "'"; + if (!(*hfacet).mark()) out << " stroke-dasharray='4 4' />\n"; + else out << " />\n"; } contour_count++; } // next facet cycle (i.e. next contour) @@ -219,7 +215,7 @@ public: std::string dump_svg( const CGAL_Nef_polyhedron3 &N ) { std::stringstream out; - out << svg_header << "\n" << svg_border() << "\n" << svg_axes() << "\n"; + out << svg_header() << "\n" << svg_border() << "\n" << svg_axes() << "\n"; out << "\n"; CGAL_Nef_polyhedron3::Volume_const_iterator c; diff --git a/src/svg.h b/src/svg.h index c7c7e1a..f8d3c0d 100644 --- a/src/svg.h +++ b/src/svg.h @@ -9,7 +9,7 @@ namespace OpenSCAD { static int svg_cursor = 0; -std::string svg_header(); +std::string svg_header( int pixwidth = 480, int pixheight = 480 ); std::string svg_label(std::string s); std::string svg_border(); std::string svg_axes(); -- cgit v0.10.1 From 66b9efb35e52987719307f605d230714408930f0 Mon Sep 17 00:00:00 2001 From: don bright Date: Sun, 28 Oct 2012 12:14:34 -0500 Subject: reduce linecount of bigbox code. minor cleaning. diff --git a/src/PolySetCGALEvaluator.cc b/src/PolySetCGALEvaluator.cc index 781c4fc..2fd2a6f 100644 --- a/src/PolySetCGALEvaluator.cc +++ b/src/PolySetCGALEvaluator.cc @@ -1,9 +1,7 @@ #include "PolySetCGALEvaluator.h" #include "cgal.h" #include "cgalutils.h" - #include -#include #include "polyset.h" #include "CGALEvaluator.h" @@ -16,21 +14,20 @@ #include "dxftess.h" #include "module.h" +#include "svg.h" #include "printutils.h" #include "openscad.h" // get_fragments_from_r() #include #include -#include -#include "svg.h" /* ZRemover -This class converts an already 'flat' Nef3 polyhedra into a Nef2 -polyhedron by stripping off the 'z' coordinate. +This class converts one or more already 'flat' Nef3 polyhedra into a Nef2 +polyhedron by stripping off the 'z' coordinates from the vertices. The class uses the 'visitor' pattern from the CGAL manual -- multiple 3d Nef polys fed to this class, with the resulting Nef2 poly accumulating @@ -38,10 +35,6 @@ in the 'output_nefpoly2d' member variable. Some notes on CGAL's Nef Polyhedron2: -0. The method for iterating through CGAL Nef2 poly and Nef3 polys is different. - Nef2 requires 'Explorer', which uses it's own Point type that is not strictly - the same as Nef2::Point_2. Nef3, in contrast, uses straightforward - iterators and circulators using the standard Nef3::Point_3 type. 1. The 'mark' on a 2d Nef face is important when doing unions/intersections. If the 'mark' of a face is wrong the resulting nef2 poly will be unexpected. 2. The 'mark' can be dependent on the points fed to the Nef2 constructor. @@ -49,6 +42,7 @@ Some notes on CGAL's Nef Polyhedron2: source()->target() instead of the ordinary source()->source(). The the latter can generate sequences of points that will fail the the CGAL::is_simple_2() test, resulting in improperly marked nef2 polys. +3. 3d facets have 'two sides'. we throw out the 'down' side to prevent dups. Debugging output is in heavily commented SVG format. @@ -95,7 +89,6 @@ public: CGAL_Nef_polyhedron3::SHalfedge_around_facet_const_circulator c1(fci), cend(c1); std::vector contour; CGAL_For_all( c1, cend ) { - // c1->source()->target() seems to work better than c1->source()->source() CGAL_Nef_polyhedron3::Point_3 point3d = c1->source()->target()->point(); CGAL_Nef_polyhedron2::Explorer::Point point2d( point3d.x(), point3d.y() ); contour.push_back( point2d ); @@ -111,8 +104,8 @@ public: log << " \n" ; *(output_nefpoly2d) += *(tmpnef2d); } else { - *(output_nefpoly2d) *= *(tmpnef2d); log << " \n"; + *(output_nefpoly2d) *= *(tmpnef2d); } log << "\n\n"; @@ -129,9 +122,6 @@ public: } // visit() }; - - - PolySetCGALEvaluator::PolySetCGALEvaluator(CGALEvaluator &cgalevaluator) : PolySetEvaluator(cgalevaluator.getTree()), cgalevaluator(cgalevaluator) { @@ -175,20 +165,12 @@ PolySet *PolySetCGALEvaluator::evaluatePolySet(const ProjectionNode &node) PRINTB("CGAL error in projection node during plane intersection: %s", e.what()); try { PRINT("Trying alternative intersection using very large thin box: "); - double inf = 1e8, eps = 0.001; - double x1 = -inf, x2 = +inf, y1 = -inf, y2 = +inf, z1 = -eps, z2 = eps; + std::vector pts; // dont use z of 0. there are bugs in CGAL. - - std::vector pts; - pts.push_back( CGAL_Nef_polyhedron3::Point_3( x1, y1, z1 ) ); - pts.push_back( CGAL_Nef_polyhedron3::Point_3( x1, y2, z1 ) ); - pts.push_back( CGAL_Nef_polyhedron3::Point_3( x2, y2, z1 ) ); - pts.push_back( CGAL_Nef_polyhedron3::Point_3( x2, y1, z1 ) ); - pts.push_back( CGAL_Nef_polyhedron3::Point_3( x1, y1, z2 ) ); - pts.push_back( CGAL_Nef_polyhedron3::Point_3( x1, y2, z2 ) ); - pts.push_back( CGAL_Nef_polyhedron3::Point_3( x2, y2, z2 ) ); - pts.push_back( CGAL_Nef_polyhedron3::Point_3( x2, y1, z2 ) ); - + CGAL_Point_3 minpt( -1e8, -1e8, -0.001 ); + CGAL_Point_3 maxpt( 1e8, 1e8, 0.001 ); + CGAL_Iso_cuboid_3 bigcuboid( minpt, maxpt ); + for ( int i=0;i<8;i++ ) pts.push_back( bigcuboid.vertex(i) ); CGAL_Polyhedron bigbox; CGAL::convex_hull_3( pts.begin(), pts.end(), bigbox ); CGAL_Nef_polyhedron3 nef_bigbox( bigbox ); -- cgit v0.10.1 From 66b6433ffe6f8e0236cf8ab1edad7045df360b2a Mon Sep 17 00:00:00 2001 From: don bright Date: Sun, 28 Oct 2012 12:37:27 -0500 Subject: cleanup diff --git a/src/PolySetCGALEvaluator.cc b/src/PolySetCGALEvaluator.cc index 2fd2a6f..a5393fd 100644 --- a/src/PolySetCGALEvaluator.cc +++ b/src/PolySetCGALEvaluator.cc @@ -94,7 +94,7 @@ public: contour.push_back( point2d ); } - assert(contour.size()>1); + if (contour.size()==0) continue; log << " \n"; @@ -108,10 +108,10 @@ public: *(output_nefpoly2d) *= *(tmpnef2d); } - log << "\n\n"; - log << OpenSCAD::dump_svg( *tmpnef2d ) << "\n"; - log << "\n\n"; - log << OpenSCAD::dump_svg( *output_nefpoly2d ) << "\n"; + log << "\n\n" + << OpenSCAD::dump_svg( *tmpnef2d ) << "\n" + << "\n\n" + << OpenSCAD::dump_svg( *output_nefpoly2d ) << "\n"; contour_counter++; } else { diff --git a/src/cgal.h b/src/cgal.h index 518d082..a7300c6 100644 --- a/src/cgal.h +++ b/src/cgal.h @@ -59,8 +59,9 @@ typedef CGAL::Polyhedron_incremental_builder_3 CGAL_Polybuilder; typedef CGAL::Point_3 CGAL_Point_3; typedef CGAL::Iso_cuboid_3 CGAL_Iso_cuboid_3; -// The type given to Iso_rectangle_2 needs to match CGAL_Nef2::Explorer::Point -// which is different than a CGAL_Kernel2::Point. Hence the suffix 'e' +// CGAL_Nef_polyhedron2 uses CGAL_Kernel2, but Iso_rectangle_2 needs to match +// CGAL_Nef_polyhedron2::Explorer::Point which is different than +// CGAL_Kernel2::Point. Hence the suffix 'e' typedef CGAL_Nef_polyhedron2::Explorer::Point CGAL_Point_2e; typedef CGAL::Iso_rectangle_2< CGAL::Simple_cartesian > CGAL_Iso_rectangle_2e; diff --git a/src/cgalutils.cc b/src/cgalutils.cc index 601b6f3..51838df 100644 --- a/src/cgalutils.cc +++ b/src/cgalutils.cc @@ -3,8 +3,11 @@ #include "cgalutils.h" #include "polyset.h" #include "printutils.h" + #include "cgal.h" +#include + PolySet *createPolySetFromPolyhedron(const CGAL_Polyhedron &p) { PolySet *ps = new PolySet(); @@ -142,7 +145,6 @@ CGAL_Polyhedron *createPolyhedronFromPolySet(const PolySet &ps) return P; } - CGAL_Iso_cuboid_3 bounding_box( const CGAL_Nef_polyhedron3 &N ) { CGAL_Iso_cuboid_3 result(-1,-1,-1,1,1,1); @@ -171,8 +173,5 @@ CGAL_Iso_rectangle_2e bounding_box( const CGAL_Nef_polyhedron2 &N ) return result; } - - - #endif /* ENABLE_CGAL */ diff --git a/src/func.cc b/src/func.cc index 21c6f33..e427bf2 100644 --- a/src/func.cc +++ b/src/func.cc @@ -530,4 +530,3 @@ void register_builtin_functions() Builtins::init("version", new BuiltinFunction(&builtin_version)); Builtins::init("version_num", new BuiltinFunction(&builtin_version_num)); } - diff --git a/src/printutils.cc b/src/printutils.cc index 57c6b49..a8b62aa 100644 --- a/src/printutils.cc +++ b/src/printutils.cc @@ -49,6 +49,3 @@ void PRINT_NOCACHE(const std::string &msg) outputhandler(msg, outputhandler_data); } } - - - diff --git a/src/printutils.h b/src/printutils.h index 935463e..9d99a19 100644 --- a/src/printutils.h +++ b/src/printutils.h @@ -3,9 +3,7 @@ #include #include -#include #include -#include #include typedef void (OutputHandlerFunc)(const std::string &msg, void *userdata); diff --git a/src/svg.cc b/src/svg.cc index 6f2cda9..f30e4b8 100644 --- a/src/svg.cc +++ b/src/svg.cc @@ -5,14 +5,13 @@ namespace OpenSCAD { - // SVG code -// currently for debugging, not necessarily pretty or useful for users. +// currently for debugging, not necessarily pretty or useful for users. (yet) -std::string svg_header( int pixw, int pixh ) +std::string svg_header() { std::stringstream out; - out << ""; return out.str(); } @@ -28,7 +27,10 @@ std::string svg_border() { std::stringstream out; out << " \n"; - out << " \n"; out << " "; return out.str(); @@ -46,8 +48,8 @@ std::string svg_axes() CGAL_Point_2e project_svg_3to2( CGAL_Point_3 p, CGAL_Iso_cuboid_3 bbox ) { - NT screenw(480); - NT screenh(480); + NT screenw(svg_px_width); + NT screenh(svg_px_height); NT screenxc = screenw / 2; NT screenyc = screenh / 2; NT bboxx = ( bbox.xmax() - bbox.xmin() ); @@ -70,8 +72,8 @@ CGAL_Point_2e project_svg_2to2( CGAL_Point_2e p, CGAL_Iso_rectangle_2e bbox ) { double x = CGAL::to_double( p.x() ); double y = CGAL::to_double( p.y() ); - double screenw = 480; - double screenh = 480; + double screenw = svg_px_width; + double screenh = svg_px_height; double borderw = screenw * 0.1618; double borderh = screenh * 0.1618; double vizw = screenw - borderw*2; @@ -132,9 +134,11 @@ std::string dump_svg( const CGAL_Nef_polyhedron2 &N ) CGAL_Iso_rectangle_2e bbox = bounding_box( N ); CGAL_Nef_polyhedron2::Explorer::Face_const_iterator i; - out << " \n"; + out << " \n"; out << svg_border() << "\n" << svg_axes() << "\n"; - svg_cursor+=480; + svg_cursor_py += svg_px_height; for ( i = explorer.faces_begin(); i!= explorer.faces_end(); ++i ) { out << " \n"; diff --git a/src/svg.h b/src/svg.h index f8d3c0d..2351288 100644 --- a/src/svg.h +++ b/src/svg.h @@ -7,27 +7,19 @@ namespace OpenSCAD { -static int svg_cursor = 0; +// currently for debugging, not necessarily pretty or useful for users. (yet) -std::string svg_header( int pixwidth = 480, int pixheight = 480 ); -std::string svg_label(std::string s); +static int svg_cursor_py = 0; +static int svg_px_width = 480; +static int svg_px_height = 480; + +std::string svg_header(); +std::string svg_label( std::string s ); std::string svg_border(); std::string svg_axes(); -CGAL_Point_2e project_svg_3to2( CGAL_Point_3 p, CGAL_Iso_cuboid_3 bbox ); -CGAL_Point_2e project_svg_2to2( CGAL_Point_2e p, CGAL_Iso_rectangle_2e bbox ); - -std::string dump_cgal_nef_polyhedron2_face_svg( - CGAL_Nef_polyhedron2::Explorer::Halfedge_around_face_const_circulator c1, - CGAL_Nef_polyhedron2::Explorer::Halfedge_around_face_const_circulator c2, - CGAL_Nef_polyhedron2::Explorer explorer, - std::string color, - bool mark, - CGAL_Iso_rectangle_2e bbox ); std::string dump_svg( const CGAL_Nef_polyhedron2 &N ); -class NefPoly3_dumper_svg; std::string dump_svg( const CGAL_Nef_polyhedron3 &N ); - } // namespace #endif -- cgit v0.10.1 From 434ebe017df92dadf9a8e75bca3f540131398ae2 Mon Sep 17 00:00:00 2001 From: don bright Date: Sun, 28 Oct 2012 12:40:16 -0500 Subject: more cleanup diff --git a/src/PolySetCGALEvaluator.cc b/src/PolySetCGALEvaluator.cc index a5393fd..245e97a 100644 --- a/src/PolySetCGALEvaluator.cc +++ b/src/PolySetCGALEvaluator.cc @@ -20,20 +20,15 @@ #include #include - - /* ZRemover This class converts one or more already 'flat' Nef3 polyhedra into a Nef2 -polyhedron by stripping off the 'z' coordinates from the vertices. +polyhedron by stripping off the 'z' coordinates from the vertices. The +resulting Nef2 poly is accumulated in the 'output_nefpoly2d' member variable. -The class uses the 'visitor' pattern from the CGAL manual -- multiple 3d -Nef polys fed to this class, with the resulting Nef2 poly accumulating -in the 'output_nefpoly2d' member variable. - -Some notes on CGAL's Nef Polyhedron2: +Notes on CGAL's Nef Polyhedron2: 1. The 'mark' on a 2d Nef face is important when doing unions/intersections. If the 'mark' of a face is wrong the resulting nef2 poly will be unexpected. @@ -44,9 +39,7 @@ Some notes on CGAL's Nef Polyhedron2: the CGAL::is_simple_2() test, resulting in improperly marked nef2 polys. 3. 3d facets have 'two sides'. we throw out the 'down' side to prevent dups. -Debugging output is in heavily commented SVG format. - -See also +The class uses the 'visitor' pattern from the CGAL manual. See also http://www.cgal.org/Manual/latest/doc_html/cgal_manual/Nef_3/Chapter_main.html http://www.cgal.org/Manual/latest/doc_html/cgal_manual/Nef_3_ref/Class_Nef_polyhedron3.html OGL_helper.h -- cgit v0.10.1 From 0473a0eff3ccaaf8632c41b4ee9ced2fd716ed3a Mon Sep 17 00:00:00 2001 From: don bright Date: Sun, 28 Oct 2012 12:43:53 -0500 Subject: put eps and inf back in diff --git a/src/PolySetCGALEvaluator.cc b/src/PolySetCGALEvaluator.cc index 245e97a..225ff05 100644 --- a/src/PolySetCGALEvaluator.cc +++ b/src/PolySetCGALEvaluator.cc @@ -28,6 +28,9 @@ This class converts one or more already 'flat' Nef3 polyhedra into a Nef2 polyhedron by stripping off the 'z' coordinates from the vertices. The resulting Nef2 poly is accumulated in the 'output_nefpoly2d' member variable. +The 'z' coordinates will either be all 0s, for an xy-plane intersected Nef3, +or, they will be a mixture of -eps and +eps, for a thin-box intersected Nef3. + Notes on CGAL's Nef Polyhedron2: 1. The 'mark' on a 2d Nef face is important when doing unions/intersections. @@ -160,8 +163,10 @@ PolySet *PolySetCGALEvaluator::evaluatePolySet(const ProjectionNode &node) PRINT("Trying alternative intersection using very large thin box: "); std::vector pts; // dont use z of 0. there are bugs in CGAL. - CGAL_Point_3 minpt( -1e8, -1e8, -0.001 ); - CGAL_Point_3 maxpt( 1e8, 1e8, 0.001 ); + double inf = 1e8; + double eps = 0.001; + CGAL_Point_3 minpt( -inf, -inf, -eps ); + CGAL_Point_3 maxpt( inf, inf, eps ); CGAL_Iso_cuboid_3 bigcuboid( minpt, maxpt ); for ( int i=0;i<8;i++ ) pts.push_back( bigcuboid.vertex(i) ); CGAL_Polyhedron bigbox; -- cgit v0.10.1 From ec41b7e4321986140bffdb87ca7efefb1d57f881 Mon Sep 17 00:00:00 2001 From: don bright Date: Sun, 28 Oct 2012 13:01:10 -0500 Subject: move failure-detection so there is only one reset of error behavior. diff --git a/src/PolySetCGALEvaluator.cc b/src/PolySetCGALEvaluator.cc index 225ff05..6ff1e35 100644 --- a/src/PolySetCGALEvaluator.cc +++ b/src/PolySetCGALEvaluator.cc @@ -104,10 +104,10 @@ public: *(output_nefpoly2d) *= *(tmpnef2d); } - log << "\n\n" - << OpenSCAD::dump_svg( *tmpnef2d ) << "\n" - << "\n\n" - << OpenSCAD::dump_svg( *output_nefpoly2d ) << "\n"; + log << "\n\n" + << OpenSCAD::dump_svg( *tmpnef2d ) << "\n" + << "\n\n" + << OpenSCAD::dump_svg( *output_nefpoly2d ) << "\n"; contour_counter++; } else { @@ -176,17 +176,10 @@ PolySet *PolySetCGALEvaluator::evaluatePolySet(const ProjectionNode &node) } catch (const CGAL::Failure_exception &e) { PRINTB("CGAL error in projection node during bigbox intersection: %s", e.what()); - sum.reset(); + sum.p3.reset( new CGAL_Nef_polyhedron3() ); } } - CGAL::set_error_behaviour(old_behaviour); - - if (sum.empty()) { - PRINT("WARNING: Projection failed."); - return NULL; - } - // remove z coordinates to make CGAL_Nef_polyhedron2 log << OpenSCAD::svg_header( 480, 100000 ) << "\n"; try { @@ -204,16 +197,20 @@ PolySet *PolySetCGALEvaluator::evaluatePolySet(const ProjectionNode &node) } log << "\n"; } - log << "\n"; - nef_poly.p2 = zremover.output_nefpoly2d; nef_poly.dim = 2; } catch (const CGAL::Failure_exception &e) { PRINTB("CGAL error in projection node while flattening: %s", e.what()); } + log << "\n"; CGAL::set_error_behaviour(old_behaviour); + if ( sum.p3->is_empty() ) { + PRINT("WARNING: projection() failed."); + return NULL; + } + // Extract polygons in the XY plane, ignoring all other polygons // FIXME: If the polyhedron is really thin, there might be unwanted polygons // in the XY plane, causing the resulting 2D polygon to be self-intersection diff --git a/src/svg.cc b/src/svg.cc index f30e4b8..cbc5695 100644 --- a/src/svg.cc +++ b/src/svg.cc @@ -8,10 +8,10 @@ namespace OpenSCAD { // SVG code // currently for debugging, not necessarily pretty or useful for users. (yet) -std::string svg_header() +std::string svg_header( int widthpx, int heightpx ) { std::stringstream out; - out << ""; return out.str(); } diff --git a/src/svg.h b/src/svg.h index 2351288..91d9bc6 100644 --- a/src/svg.h +++ b/src/svg.h @@ -9,11 +9,13 @@ namespace OpenSCAD { // currently for debugging, not necessarily pretty or useful for users. (yet) +#define SVG_PXW 480; +#define SVG_PXH 480; static int svg_cursor_py = 0; -static int svg_px_width = 480; -static int svg_px_height = 480; +static int svg_px_width = SVG_PXW; +static int svg_px_height = SVG_PXH; -std::string svg_header(); +std::string svg_header( int widthpx = SVG_PXW, int heightpx = SVG_PXH ); std::string svg_label( std::string s ); std::string svg_border(); std::string svg_axes(); -- cgit v0.10.1 From 65c57886769b86cf785ab2049d32311c4c52126a Mon Sep 17 00:00:00 2001 From: Marius Kintel Date: Sun, 28 Oct 2012 14:04:21 -0400 Subject: Updated to CGAL-4.1 diff --git a/scripts/macosx-build-dependencies.sh b/scripts/macosx-build-dependencies.sh index cee1ce4..1036320 100755 --- a/scripts/macosx-build-dependencies.sh +++ b/scripts/macosx-build-dependencies.sh @@ -216,8 +216,9 @@ build_cgal() cd $BASEDIR/src rm -rf CGAL-$version if [ ! -f CGAL-$version.tar.gz ]; then - # 4.1-beta1 - curl -O https://gforge.inria.fr/frs/download.php/31348/CGAL-$version.tar.gz + # 4.1 + curl -O https://gforge.inria.fr/frs/download.php/31641/CGAL-$version.tar.gz + # 4.1-beta1 curl -O https://gforge.inria.fr/frs/download.php/31348/CGAL-$version.tar.gz # 4.0.2 curl -O https://gforge.inria.fr/frs/download.php/31175/CGAL-$version.tar.gz # 4.0 curl -O https://gforge.inria.fr/frs/download.php/30387/CGAL-$version.tar.gz # 3.9 curl -O https://gforge.inria.fr/frs/download.php/29125/CGAL-$version.tar.gz @@ -229,7 +230,7 @@ build_cgal() if $OPTION_32BIT; then CGAL_EXTRA_FLAGS=";i386" fi - cmake -DCMAKE_INSTALL_PREFIX=$DEPLOYDIR -DGMP_INCLUDE_DIR=$DEPLOYDIR/include -DGMP_LIBRARIES=$DEPLOYDIR/lib/libgmp.dylib -DGMPXX_LIBRARIES=$DEPLOYDIR/lib/libgmpxx.dylib -DGMPXX_INCLUDE_DIR=$DEPLOYDIR/include -DMPFR_INCLUDE_DIR=$DEPLOYDIR/include -DMPFR_LIBRARIES=$DEPLOYDIR/lib/libmpfr.dylib -DWITH_CGAL_Qt3=OFF -DWITH_CGAL_Qt4=OFF -DWITH_CGAL_ImageIO=OFF -DBUILD_SHARED_LIBS=TRUE -DCMAKE_OSX_DEPLOYMENT_TARGET="$MAC_OSX_VERSION_MIN" -DCMAKE_OSX_ARCHITECTURES="x86_64$CGAL_EXTRA_FLAGS" -DBOOST_ROOT=$DEPLOYDIR + cmake -DCMAKE_INSTALL_PREFIX=$DEPLOYDIR -DGMP_INCLUDE_DIR=$DEPLOYDIR/include -DGMP_LIBRARIES=$DEPLOYDIR/lib/libgmp.dylib -DGMPXX_LIBRARIES=$DEPLOYDIR/lib/libgmpxx.dylib -DGMPXX_INCLUDE_DIR=$DEPLOYDIR/include -DMPFR_INCLUDE_DIR=$DEPLOYDIR/include -DMPFR_LIBRARIES=$DEPLOYDIR/lib/libmpfr.dylib -DWITH_CGAL_Qt3=OFF -DWITH_CGAL_Qt4=OFF -DWITH_CGAL_ImageIO=OFF -DBUILD_SHARED_LIBS=TRUE -DCMAKE_OSX_DEPLOYMENT_TARGET="$MAC_OSX_VERSION_MIN" -DCMAKE_OSX_ARCHITECTURES="x86_64$CGAL_EXTRA_FLAGS" -DBOOST_ROOT=$DEPLOYDIR -DBoost_USE_MULTITHREADED=false make -j4 make install install_name_tool -id $DEPLOYDIR/lib/libCGAL.dylib $DEPLOYDIR/lib/libCGAL.dylib @@ -369,6 +370,6 @@ build_gmp 5.0.5 build_mpfr 3.1.1 build_boost 1.51.0 # NB! For CGAL, also update the actual download URL in the function -build_cgal 4.1-beta1 +build_cgal 4.1 build_glew 1.9.0 build_opencsg 1.3.2 -- cgit v0.10.1 From 45e5cdea69183374166484baa8cef47c40bfb722 Mon Sep 17 00:00:00 2001 From: don bright Date: Sun, 28 Oct 2012 13:08:41 -0500 Subject: fix typo diff --git a/src/svg.h b/src/svg.h index 91d9bc6..776595e 100644 --- a/src/svg.h +++ b/src/svg.h @@ -9,8 +9,8 @@ namespace OpenSCAD { // currently for debugging, not necessarily pretty or useful for users. (yet) -#define SVG_PXW 480; -#define SVG_PXH 480; +#define SVG_PXW 480 +#define SVG_PXH 480 static int svg_cursor_py = 0; static int svg_px_width = SVG_PXW; static int svg_px_height = SVG_PXH; -- cgit v0.10.1 From f54797cfbda8b7e667fd5294bbca3b885d1b18de Mon Sep 17 00:00:00 2001 From: don bright Date: Sun, 28 Oct 2012 20:22:04 +0100 Subject: fixes for test suite and gcc diff --git a/src/svg.cc b/src/svg.cc index cbc5695..e5130b0 100644 --- a/src/svg.cc +++ b/src/svg.cc @@ -7,6 +7,9 @@ namespace OpenSCAD { // SVG code // currently for debugging, not necessarily pretty or useful for users. (yet) +int svg_cursor_py = 0; +int svg_px_width = SVG_PXW; +int svg_px_height = SVG_PXH; std::string svg_header( int widthpx, int heightpx ) { @@ -70,8 +73,6 @@ CGAL_Point_2e project_svg_3to2( CGAL_Point_3 p, CGAL_Iso_cuboid_3 bbox ) CGAL_Point_2e project_svg_2to2( CGAL_Point_2e p, CGAL_Iso_rectangle_2e bbox ) { - double x = CGAL::to_double( p.x() ); - double y = CGAL::to_double( p.y() ); double screenw = svg_px_width; double screenh = svg_px_height; double borderw = screenw * 0.1618; @@ -172,10 +173,10 @@ public: { bbox = bounding_box( N ); } - void visit(CGAL_Nef_polyhedron3::Vertex_const_handle v) {} + void visit(CGAL_Nef_polyhedron3::Vertex_const_handle ) {} void visit(CGAL_Nef_polyhedron3::Halfedge_const_handle ) {} void visit(CGAL_Nef_polyhedron3::SHalfedge_const_handle ) {} - void visit(CGAL_Nef_polyhedron3::SHalfloop_const_handle shh ){} + void visit(CGAL_Nef_polyhedron3::SHalfloop_const_handle ) {} void visit(CGAL_Nef_polyhedron3::SFace_const_handle ) {} void visit( CGAL_Nef_polyhedron3::Halffacet_const_handle hfacet ) { diff --git a/src/svg.h b/src/svg.h index 776595e..828dc39 100644 --- a/src/svg.h +++ b/src/svg.h @@ -11,9 +11,9 @@ namespace OpenSCAD { #define SVG_PXW 480 #define SVG_PXH 480 -static int svg_cursor_py = 0; -static int svg_px_width = SVG_PXW; -static int svg_px_height = SVG_PXH; +extern int svg_cursor_py; +extern int svg_px_width; +extern int svg_px_height; std::string svg_header( int widthpx = SVG_PXW, int heightpx = SVG_PXH ); std::string svg_label( std::string s ); diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 68083ce..18f4469 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -425,7 +425,8 @@ set(CGAL_SOURCES ../src/CGALCache.cc ../src/PolySetCGALEvaluator.cc ../src/CGAL_Nef_polyhedron_DxfData.cc - ../src/cgaladv_minkowski2.cc) + ../src/cgaladv_minkowski2.cc + ../src/svg.cc) set(COMMON_SOURCES ../src/nodedumper.cc -- cgit v0.10.1 From 73d8d3cca4de55e81d47732f2b1f9507cc0d23b4 Mon Sep 17 00:00:00 2001 From: don bright Date: Mon, 29 Oct 2012 11:46:40 +0100 Subject: fix possible crash bug diff --git a/src/PolySetCGALEvaluator.cc b/src/PolySetCGALEvaluator.cc index 6ff1e35..8e08e19 100644 --- a/src/PolySetCGALEvaluator.cc +++ b/src/PolySetCGALEvaluator.cc @@ -176,10 +176,16 @@ PolySet *PolySetCGALEvaluator::evaluatePolySet(const ProjectionNode &node) } catch (const CGAL::Failure_exception &e) { PRINTB("CGAL error in projection node during bigbox intersection: %s", e.what()); - sum.p3.reset( new CGAL_Nef_polyhedron3() ); + sum.p3->clear(); } } + if ( sum.p3->is_empty() ) { + CGAL::set_error_behaviour(old_behaviour); + PRINT("WARNING: projection() failed."); + return NULL; + } + // remove z coordinates to make CGAL_Nef_polyhedron2 log << OpenSCAD::svg_header( 480, 100000 ) << "\n"; try { @@ -206,11 +212,6 @@ PolySet *PolySetCGALEvaluator::evaluatePolySet(const ProjectionNode &node) CGAL::set_error_behaviour(old_behaviour); - if ( sum.p3->is_empty() ) { - PRINT("WARNING: projection() failed."); - return NULL; - } - // Extract polygons in the XY plane, ignoring all other polygons // FIXME: If the polyhedron is really thin, there might be unwanted polygons // in the XY plane, causing the resulting 2D polygon to be self-intersection -- cgit v0.10.1 From 2c2446e7bac971efdf8c3398738c451edc4c360e Mon Sep 17 00:00:00 2001 From: Marius Kintel Date: Wed, 31 Oct 2012 11:34:54 -0400 Subject: Return on unknown ColorMode to avoid using uninitialized variable diff --git a/src/renderer.cc b/src/renderer.cc index db3204f..985b460 100644 --- a/src/renderer.cc +++ b/src/renderer.cc @@ -49,6 +49,7 @@ void Renderer::setColor(ColorMode colormode, GLint *shaderinfo) const col.setRgb(150, 150, 150, 128); break; default: + return; break; } float rgba[4]; -- cgit v0.10.1 From b796d6c554c67146cc37f347a3909c7d129cad4e Mon Sep 17 00:00:00 2001 From: Marius Kintel Date: Wed, 31 Oct 2012 11:35:36 -0400 Subject: robustification: Postfix traversals used uninitialized response variable. Bug wasn't trigged by the current codebase though diff --git a/src/traverser.cc b/src/traverser.cc index d9b3dc1..da8c679 100644 --- a/src/traverser.cc +++ b/src/traverser.cc @@ -16,7 +16,7 @@ Response Traverser::traverse(const AbstractNode &node, const State &state) State newstate = state; newstate.setNumChildren(node.getChildren().size()); - Response response; + Response response = ContinueTraversal; if (traversaltype == PREFIX || traversaltype == PRE_AND_POSTFIX) { newstate.setPrefix(true); newstate.setParent(state.parent()); -- cgit v0.10.1 From b04734cbf57db78d188cff9de9a4e33b2366534b Mon Sep 17 00:00:00 2001 From: Marius Kintel Date: Wed, 31 Oct 2012 12:30:20 -0400 Subject: updated MCAD diff --git a/libraries/MCAD b/libraries/MCAD index fa26564..9af8990 160000 --- a/libraries/MCAD +++ b/libraries/MCAD @@ -1 +1 @@ -Subproject commit fa265644af9b720557414125fd5ba26981b97576 +Subproject commit 9af89906fa87e2c7fa21f914f00f3fe3879c69f3 -- cgit v0.10.1 From cd894cbbc3d66449232a0ec433b0aff37a4129f7 Mon Sep 17 00:00:00 2001 From: John-Paul Robinson Date: Mon, 26 Nov 2012 16:47:02 -0600 Subject: Added difference test for something from nothing The difference tests all subtract objects from an existing object but if there is no existing object as the first argument the results are inconsistent across Mac and Linux platforms. Added a test to highlight this condition. diff --git a/testdata/scad/features/difference-tests.scad b/testdata/scad/features/difference-tests.scad index 3bcd9e5..186772f 100644 --- a/testdata/scad/features/difference-tests.scad +++ b/testdata/scad/features/difference-tests.scad @@ -28,3 +28,8 @@ translate([24,0,0]) difference() { cube([10,10,10], center=true); translate([0,0,6.99]) cylinder(r=4, h=4, center=true); } + +translate([24,12,0]) difference() { + cube([0,10,10], center=true); + # cylinder(r=4, h=20, center=true); +} -- cgit v0.10.1 From d57029a52ba6a815ac5c9cc6c5f4dc7205fcc8cd Mon Sep 17 00:00:00 2001 From: don bright Date: Mon, 3 Dec 2012 05:16:15 +0100 Subject: fix bug where if $MXEDIR didn't already exist, build failed diff --git a/scripts/mingw-x-build-dependencies.sh b/scripts/mingw-x-build-dependencies.sh index 76bb7d4..ee51848 100755 --- a/scripts/mingw-x-build-dependencies.sh +++ b/scripts/mingw-x-build-dependencies.sh @@ -41,8 +41,9 @@ if [ ! -e $BASEDIR ]; then fi if [ ! -e $MXEDIR ]; then - echo "Downloading MXE into " $MXEDIR + mkdir -p $MXEDIR cd $MXEDIR/.. + echo "Downloading MXE into " $PWD git clone git://github.com/mxe/mxe.git fi -- cgit v0.10.1 From f07edc4f053b65e567230645ccbcb8aa335b9f18 Mon Sep 17 00:00:00 2001 From: don bright Date: Mon, 3 Dec 2012 08:47:54 +0100 Subject: allow 'mingw32' option. dont use OSTYPE. fix docs. allow NUMCPU multicore build diff --git a/scripts/release-common.sh b/scripts/release-common.sh index 62f8ed8..6cb5b97 100755 --- a/scripts/release-common.sh +++ b/scripts/release-common.sh @@ -1,15 +1,16 @@ #!/bin/bash # -# This script creates a binary release of OpenSCAD. -# This should work under Mac OS X, Windows (msys), and Linux cross-compiling -# for windows using mingw-cross-env (use like: OSTYPE=mingw-cross-env release-common.sh). -# Linux support pending. -# The script will create a file called openscad-.zip -# in the current directory (or in the $DEPLOYDIR of a mingw cross build) +# This script creates a binary release of OpenSCAD. This should work +# under Mac OS X, Windows (msys), Linux 32, Linux 64, and Linux->Win32 MXE +# cross-build. # -# Usage: release-common.sh [-v ] [-c] -# -v Version string (e.g. -v 2010.01) -# -c Build with commit info +# The script will create a file called openscad-. in +# the current directory (or under ./mingw32) +# +# Usage: release-common.sh [-v ] [-c] [-x32] +# -v Version string (e.g. -v 2010.01) +# -c Build with commit info +# -mingw32 Cross-compile for win32 using MXE # # If no version string is given, todays date will be used (YYYY-MM-DD) # If no make target is given, release will be used on Windows, none one Mac OS X @@ -42,11 +43,18 @@ elif [[ $OSTYPE == "linux-gnu" ]]; then ARCH=32 fi echo "Detected ARCH: $ARCH" -elif [[ $OSTYPE == "mingw-cross-env" ]]; then +fi + +if [ "`echo $* | grep mingw32`" ]; then OS=LINXWIN fi -echo "Detected OS: $OS" +if [ $OS ]; then + echo "Detected OS: $OS" +else + echo "Error: Couldn't detect OSTYPE" + exit +fi while getopts 'v:c' c do @@ -147,14 +155,19 @@ case $OS in ;; esac +if [ ! $NUMCPU ]; then + echo "note: you can 'export NUMCPU=x' for multi-core compiles (x=number)"; + NUMCPU=2 +fi + case $OS in LINXWIN) - # make -jx sometimes has problems with parser_yacc + # dont use paralell builds, it can error-out on parser_yacc. cd $DEPLOYDIR && make $TARGET cd $OPENSCADDIR ;; *) - make -j2 $TARGET + make -j$NUMCPU $TARGET ;; esac -- cgit v0.10.1 From b64139788c0679b572c68045d28a4933dcc44d36 Mon Sep 17 00:00:00 2001 From: don bright Date: Mon, 3 Dec 2012 08:52:21 +0100 Subject: fix tabs in svg.cc diff --git a/src/svg.cc b/src/svg.cc index e5130b0..ff13332 100644 --- a/src/svg.cc +++ b/src/svg.cc @@ -96,7 +96,7 @@ std::string dump_cgal_nef_polyhedron2_face_svg( bool mark, CGAL_Iso_rectangle_2e bbox ) { - std::stringstream out; + std::stringstream out; CGAL_For_all(c1, c2) { if ( explorer.is_standard( explorer.target(c1) ) ) { CGAL_Point_2e source = explorer.point( explorer.source( c1 ) ); @@ -106,7 +106,7 @@ std::string dump_cgal_nef_polyhedron2_face_svg( double mod=0; if (color=="green") mod=10; out << " \n"; - out << " \n"; out << svg_border() << "\n" << svg_axes() << "\n"; svg_cursor_py += svg_px_height; for ( i = explorer.faces_begin(); i!= explorer.faces_end(); ++i ) { - out << " \n"; - CGAL_Nef_polyhedron2::Explorer::Halfedge_around_face_const_circulator c1 - = explorer.face_cycle( i ), c2 ( c1 ); - out << dump_cgal_nef_polyhedron2_face_svg( c1, c2, explorer, "red", i->mark(), bbox ); - - CGAL_Nef_polyhedron2::Explorer::Hole_const_iterator j; - for ( j = explorer.holes_begin( i ); j!= explorer.holes_end( i ); ++j ) { - out << " \n"; - CGAL_Nef_polyhedron2::Explorer::Halfedge_around_face_const_circulator c3( j ), c4 ( c3 ); - out << dump_cgal_nef_polyhedron2_face_svg( c3, c4, explorer, "green", j->mark(), bbox ); - out << " \n"; - } - out << " \n"; - } - out << ""; + out << " \n"; + CGAL_Nef_polyhedron2::Explorer::Halfedge_around_face_const_circulator c1 + = explorer.face_cycle( i ), c2 ( c1 ); + out << dump_cgal_nef_polyhedron2_face_svg( c1, c2, explorer, "red", i->mark(), bbox ); + + CGAL_Nef_polyhedron2::Explorer::Hole_const_iterator j; + for ( j = explorer.holes_begin( i ); j!= explorer.holes_end( i ); ++j ) { + out << " \n"; + CGAL_Nef_polyhedron2::Explorer::Halfedge_around_face_const_circulator c3( j ), c4 ( c3 ); + out << dump_cgal_nef_polyhedron2_face_svg( c3, c4, explorer, "green", j->mark(), bbox ); + out << " \n"; + } + out << " \n"; + } + out << ""; std::string tmp = out.str(); boost::replace_all( tmp, "'", "\"" ); return tmp; @@ -219,29 +219,29 @@ public: std::string dump_svg( const CGAL_Nef_polyhedron3 &N ) { - std::stringstream out; + std::stringstream out; out << svg_header() << "\n" << svg_border() << "\n" << svg_axes() << "\n"; out << "\n"; - CGAL_Nef_polyhedron3::Volume_const_iterator c; - CGAL_forall_volumes(c,N) { - out << " \n"; - out << " \n"; - CGAL_Nef_polyhedron3::Shell_entry_const_iterator it; - CGAL_forall_shells_of(it,c) { - out << " \n"; - NefPoly3_dumper_svg dumper_svg(N); - N.visit_shell_objects(CGAL_Nef_polyhedron3::SFace_const_handle(it), dumper_svg ); + CGAL_Nef_polyhedron3::Volume_const_iterator c; + CGAL_forall_volumes(c,N) { + out << " \n"; + out << " \n"; + CGAL_Nef_polyhedron3::Shell_entry_const_iterator it; + CGAL_forall_shells_of(it,c) { + out << " \n"; + NefPoly3_dumper_svg dumper_svg(N); + N.visit_shell_objects(CGAL_Nef_polyhedron3::SFace_const_handle(it), dumper_svg ); out << dumper_svg.out.str(); - out << " \n"; - } - out << " \n"; - } - out << "\n"; + out << " \n"; + } + out << " \n"; + } + out << "\n"; out << ""; std::string tmp = out.str(); boost::replace_all( tmp, "'", "\"" ); - return tmp; + return tmp; } } // namespace -- cgit v0.10.1 From 0778a55a40fb7afe0d90b9f01d32fee47426c9a3 Mon Sep 17 00:00:00 2001 From: don bright Date: Mon, 3 Dec 2012 08:59:57 +0100 Subject: actually assign copyright to Marius + Clifford, to eliminate any problems with Debian. diff --git a/scripts/linux-build-dependencies.sh b/scripts/linux-build-dependencies.sh index be678d3..5e361df 100755 --- a/scripts/linux-build-dependencies.sh +++ b/scripts/linux-build-dependencies.sh @@ -1,8 +1,8 @@ #!/bin/sh -e -# test_pretty_print copyright 2012 don bright. released under the GPL 2, or +# linux-build-dependencies by don bright 2012. copyright assigned to +# Marius Kintel and Clifford Wolf, 2012. released under the GPL 2, or # later, as described in the file named 'COPYING' in OpenSCAD's project root. -# permission to change this license is given to Marius Kintel & Clifford Wolf # # This script builds all library dependencies of OpenSCAD for Linux diff --git a/src/boosty.h b/src/boosty.h index 87260ff..6ec417a 100644 --- a/src/boosty.h +++ b/src/boosty.h @@ -1,6 +1,6 @@ -// boosty.h copyright 2012 don bright. released under the GPL 2, or later, -// as described in the file named 'COPYING' in OpenSCAD's project root. -// permission is given to Marius Kintel & Clifford Wolf to change this license. +// boosty.h by don bright 2012. Copyright assigned to Marius Kintel and +// Clifford Wolf 2012. Released under the GPL 2, or later, as described in +// the file named 'COPYING' in OpenSCAD's project root. #ifndef boosty_h_ #define boosty_h_ diff --git a/src/version_check.h b/src/version_check.h index a9556e9..92b00db 100644 --- a/src/version_check.h +++ b/src/version_check.h @@ -1,6 +1,6 @@ -// version_check.h copyright 2012 don bright. released under the GPL 2, or -// later, as described in the file named 'COPYING' in OpenSCAD's project root. -// permission to change this license is given to Marius Kintel & Clifford Wolf +// version_check.h by don bright 2012. Copyright assigned to Marius Kintel and +// Clifford Wolf 2012. Released under the GPL 2, or later, as described in +// the file named 'COPYING' in OpenSCAD's project root. /* This file will check versions of libraries at compile time. If they are too old, the user will be warned. If the user wishes to force diff --git a/tests/test_pretty_print.py b/tests/test_pretty_print.py index 8c57f1c..a2a04ed 100755 --- a/tests/test_pretty_print.py +++ b/tests/test_pretty_print.py @@ -1,8 +1,8 @@ #!/usr/bin/python -# test_pretty_print copyright 2012 don bright. released under the GPL 2, or -# later, as described in the file named 'COPYING' in OpenSCAD's project root. -# permission to change this license is given to Marius Kintel & Clifford Wolf +# test_pretty_print by don bright 2012. Copyright assigned to Marius Kintel and +# Clifford Wolf 2012. Released under the GPL 2, or later, as described in +# the file named 'COPYING' in OpenSCAD's project root. # # This program 'pretty prints' the ctest output, namely -- cgit v0.10.1 From 406bf8a3a6793d0687e84872cc9b0544a8f01f80 Mon Sep 17 00:00:00 2001 From: don bright Date: Mon, 3 Dec 2012 09:08:11 +0100 Subject: clarify mingw32 usage in docs & in 'print usage' diff --git a/scripts/release-common.sh b/scripts/release-common.sh index 6cb5b97..4a26f09 100755 --- a/scripts/release-common.sh +++ b/scripts/release-common.sh @@ -17,10 +17,13 @@ # # The commit info will extracted from git and be passed to qmake as OPENSCAD_COMMIT # to identify a build in the about box. +# +# The mingw32 cross compile depends on the mxe tools + dependencies. Please +# see scripts/*mingw-* & the OpenSCAD manual for more information. printUsage() { - echo "Usage: $0 -v -c + echo "Usage: $0 -v -c -mingw32 echo echo " Example: $0 -v 2010.01 } -- cgit v0.10.1 From 5624a0e426b4d31721da9c5a633f2ac40de261a6 Mon Sep 17 00:00:00 2001 From: don bright Date: Mon, 3 Dec 2012 20:04:20 -0600 Subject: hand code html to remove qt cruft. makes it easier to change, and easier to spit out to cmdline (eventually) diff --git a/src/AboutDialog.h b/src/AboutDialog.h index 1ae6533..2211e63 100644 --- a/src/AboutDialog.h +++ b/src/AboutDialog.h @@ -16,6 +16,9 @@ public: this->aboutText->setOpenExternalLinks(true); QUrl flattr_qurl(":icons/flattr.png" ); this->aboutText->loadResource( QTextDocument::ImageResource, flattr_qurl ); + QString tmp = this->aboutText->toHtml(); + tmp.replace("__VERSION__",QString(TOSTRING(OPENSCAD_VERSION))); + this->aboutText->setHtml(tmp); } }; diff --git a/src/AboutDialog.html b/src/AboutDialog.html index e2a6264..357a6df 100644 --- a/src/AboutDialog.html +++ b/src/AboutDialog.html @@ -1,77 +1,132 @@ - -

-


-

OpenSCAD is Copyright (C) 2009-2012 Marius Kintel <marius@kintel.net> and Clifford Wolf <clifford@clifford.at>

-


-

License

-


-

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

-


-

Please visit this link for a copy of the license: GPL 2.0

-


-

Tools & Libraries used

-


-

GNU GMP

-

GNU MPFR

-

CGAL

-

Eigen2

-

OpenCSG

-

OpenGL

-

GLEW

-

Qt Toolkit

-

Boost

-

Bison

-

Flex

-

CMake

-

LodePNG

-

MingW

-

MXE

-

Linux

-

Mac OSX

-

C++, GCC, clang

-

python

-

Nullsoft installer

-


-

Acknowledgements

-


-

OpenSCAD Github Project members (public):

-


-

Marius Kintel

-

Clifford Wolf

-

Giles Bathgate

-

Brad Pitcher

-


-

Debian maintainer:

-


-

Christian M. Amsüss

-


-

Patches:

-


-

meta23

-

jasonblewis

-

gregjurman

-

brianolson

-

tjhowse

-

logxen (Mark A Cooper)

-

iamwilhelm (Wil Chung)

-

clothbot (Andrew Plumb)

-

colah (Christopher Olah)

-

-

Bug reports:

-

-

nop head, Triffid Hunter, Len Trigg, Kliment Yanev, Christian Siefkes, Whosawhatsis, MichaelAtOz, mrhdias, ibyte8bits, Koen Kooi, Tomas Mudrunka, knuds, cadr, mshearn, Hans L, 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 ... and many others

-


-

Hosting & resources

-


-

Github source repository

-


-

Rock Linux mailing list

-


-

Thingiverse

-

-

Laurent Guerby and the GCC Compile Farm, with OSUOSL, IBM, IRILL, Intel, FSF France, and AMD.

-


-

Apologies to anyone accidentally left out.

+ + + + + + + + +

+ +

+ +

+ OpenSCAD version __VERSION__ +

+ +

+ Copyright (C) 2009-2012 Marius Kintel <marius@kintel.net> and Clifford Wolf <clifford@clifford.at> +

+ +

+ License +

+ +

+ This program is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or + (at your option) any later version. +

+

+ Please visit this link for a copy of the license: GPL 2.0 +

+

+ Tools & Libraries used +

+ + +
  • GNU GMP +
  • GNU MPFR +
  • CGAL +
  • Eigen2 +
  • OpenCSG +
  • OpenGL +
  • GLEW +
  • Qt Toolkit +
  • Boost +
  • Bison +
  • Flex +
  • CMake +
  • MingW +
  • LodePNG +
  • MXE +
  • Linux +
  • Mac OSX +
  • C++, GCC, clang +
  • python +
  • Nullsoft installer + +

    + +

    + Acknowledgements +

    + +

    + OpenSCAD Github Project members (public) +
    + +

  • Marius Kintel +
  • Clifford Wolf +
  • Giles Bathgate +
  • Brad Pitcher +
  • Don Bright + +

    + +

    + Debian maintainer: + Christian M. Amsuess +

    + +

    + Patches +
    + +

  • meta23 +
  • jasonblewis +
  • gregjurman +
  • brianolson +
  • tjhowse +
  • logxen +
  • iamwilhelm +
  • clothbot +
  • colah + +

    + +

    + Mailing list, bug reports, testing, &c +

    + nop head, Triffid Hunter, Len Trigg, Kliment Yanev, Christian Siefkes, Whosawhatsis, MichaelAtOz, Tony Buser, + mrhdias, ibyte8bits, Koen Kooi, Tomas Mudrunka, knuds, cadr, mshearn, Hans L, 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 ... and many others +

    + +

    + Hosting & resources +
    + +

  • Github +
  • Rock Linux +
  • Thingiverse + +

    + Laurent Guerby and the + GCC Compile Farm, with + OSUOSL, IRILL, + FSF France, AMD, + Intel, IBM, &c. +

    +

    + +

    + Apologies to anyone left out. Please file an issue on OpenSCAD's github if you know of someone who belongs here. +

    + + + -- cgit v0.10.1 From 29c22aa55dff1a1b422bf92b2b6f7852e7be21c4 Mon Sep 17 00:00:00 2001 From: don bright Date: Mon, 3 Dec 2012 20:22:39 -0600 Subject: tidy up html for QTextBrowser. add shortcut for 'help' diff --git a/src/AboutDialog.html b/src/AboutDialog.html index 357a6df..5976447 100644 --- a/src/AboutDialog.html +++ b/src/AboutDialog.html @@ -1,39 +1,45 @@ + + + - + +

    - +

    - OpenSCAD version __VERSION__ +OpenSCAD version __VERSION__

    - Copyright (C) 2009-2012 Marius Kintel <marius@kintel.net> and Clifford Wolf <clifford@clifford.at> +Copyright (C) 2009-2012 Marius Kintel <marius@kintel.net> and Clifford Wolf <clifford@clifford.at>

    - License +License

    - This program is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by the - Free Software Foundation; either version 2 of the License, or - (at your option) any later version. +This program is free software; you can redistribute it and/or modify it +under the terms of the GNU General Public License as published by the +Free Software Foundation; either version 2 of the License, or +(at your option) any later version.

    - Please visit this link for a copy of the license: GPL 2.0 +Please visit this link for a copy of the license: GPL 2.0

    - Tools & Libraries used +Tools & Libraries used

    @@ -61,71 +67,75 @@

    - Acknowledgements +Acknowledgements

    - OpenSCAD Github Project members (public) -
    - -

  • Marius Kintel -
  • Clifford Wolf -
  • Giles Bathgate -
  • Brad Pitcher -
  • Don Bright - +OpenSCAD Github Project members (public)

    + +
  • Marius Kintel +
  • Clifford Wolf +
  • Giles Bathgate +
  • Brad Pitcher +
  • Don Bright + +

    - Debian maintainer: +Debian maintainer: Christian M. Amsuess

    - Patches -
    - -

  • meta23 -
  • jasonblewis -
  • gregjurman -
  • brianolson -
  • tjhowse -
  • logxen -
  • iamwilhelm -
  • clothbot -
  • colah - +Patches

    + +
  • meta23 +
  • jasonblewis +
  • gregjurman +
  • brianolson +
  • tjhowse +
  • logxen +
  • iamwilhelm +
  • clothbot +
  • colah + + + +

    +Mailing list, bug reports, testing, &c +

    + +nop head, Triffid Hunter, Len Trigg, Kliment Yanev, Christian Siefkes, +Whosawhatsis, MichaelAtOz, Tony Buser, mrhdias, ibyte8bits, Koen Kooi, +Tomas Mudrunka, knuds, cadr, mshearn, Hans L, 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 ... and many others +

    - Mailing list, bug reports, testing, &c -

    - nop head, Triffid Hunter, Len Trigg, Kliment Yanev, Christian Siefkes, Whosawhatsis, MichaelAtOz, Tony Buser, - mrhdias, ibyte8bits, Koen Kooi, Tomas Mudrunka, knuds, cadr, mshearn, Hans L, 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 ... and many others +Hosting & resources

    + +
  • Github +
  • Rock Linux +
  • Thingiverse + +

    - Hosting & resources -
    - -

  • Github -
  • Rock Linux -
  • Thingiverse - -

    - Laurent Guerby and the - GCC Compile Farm, with - OSUOSL, IRILL, - FSF France, AMD, - Intel, IBM, &c. -

    +Laurent Guerby and the +GCC Compile Farm, with +OSUOSL, IRILL, +FSF France, AMD, +Intel, IBM, &c.

    - Apologies to anyone left out. Please file an issue on OpenSCAD's github if you know of someone who belongs here. +Apologies to anyone left out. Please file an issue on OpenSCAD's github if you know of someone who belongs here.

    diff --git a/src/MainWindow.ui b/src/MainWindow.ui index 13bb226..f71ac96 100644 --- a/src/MainWindow.ui +++ b/src/MainWindow.ui @@ -217,7 +217,7 @@ - Help + &Help -- cgit v0.10.1 From fcaa4811e20121c15d4d75ae1cc31ef93d44cf81 Mon Sep 17 00:00:00 2001 From: don bright Date: Mon, 3 Dec 2012 20:38:46 -0600 Subject: move flattr image to right-hand side. diff --git a/src/AboutDialog.html b/src/AboutDialog.html index 5976447..371ea46 100644 --- a/src/AboutDialog.html +++ b/src/AboutDialog.html @@ -3,8 +3,8 @@ + a normal browser alone is not a sufficient test. Just edit this file and rerun + make to do your testing. --> @@ -14,7 +14,7 @@

    - +

    -- cgit v0.10.1 From 03ef1a27eab727c122512b904cf93bb5fbd5f71d Mon Sep 17 00:00:00 2001 From: don bright Date: Tue, 4 Dec 2012 22:18:12 -0600 Subject: unify build scripts. introduce 'version checker' script. simplify instructions diff --git a/README.md b/README.md index 1f9fb53..d618f85 100644 --- a/README.md +++ b/README.md @@ -131,35 +131,29 @@ compilation process. After that, follow the Compilation instructions below. -### Building for newer Linux distributions +### Building for Linux/BSD -First, make sure that you have development tools installed to get GCC. -Then after you've cloned this git repository, use a package manager to -download packages for the dependency libraries listed above. Convenience -scripts are provided for some popular systems: +First, make sure that you have git installed. Then after you've cloned +this git repository, run the script that attempts to download the +dependency packages for your system: - Ubuntu, Debian: ./scripts/ubuntu-build-dependencies.sh - OpenSUSE: ./scripts/opensuse-build-dependencies.sh - Fedora: ./scripts/fedora-build-dependencies.sh + ./scripts/uni-get-dependencies.sh -Check your library versions to make sure they meet the minimum -requirements listed above. After that follow the Compilation -instructions below. +This will get the majority of necessary packages, although your +particular system may require you to manually install some. After installing +dependencies, check their versions. You can run this script to help you: -### Building for older Linux or building without root access + ./scripts/check-dependencies.sh -First, make sure that you have development tools installed to get GCC. -Then after you've cloned this git repository, run the script that sets -up the environment variables. +If some of yours are out of date, you can build newer versions automatically +into $HOME/openscad_deps with the following commands: source ./scripts/setenv-linbuild.sh - -Then run the script to download & compile all the prerequisite libraries above: - ./scripts/linux-build-dependencies.sh + ./scripts/check-dependencies.sh -Then add LD_LIBRARY_PATH=$HOME/openscad_deps to your ~/.bashrc -After that, follow the Compilation instructions below. +This may take several hours. If successfull, follow the Compilation +instructions below. If not, file an 'issue' on the OpenSCAD github. ### Building for Windows @@ -173,13 +167,13 @@ the script that sets up the environment variables. source ./scripts/setenv-mingw-xbuild.sh -Then run the script to download & compile all the prerequisite libraries above: +Then run the script to download & compile all the dependency libraries: ./scripts/mingw-x-build-dependencies.sh -Then skip the compilation instructions below. Instead, build an installer: +Then, build OpenSCAD and package it to an installer: - OSTYPE=mingw-cross-env ./scripts/release-common.sh + ./scripts/release-common.sh mingw32 ### Compilation diff --git a/scripts/check-dependencies.sh b/scripts/check-dependencies.sh new file mode 100755 index 0000000..536c46f --- /dev/null +++ b/scripts/check-dependencies.sh @@ -0,0 +1,588 @@ +# Determine which versions of dependency libraries and tools are +# available on the system. Compare these versions with the minimum parsed +# from README.md and print results. +# +# usage +# check-dependencies.sh # check version of all dependencies +# check-dependencies.sh debug # debug this script +# +# design +# Detection is done through stages and fallbacks in case of failure. +# +# 1st stage, search by parsing header files and/or binary output +# 2nd stage, search with pkg-config +# 3rd stage, search by parsing output of package systems like dpkg or yum +# +# Goal is portability and lack of complicated regex. +# Code style is 'pretend its python'. functions return strings under +# the $function_name_result variable. tmp variables are +# funcname_abbreviated_tmp. Local vars are not used for portability. +# +# todo +# look in /usr/local/ on linux +# if /usr/ and /usr/local/ on linux both hit, throw an error +# fallback- pkgconfig --exists, then --modversion +# fallback2 - pkg manager +# todo - use OPENSCAD_LIBRARIES ??? +# - print location found, how found??? +# +DEBUG= + +debug() +{ + if [ $DEBUG ]; then echo check-dependencies.sh: $* ; fi +} + + +eigen_sysver() +{ + debug eigen + eigpath= + eig3path=$1/include/eigen3/Eigen/src/Core/util/Macros.h + eig2path=$1/include/eigen2/Eigen/src/Core/util/Macros.h + if [ -e $eig3path ]; then eigpath=$eig3path; fi + if [ -e $eig2path ]; then eigpath=$eig2path; fi + debug $eig2path + if [ ! $eigpath ]; then return; fi + eswrld=`grep "define *EIGEN_WORLD_VERSION *[0-9]*" $eigpath | awk '{print $3}'` + esmaj=`grep "define *EIGEN_MAJOR_VERSION *[0-9]*" $eigpath | awk '{print $3}'` + esmin=`grep "define *EIGEN_MINOR_VERSION *[0-9]*" $eigpath | awk '{print $3}'` + eigen_sysver_result="$eswrld.$esmaj.$esmin" +} + +opencsg_sysver() +{ + debug opencsg_sysver + if [ ! -e $1/include/opencsg.h ]; then return; fi + ocsgver=`grep "define *OPENCSG_VERSION_STRING *[0-9x]*" $1/include/opencsg.h` + ocsgver=`echo $ocsgver | awk '{print $4}' | sed s/'"'//g | sed s/[^1-9.]//g` + opencsg_sysver_result=$ocsgver +} + +cgal_sysver() +{ + cgalpath=$1/include/CGAL/version.h + if [ ! -e $cgalpath ]; then return; fi + cgal_sysver_result=`grep "define *CGAL_VERSION *[0-9.]*" $cgalpath | awk '{print $3}'` +} + +boost_sysver() +{ + boostpath=$1/include/boost/version.hpp + if [ ! -e $boostpath ]; then return; fi + bsver=`grep 'define *BOOST_LIB_VERSION *[0-9_"]*' $boostpath | awk '{print $3}'` + bsver=`echo $bsver | sed s/'"'//g | sed s/'_'/'.'/g` + boost_sysver_result=$bsver +} + +mpfr_sysver() +{ + mpfrpath=$1/include/mpfr.h + if [ ! -e $mpfrpath ]; then return; fi + mpfrsver=`grep 'define *MPFR_VERSION_STRING *' $mpfrpath | awk '{print $3}'` + mpfrsver=`echo $mpfrsver | sed s/"-.*"// | sed s/'"'//g` + mpfr_sysver_result=$mpfrsver +} + +gmp_sysver() +{ + # on some systems you have VERSION in gmp-$arch.h not gmp.h. use gmp*.h + if [ ! -e $1/include ]; then return; fi + gmppaths=`ls $1/include | grep ^gmp` + if [ ! "$gmppaths" ]; then return; fi + for gmpfile in $gmppaths; do + gmppath=$1/include/$gmpfile + if [ "`grep __GNU_MP_VERSION $gmppath`" ]; then + gmpmaj=`grep "define *__GNU_MP_VERSION *[0-9]*" $gmppath | awk '{print $3}'` + gmpmin=`grep "define *__GNU_MP_VERSION_MINOR *[0-9]*" $gmppath | awk '{print $3}'` + gmppat=`grep "define *__GNU_MP_VERSION_PATCHLEVEL *[0-9]*" $gmppath | awk '{print $3}'` + fi + done + gmp_sysver_result="$gmpmaj.$gmpmin.$gmppat" +} + +qt4_sysver() +{ + qt4path=$1/include/qt4/QtCore/qglobal.h + if [ ! -e $qt4path ]; then return; fi + qt4ver=`grep 'define *QT_VERSION_STR *' $qt4path | awk '{print $3}'` + qt4ver=`echo $qt4ver | sed s/'"'//g` + qt4_sysver_result=$qt4ver +} + +glew_sysver() +{ + glew_sysver_result= # glew has no traditional version numbers +} + +imagemagick_sysver() +{ + if [ ! -x $1/bin/convert ]; then return; fi + imver=`$1/bin/convert --version | grep -i version` + imagemagick_sysver_result=`echo $imver | sed s/"[^0-9. ]"/" "/g | awk '{print $1}'` +} + +flex_sysver() +{ + flexbin=$1/bin/flex + if [ -x $1/bin/gflex ]; then flexbin=$1/bin/gflex; fi # openbsd + if [ ! -x $flexbin ]; then return ; fi + flex_sysver_result=`$flexbin --version | sed s/"[^0-9.]"/" "/g` +} + +bison_sysver() +{ + if [ ! -x $1/bin/bison ]; then return ; fi + bison_sysver_result=`$1/bin/bison --version | grep bison | sed s/"[^0-9.]"/" "/g` +} + +gcc_sysver() +{ + bingcc=$1/bin/gcc + if [ ! -x $1/bin/gcc ]; then bingcc=gcc; fi + if [ ! "`$bingcc --version`" ]; then return; fi + gccver=`$bingcc --version| grep -i gcc` + gccver=`echo $gccver | sed s/"[^0-9. ]"/" "/g | awk '{print $1}'` + gcc_sysver_result=$gccver +} + +git_sysver() +{ + if [ ! -x $1/bin/git ]; then return ; fi + git_sysver_result=`$1/bin/git --version | grep git | sed s/"[^0-9.]"/" "/g` +} + +curl_sysver() +{ + if [ ! -x $1/bin/curl ]; then return; fi + curl_sysver_result=`$1/bin/curl --version | grep curl | sed s/"[^0-9. ]"/" "/g | awk '{print $1}'` +} + +cmake_sysver() +{ + if [ ! -x $1/bin/cmake ]; then return ; fi + cmake_sysver_result=`$1/bin/cmake --version | grep cmake | sed s/"[^0-9.]"/" "/g` +} + +make_sysver() +{ + binmake=$1/bin/make + if [ -x $1/bin/gmake ]; then binmake=$1/bin/gmake ;fi + if [ ! -x $binmake ]; then return ;fi + make_sysver_result=`$binmake --version 2>&1 | grep -i 'gnu make' | sed s/"[^0-9.]"/" "/g` + if [ ! "`echo $make_sysver_result | grep [0-9]`" ]; then return; fi +} + +bash_sysver() +{ + if [ -x /bin/bash ]; then binbash=/bin/bash ;fi + if [ -x /usr/bin/bash ]; then binbash=/usr/bin/bash ;fi + if [ -x $1/bin/bash ]; then binbash=$1/bin/bash ;fi + if [ ! -x $binbash ]; then return; fi + bash_sysver_result=`$binbash --version | grep bash | sed s/"[^0-9. ]"/" "/g|awk '{print $1}'` +} + +python_sysver() +{ + if [ ! -x $1/bin/python ]; then return; fi + python_sysver_result=`$1/bin/python --version 2>&1 | awk '{print $2}'` +} + +set_default_package_map() +{ + glew=glew + boost=boost + eigen=eigen3 + imagemagick=imagemagick + make=make + python=python + opencsg=opencsg + cgal=cgal + bison=bison + gmp=gmp + mpfr=mpfr + bash=bash + flex=flex + gcc=gcc + cmake=cmake + curl=curl + git=git + qt4=qt4 +} + + +apt_pkg_search() +{ + debug apt_pkg_search $* + apt_pkg_search_result= + pkgname=$1 + dps_ver= + + # translate pkgname to apt packagename + set_default_package_map + for pn in cgal boost mpfr opencsg qt4; do eval $pn="lib"$pn"-dev" ; done + + # handle multiple version names of same package (ubuntu, debian, etc) + if [ $pkgname = glew ]; then + glewtest=`apt-cache search libglew-dev` + if [ "`echo $glewtest | grep glew1.6-dev`" ]; then glew=libglew1.6-dev; + elif [ "`echo $glewtest | grep glew1.5-dev`" ]; then glew=libglew1.5-dev; + elif [ "`echo $glewtest | grep glew-dev`" ]; then glew=libglew-dev; fi + elif [ $pkgname = gmp ]; then + if [ "`apt-cache search libgmp3-dev`" ]; then gmp=libgmp3-dev ;fi + if [ "`apt-cache search libgmp-dev`" ]; then gmp=libgmp-dev ;fi + fi + + debpkgname=`eval echo "$"$pkgname` + + if [ ! $debpkgname ]; then + debug "unknown package" $pkgname; return; + fi + + debug $pkgname ".deb name:" $debpkgname + if [ ! "`command -v dpkg`" ]; then + debug command dpkg not found. cannot search packages. + return + fi + + # examples of apt version strings + # cgal 4.0-4 gmp 2:5.0.5+dfsg bison 1:2.5.dfsg-2.1 cmake 2.8.9~rc1 + + if [ $pkgname = eigen ]; then + aps_null=`dpkg --status libeigen3-dev 2>&1` + if [ $? = 0 ]; then + debpkgname=libeigen3-dev + else + debpkgname=libeigen2-dev + fi + fi + + debug "test dpkg on $debpkgname" + testdpkg=`dpkg --status $debpkgname 2>&1` + if [ "$testdpkg" ]; then + #debug test dpkg: $testdpkg + if [ "`echo $testdpkg | grep -i version`" ]; then + dps_ver=`dpkg --status $debpkgname | grep -i ^version: | awk ' { print $2 }'` + debug version line from dpkg: $dps_ver + dps_ver=`echo $dps_ver | tail -1 | sed s/"[-~].*"// | sed s/".*:"// | sed s/".dfsg*"//` + debug version: $dps_ver + else + debug couldnt find version string after dpkg --status $debpkgname + fi + else + debug testdpkg failed on $debpkgname + fi + + # Available to be system + #dps_ver= + #debug "test apt-cache on $debpkgname" + # apt-cache show is flaky on older apt. dont run unless search is OK + #test_aptcache=`apt-cache search $debpkgname` + #if [ "$test_aptcache" ]; then + # test_aptcache=`apt-cache show $debpkgname` + # if [ ! "`echo $test_aptcache | grep -i no.packages`" ]; then + # ver=`apt-cache show $debpkgname | grep ^Version: | awk ' { print $2 }'` + # ver=`echo $ver | tail -1 | sed s/"[-~].*"// | sed s/".*:"// | sed s/".dfsg*"//` + # if [ $ver ] ; then vera=$ver ; fi + # fi + #fi + + apt_pkg_search_result="$dps_ver" +} + +set_fedora_package_map() +{ + cgal=CGAL-devel + eigen=eigen2-devel + qt4=qt-devel + imagemagick=ImageMagick + for pn in boost gmp mpfr glew; do eval $pn=$pn"-devel" ; done +} + +yum_pkg_search() +{ + yum_pkg_search_result= + pkgname=$1 + + set_default_package_map + set_fedora_package_map + fedora_pkgname=`eval echo "$"$pkgname` + + debug $pkgname". fedora name:" $fedora_pkgname + if [ ! $fedora_pkgname ]; then + debug "unknown package" $pkgname; return; + fi + + test_yum=`yum info $fedora_pkgname 2>&1` + if [ "$test_yum" ]; then + debug test_yum: $test_yum + ydvver=`yum info $fedora_pkgname 2>&1 | grep ^Version | awk '{print $3}' ` + if [ $ydvver ]; then ydvver=$ydvver ; fi + else + debug test_yum failed on $pkgname + fi + yum_pkg_search_result="$ydvver" +} + + +pkg_search() +{ + debug pkg_search $* + pkg_search_result= + + if [ "`command -v apt-get`" ]; then + apt_pkg_search $* + pkg_search_result=$apt_pkg_search_result + elif [ "`command -v yum`" ]; then + yum_pkg_search $* + pkg_search_result=$yum_pkg_search_result + else + echo unknown system type. cannot search packages. + fi +} + +pkg_config_search() +{ + debug pkg_config_search $* + pkg_config_search_result= + pcstmp= + if [ ! $1 ]; then return; fi + pkgname=$1 + + pkg-config --exists $pkgname 2>&1 + if [ $? = 0 ]; then + pkg_config_search_result=`pkg-config --modversion $pkgname` + else + debug pkg_config_search failed on $*, result of run was: $pcstmp + fi +} + + + + +get_minversion_from_readme() +{ + if [ -e README.md ]; then READFILE=README.md; fi + if [ -e ../README.md ]; then READFILE=../README.md; fi + if [ ! $READFILE ]; then echo "cannot find README.md"; exit; fi + debug get_minversion_from_readme $* + if [ ! $1 ]; then return; fi + depname=$1 + local grv_tmp= + debug $depname + # example--> * [CGAL (3.6 - 3.9)] (www.cgal.org) becomes 3.6 + # steps: eliminate *, find left (, find -, make 'x' into 0, delete junk + grv_tmp=`grep -i ".$depname.*([0-9]" $READFILE | sed s/"*"//` + debug $grv_tmp + grv_tmp=`echo $grv_tmp | awk -F"(" '{print $2}'` + debug $grv_tmp + grv_tmp=`echo $grv_tmp | awk -F"-" '{print $1}'` + debug $grv_tmp + grv_tmp=`echo $grv_tmp | sed s/"x"/"0"/g` + debug $grv_tmp + grv_tmp=`echo $grv_tmp | sed s/"[^0-9.]"//g` + debug $grv_tmp + get_minversion_from_readme_result=$grv_tmp +} + + +find_min_version() +{ + find_min_version_result= + fmvtmp= + if [ ! $1 ] ; then return; fi + fmvdep=$1 + get_minversion_from_readme $fmvdep + fmvtmp=$get_minversion_from_readme_result + if [ $fmvdep = "git" ]; then fmvtmp=1.5 ; fi + if [ $fmvdep = "curl" ]; then fmvtmp=6 ; fi + if [ $fmvdep = "make" ]; then fmvtmp=3 ; fi + if [ $fmvdep = "python" ]; then fmvtmp=2 ; fi + find_min_version_result=$fmvtmp +} + +vers_to_int() +{ + # change x.y.z.p into x0y0z0p for purposes of comparison with -lt or -gt + # it will work as long as the resulting int is less than 2.147 billion + # and y z and p are less than 99 + # 1.2.3.4 into 1020304 + # 1.11.0.12 into 1110012 + # 2011.2.3 into 20110020300 + # the resulting integer can be simply compared using -lt or -gt + vers_to_int_result= + if [ ! $1 ] ; then return ; fi + vtoi_ver=$1 + vtoi_test=`echo $vtoi_ver | sed s/"[^0-9.]"//g` + debug vers_to_int $* :: vtoi_ver: $vtoi_ver vtoi_test: $vtoi_test + if [ ! "$vtoi_test" = "$vtoi_ver" ]; then + debug failure in version-to-integer conversion. + debug '"'$vtoi_ver'"' has letters, etc in it. setting to 0 + vtoi_ver="0" + fi + vers_to_int_result=`echo $vtoi_ver | awk -F. '{print $1*1000000+$2*10000+$3*100+$4}'` + vtoi_ver= + vtoi_test= +} + + +version_less_than_or_equal() +{ + if [ ! $1 ]; then return; fi + if [ ! $2 ]; then return; fi + v1=$1 + v2=$2 + vers_to_int $v1 + v1int=$vers_to_int_result + vers_to_int $v2 + v2int=$vers_to_int_result + debug "v1, v2, v1int, v2int" , $v1, $v2, $v1int, $v2int + if [ $v1int -le $v2int ]; then + debug "v1 <= v2" + return 0 + else + debug "v1 > v2" + return 1 + fi + v1= + v2= + v1int= + v2int= +} + +compare_version() +{ + debug compare_version $* + compare_version_result="NotOK" + if [ ! $1 ] ; then return; fi + if [ ! $2 ] ; then return; fi + cvminver=$1 + cvinstver=$2 + cvtmp= + version_less_than_or_equal $cvminver $cvinstver + if [ $? = 0 ]; then + cvtmp="OK" + else + cvtmp="NotOK" + fi + compare_version_result=$cvtmp + cvtmp= +} + +pretty_print() +{ + debug pretty_print $* + + brightred="\033[1;31m" + red="\033[0;31m" + brown="\033[0;33m" + yellow="\033[1;33m" + white="\033[1;37m" + purple="\033[1;35m" + green="\033[0;32m" + cyan="\033[0;36m" + gray="\033[0;37m" + nocolor="\033[0m" + + ppstr="%s%-12s" + pp_format='{printf("'$ppstr$ppstr$ppstr$ppstr$nocolor'\n",$1,$2,$3,$4,$5,$6,$7,$8)}' + pp_title="$gray depname $gray minimum $gray system $gray OKness" + if [ $1 ]; then pp_dep=$1; fi + if [ $pp_dep = "title" ]; then + echo -e $pp_title | awk $pp_format + return ; + fi + + if [ $2 ]; then pp_minver=$2; else pp_minver="unknown"; fi + if [ $3 ]; then pp_sysver=$3; else pp_sysver="unknown"; fi + if [ $4 ]; then pp_compared=$4; else pp_compared="NotOK"; fi + + if [ $pp_compared = "NotOK" ]; then + pp_cmpcolor=$purple; + pp_ivcolor=$purple; + else + pp_cmpcolor=$green; + pp_ivcolor=$gray; + fi + echo -e $cyan $pp_dep $gray $pp_minver $pp_ivcolor $pp_sysver $pp_cmpcolor $pp_compared | awk $pp_format + pp_dep= + pp_minver= + pp_sysver= + pp_compared= +} + + + + +find_installed_version() +{ + debug find_installed_version $* + find_installed_version_result=unknown + fsv_tmp= + dep=$1 + + # try to find/parse headers and/or binary output + if [ ! $fsv_tmp ]; then + for syspath in "/opt" "/usr/pkg" "/usr" "/usr/local" $OPENSCAD_LIBRARIES; do + if [ -e $syspath ]; then + debug $dep"_sysver" $syspath + eval $dep"_sysver" $syspath + fsv_tmp=`eval echo "$"$dep"_sysver_result"` + fi + done + fi + + # use pkg-config to search + if [ ! $fsv_tmp ]; then + if [ "`command -v pkg-config`" ]; then + pkg_config_search $dep + fsv_tmp=$pkg_config_search_result + fi + fi + + # use the package system to search + if [ ! $fsv_tmp ]; then + pkg_search $dep + fsv_tmp=$pkg_search_result + fi + + if [ $fsv_tmp ]; then + find_installed_version_result=$fsv_tmp + fi +} + + + + + + +checkargs() +{ + for i in $*; do + if [ $i = "debug" ]; then DEBUG=1 ; fi + done +} + +main() +{ + deps="qt4 cgal gmp cmake mpfr boost opencsg glew eigen gcc" + deps="$deps python bison flex git curl make" + #deps="$deps imagemagick" # needs work, only needed for tests + #deps="eigen glew opencsg" # debug + pretty_print title + for dep in $deps; do + debug "processing $dep" + find_installed_version $dep + dep_sysver=$find_installed_version_result + find_min_version $dep + dep_minver=$find_min_version_result + compare_version $dep_minver $dep_sysver + dep_compare=$compare_version_result + pretty_print $dep $dep_minver $dep_sysver $dep_compare + done +} + +checkargs $* +main +exit 0 + diff --git a/scripts/fedora-build-dependencies.sh b/scripts/fedora-build-dependencies.sh deleted file mode 100755 index 7481a63..0000000 --- a/scripts/fedora-build-dependencies.sh +++ /dev/null @@ -1,29 +0,0 @@ -echo "Tested on Fedora 17. If this fails try 'old linux' build (see README.md)" -sleep 2 - -# Fedora 17 has CGAL 4 -#if [ "`yum list installed | grep -i cgal`" ]; then -# echo "Please make sure you have removed all cgal packages and retry" -# exit -#fi - -if [ "`yum list installed | grep -i opencsg`" ]; then - echo "Please make sure you have removed all opencsg packages and retry" - exit -fi - -sudo yum install qt-devel bison flex eigen2-devel \ - boost-devel mpfr-devel gmp-devel glew-devel CGAL-devel gcc pkgconfig git - -#echo "now copy/paste the following to install CGAL and OpenCSG from source:" -#echo "sudo BASEDIR=/usr/local ./scripts/linux-build-dependencies.sh cgal-use-sys-libs" - -echo -echo "Now copy/paste the following to install OpenCSG from source:" -echo -# https://bugzilla.redhat.com/show_bug.cgi?id=144967 -echo "sudo echo /usr/local/lib | sudo tee -a /etc/ld.so.conf.d/local.conf" -echo "sudo ldconfig" -echo "sudo BASEDIR=/usr/local ./scripts/linux-build-dependencies.sh opencsg" -echo - diff --git a/scripts/freebsd-build-dependencies.sh b/scripts/freebsd-build-dependencies.sh deleted file mode 100755 index 4ea61de..0000000 --- a/scripts/freebsd-build-dependencies.sh +++ /dev/null @@ -1,28 +0,0 @@ -#!/usr/local/bin/bash -e - -echo "Tested on FreeBSD 9. Please see README.md for info on older systems." - -if [ "`pkg_info | grep -i cgal `" ]; then - echo Stopping. Please remove any CGAL packages you have installed and restart - exit -fi - -if [ "`pkg_info | grep -i opencsg`" ]; then - echo Stopping. Please remove any OpenCSG packages you have installed and restart - exit -fi - -OPENSCADDIR=$PWD -if [ ! -f $OPENSCADDIR/openscad.pro ]; then - echo "Must be run from the OpenSCAD source root directory" - exit 0 -fi - -. ./scripts/setenv-freebsdbuild.sh - -pkg_add -r bison boost-libs cmake git bash eigen2 flex gmake gmp mpfr -pkg_add -r xorg libGLU libXmu libXi xorg-vfbserver glew -pkg_add -r qt4-corelib qt4-gui qt4-moc qt4-opengl qt4-qmake qt4-rcc qt4-uic - -BASEDIR=/usr/local ./scripts/linux-build-dependencies.sh cgal-use-sys-libs -BASEDIR=/usr/local ./scripts/linux-build-dependencies.sh opencsg diff --git a/scripts/linux-build-dependencies.sh b/scripts/linux-build-dependencies.sh deleted file mode 100755 index 5e361df..0000000 --- a/scripts/linux-build-dependencies.sh +++ /dev/null @@ -1,339 +0,0 @@ -#!/bin/sh -e - -# linux-build-dependencies by don bright 2012. copyright assigned to -# Marius Kintel and Clifford Wolf, 2012. released under the GPL 2, or -# later, as described in the file named 'COPYING' in OpenSCAD's project root. - -# -# This script builds all library dependencies of OpenSCAD for Linux -# -# This script must be run from the OpenSCAD source root directory -# -# Usage: linux-build-dependencies.sh -# -# Prerequisites: -# - wget or curl -# - Qt4 -# - -printUsage() -{ - echo "Usage: $0" - echo -} - -build_git() -{ - version=$1 - echo "Building git" $version "..." - cd $BASEDIR/src - rm -rf git-$version - if [ ! -f git-$version.tar.gz ]; then - curl -O http://git-core.googlecode.com/files/git-$version.tar.gz - fi - tar zxf git-$version.tar.gz - cd git-$version - ./configure --prefix=$DEPLOYDIR - make -j$NUMCPU - make install -} - -build_cmake() -{ - version=$1 - echo "Building cmake" $version "..." - cd $BASEDIR/src - rm -rf cmake-$version - if [ ! -f cmake-$version.tar.gz ]; then - curl -O http://www.cmake.org/files/v2.8/cmake-$version.tar.gz - fi - tar zxf cmake-$version.tar.gz - cd cmake-$version - mkdir build - cd build - ../configure --prefix=$DEPLOYDIR - make -j$NUMCPU - make install -} - -build_curl() -{ - version=$1 - echo "Building curl" $version "..." - cd $BASEDIR/src - rm -rf curl-$version - if [ ! -f curl-$version.tar.bz2 ]; then - wget http://curl.haxx.se/download/curl-$version.tar.bz2 - fi - tar xjf curl-$version.tar.bz2 - cd curl-$version - mkdir build - cd build - ../configure --prefix=$DEPLOYDIR - make -j$NUMCPU - make install -} - -build_gmp() -{ - version=$1 - echo "Building gmp" $version "..." - cd $BASEDIR/src - rm -rf gmp-$version - if [ ! -f gmp-$version.tar.bz2 ]; then - curl -O ftp://ftp.gmplib.org/pub/gmp-$version/gmp-$version.tar.bz2 - fi - tar xjf gmp-$version.tar.bz2 - cd gmp-$version - mkdir build - cd build - ../configure --prefix=$DEPLOYDIR --enable-cxx - make install -} - -build_mpfr() -{ - version=$1 - echo "Building mpfr" $version "..." - cd $BASEDIR/src - rm -rf mpfr-$version - if [ ! -f mpfr-$version.tar.bz2 ]; then - curl -O http://www.mpfr.org/mpfr-$version/mpfr-$version.tar.bz2 - fi - tar xjf mpfr-$version.tar.bz2 - cd mpfr-$version - mkdir build - cd build - ../configure --prefix=$DEPLOYDIR --with-gmp=$DEPLOYDIR - make install - cd .. -} - -build_boost() -{ - version=$1 - bversion=`echo $version | tr "." "_"` - echo "Building boost" $version "..." - cd $BASEDIR/src - rm -rf boost_$bversion - if [ ! -f boost_$bversion.tar.bz2 ]; then - curl -LO http://downloads.sourceforge.net/project/boost/boost/$version/boost_$bversion.tar.bz2 - fi - tar xjf boost_$bversion.tar.bz2 - cd boost_$bversion - # We only need certain portions of boost - ./bootstrap.sh --prefix=$DEPLOYDIR --with-libraries=thread,program_options,filesystem,system,regex - if [ $CXX ]; then - if [ $CXX = "clang++" ]; then - ./b2 -j$NUMCPU toolset=clang install - # ./b2 -j$NUMCPU toolset=clang cxxflags="-stdlib=libc++" linkflags="-stdlib=libc++" install - fi - else - ./b2 -j$NUMCPU - ./b2 install - fi -} - -build_cgal() -{ - version=$1 - echo "Building CGAL" $version "..." - cd $BASEDIR/src - rm -rf CGAL-$version - if [ ! -f CGAL-$version.tar.gz ]; then - #4.0.2 - curl -O https://gforge.inria.fr/frs/download.php/31174/CGAL-$version.tar.bz2 - # 4.0 curl -O https://gforge.inria.fr/frs/download.php/30387/CGAL-$version.tar.gz - # 3.9 curl -O https://gforge.inria.fr/frs/download.php/29125/CGAL-$version.tar.gz - # 3.8 curl -O https://gforge.inria.fr/frs/download.php/28500/CGAL-$version.tar.gz - # 3.7 curl -O https://gforge.inria.fr/frs/download.php/27641/CGAL-$version.tar.gz - fi - tar jxf CGAL-$version.tar.bz2 - cd CGAL-$version - if [ $2 = 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 - 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 - fi - make -j$NUMCPU - make install -} - -build_glew() -{ - version=$1 - echo "Building GLEW" $version "..." - cd $BASEDIR/src - rm -rf glew-$version - if [ ! -f glew-$version.tgz ]; then - curl -LO http://downloads.sourceforge.net/project/glew/glew/$version/glew-$version.tgz - fi - tar xzf glew-$version.tgz - cd glew-$version - mkdir -p $DEPLOYDIR/lib/pkgconfig - - # Fedora 64-bit - if [ -e /usr/lib64 ]; then - if [ "`ls /usr/lib64 | grep Xmu`" ]; then - echo "modifying glew makefile for 64 bit machine" - sed -ibak s/"\-lXmu"/"\-L\/usr\/lib64\/libXmu.so.6"/ config/Makefile.linux - fi - fi - - if [ $CC ]; then - if [ $CC = "clang" ]; then - echo "modifying glew makefile for clang" - sed -i s/\$\(CC\)/clang/ Makefile - fi - fi - - GLEW_DEST=$DEPLOYDIR make -j$NUMCPU - GLEW_DEST=$DEPLOYDIR make install -} - -build_opencsg() -{ - version=$1 - echo "Building OpenCSG" $version "..." - cd $BASEDIR/src - rm -rf OpenCSG-$version - if [ ! -f OpenCSG-$version.tar.gz ]; then - curl -O http://www.opencsg.org/OpenCSG-$version.tar.gz - fi - tar xzf OpenCSG-$version.tar.gz - cd OpenCSG-$version - sed -ibak s/example// opencsg.pro # examples might be broken without GLUT - - # Fedora 64-bit - if [ -e /usr/lib64 ]; then - if [ "`ls /usr/lib64 | grep Xmu`" ]; then - echo "modifying opencsg makefile for 64 bit machine" - sed -ibak s/"\-lXmu"/"\-L\/usr\/lib64\/libXmu.so.6"/ src/Makefile - fi - fi - - if [ `uname | grep FreeBSD` ]; then - sed -ibak s/X11R6/local/g src/Makefile - fi - - if [ "`command -v qmake-qt4`" ]; then - OPENCSG_QMAKE=qmake-qt4 - else - OPENCSG_QMAKE=qmake - fi - - if [ $CXX ]; then - if [ $CXX = "clang++" ]; then - cd $BASEDIR/src/OpenCSG-$version/src - $OPENCSG_QMAKE - cd $BASEDIR/src/OpenCSG-$version - $OPENCSG_QMAKE - fi - else - $OPENCSG_QMAKE - fi - - make - - cp -av lib/* $DEPLOYDIR/lib - cp -av include/* $DEPLOYDIR/include - cd $OPENSCADDIR -} - -build_eigen() -{ - version=$1 - echo "Building eigen" $version "..." - cd $BASEDIR/src - rm -rf eigen-$version - EIGENDIR="none" - if [ $version = "2.0.17" ]; then EIGENDIR=eigen-eigen-b23437e61a07; fi - if [ $version = "3.1.1" ]; then EIGENDIR=eigen-eigen-43d9075b23ef; fi - if [ $EIGENDIR = "none" ]; then - echo Unknown eigen version. Please edit script. - exit 1 - fi - rm -rf ./$EIGENDIR - if [ ! -f eigen-$version.tar.bz2 ]; then - curl -LO http://bitbucket.org/eigen/eigen/get/$version.tar.bz2 - mv $version.tar.bz2 eigen-$version.tar.bz2 - fi - tar xjf eigen-$version.tar.bz2 - ln -s ./$EIGENDIR eigen-$version - cd eigen-$version - mkdir build - cd build - cmake -DCMAKE_INSTALL_PREFIX=$DEPLOYDIR .. - make -j$NUMCPU - make install -} - - -OPENSCADDIR=$PWD -if [ ! -f $OPENSCADDIR/openscad.pro ]; then - echo "Must be run from the OpenSCAD source root directory" - exit 0 -fi - -. ./scripts/setenv-linbuild.sh # '.' is equivalent to 'source' -SRCDIR=$BASEDIR/src - -if [ ! $NUMCPU ]; then - echo "Note: The NUMCPU environment variable can be set for paralell builds" - NUMCPU=1 -fi - -if [ ! -d $BASEDIR/bin ]; then - mkdir -p $BASEDIR/bin -fi - -echo "Using basedir:" $BASEDIR -echo "Using deploydir:" $DEPLOYDIR -echo "Using srcdir:" $SRCDIR -echo "Number of CPUs for parallel builds:" $NUMCPU -mkdir -p $SRCDIR $DEPLOYDIR - -if [ ! "`command -v curl`" ]; then - build_curl 7.26.0 -fi - -# NB! For cmake, also update the actual download URL in the function -if [ ! "`command -v cmake`" ]; then - build_cmake 2.8.8 -fi -if [ "`cmake --version | grep 'version 2.[1-6][^0-9]'`" ]; then - build_cmake 2.8.8 -fi - -# build_git 1.7.10.3 - -# Singly build CGAL or OpenCSG -# (Most systems have all libraries available as packages except CGAL/OpenCSG) -# (They can be built singly here by passing a command line arg to the script) -if [ $1 ]; then - if [ $1 = "cgal-use-sys-libs" ]; then - build_cgal 4.0.2 use-sys-libs - exit - fi - if [ $1 = "opencsg" ]; then - build_opencsg 1.3.2 - exit - fi -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 -build_boost 1.47.0 -# NB! For CGAL, also update the actual download URL in the function -build_cgal 4.0.2 -build_glew 1.7.0 -build_opencsg 1.3.2 - -echo "OpenSCAD dependencies built and installed to " $BASEDIR diff --git a/scripts/opensuse-build-dependencies.sh b/scripts/opensuse-build-dependencies.sh deleted file mode 100755 index 623d7d0..0000000 --- a/scripts/opensuse-build-dependencies.sh +++ /dev/null @@ -1,8 +0,0 @@ -echo "tested on OpenSUSE 12. If this fails try 'old linux' build (see README.md)" - -sudo zypper install libeigen2-devel mpfr-devel gmp-devel boost-devel \ - libqt4-devel glew-devel cmake git - -echo "now copy/paste the following to install CGAL and OpenCSG from source:" -echo "sudo BASEDIR=/usr/local ./scripts/linux-build-dependencies.sh cgal-use-sys-libs" -echo "sudo BASEDIR=/usr/local ./scripts/linux-build-dependencies.sh opencsg" diff --git a/scripts/setenv-freebsdbuild.sh b/scripts/setenv-freebsdbuild.sh deleted file mode 100644 index 49f1783..0000000 --- a/scripts/setenv-freebsdbuild.sh +++ /dev/null @@ -1,6 +0,0 @@ -# run with '. ./scripts/setenv-freebsdbuild.sh' - -# use in conjuction with freebsd-build-dependencies.sh - -QMAKESPEC=freebsd-g++ -QTDIR=/usr/local/share/qt4 diff --git a/scripts/setenv-linbuild-clang.sh b/scripts/setenv-linbuild-clang.sh deleted file mode 100644 index 9551235..0000000 --- a/scripts/setenv-linbuild-clang.sh +++ /dev/null @@ -1,12 +0,0 @@ -# build dependencies and/or openscad on linux with the clang compiler - -export CC=clang -export CXX=clang++ -export QMAKESPEC=unsupported/linux-clang - -echo CC has been modified: $CC -echo CXX has been modified: $CXX -echo QMAKESPEC has been modified: $QMAKESPEC - -. ./scripts/setenv-linbuild.sh - diff --git a/scripts/setenv-linbuild.sh b/scripts/setenv-linbuild.sh deleted file mode 100644 index 338cac9..0000000 --- a/scripts/setenv-linbuild.sh +++ /dev/null @@ -1,34 +0,0 @@ -# setup environment variables for building OpenSCAD against custom built -# dependency libraries. called by linux-build-dependencies.sh - -# run this file with 'source setenv-linbuild.sh' every time you re-login -# and want to build or run openscad against custom libraries installed -# into BASEDIR. - -# copy this file to your .bashrc if desired. - -if [ ! $BASEDIR ]; then - BASEDIR=$HOME/openscad_deps -fi -DEPLOYDIR=$BASEDIR - -export PATH=$BASEDIR/bin:$PATH -export LD_LIBRARY_PATH=$DEPLOYDIR/lib:$DEPLOYDIR/lib64 -export LD_RUN_PATH=$DEPLOYDIR/lib:$DEPLOYDIR/lib64 -export OPENSCAD_LIBRARIES=$DEPLOYDIR -export GLEWDIR=$DEPLOYDIR - -echo BASEDIR: $BASEDIR -echo DEPLOYDIR: $DEPLOYDIR -echo PATH modified -echo LD_LIBRARY_PATH modified -echo LD_RUN_PATH modified -echo OPENSCAD_LIBRARIES modified -echo GLEWDIR modified - -if [ "`command -v qmake-qt4`" ]; then - echo "Please re-run qmake-qt4 and run 'make clean' if necessary" -else - echo "Please re-run qmake and run 'make clean' if necessary" -fi - diff --git a/scripts/setenv-unibuild.sh b/scripts/setenv-unibuild.sh new file mode 100644 index 0000000..ba99235 --- /dev/null +++ b/scripts/setenv-unibuild.sh @@ -0,0 +1,64 @@ +# setup environment variables for building OpenSCAD against custom built +# dependency libraries. +# +# run with 'source ./scripts/setenv-unibuild.sh' +# +# run it every time you re-login and want to build or run openscad +# against custom libraries installed into BASEDIR. +# +# used in conjuction with uni-build-dependencies.sh + +setenv_common() +{ + if [ ! $BASEDIR ]; then + BASEDIR=$HOME/openscad_deps + fi + DEPLOYDIR=$BASEDIR + + export PATH=$BASEDIR/bin:$PATH + export LD_LIBRARY_PATH=$DEPLOYDIR/lib:$DEPLOYDIR/lib64 + export LD_RUN_PATH=$DEPLOYDIR/lib:$DEPLOYDIR/lib64 + export OPENSCAD_LIBRARIES=$DEPLOYDIR + export GLEWDIR=$DEPLOYDIR + + echo BASEDIR: $BASEDIR + echo DEPLOYDIR: $DEPLOYDIR + echo PATH modified + echo LD_LIBRARY_PATH modified + echo LD_RUN_PATH modified + echo OPENSCAD_LIBRARIES modified + echo GLEWDIR modified + + if [ "`command -v qmake-qt4`" ]; then + echo "Please re-run qmake-qt4 and run 'make clean' if necessary" + else + echo "Please re-run qmake and run 'make clean' if necessary" + fi +} + +setenv_freebsd() +{ + setenv_common + QMAKESPEC=freebsd-g++ + QTDIR=/usr/local/share/qt4 +} + +setenv_linux_clang() +{ + export CC=clang + export CXX=clang++ + export QMAKESPEC=unsupported/linux-clang + + echo CC has been modified: $CC + echo CXX has been modified: $CXX + echo QMAKESPEC has been modified: $QMAKESPEC +} + +if [ "`uname | grep -i 'linux\|debian'`" ]; then + setenv_common + if [ "`echo $* | grep clang`" ]; then + setenv_linux_clang + fi +elif [ "`uname | grep -i freebsd`" ]; then + setenv_freebsd +fi diff --git a/scripts/ubuntu-build-dependencies.sh b/scripts/ubuntu-build-dependencies.sh deleted file mode 100755 index 1754e32..0000000 --- a/scripts/ubuntu-build-dependencies.sh +++ /dev/null @@ -1,33 +0,0 @@ - -too_old() -{ - echo "System version too low. Please try 'old linux' build (see README.md)" - exit -} - -if [ "`cat /etc/issue | grep 'Debian GNU/Linux 6.0'`" ]; then - too_old -fi -if [ "`cat /etc/issue | grep 'Debian GNU/Linux 5'`" ]; then - too_old -fi -if [ "`cat /etc/issue | grep 'Ubunutu 10'`" ]; then - too_old -fi -if [ "`cat /etc/issue | grep 'Ubunutu 9'`" ]; then - too_old -fi -if [ "`cat /etc/issue | grep 'Ubunutu 8'`" ]; then - too_old -fi -if [ "`cat /etc/issue | grep 'Ubunutu 7'`" ]; then - too_old -fi - -echo "tested on Ubuntu 12. If this fails try 'old linux' build (see README.md)" - -sudo apt-get install build-essential libqt4-dev libqt4-opengl-dev \ - libxmu-dev cmake bison flex libeigen2-dev git-core libboost-all-dev \ - libXi-dev libmpfr-dev libgmp-dev libboost-dev libglew1.6-dev \ - libcgal-dev libopencsg-dev - diff --git a/scripts/uni-build-dependencies.sh b/scripts/uni-build-dependencies.sh new file mode 100755 index 0000000..009d41e --- /dev/null +++ b/scripts/uni-build-dependencies.sh @@ -0,0 +1,340 @@ +#!/bin/sh -e + +# uni-build-dependencies by don bright 2012. copyright assigned to +# Marius Kintel and Clifford Wolf, 2012. released under the GPL 2, or +# later, as described in the file named 'COPYING' in OpenSCAD's project root. + +# +# This script builds all library dependencies of OpenSCAD for Linux/BSD +# +# This script must be run from the OpenSCAD source root directory +# +# Usage: uni-build-dependencies.sh +# +# Prerequisites: +# - wget or curl +# - Qt4 +# - other +# + +printUsage() +{ + echo "Usage: $0" + echo +} + +build_git() +{ + version=$1 + echo "Building git" $version "..." + cd $BASEDIR/src + rm -rf git-$version + if [ ! -f git-$version.tar.gz ]; then + curl -O http://git-core.googlecode.com/files/git-$version.tar.gz + fi + tar zxf git-$version.tar.gz + cd git-$version + ./configure --prefix=$DEPLOYDIR + make -j$NUMCPU + make install +} + +build_cmake() +{ + version=$1 + echo "Building cmake" $version "..." + cd $BASEDIR/src + rm -rf cmake-$version + if [ ! -f cmake-$version.tar.gz ]; then + curl -O http://www.cmake.org/files/v2.8/cmake-$version.tar.gz + fi + tar zxf cmake-$version.tar.gz + cd cmake-$version + mkdir build + cd build + ../configure --prefix=$DEPLOYDIR + make -j$NUMCPU + make install +} + +build_curl() +{ + version=$1 + echo "Building curl" $version "..." + cd $BASEDIR/src + rm -rf curl-$version + if [ ! -f curl-$version.tar.bz2 ]; then + wget http://curl.haxx.se/download/curl-$version.tar.bz2 + fi + tar xjf curl-$version.tar.bz2 + cd curl-$version + mkdir build + cd build + ../configure --prefix=$DEPLOYDIR + make -j$NUMCPU + make install +} + +build_gmp() +{ + version=$1 + echo "Building gmp" $version "..." + cd $BASEDIR/src + rm -rf gmp-$version + if [ ! -f gmp-$version.tar.bz2 ]; then + curl -O ftp://ftp.gmplib.org/pub/gmp-$version/gmp-$version.tar.bz2 + fi + tar xjf gmp-$version.tar.bz2 + cd gmp-$version + mkdir build + cd build + ../configure --prefix=$DEPLOYDIR --enable-cxx + make install +} + +build_mpfr() +{ + version=$1 + echo "Building mpfr" $version "..." + cd $BASEDIR/src + rm -rf mpfr-$version + if [ ! -f mpfr-$version.tar.bz2 ]; then + curl -O http://www.mpfr.org/mpfr-$version/mpfr-$version.tar.bz2 + fi + tar xjf mpfr-$version.tar.bz2 + cd mpfr-$version + mkdir build + cd build + ../configure --prefix=$DEPLOYDIR --with-gmp=$DEPLOYDIR + make install + cd .. +} + +build_boost() +{ + version=$1 + bversion=`echo $version | tr "." "_"` + echo "Building boost" $version "..." + cd $BASEDIR/src + rm -rf boost_$bversion + if [ ! -f boost_$bversion.tar.bz2 ]; then + curl -LO http://downloads.sourceforge.net/project/boost/boost/$version/boost_$bversion.tar.bz2 + fi + tar xjf boost_$bversion.tar.bz2 + cd boost_$bversion + # We only need certain portions of boost + ./bootstrap.sh --prefix=$DEPLOYDIR --with-libraries=thread,program_options,filesystem,system,regex + if [ $CXX ]; then + if [ $CXX = "clang++" ]; then + ./b2 -j$NUMCPU toolset=clang install + # ./b2 -j$NUMCPU toolset=clang cxxflags="-stdlib=libc++" linkflags="-stdlib=libc++" install + fi + else + ./b2 -j$NUMCPU + ./b2 install + fi +} + +build_cgal() +{ + version=$1 + echo "Building CGAL" $version "..." + cd $BASEDIR/src + rm -rf CGAL-$version + if [ ! -f CGAL-$version.tar.gz ]; then + #4.0.2 + curl -O https://gforge.inria.fr/frs/download.php/31174/CGAL-$version.tar.bz2 + # 4.0 curl -O https://gforge.inria.fr/frs/download.php/30387/CGAL-$version.tar.gz + # 3.9 curl -O https://gforge.inria.fr/frs/download.php/29125/CGAL-$version.tar.gz + # 3.8 curl -O https://gforge.inria.fr/frs/download.php/28500/CGAL-$version.tar.gz + # 3.7 curl -O https://gforge.inria.fr/frs/download.php/27641/CGAL-$version.tar.gz + fi + tar jxf CGAL-$version.tar.bz2 + cd CGAL-$version + if [ $2 = 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 + 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 + fi + make -j$NUMCPU + make install +} + +build_glew() +{ + version=$1 + echo "Building GLEW" $version "..." + cd $BASEDIR/src + rm -rf glew-$version + if [ ! -f glew-$version.tgz ]; then + curl -LO http://downloads.sourceforge.net/project/glew/glew/$version/glew-$version.tgz + fi + tar xzf glew-$version.tgz + cd glew-$version + mkdir -p $DEPLOYDIR/lib/pkgconfig + + # Fedora 64-bit + if [ -e /usr/lib64 ]; then + if [ "`ls /usr/lib64 | grep Xmu`" ]; then + echo "modifying glew makefile for 64 bit machine" + sed -ibak s/"\-lXmu"/"\-L\/usr\/lib64\/libXmu.so.6"/ config/Makefile.linux + fi + fi + + if [ $CC ]; then + if [ $CC = "clang" ]; then + echo "modifying glew makefile for clang" + sed -i s/\$\(CC\)/clang/ Makefile + fi + fi + + GLEW_DEST=$DEPLOYDIR make -j$NUMCPU + GLEW_DEST=$DEPLOYDIR make install +} + +build_opencsg() +{ + version=$1 + echo "Building OpenCSG" $version "..." + cd $BASEDIR/src + rm -rf OpenCSG-$version + if [ ! -f OpenCSG-$version.tar.gz ]; then + curl -O http://www.opencsg.org/OpenCSG-$version.tar.gz + fi + tar xzf OpenCSG-$version.tar.gz + cd OpenCSG-$version + sed -ibak s/example// opencsg.pro # examples might be broken without GLUT + + # Fedora 64-bit + if [ -e /usr/lib64 ]; then + if [ "`ls /usr/lib64 | grep Xmu`" ]; then + echo "modifying opencsg makefile for 64 bit machine" + sed -ibak s/"\-lXmu"/"\-L\/usr\/lib64\/libXmu.so.6"/ src/Makefile + fi + fi + + if [ `uname | grep FreeBSD` ]; then + sed -ibak s/X11R6/local/g src/Makefile + fi + + if [ "`command -v qmake-qt4`" ]; then + OPENCSG_QMAKE=qmake-qt4 + else + OPENCSG_QMAKE=qmake + fi + + if [ $CXX ]; then + if [ $CXX = "clang++" ]; then + cd $BASEDIR/src/OpenCSG-$version/src + $OPENCSG_QMAKE + cd $BASEDIR/src/OpenCSG-$version + $OPENCSG_QMAKE + fi + else + $OPENCSG_QMAKE + fi + + make + + cp -av lib/* $DEPLOYDIR/lib + cp -av include/* $DEPLOYDIR/include + cd $OPENSCADDIR +} + +build_eigen() +{ + version=$1 + echo "Building eigen" $version "..." + cd $BASEDIR/src + rm -rf eigen-$version + EIGENDIR="none" + if [ $version = "2.0.17" ]; then EIGENDIR=eigen-eigen-b23437e61a07; fi + if [ $version = "3.1.1" ]; then EIGENDIR=eigen-eigen-43d9075b23ef; fi + if [ $EIGENDIR = "none" ]; then + echo Unknown eigen version. Please edit script. + exit 1 + fi + rm -rf ./$EIGENDIR + if [ ! -f eigen-$version.tar.bz2 ]; then + curl -LO http://bitbucket.org/eigen/eigen/get/$version.tar.bz2 + mv $version.tar.bz2 eigen-$version.tar.bz2 + fi + tar xjf eigen-$version.tar.bz2 + ln -s ./$EIGENDIR eigen-$version + cd eigen-$version + mkdir build + cd build + cmake -DCMAKE_INSTALL_PREFIX=$DEPLOYDIR .. + make -j$NUMCPU + make install +} + + +OPENSCADDIR=$PWD +if [ ! -f $OPENSCADDIR/openscad.pro ]; then + echo "Must be run from the OpenSCAD source root directory" + exit 0 +fi + +. ./scripts/setenv-unibuild.sh # '.' is equivalent to 'source' +SRCDIR=$BASEDIR/src + +if [ ! $NUMCPU ]; then + echo "Note: The NUMCPU environment variable can be set for paralell builds" + NUMCPU=1 +fi + +if [ ! -d $BASEDIR/bin ]; then + mkdir -p $BASEDIR/bin +fi + +echo "Using basedir:" $BASEDIR +echo "Using deploydir:" $DEPLOYDIR +echo "Using srcdir:" $SRCDIR +echo "Number of CPUs for parallel builds:" $NUMCPU +mkdir -p $SRCDIR $DEPLOYDIR + +if [ ! "`command -v curl`" ]; then + build_curl 7.26.0 +fi + +# NB! For cmake, also update the actual download URL in the function +if [ ! "`command -v cmake`" ]; then + build_cmake 2.8.8 +fi +if [ "`cmake --version | grep 'version 2.[1-6][^0-9]'`" ]; then + build_cmake 2.8.8 +fi + +# build_git 1.7.10.3 + +# Singly build CGAL or OpenCSG +# (Most systems have all libraries available as packages except CGAL/OpenCSG) +# (They can be built singly here by passing a command line arg to the script) +if [ $1 ]; then + if [ $1 = "cgal-use-sys-libs" ]; then + build_cgal 4.0.2 use-sys-libs + exit + fi + if [ $1 = "opencsg" ]; then + build_opencsg 1.3.2 + exit + fi +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 +build_boost 1.47.0 +# NB! For CGAL, also update the actual download URL in the function +build_cgal 4.0.2 +build_glew 1.7.0 +build_opencsg 1.3.2 + +echo "OpenSCAD dependencies built and installed to " $BASEDIR diff --git a/scripts/uni-get-dependencies.sh b/scripts/uni-get-dependencies.sh new file mode 100755 index 0000000..91a87a4 --- /dev/null +++ b/scripts/uni-get-dependencies.sh @@ -0,0 +1,94 @@ + +get_fedora_deps() +{ + echo "Tested on Fedora 17. Please see README.md for info on older systems." + sudo yum install qt-devel bison flex eigen2-devel \ + boost-devel mpfr-devel gmp-devel glew-devel CGAL-devel gcc pkgconfig git +} + +get_freebsd_deps() +{ + echo "Tested on FreeBSD 9. Please see README.md for info on older systems." + + if [ "`pkg_info | grep -i cgal `" ]; then + echo Stopping. Please remove any CGAL packages you have installed and restart + exit + fi + + if [ "`pkg_info | grep -i opencsg`" ]; then + echo Stopping. Please remove any OpenCSG packages you have installed and restart + exit + fi + + pkg_add -r bison boost-libs cmake git bash eigen2 flex gmake gmp mpfr + pkg_add -r xorg libGLU libXmu libXi xorg-vfbserver glew + pkg_add -r qt4-corelib qt4-gui qt4-moc qt4-opengl qt4-qmake qt4-rcc qt4-uic + + #echo "BASEDIR=/usr/local ./scripts/linux-build-dependencies.sh cgal-use-sys-libs" + #echo "BASEDIR=/usr/local ./scripts/linux-build-dependencies.sh opencsg" +} + + +debian_too_old() +{ + echo "System version too low. Please try 'old linux' build (see README.md)" + exit +} + +get_debian_deps() +{ + if [ "`cat /etc/issue | grep 'Debian GNU/Linux 6.0'`" ]; then + debian_too_old + fi + if [ "`cat /etc/issue | grep 'Debian GNU/Linux 5'`" ]; then + debian_too_old + fi + if [ "`cat /etc/issue | grep 'Ubunutu 10'`" ]; then + debian_too_old + fi + if [ "`cat /etc/issue | grep 'Ubunutu 9'`" ]; then + debian_too_old + fi + if [ "`cat /etc/issue | grep 'Ubunutu 8'`" ]; then + debian_too_old + fi + if [ "`cat /etc/issue | grep 'Ubunutu 7'`" ]; then + debian_too_old + fi + echo "tested on Ubuntu 12. If this fails try 'old linux' build (see README.md)" + + sudo apt-get install build-essential libqt4-dev libqt4-opengl-dev \ + libxmu-dev cmake bison flex libeigen2-dev git-core libboost-all-dev \ + libXi-dev libmpfr-dev libgmp-dev libboost-dev libglew1.6-dev \ + libcgal-dev libopencsg-dev +} + + +get_opensuse_deps() +{ + echo "tested on OpenSUSE 12. If this fails try 'old linux' build (see README.md)" + + sudo zypper install libeigen2-devel mpfr-devel gmp-devel boost-devel \ + libqt4-devel glew-devel cmake git + + # sudo BASEDIR=/usr/local ./scripts/linux-build-dependencies.sh opencsg +} + + + + +if [ "`cat /etc/issue | grep -i ubuntu`" ]; then + get_debian_deps +elif [ "`cat /etc/issue | grep -i debian`" ]; then + get_ubuntu_deps +elif [ "`cat /etc/issue | grep -i opensuse`" ]; then + get_opensuse_deps +elif [ "`cat /etc/issue | grep -i freebsd`" ]; then + get_freebsd_deps +elif [ "`cat /etc/issue | grep -i fedora`" ]; then + get_fedora_deps +else + echo "Unknown system type. Please install the dependency packages listed" + echo "in README.md using your system's package manager." +fi + -- cgit v0.10.1 From a64f93269303b89cd0fdabd5791d04e5e60d2b0a Mon Sep 17 00:00:00 2001 From: Marius Kintel Date: Sat, 8 Dec 2012 09:47:31 +0100 Subject: Render all 2D objects 1mm high in OpenCSG/Throwntogether mode diff --git a/src/polyset.cc b/src/polyset.cc index b412f5f..3b3be34 100644 --- a/src/polyset.cc +++ b/src/polyset.cc @@ -157,7 +157,7 @@ void PolySet::render_surface(csgmode_e csgmode, const Transform3d &m, GLint *sha } #endif /* ENABLE_OPENCSG */ if (this->is2d) { - double zbase = csgmode; + double zbase = 1; // Render 2D objects 1mm thick glBegin(GL_TRIANGLES); for (double z = -zbase/2; z < zbase; z += zbase) { @@ -248,7 +248,7 @@ void PolySet::render_edges(csgmode_e csgmode) const { glDisable(GL_LIGHTING); if (this->is2d) { - double zbase = csgmode; + double zbase = 1; // Render 2D objects 1mm thick for (double z = -zbase/2; z < zbase; z += zbase) { for (size_t i = 0; i < borders.size(); i++) { -- cgit v0.10.1 From c0612a9ed0899c96963e04c848a59b0164a689a2 Mon Sep 17 00:00:00 2001 From: Marius Kintel Date: Sat, 8 Dec 2012 09:53:53 +0100 Subject: Explicitly use UTF-8 as file encoding to avoid Windows automatically falling back to cp1252. Fixes #223 diff --git a/src/mainwin.cc b/src/mainwin.cc index 4b0df70..dc5b79b 100644 --- a/src/mainwin.cc +++ b/src/mainwin.cc @@ -588,7 +588,9 @@ void MainWindow::refreshDocument() this->fileName.toStdString() % file.errorString().toStdString()); } else { - QString text = QTextStream(&file).readAll(); + QTextStream reader(&file); + reader.setCodec("UTF-8"); + QString text = reader.readAll(); PRINTB("Loaded design '%s'.", this->fileName.toStdString()); editor->setPlainText(text); } @@ -900,7 +902,9 @@ void MainWindow::actionSave() PRINTB("Failed to open file for writing: %s (%s)", this->fileName.toStdString() % file.errorString().toStdString()); } else { - QTextStream(&file) << this->editor->toPlainText(); + QTextStream writer(&file); + writer.setCodec("UTF-8"); + writer << this->editor->toPlainText(); PRINTB("Saved design '%s'.", this->fileName.toStdString()); this->editor->setContentModified(false); } -- cgit v0.10.1 From 4bd97b936e2af49248e8d15f5485e09dd52fa8d5 Mon Sep 17 00:00:00 2001 From: Marius Kintel Date: Tue, 11 Dec 2012 21:22:28 +0100 Subject: Bumped eigen to 3.1.2 diff --git a/scripts/macosx-build-dependencies.sh b/scripts/macosx-build-dependencies.sh index 1036320..6313b2b 100755 --- a/scripts/macosx-build-dependencies.sh +++ b/scripts/macosx-build-dependencies.sh @@ -284,7 +284,7 @@ build_eigen() EIGENDIR="none" if [ $version = "2.0.17" ]; then EIGENDIR=eigen-eigen-b23437e61a07; fi - if [ $version = "3.1.1" ]; then EIGENDIR=eigen-eigen-43d9075b23ef; fi + if [ $version = "3.1.2" ]; then EIGENDIR=eigen-eigen-5097c01bcdc4; fi if [ $EIGENDIR = "none" ]; then echo Unknown eigen version. Please edit script. exit 1 @@ -365,7 +365,7 @@ fi echo "Using basedir:" $BASEDIR mkdir -p $SRCDIR $DEPLOYDIR -build_eigen 3.1.1 +build_eigen 3.1.2 build_gmp 5.0.5 build_mpfr 3.1.1 build_boost 1.51.0 -- cgit v0.10.1 From 2eb1842d9f3877efd0ab91a1b3eb81de03a94c46 Mon Sep 17 00:00:00 2001 From: don bright Date: Wed, 19 Dec 2012 18:34:37 -0600 Subject: do not use OSTYPE, its a read-only operating system variable diff --git a/scripts/publish-mingw-x.sh b/scripts/publish-mingw-x.sh index d6cebcd..5622e9f 100755 --- a/scripts/publish-mingw-x.sh +++ b/scripts/publish-mingw-x.sh @@ -31,7 +31,7 @@ if [ ! -f $OPENSCADDIR/openscad.pro ]; then exit 1 fi -OSTYPE=mingw-cross-env ./scripts/release-common.sh -v $VERSION $COMMIT +./scripts/release-common.sh -v $VERSION $COMMIT mingw32 if [ $? != 0 ]; then echo "release-common.sh returned error code: $?. build stopped." -- cgit v0.10.1 From 29c3699e0a0660a315be6b0e312075cbdf3c2fc0 Mon Sep 17 00:00:00 2001 From: don bright Date: Thu, 20 Dec 2012 18:03:04 +0100 Subject: clarify README linux compilation diff --git a/README.md b/README.md index d618f85..da0ea1c 100644 --- a/README.md +++ b/README.md @@ -133,27 +133,31 @@ After that, follow the Compilation instructions below. ### Building for Linux/BSD -First, make sure that you have git installed. Then after you've cloned -this git repository, run the script that attempts to download the +First, make sure that you have git installed (git-core in debian). Once you've +cloned this git repository, run the script that attempts to download the dependency packages for your system: ./scripts/uni-get-dependencies.sh -This will get the majority of necessary packages, although your -particular system may require you to manually install some. After installing +If this fails then you have to download and install the dependency packages +on your own using your system's package manager. After installing dependencies, check their versions. You can run this script to help you: ./scripts/check-dependencies.sh -If some of yours are out of date, you can build newer versions automatically -into $HOME/openscad_deps with the following commands: +If all dependencies are present and of a high enough version, skip ahead +to the Compilation instructions. If some are missing or old, then you +can download and build them into $HOME/openscad_deps as follows - source ./scripts/setenv-linbuild.sh - ./scripts/linux-build-dependencies.sh + source ./scripts/setenv-unibuild.sh + ./scripts/uni-build-dependencies.sh + +This may take several hours. After completion, again check dependencies + + source ./scripts/setenv-unibuild.sh ./scripts/check-dependencies.sh -This may take several hours. If successfull, follow the Compilation -instructions below. If not, file an 'issue' on the OpenSCAD github. +Then follow the Compilation instructions below. ### Building for Windows -- cgit v0.10.1 From f5cb2ecb3053180d3096e729cc8b0f774d79b1f3 Mon Sep 17 00:00:00 2001 From: don bright Date: Thu, 20 Dec 2012 18:55:13 +0100 Subject: enable 'out of tree' call of dependency scripts. fix old ubuntu detection. diff --git a/scripts/setenv-unibuild.sh b/scripts/setenv-unibuild.sh index ba99235..19d37f9 100644 --- a/scripts/setenv-unibuild.sh +++ b/scripts/setenv-unibuild.sh @@ -11,7 +11,15 @@ setenv_common() { if [ ! $BASEDIR ]; then - BASEDIR=$HOME/openscad_deps + if [ -f openscad.pro ]; then + # if in main openscad dir, put under $HOME + BASEDIR=$HOME/openscad_deps + else + # otherwise, assume its being run 'out of tree'. treat it somewhat like + # "configure" or "cmake", so you can build dependencies where u wish. + echo "Not in OpenSCAD dir... using current directory as base of build" + BASEDIR=$PWD + fi fi DEPLOYDIR=$BASEDIR diff --git a/scripts/uni-build-dependencies.sh b/scripts/uni-build-dependencies.sh index 009d41e..e091444 100755 --- a/scripts/uni-build-dependencies.sh +++ b/scripts/uni-build-dependencies.sh @@ -7,8 +7,6 @@ # # This script builds all library dependencies of OpenSCAD for Linux/BSD # -# This script must be run from the OpenSCAD source root directory -# # Usage: uni-build-dependencies.sh # # Prerequisites: @@ -238,7 +236,7 @@ build_opencsg() cp -av lib/* $DEPLOYDIR/lib cp -av include/* $DEPLOYDIR/include - cd $OPENSCADDIR + cd $BASEDIR } build_eigen() @@ -270,13 +268,18 @@ build_eigen() } -OPENSCADDIR=$PWD -if [ ! -f $OPENSCADDIR/openscad.pro ]; then - echo "Must be run from the OpenSCAD source root directory" - exit 0 +if [ "`command -v dirname`" ]; then + OPENSCAD_SCRIPTDIR=`dirname $0` +else + if [ ! -f openscad.pro ]; then + echo "Must be run from the OpenSCAD source root directory (dont have 'dirname')" + exit 1 + else + OPENSCAD_SCRIPTDIR=$PWD + fi fi -. ./scripts/setenv-unibuild.sh # '.' is equivalent to 'source' +. $OPENSCAD_SCRIPTDIR/setenv-unibuild.sh # '.' is equivalent to 'source' SRCDIR=$BASEDIR/src if [ ! $NUMCPU ]; then @@ -312,7 +315,7 @@ fi # (Most systems have all libraries available as packages except CGAL/OpenCSG) # (They can be built singly here by passing a command line arg to the script) if [ $1 ]; then - if [ $1 = "cgal-use-sys-libs" ]; then + if [ $1 = "cgal" ]; then build_cgal 4.0.2 use-sys-libs exit fi diff --git a/scripts/uni-get-dependencies.sh b/scripts/uni-get-dependencies.sh index 91a87a4..3ed12e6 100755 --- a/scripts/uni-get-dependencies.sh +++ b/scripts/uni-get-dependencies.sh @@ -43,16 +43,16 @@ get_debian_deps() if [ "`cat /etc/issue | grep 'Debian GNU/Linux 5'`" ]; then debian_too_old fi - if [ "`cat /etc/issue | grep 'Ubunutu 10'`" ]; then + if [ "`cat /etc/issue | grep 'Ubuntu 10'`" ]; then debian_too_old fi - if [ "`cat /etc/issue | grep 'Ubunutu 9'`" ]; then + if [ "`cat /etc/issue | grep 'Ubuntu 9'`" ]; then debian_too_old fi - if [ "`cat /etc/issue | grep 'Ubunutu 8'`" ]; then + if [ "`cat /etc/issue | grep 'Ubuntu 8'`" ]; then debian_too_old fi - if [ "`cat /etc/issue | grep 'Ubunutu 7'`" ]; then + if [ "`cat /etc/issue | grep 'Ubuntu 7'`" ]; then debian_too_old fi echo "tested on Ubuntu 12. If this fails try 'old linux' build (see README.md)" -- cgit v0.10.1 From 67ba3cb3d2f6ef1d9857fc40f8d764e9c0602932 Mon Sep 17 00:00:00 2001 From: don bright Date: Thu, 20 Dec 2012 18:59:50 +0100 Subject: for out of tree, build under $PWD/openscad_deps not $PWD diff --git a/scripts/setenv-unibuild.sh b/scripts/setenv-unibuild.sh index 19d37f9..5462983 100644 --- a/scripts/setenv-unibuild.sh +++ b/scripts/setenv-unibuild.sh @@ -18,7 +18,7 @@ setenv_common() # otherwise, assume its being run 'out of tree'. treat it somewhat like # "configure" or "cmake", so you can build dependencies where u wish. echo "Not in OpenSCAD dir... using current directory as base of build" - BASEDIR=$PWD + BASEDIR=$PWD/openscad_deps fi fi DEPLOYDIR=$BASEDIR -- cgit v0.10.1 From bbcc2a070855c0481e6cab74178c5684960bdcd8 Mon Sep 17 00:00:00 2001 From: don bright Date: Thu, 20 Dec 2012 19:35:44 +0100 Subject: update boost version. allow 'out of tree' dependency check. fix cmake detection diff --git a/scripts/check-dependencies.sh b/scripts/check-dependencies.sh index 536c46f..0401fbb 100755 --- a/scripts/check-dependencies.sh +++ b/scripts/check-dependencies.sh @@ -161,7 +161,7 @@ curl_sysver() cmake_sysver() { if [ ! -x $1/bin/cmake ]; then return ; fi - cmake_sysver_result=`$1/bin/cmake --version | grep cmake | sed s/"[^0-9.]"/" "/g` + cmake_sysver_result=`$1/bin/cmake --version | grep cmake | sed s/"[^0-9.]"/" "/g | awk '{ print $1 }'` } make_sysver() @@ -364,6 +364,11 @@ get_minversion_from_readme() { if [ -e README.md ]; then READFILE=README.md; fi if [ -e ../README.md ]; then READFILE=../README.md; fi + if [ ! $READFILE ]; then + if [ "`command -v dirname`" ]; then + READFILE=`dirname $0`/../README.md + fi + fi if [ ! $READFILE ]; then echo "cannot find README.md"; exit; fi debug get_minversion_from_readme $* if [ ! $1 ]; then return; fi diff --git a/scripts/uni-build-dependencies.sh b/scripts/uni-build-dependencies.sh index e091444..a57d1ba 100755 --- a/scripts/uni-build-dependencies.sh +++ b/scripts/uni-build-dependencies.sh @@ -120,6 +120,12 @@ build_boost() fi tar xjf boost_$bversion.tar.bz2 cd boost_$bversion + if [ "`gcc --version|grep 4.7`" ]; then + if [ "`echo $version | grep 1.47`" ]; then + echo gcc 4.7 incompatible with boost 1.47. edit boost version in $0 + exit + fi + fi # We only need certain portions of boost ./bootstrap.sh --prefix=$DEPLOYDIR --with-libraries=thread,program_options,filesystem,system,regex if [ $CXX ]; then @@ -334,7 +340,7 @@ fi build_eigen 3.1.1 build_gmp 5.0.5 build_mpfr 3.1.1 -build_boost 1.47.0 +build_boost 1.49.0 # NB! For CGAL, also update the actual download URL in the function build_cgal 4.0.2 build_glew 1.7.0 -- cgit v0.10.1 From d80b067d53218ecd914a6d19d1d11ac44a9bc300 Mon Sep 17 00:00:00 2001 From: don bright Date: Thu, 20 Dec 2012 20:52:14 +0100 Subject: convert tabs to spaces. fix some BSD problems diff --git a/scripts/check-dependencies.sh b/scripts/check-dependencies.sh index 0401fbb..feb209e 100755 --- a/scripts/check-dependencies.sh +++ b/scripts/check-dependencies.sh @@ -337,7 +337,7 @@ pkg_search() yum_pkg_search $* pkg_search_result=$yum_pkg_search_result else - echo unknown system type. cannot search packages. + debug unknown system type. cannot search packages. fi } diff --git a/scripts/uni-build-dependencies.sh b/scripts/uni-build-dependencies.sh index a57d1ba..c08b414 100755 --- a/scripts/uni-build-dependencies.sh +++ b/scripts/uni-build-dependencies.sh @@ -128,15 +128,15 @@ build_boost() fi # We only need certain portions of boost ./bootstrap.sh --prefix=$DEPLOYDIR --with-libraries=thread,program_options,filesystem,system,regex - if [ $CXX ]; then - if [ $CXX = "clang++" ]; then - ./b2 -j$NUMCPU toolset=clang install - # ./b2 -j$NUMCPU toolset=clang cxxflags="-stdlib=libc++" linkflags="-stdlib=libc++" install - fi - else - ./b2 -j$NUMCPU - ./b2 install - fi + if [ $CXX ]; then + if [ $CXX = "clang++" ]; then + ./b2 -j$NUMCPU toolset=clang install + # ./b2 -j$NUMCPU toolset=clang cxxflags="-stdlib=libc++" linkflags="-stdlib=libc++" install + fi + else + ./b2 -j$NUMCPU + ./b2 install + fi } build_cgal() @@ -178,22 +178,32 @@ build_glew() mkdir -p $DEPLOYDIR/lib/pkgconfig # Fedora 64-bit - if [ -e /usr/lib64 ]; then - if [ "`ls /usr/lib64 | grep Xmu`" ]; then - echo "modifying glew makefile for 64 bit machine" - sed -ibak s/"\-lXmu"/"\-L\/usr\/lib64\/libXmu.so.6"/ config/Makefile.linux - fi - fi - - if [ $CC ]; then - if [ $CC = "clang" ]; then - echo "modifying glew makefile for clang" - sed -i s/\$\(CC\)/clang/ Makefile - fi - fi - - GLEW_DEST=$DEPLOYDIR make -j$NUMCPU - GLEW_DEST=$DEPLOYDIR make install + if [ -e /usr/lib64 ]; then + if [ "`ls /usr/lib64 | grep Xmu`" ]; then + echo "modifying glew makefile for 64 bit machine" + sed -ibak s/"\-lXmu"/"\-L\/usr\/lib64\/libXmu.so.6"/ config/Makefile.linux + fi + fi + + if [ $CC ]; then + if [ $CC = "clang" ]; then + echo "modifying glew makefile for clang" + sed -i s/\$\(CC\)/clang/ Makefile + fi + fi + + MAKER=make + if [ "`uname | grep BSD`" ]; then + if [ "`command -v gmake`" ]; then + MAKER=gmake + else + echo "building glew on BSD requires gmake (gnu make)" + exit + fi + fi + + GLEW_DEST=$DEPLOYDIR $MAKER -j$NUMCPU + GLEW_DEST=$DEPLOYDIR $MAKER install } build_opencsg() @@ -210,12 +220,12 @@ build_opencsg() sed -ibak s/example// opencsg.pro # examples might be broken without GLUT # Fedora 64-bit - if [ -e /usr/lib64 ]; then - if [ "`ls /usr/lib64 | grep Xmu`" ]; then - echo "modifying opencsg makefile for 64 bit machine" - sed -ibak s/"\-lXmu"/"\-L\/usr\/lib64\/libXmu.so.6"/ src/Makefile - fi - fi + if [ -e /usr/lib64 ]; then + if [ "`ls /usr/lib64 | grep Xmu`" ]; then + echo "modifying opencsg makefile for 64 bit machine" + sed -ibak s/"\-lXmu"/"\-L\/usr\/lib64\/libXmu.so.6"/ src/Makefile + fi + fi if [ `uname | grep FreeBSD` ]; then sed -ibak s/X11R6/local/g src/Makefile @@ -227,16 +237,16 @@ build_opencsg() OPENCSG_QMAKE=qmake fi - if [ $CXX ]; then - if [ $CXX = "clang++" ]; then - cd $BASEDIR/src/OpenCSG-$version/src - $OPENCSG_QMAKE - cd $BASEDIR/src/OpenCSG-$version - $OPENCSG_QMAKE - fi - else - $OPENCSG_QMAKE - fi + if [ $CXX ]; then + if [ $CXX = "clang++" ]; then + cd $BASEDIR/src/OpenCSG-$version/src + $OPENCSG_QMAKE + cd $BASEDIR/src/OpenCSG-$version + $OPENCSG_QMAKE + fi + else + $OPENCSG_QMAKE + fi make @@ -289,8 +299,8 @@ fi SRCDIR=$BASEDIR/src if [ ! $NUMCPU ]; then - echo "Note: The NUMCPU environment variable can be set for paralell builds" - NUMCPU=1 + echo "Note: The NUMCPU environment variable can be set for paralell builds" + NUMCPU=1 fi if [ ! -d $BASEDIR/bin ]; then @@ -304,15 +314,15 @@ echo "Number of CPUs for parallel builds:" $NUMCPU mkdir -p $SRCDIR $DEPLOYDIR if [ ! "`command -v curl`" ]; then - build_curl 7.26.0 + build_curl 7.26.0 fi # NB! For cmake, also update the actual download URL in the function if [ ! "`command -v cmake`" ]; then - build_cmake 2.8.8 + build_cmake 2.8.8 fi if [ "`cmake --version | grep 'version 2.[1-6][^0-9]'`" ]; then - build_cmake 2.8.8 + build_cmake 2.8.8 fi # build_git 1.7.10.3 -- cgit v0.10.1 From 10f16dfe84a429c012650987d81c5ce385fd55be Mon Sep 17 00:00:00 2001 From: don bright Date: Thu, 20 Dec 2012 12:46:25 -0800 Subject: skip broken opengl testing under eigen3 diff --git a/scripts/uni-build-dependencies.sh b/scripts/uni-build-dependencies.sh index c08b414..e71bd57 100755 --- a/scripts/uni-build-dependencies.sh +++ b/scripts/uni-build-dependencies.sh @@ -278,7 +278,7 @@ build_eigen() cd eigen-$version mkdir build cd build - cmake -DCMAKE_INSTALL_PREFIX=$DEPLOYDIR .. + cmake -DCMAKE_INSTALL_PREFIX=$DEPLOYDIR -DEIGEN_TEST_NO_OPENGL=1 .. make -j$NUMCPU make install } -- cgit v0.10.1 From f95fa0d607e9cac8344fc8e9a9daf60ca7f78b07 Mon Sep 17 00:00:00 2001 From: don bright Date: Thu, 20 Dec 2012 12:52:05 -0800 Subject: change 'system' to 'found' in header of printed table diff --git a/scripts/check-dependencies.sh b/scripts/check-dependencies.sh index feb209e..2032412 100755 --- a/scripts/check-dependencies.sh +++ b/scripts/check-dependencies.sh @@ -491,7 +491,7 @@ pretty_print() ppstr="%s%-12s" pp_format='{printf("'$ppstr$ppstr$ppstr$ppstr$nocolor'\n",$1,$2,$3,$4,$5,$6,$7,$8)}' - pp_title="$gray depname $gray minimum $gray system $gray OKness" + pp_title="$gray depname $gray minimum $gray found $gray OKness" if [ $1 ]; then pp_dep=$1; fi if [ $pp_dep = "title" ]; then echo -e $pp_title | awk $pp_format -- cgit v0.10.1 From 2a612b549b90ecdedcb7763fa13404b3c76e4114 Mon Sep 17 00:00:00 2001 From: don bright Date: Thu, 20 Dec 2012 13:01:30 -0800 Subject: improve qt version detection diff --git a/scripts/check-dependencies.sh b/scripts/check-dependencies.sh index 2032412..0c69124 100755 --- a/scripts/check-dependencies.sh +++ b/scripts/check-dependencies.sh @@ -104,6 +104,9 @@ gmp_sysver() qt4_sysver() { qt4path=$1/include/qt4/QtCore/qglobal.h + if [ ! -e $qt4path ]; then + qt4path=$1/include/QtCore/qglobal.h + fi if [ ! -e $qt4path ]; then return; fi qt4ver=`grep 'define *QT_VERSION_STR *' $qt4path | awk '{print $3}'` qt4ver=`echo $qt4ver | sed s/'"'//g` -- cgit v0.10.1 From 208be52473f739816e0f53070085af0f69fd3bc4 Mon Sep 17 00:00:00 2001 From: don bright Date: Thu, 20 Dec 2012 15:14:54 -0600 Subject: improve OpenCSG build to use qmake + work better standalone diff --git a/scripts/uni-build-dependencies.sh b/scripts/uni-build-dependencies.sh index e71bd57..17f1be2 100755 --- a/scripts/uni-build-dependencies.sh +++ b/scripts/uni-build-dependencies.sh @@ -217,41 +217,36 @@ build_opencsg() fi tar xzf OpenCSG-$version.tar.gz cd OpenCSG-$version - sed -ibak s/example// opencsg.pro # examples might be broken without GLUT - # Fedora 64-bit - if [ -e /usr/lib64 ]; then - if [ "`ls /usr/lib64 | grep Xmu`" ]; then - echo "modifying opencsg makefile for 64 bit machine" - sed -ibak s/"\-lXmu"/"\-L\/usr\/lib64\/libXmu.so.6"/ src/Makefile - fi - fi + # modify the .pro file for qmake, then use qmake to + # manually rebuild the src/Makefile (some systems don't auto-rebuild it) - if [ `uname | grep FreeBSD` ]; then - sed -ibak s/X11R6/local/g src/Makefile - fi + cp opencsg.pro opencsg.pro.bak + cat opencsg.pro.bak | sed s/example// > opencsg.pro if [ "`command -v qmake-qt4`" ]; then OPENCSG_QMAKE=qmake-qt4 + elif [ "`command -v qmake4`" ]; then + OPENCSG_QMAKE=qmake4 else OPENCSG_QMAKE=qmake fi - if [ $CXX ]; then - if [ $CXX = "clang++" ]; then - cd $BASEDIR/src/OpenCSG-$version/src - $OPENCSG_QMAKE - cd $BASEDIR/src/OpenCSG-$version - $OPENCSG_QMAKE - fi - else - $OPENCSG_QMAKE - fi + cd $BASEDIR/src/OpenCSG-$version/src + $OPENCSG_QMAKE + + cd $BASEDIR/src/OpenCSG-$version + $OPENCSG_QMAKE make - cp -av lib/* $DEPLOYDIR/lib - cp -av include/* $DEPLOYDIR/include + ls lib/* include/* + echo "installing to -->" $DEPLOYDIR + mkdir -p $DEPLOYDIR/lib + mkdir -p $DEPLOYDIR/include + install lib/* $DEPLOYDIR/lib + install include/* $DEPLOYDIR/include + cd $BASEDIR } -- cgit v0.10.1 From 76923ebd9afff61d8e5e4889ac23ebf5c430227c Mon Sep 17 00:00:00 2001 From: don bright Date: Thu, 20 Dec 2012 15:28:13 -0600 Subject: CGAL<4.0.2 has strange errors with clang. notify user explicitly to upgrade. diff --git a/src/version_check.h b/src/version_check.h index 92b00db..a940f6b 100644 --- a/src/version_check.h +++ b/src/version_check.h @@ -66,6 +66,9 @@ a time, to avoid confusion. #warning "." #warning "." #warning "=======================" +#ifdef __clang__ +#error For Clang to work, CGAL must be >= 4.0.2 +#endif #endif // CGAL_VERSION_NR < 10400010000 #endif //ENABLE_CGAL -- cgit v0.10.1 From 799bb20d38f12f964f7ff3eba6575719a4530097 Mon Sep 17 00:00:00 2001 From: don bright Date: Thu, 20 Dec 2012 16:12:49 -0600 Subject: mention BSD. clarify language slightly diff --git a/README.md b/README.md index da0ea1c..6d2a631 100644 --- a/README.md +++ b/README.md @@ -80,7 +80,7 @@ numbers in brackets specify the versions which have been used for development. Other versions may or may not work as well. If you're using a newer version of Ubuntu, you can install these -libraries from aptitude. If you're using Mac, or an older Linux, there +libraries from aptitude. If you're using Mac, or an older Linux/BSD, there are build scripts that download and compile the libraries from source. Follow the instructions for the platform you're compiling on below. @@ -147,7 +147,7 @@ dependencies, check their versions. You can run this script to help you: If all dependencies are present and of a high enough version, skip ahead to the Compilation instructions. If some are missing or old, then you -can download and build them into $HOME/openscad_deps as follows +can download and build dependencies into $HOME/openscad_deps as follows: source ./scripts/setenv-unibuild.sh ./scripts/uni-build-dependencies.sh -- cgit v0.10.1 From 238cf8570dc9916f2fe18f73c7e0b1ca48653469 Mon Sep 17 00:00:00 2001 From: don bright Date: Fri, 21 Dec 2012 00:35:16 +0100 Subject: fixes for netbsd. clarify readme. diff --git a/README.md b/README.md index 6d2a631..c9a7779 100644 --- a/README.md +++ b/README.md @@ -152,7 +152,9 @@ can download and build dependencies into $HOME/openscad_deps as follows: source ./scripts/setenv-unibuild.sh ./scripts/uni-build-dependencies.sh -This may take several hours. After completion, again check dependencies +This may take an hour or two. Note it will not build huge deps like gcc +or qt, only the main ones (boost, CGAL, opencsg, etc). After completion, +again check dependencies source ./scripts/setenv-unibuild.sh ./scripts/check-dependencies.sh diff --git a/scripts/check-dependencies.sh b/scripts/check-dependencies.sh index 0c69124..b60fae6 100755 --- a/scripts/check-dependencies.sh +++ b/scripts/check-dependencies.sh @@ -107,6 +107,10 @@ qt4_sysver() if [ ! -e $qt4path ]; then qt4path=$1/include/QtCore/qglobal.h fi + if [ ! -e $qt4path ]; then + # netbsd + qt4path=$1/qt4/include/QtCore/qglobal.h + fi if [ ! -e $qt4path ]; then return; fi qt4ver=`grep 'define *QT_VERSION_STR *' $qt4path | awk '{print $3}'` qt4ver=`echo $qt4ver | sed s/'"'//g` @@ -169,11 +173,21 @@ cmake_sysver() make_sysver() { + make_sysver_tmp= binmake=$1/bin/make if [ -x $1/bin/gmake ]; then binmake=$1/bin/gmake ;fi if [ ! -x $binmake ]; then return ;fi - make_sysver_result=`$binmake --version 2>&1 | grep -i 'gnu make' | sed s/"[^0-9.]"/" "/g` - if [ ! "`echo $make_sysver_result | grep [0-9]`" ]; then return; fi + make_sysver_tmp=`$binmake --version 2>&1` + + debug finding gnu make: raw make response: $make_sysver_tmp + if [ ! "`echo $make_sysver_tmp | grep -i gnu`" ]; then + return; + fi + + make_sysver_tmp=`$binmake --version 2>&1 | grep -i 'gnu make' | sed s/"[^0-9.]"/" "/g` + if [ "`echo $make_sysver_tmp | grep [0-9]`" ]; then + make_sysver_result=$make_sysver_tmp + fi } bash_sysver() @@ -402,10 +416,13 @@ find_min_version() fmvdep=$1 get_minversion_from_readme $fmvdep fmvtmp=$get_minversion_from_readme_result + + # items not included in README.md if [ $fmvdep = "git" ]; then fmvtmp=1.5 ; fi if [ $fmvdep = "curl" ]; then fmvtmp=6 ; fi if [ $fmvdep = "make" ]; then fmvtmp=3 ; fi if [ $fmvdep = "python" ]; then fmvtmp=2 ; fi + find_min_version_result=$fmvtmp } @@ -574,7 +591,8 @@ checkargs() main() { deps="qt4 cgal gmp cmake mpfr boost opencsg glew eigen gcc" - deps="$deps python bison flex git curl make" + deps="$deps bison flex git curl make" + #deps="$deps python" # needs work, only needed for tests #deps="$deps imagemagick" # needs work, only needed for tests #deps="eigen glew opencsg" # debug pretty_print title diff --git a/scripts/setenv-unibuild.sh b/scripts/setenv-unibuild.sh index 5462983..e7fe614 100644 --- a/scripts/setenv-unibuild.sh +++ b/scripts/setenv-unibuild.sh @@ -23,6 +23,7 @@ setenv_common() fi DEPLOYDIR=$BASEDIR + export BASEDIR export PATH=$BASEDIR/bin:$PATH export LD_LIBRARY_PATH=$DEPLOYDIR/lib:$DEPLOYDIR/lib64 export LD_RUN_PATH=$DEPLOYDIR/lib:$DEPLOYDIR/lib64 @@ -51,6 +52,20 @@ setenv_freebsd() QTDIR=/usr/local/share/qt4 } +setenv_netbsd() +{ + setenv_common + QMAKESPEC=netbsd-g++ + QTDIR=/usr/pkg/qt4 + PATH=/usr/pkg/qt4/bin:$PATH + LD_LIBRARY_PATH=/usr/pkg/qt4/lib:$LD_LIBRARY_PATH + + export QMAKESPEC + export QTDIR + export PATH + export LD_LIBRARY_PATH +} + setenv_linux_clang() { export CC=clang @@ -69,4 +84,8 @@ if [ "`uname | grep -i 'linux\|debian'`" ]; then fi elif [ "`uname | grep -i freebsd`" ]; then setenv_freebsd +elif [ "`uname | grep -i netbsd`" ]; then + setenv_netbsd +else + echo unknown system. edit $0 fi diff --git a/scripts/uni-build-dependencies.sh b/scripts/uni-build-dependencies.sh index 17f1be2..804eaa5 100755 --- a/scripts/uni-build-dependencies.sh +++ b/scripts/uni-build-dependencies.sh @@ -28,7 +28,7 @@ build_git() cd $BASEDIR/src rm -rf git-$version if [ ! -f git-$version.tar.gz ]; then - curl -O http://git-core.googlecode.com/files/git-$version.tar.gz + curl --insecure -O http://git-core.googlecode.com/files/git-$version.tar.gz fi tar zxf git-$version.tar.gz cd git-$version @@ -44,7 +44,7 @@ build_cmake() cd $BASEDIR/src rm -rf cmake-$version if [ ! -f cmake-$version.tar.gz ]; then - curl -O http://www.cmake.org/files/v2.8/cmake-$version.tar.gz + curl --insecure -O http://www.cmake.org/files/v2.8/cmake-$version.tar.gz fi tar zxf cmake-$version.tar.gz cd cmake-$version @@ -80,7 +80,7 @@ build_gmp() cd $BASEDIR/src rm -rf gmp-$version if [ ! -f gmp-$version.tar.bz2 ]; then - curl -O ftp://ftp.gmplib.org/pub/gmp-$version/gmp-$version.tar.bz2 + curl --insecure -O ftp://ftp.gmplib.org/pub/gmp-$version/gmp-$version.tar.bz2 fi tar xjf gmp-$version.tar.bz2 cd gmp-$version @@ -97,7 +97,7 @@ build_mpfr() cd $BASEDIR/src rm -rf mpfr-$version if [ ! -f mpfr-$version.tar.bz2 ]; then - curl -O http://www.mpfr.org/mpfr-$version/mpfr-$version.tar.bz2 + curl --insecure -O http://www.mpfr.org/mpfr-$version/mpfr-$version.tar.bz2 fi tar xjf mpfr-$version.tar.bz2 cd mpfr-$version @@ -116,7 +116,7 @@ build_boost() cd $BASEDIR/src rm -rf boost_$bversion if [ ! -f boost_$bversion.tar.bz2 ]; then - curl -LO http://downloads.sourceforge.net/project/boost/boost/$version/boost_$bversion.tar.bz2 + curl --insecure -LO http://downloads.sourceforge.net/project/boost/boost/$version/boost_$bversion.tar.bz2 fi tar xjf boost_$bversion.tar.bz2 cd boost_$bversion @@ -147,11 +147,11 @@ build_cgal() rm -rf CGAL-$version if [ ! -f CGAL-$version.tar.gz ]; then #4.0.2 - curl -O https://gforge.inria.fr/frs/download.php/31174/CGAL-$version.tar.bz2 - # 4.0 curl -O https://gforge.inria.fr/frs/download.php/30387/CGAL-$version.tar.gz - # 3.9 curl -O https://gforge.inria.fr/frs/download.php/29125/CGAL-$version.tar.gz - # 3.8 curl -O https://gforge.inria.fr/frs/download.php/28500/CGAL-$version.tar.gz - # 3.7 curl -O https://gforge.inria.fr/frs/download.php/27641/CGAL-$version.tar.gz + 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 + # 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 cd CGAL-$version @@ -171,7 +171,7 @@ build_glew() cd $BASEDIR/src rm -rf glew-$version if [ ! -f glew-$version.tgz ]; then - curl -LO http://downloads.sourceforge.net/project/glew/glew/$version/glew-$version.tgz + curl --insecure -LO http://downloads.sourceforge.net/project/glew/glew/$version/glew-$version.tgz fi tar xzf glew-$version.tgz cd glew-$version @@ -213,7 +213,7 @@ build_opencsg() cd $BASEDIR/src rm -rf OpenCSG-$version if [ ! -f OpenCSG-$version.tar.gz ]; then - curl -O http://www.opencsg.org/OpenCSG-$version.tar.gz + curl --insecure -O http://www.opencsg.org/OpenCSG-$version.tar.gz fi tar xzf OpenCSG-$version.tar.gz cd OpenCSG-$version @@ -265,7 +265,7 @@ build_eigen() fi rm -rf ./$EIGENDIR if [ ! -f eigen-$version.tar.bz2 ]; then - curl -LO http://bitbucket.org/eigen/eigen/get/$version.tar.bz2 + curl --insecure -LO http://bitbucket.org/eigen/eigen/get/$version.tar.bz2 mv $version.tar.bz2 eigen-$version.tar.bz2 fi tar xjf eigen-$version.tar.bz2 -- cgit v0.10.1 From 89f3b31b6b3d933bf6f53d536837c04c76b74758 Mon Sep 17 00:00:00 2001 From: don bright Date: Fri, 21 Dec 2012 00:37:59 +0100 Subject: warn user about old local copies of libraries diff --git a/README.md b/README.md index c9a7779..32f151f 100644 --- a/README.md +++ b/README.md @@ -145,6 +145,7 @@ dependencies, check their versions. You can run this script to help you: ./scripts/check-dependencies.sh +Take care that you don't have old local copies anywhere (/usr/local/). If all dependencies are present and of a high enough version, skip ahead to the Compilation instructions. If some are missing or old, then you can download and build dependencies into $HOME/openscad_deps as follows: -- cgit v0.10.1 From 596fe6271f316f83239d4466eca66182da2948f2 Mon Sep 17 00:00:00 2001 From: Don Bright Date: Fri, 21 Dec 2012 00:06:28 +0000 Subject: deal with hurd diff --git a/scripts/setenv-unibuild.sh b/scripts/setenv-unibuild.sh index e7fe614..e734df7 100644 --- a/scripts/setenv-unibuild.sh +++ b/scripts/setenv-unibuild.sh @@ -87,5 +87,7 @@ elif [ "`uname | grep -i freebsd`" ]; then elif [ "`uname | grep -i netbsd`" ]; then setenv_netbsd else - echo unknown system. edit $0 + # guess + setenv_common + echo unknown system. guessed env variables. see 'setenv-unibuild.sh' fi -- cgit v0.10.1 From ced98a72c061a9b095f72ece253fcc78ebabee08 Mon Sep 17 00:00:00 2001 From: don bright Date: Thu, 20 Dec 2012 18:24:06 -0600 Subject: fix bug detecting if CGAL was already downloaded. simplify some wording diff --git a/scripts/check-dependencies.sh b/scripts/check-dependencies.sh index b60fae6..1ac864c 100755 --- a/scripts/check-dependencies.sh +++ b/scripts/check-dependencies.sh @@ -1,6 +1,5 @@ -# Determine which versions of dependency libraries and tools are -# available on the system. Compare these versions with the minimum parsed -# from README.md and print results. +# Parse the minimum versions of dependencies from README.md, and compare +# with what is found on the system. Print results. # # usage # check-dependencies.sh # check version of all dependencies @@ -23,7 +22,6 @@ # if /usr/ and /usr/local/ on linux both hit, throw an error # fallback- pkgconfig --exists, then --modversion # fallback2 - pkg manager -# todo - use OPENSCAD_LIBRARIES ??? # - print location found, how found??? # DEBUG= @@ -386,7 +384,7 @@ get_minversion_from_readme() READFILE=`dirname $0`/../README.md fi fi - if [ ! $READFILE ]; then echo "cannot find README.md"; exit; fi + if [ ! $READFILE ]; then echo "cannot find README.md"; exit 1; fi debug get_minversion_from_readme $* if [ ! $1 ]; then return; fi depname=$1 diff --git a/scripts/uni-build-dependencies.sh b/scripts/uni-build-dependencies.sh index 804eaa5..0a16886 100755 --- a/scripts/uni-build-dependencies.sh +++ b/scripts/uni-build-dependencies.sh @@ -145,7 +145,7 @@ build_cgal() echo "Building CGAL" $version "..." cd $BASEDIR/src rm -rf CGAL-$version - if [ ! -f CGAL-$version.tar.gz ]; then + 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 -- cgit v0.10.1 From 0de73575287d16be8e5004d19dbdc942cb917537 Mon Sep 17 00:00:00 2001 From: don bright Date: Fri, 21 Dec 2012 01:54:35 +0100 Subject: clarify README for linux/bsd build, streamline 'get-depdendencies' script diff --git a/README.md b/README.md index 32f151f..1889acd 100644 --- a/README.md +++ b/README.md @@ -133,29 +133,34 @@ After that, follow the Compilation instructions below. ### Building for Linux/BSD -First, make sure that you have git installed (git-core in debian). Once you've -cloned this git repository, run the script that attempts to download the -dependency packages for your system: +First, make sure that you have git installed (git-core in debian). Once +you've cloned this git repository, download and install the dependency +packages listed above using your system's package manager. A convenience +script is provided that can help with this process: ./scripts/uni-get-dependencies.sh -If this fails then you have to download and install the dependency packages -on your own using your system's package manager. After installing -dependencies, check their versions. You can run this script to help you: +After installing dependencies, check their versions. You can run this +script to help you: ./scripts/check-dependencies.sh Take care that you don't have old local copies anywhere (/usr/local/). If all dependencies are present and of a high enough version, skip ahead -to the Compilation instructions. If some are missing or old, then you -can download and build dependencies into $HOME/openscad_deps as follows: +to the Compilation instructions. + +### Building for Linux/BSD on systems with older or missing dependencies + +If some of your system dependency libraries are missing or old, then you +can download and build newer versions into $HOME/openscad_deps by +running these commands: source ./scripts/setenv-unibuild.sh ./scripts/uni-build-dependencies.sh -This may take an hour or two. Note it will not build huge deps like gcc -or qt, only the main ones (boost, CGAL, opencsg, etc). After completion, -again check dependencies +This may take several hours. Note it will not build huge deps like gcc +or qt, only the smaller ones (boost, CGAL, opencsg, etc). After +completion, again check dependencies source ./scripts/setenv-unibuild.sh ./scripts/check-dependencies.sh diff --git a/scripts/uni-get-dependencies.sh b/scripts/uni-get-dependencies.sh index 3ed12e6..8c6fd06 100755 --- a/scripts/uni-get-dependencies.sh +++ b/scripts/uni-get-dependencies.sh @@ -1,38 +1,25 @@ get_fedora_deps() { - echo "Tested on Fedora 17. Please see README.md for info on older systems." + echo "Tested on Fedora 17" sudo yum install qt-devel bison flex eigen2-devel \ boost-devel mpfr-devel gmp-devel glew-devel CGAL-devel gcc pkgconfig git } get_freebsd_deps() { - echo "Tested on FreeBSD 9. Please see README.md for info on older systems." - - if [ "`pkg_info | grep -i cgal `" ]; then - echo Stopping. Please remove any CGAL packages you have installed and restart - exit - fi - - if [ "`pkg_info | grep -i opencsg`" ]; then - echo Stopping. Please remove any OpenCSG packages you have installed and restart - exit - fi - + echo "Tested on FreeBSD 9" pkg_add -r bison boost-libs cmake git bash eigen2 flex gmake gmp mpfr pkg_add -r xorg libGLU libXmu libXi xorg-vfbserver glew pkg_add -r qt4-corelib qt4-gui qt4-moc qt4-opengl qt4-qmake qt4-rcc qt4-uic - - #echo "BASEDIR=/usr/local ./scripts/linux-build-dependencies.sh cgal-use-sys-libs" - #echo "BASEDIR=/usr/local ./scripts/linux-build-dependencies.sh opencsg" + pkg_add -r opencsg cgal } debian_too_old() { - echo "System version too low. Please try 'old linux' build (see README.md)" - exit + echo "System version too low. Please try 'old linux' build (see README.md)" + exit 1 } get_debian_deps() @@ -55,7 +42,8 @@ get_debian_deps() if [ "`cat /etc/issue | grep 'Ubuntu 7'`" ]; then debian_too_old fi - echo "tested on Ubuntu 12. If this fails try 'old linux' build (see README.md)" + + echo "Tested on Ubuntu 12.04" sudo apt-get install build-essential libqt4-dev libqt4-opengl-dev \ libxmu-dev cmake bison flex libeigen2-dev git-core libboost-all-dev \ @@ -66,27 +54,23 @@ get_debian_deps() get_opensuse_deps() { - echo "tested on OpenSUSE 12. If this fails try 'old linux' build (see README.md)" - sudo zypper install libeigen2-devel mpfr-devel gmp-devel boost-devel \ - libqt4-devel glew-devel cmake git - - # sudo BASEDIR=/usr/local ./scripts/linux-build-dependencies.sh opencsg + libqt4-devel glew-devel cmake git cgal-devel } - - if [ "`cat /etc/issue | grep -i ubuntu`" ]; then get_debian_deps elif [ "`cat /etc/issue | grep -i debian`" ]; then - get_ubuntu_deps + get_debian_deps elif [ "`cat /etc/issue | grep -i opensuse`" ]; then get_opensuse_deps elif [ "`cat /etc/issue | grep -i freebsd`" ]; then get_freebsd_deps elif [ "`cat /etc/issue | grep -i fedora`" ]; then get_fedora_deps +elif [ "`cat /etc/issue | grep -i redhat`" ]; then + get_fedora_deps else echo "Unknown system type. Please install the dependency packages listed" echo "in README.md using your system's package manager." -- cgit v0.10.1 From 43e1d6150db62e35fd28aacbd805beaa6a903c70 Mon Sep 17 00:00:00 2001 From: don bright Date: Fri, 21 Dec 2012 02:18:21 +0100 Subject: download and build bison if needed. detect better on BSD diff --git a/bison.pri b/bison.pri index 9840c5a..fcfad6f 100644 --- a/bison.pri +++ b/bison.pri @@ -19,11 +19,19 @@ win32 { unix:freebsd-g++ { # on bsd /usr/bin/bison is outdated, dont use it - QMAKE_YACC = /usr/local/bin/bison + exists(/usr/local/bin/bison) { + QMAKE_YACC = /usr/local/bin/bison + } else { # look in $PATH + QMAKE_YACC = bison + } } unix:netbsd* { - QMAKE_YACC = /usr/pkg/bin/bison + exists(/usr/pkg/bin/bison) { + QMAKE_YACC = /usr/pkg/bin/bison + } else { # look in $PATH + QMAKE_YACC = bison + } } unix:linux* { diff --git a/scripts/uni-build-dependencies.sh b/scripts/uni-build-dependencies.sh index 0a16886..1b15e53 100755 --- a/scripts/uni-build-dependencies.sh +++ b/scripts/uni-build-dependencies.sh @@ -21,6 +21,22 @@ printUsage() echo } +build_bison() +{ + version=$1 + echo "Building bison" $version + cd $BASEDIR/src + rm -rf bison-$version + if [ ! -f bison-$version.tar.gz ]; then + curl --insecure -O http://ftp.gnu.org/gnu/bison/bison-$version.tar.gz + fi + tar zxf bison-$version.tar.gz + cd bison-$version + ./configure --prefix=$DEPLOYDIR + make -j$NUMCPU + make install +} + build_git() { version=$1 @@ -312,6 +328,10 @@ if [ ! "`command -v curl`" ]; then build_curl 7.26.0 fi +if [ ! "`command -v bison`" ]; then + build_bison 2.6.1 +fi + # NB! For cmake, also update the actual download URL in the function if [ ! "`command -v cmake`" ]; then build_cmake 2.8.8 -- cgit v0.10.1 From aeefc1f6bc3613069cd6b69d6942e7b600596ff5 Mon Sep 17 00:00:00 2001 From: Don Bright Date: Fri, 21 Dec 2012 01:30:05 +0000 Subject: dont rebuild dependencies that are already built/installed diff --git a/scripts/uni-build-dependencies.sh b/scripts/uni-build-dependencies.sh index 1b15e53..1e1abe9 100755 --- a/scripts/uni-build-dependencies.sh +++ b/scripts/uni-build-dependencies.sh @@ -92,6 +92,10 @@ build_curl() build_gmp() { version=$1 + if [ -e $DEPLOYDIR/include/gmp.h ]; then + echo "gmp already installed. not building" + return + fi echo "Building gmp" $version "..." cd $BASEDIR/src rm -rf gmp-$version @@ -109,6 +113,10 @@ build_gmp() build_mpfr() { version=$1 + if [ -e $DEPLOYDIR/include/mpfr.h ]; then + echo "mpfr already installed. not building" + return + fi echo "Building mpfr" $version "..." cd $BASEDIR/src rm -rf mpfr-$version @@ -126,6 +134,10 @@ build_mpfr() build_boost() { + if [ -e $DEPLOYDIR/include/boost ]; then + echo "boost already installed. not building" + return + fi version=$1 bversion=`echo $version | tr "." "_"` echo "Building boost" $version "..." @@ -157,6 +169,10 @@ build_boost() build_cgal() { + if [ -e $DEPLOYDIR/include/CGAL/version.h ]; then + echo "CGAL already installed. not building" + return + fi version=$1 echo "Building CGAL" $version "..." cd $BASEDIR/src @@ -182,6 +198,10 @@ build_cgal() build_glew() { + if [ -e $DEPLOYDIR/include/GL/glew.h ]; then + echo "glew already installed. not building" + return + fi version=$1 echo "Building GLEW" $version "..." cd $BASEDIR/src @@ -224,6 +244,10 @@ build_glew() build_opencsg() { + if [ -e $DEPLOYDIR/include/opencsg.h ]; then + echo "OpenCSG already installed. not building" + return + fi version=$1 echo "Building OpenCSG" $version "..." cd $BASEDIR/src @@ -269,6 +293,18 @@ build_opencsg() build_eigen() { version=$1 + if [ -e $DEPLOYDIR/include/eigen2 ]; then + if [ `echo $version | grep 2....` ]; then + echo "Eigen2 already installed. not building" + return + fi + fi + if [ -e $DEPLOYDIR/include/eigen3 ]; then + if [ `echo $version | grep 3....` ]; then + echo "Eigen3 already installed. not building" + return + fi + fi echo "Building eigen" $version "..." cd $BASEDIR/src rm -rf eigen-$version @@ -368,7 +404,7 @@ build_mpfr 3.1.1 build_boost 1.49.0 # NB! For CGAL, also update the actual download URL in the function build_cgal 4.0.2 -build_glew 1.7.0 +build_glew 1.9.0 build_opencsg 1.3.2 echo "OpenSCAD dependencies built and installed to " $BASEDIR -- cgit v0.10.1 From b925540b3923089fe02e39573e1bae3ca0057daa Mon Sep 17 00:00:00 2001 From: Don Bright Date: Fri, 21 Dec 2012 01:41:20 +0000 Subject: improve handling of clang for glew build diff --git a/scripts/uni-build-dependencies.sh b/scripts/uni-build-dependencies.sh index 1e1abe9..ce633cf 100755 --- a/scripts/uni-build-dependencies.sh +++ b/scripts/uni-build-dependencies.sh @@ -221,13 +221,6 @@ build_glew() fi fi - if [ $CC ]; then - if [ $CC = "clang" ]; then - echo "modifying glew makefile for clang" - sed -i s/\$\(CC\)/clang/ Makefile - fi - fi - MAKER=make if [ "`uname | grep BSD`" ]; then if [ "`command -v gmake`" ]; then @@ -238,8 +231,8 @@ build_glew() fi fi - GLEW_DEST=$DEPLOYDIR $MAKER -j$NUMCPU - GLEW_DEST=$DEPLOYDIR $MAKER install + GLEW_DEST=$DEPLOYDIR CC=$CC $MAKER -j$NUMCPU + GLEW_DEST=$DEPLOYDIR CC=$CC $MAKER install } build_opencsg() -- cgit v0.10.1 From 8b0ced0f936f7f19732c187f37f6050d8c08c7e8 Mon Sep 17 00:00:00 2001 From: Don Bright Date: Fri, 21 Dec 2012 02:16:22 +0000 Subject: glew fixes for clang and for hurd diff --git a/scripts/uni-build-dependencies.sh b/scripts/uni-build-dependencies.sh index ce633cf..6b7d0d1 100755 --- a/scripts/uni-build-dependencies.sh +++ b/scripts/uni-build-dependencies.sh @@ -213,14 +213,28 @@ build_glew() cd glew-$version mkdir -p $DEPLOYDIR/lib/pkgconfig + # Glew makefiles are not built for Linux Multiarch. We aren't trying + # to fix everything here, just the test machines OScad normally runs on + # Fedora 64-bit - if [ -e /usr/lib64 ]; then - if [ "`ls /usr/lib64 | grep Xmu`" ]; then - echo "modifying glew makefile for 64 bit machine" + if [ "`uname -m | grep 64`" ]; then + if [ -e /usr/lib64/libXmu.so.6 ]; then sed -ibak s/"\-lXmu"/"\-L\/usr\/lib64\/libXmu.so.6"/ config/Makefile.linux fi fi + # debian hurd i386 + if [ "`uname -m | grep 386`" ]; then + if [ -e /usr/lib/i386-gnu/libXi.so.6 ]; then + sed -ibak s/"-lXi"/"\-L\/usr\/lib\/i386-gnu\/libXi.so.6"/ config/Makefile.gnu + fi + fi + + # clang linux + if [ $CC ]; then + sed -ibak s/"CC = cc"/"CC = $(CC)"/ config/Makefile.linux + fi + MAKER=make if [ "`uname | grep BSD`" ]; then if [ "`command -v gmake`" ]; then @@ -231,8 +245,8 @@ build_glew() fi fi - GLEW_DEST=$DEPLOYDIR CC=$CC $MAKER -j$NUMCPU - GLEW_DEST=$DEPLOYDIR CC=$CC $MAKER install + GLEW_DEST=$DEPLOYDIR $MAKER -j$NUMCPU + GLEW_DEST=$DEPLOYDIR $MAKER install } build_opencsg() -- cgit v0.10.1 From 1a399e7a3001ce3ae6b4e14d6fe3faad48ddfeee Mon Sep 17 00:00:00 2001 From: don bright Date: Fri, 21 Dec 2012 03:24:43 +0100 Subject: document 'out of tree' dependency build. fix opencsg on netbsd diff --git a/scripts/uni-build-dependencies.sh b/scripts/uni-build-dependencies.sh index 6b7d0d1..c39d383 100755 --- a/scripts/uni-build-dependencies.sh +++ b/scripts/uni-build-dependencies.sh @@ -6,13 +6,23 @@ # # This script builds all library dependencies of OpenSCAD for Linux/BSD +# (Except large ones like qt and gcc) # -# Usage: uni-build-dependencies.sh +# Standard usage: +# cd openscad +# . ./scripts/setenv-unibuild.sh +# ./scripts/uni-build-dependencies.sh +# +# Out-of-tree usage +# +# cd somepath +# . /path/to/openscad/scripts/setenv-unibuild.sh +# ./path/to/openscad/scripts/uni-build-dependencies.sh # # Prerequisites: # - wget or curl # - Qt4 -# - other +# - gcc (clang=experimental) # printUsage() @@ -287,11 +297,12 @@ build_opencsg() make - ls lib/* include/* + ls lib/* lib/.libs/* include/* echo "installing to -->" $DEPLOYDIR mkdir -p $DEPLOYDIR/lib mkdir -p $DEPLOYDIR/include install lib/* $DEPLOYDIR/lib + install lib/.libs/* $DEPLOYDIR/lib # netbsd install include/* $DEPLOYDIR/include cd $BASEDIR -- cgit v0.10.1 From b43cee7f418c4cc202346843a3bd94d8f56bcffd Mon Sep 17 00:00:00 2001 From: don bright Date: Fri, 21 Dec 2012 07:36:36 -0600 Subject: opensuse - get bison/flex diff --git a/scripts/uni-get-dependencies.sh b/scripts/uni-get-dependencies.sh index 8c6fd06..d170ed5 100755 --- a/scripts/uni-get-dependencies.sh +++ b/scripts/uni-get-dependencies.sh @@ -15,6 +15,11 @@ get_freebsd_deps() pkg_add -r opencsg cgal } +get_opensuse_deps() +{ + sudo zypper install libeigen2-devel mpfr-devel gmp-devel boost-devel \ + libqt4-devel glew-devel cmake git bison flex cgal-devel opencsg-devel +} debian_too_old() { @@ -52,13 +57,6 @@ get_debian_deps() } -get_opensuse_deps() -{ - sudo zypper install libeigen2-devel mpfr-devel gmp-devel boost-devel \ - libqt4-devel glew-devel cmake git cgal-devel -} - - if [ "`cat /etc/issue | grep -i ubuntu`" ]; then get_debian_deps elif [ "`cat /etc/issue | grep -i debian`" ]; then -- cgit v0.10.1 From d8ecb145ac85fea67f55732ffc3018247bc33aae Mon Sep 17 00:00:00 2001 From: don bright Date: Fri, 21 Dec 2012 08:30:27 -0600 Subject: deal with black-on-white terminals. opencsg:dont copy lib/.libs if not there. diff --git a/scripts/check-dependencies.sh b/scripts/check-dependencies.sh index 1ac864c..f1a16b8 100755 --- a/scripts/check-dependencies.sh +++ b/scripts/check-dependencies.sh @@ -496,15 +496,15 @@ pretty_print() { debug pretty_print $* - brightred="\033[1;31m" - red="\033[0;31m" - brown="\033[0;33m" - yellow="\033[1;33m" - white="\033[1;37m" - purple="\033[1;35m" - green="\033[0;32m" - cyan="\033[0;36m" - gray="\033[0;37m" + brightred="\033[40;31m" + red="\033[40;31m" + brown="\033[40;33m" + yellow="\033[40;33m" + white="\033[40;37m" + purple="\033[40;35m" + green="\033[40;32m" + cyan="\033[40;36m" + gray="\033[40;37m" nocolor="\033[0m" ppstr="%s%-12s" @@ -517,20 +517,20 @@ pretty_print() fi if [ $2 ]; then pp_minver=$2; else pp_minver="unknown"; fi - if [ $3 ]; then pp_sysver=$3; else pp_sysver="unknown"; fi + if [ $3 ]; then pp_foundver=$3; else pp_foundver="unknown"; fi if [ $4 ]; then pp_compared=$4; else pp_compared="NotOK"; fi if [ $pp_compared = "NotOK" ]; then + pp_foundcolor=$purple; pp_cmpcolor=$purple; - pp_ivcolor=$purple; else + pp_foundcolor=$gray; pp_cmpcolor=$green; - pp_ivcolor=$gray; fi - echo -e $cyan $pp_dep $gray $pp_minver $pp_ivcolor $pp_sysver $pp_cmpcolor $pp_compared | awk $pp_format + echo -e $cyan $pp_dep $gray $pp_minver $pp_foundcolor $pp_foundver $pp_cmpcolor $pp_compared | awk $pp_format pp_dep= pp_minver= - pp_sysver= + pp_foundver= pp_compared= } diff --git a/scripts/uni-build-dependencies.sh b/scripts/uni-build-dependencies.sh index c39d383..f7bedb6 100755 --- a/scripts/uni-build-dependencies.sh +++ b/scripts/uni-build-dependencies.sh @@ -297,13 +297,14 @@ build_opencsg() make - ls lib/* lib/.libs/* include/* + ls lib/* include/* + if [ -e lib/.libs ]; then ls lib/.libs/*; fi # netbsd echo "installing to -->" $DEPLOYDIR mkdir -p $DEPLOYDIR/lib mkdir -p $DEPLOYDIR/include install lib/* $DEPLOYDIR/lib - install lib/.libs/* $DEPLOYDIR/lib # netbsd install include/* $DEPLOYDIR/include + if [ -e lib/.libs ]; then install lib/.libs/* $DEPLOYDIR/lib; fi #netbsd cd $BASEDIR } -- cgit v0.10.1 From a75743f2a3e5636f1a08f47de7e106c344776cb9 Mon Sep 17 00:00:00 2001 From: don bright Date: Fri, 21 Dec 2012 08:40:57 -0600 Subject: update README to show how to build only opencsg/cgal dependencies diff --git a/README.md b/README.md index 1889acd..91717b6 100644 --- a/README.md +++ b/README.md @@ -158,9 +158,17 @@ running these commands: source ./scripts/setenv-unibuild.sh ./scripts/uni-build-dependencies.sh -This may take several hours. Note it will not build huge deps like gcc -or qt, only the smaller ones (boost, CGAL, opencsg, etc). After -completion, again check dependencies +This may take an hour or more, depending on your network and system. As +a special timesaver if you are only missing CGAL and OpenCSG, you can do +this instead: + + source ./scripts/setenv-unibuild.sh + ./scripts/uni-build-dependencies.sh opencsg + ./scripts/uni-build-dependencies.sh cgal + +Note that huge dependencies like gcc or qt are not included here, only +the smaller ones (boost, CGAL, opencsg, etc). After the build, again +check dependencies source ./scripts/setenv-unibuild.sh ./scripts/check-dependencies.sh -- cgit v0.10.1 From ef72f6fa7d3e55e11d6b7efdcee339a9cb12d5a8 Mon Sep 17 00:00:00 2001 From: don bright Date: Fri, 21 Dec 2012 09:31:01 -0600 Subject: fix slight bug in cgal build diff --git a/scripts/uni-build-dependencies.sh b/scripts/uni-build-dependencies.sh index f7bedb6..a7c62d2 100755 --- a/scripts/uni-build-dependencies.sh +++ b/scripts/uni-build-dependencies.sh @@ -1,4 +1,4 @@ -#!/bin/sh -e + #!/bin/sh -e # uni-build-dependencies by don bright 2012. copyright assigned to # Marius Kintel and Clifford Wolf, 2012. released under the GPL 2, or @@ -197,7 +197,7 @@ build_cgal() fi tar jxf CGAL-$version.tar.bz2 cd CGAL-$version - if [ $2 = use-sys-libs ]; then + 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 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 -- cgit v0.10.1 From bb317292c005679415f735e571fed17546bbf2d0 Mon Sep 17 00:00:00 2001 From: Don Bright Date: Fri, 21 Dec 2012 10:21:24 -0600 Subject: revise ubuntu / debian detection, dont try to detect version. check libgmp3-dev diff --git a/scripts/check-dependencies.sh b/scripts/check-dependencies.sh index f1a16b8..5e337c1 100755 --- a/scripts/check-dependencies.sh +++ b/scripts/check-dependencies.sh @@ -593,6 +593,7 @@ main() #deps="$deps python" # needs work, only needed for tests #deps="$deps imagemagick" # needs work, only needed for tests #deps="eigen glew opencsg" # debug + deps=glew pretty_print title for dep in $deps; do debug "processing $dep" diff --git a/scripts/uni-get-dependencies.sh b/scripts/uni-get-dependencies.sh index d170ed5..09c8181 100755 --- a/scripts/uni-get-dependencies.sh +++ b/scripts/uni-get-dependencies.sh @@ -21,39 +21,20 @@ get_opensuse_deps() libqt4-devel glew-devel cmake git bison flex cgal-devel opencsg-devel } -debian_too_old() -{ - echo "System version too low. Please try 'old linux' build (see README.md)" - exit 1 -} - get_debian_deps() { - if [ "`cat /etc/issue | grep 'Debian GNU/Linux 6.0'`" ]; then - debian_too_old - fi - if [ "`cat /etc/issue | grep 'Debian GNU/Linux 5'`" ]; then - debian_too_old - fi - if [ "`cat /etc/issue | grep 'Ubuntu 10'`" ]; then - debian_too_old - fi - if [ "`cat /etc/issue | grep 'Ubuntu 9'`" ]; then - debian_too_old - fi - if [ "`cat /etc/issue | grep 'Ubuntu 8'`" ]; then - debian_too_old - fi - if [ "`cat /etc/issue | grep 'Ubuntu 7'`" ]; then - debian_too_old - fi - echo "Tested on Ubuntu 12.04" sudo apt-get install build-essential libqt4-dev libqt4-opengl-dev \ libxmu-dev cmake bison flex libeigen2-dev git-core libboost-all-dev \ - libXi-dev libmpfr-dev libgmp-dev libboost-dev libglew1.6-dev \ + libXi-dev libmpfr-dev libboost-dev libglew1.6-dev \ libcgal-dev libopencsg-dev + + if [ "`apt-cache search libgmp | grep libgmp3-dev`" ]; then + sudo apt-get install libgmp3-dev + else + sudo apt-get install libgmp-dev + fi } -- cgit v0.10.1 From b1ecf351347d83830a546d3d6c49eafc6781634b Mon Sep 17 00:00:00 2001 From: Don Bright Date: Fri, 21 Dec 2012 10:41:06 -0600 Subject: remove debug line diff --git a/scripts/check-dependencies.sh b/scripts/check-dependencies.sh index 5e337c1..f1a16b8 100755 --- a/scripts/check-dependencies.sh +++ b/scripts/check-dependencies.sh @@ -593,7 +593,6 @@ main() #deps="$deps python" # needs work, only needed for tests #deps="$deps imagemagick" # needs work, only needed for tests #deps="eigen glew opencsg" # debug - deps=glew pretty_print title for dep in $deps; do debug "processing $dep" -- cgit v0.10.1 From 870f3dcd2d20362995308cd2829c8d7ba61cf623 Mon Sep 17 00:00:00 2001 From: don bright Date: Fri, 21 Dec 2012 14:59:35 -0500 Subject: deal with situation where gcc doesnt exist. add mageia urpmi commands. shorten os detect code diff --git a/scripts/check-dependencies.sh b/scripts/check-dependencies.sh index f1a16b8..4254ee9 100755 --- a/scripts/check-dependencies.sh +++ b/scripts/check-dependencies.sh @@ -144,7 +144,12 @@ bison_sysver() gcc_sysver() { bingcc=$1/bin/gcc - if [ ! -x $1/bin/gcc ]; then bingcc=gcc; fi + if [ ! -x $1/bin/gcc ]; then + if [ "`command -v gcc`" ]; then # fallback to $PATH + bingcc=gcc; + fi + fi + if [ ! -x $bingcc ]; then return; fi if [ ! "`$bingcc --version`" ]; then return; fi gccver=`$bingcc --version| grep -i gcc` gccver=`echo $gccver | sed s/"[^0-9. ]"/" "/g | awk '{print $1}'` diff --git a/scripts/uni-get-dependencies.sh b/scripts/uni-get-dependencies.sh index 09c8181..03aecfb 100755 --- a/scripts/uni-get-dependencies.sh +++ b/scripts/uni-get-dependencies.sh @@ -1,3 +1,5 @@ +# auto-install dependency packages using the systems package manager. +# after running this, run ./script/check-dependencies.sh. see README.md get_fedora_deps() { @@ -21,6 +23,18 @@ get_opensuse_deps() libqt4-devel glew-devel cmake git bison flex cgal-devel opencsg-devel } +get_mageia_deps() +{ + pklist="task-c-devel task-c++-devel" + pklist="$pklist libqt4-devel libgmp-devel libmpfr-devel" + pklist="$pklist libboost-devel eigen3-devel" + pklist="$pklist bison flex" + pklist="$pklist cmake imagemagick python curl git" + # cgal + opencsg don't exist + sudo urpmi ctags + sudo urpmi $pklist +} + get_debian_deps() { echo "Tested on Ubuntu 12.04" @@ -38,18 +52,20 @@ get_debian_deps() } -if [ "`cat /etc/issue | grep -i ubuntu`" ]; then +if [ "`grep -i ubuntu /etc/issue`" ]; then get_debian_deps -elif [ "`cat /etc/issue | grep -i debian`" ]; then +elif [ "`grep -i debian /etc/issue`" ]; then get_debian_deps -elif [ "`cat /etc/issue | grep -i opensuse`" ]; then +elif [ "`grep -i suse /etc/issue`" ]; then get_opensuse_deps -elif [ "`cat /etc/issue | grep -i freebsd`" ]; then +elif [ "`grep -i freebsd /etc/issue`" ]; then get_freebsd_deps -elif [ "`cat /etc/issue | grep -i fedora`" ]; then +elif [ "`grep -i fedora /etc/issue`" ]; then get_fedora_deps -elif [ "`cat /etc/issue | grep -i redhat`" ]; then +elif [ "`grep -i redhat /etc/issue`" ]; then get_fedora_deps +elif [ "`grep -i mageia /etc/issue`" ]; then + get_mageia_deps else echo "Unknown system type. Please install the dependency packages listed" echo "in README.md using your system's package manager." -- cgit v0.10.1 From e3ea506d06ae012cac3a724bcc97b3f1ba8187b8 Mon Sep 17 00:00:00 2001 From: don bright Date: Fri, 21 Dec 2012 16:54:43 -0500 Subject: add libglew-dev to mageia diff --git a/scripts/uni-get-dependencies.sh b/scripts/uni-get-dependencies.sh index 03aecfb..d2e9a51 100755 --- a/scripts/uni-get-dependencies.sh +++ b/scripts/uni-get-dependencies.sh @@ -27,7 +27,7 @@ get_mageia_deps() { pklist="task-c-devel task-c++-devel" pklist="$pklist libqt4-devel libgmp-devel libmpfr-devel" - pklist="$pklist libboost-devel eigen3-devel" + pklist="$pklist libboost-devel eigen3-devel libglew-devel" pklist="$pklist bison flex" pklist="$pklist cmake imagemagick python curl git" # cgal + opencsg don't exist -- cgit v0.10.1 From cdc408319e9474e9a4ffbfc080ced23c5ad4f23e Mon Sep 17 00:00:00 2001 From: don bright Date: Fri, 21 Dec 2012 23:44:45 +0100 Subject: NetBSD deps. also detect stray copies of libraries under /usr/local on linux diff --git a/scripts/check-dependencies.sh b/scripts/check-dependencies.sh index 4254ee9..29ed100 100755 --- a/scripts/check-dependencies.sh +++ b/scripts/check-dependencies.sh @@ -580,7 +580,27 @@ find_installed_version() } - +check_old_local() +{ + warnon= + if [ "`uname | grep -i linux`" ]; then + header_list="opencsg.h CGAL boost GL/glew.h" + liblist="libboost 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" + warnon=1 + fi + if [ -e /usr/local/lib/$i ]; then + echo "Warning: you have a copy of " $i " under /usr/local/lib" + warnon=1 + fi + done + fi + if [ $warnon ]; then + echo "Please verify your local copies don't conflict with the system" + fi +} @@ -609,6 +629,7 @@ main() dep_compare=$compare_version_result pretty_print $dep $dep_minver $dep_sysver $dep_compare done + check_old_local } checkargs $* diff --git a/scripts/uni-get-dependencies.sh b/scripts/uni-get-dependencies.sh index d2e9a51..19320c3 100755 --- a/scripts/uni-get-dependencies.sh +++ b/scripts/uni-get-dependencies.sh @@ -11,14 +11,22 @@ get_fedora_deps() get_freebsd_deps() { echo "Tested on FreeBSD 9" - pkg_add -r bison boost-libs cmake git bash eigen2 flex gmake gmp mpfr - pkg_add -r xorg libGLU libXmu libXi xorg-vfbserver glew - pkg_add -r qt4-corelib qt4-gui qt4-moc qt4-opengl qt4-qmake qt4-rcc qt4-uic - pkg_add -r opencsg cgal + pkg_add -r bison boost-libs cmake git bash eigen2 flex gmake gmp mpfr \ + xorg libGLU libXmu libXi xorg-vfbserver glew \ + qt4-corelib qt4-gui qt4-moc qt4-opengl qt4-qmake qt4-rcc qt4-uic \ + opencsg cgal +} + +get_netbsd_deps() +{ + echo tested on netbsd 6 + sudo pkgin install bison boost cmake git bash eigen flex gmake gmp mpfr \ + qt4 glew cgal opencsg modular-xorg } get_opensuse_deps() { + echo tested on opensuse 12 sudo zypper install libeigen2-devel mpfr-devel gmp-devel boost-devel \ libqt4-devel glew-devel cmake git bison flex cgal-devel opencsg-devel } @@ -52,22 +60,27 @@ get_debian_deps() } -if [ "`grep -i ubuntu /etc/issue`" ]; then - get_debian_deps -elif [ "`grep -i debian /etc/issue`" ]; then - get_debian_deps -elif [ "`grep -i suse /etc/issue`" ]; then - get_opensuse_deps -elif [ "`grep -i freebsd /etc/issue`" ]; then + +if [ -e /etc/issue ]; then + if [ "`grep -i ubuntu /etc/issue`" ]; then + get_debian_deps + elif [ "`grep -i debian /etc/issue`" ]; then + get_debian_deps + elif [ "`grep -i suse /etc/issue`" ]; then + get_opensuse_deps + elif [ "`grep -i fedora /etc/issue`" ]; then + get_fedora_deps + elif [ "`grep -i redhat /etc/issue`" ]; then + get_fedora_deps + elif [ "`grep -i mageia /etc/issue`" ]; then + get_mageia_deps + fi +elif [ "`uname | grep -i freebsd `" ]; then get_freebsd_deps -elif [ "`grep -i fedora /etc/issue`" ]; then - get_fedora_deps -elif [ "`grep -i redhat /etc/issue`" ]; then - get_fedora_deps -elif [ "`grep -i mageia /etc/issue`" ]; then - get_mageia_deps +elif [ "`uname | grep -i netbsd`" ]; then + get_netbsd_deps else - echo "Unknown system type. Please install the dependency packages listed" - echo "in README.md using your system's package manager." + echo "Unknown system type. Please install the dependency packages listed" + echo "in README.md using your system's package manager." fi -- cgit v0.10.1 From fac239c0a2de02414d4fe7a96305d0ae47557c67 Mon Sep 17 00:00:00 2001 From: don bright Date: Sat, 22 Dec 2012 00:01:19 +0100 Subject: stop apt-get from failing on unfound package names diff --git a/scripts/uni-get-dependencies.sh b/scripts/uni-get-dependencies.sh index 19320c3..1832881 100755 --- a/scripts/uni-get-dependencies.sh +++ b/scripts/uni-get-dependencies.sh @@ -45,18 +45,12 @@ get_mageia_deps() get_debian_deps() { - echo "Tested on Ubuntu 12.04" - - sudo apt-get install build-essential libqt4-dev libqt4-opengl-dev \ - libxmu-dev cmake bison flex libeigen2-dev git-core libboost-all-dev \ - libXi-dev libmpfr-dev libboost-dev libglew1.6-dev \ - libcgal-dev libopencsg-dev - - if [ "`apt-cache search libgmp | grep libgmp3-dev`" ]; then - sudo apt-get install libgmp3-dev - else - sudo apt-get install libgmp-dev - fi + for pkg in build-essential libqt4-dev libqt4-opengl-dev \ + libxmu-dev cmake bison flex git-core libboost-all-dev \ + libXi-dev libmpfr-dev libboost-dev libglew-dev libeigen2-dev \ + libeigen3-dev libcgal-dev libopencsg-dev libgmp3-dev libgmp-dev; do + sudo apt-get -y install $pkg; + done } -- cgit v0.10.1 From 0f72b116c5ae5602f708fbd16a815bde995dd9d5 Mon Sep 17 00:00:00 2001 From: don bright Date: Sat, 22 Dec 2012 00:23:33 +0100 Subject: deal with unknown system type better. remove 'tested on' messages diff --git a/scripts/check-dependencies.sh b/scripts/check-dependencies.sh index 29ed100..e1afba5 100755 --- a/scripts/check-dependencies.sh +++ b/scripts/check-dependencies.sh @@ -18,7 +18,6 @@ # funcname_abbreviated_tmp. Local vars are not used for portability. # # todo -# look in /usr/local/ on linux # if /usr/ and /usr/local/ on linux both hit, throw an error # fallback- pkgconfig --exists, then --modversion # fallback2 - pkg manager @@ -588,17 +587,17 @@ check_old_local() liblist="libboost 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" + echo "Warning: you have a copy of "$i" under /usr/local/include" warnon=1 fi if [ -e /usr/local/lib/$i ]; then - echo "Warning: you have a copy of " $i " under /usr/local/lib" + echo "Warning: you have a copy of "$i" under /usr/local/lib" warnon=1 fi done fi if [ $warnon ]; then - echo "Please verify your local copies don't conflict with the system" + echo "Please verify these local copies don't conflict with the system" fi } diff --git a/scripts/uni-get-dependencies.sh b/scripts/uni-get-dependencies.sh index 1832881..cb03563 100755 --- a/scripts/uni-get-dependencies.sh +++ b/scripts/uni-get-dependencies.sh @@ -1,16 +1,17 @@ # auto-install dependency packages using the systems package manager. # after running this, run ./script/check-dependencies.sh. see README.md +# +# this assumes you have sudo installed or are running as root. +# get_fedora_deps() { - echo "Tested on Fedora 17" sudo yum install qt-devel bison flex eigen2-devel \ boost-devel mpfr-devel gmp-devel glew-devel CGAL-devel gcc pkgconfig git } get_freebsd_deps() { - echo "Tested on FreeBSD 9" pkg_add -r bison boost-libs cmake git bash eigen2 flex gmake gmp mpfr \ xorg libGLU libXmu libXi xorg-vfbserver glew \ qt4-corelib qt4-gui qt4-moc qt4-opengl qt4-qmake qt4-rcc qt4-uic \ @@ -19,14 +20,12 @@ get_freebsd_deps() get_netbsd_deps() { - echo tested on netbsd 6 sudo pkgin install bison boost cmake git bash eigen flex gmake gmp mpfr \ qt4 glew cgal opencsg modular-xorg } get_opensuse_deps() { - echo tested on opensuse 12 sudo zypper install libeigen2-devel mpfr-devel gmp-devel boost-devel \ libqt4-devel glew-devel cmake git bison flex cgal-devel opencsg-devel } @@ -54,6 +53,11 @@ get_debian_deps() } +unknown() +{ + echo "Unknown system type. Please install the dependency packages listed" + echo "in README.md using your system's package manager." +} if [ -e /etc/issue ]; then if [ "`grep -i ubuntu /etc/issue`" ]; then @@ -64,17 +68,18 @@ if [ -e /etc/issue ]; then get_opensuse_deps elif [ "`grep -i fedora /etc/issue`" ]; then get_fedora_deps - elif [ "`grep -i redhat /etc/issue`" ]; then + elif [ "`grep -i red.hat /etc/issue`" ]; then get_fedora_deps elif [ "`grep -i mageia /etc/issue`" ]; then get_mageia_deps + else + unknown fi elif [ "`uname | grep -i freebsd `" ]; then get_freebsd_deps elif [ "`uname | grep -i netbsd`" ]; then get_netbsd_deps else - echo "Unknown system type. Please install the dependency packages listed" - echo "in README.md using your system's package manager." + unknown fi -- cgit v0.10.1 From f3cd856282e45eeb3facfa4c52c99be13b5477ad Mon Sep 17 00:00:00 2001 From: don bright Date: Sun, 23 Dec 2012 01:00:48 +0100 Subject: netbsd fixes diff --git a/README.md b/README.md index 91717b6..a40f63b 100644 --- a/README.md +++ b/README.md @@ -133,10 +133,11 @@ After that, follow the Compilation instructions below. ### Building for Linux/BSD -First, make sure that you have git installed (git-core in debian). Once -you've cloned this git repository, download and install the dependency -packages listed above using your system's package manager. A convenience -script is provided that can help with this process: +First, make sure that you have git installed (often packaged as 'git-core' +or 'scmgit'). Once you've cloned this git repository, download and install +the dependency packages listed above using your system's package +manager. A convenience script is provided that can help with this +process: ./scripts/uni-get-dependencies.sh diff --git a/eigen.pri b/eigen.pri index b7fe366..5dd3279 100644 --- a/eigen.pri +++ b/eigen.pri @@ -69,4 +69,8 @@ isEmpty(EIGEN_INCLUDEPATH) { # EIGEN being under 'include/eigen[2-3]' needs special prepending QMAKE_INCDIR_QT = $$EIGEN_INCLUDEPATH $$QMAKE_INCDIR_QT +netbsd* { + QMAKE_CXXFLAGS = -I$$EIGEN_INCLUDEPATH $$QMAKE_CXXFLAGS +} + } # eigen diff --git a/openscad.pro b/openscad.pro index 91bd735..49b764f 100644 --- a/openscad.pro +++ b/openscad.pro @@ -90,11 +90,14 @@ unix:!macx { } netbsd* { - LIBS += -L/usr/X11R7/lib + QMAKE_LFLAGS += -L/usr/X11R7/lib QMAKE_LFLAGS += -Wl,-R/usr/X11R7/lib QMAKE_LFLAGS += -Wl,-R/usr/pkg/lib !isEmpty(OPENSCAD_LIBDIR) { - QMAKE_LFLAGS += -Wl,-R$$OPENSCAD_LIBDIR/lib + QMAKE_CFLAGS = -I$$OPENSCAD_LIBDIR/include $$QMAKE_CFLAGS + QMAKE_CXXFLAGS = -I$$OPENSCAD_LIBDIR/include $$QMAKE_CXXFLAGS + QMAKE_LFLAGS = -L$$OPENSCAD_LIBDIR/lib $$QMAKE_LFLAGS + QMAKE_LFLAGS = -Wl,-R$$OPENSCAD_LIBDIR/lib $$QMAKE_LFLAGS } } diff --git a/scripts/setenv-unibuild.sh b/scripts/setenv-unibuild.sh index e734df7..456c7cd 100644 --- a/scripts/setenv-unibuild.sh +++ b/scripts/setenv-unibuild.sh @@ -58,7 +58,7 @@ setenv_netbsd() QMAKESPEC=netbsd-g++ QTDIR=/usr/pkg/qt4 PATH=/usr/pkg/qt4/bin:$PATH - LD_LIBRARY_PATH=/usr/pkg/qt4/lib:$LD_LIBRARY_PATH + LD_LIBRARY_PATH=/usr/pkg/qt4/lib:/usr/X11R7/lib:$LD_LIBRARY_PATH export QMAKESPEC export QTDIR diff --git a/scripts/uni-get-dependencies.sh b/scripts/uni-get-dependencies.sh index cb03563..c530be9 100755 --- a/scripts/uni-get-dependencies.sh +++ b/scripts/uni-get-dependencies.sh @@ -20,6 +20,8 @@ get_freebsd_deps() get_netbsd_deps() { + echo Netbsd: You must install the X sets before running.. + sleep 2 sudo pkgin install bison boost cmake git bash eigen flex gmake gmp mpfr \ qt4 glew cgal opencsg modular-xorg } -- cgit v0.10.1 From e52787b07d6da878791e828f396c9857ffbbce77 Mon Sep 17 00:00:00 2001 From: don bright Date: Sun, 23 Dec 2012 16:52:16 +0100 Subject: make glew min 1.5.4 (its OK). fix glew + gcc detection. more debugging info. diff --git a/README.md b/README.md index a40f63b..dd7c4f8 100644 --- a/README.md +++ b/README.md @@ -91,7 +91,7 @@ Follow the instructions for the platform you're compiling on below. * [MPFR (3.x)](http://www.mpfr.org/) * [boost (1.35 - 1.47)](http://www.boost.org/) * [OpenCSG (1.3.2)](http://www.opencsg.org/) -* [GLEW (1.6 ->)](http://glew.sourceforge.net/) +* [GLEW (1.5.4 ->)](http://glew.sourceforge.net/) * [Eigen (2.0.13->3.1.1)](http://eigen.tuxfamily.org/) * [GCC C++ Compiler (4.2 ->)](http://gcc.gnu.org/) * [Bison (2.4)](http://www.gnu.org/software/bison/) diff --git a/scripts/check-dependencies.sh b/scripts/check-dependencies.sh index e1afba5..bbf1baf 100755 --- a/scripts/check-dependencies.sh +++ b/scripts/check-dependencies.sh @@ -116,7 +116,23 @@ qt4_sysver() glew_sysver() { - glew_sysver_result= # glew has no traditional version numbers + glewh=$1/include/GL/glew.h + if [ -e $glewh ]; then + # glew has no traditional version number in it's headers + # so we either test for what we need and 'guess', or assign it to 0.0 + # the resulting number is a 'lower bound', not exactly what is installed + if [ "`grep __GLEW_VERSION_4_2 $glewh`" ]; then + glew_sysver_result=1.7.0 + fi + if [ ! $glew_sysver_result ]; then + if [ "`grep __GLEW_ARB_occlusion_query2 $glewh`" ]; then + glew_sysver_result=1.5.4 + fi + fi + if [ ! $glew_sysver_result ]; then + glew_sysver_result=0.0 + fi + fi } imagemagick_sysver() @@ -148,9 +164,13 @@ gcc_sysver() bingcc=gcc; fi fi + debug using bingcc: $bingcc if [ ! -x $bingcc ]; then return; fi if [ ! "`$bingcc --version`" ]; then return; fi gccver=`$bingcc --version| grep -i gcc` + debug gcc output1: $gccver + gccver=`echo $gccver | sed s/"(.*)"//g ` + debug gcc output2: $gccver gccver=`echo $gccver | sed s/"[^0-9. ]"/" "/g | awk '{print $1}'` gcc_sysver_result=$gccver } @@ -562,6 +582,7 @@ find_installed_version() # use pkg-config to search if [ ! $fsv_tmp ]; then if [ "`command -v pkg-config`" ]; then + debug plain search failed. trying pkg_config... pkg_config_search $dep fsv_tmp=$pkg_config_search_result fi @@ -569,12 +590,15 @@ find_installed_version() # use the package system to search if [ ! $fsv_tmp ]; then + debug plain + pkg_config search both failed... trying package search pkg_search $dep fsv_tmp=$pkg_search_result fi if [ $fsv_tmp ]; then find_installed_version_result=$fsv_tmp + else + debug all searches failed. unknown version. fi } -- cgit v0.10.1 From f1e22352800a199e9353e4a79baf660c02854f51 Mon Sep 17 00:00:00 2001 From: don bright Date: Sun, 23 Dec 2012 16:54:57 +0100 Subject: dont test for git, curl. they arent strictly needed for build diff --git a/scripts/check-dependencies.sh b/scripts/check-dependencies.sh index bbf1baf..8b2f550 100755 --- a/scripts/check-dependencies.sh +++ b/scripts/check-dependencies.sh @@ -637,10 +637,11 @@ checkargs() main() { deps="qt4 cgal gmp cmake mpfr boost opencsg glew eigen gcc" - deps="$deps bison flex git curl make" - #deps="$deps python" # needs work, only needed for tests + deps="$deps bison flex make" + #deps=$deps curl git # not technically necessary for build + #deps="$deps python" # only needed for tests #deps="$deps imagemagick" # needs work, only needed for tests - #deps="eigen glew opencsg" # debug + #deps="eigen glew opencsg" # debugging pretty_print title for dep in $deps; do debug "processing $dep" -- cgit v0.10.1 From 91cec829ee781e079feec5aee456b618f9667100 Mon Sep 17 00:00:00 2001 From: don bright Date: Sun, 23 Dec 2012 15:12:27 -0600 Subject: fixes for Alt Linux diff --git a/scripts/check-dependencies.sh b/scripts/check-dependencies.sh index 8b2f550..dea2e27 100755 --- a/scripts/check-dependencies.sh +++ b/scripts/check-dependencies.sh @@ -158,20 +158,17 @@ bison_sysver() gcc_sysver() { - bingcc=$1/bin/gcc - if [ ! -x $1/bin/gcc ]; then - if [ "`command -v gcc`" ]; then # fallback to $PATH - bingcc=gcc; + bingcc=$1/bin/g++ + if [ ! -x $1/bin/g++ ]; then + if [ "`command -v g++`" ]; then # fallback to $PATH + bingcc=g++; fi fi debug using bingcc: $bingcc if [ ! -x $bingcc ]; then return; fi if [ ! "`$bingcc --version`" ]; then return; fi - gccver=`$bingcc --version| grep -i gcc` - debug gcc output1: $gccver - gccver=`echo $gccver | sed s/"(.*)"//g ` - debug gcc output2: $gccver - gccver=`echo $gccver | sed s/"[^0-9. ]"/" "/g | awk '{print $1}'` + gccver=`$bingcc --version| grep -i g++ | awk ' { print $3 } '` + debug g++ output1: $gccver gcc_sysver_result=$gccver } @@ -252,6 +249,13 @@ set_default_package_map() apt_pkg_search() { + + if [ ! "`command -v dpkg`" ]; then + # can't handle systems that use apt-get for RPMs (alt linux) + debug command dpkg not found. cannot search packages. + return + fi + debug apt_pkg_search $* apt_pkg_search_result= pkgname=$1 @@ -279,10 +283,6 @@ apt_pkg_search() fi debug $pkgname ".deb name:" $debpkgname - if [ ! "`command -v dpkg`" ]; then - debug command dpkg not found. cannot search packages. - return - fi # examples of apt version strings # cgal 4.0-4 gmp 2:5.0.5+dfsg bison 1:2.5.dfsg-2.1 cmake 2.8.9~rc1 @@ -636,10 +636,10 @@ checkargs() main() { - deps="qt4 cgal gmp cmake mpfr boost opencsg glew eigen gcc" + deps="qt4 cgal gmp mpfr boost opencsg glew eigen gcc" deps="$deps bison flex make" - #deps=$deps curl git # not technically necessary for build - #deps="$deps python" # only needed for tests + #deps="$deps curl git" # not technically necessary for build + #deps="$deps python cmake" # only needed for tests #deps="$deps imagemagick" # needs work, only needed for tests #deps="eigen glew opencsg" # debugging pretty_print title diff --git a/scripts/uni-get-dependencies.sh b/scripts/uni-get-dependencies.sh index c530be9..58bebe6 100755 --- a/scripts/uni-get-dependencies.sh +++ b/scripts/uni-get-dependencies.sh @@ -10,6 +10,13 @@ get_fedora_deps() boost-devel mpfr-devel gmp-devel glew-devel CGAL-devel gcc pkgconfig git } +get_altlinux_deps() +{ + for i in boost-devel boost-filesystem-devel gcc4.5 gcc4.5-c++ \ + eigen2 libmpfr libgmp libgmp_cxx qt4-devel libcgal-devel git-core \ + libglew-devel flex bison; do sudo apt-get install $i; done +} + get_freebsd_deps() { pkg_add -r bison boost-libs cmake git bash eigen2 flex gmake gmp mpfr \ @@ -20,8 +27,6 @@ get_freebsd_deps() get_netbsd_deps() { - echo Netbsd: You must install the X sets before running.. - sleep 2 sudo pkgin install bison boost cmake git bash eigen flex gmake gmp mpfr \ qt4 glew cgal opencsg modular-xorg } @@ -34,14 +39,10 @@ get_opensuse_deps() get_mageia_deps() { - pklist="task-c-devel task-c++-devel" - pklist="$pklist libqt4-devel libgmp-devel libmpfr-devel" - pklist="$pklist libboost-devel eigen3-devel libglew-devel" - pklist="$pklist bison flex" - pklist="$pklist cmake imagemagick python curl git" - # cgal + opencsg don't exist sudo urpmi ctags - sudo urpmi $pklist + sudo urpmi task-c-devel task-c++-devel libqt4-devel libgmp-devel \ + libmpfr-devel libboost-devel eigen3-devel libglew-devel bison flex \ + cmake imagemagick python curl git } get_debian_deps() @@ -74,8 +75,10 @@ if [ -e /etc/issue ]; then get_fedora_deps elif [ "`grep -i mageia /etc/issue`" ]; then get_mageia_deps - else - unknown + elif [ "`command -v rpm`" ]; then + if [ "`rpm -qa | grep altlinux`" ]; then + get_altlinux_deps + fi fi elif [ "`uname | grep -i freebsd `" ]; then get_freebsd_deps -- cgit v0.10.1 From 2367db32533c6bb81268e580e155d8ffd37f7ec1 Mon Sep 17 00:00:00 2001 From: don bright Date: Sun, 23 Dec 2012 15:14:46 -0600 Subject: netbsd - ask user to verify X Sets are installed diff --git a/scripts/check-dependencies.sh b/scripts/check-dependencies.sh index dea2e27..f3ef545 100755 --- a/scripts/check-dependencies.sh +++ b/scripts/check-dependencies.sh @@ -614,7 +614,7 @@ check_old_local() echo "Warning: you have a copy of "$i" under /usr/local/include" warnon=1 fi - if [ -e /usr/local/lib/$i ]; then + if [ -e /usr/local/lib/$i.so ]; then echo "Warning: you have a copy of "$i" under /usr/local/lib" warnon=1 fi @@ -626,6 +626,13 @@ check_old_local() } +check_misc() +{ + if [ "`uname -a|grep -i netbsd`" ]; then + echo "NetBSD: Please manually verify the X Sets have been installed" + fi +} + checkargs() { @@ -654,6 +661,7 @@ main() pretty_print $dep $dep_minver $dep_sysver $dep_compare done check_old_local + check_misc } checkargs $* -- cgit v0.10.1 From 7be00e4bc5d0e1c97cf7f69388394376ad238675 Mon Sep 17 00:00:00 2001 From: don bright Date: Sun, 23 Dec 2012 16:01:40 -0600 Subject: more alt linux fixes diff --git a/scripts/uni-get-dependencies.sh b/scripts/uni-get-dependencies.sh index 58bebe6..cf9f136 100755 --- a/scripts/uni-get-dependencies.sh +++ b/scripts/uni-get-dependencies.sh @@ -12,8 +12,8 @@ get_fedora_deps() get_altlinux_deps() { - for i in boost-devel boost-filesystem-devel gcc4.5 gcc4.5-c++ \ - eigen2 libmpfr libgmp libgmp_cxx qt4-devel libcgal-devel git-core \ + for i in boost-devel boost-filesystem-devel gcc4.5 gcc4.5-c++ boost-program_options-devel \ + boost-thread-devel boost-system-devel boost-regex-devel eigen2 libmpfr libgmp libgmp_cxx-devel qt4-devel libcgal-devel git-core \ libglew-devel flex bison; do sudo apt-get install $i; done } -- cgit v0.10.1 From 9deb7de38e99130ba2fd34eff188e671b424e590 Mon Sep 17 00:00:00 2001 From: don bright Date: Sun, 23 Dec 2012 16:58:22 -0600 Subject: CONFIG=skip_version_check should be += otherwise qmake has bizarre problems (bison doesnt get called??) diff --git a/src/version_check.h b/src/version_check.h index a940f6b..b6a63ab 100644 --- a/src/version_check.h +++ b/src/version_check.h @@ -6,7 +6,7 @@ are too old, the user will be warned. If the user wishes to force compilation, they can run - qmake CONFIG=skip-version-check + qmake CONFIG+=skip-version-check Otherwise they will be guided to README.md and an -build-dependencies script. -- cgit v0.10.1 From ad45e8a8c52878ed6f3c7fdfb3198f18b0f8875e Mon Sep 17 00:00:00 2001 From: don bright Date: Sun, 23 Dec 2012 17:14:58 -0600 Subject: detect netbsd / freebsd after linux not before, for bison/flex. diff --git a/bison.pri b/bison.pri index fcfad6f..14e2e01 100644 --- a/bison.pri +++ b/bison.pri @@ -17,7 +17,13 @@ win32 { QMAKE_EXTRA_COMPILERS += bison_header } -unix:freebsd-g++ { +unix:linux* { + exists(/usr/bin/bison) { + QMAKE_YACC = /usr/bin/bison + } +} + +freebsd* { # on bsd /usr/bin/bison is outdated, dont use it exists(/usr/local/bin/bison) { QMAKE_YACC = /usr/local/bin/bison @@ -26,16 +32,10 @@ unix:freebsd-g++ { } } -unix:netbsd* { +netbsd* { exists(/usr/pkg/bin/bison) { QMAKE_YACC = /usr/pkg/bin/bison } else { # look in $PATH QMAKE_YACC = bison } } - -unix:linux* { - exists(/usr/bin/bison) { - QMAKE_YACC = /usr/bin/bison - } -} diff --git a/eigen.pri b/eigen.pri index 5dd3279..fd7ac74 100644 --- a/eigen.pri +++ b/eigen.pri @@ -49,13 +49,13 @@ CONFIG(mingw-cross-env) { isEmpty(EIGEN_INCLUDEPATH) { freebsd-g++: EIGEN_INCLUDEPATH = /usr/local/include/eigen3 macx: EIGEN_INCLUDEPATH = /opt/local/include/eigen3 - linux*|hurd*: EIGEN_INCLUDEPATH = /usr/include/eigen3 netbsd*: EIGEN_INCLUDEPATH = /usr/pkg/include/eigen3 - !exists($$EIGEN_INCLUDEPATH) { + linux*|hurd*|unix: EIGEN_INCLUDEPATH = /usr/include/eigen3 + isEmpty(EIGEN_INCLUDEPATH) { freebsd-g++: EIGEN_INCLUDEPATH = /usr/local/include/eigen2 macx: EIGEN_INCLUDEPATH = /opt/local/include/eigen2 - linux*|hurd*: EIGEN_INCLUDEPATH = /usr/include/eigen2 netbsd*: EIGEN_INCLUDEPATH = /usr/pkg/include/eigen2 + linux*|hurd*|unix*: EIGEN_INCLUDEPATH = /usr/include/eigen2 } } diff --git a/flex.pri b/flex.pri index 57f854e..203d90d 100644 --- a/flex.pri +++ b/flex.pri @@ -9,16 +9,17 @@ win32 { QMAKE_EXTRA_COMPILERS += flex } -unix:freebsd-g++ { +unix:linux* { + exists(/usr/bin/flex) { + QMAKE_LEX = /usr/bin/flex + } +} + +freebsd* { QMAKE_LEX = /usr/local/bin/flex } -unix:netbsd* { +netbsd* { QMAKE_LEX = /usr/pkg/bin/flex } -unix:linux* { - exists(/usr/bin/flex) { - QMAKE_LEX = /usr/bin/flex - } -} diff --git a/glew.pri b/glew.pri index f4a6ccd..9898af5 100644 --- a/glew.pri +++ b/glew.pri @@ -6,7 +6,6 @@ glew { QMAKE_INCDIR += $$GLEW_DIR/include QMAKE_LIBDIR += $$GLEW_DIR/lib QMAKE_LIBDIR += $$GLEW_DIR/lib64 - message("GLEW location: $$GLEW_DIR") } unix:LIBS += -lGLEW diff --git a/openscad.pro b/openscad.pro index 49b764f..6d9556b 100644 --- a/openscad.pro +++ b/openscad.pro @@ -116,11 +116,6 @@ netbsd* { QMAKE_CXXFLAGS_WARN_ON += -Wno-sign-compare } -CONFIG(skip-version-check) { - # force the use of outdated libraries - DEFINES += OPENSCAD_SKIP_VERSION_CHECK -} - # Application configuration macx:CONFIG += mdi CONFIG += cgal @@ -144,6 +139,12 @@ CONFIG(mingw-cross-env) { include(mingw-cross-env.pri) } +# force the use of outdated libraries +CONFIG(skip-version-check) { + DEFINES += OPENSCAD_SKIP_VERSION_CHECK +} + + win32 { FLEXSOURCES = src/lexer.l BISONSOURCES = src/parser.y -- cgit v0.10.1 From bdfbcdf339d7912e52d8400359dd192d4c20169e Mon Sep 17 00:00:00 2001 From: don bright Date: Tue, 25 Dec 2012 01:28:23 +0100 Subject: improve Gcc version detection diff --git a/scripts/check-dependencies.sh b/scripts/check-dependencies.sh index f3ef545..386e0c1 100755 --- a/scripts/check-dependencies.sh +++ b/scripts/check-dependencies.sh @@ -167,8 +167,10 @@ gcc_sysver() debug using bingcc: $bingcc if [ ! -x $bingcc ]; then return; fi if [ ! "`$bingcc --version`" ]; then return; fi - gccver=`$bingcc --version| grep -i g++ | awk ' { print $3 } '` + gccver=`$bingcc --version| grep -i g++ | awk -F "(" ' { print $2 } '` debug g++ output1: $gccver + gccver=`echo $gccver | awk -F ")" ' { print $2 } '` + debug g++ output2: $gccver gcc_sysver_result=$gccver } -- cgit v0.10.1 From b39b2ba9d066afd73958eeea3c50fa7c43326bab Mon Sep 17 00:00:00 2001 From: don bright Date: Mon, 24 Dec 2012 16:34:43 -0800 Subject: fixing g++ version detection diff --git a/scripts/check-dependencies.sh b/scripts/check-dependencies.sh index 386e0c1..c85ba09 100755 --- a/scripts/check-dependencies.sh +++ b/scripts/check-dependencies.sh @@ -171,6 +171,8 @@ gcc_sysver() debug g++ output1: $gccver gccver=`echo $gccver | awk -F ")" ' { print $2 } '` debug g++ output2: $gccver + gccver=`echo $gccver | awk ' { print $1 } '` + debug g++ output3: $gccver gcc_sysver_result=$gccver } -- cgit v0.10.1 From 6693c3b3648e63dfcacd65c3eff9b02e7ea6da32 Mon Sep 17 00:00:00 2001 From: don bright Date: Mon, 24 Dec 2012 18:41:30 -0600 Subject: fix eigen detection bug i introduced yesterday diff --git a/eigen.pri b/eigen.pri index fd7ac74..435355c 100644 --- a/eigen.pri +++ b/eigen.pri @@ -51,7 +51,7 @@ isEmpty(EIGEN_INCLUDEPATH) { macx: EIGEN_INCLUDEPATH = /opt/local/include/eigen3 netbsd*: EIGEN_INCLUDEPATH = /usr/pkg/include/eigen3 linux*|hurd*|unix: EIGEN_INCLUDEPATH = /usr/include/eigen3 - isEmpty(EIGEN_INCLUDEPATH) { + !exists(EIGEN_INCLUDEPATH) { freebsd-g++: EIGEN_INCLUDEPATH = /usr/local/include/eigen2 macx: EIGEN_INCLUDEPATH = /opt/local/include/eigen2 netbsd*: EIGEN_INCLUDEPATH = /usr/pkg/include/eigen2 diff --git a/scripts/setenv-unibuild.sh b/scripts/setenv-unibuild.sh index 456c7cd..f83a2cf 100644 --- a/scripts/setenv-unibuild.sh +++ b/scripts/setenv-unibuild.sh @@ -17,7 +17,7 @@ setenv_common() else # otherwise, assume its being run 'out of tree'. treat it somewhat like # "configure" or "cmake", so you can build dependencies where u wish. - echo "Not in OpenSCAD dir... using current directory as base of build" + echo "Warning: Not in OpenSCAD src dir... using current directory as base of build" BASEDIR=$PWD/openscad_deps fi fi -- cgit v0.10.1 From 3c9f36e7443d496b9929ac6f7f65fd6dcc1db98c Mon Sep 17 00:00:00 2001 From: don bright Date: Tue, 25 Dec 2012 02:21:22 +0100 Subject: path instructions should be / not ./ diff --git a/scripts/uni-build-dependencies.sh b/scripts/uni-build-dependencies.sh index a7c62d2..42452b8 100755 --- a/scripts/uni-build-dependencies.sh +++ b/scripts/uni-build-dependencies.sh @@ -6,18 +6,18 @@ # # This script builds all library dependencies of OpenSCAD for Linux/BSD -# (Except large ones like qt and gcc) +# (Except large ones like qt or gcc). It is based on macosx-build-dependencies.sh # # Standard usage: # cd openscad # . ./scripts/setenv-unibuild.sh # ./scripts/uni-build-dependencies.sh -# +# # Out-of-tree usage # # cd somepath # . /path/to/openscad/scripts/setenv-unibuild.sh -# ./path/to/openscad/scripts/uni-build-dependencies.sh +# /path/to/openscad/scripts/uni-build-dependencies.sh # # Prerequisites: # - wget or curl -- cgit v0.10.1 From fb6d7f987507874469de6d72ababecbeccab7d2a Mon Sep 17 00:00:00 2001 From: don bright Date: Mon, 24 Dec 2012 19:44:43 -0600 Subject: fix clang build on glew. add some documentation. diff --git a/scripts/uni-build-dependencies.sh b/scripts/uni-build-dependencies.sh index a7c62d2..6384148 100755 --- a/scripts/uni-build-dependencies.sh +++ b/scripts/uni-build-dependencies.sh @@ -242,7 +242,7 @@ build_glew() # clang linux if [ $CC ]; then - sed -ibak s/"CC = cc"/"CC = $(CC)"/ config/Makefile.linux + sed -ibak s/"CC = cc"/"# CC = cc"/ config/Makefile.linux fi MAKER=make @@ -350,6 +350,9 @@ build_eigen() } +# this section allows 'out of tree' builds, as long as the system has +# the 'dirname' command installed + if [ "`command -v dirname`" ]; then OPENSCAD_SCRIPTDIR=`dirname $0` else @@ -379,6 +382,9 @@ echo "Using srcdir:" $SRCDIR echo "Number of CPUs for parallel builds:" $NUMCPU mkdir -p $SRCDIR $DEPLOYDIR +# this section builds some basic tools, if they are missing or outdated +# they are installed under $BASEDIR/bin which we have added to our PATH + if [ ! "`command -v curl`" ]; then build_curl 7.26.0 fi -- cgit v0.10.1 From 4cc6e2a1b1b5dacb75abaa6f35d81abb7dc8c8ed Mon Sep 17 00:00:00 2001 From: don bright Date: Mon, 24 Dec 2012 20:15:40 -0600 Subject: a workaround for LD_LIBRARY_PATH having to be set every time you want to run openscad if you build your own dependencies. diff --git a/README.md b/README.md index dd7c4f8..ebe69c0 100644 --- a/README.md +++ b/README.md @@ -174,7 +174,14 @@ check dependencies source ./scripts/setenv-unibuild.sh ./scripts/check-dependencies.sh -Then follow the Compilation instructions below. +Then follow the Compilation instructions below. + +Note that if you build dependencies with this method, you may have to +modify your LD_LIBRARY_PATH environment variable every time you run the +openscad binary to avoid library problems. A workaround script called +"openscad-unirun.sh" has been included to solve this: copy it somewhere +in your PATH (/usr/local/bin) and run 'openscad-unirun.sh' instead of +the openscad binary. ### Building for Windows diff --git a/scripts/openscad-unirun.sh b/scripts/openscad-unirun.sh new file mode 100755 index 0000000..b0836eb --- /dev/null +++ b/scripts/openscad-unirun.sh @@ -0,0 +1,4 @@ +#!/bin/sh + +LD_LIBRARY_PATH=$HOME/openscad_deps/lib:$HOME/openscad_deps/lib64:$LD_LIBRARY_PATH openscad + -- cgit v0.10.1 From bc7ff5aa8d73ff08bd847bc8d0f41dc26deee54e Mon Sep 17 00:00:00 2001 From: Marius Kintel Date: Thu, 27 Dec 2012 17:30:13 +0100 Subject: Ignore dimension when evaluating control modules mixed with geometry children. Fixes #229 diff --git a/src/CGALEvaluator.cc b/src/CGALEvaluator.cc index 5e16892..a4744c2 100644 --- a/src/CGALEvaluator.cc +++ b/src/CGALEvaluator.cc @@ -130,6 +130,7 @@ CGAL_Nef_polyhedron CGALEvaluator::applyHull(const CgaladvNode &node) const CGAL_Nef_polyhedron &chN = item.second; // FIXME: Don't use deep access to modinst members if (chnode->modinst->isBackground()) continue; + if (chN.dim == 0) continue; // Ignore object with dimension 0 (e.g. echo) if (dim == 0) { dim = chN.dim; } diff --git a/testdata/scad/features/control-hull-dimension.scad b/testdata/scad/features/control-hull-dimension.scad new file mode 100644 index 0000000..c8736db --- /dev/null +++ b/testdata/scad/features/control-hull-dimension.scad @@ -0,0 +1,4 @@ +hull() { + circle(1); + echo(1); +} diff --git a/tests/regression/cgalpngtest/control-hull-dimension-expected.png b/tests/regression/cgalpngtest/control-hull-dimension-expected.png new file mode 100644 index 0000000..ceeaf54 Binary files /dev/null and b/tests/regression/cgalpngtest/control-hull-dimension-expected.png differ diff --git a/tests/regression/dumptest/control-hull-dimension-expected.txt b/tests/regression/dumptest/control-hull-dimension-expected.txt new file mode 100644 index 0000000..be2e4ee --- /dev/null +++ b/tests/regression/dumptest/control-hull-dimension-expected.txt @@ -0,0 +1,5 @@ + hull() { + circle($fn = 0, $fa = 12, $fs = 2, r = 1); + group(); + } + diff --git a/tests/regression/opencsgtest/control-hull-dimension-expected.png b/tests/regression/opencsgtest/control-hull-dimension-expected.png new file mode 100644 index 0000000..52d11c1 Binary files /dev/null and b/tests/regression/opencsgtest/control-hull-dimension-expected.png differ diff --git a/tests/regression/throwntogethertest/control-hull-dimension-expected.png b/tests/regression/throwntogethertest/control-hull-dimension-expected.png new file mode 100644 index 0000000..52d11c1 Binary files /dev/null and b/tests/regression/throwntogethertest/control-hull-dimension-expected.png differ -- cgit v0.10.1 From 7afcc417b3d26274342ad5293eaad76d7719ae32 Mon Sep 17 00:00:00 2001 From: don bright Date: Sat, 29 Dec 2012 14:26:59 -0600 Subject: prevent LD_LIBRARY_PATH problems on unix (not OSX) systems with dependency builds, by using RPATH during build. remove the shell script workaround that was added during the previous commit, as it is 'less clean' a solution. diff --git a/README.md b/README.md index ebe69c0..678b213 100644 --- a/README.md +++ b/README.md @@ -176,13 +176,6 @@ check dependencies Then follow the Compilation instructions below. -Note that if you build dependencies with this method, you may have to -modify your LD_LIBRARY_PATH environment variable every time you run the -openscad binary to avoid library problems. A workaround script called -"openscad-unirun.sh" has been included to solve this: copy it somewhere -in your PATH (/usr/local/bin) and run 'openscad-unirun.sh' instead of -the openscad binary. - ### Building for Windows OpenSCAD for Windows is usually cross-compiled from Linux. If you wish to diff --git a/openscad.pro b/openscad.pro index 6d9556b..0048963 100644 --- a/openscad.pro +++ b/openscad.pro @@ -101,6 +101,15 @@ netbsd* { } } +# Prevent LD_LIBRARY_PATH problems when running the openscad binary +# on systems where uni-build-dependencies.sh was used. +# Will not affect 'normal' builds. Also this is not tested on Mac +!isEmpty(OPENSCAD_LIBDIR) { + unix:!macx { + QMAKE_LFLAGS = -Wl,-R$$OPENSCAD_LIBDIR/lib $$QMAKE_LFLAGS + } +} + # See Dec 2011 OpenSCAD mailing list, re: CGAL/GCC bugs. *g++* { QMAKE_CXXFLAGS *= -fno-strict-aliasing diff --git a/scripts/openscad-unirun.sh b/scripts/openscad-unirun.sh deleted file mode 100755 index b0836eb..0000000 --- a/scripts/openscad-unirun.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/sh - -LD_LIBRARY_PATH=$HOME/openscad_deps/lib:$HOME/openscad_deps/lib64:$LD_LIBRARY_PATH openscad - -- cgit v0.10.1 From ed97940f56d0d9ff99ec28750986fb6ff513a39b Mon Sep 17 00:00:00 2001 From: don bright Date: Sat, 29 Dec 2012 22:27:44 +0100 Subject: make RPATH work on uni-build-dependencies with GLEW on 64 bit machines diff --git a/openscad.pro b/openscad.pro index 0048963..747a823 100644 --- a/openscad.pro +++ b/openscad.pro @@ -103,10 +103,12 @@ netbsd* { # Prevent LD_LIBRARY_PATH problems when running the openscad binary # on systems where uni-build-dependencies.sh was used. -# Will not affect 'normal' builds. Also this is not tested on Mac +# Will not affect 'normal' builds. !isEmpty(OPENSCAD_LIBDIR) { unix:!macx { QMAKE_LFLAGS = -Wl,-R$$OPENSCAD_LIBDIR/lib $$QMAKE_LFLAGS + # need /lib64 beause GLEW installs itself there on 64 bit machines + QMAKE_LFLAGS = -Wl,-R$$OPENSCAD_LIBDIR/lib64 $$QMAKE_LFLAGS } } -- cgit v0.10.1 From 41269ec0ff9406d707cde7fd584331f1cc44943a Mon Sep 17 00:00:00 2001 From: don bright Date: Sat, 29 Dec 2012 17:05:28 -0600 Subject: simplify README a little bit on build process diff --git a/README.md b/README.md index 678b213..f1d9925 100644 --- a/README.md +++ b/README.md @@ -137,7 +137,7 @@ First, make sure that you have git installed (often packaged as 'git-core' or 'scmgit'). Once you've cloned this git repository, download and install the dependency packages listed above using your system's package manager. A convenience script is provided that can help with this -process: +process on some systems: ./scripts/uni-get-dependencies.sh @@ -154,27 +154,30 @@ to the Compilation instructions. If some of your system dependency libraries are missing or old, then you can download and build newer versions into $HOME/openscad_deps by -running these commands: +following this process. First, run the script that sets up the +environment variables. source ./scripts/setenv-unibuild.sh + +Then run the script to compile all the prerequisite libraries above: + ./scripts/uni-build-dependencies.sh -This may take an hour or more, depending on your network and system. As -a special timesaver if you are only missing CGAL and OpenCSG, you can do +This may take an hour or more, depending on your network and system. It +is recommended to have at least 1 gigabyte of free disk space. As a +special timesaver if you are only missing CGAL and OpenCSG, you can do this instead: - source ./scripts/setenv-unibuild.sh ./scripts/uni-build-dependencies.sh opencsg ./scripts/uni-build-dependencies.sh cgal Note that huge dependencies like gcc or qt are not included here, only the smaller ones (boost, CGAL, opencsg, etc). After the build, again -check dependencies +check dependencies. - source ./scripts/setenv-unibuild.sh ./scripts/check-dependencies.sh -Then follow the Compilation instructions below. +After that, follow the Compilation instructions below. ### Building for Windows @@ -188,7 +191,7 @@ the script that sets up the environment variables. source ./scripts/setenv-mingw-xbuild.sh -Then run the script to download & compile all the dependency libraries: +Then run the script to download & compile all the prerequisite libraries above: ./scripts/mingw-x-build-dependencies.sh -- cgit v0.10.1 From 2230b3c4481c302f8a4baaf06b93cf9d4810dad0 Mon Sep 17 00:00:00 2001 From: don bright Date: Sat, 29 Dec 2012 17:10:52 -0600 Subject: qmake-macx last detected on eigen. (unix=1 on osx). clarify comments. diff --git a/bison.pri b/bison.pri index 14e2e01..7a63f0e 100644 --- a/bison.pri +++ b/bison.pri @@ -24,7 +24,8 @@ unix:linux* { } freebsd* { - # on bsd /usr/bin/bison is outdated, dont use it + # on some BSD, /usr/local/bin/bison is newer than + # /usr/bin/bison, so try to prefer it. exists(/usr/local/bin/bison) { QMAKE_YACC = /usr/local/bin/bison } else { # look in $PATH diff --git a/eigen.pri b/eigen.pri index 435355c..efb2d3c 100644 --- a/eigen.pri +++ b/eigen.pri @@ -48,14 +48,14 @@ CONFIG(mingw-cross-env) { isEmpty(EIGEN_INCLUDEPATH) { freebsd-g++: EIGEN_INCLUDEPATH = /usr/local/include/eigen3 - macx: EIGEN_INCLUDEPATH = /opt/local/include/eigen3 netbsd*: EIGEN_INCLUDEPATH = /usr/pkg/include/eigen3 linux*|hurd*|unix: EIGEN_INCLUDEPATH = /usr/include/eigen3 + macx: EIGEN_INCLUDEPATH = /opt/local/include/eigen3 !exists(EIGEN_INCLUDEPATH) { freebsd-g++: EIGEN_INCLUDEPATH = /usr/local/include/eigen2 - macx: EIGEN_INCLUDEPATH = /opt/local/include/eigen2 netbsd*: EIGEN_INCLUDEPATH = /usr/pkg/include/eigen2 linux*|hurd*|unix*: EIGEN_INCLUDEPATH = /usr/include/eigen2 + macx: EIGEN_INCLUDEPATH = /opt/local/include/eigen2 } } @@ -69,6 +69,7 @@ isEmpty(EIGEN_INCLUDEPATH) { # EIGEN being under 'include/eigen[2-3]' needs special prepending QMAKE_INCDIR_QT = $$EIGEN_INCLUDEPATH $$QMAKE_INCDIR_QT +# qmakespecs on netbsd prepend system includes, we need eigen first. netbsd* { QMAKE_CXXFLAGS = -I$$EIGEN_INCLUDEPATH $$QMAKE_CXXFLAGS } -- cgit v0.10.1 From b753e41dea877a1296c77a1bdc122f295f15a3bb Mon Sep 17 00:00:00 2001 From: don bright Date: Sat, 29 Dec 2012 17:13:16 -0600 Subject: cleaning up diff --git a/openscad.pro b/openscad.pro index 747a823..96250fd 100644 --- a/openscad.pro +++ b/openscad.pro @@ -127,6 +127,11 @@ netbsd* { QMAKE_CXXFLAGS_WARN_ON += -Wno-sign-compare } +# force the use of outdated libraries +CONFIG(skip-version-check) { + DEFINES += OPENSCAD_SKIP_VERSION_CHECK +} + # Application configuration macx:CONFIG += mdi CONFIG += cgal @@ -150,12 +155,6 @@ CONFIG(mingw-cross-env) { include(mingw-cross-env.pri) } -# force the use of outdated libraries -CONFIG(skip-version-check) { - DEFINES += OPENSCAD_SKIP_VERSION_CHECK -} - - win32 { FLEXSOURCES = src/lexer.l BISONSOURCES = src/parser.y -- cgit v0.10.1 From 70d810b666028d97f4587ec15619412181df0a7e Mon Sep 17 00:00:00 2001 From: don bright Date: Sat, 29 Dec 2012 17:14:13 -0600 Subject: cleanup diff --git a/openscad.pro b/openscad.pro index 96250fd..b11f45b 100644 --- a/openscad.pro +++ b/openscad.pro @@ -127,8 +127,8 @@ netbsd* { QMAKE_CXXFLAGS_WARN_ON += -Wno-sign-compare } -# force the use of outdated libraries CONFIG(skip-version-check) { + # force the use of outdated libraries DEFINES += OPENSCAD_SKIP_VERSION_CHECK } -- cgit v0.10.1 From da9c94308d16e0b978302e60c28cb962a91e2749 Mon Sep 17 00:00:00 2001 From: don bright Date: Sat, 29 Dec 2012 17:25:58 -0600 Subject: remove detection via package system, complicated + doesnt work well diff --git a/scripts/check-dependencies.sh b/scripts/check-dependencies.sh index c85ba09..e9721fd 100755 --- a/scripts/check-dependencies.sh +++ b/scripts/check-dependencies.sh @@ -5,24 +5,27 @@ # check-dependencies.sh # check version of all dependencies # check-dependencies.sh debug # debug this script # -# design -# Detection is done through stages and fallbacks in case of failure. +# output +# a table displaying the minimum version from README, the found version, +# and whether it is OK or not. # -# 1st stage, search by parsing header files and/or binary output -# 2nd stage, search with pkg-config -# 3rd stage, search by parsing output of package systems like dpkg or yum +# design +# stage 1. search by parsing header files and/or binary output (_sysver) +# stage 2. search with pkg-config # -# Goal is portability and lack of complicated regex. -# Code style is 'pretend its python'. functions return strings under -# the $function_name_result variable. tmp variables are -# funcname_abbreviated_tmp. Local vars are not used for portability. +# Code style is portability and simplicity. Plain sed, awk, grep, sh. +# Functions return strings under $function_name_result variable. +# tmp variables are named funcname_abbreviated_tmp. +# Local vars are not used. # # todo -# if /usr/ and /usr/local/ on linux both hit, throw an error -# fallback- pkgconfig --exists, then --modversion -# fallback2 - pkg manager -# - print location found, how found??? +# testing of non-bash shells +# if /usr/ and /usr/local/ on linux both hit, throw a warning +# print location found, how found??? +# look at pkgconfig --exists & --modversion +# deal with deps like GLEW that don't have proper version strings? # + DEBUG= debug() @@ -228,162 +231,6 @@ python_sysver() python_sysver_result=`$1/bin/python --version 2>&1 | awk '{print $2}'` } -set_default_package_map() -{ - glew=glew - boost=boost - eigen=eigen3 - imagemagick=imagemagick - make=make - python=python - opencsg=opencsg - cgal=cgal - bison=bison - gmp=gmp - mpfr=mpfr - bash=bash - flex=flex - gcc=gcc - cmake=cmake - curl=curl - git=git - qt4=qt4 -} - - -apt_pkg_search() -{ - - if [ ! "`command -v dpkg`" ]; then - # can't handle systems that use apt-get for RPMs (alt linux) - debug command dpkg not found. cannot search packages. - return - fi - - debug apt_pkg_search $* - apt_pkg_search_result= - pkgname=$1 - dps_ver= - - # translate pkgname to apt packagename - set_default_package_map - for pn in cgal boost mpfr opencsg qt4; do eval $pn="lib"$pn"-dev" ; done - - # handle multiple version names of same package (ubuntu, debian, etc) - if [ $pkgname = glew ]; then - glewtest=`apt-cache search libglew-dev` - if [ "`echo $glewtest | grep glew1.6-dev`" ]; then glew=libglew1.6-dev; - elif [ "`echo $glewtest | grep glew1.5-dev`" ]; then glew=libglew1.5-dev; - elif [ "`echo $glewtest | grep glew-dev`" ]; then glew=libglew-dev; fi - elif [ $pkgname = gmp ]; then - if [ "`apt-cache search libgmp3-dev`" ]; then gmp=libgmp3-dev ;fi - if [ "`apt-cache search libgmp-dev`" ]; then gmp=libgmp-dev ;fi - fi - - debpkgname=`eval echo "$"$pkgname` - - if [ ! $debpkgname ]; then - debug "unknown package" $pkgname; return; - fi - - debug $pkgname ".deb name:" $debpkgname - - # examples of apt version strings - # cgal 4.0-4 gmp 2:5.0.5+dfsg bison 1:2.5.dfsg-2.1 cmake 2.8.9~rc1 - - if [ $pkgname = eigen ]; then - aps_null=`dpkg --status libeigen3-dev 2>&1` - if [ $? = 0 ]; then - debpkgname=libeigen3-dev - else - debpkgname=libeigen2-dev - fi - fi - - debug "test dpkg on $debpkgname" - testdpkg=`dpkg --status $debpkgname 2>&1` - if [ "$testdpkg" ]; then - #debug test dpkg: $testdpkg - if [ "`echo $testdpkg | grep -i version`" ]; then - dps_ver=`dpkg --status $debpkgname | grep -i ^version: | awk ' { print $2 }'` - debug version line from dpkg: $dps_ver - dps_ver=`echo $dps_ver | tail -1 | sed s/"[-~].*"// | sed s/".*:"// | sed s/".dfsg*"//` - debug version: $dps_ver - else - debug couldnt find version string after dpkg --status $debpkgname - fi - else - debug testdpkg failed on $debpkgname - fi - - # Available to be system - #dps_ver= - #debug "test apt-cache on $debpkgname" - # apt-cache show is flaky on older apt. dont run unless search is OK - #test_aptcache=`apt-cache search $debpkgname` - #if [ "$test_aptcache" ]; then - # test_aptcache=`apt-cache show $debpkgname` - # if [ ! "`echo $test_aptcache | grep -i no.packages`" ]; then - # ver=`apt-cache show $debpkgname | grep ^Version: | awk ' { print $2 }'` - # ver=`echo $ver | tail -1 | sed s/"[-~].*"// | sed s/".*:"// | sed s/".dfsg*"//` - # if [ $ver ] ; then vera=$ver ; fi - # fi - #fi - - apt_pkg_search_result="$dps_ver" -} - -set_fedora_package_map() -{ - cgal=CGAL-devel - eigen=eigen2-devel - qt4=qt-devel - imagemagick=ImageMagick - for pn in boost gmp mpfr glew; do eval $pn=$pn"-devel" ; done -} - -yum_pkg_search() -{ - yum_pkg_search_result= - pkgname=$1 - - set_default_package_map - set_fedora_package_map - fedora_pkgname=`eval echo "$"$pkgname` - - debug $pkgname". fedora name:" $fedora_pkgname - if [ ! $fedora_pkgname ]; then - debug "unknown package" $pkgname; return; - fi - - test_yum=`yum info $fedora_pkgname 2>&1` - if [ "$test_yum" ]; then - debug test_yum: $test_yum - ydvver=`yum info $fedora_pkgname 2>&1 | grep ^Version | awk '{print $3}' ` - if [ $ydvver ]; then ydvver=$ydvver ; fi - else - debug test_yum failed on $pkgname - fi - yum_pkg_search_result="$ydvver" -} - - -pkg_search() -{ - debug pkg_search $* - pkg_search_result= - - if [ "`command -v apt-get`" ]; then - apt_pkg_search $* - pkg_search_result=$apt_pkg_search_result - elif [ "`command -v yum`" ]; then - yum_pkg_search $* - pkg_search_result=$yum_pkg_search_result - else - debug unknown system type. cannot search packages. - fi -} - pkg_config_search() { debug pkg_config_search $* @@ -400,9 +247,6 @@ pkg_config_search() fi } - - - get_minversion_from_readme() { if [ -e README.md ]; then READFILE=README.md; fi @@ -433,7 +277,6 @@ get_minversion_from_readme() get_minversion_from_readme_result=$grv_tmp } - find_min_version() { find_min_version_result= @@ -454,13 +297,12 @@ find_min_version() vers_to_int() { - # change x.y.z.p into x0y0z0p for purposes of comparison with -lt or -gt - # it will work as long as the resulting int is less than 2.147 billion - # and y z and p are less than 99 + # change x.y.z.p into an integer that can be compared using -lt or -gt # 1.2.3.4 into 1020304 # 1.11.0.12 into 1110012 # 2011.2.3 into 20110020300 - # the resulting integer can be simply compared using -lt or -gt + # it will work as long as the resulting int is less than 2.147 billion + # and y z and p are less than 99 vers_to_int_result= if [ ! $1 ] ; then return ; fi vtoi_ver=$1 @@ -562,9 +404,6 @@ pretty_print() pp_compared= } - - - find_installed_version() { debug find_installed_version $* @@ -592,13 +431,6 @@ find_installed_version() fi fi - # use the package system to search - if [ ! $fsv_tmp ]; then - debug plain + pkg_config search both failed... trying package search - pkg_search $dep - fsv_tmp=$pkg_search_result - fi - if [ $fsv_tmp ]; then find_installed_version_result=$fsv_tmp else @@ -606,12 +438,11 @@ find_installed_version() fi } - check_old_local() { warnon= if [ "`uname | grep -i linux`" ]; then - header_list="opencsg.h CGAL boost GL/glew.h" + header_list="opencsg.h CGAL boost GL/glew.h gmp.h mpfr.h eigen2 eigen3" liblist="libboost libopencsg libCGAL libglew" for i in $header_list $liblist; do if [ -e /usr/local/include/$i ]; then @@ -629,7 +460,6 @@ check_old_local() fi } - check_misc() { if [ "`uname -a|grep -i netbsd`" ]; then @@ -637,7 +467,6 @@ check_misc() fi } - checkargs() { for i in $*; do @@ -650,9 +479,7 @@ main() deps="qt4 cgal gmp mpfr boost opencsg glew eigen gcc" deps="$deps bison flex make" #deps="$deps curl git" # not technically necessary for build - #deps="$deps python cmake" # only needed for tests - #deps="$deps imagemagick" # needs work, only needed for tests - #deps="eigen glew opencsg" # debugging + #deps="$deps python cmake imagemagick" # only needed for tests pretty_print title for dep in $deps; do debug "processing $dep" -- cgit v0.10.1 From 728f00d8f7f1f94f9b29e5bfec6e6b20f99b8029 Mon Sep 17 00:00:00 2001 From: don bright Date: Sat, 29 Dec 2012 17:41:13 -0600 Subject: clarify comments diff --git a/scripts/release-common.sh b/scripts/release-common.sh index 4a26f09..ae856df 100755 --- a/scripts/release-common.sh +++ b/scripts/release-common.sh @@ -1,8 +1,8 @@ #!/bin/bash # # This script creates a binary release of OpenSCAD. This should work -# under Mac OS X, Windows (msys), Linux 32, Linux 64, and Linux->Win32 MXE -# cross-build. +# under Mac OS X, Linux 32, Linux 64, and Linux->Win32 MXE cross-build. +# Windows under msys has not been tested recently. # # The script will create a file called openscad-. in # the current directory (or under ./mingw32) @@ -18,8 +18,8 @@ # The commit info will extracted from git and be passed to qmake as OPENSCAD_COMMIT # to identify a build in the about box. # -# The mingw32 cross compile depends on the mxe tools + dependencies. Please -# see scripts/*mingw-* & the OpenSCAD manual for more information. +# The mingw32 cross compile depends on the MXE cross-build tools. Please +# see the README.md file on how to install these dependencies. printUsage() { diff --git a/scripts/uni-build-dependencies.sh b/scripts/uni-build-dependencies.sh index 8a2c7c3..9da08aa 100755 --- a/scripts/uni-build-dependencies.sh +++ b/scripts/uni-build-dependencies.sh @@ -4,16 +4,20 @@ # Marius Kintel and Clifford Wolf, 2012. released under the GPL 2, or # later, as described in the file named 'COPYING' in OpenSCAD's project root. +# This script builds most dependencies, both libraries and binary tools, +# of OpenSCAD for Linux/BSD. It won't build QT or gcc. It is based on +# macosx-build-dependencies.sh # -# This script builds all library dependencies of OpenSCAD for Linux/BSD -# (Except large ones like qt or gcc). It is based on macosx-build-dependencies.sh +# By default it builds under $HOME/openscad_deps. You can alter this by +# setting the BASEDIR environment variable or with the 'out of tree' +# feature # -# Standard usage: +# Usage: # cd openscad # . ./scripts/setenv-unibuild.sh # ./scripts/uni-build-dependencies.sh # -# Out-of-tree usage +# Out-of-tree usage: # # cd somepath # . /path/to/openscad/scripts/setenv-unibuild.sh @@ -22,7 +26,11 @@ # Prerequisites: # - wget or curl # - Qt4 -# - gcc (clang=experimental) +# - gcc +# +# Enable Clang (experimental, only works on linux): +# +# . ./scripts/setenv-unibuild.sh clang # printUsage() @@ -223,7 +231,7 @@ build_glew() cd glew-$version mkdir -p $DEPLOYDIR/lib/pkgconfig - # Glew makefiles are not built for Linux Multiarch. We aren't trying + # Glew's makefile is not built for Linux Multiarch. We aren't trying # to fix everything here, just the test machines OScad normally runs on # Fedora 64-bit @@ -369,7 +377,7 @@ SRCDIR=$BASEDIR/src if [ ! $NUMCPU ]; then echo "Note: The NUMCPU environment variable can be set for paralell builds" - NUMCPU=1 + NUMCPU=1 fi if [ ! -d $BASEDIR/bin ]; then -- cgit v0.10.1 From 413f22c610f06e5c4cfd0f40cb28167593fd857a Mon Sep 17 00:00:00 2001 From: don bright Date: Sat, 29 Dec 2012 18:00:23 -0600 Subject: clarify comments and variable names in pretty print diff --git a/scripts/check-dependencies.sh b/scripts/check-dependencies.sh index e9721fd..d2bc9ab 100755 --- a/scripts/check-dependencies.sh +++ b/scripts/check-dependencies.sh @@ -364,6 +364,12 @@ compare_version() pretty_print() { + # there are four columns, passed as $1 $2 $3 and $4 + # 1 = name of dependency + # 2 = version found in README + # 3 = version found on system + # 4 = whether it is OK or not + debug pretty_print $* brightred="\033[40;31m" @@ -380,28 +386,28 @@ pretty_print() ppstr="%s%-12s" pp_format='{printf("'$ppstr$ppstr$ppstr$ppstr$nocolor'\n",$1,$2,$3,$4,$5,$6,$7,$8)}' pp_title="$gray depname $gray minimum $gray found $gray OKness" - if [ $1 ]; then pp_dep=$1; fi - if [ $pp_dep = "title" ]; then + if [ $1 ]; then pp_depname=$1; fi + if [ $pp_depname = "title" ]; then echo -e $pp_title | awk $pp_format return ; fi if [ $2 ]; then pp_minver=$2; else pp_minver="unknown"; fi if [ $3 ]; then pp_foundver=$3; else pp_foundver="unknown"; fi - if [ $4 ]; then pp_compared=$4; else pp_compared="NotOK"; fi + if [ $4 ]; then pp_okness=$4; else pp_okness="NotOK"; fi - if [ $pp_compared = "NotOK" ]; then + if [ $pp_okness = "NotOK" ]; then pp_foundcolor=$purple; pp_cmpcolor=$purple; else pp_foundcolor=$gray; pp_cmpcolor=$green; fi - echo -e $cyan $pp_dep $gray $pp_minver $pp_foundcolor $pp_foundver $pp_cmpcolor $pp_compared | awk $pp_format - pp_dep= + echo -e $cyan $pp_depname $gray $pp_minver $pp_foundcolor $pp_foundver $pp_cmpcolor $pp_okness | awk $pp_format + pp_depname= pp_minver= pp_foundver= - pp_compared= + pp_okness= } find_installed_version() -- cgit v0.10.1 From eeadeb2552ae72004075bb4a43db33ba9af76ec0 Mon Sep 17 00:00:00 2001 From: don bright Date: Sat, 29 Dec 2012 18:02:29 -0600 Subject: clarify variable names. simplify. diff --git a/scripts/check-dependencies.sh b/scripts/check-dependencies.sh index d2bc9ab..eaed556 100755 --- a/scripts/check-dependencies.sh +++ b/scripts/check-dependencies.sh @@ -415,15 +415,15 @@ find_installed_version() debug find_installed_version $* find_installed_version_result=unknown fsv_tmp= - dep=$1 + depname=$1 # try to find/parse headers and/or binary output if [ ! $fsv_tmp ]; then for syspath in "/opt" "/usr/pkg" "/usr" "/usr/local" $OPENSCAD_LIBRARIES; do if [ -e $syspath ]; then - debug $dep"_sysver" $syspath - eval $dep"_sysver" $syspath - fsv_tmp=`eval echo "$"$dep"_sysver_result"` + debug $depname"_sysver" $syspath + eval $depname"_sysver" $syspath + fsv_tmp=`eval echo "$"$depname"_sysver_result"` fi done fi @@ -432,7 +432,7 @@ find_installed_version() if [ ! $fsv_tmp ]; then if [ "`command -v pkg-config`" ]; then debug plain search failed. trying pkg_config... - pkg_config_search $dep + pkg_config_search $depname fsv_tmp=$pkg_config_search_result fi fi @@ -482,20 +482,19 @@ checkargs() main() { - deps="qt4 cgal gmp mpfr boost opencsg glew eigen gcc" - deps="$deps bison flex make" + deps="qt4 cgal gmp mpfr boost opencsg glew eigen gcc bison flex make" #deps="$deps curl git" # not technically necessary for build #deps="$deps python cmake imagemagick" # only needed for tests pretty_print title - for dep in $deps; do + for depname in $deps; do debug "processing $dep" - find_installed_version $dep + find_installed_version $depname dep_sysver=$find_installed_version_result - find_min_version $dep + find_min_version $depname dep_minver=$find_min_version_result compare_version $dep_minver $dep_sysver dep_compare=$compare_version_result - pretty_print $dep $dep_minver $dep_sysver $dep_compare + pretty_print $depname $dep_minver $dep_sysver $dep_compare done check_old_local check_misc -- cgit v0.10.1 From 87f2d39901560526745e337f27bd2dc017f5ddd1 Mon Sep 17 00:00:00 2001 From: don bright Date: Sat, 29 Dec 2012 18:06:14 -0600 Subject: clarify comments diff --git a/scripts/setenv-unibuild.sh b/scripts/setenv-unibuild.sh index f83a2cf..d13782c 100644 --- a/scripts/setenv-unibuild.sh +++ b/scripts/setenv-unibuild.sh @@ -1,12 +1,8 @@ # setup environment variables for building OpenSCAD against custom built -# dependency libraries. +# dependency libraries. works on Linux/BSD. # -# run with 'source ./scripts/setenv-unibuild.sh' +# Please see the 'uni-build-dependencies.sh' file for usage information # -# run it every time you re-login and want to build or run openscad -# against custom libraries installed into BASEDIR. -# -# used in conjuction with uni-build-dependencies.sh setenv_common() { -- cgit v0.10.1 From 158e760b4dbda42079db41e580ee191be5c4c65f Mon Sep 17 00:00:00 2001 From: don bright Date: Sat, 29 Dec 2012 18:07:57 -0600 Subject: clarify comments diff --git a/scripts/uni-build-dependencies.sh b/scripts/uni-build-dependencies.sh index 9da08aa..88f2cf8 100755 --- a/scripts/uni-build-dependencies.sh +++ b/scripts/uni-build-dependencies.sh @@ -5,8 +5,7 @@ # later, as described in the file named 'COPYING' in OpenSCAD's project root. # This script builds most dependencies, both libraries and binary tools, -# of OpenSCAD for Linux/BSD. It won't build QT or gcc. It is based on -# macosx-build-dependencies.sh +# of OpenSCAD for Linux/BSD. It is based on macosx-build-dependencies.sh # # By default it builds under $HOME/openscad_deps. You can alter this by # setting the BASEDIR environment variable or with the 'out of tree' -- cgit v0.10.1 From db9a78f028803619cb68e17c7478e3de956e61d8 Mon Sep 17 00:00:00 2001 From: don bright Date: Sun, 30 Dec 2012 01:18:08 +0100 Subject: cleanup diff --git a/src/svg.cc b/src/svg.cc index ff13332..e5130b0 100644 --- a/src/svg.cc +++ b/src/svg.cc @@ -96,7 +96,7 @@ std::string dump_cgal_nef_polyhedron2_face_svg( bool mark, CGAL_Iso_rectangle_2e bbox ) { - std::stringstream out; + std::stringstream out; CGAL_For_all(c1, c2) { if ( explorer.is_standard( explorer.target(c1) ) ) { CGAL_Point_2e source = explorer.point( explorer.source( c1 ) ); @@ -106,7 +106,7 @@ std::string dump_cgal_nef_polyhedron2_face_svg( double mod=0; if (color=="green") mod=10; out << " \n"; - out << " \n"; out << svg_border() << "\n" << svg_axes() << "\n"; svg_cursor_py += svg_px_height; for ( i = explorer.faces_begin(); i!= explorer.faces_end(); ++i ) { - out << " \n"; - CGAL_Nef_polyhedron2::Explorer::Halfedge_around_face_const_circulator c1 - = explorer.face_cycle( i ), c2 ( c1 ); - out << dump_cgal_nef_polyhedron2_face_svg( c1, c2, explorer, "red", i->mark(), bbox ); - - CGAL_Nef_polyhedron2::Explorer::Hole_const_iterator j; - for ( j = explorer.holes_begin( i ); j!= explorer.holes_end( i ); ++j ) { - out << " \n"; - CGAL_Nef_polyhedron2::Explorer::Halfedge_around_face_const_circulator c3( j ), c4 ( c3 ); - out << dump_cgal_nef_polyhedron2_face_svg( c3, c4, explorer, "green", j->mark(), bbox ); - out << " \n"; - } - out << " \n"; - } - out << ""; + out << " \n"; + CGAL_Nef_polyhedron2::Explorer::Halfedge_around_face_const_circulator c1 + = explorer.face_cycle( i ), c2 ( c1 ); + out << dump_cgal_nef_polyhedron2_face_svg( c1, c2, explorer, "red", i->mark(), bbox ); + + CGAL_Nef_polyhedron2::Explorer::Hole_const_iterator j; + for ( j = explorer.holes_begin( i ); j!= explorer.holes_end( i ); ++j ) { + out << " \n"; + CGAL_Nef_polyhedron2::Explorer::Halfedge_around_face_const_circulator c3( j ), c4 ( c3 ); + out << dump_cgal_nef_polyhedron2_face_svg( c3, c4, explorer, "green", j->mark(), bbox ); + out << " \n"; + } + out << " \n"; + } + out << ""; std::string tmp = out.str(); boost::replace_all( tmp, "'", "\"" ); return tmp; @@ -219,29 +219,29 @@ public: std::string dump_svg( const CGAL_Nef_polyhedron3 &N ) { - std::stringstream out; + std::stringstream out; out << svg_header() << "\n" << svg_border() << "\n" << svg_axes() << "\n"; out << "\n"; - CGAL_Nef_polyhedron3::Volume_const_iterator c; - CGAL_forall_volumes(c,N) { - out << " \n"; - out << " \n"; - CGAL_Nef_polyhedron3::Shell_entry_const_iterator it; - CGAL_forall_shells_of(it,c) { - out << " \n"; - NefPoly3_dumper_svg dumper_svg(N); - N.visit_shell_objects(CGAL_Nef_polyhedron3::SFace_const_handle(it), dumper_svg ); + CGAL_Nef_polyhedron3::Volume_const_iterator c; + CGAL_forall_volumes(c,N) { + out << " \n"; + out << " \n"; + CGAL_Nef_polyhedron3::Shell_entry_const_iterator it; + CGAL_forall_shells_of(it,c) { + out << " \n"; + NefPoly3_dumper_svg dumper_svg(N); + N.visit_shell_objects(CGAL_Nef_polyhedron3::SFace_const_handle(it), dumper_svg ); out << dumper_svg.out.str(); - out << " \n"; - } - out << " \n"; - } - out << "\n"; + out << " \n"; + } + out << " \n"; + } + out << "\n"; out << ""; std::string tmp = out.str(); boost::replace_all( tmp, "'", "\"" ); - return tmp; + return tmp; } } // namespace -- cgit v0.10.1 From f40b6a672aa4c0a3df2165ffaaac49b9a8d935e7 Mon Sep 17 00:00:00 2001 From: don bright Date: Sun, 6 Jan 2013 06:27:42 +0100 Subject: switch builtin_rands() to use boost::random per issue 234 diff --git a/src/func.cc b/src/func.cc index e427bf2..a4d48e2 100644 --- a/src/func.cc +++ b/src/func.cc @@ -34,6 +34,14 @@ #include #include "stl-utils.h" #include "printutils.h" +#include +#include +#include + +boost::random::random_device nondeterministic_rng; +boost::random::mt19937 deterministic_rng; + +#include "random_device.cpp" AbstractFunction::~AbstractFunction() { @@ -131,12 +139,13 @@ double frand(double min, double max) Value builtin_rands(const Context *, const std::vector&, const std::vector &args) { + bool deterministic = false; if (args.size() == 3 && args[0].type() == Value::NUMBER && args[1].type() == Value::NUMBER && args[2].type() == Value::NUMBER) { - srand((unsigned int)time(0)); + deterministic = false; } else if (args.size() == 4 && args[0].type() == Value::NUMBER && @@ -144,7 +153,8 @@ Value builtin_rands(const Context *, const std::vector&, const std: args[2].type() == Value::NUMBER && args[3].type() == Value::NUMBER) { - srand((unsigned int)args[3].toDouble()); + deterministic_rng.seed( (unsigned int) args[3].toDouble() ); + deterministic = true; } else { @@ -153,7 +163,14 @@ Value builtin_rands(const Context *, const std::vector&, const std: Value::VectorType vec; for (int i=0; i dist( min, max ); + if ( deterministic ) { + vec.push_back( Value( dist( deterministic_rng ) ) ); + } else { + vec.push_back( Value( dist( nondeterministic_rng ) ) ); + } } return Value(vec); -- cgit v0.10.1 From 84c6d45eaac2d04d4e855dddb88bb208e531451e Mon Sep 17 00:00:00 2001 From: don bright Date: Sun, 6 Jan 2013 06:31:41 +0100 Subject: experimental workaround for boost linker problems w random_device diff --git a/src/random_device.cpp b/src/random_device.cpp new file mode 100644 index 0000000..699a880 --- /dev/null +++ b/src/random_device.cpp @@ -0,0 +1,217 @@ +/* boost random_device.cpp implementation + * + * Copyright Jens Maurer 2000 + * Copyright Steven Watanabe 2010-2011 + * Distributed under the Boost Software License, Version 1.0. (See + * accompanying file LICENSE_1_0.txt or copy at + * http://www.boost.org/LICENSE_1_0.txt) + * + * $Id: random_device.cpp 71018 2011-04-05 21:27:52Z steven_watanabe $ + * + */ + +#define BOOST_RANDOM_SOURCE + +#include +#include +#include +#include +#include + +#if !defined(BOOST_NO_INCLASS_MEMBER_INITIALIZATION) && !BOOST_WORKAROUND(BOOST_MSVC, BOOST_TESTED_AT(1600)) +// A definition is required even for integral static constants +const bool boost::random::random_device::has_fixed_range; +#endif + + +#if defined(BOOST_WINDOWS) + +#include +#include +#include // std::invalid_argument + +#define BOOST_AUTO_LINK_NOMANGLE +#define BOOST_LIB_NAME "Advapi32" +#include + +#ifdef __MINGW32__ + +extern "C" { + +// mingw's wincrypt.h appears to be missing some things +WINADVAPI +BOOL +WINAPI +CryptEnumProvidersA( + DWORD dwIndex, + DWORD *pdwReserved, + DWORD dwFlags, + DWORD *pdwProvType, + LPSTR szProvName, + DWORD *pcbProvName + ); + +} + +#endif + +namespace { + +const char * const default_token = MS_DEF_PROV_A; + +} + +class boost::random::random_device::impl +{ +public: + impl(const std::string & token) : provider(token) { + char buffer[80]; + DWORD type; + DWORD len; + + // Find the type of the provider + for(DWORD i = 0; ; ++i) { + len = sizeof(buffer); + if(!CryptEnumProvidersA(i, NULL, 0, &type, buffer, &len)) { + error("Could not find provider name"); + } + if(buffer == provider) { + break; + } + } + + if(!CryptAcquireContextA(&hProv, NULL, provider.c_str(), type, + CRYPT_VERIFYCONTEXT | CRYPT_SILENT)) { + error("Could not acquire CSP context"); + } + } + + ~impl() { + if(!CryptReleaseContext(hProv, 0)) error("Could not release CSP context"); + } + + unsigned int next() { + unsigned int result; + + if(!CryptGenRandom(hProv, sizeof(result), + static_cast(static_cast(&result)))) { + error("error while reading"); + } + + return result; + } + +private: + void error(const std::string & msg) { + char buf[80]; + DWORD num = FormatMessageA( + FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, + NULL, + GetLastError(), + 0, + buf, + sizeof(buf), + NULL); + + throw std::invalid_argument("boost::random_device: " + msg + + " Cryptopraphic Service Provider " + provider + + ": " + std::string(&buf[0], &buf[0] + num)); + } + const std::string provider; + HCRYPTPROV hProv; +}; + +#else + +namespace { +// the default is the unlimited capacity device, using some secure hash +// try "/dev/random" for blocking when the entropy pool has drained +const char * const default_token = "/dev/urandom"; +} + +/* + * This uses the POSIX interface for unbuffered reading. + * Using buffered std::istream would consume entropy which may + * not actually be used. Entropy is a precious good we avoid + * wasting. + */ + +#if defined(__GNUC__) && defined(_CXXRT_STD_NAME) +// I have severe difficulty to get the POSIX includes to work with +// -fhonor-std and Dietmar Kuhl's standard C++ library. Hack around that +// problem for now. +extern "C" { +static const int O_RDONLY = 0; +extern int open(const char *__file, int __oflag, ...); +extern int read(int __fd, __ptr_t __buf, size_t __nbytes); +extern int close(int __fd); +} +#else +#include +#include +#include // open +#include // read, close +#endif + +#include // errno +#include // strerror +#include // std::invalid_argument + + +class boost::random::random_device::impl +{ +public: + impl(const std::string & token) : path(token) { + fd = open(token.c_str(), O_RDONLY); + if(fd < 0) + error("cannot open"); + } + + ~impl() { if(close(fd) < 0) error("could not close"); } + + unsigned int next() { + unsigned int result; + long sz = read(fd, reinterpret_cast(&result), sizeof(result)); + if(sz == -1) + error("error while reading"); + else if(sz != sizeof(result)) { + errno = 0; + error("EOF while reading"); + } + return result; + } + +private: + void error(const std::string & msg) { + throw std::invalid_argument("boost::random_device: " + msg + + " random-number pseudo-device " + path + + ": " + strerror(errno)); + } + const std::string path; + int fd; +}; + +#endif // BOOST_WINDOWS + +BOOST_RANDOM_DECL boost::random::random_device::random_device() + : pimpl(new impl(default_token)) +{} + +BOOST_RANDOM_DECL boost::random::random_device::random_device(const std::string& token) + : pimpl(new impl(token)) +{} + +BOOST_RANDOM_DECL boost::random_device::~random_device() +{ + delete pimpl; +} + +BOOST_RANDOM_DECL double boost::random_device::entropy() const +{ + return 10; +} + +BOOST_RANDOM_DECL unsigned int boost::random_device::operator()() +{ + return pimpl->next(); +} -- cgit v0.10.1 From 30922740a1287230e79aaeb03d3166079fc321d9 Mon Sep 17 00:00:00 2001 From: don bright Date: Sun, 6 Jan 2013 17:03:37 +0100 Subject: remove boost::random_device, move min/max out of the random generator loop diff --git a/src/func.cc b/src/func.cc index a4d48e2..de9060d 100644 --- a/src/func.cc +++ b/src/func.cc @@ -34,14 +34,13 @@ #include #include "stl-utils.h" #include "printutils.h" -#include #include #include -boost::random::random_device nondeterministic_rng; -boost::random::mt19937 deterministic_rng; - -#include "random_device.cpp" +boost::random::mt19937 deterministic_prng; +// not technically non-deterministic, but boost::random::random_device has +// non-header library and/or version issues that would complicate the build +boost::random::mt19937 nondeterministic_prng( std::time(0) ); AbstractFunction::~AbstractFunction() { @@ -161,15 +160,15 @@ Value builtin_rands(const Context *, const std::vector&, const std: return Value(); } + 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 ); Value::VectorType vec; for (int i=0; i dist( min, max ); if ( deterministic ) { - vec.push_back( Value( dist( deterministic_rng ) ) ); + vec.push_back( Value( distributor( deterministic_rng ) ) ); } else { - vec.push_back( Value( dist( nondeterministic_rng ) ) ); + vec.push_back( Value( distributor( nondeterministic_rng ) ) ); } } diff --git a/src/random_device.cpp b/src/random_device.cpp deleted file mode 100644 index 699a880..0000000 --- a/src/random_device.cpp +++ /dev/null @@ -1,217 +0,0 @@ -/* boost random_device.cpp implementation - * - * Copyright Jens Maurer 2000 - * Copyright Steven Watanabe 2010-2011 - * Distributed under the Boost Software License, Version 1.0. (See - * accompanying file LICENSE_1_0.txt or copy at - * http://www.boost.org/LICENSE_1_0.txt) - * - * $Id: random_device.cpp 71018 2011-04-05 21:27:52Z steven_watanabe $ - * - */ - -#define BOOST_RANDOM_SOURCE - -#include -#include -#include -#include -#include - -#if !defined(BOOST_NO_INCLASS_MEMBER_INITIALIZATION) && !BOOST_WORKAROUND(BOOST_MSVC, BOOST_TESTED_AT(1600)) -// A definition is required even for integral static constants -const bool boost::random::random_device::has_fixed_range; -#endif - - -#if defined(BOOST_WINDOWS) - -#include -#include -#include // std::invalid_argument - -#define BOOST_AUTO_LINK_NOMANGLE -#define BOOST_LIB_NAME "Advapi32" -#include - -#ifdef __MINGW32__ - -extern "C" { - -// mingw's wincrypt.h appears to be missing some things -WINADVAPI -BOOL -WINAPI -CryptEnumProvidersA( - DWORD dwIndex, - DWORD *pdwReserved, - DWORD dwFlags, - DWORD *pdwProvType, - LPSTR szProvName, - DWORD *pcbProvName - ); - -} - -#endif - -namespace { - -const char * const default_token = MS_DEF_PROV_A; - -} - -class boost::random::random_device::impl -{ -public: - impl(const std::string & token) : provider(token) { - char buffer[80]; - DWORD type; - DWORD len; - - // Find the type of the provider - for(DWORD i = 0; ; ++i) { - len = sizeof(buffer); - if(!CryptEnumProvidersA(i, NULL, 0, &type, buffer, &len)) { - error("Could not find provider name"); - } - if(buffer == provider) { - break; - } - } - - if(!CryptAcquireContextA(&hProv, NULL, provider.c_str(), type, - CRYPT_VERIFYCONTEXT | CRYPT_SILENT)) { - error("Could not acquire CSP context"); - } - } - - ~impl() { - if(!CryptReleaseContext(hProv, 0)) error("Could not release CSP context"); - } - - unsigned int next() { - unsigned int result; - - if(!CryptGenRandom(hProv, sizeof(result), - static_cast(static_cast(&result)))) { - error("error while reading"); - } - - return result; - } - -private: - void error(const std::string & msg) { - char buf[80]; - DWORD num = FormatMessageA( - FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, - NULL, - GetLastError(), - 0, - buf, - sizeof(buf), - NULL); - - throw std::invalid_argument("boost::random_device: " + msg + - " Cryptopraphic Service Provider " + provider + - ": " + std::string(&buf[0], &buf[0] + num)); - } - const std::string provider; - HCRYPTPROV hProv; -}; - -#else - -namespace { -// the default is the unlimited capacity device, using some secure hash -// try "/dev/random" for blocking when the entropy pool has drained -const char * const default_token = "/dev/urandom"; -} - -/* - * This uses the POSIX interface for unbuffered reading. - * Using buffered std::istream would consume entropy which may - * not actually be used. Entropy is a precious good we avoid - * wasting. - */ - -#if defined(__GNUC__) && defined(_CXXRT_STD_NAME) -// I have severe difficulty to get the POSIX includes to work with -// -fhonor-std and Dietmar Kuhl's standard C++ library. Hack around that -// problem for now. -extern "C" { -static const int O_RDONLY = 0; -extern int open(const char *__file, int __oflag, ...); -extern int read(int __fd, __ptr_t __buf, size_t __nbytes); -extern int close(int __fd); -} -#else -#include -#include -#include // open -#include // read, close -#endif - -#include // errno -#include // strerror -#include // std::invalid_argument - - -class boost::random::random_device::impl -{ -public: - impl(const std::string & token) : path(token) { - fd = open(token.c_str(), O_RDONLY); - if(fd < 0) - error("cannot open"); - } - - ~impl() { if(close(fd) < 0) error("could not close"); } - - unsigned int next() { - unsigned int result; - long sz = read(fd, reinterpret_cast(&result), sizeof(result)); - if(sz == -1) - error("error while reading"); - else if(sz != sizeof(result)) { - errno = 0; - error("EOF while reading"); - } - return result; - } - -private: - void error(const std::string & msg) { - throw std::invalid_argument("boost::random_device: " + msg + - " random-number pseudo-device " + path + - ": " + strerror(errno)); - } - const std::string path; - int fd; -}; - -#endif // BOOST_WINDOWS - -BOOST_RANDOM_DECL boost::random::random_device::random_device() - : pimpl(new impl(default_token)) -{} - -BOOST_RANDOM_DECL boost::random::random_device::random_device(const std::string& token) - : pimpl(new impl(token)) -{} - -BOOST_RANDOM_DECL boost::random_device::~random_device() -{ - delete pimpl; -} - -BOOST_RANDOM_DECL double boost::random_device::entropy() const -{ - return 10; -} - -BOOST_RANDOM_DECL unsigned int boost::random_device::operator()() -{ - return pimpl->next(); -} -- cgit v0.10.1 From db971485846d54a043777b3db7ba43f31d486939 Mon Sep 17 00:00:00 2001 From: don bright Date: Sun, 6 Jan 2013 10:09:21 -0600 Subject: fix typo diff --git a/src/func.cc b/src/func.cc index de9060d..0f9329d 100644 --- a/src/func.cc +++ b/src/func.cc @@ -37,10 +37,10 @@ #include #include -boost::random::mt19937 deterministic_prng; +boost::random::mt19937 deterministic_rng; // not technically non-deterministic, but boost::random::random_device has // non-header library and/or version issues that would complicate the build -boost::random::mt19937 nondeterministic_prng( std::time(0) ); +boost::random::mt19937 nondeterministic_rng( std::time(0) ); AbstractFunction::~AbstractFunction() { -- cgit v0.10.1 From 8aa349b15f65dd5106d182decd26c1027dcb7b7a Mon Sep 17 00:00:00 2001 From: don bright Date: Sun, 6 Jan 2013 17:35:31 +0100 Subject: also use process ID to seed pseudo random number generator diff --git a/src/func.cc b/src/func.cc index 0f9329d..d32b382 100644 --- a/src/func.cc +++ b/src/func.cc @@ -37,10 +37,19 @@ #include #include +#ifdef __WIN32__ +#include +int process_id = _getpid(); +#else +#include +#include +int process_id = getpid(); +#endif + boost::random::mt19937 deterministic_rng; -// not technically non-deterministic, but boost::random::random_device has -// non-header library and/or version issues that would complicate the build -boost::random::mt19937 nondeterministic_rng( std::time(0) ); +// this is technically not non-deterministic, but boost::random::random_device +// has non-header library and/or version issues that would complicate the build +boost::random::mt19937 nondeterministic_rng( std::time(0) + process_id ); AbstractFunction::~AbstractFunction() { -- cgit v0.10.1 From 3825a7249944daa7765ebbdf836557c5032b2836 Mon Sep 17 00:00:00 2001 From: don bright Date: Sun, 6 Jan 2013 11:06:55 -0600 Subject: clarify that its not nondeterministic, we are supporting older systems where the C++/boost random_device stuff doesn't work. boost random_device in particular has a lot of issues with old versions not working, with -lboost_random not being installed by default, etc, that complicate the build too much. diff --git a/src/func.cc b/src/func.cc index d32b382..ee269d0 100644 --- a/src/func.cc +++ b/src/func.cc @@ -34,6 +34,14 @@ #include #include "stl-utils.h" #include "printutils.h" + +/* + Random numbers + + Newer versions of boost/C++ include a non-deterministic random_device and + auto/bind()s for random function objects, but we are supporting older systems. +*/ + #include #include @@ -47,9 +55,7 @@ int process_id = getpid(); #endif boost::random::mt19937 deterministic_rng; -// this is technically not non-deterministic, but boost::random::random_device -// has non-header library and/or version issues that would complicate the build -boost::random::mt19937 nondeterministic_rng( std::time(0) + process_id ); +boost::random::mt19937 lessdeterministic_rng( std::time(0) + process_id ); AbstractFunction::~AbstractFunction() { @@ -177,7 +183,7 @@ Value builtin_rands(const Context *, const std::vector&, const std: if ( deterministic ) { vec.push_back( Value( distributor( deterministic_rng ) ) ); } else { - vec.push_back( Value( distributor( nondeterministic_rng ) ) ); + vec.push_back( Value( distributor( lessdeterministic_rng ) ) ); } } -- cgit v0.10.1 From 00ac79c11155bd7fc5e3489b675d50dd027207ad Mon Sep 17 00:00:00 2001 From: don bright Date: Sun, 6 Jan 2013 18:12:00 +0100 Subject: remove unneeded frand functions diff --git a/src/func.cc b/src/func.cc index ee269d0..5dcb3e9 100644 --- a/src/func.cc +++ b/src/func.cc @@ -141,16 +141,6 @@ Value builtin_sign(const Context *, const std::vector&, const std:: return Value(); } -double frand() -{ - return rand()/(double(RAND_MAX)+1); -} - -double frand(double min, double max) -{ - return (min>max) ? frand()*(min-max)+max : frand()*(max-min)+min; -} - Value builtin_rands(const Context *, const std::vector&, const std::vector &args) { bool deterministic = false; -- cgit v0.10.1 From 25266bed0d6c3a0caae80a0444c073fee78cc686 Mon Sep 17 00:00:00 2001 From: don bright Date: Mon, 7 Jan 2013 21:48:26 -0600 Subject: allow qt5 build diff --git a/eigen.pri b/eigen.pri index efb2d3c..dac38a6 100644 --- a/eigen.pri +++ b/eigen.pri @@ -67,7 +67,11 @@ isEmpty(EIGEN_INCLUDEPATH) { } # EIGEN being under 'include/eigen[2-3]' needs special prepending -QMAKE_INCDIR_QT = $$EIGEN_INCLUDEPATH $$QMAKE_INCDIR_QT +contains(QT_VERSION, ^5\\..*) { + QMAKE_INCDIR = $$EIGEN_INCLUDEPATH $$QMAKE_INCDIR +} else { + QMAKE_INCDIR_QT = $$EIGEN_INCLUDEPATH $$QMAKE_INCDIR_QT +} # qmakespecs on netbsd prepend system includes, we need eigen first. netbsd* { diff --git a/scripts/setenv-unibuild.sh b/scripts/setenv-unibuild.sh index d13782c..e6fd6fe 100644 --- a/scripts/setenv-unibuild.sh +++ b/scripts/setenv-unibuild.sh @@ -73,11 +73,33 @@ setenv_linux_clang() echo QMAKESPEC has been modified: $QMAKESPEC } +setenv_qt5() +{ + export QTDIR=/opt/qt5 + export PATH=$QTDIR/bin:$PATH + export LD_LIBRARY_PATH=$QTDIR/lib:$LD_LIBRARY_PATH + export LD_RUN_PATH=$QTDIR/lib:$LD_RUN_PATH + if [ "`echo $CC | grep clang`" ]; then + if [ "`uname | grep -i linux\|debian`" ]; then + export QMAKESPEC=linux-clang + echo QMAKESPEC has been modified: $QMAKESPEC + fi + fi + + echo PATH has been modified with $QTDIR/bin + echo LD_LIBRARY_PATH has been modified with $QTDIR/lib + echo LD_RUN_PATH has been modified with $QTDIR/lib + echo QTDIR has been modified: $QTDIR +} + if [ "`uname | grep -i 'linux\|debian'`" ]; then setenv_common if [ "`echo $* | grep clang`" ]; then setenv_linux_clang fi + if [ "`echo $* | grep qt5`" ]; then + setenv_qt5 + fi elif [ "`uname | grep -i freebsd`" ]; then setenv_freebsd elif [ "`uname | grep -i netbsd`" ]; then diff --git a/scripts/uni-build-dependencies.sh b/scripts/uni-build-dependencies.sh index 88f2cf8..0c37605 100755 --- a/scripts/uni-build-dependencies.sh +++ b/scripts/uni-build-dependencies.sh @@ -31,6 +31,10 @@ # # . ./scripts/setenv-unibuild.sh clang # +# Enable Qt5 (experimental) +# +# . ./scripts/setenv-unibuild.sh qt5 +# printUsage() { -- cgit v0.10.1 From 594471bc2273d8f7a27313c29d32dc3932e02451 Mon Sep 17 00:00:00 2001 From: don bright Date: Mon, 7 Jan 2013 21:55:35 -0600 Subject: notify user of QTDIR setting diff --git a/scripts/setenv-unibuild.sh b/scripts/setenv-unibuild.sh index e6fd6fe..951f707 100644 --- a/scripts/setenv-unibuild.sh +++ b/scripts/setenv-unibuild.sh @@ -75,21 +75,30 @@ setenv_linux_clang() setenv_qt5() { - export QTDIR=/opt/qt5 - export PATH=$QTDIR/bin:$PATH - export LD_LIBRARY_PATH=$QTDIR/lib:$LD_LIBRARY_PATH - export LD_RUN_PATH=$QTDIR/lib:$LD_RUN_PATH + if [ ! $QTDIR ]; then + QTDIR=/opt/qt5 + echo Please set QTDIR before running this qt5 script. Assuming $QTDIR + fi + PATH=$QTDIR/bin:$PATH + LD_LIBRARY_PATH=$QTDIR/lib:$LD_LIBRARY_PATH + LD_RUN_PATH=$QTDIR/lib:$LD_RUN_PATH if [ "`echo $CC | grep clang`" ]; then if [ "`uname | grep -i linux\|debian`" ]; then - export QMAKESPEC=linux-clang + QMAKESPEC=linux-clang echo QMAKESPEC has been modified: $QMAKESPEC fi fi + export QTDIR + export PATH + export LD_LIBRARY_PATH + export LD_RUN_PATH + export QMAKESPEC + + echo QTDIR is set to: $QTDIR echo PATH has been modified with $QTDIR/bin echo LD_LIBRARY_PATH has been modified with $QTDIR/lib echo LD_RUN_PATH has been modified with $QTDIR/lib - echo QTDIR has been modified: $QTDIR } if [ "`uname | grep -i 'linux\|debian'`" ]; then @@ -97,9 +106,6 @@ if [ "`uname | grep -i 'linux\|debian'`" ]; then if [ "`echo $* | grep clang`" ]; then setenv_linux_clang fi - if [ "`echo $* | grep qt5`" ]; then - setenv_qt5 - fi elif [ "`uname | grep -i freebsd`" ]; then setenv_freebsd elif [ "`uname | grep -i netbsd`" ]; then @@ -109,3 +115,7 @@ else setenv_common echo unknown system. guessed env variables. see 'setenv-unibuild.sh' fi + +if [ "`echo $* | grep qt5`" ]; then + setenv_qt5 +fi -- cgit v0.10.1 From 8282cd2ea5f764b8062631e236eaba6c0fdc3ea7 Mon Sep 17 00:00:00 2001 From: don bright Date: Mon, 7 Jan 2013 22:01:32 -0600 Subject: better detection of qmake-qt5 vs qmake for qt5 diff --git a/scripts/setenv-unibuild.sh b/scripts/setenv-unibuild.sh index 951f707..881526e 100644 --- a/scripts/setenv-unibuild.sh +++ b/scripts/setenv-unibuild.sh @@ -34,11 +34,6 @@ setenv_common() echo OPENSCAD_LIBRARIES modified echo GLEWDIR modified - if [ "`command -v qmake-qt4`" ]; then - echo "Please re-run qmake-qt4 and run 'make clean' if necessary" - else - echo "Please re-run qmake and run 'make clean' if necessary" - fi } setenv_freebsd() @@ -73,8 +68,21 @@ setenv_linux_clang() echo QMAKESPEC has been modified: $QMAKESPEC } +clean_note() +{ + if [ $QT5_SETUP ]; then + QMAKEBIN=qmake + elif [ "`command -v qmake-qt4`" ]; then + QMAKEBIN=qmake-qt4 + else + QMAKEBIN=qmake + fi + echo "Please re-run" $QMAKEBIN "and run 'make clean' if necessary" +} + setenv_qt5() { + QT5_SETUP=true if [ ! $QTDIR ]; then QTDIR=/opt/qt5 echo Please set QTDIR before running this qt5 script. Assuming $QTDIR @@ -83,7 +91,7 @@ setenv_qt5() LD_LIBRARY_PATH=$QTDIR/lib:$LD_LIBRARY_PATH LD_RUN_PATH=$QTDIR/lib:$LD_RUN_PATH if [ "`echo $CC | grep clang`" ]; then - if [ "`uname | grep -i linux\|debian`" ]; then + if [ "`uname | grep -i linux`" ]; then QMAKESPEC=linux-clang echo QMAKESPEC has been modified: $QMAKESPEC fi @@ -99,6 +107,8 @@ setenv_qt5() echo PATH has been modified with $QTDIR/bin echo LD_LIBRARY_PATH has been modified with $QTDIR/lib echo LD_RUN_PATH has been modified with $QTDIR/lib + + export QT5_SETUP } if [ "`uname | grep -i 'linux\|debian'`" ]; then @@ -119,3 +129,6 @@ fi if [ "`echo $* | grep qt5`" ]; then setenv_qt5 fi + +clean_note + -- cgit v0.10.1 From 8cea6834f68cbbfb85c2568d388bf3b2e707cca5 Mon Sep 17 00:00:00 2001 From: Marius Kintel Date: Tue, 8 Jan 2013 13:24:54 -0500 Subject: bugfix for recently introduced bug: Render negative 2D objects slightly thicker than positive objects to avoid z-buffer tearing with OpenCSG rendering diff --git a/src/polyset.cc b/src/polyset.cc index 3b3be34..e601585 100644 --- a/src/polyset.cc +++ b/src/polyset.cc @@ -157,7 +157,8 @@ void PolySet::render_surface(csgmode_e csgmode, const Transform3d &m, GLint *sha } #endif /* ENABLE_OPENCSG */ if (this->is2d) { - double zbase = 1; // Render 2D objects 1mm thick + // Render 2D objects 1mm thick, but differences slightly larger + double zbase = 1 + (csgmode & CSGMODE_DIFFERENCE_FLAG) * 0.1; glBegin(GL_TRIANGLES); for (double z = -zbase/2; z < zbase; z += zbase) { @@ -248,7 +249,8 @@ void PolySet::render_edges(csgmode_e csgmode) const { glDisable(GL_LIGHTING); if (this->is2d) { - double zbase = 1; // Render 2D objects 1mm thick + // Render 2D objects 1mm thick, but differences slightly larger + double zbase = 1 + (csgmode & CSGMODE_DIFFERENCE_FLAG) * 0.1; for (double z = -zbase/2; z < zbase; z += zbase) { for (size_t i = 0; i < borders.size(); i++) { diff --git a/src/polyset.h b/src/polyset.h index 4ca57bf..6626f79 100644 --- a/src/polyset.h +++ b/src/polyset.h @@ -29,14 +29,15 @@ public: BoundingBox getBoundingBox() const; +#define CSGMODE_DIFFERENCE_FLAG 0x10 enum csgmode_e { - CSGMODE_NONE, - CSGMODE_NORMAL = 1, - CSGMODE_DIFFERENCE = 2, - CSGMODE_BACKGROUND = 11, - CSGMODE_BACKGROUND_DIFFERENCE = 12, - CSGMODE_HIGHLIGHT = 21, - CSGMODE_HIGHLIGHT_DIFFERENCE = 22 + CSGMODE_NONE = 0x00, + CSGMODE_NORMAL = 0x01, + CSGMODE_DIFFERENCE = CSGMODE_NORMAL | CSGMODE_DIFFERENCE_FLAG, + CSGMODE_BACKGROUND = 0x02, + CSGMODE_BACKGROUND_DIFFERENCE = CSGMODE_BACKGROUND | CSGMODE_DIFFERENCE_FLAG, + CSGMODE_HIGHLIGHT = 0x03, + CSGMODE_HIGHLIGHT_DIFFERENCE = CSGMODE_HIGHLIGHT | CSGMODE_DIFFERENCE_FLAG }; void render_surface(csgmode_e csgmode, const Transform3d &m, GLint *shaderinfo = NULL) const; -- cgit v0.10.1 From 810f1a86189555023240507848ff9eebb161b8de Mon Sep 17 00:00:00 2001 From: Marius Kintel Date: Tue, 8 Jan 2013 13:26:25 -0500 Subject: Don't just ignore geometric nodes having zero volume/area - when doing difference/intersection, they tend to turn negative objects into positive ones. Fixes #221 diff --git a/src/CGALEvaluator.cc b/src/CGALEvaluator.cc index a4744c2..4deb3b3 100644 --- a/src/CGALEvaluator.cc +++ b/src/CGALEvaluator.cc @@ -61,14 +61,16 @@ void CGALEvaluator::process(CGAL_Nef_polyhedron &target, const CGAL_Nef_polyhedr if (target.dim != 2 && target.dim != 3) { assert(false && "Dimension of Nef polyhedron must be 2 or 3"); } - if (src.empty()) return; // Empty polyhedron. This can happen for e.g. square([0,0]) + if (src.isEmpty()) return; // Empty polyhedron. This can happen for e.g. square([0,0]) + if (target.isEmpty() && op != CGE_UNION) return; // empty op => empty if (target.dim != src.dim) return; // If someone tries to e.g. union 2d and 3d objects CGAL::Failure_behaviour old_behaviour = CGAL::set_error_behaviour(CGAL::THROW_EXCEPTION); try { switch (op) { case CGE_UNION: - target += src; + if (target.isEmpty()) target = src.copy(); + else target += src; break; case CGE_INTERSECTION: target *= src; @@ -110,7 +112,8 @@ CGAL_Nef_polyhedron CGALEvaluator::applyToChildren(const AbstractNode &node, CGA if (!isCached(*chnode)) { CGALCache::instance()->insert(this->tree.getIdString(*chnode), chN); } - if (N.empty()) N = chN.copy(); + // Initialize N on first iteration with first expected geometric object + if (N.isNull() && !N.isEmpty()) N = chN.copy(); else process(N, chN, op); chnode->progress_report(); @@ -245,7 +248,6 @@ Response CGALEvaluator::visit(State &state, const TransformNode &node) if (!isCached(node)) { // First union all children N = applyToChildren(node, CGE_UNION); - if ( matrix_contains_infinity( node.matrix ) || matrix_contains_nan( node.matrix ) ) { // due to the way parse/eval works we can't currently distinguish between NaN and Inf PRINT("Warning: Transformation matrix contains Not-a-Number and/or Infinity - removing object."); @@ -253,51 +255,53 @@ Response CGALEvaluator::visit(State &state, const TransformNode &node) } // Then apply transform - // If there is no geometry under the transform, N will be empty and of dim 0, - // just just silently ignore such nodes - if (N.dim == 2) { - // Unfortunately CGAL provides no transform method for CGAL_Nef_polyhedron2 - // objects. So we convert in to our internal 2d data format, transform it, - // tesselate it and create a new CGAL_Nef_polyhedron2 from it.. What a hack! - - Eigen::Matrix2f testmat; - testmat << node.matrix(0,0), node.matrix(0,1), node.matrix(1,0), node.matrix(1,1); - if (testmat.determinant() == 0) { - PRINT("Warning: Scaling a 2D object with 0 - removing object"); - N.reset(); - } - else { - CGAL_Aff_transformation2 t( - node.matrix(0,0), node.matrix(0,1), node.matrix(0,3), - node.matrix(1,0), node.matrix(1,1), node.matrix(1,3), node.matrix(3,3)); + // If there is no geometry under the transform, N will be empty + // just silently ignore such nodes + if (!N.isNull()) { + if (N.dim == 2) { + // Unfortunately CGAL provides no transform method for CGAL_Nef_polyhedron2 + // objects. So we convert in to our internal 2d data format, transform it, + // tesselate it and create a new CGAL_Nef_polyhedron2 from it.. What a hack! - DxfData *dd = N.convertToDxfData(); - for (size_t i=0; i < dd->points.size(); i++) { - CGAL_Kernel2::Point_2 p = CGAL_Kernel2::Point_2(dd->points[i][0], dd->points[i][1]); - p = t.transform(p); - dd->points[i][0] = to_double(p.x()); - dd->points[i][1] = to_double(p.y()); + Eigen::Matrix2f testmat; + testmat << node.matrix(0,0), node.matrix(0,1), node.matrix(1,0), node.matrix(1,1); + if (testmat.determinant() == 0) { + PRINT("Warning: Scaling a 2D object with 0 - removing object"); + N.reset(); + } + else { + CGAL_Aff_transformation2 t( + node.matrix(0,0), node.matrix(0,1), node.matrix(0,3), + node.matrix(1,0), node.matrix(1,1), node.matrix(1,3), node.matrix(3,3)); + + DxfData *dd = N.convertToDxfData(); + for (size_t i=0; i < dd->points.size(); i++) { + CGAL_Kernel2::Point_2 p = CGAL_Kernel2::Point_2(dd->points[i][0], dd->points[i][1]); + p = t.transform(p); + dd->points[i][0] = to_double(p.x()); + dd->points[i][1] = to_double(p.y()); + } + + PolySet ps; + ps.is2d = true; + dxf_tesselate(&ps, *dd, 0, true, false, 0); + + N = evaluateCGALMesh(ps); + delete dd; } - - PolySet ps; - ps.is2d = true; - dxf_tesselate(&ps, *dd, 0, true, false, 0); - - N = evaluateCGALMesh(ps); - delete dd; - } - } - else if (N.dim == 3) { - if (node.matrix.matrix().determinant() == 0) { - PRINT("Warning: Scaling a 3D object with 0 - removing object"); - N.reset(); } - else { - CGAL_Aff_transformation t( - node.matrix(0,0), node.matrix(0,1), node.matrix(0,2), node.matrix(0,3), - node.matrix(1,0), node.matrix(1,1), node.matrix(1,2), node.matrix(1,3), - node.matrix(2,0), node.matrix(2,1), node.matrix(2,2), node.matrix(2,3), node.matrix(3,3)); - N.p3->transform(t); + else if (N.dim == 3) { + if (node.matrix.matrix().determinant() == 0) { + PRINT("Warning: Scaling a 3D object with 0 - removing object"); + N.reset(); + } + else { + CGAL_Aff_transformation t( + node.matrix(0,0), node.matrix(0,1), node.matrix(0,2), node.matrix(0,3), + node.matrix(1,0), node.matrix(1,1), node.matrix(1,2), node.matrix(1,3), + node.matrix(2,0), node.matrix(2,1), node.matrix(2,2), node.matrix(2,3), node.matrix(3,3)); + N.p3->transform(t); + } } } } @@ -388,7 +392,7 @@ void CGALEvaluator::addToParent(const State &state, const AbstractNode &node, co CGAL_Nef_polyhedron CGALEvaluator::evaluateCGALMesh(const PolySet &ps) { - if (ps.empty()) return CGAL_Nef_polyhedron(); + if (ps.empty()) return CGAL_Nef_polyhedron(ps.is2d ? 2 : 3); if (ps.is2d) { diff --git a/src/CGALRenderer.cc b/src/CGALRenderer.cc index adf1217..4357e44 100644 --- a/src/CGALRenderer.cc +++ b/src/CGALRenderer.cc @@ -43,7 +43,11 @@ CGALRenderer::CGALRenderer(const CGAL_Nef_polyhedron &root) : root(root) { - if (root.dim == 2) { + if (this->root.isNull()) { + this->polyhedron = NULL; + this->polyset = NULL; + } + else if (root.dim == 2) { DxfData *dd = root.convertToDxfData(); this->polyhedron = NULL; this->polyset = new PolySet(); @@ -67,10 +71,6 @@ CGALRenderer::CGALRenderer(const CGAL_Nef_polyhedron &root) : root(root) CGAL::OGL::Nef3_Converter::convert_to_OGLPolyhedron(*this->root.p3, this->polyhedron); this->polyhedron->init(); } - else { - this->polyhedron = NULL; - this->polyset = NULL; - } } CGALRenderer::~CGALRenderer() @@ -81,6 +81,7 @@ CGALRenderer::~CGALRenderer() void CGALRenderer::draw(bool showfaces, bool showedges) const { + if (this->root.isNull()) return; if (this->root.dim == 2) { // Draw 2D polygons glDisable(GL_LIGHTING); diff --git a/src/CGAL_Nef_polyhedron.cc b/src/CGAL_Nef_polyhedron.cc index ad2e4e2..8906595 100644 --- a/src/CGAL_Nef_polyhedron.cc +++ b/src/CGAL_Nef_polyhedron.cc @@ -61,7 +61,7 @@ CGAL_Nef_polyhedron &CGAL_Nef_polyhedron::minkowski(const CGAL_Nef_polyhedron &o int CGAL_Nef_polyhedron::weight() const { - if (this->empty()) return 0; + if (this->isNull()) return 0; size_t memsize = sizeof(CGAL_Nef_polyhedron); if (this->dim == 2) { @@ -84,8 +84,7 @@ int CGAL_Nef_polyhedron::weight() const */ PolySet *CGAL_Nef_polyhedron::convertToPolyset() { - if (this->empty()) - return new PolySet(); + if (this->isNull()) return new PolySet(); PolySet *ps = NULL; if (this->dim == 2) { ps = new PolySet(); diff --git a/src/CGAL_Nef_polyhedron.h b/src/CGAL_Nef_polyhedron.h index e8c505b..d949a2a 100644 --- a/src/CGAL_Nef_polyhedron.h +++ b/src/CGAL_Nef_polyhedron.h @@ -8,12 +8,15 @@ class CGAL_Nef_polyhedron { public: - CGAL_Nef_polyhedron() : dim(0) {} + CGAL_Nef_polyhedron(int dim = 0) : dim(dim) {} CGAL_Nef_polyhedron(CGAL_Nef_polyhedron2 *p); CGAL_Nef_polyhedron(CGAL_Nef_polyhedron3 *p); ~CGAL_Nef_polyhedron() {} - bool empty() const { return (dim == 0 || (!p2 && !p3)); } + // Empty means it is a geometric node which has zero area/volume + bool isEmpty() const { return (dim > 0 && !p2 && !p3); } + // Null means the node doesn't contain any geometry (for whatever reason) + bool isNull() const { return !p2 && !p3; } void reset() { dim=0; p2.reset(); p3.reset(); } CGAL_Nef_polyhedron &operator+=(const CGAL_Nef_polyhedron &other); CGAL_Nef_polyhedron &operator*=(const CGAL_Nef_polyhedron &other); diff --git a/src/PolySetCGALEvaluator.cc b/src/PolySetCGALEvaluator.cc index 8e08e19..224e657 100644 --- a/src/PolySetCGALEvaluator.cc +++ b/src/PolySetCGALEvaluator.cc @@ -134,11 +134,11 @@ PolySet *PolySetCGALEvaluator::evaluatePolySet(const ProjectionNode &node) if (v->modinst->isBackground()) continue; CGAL_Nef_polyhedron N = this->cgalevaluator.evaluateCGALMesh(*v); if (N.dim == 3) { - if (sum.empty()) sum = N.copy(); + if (sum.isNull()) sum = N.copy(); else sum += N; } } - if (sum.empty()) return NULL; + if (sum.isNull()) return NULL; if (!sum.p3->is_simple()) { if (!node.cut_mode) { PRINT("WARNING: Body of projection(cut = false) isn't valid 2-manifold! Modify your design.."); @@ -149,7 +149,7 @@ PolySet *PolySetCGALEvaluator::evaluatePolySet(const ProjectionNode &node) //std::cout << sum.dump(); //std::cout.flush(); - CGAL_Nef_polyhedron nef_poly; + CGAL_Nef_polyhedron nef_poly(2); if (node.cut_mode) { CGAL::Failure_behaviour old_behaviour = CGAL::set_error_behaviour(CGAL::THROW_EXCEPTION); @@ -180,7 +180,7 @@ PolySet *PolySetCGALEvaluator::evaluatePolySet(const ProjectionNode &node) } } - if ( sum.p3->is_empty() ) { + if (sum.p3->is_empty()) { CGAL::set_error_behaviour(old_behaviour); PRINT("WARNING: projection() failed."); return NULL; @@ -204,7 +204,6 @@ PolySet *PolySetCGALEvaluator::evaluatePolySet(const ProjectionNode &node) log << "\n"; } nef_poly.p2 = zremover.output_nefpoly2d; - nef_poly.dim = 2; } catch (const CGAL::Failure_exception &e) { PRINTB("CGAL error in projection node while flattening: %s", e.what()); } @@ -284,8 +283,7 @@ PolySet *PolySetCGALEvaluator::evaluatePolySet(const ProjectionNode &node) plist.push_back(p); } // FIXME: Should the CGAL_Nef_polyhedron2 be cached? - if (nef_poly.empty()) { - nef_poly.dim = 2; + if (nef_poly.isEmpty()) { nef_poly.p2.reset(new CGAL_Nef_polyhedron2(plist.begin(), plist.end(), CGAL_Nef_polyhedron2::INCLUDED)); } else { @@ -385,18 +383,18 @@ PolySet *PolySetCGALEvaluator::evaluatePolySet(const LinearExtrudeNode &node) BOOST_FOREACH (AbstractNode * v, node.getChildren()) { if (v->modinst->isBackground()) continue; CGAL_Nef_polyhedron N = this->cgalevaluator.evaluateCGALMesh(*v); - if (!N.empty()) { + if (!N.isNull()) { if (N.dim != 2) { PRINT("ERROR: linear_extrude() is not defined for 3D child objects!"); } else { - if (sum.empty()) sum = N.copy(); + if (sum.isNull()) sum = N.copy(); else sum += N; } } } - if (sum.empty()) return NULL; + if (sum.isNull()) return NULL; dxf = sum.convertToDxfData();; } else { dxf = new DxfData(node.fn, node.fs, node.fa, node.filename, node.layername, node.origin_x, node.origin_y, node.scale); @@ -485,18 +483,18 @@ PolySet *PolySetCGALEvaluator::evaluatePolySet(const RotateExtrudeNode &node) BOOST_FOREACH (AbstractNode * v, node.getChildren()) { if (v->modinst->isBackground()) continue; CGAL_Nef_polyhedron N = this->cgalevaluator.evaluateCGALMesh(*v); - if (!N.empty()) { + if (!N.isNull()) { if (N.dim != 2) { PRINT("ERROR: rotate_extrude() is not defined for 3D child objects!"); } else { - if (sum.empty()) sum = N.copy(); + if (sum.isNull()) sum = N.copy(); else sum += N; } } } - if (sum.empty()) return NULL; + if (sum.isNull()) return NULL; dxf = sum.convertToDxfData(); } else { dxf = new DxfData(node.fn, node.fs, node.fa, node.filename, node.layername, node.origin_x, node.origin_y, node.scale); @@ -511,7 +509,7 @@ PolySet *PolySetCGALEvaluator::evaluatePolySet(const CgaladvNode &node) { CGAL_Nef_polyhedron N = this->cgalevaluator.evaluateCGALMesh(node); PolySet *ps = NULL; - if (!N.empty()) { + if (!N.isNull()) { ps = N.convertToPolyset(); if (ps) ps->convexity = node.convexity; } @@ -523,7 +521,7 @@ PolySet *PolySetCGALEvaluator::evaluatePolySet(const RenderNode &node) { CGAL_Nef_polyhedron N = this->cgalevaluator.evaluateCGALMesh(node); PolySet *ps = NULL; - if (!N.empty()) { + if (!N.isNull()) { if (N.dim == 3 && !N.p3->is_simple()) { PRINT("WARNING: Body of render() isn't valid 2-manifold!"); } diff --git a/src/mainwin.cc b/src/mainwin.cc index dc5b79b..dde6761 100644 --- a/src/mainwin.cc +++ b/src/mainwin.cc @@ -1236,35 +1236,37 @@ void MainWindow::actionRenderCGALDone(CGAL_Nef_polyhedron *root_N) PolySetCache::instance()->print(); CGALCache::instance()->print(); - if (root_N->dim == 2) { - PRINT(" Top level object is a 2D object:"); - PRINTB(" Empty: %6s", (root_N->p2->is_empty() ? "yes" : "no")); - PRINTB(" Plane: %6s", (root_N->p2->is_plane() ? "yes" : "no")); - PRINTB(" Vertices: %6d", root_N->p2->explorer().number_of_vertices()); - PRINTB(" Halfedges: %6d", root_N->p2->explorer().number_of_halfedges()); - PRINTB(" Edges: %6d", root_N->p2->explorer().number_of_edges()); - PRINTB(" Faces: %6d", root_N->p2->explorer().number_of_faces()); - PRINTB(" FaceCycles: %6d", root_N->p2->explorer().number_of_face_cycles()); - PRINTB(" ConnComp: %6d", root_N->p2->explorer().number_of_connected_components()); - } - - if (root_N->dim == 3) { - PRINT(" Top level object is a 3D object:"); - PRINTB(" Simple: %6s", (root_N->p3->is_simple() ? "yes" : "no")); - PRINTB(" Valid: %6s", (root_N->p3->is_valid() ? "yes" : "no")); - PRINTB(" Vertices: %6d", root_N->p3->number_of_vertices()); - PRINTB(" Halfedges: %6d", root_N->p3->number_of_halfedges()); - PRINTB(" Edges: %6d", root_N->p3->number_of_edges()); - PRINTB(" Halffacets: %6d", root_N->p3->number_of_halffacets()); - PRINTB(" Facets: %6d", root_N->p3->number_of_facets()); - PRINTB(" Volumes: %6d", root_N->p3->number_of_volumes()); + if (!root_N->isNull()) { + if (root_N->dim == 2) { + PRINT(" Top level object is a 2D object:"); + PRINTB(" Empty: %6s", (root_N->p2->is_empty() ? "yes" : "no")); + PRINTB(" Plane: %6s", (root_N->p2->is_plane() ? "yes" : "no")); + PRINTB(" Vertices: %6d", root_N->p2->explorer().number_of_vertices()); + PRINTB(" Halfedges: %6d", root_N->p2->explorer().number_of_halfedges()); + PRINTB(" Edges: %6d", root_N->p2->explorer().number_of_edges()); + PRINTB(" Faces: %6d", root_N->p2->explorer().number_of_faces()); + PRINTB(" FaceCycles: %6d", root_N->p2->explorer().number_of_face_cycles()); + PRINTB(" ConnComp: %6d", root_N->p2->explorer().number_of_connected_components()); + } + + if (root_N->dim == 3) { + PRINT(" Top level object is a 3D object:"); + PRINTB(" Simple: %6s", (root_N->p3->is_simple() ? "yes" : "no")); + PRINTB(" Valid: %6s", (root_N->p3->is_valid() ? "yes" : "no")); + PRINTB(" Vertices: %6d", root_N->p3->number_of_vertices()); + PRINTB(" Halfedges: %6d", root_N->p3->number_of_halfedges()); + PRINTB(" Edges: %6d", root_N->p3->number_of_edges()); + PRINTB(" Halffacets: %6d", root_N->p3->number_of_halffacets()); + PRINTB(" Facets: %6d", root_N->p3->number_of_facets()); + PRINTB(" Volumes: %6d", root_N->p3->number_of_volumes()); + } } int s = this->progresswidget->elapsedTime() / 1000; PRINTB("Total rendering time: %d hours, %d minutes, %d seconds", (s / (60*60)) % ((s / 60) % 60) % (s % 60)); this->root_N = root_N; - if (!this->root_N->empty()) { + if (!this->root_N->isNull()) { this->cgalRenderer = new CGALRenderer(*this->root_N); // Go to CGAL view mode if (viewActionCGALGrid->isChecked()) { diff --git a/testdata/scad/features/difference-tests.scad b/testdata/scad/features/difference-tests.scad index 186772f..b770764 100644 --- a/testdata/scad/features/difference-tests.scad +++ b/testdata/scad/features/difference-tests.scad @@ -29,6 +29,7 @@ translate([24,0,0]) difference() { translate([0,0,6.99]) cylinder(r=4, h=4, center=true); } +// Subtracting something from nothing translate([24,12,0]) difference() { cube([0,10,10], center=true); # cylinder(r=4, h=20, center=true); diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 18f4469..87e5319 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -773,7 +773,6 @@ set_test_config(Heavy opencsgtest_minkowski3-tests cgalpngtest_minkowski3-tests cgalpngtest_for-tests cgalpngtest_for-nested-tests - cgalpngtest_difference-tests cgalpngtest_intersection-tests) foreach(FILE ${EXAMPLE_FILES}) diff --git a/tests/cgalpngtest.cc b/tests/cgalpngtest.cc index 08e539e..56861c6 100644 --- a/tests/cgalpngtest.cc +++ b/tests/cgalpngtest.cc @@ -153,30 +153,30 @@ int main(int argc, char **argv) exit(1); } - CGALRenderer cgalRenderer(N); - + CGALRenderer cgalRenderer(N); + BoundingBox bbox; if (cgalRenderer.polyhedron) { CGAL::Bbox_3 cgalbbox = cgalRenderer.polyhedron->bbox(); bbox = BoundingBox(Vector3d(cgalbbox.xmin(), cgalbbox.ymin(), cgalbbox.zmin()), - Vector3d(cgalbbox.xmax(), cgalbbox.ymax(), cgalbbox.zmax())); + Vector3d(cgalbbox.xmax(), cgalbbox.ymax(), cgalbbox.zmax())); } else if (cgalRenderer.polyset) { bbox = cgalRenderer.polyset->getBoundingBox(); } - + Vector3d center = getBoundingCenter(bbox); double radius = getBoundingRadius(bbox); - + Vector3d cameradir(1, 1, -0.5); Vector3d camerapos = center - radius*2*cameradir; csgInfo.glview->setCamera(camerapos, center); - - + + csgInfo.glview->setRenderer(&cgalRenderer); csgInfo.glview->paintGL(); csgInfo.glview->save(outfile); - + delete root_node; delete root_module; diff --git a/tests/cgalstlsanitytest.cc b/tests/cgalstlsanitytest.cc index 137f626..52cfb41 100644 --- a/tests/cgalstlsanitytest.cc +++ b/tests/cgalstlsanitytest.cc @@ -129,7 +129,7 @@ int main(int argc, char **argv) CGAL_Nef_polyhedron N = cgalevaluator.evaluateCGALMesh(*root_node); current_path(original_path); - if (!N.empty()) { + if (!N.isNull()) { std::ofstream outfile; outfile.open(outfilename); diff --git a/tests/cgaltest.cc b/tests/cgaltest.cc index e4761db..b546286 100644 --- a/tests/cgaltest.cc +++ b/tests/cgaltest.cc @@ -122,7 +122,7 @@ int main(int argc, char **argv) CGAL_Nef_polyhedron N = cgalevaluator.evaluateCGALMesh(*root_node); current_path(original_path); - if (!N.empty()) { + if (!N.isNull()) { export_stl(&N, std::cout); } -- cgit v0.10.1 From 7defd5d5a978e647d6e6b61e4190f3d9b60c0cc7 Mon Sep 17 00:00:00 2001 From: Marius Kintel Date: Tue, 8 Jan 2013 13:34:22 -0500 Subject: sync diff --git a/doc/TODO.txt b/doc/TODO.txt index be70c26..44b11ad 100644 --- a/doc/TODO.txt +++ b/doc/TODO.txt @@ -135,6 +135,7 @@ o Hollow donut problem rendering keeps the hole, but renders slightly incorrect. 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) LANGUAGE && BUILTINS -------------------- -- cgit v0.10.1 From a82651de310e4aedf7a634581e6369f528fb649c Mon Sep 17 00:00:00 2001 From: don bright Date: Tue, 8 Jan 2013 20:07:28 -0600 Subject: remove QCodeEditor inspired by Giles Bathgates Jan 7 2012 email to list diff --git a/setenv_mac-clang.sh b/setenv_mac-clang.sh index 2bc9234..0dcc51f 100644 --- a/setenv_mac-clang.sh +++ b/setenv_mac-clang.sh @@ -4,8 +4,7 @@ export QMAKESPEC=unsupported/macx-clang #export OPENCSGDIR=$PWD/../OpenCSG-1.3.0 #export CGALDIR=$PWD/../install/CGAL-3.6 -#export QCODEEDITDIR=$PWD/../qcodeedit-2.2.3/install -#export DYLD_LIBRARY_PATH=$OPENCSGDIR/lib:$QCODEEDITDIR/lib +#export DYLD_LIBRARY_PATH=$OPENCSGDIR/lib # ccache: export PATH=/opt/local/libexec/ccache:$PATH diff --git a/setenv_mjau.sh b/setenv_mjau.sh index 851cf0e..3e27665 100644 --- a/setenv_mjau.sh +++ b/setenv_mjau.sh @@ -4,8 +4,7 @@ export QMAKESPEC=macx-g++ #export OPENCSGDIR=$PWD/../OpenCSG-1.3.0 #export CGALDIR=$PWD/../install/CGAL-3.6 -#export QCODEEDITDIR=$PWD/../qcodeedit-2.2.3/install -#export DYLD_LIBRARY_PATH=$OPENCSGDIR/lib:$QCODEEDITDIR/lib +#export DYLD_LIBRARY_PATH=$OPENCSGDIR/lib # ccache: export PATH=/opt/local/libexec/ccache:$PATH diff --git a/src/editor.cc b/src/editor.cc index 92aeefe..08bf005 100644 --- a/src/editor.cc +++ b/src/editor.cc @@ -1,7 +1,6 @@ #include "editor.h" #include "Preferences.h" -#ifndef _QCODE_EDIT_ void Editor::indentSelection() { QTextCursor cursor = textCursor(); @@ -109,4 +108,3 @@ void Editor::wheelEvent ( QWheelEvent * event ) } } -#endif diff --git a/src/editor.h b/src/editor.h index bb338b0..09484f5 100644 --- a/src/editor.h +++ b/src/editor.h @@ -3,26 +3,11 @@ #include #include -#ifdef _QCODE_EDIT_ -#include -class Editor : public QEditor -#else #include class Editor : public QTextEdit -#endif { Q_OBJECT public: -#ifdef _QCODE_EDIT_ - Editor(QWidget *parent) : QEditor(parent) {} - QString toPlainText() const { return text(); } - void setPlainText(const QString& text) { setText(text); } -public slots: - //void zoomIn() { zoom(1); } - void zoomIn(int n = 1) { zoom(n); } - //void zoomOut() { zoom(-1); } - void zoomOut(int n = 1) { zoom(-n); } -#else Editor(QWidget *parent) : QTextEdit(parent) { setAcceptRichText(false); } public slots: void zoomIn(); @@ -36,5 +21,4 @@ public slots: void uncommentSelection(); private: void wheelEvent ( QWheelEvent * event ); -#endif }; diff --git a/src/highlighter.cc b/src/highlighter.cc index 64ea980..ca4b4cf 100644 --- a/src/highlighter.cc +++ b/src/highlighter.cc @@ -27,11 +27,7 @@ #include "highlighter.h" #include "parsersettings.h" // extern int parser_error_pos; -#ifdef _QCODE_EDIT_ -Highlighter::Highlighter(QDocument *parent) -#else Highlighter::Highlighter(QTextDocument *parent) -#endif : QSyntaxHighlighter(parent) { } diff --git a/src/highlighter.h b/src/highlighter.h index 1bd54d2..2eead6d 100644 --- a/src/highlighter.h +++ b/src/highlighter.h @@ -3,18 +3,10 @@ #include -#ifdef _QCODE_EDIT_ -#include "qdocument.h" -#endif - class Highlighter : public QSyntaxHighlighter { public: -#ifdef _QCODE_EDIT_ - Highlighter(QDocument *parent); -#else Highlighter(QTextDocument *parent); -#endif void highlightBlock(const QString &text); }; diff --git a/src/mainwin.cc b/src/mainwin.cc index dde6761..72254a3 100644 --- a/src/mainwin.cc +++ b/src/mainwin.cc @@ -70,11 +70,6 @@ #include #include #include -#ifdef _QCODE_EDIT_ -#include "qdocument.h" -#include "qformatscheme.h" -#include "qlanguagefactory.h" -#endif #include @@ -186,15 +181,7 @@ MainWindow::MainWindow(const QString &filename) fsteps = 1; highlighter = NULL; -#ifdef _QCODE_EDIT_ - QFormatScheme *formats = new QFormatScheme("qxs/openscad.qxf"); - QDocument::setDefaultFormatScheme(formats); - QLanguageFactory *languages = new QLanguageFactory(formats,this); - languages->addDefinitionPath("qxs"); - languages->setLanguage(editor, "openscad"); -#else editor->setTabStopWidth(30); -#endif editor->setLineWrapping(true); // Not designable this->glview->statusLabel = new QLabel(this); @@ -348,13 +335,8 @@ MainWindow::MainWindow(const QString &filename) updateRecentFileActions(); connect(editor->document(), SIGNAL(contentsChanged()), this, SLOT(animateUpdateDocChanged())); -#ifdef _QCODE_EDIT_ - connect(editor, SIGNAL(contentModified(bool)), this, SLOT(setWindowModified(bool))); - connect(editor, SIGNAL(contentModified(bool)), fileActionSave, SLOT(setEnabled(bool))); -#else connect(editor->document(), SIGNAL(modificationChanged(bool)), this, SLOT(setWindowModified(bool))); connect(editor->document(), SIGNAL(modificationChanged(bool)), fileActionSave, SLOT(setEnabled(bool))); -#endif connect(this->glview, SIGNAL(doAnimateUpdate()), this, SLOT(animateUpdate())); connect(Preferences::inst(), SIGNAL(requestRedraw()), this->glview, SLOT(updateGL())); @@ -483,12 +465,7 @@ void MainWindow::openFile(const QString &new_filename) { #ifdef ENABLE_MDI -#ifdef _QCODE_EDIT_ - if (this->editor->document()->lines() > 1 || - !this->editor->document()->text(true, false).trimmed().isEmpty()) { -#else if (!editor->toPlainText().isEmpty()) { -#endif new MainWindow(new_filename); clearCurrentOutput(); return; @@ -957,11 +934,7 @@ void MainWindow::hideEditor() void MainWindow::pasteViewportTranslation() { -#ifdef _QCODE_EDIT_ - QDocumentCursor cursor = editor->cursor(); -#else QTextCursor cursor = editor->textCursor(); -#endif QString txt; txt.sprintf("[ %.2f, %.2f, %.2f ]", -this->glview->object_trans_x, -this->glview->object_trans_y, -this->glview->object_trans_z); cursor.insertText(txt); @@ -969,11 +942,7 @@ void MainWindow::pasteViewportTranslation() void MainWindow::pasteViewportRotation() { -#ifdef _QCODE_EDIT_ - QDocumentCursor cursor = editor->cursor(); -#else QTextCursor cursor = editor->textCursor(); -#endif QString txt; txt.sprintf("[ %.2f, %.2f, %.2f ]", fmodf(360 - this->glview->object_rot_x + 90, 360), fmodf(360 - this->glview->object_rot_y, 360), fmodf(360 - this->glview->object_rot_z, 360)); @@ -1075,14 +1044,9 @@ bool MainWindow::compileTopLevelDocument(bool reload) this->highlighter = new Highlighter(editor->document()); if (!animate_panel->isVisible()) { -#ifdef _QCODE_EDIT_ - QDocumentCursor cursor = editor->cursor(); - cursor.setPosition(parser_error_pos); -#else QTextCursor cursor = editor->textCursor(); cursor.setPosition(parser_error_pos); editor->setTextCursor(cursor); -#endif } } } -- cgit v0.10.1 From b0cefc0f3b758a73ec7e30677f9f603400d9dc22 Mon Sep 17 00:00:00 2001 From: don bright Date: Tue, 8 Jan 2013 21:15:14 -0600 Subject: merge, by hand, Christopher Olah's syntax highlighter code diff --git a/src/highlighter.cc b/src/highlighter.cc index ca4b4cf..6e51ecc 100644 --- a/src/highlighter.cc +++ b/src/highlighter.cc @@ -24,16 +24,103 @@ * */ +// Syntax Highlight code by Chris Olah + #include "highlighter.h" #include "parsersettings.h" // extern int parser_error_pos; -Highlighter::Highlighter(QTextDocument *parent) +Highlighter::Highlighter(QTextDocument *parent, mode_e mode) : QSyntaxHighlighter(parent) { + this->mode = mode; + operators << "!" << "&&" << "||" << "+" << "-" << "*" << "/" << "%" << "!" << "#" << ";"; + KeyWords << "for" << "intersection_for" << "if" << "assign" + << "module" << "function" + << "$children" << "child" << "$fn" << "$fa" << "$fb" // Lump special variables in here + << "union" << "intersection" << "difference" << "render"; //Lump CSG in here + Primitives3D << "cube" << "cylinder" << "sphere" << "polyhedron"; + Primitives2D << "square" << "polygon" << "circle"; + Transforms << "scale" << "translate" << "rotate" << "multmatrix" << "color" + << "linear_extrude" << "rotate_extrude"; // Lump extrudes in here. + Imports << "include" << "use" << "import_stl"; + + //this->OperatorStyle.setForeground + KeyWordStyle.setForeground(Qt::darkGreen); + TransformStyle.setForeground(Qt::darkGreen); + PrimitiveStyle3D.setForeground(Qt::darkBlue); + PrimitiveStyle2D.setForeground(Qt::blue); + ImportStyle.setForeground(Qt::darkYellow); + QuoteStyle.setForeground(Qt::darkMagenta); + CommentStyle.setForeground(Qt::darkCyan); + ErrorStyle.setForeground(Qt::red); } void Highlighter::highlightBlock(const QString &text) { + if ( mode == NORMAL_MODE) { + state_e state = (state_e) previousBlockState(); + //Key words and Primitives + QStringList::iterator it; + + for (it = KeyWords.begin(); it != KeyWords.end(); ++it){ + for (int i = 0; i < text.count(*it); ++i){ + setFormat(text.indexOf(*it),it->size(),KeyWordStyle); + } + } + for (it = Primitives3D.begin(); it != Primitives3D.end(); ++it){ + for (int i = 0; i < text.count(*it); ++i){ + setFormat(text.indexOf(*it),it->size(),PrimitiveStyle3D); + } + } + for (it = Primitives2D.begin(); it != Primitives2D.end(); ++it){ + for (int i = 0; i < text.count(*it); ++i){ + setFormat(text.indexOf(*it),it->size(),PrimitiveStyle2D); + } + } + for (it = Transforms.begin(); it != Transforms.end(); ++it){ + for (int i = 0; i < text.count(*it); ++i){ + setFormat(text.indexOf(*it),it->size(),TransformStyle); + } + } + for (it = Imports.begin(); it != Imports.end(); ++it){ + for (int i = 0; i < text.count(*it); ++i){ + setFormat(text.indexOf(*it),it->size(),ImportStyle); + } + } + + // Quoting and Comments. + for (int n = 0; n < text.size(); ++n){ + if (state == NORMAL){ + if (text[n] == '"'){ + state = QUOTE; + setFormat(n,1,QuoteStyle); + } else if (text[n] == '/'){ + if (text[n+1] == '/'){ + setFormat(n,text.size(),CommentStyle); + break; + } else if (text[n+1] == '*'){ + setFormat(n++,2,CommentStyle); + state = COMMENT; + } + } + } else if (state == QUOTE){ + setFormat(n,1,QuoteStyle); + if (text[n] == '"' && text[n-1] != '\\') + state = NORMAL; + } else if (state == COMMENT){ + setFormat(n,1,CommentStyle); + if (text[n] == '*' && text[n+1] == '/'){ + setFormat(++n,1,CommentStyle); + state = NORMAL; + } + } + } + + } // not ErrorMode (syntax highlighting) + + + // Errors + else if (mode == ERROR_MODE) { int n = previousBlockState(); if (n < 0) n = 0; @@ -49,5 +136,6 @@ void Highlighter::highlightBlock(const QString &text) setFormat(parser_error_pos - n, 1, style); #endif } + } // if errormode } diff --git a/src/highlighter.h b/src/highlighter.h index 2eead6d..a6e2dc3 100644 --- a/src/highlighter.h +++ b/src/highlighter.h @@ -6,7 +6,26 @@ class Highlighter : public QSyntaxHighlighter { public: - Highlighter(QTextDocument *parent); + enum state_e {NORMAL=-1,QUOTE,COMMENT}; + enum mode_e {NORMAL_MODE, ERROR_MODE}; + mode_e mode; + + QStringList operators; + QStringList KeyWords; + QStringList Primitives3D; + QStringList Primitives2D; + QStringList Transforms; + QStringList Imports; + QTextCharFormat ErrorStyle; + QTextCharFormat OperatorStyle; + QTextCharFormat CommentStyle; + QTextCharFormat QuoteStyle; + QTextCharFormat KeyWordStyle; + QTextCharFormat PrimitiveStyle3D; + QTextCharFormat PrimitiveStyle2D; + QTextCharFormat TransformStyle; + QTextCharFormat ImportStyle; + Highlighter(QTextDocument *parent, mode_e mode); void highlightBlock(const QString &text); }; diff --git a/src/mainwin.cc b/src/mainwin.cc index 72254a3..af4a532 100644 --- a/src/mainwin.cc +++ b/src/mainwin.cc @@ -180,7 +180,7 @@ MainWindow::MainWindow(const QString &filename) fps = 0; fsteps = 1; - highlighter = NULL; + highlighter = new Highlighter(editor->document(), Highlighter::NORMAL_MODE); editor->setTabStopWidth(30); editor->setLineWrapping(true); // Not designable @@ -1036,18 +1036,22 @@ bool MainWindow::compileTopLevelDocument(bool reload) QFileInfo(this->fileName).absolutePath().toLocal8Bit(), false); - // Error highlighting - delete this->highlighter; - this->highlighter = NULL; + // Syntax & Error highlighting if (!this->root_module) { - this->highlighter = new Highlighter(editor->document()); + if (highlighter->mode==Highlighter::NORMAL_MODE) { + delete this->highlighter; + highlighter = new Highlighter(editor->document(), Highlighter::ERROR_MODE); + } if (!animate_panel->isVisible()) { QTextCursor cursor = editor->textCursor(); cursor.setPosition(parser_error_pos); editor->setTextCursor(cursor); } + } else if (highlighter->mode==Highlighter::ERROR_MODE) { + delete this->highlighter; + this->highlighter = new Highlighter(editor->document(), Highlighter::NORMAL_MODE); } } -- cgit v0.10.1 From cd152aaefcc8d8e118be4249291863182711cc45 Mon Sep 17 00:00:00 2001 From: don bright Date: Tue, 8 Jan 2013 21:35:36 -0600 Subject: add to acknowledgements diff --git a/src/AboutDialog.html b/src/AboutDialog.html index 371ea46..bb48f6c 100644 --- a/src/AboutDialog.html +++ b/src/AboutDialog.html @@ -109,12 +109,12 @@ Please visit this link for a copy of the license: Marius Kintel <marius@kintel.net> and Clifford Wolf <clifford@clifford.at> +Copyright (C) 2009-2013 Marius Kintel <marius@kintel.net> and Clifford Wolf <clifford@clifford.at>

    @@ -105,7 +105,7 @@ Please visit this link for a copy of the license: 0: + if user_name is None: + # Read username if not specified or loaded from svn config, or on + # subsequent tries. + sys.stdout.write('Please enter your googlecode.com username: ') + sys.stdout.flush() + user_name = sys.stdin.readline().rstrip() + if password is None: + # Read password if not loaded from svn config, or on subsequent tries. + print 'Please enter your googlecode.com password.' + print '** Note that this is NOT your Gmail account password! **' + print 'It is the password you use to access Subversion repositories,' + print 'and can be found here: http://code.google.com/hosting/settings' + password = getpass.getpass() + + status, reason, url = upload(file_path, project_name, user_name, password, + summary, labels) + # Returns 403 Forbidden instead of 401 Unauthorized for bad + # credentials as of 2007-07-17. + if status in [httplib.FORBIDDEN, httplib.UNAUTHORIZED]: + # Rest for another try. + user_name = password = None + tries = tries - 1 + else: + # We're done. + break + + return status, reason, url + + +def main(): + parser = optparse.OptionParser(usage='googlecode-upload.py -s SUMMARY ' + '-p PROJECT [options] FILE') + parser.add_option('-s', '--summary', dest='summary', + help='Short description of the file') + parser.add_option('-p', '--project', dest='project', + help='Google Code project name') + parser.add_option('-u', '--user', dest='user', + help='Your Google Code username') + parser.add_option('-w', '--password', dest='password', + help='Your Google Code password') + parser.add_option('-l', '--labels', dest='labels', + help='An optional list of comma-separated labels to attach ' + 'to the file') + + options, args = parser.parse_args() + + if not options.summary: + parser.error('File summary is missing.') + elif not options.project: + parser.error('Project name is missing.') + elif len(args) < 1: + parser.error('File to upload not provided.') + elif len(args) > 1: + parser.error('Only one file may be specified.') + + file_path = args[0] + + if options.labels: + labels = options.labels.split(',') + else: + labels = None + + status, reason, url = upload_find_auth(file_path, options.project, + options.summary, labels, + options.user, options.password) + if url: + print 'The file was uploaded successfully.' + print 'URL: %s' % url + return 0 + else: + print 'An error occurred. Your file was not uploaded.' + print 'Google Code upload server said: %s (%s)' % (reason, status) + return 1 + + +if __name__ == '__main__': + sys.exit(main()) -- cgit v0.10.1 From 8d23b5b07b0fcc9a2c75db85954bb32dc57fc6e9 Mon Sep 17 00:00:00 2001 From: don bright Date: Wed, 9 Jan 2013 19:56:56 -0600 Subject: dont crash if there's no .netrc file. add security notice. discourage .netrc use. diff --git a/scripts/googlecode_upload.py b/scripts/googlecode_upload.py index 5e25feb..375d7aa 100644 --- a/scripts/googlecode_upload.py +++ b/scripts/googlecode_upload.py @@ -4,27 +4,35 @@ # OpenSCAD Usage: # # 1. get a google account, get it added to the Google Code OpenSCAD project -# 2. go to https://code.google.com/hosting/settings to find your password +# 2. go to https://code.google.com/hosting/settings for username & password # ----- # # security note - # -# dont use the ~/.netrc file to store your password -# keep your password secret +# it's not advisable to use a ~/.netrc file to store your password +# keep your googlecode password secret # only upload from a secure machine # user's personal data can be at risk if your account -# is compromised and a fake openscad were to be uploaded -# +# is compromised and a fake openscad were to be uploaded. +# notify the OpenSCAD maintainer if your computer is stolen or +# your google account is ever compromised. # ----- # 4. if you are making a Stable Release, check 'docs/release_checklist.txt' # 5. create an OpenSCAD package (linux dev snapshot: ./scripts/release-common.sh) # 6. Run this to do the upload: # export SUMMARY="Linux x86-64 Snapshot" # replace as appropriate # export PACKAGEFILE=openscad-2013.01.10.x86-64.tar.gz # replace as appropriate -# python ./scripts/googlecode_upload.py -s $SUMMARY -p openscad $PACKAGEFILE -# 7. Wait.... (there is no progress meter). It should say 'success' eventually. +# python ./scripts/googlecode_upload.py -s '$SUMMARY' -p openscad $PACKAGEFILE +# 7. It will ask for username. Use user.name@gmail.com (include the @ mail address) +# 8. It will ask for password. Copy/paste the password from the https google code settings page above +# Don't use the big bold password, use the 'plain font' password from the 'machine' line +# 9. Wait.... (there is no progress meter). It should say 'success' eventually. # -# The rest of this file is original from Google. +# The rest of this file is original from Google with slight modifications by the +# OpenSCAD team. Modifications licensed under the same license as the +# original code from google - the Apache Software License 2.0: +# http://www.apache.org/licenses/LICENSE-2.0 + # # Copyright 2006, 2007 Google Inc. All Rights Reserved. @@ -196,7 +204,11 @@ def upload_find_auth(file_path, project_name, summary, labels=None, """ if user_name is None or password is None: from netrc import netrc - authenticators = netrc().authenticators("code.google.com") + authenticators = None + try: + authenticators = netrc().authenticators("code.google.com") + except: + print "Error accessing netrc authenticator. Trying alternate method" if authenticators: if user_name is None: user_name = authenticators[0] -- cgit v0.10.1 From 51d8350113ece0d80ae92aeec1d9f99ac5021b65 Mon Sep 17 00:00:00 2001 From: Marius Kintel Date: Fri, 11 Jan 2013 15:43:09 -0500 Subject: Added hashbang diff --git a/scripts/googlecode_upload.py b/scripts/googlecode_upload.py old mode 100644 new mode 100755 index 375d7aa..188dd6c --- a/scripts/googlecode_upload.py +++ b/scripts/googlecode_upload.py @@ -1,3 +1,4 @@ +#!/usr/bin/env python # Google Code binary package uploader # with Insturctions for uploading packages for OpenSCAD # -- cgit v0.10.1 From 3b7bc56bdeba2401f88afd46d3969bcc543796fd Mon Sep 17 00:00:00 2001 From: don bright Date: Sat, 12 Jan 2013 14:05:10 -0600 Subject: rewrite large bit of syntax highlighter, add 'manual' test instructions diff --git a/src/highlighter.cc b/src/highlighter.cc index 6e51ecc..121d751 100644 --- a/src/highlighter.cc +++ b/src/highlighter.cc @@ -24,118 +24,174 @@ * */ -// Syntax Highlight code by Chris Olah +// based on Syntax Highlight code by Chris Olah + +/* test suite + +1. action: open example001, remove first {, hit f5 + expected result: red highlight appears on last }, cursor moves there + action: replace first {, hit f5 + expected result: red highlight disappears + +2. action: type a=b + expected result: '=' is highlighted as appropriate + +3. action: open example001, put '===' after first ; + expected result: red highlight appears in === + action: remove '===' + expected result: red highlight disappears + +4. action: open example001, remove last ';' but not trailing whitespace/\n + expected result: red highlight appears on last line + action: replace last ';' + expected result: red highlight disappears + +5. action: open file, type in a multi-line comment + expected result: multiline comment should be highlighted appropriately + +6. action: open example001, put a single '=' after first { + expected result: red highlight of '=' you added + +*/ #include "highlighter.h" -#include "parsersettings.h" // extern int parser_error_pos; +#include -Highlighter::Highlighter(QTextDocument *parent, mode_e mode) +#include +Highlighter::Highlighter(QTextDocument *parent) : QSyntaxHighlighter(parent) { - this->mode = mode; - operators << "!" << "&&" << "||" << "+" << "-" << "*" << "/" << "%" << "!" << "#" << ";"; - KeyWords << "for" << "intersection_for" << "if" << "assign" - << "module" << "function" - << "$children" << "child" << "$fn" << "$fa" << "$fb" // Lump special variables in here - << "union" << "intersection" << "difference" << "render"; //Lump CSG in here - Primitives3D << "cube" << "cylinder" << "sphere" << "polyhedron"; - Primitives2D << "square" << "polygon" << "circle"; - Transforms << "scale" << "translate" << "rotate" << "multmatrix" << "color" - << "linear_extrude" << "rotate_extrude"; // Lump extrudes in here. - Imports << "include" << "use" << "import_stl"; - - //this->OperatorStyle.setForeground - KeyWordStyle.setForeground(Qt::darkGreen); - TransformStyle.setForeground(Qt::darkGreen); - PrimitiveStyle3D.setForeground(Qt::darkBlue); - PrimitiveStyle2D.setForeground(Qt::blue); - ImportStyle.setForeground(Qt::darkYellow); - QuoteStyle.setForeground(Qt::darkMagenta); - CommentStyle.setForeground(Qt::darkCyan); - ErrorStyle.setForeground(Qt::red); + QMap tokentypes; + QMap typeformats; + + tokentypes["operator"] << "=" << "!" << "&&" << "||" << "+" << "-" << "*" << "/" << "%" << "!" << "#" << ";"; + typeformats["operator"].setForeground(Qt::blue); + + tokentypes["keyword"] << "for" << "intersection_for" << "if" << "assign" << "module" << "function"; + typeformats["keyword"].setForeground(Qt::darkGreen); + + tokentypes["prim3d"] << "cube" << "cylinder" << "sphere" << "polyhedron"; + typeformats["prim3d"].setForeground(Qt::darkBlue); + + tokentypes["prim2d"] << "square" << "polygon" << "circle"; + typeformats["prim2d"].setForeground(Qt::blue); + + tokentypes["transform"] << "scale" << "translate" << "rotate" << "multmatrix" << "color" << "projection"; + typeformats["transform"].setForeground(Qt::darkGreen); + + tokentypes["import"] << "include" << "use" << "import_stl"; + typeformats["import"].setForeground(Qt::darkYellow); + + tokentypes["special"] << "$children" << "child" << "$fn" << "$fa" << "$fb"; + typeformats["special"].setForeground(Qt::darkGreen); + + tokentypes["csgop"] << "union" << "intersection" << "difference" << "render"; + typeformats["csgop"].setForeground(Qt::darkGreen); + + tokentypes["extrude"] << "linear_extrude" << "rotate_extrude"; + typeformats["extrude"].setForeground(Qt::darkGreen); + + // for speed - put all tokens into single QHash, mapped to their format + QList::iterator ki; + QList toktypes = tokentypes.keys(); + for ( ki=toktypes.begin(); ki!=toktypes.end(); ++ki ) { + QString toktype = *ki; + QStringList::iterator it; + for ( it = tokentypes[toktype].begin(); it < tokentypes[toktype].end(); ++it) { + QString token = *it; + //std::cout << token.toStdString() << "\n"; + formatMap[ token ] = typeformats [ toktype ]; + } + } + + quoteFormat.setForeground(Qt::darkMagenta); + commentFormat.setForeground(Qt::darkCyan); + errorFormat.setBackground(Qt::red); + + // format tweaks + formatMap[ "%" ].setFontWeight(QFont::Bold); + + separators << tokentypes["operator"]; + separators << "(" << ")" << "[" << "]"; + + lastErrorBlock = parent->begin(); +} + +void Highlighter::highlightError(int error_pos) +{ + QTextBlock err_block = document()->findBlock(error_pos); + std::cout << "error pos: " << error_pos << " doc len: " << document()->characterCount() << "\n"; + errorPos = error_pos; + errorState = true; + //if (errorPos == document()->characterCount()-1) errorPos--; + rehighlightBlock( err_block ); // QT 4.6 + errorState = false; + lastErrorBlock = err_block; +} + +void Highlighter::unhighlightLastError() +{ + rehighlightBlock( lastErrorBlock ); } +#include void Highlighter::highlightBlock(const QString &text) { - if ( mode == NORMAL_MODE) { - state_e state = (state_e) previousBlockState(); - //Key words and Primitives - QStringList::iterator it; + std::cout << "block[" << currentBlock().position() << ":" + << currentBlock().length() + currentBlock().position() << "]" + << ", err:" << errorPos << ", text:'" << text.toStdString() << "'\n"; - for (it = KeyWords.begin(); it != KeyWords.end(); ++it){ - for (int i = 0; i < text.count(*it); ++i){ - setFormat(text.indexOf(*it),it->size(),KeyWordStyle); - } + // Split the block into pieces and highlight each as appropriate + QString newtext = text; + QStringList::iterator sep, token; + int tokindex = -1; // deals w duplicate tokens in a single block + for ( sep = separators.begin(); sep!=separators.end(); ++sep ) { + // so a=b will have '=' highlighted + newtext = newtext.replace( *sep, " " + *sep + " "); } - for (it = Primitives3D.begin(); it != Primitives3D.end(); ++it){ - for (int i = 0; i < text.count(*it); ++i){ - setFormat(text.indexOf(*it),it->size(),PrimitiveStyle3D); - } - } - for (it = Primitives2D.begin(); it != Primitives2D.end(); ++it){ - for (int i = 0; i < text.count(*it); ++i){ - setFormat(text.indexOf(*it),it->size(),PrimitiveStyle2D); - } - } - for (it = Transforms.begin(); it != Transforms.end(); ++it){ - for (int i = 0; i < text.count(*it); ++i){ - setFormat(text.indexOf(*it),it->size(),TransformStyle); - } - } - for (it = Imports.begin(); it != Imports.end(); ++it){ - for (int i = 0; i < text.count(*it); ++i){ - setFormat(text.indexOf(*it),it->size(),ImportStyle); + QStringList tokens = newtext.split(QRegExp("\\s")); + for ( token = tokens.begin(); token!=tokens.end(); ++token ){ + if ( formatMap.contains( *token ) ) { + tokindex = text.indexOf( *token, tokindex+1 ); + // Speed note: setFormat() is the big slowdown in all of this code + setFormat( tokindex, token->size(), formatMap[ *token ]); + // std::cout << "found tok '" << (*token).toStdString() << "' at " << tokindex << "\n"; } } // Quoting and Comments. + // fixme multiline coments dont work + state_e state = (state_e) previousBlockState(); for (int n = 0; n < text.size(); ++n){ if (state == NORMAL){ if (text[n] == '"'){ state = QUOTE; - setFormat(n,1,QuoteStyle); + setFormat(n,1,quoteFormat); } else if (text[n] == '/'){ if (text[n+1] == '/'){ - setFormat(n,text.size(),CommentStyle); + setFormat(n,text.size(),commentFormat); break; } else if (text[n+1] == '*'){ - setFormat(n++,2,CommentStyle); + setFormat(n++,2,commentFormat); state = COMMENT; } } } else if (state == QUOTE){ - setFormat(n,1,QuoteStyle); + setFormat(n,1,quoteFormat); if (text[n] == '"' && text[n-1] != '\\') state = NORMAL; } else if (state == COMMENT){ - setFormat(n,1,CommentStyle); + setFormat(n,1,commentFormat); if (text[n] == '*' && text[n+1] == '/'){ - setFormat(++n,1,CommentStyle); + setFormat(++n,1,commentFormat); state = NORMAL; } } } - } // not ErrorMode (syntax highlighting) - - - // Errors - else if (mode == ERROR_MODE) { - int n = previousBlockState(); - if (n < 0) - n = 0; - int k = n + text.size() + 1; - setCurrentBlockState(k); - if (parser_error_pos >= n && parser_error_pos < k) { - QTextCharFormat style; - style.setBackground(Qt::red); - setFormat(0, text.size(), style); -#if 0 - style.setBackground(Qt::black); - style.setForeground(Qt::white); - setFormat(parser_error_pos - n, 1, style); -#endif + // Highlight an error. Do it last to 'overwrite' other formatting. + if (errorState) { + setFormat( errorPos - currentBlock().position() - 1, 1, errorFormat); } - } // if errormode } diff --git a/src/highlighter.h b/src/highlighter.h index a6e2dc3..043c34e 100644 --- a/src/highlighter.h +++ b/src/highlighter.h @@ -7,26 +7,17 @@ class Highlighter : public QSyntaxHighlighter { public: enum state_e {NORMAL=-1,QUOTE,COMMENT}; - enum mode_e {NORMAL_MODE, ERROR_MODE}; - mode_e mode; - - QStringList operators; - QStringList KeyWords; - QStringList Primitives3D; - QStringList Primitives2D; - QStringList Transforms; - QStringList Imports; - QTextCharFormat ErrorStyle; - QTextCharFormat OperatorStyle; - QTextCharFormat CommentStyle; - QTextCharFormat QuoteStyle; - QTextCharFormat KeyWordStyle; - QTextCharFormat PrimitiveStyle3D; - QTextCharFormat PrimitiveStyle2D; - QTextCharFormat TransformStyle; - QTextCharFormat ImportStyle; - Highlighter(QTextDocument *parent, mode_e mode); + QHash formatMap; + QTextCharFormat errorFormat, commentFormat, quoteFormat; + Highlighter(QTextDocument *parent); void highlightBlock(const QString &text); + void highlightError(int error_pos); + void unhighlightLastError(); +private: + QTextBlock lastErrorBlock; + int errorPos = -1; + bool errorState = false; + QStringList separators; }; #endif diff --git a/src/mainwin.cc b/src/mainwin.cc index af4a532..644cc2e 100644 --- a/src/mainwin.cc +++ b/src/mainwin.cc @@ -180,7 +180,7 @@ MainWindow::MainWindow(const QString &filename) fps = 0; fsteps = 1; - highlighter = new Highlighter(editor->document(), Highlighter::NORMAL_MODE); + highlighter = new Highlighter(editor->document()); editor->setTabStopWidth(30); editor->setLineWrapping(true); // Not designable @@ -1036,22 +1036,15 @@ bool MainWindow::compileTopLevelDocument(bool reload) QFileInfo(this->fileName).absolutePath().toLocal8Bit(), false); - // Syntax & Error highlighting - - if (!this->root_module) { - if (highlighter->mode==Highlighter::NORMAL_MODE) { - delete this->highlighter; - highlighter = new Highlighter(editor->document(), Highlighter::ERROR_MODE); - } - - if (!animate_panel->isVisible()) { + if (!animate_panel->isVisible()) { + if (!this->root_module) { QTextCursor cursor = editor->textCursor(); - cursor.setPosition(parser_error_pos); - editor->setTextCursor(cursor); + cursor.setPosition( parser_error_pos ); + editor->setTextCursor( cursor ); + highlighter->highlightError( parser_error_pos ); + } else { + highlighter->unhighlightLastError(); } - } else if (highlighter->mode==Highlighter::ERROR_MODE) { - delete this->highlighter; - this->highlighter = new Highlighter(editor->document(), Highlighter::NORMAL_MODE); } } -- cgit v0.10.1 From 2c6d69645ff1391683ae6ffde8bd305277e17914 Mon Sep 17 00:00:00 2001 From: don bright Date: Sat, 12 Jan 2013 16:11:19 -0600 Subject: now passes all tests in 'manual test suite' diff --git a/src/highlighter.cc b/src/highlighter.cc index 121d751..7f6b5f9 100644 --- a/src/highlighter.cc +++ b/src/highlighter.cc @@ -24,33 +24,78 @@ * */ -// based on Syntax Highlight code by Chris Olah +/* + Syntax Highlighter for OpenSCAD + based on Syntax Highlight code by Christopher Olah + + Speed Note: setFormat() is very slow, making 'full re-highlight' impractical. + Thus QT only updates 'blocks' (usually lines). -/* test suite + Test suite: 1. action: open example001, remove first {, hit f5 - expected result: red highlight appears on last }, cursor moves there + expected result: error highlight appears on last }, cursor moves there action: replace first {, hit f5 - expected result: red highlight disappears + expected result: error highlight disappears + +1a. action: open example001, remove first {, hit f5 + expected result: error highlight appears on last }, cursor moves there + action: replace first { with the letter 'P', hit f5 + expected result: error highlight on last } disappears, appears on elsewhere + action: replace first {, hit f5 + expected result: error highlight disappears + +2. action: type a=b into any file + expected result: '=' is highlighted with its appropriate format -2. action: type a=b - expected result: '=' is highlighted as appropriate +2a. action: type a=b=c=d=e=f= into any file + expected result: each '=' is highlighted with its appropriate format -3. action: open example001, put '===' after first ; - expected result: red highlight appears in === +3. action: open example001, put '===' after first ; hit f5 + expected result: error highlight appears in === action: remove '===' - expected result: red highlight disappears + expected result: error highlight disappears + +3a. action: open example001, put '=' after first ; hit f5 + expected result: error highlight appears + action: remove '=' + expected result: error highlight disappears + +3b. action: open example001, put '=' after first { + expected result: error highlight appears + action: remove '=' + expected result: error highlight disappears + +3c. action: open example001, replace first { with '=' + expected result: error highlight appears + action: remove '=', replace with { + expected result: error highlight disappears 4. action: open example001, remove last ';' but not trailing whitespace/\n - expected result: red highlight appears on last line + expected result: error highlight appears somewhere near end action: replace last ';' - expected result: red highlight disappears + expected result: error highlight disappears 5. action: open file, type in a multi-line comment expected result: multiline comment should be highlighted appropriately 6. action: open example001, put a single '=' after first { - expected result: red highlight of '=' you added + expected result: error highlight of '=' you added + +7. action: open example001, remove first ')' + expected result: highlight should appear appropriately + +8. action: create a large file (50,000 lines). eg at a bash prompt: + for i in {1..1000}; do cat examples/example001.scad >> test5k.scad ; done + action: open file in openscad + expected result: there should not be a slowdown due to highlighting + action: scroll to bottom, put '=' after last ; + expected result: there should be a highlight, and a report of syntax error + action: comment out the highlighter code from mainwin.cc, recompile, put '=' after last ; + expected result: there should be almost no difference in speed + +9. action: open any file, and hold down 'f5' key to repeatedly reparse + expected result: no crashing! */ @@ -61,9 +106,6 @@ Highlighter::Highlighter(QTextDocument *parent) : QSyntaxHighlighter(parent) { - QMap tokentypes; - QMap typeformats; - tokentypes["operator"] << "=" << "!" << "&&" << "||" << "+" << "-" << "*" << "/" << "%" << "!" << "#" << ";"; typeformats["operator"].setForeground(Qt::blue); @@ -111,19 +153,32 @@ Highlighter::Highlighter(QTextDocument *parent) // format tweaks formatMap[ "%" ].setFontWeight(QFont::Bold); - separators << tokentypes["operator"]; - separators << "(" << ")" << "[" << "]"; - lastErrorBlock = parent->begin(); } void Highlighter::highlightError(int error_pos) { QTextBlock err_block = document()->findBlock(error_pos); - std::cout << "error pos: " << error_pos << " doc len: " << document()->characterCount() << "\n"; + //std::cout << "error pos: " << error_pos << " doc len: " << document()->characterCount() << "\n"; errorPos = error_pos; errorState = true; - //if (errorPos == document()->characterCount()-1) errorPos--; + + while (err_block.text().remove(QRegExp("\\s+")).size()==0) { + //std::cout << "special case - errors at end of file w whitespace\n"; + err_block = err_block.previous(); + errorPos = err_block.position()+err_block.length() - 2; + } + if ( errorPos == document()->characterCount()-1 ) { + errorPos--; + } + + int block_last_pos = err_block.position() + err_block.length() - 1; + if ( errorPos == block_last_pos ) { + errorPos--; + //std::cout << "special case - errors at ends of certain blocks\n"; + } + err_block = document()->findBlock(errorPos); + rehighlightBlock( err_block ); // QT 4.6 errorState = false; lastErrorBlock = err_block; @@ -131,36 +186,38 @@ void Highlighter::highlightError(int error_pos) void Highlighter::unhighlightLastError() { - rehighlightBlock( lastErrorBlock ); + rehighlightBlock( lastErrorBlock ); // QT 4.6 } #include void Highlighter::highlightBlock(const QString &text) { - std::cout << "block[" << currentBlock().position() << ":" - << currentBlock().length() + currentBlock().position() << "]" - << ", err:" << errorPos << ", text:'" << text.toStdString() << "'\n"; + int block_first_pos = currentBlock().position(); + int block_last_pos = block_first_pos + currentBlock().length() - 1; + //std::cout << "block[" << block_first_pos << ":" << block_last_pos << "]" + // << ", err:" << errorPos << "," << errorState + // << ", text:'" << text.toStdString() << "'\n"; // Split the block into pieces and highlight each as appropriate QString newtext = text; - QStringList::iterator sep, token; - int tokindex = -1; // deals w duplicate tokens in a single block - for ( sep = separators.begin(); sep!=separators.end(); ++sep ) { - // so a=b will have '=' highlighted - newtext = newtext.replace( *sep, " " + *sep + " "); + QStringList splitHelpers; + QStringList::iterator sh, token; + int tokindex = -1; // tokindex helps w duplicate tokens in a single block + splitHelpers << tokentypes["operator"] << "(" << ")" << "[" << "]"; + for ( sh = splitHelpers.begin(); sh!=splitHelpers.end(); ++sh ) { + // so "a+b" is treated as "a + b" and formatted + newtext = newtext.replace( *sh, " " + *sh + " "); } QStringList tokens = newtext.split(QRegExp("\\s")); for ( token = tokens.begin(); token!=tokens.end(); ++token ){ if ( formatMap.contains( *token ) ) { tokindex = text.indexOf( *token, tokindex+1 ); - // Speed note: setFormat() is the big slowdown in all of this code setFormat( tokindex, token->size(), formatMap[ *token ]); // std::cout << "found tok '" << (*token).toStdString() << "' at " << tokindex << "\n"; } } // Quoting and Comments. - // fixme multiline coments dont work state_e state = (state_e) previousBlockState(); for (int n = 0; n < text.size(); ++n){ if (state == NORMAL){ @@ -188,10 +245,12 @@ void Highlighter::highlightBlock(const QString &text) } } } + setCurrentBlockState((int) state); // Highlight an error. Do it last to 'overwrite' other formatting. if (errorState) { - setFormat( errorPos - currentBlock().position() - 1, 1, errorFormat); + setFormat( errorPos - block_first_pos, 1, errorFormat); } + } diff --git a/src/highlighter.h b/src/highlighter.h index 043c34e..a0ed0da 100644 --- a/src/highlighter.h +++ b/src/highlighter.h @@ -17,7 +17,8 @@ private: QTextBlock lastErrorBlock; int errorPos = -1; bool errorState = false; - QStringList separators; + QMap tokentypes; + QMap typeformats; }; #endif diff --git a/src/mainwin.cc b/src/mainwin.cc index 644cc2e..8834b75 100644 --- a/src/mainwin.cc +++ b/src/mainwin.cc @@ -1038,6 +1038,7 @@ bool MainWindow::compileTopLevelDocument(bool reload) if (!animate_panel->isVisible()) { if (!this->root_module) { + highlighter->unhighlightLastError(); QTextCursor cursor = editor->textCursor(); cursor.setPosition( parser_error_pos ); editor->setTextCursor( cursor ); @@ -1046,6 +1047,7 @@ bool MainWindow::compileTopLevelDocument(bool reload) highlighter->unhighlightLastError(); } } + } bool changed = shouldcompiletoplevel; -- cgit v0.10.1 From 8f986a339925f523e5bf19addce6c6e8bf8c9ec3 Mon Sep 17 00:00:00 2001 From: don bright Date: Sat, 12 Jan 2013 16:36:07 -0600 Subject: make it work on Qt less than 4.6 diff --git a/src/highlighter.cc b/src/highlighter.cc index 7f6b5f9..45ba7f0 100644 --- a/src/highlighter.cc +++ b/src/highlighter.cc @@ -28,8 +28,13 @@ Syntax Highlighter for OpenSCAD based on Syntax Highlight code by Christopher Olah - Speed Note: setFormat() is very slow, making 'full re-highlight' impractical. - Thus QT only updates 'blocks' (usually lines). + Speed Note: + + setFormat() is very slow. normally this doesnt matter because we + only highlight a block or two at once. But when OpenSCAD first starts, + QT automatigically calls 'highlightBlock' on every single textblock in the file + even if it's not visible in the window. On a large file (50,000 lines) this + can take several seconds. Test suite: @@ -101,8 +106,8 @@ #include "highlighter.h" #include +#include -#include Highlighter::Highlighter(QTextDocument *parent) : QSyntaxHighlighter(parent) { @@ -133,7 +138,7 @@ Highlighter::Highlighter(QTextDocument *parent) tokentypes["extrude"] << "linear_extrude" << "rotate_extrude"; typeformats["extrude"].setForeground(Qt::darkGreen); - // for speed - put all tokens into single QHash, mapped to their format + // Put all tokens into single QHash, mapped to their format QList::iterator ki; QList toktypes = tokentypes.keys(); for ( ki=toktypes.begin(); ki!=toktypes.end(); ++ki ) { @@ -174,22 +179,31 @@ void Highlighter::highlightError(int error_pos) int block_last_pos = err_block.position() + err_block.length() - 1; if ( errorPos == block_last_pos ) { - errorPos--; //std::cout << "special case - errors at ends of certain blocks\n"; + errorPos--; } err_block = document()->findBlock(errorPos); - rehighlightBlock( err_block ); // QT 4.6 + portable_rehighlightBlock( err_block ); + errorState = false; lastErrorBlock = err_block; } void Highlighter::unhighlightLastError() { - rehighlightBlock( lastErrorBlock ); // QT 4.6 + portable_rehighlightBlock( lastErrorBlock ); +} + +void Highlighter::portable_rehighlightBlock( const QTextBlock &block ) +{ +#if (QT_VERSION >= QT_VERSION_CHECK(4, 6, 0)) + rehighlightBlock( block ); +#else + rehighlight(); // slow on big files +#endif } -#include void Highlighter::highlightBlock(const QString &text) { int block_first_pos = currentBlock().position(); diff --git a/src/highlighter.h b/src/highlighter.h index a0ed0da..322ba2d 100644 --- a/src/highlighter.h +++ b/src/highlighter.h @@ -19,6 +19,7 @@ private: bool errorState = false; QMap tokentypes; QMap typeformats; + void portable_rehighlightBlock( const QTextBlock &text ); }; #endif -- cgit v0.10.1 From 1d9d3ef8044bb12036dbd8f363e14a60eeee3409 Mon Sep 17 00:00:00 2001 From: don bright Date: Sat, 12 Jan 2013 16:39:45 -0600 Subject: oops % should not be bold diff --git a/src/highlighter.cc b/src/highlighter.cc index 45ba7f0..a636827 100644 --- a/src/highlighter.cc +++ b/src/highlighter.cc @@ -155,9 +155,6 @@ Highlighter::Highlighter(QTextDocument *parent) commentFormat.setForeground(Qt::darkCyan); errorFormat.setBackground(Qt::red); - // format tweaks - formatMap[ "%" ].setFontWeight(QFont::Bold); - lastErrorBlock = parent->begin(); } @@ -216,13 +213,13 @@ void Highlighter::highlightBlock(const QString &text) QString newtext = text; QStringList splitHelpers; QStringList::iterator sh, token; - int tokindex = -1; // tokindex helps w duplicate tokens in a single block + // splitHelpers - so "a+b" is treated as "a + b" and formatted splitHelpers << tokentypes["operator"] << "(" << ")" << "[" << "]"; for ( sh = splitHelpers.begin(); sh!=splitHelpers.end(); ++sh ) { - // so "a+b" is treated as "a + b" and formatted newtext = newtext.replace( *sh, " " + *sh + " "); } QStringList tokens = newtext.split(QRegExp("\\s")); + int tokindex = -1; // tokindex helps w duplicate tokens in a single block for ( token = tokens.begin(); token!=tokens.end(); ++token ){ if ( formatMap.contains( *token ) ) { tokindex = text.indexOf( *token, tokindex+1 ); -- cgit v0.10.1 From 3ff8ca36b5bbb57b4039d8f6372d52d2b6ab0eaf Mon Sep 17 00:00:00 2001 From: don bright Date: Sat, 12 Jan 2013 16:48:19 -0600 Subject: note about speed on qt < 4.6 diff --git a/src/highlighter.cc b/src/highlighter.cc index a636827..ab0a071 100644 --- a/src/highlighter.cc +++ b/src/highlighter.cc @@ -36,6 +36,11 @@ even if it's not visible in the window. On a large file (50,000 lines) this can take several seconds. + Also, QT 4.5 and lower do not have rehighlightBlock(), so they will be slow + on large files as well, as they re-highlight everything after each compile. + + The vast majority of OpenSCAD files, however, are not 50,000 lines + Test suite: 1. action: open example001, remove first {, hit f5 -- cgit v0.10.1 From f4f06d48d852437ee0d70b7541c9b8a1893d9624 Mon Sep 17 00:00:00 2001 From: don bright Date: Sun, 13 Jan 2013 00:01:24 +0100 Subject: fix for gcc. simplify mainwin.cc a bit. diff --git a/src/highlighter.cc b/src/highlighter.cc index ab0a071..98eff8c 100644 --- a/src/highlighter.cc +++ b/src/highlighter.cc @@ -160,6 +160,8 @@ Highlighter::Highlighter(QTextDocument *parent) commentFormat.setForeground(Qt::darkCyan); errorFormat.setBackground(Qt::red); + errorState = false; + errorPos = -1; lastErrorBlock = parent->begin(); } @@ -209,7 +211,7 @@ void Highlighter::portable_rehighlightBlock( const QTextBlock &block ) void Highlighter::highlightBlock(const QString &text) { int block_first_pos = currentBlock().position(); - int block_last_pos = block_first_pos + currentBlock().length() - 1; + //int block_last_pos = block_first_pos + currentBlock().length() - 1; //std::cout << "block[" << block_first_pos << ":" << block_last_pos << "]" // << ", err:" << errorPos << "," << errorState // << ", text:'" << text.toStdString() << "'\n"; diff --git a/src/highlighter.h b/src/highlighter.h index 322ba2d..09bba39 100644 --- a/src/highlighter.h +++ b/src/highlighter.h @@ -15,8 +15,8 @@ public: void unhighlightLastError(); private: QTextBlock lastErrorBlock; - int errorPos = -1; - bool errorState = false; + int errorPos; + bool errorState; QMap tokentypes; QMap typeformats; void portable_rehighlightBlock( const QTextBlock &text ); diff --git a/src/mainwin.cc b/src/mainwin.cc index 8834b75..6bb43e6 100644 --- a/src/mainwin.cc +++ b/src/mainwin.cc @@ -1037,14 +1037,12 @@ bool MainWindow::compileTopLevelDocument(bool reload) false); if (!animate_panel->isVisible()) { + highlighter->unhighlightLastError(); if (!this->root_module) { - highlighter->unhighlightLastError(); QTextCursor cursor = editor->textCursor(); - cursor.setPosition( parser_error_pos ); - editor->setTextCursor( cursor ); + cursor.setPosition(parser_error_pos); + editor->setTextCursor(cursor); highlighter->highlightError( parser_error_pos ); - } else { - highlighter->unhighlightLastError(); } } -- cgit v0.10.1 From 987cd438f64b6b06cffe31a512584e55b41cad9d Mon Sep 17 00:00:00 2001 From: don bright Date: Sun, 13 Jan 2013 00:37:20 +0100 Subject: fix qt4.4, old gcc, and mention Giles' Rapcad higlighter diff --git a/src/highlighter.cc b/src/highlighter.cc index 98eff8c..a7592da 100644 --- a/src/highlighter.cc +++ b/src/highlighter.cc @@ -39,8 +39,13 @@ Also, QT 4.5 and lower do not have rehighlightBlock(), so they will be slow on large files as well, as they re-highlight everything after each compile. - The vast majority of OpenSCAD files, however, are not 50,000 lines + The vast majority of OpenSCAD files, however, are not 50,000 lines and + most machines ship with Qt > 4.5 + See Also: + + Giles Bathgate's Rapcad lexer-based highlighter: rapcad.org + Test suite: 1. action: open example001, remove first {, hit f5 @@ -177,7 +182,7 @@ void Highlighter::highlightError(int error_pos) err_block = err_block.previous(); errorPos = err_block.position()+err_block.length() - 2; } - if ( errorPos == document()->characterCount()-1 ) { + if ( errorPos == lastDocumentPos()-1 ) { errorPos--; } @@ -204,10 +209,22 @@ void Highlighter::portable_rehighlightBlock( const QTextBlock &block ) #if (QT_VERSION >= QT_VERSION_CHECK(4, 6, 0)) rehighlightBlock( block ); #else - rehighlight(); // slow on big files + rehighlight(); // slow on very large files #endif } +int Highlighter::lastDocumentPos() +{ +// fixme - test it +#if (QT_VERSION >= QT_VERSION_CHECK(4, 5, 0)) + return document()->characterCount(); +#else + QTextBlock lastblock = document()->lastBlock(); + return lastblock.position() + lastblock.length(); +#endif +} + + void Highlighter::highlightBlock(const QString &text) { int block_first_pos = currentBlock().position(); diff --git a/src/highlighter.h b/src/highlighter.h index 09bba39..428bbbb 100644 --- a/src/highlighter.h +++ b/src/highlighter.h @@ -2,6 +2,8 @@ #define HIGHLIGHTER_H_ #include +#include +#include class Highlighter : public QSyntaxHighlighter { @@ -17,8 +19,9 @@ private: QTextBlock lastErrorBlock; int errorPos; bool errorState; - QMap tokentypes; - QMap typeformats; + QMap tokentypes; + QMap typeformats; + int lastDocumentPos(); void portable_rehighlightBlock( const QTextBlock &text ); }; -- cgit v0.10.1 From 59910af66ae166f2afd9925cbef9c026fe47f6ae Mon Sep 17 00:00:00 2001 From: don bright Date: Sat, 12 Jan 2013 18:29:30 -0600 Subject: highlight numbers and brackets as well diff --git a/src/highlighter.cc b/src/highlighter.cc index a7592da..2d75b67 100644 --- a/src/highlighter.cc +++ b/src/highlighter.cc @@ -39,13 +39,13 @@ Also, QT 4.5 and lower do not have rehighlightBlock(), so they will be slow on large files as well, as they re-highlight everything after each compile. - The vast majority of OpenSCAD files, however, are not 50,000 lines and + The vast majority of OpenSCAD files, however, are not 50,000 lines and most machines ship with Qt > 4.5 See Also: Giles Bathgate's Rapcad lexer-based highlighter: rapcad.org - + Test suite: 1. action: open example001, remove first {, hit f5 @@ -117,6 +117,7 @@ #include "highlighter.h" #include #include +//#include Highlighter::Highlighter(QTextDocument *parent) : QSyntaxHighlighter(parent) @@ -148,6 +149,9 @@ Highlighter::Highlighter(QTextDocument *parent) tokentypes["extrude"] << "linear_extrude" << "rotate_extrude"; typeformats["extrude"].setForeground(Qt::darkGreen); + tokentypes["bracket"] << "[" << "]"; + typeformats["bracket"].setForeground(Qt::darkGreen); + // Put all tokens into single QHash, mapped to their format QList::iterator ki; QList toktypes = tokentypes.keys(); @@ -164,6 +168,7 @@ Highlighter::Highlighter(QTextDocument *parent) quoteFormat.setForeground(Qt::darkMagenta); commentFormat.setForeground(Qt::darkCyan); errorFormat.setBackground(Qt::red); + formatMap["number"].setForeground(Qt::red); errorState = false; errorPos = -1; @@ -172,10 +177,11 @@ Highlighter::Highlighter(QTextDocument *parent) void Highlighter::highlightError(int error_pos) { - QTextBlock err_block = document()->findBlock(error_pos); - //std::cout << "error pos: " << error_pos << " doc len: " << document()->characterCount() << "\n"; - errorPos = error_pos; errorState = true; + errorPos = error_pos; + + QTextBlock err_block = document()->findBlock( errorPos ); + //std::cout << "error pos: " << error_pos << " doc len: " << document()->characterCount() << "\n"; while (err_block.text().remove(QRegExp("\\s+")).size()==0) { //std::cout << "special case - errors at end of file w whitespace\n"; @@ -224,7 +230,6 @@ int Highlighter::lastDocumentPos() #endif } - void Highlighter::highlightBlock(const QString &text) { int block_first_pos = currentBlock().position(); @@ -237,18 +242,23 @@ void Highlighter::highlightBlock(const QString &text) QString newtext = text; QStringList splitHelpers; QStringList::iterator sh, token; - // splitHelpers - so "a+b" is treated as "a + b" and formatted - splitHelpers << tokentypes["operator"] << "(" << ")" << "[" << "]"; + // splitHelpers - so "[a+b]" is treated as "[ a + b ]" and formatted + splitHelpers << tokentypes["operator"] << "(" << ")" << "[" << "]" << ","; for ( sh = splitHelpers.begin(); sh!=splitHelpers.end(); ++sh ) { newtext = newtext.replace( *sh, " " + *sh + " "); } + //std::cout << "newtext: " << newtext.toStdString() << "\n"; QStringList tokens = newtext.split(QRegExp("\\s")); - int tokindex = -1; // tokindex helps w duplicate tokens in a single block + int tokindex = 0; // tokindex helps w duplicate tokens in a single block + bool numtest; for ( token = tokens.begin(); token!=tokens.end(); ++token ){ + tokindex = text.indexOf( *token, tokindex ); if ( formatMap.contains( *token ) ) { - tokindex = text.indexOf( *token, tokindex+1 ); setFormat( tokindex, token->size(), formatMap[ *token ]); - // std::cout << "found tok '" << (*token).toStdString() << "' at " << tokindex << "\n"; + //std::cout << "found tok '" << (*token).toStdString() << "' at " << tokindex << "\n"; + } else { + (*token).toDouble( &numtest ); + if ( numtest ) setFormat( tokindex, token->size(), formatMap["number"] ); } } -- cgit v0.10.1 From d61593979199c1c025df07a5a1db879cce165529 Mon Sep 17 00:00:00 2001 From: don bright Date: Sat, 12 Jan 2013 20:07:15 -0600 Subject: balance colors, fix bug in numbers, highlight more stuff diff --git a/src/highlighter.cc b/src/highlighter.cc index 2d75b67..58912f3 100644 --- a/src/highlighter.cc +++ b/src/highlighter.cc @@ -40,7 +40,7 @@ on large files as well, as they re-highlight everything after each compile. The vast majority of OpenSCAD files, however, are not 50,000 lines and - most machines ship with Qt > 4.5 + most machines have Qt > 4.5 See Also: @@ -112,11 +112,18 @@ 9. action: open any file, and hold down 'f5' key to repeatedly reparse expected result: no crashing! +10. action: for i in examples/ex* ; do ./openscad $i ; done + expected result: make sure the colors look harmonious + +11. action: type random string of [][][][]()()[][90,3904,00,000] + expected result: all should be highlighted correctly + */ #include "highlighter.h" #include #include +#include //#include Highlighter::Highlighter(QTextDocument *parent) @@ -125,34 +132,41 @@ Highlighter::Highlighter(QTextDocument *parent) tokentypes["operator"] << "=" << "!" << "&&" << "||" << "+" << "-" << "*" << "/" << "%" << "!" << "#" << ";"; typeformats["operator"].setForeground(Qt::blue); - tokentypes["keyword"] << "for" << "intersection_for" << "if" << "assign" << "module" << "function"; - typeformats["keyword"].setForeground(Qt::darkGreen); + tokentypes["keyword"] << "module" << "function" << "for" << "intersection_for" << "if" << "assign"; + typeformats["keyword"].setForeground(QColor("Green")); + typeformats["keyword"].setToolTip("Keyword"); + + tokentypes["transform"] << "scale" << "translate" << "rotate" << "multmatrix" << "color" << "projection" << "hull"; + typeformats["transform"].setForeground(QColor("Indigo")); + + tokentypes["csgop"] << "union" << "intersection" << "difference" << "render"; + typeformats["csgop"].setForeground(QColor("DarkGreen")); tokentypes["prim3d"] << "cube" << "cylinder" << "sphere" << "polyhedron"; - typeformats["prim3d"].setForeground(Qt::darkBlue); + typeformats["prim3d"].setForeground(QColor("DarkBlue")); tokentypes["prim2d"] << "square" << "polygon" << "circle"; - typeformats["prim2d"].setForeground(Qt::blue); - - tokentypes["transform"] << "scale" << "translate" << "rotate" << "multmatrix" << "color" << "projection"; - typeformats["transform"].setForeground(Qt::darkGreen); + typeformats["prim2d"].setForeground(QColor("MidnightBlue")); - tokentypes["import"] << "include" << "use" << "import_stl"; + tokentypes["import"] << "include" << "use" << "import_stl" << "import" << "import_dxf" << "dxf_dim" << "dxf_cross"; typeformats["import"].setForeground(Qt::darkYellow); tokentypes["special"] << "$children" << "child" << "$fn" << "$fa" << "$fb"; typeformats["special"].setForeground(Qt::darkGreen); - tokentypes["csgop"] << "union" << "intersection" << "difference" << "render"; - typeformats["csgop"].setForeground(Qt::darkGreen); - tokentypes["extrude"] << "linear_extrude" << "rotate_extrude"; typeformats["extrude"].setForeground(Qt::darkGreen); - tokentypes["bracket"] << "[" << "]"; - typeformats["bracket"].setForeground(Qt::darkGreen); + tokentypes["bracket"] << "[" << "]" << "(" << ")"; + typeformats["bracket"].setForeground(QColor("Green")); + + tokentypes["curlies"] << "{" << "}"; + typeformats["curlies"].setForeground(QColor(32,32,20)); - // Put all tokens into single QHash, mapped to their format + tokentypes["bool"] << "true" << "false"; + typeformats["bool"].setForeground(QColor("DarkRed")); + + // Put each tokens into single QHash, mapped to it's format QList::iterator ki; QList toktypes = tokentypes.keys(); for ( ki=toktypes.begin(); ki!=toktypes.end(); ++ki ) { @@ -161,14 +175,14 @@ Highlighter::Highlighter(QTextDocument *parent) for ( it = tokentypes[toktype].begin(); it < tokentypes[toktype].end(); ++it) { QString token = *it; //std::cout << token.toStdString() << "\n"; - formatMap[ token ] = typeformats [ toktype ]; + tokenFormats[ token ] = typeformats [ toktype ]; } } quoteFormat.setForeground(Qt::darkMagenta); commentFormat.setForeground(Qt::darkCyan); errorFormat.setBackground(Qt::red); - formatMap["number"].setForeground(Qt::red); + numberFormat.setForeground(QColor("DarkRed")); errorState = false; errorPos = -1; @@ -243,22 +257,28 @@ void Highlighter::highlightBlock(const QString &text) QStringList splitHelpers; QStringList::iterator sh, token; // splitHelpers - so "[a+b]" is treated as "[ a + b ]" and formatted - splitHelpers << tokentypes["operator"] << "(" << ")" << "[" << "]" << ","; + splitHelpers << tokentypes["operator"] << "(" << ")" << "[" << "]" << "," << ":"; for ( sh = splitHelpers.begin(); sh!=splitHelpers.end(); ++sh ) { newtext = newtext.replace( *sh, " " + *sh + " "); } - //std::cout << "newtext: " << newtext.toStdString() << "\n"; + //std::cout << "\nnewtext: " << newtext.toStdString() << "\n"; QStringList tokens = newtext.split(QRegExp("\\s")); int tokindex = 0; // tokindex helps w duplicate tokens in a single block bool numtest; for ( token = tokens.begin(); token!=tokens.end(); ++token ){ - tokindex = text.indexOf( *token, tokindex ); - if ( formatMap.contains( *token ) ) { - setFormat( tokindex, token->size(), formatMap[ *token ]); + if ( tokenFormats.contains( *token ) ) { + tokindex = text.indexOf( *token, tokindex ); + setFormat( tokindex, token->size(), tokenFormats[ *token ]); //std::cout << "found tok '" << (*token).toStdString() << "' at " << tokindex << "\n"; + tokindex += token->size(); } else { (*token).toDouble( &numtest ); - if ( numtest ) setFormat( tokindex, token->size(), formatMap["number"] ); + if ( numtest ) { + tokindex = text.indexOf( *token, tokindex ); + setFormat( tokindex, token->size(), numberFormat ); + //std::cout << "found num '" << (*token).toStdString() << "' at " << tokindex << "\n"; + tokindex += token->size(); + } } } diff --git a/src/highlighter.h b/src/highlighter.h index 428bbbb..b4ffae8 100644 --- a/src/highlighter.h +++ b/src/highlighter.h @@ -9,8 +9,8 @@ class Highlighter : public QSyntaxHighlighter { public: enum state_e {NORMAL=-1,QUOTE,COMMENT}; - QHash formatMap; - QTextCharFormat errorFormat, commentFormat, quoteFormat; + QHash tokenFormats; + QTextCharFormat errorFormat, commentFormat, quoteFormat, numberFormat; Highlighter(QTextDocument *parent); void highlightBlock(const QString &text); void highlightError(int error_pos); -- cgit v0.10.1 From 49fe4998d08c7095dd39731f9ff8a336b3fb42a4 Mon Sep 17 00:00:00 2001 From: don bright Date: Sun, 13 Jan 2013 05:06:15 +0100 Subject: doc length tested ok. remove FIXME note diff --git a/src/highlighter.cc b/src/highlighter.cc index 58912f3..44ef368 100644 --- a/src/highlighter.cc +++ b/src/highlighter.cc @@ -235,7 +235,6 @@ void Highlighter::portable_rehighlightBlock( const QTextBlock &block ) int Highlighter::lastDocumentPos() { -// fixme - test it #if (QT_VERSION >= QT_VERSION_CHECK(4, 5, 0)) return document()->characterCount(); #else -- cgit v0.10.1 From 99a0b67cd4500b8f4410231b30fd67c0fa3aa4cb Mon Sep 17 00:00:00 2001 From: don bright Date: Sun, 13 Jan 2013 10:16:21 -0600 Subject: remove duplicate test from test list. clarify speed lanuage on large file diff --git a/src/highlighter.cc b/src/highlighter.cc index 44ef368..77d1bb8 100644 --- a/src/highlighter.cc +++ b/src/highlighter.cc @@ -94,28 +94,26 @@ 5. action: open file, type in a multi-line comment expected result: multiline comment should be highlighted appropriately -6. action: open example001, put a single '=' after first { - expected result: error highlight of '=' you added - -7. action: open example001, remove first ')' +6. action: open example001, remove first ')' expected result: highlight should appear appropriately -8. action: create a large file (50,000 lines). eg at a bash prompt: - for i in {1..1000}; do cat examples/example001.scad >> test5k.scad ; done +7. action: create a large file (50,000 lines). eg at a bash prompt: + for i in {1..2000}; do cat examples/example001.scad >> test5k.scad ; done action: open file in openscad - expected result: there should not be a slowdown due to highlighting + expected result: it should load in a reasonable amount of time action: scroll to bottom, put '=' after last ; expected result: there should be a highlight, and a report of syntax error - action: comment out the highlighter code from mainwin.cc, recompile, put '=' after last ; - expected result: there should be almost no difference in speed + action: comment out the highlighter code from mainwin.cc, recompile, + run openscad again on the large file. put '=' after last ; + expected result: there should be only a small difference in speed. -9. action: open any file, and hold down 'f5' key to repeatedly reparse +8. action: open any file, and hold down 'f5' key to repeatedly reparse expected result: no crashing! -10. action: for i in examples/ex* ; do ./openscad $i ; done +9. action: for i in examples/ex* ; do ./openscad $i ; done expected result: make sure the colors look harmonious -11. action: type random string of [][][][]()()[][90,3904,00,000] +10. action: type random string of [][][][]()()[][90,3904,00,000] expected result: all should be highlighted correctly */ -- cgit v0.10.1 From a1da6b2aded1c930a5ffdb5ecdbee708aefea243 Mon Sep 17 00:00:00 2001 From: Marius Kintel Date: Sun, 13 Jan 2013 13:46:36 -0500 Subject: Moved Mac download site from github to google code diff --git a/doc/release-checklist.txt b/doc/release-checklist.txt index e85e97c..cc85009 100644 --- a/doc/release-checklist.txt +++ b/doc/release-checklist.txt @@ -43,9 +43,15 @@ o Remove VERSION environment variable o git push --tags o Upload - - Github - Upload manually here: https://github.com/openscad/openscad/downloads - FIXME: Write a script + - Source: + scripts/googlecode_upload.py -s 'Source Code' -p openscad OpenSCAD-2013.01.08.dmg -l Featured,Type-Source openscad-$VERSION.src.tar.gz + - Linux: + scripts/googlecode_upload.py -s 'Linux Binaries' -p openscad OpenSCAD-2013.01.08.dmg -l Featured,OpSys-Linux,Type-Archive openscad-$VERSION.x86-32.tar.gz + scripts/googlecode_upload.py -s 'Linux Binaries' -p openscad OpenSCAD-2013.01.08.dmg -l Featured,OpSys-Linux,Type-Archive openscad-$VERSION.x86-64.tar.gz + - Windows: + scripts/googlecode_upload.py -s 'Windows Binaries' -p openscad OpenSCAD-2013.01.08.dmg -l Featured,OpSys-Windows,Type-Archive OpenSCAD-$VERSION.zip + scripts/googlecode_upload.py -s 'Windows Installer' -p openscad OpenSCAD-2013.01.08.dmg -l Featured,OpSys-Windows,Type-Installer OpenSCAD-$VERSION-Installer.exe + - Mac: Already done by public-macosx.sh o Update web page o Write email to mailing list diff --git a/scripts/publish-macosx.sh b/scripts/publish-macosx.sh index a2ded8a..b0cf3a5 100755 --- a/scripts/publish-macosx.sh +++ b/scripts/publish-macosx.sh @@ -6,6 +6,7 @@ if test -z "$VERSION"; then VERSION=`date "+%Y.%m.%d"` COMMIT=-c + SNAPSHOT=true fi # Turn off ccache, just for safety @@ -24,10 +25,11 @@ echo "Sanity check of the app bundle..." if [[ $? != 0 ]]; then exit 1 fi -cp OpenSCAD-$VERSION.dmg ~/Dropbox/Public -ln -sf OpenSCAD-$VERSION.dmg ~/Dropbox/Public/OpenSCAD-latest.dmg -echo "Upload in progress..." +echo "Uploading..." +LABELS=OpSys-OSX,Type-Executable +if ! $SNAPSHOT; then LABELS=$LABELS,Featured; fi +`dirname $0`/googlecode_upload.py -s 'Mac OS X Snapshot' -p openscad OpenSCAD-$VERSION.dmg -l $LABELS # Update snapshot filename on wab page `dirname $0`/update-web.sh OpenSCAD-$VERSION.dmg -- cgit v0.10.1 From db8d8919433cc68ee777fcfc3199448419733c92 Mon Sep 17 00:00:00 2001 From: Marius Kintel Date: Sun, 13 Jan 2013 18:28:13 -0500 Subject: bugfix: Wrong slot names for OpenCSG warning dialog diff --git a/src/OpenCSGWarningDialog.cc b/src/OpenCSGWarningDialog.cc index 5648576..926a55b 100644 --- a/src/OpenCSGWarningDialog.cc +++ b/src/OpenCSGWarningDialog.cc @@ -8,12 +8,12 @@ OpenCSGWarningDialog::OpenCSGWarningDialog(QWidget*) connect(this->showBox, SIGNAL(toggled(bool)), Preferences::inst()->openCSGWarningBox, SLOT(setChecked(bool))); connect(this->showBox, SIGNAL(toggled(bool)), - Preferences::inst(), SLOT(openCSGWarningChanged(bool))); + Preferences::inst(), SLOT(on_openCSGWarningBox_toggled(bool))); connect(this->enableOpenCSGBox, SIGNAL(toggled(bool)), Preferences::inst()->enableOpenCSGBox, SLOT(setChecked(bool))); connect(this->enableOpenCSGBox, SIGNAL(toggled(bool)), - Preferences::inst(), SLOT(enableOpenCSGChanged(bool))); + Preferences::inst(), SLOT(on_enableOpenCSGBox_toggled(bool))); } void OpenCSGWarningDialog::setText(const QString &text) -- cgit v0.10.1 From 5639fdba23559d0c14fd8d5245992dae406ec1a7 Mon Sep 17 00:00:00 2001 From: Marius Kintel Date: Mon, 14 Jan 2013 21:23:10 -0500 Subject: sync diff --git a/doc/TODO.txt b/doc/TODO.txt index 44b11ad..62db614 100644 --- a/doc/TODO.txt +++ b/doc/TODO.txt @@ -113,6 +113,7 @@ o Misc for confirmation. - Go through keyboard shortcuts and make them more conformant to platform standards - Show design info/stats (sizes, caches etc.) + - Support Voice Over and related technologies for vision-impaired users o Cmd-line - Add verbose option (PRINT command from mainwin.cc and progress output) -- cgit v0.10.1 From 1d8c634663a8d6b99bf6b4c6466a5d2d654504b3 Mon Sep 17 00:00:00 2001 From: Marius Kintel Date: Mon, 14 Jan 2013 21:23:40 -0500 Subject: Reorganized section for building binaries diff --git a/doc/release-checklist.txt b/doc/release-checklist.txt index cc85009..93780df 100644 --- a/doc/release-checklist.txt +++ b/doc/release-checklist.txt @@ -1,6 +1,8 @@ OpenSCAD Release Checklist -------------------------- +(See bottom of this file for how to build release binaries) + o Update VERSION environment variable export VERSION=2012.08 @@ -19,22 +21,7 @@ o Tag release o build source package scripts/git-archive-all.py --prefix=openscad-$VERSION/ openscad-$VERSION.src.tar.gz -o build binaries - tar xzf openscad-$VERSION.src.tar.gz - cd openscad-$VERSION - Mac OS X - (For Qt-4.7.3: Remove /Developers/Applications/Qt/plugins/qmltooling) - ./scripts/publish-macosx.sh -> OpenSCAD-$VERSION.dmg - Linux: - 32-bit: run on a 32-bit machine or VM - 64-bit: run on a 64-bit machine or VM - ./scripts/release-common.sh -> openscad-$VERSION.x86-ARCH.tar.gz - (where ARCH will be detected and set to 32 or 64) - Windows mingw cross-build: FIXME 32 vs. 64 bit - ./scripts/publish-mingw-x.sh -> mingw32/Openscad-$VERSION.zip - -> mingw32/Openscad-$VERSION-Installer.exe - -o FIXME: Run some tests +o Sanity check; build a binary or two and manually run some tests o Remove VERSION environment variable @@ -42,16 +29,8 @@ o Remove VERSION environment variable o git push --tags -o Upload - - Source: - scripts/googlecode_upload.py -s 'Source Code' -p openscad OpenSCAD-2013.01.08.dmg -l Featured,Type-Source openscad-$VERSION.src.tar.gz - - Linux: - scripts/googlecode_upload.py -s 'Linux Binaries' -p openscad OpenSCAD-2013.01.08.dmg -l Featured,OpSys-Linux,Type-Archive openscad-$VERSION.x86-32.tar.gz - scripts/googlecode_upload.py -s 'Linux Binaries' -p openscad OpenSCAD-2013.01.08.dmg -l Featured,OpSys-Linux,Type-Archive openscad-$VERSION.x86-64.tar.gz - - Windows: - scripts/googlecode_upload.py -s 'Windows Binaries' -p openscad OpenSCAD-2013.01.08.dmg -l Featured,OpSys-Windows,Type-Archive OpenSCAD-$VERSION.zip - scripts/googlecode_upload.py -s 'Windows Installer' -p openscad OpenSCAD-2013.01.08.dmg -l Featured,OpSys-Windows,Type-Installer OpenSCAD-$VERSION-Installer.exe - - Mac: Already done by public-macosx.sh +o Upload Source package + $ ./scripts/googlecode_upload.py -s 'Source Code' -p openscad openscad-$VERSION.src.tar.gz -l Featured,Type-Source openscad-$VERSION.src.tar.gz o Update web page o Write email to mailing list @@ -59,3 +38,33 @@ o Update external resources: - http://en.wikipedia.org/wiki/OpenSCAD o Notify package managers - Ubuntu: https://launchpad.net/~chrysn + - MacPorts: + + +Build and Upload Release Binaries +--------------------------------- + +$ export VERSION= +$ tar xzf openscad-$VERSION.src.tar.gz +$ cd openscad-$VERSION + +Mac OS X: + + $ ./scripts/publish-macosx.sh -> OpenSCAD-$VERSION.dmg + +Linux: + 32-bit: run on a 32-bit machine or VM + 64-bit: run on a 64-bit machine or VM + + $ ./scripts/release-common.sh -> openscad-$VERSION.x86-ARCH.tar.gz + (where ARCH will be detected and set to 32 or 64) + $ ./scripts/googlecode_upload.py -s 'Linux Binaries' -p openscad openscad-$VERSION.x86-ARCH.tar.gz -l Featured,OpSys-Linux,Type-Archive openscad-$VERSION.x86-ARCH.tar.gz + o Update web page with download links + +Windows mingw cross-build: FIXME 32 vs. 64 bit + + $ ./scripts/publish-mingw-x.sh -> mingw32/Openscad-$VERSION.zip + -> mingw32/Openscad-$VERSION-Installer.exe + $ ./scripts/googlecode_upload.py -s 'Windows Binaries' -p openscad OpenSCAD-$VERSION.zip -l Featured,OpSys-Windows,Type-Archive OpenSCAD-$VERSION.zip + $ ./scripts/googlecode_upload.py -s 'Windows Installer' -p openscad OpenSCAD-$VERSION-Installer.exe -l Featured,OpSys-Windows,Type-Installer OpenSCAD-$VERSION-Installer.exe + o Update web page with download links -- cgit v0.10.1 From 3d36baed60b340b508c0963d94eb011ddeefa02b Mon Sep 17 00:00:00 2001 From: Marius Kintel Date: Tue, 15 Jan 2013 19:06:02 -0500 Subject: Updated RELEASE_NOTES diff --git a/RELEASE_NOTES b/RELEASE_NOTES index f629cd6..4448e89 100644 --- a/RELEASE_NOTES +++ b/RELEASE_NOTES @@ -1,4 +1,4 @@ -OpenSCAD 2012.11 +OpenSCAD 2013.01 ================ Features: @@ -26,6 +26,8 @@ o cmd-line overrides using -D now also work for USEd modules o Modifier characters can now be used in front of if statements o rotate() with a vector argument with less that 3 elements used uninitialized variables, ending up being non-deterministic. o .csg files will now have relative filenames whenever possible +o Don't just ignore geometric nodes having zero volume/area - when doing difference/intersection, they tend to turn negative objects into positive ones. +o Always use utf-8 file encoding, also under Windows o A lot of build script fixes o Some other crash bugs fixes -- cgit v0.10.1 From 7ea7ea9aee398b3ed63a9ec2b155fe154eb9ba54 Mon Sep 17 00:00:00 2001 From: Marius Kintel Date: Wed, 16 Jan 2013 14:59:45 -0500 Subject: Linux build fix: qmake exists() was using the variable name instead of its contents diff --git a/eigen.pri b/eigen.pri index efb2d3c..0ee551c 100644 --- a/eigen.pri +++ b/eigen.pri @@ -51,7 +51,7 @@ isEmpty(EIGEN_INCLUDEPATH) { netbsd*: EIGEN_INCLUDEPATH = /usr/pkg/include/eigen3 linux*|hurd*|unix: EIGEN_INCLUDEPATH = /usr/include/eigen3 macx: EIGEN_INCLUDEPATH = /opt/local/include/eigen3 - !exists(EIGEN_INCLUDEPATH) { + !exists($$EIGEN_INCLUDEPATH) { freebsd-g++: EIGEN_INCLUDEPATH = /usr/local/include/eigen2 netbsd*: EIGEN_INCLUDEPATH = /usr/pkg/include/eigen2 linux*|hurd*|unix*: EIGEN_INCLUDEPATH = /usr/include/eigen2 -- cgit v0.10.1 From 202c57773e378ce092243f8803032564d9103023 Mon Sep 17 00:00:00 2001 From: don bright Date: Thu, 17 Jan 2013 03:51:33 +0100 Subject: allow dxf deps writing diff --git a/src/openscad.cc b/src/openscad.cc index df7adb3..472b5d4 100644 --- a/src/openscad.cc +++ b/src/openscad.cc @@ -304,8 +304,19 @@ int main(int argc, char **argv) fs::current_path(original_path); if (deps_output_file) { - if (!write_deps(deps_output_file, - stl_output_file ? stl_output_file : off_output_file)) { + std::string deps_out( deps_output_file ); + std::string geom_out; + if ( stl_output_file ) geom_out = std::string(stl_output_file); + else if ( off_output_file ) geom_out = std::string(off_output_file); + else if ( dxf_output_file ) geom_out = std::string(dxf_output_file); + else { + PRINTB("Output file:%s\n",output_file); + PRINT("Sorry, don't know how to write deps for that file type. Exiting\n"); + exit(1); + } + int result = write_deps( deps_out, geom_out ); + if ( !result ) { + PRINT("error writing deps"); exit(1); } } -- cgit v0.10.1 From 8dfc6d71cae370a84e50f4cc7624c05c859a4cea Mon Sep 17 00:00:00 2001 From: Marius Kintel Date: Thu, 17 Jan 2013 09:58:04 -0500 Subject: Added path to self-built Qt diff --git a/setenv_mjau.sh b/setenv_mjau.sh index 851cf0e..fbeb292 100644 --- a/setenv_mjau.sh +++ b/setenv_mjau.sh @@ -7,6 +7,9 @@ export QMAKESPEC=macx-g++ #export QCODEEDITDIR=$PWD/../qcodeedit-2.2.3/install #export DYLD_LIBRARY_PATH=$OPENCSGDIR/lib:$QCODEEDITDIR/lib +# Own own Qt +export PATH=$OPENSCAD_LIBRARIES/bin:$PATH + # ccache: export PATH=/opt/local/libexec/ccache:$PATH export CCACHE_BASEDIR=$PWD/.. -- cgit v0.10.1 From 136139ca018e1770e28457f63554622fbc1601ef Mon Sep 17 00:00:00 2001 From: don bright Date: Thu, 17 Jan 2013 16:16:45 +0100 Subject: CONFIG= should read CONFIG+= -- otherwise it causes bizare build errors diff --git a/src/version_check.h b/src/version_check.h index b6a63ab..db17962 100644 --- a/src/version_check.h +++ b/src/version_check.h @@ -24,26 +24,26 @@ a time, to avoid confusion. #define GMPPATCH 0 #define SYS_GMP_VER (__GNU_MP_VERSION * 10000 + __GNU_MP_VERSION_MINOR * 100 + __GNU_MP_VERSION_PATCHLEVEL * 1) #if SYS_GMP_VER < GMPMAJOR * 10000 + GMPMINOR * 100 + GMPPATCH * 1 -#error GNU GMP library missing or version too old. See README.md. To force compile, run qmake CONFIG=skip-version-check +#error GNU GMP library missing or version too old. See README.md. To force compile, run qmake CONFIG+=skip-version-check #else #include #if MPFR_VERSION < MPFR_VERSION_NUM( 3,0,0 ) -#error GNU MPFR library missing or version too old. See README.md. To force compile, run qmake CONFIG=skip-version-check +#error GNU MPFR library missing or version too old. See README.md. To force compile, run qmake CONFIG+=skip-version-check #else #include #if not EIGEN_VERSION_AT_LEAST( 2,0,13 ) -#error eigen2 library missing or version too old. See README.md. To force compile, run qmake CONFIG=skip-version-check +#error eigen2 library missing or version too old. See README.md. To force compile, run qmake CONFIG+=skip-version-check #else #include // boost 1.3.5 = 103500 #if BOOST_VERSION < 103500 -#error boost library missing or version too old. See README.md. To force compile, run qmake CONFIG=skip-version-check +#error boost library missing or version too old. See README.md. To force compile, run qmake CONFIG+=skip-version-check #else @@ -51,7 +51,7 @@ a time, to avoid confusion. #include #if CGAL_VERSION_NR < 1030601000 -#error CGAL library missing or version too old. See README.md. To force compile, run qmake CONFIG=skip-version-check +#error CGAL library missing or version too old. See README.md. To force compile, run qmake CONFIG+=skip-version-check #else #if CGAL_VERSION_NR < 1040021000 @@ -76,20 +76,20 @@ a time, to avoid confusion. #include // kludge - GLEW doesnt have compiler-accessible version numbering #ifndef GLEW_ARB_occlusion_query2 -#error GLEW library missing or version too old. See README.md. To force compile, run qmake CONFIG=skip-version-check +#error GLEW library missing or version too old. See README.md. To force compile, run qmake CONFIG+=skip-version-check #else #include // 1.3.2 -> 0x0132 #if OPENCSG_VERSION < 0x0132 -#error OPENCSG library missing or version too old. See README.md. To force compile, run qmake CONFIG=skip-version-check +#error OPENCSG library missing or version too old. See README.md. To force compile, run qmake CONFIG+=skip-version-check #else #endif // ENABLE_OPENCSG #include #if QT_VERSION < 0x040400 -#error QT library missing or version too old. See README.md. To force compile, run qmake CONFIG=skip-version-check +#error QT library missing or version too old. See README.md. To force compile, run qmake CONFIG+=skip-version-check #endif // QT -- cgit v0.10.1 From ce1969c4da70882ff1df13763ec3b35ce92ffb0b Mon Sep 17 00:00:00 2001 From: Marius Kintel Date: Thu, 17 Jan 2013 10:23:10 -0500 Subject: Show Qt version in Library Info diff --git a/src/mainwin.cc b/src/mainwin.cc index dde6761..5c18b17 100644 --- a/src/mainwin.cc +++ b/src/mainwin.cc @@ -1768,11 +1768,13 @@ void MainWindow::helpLibrary() libinfo.sprintf("Boost version: %s\n" "Eigen version: %d.%d.%d\n" "CGAL version: %s\n" - "OpenCSG version: %s\n\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); + OPENCSG_VERSION_STRING, + qVersion()); if (!this->openglbox) { this->openglbox = new QMessageBox(QMessageBox::Information, -- cgit v0.10.1 From 017059c6865a62ee5b3ea63b079f4692a646c496 Mon Sep 17 00:00:00 2001 From: don bright Date: Thu, 17 Jan 2013 16:41:04 +0100 Subject: mention that cross-building dependencies can take several hours diff --git a/README.md b/README.md index f1d9925..b98335a 100644 --- a/README.md +++ b/README.md @@ -195,7 +195,9 @@ Then run the script to download & compile all the prerequisite libraries above: ./scripts/mingw-x-build-dependencies.sh -Then, build OpenSCAD and package it to an installer: +Note that this process can take several hours, as it uses the +http://mxe.cc system to cross-build many libraries. After it is +complete, build OpenSCAD and package it to an installer: ./scripts/release-common.sh mingw32 -- cgit v0.10.1 From 05fa73b27aff81fdb2c092612a4d44a5000b469a Mon Sep 17 00:00:00 2001 From: don bright Date: Thu, 17 Jan 2013 16:43:46 +0100 Subject: US-style Trademark disclaimer diff --git a/src/AboutDialog.html b/src/AboutDialog.html index 0eee1cb..cc73255 100644 --- a/src/AboutDialog.html +++ b/src/AboutDialog.html @@ -136,6 +136,10 @@ benhowes ... and many others

    +Trademarks are property of their owners and do not imply affiliation with OpenSCAD +

    + +

    Apologies to anyone left out. Please file an issue on OpenSCAD's github if you know of someone who belongs here.

    -- cgit v0.10.1 From 2336f6fe2a50daba977d3e51bd043a69157344e1 Mon Sep 17 00:00:00 2001 From: don bright Date: Thu, 17 Jan 2013 16:57:58 +0100 Subject: point out that you need a clean shell to run the mingw crossbuild diff --git a/README.md b/README.md index b98335a..ddad806 100644 --- a/README.md +++ b/README.md @@ -186,8 +186,9 @@ attempt an MSVC build on Windows, please see this site: http://en.wikibooks.org/wiki/OpenSCAD_User_Manual/Building_on_Windows To cross-build, first make sure that you have development tools -installed to get GCC. Then after you've cloned this git repository, run -the script that sets up the environment variables. +installed to get GCC. Then after you've cloned this git repository, +start a new clean shell and run the script that sets up the environment +variables. source ./scripts/setenv-mingw-xbuild.sh -- cgit v0.10.1 From 6f73b1e8582719e4f9d6f64d29b81ec644070376 Mon Sep 17 00:00:00 2001 From: Marius Kintel Date: Thu, 17 Jan 2013 11:21:53 -0500 Subject: Credit goes to chrysn, using his handle instead of his real name diff --git a/src/AboutDialog.html b/src/AboutDialog.html index cc73255..34e8127 100644 --- a/src/AboutDialog.html +++ b/src/AboutDialog.html @@ -84,7 +84,7 @@ Please visit this link for a copy of the license:
    Debian maintainer: - Christian M. Amsuess + chrysn

    -- cgit v0.10.1 From 8537dc986c311f8b2194f4c6037b06e708a7d536 Mon Sep 17 00:00:00 2001 From: Marius Kintel Date: Thu, 17 Jan 2013 11:37:38 -0500 Subject: Build our own Qt binaries on Mac, to be able to support 32-bit builds. Upgraded gmp to 5.1.0 diff --git a/scripts/macosx-build-dependencies.sh b/scripts/macosx-build-dependencies.sh index 6313b2b..bfe0ede 100755 --- a/scripts/macosx-build-dependencies.sh +++ b/scripts/macosx-build-dependencies.sh @@ -13,11 +13,9 @@ # # Prerequisites: # - MacPorts: curl, cmake -# - Qt4 # # FIXME: # o Verbose option -# o Port to other platforms? # BASEDIR=$PWD/../libraries @@ -41,6 +39,25 @@ printUsage() echo " -c Force use of clang compiler" } +# FIXME: Support gcc/llvm/clang flags. Use -platform to make this work? kintel 20130117 +build_qt() +{ + version=$1 + 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 + if $OPTION_32BIT; then + QT_32BIT="-arch x86" + fi + ./configure -prefix $DEPLOYDIR -release $QT_32BIT -arch x86_64 -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 -j6 install +} + # Hack warning: gmplib is built separately in 32-bit and 64-bit mode # and then merged afterwards. gmplib's header files are dependent on # the CPU architecture on which configure was run and will be patched accordingly. @@ -365,8 +382,9 @@ fi echo "Using basedir:" $BASEDIR mkdir -p $SRCDIR $DEPLOYDIR +build_qt 4.8.4 build_eigen 3.1.2 -build_gmp 5.0.5 +build_gmp 5.1.0 build_mpfr 3.1.1 build_boost 1.51.0 # NB! For CGAL, also update the actual download URL in the function -- cgit v0.10.1 From 31021b3fd59462c78630ab2ca161daf4cf182b1e Mon Sep 17 00:00:00 2001 From: Marius Kintel Date: Thu, 17 Jan 2013 11:37:51 -0500 Subject: Use correct Qt tools diff --git a/scripts/publish-macosx.sh b/scripts/publish-macosx.sh index b0cf3a5..ccfeb3d 100755 --- a/scripts/publish-macosx.sh +++ b/scripts/publish-macosx.sh @@ -15,6 +15,9 @@ PATH=${PATH//\/opt\/local\/libexec\/ccache:} # This is the same location as DEPLOYDIR in macosx-build-dependencies.sh export OPENSCAD_LIBRARIES=$PWD/../libraries/install +# Make sure that the correct Qt tools are used +export PATH=$OPENSCAD_LIBRARIES/bin:$PATH + `dirname $0`/release-common.sh -v $VERSION $COMMIT if [[ $? != 0 ]]; then exit 1 -- cgit v0.10.1 From 0e4e8b64a7195b9b65cf029ccf8bb9f795bd9bae Mon Sep 17 00:00:00 2001 From: Marius Kintel Date: Thu, 17 Jan 2013 11:43:17 -0500 Subject: Test results for updated tests for issue #221 diff --git a/tests/regression/opencsgtest/difference-tests-expected.png b/tests/regression/opencsgtest/difference-tests-expected.png index 794104a..a6d863a 100644 Binary files a/tests/regression/opencsgtest/difference-tests-expected.png and b/tests/regression/opencsgtest/difference-tests-expected.png differ diff --git a/tests/regression/throwntogethertest/difference-tests-expected.png b/tests/regression/throwntogethertest/difference-tests-expected.png index 183700c..0a27c90 100644 Binary files a/tests/regression/throwntogethertest/difference-tests-expected.png and b/tests/regression/throwntogethertest/difference-tests-expected.png differ -- cgit v0.10.1 From 7f4cfc5ada494852979eb290ba76a34bfd684854 Mon Sep 17 00:00:00 2001 From: Marius Kintel Date: Thu, 17 Jan 2013 13:31:12 -0500 Subject: Added some fixme's related to quitting while doing a long calculation. It sometimes causes a crash atm. diff --git a/src/mainwin.cc b/src/mainwin.cc index 5c18b17..38355ff 100644 --- a/src/mainwin.cc +++ b/src/mainwin.cc @@ -462,6 +462,7 @@ void MainWindow::report_func(const class AbstractNode*, void *vp, int mark) QApplication::processEvents(); } + // FIXME: Check if cancel was requested by e.g. Application quit if (thisp->progresswidget->wasCanceled()) throw ProgressCancelException(); } @@ -1847,6 +1848,7 @@ void MainWindow::quit() QCloseEvent ev; QApplication::sendEvent(QApplication::instance(), &ev); if (ev.isAccepted()) QApplication::instance()->quit(); + // FIXME: Cancel any CGAL calculations } void MainWindow::consoleOutput(const std::string &msg, void *userdata) -- cgit v0.10.1 From 763e5d3f657519d80654f3c2cb79025445506041 Mon Sep 17 00:00:00 2001 From: Marius Kintel Date: Thu, 17 Jan 2013 15:02:28 -0500 Subject: Note about setting VERSION env. variable diff --git a/scripts/publish-macosx.sh b/scripts/publish-macosx.sh index ccfeb3d..e22e5bd 100755 --- a/scripts/publish-macosx.sh +++ b/scripts/publish-macosx.sh @@ -1,7 +1,7 @@ #!/bin/sh -# Set this if we're doing a release build. Comment it out for development builds -#VERSION=2011.12 +# NB! To build a release build, the VERSION environment variable needs to be set. +# See doc/release-checklist.txt if test -z "$VERSION"; then VERSION=`date "+%Y.%m.%d"` -- cgit v0.10.1 From 52c9fd7adc497a3712e90fa5139217c815a13752 Mon Sep 17 00:00:00 2001 From: Marius Kintel Date: Thu, 17 Jan 2013 15:18:30 -0500 Subject: Updated copyright year to 2013 diff --git a/src/mainwin.cc b/src/mainwin.cc index 38355ff..7643e08 100644 --- a/src/mainwin.cc +++ b/src/mainwin.cc @@ -115,7 +115,7 @@ static char helptitle[] = #endif "\nhttp://www.openscad.org\n\n"; static char copyrighttext[] = - "Copyright (C) 2009-2012 Marius Kintel and Clifford Wolf \n" + "Copyright (C) 2009-2013 Marius Kintel and Clifford Wolf \n" "\n" "This program is free software; you can redistribute it and/or modify " "it under the terms of the GNU General Public License as published by " -- cgit v0.10.1 From 6ecf96b081626c512343fc1a8f7aa4a202ffaa86 Mon Sep 17 00:00:00 2001 From: Marius Kintel Date: Thu, 17 Jan 2013 15:18:46 -0500 Subject: Minor tweaks to checklist diff --git a/doc/release-checklist.txt b/doc/release-checklist.txt index 93780df..6d53ad9 100644 --- a/doc/release-checklist.txt +++ b/doc/release-checklist.txt @@ -14,6 +14,7 @@ o Update VERSION environment variable scripts/publish-mingw-x.sh o Update RELEASE_NOTES +o Update copyright year in AboutDialog.html and mainwin.cc o Tag release git tag "openscad-$VERSION" @@ -23,14 +24,13 @@ o build source package o Sanity check; build a binary or two and manually run some tests -o Remove VERSION environment variable - - export VERSION= - o git push --tags o Upload Source package - $ ./scripts/googlecode_upload.py -s 'Source Code' -p openscad openscad-$VERSION.src.tar.gz -l Featured,Type-Source openscad-$VERSION.src.tar.gz + $ ./scripts/googlecode_upload.py -s 'Source Code' -p openscad -l Featured,Type-Source openscad-$VERSION.src.tar.gz + +o Remove VERSION environment variable + $ unset VERSION o Update web page o Write email to mailing list -- 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