Fem: Move Points and Normals properties to base class

This commit is contained in:
marioalexis
2024-02-13 19:55:46 -03:00
committed by Chris Hennes
parent a489b095f0
commit c49c52716c
26 changed files with 31 additions and 332 deletions

View File

@@ -91,6 +91,19 @@ Constraint::Constraint()
App::PropertyType(App::Prop_Output),
"Scale used for drawing constraints"); // OvG: Add scale parameter inherited
// by all derived constraints
ADD_PROPERTY_TYPE(Points,
(Base::Vector3d()),
"Constraint",
App::PropertyType(App::Prop_ReadOnly | App::Prop_Output | App::Prop_Hidden),
"Points where symbols are drawn");
ADD_PROPERTY_TYPE(Normals,
(Base::Vector3d()),
"Constraint",
App::PropertyType(App::Prop_ReadOnly | App::Prop_Output | App::Prop_Hidden),
"Normals where symbols are drawn");
Points.setValues(std::vector<Base::Vector3d>());
Normals.setValues(std::vector<Base::Vector3d>());
References.setScope(App::LinkScope::Global);
}
@@ -165,6 +178,16 @@ void Constraint::onChanged(const App::Property* prop)
}
}
}
std::vector<Base::Vector3d> points;
std::vector<Base::Vector3d> normals;
int scale = 1;
if (getPoints(points, normals, &scale)) {
Points.setValues(points);
Normals.setValues(normals);
Scale.setValue(scale);
Points.touch();
}
}
App::DocumentObject::onChanged(prop);

View File

@@ -102,6 +102,10 @@ public:
*/
App::PropertyInteger Scale;
// Read-only (calculated values). These trigger changes in the ViewProvider
App::PropertyVectorList Points;
App::PropertyVectorList Normals;
/**
* @brief Updates @ref NormalDirection.
*

View File

@@ -58,20 +58,6 @@ ConstraintContact::ConstraintContact()
"ConstraintContact",
App::PropertyType(App::Prop_None),
"Stick slope");
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");
/* */
Points.setValues(std::vector<Base::Vector3d>());
Normals.setValues(std::vector<Base::Vector3d>());
}
App::DocumentObjectExecReturn* ConstraintContact::execute()
@@ -87,18 +73,6 @@ const char* ConstraintContact::getViewProviderName() const
void ConstraintContact::onChanged(const App::Property* prop)
{
Constraint::onChanged(prop);
if (prop == &References) {
std::vector<Base::Vector3d> points;
std::vector<Base::Vector3d> normals;
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()
}
}
}
void ConstraintContact::handleChangedPropertyType(Base::XMLReader& reader,

View File

@@ -38,10 +38,6 @@ public:
/// Constructor
ConstraintContact();
// Read-only (calculated values). These trigger changes in the ViewProvider
App::PropertyVectorList Points;
App::PropertyVectorList Normals;
/*Note*/
// Constraint parameters
/******

View File

@@ -78,20 +78,6 @@ ConstraintDisplacement::ConstraintDisplacement()
ADD_PROPERTY(rotzFix, (false));
ADD_PROPERTY(rotzFree, (true));
ADD_PROPERTY(zRotation, (0.0));
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");
Points.setValues(std::vector<Base::Vector3d>());
Normals.setValues(std::vector<Base::Vector3d>());
}
App::DocumentObjectExecReturn* ConstraintDisplacement::execute()
@@ -148,19 +134,5 @@ void ConstraintDisplacement::handleChangedPropertyType(Base::XMLReader& reader,
void ConstraintDisplacement::onChanged(const App::Property* prop)
{
// Note: If we call this at the end, then the arrows are not oriented correctly initially
// because the NormalDirection has not been calculated yet
Constraint::onChanged(prop);
if (prop == &References) {
std::vector<Base::Vector3d> points;
std::vector<Base::Vector3d> normals;
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()
}
}
}

View File

@@ -40,10 +40,6 @@ public:
/// Constructor
ConstraintDisplacement();
// Read-only (calculated values). These trigger changes in the ViewProvider
App::PropertyVectorList Points;
App::PropertyVectorList Normals;
// Displacement parameters
App::PropertyDistance xDisplacement;
App::PropertyDistance yDisplacement;

View File

@@ -31,20 +31,7 @@ using namespace Fem;
PROPERTY_SOURCE(Fem::ConstraintFixed, Fem::Constraint)
ConstraintFixed::ConstraintFixed()
{
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");
Points.setValues(std::vector<Base::Vector3d>());
Normals.setValues(std::vector<Base::Vector3d>());
}
{}
App::DocumentObjectExecReturn* ConstraintFixed::execute()
{
@@ -53,19 +40,5 @@ App::DocumentObjectExecReturn* ConstraintFixed::execute()
void ConstraintFixed::onChanged(const App::Property* prop)
{
// Note: If we call this at the end, then the symbols are not oriented correctly initially
// because the NormalDirection has not been calculated yet
Constraint::onChanged(prop);
if (prop == &References) {
std::vector<Base::Vector3d> points;
std::vector<Base::Vector3d> normals;
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()
}
}
}

View File

@@ -38,10 +38,6 @@ public:
/// Constructor
ConstraintFixed();
// Read-only (calculated values). These trigger changes in the ViewProvider
App::PropertyVectorList Points;
App::PropertyVectorList Normals;
/// recalculate the object
App::DocumentObjectExecReturn* execute() override;

View File

@@ -96,17 +96,9 @@ ConstraintFluidBoundary::ConstraintFluidBoundary()
"Heat flux value for thermal boundary condition");
ADD_PROPERTY_TYPE(HTCoeffValue,(0.0),"HeatTransfer",(App::PropertyType)(App::Prop_None),
"Heat transfer coefficient for convective boundary condition");
/// geometry rendering related properties
ADD_PROPERTY_TYPE(Points,(Base::Vector3d()),"FluidBoundary",App::PropertyType(App::Prop_ReadOnly|App::Prop_Output),
"Points where arrows are drawn");
Points.setValues(std::vector<Base::Vector3d>());
ADD_PROPERTY_TYPE(DirectionVector,(Base::Vector3d(0,0,1)),"FluidBoundary",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
// property from: FemConstraintFixed object
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
}
@@ -147,19 +139,6 @@ void ConstraintFluidBoundary::onChanged(const App::Property* prop)
Subtype.setValue(1);
// need to trigger ViewProvider::updateData() for redraw in 3D view after this method
}
// 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
if (getPoints(points, normals, &scale)) {
Points.setValues(points);
Normals.setValues(normals);
Scale.setValue(scale); // OvG: Scale
Points.touch(); // This triggers ViewProvider::updateData()
}
}
else if (prop == &Direction) {
Base::Vector3d direction = getDirection(Direction);
// if Direct has no link provided return Base::Vector3d(0,0,0);

View File

@@ -54,8 +54,6 @@ 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::PropertyVector DirectionVector;
/// recalculate the object

View File

@@ -46,11 +46,6 @@ ConstraintForce::ConstraintForce()
Direction.setScope(App::LinkScope::Global);
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",
@@ -59,7 +54,6 @@ ConstraintForce::ConstraintForce()
// by default use the null vector to indicate an invalid value
naturalDirectionVector = Base::Vector3d(0, 0, 0);
Points.setValues(std::vector<Base::Vector3d>());
}
App::DocumentObjectExecReturn* ConstraintForce::execute()
@@ -91,19 +85,7 @@ void ConstraintForce::onChanged(const App::Property* prop)
// because the NormalDirection has not been calculated yet
Constraint::onChanged(prop);
if (prop == &References) {
std::vector<Base::Vector3d> points;
std::vector<Base::Vector3d> normals;
int scale = 1; // OvG: Enforce use of scale
if (getPoints(points, normals, &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) {
if (prop == &Direction) {
Base::Vector3d direction = getDirection(Direction);
if (direction.Length() < Precision::Confusion()) {
return;

View File

@@ -41,8 +41,6 @@ public:
App::PropertyForce Force;
App::PropertyLinkSub Direction;
App::PropertyBool Reversed;
// Read-only (calculated values). These trigger changes in the ViewProvider
App::PropertyVectorList Points;
App::PropertyVector DirectionVector;
/// recalculate the object

View File

@@ -45,19 +45,6 @@ ConstraintHeatflux::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),
"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");
Points.setValues(std::vector<Base::Vector3d>());
Normals.setValues(std::vector<Base::Vector3d>());
}
App::DocumentObjectExecReturn* ConstraintHeatflux::execute()
@@ -72,19 +59,5 @@ const char* ConstraintHeatflux::getViewProviderName() const
void ConstraintHeatflux::onChanged(const App::Property* prop)
{
// Note: If we call this at the end, then the arrows are not oriented correctly initially
// because the NormalDirection has not been calculated yet
Constraint::onChanged(prop);
if (prop == &References) {
std::vector<Base::Vector3d> points;
std::vector<Base::Vector3d> normals;
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()
}
}
}

View File

@@ -45,9 +45,6 @@ public:
App::PropertyFloat DFlux;
App::PropertyEnumeration ConstraintType;
App::PropertyVectorList Points;
App::PropertyVectorList Normals;
/// recalculate the object
App::DocumentObjectExecReturn* execute() override;

View File

@@ -36,19 +36,6 @@ ConstraintInitialTemperature::ConstraintInitialTemperature()
{
ADD_PROPERTY(initialTemperature, (300.0));
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()),
"ConstraintInitialTemperature",
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>());
References.setStatus(App::Property::ReadOnly, true);
References.setStatus(App::Property::Hidden, true);
}
@@ -81,19 +68,5 @@ void ConstraintInitialTemperature::handleChangedPropertyType(Base::XMLReader& re
void ConstraintInitialTemperature::onChanged(const App::Property* prop)
{
// Note: If we call this at the end, then the arrows are not oriented correctly initially
// because the NormalDirection has not been calculated yet
Constraint::onChanged(prop);
if (prop == &References) {
std::vector<Base::Vector3d> points;
std::vector<Base::Vector3d> normals;
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()
}
}
}

View File

@@ -40,10 +40,6 @@ public:
/// Constructor
ConstraintInitialTemperature();
// Read-only (calculated values). These trigger changes in the ViewProvider
App::PropertyVectorList Points;
App::PropertyVectorList Normals;
// Temperature parameters
App::PropertyTemperature initialTemperature;

View File

@@ -31,21 +31,7 @@ using namespace Fem;
PROPERTY_SOURCE(Fem::ConstraintPlaneRotation, Fem::Constraint)
ConstraintPlaneRotation::ConstraintPlaneRotation()
{
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");
Points.setValues(std::vector<Base::Vector3d>());
Normals.setValues(std::vector<Base::Vector3d>());
}
{}
App::DocumentObjectExecReturn* ConstraintPlaneRotation::execute()
{
@@ -60,16 +46,4 @@ const char* ConstraintPlaneRotation::getViewProviderName() const
void ConstraintPlaneRotation::onChanged(const App::Property* prop)
{
Constraint::onChanged(prop);
if (prop == &References) {
std::vector<Base::Vector3d> points;
std::vector<Base::Vector3d> normals;
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()
}
}
}

View File

@@ -38,11 +38,6 @@ public:
/// Constructor
ConstraintPlaneRotation();
// Read-only (calculated values). These trigger changes in the ViewProvider
App::PropertyVectorList Points;
App::PropertyVectorList Normals;
/// recalculate the object
App::DocumentObjectExecReturn* execute() override;

View File

@@ -34,18 +34,6 @@ 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");
Points.setValues(std::vector<Base::Vector3d>());
Normals.setValues(std::vector<Base::Vector3d>());
}
App::DocumentObjectExecReturn* ConstraintPressure::execute()
@@ -80,18 +68,7 @@ void ConstraintPressure::onChanged(const App::Property* prop)
{
Constraint::onChanged(prop);
if (prop == &References) {
std::vector<Base::Vector3d> points;
std::vector<Base::Vector3d> normals;
int scale = Scale.getValue();
if (getPoints(points, normals, &scale)) {
Points.setValues(points);
Normals.setValues(normals);
Scale.setValue(scale);
Points.touch();
}
}
else if (prop == &Reversed) {
if (prop == &Reversed) {
Points.touch();
}
}

View File

@@ -39,8 +39,6 @@ public:
App::PropertyPressure Pressure;
App::PropertyBool Reversed;
App::PropertyVectorList Points;
App::PropertyVectorList Normals;
/// recalculate the object
App::DocumentObjectExecReturn* execute() override;

View File

@@ -37,20 +37,8 @@ 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");
ElmerStiffness.setEnums(Stiffnesses);
Points.setValues(std::vector<Base::Vector3d>());
Normals.setValues(std::vector<Base::Vector3d>());
}
App::DocumentObjectExecReturn* ConstraintSpring::execute()
@@ -66,16 +54,4 @@ const char* ConstraintSpring::getViewProviderName() const
void ConstraintSpring::onChanged(const App::Property* prop)
{
Constraint::onChanged(prop);
if (prop == &References) {
std::vector<Base::Vector3d> points;
std::vector<Base::Vector3d> normals;
int scale = Scale.getValue();
if (getPoints(points, normals, &scale)) {
Points.setValues(points);
Normals.setValues(normals);
Scale.setValue(scale);
Points.touch();
}
}
}

View File

@@ -40,8 +40,6 @@ public:
App::PropertyStiffness NormalStiffness;
App::PropertyStiffness TangentialStiffness;
App::PropertyEnumeration ElmerStiffness;
App::PropertyVectorList Points;
App::PropertyVectorList Normals;
/// recalculate the object
App::DocumentObjectExecReturn* execute() override;

View File

@@ -44,19 +44,6 @@ ConstraintTemperature::ConstraintTemperature()
(App::PropertyType)(App::Prop_None),
"Type of constraint, temperature or concentrated heat flux");
ConstraintType.setEnums(ConstraintTypes);
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",
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()
@@ -93,19 +80,5 @@ void ConstraintTemperature::handleChangedPropertyType(Base::XMLReader& reader,
void ConstraintTemperature::onChanged(const App::Property* prop)
{
// Note: If we call this at the end, then the arrows are not oriented correctly initially
// because the NormalDirection has not been calculated yet
Constraint::onChanged(prop);
if (prop == &References) {
std::vector<Base::Vector3d> points;
std::vector<Base::Vector3d> normals;
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()
}
}
}

View File

@@ -40,10 +40,6 @@ public:
/// Constructor
ConstraintTemperature();
// Read-only (calculated values). These trigger changes in the ViewProvider
App::PropertyVectorList Points;
App::PropertyVectorList Normals;
// Temperature parameters
App::PropertyTemperature Temperature;
App::PropertyPower CFlux;

View File

@@ -66,18 +66,6 @@ ConstraintTransform::ConstraintTransform()
"ConstraintTransform",
App::PropertyType(App::Prop_ReadOnly | App::Prop_Output),
"Axis of cylindrical surface");
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",
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()
@@ -124,10 +112,6 @@ void ConstraintTransform::onChanged(const App::Property* prop)
std::vector<Base::Vector3d> normals;
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()
std::string transform_type = TransformType.getValueAsString();
if (transform_type == "Cylindrical") {
// Find data of cylinder

View File

@@ -40,8 +40,6 @@ public:
// Read-only (calculated values). These trigger changes in the ViewProvider
App::PropertyLinkSubList RefDispl;
App::PropertyLinkList NameDispl;
App::PropertyVectorList Points;
App::PropertyVectorList Normals;
App::PropertyVector BasePoint;
App::PropertyVector Axis;
App::PropertyAngle X_rot;