#include "bbcreaVtkCreateMeshFromPoints.h"
#include "bbcreaVtkPackage.h"
-#include "vtkPoints.h"
#include "vtkTriangleStrip.h"
-#include "vtkCellArray.h"
-
-#include "vtkCleanPolyData.h"
-#include "vtkTriangleFilter.h"
namespace bbcreaVtk
{
// bbSetOutputOut( bbGetInputIn() );
// std::cout << "Output value = " <<bbGetOutputOut() << std::endl;
-
-
-printf("EED CreateMeshFromPoints::Process Start\n");
-
-
std::vector<double> lstX = bbGetInputLstX();
std::vector<double> lstY = bbGetInputLstY();
std::vector<double> lstZ = bbGetInputLstZ();
std::vector<int> 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");
} else {
-
int ii,sizeSegment1,sizeSegment2;
int endSegment;
-
- vtkSmartPointer<vtkPoints> points = vtkSmartPointer<vtkPoints>::New();
+// vtkSmartPointer<vtkPoints> points = vtkSmartPointer<vtkPoints>::New();
+ if (points!=NULL) points->Delete();
+ points = vtkPoints::New();
int i,sizeLstX = lstX.size();
for (i=0;i<sizeLstX;i++)
{
points->InsertNextPoint(lstX[i],lstY[i],lstZ[i]);
} // for i
-
- vtkSmartPointer<vtkCellArray> cells = vtkSmartPointer<vtkCellArray>::New();
+// vtkSmartPointer<vtkCellArray> cells = vtkSmartPointer<vtkCellArray>::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<sizeLstIdexes-1;i++)
{
- sizeSegment1=lstIndexs[i];
- sizeSegment2=lstIndexs[i+1];
-
+ sizeSegment1 = lstIndexs[i];
+ sizeSegment2 = lstIndexs[i+1];
vtkSmartPointer<vtkTriangleStrip> triangleStrip = vtkSmartPointer<vtkTriangleStrip>::New();
triangleStrip->GetPointIds()->SetNumberOfIds(sizeSegment1+sizeSegment2);
-
maxElements=sizeSegment1;
if (maxElements<sizeSegment2) maxElements=sizeSegment2;
- maxSegment1=iGeneral+sizeSegment1;
- maxSegment2=iGeneral+sizeSegment1+sizeSegment2;
- iSeg1=iGeneral;
- iSeg2=iGeneral+sizeSegment1;
+ maxSegment1 = iGeneral+sizeSegment1;
+ maxSegment2 = iGeneral+sizeSegment1+sizeSegment2;
+ iSeg1 = iGeneral;
+ iSeg2 = iGeneral+sizeSegment1;
for (ii=0; ii<maxElements; ii++)
{
triangleStrip->GetPointIds()->SetId(ii*2 ,iSeg1);
} // for ii
iGeneral=iGeneral+sizeSegment1;
cells->InsertNextCell(triangleStrip);
-
} //for LstIndexs
-
- vtkPolyData *polydata = vtkPolyData::New();
+// 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();
+// 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)
// 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)
#include "bbcreaVtkPolyDataToImageData.h"
#include "bbcreaVtkPackage.h"
-#include "vtkPolyDataToImageStencil.h"
-#include "vtkImageStencil.h"
-
-#include "vtkCleanPolyData.h"
-#include "vtkTriangleFilter.h"
-
-#include "vtkExtractVOI.h"
-#include "vtkExtractVOI.h"
-
-
namespace bbcreaVtk
{
// bbSetOutputOut( bbGetInputIn() );
// std::cout << "Output value = " <<bbGetOutputOut() << std::endl;
- if ((bbGetInputInPolyData()!=NULL) && (bbGetInputInImage()!=NULL))
+ if ((bbGetInputInPolyData()!=NULL) && (bbGetInputInImage()!=NULL) )
{
printf("EED Warnning!! PolyDataToImageData::Process Clean this code .................;\n ");
int ext[6];
bbGetInputInImage()->GetExtent( ext );
- vtkCleanPolyData *clean1 = vtkCleanPolyData::New();
+// vtkCleanPolyData *clean1 = vtkCleanPolyData::New();
+ if (clean1!=NULL) clean1->Delete();
+ clean1 = vtkCleanPolyData::New();
clean1->SetInputData( bbGetInputInPolyData() );
clean1->Update();
vtkTriangleFilter *triangle1 = vtkTriangleFilter::New();
triangle1->SetInputData( clean1->GetOutput() );
triangle1->Update();
- vtkPolyDataToImageStencil *dataToStencil = vtkPolyDataToImageStencil::New();
+// vtkPolyDataToImageStencil *dataToStencil = vtkPolyDataToImageStencil::New();
+ if (dataToStencil!=NULL) dataToStencil->Delete();
+ dataToStencil = vtkPolyDataToImageStencil::New();
dataToStencil->SetInputData( triangle1->GetOutput() );
dataToStencil->SetOutputWholeExtent( ext );
dataToStencil->Update();
- vtkExtractVOI *extract = vtkExtractVOI::New();
+// vtkExtractVOI *extract = vtkExtractVOI::New();
+ if (extract!=NULL) extract->Delete();
+ extract = vtkExtractVOI::New();
extract->SetVOI( ext );
extract->SetSampleRate(1, 1, 1);
extract->SetInputData( bbGetInputInImage() );
extract->ReleaseDataFlagOff();
extract->Update();
- vtkImageStencil *stencil = vtkImageStencil::New();
+// vtkImageStencil *stencil = vtkImageStencil::New();
+ if (stencil!=NULL) stencil->Delete();
+ stencil = vtkImageStencil::New();
stencil->SetInputData( extract->GetOutput() );
stencil->Update();
stencil->SetStencilData( dataToStencil->GetOutput() );
// Here does nothing
// but this is where you should allocate the internal/output pointers
// if any
+ clean1 = NULL;
+ dataToStencil = NULL;
+ extract = NULL;
+ stencil = 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)