66 Copyright (c) 2015 Scientific Computing and Imaging Institute,
77 University of Utah.
88
9-
9+
1010 Permission is hereby granted, free of charge, to any person obtaining a
1111 copy of this software and associated documentation files (the "Software"),
1212 to deal in the Software without restriction, including without limitation
@@ -50,10 +50,10 @@ class BBox {
5050 enum { INSIDE, INTERSECT, OUTSIDE };
5151
5252 BBox () : is_valid_(false ) {}
53-
54- BBox (const BBox& copy)
53+
54+ BBox (const BBox& copy)
5555 : cmin_(copy.cmin_), cmax_(copy.cmax_), is_valid_(copy.is_valid_) {}
56-
56+
5757 BBox& operator =(const BBox& copy)
5858 {
5959 is_valid_ = copy.is_valid_ ;
@@ -63,35 +63,35 @@ class BBox {
6363 }
6464
6565 BBox (const BBox& b1, const BBox& b2)
66- : cmin_(b1.cmin_), cmax_(b1.cmax_), is_valid_(true )
66+ : cmin_(b1.cmin_), cmax_(b1.cmax_), is_valid_(true )
6767 {
6868 extend (b2.cmin_ );
6969 extend (b2.cmax_ );
7070 }
7171
72-
72+
7373 BBox (const Point& p1, const Point& p2)
74- : cmin_(p1), cmax_(p1), is_valid_(true )
74+ : cmin_(p1), cmax_(p1), is_valid_(true )
7575 {
7676 extend (p2);
7777 }
7878
7979 BBox (const Point& p1, const Point& p2, const Point& p3)
80- : cmin_(p1), cmax_(p1), is_valid_(true )
80+ : cmin_(p1), cmax_(p1), is_valid_(true )
8181 {
8282 extend (p2);
8383 extend (p3);
8484 }
85-
85+
8686 explicit BBox (const std::vector<Point>& points) :
8787 is_valid_(false )
8888 {
8989 for (size_t j=0 ; j<points.size (); j++)
9090 {
9191 extend (points[j]);
9292 }
93- }
94-
93+ }
94+
9595 inline bool valid () const { return is_valid_; }
9696 inline void set_valid (bool v) { is_valid_ = v; }
9797 inline void reset () { is_valid_ = false ; }
@@ -103,8 +103,8 @@ class BBox {
103103 {
104104 cmin_=Min (p, cmin_);
105105 cmax_=Max (p, cmax_);
106- }
107- else
106+ }
107+ else
108108 {
109109 cmin_=p;
110110 cmax_=p;
@@ -120,12 +120,12 @@ class BBox {
120120 {
121121 if (is_valid_)
122122 {
123- cmin_.x (cmin_.x ()-val);
124- cmin_.y (cmin_.y ()-val);
125- cmin_.z (cmin_.z ()-val);
126- cmax_.x (cmax_.x ()+val);
127- cmax_.y (cmax_.y ()+val);
128- cmax_.z (cmax_.z ()+val);
123+ cmin_.x (cmin_.x ()-val);
124+ cmin_.y (cmin_.y ()-val);
125+ cmin_.z (cmin_.z ()-val);
126+ cmax_.x (cmax_.x ()+val);
127+ cmax_.y (cmax_.y ()+val);
128+ cmax_.z (cmax_.z ()+val);
129129 }
130130 }
131131
@@ -138,8 +138,8 @@ class BBox {
138138 {
139139 cmin_=Min (p-r, cmin_);
140140 cmax_=Max (p+r, cmax_);
141- }
142- else
141+ }
142+ else
143143 {
144144 cmin_=p-r;
145145 cmax_=p+r;
@@ -156,18 +156,18 @@ class BBox {
156156 extend (b.get_max ());
157157 }
158158 }
159-
159+
160160 // / Expand the bounding box to include a disk centered at cen,
161161 // / with normal normal, and radius r.
162162 SCISHARE void extend_disk (const Point& cen, const Vector& normal, double r);
163163
164- inline Point center () const
164+ inline Point center () const
165165 {
166166 // / @todo: C assert: assert(is_valid_);
167167 Vector d = diagonal ();
168168 return cmin_ + (d * 0.5 );
169169 }
170-
170+
171171 inline double longest_edge () const
172172 {
173173 // / @todo: C assert: assert(is_valid_);
@@ -185,50 +185,50 @@ class BBox {
185185 // / Check whether two BBoxes are similar
186186 SCISHARE bool is_similar_to (const BBox &b, double diff=0.5 ) const ;
187187
188- // / Move the bounding box
188+ // / Move the bounding box
189189 SCISHARE void translate (const Vector &v);
190190
191191 // / Scale the bounding box by s, centered around o
192192 SCISHARE void scale (double s, const Vector &o);
193193
194194 inline Point get_min () const
195195 { return cmin_; }
196-
196+
197197 inline Point get_max () const
198198 { return cmax_; }
199199
200200 inline Vector diagonal () const
201- {
201+ {
202202 // TODO: needs invariant check, or refactoring.
203- ASSERT (is_valid_);
204- return cmax_-cmin_;
203+ ASSERT (is_valid_);
204+ return cmax_-cmin_;
205205 }
206206
207- inline bool inside (const Point &p) const
207+ inline bool inside (const Point &p) const
208208 {
209- return (is_valid_ && p.x () >= cmin_.x () &&
210- p.y () >= cmin_.y () && p.z () >= cmin_.z () &&
211- p.x () <= cmax_.x () && p.y () <= cmax_.y () &&
209+ return (is_valid_ && p.x () >= cmin_.x () &&
210+ p.y () >= cmin_.y () && p.z () >= cmin_.z () &&
211+ p.x () <= cmax_.x () && p.y () <= cmax_.y () &&
212212 p.z () <= cmax_.z ());
213213 }
214214
215215 inline int intersect (const BBox& b) const
216216 {
217217 if ((cmax_.x () < b.cmin_ .x ()) || (cmin_.x () > b.cmax_ .x ()) ||
218218 (cmax_.y () < b.cmin_ .y ()) || (cmin_.y () > b.cmax_ .y ()) ||
219- (cmax_.z () < b.cmin_ .z ()) || (cmin_.z () > b.cmax_ .z ()))
219+ (cmax_.z () < b.cmin_ .z ()) || (cmin_.z () > b.cmax_ .z ()))
220220 {
221221 return OUTSIDE;
222222 }
223-
223+
224224 if ((cmin_.x () <= b.cmin_ .x ()) && (cmax_.x () >= b.cmax_ .x ()) &&
225225 (cmin_.y () <= b.cmin_ .y ()) && (cmax_.y () >= b.cmax_ .y ()) &&
226- (cmin_.z () <= b.cmin_ .z ()) && (cmax_.z () >= b.cmax_ .z ()))
226+ (cmin_.z () <= b.cmin_ .z ()) && (cmax_.z () >= b.cmax_ .z ()))
227227 {
228228 return INSIDE;
229229 }
230-
231- return INTERSECT;
230+
231+ return INTERSECT;
232232 }
233233
234234 inline double x_length () { return (cmax_.x () - cmin_.x ()); }
@@ -244,14 +244,14 @@ class BBox {
244244 // / in hitNear
245245 SCISHARE bool intersect (const Point& e, const Vector& v, Point& hitNear) const ;
246246
247- friend std::ostream& operator <<(std::ostream& out, const BBox& b);
248247
249248 private:
250249 Point cmin_;
251250 Point cmax_;
252251 bool is_valid_;
253252};
254253
254+ SCISHARE std::ostream& operator <<(std::ostream& out, const BBox& b);
255255SCISHARE void Pio ( Piostream &, BBox& );
256256
257257}}}
0 commit comments