Exemplo n.º 1
0
//! set the bounding volume of the node
void DVRVolume::adjustVolume(Volume &volume)
{
    volume.setValid();
    volume.setEmpty();
    
    DVRVolumeTexturePtr tex = DVRVOLUME_PARAMETER(this, DVRVolumeTexture);

    if (tex != NullFC) 
    {
        const Vec3f & res   = tex->getResolution    ();
        const Vec3f & slice = tex->getSliceThickness();
    
        Vec3f minBB(-0.5f * res[0] * slice[0],
                    -0.5f * res[1] * slice[1],
                    -0.5f * res[2] * slice[2]);

        Vec3f maxBB(-minBB);
    
        volume.extendBy(minBB);
        volume.extendBy(maxBB);
    }    
    else 
    {
        // something wrong with initialization - show boundingbox either
        Vec3f minBB(-0.5, -0.5, -0.5);
        Vec3f maxBB( 0.5,  0.5,  0.5);
        
        volume.extendBy(minBB);
        volume.extendBy(maxBB);
    }
}
Exemplo n.º 2
0
void DVRVolume::initializeClipObjects(      DrawActionBase *action, 
                                      const Matrix         &volumeToWorld)
{
    DVRClipObjectsPtr clipObjects = DVRVOLUME_PARAMETER(this, DVRClipObjects);
  
    if(clipObjects                != NullFC && 
       clipObjects->getClipMode() != DVRClipObjects::Off)
    {
        
        DVRVolumeTexturePtr tex = DVRVOLUME_PARAMETER(this, DVRVolumeTexture);

        if(tex != NullFC) 
        {
            const Vec3f &res   = tex->getResolution();
            const Vec3f &slice = tex->getSliceThickness();
            
            Vec3f diag(res[0] * slice[0], 
                       res[1] * slice[1], 
                       res[2] * slice[2]);
            
            Vec3f sliceDir;
            
            if(getShader()->useMTSlabs())
            {
                Slicer::getAASlicingDirection(action,&sliceDir);
            }
            else
            {  
                switch (getTextures2D()) 
                {
                    case 0: // 3D textures
                        Slicer::getSlicingDirection(action, &sliceDir);    
                        break;

                    case 1: // 2D textures  
                        Slicer::getAASlicingDirection(action, &sliceDir);
                        break;

                    default: // auto
                        Window *window = action->getWindow();

                        if(window->hasExtension(_extTex3D))
                            Slicer::getSlicingDirection(action, &sliceDir);
                        else
                            Slicer::getAASlicingDirection(action, &sliceDir);
                }
            }
            
            Plane clipReferencePlane(sliceDir, -0.5f * diag.length());  
            
            clipObjects->initialize(volumeToWorld, clipReferencePlane);

            clipper.setReferencePlane(clipReferencePlane);
        }
    }
}