Starting Displacement post-processing to the FemMesh ViewProvider

This commit is contained in:
jriegel 2013-11-28 19:51:34 +01:00
parent 7a1a8051aa
commit 61e289036e
4 changed files with 80 additions and 7 deletions

View File

@ -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)
{
}
// ----------------------------------------------------------------------------

View File

@ -107,6 +107,12 @@ public:
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;}
@ -126,6 +132,9 @@ protected:
/// 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;

View File

@ -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>

View File

@ -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)
@ -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();