[vtkusers] PoinInPolygon arguments

Eric E. Monson emonson at cs.duke.edu
Mon Apr 12 07:31:08 EDT 2010


Hey Jothy,

It is common in C++ to prepare space for an array of values, and then hand that array or variable to another method where it places the answer in that array. 

So, instead of doing something like 

n = ComputeNormal(...)

He's just doing 

ComputeNormal(...,n);

and the normal is getting placed into the three-value array "n" by the routine. Think of it as passing a bucket to the algorithm where it will place the answer.

-Eric

------------------------------------------------------
Eric E Monson
Duke Visualization Technology Group


On Apr 12, 2010, at 5:56 AM, Jothybasu K Selvaraj wrote:

> Hi David,
> 
> I need a bit of clarification as I am not much familiar with c++.
> 
> 
> double n[3]; // you have declared the variable n
> 
>  polygon->ComputeNormal(
> polygon->GetPoints()->GetNumberOfPoints(),
> static_cast<double*>(polygon->GetPoints()->GetData()->GetVoidPointer(0)),
> n);// How do you set this as an input to an argument as it doesn't hold any value
> 
> Did you mistyped or am I misinterpreted?
> 
> Thanks,
> 
> Jothy
> 
> 
> 
> 
> On Thu, Apr 8, 2010 at 12:43 AM, David Doria <daviddoria+vtk at gmail.com> wrote:
> On Tue, Apr 6, 2010 at 11:33 AM, Bill Lorensen <bill.lorensen at gmail.com> wrote:
> > n is the normal to the face of the polygon
> > numPts is the number of points in the polygon
> > pts is an array of xyz points
> 
> 
> The call was pretty nasty:
> 
> 
>  double n[3];
>  polygon->ComputeNormal(polygon->GetPoints()->GetNumberOfPoints(),
> static_cast<double*>(polygon->GetPoints()->GetData()->GetVoidPointer(0)),
> n);
> 
>  double bounds[6];
>  polygon->GetPoints()->GetBounds(bounds);
> 
>  cout << "test x in polygon? " << polygon->PointInPolygon(x,
> polygon->GetPoints()->GetNumberOfPoints(),
> static_cast<double*>(polygon->GetPoints()->GetData()->GetVoidPointer(0)),
> bounds, n) << endl;
> 
> I just wrote a convenience function and submitted it to the developers
> mailing list. If it is approved, in the future you can simply call
> 
> cout << "test x in polygon? " << polygon->PointInPolygon(x) << endl;
> 
> Thanks,
> 
> David
> 
> _______________________________________________
> 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/20100412/68b35662/attachment.htm>


More information about the vtkusers mailing list