+//=====
+// 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 "bbcreaVtkPointPicker.h"
+#include "bbcreaVtkPackage.h"
+
+#include <vtkPropPicker.h>
+#include <vtkCellPicker.h>
+#include <vtkRenderWindow.h>
+#include <vtkRenderWindowInteractor.h>
+#include <vtkRendererCollection.h>
+
+namespace bbcreaVtk
+{
+
+
+
+void creaVtkCallbackPointPicker::Execute(vtkObject *caller, unsigned long, void*)
+{
+ printf("creaVtkCallbackPointPicker EED Picker\n");
+ vtkRenderWindowInteractor *iren = static_cast<vtkRenderWindowInteractor*>(caller);
+
+ int* pos = iren->GetEventPosition();
+ vtkCellPicker *picker = vtkCellPicker::New();
+ picker->SetTolerance(0.0005);
+ picker->Pick(pos[0], pos[1], 0, iren->GetRenderWindow()->GetRenderers()->GetFirstRenderer() );
+
+ if(picker->GetCellId() != -1)
+ {
+ printf("creaVtkCallbackPointPicker EED picker OK\n");
+ } else {
+ printf("creaVtkCallbackPointPicker EED picker --\n");
+ } // if
+
+
+/*
+{
+
+ std::cout << "Pick position is: " << worldPosition[0] << " " << worldPosition[1]
+ << " " << worldPosition[2] << endl;
+
+ vtkSmartPointer<vtkIdTypeArray> ids =
+ vtkSmartPointer<vtkIdTypeArray>::New();
+ ids->SetNumberOfComponents(1);
+ ids->InsertNextValue(picker->GetCellId());
+
+ vtkSmartPointer<vtkSelectionNode> selectionNode =
+ vtkSmartPointer<vtkSelectionNode>::New();
+ selectionNode->SetFieldType(vtkSelectionNode::CELL);
+ selectionNode->SetContentType(vtkSelectionNode::INDICES);
+ selectionNode->SetSelectionList(ids);
+
+ vtkSmartPointer<vtkSelection> selection =
+ vtkSmartPointer<vtkSelection>::New();
+ selection->AddNode(selectionNode);
+
+ vtkSmartPointer<vtkExtractSelection> extractSelection =
+ vtkSmartPointer<vtkExtractSelection>::New();
+#if VTK_MAJOR_VERSION <= 5
+ extractSelection->SetInput(0, this->Data);
+ extractSelection->SetInput(1, selection);
+#else
+ extractSelection->SetInputData(0, this->Data);
+ extractSelection->SetInputData(1, selection);
+#endif
+ extractSelection->Update();
+
+ // In selection
+ vtkSmartPointer<vtkUnstructuredGrid> selected =
+ vtkSmartPointer<vtkUnstructuredGrid>::New();
+ selected->ShallowCopy(extractSelection->GetOutput());
+
+ std::cout << "There are " << selected->GetNumberOfPoints()
+ << " points in the selection." << std::endl;
+ std::cout << "There are " << selected->GetNumberOfCells()
+ << " cells in the selection." << std::endl;
+
+
+#if VTK_MAJOR_VERSION <= 5
+ selectedMapper->SetInputConnection(
+ selected->GetProducerPort());
+#else
+ selectedMapper->SetInputData(selected);
+#endif
+
+ selectedActor->SetMapper(selectedMapper);
+ selectedActor->GetProperty()->EdgeVisibilityOn();
+ selectedActor->GetProperty()->SetEdgeColor(1,0,0);
+ selectedActor->GetProperty()->SetLineWidth(3);
+
+ this->Interactor->GetRenderWindow()->GetRenderers()->GetFirstRenderer()->AddActor(selectedActor);
+
+ }
+*/
+
+
+
+}
+
+
+//--------------------------------------------------------
+//--------------------------------------------------------
+//--------------------------------------------------------
+
+
+BBTK_ADD_BLACK_BOX_TO_PACKAGE(creaVtk,PointPicker)
+BBTK_BLACK_BOX_IMPLEMENTATION(PointPicker,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 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
+// 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 = " <<bbGetOutputOut() << std::endl;
+
+ if (firsttime==true)
+ {
+
+printf("EED PointPicker::Process Firsttime \n");
+ firsttime = false;
+// vtkCellPicker *picker = vtkCellPicker::New();
+// vtkPropPicker *picker = vtkCellPicker::New();
+// picker->SetTolerance(0.005);
+
+// picker->AddObserver("EndPickEvent", annotatePick)
+// iren = vtk.vtkRenderWindowInteractor()
+// iren.SetPicker(picker)
+
+/*
+ creaVtkCallbackPointPicker *callPicker = creaVtkCallbackPointPicker::New();
+ picker->AddObserver( vtkCommand::EndPickEvent , callPicker );
+ picker->AddObserver( vtkCommand::StartPickEvent , callPicker );
+ picker->AddObserver( vtkCommand::MouseMoveEvent , callPicker );
+ bbGetInputRenderer()->GetRenderWindow()->GetInteractor()->SetPicker(picker);
+*/
+
+ creaVtkCallbackPointPicker *callPicker = creaVtkCallbackPointPicker::New();
+ callPicker->_renderer = bbGetInputRenderer();
+ vtkRenderWindowInteractor *vrwi = bbGetInputRenderer()->GetRenderWindow()->GetInteractor();
+ vrwi->AddObserver( vtkCommand::EndPickEvent , callPicker );
+ vrwi->AddObserver( vtkCommand::StartPickEvent , callPicker );
+ vrwi->AddObserver( vtkCommand::MouseMoveEvent , callPicker );
+
+ } // if firsttime
+
+}
+//=====
+// 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::bbUserSetDefaultValues()
+{
+
+// SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX
+// Here we initialize the input 'In' to 0
+// bbSetInputIn(0);
+
+ firsttime=true;
+}
+//=====
+// 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
+
+
+}
+//=====
+// 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
+
+