make_mesh_3 missing disjoint components from polyhedral surface.

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

make_mesh_3 missing disjoint components from polyhedral surface.

rdzhao
Hi everyone,

I working working on generating tetrahedral mesh from input polyhedral
surface mesh. The model is a benzene with 6 C atoms and 6 H atoms. Those
atoms are disconnected balls in the input polyhedral surface mesh
(benzene.off).

However, by directly calling make_mesh_3, there will be missing components
in the final generated tet mesh.
So I resort to another post:
http://cgal-discuss.949826.n4.nabble.com/make-mesh-3-with-features-initial-points-for-C3T3-td4661118.html
This post tells that we need to set initial points as features to guide the
meshing process. So I modified the code with:

C3t3 c3t3 = CGAL::make_mesh_3<C3t3>(domain, criteria, features(domain),
no_lloyd(), no_odt(), no_perturb(), no_exude());
       
typedef C3t3::Triangulation::Point Weighted_point;
   for(int i=0; i<atoms.size(); i+=3){
        Weighted_point p(Weighted_point::Point(atoms[i], atoms[i+1],
atoms[i+2]));
    Tr::Vertex_handle vh = c3t3.triangulation().insert(p);
    c3t3.set_dimension(vh, 3);
}
CGAL::refine_mesh_3(c3t3, domain, criteria);

The idea is adding atom positions as initial points. But the code still
misses one component (a certain H atom).

A minimal code is attached here with model file (benzene.off) and atoms file
(benzene.xyz). It should be easy to directly compile and execute.

Suppose that the executable file is called &quot;Meshing&quot;. The command
to run the code is:
./Mesh benzene.xyz benzene.off 0.2

.xyz file provides the atom locations.
.off file provides the model containing 12 balls (6 C atoms and 6 H atoms).
0.2 is a parameter to roughly control the element size.

The output contains a .off file for the surface of the tet meshing, where we
can find that there is missing components compared with the input .off file.

Is there anyone that can help dig out the problem?
Thank you so much!
Rundong

&lt;nabble_a href=&quot;Archive.zip&quot;>Archive.zip



--
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: make_mesh_3 missing disjoint components from polyhedral surface.

rdzhao
The source files with only a main.cpp and 2 data files:

Archive.zip
<http://cgal-discuss.949826.n4.nabble.com/file/t376150/Archive.zip>  



--
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: make_mesh_3 missing disjoint components from polyhedral surface.

rdzhao
Is there anyone that could help?

I got stuck on this and my project didn't work through.
I'm eager to get some instructions. :)



--
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: make_mesh_3 missing disjoint components from polyhedral surface.

MaelRL
Hello,

Using the 'master' branch of CGAL, I cannot reproduce your issue: I get
all 12 connected components.

Which version of CGAL are you using?

Best,
Mael

On 01/10/2019 15:25, rdzhao wrote:

> Is there anyone that could help?
>
> I got stuck on this and my project didn't work through.
> I'm eager to get some instructions. :)
>
>
>
> --
> 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: make_mesh_3 missing disjoint components from polyhedral surface.

andreas.fabri

You might also have a look at this gist:

https://gist.github.com/afabri/1bbf46c6fd4f742bd982

The idea would be to seed with some vertices of your input  per connected component.

Best,

Andreas

On 10/1/2019 3:53 PM, Mael wrote:
Hello,

Using the 'master' branch of CGAL, I cannot reproduce your issue: I get all 12 connected components.

Which version of CGAL are you using?

Best,
Mael

On 01/10/2019 15:25, rdzhao wrote:
Is there anyone that could help?

I got stuck on this and my project didn't work through.
I'm eager to get some instructions. :)



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


-- 
Andreas Fabri, PhD
Chief Officer, GeometryFactory
Editor, The CGAL Project

phone: +33.492.954.912    skype: andreas.fabri
Reply | Threaded
Open this post in threaded view
|

Re: make_mesh_3 missing disjoint components from polyhedral surface.

rdzhao
In reply to this post by MaelRL
I'm using CGAL 4.14.1. It should be the (almost) latest version. And my
architecture is Mac OS.

You mean that you didn't change anything of my code. And it successfully
generated all 12 components?
That's really strange. I'll look into it again.



--
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: make_mesh_3 missing disjoint components from polyhedral surface.

rdzhao
In reply to this post by andreas.fabri
Cool!

I think I'm gonna have a try of this method.

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: make_mesh_3 missing disjoint components from polyhedral surface.

rdzhao
In reply to this post by andreas.fabri
I've played with your code. It successfully captures all the components.
That's great!

Your offered treatment incorporates a subset of surface vertices as seeds.
But when I changes the seeds at a set of points inside the surface, the
program crashes with segmentation fault.

What should I do to insert only interior points as seeds?

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: make_mesh_3 missing disjoint components from polyhedral surface.

rdzhao
In reply to this post by andreas.fabri
I found something more.

By making a subset of boundary vertices as seeds, somehow, the boundary
surface of the final tet mesh is limited. The triangle quality of the
boundary surface is consistent with the input surface mesh, in the sense
that if the input surface mesh has triangles with bad quality (too small,
too thin triangles), the tet mesh will be that as well.

Is there anything I can do to decoupling this relation? I need the tet mesh
to be relatively uniform in shape and size.

Thanks!!!! Thanks you so much for the help!



--
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: make_mesh_3 missing disjoint components from polyhedral surface.

Laurent Rineau (CGAL/GeometryFactory)
In reply to this post by rdzhao
On Tuesday, October 1, 2019 9:15:48 PM CEST rdzhao wrote:
> I've played with your code. It successfully captures all the components.
> That's great!
>
> Your offered treatment incorporates a subset of surface vertices as seeds.
> But when I changes the seeds at a set of points inside the surface, the
> program crashes with segmentation fault.
>
> What should I do to insert only interior points as seeds?

What you call the seeds are documented in functor Construct_initial_points of the MeshDomain_3 concept:

> A function object to construct a set of initial points on the surface of the domain.

https://doc.cgal.org/4.14.1/Mesh_3/classMeshDomain__3.html#abcf45d5a98576cad24711008e940b98f


They have to be on the surface of the domain.

If you want to insert initial points in the interior of the domain, then you will have to do the initialization of the c3t3 object by handle, using a loop, and then:

    C3t3 c3t3;
    C3t3::Triangulation& tr = c3t3.triangulation();
   
    for(auto pi: seeds) {
        Vertex_handle v = tr.insert(pi);
        // `v` could be null if `pi` is hidden by other vertices of `tr`.
        CGAL_assertion(v != Vertex_handle());
        c3t3.set_dimension(v, 2); // by construction, points are on surface
        c3t3.set_index(v, index);
    }

See an example if the the documentation:
https://doc.cgal.org/4.14.1/Mesh_3/index.html#title26

But be particularly careful with the line

    c3t3.set_dimension(v, 2);

For points that are inside the interior of the domain, the 2 has to be a 3:

    c3t3.set_dimension(v, 3);

Your custom initialization could be made of two loops:

    C3t3 c3t3;
    C3t3::Triangulation& tr = c3t3.triangulation();
   
    for(auto pi: seeds_on_surface) {
        Vertex_handle v = tr.insert(pi);
        // `v` could be null if `pi` is hidden by other vertices of `tr`.
        CGAL_assertion(v != Vertex_handle());
        c3t3.set_dimension(v, 2);
        c3t3.set_index(v, index);
    }
    for(auto pi: seeds_in_the_interior) {
        Vertex_handle v = tr.insert(pi);
        // `v` could be null if `pi` is hidden by other vertices of `tr`.
        CGAL_assertion(v != Vertex_handle());
        c3t3.set_dimension(v, 3);
        c3t3.set_index(v, index);
    }


--
Laurent Rineau, PhD
R&D Engineer at GeometryFactory           http://www.geometryfactory.com/
Release Manager of the CGAL Project       http://www.cgal.org/




--
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: make_mesh_3 missing disjoint components from polyhedral surface.

rdzhao
Thank you for the help! Laurent!

I've overcome this obstacle now!



--
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: make_mesh_3 missing disjoint components from polyhedral surface.

rdzhao
In reply to this post by andreas.fabri
Thank you, Andreas.Fabri, for the help!

I've solve this problem!



--
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