本文整理汇总了C++中BoundingBox::generatePointInside方法的典型用法代码示例。如果您正苦于以下问题:C++ BoundingBox::generatePointInside方法的具体用法?C++ BoundingBox::generatePointInside怎么用?C++ BoundingBox::generatePointInside使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BoundingBox
的用法示例。
在下文中一共展示了BoundingBox::generatePointInside方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: invalid_argument
/**
* Return a random point in a generic shape limited by a bounding box.
* @param object an object in which the point is generated
* @param rng a random number generator
* @param box a box restricting the point's volume
* @param maxAttempts number of attempts to find a suitable point
* @return a point or none if maxAttempts was exceeded
*/
boost::optional<Kernel::V3D> bounded(const IObject &object,
Kernel::PseudoRandomNumberGenerator &rng,
const BoundingBox &box,
size_t maxAttempts) {
boost::optional<Kernel::V3D> point{boost::none};
if (box.isNull()) {
throw std::invalid_argument(
"Invalid bounding box. Cannot generate random point.");
}
for (size_t attempts{0}; attempts < maxAttempts; ++attempts) {
const double r1 = rng.nextValue();
const double r2 = rng.nextValue();
const double r3 = rng.nextValue();
auto pt = box.generatePointInside(r1, r2, r3);
if (object.isValid(pt)) {
point = pt;
break;
}
};
return point;
}