Back

Element

<h3>Role and Purpose in the SOFA Ecosystem</h3> The `Element` class, defined within the `sofa::topology` namespace, is a fundamental building block used to represent geometric elements (e.g., vertices, edges, faces) within the SOFA simulation framework. It serves as a container for indices representing nodes that make up an element of the topology. <h3>Interactions with Other Components</h3> The `Element` class interacts with other components in the SOFA ecosystem primarily through its role in defining and accessing the topological structure of elements within the scene graph. It inherits from `BaseElement`, indicating that it follows a common interface for element operations. <h3>Practical Usage Guidance</h3> The `Element` class is typically used to define geometric elements in simulations, allowing users to manipulate and access node indices through various methods such as `operator[]`, `at`, and `get`. It supports standard iterator functions (`begin`, `cbegin`, `end`, `cend`) for iterating over its contents. The class provides a static size method that returns the number of nodes in the element, ensuring consistency with the specified geometry type. The operator `<` enables comparison between elements based on their node indices. <h3>Data Fields and Methods</h3> - **Static Methods:** - `size()`: Returns the number of nodes (statically defined). - **Public Member Functions:** - `Element(ArgsT&&...)`: Constructor that initializes the element with node indices. - `operator[](int i)`: Accesses an index in the element array. - `at(int i)`: Provides bounds-checked access to an index. - `get()`: Retrieves a specific index by constant template parameter. - `begin()`, `cbegin()`, `end()`, `cend()`: Iterator methods for accessing elements. - `array()`: Returns the underlying fixed array of indices. The class is designed to work with any geometry type that defines its number of nodes, providing a flexible and consistent way to represent topological elements in simulations.

abstract
`Element` represents geometric elements in SOFA simulations by storing node indices and providing methods to access them.
sheet
# Element **Overview** The `Element` class is a fundamental component within the SOFA framework, representing geometric elements such as vertices, edges, faces, or higher-order elements. It stores node indices and provides various methods for accessing these indices efficiently. **Parameters and Data** - **Static Methods:* - `size()`: Returns the number of nodes in the element (statically defined). - **Public Member Functions:** - `Element(ArgsT&&...)`: Constructor that initializes the element with node indices. - `operator[](int i)`: Accesses an index in the element array. - `at(int i)`: Provides bounds-checked access to an index. - `get()`: Retrieves a specific index by constant template parameter. - `begin()`, `cbegin()`, `end()`, `cend()`: Iterator methods for accessing elements. - `array()`: Returns the underlying fixed array of indices. **Dependencies and Connections** The `Element` class interacts with other components in the SOFA ecosystem primarily through its role in defining and accessing the topological structure of elements within the scene graph. It inherits from `BaseElement`, indicating that it follows a common interface for element operations.
description
<h3>Role and Purpose in the SOFA Ecosystem</h3> The `Element` class, defined within the `sofa::topology` namespace, is a fundamental building block used to represent geometric elements (e.g., vertices, edges, faces) within the SOFA simulation framework. It serves as a container for indices representing nodes that make up an element of the topology. <h3>Interactions with Other Components</h3> The `Element` class interacts with other components in the SOFA ecosystem primarily through its role in defining and accessing the topological structure of elements within the scene graph. It inherits from `BaseElement`, indicating that it follows a common interface for element operations. <h3>Practical Usage Guidance</h3> The `Element` class is typically used to define geometric elements in simulations, allowing users to manipulate and access node indices through various methods such as `operator[]`, `at`, and `get`. It supports standard iterator functions (`begin`, `cbegin`, `end`, `cend`) for iterating over its contents. The class provides a static size method that returns the number of nodes in the element, ensuring consistency with the specified geometry type. The operator `<` enables comparison between elements based on their node indices. <h3>Data Fields and Methods</h3> - **Static Methods:** - `size()`: Returns the number of nodes (statically defined). - **Public Member Functions:** - `Element(ArgsT&&...)`: Constructor that initializes the element with node indices. - `operator[](int i)`: Accesses an index in the element array. - `at(int i)`: Provides bounds-checked access to an index. - `get()`: Retrieves a specific index by constant template parameter. - `begin()`, `cbegin()`, `end()`, `cend()`: Iterator methods for accessing elements. - `array()`: Returns the underlying fixed array of indices. The class is designed to work with any geometry type that defines its number of nodes, providing a flexible and consistent way to represent topological elements in simulations.
maths
<h3>Mathematical and Physical Description</h3> <p>The `Element` class in the SOFA framework is a fundamental data structure used to represent geometric elements, such as vertices, edges, faces, or higher-order elements. It plays a crucial role in defining the topological structure of the simulation mesh.</p> <h4>Topological Representation</h4> <p>The `Element` class is parameterized by a geometry type (`GeometryElement`), which defines the number of nodes that make up an element (e.g., 2 for edges, 3 for triangular faces). The static method <code>size()</code> returns this predefined number.</p> <h4>Data Structure</h4> <p>The `Element` class stores its node indices in a fixed-size array (`ArrayType`), which is defined as:</p> <pre><code>using ArrayType = sofa::type::fixed_array<sofa::Index, GeometryElement::NumberOfNodes>; </code></pre> <p>This allows for efficient and consistent storage of the node indices.</p> <h4>Accessing Node Indices</h4> <p>The class provides several methods to access these node indices:</p> <ul> <li><code>operator[](size_type i)</code>: Accesses an index in the element array. This method is both non-const and const. <pre><code>constexpr reference operator[](size_type i) { return elems[i]; } constexpr const_reference operator[](size_type i) const { return elems[i]; }</code></pre> </li> <li><code>at(size_type i)</code>: Provides bounds-checked access to an index. This method is both non-const and const. <pre><code>constexpr reference at(size_type i) { return elems.at(i); } constexpr const_reference at(size_type i) const { return elems.at(i); }</code></pre> </li> <li><code>get&lt;I&gt;()</code>: Retrieves a specific index by constant template parameter. This method supports both lvalue and rvalue references. <pre><code>template< std::size_t I > [[nodiscard]] constexpr reference get() & noexcept requires( I < static_size ) { return elems[I]; } // Other overloads for const&, &&, and const&&</code></pre> </li> <li><code>array()</code>: Returns the underlying fixed array of indices. <pre><code>const ArrayType& array() const { return elems; }</code></pre> </li> </ul> <h4>Iterator Support</h4> <p>The `Element` class supports standard iterator methods for iterating over its contents:</p> <ul> <li><code>begin()</code>, <code>cbegin()</code>: Return the beginning of the element array.</li> <li><code>end()</code>, <code>cend()</code>: Return the end of the element array. <pre><code>constexpr iterator begin() noexcept { return elems.begin(); } // Other overloads for const and cbegin/cend</code></pre> </li> </ul> <h4>Comparison</h4> <p>The class supports comparison via the operator <code>&lt;</code>, which compares two elements based on their node indices. <pre><code>bool operator&lt;(const Element& other) const { return elems &lt; other.elems; }</code></pre> </p> <h4>Role in the SOFA Ecosystem</h4> <p>The `Element` class is a fundamental building block used to represent geometric elements within the SOFA simulation framework. It serves as a container for indices representing nodes that make up an element of the topology, ensuring consistency and efficiency in mesh representation.</p>
{
  "name": "Element",
  "main": {
    "name": "Element",
    "namespace": "sofa::topology",
    "module": "Sofa.framework.Topology",
    "include": "sofa/topology/Element.h",
    "doc": "",
    "inherits": [
      "BaseElement"
    ],
    "templates": [],
    "data_fields": [],
    "links": [],
    "methods": [
      {
        "name": "size",
        "return_type": "int",
        "params": [],
        "is_virtual": false,
        "is_pure_virtual": false,
        "is_static": true,
        "access": "public"
      },
      {
        "name": "Element<GeometryElement>",
        "return_type": "void",
        "params": [
          {
            "name": "args",
            "type": "ArgsT &&..."
          }
        ],
        "is_virtual": false,
        "is_pure_virtual": false,
        "is_static": false,
        "access": "public"
      },
      {
        "name": "operator[]",
        "return_type": "int",
        "params": [
          {
            "name": "i",
            "type": "int"
          }
        ],
        "is_virtual": false,
        "is_pure_virtual": false,
        "is_static": false,
        "access": "public"
      },
      {
        "name": "at",
        "return_type": "int",
        "params": [
          {
            "name": "i",
            "type": "int"
          }
        ],
        "is_virtual": false,
        "is_pure_virtual": false,
        "is_static": false,
        "access": "public"
      },
      {
        "name": "get",
        "return_type": "int",
        "params": [],
        "is_virtual": false,
        "is_pure_virtual": false,
        "is_static": false,
        "access": "public"
      },
      {
        "name": "begin",
        "return_type": "int",
        "params": [],
        "is_virtual": false,
        "is_pure_virtual": false,
        "is_static": false,
        "access": "public"
      },
      {
        "name": "cbegin",
        "return_type": "int",
        "params": [],
        "is_virtual": false,
        "is_pure_virtual": false,
        "is_static": false,
        "access": "public"
      },
      {
        "name": "end",
        "return_type": "int",
        "params": [],
        "is_virtual": false,
        "is_pure_virtual": false,
        "is_static": false,
        "access": "public"
      },
      {
        "name": "cend",
        "return_type": "int",
        "params": [],
        "is_virtual": false,
        "is_pure_virtual": false,
        "is_static": false,
        "access": "public"
      },
      {
        "name": "operator<",
        "return_type": "bool",
        "params": [
          {
            "name": "other",
            "type": "const Element<GeometryElement> &"
          }
        ],
        "is_virtual": false,
        "is_pure_virtual": false,
        "is_static": false,
        "access": "public"
      },
      {
        "name": "array",
        "return_type": "const int &",
        "params": [],
        "is_virtual": false,
        "is_pure_virtual": false,
        "is_static": false,
        "access": "public"
      }
    ]
  },
  "desc": {
    "description": "<h3>Role and Purpose in the SOFA Ecosystem</h3>\n\nThe `Element` class, defined within the `sofa::topology` namespace, is a fundamental building block used to represent geometric elements (e.g., vertices, edges, faces) within the SOFA simulation framework. It serves as a container for indices representing nodes that make up an element of the topology.\n\n<h3>Interactions with Other Components</h3>\n\nThe `Element` class interacts with other components in the SOFA ecosystem primarily through its role in defining and accessing the topological structure of elements within the scene graph. It inherits from `BaseElement`, indicating that it follows a common interface for element operations.\n\n<h3>Practical Usage Guidance</h3>\n\nThe `Element` class is typically used to define geometric elements in simulations, allowing users to manipulate and access node indices through various methods such as `operator[]`, `at`, and `get`. It supports standard iterator functions (`begin`, `cbegin`, `end`, `cend`) for iterating over its contents.\n\nThe class provides a static size method that returns the number of nodes in the element, ensuring consistency with the specified geometry type. The operator `<` enables comparison between elements based on their node indices.\n\n<h3>Data Fields and Methods</h3>\n\n- **Static Methods:**\n  - `size()`: Returns the number of nodes (statically defined).\n- **Public Member Functions:**\n  - `Element(ArgsT&&...)`: Constructor that initializes the element with node indices.\n  - `operator[](int i)`: Accesses an index in the element array.\n  - `at(int i)`: Provides bounds-checked access to an index.\n  - `get()`: Retrieves a specific index by constant template parameter.\n  - `begin()`, `cbegin()`, `end()`, `cend()`: Iterator methods for accessing elements.\n  - `array()`: Returns the underlying fixed array of indices.\n\nThe class is designed to work with any geometry type that defines its number of nodes, providing a flexible and consistent way to represent topological elements in simulations."
  },
  "maths": {
    "maths": "<h3>Mathematical and Physical Description</h3>\n\n<p>The `Element` class in the SOFA framework is a fundamental data structure used to represent geometric elements, such as vertices, edges, faces, or higher-order elements. It plays a crucial role in defining the topological structure of the simulation mesh.</p>\n\n<h4>Topological Representation</h4>\n\n<p>The `Element` class is parameterized by a geometry type (`GeometryElement`), which defines the number of nodes that make up an element (e.g., 2 for edges, 3 for triangular faces). The static method <code>size()</code> returns this predefined number.</p>\n\n<h4>Data Structure</h4>\n\n<p>The `Element` class stores its node indices in a fixed-size array (`ArrayType`), which is defined as:</p>\n\n<pre><code>using ArrayType = sofa::type::fixed_array<sofa::Index, GeometryElement::NumberOfNodes>;\n</code></pre>\n\n<p>This allows for efficient and consistent storage of the node indices.</p>\n\n<h4>Accessing Node Indices</h4>\n\n<p>The class provides several methods to access these node indices:</p>\n\n<ul>\n<li><code>operator[](size_type i)</code>: Accesses an index in the element array. This method is both non-const and const.\n\n<pre><code>constexpr reference operator[](size_type i)\n{\n    return elems[i];\n}\n\nconstexpr const_reference operator[](size_type i) const\n{\n    return elems[i];\n}</code></pre>\n</li>\n<li><code>at(size_type i)</code>: Provides bounds-checked access to an index. This method is both non-const and const.\n\n<pre><code>constexpr reference at(size_type i)\n{\n    return elems.at(i);\n}\n\nconstexpr const_reference at(size_type i) const\n{\n    return elems.at(i);\n}</code></pre>\n</li>\n<li><code>get&lt;I&gt;()</code>: Retrieves a specific index by constant template parameter. This method supports both lvalue and rvalue references.\n\n<pre><code>template< std::size_t I >\n[[nodiscard]] constexpr reference get() & noexcept requires( I < static_size )\n{\n    return elems[I];\n}\n\n// Other overloads for const&, &&, and const&&</code></pre>\n</li>\n<li><code>array()</code>: Returns the underlying fixed array of indices.\n\n<pre><code>const ArrayType& array() const\n{\n    return elems;\n}</code></pre>\n</li>\n</ul>\n\n<h4>Iterator Support</h4>\n\n<p>The `Element` class supports standard iterator methods for iterating over its contents:</p>\n\n<ul>\n<li><code>begin()</code>, <code>cbegin()</code>: Return the beginning of the element array.</li>\n<li><code>end()</code>, <code>cend()</code>: Return the end of the element array.\n\n<pre><code>constexpr iterator begin() noexcept\n{\n    return elems.begin();\n}\n\n// Other overloads for const and cbegin/cend</code></pre>\n</li>\n</ul>\n\n<h4>Comparison</h4>\n\n<p>The class supports comparison via the operator <code>&lt;</code>, which compares two elements based on their node indices.\n\n<pre><code>bool operator&lt;(const Element& other) const\n{\n    return elems &lt; other.elems;\n}</code></pre>\n</p>\n\n<h4>Role in the SOFA Ecosystem</h4>\n\n<p>The `Element` class is a fundamental building block used to represent geometric elements within the SOFA simulation framework. It serves as a container for indices representing nodes that make up an element of the topology, ensuring consistency and efficiency in mesh representation.</p>\n"
  },
  "summary": {
    "abstract": "`Element` represents geometric elements in SOFA simulations by storing node indices and providing methods to access them.",
    "sheet": "# Element\n\n**Overview**\n\nThe `Element` class is a fundamental component within the SOFA framework, representing geometric elements such as vertices, edges, faces, or higher-order elements. It stores node indices and provides various methods for accessing these indices efficiently.\n\n**Parameters and Data**\n\n- **Static Methods:*\n  - `size()`: Returns the number of nodes in the element (statically defined).\n- **Public Member Functions:**\n  - `Element(ArgsT&&...)`: Constructor that initializes the element with node indices.\n  - `operator[](int i)`: Accesses an index in the element array.\n  - `at(int i)`: Provides bounds-checked access to an index.\n  - `get()`: Retrieves a specific index by constant template parameter.\n  - `begin()`, `cbegin()`, `end()`, `cend()`: Iterator methods for accessing elements.\n  - `array()`: Returns the underlying fixed array of indices.\n\n**Dependencies and Connections**\n\nThe `Element` class interacts with other components in the SOFA ecosystem primarily through its role in defining and accessing the topological structure of elements within the scene graph. It inherits from `BaseElement`, indicating that it follows a common interface for element operations."
  }
}