Skip to content

Commit b96ef6d

Browse files
authored
Merge pull request #1704 from SCIInstitute/ospray-features
Ospray features
2 parents fad9e22 + 8df0169 commit b96ef6d

File tree

11 files changed

+12924
-657
lines changed

11 files changed

+12924
-657
lines changed

src/Core/GeometryPrimitives/BBox.cc

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
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
@@ -33,7 +33,7 @@
3333
using namespace SCIRun;
3434
using namespace SCIRun::Core::Geometry;
3535

36-
void
36+
void
3737
BBox::extend_disk(const Point& cen, const Vector& normal, double r)
3838
{
3939
if (normal.length2() < 1.e-12) { extend(cen); return; }
@@ -66,14 +66,14 @@ BBox::is_similar_to(const BBox &b, double diff) const
6666
return true;
6767
}
6868

69-
void
69+
void
7070
BBox::translate(const Vector &v)
7171
{
7272
cmin_+=v;
7373
cmax_+=v;
7474
}
7575

76-
void
76+
void
7777
BBox::scale(double s, const Vector&o)
7878
{
7979
cmin_-=o;
@@ -84,7 +84,7 @@ BBox::scale(double s, const Vector&o)
8484
cmax_+=o;
8585
}
8686

87-
bool
87+
bool
8888
BBox::overlaps(const BBox & bb) const
8989
{
9090
if( bb.cmin_.x() > cmax_.x() || bb.cmax_.x() < cmin_.x())
@@ -97,7 +97,7 @@ BBox::overlaps(const BBox & bb) const
9797
return true;
9898
}
9999

100-
bool
100+
bool
101101
BBox::overlaps_inside(const BBox & bb) const
102102
{
103103
if( bb.cmin_.x() >= cmax_.x() || bb.cmax_.x() <= cmin_.x())
@@ -110,7 +110,7 @@ BBox::overlaps_inside(const BBox & bb) const
110110
return true;
111111
}
112112

113-
bool
113+
bool
114114
BBox::intersect(const Point& origin, const Vector& dir, Point& hitPoint) const
115115
{
116116
Vector t1 = (cmin_ - origin) / dir;
@@ -123,36 +123,41 @@ BBox::intersect(const Point& origin, const Vector& dir, Point& hitPoint) const
123123
{
124124
hitPoint = origin + dir*tnear;
125125
return true;
126-
}
127-
else
126+
}
127+
else
128128
{
129129
return false;
130130
}
131131
}
132132

133-
void Pio(Piostream &stream, BBox & box)
133+
void SCIRun::Core::Geometry::Pio(Piostream &stream, BBox & box)
134134
{
135135
stream.begin_cheap_delim();
136-
136+
137137
// Store the valid flag as an int to be backwards compatible.
138138
int tmp = box.valid();
139139
Point min = box.get_min();
140140
Point max = box.get_max();
141141
Pio(stream, tmp);
142-
if (tmp)
142+
if (tmp)
143143
{
144144
Pio(stream, min);
145145
Pio(stream, max);
146146
}
147147

148-
if(stream.reading())
148+
if(stream.reading())
149149
{
150150
box.set_valid(tmp);
151-
if (tmp)
151+
if (tmp)
152152
{
153153
box.extend(min);
154154
box.extend(max);
155155
}
156156
}
157157
stream.end_cheap_delim();
158158
}
159+
160+
std::ostream& SCIRun::Core::Geometry::operator<<(std::ostream& out, const BBox& b)
161+
{
162+
return out << b.get_min() << " : " << b.get_max();
163+
}

src/Core/GeometryPrimitives/BBox.h

Lines changed: 39 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
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);
255255
SCISHARE void Pio( Piostream &, BBox& );
256256

257257
}}}

0 commit comments

Comments
 (0)