44from compas .geometry import dot_vectors
55
66
7- __all__ = [' mesh_slice_plane' ]
7+ __all__ = [" mesh_slice_plane" ]
88
99
1010def mesh_slice_plane (mesh , plane ):
@@ -45,7 +45,6 @@ def mesh_slice_plane(mesh, plane):
4545
4646
4747class IntersectionMeshPlane (object ):
48-
4948 def __init__ (self , mesh , plane ):
5049 self .mesh = mesh
5150 self .plane = plane
@@ -92,7 +91,10 @@ def positive(self):
9291 for key in vertices :
9392 faces += self .mesh .vertex_faces (key )
9493 faces = list (set (faces ))
95- vdict = {key : self .mesh .vertex_coordinates (key ) for key in vertices + self .intersections }
94+ vdict = {
95+ key : self .mesh .vertex_coordinates (key )
96+ for key in vertices + self .intersections
97+ }
9698 fdict = [self .mesh .face_vertices (fkey ) for fkey in faces ]
9799 mesh = self .meshtype .from_vertices_and_faces (vdict , fdict )
98100 if self .is_mesh_closed :
@@ -103,7 +105,7 @@ def is_positive(self, key):
103105 o = self .plane .point
104106 n = self .plane .normal
105107 if key not in self .intersections :
106- a = self .mesh .vertex_attributes (key , ' xyz' )
108+ a = self .mesh .vertex_attributes (key , " xyz" )
107109 oa = subtract_vectors (a , o )
108110 similarity = dot_vectors (n , oa )
109111 if similarity > 0.0 :
@@ -122,7 +124,10 @@ def negative(self):
122124 for key in vertices :
123125 faces += self .mesh .vertex_faces (key )
124126 faces = list (set (faces ))
125- vdict = {key : self .mesh .vertex_coordinates (key ) for key in vertices + self .intersections }
127+ vdict = {
128+ key : self .mesh .vertex_coordinates (key )
129+ for key in vertices + self .intersections
130+ }
126131 fdict = [self .mesh .face_vertices (fkey ) for fkey in faces ]
127132 mesh = self .meshtype .from_vertices_and_faces (vdict , fdict )
128133 if self .is_mesh_closed :
@@ -134,7 +139,7 @@ def is_negative(self, key):
134139 n = self .plane .normal
135140 if key in self .intersections :
136141 return False
137- a = self .mesh .vertex_attributes (key , ' xyz' )
142+ a = self .mesh .vertex_attributes (key , " xyz" )
138143 oa = subtract_vectors (a , o )
139144 similarity = dot_vectors (n , oa )
140145 return similarity < 0.0
@@ -143,12 +148,14 @@ def intersect(self):
143148 intersections = []
144149 vertex_intersections = []
145150 for u , v in list (self .mesh .edges ()):
146- a = self .mesh .vertex_attributes (u , ' xyz' )
147- b = self .mesh .vertex_attributes (v , ' xyz' )
151+ a = self .mesh .vertex_attributes (u , " xyz" )
152+ b = self .mesh .vertex_attributes (v , " xyz" )
148153 x = intersection_segment_plane ((a , b ), self .plane )
149154 if not x :
150155 continue
151- if any ([i != j for i , j in zip (x , a )]) and any ([i != j for i , j in zip (x , b )]):
156+ if any ([i != j for i , j in zip (x , a )]) and any (
157+ [i != j for i , j in zip (x , b )]
158+ ):
152159 L_ax = length_vector (subtract_vectors (x , a ))
153160 L_ab = length_vector (subtract_vectors (b , a ))
154161 t = L_ax / L_ab
@@ -164,7 +171,11 @@ def intersect(self):
164171
165172 def split (self ):
166173 for fkey in list (self .mesh .faces ()):
167- split = [key for key in self .mesh .face_vertices (fkey ) if key in self .intersections ]
174+ split = [
175+ key
176+ for key in self .mesh .face_vertices (fkey )
177+ if key in self .intersections
178+ ]
168179 if len (split ) == 2 :
169180 u , v = split
170181 try :
0 commit comments