prevent crash in CGAL nef3. fix #issue 410 . also deal w qmake bug re .h files

brodykenrick-master
Don Bright 2013-11-26 20:04:57 -06:00
parent b204aba444
commit cf9f19818c
5 changed files with 43 additions and 10 deletions

View File

@ -39,6 +39,7 @@ debug: DEFINES += DEBUG
TEMPLATE = app
INCLUDEPATH += src
DEPENDPATH += src
# Handle custom library location.
# Used when manually installing 3rd party libraries
@ -368,6 +369,7 @@ HEADERS += src/cgal.h \
src/PolySetCGALEvaluator.h \
src/CGALRenderer.h \
src/CGAL_Nef_polyhedron.h \
src/CGAL_Nef3_workaround.h \
src/cgalworker.h
SOURCES += src/cgalutils.cc \

View File

@ -159,9 +159,19 @@ CGAL_Nef_polyhedron CGALEvaluator::applyHull(const CgaladvNode &node)
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);
std::transform(P.vertices_begin(), P.vertices_end(), std::back_inserter(points3d),
boost::bind(static_cast<const CGAL_Polyhedron::Vertex::Point_3&(CGAL_Polyhedron::Vertex::*)() const>(&CGAL_Polyhedron::Vertex::point), _1));
bool err = false;
try{
err = nefworkaround::convert_to_Polyhedron<CGAL_Kernel3>( *(chN.p3), P );
//chN.p3->convert_to_Polyhedron(P);
} catch (...) {
err = true;
}
if (err) {
PRINT("ERROR: CGAL NefPolyhedron->Polyhedron conversion failed");
} else {
std::transform(P.vertices_begin(), P.vertices_end(), std::back_inserter(points3d),
boost::bind(static_cast<const CGAL_Polyhedron::Vertex::Point_3&(CGAL_Polyhedron::Vertex::*)() const>(&CGAL_Polyhedron::Vertex::point), _1));
}
}
}
chnode->progress_report();

View File

@ -98,11 +98,22 @@ PolySet *CGAL_Nef_polyhedron::convertToPolyset()
CGAL::Failure_behaviour old_behaviour = CGAL::set_error_behaviour(CGAL::THROW_EXCEPTION);
try {
CGAL_Polyhedron P;
this->p3->convert_to_Polyhedron(P);
ps = createPolySetFromPolyhedron(P);
bool err = nefworkaround::convert_to_Polyhedron<CGAL_Kernel3>( *(this->p3), P );
//this->p3->convert_to_Polyhedron(P);
if (err) {
PRINT("ERROR: CGAL NefPolyhedron->Polyhedron conversion failed");
} else {
ps = createPolySetFromPolyhedron(P);
}
}
catch (const CGAL::Precondition_exception &e) {
PRINTB("CGAL error in CGAL_Nef_polyhedron::convertToPolyset(): %s", e.what());
PRINTB("CGAL Precondition error in CGAL_Nef_polyhedron::convertToPolyset(): %s", e.what());
}
catch (const CGAL::Assertion_exception &e) {
PRINTB("CGAL Assertion error in CGAL_Nef_polyhedron::convertToPolyset(): %s", e.what());
}
catch (...) {
PRINT("CGAL unknown error in CGAL_Nef_polyhedron::convertToPolyset()");
}
CGAL::set_error_behaviour(old_behaviour);
}

View File

@ -27,6 +27,7 @@ using boost::uintmax_t;
#include <CGAL/Cartesian.h>
#include <CGAL/Polyhedron_3.h>
#include <CGAL/Nef_polyhedron_3.h>
#include <CGAL_Nef3_workaround.h>
#include <CGAL/IO/Polyhedron_iostream.h>
#include <CGAL/Exact_predicates_exact_constructions_kernel.h>
#include <CGAL/Polygon_2.h>
@ -48,9 +49,10 @@ typedef CGAL::Exact_predicates_exact_constructions_kernel CGAL_ExactKernel2;
typedef CGAL::Polygon_2<CGAL_ExactKernel2> CGAL_Poly2;
typedef CGAL::Polygon_with_holes_2<CGAL_ExactKernel2> CGAL_Poly2h;
//typedef CGAL::Cartesian<NT> CGAL_Kernel3;
typedef CGAL::Exact_predicates_exact_constructions_kernel CGAL_Kernel3;
typedef CGAL::Exact_predicates_exact_constructions_kernel::FT NT3;
typedef CGAL::Gmpq NT3;
typedef CGAL::Cartesian<NT3> CGAL_Kernel3;
//typedef CGAL::Exact_predicates_exact_constructions_kernel::FT NT3;
//typedef CGAL::Exact_predicates_exact_constructions_kernel CGAL_Kernel3;
typedef CGAL::Nef_polyhedron_3<CGAL_Kernel3> CGAL_Nef_polyhedron3;
typedef CGAL_Nef_polyhedron3::Aff_transformation_3 CGAL_Aff_transformation;

View File

@ -42,7 +42,12 @@ void export_stl(CGAL_Nef_polyhedron *root_N, std::ostream &output)
CGAL::Failure_behaviour old_behaviour = CGAL::set_error_behaviour(CGAL::THROW_EXCEPTION);
try {
CGAL_Polyhedron P;
root_N->p3->convert_to_Polyhedron(P);
//root_N->p3->convert_to_Polyhedron(P);
bool err = nefworkaround::convert_to_Polyhedron<CGAL_Kernel3>( *(root_N->p3), P );
if (err) {
PRINT("ERROR: CGAL NefPolyhedron->Polyhedron conversion failed");
return;
}
typedef CGAL_Polyhedron::Vertex Vertex;
typedef CGAL_Polyhedron::Vertex_const_iterator VCI;
@ -114,6 +119,9 @@ void export_stl(CGAL_Nef_polyhedron *root_N, std::ostream &output)
catch (const CGAL::Assertion_exception &e) {
PRINTB("CGAL error in CGAL_Nef_polyhedron3::convert_to_Polyhedron(): %s", e.what());
}
catch (...) {
PRINT("CGAL unknown error in CGAL_Nef_polyhedron3::convert_to_Polyhedron()");
}
CGAL::set_error_behaviour(old_behaviour);
}