Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | File Members | Related Pages | Examples

Model.h

Go to the documentation of this file.
00001 //
00002 //  Copyright (c) 1996-2005 by Autodesk, Inc.
00003 //
00004 //  By using this code, you are agreeing to the terms and conditions of
00005 //  the License Agreement included in the documentation for this code.
00006 //
00007 //  AUTODESK MAKES NO WARRANTIES, EXPRESS OR IMPLIED, AS TO THE CORRECTNESS
00008 //  OF THIS CODE OR ANY DERIVATIVE WORKS WHICH INCORPORATE IT. AUTODESK
00009 //  PROVIDES THE CODE ON AN "AS-IS" BASIS AND EXPLICITLY DISCLAIMS ANY
00010 //  LIABILITY, INCLUDING CONSEQUENTIAL AND INCIDENTAL DAMAGES FOR ERRORS,
00011 //  OMISSIONS, AND OTHER PROBLEMS IN THE CODE.
00012 //
00013 //  Use, duplication, or disclosure by the U.S. Government is subject to
00014 //  restrictions set forth in FAR 52.227-19 (Commercial Computer Software
00015 //  Restricted Rights) and DFAR 252.227-7013(c)(1)(ii) (Rights in Technical
00016 //  Data and Computer Software), as applicable.
00017 //
00018 
00019 #ifndef _DWFTK_MODEL_H
00020 #define _DWFTK_MODEL_H
00021 
00022 
00027 
00028 #ifndef DWFTK_READ_ONLY
00029 
00030 
00031 #include "dwfcore/STL.h"
00032 #include "dwfcore/TempFile.h"
00033 #include "dwfcore/OutputStream.h"
00034 using namespace DWFCore;
00035 
00036 #include "dwf/Toolkit.h"
00037 #include "dwf/w3dtk/W3DCamera.h"
00038 #include "dwf/w3dtk/W3DStreamWriter.h"
00039 #include "dwf/package/Units.h"
00040 #include "dwf/publisher/Publisher.h"
00041 #include "dwf/publisher/model/Segment.h"
00042 #include "dwf/publisher/model/StyleSegment.h"
00043 #include "dwf/publisher/model/IncludeSegment.h"
00044 
00045 
00046 
00047 namespace DWFToolkit
00048 {
00049 
00066 class DWFModel : public DWFToolkitMemory
00067                , public DWFPublishableSection
00068                , public DWFPropertyContainer
00069                , private DWFPublishedObject::Factory
00070                , private DWFSegmentHandlerBuilder
00071                , private DWFGeometryHandlerBuilder
00072                , private DWFFeatureHandlerBuilder
00073                , private DWFAttributeHandlerBuilder
00074 {
00075 
00076 public:
00077 
00081     static char const keNormal_FullResolution = -1;
00085     static char const keNormal_DefaultResolution = 24;
00089     static char const keNormal_MaximumResolution = 72;
00093     static char const keVertex_FullResolution = -1;
00097     static char const keVertex_DefaultResolution = 54;
00101     static char const keVertex_MaximumResolution = 72;
00105     static char const keTextureParameter_FullResolution = -1;
00109     static char const keTextureParameter_DefaultResolution = 54;
00113     static char const keTextureParameter_MaximumResolution = 72;
00114 
00119     typedef enum
00120     {
00121         eHandednessLeft,
00122         eHandednessRight,
00123 
00124         eHandednessNone
00125 
00126     } tePolygonHandedness;
00127 
00128 public:
00129 
00135     class ResourceIterator : public DWFToolkitMemory
00136                            , public DWFIterator<DWFPublishableResource*>
00137     {
00138 
00139     public:
00140 
00147         ResourceIterator( DWFPublishableResource::tList& rVector )
00148             throw()
00149             : _rVector( rVector )
00150             , _iCurrent( 0 )
00151         {;}
00152 
00159         ResourceIterator( const ResourceIterator& i )
00160             throw()
00161             : _rVector( i._rVector )
00162             , _iCurrent( i._iCurrent )
00163         {;}
00164 
00171         ResourceIterator& operator=( const ResourceIterator& i )
00172             throw()
00173         {
00174             _iCurrent = i._iCurrent;
00175 
00176             size_t n = 0;
00177             for (; n < i._rVector.size(); n++)
00178             {
00179                 _rVector.push_back( i._rVector[n] );
00180             }
00181 
00182             return *this;
00183         }
00184 
00190         virtual ~ResourceIterator()
00191             throw()
00192         {;}
00193 
00197         void reset()
00198             throw()
00199         {
00200             _iCurrent = 0;
00201         }
00202 
00206         bool valid()
00207             throw()
00208         {
00209             return (_iCurrent < _rVector.size());
00210         }
00211 
00215         bool next()
00216             throw()
00217         {
00218             if (valid())
00219             {
00220                 _iCurrent++;
00221                 return valid();
00222             }
00223             else
00224             {
00225                 return false;
00226             }
00227         }
00228 
00232         DWFPublishableResource*& get()
00233             throw( DWFException )
00234         {
00235             if (valid())
00236             {
00237                 return _rVector[_iCurrent];
00238             }
00239             else
00240             {
00241                 _DWFCORE_THROW( DWFDoesNotExistException, L"No more elements" );
00242             }
00243         }
00244 
00245     private:
00246 
00247         DWFPublishableResource::tList& _rVector;
00248         size_t  _iCurrent;
00249     };
00250 
00251 public:
00252 
00264     _DWFTK_API
00265     DWFModel( DWFOutputStream& rModelStream,
00266               const DWFString& zModelTitle = "",
00267               const DWFString& zModelSource = "",
00268               const DWFString& zModelSourceID = ""  )
00269         throw();
00270 
00281     _DWFTK_API
00282     DWFModel( const DWFString& zModelTitle = "",
00283               const DWFString& zModelSource = "",
00284               const DWFString& zModelSourceID = "" )
00285         throw();
00286 
00292     _DWFTK_API
00293     ~DWFModel()
00294         throw();
00295 
00335     _DWFTK_API
00336     void open( tePolygonHandedness  ePolygonHandedness,
00337                DWFUnits::teType     eModelUnits,
00338                double*              pTransform          = NULL,
00339                bool                 bUseDefaultLighting = true,
00340                bool                 bUsePublishedEdges = false,
00341                bool                 bUseSilhouetteEdges = false )
00342         throw( DWFException );
00343 
00352     _DWFTK_API
00353     void close()
00354         throw( DWFException );
00355 
00367     _DWFTK_API
00368     void enableW3DCompression( bool bEnableStreamCompression = true,
00369                                bool bEnableConnectivityCompression = true,
00370                                bool bEnableGlobalQuantizationCompression = false )
00371         throw( DWFException );
00372 
00388     _DWFTK_API
00389     void enableNormalsCompression( char nTotalNormalBits = keNormal_DefaultResolution )
00390         throw();
00391 
00423     _DWFTK_API
00424     void enableVertexCompression( char nTotalVertexBits = keVertex_DefaultResolution,
00425                                   char nTotalParameterBits = keTextureParameter_FullResolution )
00426         throw();
00427 
00439     _DWFTK_API
00440     void disableAllCompression()
00441         throw( DWFException );
00442 
00449     _DWFTK_API
00450     void publish( DWFPublisher& rPublisher )
00451         throw( DWFException );
00452 
00453         //
00454         //
00455         // Scene Graphics
00456         //
00457         //
00458 
00465     _DWFTK_API
00466     DWFSegment openSegment()
00467         throw( DWFException );
00468 
00475     _DWFTK_API
00476     DWFIncludeSegment openIncludeSegment()
00477         throw( DWFException );
00478 
00485     _DWFTK_API
00486     DWFStyleSegment openStyleSegment()
00487         throw( DWFException );
00488 
00500     _DWFTK_API
00501     void createView( const char*    zName,
00502                      W3DCamera&     rViewCamera )
00503         throw( DWFException );
00504 
00520     _DWFTK_API
00521     void setBoundingCube( float nMinX,   float nMinY,    float nMinZ,
00522                           float nMaxX,   float nMaxY,    float nMaxZ )
00523          throw( DWFException );
00524 
00538     _DWFTK_API
00539     void setBoundingSphere( float nCenterX, float nCenterY, float nCenterZ,
00540                             float nRadius )
00541         throw( DWFException );
00542 
00550     _DWFTK_API
00551     void setEdgeColor( float anRGB[3] )
00552         throw();
00553 
00554         //
00555         //
00556         // Publishable features
00557         //
00558         //
00559 
00566     _DWFTK_API
00567     const DWFString& getModelTitle() const
00568         throw();
00569 
00576     _DWFTK_API
00577     const DWFString& getModelSource() const
00578         throw();
00579 
00586     _DWFTK_API
00587     const DWFString& getModelSourceID() const
00588         throw();
00589 
00596     _DWFTK_API
00597     const W3DCamera* getDefaultView() const
00598         throw();
00599 
00612     _DWFTK_API
00613     void getBoundingVolume( vector<double>& rBounds ) const
00614         throw();
00615 
00627     _DWFTK_API
00628     bool useModelLighting() const
00629         throw();
00630 
00641     _DWFTK_API
00642     bool useSilhouetteEdges() const
00643         throw();
00644 
00651     _DWFTK_API
00652     const float* const getEdgeColor() const
00653         throw();
00654 
00662     _DWFTK_API
00663     DWFUnits::teType getUnits() const
00664         throw();
00665 
00680     _DWFTK_API
00681     void getTransform( double* pTransform ) const
00682         throw();
00683 
00690     _DWFTK_API
00691     tePolygonHandedness getPolygonHandedness() const
00692         throw();
00693 
00694         //
00695         //
00696         // Publishable Interface
00697         //
00698         //
00699 
00703     _DWFTK_API
00704     const DWFString& getMIMEType()
00705         throw( DWFException );
00706 
00710     _DWFTK_API
00711     DWFInputStream* getInputStream()
00712         throw( DWFException );
00713 
00717     _DWFTK_API
00718     void embedFont( DWFEmbeddedFont* pFont )
00719         throw( DWFException );
00720 
00724     _DWFTK_API
00725     void addResource( DWFPublishableResource* pResource )
00726         throw( DWFException );
00727 
00731     _DWFTK_API
00732     DWFIterator<DWFPublishableResource*>* getResources()
00733         throw( DWFException );
00734 
00735 private:
00736 
00740     DWFPublishedObject* makePublishedObject( DWFPublishedObject::tKey nKey,
00741                                              const DWFString&      zName )
00742         throw( DWFException );
00743 
00747     DWFPublishedObject& findPublishedObject( DWFPublishedObject::tKey nKey )
00748         throw( DWFException );
00749 
00750 private:
00751 
00752         //
00753         //
00754         // SegmentHandlerBuilder Interface
00755         //
00756         //
00757 
00758     TK_Close_Segment& getCloseSegmentHandler()
00759         throw( DWFException );
00760 
00761     TK_Open_Segment& getOpenSegmentHandler()
00762         throw( DWFException );
00763 
00764     TK_Referenced_Segment& getIncludeSegmentHandler()
00765         throw( DWFException );
00766 
00767     TK_Referenced_Segment& getStyleSegmentHandler()
00768         throw( DWFException );
00769 
00770         //
00771         //
00772         // GeometryHandlerBuilder Interface
00773         //
00774         //
00775 
00776     TK_Area_Light& getAreaLightHandler()
00777         throw( DWFException );
00778 
00779     TK_Circle& getCircleHandler()
00780         throw( DWFException );
00781 
00782     TK_Circle& getCircularArcHandler()
00783         throw( DWFException );
00784 
00785     TK_Circle& getCircularChordHandler()
00786         throw( DWFException );
00787 
00788     TK_Circle& getCircularWedgeHandler()
00789         throw( DWFException );
00790 
00791     TK_Cutting_Plane& getCuttingPlaneHandler()
00792         throw( DWFException );
00793 
00794     TK_Point& getDistantLightHandler()
00795         throw( DWFException );
00796 
00797     TK_Ellipse& getEllipseHandler()
00798         throw( DWFException );
00799 
00800     TK_Ellipse& getEllipticalArcHandler()
00801         throw( DWFException );
00802 
00803     TK_Image& getImageHandler()
00804         throw( DWFException );
00805 
00806     TK_Line& getLineHandler()
00807         throw( DWFException );
00808 
00809     TK_Point& getLocalLightHandler()
00810         throw( DWFException );
00811 
00812     TK_NURBS_Curve& getNURBSCurveHandler()
00813         throw( DWFException );
00814 
00815     TK_NURBS_Surface& getNURBSSurfaceHandler()
00816         throw( DWFException );
00817 
00818     TK_PolyCylinder& getPolyCylinderHandler()
00819         throw( DWFException );
00820 
00821     TK_Polypoint& getPolygonHandler()
00822         throw( DWFException );
00823 
00824     TK_Polypoint& getPolylineHandler()
00825         throw( DWFException );
00826 
00827     //
00828     // IMPORTANT:   Setting this flag to true when you data is not in tristrips may produce garbage.
00829     //
00830     // bTriStripsOnly - the shell is assumed to contain triangles only and may not contain holes,
00831     //                  and the "faces" are actually the way that vertices are connected into triangle strips.
00832     //                  Start with the length of the strip, followed by the vertex indices to be connected.
00833     //                  The first 3 vertices form a triangle, and every additional vertex is
00834     //                  combined with the two previous ones to  define one additional triangle.
00835     //                  Exactly as with OpenGL's GL_TRIANGLE_STRIP primitive,
00836     //                  the orientation of every even triangle is reversed, beginning with the second.
00837     //
00838     // bDisableOptimization - Disable vertex and face optimization algorithm just before stream serialization
00839     //                          This optimization is on by default, it's tolerance parameters may be tuned
00840     //                          by calling optimize() (this method can also be used to disable the process)
00841     //
00842     TK_Shell& getShellHandler( bool bTriStripsOnly = false,
00843                                bool bDisableOptimization = false )
00844         throw( DWFException );
00845 
00846     TK_Spot_Light& getSpotLightHandler()
00847         throw( DWFException );
00848 
00849     TK_Text& getTextHandler()
00850         throw( DWFException );
00851 
00852     TK_Text& getTextWithEncodingHandler()
00853         throw( DWFException );
00854 
00855         //
00856         //
00857         // FeatureHandlerBuilder Interface
00858         //
00859         //
00860 
00861     TK_Texture& getTextureHandler()
00862         throw( DWFException );
00863 
00864     TK_Matrix& getTextureMatrixHandler()
00865         throw( DWFException );
00866 
00867         //
00868         //
00869         // AttributeHandlerBuilder Interface
00870         //
00871         //
00872 
00873     TK_Color& getColorHandler()
00874         throw( DWFException );
00875 
00876     TK_Color_Map& getColorMapHandler()
00877         throw( DWFException );
00878 
00879     TK_Color_RGB& getColorRGBHandler()
00880         throw( DWFException );
00881 
00882     TK_Linear_Pattern& getEdgePatternHandler()
00883         throw( DWFException );
00884 
00885     TK_Size& getEdgeWeightHandler()
00886         throw( DWFException );
00887 
00888     TK_Enumerated& getFacePatternHandler()
00889         throw( DWFException );
00890 
00891     TK_Enumerated& getHandednessHandler()
00892         throw( DWFException );
00893 
00894     TK_Heuristics& getHeuristicsHandler()
00895         throw( DWFException );
00896 
00897     TK_Linear_Pattern& getLinePatternHandler()
00898         throw( DWFException );
00899 
00900     TK_Size& getLineWeightHandler()
00901         throw( DWFException );
00902 
00903     TK_Size& getMarkerSizeHandler()
00904         throw( DWFException );
00905 
00906     TK_Enumerated& getMarkerSymbolHandler()
00907         throw( DWFException );
00908 
00909     TK_Matrix& getModellingMatrixHandler()
00910         throw( DWFException );
00911 
00912     TK_Rendering_Options& getRenderingOptionsHandler()
00913         throw( DWFException );
00914 
00915     TK_Selectability& getSelectabilityHandler()
00916         throw( DWFException );
00917 
00918     TK_Enumerated& getTextAlignmentHandler()
00919         throw( DWFException );
00920 
00921     TK_Text_Font& getTextFontHandler()
00922         throw( DWFException );
00923 
00924     TK_Point& getTextPathHandler()
00925         throw( DWFException );
00926 
00927     TK_Size& getTextSpacingHandler()
00928         throw( DWFException );
00929 
00930     TK_User_Options& getUserOptionsHandler()
00931         throw( DWFException );
00932 
00933     TK_Unicode_Options& getUnicodeOptionsHandler()
00934         throw( DWFException );
00935 
00936     TK_Visibility& getVisibilityHandler()
00937         throw( DWFException );
00938 
00939     TK_Camera& getCameraHandler()
00940         throw( DWFException );
00941 
00942     TK_Camera& getViewHandler()
00943         throw( DWFException );
00944 
00945 private:
00946 
00947     bool                    _bOpen;
00948     bool                    _bCompress;
00949     bool                    _bStreamDefaults;
00950     bool                    _bBoundingVolumeSet;
00951     bool                    _bUseDefaultLighting;
00952     bool                    _bModelLightsUsed;
00953     bool                    _bUseSilhouetteEdges;
00954     bool                    _bSetEdgeColor;
00955     float                   _anEdgeColor[3];
00956 
00957     DWFUnits::teType        _eUnits;
00958     double                  _anUnitsTransform[16];
00959     tePolygonHandedness     _eHandedness;
00960 
00961     unsigned int            _nStyleSegments;
00962 
00963     DWFString               _zMIME;
00964     DWFString               _zTitle;
00965     DWFString               _zSource;
00966     DWFString               _zSourceID;
00967 
00968     DWFTempFile*            _pW3DFile;
00969 
00970     BStreamFileToolkit      _oToolkit;
00971     W3DStreamWriter*        _pW3DStreamWriter;
00972     W3DCamera*              _pDefaultViewCamera;
00973 
00974     vector<double>                  _oBoundingVolume;
00975     DWFEmbeddedFont::tList          _oEmbeddedFonts;
00976     DWFPublishableResource::tList   _oResources;
00977     DWFPublishedObject::tMap        _oPublishedObjects;
00978 
00979 private:
00980 
00981     //
00982     // Not Implemented
00983     //
00984 
00985     DWFModel( const DWFModel& );
00986     DWFModel& operator=( const DWFModel& );
00987 };
00988 
00989 
00990 }
00991 
00992 
00993 #endif
00994 #endif

Generated on Tue May 17 12:38:51 2005 for Autodesk DWF Toolkit by  doxygen 1.4.1