Skip to content

Commit

Permalink
Starting Displacement post-processing to the FemMesh ViewProvider
Browse files Browse the repository at this point in the history
  • Loading branch information
jriegel committed Nov 28, 2013
1 parent 7a1a805 commit 61e2890
Show file tree
Hide file tree
Showing 4 changed files with 80 additions and 7 deletions.
29 changes: 29 additions & 0 deletions src/Mod/Fem/Gui/ViewProviderFemMesh.cpp
Expand Up @@ -523,6 +523,35 @@ void ViewProviderFemMesh::resetColorByNodeId(void)

}

void ViewProviderFemMesh::setDisplacementByNodeId(const std::map<long,Base::Vector3d> &NodeDispMap)
{
DisplacementVector.resize(vNodeElementIdx.size());
int i=0;
for(std::vector<unsigned long>::const_iterator it=vNodeElementIdx.begin()
;it!=vNodeElementIdx.end()
;++it,i++){
const std::map<long,Base::Vector3d>::const_iterator pos = NodeDispMap.find(*it);
if(pos == NodeDispMap.end())
DisplacementVector[i] = Base::Vector3d(0.0,0.0,0.0);
else
DisplacementVector[i] = pos->second;
}
animateNodes(1.0);

}

void ViewProviderFemMesh::resetDisplacementByNodeId(void)
{
animateNodes(0.0);
DisplacementVector.clear();
}
/// reaply the node displacement with a certain factor and do a redraw
void ViewProviderFemMesh::animateNodes(double factor)
{


}


// ----------------------------------------------------------------------------

Expand Down
9 changes: 9 additions & 0 deletions src/Mod/Fem/Gui/ViewProviderFemMesh.h
Expand Up @@ -107,6 +107,12 @@ class FemGuiExport ViewProviderFemMesh : public Gui::ViewProviderGeometryObject
void setColorByNodeId(const std::map<long,App::Color> &NodeColorMap);
/// reset the view of the node colors
void resetColorByNodeId(void);
/// set the displacement for each node
void setDisplacementByNodeId(const std::map<long,Base::Vector3d> &NodeDispMap);
/// reset the view of the node displacement
void resetDisplacementByNodeId(void);
/// reaply the node displacement with a certain factor and do a redraw
void animateNodes(double factor);
//@}

const std::vector<unsigned long> &getVisibleElementFaces(void)const{return vFaceElementIdx;}
Expand All @@ -126,6 +132,9 @@ class FemGuiExport ViewProviderFemMesh : public Gui::ViewProviderGeometryObject
/// index of elements to their triangles
std::vector<unsigned long> vFaceElementIdx;
std::vector<unsigned long> vNodeElementIdx;

std::vector<Base::Vector3d> DisplacementVector;
double DisplacementFactor;

SoMaterial * pcPointMaterial;
SoDrawStyle * pcPointStyle;
Expand Down
20 changes: 13 additions & 7 deletions src/Mod/Fem/Gui/ViewProviderFemMeshPy.xml
Expand Up @@ -20,13 +20,19 @@
<UserDocu></UserDocu>
</Documentation>
</Methode>
<Attribute Name="NodeColor" ReadOnly="false">
<Documentation>
<UserDocu>Postprocessing color of the the nodes. The faces between the nodes gets interpolated. </UserDocu>
</Documentation>
<Parameter Name="NodeColor" Type="Dict"/>
</Attribute>
<Attribute Name="HighlightedNodes" ReadOnly="false">
<Attribute Name="NodeColor" ReadOnly="false">
<Documentation>
<UserDocu>Postprocessing color of the the nodes. The faces between the nodes gets interpolated. </UserDocu>
</Documentation>
<Parameter Name="NodeColor" Type="Dict"/>
</Attribute>
<Attribute Name="NodeDisplacement" ReadOnly="false">
<Documentation>
<UserDocu>Postprocessing color of the the nodes. The faces between the nodes gets interpolated. </UserDocu>
</Documentation>
<Parameter Name="NodeDisplacement" Type="Dict"/>
</Attribute>
<Attribute Name="HighlightedNodes" ReadOnly="false">
<Documentation>
<UserDocu>List of nodes which gets highlighted</UserDocu>
</Documentation>
Expand Down
29 changes: 29 additions & 0 deletions src/Mod/Fem/Gui/ViewProviderFemMeshPyImp.cpp
@@ -1,6 +1,9 @@

#include "PreCompiled.h"

#include <Base/VectorPy.h>
#include <Base/GeometryPyCXX.h>

#include "Mod/Fem/Gui/ViewProviderFemMesh.h"

// inclusion of the generated files (generated out of ViewProviderFemMeshPy.xml)
Expand Down Expand Up @@ -49,6 +52,32 @@ void ViewProviderFemMeshPy::setNodeColor(Py::Dict arg)
}
}

Py::Dict ViewProviderFemMeshPy::getNodeDisplacement(void) const
{
//return Py::Dict();
throw Py::AttributeError("Not yet implemented");
}

void ViewProviderFemMeshPy::setNodeDisplacement(Py::Dict arg)
{
if(arg.size() == 0)
this->getViewProviderFemMeshPtr()->resetColorByNodeId();
else {
std::map<long,Base::Vector3d> NodeDispMap;
union PyType_Object pyType = {&(Base::VectorPy::Type)};
Py::Type vType(pyType.o);

for( Py::Dict::iterator it = arg.begin(); it!= arg.end();++it){
Py::Int id((*it).first);
if ((*it).second.isType(vType)) {
Py::Vector p((*it).second);
NodeDispMap[id] = p.toVector();
}
}
this->getViewProviderFemMeshPtr()->setDisplacementByNodeId(NodeDispMap);
}
}

Py::List ViewProviderFemMeshPy::getHighlightedNodes(void) const
{
//return Py::List();
Expand Down

0 comments on commit 61e2890

Please sign in to comment.