SOFA API  c76874b7
Open source framework for multi-physics simuation
sofa::component::topology::EdgeSetTopologyModifier Class Reference

#include <EdgeSetTopologyModifier.h>

Inheritance diagram for sofa::component::topology::EdgeSetTopologyModifier:

Detailed Description

A class that can apply basic transformations on a set of edges.

Public Member Functions

 SOFA_CLASS (EdgeSetTopologyModifier, PointSetTopologyModifier)
 
void init () override
 
void propagateTopologicalEngineChanges () override
 function to propagate topological change events by parsing the list of topologyEngines linked to this topology. More...
 
virtual void addEdges (const sofa::helper::vector< Edge > &edges)
 add a set of edges More...
 
virtual void addEdges (const sofa::helper::vector< Edge > &edges, const sofa::helper::vector< sofa::helper::vector< EdgeID > > &ancestors, const sofa::helper::vector< sofa::helper::vector< SReal > > &baryCoefs)
 add a set of edges More...
 
virtual void addEdges (const sofa::helper::vector< Edge > &edges, const sofa::helper::vector< core::topology::EdgeAncestorElem > &ancestorElems)
 add a set of edges More...
 
virtual void addEdgesWarning (const size_t nEdges)
 Sends a message to warn that some edges were added in this topology. More...
 
virtual void addEdgesWarning (const size_t nEdges, const sofa::helper::vector< Edge > &edgesList, const sofa::helper::vector< EdgeID > &edgesIndexList)
 Sends a message to warn that some edges were added in this topology. More...
 
virtual void addEdgesWarning (const size_t nEdges, const sofa::helper::vector< Edge > &edgesList, const sofa::helper::vector< EdgeID > &edgesIndexList, const sofa::helper::vector< sofa::helper::vector< EdgeID > > &ancestors)
 Sends a message to warn that some edges were added in this topology. More...
 
virtual void addEdgesWarning (const size_t nEdges, const sofa::helper::vector< Edge > &edgesList, const sofa::helper::vector< EdgeID > &edgesIndexList, const sofa::helper::vector< sofa::helper::vector< EdgeID > > &ancestors, const sofa::helper::vector< sofa::helper::vector< SReal > > &baryCoefs)
 Sends a message to warn that some edges were added in this topology. More...
 
virtual void addEdgesWarning (const size_t nEdges, const sofa::helper::vector< Edge > &edgesList, const sofa::helper::vector< EdgeID > &edgesIndexList, const sofa::helper::vector< core::topology::EdgeAncestorElem > &ancestorElems)
 Sends a message to warn that some edges were added in this topology. More...
 
void addEdgeProcess (Edge e)
 Effectively add an edge. More...
 
virtual void addEdgesProcess (const sofa::helper::vector< Edge > &edges)
 Effectively add some edges to this topology. More...
 
virtual void removeEdgesWarning (sofa::helper::vector< EdgeID > &edges)
 Sends a message to warn that some edges are about to be deleted. More...
 
virtual void removeEdgesProcess (const sofa::helper::vector< EdgeID > &indices, const bool removeIsolatedItems=false)
 Effectively Remove a subset of edges. Eventually remove isolated vertices. More...
 
virtual void swapEdgesProcess (const sofa::helper::vector< sofa::helper::vector< EdgeID > > &edgesPairs)
 Swap the edges. More...
 
virtual void fuseEdgesProcess (const sofa::helper::vector< sofa::helper::vector< EdgeID > > &edgesPairs, const bool removeIsolatedPoints=true)
 Fuse the edges. More...
 
virtual void splitEdgesProcess (sofa::helper::vector< EdgeID > &indices, const bool removeIsolatedPoints=true)
 Split the edges. More...
 
virtual void splitEdgesProcess (sofa::helper::vector< EdgeID > &indices, const sofa::helper::vector< sofa::helper::vector< SReal > > &baryCoefs, const bool removeIsolatedPoints=true)
 Split the edges. More...
 
void addPointsProcess (const size_t nPoints) override
 Add some points to this topology. More...
 
void removePointsProcess (const sofa::helper::vector< PointID > &indices, const bool removeDOF=true) override
 Remove a subset of points. More...
 
void renumberPointsProcess (const sofa::helper::vector< PointID > &index, const sofa::helper::vector< PointID > &, const bool renumberDOF=true) override
 Reorder this topology. More...
 
virtual void removeEdges (const sofa::helper::vector< EdgeID > &edgeIds, const bool removeIsolatedPoints=true, const bool resetTopoChange=true)
 Remove a set of edges. More...
 
void removeItems (const sofa::helper::vector< EdgeID > &items) override
 Generic method to remove a list of items. More...
 
void renumberPoints (const sofa::helper::vector< PointID > &index, const sofa::helper::vector< PointID > &inv_index) override
 Generic method for points renumbering. More...
 
virtual void swapEdges (const sofa::helper::vector< sofa::helper::vector< EdgeID > > &edgesPairs)
 Swap a list of pair edges, replacing each edge pair ((p11, p12), (p21, p22)) by the edge pair ((p11, p21), (p12, p22)) More...
 
virtual void fuseEdges (const sofa::helper::vector< sofa::helper::vector< EdgeID > > &edgesPairs, const bool removeIsolatedPoints=true)
 Fuse a list of pair edges, replacing each edge pair ((p11, p12), (p21, p22)) by one edge (p11, p22) More...
 
virtual void splitEdges (sofa::helper::vector< EdgeID > &indices, const bool removeIsolatedPoints=true)
 Split an array of edges, replacing each edge (p1, p2) by two edges (p1, p3) and (p3, p2) where p3 is the new vertex On each edge, a vertex is created based on its barycentric coordinates. More...
 
virtual void splitEdges (sofa::helper::vector< EdgeID > &indices, const sofa::helper::vector< sofa::helper::vector< SReal > > &baryCoefs, const bool removeIsolatedPoints=true)
 Split an array of edges, replacing each edge (p1, p2) by two edges (p1, p3) and (p3, p2) where p3 is the new vertex On each edge, a vertex is created based on its barycentric coordinates. More...
 
virtual void resortCuthillMckee (sofa::helper::vector< int > &inverse_permutation)
 Gives the optimal vertex permutation according to the Reverse CuthillMckee algorithm (use BOOST GRAPH LIBRAIRY) More...
 
void movePointsProcess (const sofa::helper::vector< PointID > &id, const sofa::helper::vector< sofa::helper::vector< PointID > > &ancestors, const sofa::helper::vector< sofa::helper::vector< SReal > > &coefs, const bool moveDOF=true) override
 Move input points indices to input new coords. Also propagate event and update edgesAroundVertex for data handling. More...
 
virtual bool removeConnectedComponents (EdgeID elemID)
 Given an element indice, it will remove all the connected component in which this element belongs to. Warning: if there is only one connected component in the model. All the object will be removed. More...
 
virtual bool removeConnectedElements (EdgeID elemID)
 Given an element indice, it will remove all elements directly connected to the input one. More...
 
virtual bool removeIsolatedElements ()
 If several connected components are detected, it will keep only the biggest one and remove all the rest. Warning: if two connected components have the same number of element and are the biggest. It will keep the first one. More...
 
virtual bool removeIsolatedElements (size_t scaleElem)
 If several connected components are detected, it will remove all connected component with less than a given number of elements. More...
 
- Public Member Functions inherited from sofa::component::topology::PointSetTopologyModifier
 SOFA_CLASS (PointSetTopologyModifier, core::topology::TopologyModifier)
 
void init () override
 
virtual void swapPoints (const int i1, const int i2)
 Swap points i1 and i2. More...
 
void addPointsWarning (const size_t nPoints, const bool addDOF=true)
 Sends a message to warn that some points were added in this topology. More...
 
void addPointsWarning (const size_t nPoints, const sofa::helper::vector< sofa::helper::vector< PointID > > &ancestors, const sofa::helper::vector< sofa::helper::vector< SReal > > &coefs, const bool addDOF=true)
 Sends a message to warn that some points were added in this topology. More...
 
void addPointsWarning (const size_t nPoints, const sofa::helper::vector< core::topology::PointAncestorElem > &ancestorElems, const bool addDOF=true)
 Sends a message to warn that some points were added in this topology. More...
 
virtual void addPoints (const size_t nPoints, const bool addDOF=true)
 Add a set of points. More...
 
virtual void addPoints (const size_t nPoints, const sofa::helper::vector< sofa::helper::vector< PointID > > &ancestors, const sofa::helper::vector< sofa::helper::vector< SReal > > &coefs, const bool addDOF=true)
 Add a set of points. More...
 
void addPoints (const size_t nPoints, const sofa::helper::vector< core::topology::PointAncestorElem > &ancestorElems, const bool addDOF=true)
 Add a set of points according to their ancestors topology elements. More...
 
void removePointsWarning (sofa::helper::vector< PointID > &indices, const bool removeDOF=true)
 Sends a message to warn that some points are about to be deleted. More...
 
void renumberPointsWarning (const sofa::helper::vector< PointID > &index, const sofa::helper::vector< PointID > &inv_index, const bool renumberDOF=true)
 Sends a message to warn that points are about to be reordered. More...
 
void propagateTopologicalChanges () override
 Called by a topology to warn specific topologies linked to it that TopologyChange objects happened. More...
 
void propagateTopologicalChangesWithoutReset ()
 TODO: doc ?? More...
 
void propagateStateChanges () override
 Called by a topology to warn the Mechanical Object component that points have been added or will be removed. More...
 
void notifyEndingEvent () override
 
void removeItems (const sofa::helper::vector< PointID > &) override
 Generic method to remove a list of items. More...
 

Protected Member Functions

 EdgeSetTopologyModifier ()
 
 ~EdgeSetTopologyModifier () override
 
- Protected Member Functions inherited from sofa::component::topology::PointSetTopologyModifier
 PointSetTopologyModifier ()
 
 ~PointSetTopologyModifier () override
 

Additional Inherited Members

- Public Attributes inherited from sofa::component::topology::PointSetTopologyModifier
Data< boold_propagateToDOF
 propagate changes to Mechanical object DOFs More...
 

Constructor details

sofa::component::topology::EdgeSetTopologyModifier::EdgeSetTopologyModifier ( )
inlineprotected
sofa::component::topology::EdgeSetTopologyModifier::~EdgeSetTopologyModifier ( )
inlineoverrideprotected

Function details

void sofa::component::topology::EdgeSetTopologyModifier::addEdgeProcess ( Edge  e)

Effectively add an edge.

void sofa::component::topology::EdgeSetTopologyModifier::addEdges ( const sofa::helper::vector< Edge > &  edges)
virtual

add a set of edges

Parameters
edgesan array of pair of vertex indices describing the edge to be created
void sofa::component::topology::EdgeSetTopologyModifier::addEdges ( const sofa::helper::vector< Edge > &  edges,
const sofa::helper::vector< sofa::helper::vector< EdgeID > > &  ancestors,
const sofa::helper::vector< sofa::helper::vector< SReal > > &  baryCoefs 
)
virtual

add a set of edges

Parameters
edgesan array of pair of vertex indices describing the edge to be created
ancestorsfor each edge to be created provides an array of edge ancestors (optional)
baryCoefsfor each edge provides the barycentric coordinates (sum to 1) associated with each ancestor (optional)
void sofa::component::topology::EdgeSetTopologyModifier::addEdges ( const sofa::helper::vector< Edge > &  edges,
const sofa::helper::vector< core::topology::EdgeAncestorElem > &  ancestorElems 
)
virtual

add a set of edges

Parameters
edgesan array of pair of vertex indices describing the edge to be created
ancestorsfor each edge to be created provides an array of edge ancestors (optional)
baryCoefsfor each edge provides the barycentric coordinates (sum to 1) associated with each ancestor (optional)
void sofa::component::topology::EdgeSetTopologyModifier::addEdgesProcess ( const sofa::helper::vector< Edge > &  edges)
virtual
void sofa::component::topology::EdgeSetTopologyModifier::addEdgesWarning ( const size_t  nEdges)
virtual

Sends a message to warn that some edges were added in this topology.

See also
addEdgesProcess
void sofa::component::topology::EdgeSetTopologyModifier::addEdgesWarning ( const size_t  nEdges,
const sofa::helper::vector< Edge > &  edgesList,
const sofa::helper::vector< EdgeID > &  edgesIndexList 
)
virtual

Sends a message to warn that some edges were added in this topology.

See also
addEdgesProcess

Reimplemented in sofa::component::topology::TriangleSetTopologyModifier.

void sofa::component::topology::EdgeSetTopologyModifier::addEdgesWarning ( const size_t  nEdges,
const sofa::helper::vector< Edge > &  edgesList,
const sofa::helper::vector< EdgeID > &  edgesIndexList,
const sofa::helper::vector< sofa::helper::vector< EdgeID > > &  ancestors 
)
virtual

Sends a message to warn that some edges were added in this topology.

See also
addEdgesProcess
void sofa::component::topology::EdgeSetTopologyModifier::addEdgesWarning ( const size_t  nEdges,
const sofa::helper::vector< Edge > &  edgesList,
const sofa::helper::vector< EdgeID > &  edgesIndexList,
const sofa::helper::vector< sofa::helper::vector< EdgeID > > &  ancestors,
const sofa::helper::vector< sofa::helper::vector< SReal > > &  baryCoefs 
)
virtual

Sends a message to warn that some edges were added in this topology.

See also
addEdgesProcess

Reimplemented in sofa::component::topology::TriangleSetTopologyModifier.

void sofa::component::topology::EdgeSetTopologyModifier::addEdgesWarning ( const size_t  nEdges,
const sofa::helper::vector< Edge > &  edgesList,
const sofa::helper::vector< EdgeID > &  edgesIndexList,
const sofa::helper::vector< core::topology::EdgeAncestorElem > &  ancestorElems 
)
virtual

Sends a message to warn that some edges were added in this topology.

See also
addEdgesProcess
void sofa::component::topology::EdgeSetTopologyModifier::addPointsProcess ( const size_t  nPoints)
overridevirtual
void sofa::component::topology::EdgeSetTopologyModifier::fuseEdges ( const sofa::helper::vector< sofa::helper::vector< EdgeID > > &  edgesPairs,
const bool  removeIsolatedPoints = true 
)
virtual

Fuse a list of pair edges, replacing each edge pair ((p11, p12), (p21, p22)) by one edge (p11, p22)

Parameters
removeIsolatedPointsif true isolated vertices are also removed
void sofa::component::topology::EdgeSetTopologyModifier::fuseEdgesProcess ( const sofa::helper::vector< sofa::helper::vector< EdgeID > > &  edgesPairs,
const bool  removeIsolatedPoints = true 
)
virtual

Fuse the edges.

Parameters
removeIsolatedItemsif true isolated vertices are also removed
void sofa::component::topology::EdgeSetTopologyModifier::init ( void  )
override
void sofa::component::topology::EdgeSetTopologyModifier::movePointsProcess ( const sofa::helper::vector< PointID > &  id,
const sofa::helper::vector< sofa::helper::vector< PointID > > &  ancestors,
const sofa::helper::vector< sofa::helper::vector< SReal > > &  coefs,
const bool  moveDOF = true 
)
overridevirtual

Move input points indices to input new coords. Also propagate event and update edgesAroundVertex for data handling.

Parameters
idThe list of indices to move
ancestorsThe list of ancestors to define relative new position
coefsThe barycoef to locate new coord relatively to ancestors. bool allowing the move (default true)

Reimplemented from sofa::component::topology::PointSetTopologyModifier.

Reimplemented in sofa::component::topology::TriangleSetTopologyModifier.

void sofa::component::topology::EdgeSetTopologyModifier::propagateTopologicalEngineChanges ( )
overridevirtual
bool sofa::component::topology::EdgeSetTopologyModifier::removeConnectedComponents ( EdgeID  elemID)
virtual

Given an element indice, it will remove all the connected component in which this element belongs to. Warning: if there is only one connected component in the model. All the object will be removed.

Parameters
elemIDThe ID of the input element.
Returns
false if something goes wrong during the process.
bool sofa::component::topology::EdgeSetTopologyModifier::removeConnectedElements ( EdgeID  elemID)
virtual

Given an element indice, it will remove all elements directly connected to the input one.

Parameters
elemIDThe ID of the input element.
Returns
false if something goes wrong during the process.
void sofa::component::topology::EdgeSetTopologyModifier::removeEdges ( const sofa::helper::vector< EdgeID > &  edgeIds,
const bool  removeIsolatedPoints = true,
const bool  resetTopoChange = true 
)
virtual

Remove a set of edges.

Parameters
edgesan array of edge indices to be removed (note that the array is not const since it needs to be sorted)
void sofa::component::topology::EdgeSetTopologyModifier::removeEdgesProcess ( const sofa::helper::vector< EdgeID > &  indices,
const bool  removeIsolatedItems = false 
)
virtual

Effectively Remove a subset of edges. Eventually remove isolated vertices.

Elements corresponding to these edges are removed form the mechanical object's state vectors.

Important : some structures might need to be warned BEFORE the edges are actually deleted, so always use method removeEdgesWarning before calling removeEdgesProcess.

See also
removeEdgesWarning

Important : parameter indices is not const because it is actually sorted from the highest index to the lowest one.

Parameters
removeIsolatedItemsif true isolated vertices are also removed

Reimplemented in sofa::component::topology::TriangleSetTopologyModifier, sofa::component::topology::TetrahedronSetTopologyModifier, sofa::component::topology::HexahedronSetTopologyModifier, and sofa::component::topology::QuadSetTopologyModifier.

void sofa::component::topology::EdgeSetTopologyModifier::removeEdgesWarning ( sofa::helper::vector< EdgeID > &  edges)
virtual

Sends a message to warn that some edges are about to be deleted.

See also
removeEdgesProcess
bool sofa::component::topology::EdgeSetTopologyModifier::removeIsolatedElements ( )
virtual

If several connected components are detected, it will keep only the biggest one and remove all the rest. Warning: if two connected components have the same number of element and are the biggest. It will keep the first one.

Returns
false if something goes wrong during the process.
bool sofa::component::topology::EdgeSetTopologyModifier::removeIsolatedElements ( size_t  scaleElem)
virtual

If several connected components are detected, it will remove all connected component with less than a given number of elements.

Parameters
scaleElemthreshold number size under which connected component will be removed.
Returns
false if something goes wrong during the process.
void sofa::component::topology::EdgeSetTopologyModifier::removeItems ( const sofa::helper::vector< EdgeID > &  items)
override

Generic method to remove a list of items.

void sofa::component::topology::EdgeSetTopologyModifier::removePointsProcess ( const sofa::helper::vector< PointID > &  indices,
const bool  removeDOF = true 
)
overridevirtual

Remove a subset of points.

these points are removed form the mechanical object's state vectors.

Important : some structures might need to be warned BEFORE the points are actually deleted, so always use method removePointsWarning before calling removePointsProcess.

See also
removePointsWarning Important : the points are actually deleted from the mechanical object's state vectors iff (removeDOF == true)

Reimplemented from sofa::component::topology::PointSetTopologyModifier.

Reimplemented in sofa::component::topology::TriangleSetTopologyModifier, sofa::component::topology::TetrahedronSetTopologyModifier, sofa::component::topology::HexahedronSetTopologyModifier, and sofa::component::topology::QuadSetTopologyModifier.

void sofa::component::topology::EdgeSetTopologyModifier::renumberPoints ( const sofa::helper::vector< PointID > &  index,
const sofa::helper::vector< PointID > &  inv_index 
)
overridevirtual
void sofa::component::topology::EdgeSetTopologyModifier::renumberPointsProcess ( const sofa::helper::vector< PointID > &  index,
const sofa::helper::vector< PointID > &  inv_index,
const bool  renumberDOF = true 
)
overridevirtual

Reorder this topology.

Important : the points are actually renumbered in the mechanical object's state vectors iff (renumberDOF == true)

See also
MechanicalObject::renumberValues

Reimplemented from sofa::component::topology::PointSetTopologyModifier.

Reimplemented in sofa::component::topology::TriangleSetTopologyModifier, sofa::component::topology::TetrahedronSetTopologyModifier, sofa::component::topology::HexahedronSetTopologyModifier, and sofa::component::topology::QuadSetTopologyModifier.

void sofa::component::topology::EdgeSetTopologyModifier::resortCuthillMckee ( sofa::helper::vector< int > &  inverse_permutation)
virtual

Gives the optimal vertex permutation according to the Reverse CuthillMckee algorithm (use BOOST GRAPH LIBRAIRY)

sofa::component::topology::EdgeSetTopologyModifier::SOFA_CLASS ( EdgeSetTopologyModifier  ,
PointSetTopologyModifier   
)
void sofa::component::topology::EdgeSetTopologyModifier::splitEdges ( sofa::helper::vector< EdgeID > &  indices,
const bool  removeIsolatedPoints = true 
)
virtual

Split an array of edges, replacing each edge (p1, p2) by two edges (p1, p3) and (p3, p2) where p3 is the new vertex On each edge, a vertex is created based on its barycentric coordinates.

Parameters
removeIsolatedPointsif true isolated vertices are also removed
void sofa::component::topology::EdgeSetTopologyModifier::splitEdges ( sofa::helper::vector< EdgeID > &  indices,
const sofa::helper::vector< sofa::helper::vector< SReal > > &  baryCoefs,
const bool  removeIsolatedPoints = true 
)
virtual

Split an array of edges, replacing each edge (p1, p2) by two edges (p1, p3) and (p3, p2) where p3 is the new vertex On each edge, a vertex is created based on its barycentric coordinates.

Parameters
removeIsolatedPointsif true isolated vertices are also removed
void sofa::component::topology::EdgeSetTopologyModifier::splitEdgesProcess ( sofa::helper::vector< EdgeID > &  indices,
const bool  removeIsolatedPoints = true 
)
virtual

Split the edges.

Parameters
removeIsolatedItemsif true isolated vertices are also removed
void sofa::component::topology::EdgeSetTopologyModifier::splitEdgesProcess ( sofa::helper::vector< EdgeID > &  indices,
const sofa::helper::vector< sofa::helper::vector< SReal > > &  baryCoefs,
const bool  removeIsolatedPoints = true 
)
virtual

Split the edges.

Parameters
removeIsolatedItemsif true isolated vertices are also removed
void sofa::component::topology::EdgeSetTopologyModifier::swapEdges ( const sofa::helper::vector< sofa::helper::vector< EdgeID > > &  edgesPairs)
virtual

Swap a list of pair edges, replacing each edge pair ((p11, p12), (p21, p22)) by the edge pair ((p11, p21), (p12, p22))

void sofa::component::topology::EdgeSetTopologyModifier::swapEdgesProcess ( const sofa::helper::vector< sofa::helper::vector< EdgeID > > &  edgesPairs)
virtual

Swap the edges.