//===== // 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 "bbcreaVtkPointPickerNearest.h" #include "bbcreaVtkPackage.h" #include "vtkPoints.h" #include #include namespace bbcreaVtk { BBTK_ADD_BLACK_BOX_TO_PACKAGE(creaVtk,PointPickerNearest) BBTK_BLACK_BOX_IMPLEMENTATION(PointPickerNearest,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 PointPickerNearest::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') printf ("EED PointPickerNearest::Process Start\n"); std::vector lstNormal; std::vector refPoint = bbGetInputPoint(); printf ("EED PointPickerNearest::Process 1\n"); if ((bbGetInputActive()==true) && ( bbGetInputMesh()!=NULL) && (refPoint.size()==3) ) { double p[3]; double min; double minBack=100000000; double dx,dy,dz; long i,iBack=-1; vtkPoints *points = bbGetInputMesh()->GetPoints(); long size = points->GetNumberOfPoints(); double border = bbGetInputBorder() * bbGetInputBorder(); printf ("EED PointPickerNearest::Process 2\n"); for ( i=0 ; iGetPoint(i,p); dx = p[0]-refPoint[0]; dy = p[1]-refPoint[1]; dz = p[2]-refPoint[2]; min = dx*dx + dy*dy + dz*dz; if (min=0) { vtkPointData *pointdata = bbGetInputMesh()->GetPointData(); vtkDataArray *dataarray; double *pValue; /* int i,size=pointdata->GetNumberOfArrays(); for(i=0;iGetArray(i); printf("EED creaVtkCallbackPointPicker::Execute dataarray=%s n=%ld p=%ld\n", dataarray->GetName(),dataarray->GetNumberOfValues() ,polydata->GetNumberOfPoints() ); } // for i */ printf ("EED PointPickerNearest::Process 4\n"); dataarray = pointdata->GetNormals(); if (dataarray!=NULL) { pValue = dataarray->GetTuple3( iBack ); printf ("EED PointPickerNearest::Process 5\n"); lstNormal.push_back(pValue[0]); lstNormal.push_back(pValue[1]); lstNormal.push_back(pValue[2]); } // if dataarray } // if iBack bbSetOutputPointId( iBack ); bbSetOutputNormal( lstNormal ); printf ("EED PointPickerNearest::Process 6 %ld\n", iBack); std::vector lstPointOut; if (iBack>=0){ points->GetPoint(iBack,p); lstPointOut.push_back(p[0]); lstPointOut.push_back(p[1]); lstPointOut.push_back(p[2]); printf ("EED PointPickerNearest::Process 7 pointOut=%f %f %f\n", lstPointOut[0],lstPointOut[1],lstPointOut[2]); }// if iBack bbSetOutputPointOut( lstPointOut ); } else { bbSetOutputPointId( -1 ); lstNormal.push_back(0); lstNormal.push_back(1); lstNormal.push_back(2); bbSetOutputNormal( lstNormal ); bbSetOutputPointOut( bbGetInputPoint() ); } printf ("EED PointPickerNearest::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 PointPickerNearest::bbUserSetDefaultValues() { // SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX // Here we initialize the input 'In' to 0 bbSetInputActive(false); bbSetInputMesh(NULL); bbSetInputBorder(5); } //===== // 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 PointPickerNearest::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 PointPickerNearest::bbUserFinalizeProcessing() { // THE FINALIZATION METHOD BODY : // Here does nothing // but this is where you should desallocate the internal/output pointers // if any } } // EO namespace bbcreaVtk