25#ifndef __BITPIT_ELEMENT_HPP__
26#define __BITPIT_ELEMENT_HPP__
30#include <unordered_map>
33#include "bitpit_common.hpp"
34#include "bitpit_containers.hpp"
36#include "element_type.hpp"
37#include "element_reference.hpp"
43IBinaryStream & operator>>(IBinaryStream &buf, Element& element);
44OBinaryStream &
operator<<(OBinaryStream &buf,
const Element& element);
78 constexpr std::size_t
operator()(U&& value)
const noexcept
80 return static_cast<std::size_t
>(std::forward<U>(value));
119 void setConnect(std::unique_ptr<
long[]> &&connect);
155 BITPIT_PUBLIC_API
static const long NULL_ID;
157 std::array<double, 3>
evalCentroid(
const std::array<double, 3> *coordinates)
const;
159 double evalSize(
const std::array<double, 3> *coordinates)
const;
161 double evalVolume(
const std::array<double, 3> *coordinates)
const;
162 double evalArea(
const std::array<double, 3> *coordinates)
const;
163 double evalLength(
const std::array<double, 3> *coordinates)
const;
165 std::array<double, 3>
evalNormal(
const std::array<double, 3> *coordinates,
const std::array<double, 3> &orientation = {{0., 0., 1.}},
const std::array<double, 3> &point = {{0.5, 0.5, 0.5}})
const;
167 void evalPointProjection(
const std::array<double, 3> &point,
const std::array<double, 3> *coordinates, std::array<double, 3> *projection,
double *distance)
const;
168 double evalPointDistance(
const std::array<double, 3> &point,
const std::array<double, 3> *coordinates)
const;
175 friend class Element;
180 int importVertexCoordinates(
const std::array<double, 3> &coordinates);
181 int importVertexCoordinates(std::array<double, 3> &&coordinates);
182 std::vector<int> importVertexCoordinates(
const std::array<double, 3> * coordinates,
int nVertices);
184 void importPolygon(
const std::vector<int> &vertexIds);
185 void importPolyhedron(
const std::vector<int> &vertexIds,
const std::vector<std::vector<int>> &faceVertexIds);
187 int getTileCount()
const;
189 std::vector<std::array<double, 3>> getTileVertexCoordinates(
int tile)
const;
193 std::vector<ElementType> m_types;
194 std::vector<std::vector<int>> m_connects;
196 std::vector<std::array<double, 3>> m_coordinates;
199 static int countPolygonVertices(
const long *connectivity);
201 static int countPolygonFaces(
const long *connectivity);
202 static int countPolyhedronFaces(
const long *connectivity);
210 std::unique_ptr<long[]> m_connect;
212 void _initialize(
long id,
ElementType type = ElementType::UNDEFINED,
int connectSize = 0);
213 void _initialize(
long id,
ElementType type, std::unique_ptr<
long[]> &&connectStorage);
215 Tesselation generateTesselation(
const std::array<double, 3> *coordinates)
const;
217 std::vector<ConstProxyVector<long>> evalEdgeConnects(
int maxEdges = -1)
const;
221template<
class DerivedElement>
243 DerivedElement &m_element;
246 std::size_t m_firstVertexId;
256template<
class DerivedElement>
260 typedef typename ElementHalfItem<DerivedElement>::Winding Winding;
271template<
class DerivedElement>
275 typedef typename ElementHalfItem<DerivedElement>::Winding Winding;
291#include "element.tpp"
The Tesselation class allows to tessalete polygons and polyhedrons.
The ElementHalfEdge class defines element half-edge items.
ElementHalfEdge(DerivedElement &element, int edge, Winding winding)
The ElementHalfFace class defines element half-faces.
ElementHalfFace(DerivedElement &element, int face, Winding winding)
The ElementHalfItem class is the base calss for defining element half-edge and half-faces.
bool operator!=(const ElementHalfItem &other) const
ElementHalfItem(DerivedElement &element, ConstProxyVector< long > &&vertexIds, ElementHalfItem< DerivedElement >::Winding winding)
const ConstProxyVector< long > & getVertexIds() const
DerivedElement & getElement() const
bool operator==(const ElementHalfItem &other) const
void setWinding(Winding winding)
Winding getWinding() const
The Element class provides an interface for defining elements.
Element & operator=(const Element &other)
ConstProxyVector< int > getFaceLocalConnect(int face) const
double evalVolume(const std::array< double, 3 > *coordinates) const
ConstProxyVector< long > getFaceVertexIds(int face) const
ElementType getType() const
int getEdgeVertexCount(int edge) const
double evalArea(const std::array< double, 3 > *coordinates) const
long getFaceVertexId(int face, int vertex) const
void swap(Element &other) noexcept
void setType(ElementType type)
double evalLength(const std::array< double, 3 > *coordinates) const
ConstProxyVector< long > getEdgeVertexIds(int edge) const
int findVertex(long vertexId) const
const ReferenceElementInfo & getInfo() const
bool isThreeDimensional() const
unsigned int getBinarySize() const
ConstProxyVector< int > getEdgeLocalVertexIds(int edge) const
ElementType getFaceType(int face) const
ConstProxyVector< int > getEdgeLocalConnect(int edge) const
ConstProxyVector< long > getVertexIds() const
long getEdgeVertexId(int edge, int vertex) const
ConstProxyVector< int > getFaceLocalVertexIds(int face) const
void initialize(long id, ElementType type, int connectSize=0)
double evalSize(const std::array< double, 3 > *coordinates) const
bool hasSameConnect(const Element &other) const
int getFaceVertexCount(int face) const
const long * getConnect() const
void evalPointProjection(const std::array< double, 3 > &point, const std::array< double, 3 > *coordinates, std::array< double, 3 > *projection, double *distance) const
double evalPointDistance(const std::array< double, 3 > &point, const std::array< double, 3 > *coordinates) const
ConstProxyVector< long > getFaceConnect(int face) const
long getVertexId(int vertex) const
std::array< double, 3 > evalNormal(const std::array< double, 3 > *coordinates, const std::array< double, 3 > &orientation={{0., 0., 1.}}, const std::array< double, 3 > &point={{0.5, 0.5, 0.5}}) const
static void renumberFaceStream(const PiercedStorage< long, long > &map, std::vector< long > *faceStream)
ConstProxyVector< long > getEdgeConnect(int edge) const
void setConnect(std::unique_ptr< long[]> &&connect)
std::array< double, 3 > evalCentroid(const std::array< double, 3 > *coordinates) const
std::vector< long > getFaceStream() const
int renumberVertices(const std::unordered_map< long, long > &map)
int getVertexCount() const
int getConnectSize() const
int getFaceStreamSize() const
static int getFaceStreamPosition(const long *connectivity, int face)
ElementType getEdgeType(int edge) const
Metafunction for generating a pierced storage.
Metafunction for generating a pierced vector.
Metafunction for generating a list of elements that can be either stored in an external vectror or,...
The ReferenceElementInfo class allows to define information about reference elements.
std::ostream & operator<<(std::ostream &, const std::vector< T > &)
The ElementHalfItem::Hasher class allows to create hashes for the half-items.
std::size_t operator()(const ElementHalfItem &item) const
constexpr std::size_t operator()(U &&value) const noexcept