#include <Iguana/Inventor/interface/IgSoFieldPlaneMap.h>
Public Member Functions | |
IgSoFieldPlaneMap (void) | |
Static Public Member Functions | |
static void | initClass (void) |
Public Attributes | |
SoMFVec3f | corners |
SoMFVec3f | lowerLeftCorners |
SoMFVec3f | lowerRightCorners |
SoMFUInt32 | orderedRGBA |
SoMFVec3f | upperRightCorners |
SoMFUInt32 | xdivs |
SoMFUInt32 | zdivs |
Protected Member Functions | |
virtual void | computeBBox (SoAction *, SbBox3f &box, SbVec3f ¢er) |
virtual void | generatePrimitives (SoAction *action) |
virtual void | GLRender (SoGLRenderAction *renderAction) |
virtual | ~IgSoFieldPlaneMap (void) |
Private Member Functions | |
SO_NODE_HEADER (IgSoFieldPlaneMap) |
of volumetric data) drawn as a colour map.
Definition at line 20 of file IgSoFieldPlaneMap.h.
IgSoFieldPlaneMap::IgSoFieldPlaneMap | ( | void | ) |
Definition at line 52 of file IgSoFieldPlaneMap.cc.
References corners, lowerLeftCorners, lowerRightCorners, orderedRGBA, upperRightCorners, xdivs, and zdivs.
00053 { 00054 SO_NODE_CONSTRUCTOR (IgSoFieldPlaneMap); 00055 SO_NODE_ADD_FIELD (corners, (0, 0, 0)); 00056 00057 SO_NODE_ADD_FIELD (xdivs, (0)); 00058 SO_NODE_ADD_FIELD (zdivs, (0)); 00059 SO_NODE_ADD_FIELD (lowerLeftCorners, (0, 0, 0)); 00060 SO_NODE_ADD_FIELD (upperRightCorners, (0, 0, 0)); 00061 SO_NODE_ADD_FIELD (lowerRightCorners, (0, 0, 0)); 00062 SO_NODE_ADD_FIELD (orderedRGBA, (0)); 00063 }
IgSoFieldPlaneMap::~IgSoFieldPlaneMap | ( | void | ) | [protected, virtual] |
void IgSoFieldPlaneMap::computeBBox | ( | SoAction * | , | |
SbBox3f & | box, | |||
SbVec3f & | center | |||
) | [protected, virtual] |
Definition at line 81 of file IgSoFieldPlaneMap.cc.
References corners.
00082 { 00083 if (corners.getNum () == 4) 00084 { 00085 box.extendBy (corners [0]); 00086 box.extendBy (corners [1]); 00087 box.extendBy (corners [2]); 00088 box.extendBy (corners [3]); 00089 center = (corners [0] + corners [3]) / 2; 00090 } 00091 }
void IgSoFieldPlaneMap::generatePrimitives | ( | SoAction * | action | ) | [protected, virtual] |
Definition at line 208 of file IgSoFieldPlaneMap.cc.
References corners, fd, i, index, j, lowerLeftCorners, lowerRightCorners, orderedRGBA, pv, state, upperRightCorners, xdivs, and zdivs.
00209 { 00210 // NB: This is pretty much like GLRender (). If you change one, 00211 // please change both! 00212 if (corners.getNum () != 4) { return; } 00213 00214 // Push a new state since we modify shape hints. Then setup and 00215 // transmit styles and the one and only normal for this plane. 00216 SoState *state = action->getState (); 00217 state->push (); 00218 00219 SoShapeHintsElement::set (state, SoShapeHintsElement::COUNTERCLOCKWISE, 00220 SoShapeHintsElement::UNKNOWN_SHAPE_TYPE, 00221 SoShapeHintsElement::CONVEX); 00222 00223 // Precalculate some coordinates 00224 SbVec3f normal = SbPlane (corners[0], corners[1], corners[2]).getNormal (); 00225 00226 // Send all non-empty rectangles as two triangles each. See 00227 // GLRender() for details. 00228 SoPrimitiveVertex pv; 00229 SoFaceDetail fd; 00230 SoPointDetail pd; 00231 00232 pv.setNormal (normal); 00233 pv.setDetail (&pd); 00234 pd.setNormalIndex (0); 00235 pd.setTextureCoordIndex (0); 00236 00237 unsigned regionOffset = 0; 00238 unsigned index = 0; 00239 00240 //std::cout << "-----------------------> here8.1 <----" << std::endl; 00241 00242 for (unsigned region = 0; region < 5; region++) 00243 { 00244 if (xdivs[region] && zdivs[region]) 00245 { 00246 // Precalculate some coordinates 00247 SbVec3f corner = lowerLeftCorners [region]; 00248 00249 unsigned xdiv = xdivs[region]; 00250 SbVec3f xstep = (lowerRightCorners [region] - lowerLeftCorners [region]) / xdiv; 00251 00252 unsigned zdiv = zdivs[region]; 00253 SbVec3f zstep = (upperRightCorners [region] - lowerLeftCorners [region]) / zdiv; 00254 00255 for (unsigned i = 0; i < zdiv; ++i) 00256 { 00257 fd.setPartIndex (int (i)); 00258 00259 for (unsigned j = 0; j < xdiv; ++j, ++index) 00260 { 00261 unsigned colours [4] = { 00262 orderedRGBA [regionOffset + i * (xdiv+1) + j], 00263 orderedRGBA [regionOffset + i * (xdiv+1) + j+1], 00264 orderedRGBA [regionOffset + (i+1) * (xdiv+1) + j+1], 00265 orderedRGBA [regionOffset + (i+1) * (xdiv+1) + j] 00266 }; 00267 00268 if ((colours [0] & 0xff) 00269 || (colours [1] & 0xff) 00270 || (colours [2] & 0xff) 00271 || (colours [3] & 0xff)) 00272 { 00273 // Send the quad as a triangle strip. We installed 00274 // above point detail into `pv', and pass face detail 00275 // below to beginShape(). Thus the face has full info 00276 // about all its points. 00277 // 00278 // We provide material indices into our orderedRGBA 00279 // array and vertex indices as if this was a quad 00280 // mesh/strip. 00281 00282 fd.setFaceIndex (int (index)); 00283 beginShape (action, TRIANGLE_STRIP, &fd); 00284 00285 // setPoint () takes a vector 00286 pv.setPoint (corner + j * xstep + i * zstep); 00287 pv.setMaterialIndex (int (index)); 00288 pd.setCoordinateIndex (int (i * xdiv + j)); 00289 pd.setMaterialIndex (int (index)); 00290 shapeVertex (&pv); 00291 00292 pv.setPoint (corner + (j+1) * xstep + i * zstep); 00293 pv.setMaterialIndex (int (index)); 00294 pd.setCoordinateIndex (int (i * xdiv + j+1)); 00295 pd.setMaterialIndex (int (index)); 00296 shapeVertex (&pv); 00297 00298 00299 pv.setPoint (corner + (j+1) * xstep + (i+1) * zstep); 00300 pv.setMaterialIndex (int (index)); 00301 pd.setCoordinateIndex (int ((i+1) * xdiv + j+1)); 00302 pd.setMaterialIndex (int (index)); 00303 shapeVertex (&pv); 00304 00305 pv.setPoint (corner + j * xstep + (i+1) * zstep); 00306 pv.setMaterialIndex (int (index)); 00307 pd.setCoordinateIndex (int (i * xdiv + j+1)); 00308 pd.setMaterialIndex (int (index)); 00309 shapeVertex (&pv); 00310 00311 endShape (); 00312 } 00313 } 00314 } 00315 regionOffset += (xdivs[region] + 1) * (zdivs[region] + 1); 00316 } 00317 } 00318 // Restore old state. 00319 state->pop (); 00320 }
void IgSoFieldPlaneMap::GLRender | ( | SoGLRenderAction * | renderAction | ) | [protected, virtual] |
Definition at line 97 of file IgSoFieldPlaneMap.cc.
References corners, DO_MATERIAL, i, j, lowerLeftCorners, lowerRightCorners, orderedRGBA, reset(), state, upperRightCorners, xdivs, and zdivs.
00098 { 00099 // NB: This is pretty much like generatePrimitives(). If you 00100 // change one, please change both! 00101 00102 if (corners.getNum () != 4 00103 || ! shouldGLRender (action) 00104 || action->handleTransparency (true)) 00105 return; 00106 00107 // Push a new state since we modify shape hints. Then setup and 00108 // transmit styles. Colours we do ourselves. Then we have to tell 00109 // Inventor which bits of state we modified. Note that we don't 00110 // need to manage blending as handleTransparency() took care of that. 00111 SoState *state = action->getState (); 00112 state->push (); 00113 00114 SoShapeHintsElement::set (state, SoShapeHintsElement::COUNTERCLOCKWISE, 00115 SoShapeHintsElement::UNKNOWN_SHAPE_TYPE, 00116 SoShapeHintsElement::CONVEX); 00117 SoLazyElement::setColorMaterial (state, true); 00118 SoGLLazyElement::sendNoMaterial (state); 00119 00120 // Precalculate some coordinates 00121 SbVec3f corner; 00122 SbVec3f normal = SbPlane (corners[0], corners[1], corners[2]).getNormal (); 00123 00124 unsigned prevcolour = 0; 00125 unsigned regionOffset = 0; 00126 00127 00128 // Send first the one and only normal for this plane and then all 00129 // non-empty rectangles. We process the plane Z-major (i), 00130 // X-minor (j). Y remains constant zero. In both directions 00131 // there are one more vertex than there are divisions. Each 00132 // vertex is assigned a colour and transparency from packed colour 00133 // array `rgba' with the according region index. 00134 // Faces with all four corners with a = 0, i.e. invisible, are not 00135 // drawn at all. 00136 glBegin (GL_QUADS); 00137 glNormal3f (normal [0], normal [1], normal [2]); 00138 00139 for (unsigned region = 0; region < 5; region++) 00140 { 00141 if (xdivs[region] && zdivs[region]) 00142 { 00143 // Precalculate the region's corner 00144 corner = lowerLeftCorners [region]; 00145 00146 // amount of division and the unit step in this direction 00147 unsigned xdiv = xdivs[region]; 00148 SbVec3f xstep = (lowerRightCorners[region] - lowerLeftCorners [region]) / xdiv; 00149 00150 unsigned zdiv = zdivs[region]; 00151 SbVec3f zstep = (upperRightCorners [region] - lowerRightCorners [region]) / zdiv; 00152 00153 // indices only go right up to before the limit, because we dont 00154 // want the quads mixed with the colors of the potencially more 00155 // detailed area 00156 for (unsigned i = 0; i < zdiv; ++i) 00157 { 00158 for (unsigned j = 0; j < xdiv; ++j) 00159 { 00160 unsigned colours [4] = { 00161 orderedRGBA [regionOffset + i * (xdiv+1) + j], 00162 orderedRGBA [regionOffset + i * (xdiv+1) + j+1], 00163 orderedRGBA [regionOffset + (i+1) * (xdiv+1) + j+1], 00164 orderedRGBA [regionOffset + (i+1) * (xdiv+1) + j] 00165 }; 00166 00167 if ((colours [0] & 0xff) 00168 || (colours [1] & 0xff) 00169 || (colours [2] & 0xff) 00170 || (colours [3] & 0xff)) 00171 { 00172 // Draw the quad. Avoid material switch where we can. 00173 DO_MATERIAL (0); 00174 SbVec3f vertex = corner + j * xstep + i * zstep; 00175 glVertex3f (vertex [0], vertex [1], vertex [2]); 00176 00177 DO_MATERIAL (1); 00178 vertex = corner + (j+1) * xstep + i * zstep; 00179 glVertex3f (vertex [0], vertex [1], vertex [2]); 00180 00181 DO_MATERIAL (2); 00182 vertex = corner + (j+1) * xstep + (i+1) * zstep; 00183 glVertex3f (vertex [0], vertex [1], vertex [2]); 00184 00185 DO_MATERIAL (3); 00186 vertex = corner + j * xstep + (i+1) * zstep; 00187 glVertex3f (vertex [0], vertex [1], vertex [2]); 00188 } 00189 } 00190 } 00191 // note: we have one vertex more than division in each direction 00192 regionOffset += (xdivs[region] + 1) * (zdivs[region] + 1); 00193 } 00194 } 00195 glEnd (); 00196 00197 // Restore old state. 00198 ((SoGLLazyElement *) SoLazyElement::getInstance (state)) 00199 ->reset (state, SoLazyElement::DIFFUSE_MASK); 00200 state->pop (); 00201 // } 00202 }
Definition at line 66 of file IgSoFieldPlaneMap.cc.
Referenced by initNodes(), and initShapes().
00067 { 00068 SO_NODE_INIT_CLASS (IgSoFieldPlaneMap, SoShape, "Shape"); 00069 SO_ENABLE (SoCallbackAction, SoLazyElement); 00070 SO_ENABLE (SoPickAction, SoLazyElement); 00071 // SO_ENABLE (SoGLRenderAction, SoGLLazyElement); 00072 }
IgSoFieldPlaneMap::SO_NODE_HEADER | ( | IgSoFieldPlaneMap | ) | [private] |
SoMFVec3f IgSoFieldPlaneMap::corners |
Definition at line 24 of file IgSoFieldPlaneMap.h.
Referenced by computeBBox(), IgSoFieldPlane::convertGradientScaleColors(), IgSoFieldPlane::determineCorners(), generatePrimitives(), GLRender(), IgSoFieldPlaneMap(), IgSoFieldPlane::resampleSegments(), and IgSoFieldPlane::updateCorners().
SoMFVec3f IgSoFieldPlaneMap::lowerLeftCorners |
Definition at line 28 of file IgSoFieldPlaneMap.h.
Referenced by IgSoFieldPlane::convertGradientScaleColors(), generatePrimitives(), GLRender(), IgSoFieldPlaneMap(), and IgSoFieldPlane::transferValuesToMap().
SoMFVec3f IgSoFieldPlaneMap::lowerRightCorners |
Definition at line 30 of file IgSoFieldPlaneMap.h.
Referenced by IgSoFieldPlane::convertGradientScaleColors(), generatePrimitives(), GLRender(), IgSoFieldPlaneMap(), and IgSoFieldPlane::transferValuesToMap().
SoMFUInt32 IgSoFieldPlaneMap::orderedRGBA |
Definition at line 31 of file IgSoFieldPlaneMap.h.
Referenced by IgSoFieldPlane::convertGradientScaleColors(), IgSoFieldPlane::convertMagFieldColors(), generatePrimitives(), GLRender(), and IgSoFieldPlaneMap().
SoMFVec3f IgSoFieldPlaneMap::upperRightCorners |
Definition at line 29 of file IgSoFieldPlaneMap.h.
Referenced by IgSoFieldPlane::convertGradientScaleColors(), generatePrimitives(), GLRender(), IgSoFieldPlaneMap(), and IgSoFieldPlane::transferValuesToMap().
SoMFUInt32 IgSoFieldPlaneMap::xdivs |
Definition at line 26 of file IgSoFieldPlaneMap.h.
Referenced by IgSoFieldPlane::convertGradientScaleColors(), generatePrimitives(), GLRender(), IgSoFieldPlaneMap(), and IgSoFieldPlane::transferValuesToMap().
SoMFUInt32 IgSoFieldPlaneMap::zdivs |
Definition at line 27 of file IgSoFieldPlaneMap.h.
Referenced by IgSoFieldPlane::convertGradientScaleColors(), generatePrimitives(), GLRender(), IgSoFieldPlaneMap(), and IgSoFieldPlane::transferValuesToMap().