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

OSGTileLoadBalancer.h

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------------*\
00002  *                                OpenSG                                     *
00003  *                                                                           *
00004  *                                                                           *
00005  *             Copyright (C) 2000-2002 by the OpenSG Forum                   *
00006  *                                                                           *
00007  *                            www.opensg.org                                 *
00008  *                                                                           *
00009  *   contact: dirk@opensg.org, gerrit.voss@vossg.org, jbehr@zgdv.de          *
00010  *                                                                           *
00011 \*---------------------------------------------------------------------------*/
00012 /*---------------------------------------------------------------------------*\
00013  *                                License                                    *
00014  *                                                                           *
00015  * This library is free software; you can redistribute it and/or modify it   *
00016  * under the terms of the GNU Library General Public License as published    *
00017  * by the Free Software Foundation, version 2.                               *
00018  *                                                                           *
00019  * This library is distributed in the hope that it will be useful, but       *
00020  * WITHOUT ANY WARRANTY; without even the implied warranty of                *
00021  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU         *
00022  * Library General Public License for more details.                          *
00023  *                                                                           *
00024  * You should have received a copy of the GNU Library General Public         *
00025  * License along with this library; if not, write to the Free Software       *
00026  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.                 *
00027  *                                                                           *
00028 \*---------------------------------------------------------------------------*/
00029 /*---------------------------------------------------------------------------*\
00030  *                                Changes                                    *
00031  *                                                                           *
00032  *                                                                           *
00033  *                                                                           *
00034  *                                                                           *
00035  *                                                                           *
00036  *                                                                           *
00037 \*---------------------------------------------------------------------------*/
00038 
00039 #ifndef _GEO_TILE_LOAD_BALANCER_H_
00040 #define _GEO_TILE_LOAD_BALANCER_H_
00041 #ifdef __sgi
00042 #pragma once
00043 #endif
00044 
00045 #include <map>
00046 #include <vector>
00047 #include <OSGSystemDef.h>
00048 #include <OSGBaseTypes.h>
00049 #include <OSGTileGeometryLoad.h>
00050 #include <OSGRenderNode.h>
00051 
00052 OSG_BEGIN_NAMESPACE
00053 
00054 class Action;
00055 
00056 class OSG_SYSTEMLIB_DLLMAPPING TileLoadBalancer
00057 {
00058     /*==========================  PUBLIC  =================================*/
00059   public:
00060     struct Region {
00061         Int32  x1,y1,x2,y2;
00062         Real32 culledFaces;
00063         Real32 culledNodes;
00064         Real32 faces;
00065         Real32 pixel;
00066     };
00067     typedef std::vector<TileGeometryLoad>                   TileGeometryLoadLstT;
00068     typedef std::map<UInt32,TileGeometryLoadLstT::iterator> TileGeometryLoadMapT;
00069     typedef std::vector<Region>                    ResultT;
00070     typedef std::vector<RenderNode>                RenderNodeLstT;
00071 
00072     /*---------------------------------------------------------------------*/
00077     /*---------------------------------------------------------------------*/
00082     /*---------------------------------------------------------------------*/
00086     TileLoadBalancer(bool useFaceDistribution=false,
00087                      bool cutBestDirection=true);
00088     TileLoadBalancer(const TileLoadBalancer &source);
00089 
00091     /*---------------------------------------------------------------------*/
00095     TileLoadBalancer& operator =(const TileLoadBalancer &source);
00096 
00098     /*---------------------------------------------------------------------*/
00102     virtual ~TileLoadBalancer(void);
00103 
00105     /*---------------------------------------------------------------------*/
00109     void update             (NodePtr           node   );
00110     void balance            (ViewportPtr       vp,
00111                              bool              shrink,
00112                              ResultT          &result );
00113     void addRenderNode      (const RenderNode &rn,UInt32 id);
00114     void drawVolumes        (WindowPtr win);
00115     void setRegionStatistics(ViewportPtr           vp,
00116                              ResultT              &result);
00117 
00119     /*---------------------------------------------------------------------*/
00124     /*---------------------------------------------------------------------*/
00129     /*---------------------------------------------------------------------*/
00134     /*=========================  PROTECTED  ===============================*/
00135   protected:
00136 
00137     /*---------------------------------------------------------------------*/
00141     class RegionLoad 
00142     {
00143       public:
00144         RegionLoad         ( TileGeometryLoad *load=NULL           );
00145         Real32   getCost   ( const RenderNode &renderNode );
00146         Real32   getCost   ( const RenderNode &renderNode,
00147                              const Int32 wmin[2],
00148                              const Int32 wmax[2]          ) const;
00149         TileGeometryLoad *getLoad   ( void                         );
00150         void     updateCost( const Int32 wmin[2],
00151                              const Int32 wmax[2]          );
00152       private:
00153         Real32   _visibleFaces;
00154         Real32   _invisibleFaces;
00155         Real32   _pixel;
00156         TileGeometryLoad *_load;
00157     };
00158     typedef std::vector<RegionLoad>   RegionLoadVecT;
00159 
00161     /*---------------------------------------------------------------------*/
00165     TileGeometryLoadLstT  _tileGeometryLoad;
00166     RenderNodeLstT        _renderNode;
00167     bool                  _useFaceDistribution;
00168     bool                  _cutBestDirection;
00169 
00171     /*---------------------------------------------------------------------*/
00175     double runFaceBench(GLuint dlist,UInt32 size,Real32 visible);
00176     void updateSubtree (NodePtr &node,TileGeometryLoadMapT &loadMap);
00177     void splitRegion   (UInt32          rnFrom,
00178                         UInt32          rnTo,
00179                         RegionLoadVecT &visible,
00180                         Int32           amin[2],
00181                         Int32           amax[2],
00182                         UInt32          depth,
00183                         ResultT        &result);
00184     Real32 findBestCut (const RenderNode &renderNodeA,
00185                         const RenderNode &renderNodeB,
00186                         RegionLoadVecT &visible,
00187                         Int32           amin[2],
00188                         Int32           amax[2],
00189                         Int32          &bestAxis,
00190                         Int32          &bestCut);
00191     double calcFaceRenderingCost(TileGeometryLoad *load,
00192                                  Int32 amin[2],Int32 amax[2]);
00193 
00196     /*==========================  PRIVATE  ================================*/
00197   private:
00198     friend class RegionLoad;
00199 };
00200 
00201 OSG_END_NAMESPACE
00202 
00203 #include "OSGTileLoadBalancer.inl"
00204 
00205 #define OSG_TILE_LOAD_BALANCER_HEADER_CVSID "@(#)$Id:$"
00206 
00207 #endif /* _TILE_GEOMETRY_LOADMANAGER_H_ */
00208 
00209 
00210 
00211 

Generated on Thu Aug 25 04:11:43 2005 for OpenSG by  doxygen 1.4.3