]> Creatis software - creaVtk.git/commitdiff
#3502 Bug close surface in CreateMeshFromPoints
authorPablo Garzon <gapablo2001@gmail.com>
Fri, 14 Apr 2023 09:08:04 +0000 (11:08 +0200)
committerPablo Garzon <gapablo2001@gmail.com>
Fri, 14 Apr 2023 09:08:04 +0000 (11:08 +0200)
bbtk_creaVtk_PKG/src/bbcreaVtkCreateMeshFromPoints.cxx

index f32a210e5feb9fcdc472de48bfa62047257574a4..c794d404e66043e165af0fd6449a069061ad4448 100644 (file)
@@ -37,7 +37,7 @@ void CreateMeshFromPoints::Process()
                std::vector<double> lstY                = bbGetInputLstY();
                std::vector<double> lstZ                = bbGetInputLstZ();
                std::vector<int> lstIndexs              = bbGetInputLstIndexs();
-               if ( (lstIndexs.size()<=1) || (lstX.size()==0) || (lstX.size()!=lstY.size()) || (lstY.size()!=lstZ.size()) )
+               if ( (lstIndexs.size()<1) || (lstX.size()==0) || (lstX.size()!=lstY.size()) || (lstY.size()!=lstZ.size()) )
                {
                        printf("Warning! CreateMeshFromPoints::Process: List of points X Y Z  and LstIndexes is not correct\n");
                        bbSetOutputOut(NULL);
@@ -78,25 +78,25 @@ void CreateMeshFromPoints::Process()
                                        triangleStrip->GetPointIds()->SetId(ii*2+1,iSeg2);
                                        iSeg1++;
                                        iSeg2++;
-                    if (iSeg1>=maxSegment1) { iSeg1=maxSegment1-1; }
-                    if (iSeg2>=maxSegment2) { iSeg2=maxSegment2-1; }
+                       if (iSeg1>=maxSegment1) { iSeg1=maxSegment1-1; }
+                       if (iSeg2>=maxSegment2) { iSeg2=maxSegment2-1; }
                                } // for ii 
                                iGeneral=iGeneral+sizeSegment1;
                                cells->InsertNextCell(triangleStrip);
                        } //for  LstIndexs
 
-                       int lastId1 = lstIndexs[0]-1;
-                       int lastId2 = sizeLstX - 1;
-                       int firstId2 = sizeLstX - lstIndexs[sizeLstIdexes - 1];
-                       bool face1open = lstX[0] != lstX[lastId1] && lstY[0] != lstY[lastId1] && lstZ[0] != lstZ[lastId1];
-                       bool face2open = lstX[firstId2] != lstX[lastId2] && lstY[firstId2] != lstY[lastId2] && lstZ[firstId2] != lstZ[lastId2];
-                       
-                       bool altFace1open = lstX[0] != lstX[firstId2] && lstY[0] != lstY[firstId2] && lstZ[0] != lstZ[firstId2];
-                       bool altFace2open = lstX[lastId1] != lstX[lastId2] && lstY[lastId1] != lstY[lastId2] && lstZ[lastId1] != lstZ[lastId2];
-                       
-                       isClosedCont = false;
                        if(bbGetInputCloseSurface())
                        {                       
+                               int lastId1 = lstIndexs[0]-1;
+                               int lastId2 = sizeLstX - 1;
+                               int firstId2 = sizeLstX - lstIndexs[sizeLstIdexes - 1];
+                               bool face1open = lstX[0] != lstX[lastId1] && lstY[0] != lstY[lastId1] && lstZ[0] != lstZ[lastId1];
+                               bool face2open = lstX[firstId2] != lstX[lastId2] && lstY[firstId2] != lstY[lastId2] && lstZ[firstId2] != lstZ[lastId2];
+                               
+                               bool altFace1open = lstX[0] != lstX[firstId2] && lstY[0] != lstY[firstId2] && lstZ[0] != lstZ[firstId2];
+                               bool altFace2open = lstX[lastId1] != lstX[lastId2] && lstY[lastId1] != lstY[lastId2] && lstZ[lastId1] != lstZ[lastId2];
+                               
+                               isClosedCont = false;
                                //false = Open Contour
                                //true = Closed Contour
                                if(!face1open && !face2open)
@@ -134,7 +134,6 @@ void CreateMeshFromPoints::Process()
                }// 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.
@@ -149,7 +148,6 @@ void CreateMeshFromPoints::CloseContourSides(std::vector<int> lstIndexs, bool uP
        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)
@@ -291,11 +289,11 @@ bool CreateMeshFromPoints::CalcValidCentroid(double(&centroid)[3], int start, in
        bool samePoint = true;
        int splineMidPoint = numPoints/2;
        bool collinear = true;
-       
+
        points->GetPoint(start, firstPoint);
        points->GetPoint(splineMidPoint, middlePoint);
        vtkMath::Subtract(middlePoint, firstPoint, vector1);
-       
+
        for(int i = start; i < end; i+=increment){
                points->GetPoint(i, currPoint);
                if(samePoint && i > start && (currPoint[0] != prevPoint[0] || currPoint[1] != prevPoint[1] || currPoint[2] != prevPoint[2])){