[vtkusers] vtkPoints Adding too many points?

Bill Chivas billno123 at hotmail.com
Tue Nov 16 04:58:58 EST 2010


The "GetNumberOfPoints()" method returns the "last_id + 1". It doesn't return the actual number of points. 
It does that because it supposes the points ids indexing is started from 0 (zero). 
The only one that returns the actual number of points is the "points1" whose ids indexing is started from zero.

Major problem for deleting a point (or cell)....you have to re-build grid...look at my problem...

> Date: Mon, 15 Nov 2010 22:11:25 -0800
> From: ambarc at gmail.com
> To: vtkusers at vtk.org
> Subject: [vtkusers] vtkPoints Adding too many points?
> 
> I'm have a set of vtkPoint references, and each reference seems to be
> getting the points added to it's predecessor as well as the ones added
> to itself. Here's the basic code:
> 
> 	vtkPolyData *poly1 = vtkPolyData::New();
> 	vtkPolyData *poly2 = vtkPolyData::New();
> 	vtkPolyData *poly3 = vtkPolyData::New();
> 	vtkPolyData *poly4 = vtkPolyData::New();
> 
> 	vtkPoints *points1 = vtkPoints::New();
> 	vtkPoints *points2 = vtkPoints::New();
> 	vtkPoints *points3 = vtkPoints::New();
> 	vtkPoints *points4 = vtkPoints::New();
> 
> 	//Inserting points.
> 	
> 	points1->InsertPoint(0, 1, 4, 5);
> 	points1->InsertPoint(1, -1, 3, 2);
> 	points1->InsertPoint(2, -4, -4, -4);
> 
> 	points2->InsertPoint(3, 2, 8, 9);
> 	points2->InsertPoint(4, -2, 2, 3);
> 	points2->InsertPoint(5, 4,  5,  5);
> 
> 	points3->InsertPoint(6, -1, 4, -5);
> 	points3->InsertPoint(7, -4, -2, -2);
> 	points3->InsertPoint(8, -2, -9, 9);
> 
> 	points4->InsertPoint(9, 1, 6, 5);
> 	points4->InsertPoint(10, -1, 3, 2);
> 	points4->InsertPoint(11, -4, -4, -4);
> 	cout<<points4->GetNumberOfPoints()<<"
> "<<points3->GetNumberOfPoints()<<" "<<points2->GetNumberOfPoints()<<"
> "<<points1->GetNumberOfPoints()<<" "<<endl;
> 	//Setting the points as the data.
> 
> 	poly1->SetPoints(points1);
> 	poly2->SetPoints(points2);
> 	poly3->SetPoints(points3);
> 	poly4->SetPoints(points4);
> 
> 	cout<<poly4->GetNumberOfPoints()<<" "<<poly3->GetNumberOfPoints()<<"
> "<<poly2->GetNumberOfPoints()<<" "<<poly1->GetNumberOfPoints()<<"
> "<<endl;
> 
> The output I get is
> 12 9 6 3
> 12 9 6 3
> 
> Instead of the expected
> 3 3 3 3
> 3 3 3 3
> _______________________________________________
> Powered by www.kitware.com
> 
> Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
> 
> Please keep messages on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ
> 
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
 		 	   		  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20101116/7cbbe6f5/attachment.htm>


More information about the vtkusers mailing list