opennurbs_bounding_box.h
1 /* $NoKeywords: $ */
2 /*
3 //
4 // Copyright (c) 1993-2012 Robert McNeel & Associates. All rights reserved.
5 // OpenNURBS, Rhinoceros, and Rhino3D are registered trademarks of Robert
6 // McNeel & Associates.
7 //
8 // THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY.
9 // ALL IMPLIED WARRANTIES OF FITNESS FOR ANY PARTICULAR PURPOSE AND OF
10 // MERCHANTABILITY ARE HEREBY DISCLAIMED.
11 //
12 // For complete openNURBS copyright information see <http://www.opennurbs.org>.
13 //
14 ////////////////////////////////////////////////////////////////
15 */
16 
17 #if !defined(ON_BOUNDING_BOX_INC_)
18 #define ON_BOUNDING_BOX_INC_
19 
20 ////////////////////////////////////////////////////////////////
21 //
22 // ON_BoundingBox - axis aligned bounding box
23 //
24 
25 class ON_CLASS ON_BoundingBox
26 {
27 public:
28  static const ON_BoundingBox EmptyBoundingBox; // ((1.0,0.0,0.0),(-1.0,0.0,0.0))
29  static const ON_BoundingBox UnsetBoundingBox; // all coordinates are ON_UNSET_VALUE
30  static const ON_BoundingBox NanBoundingBox; // all coordinates are ON_DBL_QNAN
31 
32  ON_BoundingBox() ON_NOEXCEPT; // creates EmptyBoundingBox
33  ~ON_BoundingBox() = default;
34  ON_BoundingBox(const ON_BoundingBox&) = default;
35  ON_BoundingBox& operator=(const ON_BoundingBox&) = default;
36 
37  explicit ON_BoundingBox(
38  const ON_3dPoint&, // min corner of axis aligned bounding box
39  const ON_3dPoint& // max corner of axis aligned bounding box
40  );
41 
42 
43  // OBSOLETE
44  // temporary - use ON_ClippingRegion - this function will be removed soon.
45  int IsVisible(
46  const ON_Xform& bbox2c
47  ) const;
48 
49 
50  // OBSOLETE
51  void Destroy(); // set this = ON_BoundingBox::EmptyBoundingBox
52 
53  // operator[] returns min if index <= 0 and max if indes >= 1
54  ON_3dPoint& operator[](int);
55  const ON_3dPoint& operator[](int) const;
56 
57  ON_3dPoint Min() const;
58  ON_3dPoint Max() const;
59  ON_3dVector Diagonal() const; // max corner - min corner
60  ON_3dPoint Center() const;
61  ON_3dPoint Corner( // 8 corners of box
62  int, // x_index 0 = Min().x, 1 = Max().x
63  int, // y_index 0 = Min().y, 1 = Max().y
64  int // z_index 0 = Min().z, 1 = Max().z
65  ) const;
66  bool GetCorners(
67  ON_3dPointArray& box_corners // returns list of 8 corner points
68  ) const;
69  bool GetCorners(
70  ON_3dPoint box_corners[8] // returns list of 8 corner points
71  ) const;
72 
73  /*
74  Parameters:
75  edges[] - out
76  12 edge lines. If the bounding box has no height, width or depth,
77  then the corresponding edges will have the same "from" and "to"
78  points.
79  Returns:
80  If the bounding box is valid, then true is returned and
81  12 line segments, some possibly a single point, are returned.
82  Otherwise false is returned and 12 line segments with "from"
83  and "to" points set to ON_3dPoint::UnsetPoint are returned.
84  */
85  bool GetEdges(
86  ON_Line edges[12] // returns list of 12 edge segments
87  ) const;
88 
89  // OBSOLETE IsValid() = IsNotEmpty()
90  bool IsValid() const; // empty boxes are not valid
91 
92  bool IsSet() const; // every coordinate is a finite, valid double, not ON_UNSET_VALUE and not ON_UNSET_POSITIVE_VALUE
93  bool IsUnset() const; // some coordinate is ON_UNSET_VALUE or ON_UNSET_POSITIVE_VALUE
94  bool IsNan() const; // some coordinate is a NAN
95  bool IsUnsetOrNan() const; // = IsUnset() or IsNan()
96 
97  bool IsEmpty() const; // (m_min.x > m_max.x || m_min.y > m_max.y || m_min.z > m_max.z) && IsSet();
98  bool IsNotEmpty() const; // (m_min.x <= m_max.x && m_min.y <= m_max.y && m_min.z <= m_max.z) && IsSet()
99  bool IsPoint() const; // (m_min.x == m_max.x && m_min.y == m_max.y && m_min.z == m_max.z) && IsSet()
100 
101  void Dump(class ON_TextLog&) const;
102 
103  /*
104  Description:
105  Test a bounding box to see if it is degenerate (flat)
106  in one or more directions.
107  Parameters:
108  tolerance - [in] Distances <= tolerance will be considered
109  to be zero. If tolerance is negative (default), then
110  a scale invarient tolerance is used.
111  Returns:
112  @untitled table
113  0 box is not degenerate
114  1 box is a rectangle (degenerate in one direction)
115  2 box is a line (degenerate in two directions)
116  3 box is a point (degenerate in three directions)
117  4 box is not valid
118  */
119  int IsDegenerate(
120  double tolerance = ON_UNSET_VALUE
121  ) const;
122 
123 
124  //////////
125  // ON_BoundingBox::Transform() updates the bounding box
126  // to be the smallest axis aligned bounding box that contains
127  // the transform of the eight corner points of the input
128  // bounding box.
129  bool Transform( const ON_Xform& );
130 
131  double Tolerance() const; // rough guess at a tolerance to use for comparing
132  // objects in this bounding box
133 
134 
135  // All of these Set() functions set or expand a box to enclose the points in the arguments
136  // If bGrowBox is true, the existing box is expanded, otherwise it is only set to the current point list
137  bool Set(
138  int dim,
139  bool is_rat,
140  int count,
141  int stride,
142  const double* point_array,
143  int bGrowBox = false
144  );
145 
146  bool Set(
147  const ON_3dPoint& point,
148  int bGrowBox = false
149  );
150 
151  bool Set(
152  const ON_2dPoint& point,
153  int bGrowBox = false
154  );
155 
156  bool Set(
157  const ON_SimpleArray<ON_4dPoint>& point_array,
158  int bGrowBox = false
159  );
160 
161  bool Set(
162  const ON_SimpleArray<ON_3dPoint>& point_array,
163  int bGrowBox = false
164  );
165 
166  bool Set(
167  const ON_SimpleArray<ON_2dPoint>& point_array,
168  int bGrowBox = false
169  );
170 
171  bool Set(
172  int dim,
173  bool is_rat,
174  int count,
175  int stride,
176  const float* point_array,
177  int bGrowBox = false
178  );
179 
180  bool Set(
181  const ON_3fPoint& point,
182  int bGrowBox = false
183  );
184 
185  bool Set(
186  const ON_2fPoint& point,
187  int bGrowBox = false
188  );
189 
190  bool Set(
191  const ON_SimpleArray<ON_4fPoint>& point_array,
192  int bGrowBox = false
193  );
194 
195  bool Set(
196  const ON_SimpleArray<ON_3fPoint>& point_array,
197  int bGrowBox = false
198  );
199 
200  bool Set(
201  const ON_SimpleArray<ON_2fPoint>& point_array,
202  int bGrowBox = false
203  );
204 
205  bool IsPointIn(
206  const ON_3dPoint& test_point, // point to test
207  int bStrictlyIn = false
208  // true to test for strict ( min < point < max )
209  // false to test for (min <= point <= max)
210  //
211  ) const;
212 
213  //////////
214  // Point on or in the box that is closest to test_point.
215  // If test_point is in or on the box, the test_point is returned.
216  ON_3dPoint ClosestPoint(
217  const ON_3dPoint& test_point
218  ) const;
219 
220 
221  /*
222  Description:
223  Quickly find a lower bound on the distance
224  between the point and this bounding box.
225  Parameters:
226  P - [in]
227  Returns:
228  A distance that is less than or equal to the shortest
229  distance from the line to this bounding box.
230  Put another way, if Q is any point in this bounding box,
231  then P.DistanceTo(Q) >= MinimumDistanceTo(bbox).
232  */
233  double MinimumDistanceTo( const ON_3dPoint& P ) const;
234 
235  /*
236  Description:
237  Quickly find an upper bound on the distance
238  between the point and this bounding box.
239  Parameters:
240  P - [in]
241  Returns:
242  A distance that is greater than or equal to the
243  longest distance from the point P to this bounding box.
244  Put another way, if Q is any point in this bounding box,
245  then P.DistanceTo(Q) <= MaximumDistanceTo(bbox).
246  */
247  double MaximumDistanceTo( const ON_3dPoint& P ) const;
248 
249 
250  /*
251  Description:
252  Quickly find a lower bound on the distance
253  between this and the other bounding box.
254  Parameters:
255  other - [in]
256  Returns:
257  A distance that is less than or equal to the shortest
258  distance between the bounding boxes.
259  Put another way, if Q is any point in this bounding box
260  and P is any point in the other bounding box,
261  then P.DistanceTo(Q) >= MinimumDistanceTo(bbox).
262  */
263  double MinimumDistanceTo( const ON_BoundingBox& other ) const;
264 
265  /*
266  Description:
267  Quickly find an upper bound on the distance
268  between this and the other bounding box.
269  Parameters:
270  other - [in]
271  Returns:
272  A distance that is greater than or equal to the longest
273  distance between the bounding boxes.
274  Put another way, if Q is any point in this bounding box
275  and P is any point in the other bounding box,
276  then P.DistanceTo(Q) <= MaximumDistanceTo(bbox).
277  */
278  double MaximumDistanceTo( const ON_BoundingBox& other ) const;
279 
280  /*
281  Description:
282  Quickly find a lower bound on the distance
283  between the line segment and this bounding box.
284  Parameters:
285  line - [in]
286  Returns:
287  A distance that is less than or equal to the shortest
288  distance from the line to this bounding box.
289  Put another way, if Q is any point on line
290  and P is any point in this bounding box, then
291  P.DistanceTo(Q) >= MinimumDistanceTo(bbox).
292  */
293  double MinimumDistanceTo( const ON_Line& line ) const;
294 
295  /*
296  Description:
297  Quickly find a tight lower bound on the distance
298  between the plane and this bounding box.
299  Parameters:
300  plane - [in]
301  Returns:
302  The minimum distance between a point on the plane
303  and a point on the bounding box.
304  See Also:
305  ON_PlaneEquation::MimimumValueAt
306  ON_PlaneEquation::MaximumValueAt
307  */
308  double MinimumDistanceTo( const ON_Plane& plane ) const;
309  double MinimumDistanceTo( const ON_PlaneEquation& plane_equation ) const;
310 
311  /*
312  Description:
313  Quickly find an upper bound on the distance
314  between the line segment and this bounding box.
315  Parameters:
316  line - [in]
317  Returns:
318  A distance that is greater than or equal to the
319  longest distance from the line to this bounding box.
320  Put another way, if Q is any point on the line
321  and P is any point in this bounding box, then
322  P.DistanceTo(Q) <= MaximumDistanceTo(bbox).
323  */
324  double MaximumDistanceTo( const ON_Line& line ) const;
325 
326  /*
327  Description:
328  Quickly find a tight upper bound on the distance
329  between the plane and this bounding box.
330  Parameters:
331  plane - [in]
332  Returns:
333  A distance that is equal to the longest distance from
334  the plane to this bounding box. Put another way,
335  if Q is any point on the plane and P is any point
336  in this bounding box, then
337  P.DistanceTo(Q) <= MaximumDistanceTo(bbox) and there
338  is at least one point on the bounding box where the
339  distance is equal to the returned value.
340  See Also:
341  ON_PlaneEquation::MaximumValueAt
342  */
343  double MaximumDistanceTo( const ON_Plane& plane ) const;
344  double MaximumDistanceTo( const ON_PlaneEquation& plane_equation ) const;
345 
346 
347  /*
348  Description:
349  Quickly determine if the shortest distance from
350  the point P to the bounding box is greater than d.
351  Parameters:
352  d - [in] distance (> 0.0)
353  P - [in]
354  Returns:
355  True if if the shortest distance from the point P
356  to the bounding box is greater than d.
357  */
358  bool IsFartherThan( double d, const ON_3dPoint& P ) const;
359 
360  /*
361  Description:
362  Quickly determine if the shortest distance from the line
363  to the bounding box is greater than d.
364  Parameters:
365  d - [in] distance (> 0.0)
366  line - [in]
367  Returns:
368  True if the shortest distance from the line
369  to the bounding box is greater than d. It is not the
370  case that false means that the shortest distance
371  is less than or equal to d.
372  */
373  bool IsFartherThan( double d, const ON_Line& line ) const;
374 
375  /*
376  Description:
377  Quickly determine if the shortest distance from the plane
378  to the bounding box is greater than d.
379  Parameters:
380  d - [in] distance (> 0.0)
381  plane - [in]
382  Returns:
383  True if the shortest distance from the plane
384  to the bounding box is greater than d, and false
385  if the shortest distance is less than or equal to d.
386  */
387  bool IsFartherThan( double d, const ON_Plane& plane ) const;
388 
389  /*
390  Description:
391  Quickly determine if the shortest distance from the plane
392  to the bounding box is greater than d.
393  Parameters:
394  d - [in] distance (> 0.0)
395  plane_equation - [in] (the first three coefficients
396  are assumed to be a unit vector.
397  If not, adjust your d accordingly.)
398  Returns:
399  True if the shortest distance from the plane
400  to the bounding box is greater than d, and false
401  if the shortest distance is less than or equal to d.
402  */
403  bool IsFartherThan( double d, const ON_PlaneEquation& plane_equation ) const;
404 
405  /*
406  Description:
407  Quickly determine if the shortest distance this bounding
408  box to another bounding box is greater than d.
409  Parameters:
410  d - [in] distance (> 0.0)
411  other - [in] other bounding box
412  Returns:
413  True if if the shortest distance from this bounding
414  box to the other bounding box is greater than d.
415  */
416  bool IsFartherThan( double d, const ON_BoundingBox& other ) const;
417 
418 
419  // Description:
420  // Get point in a bounding box that is closest to a line
421  // segment.
422  // Parameters:
423  // line - [in] line segment
424  // box_point - [out] point in box that is closest to line
425  // segment point at t0.
426  // t0 - [out] parameter of point on line that is closest to
427  // the box.
428  // t1 - [out] parameter of point on line that is closest to
429  // the box.
430  // Returns:
431  // 3 success - line segments intersects box in a segment
432  // from line(t0) to line(t1) (t0 < t1)
433  // 2 success - line segments intersects box in a single point
434  // at line(t0) (t0==t1)
435  // 1 success - line segment does not intersect box. Closest
436  // point on the line is at line(t0) (t0==t1)
437  // 0 failure - box is invalid.
438  // Remarks:
439  // The box is treated as a solid box. If the intersection
440  // of the line segment, then 3 is returned.
441  int GetClosestPoint(
442  const ON_Line&, // line
443  ON_3dPoint&, // box_point
444  double*, // t0
445  double* // t1
446  ) const;
447 
448  //////////
449  // Get points on bounding boxes that are closest to each other.
450  // If the boxes intersect, then the point at the centroid of the
451  // intersection is returned for both points.
452  bool GetClosestPoint(
453  const ON_BoundingBox&, // "other" bounding box
454  ON_3dPoint&, // point on "this" box that is closest to "other" box
455  ON_3dPoint& // point on "other" box that is closest to "this" box
456  ) const;
457 
458  //////////
459  // Point on the box that is farthest from the test_point.
460  ON_3dPoint FarPoint(
461  const ON_3dPoint& // test_point
462  ) const;
463 
464  //////////
465  // Get points on bounding boxes that are farthest from each other.
466  bool GetFarPoint(
467  const ON_BoundingBox&, // "other" bounding box
468  ON_3dPoint&, // point on "this" box that is farthest from "other" box
469  ON_3dPoint& // point on "other" box that is farthest from "this" box
470  ) const;
471 
472  /*
473  Description:
474  Intersect this with other_bbox and save intersection in this.
475  Parameters:
476  other_bbox - [in]
477  Returns:
478  True if this-intesect-other_bbox is a non-empty valid bounding box
479  and this is set. False if the intersection is empty, in which case
480  "this" is set to an invalid bounding box.
481  Remarks:
482  If "this" or other_bbox is invalid, they are treated as
483  the empty set, and false is returned.
484  */
485  bool Intersection(
486  const ON_BoundingBox& other_bbox
487  );
488 
489  /*
490  Description:
491  Set "this" to the intersection of bbox_A and bbox_B.
492  Parameters:
493  bbox_A - [in]
494  bbox_B - [in]
495  Returns:
496  True if the "this" is a non-empty valid bounding box.
497  False if the intersection is empty, in which case
498  "this" is set to an invalid bounding box.
499  Remarks:
500  If bbox_A or bbox_B is invalid, they are treated as
501  the empty set, and false is returned.
502  */
503  bool Intersection( // this = intersection of two args
504  const ON_BoundingBox& bbox_A,
505  const ON_BoundingBox& bbox_B
506  );
507 
508  bool Intersection( //Returns true when intersect is non-empty.
509  const ON_Line&, //Infinite Line segment to intersect with
510  double* =nullptr , // t0 parameter of first intersection point
511  double* =nullptr // t1 parameter of last intersection point (t0<=t1)
512  ) const;
513 
514  /*
515  Description:
516  Test a box to see if it is contained in this box.
517  Parameters:
518  other - [in] box to test
519  bProperSubSet - [in] if true, then the test is for a proper inclusion.
520  Returns:
521  If bProperSubSet is false, then the result is true when
522  this->m_min[i] <= other.m_min[i] and other.m_max[i] <= this->m_max[i].
523  for i=0,1 and 2.
524  If bProperSubSet is true, then the result is true when
525  the above condition is true and at least one of the inequalities is strict.
526  */
527  bool Includes(
528  const ON_BoundingBox& other,
529  bool bProperSubSet = false
530  ) const;
531 
532  double Volume() const;
533 
534  double Area() const;
535 
536  // Union() returns true if union is not empty.
537  // Invalid boxes are treated as the empty set.
538  bool Union( // this = this union arg
539  const ON_BoundingBox&
540  );
541 
542  bool Union( // this = union of two args
543  const ON_BoundingBox&,
544  const ON_BoundingBox&
545  );
546 
547  /*
548  Description:
549  Test to see if "this" and other_bbox are disjoint (do not intersect).
550  Parameters:
551  other_bbox - [in]
552  Returns:
553  True if "this" and other_bbox are disjoint.
554  Remarks:
555  If "this" or other_bbox is invalid, then true is returned.
556  */
557  bool IsDisjoint(
558  const ON_BoundingBox& other_bbox
559  ) const;
560 
561  bool SwapCoordinates( int, int );
563  ON_3dPoint m_min;
564  ON_3dPoint m_max;
565 };
566 
567 /*
568 Returns:
569  True if lhs and rhs are identical.
570 */
571 ON_DECL
572 bool operator==( const ON_BoundingBox& lhs, const ON_BoundingBox& rhs );
573 
574 /*
575 Returns:
576  True if lhs and rhs are not equal.
577 */
578 ON_DECL
579 bool operator!=( const ON_BoundingBox& lhs, const ON_BoundingBox& rhs );
580 
581 class ON_CLASS ON_BoundingBoxAndHash
582 {
583 public:
584  ON_BoundingBoxAndHash() = default;
585  ~ON_BoundingBoxAndHash() = default;
586  ON_BoundingBoxAndHash(const ON_BoundingBoxAndHash&) = default;
587  ON_BoundingBoxAndHash& operator=(const ON_BoundingBoxAndHash&) = default;
588 
589 public:
590  // This hash depends on the context and is a hash
591  // of the information used to calculte the bounding box.
592  // It is not the hash of the box values
593 
594  void Set(
595  const ON_BoundingBox& bbox,
596  const ON_SHA1_Hash& hash
597  );
598 
599  const ON_BoundingBox& BoundingBox() const;
600 
601  const ON_SHA1_Hash& Hash() const;
602 
603  /*
604  Returns:
605  True if bounding box IsSet() is true and hash is not EmptyContentHash.
606  */
607  bool IsSet() const;
608 
609  bool Write(
610  class ON_BinaryArchive& archive
611  ) const;
612 
613  bool Read(
614  class ON_BinaryArchive& archive
615  );
616 
617  private:
618  ON_BoundingBox m_bbox = ON_BoundingBox::UnsetBoundingBox;
620 };
621 
622 /*
623 A class that caches 8 bounding box - hash pairs and keeps the most frequently
624 used bounding boxes.
625 */
626 class ON_CLASS ON_BoundingBoxCache
627 {
628 public:
629  ON_BoundingBoxCache() = default;
630  ~ON_BoundingBoxCache() = default;
631  ON_BoundingBoxCache(const ON_BoundingBoxCache&) = default;
632  ON_BoundingBoxCache& operator=(const ON_BoundingBoxCache&) = default;
633 
634 public:
635  /*
636  Description:
637  Add a bounding box that can be found from a hash value.
638  Parameters:
639  bbox - [in]
640  hash - [in]
641  A hash of the information needed to create this bounding box.
642  */
643  void AddBoundingBox(
644  const ON_BoundingBox& bbox,
645  const ON_SHA1_Hash& hash
646  );
647 
648  void AddBoundingBox(
649  const ON_BoundingBoxAndHash& bbox_and_hash
650  );
651 
652  /*
653  Description:
654  Get a cached bounding box.
655  Parameters:
656  hash - [in]
657  bbox - [out]
658  If the hash identifies a bounding box in the cache, then
659  that bounding box is returned. Otherwise ON_BoundingBox::NanBoundingBox
660  is returned.
661  Returns:
662  true - cached bounding box returned
663  false - bounding box not in cache.
664  */
665  bool GetBoundingBox(
666  const ON_SHA1_Hash& hash,
667  ON_BoundingBox& bbox
668  ) const;
669 
670  /*
671  Description:
672  Remove a bounding box that can be found from a hash value.
673  Parameters:
674  hash - [in]
675  Returns:
676  true - hash was in the cache and removed.
677  false - hash was not in the cache.
678  Remarks:
679  If the hash values you are using are correctly computed and include
680  all information that the bouding box depends on, then
681  you never need to remove bounding boxes. Unused ones will get
682  removed as new ones are added.
683  */
684  bool RemoveBoundingBox(
685  const ON_SHA1_Hash& hash
686  );
687 
688  /*
689  Description:
690  Removes all bounding boxes.
691  Remarks:
692  If the hash values you are using are correctly computed and include
693  all information that the bouding box depends on, then
694  you never need to remove bounding boxes. Unused ones will get
695  removed as new ones are added.
696  If the hash does not include all information required to compute
697  the bounding boxes, then call RemoveAllBoundingBoxes() when the
698  non-hashed information changes.
699  */
700  void RemoveAllBoundingBoxes();
701 
702  /*
703  Returns:
704  Number of cached boxes.
705  */
706  unsigned int BoundingBoxCount() const;
707 
708  bool Write(
709  class ON_BinaryArchive& archive
710  ) const;
711 
712  bool Read(
713  class ON_BinaryArchive& archive
714  );
715 
716 private:
717  // number of boxes set in m_cache[]
718  unsigned int m_count = 0;
719 
720  // capacity of m_cache[] - set when needed
721  unsigned int m_capacity = 0;
722 
723  // Bounding box cache. Most recently used boxes are first.
724  mutable ON_BoundingBoxAndHash m_cache[8];
725 
726  /*
727  Returns:
728  m_cache[] array index of box with the hash.
729  ON_UNSET_UINT_INDEX if hash is not present in m_cache[] array.
730  */
731  unsigned int Internal_CacheIndex(const ON_SHA1_Hash& hash) const;
732 };
733 
734 #if defined(ON_DLL_TEMPLATE)
735 
736 ON_DLL_TEMPLATE template class ON_CLASS ON_SimpleArray<ON_BoundingBox>;
737 ON_DLL_TEMPLATE template class ON_CLASS ON_SimpleArray<ON_BoundingBoxAndHash>;
738 
739 #endif
740 
741 /*
742 Description:
743  Get a tight bounding box that contains the points.
744 Parameters:
745  dim - [in] (>=1)
746  is_rat - [in] true if points are rational
747  count - [in] number of points
748  stride - [in] stride between points
749  point_list - [in]
750  bbox - [in/out]
751  bGrowBox - [in] (default = false)
752  If the input bbox is valid and bGrowBox is true,
753  then the output bbox is the union of the input
754  bbox and the bounding box of the point list.
755  xform - [in] (default = nullptr)
756  If not null, the bounding box of the transformed
757  points is calculated. The points are not modified.
758 Returns:
759  True if the output bbox is valid.
760 */
761 ON_DECL
762 bool ON_GetPointListBoundingBox(
763  int dim,
764  bool is_rat,
765  int count,
766  int stride,
767  const double* point_list,
768  ON_BoundingBox& bbox,
769  int bGrowBox = false,
770  const ON_Xform* xform = 0
771  );
772 
773 ON_DECL
774 bool ON_GetPointListBoundingBox(
775  int dim,
776  bool is_rat,
777  int count,
778  int stride,
779  const float* point_list,
780  ON_BoundingBox& bbox,
781  int bGrowBox = false,
782  const ON_Xform* xform = 0
783  );
784 
785 ON_DECL
786 bool ON_GetPointListBoundingBox(
787  int dim,
788  bool is_rat,
789  int count,
790  int stride,
791  const double* point_list,
792  double* boxmin, // min[dim]
793  double* boxmax, // max[dim]
794  int bGrowBox
795  );
796 
797 ON_DECL
798 ON_BoundingBox ON_PointListBoundingBox(
799  int dim,
800  bool is_rat,
801  int count,
802  int stride,
803  const double* point_list
804  );
805 
806 ON_DECL
807 bool ON_GetPointListBoundingBox(
808  int dim,
809  bool is_rat,
810  int count,
811  int stride,
812  const float* point_list,
813  float* boxmin, // min[dim]
814  float* boxmax, // max[dim]
815  int bGrowBox
816  );
817 
818 ON_DECL
819 ON_BoundingBox ON_PointListBoundingBox( // low level workhorse function
820  int dim,
821  bool is_rat,
822  int count,
823  int stride,
824  const float* point_list
825  );
826 
827 ON_DECL
828 bool ON_GetPointGridBoundingBox(
829  int dim,
830  bool is_rat,
831  int point_count0, int point_count1,
832  int point_stride0, int point_stride1,
833  const double* point_grid,
834  double* boxmin, // min[dim]
835  double* boxmax, // max[dim]
836  int bGrowBox
837  );
838 
839 ON_DECL
840 ON_BoundingBox ON_PointGridBoundingBox(
841  int dim,
842  bool is_rat,
843  int point_count0, int point_count1,
844  int point_stride0, int point_stride1,
845  const double* point_grid
846  );
847 
848 ON_DECL
849 double ON_BoundingBoxTolerance(
850  int dim,
851  const double* bboxmin,
852  const double* bboxmax
853  );
854 
855 /*
856 Description:
857  Determine if an object is too large or too far
858  from the origin for single precision coordinates
859  to be useful.
860 Parameters:
861  bbox - [in]
862  Bounding box of an object with single precision
863  coordinates. An ON_Mesh is an example of an
864  object with single precision coordinates.
865  xform - [out]
866  If this function returns false and xform is not
867  null, then the identity transform is returned.
868  If this function returns true and xform is not
869  null, then the transform moves the region
870  contained in bbox to a location where single
871  precision coordinates will have enough
872  information for the object to be useful.
873 Returns:
874  true:
875  The region contained in bbox is too large
876  or too far from the origin for single
877  precision coordinates to be useful.
878  false:
879  A single precision object contained in bbox
880  will be satisfactory for common calculations.
881 */
882 ON_DECL
883 bool ON_BeyondSinglePrecision( const ON_BoundingBox& bbox, ON_Xform* xform );
884 
885 ON_DECL
886 bool ON_WorldBBoxIsInTightBBox(
887  const ON_BoundingBox& tight_bbox,
888  const ON_BoundingBox& world_bbox,
889  const ON_Xform* xform
890  );
891 
892 #endif
Definition: opennurbs_bounding_box.h:562
Definition: opennurbs_bounding_box.h:606
static const ON_BoundingBox EmptyBoundingBox
Definition: opennurbs_bounding_box.h:28
static const ON_SHA1_Hash EmptyContentHash
Definition: opennurbs_sha1.h:23
Definition: opennurbs_array.h:36
Definition: opennurbs_sha1.h:19
Definition: opennurbs_fpoint.h:211
static const ON_BoundingBox UnsetBoundingBox
Definition: opennurbs_bounding_box.h:29
Definition: opennurbs_point.h:277
Definition: opennurbs_point.h:2018
static const ON_BoundingBox NanBoundingBox
Definition: opennurbs_bounding_box.h:30
Definition: opennurbs_point.h:648
Definition: opennurbs_bounding_box.h:25
Definition: opennurbs_xform.h:28
Definition: opennurbs_line.h:20
Definition: opennurbs_textlog.h:20
Definition: opennurbs_archive.h:1783
Definition: opennurbs_fpoint.h:38
Definition: opennurbs_point.h:460
Definition: opennurbs_plane.h:20
Definition: opennurbs_fpoint.h:385
Typically the vector portion is a unit vector and m_d = -(x*P.x + y*P.y + z*P.z) for a point P on the...
Definition: opennurbs_point.h:1433
Definition: opennurbs_point.h:1152