本文整理汇总了C++中SbBox3f::setBounds方法的典型用法代码示例。如果您正苦于以下问题:C++ SbBox3f::setBounds方法的具体用法?C++ SbBox3f::setBounds怎么用?C++ SbBox3f::setBounds使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SbBox3f
的用法示例。
在下文中一共展示了SbBox3f::setBounds方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
// 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:
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);
}
示例3: 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);
}
}
示例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();
}
示例5: computeBBox
void ShapeParabolicRectangle::computeBBox( SoAction*, SbBox3f& box, SbVec3f& /*center*/ )
{
BBox bBox = GetBBox();
// These points define the min and max extents of the box.
SbVec3f min, max;
min.setValue( bBox.pMin.x, bBox.pMin.y, bBox.pMin.z );
max.setValue( bBox.pMax.x, bBox.pMax.y, bBox.pMax.z );;
// Set the box to bound the two extreme points.
box.setBounds(min, max);
}
示例6: if
// Doc in parent
void
SoVRMLCylinder::computeBBox(SoAction * COIN_UNUSED_ARG(action),
SbBox3f & box,
SbVec3f & center)
{
float r = this->radius.getValue();
float h = this->height.getValue();
// Allow negative values.
if (r < 0.0f) r = -r;
if (h < 0.0f) h = -h;
// Either the SIDES are present, or we've at least got both the TOP
// and BOTTOM caps -- so just find the middle point and enclose
// everything.
if (this->side.getValue() ||
(this->bottom.getValue() &&
this->top.getValue())) {
center.setValue(0.0f, 0.0f, 0.0f);
box.setBounds(SbVec3f(-r, -h/2.0f, -r), SbVec3f(r, h/2.0f, r));
}
// ..not a "full" cylinder, but we've got the BOTTOM cap.
else if (this->bottom.getValue()) {
center.setValue(0.0f, -h/2.0f, 0.0f);
box.setBounds(SbVec3f(-r, -h/2.0f, -r), SbVec3f(r, -h/2.0f, r));
}
// ..not a "full" cylinder, but we've got the TOP cap.
else if (this->top.getValue()) {
center.setValue(0.0f, h/2.0f, 0.0f);
box.setBounds(SbVec3f(-r, h/2.0f, -r), SbVec3f(r, h/2.0f, 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));
}
}
示例7: computeBBox
void SoRing::computeBBox(SoAction*, SbBox3f& box, SbVec3f& BBcenter)
{
float Xc, Yc;
center.getValue().getValue(Xc,Yc);
// centered at origin
BBcenter.setValue(Xc, Yc, 0.);
// bounding box
float R = outerRadius.getValue();
float theta = sweepAngle.getValue()*M_PI/180.F;
float Xmin, Ymin, Ymax;
if ( theta < M_PI_2 )
{
Ymin = 0;
Ymax = R*sin(theta);
Xmin = 0;
}
else if ( theta < M_PI )
{
Ymin = 0;
Ymax = R;
Xmin = R*cos(theta);
}
else if ( theta < 3*M_PI_2 )
{
Ymin = R*sin(theta);
Ymax = R;
Xmin = -R;
}
else
{
Xmin = -R;
Ymin = -R;
Ymax = R;
}
SbVec3f corner1(Xmin+Xc,Ymin+Yc,0);
SbVec3f corner2(R+Xc,Ymax+Yc,0);
box.setBounds(corner1,corner2);
}
示例8: activated
void CmdPartDesignBody::activated(int iMsg)
{
Q_UNUSED(iMsg);
if ( !PartDesignGui::assureModernWorkflow( getDocument() ) )
return;
App::Part *actPart = PartDesignGui::getActivePart ();
App::Part* partOfBaseFeature = nullptr;
std::vector<App::DocumentObject*> features =
getSelection().getObjectsOfType(Part::Feature::getClassTypeId());
App::DocumentObject* baseFeature = nullptr;
bool viewAll = features.empty();
if (!features.empty()) {
if (features.size() == 1) {
baseFeature = features[0];
if ( baseFeature->isDerivedFrom ( PartDesign::Feature::getClassTypeId() ) &&
PartDesign::Body::findBodyOf ( baseFeature ) ) {
// Prevent creating bodies based on features already belonging to other bodies
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Bad base feature"),
QObject::tr("Body can't be based on a PartDesign feature."));
baseFeature = nullptr;
}
else if (PartDesign::Body::findBodyOf ( baseFeature )){
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Bad base feature"),
QObject::tr("%1 already belongs to a body, can't use it as base feature for another body.")
.arg(QString::fromUtf8(baseFeature->Label.getValue())));
baseFeature = nullptr;
}
else if ( baseFeature->isDerivedFrom ( Part::BodyBase::getClassTypeId() ) ) {
// Prevent creating bodies based on bodies
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Bad base feature"),
QObject::tr("Body can't be based on another body."));
baseFeature = nullptr;
}
else {
partOfBaseFeature = App::Part::getPartOfObject(baseFeature);
if (partOfBaseFeature != 0 && partOfBaseFeature != actPart){
//prevent cross-part mess
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Bad base feature"),
QObject::tr("Base feature (%1) belongs to other part.")
.arg(QString::fromUtf8(baseFeature->Label.getValue())));
baseFeature = nullptr;
};
}
} else {
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Bad base feature"),
QObject::tr("Body may be based no more than on one feature."));
return;
}
}
openCommand("Add a Body");
std::string bodyName = getUniqueObjectName("Body");
// add the Body feature itself, and make it active
doCommand(Doc,"App.activeDocument().addObject('PartDesign::Body','%s')", bodyName.c_str());
if (baseFeature) {
if (partOfBaseFeature){
//withdraw base feature from Part, otherwise visibility mandess results
doCommand(Doc,"App.activeDocument().%s.removeObject(App.activeDocument().%s)",
partOfBaseFeature->getNameInDocument(), baseFeature->getNameInDocument());
}
doCommand(Doc,"App.activeDocument().%s.BaseFeature = App.activeDocument().%s",
bodyName.c_str(), baseFeature->getNameInDocument());
}
addModule(Gui,"PartDesignGui"); // import the Gui module only once a session
doCommand(Gui::Command::Gui, "Gui.activeView().setActiveObject('%s', App.activeDocument().%s)",
PDBODYKEY, bodyName.c_str());
// Make the "Create sketch" prompt appear in the task panel
doCommand(Gui,"Gui.Selection.clearSelection()");
doCommand(Gui,"Gui.Selection.addSelection(App.ActiveDocument.%s)", bodyName.c_str());
if (actPart) {
doCommand(Doc,"App.activeDocument().%s.addObject(App.ActiveDocument.%s)",
actPart->getNameInDocument(), bodyName.c_str());
}
// The method 'SoCamera::viewBoundingBox' is still declared as protected in Coin3d versions
// older than 4.0.
#if COIN_MAJOR_VERSION >= 4
// if no part feature was there then auto-adjust the camera
if (viewAll) {
Gui::Document* doc = Gui::Application::Instance->getDocument(getDocument());
Gui::View3DInventor* view = doc ? qobject_cast<Gui::View3DInventor*>(doc->getActiveView()) : nullptr;
if (view) {
SoCamera* camera = view->getViewer()->getCamera();
SbViewportRegion vpregion = view->getViewer()->getViewportRegion();
float aspectratio = vpregion.getViewportAspectRatio();
float size = Gui::ViewProviderOrigin::defaultSize();
SbBox3f bbox;
bbox.setBounds(-size,-size,-size,size,size,size);
camera->viewBoundingBox(bbox, aspectratio, 1.0f);
}
}
//.........这里部分代码省略.........
示例9: computeBBox
void SoXipCPUMprRender::computeBBox(SoAction *action, SbBox3f &box, SbVec3f ¢er)
{
center.setValue(0.5, 0.5, 0.5);
box.setBounds(0, 0, 0, 1, 1, 1);
}
示例10: computeBBox
void SoFCBoundingBox::computeBBox (SoAction * /*action*/, SbBox3f &box, SbVec3f ¢er)
{
center = (minBounds.getValue() + maxBounds.getValue()) / 2.0f;
box.setBounds(minBounds.getValue(), maxBounds.getValue());
}