#include <Iguana/Inventor/interface/IgSoPolyVol.h>
Public Member Functions | |
IgSoPolyVol (void) | |
virtual void | initialise (const int sides, const float dZHalf, const float *angles, const float *sideHalf) |
method to set actual values: note angles are in radians | |
Static Public Member Functions | |
static void | initClass (void) |
Public Attributes | |
SoSFVec3f | center |
SoSFFloat | dZ |
SoMFVec3f | vtxPts |
Protected Member Functions | |
virtual void | refresh (void) |
Private Member Functions | |
SO_KIT_CATALOG_ENTRY_HEADER (face) | |
SO_KIT_CATALOG_ENTRY_HEADER (trans) | |
SO_KIT_CATALOG_ENTRY_HEADER (hints) | |
SO_KIT_HEADER (IgSoPolyVol) |
Definition at line 28 of file IgSoPolyVol.h.
IgSoPolyVol::IgSoPolyVol | ( | void | ) |
Definition at line 26 of file IgSoPolyVol.cc.
References center, dZ, FALSE, IgSoShapeKit::setUpConnections(), TRUE, and vtxPts.
00027 { 00028 SO_KIT_CONSTRUCTOR (IgSoPolyVol); 00029 SO_KIT_ADD_FIELD (vtxPts, (SbVec3f (0,0,0))); 00030 SO_KIT_ADD_FIELD (center, (SbVec3f (0,0,0))); 00031 SO_KIT_ADD_FIELD (dZ, (1.0)); 00032 SO_KIT_ADD_CATALOG_ENTRY (hints, SoShapeHints, FALSE, separator,\x0, TRUE); 00033 SO_KIT_ADD_CATALOG_ENTRY (trans, SoTranslation, FALSE, separator,\x0, TRUE); 00034 SO_KIT_ADD_CATALOG_ENTRY (face, SoIndexedFaceSet, FALSE, separator,\x0, TRUE); 00035 SO_KIT_INIT_INSTANCE (); 00036 setUpConnections (true, true); 00037 00038 const SbVec3f defPolyVol[10] = { 00039 SbVec3f (0.0,0.0,-0.5), SbVec3f (1.0,0.0,-0.5), SbVec3f (1.5,1.0,-0.5), 00040 SbVec3f (0.2,1.2,-0.5), SbVec3f (-0.2,1.0,-0.5), 00041 SbVec3f (0.0,0.0,0.5), SbVec3f (1.0,0.0,0.5), SbVec3f (1.5,1.0,0.5), 00042 SbVec3f (0.2,1.2,0.5), SbVec3f (-0.2,1.0,0.5) 00043 }; 00044 vtxPts.setValues (0,10,defPolyVol); 00045 }
Reimplemented from IgSoShapeKit.
Definition at line 23 of file IgSoPolyVol.cc.
Referenced by initNodes(), and initShapes().
00024 { SO_KIT_INIT_CLASS (IgSoPolyVol, IgSoShapeKit, "IgSoShapeKit"); }
void IgSoPolyVol::initialise | ( | const int | sides, | |
const float | dZHalf, | |||
const float * | angles, | |||
const float * | sideHalf | |||
) | [virtual] |
method to set actual values: note angles are in radians
Definition at line 112 of file IgSoPolyVol.cc.
References funct::cos(), i, funct::sin(), vtxPts, x, y, and z.
00114 { 00115 assert (sides > 2); 00116 00117 // Stuff the points into the vtxPts 00118 vtxPts.setNum (2*sides); 00119 00120 SbVec3f *pt = vtxPts.startEditing (); 00121 float x = 0; 00122 float y = 0; 00123 float z = 0; 00124 00125 for (int i = 0; i < sides; i++, pt++) 00126 { 00127 *pt = SbVec3f (x,y,z-dZHalf); 00128 *(pt+sides) = SbVec3f (x,y,z+dZHalf); 00129 x += 2 * (*sideHalf) * cos (*angles); 00130 y += 2 * (*sideHalf++) * sin (*angles++); 00131 } 00132 00133 vtxPts.finishEditing (); 00134 }
Reimplemented from IgSoShapeKit.
Definition at line 48 of file IgSoPolyVol.cc.
References center, i, NULL, and vtxPts.
00049 { 00050 if (vtxPts.getNum () < 2) 00051 { 00052 // set parts 00053 setPart ("hints", NULL); 00054 setPart ("trans", NULL); 00055 setPart ("face", NULL); 00056 00057 return; 00058 } 00059 00060 SoTranslation *trans = new SoTranslation; 00061 SoShapeHints *hints = new SoShapeHints; 00062 SoVertexProperty *vtx = new SoVertexProperty; 00063 SoIndexedFaceSet *face = new SoIndexedFaceSet; 00064 00065 hints->vertexOrdering = SoShapeHints::COUNTERCLOCKWISE; 00066 hints->faceType = SoShapeHints::UNKNOWN_FACE_TYPE; 00067 hints->shapeType = SoShapeHints::SOLID; 00068 hints->creaseAngle = 0; 00069 00070 trans->translation = center; 00071 00072 // Create the face set 00073 vtx->vertex = vtxPts; 00074 face->vertexProperty = vtx; 00075 00076 int nsides = vtxPts.getNum ()/2; // number of sides of front polygon 00077 face->coordIndex.setNum (7 * nsides + 2); //5*nsides for side polys+ 2* (nsides+1) for front and back 00078 00079 int *indx = face->coordIndex.startEditing (); 00080 int i; 00081 00082 // sides 00083 for (i = 0; i < nsides-1; i++) 00084 { 00085 *indx++ = i; 00086 *indx++ = i+1; 00087 *indx++ = i+nsides+1; 00088 *indx++ = i+nsides; 00089 *indx++ = SO_END_FACE_INDEX; 00090 } 00091 *indx++ = i; *indx++ = 0; *indx++ = nsides; *indx++ = i+nsides; 00092 *indx++ = SO_END_FACE_INDEX; 00093 00094 // front & back faces; back face counts down 00095 for (i = nsides-1; i > -1; i--) 00096 { 00097 *indx = i; 00098 *((indx++) + nsides + 1) = 2*nsides-1-i; // bump past n vertices+end_face 00099 } 00100 *indx++ = SO_END_FACE_INDEX; 00101 *(indx+nsides) = SO_END_FACE_INDEX; 00102 face->coordIndex.finishEditing (); 00103 00104 // set parts 00105 setPart ("hints", hints); 00106 setPart ("trans", trans); 00107 setPart ("face", face); 00108 }
IgSoPolyVol::SO_KIT_CATALOG_ENTRY_HEADER | ( | face | ) | [private] |
IgSoPolyVol::SO_KIT_CATALOG_ENTRY_HEADER | ( | trans | ) | [private] |
IgSoPolyVol::SO_KIT_CATALOG_ENTRY_HEADER | ( | hints | ) | [private] |
IgSoPolyVol::SO_KIT_HEADER | ( | IgSoPolyVol | ) | [private] |
SoSFVec3f IgSoPolyVol::center |
SoSFFloat IgSoPolyVol::dZ |
SoMFVec3f IgSoPolyVol::vtxPts |
Definition at line 39 of file IgSoPolyVol.h.
Referenced by IgSoPolyVol(), initialise(), and refresh().