39 #include "Implicit.hh"
59 typedef typename Vec3::value_type real;
63 : implicit1_(_implicit1), implicit2_(_implicit2)
71 return implicit1_.is_inside(_p) || implicit2_.is_inside(_p);
75 return std::min(implicit1_.scalar_distance(_p),
76 implicit2_.scalar_distance(_p));
83 real& _distance)
const
89 ok1 = implicit1_.directed_distance(_p0, _p1, p1, n1, d1);
90 ok2 = implicit2_.directed_distance(_p0, _p1, p2, n2, d2);
92 if (ok1 && ok2) {
if (d1 < d2) ok2 =
false;
else ok1 =
false; }
94 if (ok1) { _point = p1; _normal = n1; _distance = d1;
return true; }
95 else if (ok2) { _point = p2; _normal = n2; _distance = d2;
return true; }
119 template<
class Vec3>
124 typedef typename Vec3::value_type real;
128 : implicit1_(_implicit1), implicit2_(_implicit2)
136 return (implicit1_.is_inside(_p) && implicit2_.is_inside(_p));
140 return std::max(implicit1_.scalar_distance(_p),
141 implicit2_.scalar_distance(_p));
148 real& _distance)
const
154 ok1 = implicit1_.directed_distance(_p0, _p1, p1, n1, d1);
155 ok2 = implicit2_.directed_distance(_p0, _p1, p2, n2, d2);
157 if (ok1 && ok2) {
if (d1 > d2) ok2 =
false;
else ok1 =
false; }
159 if (ok1) { _point = p1; _normal = n1; _distance = d1;
return true; }
160 else if (ok2) { _point = p2; _normal = n2; _distance = d2;
return true; }
185 template<
class Vec3>
190 typedef typename Vec3::value_type real;
196 : implicit1_(_implicit1), implicit2_(_implicit2)
204 return implicit1_.is_inside(_p) && !implicit2_.is_inside(_p);
208 return std::max(implicit1_.scalar_distance(_p),
209 -implicit2_.scalar_distance(_p));
216 real& _distance)
const
222 ok1 = implicit1_.directed_distance(_p0, _p1, p1, n1, d1);
223 ok2 = implicit2_.directed_distance(_p0, _p1, p2, n2, d2);
226 if (ok1 && ok2) {
if (d1 > d2) ok2 =
false;
else ok1 =
false; }
228 if (ok1) { _point = p1; _normal = n1; _distance = d1;
return true; }
229 else if (ok2) { _point = p2; _normal = n2; _distance = d2;
return true; }
248 #endif // ISOEX_CSG_HH defined
Difference(const Implicit< Vec3 > &_implicit1, const Implicit< Vec3 > &_implicit2)
Definition: csg.hh:195
bool is_inside(const Vec3 &_p) const
Definition: csg.hh:135
real scalar_distance(const Vec3 &_p) const
Definition: csg.hh:139
bool directed_distance(const Vec3 &_p0, const Vec3 &_p1, Vec3 &_point, Vec3 &_normal, real &_distance) const
Definition: csg.hh:79
bool directed_distance(const Vec3 &_p0, const Vec3 &_p1, Vec3 &_point, Vec3 &_normal, real &_distance) const
Definition: csg.hh:212
bool is_inside(const Vec3 &_p) const
Definition: csg.hh:203
Union(const Implicit< Vec3 > &_implicit1, const Implicit< Vec3 > &_implicit2)
Constructor: given the two implicit objects to unite.
Definition: csg.hh:62
Intersection(const Implicit< Vec3 > &_implicit1, const Implicit< Vec3 > &_implicit2)
Constructor: given the two implicit objects to intersect.
Definition: csg.hh:127
real scalar_distance(const Vec3 &_p) const
Definition: csg.hh:74
Definition: Implicit.hh:57
A type for volume images, or 3D textures.
real scalar_distance(const Vec3 &_p) const
Definition: csg.hh:207
bool directed_distance(const Vec3 &_p0, const Vec3 &_p1, Vec3 &_point, Vec3 &_normal, real &_distance) const
Definition: csg.hh:144
bool is_inside(const Vec3 &_p) const
Definition: csg.hh:70