All: Reformat according to new standard
This commit is contained in:
committed by
Kacper Donat
parent
eafd18dac0
commit
25c3ba7338
@@ -20,7 +20,7 @@
|
||||
* *
|
||||
***************************************************************************/
|
||||
|
||||
# include <sstream>
|
||||
#include <sstream>
|
||||
|
||||
#include <Inventor/SbBox.h>
|
||||
#include <Inventor/actions/SoGLRenderAction.h>
|
||||
@@ -37,37 +37,24 @@ using namespace Gui;
|
||||
SO_NODE_SOURCE(SoFCBoundingBox)
|
||||
|
||||
// vertices used to create a box
|
||||
static const int32_t bBoxVerts[8][3] =
|
||||
{
|
||||
{0, 0, 0},
|
||||
{1, 0, 0},
|
||||
{1, 1, 0},
|
||||
{0, 1, 0},
|
||||
{0, 0, 1},
|
||||
{1, 0, 1},
|
||||
{1, 1, 1},
|
||||
{0, 1, 1}
|
||||
};
|
||||
static const int32_t bBoxVerts[8][3]
|
||||
= {{0, 0, 0}, {1, 0, 0}, {1, 1, 0}, {0, 1, 0}, {0, 0, 1}, {1, 0, 1}, {1, 1, 1}, {0, 1, 1}};
|
||||
|
||||
// indexes used to create the edges
|
||||
static const int32_t bBoxEdges[36] =
|
||||
{
|
||||
0,1,-1, 1,2,-1, 2,3,-1, 3,0,-1,
|
||||
4,5,-1, 5,6,-1, 6,7,-1, 7,4,-1,
|
||||
0,4,-1, 1,5,-1, 2,6,-1, 3,7,-1
|
||||
};
|
||||
static const int32_t bBoxEdges[36] = {0, 1, -1, 1, 2, -1, 2, 3, -1, 3, 0, -1, 4, 5, -1, 5, 6, -1,
|
||||
6, 7, -1, 7, 4, -1, 0, 4, -1, 1, 5, -1, 2, 6, -1, 3, 7, -1};
|
||||
|
||||
void SoFCBoundingBox::initClass ()
|
||||
void SoFCBoundingBox::initClass()
|
||||
{
|
||||
SO_NODE_INIT_CLASS(SoFCBoundingBox, SoShape, "Shape");
|
||||
}
|
||||
|
||||
SoFCBoundingBox::SoFCBoundingBox ()
|
||||
SoFCBoundingBox::SoFCBoundingBox()
|
||||
{
|
||||
SO_NODE_CONSTRUCTOR(SoFCBoundingBox);
|
||||
|
||||
SO_NODE_ADD_FIELD(minBounds, (-1.0, -1.0, -1.0));
|
||||
SO_NODE_ADD_FIELD(maxBounds, ( 1.0, 1.0, 1.0));
|
||||
SO_NODE_ADD_FIELD(maxBounds, (1.0, 1.0, 1.0));
|
||||
SO_NODE_ADD_FIELD(coordsOn, (true));
|
||||
SO_NODE_ADD_FIELD(dimensionsOn, (true));
|
||||
|
||||
@@ -80,7 +67,7 @@ SoFCBoundingBox::SoFCBoundingBox ()
|
||||
root->addChild(bboxSep);
|
||||
|
||||
// the lines of the box
|
||||
bboxLines = new SoIndexedLineSet();
|
||||
bboxLines = new SoIndexedLineSet();
|
||||
bboxLines->coordIndex.setNum(36);
|
||||
bboxLines->coordIndex.setValues(0, 36, bBoxEdges);
|
||||
bboxSep->addChild(bboxLines);
|
||||
@@ -115,26 +102,27 @@ SoFCBoundingBox::SoFCBoundingBox ()
|
||||
root->ref();
|
||||
}
|
||||
|
||||
SoFCBoundingBox::~SoFCBoundingBox ()
|
||||
SoFCBoundingBox::~SoFCBoundingBox()
|
||||
{
|
||||
root->unref();
|
||||
}
|
||||
|
||||
void SoFCBoundingBox::GLRender (SoGLRenderAction *action)
|
||||
void SoFCBoundingBox::GLRender(SoGLRenderAction* action)
|
||||
{
|
||||
SbVec3f corner[2], ctr, *vptr;
|
||||
SbBool coord, dimension;
|
||||
|
||||
// grab the current state
|
||||
//SoState *state = action->getState();
|
||||
// SoState *state = action->getState();
|
||||
|
||||
if (!shouldGLRender(action))
|
||||
if (!shouldGLRender(action)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// get the latest values from the fields
|
||||
corner[0] = minBounds.getValue();
|
||||
corner[1] = maxBounds.getValue();
|
||||
coord = coordsOn.getValue();
|
||||
coord = coordsOn.getValue();
|
||||
dimension = dimensionsOn.getValue();
|
||||
|
||||
// set the coordinates for the LineSet to point to
|
||||
@@ -155,20 +143,23 @@ void SoFCBoundingBox::GLRender (SoGLRenderAction *action)
|
||||
str.setf(std::ios::fixed | std::ios::showpoint);
|
||||
str << "(" << vptr[i][0] << "," << vptr[i][1] << "," << vptr[i][2] << ")";
|
||||
|
||||
SoSeparator *sep = static_cast<SoSeparator *>(textSep->getChild(i));
|
||||
SoTransform *trans = static_cast<SoTransform *>(sep->getChild(0));
|
||||
SoSeparator* sep = static_cast<SoSeparator*>(textSep->getChild(i));
|
||||
SoTransform* trans = static_cast<SoTransform*>(sep->getChild(0));
|
||||
|
||||
trans->translation.setValue(vptr[i].getValue());
|
||||
SoText2* t = static_cast<SoText2 *>(sep->getChild(1));
|
||||
SoText2* t = static_cast<SoText2*>(sep->getChild(1));
|
||||
t->string.setValue(str.str().c_str());
|
||||
}
|
||||
|
||||
textSep->ref();
|
||||
if (root->findChild(textSep) < 0)
|
||||
if (root->findChild(textSep) < 0) {
|
||||
root->addChild(textSep);
|
||||
} else {
|
||||
if (root->findChild(textSep) >= 0)
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (root->findChild(textSep) >= 0) {
|
||||
root->removeChild(textSep);
|
||||
}
|
||||
}
|
||||
|
||||
// if dimension is true then set the text nodes
|
||||
@@ -181,39 +172,41 @@ void SoFCBoundingBox::GLRender (SoGLRenderAction *action)
|
||||
str.setf(std::ios::fixed | std::ios::showpoint);
|
||||
str << (2.0f * ctr[i]);
|
||||
|
||||
SoSeparator *sep = static_cast<SoSeparator *>(dimSep->getChild(i));
|
||||
SoTransform *trans = static_cast<SoTransform *>(sep->getChild(0));
|
||||
SoSeparator* sep = static_cast<SoSeparator*>(dimSep->getChild(i));
|
||||
SoTransform* trans = static_cast<SoTransform*>(sep->getChild(0));
|
||||
|
||||
SbVec3f point = corner[0];
|
||||
point[i] += ctr[i];
|
||||
trans->translation.setValue(point.getValue());
|
||||
SoText2* t = static_cast<SoText2 *>(sep->getChild(1));
|
||||
SoText2* t = static_cast<SoText2*>(sep->getChild(1));
|
||||
t->string.setValue(str.str().c_str());
|
||||
}
|
||||
|
||||
dimSep->ref();
|
||||
if (root->findChild(dimSep) < 0)
|
||||
if (root->findChild(dimSep) < 0) {
|
||||
root->addChild(dimSep);
|
||||
} else {
|
||||
if (root->findChild(dimSep) >= 0)
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (root->findChild(dimSep) >= 0) {
|
||||
root->removeChild(dimSep);
|
||||
}
|
||||
}
|
||||
|
||||
bboxCoords->point.finishEditing();
|
||||
|
||||
// Avoid shading
|
||||
SoState * state = action->getState();
|
||||
SoState* state = action->getState();
|
||||
state->push();
|
||||
SoLazyElement::setLightModel(state, SoLazyElement::BASE_COLOR);
|
||||
root->GLRender(action);
|
||||
state->pop();
|
||||
}
|
||||
|
||||
void SoFCBoundingBox::generatePrimitives (SoAction * /*action*/)
|
||||
{
|
||||
}
|
||||
void SoFCBoundingBox::generatePrimitives(SoAction* /*action*/)
|
||||
{}
|
||||
|
||||
void SoFCBoundingBox::computeBBox (SoAction * /*action*/, SbBox3f &box, SbVec3f ¢er)
|
||||
void SoFCBoundingBox::computeBBox(SoAction* /*action*/, SbBox3f& box, SbVec3f& center)
|
||||
{
|
||||
center = (minBounds.getValue() + maxBounds.getValue()) / 2.0f;
|
||||
box.setBounds(minBounds.getValue(), maxBounds.getValue());
|
||||
@@ -221,7 +214,7 @@ void SoFCBoundingBox::computeBBox (SoAction * /*action*/, SbBox3f &box, SbVec3f
|
||||
|
||||
void SoFCBoundingBox::finish()
|
||||
{
|
||||
atexit_cleanup();
|
||||
atexit_cleanup();
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------
|
||||
@@ -235,11 +228,11 @@ SoSkipBoundingGroup::SoSkipBoundingGroup()
|
||||
{
|
||||
SO_NODE_CONSTRUCTOR(SoSkipBoundingGroup);
|
||||
|
||||
SO_NODE_ADD_FIELD(mode, (INCLUDE_BBOX));
|
||||
SO_NODE_ADD_FIELD(mode, (INCLUDE_BBOX));
|
||||
|
||||
SO_NODE_DEFINE_ENUM_VALUE(Modes, INCLUDE_BBOX);
|
||||
SO_NODE_DEFINE_ENUM_VALUE(Modes, EXCLUDE_BBOX);
|
||||
SO_NODE_SET_SF_ENUM_TYPE (mode, Modes);
|
||||
SO_NODE_SET_SF_ENUM_TYPE(mode, Modes);
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -247,10 +240,9 @@ SoSkipBoundingGroup::SoSkipBoundingGroup()
|
||||
*/
|
||||
SoSkipBoundingGroup::~SoSkipBoundingGroup() = default;
|
||||
|
||||
void
|
||||
SoSkipBoundingGroup::initClass()
|
||||
void SoSkipBoundingGroup::initClass()
|
||||
{
|
||||
SO_NODE_INIT_CLASS(SoSkipBoundingGroup,SoGroup,"Group");
|
||||
SO_NODE_INIT_CLASS(SoSkipBoundingGroup, SoGroup, "Group");
|
||||
}
|
||||
|
||||
void SoSkipBoundingGroup::finish()
|
||||
@@ -258,9 +250,9 @@ void SoSkipBoundingGroup::finish()
|
||||
atexit_cleanup();
|
||||
}
|
||||
|
||||
void SoSkipBoundingGroup::getBoundingBox(SoGetBoundingBoxAction *action)
|
||||
void SoSkipBoundingGroup::getBoundingBox(SoGetBoundingBoxAction* action)
|
||||
{
|
||||
if (mode.getValue() == INCLUDE_BBOX)
|
||||
if (mode.getValue() == INCLUDE_BBOX) {
|
||||
inherited::getBoundingBox(action);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user