+ bbSetOutputOut( triangle->GetOutput() );
+ // bbSetOutputOut( clean->GetOutput() );
+ }// if listXYZ size
+ //printf("PG CreateMeshFromPoints::Process: End\n");
+}
+/**
+* Closes the sides of the contour
+* iterates in one way or the other, depending on the order of the points and calculated vectors.
+* uPointOrder: Points are order in a U shape
+* lstIndexs: number of points on each spline
+*/
+void CreateMeshFromPoints::CloseContourSides(std::vector<int> lstIndexs, bool uPointOrder, bool isClosedCont){
+ int sizeLstIdexes = lstIndexs.size();
+ int sizePoints = bbGetInputLstX().size();
+
+ int firstIndex, end, centroidId, numPointsFace, contraryId;
+ int increment = uPointOrder?1:sizeLstIdexes;
+ double centroid[3];
+ int numProcessFaces = sizeLstIdexes > 1?2:1;
+ for(int facesIdx = 0; facesIdx < numProcessFaces; facesIdx++){
+ std::fill(std::begin(centroid), std::end(centroid), 0);
+ if(facesIdx == 0)
+ {
+ firstIndex = 0;
+ numPointsFace = uPointOrder?lstIndexs[0]: sizeLstIdexes;
+ end = uPointOrder?firstIndex + numPointsFace:sizePoints - lstIndexs[sizeLstIdexes - 1] + 1;
+ contraryId = sizePoints-1;
+ }else{
+ firstIndex = uPointOrder?sizePoints - lstIndexs[sizeLstIdexes-1]:lstIndexs[0]-1;
+ numPointsFace = uPointOrder?lstIndexs[sizeLstIdexes-1]:sizeLstIdexes;
+ end = uPointOrder?firstIndex + numPointsFace:sizePoints;
+ contraryId = 0;
+ }
+ if(numPointsFace > 1)
+ {
+ bool validCentroid = CalcValidCentroid(centroid, firstIndex, end, increment, numPointsFace);
+ if(validCentroid)
+ {
+ bool normalOrder = isPointingCorrectly(firstIndex, firstIndex+increment, centroid, contraryId);
+ centroidId = points->InsertNextPoint(centroid[0], centroid[1], centroid[2]);
+ if( normalOrder )
+ {
+ int initial = firstIndex;
+ for(int index = initial; index < end; index+=increment){
+ if(index+increment >= end && !isClosedCont){
+ vtkNew<vtkTriangle> triangle;
+ triangle->GetPointIds()->SetId(0, index);
+ triangle->GetPointIds()->SetId(1, initial);
+ triangle->GetPointIds()->SetId(2, centroidId);
+ cells->InsertNextCell(triangle);
+ }else if(index+increment < end){
+ vtkNew<vtkTriangle> triangle;
+ triangle->GetPointIds()->SetId(0, index);
+ triangle->GetPointIds()->SetId(1, index+increment);
+ triangle->GetPointIds()->SetId(2, centroidId);
+ cells->InsertNextCell(triangle);
+ }
+ }
+ } else {
+ int initial = firstIndex-1;
+ int triangleStripStart = end-1;
+ for(int index = triangleStripStart; index > initial; index-=increment){
+ if(index-increment <= initial && !isClosedCont){
+ vtkNew<vtkTriangle> triangle;
+ triangle->GetPointIds()->SetId(0, index);
+ triangle->GetPointIds()->SetId(1, triangleStripStart);
+ triangle->GetPointIds()->SetId(2, centroidId);
+ cells->InsertNextCell(triangle);
+ }else if(index-increment > initial){
+ vtkNew<vtkTriangle> triangle;
+ triangle->GetPointIds()->SetId(0, index);
+ triangle->GetPointIds()->SetId(1, index-increment);
+ triangle->GetPointIds()->SetId(2, centroidId);
+ cells->InsertNextCell(triangle);
+ }
+ }
+ }
+ }//if validCentroid
+ }//if numPointsFace
+ }//for facesIdx
+
+}