how create a ply file from an extractedselection in a polydata

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

how create a ply file from an extractedselection in a polydata

cerina
Good morning,

any help in  : how to create a ply file from an extractedselection in a polydata. I tried with my last post, but i get just one triangle and shows me that there are 0 vertex.

Regards,
Cerina
Reply | Threaded
Open this post in threaded view
|

Re: how create a ply file from an extractedselection in a polydata

David Doria-2-3
On Tue, Sep 18, 2012 at 6:57 AM, cerina <[hidden email]> wrote:
> Good morning,
>
> any help in  : how to create a ply file from an extractedselection in a
> polydata. I tried with my last post, but i get just one triangle and shows
> me that there are 0 vertex.
>
> Regards,
> Cerina

http://www.vtk.org/Wiki/VTK/MinimalExample
_______________________________________________
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: how create a ply file from an extractedselection in a polydata

cerina
Hi david,
i tried your last suggestion : I create a new polydata and adding to it: points, vertices,lines and triangles like this:
// Assign all points to root node
for (int i=0;i<this->Input->GetNumberOfPoints();i++)
PointsNode->SetValue(i,0);

int NumberOfSplitNodes;
int Level=0;
for(int h=0;h<8; h++)
{
.................. // subdividing the octree
}
for(int m=1; m<NumberOfSplitNodes; m++)// debut de boucle des régions
{

vtkIdType v1;
vtkIdType v2;
vtkIdType v3;
vtkIdList *pts=vtkIdList::New();
vtkPoints* points = vtkPoints::New();
 vtkSmartPointer<vtkCellArray> vertices = vtkSmartPointer<vtkCellArray>::New();
vtkSmartPointer<vtkCellArray> triangles = vtkSmartPointer<vtkCellArray>::New();
 vtkSmartPointer<vtkCellArray> lines = vtkSmartPointer<vtkCellArray>::New();
 vtkSmartPointer<vtkTriangle> triangle = vtkSmartPointer<vtkTriangle>::New();
vtkSmartPointer<vtkLine> line0 = vtkSmartPointer<vtkLine>::New();
vtkSmartPointer<vtkLine> line1 = vtkSmartPointer<vtkLine>::New();
vtkSmartPointer<vtkLine> line2 = vtkSmartPointer<vtkLine>::New();
 int j=(this->Input->GetNumberOfPoints()/8);
for ( int k=0; k<j;k++)
{
double x[3];
this->Input->GetPointCoordinates(k,x);
vtkIdType pid[1];
pid[0] = points->InsertNextPoint(x[0],x[1],x[2]);
vertices->InsertNextCell(1,pid);
}
int jj=(this->Input->GetNumberOfCells()/8);
for (int k=0; k<jj;k++)
{
this->Input->GetFaceVertices(k,v1,v2,v3);
 line0->GetPointIds()->SetId ( 0,v1 );
  line0->GetPointIds()->SetId ( 1,v2 );
 
  line1->GetPointIds()->SetId ( 0,v1 );
  line1->GetPointIds()->SetId ( 1,v3 );
 
  line2->GetPointIds()->SetId ( 0,v2 );
  line2->GetPointIds()->SetId ( 1,v3 );
lines->InsertNextCell(line0);

  lines->InsertNextCell( line1 );
  lines->InsertNextCell( line2 );
 
triangle->GetPointIds()->SetId(v1,v1);
triangle->GetPointIds()->SetId(v2,v2);
triangle->GetPointIds()->SetId(v3,v3);
triangles->InsertNextCell(triangle);
                       
}

            vtkSmartPointer<vtkPolyData> newdata =
   vtkSmartPointer<vtkPolyData>::New();
                       
 
newdata->SetPoints(points);
newdata->SetVerts(vertices);
newdata->SetLines(lines);
newdata->SetPolys(triangles);


vtkPLYWriter *Writer=vtkPLYWriter::New();

Writer->SetInput(newdata);
std::stringstream strfile;
strfile<<"Region"<<m<<".ply";
Writer->SetFileName(strfile.str().c_str());
Writer->Write();

}

but i got just one file and when i open it, i visualize just one triangle:
Reply | Threaded
Open this post in threaded view
|

Re: how create a ply file from an extractedselection in a polydata

cerina
is there any body who can give me a suggestion to resolve my problem please!!! , i know that may be , there are vertices which are linked to my faces, and didn't appears nor in the list of vertices neither in my points may be
Reply | Threaded
Open this post in threaded view
|

Re: how create a ply file from an extractedselection in a polydata

Alex Malyushytskyy
My suggestion is start using debugger,
and review your coding style.

For example:

int NumberOfSplitNodes;
........
for(int m=1; m<NumberOfSplitNodes; m++)// debut de boucle des régions
.........

NumberOfSplitNodes variable is undefined but used.
As I mentioned already compiler should have provide a warning and you
expected to read (at least) them,
but if you did not declare variable in a "C" style without
initialization it would not happen.


Also if you want somebody to look in your code deeply you should have
provided as small; as possible
self - sufficient example and make sure it is posted in the way it can
be compiled as is and it is clear what you are trying to achieve.
May be some comments could help. For example why /8 in the following line?
 int j=(this->Input->GetNumberOfPoints()/8);

Alex

On Tue, Sep 18, 2012 at 12:10 PM, cerina <[hidden email]> wrote:

> is there any body who can give me a suggestion to resolve my problem
> please!!! , i know that may be , there are vertices which are linked to my
> faces, and didn't appears nor in the list of vertices neither in my points
> may be
>
>
>
> --
> View this message in context: http://vtk.1045678.n5.nabble.com/how-create-a-ply-file-from-an-extractedselection-in-a-polydata-tp5716164p5716179.html
> Sent from the VTK - Users mailing list archive at Nabble.com.
> _______________________________________________
> 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
_______________________________________________
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