Fem: Apply clang-format
This commit is contained in:
@@ -2,8 +2,8 @@
|
||||
#include "PreCompiled.h"
|
||||
|
||||
#ifndef _PreComp_
|
||||
# include <SMESH_Mesh.hxx>
|
||||
# include <SMESHDS_Mesh.hxx>
|
||||
#include <SMESHDS_Mesh.hxx>
|
||||
#include <SMESH_Mesh.hxx>
|
||||
#endif
|
||||
|
||||
#include <Base/GeometryPyCXX.h>
|
||||
@@ -11,9 +11,11 @@
|
||||
#include <Mod/Fem/App/FemMeshObject.h>
|
||||
|
||||
#include "ViewProviderFemMesh.h"
|
||||
// clang-format off
|
||||
// inclusion of the generated files (generated out of ViewProviderFemMeshPy.xml)
|
||||
#include "ViewProviderFemMeshPy.h"
|
||||
#include "ViewProviderFemMeshPy.cpp"
|
||||
// clang-format off
|
||||
|
||||
|
||||
using namespace FemGui;
|
||||
@@ -28,8 +30,9 @@ std::string ViewProviderFemMeshPy::representation() const
|
||||
PyObject* ViewProviderFemMeshPy::applyDisplacement(PyObject* args)
|
||||
{
|
||||
double factor;
|
||||
if (!PyArg_ParseTuple(args, "d", &factor))
|
||||
if (!PyArg_ParseTuple(args, "d", &factor)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
this->getViewProviderFemMeshPtr()->applyDisplacementToNodes(factor);
|
||||
|
||||
@@ -39,23 +42,34 @@ PyObject* ViewProviderFemMeshPy::applyDisplacement(PyObject* args)
|
||||
|
||||
App::Color calcColor(double value, double min, double max)
|
||||
{
|
||||
if (max < 0) max = 0;
|
||||
if (min > 0) min = 0;
|
||||
if (max < 0) {
|
||||
max = 0;
|
||||
}
|
||||
if (min > 0) {
|
||||
min = 0;
|
||||
}
|
||||
|
||||
if (value < min)
|
||||
if (value < min) {
|
||||
return App::Color(0.0, 0.0, 1.0);
|
||||
if (value > max)
|
||||
}
|
||||
if (value > max) {
|
||||
return App::Color(1.0, 0.0, 0.0);
|
||||
if (value == 0.0)
|
||||
}
|
||||
if (value == 0.0) {
|
||||
return App::Color(0.0, 1.0, 0.0);
|
||||
if (value > max / 2.0)
|
||||
}
|
||||
if (value > max / 2.0) {
|
||||
return App::Color(1.0, 1 - ((value - (max / 2.0)) / (max / 2.0)), 0.0);
|
||||
if (value > 0.0)
|
||||
}
|
||||
if (value > 0.0) {
|
||||
return App::Color(value / (max / 2.0), 1.0, 0.0);
|
||||
if (value < min / 2.0)
|
||||
}
|
||||
if (value < min / 2.0) {
|
||||
return App::Color(0.0, 1 - ((value - (min / 2.0)) / (min / 2.0)), 1.0);
|
||||
if (value < 0.0)
|
||||
}
|
||||
if (value < 0.0) {
|
||||
return App::Color(0.0, 1.0, value / (min / 2.0));
|
||||
}
|
||||
return App::Color(0, 0, 0);
|
||||
}
|
||||
|
||||
@@ -83,18 +97,23 @@ PyObject* ViewProviderFemMeshPy::setNodeColorByScalars(PyObject* args)
|
||||
PyObject* value_py = PyList_GetItem(values_py, i);
|
||||
double val = PyFloat_AsDouble(value_py);
|
||||
values.push_back(val);
|
||||
if (val > max)
|
||||
if (val > max) {
|
||||
max = val;
|
||||
if (val < min)
|
||||
}
|
||||
if (val < min) {
|
||||
min = val;
|
||||
}
|
||||
}
|
||||
long i = 0;
|
||||
for (std::vector<double>::const_iterator it = values.begin(); it != values.end(); ++it, i++)
|
||||
for (std::vector<double>::const_iterator it = values.begin(); it != values.end();
|
||||
++it, i++) {
|
||||
node_colors[i] = calcColor(*it, min, max);
|
||||
}
|
||||
this->getViewProviderFemMeshPtr()->setColorByNodeId(ids, node_colors);
|
||||
}
|
||||
else {
|
||||
PyErr_SetString(PyExc_TypeError, "PyArg_ParseTuple failed. Invalid arguments used with setNodeByScalars");
|
||||
PyErr_SetString(PyExc_TypeError,
|
||||
"PyArg_ParseTuple failed. Invalid arguments used with setNodeByScalars");
|
||||
return nullptr;
|
||||
}
|
||||
Py_Return;
|
||||
@@ -103,8 +122,9 @@ PyObject* ViewProviderFemMeshPy::setNodeColorByScalars(PyObject* args)
|
||||
|
||||
PyObject* ViewProviderFemMeshPy::resetNodeColor(PyObject* args)
|
||||
{
|
||||
if (!PyArg_ParseTuple(args, ""))
|
||||
if (!PyArg_ParseTuple(args, "")) {
|
||||
return nullptr;
|
||||
}
|
||||
this->getViewProviderFemMeshPtr()->resetColorByNodeId();
|
||||
Py_Return;
|
||||
}
|
||||
@@ -133,7 +153,9 @@ PyObject* ViewProviderFemMeshPy::setNodeDisplacementByVectors(PyObject* args)
|
||||
this->getViewProviderFemMeshPtr()->setDisplacementByNodeId(ids, vectors);
|
||||
}
|
||||
else {
|
||||
PyErr_SetString(PyExc_TypeError, "PyArg_ParseTuple failed. Invalid arguments used with setNodeDisplacementByVectors");
|
||||
PyErr_SetString(
|
||||
PyExc_TypeError,
|
||||
"PyArg_ParseTuple failed. Invalid arguments used with setNodeDisplacementByVectors");
|
||||
return nullptr;
|
||||
}
|
||||
Py_Return;
|
||||
@@ -142,8 +164,9 @@ PyObject* ViewProviderFemMeshPy::setNodeDisplacementByVectors(PyObject* args)
|
||||
|
||||
PyObject* ViewProviderFemMeshPy::resetNodeDisplacement(PyObject* args)
|
||||
{
|
||||
if (!PyArg_ParseTuple(args, ""))
|
||||
if (!PyArg_ParseTuple(args, "")) {
|
||||
return nullptr;
|
||||
}
|
||||
this->getViewProviderFemMeshPtr()->resetDisplacementByNodeId();
|
||||
Py_Return;
|
||||
}
|
||||
@@ -151,7 +174,7 @@ PyObject* ViewProviderFemMeshPy::resetNodeDisplacement(PyObject* args)
|
||||
|
||||
Py::Dict ViewProviderFemMeshPy::getNodeColor() const
|
||||
{
|
||||
//return Py::List();
|
||||
// return Py::List();
|
||||
throw Py::AttributeError("Not yet implemented");
|
||||
}
|
||||
|
||||
@@ -159,18 +182,21 @@ Py::Dict ViewProviderFemMeshPy::getNodeColor() const
|
||||
void ViewProviderFemMeshPy::setNodeColor(Py::Dict arg)
|
||||
{
|
||||
long size = arg.size();
|
||||
if (size == 0)
|
||||
if (size == 0) {
|
||||
this->getViewProviderFemMeshPtr()->resetColorByNodeId();
|
||||
}
|
||||
else {
|
||||
Base::TimeInfo Start;
|
||||
Base::Console().Log("Start: ViewProviderFemMeshPy::setNodeColor() =================================\n");
|
||||
//std::map<long,App::Color> NodeColorMap;
|
||||
Base::Console().Log(
|
||||
"Start: ViewProviderFemMeshPy::setNodeColor() =================================\n");
|
||||
// std::map<long,App::Color> NodeColorMap;
|
||||
|
||||
//for( Py::Dict::iterator it = arg.begin(); it!= arg.end();++it){
|
||||
// Py::Long id((*it).first);
|
||||
// Py::Tuple color((*it).second);
|
||||
// NodeColorMap[id] = App::Color(Py::Float(color[0]),Py::Float(color[1]),Py::Float(color[2]),0);
|
||||
//}
|
||||
// for( Py::Dict::iterator it = arg.begin(); it!= arg.end();++it){
|
||||
// Py::Long id((*it).first);
|
||||
// Py::Tuple color((*it).second);
|
||||
// NodeColorMap[id] =
|
||||
// App::Color(Py::Float(color[0]),Py::Float(color[1]),Py::Float(color[2]),0);
|
||||
// }
|
||||
std::vector<long> NodeIds(size);
|
||||
std::vector<App::Color> NodeColors(size);
|
||||
|
||||
@@ -179,35 +205,40 @@ void ViewProviderFemMeshPy::setNodeColor(Py::Dict arg)
|
||||
Py::Long id((*it).first);
|
||||
Py::Tuple color((*it).second);
|
||||
NodeIds[i] = id;
|
||||
NodeColors[i] = App::Color(Py::Float(color[0]), Py::Float(color[1]), Py::Float(color[2]), 0);
|
||||
NodeColors[i] =
|
||||
App::Color(Py::Float(color[0]), Py::Float(color[1]), Py::Float(color[2]), 0);
|
||||
}
|
||||
Base::Console().Log(" %f: Start ViewProviderFemMeshPy::setNodeColor() call \n", Base::TimeInfo::diffTimeF(Start, Base::TimeInfo()));
|
||||
Base::Console().Log(" %f: Start ViewProviderFemMeshPy::setNodeColor() call \n",
|
||||
Base::TimeInfo::diffTimeF(Start, Base::TimeInfo()));
|
||||
|
||||
//this->getViewProviderFemMeshPtr()->setColorByNodeId(NodeColorMap);
|
||||
// this->getViewProviderFemMeshPtr()->setColorByNodeId(NodeColorMap);
|
||||
this->getViewProviderFemMeshPtr()->setColorByNodeId(NodeIds, NodeColors);
|
||||
Base::Console().Log(" %f: Finish ViewProviderFemMeshPy::setNodeColor() call \n", Base::TimeInfo::diffTimeF(Start, Base::TimeInfo()));
|
||||
Base::Console().Log(" %f: Finish ViewProviderFemMeshPy::setNodeColor() call \n",
|
||||
Base::TimeInfo::diffTimeF(Start, Base::TimeInfo()));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Py::Dict ViewProviderFemMeshPy::getElementColor() const
|
||||
{
|
||||
//return Py::List();
|
||||
// return Py::List();
|
||||
throw Py::AttributeError("Not yet implemented");
|
||||
}
|
||||
|
||||
|
||||
void ViewProviderFemMeshPy::setElementColor(Py::Dict arg)
|
||||
{
|
||||
if (arg.size() == 0)
|
||||
if (arg.size() == 0) {
|
||||
this->getViewProviderFemMeshPtr()->resetColorByNodeId();
|
||||
}
|
||||
else {
|
||||
std::map<long, App::Color> NodeColorMap;
|
||||
|
||||
for (Py::Dict::iterator it = arg.begin(); it != arg.end(); ++it) {
|
||||
Py::Long id((*it).first);
|
||||
Py::Tuple color((*it).second);
|
||||
NodeColorMap[id] = App::Color(Py::Float(color[0]), Py::Float(color[1]), Py::Float(color[2]), 0);
|
||||
NodeColorMap[id] =
|
||||
App::Color(Py::Float(color[0]), Py::Float(color[1]), Py::Float(color[2]), 0);
|
||||
}
|
||||
this->getViewProviderFemMeshPtr()->setColorByElementId(NodeColorMap);
|
||||
}
|
||||
@@ -216,15 +247,16 @@ void ViewProviderFemMeshPy::setElementColor(Py::Dict arg)
|
||||
|
||||
Py::Dict ViewProviderFemMeshPy::getNodeDisplacement() const
|
||||
{
|
||||
//return Py::Dict();
|
||||
// return Py::Dict();
|
||||
throw Py::AttributeError("Not yet implemented");
|
||||
}
|
||||
|
||||
|
||||
void ViewProviderFemMeshPy::setNodeDisplacement(Py::Dict arg)
|
||||
void ViewProviderFemMeshPy::setNodeDisplacement(Py::Dict arg)
|
||||
{
|
||||
if (arg.size() == 0)
|
||||
if (arg.size() == 0) {
|
||||
this->getViewProviderFemMeshPtr()->resetColorByNodeId();
|
||||
}
|
||||
else {
|
||||
std::map<long, Base::Vector3d> NodeDispMap;
|
||||
Py::Type vType(Base::getTypeAsObject(&Base::VectorPy::Type));
|
||||
@@ -256,15 +288,18 @@ Py::List ViewProviderFemMeshPy::getHighlightedNodes() const
|
||||
void ViewProviderFemMeshPy::setHighlightedNodes(Py::List arg)
|
||||
{
|
||||
ViewProviderFemMesh* vp = this->getViewProviderFemMeshPtr();
|
||||
const SMESHDS_Mesh* data = static_cast<Fem::FemMeshObject*>
|
||||
(vp->getObject())->FemMesh.getValue().getSMesh()->GetMeshDS();
|
||||
const SMESHDS_Mesh* data = static_cast<Fem::FemMeshObject*>(vp->getObject())
|
||||
->FemMesh.getValue()
|
||||
.getSMesh()
|
||||
->GetMeshDS();
|
||||
|
||||
std::set<long> res;
|
||||
for (Py::List::iterator it = arg.begin(); it != arg.end(); ++it) {
|
||||
long id = static_cast<long>(Py::Long(*it));
|
||||
const SMDS_MeshNode* node = data->FindNode(id);
|
||||
if (node)
|
||||
if (node) {
|
||||
res.insert(id);
|
||||
}
|
||||
}
|
||||
|
||||
this->getViewProviderFemMeshPtr()->setHighlightNodes(res);
|
||||
@@ -273,8 +308,9 @@ void ViewProviderFemMeshPy::setHighlightedNodes(Py::List arg)
|
||||
|
||||
PyObject* ViewProviderFemMeshPy::resetHighlightedNodes(PyObject* args)
|
||||
{
|
||||
if (!PyArg_ParseTuple(args, ""))
|
||||
if (!PyArg_ParseTuple(args, "")) {
|
||||
return nullptr;
|
||||
}
|
||||
this->getViewProviderFemMeshPtr()->resetHighlightNodes();
|
||||
Py_Return;
|
||||
}
|
||||
@@ -282,19 +318,22 @@ PyObject* ViewProviderFemMeshPy::resetHighlightedNodes(PyObject* args)
|
||||
|
||||
Py::List ViewProviderFemMeshPy::getVisibleElementFaces() const
|
||||
{
|
||||
const std::vector<unsigned long>& visElmFc = this->getViewProviderFemMeshPtr()->getVisibleElementFaces();
|
||||
const std::vector<unsigned long>& visElmFc =
|
||||
this->getViewProviderFemMeshPtr()->getVisibleElementFaces();
|
||||
std::vector<unsigned long> trans;
|
||||
|
||||
// sorting out double faces through higher order elements and null entries
|
||||
long elementOld = 0, faceOld = 0;
|
||||
for (unsigned long it : visElmFc) {
|
||||
if (it == 0)
|
||||
if (it == 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
long element = it >> 3;
|
||||
long face = (it & 7) + 1;
|
||||
if (element == elementOld && face == faceOld)
|
||||
if (element == elementOld && face == faceOld) {
|
||||
continue;
|
||||
}
|
||||
|
||||
trans.push_back(it);
|
||||
elementOld = element;
|
||||
@@ -303,7 +342,8 @@ Py::List ViewProviderFemMeshPy::getVisibleElementFaces() const
|
||||
|
||||
Py::List result(trans.size());
|
||||
int i = 0;
|
||||
for (std::vector<unsigned long>::const_iterator it = trans.begin(); it != trans.end(); ++it, i++) {
|
||||
for (std::vector<unsigned long>::const_iterator it = trans.begin(); it != trans.end();
|
||||
++it, i++) {
|
||||
Py::Tuple tup(2);
|
||||
long element = *it >> 3;
|
||||
long face = (*it & 7) + 1;
|
||||
|
||||
Reference in New Issue
Block a user