[vtkusers] Crashing while trying to improve peformance
Konstantinos Kelg
kkelgeor at yahoo.gr
Sun Nov 30 16:06:34 EST 2008
Hello,
(I have corrected some things in my previous mail)
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,a1,b1,c1, 3,a2,b2,c2, 3,a3,b3,c3, ...............}
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();
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, VerticesP[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/20081130/04a4cb4e/attachment.htm>
More information about the vtkusers
mailing list