125 if(!fPolyhedron)
return;
128 SoState *state = aAction->getState();
129 SbBool useTexFunction =
130 (SoTextureCoordinateElement::getType(state) ==
131 SoTextureCoordinateElement::FUNCTION);
132 const SoTextureCoordinateElement *tce = NULL;
133 SbVec4f texCoord(0.,0.,0.,0.);
134 if (useTexFunction) {
135 tce = SoTextureCoordinateElement::getInstance(state);
142 SoPrimitiveVertex pv;
143 SbVec3f point, normal;
146#define GEN_VERTEX(pv,x,y,z,s,t,nx,ny,nz) \
147 point.setValue(x,y,z); \
148 normal.setValue(nx,ny,nz); \
149 if (useTexFunction) { \
150 texCoord=tce->get(point,normal); \
155 pv.setPoint(point); \
156 pv.setNormal(normal); \
157 pv.setTextureCoords(texCoord); \
168 beginShape(aAction,POLYGON);
182 }
while (notLastEdge);
184 }
while (notLastFace);
186 SoPrimitiveVertex pvb,pve;
187 pve.setTextureCoords(texCoord);
188 pvb.setTextureCoords(texCoord);
191 beginShape(aAction,POLYGON);
202 normal.setValue(unitNormal[0],unitNormal[1],unitNormal[2]);
206 int prevEdgeFlag = edgeFlag;
208 SbBool firstEdge =
TRUE;
215 pvb.setNormal(normal);
216 point.setValue(vertex[0],vertex[1],vertex[2]);
221 prevEdgeFlag = edgeFlag;
223 if(edgeFlag!=prevEdgeFlag) {
225 pvb.setNormal(normal);
226 point.setValue(vertex[0],vertex[1],vertex[2]);
229 pve.setNormal(normal);
230 point.setValue(vertex[0],vertex[1],vertex[2]);
232 invokeLineSegmentCallbacks(aAction,&pvb,&pve);
234 prevEdgeFlag = edgeFlag;
237 pve.setNormal(normal);
238 point.setValue(vertex[0],vertex[1],vertex[2]);
240 invokeLineSegmentCallbacks(aAction,&pvb,&pve);
246 }
while (notLastEdge);
247 }
while (notLastFace);
260 if(!fPolyhedron)
return;
262 SbVec3f vmin(-1,-1,-1);
263 SbVec3f vmax( 1, 1, 1);
264 aBox.setBounds(vmin,vmax);
265 aCenter.setValue(0,0,0);
268 float xmn = 0,ymn = 0,zmn = 0;
269 float xmx = 0,ymx = 0,zmx = 0;
270 float xct = 0,yct = 0,zct = 0;
283 point.setValue(vertex[0],vertex[1],vertex[2]);
285 xct = xmx = xmn = point[0];
286 yct = ymx = ymn = point[1];
287 zct = zmx = zmn = point[2];
305 }
while (notLastEdge);
306 }
while (notLastFace);
307 SbVec3f vmin(xmn,ymn,zmn);
308 SbVec3f vmax(xmx,ymx,zmx);
309 aBox.setBounds(vmin,vmax);
311 aCenter.setValue(0,0,0);
313 aCenter.setValue(xct/count,yct/count,zct/count);
328 if(!fPolyhedron)
return;
334 SoSeparator* separator =
new SoSeparator;
336 SoNormalBinding* normalBinding =
new SoNormalBinding;
337 normalBinding->value = SoNormalBinding::PER_FACE;
338 separator->addChild(normalBinding);
340 SoCoordinate3* coordinate3 =
new SoCoordinate3;
341 separator->addChild(coordinate3);
342 SoNormal* normal =
new SoNormal;
343 separator->addChild(normal);
344 SoIndexedFaceSet* indexedFaceSet =
new SoIndexedFaceSet;
345 separator->addChild(indexedFaceSet);
350 SbVec3f* normals =
new SbVec3f[nface];
352 SbVec3f* points =
new SbVec3f[nvert];
353 int32_t* coords =
new int32_t[nvert+1];
373 points[ipoint].setValue(vertex[0],vertex[1],vertex[2]);
374 coords[ipoint] = icoord + ipoint;
376 }
while (notLastEdge);
379 coords[ipoint] = SO_END_FACE_INDEX;
380 coordinate3->point.setValues(icoord,ipoint,points);
383 normals[inormal].setValue(unitNormal[0],unitNormal[1],unitNormal[2]);
386 indexedFaceSet->coordIndex.setValues(iindex,(ipoint+1),coords);
389 }
while (notLastFace);
391 normal->vector.setValues(0,inormal,normals);
401 SoSeparator* separator =
new SoSeparator;
406 int nedge = nvert * 3;
407 int npoint = nedge*2;
408 SbVec3f* points =
new SbVec3f[npoint];
409 int ncoord = nedge*3;
410 int32_t* coords =
new int32_t[ncoord];
412 SbVec3f pvb(0.,0.,0.), pve(0.,0.,0.);
432 int prevEdgeFlag = edgeFlag;
434 SbBool firstEdge =
TRUE;
441 pvb.setValue(vertex[0],vertex[1],vertex[2]);
445 prevEdgeFlag = edgeFlag;
447 if(edgeFlag!=prevEdgeFlag) {
449 pvb.setValue(vertex[0],vertex[1],vertex[2]);
451 pve.setValue(vertex[0],vertex[1],vertex[2]);
453 if((ipoint+1)>=npoint) {
454 int new_npoint = 2 * npoint;
455 SbVec3f* new_points =
new SbVec3f[new_npoint];
456 for(
int i=0;i<npoint;i++) new_points[i] = points[i];
462 if((icoord+2)>=ncoord) {
463 int new_ncoord = 2 * ncoord;
464 int32_t* new_coords =
new int32_t[new_ncoord];
465 for(
int i=0;i<ncoord;i++) new_coords[i] = coords[i];
471 points[ipoint+0] = pvb;
472 points[ipoint+1] = pve;
473 coords[icoord+0] = ipoint + 0;
474 coords[icoord+1] = ipoint + 1;
475 coords[icoord+2] = SO_END_LINE_INDEX;
480 prevEdgeFlag = edgeFlag;
483 pve.setValue(vertex[0],vertex[1],vertex[2]);
485 if((ipoint+1)>=npoint) {
486 int new_npoint = 2 * npoint;
487 SbVec3f* new_points =
new SbVec3f[new_npoint];
488 for(
int i=0;i<npoint;i++) new_points[i] = points[i];
494 if((icoord+2)>=ncoord) {
495 int new_ncoord = 2 * ncoord;
496 int32_t* new_coords =
new int32_t[new_ncoord];
497 for(
int i=0;i<ncoord;i++) new_coords[i] = coords[i];
503 points[ipoint+0] = pvb;
504 points[ipoint+1] = pve;
505 coords[icoord+0] = ipoint + 0;
506 coords[icoord+1] = ipoint + 1;
507 coords[icoord+2] = SO_END_LINE_INDEX;
517 }
while (notLastEdge);
518 }
while (notLastFace);
520 SoCoordinate3* coordinate3 =
new SoCoordinate3;
521 coordinate3->point.setValues(0,ipoint,points);
522 separator->addChild(coordinate3);
524 SoIndexedLineSet* indexedLineSet =
new SoIndexedLineSet;
525 indexedLineSet->coordIndex.setValues(0,icoord,coords);
526 separator->addChild(indexedLineSet);
#define GEN_VERTEX(pv, x, y, z, s, t, nx, ny, nz)