diff options
author | Marius Kintel <marius@kintel.net> | 2011-09-06 12:57:24 (GMT) |
---|---|---|
committer | Marius Kintel <marius@kintel.net> | 2011-09-06 12:57:24 (GMT) |
commit | 1e4e18c52451d2f04050cb44441b615398882c56 (patch) | |
tree | 0fc51c818db83632e983c0720d1e497c83fedb01 /src/CGAL_Nef_polyhedron.cc | |
parent | fdd96a177c0fb3a94d317cb3e584b4881c09ea0e (diff) |
minkowski sums should now work again
Diffstat (limited to 'src/CGAL_Nef_polyhedron.cc')
-rw-r--r-- | src/CGAL_Nef_polyhedron.cc | 72 |
1 files changed, 42 insertions, 30 deletions
diff --git a/src/CGAL_Nef_polyhedron.cc b/src/CGAL_Nef_polyhedron.cc index 0c8c627..afe7119 100644 --- a/src/CGAL_Nef_polyhedron.cc +++ b/src/CGAL_Nef_polyhedron.cc @@ -1,6 +1,8 @@ #include "CGAL_Nef_polyhedron.h" #include "cgal.h" #include "polyset.h" +#include "dxfdata.h" +#include "dxftess.h" #include <CGAL/minkowski_sum_3.h> CGAL_Nef_polyhedron& CGAL_Nef_polyhedron::operator+=(const CGAL_Nef_polyhedron &other) @@ -48,38 +50,48 @@ int CGAL_Nef_polyhedron::weight() const */ PolySet *CGAL_Nef_polyhedron::convertToPolyset() { + assert(!this->empty()); PolySet *ps = new PolySet(); - CGAL_Polyhedron P; - this->p3->convert_to_Polyhedron(P); - - typedef CGAL_Polyhedron::Vertex Vertex; - typedef CGAL_Polyhedron::Vertex_const_iterator VCI; - typedef CGAL_Polyhedron::Facet_const_iterator FCI; - typedef CGAL_Polyhedron::Halfedge_around_facet_const_circulator HFCC; - - for (FCI fi = P.facets_begin(); fi != P.facets_end(); ++fi) { - HFCC hc = fi->facet_begin(); - HFCC hc_end = hc; - Vertex v1, v2, v3; - v1 = *VCI((hc++)->vertex()); - v3 = *VCI((hc++)->vertex()); - do { - v2 = v3; + if (this->dim == 2) { + DxfData *dd = this->convertToDxfData(); + ps->is2d = true; + dxf_tesselate(ps, *dd, 0, true, false, 0); + dxf_border_to_ps(ps, *dd); + delete dd; + } + else if (this->dim == 3) { + CGAL_Polyhedron P; + this->p3->convert_to_Polyhedron(P); + + typedef CGAL_Polyhedron::Vertex Vertex; + typedef CGAL_Polyhedron::Vertex_const_iterator VCI; + typedef CGAL_Polyhedron::Facet_const_iterator FCI; + typedef CGAL_Polyhedron::Halfedge_around_facet_const_circulator HFCC; + + for (FCI fi = P.facets_begin(); fi != P.facets_end(); ++fi) { + HFCC hc = fi->facet_begin(); + HFCC hc_end = hc; + Vertex v1, v2, v3; + v1 = *VCI((hc++)->vertex()); v3 = *VCI((hc++)->vertex()); - double x1 = CGAL::to_double(v1.point().x()); - double y1 = CGAL::to_double(v1.point().y()); - double z1 = CGAL::to_double(v1.point().z()); - double x2 = CGAL::to_double(v2.point().x()); - double y2 = CGAL::to_double(v2.point().y()); - double z2 = CGAL::to_double(v2.point().z()); - double x3 = CGAL::to_double(v3.point().x()); - double y3 = CGAL::to_double(v3.point().y()); - double z3 = CGAL::to_double(v3.point().z()); - ps->append_poly(); - ps->append_vertex(x1, y1, z1); - ps->append_vertex(x2, y2, z2); - ps->append_vertex(x3, y3, z3); - } while (hc != hc_end); + do { + v2 = v3; + v3 = *VCI((hc++)->vertex()); + double x1 = CGAL::to_double(v1.point().x()); + double y1 = CGAL::to_double(v1.point().y()); + double z1 = CGAL::to_double(v1.point().z()); + double x2 = CGAL::to_double(v2.point().x()); + double y2 = CGAL::to_double(v2.point().y()); + double z2 = CGAL::to_double(v2.point().z()); + double x3 = CGAL::to_double(v3.point().x()); + double y3 = CGAL::to_double(v3.point().y()); + double z3 = CGAL::to_double(v3.point().z()); + ps->append_poly(); + ps->append_vertex(x1, y1, z1); + ps->append_vertex(x2, y2, z2); + ps->append_vertex(x3, y3, z3); + } while (hc != hc_end); + } } return ps; } |