@@ -75,6 +75,10 @@ def is_line(self):
7575 def is_polygon (self ):
7676 return len (self .intersections ) >= 3
7777
78+ @property
79+ def is_mesh_closed (self ):
80+ return self .mesh .is_closed ()
81+
7882 @property
7983 def positive (self ):
8084 if self .is_none :
@@ -90,7 +94,8 @@ def positive(self):
9094 vdict = {key : self .mesh .vertex_coordinates (key ) for key in vertices + self .intersections }
9195 fdict = [self .mesh .face_vertices (fkey ) for fkey in faces ]
9296 mesh = self .meshtype .from_vertices_and_faces (vdict , fdict )
93- mesh .add_face (mesh .vertices_on_boundary ())
97+ if self .is_mesh_closed :
98+ mesh .add_face (mesh .vertices_on_boundary ())
9499 return mesh
95100
96101 def is_positive (self , key ):
@@ -119,7 +124,8 @@ def negative(self):
119124 vdict = {key : self .mesh .vertex_coordinates (key ) for key in vertices + self .intersections }
120125 fdict = [self .mesh .face_vertices (fkey ) for fkey in faces ]
121126 mesh = self .meshtype .from_vertices_and_faces (vdict , fdict )
122- mesh .add_face (mesh .vertices_on_boundary ())
127+ if self .is_mesh_closed :
128+ mesh .add_face (mesh .vertices_on_boundary ())
123129 return mesh
124130
125131 def is_negative (self , key ):
@@ -140,11 +146,16 @@ def intersect(self):
140146 x = intersection_segment_plane ((a , b ), self .plane )
141147 if not x :
142148 continue
143- L_ax = length_vector (subtract_vectors (x , a ))
144- L_ab = length_vector (subtract_vectors (b , a ))
145- t = L_ax / L_ab
146- key = self .mesh .split_edge (u , v , t = t , allow_boundary = True )
147- intersections .append (key )
149+ if len (x ) == sum ([1 for i , j in zip (x , a ) if i == j ]):
150+ intersections .append (u )
151+ elif len (x ) == sum ([1 for i , j in zip (x , b ) if i == j ]):
152+ intersections .append (v )
153+ else :
154+ L_ax = length_vector (subtract_vectors (x , a ))
155+ L_ab = length_vector (subtract_vectors (b , a ))
156+ t = L_ax / L_ab
157+ key = self .mesh .split_edge (u , v , t = t , allow_boundary = True )
158+ intersections .append (key )
148159 self ._intersections = intersections
149160
150161 def split (self ):
0 commit comments