#ifndef VLI_H #define VLI_H /**************************************************************************** * * vli.h $Revision: 1.112 $ $Date: 2000/05/19 16:50:44 $ * * Purpose: * This is a single header file that includes all VLI objects. * * VLI (Volume Library Interface) 1.0 provides a software interface * to the VolumePro500 Hardware. See http://www.rtviz.com * if the Online help has not been installed. * * Copyright: * Copyright, Mitsubishi Electric Information Technology Center * America, Inc., 1998, 1999. All rights reserved. * *************************************************************************/ #include /**************************************************************************** * * This section defines types used throughout VLI. * ****************************************************************************/ #define kVLIMajorVersion 1 #define kVLIMinorVersion 0 typedef char VLIint8; typedef short VLIint16; typedef long VLIint32; typedef unsigned char VLIuint8; typedef unsigned short VLIuint16; typedef unsigned long VLIuint32; #ifdef WIN32 typedef unsigned __int64 VLIuint64; #else typedef unsigned long long VLIuint64; #endif typedef float VLIfloat32; typedef double VLIfloat64; typedef int VLIbool; #define VLIfalse 0 #define VLItrue (!VLIfalse) // Different voxel formats const VLIuint32 kVLIVoxelFormatUINT8 = 0x00020000; const VLIuint32 kVLIVoxelFormatUINT12L = 0x01030000; const VLIuint32 kVLIVoxelFormatUINT12U = 0x01040000; // number of rendering buffers const int kVLIMaxRenderBuffers = 16; typedef VLIuint32 VLIPixel; // Enum to define all the errors in VLI enum VLIStatus { // Successful kVLIOK = 0, kVLIMultiPass, kVLITimeout, // Not successful kVLIErrAlloc = 1001, // Could not allocate a needed resource kVLIErrVolumeInvalid, // Volume is incorrect; generally means volume has no data storage kVLIErrMath, // Math error such as divide by zero kVLIErrArgument, // Argument value is incorrect kVLIErrUnimplemented, // Reserved for future kVLIErrTooMany, // Attempting to add too many objects to a context (CutPlanes) kVLIErrTooLarge, // Volume is too large to map or lock kVLIErrDuplicate, // Attempting to add a duplicate object to a context kVLIErrNoHardware, // No Volume Graphics hardware is present kVLIErrReadOnly, // Cannot satisfy 'write' request because volume is read-only kVLIErrAccess, // Cannot currently satisfy access request because of current access usage kVLIErrAborted, // Rendering process was aborted kVLIErrBasePlaneAllocation, // Out of pixel buffers kVLIErrBasePlaneTooLarge, // BasePlane is too large for graphics board kVLIErrHardware, // Undetermined hardware error kVLIErrInternal, // Internal error kVLIErrIDRollover, // Internal IDs have maxxed out. Exit all VLI apps, then try again. kVLIErrVersion, // Application was built against another version of the library kVLIErrMaxAngleDeviation // view angle workaround failed }; inline VLIbool VLIFailed(VLIStatus inStatus) { return inStatus >= kVLIErrAlloc; } inline VLIbool VLISucceeded(VLIStatus inStatus) { return inStatus < kVLIErrAlloc; } // Pixel Formats supported in VLI enum VLIPixelFormat { kVLIPixelFormatRGBA8 = 1, kVLIPixelFormatBGRA8, kVLIPixelFormatARGB8, kVLIPixelFormatABGR8, kVLIPixelFormatRGBA4, kVLIPixelFormatBGRA4, kVLIPixelFormatARGB4, kVLIPixelFormatABGR4, kVLIPixelFormatRGB5A1, kVLIPixelFormatBGR5A1, kVLIPixelFormatA1RGB5, kVLIPixelFormatA1BGR5, kVLIPixelFormatR5G6B5, kVLIPixelFormatB5G6R5, kVLIPixelFormatRGBA = kVLIPixelFormatRGBA8, kVLIFirstPixelFormat = kVLIPixelFormatRGBA8, kVLILastPixelFormat = kVLIPixelFormatB5G6R5 }; enum VLIBlendMode { kVLIBlendMIP = 3UL, // Maximum Intensity Projection kVLIBlendMINIP = 2UL, // MINimum Intensity Projection kVLIBlendFTB = 0UL // Front to back, standard blending method }; enum VLICoordinateSpace { kVLIObjectSpace, // Object/Volume space kVLICameraSpace, kVLIWorldSpace, // World Space kVLIBasePlaneSpace }; enum VLIAccessType { kVLIAccessNoControl, // No readers or writers kVLIAccessReadExclusive, // One reader, no writers kVLIAccessReadShared, // Multiple readers, no writers kVLIAccessWrite, // Internal use only kVLIAccessWriteExclusive, // No readers, one writer kVLIAccessWriteShared // Multiple readers, multiple writers DANGEROUS!! }; typedef VLIuint32 VLIRGBAPacked; #define VLIPackRGBA(r,g,b,a) (((r)<<24)|((g)<<16)|((b)<<8)|(a)) #define VLIGetRed(packed) (VLIuint8)(((packed)>>24)&0xff) #define VLIGetGreen(packed) (VLIuint8)(((packed)>>16)&0xff) #define VLIGetBlue(packed) (VLIuint8)(((packed)>>8)&0xff) #define VLIGetAlpha(packed) (VLIuint8)((packed)&0xff) // The following is needed to generate WIN dll #if defined(WIN32) # ifdef VLI_MAKE_DLL # define VLIEXPORT __declspec( dllexport ) # else # define VLIEXPORT __declspec( dllimport ) # endif #endif #ifdef unix # undef VLIEXPORT # define VLIEXPORT #endif /*************************************************************************** * * Global functions that handle system initialization * and configuration. * **************************************************************************/ #define VLIOpen() VLIOpenInternal(kVLIMajorVersion,kVLIMinorVersion) VLIEXPORT VLIStatus VLIOpenInternal(int majorVersion, int minorVersion); VLIEXPORT void VLIClose(void); VLIEXPORT VLIStatus VLISetEpsilon(double inEpsilon); VLIEXPORT double VLIGetEpsilon(void); VLIEXPORT void VLISetParameter(const char *name, VLIuint64 value); VLIEXPORT VLIuint64 VLIGetParameter(const char *name); /**************************************************************************** * * This section describes the VLIVector2D class/object. * This is subset of the vector3 class from the graphics gems * vector math library. * ****************************************************************************/ class VLIEXPORT VLIVector2D { public: VLIVector2D(void); VLIVector2D(const VLIVector2D& v); VLIVector2D(double x, double y); VLIVector2D(const double [2]); VLIVector2D(const float [2]); // properties, sets and gets VLIVector2D& Assign(double x, double y); VLIVector2D& Assign(const double [2]); VLIVector2D& Assign(const float [2]); VLIVector2D& operator = (const VLIVector2D& v); // array access // double& X(void); double& Y(void); double& operator [](int); const double& operator [](int) const; // math operators // VLIVector2D& operator +=(const VLIVector2D&); VLIVector2D& operator -=(const VLIVector2D&); VLIVector2D& operator *=(double); VLIVector2D& operator /=(double); VLIVector2D operator +(const VLIVector2D&) const; VLIVector2D operator -(const VLIVector2D&) const; VLIVector2D operator -(void) const; VLIVector2D operator *(double) const; VLIVector2D operator /(double) const; VLIEXPORT friend VLIVector2D operator *(double, const VLIVector2D&); VLIbool operator ==(const VLIVector2D&) const; VLIbool operator !=(const VLIVector2D&) const; // operations // double Length(void) const; double LengthSquared(void) const; VLIVector2D& Normalize(double to=1.0); void CopyTo(double *x, double *y) const; void CopyTo(float [2]) const; void CopyTo(double [2]) const; double Dot(const VLIVector2D&) const; VLIEXPORT friend double VLIDot(const VLIVector2D&, const VLIVector2D&); VLIEXPORT friend double VLIDistance(const VLIVector2D&, const VLIVector2D&); VLIEXPORT friend double VLIDistanceSquared(const VLIVector2D&, const VLIVector2D&); // output // VLIEXPORT friend ostream & operator << ( ostream &, const VLIVector2D & ); protected: double m_v[2]; }; /**************************************************************************** * * This section describes VLIVector3D objects. It is mostly a subset * of the vector3 class from the graphics gems vector math library. * ***************************************************************************/ class VLIEXPORT VLIVector3D { public: // Constructors VLIVector3D(void); // creates a zero length vector VLIVector3D(const VLIVector3D& inVec); VLIVector3D(double inX, double inY, double inZ); VLIVector3D(const double [3]); VLIVector3D(const float [3]); // Setting the value VLIVector3D& Assign(double x, double y, double z); VLIVector3D& Assign(const double [3]); VLIVector3D& Assign(const float [3]); VLIVector3D& operator = (const VLIVector3D& inVec); // Access, either read or write double& X(void); // allows modification on the fly: v->X() += 1.1; etc double& Y(void); double& Z(void); double& operator [](int); const double& operator [](int) const; // Reading out the value void CopyTo(float* outX, float* outY, float* outZ) const; void CopyTo(double* outX, double* outY, double* outZ) const; void CopyTo(float outArray[3]) const; void CopyTo(double outArray[3]) const; // math operators VLIVector3D& operator +=(const VLIVector3D&); VLIVector3D& operator -=(const VLIVector3D&); VLIVector3D& operator *=(double); VLIVector3D& operator /=(double); VLIVector3D operator +(const VLIVector3D&) const; VLIVector3D operator -(const VLIVector3D&) const; VLIVector3D operator -(void) const; VLIVector3D operator *(double) const; VLIVector3D operator /(double) const; VLIEXPORT friend VLIVector3D operator *(double, const VLIVector3D&); VLIbool operator ==(const VLIVector3D&) const; VLIbool operator !=(const VLIVector3D&) const; // operations double Length(void) const; double LengthSquared(void) const; VLIVector3D& Normalize(double to=1.0); double Dot(const VLIVector3D& inV) const; VLIEXPORT friend double VLIDot(const VLIVector3D& inA, const VLIVector3D& inB); VLIEXPORT friend VLIVector3D VLICross(const VLIVector3D& inA, const VLIVector3D& inB); VLIEXPORT friend double VLIDistance(const VLIVector3D& inA, const VLIVector3D& inB); VLIEXPORT friend double VLIDistanceSquared(const VLIVector3D& inA, const VLIVector3D& inB); // output VLIEXPORT friend ostream & operator << ( ostream &, const VLIVector3D & ); protected: double m_v[3]; }; /*************************************************************************** * * This section defines a 4x4 matrix class. * ***************************************************************************/ class VLIEXPORT VLIMatrix { public: VLIMatrix (void); // creates an identity matrix VLIMatrix (const VLIMatrix&); // Copy constructor // The array constructors take in column major form, //the same as in OpenGL // 0, 4, 8, 12 // 1, 5, 9, 13 // 2, 6, 10, 14 // 3, 7, 11, 15 VLIMatrix (const double inArray[16]); VLIMatrix (const float inArray[16]); // Constructor to specify by individual elements. // Elements are passed in row by row. VLIMatrix ( double in00, double in01, double in02, double in03, double in10, double in11, double in12, double in13, double in20, double in21, double in22, double in23, double in30, double in31, double in32, double in33); ~VLIMatrix(void); // Same order as OpenGL VLIMatrix& Assign(const double inArray[16]); VLIMatrix& Assign(const float inArray[16]); // Assignment from individual elements. // Elements are passed in row by row. VLIMatrix& Assign ( double in00, double in01, double in02, double in03, double in10, double in11, double in12, double in13, double in20, double in21, double in22, double in23, double in30, double in31, double in32, double in33); void CopyTo (double outArray[16]) const; void CopyTo (float outArray[16]) const; void TransformPoint (const VLIVector3D& in, VLIVector3D& out) const; void TransformVector (const VLIVector3D& in, VLIVector3D& out) const; // Array access double* operator [](int); const double* operator [](int) const; VLIMatrix& operator *=(const VLIMatrix&); VLIMatrix operator *(const double) const; VLIMatrix operator *(const VLIMatrix&) const; VLIMatrix& operator =(const VLIMatrix&); VLIbool operator ==(const VLIMatrix&) const; VLIbool operator !=(const VLIMatrix&) const; VLIEXPORT friend VLIMatrix operator *(const double, const VLIMatrix&); // Transpose the 4x4 Matrix VLIMatrix Transpose(void) const; VLIMatrix Inverse (void) const; double Determinant(void) const; VLIMatrix Adjoint(void) const; VLIbool IsSingular (void) const; static VLIMatrix Identity (void); static VLIMatrix Rotate(double inDegrees, const VLIVector3D& inAxis); static VLIMatrix Scale (double inSx, double inSy, double inSZ); static VLIMatrix Translate (double inTx, double inTy, double inTZ); static VLIMatrix LookAt (const VLIVector3D& inEye, const VLIVector3D& inAim, const VLIVector3D& inUp); VLIEXPORT friend ostream & operator << ( ostream &, const VLIMatrix & ); private: // This is what is compatible with OpenGL // 0, 4, 8, 12 // 1, 5, 9, 13 // 2, 6, 10, 14 // 3, 7, 11, 15 double m_matrix[4][4]; }; /**************************************************************************** * * This section describes the VLICamera class that manages * the view transformation. * ***************************************************************************/ class VLIEXPORT VLICamera { public: // default constructor creates a camera at (0,0,1) with // aim (0,0,0) and up vector (0,1,0). VLICamera (void); VLICamera (const VLIMatrix& inMatrix); virtual ~VLICamera(void); // Get and set the view matrix. VLIMatrix GetViewMatrix (void) const; VLIStatus SetViewMatrix (const VLIMatrix& inMatrix); // used to bound volume being rendered. Useful only // if a small section of a large volume is in the // viewport. void GetViewport( double& outWidth, double& outHeight ); VLIStatus SetViewport( double inWidth, double inHeight ); private: VLIMatrix m_matrix; VLIfloat64 m_viewportWidth; VLIfloat64 m_viewportHeight; friend class VLIContextInternal; }; /************************************************************************** * * This section describes the VLIConfiguration class that encapsulates * the hardware and software configuration. * ***************************************************************************/ class VLIEXPORT VLIConfiguration { public: VLIConfiguration (void) ; virtual ~VLIConfiguration (void); // Major and Minor versions of the boards int GetBoardMajorVersion (void) const; int GetBoardMinorVersion (void) const; // Get the number of boards installed in the system int GetNumberOfBoards (void) const; VLIuint32 GetAvailableMemory (int inIthBoard) const; int GetMaxCutPlanes (void) const; // Major and minor VLI version info int GetVLIMajorVersion(void) const; int GetVLIMinorVersion(void) const; int GetGradientTableLength(void) const; void GetMaxLockedSize(unsigned int inFormat, unsigned int &outNx, unsigned int &outNy, unsigned int &outNz); void GetMaxMappedSize(unsigned int inFormat, unsigned int &outNx, unsigned int &outNy, unsigned int &outNz); private: int m_boardMajorVersion; int m_boardMinorVersion; int m_nCutPlanes; int m_gradientTableLength; unsigned int m_maxMappedSize[3]; unsigned int m_maxLockedSize[3]; int m_nBoards; VLIuint32 *m_availableMemory; }; /*************************************************************************** * * This section describes the VLICrop class/object. * ***************************************************************************/ class VLIEXPORT VLICrop { public: enum Flags { kDisable = 0, kEnableX0 = 0x1, kEnableY0 = 0x2, kEnableZ0 = 0x4, kInvert0 = 0x8, kEnableX1 = 0x10, kEnableY1 = 0x20, kEnableZ1 = 0x40, kInvert1 = 0x80, kEnableX2 = 0x100, kEnableY2 = 0x200, kEnableZ2 = 0x400, kInvert2 = 0x800, kOrSelect = 0x1000, kInvertOutput = 0x2000, kSubVolume = kEnableX0|kEnableY0|kEnableZ0, k3DCross = kEnableX0|kEnableY0|kEnableY1|kEnableZ1|kEnableX2|kEnableZ2|kOrSelect, k3DCrossInvert = k3DCross|kInvertOutput, k3DFence = kEnableX0|kEnableY1|kEnableZ2|kOrSelect, k3DFenceInvert = k3DFence|kInvertOutput }; // Constructors VLICrop (void); // The default constructor creates a disabled crop object VLICrop (double inMinX, double inMaxX, double inMinY, double inMaxY, double inMinZ, double inMaxZ, int inFlags = kSubVolume); // Destructor ~VLICrop (void); // Get and set the 3 slabs (slabX, slabY, slabZ) void GetSlabs ( double& outMinX, double& outMaxX, double& outMinY, double& outMaxY, double& outMinZ, double& outMaxZ) const; VLIStatus SetSlabs ( double inMinX, double inMaxX, double inMinY, double inMaxY, double inMinZ, double inMaxZ); VLIStatus SetXSlab(double inMinX, double inMaxX); VLIStatus SetYSlab(double inMinY, double inMaxY); VLIStatus SetZSlab(double inMinZ, double inMaxZ); // Set the flags for cropping int GetFlags (void) const; VLIStatus SetFlags (int inFlags); private: double m_minX; /* X position of minimum YZ crop plane */ double m_minY; /* Y position of minimum XZ crop plane */ double m_minZ; /* Z position of minimum XY crop plane */ double m_maxX; /* X position of maximum YZ crop plane */ double m_maxY; /* Y position of maximum XZ crop plane */ double m_maxZ; /* Z position of maximum XY crop plane */ unsigned int m_configuration; /* how planes are combined to form crop volume */ }; /*************************************************************************** * * This section describes the VLICutPlane class/object. * ****************************************************************************/ class VLIEXPORT VLICutPlane { public: enum Flags { kInside = 0, kOutside = 1 }; // Create an instance of a cutplane static VLICutPlane *Create (double inA, double inB, double inC, double inD, double inOffset, double inFallOff = 0.0, Flags inFlags = kInside); // Get and set the cutplane coefficients void GetPlane (double& outA, double& outB, double& outC, double& outD) const; VLIStatus SetPlane (double inA, double inB, double inC, double inD); // Get and set the thickness double GetThickness (void) const; VLIStatus SetThickness (double inThickness ); // Falloff region in which opacity ramps down to zero double GetFallOff (void) const; VLIStatus SetFallOff (double inFallOff); // Get and set flags Flags GetFlags (void) const; VLIStatus SetFlags (Flags inFlags); int Release(void); int AddRef(void); public: // a field for application. Except for initializing it to null, // VLI does not change or reference it. void *m_appData; }; /**************************************************************************** * * This section describes the VLIGraphicsContext abstract class/object. * ****************************************************************************/ class VLIContext; class VLIEXPORT VLIGraphicsContext { public: enum InfoType { kView = 1, kLight = 2, kCutPlane = 4, kMaterial = 8, kAll = (kView|kLight|kCutPlane|kMaterial) }; virtual int TransferBasePlane( int inBuffer, unsigned int inNx, unsigned int inNy, unsigned int inIX, unsigned int inIY, VLIPixel *inBasePlane)=0; virtual int ImportAttributesToVLIContext ( VLIContext& inContext, InfoType inFlags)=0; virtual int GetTextureMemoryAddress( int inBuffer, unsigned inNX, unsigned inNY, unsigned int& outStride, unsigned &outFormat, void *& outAddress, unsigned int outBusAddress[2])=0; virtual int RenderHexagon (int inBuffer, VLIVector3D inGeomHex[6], VLIVector2D inTexHex[6])=0; virtual VLIPixelFormat GetPixelFormat(void) const; virtual int SetPixelFormat(VLIPixelFormat inFormat); protected: VLIGraphicsContext (void); private: VLIPixelFormat m_pixelFormat; }; /**************************************************************************** * * This section describes the VLILight class/object. * ****************************************************************************/ class VLIEXPORT VLILight { private: // statics used to initialize data. const static VLIVector3D sNegativeZ; public: static VLILight* CreateDirectional( const VLIVector3D& inDirection = sNegativeZ, double inIntensity = 1.0); // Accessor functions for direction, and intensity. const VLIVector3D& GetDirection (void) const; double GetIntensity (void) const; VLIStatus SetDirection (const VLIVector3D &inDirection); VLIStatus SetIntensity (double inIntensity); // When someone adds a reference, they must call AddRef int AddRef (void); // Release the light source int Release (void); public: // Except for initialization, VLI does not touch this void *m_appData; }; /*************************************************************************** * * This section describes the VLICursor class/object that manages * the hardware 3D cursor * ****************************************************************************/ class VLIEXPORT VLICursor { public: enum Types { kCrossHair = 0x00000000, kPlane = 0x00000010 }; enum Flags { kDisable = 0x00000000, kEnableX = 0x00000004, kEnableY = 0x00000002, kEnableZ = 0x00000001, kEnableAll = (kEnableX|kEnableY|kEnableZ), kExcludeOverlap = 0x00000080, kDisableCrop = 0x00040000 }; enum Axes { kXAxis = 4, kYAxis = 2, kZAxis = 1 }; // the constructor creates an enabled cross-hair cursor // and with blend mode. The cursor is located at origin of the volume. VLICursor(void); virtual ~VLICursor(void); // cursor type VLIStatus SetType(int inType); int GetType(void) const; // cursor size; VLIStatus SetWidth (double inWidth); double GetWidth (void); VLIStatus SetLength(double inLength); double GetLength(void); // cursor location, in object coordinate system VLIStatus SetPosition(double inX, double inY, double inZ); void GetPosition(double& outX, double& outY, double& outZ); // cursor attributes: replace or blend, what to do with overlap etc VLIStatus SetAttributes(int inModes); int GetAttributes(void) const; // cursor colors. You can set the color for more than one axis // by ORing the axis enum VLIStatus SetColor(int inAxes, double inRed, double inGreen, double inBlue); VLIStatus GetColor(int inAxis, double& outRed, double& outGreen,double& outBlue); VLIStatus SetOpacity(int inAxes, double inAlpha); double GetOpacity(int inAxis); VLIStatus SetColorAndOpacity(int inAxes, VLIRGBAPacked inRGBA); VLIRGBAPacked GetColorAndOpacity(int inAxis); private: double m_Position[3]; double m_width; double m_length; unsigned int m_configuration; double m_Red [3]; double m_Green[3]; double m_Blue [3]; double m_Alpha[3]; friend class RenderingRecord; }; /*************************************************************************** * * This section describes the VLIVolume class/object that manages * voxel data. * ****************************************************************************/ class VLIEXPORT VLIVolume { public: enum Layout { kSliced, kBlocked }; enum ReadMode // Can volumes created from files be modified? { kReadOnly, // no, files and volumes are read-only kCopyOnWrite, // files are only read, volumes can be modified kReadWrite // modifying the volume will cause the file to change NOT YET IMPLEMENTED }; static VLIVolume *Create ( VLIuint32 inFormat, // voxel format void *inVoxels, // pointer to voxel data in slices unsigned int inSizeX, // size of the volume in X in voxels unsigned int inSizeY, // size of the volume in Y unsigned int inSizeZ, // size of the volume in Z Layout inLayout = kSliced);// sliced static VLIVolume *CreateFromFile ( const char *inFilename, // name of file to be loaded int inFileType = 0, // type of file, 0 = decipher ReadMode inReadMode = kReadOnly); // read mode VLIbool IsReadOnly(void) const; // Created from file in read-only mode? VLIuint32 GetFormat(void) const; // format of the volume Layout GetLayout(void) const; // layout of the volume(slice/block) void GetSize(unsigned int& nXVox, unsigned int& nYVox, unsigned int& nZVox ) const; // Volume model matrix - built from scale, shear, rotate & translate // VLIStatus SetModelMatrix (const VLIMatrix& inModel); VLIMatrix GetModelMatrix (void) const; // Subvolume Rendering VLIStatus SetActiveSubVolumeSize( unsigned int inNX, unsigned int inNY, unsigned int inNZ); void GetActiveSubVolumeSize( unsigned int& inNX, unsigned int& inNY, unsigned int& inNZ); VLIStatus SetActiveSubVolumeOrigin(unsigned int inNX, unsigned int inNY, unsigned int inNZ); void GetActiveSubVolumeOrigin(unsigned int& inNX, unsigned int& inNY, unsigned int& inNZ); VLIStatus UpdateVolume( VLIuint32 inFormat, // voxel format void *inVoxels, // data unsigned int inTargetXVox, // where to change the volume in X unsigned int inTargetYVox, // change the volume in Y unsigned int inTargetZVox, // change the volume in Z unsigned int inNXVox, // size of the subvolume in X unsigned int inNYVox, // size of the subvolume in Y unsigned int inNZVox, // size of the subvolume in Z Layout layout = kSliced); // sliced only for now. VLIbool IsLoaded(void) const; // true if volume is on the board int AddRef(void); int Release(void); VLIStatus LockVolume(void); VLIbool IsLocked(void) const; VLIStatus UnlockVolume(void); VLIStatus MapVolume( VLIAccessType inAccess, void *&outBaseAddress, unsigned int &outSx, unsigned int &outSy); VLIStatus MapSubVolume( VLIAccessType inAccess, unsigned int inAtX, unsigned int inAtY, unsigned int inAtZ, unsigned int inNx, unsigned int inNy, unsigned int inNz, void *&outBaseAddress, unsigned int &outSx, unsigned int &outSy); VLIStatus UnmapVolume(void); VLIAccessType GetAccessControl(void) const; public: // Except for initialization, VLI does not touch this void *m_appData; }; /*************************************************************************** * * Error handler functions that handle system initialization * and configuration. * **************************************************************************/ class VLIEXPORT VLIErrorHandler { public: VLIErrorHandler(void); virtual ~VLIErrorHandler(void); virtual void ErrorNotify(int inErrNum, const char *inFile, int inLineNum); }; VLIEXPORT VLIErrorHandler* VLISetErrorHandler(VLIErrorHandler *inHandler); /**************************************************************************** * * This section describes the VLILookupTable class/object that manages * both color and opacity lookups. * ****************************************************************************/ class VLILookupTable; struct VLIRGBColor { public: VLIuint8 m_red, m_green, m_blue; private: VLIuint8 m_pad; }; struct VLIRGBAFloat { float m_red, m_green, m_blue, m_alpha; }; class VLIEXPORT VLILookupTable { public: enum Size { kSize4096 = 4096, kSize2048 = 2048, kSize1024 = 1024, kSize512 = 512, kSize256 = 256 }; // Creates a gray ramp for color lookup table and // a linear ramp for alpha table static VLILookupTable* Create (Size inTableSize = kSize4096); static VLILookupTable* Create (Size inTableSize, const VLIuint8 inColor[][3], const VLIuint16* inAlphas ); static VLILookupTable* Create (Size inTableSize, const VLIRGBAPacked* inEntries ); static VLILookupTable* Create (Size inTableSize, const VLIRGBAFloat* inEntries ); // Routines to change one or more color entries // Red, green and blue in the range 0 to 255. VLIStatus SetColorEntry(unsigned int inIndex, unsigned int inRed, unsigned int inGreen, unsigned int inBlue); // Red, green and blue in the range 0.0 to 1.0 VLIStatus SetColorEntry(unsigned int inIndex, double inRed, double inGreen, double inBlue); // Red, green and blue in the range 0 to 255. VLIStatus SetColorEntries(unsigned int inIndex, //starting index(0 based) unsigned int inLength, //number of entries to set const VLIuint8 inRGB[][3] ); // Red, green and blue in the range 0.0 to 1.0 VLIStatus SetColorEntries(unsigned int inIndex, //starting index(0 based) unsigned int inLength, //size of initial array const VLIRGBColor* inEntries ); // Routines to retrieve color entries // Red, green and blue in the range 0 to 255. VLIStatus GetColorEntries(unsigned int inIndex, //starting index(0 based) unsigned int inLength, //number of entries to Get VLIuint8 outRGB[][3] ) const; // Red, green and blue in the range 0.0 to 1.0 VLIStatus GetColorEntries(unsigned int inIndex, //starting index(0 based) unsigned int inLength, // number of entries to Get VLIRGBColor* outEntries) const; // Routines to change one or more alpha entries // Alpha in the range 0 to 4095. VLIStatus SetAlphaEntry(unsigned int inIndex, unsigned int inAlpha); // Alpha in the range 0.0 to 1.0. VLIStatus SetAlphaEntry(unsigned int inIndex, double inAlpha); // Alpha in the range 0 to 4095. VLIStatus SetAlphaEntries(unsigned int inIndex, //starting index(0 based) unsigned int inLength, //number of entries to set const VLIuint16* inAlpha); // Alpha in the range 0.0 to 1.0. VLIStatus SetAlphaEntries(unsigned int inIndex, //starting index(0 based) unsigned int inLength, //number of entries to set const float * inAlpha); // Routines to retrieve alpha entries // Alpha in the range 0 to 4095. VLIStatus GetAlphaEntries(unsigned int inIndex, //starting index(0 based) unsigned int inLength, // number of entries to Get VLIuint16* outAlpha ) const; // Alpha in the range 0.0 to 1.0. VLIStatus GetAlphaEntries(unsigned int inIndex, //starting index(0 based) unsigned int inLength, // number of entries to Get float * outAlpha ) const; // Routines to change both color and alpha of one or more entries // Red, green and blue in the range 0 to 255, alpha in the range 0 to 4095. VLIStatus SetRGBAEntry(unsigned int inIndex, unsigned int inRed, unsigned int inGreen, unsigned int inBlue, unsigned int inAlpha); // Red, green, blue and alpha in the range 0.0 to 1.0. VLIStatus SetRGBAEntry(unsigned int inIndex, double inRed, double inGreen, double inBlue, double inAlpha); // Red, green, blue and alpha in the range 0 to 255. VLIStatus SetRGBAEntry(unsigned int inIndex, VLIRGBAPacked inPacked); // Red, green, blue and alpha in the range 0 to 255. VLIStatus SetRGBAEntries(unsigned int inIndex, //starting index (0 based) unsigned int inLength, //number of entries to set const VLIRGBAPacked* inRGBA); // Red, green, blue and alpha in the range 0.0 to 1.0. VLIStatus SetRGBAEntries(unsigned int index, // starting index (zero based) unsigned int length, // number of entries to set const VLIRGBAFloat* inRGBA); // Routines to retrieve color and alpha entries // Red, green, blue and alpha in the range 0 to 255. VLIStatus GetRGBAEntries(unsigned int inIndex, //starting index(0 based) unsigned int inLength, // number of entries to Get VLIRGBAPacked* outRGBA) const; // Red, green, blue and alpha in the range 0 to 255. VLIStatus GetRGBAEntries(unsigned int index, // starting index (zero based) unsigned int length, // number of entries to set VLIRGBAFloat* inRGBA) const; Size GetSize(void) const; // When someone adds a reference, they must call AddRef int AddRef (void); int Release(void); public: // a field for application. VLI does not reference or modify it except // for initializing it to null. void *m_appData; }; /**************************************************************************** * * This section describes VLIEventBase and its children. These clases * hold data used by callback routines. * ***************************************************************************/ enum VLIEvent { kVLIEventRenderDone, kVLIEventTransferDone, kVLIEventLightMap, kVLIEventLightMapChange, kVLIEventMultiPassBasePlane, kVLINumberOfEvents // number of events }; class VLIEXPORT VLIEventBase { public: int buffer; virtual VLIEvent EventType(void) const = 0; virtual ~VLIEventBase(void) { } VLIEventBase(int buffer); }; class VLIEXPORT VLIEventRenderDone : public VLIEventBase { public: VLIEvent EventType(void) const; VLIEventRenderDone(int buffer); }; class VLIEXPORT VLIEventTransferDone : public VLIEventBase { public: VLIEvent EventType(void) const; VLIEventTransferDone(int buffer); }; typedef enum {kVLILightMapType1} VLILightMapType; class VLIEXPORT VLIEventLightMap : public VLIEventBase { public: VLILightMapType lightFormat; // kVLILightMapType1 implies 2 maps int bytesPerElement; int numberOfElements; void *pointerToMap1; // Diffuse void *pointerToMap2; // Specular VLIEvent EventType(void) const; VLIEventLightMap(int buffer, VLILightMapType format, int eltSize, int nElts, void *map1, void *map2); }; class VLIEXPORT VLIEventLightMapChange : public VLIEventBase { public: VLILightMapType lightFormat; // kVLILightMapType1 implies 2 MapChanges int bytesPerElement; int numberOfElements; void *pointerToMap1; // Diffuse void *pointerToMap2; // Specular VLIEvent EventType(void) const; VLIEventLightMapChange(int buffer, VLILightMapType format, int eltSize, int nElts, void *MapChange1, void *MapChange2); }; class VLIEXPORT VLIEventMultiPassBasePlane : public VLIEventBase { public: VLIEvent EventType(void) const; VLIEventMultiPassBasePlane (int buffer, int multiPassBuffer); int multiPassBuffer; }; typedef void (*VLIEventCallback)(VLIEventBase *inEvent, void *inData); /**************************************************************************** * * This section describes the VLIContext class/object. This class * manages the rendering context and parameters. * ***************************************************************************/ #define kVLILinearGradientRamp 0 class VLIEXPORT VLIContext { public: // Create Function static VLIContext* Create (VLILookupTable* inColor = 0); // Current camera VLICamera& GetCamera (void); VLIStatus SetCamera (const VLICamera& inCam); // Current lookup table VLILookupTable* GetLookupTable (void) const; VLIStatus SetLookupTable (const VLILookupTable* inLUT); // Current reflection properties void GetReflectionProperties (double& outDiffuse, double& outSpecular, double& outEmissive, double& outSpecularExponent) const; VLIStatus SetReflectionProperties (double inDiffuse, double inSpecular, double inEmissive, double inSpecularExponent); // Specular Color void GetSpecularColor (double& outRed, double& outGreen, double& outBlue) const; VLIStatus SetSpecularColor (double inRed, double inGreen, double inBlue); // Functions to add and remove light sources VLIStatus AddLight (VLILight *inLight); VLIStatus RemoveLight (VLILight *inLight); // Get number of current light sources unsigned int GetLightCount (void) const; // Get the "ith" light source VLILight* GetLight (unsigned int inI) const; // Gradient modulation of lighting VLIbool GetGradientSpecularIlluminationModulation (void) const; VLIbool GetGradientDiffuseIlluminationModulation (void) const; VLIStatus SetGradientSpecularIlluminationModulation (VLIbool inGMIMSpecular); VLIStatus SetGradientDiffuseIlluminationModulation (VLIbool inGMIMDiffuse); // Gradient modulation of opacity VLIbool GetGradientOpacityModulation (void) const; VLIStatus SetGradientOpacityModulation (VLIbool inOn); // Toggle opacity adjustment. VLIbool GetCorrectOpacity(void) const; VLIStatus SetCorrectOpacity(VLIbool inOn); // GradientMagnitude transfer function. The table is // the normalized (between 0 and 1) lookup table having VLIStatus SetGradientTable(const double inTable[]); const double * GetGradientTable(void) const; // Blend modes VLIBlendMode GetBlendMode (void) const; VLIStatus SetBlendMode (VLIBlendMode inMode); // Cut Plane VLIStatus AddCutPlane (VLICutPlane* inPlane); VLIStatus RemoveCutPlane (VLICutPlane* inPlane); unsigned int GetCutPlaneCount (void) const; VLICutPlane* GetCutPlane (unsigned int inI) const; // Cropping VLICrop& GetCrop (void); VLIStatus SetCrop (const VLICrop& inCrop); // the hardware 3D cursor VLICursor& GetCursor(void); VLIStatus SetCursor(const VLICursor& inCursor); // Super Sampling void GetSuperSamplingFactor (double& outX, double& outY, double& outZ) const; VLIStatus SetSuperSamplingFactor (double inX, double inY, double inZ); // Supersampling space - object (volume) or view VLICoordinateSpace GetSuperSamplingSpace (void) const; VLIStatus SetSuperSamplingSpace (VLICoordinateSpace inSpace); // Set notify (render or transfer completion) callback VLIStatus SetNotifyCallback (VLIEvent inEvent, VLIEventCallback inNotify, void *inData); // The following two are temporary VLIStatus RenderBasePlane (VLIVolume *inVolume, int inBuffer, VLIbool inLeaveOnBoard = VLIfalse); VLIStatus FetchBasePlane ( int inBuffer, int &outBaseWidth, int &outBaseHeight, int &outImageWidth, int &outImageHeight, VLIPixel *&outBasePlane, VLIVector3D outHexGeometry[6], VLIVector2D outTexCoordinates[6]); VLIStatus ReleaseBasePlane (int inBuffer); VLIStatus SetBasePlaneFormat(VLIPixelFormat inFormat); VLIPixelFormat GetBasePlaneFormat(void) const; static VLIStatus DescribePixelFormat( VLIPixelFormat inFormat, int& outRedWidth, int& outRedOffset, int& outGreenWidth, int& outGreenOffset, int& outBlueWidth, int& outBlueOffset, int& outAlphaWidth, int& outAlphaOffset); enum AccumulationMode {kGrowBasePlane, kBlendBasePlane}; VLIStatus SetBasePlaneAccumulation (AccumulationMode inMode); AccumulationMode GetBasePlaneAccumulation (void) const; // Render the volume to the graphics context VLIStatus RenderToGraphicsContext(VLIVolume* inVolume, int inBuffer, VLIGraphicsContext& inGC); // Abort current render VLIStatus Abort(int inBuffer); VLIStatus WaitForEvent(long inTimeoutMilliseconds, VLIEventBase *&outEvent, void *&outData); static VLIEventCallback kVLIEventNoCallbackRoutine; int AddRef (void); int Release(void); public: // a field for application. Except for initializing it to null, // VLI does not change or reference it void *m_appData; }; /******************************** END OF FILE *********************************/ #endif /* VLI_H */