FreeCAD C++
|
#include <Mod/Fem/App/FemConstraint.h>
Base class of all Constraint Objects of the Fem module.
Constraint isn't intended to be used directely. Actual Constraints used to specify a simulation are children of this class. The base class essentially does two things: Most importantely it has a property Constraint::References which is a list of all sub objects the constraint applys to. Defining it in the base class exposes a common interface to code using different constraints.
The second purpose of Constraint is to support the redering to the screen done by the View Provider FemGui::ViewProviderFemConstraint. The rendering is decoupled from the objects listed in the References property by using a point cloud a normal vector and a scale factor which is generated by this class. The View Provider doesn't know of the references it just asks Constraint for those values and renders a widget for each point scaled by the scale factor pointing in the direction of the normal vector. These values are exposed by the two properties NormalDirection and Scale and the protected method getPoints(points&, normals&, scale&).
Public Member Functions | |
virtual App::DocumentObjectExecReturn * | execute () |
Updates NormalDirection. More... | |
int | calcDrawScaleFactor (double lparam) const |
Calculates scale factor based on length of edge. More... | |
int | calcDrawScaleFactor (double lvparam, double luparam) const |
Calculates scale factor based on size of face. More... | |
int | calcDrawScaleFactor () const |
Returns default scale factor of 1. More... | |
![]() | |
DocumentObject (void) | |
Constructor. | |
const char * | getNameInDocument (void) const |
returns the name which is set in the document for this object (not the name property!) | |
App::Document * | getDocument (void) const |
gets the document in which this Object is handled | |
bool | testIfLinkDAGCompatible (DocumentObject *linkTo) const |
testIfLinkIsDAG tests a link that is about to be created for circular references. More... | |
virtual short | mustExecute (void) const |
bool | recomputeFeature () |
Recompute only this feature. | |
const char * | getStatusString (void) const |
get the status Message | |
virtual void | onLostLinkToObject (DocumentObject *) |
virtual std::vector< PyObject * > | getPySubObjects (const std::vector< std::string > &) const |
its used to get the python sub objects by name (e.g. by the selection) | |
void | touch (void) |
set this document object touched (cause recomputation on dependent features) More... | |
bool | isTouched (void) const |
test if this document object is touched | |
void | enforceRecompute () |
Enforce this document object to be recomputed. | |
bool | mustRecompute (void) const |
Test if this document object must be recomputed. | |
void | purgeTouched (void) |
reset this document object touched | |
bool | isError (void) const |
set this feature to error | |
void | purgeError (void) |
remove the error from the object | |
bool | isRecomputing () const |
returns true if this objects is currently recomputing | |
bool | isRestoring () const |
returns true if this objects is currently restoring from file | |
bool | isRemoving () const |
returns true if this objects is currently removed from the document | |
unsigned long | getStatus () const |
return the status bits | |
std::vector< App::DocumentObject * > | getOutList (void) const |
returns a list of objects this object is pointing to by Links More... | |
std::vector< App::DocumentObject * > | getOutListOfProperty (App::Property *) const |
returns a list of objects linked by the property | |
std::vector< App::DocumentObject * > | getOutListRecursive (void) const |
returns a list of objects this object is pointing to by Links and all further descended | |
std::vector< std::list< App::DocumentObject * > > | getPathsByOutList (App::DocumentObject *to) const |
get all possible paths from this to another object following the OutList | |
std::vector< App::DocumentObject * > | getInList (void) const |
get all objects link to this object | |
std::vector< App::DocumentObject * > | getInListRecursive (void) const |
get all objects link directly or indirectly to this object | |
DocumentObjectGroup * | getGroup () const |
get group if object is part of a group, otherwise 0 is returned | |
bool | isInInListRecursive (DocumentObject *objToTest) const |
test if this object is in the InList and recursive further down | |
bool | isInInList (DocumentObject *objToTest) const |
test if this object is directly (non recursive) in the InList | |
bool | isInOutListRecursive (DocumentObject *objToTest) const |
test if the given object is in the OutList and recursive further down | |
bool | isInOutList (DocumentObject *objToTest) const |
test if this object is directly (non recursive) in the OutList | |
void | _removeBackLink (DocumentObject *) |
internal, used by PropertyLink to maintain DAG back links | |
void | _addBackLink (DocumentObject *) |
internal, used by PropertyLink to maintain DAG back links | |
![]() | |
TransactionalObject (void) | |
Constructor. | |
![]() | |
virtual Property * | getPropertyByName (const char *name) const override |
find a property by its name | |
virtual const char * | getPropertyName (const Property *prop) const override |
get the name of a property | |
virtual void | getPropertyMap (std::map< std::string, Property * > &Map) const override |
get all properties of the class (including properties of the parent) | |
virtual void | getPropertyList (std::vector< Property * > &List) const override |
get all properties of the class (including properties of the parent) | |
virtual short | getPropertyType (const Property *prop) const override |
get the Type of a Property | |
virtual short | getPropertyType (const char *name) const override |
get the Type of a named Property | |
virtual const char * | getPropertyGroup (const Property *prop) const override |
get the Group of a Property | |
virtual const char * | getPropertyGroup (const char *name) const override |
get the Group of a named Property | |
virtual const char * | getPropertyDocumentation (const Property *prop) const override |
get the Group of a Property | |
virtual const char * | getPropertyDocumentation (const char *name) const override |
get the Group of a named Property | |
![]() | |
PropertyContainer () | |
virtual | ~PropertyContainer () |
void | setPropertyStatus (unsigned char bit, bool value) |
set the Status bit of all properties at once | |
bool | isReadOnly (const Property *prop) const |
check if the property is read-only | |
bool | isReadOnly (const char *name) const |
check if the named property is read-only | |
bool | isHidden (const Property *prop) const |
check if the property is hidden | |
bool | isHidden (const char *name) const |
check if the named property is hidden | |
![]() | |
virtual void | SaveDocFile (Writer &) const |
virtual void | RestoreDocFile (Reader &) |
![]() | |
BaseClass () | |
Construction. | |
virtual | ~BaseClass () |
Destruction. | |
Public Attributes | |
App::PropertyLinkSubList | References |
List of objects the constraints applies to. More... | |
App::PropertyVector | NormalDirection |
Vector pointing into the effective direction of the constraint. More... | |
App::PropertyInteger | Scale |
Supposed to reflect the size of the References. More... | |
Protected Member Functions | |
virtual void | onChanged (const App::Property *prop) |
Updates NormalDirection if References change. | |
virtual void | onDocumentRestored () |
Triggers onChanged to update View Provider. More... | |
bool | getPoints (std::vector< Base::Vector3d > &points, std::vector< Base::Vector3d > &normals, int *scale) const |
Returns data based on References relevant for rendering widgets. More... | |
bool | getCylinder (double &radius, double &height, Base::Vector3d &base, Base::Vector3d &axis) const |
Extract properties of cylindrical face. More... | |
Base::Vector3d | getBasePoint (const Base::Vector3d &base, const Base::Vector3d &axis, const App::PropertyLinkSub &location, const double &dist) |
Calculate point of cylidrical face where to render widget. More... | |
const Base::Vector3d | getDirection (const App::PropertyLinkSub &direction) |
Get normal vector of point calculated by getBasePoint. More... | |
![]() | |
virtual App::DocumentObjectExecReturn * | recompute (void) |
recompute only this object | |
virtual void | onBeforeChange (const Property *prop) |
get called before the value is changed | |
virtual void | onSettingDocument () |
get called after setting the document | |
virtual void | setupObject () |
get called after a brand new object was created | |
virtual void | unsetupObject () |
get called when object is going to be removed from the document | |
Additional Inherited Members | |
![]() | |
static std::string | encodeAttribute (const std::string &) |
Encodes an attribute upon saving. | |
![]() | |
std::bitset< 32 > | StatusBits |
Py::Object | PythonObject |
python object of this class and all descendent | |
App::Document * | _pDoc |
pointer to the document this object belongs to | |
std::string | oldLabel |
Old label; used for renaming expressions. | |
int Fem::Constraint::calcDrawScaleFactor | ( | double | lparam | ) | const |
Calculates scale factor based on length of edge.
Used to calculate the scale factor returned by getPoints when the scale factor is calculated for a face.
int Fem::Constraint::calcDrawScaleFactor | ( | double | lvparam, |
double | luparam | ||
) | const |
Calculates scale factor based on size of face.
Used to calculate the scale factor returned by getPoints when the scale factor is calculated for a edge.
int Fem::Constraint::calcDrawScaleFactor | ( | ) | const |
Returns default scale factor of 1.
This is just used to make code more understandable. Other versions (overloads) of this function do useful calculations based on faces or edges. Used by getPoints if no useful shape information is avaliable.
|
virtual |
Updates NormalDirection.
Updates NormalDirection using new References. It does so by calling onChanged once with the References property and once with the Scale property. The second call doesn't do anything.
Reimplemented from App::DocumentObject.
|
protected |
Calculate point of cylidrical face where to render widget.
|
protected |
Extract properties of cylindrical face.
|
protected |
Get normal vector of point calculated by getBasePoint.
|
protected |
Returns data based on References relevant for rendering widgets.
Extracts data from all objects inside References relevant for widget rendering by the View Provider. This includes the points at which widgets shall be drawn, a vector per point indicating the direction the widget should face and a global scale factor for all widgets. Two vectors of equal length are used to return the points and their normal vectors. The normal vector of points[i] can be found with the same index in normals[i].
[out] | points | For each vertex a point equal to the location of that vertix is pushed into the points vector. For each edge at least to points, the beginning and the end of the edge, are pushed into the vector. Depending on the length of the edge more points may be added in between. For each face a number of points depending on the size of the face and the step size calculated internally are pushed into the vector. |
[out] | normals | For vertexes and edges normal vectors equal to the NormalDirection are pushed onto the vector. For each point of a face a Base::Vector3d equal to the normal vector of the face at that position is added to the vector. |
[out] | scale | The scale contains a scale value for the object in References that was processed last. For calculation various versions of calcDrawScaleFactor are used. |
|
protectedvirtual |
Triggers onChanged to update View Provider.
Reimplemented from App::DocumentObject.
App::PropertyVector Fem::Constraint::NormalDirection |
Vector pointing into the effective direction of the constraint.
If References contains only one face of a shape than NormalDirection is the normal vector of that face. If more than one face is referenced that it is the normal vector of the first face. If References is empty or doesn't contain a face the value of NormalDirection is the Z-axis or its previous value.
App::PropertyLinkSubList Fem::Constraint::References |
List of objects the constraints applies to.
This is a list of subobjects (e.g. Faces, Edges, ...) the constraint applies to. It's only supposed to contain objects of or derived from Part::Feature. Altering this property triggers a update of NormalDirection and Scale.
App::PropertyInteger Fem::Constraint::Scale |
Supposed to reflect the size of the References.
This property should be a scale factor for the widgets rendered by the View Provider but it's always 1. It isn't updated when References changes.