[vtk-developers] Best fit plane function location

David Doria daviddoria+vtk at gmail.com
Mon Jan 25 08:13:36 EST 2010


On Mon, Jan 25, 2010 at 7:01 AM, Will Schroeder
<will.schroeder at kitware.com> wrote:
>
> David-
>
> I really do not want to start collecting geometric operations in a new geometric utilities class. Currently (for better or for worse) the VTK geometric operations are associated with the various cells with which they are consistent. This utility would be yet another place to look for stuff and is not consistent with what's in VTK now.
>
> The vtkPlane problem was that one of the best fit plane arguments was a vtkDataSet* which resulted in linkage problems. Another way to accomplish something similar is to not use vtkDataSet*, instead use vtkPoints*; note that vtkPlane is already in VTK/Common. More often than not you are going to fit a plane to a set of points explicitly represented by vtkPoints (subclasses of vtkPointSet). I'd expect only in rare circumstances are you going to traverse points using vtkDataSet::GetPoint(ptId) since this would correspond to implicit datasets such as images. If necessary you could always populate a vtkPoints from an implicit dataset (use random sampling or even the whole population, better yet I would argue that implicit datasets typically have closed-form solutions to the best fit plane).
>
> Will
>

I agree. I originally operated on vtkPoints. However, I was asked to
remove the reduncancy of plane fitting in vtkTextureMapToPlane.

void vtkTextureMapToPlane::ComputeNormal(vtkDataSet *input)

I copied the points out of the vtkDataSet into a vtkPoints to pass to
my function, but everyone thought that was unnecessary, that I should
just make the BestFit function accept a vtkDataSet.

Is it ok to go ahead and do something like this:

void vtkTextureMapToPlane::ComputeNormal(vtkDataSet *input)
{
 vtkSmartPointer<vtkPoints> points = vtkSmartPointer<vtkPoints>::New();
 for(unsigned int i = 0; i < input->GetNumberOfPoints(); i++)
   {
   double p[3];
   input->GetPoint(i, p);
   points->InsertNextPoint(p);
   }

... BestFit(points)...

like I had originally?

Thanks,

David



More information about the vtk-developers mailing list