#1061 fixed test build behaving differently from GUI build due to ENABLE_CGAL flag not being passed to all relevant sources. Added testcase

master
Marius Kintel 2014-12-09 16:42:02 -05:00
parent 2462799655
commit 6d9329966a
8 changed files with 29 additions and 19 deletions

View File

@ -2,7 +2,9 @@
#include "polyset.h"
#include "Polygon2d.h"
#include "printutils.h"
#ifdef ENABLE_CGAL
#include "cgalutils.h"
#endif
#include <boost/foreach.hpp>
@ -45,6 +47,7 @@ namespace PolysetUtils {
The tessellation will be robust wrt. degenerate and self-intersecting
*/
void tessellate_faces(const PolySet &inps, PolySet &outps) {
#ifdef ENABLE_CGAL
int degeneratePolygons = 0;
for (size_t i = 0; i < inps.polygons.size(); i++) {
const Polygon pgon = inps.polygons[i];
@ -76,5 +79,17 @@ namespace PolysetUtils {
}
}
if (degeneratePolygons > 0) PRINT("WARNING: PolySet has degenerate polygons");
#else
assert(false);
#endif
}
bool is_approximately_convex(const PolySet &ps) {
#ifdef ENABLE_CGAL
return CGALUtils::is_approximately_convex(ps);
#else
return false;
#endif
}
}

View File

@ -7,5 +7,6 @@ namespace PolysetUtils {
Polygon2d *project(const PolySet &ps);
void tessellate_faces(const PolySet &inps, PolySet &outps);
bool is_approximately_convex(const PolySet &ps);
};

View File

@ -25,6 +25,7 @@
*/
#include "polyset.h"
#include "polyset-utils.h"
#include "linalg.h"
#include "printutils.h"
#include <Eigen/LU>
@ -140,20 +141,10 @@ void PolySet::transform(const Transform3d &mat)
}
}
namespace CGALUtils {
extern bool is_approximately_convex(const PolySet &ps);
}
bool PolySet::is_convex() const {
if (convex) return true;
if (convex) return true;
if (!convex) return false;
#ifdef ENABLE_CGAL
convex = CGALUtils::is_approximately_convex(*this);
return convex;
#else
return false;
#endif
return PolysetUtils::is_approximately_convex(*this);
}
void PolySet::resize(Vector3d newsize, const Eigen::Matrix<bool,3,1> &autosize)

1
testdata/scad/bugs/issue1061.scad vendored Normal file
View File

@ -0,0 +1 @@
polyhedron(points = [[-5, -5, 0], [-5, 5, 0], [5, 5, 0], [5, -5, 0], [-1.87866, -4.21311, 3], [-4.21311, 5.51058, 3], [5.51058, 7.84504, 3], [7.84504, -1.87866, 3], [1.05099, -3.48892, 6], [-3.48892, 5.42115, 6], [5.42115, 9.96105, 6], [9.96105, 1.05099, 6], [3.39596, -3.09852, 9], [-3.09852, 4.50554, 9], [4.50554, 11, 9], [11, 3.39596, 9], [4.91038, -3.17979, 12], [-3.17979, 2.69807, 12], [2.69807, 10.7882, 12], [10.7882, 4.91038, 12], [5.53441, -3.70439, 15], [-3.70439, 0.122447, 15], [0.122447, 9.36124, 15], [9.36124, 5.53441, 15], [5.39234, -4.48455, 18], [-4.48455, -2.9202, 18], [-2.9202, 6.95668, 18], [6.95668, 5.39234, 18]], faces = [[0, 1, 5, 4], [1, 2, 6, 5], [2, 3, 7, 6], [3, 0, 4, 7], [4, 5, 9, 8], [5, 6, 10, 9], [6, 7, 11, 10], [7, 4, 8, 11], [8, 9, 13, 12], [9, 10, 14, 13], [10, 11, 15, 14], [11, 8, 12, 15], [12, 13, 17, 16], [13, 14, 18, 17], [14, 15, 19, 18], [15, 12, 16, 19], [16, 17, 21, 20], [17, 18, 22, 21], [18, 19, 23, 22], [19, 16, 20, 23], [20, 21, 25, 24], [21, 22, 26, 25], [22, 23, 27, 26], [23, 20, 24, 27], [3, 2, 1, 0], [24, 25, 26, 27]]);

View File

@ -632,7 +632,6 @@ set(CORE_SOURCES
../src/csgtermnormalizer.cc
../src/Geometry.cc
../src/Polygon2d.cc
../src/polyset.cc
../src/csgops.cc
../src/transform.cc
../src/color.cc
@ -666,7 +665,10 @@ set(NOCGAL_SOURCES
../src/builtin.cc
../src/import.cc
../src/export.cc
../src/LibraryInfo.cc)
../src/LibraryInfo.cc
../src/polyset.cc
../src/polyset-utils.cc)
set(CGAL_SOURCES
${NOCGAL_SOURCES}
@ -678,7 +680,6 @@ set(CGAL_SOURCES
../src/CGALCache.cc
../src/CGAL_Nef_polyhedron_DxfData.cc
../src/Polygon2d-CGAL.cc
../src/polyset-utils.cc
../src/svg.cc
../src/GeometryEvaluator.cc)
@ -749,20 +750,20 @@ set_target_properties(tests-offscreen PROPERTIES COMPILE_FLAGS "${ENABLE_OPENCSG
# modulecachetest
#
add_executable(modulecachetest modulecachetest.cc)
target_link_libraries(modulecachetest tests-nocgal)
target_link_libraries(modulecachetest tests-nocgal ${GLEW_LIBRARY} ${OPENCSG_LIBRARY} ${APP_SERVICES_LIBRARY})
#
# csgtexttest
#
add_executable(csgtexttest csgtexttest.cc CSGTextRenderer.cc CSGTextCache.cc)
target_link_libraries(csgtexttest tests-nocgal)
target_link_libraries(csgtexttest tests-nocgal ${GLEW_LIBRARY} ${OPENCSG_LIBRARY} ${APP_SERVICES_LIBRARY})
#
# cgalcachetest
#
add_executable(cgalcachetest cgalcachetest.cc)
set_target_properties(cgalcachetest PROPERTIES COMPILE_FLAGS "-DENABLE_CGAL ${CGAL_CXX_FLAGS_INIT}")
target_link_libraries(cgalcachetest tests-cgal)
target_link_libraries(cgalcachetest tests-cgal ${GLEW_LIBRARY} ${OPENCSG_LIBRARY} ${APP_SERVICES_LIBRARY})
#
# openscad no-qt
@ -1213,7 +1214,8 @@ list(APPEND BUGS_FILES ${CMAKE_SOURCE_DIR}/../testdata/scad/bugs/issue584.scad
${CMAKE_SOURCE_DIR}/../testdata/scad/bugs/issue964b.scad
${CMAKE_SOURCE_DIR}/../testdata/scad/bugs/issue990.scad
${CMAKE_SOURCE_DIR}/../testdata/scad/bugs/issue1004.scad
${CMAKE_SOURCE_DIR}/../testdata/scad/bugs/issue1005.scad)
${CMAKE_SOURCE_DIR}/../testdata/scad/bugs/issue1005.scad
${CMAKE_SOURCE_DIR}/../testdata/scad/bugs/issue1061.scad)
list(APPEND EXPORT3D_TEST_FILES ${BUGS_FILES})
list(REMOVE_ITEM EXPORT3D_TEST_FILES ${CMAKE_SOURCE_DIR}/../testdata/scad/bugs/issue899.scad)
list(APPEND ALL_2D_FILES ${CMAKE_SOURCE_DIR}/../testdata/scad/bugs/issue899.scad)

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB