osg::Brick Class Reference

#include <OSGBrick.h>

List of all members.

Public Member Functions

BrickgetNext (void)
 Returns next brick in sorted order.
void init (Int32 minVoxX, Int32 minVoxY, Int32 minVoxZ, Int32 resX, Int32 resY, Int32 resZ, Real32 xMin, Real32 yMin, Real32 zMin, Real32 xMax, Real32 yMax, Real32 zMax, Int32 overlap=1, BrickSet::Orientation ori=BrickSet::UNDEF)
 Initialize brick size and geometry.
void activateTexture (DrawActionBase *action)
 Activate textures.
void changeFromTexture (DrawActionBase *action, Brick *old)
 Change active texture.
void deactivateTexture (DrawActionBase *action)
 Deactivate textures.
void renderSlices (DVRVolume *volume, DrawActionBase *action, DVRShaderPtr shader, DVRClipper *clipper, TextureManager::TextureMode mode)
 Render slices.
void renderBrick (void)
 Render brick boundaries.
void vertToTex (Real32 *vx, Real32 *vy, Real32 *vz, Real32 *tx, Real32 *ty, Real32 *tz)
 Transform vertex to texture coordinates.
void vertToTex (Vec3f &vert, Vec3f &tex)
 Transform vertex to texture coordinates.

Private Member Functions

void render3DSlices (DVRVolume *volume, DrawActionBase *action, DVRShaderPtr shader, DVRClipper *clipper, const Vec3f &sliceDir)
 Render slices.
void render2DSlices (DVRVolume *volume, DrawActionBase *action, DVRShaderPtr shader, DVRClipper *clipper, const Vec3f &sliceDir)
void render2DMultiSlices (DVRVolume *volume, DrawActionBase *action, DVRShaderPtr shader, DVRClipper *clipper, bool btf, const Vec3f &sliceDir)
 Render Slices 2D with Multi-textures.
void render2DSliceXY (DVRVolume *volume, DrawActionBase *action, DVRShaderPtr shader, DVRClipper *clipper, const Vec3f &sliceDir, const Real32 &zCoord)
void render2DSliceXZ (DVRVolume *volume, DrawActionBase *action, DVRShaderPtr shader, DVRClipper *clipper, const Vec3f &sliceDir, const Real32 &yCoord)
void render2DSliceYZ (DVRVolume *volume, DrawActionBase *action, DVRShaderPtr shader, DVRClipper *clipper, const Vec3f &sliceDir, const Real32 &xCoord)

Private Attributes

Vec3f vertex [8]
Line edges [12]
TextureChunkPtrtexture
UInt32texStage
Int32 numTextures
Vec3f center
Real32 radius
Vec3f texTranslate
Vec3f texScale
Int32 voxSize [3]
Int32 minVox [3]
Vec3f m_lowerLeft
Vec3f m_upperRight
BrickSet::Orientation m_ori
Real32 distance
Brickprev
Bricknext
DVRSlice slice
DVRRenderSlice clippedSlice

Friends

class BrickSet


Detailed Description

Definition at line 88 of file OSGBrick.h.


Member Function Documentation

Brick * osg::Brick::getNext ( void   )  [inline]

Definition at line 13 of file OSGBrick.inl.

References next.

Referenced by osg::DVRVolume::draw().

00014 {
00015     return next;
00016 }

void osg::Brick::init ( Int32  minVoxX,
Int32  minVoxY,
Int32  minVoxZ,
Int32  resX,
Int32  resY,
Int32  resZ,
Real32  xMin,
Real32  yMin,
Real32  zMin,
Real32  xMax,
Real32  yMax,
Real32  zMax,
Int32  overlap = 1,
BrickSet::Orientation  ori = BrickSet::UNDEF 
)

! Initialize edge/vertex structure

Definition at line 601 of file OSGBrick.cpp.

References center, edges, FINFO, m_lowerLeft, m_ori, m_upperRight, minVox, radius, texScale, texTranslate, vertex, and voxSize.

Referenced by osg::BrickSet::buildBricks2D(), and osg::BrickSet::buildBricks3D().

00607 {
00608     
00609     FINFO(("Brick::init - upper left (%d, %d, %d)\n",
00610            minVoxX, minVoxY, minVoxZ));
00611 
00612     FINFO(("Brick::init (%d, %d, %d): %f %f %f -> %f %f %f \n",
00613            resX, resY, resZ, xmin, ymin, zmin, xmax, ymax, zmax));
00614 
00615     Real32 xrange = xmax - xmin;
00616     Real32 yrange = ymax - ymin;
00617     Real32 zrange = zmax - zmin;               
00618     
00619     minVox[0] = minVoxX;
00620     minVox[1] = minVoxY;
00621     minVox[2] = minVoxZ;
00622     
00623     voxSize[0] = resX;
00624     voxSize[1] = resY;
00625     voxSize[2] = resZ;
00626     
00627     m_lowerLeft  = Vec3f(xmin, ymin, zmin);
00628     m_upperRight = Vec3f(xmax, ymax, zmax);
00629     
00630     m_ori = ori;
00631     
00632     Real32 texCoorMin[3], texCoorMax[3];
00633     
00634     texCoorMin[0] = (2 * Real32(overlap) - 1) / 2.0f / Real32(resX);
00635     texCoorMin[1] = (2 * Real32(overlap) - 1) / 2.0f / Real32(resY);
00636     texCoorMin[2] = (2 * Real32(overlap) - 1) / 2.0f / Real32(resZ);
00637     
00638     texCoorMax[0] = 1 - texCoorMin[0];
00639     texCoorMax[1] = 1 - texCoorMin[1];
00640     texCoorMax[2] = 1 - texCoorMin[2];
00641     
00642     texScale = Vec3f((texCoorMax[0] - texCoorMin[0]) / xrange,
00643                      (texCoorMax[1] - texCoorMin[1]) / yrange,
00644                      (texCoorMax[2] - texCoorMin[2]) / zrange);
00645 
00646     texTranslate = Vec3f(texCoorMin[0] - texScale[0] * xmin,
00647                          texCoorMin[1] - texScale[1] * ymin,
00648                          texCoorMin[2] - texScale[2] * zmin);
00649     
00650     FINFO (("Brick::init - overlap:      %d \n", 
00651             overlap));
00652 
00653     FINFO (("Brick::init - texScale:     %f %f %f \n", 
00654             texScale[0], texScale[1], texScale[2]));
00655 
00656     FINFO (("Brick::init - texTranslate: %f %f %f \n", 
00657             texTranslate[0], texTranslate[1], texTranslate[2]));
00658     
00660     
00661     //
00662     //                         e3       
00663     //          v5 o----------------o v4
00664     //            /|               /|
00665     //           / |              / |
00666     //      e10 /  |          e9 /  |e7
00667     //         /   |   e1       /   |
00668     //     v3 o----------------o v2 |
00669     //        |    |           |    |
00670     //        |    |e6         |    |
00671     //        |e5  |           |e4  |
00672     //        |    |    e2     |    |
00673     //        |    o-----------|----o v7
00674     //        |   /  v6        |   /
00675     //        |  /             |  /
00676     //        | /e11           | /e8
00677     //        |/               |/
00678     //   y    o----------------o
00679     //   | z  v0      e0       v1
00680     //   |/
00681     //   +---x
00682                 
00683     // ------------- Initialize 8 Vertices -------------
00684 
00685     vertex[0] = Vec3f( xmin,  ymin,  zmin); 
00686     vertex[1] = Vec3f( xmax,  ymin,  zmin);
00687     vertex[2] = Vec3f( xmax,  ymax,  zmin);
00688     vertex[3] = Vec3f( xmin,  ymax,  zmin);
00689     
00690     vertex[4] = Vec3f( xmax,  ymax,  zmax);
00691     vertex[5] = Vec3f( xmin,  ymax,  zmax); 
00692     vertex[6] = Vec3f( xmin,  ymin,  zmax);
00693     vertex[7] = Vec3f( xmax,  ymin,  zmax);
00694     
00695     center = Vec3f(0.0, 0.0, 0.0);
00696 
00697     for(Int32 j = 0; j < 8; j++) 
00698     {
00699         center += vertex[j];
00700     }
00701 
00702     center /= 8.0;
00703     radius  = (vertex[0] - center).length();
00704     
00705     // -------------- Initialize 12 Edges --------------
00706 
00707     const int eindex[12][2] = 
00708     {
00709         {0, 1}, // e0
00710         {2, 3}, // e1
00711         {6, 7}, // e2
00712         {4, 5}, // e3
00713         {1, 2}, // e4
00714         {0, 3}, // e5
00715         {5, 6}, // e6
00716         {4, 7}, // e7
00717         {1, 7}, // e8
00718         {2, 4}, // e9
00719         {3, 5}, // e10
00720         {0, 6}  // e11
00721     };
00722     
00723     for(Int32 i = 0; i < 12; i++) 
00724     {
00725         edges[i] = Line(Pnt3f(vertex[eindex[i][0]]),
00726                         Pnt3f(vertex[eindex[i][1]]));
00727     }
00728     
00729 #if 0
00730     TOUT("Init Brick");
00731     TOUT("Brick (" << x << ", " << y << ", " << z << ")");
00732     TOUT(VARDUMP(nXMin) << ", " << VARDUMP(nXMax));
00733     TOUT(VARDUMP(nYMin) << ", " << VARDUMP(nYMax));
00734     TOUT(VARDUMP(nZMin) << ", " << VARDUMP(nZMax));
00735     TOUT(VARDUMP(nDataSize));
00736 #endif
00737 }

void osg::Brick::activateTexture ( DrawActionBase action  ) 

Definition at line 741 of file OSGBrick.cpp.

References FDEBUG, numTextures, texStage, and texture.

Referenced by changeFromTexture(), render2DSliceXY(), render2DSliceXZ(), render2DSliceYZ(), and render3DSlices().

00742 {
00743     for(Int32 i = 0; i < numTextures; i++) 
00744     {
00745         FDEBUG(("Brick::activateTexture - Brick: %d - Texture %d "
00746                 "- Stage: %d - ID: %d\n",
00747                 this, i, texStage[i], texture[i]->getGLId()));
00748 
00749         texture[i]->activate(action, texStage[i]);
00750     }
00751 }

void osg::Brick::changeFromTexture ( DrawActionBase action,
Brick old 
)

Definition at line 755 of file OSGBrick.cpp.

References activateTexture(), FDEBUG, numTextures, texStage, and texture.

00756 {
00757     FDEBUG(("Brick::changeFromTexture\n"));
00758     
00759     if(old == NULL)
00760         activateTexture(action);
00761     
00762     for(Int32 i = 0; i < numTextures; i++)
00763     {
00764         texture[i]->changeFrom(action, &(*(old->texture[i])), texStage[i]);
00765     }
00766 }

void osg::Brick::deactivateTexture ( DrawActionBase action  ) 

Definition at line 770 of file OSGBrick.cpp.

References numTextures, texStage, and texture.

Referenced by osg::DVRVolume::draw(), render2DSliceXY(), render2DSliceXZ(), render2DSliceYZ(), and render3DSlices().

00771 {
00772     for(Int32 i = 0; i < numTextures; i++) 
00773     {
00774         texture[i]->deactivate(action, texStage[i]);
00775     }
00776     
00777 }

void osg::Brick::renderSlices ( DVRVolume volume,
DrawActionBase action,
DVRShaderPtr  shader,
DVRClipper clipper,
TextureManager::TextureMode  mode 
)

Render 2D/3D Slices.

Definition at line 781 of file OSGBrick.cpp.

References FDEBUG, osg::Slicer::getAASlicingDirection(), osg::Slicer::getSlicingDirection(), GL_TEXTURE_3D, GLboolean, osg::Slicer::isBackToFront(), render2DMultiSlices(), render2DSlices(), render3DSlices(), SWARNING, osg::TextureManager::TM_2D, osg::TextureManager::TM_2D_Multi, and osg::TextureManager::TM_3D.

00786 {  
00787     switch (textureMode)
00788     {
00789         case TextureManager::TM_2D:
00790         {
00791             GLboolean val;
00792             glGetBooleanv(GL_TEXTURE_3D, &val);
00793 
00794             if(val != 0) 
00795             {
00796                 glDisable(GL_TEXTURE_3D);
00797                 SWARNING << "Brick::renderSlices - 3DTextures enabled "
00798                          << "-> DISABLING " 
00799                          << (int) val 
00800                          << std::endl;
00801             }
00802 
00803             Vec3f sliceDir;
00804 
00805             Slicer::getAASlicingDirection(action, &sliceDir);
00806 
00807             render2DSlices(volume, action, shader, clipper, sliceDir);
00808 
00809             break;
00810         }
00811         case TextureManager::TM_2D_Multi:
00812         {
00813             FDEBUG(("Brick::renderSlices - 2D MTex Slabs\n"));
00814 
00815             Vec3f sliceDir;
00816 
00817             Int32 dir = Slicer::getAASlicingDirection(action, &sliceDir);
00818 
00819             render2DMultiSlices(volume, action, shader, clipper,
00820                                 Slicer::isBackToFront(dir),sliceDir);
00821             break;
00822         }
00823 
00824         default:
00825         case TextureManager::TM_3D:
00826         {
00827             FDEBUG(("Brick::renderSlices -3D slices\n"));
00828 
00829             Vec3f sliceDir;
00830 
00831             Slicer::getSlicingDirection(action, &sliceDir);
00832 
00833             render3DSlices(volume, action, shader, clipper, sliceDir);
00834 
00835             break;
00836         }
00837     }
00838 }

void osg::Brick::renderBrick ( void   ) 

Render brick bounding box.

Definition at line 842 of file OSGBrick.cpp.

References FDEBUG, GL_TEXTURE_3D, and vertex.

Referenced by osg::DVRVolume::draw().

00843 {
00844     FDEBUG(("Brick::renderBrick"));
00845     
00846     const int eindex[12][2] = 
00847     {
00848         {0,1}, 
00849         {2,3}, 
00850         {6,7}, 
00851         {4,5}, 
00852         {1,2}, 
00853         {0,3}, 
00854         {5,6}, 
00855         {4,7}, 
00856         {1,7}, 
00857         {2,4}, 
00858         {3,5}, 
00859         {0,6}
00860     };
00861     
00862     glPushAttrib(GL_ENABLE_BIT | GL_CURRENT_BIT);
00863     glDisable   (GL_TEXTURE_3D);
00864     glDisable   (GL_TEXTURE_2D);
00865 
00866     glColor4f   (1.0, 0.0, 0.0, 1.0 );
00867     
00868     glBegin(GL_LINES);
00869     {
00870         for(Int32 i = 0; i < 12; i++) 
00871         {
00872             glVertex3fv(vertex[eindex[i][0]].getValues());
00873             glVertex3fv(vertex[eindex[i][1]].getValues());
00874         }
00875     }
00876     glEnd();
00877     
00878     glPopAttrib();
00879 }

void osg::Brick::vertToTex ( Real32 vx,
Real32 vy,
Real32 vz,
Real32 tx,
Real32 ty,
Real32 tz 
)

Definition at line 883 of file OSGBrick.cpp.

References texScale, and texTranslate.

00885 {
00886     *tx = *vx * texScale[0] + texTranslate[0];
00887     *ty = *vy * texScale[1] + texTranslate[1]; 
00888     *tz = *vz * texScale[2] + texTranslate[2];
00889 }

void osg::Brick::vertToTex ( Vec3f vert,
Vec3f tex 
)

Definition at line 893 of file OSGBrick.cpp.

References texScale, and texTranslate.

00894 {
00895     tex[0] = vert[0] * texScale[0] + texTranslate[0];
00896     tex[1] = vert[1] * texScale[1] + texTranslate[1];
00897     tex[2] = vert[2] * texScale[2] + texTranslate[2];
00898 };

void osg::Brick::render3DSlices ( DVRVolume volume,
DrawActionBase action,
DVRShaderPtr  shader,
DVRClipper clipper,
const Vec3f sliceDir 
) [private]

Render 3D Slices.

Definition at line 902 of file OSGBrick.cpp.

References activateTexture(), center, osg::DVRRenderSlice::clear(), clippedSlice, osg::DVRClipper::clipSlice(), deactivateTexture(), osg::DVRRenderSlice::directRender, osg::VectorInterface< ValueTypeT, StorageInterfaceT >::dot(), DVRVOLUME_PARAMETER, edges, FACE_BACK, FACE_BOTTOM, FACE_FRONT, FACE_LEFT, FACE_RIGHT, FACE_TOP, FDEBUG, osg::DVRVolumeBase::getBaseAlpha(), osg::DVRVolumeBase::getDoTextures(), osg::DVRVolumeBase::getSampling(), osg::PointInterface< ValueTypeT, StorageInterfaceT >::getValues(), osg::Plane::intersect(), osg::VectorInterface< ValueTypeT, StorageInterfaceT >::length(), osg::NullFC, osg::DVRRenderSlice::numPerVertexData, osg::DVRClipObjects::Off, osg::Plane::offset(), osg::DVRRenderSlice::orientation, osg::osgpow(), radius, osg::DVRClipper::reset(), osg::DVRSlice::resetSlice(), osg::DVRSlice::setNormal(), osg::DVRSlice::setTextureTransform(), osg::DVRSlice::setVertex(), SINFO, slice, texScale, texTranslate, and osg::DVRRenderSlice::UNDEFINED.

Referenced by renderSlices().

00907 {
00908     Int32 i, j;
00909 
00910     DVRVolumeTexturePtr tex = DVRVOLUME_PARAMETER(volume, DVRVolumeTexture);
00911 
00912     if(tex == NullFC) 
00913         return;
00914     
00915     Vec3f res            = tex->getResolution();
00916     Vec3f vox            = tex->getSliceThickness();
00917 
00918     Real32 fSampleRate    = volume->getSampling();
00919     Real32 fSliceDistance = vox.length() / 2.0f / fSampleRate;
00920     Real32 fTolerance     = fSliceDistance / 100.0f;
00921     Real32 fAlphaCorrect  = 1.f - osgpow(1.f  - volume->getBaseAlpha(), 
00922                                          1.0f / fSampleRate           );
00923     
00924     SINFO << "Sampling rate: "
00925           << fSampleRate 
00926           << " Alpha-Correction " 
00927           << fAlphaCorrect
00928           << std::endl;
00929     
00930     Vec3f diag(res[0]*vox[0], res[1]*vox[1], res[2]*vox[2]);
00931 
00932     Real32 fRadius = 0.5f * diag.length();
00933     
00934     const int ecodes[12] = 
00935     {
00936         (FACE_FRONT  + FACE_BOTTOM), // edge 0
00937         (FACE_FRONT  + FACE_TOP   ), // edge 1
00938         (FACE_BACK   + FACE_BOTTOM), // edge 2
00939         (FACE_BACK   + FACE_TOP   ), // edge 3
00940 
00941         (FACE_FRONT  + FACE_RIGHT ), // edge 4
00942         (FACE_FRONT  + FACE_LEFT  ), // edge 5
00943         (FACE_BACK   + FACE_LEFT  ), // edge 6
00944         (FACE_BACK   + FACE_RIGHT ), // edge 7
00945 
00946         (FACE_RIGHT  + FACE_BOTTOM), // edge 8
00947         (FACE_RIGHT  + FACE_TOP   ), // edge 9
00948         (FACE_TOP    + FACE_LEFT  ), // edge 10
00949         (FACE_BOTTOM + FACE_LEFT  )  // edge 11
00950     };
00951     
00952     // get the slicing normal
00953     Vec3f vecViewDir = sliceDir;
00954 
00955     Plane planeSlice(vecViewDir, -fRadius);
00956 
00957     Int32 numSlices = 1 + (Int32) (2.0f * fRadius/ fSliceDistance); 
00958     
00959     Vec3f   vecIntersections[12];
00960     Int32   nEdgeCodes[12];
00961 
00962     bool    bIntersectionUsed[12];
00963 
00964     Vec3f   vecIntersectionsSorted[12];
00965     Vec3f   vecIntersection;
00966 
00967     Int32   nSlice, numIntersections, nEdgeCode, numUsedIntersections;
00968 
00969     Vec3f   v, texscale, textrans; 
00970 
00971     texscale = texScale;
00972     textrans = texTranslate;
00973 
00974     // set the reference plane for clipping
00975     DVRClipObjectsPtr clipObjects = DVRVOLUME_PARAMETER(volume, 
00976                                                         DVRClipObjects);
00977 
00978     bool doClipping = false;
00979 
00980     if(clipObjects != NullFC)
00981     {
00982         if(clipObjects->count()       >  0                && 
00983            clipObjects->getClipMode() != DVRClipObjects::Off)
00984         {
00985             doClipping = true;
00986             clipper->reset(volume);
00987         }
00988     }
00989 
00990     slice.setTextureTransform(texScale,texTranslate);
00991 
00992     for(nSlice = 0; nSlice < numSlices; nSlice++) 
00993     {
00994         
00995         // calculate intersection with each edge
00996         numIntersections = 0;
00997 
00998         for(i = 0; i < 12; i++) 
00999         {
01000             if(planeSlice.intersect(edges[i],vecIntersection)) 
01001             {
01002                 
01003                 if((vecIntersection-center).length() <= radius) 
01004                 {
01005                     vecIntersections[numIntersections]  = vecIntersection;
01006                     nEdgeCodes[numIntersections]        = ecodes[i];
01007                     bIntersectionUsed[numIntersections] = false;
01008 
01009                     numIntersections++;
01010                 }
01011             }
01012         }
01013         
01014         // eleminate double vertices
01015         // --------------------------------------------
01016 
01017         if (numIntersections > 2) 
01018         {
01019             for(i = 0; i < numIntersections-1; i++) 
01020             {
01021                 for(j = i+1; j < numIntersections; j++) 
01022                 {
01023                     if((vecIntersections[i]-vecIntersections[j]).length() < 
01024                        fTolerance) 
01025                     {
01026                         // merge the two intersections
01027                         nEdgeCodes[i] |= nEdgeCodes[j];
01028                         // remove j
01029                         if(j < numIntersections-1) 
01030                         {
01031                             vecIntersections[j] = 
01032                                 vecIntersections[numIntersections-1];
01033                             nEdgeCodes[j] = nEdgeCodes[numIntersections-1];
01034 
01035                             // vertex j has changed, so examine the 
01036                             // vertex j again
01037                             j--; 
01038                         }
01039 
01040                         numIntersections--;
01041                     }
01042                 }
01043             }
01044         }
01045         
01046         assert(numIntersections <= 6);
01047         
01048         if(numIntersections > 2) 
01049         {
01050             
01051             //find correct sequence;
01052             vecIntersectionsSorted[0] = vecIntersections[0];
01053             bIntersectionUsed[0]      = true;
01054             numUsedIntersections      = 1;
01055               
01056             nEdgeCode = nEdgeCodes[0];
01057 
01058             // HACK need to fix the endless loop!
01059             UInt32 count = 0;
01060             while(numUsedIntersections != numIntersections && ++count <= numIntersections)
01061             {
01062                 for(Int32 i = 1; i < numIntersections; i++) 
01063                 {
01064                     if ((bIntersectionUsed[i] == false   ) && 
01065                         (nEdgeCodes[i]        & nEdgeCode)  ) 
01066                     {
01067                         vecIntersectionsSorted[numUsedIntersections] = 
01068                             vecIntersections[i];
01069 
01070                         nEdgeCode            = nEdgeCodes[i];
01071                         bIntersectionUsed[i] = true;
01072 
01073                         numUsedIntersections++;
01074                     }
01075                 }
01076             }
01077             
01078             if(doClipping)
01079             {
01080                 // check slice orientation
01081                 Vec3f sliceNormal = 
01082                     (vecIntersectionsSorted[1] -
01083                      vecIntersectionsSorted[0]).cross(
01084                          vecIntersectionsSorted[2]-vecIntersectionsSorted[1]);
01085                 
01086                 bool sliceCCW = sliceNormal.dot(sliceDir) > 0.0; 
01087                 
01088                 slice.resetSlice();
01089                 
01090                 if(sliceCCW)
01091                 {
01092                     for(Int32 i = 0; i < numIntersections; i++)
01093                     {
01094                         slice.setVertex(vecIntersectionsSorted[i]);
01095                     }
01096                 }
01097                 else
01098                 {
01099                     for(Int32 i = numIntersections-1; i >=0 ; i--)
01100                     {
01101                         slice.setVertex(vecIntersectionsSorted[i]);
01102                     }       
01103                 }
01104                 
01105                 slice.setNormal(sliceDir);
01106                 
01107                 // number of additional per vertex attributes 
01108                 // (not position + first texture coordinates)
01109 
01110                 clippedSlice.numPerVertexData = 0;
01111                 
01112                 // we use 3D textures
01113                 clippedSlice.orientation = DVRRenderSlice::UNDEFINED;
01114                 
01115                 // contours only
01116                 if(clipObjects->getDoContours())
01117                 {
01118                     deactivateTexture(action);
01119                     clipper->clipSlice(volume, 
01120                                        slice, 
01121                                        sliceDir,
01122                                        fSliceDistance * nSlice, 
01123                                        clippedSlice);
01124                     activateTexture(action);
01125                 }        
01126                 else if (shader->hasRenderCallback()) 
01127                 {
01128                     // shader managed slice rendering
01129                     
01130                     clippedSlice.directRender = false;
01131                     
01132                     clipper->clipSlice(volume, slice, 
01133                                        sliceDir,
01134                                        fSliceDistance * nSlice, 
01135                                        clippedSlice);
01136                     
01137                     shader->renderSlice(volume, action, &clippedSlice);
01138                 } 
01139                 else if (volume->getDoTextures()) 
01140                 {
01141                     // textured slices
01142                     
01143                     clippedSlice.directRender = true;
01144                     
01145                     clipper->clipSlice(volume, 
01146                                        slice, 
01147                                        sliceDir,
01148                                        fSliceDistance * nSlice, 
01149                                        clippedSlice);
01150                 }
01151                 else 
01152                 {
01153                     // untextured slices only
01154 
01155                     glColor4f(1.0, 1.0, 1.0, 1.0);
01156 
01157                     clippedSlice.directRender = true;   
01158     
01159                     clipper->clipSlice(volume, 
01160                                        slice, 
01161                                        sliceDir,
01162                                        fSliceDistance * nSlice, 
01163                                        clippedSlice);
01164                 }
01165                 clippedSlice.clear();
01166             }      
01167             else
01168             { 
01169                 // clipping disabled    
01170                 
01171                 if(shader->hasRenderCallback()) 
01172                 {
01173                     
01174                     // copy all data into a single field and 
01175                     // call rendercallback
01176 
01177                     Real32 data[12 * 6]; // numIntersections is bounded by 12
01178                     UInt32 index = 0;
01179 
01180                     for(Int32 i = 0; i < numIntersections; i++) 
01181                     {
01182                         v = vecIntersectionsSorted[i];
01183                         
01184                         data[index++] = v[0];
01185                         data[index++] = v[1];
01186                         data[index++] = v[2];
01187                         
01188                         data[index++] = v[0] * texscale[0] + textrans[0];
01189                         data[index++] = v[1] * texscale[1] + textrans[1];
01190                         data[index++] = v[2] * texscale[2] + textrans[2];
01191                     }
01192                     
01193                     shader->renderSlice(volume, 
01194                                         action, 
01195                                         data, 
01196                                         numIntersections, 
01197                                         6);
01198                 } 
01199                 else if (volume->getDoTextures()) 
01200                 {
01201                     // textured slices
01202                     
01203                     glBegin(GL_TRIANGLE_FAN);
01204                     
01205                     for(i = 0; i < numIntersections; i++) 
01206                     {
01207                         v = vecIntersectionsSorted[i];
01208                         
01209                         glColor4f(1.0, 1.0, 1.0, fAlphaCorrect);
01210 
01211                         glTexCoord3f((v[0] * texscale[0] + textrans[0]), 
01212                                      (v[1] * texscale[1] + textrans[1]) , 
01213                                      (v[2] * texscale[2] + textrans[2]));
01214                         glVertex3fv(v.getValues());
01215                         
01216                         FDEBUG(
01217                             ("Brick::render3DSlices V: %f %f %f T: %f %f %f\n",
01218                              v[0], v[1], v[2],
01219                              (v[0] * texscale[0] + textrans[0]), 
01220                              (v[1] * texscale[1] + textrans[1]), 
01221                              (v[2] * texscale[2] + textrans[2])));
01222                     }
01223 
01224                     glEnd();
01225                     
01226                 }
01227                 else 
01228                 {
01229                     // untextured slices only
01230                     
01231                     glColor4f(1.0, 1.0, 1.0, 1.0);
01232 
01233                     glBegin(GL_LINE_LOOP);
01234                     {
01235                         for(i = 0; i < numIntersections; i++) 
01236                         {
01237                             v = vecIntersectionsSorted[i];
01238 
01239                             glVertex3fv(v.getValues());
01240                         }
01241                     }                    
01242                     glEnd();
01243                 }
01244             }
01245         }
01246         
01247         // next plane
01248         planeSlice.offset(fSliceDistance);
01249     }
01250 }

void osg::Brick::render2DSlices ( DVRVolume volume,
DrawActionBase action,
DVRShaderPtr  shader,
DVRClipper clipper,
const Vec3f sliceDir 
) [private]

Definition at line 1875 of file OSGBrick.cpp.

References center, clippedSlice, m_ori, osg::DVRRenderSlice::numPerVertexData, osg::DVRRenderSlice::orientation, render2DSliceXY(), render2DSliceXZ(), render2DSliceYZ(), osg::DVRSlice::setTextureTransform(), slice, texScale, texTranslate, osg::DVRRenderSlice::XY, osg::BrickSet::XY, osg::DVRRenderSlice::XZ, osg::BrickSet::XZ, osg::DVRRenderSlice::YZ, and osg::BrickSet::YZ.

Referenced by renderSlices().

01880 {
01881     // number of additional per vertex attributes 
01882     // (not position + first texture coordinates)
01883 
01884     clippedSlice.numPerVertexData = 0;
01885 
01886     slice.setTextureTransform(texScale,texTranslate);
01887 
01888     switch(m_ori)
01889     {
01890         case BrickSet::XY:
01891             clippedSlice.orientation = DVRRenderSlice::XY;
01892             render2DSliceXY(volume,
01893                             action,
01894                             shader,
01895                             clipper,
01896                             sliceDir,
01897                             center[2]);
01898             break;
01899 
01900         case BrickSet::XZ:
01901             clippedSlice.orientation = DVRRenderSlice::XZ;
01902             render2DSliceXZ(volume,
01903                             action,
01904                             shader,
01905                             clipper,
01906                             sliceDir,
01907                             center[1]);
01908             break;
01909 
01910         case BrickSet::YZ:
01911             clippedSlice.orientation = DVRRenderSlice::YZ;
01912             render2DSliceYZ(volume,
01913                             action,
01914                             shader,
01915                             clipper,
01916                             sliceDir,
01917                             center[0]);
01918             break;
01919 
01920         default:
01921             break;
01922     }   
01923 }

void osg::Brick::render2DMultiSlices ( DVRVolume volume,
DrawActionBase action,
DVRShaderPtr  shader,
DVRClipper clipper,
bool  btf,
const Vec3f sliceDir 
) [private]

Definition at line 1927 of file OSGBrick.cpp.

References clippedSlice, DVRVOLUME_PARAMETER, FDEBUG, osg::DVRVolumeBase::getSampling(), m_lowerLeft, m_ori, m_upperRight, osg::NullFC, osg::DVRRenderSlice::numPerVertexData, osg::DVRRenderSlice::orientation, render2DSliceXY(), render2DSliceXZ(), render2DSliceYZ(), osg::DVRSlice::setTextureTransform(), SINFO, slice, texScale, texTranslate, osg::DVRRenderSlice::XY, osg::BrickSet::XY, osg::DVRRenderSlice::XZ, osg::BrickSet::XZ, osg::DVRRenderSlice::YZ, and osg::BrickSet::YZ.

Referenced by renderSlices().

01933 {
01934     DVRVolumeTexturePtr tex = DVRVOLUME_PARAMETER(volume, DVRVolumeTexture);
01935 
01936     if(tex == NullFC) 
01937         return;
01938 
01939     Vec3f  res         = tex->getResolution();
01940     Vec3f  vox         = tex->getSliceThickness();
01941 
01942     Real32 fSampleRate = volume->getSampling();
01943     
01944     Int32  dim       = 2 - m_ori; // dimension perpenticular to slice planes
01945 
01946     Real32 numSlices = res[dim] * fSampleRate;
01947 
01948     // ancor for the slices
01949     Real32 anchor    = (-res[dim] / 2.0f + 0.5f) * vox[dim]; 
01950     Real32 dist      = vox[dim] / fSampleRate;
01951 
01952     if(btf)
01953     {
01954         SINFO << "Brick::render2DMultiSlices - BTF" << std::endl;
01955 
01956         anchor = -anchor;
01957         dist   = -dist;
01958     }
01959     
01960     FDEBUG(("Brick::render2DMultiSlices - ori:       %d", m_ori));
01961     FDEBUG(("Brick::render2DMultiSlices - numSlices: %d", numSlices));
01962     
01963     // number of additional per vertex attributes 
01964     // (not position + first texture coordinates)
01965 
01966     clippedSlice.numPerVertexData = 0;
01967     
01968     Vec3f multiTexScale     = texScale;
01969     Vec3f multiTexTranslate = texTranslate;
01970     
01971     switch(m_ori)
01972     {
01973         case BrickSet::XY:
01974 
01975             clippedSlice.orientation = DVRRenderSlice::XY;
01976 
01977             // "reuse" texScale/translate for setting the interpolation 
01978             // factor whem clipping is performed
01979             multiTexScale[2] = 0.0;
01980 
01981             for(UInt32 nSlice = 0; nSlice < numSlices; nSlice++)
01982             {
01983                 if((anchor >= m_lowerLeft[2]) && (anchor < m_upperRight[2]))
01984                 {      
01985                     FDEBUG(("Slice %d: %f\n", nSlice, anchor));
01986 
01987                     multiTexTranslate[2] = anchor - m_lowerLeft[2];
01988 
01989                     slice.setTextureTransform(multiTexScale,multiTexTranslate);
01990 
01991                     render2DSliceXY(volume,
01992                                     action,
01993                                     shader,
01994                                     clipper,
01995                                     sliceDir,
01996                                     anchor);
01997                 }
01998 
01999                 // next slice
02000                 anchor += dist;
02001             }    
02002             break;
02003 
02004         case BrickSet::XZ:
02005 
02006             clippedSlice.orientation = DVRRenderSlice::XZ;
02007 
02008             multiTexScale[1] = 0.0;
02009 
02010             for(UInt32 nSlice = 0; nSlice < numSlices; nSlice++)
02011             {
02012                 if((anchor >= m_lowerLeft[1]) && (anchor < m_upperRight[1]))
02013                 {        
02014                     FDEBUG(("Slice %d: %f\n", nSlice, anchor));
02015                     // "reuse" texScale/translate for setting the 
02016                     // interpolation factor whem clipping is performed
02017 
02018                     multiTexTranslate[1] = anchor - m_lowerLeft[1];
02019 
02020                     slice.setTextureTransform(multiTexScale,multiTexTranslate);
02021 
02022                     render2DSliceXZ(volume,
02023                                     action,
02024                                     shader,
02025                                     clipper,
02026                                     sliceDir,
02027                                     anchor);
02028                 }
02029                 // next slice
02030                 anchor += dist;
02031             }
02032             break;
02033 
02034         case BrickSet::YZ:
02035 
02036             clippedSlice.orientation = DVRRenderSlice::YZ;
02037 
02038             multiTexScale[0] = 0.0;
02039 
02040             for(UInt32 nSlice = 0; nSlice < numSlices; nSlice++)
02041             {
02042                 if((anchor >= m_lowerLeft[0]) && (anchor < m_upperRight[0]))
02043                 {        
02044                     FDEBUG(("Slice %d: %f\n", nSlice, anchor));
02045                     // "reuse" texScale/translate for setting the 
02046                     // interpolation factor whem clipping is performed
02047 
02048                     multiTexTranslate[0] = anchor - m_lowerLeft[0];
02049 
02050                     slice.setTextureTransform(multiTexScale,multiTexTranslate);
02051 
02052                     render2DSliceYZ(volume,
02053                                     action,
02054                                     shader,
02055                                     clipper,
02056                                     sliceDir,
02057                                     anchor);
02058                 }
02059 
02060                 // next slice
02061                 anchor += dist;
02062             }
02063             break;
02064 
02065         default:
02066             break;
02067     }
02068 }

void osg::Brick::render2DSliceXY ( DVRVolume volume,
DrawActionBase action,
DVRShaderPtr  shader,
DVRClipper clipper,
const Vec3f sliceDir,
const Real32 zCoord 
) [private]

Definition at line 1253 of file OSGBrick.cpp.

References activateTexture(), center, osg::DVRRenderSlice::clear(), clippedSlice, osg::DVRClipper::clipSlice(), deactivateTexture(), osg::DVRRenderSlice::directRender, osg::Plane::distance(), DVRVOLUME_PARAMETER, FDEBUG, osg::DVRVolumeBase::getDoTextures(), osg::DVRClipper::getReferencePlane(), m_lowerLeft, osg::NullFC, osg::DVRClipObjects::Off, osg::DVRSlice::resetSlice(), osg::DVRSlice::setNormal(), osg::DVRSlice::setVertex(), slice, texScale, texTranslate, and vertex.

Referenced by render2DMultiSlices(), and render2DSlices().

01259 {
01260     Real32 xmin = vertex[0][0];
01261     Real32 xmax = vertex[1][0];
01262     
01263     Real32 ymin = vertex[0][1];
01264     Real32 ymax = vertex[2][1]; 
01265   
01266     // get clip objects
01267     DVRClipObjectsPtr clipObjects = DVRVOLUME_PARAMETER(volume, 
01268                                                         DVRClipObjects);
01269   
01270     // check whether clipping should be performed
01271     bool doClipping = false;  
01272     if(clipObjects != NullFC)
01273     {
01274         if(clipObjects->count()       >  0                && 
01275            clipObjects->getClipMode() != DVRClipObjects::Off)
01276         {
01277             doClipping = true;
01278         }
01279     }
01280     
01281     if(doClipping)
01282     {
01283         slice.resetSlice();
01284         
01285         if(sliceDir[2] > 0.0)
01286         {
01287             slice.setVertex(Vec3f(xmin, ymin, zCoord));
01288             slice.setVertex(Vec3f(xmax, ymin, zCoord));
01289             slice.setVertex(Vec3f(xmax, ymax, zCoord));
01290             slice.setVertex(Vec3f(xmin, ymax, zCoord));
01291         }
01292         else
01293         {
01294             slice.setVertex(Vec3f(xmin, ymax, zCoord));
01295             slice.setVertex(Vec3f(xmax, ymax, zCoord));
01296             slice.setVertex(Vec3f(xmax, ymin, zCoord));
01297             slice.setVertex(Vec3f(xmin, ymin, zCoord));
01298         }
01299 
01300         slice.setNormal(sliceDir);
01301         
01302         Real32 dist = clipper->getReferencePlane().distance(
01303             Pnt3f(center[0], center[1], zCoord)); 
01304     
01305         FDEBUG(("Brick - dist to refPlane: %f\n",dist))
01306             FDEBUG(("Brick - Brick center: %f\n",zCoord))
01307 
01308             // contours only
01309             if(clipObjects->getDoContours())
01310             {
01311                 deactivateTexture(action);
01312 
01313                 clipper->clipSlice(volume, 
01314                                    slice, 
01315                                    sliceDir,
01316                                    dist, 
01317                                    clippedSlice);
01318 
01319                 activateTexture(action);
01320             }        
01321             else if (shader->hasRenderCallback()) 
01322             {
01323                 // shader managed slice rendering
01324       
01325                 clippedSlice.directRender = false;
01326                 
01327                 clipper->clipSlice(volume, 
01328                                    slice, 
01329                                    sliceDir,
01330                                    dist, 
01331                                    clippedSlice);
01332                 
01333                 shader->renderSlice(volume, action, &clippedSlice);
01334             } 
01335             else if(volume->getDoTextures()) 
01336             {
01337                 // textured slices
01338       
01339                 clippedSlice.directRender = true;
01340                 
01341                 clipper->clipSlice(volume, slice, 
01342                                    sliceDir,dist, 
01343                                    clippedSlice);
01344             }
01345             else 
01346             {
01347                 // untextured slices only
01348 
01349                 glColor4f(1.0, 1.0, 1.0, 1.0);
01350 
01351                 clippedSlice.directRender = true;       
01352 
01353                 clipper->clipSlice(volume, 
01354                                    slice, 
01355                                    sliceDir,
01356                                    dist, 
01357                                    clippedSlice);
01358             }
01359         clippedSlice.clear();
01360     }    
01361     else 
01362     { 
01363         // clipping disabled
01364         
01365         if((shader != NullFC) && shader->hasRenderCallback()) 
01366         {
01367             // do nothing
01368         } 
01369         else if(volume->getDoTextures()) 
01370         {
01371             glBegin(GL_TRIANGLE_FAN);
01372         } 
01373         else
01374         {
01375             glColor4f(1.0, 1.0, 1.0, 1.0);
01376             glBegin(GL_LINE_LOOP);
01377         }      
01378         
01379         if((shader != NullFC) && shader->hasRenderCallback()) 
01380         {
01381             // copy all data into a single field and call rendercallback
01382       
01383             Real32 multiTexIntFactor = zCoord - m_lowerLeft[2];
01384             
01385             Real32 data[] = 
01386             {
01387                 xmin, 
01388                 ymin, 
01389                 zCoord, // first vertex
01390                 xmin * texScale[0] + texTranslate[0], 
01391                 ymin * texScale[1] + texTranslate[1], 
01392                 multiTexIntFactor,
01393 
01394                 xmax, 
01395                 ymin, 
01396                 zCoord, // second vertex
01397                 xmax * texScale[0] + texTranslate[0], 
01398                 ymin * texScale[1] + texTranslate[1], multiTexIntFactor,
01399 
01400                 xmax, 
01401                 ymax, 
01402                 zCoord, // third vertex
01403                 xmax * texScale[0] + texTranslate[0], 
01404                 ymax * texScale[1] + texTranslate[1], 
01405                 multiTexIntFactor,
01406 
01407                 xmin, 
01408                 ymax, 
01409                 zCoord, // fourth vertex
01410                 xmin * texScale[0] + texTranslate[0], 
01411                 ymax * texScale[1] + texTranslate[1], 
01412                 multiTexIntFactor
01413             };
01414             
01415             shader->renderSlice(volume, action, data, 4, 6);
01416             
01417         } 
01418         else 
01419         {
01420             glTexCoord2f(xmin * texScale[0] + texTranslate[0],
01421                          ymin * texScale[1] + texTranslate[1]);
01422 
01423             glVertex3f(xmin, ymin, zCoord);
01424             
01425 
01426             glTexCoord2f(xmax * texScale[0] + texTranslate[0],
01427                          ymin * texScale[1] + texTranslate[1]);
01428 
01429             glVertex3f(xmax, ymin, zCoord);
01430             
01431 
01432             glTexCoord2f(xmax * texScale[0] + texTranslate[0],
01433                          ymax * texScale[1] + texTranslate[1]);
01434 
01435             glVertex3f(xmax, ymax, zCoord);
01436             
01437 
01438             glTexCoord2f(xmin * texScale[0] + texTranslate[0],
01439                          ymax * texScale[1] + texTranslate[1]);
01440 
01441             glVertex3f(xmin, ymax, zCoord);
01442         }
01443         
01444         if((shader != NullFC) && shader->hasRenderCallback()) 
01445         {
01446             // do nothing
01447         } 
01448         else
01449         {
01450             glEnd();
01451         }
01452         
01453     }
01454     
01455 }

void osg::Brick::render2DSliceXZ ( DVRVolume volume,
DrawActionBase action,
DVRShaderPtr  shader,
DVRClipper clipper,
const Vec3f sliceDir,
const Real32 yCoord 
) [private]

Definition at line 1457 of file OSGBrick.cpp.

References activateTexture(), center, osg::DVRRenderSlice::clear(), clippedSlice, osg::DVRClipper::clipSlice(), deactivateTexture(), osg::DVRRenderSlice::directRender, osg::Plane::distance(), DVRVOLUME_PARAMETER, FDEBUG, osg::DVRVolumeBase::getDoTextures(), osg::DVRClipper::getReferencePlane(), m_lowerLeft, osg::NullFC, osg::DVRClipObjects::Off, osg::DVRSlice::resetSlice(), osg::DVRSlice::setNormal(), osg::DVRSlice::setVertex(), slice, texScale, texTranslate, and vertex.

Referenced by render2DMultiSlices(), and render2DSlices().

01463 {
01464     Real32 xmin = vertex[0][0];
01465     Real32 xmax = vertex[1][0];
01466     
01467     Real32 zmin = vertex[0][2];
01468     Real32 zmax = vertex[4][2]; 
01469   
01470     // get clip objects
01471     DVRClipObjectsPtr clipObjects = DVRVOLUME_PARAMETER(volume, 
01472                                                         DVRClipObjects);
01473 
01474     // check whether clipping should be performed
01475     bool doClipping = false;  
01476     if(clipObjects != NullFC)
01477     {
01478         if(clipObjects->count()       >  0                && 
01479            clipObjects->getClipMode() != DVRClipObjects::Off)
01480         {
01481             doClipping = true;
01482         }
01483     }
01484     
01485     if(doClipping)
01486     {
01487         slice.resetSlice();
01488 
01489         if(sliceDir[1] < 0.0)
01490         {
01491             slice.setVertex(Vec3f(xmin, yCoord, zmin));
01492             slice.setVertex(Vec3f(xmax, yCoord, zmin));
01493             slice.setVertex(Vec3f(xmax, yCoord, zmax));
01494             slice.setVertex(Vec3f(xmin, yCoord, zmax));
01495         }
01496         else
01497         {
01498             slice.setVertex(Vec3f(xmin, yCoord, zmax));
01499             slice.setVertex(Vec3f(xmax, yCoord, zmax));
01500             slice.setVertex(Vec3f(xmax, yCoord, zmin));
01501             slice.setVertex(Vec3f(xmin, yCoord, zmin));
01502         }
01503         
01504         slice.setNormal(sliceDir);
01505     
01506         Real32 dist = clipper->getReferencePlane().distance(
01507             Pnt3f(center[0], yCoord, center[2])); 
01508         
01509         FDEBUG(("Brick - dist to refPlane: %f\n",dist))
01510             FDEBUG(("Brick - Brick center: %f\n",yCoord))
01511             
01512             // contours only
01513             if(clipObjects->getDoContours())
01514             {
01515                 deactivateTexture(action);
01516 
01517                 clipper->clipSlice(volume, 
01518                                    slice, 
01519                                    sliceDir,
01520                                    dist, 
01521                                    clippedSlice);
01522 
01523                 activateTexture(action);
01524             }        
01525             else if(shader->hasRenderCallback()) 
01526             {
01527                 // shader managed slice rendering
01528                 
01529                 clippedSlice.directRender = false;
01530                 
01531                 clipper->clipSlice(volume, 
01532                                    slice, 
01533                                    sliceDir,
01534                                    dist, 
01535                                    clippedSlice);
01536                 
01537                 shader->renderSlice(volume, action, &clippedSlice);
01538             } 
01539             else if(volume->getDoTextures()) 
01540             {      
01541                 // textured slices
01542       
01543                 clippedSlice.directRender = true;
01544                 
01545                 clipper->clipSlice(volume, 
01546                                    slice, 
01547                                    sliceDir,
01548                                    dist, 
01549                                    clippedSlice);
01550             }
01551             else 
01552             {
01553                 // untextured slices only
01554 
01555                 glColor4f(1.0, 1.0, 1.0, 1.0);
01556 
01557                 clippedSlice.directRender = true;       
01558 
01559                 clipper->clipSlice(volume, 
01560                                    slice, 
01561                                    sliceDir,
01562                                    dist, 
01563                                    clippedSlice);
01564             }
01565         clippedSlice.clear();
01566     }    
01567     else 
01568     { 
01569         // clipping disabled
01570         
01571         if((shader != NullFC) && shader->hasRenderCallback()) 
01572         {
01573             // do nothing
01574         }
01575         else if(volume->getDoTextures()) 
01576         {
01577             glBegin(GL_TRIANGLE_FAN);
01578         }
01579         else
01580         {
01581             glColor4f(1.0, 1.0, 1.0, 1.0);
01582 
01583             glBegin(GL_LINE_LOOP);
01584         }
01585         
01586         if((shader != NullFC) && shader->hasRenderCallback()) 
01587         {
01588             // copy all data into a single field and call rendercallback
01589             
01590             Real32 multiTexIntFactor = yCoord - m_lowerLeft[1];
01591             
01592             Real32 data[] = 
01593             {
01594                 xmin, 
01595                 yCoord, 
01596                 zmin, // first vertex
01597                 xmin * texScale[0] + texTranslate[0], 
01598                 zmin * texScale[2] + texTranslate[2], 
01599                 multiTexIntFactor,
01600 
01601                 xmax, 
01602                 yCoord, 
01603                 zmin, // second vertex
01604                 xmax * texScale[0] + texTranslate[0], 
01605                 zmin * texScale[2] + texTranslate[2], 
01606                 multiTexIntFactor,
01607 
01608                 xmax, 
01609                 yCoord, 
01610                 zmax, // third vertex
01611                 xmax * texScale[0] + texTranslate[0], 
01612                 zmax * texScale[2] + texTranslate[2], 
01613                 multiTexIntFactor,
01614 
01615                 xmin, 
01616                 yCoord, 
01617                 zmax, // fourth vertex
01618                 xmin * texScale[0] + texTranslate[0], 
01619                 zmax * texScale[2] + texTranslate[2], 
01620                 multiTexIntFactor
01621             };
01622                  
01623             shader->renderSlice(volume, action, data, 4, 6);
01624         } 
01625         else 
01626         {
01627             FDEBUG(("XZ render2dslice (texcoor): %f %f\n",
01628                     xmin * texScale[0] + texTranslate[0],
01629                     zmin * texScale[2] + texTranslate[2]));       
01630 
01631             glTexCoord2f(xmin * texScale[0] + texTranslate[0],
01632                          zmin * texScale[2] + texTranslate[2]);
01633         
01634             glVertex3f(xmin, yCoord, zmin);
01635             
01636             
01637             glTexCoord2f(xmax * texScale[0] + texTranslate[0],
01638                          zmin * texScale[2] + texTranslate[2]);
01639 
01640             glVertex3f(xmax, yCoord, zmin);
01641             
01642 
01643             glTexCoord2f(xmax * texScale[0] + texTranslate[0],
01644                          zmax * texScale[2] + texTranslate[2]);
01645 
01646             glVertex3f(xmax, yCoord, zmax);
01647             
01648 
01649             glTexCoord2f(xmin * texScale[0] + texTranslate[0],
01650                          zmax * texScale[2] + texTranslate[2]);
01651 
01652             glVertex3f(xmin, yCoord, zmax);
01653         }
01654         
01655         if((shader != NullFC) && shader->hasRenderCallback()) 
01656         {
01657             // do nothing
01658         } 
01659         else
01660         {
01661             glEnd();
01662         }
01663     }
01664 }

void osg::Brick::render2DSliceYZ ( DVRVolume volume,
DrawActionBase action,
DVRShaderPtr  shader,
DVRClipper clipper,
const Vec3f sliceDir,
const Real32 xCoord 
) [private]

Definition at line 1666 of file OSGBrick.cpp.

References activateTexture(), center, osg::DVRRenderSlice::clear(), clippedSlice, osg::DVRClipper::clipSlice(), deactivateTexture(), osg::DVRRenderSlice::directRender, osg::Plane::distance(), DVRVOLUME_PARAMETER, FDEBUG, osg::DVRVolumeBase::getDoTextures(), osg::DVRClipper::getReferencePlane(), m_lowerLeft, osg::NullFC, osg::DVRClipObjects::Off, osg::DVRSlice::resetSlice(), osg::DVRSlice::setNormal(), osg::DVRSlice::setVertex(), slice, texScale, texTranslate, and vertex.

Referenced by render2DMultiSlices(), and render2DSlices().

01672 {  
01673     Real32 ymin = vertex[0][1];
01674     Real32 ymax = vertex[2][1]; 
01675     
01676     Real32 zmin = vertex[0][2];
01677     Real32 zmax = vertex[4][2]; 
01678   
01679     // get clip objects
01680     DVRClipObjectsPtr clipObjects = DVRVOLUME_PARAMETER(volume, 
01681                                                         DVRClipObjects);
01682   
01683     // check whether clipping should be performed
01684     bool doClipping = false;  
01685 
01686     if(clipObjects != NullFC)
01687     {
01688         if(clipObjects->count()       >  0                && 
01689            clipObjects->getClipMode() != DVRClipObjects::Off)
01690         {
01691             doClipping = true;
01692         }
01693     }
01694     
01695     if(doClipping)
01696     {
01697         
01698         slice.resetSlice();
01699         
01700         if(sliceDir[0] > 0.0)
01701         {
01702             slice.setVertex(Vec3f(xCoord, ymin, zmin));
01703             slice.setVertex(Vec3f(xCoord, ymax, zmin));
01704             slice.setVertex(Vec3f(xCoord, ymax, zmax));
01705             slice.setVertex(Vec3f(xCoord, ymin, zmax));
01706         }
01707         else
01708         {
01709             slice.setVertex(Vec3f(xCoord, ymin, zmax));
01710             slice.setVertex(Vec3f(xCoord, ymax, zmax));
01711             slice.setVertex(Vec3f(xCoord, ymax, zmin));
01712             slice.setVertex(Vec3f(xCoord, ymin, zmin));
01713         }
01714     
01715         slice.setNormal(sliceDir);
01716     
01717         Real32 dist = clipper->getReferencePlane().distance(
01718             Pnt3f(xCoord,center[1],center[2])); 
01719         
01720         FDEBUG(("Brick - dist to refPlane: %f\n",dist))
01721             FDEBUG(("Brick - Brick center: %f\n",xCoord))
01722             
01723             // contours only
01724             if(clipObjects->getDoContours())
01725             {
01726                 deactivateTexture(action);
01727 
01728                 clipper->clipSlice(volume, 
01729                                    slice, 
01730                                    sliceDir,
01731                                    dist, 
01732                                    clippedSlice);
01733 
01734                 activateTexture(action);
01735             }        
01736             else if(shader->hasRenderCallback()) 
01737             {
01738                 // shader managed slice rendering
01739                 
01740                 clippedSlice.directRender = false;
01741                 
01742                 clipper->clipSlice(volume, 
01743                                    slice, 
01744                                    sliceDir,
01745                                    dist, 
01746                                    clippedSlice);
01747                 
01748                 shader->renderSlice(volume, action, &clippedSlice);
01749                 
01750             } 
01751             else if (volume->getDoTextures()) 
01752             {     
01753                 // textured slices
01754                 
01755                 clippedSlice.directRender = true;
01756                 
01757                 clipper->clipSlice(volume, 
01758                                    slice, 
01759                                    sliceDir,
01760                                    dist, 
01761                                    clippedSlice);
01762             }
01763             else 
01764             {
01765                 // untextured slices only
01766 
01767                 glColor4f(1.0, 1.0, 1.0, 1.0);
01768 
01769                 clippedSlice.directRender = true;       
01770 
01771                 clipper->clipSlice(volume, 
01772                                    slice, 
01773                                    sliceDir,
01774                                    dist, 
01775                                    clippedSlice);
01776             }
01777         clippedSlice.clear();
01778     }    
01779     else 
01780     { 
01781         // clipping disabled
01782 
01783         if((shader != NullFC) && shader->hasRenderCallback()) 
01784         {
01785             // do nothing
01786         } 
01787         else if (volume->getDoTextures()) 
01788         {
01789             glBegin(GL_TRIANGLE_FAN);
01790         } 
01791         else 
01792         {
01793             glColor4f(1.0, 1.0, 1.0, 1.0);
01794 
01795             glBegin(GL_LINE_LOOP);
01796         }
01797 
01798         if((shader != NullFC) && shader->hasRenderCallback()) 
01799         {
01800             // copy all data into a single field and call render callback
01801             
01802             Real32 multiTexIntFactor = xCoord - m_lowerLeft[0];
01803             
01804             Real32 data[] = 
01805             { 
01806                 xCoord, 
01807                 ymin, 
01808                 zmin,
01809                 ymin * texScale[1] + texTranslate[1], 
01810                 zmin * texScale[2] + texTranslate[2], 
01811                 multiTexIntFactor,
01812 
01813                 xCoord, 
01814                 ymax, 
01815                 zmin,
01816                 ymax * texScale[1] + texTranslate[1], 
01817                 zmin * texScale[2] + texTranslate[2], 
01818                 multiTexIntFactor,
01819 
01820                 xCoord, 
01821                 ymax, 
01822                 zmax,
01823                 ymax * texScale[1] + texTranslate[1], 
01824                 zmax * texScale[2] + texTranslate[2], 
01825                 multiTexIntFactor,
01826 
01827                 xCoord, 
01828                 ymin, 
01829                 zmax,
01830                 ymin * texScale[1] + texTranslate[1], 
01831                 zmax * texScale[2] + texTranslate[2], 
01832                 multiTexIntFactor
01833             };
01834                  
01835             shader->renderSlice(volume, action, data, 4, 6);
01836         } 
01837         else 
01838         {
01839             glTexCoord2f(ymin * texScale[1] + texTranslate[1],
01840                          zmin * texScale[2] + texTranslate[2]);
01841 
01842             glVertex3f(xCoord, ymin, zmin);
01843             
01844 
01845             glTexCoord2f(ymax * texScale[1] + texTranslate[1],
01846                          zmin * texScale[2] + texTranslate[2]);
01847 
01848             glVertex3f(xCoord, ymax, zmin);
01849             
01850 
01851             glTexCoord2f(ymax * texScale[1] + texTranslate[1],
01852                          zmax * texScale[2] + texTranslate[2]);
01853 
01854             glVertex3f(xCoord, ymax, zmax);
01855 
01856             
01857             glTexCoord2f(ymin * texScale[1] + texTranslate[1],
01858                          zmax * texScale[2] + texTranslate[2]);
01859 
01860             glVertex3f(xCoord, ymin, zmax);
01861         }
01862         
01863         if((shader != NullFC) && shader->hasRenderCallback()) 
01864         {
01865             // do nothing
01866         } 
01867         else
01868         {
01869             glEnd();
01870         }
01871     }
01872 }


Friends And Related Function Documentation

friend class BrickSet [friend]

Definition at line 191 of file OSGBrick.h.


Member Data Documentation

Vec3f osg::Brick::vertex[8] [private]

Definition at line 127 of file OSGBrick.h.

Referenced by init(), render2DSliceXY(), render2DSliceXZ(), render2DSliceYZ(), and renderBrick().

Line osg::Brick::edges[12] [private]

Definition at line 128 of file OSGBrick.h.

Referenced by init(), and render3DSlices().

Definition at line 133 of file OSGBrick.h.

Referenced by init(), and render3DSlices().

Int32 osg::Brick::voxSize[3] [private]

Definition at line 136 of file OSGBrick.h.

Referenced by osg::BrickSet::buildBrickTextures(), and init().

Int32 osg::Brick::minVox[3] [private]

Definition at line 137 of file OSGBrick.h.

Referenced by osg::BrickSet::buildBrickTextures(), and init().

Definition at line 139 of file OSGBrick.h.

Referenced by init(), and render2DMultiSlices().

Definition at line 140 of file OSGBrick.h.

Referenced by init(), render2DMultiSlices(), and render2DSlices().

Definition at line 143 of file OSGBrick.h.

Referenced by osg::BrickSet::sortBricks3D().

Brick* osg::Brick::prev [private]

Definition at line 144 of file OSGBrick.h.

Referenced by osg::BrickSet::sortBricks2D(), and osg::BrickSet::sortBricks3D().

Brick* osg::Brick::next [private]

Definition at line 145 of file OSGBrick.h.

Referenced by getNext(), osg::BrickSet::sortBricks2D(), and osg::BrickSet::sortBricks3D().


The documentation for this class was generated from the following files:

Generated on Mon Mar 17 11:14:03 2008 for OpenSG by  doxygen 1.5.5