//===== // 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 "bbcreaVtkCreateMeshFromPoints.h" #include "bbcreaVtkPackage.h" #include "vtkTriangleStrip.h" namespace bbcreaVtk { BBTK_ADD_BLACK_BOX_TO_PACKAGE(creaVtk,CreateMeshFromPoints) BBTK_BLACK_BOX_IMPLEMENTATION(CreateMeshFromPoints,bbtk::AtomicBlackBox); //===== // 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) //===== void CreateMeshFromPoints::Process() { // THE MAIN PROCESSING METHOD BODY // Here we simply set the input 'In' value to the output 'Out' // And print out the output value // INPUT/OUTPUT ACCESSORS ARE OF THE FORM : // void bbSet{Input|Output}NAME(const TYPE&) // const TYPE& bbGet{Input|Output}NAME() const // Where : // * NAME is the name of the input/output // (the one provided in the attribute 'name' of the tag 'input') // * TYPE is the C++ type of the input/output // (the one provided in the attribute 'type' of the tag 'input') // 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"); } else { int ii,sizeSegment1,sizeSegment2; int endSegment; // 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(); 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; } // for ii iGeneral=iGeneral+sizeSegment1; cells->InsertNextCell(triangleStrip); } //for LstIndexs // vtkPolyData *polydata = vtkPolyData::New(); if (polydata!=NULL) polydata->Delete(); polydata = vtkPolyData::New(); polydata->SetPoints(points); polydata->SetStrips(cells); // 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 } //===== // 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) //===== 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) //===== void CreateMeshFromPoints::bbUserInitializeProcessing() { // THE INITIALIZATION METHOD BODY : // Here does nothing // but this is where you should allocate the internal/output pointers // if any } //===== // 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) //===== void CreateMeshFromPoints::bbUserFinalizeProcessing() { // THE FINALIZATION METHOD BODY : // Here does nothing // but this is where you should desallocate the internal/output pointers // if any } } // EO namespace bbcreaVtk