Element mapper returning a particular element state as its value 2015-07-10:DGT: Class is extended to be able to return a data object. This was driven by the existence of vector states on volume (hexahedral) elements.
#include <Mesh/DataStructures/elementstatemapper.h>
|
| ElementStateMapper () |
|
| ElementStateMapper (const ElementStateMapper &mapper) |
|
| ~ElementStateMapper () override |
|
bool | canSerialize () const override |
|
ElementStateMapper * | clone () const override |
|
Application::Memento::Data * | createMementoData (const MeshModelInterface &model, const ElementType::List &supportedElementTypes={ &ElementType::Tri::getInstance(), &ElementType::Quad::getInstance(), &ElementType::Tetrahedron::getInstance(), &ElementType::Hexahedron::getInstance() }) const override |
|
const QString & | getStateName () const |
|
double | getValue (const ElementType::Type &elementType, const ElementHandle &element, Application::Memento::Data &mementoData) const override |
|
bool | getValueDataObject (const ElementType::Type &elementType, const ElementHandle &element, Application::Memento::Data &mementoData, DataExecution::DataObject *returnValue) const override |
|
VectorMapping | getVectorMapping () const |
|
bool | load (const DataExecution::SerializedItem &item) override |
|
ElementStateMapper & | operator= (const ElementStateMapper &mapper) |
|
bool | save (DataExecution::SerializedItem &item) const override |
|
void | setStateName (const QString &name) |
|
void | setVectorMapping (VectorMapping mapping) |
|
bool | canSerialize () const override |
|
ElementMapper * | clone () const override=0 |
|
virtual Application::Memento::Data * | createMementoData (const MeshModelInterface &model, const ElementType::List &supportedElementTypes={&ElementType::Tri::getInstance(), &ElementType::Quad::getInstance(), &ElementType::Tetrahedron::getInstance(), &ElementType::Hexahedron::getInstance()}) const =0 |
|
virtual double | getValue (const ElementType::Type &elementType, const ElementHandle &element, Application::Memento::Data &mementoData) const =0 |
|
virtual bool | getValueDataObject (const ElementType::Type &, const ElementHandle &, Application::Memento::Data &, DataExecution::DataObject *) const |
|
bool | load (const DataExecution::SerializedItem &item) override |
|
void | logText (const QString &msg) const |
|
bool | save (DataExecution::SerializedItem &item) const override |
|
virtual | ~Clonable ()=default |
|
virtual Clonable * | clone () const =0 |
|
virtual | ~Serialize ()=default |
|
virtual bool | canSerialize () const =0 |
|
virtual bool | load (const SerializedItem &item)=0 |
|
virtual bool | save (SerializedItem &item) const =0 |
|
◆ ElementStateMapper() [1/2]
The mapper is constructed with no state name set. The vector mapping defaults to mapping the vector magnitude.
- See also
- setStateName()
◆ ElementStateMapper() [2/2]
◆ ~ElementStateMapper()
◆ canSerialize()
bool canSerialize |
( |
| ) |
const |
|
overridevirtual |
- Returns
- True if this object can be serialized.
For objects that can be serialized, the save and load functions will be used to do the serialization. If this function returns false, both load() and save() must also return false.
Reimplemented from ElementMapper.
◆ clone()
- Returns
- A clone of this object.
- Note
- Subclasses would normally return their own type rather than the Clonable type. The C++ language rules allow a more derived type to be returned from a virtual function and the compiler will still treat it as a valid override.
Implements ElementMapper.
◆ createMementoData()
- Parameters
-
model | The model that will be used for mapping elements to values. |
supportedElementTypes | Element types supported for this operation |
- Returns
- A memento object which client code cannot do anything useful with except pass it around. The memento is ultimately only useful to the getValue() function. It holds internal data the mapper will use to perform the required mapping.
- Note
- The memento can be considered valid for as long as model is not modified and the state name of the mapper remains the same. As soon as the state name or anything in model is changed, the caller should obtain a new memento.
Implements ElementMapper.
◆ getStateName()
const QString & getStateName |
( |
| ) |
const |
- Returns
- The name of the state to map to a value.
- See also
- setStateName()
◆ getValue()
- Parameters
-
elementType | The type of element |
element | The element whose state should be mapped to a value. |
mementoData | The data from the memento created by a previous call to createMementoData(). It is used internally by this function to work out what value needs to be returned. |
- Returns
- The value of the requested state from this element. If mementoData is invalid, which can happen if the requested element state is not in the model passed to createMementoData(), then this function returns 0.
Implements ElementMapper.
◆ getValueDataObject()
◆ getVectorMapping()
- Returns
- The way vector states should be interpreted if the named state is a vector.
- See also
- setVectorMapping()
◆ load()
- Parameters
-
item | Supplies the state to be loaded into this object. |
This function will load the state of this object from item. For many object types, this is most easily implemented in terms of the object's input operator (>>).
It would be reasonable for subclass implementations to assume that the data provided in item is in the same form as would have been saved from a call to save.
- Returns
- If the state of the object could not be loaded, the function returns false. A return value of true implies that the object state was successfully loaded. If canSerialize() returns false, this function must do nothing except return false as well.
Reimplemented from ElementMapper.
◆ operator=()
◆ save()
- Parameters
-
item | Where to save the state of this object. |
This function will serialise the object by saving it to item. For most object types, this is most easily implemented in terms of the object's output operator (<<).
It is allowable for an object to only serialize part of itself. This would be useful if the data it represents has a set of defaults and only those values different to the defaults need to be serialized. Such an implementation then needs to be careful how it handles the complimentary load member function.
- Returns
- If an object could not be serialised or if the underlying object type does not support serialisation, this function should return false. A return value of true implies that the object was successfully saved to item. If canSerialize() returns false, this function must do nothing except return false as well.
Reimplemented from ElementMapper.
◆ setStateName()
void setStateName |
( |
const QString & |
name | ) |
|
- Parameters
-
name | The name of the state to be mapped to a value. The state can be any of the supported state types. Scalar doubles and integers are both returned directly. Values for vector states are returned according to the current setting returned by getVectorMapping(). As special cases, the element ID can be requested with the state name "id" and the component of the element can be requested with the state name "compId". |
- See also
- getStateName(), setVectorMapping()
◆ setVectorMapping()
- Parameters
-
mapping | When the named state is a vector, mapping defines how to interpret that vector and map it into a single value. |
- See also
- getVectorMapping()