X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;ds=sidebyside;f=bbtk_creaVtk_PKG%2Fsrc%2FbbcreaVtkPointPicker.cxx;h=3d71c086809a59cfda0334da4ada5e4a2868acfa;hb=2ff30a2f6c323b37d5e38743e3875535ea2563f6;hp=0d75b953cdbb85b06199b70e5e6d4834c2d8e1d8;hpb=8b897e95b16fec9d4da9e687b750101f6f16e173;p=creaVtk.git diff --git a/bbtk_creaVtk_PKG/src/bbcreaVtkPointPicker.cxx b/bbtk_creaVtk_PKG/src/bbcreaVtkPointPicker.cxx index 0d75b95..3d71c08 100644 --- a/bbtk_creaVtk_PKG/src/bbcreaVtkPointPicker.cxx +++ b/bbtk_creaVtk_PKG/src/bbcreaVtkPointPicker.cxx @@ -8,18 +8,22 @@ #include #include #include +#include +#include +#include +#include namespace bbcreaVtk { creaVtkCallbackPointPicker::creaVtkCallbackPointPicker(void) { - boxPointPicker=NULL; + boxPointPicker = NULL; } void creaVtkCallbackPointPicker::setBox(PointPicker *box) { - boxPointPicker=box; + boxPointPicker = box; } void creaVtkCallbackPointPicker::Execute(vtkObject *caller, unsigned long, void*) @@ -28,33 +32,61 @@ void creaVtkCallbackPointPicker::Execute(vtkObject *caller, unsigned long, void* { if (boxPointPicker->bbGetInputActive()==true) { -// printf("creaVtkCallbackPointPicker EED Picker\n"); - vtkRenderWindowInteractor *iren = static_cast(caller); - int* pos = iren->GetEventPosition(); - vtkCellPicker *picker = vtkCellPicker::New(); + vtkRenderWindowInteractor *iren = static_cast(caller); + int *pos = iren->GetEventPosition(); + vtkCellPicker *picker = vtkCellPicker::New(); picker->SetTolerance(0.0005); + if (boxPointPicker->bbGetInputProp3D()!=NULL ) + { + picker->AddPickList( boxPointPicker->bbGetInputProp3D() ); + picker->PickFromListOn(); + } picker->Pick(pos[0], pos[1], 0, iren->GetRenderWindow()->GetRenderers()->GetFirstRenderer() ); double point[3]; - if(picker->GetCellId() != -1) { -// printf("creaVtkCallbackPointPicker EED picker OK\n"); picker->GetPickPosition(point); std::vector vecPoint; vecPoint.push_back( point[0] ); vecPoint.push_back( point[1] ); vecPoint.push_back( point[2] ); - boxPointPicker->bbSetOutputPoint( vecPoint ); - boxPointPicker->bbSetOutputMesh( picker->GetProp3D() ); - boxPointPicker->bbSetOutputPointId( picker->GetPointId() ); - boxPointPicker->bbSetOutputCellId( picker->GetCellId() ); - boxPointPicker->bbSignalOutputModification(); - } else { -// printf("creaVtkCallbackPointPicker EED picker --\n"); - } // if - } + boxPointPicker->bbSetOutputPoint( vecPoint ); + boxPointPicker->bbSetOutputMesh( picker->GetProp3D() ); + boxPointPicker->bbSetOutputPointId( picker->GetPointId() ); + + boxPointPicker->bbSetOutputCellId( picker->GetCellId() ); + vtkDataSet *dataset = picker->GetDataSet(); + if (strcmp(dataset->GetClassName(),"vtkPolyData")==0) + { + vtkPolyData *polydata = (vtkPolyData*)dataset; + vtkPointData *pointdata = polydata->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( picker->GetPointId() ); + std::vector lstNormal; + lstNormal.push_back(pValue[0]); + lstNormal.push_back(pValue[1]); + lstNormal.push_back(pValue[2]); + boxPointPicker->bbSetOutputNormal( lstNormal ); + } // if dataarray + } // if ClassName + boxPointPicker->bbSignalOutputModification(); + } // if + } // if Active } // if boxPoiintPicker + /* { @@ -115,8 +147,6 @@ void creaVtkCallbackPointPicker::Execute(vtkObject *caller, unsigned long, void* } */ - - } @@ -132,7 +162,6 @@ BBTK_BLACK_BOX_IMPLEMENTATION(PointPicker,bbtk::AtomicBlackBox); //===== void PointPicker::Process() { - // THE MAIN PROCESSING METHOD BODY // Here we simply set the input 'In' value to the output 'Out' // And print out the output value @@ -166,10 +195,8 @@ void PointPicker::Process() picker->AddObserver( vtkCommand::MouseMoveEvent , callPicker ); bbGetInputRenderer()->GetRenderWindow()->GetInteractor()->SetPicker(picker); */ - callPicker = creaVtkCallbackPointPicker::New(); callPicker->setBox( this ); - } // if firsttime @@ -199,9 +226,21 @@ void PointPicker::Process() } // if bbGetInputRenderer() - - +// std::vector lstPoint; +// lstPoint.push_back(0); +// lstPoint.push_back(0); +// lstPoint.push_back(1); +// bbSetOutputPoint( lstPoint ); + +// BORRAME bbSetOutputPoint( bbGetInputDefaultPoint() ); + +// bbSetOutputMesh( NULL ); +// Borrame bbSetOutputPointId( bbGetInputDefaultPointId() ); +// bbSetOutputCellId( -1 ); +// bbSetOutputNormal( lstPoint ); + } + //===== // 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) //===== @@ -212,38 +251,42 @@ void PointPicker::bbUserSetDefaultValues() // bbSetInputIn(0); bbSetInputActive(true); bbSetInputTypeEvent(0); + bbSetInputDefaultPointId( -1 ); bbSetOutputMesh(NULL); bbSetOutputPointId(-1); bbSetOutputCellId(-1); firsttime=true; callPicker=NULL; + bbSetInputProp3D(NULL); + std::vector lstNormal; + lstNormal.push_back(0); + lstNormal.push_back(0); + lstNormal.push_back(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 PointPicker::bbUserInitializeProcessing() { - // THE INITIALIZATION METHOD BODY : // Here does nothing // but this is where you should allocate the internal/output pointers -// if any - - +// 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 PointPicker::bbUserFinalizeProcessing() { - // THE FINALIZATION METHOD BODY : // Here does nothing // but this is where you should desallocate the internal/output pointers // if any - } -} -// EO namespace bbcreaVtk + +}// EO namespace bbcreaVtk