void BoundingBox::expandBy(const BoundingBox& bbox) { if(!bbox.empty()){ if(bbox.min().x() < min_.x()){ min_.x() = bbox.min().x(); } if(bbox.max().x() > max_.x()){ max_.x() = bbox.max().x(); } if(bbox.min().y() < min_.y()){ min_.y() = bbox.min().y(); } if(bbox.max().y() > max_.y()){ max_.y() = bbox.max().y(); } if(bbox.min().z() < min_.z()){ min_.z() = bbox.min().z(); } if(bbox.max().z() > max_.z()){ max_.z() = bbox.max().z(); } if(empty_){ empty_ = (min_.x() >= max_.x()) && (min_.y() >= max_.y()) && (min_.z() >= max_.z()); } } }
/** Test if @a box intersects this bounding box. */ bool intersects(const BoundingBox& box) const { if (empty() || box.empty()) return false; for (unsigned i = 0; i != DIM; ++i) if (box.min_[i] > max_[i] || box.max_[i] < min_[i]) return false; return true; }
/** Helper method to determine if this Iterator is valid. */ bool is_valid() const { if (s_ == nullptr || bb_.empty()) return false; if (code_ >= s_->mc_.code(bb_.max())+1) return false; if (loc_ >= s_->c2t_[code_].size()) return false; return bb_.contains(s_->t2p_(s_->c2t_[code_][loc_])); }
void PositionDragger::adjustSize(const BoundingBox& bb) { if(!bb.empty()){ Vector3 s = bb.size() / 2.0; std::sort(s.data(), s.data() + 3); double a = Vector2(s[0], s[1]).norm() * 1.1; double r = std::max(a, s[2] * 1.2); setRadius(r); } }
/** Helper method to advance this Iterator until it reaches a valid * position or end(). */ void fix() { assert(s_ != nullptr && !bb_.empty()); if (code_ >= s_->mc_.code(bb_.max())+1) { // Make equal to end() and return. code_ = s_->mc_.code(bb_.max())+1; loc_ = 0; return; } if (loc_ >= s_->c2t_[code_].size() || !bb_.contains(s_->t2p_(s_->c2t_[code_][loc_]))) { operator++(); } }
void MeshShapeItemImpl::attachPositionDragger() { positionDragger = new ModelEditDragger; positionDragger->sigDragStarted().connect(boost::bind(&MeshShapeItemImpl::onDraggerStarted, this)); positionDragger->sigPositionDragged().connect(boost::bind(&MeshShapeItemImpl::onDraggerDragged, this)); BoundingBox bb = sceneLink->untransformedBoundingBox(); if (bb.empty()) { positionDragger->setRadius(0.1); } else { positionDragger->adjustSize(sceneLink->untransformedBoundingBox()); } sceneLink->addChild(positionDragger); sceneLink->notifyUpdate(); self->notifyUpdate(); }
BoundingBoxf::BoundingBoxf(const BoundingBox& org) { min_ = org.min().cast<Vector3f::Scalar>(); max_ = org.max().cast<Vector3f::Scalar>(); empty_ = org.empty(); }
/** Test if @a box intersects this bounding box. */ bool intersects(const BoundingBox& box) const { return !empty() && !box.empty() && box.min_.x <= max_.x && box.max_.x >= min_.x && box.min_.y <= max_.y && box.max_.y >= min_.y && box.min_.z <= max_.z && box.max_.z >= min_.z; }
/** Test if @a box is entirely within this bounding box. * * Returns false if @a box.empty(). */ bool contains(const BoundingBox& box) const { return !box.empty() && contains(box.min()) && contains(box.max()); }
/** Method to return an iterator pointing to "one past" * the last item in a given BoundingBox. */ iterator end(const BoundingBox& bb) const { assert(!bb.empty()); return Iterator(this, bb, mc_.code(bb.max())+1, 0); }
/** Method to return an iterator pointing to the first item * in a given BoundingBox. */ iterator begin(const BoundingBox& bb) const { assert(!bb.empty()); return Iterator(this, bb, mc_.code(bb.min()), 0); }