Text archives Help
- From: brownlee@sci.utah.edu
- To: manta@sci.utah.edu
- Subject: [Manta] r2238 - in trunk: Model/MiscObjects Model/Primitives scenes/csafe/python scenes/csafe/src
- Date: Thu, 1 May 2008 19:18:49 -0600 (MDT)
Author: brownlee
Date: Thu May 1 19:18:49 2008
New Revision: 2238
Modified:
trunk/Model/MiscObjects/CuttingPlane.h
trunk/Model/Primitives/Cube.h
trunk/scenes/csafe/python/Configuration.py
trunk/scenes/csafe/python/Histogram.py
trunk/scenes/csafe/python/SceneInfo.py
trunk/scenes/csafe/python/SceneMenus.py
trunk/scenes/csafe/python/csafe_demo.cfg
trunk/scenes/csafe/python/csafe_demo.py
trunk/scenes/csafe/src/CDGridSpheres.cc
trunk/scenes/csafe/src/CDTest.h
Log:
fixed issues with cuttingplane, volume culling
Modified: trunk/Model/MiscObjects/CuttingPlane.h
==============================================================================
--- trunk/Model/MiscObjects/CuttingPlane.h (original)
+++ trunk/Model/MiscObjects/CuttingPlane.h Thu May 1 19:18:49 2008
@@ -1,6 +1,6 @@
#ifndef Manta_Model_CuttingPlane_h
-#define Manta_Model_CuttinPlane_h
+#define Manta_Model_CuttingPlane_h
#include <Core/Geometry/Vector.h>
#include <Core/Geometry/BBox.h>
@@ -14,7 +14,6 @@
namespace Manta {
class CuttingPlane : public Object {
- private:
BBox bounds; // Bounds of the internal object.
Object *internal_object; // Object to be cut.
Modified: trunk/Model/Primitives/Cube.h
==============================================================================
--- trunk/Model/Primitives/Cube.h (original)
+++ trunk/Model/Primitives/Cube.h Thu May 1 19:18:49 2008
@@ -13,7 +13,11 @@
public:
Cube(Material* mat, const Vector& min_, const Vector& max_ );
~Cube();
-
+ void setMinMax(const Vector& p0, const Vector& p1)
+ {
+ bbox[0] = Min(p0, p1);
+ bbox[1] = Max(p0, p1);
+}
virtual void computeBounds(const PreprocessContext& context,
BBox& bbox) const;
virtual void intersect(const RenderContext& context, RayPacket& rays)
const ;
Modified: trunk/scenes/csafe/python/Configuration.py
==============================================================================
--- trunk/scenes/csafe/python/Configuration.py (original)
+++ trunk/scenes/csafe/python/Configuration.py Thu May 1 19:18:49 2008
@@ -155,6 +155,15 @@
for j in range(numSphere):
i+=1
scene.nrrdFiles.append(lines[i].strip())
+ id = len(scene.frame.transferFunctions)
+ scene.frame.transferFunctions.append(TransferF.TransferF(scene.frame,
[], id, "InvRainbowIso", manta_new(RGBAColorMap(0))))
+ scene.frame.transferFunctions.append(TransferF.TransferF(scene.frame,
[], id+1, "InvRainbow", manta_new(RGBAColorMap(1))))
+ scene.frame.transferFunctions.append(TransferF.TransferF(scene.frame,
[], id+2, "Rainbow", manta_new(RGBAColorMap(2))))
+ scene.frame.transferFunctions.append(TransferF.TransferF(scene.frame,
[], id+3, "InvGrayscale", manta_new(RGBAColorMap(3))))
+ scene.frame.transferFunctions.append(TransferF.TransferF(scene.frame,
[], id+4, "InvBlackBody", manta_new(RGBAColorMap(4))))
+ scene.frame.transferFunctions.append(TransferF.TransferF(scene.frame,
[], id+5, "BlackBody", manta_new(RGBAColorMap(5))))
+ scene.frame.transferFunctions.append(TransferF.TransferF(scene.frame,
[], id+6, "GreyScale", manta_new(RGBAColorMap(6))))
+
scene.frame.LayoutWindow()
print "Done reading Configuration file"
@@ -182,4 +191,4 @@
else:
for i in range(len(scene.nrrdFiles)):
f.write(str(scene.nrrdFiles2[i])+"\n")
- f.write(str(scene.nrrdFiles[i])+"\n")
+ a.write(str(scene.nrrdFiles[i])+"\n")
Modified: trunk/scenes/csafe/python/Histogram.py
==============================================================================
--- trunk/scenes/csafe/python/Histogram.py (original)
+++ trunk/scenes/csafe/python/Histogram.py Thu May 1 19:18:49 2008
@@ -384,7 +384,10 @@
self.SetForegroundColour(wx.Colour(255,0,0))
dc.SetPen(wx.Pen(wx.Colour(255,255,255), 1))
dc.SetBrush(wx.Brush(wx.Colour(255,255,255)))
- dc.SetFont(wx.Font(8, wx.FONTFAMILY_DEFAULT, wx.NORMAL,
wx.FONTWEIGHT_BOLD))
+ fontSize = 8
+ if self.scene.biggify == True:
+ fontSize = 12
+ dc.SetFont(wx.Font(fontSize, wx.FONTFAMILY_DEFAULT, wx.NORMAL,
wx.FONTWEIGHT_BOLD))
string = str(round(self.cropDMin, 2))
extent = dc.GetTextExtent(string)
dc.DrawTextPoint(string, (cropMin*self.width - extent[0]/2.0 +
self.paddingW/2.0,self.height))
@@ -394,13 +397,17 @@
#draw min/max text
textHeight = extent[1]
+ ypos = self.height+textHeight-4.0
+ if self.scene.biggify:
+ ypos = self.height + 4.0
string = str(round(self.dMin, 2))
extent = dc.GetTextExtent(string)
- dc.DrawTextPoint(string, (self.paddingW/2.0 -
extent[0]/2.0,self.height + textHeight - 4.0))
+ dc.DrawTextPoint(string, (self.paddingW/2.0 - extent[0]/2.0,ypos))
string = str(round(self.dMax, 2))
extent = dc.GetTextExtent(string)
- dc.DrawTextPoint(string, (self.paddingW/2.0 + self.width -
extent[0]/2.0,self.height + textHeight - 4.0))
-
+ dc.DrawTextPoint(string, (self.paddingW/2.0 + self.width -
extent[0]/2.0,ypos))
+
+
def DrawLines(self, dc):
#dc.BeginDrawing()
@@ -551,7 +558,7 @@
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)
+ 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.Show(True)
def OnClickZoomIn(self, evt):
@@ -631,19 +638,20 @@
class MeasurementsFrame(wx.Frame):
- def __init__(self, parent, ID, title, zoomMin, zoomMax, cropMin,
cropMax, colorMin, colorMax, pos=wx.DefaultPosition, size=wx.DefaultSize,
style=wx.DEFAULT_FRAME_STYLE):
+ def __init__(self, parent, ID, title, zoomMin, zoomMax, cropMin,
cropMax, colorMin, colorMax, group, pos=wx.DefaultPosition,
size=wx.DefaultSize, style=wx.DEFAULT_FRAME_STYLE):
wx.Frame.__init__(self, parent, ID, title, pos, size, style)
self.parent = parent
panel = wx.Panel(self, -1)
vs = wx.BoxSizer( wx.VERTICAL )
gbs = wx.GridBagSizer(5,5)
-
+ self.group = group
self.zoomText = wx.StaticText(self, -1, "Zoom into data values: ",
(20, 10))
self.zoomMinTcl = wx.TextCtrl(self, -1, str(zoomMin), size=(125, -1))
self.zoomMaxTcl = wx.TextCtrl(self, -1, str(zoomMax), size=(125, -1))
- self.cropText = wx.StaticText(self, -1, "Crop displayed data values:
", (20, 10))
- self.cropMinTcl = wx.TextCtrl(self, -1, str(cropMin), size=(125, -1))
- self.cropMaxTcl = wx.TextCtrl(self, -1, str(cropMax), size=(125, -1))
+ if (group == 0): #spheres
+ self.cropText = wx.StaticText(self, -1, "Crop displayed data
values: ", (20, 10))
+ self.cropMinTcl = wx.TextCtrl(self, -1, str(cropMin), size=(125,
-1))
+ self.cropMaxTcl = wx.TextCtrl(self, -1, str(cropMax), size=(125,
-1))
self.colorText = wx.StaticText(self, -1, "Crop color values: ", (20,
10))
self.colorMinTcl = wx.TextCtrl(self, -1, str(colorMin), size=(125,
-1))
self.colorMaxTcl = wx.TextCtrl(self, -1, str(colorMax), size=(125,
-1))
@@ -653,9 +661,10 @@
gbs.Add(self.zoomText, (1,0))
gbs.Add(self.zoomMinTcl, (1,1))
gbs.Add(self.zoomMaxTcl, (1,2))
- gbs.Add(self.cropText, (2,0))
- gbs.Add(self.cropMinTcl, (2,1))
- gbs.Add(self.cropMaxTcl, (2,2))
+ if (group == 0):
+ gbs.Add(self.cropText, (2,0))
+ gbs.Add(self.cropMinTcl, (2,1))
+ gbs.Add(self.cropMaxTcl, (2,2))
gbs.Add(self.colorText, (3,0))
gbs.Add(self.colorMinTcl, (3,1))
gbs.Add(self.colorMaxTcl, (3,2))
@@ -687,8 +696,11 @@
def OnCloseMe(self, event):
zoomMin = self.zoomMinTcl.GetValue()
zoomMax = self.zoomMaxTcl.GetValue()
- cropMin = self.cropMinTcl.GetValue()
- cropMax = self.cropMaxTcl.GetValue()
+ cropMin = 0
+ cropMax = 0
+ if self.group == 0:
+ cropMin = self.cropMinTcl.GetValue()
+ cropMax = self.cropMaxTcl.GetValue()
colorMin = self.colorMinTcl.GetValue()
colorMax = self.colorMaxTcl.GetValue()
#print "zomMin: " + str(zoomMin)
Modified: trunk/scenes/csafe/python/SceneInfo.py
==============================================================================
--- trunk/scenes/csafe/python/SceneInfo.py (original)
+++ trunk/scenes/csafe/python/SceneInfo.py Thu May 1 19:18:49 2008
@@ -27,3 +27,8 @@
self.aoNum = 10
self.showSpheres = True
self.showVolume = True
+ self.biggify = False # make text bigger
+ self.minX = self.minY = self.minZ = -0.1
+ self.maxX = self.maxY = self.maxZ = 0.1
+ self.maxY = 0.2
+
Modified: trunk/scenes/csafe/python/SceneMenus.py
==============================================================================
--- trunk/scenes/csafe/python/SceneMenus.py (original)
+++ trunk/scenes/csafe/python/SceneMenus.py Thu May 1 19:18:49 2008
@@ -7,6 +7,7 @@
from manta import *
from csafe import *
import wx.lib.scrolledpanel as scrolled
+import FloatSpin as FS
class AddRemoveFilesFrame(wx.Frame):
def __init__(self, parent, id, title, scene):
@@ -148,6 +149,57 @@
def OnCloseWindow(self, evt):
self.Destroy()
+class BBoxFrame(wx.Frame):
+ def __init__(self, parent, id, title, scene):
+ wx.Frame.__init__(self, parent, id, title, None, (700, 600))
+ self.scene = scene
+ panel = wx.Panel(self,-1)
+ sizer = wx.BoxSizer(wx.VERTICAL)
+ hSizer = wx.BoxSizer(wx.HORIZONTAL)
+ hSizer.Add(wx.StaticText(self,-1,"minBound: "))
+ self.minXSP = self.addSpinner(self,scene.minX)
+ self.minYSP = self.addSpinner(self,scene.minY)
+ self.minZSP = self.addSpinner(self,scene.minZ)
+ hSizer.Add(self.minXSP,0,wx.ALL,3)
+ hSizer.Add(self.minYSP,0,wx.ALL,3)
+ hSizer.Add(self.minZSP,0,wx.ALL,3)
+ sizer.Add(hSizer, 0, wx.ALL|wx.ALIGN_LEFT, 10)
+
+ hSizer2 = wx.BoxSizer(wx.HORIZONTAL)
+ hSizer2.Add(wx.StaticText(self,-1,"maxBound: "))
+ self.maxXSP = self.addSpinner(self,scene.maxX)
+ self.maxYSP = self.addSpinner(self,scene.maxY)
+ self.maxZSP = self.addSpinner(self,scene.maxZ)
+ hSizer2.Add(self.maxXSP,0,wx.ALL,3)
+ hSizer2.Add(self.maxYSP,0,wx.ALL,3)
+ hSizer2.Add(self.maxZSP,0,wx.ALL,3)
+ sizer.Add(hSizer2,0, wx.ALL|wx.ALIGN_LEFT, 10)
+
+ panel.SetSizer(sizer)
+
+
+
+ def addSpinner(self, where, value, id=wx.ID_ANY):
+ floatspin = FS.FloatSpin(where, id,
+ increment=0.001, value=value,
+ extrastyle=FS.FS_LEFT)
+ floatspin.SetFormat("%g")
+ floatspin.SetDigits(6)
+ floatspin.Bind(FS.EVT_FLOATSPIN, self.OnFloatSpin)
+ return floatspin
+
+ def OnFloatSpin(self, event):
+ self.scene.minX = self.minXSP.GetValue()
+ self.scene.minY = self.minYSP.GetValue()
+ self.scene.minZ = self.minZSP.GetValue()
+ self.scene.maxX = self.maxXSP.GetValue()
+ self.scene.maxY = self.maxYSP.GetValue()
+ self.scene.maxZ = self.maxZSP.GetValue()
+ min = manta_new(Vector(float(self.scene.minX),
float(self.scene.minY), float(self.scene.minZ)))
+ max = manta_new(Vector(float(self.scene.maxX),
float(self.scene.maxY), float(self.scene.maxZ)))
+ self.scene.test.setClippingBBox(min, max)
+ self.scene.test.useClippingBBox(True)
+
@@ -222,6 +274,12 @@
hSizer10.Add(self.repeatTcl, 0, wx.ALL, 3)
sizer.Add(hSizer10, 0 , wx.ALL|wx.ALIGN_CENTER,5 )
+ self.biggifyCB = wx.CheckBox(panel, -1, "Make text bigger")
+ self.biggifyCB.SetValue(self.scene.biggify)
+ sizer.Add(self.biggifyCB,0,wx.ALL|wx.ALIGN_CENTER,5)
+
+ self.Bind(wx.EVT_CHECKBOX, self.OnClickBigger, self.biggifyCB)
+
self.showSpheresCB = wx.CheckBox(panel, -1, "Show Sphere Data")
self.showSpheresCB.SetValue(self.scene.showSpheres)
sizer.Add(self.showSpheresCB,0,wx.ALL|wx.ALIGN_CENTER,5)
@@ -230,6 +288,9 @@
self.showVolumeCB.SetValue(self.scene.showVolume)
sizer.Add(self.showVolumeCB,0,wx.ALL|wx.ALIGN_CENTER,5)
+ self.Bind(wx.EVT_CHECKBOX, self.OnClickShowSpheres,
self.showSpheresCB)
+ self.Bind(wx.EVT_CHECKBOX, self.OnClickShowVolume, self.showVolumeCB)
+
hSizer4 = wx.BoxSizer(wx.HORIZONTAL)
self.ridxText = wx.StaticText(panel, -1, "Radius Index (-1 to use one
radius): ")
self.ridxTcl = wx.TextCtrl(panel,-1,str(scene.ridx),size=(125,-1))
@@ -294,7 +355,19 @@
self.Bind(wx.EVT_CHECKBOX, self.OnClickLockFrames, self.checkBox)
self.Bind(wx.EVT_CHECKBOX, self.OnClickLoop, self.checkBox2)
self.Bind(wx.EVT_CHECKBOX, self.OnClickAO, self.aoCB)
-
+
+ def OnClickBigger(self, evt):
+ self.scene.biggify = evt.IsChecked()
+ self.scene.frame.LayoutWindow()
+
+ def OnClickShowSpheres(self, evt):
+ self.scene.showSpheres = evt.IsChecked()
+ self.scene.test.setVisibility(self.scene.showSpheres,
self.scene.showVolume)
+
+ def OnClickShowVolume(self, evt):
+ self.scene.showVolume = evt.IsChecked()
+ self.scene.test.setVisibility(self.scene.showSpheres,
self.scene.showVolume)
+
def OnClickAO(self, evt):
self.scene.test.useAO(evt.IsChecked())
self.scene.useAO = evt.IsChecked()
Modified: trunk/scenes/csafe/python/csafe_demo.cfg
==============================================================================
--- trunk/scenes/csafe/python/csafe_demo.cfg (original)
+++ trunk/scenes/csafe/python/csafe_demo.cfg Thu May 1 19:18:49 2008
@@ -14,7 +14,7 @@
0.790000021458 1.0 0.89411765337 0.313725501299 0.389999985695
0.850000023842 1.0 0.96862745285 0.470588237047 0.430000007153
0.920000016689 1.0 1.0 0.705882370472 0.469999998808
-1.0 1.0 1.0 1.0 0.5
+1.0 1.0 1.0 1.0 0.0
[Transfer Function]
@@ -193,9 +193,9 @@
x
0
0
--0.0613283030689 0.0587040632963
--0.0613283030689 0.0587040632963
--0.0612165068462 0.0576155358553
+4.07959487347e-06 0.0587819218636
+4.07959487347e-06 0.0587819218636
+0.0 0.0587778422687
1
@@ -203,9 +203,9 @@
y
1
0
-3.517361165e-06 0.0709128901362
-3.517361165e-06 0.0709128901362
-0.0 0.0709093727751
+-0.0613283030689 0.0587040632963
+-0.0613283030689 0.0587040632963
+-0.0612165068462 0.0576155358553
2
@@ -213,9 +213,9 @@
z
2
0
-3.00736237129e-12 9.78749994829e-07
-3.00736237129e-12 9.78749994829e-07
--4.89373493733e-07 1.4681204812e-06
+3.517361165e-06 0.0709128901362
+3.517361165e-06 0.0709128901362
+0.0 0.0709093727751
3
@@ -223,9 +223,9 @@
p.mass
3
0
-17.9502124786 5116.43701172
-17.9502124786 5116.43701172
-0.0 5098.48679924
+3.00736237129e-12 9.78749994829e-07
+3.00736237129e-12 9.78749994829e-07
+0.0 9.78746987466e-07
4
@@ -233,9 +233,9 @@
p.temperature
4
0
--23199981568.0 13832486912.0
--23199981568.0 13832486912.0
--22960130457.6 13702013337.6
+17.9502124786 5116.43701172
+17.9502124786 5116.43701172
+0.0 5098.48679924
5
@@ -243,9 +243,9 @@
p.stress Trace/3
5
0
-2.95434688269e-06 0.000362312624929
-2.95434688269e-06 0.000362312624929
-0.0 0.000359358278047
+-23199981568.0 13832486912.0
+-23199981568.0 13832486912.0
+-22960130457.6 13702013337.6
6
@@ -253,9 +253,9 @@
Radius from p.volume
6
0
-0.0 1.0
-0.0 1.0
-0.0 1.0
+2.95434688269e-06 0.000362312624929
+2.95434688269e-06 0.000362312624929
+0.0 0.000359358278047
8
@@ -263,9 +263,9 @@
Material Index
7
0
--3.40282346639e+38 3.40282346639e+38
--3.40282346639e+38 3.40282346639e+38
--3.40282346639e+38 3.40282346639e+38
+0.0 1.0
+0.0 1.0
+0.0 1.0
9
Modified: trunk/scenes/csafe/python/csafe_demo.py
==============================================================================
--- trunk/scenes/csafe/python/csafe_demo.py (original)
+++ trunk/scenes/csafe/python/csafe_demo.py Thu May 1 19:18:49 2008
@@ -85,6 +85,7 @@
menuScene.Append(201, "&Add/Remove Files", "Add and remove Nrrd
files to the scene")
menuScene.Append(204, "Add &Histogram", "Add a histogram to the
panel")
menuScene.Append(202, "Scene Preferences")
+ menuScene.Append(205, "Cutting Bounding Box")
menuScene.Append(203, "&Generate")
menuBar.Append(menuScene, "Scene")
@@ -106,14 +107,16 @@
self.Bind(wx.EVT_MENU, self.Menu203, id=203)
self.Bind(wx.EVT_MENU, self.Menu204, id=204)
self.Bind(wx.EVT_MENU, self.Menu110, id=110)
+ self.Bind(wx.EVT_MENU, self.Menu205, id=205)
self.SetBackgroundColour(self.scene.bgColor)
+ def Menu205(self, evt):
+ frame = SceneMenus.BBoxFrame(self, -1, "Bounding Box", self.scene)
+ frame.Show(True)
+
def Menu110(self, evt):
self.SetFocus()
- dlg = wx.FileDialog(self, message="Open UDA folder",
- defaultDir=os.getcwd(),
- defaultFile="",
- wildcard="*",
+ dlg = wx.DirDialog(self, message="Open UDA folder",
style=wx.OPEN|wx.CHANGE_DIR)
if dlg.ShowModal() == wx.ID_OK:
filename = dlg.GetPath()
@@ -122,7 +125,36 @@
if dlg2.ShowModal() == wx.ID_OK:
volName = dlg2.GetValue()
self.scene.test.loadUDA(filename, volName)
- self.BuildScene()
+ t0 = TransferF.TransferF(self, [], 1, "x")
+ dataMin = -1.1
+ dataMax = 2.2
+ min = SWIGIFYCreateDouble(0)
+ max = SWIGIFYCreateDouble(100)
+ dataMin = SWIGIFYGetDouble(min)
+ dataMax = SWIGIFYGetDouble(max)
+ histValues1 = []
+ histValues2 = []
+ histValues3 = []
+ for i in range(0,100):
+ histValues1.append(5)
+ histValues2.append(5)
+ histValues3.append(5)
+ histoGroup0 =
Histogram.HistogramGroup(self.scene.frame.panel, histValues1, dataMin,
dataMax, 300, 40.0, self.scene.frame.transferFunctions[1], self.scene.tPanel,
self.scene, 0, "x")
+ self.scene.frame.histoGroups.append(histoGroup0)
+ histoGroup1 =
Histogram.HistogramGroup(self.scene.frame.panel, histValues2, dataMin,
dataMax, 300, 40.0, self.scene.frame.transferFunctions[2], self.scene.tPanel,
self.scene, 1, "y")
+ self.scene.frame.histoGroups.append(histoGroup1)
+ histoGroup2 =
Histogram.HistogramGroup(self.scene.frame.panel, histValues3, dataMin,
dataMax, 300, 40.0, self.scene.frame.transferFunctions[3], self.scene.tPanel,
self.scene, 2, "z")
+ self.scene.frame.histoGroups.append(histoGroup2)
+ histoGroup0.group = 0
+ histoGroup1.group = 1
+ histoGroup2.group = 2
+ histoGroup0.SetBackgroundColour(self.scene.bgColor)
+ histoGroup1.SetBackgroundColour(self.scene.bgColor)
+ histoGroup2.SetBackgroundColour(self.scene.bgColor)
+
+ self.scene.frame.LayoutWindow()
+ self.BuildHistograms()
+ self.slider.SetRange(1, 1)
self.scene.mantaFrame.StartEngine()
def Menu101(self, evt):
Modified: trunk/scenes/csafe/src/CDGridSpheres.cc
==============================================================================
--- trunk/scenes/csafe/src/CDGridSpheres.cc (original)
+++ trunk/scenes/csafe/src/CDGridSpheres.cc Thu May 1 19:18:49 2008
@@ -625,7 +625,7 @@
Color result;
for (int j=0;j<Color::NumComponents; ++j)
result[j]=totalLight[j][i]*diffuse.colordata[j][i];
- rays.setColor(i, result*rays.getColor(i));
+ rays.setColor(i, result+rays.getColor(i));
}
}
else
@@ -1068,7 +1068,7 @@
int particle=rays.scratchpad<int>(i);
float value=*(spheres + particle + cidx);
float minimum=cmin[cidx];
- float normalized=(value - minimum)/(cmax[cidx] - minimum);
+ float normalized=(value-minimum)/(cmax[cidx] - minimum);
//int ncolors=cmap->blended.size() - 1;
//int
idx=SCIRun::Clamp(static_cast<int>(ncolors*normalized), 0, ncolors);
//diffuse.set(i, cmap->blended[idx]);
Modified: trunk/scenes/csafe/src/CDTest.h
==============================================================================
--- trunk/scenes/csafe/src/CDTest.h (original)
+++ trunk/scenes/csafe/src/CDTest.h Thu May 1 19:18:49 2008
@@ -40,6 +40,7 @@
#include <teem/nrrd.h>
#include <Model/Readers/VolumeNRRD.h>
#include <Model/Readers/UDAReader.h>
+#include <Model/MiscObjects/CuttingPlane.h>
#include <vector>
#include <string>
@@ -77,6 +78,8 @@
_forceDataMin = -FLT_MAX;
_forceDataMax = -FLT_MAX;
_useAO = false;
+ _spheresVisible = true;
+ _volVisible = true;
}
//! sets the scene object, necessary for initializing scene
and loading spheres/volume
@@ -145,8 +148,88 @@
_volCMap = new RGBAColorMap(slices, 64);
}
-
- }
+ //Group* cutWorld = new Group();
+ //cutWorld->add(new CuttingPlane(Vector(0,0,0),
Vector(0,1,0), _world));
+ //_scene->setObject(cutWorld);
+ _sphereAnimationCut = new Group();
+ _cuts[0] = new CuttingPlane(Vector(0,1,0),
Vector(0,1,0), _sphereAnimation);
+ _cuts[1] = new CuttingPlane(Vector(0,0,0),
Vector(0,-1,0), _cuts[0]);
+ _cuts[2] = new CuttingPlane(Vector(0,0,0),
Vector(-1,0,0), _cuts[1]);
+ _cuts[3] = new CuttingPlane(Vector(0,0,0),
Vector(1,0,0), _cuts[2]);
+ _cuts[4] = new CuttingPlane(Vector(0,0,0),
Vector(0,0,1), _cuts[3]);
+ _cuts[5] = new CuttingPlane(Vector(0,0,0),
Vector(0,0,-1), _cuts[4]);
+ _sphereAnimationCut->add(_cuts[0]);
+ }
+ Group* _sphereAnimationCut;
+ CuttingPlane* _cuts[6]; //up down left right forward back
+ bool _useClippingBBox, _spheresVisible, _volVisible;
+ void setClippingBBox(Vector min, Vector max)
+ {
+ cout << "clipping min max: " << min[0] << " " << min[1]
<< " " << min[2]
+ << "\n" << max[0] << " " << max[1] << " " << max[2]
<< endl;
+ /*_cuts[0]->setPlanePoint(max);
+ _cuts[1]->setPlanePoint(min);
+ _cuts[2]->setPlanePoint(min);
+ _cuts[3]->setPlanePoint(max);
+ _cuts[4]->setPlanePoint(max);
+ _cuts[5]->setPlanePoint(min);
+ LightSet* lights = _scene->getLights();
+ PreprocessContext context(_manta_interface, 0, 1,
lights);
+ for(int i = 0; i < 6; i++)
+ {
+ _sphereAnimation->computeBounds(context,
_cuts[i]->bounds);
+ }*/
+ for(int i =0; i < 3; i++)
+ setClipMinMax(i, min[i], max[i]);
+ Vector minB(_minBound);
+ Vector maxB(_maxBound);
+ for(int i=0;i<3;i++)
+ {
+ minB[i] = std::max(min[i], minB[i]);
+ maxB[i] = std::min(max[i], maxB[i]);
+ }
+ for(int i = 0; i < int(_volPrims.size()); i++)
+ {
+ _volPrims[i]->setMinMax(minB, maxB);
+ }
+ }
+ void useClippingBBox(bool st)
+ {
+ /* _useClippingBBox = st;
+ if (st == true)
+ {
+ _world = new Group();
+ if (_volVisible)
+ _world->add(_volAnimation);
+ if (_spheresVisible)
+ _world->add(_sphereAnimationCut);
+ _scene->setObject(_world);
+ }
+ else
+ {
+ _world = new Group();
+ if (_volVisible)
+ _world->add(_volAnimation);
+ if (_spheresVisible)
+ _world->add(_sphereAnimation);
+ }*/
+ }
+ void setVisibility(bool spheres, bool volume)
+ {
+ _spheresVisible = spheres;
+ _volVisible = volume;
+ _world = new Group();
+ if (spheres)
+ {
+ if(_useClippingBBox)
+ _world->add(_sphereAnimationCut);
+ else
+ _world->add(_sphereAnimation);
+ }
+ if (volume)
+ _world->add(_volAnimation);
+ _scene->setObject(_world);
+ }
//! add a sphere file to be loaded
/*!
@@ -252,7 +335,7 @@
if (_clipFrames && _endFrame <
int(_sphereGrids.size()))
_sphereAnimation->clipFrames(_startFrame,
_endFrame);
}
-
+ vector<Cube*> _volPrims;
//! clear list of volume files
/*!
*/
@@ -263,10 +346,11 @@
cout << "Loading Nrrd file: " << *i <<
"...\n";
Group* group = new Group();
Volume<float>* mat = new
Volume<float>(loadNRRDToGrid<float>(*i), _volCMap, _minBound, _maxBound,
0.00125, 10, 3, _forceDataMin, _forceDataMax);
- Primitive* vol = new Cube(mat, _minBound -
Vector(0.001, 0.001, 0.001), _maxBound + Vector(0.001, 0.001, 0.001));
+ Cube* vol = new Cube(mat, _minBound -
Vector(0.001, 0.001, 0.001), _maxBound + Vector(0.001, 0.001, 0.001));
group->add(vol);
_volAnimation->push_back(group);
_vols.push_back(mat);
+ _volPrims.push_back(vol);
numFrames2++;
//Nrrd *new_nrrd = nrrdNew();
////////////////////////////////////////////////////////////////////////////
@@ -297,14 +381,23 @@
uda.readUDA(file, volName);
for (std::vector<UDAReader::Timestep>::iterator itr =
uda.timesteps.begin(); itr != uda.timesteps.end(); itr++)
{
+ float* sdata = itr->sphereData;
+ for (int i = 0; i < 100; i++)
+ cout << "sphere data: " << sdata[i] << endl;
Group* group = new Group();
RGBAColorMap* cmap = new RGBAColorMap(1);
- CDGridSpheres* grid = new
CDGridSpheres(itr->sphereData, itr->numSpheres, itr->numSphereVars, 6,
2,_radius, _ridx, cmap , _cidx);
+ int ridx = _ridx;
+ if (ridx >= itr->numSphereVars)
+ ridx = -1;
+ int cidx = _cidx;
+ if (cidx >= itr->numSphereVars)
+ cidx = 0;
+ CDGridSpheres* grid = new
CDGridSpheres(itr->sphereData, itr->numSpheres, itr->numSphereVars, 6,
2,_radius, ridx, cmap , cidx);
group->add(grid);
_sphereGrids.push_back(grid);
- if (itr->numSphereVars > _sphereMins.size())
+ if (itr->numSphereVars >
int(_sphereMins.size()))
{
- for(size_t j = _sphereMins.size(); j
< itr->numSphereVars; j++)
+ for(int j = int(_sphereMins.size());
j < itr->numSphereVars; j++)
{
_sphereMins.push_back(FLT_MAX);
_sphereMaxs.push_back(-FLT_MAX);
@@ -325,7 +418,7 @@
Group* group2 = new Group();
Volume<float>* mat = new
Volume<float>(itr->volume, _volCMap, _minBound, _maxBound, 0.00125, 10, 3,
_forceDataMin, _forceDataMax);
Primitive* vol = new Cube(mat, _minBound -
Vector(0.001, 0.001, 0.001), _maxBound + Vector(0.001, 0.001, 0.001));
- group->add(vol);
+ group2->add(vol);
_volAnimation->push_back(group2);
_vols.push_back(mat);
numFrames2++;
@@ -581,7 +674,7 @@
*/
void setSphereCMinMax(int index, float min, float max)
//set the min max for normalizing color data
{
- if (index >= int(_sphereMins.size()))
+ if (index >= int(_sphereGrids.size()))
return;
for(int i =0; i < int(_sphereGrids.size()); i++)
_sphereGrids[i]->setCMinMax(index, min, max);
- [Manta] r2238 - in trunk: Model/MiscObjects Model/Primitives scenes/csafe/python scenes/csafe/src, brownlee, 05/01/2008
Archive powered by MHonArc 2.6.16.