//===== // 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 "bbcreaVtkCleanMeshWithPatch.h" #include "bbcreaVtkPackage.h" #include #include #include #include namespace bbcreaVtk { BBTK_ADD_BLACK_BOX_TO_PACKAGE(creaVtk,CleanMeshWithPatch) BBTK_BLACK_BOX_IMPLEMENTATION(CleanMeshWithPatch,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 CleanMeshWithPatch::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 = " < lstIndexs = bbGetInputLstIndexs(); if (( lstIndexs.size()>=3 ) && (bbGetInputMesh()!=NULL) ) { // Step 1. ----Get perimeter CtrlPoints----- std::vector lstX = bbGetInputLstX(); std::vector lstY = bbGetInputLstY(); std::vector lstZ = bbGetInputLstZ(); std::vector perimeterX; std::vector perimeterY; std::vector perimeterZ; std::vector tmpX; std::vector tmpY; std::vector tmpZ; int iGroup,sizeGroups = lstIndexs.size(); int i,iGeneral=0,size; for (iGroup=0 ; iGroup=iGeneral ; i--) { perimeterX.push_back( lstX[i] ); perimeterY.push_back( lstY[i] ); perimeterZ.push_back( lstZ[i] ); } // for i last group } // if iGroup == 0 iGeneral=iGeneral+lstIndexs[iGroup]; } // for size=tmpX.size(); for (i=0; i spc; if (bbGetInputSpacing().size()<3) { spc.push_back(1); spc.push_back(1); spc.push_back(1); } else { spc = bbGetInputSpacing(); }// vtkStaticPointLocator *pointLocator; pointLocator = vtkStaticPointLocator::New(); pointLocator->SetDataSet( bbGetInputMesh() ); pointLocator->BuildLocator(); long int id; size=perimeterX.size(); std::vector lstIds; for (i=0;iFindClosestPoint( perimeterX[i]*spc[0] ,perimeterY[i]*spc[1] , perimeterZ[i]*spc[2] ) ; lstIds.push_back( id ); printf("EED id=%ld spc=%f %f %f point=%f %f %f \n",id, spc[0],spc[1],spc[2], perimeterX[i], perimeterY[i], perimeterZ[i] ); } // for i perimeter // Step 3 Get geodesic path from segments long int id1,id2; vtkAppendPolyData* append = vtkAppendPolyData::New(); vtkPoints *points ; for (i=0;iSetInputData( bbGetInputMesh() ); pathFilter->SetStartVertex( id1 ); pathFilter->SetEndVertex( id2 ); pathFilter->Update(); append->AddInputData( pathFilter->GetOutput() ); append->Update(); points = pathFilter->GetOutput()->GetPoints(); printf("EED nrP=%d \n", points->GetNumberOfPoints() ); pathFilter->Delete(); // if (i==0) bbSetOutputOut( pathFilter->GetOutput() ); } // for i perimeter append->Update(); // Step 4. -- vtkImprintFilter --- vtkImprintFilter *imp = vtkImprintFilter::New(); // imp->SetTargetData( append->GetOutput() ); // imp->SetImprintData( bbGetInputMesh() ); // imp->SetTargetData( bbGetInputMesh() ); // imp->SetImprintData( append->GetOutput() ); // imp->SetTargetData( bbGetInputMesh() ); // imp->SetImprintData( bbGetInputPatch() ); imp->SetTargetData( bbGetInputMesh() ); imp->SetImprintData( bbGetInputPatch() ); // imp->SetOutputTypeToProjectedImprint(); imp->SetOutputTypeToTargetCells(); // imp->SetOutputTypeToImprintedCells(); // imp->SetOutputTypeToImprintedRegion(); // imp->SetOutputTypeToMergedImprint(); imp->SetTolerance(500); imp->Update(); bbSetOutputOut( imp->GetOutput() ); printf("EED CleanMeshWithPatch::Process size=%d \n", perimeterX.size()); } // if LstIndexs size >=3 printf("EED CleanMeshWithPatch::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) //===== void CleanMeshWithPatch::bbUserSetDefaultValues() { // SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX // Here we initialize the input 'In' to 0 bbSetInputMesh(NULL); bbSetInputPatch(NULL); bbSetOutputOut(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 CleanMeshWithPatch::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 CleanMeshWithPatch::bbUserFinalizeProcessing() { // THE FINALIZATION METHOD BODY : // Here does nothing // but this is where you should desallocate the internal/output pointers // if any } } // EO namespace bbcreaVtk