Visual Computing Library
Loading...
Searching...
No Matches
mesh.h
1/*****************************************************************************
2 * VCLib *
3 * Visual Computing Library *
4 * *
5 * Copyright(C) 2021-2025 *
6 * Visual Computing Lab *
7 * ISTI - Italian National Research Council *
8 * *
9 * All rights reserved. *
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the Mozilla Public License Version 2.0 as published *
13 * by the Mozilla Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 * This program is distributed in the hope that it will be useful, *
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
19 * Mozilla Public License Version 2.0 *
20 * (https://www.mozilla.org/en-US/MPL/2.0/) for more details. *
21 ****************************************************************************/
22
23#ifndef VCL_MESH_MESH_H
24#define VCL_MESH_MESH_H
25
26#include "mesh_components.h"
27#include "mesh_containers.h"
28
29#include <vclib/concepts/mesh.h>
30
31namespace vcl {
32
66template<typename... Args>
67class Mesh : public Args...
68{
69 static_assert(HasVertices<Args...>, "A Mesh must have a VertexContainer.");
70
71 template<typename El, bool b>
72 friend struct comp::detail::CustomComponentsData;
73
74 template<typename El, bool b>
75 friend struct comp::detail::ComponentData;
76
77 template<ElementConcept T>
78 friend class mesh::ElementContainer;
79
80 template<uint ELEM_ID, typename MeshType, typename... Comps>
81 friend class Element;
82
83 // Predicate structures
84
85 template<uint ELEM_ID>
87 public mesh::ContainerOfElement<ELEM_ID, Mesh<Args...>>
88 {
89 };
90
101 template<ElementConcept El>
102 struct ContainerOf : public ContainerOfElement<El::ELEMENT_ID>
103 {
104 };
105
106public:
114 TypeWrapper<Args...>>::type;
115
122 FilterTypesByCondition<comp::IsComponentPred, TypeWrapper<Args...>>::
123 type;
124
136 template<uint ELEM_ID>
138
150 template<uint ELEM_ID>
152
153 /* Constexpr static member functions */
154
179 template<ElementConcept El>
180 static constexpr bool hasContainerOf()
181 {
182 return mesh::HasContainerOfPred<El, Mesh<Args...>>::value;
183 }
184
202 template<uint ELEM_ID>
203 static constexpr bool hasContainerOf()
204 {
205 return mesh::HasContainerOfElementPred<ELEM_ID, Mesh<Args...>>::value;
206 }
207
226 template<uint ELEM_ID, uint COMP_ID>
227 static constexpr bool hasPerElementComponent()
228 {
229 return mesh::HasPerElementComponent<Mesh<Args...>, ELEM_ID, COMP_ID>;
230 }
231
251 template<uint ELEM_ID, uint COMP_ID>
252 static constexpr bool hasPerElementOptionalComponent()
253 {
254 return mesh::
255 HasPerElementOptionalComponent<Mesh<Args...>, ELEM_ID, COMP_ID>;
256 }
257
258 /* Constructors */
259
264 {
265 // Set to all element containers their parent mesh (this)
266 updateAllParentMeshPointers();
267 }
268
276 Mesh(const Mesh& oth) :
277 Args(oth)... // call auto copy constructors for all the container
278 // elements and components
279 {
280 // Set to all element containers their parent mesh (this)
281 updateAllParentMeshPointers();
282
283 // for each container of oth, save its base pointer
284 // will need it to update all the pointers of this mesh
285 constexpr uint N_CONTAINERS =
286 NumberOfTypes<typename Mesh<Args...>::Containers>::value;
287 std::array<const void*, N_CONTAINERS> othBases =
289
290 // update all the pointers contained on each container
291 // use the base pointer of each container of oth to update all the
292 // pointers in this mesh. Each pointer of oth that was copied in this
293 // mesh, will be updated computing its offset wrt the base of oth, and
294 // then adding that offset to the new base pointer of this mesh
296 }
297
305 {
306 swap(oth); // use copy and swap idiom: this (empty) mesh is swapped with
307 // the input one
308 }
309
310 /* Member functions */
311
318 bool isCompact() const
319 {
320 bool isCompact = true;
322 return isCompact;
323 }
324
329 void clear() { (clearContainer<Args>(), ...); }
330
337 void compact() { (compactContainer<Args>(), ...); }
338
347
356
386 template<typename OtherMeshType>
388 {
389 // enable all optional components of this Mesh depending on what's
390 // available in the OtherMeshType
391
393 }
394
408 void append(const Mesh& m)
409 {
410 // for each container of this mesh, save its size
411 // will need it to update all the pointers/indices of this mesh
412 constexpr uint N_CONTAINERS =
413 NumberOfTypes<typename Mesh<Args...>::Containers>::value;
414 std::array<std::size_t, N_CONTAINERS> sizes =
416
417 // for each container of the other mesh m, save its bases
418 // will need it to update all the pointers of this mesh
419 std::array<const void*, N_CONTAINERS> bases =
421
422 // call the append function for each container
423 (appendContainer<Args>(m), ...);
424
425 // update all the pointers/indices contained on each container
427 ...);
428 }
429
444 template<typename OtherMeshType>
446 {
447 // This function will first:
448 // Call, for each Container and Component of the mesh, its importFrom
449 // function. In case of containers, it first creates the same number of
450 // elements in the container, and then calls the importFrom function for
451 // each new element.
452
453 (Args::importFrom(m), ...);
454
455 // Set to all element containers their parent mesh (this)
456 updateAllParentMeshPointers();
457
458 if constexpr (mesh::HasFaceContainer<Mesh<Args...>>) {
459 // Now I need to manage imports between different types of meshes
460 // (same type of meshes are already managed from importFrom member
461 // function).
462 //
463 // Generally speaking, Polygon meshes can import from any other type
464 // of mesh. We need to take care when this mesh has static vertex
465 // references number in the face container (VERTEX_NUMBER >= 3).
466 //
467 // The follwing case don't need to be managed:
468 // - import polygon mesh from triangle mesh
469 //
470 // I can manage the following cases:
471 // - import triangle mesh from polygon mesh: need triangulation
472 //
473 // I cannot manage the follwing cases:
474 // - import static non-triangle mesh from polygon mesh or from a
475 // mesh with different VERTEX_NUMBER
476
477 // in case of import from poly to triangle mesh, I need to manage
478 // triangulation of polygons and create additional triangle faces
479 // for each of the imported polygons. This function statically
480 // asserts that the import can be done.
481 using FaceContainer = typename Mesh<Args...>::FaceContainer;
482 FaceContainer::manageImportTriFromPoly(m);
483 }
484 }
485
490 void swap(Mesh& m2)
491 {
492 Mesh<Args...>& m1 = *this;
493
494 constexpr uint N_CONTAINERS =
495 NumberOfTypes<typename Mesh<Args...>::Containers>::value;
496 static_assert(N_CONTAINERS != 0);
497
498 // container bases of each container for m1 and m2
499 // we save the bases of the containers before swap
500 std::array<const void*, N_CONTAINERS> m1Bases =
502 std::array<const void*, N_CONTAINERS> m2Bases =
504
505 // actual swap of all the containers and the components of the mesh
506 // using pack expansion: swap will be called for each of the containers
507 // (or components!) that compose the Mesh
508 using std::swap;
509 (swap((Args&) m1, (Args&) m2), ...);
510
511 // Set to all elements their parent mesh
512 m1.updateAllParentMeshPointers();
513 m2.updateAllParentMeshPointers();
514
515 // update all the refs to m1 and m2: old base of m1 is now "old
516 // base" of m2, and viceversa
519 }
520
529 friend void swap(Mesh& a, Mesh& b) { a.swap(b); }
530
538 {
539 swap(oth);
540 return *this;
541 }
542
543 /*** Generic Element functions ***/
544
556 template<ElementConcept El>
557 uint index(const El& e) const requires (hasContainerOf<El>())
558 {
559 using Container = ContainerOf<El>::type;
560 return Container::index(&e);
561 }
562
574 template<ElementConcept El>
575 uint index(const El* e) const requires (hasContainerOf<El>())
576 {
577 using Container = ContainerOf<El>::type;
578 return Container::index(e);
579 }
580
595 template<uint ELEM_ID>
596 const auto& element(uint i) const requires (hasContainerOf<ELEM_ID>())
597 {
599
600 return Cont::element(i);
601 }
602
617 template<uint ELEM_ID>
619 {
621
622 return Cont::element(i);
623 }
624
634 template<uint ELEM_ID>
636 {
638
639 return Cont::elementNumber();
640 }
641
656 template<uint ELEM_ID>
658 {
660
661 return Cont::elementContainerSize();
662 }
663
674 template<uint ELEM_ID>
676 {
678
679 return Cont::deletedElementNumber();
680 }
681
696 template<uint ELEM_ID>
698 {
700
701 return Cont::addElement();
702 }
703
719 template<uint ELEM_ID>
721 {
723
724 return Cont::addElements(n); // add the number elements
725 }
726
747 template<uint ELEM_ID>
749 {
751
752 Cont::clearElements();
753 }
754
788 template<uint ELEM_ID>
790 {
792
793 Cont::resizeElements(n);
794 }
795
816 template<uint ELEM_ID>
818 {
820
821 Cont::reserveElements(n);
822 }
823
830 template<uint ELEM_ID>
832 {
834
835 Cont::compactElements();
836 }
837
855 template<uint ELEM_ID>
857 {
859
860 Cont::deleteElement(i);
861 }
862
880 template<ElementConcept El>
881 void deleteElement(const El* e) const requires (hasContainerOf<El>())
882 {
884 return Cont::deleteElement(e);
885 }
886
904 template<ElementConcept El>
905 void deleteElement(const El& e) const requires (hasContainerOf<El>())
906 {
908 return Cont::deleteElement(&e);
909 }
910
928 template<uint ELEM_ID>
929 std::vector<uint> compactIndices() const
930 requires (hasContainerOf<ELEM_ID>())
931 {
933
934 return Cont::elementConpactIndices();
935 }
936
963 template<uint ELEM_ID>
964 void updateIndices(const std::vector<uint>& newIndices)
965 requires (hasContainerOf<ELEM_ID>())
966 {
968
969 return Cont::updateElementIndices(newIndices);
970 }
971
972 void serialize(std::ostream& os) const
973 {
975
977 }
978
979 void deserialize(std::istream& is)
980 {
981 (preDeserialization<Args>(is), ...);
982
983 (postDeserialization<Args>(is), ...);
984 }
985
1003 template<uint ELEM_ID>
1004 auto begin(bool jumpDeleted = true) requires (hasContainerOf<ELEM_ID>())
1005 {
1007
1008 return Cont::elementBegin(jumpDeleted);
1009 }
1010
1022 template<uint ELEM_ID>
1023 auto end() requires (hasContainerOf<ELEM_ID>())
1024 {
1026
1027 return Cont::elementEnd();
1028 }
1029
1047 template<uint ELEM_ID>
1048 auto begin(bool jumpDeleted = true) const
1049 requires (hasContainerOf<ELEM_ID>())
1050 {
1052
1053 return Cont::elementBegin(jumpDeleted);
1054 }
1055
1067 template<uint ELEM_ID>
1068 auto end() const requires (hasContainerOf<ELEM_ID>())
1069 {
1071
1072 return Cont::elementEnd();
1073 }
1074
1097 template<uint ELEM_ID>
1098 auto elements(bool jumpDeleted = true) requires (hasContainerOf<ELEM_ID>())
1099 {
1101
1102 return Cont::elements(jumpDeleted);
1103 }
1104
1127 template<uint ELEM_ID>
1128 auto elements(bool jumpDeleted = true) const
1129 requires (hasContainerOf<ELEM_ID>())
1130 {
1132
1133 return Cont::elements(jumpDeleted);
1134 }
1135
1149 template<uint ELEM_ID, uint COMP_ID>
1157
1169 template<uint ELEM_ID, uint COMP_ID>
1177
1189 template<uint ELEM_ID, uint COMP_ID>
1197
1214 template<uint ELEM_ID>
1215 bool hasPerElementCustomComponent(const std::string& name) const
1217 {
1219
1220 return Cont::hasElemCustomComponent(name);
1221 }
1222
1235 template<uint ELEM_ID>
1236 std::vector<std::string> perElementCustomComponentNames() const
1237 requires (hasPerElementComponent<ELEM_ID, CompId::CUSTOM_COMPONENTS>())
1238 {
1240
1241 return Cont::elemCustomComponentNames();
1242 }
1243
1258 template<uint ELEM_ID, typename K>
1259 bool isPerElementCustomComponentOfType(const std::string& name) const
1261 {
1263
1264 return Cont::template isElemCustomComponentOfType<K>(name);
1265 }
1266
1280 template<uint ELEM_ID>
1281 std::type_index perElementCustomComponentType(const std::string& name) const
1283 {
1285
1286 return Cont::elemCustomComponentType(name);
1287 }
1288
1302 template<uint ELEM_ID, typename K>
1304 requires (hasPerElementComponent<ELEM_ID, CompId::CUSTOM_COMPONENTS>())
1305 {
1307
1308 return Cont::template elemCustomComponentNamesOfType<K>();
1309 }
1310
1323 template<uint ELEM_ID, typename K>
1324 void addPerElementCustomComponent(const std::string& name)
1326 {
1328
1329 Cont::template addElemCustomComponent<K>(name);
1330 }
1331
1343 template<uint ELEM_ID>
1344 void deletePerElementCustomComponent(const std::string& name)
1346 {
1348
1349 Cont::deleteElemCustomComponent(name);
1350 }
1351
1393 template<uint ELEM_ID, typename K>
1402
1444 template<uint ELEM_ID, typename K>
1453
1454protected:
1455 template<typename Cont>
1456 bool isContainerCompact() const
1457 {
1459 return Cont::elementNumber() == Cont::elementContainerSize();
1460 }
1461 else {
1462 return true; // does not count as a container
1463 }
1464 }
1465
1475 template<typename Cont>
1477 {
1479 if (Cont::elementNumber() != Cont::elementContainerSize()) {
1480 Cont::compactElements();
1481 }
1482 }
1483 }
1484
1494 template<typename Cont>
1496 {
1498 Cont::enableAllOptionalComponents();
1499 }
1500 }
1501
1511 template<typename Cont>
1513 {
1515 Cont::disableAllOptionalComponents();
1516 }
1517 }
1518
1528 template<typename Cont>
1530 {
1532 Cont::clearElements();
1533 }
1534 }
1535
1536 template<ElementConcept Element>
1537 void updateAllReferences(const Element* oldBase)
1538 {
1539 if (oldBase != nullptr)
1541 }
1542
1543 // this function is required in order to get msvc compile
1544 template<typename Element, typename... A>
1545 void updateReferences(const Element* oldBase, TypeWrapper<A...>)
1546 {
1547 updateReferences(
1548 oldBase, TypeWrapper<A...>(), std::array<std::size_t, 0>(), 0);
1549 }
1550
1551 // this function is required in order to get msvc compile
1552 template<typename Cont, typename Element>
1553 void updateReferences(const Element* oldBase)
1554 {
1555 updateReferences<Cont>(oldBase, std::array<std::size_t, 0>(), 0);
1556 }
1557
1558 // this additional function is necessary because otherwise msvc jumps
1559 // totally the pack expansion if called directly in the function
1560 // updateReferencesOfContainerTypeAfterAppend
1561 template<typename Element, std::size_t N, typename... A>
1562 void updateReferences(
1563 const Element* oldBase,
1564 TypeWrapper<A...>,
1565 const std::array<std::size_t, N>& sizes = std::array<std::size_t, 0>(),
1566 uint offset = 0)
1567 {
1568 (updateReferences<A>(oldBase, sizes, offset), ...);
1569 }
1570
1571 template<typename Cont, typename Element, std::size_t N>
1572 void updateReferences(
1573 const Element* oldBase,
1574 const std::array<std::size_t, N>& sizes = std::array<std::size_t, 0>(),
1575 uint offset = 0)
1576 {
1577 if constexpr (mesh::ElementContainerConcept<Cont>) {
1578 if constexpr (N > 0) {
1579 using Containers = Mesh<Args...>::Containers;
1580 constexpr uint I = IndexInTypes<Cont, Containers>::value;
1581 static_assert(I >= 0 && I != UINT_NULL);
1582 Cont::updateReferences(oldBase, sizes[I], offset);
1583 }
1584 else {
1585 Cont::updateReferences(oldBase);
1586 }
1587 }
1588 }
1589
1590 template<ElementConcept Element>
1591 void updateAllReferences(const std::vector<uint>& newIndices)
1592 {
1593 (updateReferences<Args, Element>(newIndices), ...);
1594 }
1595
1596 template<typename Cont, typename Element>
1597 void updateReferences(const std::vector<uint>& newIndices)
1598 {
1599 if constexpr (mesh::ElementContainerConcept<Cont>) {
1600 Cont::template updateReferences<Element>(newIndices);
1601 }
1602 }
1603
1604private:
1605 // hide init and isAvailable members
1606 void init() {};
1607
1608 bool isAvailable() const { return true; }
1609
1610 // enable optional components
1611
1612 template<typename Cont, typename OtherMeshType>
1613 void enableSameOptionalComponentsOf(const OtherMeshType& m)
1614 {
1615 if constexpr (mesh::ElementContainerConcept<Cont>) {
1616 Cont::enableOptionalComponentsOf(m);
1617 }
1618 }
1619
1620 // private parent mesh pointers functions
1621
1622 void updateAllParentMeshPointers() { (setParentMeshPointers<Args>(), ...); }
1623
1624 template<typename Cont>
1625 void setParentMeshPointers()
1626 {
1627 if constexpr (mesh::ElementContainerConcept<Cont>) {
1628 Cont::setParentMeshPointers(this);
1629 }
1630 }
1631
1632 template<typename Cont>
1633 void appendContainer(const Mesh& m)
1634 {
1635 if constexpr (mesh::ElementContainerConcept<Cont>) {
1636 Cont::append((const Cont&) m);
1637 }
1638 }
1639
1640 // private copy and swap member functions
1641
1649 template<uint I, typename Cont, typename Array, typename... A>
1651 {
1652 // since this function is called using pack expansion, it means that
1653 // Cont could be a mesh component and not a cointainer. We check if Cont
1654 // is a container
1656 static_assert(I >= 0 && I != UINT_NULL);
1657 bases[I] = m.Cont::mElemVec.data();
1658 }
1659 }
1660
1661 template<typename... A>
1662 static auto getContainerBases(const Mesh<A...>& m)
1663 {
1664 using Containers = Mesh<A...>::Containers;
1665
1666 // the number of containers in Mesh<A...>
1668 // each element of this array will contain the base pointer of the
1669 // vector of elements contained in each container of Mesh<A...>
1670 std::array<const void*, N_CONTAINERS> bases;
1671
1672 // for each container/component of Mesh<A...>, we set call the function
1673 // that sets the base of the container in its index
1675 ...);
1676
1677 return bases;
1678 }
1679
1687 template<uint I, typename Cont, typename Array, typename... A>
1689 {
1690 // since this function is called using pack expansion, it means that
1691 // Cont could be a mesh component and not a cointainer. We check if Cont
1692 // is a container
1694 static_assert(I >= 0 && I != UINT_NULL);
1695 sizes[I] = m.Cont::mElemVec.size();
1696 }
1697 }
1698
1699 template<typename... A>
1700 static auto getContainerSizes(const Mesh<A...>& m)
1701 {
1702 using Containers = Mesh<A...>::Containers;
1703
1704 // the number of containers in Mesh<A...>
1706 // each element of this array will contain the size of the
1707 // vector of elements contained in each container of Mesh<A...>
1708 std::array<std::size_t, N_CONTAINERS> sizes;
1709
1710 // for each container/component of Mesh<A...>, we set call the function
1711 // that sets the size of the container in its index
1713 ...);
1714
1715 return sizes;
1716 }
1717
1742 template<typename Cont, typename Array, typename... A>
1744 Mesh<A...>& m,
1745 const Array& bases)
1746 {
1747 // since this function is called using pack expansion, it means that
1748 // Cont could be a mesh component and not a cointainer. We check if Cont
1749 // is a container
1751 // The element type contained in the container
1752 // We need it to get back the actual type of the element from the
1753 // old bases
1754 using ElType = Cont::ElementType;
1755
1756 using Containers = Mesh<A...>::Containers;
1758 static_assert(I >= 0 && I != UINT_NULL);
1759
1760 using ContainerWrapper = TypeWrapper<A...>;
1761
1762 // for each Container A in m, we update the references of ElType.
1763 // old base is contained in the array bases, the new base is the
1764 // base of the container
1765 m.updateReferences(
1766 reinterpret_cast<const ElType*>(bases[I]), ContainerWrapper());
1767 }
1768 }
1769
1770 template<typename Cont, typename ArrayB, typename ArrayS, typename... A>
1771 static void updateReferencesOfContainerTypeAfterAppend(
1772 Mesh<A...>& m,
1773 const ArrayB& bases,
1774 const ArrayS& sizes)
1775 {
1776 // since this function is called using pack expansion, it means that
1777 // Cont could be a mesh component and not a cointainer. We check if Cont
1778 // is a container
1780 // The element type contained in the container
1781 // We need it to get back the actual type of the element from the
1782 // old bases
1783 using ElType = Cont::ElementType;
1784
1785 using Containers = Mesh<A...>::Containers;
1786 constexpr uint I = IndexInTypes<Cont, Containers>::value;
1787 static_assert(I >= 0 && I != UINT_NULL);
1788
1789 using ContainerWrapper = TypeWrapper<A...>;
1790
1791 // for each Container A in m, we update the references of ElType.
1792 // old base is contained in the array bases
1793 m.updateReferences(
1794 reinterpret_cast<const ElType*>(bases[I]),
1796 sizes,
1797 sizes[I]);
1798 }
1799 }
1800
1801 // serialization/deserialization
1802
1803 template<typename Cont>
1804 void preSerialization(std::ostream& os) const
1805 {
1806 if constexpr (mesh::ElementContainerConcept<Cont>) {
1807 Cont::serializeOptionalComponentsAndElementsNumber(os);
1808 }
1809 }
1810
1811 template<typename Cont>
1812 void postSerialization(std::ostream& os) const
1813 {
1814 if constexpr (mesh::ElementContainerConcept<Cont>) {
1815 Cont::serializeElements(os);
1816 }
1817 else {
1818 // cont is a component...
1819 Cont::serialize(os);
1820 }
1821 }
1822
1823 template<typename Cont>
1824 void preDeserialization(std::istream& is)
1825 {
1826 if constexpr (mesh::ElementContainerConcept<Cont>) {
1827 Cont::deserializeOptionalComponentsAndElementsNumber(is);
1828 }
1829 }
1830
1831 template<typename Cont>
1832 void postDeserialization(std::istream& is)
1833 {
1834 if constexpr (mesh::ElementContainerConcept<Cont>) {
1835 Cont::deserializeElements(is);
1836 }
1837 else {
1838 // cont is a component...
1839 Cont::deserialize(is);
1840 }
1841 }
1842
1843 // member functions used by friends
1844
1845 template<uint ELEM_ID, typename T>
1846 uint elementIndex(const T* el) const
1847 {
1848 using Cont = ContainerOfElement<ELEM_ID>::type;
1849 using ElType = Cont::ElementType;
1850 return index(static_cast<const ElType*>(el));
1851 }
1852
1853 template<typename El>
1854 auto& customComponents()
1855 {
1856 using ElCont = ContainerOf<El>::type;
1857
1858 return ElCont::mCustomCompVecMap;
1859 }
1860
1861 template<typename El>
1862 const auto& customComponents() const
1863 {
1864 using ElCont = ContainerOf<El>::type;
1865
1866 return ElCont::mCustomCompVecMap;
1867 }
1868
1869 template<typename El>
1870 auto& verticalComponents()
1871 {
1872 using ElCont = ContainerOf<El>::type;
1873
1874 return ElCont::mVerticalCompVecTuple;
1875 }
1876
1877 template<typename El>
1878 const auto& verticalComponents() const
1879 {
1880 using ElCont = ContainerOf<El>::type;
1881
1882 return ElCont::mVerticalCompVecTuple;
1883 }
1884};
1885
1886} // namespace vcl
1887
1888#endif // VCL_MESH_MESH_H
The Array class is a dynamically allocated N-dimensional array stored in RowWise mode.
Definition array.h:64
The Element class.
Definition element.h:57
The Mesh class represents a generic 3D mesh. A mesh is composed of a generic number of containers of ...
Definition mesh.h:68
bool isCompact() const
Returns true if this mesh is compact, meaning that all its containers have no deleted elements (size ...
Definition mesh.h:318
auto elements(bool jumpDeleted=true) const
Definition mesh.h:1128
uint deletedNumber() const
Returns the number of deleted elements of the given type in this mesh.
Definition mesh.h:675
void deleteElement(uint i)
Marks as deleted the element at the given index from its container, deduced from the template index E...
Definition mesh.h:856
void deleteElement(const El &e) const
Marks as deleted the given element from its container.
Definition mesh.h:905
Mesh()
Empty constructor, constructs an empty mesh.
Definition mesh.h:263
Mesh(const Mesh &oth)
Copy constructor of the Mesh. Will create a deep copy of the given input mesh, taking care of copying...
Definition mesh.h:276
auto begin(bool jumpDeleted=true)
Returns an iterator to the begining of the container of the elements having ID ELEM_ID in the mesh.
Definition mesh.h:1004
CustomComponentVectorHandle< K > perElementCustomComponentVectorHandle(const std::string &name)
Returns a vector handle to the custom component of type K having the given name associated to the Ele...
Definition mesh.h:1394
std::type_index perElementCustomComponentType(const std::string &name) const
Returns the std::type_index of the custom component having the given name associated to the Element h...
Definition mesh.h:1281
void compactContainer()
Definition mesh.h:1476
auto elements(bool jumpDeleted=true)
Definition mesh.h:1098
void compactElements()
Compacts the Container of the given element, removing all the elements marked as deleted....
Definition mesh.h:831
void enableSameOptionalComponentsOf(const OtherMeshType &m)
Enables all the OptionalComponents of this mesh according to the Components available on the OtherMes...
Definition mesh.h:387
Mesh(Mesh &&oth)
Move constructor, moves the given mesh into this one, without any other resource acquisition.
Definition mesh.h:304
bool hasPerElementCustomComponent(const std::string &name) const
Returns true if the Element having ID ELEM_ID has a custom component with the given name.
Definition mesh.h:1215
std::vector< uint > compactIndices() const
Returns a vector that tells, for each element of the container of ELEM_ID in the mesh,...
Definition mesh.h:929
void deleteElement(const El *e) const
Marks as deleted the given element from its container.
Definition mesh.h:881
void disableAllOptionalComponents()
Disables all the optional components of the elements of the containers if the mesh.
Definition mesh.h:352
void addPerElementCustomComponent(const std::string &name)
Adds a custom component of type K having the given name to the Element having ID ELEM_ID.
Definition mesh.h:1324
void append(const Mesh &m)
Appends all the elements contained in the mesh m to this mesh.
Definition mesh.h:408
auto end()
Returns an iterator to the end of the container of the elements having ID ELEM_ID in the mesh.
Definition mesh.h:1023
void enableAllOptionalComponentsInContainer()
Definition mesh.h:1495
bool isPerElementCustomComponentOfType(const std::string &name) const
Returns true if the Element having ID ELEM_ID has a custom component of type K with the given name.
Definition mesh.h:1259
uint add()
Adds a new element of the given type into its container, returning the index of the added element in ...
Definition mesh.h:697
void clear()
Clears all the Elements contained in the mesh.
Definition mesh.h:329
uint add(uint n)
Adds n new elements of the given type into its container, returning the index of the first added elem...
Definition mesh.h:720
void swap(Mesh &m2)
Swaps this mesh with the other input Mesh m2.
Definition mesh.h:490
uint containerSize() const
Returns the size of the container of elements of the given type in this mesh.
Definition mesh.h:657
void clearElements()
Clears the container of ELEM_ID elements the Mesh, deleting all the Elements.
Definition mesh.h:748
void importFrom(const OtherMeshType &m)
Imports all the components that can be imported from another type of mesh.
Definition mesh.h:445
bool isPerElementComponentEnabled() const
Returns true if optional Component having ID COMP_ID is enabled for elements having ID ELEM_ID in the...
Definition mesh.h:1150
const auto & element(uint i) const
Returns the element of the given type at the given index inside its container of this mesh.
Definition mesh.h:596
void compact()
Compacts all the containers of the mesh.
Definition mesh.h:337
void updateIndices(const std::vector< uint > &newIndices)
Updates all the indices and pointers of the elements of the container of ELEM_ID in the mesh,...
Definition mesh.h:964
Mesh & operator=(Mesh oth)
Assignment operator of the Mesh.
Definition mesh.h:537
void clearContainer()
Definition mesh.h:1529
void deletePerElementCustomComponent(const std::string &name)
Deletes the custom component of the given name from the Element having ID ELEM_ID.
Definition mesh.h:1344
void reserve(uint n)
Reserves a number of elements of the given type in its container. The function does not add any eleme...
Definition mesh.h:817
void resize(uint n)
Resizes the Element container to contain n Elements of type ELEM_ID.
Definition mesh.h:789
static void updateReferencesOfContainerType(Mesh< A... > &m, const Array &bases)
Definition mesh.h:1743
auto end() const
Returns a const iterator to the end of the container of the elements having ID ELEM_ID in the mesh.
Definition mesh.h:1068
void enableAllOptionalComponents()
Enables all the optional components of the elements of the containers if the mesh.
Definition mesh.h:343
std::vector< std::string > perElementCustomComponentNames() const
Returns a vector containing all the names of the custom components of any type associated to the Elem...
Definition mesh.h:1236
void disableAllOptionalComponentsInContainer()
Definition mesh.h:1512
static constexpr bool hasPerElementComponent()
Returns true if this Mesh has a container of elements having the same Element ID of the template ELEM...
Definition mesh.h:227
static void setContainerBase(const Mesh< A... > &m, Array &bases)
Definition mesh.h:1650
friend void swap(Mesh &a, Mesh &b)
Specializes the swap function to allow the swapping of two Mesh objects.
Definition mesh.h:529
FilterTypesByCondition< mesh::IsElementContainerPred, TypeWrapper< Args... > >::type Containers
Containers is a vcl::TypeWrapper that wraps all the types from which the Mesh inherits (Args) that ar...
Definition mesh.h:114
auto & element(uint i)
Returns the element of the given type at the given index inside its container of this mesh.
Definition mesh.h:618
void enablePerElementComponent()
Enables the optional Component having ID COMP_ID for elements having ID ELEM_ID in the mesh.
Definition mesh.h:1170
uint index(const El *e) const
Returns the index of the given element in its Container of the Mesh.
Definition mesh.h:575
void disablePerElementComponent()
Disables the optional Component having ID COMP_ID for elements having ID ELEM_ID in the mesh.
Definition mesh.h:1190
ConstCustomComponentVectorHandle< K > perElementCustomComponentVectorHandle(const std::string &name) const
Returns a const vector handle to the custom component of type K having the given name associated to t...
Definition mesh.h:1445
uint number() const
Returns the number of elements of the given type in this mesh.
Definition mesh.h:635
ContainerType< ELEM_ID >::ElementType ElementType
ElementType is an alias that exposes the type of the Element identified by the template parameter ELE...
Definition mesh.h:151
uint index(const El &e) const
Returns the index of the given element in its Container of the Mesh.
Definition mesh.h:557
auto begin(bool jumpDeleted=true) const
Returns a const iterator to the begining of the container of the elements having ID ELEM_ID in the me...
Definition mesh.h:1048
static constexpr bool hasPerElementOptionalComponent()
Returns true if this Mesh has a container of elements having the same Element ID of the template ELEM...
Definition mesh.h:252
static constexpr bool hasContainerOf()
Returns true if this Mesh has a container of elements having the same Element ID of the template Elem...
Definition mesh.h:180
std::vector< std::string > perElementCustomComponentNamesOfType() const
Returns a vector containing all the names of the custom components of type K associated to the Elemen...
Definition mesh.h:1303
static void setContainerSize(const Mesh< A... > &m, Array &sizes)
Definition mesh.h:1688
A class representing a line segment in n-dimensional space. The class is parameterized by a PointConc...
Definition segment.h:43
Definition element.h:44
HasVertices concepts is satisfied when at least one of its types is (or inherits from) a vcl::mesh::V...
Definition vertex_container.h:130
ElementContainerConcept is a concept satisfied when the type T is an Element Container.
Definition element_container.h:36
The HasFaceContainer concept is satisfied only if a container class provides the types and member fun...
Definition face_container.h:44
Definition mesh_concept.h:40
constexpr uint UINT_NULL
The UINT_NULL value represent a null value of uint that is the maximum value that can be represented ...
Definition base.h:48
The CompId struct enumerates the components that can compose a element or a mesh.
Definition mesh_components.h:50
Removes all types that do not satisfy a condition, and get them as a tuple.
Definition filter_types.h:72
Definition variadic_templates.h:128
Definition mesh.h:88
The ContainerOf struct allows to get the Container of an Element on this Mesh.
Definition mesh.h:103
Definition variadic_templates.h:143
A simple structure that wraps a list of variadic templates, without instantiating anything....
Definition type_wrapper.h:41
The ContainerOfElement structure exposes the type of the container of the given MeshType having eleme...
Definition mesh_containers.h:107
Definition mesh_containers.h:146
Definition mesh_containers.h:138
The predicate IsElementContainerPred sets its bool value to true when the type T satisfies the Elemen...
Definition mesh_containers.h:81