surface mesh creation and intersection in python

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

surface mesh creation and intersection in python

gregthom992
Hi,

I have been looking around for a simple CGAL python example but I have not
had any luck
I basically want to create two surface meshes from python numpy arrays of
points (3d) and triangles . I want to check if they intersect with CGAL. I
also want to find the closest point on the two surface meshes.
Any ideas with pseudocode will be helpful

Thanks



--
Sent from: http://cgal-discuss.949826.n4.nabble.com/

--
You are currently subscribed to cgal-discuss.
To unsubscribe or access the archives, go to
https://sympa.inria.fr/sympa/info/cgal-discuss


Reply | Threaded
Open this post in threaded view
|

Re: surface mesh creation and intersection in python

rahulverma88
I've actually been trying to use a Python interface to CGAL for a while now,
and I have not been able to do much with the CGAL Python bindings
(https://github.com/CGAL/cgal-swig-bindings) - the actual CGAL library is
far more feature-rich. I have found it much more useful to write out your
intersection functions in C++, and then pass it your points/lines as arrays
from Python using SWIG.

So your C++ function prototype looks like:

<return_type> cpp_function_for_mesh_intersection(double *xs, double *ys,
double *zs, int num_points);

Using SWIG, this can be compiled to a Python module,
and then your Python call will look like:

mesh_intersection_module.cpp_function_for_mesh_intersection(xs, ys, zs,
num_points)

It is not trivial to do all this, but it shouldn't be that hard either. I
don't think this is the best solution, but it worked for the specific thing
I was trying to do.



--
Sent from: http://cgal-discuss.949826.n4.nabble.com/

--
You are currently subscribed to cgal-discuss.
To unsubscribe or access the archives, go to
https://sympa.inria.fr/sympa/info/cgal-discuss


Reply | Threaded
Open this post in threaded view
|

Re: surface mesh creation and intersection in python

gregthom992
Hi Rahulverm88

Thanks for you idea. That crossed my mind earlier but I put it off as I
thought this sort of thing is already done. What I gather from reading the
posts is that booleans in CGAL is kind of a problem and slow ? One post was
talking of the order of 10s for union of two meshes ?
I am not sure I want to use CGAL then, unless someone has some other
information ? I am just looking to check if they intersect of not intersect
and then get some sort of distance between the two meshes.

Thanks

GT



--
Sent from: http://cgal-discuss.949826.n4.nabble.com/

--
You are currently subscribed to cgal-discuss.
To unsubscribe or access the archives, go to
https://sympa.inria.fr/sympa/info/cgal-discuss


Reply | Threaded
Open this post in threaded view
|

Re: surface mesh creation and intersection in python

rahulverma88
I searched quite a lot for it, but I couldn't find any implementations for
it.

If CGAL is indeed slow for booleans, there are probably some optimizations
you could do - like check the AABB trees of your meshes for intersections.
The CGAL Python bindings project does have a function for that.



--
Sent from: http://cgal-discuss.949826.n4.nabble.com/

--
You are currently subscribed to cgal-discuss.
To unsubscribe or access the archives, go to
https://sympa.inria.fr/sympa/info/cgal-discuss


Reply | Threaded
Open this post in threaded view
|

Re: surface mesh creation and intersection in python

Sebastien Loriot (GeometryFactory)
In reply to this post by gregthom992
On 9/20/19 3:15 PM, gregthom992 wrote:
> Hi Rahulverm88
>
> Thanks for you idea. That crossed my mind earlier but I put it off as I
> thought this sort of thing is already done. What I gather from reading the
> posts is that booleans in CGAL is kind of a problem and slow ? One post was
> talking of the order of 10s for union of two meshes ?

I don't know what post you read but it was probably about the Nef_3
package. If you use corefinement from Polygon Mesh Processing package
the runtime is pretty decent AFAIK:
https://doc.cgal.org/latest/Polygon_mesh_processing/index.html#Coref_section

Note that the runtime will always depends on the number of input
simplices + the size of the intersection. So 10s might be what you will
have for a single Boolean if the input are large and you have many
intersections.
For example computing the union of 2 meshes with 350,000 vertices each
takes 3.8s if they intersect heavily and 2.18s if the intersection
region is small.

About python bindings, some functions from PMP has already been wrapped
but obviously not all of them.

Extending the file CGAL_Polygon_mesh_processing.i is quite straight
forward. If you are missing a function, PRs are welcome.

Look at test_pmp.py for how to load a mesh from an array of points
and polygons.

Sebastien.

> I am not sure I want to use CGAL then, unless someone has some other
> information ? I am just looking to check if they intersect of not intersect
> and then get some sort of distance between the two meshes.
>
> Thanks
>
> GT
>
>
>
> --
> Sent from: http://cgal-discuss.949826.n4.nabble.com/
>

--
You are currently subscribed to cgal-discuss.
To unsubscribe or access the archives, go to
https://sympa.inria.fr/sympa/info/cgal-discuss