Text archives Help
- From: brownlee@sci.utah.edu
- To: manta@sci.utah.edu
- Subject: [Manta] r2056 - in trunk: Model/MiscObjects SwigInterface scenes/csafe/python scenes/csafe/src
- Date: Tue, 12 Feb 2008 21:11:37 -0700 (MST)
Author: brownlee
Date: Tue Feb 12 21:11:36 2008
New Revision: 2056
Modified:
trunk/Model/MiscObjects/KeyFrameAnimation.cc
trunk/Model/MiscObjects/KeyFrameAnimation.h
trunk/SwigInterface/manta.i
trunk/scenes/csafe/python/Configuration.py
trunk/scenes/csafe/python/SceneInfo.py
trunk/scenes/csafe/python/SceneMenus.py
trunk/scenes/csafe/python/csafe_demo.py
trunk/scenes/csafe/src/CDTest.h
Log:
fixed swig compile errors, added more animation controls to csafe demo
Modified: trunk/Model/MiscObjects/KeyFrameAnimation.cc
==============================================================================
--- trunk/Model/MiscObjects/KeyFrameAnimation.cc (original)
+++ trunk/Model/MiscObjects/KeyFrameAnimation.cc Tue Feb 12 21:11:36
2008
@@ -13,7 +13,9 @@
KeyFrameAnimation::KeyFrameAnimation(InterpolationMode interpolation) :
as(NULL), interpolation(interpolation), spareGroup(NULL),
currGroup(NULL), currTime(-1), updateToCurrTime(false),
- paused(false), barrier("keyframe animation barrier"), duration(1)
+ paused(false), barrier("keyframe animation barrier"), duration(1),
+ lockedFrames(false), lastFrame(0), startFrame(0), endFrame(0),
framesClipped(false),
+ loop(true), repeatLastFrame(0.0), repeating(false), forceUpdate(false)
{
}
@@ -31,6 +33,11 @@
as->setGroup(currGroup);
}
frames.push_back(objects);
+ if (!framesClipped)
+ {
+ endFrame = frames.size() - 1;
+ numFrames = frames.size();
+ }
}
void KeyFrameAnimation::setInterpolation(InterpolationMode mode)
@@ -51,7 +58,7 @@
paused = false;
if (spareGroup == NULL && interpolation != truncate && !frames.empty()) {
- spareGroup = frames[0]->clone(shallow);
+ spareGroup = frames[startFrame]->clone(shallow);
currGroup = spareGroup;
if (as)
as->setGroup(currGroup);
@@ -78,45 +85,76 @@
{
if (frames.empty())
return;
- //only one thread can do serial code
if (context.proc == 0) {
- if (updateToCurrTime) {
- updateToCurrTime = false;
- differentFrame = isDifferentFrame(newTime);
- startTime = context.time - newTime;
- currTime = newTime;
- if (paused) {
- pauseTime = startTime;
+ if (forceUpdate)
+ {
+ forceUpdate = false;
+ currGroup = frames[startFrame];
}
+ }
+
+ //only one thread can do serial code
+ if (context.proc == 0) {
+ if (repeating)
+ {
+ if ((context.time - startTime) >= (duration+repeatLastFrame))
+ {
+ repeating = false;
+ updateToCurrTime = true;
+ }
}
- else if (paused) {
- differentFrame = false;
- }
- else {
- float newTime = wrapTime(context.time - startTime);
- differentFrame = isDifferentFrame(newTime);
- currTime = newTime;
- }
- }
-
+ else
+ {
+ if (updateToCurrTime) {
+ updateToCurrTime = false;
+ differentFrame = isDifferentFrame(newTime);
+ startTime = context.time - newTime;
+ currTime = newTime;
+ if (paused) {
+ pauseTime = startTime;
+ }
+ }
+ else if (paused) {
+ differentFrame = false;
+ }
+ else {
+ float newTime = wrapTime(context.time - startTime);
+ differentFrame = isDifferentFrame(newTime);
+ currTime = newTime;
+ }
+ if (!loop && (context.time - startTime) >=duration)
+ {
+ pauseAnimation();
+ }
+ if (loop && repeatLastFrame > 0.0f && (context.time -
startTime) >= duration)
+ {
+ repeating = true;
+ }
+ }
+ }
//need to make sure proc 0 has updated the currTime.
//a barrier is a little heavy for this, but it's cleaner code (and I'm
lazy).
barrier.wait(context.numProcs);
if (differentFrame) {
- float frame = currTime/duration * frames.size();
+ float frame = currTime/duration * numFrames;
+ if (lockedFrames && lastFrame!=frame && (lastFrame+1)%(numFrames) !=
frame)
+ {
+ frame = (lastFrame+1)%(numFrames);
+ }
+ lastFrame = frame;
if (interpolation == linear) {
//do interpolation in parallel
int start = static_cast<int>(frame);
- int end = (start+1) % frames.size();
+ int end = (start+1) % (numFrames);
float t = frame - start;
- assert(frames[start]->size() == frames[end]->size());
+ assert(frames[start+startFrame]->size() ==
frames[end+startFrame]->size());
std::vector<keyframe_t> keyframes(2);
- keyframes[0].keyframe = frames[start];
+ keyframes[0].keyframe = frames[start+startFrame];
keyframes[0].t = 1-t;
- keyframes[1].keyframe = frames[end];
+ keyframes[1].keyframe = frames[end+startFrame];
keyframes[1].t = t;
// NOTE(boulos): This doesn't actually change the group pointer,
@@ -129,7 +167,7 @@
else if (interpolation == truncate) {
// NOTE(boulos): Only proc 0 should change the currGroup pointer
if (context.proc == 0) {
- currGroup = frames[(int) frame];
+ currGroup = frames[(int) frame+startFrame];
// TODO(boulos): Who should check for identical pointers?
if (as)
as->setGroup(currGroup);
@@ -146,6 +184,37 @@
}
}
+//! make sure every frame is shown at least once
+void KeyFrameAnimation::lockFrames(bool st)
+{
+ lockedFrames = st;
+}
+
+void KeyFrameAnimation::clipFrames(int start, int end)
+{
+ if (start < 0 || end >= int(frames.size()) || end < start)
+ {
+ cerr << "clipFrames out of bounds\n";
+ return;
+ }
+ startFrame = start;
+ endFrame = end;
+ numFrames = end - start + 1;
+ framesClipped = true;
+ forceUpdate = true;
+}
+
+void KeyFrameAnimation::repeatLastFrameForSeconds(float time)
+{
+ assert(time >= 0.0f);
+ repeatLastFrame = time;
+}
+
+void KeyFrameAnimation::loopAnimation(bool st)
+{
+ loop = st;
+}
+
float KeyFrameAnimation::wrapTime(float time) const
{
//TODO: add other wrapping modes.
@@ -186,8 +255,8 @@
return time != currTime;
if (interpolation == truncate) {
- int i = static_cast<int>(time/duration * frames.size());
- int j = static_cast<int>(currTime/duration * frames.size());
+ int i = static_cast<int>(time/duration * numFrames);
+ int j = static_cast<int>(currTime/duration * numFrames);
return i != j;
}
Modified: trunk/Model/MiscObjects/KeyFrameAnimation.h
==============================================================================
--- trunk/Model/MiscObjects/KeyFrameAnimation.h (original)
+++ trunk/Model/MiscObjects/KeyFrameAnimation.h Tue Feb 12 21:11:36 2008
@@ -30,6 +30,13 @@
void temporaryUpdate(int proc, int numProcs, bool &); //this will be
replaced by update
void update(Temp_Callback context);
+ //! make sure every frame is shown at least once
+ void lockFrames(bool st);
+ //! clip animation to loop from start to end
+ void clipFrames(int start, int end);
+ void repeatLastFrameForSeconds(float time);
+ void loopAnimation(bool st);
+
//set animation to a specific time (frame)
//returns whether the frame is different from the previous frame.
bool setTime(float time);
@@ -86,6 +93,17 @@
vector<Group*> frames;
float duration; //how many seconds long
+
+ bool lockedFrames; // make sure that no frames are skipped when setting
time, each frame will be shown at least once
+ int lastFrame;
+ int startFrame;
+ int endFrame;
+ int numFrames;
+ bool framesClipped;
+ bool loop;
+ float repeatLastFrame; //this will repeat the last frame for the given
number of seconds (on top of the duration)
+ bool repeating;
+ bool forceUpdate;
};
}
#endif
Modified: trunk/SwigInterface/manta.i
==============================================================================
--- trunk/SwigInterface/manta.i (original)
+++ trunk/SwigInterface/manta.i Tue Feb 12 21:11:36 2008
@@ -288,6 +288,15 @@
%ignore Manta::DynBVH::firstIntersects;
%ignore Manta::DynBVH::finishUpdate;
%ignore Manta::DynBVH::parallelTopDownUpdate;
+%ignore Manta::DynBVH::beginParallelBuild;
+%ignore Manta::DynBVH::beginParallelUpdate;
+%ignore Manta::DynBVH::parallelTopDownBuild;
+%ignore Manta::DynBVH::parallelApproximateSAH;
+%ignore Manta::DynBVH::parallelComputeBounds;
+%ignore Manta::DynBVH::parallelComputeBoundsReduction;
+%ignore Manta::DynBVH::parallelComputeBins;
+%ignore Manta::DynBVH::parallelComputeBinsReduction;
+%ignore Manta::DynBVH::splitBuild;
%include <Model/Groups/KDTree.h>
%include <Model/Groups/DynBVH.h>
Modified: trunk/scenes/csafe/python/Configuration.py
==============================================================================
--- trunk/scenes/csafe/python/Configuration.py (original)
+++ trunk/scenes/csafe/python/Configuration.py Tue Feb 12 21:11:36 2008
@@ -94,9 +94,9 @@
i +=1
name = lines[i].strip()
i += 1
- index = int(lines[i].strip())
+ index = int(float(lines[i].strip()))
i += 1
- group = int(lines[i].strip())
+ group = int(float(lines[i].strip()))
i += 1
zoomInto = lines[i].split()
zoomIntoMin = float(zoomInto[0])
@@ -133,25 +133,25 @@
scene.duration = float(lines[i].strip())
scene.test.setDuration(scene.duration)
i+=1
- scene.ridx = int(lines[i].strip())
+ scene.ridx = int(float(lines[i].strip()))
scene.test.setRidx(scene.ridx)
i+=1
scene.radius = float(lines[i].strip())
scene.test.setRadius(scene.radius)
i+=1
- scene.cidx = int(lines[i].strip())
+ scene.cidx = int(float(lines[i].strip()))
scene.test.setCidx(scene.cidx)
i+=1
- scene.numThreads = int(lines[i].strip())
+ scene.numThreads = int(float(lines[i].strip()))
scene.engine.changeNumWorkers(scene.numThreads)
print "setting numWorkers to: " +
str(scene.numThreads)
i+=1
- numVol = int(lines[i].strip())
+ numVol = int(float(lines[i].strip()))
for j in range(numVol):
i+=1
scene.nrrdFiles2.append(lines[i].strip())
i+=1
- numSphere = int(lines[i].strip())
+ numSphere = int(float(lines[i].strip()))
for j in range(numSphere):
i+=1
scene.nrrdFiles.append(lines[i].strip())
Modified: trunk/scenes/csafe/python/SceneInfo.py
==============================================================================
--- trunk/scenes/csafe/python/SceneInfo.py (original)
+++ trunk/scenes/csafe/python/SceneInfo.py Tue Feb 12 21:11:36 2008
@@ -16,3 +16,8 @@
self.sceneWD = "/"
self.histogramBMPLoaded = False
self.bgColor = wx.Colour(90,90,90)
+ self.startFrame = self.endFrame = 0
+ self.clipFrames = False #true if start/end are set
+ self.lockFrames = False
+ self.loop = True
+ self.repeatLastFrame = 0.0
Modified: trunk/scenes/csafe/python/SceneMenus.py
==============================================================================
--- trunk/scenes/csafe/python/SceneMenus.py (original)
+++ trunk/scenes/csafe/python/SceneMenus.py Tue Feb 12 21:11:36 2008
@@ -166,6 +166,40 @@
hSizer2.Add(self.frameButton, 0, wx.ALL, 3)
hSizer2.Add(self.frameTcl, 0, wx.ALL, 3)
sizer.Add(hSizer2, 0, wx.ALL|wx.ALIGN_CENTER, 5)
+
+ self.frameText2 = wx.StaticText(panel,-1, "Go to frame: ")
+ self.frameButton2 = wx.Button(panel, -1,"Set")
+ self.frameTcl2 = wx.TextCtrl(panel, -1, "", size=(125, -1))
+ hSizer8 = wx.BoxSizer(wx.HORIZONTAL)
+ hSizer8.Add(self.frameText2, 0, wx.ALL, 3)
+ hSizer8.Add(self.frameButton2, 0, wx.ALL, 3)
+ hSizer8.Add(self.frameTcl2, 0, wx.ALL, 3)
+ sizer.Add(hSizer8, 0, wx.ALL|wx.ALIGN_CENTER, 5)
+
+ if scene.clipFrames == False:
+ scene.endFrame = len(scene.nrrdFiles) -1
+ if len(scene.nrrdFiles2) > len(scene.nrrdFiles):
+ scene.endFrame = len(scene.nrrdFiles2)-1
+ if scene.endFrame < 0:
+ scene.endFrame = 0
+ self.frameText3 = wx.StaticText(panel,-1, "Start/End frames: ")
+ self.frameButton3 = wx.Button(panel, -1,"Set")
+ self.frameTcl3 = wx.TextCtrl(panel, -1, str(scene.startFrame),
size=(125, -1))
+ self.frameTcl3_2 = wx.TextCtrl(panel, -1, str(scene.endFrame),
size=(125, -1))
+ hSizer9 = wx.BoxSizer(wx.HORIZONTAL)
+ hSizer9.Add(self.frameText3, 0, wx.ALL, 3)
+ hSizer9.Add(self.frameButton3, 0, wx.ALL, 3)
+ hSizer9.Add(self.frameTcl3, 0, wx.ALL, 3)
+ hSizer9.Add(self.frameTcl3_2, 0, wx.ALL, 3)
+ sizer.Add(hSizer9, 0, wx.ALL|wx.ALIGN_CENTER, 5)
+
+ self.checkBox = wx.CheckBox(panel, -1, "No skipping timesteps")
+ self.checkBox.SetValue(self.scene.lockFrames)
+ sizer.Add(self.checkBox,0,wx.ALL|wx.ALIGN_CENTER,5)
+
+ self.checkBox2 = wx.CheckBox(panel, -1, "Loop Animation")
+ self.checkBox2.SetValue(self.scene.loop)
+ sizer.Add(self.checkBox2,0,wx.ALL|wx.ALIGN_CENTER,5)
hSizer3 = wx.BoxSizer(wx.HORIZONTAL)
self.durText = wx.StaticText(panel, 0, "Set duration (seconds): ")
@@ -176,6 +210,16 @@
hSizer3.Add(self.durButton, 0, wx.ALL, 3)
hSizer3.Add(self.durTcl, 0, wx.ALL, 3)
sizer.Add(hSizer3, 0 , wx.ALL|wx.ALIGN_CENTER,5 )
+
+ hSizer10 = wx.BoxSizer(wx.HORIZONTAL)
+ self.repeatText = wx.StaticText(panel, 0, "Repeat last frame
(additional to duration) (seconds): ")
+ self.repeatButton = wx.Button(panel,-1, "Set")
+ repeat = self.scene.repeatLastFrame
+ self.repeatTcl = wx.TextCtrl(panel, 0, str(repeat), size=(125, -1))
+ hSizer10.Add(self.repeatText, 0, wx.ALL, 3)
+ hSizer10.Add(self.repeatButton, 0, wx.ALL, 3)
+ hSizer10.Add(self.repeatTcl, 0, wx.ALL, 3)
+ sizer.Add(hSizer10, 0 , wx.ALL|wx.ALIGN_CENTER,5 )
hSizer4 = wx.BoxSizer(wx.HORIZONTAL)
self.ridxText = wx.StaticText(panel, -1, "Radius Index (-1 to use one
radius): ")
@@ -215,7 +259,11 @@
self.okButton = wx.Button(panel, wx.ID_OK)
- sizer.Add(self.okButton, 0, wx.ALL|wx.ALIGN_CENTER, 5)
+ self.cancelButton = wx.Button(panel, wx.ID_CANCEL)
+ hSizer10 = wx.BoxSizer(wx.HORIZONTAL)
+ hSizer10.Add(self.okButton, 0, wx.ALL,3)
+ hSizer10.Add(self.cancelButton, 0, wx.ALL,3)
+ sizer.Add(hSizer10, 0, wx.ALL|wx.ALIGN_CENTER, 5)
panel.SetSizer(sizer)
@@ -225,10 +273,38 @@
self.SetAutoLayout(True)
self.Bind(wx.EVT_BUTTON, self.OnClickTime, self.frameButton)
+ self.Bind(wx.EVT_BUTTON, self.OnClickGoToFrame, self.frameButton2)
+ self.Bind(wx.EVT_BUTTON, self.OnClickClipFrames, self.frameButton3)
self.Bind(wx.EVT_BUTTON, self.OnClickDuration, self.durButton)
+ self.Bind(wx.EVT_BUTTON, self.OnClickRepeatLastFrame,
self.repeatButton)
self.Bind(wx.EVT_BUTTON, self.OnClickOK, self.okButton)
+ self.Bind(wx.EVT_BUTTON, self.OnClickCancel, self.cancelButton)
self.Bind(wx.EVT_CLOSE, self.OnCloseWindow)
self.Bind(wx.EVT_SPIN, self.OnSpinNP, self.npSP)
+ self.Bind(wx.EVT_CHECKBOX, self.OnClickLockFrames, self.checkBox)
+ self.Bind(wx.EVT_CHECKBOX, self.OnClickLoop, self.checkBox2)
+
+ def OnClickRepeatLastFrame(self, evt):
+ self.scene.repeatLastFrame = float(self.repeatTcl.GetValue())
+ self.scene.test.repeatLastFrame(self.scene.repeatLastFrame)
+
+ def OnClickLoop(self, evt):
+ self.scene.loop = evt.IsChecked()
+ self.scene.test.loopAnimations(self.scene.loop)
+
+ def OnClickLockFrames(self, evt):
+ self.scene.lockFrames = evt.IsChecked()
+ self.scene.test.lockFrames(self.scene.lockFrames)
+
+ def OnClickClipFrames(self, evt):
+ self.scene.startFrame = int(self.frameTcl3.GetValue())
+ self.scene.endFrame = int(self.frameTcl3_2.GetValue())
+ self.scene.clipFrames = True
+ self.scene.test.clipFrames(self.scene.startFrame,
self.scene.endFrame)
+
+ def OnClickGoToFrame(self, evt):
+ frame = int(self.frameTcl2.GetValue())
+ self.scene.test.gotoFrame(frame)
def OnSpinNP(self, evt):
self.text.SetValue(str(evt.GetPosition()))
@@ -246,14 +322,14 @@
def OnClickOK(self, evt):
self.ApplySettings()
- self.Close(True)
+ self.Close(True)
def OnClickCancel(self, evt):
self.Close(True)
def OnClickTime(self, evt):
time = float(self.frameTcl.GetValue())
- self.scene.test.gotoFrame(time)
+ self.scene.test.gotoTime(time)
def OnClickDuration(self, evt):
duration = float(self.durTcl.GetValue())
Modified: trunk/scenes/csafe/python/csafe_demo.py
==============================================================================
--- trunk/scenes/csafe/python/csafe_demo.py (original)
+++ trunk/scenes/csafe/python/csafe_demo.py Tue Feb 12 21:11:36 2008
@@ -79,7 +79,7 @@
menuScene = wx.Menu()
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 Properties")
+ menuScene.Append(202, "Scene Preferences")
menuScene.Append(203, "&Generate")
menuBar.Append(menuScene, "Scene")
@@ -173,13 +173,14 @@
################ Scene Properties #################
def Menu202(self, evt):
- frame = SceneMenus.ScenePropertiesFrame(self, -1, "Scene Properties",
self.scene)
+ frame = SceneMenus.ScenePropertiesFrame(self, -1, "Scene
Preferences", self.scene)
frame.Show(True)
################ Generate Scene #################
def Menu203(self, evt):
self.BuildScene()
+ ################ Add Histogram #################
def Menu204(self, evt):
group = 0
name = "untitled"
Modified: trunk/scenes/csafe/src/CDTest.h
==============================================================================
--- trunk/scenes/csafe/src/CDTest.h (original)
+++ trunk/scenes/csafe/src/CDTest.h Tue Feb 12 21:11:36 2008
@@ -238,6 +238,8 @@
cout << "Loading " << *i << " done.\n";
}
updateFrames();
+ if (_clipFrames && _endFrame <
int(_sphereGrids.size()))
+ _sphereAnimation->clipFrames(_startFrame,
_endFrame);
}
//! clear list of volume files
@@ -272,6 +274,8 @@
cout << "Loading " << *i << " done.\n";
}
updateFrames();
+ if (_clipFrames && _endFrame < int(_vols.size()))
+ _volAnimation->clipFrames(_startFrame,
_endFrame);
}
//! update the frame cieling
@@ -296,14 +300,35 @@
/*!
\param time to go to
*/
- void gotoFrame(float time) { _sphereAnimation->setTime(time);
_volAnimation->setTime(time); }
+ void gotoTime(float time) { _sphereAnimation->setTime(time);
_volAnimation->setTime(time); }
+
+ // 0-based
+ void gotoFrame(int frame) {
+ if (frame < 0 || frame >= numFrames)
+ {
+ cerr << "ERROR: frame: " << frame << " out of
bounds\n";
+ return;
+ }
+ float step;
+ if (numFrames == 0)
+ step = 0;
+ else
+ step = duration/float(numFrames);
+ _sphereAnimation->setTime( step*float(frame) +
0.0001f);
+ _volAnimation->setTime(step*float(frame) + 0.0001f);
+ }
+
+ void lockFrames(bool st) { _sphereAnimation->lockFrames(st);
_volAnimation->lockFrames(st); }
+ void loopAnimations(bool st)
{_sphereAnimation->loopAnimation(st); _volAnimation->loopAnimation(st); }
+ void clipFrames(int start, int end) { _startFrame = start;
_endFrame = end; _clipFrames = true;
+ if (end < numFrames1)
_sphereAnimation->clipFrames(start,end); if (end < numFrames2)
_volAnimation->clipFrames(start,end); }
+ void repeatLastFrame(float time) {
_sphereAnimation->repeatLastFrameForSeconds(time);
_volAnimation->repeatLastFrameForSeconds(time); }
//! skip ahead one frame
/*!
*/
void forwardAnimation()
{
- cout << _sphereAnimation->getTime() << endl;
float step;
if (numFrames == 0)
step = 0;
@@ -591,6 +616,7 @@
Scene* _scene;
KeyFrameAnimation* _sphereAnimation;
KeyFrameAnimation* _volAnimation;
+ int _startFrame, _endFrame, _clipFrames;
};
#endif
- [Manta] r2056 - in trunk: Model/MiscObjects SwigInterface scenes/csafe/python scenes/csafe/src, brownlee, 02/12/2008
Archive powered by MHonArc 2.6.16.