From: Eduardo DAVILA Date: Thu, 23 Mar 2023 10:48:26 +0000 (+0100) Subject: Clean code X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=f6dd6405cd6d7cce327da9fdb46a89a0d669e566;p=creaVtk.git Clean code --- diff --git a/bbtk_creaVtk_PKG/src/bbcreaVtkCreateMeshFromPoints.cxx b/bbtk_creaVtk_PKG/src/bbcreaVtkCreateMeshFromPoints.cxx index a6948c4..69aab08 100644 --- a/bbtk_creaVtk_PKG/src/bbcreaVtkCreateMeshFromPoints.cxx +++ b/bbtk_creaVtk_PKG/src/bbcreaVtkCreateMeshFromPoints.cxx @@ -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 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 triangleStrip1 = vtkSmartPointer::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 lstIndexs, bool uP triangleIndex+=2; } cells->InsertNextCell(triangleStrip1); - } - else{ + } else { int initial = firstIndex-1; int triangleIndex = 0; int triangleStripStart = end-1; diff --git a/bbtk_creaVtk_PKG/src/bbcreaVtkGlyphPolyDataNormals.cxx b/bbtk_creaVtk_PKG/src/bbcreaVtkGlyphPolyDataNormals.cxx index f21b517..55d8fe5 100644 --- a/bbtk_creaVtk_PKG/src/bbcreaVtkGlyphPolyDataNormals.cxx +++ b/bbtk_creaVtk_PKG/src/bbcreaVtkGlyphPolyDataNormals.cxx @@ -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 } //===== diff --git a/bbtk_creaVtk_PKG/src/bbcreaVtkPolyDataNormals.cxx b/bbtk_creaVtk_PKG/src/bbcreaVtkPolyDataNormals.cxx index 5c0ddab..1463602 100644 --- a/bbtk_creaVtk_PKG/src/bbcreaVtkPolyDataNormals.cxx +++ b/bbtk_creaVtk_PKG/src/bbcreaVtkPolyDataNormals.cxx @@ -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 ); } diff --git a/bbtk_creaVtk_PKG/src/bbcreaVtkPolyDataNormals.h b/bbtk_creaVtk_PKG/src/bbcreaVtkPolyDataNormals.h index 1bcfafd..41dd924 100644 --- a/bbtk_creaVtk_PKG/src/bbcreaVtkPolyDataNormals.h +++ b/bbtk_creaVtk_PKG/src/bbcreaVtkPolyDataNormals.h @@ -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,""); BBTK_END_DESCRIBE_BLACK_BOX(PolyDataNormals);