Skip to content

Commit

Permalink
Finish Displacement and animation of it.
Browse files Browse the repository at this point in the history
  • Loading branch information
jriegel committed Nov 28, 2013
1 parent 61e2890 commit 09fe84a
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 4 deletions.
23 changes: 22 additions & 1 deletion src/Mod/Fem/Gui/ViewProviderFemMesh.cpp
Expand Up @@ -213,6 +213,7 @@ ViewProviderFemMesh::ViewProviderFemMesh()
pcPointMaterial->ref();
//PointMaterial.touch();

DisplacementFactor = 0;
}

ViewProviderFemMesh::~ViewProviderFemMesh()
Expand Down Expand Up @@ -548,8 +549,28 @@ void ViewProviderFemMesh::resetDisplacementByNodeId(void)
/// reaply the node displacement with a certain factor and do a redraw
void ViewProviderFemMesh::animateNodes(double factor)
{
float x,y,z;
// set the point coordinates
long sz = pcCoords->point.getNum();
SbVec3f* verts = pcCoords->point.startEditing();
for (long i=0;i < sz ;i++) {
verts[i].getValue(x,y,z);
// undo old factor#
Base::Vector3d oldDisp = DisplacementVector[i] * DisplacementFactor;
x -= oldDisp.x;
y -= oldDisp.y;
z -= oldDisp.z;
// apply new factor
Base::Vector3d newDisp = DisplacementVector[i] * factor;
x += newDisp.x;
y += newDisp.y;
z += newDisp.z;
// set the new value
verts[i].setValue(x,y,z);
}
pcCoords->point.finishEditing();


DisplacementFactor = factor;
}


Expand Down
11 changes: 8 additions & 3 deletions src/Mod/Fem/Gui/ViewProviderFemMeshPyImp.cpp
Expand Up @@ -20,10 +20,15 @@ std::string ViewProviderFemMeshPy::representation(void) const



PyObject* ViewProviderFemMeshPy::animate(PyObject * /*args*/)
PyObject* ViewProviderFemMeshPy::animate(PyObject * args)
{
PyErr_SetString(PyExc_NotImplementedError, "Not yet implemented");
return 0;
double factor;
if (!PyArg_ParseTuple(args, "d", &factor))
return 0;

this->getViewProviderFemMeshPtr()->animateNodes(factor);

Py_Return;
}


Expand Down

0 comments on commit 09fe84a

Please sign in to comment.