diff --git a/cgal/data/issue1105.polygon b/cgal/data/issue1105.polygon new file mode 100644 index 00000000..15809c1f --- /dev/null +++ b/cgal/data/issue1105.polygon @@ -0,0 +1,4 @@ +6, -25, 29.285714285714285 +6, -26.732050855686023, 29.020513307787397 +6, -26.732050855686026, 29.020513307787397 +6, -26, 29.132600433972414 diff --git a/cgal/polyhole-tessellator.cpp b/cgal/polyhole-tessellator.cpp index 0fba0e36..7a433a24 100644 --- a/cgal/polyhole-tessellator.cpp +++ b/cgal/polyhole-tessellator.cpp @@ -1,10 +1,13 @@ #include +#include #include #include #include #include "cgalutils.h" + + // Nef polyhedron are using CGAL_Kernel3 (Cartesian) // Triangulation will use Epick @@ -95,12 +98,23 @@ bool import_polygon(PolyholeK &polyhole, const std::string &filename) int main(int argc, char *argv[]) { PolyholeK polyhole; - if (argc == 2) { + K::Vector_3 *normal = NULL; + if (argc >= 2) { if (!import_polygon(polyhole, argv[1])) { std::cerr << "Error importing polygon" << std::endl; exit(1); } std::cerr << "Imported " << polyhole.size() << " polygons" << std::endl; + + if (argc == 3) { + std::vector strs; + std::vector normalvec; + std::string arg(argv[2]); + boost::split(strs, arg, boost::is_any_of(",")); + assert(strs.size() == 3); + BOOST_FOREACH(const std::string &s, strs) normalvec.push_back(boost::lexical_cast(s)); + normal = new K::Vector_3(normalvec[0], normalvec[1], normalvec[2]); + } } else { //construct two non-intersecting nested polygons @@ -119,7 +133,7 @@ int main(int argc, char *argv[]) } Polygons triangles; - bool ok = CGALUtils::tessellatePolygonWithHoles(polyhole, triangles); + bool ok = CGALUtils::tessellatePolygonWithHoles(polyhole, triangles, normal); std::cerr << "Tessellated into " << triangles.size() << " triangles" << std::endl; export_stl(triangles, std::cout);