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

Method filter

cadquery/selectors.py:125–151  ·  view source on GitHub ↗
(self, objectList: Sequence[Shape])

Source from the content-addressed store, hash-verified

123 self.test_boundingbox = boundingbox
124
125 def filter(self, objectList: Sequence[Shape]):
126
127 result = []
128 x0, y0, z0 = self.p0.toTuple()
129 x1, y1, z1 = self.p1.toTuple()
130
131 def isInsideBox(p):
132 # using XOR for checking if x/y/z is in between regardless
133 # of order of x/y/z0 and x/y/z1
134 return (
135 ((p.x < x0) ^ (p.x < x1))
136 and ((p.y < y0) ^ (p.y < y1))
137 and ((p.z < z0) ^ (p.z < z1))
138 )
139
140 for o in objectList:
141 if self.test_boundingbox:
142 bb = o.BoundingBox()
143 if isInsideBox(Vector(bb.xmin, bb.ymin, bb.zmin)) and isInsideBox(
144 Vector(bb.xmax, bb.ymax, bb.zmax)
145 ):
146 result.append(o)
147 else:
148 if isInsideBox(o.Center()):
149 result.append(o)
150
151 return result
152
153
154class BaseDirSelector(Selector):

Callers

nothing calls this directly

Calls 5

VectorClass · 0.85
appendMethod · 0.80
toTupleMethod · 0.45
BoundingBoxMethod · 0.45
CenterMethod · 0.45

Tested by

no test coverage detected