[vtkusers] Manually constructing a vtkPolyData
Dai Qiang
dqreg at yahoo.com.cn
Wed May 18 21:31:56 EDT 2005
Hi Randall,
This piece of code might be helpful.
for(int i=0;i<count;i++)
{
int a, b, c;
importCellArray->InsertNextCell(3);
importCellArray->InsertCellPoint(a);
importCellArray->InsertCellPoint(b);
importCellArray->InsertCellPoint(c);
}//Generate Triangle List
for(i=0;i<count;i++)
{
float x,y,z;
importPoints->InsertPoint(importPoints->GetNumberOfPoints(),x,y,z);
}//Generate Points
finalPoly->SetPoints(importPoints);
finalPoly->SetPolys(importCellArray);
Qiang
Randall Hand <randall.hand at gmail.com> 写道:
I have a code block similar to this:
// First load the points
vtkPoints *newPts = vtkPoints::New();
newPts->Allocate(countVert);
for(i=1; i<=countVert; i++) {
newPts->InsertPoint(i-1, x, y, z);
}
// Now load up the connectivity
vtkIdList *pts = vtkIdList::New();
pts->Allocate(VTK_CELL_SIZE);
vtkCellArray *newPolys = vtkCellArray::New();
newPolys->Allocate(countPoly);
for(i=1; i<=countPoly; i++) {
pts->Reset();
pts->InsertNextId(v1-1);
pts->InsertNextId(v2-1);
pts->InsertNextId(v3-1);
newPolys->InsertNextCell(pts);
}
fclose(fptr);
vtkPolyData *output = vtkPolyData::New();
output->SetPoints(newPts);
newPts->Delete();
output->SetPolys(newPolys);
newPolys->Delete();
pts->Delete();
Now when I try to query the resulting vtkPolyData, I get segfaults in the ComputeBounds routines. I tried connecting it to a vtkPLYWriter, and it saves a file to disk that crashes both 3DSMax & Paraview. Any ideas what I'm missing here?
--
Randall Hand
http://www.yeraze.com _______________________________________________
This is the private VTK discussion list.
Please keep messages on-topic. Check the FAQ at: http://www.vtk.org/Wiki/VTK_FAQ
Follow this link to subscribe/unsubscribe:
http://www.vtk.org/mailman/listinfo/vtkusers
---------------------------------
Do You Yahoo!?
注册世界一流品质的雅虎免费电邮
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20050519/2804b387/attachment.htm>
More information about the vtkusers
mailing list