[vtkusers] Information of vtkActor, points and coordinates
David Doria
daviddoria at gmail.com
Wed Feb 23 08:17:36 EST 2011
On Wed, Feb 23, 2011 at 8:10 AM, ederhazael <ederhazael at hotmail.com> wrote:
>
> I have a problem, I am trying to get the "number of points" and the "number
> of cells" with this code:
>
> int points=Actor->GetMapper()->GetInput()->GetNumberOfPoints();
> int cells=Actor->GetMapper()->GetInput()->GetNumberOfCells();
>
> but in both cases, I get a 0. I think that I need "Build Cells" and "Build
> Links" as in the mesh, but the code is diferent because I use this code in
> the mesh;
>
> "Mesh"->GetOutput()->BuildCells();
>
> But in the vtkActor it not work, because it not have the opcion.
>
> What do you think?
>
> Thanks
The following outputs
4
4
for me.
#include <vtkPolyData.h>
#include <vtkPoints.h>
#include <vtkSmartPointer.h>
#include <vtkActor.h>
#include <vtkPolyDataMapper.h>
int main(int argc, char *argv[])
{
vtkSmartPointer<vtkPoints> points =
vtkSmartPointer<vtkPoints>::New();
points->InsertNextPoint(0,0,0);
points->InsertNextPoint(0,1,0);
points->InsertNextPoint(1,0,0);
points->InsertNextPoint(1.5,1,0);
vtkSmartPointer<vtkPolyData> polydata =
vtkSmartPointer<vtkPolyData>::New();
polydata->SetPoints(points);
std::cout << polydata->GetNumberOfPoints() << std::endl;
vtkSmartPointer<vtkPolyDataMapper> mapper =
vtkSmartPointer<vtkPolyDataMapper>::New();
mapper->SetInput(polydata);
vtkSmartPointer<vtkActor> actor =
vtkSmartPointer<vtkActor>::New();
actor->SetMapper(mapper);
std::cout << actor->GetMapper()->GetInput()->GetNumberOfPoints() << std::endl;
return EXIT_SUCCESS;
}
David
More information about the vtkusers
mailing list