Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

surface remesh does not work properly #167

Open
JianqiangDing opened this issue Oct 25, 2021 · 9 comments
Open

surface remesh does not work properly #167

JianqiangDing opened this issue Oct 25, 2021 · 9 comments

Comments

@JianqiangDing
Copy link

Hi, Nico Schlömer,

Am I doing something wrong? I just clone the latest pygalmesh, but I do not pass all the unit tests, here is a screenshot of the output

image

I just clone the repo, check into the main directory then run "pytest". Could you please help me to figure out what's wrong with the surface_remesh API? (I just got a SIGSEGV here, if necessary, I can show you an MWE, but you can just check if all the tests work properly or not

any kind of suggestion would be helpful :)

@nschloe
Copy link
Collaborator

nschloe commented Oct 25, 2021

An MWE is always useful. SIGSEGVs are suspicious though, pointing towards something in CGAL itself.

@JianqiangDing
Copy link
Author

I am sorry, So you can pass all the tests by default??(by just clone repo, cd dir, run pytest

@nschloe
Copy link
Collaborator

nschloe commented Oct 25, 2021

Yeah, tests run on my system and on github-actions. CGAL behaves slightly differently from machine to machine, so perhaps you'd just have to adapt the tolerances slightly.

@JianqiangDing
Copy link
Author

big thanks for your quick response, totally agree with you, It might be some problems that happened to CGAL, cause the first two tests passed which are only call meshio APIs(if I understand the code right), while the following tests call CGAL APIs.I'll check CGAL first.

thank you again for your kind advice (really useful library)

@nschloe
Copy link
Collaborator

nschloe commented Oct 25, 2021

Closing since this is probably not a CGAL bug, but feel free to continue posting here.

@nschloe nschloe closed this as completed Oct 25, 2021
@JianqiangDing
Copy link
Author

JianqiangDing commented Oct 29, 2021

Hi, Nico Schlömer,

Firstly, I just figure out the problem I faced several days ago because you upload two test mesh cases as large files using git-lfs (which is not necessary right now I think, cause they are small files, probably you can fix this or point out in doc that the repo using git-lfs maintaining mesh data)

Secondly, here is an MWE that crashed with SIGSEGV

import meshio
import pygalmesh
import numpy as np


def init_mesh():
    points = np.array(
        [
            [0.0, 0.0, 1.0],
            [0.0, 1.0, 0.0],
            [-1.0, 0.0, 0.0],
            [1.0, 0.0, 0.0],
            [0.0, -1.0, 0.0],
        ],
        dtype=float,
    )
    triangles = np.array(
        [[0, 1, 2], [0, 1, 3], [4, 0, 2], [4, 0, 3], [4, 1, 3], [4, 1, 2]], dtype=int
    )
    cells = [("triangle", triangles)]
    return meshio.Mesh(points, cells)


if __name__ == "__main__":
    temp_mesh_name = "temp_file_mesh_name"
    suffix = ".obj"
    temp_mesh_file = temp_mesh_name + suffix
    mesh = init_mesh()
    mesh.write(temp_mesh_file)
    remesh = pygalmesh.remesh_surface(
        temp_mesh_file,
        max_edge_size_at_feature_edges=0.025,
        min_facet_angle=25,
        max_radius_surface_delaunay_ball=0.1,
        max_facet_distance=0.001,
        verbose=True,
    )

And a screenshot

image

Is this an issue about parameters setting? (I am not familiar with this remeshing method, any suggestion from you would be helpful, thanks

@nschloe nschloe reopened this Oct 29, 2021
@nschloe
Copy link
Collaborator

nschloe commented Oct 29, 2021

Alright, I also see the segfault on my machine. The full error:

CGAL::Polyhedron_incremental_builder_3<HDS>::
lookup_halfedge(): input error: facet 1 shares a halfedge from vertex 0 to vertex 1 with facet 0.
 
Polyhedron_scan_OFF<Traits>::
operator()(): input error: facet 2 has fewer than 3 vertices.
Inserting protection balls...
  refine_balls = true
  min_balls_radius = 0
  min_balls_weight = 0
insert_corners() done. Nb of points in triangulation: 0
insert_balls_on_edges() done. Nb of points in triangulation: 0
refine_balls() done. Nb of points in triangulation: 0

[1]    702209 segmentation fault (core dumped)  python3 bb.py

That smells like a CGAL bug, perhaps @lrineau has an idea here?

@JianqiangDing
Copy link
Author

JianqiangDing commented Oct 30, 2021

How about subdividing triangles to ensure having enough triangles, then using optimesh to upgrade the whole quality? (as another way to do remeshing)Does this idea make sense? (seems optimesh just care about the angles but the max_allowed_edge_length :))

I am afraid this procedure may break original sharp edges, am I right?

@nschloe
Copy link
Collaborator

nschloe commented Oct 30, 2021

Your initial mesh is so rough that it will be hard for any algorithm to achieve something meaningful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants