Main Page | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | File Members

BPolyhedron.h

00001 //
00002 // Copyright (c) 2000 by Tech Soft America, LLC.
00003 // The information contained herein is confidential and proprietary to
00004 // Tech Soft America, LLC., and considered a trade secret as defined under
00005 // civil and criminal statutes.  Tech Soft America shall pursue its civil
00006 // and criminal remedies in the event of unauthorized use or misappropriation
00007 // of its trade secrets.  Use of this information by anyone other than
00008 // authorized employees of Tech Soft America, LLC. is granted only under a
00009 // written non-disclosure agreement, expressly prescribing the scope and
00010 // manner of such use.
00011 //
00012 // $Header: /NewRoot/DWF Toolkit/v6/develop/global/src/dwf/w3dtk/BPolyhedron.h 1     9/12/04 8:48p Evansg $
00013 //
00014 #ifndef BBINFILETK_POLYHEDRON
00015 #define BBINFILETK_POLYHEDRON
00016 
00017 
00019 
00024 class BBINFILETK_API TK_Polyhedron : public BBaseOpcodeHandler {
00025     private:
00026         TK_Polyhedron(const TK_Polyhedron&);
00027         TK_Polyhedron& operator=(const TK_Polyhedron&);
00028 
00029     public:
00030 
00034         enum Exists {                   
00035             Vertex_None         = 0x0000,
00036             Vertex_Normal       = 0x0001,
00037             Vertex_Parameter    = 0x0002,
00038             Vertex_Face_Color   = 0x0004,
00039             Vertex_Edge_Color   = 0x0008,
00040             Vertex_Marker_Color = 0x0010,
00041             Vertex_Face_Index   = 0x0020,
00042             Vertex_Edge_Index   = 0x0040,
00043             Vertex_Marker_Index = 0x0080,
00044             Vertex_Any_Color    = 0x00FC
00045         };
00046 
00050         enum Face_Exists {
00051             Face_None         = 0x0000,
00052             Face_Color        = 0x0001,
00053             Face_Index        = 0x0002,
00054             Face_Any_Color    = 0x0003
00055         };
00056 
00060         enum Suboptions {
00061             TKSH_STANDARD                 = 0x00,
00062             TKSH_COMPRESSED_POINTS        = 0x01,
00063             TKSH_COMPRESSED_FACES         = 0x02,
00064             TKSH_TRISTRIPS                = 0x04,
00065             TKSH_HAS_OPTIONALS            = 0x08,
00066             TKSH_FIRSTPASS                = 0x10,
00067             TKSH_BOUNDING_ONLY            = 0x20,
00068             TKSH_CONNECTIVITY_COMPRESSION = 0x40,
00069             TKSH_EXPANDED                 = 0x80
00070         };
00071 
00076         enum Suboptions2 {
00077             TKSH2_COLLECTION              = 0x0001,
00078             TKSH2_NULL                    = 0x0002,
00079             TKSH2_HAS_NEGATIVE_FACES      = 0x0004,
00080             TKSH2_GLOBAL_QUANTIZATION     = 0x0008
00081         };
00082 
00086         enum Opt_Opcode {
00087             OPT_TERMINATE                   = 0,
00088             OPT_ALL_NORMALS_COMPRESSED      = 1,
00089             OPT_NORMALS_COMPRESSED          = 2,
00090             OPT_ALL_PARAMETERS_COMPRESSED   = 3,
00091             OPT_PARAMETERS_COMPRESSED       = 4,
00092             OPT_ALL_VFCOLORS                = 5,
00093             OPT_VERTEX_FCOLORS              = 6,
00094             OPT_ALL_VECOLORS                = 7,
00095             OPT_VERTEX_ECOLORS              = 8,
00096             OPT_ALL_VMCOLORS                = 9,
00097             OPT_VERTEX_MCOLORS              = 10,
00098             OPT_ALL_VFINDICES               = 11,
00099             OPT_VERTEX_FINDICES             = 12,
00100             OPT_ALL_VEINDICES               = 13,
00101             OPT_VERTEX_EINDICES             = 14,
00102             OPT_ALL_VMINDICES               = 15,
00103             OPT_VERTEX_MINDICES             = 16,
00104             OPT_ALL_NORMALS                 = 17,
00105             OPT_NORMALS                     = 18,
00106             OPT_ALL_NORMALS_POLAR           = 19,
00107             OPT_NORMALS_POLAR               = 20,
00108     
00109             /* break in sequence to allow for new vertex attributes */
00110             OPT_ALL_FACE_COLORS             = 33,
00111             OPT_FACE_COLORS                 = 34,
00112             OPT_ALL_FACE_INDICES            = 35,
00113             OPT_FACE_INDICES                = 36,
00114             
00115             OPT_FACE_REGIONS                = 51,
00116             
00117             OPT_ENTITY_ATTRIBUTES           = 99
00118         };
00119 
00120 
00121         //see TK_Shell for GetFacesLength, GetFaces, GetLodLevel, SetFaces, SetLodLevel
00122 
00124         float const *GetPoints() const { return mp_points; };
00126         float *GetPoints() { return mp_points; };
00128         int GetPointCount() const { return mp_pointcount; };
00130         unsigned int const *GetExists() const { return mp_exists; };
00132         unsigned int *GetExists() { return mp_exists; };
00134         unsigned int const *GetFaceExists() const { return mp_face_exists; };
00136         unsigned int *GetFaceExists() { return mp_face_exists; };
00138         ID_Key GetKey() const { return mp_key; };
00140         unsigned char GetSubop() const { return mp_subop; };
00142         unsigned short GetSubop2() const { return mp_subop2; };
00144         const float *GetBounding() const { return mp_bbox; };
00146         float const *GetVertexNormals() const { return mp_normals; };
00148         float *GetVertexNormals() { return mp_normals; };
00150         float const *GetVertexParameters() const { return mp_params; };
00152         float *GetVertexParameters() { return mp_params; };
00154         float const *GetVertexFaceColors() const { return mp_vfcolors; };
00156         float *GetVertexFaceColors() { return mp_vfcolors; };
00158         float const *GetVertexEdgeColors() const { return mp_vecolors; };
00160         float *GetVertexEdgeColors() { return mp_vecolors; };
00162         float const *GetVertexMarkerColors() const { return mp_vmcolors; };
00164         float *GetVertexMarkerColors() { return mp_vmcolors; };
00167         float const *GetVertexColors() const { 
00168             if( mp_vmcolors != 0 ) return mp_vmcolors;
00169             else if( mp_vfcolors != 0 ) return mp_vfcolors;
00170             else if( mp_vecolors != 0 ) return mp_vecolors;
00171             else return 0;
00172         };
00175         float *GetVertexColors() { 
00176             if( mp_vmcolors != 0 ) return mp_vmcolors;
00177             else if( mp_vfcolors != 0 ) return mp_vfcolors;
00178             else if( mp_vecolors != 0 ) return mp_vecolors;
00179             else return 0;
00180         };
00182         float const *GetVertexFaceIndices() const { return mp_vfindices; };
00184         float *GetVertexFaceIndices() { return mp_vfindices; };
00186         float const *GetVertexEdgeIndices() const { return mp_veindices; };
00188         float *GetVertexEdgeIndices() { return mp_veindices; };
00190         float const *GetVertexMarkerIndices() const { return mp_vmindices; };
00192         float *GetVertexMarkerIndices() { return mp_vmindices; };
00195         float const *GetVertexIndices() const { 
00196             if( mp_vmindices != 0 ) return mp_vmindices;
00197             else if( mp_vfindices != 0 ) return mp_vfindices;
00198             else if( mp_veindices != 0 ) return mp_veindices;
00199             else return 0;
00200         };
00203         float *GetVertexIndices() { 
00204             if( mp_vmindices != 0 ) return mp_vmindices;
00205             else if( mp_vfindices != 0 ) return mp_vfindices;
00206             else if( mp_veindices != 0 ) return mp_veindices;
00207             else return 0;
00208         };
00210         float const *GetFaceColors() const { return mp_fcolors; };
00212         float *GetFaceColors() { return mp_fcolors; };
00214         float const *GetFaceIndices() const { return mp_findices; };
00216         float *GetFaceIndices() { return mp_findices; };
00218         int const * GetFaceRegions() const { return mp_fregions; };
00220         int alter * GetFaceRegions() alter { return mp_fregions; };
00221 
00223         TK_Status SetKey( BStreamFileToolkit &tk, ID_Key key ) alter { set_last_key( tk, key ); mp_key = key; return TK_Normal; };
00226         TK_Status SetSubop( unsigned char subop ) alter { mp_subop = subop; return TK_Normal; };
00229         TK_Status SetSubop2( unsigned short subop2 ) alter { mp_subop2 = subop2; return TK_Normal; };
00234         TK_Status InitSubop( BStreamFileToolkit &tk, int lodlevel, bool is_firstpass ) alter;
00237         TK_Status SetBounding( float const *bbox ) alter { mp_bbox[0] = bbox[0]; mp_bbox[1] = bbox[1]; mp_bbox[2] = bbox[2]; mp_bbox[3] = bbox[3]; mp_bbox[4] = bbox[4]; mp_bbox[5] = bbox[5]; return TK_Normal; };
00242         TK_Status SetPoints( int count, float const *points ) alter;
00247         TK_Status SetVertexNormals( float const *normals ) alter;
00254         TK_Status SetVertexParameters( float const *parameters ) alter;
00261         TK_Status SetVertexFaceColors( float const *colors ) alter;
00268         TK_Status SetVertexEdgeColors( float const *colors ) alter;
00275         TK_Status SetVertexMarkerColors( float const *colors ) alter;
00284         TK_Status SetVertexColors( float const *colors ) alter;
00292         TK_Status SetVertexFaceIndices( float const *indices ) alter;
00299         TK_Status SetVertexEdgeIndices( float const *indices ) alter;
00306         TK_Status SetVertexMarkerIndices( float const *indices ) alter;
00314         TK_Status SetVertexIndices( float const *indices ) alter;
00320         TK_Status SetFaceColors( float const *colors ) alter;
00326         TK_Status SetFaceIndices( float const *indices ) alter;
00329         TK_Status SetFaceRegions (int const * regions = 0) alter;
00335         TK_Status AppendObject( BStreamFileToolkit & tk, BBaseOpcodeHandler *obj );
00338         BBaseOpcodeHandler *PopObject();
00339 
00341         bool HasOptionals() {
00342             return
00343                 mp_normals != 0 ||
00344                 mp_params != 0 ||
00345                 mp_vfcolors != 0 ||
00346                 mp_vecolors != 0 ||
00347                 mp_vmcolors != 0 ||
00348                 mp_vfindices != 0 ||
00349                 mp_veindices != 0 ||
00350                 mp_vmindices != 0 ||
00351                 mp_fcolors != 0 ||
00352                 mp_findices != 0 ||
00353                 mp_fregions != 0 ||
00354                 !(mp_subop2 && 0x011) && mp_num_collection_parts > 0;   // 0x01 matches TKSH2_COLLECTION
00355         };
00357         bool HasVertexNormals() { return mp_normals != 0; };
00359         bool HasVertexParameters() { return mp_params != 0; };
00361         bool HasVertexFaceColors() { return mp_vfcolors != 0; };
00363         bool HasVertexEdgeColors() { return mp_vecolors != 0; };
00365         bool HasVertexMarkerColors() { return mp_vmcolors != 0; };
00367         bool HasVertexColors() { return 
00368                 mp_vfcolors != 0 || 
00369                 mp_vecolors != 0 ||
00370                 mp_vmcolors != 0;
00371         };
00373         inline bool HasVertexFaceIndices() const { return mp_vfindices != 0; };
00375         inline bool HasVertexEdgeIndices() const { return mp_veindices != 0; };
00377         inline bool HasVertexMarkerIndices() const { return mp_vmindices != 0; };
00379         inline bool HasVertexIndices() const { return 
00380                 mp_vfindices != 0 || 
00381                 mp_veindices != 0 ||
00382                 mp_vmindices != 0;
00383         };
00385         inline bool HasFaceColors() const { return mp_fcolors != 0; };
00387         inline bool HasFaceIndices() const { return mp_findices != 0; };
00389         inline bool HasFaceRegions() const { return mp_fregions != 0; };
00391         inline bool HasFaceAttributes() const { return (HasFaceColors() || HasFaceIndices() || HasFaceRegions()); };
00392 
00393     public:
00394         //data members previxed with "mp_", not "m_", to avoid potential naming conflicts
00395 
00396 
00397 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00398 
00399         //a few data members need to be accessed by both polyhedron & [shell,mesh]
00400         int             mp_pointcount;  
00401         int             mp_facecount;   
00402         float *         mp_points;      
00403         float *         mp_normals;     
00404         float *         mp_params;      
00405         float *         mp_fcolors;     
00406         float *         mp_findices;    
00407         float *         mp_vfcolors;    
00408         float *         mp_vecolors;    
00409         float *         mp_vmcolors;    
00410         float *         mp_vfindices;   
00411         float *         mp_veindices;   
00412         float *         mp_vmindices;   
00413         int *           mp_fregions;    
00415         unsigned int *  mp_exists;      
00416         unsigned int *  mp_face_exists; 
00418         int             mp_normalcount;  
00419         int             mp_paramcount;   
00420         int             mp_fcolorcount;  
00421         int             mp_findexcount;  
00422         int             mp_vfcolorcount; 
00423         int             mp_vecolorcount; 
00424         int             mp_vmcolorcount; 
00425         int             mp_vfindexcount; 
00426         int             mp_veindexcount; 
00427         int             mp_vmindexcount; 
00429         int             mp_stage;        
00430         int             mp_substage;     
00431         int             mp_progress;     
00432         unsigned char   mp_optopcode;    
00435         unsigned short  mp_present;         
00436         unsigned short  mp_face_present;    
00437         unsigned char   mp_bits_per_sample; 
00438         float           mp_bbox[6];         
00439         ID_Key          mp_key;             
00440         TK_Instance *   mp_instance;        
00441         float           mp_matrix[16];      
00442         unsigned char * mp_workspace;       
00443         int             mp_workspace_allocated; 
00444         int             mp_workspace_used;  
00445         unsigned char   mp_compression_scheme; 
00446         unsigned char   mp_subop;           
00447         unsigned short  mp_subop2;          
00448         int             mp_num_collection_parts; 
00449         BBaseOpcodeHandler **mp_collection_parts;
00452         TK_Polyhedron(unsigned char op);
00453         ~TK_Polyhedron();
00454 
00455         TK_Status   Read (BStreamFileToolkit & tk) alter;
00456         TK_Status   Write (BStreamFileToolkit & tk) alter;
00457         void        Reset (void) alter;
00458 
00459         virtual TK_Status   read_trivial_points (BStreamFileToolkit & tk) alter; 
00460         virtual TK_Status   write_trivial_points (BStreamFileToolkit & tk) alter; 
00462         TK_Status   read_vertex_normals (BStreamFileToolkit & tk) alter; 
00463         TK_Status   read_vertex_normals_compressed (BStreamFileToolkit & tk) alter; 
00464         TK_Status   read_vertex_normals_all (BStreamFileToolkit & tk) alter; 
00465         TK_Status   read_vertex_normals_compressed_all (BStreamFileToolkit & tk) alter; 
00466         TK_Status   read_vertex_parameters (BStreamFileToolkit & tk) alter; 
00467         TK_Status   read_vertex_parameters_all (BStreamFileToolkit & tk) alter; 
00468         TK_Status   read_vertex_colors_all (BStreamFileToolkit & tk, unsigned char op ) alter; 
00469         TK_Status   read_vertex_colors (BStreamFileToolkit & tk, unsigned char op ) alter; 
00470         TK_Status   read_vertex_indices_all (BStreamFileToolkit & tk, unsigned char op ) alter; 
00471         TK_Status   read_vertex_indices (BStreamFileToolkit & tk, unsigned char op ) alter; 
00472         TK_Status   read_face_colors (BStreamFileToolkit & tk) alter; 
00473         TK_Status   read_face_colors_all (BStreamFileToolkit & tk) alter; 
00474         TK_Status   read_face_indices (BStreamFileToolkit & tk) alter; 
00475         TK_Status   read_face_indices_all (BStreamFileToolkit & tk) alter; 
00476         TK_Status   read_face_regions (BStreamFileToolkit & tk) alter; 
00477                 virtual TK_Status read_collection (BStreamFileToolkit & tk) alter; 
00479         TK_Status   write_vertex_normals (BStreamFileToolkit & tk) alter; 
00480         TK_Status   write_vertex_normals_compressed (BStreamFileToolkit & tk) alter; 
00481         TK_Status   write_vertex_normals_all (BStreamFileToolkit & tk) alter; 
00482         TK_Status   write_vertex_normals_compressed_all (BStreamFileToolkit & tk) alter; 
00483         TK_Status   write_vertex_parameters (BStreamFileToolkit & tk) alter; 
00484         TK_Status   write_vertex_parameters_all (BStreamFileToolkit & tk) alter; 
00485         TK_Status   write_vertex_colors (BStreamFileToolkit & tk, unsigned char op ) alter; 
00486         TK_Status   write_vertex_colors_all (BStreamFileToolkit & tk, unsigned char op ) alter; 
00487         TK_Status   write_vertex_indices (BStreamFileToolkit & tk, unsigned char op ) alter;  
00488         TK_Status   write_vertex_indices_all (BStreamFileToolkit & tk, unsigned char op ) alter;  
00489         TK_Status   write_face_colors (BStreamFileToolkit & tk) alter; 
00490         TK_Status   write_face_colors_all (BStreamFileToolkit & tk) alter; 
00491         TK_Status   write_face_indices (BStreamFileToolkit & tk) alter; 
00492         TK_Status   write_face_indices_all (BStreamFileToolkit & tk) alter; 
00495         void normals_cartesian_to_polar( int count, const float *in, float *out );  
00497         void normals_polar_to_cartesian( int count, const float *in, float *out );  
00498 
00502         TK_Status   write_vertex_normals_main (BStreamFileToolkit & tk) alter; 
00507         TK_Status   write_vertex_parameters_main (BStreamFileToolkit & tk) alter; 
00513         TK_Status   write_vertex_colors_main (BStreamFileToolkit & tk, unsigned char base_op ) alter;
00519         TK_Status   write_vertex_indices_main (BStreamFileToolkit & tk, unsigned char base_op ) alter; 
00524         TK_Status   write_face_colors_main (BStreamFileToolkit & tk) alter; 
00529                 TK_Status   write_face_indices_main (BStreamFileToolkit & tk) alter;
00530         TK_Status   write_face_regions (BStreamFileToolkit & tk) alter;  
00531                 virtual TK_Status write_collection (BStreamFileToolkit & tk, bool write_tag = false, int variant = 0) alter; 
00533         virtual TK_Status mangle_points (BStreamFileToolkit & tk, int pointmap_count, int *pointmap ) alter; 
00534         virtual TK_Status mangle_point_attributes (BStreamFileToolkit & tk, int pointmap_count, int *pointmap ) alter; 
00535         virtual TK_Status mangle_face_attributes (BStreamFileToolkit & tk, int facemap_count, int *facemap ) alter; 
00536         bool has_face_attributes() const; 
00546         TK_Status repulse_compress_normals (BStreamFileToolkit & tk, int bits) alter;
00552         TK_Status repulse_decompress_normals (BStreamFileToolkit & tk, int bits) alter;
00553 
00555         void set_points (int count, float const * points = 0) alter { SetPoints( count, points ); };
00557         void set_normals (float const * normals = 0) alter { SetVertexNormals( normals ); };
00559         void set_parameters (float const * params = 0) alter { SetVertexParameters( params ); };
00561         void set_vfcolors (float const * colors = 0) alter { SetVertexFaceColors( colors ); };
00563         void set_vecolors (float const * colors = 0) alter { SetVertexEdgeColors( colors ); };
00565         void set_vmcolors (float const * colors = 0) alter { SetVertexMarkerColors( colors ); };
00567         void set_vfindices (float const * indices = 0) alter { SetVertexFaceIndices( indices ); };
00569         void set_veindices (float const * indices = 0) alter { SetVertexEdgeIndices( indices ); };
00571         void set_vmindices (float const * indices = 0) alter { SetVertexMarkerIndices( indices ); };
00573         void set_fcolors (float const * colors = 0) alter { SetFaceColors( colors ); };
00575         void set_findices (float const * indices = 0) alter { SetFaceIndices( indices ); };
00577         void set_exists (unsigned int const * exists = 0) alter;
00579         void set_face_exists (unsigned int const * exists = 0) alter;
00581         void set_facemap (int count, int const * facemap = 0) alter;
00582 
00583 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
00584 
00585 }; // end declaration of class TK_Polyhedron
00586 
00587 
00589 
00595 class BBINFILETK_API TK_Mesh : public TK_Polyhedron {
00596     private:
00597         TK_Mesh(const TK_Mesh&);
00598         TK_Mesh& operator=(const TK_Mesh&);
00599 
00600 
00601     protected:
00602         int             m_rows;     
00603         int             m_columns;  
00605     public:
00606         TK_Mesh()
00607             : TK_Polyhedron (TKE_Mesh), m_rows(0), m_columns(0) {}
00608 
00609         TK_Status   Read (BStreamFileToolkit & tk) alter;
00610         TK_Status   Write (BStreamFileToolkit & tk) alter;
00611         void        Reset (void) alter;
00612 }; // end declaration of class TK_Mesh
00613 
00614 #endif
00615 
00616 

Generated on Tue May 17 12:06:00 2005 for Autodesk DWF 3D Toolkit by  doxygen 1.4.1