Index: GTP/trunk/Lib/Vis/Preprocessing/src/Mutation.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/Mutation.cpp	(revision 2050)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/Mutation.cpp	(revision 2060)
@@ -10,4 +10,5 @@
 #include "Mutation.h"
 #include "Exporter.h"
+#include "Environment.h"
 
 #ifdef GTP_INTERNAL
@@ -18,12 +19,10 @@
 
 #define MUTATION_USE_CDF 0
-#define USE_SILHOUETTE_MUTATIONS 0
-
-
-#define SIL_TERMINATION_MUTATION_PROB 0.8f
+
+  //#define SIL_TERMINATION_MUTATION_PROB 0.8f
 
 #define EVALUATE_MUTATION_STATS 1
 
-#define Q_SEARCH_STEPS 3
+  //#define Q_SEARCH_STEPS 3
 
 #define SORT_RAY_ENTRIES 1
@@ -123,5 +122,4 @@
 		VssRay *newRay = vssRays[i];
 
-#define DIST_THRESHOLD 3.0f
 
 		Intersectable *oldObject = oldRay->mTerminationObject;
@@ -133,5 +131,5 @@
 		  float newDist = Magnitude(newRay->mTermination - newRay->mOrigin);
 		  
-		  if (newDist < oldDist - oldObject->GetBox().Radius()*DIST_THRESHOLD) {
+		  if (newDist < oldDist - oldObject->GetBox().Radius()*mReverseSamplesDistance) {
 			Vector3 origin, termination;
 			if (ComputeReverseMutation(*oldRay, *newRay, origin, termination)) {
@@ -170,27 +168,25 @@
   cout<<"Percentage of contributing rays:"<<pContributingRays<<endl;
   
-#if USE_AVG_CONTRIBUTION
-  float importance = 1.0f/(pContributingRays + 1e-5);
-// float importance = 1.0f;
-  // set this values for last contributingRays
-  int index = mBufferStart - 1;
-  
-  for (int i=0; i < contributingRays; i++, index--) {
-	if (index < 0)
-	  index = mRays.size()-1;
-	mRays[index].mImportance = importance;
-  }
-#else
-  // use unsucc mutation samples as feedback on importance
-  for (int i=0; i < mRays.size(); i++) {
-	const float  minImportance = 0.1f;
-	const int minImportanceSamples = 20;
-	mRays[i].mImportance = minImportance +
-	  (1-minImportance)*exp(-3.0f*mRays[i].mUnsuccessfulMutations/minImportanceSamples);
-	
-	//mRays[i].mImportance = 1.0f/(mRays[i].mUnsuccessfulMutations+3);
-	//	mRays[i].mImportance = 1.0f;
-  }
-#endif
+  if (mUseUnsuccCountImportance) {
+	// use unsucc mutation samples as feedback on importance
+	for (int i=0; i < mRays.size(); i++) {
+	  const float  minImportance = 0.1f;
+	  const int minImportanceSamples = 20;
+	  mRays[i].mImportance = minImportance +
+		(1-minImportance)*exp(-3.0f*mRays[i].mUnsuccessfulMutations/minImportanceSamples);
+	}
+  } else {
+	float importance = 1.0f;
+	if (mUsePassImportance) 
+	  importance = 1.0f/(pContributingRays + 1e-5);
+	// set this values for last contributingRays
+	int index = mBufferStart - 1;
+	
+	for (int i=0; i < contributingRays; i++, index--) {
+	  if (index < 0)
+		index = mRays.size()-1;
+	  mRays[index].mImportance = importance;
+	}
+  }
   
 #if SORT_RAY_ENTRIES
@@ -373,5 +369,5 @@
   float right = 1.0f;
   // cast rays to find silhouette ray
-  for (int j=0; j < Q_SEARCH_STEPS; j++) {
+  for (int j=0; j < mSilhouetteSearchSteps; j++) {
 	for (i=0; i < packetSize; i++) {
 	  float r = left + (i+1)*(right-left)/(packetSize+1);
@@ -482,5 +478,5 @@
   float right = radius;
   // cast rays to find silhouette ray
-  for (int j=0; j < Q_SEARCH_STEPS; j++) {
+  for (int j=0; j < mSilhouetteSearchSteps; j++) {
 	for (i=0; i < packetSize; i++) {
 	  float r = left + (i+1)*(right-left)/(packetSize+1);
@@ -623,9 +619,5 @@
   }
   
-#if USE_SILHOUETTE_MUTATIONS
-  return GenerateSilhouetteMutation(index, sray);
-#else  
   return GenerateMutation(index, sray);
-#endif
 }
 
@@ -666,19 +658,9 @@
   Vector3 termination = ray->mTermination; //box.Center(); //ray->mTermination; //box.Center();
 
-  // optimal for Pompeii 0.1f
-  // optimal for Vienna 0.5f
-  
-  float radiusExtension = 0.5f;
-  //  + mRays[index].mMutations/50.0f;
-  
-  float mutationRadius = objectRadius*radiusExtension;
-  
-  // tmp for pompeii
-  //  mutationRadius = 0.22f;
-
+  
   // use probabilitistic approach to decide for the type of mutation
   float a = RandomValue(0.0f,1.0f);
 
-  if (a < SIL_TERMINATION_MUTATION_PROB) {
+  if (mUseSilhouetteSamples && a < mSilhouetteProb) {
 	termination += ComputeSilhouetteTerminationMutation(*ray,
 														origin,
@@ -691,9 +673,9 @@
 	origin += ComputeOriginMutation(*ray, U, V,
 									Vector2(rr[0], rr[1]),
-									mutationRadius);
+									mMutationRadiusOrigin*objectRadius);
 	
 	termination += ComputeTerminationMutation(*ray, U, V,
 											  Vector2(rr[2], rr[3]),
-											  mutationRadius);
+											  mMutationRadiusTermination*objectRadius);
   }
 
@@ -734,72 +716,4 @@
   return false;
 }
-
-bool
-MutationBasedDistribution::GenerateSilhouetteMutation(const int index, SimpleRay &sray)
-{
-#ifndef GTP_INTERNAL
-  return GenerateMutation(index, sray);
-#else
-  const int packetSize = 4;
-  const int maxTries = 8;
-  
-  static int hit_triangles[16];
-  static float dist[16];
-  
-  SimpleRay mutationCandidates[packetSize];
-  int candidates = 0;
-
-  VssRay *ray = mRays[index].mRay;
-  
-  Intersectable *object = mPreprocessor.mViewCellsManager->GetIntersectable(
-																			*ray,
-																			true);
-  
-  AxisAlignedBox3 box = object->GetBox();
-
-  int id = 0;
-  int silhouetteRays = 0;
-  int tries = 0;
-  while (silhouetteRays == 0 && tries < maxTries) {
-	for (candidates = 0; candidates < packetSize && tries < maxTries; tries++)
-	  if (GenerateMutationCandidate(index, mutationCandidates[candidates], object, box))
-		candidates++;
-
-	if (candidates < packetSize)
-	  break;
-	
-	//	cout<<candidates<<endl;
-	// cast rays to find silhouette edge
-	for (int i=0; i < packetSize; i++)
-	  mlrtaStoreRayAS4(&mutationCandidates[i].mOrigin.x,
-					   &mutationCandidates[i].mDirection.x,
-					   i);
-
-	mlrtaTraverseGroupAS4(&box.Min().x,
-						  &box.Max().x,
-						  hit_triangles,
-						  dist);
-	
-	for (int i=0; i < packetSize; i++)
-	  if (hit_triangles[i] == -1) {
-		silhouetteRays++;
-		id = i;
-		break;
-	  }
-  }
-
-  if (candidates == 0)
-	return false;
-  
-  //  cout<<id<<endl;
-  // cout<<tries<<endl;
-  sray = mutationCandidates[id];
-  mRays[index].mMutations++;
-  mRays[index].mUnsuccessfulMutations++;
-
-  return true;
-#endif
-}
-
   
 
@@ -811,14 +725,46 @@
   mType = MUTATION_BASED_DISTRIBUTION;
   mBufferStart = 0;
-  mMaxRays = 500000;
+  mLastIndex = 0;
+
+  Environment::GetSingleton()->GetIntValue("Mutation.bufferSize",
+										   mMaxRays);
+  
   mRays.reserve(mMaxRays);
-  mOriginMutationSize = 10.0f;
-  mLastIndex = 0;
-  //  mOriginMutationSize = Magnitude(preprocessor.mViewCellsManager->
-  //								  GetViewSpaceBox().Diagonal())*1e-3;
-  
-}
-
-
-
-}
+  
+  Environment::GetSingleton()->GetFloatValue("Mutation.radiusOrigin",
+											 mMutationRadiusOrigin);
+
+  Environment::GetSingleton()->GetFloatValue("Mutation.radiusTermination",
+											 mMutationRadiusTermination);
+  
+  Environment::GetSingleton()->GetBoolValue("Mutation.useReverseSamples",
+											mUseReverseSamples);
+  
+  Environment::GetSingleton()->GetFloatValue("Mutation.reverseSamplesDistance",
+											 mReverseSamplesDistance);
+  
+  
+  Environment::GetSingleton()->GetBoolValue("Mutation.useSilhouetteSamples",
+											mUseSilhouetteSamples);
+
+  Environment::GetSingleton()->GetIntValue("Mutation.silhouetteSearchSteps",
+										   mSilhouetteSearchSteps);
+  
+  Environment::GetSingleton()->GetFloatValue("Mutation.silhouetteProb",
+											 mSilhouetteProb);
+
+
+  Environment::GetSingleton()->GetBoolValue("Mutation.usePassImportance",
+											mUsePassImportance);
+  
+
+  Environment::GetSingleton()->GetBoolValue("Mutation.useUnsuccCountImportance",
+											mUseUnsuccCountImportance);
+
+  
+  
+}
+
+
+
+}
Index: GTP/trunk/Lib/Vis/Preprocessing/src/run_test2
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/run_test2	(revision 2052)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/run_test2	(revision 2060)
@@ -31,8 +31,13 @@
 
 SCENE=../data/vienna/vienna_cropped.obj
-VIEWCELLS=../data/vienna/vienna_cropped-gradient-viewcells.xml.gz
+#VIEWCELLS=../data/vienna/vienna_cropped-gradient-viewcells.xml.gz
+VIEWCELLS=../data/vienna/vienna-seq-viewcells-20000.xml.gz
 
+<<<<<<< .mine
+PREFIX=../work/plots/osp-vienna2-1e5
+=======
 # SCENE=../data/Pompeii/PompeiiTen.obj
 # VIEWCELLS=../data/Pompeii/pompeii_big-seq-viewcells.xml.gz
+>>>>>>> .r2051
 
 PREFIX=../work/plots/osp-FILTER-1e5
@@ -50,4 +55,10 @@
 -preprocessor_histogram_file=$PREFIX-i-mixed-b1-n4a.hlog
 
+<<<<<<< .mine
+# $COMMAND -preprocessor=sampling -scene_filename=$SCENE -view_cells_filename=$VIEWCELLS \
+# -preprocessor_visibility_file=$PREFIX-r-reference.xml \
+# -view_cells_filter_max_size=1 -preprocessor_stats=$PREFIX-r-reference.log \
+# -preprocessor_histogram_file=$PREFIX-r-reference.hlog
+=======
 $COMMAND -preprocessor=combined -scene_filename=$SCENE -view_cells_filename=$VIEWCELLS \
 -rss_distributions=mutation+object_direction+spatial \
@@ -57,4 +68,5 @@
 -preprocessor_stats=$PREFIX-i-mixed-b1-n4b.log \
 -preprocessor_histogram_file=$PREFIX-i-mixed-b1-n4b.hlog
+>>>>>>> .r2051
 
 $COMMAND -preprocessor=combined -scene_filename=$SCENE -view_cells_filename=$VIEWCELLS \
@@ -78,23 +90,23 @@
 
 
-# $COMMAND -preprocessor=combined -scene_filename=$SCENE -view_cells_filename=$VIEWCELLS \
-# -rss_distributions=mutation+object_direction+spatial -view_cells_filter_max_size=1 \
-# -view_cells_use_kd_pvs- -af_use_kd_pvs+ \
-# -preprocessor_visibility_file=$PREFIX-i-mixed-bvh-n4k.xml \
-# -preprocessor_stats=$PREFIX-i-mixed-bvh-n4k.log \
-# -preprocessor_histogram_file=$PREFIX-i-mixed-bvh-n4k.hlog
+$COMMAND -preprocessor=combined -scene_filename=$SCENE -view_cells_filename=$VIEWCELLS \
+-rss_distributions=mutation+object_direction+spatial -view_cells_filter_max_size=1 \
+-view_cells_use_kd_pvs- -af_use_kd_pvs- \
+-preprocessor_visibility_file=$PREFIX-i-mixed-bvh-n4k.xml \
+-preprocessor_stats=$PREFIX-i-mixed-bvh-n4k.log \
+-preprocessor_histogram_file=$PREFIX-i-mixed-bvh-n4k.hlog
 
-# $COMMAND -preprocessor=sampling -scene_filename=$SCENE -view_cells_filename=$VIEWCELLS \
-# -view_cells_use_kd_pvs- -af_use_kd_pvs+ \
-# -preprocessor_visibility_file=$PREFIX-r-bvh-reference.xml \
-# -view_cells_filter_max_size=1 -preprocessor_stats=$PREFIX-r-bvh-reference.log \
-# -preprocessor_histogram_file=$PREFIX-r-bvh-reference.hlog
+$COMMAND -preprocessor=sampling -scene_filename=$SCENE -view_cells_filename=$VIEWCELLS \
+-view_cells_use_kd_pvs- -af_use_kd_pvs- \
+-preprocessor_visibility_file=$PREFIX-r-bvh-reference.xml \
+-view_cells_filter_max_size=1 -preprocessor_stats=$PREFIX-r-bvh-reference.log \
+-preprocessor_histogram_file=$PREFIX-r-bvh-reference.hlog
 
-# $COMMAND -scene_filename=$SCENE -view_cells_filename=$VIEWCELLS \
-# -view_cells_use_kd_pvs- -af_use_kd_pvs+ \
-#  -rss_distributions=direction -view_cells_filter_max_size=1 \
-#  -preprocessor_visibility_file=$PREFIX-r-bvh-reference-global.xml \
-#  -preprocessor_stats=$PREFIX-r-bvh-reference-global.log \
-#  -preprocessor_histogram_file=$PREFIX-r-bvh-reference-global.hlog
+$COMMAND -scene_filename=$SCENE -view_cells_filename=$VIEWCELLS \
+-view_cells_use_kd_pvs- -af_use_kd_pvs- \
+ -rss_distributions=direction -view_cells_filter_max_size=1 \
+ -preprocessor_visibility_file=$PREFIX-r-bvh-reference-global.xml \
+ -preprocessor_stats=$PREFIX-r-bvh-reference-global.log \
+ -preprocessor_histogram_file=$PREFIX-r-bvh-reference-global.hlog
 
 
Index: GTP/trunk/Lib/Vis/Preprocessing/src/Environment.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/Environment.cpp	(revision 2051)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/Environment.cpp	(revision 2060)
@@ -1287,4 +1287,59 @@
 
    /*************************************************************************/
+   /*    Mutation strategy related options                                  */
+   /*************************************************************************/
+   
+   RegisterOption("Mutation.bufferSize",
+				  optInt,
+				  "mutation_buffer_size=",
+				  "500000");
+
+   RegisterOption("Mutation.radiusOrigin",
+				  optFloat,
+				  "mutation_radius_origin=",
+				  "0.5");
+
+   RegisterOption("Mutation.radiusTermination",
+				  optFloat,
+				  "mutation_radius_termination=",
+				  "0.5");
+
+   RegisterOption("Mutation.useReverseSamples",
+				  optBool,
+				  "mutation_use_reverse_samples",
+				  "true");
+
+   RegisterOption("Mutation.reverseSamplesDistance",
+				  optFloat,
+				  "mutation_reverse_samples_distance",
+				  "3.0");
+
+   RegisterOption("Mutation.useSilhouetteSamples",
+				  optBool,
+				  "mutation_use_silhouette_samples",
+				  "true");
+
+   RegisterOption("Mutation.silhouetteSearchSteps",
+				  optInt,
+				  "mutation_silhouette_search_steps=",
+				  "3");
+
+   RegisterOption("Mutation.silhouetteProb",
+				  optFloat,
+				  "mutation_silhouette_prob=",
+				  "0.8");
+
+   RegisterOption("Mutation.usePassImportance",
+				  optBool,
+				  "mutation_use_pass_importance",
+				  "true");
+
+   RegisterOption("Mutation.useUnsuccCountImportance",
+				  optBool,
+				  "mutation_use_unsucc_count_importance",
+				  "false");
+   
+   
+   /*************************************************************************/
    /*                       GvsPrerpocessor related options                 */
    /*************************************************************************/
Index: GTP/trunk/Lib/Vis/Preprocessing/src/default.env
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/default.env	(revision 2051)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/default.env	(revision 2060)
@@ -199,5 +199,5 @@
 
 ViewCells {
-	importRandomViewCells true
+	importRandomViewCells false
 
 	useKdPvs true
Index: GTP/trunk/Lib/Vis/Preprocessing/src/Makefile
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/Makefile	(revision 2049)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/Makefile	(revision 2060)
@@ -1,5 +1,5 @@
 #############################################################################
 # Makefile for building: preprocessor
-# Generated by qmake (2.00a) (Qt 4.1.2) on: út 23. I 21:53:49 2007
+# Generated by qmake (2.00a) (Qt 4.1.2) on: ?t 25. I 14:38:54 2007
 # Project:  preprocessor.pro
 # Template: app
@@ -63,5 +63,5 @@
 	$(MAKE) -f $(MAKEFILE).Debug uninstall
 
-Makefile: preprocessor.pro  C:/Qt/4.1.2/mkspecs/win32-msvc.net\qmake.conf C:/Qt/4.1.2/mkspecs/qconfig.pri \
+Makefile: preprocessor.pro  C:/Qt/4.1.2/mkspecs/win32-msvc2005\qmake.conf C:/Qt/4.1.2/mkspecs/qconfig.pri \
 		C:\Qt\4.1.2\mkspecs\features\qt_config.prf \
 		C:\Qt\4.1.2\mkspecs\features\exclusive_builds.prf \
Index: GTP/trunk/Lib/Vis/Preprocessing/src/Mutation.h
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/Mutation.h	(revision 2022)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/Mutation.h	(revision 2060)
@@ -32,6 +32,4 @@
   bool
   GenerateMutation(const int index, SimpleRay &ray);
-  bool
-  GenerateSilhouetteMutation(const int index, SimpleRay &ray);
 
   bool
@@ -126,8 +124,19 @@
   
   vector<RayEntry> mRays;
-  int mMaxRays;
-  float mOriginMutationSize;
   int mBufferStart;
   int mLastIndex;
+
+
+  int mMaxRays;
+  float mMutationRadiusOrigin;
+  float mMutationRadiusTermination;
+  bool mUseReverseSamples;
+  float mReverseSamplesDistance;
+  bool mUseSilhouetteSamples;
+  int mSilhouetteSearchSteps;
+  float mSilhouetteProb;
+  bool mUsePassImportance;
+  bool mUseUnsuccCountImportance;
+
 };
 
