<P>Hi everybody,</P>
<P>I am new to vtk, I tried to create a cube datatype (see the code below), when I called the polys->SetCells(12, IdTypeArray) function the system crashes.</P>
<P>Is it the correct manner to set the cell type as VTK_TETRA like this?</P>
<P>vtkIdTypeArray *IdTypeArray = vtkIdTypeArray::New(); <BR>IdTypeArray->SetNumberOfValues(12);</P>
<P>for (i=0; i<12; i++) {<BR> polys->InsertNextCell(4,pts[i]); // tetra<BR> IdTypeArray->SetValue(i,VTK_TETRA);<BR>}<BR>polys->SetCells(12, IdTypeArray);</P>
<P>thanks for your time</P>
<P>Naim</P>
<P>// code source</P>
<P>void CGLModelViewCtrl::Cube()<BR>{</P>
<P>static float x[9][3]={{5.000000e-001, -2.840789e-002, 4.103363e-002}, </P>
<P> {0.000000e+000, -2.840789e-002, 4.103363e-002}, <BR> {5.000000e-001, -2.840789e-002, -4.589664e-001}, <BR> {0.000000e+000, -2.840789e-002, -4.589664e-001},<BR> {5.000000e-001, 4.715921e-001, -4.589664e-001}, <BR> {0.000000e+000, 4.715921e-001, -4.589664e-001}, <BR> {5.000000e-001, 4.715921e-001, 4.103363e-002}, <BR> {0.000000e+000, 4.715921e-001, 4.103363e-002},<BR> {3.438136e-001, 2.000117e-001, -2.254762e-001}};</P>
<P>static vtkIdType pts[12][4]={{1, 0, 8, 7}, <BR> {7, 0, 8, 6}, <BR> {1, 5, 8, 3},<BR> {5, 3, 4, 8}, <BR> {4, 5, 8, 6}, <BR> {4, 8, 2, 6},<BR> {8, 7, 5, 1},<BR> {6, 8, 2, 0},<BR> {0, 8, 2, 1},<BR> {1, 8, 2, 3},<BR> {8, 4, 2, 3},<BR> {6, 7, 5, 8}};</P>
<P> </P>
<P>// We'll create the building blocks of polydata including data attributes.</P>
<P>cube = vtkPolyData::New();<BR>points = vtkPoints::New();<BR>polys = vtkCellArray::New();<BR>scalars = vtkFloatArray::New();</P>
<P>// Load the point, cell, and data attributes.</P>
<P>for (int i=0; i<9; i++) points->InsertPoint(i,x[i]);</P>
<P>vtkIdTypeArray *IdTypeArray = vtkIdTypeArray::New(); <BR>IdTypeArray->SetNumberOfValues(12);</P>
<P>for (i=0; i<12; i++) {<BR> polys->InsertNextCell(4,pts[i]);<BR> IdTypeArray->SetValue(i,VTK_TETRA);<BR>}<BR>polys->SetCells(12, IdTypeArray);</P>
<P>scalars->InsertTuple1(0,0.866885);<BR>scalars->InsertTuple1(1,0.562442);<BR>scalars->InsertTuple1(2,0.661086);<BR>scalars->InsertTuple1(3,0);<BR>scalars->InsertTuple1(4,0.740853);<BR>scalars->InsertTuple1(5,1);<BR>scalars->InsertTuple1(6,0.728700);<BR>scalars->InsertTuple1(7,0.739150);<BR>scalars->InsertTuple1(8,0.260398);</P>
<P>// We now assign the pieces to the vtkPolyData.</P>
<P>cube->SetPoints(points);<BR>points->Delete();<BR>cube->SetPolys(polys);<BR>polys->Delete();<BR>cube->GetPointData()->SetScalars(scalars);<BR>cube->Squeeze();<BR>cube->Update();<BR>scalars->Delete();</P>
<P>// Now we'll look at it.</P>
<P>cubeMapper = vtkPolyDataMapper::New();<BR>cubeMapper->SetInput(cube);</P>
<P>cubeActor = vtkActor::New();<BR>cubeActor->SetMapper(cubeMapper);<BR>renderer->AddActor(cubeActor);<BR>renderer->SetActiveCamera(camera);<BR>renderer->ResetCamera();<BR>}</P><p><br><hr size=1>Post your free ad now! <a href="http://ca.personals.yahoo.com/"><b>Yahoo! Canada Personals</b></a><br>