Text archives Help
- From: thiago@sci.utah.edu
- To: manta@sci.utah.edu
- Subject: [Manta] r1684 - in trunk: Interface Model/Groups Model/MiscObjects Model/Primitives
- Date: Tue, 28 Aug 2007 15:59:17 -0600 (MDT)
Author: thiago
Date: Tue Aug 28 15:59:17 2007
New Revision: 1684
Added:
trunk/Interface/MeshTriangle.h
Modified:
trunk/Model/Groups/Mesh.cc
trunk/Model/MiscObjects/KeyFrameAnimation.cc
trunk/Model/Primitives/WaldTriangle.h
Log:
Interface/MeshTriangle.h
Model/Groups/Mesh.cc
Model/Primitives/WaldTriangle.h :
Added an interface that triangles are required to provide in order
to be used in a Mesh.
Model/MiscObjects/KeyFrameAnimation.cc: The last change left animations
brokens (seg fault). This should fix it so that it once again works.
Added: trunk/Interface/MeshTriangle.h
==============================================================================
--- (empty file)
+++ trunk/Interface/MeshTriangle.h Tue Aug 28 15:59:17 2007
@@ -0,0 +1,17 @@
+#ifndef Manta_Interface_MeshTriangle_h
+#define Manta_Interface_MeshTriangle_h
+
+#include <Interface/Primitive.h>
+
+namespace Manta {
+
+ class Mesh;
+
+ class MeshTriangle : public Primitive {
+ public:
+
+ virtual void attachMesh(Mesh *mesh) = 0;
+ virtual void attachMesh(Mesh *mesh, unsigned int id) = 0;
+ };
+}
+#endif //Manta_Interface_MeshTriangle_h
Modified: trunk/Model/Groups/Mesh.cc
==============================================================================
--- trunk/Model/Groups/Mesh.cc (original)
+++ trunk/Model/Groups/Mesh.cc Tue Aug 28 15:59:17 2007
@@ -1,5 +1,5 @@
#include <Model/Groups/Mesh.h>
-#include <Model/Primitives/WaldTriangle.h>
+#include <Interface/MeshTriangle.h>
#include <Core/Util/Preprocessor.h>
#include <SCIRun/Core/Exceptions/InternalError.h>
@@ -21,13 +21,8 @@
Group::clone(depth, copy);
- //If we end up having more than just a WaldTriangle as the types of
- //triangles that can come from a mesh, then the correct thing to do
- //is create an interface that mesh triangles inherent from that
- //requires attachMesh to be implemented. Then we can cast to that
- //interface instead of the specific WaldTriangle.
for (unsigned int i=0; i < objs.size(); ++i) {
- static_cast<WaldTriangle*>(copy->objs[i])->attachMesh(copy);
+ static_cast<MeshTriangle*>(copy->objs[i])->attachMesh(copy);
}
copy->vertices = vertices;
@@ -146,11 +141,9 @@
void Mesh::addTriangle(Object *tri)
{
- //TODO: change this function from taking an Object to taking an
- //interface of type MeshTriangle.
- WaldTriangle *waldtri = static_cast<WaldTriangle*>(tri);
- waldtri->attachMesh(this, objs.size());
- objs.push_back(waldtri);
+ MeshTriangle *meshTri = static_cast<MeshTriangle*>(tri);
+ meshTri->attachMesh(this, objs.size());
+ objs.push_back(meshTri);
}
@@ -284,7 +277,7 @@
face_material[tri_index] = face_material.back();
face_material.pop_back();
- WaldTriangle* tri = static_cast<WaldTriangle*>(objs[tri_index]);
+ MeshTriangle* tri = static_cast<MeshTriangle*>(objs[tri_index]);
tri->attachMesh(this, tri_index);
shrinkTo(size()-1, false); //note this might cause a memory leak.
Modified: trunk/Model/MiscObjects/KeyFrameAnimation.cc
==============================================================================
--- trunk/Model/MiscObjects/KeyFrameAnimation.cc (original)
+++ trunk/Model/MiscObjects/KeyFrameAnimation.cc Tue Aug 28 15:59:17
2007
@@ -26,6 +26,8 @@
if (spareGroup == NULL && interpolation != truncate) {
spareGroup = objects->clone(shallow);
currGroup = spareGroup;
+ if (as)
+ as->setGroup(currGroup);
}
frames.push_back(objects);
}
@@ -36,6 +38,8 @@
if (spareGroup == NULL && !frames.empty())
spareGroup = frames[0]->clone(shallow);
currGroup = spareGroup;
+ if (as)
+ as->setGroup(currGroup);
}
interpolation = mode;
}
@@ -48,6 +52,8 @@
if (spareGroup == NULL && interpolation != truncate && !frames.empty()) {
spareGroup = frames[0]->clone(shallow);
currGroup = spareGroup;
+ if (as)
+ as->setGroup(currGroup);
}
setTime(0);
@@ -69,7 +75,7 @@
void KeyFrameAnimation::update(Temp_Callback context)
{
- if (frames.size() < 1)
+ if (frames.empty())
return;
//only one thread can do serial code
if (context.proc == 0) {
@@ -124,18 +130,18 @@
if (context.proc == 0) {
currGroup = frames[(int) frame];
// TODO(boulos): Who should check for identical pointers?
- if (as) as->setGroup(currGroup);
+ if (as)
+ as->setGroup(currGroup);
}
+ //make sure the as->setGroup has occured before all the threads
+ //go do an update.
+ barrier.wait(context.numProcs);
+
}
- // NOTE(boulos): We have to wait until the group is properly
- // interpolated before proceeding to the acceleration structure
- // update (there's no way to ensure that all the geometry will be
- // ready before someone starts touching it in update otherwise).
- barrier.wait(context.numProcs);
if (as)
- as->update(context.proc, context.numProcs);
+ as->rebuild(context.proc, context.numProcs);
}
}
Modified: trunk/Model/Primitives/WaldTriangle.h
==============================================================================
--- trunk/Model/Primitives/WaldTriangle.h (original)
+++ trunk/Model/Primitives/WaldTriangle.h Tue Aug 28 15:59:17 2007
@@ -2,6 +2,7 @@
#ifndef Manta_Model_WaldTriangle_h
#define Manta_Model_WaldTriangle_h
+#include <Interface/MeshTriangle.h>
#include <Interface/RayPacket.h>
#include <Core/Geometry/Vector.h>
#include <Core/Geometry/Ray.h>
@@ -10,7 +11,7 @@
namespace Manta
{
- class WaldTriangle : public Primitive, public TexCoordMapper
+ class WaldTriangle : public MeshTriangle, public TexCoordMapper
{
public:
- [Manta] r1684 - in trunk: Interface Model/Groups Model/MiscObjects Model/Primitives, thiago, 08/28/2007
Archive powered by MHonArc 2.6.16.