18#include <Inventor/SbBox.h>
19#include <Inventor/actions/SoPickAction.h>
20#include <Inventor/nodes/SoSeparator.h>
21#include <Inventor/nodes/SoIndexedFaceSet.h>
22#include <Inventor/nodes/SoIndexedLineSet.h>
24#include <Inventor/SoPrimitiveVertex.h>
25#include <Inventor/C/glue/gl.h>
26#include <Inventor/elements/SoGLCacheContextElement.h>
46 3, 2, 1, 0, SO_END_FACE_INDEX,
47 4, 5, 6, 7, SO_END_FACE_INDEX,
48 0, 1, 5, 4, SO_END_FACE_INDEX,
49 1, 2, 6, 5, SO_END_FACE_INDEX,
50 2, 3, 7, 6, SO_END_FACE_INDEX,
51 3, 0, 4, 7, SO_END_FACE_INDEX
56 0, 1, 2, 3, 0, 4, 5, 6, 7, 4, SO_END_LINE_INDEX,
57 3, 7, SO_END_LINE_INDEX,
58 6, 2, SO_END_LINE_INDEX,
59 5, 1, SO_END_LINE_INDEX,
65 [[maybe_unused]]
static const bool didInit = [&]() {
79 setNodeType(EXTENSION);
96 SoState *state = action->getState();
98 if ( action->getTypeId().isDerivedFrom(SoPickAction::getClassTypeId()) ) {
101 SoPrimitiveVertex vertex;
102 beginShape(action,QUADS);
105 for (
int j = 0; j < 4; ++j) {
106 const int ivert = *iptr++;
108 shapeVertex(&vertex);
117 glNormal3fv(
static_cast<const GLfloat*
>(&
m_normals[i*3]));
118 for (
int j = 0; j < 4; j++)
119 glVertex3fv(
static_cast<const GLfloat*
>(&
m_points[(*iptr++)*3]));
126 SbColor outlineColour;
130 glPushAttrib(GL_CURRENT_BIT | GL_LIGHTING_BIT);
132 const bool transparencyOn = glIsEnabled(GL_BLEND);
134 if (disableLighting) glDisable(GL_LIGHTING);
135 if (transparencyOn) glDisable(GL_BLEND);
137 glColor3fv(outlineColour.getValue());
138#define trdV(i) glVertex3fv(static_cast<const GLfloat*>(&m_points[i*3]));
139 glBegin(GL_LINE_STRIP);
149 if (disableLighting) glEnable(GL_LIGHTING);
150 if (transparencyOn) glEnable(GL_BLEND);
156 if (state&&state->isElementEnabled(SoGLCacheContextElement::getClassStackIndex())) {
158 SoGLCacheContextElement::shouldAutoCache(state, SoGLCacheContextElement::DO_AUTO_CACHE);
159#if ((COIN_MAJOR_VERSION>=3)||((COIN_MAJOR_VERSION==2)&&(COIN_MINOR_VERSION>=5)))
160 SoGLCacheContextElement::incNumShapes(state);
189 float xcenter,
float ycenter,
float zcenter ) {
204 double phiMin,
double phiMax,
205 double cellDepth,
double cellDistance,
206 double etasqueezefact,
double phisqueezefact )
209 if (phiMax<phiMin)
std::swap(phiMin,phiMax);
210 if (etaMax<etaMin)
std::swap(etaMin,etaMax);
212 if (etasqueezefact!=1.0) {
213 double etashift(0.5*(1.0-etasqueezefact)*fabs(etaMax-etaMin));
217 if (phisqueezefact!=1.0) {
218 double phishift(0.5*(1.0-phisqueezefact)*fabs(phiMax-phiMin));
223 if (cellDistance<0) cellDistance = -cellDistance;
224 if (cellDepth<0) cellDistance = std::max(cellDistance-cellDepth,0.0);
225 double tantheta2 = tan(2*atan(exp(-etaMin)));
226 double tantheta1 = tan(2*atan(exp(-etaMax)));
227 const double cpMin(cos(phiMin));
228 const double cpMax(cos(phiMax));
229 const double spMin(sin(phiMin));
230 const double spMax(sin(phiMax));
232 const double rf = cellDistance;
233 const double rb = cellDistance+cellDepth;
234 const double rfdivtantheta1(rf/tantheta1);
235 const double rbdivtantheta1(rb/tantheta1);
236 const double rfdivtantheta2(rf/tantheta2);
237 const double rbdivtantheta2(rb/tantheta2);
247 const double eta(0.5*(etaMin+etaMax));
248 const double zf(
eta>0?cellDistance:-cellDistance);
249 double zb = (zf > 0 ? zf+cellDepth: zf-cellDepth);
266 double phiMin,
double phiMax,
267 double cellDepth,
double cellDistance,
268 double etasqueezefact,
double phisqueezefact )
271 cellDepth, cellDistance, etasqueezefact, phisqueezefact );
276 double phiMin,
double phiMax,
277 double cellDepth,
double cellDistance,
278 double etasqueezefact,
double phisqueezefact )
281 cellDepth, cellDistance, etasqueezefact, phisqueezefact );
286 float dy1,
float dy2,
303 float dx1,
float dx2,
float dy2,
float dx3,
304 float dx4,
float alp1,
float alp2 )
308 const float tanTheta(tan(
theta));
309 const float TthetaCphi = tanTheta*cos(
phi);
310 const float TthetaSphi = tanTheta*sin(
phi);
311 const float Talp1 = tan(alp1);
312 const float Talp2 = tan(alp2);
346 const float dzTthetaCphi(dz*TthetaCphi);
347 const float dzTthetaSphi(dz*TthetaSphi);
363 float x1,
float y1,
float z1,
364 float x2,
float y2,
float z2,
365 float x3,
float y3,
float z3,
366 float x4,
float y4,
float z4,
367 float x5,
float y5,
float z5,
368 float x6,
float y6,
float z6,
369 float x7,
float y7,
float z7 )
396 const double edge1X(
m_points[index_v2*3+0]-v1X), edge1Y(
m_points[index_v2*3+1]-v1Y), edge1Z(
m_points[index_v2*3+2]-v1Z);
397 const double edge2X(
m_points[index_v3*3+0]-v1X), edge2Y(
m_points[index_v3*3+1]-v1Y), edge2Z(
m_points[index_v3*3+2]-v1Z);
399 double nx(edge1Y*edge2Z-edge1Z*edge2Y);
400 double ny(edge1Z*edge2X-edge1X*edge2Z);
401 double nz(edge1X*edge2Y-edge1Y*edge2X);
402 double nl(nx*nx+ny*ny+nz*nz);
404 std::cout<<
"SoGenericBox::Error Could not calculate normal due to degenerate face edge"<<std::endl;
405 nx=1.0;ny=0.0;nz=0.0;nl=1;
411 const double s(1.0/sqrt(nl));
418 float xmin(1.0e99),
ymin(1.0e99), zmin(1.0e99);
419 float xmax(-1.0e99),
ymax(-1.0e99), zmax(-1.0e99);
424 zmin = std::min(zmin,
z); zmax = std::max(zmax,
z);
444 SoSeparator * sep =
new SoSeparator;
447 SoVertexProperty *vertices =
new SoVertexProperty();
450 SoIndexedFaceSet * faceset =
new SoIndexedFaceSet;
452 faceset->vertexProperty = vertices;
453 sep->addChild(faceset);
462 SoIndexedLineSet * lineset =
new SoIndexedLineSet;
464 lineset->vertexProperty = vertices;
465 sep->addChild(lineset);
Scalar eta() const
pseudorapidity method
Scalar phi() const
phi method
Scalar theta() const
theta method
static const int SOGENERICBOX_NPOINTS
static const int SOGENERICBOX_NFACES
static int sogenericbox_vindices[]
static int sogenericbox_vindices_foraltreplines[20]
static int sogenericbox_vindices_foraltrepfaces[5 *SOGENERICBOX_NFACES]
SO_NODE_SOURCE(SoOutlineColour)
virtual void clearAlternateRep()
void setParametersForBox(float dx, float dy, float dz, float xcenter=0.0, float ycenter=0.0, float zcenter=0.0)
void internalSetParametersForEtaPhiCell(bool barrel, double etaMin, double etaMax, double phiMin, double phiMax, double cellDepth, double cellDistance, double etasqueezefact, double phisqueezefact)
void ensurePointsAllocated()
void setParametersForTrapezoid(float dz, float theta, float phi, float dy1, float dx1, float dx2, float dy2, float dx3, float dx4, float alp1, float alp2)
void setParametersForTrd(float dx1, float dx2, float dy1, float dy2, float dz)
void setGenericParameters(float x0, float y0, float z0, float x1, float y1, float z1, float x2, float y2, float z2, float x3, float y3, float z3, float x4, float y4, float z4, float x5, float y5, float z5, float x6, float y6, float z6, float x7, float y7, float z7)
SoSFBool forceEdgeLinesInBaseColour
virtual void computeBBox(SoAction *action, SbBox3f &box, SbVec3f ¢er)
void setParametersForBarrelEtaPhiCell(double etaMin, double etaMax, double phiMin, double phiMax, double cellDepth, double cellDistance, double etasqueezefact=1.0, double phisqueezefact=1.0)
void setupDefaultPoints()
virtual void generatePrimitives(SoAction *action)
void setParametersForEndCapEtaPhiCell(double etaMin, double etaMax, double phiMin, double phiMax, double cellDepth, double cellDistance, double etasqueezefact=1.0, double phisqueezefact=1.0)
virtual void generateAlternateRep()
static bool get(SoState *, SbColor &)
void swap(ElementLinkVector< DOBJ > &lhs, ElementLinkVector< DOBJ > &rhs)