Triangle Strips
Matthew Hall
mahall at math.uiuc.edu
Fri Dec 17 12:21:46 EST 1999
Note that VTK uses an indexed scheme for strips - I.e. the vtkPointData
is not
ordered at all. (Which might explain why you were getting triangles from
all over)
The ordering is actually stored in an array of integers (encased in a
vtkCellArray). The format is:
(m,i1,i2,i3,i4,...im , n,i1,i2,..., in,...)
where m and n are the number of vertices in a strip and the i's are
indexes into
the point data. The triangles are stored as mentioned below.
Thus, given vtkPolyData, you can extract the strips as follows - this
example
would print out the vertex coordinates for each triangle in the strip.
(Completely
non-optimized code here!)
void PrintTriangle(float *,float *, float *); //just a big 'ol cout<<
statement
...
void PrintStrips(){
vtkPolyData *mypoly = ...;
vtkPoints *mypoints = mypoly->GetPoints();
vtkCellArray *mystrips = mypoly->GetStrips();
int *indices=mystrips->GetPointer();
int numindices=mystrips->GetNumberOfConnectivityEntries(); //Whoa!
int idx=0;
while (idx<numindices){
int striplen=indices[idx]; //Get length of next strip
idx++;
for (int jj=0;jj<striplen-2;jj++){
float A[3],B[3],C[3]; //coordinates of triangle vertices
mypoints->GetPoint(indices[idx],A);
mypoints->GetPoint(indices[idx+1],B);
mypoints->GetPoint(indices[idx+2],C);
PrintTriangle(A,B,C);
idx++;
}
}
}
I would imaging that OpenInventor's indexed triangle strip format is
within epsilon of VTK's - i.e. the number of vertices in the strip,
followed
by the indices of the vertices. VTK just stuffs 'em all into one big
array.
-matt
Will Schroeder wrote:
>
> Hi Nils-
>
> First three points define a triangle (p0,p1,p2), then each additional point p3 defines a triangle by using (p1,p2,p3) and so on.
>
> Will
>
> At 05:00 PM 12/17/99 +0100, Nils Holger Busch wrote:
> >Hello,
> >
> >can anyone enlighten me how the cell and point structure of a
> >vtkPolyData triangle strip as output from vtkStripper actually looks
> >like? I found the description in the book a little terse.
> >
> >Specifically, I need to transform the vtk triangle strips into
> >OpenInventor triangle strips (either SoTriangleStripSet or
> >SoIndexedTriangleStripSet, depending on the vtk format). Has anyone done
> >this and is willing to share his code.
> >
> >I have tried transforming the vtk triangle strips into a
> >SoTriangleStripSet, but the output has the wrong toplogy ( jagged
> >triangles connecting separate triangle strips ).
> >
> >Thanks.
> >
> >--
> >Best regards,
> > Nils H. Busch
> >
-----------------------------------------------------------------------------
This is the private VTK discussion list. Please keep messages on-topic.
Check the FAQ at: <http://www.automatrix.com/cgi-bin/vtkfaq>
To UNSUBSCRIBE, send message body containing "unsubscribe vtkusers" to
<majordomo at gsao.med.ge.com>. For help, send message body containing
"info vtkusers" to the same address. Live long and prosper.
-----------------------------------------------------------------------------
More information about the vtkusers
mailing list