本文整理汇总了C++中BoundingBox::center方法的典型用法代码示例。如果您正苦于以下问题:C++ BoundingBox::center方法的具体用法?C++ BoundingBox::center怎么用?C++ BoundingBox::center使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BoundingBox
的用法示例。
在下文中一共展示了BoundingBox::center方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: doesIntersectBox
bool TriangleBasic::doesIntersectBox(BoundingBox & bbox)
{
// prepare the data and call the "triBoxOverlap" worker routine
double boxcenter[3];
double boxhalfsize[3];
double triverts[3][3];
Vec3d center_ = bbox.center();
Vec3d halfSides_ = bbox.halfSides();
boxcenter[0] = center_[0];
boxcenter[1] = center_[1];
boxcenter[2] = center_[2];
boxhalfsize[0] = halfSides_[0];
boxhalfsize[1] = halfSides_[1];
boxhalfsize[2] = halfSides_[2];
triverts[0][0] = first_[0];
triverts[0][1] = first_[1];
triverts[0][2] = first_[2];
triverts[1][0] = second_[0];
triverts[1][1] = second_[1];
triverts[1][2] = second_[2];
triverts[2][0] = third_[0];
triverts[2][1] = third_[1];
triverts[2][2] = third_[2];
return triBoxOverlap(boxcenter,boxhalfsize,triverts);
}
示例2: addAnchorByThreshold
void BlockBccMeshBuilder::addAnchorByThreshold(ATetrahedronMesh * mesh,
unsigned istripe,
const Matrix33F & invspace,
const Vector3F & center,
float threshold,
bool isLower,
unsigned tri)
{
unsigned tetMax = mesh->numTetrahedrons() * 4;
if(istripe < indexDrifts.size() -1)
tetMax = indexDrifts[istripe + 1];
BoundingBox box;
Vector3F q;
unsigned i = indexDrifts[istripe];
unsigned j;
for(;i<tetMax;i+=4) {
unsigned * tet = mesh->tetrahedronIndices(i/4);
box.reset();
for(j=0; j< 4; j++)
box.expandBy(mesh->points()[tet[j]], 1e-3f);
q = invspace.transform(box.center() - center);
if(isLower) {
if(q.x > threshold) continue;
}
else {
if(q.x < threshold) continue;
}
for(j=0; j< 4; j++)
mesh->anchors()[tet[j]] = (1<<24 | tri);
}
}
示例3: adjustTextBoundingBox
static void adjustTextBoundingBox(BoundingBox &textBB, const Camera &camera, float minSize, float maxSize, unsigned int nbLines) {
Vec4i viewport = camera.getViewport();
Vec2f textBBMinScr = computeScreenPos(camera.transformMatrix(), viewport, textBB[0]);
Vec2f textBBMaxScr = computeScreenPos(camera.transformMatrix(), viewport, textBB[1]);
float screenH = (textBBMaxScr[1] - textBBMinScr[1]) / nbLines;
Vec3f center = textBB.center();
Vec3f scale = textBB[1] - textBB[0];
float ratio = textBB.width() / textBB.height();
float scaleX = textBB.width();
if (screenH < minSize) {
scaleX *= (minSize/screenH);
}
if (screenH > maxSize) {
scaleX *= (maxSize/screenH);
}
float scaleY = scaleX/ratio;
textBB[0][0] = ((textBB[0][0] - center[0]) / scale[0]) * scaleX + center[0];
textBB[0][1] = ((textBB[0][1] - center[1]) / scale[1]) * scaleY + center[1];
textBB[1][0] = ((textBB[1][0] - center[0]) / scale[0]) * scaleX + center[0];
textBB[1][1] = ((textBB[1][1] - center[1]) / scale[1]) * scaleY + center[1];
}
示例4: expandBy
void BoundingSphere::expandBy(const BoundingBox& bb)
{
if (bb.valid())
{
if (valid())
{
BoundingBox newbb(bb);
for(unsigned int c=0;c<8;++c)
{
Vec3 v = bb.corner(c)-_center; // get the direction vector from corner
v.normalize(); // normalise it.
v *= -_radius; // move the vector in the opposite direction distance radius.
v += _center; // move to absolute position.
newbb.expandBy(v); // add it into the new bounding box.
}
_center = newbb.center();
_radius = newbb.radius();
}
else
{
_center = bb.center();
_radius = bb.radius();
}
}
}
示例5:
void ExampVox::voxelize2(sdb::VectorArray<cvx::Triangle> * tri,
const BoundingBox & bbox)
{
TreeProperty::BuildProfile bf;
bf._maxLeafPrims = 64;
KdEngine engine;
KdNTree<cvx::Triangle, KdNode4 > gtr;
engine.buildTree<cvx::Triangle, KdNode4, 4>(>r, tri, bbox, &bf);
BoundingBox tb = gtr.getBBox();
const float gz = tb.getLongestDistance() * 1.23f;
const Vector3F cent = tb.center();
tb.setMin(cent.x - gz, cent.y - gz, cent.z - gz );
tb.setMax(cent.x + gz, cent.y + gz, cent.z + gz );
ttg::FieldTriangulation msh;
msh.fillBox(tb, gz);
BDistanceFunction distFunc;
distFunc.addTree(>r);
distFunc.setDomainDistanceRange(gz * GDT_FAC_ONEOVER8 );
msh.frontAdaptiveBuild<BDistanceFunction>(&distFunc, 3, 4, .3f);
msh.triangulateFront();
std::cout.flush();
buildTriangleDrawBuf(msh.numFrontTriangles(), msh.triangleIndices(),
msh.numVertices(), msh.triangleVertexP(), msh.triangleVertexN() );
}
示例6: renderText
static void renderText(NVGcontext *vg, const std::string &text, const tlp::BoundingBox &renderingBox, const tlp::Color &textColor) {
vector<string> textVector = splitStringToLines(text);
float fontSize = renderingBox.height()/textVector.size();
nvgFontSize(vg, fontSize);
nvgTextAlign(vg,NVG_ALIGN_CENTER|NVG_ALIGN_MIDDLE);
nvgFillColor(vg, nvgRGBA(textColor[0],textColor[1],textColor[2],textColor[3]));
for (size_t i = 0 ; i < textVector.size() ; ++i) {
BoundingBox rb;
rb[0] = Vec3f(renderingBox[0][0], renderingBox[0][1] + i * fontSize);
rb[1] = Vec3f(renderingBox[1][0], renderingBox[0][1] + (i+1) * fontSize);
nvgText(vg, rb.center()[0], rb.center()[1], textVector[i].c_str(), NULL);
}
}
示例7: computeBound
BoundingSphere Group::computeBound() const
{
BoundingSphere bsphere;
if (_children.empty())
{
return bsphere;
}
// note, special handling of the case when a child is an Transform,
// such that only Transforms which are relative to their parents coordinates frame (i.e this group)
// are handled, Transform relative to and absolute reference frame are ignored.
BoundingBox bb;
bb.init();
NodeList::const_iterator itr;
for(itr=_children.begin();
itr!=_children.end();
++itr)
{
osg::Node* child = itr->get();
const osg::Transform* transform = child->asTransform();
if (!transform || transform->getReferenceFrame()==osg::Transform::RELATIVE_RF)
{
osg::Drawable* drawable = child->asDrawable();
if (drawable)
{
bb.expandBy(drawable->getBoundingBox());
}
else
{
const osg::BoundingSphere& bs = child->getBound();
bb.expandBy(bs);
}
}
}
if (!bb.valid())
{
return bsphere;
}
bsphere._center = bb.center();
bsphere._radius = 0.0f;
for(itr=_children.begin();
itr!=_children.end();
++itr)
{
osg::Node* child = itr->get();
const osg::Transform* transform = child->asTransform();
if (!transform || transform->getReferenceFrame()==osg::Transform::RELATIVE_RF)
{
const BoundingSphere& bs = child->getBound();
bsphere.expandRadiusBy(bs);
}
}
return bsphere;
}
示例8: putIntoObjectSpace
void BaseMesh::putIntoObjectSpace()
{
BoundingBox b = BaseMesh::calculateBBox();
setBBox(b);
const Vector3F c = b.center();
const unsigned nv = getNumVertices();
for(unsigned i = 0; i < nv; i++)
_vertices[i] -= c;
}
示例9: store
bool ElementStore::store(const Element& element, const QuadKey& quadKey, const StyleProvider& styleProvider)
{
const BoundingBox expectedQuadKeyBbox = utymap::utils::GeoUtils::quadKeyToBoundingBox(quadKey);
return store(element,
LodRange(quadKey.levelOfDetail, quadKey.levelOfDetail),
styleProvider,
[&](const BoundingBox& elementBoundingBox, const BoundingBox& quadKeyBbox) {
return elementBoundingBox.intersects(expectedQuadKeyBbox) &&
expectedQuadKeyBbox.center() == quadKeyBbox.center();
});
}
示例10: self
EditableSceneBodyImpl::EditableSceneBodyImpl(EditableSceneBody* self, BodyItemPtr& bodyItem)
: self(self),
bodyItem(bodyItem),
kinematicsBar(KinematicsBar::instance()),
modified(SgUpdate::MODIFIED)
{
pointedSceneLink = 0;
outlinedLink = 0;
targetLink = 0;
positionDragger = new PositionDragger;
positionDragger->setDraggerAlwaysShown(true);
positionDragger->sigDragStarted().connect(boost::bind(&EditableSceneBodyImpl::onDraggerIKstarted, this));
positionDragger->sigPositionDragged().connect(boost::bind(&EditableSceneBodyImpl::onDraggerIKdragged, this));
dragMode = DRAG_NONE;
isDragging = false;
isEditMode = false;
markerGroup = new SgGroup;
markerGroup->setName("Marker");
self->addChild(markerGroup);
double radius = 0;
const int n = self->numSceneLinks();
for(int i=0; i < n; ++i){
SceneLink* sLink = self->sceneLink(i);
BoundingBox bb = sLink->boundingBox();
double radius0 = (bb.max() - bb.center()).norm();
if(radius0 > radius){
radius = radius0;
}
}
cmMarker = new CrossMarker(0.25, Vector3f(0.0f, 1.0f, 0.0f), 2.0);
cmMarker->setName("centerOfMass");
cmMarker->setSize(radius);
isCmVisible = false;
LeggedBodyHelperPtr legged = getLeggedBodyHelper(self->body());
if(legged->isValid() && legged->numFeet() > 0){
Link* footLink = legged->footLink(0);
const double r = calcLinkMarkerRadius(self->sceneLink(footLink->index()));
zmpMarker = new SphereMarker(r, Vector3f(0.0f, 1.0f, 0.0f), 0.3);
zmpMarker->setName("ZMP");
zmpMarker->addChild(new CrossMarker(r * 2.5, Vector3f(0.0f, 1.0f, 0.0f), 2.0f));
} else {
zmpMarker = new SphereMarker(0.1, Vector3f(0.0f, 1.0f, 0.0f), 0.3);
}
isZmpVisible = false;
self->sigGraphConnection().connect(boost::bind(&EditableSceneBodyImpl::onSceneGraphConnection, this, _1));
}
示例11: frameAll
void BaseView::frameAll(const BoundingBox & b)
{
Vector3F eye = b.center();
eye.z = b.getMax(2) + b.distance(0) / hfov() * .55f + 120.f;
setEyePosition(eye);
Matrix44F m;
m.setTranslation(eye);
*cameraSpaceR() = m;
m.inverse();
*cameraInvSpaceR() = m;
setFrustum(1.33f, 1.f, 26.2f, -1.f, -1000.f);
}
示例12: onInitialize
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool Labels::onInitialize()
{
// Add 3D geometry rendering
// ------------------------------------------
ref<Part> cubePart = createCubePart();
ref<ModelBasicList> myModel = new ModelBasicList;
cubePart->setPriority(1);
myModel->addPart(cubePart.p());
addTextParts(myModel.p());
myModel->updateBoundingBoxesRecursive();
m_renderSequence->rendering(0)->scene()->addModel(myModel.p());
BoundingBox bb = m_renderSequence->boundingBox();
if (bb.isValid())
{
m_camera->fitView(bb, -Vec3d::Z_AXIS, Vec3d::X_AXIS);
m_trackball->setRotationPoint(bb.center());
}
ref<OverlayAxisCross> axisCross = new OverlayAxisCross(m_camera.p(), new FixedAtlasFont(FixedAtlasFont::STANDARD));
m_renderSequence->firstRendering()->addOverlayItem(axisCross.p(), OverlayItem::BOTTOM_LEFT, OverlayItem::HORIZONTAL);
ref<OverlayColorLegend> legend = new OverlayColorLegend(new FixedAtlasFont(FixedAtlasFont::STANDARD));
legend->setTitle("Legend title\nLegend unit");
legend->setColor(Color3::DARK_RED);
m_renderSequence->firstRendering()->addOverlayItem(legend.p(), OverlayItem::TOP_LEFT, OverlayItem::VERTICAL);
// Set up font
// ------------------------------------------
CVF_ASSERT(m_font.isNull());
m_fontSize = CVF_SNIP_Labels_MIN_FONT_SIZE * 4;
// Set up properties
// ------------------------------------------
m_propFontName = new PropertyEnum("Font name");
m_propFontName->addItem(CVF_SNIP_Labels_FONT_B, CVF_SNIP_Labels_FONT_B);
m_propFontName->addItem(CVF_SNIP_Labels_FONT_C, CVF_SNIP_Labels_FONT_C);
m_propFontName->setCurrentIdent(CVF_SNIP_Labels_FONT_B);
m_propertyPublisher->publishProperty(m_propFontName.p());
updateFont(m_propFontName->currentIdent());
m_propFontSize = new PropertyInt("Font size", m_fontSize);
m_propFontSize->setRange(1, 36);
m_propertyPublisher->publishProperty(m_propFontSize.p());
updateFont(m_fontSize);
return true;
}
示例13: insertToGroup
void GridClustering::insertToGroup(const BoundingBox & box, const unsigned & idx)
{
const Vector3F center = box.center();
GroupCell * c = insertChild((const float *)¢er);
if(!c) {
std::cout<<"\n error cast to GroupCell";
return;
}
c->insert(idx);
c->m_box.expandBy(box);
}
示例14: assert
void DepthComplexity3D::writeRaysSpherical(std::ostream& out, int k) {
assert(_computeGoodRays);
long long unsigned int total = 0;
for(int i = 0 ; i <= k ; ++i) {
const std::vector<Segment> & _rays = goodRays(maximum()-i);
total += _rays.size();
}
out << total << "\n";
/* Simple spherical coordinates
for(int i = 0 ; i <= k ; ++i) {
const std::vector<Segment> & _rays = goodRays(maximum()-i);
std::vector<Segment>::const_iterator ite = _rays.begin();
std::vector<Segment>::const_iterator end = _rays.end();
for (; ite != end; ++ite) {
double a, b, c, d;
double x1 = ite->a.x, x2 = ite->b.x, y1 = ite->a.y, y2 = ite->b.y, z1 = ite->a.z, z2 = ite->b.z;
a = atan2(y1, x1);
b = atan2(z1, sqrt(x1*x1 + y1*y1));
c = atan2(y2, x2);
d = atan2(z2, sqrt(x2*x2 + y2*y2));
out << a << " " << b << " " << c << " " << d << " " << maximum()-i << "\n";
}
}
*/
BoundingBox aabb = _mesh->aabb;
Sphere sph;
sph.center = aabb.center();
sph.radius = aabb.extents().length()/2;
// Coordinates of intersection with bounding sphere
for(int i = 0 ; i <= k ; ++i) {
const std::vector<Segment> & _rays = goodRays(maximum()-i);
std::vector<Segment>::const_iterator ite = _rays.begin();
std::vector<Segment>::const_iterator end = _rays.end();
for (; ite != end; ++ite) {
vec3d f, s;
assert(segmentSphereIntersection3D(*ite,sph,f,s));
f = cartesianToSpherical(f);
s = cartesianToSpherical(s);
out << f.y << " " << f.z << " " << s.y << " " << s.z << " " << maximum()-i << "\n";
}
}
}
示例15: expandRadiusBy
void BoundingSphere::expandRadiusBy(const BoundingBox& bb)
{
if (bb.valid())
{
if (valid())
{
for(unsigned int c=0;c<8;++c)
{
expandRadiusBy(bb.corner(c));
}
}
else
{
_center = bb.center();
_radius = bb.radius();
}
}
}