meshing of a circle does not work correctly except for unit circles

Issue #72 resolved
Jim Jiao created an issue

It seems that there is a major bug in the CSG. The following code

from mshr import *
mesh = generate_mesh(Circle(Point(0, 0), 0.05), 10)

generates a triangle instead of circle.

mesh = generate_mesh(Circle(Point(0, 0), 0.1), 10)

generates a hexgon instead of circle.

It seems that something was hard coded so that the Circle representation only works for unit circles.

Comments (3)

  1. Jim Jiao reporter

    I found that the bug is in include/mshr/CSGCGALDomain2D.h

    44  CSGCGALDomain2D(
    45      std::shared_ptr<const CSGGeometry> geometry,
    46      double segment_granularity=0.1
    47      );
    

    The default segment_granularity is set to 0.1, without considering the radius of the circle. It affects the computation of num_segments in make_circle and make_ellipse in src/CSGCGALDomain2D.h

  2. Benjamin Dam Kehlet

    Thanks for reporting. You are almost right.

    The algorithm currently does two passes, first with segment_granularity set to 0.1, to attempt to estimate the size of the geometry. Then it reruns it with segment_granularitycomputed based on the first run. This is a quick hack and it doesn't work at all in your case. I'll fix it properly.

  3. Log in to comment