X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=bbtk_creaVtk_PKG%2Fsrc%2FbbcreaVtkCreateMeshFromPoints.cxx;h=c794d404e66043e165af0fd6449a069061ad4448;hb=55dbf512eccdd000f358fc19812417ae8adbf268;hp=194c3780f0940395ea86a8af42385f6282240920;hpb=474a0f3cd44a108f172a412545fbd7b2d716ed8f;p=creaVtk.git diff --git a/bbtk_creaVtk_PKG/src/bbcreaVtkCreateMeshFromPoints.cxx b/bbtk_creaVtk_PKG/src/bbcreaVtkCreateMeshFromPoints.cxx index 194c378..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,28 +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]; - - //bool closedLineOrd = !altFace1open && !altFace2open; - - //isClosedCont = !face1open && !face2open; - 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) @@ -137,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. @@ -151,8 +147,8 @@ void CreateMeshFromPoints::CloseContourSides(std::vector lstIndexs, bool uP int firstIndex, end, centroidId, numPointsFace, contraryId; int increment = uPointOrder?1:sizeLstIdexes; double centroid[3]; - - for(int facesIdx = 0; facesIdx < 2; facesIdx++){ + 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) { @@ -186,8 +182,6 @@ void CreateMeshFromPoints::CloseContourSides(std::vector lstIndexs, bool uP triangleStrip1->GetPointIds()->SetId(triangleIndex+2,initial);//2 triangleStrip1->GetPointIds()->SetId(triangleIndex+3,centroidId);//3 } - //else{ - //} triangleIndex+=2; } cells->InsertNextCell(triangleStrip1); @@ -202,8 +196,6 @@ void CreateMeshFromPoints::CloseContourSides(std::vector lstIndexs, bool uP triangleStrip1->GetPointIds()->SetId(triangleIndex+2,triangleStripStart); triangleStrip1->GetPointIds()->SetId(triangleIndex+3,centroidId); } - //else{ - //} triangleIndex+=2; } cells->InsertNextCell(triangleStrip1); @@ -297,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])){