Index: GTP/trunk/Lib/Vis/Preprocessing/src/Mutation.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/Mutation.cpp	(revision 1995)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/Mutation.cpp	(revision 1997)
@@ -18,4 +18,7 @@
 #define MUTATION_USE_CDF 0
 #define USE_SILHOUETTE_MUTATIONS 0
+
+#define USE_SIL_TERMINATION_MUTATION 1
+
 #define EVALUATE_MUTATION_STATS 1
 
@@ -257,4 +260,58 @@
 
 
+Vector3
+MutationBasedDistribution::ComputeSilhouetteTerminationMutation(const VssRay &ray,
+																const Vector3 &origin,
+																const AxisAlignedBox3 &box,
+																const Vector3 &U,
+																const Vector3 &V,
+																const Vector2 vr2,
+																const float radius
+																)
+{
+  const int packetSize = 16;
+
+  static int hit_triangles[packetSize];
+  static float dist[packetSize];
+  static Vector3 dirs[packetSize];
+  // mutate the 
+  float alpha = RandomValue(0.0f, 2.0f*M_PI);
+  
+  // direction along which we will mutate the ray
+  Vector3 line = sin(alpha)*U + cos(alpha)*V;
+  
+  //  cout<<line<<endl;
+  // create 16 rays along the selected dir
+  
+  // cast rays to find silhouette ray
+  for (int i=0; i < packetSize; i++) {
+	dirs[i] = Normalize(ray.mTermination + ((radius/(packetSize - i))*line) - origin );
+	mlrtaStoreRayAS16(&origin.x,
+					  &dirs[i].x,
+					  i);
+  }
+  
+  mlrtaTraverseGroupAS16(&box.Min().x,
+						 &box.Max().x,
+						 hit_triangles,
+						 dist);
+  
+  for (int i=0; i < packetSize; i++) {
+	if (hit_triangles[i] == -1 || !box.IsInside(origin + dist[i]*dirs[i])) {
+	  // break on first passing ray
+	  break;
+	}
+  }
+  
+  if (i == packetSize) {
+	//	cerr<<"Warning: hit the same box here should never happen!"<<endl;
+	// shift the ray even a bit more
+	//	cout<<"W"<<i<<endl;
+	return ray.mTermination + (RandomValue(1.0f, 2.0f)*radius)*line;
+  }
+
+  //  cout<<i<<endl;
+  return dirs[i];
+}
 
 
@@ -385,8 +442,16 @@
 								  mutationRadius);
   
+#if USE_SIL_TERMINATION_MUTATION
+  termination += ComputeSilhouetteTerminationMutation(*ray,
+													  origin,
+													  box,
+													  U, V,
+													  Vector2(rr[2], rr[3]),
+													  3.0f*objectRadius);
+#else
   termination += ComputeTerminationMutation(*ray, U, V,
 											Vector2(rr[2], rr[3]),
 											mutationRadius);
-  
+#endif
   Vector3 direction = termination - origin;
   
Index: GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtGlRenderer.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtGlRenderer.cpp	(revision 1983)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtGlRenderer.cpp	(revision 1997)
@@ -303,5 +303,58 @@
 
 
-
+void
+QtGlRendererWidget::InitGL()
+{
+  GlRenderer::InitGL();
+
+  GLfloat mat_ambient[]   = {  0.5, 0.5, 0.5, 1.0  };
+  /*  mat_specular and mat_shininess are NOT default values	*/
+  GLfloat mat_diffuse[]   = {  1.0, 1.0, 1.0, 1.0  };
+  GLfloat mat_specular[]  = {  0.3, 0.3, 0.3, 1.0  };
+  GLfloat mat_shininess[] = {  1.0  };
+  
+  GLfloat light_ambient[]  = {  0.2, 0.2, 0.2, 1.0  };
+  GLfloat light_diffuse[]  = {  0.4, 0.4, 0.4, 1.0  };
+  GLfloat light_specular[] = {  0.3, 0.3, 0.3, 1.0  };
+  
+  GLfloat lmodel_ambient[] = {  0.3, 0.3, 0.3, 1.0  };
+  
+  
+  // default Material
+  glMaterialfv(GL_FRONT, GL_AMBIENT, mat_ambient);
+  glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_diffuse);
+  glMaterialfv(GL_FRONT, GL_SPECULAR, mat_specular);
+  glMaterialfv(GL_FRONT, GL_SHININESS, mat_shininess);
+
+  // a light
+  glLightfv(GL_LIGHT0, GL_AMBIENT, light_ambient);
+  glLightfv(GL_LIGHT0, GL_DIFFUSE, light_diffuse);
+  glLightfv(GL_LIGHT0, GL_SPECULAR, light_specular);
+  
+  glLightfv(GL_LIGHT1, GL_AMBIENT, light_ambient);
+  glLightfv(GL_LIGHT1, GL_DIFFUSE, light_diffuse);
+  glLightfv(GL_LIGHT1, GL_SPECULAR, light_specular);
+  
+  glLightModelfv(GL_LIGHT_MODEL_AMBIENT, lmodel_ambient);
+  
+  glEnable(GL_LIGHTING);
+  glEnable(GL_LIGHT0);
+  glEnable(GL_LIGHT1);
+  
+  
+  // set position of the light
+  GLfloat infinite_light[] = {  1.0, 0.8, 1.0, 0.0  };
+  glLightfv (GL_LIGHT0, GL_POSITION, infinite_light);
+  
+  // set position of the light2
+  GLfloat infinite_light2[] = {  -0.3, 1.5, 1.0, 0.0  };
+  glLightfv (GL_LIGHT1, GL_POSITION, infinite_light2);
+  
+  glColorMaterial( GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE);
+  //   glColorMaterial( GL_FRONT_AND_BACK, GL_SPECULAR);
+  glEnable(GL_COLOR_MATERIAL);
+  
+  glShadeModel( GL_FLAT );
+}
 
 
@@ -617,4 +670,5 @@
 	  RenderErrors();
 	} else {
+	  glColor3f(0.6f, 0.6f, 0.6f);
 	  RenderPvs();
 	}
Index: GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtGlRenderer.h
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtGlRenderer.h	(revision 1948)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtGlRenderer.h	(revision 1997)
@@ -172,4 +172,7 @@
 	InitGL();
   }
+
+  virtual void InitGL();
+  
   void resizeGL(int w, int h);
   void paintGL();
Index: GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtGlViewer.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtGlViewer.cpp	(revision 1983)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtGlViewer.cpp	(revision 1997)
@@ -52,5 +52,6 @@
 	if (mRenderer->mRenderViewCells) 
 	  mRenderer->RenderViewCells();
-	
+
+	glColor3f(0.8f, 0.8f, 0.8f);
 	mRenderer->RenderPvs();
 
Index: GTP/trunk/Lib/Vis/Preprocessing/src/GlRenderer.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/GlRenderer.cpp	(revision 1990)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/GlRenderer.cpp	(revision 1997)
@@ -115,4 +115,6 @@
   
   glBegin(GL_TRIANGLES);
+  Vector3 normal = t.GetNormal();
+  glNormal3f(normal.x, normal.y, normal.z);
   glVertex3f(t.mVertices[0].x, t.mVertices[0].y, t.mVertices[0].z);
   glVertex3f(t.mVertices[1].x, t.mVertices[1].y, t.mVertices[1].z);
@@ -315,62 +317,9 @@
   glEnable(GL_CULL_FACE);
   glShadeModel(GL_FLAT);
+  glDepthFunc( GL_LESS );
   glEnable(GL_DEPTH_TEST);
   glEnable(GL_CULL_FACE);
   
   InitExtensions();
-  
-#if 0
-  GLfloat mat_ambient[]   = {  0.5, 0.5, 0.5, 1.0  };
-  /*  mat_specular and mat_shininess are NOT default values	*/
-  GLfloat mat_diffuse[]   = {  1.0, 1.0, 1.0, 1.0  };
-  GLfloat mat_specular[]  = {  0.3, 0.3, 0.3, 1.0  };
-  GLfloat mat_shininess[] = {  1.0  };
-  
-  GLfloat light_ambient[]  = {  0.2, 0.2, 0.2, 1.0  };
-  GLfloat light_diffuse[]  = {  0.4, 0.4, 0.4, 1.0  };
-  GLfloat light_specular[] = {  0.3, 0.3, 0.3, 1.0  };
-  
-  GLfloat lmodel_ambient[] = {  0.3, 0.3, 0.3, 1.0  };
-  
-  
-  // default Material
-  glMaterialfv(GL_FRONT, GL_AMBIENT, mat_ambient);
-  glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_diffuse);
-  glMaterialfv(GL_FRONT, GL_SPECULAR, mat_specular);
-  glMaterialfv(GL_FRONT, GL_SHININESS, mat_shininess);
-
-  // a light
-  glLightfv(GL_LIGHT0, GL_AMBIENT, light_ambient);
-  glLightfv(GL_LIGHT0, GL_DIFFUSE, light_diffuse);
-  glLightfv(GL_LIGHT0, GL_SPECULAR, light_specular);
-  
-  glLightfv(GL_LIGHT1, GL_AMBIENT, light_ambient);
-  glLightfv(GL_LIGHT1, GL_DIFFUSE, light_diffuse);
-  glLightfv(GL_LIGHT1, GL_SPECULAR, light_specular);
-  
-  glLightModelfv(GL_LIGHT_MODEL_AMBIENT, lmodel_ambient);
-  
-  glEnable(GL_LIGHTING);
-  glEnable(GL_LIGHT0);
-  glEnable(GL_LIGHT1);
-  
-  
-  // set position of the light
-  GLfloat infinite_light[] = {  1.0, 0.8, 1.0, 0.0  };
-  glLightfv (GL_LIGHT0, GL_POSITION, infinite_light);
-  
-  // set position of the light2
-  GLfloat infinite_light2[] = {  -0.3, 1.5, 1.0, 0.0  };
-  glLightfv (GL_LIGHT1, GL_POSITION, infinite_light2);
-  
-  glColorMaterial( GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE);
-  //   glColorMaterial( GL_FRONT_AND_BACK, GL_SPECULAR);
-  glEnable(GL_COLOR_MATERIAL);
-  
-  glShadeModel( GL_FLAT );
-  
-  glDepthFunc( GL_LESS );
-  glEnable( GL_DEPTH_TEST );
-#endif
 
   glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE );
Index: GTP/trunk/Lib/Vis/Preprocessing/src/Makefile
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/Makefile	(revision 1995)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/Makefile	(revision 1997)
@@ -1,5 +1,5 @@
 #############################################################################
 # Makefile for building: preprocessor
-# Generated by qmake (2.00a) (Qt 4.1.2) on: ?t 18. I 16:30:52 2007
+# Generated by qmake (2.00a) (Qt 4.1.2) on: ?t 18. I 20:30:31 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-msvc2005\qmake.conf C:/Qt/4.1.2/mkspecs/qconfig.pri \
+Makefile: preprocessor.pro  C:/Qt/4.1.2/mkspecs/win32-msvc.net\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 1991)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/Mutation.h	(revision 1997)
@@ -79,4 +79,15 @@
 							 );
 
+
+  Vector3
+  ComputeSilhouetteTerminationMutation(const VssRay &ray,
+									   const Vector3 &origin,
+									   const AxisAlignedBox3 &box,
+									   const Vector3 &U,
+									   const Vector3 &V,
+									   const Vector2 vr2,
+									   const float radius
+									   );
+
   RayEntry &GetEntry(const int index) {
 	return mRays[(mBufferStart+index)%mRays.size()];
Index: GTP/trunk/Lib/Vis/Preprocessing/src/GlRenderer.h
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/GlRenderer.h	(revision 1983)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/GlRenderer.h	(revision 1997)
@@ -149,5 +149,5 @@
   EvalPvsStat();
 
-  void InitGL();
+  virtual void InitGL();
 
   virtual int GetWidth() const { return 0; }
