MCPcopy Create free account
hub / github.com/Kitware/VTK / IntersectBox

Method IntersectBox

Common/DataModel/vtkBoundingBox.cxx:199–245  ·  view source on GitHub ↗

------------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

197
198//------------------------------------------------------------------------------
199int vtkBoundingBox::IntersectBox(const vtkBoundingBox& bbox)
200{
201 // if either box is not valid don't do the operation
202 if (!(this->IsValid() && bbox.IsValid()))
203 {
204 return 0;
205 }
206
207 bool intersects;
208 double pMin[3], pMax[3];
209 for (unsigned i = 0; i < 3; i++)
210 {
211 intersects = false;
212 if ((bbox.MinPnt[i] >= this->MinPnt[i]) && (bbox.MinPnt[i] <= this->MaxPnt[i]))
213 {
214 intersects = true;
215 pMin[i] = bbox.MinPnt[i];
216 }
217 else if ((this->MinPnt[i] >= bbox.MinPnt[i]) && (this->MinPnt[i] <= bbox.MaxPnt[i]))
218 {
219 intersects = true;
220 pMin[i] = this->MinPnt[i];
221 }
222 if ((bbox.MaxPnt[i] >= this->MinPnt[i]) && (bbox.MaxPnt[i] <= this->MaxPnt[i]))
223 {
224 intersects = true;
225 pMax[i] = bbox.MaxPnt[i];
226 }
227 else if ((this->MaxPnt[i] >= bbox.MinPnt[i]) && (this->MaxPnt[i] <= bbox.MaxPnt[i]))
228 {
229 intersects = true;
230 pMax[i] = this->MaxPnt[i];
231 }
232 if (!intersects)
233 {
234 return 0;
235 }
236 }
237
238 // OK they did intersect - set the box to be the result
239 for (unsigned i = 0; i < 3; i++)
240 {
241 this->MinPnt[i] = pMin[i];
242 this->MaxPnt[i] = pMax[i];
243 }
244 return 1;
245}
246
247//------------------------------------------------------------------------------
248int vtkBoundingBox::Intersects(const vtkBoundingBox& bbox) const

Callers

nothing calls this directly

Calls 2

IsValidMethod · 0.95
IsValidMethod · 0.45

Tested by

no test coverage detected