[vtkusers] problem with vtkPolyData

Vincent BAUDET vbaudet at bat710.univ-lyon1.fr
Tue Dec 17 13:28:15 EST 2002


Hi,
I just found the problem,

In fact I didn't see very well that the vtkPolyData need an order in the
definition of certain cells.

Bye.

Vincent BAUDET wrote:

> Hello everybody,
>
> I have began to use vtk in order to know if it was accurate enough for
> modeling and animation.
>
> I used a vtkPolyData
> it seemed very easy to use with the cube example in C++
> but when i tried to make my own model :
>               first of all, 2 tetrahedra with links between points, I
> was surprised to find that my polydata had the origin
> point, that I never put in it and that this point was linked to the
> others or that some links I never defined were
> obtained.
>               I then tried to change the order in the link affectation
> at one time this point disapear.
>               Almost, I used the same code in an other PC, and the
> point was not added.... (strange)
>
> Is there any allocation I don't do and I should do?
> Is there any people that can answer what happened?
>
> Here is one example of code (look  at the definition liens.... and try
> with this state and try with the change I used):
>
> #include "vtkPoints.h"
> #include "vtkCellArray.h"
> #include "vtkPolyData.h"
> #include "vtkPolyDataMapper.h"
> #include "vtkActor.h"
> #include "vtkRenderer.h"
> #include "vtkRenderWindow.h"
> #include "vtkRenderWindowInteractor.h"
> #include "vtkMath.h"
> #include "vtkFloatArray.h"
>
> float pt[5][3]={{10,10,10} , {20,30,10} , {30,20,10} , {20,20,35},
> {15,45,65}};
>
> //Look Here
>
> int liens[9][2]={{1,2} ,{2,0},
> {1,0},{1,3},{3,0},{2,3},{3,4},{4,2},{1,4}}; // replace (1,4) by (4,1)
>
> int
> faces[7][3]={{2,1,0},{0,1,3},{0,2,3},{1,2,3},{4,2,3},{4,3,1},{4,1,2}};
>
> int main()
> {
>   unsigned int i;
>
>   vtkPolyData *cube=vtkPolyData::New();
>
>   vtkPoints *points=vtkPoints::New();
>
>   for(i=0;i<(unsigned
> int)(sizeof(pt)/(3*sizeof(float)));i++)points->InsertPoint(i,pt[i]);
>
>   vtkCellArray *links=vtkCellArray::New();
>
>   for(i=0;i<(unsigned
> int)(sizeof(liens)/(2*sizeof(int)));i++)links->InsertNextCell(VTK_LINE,liens[i]);
>
>   vtkCellArray *polys=vtkCellArray::New();
>
>   for(i=0;i<(unsigned
> int)(sizeof(faces)/(3*sizeof(int)));i++)links->InsertNextCell(VTK_TRIANGLE,faces[i]);
>
>   cube->SetPoints(points);
>   points->Delete();
>
>   cube->SetLines(links);
>   links->Delete();
>
>   cube->SetStrips(polys);
>   polys->Delete();
>
>   vtkPolyDataMapper *cubeMapper = vtkPolyDataMapper::New();
>   cubeMapper->SetInput(cube);
>   cubeMapper->SetScalarRange(0,7);
>
>   vtkActor* cubeActor = vtkActor::New();
>   cubeActor->SetMapper(cubeMapper);
>   cubeActor->GetProperty()->SetColor(0,0,1);
>
>   vtkRenderer *renderer = vtkRenderer::New();
>   vtkRenderWindow *renWin = vtkRenderWindow::New();
>   renWin->AddRenderer(renderer);
>
>   vtkRenderWindowInteractor *iren = vtkRenderWindowInteractor::New();
>   iren->SetRenderWindow(renWin);
>
>   renderer->AddActor(cubeActor);
>   renderer->SetBackground(1,1,1);
>
>   renWin->SetSize(300,300);
>
>   // interact with data
>   renWin->Render();
>   iren->Start();
>
>   // Clean up
>
>   cube->Delete();
>   cubeMapper->Delete();
>   cubeActor->Delete();
>   renderer->Delete();
>   renWin->Delete();
>   iren->Delete();
>
>   return 0;
>
> }
>
>
>
> Thank you for your answer.
>
> --
> ===============================================================================
> e-mail : vbaudet at bat710.univ-lyon1.fr
> Batiment 710, UFR Informatique, Universite Claude Bernard Lyon 1
> 43 boulevard du 11 novembre 1918, 69622 Villeurbanne cedex, France
>
>

--
===============================================================================
e-mail : vbaudet at bat710.univ-lyon1.fr
Batiment 710, UFR Informatique, Universite Claude Bernard Lyon 1
43 boulevard du 11 novembre 1918, 69622 Villeurbanne cedex, France


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20021217/e5d363dd/attachment.htm>


More information about the vtkusers mailing list