Index: trunk/source/materials/src/G4OpticalSurface.cc
===================================================================
--- trunk/source/materials/src/G4OpticalSurface.cc	(revision 986)
+++ trunk/source/materials/src/G4OpticalSurface.cc	(revision 1196)
@@ -25,6 +25,6 @@
 //
 //
-// $Id: G4OpticalSurface.cc,v 1.12 2008/12/11 10:23:54 gcosmo Exp $
-// GEANT4 tag $Name: geant4-09-02-ref-02 $
+// $Id: G4OpticalSurface.cc,v 1.15 2009/11/20 00:57:51 gum Exp $
+// GEANT4 tag $Name: geant4-09-03-cand-01 $
 //
 // 
@@ -66,4 +66,5 @@
       polish                     = right.polish;
       theMaterialPropertiesTable = right.theMaterialPropertiesTable;
+      AngularDistribution        = right.AngularDistribution;
      } 
   return *this;
@@ -92,17 +93,25 @@
 		polish = 0.0;
 	}
+        else if ( model == LUT ) {
+                sigma_alpha = value;
+                polish = 0.0;
+        }
 	else {
 		G4Exception("G4OpticalSurface::G4OpticalSurface ==> " 
 			    "Constructor called with INVALID model.");
 	}
-}
-
-G4OpticalSurface::G4OpticalSurface()
-  : G4SurfaceProperty()
-{
+
+        AngularDistribution = NULL;
+
+        if (type == dielectric_LUT) {
+           AngularDistribution =
+                       new float[incidentIndexMax*thetaIndexMax*phiIndexMax];
+           ReadFile();
+        }
 }
 
 G4OpticalSurface::~G4OpticalSurface()
 {
+        if (AngularDistribution) delete AngularDistribution;
 }
 
@@ -143,4 +152,7 @@
 		G4cout << polish      << G4endl;
 	}
+        else if (theModel == LUT ){
+                G4cout << sigma_alpha << G4endl;
+        }
 	else {
 		G4cout << sigma_alpha << G4endl;
@@ -148,2 +160,120 @@
 	G4cout << G4endl;
 }
+
+void G4OpticalSurface::SetType(const G4SurfaceType& type)
+{
+  theType = type;
+  if (type == dielectric_LUT) {
+     if (!AngularDistribution) AngularDistribution =
+                       new float[incidentIndexMax*thetaIndexMax*phiIndexMax];
+     ReadFile();
+  }
+}
+
+void G4OpticalSurface::SetFinish(const G4OpticalSurfaceFinish finish)
+{
+  theFinish = finish;
+  if (theType == dielectric_LUT) {
+     if (!AngularDistribution) AngularDistribution =
+                       new float[incidentIndexMax*thetaIndexMax*phiIndexMax];
+     ReadFile();
+  }
+}
+
+void G4OpticalSurface::ReadFile()
+{
+  G4String readFileName = " ";
+
+  if (theFinish == polishedlumirrorglue) {
+     readFileName = "PolishedLumirrorGlue.dat";
+  }
+  else if (theFinish == polishedlumirrorair) {
+     readFileName = "PolishedLumirror.dat";
+  }
+  else if (theFinish == polishedteflonair) {
+     readFileName = "PolishedTeflon.dat";
+  }
+  else if (theFinish == polishedtioair) {
+     readFileName = "PolishedTiO.dat";
+  }
+  else if (theFinish == polishedtyvekair) {
+     readFileName = "PolishedTyvek.dat";
+  }
+  else if (theFinish == polishedvm2000glue) {
+     readFileName = "PolishedVM2000Glue.dat";
+  }
+  else if (theFinish == polishedvm2000air) {
+     readFileName = "PolishedVM2000.dat";
+  }
+  else if (theFinish == etchedlumirrorglue) {
+     readFileName = "EtchedLumirrorGlue.dat";
+  }
+  else if (theFinish == etchedlumirrorair) {
+     readFileName = "EtchedLumirror.dat";
+  }
+  else if (theFinish == etchedteflonair) {
+     readFileName = "EtchedTeflon.dat";
+  }
+  else if (theFinish == etchedtioair) {
+     readFileName = "EtchedTiO.dat";
+  }
+  else if (theFinish == etchedtyvekair) {
+     readFileName = "EtchedTyvek.dat";
+  }
+  else if (theFinish == etchedvm2000glue) {
+     readFileName = "EtchedVM2000Glue.dat";
+  }
+  else if (theFinish == etchedvm2000air) {
+     readFileName = "EtchedVM2000.dat";
+  }
+  else if (theFinish == groundlumirrorglue) {
+     readFileName = "GroundLumirrorGlue.dat";
+  }
+  else if (theFinish == groundlumirrorair) {
+     readFileName = "GroundLumirror.dat";
+  }
+  else if (theFinish == groundteflonair) {
+     readFileName = "GroundTeflon.dat";
+  }
+  else if (theFinish == groundtioair) {
+     readFileName = "GroundTiO.dat";
+  }
+  else if (theFinish == groundtyvekair) {
+     readFileName = "GroundTyvek.dat";
+  }
+  else if (theFinish == groundvm2000glue) {
+     readFileName = "GroundVM2000Glue.dat";
+  }
+  else if (theFinish == groundvm2000air) {
+     readFileName = "GroundVM2000.dat";
+  }
+
+  if (readFileName == " ") return;
+
+  char* path = getenv("G4REALSURFACEDATA");
+  if (!path) {
+     G4String excep =
+        "G4OpBoundaryProcess - G4REALSURFACEDATA environment variable not set";
+     G4Exception(excep);
+  }
+  G4String pathString(path);
+
+  readFileName = pathString + "/" + readFileName;
+
+  // Open LUT with Material and Integer Angle
+  FILE* readFileHandle;
+
+  readFileHandle = fopen(readFileName,"r");
+
+  if (readFileHandle!=NULL) {
+     for (int i=0;i<incidentIndexMax*thetaIndexMax*phiIndexMax;i++) {
+         fscanf(readFileHandle,"%6f", &AngularDistribution[i]);
+     }
+     G4cout << "LUT - data file: " << readFileName << " read in! " << G4endl;
+  }
+  else {
+     G4String excep = "LUT - data file: " + readFileName + " not found";
+     G4Exception(excep);
+  }
+  fclose(readFileHandle);
+}
