[vtkusers] Crashing while trying to improve performance...
Konstantinos Kelg
kkelgeor at yahoo.gr
Sat Nov 29 15:35:46 EST 2008
Hello,
I 'm creating a 3D animation, visualizing a 3D surface per frame (the data get loaded from
files) and I 've tried to improve it's speed. I give you my code below. I 've tried to speed up
the setting of vertex and cell data by using "SetArray" instead of looping through the
whole array. Setting the vertex data works fine, causing no trouble, but when I try to set the
cell data I get crashes. The code for setting the vertex and the cell data is quite similar, so
I can't understand why the 1st works while the other fails... :(
I am a beginner in VTK. Any kind of help would be highly appreciated.
The "(int*)TPoints" variable is a pointer to integer data that defines triangles like the
following:
{3,x1,y1,z1, 3,x2,y2,z2, 3,x3,y3,z3, ...............} repeated "m_NumOfTriangles"
times.
#define FAST // Enable fast vertex data set.
#define FAST_2 // Enable fast cell data set.
.....
.....
if( !LoadTrianglesFromFile(lpStr,false) ) return;
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
vtkPoints *points = vtkPoints::New();
#ifdef FAST
points->SetDataTypeToFloat(); // I'm not sure if this is needed and what it does.
vtkFloatArray* da = vtkFloatArray::New();
da->SetNumberOfComponents(3);
da->SetArray((float*)VerticesP, m_NumOfVertices*3*sizeof(float), 1);
points->SetData(da);
da->Delete();
#else
for(int k=0; k<m_NumOfVertices; k++)
{
points->SetPoint(k, Vertices[k].coords);
}
#endif
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
vtkCellArray *cellArray = vtkCellArray::New();
#ifdef FAST_2
cellArray->SetNumberOfCells(m_NumOfTriangles);
vtkIdTypeArray *ita = vtkIdTypeArray::New();
ita->SetNumberOfComponents(4);
ita->SetArray((int*)TPoints, m_NumOfTriangles*4*sizeof(int), 1);
cellArray->SetCells(m_NumOfTriangles, ita);
ita->Delete();
#else
for(int k=0; k<m_NumOfTriangles; k++)
{
cellArray->InsertNextCell(3, TPoints[k].corners);
}
#endif
Thanks.
___________________________________________________________
Χρησιμοποιείτε Yahoo!;
Βαρεθήκατε τα ενοχλητικά μηνύματα (spam); Το Yahoo! Mail
διαθέτει την καλύτερη δυνατή προστασία κατά των ενοχλητικών
μηνυμάτων http://login.yahoo.com/config/mail?.intl=gr
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20081129/f4fbeee2/attachment.htm>
More information about the vtkusers
mailing list