MCPcopy
hub / github.com/CadQuery/cadquery / filter

Method filter

cadquery/selectors.py:167–189  ·  view source on GitHub ↗

There are lots of kinds of filters, but for planes they are always based on the normal of the plane, and for edges on the tangent vector along the edge

(self, objectList: Sequence[Shape])

Source from the content-addressed store, hash-verified

165 return True
166
167 def filter(self, objectList: Sequence[Shape]) -> List[Shape]:
168 """
169 There are lots of kinds of filters, but for planes they are always
170 based on the normal of the plane, and for edges on the tangent vector
171 along the edge
172 """
173 r = []
174 for o in objectList:
175 # no really good way to avoid a switch here, edges and faces are simply different!
176 if o.ShapeType() == "Face" and o.geomType() == "PLANE":
177 # a face is only parallel to a direction if it is a plane, and
178 # its normal is parallel to the dir
179 test_vector = cast(FaceProtocol, o).normalAt(None)
180 elif o.ShapeType() == "Edge" and o.geomType() == "LINE":
181 # an edge is parallel to a direction if its underlying geometry is plane or line
182 test_vector = cast(Shape1DProtocol, o).tangentAt()
183 else:
184 continue
185
186 if self.test(test_vector):
187 r.append(o)
188
189 return r
190
191
192class ParallelDirSelector(BaseDirSelector):

Callers

nothing calls this directly

Calls 6

testMethod · 0.95
appendMethod · 0.80
ShapeTypeMethod · 0.45
geomTypeMethod · 0.45
normalAtMethod · 0.45
tangentAtMethod · 0.45

Tested by

no test coverage detected