Index: GTP/trunk/Lib/Vis/Preprocessing/scripts/TestPreprocessor.vcproj
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/scripts/TestPreprocessor.vcproj	(revision 1011)
+++ GTP/trunk/Lib/Vis/Preprocessing/scripts/TestPreprocessor.vcproj	(revision 1076)
@@ -73,4 +73,5 @@
 				PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
 				RuntimeLibrary="2"
+				RuntimeTypeInfo="TRUE"
 				UsePrecompiledHeader="0"
 				WarningLevel="3"
@@ -85,9 +86,10 @@
 				LinkIncremental="1"
 				AdditionalLibraryDirectories="..\support\xercesc\lib\;..\support\zlib\lib\;..\support\devil\lib;&quot;$(QTDIR)\lib&quot;;..\include;..\src\GL;&quot;$(CG_LIB_PATH)&quot;;&quot;$(GTPDIR)\NonGTP\Xerces&quot;;&quot;$(GTPDIR)\NonGTP\Xerces\xercesc\lib&quot;;&quot;$(GTPDIR)\NonGTP\zlib\lib&quot;;&quot;$(GTPDIR)\NonGTP\Devil\lib&quot;;..\lib\release;..\..\Preprocessing\lib\release"
-				GenerateDebugInformation="FALSE"
+				GenerateDebugInformation="TRUE"
 				SubSystem="1"
 				OptimizeReferences="2"
 				EnableCOMDATFolding="2"
-				TargetMachine="1"/>
+				TargetMachine="1"
+				FixedBaseAddress="1"/>
 			<Tool
 				Name="VCMIDLTool"/>
@@ -133,4 +135,7 @@
 			UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}">
 		</Filter>
+		<File
+			RelativePath=".\VTune\TestPreprocessor.vpj">
+		</File>
 	</Files>
 	<Globals>
Index: GTP/trunk/Lib/Vis/Preprocessing/src/VspBspTree.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/VspBspTree.cpp	(revision 1074)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/VspBspTree.cpp	(revision 1076)
@@ -629,4 +629,10 @@
 
 
+	// first node is kd node, i.e. an axis aligned box
+	if (1)
+        tData.mIsKdNode = true;
+	else
+		tData.mIsKdNode = false;
+
 	// compute first split candidate
 	VspBspSplitCandidate splitCandidate;
@@ -793,4 +799,5 @@
 			// if it was a kd node (i.e., a box) and the split axis is axis aligned, it is still a kd node
 			tFrontData.mIsKdNode = tBackData.mIsKdNode = (tData.mIsKdNode && (splitAxis < 3));
+			
 			tFrontData.mAxis = tBackData.mAxis = splitAxis;
 
@@ -1539,5 +1546,5 @@
 	//Debug << "use special axis: " << useSpecialAxis << endl;
 	//Debug << "axis: " << sAxis << " drivingaxis: " << box.Size().DrivingAxis();
-
+	
 	for (axis = 0; axis < 3 ; ++ axis)
 	{
@@ -1560,5 +1567,5 @@
 				nPosition[axis] = (box.Min()[axis] + box.Max()[axis]) * 0.5f;
 				Vector3 normal(0,0,0); normal[axis] = 1.0f;
-
+				
 				// allows faster split because we have axis aligned kd tree boxes
 				if (isKdNode)
@@ -2262,15 +2269,17 @@
 
 
-void VspBspTree::AddObjToPvs(Intersectable *obj,
-							 const int cf,
-							 float &frontPvs,
-							 float &backPvs,
-							 float &totalPvs) const
+inline void VspBspTree::AddObjToPvs(Intersectable *obj,
+										 const int cf,
+										 float &frontPvs,
+										 float &backPvs,
+										 float &totalPvs) const
 {
 	if (!obj)
 		return;
-
+#if 0
 	const float renderCost = mViewCellsManager->EvalRenderCost(obj);
-
+#else
+	const int renderCost = 1;
+#endif
 	// new object
 	if ((obj->mMailbox != sFrontId) &&
Index: GTP/trunk/Lib/Vis/Preprocessing/src/VssPreprocessor.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/VssPreprocessor.cpp	(revision 1074)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/VssPreprocessor.cpp	(revision 1076)
@@ -566,5 +566,5 @@
   cout << "use view space box=" << mUseViewSpaceBox<<endl;
 
-
+  
   if (mUseViewSpaceBox)
   {
Index: GTP/trunk/Lib/Vis/Preprocessing/src/VspOspTree.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/VspOspTree.cpp	(revision 1074)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/VspOspTree.cpp	(revision 1076)
@@ -377,5 +377,5 @@
 	//-- debug output
 
-	Debug << "******* VSP BSP options ******** " << endl;
+	Debug << "******* VSP options ******** " << endl;
     Debug << "max depth: " << mTermMaxDepth << endl;
 	Debug << "min PVS: " << mTermMinPvs << endl;
@@ -1641,5 +1641,6 @@
 		return;
 
-	const float renderCost = mViewCellsManager->EvalRenderCost(obj);
+	//const float renderCost = mViewCellsManager->EvalRenderCost(obj);
+	const int renderCost = 1;
 
 	// new object
@@ -2735,5 +2736,5 @@
 	//-- debug output
 
-	Debug << "******* VSP BSP options ******** " << endl;
+	Debug << "******* OSP options ******** " << endl;
     Debug << "max depth: " << mTermMaxDepth << endl;
 	Debug << "min PVS: " << mTermMinPvs << endl;
Index: GTP/trunk/Lib/Vis/Preprocessing/src/Polygon3.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/Polygon3.cpp	(revision 863)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/Polygon3.cpp	(revision 1076)
@@ -11,4 +11,5 @@
 Polygon3::Polygon3(): 
 mMaterial(NULL), mParent(NULL), mPiercingRays(0)
+, mPlane(NULL)
 {
 	// mostly there will be triangles
@@ -18,4 +19,5 @@
 Polygon3::Polygon3(const VertexContainer &vertices): 
 mMaterial(NULL), mParent(NULL), mPiercingRays(0)
+, mPlane(NULL)
 {
 	mVertices.reserve(vertices.size());
@@ -26,4 +28,5 @@
 Polygon3::Polygon3(MeshInstance *parent): 
 mMaterial(NULL), mParent(parent), mPiercingRays(0)
+, mPlane(NULL)
 {}
 
@@ -31,4 +34,5 @@
 Polygon3::Polygon3(Face *face, Mesh *parentMesh):
 mMaterial(NULL), mParent(NULL), mPiercingRays(0)
+, mPlane(NULL)
 {	
 	mVertices.reserve(face->mVertexIndices.size());
@@ -44,7 +48,13 @@
 
 
-Plane3 Polygon3::GetSupportingPlane() const
-{
+Plane3 Polygon3::GetSupportingPlane()// const
+{
+#if 0
 	return Plane3(mVertices[0], mVertices[1], mVertices[2]);
+#else
+	if (!mPlane)
+		mPlane = new Plane3(mVertices[0], mVertices[1], mVertices[2]);
+	return *mPlane;
+#endif
 }
 
Index: GTP/trunk/Lib/Vis/Preprocessing/src/Polygon3.h
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/Polygon3.h	(revision 860)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/Polygon3.h	(revision 1076)
@@ -46,5 +46,5 @@
 	/** Returns supporting plane of this polygon.
 	*/
-	Plane3 GetSupportingPlane() const;
+	Plane3 GetSupportingPlane(); //const;
 
 	/** Splits polygon.
@@ -156,4 +156,7 @@
 	RayContainer mPiercingRays;
 
+	~Polygon3() {DEL_PTR(mPlane);}
+	Plane3 *mPlane;
+
 };
 
Index: GTP/trunk/Lib/Vis/Preprocessing/src/Plane3.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/Plane3.cpp	(revision 863)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/Plane3.cpp	(revision 1076)
@@ -4,4 +4,21 @@
 
 namespace GtpVisibilityPreprocessor {
+
+
+Plane3::Plane3(const Vector3 &a,
+			   const Vector3 &b,
+			   const Vector3 &c) 
+{
+    Vector3 v1=a-b, v2=c-b;
+    mNormal = Normalize(CrossProd(v2,v1));
+    mD = -DotProd(b, mNormal);
+}
+
+Plane3::Plane3(const Vector3 &normal,
+			   const Vector3 &point):
+mNormal(normal)
+{
+    mD = -DotProd(normal, point);
+}
 
 
Index: GTP/trunk/Lib/Vis/Preprocessing/src/UnigraphicsParser.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/UnigraphicsParser.cpp	(revision 1004)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/UnigraphicsParser.cpp	(revision 1076)
@@ -46,5 +46,4 @@
 				 const bool loadPolygonsAsMeshese)
 {
-  
   map<string, Vector3, ltstr> vht; // hash table for vectors
   map<string, Vector3, ltstr> cht; // hash table for colors
@@ -139,9 +138,9 @@
 		vertexIndices.push_back(index);
       }
-      
+    
       face = new Face(vertexIndices);
       
       fscanf(file,"%s",str);   // get the next vertex label
-      
+    
       if (str[0]!=';') {
 	c = cht.find(str);
Index: GTP/trunk/Lib/Vis/Preprocessing/src/KdTree.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/KdTree.cpp	(revision 1074)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/KdTree.cpp	(revision 1076)
@@ -74,4 +74,5 @@
 KdTree::Construct()
 {
+
   if (!splitCandidates)
     splitCandidates = new vector<SortableEntry>;
Index: GTP/trunk/Lib/Vis/Preprocessing/src/Plane3.h
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/Plane3.h	(revision 1047)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/Plane3.h	(revision 1076)
@@ -19,16 +19,9 @@
 		 const Vector3 &b,
 		 const Vector3 &c
-	 ) {
-    Vector3 v1=a-b, v2=c-b;
-    mNormal = Normalize(CrossProd(v2,v1));
-    mD = -DotProd(b, mNormal);
-  }
+	 );
 
   Plane3(const Vector3 &normal,
 		 const Vector3 &point
-		 ):mNormal(normal)
-  {
-    mD = -DotProd(normal, point);
-  }
+		 );
 
   void ReverseOrientation()
Index: GTP/trunk/Lib/Vis/Preprocessing/src/main.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/main.cpp	(revision 1005)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/main.cpp	(revision 1076)
@@ -90,5 +90,4 @@
   }
   
-
   QApplication *app = NULL;
 
@@ -110,4 +109,5 @@
   Environment::GetSingleton()->GetStringValue("Scene.filename", buff);
   string filename(buff);
+ 
   p->LoadScene(filename);
   
Index: GTP/trunk/Lib/Vis/Preprocessing/src/Mesh.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/Mesh.cpp	(revision 1020)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/Mesh.cpp	(revision 1076)
@@ -72,7 +72,7 @@
 {
 	Cleanup();
-   
+ 
 	ComputeBoundingBox();
-   
+ 
 	/** true if it is a watertight convex mesh 
 	*/
@@ -88,4 +88,5 @@
 		
 		cout<<"KD";
+		
 		mKdTree->Construct();
 
@@ -480,6 +481,6 @@
 
 	Plane3 plane = Plane3(mVertices[face->mVertexIndices[0]],
-												mVertices[face->mVertexIndices[1]],
-												mVertices[face->mVertexIndices[2]]);
+						  mVertices[face->mVertexIndices[1]],
+						  mVertices[face->mVertexIndices[2]]);
 	
 	if (!eq(Magnitude(plane.mNormal), 1.0f))
