17 #ifndef GZ_MATH_PIECEWISE_SCALAR_FIELD3_HH_
18 #define GZ_MATH_PIECEWISE_SCALAR_FIELD3_HH_
28 #include <gz/math/config.hh>
33 inline namespace GZ_MATH_VERSION_NAMESPACE {
38 template<
typename ScalarField3T,
typename ScalarT>
76 for (
size_t i = 0; i < pieces.size(); ++i)
78 if (pieces[i].region.Empty())
80 std::cerr <<
"Region #" << i <<
" (" << pieces[i].region
81 <<
") in piecewise scalar field definition is empty."
84 for (
size_t j = i + 1; j < pieces.size(); ++j)
86 if (pieces[i].region.Intersects(pieces[j].region))
88 std::cerr <<
"Detected overlap between regions in "
89 <<
"piecewise scalar field definition: "
90 <<
"region #" << i <<
" (" << pieces[i].region
91 <<
") overlaps with region #" << j <<
" ("
92 << pieces[j].region <<
"). Region #" << i
93 <<
" will take precedence when overlapping."
116 this->pieces.begin(), this->pieces.end(),
117 [&](
const Piece &piece)
119 return piece.region.Contains(_p);
121 if (it == this->pieces.end())
125 return it->field(_p);
135 return this->Evaluate(_p);
150 if (this->pieces.empty())
156 for (
const Piece &piece : this->pieces)
158 if (!piece.region.Empty())
161 const ScalarT y = piece.field.Minimum(piece.region, p);
179 return this->Minimum(pMin);
189 ScalarField3T, ScalarT> &_field)
191 if (_field.pieces.empty())
193 return _out <<
"undefined";
195 for (
size_t i = 0; i < _field.pieces.size() - 1; ++i)
197 _out << _field.pieces[i].field <<
" if (x, y, z) in "
198 << _field.pieces[i].region <<
"; ";
200 return _out << _field.pieces.back().field
201 <<
" if (x, y, z) in "
202 << _field.pieces.back().region;
209 template<
typename ScalarField3T>
211 template<
typename ScalarField3T>
215 #endif // GZ_MATH_PIECEWISE_SCALAR_FIELD3_HH_