int CMeshCutting::FillHole(KW_Mesh& Mesh,vector<Halfedge_handle> hhClosedCurve) { //fill the hole of hhClosedCurve Mesh.fill_hole(hhClosedCurve.front()); Mesh.normalize_border(); int test00=Mesh.size_of_border_edges(); assert(test00==0); //create a center vertex vector<Point_3> EdgePoints; for (unsigned int i=0;i<this->hCuttingClosedCurveVertex3d.size();i++) { EdgePoints.push_back(this->hCuttingClosedCurveVertex3d.at(i)->point()); } Point_3 CentroidPoint=CGAL::centroid(EdgePoints.begin(),EdgePoints.end()); Halfedge_handle hhToCenterPoint=Mesh.create_center_vertex(hhClosedCurve.front()); hhToCenterPoint->vertex()->point()=CentroidPoint; //Halfedge_handle hhStart=hhClosedCurve.front(); //while (true) //{ // int iFacetDegree=hhStart->facet()->facet_degree(); // if (iFacetDegree==3) // { // break; // } // Halfedge_handle hhNewStart; // if (iFacetDegree%2==0) // { // hhNewStart=Mesh.split_facet(hhStart->next(),hhStart->prev()); // } // else // { // hhNewStart=Mesh.split_facet(hhStart,hhStart->prev()->prev()); // } // hhStart=hhNewStart->opposite(); //} Mesh.normalize_border(); assert(Mesh.size_of_border_edges()==0); return 0; }
int CMeshCutting::DeleteFacets(KW_Mesh& Mesh,vector<Halfedge_handle> hhClosedCurve) { //triangle incident to hhClosedCurve->opposite(outside the closed curve) vector<Facet_handle> fhCurveOutTri; //triangle incident to hhClosedCurve(inside the closed curve) vector<Facet_handle> fhCurveInTri; for (unsigned int i=0;i<hhClosedCurve.size();i++) { Halfedge_handle hhCurrent=hhClosedCurve.at(i); Halfedge_handle hhOpp=hhCurrent->opposite(); fhCurveInTri.push_back(hhCurrent->facet()); fhCurveOutTri.push_back(hhOpp->facet()); } assert(fhCurveInTri.size()==fhCurveOutTri.size()); int test10=Mesh.size_of_facets(); //delete fhCurveInTri first for (unsigned int i=0;i<fhCurveInTri.size();i++) { Mesh.erase_facet(fhCurveInTri.at(i)->halfedge()); } Mesh.normalize_border(); int test11=Mesh.size_of_facets(); assert(fhCurveInTri.size()+test11==test10); vector<Facet_handle> fhWithBorderEdge; while (GetFacetsWithBorderEdge(Mesh,fhWithBorderEdge,fhCurveOutTri)) { for (unsigned int i=0;i<fhWithBorderEdge.size();i++) { Mesh.erase_facet(fhWithBorderEdge.at(i)->halfedge()); } fhWithBorderEdge.clear(); Mesh.normalize_border(); } return 0; }