本文整理汇总了C++中SbBox3f类的典型用法代码示例。如果您正苦于以下问题:C++ SbBox3f类的具体用法?C++ SbBox3f怎么用?C++ SbBox3f使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了SbBox3f类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: COIN_UNUSED_ARG
// Doc in parent
void
SoVRMLCone::computeBBox(SoAction * COIN_UNUSED_ARG(action),
SbBox3f & box,
SbVec3f & center)
{
float r = this->bottomRadius.getValue();
float h = this->height.getValue();
// Allow negative values.
if (h < 0.0f) h = -h;
if (r < 0.0f) r = -r;
float half_height = h * 0.5f;
// The SIDES are present, so just find the middle point and enclose
// everything.
if (this->side.getValue()) {
center.setValue(0.0f, 0.0f, 0.0f);
box.setBounds(SbVec3f(-r, -half_height, -r), SbVec3f(r, half_height, r));
}
// ..no SIDES, but we've still got the bottom (NB: OIV misses this case).
else if (this->bottom.getValue()) {
center.setValue(0.0f, -half_height, 0.0f);
box.setBounds(SbVec3f(-r, -half_height, -r), SbVec3f(r, -half_height, r));
}
// ..no parts present. My confidence is shot -- I feel very small.
else {
center.setValue(0.0f, 0.0f, 0.0f);
box.setBounds(SbVec3f(0.0f, 0.0f, 0.0f), SbVec3f(0.0f, 0.0f, 0.0f));
}
}
示例2: make_scene_graph
// This is a helper function for debugging purposes: it sets up an
// SoCoordinate3 + SoIndexedLineSet pair of nodes exposing the
// geometry of the SbBox3f input argument.
static void
make_scene_graph(const SbBox3f & box, SoCoordinate3 *& coord3, SoIndexedLineSet *& ils)
{
const SbVec3f & vmin = box.getMin();
const SbVec3f & vmax = box.getMax();
const SbVec3f corners[] = {
// back face
SbVec3f(vmin[0], vmin[1], vmin[2]),
SbVec3f(vmax[0], vmin[1], vmin[2]),
SbVec3f(vmax[0], vmax[1], vmin[2]),
SbVec3f(vmin[0], vmax[1], vmin[2]),
// front face
SbVec3f(vmin[0], vmin[1], vmax[2]),
SbVec3f(vmax[0], vmin[1], vmax[2]),
SbVec3f(vmax[0], vmax[1], vmax[2]),
SbVec3f(vmin[0], vmax[1], vmax[2])
};
const int32_t indices[] = {
0, 1, 2, 3, 0, -1, // back face
4, 5, 6, 7, 4, -1, // front face
0, 4, -1, 1, 5, -1, 2, 6, -1, 3, 7, -1 // "crossover" lines
};
coord3 = new SoCoordinate3;
coord3->point.setValues(0, sizeof(corners) / sizeof(corners[0]), corners);
ils = new SoIndexedLineSet;
ils->coordIndex.setValues(0, sizeof(indices) / sizeof(indices[0]), indices);
}
示例3:
// 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();
}
示例4:
void
SoCylinder::computeBBox(SoAction *, SbBox3f &box, SbVec3f ¢er)
//
////////////////////////////////////////////////////////////////////////
{
int curParts = (parts.isIgnored() ? ALL : parts.getValue());
if (curParts == 0) // No parts at all!
box.setBounds(0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
else {
float r, h;
SbVec3f min, max;
getSize(r, h);
if (HAS_PART(curParts, SIDES | TOP))
max.setValue( r, h, r);
else
max.setValue( r, -h, r);
if (HAS_PART(curParts, SIDES | BOTTOM))
min.setValue(-r, -h, -r);
else
min.setValue(-r, h, -r);
box.setBounds(min, max);
}
center.setValue(0.0, 0.0, 0.0);
}
示例5: computeBBox
/**
* Sets the bounding box of the mesh to \a box and its center to \a center.
*/
void SoPolygon::computeBBox(SoAction *action, SbBox3f &box, SbVec3f ¢er)
{
SoState* state = action->getState();
const SoCoordinateElement * coords = SoCoordinateElement::getInstance(state);
if (!coords) return;
const SbVec3f * points = coords->getArrayPtr3();
if (!points) return;
float maxX=-FLT_MAX, minX=FLT_MAX,
maxY=-FLT_MAX, minY=FLT_MAX,
maxZ=-FLT_MAX, minZ=FLT_MAX;
int32_t len = coords->getNum();
int32_t beg = startIndex.getValue();
int32_t cnt = numVertices.getValue();
int32_t end = beg + cnt;
if (end <= len) {
for (int32_t i=beg; i<end; i++) {
maxX = std::max<float>(maxX,points[i][0]);
minX = std::min<float>(minX,points[i][0]);
maxY = std::max<float>(maxY,points[i][1]);
minY = std::min<float>(minY,points[i][1]);
maxZ = std::max<float>(maxZ,points[i][2]);
minZ = std::min<float>(minZ,points[i][2]);
}
box.setBounds(minX,minY,minZ,maxX,maxY,maxZ);
center.setValue(0.5f*(minX+maxX),0.5f*(minY+maxY),0.5f*(minZ+maxZ));
}
else {
box.setBounds(SbVec3f(0,0,0), SbVec3f(0,0,0));
center.setValue(0.0f,0.0f,0.0f);
}
}
示例6: bboxAction
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;
}
示例7: expand_SbXfBox3f
// Expand SbXfBox3f in all directions with an epsilon value.
static SbXfBox3f
expand_SbXfBox3f(const SbXfBox3f & box, float epsilon)
{
assert(epsilon > 0.0f);
// FIXME: quality check the calculation for the epsilon-extended
// bbox. It needs to be correct _and_ not adding on too much
// fat. 20030331 mortene.
// This invokes the copy constructor (and not the SbXfBox3f(SbBox3f)
// constructor), so the transformation matrix is also copied.
SbXfBox3f extbox(box);
SbVec3f epsilonvec(epsilon, epsilon, epsilon);
// Move epsilon to object space.
box.getTransform().multDirMatrix(epsilonvec, epsilonvec);
const float localepsilon = epsilonvec.length(); // yes, it's a bit large...
epsilonvec = SbVec3f(localepsilon, localepsilon, localepsilon);
// Get superclass-pointer, so we can modify the box corners
// directly.
SbBox3f * extboxp = static_cast<SbBox3f *>(&extbox);
extboxp->getMin() -= epsilonvec;
extboxp->getMax() += epsilonvec;
return extbox;
}
示例8:
void
SbSphere::circumscribe(const SbBox3f &box)
//
//////////////////////////////////////////////////////////////////////////////
{
center = 0.5 * (box.getMin() + box.getMax());
radius = (box.getMax() - center).length();
}
示例9:
void
SoNurbsSurface::computeBBox(SoAction *action, SbBox3f &box, SbVec3f ¢er)
//
////////////////////////////////////////////////////////////////////////
{
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;
}
示例10: bbox
void IvDragger::_GetBounds(SoSeparator *subtree, AABB& ab)
{
SoGetBoundingBoxAction bbox(_viewer.lock()->GetViewer()->getViewportRegion());
bbox.apply(subtree);
SbBox3f box = bbox.getBoundingBox();
RaveVector<float> vmin, vmax;
box.getBounds(vmin.x,vmin.y,vmin.z,vmax.x,vmax.y,vmax.z);
ab.pos = 0.5*(vmin+vmax);
ab.extents = 0.5*(vmax-vmin);
}
示例11: 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 );
}
}
示例12: bbox
void SoVtkAssembly::getBoundingBox(SoGetBoundingBoxAction *action)
{
SbBox3f bbox;
SbVec3f center;
if (mAssembly)
{
const double *bounds = mAssembly->GetBounds();
SbBox3f bbox(bounds[0], bounds[2], bounds[4], bounds[1], bounds[3], bounds[5]);
action->extendBy(bbox);
action->setCenter(bbox.getCenter(), FALSE);
}
}
示例13:
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();
}
示例14: fabs
// set scale
void
InvAnnoManager::setSize(const SbBox3f &bb)
{
float dx = fabs(bb.getMin()[0] - bb.getMax()[0]);
float dy = fabs(bb.getMin()[1] - bb.getMax()[1]);
float dz = fabs(bb.getMin()[2] - bb.getMax()[2]);
float hsc = max(dx, dy);
hsc = max(hsc, dz);
hsc *= 0.2;
scale_ = hsc;
}
示例15: 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 ¢er)
{
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();
}