changed: gcc8 base update
[opensg.git] / Source / System / Cluster / Window / SortFirst / OSGTileLoadBalancer.h
blobd1f5b3ee4e930dc97e611123dad05fe09e791875
1 /*---------------------------------------------------------------------------*\
2 * OpenSG *
3 * *
4 * *
5 * Copyright (C) 2000-2002 by the OpenSG Forum *
6 * *
7 * www.opensg.org *
8 * *
9 * contact: dirk@opensg.org, gerrit.voss@vossg.org, jbehr@zgdv.de *
10 * *
11 \*---------------------------------------------------------------------------*/
12 /*---------------------------------------------------------------------------*\
13 * License *
14 * *
15 * This library is free software; you can redistribute it and/or modify it *
16 * under the terms of the GNU Library General Public License as published *
17 * by the Free Software Foundation, version 2. *
18 * *
19 * This library is distributed in the hope that it will be useful, but *
20 * WITHOUT ANY WARRANTY; without even the implied warranty of *
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
22 * Library General Public License for more details. *
23 * *
24 * You should have received a copy of the GNU Library General Public *
25 * License along with this library; if not, write to the Free Software *
26 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. *
27 * *
28 \*---------------------------------------------------------------------------*/
29 /*---------------------------------------------------------------------------*\
30 * Changes *
31 * *
32 * *
33 * *
34 * *
35 * *
36 * *
37 \*---------------------------------------------------------------------------*/
39 #ifndef _OSG_TILE_LOAD_BALANCER_H_
40 #define _OSG_TILE_LOAD_BALANCER_H_
41 #ifdef __sgi
42 #pragma once
43 #endif
45 #include <map>
46 #include <vector>
48 #include "OSGTileGeometryLoad.h"
49 #include "OSGRenderNode.h"
51 OSG_BEGIN_NAMESPACE
53 class Action;
55 /*! \ingroup GrpClusterWindowBalancer
56 \ingroup GrpLibOSGCluster
57 \includebasedoc
60 class OSG_CLUSTER_DLLMAPPING TileLoadBalancer
62 /*========================== PUBLIC =================================*/
64 public:
66 /*! \nohierarchy
69 struct Region
71 Int32 x1,y1,x2,y2;
72 Real32 culledFaces;
73 Real32 culledNodes;
74 Real32 faces;
75 Real32 pixel;
78 typedef std::vector<TileGeometryLoad> TileGeometryLoadLstT;
79 typedef std::map<UInt32,
80 TileGeometryLoadLstT::iterator> TileGeometryLoadMapT;
82 typedef std::vector<Region> ResultT;
83 typedef std::vector<RenderNode> RenderNodeLstT;
85 /*---------------------------------------------------------------------*/
86 /*! \name dcast */
87 /*! \{ */
89 /*! \} */
90 /*---------------------------------------------------------------------*/
91 /*! \name General Fieldcontainer Declaration */
92 /*! \{ */
94 /*! \} */
95 /*---------------------------------------------------------------------*/
96 /*! \name Constructors */
97 /*! \{ */
99 TileLoadBalancer(bool useFaceDistribution=false,
100 bool cutBestDirection=true);
101 TileLoadBalancer(const TileLoadBalancer &source);
103 /*! \} */
104 /*---------------------------------------------------------------------*/
105 /*! \name Assignment */
106 /*! \{ */
108 TileLoadBalancer& operator =(const TileLoadBalancer &source);
110 /*! \} */
111 /*---------------------------------------------------------------------*/
112 /*! \name Destructor */
113 /*! \{ */
115 virtual ~TileLoadBalancer(void);
117 /*! \} */
118 /*---------------------------------------------------------------------*/
119 /*! \name Load balancing functions */
120 /*! \{ */
122 void update (Node *node );
123 void balance (Viewport *vp,
124 bool shrink,
125 ResultT &result );
126 void addRenderNode (const RenderNode &rn,UInt32 id);
127 void drawVolumes (Window *win);
128 void setRegionStatistics(Viewport *vp,
129 ResultT &result);
131 /*! \} */
132 /*---------------------------------------------------------------------*/
133 /*! \name Get */
134 /*! \{ */
136 /*! \} */
137 /*---------------------------------------------------------------------*/
138 /*! \name Set */
139 /*! \{ */
141 /*! \} */
142 /*---------------------------------------------------------------------*/
143 /*! \name Dump */
144 /*! \{ */
146 /*! \} */
147 /*========================= PROTECTED ===============================*/
149 protected:
151 /*---------------------------------------------------------------------*/
152 /*! \name Types */
153 /*! \{ */
155 /*! \nohierarchy
158 class RegionLoad
160 public:
161 RegionLoad ( TileGeometryLoad *load=NULL );
162 Real32 getCost ( const RenderNode &renderNode );
163 Real32 getCost ( const RenderNode &renderNode,
164 const Int32 wmin[2],
165 const Int32 wmax[2] ) const;
166 TileGeometryLoad *getLoad ( void );
167 void updateCost( const Int32 wmin[2],
168 const Int32 wmax[2] );
169 private:
170 Real32 _visibleFaces;
171 Real32 _invisibleFaces;
172 Real32 _pixel;
173 TileGeometryLoad *_load;
176 typedef std::vector<RegionLoad> RegionLoadVecT;
178 /*! \} */
179 /*---------------------------------------------------------------------*/
180 /*! \name Fields */
181 /*! \{ */
183 TileGeometryLoadLstT _tileGeometryLoad;
184 RenderNodeLstT _renderNode;
185 bool _useFaceDistribution;
186 bool _cutBestDirection;
188 /*! \} */
189 /*---------------------------------------------------------------------*/
190 /*! \name Member */
191 /*! \{ */
193 double runFaceBench(GLuint dlist,UInt32 size,Real32 visible);
194 void updateSubtree (Node * const node,TileGeometryLoadMapT &loadMap);
195 void splitRegion (UInt32 rnFrom,
196 UInt32 rnTo,
197 RegionLoadVecT &visible,
198 Int32 amin[2],
199 Int32 amax[2],
200 UInt32 depth,
201 ResultT &result);
202 Real32 findBestCut (const RenderNode &renderNodeA,
203 const RenderNode &renderNodeB,
204 RegionLoadVecT &visible,
205 Int32 amin[2],
206 Int32 amax[2],
207 Int32 &bestAxis,
208 Int32 &bestCut);
209 double calcFaceRenderingCost(TileGeometryLoad *load,
210 Int32 amin[2],Int32 amax[2]);
212 /*! \} */
214 /*========================== PRIVATE ================================*/
216 private:
218 friend class RegionLoad;
221 OSG_END_NAMESPACE
223 #include "OSGTileLoadBalancer.inl"
225 #endif /* _TILE_GEOMETRY_LOADMANAGER_H_ */