[vtk-developers] Convenience functions for vtkPolygon

David Doria daviddoria+vtk at gmail.com
Wed Apr 7 19:46:53 EDT 2010


I have added an objected oriented convenience function,
void vtkPolygon::ComputeNormal(double normal[3]);

which simply calls an existing static function in vtkPolygon with the
data from an instantiated polygon (you may remember a similar case
with ComputeArea several months ago).

The result is instead of this:
double n[3];
 polygon->ComputeNormal(polygon->GetPoints()->GetNumberOfPoints(),
static_cast<double*>(polygon->GetPoints()->GetData()->GetVoidPointer(0)),
n);

we can use

double n[3];
polygon->ComputeNormal(n);

I also added an object oriented convenience function for
PointInPolygon, which allows replacing a call like this:

polygon->PointInPolygon(x, polygon->GetPoints()->GetNumberOfPoints(),
static_cast<double*>(polygon->GetPoints()->GetData()->GetVoidPointer(0)),
bounds, n);

to this:

polygon->PointInPolygon(x);

The new files are available here:
http://www.rpi.edu/~doriad/VTK_List/vtkPolygon/

Please let me know if these changes can be committed.

Thanks,

David



More information about the vtk-developers mailing list