27 m_vertices = (
MFloat**)tmpPointer;
29 for(
MInt i = 0; i < nDim; i++) {
30 tmpPointer = (
void*)((
MFloat**)tmpPointer + 1);
33 for(
MInt i = 0; i < nDim; i++) {
35 m_vertices[i] = (
MFloat*)tmpPointer;
37 tmpPointer = (
void*)((
MFloat*)tmpPointer + nDim);
39 m_normal = (
MFloat*)tmpPointer;
40 tmpPointer = (
void*)((
MFloat*)tmpPointer + nDim);
41 m_minMax = (
MFloat*)tmpPointer;
48 for(
MInt j = 0; j < nDim; j++) {
49 m_minMax[j] = m_vertices[0][j];
50 m_minMax[j + nDim] = m_vertices[0][j];
52 for(
MInt i = 0; i < nDim; i++) {
53 for(
MInt j = 0; j < nDim; j++) {
55 m_minMax[j + nDim] = (m_minMax[j + nDim] < m_vertices[i][j]) ? m_vertices[i][j] : m_minMax[j + nDim];
57 m_minMax[j] = (m_minMax[j] > m_vertices[i][j]) ? m_vertices[i][j] : m_minMax[j];
67 cerr <<
"------------------------------" << endl;
69 IF_CONSTEXPR(nDim == 3) { cerr <<
"M_Normal : " << m_normal[0] <<
" " << m_normal[1] <<
" " << m_normal[2] << endl; }
71 for(
MInt i = 0; i < nDim; i++) {
72 cerr <<
"Vertex " << i <<
": ";
73 for(
MInt j = 0; j < nDim; j++) {
74 cerr << m_vertices[i][j] <<
" ";
78 cerr <<
"Bounding box: " << endl <<
"m_min: ";
80 for(
MInt i = 0; i < nDim; i++) {
81 cerr << m_minMax[i] <<
" ";
84 cerr <<
"Bounding box: " << endl <<
"m_max: ";
86 for(
MInt i = 0; i < nDim; i++) {
87 cerr << m_minMax[i + nDim] <<
" ";
106 using Vec2D = array<MFloat, 2>;
107 using Vec3D = array<MFloat, 3>;
110 IF_CONSTEXPR(nDim == 2) {
114 edge[0] = vertices[2] - vertices[0];
115 edge[1] = vertices[3] - vertices[1];
123 copy(norm.begin(), norm.end(), normal);
125 else IF_CONSTEXPR(nDim == 3) {
126 Vec3D edge0, edge1, norm;
129 edge0[0] = vertices[3] - vertices[0];
130 edge0[1] = vertices[4] - vertices[1];
131 edge0[2] = vertices[5] - vertices[2];
132 edge1[0] = vertices[6] - vertices[0];
133 edge1[1] = vertices[7] - vertices[1];
134 edge1[2] = vertices[8] - vertices[2];
141 copy(norm.begin(), norm.end(), normal);
144 TERMM(1,
"Bad number of dimensions.");
166 for(
MInt dim = 0; dim < nDim; dim++) {
168 for(
MInt vertexId = 0; vertexId < nDim; vertexId++) {
169 centroid[dim] += vertices[(vertexId * nDim) + dim];
171 centroid[dim] /=
static_cast<MFloat>(nDim);
187 IF_CONSTEXPR(nDim == 2) {
189 vertices[0] = m_vertices[0][0];
190 vertices[1] = m_vertices[0][1];
191 vertices[2] = m_vertices[1][0];
192 vertices[3] = m_vertices[1][1];
194 else IF_CONSTEXPR(nDim == 3) {
196 vertices[0] = m_vertices[0][0];
197 vertices[1] = m_vertices[0][1];
198 vertices[2] = m_vertices[0][2];
199 vertices[3] = m_vertices[1][0];
200 vertices[4] = m_vertices[1][1];
201 vertices[5] = m_vertices[1][2];
202 vertices[6] = m_vertices[2][0];
203 vertices[7] = m_vertices[2][1];
204 vertices[8] = m_vertices[2][2];
void calcNormal(const MFloat *const vertices, MFloat *normal) const
Calculates the normal vector from the geometry element vertices.
void allocateElements(void *, void *, MInt &)
void writeElement() const
void calcCentroid(const MFloat *const vertices, MFloat *centroid) const
Calculate the centroid of the geometry element vertices.
void getVertices(MFloat *vertices) const
Return the vertices of the geometry element.
void cross(const T *const u, const T *const v, T *const c)
void normalize(std::array< T, N > &u)