23 #include <Inventor/SbBox.h>
24 #include <Inventor/actions/SoAction.h>
25 #include <Inventor/actions/SoPickAction.h>
26 #include <Inventor/SoPrimitiveVertex.h>
27 #include <Inventor/elements/SoTextureCoordinateElement.h>
28 #include <Inventor/elements/SoGLCacheContextElement.h>
30 #include <Inventor/nodes/SoSeparator.h>
31 #include <Inventor/nodes/SoIndexedFaceSet.h>
32 #include <Inventor/nodes/SoVertexProperty.h>
34 #include <Inventor/C/glue/gl.h>
49 [[maybe_unused]]
static const bool didInit = [&]() {
65 setNodeType(EXTENSION);
79 m_polyhedron = std::make_unique<SbPolyhedron>(aPolyhedron);
80 setNodeType(EXTENSION);
95 m_polyhedron = std::make_unique<SbPolyhedron>(*aPolyhedron);
96 setNodeType(EXTENSION);
120 SoState *state = aAction->getState();
123 SbBool useTexFunction =
125 SoTextureCoordinateElement::FUNCTION);
126 const SoTextureCoordinateElement *tce = NULL;
128 if (useTexFunction) {
129 tce = SoTextureCoordinateElement::getInstance(state);
137 SoPrimitiveVertex
pv;
138 SbVec3f point, normal;
141 #define GEN_VERTEX(pv,x,y,z,s,t,nx,ny,nz) \
142 point.setValue(x,y,z); \
143 normal.setValue(nx,ny,nz); \
144 if (useTexFunction) { \
145 texCoord=tce->get(point,normal); \
150 pv.setPoint(point); \
151 pv.setNormal(normal); \
152 pv.setTextureCoords(texCoord); \
159 if ( aAction->getTypeId().isDerivedFrom(SoPickAction::getClassTypeId()) ){
164 notLastFace =
m_polyhedron->GetNextUnitNormal(unitNormal);
166 beginShape(aAction,POLYGON);
180 }
while (notLastEdge);
182 }
while (notLastFace);
187 glEnableClientState(GL_VERTEX_ARRAY);
189 glEnableClientState(GL_NORMAL_ARRAY);
198 glDrawArrays(GL_TRIANGLES, 0,
m_vcount);
199 glDisableClientState(GL_VERTEX_ARRAY);
200 glDisableClientState(GL_NORMAL_ARRAY);
276 if (state&&state->isElementEnabled(SoGLCacheContextElement::getClassStackIndex())) {
278 SoGLCacheContextElement::shouldAutoCache(state, SoGLCacheContextElement::DO_AUTO_CACHE);
279 #if ((COIN_MAJOR_VERSION>=3)||((COIN_MAJOR_VERSION==2)&&(COIN_MINOR_VERSION>=5)))
280 SoGLCacheContextElement::incNumShapes(state);
295 SbVec3f
vmin(-1,-1,-1);
296 SbVec3f
vmax( 1, 1, 1);
298 aCenter.setValue(0,0,0);
303 float xmn = 0,ymn = 0,zmn = 0;
304 float xmx = 0,ymx = 0,zmx = 0;
305 float xct = 0,yct = 0,zct = 0;
312 notLastFace =
m_polyhedron->GetNextUnitNormal(unitNormal);
321 xct = xmx = xmn = point[0];
322 yct = ymx = ymn = point[1];
323 zct = zmx = zmn = point[2];
341 }
while (notLastEdge);
342 }
while (notLastFace);
343 SbVec3f
vmin(xmn,ymn,zmn);
344 SbVec3f
vmax(xmx,ymx,zmx);
348 aCenter.setValue(0,0,0);
379 SoVertexProperty *vertices =
new SoVertexProperty();
383 for(
int i = 0;
i < vno;
i++){
391 int* aface =
new int[8 * fno];
392 for(
int i = 0;
i < fno;
i++){
397 aface[fcr] = (inodes[0] <= vno) ? (inodes[0] - 1) : (0); fcr++;
398 aface[fcr] = (inodes[1] <= vno) ? (inodes[1] - 1) : (0); fcr++;
399 aface[fcr] = (inodes[2] <= vno) ? (inodes[2] - 1) : (0); fcr++;
400 if(
n == 4) { aface[fcr] = (inodes[3] <= vno) ? (inodes[3] - 1) : (0); fcr++; }
401 aface[fcr] = -1; fcr++;
403 SoIndexedFaceSet * faceset =
new SoIndexedFaceSet;
404 faceset->coordIndex.setValues(0, fcr, aface);
406 faceset->vertexProperty = vertices;
425 for(
long i = 0;
i < len;
i++){
426 if((
v.pos[0] == vertices[
i].
pos[0]) && (
v.pos[1] == vertices[
i].
pos[1]) && (
v.pos[2] == vertices[
i].
pos[2]) &&
427 (
v.nor[0] == vertices[
i].
nor[0]) && (
v.nor[1] == vertices[
i].
nor[1]) && (
v.nor[2] == vertices[
i].
nor[2]))
536 for(
int i = 0;
i < fno;
i++){
552 for(
int i = 0;
i < fno;
i++){