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


C++ SbBox3f::extendBy方法代码示例

本文整理汇总了C++中SbBox3f::extendBy方法的典型用法代码示例。如果您正苦于以下问题:C++ SbBox3f::extendBy方法的具体用法?C++ SbBox3f::extendBy怎么用?C++ SbBox3f::extendBy使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SbBox3f的用法示例。


在下文中一共展示了SbBox3f::extendBy方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1:

void
SoNurbsSurface::computeBBox(SoAction *action, SbBox3f &box, SbVec3f &center)
//
////////////////////////////////////////////////////////////////////////
{
    const SoCoordinateElement   *ce =
            SoCoordinateElement::getInstance(action->getState());
    int32_t			nCoords, numSurfCoords;
    int				j, curCoord;
    SbVec3f			tmpCoord;

    //
    // Loop through coordinates, keeping max bounding box and sum of coords
    // If the coordinates are rational, divide the first three values by
    // the fourth value before extending the bounding box.
    //
    numSurfCoords = numUControlPoints.getValue() *
                    numVControlPoints.getValue();
    nCoords = ce->getNum();

    // Check for a degenerate surface
    if ((numSurfCoords == 0) || (nCoords == 0))
        return;

    curCoord = 0;
    center.setValue(0.0, 0.0, 0.0);
    if (ce->is3D()) {
        for (j = 0; j < numSurfCoords; j++) {
            //
            // Wrap around if necessary
            //
            if (curCoord >= nCoords)
	        curCoord = 0;
            const SbVec3f &coord = ce->get3(curCoord);
            box.extendBy(coord);
            center += coord;
            curCoord++;
        }
    }
    else {
        for (j = 0; j < numSurfCoords; j++) {
            //
            // Wrap around if necessary
            //
            if (curCoord >= nCoords)
	        curCoord = 0;
            const SbVec4f &coord = ce->get4(curCoord);
            coord.getReal (tmpCoord);
            box.extendBy (tmpCoord);
            center += tmpCoord;
            curCoord++;
        }
    }

    center /= (float) numSurfCoords;
}
开发者ID:OpenXIP,项目名称:xip-libraries,代码行数:56,代码来源:SoNurbsSurface.cpp

示例2: computeBBox

void ShapeBezierSurface::computeBBox(SoAction*, SbBox3f& box, SbVec3f& /*center*/ )
{
	box.makeEmpty();
	for (int i = 0; i < m_surfacesVector.size(); i++)
	{
		BBox pBox =  m_surfacesVector[i]->GetComputeBBox();
		SbVec3f pMin( pBox.pMin[0], pBox.pMin[1], pBox.pMin[2] );
		box.extendBy( pMin );
		SbVec3f pMax( pBox.pMax[0], pBox.pMax[1], pBox.pMax[2] );
		box.extendBy( pMax );
	}
}
开发者ID:Lillian003,项目名称:tonatiuh,代码行数:12,代码来源:ShapeBezierSurface.cpp

示例3: getRelevantBoundBox

SbBox3f ViewProviderDatum::getRelevantBoundBox () const {
    std::vector<App::DocumentObject *> objs;

    // Probe body first
    PartDesign::Body* body = PartDesign::Body::findBodyOf ( this->getObject() );
    if (body) {
        objs = body->getFullModel ();
    } else {
        // Probe if we belongs to some group
        App::DocumentObjectGroup* group =  App::DocumentObjectGroup::getGroupOfObject ( this->getObject () );

        if(group) {
            objs = group->getObjects ();
        } else {
            // Fallback to whole document
            objs = this->getObject ()->getDocument ()->getObjects ();
        }
    }

    Gui::View3DInventorViewer* viewer = static_cast<Gui::View3DInventor*>(this->getActiveView())->getViewer();
    SoGetBoundingBoxAction bboxAction(viewer->getSoRenderManager()->getViewportRegion());
    SbBox3f bbox = getRelevantBoundBox (bboxAction, objs);

    if ( bbox.getVolume () < Precision::Confusion() ) {
        bbox.extendBy ( defaultBoundBox () );
    }

    return bbox;
}
开发者ID:sanguinariojoe,项目名称:FreeCAD,代码行数:29,代码来源:ViewProviderDatum.cpp

示例4:

// doc in super
void
SoOrthoSlice::computeBBox(SoAction * action, SbBox3f & box, SbVec3f & center)
{
  SoState * state = action->getState();
  if (!PRIVATE(this)->confirmValidInContext(state)) { return; }

  const CvrVoxelBlockElement * vbelem = CvrVoxelBlockElement::getInstance(state);
  if (vbelem == NULL) return;

  SbBox3f vdbox = vbelem->getUnitDimensionsBox();
  SbVec3f bmin, bmax;
  vdbox.getBounds(bmin, bmax);

  const SbVec3s & dimensions = vbelem->getVoxelCubeDimensions();

  const int axisidx = (int)axis.getValue();
  const int slice = this->sliceNumber.getValue();
  const float depth = (float)fabs(bmax[axisidx] - bmin[axisidx]);

  bmin[axisidx] = bmax[axisidx] =
    (bmin[axisidx] + (depth / dimensions[axisidx]) * slice);

  vdbox.setBounds(bmin, bmax);

  box.extendBy(vdbox);
  center = vdbox.getCenter();
}
开发者ID:Alexpux,项目名称:SIMVoleon,代码行数:28,代码来源:OrthoSlice.cpp

示例5: computeBBox

void SoWidgetShape::computeBBox(SoAction *action, SbBox3f &box, SbVec3f &center)
{
    // ignore if node is empty
    if (this->image.isNull()) return;

    SbVec3f v0, v1, v2, v3;
    // this will cause a cache dependency on the view volume,
    // model matrix and viewport.
    this->getQuad(action->getState(), v0, v1, v2, v3);

    box.makeEmpty();
    box.extendBy(v0);
    box.extendBy(v1);
    box.extendBy(v2);
    box.extendBy(v3);
    center = box.getCenter();
}
开发者ID:greyltc,项目名称:FreeCAD,代码行数:17,代码来源:Workbench.cpp

示例6:

void 
SoXipMarkerSet::computeBBox( SoAction* action, SbBox3f& box, SbVec3f& center )
{
	const SoCoordinateElement* ce = (const SoCoordinateElement *) SoCoordinateElement::getInstance( action->getState() );

	if( ce )
	{
		for( int i = 0; i < ce->getNum(); ++ i )
			box.extendBy( ce->get3(i) );
	}

	center = box.getCenter();
}
开发者ID:OpenXIP,项目名称:xip-libraries,代码行数:13,代码来源:SoXipMarkerSet.cpp

示例7: computeBBox

/**
 * Sets the bounding box of the probe to \a box and its center to \a center.
 */
void SoRegPoint::computeBBox(SoAction *action, SbBox3f &box, SbVec3f &center)
{
    root->doAction(action);
    if (action->getTypeId().isDerivedFrom(SoGetBoundingBoxAction::getClassTypeId()))
        static_cast<SoGetBoundingBoxAction*>(action)->resetCenter();

    SbVec3f p1 = base.getValue();
    SbVec3f p2 = p1 + normal.getValue() * length.getValue();

    box.extendBy(p1);
    box.extendBy(p2);

    center = box.getCenter();
}
开发者ID:AjinkyaDahale,项目名称:FreeCAD,代码行数:17,代码来源:SoAxisCrossKit.cpp

示例8:

SbBool
SoXipPolygon::isConsistent() const
{
	// check if the contour size is greater than the minimum size.
	const SbVec3f* pointPtr = point.getValues(0);

	SbBox3f bbox;
	for( int i = 0; i < point.getNum(); ++ i )
		bbox.extendBy( pointPtr[i] );

	SbVec3f bbSize;
	bbox.getSize(bbSize[0], bbSize[1], bbSize[2]);

	float screenScale = mViewVolume.getHeight() / mViewport.getViewportSizePixels()[1];
	float bbLengthPix = bbSize.length() / screenScale;

	return ( bbLengthPix >= (2 * CLOSING_MIN_PIXEL_DISTANCE) );
}
开发者ID:OpenXIP,项目名称:xip-libraries,代码行数:18,代码来源:SoXipPolygon.cpp

示例9:

// doc from parent
void
SmTextureText2::computeBBox(SoAction * action, SbBox3f & box, SbVec3f & center)
{
  SoState * state = action->getState();

  // never cull this node. We do quick culling in the render method
  SoCacheElement::invalidate(state);

  // this boundingbox will _not_ be 100% correct. We just supply an
  // estimate to avoid using lots of processing for calculating the
  // boundingbox.  FIXME: make it configurable if the bbox should be
  // accurate or not
  const SbVec3f * positions;
  const int numpositions = this->getPositions(state, positions);
  const SbVec3f & offset = this->offset.getValue();

  for (int i = 0; i < numpositions; i++) {
    box.extendBy(positions[i] + offset);
  }
  center = box.getCenter();
}
开发者ID:Alexpux,项目名称:SmallChange,代码行数:22,代码来源:SmTextureText2.cpp

示例10: updateOriginDatumSize

void ViewProviderBody::updateOriginDatumSize () {
    PartDesign::Body *body = static_cast<PartDesign::Body *> ( getObject() );
    
    // Use different bounding boxes for datums and for origins:
    Gui::Document* gdoc = Gui::Application::Instance->getDocument(getObject()->getDocument());
    if(!gdoc) 
        return;
    
    Gui::MDIView* view = gdoc->getViewOfViewProvider(this);
    if(!view)
        return;
    
    Gui::View3DInventorViewer* viewer = static_cast<Gui::View3DInventor*>(view)->getViewer();
    SoGetBoundingBoxAction bboxAction(viewer->getSoRenderManager()->getViewportRegion());

    const auto & model = body->getFullModel ();

    // BBox for Datums is calculated from all visible objects but treating datums as their basepoints only
    SbBox3f bboxDatums = ViewProviderDatum::getRelevantBoundBox ( bboxAction, model );
    // BBox for origin should take into account datums size also
    SbBox3f bboxOrigins = bboxDatums;

    for(App::DocumentObject* obj : model) {
        if ( obj->isDerivedFrom ( Part::Datum::getClassTypeId () ) ) {
            ViewProvider *vp = Gui::Application::Instance->getViewProvider(obj);
            if (!vp) { continue; }

            ViewProviderDatum *vpDatum = static_cast <ViewProviderDatum *> (vp) ;

            vpDatum->setExtents ( bboxDatums );

            bboxAction.apply ( vp->getRoot () );
            bboxOrigins.extendBy ( bboxAction.getBoundingBox () );
        }
    }

    // get the bounding box values
    SbVec3f max = bboxOrigins.getMax();
    SbVec3f min = bboxOrigins.getMin();

    // obtain an Origin and it's ViewProvider
    App::Origin* origin = 0;
    Gui::ViewProviderOrigin* vpOrigin = 0;
    try {
        origin = body->getOrigin ();
        assert (origin);

        Gui::ViewProvider *vp = Gui::Application::Instance->getViewProvider(origin);
        if (!vp) {
            throw Base::Exception ("No view provider linked to the Origin");
        }
        assert ( vp->isDerivedFrom ( Gui::ViewProviderOrigin::getClassTypeId () ) );
        vpOrigin = static_cast <Gui::ViewProviderOrigin *> ( vp );
    } catch (const Base::Exception &ex) {
        Base::Console().Error ("%s\n", ex.what() );
        return;
    }

    // calculate the desired origin size
    Base::Vector3d size;

    for (uint_fast8_t i=0; i<3; i++) {
        size[i] = std::max ( fabs ( max[i] ), fabs ( min[i] ) );
        if (size[i] < Precision::Confusion() ) {
            size[i] = Gui::ViewProviderOrigin::defaultSize();
        }
    }

    vpOrigin->Size.setValue ( size*1.2 );
}
开发者ID:3DPrinterGuy,项目名称:FreeCAD,代码行数:70,代码来源:ViewProviderBody.cpp


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