[vtkusers] some queries with vtkcellarrays
Chiranjib Sur
sur.chiranjib at gmail.com
Mon Jul 20 05:48:05 EDT 2015
Hi VTK experts,
I am not an expert vtk programmers like many others in the forum. I have a
confusion.
I am creating a set of vtk points (and eventually a vtkpolydata) and want
to create vtkcells for the associated points. I was looking at the examples
and trying to implement this way (
http://www.vtk.org/gitweb?p=VTK.git;a=blob;f=Examples/VisualizationAlgorithms/Cxx/TubesWithVaryingRadiusAndColors.cxx
)
What I am observing is that when I create vtkcells, I only create ONE cell.
What is going wrong here and why not all vtkcells are created?
Any suggestions ?
Thanks in advance,
Chiranjib
Here is my code snippet
// VTK points are defined here
vtkSmartPointer<vtkPoints> newPoints =
vtkSmartPointer<vtkPoints>::New();
// Set precision for the vtk points
newPoints->SetDataType( VTK_DOUBLE );
unsigned int count = 0;
double resolution = 0.1;
// Create the points for the entire volume
for (unsigned int j = 0; j<10; j++)
{
for (unsigned int i = 0; i<10; i++)
{
for (unsigned int k = 0; k<10; k++)
{
newPoints->InsertNextPoint( x0[0]+ resolution*i, x0[1]+
resolution*j, x0[2]+ resolution*k );
count++;
}
}
}
std::cout << "length of mycube = " << xl << ","<<yl<<","<<zl << std::endl;
std::cout << "Number of points = " << count << std::endl;
// Insert vtk cell arrays
vtkSmartPointer<vtkCellArray> cell =
vtkSmartPointer<vtkCellArray>::New();
cell->InsertNextCell( count);
for (vtkIdType i= 0; i < count; i++)
{
cell->InsertCellPoint(i);
}
// Define the polydata for the cube
vtkSmartPointer<vtkPolyData> np = vtkSmartPointer<vtkPolyData>::New();
np->SetPoints( newPoints );
np->SetLines( cell);
std::cout << "Number of cells "<< np->GetNumberOfCells() << ":" << count
<< std::endl;
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20150720/b5469d5c/attachment.html>
More information about the vtkusers
mailing list