Starting Displacement post-processing to the FemMesh ViewProvider
This commit is contained in:
parent
7a1a8051aa
commit
61e289036e
|
@ -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)
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
|
@ -107,6 +107,12 @@ public:
|
||||||
void setColorByNodeId(const std::map<long,App::Color> &NodeColorMap);
|
void setColorByNodeId(const std::map<long,App::Color> &NodeColorMap);
|
||||||
/// reset the view of the node colors
|
/// reset the view of the node colors
|
||||||
void resetColorByNodeId(void);
|
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;}
|
const std::vector<unsigned long> &getVisibleElementFaces(void)const{return vFaceElementIdx;}
|
||||||
|
@ -126,6 +132,9 @@ protected:
|
||||||
/// index of elements to their triangles
|
/// index of elements to their triangles
|
||||||
std::vector<unsigned long> vFaceElementIdx;
|
std::vector<unsigned long> vFaceElementIdx;
|
||||||
std::vector<unsigned long> vNodeElementIdx;
|
std::vector<unsigned long> vNodeElementIdx;
|
||||||
|
|
||||||
|
std::vector<Base::Vector3d> DisplacementVector;
|
||||||
|
double DisplacementFactor;
|
||||||
|
|
||||||
SoMaterial * pcPointMaterial;
|
SoMaterial * pcPointMaterial;
|
||||||
SoDrawStyle * pcPointStyle;
|
SoDrawStyle * pcPointStyle;
|
||||||
|
|
|
@ -20,13 +20,19 @@
|
||||||
<UserDocu></UserDocu>
|
<UserDocu></UserDocu>
|
||||||
</Documentation>
|
</Documentation>
|
||||||
</Methode>
|
</Methode>
|
||||||
<Attribute Name="NodeColor" ReadOnly="false">
|
<Attribute Name="NodeColor" ReadOnly="false">
|
||||||
<Documentation>
|
<Documentation>
|
||||||
<UserDocu>Postprocessing color of the the nodes. The faces between the nodes gets interpolated. </UserDocu>
|
<UserDocu>Postprocessing color of the the nodes. The faces between the nodes gets interpolated. </UserDocu>
|
||||||
</Documentation>
|
</Documentation>
|
||||||
<Parameter Name="NodeColor" Type="Dict"/>
|
<Parameter Name="NodeColor" Type="Dict"/>
|
||||||
</Attribute>
|
</Attribute>
|
||||||
<Attribute Name="HighlightedNodes" ReadOnly="false">
|
<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>
|
<Documentation>
|
||||||
<UserDocu>List of nodes which gets highlighted</UserDocu>
|
<UserDocu>List of nodes which gets highlighted</UserDocu>
|
||||||
</Documentation>
|
</Documentation>
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
|
|
||||||
#include "PreCompiled.h"
|
#include "PreCompiled.h"
|
||||||
|
|
||||||
|
#include <Base/VectorPy.h>
|
||||||
|
#include <Base/GeometryPyCXX.h>
|
||||||
|
|
||||||
#include "Mod/Fem/Gui/ViewProviderFemMesh.h"
|
#include "Mod/Fem/Gui/ViewProviderFemMesh.h"
|
||||||
|
|
||||||
// inclusion of the generated files (generated out of ViewProviderFemMeshPy.xml)
|
// 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
|
Py::List ViewProviderFemMeshPy::getHighlightedNodes(void) const
|
||||||
{
|
{
|
||||||
//return Py::List();
|
//return Py::List();
|
||||||
|
|
Loading…
Reference in New Issue
Block a user