create a vtkPolydata from a list of PointId

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

create a vtkPolydata from a list of PointId

cerina
Hi all,
when i pick on the mesh, i retrieve a list of pointId that are not ordered ( eg: 1,5, 17...).So i want to create a polydata from those points.I try to do that, but it didn't work, and the progam is blocked. Is there any body who can correct my code:

 vtkSmartPointer<vtkIdTypeArray> idss = vtkSmartPointer<vtkIdTypeArray>::New();
         
           for(int cc=0; cc<polydata->GetNumberOfPoints();cc++)
           {
                   if(PointsNode->GetValue(cc)==region)
                   {
           idss->SetNumberOfComponents(1);
            idss->InsertNextValue(cc);
                                   }
           }
                   vtkSmartPointer<vtkSelectionNode> selectionNode =
                vtkSmartPointer<vtkSelectionNode>::New();
            selectionNode->SetFieldType(vtkSelectionNode::CELL);
            selectionNode->SetContentType(vtkSelectionNode::INDICES);
            selectionNode->SetSelectionList(idss);

            vtkSmartPointer<vtkSelection> selection =
                vtkSmartPointer<vtkSelection>::New();
            selection->AddNode(selectionNode);

            vtkSmartPointer<vtkExtractSelection> extractSelection =
                vtkSmartPointer<vtkExtractSelection>::New();

                        extractSelection->SetInput(0, this->reader->GetOutput());
            extractSelection->SetInput(1, selection);
            extractSelection->Update();

            selected->ShallowCopy(extractSelection->GetOutput());

            vtkSmartPointer<vtkPolyData> newdata =
                vtkSmartPointer<vtkPolyData>::New();
            newdata->SetPoints(selected->GetPoints());

            newdata->SetPolys(selected->GetCells());

I want then to change the points of this newdata with a list of vtkPoints that i stored:
 while(i<nbrcor)//nbcor : is the number of points that i stored in the vector <b>sommet
 {
        newpoints->InsertNextPoint(sommet[si][0],sommet[si][1],sommet[si][2]);
        i++;
          }
newdata->SetPoints(newpoints);

but nothing is ok, the program is blocked.
Also I tried to insert my newpoints like this:
for(int n=0;n<nbrcor;n++)
                        {
                                double* somm=sommet[n];
                        newdata->GetPoints()->InsertNextPoint(somm);
            newdata->GetVerts()->InsertNextCell(n+1);
            newdata->GetVerts()->InsertCellPoint(newdata->GetPoints()->GetNumberOfPoints()-1);
            newdata->Update();
                        }
                        polydata->GetPoints()->Modified();
                        polydata->Modified();
                        polydata->Update();
But, also, nothing is going on. any help please.
                 

Best regards,
Cerina
Reply | Threaded
Open this post in threaded view
|

Re: create a vtkPolydata from a list of PointId

David Doria-2-3
On Sun, Sep 9, 2012 at 11:50 AM, cerina <[hidden email]> wrote:
> Hi all,
> when i pick on the mesh, i retrieve a list of pointId that are not ordered (
> eg: 1,5, 17...).So i want to create a polydata from those points.I try to do
> that, but it didn't work, and the progam is blocked. Is there any body who
> can correct my code:

What do you mean by "nothing is going on" and "the program is
blocked"? Please follow these guidelines when posting questions and
code:

http://www.vtk.org/Wiki/VTK/MinimalExample

David
_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ

Follow this link to subscribe/unsubscribe:
http://www.vtk.org/mailman/listinfo/vtkusers
Reply | Threaded
Open this post in threaded view
|

Re: create a vtkPolydata from a list of PointId

cerina
This post was updated on .
David Doria-2-3 wrote
What do you mean by "nothing is going on" and "the program is
blocked"? Please follow these guidelines when posting questions and
code:

http://www.vtk.org/Wiki/VTK/MinimalExample

David
Thanks David for reply
okay, I'll explain more. I have an application that is used to refine a mesh 3D.I have 8 files containing the coordinates of the vertices of the 8 mesh's region. when I pick in the mesh, I retrieve the pickedPoint and I  retrieve also all points that belong to the same region as pickedPoint.
my question is: is it possible to create a vtkpolydata from these points recovered and change it by eliminating all vertices and inserting the vertices of the file.
I also have for each region of the final mesh, a file that contains a list of vertices of each face.
My code is very long, and it is implemented in the class MouseInteractorStyle. I do'nt know what I should put and what is optional, because everything is related to each other.

Best Regards
Reply | Threaded
Open this post in threaded view
|

Re: create a vtkPolydata from a list of PointId

cerina
This post was updated on .
In reply to this post by David Doria-2-3
David Doria-2-3 wrote
What do you mean by "nothing is going on" and "the program is
blocked"? Please follow these guidelines when posting questions and
code:

http://www.vtk.org/Wiki/VTK/MinimalExample

David
i have this image, i will pick in the green region

when i pick in it, i will retrieve all points that belongs to the same region (the green one), i want to create a newpolydata from this region, and my question is: is it possible to delete all points from this newpolydata, and fill it with other points ( which belongs at the final mesh) in to have this image, i mean, just the green region will be like the green one in the second image:


thanks again

Cerina