The Mangrove TDS Library  2.0 A C++ tool for the Fast Prototyping of Topological Data Structures
The TS data structure

Here, we propose a brief analysis of the Triangle-Segment (TS) data structure, initially proposed in [22] for representing simplicial complexes of dimension up to . In particular, we briefly propose its extension to a specific class of cell complexes, and its description as mangrove in our Mangrove TDS Library.

Attention
For the sake of efficiency, we consider the TS data structure describing cell complexes, in which each -cell (with ) has a priori fixed number of bounding cells, so that an enumeration mechanism for the faces of can be defined in terms of what vertices of are needed. As a consequence, it is possible to exploit ghost topological entities (see the Ghost Topological Entities Section). In particular, simplices of dimension up to are supported as well as quads (2-cells with 4 vertices), pentagons (2-cells with 5 vertices), and hexagonals (2-cells with 6 vertices).

# Formal Definition

The Triangle-Segment (TS) data structure is an explicit adjacency-based representation for any domain, including non-manifolds (see the Non-Manifold Complexes Section) of dimension up to , discretized by simplicial and cell complexes, and necessarily embedded in the Euclidean 3D space. In particular, it exploits the radial sorting of -cells around a non-manifold edge, in order to reduce the amount of information to be encoded.

Given any cell -complex (with ), the TS data structure encodes only vertices and top topological - and -entities (cells that are not on the boundary of other cells), plus a subset of co-boundary relations for each vertex, and a subset of adjacency relation for each top topological -entity in .

In particular, for each vertex , it encodes partial co-boundary relation , with , which associates with top edges, and one arbitrary top topological -entity (representative cell) for each -cluster in the star of . Recall that any -cluster in the star of is a maximal -subcomplex of , formed by top topological -entities, which are incident at .

For each top edge , it encodes boundary relation , which associates with its two vertices.

For each top -cell , it encodes:

• boundary relation , which associates with its vertices;
• adjacency relation , which associates with top topological -entities, adjacent to .
Attention
Recall that each -face of any top -cell may be shared by more than two top -cells. In this case, we speak about non-manifold adjacency, and it may be very expensive to be encoded directly.

In order to solve this drawback, the TS data structure also encodes partial co-boundary , which is defined for each edge on the boundary of more than two -cells. For each top -cell in the star of , this relation consists of two top -cells, which immediately precede and follow in radial order around edge . For example, edge in the following Figure is shared by triangles. For instance, we can define with respect to triangle (in yellow).

A non-manifold edge, shared by more than two top 2-cells

Partial topological relation allows for a compact encoding for adjacency relation for any top -cell along one of its -faces . In particular:

• if more than two top -cells are incident at (including ), then is encoded by replicating with respect to each top -cell in the star of .
• if at most two top -cells are incident at (including ), then there is manifold adjacency along , which can be encoded directly.
Attention
As a consequence, partial relation completely characterizes a non-manifold edge , in fact if there is any , then is surely non-manifold.
All top -cells, incident at , can be retrieved by retrieving all partial relations , related to edge , which form a cyclic list, radially sorted around .

# The TS-graph

The graph-based representation of the TS data structure, which we call the TS-graph, is a partial mangrove. Let any cell -complex (with ), then the TS-graph is formed by:

• nodes corresponding to vertices, and top cells in . A node corresponds to any cell in , directly encoded in the TS data structure. However, there are also special nodes (namely fake nodes), that correspond to -cells such that is not empty. These nodes allow for an elegant, uniform, and efficient way to encode partial relations of interest.
• Boundary arcs , corresponding to boundary relation , with , such that .
• Co-bundary arcs , corresponding to partial co-boundary relation , with , such that .
• Manifold Adjacency arcs , corresponding to manifold adjacency relation along a manifold -face of and , such that .
• Non-manifold Co-boundary arcs , corresponding to partial co-boundary relation , such that top -cell is incident at .
• Non-manifold Boundary arcs , corresponding to boundary relation , such that any edge of top -cell is non-manifold, and is not empty.

In particular, we can identify several spanning subgraphs of :

• the spanning subgraph formed by all nodes, corresponding to top topological entities and vertices, and by boundary arcs, is the TS Boundary Graph;
• the spanning subgraph formed by all nodes, corresponding to vertices and top topological entities, and by co-boundary arcs, is the TS Co-boundary Graph;
• the spanning subgraph formed by all fake nodes, and nodes, corresponding to top topological entities, and by manifold adjacency, non-manifold co-boundary, and non-manifold boundary arcs, is the TS Adjacency Graph.

Encoding the TS-graph as mangrove requires to store also several Hasse diagrams (see the Ghost Topological Entities Section), one for each type of top cells in , for . Experimental results in [14],[12] show their storage cost does not depend on the number of top -cells in , and their storage cost is basically not relevant.

# Some Implementation Remarks

The TS data structure is implemented in the mangrove_tds::Mangrove_TriangleSegment class, which is a subclass of the mangrove_tds::Mangrove_PartialMangrove class.

Attention
Generally speaking, for each node , only the unique identifiers of endpoints of arcs, outgoing from , are stored, and their dimension is implicit.

In particular, nodes of the TS-graph are stored in three array-based collections of topological entities (see the Internal Encoding of Mangroves Section), one for vertices, one for -cells (corresponding both to top and to non-manifold, namely fake nodes), and one for maximal -cells.

For a node , corresponding to a maximal -cell, only indices of its vertices (of dimension ) are stored, as well as indices of -cells (non-manifold adjacency, corresponding to fake nodes) and -cells (manifold adjacency), necessary for encoding adjacency relation along immediate faces of .

For a node , corresponding to a top edge, only indices of its vertices (of dimension ) are stored. On the contrary, for each fake node , corresponding to a non-manifold edge , two indices of nodes, corresponding to top -cells in , are encoded.

For a node corresponding to any vertex , only indices of top edges and representative cells of -clusters, incident at , are stored.

Attention
Note that none arc, related to auxiliary boundary relations, is encoded, thus only the effective content of the TS data structure is encoded.
In any case, note that this information is almost transparent for the user, which may exploit capabilities of the mangrove_tds::Mangrove_Mangrove class.

The mangrove_tds::Mangrove_TriangleSegment class contains implementations of all topological queries, and editing operators. It is a templated class itself, built on the template Derived class. This latter is exploited in the context of the Curiously Recurring Template Pattern (as inherited by the mangrove_tds::Mangrove_Mangrove class) in order to implement the static polymorphism. In this way, we can reuse some parts and provide only member functions, specialized for the TS data structure.

template< class Derived > class Mangrove_TriangleSegment : public Mangrove_PartialMangrove< Derived >
{
public:

/* Implementing topological queries and editing operators. */
...
};


In particular, in the mangrove_tds::Mangrove_TriangleSegment class, it is also possible to customize two aspects:

• the order of vertices (and thus of arcs) to be stored in boundary relations of any node. This aspect may be application-dependent.
• The enumeration of vertices for faces of any top -cell (with ), namely enumeration in Hasse diagrams , and the extraction of topological queries from (restricted to any top -cell).

Specifically, these two aspects are fundamental for defining what top cells can be represented in the TS data structure. In order to support a wide range of possibilities, the current implementation of these aspects is parametric in the mangrove_tds::Mangrove_TriangleSegment class. These aspects must be managed in the templated Derived class, which is also a trait class. In the current implementation, we propose two specific traits:

• one trait, specific for simplicial complexes, where simplices of dimension up to 2 are supported. Here, vertices are sorted in increasing order, as imposed by the simplicial homology. This trait is provided by the mangrove_tds::Mangrove_TriangleSegment_Simpl class.
• one trait, specific for cell complexes, where simplices and cells of dimension up to 2 are supported. Here, vertices are mostly sorted according to the STEP format, very common in exchanging data in CAD applications. Here, simplices, quads (2-cells with 4 vertices), pentagons (2-cells with 5 vertices), and hexagonals (2-cells with 6 vertices) are supported. This trait is provided by the mangrove_tds::Mangrove_TriangleSegment_Cell class.
class Mangrove_TriangleSegment_Simpl : public Mangrove_TriangleSegment< Mangrove_TriangleSegment_Simpl >
{
public:

/* Topological queries and editing operators are inherited. */
...

/* Sorting vertices in increasing order */
...

/* Retrieving topological queries from supported Hasse diagrams. */
...
};

class Mangrove_TriangleSegment_Cell : public Mangrove_TriangleSegment< Mangrove_TriangleSegment_Cell >
{
public:

/* Topological queries and editing operators are inherited. */
...

/* Sorting vertices in increasing order */
...

/* Retrieving topological queries from supported Hasse diagrams. */
...
};
Attention
You can write your own traits with these properties.
In any case, note that these operations are almost transparent for the user, which MUST NOT exploit directly the mangrove_tds::Mangrove_TriangleSegment class, but ONLY traits. For instance, one between the mangrove_tds::Mangrove_TriangleSegment_Cell or the mangrove_tds::Mangrove_TriangleSegment_Simpl classes, but also one custom trait can be exploited.
All Unit Tests Programs demonstrate the correctness and the validity of this modular approach, which has been also exploited for other topological data structures.