Closed f-p-b closed 1 month ago
With cgal 5.6.x branch I have the following:
using https://gist.github.com/sloriot/f7ea17c69c722acc54bef824e1017b57
If I add .manifold()
I have:
terminate called after throwing an instance of 'CGAL::Assertion_exception'
what(): CGAL ERROR: assertion violation!
File: /home/sloriot/CGAL/git/integration/Mesh_3/include/CGAL/Mesh_3/Refine_facets_3.h
Line: 859
Explanation: (-0.3633066446675759 -0.5 -0.29269817778953555 0) is already inserted on surface.
Aborted
Although the spheres representing the constrained edges obscure most of the affected areas in the image, based on the few spots with issues visible (marked by the red arrows) it seems to reproduce the issue I am encountering. The two tetra sticking out at the top should not be there as they don't belong to the domain being meshed and at the bottom corner there is an element missing from the domain:
When running with .manifold() I have:
terminate called after throwing an instance of 'CGAL::Assertion_exception'
what(): CGAL ERROR: assertion violation!
File: /mnt/c/Workdir/Develop/TestBox/cgal_test/libs/CGAL-5.6/include/CGAL/Mesh_3/Refine_facets_3.h
Line: 1500
Explanation: Mesh_3 ERROR: A facet is not in conflict with its refinement point!
Debugging information:
Facet: (0x55f6743245a0, 3) = (0.5 0.24802094429145205 0.31521894221984847 0, 0.5 0.24802094735800306 0.31521895230952635 0, 0.5 0.24802094229966587 0.315218953368535 0)
Dual: Segment(0.50239510072181526 0.24802094379119005 0.31521894788273952 , 0.49527770566129697 0.2480344687443283 0.31526551456807811)
Refinement point: 0.5 0.2480254951227866 0.31523461820885157 0
Cells adjacent to facet:
( 0.5 0.248021 0.315219 0 , 0.5 0.248021 0.315219 0 , 0.5 0.248021 0.315219 0 , 0.500025 0.254315 0.355228 0.00164025 )
( 0.499965 0.287755 0.323072 0.00164025 , 0.5 0.248021 0.315219 0 , 0.5 0.248021 0.315219 0 , 0.5 0.248021 0.315219 0 )
Aborted
Am I making a mistake when defining my hybrid domain or polylines, or is it more an issue on CGAL's end?
Anonymous (@Another-Anonymous-User, really?! why that name?),
I have reproduced your issue and I propose a fix. I published my version as a branch in my fork: fix-issue-8212-hydrib-domain
.
You can see the four commits I have added, and the diff compared to your version: https://github.com/lrineau/cgal/compare/e088fc4dfbc...lrineau:cgal:fix-issue-8212-hydrib-domain
https://github.com/lrineau/cgal/compare/e088fc4dfbc is your version of the code.
That issue is not really a bug, as far as we know. That is the expected behavior of Mesh_3, given the data, the domain, and the mesh criteria. I will close this issue, but we can still discuss in it.
Thanks you for helping out!
Regarding your edit to line 102 (return 2 instead of 0). I was returning a zero because I don’t need the mesh of both domains and assumed for large problems keeping only the required domain will reduce the required resources noticeably since only the mesh for the domain of interest is kept in memory. Given you changed it, are there risks in removing the domain by returning a 0 instead of a 2?
Regarding the adjustments to the relative_error_bound
and facet_distance
. I have tested some other cases and adjusting them (especially the relative_error_bound
) has helped fix similar issues. I am still a bit puzzled by it though. At which stage does relative_error_bound come into play? Because sure, I get its the intersection between the implicit surface and query segments. However, how closely the surface of the mesh approximates the implicit surface is controlled by facet_distance
if I understand correctly. Does this means that it’s the query made to determine at which side of the surface an element lies? Or is it some other query at some other stage of the process?
why that name?
@lrineau, It started as a joke and then I was too lazy to change it if I am honest ^_^'. Will probably get to changing it one of these days…
Thanks you for helping out!
Regarding your edit to line 102 (return 2 instead of 0). I was returning a zero because I don’t need the mesh of both domains and assumed for large problems keeping only the required domain will reduce the required resources noticeably since only the mesh for the domain of interest is kept in memory. Given you changed it, are there risks in removing the domain by returning a 0 instead of a 2?
There is no risk, but the right value is not return 0
. I have pushed a new commit, see: https://github.com/lrineau/cgal/compare/e088fc4dfbc...lrineau:cgal:fix-issue-8212-hydrib-domain
With return 0
, the result is a non-null boost::optional<int>
containing the value 0
. And that is forbidden by the CGAL Mesh_3 documentation (the subdomain index cannot be null).
With return boost::none
, the result is a null boost::optional
, that is the way to tell the Mesh_3 engine that the query point is outside the mesh domain.
Regarding the adjustments to the
relative_error_bound
andfacet_distance
. I have tested some other cases and adjusting them (especially therelative_error_bound
) has helped fix similar issues. I am still a bit puzzled by it though. At which stage does relative_error_bound come into play? Because sure, I get its the intersection between the implicit surface and query segments. However, how closely the surface of the mesh approximates the implicit surface is controlled byfacet_distance
if I understand correctly. Does this means that it’s the query made to determine at which side of the surface an element lies? Or is it some other query at some other stage of the process?
The code you are working on has two distinct parts that are following the abstraction used in CGAL Mesh_3:
The parameter facet_distance
is in the mesh criteria, and only used by the mesh engine to decide if a given 3D triangle is "close enough" to the actual surface of the mesh domain.
The parameter relative_error_bound
is a parameter for the mesh domain class, and rules the bisection algorithm used to compute intersections between a query segment and a given implicit surface. If the relative_error_bound
is too big, the mesh domain implementation will compute points on the implicit surface, with not enough precision. That means that the surface the mesh engine is constructing will be noisy, or blurry. And then, with a small facet_distance
, the mesh engine has close to zero chance to converge to a state where the facet_distance
criterion is satisfied for all 3D triangles of the surface mesh.
why that name?
@lrineau, It started as a joke and then I was too lazy to change it if I am honest ^_^'. Will probably get to changing it one of these days…
By the way, what are you working on? Unless you really want to stay anonymous, maybe tell us more about you and the actual goal of the CGAL code you are working on. Statistically, you are probably a student, probably a PhD student, who needs that CGAL code for a research purpose.
Thanks for the additional explanations.
By the way, what are you working on?
This is what I am working on: https://github.com/tpms-lattice/ASLI/tree/develop
why that name?
@lrineau, It started as a joke and then I was too lazy to change it if I am honest ^_^'. Will probably get to changing it one of these days…
You are probably https://www.mech.kuleuven.be/en/bme/bme-people/00116401
I wonder if your lab has had collaboration with the CGAL project in the past. Maybe we can help you more about your code. Have you already tried CGAL 3d periodic meshes? Maybe you could discuss with @MaelRL and @MoniqueTeillaud who are still active contributors to the CGAL project.
There was actually a collaboration between CGAL (actually @MoniqueTeillaud and KU Leuven in 2008-2009:
Bingo, I see you were really curious.
The group I am in (Biomech Research Unit) has not had any collaborations with the CGAL project as far as I know.
I did look into using the 3D periodic meshes of CGAL a while back for cases were the structure is uniform but was having some issues with elements missing from the triangulation. I was in contact about it with MaelRL trough stackoverflow but even after he made some improvements it was not completely eliminated. So I did not really pursue it further at the time since the code main use mode (at least for us) is non-uniform structures. Still want to try it out again at some point now that CGAL has had some updates as it would make generating uniform infills much faster. But I have to make some time for that.
Issue Details
When creating a volume mesh using a hybrid domain, elements are regularly missing or assigned to the wrong side of the implicit surface as can be seen in the figure.
The source code provided bellow should reproduce the issue if given the following polylines to protect: polylines.txt and the input .off file.
Source Code
Environment