| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| |
|
| |
|
| | #include <Precision.hxx> |
| |
|
| |
|
| | #include "FemConstraintForce.h" |
| |
|
| |
|
| | using namespace Fem; |
| |
|
| | PROPERTY_SOURCE(Fem::ConstraintForce, Fem::Constraint) |
| |
|
| | ConstraintForce::ConstraintForce() |
| | { |
| | ADD_PROPERTY(Force, (0.0)); |
| | ADD_PROPERTY_TYPE( |
| | Direction, |
| | (nullptr), |
| | "ConstraintForce", |
| | (App::PropertyType)(App::Prop_None), |
| | "Element giving direction of constraint" |
| | ); |
| | |
| | Direction.setScope(App::LinkScope::Global); |
| |
|
| | ADD_PROPERTY(Reversed, (0)); |
| | 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); |
| | ADD_PROPERTY_TYPE( |
| | EnableAmplitude, |
| | (false), |
| | "ConstraintForce", |
| | (App::PropertyType)(App::Prop_None), |
| | "Amplitude of the force load" |
| | ); |
| | ADD_PROPERTY_TYPE( |
| | AmplitudeValues, |
| | (std::vector<std::string> {"0, 0", "1, 1"}), |
| | "ConstraintForce", |
| | (App::PropertyType)(App::Prop_None), |
| | "Amplitude values" |
| | ); |
| | } |
| |
|
| | App::DocumentObjectExecReturn* ConstraintForce::execute() |
| | { |
| | return Constraint::execute(); |
| | } |
| |
|
| | void ConstraintForce::handleChangedPropertyType( |
| | Base::XMLReader& reader, |
| | const char* TypeName, |
| | App::Property* prop |
| | ) |
| | { |
| | |
| | if (prop == &Force && strcmp(TypeName, "App::PropertyFloat") == 0) { |
| | App::PropertyFloat ForceProperty; |
| | |
| | ForceProperty.Restore(reader); |
| | |
| | |
| | Force.setValue(ForceProperty.getValue() * 1000); |
| | } |
| | else { |
| | Constraint::handleChangedPropertyType(reader, TypeName, prop); |
| | } |
| | } |
| |
|
| | void ConstraintForce::onChanged(const App::Property* prop) |
| | { |
| | |
| | |
| | Constraint::onChanged(prop); |
| |
|
| | if (prop == &Direction) { |
| | Base::Vector3d direction = getDirection(Direction); |
| | if (direction.Length() < Precision::Confusion()) { |
| | return; |
| | } |
| | naturalDirectionVector = direction; |
| | if (Reversed.getValue()) { |
| | direction = -direction; |
| | } |
| | DirectionVector.setValue(direction); |
| | } |
| | else if (prop == &Reversed) { |
| | |
| | if (naturalDirectionVector.Length() < Precision::Confusion()) { |
| | naturalDirectionVector = getDirection(Direction); |
| | } |
| | if (naturalDirectionVector.Length() >= Precision::Confusion()) { |
| | if (Reversed.getValue() && (DirectionVector.getValue() == naturalDirectionVector)) { |
| | DirectionVector.setValue(-naturalDirectionVector); |
| | } |
| | else if (!Reversed.getValue() && (DirectionVector.getValue() != naturalDirectionVector)) { |
| | DirectionVector.setValue(naturalDirectionVector); |
| | } |
| | } |
| | } |
| | else if (prop == &NormalDirection) { |
| | |
| | if (!Direction.getValue()) { |
| | Base::Vector3d direction = NormalDirection.getValue(); |
| | if (Reversed.getValue()) { |
| | direction = -direction; |
| | } |
| | DirectionVector.setValue(direction); |
| | naturalDirectionVector = direction; |
| | } |
| | } |
| | } |
| |
|