[vtkusers] unhandled exception in program using MouseInteraction

cerina cerine-baratelli at hotmail.fr
Sun Sep 2 17:03:10 EDT 2012


sorry, it was a mistake when I create the post for the first time ( it was in
html format), and here is the code:
#include <vtkObjectFactory.h>
#include "vtkOctree.h" 
#include "RenderWindow.h" 
#include <vtkRenderWindowInteractor.h>
#include <vtkInteractorStyleTrackballCamera.h>
#include <vtkPointPicker.h>
#include <vtkSmartPointer.h>
#include <vtkUnstructuredGrid.h>
#include <vtkPolyDataMapper.h>
#include <vtkActor.h>
// Catch mouse events 
class MouseInteractorStyle : public vtkInteractorStyleTrackballCamera 
{ 
  public: 
  static MouseInteractorStyle* New(); 

  vtkSurface* Mesh2;// here is the input Data 
  vtkIntArray *lesNodes;// this is the nodes of the octree 
  
    virtual void OnLeftButtonDown() 
    { 

      int* pos = this->GetInteractor()->GetEventPosition(); 
  vtkSmartPointer<vtkPointPicker> picker = 
  vtkSmartPointer<vtkPointPicker>::New(); 
  picker->Pick(pos[0], pos[1], pos[2], this->GetDefaultRenderer()); 
  double* worldPosition = picker->GetPickPosition(); 
  vtkIdType c=picker->GetPointId(); 
  cout<<" the PointId is : "<<picker->GetPointId()<<endl; 
  cout&lt;&lt;&quot; point coordinates are:
&quot;&lt;&lt;pos[0]&lt;&lt;&quot; &quot;&lt;&lt;pos[1]&lt;&lt;&quot;
&quot;&lt;&lt;pos[2]&lt;&lt;endl; 
               Mesh2->GetPoint(c); 
        cout<<"nombre des sommets : "<<	Mesh2->GetNumberOfPoints()<<endl; 
 
this->Interactor->GetRenderWindow()->GetRenderers()->GetFirstRenderer()->AddActor(selectedActor); 
      vtkInteractorStyleTrackballCamera::OnLeftButtonDown(); 
        }; 
}; 
  
vtkStandardNewMacro(MouseInteractorStyle); 

void vtkOctree::Decompose(vtkSurface *Mesh1) 
{ 
        RenderWindow *Window=RenderWindow::New(); 
        Window->SetInput(this->Input); 
        vtkIntArray *PointsNode=vtkIntArray::New(); 
        PointsNode->SetNumberOfValues(this->Input->GetNumberOfPoints()); 
               /***********************************/ 
                here , there is the long code that  subdivide the octree: i
will not put it 
               /***********************************/ 

                // create polydata for visualization 
        cout<<NumberOfSplitNodes&lt;&lt;&quot; Nodes
split&quot;&lt;&lt;endl; 
        Window->DisplayVerticesColors(PointsNode); 
        Window->Render(); 
             //here i initialize the interaction 
             vtkRenderWindowInteractor
*interactor=vtkRenderWindowInteractor::New(); 
        interactor->SetRenderWindow(Window->GetvtkRenderWindow()); 
        interactor->Initialize(); 
        vtkSmartPointer<MouseInteractorStyle> style =
vtkSmartPointer<MouseInteractorStyle>::New(); 
        style->Mesh2=Mesh1; 
        style->lesNodes=PointsNode; 
        interactor->SetInteractorStyle(style); 
        Window->GetvtkRenderWindow()->SetInteractor(interactor); 
        interactor->Start(); 
        Window->Interact(); 
                
        Window->Delete(); 
        PointsNode->Delete(); 
} 

and this is the main  file: 

#include "vtkSurface.h" 
#include "RenderWindow.h" 
#include "vtkOctree.h" 


int main( int argc, char *argv[] ) 
{ 
         // Parse command line arguments 
  if(argc != 2) 
    { 
    std::cout << "Usage: " << argv[0] << " Filename(.ply)" << std::endl; 
    return EXIT_FAILURE; 
    } 

        vtkSurface *Mesh; 
        
        // Load the mesh and create the vtkSurface data structure 
        Mesh=vtkSurface::New(); 
        cout <<"load : "<<argv[1]&lt;&lt;endl; 
        Mesh->CreateFromFile(argv[1]); 
        Mesh->DisplayMeshProperties(); 
        
        vtkOctree *Octree=vtkOctree::New(); 
        Octree->SetInput(Mesh); 
        Octree->Decompose(Mesh); 
        
        return (0); 
} 
Sorry again



--
View this message in context: http://vtk.1045678.n5.nabble.com/unhandled-exception-in-program-using-MouseInteraction-tp5715775p5715777.html
Sent from the VTK - Users mailing list archive at Nabble.com.



More information about the vtkusers mailing list