std::pair<Point_3, Dart_handle> operator () (Vertex & v) const { Dart_handle d = v.dart (); int degree = 0; bool open = false; LCC::One_dart_per_incident_cell_range<1,0>::iterator it (mlcc, d), itend(mlcc.one_dart_per_incident_cell<1,0>(d).end()); for (; it != itend; ++it) { ++degree; if (mlcc.is_free(it, 2)) open = true; } if (open) return make_pair(v.point(), d); LCC::FT alpha = (4.0f - 2.0f * (LCC::FT) cos (2.0f * PI / (LCC::FT) degree)) / 9.0f; LCC::Vector vec = LCC::Traits::Construct_scaled_vector() ( LCC::Traits::Construct_vector() (CGAL::ORIGIN, v.point()), (1.0f - alpha)); for (it.rewind (); it != itend; ++it) { CGAL_assertion (!mlcc.is_free(it,2)); vec = vec + (mlcc.point(mlcc.beta(it,2)) - CGAL::ORIGIN) * alpha / degree; } std::pair<Point_3, Dart_handle> res=std::make_pair (LCC::Traits::Construct_translated_point() (CGAL::ORIGIN, vec), d); return res; }
Vertex operator () (Vertex & v) const { Dart_handle d = v.dart (); // Old points aren't concerned. if (mlcc.is_marked(d, old)) { return v; } std::vector<LCC::Point> facetsPoints; facetsPoints.resize(0); // We search barycenter point of incidents facets. for (LCC::One_dart_per_incident_cell_range<1,0>::iterator it = mlcc.one_dart_per_incident_cell<1,0>(d).begin(); it != mlcc.one_dart_per_incident_cell<1,0>(d).end(); ++it) { // If the vertex is on a border. if (mlcc.is_free(it,2)) { return v; } // If we found barycenter of a facet. if (!mlcc.is_marked(mlcc.opposite(it), old)) { facetsPoints.push_back(mlcc.point(mlcc.opposite(it))); } } // If we found more than two points we are on a vertice barycenter of a facet. // They aren't concerned. if (facetsPoints.size() > 2 || facetsPoints.size() < 2) { return v; } // Average. LCC::Vector averageFacetsV = LCC::Traits::Construct_vector() ( CGAL::ORIGIN, LCC::Point(0,0,0) ); for (unsigned int i=0; i < facetsPoints.size(); i++) { averageFacetsV = LCC::Traits::Construct_sum_of_vectors() (averageFacetsV, LCC::Traits::Construct_vector() (CGAL::ORIGIN, facetsPoints[i])); } averageFacetsV = LCC::Traits::Construct_scaled_vector() ( averageFacetsV, (1.0f/facetsPoints.size()) ); // Barycenter point. LCC::Vector barycenterV = LCC::Traits::Construct_sum_of_vectors() ( LCC::Traits::Construct_vector() (CGAL::ORIGIN, v.point()), averageFacetsV ); barycenterV = LCC::Traits::Construct_scaled_vector() ( barycenterV, (1.0f/2.0f) ); Vertex res = LCC::Traits::Construct_translated_point() (CGAL::ORIGIN, barycenterV); res.set_dart (d); return res; }
Vertex operator () (Vertex & v) const { Dart_handle d = v.dart (); // Just old points are concerned. if (!mlcc.is_marked(d, old)) { return v; } unsigned int degree = 0; std::vector<LCC::Point> edgesPoints; edgesPoints.resize(0); std::vector<LCC::Point> facetsPoints; facetsPoints.resize(0); // We search barycenter point of incidents facets, and incidents edges points. for (LCC::One_dart_per_incident_cell_range<1,0>::iterator it = mlcc.one_dart_per_incident_cell<1,0>(d).begin(); it != mlcc.one_dart_per_incident_cell<1,0>(d).end(); ++it) { // If the vertex is on a border if (mlcc.is_free(it,2)) { return v; } // If incident isn't an old point, it's an edge point. if (!mlcc.is_marked(mlcc.opposite(it), old)) { edgesPoints.push_back (mlcc.point(mlcc.opposite(it))); } // We go find the "facet point" of incidents facet (barycenter of a facet). facetsPoints.push_back (mlcc.point(mlcc.beta(mlcc.opposite(it), 0))); ++degree; } CGAL_assertion (facetsPoints.size() != 0 && edgesPoints.size() != 0); if (facetsPoints.size() < 3 || edgesPoints.size() < 3 ) { return v; } // Average of incidents "edge points". LCC::Vector averageEdgesV = LCC::Traits::Construct_vector() (CGAL::ORIGIN, LCC::Point(0,0,0)); for (unsigned int i=0; i < edgesPoints.size(); i++) { averageEdgesV = LCC::Traits::Construct_sum_of_vectors() ( averageEdgesV, LCC::Traits::Construct_vector() (CGAL::ORIGIN, edgesPoints[i])); } averageEdgesV = LCC::Traits::Construct_scaled_vector() ( averageEdgesV, 1.0f/ (LCC::FT) edgesPoints.size() ); // Average of incidents "facet points". LCC::Vector averageFacetsV = LCC::Traits::Construct_vector() (CGAL::ORIGIN, LCC::Point(0,0,0)); for (unsigned int i=0; i < facetsPoints.size(); i++) { averageFacetsV = LCC::Traits::Construct_sum_of_vectors() ( averageFacetsV, LCC::Traits::Construct_vector() (CGAL::ORIGIN, facetsPoints[i])); } averageFacetsV = LCC::Traits::Construct_scaled_vector() ( averageFacetsV, (1.0f/ (LCC::FT) facetsPoints.size()) ); // COEFFICIENTS of PQQ - Catmull–Clark subdivision : // point = ( averageFacets + 2*averageEdges + point*(degree-3) )/degree averageFacetsV = LCC::Traits::Construct_scaled_vector() ( averageFacetsV, 1.0f/ (LCC::FT) degree); averageEdgesV = LCC::Traits::Construct_scaled_vector() ( averageEdgesV, 2.0f/ (LCC::FT) degree); LCC::Vector pointV = LCC::Traits::Construct_scaled_vector() ( LCC::Traits::Construct_vector() (CGAL::ORIGIN, v.point() ), (LCC::FT) (degree-3)/ (LCC::FT) degree ); // New position of the old point. LCC::Vector newPosition = LCC::Traits::Construct_sum_of_vectors() ( averageFacetsV, averageEdgesV); newPosition = LCC::Traits::Construct_sum_of_vectors() ( newPosition, pointV); Vertex res = LCC::Traits::Construct_translated_point() (CGAL::ORIGIN, newPosition); res.set_dart (d); return res; }