Fem: Apply clang-format

This commit is contained in:
wmayer
2023-09-22 12:38:37 +02:00
committed by wwmayer
parent 800006a505
commit 91a40b2007
79 changed files with 3674 additions and 2787 deletions

View File

@@ -30,26 +30,26 @@
#include "FemAnalysis.h"
#include "FemConstraintBearing.h"
#include "FemConstraintFixed.h"
#include "FemConstraintForce.h"
#include "FemConstraintPressure.h"
#include "FemConstraintGear.h"
#include "FemConstraintPulley.h"
#include "FemConstraintContact.h"
#include "FemConstraintDisplacement.h"
#include "FemConstraintTemperature.h"
#include "FemConstraintFixed.h"
#include "FemConstraintFluidBoundary.h"
#include "FemConstraintForce.h"
#include "FemConstraintGear.h"
#include "FemConstraintHeatflux.h"
#include "FemConstraintInitialTemperature.h"
#include "FemConstraintPlaneRotation.h"
#include "FemConstraintContact.h"
#include "FemConstraintFluidBoundary.h"
#include "FemConstraintTransform.h"
#include "FemConstraintPressure.h"
#include "FemConstraintPulley.h"
#include "FemConstraintSpring.h"
#include "FemConstraintTemperature.h"
#include "FemConstraintTransform.h"
#include "FemMesh.h"
#include "FemMeshObject.h"
#include "FemMeshProperty.h"
#include "FemMeshPy.h"
#include "FemMeshShapeObject.h"
#include "FemMeshShapeNetgenObject.h"
#include "FemMeshShapeObject.h"
#include "FemResultObject.h"
#include "FemSetElementsObject.h"
#include "FemSetFacesObject.h"
@@ -59,14 +59,15 @@
#include "HypothesisPy.h"
#ifdef FC_USE_VTK
# include "FemPostFilter.h"
# include "FemPostFunction.h"
# include "FemPostPipeline.h"
# include "PropertyPostDataObject.h"
#include "FemPostFilter.h"
#include "FemPostFunction.h"
#include "FemPostPipeline.h"
#include "PropertyPostDataObject.h"
#endif
namespace Fem {
namespace Fem
{
extern PyObject* initModule();
}
@@ -76,15 +77,16 @@ PyMOD_INIT_FUNC(Fem)
// load dependent module
try {
Base::Interpreter().loadModule("Part");
//Base::Interpreter().loadModule("Mesh");
// Base::Interpreter().loadModule("Mesh");
}
catch(const Base::Exception& e) {
catch (const Base::Exception& e) {
PyErr_SetString(PyExc_ImportError, e.what());
PyMOD_Return(nullptr);
}
PyObject* femModule = Fem::initModule();
Base::Console().Log("Loading Fem module... done\n");
// clang-format off
Fem::StdMeshers_Arithmetic1DPy ::init_type(femModule);
Fem::StdMeshers_AutomaticLengthPy ::init_type(femModule);
Fem::StdMeshers_NotConformAllowedPy ::init_type(femModule);
@@ -194,6 +196,7 @@ PyMOD_INIT_FUNC(Fem)
Fem::PropertyPostDataObject ::init();
#endif
// clang-format on
PyMOD_Return(femModule);
}

View File

@@ -22,8 +22,8 @@
#include "PreCompiled.h"
#ifndef _PreComp_
# include <cstdlib>
# include <memory>
#include <cstdlib>
#include <memory>
#endif
#include <App/Application.h>
@@ -43,65 +43,77 @@
#endif
namespace Fem {
class Module : public Py::ExtensionModule<Module>
namespace Fem
{
class Module: public Py::ExtensionModule<Module>
{
public:
Module() : Py::ExtensionModule<Module>("Fem")
Module()
: Py::ExtensionModule<Module>("Fem")
{
add_varargs_method("open",&Module::open,
"open(string) -- Create a new document and a Mesh::Import feature to load the file into the document."
);
add_varargs_method("insert",&Module::insert,
"insert(string|mesh,[string]) -- Load or insert a mesh into the given or active document."
);
add_varargs_method("export",&Module::exporter,
"export(list,string) -- Export a list of objects into a single file."
);
add_varargs_method("read",&Module::read,
"Read a mesh from a file and returns a Mesh object."
);
add_varargs_method("open",
&Module::open,
"open(string) -- Create a new document and a Mesh::Import feature to "
"load the file into the document.");
add_varargs_method("insert",
&Module::insert,
"insert(string|mesh,[string]) -- Load or insert a mesh into the given "
"or active document.");
add_varargs_method("export",
&Module::exporter,
"export(list,string) -- Export a list of objects into a single file.");
add_varargs_method("read",
&Module::read,
"Read a mesh from a file and returns a Mesh object.");
#ifdef FC_USE_VTK
add_varargs_method("readResult",&Module::readResult,
"Read a CFD or Mechanical result (auto detect) from a file (file format detected from file suffix)"
);
add_varargs_method("writeResult",&Module::writeResult,
"write a CFD or FEM result (auto detect) to a file (file format detected from file suffix)"
);
add_varargs_method("readResult",
&Module::readResult,
"Read a CFD or Mechanical result (auto detect) from a file (file format "
"detected from file suffix)");
add_varargs_method("writeResult",
&Module::writeResult,
"write a CFD or FEM result (auto detect) to a file (file format "
"detected from file suffix)");
#endif
add_varargs_method("show",&Module::show,
"show(shape,[string]) -- Add the mesh to the active document or create one if no document exists."
);
initialize("This module is the Fem module."); // register with Python
add_varargs_method("show",
&Module::show,
"show(shape,[string]) -- Add the mesh to the active document or create "
"one if no document exists.");
initialize("This module is the Fem module."); // register with Python
}
private:
Py::Object invoke_method_varargs(void *method_def, const Py::Tuple &args) override
Py::Object invoke_method_varargs(void* method_def, const Py::Tuple& args) override
{
try {
return Py::ExtensionModule<Module>::invoke_method_varargs(method_def, args);
}
catch (const Standard_Failure &e) {
catch (const Standard_Failure& e) {
std::string str;
Standard_CString msg = e.GetMessageString();
str += typeid(e).name();
str += " ";
if (msg) {str += msg;}
else {str += "No OCCT Exception Message";}
if (msg) {
str += msg;
}
else {
str += "No OCCT Exception Message";
}
throw Py::Exception(Part::PartExceptionOCCError, str);
}
catch (const Base::Exception &e) {
catch (const Base::Exception& e) {
throw Py::RuntimeError(e.what());
}
catch (const std::exception &e) {
catch (const std::exception& e) {
throw Py::RuntimeError(e.what());
}
}
Py::Object open(const Py::Tuple& args)
{
char* Name;
if (!PyArg_ParseTuple(args.ptr(), "et","utf-8",&Name))
if (!PyArg_ParseTuple(args.ptr(), "et", "utf-8", &Name)) {
throw Py::Exception();
}
std::string EncodedName = std::string(Name);
PyMem_Free(Name);
@@ -110,9 +122,9 @@ private:
mesh->read(EncodedName.c_str());
Base::FileInfo file(EncodedName.c_str());
// create new document and add Import feature
App::Document *pcDoc = App::GetApplication().newDocument();
FemMeshObject *pcFeature = static_cast<FemMeshObject *>
(pcDoc->addObject("Fem::FemMeshObject", file.fileNamePure().c_str()));
App::Document* pcDoc = App::GetApplication().newDocument();
FemMeshObject* pcFeature = static_cast<FemMeshObject*>(
pcDoc->addObject("Fem::FemMeshObject", file.fileNamePure().c_str()));
pcFeature->Label.setValue(file.fileNamePure().c_str());
pcFeature->FemMesh.setValuePtr(mesh.release());
pcFeature->purgeTouched();
@@ -123,17 +135,20 @@ private:
{
char* Name;
const char* DocName = nullptr;
if (!PyArg_ParseTuple(args.ptr(), "et|s","utf-8",&Name,&DocName))
if (!PyArg_ParseTuple(args.ptr(), "et|s", "utf-8", &Name, &DocName)) {
throw Py::Exception();
}
std::string EncodedName = std::string(Name);
PyMem_Free(Name);
App::Document *pcDoc = nullptr;
if (DocName)
App::Document* pcDoc = nullptr;
if (DocName) {
pcDoc = App::GetApplication().getDocument(DocName);
else
}
else {
pcDoc = App::GetApplication().getActiveDocument();
}
if (!pcDoc) {
pcDoc = App::GetApplication().newDocument(DocName);
@@ -145,8 +160,8 @@ private:
std::unique_ptr<FemMesh> mesh(new FemMesh);
mesh->read(EncodedName.c_str());
FemMeshObject *pcFeature = static_cast<FemMeshObject *>
(pcDoc->addObject("Fem::FemMeshObject", file.fileNamePure().c_str()));
FemMeshObject* pcFeature = static_cast<FemMeshObject*>(
pcDoc->addObject("Fem::FemMeshObject", file.fileNamePure().c_str()));
pcFeature->Label.setValue(file.fileNamePure().c_str());
pcFeature->FemMesh.setValuePtr(mesh.release());
pcFeature->purgeTouched();
@@ -155,8 +170,8 @@ private:
#ifdef FC_USE_VTK
if (FemPostPipeline::canRead(file)) {
FemPostPipeline *pcFeature = static_cast<FemPostPipeline *>
(pcDoc->addObject("Fem::FemPostPipeline", file.fileNamePure().c_str()));
FemPostPipeline* pcFeature = static_cast<FemPostPipeline*>(
pcDoc->addObject("Fem::FemPostPipeline", file.fileNamePure().c_str()));
pcFeature->Label.setValue(file.fileNamePure().c_str());
pcFeature->read(file);
@@ -177,8 +192,9 @@ private:
{
PyObject* object;
char* Name;
if (!PyArg_ParseTuple(args.ptr(), "Oet",&object,"utf-8",&Name))
if (!PyArg_ParseTuple(args.ptr(), "Oet", &object, "utf-8", &Name)) {
throw Py::Exception();
}
std::string EncodedName = std::string(Name);
PyMem_Free(Name);
@@ -188,7 +204,8 @@ private:
for (Py::Sequence::iterator it = list.begin(); it != list.end(); ++it) {
PyObject* item = (*it).ptr();
if (PyObject_TypeCheck(item, &(App::DocumentObjectPy::Type))) {
App::DocumentObject* obj = static_cast<App::DocumentObjectPy*>(item)->getDocumentObjectPtr();
App::DocumentObject* obj =
static_cast<App::DocumentObjectPy*>(item)->getDocumentObjectPtr();
if (obj->getTypeId().isDerivedFrom(meshId)) {
static_cast<FemMeshObject*>(obj)->FemMesh.getValue().write(EncodedName.c_str());
return Py::None();
@@ -201,8 +218,9 @@ private:
Py::Object read(const Py::Tuple& args)
{
char* Name;
if (!PyArg_ParseTuple(args.ptr(), "et","utf-8",&Name))
if (!PyArg_ParseTuple(args.ptr(), "et", "utf-8", &Name)) {
throw Py::Exception();
}
std::string EncodedName = std::string(Name);
PyMem_Free(Name);
@@ -218,21 +236,22 @@ private:
char* fileName = nullptr;
char* objName = nullptr;
if (!PyArg_ParseTuple(args.ptr(), "et|et","utf-8", &fileName, "utf-8", &objName))
if (!PyArg_ParseTuple(args.ptr(), "et|et", "utf-8", &fileName, "utf-8", &objName)) {
throw Py::Exception();
}
std::string EncodedName = std::string(fileName);
PyMem_Free(fileName);
std::string resName = std::string(objName);
PyMem_Free(objName);
if (resName.length())
{
if (resName.length()) {
App::Document* pcDoc = App::GetApplication().getActiveDocument();
App::DocumentObject* obj = pcDoc->getObject(resName.c_str());
FemVTKTools::readResult(EncodedName.c_str(), obj);
}
else
else {
FemVTKTools::readResult(EncodedName.c_str()); // assuming activeObject can hold Result
}
return Py::None();
}
@@ -240,23 +259,29 @@ private:
Py::Object writeResult(const Py::Tuple& args)
{
char* fileName = nullptr;
PyObject *pcObj = nullptr;
PyObject* pcObj = nullptr;
if (!PyArg_ParseTuple(args.ptr(), "et|O!","utf-8", &fileName, &(App::DocumentObjectPy::Type), &pcObj))
if (!PyArg_ParseTuple(args.ptr(),
"et|O!",
"utf-8",
&fileName,
&(App::DocumentObjectPy::Type),
&pcObj)) {
throw Py::Exception();
}
std::string EncodedName = std::string(fileName);
PyMem_Free(fileName);
if (pcObj)
{
if (PyObject_TypeCheck(pcObj, &(App::DocumentObjectPy::Type)))
{
App::DocumentObject* obj = static_cast<App::DocumentObjectPy*>(pcObj)->getDocumentObjectPtr();
if (pcObj) {
if (PyObject_TypeCheck(pcObj, &(App::DocumentObjectPy::Type))) {
App::DocumentObject* obj =
static_cast<App::DocumentObjectPy*>(pcObj)->getDocumentObjectPtr();
FemVTKTools::writeResult(EncodedName.c_str(), obj);
}
}
else
else {
FemVTKTools::writeResult(EncodedName.c_str());
}
return Py::None();
}
@@ -264,18 +289,20 @@ private:
Py::Object show(const Py::Tuple& args)
{
PyObject *pcObj;
char *name = "Mesh";
if (!PyArg_ParseTuple(args.ptr(), "O!|s", &(FemMeshPy::Type), &pcObj, &name))
PyObject* pcObj;
char* name = "Mesh";
if (!PyArg_ParseTuple(args.ptr(), "O!|s", &(FemMeshPy::Type), &pcObj, &name)) {
throw Py::Exception();
}
App::Document *pcDoc = App::GetApplication().getActiveDocument();
if (!pcDoc)
App::Document* pcDoc = App::GetApplication().getActiveDocument();
if (!pcDoc) {
pcDoc = App::GetApplication().newDocument();
}
FemMeshPy* pShape = static_cast<FemMeshPy*>(pcObj);
Fem::FemMeshObject *pcFeature = static_cast<Fem::FemMeshObject*>
(pcDoc->addObject("Fem::FemMeshObject", name));
Fem::FemMeshObject* pcFeature =
static_cast<Fem::FemMeshObject*>(pcDoc->addObject("Fem::FemMeshObject", name));
// copy the data
pcFeature->FemMesh.setValue(*(pShape->getFemMeshPtr()));
pcDoc->recompute();
@@ -289,4 +316,4 @@ PyObject* initModule()
return Base::Interpreter().addModule(new Module);
}
} // namespace Fem
} // namespace Fem

View File

@@ -62,17 +62,20 @@ PROPERTY_SOURCE_ABSTRACT(Fem::DocumentObject, App::DocumentObject)
// Python feature ---------------------------------------------------------
namespace App {
namespace App
{
/// @cond DOXERR
PROPERTY_SOURCE_TEMPLATE(Fem::FemAnalysisPython, Fem::FemAnalysis)
template<> const char* Fem::FemAnalysisPython::getViewProviderName() const {
template<>
const char* Fem::FemAnalysisPython::getViewProviderName() const
{
return "FemGui::ViewProviderFemAnalysisPython";
}
// template<> void Fem::FemAnalysisPython::Restore(Base::XMLReader& reader) {
// FemAnalysis::Restore(reader);
// }
//template<> PyObject* Fem::FemAnalysisPython::getPyObject(void) {
// template<> PyObject* Fem::FemAnalysisPython::getPyObject(void) {
// if (PythonObject.is(Py::_None())) {
// // ref counter is set to 1
// PythonObject = Py::Object(new App::DocumentObjectPy(this),true);
@@ -83,17 +86,22 @@ template<> const char* Fem::FemAnalysisPython::getViewProviderName() const {
// explicit template instantiation
template class FemExport FeaturePythonT<Fem::FemAnalysis>;
}
} // namespace App
// ---------------------------------------------------------
namespace App {
namespace App
{
/// @cond DOXERR
PROPERTY_SOURCE_TEMPLATE(Fem::FeaturePython, Fem::DocumentObject)
template<> const char* Fem::FeaturePython::getViewProviderName() const {
template<>
const char* Fem::FeaturePython::getViewProviderName() const
{
return "Gui::ViewProviderPythonFeature";
}
template<> PyObject* Fem::FeaturePython::getPyObject() {
template<>
PyObject* Fem::FeaturePython::getPyObject()
{
if (PythonObject.is(Py::_None())) {
// ref counter is set to 1
PythonObject = Py::Object(new App::FeaturePythonPyT<App::DocumentObjectPy>(this), true);
@@ -103,4 +111,4 @@ template<> PyObject* Fem::FeaturePython::getPyObject() {
// explicit template instantiation
template class FemExport FeaturePythonT<Fem::DocumentObject>;
/// @endcond
}
} // namespace App

View File

@@ -24,12 +24,13 @@
#define Fem_FemAnalysis_H
#include <App/DocumentObjectGroup.h>
#include <App/PropertyStandard.h>
#include <App/FeaturePython.h>
#include <App/PropertyStandard.h>
#include <Mod/Fem/FemGlobal.h>
namespace Fem {
namespace Fem
{
/**
* @brief Container of objects relevant to one simulation.
@@ -49,7 +50,8 @@ namespace Fem {
* Analysis object. Every document object of FreeCAD can be part of a
* Analysis.
*/
class FemExport FemAnalysis : public App::DocumentObjectGroup {
class FemExport FemAnalysis: public App::DocumentObjectGroup
{
PROPERTY_HEADER_WITH_OVERRIDE(Fem::FemAnalysis);
public:
@@ -66,9 +68,10 @@ public:
* directory name for an analysis. Retains its value across save/load
* cycles.
*/
App::PropertyUUID Uid;
App::PropertyUUID Uid;
const char* getViewProviderName() const override {
const char* getViewProviderName() const override
{
return "FemGui::ViewProviderFemAnalysis";
}
@@ -82,11 +85,12 @@ protected:
* property of DocumentObjectGroup. This methods translates old files
* still using the "Member" property.
*/
void handleChangedPropertyName(
Base::XMLReader &reader, const char * TypeName, const char *PropName) override;
void handleChangedPropertyName(Base::XMLReader& reader,
const char* TypeName,
const char* PropName) override;
};
class FemExport DocumentObject : public App::DocumentObject
class FemExport DocumentObject: public App::DocumentObject
{
PROPERTY_HEADER_WITH_OVERRIDE(Fem::DocumentObject);
};
@@ -95,7 +99,7 @@ using FemAnalysisPython = App::FeaturePythonT<FemAnalysis>;
using FeaturePython = App::FeaturePythonT<DocumentObject>;
} //namespace Fem
} // namespace Fem
#endif // Fem_FemAnalysis_H
#endif // Fem_FemAnalysis_H

View File

@@ -24,32 +24,32 @@
#include "PreCompiled.h"
#ifndef _PreComp_
# include <cmath> //OvG: Required for log10
# include <Adaptor3d_IsoCurve.hxx>
# include <BRep_Tool.hxx>
# include <BRepAdaptor_Curve.hxx>
# include <BRepAdaptor_Surface.hxx>
# include <BRepGProp.hxx>
# include <BRepGProp_Face.hxx>
# include <BRepClass_FaceClassifier.hxx>
# include <GCPnts_AbscissaPoint.hxx>
# include <Geom_Line.hxx>
# include <Geom_Plane.hxx>
# include <GeomAPI_IntCS.hxx>
# include <GeomAPI_ProjectPointOnSurf.hxx>
# include <gp_Cylinder.hxx>
# include <gp_Pln.hxx>
# include <gp_Pnt.hxx>
# include <gp_Vec.hxx>
# include <GProp_GProps.hxx>
# include <Precision.hxx>
# include <Standard_Version.hxx>
# include <TopoDS.hxx>
# include <TopoDS_Vertex.hxx>
# if OCC_VERSION_HEX < 0x070600
# include <Adaptor3d_HSurface.hxx>
# include <BRepAdaptor_HSurface.hxx>
# endif
#include <Adaptor3d_IsoCurve.hxx>
#include <BRepAdaptor_Curve.hxx>
#include <BRepAdaptor_Surface.hxx>
#include <BRepClass_FaceClassifier.hxx>
#include <BRepGProp.hxx>
#include <BRepGProp_Face.hxx>
#include <BRep_Tool.hxx>
#include <GCPnts_AbscissaPoint.hxx>
#include <GProp_GProps.hxx>
#include <GeomAPI_IntCS.hxx>
#include <GeomAPI_ProjectPointOnSurf.hxx>
#include <Geom_Line.hxx>
#include <Geom_Plane.hxx>
#include <Precision.hxx>
#include <Standard_Version.hxx>
#include <TopoDS.hxx>
#include <TopoDS_Vertex.hxx>
#include <cmath> //OvG: Required for log10
#include <gp_Cylinder.hxx>
#include <gp_Pln.hxx>
#include <gp_Pnt.hxx>
#include <gp_Vec.hxx>
#if OCC_VERSION_HEX < 0x070600
#include <Adaptor3d_HSurface.hxx>
#include <BRepAdaptor_HSurface.hxx>
#endif
#endif
#include <App/DocumentObjectPy.h>
@@ -72,16 +72,29 @@ PROPERTY_SOURCE(Fem::Constraint, App::DocumentObject)
Constraint::Constraint()
{
ADD_PROPERTY_TYPE(References, (nullptr, nullptr), "Constraint", (App::PropertyType)(App::Prop_None), "Elements where the constraint is applied");
ADD_PROPERTY_TYPE(NormalDirection, (Base::Vector3d(0, 0, 1)), "Constraint", App::PropertyType(App::Prop_ReadOnly | App::Prop_Output), "Normal direction pointing outside of solid");
ADD_PROPERTY_TYPE(Scale, (1), "Base", App::PropertyType(App::Prop_Output), "Scale used for drawing constraints"); //OvG: Add scale parameter inherited by all derived constraints
ADD_PROPERTY_TYPE(References,
(nullptr, nullptr),
"Constraint",
(App::PropertyType)(App::Prop_None),
"Elements where the constraint is applied");
ADD_PROPERTY_TYPE(NormalDirection,
(Base::Vector3d(0, 0, 1)),
"Constraint",
App::PropertyType(App::Prop_ReadOnly | App::Prop_Output),
"Normal direction pointing outside of solid");
ADD_PROPERTY_TYPE(Scale,
(1),
"Base",
App::PropertyType(App::Prop_Output),
"Scale used for drawing constraints"); // OvG: Add scale parameter inherited
// by all derived constraints
References.setScope(App::LinkScope::Global);
}
Constraint::~Constraint() = default;
App::DocumentObjectExecReturn *Constraint::execute()
App::DocumentObjectExecReturn* Constraint::execute()
{
try {
References.touch();
@@ -93,15 +106,17 @@ App::DocumentObjectExecReturn *Constraint::execute()
}
}
//OvG: Provide the ability to determine how big to draw constraint arrows etc.
// OvG: Provide the ability to determine how big to draw constraint arrows etc.
int Constraint::calcDrawScaleFactor(double lparam) const
{
return ((int)round(log(lparam)*log(lparam)*log(lparam)/10)>1)?((int)round(log(lparam)*log(lparam)*log(lparam)/10)):1;
return ((int)round(log(lparam) * log(lparam) * log(lparam) / 10) > 1)
? ((int)round(log(lparam) * log(lparam) * log(lparam) / 10))
: 1;
}
int Constraint::calcDrawScaleFactor(double lvparam, double luparam) const
{
return calcDrawScaleFactor((lvparam+luparam)/2.0);
return calcDrawScaleFactor((lvparam + luparam) / 2.0);
}
int Constraint::calcDrawScaleFactor() const
@@ -113,8 +128,9 @@ int Constraint::calcDrawScaleFactor() const
void Constraint::onChanged(const App::Property* prop)
{
if (prop == &References) {
// If References are changed, recalculate the normal direction. If no useful reference is found,
// use z axis or previous value. If several faces are selected, only the first one is used
// If References are changed, recalculate the normal direction. If no useful reference is
// found, use z axis or previous value. If several faces are selected, only the first one is
// used
std::vector<App::DocumentObject*> Objects = References.getValues();
std::vector<std::string> SubElements = References.getSubValues();
@@ -137,7 +153,7 @@ void Constraint::onChanged(const App::Property* prop)
gp_Pnt center;
double u1, u2, v1, v2;
props.Bounds(u1, u2, v1, v2);
props.Normal((u1+u2)/2.0, (v1+v2)/2.0, center, normal);
props.Normal((u1 + u2) / 2.0, (v1 + v2) / 2.0, center, normal);
normal.Normalize();
NormalDirection.setValue(normal.X(), normal.Y(), normal.Z());
// One face is enough...
@@ -157,7 +173,9 @@ void Constraint::onDocumentRestored()
App::DocumentObject::onDocumentRestored();
}
bool Constraint::getPoints(std::vector<Base::Vector3d> &points, std::vector<Base::Vector3d> &normals, int * scale) const
bool Constraint::getPoints(std::vector<Base::Vector3d>& points,
std::vector<Base::Vector3d>& normals,
int* scale) const
{
std::vector<App::DocumentObject*> Objects = References.getValues();
std::vector<std::string> SubElements = References.getSubValues();
@@ -169,23 +187,26 @@ bool Constraint::getPoints(std::vector<Base::Vector3d> &points, std::vector<Base
App::DocumentObject* obj = Objects[i];
Part::Feature* feat = static_cast<Part::Feature*>(obj);
const Part::TopoShape& toposhape = feat->Shape.getShape();
if (toposhape.isNull())
if (toposhape.isNull()) {
return false;
}
sh = toposhape.getSubShape(SubElements[i].c_str(), true);
if (sh.IsNull())
if (sh.IsNull()) {
return false;
}
if (sh.ShapeType() == TopAbs_VERTEX) {
const TopoDS_Vertex& vertex = TopoDS::Vertex(sh);
gp_Pnt p = BRep_Tool::Pnt(vertex);
points.emplace_back(p.X(), p.Y(), p.Z());
normals.push_back(NormalDirection.getValue());
//OvG: Scale by whole object mass in case of a vertex
// OvG: Scale by whole object mass in case of a vertex
GProp_GProps props;
BRepGProp::VolumeProperties(toposhape.getShape(), props);
double lx = props.Mass();
*scale = this->calcDrawScaleFactor(sqrt(lx)*0.5); //OvG: setup draw scale for constraint
// OvG: setup draw scale for constraint
*scale = this->calcDrawScaleFactor(sqrt(lx) * 0.5);
}
else if (sh.ShapeType() == TopAbs_EDGE) {
BRepAdaptor_Curve curve(TopoDS::Edge(sh));
@@ -194,26 +215,26 @@ bool Constraint::getPoints(std::vector<Base::Vector3d> &points, std::vector<Base
GProp_GProps props;
BRepGProp::LinearProperties(TopoDS::Edge(sh), props);
double l = props.Mass();
// Create points with 10 units distance, but at least one at the beginning and end of the edge
// Create points with 10 units distance, but at least one at the beginning and end of
// the edge
int steps;
if (l >= 30) //OvG: Increase 10 units distance proportionately to l for larger objects.
{
*scale = this->calcDrawScaleFactor(l); //OvG: setup draw scale for constraint
steps = (int)round(l / (10*( *scale)));
steps = steps<3?3:steps;
// OvG: Increase 10 units distance proportionately to l for larger objects.
if (l >= 30) {
*scale = this->calcDrawScaleFactor(l); // OvG: setup draw scale for constraint
steps = (int)round(l / (10 * (*scale)));
steps = steps < 3 ? 3 : steps;
}
else if (l >= 20)
{
else if (l >= 20) {
steps = (int)round(l / 10);
*scale = this->calcDrawScaleFactor(); //OvG: setup draw scale for constraint
*scale = this->calcDrawScaleFactor(); // OvG: setup draw scale for constraint
}
else
{
else {
steps = 1;
*scale = this->calcDrawScaleFactor(); //OvG: setup draw scale for constraint
*scale = this->calcDrawScaleFactor(); // OvG: setup draw scale for constraint
}
steps = steps>CONSTRAINTSTEPLIMIT?CONSTRAINTSTEPLIMIT:steps; //OvG: Place upper limit on number of steps
// OvG: Place upper limit on number of steps
steps = steps > CONSTRAINTSTEPLIMIT ? CONSTRAINTSTEPLIMIT : steps;
double step = (lp - fp) / steps;
for (int i = 0; i < steps + 1; i++) {
// Parameter values must be in the range [fp, lp] (#0003683)
@@ -256,12 +277,12 @@ bool Constraint::getPoints(std::vector<Base::Vector3d> &points, std::vector<Base
try {
isoc.Load(GeomAbs_IsoU, ulp);
lv = (l + GCPnts_AbscissaPoint::Length(isoc, Precision::Confusion()))/2.0;
lv = (l + GCPnts_AbscissaPoint::Length(isoc, Precision::Confusion())) / 2.0;
}
catch (const Standard_Failure&) {
gp_Pnt p1 = hsurf->Value(ulp, vfp);
gp_Pnt p2 = hsurf->Value(ulp, vlp);
lv = (l + p1.Distance(p2))/2.0;
lv = (l + p1.Distance(p2)) / 2.0;
}
try {
@@ -276,52 +297,52 @@ bool Constraint::getPoints(std::vector<Base::Vector3d> &points, std::vector<Base
try {
isoc.Load(GeomAbs_IsoV, vlp);
lu = (l + GCPnts_AbscissaPoint::Length(isoc, Precision::Confusion()))/2.0;
lu = (l + GCPnts_AbscissaPoint::Length(isoc, Precision::Confusion())) / 2.0;
}
catch (const Standard_Failure&) {
gp_Pnt p1 = hsurf->Value(ufp, vlp);
gp_Pnt p2 = hsurf->Value(ulp, vlp);
lu = (l + p1.Distance(p2))/2.0;
lu = (l + p1.Distance(p2)) / 2.0;
}
// OvG: Increase 10 units distance proportionately to lv for larger objects.
int stepsv;
if (lv >= 30) //OvG: Increase 10 units distance proportionately to lv for larger objects.
{
*scale = this->calcDrawScaleFactor(lv, lu); //OvG: setup draw scale for constraint
if (lv >= 30) {
*scale = this->calcDrawScaleFactor(lv, lu); // OvG: setup draw scale for constraint
stepsv = (int)round(lv / (10 * (*scale)));
stepsv = stepsv<3?3:stepsv;
stepsv = stepsv < 3 ? 3 : stepsv;
}
else if (lv >= 20.0)
{
else if (lv >= 20.0) {
stepsv = (int)round(lv / 10);
*scale = this->calcDrawScaleFactor(); //OvG: setup draw scale for constraint
*scale = this->calcDrawScaleFactor(); // OvG: setup draw scale for constraint
}
else
{
stepsv = 2; // Minimum of three arrows to ensure (as much as possible) that at least one is displayed
*scale = this->calcDrawScaleFactor(); //OvG: setup draw scale for constraint
else {
// Minimum of three arrows to ensure (as much as possible) that at
// least one is displayed
stepsv = 2;
*scale = this->calcDrawScaleFactor(); // OvG: setup draw scale for constraint
}
stepsv = stepsv>CONSTRAINTSTEPLIMIT?CONSTRAINTSTEPLIMIT:stepsv; //OvG: Place upper limit on number of steps
// OvG: Place upper limit on number of steps
stepsv = stepsv > CONSTRAINTSTEPLIMIT ? CONSTRAINTSTEPLIMIT : stepsv;
int stepsu;
if (lu >= 30) //OvG: Increase 10 units distance proportionately to lu for larger objects.
{
*scale = this->calcDrawScaleFactor(lv,lu); //OvG: setup draw scale for constraint
stepsu = (int)round(lu / (10*( *scale)));
stepsu = stepsu<3?3:stepsu;
// OvG: Increase 10 units distance proportionately to lu for larger objects.
if (lu >= 30) {
*scale = this->calcDrawScaleFactor(lv, lu); // OvG: setup draw scale for constraint
stepsu = (int)round(lu / (10 * (*scale)));
stepsu = stepsu < 3 ? 3 : stepsu;
}
else if (lu >= 20.0)
{
else if (lu >= 20.0) {
stepsu = (int)round(lu / 10);
*scale = this->calcDrawScaleFactor(); //OvG: setup draw scale for constraint
*scale = this->calcDrawScaleFactor(); // OvG: setup draw scale for constraint
}
else
{
else {
stepsu = 2;
*scale = this->calcDrawScaleFactor(); //OvG: setup draw scale for constraint
*scale = this->calcDrawScaleFactor(); // OvG: setup draw scale for constraint
}
stepsu = stepsu>CONSTRAINTSTEPLIMIT?CONSTRAINTSTEPLIMIT:stepsu; //OvG: Place upper limit on number of steps
// OvG: Place upper limit on number of steps
stepsu = stepsu > CONSTRAINTSTEPLIMIT ? CONSTRAINTSTEPLIMIT : stepsu;
double stepv = (vlp - vfp) / stepsv;
double stepu = (ulp - ufp) / stepsu;
// Create points and normals
@@ -333,7 +354,7 @@ bool Constraint::getPoints(std::vector<Base::Vector3d> &points, std::vector<Base
BRepClass_FaceClassifier classifier(face, p, Precision::Confusion());
if (classifier.State() != TopAbs_OUT) {
points.emplace_back(p.X(), p.Y(), p.Z());
props.Normal(u, v,center,normal);
props.Normal(u, v, center, normal);
normal.Normalize();
normals.emplace_back(normal.X(), normal.Y(), normal.Z());
}
@@ -345,24 +366,29 @@ bool Constraint::getPoints(std::vector<Base::Vector3d> &points, std::vector<Base
return true;
}
bool Constraint::getCylinder(double &radius, double &height, Base::Vector3d& base, Base::Vector3d& axis) const
bool Constraint::getCylinder(double& radius,
double& height,
Base::Vector3d& base,
Base::Vector3d& axis) const
{
std::vector<App::DocumentObject*> Objects = References.getValues();
std::vector<std::string> SubElements = References.getSubValues();
if (Objects.empty())
if (Objects.empty()) {
return false;
}
App::DocumentObject* obj = Objects[0];
Part::Feature* feat = static_cast<Part::Feature*>(obj);
const Part::TopoShape& toposhape = feat->Shape.getShape();
if (toposhape.isNull())
if (toposhape.isNull()) {
return false;
}
TopoDS_Shape sh = toposhape.getSubShape(SubElements[0].c_str());
TopoDS_Face face = TopoDS::Face(sh);
BRepAdaptor_Surface surface(face);
gp_Cylinder cyl = surface.Cylinder();
gp_Pnt start = surface.Value(surface.FirstUParameter(), surface.FirstVParameter());
gp_Pnt end = surface.Value(surface.FirstUParameter(), surface.LastVParameter());
gp_Pnt end = surface.Value(surface.FirstUParameter(), surface.LastVParameter());
height = start.Distance(end);
radius = cyl.Radius();
@@ -374,14 +400,17 @@ bool Constraint::getCylinder(double &radius, double &height, Base::Vector3d& bas
return true;
}
Base::Vector3d Constraint::getBasePoint(const Base::Vector3d& base, const Base::Vector3d& axis,
const App::PropertyLinkSub& location, const double& dist)
Base::Vector3d Constraint::getBasePoint(const Base::Vector3d& base,
const Base::Vector3d& axis,
const App::PropertyLinkSub& location,
const double& dist)
{
// Get the point specified by Location and Distance
App::DocumentObject* objLoc = location.getValue();
std::vector<std::string> names = location.getSubValues();
if (names.empty())
return Base::Vector3d(0,0,0);
if (names.empty()) {
return Base::Vector3d(0, 0, 0);
}
std::string subName = names.front();
Part::Feature* featLoc = static_cast<Part::Feature*>(objLoc);
TopoDS_Shape shloc = featLoc->Shape.getShape().getSubShape(subName.c_str());
@@ -392,7 +421,8 @@ Base::Vector3d Constraint::getBasePoint(const Base::Vector3d& base, const Base::
if (shloc.ShapeType() == TopAbs_FACE) {
BRepAdaptor_Surface surface(TopoDS::Face(shloc));
plane = surface.Plane();
} else {
}
else {
BRepAdaptor_Curve curve(TopoDS::Edge(shloc));
gp_Lin line = curve.Line();
gp_Dir tang = line.Direction().Crossed(cylaxis);
@@ -404,28 +434,32 @@ Base::Vector3d Constraint::getBasePoint(const Base::Vector3d& base, const Base::
Handle(Geom_Plane) pln = new Geom_Plane(plane);
gp_Pnt cylbase(base.x, base.y, base.z);
GeomAPI_ProjectPointOnSurf proj(cylbase, pln);
if (!proj.IsDone())
return Base::Vector3d(0,0,0);
if (!proj.IsDone()) {
return Base::Vector3d(0, 0, 0);
}
gp_Pnt projPnt = proj.NearestPoint();
if ((fabs(dist) > Precision::Confusion()) && (projPnt.IsEqual(cylbase, Precision::Confusion()) == Standard_False))
if ((fabs(dist) > Precision::Confusion())
&& (projPnt.IsEqual(cylbase, Precision::Confusion()) == Standard_False)) {
plane.Translate(gp_Vec(projPnt, cylbase).Normalized().Multiplied(dist));
}
Handle(Geom_Plane) plnt = new Geom_Plane(plane);
// Intersect translated plane with cylinder axis
Handle(Geom_Curve) crv = new Geom_Line(cylbase, cylaxis);
GeomAPI_IntCS intersector(crv, plnt);
if (!intersector.IsDone())
return Base::Vector3d(0,0,0);
if (!intersector.IsDone()) {
return Base::Vector3d(0, 0, 0);
}
gp_Pnt inter = intersector.Point(1);
return Base::Vector3d(inter.X(), inter.Y(), inter.Z());
}
const Base::Vector3d Constraint::getDirection(const App::PropertyLinkSub &direction)
const Base::Vector3d Constraint::getDirection(const App::PropertyLinkSub& direction)
{
App::DocumentObject* obj = direction.getValue();
if (!obj) {
return Base::Vector3d(0,0,0);
return Base::Vector3d(0, 0, 0);
}
if (obj->getTypeId().isDerivedFrom(App::Line::getClassTypeId())) {
@@ -447,13 +481,15 @@ const Base::Vector3d Constraint::getDirection(const App::PropertyLinkSub &direct
}
std::vector<std::string> names = direction.getSubValues();
if (names.empty())
return Base::Vector3d(0,0,0);
if (names.empty()) {
return Base::Vector3d(0, 0, 0);
}
std::string subName = names.front();
Part::Feature* feat = static_cast<Part::Feature*>(obj);
const Part::TopoShape& shape = feat->Shape.getShape();
if (shape.isNull())
return Base::Vector3d(0,0,0);
if (shape.isNull()) {
return Base::Vector3d(0, 0, 0);
}
TopoDS_Shape sh;
try {
sh = shape.getSubShape(subName.c_str());
@@ -469,17 +505,22 @@ const Base::Vector3d Constraint::getDirection(const App::PropertyLinkSub &direct
// Python feature ---------------------------------------------------------
namespace App {
namespace App
{
/// @cond DOXERR
PROPERTY_SOURCE_TEMPLATE(Fem::ConstraintPython, Fem::Constraint)
template<> const char* Fem::ConstraintPython::getViewProviderName() const {
template<>
const char* Fem::ConstraintPython::getViewProviderName() const
{
return "FemGui::ViewProviderFemConstraintPython";
}
template<> PyObject* Fem::ConstraintPython::getPyObject() {
template<>
PyObject* Fem::ConstraintPython::getPyObject()
{
if (PythonObject.is(Py::_None())) {
// ref counter is set to 1
PythonObject = Py::Object(new App::FeaturePythonPyT<App::DocumentObjectPy>(this),true);
PythonObject = Py::Object(new App::FeaturePythonPyT<App::DocumentObjectPy>(this), true);
}
return Py::new_reference_to(PythonObject);
}
@@ -489,4 +530,4 @@ template class FemExport FeaturePythonT<Fem::Constraint>;
/// @endcond
}
} // namespace App

View File

@@ -32,7 +32,8 @@
#include <Mod/Fem/FemGlobal.h>
namespace Fem {
namespace Fem
{
/**
* @brief Base class of all Constraint Objects of the Fem module.
@@ -56,7 +57,8 @@ namespace Fem {
* and @ref Scale and the protected method @ref getPoints(points&, normals&,
* scale&).
*/
class FemExport Constraint : public App::DocumentObject {
class FemExport Constraint: public App::DocumentObject
{
PROPERTY_HEADER_WITH_OVERRIDE(Fem::Constraint);
public:
@@ -113,7 +115,7 @@ public:
* cleared right after the @ref execute call by the recompute mechanism.
* See Document::recompute() and DocumentObject::purgeTouched().
*/
App::DocumentObjectExecReturn *execute() override;
App::DocumentObjectExecReturn* execute() override;
/**
* @brief Calculates scale factor based on length of edge.
@@ -154,12 +156,12 @@ public:
*/
int calcDrawScaleFactor() const;
const char* getViewProviderName() const override {
const char* getViewProviderName() const override
{
return "FemGui::ViewProviderFemConstraint";
}
protected:
/**
* @brief Updates NormalDirection if References change.
*/
@@ -208,10 +210,9 @@ protected:
* returns true. If an error occurred and the data couldn't be extracted
* properly false is returned.
*/
bool getPoints(
std::vector<Base::Vector3d>& points,
std::vector<Base::Vector3d>& normals,
int * scale) const;
bool getPoints(std::vector<Base::Vector3d>& points,
std::vector<Base::Vector3d>& normals,
int* scale) const;
/**
* @brief Extract properties of cylindrical face.
@@ -220,9 +221,8 @@ protected:
* This method is very specific and doesn't require access to member
* variables. It should be rewritten at a different place.
*/
bool getCylinder(
double& radius, double& height,
Base::Vector3d& base, Base::Vector3d& axis) const;
bool
getCylinder(double& radius, double& height, Base::Vector3d& base, Base::Vector3d& axis) const;
/**
* @brief Calculate point of cylindrical face where to render widget.
@@ -231,8 +231,10 @@ protected:
* This method is very specific and doesn't require access to member
* variables. It should be rewritten at a different place.
*/
Base::Vector3d getBasePoint(const Base::Vector3d& base, const Base::Vector3d& axis,
const App::PropertyLinkSub &location, const double& dist);
Base::Vector3d getBasePoint(const Base::Vector3d& base,
const Base::Vector3d& axis,
const App::PropertyLinkSub& location,
const double& dist);
/**
* @brief Get normal vector of point calculated by @ref getBasePoint.
*
@@ -240,13 +242,13 @@ protected:
* This method is very specific and doesn't require access to member
* variables. It should be rewritten at a different place.
*/
const Base::Vector3d getDirection(const App::PropertyLinkSub &direction);
const Base::Vector3d getDirection(const App::PropertyLinkSub& direction);
};
using ConstraintPython = App::FeaturePythonT<Constraint>;
} //namespace Fem
} // namespace Fem
#endif // FEM_CONSTRAINT_H
#endif // FEM_CONSTRAINT_H

View File

@@ -40,19 +40,28 @@ PROPERTY_SOURCE(Fem::ConstraintBearing, Fem::Constraint)
ConstraintBearing::ConstraintBearing()
{
ADD_PROPERTY_TYPE(Location,(nullptr),"ConstraintBearing",(App::PropertyType)(App::Prop_None),
ADD_PROPERTY_TYPE(Location,
(nullptr),
"ConstraintBearing",
(App::PropertyType)(App::Prop_None),
"Element giving axial location of constraint");
ADD_PROPERTY(Dist,(0.0));
ADD_PROPERTY(AxialFree,(0));
ADD_PROPERTY(Radius,(0.0));
ADD_PROPERTY(Height,(0.0));
ADD_PROPERTY_TYPE(BasePoint,(Base::Vector3d(0,0,0)),"ConstraintBearing",App::PropertyType(App::Prop_ReadOnly|App::Prop_Output),
ADD_PROPERTY(Dist, (0.0));
ADD_PROPERTY(AxialFree, (0));
ADD_PROPERTY(Radius, (0.0));
ADD_PROPERTY(Height, (0.0));
ADD_PROPERTY_TYPE(BasePoint,
(Base::Vector3d(0, 0, 0)),
"ConstraintBearing",
App::PropertyType(App::Prop_ReadOnly | App::Prop_Output),
"Base point of cylindrical bearing seat");
ADD_PROPERTY_TYPE(Axis,(Base::Vector3d(0,1,0)),"ConstraintBearing",App::PropertyType(App::Prop_ReadOnly|App::Prop_Output),
ADD_PROPERTY_TYPE(Axis,
(Base::Vector3d(0, 1, 0)),
"ConstraintBearing",
App::PropertyType(App::Prop_ReadOnly | App::Prop_Output),
"Axis of bearing seat");
}
App::DocumentObjectExecReturn *ConstraintBearing::execute()
App::DocumentObjectExecReturn* ConstraintBearing::execute()
{
return Constraint::execute();
}
@@ -67,19 +76,21 @@ void ConstraintBearing::onChanged(const App::Property* prop)
// Find data of cylinder
double radius, height;
Base::Vector3d base, axis;
if (!getCylinder(radius, height, base, axis))
if (!getCylinder(radius, height, base, axis)) {
return;
}
Radius.setValue(radius);
Axis.setValue(axis);
Height.setValue(height);
// Update base point
base = base + axis * height/2;
base = base + axis * height / 2;
if (Location.getValue()) {
base = getBasePoint(base, axis, Location, Dist.getValue());
}
BasePoint.setValue(base);
BasePoint.touch(); // This triggers ViewProvider::updateData()
} else if ((prop == &Location) || (prop == &Dist)) {
BasePoint.touch(); // This triggers ViewProvider::updateData()
}
else if ((prop == &Location) || (prop == &Dist)) {
App::DocumentObject* obj = Location.getValue();
std::vector<std::string> names = Location.getSubValues();
if (names.empty()) {
@@ -92,20 +103,22 @@ void ConstraintBearing::onChanged(const App::Property* prop)
if (sh.ShapeType() == TopAbs_FACE) {
BRepAdaptor_Surface surface(TopoDS::Face(sh));
if (surface.GetType() != GeomAbs_Plane) {
return; // "Location must be a planar face or linear edge"
return; // "Location must be a planar face or linear edge"
}
} else if (sh.ShapeType() == TopAbs_EDGE) {
}
else if (sh.ShapeType() == TopAbs_EDGE) {
BRepAdaptor_Curve line(TopoDS::Edge(sh));
if (line.GetType() != GeomAbs_Line) {
return; // "Location must be a planar face or linear edge"
return; // "Location must be a planar face or linear edge"
}
}
double radius, height;
Base::Vector3d base, axis;
if (!getCylinder(radius, height, base, axis))
if (!getCylinder(radius, height, base, axis)) {
return;
base = getBasePoint(base + axis * height/2, axis, Location, Dist.getValue());
}
base = getBasePoint(base + axis * height / 2, axis, Location, Dist.getValue());
BasePoint.setValue(base);
BasePoint.touch();
}

View File

@@ -33,7 +33,7 @@
namespace Fem
{
class FemExport ConstraintBearing : public Fem::Constraint
class FemExport ConstraintBearing: public Fem::Constraint
{
PROPERTY_HEADER_WITH_OVERRIDE(Fem::ConstraintBearing);
@@ -54,10 +54,11 @@ public:
App::PropertyVector Axis;
/// recalculate the object
App::DocumentObjectExecReturn *execute() override;
App::DocumentObjectExecReturn* execute() override;
/// returns the type name of the ViewProvider
const char* getViewProviderName() const override {
const char* getViewProviderName() const override
{
return "FemGui::ViewProviderFemConstraintBearing";
}
@@ -65,7 +66,7 @@ protected:
void onChanged(const App::Property* prop) override;
};
} //namespace Fem
} // namespace Fem
#endif // FEM_CONSTRAINTBEARING_H
#endif // FEM_CONSTRAINTBEARING_H

View File

@@ -32,20 +32,26 @@ PROPERTY_SOURCE(Fem::ConstraintContact, Fem::Constraint)
ConstraintContact::ConstraintContact()
{
/*Note: Initialise parameters here*/
ADD_PROPERTY(Slope,(0.0));
ADD_PROPERTY(Friction,(0.0));
/* */
/*Note: Initialise parameters here*/
ADD_PROPERTY(Slope, (0.0));
ADD_PROPERTY(Friction, (0.0));
/* */
ADD_PROPERTY_TYPE(Points,(Base::Vector3d()),"ConstraintContact",App::PropertyType(App::Prop_ReadOnly|App::Prop_Output),
ADD_PROPERTY_TYPE(Points,
(Base::Vector3d()),
"ConstraintContact",
App::PropertyType(App::Prop_ReadOnly | App::Prop_Output),
"Points where symbols are drawn");
ADD_PROPERTY_TYPE(Normals,(Base::Vector3d()),"ConstraintContact",App::PropertyType(App::Prop_ReadOnly|App::Prop_Output),
"Normals where symbols are drawn");
ADD_PROPERTY_TYPE(Normals,
(Base::Vector3d()),
"ConstraintContact",
App::PropertyType(App::Prop_ReadOnly | App::Prop_Output),
"Normals where symbols are drawn");
Points.setValues(std::vector<Base::Vector3d>());
Normals.setValues(std::vector<Base::Vector3d>());
}
App::DocumentObjectExecReturn *ConstraintContact::execute()
App::DocumentObjectExecReturn* ConstraintContact::execute()
{
return Constraint::execute();
}
@@ -62,12 +68,12 @@ void ConstraintContact::onChanged(const App::Property* prop)
if (prop == &References) {
std::vector<Base::Vector3d> points;
std::vector<Base::Vector3d> normals;
int scale = 1; //OvG: Enforce use of scale
int scale = 1; // OvG: Enforce use of scale
if (getPoints(points, normals, &scale)) {
Points.setValues(points);
Normals.setValues(normals);
Scale.setValue(scale); //OvG: Scale
Points.touch(); // This triggers ViewProvider::updateData()
Scale.setValue(scale); // OvG: Scale
Points.touch(); // This triggers ViewProvider::updateData()
}
}
}

View File

@@ -30,7 +30,7 @@
namespace Fem
{
class FemExport ConstraintContact : public Fem::Constraint
class FemExport ConstraintContact: public Fem::Constraint
{
PROPERTY_HEADER_WITH_OVERRIDE(Fem::ConstraintContact);
@@ -42,32 +42,31 @@ public:
App::PropertyVectorList Points;
App::PropertyVectorList Normals;
/*Note*/
//Constraint parameters
/*Note*/
// Constraint parameters
/******
* Add the constraint parameters here, the variables or data
* that needs to be eventually send over to the calculix input file.
* This is only the definitions of the variables
******/
//ex.
// ex.
App::PropertyFloat Slope;
App::PropertyFloat Friction;
//etc
/* */
// etc
/* */
/// recalculate the object
App::DocumentObjectExecReturn *execute() override;
App::DocumentObjectExecReturn* execute() override;
/// returns the type name of the ViewProvider
const char* getViewProviderName() const override;
protected:
void onChanged(const App::Property* prop) override;
};
} //namespace Fem
} // namespace Fem
#endif // FEM_CONSTRAINTCONTACT_H
#endif // FEM_CONSTRAINTCONTACT_H

View File

@@ -94,7 +94,7 @@ ConstraintDisplacement::ConstraintDisplacement()
Normals.setValues(std::vector<Base::Vector3d>());
}
App::DocumentObjectExecReturn *ConstraintDisplacement::execute()
App::DocumentObjectExecReturn* ConstraintDisplacement::execute()
{
return Constraint::execute();
}
@@ -105,8 +105,8 @@ const char* ConstraintDisplacement::getViewProviderName() const
}
void ConstraintDisplacement::handleChangedPropertyType(Base::XMLReader& reader,
const char* TypeName,
App::Property* prop)
const char* TypeName,
App::Property* prop)
{
// properties _Displacement had App::PropertyFloat and were changed to App::PropertyDistance
if (prop == &xDisplacement && strcmp(TypeName, "App::PropertyFloat") == 0) {
@@ -152,12 +152,12 @@ void ConstraintDisplacement::onChanged(const App::Property* prop)
if (prop == &References) {
std::vector<Base::Vector3d> points;
std::vector<Base::Vector3d> normals;
int scale = 1; // OvG: Enforce use of scale
int scale = 1; // OvG: Enforce use of scale
if (getPoints(points, normals, &scale)) {
Points.setValues(points);
Normals.setValues(normals);
Scale.setValue(scale); // OvG: Scale
Points.touch(); // This triggers ViewProvider::updateData()
Scale.setValue(scale); // OvG: Scale
Points.touch(); // This triggers ViewProvider::updateData()
}
}
}

View File

@@ -32,7 +32,7 @@
namespace Fem
{
class FemExport ConstraintDisplacement : public Fem::Constraint
class FemExport ConstraintDisplacement: public Fem::Constraint
{
PROPERTY_HEADER_WITH_OVERRIDE(Fem::ConstraintDisplacement);
@@ -44,7 +44,7 @@ public:
App::PropertyVectorList Points;
App::PropertyVectorList Normals;
//Displacement parameters
// Displacement parameters
App::PropertyDistance xDisplacement;
App::PropertyDistance yDisplacement;
App::PropertyDistance zDisplacement;
@@ -72,19 +72,19 @@ public:
App::PropertyBool useFlowSurfaceForce;
/// recalculate the object
App::DocumentObjectExecReturn *execute() override;
App::DocumentObjectExecReturn* execute() override;
/// returns the type name of the ViewProvider
const char* getViewProviderName() const override;
protected:
void handleChangedPropertyType(Base::XMLReader& reader, const char* TypeName,
void handleChangedPropertyType(Base::XMLReader& reader,
const char* TypeName,
App::Property* prop) override;
void onChanged(const App::Property* prop) override;
};
} //namespace Fem
} // namespace Fem
#endif // FEM_CONSTRAINTDISPLACEMENT_H
#endif // FEM_CONSTRAINTDISPLACEMENT_H

View File

@@ -32,15 +32,21 @@ PROPERTY_SOURCE(Fem::ConstraintFixed, Fem::Constraint)
ConstraintFixed::ConstraintFixed()
{
ADD_PROPERTY_TYPE(Points,(Base::Vector3d()),"ConstraintFixed",App::PropertyType(App::Prop_ReadOnly|App::Prop_Output),
ADD_PROPERTY_TYPE(Points,
(Base::Vector3d()),
"ConstraintFixed",
App::PropertyType(App::Prop_ReadOnly | App::Prop_Output),
"Points where symbols are drawn");
ADD_PROPERTY_TYPE(Normals,(Base::Vector3d()),"ConstraintFixed",App::PropertyType(App::Prop_ReadOnly|App::Prop_Output),
"Normals where symbols are drawn");
ADD_PROPERTY_TYPE(Normals,
(Base::Vector3d()),
"ConstraintFixed",
App::PropertyType(App::Prop_ReadOnly | App::Prop_Output),
"Normals where symbols are drawn");
Points.setValues(std::vector<Base::Vector3d>());
Normals.setValues(std::vector<Base::Vector3d>());
}
App::DocumentObjectExecReturn *ConstraintFixed::execute()
App::DocumentObjectExecReturn* ConstraintFixed::execute()
{
return Constraint::execute();
}
@@ -54,12 +60,12 @@ void ConstraintFixed::onChanged(const App::Property* prop)
if (prop == &References) {
std::vector<Base::Vector3d> points;
std::vector<Base::Vector3d> normals;
int scale = 1; //OvG: Enforce use of scale
int scale = 1; // OvG: Enforce use of scale
if (getPoints(points, normals, &scale)) {
Points.setValues(points);
Normals.setValues(normals);
Scale.setValue(scale); //OvG: Scale
Points.touch(); // This triggers ViewProvider::updateData()
Scale.setValue(scale); // OvG: Scale
Points.touch(); // This triggers ViewProvider::updateData()
}
}
}

View File

@@ -30,7 +30,7 @@
namespace Fem
{
class FemExport ConstraintFixed : public Fem::Constraint
class FemExport ConstraintFixed: public Fem::Constraint
{
PROPERTY_HEADER_WITH_OVERRIDE(Fem::ConstraintFixed);
@@ -43,10 +43,11 @@ public:
App::PropertyVectorList Normals;
/// recalculate the object
App::DocumentObjectExecReturn *execute() override;
App::DocumentObjectExecReturn* execute() override;
/// returns the type name of the ViewProvider
const char* getViewProviderName() const override {
const char* getViewProviderName() const override
{
return "FemGui::ViewProviderFemConstraintFixed";
}
@@ -54,7 +55,7 @@ protected:
void onChanged(const App::Property* prop) override;
};
} //namespace Fem
} // namespace Fem
#endif // FEM_CONSTRAINTFIXED_H
#endif // FEM_CONSTRAINTFIXED_H

View File

@@ -24,7 +24,7 @@
#include "PreCompiled.h"
#ifndef _PreComp_
# include <Precision.hxx>
#include <Precision.hxx>
#endif
#include <Base/Console.h>
@@ -36,6 +36,7 @@ using namespace Fem;
PROPERTY_SOURCE(Fem::ConstraintFluidBoundary, Fem::Constraint)
// clang-format off
// see forum topic: https://forum.freecad.org/viewtopic.php?&p=407901
// also defined in TaskFemConstraintFluidBoundary.cpp and FoamCaseBuilder/BasicBuilder.py, update simultaneously
@@ -58,9 +59,11 @@ static const char* ThermalBoundaryTypes[] = {"fixedValue","zeroGradient", "fixed
static const char* ThermalBoundaryHelpTexts[] = {"fixed Temperature [K]", "no heat transfer ()", "fixed value heat flux [K/m]",
"mixed fixedGradient and fixedValue", "fixed heat flux [W/m2]", "Heat transfer coeff [W/(M2)/K]", "conjugate heat transfer with solid", NULL};
*/
// clang-format on
ConstraintFluidBoundary::ConstraintFluidBoundary()
{
// clang-format off
/// momentum boundary: pressure and velocity
ADD_PROPERTY_TYPE(BoundaryType,(1),"FluidBoundary",(App::PropertyType)(App::Prop_None),
"Basic boundary type like inlet, wall, outlet,etc");
@@ -104,9 +107,10 @@ ConstraintFluidBoundary::ConstraintFluidBoundary()
ADD_PROPERTY_TYPE(Normals,(Base::Vector3d()),"FluidBoundary",App::PropertyType(App::Prop_ReadOnly|App::Prop_Output),
"Normals where symbols are drawn");
Normals.setValues(std::vector<Base::Vector3d>());
// clang-format on
}
App::DocumentObjectExecReturn *ConstraintFluidBoundary::execute()
App::DocumentObjectExecReturn* ConstraintFluidBoundary::execute()
{
return Constraint::execute();
}
@@ -128,40 +132,47 @@ void ConstraintFluidBoundary::onChanged(const App::Property* prop)
else if (boundaryType == "freestream") {
Subtype.setEnums(FreestreamSubtypes);
}
else if(boundaryType == "inlet") {
else if (boundaryType == "inlet") {
Subtype.setEnums(InletSubtypes);
}
else if(boundaryType == "outlet") {
else if (boundaryType == "outlet") {
Subtype.setEnums(OutletSubtypes);
}
else {
Base::Console().Message(boundaryType.c_str());
Base::Console().Message(" Error: this boundaryType is not defined\n");
}
Subtype.setValue(1); // must set a default (0 or 1) as freestream has only 2 subtypes
// must set a default (0 or 1) as freestream has only 2 subtypes
Subtype.setValue(1);
// need to trigger ViewProvider::updateData() for redraw in 3D view after this method
}
//naturalDirectionVector is a private member of this class
// naturalDirectionVector is a private member of this class
if (prop == &References) {
std::vector<Base::Vector3d> points;
std::vector<Base::Vector3d> normals;
int scale = 1; //OvG: Enforce use of scale
int scale = 1; // OvG: Enforce use of scale
if (getPoints(points, normals, &scale)) {
Points.setValues(points);
Normals.setValues(normals);
Scale.setValue(scale); //OvG: Scale
Points.touch(); // This triggers ViewProvider::updateData()
Scale.setValue(scale); // OvG: Scale
Points.touch(); // This triggers ViewProvider::updateData()
}
} else if (prop == &Direction) {
Base::Vector3d direction = getDirection(Direction); // Fem::Constraint
if (direction.Length() < Precision::Confusion()) // if Direct has no link provided return Base::Vector3d(0,0,0);
}
else if (prop == &Direction) {
Base::Vector3d direction = getDirection(Direction);
// if Direct has no link provided return Base::Vector3d(0,0,0);
if (direction.Length() < Precision::Confusion()) {
return;
}
naturalDirectionVector = direction;
if (Reversed.getValue())
if (Reversed.getValue()) {
direction = -direction;
}
DirectionVector.setValue(direction);
} else if (prop == &Reversed) {
}
else if (prop == &Reversed) {
// if the direction is invalid try to compute it again
if (naturalDirectionVector.Length() < Precision::Confusion()) {
naturalDirectionVector = getDirection(Direction);
@@ -169,16 +180,20 @@ void ConstraintFluidBoundary::onChanged(const App::Property* prop)
if (naturalDirectionVector.Length() >= Precision::Confusion()) {
if (Reversed.getValue() && (DirectionVector.getValue() == naturalDirectionVector)) {
DirectionVector.setValue(-naturalDirectionVector);
} else if (!Reversed.getValue() && (DirectionVector.getValue() != naturalDirectionVector)) {
}
else if (!Reversed.getValue()
&& (DirectionVector.getValue() != naturalDirectionVector)) {
DirectionVector.setValue(naturalDirectionVector);
}
}
} else if (prop == &NormalDirection) {
}
else if (prop == &NormalDirection) {
// Set a default direction if no direction reference has been given
if (!Direction.getValue()) {
Base::Vector3d direction = NormalDirection.getValue();
if (Reversed.getValue())
if (Reversed.getValue()) {
direction = -direction;
}
DirectionVector.setValue(direction);
naturalDirectionVector = direction;
}

View File

@@ -55,14 +55,15 @@ public:
App::PropertyBool Reversed;
// Read-only (calculated values). These trigger changes in the ViewProvider
App::PropertyVectorList Points;
App::PropertyVectorList Normals; // needed to draw diff BoundaryType
App::PropertyVectorList Normals; // needed to draw diff BoundaryType
App::PropertyVector DirectionVector;
/// recalculate the object
App::DocumentObjectExecReturn *execute() override;
App::DocumentObjectExecReturn* execute() override;
/// returns the type name of the ViewProvider
const char* getViewProviderName() const override {
const char* getViewProviderName() const override
{
return "FemGui::ViewProviderFemConstraintFluidBoundary";
}
@@ -73,7 +74,7 @@ private:
Base::Vector3d naturalDirectionVector;
};
} //namespace Fem
} // namespace Fem
#endif // FEM_FLUIDBOUNDARY_H
#endif // FEM_FLUIDBOUNDARY_H

View File

@@ -24,7 +24,7 @@
#include "PreCompiled.h"
#ifndef _PreComp_
# include <Precision.hxx>
#include <Precision.hxx>
#endif
#include "FemConstraintForce.h"
@@ -36,19 +36,29 @@ PROPERTY_SOURCE(Fem::ConstraintForce, Fem::Constraint)
ConstraintForce::ConstraintForce()
{
ADD_PROPERTY(Force,(0.0));
ADD_PROPERTY_TYPE(Direction,(nullptr),"ConstraintForce",(App::PropertyType)(App::Prop_None),
ADD_PROPERTY(Force, (0.0));
ADD_PROPERTY_TYPE(Direction,
(nullptr),
"ConstraintForce",
(App::PropertyType)(App::Prop_None),
"Element giving direction of constraint");
ADD_PROPERTY(Reversed,(0));
ADD_PROPERTY_TYPE(Points,(Base::Vector3d()),"ConstraintForce",App::PropertyType(App::Prop_ReadOnly|App::Prop_Output),
ADD_PROPERTY(Reversed, (0));
ADD_PROPERTY_TYPE(Points,
(Base::Vector3d()),
"ConstraintForce",
App::PropertyType(App::Prop_ReadOnly | App::Prop_Output),
"Points where arrows are drawn");
ADD_PROPERTY_TYPE(DirectionVector,(Base::Vector3d(0,0,1)),"ConstraintForce",App::PropertyType(App::Prop_ReadOnly|App::Prop_Output),
ADD_PROPERTY_TYPE(DirectionVector,
(Base::Vector3d(0, 0, 1)),
"ConstraintForce",
App::PropertyType(App::Prop_ReadOnly | App::Prop_Output),
"Direction of arrows");
naturalDirectionVector = Base::Vector3d(0,0,0); // by default use the null vector to indicate an invalid value
naturalDirectionVector =
Base::Vector3d(0, 0, 0); // by default use the null vector to indicate an invalid value
Points.setValues(std::vector<Base::Vector3d>());
}
App::DocumentObjectExecReturn *ConstraintForce::execute()
App::DocumentObjectExecReturn* ConstraintForce::execute()
{
return Constraint::execute();
}
@@ -62,21 +72,27 @@ void ConstraintForce::onChanged(const App::Property* prop)
if (prop == &References) {
std::vector<Base::Vector3d> points;
std::vector<Base::Vector3d> normals;
int scale = 1; //OvG: Enforce use of scale
int scale = 1; // OvG: Enforce use of scale
if (getPoints(points, normals, &scale)) {
Points.setValues(points); // We don't use the normals because all arrows should have the same direction
Scale.setValue(scale); //OvG Scale
// We don't use the normals because all arrows should have
// the same direction
Points.setValues(points);
Scale.setValue(scale);
Points.touch();
}
} else if (prop == &Direction) {
}
else if (prop == &Direction) {
Base::Vector3d direction = getDirection(Direction);
if (direction.Length() < Precision::Confusion())
if (direction.Length() < Precision::Confusion()) {
return;
}
naturalDirectionVector = direction;
if (Reversed.getValue())
if (Reversed.getValue()) {
direction = -direction;
}
DirectionVector.setValue(direction);
} else if (prop == &Reversed) {
}
else if (prop == &Reversed) {
// if the direction is invalid try to compute it again
if (naturalDirectionVector.Length() < Precision::Confusion()) {
naturalDirectionVector = getDirection(Direction);
@@ -84,16 +100,20 @@ void ConstraintForce::onChanged(const App::Property* prop)
if (naturalDirectionVector.Length() >= Precision::Confusion()) {
if (Reversed.getValue() && (DirectionVector.getValue() == naturalDirectionVector)) {
DirectionVector.setValue(-naturalDirectionVector);
} else if (!Reversed.getValue() && (DirectionVector.getValue() != naturalDirectionVector)) {
}
else if (!Reversed.getValue()
&& (DirectionVector.getValue() != naturalDirectionVector)) {
DirectionVector.setValue(naturalDirectionVector);
}
}
} else if (prop == &NormalDirection) {
}
else if (prop == &NormalDirection) {
// Set a default direction if no direction reference has been given
if (!Direction.getValue()) {
Base::Vector3d direction = NormalDirection.getValue();
if (Reversed.getValue())
if (Reversed.getValue()) {
direction = -direction;
}
DirectionVector.setValue(direction);
naturalDirectionVector = direction;
}

View File

@@ -30,7 +30,7 @@
namespace Fem
{
class FemExport ConstraintForce : public Fem::Constraint
class FemExport ConstraintForce: public Fem::Constraint
{
PROPERTY_HEADER_WITH_OVERRIDE(Fem::ConstraintForce);
@@ -46,10 +46,11 @@ public:
App::PropertyVector DirectionVector;
/// recalculate the object
App::DocumentObjectExecReturn *execute() override;
App::DocumentObjectExecReturn* execute() override;
/// returns the type name of the ViewProvider
const char* getViewProviderName() const override {
const char* getViewProviderName() const override
{
return "FemGui::ViewProviderFemConstraintForce";
}
@@ -60,7 +61,7 @@ private:
Base::Vector3d naturalDirectionVector;
};
} //namespace Fem
} // namespace Fem
#endif // FEM_CONSTRAINTFORCE_H
#endif // FEM_CONSTRAINTFORCE_H

View File

@@ -24,7 +24,7 @@
#include "PreCompiled.h"
#ifndef _PreComp_
# include <Precision.hxx>
#include <Precision.hxx>
#endif
#include "FemConstraintGear.h"
@@ -36,18 +36,24 @@ PROPERTY_SOURCE(Fem::ConstraintGear, Fem::ConstraintBearing)
ConstraintGear::ConstraintGear()
{
ADD_PROPERTY(Diameter,(100.0));
ADD_PROPERTY(Force,(1000.0));
ADD_PROPERTY(ForceAngle,(0.0));
ADD_PROPERTY_TYPE(Direction,(nullptr),"ConstraintGear",(App::PropertyType)(App::Prop_None),
ADD_PROPERTY(Diameter, (100.0));
ADD_PROPERTY(Force, (1000.0));
ADD_PROPERTY(ForceAngle, (0.0));
ADD_PROPERTY_TYPE(Direction,
(nullptr),
"ConstraintGear",
(App::PropertyType)(App::Prop_None),
"Element giving direction of gear force");
ADD_PROPERTY(Reversed,(0));
ADD_PROPERTY_TYPE(DirectionVector,(Base::Vector3d(1,1,1).Normalize()),"ConstraintGear",App::PropertyType(App::Prop_ReadOnly|App::Prop_Output),
ADD_PROPERTY(Reversed, (0));
ADD_PROPERTY_TYPE(DirectionVector,
(Base::Vector3d(1, 1, 1).Normalize()),
"ConstraintGear",
App::PropertyType(App::Prop_ReadOnly | App::Prop_Output),
"Direction of gear force");
naturalDirectionVector = Base::Vector3d(1,1,1).Normalize();
naturalDirectionVector = Base::Vector3d(1, 1, 1).Normalize();
}
App::DocumentObjectExecReturn *ConstraintGear::execute()
App::DocumentObjectExecReturn* ConstraintGear::execute()
{
return ConstraintBearing::execute();
}
@@ -58,18 +64,22 @@ void ConstraintGear::onChanged(const App::Property* prop)
if (prop == &Direction) {
Base::Vector3d direction = getDirection(Direction);
if (direction.Length() < Precision::Confusion())
if (direction.Length() < Precision::Confusion()) {
return;
}
naturalDirectionVector = direction;
if (Reversed.getValue())
if (Reversed.getValue()) {
direction = -direction;
}
DirectionVector.setValue(direction);
DirectionVector.touch();
} else if (prop == &Reversed) {
}
else if (prop == &Reversed) {
if (Reversed.getValue() && (DirectionVector.getValue() == naturalDirectionVector)) {
DirectionVector.setValue(-naturalDirectionVector);
DirectionVector.touch();
} else if (!Reversed.getValue() && (DirectionVector.getValue() != naturalDirectionVector)) {
}
else if (!Reversed.getValue() && (DirectionVector.getValue() != naturalDirectionVector)) {
DirectionVector.setValue(naturalDirectionVector);
DirectionVector.touch();
}

View File

@@ -30,7 +30,7 @@
namespace Fem
{
class FemExport ConstraintGear : public Fem::ConstraintBearing
class FemExport ConstraintGear: public Fem::ConstraintBearing
{
PROPERTY_HEADER_WITH_OVERRIDE(Fem::ConstraintGear);
@@ -47,10 +47,11 @@ public:
App::PropertyVector DirectionVector;
/// recalculate the object
App::DocumentObjectExecReturn *execute() override;
App::DocumentObjectExecReturn* execute() override;
/// returns the type name of the ViewProvider
const char* getViewProviderName() const override {
const char* getViewProviderName() const override
{
return "FemGui::ViewProviderFemConstraintGear";
}
@@ -61,7 +62,7 @@ private:
Base::Vector3d naturalDirectionVector;
};
} //namespace Fem
} // namespace Fem
#endif // FEM_CONSTRAINTGear_H
#endif // FEM_CONSTRAINTGear_H

View File

@@ -31,27 +31,36 @@ using namespace Fem;
PROPERTY_SOURCE(Fem::ConstraintHeatflux, Fem::Constraint)
static const char* ConstraintTypes[] = {"DFlux","Convection", nullptr};
static const char* ConstraintTypes[] = {"DFlux", "Convection", nullptr};
ConstraintHeatflux::ConstraintHeatflux()
{
ADD_PROPERTY(AmbientTemp,(0.0));
ADD_PROPERTY(AmbientTemp, (0.0));
/*ADD_PROPERTY(FaceTemp,(0.0));*/
ADD_PROPERTY(FilmCoef,(0.0));
ADD_PROPERTY(DFlux,(0.0));
ADD_PROPERTY_TYPE(ConstraintType,(1),"ConstraintHeatflux",(App::PropertyType)(App::Prop_None),
ADD_PROPERTY(FilmCoef, (0.0));
ADD_PROPERTY(DFlux, (0.0));
ADD_PROPERTY_TYPE(ConstraintType,
(1),
"ConstraintHeatflux",
(App::PropertyType)(App::Prop_None),
"Type of constraint, surface convection or surface heat flux");
ConstraintType.setEnums(ConstraintTypes);
ADD_PROPERTY_TYPE(Points,(Base::Vector3d()),"ConstraintHeatflux",App::PropertyType(App::Prop_ReadOnly|App::Prop_Output),
ADD_PROPERTY_TYPE(Points,
(Base::Vector3d()),
"ConstraintHeatflux",
App::PropertyType(App::Prop_ReadOnly | App::Prop_Output),
"Points where symbols are drawn");
ADD_PROPERTY_TYPE(Normals,(Base::Vector3d()),"ConstraintHeatflux",App::PropertyType(App::Prop_ReadOnly|App::Prop_Output),
"Normals where symbols are drawn");
ADD_PROPERTY_TYPE(Normals,
(Base::Vector3d()),
"ConstraintHeatflux",
App::PropertyType(App::Prop_ReadOnly | App::Prop_Output),
"Normals where symbols are drawn");
Points.setValues(std::vector<Base::Vector3d>());
Normals.setValues(std::vector<Base::Vector3d>());
}
App::DocumentObjectExecReturn *ConstraintHeatflux::execute()
App::DocumentObjectExecReturn* ConstraintHeatflux::execute()
{
return Constraint::execute();
}
@@ -70,12 +79,12 @@ void ConstraintHeatflux::onChanged(const App::Property* prop)
if (prop == &References) {
std::vector<Base::Vector3d> points;
std::vector<Base::Vector3d> normals;
int scale = 1; //OvG: Enforce use of scale
int scale = 1; // OvG: Enforce use of scale
if (getPoints(points, normals, &scale)) {
Points.setValues(points);
Normals.setValues(normals);
Scale.setValue(scale); //OvG: Scale
Points.touch(); // This triggers ViewProvider::updateData()
Scale.setValue(scale); // OvG: Scale
Points.touch(); // This triggers ViewProvider::updateData()
}
}
}

View File

@@ -29,9 +29,10 @@
#include "FemConstraint.h"
namespace Fem {
namespace Fem
{
class FemExport ConstraintHeatflux : public Fem::Constraint
class FemExport ConstraintHeatflux: public Fem::Constraint
{
PROPERTY_HEADER_WITH_OVERRIDE(Fem::ConstraintHeatflux);
@@ -48,7 +49,7 @@ public:
App::PropertyVectorList Normals;
/// recalculate the object
App::DocumentObjectExecReturn *execute() override;
App::DocumentObjectExecReturn* execute() override;
/// returns the type name of the ViewProvider
const char* getViewProviderName() const override;
@@ -57,6 +58,6 @@ protected:
void onChanged(const App::Property* prop) override;
};
}
} // namespace Fem
#endif // FEM_CONSTRAINTHEATFLUX_H
#endif // FEM_CONSTRAINTHEATFLUX_H

View File

@@ -36,11 +36,13 @@ ConstraintInitialTemperature::ConstraintInitialTemperature()
{
ADD_PROPERTY(initialTemperature, (300.0));
ADD_PROPERTY_TYPE(Points, (Base::Vector3d()),
ADD_PROPERTY_TYPE(Points,
(Base::Vector3d()),
"ConstraintInitialTemperature",
App::PropertyType(App::Prop_ReadOnly | App::Prop_Output),
"Points where symbols are drawn");
ADD_PROPERTY_TYPE(Normals, (Base::Vector3d()),
ADD_PROPERTY_TYPE(Normals,
(Base::Vector3d()),
"ConstraintInitialTemperature",
App::PropertyType(App::Prop_ReadOnly | App::Prop_Output),
"Normals where symbols are drawn");
@@ -51,7 +53,7 @@ ConstraintInitialTemperature::ConstraintInitialTemperature()
References.setStatus(App::Property::Hidden, true);
}
App::DocumentObjectExecReturn *ConstraintInitialTemperature::execute()
App::DocumentObjectExecReturn* ConstraintInitialTemperature::execute()
{
return Constraint::execute();
}
@@ -83,12 +85,12 @@ void ConstraintInitialTemperature::onChanged(const App::Property* prop)
if (prop == &References) {
std::vector<Base::Vector3d> points;
std::vector<Base::Vector3d> normals;
int scale = 1; //OvG: Enforce use of scale
int scale = 1; // OvG: Enforce use of scale
if (getPoints(points, normals, &scale)) {
Points.setValues(points);
Normals.setValues(normals);
Scale.setValue(scale); //OvG: Scale
Points.touch(); // This triggers ViewProvider::updateData()
Scale.setValue(scale); // OvG: Scale
Points.touch(); // This triggers ViewProvider::updateData()
}
}
}

View File

@@ -32,7 +32,7 @@
namespace Fem
{
class FemExport ConstraintInitialTemperature : public Fem::Constraint
class FemExport ConstraintInitialTemperature: public Fem::Constraint
{
PROPERTY_HEADER_WITH_OVERRIDE(Fem::ConstraintInitialTemperature);
@@ -44,24 +44,24 @@ public:
App::PropertyVectorList Points;
App::PropertyVectorList Normals;
//Temperature parameters
// Temperature parameters
App::PropertyTemperature initialTemperature;
/// recalculate the object
App::DocumentObjectExecReturn *execute() override;
App::DocumentObjectExecReturn* execute() override;
/// returns the type name of the ViewProvider
const char* getViewProviderName() const override;
protected:
void handleChangedPropertyType(Base::XMLReader& reader, const char* TypeName,
void handleChangedPropertyType(Base::XMLReader& reader,
const char* TypeName,
App::Property* prop) override;
void onChanged(const App::Property* prop) override;
};
} //namespace Fem
} // namespace Fem
#endif // FEM_CONSTRAINTINITIALTEMPERATURE_H
#endif // FEM_CONSTRAINTINITIALTEMPERATURE_H

View File

@@ -33,15 +33,21 @@ PROPERTY_SOURCE(Fem::ConstraintPlaneRotation, Fem::Constraint)
ConstraintPlaneRotation::ConstraintPlaneRotation()
{
ADD_PROPERTY_TYPE(Points,(Base::Vector3d()),"ConstraintPlaneRotation",App::PropertyType(App::Prop_ReadOnly|App::Prop_Output),
ADD_PROPERTY_TYPE(Points,
(Base::Vector3d()),
"ConstraintPlaneRotation",
App::PropertyType(App::Prop_ReadOnly | App::Prop_Output),
"Points where symbols are drawn");
ADD_PROPERTY_TYPE(Normals,(Base::Vector3d()),"ConstraintPlaneRotation",App::PropertyType(App::Prop_ReadOnly|App::Prop_Output),
"Normals where symbols are drawn");
ADD_PROPERTY_TYPE(Normals,
(Base::Vector3d()),
"ConstraintPlaneRotation",
App::PropertyType(App::Prop_ReadOnly | App::Prop_Output),
"Normals where symbols are drawn");
Points.setValues(std::vector<Base::Vector3d>());
Normals.setValues(std::vector<Base::Vector3d>());
}
App::DocumentObjectExecReturn *ConstraintPlaneRotation::execute()
App::DocumentObjectExecReturn* ConstraintPlaneRotation::execute()
{
return Constraint::execute();
}
@@ -58,12 +64,12 @@ void ConstraintPlaneRotation::onChanged(const App::Property* prop)
if (prop == &References) {
std::vector<Base::Vector3d> points;
std::vector<Base::Vector3d> normals;
int scale = 1; //OvG: Enforce use of scale
int scale = 1; // OvG: Enforce use of scale
if (getPoints(points, normals, &scale)) {
Points.setValues(points);
Normals.setValues(normals);
Scale.setValue(scale); //OvG: Scale
Points.touch(); // This triggers ViewProvider::updateData()
Scale.setValue(scale); // OvG: Scale
Points.touch(); // This triggers ViewProvider::updateData()
}
}
}

View File

@@ -30,7 +30,7 @@
namespace Fem
{
class FemExport ConstraintPlaneRotation : public Fem::Constraint
class FemExport ConstraintPlaneRotation: public Fem::Constraint
{
PROPERTY_HEADER_WITH_OVERRIDE(Fem::ConstraintPlaneRotation);
@@ -44,17 +44,16 @@ public:
/// recalculate the object
App::DocumentObjectExecReturn *execute() override;
App::DocumentObjectExecReturn* execute() override;
/// returns the type name of the ViewProvider
const char* getViewProviderName() const override;
protected:
void onChanged(const App::Property* prop) override;
};
} //namespace Fem
} // namespace Fem
#endif // FEM_CONSTRAINTPLANEROTATION_H
#endif // FEM_CONSTRAINTPLANEROTATION_H

View File

@@ -32,19 +32,23 @@ PROPERTY_SOURCE(Fem::ConstraintPressure, Fem::Constraint)
ConstraintPressure::ConstraintPressure()
{
ADD_PROPERTY(Pressure,(0.0));
ADD_PROPERTY(Reversed,(0));
ADD_PROPERTY_TYPE(Points,(Base::Vector3d()),"ConstraintPressure",
App::PropertyType(App::Prop_ReadOnly|App::Prop_Output),
"Points where arrows are drawn");
ADD_PROPERTY_TYPE(Normals,(Base::Vector3d()),"ConstraintPressure",
App::PropertyType(App::Prop_ReadOnly|App::Prop_Output),
"Normals where symbols are drawn");
ADD_PROPERTY(Pressure, (0.0));
ADD_PROPERTY(Reversed, (0));
ADD_PROPERTY_TYPE(Points,
(Base::Vector3d()),
"ConstraintPressure",
App::PropertyType(App::Prop_ReadOnly | App::Prop_Output),
"Points where arrows are drawn");
ADD_PROPERTY_TYPE(Normals,
(Base::Vector3d()),
"ConstraintPressure",
App::PropertyType(App::Prop_ReadOnly | App::Prop_Output),
"Normals where symbols are drawn");
Points.setValues(std::vector<Base::Vector3d>());
Normals.setValues(std::vector<Base::Vector3d>());
}
App::DocumentObjectExecReturn *ConstraintPressure::execute()
App::DocumentObjectExecReturn* ConstraintPressure::execute()
{
return Constraint::execute();
}
@@ -68,7 +72,8 @@ void ConstraintPressure::onChanged(const App::Property* prop)
Scale.setValue(scale);
Points.touch();
}
} else if (prop == &Reversed) {
}
else if (prop == &Reversed) {
Points.touch();
}
}

View File

@@ -27,9 +27,10 @@
#include "FemConstraint.h"
namespace Fem {
namespace Fem
{
class FemExport ConstraintPressure : public Fem::Constraint
class FemExport ConstraintPressure: public Fem::Constraint
{
PROPERTY_HEADER_WITH_OVERRIDE(Fem::ConstraintPressure);
@@ -42,7 +43,7 @@ public:
App::PropertyVectorList Normals;
/// recalculate the object
App::DocumentObjectExecReturn *execute() override;
App::DocumentObjectExecReturn* execute() override;
/// returns the type name of the ViewProvider
const char* getViewProviderName() const override;
@@ -51,6 +52,6 @@ protected:
void onChanged(const App::Property* prop) override;
};
}
} // namespace Fem
#endif // FEM_CONSTRAINTPRESSURE_H
#endif // FEM_CONSTRAINTPRESSURE_H

View File

@@ -24,7 +24,7 @@
#include "PreCompiled.h"
#ifndef _PreComp_
# include <Precision.hxx>
#include <Precision.hxx>
#endif
#include "FemConstraintPulley.h"
@@ -36,16 +36,25 @@ PROPERTY_SOURCE(Fem::ConstraintPulley, Fem::ConstraintGear)
ConstraintPulley::ConstraintPulley()
{
ADD_PROPERTY(OtherDiameter,(100.0));
ADD_PROPERTY(CenterDistance,(500.0));
ADD_PROPERTY(IsDriven,(0));
ADD_PROPERTY(TensionForce,(0.0));
ADD_PROPERTY(OtherDiameter, (100.0));
ADD_PROPERTY(CenterDistance, (500.0));
ADD_PROPERTY(IsDriven, (0));
ADD_PROPERTY(TensionForce, (0.0));
ADD_PROPERTY_TYPE(BeltAngle,(0),"ConstraintPulley",App::PropertyType(App::Prop_ReadOnly|App::Prop_Output),
ADD_PROPERTY_TYPE(BeltAngle,
(0),
"ConstraintPulley",
App::PropertyType(App::Prop_ReadOnly | App::Prop_Output),
"Angle of belt forces");
ADD_PROPERTY_TYPE(BeltForce1,(0.0),"ConstraintPulley",App::PropertyType(App::Prop_ReadOnly|App::Prop_Output),
ADD_PROPERTY_TYPE(BeltForce1,
(0.0),
"ConstraintPulley",
App::PropertyType(App::Prop_ReadOnly | App::Prop_Output),
"First belt force");
ADD_PROPERTY_TYPE(BeltForce2,(0.0),"ConstraintPulley",App::PropertyType(App::Prop_ReadOnly|App::Prop_Output),
ADD_PROPERTY_TYPE(BeltForce2,
(0.0),
"ConstraintPulley",
App::PropertyType(App::Prop_ReadOnly | App::Prop_Output),
"Second belt force");
ForceAngle.setValue(0.0);
Diameter.setValue(300.0);
@@ -53,7 +62,7 @@ ConstraintPulley::ConstraintPulley()
onChanged(&Force);
}
App::DocumentObjectExecReturn *ConstraintPulley::execute()
App::DocumentObjectExecReturn* ConstraintPulley::execute()
{
return ConstraintGear::execute();
}
@@ -64,24 +73,30 @@ void ConstraintPulley::onChanged(const App::Property* prop)
if ((prop == &Diameter) || (prop == &OtherDiameter) || (prop == &CenterDistance)) {
if (CenterDistance.getValue() > Precision::Confusion()) {
BeltAngle.setValue(asin((Diameter.getValue() - OtherDiameter.getValue())/2/CenterDistance.getValue()));
BeltAngle.setValue(asin((Diameter.getValue() - OtherDiameter.getValue()) / 2
/ CenterDistance.getValue()));
BeltAngle.touch();
}
} else if ((prop == &Force) || (prop == &TensionForce) || (prop == &IsDriven)) {
}
else if ((prop == &Force) || (prop == &TensionForce) || (prop == &IsDriven)) {
double radius = Diameter.getValue() / 2.0;
if (radius < Precision::Confusion())
if (radius < Precision::Confusion()) {
return;
double force = Force.getValue() / (radius/1000);
if (fabs(force) < Precision::Confusion())
}
double force = Force.getValue() / (radius / 1000);
if (fabs(force) < Precision::Confusion()) {
return;
}
bool neg = (force < 0.0);
if (neg)
if (neg) {
force *= -1.0;
}
if (IsDriven.getValue() == neg) {
BeltForce1.setValue(force + TensionForce.getValue());
BeltForce2.setValue(TensionForce.getValue());
} else {
}
else {
BeltForce2.setValue(force + TensionForce.getValue());
BeltForce1.setValue(TensionForce.getValue());
}

View File

@@ -30,7 +30,7 @@
namespace Fem
{
class FemExport ConstraintPulley : public Fem::ConstraintGear
class FemExport ConstraintPulley: public Fem::ConstraintGear
{
PROPERTY_HEADER_WITH_OVERRIDE(Fem::ConstraintPulley);
@@ -52,19 +52,19 @@ public:
App::PropertyFloat BeltForce2;
/// recalculate the object
App::DocumentObjectExecReturn *execute() override;
App::DocumentObjectExecReturn* execute() override;
/// returns the type name of the ViewProvider
const char* getViewProviderName() const override {
const char* getViewProviderName() const override
{
return "FemGui::ViewProviderFemConstraintPulley";
}
protected:
void onChanged(const App::Property* prop) override;
};
} //namespace Fem
} // namespace Fem
#endif // FEM_CONSTRAINTPulley_H
#endif // FEM_CONSTRAINTPulley_H

View File

@@ -26,8 +26,7 @@
#include "FemConstraintSpring.h"
static const char* Stiffnesses[] = {"Normal Stiffness",
"Tangential Stiffness", nullptr};
static const char* Stiffnesses[] = {"Normal Stiffness", "Tangential Stiffness", nullptr};
using namespace Fem;
@@ -38,12 +37,16 @@ ConstraintSpring::ConstraintSpring()
ADD_PROPERTY(NormalStiffness, (0.0));
ADD_PROPERTY(TangentialStiffness, (0.0));
ADD_PROPERTY(ElmerStiffness, (1));
ADD_PROPERTY_TYPE(Points, (Base::Vector3d()), "ConstraintSpring",
App::PropertyType(App::Prop_ReadOnly | App::Prop_Output),
"Points where arrows are drawn");
ADD_PROPERTY_TYPE(Normals, (Base::Vector3d()), "ConstraintSpring",
App::PropertyType(App::Prop_ReadOnly | App::Prop_Output),
"Normals where symbols are drawn");
ADD_PROPERTY_TYPE(Points,
(Base::Vector3d()),
"ConstraintSpring",
App::PropertyType(App::Prop_ReadOnly | App::Prop_Output),
"Points where arrows are drawn");
ADD_PROPERTY_TYPE(Normals,
(Base::Vector3d()),
"ConstraintSpring",
App::PropertyType(App::Prop_ReadOnly | App::Prop_Output),
"Normals where symbols are drawn");
ElmerStiffness.setEnums(Stiffnesses);
Points.setValues(std::vector<Base::Vector3d>());

View File

@@ -27,9 +27,10 @@
#include "FemConstraint.h"
namespace Fem {
namespace Fem
{
class FemExport ConstraintSpring : public Fem::Constraint
class FemExport ConstraintSpring: public Fem::Constraint
{
PROPERTY_HEADER_WITH_OVERRIDE(Fem::ConstraintSpring);
@@ -43,7 +44,7 @@ public:
App::PropertyVectorList Normals;
/// recalculate the object
App::DocumentObjectExecReturn *execute() override;
App::DocumentObjectExecReturn* execute() override;
/// returns the type name of the ViewProvider
const char* getViewProviderName() const override;
@@ -52,6 +53,6 @@ protected:
void onChanged(const App::Property* prop) override;
};
}
} // namespace Fem
#endif // FEM_CONSTRAINTPSPRING_H
#endif // FEM_CONSTRAINTPSPRING_H

View File

@@ -32,28 +32,34 @@ using namespace Fem;
PROPERTY_SOURCE(Fem::ConstraintTemperature, Fem::Constraint)
static const char* ConstraintTypes[] = {"CFlux","Temperature", nullptr};
static const char* ConstraintTypes[] = {"CFlux", "Temperature", nullptr};
ConstraintTemperature::ConstraintTemperature()
{
ADD_PROPERTY(Temperature, (300.0));
ADD_PROPERTY(CFlux, (0.0));
ADD_PROPERTY_TYPE(ConstraintType, (1), "ConstraintTemperature",
ADD_PROPERTY_TYPE(ConstraintType,
(1),
"ConstraintTemperature",
(App::PropertyType)(App::Prop_None),
"Type of constraint, temperature or concentrated heat flux");
ConstraintType.setEnums(ConstraintTypes);
ADD_PROPERTY_TYPE(Points, (Base::Vector3d()), "ConstraintTemperature",
ADD_PROPERTY_TYPE(Points,
(Base::Vector3d()),
"ConstraintTemperature",
App::PropertyType(App::Prop_ReadOnly | App::Prop_Output),
"Points where symbols are drawn");
ADD_PROPERTY_TYPE(Normals, (Base::Vector3d()), "ConstraintTemperature",
ADD_PROPERTY_TYPE(Normals,
(Base::Vector3d()),
"ConstraintTemperature",
App::PropertyType(App::Prop_ReadOnly | App::Prop_Output),
"Normals where symbols are drawn");
Points.setValues(std::vector<Base::Vector3d>());
Normals.setValues(std::vector<Base::Vector3d>());
}
App::DocumentObjectExecReturn *ConstraintTemperature::execute()
App::DocumentObjectExecReturn* ConstraintTemperature::execute()
{
return Constraint::execute();
}
@@ -63,7 +69,8 @@ const char* ConstraintTemperature::getViewProviderName() const
return "FemGui::ViewProviderFemConstraintTemperature";
}
void ConstraintTemperature::handleChangedPropertyType(Base::XMLReader& reader, const char* TypeName,
void ConstraintTemperature::handleChangedPropertyType(Base::XMLReader& reader,
const char* TypeName,
App::Property* prop)
{
// property Temperature had App::PropertyFloat and was changed to App::PropertyTemperature
@@ -90,12 +97,12 @@ void ConstraintTemperature::onChanged(const App::Property* prop)
if (prop == &References) {
std::vector<Base::Vector3d> points;
std::vector<Base::Vector3d> normals;
int scale = 1; //OvG: Enforce use of scale
int scale = 1; // OvG: Enforce use of scale
if (getPoints(points, normals, &scale)) {
Points.setValues(points);
Normals.setValues(normals);
Scale.setValue(scale); //OvG: Scale
Points.touch(); // This triggers ViewProvider::updateData()
Scale.setValue(scale); // OvG: Scale
Points.touch(); // This triggers ViewProvider::updateData()
}
}
}

View File

@@ -32,7 +32,7 @@
namespace Fem
{
class FemExport ConstraintTemperature : public Fem::Constraint
class FemExport ConstraintTemperature: public Fem::Constraint
{
PROPERTY_HEADER_WITH_OVERRIDE(Fem::ConstraintTemperature);
@@ -44,26 +44,26 @@ public:
App::PropertyVectorList Points;
App::PropertyVectorList Normals;
//Temperature parameters
// Temperature parameters
App::PropertyTemperature Temperature;
App::PropertyPower CFlux;
App::PropertyEnumeration ConstraintType;
/// recalculate the object
App::DocumentObjectExecReturn *execute() override;
App::DocumentObjectExecReturn* execute() override;
/// returns the type name of the ViewProvider
const char* getViewProviderName() const override;
protected:
void handleChangedPropertyType(Base::XMLReader& reader, const char* TypeName,
void handleChangedPropertyType(Base::XMLReader& reader,
const char* TypeName,
App::Property* prop) override;
void onChanged(const App::Property* prop) override;
};
} //namespace Fem
} // namespace Fem
#endif // FEM_CONSTRAINTTEMPERATURE_H
#endif // FEM_CONSTRAINTTEMPERATURE_H

View File

@@ -30,71 +30,86 @@ using namespace Fem;
PROPERTY_SOURCE(Fem::ConstraintTransform, Fem::Constraint)
static const char* TransformTypes[] = {"Cylindrical","Rectangular", nullptr};
static const char* TransformTypes[] = {"Cylindrical", "Rectangular", nullptr};
ConstraintTransform::ConstraintTransform()
{
ADD_PROPERTY(X_rot, (0.0));
ADD_PROPERTY(Y_rot, (0.0));
ADD_PROPERTY(Z_rot, (0.0));
ADD_PROPERTY_TYPE(TransformType, (1), "ConstraintTransform",
ADD_PROPERTY_TYPE(TransformType,
(1),
"ConstraintTransform",
(App::PropertyType)(App::Prop_None),
"Type of transform, rectangular or cylindrical");
TransformType.setEnums(TransformTypes);
ADD_PROPERTY_TYPE(RefDispl, (nullptr, nullptr),
"ConstraintTransform", (App::PropertyType)(App::Prop_None),
ADD_PROPERTY_TYPE(RefDispl,
(nullptr, nullptr),
"ConstraintTransform",
(App::PropertyType)(App::Prop_None),
"Elements where the constraint is applied");
// RefDispl must get a global scope, see
// https://forum.freecad.org/viewtopic.php?p=671402#p671402
RefDispl.setScope(App::LinkScope::Global);
ADD_PROPERTY_TYPE(NameDispl, (nullptr), "ConstraintTransform",
ADD_PROPERTY_TYPE(NameDispl,
(nullptr),
"ConstraintTransform",
(App::PropertyType)(App::Prop_None),
"Elements where the constraint is applied");
ADD_PROPERTY_TYPE(BasePoint, (Base::Vector3d(0, 0, 0)), "ConstraintTransform",
ADD_PROPERTY_TYPE(BasePoint,
(Base::Vector3d(0, 0, 0)),
"ConstraintTransform",
App::PropertyType(App::Prop_ReadOnly | App::Prop_Output),
"Base point of cylindrical surface");
ADD_PROPERTY_TYPE(Axis, (Base::Vector3d(0, 1, 0)), "ConstraintTransform",
ADD_PROPERTY_TYPE(Axis,
(Base::Vector3d(0, 1, 0)),
"ConstraintTransform",
App::PropertyType(App::Prop_ReadOnly | App::Prop_Output),
"Axis of cylindrical surface");
ADD_PROPERTY_TYPE(Points, (Base::Vector3d()), "ConstraintTransform",
ADD_PROPERTY_TYPE(Points,
(Base::Vector3d()),
"ConstraintTransform",
App::PropertyType(App::Prop_ReadOnly | App::Prop_Output),
"Points where symbols are drawn");
ADD_PROPERTY_TYPE(Normals, (Base::Vector3d()), "ConstraintTransform",
ADD_PROPERTY_TYPE(Normals,
(Base::Vector3d()),
"ConstraintTransform",
App::PropertyType(App::Prop_ReadOnly | App::Prop_Output),
"Normals where symbols are drawn");
Points.setValues(std::vector<Base::Vector3d>());
Normals.setValues(std::vector<Base::Vector3d>());
}
App::DocumentObjectExecReturn *ConstraintTransform::execute()
App::DocumentObjectExecReturn* ConstraintTransform::execute()
{
return Constraint::execute();
}
const char* ConstraintTransform::getViewProviderName() const
{
return "FemGui::ViewProviderFemConstraintTransform";
return "FemGui::ViewProviderFemConstraintTransform";
}
void ConstraintTransform::handleChangedPropertyType(Base::XMLReader& reader,
const char* TypeName, App::Property* prop)
const char* TypeName,
App::Property* prop)
{
// properties _rot had App::PropertyFloat and were changed to App::PropertyAngle
if (prop == &X_rot && strcmp(TypeName, "App::PropertyFloat") == 0) {
App::PropertyFloat X_rotProperty;
X_rotProperty.Restore(reader);
X_rot.setValue(X_rotProperty.getValue());
}
else if (prop == &Y_rot && strcmp(TypeName, "App::PropertyFloat") == 0) {
App::PropertyFloat Y_rotProperty;
Y_rotProperty.Restore(reader);
Y_rot.setValue(Y_rotProperty.getValue());
}
else if (prop == &Z_rot && strcmp(TypeName, "App::PropertyFloat") == 0) {
App::PropertyFloat Z_rotProperty;
Z_rotProperty.Restore(reader);
Z_rot.setValue(Z_rotProperty.getValue());
}
// properties _rot had App::PropertyFloat and were changed to App::PropertyAngle
if (prop == &X_rot && strcmp(TypeName, "App::PropertyFloat") == 0) {
App::PropertyFloat X_rotProperty;
X_rotProperty.Restore(reader);
X_rot.setValue(X_rotProperty.getValue());
}
else if (prop == &Y_rot && strcmp(TypeName, "App::PropertyFloat") == 0) {
App::PropertyFloat Y_rotProperty;
Y_rotProperty.Restore(reader);
Y_rot.setValue(Y_rotProperty.getValue());
}
else if (prop == &Z_rot && strcmp(TypeName, "App::PropertyFloat") == 0) {
App::PropertyFloat Z_rotProperty;
Z_rotProperty.Restore(reader);
Z_rot.setValue(Z_rotProperty.getValue());
}
}
void ConstraintTransform::onChanged(const App::Property* prop)
@@ -104,24 +119,25 @@ void ConstraintTransform::onChanged(const App::Property* prop)
if (prop == &References) {
std::vector<Base::Vector3d> points;
std::vector<Base::Vector3d> normals;
int scale = 1; //OvG: Enforce use of scale
int scale = 1; // OvG: Enforce use of scale
if (getPoints(points, normals, &scale)) {
Points.setValues(points);
Normals.setValues(normals);
Scale.setValue(scale); //OvG: Scale
Points.touch(); // This triggers ViewProvider::updateData()
Scale.setValue(scale); // OvG: Scale
Points.touch(); // This triggers ViewProvider::updateData()
std::string transform_type = TransformType.getValueAsString();
if (transform_type == "Cylindrical") {
// Find data of cylinder
double radius, height;
Base::Vector3d base, axis;
if (!getCylinder(radius, height, base, axis))
return;
if (!getCylinder(radius, height, base, axis)) {
return;
}
Axis.setValue(axis);
// Update base point
base = base + axis * height/2;
base = base + axis * height / 2;
BasePoint.setValue(base);
BasePoint.touch(); // This triggers ViewProvider::updateData()
BasePoint.touch(); // This triggers ViewProvider::updateData()
}
}
}

View File

@@ -29,7 +29,7 @@
namespace Fem
{
class FemExport ConstraintTransform : public Fem::Constraint
class FemExport ConstraintTransform: public Fem::Constraint
{
PROPERTY_HEADER_WITH_OVERRIDE(Fem::ConstraintTransform);
@@ -48,23 +48,23 @@ public:
App::PropertyAngle Y_rot;
App::PropertyAngle Z_rot;
App::PropertyEnumeration TransformType;
//etc
/* */
// etc
/* */
/// recalculate the object
App::DocumentObjectExecReturn *execute() override;
App::DocumentObjectExecReturn* execute() override;
/// returns the type name of the ViewProvider
const char* getViewProviderName() const override;
protected:
void handleChangedPropertyType(Base::XMLReader& reader, const char* TypeName,
void handleChangedPropertyType(Base::XMLReader& reader,
const char* TypeName,
App::Property* prop) override;
void onChanged(const App::Property* prop) override;
};
} //namespace Fem
} // namespace Fem
#endif // FEM_CONSTRAINTTransform_H
#endif // FEM_CONSTRAINTTransform_H

File diff suppressed because it is too large Load Diff

View File

@@ -27,8 +27,8 @@
#include <memory>
#include <vector>
#include <SMESH_Version.h>
#include <SMDSAbs_ElementType.hxx>
#include <SMESH_Version.h>
#include <App/ComplexGeoData.h>
#include <Base/Quantity.h>
@@ -51,7 +51,7 @@ using SMESH_HypothesisPtr = std::shared_ptr<SMESH_Hypothesis>;
/** The representation of a FemMesh
*/
class FemExport FemMesh : public Data::ComplexGeoData
class FemExport FemMesh: public Data::ComplexGeoData
{
TYPESYSTEM_HEADER_WITH_OVERRIDE();
@@ -60,20 +60,20 @@ public:
FemMesh(const FemMesh&);
~FemMesh() override;
FemMesh &operator=(const FemMesh&);
FemMesh& operator=(const FemMesh&);
const SMESH_Mesh* getSMesh() const;
SMESH_Mesh* getSMesh();
static SMESH_Gen * getGenerator();
void addHypothesis(const TopoDS_Shape & aSubShape, SMESH_HypothesisPtr hyp);
static SMESH_Gen* getGenerator();
void addHypothesis(const TopoDS_Shape& aSubShape, SMESH_HypothesisPtr hyp);
void setStandardHypotheses();
void compute();
// from base class
unsigned int getMemSize () const override;
void Save (Base::Writer &/*writer*/) const override;
void Restore(Base::XMLReader &/*reader*/) override;
void SaveDocFile (Base::Writer &writer) const override;
void RestoreDocFile(Base::Reader &reader) override;
unsigned int getMemSize() const override;
void Save(Base::Writer& /*writer*/) const override;
void Restore(Base::XMLReader& /*reader*/) override;
void SaveDocFile(Base::Writer& writer) const override;
void RestoreDocFile(Base::Reader& reader) override;
/** @name Subelement management */
//@{
@@ -86,40 +86,41 @@ public:
/// get the subelement by type and number
Data::Segment* getSubElement(const char* Type, unsigned long) const override;
/** Get points from object with given accuracy */
void getPoints(std::vector<Base::Vector3d> &Points,
std::vector<Base::Vector3d> &Normals,
double Accuracy, uint16_t flags=0) const override;
void getPoints(std::vector<Base::Vector3d>& Points,
std::vector<Base::Vector3d>& Normals,
double Accuracy,
uint16_t flags = 0) const override;
//@}
/** @name search and retrieval */
//@{
/// retrieving by region growing
std::set<long> getSurfaceNodes(long ElemId, short FaceId, float Angle=360)const;
std::set<long> getSurfaceNodes(long ElemId, short FaceId, float Angle = 360) const;
/// retrieving by solid
std::set<int> getNodesBySolid(const TopoDS_Solid &solid) const;
std::set<int> getNodesBySolid(const TopoDS_Solid& solid) const;
/// retrieving by face
std::set<int> getNodesByFace(const TopoDS_Face &face) const;
std::set<int> getNodesByFace(const TopoDS_Face& face) const;
/// retrieving by edge
std::set<int> getNodesByEdge(const TopoDS_Edge &edge) const;
std::set<int> getNodesByEdge(const TopoDS_Edge& edge) const;
/// retrieving by vertex
std::set<int> getNodesByVertex(const TopoDS_Vertex &vertex) const;
std::set<int> getNodesByVertex(const TopoDS_Vertex& vertex) const;
/// retrieving node IDs by element ID
std::list<int> getElementNodes(int id) const;
/// retrieving elements IDs by node ID
std::list<int> getNodeElements(int id, SMDSAbs_ElementType type=SMDSAbs_All) const;
std::list<int> getNodeElements(int id, SMDSAbs_ElementType type = SMDSAbs_All) const;
/// retrieving face IDs number by face
std::list<int> getFacesByFace(const TopoDS_Face &face) const;
std::list<int> getFacesByFace(const TopoDS_Face& face) const;
/// retrieving edge IDs number by edge
std::list<int> getEdgesByEdge(const TopoDS_Edge &edge) const;
std::list<int> getEdgesByEdge(const TopoDS_Edge& edge) const;
/// retrieving volume IDs and face IDs number by face
std::list<std::pair<int, int> > getVolumesByFace(const TopoDS_Face &face) const;
std::list<std::pair<int, int>> getVolumesByFace(const TopoDS_Face& face) const;
/// retrieving volume IDs and CalculiX face number by face
std::map<int, int> getccxVolumesByFace(const TopoDS_Face &face) const;
std::map<int, int> getccxVolumesByFace(const TopoDS_Face& face) const;
/// retrieving IDs of edges not belonging to any face (and thus not belonging to any volume too)
std::set<int> getEdgesOnly() const;
/// retrieving IDs of faces not belonging to any volume
std::set<int> getFacesOnly() const;
//@}
//@}
/** @name Placement control */
//@{
@@ -128,21 +129,21 @@ public:
/// get the transformation
Base::Matrix4D getTransform() const override;
/// Bound box from the shape
Base::BoundBox3d getBoundBox()const override;
Base::BoundBox3d getBoundBox() const override;
/// get the volume (when there are volume elements)
Base::Quantity getVolume()const;
Base::Quantity getVolume() const;
//@}
/** @name Modification */
//@{
/// Applies a transformation on the real geometric data type
void transformGeometry(const Base::Matrix4D &rclMat) override;
void transformGeometry(const Base::Matrix4D& rclMat) override;
//@}
/** @name Group management */
//@{
/// Adds group to mesh
int addGroup(const std::string, const std::string, const int=-1);
int addGroup(const std::string, const std::string, const int = -1);
/// Adds elements to group (int due to int used by raw SMESH functions)
void addGroupElements(int, const std::set<int>&);
/// Remove group (Name due to similarity to SMESH basis functions)
@@ -150,7 +151,8 @@ public:
//@}
struct FemMeshInfo {
struct FemMeshInfo
{
int numFaces;
int numNode;
int numTria;
@@ -168,28 +170,28 @@ public:
struct FemMeshInfo getInfo() const;
/// import from files
void read(const char *FileName);
void write(const char *FileName) const;
void writeABAQUS(const std::string &Filename, int elemParam, bool groupParam) const;
void writeZ88(const std::string &FileName) const;
void read(const char* FileName);
void write(const char* FileName) const;
void writeABAQUS(const std::string& Filename, int elemParam, bool groupParam) const;
void writeZ88(const std::string& FileName) const;
private:
void copyMeshData(const FemMesh&);
void readNastran(const std::string &Filename);
void readNastran95(const std::string &Filename);
void readZ88(const std::string &Filename);
void readAbaqus(const std::string &Filename);
void readNastran(const std::string& Filename);
void readNastran95(const std::string& Filename);
void readZ88(const std::string& Filename);
void readAbaqus(const std::string& Filename);
private:
/// positioning matrix
Base::Matrix4D _Mtrx;
SMESH_Mesh *myMesh;
SMESH_Mesh* myMesh;
std::list<SMESH_HypothesisPtr> hypoth;
static SMESH_Gen *_mesh_gen;
static SMESH_Gen* _mesh_gen;
};
} //namespace Part
} // namespace Fem
#endif // FEM_FEMMESH_H
#endif // FEM_FEMMESH_H

View File

@@ -22,12 +22,12 @@
#include "PreCompiled.h"
#include <App/GeoFeaturePy.h>
#include <App/FeaturePythonPyImp.h>
#include <App/GeoFeaturePy.h>
#include <Base/Placement.h>
#include "FemMeshObject.h"
#include "FemMesh.h"
#include "FemMeshObject.h"
using namespace Fem;
@@ -38,7 +38,7 @@ PROPERTY_SOURCE(Fem::FemMeshObject, App::GeoFeature)
FemMeshObject::FemMeshObject()
{
ADD_PROPERTY_TYPE(FemMesh,(), "FEM Mesh",Prop_NoRecompute,"FEM Mesh object");
ADD_PROPERTY_TYPE(FemMesh, (), "FEM Mesh", Prop_NoRecompute, "FEM Mesh object");
// in the regard of recomputes see:
// https://forum.freecad.org/viewtopic.php?f=18&t=33329#p279203
}
@@ -50,9 +50,9 @@ short FemMeshObject::mustExecute() const
return 0;
}
PyObject *FemMeshObject::getPyObject()
PyObject* FemMeshObject::getPyObject()
{
if (PythonObject.is(Py::_None())){
if (PythonObject.is(Py::_None())) {
// ref counter is set to 1
PythonObject = Py::asObject(new GeoFeaturePy(this));
}
@@ -67,19 +67,23 @@ void FemMeshObject::onChanged(const Property* prop)
if (prop == &this->Placement) {
this->FemMesh.setTransform(this->Placement.getValue().toMatrix());
}
}
// Python feature ---------------------------------------------------------
namespace App {
namespace App
{
/// @cond DOXERR
PROPERTY_SOURCE_TEMPLATE(Fem::FemMeshObjectPython, Fem::FemMeshObject)
template<> const char* Fem::FemMeshObjectPython::getViewProviderName() const {
template<>
const char* Fem::FemMeshObjectPython::getViewProviderName() const
{
return "FemGui::ViewProviderFemMeshPython";
}
template<> PyObject* Fem::FemMeshObjectPython::getPyObject() {
template<>
PyObject* Fem::FemMeshObjectPython::getPyObject()
{
if (PythonObject.is(Py::_None())) {
// ref counter is set to 1
PythonObject = Py::asObject(new App::FeaturePythonPyT<App::GeoFeaturePy>(this));
@@ -92,4 +96,4 @@ template class FemExport FeaturePythonT<Fem::FemMeshObject>;
/// @endcond
}
} // namespace App

View File

@@ -33,7 +33,7 @@
namespace Fem
{
class FemExport FemMeshObject : public App::GeoFeature
class FemExport FemMeshObject: public App::GeoFeature
{
PROPERTY_HEADER_WITH_OVERRIDE(Fem::FemMeshObject);
@@ -43,15 +43,18 @@ public:
~FemMeshObject() override;
/// returns the type name of the ViewProvider
const char* getViewProviderName() const override {
const char* getViewProviderName() const override
{
return "FemGui::ViewProviderFemMesh";
}
App::DocumentObjectExecReturn *execute() override {
App::DocumentObjectExecReturn* execute() override
{
return App::DocumentObject::StdReturn;
}
short mustExecute() const override;
PyObject *getPyObject() override;
const App::PropertyComplexGeoData* getPropertyOfGeometry() const override {
PyObject* getPyObject() override;
const App::PropertyComplexGeoData* getPropertyOfGeometry() const override
{
return &FemMesh;
}
@@ -59,13 +62,13 @@ public:
protected:
/// get called by the container when a property has changed
void onChanged (const App::Property* prop) override;
void onChanged(const App::Property* prop) override;
};
using FemMeshObjectPython = App::FeaturePythonT<FemMeshObject>;
} //namespace Fem
} // namespace Fem
#endif // Fem_FemMeshObject_H
#endif // Fem_FemMeshObject_H

View File

@@ -23,7 +23,7 @@
#include "PreCompiled.h"
#ifndef _PreComp_
# include <sstream>
#include <sstream>
#endif
#include <Base/PlacementPy.h>
@@ -36,11 +36,11 @@
using namespace Fem;
TYPESYSTEM_SOURCE(Fem::PropertyFemMesh , App::PropertyComplexGeoData)
TYPESYSTEM_SOURCE(Fem::PropertyFemMesh, App::PropertyComplexGeoData)
PropertyFemMesh::PropertyFemMesh() : _FemMesh(new FemMesh)
{
}
PropertyFemMesh::PropertyFemMesh()
: _FemMesh(new FemMesh)
{}
PropertyFemMesh::~PropertyFemMesh() = default;
@@ -61,7 +61,7 @@ void PropertyFemMesh::setValue(const FemMesh& sh)
hasSetValue();
}
const FemMesh &PropertyFemMesh::getValue()const
const FemMesh& PropertyFemMesh::getValue() const
{
return *_FemMesh;
}
@@ -76,7 +76,7 @@ Base::BoundBox3d PropertyFemMesh::getBoundingBox() const
return _FemMesh->getBoundBox();
}
void PropertyFemMesh::setTransform(const Base::Matrix4D &rclTrf)
void PropertyFemMesh::setTransform(const Base::Matrix4D& rclTrf)
{
_FemMesh->setTransform(rclTrf);
}
@@ -86,28 +86,28 @@ Base::Matrix4D PropertyFemMesh::getTransform() const
return _FemMesh->getTransform();
}
void PropertyFemMesh::transformGeometry(const Base::Matrix4D &rclMat)
void PropertyFemMesh::transformGeometry(const Base::Matrix4D& rclMat)
{
aboutToSetValue();
_FemMesh->transformGeometry(rclMat);
hasSetValue();
}
PyObject *PropertyFemMesh::getPyObject()
PyObject* PropertyFemMesh::getPyObject()
{
FemMeshPy* mesh = new FemMeshPy(&*_FemMesh);
mesh->setConst();
return mesh;
}
void PropertyFemMesh::setPyObject(PyObject *value)
void PropertyFemMesh::setPyObject(PyObject* value)
{
if (PyObject_TypeCheck(value, &(FemMeshPy::Type))) {
FemMeshPy *pcObject = static_cast<FemMeshPy*>(value);
FemMeshPy* pcObject = static_cast<FemMeshPy*>(value);
setValue(*pcObject->getFemMeshPtr());
}
else if (PyObject_TypeCheck(value, &(Base::PlacementPy::Type))) {
Base::PlacementPy *pcObject = static_cast<Base::PlacementPy*>(value);
Base::PlacementPy* pcObject = static_cast<Base::PlacementPy*>(value);
transformGeometry(pcObject->getPlacementPtr()->toMatrix());
}
else {
@@ -117,41 +117,41 @@ void PropertyFemMesh::setPyObject(PyObject *value)
}
}
App::Property *PropertyFemMesh::Copy() const
App::Property* PropertyFemMesh::Copy() const
{
PropertyFemMesh *prop = new PropertyFemMesh();
PropertyFemMesh* prop = new PropertyFemMesh();
prop->_FemMesh = this->_FemMesh;
return prop;
}
void PropertyFemMesh::Paste(const App::Property &from)
void PropertyFemMesh::Paste(const App::Property& from)
{
aboutToSetValue();
_FemMesh = dynamic_cast<const PropertyFemMesh&>(from)._FemMesh;
hasSetValue();
}
unsigned int PropertyFemMesh::getMemSize () const
unsigned int PropertyFemMesh::getMemSize() const
{
return _FemMesh->getMemSize();
}
void PropertyFemMesh::Save (Base::Writer &writer) const
void PropertyFemMesh::Save(Base::Writer& writer) const
{
_FemMesh->Save(writer);
}
void PropertyFemMesh::Restore(Base::XMLReader &reader)
void PropertyFemMesh::Restore(Base::XMLReader& reader)
{
_FemMesh->Restore(reader);
}
void PropertyFemMesh::SaveDocFile (Base::Writer &writer) const
void PropertyFemMesh::SaveDocFile(Base::Writer& writer) const
{
_FemMesh->SaveDocFile(writer);
}
void PropertyFemMesh::RestoreDocFile(Base::Reader &reader )
void PropertyFemMesh::RestoreDocFile(Base::Reader& reader)
{
aboutToSetValue();
_FemMesh->RestoreDocFile(reader);

View File

@@ -35,7 +35,7 @@ namespace Fem
/** The part shape property class.
* @author Werner Mayer
*/
class FemExport PropertyFemMesh : public App::PropertyComplexGeoData
class FemExport PropertyFemMesh: public App::PropertyComplexGeoData
{
TYPESYSTEM_HEADER_WITH_OVERRIDE();
@@ -49,9 +49,10 @@ public:
/// set the FemMesh shape
void setValue(const FemMesh&);
/// does nothing, for add property macro
void setValue(){}
void setValue()
{}
/// get the FemMesh shape
const FemMesh &getValue() const;
const FemMesh& getValue() const;
const Data::ComplexGeoData* getComplexData() const override;
//@}
@@ -64,26 +65,29 @@ public:
void setTransform(const Base::Matrix4D& rclTrf) override;
/// Get the placement of the geometry
Base::Matrix4D getTransform() const override;
void transformGeometry(const Base::Matrix4D &rclMat) override;
void transformGeometry(const Base::Matrix4D& rclMat) override;
//@}
/** @name Python interface */
//@{
PyObject* getPyObject() override;
void setPyObject(PyObject *value) override;
void setPyObject(PyObject* value) override;
//@}
/** @name Save/restore */
//@{
void Save (Base::Writer &writer) const override;
void Restore(Base::XMLReader &reader) override;
void SaveDocFile (Base::Writer &writer) const override;
void RestoreDocFile(Base::Reader &reader) override;
void Save(Base::Writer& writer) const override;
void Restore(Base::XMLReader& reader) override;
void SaveDocFile(Base::Writer& writer) const override;
void RestoreDocFile(Base::Reader& reader) override;
App::Property *Copy() const override;
void Paste(const App::Property &from) override;
unsigned int getMemSize () const override;
const char* getEditorName() const override { return "FemGui::PropertyFemMeshItem"; }
App::Property* Copy() const override;
void Paste(const App::Property& from) override;
unsigned int getMemSize() const override;
const char* getEditorName() const override
{
return "FemGui::PropertyFemMeshItem";
}
//@}
private:
@@ -91,7 +95,7 @@ private:
};
} //namespace Fem
} // namespace Fem
#endif // PROPERTYTOPOSHAPE_H
#endif // PROPERTYTOPOSHAPE_H

File diff suppressed because it is too large Load Diff

View File

@@ -24,22 +24,22 @@
#include <SMESH_Version.h>
#ifndef _PreComp_
# include <Python.h>
# include <SMESHDS_Mesh.hxx>
# include <SMESH_Mesh.hxx>
#include <Python.h>
#include <SMESHDS_Mesh.hxx>
#include <SMESH_Mesh.hxx>
# ifdef FCWithNetgen
# include <NETGENPlugin_Hypothesis.hxx>
# include <NETGENPlugin_Mesher.hxx>
# endif
#ifdef FCWithNetgen
#include <NETGENPlugin_Hypothesis.hxx>
#include <NETGENPlugin_Mesher.hxx>
#endif
#endif
#include <App/DocumentObjectPy.h>
#include <Base/Console.h>
#include <Mod/Part/App/PartFeature.h>
#include "FemMeshShapeNetgenObject.h"
#include "FemMesh.h"
#include "FemMeshShapeNetgenObject.h"
using namespace Fem;
@@ -47,49 +47,64 @@ using namespace App;
PROPERTY_SOURCE(Fem::FemMeshShapeNetgenObject, Fem::FemMeshShapeObject)
const char* FinenessEnums[]= {"VeryCoarse","Coarse","Moderate","Fine","VeryFine","UserDefined",nullptr};
const char* FinenessEnums[] =
{"VeryCoarse", "Coarse", "Moderate", "Fine", "VeryFine", "UserDefined", nullptr};
FemMeshShapeNetgenObject::FemMeshShapeNetgenObject()
{
ADD_PROPERTY_TYPE(MaxSize,(1000), "MeshParams",Prop_None,"Maximum element size");
ADD_PROPERTY_TYPE(SecondOrder,(true), "MeshParams",Prop_None,"Create quadric elements");
ADD_PROPERTY_TYPE(Fineness,(2), "MeshParams",Prop_None,"Fineness level of the mesh");
ADD_PROPERTY_TYPE(MaxSize, (1000), "MeshParams", Prop_None, "Maximum element size");
ADD_PROPERTY_TYPE(SecondOrder, (true), "MeshParams", Prop_None, "Create quadric elements");
ADD_PROPERTY_TYPE(Fineness, (2), "MeshParams", Prop_None, "Fineness level of the mesh");
Fineness.setEnums(FinenessEnums);
ADD_PROPERTY_TYPE(GrowthRate,(0.3), "MeshParams",Prop_None," allows to define how much the linear dimensions of two adjacent cells can differ");
ADD_PROPERTY_TYPE(NbSegsPerEdge,(1), "MeshParams",Prop_None,"allows to define the minimum number of mesh segments in which edges will be split");
ADD_PROPERTY_TYPE(NbSegsPerRadius,(2), "MeshParams",Prop_None,"allows to define the minimum number of mesh segments in which radiuses will be split");
ADD_PROPERTY_TYPE(Optimize,(true), "MeshParams",Prop_None,"Optimize the resulting mesh");
ADD_PROPERTY_TYPE(
GrowthRate,
(0.3),
"MeshParams",
Prop_None,
" allows to define how much the linear dimensions of two adjacent cells can differ");
ADD_PROPERTY_TYPE(
NbSegsPerEdge,
(1),
"MeshParams",
Prop_None,
"allows to define the minimum number of mesh segments in which edges will be split");
ADD_PROPERTY_TYPE(
NbSegsPerRadius,
(2),
"MeshParams",
Prop_None,
"allows to define the minimum number of mesh segments in which radiuses will be split");
ADD_PROPERTY_TYPE(Optimize, (true), "MeshParams", Prop_None, "Optimize the resulting mesh");
}
FemMeshShapeNetgenObject::~FemMeshShapeNetgenObject() = default;
App::DocumentObjectExecReturn *FemMeshShapeNetgenObject::execute()
App::DocumentObjectExecReturn* FemMeshShapeNetgenObject::execute()
{
#ifdef FCWithNetgen
Fem::FemMesh newMesh;
Part::Feature *feat = Shape.getValue<Part::Feature*>();
Part::Feature* feat = Shape.getValue<Part::Feature*>();
TopoDS_Shape shape = feat->Shape.getValue();
NETGENPlugin_Mesher myNetGenMesher(newMesh.getSMesh(),shape,true);
NETGENPlugin_Mesher myNetGenMesher(newMesh.getSMesh(), shape, true);
#if SMESH_VERSION_MAJOR >= 9
NETGENPlugin_Hypothesis* tet= new NETGENPlugin_Hypothesis(0,newMesh.getGenerator());
NETGENPlugin_Hypothesis* tet = new NETGENPlugin_Hypothesis(0, newMesh.getGenerator());
#else
NETGENPlugin_Hypothesis* tet= new NETGENPlugin_Hypothesis(0,1,newMesh.getGenerator());
NETGENPlugin_Hypothesis* tet = new NETGENPlugin_Hypothesis(0, 1, newMesh.getGenerator());
#endif
tet->SetMaxSize(MaxSize.getValue());
tet->SetSecondOrder(SecondOrder.getValue());
tet->SetOptimize(Optimize.getValue());
int iFineness = Fineness.getValue();
tet->SetFineness((NETGENPlugin_Hypothesis::Fineness)iFineness);
if(iFineness == 5){
if (iFineness == 5) {
tet->SetGrowthRate(GrowthRate.getValue());
tet->SetNbSegPerEdge(NbSegsPerEdge.getValue());
tet->SetNbSegPerRadius(NbSegsPerRadius.getValue());
}
myNetGenMesher.SetParameters( tet);
myNetGenMesher.SetParameters(tet);
newMesh.getSMesh()->ShapeToMesh(shape);
myNetGenMesher.Compute();
@@ -100,40 +115,42 @@ App::DocumentObjectExecReturn *FemMeshShapeNetgenObject::execute()
const SMDS_MeshInfo& info = data->GetMeshInfo();
int numFaces = data->NbFaces();
int numNode = info.NbNodes();
//int numTria = info.NbTriangles();
//int numQuad = info.NbQuadrangles();
//int numPoly = info.NbPolygons();
// int numTria = info.NbTriangles();
// int numQuad = info.NbQuadrangles();
// int numPoly = info.NbPolygons();
int numVolu = info.NbVolumes();
//int numTetr = info.NbTetras();
//int numHexa = info.NbHexas();
//int numPyrd = info.NbPyramids();
//int numPris = info.NbPrisms();
//int numHedr = info.NbPolyhedrons();
// int numTetr = info.NbTetras();
// int numHexa = info.NbHexas();
// int numPyrd = info.NbPyramids();
// int numPris = info.NbPrisms();
// int numHedr = info.NbPolyhedrons();
Base::Console().Log("NetgenMesh: %i Nodes, %i Volumes, %i Faces\n",numNode,numVolu,numFaces);
Base::Console().Log("NetgenMesh: %i Nodes, %i Volumes, %i Faces\n", numNode, numVolu, numFaces);
FemMesh.setValue(newMesh);
FemMesh.setValue(newMesh);
return App::DocumentObject::StdReturn;
#else
return new App::DocumentObjectExecReturn("The FEM module is built without NETGEN support. Meshing will not work!!!", this);
return new App::DocumentObjectExecReturn(
"The FEM module is built without NETGEN support. Meshing will not work!!!",
this);
#endif
}
//short FemMeshShapeNetgenObject::mustExecute(void) const
// short FemMeshShapeNetgenObject::mustExecute(void) const
//{
// return 0;
//}
// return 0;
// }
//PyObject *FemMeshShapeNetgenObject::getPyObject()
// PyObject *FemMeshShapeNetgenObject::getPyObject()
//{
// if (PythonObject.is(Py::_None())){
// // ref counter is set to 1
// PythonObject = Py::Object(new DocumentObjectPy(this),true);
// }
// return Py::new_reference_to(PythonObject);
//}
// if (PythonObject.is(Py::_None())){
// // ref counter is set to 1
// PythonObject = Py::Object(new DocumentObjectPy(this),true);
// }
// return Py::new_reference_to(PythonObject);
// }
//void FemMeshShapeNetgenObject::onChanged(const Property* prop)
// void FemMeshShapeNetgenObject::onChanged(const Property* prop)
//{
// Fem::FemMeshShapeObject::onChanged(prop);
//}
// Fem::FemMeshShapeObject::onChanged(prop);
// }

View File

@@ -23,13 +23,13 @@
#ifndef Fem_FemMeshShapeNetgenObject_H
#define Fem_FemMeshShapeNetgenObject_H
#include <App/PropertyStandard.h>
#include "FemMeshShapeObject.h"
#include <App/PropertyStandard.h>
namespace Fem
{
class FemExport FemMeshShapeNetgenObject : public FemMeshShapeObject
class FemExport FemMeshShapeNetgenObject: public FemMeshShapeObject
{
PROPERTY_HEADER_WITH_OVERRIDE(Fem::FemMeshShapeNetgenObject);
@@ -38,31 +38,32 @@ public:
FemMeshShapeNetgenObject();
~FemMeshShapeNetgenObject() override;
App::PropertyFloat MaxSize;
App::PropertyBool SecondOrder;
App::PropertyEnumeration Fineness;
App::PropertyFloat GrowthRate;
App::PropertyInteger NbSegsPerEdge;
App::PropertyInteger NbSegsPerRadius;
App::PropertyBool Optimize;
App::PropertyFloat MaxSize;
App::PropertyBool SecondOrder;
App::PropertyEnumeration Fineness;
App::PropertyFloat GrowthRate;
App::PropertyInteger NbSegsPerEdge;
App::PropertyInteger NbSegsPerRadius;
App::PropertyBool Optimize;
/// returns the type name of the ViewProvider
const char* getViewProviderName() const override {
const char* getViewProviderName() const override
{
return "FemGui::ViewProviderFemMeshShapeNetgen";
}
App::DocumentObjectExecReturn *execute() override;
App::DocumentObjectExecReturn* execute() override;
//virtual short mustExecute(void) const;
//virtual PyObject *getPyObject(void);
// virtual short mustExecute(void) const;
// virtual PyObject *getPyObject(void);
//App::PropertyLink Shape;
// App::PropertyLink Shape;
protected:
/// get called by the container when a property has changed
//virtual void onChanged (const App::Property* prop);
// virtual void onChanged (const App::Property* prop);
};
} //namespace Fem
} // namespace Fem
#endif // Fem_FemMeshShapeNetgenObject_H
#endif // Fem_FemMeshShapeNetgenObject_H

View File

@@ -24,33 +24,33 @@
#include <SMESH_Version.h>
#ifndef _PreComp_
# include <Python.h>
# include <BRepBuilderAPI_Copy.hxx>
# include <BRepTools.hxx>
# include <SMESH_Gen.hxx>
# include <SMESH_Mesh.hxx>
# include <StdMeshers_MaxLength.hxx>
# include <StdMeshers_LocalLength.hxx>
# include <StdMeshers_MaxElementArea.hxx>
# include <StdMeshers_QuadranglePreference.hxx>
# include <StdMeshers_Quadrangle_2D.hxx>
# include <StdMeshers_Regular_1D.hxx>
# include <StdMeshers_Deflection1D.hxx>
# include <StdMeshers_Hexa_3D.hxx>
# include <StdMeshers_NumberOfSegments.hxx>
# include <StdMeshers_RadialPrism_3D.hxx>
# include <StdMeshers_SegmentAroundVertex_0D.hxx>
# include <StdMeshers_ProjectionSource1D.hxx>
# include <StdMeshers_ProjectionSource2D.hxx>
# include <StdMeshers_ProjectionSource3D.hxx>
# include <StdMeshers_StartEndLength.hxx>
#include <BRepBuilderAPI_Copy.hxx>
#include <BRepTools.hxx>
#include <Python.h>
#include <SMESH_Gen.hxx>
#include <SMESH_Mesh.hxx>
#include <StdMeshers_Deflection1D.hxx>
#include <StdMeshers_Hexa_3D.hxx>
#include <StdMeshers_LocalLength.hxx>
#include <StdMeshers_MaxElementArea.hxx>
#include <StdMeshers_MaxLength.hxx>
#include <StdMeshers_NumberOfSegments.hxx>
#include <StdMeshers_ProjectionSource1D.hxx>
#include <StdMeshers_ProjectionSource2D.hxx>
#include <StdMeshers_ProjectionSource3D.hxx>
#include <StdMeshers_QuadranglePreference.hxx>
#include <StdMeshers_Quadrangle_2D.hxx>
#include <StdMeshers_RadialPrism_3D.hxx>
#include <StdMeshers_Regular_1D.hxx>
#include <StdMeshers_SegmentAroundVertex_0D.hxx>
#include <StdMeshers_StartEndLength.hxx>
#endif
#include <App/DocumentObjectPy.h>
#include <Mod/Part/App/PartFeature.h>
#include "FemMeshShapeObject.h"
#include "FemMesh.h"
#include "FemMeshShapeObject.h"
using namespace Fem;
@@ -62,17 +62,20 @@ PROPERTY_SOURCE(Fem::FemMeshShapeObject, Fem::FemMeshObject)
FemMeshShapeObject::FemMeshShapeObject()
{
ADD_PROPERTY_TYPE(
Shape, (nullptr), "FEM Mesh", Prop_None,
Shape,
(nullptr),
"FEM Mesh",
Prop_None,
"Geometry object, the mesh is made from. The geometry object has to have a Shape.");
}
FemMeshShapeObject::~FemMeshShapeObject() = default;
App::DocumentObjectExecReturn *FemMeshShapeObject::execute()
App::DocumentObjectExecReturn* FemMeshShapeObject::execute()
{
Fem::FemMesh newMesh;
Part::Feature *feat = Shape.getValue<Part::Feature*>();
Part::Feature* feat = Shape.getValue<Part::Feature*>();
#if 0
TopoDS_Shape oshape = feat->Shape.getValue();
@@ -84,9 +87,9 @@ App::DocumentObjectExecReturn *FemMeshShapeObject::execute()
#endif
newMesh.getSMesh()->ShapeToMesh(shape);
SMESH_Gen *myGen = newMesh.getGenerator();
SMESH_Gen* myGen = newMesh.getGenerator();
int hyp=0;
int hyp = 0;
#if 0
SMESH_HypothesisPtr len(new StdMeshers_MaxLength(hyp++, 1, myGen));
static_cast<StdMeshers_MaxLength*>(len.get())->SetLength(1.0);
@@ -152,10 +155,10 @@ App::DocumentObjectExecReturn *FemMeshShapeObject::execute()
SMESH_HypothesisPtr reg(new StdMeshers_Regular_1D(hyp++, myGen));
newMesh.addHypothesis(shape, reg);
SMESH_HypothesisPtr qdp(new StdMeshers_QuadranglePreference(hyp++,myGen));
SMESH_HypothesisPtr qdp(new StdMeshers_QuadranglePreference(hyp++, myGen));
newMesh.addHypothesis(shape, qdp);
SMESH_HypothesisPtr q2d(new StdMeshers_Quadrangle_2D(hyp++,myGen));
SMESH_HypothesisPtr q2d(new StdMeshers_Quadrangle_2D(hyp++, myGen));
newMesh.addHypothesis(shape, q2d);
#else
SMESH_HypothesisPtr len(new StdMeshers_MaxLength(hyp++, 1, myGen));
@@ -181,21 +184,21 @@ App::DocumentObjectExecReturn *FemMeshShapeObject::execute()
SMESH_HypothesisPtr reg(new StdMeshers_Regular_1D(hyp++, 1, myGen));
newMesh.addHypothesis(shape, reg);
//SMESH_HypothesisPtr sel(new StdMeshers_StartEndLength(hyp++, 1, myGen));
//static_cast<StdMeshers_StartEndLength*>(sel.get())->SetLength(1.0, true);
//newMesh.addHypothesis(shape, sel;
// SMESH_HypothesisPtr sel(new StdMeshers_StartEndLength(hyp++, 1, myGen));
// static_cast<StdMeshers_StartEndLength*>(sel.get())->SetLength(1.0, true);
// newMesh.addHypothesis(shape, sel;
SMESH_HypothesisPtr qdp(new StdMeshers_QuadranglePreference(hyp++,1,myGen));
SMESH_HypothesisPtr qdp(new StdMeshers_QuadranglePreference(hyp++, 1, myGen));
newMesh.addHypothesis(shape, qdp);
SMESH_HypothesisPtr q2d(new StdMeshers_Quadrangle_2D(hyp++,1,myGen));
SMESH_HypothesisPtr q2d(new StdMeshers_Quadrangle_2D(hyp++, 1, myGen));
newMesh.addHypothesis(shape, q2d);
#endif
// create mesh
newMesh.compute();
#endif
#if 0 // NETGEN test
#if 0 // NETGEN test
NETGENPlugin_Mesher myNetGenMesher(newMesh.getSMesh(),shape,true);
//NETGENPlugin_SimpleHypothesis_2D * tet2 = new NETGENPlugin_SimpleHypothesis_2D(hyp++,1,myGen);
@@ -219,21 +222,21 @@ App::DocumentObjectExecReturn *FemMeshShapeObject::execute()
return App::DocumentObject::StdReturn;
}
//short FemMeshShapeObject::mustExecute(void) const
// short FemMeshShapeObject::mustExecute(void) const
//{
// return 0;
//}
// return 0;
// }
//PyObject *FemMeshShapeObject::getPyObject()
// PyObject *FemMeshShapeObject::getPyObject()
//{
// if (PythonObject.is(Py::_None())){
// // ref counter is set to 1
// PythonObject = Py::Object(new DocumentObjectPy(this),true);
// }
// return Py::new_reference_to(PythonObject);
//}
// if (PythonObject.is(Py::_None())){
// // ref counter is set to 1
// PythonObject = Py::Object(new DocumentObjectPy(this),true);
// }
// return Py::new_reference_to(PythonObject);
// }
//void FemMeshShapeObject::onChanged(const Property* prop)
// void FemMeshShapeObject::onChanged(const Property* prop)
//{
// App::GeoFeature::onChanged(prop);
//}
// App::GeoFeature::onChanged(prop);
// }

View File

@@ -29,7 +29,7 @@
namespace Fem
{
class FemExport FemMeshShapeObject : public FemMeshObject
class FemExport FemMeshShapeObject: public FemMeshObject
{
PROPERTY_HEADER_WITH_OVERRIDE(Fem::FemMeshShapeObject);
@@ -39,22 +39,23 @@ public:
~FemMeshShapeObject() override;
/// returns the type name of the ViewProvider
const char* getViewProviderName() const override {
const char* getViewProviderName() const override
{
return "FemGui::ViewProviderFemMeshShape";
}
App::DocumentObjectExecReturn *execute() override;
App::DocumentObjectExecReturn* execute() override;
//virtual short mustExecute(void) const;
//virtual PyObject *getPyObject(void);
// virtual short mustExecute(void) const;
// virtual PyObject *getPyObject(void);
App::PropertyLink Shape;
protected:
/// get called by the container when a property has changed
//virtual void onChanged (const App::Property* prop);
// virtual void onChanged (const App::Property* prop);
};
} //namespace Fem
} // namespace Fem
#endif // Fem_FemMeshShapeObject_H
#endif // Fem_FemMeshShapeObject_H

View File

@@ -23,9 +23,9 @@
#include "PreCompiled.h"
#ifndef _PreComp_
# include <Python.h>
# include <vtkDoubleArray.h>
# include <vtkPointData.h>
#include <Python.h>
#include <vtkDoubleArray.h>
#include <vtkPointData.h>
#endif
#include <App/Document.h>
@@ -42,7 +42,7 @@ PROPERTY_SOURCE(Fem::FemPostFilter, Fem::FemPostObject)
FemPostFilter::FemPostFilter()
{
ADD_PROPERTY(Input,(nullptr));
ADD_PROPERTY(Input, (nullptr));
}
FemPostFilter::~FemPostFilter() = default;
@@ -69,13 +69,14 @@ DocumentObjectExecReturn* FemPostFilter::execute()
if (!m_pipelines.empty() && !m_activePipeline.empty()) {
FemPostFilter::FilterPipeline& pipe = m_pipelines[m_activePipeline];
vtkSmartPointer<vtkDataObject> data = getInputData();
if (!data || !data->IsA("vtkDataSet"))
if (!data || !data->IsA("vtkDataSet")) {
return StdReturn;
}
if ((m_activePipeline == "DataAlongLine") || (m_activePipeline == "DataAtPoint")) {
pipe.filterSource->SetSourceData(getInputData());
pipe.filterTarget->Update();
Data.setValue(pipe.filterTarget->GetOutputDataObject(0));
pipe.filterSource->SetSourceData(getInputData());
pipe.filterTarget->Update();
Data.setValue(pipe.filterTarget->GetOutputDataObject(0));
}
else {
pipe.source->SetInputDataObject(data);
@@ -90,19 +91,23 @@ DocumentObjectExecReturn* FemPostFilter::execute()
vtkDataObject* FemPostFilter::getInputData()
{
if (Input.getValue()) {
if (Input.getValue()->getTypeId().isDerivedFrom(Base::Type::fromName("Fem::FemPostObject")))
if (Input.getValue()->getTypeId().isDerivedFrom(
Base::Type::fromName("Fem::FemPostObject"))) {
return Input.getValue<FemPostObject*>()->Data.getValue();
else
}
else {
throw std::runtime_error(
"The filter's Input object is not a 'Fem::FemPostObject' object!");
}
}
else {
//get the pipeline and use the pipelinedata
// get the pipeline and use the pipelinedata
std::vector<App::DocumentObject*> objs =
getDocument()->getObjectsOfType(FemPostPipeline::getClassTypeId());
for (auto it : objs) {
if (static_cast<FemPostPipeline*>(it)->holdsPostObject(this))
if (static_cast<FemPostPipeline*>(it)->holdsPostObject(this)) {
return static_cast<FemPostObject*>(it)->Data.getValue();
}
}
}
@@ -136,10 +141,16 @@ FemPostDataAlongLineFilter::FemPostDataAlongLineFilter()
"DataAlongLine",
App::Prop_None,
"The number of intervals between the 2 end points of line");
ADD_PROPERTY_TYPE(
XAxisData, (0), "DataAlongLine", App::Prop_None, "X axis data values used for plotting");
ADD_PROPERTY_TYPE(
YAxisData, (0), "DataAlongLine", App::Prop_None, "Y axis data values used for plotting");
ADD_PROPERTY_TYPE(XAxisData,
(0),
"DataAlongLine",
App::Prop_None,
"X axis data values used for plotting");
ADD_PROPERTY_TYPE(YAxisData,
(0),
"DataAlongLine",
App::Prop_None,
"Y axis data values used for plotting");
ADD_PROPERTY_TYPE(PlotData, (""), "DataAlongLine", App::Prop_None, "Field used for plotting");
PlotData.setStatus(App::Property::ReadOnly, true);
@@ -178,7 +189,7 @@ FemPostDataAlongLineFilter::~FemPostDataAlongLineFilter() = default;
DocumentObjectExecReturn* FemPostDataAlongLineFilter::execute()
{
//recalculate the filter
// recalculate the filter
return Fem::FemPostFilter::execute();
}
@@ -223,10 +234,12 @@ void FemPostDataAlongLineFilter::onChanged(const Property* prop)
short int FemPostDataAlongLineFilter::mustExecute() const
{
if (Point1.isTouched() || Point2.isTouched() || Resolution.isTouched())
if (Point1.isTouched() || Point2.isTouched() || Resolution.isTouched()) {
return 1;
else
}
else {
return App::DocumentObject::mustExecute();
}
}
void FemPostDataAlongLineFilter::GetAxisData()
@@ -236,13 +249,15 @@ void FemPostDataAlongLineFilter::GetAxisData()
vtkSmartPointer<vtkDataObject> data = m_probe->GetOutputDataObject(0);
vtkDataSet* dset = vtkDataSet::SafeDownCast(data);
if (!dset)
if (!dset) {
return;
}
vtkDataArray* pdata = dset->GetPointData()->GetArray(PlotData.getValue());
// VTK cannot deliver data when the filer relies e.g. on a scalar clip filter
// whose value is set so that all data are clipped
if (!pdata)
if (!pdata) {
return;
}
vtkDataArray* tcoords = dset->GetPointData()->GetTCoords("Texture Coordinates");
vtkIdType component = 0;
@@ -260,8 +275,9 @@ void FemPostDataAlongLineFilter::GetAxisData()
value = pdata->GetComponent(i, component);
}
else {
for (vtkIdType j = 0; j < pdata->GetNumberOfComponents(); ++j)
for (vtkIdType j = 0; j < pdata->GetNumberOfComponents(); ++j) {
value += std::pow(pdata->GetComponent(i, j), 2);
}
value = std::sqrt(value);
}
@@ -288,8 +304,11 @@ FemPostDataAtPointFilter::FemPostDataAtPointFilter()
"DataAtPoint",
App::Prop_None,
"Center of the point");
ADD_PROPERTY_TYPE(
Radius, (0), "DataAtPoint", App::Prop_None, "Radius around the point (unused)");
ADD_PROPERTY_TYPE(Radius,
(0),
"DataAtPoint",
App::Prop_None,
"Radius around the point (unused)");
ADD_PROPERTY_TYPE(PointData, (0), "DataAtPoint", App::Prop_None, "Point data values");
ADD_PROPERTY_TYPE(FieldName, (""), "DataAtPoint", App::Prop_None, "Field used for plotting");
ADD_PROPERTY_TYPE(Unit, (""), "DataAtPoint", App::Prop_None, "Unit used for the field");
@@ -327,7 +346,7 @@ FemPostDataAtPointFilter::~FemPostDataAtPointFilter() = default;
DocumentObjectExecReturn* FemPostDataAtPointFilter::execute()
{
//recalculate the filter
// recalculate the filter
return Fem::FemPostFilter::execute();
}
@@ -343,10 +362,12 @@ void FemPostDataAtPointFilter::onChanged(const Property* prop)
short int FemPostDataAtPointFilter::mustExecute() const
{
if (Center.isTouched())
if (Center.isTouched()) {
return 1;
else
}
else {
return App::DocumentObject::mustExecute();
}
}
void FemPostDataAtPointFilter::GetPointData()
@@ -355,24 +376,28 @@ void FemPostDataAtPointFilter::GetPointData()
vtkSmartPointer<vtkDataObject> data = m_probe->GetOutputDataObject(0);
vtkDataSet* dset = vtkDataSet::SafeDownCast(data);
if (!dset)
if (!dset) {
return;
}
vtkDataArray* pdata = dset->GetPointData()->GetArray(FieldName.getValue());
// VTK cannot deliver data when the filer relies e.g. on a scalar clip filter
// whose value is set so that all data are clipped
if (!pdata)
if (!pdata) {
return;
}
int component = 0;
for (int i = 0; i < dset->GetNumberOfPoints(); ++i) {
double value = 0;
if (pdata->GetNumberOfComponents() == 1)
if (pdata->GetNumberOfComponents() == 1) {
value = pdata->GetComponent(i, component);
}
else {
for (int j = 0; j < pdata->GetNumberOfComponents(); ++j)
for (int j = 0; j < pdata->GetNumberOfComponents(); ++j) {
value += std::pow(pdata->GetComponent(i, j), 2);
}
value = std::sqrt(value);
}
@@ -439,10 +464,12 @@ void FemPostClipFilter::onChanged(const Property* prop)
}
else if (prop == &CutCells) {
if (!CutCells.getValue())
if (!CutCells.getValue()) {
setActiveFilterPipeline("extract");
else
}
else {
setActiveFilterPipeline("clip");
}
};
Fem::FemPostFilter::onChanged(prop);
@@ -450,17 +477,20 @@ void FemPostClipFilter::onChanged(const Property* prop)
short int FemPostClipFilter::mustExecute() const
{
if (Function.isTouched() || InsideOut.isTouched() || CutCells.isTouched())
if (Function.isTouched() || InsideOut.isTouched() || CutCells.isTouched()) {
return 1;
else
}
else {
return App::DocumentObject::mustExecute();
}
}
DocumentObjectExecReturn* FemPostClipFilter::execute()
{
if (!m_extractor->GetImplicitFunction())
if (!m_extractor->GetImplicitFunction()) {
return StdReturn;
}
return Fem::FemPostFilter::execute();
}
@@ -474,10 +504,16 @@ FemPostContoursFilter::FemPostContoursFilter()
{
ADD_PROPERTY_TYPE(NumberOfContours, (10), "Contours", App::Prop_None, "The number of contours");
ADD_PROPERTY_TYPE(Field, (long(0)), "Clip", App::Prop_None, "The field used to clip");
ADD_PROPERTY_TYPE(
VectorMode, ((long)0), "Contours", App::Prop_None, "Select what vector field");
ADD_PROPERTY_TYPE(NoColor, (false), "Contours",
PropertyType(Prop_Hidden), "Don't color the contours");
ADD_PROPERTY_TYPE(VectorMode,
((long)0),
"Contours",
App::Prop_None,
"Select what vector field");
ADD_PROPERTY_TYPE(NoColor,
(false),
"Contours",
PropertyType(Prop_Hidden),
"Don't color the contours");
m_contourConstraints.LowerBound = 1;
m_contourConstraints.UpperBound = 1000;
@@ -509,23 +545,27 @@ DocumentObjectExecReturn* FemPostContoursFilter::execute()
// delete contour field
vtkSmartPointer<vtkDataObject> data = getInputData();
vtkDataSet* dset = vtkDataSet::SafeDownCast(data);
if (!dset)
if (!dset) {
return returnObject;
}
dset->GetPointData()->RemoveArray(contourFieldName.c_str());
// refresh fields to reflect the deletion
if (!m_blockPropertyChanges)
if (!m_blockPropertyChanges) {
refreshFields();
}
return returnObject;
}
void FemPostContoursFilter::onChanged(const Property* prop)
{
if (m_blockPropertyChanges)
if (m_blockPropertyChanges) {
return;
}
if (prop == &Field && (Field.getValue() >= 0))
if (prop == &Field && (Field.getValue() >= 0)) {
refreshVectors();
}
// note that we need to calculate also in case of a Data change
// otherwise the contours output would be empty and the ViewProviderFemPostObject
@@ -537,15 +577,20 @@ void FemPostContoursFilter::onChanged(const Property* prop)
// get the field and its data
vtkSmartPointer<vtkDataObject> data = getInputData();
vtkDataSet* dset = vtkDataSet::SafeDownCast(data);
if (!dset)
if (!dset) {
return;
}
vtkDataArray* pdata = dset->GetPointData()->GetArray(Field.getValueAsString());
if (!pdata)
if (!pdata) {
return;
}
if (pdata->GetNumberOfComponents() == 1) {
// if we have a scalar, we can directly use the array
m_contours->SetInputArrayToProcess(
0, 0, 0, vtkDataObject::FIELD_ASSOCIATION_POINTS, Field.getValueAsString());
m_contours->SetInputArrayToProcess(0,
0,
0,
vtkDataObject::FIELD_ASSOCIATION_POINTS,
Field.getValueAsString());
pdata->GetRange(p);
recalculateContours(p[0], p[1]);
}
@@ -555,12 +600,15 @@ void FemPostContoursFilter::onChanged(const Property* prop)
// scalar array and append this temporarily to the data. (vtkExtractVectorComponents
// does not work because our data is an unstructured data set.)
int component = -1;
if (VectorMode.getValue() == 1)
if (VectorMode.getValue() == 1) {
component = 0;
else if (VectorMode.getValue() == 2)
}
else if (VectorMode.getValue() == 2) {
component = 1;
else if (VectorMode.getValue() == 3)
}
else if (VectorMode.getValue() == 3) {
component = 2;
}
// extract the component to a new array
vtkSmartPointer<vtkDoubleArray> componentArray = vtkSmartPointer<vtkDoubleArray>::New();
componentArray->SetNumberOfComponents(1);
@@ -569,8 +617,9 @@ void FemPostContoursFilter::onChanged(const Property* prop)
if (component >= 0) {
for (vtkIdType tupleIdx = 0; tupleIdx < numTuples; ++tupleIdx) {
componentArray->SetComponent(
tupleIdx, 0, pdata->GetComponent(tupleIdx, component));
componentArray->SetComponent(tupleIdx,
0,
pdata->GetComponent(tupleIdx, component));
}
}
else {
@@ -590,8 +639,11 @@ void FemPostContoursFilter::onChanged(const Property* prop)
// add the array as new field and use it for the contour filter
dset->GetPointData()->AddArray(componentArray);
m_contours->SetInputArrayToProcess(
0, 0, 0, vtkDataObject::FIELD_ASSOCIATION_POINTS, contourFieldName.c_str());
m_contours->SetInputArrayToProcess(0,
0,
0,
vtkDataObject::FIELD_ASSOCIATION_POINTS,
contourFieldName.c_str());
componentArray->GetRange(p);
recalculateContours(p[0], p[1]);
if (prop == &Data) {
@@ -610,10 +662,12 @@ void FemPostContoursFilter::onChanged(const Property* prop)
short int FemPostContoursFilter::mustExecute() const
{
if (Field.isTouched() || VectorMode.isTouched() || NumberOfContours.isTouched()
|| Data.isTouched())
|| Data.isTouched()) {
return 1;
else
}
else {
return App::DocumentObject::mustExecute();
}
}
void FemPostContoursFilter::recalculateContours(double min, double max)
@@ -630,8 +684,9 @@ void FemPostContoursFilter::refreshFields()
m_blockPropertyChanges = true;
std::string fieldName;
if (Field.getValue() >= 0)
if (Field.getValue() >= 0) {
fieldName = Field.getValueAsString();
}
std::vector<std::string> FieldsArray;
@@ -688,12 +743,14 @@ void FemPostContoursFilter::refreshVectors()
// store name if already set
std::string vectorName;
if (VectorMode.hasEnums() && VectorMode.getValue() >= 0)
if (VectorMode.hasEnums() && VectorMode.getValue() >= 0) {
vectorName = VectorMode.getValueAsString();
}
std::vector<std::string> vectorArray;
if (fieldArray->GetNumberOfComponents() == 1)
if (fieldArray->GetNumberOfComponents() == 1) {
vectorArray.emplace_back("Not a vector");
}
else {
vectorArray.emplace_back("Magnitude");
if (fieldArray->GetNumberOfComponents() >= 2) {
@@ -711,8 +768,9 @@ void FemPostContoursFilter::refreshVectors()
// apply stored name
auto it = std::find(vectorArray.begin(), vectorArray.end(), vectorName);
if (!vectorName.empty() && it != vectorArray.end())
if (!vectorName.empty() && it != vectorArray.end()) {
VectorMode.setValue(vectorName.c_str());
}
m_blockPropertyChanges = false;
}
@@ -756,16 +814,19 @@ void FemPostCutFilter::onChanged(const Property* prop)
short int FemPostCutFilter::mustExecute() const
{
if (Function.isTouched())
if (Function.isTouched()) {
return 1;
else
}
else {
return App::DocumentObject::mustExecute();
}
}
DocumentObjectExecReturn* FemPostCutFilter::execute()
{
if (!m_cutter->GetCutFunction())
if (!m_cutter->GetCutFunction()) {
return StdReturn;
}
return Fem::FemPostFilter::execute();
}
@@ -775,17 +836,22 @@ DocumentObjectExecReturn* FemPostCutFilter::execute()
// scalar clip filter
PROPERTY_SOURCE(Fem::FemPostScalarClipFilter, Fem::FemPostFilter)
FemPostScalarClipFilter::FemPostScalarClipFilter() : FemPostFilter() {
FemPostScalarClipFilter::FemPostScalarClipFilter()
: FemPostFilter()
{
ADD_PROPERTY_TYPE(
Value, (0), "Clip", App::Prop_None, "The scalar value used to clip the selected field");
ADD_PROPERTY_TYPE(Value,
(0),
"Clip",
App::Prop_None,
"The scalar value used to clip the selected field");
ADD_PROPERTY_TYPE(Scalars, (long(0)), "Clip", App::Prop_None, "The field used to clip");
ADD_PROPERTY_TYPE(InsideOut, (false), "Clip", App::Prop_None, "Invert the clip direction");
Value.setConstraints(&m_constraints);
FilterPipeline clip;
m_clipper = vtkSmartPointer<vtkTableBasedClipDataSet>::New();
m_clipper = vtkSmartPointer<vtkTableBasedClipDataSet>::New();
clip.source = m_clipper;
clip.target = m_clipper;
addFilterPipeline(clip, "clip");
@@ -797,21 +863,24 @@ FemPostScalarClipFilter::~FemPostScalarClipFilter() = default;
DocumentObjectExecReturn* FemPostScalarClipFilter::execute()
{
std::string val;
if (Scalars.getValue() >= 0)
if (Scalars.getValue() >= 0) {
val = Scalars.getValueAsString();
}
std::vector<std::string> ScalarsArray;
vtkSmartPointer<vtkDataObject> data = getInputData();
vtkDataSet* dset = vtkDataSet::SafeDownCast(data);
if (!dset)
if (!dset) {
return StdReturn;
}
vtkPointData* pd = dset->GetPointData();
// get all scalar fields
for (int i = 0; i < pd->GetNumberOfArrays(); ++i) {
if (pd->GetArray(i)->GetNumberOfComponents() == 1)
if (pd->GetArray(i)->GetNumberOfComponents() == 1) {
ScalarsArray.emplace_back(pd->GetArrayName(i));
}
}
App::Enumeration empty;
@@ -822,10 +891,11 @@ DocumentObjectExecReturn* FemPostScalarClipFilter::execute()
// search if the current field is in the available ones and set it
std::vector<std::string>::iterator it =
std::find(ScalarsArray.begin(), ScalarsArray.end(), val);
if (!val.empty() && it != ScalarsArray.end())
if (!val.empty() && it != ScalarsArray.end()) {
Scalars.setValue(val.c_str());
}
//recalculate the filter
// recalculate the filter
return Fem::FemPostFilter::execute();
}
@@ -838,8 +908,11 @@ void FemPostScalarClipFilter::onChanged(const Property* prop)
m_clipper->SetInsideOut(InsideOut.getValue());
}
else if (prop == &Scalars && (Scalars.getValue() >= 0)) {
m_clipper->SetInputArrayToProcess(0, 0, 0,
vtkDataObject::FIELD_ASSOCIATION_POINTS, Scalars.getValueAsString());
m_clipper->SetInputArrayToProcess(0,
0,
0,
vtkDataObject::FIELD_ASSOCIATION_POINTS,
Scalars.getValueAsString());
setConstraintForField();
}
@@ -848,26 +921,28 @@ void FemPostScalarClipFilter::onChanged(const Property* prop)
short int FemPostScalarClipFilter::mustExecute() const
{
if (Value.isTouched() ||
InsideOut.isTouched() ||
Scalars.isTouched())
if (Value.isTouched() || InsideOut.isTouched() || Scalars.isTouched()) {
return 1;
else
}
else {
return App::DocumentObject::mustExecute();
}
}
void FemPostScalarClipFilter::setConstraintForField()
{
vtkSmartPointer<vtkDataObject> data = getInputData();
vtkDataSet* dset = vtkDataSet::SafeDownCast(data);
if (!dset)
if (!dset) {
return;
}
vtkDataArray* pdata = dset->GetPointData()->GetArray(Scalars.getValueAsString());
// VTK cannot deliver data when the filer relies e.g. on a cut clip filter
// whose value is set so that all data are cut
if (!pdata)
if (!pdata) {
return;
}
double p[2];
pdata->GetRange(p);
m_constraints.LowerBound = p[0];
@@ -880,18 +955,22 @@ void FemPostScalarClipFilter::setConstraintForField()
// warp vector filter
PROPERTY_SOURCE(Fem::FemPostWarpVectorFilter, Fem::FemPostFilter)
FemPostWarpVectorFilter::FemPostWarpVectorFilter() : FemPostFilter()
FemPostWarpVectorFilter::FemPostWarpVectorFilter()
: FemPostFilter()
{
ADD_PROPERTY_TYPE(Factor,
(0),
"Warp",
App::Prop_None,
"The factor by which the vector is added to the node positions");
ADD_PROPERTY_TYPE(
Vector, (long(0)), "Warp", App::Prop_None, "The field added to the node position");
ADD_PROPERTY_TYPE(Vector,
(long(0)),
"Warp",
App::Prop_None,
"The field added to the node position");
FilterPipeline warp;
m_warp = vtkSmartPointer<vtkWarpVector>::New();
m_warp = vtkSmartPointer<vtkWarpVector>::New();
warp.source = m_warp;
warp.target = m_warp;
addFilterPipeline(warp, "warp");
@@ -903,21 +982,24 @@ FemPostWarpVectorFilter::~FemPostWarpVectorFilter() = default;
DocumentObjectExecReturn* FemPostWarpVectorFilter::execute()
{
std::string val;
if (Vector.getValue() >= 0)
if (Vector.getValue() >= 0) {
val = Vector.getValueAsString();
}
std::vector<std::string> VectorArray;
vtkSmartPointer<vtkDataObject> data = getInputData();
vtkDataSet* dset = vtkDataSet::SafeDownCast(data);
if (!dset)
if (!dset) {
return StdReturn;
}
vtkPointData* pd = dset->GetPointData();
// get all vector fields
for (int i = 0; i < pd->GetNumberOfArrays(); ++i) {
if (pd->GetArray(i)->GetNumberOfComponents() == 3)
if (pd->GetArray(i)->GetNumberOfComponents() == 3) {
VectorArray.emplace_back(pd->GetArrayName(i));
}
}
App::Enumeration empty;
@@ -926,31 +1008,38 @@ DocumentObjectExecReturn* FemPostWarpVectorFilter::execute()
Vector.setValue(m_vectorFields);
// search if the current field is in the available ones and set it
std::vector<std::string>::iterator it =
std::find(VectorArray.begin(), VectorArray.end(), val);
if (!val.empty() && it != VectorArray.end())
std::vector<std::string>::iterator it = std::find(VectorArray.begin(), VectorArray.end(), val);
if (!val.empty() && it != VectorArray.end()) {
Vector.setValue(val.c_str());
}
//recalculate the filter
// recalculate the filter
return Fem::FemPostFilter::execute();
}
void FemPostWarpVectorFilter::onChanged(const Property* prop)
{
if (prop == &Factor)
if (prop == &Factor) {
// since our mesh is in mm, we must scale the factor
m_warp->SetScaleFactor(1000 * Factor.getValue());
else if (prop == &Vector && (Vector.getValue() >= 0))
m_warp->SetInputArrayToProcess(0, 0, 0,
vtkDataObject::FIELD_ASSOCIATION_POINTS, Vector.getValueAsString());
}
else if (prop == &Vector && (Vector.getValue() >= 0)) {
m_warp->SetInputArrayToProcess(0,
0,
0,
vtkDataObject::FIELD_ASSOCIATION_POINTS,
Vector.getValueAsString());
}
Fem::FemPostFilter::onChanged(prop);
}
short int FemPostWarpVectorFilter::mustExecute() const
{
if (Factor.isTouched() || Vector.isTouched())
if (Factor.isTouched() || Vector.isTouched()) {
return 1;
else
}
else {
return App::DocumentObject::mustExecute();
}
}

View File

@@ -28,11 +28,11 @@
#include <vtkExtractGeometry.h>
#include <vtkExtractVectorComponents.h>
#include <vtkLineSource.h>
#include <vtkVectorNorm.h>
#include <vtkPointSource.h>
#include <vtkProbeFilter.h>
#include <vtkSmartPointer.h>
#include <vtkTableBasedClipDataSet.h>
#include <vtkVectorNorm.h>
#include <vtkWarpVector.h>
#include <App/PropertyUnits.h>
@@ -43,7 +43,7 @@
namespace Fem
{
class FemExport FemPostFilter : public Fem::FemPostObject
class FemExport FemPostFilter: public Fem::FemPostObject
{
PROPERTY_HEADER_WITH_OVERRIDE(Fem::FemPostFilter);
@@ -59,18 +59,20 @@ public:
protected:
vtkDataObject* getInputData();
//pipeline handling for derived filter
struct FilterPipeline {
vtkSmartPointer<vtkAlgorithm> source, target;
vtkSmartPointer<vtkProbeFilter> filterSource, filterTarget;
std::vector<vtkSmartPointer<vtkAlgorithm> > algorithmStorage;
// pipeline handling for derived filter
struct FilterPipeline
{
vtkSmartPointer<vtkAlgorithm> source, target;
vtkSmartPointer<vtkProbeFilter> filterSource, filterTarget;
std::vector<vtkSmartPointer<vtkAlgorithm>> algorithmStorage;
};
void addFilterPipeline(const FilterPipeline& p, std::string name);
void setActiveFilterPipeline(std::string name);
FilterPipeline& getFilterPipeline(std::string name);
private:
//handling of multiple pipelines which can be the filter
// handling of multiple pipelines which can be the filter
std::map<std::string, FilterPipeline> m_pipelines;
std::string m_activePipeline;
};
@@ -93,14 +95,14 @@ public:
App::PropertyVectorDistance Point1;
App::PropertyVectorDistance Point2;
App::PropertyInteger Resolution;
App::PropertyFloatList XAxisData;
App::PropertyFloatList YAxisData;
App::PropertyString PlotData;
App::PropertyInteger Resolution;
App::PropertyFloatList XAxisData;
App::PropertyFloatList YAxisData;
App::PropertyString PlotData;
const char* getViewProviderName() const override
{
return "FemGui::ViewProviderFemPostDataAlongLine";
return "FemGui::ViewProviderFemPostDataAlongLine";
}
short int mustExecute() const override;
void GetAxisData();
@@ -108,7 +110,8 @@ public:
protected:
App::DocumentObjectExecReturn* execute() override;
void onChanged(const App::Property* prop) override;
void handleChangedPropertyType(Base::XMLReader& reader, const char* TypeName,
void handleChangedPropertyType(Base::XMLReader& reader,
const char* TypeName,
App::Property* prop) override;
private:
@@ -128,15 +131,15 @@ public:
FemPostDataAtPointFilter();
~FemPostDataAtPointFilter() override;
App::PropertyVectorDistance Center;
App::PropertyDistance Radius;
App::PropertyString FieldName;
App::PropertyFloatList PointData;
App::PropertyString Unit;
App::PropertyVectorDistance Center;
App::PropertyDistance Radius;
App::PropertyString FieldName;
App::PropertyFloatList PointData;
App::PropertyString Unit;
const char* getViewProviderName() const override
{
return "FemGui::ViewProviderFemPostDataAtPoint";
return "FemGui::ViewProviderFemPostDataAtPoint";
}
short int mustExecute() const override;
@@ -168,7 +171,7 @@ public:
const char* getViewProviderName() const override
{
return "FemGui::ViewProviderFemPostClip";
return "FemGui::ViewProviderFemPostClip";
}
short int mustExecute() const override;
App::DocumentObjectExecReturn* execute() override;
@@ -286,7 +289,8 @@ private:
// ***************************************************************************
// warp vector filter
class FemExport FemPostWarpVectorFilter : public FemPostFilter {
class FemExport FemPostWarpVectorFilter: public FemPostFilter
{
PROPERTY_HEADER_WITH_OVERRIDE(Fem::FemPostWarpVectorFilter);
@@ -294,10 +298,11 @@ public:
FemPostWarpVectorFilter();
~FemPostWarpVectorFilter() override;
App::PropertyFloat Factor;
App::PropertyEnumeration Vector;
App::PropertyFloat Factor;
App::PropertyEnumeration Vector;
const char* getViewProviderName() const override {
const char* getViewProviderName() const override
{
return "FemGui::ViewProviderFemPostWarpVector";
}
short int mustExecute() const override;
@@ -307,11 +312,11 @@ protected:
void onChanged(const App::Property* prop) override;
private:
vtkSmartPointer<vtkWarpVector> m_warp;
App::Enumeration m_vectorFields;
vtkSmartPointer<vtkWarpVector> m_warp;
App::Enumeration m_vectorFields;
};
} //namespace Fem
} // namespace Fem
#endif // Fem_FemPostFilter_H
#endif // Fem_FemPostFilter_H

View File

@@ -30,14 +30,17 @@ using namespace App;
PROPERTY_SOURCE(Fem::FemPostFunctionProvider, App::DocumentObject)
FemPostFunctionProvider::FemPostFunctionProvider() : DocumentObject() {
FemPostFunctionProvider::FemPostFunctionProvider()
: DocumentObject()
{
ADD_PROPERTY(Functions, (nullptr));
}
FemPostFunctionProvider::~FemPostFunctionProvider() = default;
void FemPostFunctionProvider::onChanged(const Property* prop) {
void FemPostFunctionProvider::onChanged(const Property* prop)
{
App::DocumentObject::onChanged(prop);
}
@@ -48,7 +51,8 @@ FemPostFunction::FemPostFunction() = default;
FemPostFunction::~FemPostFunction() = default;
DocumentObjectExecReturn* FemPostFunction::execute() {
DocumentObjectExecReturn* FemPostFunction::execute()
{
return DocumentObject::StdReturn;
}
@@ -80,10 +84,12 @@ void FemPostBoxFunction::onChanged(const Property* prop)
float l = Length.getValue();
float w = Width.getValue();
float h = Height.getValue();
m_box->SetBounds(
vec[0] - l/2, vec[0] + l/2,
vec[1] - w/2, vec[1] + w/2,
vec[2] - h/2, vec[2] + h/2);
m_box->SetBounds(vec[0] - l / 2,
vec[0] + l / 2,
vec[1] - w / 2,
vec[1] + w / 2,
vec[2] - h / 2,
vec[2] + h / 2);
}
Fem::FemPostFunction::onChanged(prop);
@@ -145,7 +151,9 @@ void FemPostCylinderFunction::onDocumentRestored()
// plane function
PROPERTY_SOURCE(Fem::FemPostPlaneFunction, Fem::FemPostFunction)
FemPostPlaneFunction::FemPostPlaneFunction() : FemPostFunction() {
FemPostPlaneFunction::FemPostPlaneFunction()
: FemPostFunction()
{
ADD_PROPERTY(Origin, (Base::Vector3d(0.0, 0.0, 0.0)));
ADD_PROPERTY(Normal, (Base::Vector3d(0.0, 0.0, 1.0)));
@@ -159,7 +167,8 @@ FemPostPlaneFunction::FemPostPlaneFunction() : FemPostFunction() {
FemPostPlaneFunction::~FemPostPlaneFunction() = default;
void FemPostPlaneFunction::onChanged(const Property* prop) {
void FemPostPlaneFunction::onChanged(const Property* prop)
{
if (prop == &Origin) {
const Base::Vector3d& vec = Origin.getValue();
@@ -173,7 +182,8 @@ void FemPostPlaneFunction::onChanged(const Property* prop) {
Fem::FemPostFunction::onChanged(prop);
}
void FemPostPlaneFunction::onDocumentRestored() {
void FemPostPlaneFunction::onDocumentRestored()
{
// This is to notify the view provider that the document has been fully restored
Normal.touch();
}
@@ -183,7 +193,9 @@ void FemPostPlaneFunction::onDocumentRestored() {
// sphere function
PROPERTY_SOURCE(Fem::FemPostSphereFunction, Fem::FemPostFunction)
FemPostSphereFunction::FemPostSphereFunction() : FemPostFunction() {
FemPostSphereFunction::FemPostSphereFunction()
: FemPostFunction()
{
ADD_PROPERTY(Radius, (5.0));
ADD_PROPERTY(Center, (Base::Vector3d(1.0, 0.0, 0.0)));
@@ -197,7 +209,8 @@ FemPostSphereFunction::FemPostSphereFunction() : FemPostFunction() {
FemPostSphereFunction::~FemPostSphereFunction() = default;
void FemPostSphereFunction::onChanged(const Property* prop) {
void FemPostSphereFunction::onChanged(const Property* prop)
{
if (prop == &Center) {
const Base::Vector3d& vec = Center.getValue();

View File

@@ -39,7 +39,7 @@
namespace Fem
{
class FemExport FemPostFunction : public App::DocumentObject
class FemExport FemPostFunction: public App::DocumentObject
{
PROPERTY_HEADER_WITH_OVERRIDE(Fem::FemPostFunction);
@@ -48,24 +48,32 @@ public:
FemPostFunction();
~FemPostFunction() override;
const char* getViewProviderName() const override {
const char* getViewProviderName() const override
{
return "FemGui::ViewProviderFemPostFunction";
}
App::DocumentObjectExecReturn* execute() override;
//bound box handling
void setBoundingBox(vtkBoundingBox b) {m_boundingBox = b;};
// bound box handling
void setBoundingBox(vtkBoundingBox b)
{
m_boundingBox = b;
};
//get the algorithm or the data
vtkSmartPointer<vtkImplicitFunction> getImplicitFunction() {return m_implicit;};
// get the algorithm or the data
vtkSmartPointer<vtkImplicitFunction> getImplicitFunction()
{
return m_implicit;
};
protected:
vtkSmartPointer<vtkImplicitFunction> m_implicit;
vtkBoundingBox m_boundingBox;
vtkSmartPointer<vtkImplicitFunction> m_implicit;
vtkBoundingBox m_boundingBox;
};
class FemExport FemPostFunctionProvider : public App::DocumentObject {
class FemExport FemPostFunctionProvider: public App::DocumentObject
{
PROPERTY_HEADER_WITH_OVERRIDE(Fem::FemPostFunctionProvider);
@@ -73,7 +81,8 @@ public:
FemPostFunctionProvider();
~FemPostFunctionProvider() override;
const char* getViewProviderName() const override {
const char* getViewProviderName() const override
{
return "FemGui::ViewProviderFemPostFunctionProvider";
}
@@ -85,21 +94,21 @@ protected:
// ---------------------------------------------------------------------------
class FemExport FemPostBoxFunction : public FemPostFunction
class FemExport FemPostBoxFunction: public FemPostFunction
{
PROPERTY_HEADER_WITH_OVERRIDE(Fem::FemPostBoxFunction);
public:
FemPostBoxFunction();
~FemPostBoxFunction() override;
App::PropertyVectorDistance Center;
App::PropertyDistance Length;
App::PropertyDistance Width;
App::PropertyDistance Height;
App::PropertyVectorDistance Center;
App::PropertyDistance Length;
App::PropertyDistance Width;
App::PropertyDistance Height;
const char* getViewProviderName() const override {
const char* getViewProviderName() const override
{
return "FemGui::ViewProviderFemPostBoxFunction";
}
@@ -113,20 +122,20 @@ protected:
// ---------------------------------------------------------------------------
class FemExport FemPostCylinderFunction : public FemPostFunction
class FemExport FemPostCylinderFunction: public FemPostFunction
{
PROPERTY_HEADER_WITH_OVERRIDE(Fem::FemPostCylinderFunction);
public:
FemPostCylinderFunction();
~FemPostCylinderFunction() override;
App::PropertyVector Axis;
App::PropertyVectorDistance Center;
App::PropertyDistance Radius;
App::PropertyVector Axis;
App::PropertyVectorDistance Center;
App::PropertyDistance Radius;
const char* getViewProviderName() const override {
const char* getViewProviderName() const override
{
return "FemGui::ViewProviderFemPostCylinderFunction";
}
@@ -140,19 +149,19 @@ protected:
// ---------------------------------------------------------------------------
class FemExport FemPostPlaneFunction : public FemPostFunction
class FemExport FemPostPlaneFunction: public FemPostFunction
{
PROPERTY_HEADER_WITH_OVERRIDE(Fem::FemPostPlaneFunction);
public:
FemPostPlaneFunction();
~FemPostPlaneFunction() override;
App::PropertyVector Normal;
App::PropertyVectorDistance Origin;
App::PropertyVector Normal;
App::PropertyVectorDistance Origin;
const char* getViewProviderName() const override {
const char* getViewProviderName() const override
{
return "FemGui::ViewProviderFemPostPlaneFunction";
}
@@ -166,19 +175,19 @@ protected:
// ---------------------------------------------------------------------------
class FemExport FemPostSphereFunction : public FemPostFunction
class FemExport FemPostSphereFunction: public FemPostFunction
{
PROPERTY_HEADER_WITH_OVERRIDE(Fem::FemPostSphereFunction);
public:
FemPostSphereFunction();
~FemPostSphereFunction() override;
App::PropertyDistance Radius;
App::PropertyVectorDistance Center;
App::PropertyDistance Radius;
App::PropertyVectorDistance Center;
const char* getViewProviderName() const override {
const char* getViewProviderName() const override
{
return "FemGui::ViewProviderFemPostSphereFunction";
}
@@ -188,7 +197,7 @@ protected:
vtkSmartPointer<vtkSphere> m_sphere;
};
} //namespace Fem
} // namespace Fem
#endif // Fem_FemPostFunction_H
#endif // Fem_FemPostFunction_H

View File

@@ -23,7 +23,7 @@
#include "PreCompiled.h"
#ifndef _PreComp_
# include <vtkDataSet.h>
#include <vtkDataSet.h>
#endif
#include "FemPostObject.h"
@@ -42,13 +42,15 @@ FemPostObject::FemPostObject()
FemPostObject::~FemPostObject() = default;
vtkBoundingBox FemPostObject::getBoundingBox() {
vtkBoundingBox FemPostObject::getBoundingBox()
{
vtkBoundingBox box;
vtkDataSet* dset = vtkDataSet::SafeDownCast(Data.getValue());
if (dset)
if (dset) {
box.AddBounds(dset->GetBounds());
}
// TODO: add calculation of multiblock and Multipiece datasets

View File

@@ -24,8 +24,8 @@
#ifndef Fem_FemPostObject_H
#define Fem_FemPostObject_H
#include <App/GeoFeature.h>
#include "PropertyPostDataObject.h"
#include <App/GeoFeature.h>
#include <vtkBoundingBox.h>
@@ -34,7 +34,7 @@ namespace Fem
// poly data is the only data we can visualize, hence every post
// processing object needs to expose it
class FemExport FemPostObject : public App::GeoFeature
class FemExport FemPostObject: public App::GeoFeature
{
PROPERTY_HEADER_WITH_OVERRIDE(Fem::FemPostObject);
@@ -48,7 +48,7 @@ public:
vtkBoundingBox getBoundingBox();
};
} //namespace Fem
} // namespace Fem
#endif // Fem_FemPostObject_H
#endif // Fem_FemPostObject_H

View File

@@ -23,27 +23,27 @@
#include "PreCompiled.h"
#ifndef _PreComp_
# include <Python.h>
# include <vtkAppendFilter.h>
# include <vtkDataSetReader.h>
# include <vtkImageData.h>
# include <vtkRectilinearGrid.h>
# include <vtkStructuredGrid.h>
# include <vtkUnstructuredGrid.h>
# include <vtkXMLImageDataReader.h>
# include <vtkXMLPolyDataReader.h>
# include <vtkXMLPUnstructuredGridReader.h>
# include <vtkXMLRectilinearGridReader.h>
# include <vtkXMLStructuredGridReader.h>
# include <vtkXMLUnstructuredGridReader.h>
#include <Python.h>
#include <vtkAppendFilter.h>
#include <vtkDataSetReader.h>
#include <vtkImageData.h>
#include <vtkRectilinearGrid.h>
#include <vtkStructuredGrid.h>
#include <vtkUnstructuredGrid.h>
#include <vtkXMLImageDataReader.h>
#include <vtkXMLPUnstructuredGridReader.h>
#include <vtkXMLPolyDataReader.h>
#include <vtkXMLRectilinearGridReader.h>
#include <vtkXMLStructuredGridReader.h>
#include <vtkXMLUnstructuredGridReader.h>
#endif
#include <Base/Console.h>
#include "FemPostPipeline.h"
#include "FemPostPipelinePy.h"
#include "FemMesh.h"
#include "FemMeshObject.h"
#include "FemPostPipeline.h"
#include "FemPostPipelinePy.h"
#include "FemVTKTools.h"
@@ -51,12 +51,15 @@ using namespace Fem;
using namespace App;
PROPERTY_SOURCE(Fem::FemPostPipeline, Fem::FemPostObject)
const char* FemPostPipeline::ModeEnums[] = { "Serial", "Parallel", "Custom", nullptr };
const char* FemPostPipeline::ModeEnums[] = {"Serial", "Parallel", "Custom", nullptr};
FemPostPipeline::FemPostPipeline()
{
ADD_PROPERTY_TYPE(
Filter, (nullptr), "Pipeline", App::Prop_None, "The filter used in this pipeline");
ADD_PROPERTY_TYPE(Filter,
(nullptr),
"Pipeline",
App::Prop_None,
"The filter used in this pipeline");
ADD_PROPERTY_TYPE(Functions,
(nullptr),
"Pipeline",
@@ -77,25 +80,28 @@ FemPostPipeline::~FemPostPipeline() = default;
short FemPostPipeline::mustExecute() const
{
if (Mode.isTouched())
if (Mode.isTouched()) {
return 1;
}
return FemPostFilter::mustExecute();
}
DocumentObjectExecReturn* FemPostPipeline::execute() {
DocumentObjectExecReturn* FemPostPipeline::execute()
{
// if we are the toplevel pipeline our data object is not created by filters,
// we are the main source
if (!Input.getValue())
if (!Input.getValue()) {
return StdReturn;
}
// now if we are a filter than our data object is created by the filter we hold
// if we are in serial mode we just copy over the data of the last filter,
// but if we are in parallel we need to combine all filter results
if (Mode.getValue() == 0) {
//serial
// serial
Data.setValue(getLastPostObject()->Data.getValue());
}
else if (Mode.getValue() == 1) {
@@ -117,34 +123,45 @@ DocumentObjectExecReturn* FemPostPipeline::execute() {
}
bool FemPostPipeline::canRead(Base::FileInfo File) {
bool FemPostPipeline::canRead(Base::FileInfo File)
{
// from FemResult only unstructural mesh is supported in femvtktoools.cpp
return File.hasExtension({"vtk", "vtp", "vts", "vtr", "vti", "vtu", "pvtu"});
}
void FemPostPipeline::read(Base::FileInfo File) {
void FemPostPipeline::read(Base::FileInfo File)
{
// checking on the file
if (!File.isReadable())
if (!File.isReadable()) {
throw Base::FileException("File to load not existing or not readable", File);
}
if (File.hasExtension("vtu"))
if (File.hasExtension("vtu")) {
readXMLFile<vtkXMLUnstructuredGridReader>(File.filePath());
else if (File.hasExtension("pvtu"))
}
else if (File.hasExtension("pvtu")) {
readXMLFile<vtkXMLPUnstructuredGridReader>(File.filePath());
else if (File.hasExtension("vtp"))
}
else if (File.hasExtension("vtp")) {
readXMLFile<vtkXMLPolyDataReader>(File.filePath());
else if (File.hasExtension("vts"))
}
else if (File.hasExtension("vts")) {
readXMLFile<vtkXMLStructuredGridReader>(File.filePath());
else if (File.hasExtension("vtr"))
}
else if (File.hasExtension("vtr")) {
readXMLFile<vtkXMLRectilinearGridReader>(File.filePath());
else if (File.hasExtension("vti"))
}
else if (File.hasExtension("vti")) {
readXMLFile<vtkXMLImageDataReader>(File.filePath());
else if (File.hasExtension("vtk"))
}
else if (File.hasExtension("vtk")) {
readXMLFile<vtkDataSetReader>(File.filePath());
else
}
else {
throw Base::FileException("Unknown extension");
}
}
void FemPostPipeline::scale(double s)
@@ -158,14 +175,16 @@ void FemPostPipeline::onChanged(const Property* prop)
// if we are in custom mode the user is free to set the input
// thus nothing needs to be done here
if (Mode.getValue() == 2) // custom
if (Mode.getValue() == 2) { // custom
return;
}
// we check if all connections are right and add new ones if needed
std::vector<App::DocumentObject*> objs = Filter.getValues();
if (objs.empty())
if (objs.empty()) {
return;
}
std::vector<App::DocumentObject*>::iterator it = objs.begin();
FemPostFilter* filter = static_cast<FemPostFilter*>(*it);
@@ -174,8 +193,9 @@ void FemPostPipeline::onChanged(const Property* prop)
if (Input.getValue()) {
// the first filter is always connected to the input
if (filter->Input.getValue() != Input.getValue())
if (filter->Input.getValue() != Input.getValue()) {
filter->Input.setValue(Input.getValue());
}
// all the others need to be connected to the previous filter or the source,
// dependent on the mode
@@ -183,13 +203,15 @@ void FemPostPipeline::onChanged(const Property* prop)
for (; it != objs.end(); ++it) {
FemPostFilter* nextFilter = static_cast<FemPostFilter*>(*it);
if (Mode.getValue() == 0) { //serial mode
if (nextFilter->Input.getValue() != filter)
if (Mode.getValue() == 0) { // serial mode
if (nextFilter->Input.getValue() != filter) {
nextFilter->Input.setValue(filter);
}
}
else { //Parallel mode
if (nextFilter->Input.getValue() != Input.getValue())
else { // Parallel mode
if (nextFilter->Input.getValue() != Input.getValue()) {
nextFilter->Input.setValue(Input.getValue());
}
}
filter = nextFilter;
@@ -198,8 +220,9 @@ void FemPostPipeline::onChanged(const Property* prop)
// if we have no input the filters are responsible of grabbing the pipeline data themself
else {
// the first filter must always grab the data
if (filter->Input.getValue())
if (filter->Input.getValue()) {
filter->Input.setValue(nullptr);
}
// all the others need to be connected to the previous filter or grab the data,
// dependent on mode
@@ -207,13 +230,15 @@ void FemPostPipeline::onChanged(const Property* prop)
for (; it != objs.end(); ++it) {
FemPostFilter* nextFilter = static_cast<FemPostFilter*>(*it);
if (Mode.getValue() == 0) { //serial mode
if (nextFilter->Input.getValue() != filter)
if (Mode.getValue() == 0) { // serial mode
if (nextFilter->Input.getValue() != filter) {
nextFilter->Input.setValue(filter);
}
}
else { //Parallel mode
if (nextFilter->Input.getValue())
else { // Parallel mode
if (nextFilter->Input.getValue()) {
nextFilter->Input.setValue(nullptr);
}
}
filter = nextFilter;
@@ -222,35 +247,40 @@ void FemPostPipeline::onChanged(const Property* prop)
}
App::GeoFeature::onChanged(prop);
}
void FemPostPipeline::recomputeChildren()
{
for (const auto &obj : Filter.getValues())
for (const auto& obj : Filter.getValues()) {
obj->touch();
}
}
FemPostObject* FemPostPipeline::getLastPostObject() {
FemPostObject* FemPostPipeline::getLastPostObject()
{
if (Filter.getValues().empty())
if (Filter.getValues().empty()) {
return this;
}
return static_cast<FemPostObject*>(Filter.getValues().back());
}
bool FemPostPipeline::holdsPostObject(FemPostObject* obj) {
bool FemPostPipeline::holdsPostObject(FemPostObject* obj)
{
std::vector<App::DocumentObject*>::const_iterator it = Filter.getValues().begin();
for (; it != Filter.getValues().end(); ++it) {
if (*it == obj)
if (*it == obj) {
return true;
}
}
return false;
}
void FemPostPipeline::load(FemResultObject* res) {
void FemPostPipeline::load(FemResultObject* res)
{
if (!res->Mesh.getValue()) {
Base::Console().Log("Result mesh object is empty.\n");
return;

View File

@@ -34,7 +34,7 @@
namespace Fem
{
class FemExport FemPostPipeline : public Fem::FemPostFilter
class FemExport FemPostPipeline: public Fem::FemPostFilter
{
PROPERTY_HEADER_WITH_OVERRIDE(Fem::FemPostPipeline);
@@ -43,38 +43,41 @@ public:
FemPostPipeline();
~FemPostPipeline() override;
App::PropertyLinkList Filter;
App::PropertyLink Functions;
App::PropertyEnumeration Mode;
App::PropertyLinkList Filter;
App::PropertyLink Functions;
App::PropertyEnumeration Mode;
short mustExecute() const override;
App::DocumentObjectExecReturn* execute() override;
PyObject* getPyObject() override;
const char* getViewProviderName() const override {
const char* getViewProviderName() const override
{
return "FemGui::ViewProviderFemPostPipeline";
}
//load data from files
// load data from files
static bool canRead(Base::FileInfo file);
void read(Base::FileInfo file);
void scale(double s);
//load from results
// load from results
void load(FemResultObject* res);
//Pipeline handling
// Pipeline handling
void recomputeChildren();
FemPostObject *getLastPostObject();
bool holdsPostObject(FemPostObject *obj);
FemPostObject* getLastPostObject();
bool holdsPostObject(FemPostObject* obj);
protected:
void onChanged(const App::Property *prop) override;
void onChanged(const App::Property* prop) override;
private:
static const char* ModeEnums[];
template<class TReader> void readXMLFile(std::string file) {
template<class TReader>
void readXMLFile(std::string file)
{
vtkSmartPointer<TReader> reader = vtkSmartPointer<TReader>::New();
reader->SetFileName(file.c_str());
@@ -83,7 +86,7 @@ private:
}
};
} //namespace Fem
} // namespace Fem
#endif // Fem_FemPostPipeline_H
#endif // Fem_FemPostPipeline_H

View File

@@ -22,14 +22,16 @@
#include "PreCompiled.h"
#ifndef _PreComp_
# include <Python.h>
#include <Python.h>
#endif
#include <Base/FileInfo.h>
// clang-format off
#include "FemPostPipeline.h"
#include "FemPostPipelinePy.h"
#include "FemPostPipelinePy.cpp"
// clang-format on
using namespace Fem;
@@ -40,7 +42,7 @@ std::string FemPostPipelinePy::representation() const
return {"<FemPostPipeline object>"};
}
PyObject* FemPostPipelinePy::read(PyObject *args)
PyObject* FemPostPipelinePy::read(PyObject* args)
{
char* Name;
if (PyArg_ParseTuple(args, "et", "utf-8", &Name)) {
@@ -51,7 +53,7 @@ PyObject* FemPostPipelinePy::read(PyObject *args)
return nullptr;
}
PyObject* FemPostPipelinePy::scale(PyObject *args)
PyObject* FemPostPipelinePy::scale(PyObject* args)
{
double scale;
if (PyArg_ParseTuple(args, "d", &scale)) {
@@ -61,11 +63,12 @@ PyObject* FemPostPipelinePy::scale(PyObject *args)
return nullptr;
}
PyObject* FemPostPipelinePy::load(PyObject *args)
PyObject* FemPostPipelinePy::load(PyObject* args)
{
PyObject* py;
if (!PyArg_ParseTuple(args, "O!", &(App::DocumentObjectPy::Type), &py))
if (!PyArg_ParseTuple(args, "O!", &(App::DocumentObjectPy::Type), &py)) {
return nullptr;
}
App::DocumentObject* obj = static_cast<App::DocumentObjectPy*>(py)->getDocumentObjectPtr();
if (!obj->getTypeId().isDerivedFrom(FemResultObject::getClassTypeId())) {
@@ -77,31 +80,35 @@ PyObject* FemPostPipelinePy::load(PyObject *args)
Py_Return;
}
PyObject *FemPostPipelinePy::recomputeChildren(PyObject *args)
PyObject* FemPostPipelinePy::recomputeChildren(PyObject* args)
{
if (!PyArg_ParseTuple(args, ""))
if (!PyArg_ParseTuple(args, "")) {
return nullptr;
}
getFemPostPipelinePtr()->recomputeChildren();
Py_Return;
}
PyObject* FemPostPipelinePy::getLastPostObject(PyObject *args)
PyObject* FemPostPipelinePy::getLastPostObject(PyObject* args)
{
if (!PyArg_ParseTuple(args, ""))
if (!PyArg_ParseTuple(args, "")) {
return nullptr;
}
App::DocumentObject* obj = getFemPostPipelinePtr()->getLastPostObject();
if (obj)
if (obj) {
return obj->getPyObject();
}
Py_Return;
}
PyObject* FemPostPipelinePy::holdsPostObject(PyObject *args)
PyObject* FemPostPipelinePy::holdsPostObject(PyObject* args)
{
PyObject* py;
if (!PyArg_ParseTuple(args, "O!", &(App::DocumentObjectPy::Type), &py))
if (!PyArg_ParseTuple(args, "O!", &(App::DocumentObjectPy::Type), &py)) {
return nullptr;
}
App::DocumentObject* obj = static_cast<App::DocumentObjectPy*>(py)->getDocumentObjectPtr();
if (!obj->getTypeId().isDerivedFrom(FemPostObject::getClassTypeId())) {
@@ -113,7 +120,7 @@ PyObject* FemPostPipelinePy::holdsPostObject(PyObject *args)
return Py_BuildValue("O", (ok ? Py_True : Py_False));
}
PyObject *FemPostPipelinePy::getCustomAttributes(const char* /*attr*/) const
PyObject* FemPostPipelinePy::getCustomAttributes(const char* /*attr*/) const
{
return nullptr;
}

View File

@@ -54,29 +54,34 @@ short FemResultObject::mustExecute() const
return 0;
}
PyObject *FemResultObject::getPyObject()
PyObject* FemResultObject::getPyObject()
{
if (PythonObject.is(Py::_None())){
if (PythonObject.is(Py::_None())) {
// ref counter is set to 1
PythonObject = Py::Object(new DocumentObjectPy(this),true);
PythonObject = Py::Object(new DocumentObjectPy(this), true);
}
return Py::new_reference_to(PythonObject);
}
// Python feature ---------------------------------------------------------
namespace App {
namespace App
{
/// @cond DOXERR
PROPERTY_SOURCE_TEMPLATE(Fem::FemResultObjectPython, Fem::FemResultObject)
template<> const char* Fem::FemResultObjectPython::getViewProviderName() const {
template<>
const char* Fem::FemResultObjectPython::getViewProviderName() const
{
return "FemGui::ViewProviderResultPython";
}
/// @endcond
template<> PyObject* Fem::FemResultObjectPython::getPyObject() {
template<>
PyObject* Fem::FemResultObjectPython::getPyObject()
{
if (PythonObject.is(Py::_None())) {
// ref counter is set to 1
PythonObject = Py::Object(new App::FeaturePythonPyT<App::DocumentObjectPy>(this),true);
PythonObject = Py::Object(new App::FeaturePythonPyT<App::DocumentObjectPy>(this), true);
}
return Py::new_reference_to(PythonObject);
}
@@ -84,4 +89,4 @@ template<> PyObject* Fem::FemResultObjectPython::getPyObject() {
// explicit template instantiation
template class FemExport FeaturePythonT<Fem::FemResultObject>;
}
} // namespace App

View File

@@ -31,7 +31,7 @@
namespace Fem
{
/// Father of all result data in a Fem Analysis
class FemExport FemResultObject : public App::DocumentObject
class FemExport FemResultObject: public App::DocumentObject
{
PROPERTY_HEADER_WITH_OVERRIDE(Fem::FemResultObject);
@@ -50,20 +50,22 @@ public:
/// Displacement vectors of analysis
/// returns the type name of the ViewProvider
const char* getViewProviderName() const override {
const char* getViewProviderName() const override
{
return "FemGui::ViewProviderResult";
}
App::DocumentObjectExecReturn *execute() override {
App::DocumentObjectExecReturn* execute() override
{
return App::DocumentObject::StdReturn;
}
short mustExecute() const override;
PyObject *getPyObject() override;
PyObject* getPyObject() override;
};
using FemResultObjectPython = App::FeaturePythonT<FemResultObject>;
} //namespace Fem
} // namespace Fem
#endif // Fem_FemResultObject_H
#endif // Fem_FemResultObject_H

View File

@@ -42,12 +42,11 @@ short FemSetElementsObject::mustExecute() const
return 0;
}
PyObject *FemSetElementsObject::getPyObject()
PyObject* FemSetElementsObject::getPyObject()
{
if (PythonObject.is(Py::_None())){
if (PythonObject.is(Py::_None())) {
// ref counter is set to 1
PythonObject = Py::Object(new DocumentObjectPy(this),true);
PythonObject = Py::Object(new DocumentObjectPy(this), true);
}
return Py::new_reference_to(PythonObject);
}

View File

@@ -23,14 +23,14 @@
#ifndef Fem_FemSetElementsObjec_H
#define Fem_FemSetElementsObjec_H
#include <App/DocumentObject.h>
#include "FemSetObject.h"
#include <App/DocumentObject.h>
namespace Fem
{
class FemExport FemSetElementsObject : public FemSetObject
class FemExport FemSetElementsObject: public FemSetObject
{
PROPERTY_HEADER_WITH_OVERRIDE(Fem::FemSetElementsObject);
@@ -40,19 +40,19 @@ public:
~FemSetElementsObject() override;
// returns the type name of the ViewProvider
const char* getViewProviderName() const override {
const char* getViewProviderName() const override
{
return "FemGui::ViewProviderSetElements";
}
App::DocumentObjectExecReturn *execute() override {
App::DocumentObjectExecReturn* execute() override
{
return App::DocumentObject::StdReturn;
}
short mustExecute() const override;
PyObject *getPyObject() override;
PyObject* getPyObject() override;
};
} //namespace Fem
} // namespace Fem
#endif // Fem_FemSetElementsObjec_H
#endif // Fem_FemSetElementsObjec_H

View File

@@ -42,12 +42,11 @@ short FemSetFacesObject::mustExecute() const
return 0;
}
PyObject *FemSetFacesObject::getPyObject()
PyObject* FemSetFacesObject::getPyObject()
{
if (PythonObject.is(Py::_None())){
if (PythonObject.is(Py::_None())) {
// ref counter is set to 1
PythonObject = Py::Object(new DocumentObjectPy(this),true);
PythonObject = Py::Object(new DocumentObjectPy(this), true);
}
return Py::new_reference_to(PythonObject);
}

View File

@@ -23,14 +23,14 @@
#ifndef Fem_FemSetFacesObject_H
#define Fem_FemSetFacesObject_H
#include <App/DocumentObject.h>
#include "FemSetObject.h"
#include <App/DocumentObject.h>
namespace Fem
{
class FemExport FemSetFacesObject : public FemSetObject
class FemExport FemSetFacesObject: public FemSetObject
{
PROPERTY_HEADER_WITH_OVERRIDE(Fem::FemSetFacesObject);
@@ -40,17 +40,19 @@ public:
~FemSetFacesObject() override;
// returns the type name of the ViewProvider
const char* getViewProviderName() const override {
const char* getViewProviderName() const override
{
return "FemGui::ViewProviderSetFaces";
}
App::DocumentObjectExecReturn *execute() override {
App::DocumentObjectExecReturn* execute() override
{
return App::DocumentObject::StdReturn;
}
short mustExecute() const override;
PyObject *getPyObject() override;
PyObject* getPyObject() override;
};
} //namespace Fem
} // namespace Fem
#endif // Fem_FemSetFacesObject_H
#endif // Fem_FemSetFacesObject_H

View File

@@ -22,8 +22,8 @@
#include "PreCompiled.h"
#include <App/DocumentObjectPy.h>
#include "FemSetGeometryObject.h"
#include <App/DocumentObjectPy.h>
using namespace Fem;
@@ -41,12 +41,11 @@ short FemSetGeometryObject::mustExecute() const
return 0;
}
PyObject *FemSetGeometryObject::getPyObject()
PyObject* FemSetGeometryObject::getPyObject()
{
if (PythonObject.is(Py::_None())){
if (PythonObject.is(Py::_None())) {
// ref counter is set to 1
PythonObject = Py::Object(new DocumentObjectPy(this),true);
PythonObject = Py::Object(new DocumentObjectPy(this), true);
}
return Py::new_reference_to(PythonObject);
}

View File

@@ -23,14 +23,14 @@
#ifndef Fem_FemSetGeometryObject_H
#define Fem_FemSetGeometryObject_H
#include <App/DocumentObject.h>
#include "FemSetObject.h"
#include <App/DocumentObject.h>
namespace Fem
{
class FemExport FemSetGeometryObject : public FemSetObject
class FemExport FemSetGeometryObject: public FemSetObject
{
PROPERTY_HEADER_WITH_OVERRIDE(Fem::FemSetGeometryObject);
@@ -40,19 +40,19 @@ public:
~FemSetGeometryObject() override;
// returns the type name of the ViewProvider
const char* getViewProviderName() const override {
const char* getViewProviderName() const override
{
return "FemGui::ViewProviderSetGeometry";
}
App::DocumentObjectExecReturn *execute() override {
App::DocumentObjectExecReturn* execute() override
{
return App::DocumentObject::StdReturn;
}
short mustExecute() const override;
PyObject *getPyObject() override;
PyObject* getPyObject() override;
};
} //namespace Fem
} // namespace Fem
#endif // Fem_FemSetGeometryObject_H
#endif // Fem_FemSetGeometryObject_H

View File

@@ -35,7 +35,7 @@ PROPERTY_SOURCE(Fem::FemSetNodesObject, Fem::FemSetObject)
FemSetNodesObject::FemSetNodesObject()
{
ADD_PROPERTY_TYPE(Nodes,(), "Node indexes",Prop_None,"Nodes belonging to the NodesSet");
ADD_PROPERTY_TYPE(Nodes, (), "Node indexes", Prop_None, "Nodes belonging to the NodesSet");
}
FemSetNodesObject::~FemSetNodesObject() = default;
@@ -45,12 +45,11 @@ short FemSetNodesObject::mustExecute() const
return 0;
}
PyObject *FemSetNodesObject::getPyObject()
PyObject* FemSetNodesObject::getPyObject()
{
if (PythonObject.is(Py::_None())){
if (PythonObject.is(Py::_None())) {
// ref counter is set to 1
PythonObject = Py::Object(new DocumentObjectPy(this),true);
PythonObject = Py::Object(new DocumentObjectPy(this), true);
}
return Py::new_reference_to(PythonObject);
}

View File

@@ -24,14 +24,14 @@
#ifndef Fem_FemSetNodesObject_H
#define Fem_FemSetNodesObject_H
#include "FemSetObject.h"
#include <App/DocumentObject.h>
#include <App/PropertyStandard.h>
#include "FemSetObject.h"
namespace Fem
{
class FemExport FemSetNodesObject : public FemSetObject
class FemExport FemSetNodesObject: public FemSetObject
{
PROPERTY_HEADER_WITH_OVERRIDE(Fem::FemSetNodesObject);
@@ -43,19 +43,19 @@ public:
App::PropertyIntegerSet Nodes;
// returns the type name of the ViewProvider
const char* getViewProviderName() const override {
const char* getViewProviderName() const override
{
return "FemGui::ViewProviderSetNodes";
}
App::DocumentObjectExecReturn *execute() override {
App::DocumentObjectExecReturn* execute() override
{
return App::DocumentObject::StdReturn;
}
short mustExecute() const override;
PyObject *getPyObject() override;
PyObject* getPyObject() override;
};
} //namespace Fem
} // namespace Fem
#endif // Fem_FemSetNodesObject_H
#endif // Fem_FemSetNodesObject_H

View File

@@ -22,8 +22,8 @@
#include "PreCompiled.h"
#include <App/DocumentObjectPy.h>
#include "FemSetObject.h"
#include <App/DocumentObjectPy.h>
using namespace Fem;
@@ -34,7 +34,7 @@ PROPERTY_SOURCE(Fem::FemSetObject, App::DocumentObject)
FemSetObject::FemSetObject()
{
ADD_PROPERTY_TYPE(FemMesh,(nullptr), "MeshSet link",Prop_None,"MeshSet the set belongs to");
ADD_PROPERTY_TYPE(FemMesh, (nullptr), "MeshSet link", Prop_None, "MeshSet the set belongs to");
}
FemSetObject::~FemSetObject() = default;
@@ -44,12 +44,11 @@ short FemSetObject::mustExecute() const
return 0;
}
PyObject *FemSetObject::getPyObject()
PyObject* FemSetObject::getPyObject()
{
if (PythonObject.is(Py::_None())){
if (PythonObject.is(Py::_None())) {
// ref counter is set to 1
PythonObject = Py::Object(new DocumentObjectPy(this),true);
PythonObject = Py::Object(new DocumentObjectPy(this), true);
}
return Py::new_reference_to(PythonObject);
}

View File

@@ -31,7 +31,7 @@
namespace Fem
{
class FemExport FemSetObject : public App::DocumentObject
class FemExport FemSetObject: public App::DocumentObject
{
PROPERTY_HEADER_WITH_OVERRIDE(Fem::FemSetObject);
@@ -43,19 +43,18 @@ public:
App::PropertyLink FemMesh;
/// returns the type name of the ViewProvider
//virtual const char* getViewProviderName(void) const {
// return "FemGui::ViewProviderFemSet";
//}
App::DocumentObjectExecReturn *execute() override {
// virtual const char* getViewProviderName(void) const {
// return "FemGui::ViewProviderFemSet";
// }
App::DocumentObjectExecReturn* execute() override
{
return App::DocumentObject::StdReturn;
}
short mustExecute() const override;
PyObject *getPyObject() override;
PyObject* getPyObject() override;
};
} //namespace Fem
} // namespace Fem
#endif // Fem_FemSetObject_H
#endif // Fem_FemSetObject_H

View File

@@ -44,28 +44,33 @@ short FemSolverObject::mustExecute() const
return 0;
}
PyObject *FemSolverObject::getPyObject()
PyObject* FemSolverObject::getPyObject()
{
if (PythonObject.is(Py::_None())){
if (PythonObject.is(Py::_None())) {
// ref counter is set to 1
PythonObject = Py::Object(new DocumentObjectPy(this),true);
PythonObject = Py::Object(new DocumentObjectPy(this), true);
}
return Py::new_reference_to(PythonObject);
}
// Python feature ---------------------------------------------------------
namespace App {
namespace App
{
/// @cond DOXERR
PROPERTY_SOURCE_TEMPLATE(Fem::FemSolverObjectPython, Fem::FemSolverObject)
template<> const char* Fem::FemSolverObjectPython::getViewProviderName() const {
template<>
const char* Fem::FemSolverObjectPython::getViewProviderName() const
{
return "FemGui::ViewProviderSolverPython";
}
template<> PyObject* Fem::FemSolverObjectPython::getPyObject() {
template<>
PyObject* Fem::FemSolverObjectPython::getPyObject()
{
if (PythonObject.is(Py::_None())) {
// ref counter is set to 1
PythonObject = Py::Object(new App::FeaturePythonPyT<App::DocumentObjectPy>(this),true);
PythonObject = Py::Object(new App::FeaturePythonPyT<App::DocumentObjectPy>(this), true);
}
return Py::new_reference_to(PythonObject);
}
@@ -73,4 +78,4 @@ template<> PyObject* Fem::FemSolverObjectPython::getPyObject() {
// explicit template instantiation
template class FemExport FeaturePythonT<Fem::FemSolverObject>;
}
} // namespace App

View File

@@ -31,7 +31,7 @@
namespace Fem
{
/// Father of all result data in a Fem Analysis
class FemExport FemSolverObject : public App::DocumentObject
class FemExport FemSolverObject: public App::DocumentObject
{
PROPERTY_HEADER_WITH_OVERRIDE(Fem::FemSolverObject);
@@ -43,20 +43,21 @@ public:
// Attributes are implemented in the FemSolverObjectPython
/// returns the type name of the ViewProvider
const char* getViewProviderName() const override {
const char* getViewProviderName() const override
{
return "FemGui::ViewProviderSolver";
}
App::DocumentObjectExecReturn *execute() override {
App::DocumentObjectExecReturn* execute() override
{
return App::DocumentObject::StdReturn;
}
short mustExecute() const override;
PyObject *getPyObject() override;
PyObject* getPyObject() override;
};
using FemSolverObjectPython = App::FeaturePythonT<FemSolverObject>;
} //namespace Fem
} // namespace Fem
#endif // Fem_FemSolverObject_H
#endif // Fem_FemSolverObject_H

View File

@@ -23,24 +23,24 @@
#include "PreCompiled.h"
#ifndef _PreComp_
# include <QFileInfo>
#include <QFileInfo>
# include <BRepAdaptor_Curve.hxx>
# include <BRepAdaptor_Surface.hxx>
# include <Geom_BezierCurve.hxx>
# include <Geom_BezierSurface.hxx>
# include <Geom_BSplineCurve.hxx>
# include <Geom_BSplineSurface.hxx>
# include <gp_Dir.hxx>
# include <gp_Lin.hxx>
# include <gp_Pln.hxx>
# include <gp_Vec.hxx>
# include <Precision.hxx>
# include <TColgp_Array2OfPnt.hxx>
# include <TopoDS.hxx>
# include <TopoDS_Shape.hxx>
# include <TopoDS_Edge.hxx>
# include <TopoDS_Face.hxx>
#include <BRepAdaptor_Curve.hxx>
#include <BRepAdaptor_Surface.hxx>
#include <Geom_BSplineCurve.hxx>
#include <Geom_BSplineSurface.hxx>
#include <Geom_BezierCurve.hxx>
#include <Geom_BezierSurface.hxx>
#include <Precision.hxx>
#include <TColgp_Array2OfPnt.hxx>
#include <TopoDS.hxx>
#include <TopoDS_Edge.hxx>
#include <TopoDS_Face.hxx>
#include <TopoDS_Shape.hxx>
#include <gp_Dir.hxx>
#include <gp_Lin.hxx>
#include <gp_Pln.hxx>
#include <gp_Vec.hxx>
#endif
#include <App/Application.h>
@@ -78,22 +78,22 @@ bool Fem::Tools::isPlanar(const TopoDS_Face& face)
else if (surface.GetType() == GeomAbs_BSplineSurface) {
Handle(Geom_BSplineSurface) spline = surface.BSpline();
try {
TColgp_Array2OfPnt poles(1,spline->NbUPoles(),1,spline->NbVPoles());
TColgp_Array2OfPnt poles(1, spline->NbUPoles(), 1, spline->NbVPoles());
spline->Poles(poles);
// get the plane from three control points
gp_Pnt p1 = poles(poles.LowerRow(),poles.LowerCol());
gp_Pnt p2 = poles(poles.UpperRow(),poles.LowerCol());
gp_Pnt p3 = poles(poles.LowerRow(),poles.UpperCol());
gp_Pnt p1 = poles(poles.LowerRow(), poles.LowerCol());
gp_Pnt p2 = poles(poles.UpperRow(), poles.LowerCol());
gp_Pnt p3 = poles(poles.LowerRow(), poles.UpperCol());
gp_Vec vec1(p1, p2);
gp_Vec vec2(p1, p3);
gp_Vec vec3 = vec1.Crossed(vec2);
gp_Pln plane(p1, gp_Dir(vec3));
for (int i=poles.LowerRow(); i<=poles.UpperRow(); i++) {
for (int j=poles.LowerCol(); j<poles.UpperCol(); j++) {
for (int i = poles.LowerRow(); i <= poles.UpperRow(); i++) {
for (int j = poles.LowerCol(); j < poles.UpperCol(); j++) {
// are control points coplanar?
const gp_Pnt& pole = poles(i,j);
const gp_Pnt& pole = poles(i, j);
Standard_Real dist = plane.Distance(pole);
if (dist > Precision::Confusion()) {
return false;
@@ -110,22 +110,22 @@ bool Fem::Tools::isPlanar(const TopoDS_Face& face)
else if (surface.GetType() == GeomAbs_BezierSurface) {
Handle(Geom_BezierSurface) bezier = surface.Bezier();
try {
TColgp_Array2OfPnt poles(1,bezier->NbUPoles(),1,bezier->NbVPoles());
TColgp_Array2OfPnt poles(1, bezier->NbUPoles(), 1, bezier->NbVPoles());
bezier->Poles(poles);
// get the plane from three control points
gp_Pnt p1 = poles(poles.LowerRow(),poles.LowerCol());
gp_Pnt p2 = poles(poles.UpperRow(),poles.LowerCol());
gp_Pnt p3 = poles(poles.LowerRow(),poles.UpperCol());
gp_Pnt p1 = poles(poles.LowerRow(), poles.LowerCol());
gp_Pnt p2 = poles(poles.UpperRow(), poles.LowerCol());
gp_Pnt p3 = poles(poles.LowerRow(), poles.UpperCol());
gp_Vec vec1(p1, p2);
gp_Vec vec2(p1, p3);
gp_Vec vec3 = vec1.Crossed(vec2);
gp_Pln plane(p1, gp_Dir(vec3));
for (int i=poles.LowerRow(); i<=poles.UpperRow(); i++) {
for (int j=poles.LowerCol(); j<poles.UpperCol(); j++) {
for (int i = poles.LowerRow(); i <= poles.UpperRow(); i++) {
for (int j = poles.LowerCol(); j < poles.UpperCol(); j++) {
// are control points coplanar?
const gp_Pnt& pole = poles(i,j);
const gp_Pnt& pole = poles(i, j);
Standard_Real dist = plane.Distance(pole);
if (dist > Precision::Confusion()) {
return false;
@@ -154,13 +154,13 @@ gp_XYZ Fem::Tools::getDirection(const TopoDS_Face& face)
else if (surface.GetType() == GeomAbs_BSplineSurface) {
Handle(Geom_BSplineSurface) spline = surface.BSpline();
try {
TColgp_Array2OfPnt poles(1,spline->NbUPoles(),1,spline->NbVPoles());
TColgp_Array2OfPnt poles(1, spline->NbUPoles(), 1, spline->NbVPoles());
spline->Poles(poles);
// get the plane from three control points
gp_Pnt p1 = poles(poles.LowerRow(),poles.LowerCol());
gp_Pnt p2 = poles(poles.UpperRow(),poles.LowerCol());
gp_Pnt p3 = poles(poles.LowerRow(),poles.UpperCol());
gp_Pnt p1 = poles(poles.LowerRow(), poles.LowerCol());
gp_Pnt p2 = poles(poles.UpperRow(), poles.LowerCol());
gp_Pnt p3 = poles(poles.LowerRow(), poles.UpperCol());
gp_Vec vec1(p1, p2);
gp_Vec vec2(p1, p3);
gp_Vec vec3 = vec1.Crossed(vec2);
@@ -173,13 +173,13 @@ gp_XYZ Fem::Tools::getDirection(const TopoDS_Face& face)
else if (surface.GetType() == GeomAbs_BezierSurface) {
Handle(Geom_BezierSurface) bezier = surface.Bezier();
try {
TColgp_Array2OfPnt poles(1,bezier->NbUPoles(),1,bezier->NbVPoles());
TColgp_Array2OfPnt poles(1, bezier->NbUPoles(), 1, bezier->NbVPoles());
bezier->Poles(poles);
// get the plane from three control points
gp_Pnt p1 = poles(poles.LowerRow(),poles.LowerCol());
gp_Pnt p2 = poles(poles.UpperRow(),poles.LowerCol());
gp_Pnt p3 = poles(poles.LowerRow(),poles.UpperCol());
gp_Pnt p1 = poles(poles.LowerRow(), poles.LowerCol());
gp_Pnt p2 = poles(poles.UpperRow(), poles.LowerCol());
gp_Pnt p3 = poles(poles.LowerRow(), poles.UpperCol());
gp_Vec vec1(p1, p2);
gp_Vec vec2(p1, p3);
gp_Vec vec3 = vec1.Crossed(vec2);
@@ -207,7 +207,7 @@ bool Fem::Tools::isLinear(const TopoDS_Edge& edge)
gp_Vec vec(s1, sn);
gp_Lin line(s1, gp_Dir(vec));
for (int i=2; i<spline->NbPoles(); i++) {
for (int i = 2; i < spline->NbPoles(); i++) {
// are control points collinear?
Standard_Real dist = line.Distance(spline->Pole(i));
if (dist > Precision::Confusion()) {
@@ -229,7 +229,7 @@ bool Fem::Tools::isLinear(const TopoDS_Edge& edge)
gp_Vec vec(s1, sn);
gp_Lin line(s1, gp_Dir(vec));
for (int i=2; i<bezier->NbPoles(); i++) {
for (int i = 2; i < bezier->NbPoles(); i++) {
// are control points collinear?
Standard_Real dist = line.Distance(bezier->Pole(i));
if (dist > Precision::Confusion()) {
@@ -285,8 +285,8 @@ gp_XYZ Fem::Tools::getDirection(const TopoDS_Edge& edge)
// function to determine 3rd-party binaries used by the FEM WB
std::string Fem::Tools::checkIfBinaryExists(std::string prefSection,
std::string prefBinaryName,
std::string binaryName)
std::string prefBinaryName,
std::string binaryName)
{
// if "Search in known binary directories" is set in the preferences, we ignore custom path
auto paramPath = "User parameter:BaseApp/Preferences/Mod/Fem/" + prefSection;
@@ -305,8 +305,9 @@ std::string Fem::Tools::checkIfBinaryExists(std::string prefSection,
// check the folder of the FreeCAD binary
else {
auto homePathBinary = App::Application::getHomePath() + "bin/" + binaryName;
if (QFileInfo::exists(QString::fromLatin1(homePathBinary.c_str())))
if (QFileInfo::exists(QString::fromLatin1(homePathBinary.c_str()))) {
return binaryName;
}
}
}
else {
@@ -315,8 +316,9 @@ std::string Fem::Tools::checkIfBinaryExists(std::string prefSection,
App::GetApplication().GetParameterGroupByPath(paramPath.c_str());
auto binaryPath = hGrp->GetASCII(binaryPathString.c_str(), "");
QFileInfo::exists(QString::fromLatin1(binaryPath.c_str()));
if (QFileInfo::exists(QString::fromLatin1(binaryPath.c_str())))
if (QFileInfo::exists(QString::fromLatin1(binaryPath.c_str()))) {
return binaryPath;
}
}
return "";
}

View File

@@ -25,8 +25,8 @@
#define FEM_TOOLS_H
#include <Base/Vector3D.h>
#include <gp_XYZ.hxx>
#include <Mod/Fem/FemGlobal.h>
#include <gp_XYZ.hxx>
class TopoDS_Shape;
class TopoDS_Edge;
@@ -72,11 +72,12 @@ public:
The result is either the full path if available or just the binary
name if it was found in a system path
*/
static std::string checkIfBinaryExists(std::string prefSection, std::string prefBinaryPath,
static std::string checkIfBinaryExists(std::string prefSection,
std::string prefBinaryPath,
std::string prefBinaryName);
};
} //namespace Fem
} // namespace Fem
#endif // FEM_TOOLS_H
#endif // FEM_TOOLS_H

View File

@@ -24,38 +24,38 @@
#include "PreCompiled.h"
#ifndef _PreComp_
# include <cmath>
# include <cstdlib>
# include <map>
# include <memory>
# include <Python.h>
#include <Python.h>
#include <cmath>
#include <cstdlib>
#include <map>
#include <memory>
# include <SMESH_Mesh.hxx>
# include <SMESHDS_Mesh.hxx>
#include <SMESHDS_Mesh.hxx>
#include <SMESH_Mesh.hxx>
# include <vtkCellArray.h>
# include <vtkDataArray.h>
# include <vtkDataSetReader.h>
# include <vtkDataSetWriter.h>
# include <vtkDoubleArray.h>
# include <vtkHexahedron.h>
# include <vtkIdList.h>
# include <vtkPointData.h>
# include <vtkPyramid.h>
# include <vtkQuad.h>
# include <vtkQuadraticTriangle.h>
# include <vtkQuadraticQuad.h>
# include <vtkQuadraticTetra.h>
# include <vtkQuadraticPyramid.h>
# include <vtkQuadraticWedge.h>
# include <vtkQuadraticHexahedron.h>
# include <vtkTetra.h>
# include <vtkTriangle.h>
# include <vtkUnstructuredGrid.h>
# include <vtkWedge.h>
# include <vtkXMLPUnstructuredGridReader.h>
# include <vtkXMLUnstructuredGridReader.h>
# include <vtkXMLUnstructuredGridWriter.h>
#include <vtkCellArray.h>
#include <vtkDataArray.h>
#include <vtkDataSetReader.h>
#include <vtkDataSetWriter.h>
#include <vtkDoubleArray.h>
#include <vtkHexahedron.h>
#include <vtkIdList.h>
#include <vtkPointData.h>
#include <vtkPyramid.h>
#include <vtkQuad.h>
#include <vtkQuadraticHexahedron.h>
#include <vtkQuadraticPyramid.h>
#include <vtkQuadraticQuad.h>
#include <vtkQuadraticTetra.h>
#include <vtkQuadraticTriangle.h>
#include <vtkQuadraticWedge.h>
#include <vtkTetra.h>
#include <vtkTriangle.h>
#include <vtkUnstructuredGrid.h>
#include <vtkWedge.h>
#include <vtkXMLPUnstructuredGridReader.h>
#include <vtkXMLUnstructuredGridReader.h>
#include <vtkXMLUnstructuredGridWriter.h>
#endif
#include <App/Application.h>
@@ -66,31 +66,31 @@
#include <Base/TimeInfo.h>
#include <Base/Type.h>
#include "FemVTKTools.h"
#include "FemAnalysis.h"
#include "FemResultObject.h"
#include "FemVTKTools.h"
namespace Fem
{
template<class TReader> vtkDataSet* readVTKFile(const char*fileName)
template<class TReader>
vtkDataSet* readVTKFile(const char* fileName)
{
vtkSmartPointer<TReader> reader =
vtkSmartPointer<TReader>::New();
vtkSmartPointer<TReader> reader = vtkSmartPointer<TReader>::New();
reader->SetFileName(fileName);
reader->Update();
auto output = reader->GetOutput();
if (output)
if (output) {
output->Register(reader);
}
return vtkDataSet::SafeDownCast(output);
}
template<class TWriter>
void writeVTKFile(const char* filename, vtkSmartPointer<vtkUnstructuredGrid> dataset)
{
vtkSmartPointer<TWriter> writer =
vtkSmartPointer<TWriter>::New();
vtkSmartPointer<TWriter> writer = vtkSmartPointer<TWriter>::New();
writer->SetFileName(filename);
writer->SetInputData(dataset);
writer->Write();
@@ -104,11 +104,11 @@ void FemVTKTools::importVTKMesh(vtkSmartPointer<vtkDataSet> dataset, FemMesh* me
Base::Console().Log("%d nodes/points and %d cells/elements found!\n", nPoints, nCells);
Base::Console().Log("Build SMESH mesh out of the vtk mesh data.\n", nPoints, nCells);
//vtkSmartPointer<vtkCellArray> cells = dataset->GetCells();
// works only for vtkUnstructuredGrid
vtkSmartPointer<vtkIdList> idlist= vtkSmartPointer<vtkIdList>::New();
// vtkSmartPointer<vtkCellArray> cells = dataset->GetCells();
// works only for vtkUnstructuredGrid
vtkSmartPointer<vtkIdList> idlist = vtkSmartPointer<vtkIdList>::New();
//Now fill the SMESH datastructure
// Now fill the SMESH datastructure
SMESH_Mesh* smesh = mesh->getSMesh();
SMESHDS_Mesh* meshds = smesh->GetMeshDS();
meshds->ClearMesh();
@@ -124,10 +124,10 @@ void FemVTKTools::importVTKMesh(vtkSmartPointer<vtkDataSet> dataset, FemMesh* me
vtkIdType* ids = idlist->GetPointer(0);
switch (dataset->GetCellType(iCell)) {
// 2D faces
case VTK_TRIANGLE:// tria3
case VTK_TRIANGLE: // tria3
meshds->AddFaceWithID(ids[0] + 1, ids[1] + 1, ids[2] + 1, iCell + 1);
break;
case VTK_QUADRATIC_TRIANGLE:// tria6
case VTK_QUADRATIC_TRIANGLE: // tria6
meshds->AddFaceWithID(ids[0] + 1,
ids[1] + 1,
ids[2] + 1,
@@ -136,10 +136,10 @@ void FemVTKTools::importVTKMesh(vtkSmartPointer<vtkDataSet> dataset, FemMesh* me
ids[5] + 1,
iCell + 1);
break;
case VTK_QUAD:// quad4
case VTK_QUAD: // quad4
meshds->AddFaceWithID(ids[0] + 1, ids[1] + 1, ids[2] + 1, ids[3] + 1, iCell + 1);
break;
case VTK_QUADRATIC_QUAD:// quad8
case VTK_QUADRATIC_QUAD: // quad8
meshds->AddFaceWithID(ids[0] + 1,
ids[1] + 1,
ids[2] + 1,
@@ -152,10 +152,10 @@ void FemVTKTools::importVTKMesh(vtkSmartPointer<vtkDataSet> dataset, FemMesh* me
break;
// 3D volumes
case VTK_TETRA:// tetra4
case VTK_TETRA: // tetra4
meshds->AddVolumeWithID(ids[0] + 1, ids[1] + 1, ids[2] + 1, ids[3] + 1, iCell + 1);
break;
case VTK_QUADRATIC_TETRA:// tetra10
case VTK_QUADRATIC_TETRA: // tetra10
meshds->AddVolumeWithID(ids[0] + 1,
ids[1] + 1,
ids[2] + 1,
@@ -168,7 +168,7 @@ void FemVTKTools::importVTKMesh(vtkSmartPointer<vtkDataSet> dataset, FemMesh* me
ids[9] + 1,
iCell + 1);
break;
case VTK_HEXAHEDRON:// hexa8
case VTK_HEXAHEDRON: // hexa8
meshds->AddVolumeWithID(ids[0] + 1,
ids[1] + 1,
ids[2] + 1,
@@ -179,7 +179,7 @@ void FemVTKTools::importVTKMesh(vtkSmartPointer<vtkDataSet> dataset, FemMesh* me
ids[7] + 1,
iCell + 1);
break;
case VTK_QUADRATIC_HEXAHEDRON:// hexa20
case VTK_QUADRATIC_HEXAHEDRON: // hexa20
meshds->AddVolumeWithID(ids[0] + 1,
ids[1] + 1,
ids[2] + 1,
@@ -202,7 +202,7 @@ void FemVTKTools::importVTKMesh(vtkSmartPointer<vtkDataSet> dataset, FemMesh* me
ids[19] + 1,
iCell + 1);
break;
case VTK_WEDGE:// penta6
case VTK_WEDGE: // penta6
meshds->AddVolumeWithID(ids[0] + 1,
ids[1] + 1,
ids[2] + 1,
@@ -211,7 +211,7 @@ void FemVTKTools::importVTKMesh(vtkSmartPointer<vtkDataSet> dataset, FemMesh* me
ids[5] + 1,
iCell + 1);
break;
case VTK_QUADRATIC_WEDGE:// penta15
case VTK_QUADRATIC_WEDGE: // penta15
meshds->AddVolumeWithID(ids[0] + 1,
ids[1] + 1,
ids[2] + 1,
@@ -229,11 +229,15 @@ void FemVTKTools::importVTKMesh(vtkSmartPointer<vtkDataSet> dataset, FemMesh* me
ids[14] + 1,
iCell + 1);
break;
case VTK_PYRAMID:// pyra5
meshds->AddVolumeWithID(
ids[0] + 1, ids[1] + 1, ids[2] + 1, ids[3] + 1, ids[4] + 1, iCell + 1);
case VTK_PYRAMID: // pyra5
meshds->AddVolumeWithID(ids[0] + 1,
ids[1] + 1,
ids[2] + 1,
ids[3] + 1,
ids[4] + 1,
iCell + 1);
break;
case VTK_QUADRATIC_PYRAMID:// pyra13
case VTK_QUADRATIC_PYRAMID: // pyra13
meshds->AddVolumeWithID(ids[0] + 1,
ids[1] + 1,
ids[2] + 1,
@@ -294,7 +298,7 @@ FemMesh* FemVTKTools::readVTKMesh(const char* filename, FemMesh* mesh)
Base::Console().Error("file name extension is not supported\n");
return nullptr;
}
//Mesh should link to the part feature, in order to set up FemConstraint
// Mesh should link to the part feature, in order to set up FemConstraint
Base::Console().Log(" %f: Done \n", Base::TimeInfo::diffTimeF(Start, Base::TimeInfo()));
return mesh;
@@ -310,11 +314,10 @@ void exportFemMeshFaces(vtkSmartPointer<vtkUnstructuredGrid> grid,
vtkSmartPointer<vtkCellArray> quadArray = vtkSmartPointer<vtkCellArray>::New();
vtkSmartPointer<vtkCellArray> quadQuadArray = vtkSmartPointer<vtkCellArray>::New();
for (;aFaceIter->more();)
{
for (; aFaceIter->more();) {
const SMDS_MeshFace* aFace = aFaceIter->next();
//triangle
// triangle
if (aFace->NbNodes() == 3) {
vtkSmartPointer<vtkTriangle> tria = vtkSmartPointer<vtkTriangle>::New();
tria->GetPointIds()->SetId(0, aFace->GetNode(0)->GetID() - 1);
@@ -323,7 +326,7 @@ void exportFemMeshFaces(vtkSmartPointer<vtkUnstructuredGrid> grid,
triangleArray->InsertNextCell(tria);
}
//quad
// quad
else if (aFace->NbNodes() == 4) {
vtkSmartPointer<vtkQuad> quad = vtkSmartPointer<vtkQuad>::New();
quad->GetPointIds()->SetId(0, aFace->GetNode(0)->GetID() - 1);
@@ -333,7 +336,7 @@ void exportFemMeshFaces(vtkSmartPointer<vtkUnstructuredGrid> grid,
quadArray->InsertNextCell(quad);
}
//quadratic triangle
// quadratic triangle
else if (aFace->NbNodes() == 6) {
vtkSmartPointer<vtkQuadraticTriangle> tria =
vtkSmartPointer<vtkQuadraticTriangle>::New();
@@ -345,7 +348,7 @@ void exportFemMeshFaces(vtkSmartPointer<vtkUnstructuredGrid> grid,
tria->GetPointIds()->SetId(5, aFace->GetNode(5)->GetID() - 1);
quadTriangleArray->InsertNextCell(tria);
}
//quadratic quad
// quadratic quad
else if (aFace->NbNodes() == 8) {
vtkSmartPointer<vtkQuadraticQuad> quad = vtkSmartPointer<vtkQuadraticQuad>::New();
quad->GetPointIds()->SetId(0, aFace->GetNode(0)->GetID() - 1);
@@ -363,17 +366,21 @@ void exportFemMeshFaces(vtkSmartPointer<vtkUnstructuredGrid> grid,
throw std::runtime_error("Face not yet supported by FreeCAD's VTK mesh builder\n");
}
}
if (triangleArray->GetNumberOfCells() > 0)
if (triangleArray->GetNumberOfCells() > 0) {
grid->SetCells(VTK_TRIANGLE, triangleArray);
}
if (quadArray->GetNumberOfCells() > 0)
if (quadArray->GetNumberOfCells() > 0) {
grid->SetCells(VTK_QUAD, quadArray);
}
if (quadTriangleArray->GetNumberOfCells() > 0)
if (quadTriangleArray->GetNumberOfCells() > 0) {
grid->SetCells(VTK_QUADRATIC_TRIANGLE, quadTriangleArray);
}
if (quadQuadArray->GetNumberOfCells() > 0)
if (quadQuadArray->GetNumberOfCells() > 0) {
grid->SetCells(VTK_QUADRATIC_QUAD, quadQuadArray);
}
Base::Console().Log(" End: VTK mesh builder faces.\n");
}
@@ -392,11 +399,10 @@ void exportFemMeshCells(vtkSmartPointer<vtkUnstructuredGrid> grid,
vtkSmartPointer<vtkCellArray> quadWedgeArray = vtkSmartPointer<vtkCellArray>::New();
vtkSmartPointer<vtkCellArray> quadHexaArray = vtkSmartPointer<vtkCellArray>::New();
for (;aVolIter->more();)
{
for (; aVolIter->more();) {
const SMDS_MeshVolume* aVol = aVolIter->next();
if (aVol->NbNodes() == 4) {// tetra4
if (aVol->NbNodes() == 4) { // tetra4
Base::Console().Log(" Volume tetra4\n");
vtkSmartPointer<vtkTetra> cell = vtkSmartPointer<vtkTetra>::New();
cell->GetPointIds()->SetId(0, aVol->GetNode(0)->GetID() - 1);
@@ -405,7 +411,7 @@ void exportFemMeshCells(vtkSmartPointer<vtkUnstructuredGrid> grid,
cell->GetPointIds()->SetId(3, aVol->GetNode(3)->GetID() - 1);
tetraArray->InsertNextCell(cell);
}
else if (aVol->NbNodes() == 5) {// pyra5
else if (aVol->NbNodes() == 5) { // pyra5
Base::Console().Log(" Volume pyra5\n");
vtkSmartPointer<vtkPyramid> cell = vtkSmartPointer<vtkPyramid>::New();
cell->GetPointIds()->SetId(0, aVol->GetNode(0)->GetID() - 1);
@@ -415,7 +421,7 @@ void exportFemMeshCells(vtkSmartPointer<vtkUnstructuredGrid> grid,
cell->GetPointIds()->SetId(4, aVol->GetNode(4)->GetID() - 1);
pyramidArray->InsertNextCell(cell);
}
else if (aVol->NbNodes() == 6) {// penta6
else if (aVol->NbNodes() == 6) { // penta6
Base::Console().Log(" Volume penta6\n");
vtkSmartPointer<vtkWedge> cell = vtkSmartPointer<vtkWedge>::New();
cell->GetPointIds()->SetId(0, aVol->GetNode(0)->GetID() - 1);
@@ -426,7 +432,7 @@ void exportFemMeshCells(vtkSmartPointer<vtkUnstructuredGrid> grid,
cell->GetPointIds()->SetId(5, aVol->GetNode(5)->GetID() - 1);
wedgeArray->InsertNextCell(cell);
}
else if (aVol->NbNodes() == 8) {// hexa8
else if (aVol->NbNodes() == 8) { // hexa8
Base::Console().Log(" Volume hexa8\n");
vtkSmartPointer<vtkHexahedron> cell = vtkSmartPointer<vtkHexahedron>::New();
cell->GetPointIds()->SetId(0, aVol->GetNode(0)->GetID() - 1);
@@ -439,7 +445,7 @@ void exportFemMeshCells(vtkSmartPointer<vtkUnstructuredGrid> grid,
cell->GetPointIds()->SetId(7, aVol->GetNode(7)->GetID() - 1);
hexaArray->InsertNextCell(cell);
}
else if (aVol->NbNodes() == 10) {// tetra10
else if (aVol->NbNodes() == 10) { // tetra10
Base::Console().Log(" Volume tetra10\n");
vtkSmartPointer<vtkQuadraticTetra> tetra = vtkSmartPointer<vtkQuadraticTetra>::New();
for (int i = 0; i < 10; i++) {
@@ -448,7 +454,7 @@ void exportFemMeshCells(vtkSmartPointer<vtkUnstructuredGrid> grid,
quadTetraArray->InsertNextCell(tetra);
}
else if (aVol->NbNodes() == 13) {// pyra13
else if (aVol->NbNodes() == 13) { // pyra13
Base::Console().Log(" Volume pyra13\n");
vtkSmartPointer<vtkQuadraticPyramid> cell = vtkSmartPointer<vtkQuadraticPyramid>::New();
for (int i = 0; i < 13; i++) {
@@ -457,7 +463,7 @@ void exportFemMeshCells(vtkSmartPointer<vtkUnstructuredGrid> grid,
}
quadPyramidArray->InsertNextCell(cell);
}
else if (aVol->NbNodes() == 15) {// penta15
else if (aVol->NbNodes() == 15) { // penta15
Base::Console().Log(" Volume penta15\n");
vtkSmartPointer<vtkQuadraticWedge> cell = vtkSmartPointer<vtkQuadraticWedge>::New();
for (int i = 0; i < 15; i++) {
@@ -465,7 +471,7 @@ void exportFemMeshCells(vtkSmartPointer<vtkUnstructuredGrid> grid,
}
quadWedgeArray->InsertNextCell(cell);
}
else if (aVol->NbNodes() == 20) {// hexa20
else if (aVol->NbNodes() == 20) { // hexa20
Base::Console().Log(" Volume hexa20\n");
vtkSmartPointer<vtkQuadraticHexahedron> cell =
vtkSmartPointer<vtkQuadraticHexahedron>::New();
@@ -479,34 +485,43 @@ void exportFemMeshCells(vtkSmartPointer<vtkUnstructuredGrid> grid,
}
}
if (tetraArray->GetNumberOfCells() > 0)
if (tetraArray->GetNumberOfCells() > 0) {
grid->SetCells(VTK_TETRA, tetraArray);
}
if (pyramidArray->GetNumberOfCells() > 0)
if (pyramidArray->GetNumberOfCells() > 0) {
grid->SetCells(VTK_PYRAMID, pyramidArray);
}
if (wedgeArray->GetNumberOfCells() > 0)
if (wedgeArray->GetNumberOfCells() > 0) {
grid->SetCells(VTK_WEDGE, wedgeArray);
}
if (hexaArray->GetNumberOfCells() > 0)
if (hexaArray->GetNumberOfCells() > 0) {
grid->SetCells(VTK_HEXAHEDRON, hexaArray);
}
if (quadTetraArray->GetNumberOfCells() > 0)
if (quadTetraArray->GetNumberOfCells() > 0) {
grid->SetCells(VTK_QUADRATIC_TETRA, quadTetraArray);
}
if (quadPyramidArray->GetNumberOfCells() > 0)
if (quadPyramidArray->GetNumberOfCells() > 0) {
grid->SetCells(VTK_QUADRATIC_PYRAMID, quadPyramidArray);
}
if (quadWedgeArray->GetNumberOfCells() > 0)
if (quadWedgeArray->GetNumberOfCells() > 0) {
grid->SetCells(VTK_QUADRATIC_WEDGE, quadWedgeArray);
}
if (quadHexaArray->GetNumberOfCells() > 0)
if (quadHexaArray->GetNumberOfCells() > 0) {
grid->SetCells(VTK_QUADRATIC_HEXAHEDRON, quadHexaArray);
}
Base::Console().Log(" End: VTK mesh builder volumes.\n");
}
void FemVTKTools::exportVTKMesh(const FemMesh* mesh, vtkSmartPointer<vtkUnstructuredGrid> grid,
void FemVTKTools::exportVTKMesh(const FemMesh* mesh,
vtkSmartPointer<vtkUnstructuredGrid> grid,
float scale)
{
@@ -521,9 +536,10 @@ void FemVTKTools::exportVTKMesh(const FemMesh* mesh, vtkSmartPointer<vtkUnstruct
SMDS_NodeIteratorPtr aNodeIter = meshDS->nodesIterator();
while (aNodeIter->more()) {
const SMDS_MeshNode* node = aNodeIter->next();// why float, not double?
double coords[3] = {
double(node->X() * scale), double(node->Y() * scale), double(node->Z() * scale)};
const SMDS_MeshNode* node = aNodeIter->next(); // why float, not double?
double coords[3] = {double(node->X() * scale),
double(node->Y() * scale),
double(node->Z() * scale)};
points->InsertPoint(node->GetID() - 1, coords);
// memory is allocated by VTK points size for max node id, not for point count
// if the SMESH mesh has gaps in node numbering, points without any element
@@ -559,7 +575,7 @@ void FemVTKTools::writeVTKMesh(const char* filename, const FemMesh* mesh)
vtkSmartPointer<vtkUnstructuredGrid> grid = vtkSmartPointer<vtkUnstructuredGrid>::New();
exportVTKMesh(mesh, grid);
//vtkSmartPointer<vtkDataSet> dataset = vtkDataSet::SafeDownCast(grid);
// vtkSmartPointer<vtkDataSet> dataset = vtkDataSet::SafeDownCast(grid);
Base::Console().Log("Start: writing mesh data ======================\n");
if (f.hasExtension("vtu")) {
writeVTKFile<vtkXMLUnstructuredGridWriter>(filename, grid);
@@ -571,7 +587,7 @@ void FemVTKTools::writeVTKMesh(const char* filename, const FemMesh* mesh)
Base::Console().Error("file name extension is not supported to write VTK\n");
}
Base::Console().Log(" %f: Done \n",Base::TimeInfo::diffTimeF(Start, Base::TimeInfo()));
Base::Console().Log(" %f: Done \n", Base::TimeInfo::diffTimeF(Start, Base::TimeInfo()));
}
@@ -589,9 +605,10 @@ App::DocumentObject* getObjectByType(const Base::Type type)
}
if (obj->getTypeId() == FemAnalysis::getClassTypeId()) {
std::vector<App::DocumentObject*> fem = (static_cast<FemAnalysis*>(obj))->Group.getValues();
for (const auto & it : fem) {
if (it->getTypeId().isDerivedFrom(type))
return static_cast<App::DocumentObject*>(it);// return the first of that type
for (const auto& it : fem) {
if (it->getTypeId().isDerivedFrom(type)) {
return static_cast<App::DocumentObject*>(it); // return the first of that type
}
}
}
return nullptr;
@@ -613,7 +630,7 @@ App::DocumentObject* createObjectByType(const Base::Type type)
return newobj;
}
else {
return pcDoc->addObject(type.getName());// create in the active document
return pcDoc->addObject(type.getName()); // create in the active document
}
}
@@ -621,7 +638,8 @@ App::DocumentObject* createObjectByType(const Base::Type type)
App::DocumentObject* FemVTKTools::readResult(const char* filename, App::DocumentObject* res)
{
Base::TimeInfo Start;
Base::Console().Log("Start: read FemResult with FemMesh from VTK file ======================\n");
Base::Console().Log(
"Start: read FemResult with FemMesh from VTK file ======================\n");
Base::FileInfo f(filename);
vtkSmartPointer<vtkDataSet> ds;
@@ -666,10 +684,11 @@ App::DocumentObject* FemVTKTools::readResult(const char* filename, App::Document
// PropertyLink is the property type to store DocumentObject pointer
App::PropertyLink* link =
dynamic_cast<App::PropertyLink*>(result->getPropertyByName("Mesh"));
if (link)
if (link) {
link->setValue(mesh);
}
//vtkSmartPointer<vtkPointData> pd = dataset->GetPointData();
// vtkSmartPointer<vtkPointData> pd = dataset->GetPointData();
importFreeCADResult(dataset, result);
}
@@ -681,14 +700,15 @@ App::DocumentObject* FemVTKTools::readResult(const char* filename, App::Document
}
void FemVTKTools::writeResult(const char* filename, const App::DocumentObject* res) {
void FemVTKTools::writeResult(const char* filename, const App::DocumentObject* res)
{
if (!res) {
App::Document* pcDoc = App::GetApplication().getActiveDocument();
if (!pcDoc) {
Base::Console().Message("No active document is found thus do nothing and return\n");
return;
}
res = pcDoc->getActiveObject();//type checking is done by caller
res = pcDoc->getActiveObject(); // type checking is done by caller
}
if (!res) {
Base::Console().Error("Result object pointer is invalid and it is not active object");
@@ -713,7 +733,7 @@ void FemVTKTools::writeResult(const char* filename, const App::DocumentObject* r
// result
FemVTKTools::exportFreeCADResult(res, grid);
//vtkSmartPointer<vtkDataSet> dataset = vtkDataSet::SafeDownCast(grid);
// vtkSmartPointer<vtkDataSet> dataset = vtkDataSet::SafeDownCast(grid);
if (f.hasExtension("vtu")) {
writeVTKFile<vtkXMLUnstructuredGridWriter>(filename, grid);
}
@@ -730,7 +750,8 @@ void FemVTKTools::writeResult(const char* filename, const App::DocumentObject* r
}
std::map<std::string, std::string> _getFreeCADMechResultVectorProperties() {
std::map<std::string, std::string> _getFreeCADMechResultVectorProperties()
{
// see src/Mod/Fem/femobjects/_FemResultMechanical
// App::PropertyVectorList will be a list of vectors in vtk
std::map<std::string, std::string> resFCVecProp;
@@ -750,12 +771,13 @@ std::map<std::string, std::string> _getFreeCADMechResultVectorProperties() {
// some scalar list are not needed on VTK file export but they are needed for internal VTK pipeline
// TODO some filter to only export the needed values to VTK file but have all
// in FreeCAD VTK pipeline
std::map<std::string, std::string> _getFreeCADMechResultScalarProperties() {
std::map<std::string, std::string> _getFreeCADMechResultScalarProperties()
{
// see src/Mod/Fem/femobjects/result_mechanical.py
// App::PropertyFloatList will be a list of scalars in vtk
std::map<std::string, std::string> resFCScalProp;
resFCScalProp["DisplacementLengths"] =
"Displacement Magnitude";// can be plotted in Paraview as THE DISPLACEMENT MAGNITUDE
"Displacement Magnitude"; // can be plotted in Paraview as THE DISPLACEMENT MAGNITUDE
resFCScalProp["MaxShear"] = "Tresca Stress";
resFCScalProp["NodeStressXX"] = "Stress xx component";
resFCScalProp["NodeStressYY"] = "Stress yy component";
@@ -782,12 +804,13 @@ std::map<std::string, std::string> _getFreeCADMechResultScalarProperties() {
// how to generate them in paraview)
// but there are needed anyway because the pipeline in FreeCAD needs the principal stress values
// https://forum.freecad.org/viewtopic.php?f=18&t=33106&p=416006#p412800
resFCScalProp["PrincipalMax"] =
"Major Principal Stress";// can be plotted in Paraview as THE MAJOR PRINCIPAL STRESS MAGNITUDE
resFCScalProp["PrincipalMax"] = "Major Principal Stress"; // can be plotted in Paraview as THE
// MAJOR PRINCIPAL STRESS MAGNITUDE
resFCScalProp["PrincipalMed"] =
"Intermediate Principal Stress";// can be plotted in Paraview as THE INTERMEDIATE PRINCIPAL STRESS MAGNITUDE
resFCScalProp["PrincipalMin"] =
"Minor Principal Stress";// can be plotted in Paraview as THE MINOR PRINCIPAL STRESS MAGNITUDE
"Intermediate Principal Stress"; // can be plotted in Paraview as THE INTERMEDIATE
// PRINCIPAL STRESS MAGNITUDE
resFCScalProp["PrincipalMin"] = "Minor Principal Stress"; // can be plotted in Paraview as THE
// MINOR PRINCIPAL STRESS MAGNITUDE
resFCScalProp["vonMises"] = "von Mises Stress";
resFCScalProp["Temperature"] = "Temperature";
resFCScalProp["MohrCoulomb"] = "MohrCoulomb";
@@ -811,7 +834,7 @@ void FemVTKTools::importFreeCADResult(vtkSmartPointer<vtkDataSet> dataset,
std::map<std::string, std::string> vectors = _getFreeCADMechResultVectorProperties();
std::map<std::string, std::string> scalars = _getFreeCADMechResultScalarProperties();
double ts = 0.0;// t=0.0 for static simulation
double ts = 0.0; // t=0.0 for static simulation
static_cast<App::PropertyFloat*>(result->getPropertyByName("Time"))->setValue(ts);
vtkSmartPointer<vtkPointData> pd = dataset->GetPointData();
@@ -833,9 +856,9 @@ void FemVTKTools::importFreeCADResult(vtkSmartPointer<vtkDataSet> dataset,
Base::Console().Log(" NodeNumbers have been filled with values.\n");
// vectors
for (const auto & it : vectors) {
int dim = 3;// Fixme: currently 3D only, here we could run into trouble,
// FreeCAD only supports dim 3D, I do not know about VTK
for (const auto& it : vectors) {
int dim = 3; // Fixme: currently 3D only, here we could run into trouble,
// FreeCAD only supports dim 3D, I do not know about VTK
vtkDataArray* vector_field = vtkDataArray::SafeDownCast(pd->GetArray(it.second.c_str()));
if (vector_field && vector_field->GetNumberOfComponents() == dim) {
App::PropertyVectorList* vector_list =
@@ -844,7 +867,7 @@ void FemVTKTools::importFreeCADResult(vtkSmartPointer<vtkDataSet> dataset,
std::vector<Base::Vector3d> vec(nPoints);
for (vtkIdType i = 0; i < nPoints; ++i) {
double* p = vector_field->GetTuple(
i);// both vtkFloatArray and vtkDoubleArray return double* for GetTuple(i)
i); // both vtkFloatArray and vtkDoubleArray return double* for GetTuple(i)
vec[i] = (Base::Vector3d(p[0], p[1], p[2]));
}
// PropertyVectorList will not show up in PropertyEditor
@@ -859,17 +882,18 @@ void FemVTKTools::importFreeCADResult(vtkSmartPointer<vtkDataSet> dataset,
continue;
}
}
else
else {
Base::Console().Message(" PropertyVectorList NOT found in vkt file data: %s\n",
it.first.c_str());
}
}
// scalars
for (const auto & scalar : scalars) {
for (const auto& scalar : scalars) {
vtkDataArray* vec = vtkDataArray::SafeDownCast(pd->GetArray(scalar.second.c_str()));
if (nPoints && vec && vec->GetNumberOfComponents() == 1) {
App::PropertyFloatList* field =
static_cast<App::PropertyFloatList*>(result->getPropertyByName(scalar.first.c_str()));
App::PropertyFloatList* field = static_cast<App::PropertyFloatList*>(
result->getPropertyByName(scalar.first.c_str()));
if (!field) {
Base::Console().Error("static_cast<App::PropertyFloatList*>((result->"
"getPropertyByName(\"%s\")) failed.\n",
@@ -882,18 +906,21 @@ void FemVTKTools::importFreeCADResult(vtkSmartPointer<vtkDataSet> dataset,
for (vtkIdType i = 0; i < vec->GetNumberOfTuples(); i++) {
double v = *(vec->GetTuple(i));
values[i] = v;
if (v > vmax)
if (v > vmax) {
vmax = v;
if (v < vmin)
}
if (v < vmin) {
vmin = v;
}
}
field->setValues(values);
Base::Console().Log(" A PropertyFloatList has been filled with vales: %s\n",
scalar.first.c_str());
}
else
else {
Base::Console().Message(" PropertyFloatList NOT found in vkt file data %s\n",
scalar.first.c_str());
}
}
// stats
@@ -931,19 +958,21 @@ void FemVTKTools::exportFreeCADResult(const App::DocumentObject* result,
double factor = 1.0;
// vectors
for (const auto & it : vectors) {
const int dim = 3;//Fixme, detect dim, but FreeCAD PropertyVectorList ATM only has DIM of 3
for (const auto& it : vectors) {
const int dim =
3; // Fixme, detect dim, but FreeCAD PropertyVectorList ATM only has DIM of 3
App::PropertyVectorList* field = nullptr;
if (res->getPropertyByName(it.first.c_str()))
field =
static_cast<App::PropertyVectorList*>(res->getPropertyByName(it.first.c_str()));
else
if (res->getPropertyByName(it.first.c_str())) {
field = static_cast<App::PropertyVectorList*>(res->getPropertyByName(it.first.c_str()));
}
else {
Base::Console().Error(" PropertyVectorList not found: %s\n", it.first.c_str());
}
if (field && field->getSize() > 0) {
//if (nPoints != field->getSize())
// Base::Console().Error("Size of PropertyVectorList = %d, not equal
// to vtk mesh node count %d \n", field->getSize(), nPoints);
// if (nPoints != field->getSize())
// Base::Console().Error("Size of PropertyVectorList = %d, not equal
// to vtk mesh node count %d \n", field->getSize(), nPoints);
const std::vector<Base::Vector3d>& vel = field->getValues();
vtkSmartPointer<vtkDoubleArray> data = vtkSmartPointer<vtkDoubleArray>::New();
data->SetNumberOfComponents(dim);
@@ -960,13 +989,15 @@ void FemVTKTools::exportFreeCADResult(const App::DocumentObject* result,
}
}
if (it.first.compare("DisplacementVectors") == 0)
factor = 0.001;// to get meter
else
if (it.first.compare("DisplacementVectors") == 0) {
factor = 0.001; // to get meter
}
else {
factor = 1.0;
}
SMDS_NodeIteratorPtr aNodeIter = meshDS->nodesIterator();
for (const auto & jt : vel) {
for (const auto& jt : vel) {
const SMDS_MeshNode* node = aNodeIter->next();
double tuple[] = {jt.x * factor, jt.y * factor, jt.z * factor};
data->SetTuple(node->GetID() - 1, tuple);
@@ -985,17 +1016,20 @@ void FemVTKTools::exportFreeCADResult(const App::DocumentObject* result,
}
// scalars
for (const auto & scalar : scalars) {
for (const auto& scalar : scalars) {
App::PropertyFloatList* field = nullptr;
if (res->getPropertyByName(scalar.first.c_str()))
field = static_cast<App::PropertyFloatList*>(res->getPropertyByName(scalar.first.c_str()));
else
if (res->getPropertyByName(scalar.first.c_str())) {
field =
static_cast<App::PropertyFloatList*>(res->getPropertyByName(scalar.first.c_str()));
}
else {
Base::Console().Error("PropertyFloatList %s not found \n", scalar.first.c_str());
}
if (field && field->getSize() > 0) {
//if (nPoints != field->getSize())
// Base::Console().Error("Size of PropertyFloatList = %d, not equal to vtk mesh
// node count %d \n", field->getSize(), nPoints);
// if (nPoints != field->getSize())
// Base::Console().Error("Size of PropertyFloatList = %d, not equal to vtk mesh
// node count %d \n", field->getSize(), nPoints);
const std::vector<double>& vec = field->getValues();
vtkSmartPointer<vtkDoubleArray> data = vtkSmartPointer<vtkDoubleArray>::New();
data->SetNumberOfValues(nPoints);
@@ -1021,19 +1055,23 @@ void FemVTKTools::exportFreeCADResult(const App::DocumentObject* result,
|| (scalar.first.compare("PrincipalMed") == 0)
|| (scalar.first.compare("PrincipalMin") == 0)
|| (scalar.first.compare("vonMises") == 0)
|| (scalar.first.compare("NetworkPressure") == 0) )
factor = 1e6; // to get Pascal
else if (scalar.first.compare("DisplacementLengths") == 0)
factor = 0.001; // to get meter
else
|| (scalar.first.compare("NetworkPressure") == 0)) {
factor = 1e6; // to get Pascal
}
else if (scalar.first.compare("DisplacementLengths") == 0) {
factor = 0.001; // to get meter
}
else {
factor = 1.0;
}
SMDS_NodeIteratorPtr aNodeIter = meshDS->nodesIterator();
for (double i : vec) {
const SMDS_MeshNode* node = aNodeIter->next();
// for the MassFlowRate the last vec entries can be a nullptr, thus check this
if (node)
if (node) {
data->SetValue(node->GetID() - 1, i * factor);
}
}
grid->GetPointData()->AddArray(data);
@@ -1052,4 +1090,4 @@ void FemVTKTools::exportFreeCADResult(const App::DocumentObject* result,
Base::Console().Log("End: Create VTK result data from FreeCAD result data.\n");
}
} // namespace
} // namespace Fem

View File

@@ -34,34 +34,42 @@
namespace Fem
{
// utility class to import/export read/write vtk mesh and result
class FemExport FemVTKTools
{
public:
// extract data from vtkUnstructuredGrid instance and fill a FreeCAD FEM mesh object with that data
static void importVTKMesh(vtkSmartPointer<vtkDataSet> grid, FemMesh* mesh, float scale = 1.0);
// utility class to import/export read/write vtk mesh and result
class FemExport FemVTKTools
{
public:
// extract data from vtkUnstructuredGrid instance and fill a FreeCAD FEM mesh object with that
// data
static void importVTKMesh(vtkSmartPointer<vtkDataSet> grid, FemMesh* mesh, float scale = 1.0);
// extract data from FreCAD FEM mesh and fill a vtkUnstructuredGrid instance with that data
static void exportVTKMesh(const FemMesh* mesh, vtkSmartPointer<vtkUnstructuredGrid> grid, float scale = 1.0);
// extract data from FreCAD FEM mesh and fill a vtkUnstructuredGrid instance with that data
static void exportVTKMesh(const FemMesh* mesh,
vtkSmartPointer<vtkUnstructuredGrid> grid,
float scale = 1.0);
// extract data from vtkUnstructuredGrid object and fill a FreeCAD FEM result object with that data (needed by readResult)
static void importFreeCADResult(vtkSmartPointer<vtkDataSet> dataset, App::DocumentObject* result);
// extract data from vtkUnstructuredGrid object and fill a FreeCAD FEM result object with that
// data (needed by readResult)
static void importFreeCADResult(vtkSmartPointer<vtkDataSet> dataset,
App::DocumentObject* result);
// extract data from a FreeCAD FEM result object and fill a vtkUnstructuredGrid object with that data (needed by writeResult)
static void exportFreeCADResult(const App::DocumentObject* result, vtkSmartPointer<vtkDataSet> grid);
// extract data from a FreeCAD FEM result object and fill a vtkUnstructuredGrid object with that
// data (needed by writeResult)
static void exportFreeCADResult(const App::DocumentObject* result,
vtkSmartPointer<vtkDataSet> grid);
// FemMesh read from vtkUnstructuredGrid data file
static FemMesh* readVTKMesh(const char* filename, FemMesh* mesh);
// FemMesh read from vtkUnstructuredGrid data file
static FemMesh* readVTKMesh(const char* filename, FemMesh* mesh);
// FemMesh write to vtkUnstructuredGrid data file
static void writeVTKMesh(const char* Filename, const FemMesh* mesh);
// FemMesh write to vtkUnstructuredGrid data file
static void writeVTKMesh(const char* Filename, const FemMesh* mesh);
// FemResult (activeObject or created if res= NULL) read from vtkUnstructuredGrid dataset file
static App::DocumentObject* readResult(const char* Filename, App::DocumentObject* res = nullptr);
// FemResult (activeObject or created if res= NULL) read from vtkUnstructuredGrid dataset file
static App::DocumentObject* readResult(const char* Filename,
App::DocumentObject* res = nullptr);
// write FemResult (activeObject if res= NULL) to vtkUnstructuredGrid dataset file
static void writeResult(const char* filename, const App::DocumentObject* res = nullptr);
};
}
// write FemResult (activeObject if res= NULL) to vtkUnstructuredGrid dataset file
static void writeResult(const char* filename, const App::DocumentObject* res = nullptr);
};
} // namespace Fem
#endif //FEM_VTK_TOOLS_H
#endif // FEM_VTK_TOOLS_H

701
src/Mod/Fem/App/HypothesisPy.cpp Executable file → Normal file

File diff suppressed because it is too large Load Diff

237
src/Mod/Fem/App/HypothesisPy.h Executable file → Normal file
View File

@@ -24,22 +24,25 @@
#define FEM_HYPOTHESISPY_H
#include <CXX/Extensions.hxx>
#include <SMESH_Version.h> // needed for SMESH_VERSION_MAJOR
#include <memory>
#include <SMESH_Version.h> // needed for SMESH_VERSION_MAJOR
class SMESH_Hypothesis;
class SMESH_Gen;
namespace Fem {
namespace Fem
{
class HypothesisPy : public Py::PythonExtension<HypothesisPy>
class HypothesisPy: public Py::PythonExtension<HypothesisPy>
{
public:
using HypothesisPyBase = Py::PythonExtension<HypothesisPy>;
explicit HypothesisPy(std::shared_ptr<SMESH_Hypothesis>);
~HypothesisPy() override;
std::shared_ptr<SMESH_Hypothesis> getHypothesis() const
{ return hyp; }
{
return hyp;
}
private:
std::shared_ptr<SMESH_Hypothesis> hyp;
@@ -47,17 +50,17 @@ private:
using Hypothesis = Py::ExtensionObject<HypothesisPy>;
template <class T>
class SMESH_HypothesisPy : public Py::PythonExtension<T>
template<class T>
class SMESH_HypothesisPy: public Py::PythonExtension<T>
{
public:
using SMESH_HypothesisPyBase = SMESH_HypothesisPy<T>;
static void init_type(PyObject*); // announce properties and methods
static void init_type(PyObject*); // announce properties and methods
explicit SMESH_HypothesisPy(SMESH_Hypothesis*);
~SMESH_HypothesisPy() override;
Py::Object getattr(const char *name) override;
Py::Object getattr(const char* name) override;
Py::Object repr() override;
Py::Object getLibName(const Py::Tuple& args);
Py::Object setLibName(const Py::Tuple& args);
@@ -72,22 +75,26 @@ public:
Py::Object setParametersByMesh(const Py::Tuple& args);
std::shared_ptr<SMESH_Hypothesis> getHypothesis() const
{ return hyp; }
{
return hyp;
}
protected:
template<typename type>
type* hypothesis() const
{ return static_cast<type*>(hyp.get()); }
{
return static_cast<type*>(hyp.get());
}
private:
static PyObject *PyMake(struct _typeobject *, PyObject *, PyObject *);
static PyObject* PyMake(struct _typeobject*, PyObject*, PyObject*);
private:
std::shared_ptr<SMESH_Hypothesis> hyp;
};
#if SMESH_VERSION_MAJOR >= 9
class StdMeshers_Arithmetic1DPy : public SMESH_HypothesisPy<StdMeshers_Arithmetic1DPy>
class StdMeshers_Arithmetic1DPy: public SMESH_HypothesisPy<StdMeshers_Arithmetic1DPy>
{
public:
static void init_type(PyObject*);
@@ -98,7 +105,7 @@ public:
Py::Object getLength(const Py::Tuple& args);
};
class StdMeshers_AutomaticLengthPy : public SMESH_HypothesisPy<StdMeshers_AutomaticLengthPy>
class StdMeshers_AutomaticLengthPy: public SMESH_HypothesisPy<StdMeshers_AutomaticLengthPy>
{
public:
static void init_type(PyObject*);
@@ -110,7 +117,7 @@ public:
Py::Object getLength(const Py::Tuple& args);
};
class StdMeshers_NotConformAllowedPy : public SMESH_HypothesisPy<StdMeshers_NotConformAllowedPy>
class StdMeshers_NotConformAllowedPy: public SMESH_HypothesisPy<StdMeshers_NotConformAllowedPy>
{
public:
static void init_type(PyObject*);
@@ -118,7 +125,7 @@ public:
~StdMeshers_NotConformAllowedPy();
};
class StdMeshers_MaxLengthPy : public SMESH_HypothesisPy<StdMeshers_MaxLengthPy>
class StdMeshers_MaxLengthPy: public SMESH_HypothesisPy<StdMeshers_MaxLengthPy>
{
public:
static void init_type(PyObject*);
@@ -134,7 +141,7 @@ public:
Py::Object getUsePreestimatedLength(const Py::Tuple& args);
};
class StdMeshers_LocalLengthPy : public SMESH_HypothesisPy<StdMeshers_LocalLengthPy>
class StdMeshers_LocalLengthPy: public SMESH_HypothesisPy<StdMeshers_LocalLengthPy>
{
public:
static void init_type(PyObject*);
@@ -147,7 +154,7 @@ public:
Py::Object getPrecision(const Py::Tuple& args);
};
class StdMeshers_MaxElementAreaPy : public SMESH_HypothesisPy<StdMeshers_MaxElementAreaPy>
class StdMeshers_MaxElementAreaPy: public SMESH_HypothesisPy<StdMeshers_MaxElementAreaPy>
{
public:
static void init_type(PyObject*);
@@ -158,7 +165,8 @@ public:
Py::Object getMaxArea(const Py::Tuple& args);
};
class StdMeshers_QuadranglePreferencePy : public SMESH_HypothesisPy<StdMeshers_QuadranglePreferencePy>
class StdMeshers_QuadranglePreferencePy
: public SMESH_HypothesisPy<StdMeshers_QuadranglePreferencePy>
{
public:
static void init_type(PyObject*);
@@ -166,7 +174,7 @@ public:
~StdMeshers_QuadranglePreferencePy();
};
class StdMeshers_Quadrangle_2DPy : public SMESH_HypothesisPy<StdMeshers_Quadrangle_2DPy>
class StdMeshers_Quadrangle_2DPy: public SMESH_HypothesisPy<StdMeshers_Quadrangle_2DPy>
{
public:
static void init_type(PyObject*);
@@ -174,7 +182,7 @@ public:
~StdMeshers_Quadrangle_2DPy();
};
class StdMeshers_Regular_1DPy : public SMESH_HypothesisPy<StdMeshers_Regular_1DPy>
class StdMeshers_Regular_1DPy: public SMESH_HypothesisPy<StdMeshers_Regular_1DPy>
{
public:
static void init_type(PyObject*);
@@ -182,7 +190,7 @@ public:
~StdMeshers_Regular_1DPy();
};
class StdMeshers_UseExisting_1DPy : public SMESH_HypothesisPy<StdMeshers_UseExisting_1DPy>
class StdMeshers_UseExisting_1DPy: public SMESH_HypothesisPy<StdMeshers_UseExisting_1DPy>
{
public:
static void init_type(PyObject*);
@@ -190,7 +198,7 @@ public:
~StdMeshers_UseExisting_1DPy();
};
class StdMeshers_UseExisting_2DPy : public SMESH_HypothesisPy<StdMeshers_UseExisting_2DPy>
class StdMeshers_UseExisting_2DPy: public SMESH_HypothesisPy<StdMeshers_UseExisting_2DPy>
{
public:
static void init_type(PyObject*);
@@ -198,7 +206,7 @@ public:
~StdMeshers_UseExisting_2DPy();
};
class StdMeshers_CompositeSegment_1DPy : public SMESH_HypothesisPy<StdMeshers_CompositeSegment_1DPy>
class StdMeshers_CompositeSegment_1DPy: public SMESH_HypothesisPy<StdMeshers_CompositeSegment_1DPy>
{
public:
static void init_type(PyObject*);
@@ -206,7 +214,7 @@ public:
~StdMeshers_CompositeSegment_1DPy();
};
class StdMeshers_Deflection1DPy : public SMESH_HypothesisPy<StdMeshers_Deflection1DPy>
class StdMeshers_Deflection1DPy: public SMESH_HypothesisPy<StdMeshers_Deflection1DPy>
{
public:
static void init_type(PyObject*);
@@ -216,7 +224,7 @@ public:
Py::Object setDeflection(const Py::Tuple& args);
};
class StdMeshers_Hexa_3DPy : public SMESH_HypothesisPy<StdMeshers_Hexa_3DPy>
class StdMeshers_Hexa_3DPy: public SMESH_HypothesisPy<StdMeshers_Hexa_3DPy>
{
public:
static void init_type(PyObject*);
@@ -224,7 +232,7 @@ public:
~StdMeshers_Hexa_3DPy();
};
class StdMeshers_StartEndLengthPy : public SMESH_HypothesisPy<StdMeshers_StartEndLengthPy>
class StdMeshers_StartEndLengthPy: public SMESH_HypothesisPy<StdMeshers_StartEndLengthPy>
{
public:
static void init_type(PyObject*);
@@ -234,7 +242,8 @@ public:
Py::Object getLength(const Py::Tuple& args);
};
class StdMeshers_SegmentLengthAroundVertexPy : public SMESH_HypothesisPy<StdMeshers_SegmentLengthAroundVertexPy>
class StdMeshers_SegmentLengthAroundVertexPy
: public SMESH_HypothesisPy<StdMeshers_SegmentLengthAroundVertexPy>
{
public:
static void init_type(PyObject*);
@@ -244,7 +253,8 @@ public:
Py::Object getLength(const Py::Tuple& args);
};
class StdMeshers_SegmentAroundVertex_0DPy : public SMESH_HypothesisPy<StdMeshers_SegmentAroundVertex_0DPy>
class StdMeshers_SegmentAroundVertex_0DPy
: public SMESH_HypothesisPy<StdMeshers_SegmentAroundVertex_0DPy>
{
public:
static void init_type(PyObject*);
@@ -252,7 +262,7 @@ public:
~StdMeshers_SegmentAroundVertex_0DPy();
};
class StdMeshers_RadialPrism_3DPy : public SMESH_HypothesisPy<StdMeshers_RadialPrism_3DPy>
class StdMeshers_RadialPrism_3DPy: public SMESH_HypothesisPy<StdMeshers_RadialPrism_3DPy>
{
public:
static void init_type(PyObject*);
@@ -260,7 +270,7 @@ public:
~StdMeshers_RadialPrism_3DPy();
};
class StdMeshers_QuadraticMeshPy : public SMESH_HypothesisPy<StdMeshers_QuadraticMeshPy>
class StdMeshers_QuadraticMeshPy: public SMESH_HypothesisPy<StdMeshers_QuadraticMeshPy>
{
public:
static void init_type(PyObject*);
@@ -268,7 +278,7 @@ public:
~StdMeshers_QuadraticMeshPy();
};
class StdMeshers_ProjectionSource3DPy : public SMESH_HypothesisPy<StdMeshers_ProjectionSource3DPy>
class StdMeshers_ProjectionSource3DPy: public SMESH_HypothesisPy<StdMeshers_ProjectionSource3DPy>
{
public:
static void init_type(PyObject*);
@@ -276,7 +286,7 @@ public:
~StdMeshers_ProjectionSource3DPy();
};
class StdMeshers_ProjectionSource2DPy : public SMESH_HypothesisPy<StdMeshers_ProjectionSource2DPy>
class StdMeshers_ProjectionSource2DPy: public SMESH_HypothesisPy<StdMeshers_ProjectionSource2DPy>
{
public:
static void init_type(PyObject*);
@@ -284,7 +294,7 @@ public:
~StdMeshers_ProjectionSource2DPy();
};
class StdMeshers_ProjectionSource1DPy : public SMESH_HypothesisPy<StdMeshers_ProjectionSource1DPy>
class StdMeshers_ProjectionSource1DPy: public SMESH_HypothesisPy<StdMeshers_ProjectionSource1DPy>
{
public:
static void init_type(PyObject*);
@@ -292,7 +302,7 @@ public:
~StdMeshers_ProjectionSource1DPy();
};
class StdMeshers_Projection_3DPy : public SMESH_HypothesisPy<StdMeshers_Projection_3DPy>
class StdMeshers_Projection_3DPy: public SMESH_HypothesisPy<StdMeshers_Projection_3DPy>
{
public:
static void init_type(PyObject*);
@@ -300,7 +310,7 @@ public:
~StdMeshers_Projection_3DPy();
};
class StdMeshers_Projection_2DPy : public SMESH_HypothesisPy<StdMeshers_Projection_2DPy>
class StdMeshers_Projection_2DPy: public SMESH_HypothesisPy<StdMeshers_Projection_2DPy>
{
public:
static void init_type(PyObject*);
@@ -308,7 +318,7 @@ public:
~StdMeshers_Projection_2DPy();
};
class StdMeshers_Projection_1DPy : public SMESH_HypothesisPy<StdMeshers_Projection_1DPy>
class StdMeshers_Projection_1DPy: public SMESH_HypothesisPy<StdMeshers_Projection_1DPy>
{
public:
static void init_type(PyObject*);
@@ -316,7 +326,7 @@ public:
~StdMeshers_Projection_1DPy();
};
class StdMeshers_Prism_3DPy : public SMESH_HypothesisPy<StdMeshers_Prism_3DPy>
class StdMeshers_Prism_3DPy: public SMESH_HypothesisPy<StdMeshers_Prism_3DPy>
{
public:
static void init_type(PyObject*);
@@ -324,7 +334,7 @@ public:
~StdMeshers_Prism_3DPy();
};
class StdMeshers_NumberOfSegmentsPy : public SMESH_HypothesisPy<StdMeshers_NumberOfSegmentsPy>
class StdMeshers_NumberOfSegmentsPy: public SMESH_HypothesisPy<StdMeshers_NumberOfSegmentsPy>
{
public:
static void init_type(PyObject*);
@@ -334,7 +344,7 @@ public:
Py::Object getNumSegm(const Py::Tuple& args);
};
class StdMeshers_NumberOfLayersPy : public SMESH_HypothesisPy<StdMeshers_NumberOfLayersPy>
class StdMeshers_NumberOfLayersPy: public SMESH_HypothesisPy<StdMeshers_NumberOfLayersPy>
{
public:
static void init_type(PyObject*);
@@ -344,7 +354,7 @@ public:
Py::Object getNumLayers(const Py::Tuple& args);
};
class StdMeshers_MEFISTO_2DPy : public SMESH_HypothesisPy<StdMeshers_MEFISTO_2DPy>
class StdMeshers_MEFISTO_2DPy: public SMESH_HypothesisPy<StdMeshers_MEFISTO_2DPy>
{
public:
static void init_type(PyObject*);
@@ -352,7 +362,7 @@ public:
~StdMeshers_MEFISTO_2DPy();
};
class StdMeshers_MaxElementVolumePy : public SMESH_HypothesisPy<StdMeshers_MaxElementVolumePy>
class StdMeshers_MaxElementVolumePy: public SMESH_HypothesisPy<StdMeshers_MaxElementVolumePy>
{
public:
static void init_type(PyObject*);
@@ -362,7 +372,7 @@ public:
Py::Object getMaxVolume(const Py::Tuple& args);
};
class StdMeshers_LengthFromEdgesPy : public SMESH_HypothesisPy<StdMeshers_LengthFromEdgesPy>
class StdMeshers_LengthFromEdgesPy: public SMESH_HypothesisPy<StdMeshers_LengthFromEdgesPy>
{
public:
static void init_type(PyObject*);
@@ -372,7 +382,7 @@ public:
Py::Object getMode(const Py::Tuple& args);
};
class StdMeshers_LayerDistributionPy : public SMESH_HypothesisPy<StdMeshers_LayerDistributionPy>
class StdMeshers_LayerDistributionPy: public SMESH_HypothesisPy<StdMeshers_LayerDistributionPy>
{
public:
static void init_type(PyObject*);
@@ -382,7 +392,7 @@ public:
Py::Object getLayerDistribution(const Py::Tuple& args);
};
#else
class StdMeshers_Arithmetic1DPy : public SMESH_HypothesisPy<StdMeshers_Arithmetic1DPy>
class StdMeshers_Arithmetic1DPy: public SMESH_HypothesisPy<StdMeshers_Arithmetic1DPy>
{
public:
static void init_type(PyObject*);
@@ -393,7 +403,7 @@ public:
Py::Object getLength(const Py::Tuple& args);
};
class StdMeshers_AutomaticLengthPy : public SMESH_HypothesisPy<StdMeshers_AutomaticLengthPy>
class StdMeshers_AutomaticLengthPy: public SMESH_HypothesisPy<StdMeshers_AutomaticLengthPy>
{
public:
static void init_type(PyObject*);
@@ -405,7 +415,7 @@ public:
Py::Object getLength(const Py::Tuple& args);
};
class StdMeshers_NotConformAllowedPy : public SMESH_HypothesisPy<StdMeshers_NotConformAllowedPy>
class StdMeshers_NotConformAllowedPy: public SMESH_HypothesisPy<StdMeshers_NotConformAllowedPy>
{
public:
static void init_type(PyObject*);
@@ -413,7 +423,7 @@ public:
~StdMeshers_NotConformAllowedPy() override;
};
class StdMeshers_MaxLengthPy : public SMESH_HypothesisPy<StdMeshers_MaxLengthPy>
class StdMeshers_MaxLengthPy: public SMESH_HypothesisPy<StdMeshers_MaxLengthPy>
{
public:
static void init_type(PyObject*);
@@ -429,7 +439,7 @@ public:
Py::Object getUsePreestimatedLength(const Py::Tuple& args);
};
class StdMeshers_LocalLengthPy : public SMESH_HypothesisPy<StdMeshers_LocalLengthPy>
class StdMeshers_LocalLengthPy: public SMESH_HypothesisPy<StdMeshers_LocalLengthPy>
{
public:
static void init_type(PyObject*);
@@ -442,7 +452,7 @@ public:
Py::Object getPrecision(const Py::Tuple& args);
};
class StdMeshers_MaxElementAreaPy : public SMESH_HypothesisPy<StdMeshers_MaxElementAreaPy>
class StdMeshers_MaxElementAreaPy: public SMESH_HypothesisPy<StdMeshers_MaxElementAreaPy>
{
public:
static void init_type(PyObject*);
@@ -453,7 +463,8 @@ public:
Py::Object getMaxArea(const Py::Tuple& args);
};
class StdMeshers_QuadranglePreferencePy : public SMESH_HypothesisPy<StdMeshers_QuadranglePreferencePy>
class StdMeshers_QuadranglePreferencePy
: public SMESH_HypothesisPy<StdMeshers_QuadranglePreferencePy>
{
public:
static void init_type(PyObject*);
@@ -461,7 +472,7 @@ public:
~StdMeshers_QuadranglePreferencePy() override;
};
class StdMeshers_Quadrangle_2DPy : public SMESH_HypothesisPy<StdMeshers_Quadrangle_2DPy>
class StdMeshers_Quadrangle_2DPy: public SMESH_HypothesisPy<StdMeshers_Quadrangle_2DPy>
{
public:
static void init_type(PyObject*);
@@ -469,7 +480,7 @@ public:
~StdMeshers_Quadrangle_2DPy() override;
};
class StdMeshers_Regular_1DPy : public SMESH_HypothesisPy<StdMeshers_Regular_1DPy>
class StdMeshers_Regular_1DPy: public SMESH_HypothesisPy<StdMeshers_Regular_1DPy>
{
public:
static void init_type(PyObject*);
@@ -477,7 +488,7 @@ public:
~StdMeshers_Regular_1DPy() override;
};
class StdMeshers_UseExisting_1DPy : public SMESH_HypothesisPy<StdMeshers_UseExisting_1DPy>
class StdMeshers_UseExisting_1DPy: public SMESH_HypothesisPy<StdMeshers_UseExisting_1DPy>
{
public:
static void init_type(PyObject*);
@@ -485,7 +496,7 @@ public:
~StdMeshers_UseExisting_1DPy() override;
};
class StdMeshers_UseExisting_2DPy : public SMESH_HypothesisPy<StdMeshers_UseExisting_2DPy>
class StdMeshers_UseExisting_2DPy: public SMESH_HypothesisPy<StdMeshers_UseExisting_2DPy>
{
public:
static void init_type(PyObject*);
@@ -493,7 +504,7 @@ public:
~StdMeshers_UseExisting_2DPy() override;
};
class StdMeshers_CompositeSegment_1DPy : public SMESH_HypothesisPy<StdMeshers_CompositeSegment_1DPy>
class StdMeshers_CompositeSegment_1DPy: public SMESH_HypothesisPy<StdMeshers_CompositeSegment_1DPy>
{
public:
static void init_type(PyObject*);
@@ -501,7 +512,7 @@ public:
~StdMeshers_CompositeSegment_1DPy() override;
};
class StdMeshers_Deflection1DPy : public SMESH_HypothesisPy<StdMeshers_Deflection1DPy>
class StdMeshers_Deflection1DPy: public SMESH_HypothesisPy<StdMeshers_Deflection1DPy>
{
public:
static void init_type(PyObject*);
@@ -511,24 +522,24 @@ public:
Py::Object setDeflection(const Py::Tuple& args);
};
class StdMeshers_Hexa_3DPy : public SMESH_HypothesisPy<StdMeshers_Hexa_3DPy>
class StdMeshers_Hexa_3DPy: public SMESH_HypothesisPy<StdMeshers_Hexa_3DPy>
{
public:
static void init_type(PyObject*);
StdMeshers_Hexa_3DPy(int hypId, int studyId, SMESH_Gen* gen);
~StdMeshers_Hexa_3DPy() override;
};
#if SMESH_VERSION_MAJOR < 7 // -----------------------------------------------
class StdMeshers_TrianglePreferencePy : public SMESH_HypothesisPy<StdMeshers_TrianglePreferencePy>
#if SMESH_VERSION_MAJOR < 7 // -----------------------------------------------
class StdMeshers_TrianglePreferencePy: public SMESH_HypothesisPy<StdMeshers_TrianglePreferencePy>
{
public:
static void init_type(PyObject*);
StdMeshers_TrianglePreferencePy(int hypId, int studyId, SMESH_Gen* gen);
~StdMeshers_TrianglePreferencePy();
};
#endif // --------------------------------------------------------------------
#endif // --------------------------------------------------------------------
class StdMeshers_StartEndLengthPy : public SMESH_HypothesisPy<StdMeshers_StartEndLengthPy>
class StdMeshers_StartEndLengthPy: public SMESH_HypothesisPy<StdMeshers_StartEndLengthPy>
{
public:
static void init_type(PyObject*);
@@ -538,7 +549,8 @@ public:
Py::Object getLength(const Py::Tuple& args);
};
class StdMeshers_SegmentLengthAroundVertexPy : public SMESH_HypothesisPy<StdMeshers_SegmentLengthAroundVertexPy>
class StdMeshers_SegmentLengthAroundVertexPy
: public SMESH_HypothesisPy<StdMeshers_SegmentLengthAroundVertexPy>
{
public:
static void init_type(PyObject*);
@@ -548,7 +560,8 @@ public:
Py::Object getLength(const Py::Tuple& args);
};
class StdMeshers_SegmentAroundVertex_0DPy : public SMESH_HypothesisPy<StdMeshers_SegmentAroundVertex_0DPy>
class StdMeshers_SegmentAroundVertex_0DPy
: public SMESH_HypothesisPy<StdMeshers_SegmentAroundVertex_0DPy>
{
public:
static void init_type(PyObject*);
@@ -556,7 +569,7 @@ public:
~StdMeshers_SegmentAroundVertex_0DPy() override;
};
class StdMeshers_RadialPrism_3DPy : public SMESH_HypothesisPy<StdMeshers_RadialPrism_3DPy>
class StdMeshers_RadialPrism_3DPy: public SMESH_HypothesisPy<StdMeshers_RadialPrism_3DPy>
{
public:
static void init_type(PyObject*);
@@ -564,7 +577,7 @@ public:
~StdMeshers_RadialPrism_3DPy() override;
};
class StdMeshers_QuadraticMeshPy : public SMESH_HypothesisPy<StdMeshers_QuadraticMeshPy>
class StdMeshers_QuadraticMeshPy: public SMESH_HypothesisPy<StdMeshers_QuadraticMeshPy>
{
public:
static void init_type(PyObject*);
@@ -572,63 +585,63 @@ public:
~StdMeshers_QuadraticMeshPy() override;
};
class StdMeshers_ProjectionSource3DPy : public SMESH_HypothesisPy<StdMeshers_ProjectionSource3DPy>
class StdMeshers_ProjectionSource3DPy: public SMESH_HypothesisPy<StdMeshers_ProjectionSource3DPy>
{
public:
static void init_type(PyObject*);
StdMeshers_ProjectionSource3DPy(int hypId, int studyId, SMESH_Gen* gen);
~StdMeshers_ProjectionSource3DPy() override;
//Py::Object setSource3DShape(const Py::Tuple& args);
//Py::Object getSource3DShape(const Py::Tuple& args);
//Py::Object setSourceMesh(const Py::Tuple& args);
//Py::Object getSourceMesh(const Py::Tuple& args);
//Py::Object setVertexAssociation(const Py::Tuple& args);
//Py::Object getSourceVertex(const Py::Tuple& args);
//Py::Object getTargetVertex(const Py::Tuple& args);
//Py::Object hasVertexAssociation(const Py::Tuple& args);
//Py::Object getStoreParams(const Py::Tuple& args);
//Py::Object restoreParams(const Py::Tuple& args);
// Py::Object setSource3DShape(const Py::Tuple& args);
// Py::Object getSource3DShape(const Py::Tuple& args);
// Py::Object setSourceMesh(const Py::Tuple& args);
// Py::Object getSourceMesh(const Py::Tuple& args);
// Py::Object setVertexAssociation(const Py::Tuple& args);
// Py::Object getSourceVertex(const Py::Tuple& args);
// Py::Object getTargetVertex(const Py::Tuple& args);
// Py::Object hasVertexAssociation(const Py::Tuple& args);
// Py::Object getStoreParams(const Py::Tuple& args);
// Py::Object restoreParams(const Py::Tuple& args);
};
class StdMeshers_ProjectionSource2DPy : public SMESH_HypothesisPy<StdMeshers_ProjectionSource2DPy>
class StdMeshers_ProjectionSource2DPy: public SMESH_HypothesisPy<StdMeshers_ProjectionSource2DPy>
{
public:
static void init_type(PyObject*);
StdMeshers_ProjectionSource2DPy(int hypId, int studyId, SMESH_Gen* gen);
~StdMeshers_ProjectionSource2DPy() override;
//Py::Object setSourceFace(const Py::Tuple& args);
//Py::Object getSourceFace(const Py::Tuple& args);
//Py::Object isCompoundSource(const Py::Tuple& args);
//Py::Object setSourceMesh(const Py::Tuple& args);
//Py::Object getSourceMesh(const Py::Tuple& args);
//Py::Object setVertexAssociation(const Py::Tuple& args);
//Py::Object getSourceVertex(const Py::Tuple& args);
//Py::Object getTargetVertex(const Py::Tuple& args);
//Py::Object hasVertexAssociation(const Py::Tuple& args);
//Py::Object getStoreParams(const Py::Tuple& args);
//Py::Object restoreParams(const Py::Tuple& args);
// Py::Object setSourceFace(const Py::Tuple& args);
// Py::Object getSourceFace(const Py::Tuple& args);
// Py::Object isCompoundSource(const Py::Tuple& args);
// Py::Object setSourceMesh(const Py::Tuple& args);
// Py::Object getSourceMesh(const Py::Tuple& args);
// Py::Object setVertexAssociation(const Py::Tuple& args);
// Py::Object getSourceVertex(const Py::Tuple& args);
// Py::Object getTargetVertex(const Py::Tuple& args);
// Py::Object hasVertexAssociation(const Py::Tuple& args);
// Py::Object getStoreParams(const Py::Tuple& args);
// Py::Object restoreParams(const Py::Tuple& args);
};
class StdMeshers_ProjectionSource1DPy : public SMESH_HypothesisPy<StdMeshers_ProjectionSource1DPy>
class StdMeshers_ProjectionSource1DPy: public SMESH_HypothesisPy<StdMeshers_ProjectionSource1DPy>
{
public:
static void init_type(PyObject*);
StdMeshers_ProjectionSource1DPy(int hypId, int studyId, SMESH_Gen* gen);
~StdMeshers_ProjectionSource1DPy() override;
//Py::Object setSourceEdge(const Py::Tuple& args);
//Py::Object getSourceEdge(const Py::Tuple& args);
//Py::Object isCompoundSource(const Py::Tuple& args);
//Py::Object setSourceMesh(const Py::Tuple& args);
//Py::Object getSourceMesh(const Py::Tuple& args);
//Py::Object setVertexAssociation(const Py::Tuple& args);
//Py::Object getSourceVertex(const Py::Tuple& args);
//Py::Object getTargetVertex(const Py::Tuple& args);
//Py::Object hasVertexAssociation(const Py::Tuple& args);
//Py::Object getStoreParams(const Py::Tuple& args);
//Py::Object restoreParams(const Py::Tuple& args);
// Py::Object setSourceEdge(const Py::Tuple& args);
// Py::Object getSourceEdge(const Py::Tuple& args);
// Py::Object isCompoundSource(const Py::Tuple& args);
// Py::Object setSourceMesh(const Py::Tuple& args);
// Py::Object getSourceMesh(const Py::Tuple& args);
// Py::Object setVertexAssociation(const Py::Tuple& args);
// Py::Object getSourceVertex(const Py::Tuple& args);
// Py::Object getTargetVertex(const Py::Tuple& args);
// Py::Object hasVertexAssociation(const Py::Tuple& args);
// Py::Object getStoreParams(const Py::Tuple& args);
// Py::Object restoreParams(const Py::Tuple& args);
};
class StdMeshers_Projection_3DPy : public SMESH_HypothesisPy<StdMeshers_Projection_3DPy>
class StdMeshers_Projection_3DPy: public SMESH_HypothesisPy<StdMeshers_Projection_3DPy>
{
public:
static void init_type(PyObject*);
@@ -636,7 +649,7 @@ public:
~StdMeshers_Projection_3DPy() override;
};
class StdMeshers_Projection_2DPy : public SMESH_HypothesisPy<StdMeshers_Projection_2DPy>
class StdMeshers_Projection_2DPy: public SMESH_HypothesisPy<StdMeshers_Projection_2DPy>
{
public:
static void init_type(PyObject*);
@@ -644,7 +657,7 @@ public:
~StdMeshers_Projection_2DPy() override;
};
class StdMeshers_Projection_1DPy : public SMESH_HypothesisPy<StdMeshers_Projection_1DPy>
class StdMeshers_Projection_1DPy: public SMESH_HypothesisPy<StdMeshers_Projection_1DPy>
{
public:
static void init_type(PyObject*);
@@ -652,7 +665,7 @@ public:
~StdMeshers_Projection_1DPy() override;
};
class StdMeshers_Prism_3DPy : public SMESH_HypothesisPy<StdMeshers_Prism_3DPy>
class StdMeshers_Prism_3DPy: public SMESH_HypothesisPy<StdMeshers_Prism_3DPy>
{
public:
static void init_type(PyObject*);
@@ -660,7 +673,7 @@ public:
~StdMeshers_Prism_3DPy() override;
};
class StdMeshers_NumberOfSegmentsPy : public SMESH_HypothesisPy<StdMeshers_NumberOfSegmentsPy>
class StdMeshers_NumberOfSegmentsPy: public SMESH_HypothesisPy<StdMeshers_NumberOfSegmentsPy>
{
public:
static void init_type(PyObject*);
@@ -670,7 +683,7 @@ public:
Py::Object getNumSegm(const Py::Tuple& args);
};
class StdMeshers_NumberOfLayersPy : public SMESH_HypothesisPy<StdMeshers_NumberOfLayersPy>
class StdMeshers_NumberOfLayersPy: public SMESH_HypothesisPy<StdMeshers_NumberOfLayersPy>
{
public:
static void init_type(PyObject*);
@@ -680,7 +693,7 @@ public:
Py::Object getNumLayers(const Py::Tuple& args);
};
class StdMeshers_MEFISTO_2DPy : public SMESH_HypothesisPy<StdMeshers_MEFISTO_2DPy>
class StdMeshers_MEFISTO_2DPy: public SMESH_HypothesisPy<StdMeshers_MEFISTO_2DPy>
{
public:
static void init_type(PyObject*);
@@ -688,7 +701,7 @@ public:
~StdMeshers_MEFISTO_2DPy() override;
};
class StdMeshers_MaxElementVolumePy : public SMESH_HypothesisPy<StdMeshers_MaxElementVolumePy>
class StdMeshers_MaxElementVolumePy: public SMESH_HypothesisPy<StdMeshers_MaxElementVolumePy>
{
public:
static void init_type(PyObject*);
@@ -698,7 +711,7 @@ public:
Py::Object getMaxVolume(const Py::Tuple& args);
};
class StdMeshers_LengthFromEdgesPy : public SMESH_HypothesisPy<StdMeshers_LengthFromEdgesPy>
class StdMeshers_LengthFromEdgesPy: public SMESH_HypothesisPy<StdMeshers_LengthFromEdgesPy>
{
public:
static void init_type(PyObject*);
@@ -708,7 +721,7 @@ public:
Py::Object getMode(const Py::Tuple& args);
};
class StdMeshers_LayerDistributionPy : public SMESH_HypothesisPy<StdMeshers_LayerDistributionPy>
class StdMeshers_LayerDistributionPy: public SMESH_HypothesisPy<StdMeshers_LayerDistributionPy>
{
public:
static void init_type(PyObject*);
@@ -719,6 +732,6 @@ public:
};
#endif
} // namespace Fem
} // namespace Fem
#endif // FEM_HYPOTHESISPY_H
#endif // FEM_HYPOTHESISPY_H

View File

@@ -26,8 +26,8 @@
#include <FCConfig.h>
#ifdef _MSC_VER
# pragma warning(disable : 4290)
# pragma warning(disable : 4275)
#pragma warning(disable : 4290)
#pragma warning(disable : 4275)
#endif
#ifdef _PreComp_
@@ -56,19 +56,19 @@
#include <QFileInfo>
// Salomesh
#include <SMDSAbs_ElementType.hxx>
#include <SMDS_MeshElement.hxx>
#include <SMDS_MeshGroup.hxx>
#include <SMDS_MeshNode.hxx>
#include <SMDS_PolyhedralVolumeOfNodes.hxx>
#include <SMDSAbs_ElementType.hxx>
#include <SMESHDS_Group.hxx>
#include <SMESHDS_GroupBase.hxx>
#include <SMESHDS_Mesh.hxx>
#include <SMESH_Gen.hxx>
#include <SMESH_Group.hxx>
#include <SMESH_Mesh.hxx>
#include <SMESH_MeshEditor.hxx>
#include <SMESH_Version.h>
#include <SMESHDS_Group.hxx>
#include <SMESHDS_GroupBase.hxx>
#include <SMESHDS_Mesh.hxx>
#include <StdMeshers_Arithmetic1D.hxx>
#include <StdMeshers_AutomaticLength.hxx>
@@ -78,40 +78,40 @@
#include <StdMeshers_LayerDistribution.hxx>
#include <StdMeshers_LengthFromEdges.hxx>
#include <StdMeshers_LocalLength.hxx>
#include <StdMeshers_MEFISTO_2D.hxx>
#include <StdMeshers_MaxElementArea.hxx>
#include <StdMeshers_MaxElementVolume.hxx>
#include <StdMeshers_MaxLength.hxx>
#include <StdMeshers_MEFISTO_2D.hxx>
#include <StdMeshers_NotConformAllowed.hxx>
#include <StdMeshers_NumberOfLayers.hxx>
#include <StdMeshers_NumberOfSegments.hxx>
#include <StdMeshers_Prism_3D.hxx>
#include <StdMeshers_Projection_1D.hxx>
#include <StdMeshers_Projection_2D.hxx>
#include <StdMeshers_Projection_3D.hxx>
#include <StdMeshers_ProjectionSource1D.hxx>
#include <StdMeshers_ProjectionSource2D.hxx>
#include <StdMeshers_ProjectionSource3D.hxx>
#include <StdMeshers_Projection_1D.hxx>
#include <StdMeshers_Projection_2D.hxx>
#include <StdMeshers_Projection_3D.hxx>
#include <StdMeshers_QuadranglePreference.hxx>
#include <StdMeshers_Quadrangle_2D.hxx>
#include <StdMeshers_QuadraticMesh.hxx>
#include <StdMeshers_QuadranglePreference.hxx>
#include <StdMeshers_RadialPrism_3D.hxx>
#include <StdMeshers_Regular_1D.hxx>
#include <StdMeshers_SegmentAroundVertex_0D.hxx>
#include <StdMeshers_SegmentLengthAroundVertex.hxx>
#include <StdMeshers_StartEndLength.hxx>
#if SMESH_VERSION_MAJOR < 7
# include <StdMeshers_TrianglePreference.hxx>
#include <StdMeshers_TrianglePreference.hxx>
#endif
#include <StdMeshers_UseExisting_1D2D.hxx>
// Opencascade
#include <Adaptor3d_IsoCurve.hxx>
#include <Bnd_Box.hxx>
#include <BRep_Tool.hxx>
#include <BRepAdaptor_Curve.hxx>
#include <BRep_Tool.hxx>
#include <Bnd_Box.hxx>
#if OCC_VERSION_HEX < 0x070600
# include <BRepAdaptor_HSurface.hxx>
#include <BRepAdaptor_HSurface.hxx>
#endif
#include <BRepAdaptor_Surface.hxx>
#include <BRepBndLib.hxx>
@@ -123,20 +123,15 @@
#include <BRepGProp_Face.hxx>
#include <BRepTools.hxx>
#include <GCPnts_AbscissaPoint.hxx>
#include <Geom_BezierCurve.hxx>
#include <Geom_BezierSurface.hxx>
#include <Geom_BSplineCurve.hxx>
#include <Geom_BSplineSurface.hxx>
#include <Geom_Line.hxx>
#include <Geom_Plane.hxx>
#include <GProp_GProps.hxx>
#include <GeomAPI_IntCS.hxx>
#include <GeomAPI_ProjectPointOnSurf.hxx>
#include <gp_Dir.hxx>
#include <gp_Lin.hxx>
#include <gp_Pln.hxx>
#include <gp_Pnt.hxx>
#include <gp_Vec.hxx>
#include <GProp_GProps.hxx>
#include <Geom_BSplineCurve.hxx>
#include <Geom_BSplineSurface.hxx>
#include <Geom_BezierCurve.hxx>
#include <Geom_BezierSurface.hxx>
#include <Geom_Line.hxx>
#include <Geom_Plane.hxx>
#include <Precision.hxx>
#include <ShapeAnalysis_ShapeTolerance.hxx>
#include <Standard_Real.hxx>
@@ -148,6 +143,11 @@
#include <TopoDS_Shape.hxx>
#include <TopoDS_Solid.hxx>
#include <TopoDS_Vertex.hxx>
#include <gp_Dir.hxx>
#include <gp_Lin.hxx>
#include <gp_Pln.hxx>
#include <gp_Pnt.hxx>
#include <gp_Vec.hxx>
// VTK
#include <vtkAppendFilter.h>
@@ -190,10 +190,10 @@
// Netgen
#ifdef FCWithNetgen
# include <NETGENPlugin_Hypothesis.hxx>
# include <NETGENPlugin_Mesher.hxx>
# include <NETGENPlugin_SimpleHypothesis_3D.hxx>
#include <NETGENPlugin_Hypothesis.hxx>
#include <NETGENPlugin_Mesher.hxx>
#include <NETGENPlugin_SimpleHypothesis_3D.hxx>
#endif
#endif // _PreComp_
#endif // _PreComp_
#endif

View File

@@ -23,21 +23,21 @@
#include "PreCompiled.h"
#ifndef _PreComp_
# include <Python.h>
# include <vtkCompositeDataSet.h>
# include <vtkMultiBlockDataSet.h>
# include <vtkMultiPieceDataSet.h>
# include <vtkPolyData.h>
# include <vtkRectilinearGrid.h>
# include <vtkStructuredGrid.h>
# include <vtkUnstructuredGrid.h>
# include <vtkUniformGrid.h>
# include <vtkXMLDataSetWriter.h>
# include <vtkXMLImageDataReader.h>
# include <vtkXMLPolyDataReader.h>
# include <vtkXMLRectilinearGridReader.h>
# include <vtkXMLStructuredGridReader.h>
# include <vtkXMLUnstructuredGridReader.h>
#include <Python.h>
#include <vtkCompositeDataSet.h>
#include <vtkMultiBlockDataSet.h>
#include <vtkMultiPieceDataSet.h>
#include <vtkPolyData.h>
#include <vtkRectilinearGrid.h>
#include <vtkStructuredGrid.h>
#include <vtkUniformGrid.h>
#include <vtkUnstructuredGrid.h>
#include <vtkXMLDataSetWriter.h>
#include <vtkXMLImageDataReader.h>
#include <vtkXMLPolyDataReader.h>
#include <vtkXMLRectilinearGridReader.h>
#include <vtkXMLStructuredGridReader.h>
#include <vtkXMLUnstructuredGridReader.h>
#endif
#include <App/Application.h>
@@ -54,45 +54,48 @@
using namespace Fem;
TYPESYSTEM_SOURCE(Fem::PropertyPostDataObject , App::Property)
TYPESYSTEM_SOURCE(Fem::PropertyPostDataObject, App::Property)
PropertyPostDataObject::PropertyPostDataObject() = default;
PropertyPostDataObject::~PropertyPostDataObject() = default;
void PropertyPostDataObject::scaleDataObject(vtkDataObject *dataObject, double s)
void PropertyPostDataObject::scaleDataObject(vtkDataObject* dataObject, double s)
{
auto scalePoints = [](vtkPoints *points, double s) {
auto scalePoints = [](vtkPoints* points, double s) {
for (vtkIdType i = 0; i < points->GetNumberOfPoints(); i++) {
double xyz[3];
points->GetPoint(i, xyz);
for (double & j : xyz)
for (double& j : xyz) {
j *= s;
}
points->SetPoint(i, xyz);
}
};
if (dataObject->GetDataObjectType() == VTK_POLY_DATA) {
vtkPolyData *dataSet = vtkPolyData::SafeDownCast(dataObject);
vtkPolyData* dataSet = vtkPolyData::SafeDownCast(dataObject);
scalePoints(dataSet->GetPoints(), s);
}
else if (dataObject->GetDataObjectType() == VTK_STRUCTURED_GRID) {
vtkStructuredGrid *dataSet = vtkStructuredGrid::SafeDownCast(dataObject);
vtkStructuredGrid* dataSet = vtkStructuredGrid::SafeDownCast(dataObject);
scalePoints(dataSet->GetPoints(), s);
}
else if (dataObject->GetDataObjectType() == VTK_UNSTRUCTURED_GRID) {
vtkUnstructuredGrid *dataSet = vtkUnstructuredGrid::SafeDownCast(dataObject);
vtkUnstructuredGrid* dataSet = vtkUnstructuredGrid::SafeDownCast(dataObject);
scalePoints(dataSet->GetPoints(), s);
}
else if (dataObject->GetDataObjectType() == VTK_MULTIBLOCK_DATA_SET) {
vtkMultiBlockDataSet *dataSet = vtkMultiBlockDataSet::SafeDownCast(dataObject);
for (unsigned int i = 0; i < dataSet->GetNumberOfBlocks(); i++)
vtkMultiBlockDataSet* dataSet = vtkMultiBlockDataSet::SafeDownCast(dataObject);
for (unsigned int i = 0; i < dataSet->GetNumberOfBlocks(); i++) {
scaleDataObject(dataSet->GetBlock(i), s);
}
}
else if (dataObject->GetDataObjectType() == VTK_MULTIPIECE_DATA_SET) {
vtkMultiPieceDataSet *dataSet = vtkMultiPieceDataSet::SafeDownCast(dataObject);
for (unsigned int i = 0; i < dataSet->GetNumberOfPieces(); i++)
vtkMultiPieceDataSet* dataSet = vtkMultiPieceDataSet::SafeDownCast(dataObject);
for (unsigned int i = 0; i < dataSet->GetNumberOfPieces(); i++) {
scaleDataObject(dataSet->GetPiece(i), s);
}
}
}
@@ -105,7 +108,7 @@ void PropertyPostDataObject::scale(double s)
}
}
void PropertyPostDataObject::setValue(const vtkSmartPointer<vtkDataObject> &ds)
void PropertyPostDataObject::setValue(const vtkSmartPointer<vtkDataObject>& ds)
{
aboutToSetValue();
@@ -120,7 +123,7 @@ void PropertyPostDataObject::setValue(const vtkSmartPointer<vtkDataObject> &ds)
hasSetValue();
}
const vtkSmartPointer<vtkDataObject> &PropertyPostDataObject::getValue() const
const vtkSmartPointer<vtkDataObject>& PropertyPostDataObject::getValue() const
{
return m_dataObject;
}
@@ -140,26 +143,26 @@ bool PropertyPostDataObject::isDataSet()
int PropertyPostDataObject::getDataType()
{
if (!m_dataObject)
if (!m_dataObject) {
return -1;
}
return m_dataObject->GetDataObjectType();
}
PyObject *PropertyPostDataObject::getPyObject()
PyObject* PropertyPostDataObject::getPyObject()
{
//TODO: fetch the vtk python object from the data set and return it
// TODO: fetch the vtk python object from the data set and return it
return Py::new_reference_to(Py::None());
}
void PropertyPostDataObject::setPyObject(PyObject * /*value*/)
{
}
void PropertyPostDataObject::setPyObject(PyObject* /*value*/)
{}
App::Property *PropertyPostDataObject::Copy() const
App::Property* PropertyPostDataObject::Copy() const
{
PropertyPostDataObject *prop = new PropertyPostDataObject();
PropertyPostDataObject* prop = new PropertyPostDataObject();
if (m_dataObject) {
prop->createDataObjectByExternalType(m_dataObject);
@@ -204,10 +207,10 @@ void PropertyPostDataObject::createDataObjectByExternalType(vtkSmartPointer<vtkD
}
void PropertyPostDataObject::Paste(const App::Property &from)
void PropertyPostDataObject::Paste(const App::Property& from)
{
aboutToSetValue();
m_dataObject = dynamic_cast<const PropertyPostDataObject &>(from).m_dataObject;
m_dataObject = dynamic_cast<const PropertyPostDataObject&>(from).m_dataObject;
hasSetValue();
}
@@ -218,34 +221,35 @@ unsigned int PropertyPostDataObject::getMemSize() const
void PropertyPostDataObject::getPaths(std::vector<App::ObjectIdentifier>& /*paths*/) const
{
/* paths.push_back(App::ObjectIdentifier(getContainer())
<< App::ObjectIdentifier::Component::SimpleComponent(getName())
<< App::ObjectIdentifier::Component::SimpleComponent(
App::ObjectIdentifier::String("ShapeType")));
paths.push_back(App::ObjectIdentifier(getContainer())
<< App::ObjectIdentifier::Component::SimpleComponent(getName())
<< App::ObjectIdentifier::Component::SimpleComponent(
App::ObjectIdentifier::String("Orientation")));
paths.push_back(App::ObjectIdentifier(getContainer())
<< App::ObjectIdentifier::Component::SimpleComponent(getName())
<< App::ObjectIdentifier::Component::SimpleComponent(
App::ObjectIdentifier::String("Length")));
paths.push_back(App::ObjectIdentifier(getContainer())
<< App::ObjectIdentifier::Component::SimpleComponent(getName())
<< App::ObjectIdentifier::Component::SimpleComponent(
App::ObjectIdentifier::String("Area")));
paths.push_back(App::ObjectIdentifier(getContainer())
<< App::ObjectIdentifier::Component::SimpleComponent(getName())
<< App::ObjectIdentifier::Component::SimpleComponent(
App::ObjectIdentifier::String("Volume")));
*/
/* paths.push_back(App::ObjectIdentifier(getContainer())
<< App::ObjectIdentifier::Component::SimpleComponent(getName())
<< App::ObjectIdentifier::Component::SimpleComponent(
App::ObjectIdentifier::String("ShapeType")));
paths.push_back(App::ObjectIdentifier(getContainer())
<< App::ObjectIdentifier::Component::SimpleComponent(getName())
<< App::ObjectIdentifier::Component::SimpleComponent(
App::ObjectIdentifier::String("Orientation")));
paths.push_back(App::ObjectIdentifier(getContainer())
<< App::ObjectIdentifier::Component::SimpleComponent(getName())
<< App::ObjectIdentifier::Component::SimpleComponent(
App::ObjectIdentifier::String("Length")));
paths.push_back(App::ObjectIdentifier(getContainer())
<< App::ObjectIdentifier::Component::SimpleComponent(getName())
<< App::ObjectIdentifier::Component::SimpleComponent(
App::ObjectIdentifier::String("Area")));
paths.push_back(App::ObjectIdentifier(getContainer())
<< App::ObjectIdentifier::Component::SimpleComponent(getName())
<< App::ObjectIdentifier::Component::SimpleComponent(
App::ObjectIdentifier::String("Volume")));
*/
}
void PropertyPostDataObject::Save(Base::Writer &writer) const
void PropertyPostDataObject::Save(Base::Writer& writer) const
{
std::string extension;
if (!m_dataObject)
if (!m_dataObject) {
return;
}
switch (m_dataObject->GetDataObjectType()) {
@@ -262,35 +266,35 @@ void PropertyPostDataObject::Save(Base::Writer &writer) const
extension = "vtu";
break;
case VTK_UNIFORM_GRID:
extension = "vti";//image data
extension = "vti"; // image data
break;
//TODO:multi-datasets use multiple files, this needs to be implemented specially
// case VTK_COMPOSITE_DATA_SET:
// prop->m_dataObject = vtkCompositeDataSet::New();
// break;
// case VTK_MULTIBLOCK_DATA_SET:
// prop->m_dataObject = vtkMultiBlockDataSet::New();
// break;
// case VTK_MULTIPIECE_DATA_SET:
// prop->m_dataObject = vtkMultiPieceDataSet::New();
// break;
// TODO:multi-datasets use multiple files, this needs to be implemented specially
// case VTK_COMPOSITE_DATA_SET:
// prop->m_dataObject = vtkCompositeDataSet::New();
// break;
// case VTK_MULTIBLOCK_DATA_SET:
// prop->m_dataObject = vtkMultiBlockDataSet::New();
// break;
// case VTK_MULTIPIECE_DATA_SET:
// prop->m_dataObject = vtkMultiPieceDataSet::New();
// break;
default:
break;
};
if (!writer.isForceXML()) {
std::string file = "Data." + extension;
writer.Stream() << writer.ind() << "<Data file=\""
<< writer.addFile(file.c_str(), this)
writer.Stream() << writer.ind() << "<Data file=\"" << writer.addFile(file.c_str(), this)
<< "\"/>" << std::endl;
}
}
void PropertyPostDataObject::Restore(Base::XMLReader &reader)
void PropertyPostDataObject::Restore(Base::XMLReader& reader)
{
reader.readElement("Data");
if (!reader.hasAttribute("file"))
if (!reader.hasAttribute("file")) {
return;
}
std::string file(reader.getAttribute("file"));
@@ -300,12 +304,13 @@ void PropertyPostDataObject::Restore(Base::XMLReader &reader)
}
}
void PropertyPostDataObject::SaveDocFile(Base::Writer &writer) const
void PropertyPostDataObject::SaveDocFile(Base::Writer& writer) const
{
// If the shape is empty we simply store nothing. The file size will be 0 which
// can be checked when reading in the data.
if (!m_dataObject)
if (!m_dataObject) {
return;
}
// create a temporary file and copy the content to the zip stream
// once the tmp. filename is known use always the same because otherwise
@@ -319,7 +324,7 @@ void PropertyPostDataObject::SaveDocFile(Base::Writer &writer) const
#ifdef VTK_CELL_ARRAY_V2
// Looks like an invalid data object that causes a crash with vtk9
vtkUnstructuredGrid *dataGrid = vtkUnstructuredGrid::SafeDownCast(m_dataObject);
vtkUnstructuredGrid* dataGrid = vtkUnstructuredGrid::SafeDownCast(m_dataObject);
if (dataGrid && (dataGrid->GetPiece() < 0 || dataGrid->GetNumberOfPoints() <= 0)) {
std::cerr << "PropertyPostDataObject::SaveDocFile: ignore empty vtkUnstructuredGrid\n";
return;
@@ -331,11 +336,12 @@ void PropertyPostDataObject::SaveDocFile(Base::Writer &writer) const
// not be created we should not abort.
// We only print an error message but continue writing the next files to the
// stream...
App::PropertyContainer *father = this->getContainer();
App::PropertyContainer* father = this->getContainer();
if (father && father->isDerivedFrom(App::DocumentObject::getClassTypeId())) {
App::DocumentObject *obj = static_cast<App::DocumentObject *>(father);
App::DocumentObject* obj = static_cast<App::DocumentObject*>(father);
Base::Console().Error("Dataset of '%s' cannot be written to vtk file '%s'\n",
obj->Label.getValue(), fi.filePath().c_str());
obj->Label.getValue(),
fi.filePath().c_str());
}
else {
Base::Console().Error("Cannot save vtk file '%s'\n", fi.filePath().c_str());
@@ -348,7 +354,7 @@ void PropertyPostDataObject::SaveDocFile(Base::Writer &writer) const
Base::ifstream file(fi, std::ios::in | std::ios::binary);
if (file) {
std::streambuf *buf = file.rdbuf();
std::streambuf* buf = file.rdbuf();
writer.Stream() << buf;
}
@@ -357,7 +363,7 @@ void PropertyPostDataObject::SaveDocFile(Base::Writer &writer) const
fi.deleteFile();
}
void PropertyPostDataObject::RestoreDocFile(Base::Reader &reader)
void PropertyPostDataObject::RestoreDocFile(Base::Reader& reader)
{
Base::FileInfo xml(reader.getFileName());
// create a temporary file and copy the content from the zip stream
@@ -367,7 +373,7 @@ void PropertyPostDataObject::RestoreDocFile(Base::Reader &reader)
Base::ofstream file(fi, std::ios::out | std::ios::binary);
unsigned long ulSize = 0;
if (reader) {
std::streambuf *buf = file.rdbuf();
std::streambuf* buf = file.rdbuf();
reader >> buf;
file.flush();
ulSize = buf->pubseekoff(0, std::ios::cur, std::ios::in);
@@ -381,16 +387,21 @@ void PropertyPostDataObject::RestoreDocFile(Base::Reader &reader)
// TODO: read in of composite data structures need to be coded,
// including replace of "GetOutputAsDataSet()"
vtkSmartPointer<vtkXMLReader> xmlReader;
if (extension == "vtp")
if (extension == "vtp") {
xmlReader = vtkSmartPointer<vtkXMLPolyDataReader>::New();
else if (extension == "vts")
}
else if (extension == "vts") {
xmlReader = vtkSmartPointer<vtkXMLStructuredGridReader>::New();
else if (extension == "vtr")
}
else if (extension == "vtr") {
xmlReader = vtkSmartPointer<vtkXMLRectilinearGridReader>::New();
else if (extension == "vtu")
}
else if (extension == "vtu") {
xmlReader = vtkSmartPointer<vtkXMLUnstructuredGridReader>::New();
else if (extension == "vti")
}
else if (extension == "vti") {
xmlReader = vtkSmartPointer<vtkXMLImageDataReader>::New();
}
xmlReader->SetFileName(fi.filePath().c_str());
xmlReader->Update();
@@ -400,11 +411,12 @@ void PropertyPostDataObject::RestoreDocFile(Base::Reader &reader)
// not be read it's NOT an indication for an invalid input stream 'reader'.
// We only print an error message but continue reading the next files from the
// stream...
App::PropertyContainer *father = this->getContainer();
App::PropertyContainer* father = this->getContainer();
if (father && father->isDerivedFrom(App::DocumentObject::getClassTypeId())) {
App::DocumentObject *obj = static_cast<App::DocumentObject *>(father);
App::DocumentObject* obj = static_cast<App::DocumentObject*>(father);
Base::Console().Error("Dataset file '%s' with data of '%s' seems to be empty\n",
fi.filePath().c_str(), obj->Label.getValue());
fi.filePath().c_str(),
obj->Label.getValue());
}
else {
Base::Console().Warning("Loaded Dataset file '%s' seems to be empty\n",

View File

@@ -36,7 +36,7 @@ namespace Fem
/** The vtk data set property class.
* @author Stefan Tröger
*/
class FemExport PropertyPostDataObject : public App::Property
class FemExport PropertyPostDataObject: public App::Property
{
TYPESYSTEM_HEADER_WITH_OVERRIDE();
@@ -55,30 +55,30 @@ public:
/// check if we hold a dataset or a dataobject (which would mean a composite data structure)
bool isDataSet();
bool isComposite();
int getDataType();
int getDataType();
//@}
/** @name Python interface */
//@{
PyObject* getPyObject() override;
void setPyObject(PyObject *value) override;
void setPyObject(PyObject* value) override;
//@}
/** @name Save/restore */
//@{
void Save (Base::Writer &writer) const override;
void Restore(Base::XMLReader &reader) override;
void Save(Base::Writer& writer) const override;
void Restore(Base::XMLReader& reader) override;
void SaveDocFile (Base::Writer &writer) const override;
void RestoreDocFile(Base::Reader &reader) override;
void SaveDocFile(Base::Writer& writer) const override;
void RestoreDocFile(Base::Reader& reader) override;
App::Property *Copy() const override;
void Paste(const App::Property &from) override;
unsigned int getMemSize () const override;
App::Property* Copy() const override;
void Paste(const App::Property& from) override;
unsigned int getMemSize() const override;
//@}
/// Get valid paths for this property; used by auto completer
void getPaths(std::vector<App::ObjectIdentifier> & paths) const override;
void getPaths(std::vector<App::ObjectIdentifier>& paths) const override;
private:
static void scaleDataObject(vtkDataObject*, double s);
@@ -88,7 +88,7 @@ protected:
vtkSmartPointer<vtkDataObject> m_dataObject;
};
} //namespace FEM
} // namespace Fem
#endif // FEM_PROPERTYPOSTDATASET_H
#endif // FEM_PROPERTYPOSTDATASET_H