[vtkusers] xxxxxSPAMxxxxx xxxxxSPAMxxxxx VtkIdType Polygon

David Doria daviddoria+vtk at gmail.com
Wed Jul 7 15:06:18 EDT 2010


On Wed, Jul 7, 2010 at 9:49 AM, alex <alexdowson at hotmail.com> wrote:
> Hi
>
> I have some array of polygon in which some is triangles,some is quads, some
> is polygon. Mean it is mixed array. It renders peferct as i need.
>
> Now my question is i want to do some collision detection stuff and it need
> triangles as input so do i need to convert this n-side polygon into
> triangles ?
>
>
> My arrays are looks like this.
>
> static vtkIdType pid3[3][3]= {{41,56,49},{42,49,50},{43,50,51},};
> static vtkIdType pid4[3][4] ={{0,1,9,2},{0,2,11,3},{0,3,13,4},}
> static vtkIdType pid5[3][5] =
> {{87,88,9,1,24},{57,58,10,2,9},{59,60,11,2,10},}
> static vtkIdType pid8[8]= {56,55,54,53,52,51,50,49};
>
>
> I am using this code right now is this.
>
> // copy cells
> vtkIdType* polys = poly->GetPolys()->GetPointer();
>
> for (int i=0; i<numCellFirst; i++)
> {
>  udword a = *(polys+1+i*4);
>  udword b = *(polys+2+i*4);
>  udword c = *(polys+3+i*4);
>
> // copy to collision detection
>
> triangles[i] = IndexedTriangle(a,b,c);
>
> }
>
>
> Any clue ?
>
> Alex

Alex,

If you want to convert your mesh to triangles, you can use this:
http://www.vtk.org/Wiki/VTK/Examples/Meshes/Triangulate_a_mesh

However, I think you should instead use Bryn's code form here:
http://www.midasjournal.org/browse/publication/726 - it works great!

Thanks,

David



More information about the vtkusers mailing list