[vtkusers] vtkSelectEnclosedPoints without an input

Valdo Meyer stan1313 at hotmail.fr
Sat Jun 9 04:01:23 EDT 2012


I wonder about the fiability of this class to determine whether a point lies inside a closed surface.
The implemented is based on ray casting, with a curious system of votes (vote=1 if a ray intersects the surface, 0 otherwise) which seems to mean that the ray-surface intersection test is not reliable.
So my question is: in which respect is the test reliable?

Date: Fri, 8 Jun 2012 09:42:42 -0700
From: jochen.kling at email.de
To: vtkusers at vtk.org
Subject: Re: [vtkusers] vtkSelectEnclosedPoints without an input

Hello Federico,


after some research and trial and error I found a solution for that. Here is a complete example (without rendering anything):


/*
This is a backdoor that can be used to test many points for containment. 
First initialize the instance, then repeated calls to IsInsideSurface() 
can be used without rebuilding the search structures. 
The complete method releases memory. 

In other words, you do have to feed the vtkSelectEnclosedPoints object
neither with polydata as the input nor with a surface.
*/
#include <vtkSphereSource.h>
#include <vtkSmartPointer.h>
#include <vtkPolyData.h>
#include <vtkSelectEnclosedPoints.h>

int main()
{
    vtkSmartPointer<vtkSphereSource> sphereSource = 
        vtkSmartPointer<vtkSphereSource>::New();
    sphereSource->SetCenter(0.0, 0.0, 0.0);
    sphereSource->SetRadius(1.0);
    sphereSource->Update();

    vtkPolyData* sphere = sphereSource->GetOutput();

    double testInside[3] = {0.0, 0.0, 0.0};
    double testOutside[3] = {10.0, 0.0, 0.0};
    vtkSmartPointer<vtkSelectEnclosedPoints> selectEnclosedPoints = 
        vtkSmartPointer<vtkSelectEnclosedPoints>::New();

    selectEnclosedPoints->Initialize(sphere);
    std::cout << selectEnclosedPoints->IsInsideSurface(testInside) << std::endl;
    std::cout << selectEnclosedPoints->IsInsideSurface(testOutside) << std::endl;
    return EXIT_SUCCESS;
}




with kind regards

Jochen
	


View this message in context: Re: vtkSelectEnclosedPoints without an input

Sent from the VTK - Users mailing list archive at Nabble.com.

_______________________________________________
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/20120609/924c601c/attachment.htm>


More information about the vtkusers mailing list