Index: GTP/trunk/Lib/Vis/Preprocessing/src/HierarchyManager.h
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/HierarchyManager.h	(revision 2353)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/HierarchyManager.h	(revision 2530)
@@ -197,14 +197,11 @@
 	*/
 	HierarchyManager(const int objectSpaceHierarchyType);
-	
 	/** Hack: OspTree will copy the content from this kd tree.
 		Only view space hierarchy will be constructed.
 	*/
 	HierarchyManager(KdTree *kdTree);
-
 	/** Deletes space partition and view space partition.
 	*/
 	~HierarchyManager();
-
 	/** Constructs the view space and object space subdivision from a given set of rays
 		and a set of objects.
@@ -233,33 +230,25 @@
 	*/
 	int GetObjectSpaceSubdivisionType() const;	
-	
 	/** The type of view space space subdivison
 	*/
 	int GetViewSpaceSubdivisionType() const;
-	
 	/** Sets a pointer to the view cells manager.
 	*/		
 	void SetViewCellsManager(ViewCellsManager *vcm);
-	
 	/** Sets a pointer to the view cells tree.
 	*/
 	void SetViewCellsTree(ViewCellsTree *vcTree);
-
 	/** Exports the object hierarchy to disc.
 	*/
 	void ExportObjectSpaceHierarchy(OUT_STREAM &stream);
-	
 	/** Print out statistics.
 	*/
 	void PrintHierarchyStatistics(std::ostream &stream) const;
-
 	/** Returns the view space partition tree.
 	*/
 	VspTree *GetVspTree();
-
 	/** Returns object space bounding box.
 	*/
 	AxisAlignedBox3 GetObjectSpaceBox() const;
-
 	/** Exports object space hierarchy for visualization.
 	*/
@@ -275,5 +264,4 @@
   
 	Intersectable *GetIntersectable(Intersectable *obj, const Vector3 &point) const;
-
 	/** Export object space partition bounding boxes.
 	*/
@@ -306,6 +294,4 @@
 						   const float totalPvs,
 						   const float raysPerObjects) const;
-
-
 	/** Casts line segment into the view cells tree.
 		@param origin the origin of the line segment
@@ -346,6 +332,6 @@
 
 
-	//////////////////////////////
-	// the main loop
+	//////////////
+	// these functions implement the main loop
 
 	/** This is for interleaved construction / sequential construction.
@@ -355,5 +341,4 @@
 						 const ObjectContainer &objects,
 						 AxisAlignedBox3 *forcedViewSpace);
-	
 	/** This is for interleaved construction using some objects 
 		and some view space splits.
@@ -365,5 +350,4 @@
 						const int minSteps,
 						const int maxSteps);
-
 	/** Default subdivision method.
 	*/
@@ -371,5 +355,5 @@
 	
 	
-	////////////////////////////////////////////////
+	//////////////////////////
 
 	/** Evaluates the subdivision candidate and executes the split.
@@ -380,13 +364,10 @@
 								   std::vector<SubdivisionCandidate *> &dirtyList
 								   );
-
 	/** Tests if hierarchy construction is finished.
 	*/
 	bool FinishedConstruction() const;
-
 	/** Returns next subdivision candidate from the split queue.
 	*/
 	SubdivisionCandidate *NextSubdivisionCandidate(SplitQueue &splitQueue);
-
 	/** Repairs the dirty entries of the subdivision candidate queue. The
 		list of entries is given in the dirty list.
@@ -397,5 +378,4 @@
 					SplitQueue &splitQueue,
 					const bool recomputeSplitPlaneOnRepair);
-
 	/** Collect subdivision candidates which were affected by the splits from the
 		chosenCandidates list.
@@ -403,5 +383,4 @@
 	void CollectDirtyCandidates(const SubdivisionCandidateContainer &chosenCandidates, 
 								SubdivisionCandidateContainer &dirtyList);
-
 	/** Print subdivision stats for log.
 	*/
@@ -420,15 +399,12 @@
 	void CollectViewSpaceDirtyList(SubdivisionCandidate *sc,
 								   SubdivisionCandidateContainer &dirtyList);
-
 	/** Collect affected object space candidates.
 	*/
 	void CollectObjectSpaceDirtyList(SubdivisionCandidate *sc,
 									 SubdivisionCandidateContainer &dirtyList);
-		
 	/** Export object space partition tree.
 	*/
 	void ExportOspTree(Exporter *exporter, 
 					   const ObjectContainer &objects) const;
-
 	/** Parse the environment variables.
 	*/
@@ -463,27 +439,21 @@
 	*/
 	bool ObjectSpaceSubdivisionConstructed() const;
-	
 	/** Was view space subdivision already constructed?
 	*/
 	bool ViewSpaceSubdivisionConstructed() const;
-
 	/** Reset the split queue, i.e., reevaluate the split candidates.
 	*/
     void ResetQueue(SplitQueue &splitQueue, const bool recomputeSplitPlane);
-
 	/** After the suddivision has ended, do some final tasks.
 	*/
 	void FinishObjectSpaceSubdivision(const ObjectContainer &objects, 
 									  const bool removeRayRefs = true) const;
-
 	/** Returns depth of object space subdivision.
 	*/
 	int GetObjectSpaceSubdivisionDepth() const;
-
 	/** Returns number of leaves in object space subdivision.
 	*/
 	int GetObjectSpaceSubdivisionLeaves() const;
 	int GetObjectSpaceSubdivisionNodes() const;
-
 	/** Construct object space partition interleaved with view space partition.
 		Each time the best object or view space candidate is selected
@@ -493,5 +463,4 @@
 							  const ObjectContainer &objects,
 							  AxisAlignedBox3 *forcedViewSpace);
-
 	/** Construct object space partition interleaved with view space partition.
 		The method chooses a number candidates of each type for subdivision.
@@ -505,5 +474,4 @@
 										  const ObjectContainer &objects,
 										  AxisAlignedBox3 *forcedViewSpace);
-
 	/** Use iteration to construct the object space hierarchy.
 	*/
@@ -511,5 +479,4 @@
 							 const ObjectContainer &objects,
 							 AxisAlignedBox3 *forcedViewSpace);
-
 	/** Based on a given subdivision, we try to optimize using an
 		multiple iteration over view and object space.
@@ -518,5 +485,4 @@
 							const ObjectContainer &objects,
 							AxisAlignedBox3 *forcedViewSpace);
-
 	/** Reset the object space subdivision. 
 		E.g., deletes hierarchy and resets stats.
@@ -533,4 +499,5 @@
 
 	void CreateTraversalTree();
+
 
 	///////////////////////////
@@ -570,4 +537,10 @@
 protected:
 
+	friend VspTree;
+	friend OspTree;
+	friend BvHierarchy;
+	friend ViewCellsParseHandlers;
+
+
 	/** construction types
 		sequential: construct first view space, then object space
@@ -580,5 +553,4 @@
 	/// type of hierarchy construction
 	int mConstructionType;
-
 	/// Type of object space partition
 	int mObjectSpaceSubdivisionType;
@@ -586,14 +558,6 @@
     int mViewSpaceSubdivisionType;
 
-	/// the traversal queue
+	/// the queue maintains the split candidates during traversal
 	SplitQueue mTQueue;
-	
-	////////////
-	//-- helper variables
-	
-	// the original osp type
-	int mSavedObjectSpaceSubdivisionType;
-	// the original vsp type
-	int mSavedViewSpaceSubdivisionType;
 	
 
@@ -601,4 +565,6 @@
 	// Hierarchies
 
+	/// the bounding volume hierarchy
+	BvHierarchy *mBvHierarchy;
 	/// view space hierarchy
 	VspTree *mVspTree;
@@ -608,20 +574,10 @@
 	float mInitialRenderCost;
 	
-	//float mMaxAvgRayContri;
-	//float mMinAvgRayContri;
-
 	float mMaxAvgRaysPerObject;
 	float mMinAvgRaysPerObject;
 
-	// quick hack:
-public:
-	/// bounding volume hierarchy
-	BvHierarchy *mBvHierarchy;
-	
+
+	/// an internal tree optimized for view cell traversal
 	bool mUseTraversalTree;
-
-	float mMinRenderCost;
-
-protected:
 
 
@@ -638,4 +594,6 @@
 	float mTermMaxMemory;
 
+	float mMinRenderCost;
+
 
 	////////////////////
@@ -651,29 +609,23 @@
 	int mMinDepthForViewSpaceSubdivion;
 	
-	//int mMinRenderCostDecrease;
-
-	std::ofstream mSubdivisionStats;
-
 	/// if the queue should be repaired after a subdivision steps
 	bool mRepairQueue;
 
 	bool mStartWithObjectSpace;
-	/** if multi level construction method should be used
-		where we iterate over both hierarchies until we
-		converge to the optimum.
+	/** multi level construction method  means that
+		we iterate over both hierarchies until we
+		converge to the optimum. 
 	*/
 	bool mUseMultiLevelConstruction;
-
 	/// number of iteration steps for multilevel approach	
 	int mNumMultiLevels;
-
 	/** if split plane should be recomputed for the repair.
 		Otherwise only the priority is recomputed, the
-		split plane itself stays the same
+		split plane itself stays the same. 
 	*/
 	bool mRecomputeSplitPlaneOnRepair;
 
 	/** If memory should be considered during choosing
-		of the next split type during gradient method.
+		of the next split type during gradient method. 
 	*/
 	bool mConsiderMemory;
@@ -684,13 +636,21 @@
 
 	int mTimeStamp;
-	friend VspTree;
-	friend OspTree;
-	friend BvHierarchy;
 
 	float mPriority;
 
-	friend ViewCellsParseHandlers;
-
+
+	////////////
+	//-- helper variables
+	
+	// the original osp type
+	int mSavedObjectSpaceSubdivisionType;
+	// the original vsp type
+	int mSavedViewSpaceSubdivisionType;
+	
+
+	/// this is just a cache used during evaluation
 	ViewCellContainer mOldViewCells;
+
+	std::ofstream mSubdivisionStats;
 };
 
