All: Reformat according to new standard
This commit is contained in:
committed by
Kacper Donat
parent
eafd18dac0
commit
25c3ba7338
@@ -24,23 +24,23 @@
|
||||
|
||||
#include <FCConfig.h>
|
||||
|
||||
# ifdef FC_OS_WIN32
|
||||
# include <windows.h>
|
||||
# endif
|
||||
# ifdef FC_OS_MACOSX
|
||||
# include <OpenGL/gl.h>
|
||||
# else
|
||||
# include <GL/gl.h>
|
||||
# endif
|
||||
# include <algorithm>
|
||||
# include <limits>
|
||||
# include <Inventor/actions/SoGLRenderAction.h>
|
||||
# include <Inventor/bundles/SoMaterialBundle.h>
|
||||
# include <Inventor/bundles/SoTextureCoordinateBundle.h>
|
||||
# include <Inventor/elements/SoCoordinateElement.h>
|
||||
# include <Inventor/elements/SoLazyElement.h>
|
||||
# include <Inventor/errors/SoReadError.h>
|
||||
# include <Inventor/misc/SoState.h>
|
||||
#ifdef FC_OS_WIN32
|
||||
# include <windows.h>
|
||||
#endif
|
||||
#ifdef FC_OS_MACOSX
|
||||
# include <OpenGL/gl.h>
|
||||
#else
|
||||
# include <GL/gl.h>
|
||||
#endif
|
||||
#include <algorithm>
|
||||
#include <limits>
|
||||
#include <Inventor/actions/SoGLRenderAction.h>
|
||||
#include <Inventor/bundles/SoMaterialBundle.h>
|
||||
#include <Inventor/bundles/SoTextureCoordinateBundle.h>
|
||||
#include <Inventor/elements/SoCoordinateElement.h>
|
||||
#include <Inventor/elements/SoLazyElement.h>
|
||||
#include <Inventor/errors/SoReadError.h>
|
||||
#include <Inventor/misc/SoState.h>
|
||||
|
||||
#include "SoFCShapeObject.h"
|
||||
|
||||
@@ -86,17 +86,18 @@ SoFCControlPoints::SoFCControlPoints()
|
||||
/**
|
||||
* Renders the control points.
|
||||
*/
|
||||
void SoFCControlPoints::GLRender(SoGLRenderAction *action)
|
||||
void SoFCControlPoints::GLRender(SoGLRenderAction* action)
|
||||
{
|
||||
if (shouldGLRender(action))
|
||||
{
|
||||
SoState* state = action->getState();
|
||||
const SoCoordinateElement * coords = SoCoordinateElement::getInstance(state);
|
||||
if (!coords)
|
||||
if (shouldGLRender(action)) {
|
||||
SoState* state = action->getState();
|
||||
const SoCoordinateElement* coords = SoCoordinateElement::getInstance(state);
|
||||
if (!coords) {
|
||||
return;
|
||||
const SbVec3f * points = coords->getArrayPtr3();
|
||||
if (!points)
|
||||
}
|
||||
const SbVec3f* points = coords->getArrayPtr3();
|
||||
if (!points) {
|
||||
return;
|
||||
}
|
||||
|
||||
SoMaterialBundle mb(action);
|
||||
SoTextureCoordinateBundle tb(action, true, false);
|
||||
@@ -111,92 +112,94 @@ void SoFCControlPoints::GLRender(SoGLRenderAction *action)
|
||||
/**
|
||||
* Renders the control points and knots.
|
||||
*/
|
||||
void SoFCControlPoints::drawControlPoints(const SbVec3f * points,int32_t len) const
|
||||
void SoFCControlPoints::drawControlPoints(const SbVec3f* points, int32_t len) const
|
||||
{
|
||||
glLineWidth(1.0f);
|
||||
glColor3fv(lineColor.getValue().getValue());
|
||||
|
||||
uint32_t nCtU=numPolesU.getValue();
|
||||
uint32_t nCtV=numPolesV.getValue();
|
||||
uint32_t nCtU = numPolesU.getValue();
|
||||
uint32_t nCtV = numPolesV.getValue();
|
||||
uint32_t poles = nCtU * nCtV;
|
||||
if (poles > (uint32_t)len)
|
||||
return; // wrong setup, too few points
|
||||
if (poles > (uint32_t)len) {
|
||||
return; // wrong setup, too few points
|
||||
}
|
||||
// draw control mesh
|
||||
glBegin(GL_LINES);
|
||||
for (uint32_t u = 0; u < nCtU-1; ++u) {
|
||||
for (uint32_t v = 0; v < nCtV -1; ++v) {
|
||||
glVertex3fv(points[u*nCtV+v].getValue());
|
||||
glVertex3fv(points[u*nCtV+v+1].getValue());
|
||||
glVertex3fv(points[u*nCtV+v].getValue());
|
||||
glVertex3fv(points[(u+1)*nCtV+v].getValue());
|
||||
for (uint32_t u = 0; u < nCtU - 1; ++u) {
|
||||
for (uint32_t v = 0; v < nCtV - 1; ++v) {
|
||||
glVertex3fv(points[u * nCtV + v].getValue());
|
||||
glVertex3fv(points[u * nCtV + v + 1].getValue());
|
||||
glVertex3fv(points[u * nCtV + v].getValue());
|
||||
glVertex3fv(points[(u + 1) * nCtV + v].getValue());
|
||||
}
|
||||
glVertex3fv(points[(u+1)*nCtV-1].getValue());
|
||||
glVertex3fv(points[(u+2)*nCtV-1].getValue());
|
||||
glVertex3fv(points[(u + 1) * nCtV - 1].getValue());
|
||||
glVertex3fv(points[(u + 2) * nCtV - 1].getValue());
|
||||
}
|
||||
for (uint32_t v = 0; v < nCtV -1; ++v) {
|
||||
glVertex3fv(points[(nCtU-1)*nCtV+v].getValue());
|
||||
glVertex3fv(points[(nCtU-1)*nCtV+v+1].getValue());
|
||||
for (uint32_t v = 0; v < nCtV - 1; ++v) {
|
||||
glVertex3fv(points[(nCtU - 1) * nCtV + v].getValue());
|
||||
glVertex3fv(points[(nCtU - 1) * nCtV + v + 1].getValue());
|
||||
}
|
||||
glEnd();
|
||||
|
||||
// draw poles
|
||||
glPointSize(5.0f);
|
||||
glBegin(GL_POINTS);
|
||||
for (uint32_t p=0; p<poles; p++) {
|
||||
for (uint32_t p = 0; p < poles; p++) {
|
||||
glVertex3fv(points[p].getValue());
|
||||
}
|
||||
glEnd();
|
||||
|
||||
// draw knots if available
|
||||
uint32_t knots=numKnotsU.getValue() * numKnotsV.getValue();
|
||||
uint32_t knots = numKnotsU.getValue() * numKnotsV.getValue();
|
||||
uint32_t index = poles + knots;
|
||||
if (index > (uint32_t)len)
|
||||
return; // wrong setup, too few points
|
||||
if (index > (uint32_t)len) {
|
||||
return; // wrong setup, too few points
|
||||
}
|
||||
glColor3f(1.0f, 1.0f, 0.0f);
|
||||
glPointSize(6.0f);
|
||||
glBegin(GL_POINTS);
|
||||
for (uint32_t p=poles; p<index; p++) {
|
||||
for (uint32_t p = poles; p < index; p++) {
|
||||
glVertex3fv(points[p].getValue());
|
||||
}
|
||||
glEnd();
|
||||
}
|
||||
|
||||
void SoFCControlPoints::generatePrimitives(SoAction* /*action*/)
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
/**
|
||||
* Sets the bounding box of the mesh to \a box and its center to \a center.
|
||||
*/
|
||||
void SoFCControlPoints::computeBBox(SoAction *action, SbBox3f &box, SbVec3f ¢er)
|
||||
void SoFCControlPoints::computeBBox(SoAction* action, SbBox3f& box, SbVec3f& center)
|
||||
{
|
||||
SoState* state = action->getState();
|
||||
const SoCoordinateElement * coords = SoCoordinateElement::getInstance(state);
|
||||
if (!coords)
|
||||
SoState* state = action->getState();
|
||||
const SoCoordinateElement* coords = SoCoordinateElement::getInstance(state);
|
||||
if (!coords) {
|
||||
return;
|
||||
const SbVec3f * points = coords->getArrayPtr3();
|
||||
if (!points)
|
||||
}
|
||||
const SbVec3f* points = coords->getArrayPtr3();
|
||||
if (!points) {
|
||||
return;
|
||||
}
|
||||
constexpr float floatMax = std::numeric_limits<float>::max();
|
||||
float maxX=-floatMax, minX=floatMax,
|
||||
maxY=-floatMax, minY=floatMax,
|
||||
maxZ=-floatMax, minZ=floatMax;
|
||||
float maxX = -floatMax, minX = floatMax, maxY = -floatMax, minY = floatMax, maxZ = -floatMax,
|
||||
minZ = floatMax;
|
||||
int32_t len = coords->getNum();
|
||||
if (len > 0) {
|
||||
for (int32_t i=0; i<len; 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]);
|
||||
for (int32_t i = 0; i < len; 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));
|
||||
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);
|
||||
box.setBounds(SbVec3f(0, 0, 0), SbVec3f(0, 0, 0));
|
||||
center.setValue(0.0f, 0.0f, 0.0f);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user