From 55dbf512eccdd000f358fc19812417ae8adbf268 Mon Sep 17 00:00:00 2001 From: Pablo Garzon Date: Fri, 14 Apr 2023 11:08:04 +0200 Subject: [PATCH] #3502 Bug close surface in CreateMeshFromPoints --- .../src/bbcreaVtkCreateMeshFromPoints.cxx | 32 +++++++++---------- 1 file changed, 15 insertions(+), 17 deletions(-) diff --git a/bbtk_creaVtk_PKG/src/bbcreaVtkCreateMeshFromPoints.cxx b/bbtk_creaVtk_PKG/src/bbcreaVtkCreateMeshFromPoints.cxx index f32a210..c794d40 100644 --- a/bbtk_creaVtk_PKG/src/bbcreaVtkCreateMeshFromPoints.cxx +++ b/bbtk_creaVtk_PKG/src/bbcreaVtkCreateMeshFromPoints.cxx @@ -37,7 +37,7 @@ void CreateMeshFromPoints::Process() std::vector lstY = bbGetInputLstY(); std::vector lstZ = bbGetInputLstZ(); std::vector 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 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(¢roid)[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])){ -- 2.47.1