From: Pablo Garzon Date: Tue, 28 Mar 2023 12:15:31 +0000 (+0200) Subject: #3502 Bug close surface in CreateMeshFromPoints X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=1c64ff05e9d47bc02f19370b0cefa3f1ad9af1cf;p=creaVtk.git #3502 Bug close surface in CreateMeshFromPoints --- diff --git a/bbtk_creaVtk_PKG/src/bbcreaVtkCreateMeshFromPoints.cxx b/bbtk_creaVtk_PKG/src/bbcreaVtkCreateMeshFromPoints.cxx index 463e632..bfe74d4 100644 --- a/bbtk_creaVtk_PKG/src/bbcreaVtkCreateMeshFromPoints.cxx +++ b/bbtk_creaVtk_PKG/src/bbcreaVtkCreateMeshFromPoints.cxx @@ -160,17 +160,19 @@ void CreateMeshFromPoints::CloseContourSides(std::vector lstIndexs, bool uP bool normalOrder = isPointingCorrectly(firstIndex, firstIndex+increment, centroid, contraryId); centroidId = points->InsertNextPoint(centroid[0], centroid[1], centroid[2]); vtkSmartPointer triangleStrip1 = vtkSmartPointer::New(); - triangleStrip1->GetPointIds()->SetNumberOfIds(numPointsFace*2+2); + triangleStrip1->GetPointIds()->SetNumberOfIds(numPointsFace*2+1); if( normalOrder ) { int initial = firstIndex; int triangleIndex = 0; for(int index = initial; index < end; index+=increment){ triangleStrip1->GetPointIds()->SetId(triangleIndex,index); - triangleStrip1->GetPointIds()->SetId(triangleIndex+1,centroidId); if(index+increment >= end){ - triangleStrip1->GetPointIds()->SetId(triangleIndex+2,initial); - triangleStrip1->GetPointIds()->SetId(triangleIndex+3,centroidId); + triangleStrip1->GetPointIds()->SetId(triangleIndex+1,initial);//2 + triangleStrip1->GetPointIds()->SetId(triangleIndex+2,centroidId);//3 + } + else{ + triangleStrip1->GetPointIds()->SetId(triangleIndex+1,centroidId);//1 } triangleIndex+=2; } @@ -181,10 +183,11 @@ void CreateMeshFromPoints::CloseContourSides(std::vector lstIndexs, bool uP int triangleStripStart = end-1; for(int index = triangleStripStart; index > initial; index-=increment){ triangleStrip1->GetPointIds()->SetId(triangleIndex,index); - triangleStrip1->GetPointIds()->SetId(triangleIndex+1,centroidId); if(index-increment <= initial){ - triangleStrip1->GetPointIds()->SetId(triangleIndex+2,triangleStripStart); - triangleStrip1->GetPointIds()->SetId(triangleIndex+3,centroidId); + triangleStrip1->GetPointIds()->SetId(triangleIndex+1,triangleStripStart); + triangleStrip1->GetPointIds()->SetId(triangleIndex+2,centroidId); + }else{ + triangleStrip1->GetPointIds()->SetId(triangleIndex+1,centroidId); } triangleIndex+=2; } @@ -219,7 +222,7 @@ bool CreateMeshFromPoints::isPointingCorrectly( int firstPointId, int secPointId double dotCalc; dotCalc = vtkMath::Dot(normal, contrVect); - return dotCalc>0; + return dotCalc<0; } /** @@ -232,24 +235,25 @@ bool CreateMeshFromPoints::CheckLinePointOrder(){ double center[3]; double firstRadiusSum = 0; double secondRadiusSum = 0; - for(int i = 0; i < lstIndexs[0] && lstIndexs[0] > 3; i+=3){ - if(i+3 <= lstIndexs[0]){ + for(int i = 0; i < lstIndexs[0] && lstIndexs[0] > 9; i+=5){ + if(i+10 < lstIndexs[0]){ points->GetPoint(i, point1); - points->GetPoint(i+1, point2); - points->GetPoint(i+2, point3); + points->GetPoint(i+5, point2); + points->GetPoint(i+10, point3); firstRadiusSum += vtkMath::Solve3PointCircle(point1, point2, point3, center); } } - for(int i = 0; i < sizePoints && lstIndexs.size() > 3; i+=(lstIndexs[0]*3)){ - if(i+(3*lstIndexs[0]) <= sizePoints){ + for(int i = 0; i < sizePoints && lstIndexs.size() > 9; i+=(lstIndexs.size()*5)){ + if(i+(10*lstIndexs.size()) < sizePoints){ points->GetPoint(i, point1); - points->GetPoint(i+lstIndexs[0], point2); - points->GetPoint(i+(2*lstIndexs[0]), point3); + points->GetPoint(i+(5*lstIndexs.size()), point2); + points->GetPoint(i+(10*lstIndexs.size()), point3); secondRadiusSum += vtkMath::Solve3PointCircle(point1, point2, point3, center); } } - + //cout << firstRadiusSum << endl; + //cout << secondRadiusSum << endl; return firstRadiusSum > secondRadiusSum; }