SOFA API  3ea83cbd
Open source framework for multi-physics simuation
sofa::core::topology::TopologySubsetIndices Class Reference

#include <TopologySubsetIndices.h>

A class for storing point indices. Automatically manages topological changes on Point. More...

Inheritance diagram for sofa::core::topology::TopologySubsetIndices:

Detailed Description

A class for storing point indices. Automatically manages topological changes on Point.

This class is a TopologySubsetData templated on PointData and wrapping a type::vector <Index>. The type::vector <Index> works as a map storing the global indices of the Point this subset is applied on. For example a TopologySubsetIndices of size N can be used in a FixConstraint to store the N fixed points. If the points are removed this subset will follow the changes and remove the constraints.

Public Member Functions

 TopologySubsetIndices (const typename sofa::core::topology::BaseTopologyData< type::vector< Index > >::InitData &data)
 Default Constructor to init Data. More...
 
Index indexOfElement (Index index) const override
 
void createTopologyHandler (sofa::core::topology::BaseMeshTopology *_topology) override
 Function to create topology handler to manage this Data. More...
 
Index getLastElementIndex () const override
 Return the last element index of the topolgy buffer this Data is linked to. More...
 
- Public Member Functions inherited from sofa::core::topology::TopologySubsetData< core::topology::BaseMeshTopology::Point, type::vector< Index > >
 TopologySubsetData (const typename sofa::core::topology::BaseTopologyData< type::vector< Index > >::InitData &data)
 Default Constructor to init Data. More...
 
void setMap2Elements (const sofa::type::vector< Index > _map2Elements)
 Method to set a vector map to rull this subsetData. Will set. More...
 
sofa::type::vector< Index > & getMap2Elements ()
 Getter of the vector map indices. More...
 
void supportNewTopologyElements (bool value)
 
bool isNewTopologyElementsSupported () const
 Getter to the option. More...
 
void swap (Index i1, Index i2) override
 Swaps values of this subsetmap at indices i1 and i2. (only if i1 and i2 < subset size()) More...
 
virtual void add (sofa::Size nbElements, const sofa::type::vector< sofa::type::vector< Index > > &ancestors, const sofa::type::vector< sofa::type::vector< SReal > > &coefs)
 
virtual void add (sofa::Size nbElements, const sofa::type::vector< core::topology::BaseMeshTopology::Point > &elems, const sofa::type::vector< sofa::type::vector< Index > > &ancestors, const sofa::type::vector< sofa::type::vector< SReal > > &coefs)
 
void add (const sofa::type::vector< Index > &index, const sofa::type::vector< core::topology::BaseMeshTopology::Point > &elems, const sofa::type::vector< sofa::type::vector< Index > > &ancestors, const sofa::type::vector< sofa::type::vector< SReal > > &coefs, const sofa::type::vector< AncestorElem > &ancestorElems) override
 
void remove (const sofa::type::vector< Index > &index) override
 Remove the data using a set of indices. Will remove only the data contains by this subset. More...
 
void renumber (const sofa::type::vector< Index > &index) override
 Reorder the values. TODO epernod 2021-05-24: check if needed and implement it if needed. More...
 
void move (const sofa::type::vector< Index > &indexList, const sofa::type::vector< sofa::type::vector< Index > > &ancestors, const sofa::type::vector< sofa::type::vector< SReal > > &coefs) override
 Move a list of points. TODO epernod 2021-05-24: check if needed and implement it if needed. More...
 
void addOnMovedPosition (const sofa::type::vector< Index > &indexList, const sofa::type::vector< core::topology::BaseMeshTopology::Point > &elems) override
 
void removeOnMovedPosition (const sofa::type::vector< Index > &indices) override
 
- Public Member Functions inherited from sofa::core::topology::TopologyData< ElementType, VecT >
 TopologyData (const typename sofa::core::topology::BaseTopologyData< VecT >::InitData &data)
 Constructor. More...
 
 ~TopologyData ()
 Default Destructor. More...
 
void linkToPointDataArray ()
 Link Data to topology arrays. More...
 
void linkToEdgeDataArray ()
 Method used to link Data to edge Data array, using the TopologyHandler's method. More...
 
void linkToTriangleDataArray ()
 Method used to link Data to triangle Data array, using the TopologyHandler's method. More...
 
void linkToQuadDataArray ()
 Method used to link Data to quad Data array, using the TopologyHandler's method. More...
 
void linkToTetrahedronDataArray ()
 Method used to link Data to tetrahedron Data array, using the TopologyHandler's method. More...
 
void linkToHexahedronDataArray ()
 Method used to link Data to hexahedron Data array, using the TopologyHandler's method. More...
 
void swap (Index i1, Index i2) override
 Swaps values at indices i1 and i2. More...
 
void remove (const sofa::type::vector< Index > &index) override
 Remove the values corresponding to the elements removed. More...
 
void renumber (const sofa::type::vector< Index > &index) override
 Reorder the values. More...
 
void move (const sofa::type::vector< Index > &indexList, const sofa::type::vector< sofa::type::vector< Index > > &ancestors, const sofa::type::vector< sofa::type::vector< SReal > > &coefs) override
 Move a list of points. More...
 
void setDestructionCallback (std::function< void(Index, value_type &)> func)
 
void setCreationCallback (std::function< void(Index, value_type &, const ElementType &, const sofa::type::vector< Index > &, const sofa::type::vector< SReal > &)> func)
 
void addTopologyEventCallBack (core::topology::TopologyChangeType type, TopologyChangeCallback callback)
 Method to add a Callback method to be registered in the TopologyHandler. This callback will be used when TopologyChangeType. More...
 
- Public Member Functions inherited from sofa::core::topology::BaseTopologyData< VecT >
 BaseTopologyData (const sofa::core::objectmodel::BaseData::BaseInitData &init)
 
virtual void add (const sofa::type::vector< Topology::PointID > &, const sofa::type::vector< Topology::Point > &, const sofa::type::vector< sofa::type::vector< Topology::PointID > > &, const sofa::type::vector< sofa::type::vector< SReal > > &, const sofa::type::vector< PointAncestorElem > &)
 Add some values. Values are added at the end of the vector. More...
 
virtual void add (const sofa::type::vector< Topology::EdgeID > &, const sofa::type::vector< Topology::Edge > &, const sofa::type::vector< sofa::type::vector< Topology::EdgeID > > &, const sofa::type::vector< sofa::type::vector< SReal > > &, const sofa::type::vector< EdgeAncestorElem > &)
 
virtual void add (const sofa::type::vector< Topology::TriangleID > &, const sofa::type::vector< Topology::Triangle > &, const sofa::type::vector< sofa::type::vector< Topology::TriangleID > > &, const sofa::type::vector< sofa::type::vector< SReal > > &, const sofa::type::vector< TriangleAncestorElem > &)
 add Triangle More...
 
virtual void add (const sofa::type::vector< Topology::TetrahedronID > &, const sofa::type::vector< Topology::Tetrahedron > &, const sofa::type::vector< sofa::type::vector< Topology::TetrahedronID > > &, const sofa::type::vector< sofa::type::vector< SReal > > &, const sofa::type::vector< TetrahedronAncestorElem > &)
 add Quad & Tetrahedron More...
 
virtual void add (const sofa::type::vector< Topology::QuadID > &, const sofa::type::vector< Topology::Quad > &, const sofa::type::vector< sofa::type::vector< Topology::QuadID > > &, const sofa::type::vector< sofa::type::vector< SReal > > &, const sofa::type::vector< QuadAncestorElem > &)
 
virtual void add (const sofa::type::vector< Topology::HexahedronID > &, const sofa::type::vector< Topology::Hexahedron > &, const sofa::type::vector< sofa::type::vector< Topology::HexahedronID > > &, const sofa::type::vector< sofa::type::vector< SReal > > &, const sofa::type::vector< HexahedronAncestorElem > &)
 add Hexahedron More...
 
virtual void remove (const sofa::type::vector< unsigned int > &)
 Remove the values corresponding to the points removed. More...
 
virtual void swap (unsigned int, unsigned int)
 Swaps values at indices i1 and i2. More...
 
virtual void renumber (const sofa::type::vector< unsigned int > &)
 Reorder the values. More...
 
virtual void move (const sofa::type::vector< unsigned int > &, const sofa::type::vector< sofa::type::vector< unsigned int > > &, const sofa::type::vector< sofa::type::vector< SReal > > &)
 Move a list of points. More...
 
sofa::core::topology::BaseMeshTopologygetTopology ()
 
void setDataSetArraySize (const Index s)
 to handle PointSubsetData More...
 
- Public Member Functions inherited from sofa::core::objectmodel::Data< T >
const sofa::defaulttype::AbstractTypeInfogetValueTypeInfo () const override
 Get info about the value type of the associated variable. More...
 
bool read (const std::string &s) override
 
void printValue (std::ostream &out) const override
 General case for printing default value. More...
 
std::string getValueString () const override
 General case for printing value. More...
 
std::string getDefaultValueString () const override
 General case for printing default value. More...
 
std::string getValueTypeString () const override
 Get the name of the type of the value held in this Data. More...
 
void operator= (const T &value)
 
bool copyValueFrom (const Data< T > *data)
 
 Data (const Data &)=delete
 
Dataoperator= (const Data &)=delete
 
bool SOFA_CORE_API read (const std::string &str)
 Specialization for reading strings. More...
 
bool SOFA_CORE_API read (const std::string &str)
 Specialization for reading booleans. More...
 
bool read (const std::string &str)
 Specialization for reading strings. More...
 
bool read (const std::string &str)
 Specialization for reading booleans. More...
 
virtual T * beginEdit ()
 
virtual T * beginWriteOnly ()
 
virtual void endEdit ()
 
void setValue (const T &value)
 
const T & getValue () const
 
BaseDatagetNewInstance () override
 
 Data (const BaseData::BaseInitData &init)
 
 Data (const InitData &init)
 
 Data (const char *helpMsg=nullptr, bool isDisplayed=true, bool isReadOnly=false)
 
 Data (const std::string &helpMsg, bool isDisplayed=true, bool isReadOnly=false)
 
 Data (const T &value, const char *helpMsg=nullptr, bool isDisplayed=true, bool isReadOnly=false)
 
 Data (const T &value, const std::string &helpMsg, bool isDisplayed=true, bool isReadOnly=false)
 
 ~Data () override
 Destructor. More...
 
- Public Member Functions inherited from sofa::core::objectmodel::BaseData
 BaseData (const BaseInitData &init)
 
 BaseData (const std::string &helpMsg, DataFlags flags=FLAG_DEFAULT)
 
 BaseData (const char *helpMsg, DataFlags flags=FLAG_DEFAULT)
 
 BaseData (const std::string &helpMsg, bool isDisplayed=true, bool isReadOnly=false)
 
 BaseData (const char *helpMsg, bool isDisplayed=true, bool isReadOnly=false)
 
 ~BaseData () override
 Destructor. More...
 
const void * getValueVoidPtr () const
 Get current value as a void pointer (use getValueTypeInfo to find how to access it) More...
 
void * beginEditVoidPtr ()
 Begin edit current value as a void pointer (use getValueTypeInfo to find how to access it) More...
 
void endEditVoidPtr ()
 Must be called after beginEditVoidPtr(), after you are finished modifying this Data. More...
 
const std::string & getHelp () const
 Get a help message that describes this Data. More...
 
void setHelp (const std::string &val)
 Set the help message. More...
 
const std::string & getGroup () const
 Get group. More...
 
void setGroup (const std::string &val)
 Set group. More...
 
const std::string & getWidget () const
 Get widget. More...
 
void setWidget (const char *val)
 Set widget. More...
 
virtual std::string getLinkPath () const
 If we use the Data as a link and not as value directly. More...
 
virtual bool canBeLinked () const
 
BasegetOwner () const
 Return the Base component owning this Data. More...
 
void setOwner (Base *o)
 Set the owner of this Data. More...
 
BaseDatagetData () const
 This method is needed by DDGNode. More...
 
const std::string & getName () const
 Return the name of this Data within the Base component. More...
 
void setName (const std::string &name)
 
bool hasDefaultValue () const
 Return whether the Data has a default value or not. More...
 
bool setParent (BaseData *parent, const std::string &path=std::string())
 Link to a parent data. The value of this data will automatically duplicate the value of the parent data. More...
 
bool setParent (const std::string &path)
 
virtual bool validParent (const BaseData *parent)
 Check if a given Data can be linked as a parent of this data. More...
 
BaseDatagetParent () const
 
void update () override
 Update the value of this Data. More...
 
bool copyValueFrom (const BaseData *data)
 Update this Data from the value of its parent. More...
 
bool updateValueFromLink (const BaseData *data)
 
void setFlag (DataFlagsEnum flag, bool b)
 Set one of the flags. More...
 
bool getFlag (DataFlagsEnum flag) const
 Get one of the flags. More...
 
bool isDisplayed () const
 Return whether this Data has to be displayed in GUIs. More...
 
bool isReadOnly () const
 Return whether this Data will be read-only in GUIs. More...
 
bool isPersistent () const
 Return whether this Data contains persistent information. More...
 
bool isAutoLink () const
 Return whether this Data should be autolinked when using the src="" syntax. More...
 
bool isRequired () const
 Return whether the Data has to be set by the user for the owner component to be valid. More...
 
void setDisplayed (bool b)
 Set whether this Data should be displayed in GUIs. More...
 
void setReadOnly (bool b)
 Set whether this Data is read-only. More...
 
void setPersistent (bool b)
 Set whether this Data contains persistent information. More...
 
void setAutoLink (bool b)
 Set whether this data should be autolinked when using the src="" syntax. More...
 
void setRequired (bool b)
 Set whether the Data has to be set by the user for the owner component to be valid. More...
 
bool isSet () const
 
void unset ()
 Reset the isSet flag to false, to indicate that the current value is the default for this Data. More...
 
void forceSet ()
 Reset the isSet flag to true, to indicate that the current value has been modified. More...
 
int getCounter () const
 
- Public Member Functions inherited from sofa::core::objectmodel::DDGNode
 DDGNode ()
 Constructor. More...
 
virtual ~DDGNode ()
 Destructor. Automatically remove remaining links. More...
 
void addInput (DDGNode *n)
 Add a new input to this node. More...
 
void delInput (DDGNode *n)
 Remove an input from this node. More...
 
void addOutput (DDGNode *n)
 Add a new output to this node. More...
 
void delOutput (DDGNode *n)
 Remove an output from this node. More...
 
const DDGLinkContainergetInputs ()
 Get the list of inputs for this DDGNode. More...
 
const DDGLinkContainergetOutputs ()
 Get the list of outputs for this DDGNode. More...
 
bool isDirty () const
 Returns true if the DDGNode needs to be updated. More...
 
virtual void setDirtyValue ()
 Indicate the value needs to be updated. More...
 
virtual void setDirtyOutputs ()
 Indicate the outputs needs to be updated. This method must be called after changing the value of this node. More...
 
void cleanDirty ()
 Set dirty flag to false. More...
 
virtual void notifyEndEdit ()
 Notify links that the DGNode has been modified. More...
 
void updateIfDirty () const
 Utility method to call update if necessary. This method should be called before reading of writing the value of this node. More...
 

Protected Member Functions

void swapPostProcess (Index i1, Index i2) override
 
void removePostProcess (sofa::Size nbElements) override
 
void addPostProcess (sofa::Index dataLastId) override
 
void updateLastIndex (Index posLastIndex, Index newGlobalId) override
 
- Protected Member Functions inherited from sofa::core::topology::TopologyData< ElementType, VecT >
void linkToElementDataArray (sofa::core::topology::BaseMeshTopology::Point *)
 
void linkToElementDataArray (sofa::core::topology::BaseMeshTopology::Edge *)
 
void linkToElementDataArray (sofa::core::topology::BaseMeshTopology::Triangle *)
 
void linkToElementDataArray (sofa::core::topology::BaseMeshTopology::Quad *)
 
void linkToElementDataArray (sofa::core::topology::BaseMeshTopology::Tetrahedron *)
 
void linkToElementDataArray (sofa::core::topology::BaseMeshTopology::Hexahedron *)
 
void unlinkFromElementDataArray (sofa::core::topology::BaseMeshTopology::Point *)
 Method to properly remove TopologyHandler. More...
 
void unlinkFromElementDataArray (sofa::core::topology::BaseMeshTopology::Edge *)
 
void unlinkFromElementDataArray (sofa::core::topology::BaseMeshTopology::Triangle *)
 
void unlinkFromElementDataArray (sofa::core::topology::BaseMeshTopology::Quad *)
 
void unlinkFromElementDataArray (sofa::core::topology::BaseMeshTopology::Tetrahedron *)
 
void unlinkFromElementDataArray (sofa::core::topology::BaseMeshTopology::Hexahedron *)
 
- Protected Member Functions inherited from sofa::core::objectmodel::Data< T >
std::istream & readValue (std::istream &in)
 
std::istream & readValue (std::istream &in)
 
SOFA_CORE_API std::istream & readValue (std::istream &in)
 
- Protected Member Functions inherited from sofa::core::objectmodel::BaseData
bool genericCopyValueFrom (const BaseData *parent)
 Try to update this Data from the value of its parent in "fast mode";. More...
 
- Protected Member Functions inherited from sofa::core::objectmodel::DDGNode
virtual void doAddInput (DDGNode *n)
 
virtual void doAddOutput (DDGNode *n)
 
virtual void doDelOutput (DDGNode *n)
 
void cleanDirtyOutputsOfInputs ()
 the dirtyOutputs flags of all the inputs will be set to false More...
 

Additional Inherited Members

- Public Attributes inherited from sofa::core::topology::TopologyData< ElementType, VecT >
std::function< void(Index, value_type &)> p_onDestructionCallback
 
std::function< void(Index, value_type &, const ElementType &, const sofa::type::vector< Index > &, const sofa::type::vector< SReal > &)> p_onCreationCallback
 
- Public Attributes inherited from sofa::core::objectmodel::Data< T >
int m_counter
 Number of changes since creation. More...
 
bool m_isSet
 True if this Data is set, i.e. its value is different from the default value. More...
 
- Public Attributes inherited from sofa::core::objectmodel::BaseData
std::string help {""}
 Help message. More...
 
std::string ownerClass {""}
 Owner class. More...
 
std::string group {""}
 group More...
 
std::string widget {""}
 widget More...
 
int m_counter
 Number of changes since creation. More...
 
bool m_isSet
 True if this Data is set, i.e. its value is different from the default value. More...
 
DataFlags m_dataFlags
 Flags indicating the purpose and behaviour of this Data. More...
 
Basem_owner {nullptr}
 Return the Base component owning this Data. More...
 
std::string m_name
 Data name within the Base component. More...
 
bool m_hasDefaultValue = false
 True if this Data has a default value. More...
 
DataLink< BaseDataparentData
 Parent Data. More...
 
- Protected Attributes inherited from sofa::core::topology::TopologySubsetData< core::topology::BaseMeshTopology::Point, type::vector< Index > >
sofa::type::vector< Index > m_map2Elements
 same size as this SubsetData but contains id of element link to each data[] More...
 
bool m_addNewElements
 
- Protected Attributes inherited from sofa::core::topology::TopologyData< ElementType, VecT >
std::unique_ptr< TopologyDataElementHandlerm_topologyHandler
 
bool m_isTopologyDynamic
 
- Protected Attributes inherited from sofa::core::topology::BaseTopologyData< VecT >
sofa::core::topology::BaseMeshTopologym_topology
 Pointer to the Topology this TopologyData is depending on. More...
 
Index m_lastElementIndex
 
- Protected Attributes inherited from sofa::core::objectmodel::Data< T >
m_defaultValue
 
ValueType m_value
 Value. More...
 
- Protected Attributes inherited from sofa::core::objectmodel::DDGNode
DDGLinkContainer inputs
 
DDGLinkContainer outputs
 
- Static Public Member Functions inherited from sofa::core::objectmodel::Data< T >
static constexpr bool isCopyOnWrite ()
 
static std::string templateName ()
 
- Static Public Member Functions inherited from sofa::core::objectmodel::BaseData
static std::string decodeTypeName (const std::type_info &t)
 Helper method to decode the type name to a more readable form if possible. More...
 
template<class T >
static std::string typeName (const T *=nullptr)
 Helper method to get the type name of type T. More...
 

Constructor details

◆ TopologySubsetIndices()

sofa::core::topology::TopologySubsetIndices::TopologySubsetIndices ( const typename sofa::core::topology::BaseTopologyData< type::vector< Index > >::InitData data)
explicit

Default Constructor to init Data.

Function details

◆ addPostProcess()

void sofa::core::topology::TopologySubsetIndices::addPostProcess ( sofa::Index  dataLastId)
overrideprotectedvirtual

Internal method called at the end of

See also
add method to apply internal mechanism, such as updating the map size.
Parameters
dataLastIdIndex of the last element id in the TopologyData tracked

Reimplemented from sofa::core::topology::TopologySubsetData< core::topology::BaseMeshTopology::Point, type::vector< Index > >.

◆ createTopologyHandler()

void sofa::core::topology::TopologySubsetIndices::createTopologyHandler ( sofa::core::topology::BaseMeshTopology _topology)
overridevirtual

Function to create topology handler to manage this Data.

Parameters
Pointerto dynamic topology is needed.

Reimplemented from sofa::core::topology::TopologyData< ElementType, VecT >.

◆ getLastElementIndex()

Index sofa::core::topology::TopologySubsetIndices::getLastElementIndex ( ) const
overridevirtual

Return the last element index of the topolgy buffer this Data is linked to.

See also
m_lastElementIndex

Reimplemented from sofa::core::topology::BaseTopologyData< VecT >.

◆ indexOfElement()

Index sofa::core::topology::TopologySubsetIndices::indexOfElement ( Index  index) const
overridevirtual

Method to return the index position of an element inside the vector map

See also
m_map2Elements
Parameters
{Index}element index of the full Data vector to find in the vector map
Returns
{Index} position of the element in the vector map. return sofa::InvalidID if not found.

Reimplemented from sofa::core::topology::TopologySubsetData< core::topology::BaseMeshTopology::Point, type::vector< Index > >.

◆ removePostProcess()

void sofa::core::topology::TopologySubsetIndices::removePostProcess ( sofa::Size  nbElements)
overrideprotectedvirtual

Internal method called at the end of

See also
remove method to apply internal mechanism, such as updating the map size
Parameters
nbElementsNumber of element removed.

Reimplemented from sofa::core::topology::TopologySubsetData< core::topology::BaseMeshTopology::Point, type::vector< Index > >.

◆ swapPostProcess()

void sofa::core::topology::TopologySubsetIndices::swapPostProcess ( Index  i1,
Index  i2 
)
overrideprotectedvirtual

Internal method called at the end of

See also
swap method to apply internal mechanism, such as map swap.
Parameters
i1First element index to be swaped.
i2Second element index to be swaped with first one.

Reimplemented from sofa::core::topology::TopologySubsetData< core::topology::BaseMeshTopology::Point, type::vector< Index > >.

◆ updateLastIndex()

void sofa::core::topology::TopologySubsetIndices::updateLastIndex ( Index  posLastIndex,
Index  newGlobalId 
)
overrideprotectedvirtual

Internal method to update the last element of this Data and/or map when the topology buffer is reduced.

Parameters
posLastIndexIndex position of the last topology element in this subset.
newGlobalIdGlobal topology element index to be set at Data[posLastIndex].

Reimplemented from sofa::core::topology::TopologySubsetData< core::topology::BaseMeshTopology::Point, type::vector< Index > >.