Skip to content

Commit

Permalink
Fix test_triangle_refine()
Browse files Browse the repository at this point in the history
  • Loading branch information
inducer committed Oct 8, 2013
1 parent 4177ed2 commit 6415373
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions test/test_meshpy.py
Expand Up @@ -33,9 +33,10 @@ def test_triangle_refine():

segments = 50

points = [ (1,0),(1,1),(-1,1),(-1,-1),(1,-1),(1,0) ]
points = [ (1,0),(1,1),(-1,1),(-1,-1),(1,-1) ]
n_outer_points = len(points)

for i in range( 0, segments + 1 ):
for i in range( 0, segments):
angle = i * 2 * math.pi / segments
points.append( ( 0.5 * math.cos( angle ), 0.5 * math.sin( angle ) ) )

Expand All @@ -52,13 +53,16 @@ def needs_refinement(vertices, area ):
bary_y = (vert_origin.y + vert_destination.y + vert_apex.y) / 3

dist_center = math.sqrt( bary_x**2 + bary_y**2 )
max_area = 100*(math.fabs( 0.002 * (dist_center-0.5) ) + 0.0001)
max_area = 100*(math.fabs( 0.002 * (dist_center-0.3) ) + 0.0001)
return area > max_area

info = triangle.MeshInfo()
info.set_points(points)
info.set_holes([(0,0)])
info.set_facets(round_trip_connect(0, len(points)-1))
info.set_facets(
round_trip_connect(0, n_outer_points-1)
+
round_trip_connect(n_outer_points, len(points)-1))

mesh = triangle.build(info, refinement_func=needs_refinement)

Expand Down

0 comments on commit 6415373

Please sign in to comment.