Index: GTP/trunk/Lib/Vis/Preprocessing/scripts/generate_viewcells.sh
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/scripts/generate_viewcells.sh	(revision 1456)
+++ GTP/trunk/Lib/Vis/Preprocessing/scripts/generate_viewcells.sh	(revision 1744)
@@ -1,58 +1,29 @@
 #!/bin/sh
 
-PROGRAM=../bin/release/Preprocessor.exe
-#PROGRAM=../bin/Debug/Preprocessor.exe
+# add bin to path
+export PATH=../bin:$PATH
 
-if [ $# -ne 3 ]
-then
-    echo "Usage:"
-	echo "preprocess_visibility scene_file.x3d viewcells_file.xml number_of_viewcells"
-    exit
-fi
+#TARGET=debug
+TARGET=release
 
+PROGRAM=../bin/$TARGET/Preprocessor.exe
 
-
-SCENE=$1
-VIEWCELLS=$2
-NUM_VIEWCELLS=$3
-NUM_SAMPLE_RAYS=500000
-
-LOG_PREFIX=generate_viewcells
-
+SCENE=vienna_cropped
+LOG_PREFIX=../scripts/$SCENE
 ENVIRONMENT=generate_viewcells.env
 
+echo "starting $TARGET mode for $SCENE scene"
 
-###############################################
+############################################################################
 
-METHOD=avs
-echo "$SCENE $METHOD"
+ METHOD=gradient
+ echo "$SCENE $METHOD"
 
-$PROGRAM $ENVIRONMENT \
--scene_filename=$SCENE \
--view_cells_type=vspBspTree \
--view_cells_construction_samples=0 \
--vsp_bsp_construction_samples=$NUM_SAMPLE_RAYS \
--vsp_bsp_term_max_view_cells=$NUM_VIEWCELLS \
--view_cells_evaluation_stats_prefix=$LOG_PREFIX-$METHOD \
--view_cells_merge_stats=$LOG_PREFIX-$METHOD-mergeStats.log \
--vsp_bsp_subdivision_stats=$LOG_PREFIX-$METHOD-subdivisionStats.log \
--view_cells_post_process_merge=false \
--view_cells_active=$NUM_VIEWCELLS \
--view_cells_filename=$VIEWCELLS \
--view_cells_export_pvs=true \
--view_cells_export_bounding_boxes=true \
--vsp_bsp_term_min_pvs=0 \
--view_cells_evaluate=false \
--vsp_bsp_use_cost_heuristics=true \
--vsp_bsp_max_poly_candidates=0 \
--vsp_bsp_use_split_cost_queue=true \
--view_cells_show_visualization=true \
--view_cells_construction_samples=0 \
--view_cells_evaluation_samples=2000000 \
--view_cells_evaluation_samples_per_pass=1000000
-
-
-mv debug.log $LOG_PREFIX-$METHOD-debug.log
-mv merged_view_cells.wrl $LOG_PREFIX-$METHOD-merged_view_cells.wrl
-mv merged_view_cells_pvs.wrl $LOG_PREFIX-$METHOD-merged_view_cells_pvs.wrl
-#mv final_view_cells.x3d $LOG_PREFIX-$METHOD-final_view_cells.x3d
+ $PROGRAM $ENVIRONMENT \
+ -view_cells_filename=$LOG_PREFIX-$METHOD-viewcells.xml.gz \
+  -view_cells_merge_stats=$LOG_PREFIX-$METHOD-mergeStats.log \
+  -vsp_subdivision_stats=$LOG_PREFIX-$METHOD-vsp-subdivisionStats.log \
+  -bvh_subdivision_stats=$LOG_PREFIX-$METHOD-bvh-subdivisionStats.log \
+  -hierarchy_subdivision_stats=$LOG_PREFIX-$METHOD-hierarchy-subdivisionStats.log \
+  -hierarchy_construction_type=2 \
+  -hierarchy_construction_consider_memory=true
Index: GTP/trunk/Lib/Vis/Preprocessing/scripts/generate_viewcells.env
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/scripts/generate_viewcells.env	(revision 1455)
+++ GTP/trunk/Lib/Vis/Preprocessing/scripts/generate_viewcells.env	(revision 1744)
@@ -1,3 +1,3 @@
-#############################################################################
+##############################################################################
 # ERS default configuration file
 # Jiri Bittner 2003
@@ -5,50 +5,48 @@
 
 Scene {
+
 #	filename glasgow1.x3d
 #	filename vienna.x3d
 #	filename ../data/vienna/vienna-simple.x3d
 #	filename ../data/vienna/vienna-buildings.x3d
-	filename ../data/vienna/city1500_flat_1.x3d
-#	filename ../data/vienna/vienna-roads.x3d
-#	filename ../data/vienna/vienna-buildings.x3d;../data/vienna/vienna-roads.x3d;../data/vienna/vienna-roofs.x3d
-#filename ../data/vienna/vienna-buildings.x3d;../data/vienna/vienna-roofs.x3d;../data/vienna/vienna-roads.x3d
-#filename ../data/vienna/city1500_flat_1.x3d;../data/vienna/vienna-roofs.x3d;../data/vienna/vienna-roads.x3d
-#filename ../data/vienna/vienna-buildings.x3d;../data/vienna/vienna-roofs.x3d;../data/vienna/vienna-roads.x3d;../data/vienna/vienna-plane.x3d
-#filename ../data/vienna/city1500_flat_1.x3d;../data/vienna/vienna-roofs.x3d;../data/vienna/vienna-roads.x3d;../data/vienna/vienna-plane.x3d
+#	filename ../data/vienna/vienna-roofs.x3d
+#	filename ../data/vienna/vienna-buildings.x3d;../data/vienna/vienna-roofs.x3d;../data/vienna/vienna-roads.x3d
+#	filename ../data/vienna/vienna-buildings_vienna-roofs_vienna-roads_vienna-plane_cropped.obj
+	filename ../data/vienna/vienna_cropped.obj
+#;../data/vienna/vienna-plane.x3d
+#	filename ../data/vienna/vienna-buildings.x3d;../data/vienna/vienna-roofs.x3d;../data/vienna/vienna-roads.x3d;../data/vienna/vienna-plane.x3d
 #	filename ../data/vienna/viewcells-25-sel.x3d
 #	filename ../data/atlanta/atlanta2.x3d
 #	filename ../data/soda/soda.dat
 #	filename ../data/soda/soda5.dat
-}
+#	filename ../data/artificial/cube_test.x3d
+#	filename ../data/grandcanyon1_RotXmin90.obj
+#	filename ../data/CityModel.obj
+#	filename ../data/arena/arena-low-lods.obj
+}
+
 
 Preprocessor {
-	# stored sample rays
-	samplesFilename rays.out
 	useGlRenderer false
-#	type sampling
 	type vss
-#	type rss
 	detectEmptyViewSpace true
-	loadMeshes true
-	applyVisibilityFilter true
-	applyVisibilitySpatialFilter true
-}
+	loadMeshes false
+	# internal raycaster
+	rayCastMethod 0
+	# intel raycaster
+	#rayCastMethod 1
+	exportVisibility false
+	loadKdTree false
+	exportKdTree false 
+#	exportObj true
+}
+
 
 VssPreprocessor {
-	samplesPerPass  100000
 	initialSamples 0
 	vssSamples 0
-	vssSamplesPerPass 500000
 	useImportanceSampling true
 	loadInitialSamples  false
 	storeInitialSamples false
-	useViewSpaceBox false
-#	testBeamSampling true
-}
-
-
-SamplingPreprocessor {
-	totalSamples 500000
-	samplesPerPass  3
 }
 
@@ -58,5 +56,5 @@
 	epsilon		1e-6
 	
-	maxDepth 	40
+	maxDepth 	2
 	minPvs		30
 	minRays		800
@@ -74,5 +72,5 @@
 	
 	interleaveDirSplits	true
-    dirSplitDepth 0
+    	dirSplitDepth 0
 	
 	numberOfEndPointDomains	10000
@@ -83,63 +81,6 @@
 }
 
-RssPreprocessor {
-	samplesPerPass  100000
-	#initialSamples 500000
-	#vssSamples 10000000
-	#for view cell construction
-	initialSamples 0
-	vssSamples 0
-	vssSamplesPerPass 500000
-	useImportanceSampling true
-
-	directionalSampling true
-	objectBasedSampling false
-
-	Export {
-		pvs false
-		rssTree false
-		rays true
-		numRays 5000
-	}
-
-	useViewcells true
-	updateSubdivision true
-	loadInitialSamples false
-	storeInitialSamples false
-}
-
-
-RssTree {
-
-	epsilon		1e-6
-
-	maxDepth 	40
-	minPvs		3
-	minRays		30
-	minSize		0.001
- 	maxCostRatio 1.0
-	maxRayContribution 0.5
-	maxRays		1000000
-	maxTotalMemory	200
-	maxStaticMemory	100
-
-#	splitType regular
-#	splitType heuristic
-	splitType hybrid
-	splitUseOnlyDrivingAxis true
-	importanceBasedCost false
-
-	interleaveDirSplits	true
-    dirSplitDepth 0
-
-	numberOfEndPointDomains	10000
-	ct_div_ci	0.0
-	randomize	false
-
-	refDirBoxMaxSize	0.1
-}
 
 Limits {
-
        threshold	1e-6
        small		1e-6
@@ -147,10 +88,27 @@
 }
 
+
 Unigraphics {
-		meshGrouping 1
-}
+	meshGrouping 1
+}
+
 
 KdTree {
 	sahUseFaces true
+
+	Termination {
+		minCost 0
+		maxDepth 20
+		
+		maxCostRatio 1.5
+		ct_div_ci 0.5
+	}
+
+#	splitMethod spatialMedian
+	splitMethod SAH
+	splitBorder 0.01
+}
+
+MeshKdTree {
 	Termination {
 		minCost 1
@@ -165,28 +123,16 @@
 }
 
-MeshKdTree {
-	Termination {
-		minCost 1
-		maxDepth 18
-		maxCostRatio 0.9
-		ct_div_ci 0.5
-	}
-
-#	splitMethod spatialMedian
-	splitMethod SAH
-	splitBorder 0.01
-}
-
-
 
 ViewCells {
-	# samples used for view cell construction
+	
+	# samples used for view cell construction 
+	# (after the sampling used for the hierarchy)
 	Construction {
 		samples 0
-		samplesPerPass 1500000
-	}
-
-	#number of active view cells
-	active 200000
+		samplesPerPass 1000000
+	}
+
+	# number of active view cells
+	active 50000
 	maxStaticMemory	40
 
@@ -194,13 +140,9 @@
 	loadFromFile false
 
-	#type kdTree
-	#type vspKdTree
-	#type bspTree
-	type vspBspTree
-	#type sceneDependent
-	
-	height 5.0
-	maxViewCells 3000
-
+	exportPvs false
+
+	# type of view cells
+	type vspOspTree
+	
 	#percentage of total visible objects where pvs is considered invalid
 	maxPvsRatio 1.0
@@ -208,238 +150,138 @@
 	processOnlyValidViewCells false
 
-	#stats viewCellStats.log
-
+	#samplingType object_directional
 	#samplingType directional
 	samplingType box
+	#samplingType reverse_object
+	#samplingType object
 
 	PostProcess {
 		# how much samples are used for post processing
 		samples 0
-		renderCostWeight 1.0
-		maxCostRatio 0.1
-		minViewCells 1
-		avgCostMaxDeviation 0.01
 		maxMergesPerPass 5000
 		useRaysForMerge false
+		refine false
 		compress false
-		merge true
+		merge false
 	}
 
 	Visualization {
 		# how much samples we use for visualization
-		samples 0
-		#colorCode PVS
-		#colorCode MergedLeaves
-		#colorCode MergedTreeDiff
-		colorCode Random
-		exportRays false
+		samples 200
+		exportRays true
 		exportGeometry true
 		exportMergedViewCells false
 		useClipPlane true
 		clipPlaneAxis 1
-		clipPlanePos  0.3
+		clipPlanePos 0.3
+		maxOutput 2
 	}
 
 	showVisualization true
+	#showVisualization false
 	evaluateViewCells false
 	
 	Evaluation {
-		samplesPerPass 1000000
-		samples 1000000
+		samples         80000000
+		samplesForStats 80000000
+		samplesPerPass  2000000
+
+		stepSize	500
+
+		#samplingType object_directional
+		#samplingType reverse_object
+		#samplingType object
+		samplingType box
+
 		statsPrefix ../scripts/viewCells
-		#samplingType directional
-		samplingType box
-		histogram true
-		histoStepSize 5000
-	}
-
-#	filename ../data/atlanta/atlanta_viewcells_large.x3d
-#	filename ../data/vienna/viewcells-25-sel.x3d
-#	filename ../data/vienna/viewcells-25.x3d
-#	filename ../data/vienna/viewcells-large-sel.x3d
-	filename ../data/vienna/vienna-visibility.xml.zip
-#	filename ../scripts/vienna-visibility.xml.zip
-}
-
-
-Simulation {
-	objRenderCost 1.0
-	vcOverhead 1.0
-	# always between 0 and 1
-	moveSpeed 0.0001
-}
-
-
-VspBspTree {
+	}
+}
+
+
+################################
+#
+# View space partitioning kd tree
+#
+
+VspTree {
 	Construction {
-		samples 500000
-		epsilon 0.0000001
-		randomize false
-		renderCostWeight 1.0
-	}
-
-
-	# random polygon       = 1
-	# axis aligned         = 2
-	# least ray splits     = 256
-	# balanced rays        = 512
-	# pvs                  = 1024
-	
-	splitPlaneStrategy 1026
-	
-	# maximal candidates for split planes
-	maxPolyCandidates 0
-
-	usePolygonSplitIfAvailable false
-
-	# maximal tested rays for split cost heuristics
-	maxTests 10000
-	
-	maxTotalMemory	50
-	maxStaticMemory	50
-
-	subdivisionStats ../subdivisionStats.log
-
-	# factors for evaluating split plane costs
-	Factor {
-		leastRaySplits 1.0
-	  	balancedRays 1.0
-	  	pvs 1.0
-	}
-	
-	Termination {
-		# parameters used for autopartition
-		minRays 		-15
-		minPolygons 		-1
-		maxDepth		25
-		minPvs 			0
-		minProbability		0.000001
-		maxRayContribution	1
-		maxCostRatio		0.9
-		missTolerance		6
-		globalCostMissTolerance 4
-		#minGlobalCostRatio      0.0000001
-		minGlobalCostRatio      0.0001
-		maxViewCells		5000
-	
-
-		# used for pvs criterium
-		ct_div_ci 0.0
-		
-		AxisAligned {
-			minRays 		50000
-			maxRayContribution	9.9
-		}
-	}
-	
-	useSplitCostQueue true
-	useCostHeuristics false
-
+		renderCostDecreaseWeight 1.0
+	}
+
+	Termination {
+		minPvs 0
+		maxViewCells 500000
+	}
+
+	useCostHeuristics true
 	splitUseOnlyDrivingAxis false
-	simulateOctree false
-	useRandomAxis false
-	usePolygonSplitIfAvailable false
-	nodePriorityQueueType 0
-
-	Visualization {
-		# x3d visualization of the split planes
-		exportSplits false
-	}
-}
-
-BspTree {
+
+	# maximum number of tests per node
+	maxTests 50000
+}
+
+
+##########################
+#
+# The bounding volume hierarchy
+#
+
+BvHierarchy {
+
+	Construction {		
+		renderCostDecreaseWeight 1.0
+	}
+
+	Termination {
+		maxLeaves 50000000
+	}
+
+	minRaysForVisibility 15
+
+	# use only surface area heuristic	
+	useCostHeuristics true
+	useSah false
+
+	splitUseOnlyDrivingAxis false
+
+	maxTests 50000
+}
+
+
+###############################################################
+#
+# Manages the construction of view space and object space partition
+#
+
+Hierarchy {
+	# the type of object space partition: view space is always vsp (=kd) partition
+	type bvh
+	
 	Construction {
-		samples 100000
-		epsilon 0.005
-	}
-
-
-	# random polygon       = 1
-	# axis aligned         = 2
-	# least splits         = 4
-	# balanced polygons    = 8
-	# balanced view cells  = 16
-	# largest polygon area = 32
-	# vertical axis        = 64
-	# blocked rays         = 128
-	# least ray splits     = 256
-	# balanced rays        = 512
-	# pvs                  = 1024
-
-	# least splits + balanced polygons
-	#splitPlaneStrategy 12
-	
-	#axis aligned + vertical axis
-	#splitPlaneStrategy 66
-	
-	# axis aligned + balanced view cells
-	# splitPlaneStrategy 18
-	
-	# largest polygon area
-	#splitPlaneStrategy 32
-	
-	# axus aligned + balanced polygons
-	#splitPlaneStrategy 72
-	
-	# axis aligned + blocked rays
-	#splitPlaneStrategy 130
-	
-	#splitPlaneStrategy 384
-	#splitPlaneStrategy 130
-	
-	splitPlaneStrategy 32
-	
-	maxPolyCandidates 100
-	maxRayCandidates 0
-	
-	maxTests 10000
-	
-	subdivisionStats ../subDivisionStats.log
-
-	# factors for evaluating split plane costs
-	Factor {
-		verticalSplits 1.0
-	  	largestPolyArea 1.0
-	  	blockedRays 1.0
-	  	leastRaySplits 1.0
-	  	balancedRays 1.0
-	  	pvs 1.0
-	  	leastSplits 1.0
-	  	balancedPolys 1.0
-	  	balancedViewCells 1.0
-	}
-	
-	Termination {
-		# parameters used for autopartition
-		minRays -1
-		minPolygons 0
-		maxDepth 30
-		minPvs -1
-		minProbability 0.00001
-		maxRayContribution 9999
-		maxViewCells 50000
-
-		# used for pvs criterium
-		ct_div_ci 0.0
-	
-		maxCostRatio 0.9
-		
-		# axis aligned splits
-		AxisAligned {
-			minPolys 5000
-			minRays 500
-			minObjects 10
-			ct_div_ci 0.5
-		}
-	}
-	
-	AxisAligned {
-		splitBorder 0.01
-	}
-	
-	
-	Visualization {
-		# x3d visualization of the split planes
-		exportSplits false
-	}
-}
+
+		samples 3000000
+
+		# type 0 = sequential computation, 1 = interleaved, 2 = gradient
+		type 2
+
+		###############################
+		# only for interleaved method
+
+		# minimal steps of same type for gradient method
+		minStepsOfSameType 100
+		# maximum steps of same type for gradient method
+		maxStepsOfSameType 900
+
+		# maximum number of repair steps per gradient step
+		maxRepairs 1000
+	}
+
+	Termination {
+		# maximal number of leaves
+		maxLeaves 100000
+		# maximal memory in MB
+		maxMemory 20
+		# minimum ratio of global cost decrease
+		minGlobalCostRatio -1
+	}
+}
