]> Creatis software - creaVtk.git/commitdiff
#3502 Bug close surface in CreateMeshFromPoints
authorPablo Garzon <garzon@ei-pfe-706.creatis.insa-lyon.fr>
Tue, 28 Mar 2023 12:15:31 +0000 (14:15 +0200)
committerPablo Garzon <garzon@ei-pfe-706.creatis.insa-lyon.fr>
Tue, 28 Mar 2023 12:15:31 +0000 (14:15 +0200)
bbtk_creaVtk_PKG/src/bbcreaVtkCreateMeshFromPoints.cxx

index 463e632ca411f127a9a7f0f9e0cd8473252007c8..bfe74d4182d5d7abb6b93a90010012312ab2de9c 100644 (file)
@@ -160,17 +160,19 @@ void CreateMeshFromPoints::CloseContourSides(std::vector<int> lstIndexs, bool uP
                                bool normalOrder    = isPointingCorrectly(firstIndex, firstIndex+increment, centroid, contraryId);
                                centroidId          = points->InsertNextPoint(centroid[0], centroid[1], centroid[2]);
                                vtkSmartPointer<vtkTriangleStrip> triangleStrip1 = vtkSmartPointer<vtkTriangleStrip>::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<int> 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;
 }