当前位置: 首页>>代码示例>>C++>>正文


C++ BoundingBox::center方法代码示例

本文整理汇总了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);
}
开发者ID:starseeker,项目名称:VegaFEM-cmake,代码行数:31,代码来源:triangle.cpp

示例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);
	}
}
开发者ID:spinos,项目名称:aphid,代码行数:34,代码来源:BlockBccMeshBuilder.cpp

示例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];
}
开发者ID:anlambert,项目名称:tulipjs,代码行数:26,代码来源:LabelsRenderer.cpp

示例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();
        }
    }
}
开发者ID:joevandyk,项目名称:osg,代码行数:28,代码来源:BoundingSphere.cpp

示例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>(&gtr, 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(&gtr);
	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() );
						
}
开发者ID:spinos,项目名称:aphid,代码行数:31,代码来源:ExampVox.cpp

示例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);
  }

}
开发者ID:anlambert,项目名称:tulipjs,代码行数:17,代码来源:LabelsRenderer.cpp

示例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;
}
开发者ID:AlexBobkov,项目名称:OpenSceneGraph,代码行数:58,代码来源:Group.cpp

示例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;
}
开发者ID:spinos,项目名称:aphid,代码行数:11,代码来源:BaseMesh.cpp

示例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();
                });
}
开发者ID:Euphe,项目名称:utymap,代码行数:11,代码来源:ElementStore.cpp

示例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));
}
开发者ID:orikuma,项目名称:choreonoid,代码行数:52,代码来源:EditableSceneBody.cpp

示例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);
}
开发者ID:spinos,项目名称:aphid,代码行数:13,代码来源:ViewCull.cpp

示例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;
}
开发者ID:magnesj,项目名称:CustomVisualizationCore,代码行数:53,代码来源:snipLabels.cpp

示例13: insertToGroup

void GridClustering::insertToGroup(const BoundingBox & box, const unsigned & idx)
{
	const Vector3F center = box.center();
	
	GroupCell * c = insertChild((const float *)&center);
		
	if(!c) {
		std::cout<<"\n error cast to GroupCell";
		return;
	}
	
	c->insert(idx);
	c->m_box.expandBy(box);
}
开发者ID:spinos,项目名称:aphid,代码行数:14,代码来源:GridClustering.cpp

示例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";
    }
  }
}
开发者ID:joaocomba,项目名称:depth-complexity,代码行数:45,代码来源:dc_3d.cpp

示例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();
        }
    }
}
开发者ID:joevandyk,项目名称:osg,代码行数:18,代码来源:BoundingSphere.cpp


注:本文中的BoundingBox::center方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。