Index: trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellsManager.h
===================================================================
--- trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellsManager.h	(revision 579)
+++ trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellsManager.h	(revision 580)
@@ -27,4 +27,6 @@
 class Beam;
 class Preprocessor;
+class ViewCellsTree;
+class MergeCandidate;
 
 struct BspRay;
@@ -133,9 +135,9 @@
 		@returns new view cell based on the merging.
 	*/
-	ViewCell *MergeViewCells(ViewCell &front, ViewCell &back) const;
+	ViewCellInterior *MergeViewCells(ViewCell &front, ViewCell &back) const;
 	
 	/** Generates view cell of type specified by this manager
 	*/
-	virtual ViewCell *GenerateViewCell(Mesh *mesh = NULL) const;
+	virtual ViewCell *GenerateViewCell(Mesh *mesh = NULL) const = 0;
 
 	/** Adds a new view cell to the list of predefined view cells.
@@ -206,5 +208,5 @@
 	virtual float GetRendercost(ViewCell *viewCell, float objRendercost) const = 0;
 
-	/** Returns vector of loaded / generated view cells.
+	/** Returns container of loaded / generated view cells.
 	*/
 	ViewCellContainer &GetViewCells();
@@ -311,5 +313,5 @@
 	/** Exports view cell geometry.
 	*/
-	virtual void ExportVcGeometry(Exporter *exporter, ViewCell *vc) const = 0;
+	virtual void ExportViewCellGeometry(Exporter *exporter, ViewCell *vc) const = 0;
 
 	virtual void FinalizeViewCells(const bool createMesh);
@@ -325,7 +327,18 @@
 	/** Evaluates statistics values on view cells.
 	*/
-	void EvaluateRenderStatistics(float &totalRenderCost, 
-								  float &expectedRenderCost, 
-								  float &variance);
+	void EvaluateRenderStatistics(float &totalRenderCost,
+								  float &expectedRenderCost,
+								  float &deviation,
+								  float &variance,
+								  int &totalPvs,
+								  float &avgRenderCost);
+
+
+	/** Returns hierarchy of the view cells.
+	*/
+	ViewCellsTree *GetViewCellsTree();
+
+	virtual void CollectMergeCandidates(const VssRayContainer &rays, vector<MergeCandidate> &candidates) = 0;
+
 
 protected:
@@ -392,4 +405,6 @@
 	/// Loaded view cells
 	ViewCellContainer mViewCells;
+
+	ViewCellsTree *mViewCellsTree;
 
 	/// maximum number of samples taken for construction of the view cells
@@ -417,4 +432,8 @@
 	bool mOnlyValidViewCells;
 
+	/// if rays should be used to collect merge candidates
+	bool mUseRaysForMerge;
+	
+
 	//-- visualization options
 	
@@ -472,5 +491,7 @@
 	void CreateMesh(ViewCell *vc);
 
-	void ExportVcGeometry(Exporter *exporter, ViewCell *vc) const;
+	void ExportViewCellGeometry(Exporter *exporter, ViewCell *vc) const;
+	
+	void CollectMergeCandidates(const VssRayContainer &rays, vector<MergeCandidate> &candidates);
 
 protected:
@@ -529,4 +550,5 @@
 	bool ViewCellsConstructed() const;
 
+	ViewCell *GenerateViewCell(Mesh *mesh) const;
 
 	/** Prints out statistics of this approach.
@@ -540,9 +562,14 @@
 	void CreateMesh(ViewCell *vc);
 
-	void ExportVcGeometry(Exporter *exporter, ViewCell *vc) const;
+	void ExportViewCellGeometry(Exporter *exporter, ViewCell *vc) const;
+
+	void CollectMergeCandidates(const VssRayContainer &rays, vector<MergeCandidate> &candidates);
 
 protected:
 
+	/** Collects view cells from a hierarchy.
+	*/
 	void CollectViewCells();
+
 	KdNode *GetNodeForPvs(KdLeaf *leaf);
 
@@ -598,5 +625,7 @@
 	void CreateMesh(ViewCell *vc);
 
-	void ExportVcGeometry(Exporter *exporter, ViewCell *vc) const;
+	void ExportViewCellGeometry(Exporter *exporter, ViewCell *vc) const;
+
+	void CollectMergeCandidates(const VssRayContainer &rays, vector<MergeCandidate> &candidates);
 
 protected:
@@ -664,9 +693,11 @@
 	int CastBeam(Beam &beam);
 
-	void ExportVcGeometry(Exporter *exporter, ViewCell *vc) const;
+	void ExportViewCellGeometry(Exporter *exporter, ViewCell *vc) const;
 
 	//float GetVolume(ViewCell *viewCell) const;
 
 	void Finalize(ViewCell *viewCell, const bool createMesh);
+
+	void CollectMergeCandidates(const VssRayContainer &rays, vector<MergeCandidate> &candidates);
 
 protected:
