X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;ds=sidebyside;f=bbtk_creaVtk_PKG%2Fsrc%2FbbcreaVtkCreateMeshFromPoints.cxx;h=534d0029101cb8ca4cce1d167bf095e7721817ac;hb=690b561e62bf9835b94cf248a6747b50b0641df7;hp=34c6e66fd584cf9d9dec835ad3a23b6bebcb105b;hpb=27cd1709e7cd62aa62f02df8abecdd8bea1d8767;p=creaVtk.git diff --git a/bbtk_creaVtk_PKG/src/bbcreaVtkCreateMeshFromPoints.cxx b/bbtk_creaVtk_PKG/src/bbcreaVtkCreateMeshFromPoints.cxx index 34c6e66..534d002 100644 --- a/bbtk_creaVtk_PKG/src/bbcreaVtkCreateMeshFromPoints.cxx +++ b/bbtk_creaVtk_PKG/src/bbcreaVtkCreateMeshFromPoints.cxx @@ -4,12 +4,7 @@ #include "bbcreaVtkCreateMeshFromPoints.h" #include "bbcreaVtkPackage.h" -#include "vtkPoints.h" #include "vtkTriangleStrip.h" -#include "vtkCellArray.h" - -#include "vtkCleanPolyData.h" - namespace bbcreaVtk { @@ -37,82 +32,77 @@ void CreateMeshFromPoints::Process() // bbSetOutputOut( bbGetInputIn() ); // std::cout << "Output value = " < lstX = bbGetInputLstX(); 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()) ) { printf("Warnning! CreateMeshFromPoints::Process: List of points X Y Z and LstIndexes is not correct\n"); + bbSetOutputOut(NULL); } else { - + printf("EED CreateMeshFromPoints::Process initial=%d final=%d\n" , lstIndexs[0] , lstIndexs[ lstIndexs.size()-1 ] ); int ii,sizeSegment1,sizeSegment2; int endSegment; - - vtkSmartPointer points = vtkSmartPointer::New(); +// vtkSmartPointer points = vtkSmartPointer::New(); + if (points!=NULL) points->Delete(); + points = vtkPoints::New(); int i,sizeLstX = lstX.size(); for (i=0;iInsertNextPoint(lstX[i],lstY[i],lstZ[i]); } // for i - - vtkSmartPointer cells = vtkSmartPointer::New(); +// vtkSmartPointer cells = vtkSmartPointer::New(); + if (cells!=NULL) cells->Delete(); + cells = vtkCellArray::New(); int maxElements; int maxSegment1,maxSegment2; int iSeg1,iSeg2; - int iGeneral = 0; int sizeLstIdexes=lstIndexs.size(); - for (i=0; i triangleStrip = vtkSmartPointer::New(); triangleStrip->GetPointIds()->SetNumberOfIds(sizeSegment1+sizeSegment2); - maxElements=sizeSegment1; if (maxElementsGetPointIds()->SetId(ii*2 ,iSeg1); 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 - - vtkPolyData *polydata = vtkPolyData::New(); + } //for LstIndexs +// vtkPolyData *polydata = vtkPolyData::New(); + if (polydata!=NULL) polydata->Delete(); + polydata = vtkPolyData::New(); polydata->SetPoints(points); polydata->SetStrips(cells); - - vtkCleanPolyData *clean=vtkCleanPolyData::New(); +// vtkCleanPolyData *clean=vtkCleanPolyData::New(); + if (clean!=NULL) clean->Delete(); + clean = vtkCleanPolyData::New(); clean->SetInputData(polydata); clean->Update(); - +// vtkTriangleFilter *triangle = vtkTriangleFilter::New(); + if (triangle!=NULL) triangle->Delete(); + triangle = vtkTriangleFilter::New(); + triangle->SetInputData( clean->GetOutput() ); + triangle->Update(); bbSetOutputOut( clean->GetOutput() ); - }// if listXYZ size - -printf("EED CreateMeshFromPoints::Process End\n"); - - } + //===== // Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost) //===== @@ -122,7 +112,11 @@ void CreateMeshFromPoints::bbUserSetDefaultValues() // SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX // Here we initialize the input 'In' to 0 // bbSetInputIn(0); - + points = NULL; + cells = NULL; + polydata = NULL; + clean = NULL; + triangle = NULL; } //===== // Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)