diff options
author | don bright <hugh.m.bright@gmail.com> | 2013-03-11 02:35:30 (GMT) |
---|---|---|
committer | don bright <hugh.m.bright@gmail.com> | 2013-03-11 02:35:30 (GMT) |
commit | 5559ae9a6af459021c5b7ab4a823f491dce822a0 (patch) | |
tree | ccea074154b71c24ab0aee3150d4b07eef896a05 /src/cgalutils.cc | |
parent | 33a54b52f2c54c4ac66881d63b852b472f5589f1 (diff) |
move transform from CGALEvaluator to Nef_polyhedron - reuse in resize(). also
move ZRemover code to cgalutils, also cleanup SVG code
Diffstat (limited to 'src/cgalutils.cc')
-rw-r--r-- | src/cgalutils.cc | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/src/cgalutils.cc b/src/cgalutils.cc index 66d4b18..8b4c476 100644 --- a/src/cgalutils.cc +++ b/src/cgalutils.cc @@ -173,5 +173,56 @@ CGAL_Iso_rectangle_2e bounding_box( const CGAL_Nef_polyhedron2 &N ) return result; } +void ZRemover::visit( CGAL_Nef_polyhedron3::Halffacet_const_handle hfacet ) +{ + log << " <!-- ZRemover Halffacet visit. Mark: " << hfacet->mark() << " -->\n"; + if ( hfacet->plane().orthogonal_direction() != this->up ) { + log << " <!-- ZRemover down-facing half-facet. skipping -->\n"; + log << " <!-- ZRemover Halffacet visit end-->\n"; + return; + } + + // possible optimization - throw out facets that are vertically oriented + + CGAL_Nef_polyhedron3::Halffacet_cycle_const_iterator fci; + int contour_counter = 0; + CGAL_forall_facet_cycles_of( fci, hfacet ) { + if ( fci.is_shalfedge() ) { + log << " <!-- ZRemover Halffacet cycle begin -->\n"; + CGAL_Nef_polyhedron3::SHalfedge_around_facet_const_circulator c1(fci), cend(c1); + std::vector<CGAL_Nef_polyhedron2::Explorer::Point> contour; + CGAL_For_all( c1, cend ) { + CGAL_Nef_polyhedron3::Point_3 point3d = c1->source()->target()->point(); + CGAL_Nef_polyhedron2::Explorer::Point point2d( point3d.x(), point3d.y() ); + contour.push_back( point2d ); + } + if (contour.size()==0) continue; + + log << " <!-- is_simple_2:" << CGAL::is_simple_2( contour.begin(), contour.end() ) << " --> \n"; + + tmpnef2d.reset( new CGAL_Nef_polyhedron2( contour.begin(), contour.end(), boundary ) ); + + if ( contour_counter == 0 ) { + log << " <!-- contour is a body. make union(). " << contour.size() << " points. -->\n" ; + *(output_nefpoly2d) += *(tmpnef2d); + } else { + log << " <!-- contour is a hole. make intersection(). " << contour.size() << " points. -->\n"; + *(output_nefpoly2d) *= *(tmpnef2d); + } + + /*log << "\n<!-- ======== output tmp nef: ==== -->\n" + << OpenSCAD::dump_svg( *tmpnef2d ) << "\n" + << "\n<!-- ======== output accumulator: ==== -->\n" + << OpenSCAD::dump_svg( *output_nefpoly2d ) << "\n";*/ + + contour_counter++; + } else { + log << " <!-- ZRemover trivial facet cycle skipped -->\n"; + } + log << " <!-- ZRemover Halffacet cycle end -->\n"; + } + log << " <!-- ZRemover Halffacet visit end -->\n"; +} + #endif /* ENABLE_CGAL */ |