Skip to content

Commit 38b8425

Browse files
alxbilgerhugtalbot
andauthored
[Topology] Container for prisms and pyramids (#5784)
* [Topology] Container for prisms and pyramids * remove duplicate --------- Co-authored-by: Hugo <hugo.talbot@sofa-framework.org>
1 parent 73b9cda commit 38b8425

File tree

6 files changed

+45
-14
lines changed

6 files changed

+45
-14
lines changed

Sofa/Component/Topology/Container/Constant/src/sofa/component/topology/container/constant/MeshTopology.cpp

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -491,6 +491,8 @@ MeshTopology::MeshTopology()
491491
, d_seqQuads(initData(&d_seqQuads, "quads", "List of quad indices"))
492492
, d_seqTetrahedra(initData(&d_seqTetrahedra, "tetrahedra", "List of tetrahedron indices"))
493493
, d_seqHexahedra(initData(&d_seqHexahedra, "hexahedra", "List of hexahedron indices"))
494+
, d_seqPrisms(initData(&d_seqPrisms, "prisms", "List of prisms indices"))
495+
, d_seqPyramids(initData(&d_seqPyramids, "pyramids", "List of pyramids indices"))
494496
, d_seqUVs(initData(&d_seqUVs, "uv", "List of uv coordinates"))
495497
, d_computeAllBuffers(initData(&d_computeAllBuffers, false, "computeAllBuffers", "Option to compute all crossed topology buffers at init. False by default"))
496498
, nbPoints(0)
@@ -763,7 +765,6 @@ const MeshTopology::SeqTriangles& MeshTopology::getTriangles()
763765

764766
const MeshTopology::SeqQuads& MeshTopology::getQuads()
765767
{
766-
767768
return d_seqQuads.getValue();
768769
}
769770

@@ -787,6 +788,16 @@ const MeshTopology::SeqHexahedra& MeshTopology::getHexahedra()
787788
return d_seqHexahedra.getValue();
788789
}
789790

791+
const BaseMeshTopology::SeqPrisms& MeshTopology::getPrisms()
792+
{
793+
return d_seqPrisms.getValue();
794+
}
795+
796+
const BaseMeshTopology::SeqPyramids& MeshTopology::getPyramids()
797+
{
798+
return d_seqPyramids.getValue();
799+
}
800+
790801
const MeshTopology::SeqUV& MeshTopology::getUVs()
791802
{
792803
return d_seqUVs.getValue();

Sofa/Component/Topology/Container/Constant/src/sofa/component/topology/container/constant/MeshTopology.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,8 @@ class SOFA_COMPONENT_TOPOLOGY_CONTAINER_CONSTANT_API MeshTopology : public core:
9898
const SeqQuads& getQuads() override;
9999
const SeqTetrahedra& getTetrahedra() override;
100100
const SeqHexahedra& getHexahedra() override;
101+
const SeqPrisms& getPrisms() override;
102+
const SeqPyramids& getPyramids() override;
101103

102104
// If using STEP loader, include also uv coordinates
103105
typedef Index UVID;
@@ -298,6 +300,8 @@ class SOFA_COMPONENT_TOPOLOGY_CONTAINER_CONSTANT_API MeshTopology : public core:
298300
Data<SeqQuads> d_seqQuads; ///< List of quad indices
299301
Data<SeqTetrahedra> d_seqTetrahedra; ///< List of tetrahedron indices
300302
Data<SeqHexahedra> d_seqHexahedra; ///< List of hexahedron indices
303+
Data<SeqPrisms> d_seqPrisms;
304+
Data<SeqPyramids> d_seqPyramids;
301305
Data<SeqUV> d_seqUVs; ///< List of uv coordinates
302306
Data<bool> d_computeAllBuffers; ///< Option to call method computeCrossElementBuffers. False by default
303307

Sofa/framework/Core/src/sofa/core/topology/BaseMeshTopology.h

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,13 @@ class SOFA_CORE_API BaseMeshTopology : public core::topology::Topology
3434
SOFA_ABSTRACT_CLASS(BaseMeshTopology, core::topology::Topology);
3535
SOFA_BASE_CAST_IMPLEMENTATION(BaseMeshTopology)
3636

37-
typedef sofa::type::vector<Edge> SeqEdges;
38-
typedef sofa::type::vector<Triangle> SeqTriangles;
39-
typedef sofa::type::vector<Quad> SeqQuads;
40-
typedef sofa::type::vector<Tetra> SeqTetrahedra;
41-
typedef sofa::type::vector<Hexa> SeqHexahedra;
37+
using SeqEdges = sofa::type::vector<Edge>;
38+
using SeqTriangles = sofa::type::vector<Triangle>;
39+
using SeqQuads = sofa::type::vector<Quad>;
40+
using SeqTetrahedra = sofa::type::vector<Tetra>;
41+
using SeqHexahedra = sofa::type::vector<Hexa>;
42+
using SeqPrisms = sofa::type::vector<Prism>;
43+
using SeqPyramids = sofa::type::vector<Pyramid>;
4244

4345
/// @name Deprecated types, for backward-compatibility
4446
/// @{
@@ -104,6 +106,8 @@ class SOFA_CORE_API BaseMeshTopology : public core::topology::Topology
104106
virtual const SeqQuads& getQuads() = 0;
105107
virtual const SeqTetrahedra& getTetrahedra() = 0;
106108
virtual const SeqHexahedra& getHexahedra() = 0;
109+
virtual const SeqPrisms& getPrisms() = 0;
110+
virtual const SeqPyramids& getPyramids() = 0;
107111
/// @}
108112

109113
/// Random accessors
@@ -113,14 +117,18 @@ class SOFA_CORE_API BaseMeshTopology : public core::topology::Topology
113117
virtual Size getNbTriangles() { return Size(getTriangles().size()); }
114118
virtual Size getNbQuads() { return Size(getQuads().size()); }
115119
virtual Size getNbTetrahedra() { return Size(getTetrahedra().size()); }
116-
virtual Size getNbHexahedra() { return Size(getHexahedra().size()); }
120+
virtual Size getNbHexahedra() { return Size(getHexahedra().size()); }
121+
virtual Size getNbPrisms() { return Size(getPrisms().size()); }
122+
virtual Size getNbPyramids() { return Size(getPyramids().size()); }
117123

118124
virtual const Edge getEdge(EdgeID i) { return getEdges()[i]; }
119125
virtual const Triangle getTriangle(TriangleID i) { return getTriangles()[i]; }
120126
virtual const Quad getQuad(QuadID i) { return getQuads()[i]; }
121127
virtual const Tetra getTetrahedron(TetraID i) { return getTetrahedra()[i]; }
122-
virtual const Hexa getHexahedron(HexaID i) { return getHexahedra()[i]; }
123-
128+
virtual const Hexa getHexahedron(HexaID i) { return getHexahedra()[i]; }
129+
virtual const Prism getPrism(PrismID i) { return getPrisms()[i]; }
130+
virtual const Pyramid getPyramid(PyramidID i) { return getPyramids()[i]; }
131+
124132
/// Type of higher topology element contains in this container @see ElementType
125133
virtual sofa::geometry::ElementType getTopologyType() const = 0;
126134
/// @}

Sofa/framework/Core/src/sofa/core/topology/BaseTopology.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,8 @@ class SOFA_CORE_API TopologyContainer : public sofa::core::topology::BaseTopolog
174174
const SeqQuads& getQuads() override { static SeqQuads empty; return empty; }
175175
const SeqTetrahedra& getTetrahedra() override { static SeqTetrahedra empty; return empty; }
176176
const SeqHexahedra& getHexahedra() override { static SeqHexahedra empty; return empty; }
177+
const SeqPrisms& getPrisms() override { static SeqPrisms empty; return empty; }
178+
const SeqPyramids& getPyramids() override { static SeqPyramids empty; return empty; }
177179

178180
/** \brief Get the current revision of this mesh.
179181
*

Sofa/framework/Core/src/sofa/core/topology/Topology.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,8 @@ class SOFA_CORE_API Topology : public virtual sofa::core::objectmodel::BaseObjec
7171
typedef sofa::Index HexahedronID;
7272
SOFA_CORE_TOPOLOGY_ATTRIBUTE_DEPRECATED__ALIASES_INDEX()
7373
typedef sofa::Index HexaID;
74+
SOFA_CORE_TOPOLOGY_ATTRIBUTE_DEPRECATED__ALIASES_INDEX()
75+
typedef sofa::Index PrismID;
7476

7577
inline static const auto InvalidSet = sofa::topology::InvalidSet;
7678
static constexpr auto InvalidEdge = sofa::topology::InvalidEdge;

Sofa/framework/Core/test/topology/TopologySubsetIndices_test.cpp

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,13 @@ class SimplePointTopology: public BaseMeshTopology
4545
m_data.createTopologyHandler(this);
4646
}
4747

48-
virtual const SeqEdges& getEdges() { return m_edges; }
49-
virtual const SeqTriangles& getTriangles() { return m_triangles; }
50-
virtual const SeqQuads& getQuads() { return m_quads; }
51-
virtual const SeqTetrahedra& getTetrahedra() { return m_tetra; }
52-
virtual const SeqHexahedra& getHexahedra() { return m_hexa; }
48+
const SeqEdges& getEdges() override { return m_edges; }
49+
const SeqTriangles& getTriangles() override { return m_triangles; }
50+
const SeqQuads& getQuads() override { return m_quads; }
51+
const SeqTetrahedra& getTetrahedra() override { return m_tetra; }
52+
const SeqHexahedra& getHexahedra() override { return m_hexa; }
53+
const SeqPrisms& getPrisms() override { return m_prisms; }
54+
const SeqPyramids& getPyramids() override { return m_pyramids; }
5355

5456
virtual sofa::geometry::ElementType getTopologyType() const
5557
{
@@ -78,6 +80,8 @@ class SimplePointTopology: public BaseMeshTopology
7880
sofa::type::vector<Quad> m_quads;
7981
sofa::type::vector<Tetra> m_tetra;
8082
sofa::type::vector<Hexa> m_hexa;
83+
sofa::type::vector<Prism> m_prisms;
84+
sofa::type::vector<Pyramid> m_pyramids;
8185

8286
TopologySubsetIndices m_data;
8387
type::vector<sofa::Index> m_points;

0 commit comments

Comments
 (0)