<div class="gmail_quote">On Sun, Sep 2, 2012 at 4:40 PM, cerina <span dir="ltr">&lt;<a href="mailto:cerine-baratelli@hotmail.fr" target="_blank">cerine-baratelli@hotmail.fr</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hi, 
I&#39;m using vtkOctree to segment my Mesh to 8 regions. I tried to pick on the mesh in order to get the picked point&#39;s coordinates, but i got an unhandled exception. The program is using the vtk Octree, here is my code:
<h3>
#include <u></u>
#include &quot;vtkOctree.h&quot;
#include &quot;RenderWindow.h&quot;
#include <u></u>
#include <u></u>
#include <u></u>
#include <u></u>
#include <u></u>
#include <u></u>
#include <u></u>
// Catch mouse events
class MouseInteractorStyle : public vtkInteractorStyleTrackballCamera
{
  public:
  static MouseInteractorStyle* New();

  vtkSurface* Mesh2;
  vtkIntArray *lesNodes;
 
    virtual void OnLeftButtonDown()
    {
                
      // Get the location of the click (in window coordinates)
      int* pos = this-&gt;GetInteractor()-&gt;GetEventPosition();
 
          vtkSmartPointer<u></u> picker =
        vtkSmartPointer<u></u>::New();
     
 
      // Pick from this location.
      picker-&gt;Pick(pos[0], pos[1], pos[2], this-&gt;GetDefaultRenderer());
 
      double* worldPosition = picker-&gt;GetPickPosition();
          vtkIdType c=picker-&gt;GetPointId();
          cout&lt;&lt;&quot; the PointId is : &quot;&lt;<u></u>GetPointId()&lt;&lt;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-&gt;GetPoint(c);
                cout&lt;&lt;&quot;nombre des sommets : &quot;&lt;&lt;        Mesh2-&gt;GetNumberOfPoints()&lt;&lt;endl;
                
  this-&gt;Interactor-&gt;GetRenderWindow()-&gt;GetRenderers()-&gt;GetFirstRenderer()-&gt;AddActor(selectedActor);
 
        
      // Forward events
      vtkInteractorStyleTrackballCamera::OnLeftButtonDown();
        };

 
   // vtkSmartPointer<u></u> Data;
    vtkSmartPointer<u></u> selectedMapper;
    vtkSmartPointer<u></u> selectedActor;
 
};
 
vtkStandardNewMacro(MouseInteractorStyle);




void vtkOctree::Decompose(vtkSurface *Mesh1)
{
//        vtkSurface *Edges=vtkSurface::New();
        
        RenderWindow *Window=RenderWindow::New();
        Window-&gt;SetInput(this-&gt;Input);
        
        vtkIntArray *PointsNode=vtkIntArray::New();
        PointsNode-&gt;SetNumberOfValues(this-&gt;Input-&gt;GetNumberOfPoints());
        
        std::vector<u></u> Nodes;
        
        Node Node1;
        
        double Bounds[6];
        
        this-&gt;Input-&gt;GetPoints()-&gt;ComputeBounds();
        this-&gt;Input-&gt;GetPoints()-&gt;GetBounds(Bounds);
        
        // Create Root Node and push it into the array of nodes
        Node1.NumberOfPoints=this-&gt;Input-&gt;GetNumberOfPoints();
        // subdivide the Mesh to 8 areas
        for (int i=0;i&lt;3;i++)
        {
                Node1.Center[i]=0.5*(Bounds[2*i+1]+Bounds[2*i]);
                Node1.Radius[i]=0.5*(Bounds[2*i+1]-Bounds[2*i]);
        }
        Nodes.push_back(Node1);
        
        // Assign all points to root node        
        for (int i=0;i<u></u>Input-&gt;GetNumberOfPoints();i++)
                PointsNode-&gt;SetValue(i,0);
        
        int NumberOfSplitNodes;
        int Level=0;
        for(int h=0;h&lt;2; h++)
        {
                cout&lt;&lt;&quot;Level &quot;&lt;&lt;Level++&lt;&lt;endl;
                NumberOfSplitNodes=0;
                for (int i=0;i&lt;this-&gt;Input-&gt;GetNumberOfPoints();i++)
                {
                        int NodeId=PointsNode-&gt;GetValue(i);
                        if (Nodes[NodeId].NeedsSplit())
                        {
                                if (!Nodes[NodeId].HasChildren())
                                {
                                        NumberOfSplitNodes++;
                                        // we need to create 8 sub-nodes (one for each octant)
                                        int Coordinates[3];
                                        for (Coordinates[0]=0;Coordinates[0]&lt;2;Coordinates[0]++)
                                        {
                                                for (Coordinates[1]=0;Coordinates[1]&lt;2;Coordinates[1]++)
                                                {
                                                        for (Coordinates[2]=0;Coordinates[2]&lt;2;Coordinates[2]++)
                                                        {
                                                                Node1.Reset();
                                                                // Create one child node
                                                                for (int j=0;j&lt;3;j++)
                                                                {
                                                                        Node1.Center[j]=Nodes[NodeId].Center[j]+
                                                                                ((double) Coordinates[j]-0.5)*Nodes[NodeId].Radius[j];
                                                                        Node1.Radius[j]=0.5*Nodes[NodeId].Radius[j];



                                                                }
                                                                
                                                                Nodes[NodeId].Children[Coordinates[0]][Coordinates[1]][Coordinates[2]]=
                                                                        Nodes.size();
                                                                Nodes.push_back(Node1);
                                                        }
                                                }
                                        }
                                }
                                double Point[3];
                                this-&gt;Input-&gt;GetPoint(i,Point);
                                int Coordinates[3];
                                for (int j=0;j&lt;3;j++)
                                {
                                        if (Point[j]&lt;Nodes[NodeId].Center[j])
                                                Coordinates[j]=0;
                                        else
                                                Coordinates[j]=1;
                                }
                                int Child=Nodes[NodeId].Children[Coordinates[0]][Coordinates[1]][Coordinates[2]];
                                PointsNode-&gt;SetValue(i,Child);
                                Nodes[Child].NumberOfPoints++;
                                
                                
                                
                }
                        
                        
                }
                h++;

                               
                         
                        
                               
        };
        
                // create polydata for visualization

                cout&lt;&lt;NumberOfSplitNodes&lt;&lt;&quot; Nodes split&quot;&lt;&lt;endl;
                Window-&gt;DisplayVerticesColors(PointsNode);
                Window-&gt;Render();
                
                <font color="#32CD32"> //here i initialize the interaction</font>
                vtkRenderWindowInteractor *interactor=vtkRenderWindowInteractor::New();
                interactor-&gt;SetRenderWindow(Window-&gt;GetvtkRenderWindow());
                
                interactor-&gt;Initialize();
                
                vtkSmartPointer<u></u> style = vtkSmartPointer<u></u>::New();
                style-&gt;Mesh2=Mesh1;
                style-&gt;lesNodes=PointsNode;
                interactor-&gt;SetInteractorStyle(style);
                
                Window-&gt;GetvtkRenderWindow()-&gt;SetInteractor(interactor);
                interactor-&gt;Start();
                Window-&gt;Interact();
                
        Window-&gt;Delete();
        PointsNode-&gt;Delete();
}
</h3>
and this is the main  file:
#include &quot;vtkSurface.h&quot;
#include &quot;RenderWindow.h&quot;
#include &quot;vtkOctree.h&quot;


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

        vtkSurface *Mesh;
        
        // Load the mesh and create the vtkSurface data structure
        Mesh=vtkSurface::New();
        cout &lt;&lt;&quot;load : &quot;&lt;&lt;argv[1]&lt;&lt;endl;
        Mesh-&gt;CreateFromFile(argv[1]);
        

        // prints to standard output the mesh caracteristics
        Mesh-&gt;DisplayMeshProperties();
        
        vtkOctree *Octree=vtkOctree::New();
        Octree-&gt;SetInput(Mesh);
        Octree-&gt;Decompose(Mesh);
        
        return (0);
}<br></blockquote><div><br></div>Please ensure your code formatting remains when composing your message to the mailing list. This is impossible to read.<br clear="all"><br>David </div><br>