Text archives Help
- From:
- To:
- Subject: [Manta] r2320 - in trunk: Core/Color/Colormaps Model/Readers SwigInterface scenes/csafe scenes/csafe/python scenes/csafe/src
- Date: Mon, 8 Sep 2008 23:18:23 -0600 (MDT)
Author: brownlee
Date: Mon Sep 8 23:18:21 2008
New Revision: 2320
Added:
trunk/scenes/csafe/python/SCIRunCameraPathToManta.py (contents, props
changed)
trunk/scenes/csafe/src/CSAFEObject.cc
trunk/scenes/csafe/src/CSAFEObject.h
Modified:
trunk/Core/Color/Colormaps/LinearColormap.h
trunk/Model/Readers/UDAReader.cc
trunk/SwigInterface/MantaCameraPath.py
trunk/scenes/csafe/CMakeLists.txt
trunk/scenes/csafe/python/Histogram.py
trunk/scenes/csafe/python/SceneMenus.py
trunk/scenes/csafe/python/TransferF.py
trunk/scenes/csafe/python/csafe_demo.py
trunk/scenes/csafe/src/CDGridSpheres.cc
trunk/scenes/csafe/src/CDGridSpheres.h
trunk/scenes/csafe/src/CDSWIGIFY.h
trunk/scenes/csafe/src/CDTest.h
Log:
fixing camerapath, adding script to convert between scirun and manta
camerapaths, fixes to minor annoyances with csafe demo, added ability to use
recursivegrid, but it is too slow with range culling at the moment
Modified: trunk/Core/Color/Colormaps/LinearColormap.h
==============================================================================
--- trunk/Core/Color/Colormaps/LinearColormap.h (original)
+++ trunk/Core/Color/Colormaps/LinearColormap.h Mon Sep 8 23:18:21 2008
@@ -43,6 +43,20 @@
update();
}
+ void setColors(const std::vector<Color>& colors_){
+ colors = colors_;
+ update();
+ }
+
+ float getMin() {
+ return min;
+ }
+
+ float getMax() {
+ return max;
+ }
+
+
Color color(const T& val) const {
// norm is a value in the range [0, N], where N is one less than the
// number of colors.
Modified: trunk/Model/Readers/UDAReader.cc
==============================================================================
--- trunk/Model/Readers/UDAReader.cc (original)
+++ trunk/Model/Readers/UDAReader.cc Mon Sep 8 23:18:21 2008
@@ -93,7 +93,7 @@
cur = cur->next;
}
xmlFreeDoc(doc);
- cout << "UDAReader complete\n";
+ cout << "UDAReader Header complete\n";
}
void UDAReader::readUDA(string directory, string volumeVarName)
@@ -105,7 +105,7 @@
directory = directory + string("/");
_directory = directory;
filename = directory + string("index.xml");
- cout << "UDAReader, reading: " << filename << endl;
+ cout << "UDAReader, reading data: " << filename << endl;
xmlDocPtr doc;
xmlNodePtr cur;
doc = xmlParseFile(filename.c_str());
@@ -154,8 +154,21 @@
}
cur = cur->next;
}
+ cout << "timesteps: \n";
+ for(int i = 0; i < int(timesteps.size()); i++){
+ cout << "timestep : " << i << endl;
+ cout << "numSphereVars: " << timesteps[i].numSphereVars << "
numSpheres: " << timesteps[i].numSpheres << endl;
+ float* s = timesteps[i].sphereData;
+ for(int j = 0; j < timesteps[i].numSpheres; j++) {
+ cout << "sphere " << j << " : " << *s << " " << *(s+1) << " " <<
*(s+2) << endl;
+ s+=3;
+ }
+ cout << "upper: " << timesteps[i].upper << endl;
+ cout << "lower: " << timesteps[i].lower << endl;
+ cout << "indices: " << timesteps[i].indices << endl;
+ }
xmlFreeDoc(doc);
- cout << "UDAReader complete\n";
+ cout << "UDAReader Data complete\n";
}
void UDAReader::parseTimestepFile(string filename)
@@ -659,19 +672,19 @@
timestep.upper[1] = max(patch.upper[1],timestep.upper[1]);
timestep.upper[2] = max(patch.upper[2],timestep.upper[2]);
}
- if ((!xmlStrcmp(cur->name, (const xmlChar *)"interiorLowIndex")))
+ if ((!xmlStrcmp(cur->name, (const xmlChar *)"lowIndex")))
{
stringstream s(parseXMLString((const
char*)xmlNodeListGetString(doc, cur->xmlChildrenNode, 1)));
s >> patch.lowIndex[0] >> patch.lowIndex[1] >>
patch.lowIndex[2];
+ patch.lowIndex[0]++;
+ patch.lowIndex[1]++;
+ patch.lowIndex[2]++;
}
if ((!xmlStrcmp(cur->name, (const xmlChar
*)"interiorHighIndex")))
{
stringstream s(parseXMLString((const
char*)xmlNodeListGetString(doc, cur->xmlChildrenNode, 1)));
s >> patch.highIndex[0] >> patch.highIndex[1] >>
patch.highIndex[2];
- patch.highIndex[0]++;
- patch.highIndex[1]++;
- patch.highIndex[2]++;
- timestep.indices[0] =
max(patch.highIndex[0],timestep.indices[0]);
+ timestep.indices[0] =
max(patch.highIndex[0],timestep.indices[0]);
timestep.indices[1] =
max(patch.highIndex[1],timestep.indices[1]);
timestep.indices[2] =
max(patch.highIndex[2],timestep.indices[2]);
}
Modified: trunk/SwigInterface/MantaCameraPath.py
==============================================================================
--- trunk/SwigInterface/MantaCameraPath.py (original)
+++ trunk/SwigInterface/MantaCameraPath.py Mon Sep 8 23:18:21 2008
@@ -201,6 +201,7 @@
# Toggle buttons.
self.new_path_button.SetLabel( "New Path" )
+
# Create a new automator.
automator = CameraPathAutomator( self.engine, 0, 0,
self.new_path_data,
@@ -221,7 +222,7 @@
# Add a timer to record camera position information.
self.record_timer.Start( interval )
- self.record_prev_frame = self.engine.getCurrentFrame()
+ self.record_prev_frame =
self.engine.getFrameState().frameSerialNumber
self.record_prev_time = time.time()
# Toggle buttons.
@@ -233,7 +234,7 @@
camera_data = self.engine.getCamera( self.channel
).getBasicCameraData()
# Compute elapse time and frames.
- current_frame = self.engine.getCurrentFrame()
+ current_frame = self.engine.getFrameState().frameSerialNumber
current_time = time.time()
elapse_frames = current_frame - self.record_prev_frame;
Modified: trunk/scenes/csafe/CMakeLists.txt
==============================================================================
--- trunk/scenes/csafe/CMakeLists.txt (original)
+++ trunk/scenes/csafe/CMakeLists.txt Mon Sep 8 23:18:21 2008
@@ -91,6 +91,8 @@
src/CDTest.h
src/CDGridSpheres.cc
src/CDGridSpheres.h
+ src/CSAFEObject.cc
+ src/CSAFEObject.h
)
Modified: trunk/scenes/csafe/python/Histogram.py
==============================================================================
--- trunk/scenes/csafe/python/Histogram.py (original)
+++ trunk/scenes/csafe/python/Histogram.py Mon Sep 8 23:18:21 2008
@@ -84,12 +84,12 @@
self.dMax = dataMax #the min and max of displayed data
self.zoomDMin = dataMin #min data value of data to display (may not
be an actual value contianed in data)
self.zoomDMax = dataMax #max data value of data to display (may not
be an actual value contianed in data)
- self.absoluteDMin = self.dMin #absolute min of the data
+ self.absoluteDMin = self.dMin #absolute min of the data (ignoring
zoom)
self.absoluteDMax = self.dMax
- self.colorDMin = self.dMin
- self.colorDMax = self.dMax
- self.zoomDMin = self.dMin
- self.zoomDMax = self.dMax
+ self.colorDMin = self.dMin #scale colors by this minimum value
+ self.colorDMax = self.dMax #scale colors by this maximum value
+ self.zoomDMin = self.dMin
+ self.zoomDMax = self.dMax
self.data = histValues
self.numBuckets = len(histValues)
self.Update()
@@ -207,8 +207,12 @@
self.Refresh()
if (self.parent.group != 1): #if not the volumedata
- self.scene.test.setClipMinMax(self.varIndex,
float(self.cropDMin - 0.00000001), float(self.cropDMax+ 0.00000001))
#TODO: should get rid of epsilon...
-
+ index = self.varIndex;
+ min = self.cropDMin - 0.00001
+ max = self.cropDMax + 0.00001
+ min = float(0)
+ max = float(1)
+ self.scene.test.setClipMinMax(index, min,max) #TODO: should
get rid of epsilon...
def SetValues(self, datavalues, nbuckets, widthn, heightn):
self.data = datavalues
@@ -216,37 +220,6 @@
self.width = widthn
self.height = heightn
- def SendValues(self, zoomMin, zoomMax, cropMin, cropMax, colorMin,
colorMax): #sent from MeasurementsFrame
- #print "values arrived"
- self.zooms.append( (self.zoomDMin, self.zoomDMax))
- self.zoomDMin = zoomMin
- self.zoomDMax = zoomMax
- self.colorDMin = colorMin
- self.colorDMax = colorMax
- self.Update()
- min = 0
- max = 0
- dWidth = self.dMax - self.dMin
- if dWidth == 0:
- dWidth = 1.0
- self.cropMin = (cropMin - self.dMin)/dWidth
- self.cropMax = (cropMax - self.dMin)/dWidth
- if self.cropDMin < 0.0:
- self.cropDMin = 0.0
- if self.cropDMin > 1.0:
- self.cropDMin = 1.0
- if self.cropDMax < 0.0:
- self.cropDMax = 0.0
- if self.cropDMax > 1.0:
- self.cropDMax = 1.0
-
- self.cropDMin = self.cropMin*dWidth + self.dMin #cropped data min
- self.cropDMax = self.cropMax*dWidth + self.dMin #cropped data max
- if (self.parent.group == 0):
- self.scene.test.setSphereCMinMax(self.varIndex, colorMin,
colorMax)
- else:
- self.scene.test.setVolCMinMax(colorMin, colorMax)
-
#update dMin/Max, cropMin/Max based on zoomDMin/Max
def UpdateDMinMax(self):
@@ -357,7 +330,8 @@
if float(barHeightNorm) > 1.0:
print "error"
# print '%f %f %f %f' % (frequency, start, end, barHeightNorm)
- colorPos = (( (float(i)/width)*(absoluteDMax-absoluteDMin))
+ absoluteDMin- self.colorDMin)/colorWidth
+ # colorPos = (( (float(i)/width)*(absoluteDMax-absoluteDMin))
+ absoluteDMin- self.colorDMin)/colorWidth
+ colorPos = ((
(float(i)/width)*(self.zoomDMax-self.zoomDMin)) + self.zoomDMin-
self.colorDMin)/colorWidth
#print colorPos
color = self.transferF.GetColor(colorPos)
self.lines.append( (color, ( blx + i, bly, blx + i, (bly -
barHeightNorm*height) ) ) )
@@ -469,10 +443,8 @@
self.datavalues = []
for i in range(0, self.scene.histogramBuckets):
self.datavalues.append(5)
- min = SWIGIFYCreateDouble(0)
- max = SWIGIFYCreateDouble(100)
- self.dataMin = SWIGIFYGetDouble(min)
- self.dataMax = SWIGIFYGetDouble(max)
+ self.dataMin = 0
+ self.dataMax = 100
self.numbuckets = self.scene.histogramBuckets
self.width = 300.0
self.height = 40.0
@@ -523,7 +495,7 @@
zoomMax = self.histogram.zoomDMax
cropMin = self.histogram.cropDMin
cropMax = self.histogram.cropDMax
- self.histogram.SendValues(zoomMin, zoomMax, cropMin, cropMax,
float(min), float(max))
+ self.SendValues(zoomMin, zoomMax, cropMin, cropMax, float(min),
float(max))
def OnClick(self, evt):
print "clicked histogro"
@@ -609,8 +581,40 @@
self.visible = True
def OnClickMeasurements(self, evt):
- win = MeasurementsFrame(self.histogram, -1, self.title + "
Measurements", self.histogram.zoomDMin, self.histogram.zoomDMax,
self.histogram.cropDMin, self.histogram.cropDMax, self.histogram.colorDMin,
self.histogram.colorDMax, self.group)
+ win = MeasurementsFrame(self, -1, self.title + " Measurements",
self.histogram.zoomDMin, self.histogram.zoomDMax, self.histogram.cropDMin,
self.histogram.cropDMax, self.histogram.colorDMin, self.histogram.colorDMax,
self.group)
win.Show(True)
+
+ def SendValues(self, zoomMin, zoomMax, cropMin, cropMax, colorMin,
colorMax): #sent from MeasurementsFrame
+ #print "values arrived"
+ self.histogram.zooms.append( (self.histogram.zoomDMin,
self.histogram.zoomDMax))
+ self.histogram.zoomDMin = zoomMin
+ self.histogram.zoomDMax = zoomMax
+ self.histogram.colorDMin = colorMin
+ self.histogram.colorDMax = colorMax
+ self.histogram.Update()
+ min = 0
+ max = 0
+ dWidth = self.histogram.dMax - self.histogram.dMin
+ if dWidth == 0:
+ dWidth = 1.0
+ self.histogram.cropMin = (cropMin - self.histogram.dMin)/dWidth
+ self.histogram.cropMax = (cropMax - self.histogram.dMin)/dWidth
+ if self.histogram.cropDMin < 0.0:
+ self.histogram.cropDMin = 0.0
+ if self.histogram.cropDMin > 1.0:
+ self.histogram.cropDMin = 1.0
+ if self.histogram.cropDMax < 0.0:
+ self.histogram.cropDMax = 0.0
+ if self.histogram.cropDMax > 1.0:
+ self.histogram.cropDMax = 1.0
+
+ self.histogram.cropDMin = self.histogram.cropMin*dWidth +
self.histogram.dMin #cropped data min
+ self.histogram.cropDMax = self.histogram.cropMax*dWidth +
self.histogram.dMin #cropped data max
+ if (self.histogram.parent.group == 0):
+ if self.transferFPanel.transferFPanel.histogramGroup == self:
+ self.scene.test.setSphereColorMinMax(self.histogram.varIndex,
colorMin, colorMax)
+ else:
+ self.scene.test.setVolColorMinMax(colorMin, colorMax)
def OnClickZoomIn(self, evt):
self.histogram.ZoomIn()
@@ -630,6 +634,7 @@
self.scene.test.setCidx(self.varIndex)
if (self.transferF != None):
self.scene.test.setSphereCMap(self.transferF.cmap)
+ self.scene.test.setSphereColorMinMax(self.varIndex,
self.histogram.colorDMin, self.histogram.colorDMax)
def OnClickVisible(self, evt):
if self.visible:
Added: trunk/scenes/csafe/python/SCIRunCameraPathToManta.py
==============================================================================
--- (empty file)
+++ trunk/scenes/csafe/python/SCIRunCameraPathToManta.py Mon Sep 8
23:18:21 2008
@@ -0,0 +1,42 @@
+#! /usr/bin/python
+
+#
+# converts a scirun camera path file to a manta camera path file.
+#
+# usage: script.py [scirun camerapath file] [output manta camera path
filename]
+# by: Carson Brownlee (brownleeATcs.utah.edu)
+#
+
+import sys
+
+if len(sys.argv) < 3:
+ print "incorrect command line arguments. \n correct usage: [inputfile]
[outputfile]"
+ sys.exit(1)
+
+fin = open(sys.argv[1], 'r')
+fout = open(sys.argv[2], 'w')
+
+lines = fin.readlines()
+num = int(float(lines[0]))
+fout.write('delta_t(1.0000000)\n')
+fout.write('delta_time(0.50000)\n')
+for i in range(1,num):
+ line = lines[i].split()
+ e_x = float(line[0])
+ e_y = float(line[1])
+ e_z = float(line[2])
+
+ l_x = float(line[3])
+ l_y = float(line[4])
+ l_z = float(line[5])
+
+ up_x = float(line[6])
+ up_y = float(line[7])
+ up_z = float(line[8])
+
+ fov = float(line[9])
+ wtf = float(line[10])
+ fout.write('control( -eye '+str(e_x)+' '+str(e_y)+' '+str(e_z)+' -lookat
'+str(l_x) \
+ +' '+str(l_y)+' '+str(l_z)+' -up '+str(up_x)+'
'+str(up_y)+' '+str(up_z)+' )\n')
+
+
Modified: trunk/scenes/csafe/python/SceneMenus.py
==============================================================================
--- trunk/scenes/csafe/python/SceneMenus.py (original)
+++ trunk/scenes/csafe/python/SceneMenus.py Mon Sep 8 23:18:21 2008
@@ -22,9 +22,9 @@
sizer.Add(wx.StaticText(panel,-1, "Sphere data nrrds/nhdrs: "))
sizer.Add(self.lb1, -1, wx.ALL|wx.ALIGN_CENTER, 5)
hSizer1 = wx.BoxSizer(wx.HORIZONTAL)
- self.addButton = wx.Button(panel,wx.ID_ADD)
- self.removeButton = wx.Button(panel, wx.ID_REMOVE)
- hSizer1.Add(self.addButton, 0, wx.ALL, 3)
+ self.addParticlesButton = wx.Button(panel,-1, "Add Particles File")
+ self.removeButton = wx.Button(panel, -1,"Remove Particles")
+ hSizer1.Add(self.addParticlesButton, 0, wx.ALL, 3)
hSizer1.Add(self.removeButton, 0, wx.ALL, 3)
sizer.Add(hSizer1, 0, wx.ALL|wx.ALIGN_CENTER, 5)
@@ -33,9 +33,9 @@
sizer.Add(self.lb2, -1, wx.ALL|wx.ALIGN_CENTER, 5)
hSizer2 = wx.BoxSizer(wx.HORIZONTAL)
- self.addButton2 = wx.Button(panel,-1, "Add")
- self.removeButton2 = wx.Button(panel, -1, "Remove")
- hSizer2.Add(self.addButton2, 0, wx.ALL, 3)
+ self.addVolumeButton = wx.Button(panel,-1, "Add Volume File")
+ self.removeButton2 = wx.Button(panel, -1, "Remove Volume")
+ hSizer2.Add(self.addVolumeButton, 0, wx.ALL, 3)
hSizer2.Add(self.removeButton2, 0, wx.ALL, 3)
sizer.Add(hSizer2, 0, wx.ALL|wx.ALIGN_CENTER, 5)
@@ -54,8 +54,8 @@
self.Refresh()
self.Bind(wx.EVT_BUTTON, self.OnClickOk, self.okButton)
- self.Bind(wx.EVT_BUTTON, self.OnClickAdd, self.addButton)
- self.Bind(wx.EVT_BUTTON, self.OnClickAdd2, self.addButton2)
+ self.Bind(wx.EVT_BUTTON, self.OnClickAddParticles,
self.addParticlesButton)
+ self.Bind(wx.EVT_BUTTON, self.OnClickAddVolume, self.addVolumeButton)
self.Bind(wx.EVT_BUTTON, self.OnClickCancel, self.cancelButton)
self.Bind(wx.EVT_BUTTON, self.OnClickRemove, self.removeButton)
self.Bind(wx.EVT_BUTTON, self.OnClickRemove2, self.removeButton2)
@@ -104,11 +104,11 @@
except:
continue
- def OnClickAdd(self, evt):
- wildcard = "Nrrd File (*.nrrd)|*.nrrd|" \
- "Nrrd Header (*.nrhd)|*.nrhd|" \
- "All files (*.*)|*.*"
- dlg = wx.FileDialog(self, message="Choose a file(s)",
+ def OnClickAddParticles(self, evt):
+ wildcard = "All files (*.*)|*.*" \
+ "Nrrd File (*.nrrd)|*.nrrd|" \
+ "Nrrd Header (*.nrhd)|*.nhdr|"
+ dlg = wx.FileDialog(self, message="Choose a Particle file(s)",
defaultDir=os.getcwd(), defaultFile="",wildcard=wildcard,
style=wx.OPEN | wx.MULTIPLE | wx.CHANGE_DIR)
if dlg.ShowModal() == wx.ID_OK:
@@ -123,11 +123,12 @@
dlg.Destroy()
- def OnClickAdd2(self, evt):
- wildcard = "Nrrd File (*.nrrd)|*.nrrd|" \
- "Nrrd Header (*.nrhd)|*.nrhd|" \
- "All files (*.*)|*.*"
- dlg = wx.FileDialog(self, message="Choose a file(s)",
+ def OnClickAddVolume(self, evt):
+ wildcard = "All files (*.*)|*.*" \
+ "Nrrd File (*.nrrd)|*.nrrd|" \
+ "Nrrd Header (*.nrhd)|*.nhdr|"
+
+ dlg = wx.FileDialog(self, message="Choose a Volume file(s)",
defaultDir=os.getcwd(), defaultFile="",wildcard=wildcard,
style=wx.OPEN | wx.MULTIPLE | wx.CHANGE_DIR)
if dlg.ShowModal() == wx.ID_OK:
@@ -530,7 +531,7 @@
histValues1.append(5)
colors = []
#t = TransferF.TransferF(self, colors, self.transferFID, self.name,
manta_new(CDColorMap(1)))
- histoGroup = Histogram.HistogramGroup(self.scene.frame.panel,
histValues1, dataMin, dataMax, 300, 40.0,
self.scene.frame.transferFunctions[self.transferFID], self.scene.tPanel,
self.scene, self.index, self.name)
+ histoGroup = Histogram.HistogramGroup(self.scene.frame.panel,
self.scene, self.index, self.name, self.transferFID)
color = wx.Colour(90,90,90)
histoGroup.group = self.group
histoGroup.SetBackgroundColour(color)
Modified: trunk/scenes/csafe/python/TransferF.py
==============================================================================
--- trunk/scenes/csafe/python/TransferF.py (original)
+++ trunk/scenes/csafe/python/TransferF.py Mon Sep 8 23:18:21 2008
@@ -164,7 +164,7 @@
self.colorSelectorWidth = 10.0
self.selected = None
self.dSelected = None
- self.histogram = None
+ self.histogramGroup = None
self.SetBackgroundColour(wx.Colour(90,90,90))
def SetUpdateFunction(self, function):
@@ -254,11 +254,11 @@
def SetHistogramGroup(self, histo):
- self.histogram = histo
+ self.histogramGroup = histo
def UpdateHistogram(self):
- if self.histogram != None:
- self.histogram.Update()
+ if self.histogramGroup != None:
+ self.histogramGroup.Update()
self.transferF.UpdateColorMap()
def OnClick(self, evt):
@@ -524,11 +524,11 @@
self.transferF = transferF
self.transferFPanel.SetTransferF(transferF)
label = transferF.label
- if self.transferFPanel.histogram != None:
- label = str(label) + str(" : ") +
str(self.transferFPanel.histogram.title)
+ if self.transferFPanel.histogramGroup != None:
+ label = str(label) + str(" : ") +
str(self.transferFPanel.histogramGroup.title)
self.SetLabel(label)
- if self.transferFPanel.histogram != None:
- self.transferFPanel.histogram.SetTransferF(transferF)
+ if self.transferFPanel.histogramGroup != None:
+ self.transferFPanel.histogramGroup.SetTransferF(transferF)
def SetUpdateFunction(self, function):
print ""
Modified: trunk/scenes/csafe/python/csafe_demo.py
==============================================================================
--- trunk/scenes/csafe/python/csafe_demo.py (original)
+++ trunk/scenes/csafe/python/csafe_demo.py Mon Sep 8 23:18:21 2008
@@ -145,7 +145,7 @@
self.scene.frame.LayoutWindow()
self.BuildHistograms()
self.slider.SetRange(1, 1)
- self.scene.mantaFrame.StartEngine()
+ self.scene.mantaApp.frame.StartEngine()
def Menu101(self, evt):
info = wx.AboutDialogInfo()
@@ -233,7 +233,6 @@
################ Generate Scene #################
def Menu203(self, evt):
self.BuildScene()
- self.scene.mantaFrame.StartEngine()
################ Add Histogram #################
def Menu204(self, evt):
@@ -261,13 +260,14 @@
for i in range(0, len(self.scene.nrrdFiles)):
self.test.addSphereNrrd(self.scene.nrrdFiles[i])
#self.test.loadSphereNrrds()
- self.test.setVolCMinMax(300, 2100)
+ self.test.setVolColorMinMax(300, 2100)
self.test.reloadData()
#self.test.loadVolNrrds()
self.BuildHistograms()
self.slider.SetRange(1, int(max(len(self.scene.nrrdFiles),
len(self.scene.nrrdFiles2))))
+ self.scene.mantaApp.frame.StartEngine()
def BuildHistograms(self):
for i in range(len(self.histoGroups)):
@@ -293,12 +293,13 @@
#print histValues[j]
self.histoGroups[i].SetValues(histValues, dataMin, dataMax)
if vol == False:
-
self.test.getSphereCMinMax(self.histoGroups[i].varIndex, cmin, cmax)
+
self.test.getSphereDataMinMax(self.histoGroups[i].varIndex, cmin, cmax)
else:
- self.test.getVolCMinMax(cmin, cmax)
+ self.test.getVolDataMinMax(cmin, cmax)
dataCMin = SWIGIFYGetFloat(cmin)
dataCMax = SWIGIFYGetFloat(cmax)
self.histoGroups[i].SetCMinMax(dataCMin, dataCMax)
+ SWIGIFYDestroyIntArray(histValues1Ptr)
def UpdateColorMap(self, transferF):
@@ -312,6 +313,7 @@
if (cmap != None):
cmap.SetColors(slices)
self.volCMap.scaleAlphas(0.00125)
+ self.scene.test.updateSphereCMap()
def OnClick(self, evt):
print "clicked main"
@@ -335,8 +337,6 @@
self.visible = True
def InitializeScene(self,frame, engine):
-
- self.scene.mantaFrame = frame
self.SetBackgroundColour(self.scene.bgColor)
@@ -567,38 +567,8 @@
setup = Setup()
def initialize_scene( frame, engine ):
- global setup
- frame1 = MyFrame(None, -1, "CSAFE Demo")
- frame1.Show(True)
- frame1.InitializeScene(frame, engine)
- frame1.LayoutWindow()
- print "cfg: " + str(setup.cfg)
- if (setup.cfg != ""):
- Configuration.ReadConfiguration(frame1.scene, setup.cfg)
- if (setup.nrrdlist != ""):
- Configuration.ReadNRRDList(frame1.scene, setup.nrrdlist)
- if (setup.uda != ""):
- frame1.scene.test.readUDAHeader(str(setup.uda))
- frame1.scene.test.loadUDA(str(setup.uda), str(setup.udaVol))
- t0 = TransferF.TransferF(frame1, [], 1, "x")
- histoGroup0 = Histogram.HistogramGroup(frame1.scene.frame.panel,
frame1.scene, 0, "x")
- frame1.scene.frame.histoGroups.append(histoGroup0)
- histoGroup1 = Histogram.HistogramGroup(frame1.scene.frame.panel,
frame1.scene, 1, "y")
- frame1.scene.frame.histoGroups.append(histoGroup1)
- histoGroup2 = Histogram.HistogramGroup(frame1.scene.frame.panel,
frame1.scene, 2, "z")
- frame1.scene.frame.histoGroups.append(histoGroup2)
-
- frame1.scene.frame.LayoutWindow()
- frame1.BuildHistograms()
- frame1.slider.SetRange(1, 1)
- frame1.scene.mantaFrame.StartEngine()
-
- if (setup.generate == True):
- frame1.BuildScene()
- frame1.scene.mantaFrame.StartEngine()
- frame1.scene.numThreads = setup.num_workers
- frame1.scene.engine.changeNumWorkers(frame1.scene.numThreads)
-
+ print "setup"
+
def usage():
print "Usage: python test.py [options]"
@@ -645,23 +615,52 @@
usage()
-
###########################################################################
# Create the application.
app = wxManta.MantaApp( initialize_scene,
- setup.num_workers, (512,512), False, None,
begin_rendering=False)
-
+ setup.num_workers, renderSize=(512,512),
begin_rendering=False)
+
+ frame1 = MyFrame(None, -1, "CSAFE Demo")
+ frame1.scene.mantaFrame = app.frame
+ #frame1.scene.mantaFrame.StartEngine()
+ frame1.Show(True)
+ frame1.InitializeScene(app.frame, app.frame.engine)
+ frame1.LayoutWindow()
+ frame1.scene.mantaApp = app
+ print "cfg: " + str(setup.cfg)
+ if (setup.cfg != ""):
+ Configuration.ReadConfiguration(frame1.scene, setup.cfg)
+ if (setup.nrrdlist != ""):
+ Configuration.ReadNRRDList(frame1.scene, setup.nrrdlist)
+ if (setup.uda != ""):
+ frame1.scene.test.readUDAHeader(str(setup.uda))
+ frame1.scene.test.loadUDA(str(setup.uda), str(setup.udaVol))
+ t0 = TransferF.TransferF(frame1, [], 1, "x")
+ histoGroup0 = Histogram.HistogramGroup(frame1.scene.frame.panel,
frame1.scene, 0, "x")
+ frame1.scene.frame.histoGroups.append(histoGroup0)
+ histoGroup1 = Histogram.HistogramGroup(frame1.scene.frame.panel,
frame1.scene, 1, "y")
+ frame1.scene.frame.histoGroups.append(histoGroup1)
+ histoGroup2 = Histogram.HistogramGroup(frame1.scene.frame.panel,
frame1.scene, 2, "z")
+ frame1.scene.frame.histoGroups.append(histoGroup2)
+
+ frame1.scene.frame.LayoutWindow()
+ frame1.BuildHistograms()
+ frame1.slider.SetRange(1, 1)
+ frame1.scene.mantaApp.frame.StartEngine()
+
+ if (setup.generate == True):
+ frame1.BuildScene()
+ frame1.scene.numThreads = setup.num_workers
+ frame1.scene.engine.changeNumWorkers(frame1.scene.numThreads)
###########################################################################
# Perform any additional setup
-
-
+
+ # initialize_scene2(app.frame, app.frame.engine, app)
# Start rendering.
app.MainLoop()
if __name__ == "__main__":
print "starting\n"
main()
-
-
-
+
Modified: trunk/scenes/csafe/src/CDGridSpheres.cc
==============================================================================
--- trunk/scenes/csafe/src/CDGridSpheres.cc (original)
+++ trunk/scenes/csafe/src/CDGridSpheres.cc Mon Sep 8 23:18:21 2008
@@ -13,6 +13,8 @@
#include <Interface/ShadowAlgorithm.h>
#include "CDGridSpheres.h"
#include <Model/Textures/Constant.h>
+#include <Model/Materials/Lambertian.h>
+#include <Model/Materials/Phong.h>
#include <Core/Containers/Array1.h>
#include <Core/Math/MinMax.h>
#include <Core/Util/Timer.h>
@@ -31,6 +33,7 @@
radius(radius), ridx(ridx), ncells(ncells), depth(depth),
cmap(cmap), cidx(cidx), _useAmbientOcclusion(false)
{
+ _matl = new Phong(this, this, 10, NULL);
cerr<<"Initializing GridSpheres\n";
if (radius <= 0) {
@@ -109,6 +112,7 @@
void CDGridSpheres::preprocess(const PreprocessContext& context)
{
+ _matl->preprocess(context);
// Preprocess material
LitMaterial::preprocess(context);
@@ -567,23 +571,25 @@
void CDGridSpheres::shade(const RenderContext& context, RayPacket& rays)
const
{
// Compute ambient light
- ColorArray ambient;
- activeLights->getAmbientLight()->computeAmbient(context, rays,
ambient);
+ ColorArray ambient;
+ // activeLights->getAmbientLight()->computeAmbient(context, rays,
ambient);
// Shade a bunch of rays that have intersected the same particle
- lambertianShade(context, rays, ambient);
+ // lambertianShade(context, rays, ambient);
+
+ _matl->shade(context, rays);
}
void CDGridSpheres::lambertianShade(const RenderContext& context, RayPacket&
rays,
ColorArray& totalLight) const
{
- // Compute normals
+ // Compute normals
rays.computeNormals<false>(context);
// Compute colors
Packet<Color> diffuse;
mapDiffuseColors(diffuse, rays);
-
+ /*
// Normalize directions for proper dot product computation
rays.normalizeDirections();
@@ -615,7 +621,8 @@
totalLight[j][i] +=
light[j]*cos_theta;
}
}
- } while(!shadowState.done());
+ } while(!shadowState.done());*/
+ _matl->shade(context, rays);
if (_useAmbientOcclusion)
{
//ambient occlusion
@@ -632,10 +639,11 @@
{
// Sum up diffuse/specular contributions
for (int i=rays.begin(); i < rays.end(); ++i) {
- Color result;
+ /*Color result;
for (int j=0;j<Color::NumComponents; ++j)
-
result[j]=totalLight[j][i]*diffuse.colordata[j][i];
- rays.setColor(i, result);
+ result[j]=totalLight[j][i]*diffuse.colordata[j][i];*/
+
+ rays.setColor(i, rays.getColor(i)*diffuse.get(i));
}
}
}
@@ -1074,6 +1082,17 @@
//diffuse.set(i, cmap->blended[idx]);
diffuse.set(i, cmap->GetColor(normalized).color);
}
+}
+
+void CDGridSpheres::mapValues(Packet<Color>& results, const RenderContext&,
RayPacket& rays) const {
+ // cout << "mapping values based on color index: " << cidx << endl;
+ for(int i = rays.begin(); i < rays.end(); i++) {
+ int particle=rays.scratchpad<int>(i);
+ float value=*(spheres + particle + cidx);
+ float minimum=cmin[cidx];
+ float normalized=(value-minimum)/(cmax[cidx] - minimum);
+ results.set(i, cmap->GetColor(normalized).color);
+ }
}
bool CDGridSpheres::clip(int s) const
Modified: trunk/scenes/csafe/src/CDGridSpheres.h
==============================================================================
--- trunk/scenes/csafe/src/CDGridSpheres.h (original)
+++ trunk/scenes/csafe/src/CDGridSpheres.h Mon Sep 8 23:18:21 2008
@@ -22,7 +22,7 @@
class RegularColorMap;
class CDGridSpheres : public PrimitiveCommon, public LitMaterial,
- public TexCoordMapper
+ public TexCoordMapper, public Texture<Color>
{
public:
CDGridSpheres(float* spheres, int nspheres, int nvars, int
ncells, int depth,
@@ -108,6 +108,10 @@
void lambertianShade(const RenderContext& context, RayPacket&
rays,
ColorArray&
totalLight) const;
+void mapValues(Packet<Color>& results,
+ const RenderContext&,
+ RayPacket& rays) const;
+
protected:
float* spheres;
@@ -141,6 +145,7 @@
int cidx;
AmbientOcclusion* _ao;
bool _useAmbientOcclusion;
+ Material* _matl;
};
}
Modified: trunk/scenes/csafe/src/CDSWIGIFY.h
==============================================================================
--- trunk/scenes/csafe/src/CDSWIGIFY.h (original)
+++ trunk/scenes/csafe/src/CDSWIGIFY.h Mon Sep 8 23:18:21 2008
@@ -13,6 +13,11 @@
return new int[size];
}
+void SWIGIFYDestroyIntArray(int* array)
+{
+ delete[] array;
+}
+
double SWIGIFYGetIntArrayValue(int* array, int i) { return array[i]; }
double* SWIGIFYCreateDouble(double val) { return new double(val);}
Modified: trunk/scenes/csafe/src/CDTest.h
==============================================================================
--- trunk/scenes/csafe/src/CDTest.h (original)
+++ trunk/scenes/csafe/src/CDTest.h Mon Sep 8 23:18:21 2008
@@ -7,6 +7,13 @@
#ifndef CDTEST_H
#define CDTEST_H
+#include <Model/Primitives/Sphere.h>
+#include <Model/Materials/Phong.h>
+#include <Model/Materials/AmbientOcclusion.h>
+#include <Model/Groups/RecursiveGrid.h>
+#include "CSAFEObject.h"
+#include <Model/Textures/ValueColormap.h>
+
#include <Model/Materials/Volume.h>
#include <Core/Color/Color.h>
#include <Core/Geometry/Vector.h>
@@ -45,9 +52,18 @@
#include <vector>
#include <string>
+#define PRECOMPUTE_GRIDS 1
+#define USE_GRIDSPHERES 1
+
using namespace std;
using namespace Manta;
+#if USE_GRIDSPHERES
+typedef CDGridSpheres GridType;
+#else
+ typedef RecursiveGrid GridType;
+#endif
+
/*!
\class CDTest
@@ -80,8 +96,17 @@
_useAO = false;
_spheresVisible = true;
_volVisible = true;
+ _sphereCMap = NULL;
+ _sphereDMins = new float[16];
+ _sphereDMaxs = new float[16];
}
+ ~CDTest()
+ {
+ delete[] _sphereDMins;
+ delete[] _sphereDMaxs;
+ }
+
//! sets the scene object, necessary for initializing scene and
loading spheres/volume
/*!
\param scene to set
@@ -96,6 +121,10 @@
*/
void initScene()
{
+ if (!_sphereCMap)
+ _sphereCMap =
LinearColormap<float>::createColormap(Rainbow,400,600);
+ ValueColormap<float>* vcmap = new ValueColormap<float>(_sphereCMap);
+ _sphereMatl = new Phong(vcmap,vcmap, 10, NULL);
_world = new Group();
_scene->setBackground(new ConstantBackground(Color(RGB(.5, .5,
.5))));
_scene->setObject(_world);
@@ -110,6 +139,9 @@
if (_sphereAnimation)
delete _sphereAnimation;
_sphereAnimation= new KeyFrameAnimation();
+#if !PRECOMPUTE_GRIDS
+ _sphereAnimation->useAccelerationStructure(new RecursiveGrid(3));
+#endif
if (_volAnimation)
delete _volAnimation;
_volAnimation = new KeyFrameAnimation();
@@ -272,29 +304,75 @@
//! load list of sphere nrrd files
/*!
-
*/
void loadSphereNrrds()
{
LightSet* lights = _scene->getLights();
PreprocessContext context(_manta_interface, 0, 1, lights);
_nrrds.clear();
- for(vector<string>::iterator i = _nrrdFilenames.begin(); i !=
_nrrdFilenames.end(); i++)
+ for(int i = 0; i < 16; i++) {
+ _sphereDMins[i] = -FLT_MAX;
+ _sphereDMaxs[i] = FLT_MAX;
+ }
+
+ for(vector<string>::iterator itr = _nrrdFilenames.begin(); itr
!= _nrrdFilenames.end(); itr++)
{
- cout << "Loading Nrrd file: " << *i << "...\n";
+ cout << "Loading Nrrd file: " << *itr << "...\n";
ParticleNRRD* pnrrd = new ParticleNRRD();
- pnrrd->readFile(*i);
+ pnrrd->readFile(*itr);
+ if (_cidx >= int(pnrrd->getNVars())) {
+ cerr << "error: color index not in data, settting to index
0\n";
+ _cidx = 0;
+ }
+ if (_ridx >= int(pnrrd->getNVars())) {
+ cerr << "error: radius index not in data, setting to
constant radius\n";
+ _ridx = -1;
+ }
+ if (pnrrd->getNVars() < 3) {
+ cerr << "fatal IO error: expected a sphere file with at
least 3 data indices\n";
+ exit(2);
+ }
_spherePNrrds.push_back(pnrrd);
Group* group = new Group();
- RGBAColorMap* cmap = new RGBAColorMap(1);
+
+#if USE_GRIDSPHERES
+ RGBAColorMap* cmap = new RGBAColorMap(1);
CDGridSpheres* grid = new
CDGridSpheres(pnrrd->getParticleData(), pnrrd->getNParticles(),
pnrrd->getNVars(), 6, 2,_radius, _ridx, cmap , _cidx);
//grid->setCMinMax(4, 299.50411987304688, 500.59423828125);
- //TODO: unhardcode this!
- //cout << "reprocess\n";
- //grid->preprocess(context);
- //cout << "donepreprocess\n";
+ //Material* matl = new Phong(Color(RGB(1,0,0)),
Color(RGB(1,0,0)), 10);
+ //Material* matl = new AmbientOcclusion(colormap, 0.01, 10);
+ //grid->preprocess(context);
+
+#else
+ Group* g = new Group();
+ _sphereGroups.push_back(g);
+ CSAFEPrim::init(pnrrd->getNVars(), _sphereDMins,
_sphereDMaxs, _cidx);
+ float radius = _radius;
+ for(size_t i = 0; i < pnrrd->getNParticles(); i++) {
+ float* data = pnrrd->getParticleData() +
i*pnrrd->getNVars();
+ if (_ridx > -1)
+ radius = data[_ridx];
+ g->add(new CSAFEPrim(new Sphere(_sphereMatl,
Vector(data[0],data[1],data[2]),radius), data));
+ // g->add( new
ValuePrimitive<float>(new Sphere(matl,
Vector(data[0],data[1],data[2]),data[_ridx]), data[_cidx]));
+ // g->add(new
Sphere(matl, Vector(data[0], data[1], data[2]), data[_ridx]));
+ }
+#if PRECOMPUTE_GRIDS
+ RecursiveGrid* grid = new RecursiveGrid();
+ //g->preprocess(context);
+ //ParticleGrid* grid = new ParticleGrid(pnrrd, _radius,
_ridx, _cidx);
+ grid->setGroup(g);
+ //grid->preprocess(context);
+ grid->rebuild();
+#endif
+#endif //USE_GRIDSPHERES
+
group->add(grid);
_sphereGrids.push_back(grid);
+#if PRECOMPUTE_GRIDS
+ _sphereAnimation->push_back(group);
+#else
+ _sphereAnimation->push_back(g);
+#endif //PRECOMPUTE_GRIDS
if (pnrrd->getNVars() > _sphereMins.size())
{
for(size_t j = _sphereMins.size(); j <
pnrrd->getNVars(); j++)
@@ -305,14 +383,20 @@
}
for(int j = 0; j < int(_sphereMins.size()); j++)
{
- float min,max;
- grid->getMinMax(j, min, max);
- if (_sphereMins[j] > min)
- _sphereMins[j] = min;
- if (_sphereMaxs[j] < max)
- _sphereMaxs[j] = max;
- }
- _sphereAnimation->push_back(group);
+ float min = _sphereMins[j];
+ float max = _sphereMaxs[j];
+ float* pdata = pnrrd->getParticleData();
+ for(size_t i = 0; i < pnrrd->getNParticles(); i++) {
+ if (pdata[j] < min)
+ min = pdata[j];
+ if (pdata[j] > max)
+ max = pdata[j];
+ pdata += pnrrd->getNVars();
+ }
+ _sphereMins[j] = min;
+ _sphereMaxs[j] = max;
+ }
+ //_sphereAnimation->useAccelerationStructure(grid);
numFrames1++;
//Nrrd *new_nrrd = nrrdNew();
////////////////////////////////////////////////////////////////////////////
@@ -330,8 +414,9 @@
// }
//_nrrds.push_back(new_nrrd);
- cout << "Loading " << *i << " done.\n";
+ cout << "Loading " << *itr << " done.\n";
}
+ // _sphereAnimation->preprocess(context);
updateFrames();
if (_clipFrames && _endFrame < int(_sphereGrids.size()))
_sphereAnimation->clipFrames(_startFrame, _endFrame);
@@ -344,7 +429,7 @@
{
for(vector<string>::iterator i = _nrrdFilenames2.begin(); i !=
_nrrdFilenames2.end(); i++)
{
- cout << "Loading Nrrd file: " << *i << "...\n";
+ cout << "Loading Nrrd file: " << *i << "..." << endl;
Group* group = new Group();
Volume<float>* mat = new
Volume<float>(loadNRRDToGrid<float>(*i), _volCMap, BBox(_minBound,
_maxBound), 0.00125, 3, _forceDataMin, _forceDataMax);
Cube* vol = new Cube(mat, _minBound, _maxBound);
@@ -353,20 +438,6 @@
_vols.push_back(mat);
_volPrims.push_back(vol);
numFrames2++;
- //Nrrd *new_nrrd = nrrdNew();
-
////////////////////////////////////////////////////////////////////////////
- // Attempt to open the nrrd
- //if (nrrdLoad( new_nrrd, i->c_str(), 0 )) {
- // char *reason = biffGetDone( NRRD );
- // std::cout << "WARNING Loading Nrrd Failed: " << reason
<< std::endl;
- // exit(__LINE__);
- // }
-
- // Check to make sure the nrrd is the proper dimensions.
- // if (new_nrrd->dim != 3) {
- // std::cout << "WARNING Nrrd must three dimension RGB" <<
std::endl;
- // exit(__LINE__);
- // }
cout << "Loading " << *i << " done.\n";
}
updateFrames();
@@ -402,8 +473,10 @@
if (cidx >= itr->numSphereVars)
cidx = 0;
CDGridSpheres* grid = new CDGridSpheres(itr->sphereData,
itr->numSpheres, itr->numSphereVars, 6, 2,_radius, ridx, cmap , cidx);
+#if USE_GRIDSPHERES
group->add(grid);
_sphereGrids.push_back(grid);
+#endif
if (itr->numSphereVars > int(_sphereMins.size()))
{
for(int j = int(_sphereMins.size()); j <
itr->numSphereVars; j++)
@@ -657,9 +730,32 @@
\param colormap
*/
void setSphereCMap(RGBAColorMap* map) {
+ #if USE_GRIDSPHERES
for(int i =0; i < int(_sphereGrids.size()); i++)
_sphereGrids[i]->setCMap(map);
- }
+ #else
+ _setCMapHelper = map;
+ _manta_interface->addOneShotCallback(MantaInterface::Relative, 1,
Callback::create(this, &CDTest::setSphereCMapHelper));
+ #endif
+ }
+
+ void updateSphereCMap() {
+ _manta_interface->addOneShotCallback(MantaInterface::Relative, 1,
Callback::create(this, &CDTest::setSphereCMapHelper));
+ }
+
+ //! called by setSphereCMap
+ /*!
+ */
+ void setSphereCMapHelper(int, int)
+ {
+ std::vector<Color> colors;
+ RGBAColorMap* map = _setCMapHelper;
+ for(int i = 0; i < map->GetNumSlices(); i++) {
+ colors.push_back(map->GetSlice(i).color.color);
+ }
+ cout << "setting sphere colors\n";
+ _sphereCMap->setColors(colors);
+ }
//! set minimum and maximum clipping region for a specific index
into spheres
/*!
@@ -671,8 +767,20 @@
{
if (index >= int(_sphereMins.size()))
return;
- for(int i = 0; i < int(_sphereGrids.size()); i++)
+#if USE_SPHEREGRIDS
+ for(int i = 0; i < int(_sphereGrids.size()); i++)
if (_sphereGrids[i]) _sphereGrids[i]->setClipMinMax(index,
min, max);
+#else
+ _sphereDMins[index] = min;
+ _sphereDMaxs[index] = max;
+ for(size_t i = 0; i < _sphereGroups.size(); i++) {
+ for(size_t s = 0; s < _sphereGroups[i]->size(); s++) {
+ CSAFEPrim* prim =
dynamic_cast<CSAFEPrim*>(_sphereGroups[i]->get(s));
+ if (prim)
+ prim->updateOcclusion();
+ }
+ }
+#endif
}
//! set the minimum and maximum data values used for normalizing
color data
@@ -681,12 +789,17 @@
\param min
\param max
*/
- void setSphereCMinMax(int index, float min, float max) //set the
min max for normalizing color data
+ void setSphereColorMinMax(int index, float min, float max) //set
the min max for normalizing color data
{
- if (index >= int(_sphereGrids.size()))
- return;
- for(int i =0; i < int(_sphereGrids.size()); i++)
- _sphereGrids[i]->setCMinMax(index, min, max);
+#if USE_SPHEREGRIDS
+ for(int i =0; i < int(_sphereGrids.size()); i++)
+ _sphereGrids[i]->setCMinMax(index, min, max);
+#else
+ if (!_sphereCMap)
+ return;
+ cout << "setting color min/max to: " << min << " " << max << endl;
+ _sphereCMap->setRange(min, max);
+#endif
}
//! get the min and max being used for normalizing color values
@@ -695,17 +808,39 @@
\param returns min
\param returns max
*/
- void getSphereCMinMax(int index, float& min, float& max)
+ void getSphereColorMinMax(int index, float& min, float& max)
{
+#if USE_SPHEREGRIDS
+ for(int i =0;i<int(_sphereGrids.size());i++)
+ _sphereGrids[i]->getCMinMax(index, min, max);
+#else
+ min = _sphereCMap->getMin();
+ max = _sphereCMap->getMax();
+#endif
+
+ }
+
+ //! get the min and max of spheres
+ /*!
+ \param index into data
+ \param returns min
+ \param returns max
+ */
+ void getSphereDataMinMax(int index, float& min, float& max)
+ {
+#if USE_SPHEREGRIDS
+ for(int i =0;i<int(_sphereGrids.size());i++)
+ _sphereGrids[i]->getCMinMax(index, min, max);
+#else
if(index >= int(_sphereMins.size()))
{
min = -FLT_MAX;
- max = FLT_MAX;
+ max = FLT_MIN;
return;
}
- for(int i =0;i<int(_sphereGrids.size());i++)
- _sphereGrids[i]->getCMinMax(index, min, max);
-
+ min = _sphereMins[index];
+ max = _sphereMaxs[index];
+#endif
}
//! set minimum and maximum data values for volume data, should be
called before loading
@@ -713,7 +848,7 @@
\param min
\param max
*/
- void setVolCMinMax(float min, float max)
+ void setVolColorMinMax(float min, float max)
{
_forceDataMin = min;
_forceDataMax = max;
@@ -724,7 +859,18 @@
\param returns min
\param returns max
*/
- void getVolCMinMax(float& min, float& max)
+ void getVolColorMinMax(float& min, float& max)
+ {
+ min = _forceDataMin;
+ max = _forceDataMax;
+ }
+
+ //! get the min and max data values of the volume
+ /*!
+ \param returns min
+ \param returns max
+ */
+ void getVolDataMinMax(float& min, float& max)
{
min = FLT_MAX;
max = -FLT_MAX;
@@ -768,9 +914,14 @@
\param color index to use
*/
void setCidx(int cidx) {
+#if USE_GRIDSPHERES
+ cout << "2\n";
+ for(int i =0; i < int(_sphereGrids.size()); i++)
+ _sphereGrids[i]->setCidx(cidx);
+#else
+ CSAFEPrim::setCIndex(cidx);
+#endif
_cidx = cidx;
- for(int i =0; i < int(_sphereGrids.size()); i++)
- _sphereGrids[i]->setCidx(cidx);
}
//! get color index
@@ -782,11 +933,14 @@
//! set to use ambient occlusion on spheres
void useAO(bool st)
{
+#if USE_SPHEREGRIDS
+
+ for(int i = 0; i < int(_sphereGrids.size()); i++)
+ _sphereGrids[i]->useAmbientOcclusion(st);
+#endif
if (st == _useAO)
return;
- _useAO = st;
- for(int i = 0; i < int(_sphereGrids.size()); i++)
- _sphereGrids[i]->useAmbientOcclusion(st);
+ _useAO = st;
}
//! set the cutoff distance and number of generated rays
@@ -796,8 +950,10 @@
*/
void setAOVars(float cutoff, int numDirs)
{
+ #if USE_SPHEREGRIDS
for(int i = 0; i < int(_sphereGrids.size()); i++)
_sphereGrids[i]->setAmbientOcclusionVariables(cutoff,
numDirs);
+ #endif
}
protected:
@@ -809,8 +965,10 @@
for (vector<Volume<float>*>::iterator itr = _volsOld.begin();
itr != _volsOld.end(); itr++)
delete *itr;
_volsOld.clear();
- for (vector<CDGridSpheres*>::iterator itr =
_sphereGridsOld.begin(); itr != _sphereGridsOld.end(); itr++)
- delete *itr;
+#if USE_SPHEREGRIDS
+ for (vector<CDGridSpheres*>::iterator itr =
_sphereGridsOld.begin(); itr != _sphereGridsOld.end(); itr++)
+ delete *itr;
+#endif
_sphereGridsOld.clear();
for (vector<ParticleNRRD*>::iterator itr =
_spherePNrrdsOld.begin(); itr != _spherePNrrdsOld.end(); itr++)
delete *itr;
@@ -819,6 +977,8 @@
MantaInterface* _manta_interface;
RGBAColorMap* _volCMap;
+ LinearColormap<float>* _sphereCMap;
+ Material* _sphereMatl;
Vector _minBound;
Vector _maxBound;
float _forceDataMin;
@@ -834,11 +994,12 @@
vector<string> _nrrdFilenames2;
vector<Nrrd*> _nrrds;
vector<ParticleNRRD*> _spherePNrrds;
- vector<CDGridSpheres*> _sphereGrids;
+ vector<GridType*> _sphereGrids;
vector<Volume<float>*> _vols;
vector<ParticleNRRD*> _spherePNrrdsOld;
- vector<CDGridSpheres*> _sphereGridsOld;
+ vector<GridType*> _sphereGridsOld;
vector<Volume<float>*> _volsOld;
+ vector<Group*> _sphereGroups;
vector<float> _sphereMins;
vector<float> _sphereMaxs;
Group* _world;
@@ -847,7 +1008,9 @@
KeyFrameAnimation* _volAnimation;
int _startFrame, _endFrame, _clipFrames;
bool _useAO;
+ RGBAColorMap* _setCMapHelper;
UDAReader uda;
+ float* _sphereDMins, *_sphereDMaxs;
};
#endif
Added: trunk/scenes/csafe/src/CSAFEObject.cc
==============================================================================
--- (empty file)
+++ trunk/scenes/csafe/src/CSAFEObject.cc Mon Sep 8 23:18:21 2008
@@ -0,0 +1,8 @@
+#include "CSAFEObject.h"
+
+using namespace Manta;
+
+int CSAFEPrim::__cindex = 0;
+float* CSAFEPrim::__dmins = NULL;
+float* CSAFEPrim::__dmaxs = NULL;
+int CSAFEPrim::__numIndices = 0;
Added: trunk/scenes/csafe/src/CSAFEObject.h
==============================================================================
--- (empty file)
+++ trunk/scenes/csafe/src/CSAFEObject.h Mon Sep 8 23:18:21 2008
@@ -0,0 +1,73 @@
+#ifndef CSAFE_OBJECT_H
+#define CSAFE_OBJECT_H
+
+#include <Interface/Object.h>
+#include <MantaTypes.h>
+#include <Interface/Context.h>
+#include <Interface/Texture.h>
+#include <Interface/RayPacket.h>
+#include <Core/Color/ColorSpace.h>
+#include <Model/Materials/Volume.h>
+#include <Model/Primitives/ValuePrimitive.h>
+
+namespace Manta
+{
+
+class CSAFEPrim : public ValuePrimitive<float> {
+public:
+ CSAFEPrim(Primitive* object, float* data)
+ : ValuePrimitive<float>(object), _data(data), _isOccluded(-1)
+ {
+ updateOcclusion();
+ }
+ virtual ~CSAFEPrim() {}
+ virtual void intersect(const RenderContext& context, RayPacket& rays) const
+ {
+ if(_isOccluded)
+ return;
+
+ ValuePrimitive<float>::intersect(context, rays);
+ }
+ virtual float getValue() const { return _data[__cindex]; }
+ void updateOcclusion()
+ {
+ _isOccluded = false;
+ float data;
+ for(int i = 0; i <__numIndices; i++) {
+ data = _data[i];
+ if (data < __dmins[i] || data > __dmaxs[i]) {
+ _isOccluded = true;
+ return;
+ }
+ }
+ }
+ /* void makeDirty()
+ {
+ _isOccluded = -1;
+ }*/
+
+ static void init(int numIndices, float* dmins, float* dmaxs, int cindex)
+ {
+ __numIndices = numIndices;
+ __dmins = dmins;
+ __dmaxs = dmaxs;
+ __cindex = cindex;
+ }
+
+
+ static void setNumIndices(int numIndices) { __numIndices = numIndices; }
+ static void setDMins(float* dmins) { __dmins = dmins; }
+ static void setDMaxs(float* dmaxs) {__dmaxs = dmaxs; }
+ static void setCIndex(int cindex) { __cindex = cindex; }
+
+protected:
+ static int __numIndices;
+ float* _data;
+ static float* __dmins, *__dmaxs;
+ static int __cindex;
+ bool _isOccluded;
+};
+
+}
+
+#endif
- [Manta] r2320 - in trunk: Core/Color/Colormaps Model/Readers SwigInterface scenes/csafe scenes/csafe/python scenes/csafe/src, brownlee, 09/08/2008
Archive powered by MHonArc 2.6.16.