From: Eduardo DAVILA Date: Thu, 6 Jan 2022 16:07:03 +0000 (+0100) Subject: PointPickerNearest box X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=c30d7fdcd46f34dd43b2ae4974e883494f2f64e7;p=creaVtk.git PointPickerNearest box --- diff --git a/bbtk_creaVtk_PKG/src/bbcreaVtkPointPicker.h b/bbtk_creaVtk_PKG/src/bbcreaVtkPointPicker.h index d48c560..09fd1fa 100644 --- a/bbtk_creaVtk_PKG/src/bbcreaVtkPointPicker.h +++ b/bbtk_creaVtk_PKG/src/bbcreaVtkPointPicker.h @@ -82,8 +82,8 @@ BBTK_BEGIN_DESCRIBE_BLACK_BOX(PointPicker,bbtk::AtomicBlackBox); BBTK_OUTPUT(PointPicker,Point,"Point [x,y,z])",std::vector,""); BBTK_OUTPUT(PointPicker,Mesh,"Mesh",vtkProp3D*,""); - BBTK_OUTPUT(PointPicker,PointId,"Point Id in Mesh",longInt,""); - BBTK_OUTPUT(PointPicker,CellId,"Cell Id in Mesh",longInt,""); + BBTK_OUTPUT(PointPicker,PointId,"Mesh point Id",longInt,""); + BBTK_OUTPUT(PointPicker,CellId,"Mesh cell Id",longInt,""); BBTK_OUTPUT(PointPicker,Normal,"Normal [nx,ny,nz]",std::vector,""); BBTK_END_DESCRIBE_BLACK_BOX(PointPicker); diff --git a/bbtk_creaVtk_PKG/src/bbcreaVtkPointPickerNearest.cxx b/bbtk_creaVtk_PKG/src/bbcreaVtkPointPickerNearest.cxx new file mode 100644 index 0000000..e7534a0 --- /dev/null +++ b/bbtk_creaVtk_PKG/src/bbcreaVtkPointPickerNearest.cxx @@ -0,0 +1,133 @@ +//===== +// 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') + + + std::vector lstNormal; + std::vector refPoint = bbGetInputPoint(); + + 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(); + 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 + */ + dataarray = pointdata->GetNormals(); + if (dataarray!=NULL) + { + pValue = dataarray->GetTuple3( iBack ); + lstNormal.push_back(pValue[0]); + lstNormal.push_back(pValue[1]); + lstNormal.push_back(pValue[2]); + } // if dataarray + } // if iBack + bbSetOutputPointId( iBack ); + bbSetOutputNormal( lstNormal ); + } else { + bbSetOutputPointId( -1 ); + bbSetOutputNormal( lstNormal ); + } +} +//===== +// 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(10); +} +//===== +// 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 + + diff --git a/bbtk_creaVtk_PKG/src/bbcreaVtkPointPickerNearest.h b/bbtk_creaVtk_PKG/src/bbcreaVtkPointPickerNearest.h new file mode 100644 index 0000000..988829e --- /dev/null +++ b/bbtk_creaVtk_PKG/src/bbcreaVtkPointPickerNearest.h @@ -0,0 +1,59 @@ +//===== +// 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) +//===== +#ifndef __bbcreaVtkPointPickerNearest_h_INCLUDED__ +#define __bbcreaVtkPointPickerNearest_h_INCLUDED__ + +#include "bbcreaVtk_EXPORT.h" +#include "bbtkAtomicBlackBox.h" +#include "iostream" + +#include "vtkPolyData.h" + + +namespace bbcreaVtk +{ + +typedef long int longInt; + +class bbcreaVtk_EXPORT PointPickerNearest + : + public bbtk::AtomicBlackBox +{ + BBTK_BLACK_BOX_INTERFACE(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) +//===== + BBTK_DECLARE_INPUT(Active,bool); + BBTK_DECLARE_INPUT(Point,std::vector); + BBTK_DECLARE_INPUT(Mesh,vtkPolyData*); + BBTK_DECLARE_INPUT(Border,double); + BBTK_DECLARE_OUTPUT(PointId,longInt); + BBTK_DECLARE_OUTPUT(Normal,std::vector); + BBTK_PROCESS(Process); + void Process(); +//===== +// 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) +//===== +}; + +BBTK_BEGIN_DESCRIBE_BLACK_BOX(PointPickerNearest,bbtk::AtomicBlackBox); + BBTK_NAME("PointPickerNearest"); + BBTK_AUTHOR("InfoDev"); + BBTK_DESCRIPTION("No Description."); + BBTK_CATEGORY("empty"); + BBTK_INPUT(PointPickerNearest,Active,"(default false) true/false",bool,""); + BBTK_INPUT(PointPickerNearest,Point,"Point [x,y,z]",std::vector,""); + BBTK_INPUT(PointPickerNearest,Mesh,"Mesh polyData",vtkPolyData*,""); + BBTK_INPUT(PointPickerNearest,Border,"(default 10) Distance max to be acvive",double,""); + BBTK_OUTPUT(PointPickerNearest,PointId,"Mesh point Id ",longInt,""); + BBTK_OUTPUT(PointPickerNearest,Normal,"Normal [nx,ny,nz]",std::vector,""); +BBTK_END_DESCRIBE_BLACK_BOX(PointPickerNearest); +//===== +// 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) +//===== +} +// EO namespace bbcreaVtk + +#endif // __bbcreaVtkPointPickerNearest_h_INCLUDED__ +