]> Creatis software - creaVtk.git/commitdiff
Clean code
authorEduardo DAVILA <davila@creatis.insa-lyon.fr>
Thu, 23 Mar 2023 10:48:26 +0000 (11:48 +0100)
committerEduardo DAVILA <davila@creatis.insa-lyon.fr>
Thu, 23 Mar 2023 10:48:26 +0000 (11:48 +0100)
bbtk_creaVtk_PKG/src/bbcreaVtkCreateMeshFromPoints.cxx
bbtk_creaVtk_PKG/src/bbcreaVtkGlyphPolyDataNormals.cxx
bbtk_creaVtk_PKG/src/bbcreaVtkPolyDataNormals.cxx
bbtk_creaVtk_PKG/src/bbcreaVtkPolyDataNormals.h

index a6948c45ee344c4fe7d6f3966b8ec98ba0df7242..69aab0853b9182bfbc92af097f6a8ca2fe5caf96 100644 (file)
@@ -96,8 +96,7 @@ void CreateMeshFromPoints::Process()
                                        CloseOpenContourSurface(lstIndexs);
                                }
                        }
-                       
-                       
+                    
 //                     vtkPolyData *polydata = vtkPolyData::New();
                        if (polydata!=NULL) polydata->Delete();
                        polydata = vtkPolyData::New();
@@ -113,7 +112,8 @@ void CreateMeshFromPoints::Process()
                        triangle = vtkTriangleFilter::New();
                        triangle->SetInputData( clean->GetOutput() );
                        triangle->Update();
-                       bbSetOutputOut( clean->GetOutput() );
+            bbSetOutputOut( triangle->GetOutput() );
+            //            bbSetOutputOut( clean->GetOutput() );
                }// if listXYZ size
                //printf("PG CreateMeshFromPoints::Process: End\n");
 }
@@ -150,11 +150,12 @@ void CreateMeshFromPoints::CloseContourSides(std::vector<int> lstIndexs, bool uP
                        double lastPoint[3] = {};
                        bool validCentroid = CalcValidCentroid(centroid, firstIndex, end, increment, numPointsFace);
                        if(validCentroid){
-                               bool normalOrder = isPointingCorrectly(firstIndex, firstIndex+increment, centroid, contraryId);
-                               centroidId = points->InsertNextPoint(centroid[0], centroid[1], centroid[2]);
+                               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+1);
-                               if(normalOrder){        //(facesIdx == 0 && uPointOrder) || (facesIdx == 1 && !uPointOrder)){
+                               if( !normalOrder )
+                {      //(facesIdx == 0 && uPointOrder) || (facesIdx == 1 && !uPointOrder)){
                                        int initial = firstIndex;
                                        int triangleIndex = 0;
                                        for(int index = initial; index < end; index+=increment){
@@ -169,8 +170,7 @@ void CreateMeshFromPoints::CloseContourSides(std::vector<int> lstIndexs, bool uP
                                                triangleIndex+=2;
                                        }
                                        cells->InsertNextCell(triangleStrip1);
-                               }
-                               else{
+                               } else {
                                        int initial = firstIndex-1;
                                        int triangleIndex = 0;
                                        int triangleStripStart = end-1;
index f21b5175805c2dcfe12a4b2b8fe7fc822bd828b6..55d8fe58e14d148ca2ffd197cfc6dc039d87cfd0 100644 (file)
@@ -38,17 +38,26 @@ void GlyphPolyDataNormals::Process()
        //Type of Glyph 1-Arrow 2-Line
        //size of glyph Done
 
-       if(bbGetInputIn() == NULL){
+       if(bbGetInputIn() == NULL)
+    {
                printf("Warnning! GlyphPolyDataNormals::Process: Missing input PolyData\n");
                bbSetOutputOut( NULL );
-       }
-       else if(bbGetInputRenderer() == NULL){
+        
+        if(bbGetInputRenderer() != NULL)
+        {
+            if( (actorAdded==true) && (bbGetInputActive()==true) )
+            {
+                bbGetInputRenderer()->RemoveActor(normalsActor);
+                actorAdded = false;
+            }
+        } // if Renderer
+        
+       } else if(bbGetInputRenderer() == NULL) {
                printf("Warnning! GlyphPolyDataNormals::Process: Missing Renderer\n");
                bbSetOutputOut( NULL );
-       }
-       else{
+       } else {
                //Arrow Source
-               arrow->SetTipResolution(16);
+               arrow->SetTipResolution(4);
                arrow->SetTipLength(0.5);
                arrow->SetTipRadius(0.2 * bbGetInputGlyphType());
                arrow->Update();
@@ -77,19 +86,20 @@ void GlyphPolyDataNormals::Process()
                                                        bbGetInputColor()[1],
                                                        bbGetInputColor()[2]);
                
-               if(bbGetInputRenderer() != NULL){
-                       if(actorAdded && !bbGetInputActive()){                          
+               if(bbGetInputRenderer() != NULL)
+        {
+                       if( (actorAdded==true) && !(bbGetInputActive()==true) )
+            {
                                bbGetInputRenderer()->RemoveActor(normalsActor);
                                actorAdded = false;
-                       }
-                       else if(bbGetInputActive() && !actorAdded){
+                       } else if(bbGetInputActive() && !actorAdded) {
                                bbGetInputRenderer()->AddActor(normalsActor);
                                actorAdded = true;      
                        }       
-               }
+               } // if Renderer
 
                bbSetOutputOut( normalsActor );
-       }
+       } // if InputIn
   
 }
 //===== 
index 5c0ddab5284d55b2e98517e7c520b65d604c6dce..1463602c72c6a87a0da00a52bdd1473a364bb43e 100644 (file)
@@ -39,6 +39,8 @@ void PolyDataNormals::Process()
     if (bbGetInputIn()!=NULL)
     {
         vtkPolyDataNormals* normal = vtkPolyDataNormals::New();
+        normal->SetAutoOrientNormals(false);
+        normal->SetConsistency(false);
         normal->SetInputData( bbGetInputIn() );
         if (bbGetInputComputeType()==0)
         {
@@ -144,6 +146,8 @@ void PolyDataNormals::bbUserSetDefaultValues()
 {
 //  SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX 
 //    Here we initialize the input 'In' to 0
+    bbSetInputType(0);
+    bbSetInputComputeType(0);
     bbSetInputIn(NULL);
     bbSetOutputOut( NULL );
 }
index 1bcfafd052dd9cd208524029a756704d123e259d..41dd9244dffb4ba3241979dbfebea7535a6ab84a 100644 (file)
@@ -41,9 +41,9 @@ BBTK_BEGIN_DESCRIBE_BLACK_BOX(PolyDataNormals,bbtk::AtomicBlackBox);
   BBTK_DESCRIPTION("No Description.");
   BBTK_CATEGORY("empty");
     BBTK_INPUT(PolyDataNormals,In,"Mesh input",vtkPolyData*,"");
-    BBTK_INPUT(PolyDataNormals,ComputeType,"(0 default) 0:points  1:Cells",int,"");
+    BBTK_INPUT(PolyDataNormals,ComputeType,"(0 default) 0:Cells 1:Points",int,"");
     BBTK_INPUT(PolyDataNormals,Type,"(0 default) 0:Normal Action   1:Apply correction direction (try param=1)",int,"");
-    BBTK_INPUT(PolyDataNormals,Param,"(0 default) For Type=1 [-2 2] 0:parallel 1:NormalState -1:OpositState",double ,"");
+    BBTK_INPUT(PolyDataNormals,Param,"(0 default) For Type=1  (Normaly for open meshs)    [-2 2] 0:parallel 1:NormalState -1:OpositState",double ,"");
     BBTK_OUTPUT(PolyDataNormals,Out,"Mesh output",vtkPolyData*,"");
     BBTK_OUTPUT(PolyDataNormals,MeanNormal,"Mean Normal",std::vector<double>,"");
 BBTK_END_DESCRIBE_BLACK_BOX(PolyDataNormals);