From 53e2e583b9d9a0e89872515b93d4eaa3ca78c82c Mon Sep 17 00:00:00 2001 From: Julien J Tierny Date: Wed, 20 Sep 2023 17:20:46 +0200 Subject: [PATCH 01/12] inlining (fully) implicit `getVertexNeighbor` --- .../ImplicitPreconditions.cpp | 330 ------------------ .../ImplicitPreconditions.h | 327 ++++++++++++++++- .../ImplicitTriangulation.cpp | 138 -------- .../ImplicitTriangulation.h | 137 +++++++- 4 files changed, 457 insertions(+), 475 deletions(-) diff --git a/core/base/implicitTriangulation/ImplicitPreconditions.cpp b/core/base/implicitTriangulation/ImplicitPreconditions.cpp index 1837b2db41..558fc7aed3 100644 --- a/core/base/implicitTriangulation/ImplicitPreconditions.cpp +++ b/core/base/implicitTriangulation/ImplicitPreconditions.cpp @@ -363,333 +363,3 @@ int ttk::ImplicitWithPreconditions::preconditionTetrahedronsInternal() { return 0; } - -ttk::ImplicitTriangulation::VertexPosition - ttk::ImplicitNoPreconditions::getVertexPosition(const SimplexId v) const { - - if(this->dimensionality_ == 1) { - if(v == 0) { - return VertexPosition::LEFT_CORNER_1D; - } else if(v == this->vertexNumber_ - 1) { - return VertexPosition::RIGHT_CORNER_1D; - } - return VertexPosition::CENTER_1D; - } else if(this->dimensionality_ == 2) { - const auto p{this->getVertexCoords(v)}; - if(0 < p[0] and p[0] < this->nbvoxels_[this->Di_]) { - if(0 < p[1] and p[1] < this->nbvoxels_[this->Dj_]) - return VertexPosition::CENTER_2D; - else if(p[1] == 0) - return VertexPosition::TOP_EDGE_2D; // ab - else - return VertexPosition::BOTTOM_EDGE_2D; // cd - } else if(p[0] == 0) { - if(0 < p[1] and p[1] < this->nbvoxels_[this->Dj_]) - return VertexPosition::LEFT_EDGE_2D; // ac - else if(p[1] == 0) - return VertexPosition::TOP_LEFT_CORNER_2D; // a - else - return VertexPosition::BOTTOM_LEFT_CORNER_2D; // c - } else { - if(0 < p[1] and p[1] < this->nbvoxels_[this->Dj_]) - return VertexPosition::RIGHT_EDGE_2D; // bd - else if(p[1] == 0) - return VertexPosition::TOP_RIGHT_CORNER_2D; // b - else - return VertexPosition::BOTTOM_RIGHT_CORNER_2D; // d - } - - } else if(this->dimensionality_ == 3) { - const auto p{this->getVertexCoords(v)}; - if(0 < p[0] and p[0] < this->nbvoxels_[0]) { - if(0 < p[1] and p[1] < this->nbvoxels_[1]) { - if(0 < p[2] and p[2] < this->nbvoxels_[2]) - return VertexPosition::CENTER_3D; - else if(p[2] == 0) - return VertexPosition::FRONT_FACE_3D; // abcd - else - return VertexPosition::BACK_FACE_3D; // efgh - } else if(p[1] == 0) { - if(0 < p[2] and p[2] < this->nbvoxels_[2]) - return VertexPosition::TOP_FACE_3D; // abef - else if(p[2] == 0) - return VertexPosition::TOP_FRONT_EDGE_3D; // ab - else - return VertexPosition::TOP_BACK_EDGE_3D; // ef - } else { - if(0 < p[2] and p[2] < this->nbvoxels_[2]) - return VertexPosition::BOTTOM_FACE_3D; // cdgh - else if(p[2] == 0) - return VertexPosition::BOTTOM_FRONT_EDGE_3D; // cd - else - return VertexPosition::BOTTOM_BACK_EDGE_3D; // gh - } - } else if(p[0] == 0) { - if(0 < p[1] and p[1] < this->nbvoxels_[1]) { - if(0 < p[2] and p[2] < this->nbvoxels_[2]) - return VertexPosition::LEFT_FACE_3D; // aceg - else if(p[2] == 0) - return VertexPosition::LEFT_FRONT_EDGE_3D; // ac - else - return VertexPosition::LEFT_BACK_EDGE_3D; // eg - } else if(p[1] == 0) { - if(0 < p[2] and p[2] < this->nbvoxels_[2]) - return VertexPosition::TOP_LEFT_EDGE_3D; // ae - else if(p[2] == 0) - return VertexPosition::TOP_LEFT_FRONT_CORNER_3D; // a - else - return VertexPosition::TOP_LEFT_BACK_CORNER_3D; // e - } else { - if(0 < p[2] and p[2] < this->nbvoxels_[2]) - return VertexPosition::BOTTOM_LEFT_EDGE_3D; // cg - else if(p[2] == 0) - return VertexPosition::BOTTOM_LEFT_FRONT_CORNER_3D; // c - else - return VertexPosition::BOTTOM_LEFT_BACK_CORNER_3D; // g - } - } else { - if(0 < p[1] and p[1] < this->nbvoxels_[1]) { - if(0 < p[2] and p[2] < this->nbvoxels_[2]) - return VertexPosition::RIGHT_FACE_3D; // bdfh - else if(p[2] == 0) - return VertexPosition::RIGHT_FRONT_EDGE_3D; // bd - else - return VertexPosition::RIGHT_BACK_EDGE_3D; // fh - } else if(p[1] == 0) { - if(0 < p[2] and p[2] < this->nbvoxels_[2]) - return VertexPosition::TOP_RIGHT_EDGE_3D; // bf - else if(p[2] == 0) - return VertexPosition::TOP_RIGHT_FRONT_CORNER_3D; // b - else - return VertexPosition::TOP_RIGHT_BACK_CORNER_3D; // f - } else { - if(0 < p[2] and p[2] < this->nbvoxels_[2]) - return VertexPosition::BOTTOM_RIGHT_EDGE_3D; // dh - else if(p[2] == 0) - return VertexPosition::BOTTOM_RIGHT_FRONT_CORNER_3D; // d - else - return VertexPosition::BOTTOM_RIGHT_BACK_CORNER_3D; // h - } - } - } - return VertexPosition::CENTER_3D; -} - -ttk::ImplicitTriangulation::EdgePosition - ttk::ImplicitNoPreconditions::getEdgePosition(const SimplexId e) const { - std::array p{}; - if(this->dimensionality_ == 3) { - - if(e < this->esetshift_[0]) { - this->edgeToPosition(e, 0, p.data()); - if(p[1] > 0 and p[1] < this->nbvoxels_[1]) { - if(p[2] > 0 and p[2] < this->nbvoxels_[2]) - return EdgePosition::L_xnn_3D; - else if(p[2] == 0) - return EdgePosition::L_xn0_3D; - else - return EdgePosition::L_xnN_3D; - } else if(p[1] == 0) { - if(p[2] > 0 and p[2] < this->nbvoxels_[2]) - return EdgePosition::L_x0n_3D; - else if(p[2] == 0) - return EdgePosition::L_x00_3D; - else - return EdgePosition::L_x0N_3D; - } else { - if(p[2] > 0 and p[2] < this->nbvoxels_[2]) - return EdgePosition::L_xNn_3D; - else if(p[2] == 0) - return EdgePosition::L_xN0_3D; - else - return EdgePosition::L_xNN_3D; - } - } else if(e < this->esetshift_[1]) { - this->edgeToPosition(e, 1, p.data()); - if(p[0] > 0 and p[0] < this->nbvoxels_[0]) { - if(p[2] > 0 and p[2] < this->nbvoxels_[2]) - return EdgePosition::H_nyn_3D; - else if(p[2] == 0) - return EdgePosition::H_ny0_3D; - else - return EdgePosition::H_nyN_3D; - } else if(p[0] == 0) { - if(p[2] > 0 and p[2] < this->nbvoxels_[2]) - return EdgePosition::H_0yn_3D; - else if(p[2] == 0) - return EdgePosition::H_0y0_3D; - else - return EdgePosition::H_0yN_3D; - } else { - if(p[2] > 0 and p[2] < this->nbvoxels_[2]) - return EdgePosition::H_Nyn_3D; - else if(p[2] == 0) - return EdgePosition::H_Ny0_3D; - else - return EdgePosition::H_NyN_3D; - } - } else if(e < this->esetshift_[2]) { - this->edgeToPosition(e, 2, p.data()); - if(p[0] > 0 and p[0] < this->nbvoxels_[0]) { - if(p[1] > 0 and p[1] < this->nbvoxels_[1]) - return EdgePosition::P_nnz_3D; - else if(p[1] == 0) - return EdgePosition::P_n0z_3D; - else - return EdgePosition::P_nNz_3D; - } else if(p[0] == 0) { - if(p[1] > 0 and p[1] < this->nbvoxels_[1]) - return EdgePosition::P_0nz_3D; - else if(p[1] == 0) - return EdgePosition::P_00z_3D; - else - return EdgePosition::P_0Nz_3D; - } else { - if(p[1] > 0 and p[1] < this->nbvoxels_[1]) - return EdgePosition::P_Nnz_3D; - else if(p[1] == 0) - return EdgePosition::P_N0z_3D; - else - return EdgePosition::P_NNz_3D; - } - } else if(e < this->esetshift_[3]) { - this->edgeToPosition(e, 3, p.data()); - if(p[2] > 0 and p[2] < this->nbvoxels_[2]) - return EdgePosition::D1_xyn_3D; - else if(p[2] == 0) - return EdgePosition::D1_xy0_3D; - else - return EdgePosition::D1_xyN_3D; - } else if(e < this->esetshift_[4]) { - this->edgeToPosition(e, 4, p.data()); - if(p[0] > 0 and p[0] < this->nbvoxels_[0]) - return EdgePosition::D2_nyz_3D; - else if(p[0] == 0) - return EdgePosition::D2_0yz_3D; - else - return EdgePosition::D2_Nyz_3D; - } else if(e < this->esetshift_[5]) { - this->edgeToPosition(e, 5, p.data()); - if(p[1] > 0 and p[1] < this->nbvoxels_[1]) - return EdgePosition::D3_xnz_3D; - else if(p[1] == 0) - return EdgePosition::D3_x0z_3D; - else - return EdgePosition::D3_xNz_3D; - } else if(e < this->esetshift_[6]) { - return EdgePosition::D4_3D; - } - - } else if(this->dimensionality_ == 2) { - if(e < this->esetshift_[0]) { - this->edgeToPosition2d(e, 0, p.data()); - if(p[1] > 0 and p[1] < this->nbvoxels_[this->Dj_]) - return EdgePosition::L_xn_2D; - else if(p[1] == 0) - return EdgePosition::L_x0_2D; - else - return EdgePosition::L_xN_2D; - } else if(e < this->esetshift_[1]) { - this->edgeToPosition2d(e, 1, p.data()); - if(p[0] > 0 and p[0] < this->nbvoxels_[this->Di_]) - return EdgePosition::H_ny_2D; - else if(p[0] == 0) - return EdgePosition::H_0y_2D; - else - return EdgePosition::H_Ny_2D; - } else if(e < this->esetshift_[2]) { - return EdgePosition::D1_2D; - } - - } else if(this->dimensionality_ == 1) { - if(e == 0) { - return EdgePosition::FIRST_EDGE_1D; - } else if(e == this->edgeNumber_ - 1) - return EdgePosition::CENTER_1D; - } else { - return EdgePosition::LAST_EDGE_1D; - } - - return EdgePosition::CENTER_1D; -} - -std::array - ttk::ImplicitNoPreconditions::getEdgeCoords(const SimplexId e) const { - std::array p{}; - if(this->dimensionality_ == 3) { - if(e < this->esetshift_[0]) { - this->edgeToPosition(e, 0, p.data()); - } else if(e < this->esetshift_[1]) { - this->edgeToPosition(e, 1, p.data()); - } else if(e < this->esetshift_[2]) { - this->edgeToPosition(e, 2, p.data()); - } else if(e < this->esetshift_[3]) { - this->edgeToPosition(e, 3, p.data()); - } else if(e < this->esetshift_[4]) { - this->edgeToPosition(e, 4, p.data()); - } else if(e < this->esetshift_[5]) { - this->edgeToPosition(e, 5, p.data()); - } else if(e < this->esetshift_[6]) { - this->edgeToPosition(e, 6, p.data()); - } - - } else if(this->dimensionality_ == 2) { - if(e < this->esetshift_[0]) { - this->edgeToPosition2d(e, 0, p.data()); - } else if(e < this->esetshift_[1]) { - this->edgeToPosition2d(e, 1, p.data()); - } else if(e < this->esetshift_[2]) { - this->edgeToPosition2d(e, 2, p.data()); - } - } - return p; -} - -ttk::ImplicitTriangulation::TrianglePosition - ttk::ImplicitNoPreconditions::getTrianglePosition(const SimplexId t) const { - if(this->dimensionality_ == 2) { - if(t % 2 == 0) { - return TrianglePosition::TOP_2D; - } else { - return TrianglePosition::BOTTOM_2D; - } - } else if(this->dimensionality_ == 3) { - if(t < this->tsetshift_[0]) { - return TrianglePosition::F_3D; - } else if(t < this->tsetshift_[1]) { - return TrianglePosition::H_3D; - } else if(t < this->tsetshift_[2]) { - return TrianglePosition::C_3D; - } else if(t < this->tsetshift_[3]) { - return TrianglePosition::D1_3D; - } else if(t < this->tsetshift_[4]) { - return TrianglePosition::D2_3D; - } else if(t < this->tsetshift_[5]) { - return TrianglePosition::D3_3D; - } - } - return TrianglePosition::C_3D; -} - -std::array - ttk::ImplicitNoPreconditions::getTriangleCoords(const SimplexId t) const { - std::array p{}; - if(this->dimensionality_ == 2) { - this->triangleToPosition2d(t, p.data()); - } else if(this->dimensionality_ == 3) { - if(t < this->tsetshift_[0]) { - this->triangleToPosition(t, 0, p.data()); - } else if(t < this->tsetshift_[1]) { - this->triangleToPosition(t, 1, p.data()); - } else if(t < this->tsetshift_[2]) { - this->triangleToPosition(t, 2, p.data()); - } else if(t < this->tsetshift_[3]) { - this->triangleToPosition(t, 3, p.data()); - } else if(t < this->tsetshift_[4]) { - this->triangleToPosition(t, 4, p.data()); - } else if(t < this->tsetshift_[5]) { - this->triangleToPosition(t, 5, p.data()); - } - } - return p; -} diff --git a/core/base/implicitTriangulation/ImplicitPreconditions.h b/core/base/implicitTriangulation/ImplicitPreconditions.h index aee37842ed..ed92bd8a90 100644 --- a/core/base/implicitTriangulation/ImplicitPreconditions.h +++ b/core/base/implicitTriangulation/ImplicitPreconditions.h @@ -96,7 +96,114 @@ namespace ttk { return 0; } - VertexPosition getVertexPosition(const SimplexId v) const; + inline VertexPosition getVertexPosition(const SimplexId v) const { + if(this->dimensionality_ == 1) { + if(v == 0) { + return VertexPosition::LEFT_CORNER_1D; + } else if(v == this->vertexNumber_ - 1) { + return VertexPosition::RIGHT_CORNER_1D; + } + return VertexPosition::CENTER_1D; + } else if(this->dimensionality_ == 2) { + const auto p{this->getVertexCoords(v)}; + if(0 < p[0] and p[0] < this->nbvoxels_[this->Di_]) { + if(0 < p[1] and p[1] < this->nbvoxels_[this->Dj_]) + return VertexPosition::CENTER_2D; + else if(p[1] == 0) + return VertexPosition::TOP_EDGE_2D; // ab + else + return VertexPosition::BOTTOM_EDGE_2D; // cd + } else if(p[0] == 0) { + if(0 < p[1] and p[1] < this->nbvoxels_[this->Dj_]) + return VertexPosition::LEFT_EDGE_2D; // ac + else if(p[1] == 0) + return VertexPosition::TOP_LEFT_CORNER_2D; // a + else + return VertexPosition::BOTTOM_LEFT_CORNER_2D; // c + } else { + if(0 < p[1] and p[1] < this->nbvoxels_[this->Dj_]) + return VertexPosition::RIGHT_EDGE_2D; // bd + else if(p[1] == 0) + return VertexPosition::TOP_RIGHT_CORNER_2D; // b + else + return VertexPosition::BOTTOM_RIGHT_CORNER_2D; // d + } + + } else if(this->dimensionality_ == 3) { + const auto p{this->getVertexCoords(v)}; + if(0 < p[0] and p[0] < this->nbvoxels_[0]) { + if(0 < p[1] and p[1] < this->nbvoxels_[1]) { + if(0 < p[2] and p[2] < this->nbvoxels_[2]) + return VertexPosition::CENTER_3D; + else if(p[2] == 0) + return VertexPosition::FRONT_FACE_3D; // abcd + else + return VertexPosition::BACK_FACE_3D; // efgh + } else if(p[1] == 0) { + if(0 < p[2] and p[2] < this->nbvoxels_[2]) + return VertexPosition::TOP_FACE_3D; // abef + else if(p[2] == 0) + return VertexPosition::TOP_FRONT_EDGE_3D; // ab + else + return VertexPosition::TOP_BACK_EDGE_3D; // ef + } else { + if(0 < p[2] and p[2] < this->nbvoxels_[2]) + return VertexPosition::BOTTOM_FACE_3D; // cdgh + else if(p[2] == 0) + return VertexPosition::BOTTOM_FRONT_EDGE_3D; // cd + else + return VertexPosition::BOTTOM_BACK_EDGE_3D; // gh + } + } else if(p[0] == 0) { + if(0 < p[1] and p[1] < this->nbvoxels_[1]) { + if(0 < p[2] and p[2] < this->nbvoxels_[2]) + return VertexPosition::LEFT_FACE_3D; // aceg + else if(p[2] == 0) + return VertexPosition::LEFT_FRONT_EDGE_3D; // ac + else + return VertexPosition::LEFT_BACK_EDGE_3D; // eg + } else if(p[1] == 0) { + if(0 < p[2] and p[2] < this->nbvoxels_[2]) + return VertexPosition::TOP_LEFT_EDGE_3D; // ae + else if(p[2] == 0) + return VertexPosition::TOP_LEFT_FRONT_CORNER_3D; // a + else + return VertexPosition::TOP_LEFT_BACK_CORNER_3D; // e + } else { + if(0 < p[2] and p[2] < this->nbvoxels_[2]) + return VertexPosition::BOTTOM_LEFT_EDGE_3D; // cg + else if(p[2] == 0) + return VertexPosition::BOTTOM_LEFT_FRONT_CORNER_3D; // c + else + return VertexPosition::BOTTOM_LEFT_BACK_CORNER_3D; // g + } + } else { + if(0 < p[1] and p[1] < this->nbvoxels_[1]) { + if(0 < p[2] and p[2] < this->nbvoxels_[2]) + return VertexPosition::RIGHT_FACE_3D; // bdfh + else if(p[2] == 0) + return VertexPosition::RIGHT_FRONT_EDGE_3D; // bd + else + return VertexPosition::RIGHT_BACK_EDGE_3D; // fh + } else if(p[1] == 0) { + if(0 < p[2] and p[2] < this->nbvoxels_[2]) + return VertexPosition::TOP_RIGHT_EDGE_3D; // bf + else if(p[2] == 0) + return VertexPosition::TOP_RIGHT_FRONT_CORNER_3D; // b + else + return VertexPosition::TOP_RIGHT_BACK_CORNER_3D; // f + } else { + if(0 < p[2] and p[2] < this->nbvoxels_[2]) + return VertexPosition::BOTTOM_RIGHT_EDGE_3D; // dh + else if(p[2] == 0) + return VertexPosition::BOTTOM_RIGHT_FRONT_CORNER_3D; // d + else + return VertexPosition::BOTTOM_RIGHT_BACK_CORNER_3D; // h + } + } + } + return VertexPosition::CENTER_3D; + } inline std::array getVertexCoords(const SimplexId v) const { std::array p{}; @@ -108,10 +215,220 @@ namespace ttk { return p; } - EdgePosition getEdgePosition(const SimplexId e) const; - std::array getEdgeCoords(const SimplexId e) const; - TrianglePosition getTrianglePosition(const SimplexId t) const; - std::array getTriangleCoords(const SimplexId t) const; + inline EdgePosition getEdgePosition(const SimplexId e) const { + std::array p{}; + if(this->dimensionality_ == 3) { + + if(e < this->esetshift_[0]) { + this->edgeToPosition(e, 0, p.data()); + if(p[1] > 0 and p[1] < this->nbvoxels_[1]) { + if(p[2] > 0 and p[2] < this->nbvoxels_[2]) + return EdgePosition::L_xnn_3D; + else if(p[2] == 0) + return EdgePosition::L_xn0_3D; + else + return EdgePosition::L_xnN_3D; + } else if(p[1] == 0) { + if(p[2] > 0 and p[2] < this->nbvoxels_[2]) + return EdgePosition::L_x0n_3D; + else if(p[2] == 0) + return EdgePosition::L_x00_3D; + else + return EdgePosition::L_x0N_3D; + } else { + if(p[2] > 0 and p[2] < this->nbvoxels_[2]) + return EdgePosition::L_xNn_3D; + else if(p[2] == 0) + return EdgePosition::L_xN0_3D; + else + return EdgePosition::L_xNN_3D; + } + } else if(e < this->esetshift_[1]) { + this->edgeToPosition(e, 1, p.data()); + if(p[0] > 0 and p[0] < this->nbvoxels_[0]) { + if(p[2] > 0 and p[2] < this->nbvoxels_[2]) + return EdgePosition::H_nyn_3D; + else if(p[2] == 0) + return EdgePosition::H_ny0_3D; + else + return EdgePosition::H_nyN_3D; + } else if(p[0] == 0) { + if(p[2] > 0 and p[2] < this->nbvoxels_[2]) + return EdgePosition::H_0yn_3D; + else if(p[2] == 0) + return EdgePosition::H_0y0_3D; + else + return EdgePosition::H_0yN_3D; + } else { + if(p[2] > 0 and p[2] < this->nbvoxels_[2]) + return EdgePosition::H_Nyn_3D; + else if(p[2] == 0) + return EdgePosition::H_Ny0_3D; + else + return EdgePosition::H_NyN_3D; + } + } else if(e < this->esetshift_[2]) { + this->edgeToPosition(e, 2, p.data()); + if(p[0] > 0 and p[0] < this->nbvoxels_[0]) { + if(p[1] > 0 and p[1] < this->nbvoxels_[1]) + return EdgePosition::P_nnz_3D; + else if(p[1] == 0) + return EdgePosition::P_n0z_3D; + else + return EdgePosition::P_nNz_3D; + } else if(p[0] == 0) { + if(p[1] > 0 and p[1] < this->nbvoxels_[1]) + return EdgePosition::P_0nz_3D; + else if(p[1] == 0) + return EdgePosition::P_00z_3D; + else + return EdgePosition::P_0Nz_3D; + } else { + if(p[1] > 0 and p[1] < this->nbvoxels_[1]) + return EdgePosition::P_Nnz_3D; + else if(p[1] == 0) + return EdgePosition::P_N0z_3D; + else + return EdgePosition::P_NNz_3D; + } + } else if(e < this->esetshift_[3]) { + this->edgeToPosition(e, 3, p.data()); + if(p[2] > 0 and p[2] < this->nbvoxels_[2]) + return EdgePosition::D1_xyn_3D; + else if(p[2] == 0) + return EdgePosition::D1_xy0_3D; + else + return EdgePosition::D1_xyN_3D; + } else if(e < this->esetshift_[4]) { + this->edgeToPosition(e, 4, p.data()); + if(p[0] > 0 and p[0] < this->nbvoxels_[0]) + return EdgePosition::D2_nyz_3D; + else if(p[0] == 0) + return EdgePosition::D2_0yz_3D; + else + return EdgePosition::D2_Nyz_3D; + } else if(e < this->esetshift_[5]) { + this->edgeToPosition(e, 5, p.data()); + if(p[1] > 0 and p[1] < this->nbvoxels_[1]) + return EdgePosition::D3_xnz_3D; + else if(p[1] == 0) + return EdgePosition::D3_x0z_3D; + else + return EdgePosition::D3_xNz_3D; + } else if(e < this->esetshift_[6]) { + return EdgePosition::D4_3D; + } + + } else if(this->dimensionality_ == 2) { + if(e < this->esetshift_[0]) { + this->edgeToPosition2d(e, 0, p.data()); + if(p[1] > 0 and p[1] < this->nbvoxels_[this->Dj_]) + return EdgePosition::L_xn_2D; + else if(p[1] == 0) + return EdgePosition::L_x0_2D; + else + return EdgePosition::L_xN_2D; + } else if(e < this->esetshift_[1]) { + this->edgeToPosition2d(e, 1, p.data()); + if(p[0] > 0 and p[0] < this->nbvoxels_[this->Di_]) + return EdgePosition::H_ny_2D; + else if(p[0] == 0) + return EdgePosition::H_0y_2D; + else + return EdgePosition::H_Ny_2D; + } else if(e < this->esetshift_[2]) { + return EdgePosition::D1_2D; + } + + } else if(this->dimensionality_ == 1) { + if(e == 0) { + return EdgePosition::FIRST_EDGE_1D; + } else if(e == this->edgeNumber_ - 1) + return EdgePosition::CENTER_1D; + } else { + return EdgePosition::LAST_EDGE_1D; + } + + return EdgePosition::CENTER_1D; + } + + inline std::array getEdgeCoords(const SimplexId e) const { + std::array p{}; + if(this->dimensionality_ == 3) { + if(e < this->esetshift_[0]) { + this->edgeToPosition(e, 0, p.data()); + } else if(e < this->esetshift_[1]) { + this->edgeToPosition(e, 1, p.data()); + } else if(e < this->esetshift_[2]) { + this->edgeToPosition(e, 2, p.data()); + } else if(e < this->esetshift_[3]) { + this->edgeToPosition(e, 3, p.data()); + } else if(e < this->esetshift_[4]) { + this->edgeToPosition(e, 4, p.data()); + } else if(e < this->esetshift_[5]) { + this->edgeToPosition(e, 5, p.data()); + } else if(e < this->esetshift_[6]) { + this->edgeToPosition(e, 6, p.data()); + } + + } else if(this->dimensionality_ == 2) { + if(e < this->esetshift_[0]) { + this->edgeToPosition2d(e, 0, p.data()); + } else if(e < this->esetshift_[1]) { + this->edgeToPosition2d(e, 1, p.data()); + } else if(e < this->esetshift_[2]) { + this->edgeToPosition2d(e, 2, p.data()); + } + } + return p; + } + + inline TrianglePosition getTrianglePosition(const SimplexId t) const { + if(this->dimensionality_ == 2) { + if(t % 2 == 0) { + return TrianglePosition::TOP_2D; + } else { + return TrianglePosition::BOTTOM_2D; + } + } else if(this->dimensionality_ == 3) { + if(t < this->tsetshift_[0]) { + return TrianglePosition::F_3D; + } else if(t < this->tsetshift_[1]) { + return TrianglePosition::H_3D; + } else if(t < this->tsetshift_[2]) { + return TrianglePosition::C_3D; + } else if(t < this->tsetshift_[3]) { + return TrianglePosition::D1_3D; + } else if(t < this->tsetshift_[4]) { + return TrianglePosition::D2_3D; + } else if(t < this->tsetshift_[5]) { + return TrianglePosition::D3_3D; + } + } + return TrianglePosition::C_3D; + } + + inline std::array getTriangleCoords(const SimplexId t) const { + std::array p{}; + if(this->dimensionality_ == 2) { + this->triangleToPosition2d(t, p.data()); + } else if(this->dimensionality_ == 3) { + if(t < this->tsetshift_[0]) { + this->triangleToPosition(t, 0, p.data()); + } else if(t < this->tsetshift_[1]) { + this->triangleToPosition(t, 1, p.data()); + } else if(t < this->tsetshift_[2]) { + this->triangleToPosition(t, 2, p.data()); + } else if(t < this->tsetshift_[3]) { + this->triangleToPosition(t, 3, p.data()); + } else if(t < this->tsetshift_[4]) { + this->triangleToPosition(t, 4, p.data()); + } else if(t < this->tsetshift_[5]) { + this->triangleToPosition(t, 5, p.data()); + } + } + return p; + } inline std::array getTetrahedronCoords(const SimplexId t) const { diff --git a/core/base/implicitTriangulation/ImplicitTriangulation.cpp b/core/base/implicitTriangulation/ImplicitTriangulation.cpp index 0b00c5db8e..21b1edb2ee 100644 --- a/core/base/implicitTriangulation/ImplicitTriangulation.cpp +++ b/core/base/implicitTriangulation/ImplicitTriangulation.cpp @@ -357,144 +357,6 @@ bool ImplicitTriangulation::TTK_TRIANGULATION_INTERNAL(isTriangleOnBoundary)( return false; } -template -int ImplicitTriangulationCRTP::TTK_TRIANGULATION_INTERNAL( - getVertexNeighbor)(const SimplexId &vertexId, - const int &localNeighborId, - SimplexId &neighborId) const { - -#ifndef TTK_ENABLE_KAMIKAZE - if(localNeighborId < 0 - or localNeighborId >= getVertexNeighborNumber(vertexId)) - return -1; -#endif // !TTK_ENABLE_KAMIKAZE - - switch(this->underlying().getVertexPosition(vertexId)) { - case VertexPosition::CENTER_3D: - neighborId = vertexId + this->vertexNeighborABCDEFGH_[localNeighborId]; - break; - case VertexPosition::FRONT_FACE_3D: - neighborId = vertexId + this->vertexNeighborABCD_[localNeighborId]; - break; - case VertexPosition::BACK_FACE_3D: - neighborId = vertexId + this->vertexNeighborEFGH_[localNeighborId]; - break; - case VertexPosition::TOP_FACE_3D: - neighborId = vertexId + this->vertexNeighborAEFB_[localNeighborId]; - break; - case VertexPosition::BOTTOM_FACE_3D: - neighborId = vertexId + this->vertexNeighborGHDC_[localNeighborId]; - break; - case VertexPosition::LEFT_FACE_3D: - neighborId = vertexId + this->vertexNeighborAEGC_[localNeighborId]; - break; - case VertexPosition::RIGHT_FACE_3D: - neighborId = vertexId + this->vertexNeighborBFHD_[localNeighborId]; - break; - case VertexPosition::TOP_FRONT_EDGE_3D: // ab - neighborId = vertexId + this->vertexNeighborAB_[localNeighborId]; - break; - case VertexPosition::BOTTOM_FRONT_EDGE_3D: // cd - neighborId = vertexId + this->vertexNeighborCD_[localNeighborId]; - break; - case VertexPosition::LEFT_FRONT_EDGE_3D: // ac - neighborId = vertexId + this->vertexNeighborAC_[localNeighborId]; - break; - case VertexPosition::RIGHT_FRONT_EDGE_3D: // bd - neighborId = vertexId + this->vertexNeighborBD_[localNeighborId]; - break; - case VertexPosition::TOP_BACK_EDGE_3D: // ef - neighborId = vertexId + this->vertexNeighborEF_[localNeighborId]; - break; - case VertexPosition::BOTTOM_BACK_EDGE_3D: // gh - neighborId = vertexId + this->vertexNeighborGH_[localNeighborId]; - break; - case VertexPosition::LEFT_BACK_EDGE_3D: // eg - neighborId = vertexId + this->vertexNeighborEG_[localNeighborId]; - break; - case VertexPosition::RIGHT_BACK_EDGE_3D: // fh - neighborId = vertexId + this->vertexNeighborFH_[localNeighborId]; - break; - case VertexPosition::TOP_LEFT_EDGE_3D: // ae - neighborId = vertexId + this->vertexNeighborAE_[localNeighborId]; - break; - case VertexPosition::TOP_RIGHT_EDGE_3D: // bf - neighborId = vertexId + this->vertexNeighborBF_[localNeighborId]; - break; - case VertexPosition::BOTTOM_LEFT_EDGE_3D: // cg - neighborId = vertexId + this->vertexNeighborCG_[localNeighborId]; - break; - case VertexPosition::BOTTOM_RIGHT_EDGE_3D: // dh - neighborId = vertexId + this->vertexNeighborDH_[localNeighborId]; - break; - case VertexPosition::TOP_LEFT_FRONT_CORNER_3D: // a - neighborId = vertexId + this->vertexNeighborA_[localNeighborId]; - break; - case VertexPosition::TOP_RIGHT_FRONT_CORNER_3D: // b - neighborId = vertexId + this->vertexNeighborB_[localNeighborId]; - break; - case VertexPosition::BOTTOM_LEFT_FRONT_CORNER_3D: // c - neighborId = vertexId + this->vertexNeighborC_[localNeighborId]; - break; - case VertexPosition::BOTTOM_RIGHT_FRONT_CORNER_3D: // d - neighborId = vertexId + this->vertexNeighborD_[localNeighborId]; - break; - case VertexPosition::TOP_LEFT_BACK_CORNER_3D: // e - neighborId = vertexId + this->vertexNeighborE_[localNeighborId]; - break; - case VertexPosition::TOP_RIGHT_BACK_CORNER_3D: // f - neighborId = vertexId + this->vertexNeighborF_[localNeighborId]; - break; - case VertexPosition::BOTTOM_LEFT_BACK_CORNER_3D: // g - neighborId = vertexId + this->vertexNeighborG_[localNeighborId]; - break; - case VertexPosition::BOTTOM_RIGHT_BACK_CORNER_3D: // h - neighborId = vertexId + this->vertexNeighborH_[localNeighborId]; - break; - case VertexPosition::CENTER_2D: - neighborId = vertexId + this->vertexNeighbor2dABCD_[localNeighborId]; - break; - case VertexPosition::TOP_EDGE_2D: - neighborId = vertexId + this->vertexNeighbor2dAB_[localNeighborId]; - break; - case VertexPosition::BOTTOM_EDGE_2D: - neighborId = vertexId + this->vertexNeighbor2dCD_[localNeighborId]; - break; - case VertexPosition::LEFT_EDGE_2D: - neighborId = vertexId + this->vertexNeighbor2dAC_[localNeighborId]; - break; - case VertexPosition::RIGHT_EDGE_2D: - neighborId = vertexId + this->vertexNeighbor2dBD_[localNeighborId]; - break; - case VertexPosition::TOP_LEFT_CORNER_2D: // a - neighborId = vertexId + this->vertexNeighbor2dA_[localNeighborId]; - break; - case VertexPosition::TOP_RIGHT_CORNER_2D: // b - neighborId = vertexId + this->vertexNeighbor2dB_[localNeighborId]; - break; - case VertexPosition::BOTTOM_LEFT_CORNER_2D: // c - neighborId = vertexId + this->vertexNeighbor2dC_[localNeighborId]; - break; - case VertexPosition::BOTTOM_RIGHT_CORNER_2D: // d - neighborId = vertexId + this->vertexNeighbor2dD_[localNeighborId]; - break; - case VertexPosition::CENTER_1D: - neighborId = (localNeighborId == 0 ? vertexId + 1 : vertexId - 1); - break; - case VertexPosition::LEFT_CORNER_1D: - neighborId = vertexId + 1; - break; - case VertexPosition::RIGHT_CORNER_1D: - neighborId = vertexId - 1; - break; - default: - neighborId = -1; - break; - } - - return 0; -} - const vector> * ImplicitTriangulation::TTK_TRIANGULATION_INTERNAL(getVertexNeighbors)() { if(vertexNeighborList_.empty()) { diff --git a/core/base/implicitTriangulation/ImplicitTriangulation.h b/core/base/implicitTriangulation/ImplicitTriangulation.h index a8f32244d8..daa8f69d75 100644 --- a/core/base/implicitTriangulation/ImplicitTriangulation.h +++ b/core/base/implicitTriangulation/ImplicitTriangulation.h @@ -918,10 +918,143 @@ namespace ttk { bool TTK_TRIANGULATION_INTERNAL(isEdgeOnBoundary)( const SimplexId &edgeId) const override; - int TTK_TRIANGULATION_INTERNAL(getVertexNeighbor)( + inline int TTK_TRIANGULATION_INTERNAL(getVertexNeighbor)( const SimplexId &vertexId, const int &localNeighborId, - SimplexId &neighborId) const override; + SimplexId &neighborId) const override { + +#ifndef TTK_ENABLE_KAMIKAZE + if(localNeighborId < 0 + or localNeighborId >= getVertexNeighborNumber(vertexId)) + return -1; +#endif // !TTK_ENABLE_KAMIKAZE + + switch(this->underlying().getVertexPosition(vertexId)) { + case VertexPosition::CENTER_3D: + neighborId + = vertexId + this->vertexNeighborABCDEFGH_[localNeighborId]; + break; + case VertexPosition::FRONT_FACE_3D: + neighborId = vertexId + this->vertexNeighborABCD_[localNeighborId]; + break; + case VertexPosition::BACK_FACE_3D: + neighborId = vertexId + this->vertexNeighborEFGH_[localNeighborId]; + break; + case VertexPosition::TOP_FACE_3D: + neighborId = vertexId + this->vertexNeighborAEFB_[localNeighborId]; + break; + case VertexPosition::BOTTOM_FACE_3D: + neighborId = vertexId + this->vertexNeighborGHDC_[localNeighborId]; + break; + case VertexPosition::LEFT_FACE_3D: + neighborId = vertexId + this->vertexNeighborAEGC_[localNeighborId]; + break; + case VertexPosition::RIGHT_FACE_3D: + neighborId = vertexId + this->vertexNeighborBFHD_[localNeighborId]; + break; + case VertexPosition::TOP_FRONT_EDGE_3D: // ab + neighborId = vertexId + this->vertexNeighborAB_[localNeighborId]; + break; + case VertexPosition::BOTTOM_FRONT_EDGE_3D: // cd + neighborId = vertexId + this->vertexNeighborCD_[localNeighborId]; + break; + case VertexPosition::LEFT_FRONT_EDGE_3D: // ac + neighborId = vertexId + this->vertexNeighborAC_[localNeighborId]; + break; + case VertexPosition::RIGHT_FRONT_EDGE_3D: // bd + neighborId = vertexId + this->vertexNeighborBD_[localNeighborId]; + break; + case VertexPosition::TOP_BACK_EDGE_3D: // ef + neighborId = vertexId + this->vertexNeighborEF_[localNeighborId]; + break; + case VertexPosition::BOTTOM_BACK_EDGE_3D: // gh + neighborId = vertexId + this->vertexNeighborGH_[localNeighborId]; + break; + case VertexPosition::LEFT_BACK_EDGE_3D: // eg + neighborId = vertexId + this->vertexNeighborEG_[localNeighborId]; + break; + case VertexPosition::RIGHT_BACK_EDGE_3D: // fh + neighborId = vertexId + this->vertexNeighborFH_[localNeighborId]; + break; + case VertexPosition::TOP_LEFT_EDGE_3D: // ae + neighborId = vertexId + this->vertexNeighborAE_[localNeighborId]; + break; + case VertexPosition::TOP_RIGHT_EDGE_3D: // bf + neighborId = vertexId + this->vertexNeighborBF_[localNeighborId]; + break; + case VertexPosition::BOTTOM_LEFT_EDGE_3D: // cg + neighborId = vertexId + this->vertexNeighborCG_[localNeighborId]; + break; + case VertexPosition::BOTTOM_RIGHT_EDGE_3D: // dh + neighborId = vertexId + this->vertexNeighborDH_[localNeighborId]; + break; + case VertexPosition::TOP_LEFT_FRONT_CORNER_3D: // a + neighborId = vertexId + this->vertexNeighborA_[localNeighborId]; + break; + case VertexPosition::TOP_RIGHT_FRONT_CORNER_3D: // b + neighborId = vertexId + this->vertexNeighborB_[localNeighborId]; + break; + case VertexPosition::BOTTOM_LEFT_FRONT_CORNER_3D: // c + neighborId = vertexId + this->vertexNeighborC_[localNeighborId]; + break; + case VertexPosition::BOTTOM_RIGHT_FRONT_CORNER_3D: // d + neighborId = vertexId + this->vertexNeighborD_[localNeighborId]; + break; + case VertexPosition::TOP_LEFT_BACK_CORNER_3D: // e + neighborId = vertexId + this->vertexNeighborE_[localNeighborId]; + break; + case VertexPosition::TOP_RIGHT_BACK_CORNER_3D: // f + neighborId = vertexId + this->vertexNeighborF_[localNeighborId]; + break; + case VertexPosition::BOTTOM_LEFT_BACK_CORNER_3D: // g + neighborId = vertexId + this->vertexNeighborG_[localNeighborId]; + break; + case VertexPosition::BOTTOM_RIGHT_BACK_CORNER_3D: // h + neighborId = vertexId + this->vertexNeighborH_[localNeighborId]; + break; + case VertexPosition::CENTER_2D: + neighborId = vertexId + this->vertexNeighbor2dABCD_[localNeighborId]; + break; + case VertexPosition::TOP_EDGE_2D: + neighborId = vertexId + this->vertexNeighbor2dAB_[localNeighborId]; + break; + case VertexPosition::BOTTOM_EDGE_2D: + neighborId = vertexId + this->vertexNeighbor2dCD_[localNeighborId]; + break; + case VertexPosition::LEFT_EDGE_2D: + neighborId = vertexId + this->vertexNeighbor2dAC_[localNeighborId]; + break; + case VertexPosition::RIGHT_EDGE_2D: + neighborId = vertexId + this->vertexNeighbor2dBD_[localNeighborId]; + break; + case VertexPosition::TOP_LEFT_CORNER_2D: // a + neighborId = vertexId + this->vertexNeighbor2dA_[localNeighborId]; + break; + case VertexPosition::TOP_RIGHT_CORNER_2D: // b + neighborId = vertexId + this->vertexNeighbor2dB_[localNeighborId]; + break; + case VertexPosition::BOTTOM_LEFT_CORNER_2D: // c + neighborId = vertexId + this->vertexNeighbor2dC_[localNeighborId]; + break; + case VertexPosition::BOTTOM_RIGHT_CORNER_2D: // d + neighborId = vertexId + this->vertexNeighbor2dD_[localNeighborId]; + break; + case VertexPosition::CENTER_1D: + neighborId = (localNeighborId == 0 ? vertexId + 1 : vertexId - 1); + break; + case VertexPosition::LEFT_CORNER_1D: + neighborId = vertexId + 1; + break; + case VertexPosition::RIGHT_CORNER_1D: + neighborId = vertexId - 1; + break; + default: + neighborId = -1; + break; + } + + return 0; + } int getVertexEdgeInternal(const SimplexId &vertexId, const int &id, From a53067d9dccee9f6e7264a3606aefe7175805610 Mon Sep 17 00:00:00 2001 From: Julien Tierny Date: Thu, 21 Sep 2023 08:54:53 +0200 Subject: [PATCH 02/12] further in-lining for the implicit triangulation --- .../connectedComponents/ConnectedComponents.h | 2 +- core/base/fiberSurface/FiberSurface.h | 2 +- .../ImplicitTriangulation.cpp | 1302 ---------------- .../ImplicitTriangulation.h | 1324 ++++++++++++++++- 4 files changed, 1273 insertions(+), 1357 deletions(-) diff --git a/core/base/connectedComponents/ConnectedComponents.h b/core/base/connectedComponents/ConnectedComponents.h index 6598487015..7d99580a23 100644 --- a/core/base/connectedComponents/ConnectedComponents.h +++ b/core/base/connectedComponents/ConnectedComponents.h @@ -63,7 +63,7 @@ namespace ttk { TID id = seed; float size = 0; - float x, y, z; + float x = 0, y = 0, z = 0; float center[3] = {0, 0, 0}; while(!stack.empty()) { diff --git a/core/base/fiberSurface/FiberSurface.h b/core/base/fiberSurface/FiberSurface.h index a292602d83..2f901f01e7 100644 --- a/core/base/fiberSurface/FiberSurface.h +++ b/core/base/fiberSurface/FiberSurface.h @@ -764,7 +764,7 @@ inline int ttk::FiberSurface::computeCase0( Geometry::computeBarycentricCoordinates( p0.data(), p1.data(), p.data(), baryCentrics, 2); - float pA[3], pB[3]; + float pA[3] = {0, 0, 0}, pB[3] = {0, 0, 0}; if(triangulation) { triangulation->getVertexPoint(vertexId0, pA[0], pA[1], pA[2]); triangulation->getVertexPoint(vertexId1, pB[0], pB[1], pB[2]); diff --git a/core/base/implicitTriangulation/ImplicitTriangulation.cpp b/core/base/implicitTriangulation/ImplicitTriangulation.cpp index 21b1edb2ee..02e8394ad8 100644 --- a/core/base/implicitTriangulation/ImplicitTriangulation.cpp +++ b/core/base/implicitTriangulation/ImplicitTriangulation.cpp @@ -5,57 +5,6 @@ using namespace std; using namespace ttk; -#define CASE_EDGE_POSITION_L_3D \ - case EdgePosition::L_xnn_3D: \ - case EdgePosition::L_xn0_3D: \ - case EdgePosition::L_xnN_3D: \ - case EdgePosition::L_x0n_3D: \ - case EdgePosition::L_x00_3D: \ - case EdgePosition::L_x0N_3D: \ - case EdgePosition::L_xNn_3D: \ - case EdgePosition::L_xN0_3D: \ - case EdgePosition::L_xNN_3D -#define CASE_EDGE_POSITION_H_3D \ - case EdgePosition::H_nyn_3D: \ - case EdgePosition::H_ny0_3D: \ - case EdgePosition::H_nyN_3D: \ - case EdgePosition::H_0yn_3D: \ - case EdgePosition::H_0y0_3D: \ - case EdgePosition::H_0yN_3D: \ - case EdgePosition::H_Nyn_3D: \ - case EdgePosition::H_Ny0_3D: \ - case EdgePosition::H_NyN_3D -#define CASE_EDGE_POSITION_P_3D \ - case EdgePosition::P_nnz_3D: \ - case EdgePosition::P_n0z_3D: \ - case EdgePosition::P_nNz_3D: \ - case EdgePosition::P_0nz_3D: \ - case EdgePosition::P_00z_3D: \ - case EdgePosition::P_0Nz_3D: \ - case EdgePosition::P_Nnz_3D: \ - case EdgePosition::P_N0z_3D: \ - case EdgePosition::P_NNz_3D -#define CASE_EDGE_POSITION_D1_3D \ - case EdgePosition::D1_xyn_3D: \ - case EdgePosition::D1_xy0_3D: \ - case EdgePosition::D1_xyN_3D -#define CASE_EDGE_POSITION_D2_3D \ - case EdgePosition::D2_nyz_3D: \ - case EdgePosition::D2_0yz_3D: \ - case EdgePosition::D2_Nyz_3D -#define CASE_EDGE_POSITION_D3_3D \ - case EdgePosition::D3_xnz_3D: \ - case EdgePosition::D3_x0z_3D: \ - case EdgePosition::D3_xNz_3D -#define CASE_EDGE_POSITION_L_2D \ - case EdgePosition::L_xn_2D: \ - case EdgePosition::L_x0_2D: \ - case EdgePosition::L_xN_2D -#define CASE_EDGE_POSITION_H_2D \ - case EdgePosition::H_ny_2D: \ - case EdgePosition::H_0y_2D: \ - case EdgePosition::H_Ny_2D - ImplicitTriangulation::ImplicitTriangulation() : cellNumber_{}, vertexNumber_{}, edgeNumber_{}, triangleNumber_{}, tetrahedronNumber_{}, isAccelerated_{} { @@ -268,95 +217,6 @@ int ImplicitTriangulation::checkAcceleration() { return 0; } -bool ImplicitTriangulation::isPowerOfTwo(unsigned long long int v, - unsigned long long int &r) { - if(v && !(v & (v - 1))) { - r = 0; - while(v >>= 1) - r++; - return true; - } - return false; -} - -template -bool ImplicitTriangulationCRTP::TTK_TRIANGULATION_INTERNAL( - isVertexOnBoundary)(const SimplexId &vertexId) const { - -#ifdef TTK_ENABLE_MPI - if(this->metaGrid_ != nullptr) { - return this->isVertexOnGlobalBoundaryInternal(vertexId); - } -#endif // TTK_ENABLE_MPI - -#ifndef TTK_ENABLE_KAMIKAZE - if(vertexId < 0 or vertexId >= vertexNumber_) - return false; -#endif // !TTK_ENABLE_KAMIKAZE - - switch(this->underlying().getVertexPosition(vertexId)) { - case VertexPosition::CENTER_3D: - case VertexPosition::CENTER_2D: - case VertexPosition::CENTER_1D: - return false; - default: - return true; - } -} - -template -bool ImplicitTriangulationCRTP::TTK_TRIANGULATION_INTERNAL( - isEdgeOnBoundary)(const SimplexId &edgeId) const { - -#ifdef TTK_ENABLE_MPI - if(this->metaGrid_ != nullptr) { - return this->isEdgeOnGlobalBoundaryInternal(edgeId); - } -#endif // TTK_ENABLE_MPI - -#ifndef TTK_ENABLE_KAMIKAZE - if(edgeId < 0 or edgeId >= edgeNumber_) - return false; -#endif // !TTK_ENABLE_KAMIKAZE - - switch(this->underlying().getEdgePosition(edgeId)) { - case EdgePosition::L_xnn_3D: - case EdgePosition::H_nyn_3D: - case EdgePosition::P_nnz_3D: - case EdgePosition::D1_xyn_3D: - case EdgePosition::D2_nyz_3D: - case EdgePosition::D3_xnz_3D: - case EdgePosition::D4_3D: - case EdgePosition::L_xn_2D: - case EdgePosition::H_ny_2D: - case EdgePosition::D1_2D: - return false; - default: - break; - } - return true; -} - -bool ImplicitTriangulation::TTK_TRIANGULATION_INTERNAL(isTriangleOnBoundary)( - const SimplexId &triangleId) const { - -#ifdef TTK_ENABLE_MPI - if(this->metaGrid_ != nullptr) { - return this->isTriangleOnGlobalBoundaryInternal(triangleId); - } -#endif // TTK_ENABLE_MPI - -#ifndef TTK_ENABLE_KAMIKAZE - if(triangleId < 0 or triangleId >= triangleNumber_) - return false; -#endif // !TTK_ENABLE_KAMIKAZE - - if(dimensionality_ == 3) - return (TTK_TRIANGULATION_INTERNAL(getTriangleStarNumber)(triangleId) == 1); - - return false; -} - const vector> * ImplicitTriangulation::TTK_TRIANGULATION_INTERNAL(getVertexNeighbors)() { if(vertexNeighborList_.empty()) { @@ -375,162 +235,6 @@ const vector> * return &vertexNeighborList_; } -SimplexId ImplicitTriangulation::getVertexEdgeNumberInternal( - const SimplexId &vertexId) const { - return TTK_TRIANGULATION_INTERNAL(getVertexNeighborNumber)(vertexId); -} - -template -int ImplicitTriangulationCRTP::getVertexEdgeInternal( - const SimplexId &vertexId, const int &localEdgeId, SimplexId &edgeId) const { -#ifndef TTK_ENABLE_KAMIKAZE - if(localEdgeId < 0 or localEdgeId >= getVertexEdgeNumberInternal(vertexId)) - return -1; -#endif - // e--------f - // /| /| - // / | / | - // a--g-----b--h - // | / | / - // |/ |/ - // c--------d - // - // Classement des "Edges" et dans cet ordre: - // L: largeur (type ab) - // H: hauteur (type ac) - // P: profondeur (type ae) - // D1: diagonale1 (type bc) - // D2: diagonale2 (type ag) - // D3: diagonale3 (type be) - // D4: diagonale4 (type bg) - - const auto &p = this->underlying().getVertexCoords(vertexId); - - switch(this->underlying().getVertexPosition(vertexId)) { - case VertexPosition::CENTER_3D: - edgeId = getVertexEdgeABCDEFGH(p.data(), localEdgeId); - break; - case VertexPosition::FRONT_FACE_3D: - edgeId = getVertexEdgeABDC(p.data(), localEdgeId); - break; - case VertexPosition::BACK_FACE_3D: - edgeId = getVertexEdgeEFHG(p.data(), localEdgeId); - break; - case VertexPosition::TOP_FACE_3D: - edgeId = getVertexEdgeAEFB(p.data(), localEdgeId); - break; - case VertexPosition::BOTTOM_FACE_3D: - edgeId = getVertexEdgeGHDC(p.data(), localEdgeId); - break; - case VertexPosition::LEFT_FACE_3D: - edgeId = getVertexEdgeAEGC(p.data(), localEdgeId); - break; - case VertexPosition::RIGHT_FACE_3D: - edgeId = getVertexEdgeBFHD(p.data(), localEdgeId); - break; - case VertexPosition::TOP_FRONT_EDGE_3D: // ab - edgeId = getVertexEdgeAB(p.data(), localEdgeId); - break; - case VertexPosition::BOTTOM_FRONT_EDGE_3D: // cd - edgeId = getVertexEdgeCD(p.data(), localEdgeId); - break; - case VertexPosition::LEFT_FRONT_EDGE_3D: // ac - edgeId = getVertexEdgeAC(p.data(), localEdgeId); - break; - case VertexPosition::RIGHT_FRONT_EDGE_3D: // bd - edgeId = getVertexEdgeBD(p.data(), localEdgeId); - break; - case VertexPosition::TOP_BACK_EDGE_3D: // ef - edgeId = getVertexEdgeEF(p.data(), localEdgeId); - break; - case VertexPosition::BOTTOM_BACK_EDGE_3D: // gh - edgeId = getVertexEdgeGH(p.data(), localEdgeId); - break; - case VertexPosition::LEFT_BACK_EDGE_3D: // eg - edgeId = getVertexEdgeEG(p.data(), localEdgeId); - break; - case VertexPosition::RIGHT_BACK_EDGE_3D: // fh - edgeId = getVertexEdgeFH(p.data(), localEdgeId); - break; - case VertexPosition::TOP_LEFT_EDGE_3D: // ae - edgeId = getVertexEdgeAE(p.data(), localEdgeId); - break; - case VertexPosition::TOP_RIGHT_EDGE_3D: // bf - edgeId = getVertexEdgeBF(p.data(), localEdgeId); - break; - case VertexPosition::BOTTOM_LEFT_EDGE_3D: // cg - edgeId = getVertexEdgeCG(p.data(), localEdgeId); - break; - case VertexPosition::BOTTOM_RIGHT_EDGE_3D: // dh - edgeId = getVertexEdgeDH(p.data(), localEdgeId); - break; - case VertexPosition::TOP_LEFT_FRONT_CORNER_3D: // a - edgeId = getVertexEdgeA(p.data(), localEdgeId); - break; - case VertexPosition::TOP_RIGHT_FRONT_CORNER_3D: // b - edgeId = getVertexEdgeB(p.data(), localEdgeId); - break; - case VertexPosition::BOTTOM_LEFT_FRONT_CORNER_3D: // c - edgeId = getVertexEdgeC(p.data(), localEdgeId); - break; - case VertexPosition::BOTTOM_RIGHT_FRONT_CORNER_3D: // d - edgeId = getVertexEdgeD(p.data(), localEdgeId); - break; - case VertexPosition::TOP_LEFT_BACK_CORNER_3D: // e - edgeId = getVertexEdgeE(p.data(), localEdgeId); - break; - case VertexPosition::TOP_RIGHT_BACK_CORNER_3D: // f - edgeId = getVertexEdgeF(p.data(), localEdgeId); - break; - case VertexPosition::BOTTOM_LEFT_BACK_CORNER_3D: // g - edgeId = getVertexEdgeG(p.data(), localEdgeId); - break; - case VertexPosition::BOTTOM_RIGHT_BACK_CORNER_3D: // h - edgeId = getVertexEdgeH(p.data(), localEdgeId); - break; - case VertexPosition::CENTER_2D: - edgeId = getVertexEdge2dABCD(p.data(), localEdgeId); - break; - case VertexPosition::TOP_EDGE_2D: - edgeId = getVertexEdge2dAB(p.data(), localEdgeId); - break; - case VertexPosition::BOTTOM_EDGE_2D: - edgeId = getVertexEdge2dCD(p.data(), localEdgeId); - break; - case VertexPosition::LEFT_EDGE_2D: - edgeId = getVertexEdge2dAC(p.data(), localEdgeId); - break; - case VertexPosition::RIGHT_EDGE_2D: - edgeId = getVertexEdge2dBD(p.data(), localEdgeId); - break; - case VertexPosition::TOP_LEFT_CORNER_2D: // a - edgeId = getVertexEdge2dA(p.data(), localEdgeId); - break; - case VertexPosition::TOP_RIGHT_CORNER_2D: // b - edgeId = getVertexEdge2dB(p.data(), localEdgeId); - break; - case VertexPosition::BOTTOM_LEFT_CORNER_2D: // c - edgeId = getVertexEdge2dC(p.data(), localEdgeId); - break; - case VertexPosition::BOTTOM_RIGHT_CORNER_2D: // d - edgeId = getVertexEdge2dD(p.data(), localEdgeId); - break; - case VertexPosition::CENTER_1D: - edgeId = (localEdgeId == 0 ? vertexId : vertexId - 1); - break; - case VertexPosition::LEFT_CORNER_1D: - edgeId = vertexId; - break; - case VertexPosition::RIGHT_CORNER_1D: - edgeId = vertexId - 1; - break; - default: - edgeId = -1; - } - - return 0; -} - const vector> * ImplicitTriangulation::getVertexEdgesInternal() { if(vertexEdgeList_.empty()) { @@ -550,158 +254,6 @@ const vector> * return &vertexEdgeList_; } -template -SimplexId ImplicitTriangulationCRTP::getVertexTriangleNumberInternal( - const SimplexId &vertexId) const { -#ifndef TTK_ENABLE_KAMIKAZE - if(vertexId < 0 or vertexId >= vertexNumber_) - return -1; -#endif - - switch(this->underlying().getVertexPosition(vertexId)) { - case VertexPosition::CENTER_3D: - return 36; - case VertexPosition::FRONT_FACE_3D: - case VertexPosition::BACK_FACE_3D: - case VertexPosition::TOP_FACE_3D: - case VertexPosition::BOTTOM_FACE_3D: - case VertexPosition::LEFT_FACE_3D: - case VertexPosition::RIGHT_FACE_3D: - return 21; - case VertexPosition::TOP_FRONT_EDGE_3D: // ab - case VertexPosition::RIGHT_FRONT_EDGE_3D: // bd - case VertexPosition::BOTTOM_BACK_EDGE_3D: // gh - case VertexPosition::LEFT_BACK_EDGE_3D: // eg - case VertexPosition::BOTTOM_LEFT_EDGE_3D: // cg - case VertexPosition::TOP_RIGHT_EDGE_3D: // bf - return 15; - case VertexPosition::TOP_RIGHT_FRONT_CORNER_3D: // b - case VertexPosition::BOTTOM_LEFT_BACK_CORNER_3D: // g - return 12; - case VertexPosition::TOP_BACK_EDGE_3D: // ef - case VertexPosition::BOTTOM_FRONT_EDGE_3D: // cd - case VertexPosition::LEFT_FRONT_EDGE_3D: // ac - case VertexPosition::TOP_LEFT_EDGE_3D: // ae - case VertexPosition::RIGHT_BACK_EDGE_3D: // fh - case VertexPosition::BOTTOM_RIGHT_EDGE_3D: // dh - return 9; - case VertexPosition::TOP_LEFT_FRONT_CORNER_3D: // a - case VertexPosition::BOTTOM_LEFT_FRONT_CORNER_3D: // c - case VertexPosition::BOTTOM_RIGHT_FRONT_CORNER_3D: // d - case VertexPosition::TOP_LEFT_BACK_CORNER_3D: // e - case VertexPosition::TOP_RIGHT_BACK_CORNER_3D: // f - case VertexPosition::BOTTOM_RIGHT_BACK_CORNER_3D: // h - return 5; - default: // 1D + 2D - break; - } - - return 0; -} - -template -int ImplicitTriangulationCRTP::getVertexTriangleInternal( - const SimplexId &vertexId, - const int &localTriangleId, - SimplexId &triangleId) const { -#ifndef TTK_ENABLE_KAMIKAZE - if(localTriangleId < 0 - or localTriangleId >= getVertexTriangleNumberInternal(vertexId)) - return -1; -#endif - - const auto &p = this->underlying().getVertexCoords(vertexId); - - switch(this->underlying().getVertexPosition(vertexId)) { - case VertexPosition::CENTER_3D: - triangleId = getVertexTriangleABCDEFGH(p.data(), localTriangleId); - break; - case VertexPosition::FRONT_FACE_3D: - triangleId = getVertexTriangleABDC(p.data(), localTriangleId); - break; - case VertexPosition::BACK_FACE_3D: - triangleId = getVertexTriangleEFHG(p.data(), localTriangleId); - break; - case VertexPosition::TOP_FACE_3D: - triangleId = getVertexTriangleAEFB(p.data(), localTriangleId); - break; - case VertexPosition::BOTTOM_FACE_3D: - triangleId = getVertexTriangleGHDC(p.data(), localTriangleId); - break; - case VertexPosition::LEFT_FACE_3D: - triangleId = getVertexTriangleAEGC(p.data(), localTriangleId); - break; - case VertexPosition::RIGHT_FACE_3D: - triangleId = getVertexTriangleBFHD(p.data(), localTriangleId); - break; - case VertexPosition::TOP_FRONT_EDGE_3D: // ab - triangleId = getVertexTriangleAB(p.data(), localTriangleId); - break; - case VertexPosition::BOTTOM_FRONT_EDGE_3D: // cd - triangleId = getVertexTriangleCD(p.data(), localTriangleId); - break; - case VertexPosition::LEFT_FRONT_EDGE_3D: // ac - triangleId = getVertexTriangleAC(p.data(), localTriangleId); - break; - case VertexPosition::RIGHT_FRONT_EDGE_3D: // bd - triangleId = getVertexTriangleBD(p.data(), localTriangleId); - break; - case VertexPosition::TOP_BACK_EDGE_3D: // ef - triangleId = getVertexTriangleEF(p.data(), localTriangleId); - break; - case VertexPosition::BOTTOM_BACK_EDGE_3D: // gh - triangleId = getVertexTriangleGH(p.data(), localTriangleId); - break; - case VertexPosition::LEFT_BACK_EDGE_3D: // eg - triangleId = getVertexTriangleEG(p.data(), localTriangleId); - break; - case VertexPosition::RIGHT_BACK_EDGE_3D: // fh - triangleId = getVertexTriangleFH(p.data(), localTriangleId); - break; - case VertexPosition::TOP_LEFT_EDGE_3D: // ae - triangleId = getVertexTriangleAE(p.data(), localTriangleId); - break; - case VertexPosition::TOP_RIGHT_EDGE_3D: // bf - triangleId = getVertexTriangleBF(p.data(), localTriangleId); - break; - case VertexPosition::BOTTOM_LEFT_EDGE_3D: // cg - triangleId = getVertexTriangleCG(p.data(), localTriangleId); - break; - case VertexPosition::BOTTOM_RIGHT_EDGE_3D: // dh - triangleId = getVertexTriangleDH(p.data(), localTriangleId); - break; - case VertexPosition::TOP_LEFT_FRONT_CORNER_3D: // a - triangleId = getVertexTriangleA(p.data(), localTriangleId); - break; - case VertexPosition::TOP_RIGHT_FRONT_CORNER_3D: // b - triangleId = getVertexTriangleB(p.data(), localTriangleId); - break; - case VertexPosition::BOTTOM_LEFT_FRONT_CORNER_3D: // c - triangleId = getVertexTriangleC(p.data(), localTriangleId); - break; - case VertexPosition::BOTTOM_RIGHT_FRONT_CORNER_3D: // d - triangleId = getVertexTriangleD(p.data(), localTriangleId); - break; - case VertexPosition::TOP_LEFT_BACK_CORNER_3D: // e - triangleId = getVertexTriangleE(p.data(), localTriangleId); - break; - case VertexPosition::TOP_RIGHT_BACK_CORNER_3D: // f - triangleId = getVertexTriangleF(p.data(), localTriangleId); - break; - case VertexPosition::BOTTOM_LEFT_BACK_CORNER_3D: // g - triangleId = getVertexTriangleG(p.data(), localTriangleId); - break; - case VertexPosition::BOTTOM_RIGHT_BACK_CORNER_3D: // h - triangleId = getVertexTriangleH(p.data(), localTriangleId); - break; - default: // 1D + 2D - triangleId = -1; - break; - } - - return 0; -} - const vector> * ImplicitTriangulation::getVertexTrianglesInternal() { if(vertexTriangleList_.empty()) { @@ -721,141 +273,6 @@ const vector> * return &vertexTriangleList_; } -SimplexId ImplicitTriangulation::TTK_TRIANGULATION_INTERNAL( - getVertexLinkNumber)(const SimplexId &vertexId) const { - return TTK_TRIANGULATION_INTERNAL(getVertexStarNumber)(vertexId); -} - -template -int ImplicitTriangulationCRTP::TTK_TRIANGULATION_INTERNAL( - getVertexLink)(const SimplexId &vertexId, - const int &localLinkId, - SimplexId &linkId) const { - -#ifndef TTK_ENABLE_KAMIKAZE - if(localLinkId < 0 or localLinkId >= getVertexLinkNumber(vertexId)) - return -1; -#endif // !TTK_ENABLE_KAMIKAZE - - const auto &p = this->underlying().getVertexCoords(vertexId); - - switch(this->underlying().getVertexPosition(vertexId)) { - case VertexPosition::CENTER_3D: - linkId = getVertexLinkABCDEFGH(p.data(), localLinkId); - break; - case VertexPosition::FRONT_FACE_3D: - linkId = getVertexLinkABDC(p.data(), localLinkId); - break; - case VertexPosition::BACK_FACE_3D: - linkId = getVertexLinkEFHG(p.data(), localLinkId); - break; - case VertexPosition::TOP_FACE_3D: - linkId = getVertexLinkAEFB(p.data(), localLinkId); - break; - case VertexPosition::BOTTOM_FACE_3D: - linkId = getVertexLinkGHDC(p.data(), localLinkId); - break; - case VertexPosition::LEFT_FACE_3D: - linkId = getVertexLinkAEGC(p.data(), localLinkId); - break; - case VertexPosition::RIGHT_FACE_3D: - linkId = getVertexLinkBFHD(p.data(), localLinkId); - break; - case VertexPosition::TOP_FRONT_EDGE_3D: // ab - linkId = getVertexLinkAB(p.data(), localLinkId); - break; - case VertexPosition::BOTTOM_FRONT_EDGE_3D: // cd - linkId = getVertexLinkCD(p.data(), localLinkId); - break; - case VertexPosition::LEFT_FRONT_EDGE_3D: // ac - linkId = getVertexLinkAC(p.data(), localLinkId); - break; - case VertexPosition::RIGHT_FRONT_EDGE_3D: // bd - linkId = getVertexLinkBD(p.data(), localLinkId); - break; - case VertexPosition::TOP_BACK_EDGE_3D: // ef - linkId = getVertexLinkEF(p.data(), localLinkId); - break; - case VertexPosition::BOTTOM_BACK_EDGE_3D: // gh - linkId = getVertexLinkGH(p.data(), localLinkId); - break; - case VertexPosition::LEFT_BACK_EDGE_3D: // eg - linkId = getVertexLinkEG(p.data(), localLinkId); - break; - case VertexPosition::RIGHT_BACK_EDGE_3D: // fh - linkId = getVertexLinkFH(p.data(), localLinkId); - break; - case VertexPosition::TOP_LEFT_EDGE_3D: // ae - linkId = getVertexLinkAE(p.data(), localLinkId); - break; - case VertexPosition::TOP_RIGHT_EDGE_3D: // bf - linkId = getVertexLinkBF(p.data(), localLinkId); - break; - case VertexPosition::BOTTOM_LEFT_EDGE_3D: // cg - linkId = getVertexLinkCG(p.data(), localLinkId); - break; - case VertexPosition::BOTTOM_RIGHT_EDGE_3D: // dh - linkId = getVertexLinkDH(p.data(), localLinkId); - break; - case VertexPosition::TOP_LEFT_FRONT_CORNER_3D: // a - linkId = getVertexLinkA(p.data(), localLinkId); - break; - case VertexPosition::TOP_RIGHT_FRONT_CORNER_3D: // b - linkId = getVertexLinkB(p.data(), localLinkId); - break; - case VertexPosition::BOTTOM_LEFT_FRONT_CORNER_3D: // c - linkId = getVertexLinkC(p.data(), localLinkId); - break; - case VertexPosition::BOTTOM_RIGHT_FRONT_CORNER_3D: // d - linkId = getVertexLinkD(p.data(), localLinkId); - break; - case VertexPosition::TOP_LEFT_BACK_CORNER_3D: // e - linkId = getVertexLinkE(p.data(), localLinkId); - break; - case VertexPosition::TOP_RIGHT_BACK_CORNER_3D: // f - linkId = getVertexLinkF(p.data(), localLinkId); - break; - case VertexPosition::BOTTOM_LEFT_BACK_CORNER_3D: // g - linkId = getVertexLinkG(p.data(), localLinkId); - break; - case VertexPosition::BOTTOM_RIGHT_BACK_CORNER_3D: // h - linkId = getVertexLinkH(p.data(), localLinkId); - break; - case VertexPosition::CENTER_2D: - linkId = getVertexLink2dABCD(p.data(), localLinkId); - break; - case VertexPosition::TOP_EDGE_2D: - linkId = getVertexLink2dAB(p.data(), localLinkId); - break; - case VertexPosition::BOTTOM_EDGE_2D: - linkId = getVertexLink2dCD(p.data(), localLinkId); - break; - case VertexPosition::LEFT_EDGE_2D: - linkId = getVertexLink2dAC(p.data(), localLinkId); - break; - case VertexPosition::RIGHT_EDGE_2D: - linkId = getVertexLink2dBD(p.data(), localLinkId); - break; - case VertexPosition::TOP_LEFT_CORNER_2D: // a - linkId = getVertexLink2dA(p.data(), localLinkId); - break; - case VertexPosition::TOP_RIGHT_CORNER_2D: // b - linkId = getVertexLink2dB(p.data(), localLinkId); - break; - case VertexPosition::BOTTOM_LEFT_CORNER_2D: // c - linkId = getVertexLink2dC(p.data(), localLinkId); - break; - case VertexPosition::BOTTOM_RIGHT_CORNER_2D: // d - linkId = getVertexLink2dD(p.data(), localLinkId); - break; - default: // 1D - linkId = -1; - break; - }; - - return 0; -} - const vector> * ImplicitTriangulation::TTK_TRIANGULATION_INTERNAL(getVertexLinks)() { if(vertexLinkList_.empty()) { @@ -875,197 +292,6 @@ const vector> * return &vertexLinkList_; } -template -SimplexId ImplicitTriangulationCRTP::TTK_TRIANGULATION_INTERNAL( - getVertexStarNumber)(const SimplexId &vertexId) const { - -#ifndef TTK_ENABLE_KAMIKAZE - if(vertexId < 0 or vertexId >= vertexNumber_) - return -1; -#endif // !TTK_ENABLE_KAMIKAZE - - switch(this->underlying().getVertexPosition(vertexId)) { - case VertexPosition::CENTER_3D: - return 24; - case VertexPosition::FRONT_FACE_3D: - case VertexPosition::BACK_FACE_3D: - case VertexPosition::TOP_FACE_3D: - case VertexPosition::BOTTOM_FACE_3D: - case VertexPosition::LEFT_FACE_3D: - case VertexPosition::RIGHT_FACE_3D: - return 12; - case VertexPosition::TOP_FRONT_EDGE_3D: // ab - case VertexPosition::RIGHT_FRONT_EDGE_3D: // bd - case VertexPosition::BOTTOM_BACK_EDGE_3D: // gh - case VertexPosition::LEFT_BACK_EDGE_3D: // eg - case VertexPosition::BOTTOM_LEFT_EDGE_3D: // cg - case VertexPosition::TOP_RIGHT_EDGE_3D: // bf - return 8; - case VertexPosition::TOP_RIGHT_FRONT_CORNER_3D: // b - case VertexPosition::BOTTOM_LEFT_BACK_CORNER_3D: // g - case VertexPosition::CENTER_2D: - return 6; - case VertexPosition::TOP_BACK_EDGE_3D: // ef - case VertexPosition::BOTTOM_FRONT_EDGE_3D: // cd - case VertexPosition::LEFT_FRONT_EDGE_3D: // ac - case VertexPosition::TOP_LEFT_EDGE_3D: // ae - case VertexPosition::RIGHT_BACK_EDGE_3D: // fh - case VertexPosition::BOTTOM_RIGHT_EDGE_3D: // dh - return 4; - case VertexPosition::TOP_EDGE_2D: // ab - case VertexPosition::BOTTOM_EDGE_2D: // cd - case VertexPosition::LEFT_EDGE_2D: // ac - case VertexPosition::RIGHT_EDGE_2D: // bd - return 3; - case VertexPosition::TOP_LEFT_FRONT_CORNER_3D: // a - case VertexPosition::BOTTOM_LEFT_FRONT_CORNER_3D: // c - case VertexPosition::BOTTOM_RIGHT_FRONT_CORNER_3D: // d - case VertexPosition::TOP_LEFT_BACK_CORNER_3D: // e - case VertexPosition::TOP_RIGHT_BACK_CORNER_3D: // f - case VertexPosition::BOTTOM_RIGHT_BACK_CORNER_3D: // h - case VertexPosition::TOP_RIGHT_CORNER_2D: // b - case VertexPosition::BOTTOM_LEFT_CORNER_2D: // c - return 2; - case VertexPosition::TOP_LEFT_CORNER_2D: // a - case VertexPosition::BOTTOM_RIGHT_CORNER_2D: // d - return 1; - default: // 1D - break; - } - - return 0; -} - -template -int ImplicitTriangulationCRTP::TTK_TRIANGULATION_INTERNAL( - getVertexStar)(const SimplexId &vertexId, - const int &localStarId, - SimplexId &starId) const { - -#ifndef TTK_ENABLE_KAMIKAZE - if(localStarId < 0 or localStarId >= getVertexStarNumber(vertexId)) - return -1; -#endif // !TTK_ENABLE_KAMIKAZE - - const auto &p = this->underlying().getVertexCoords(vertexId); - - switch(this->underlying().getVertexPosition(vertexId)) { - case VertexPosition::CENTER_3D: - starId = getVertexStarABCDEFGH(p.data(), localStarId); - break; - case VertexPosition::FRONT_FACE_3D: - starId = getVertexStarABDC(p.data(), localStarId); - break; - case VertexPosition::BACK_FACE_3D: - starId = getVertexStarEFHG(p.data(), localStarId); - break; - case VertexPosition::TOP_FACE_3D: - starId = getVertexStarAEFB(p.data(), localStarId); - break; - case VertexPosition::BOTTOM_FACE_3D: - starId = getVertexStarGHDC(p.data(), localStarId); - break; - case VertexPosition::LEFT_FACE_3D: - starId = getVertexStarAEGC(p.data(), localStarId); - break; - case VertexPosition::RIGHT_FACE_3D: - starId = getVertexStarBFHD(p.data(), localStarId); - break; - case VertexPosition::TOP_FRONT_EDGE_3D: // ab - starId = getVertexStarAB(p.data(), localStarId); - break; - case VertexPosition::BOTTOM_FRONT_EDGE_3D: // cd - starId = getVertexStarCD(p.data(), localStarId); - break; - case VertexPosition::LEFT_FRONT_EDGE_3D: // ac - starId = getVertexStarAC(p.data(), localStarId); - break; - case VertexPosition::RIGHT_FRONT_EDGE_3D: // bd - starId = getVertexStarBD(p.data(), localStarId); - break; - case VertexPosition::TOP_BACK_EDGE_3D: // ef - starId = getVertexStarEF(p.data(), localStarId); - break; - case VertexPosition::BOTTOM_BACK_EDGE_3D: // gh - starId = getVertexStarGH(p.data(), localStarId); - break; - case VertexPosition::LEFT_BACK_EDGE_3D: // eg - starId = getVertexStarEG(p.data(), localStarId); - break; - case VertexPosition::RIGHT_BACK_EDGE_3D: // fh - starId = getVertexStarFH(p.data(), localStarId); - break; - case VertexPosition::TOP_LEFT_EDGE_3D: // ae - starId = getVertexStarAE(p.data(), localStarId); - break; - case VertexPosition::TOP_RIGHT_EDGE_3D: // bf - starId = getVertexStarBF(p.data(), localStarId); - break; - case VertexPosition::BOTTOM_LEFT_EDGE_3D: // cg - starId = getVertexStarCG(p.data(), localStarId); - break; - case VertexPosition::BOTTOM_RIGHT_EDGE_3D: // dh - starId = getVertexStarDH(p.data(), localStarId); - break; - case VertexPosition::TOP_LEFT_FRONT_CORNER_3D: // a - starId = getVertexStarA(p.data(), localStarId); - break; - case VertexPosition::TOP_RIGHT_FRONT_CORNER_3D: // b - starId = getVertexStarB(p.data(), localStarId); - break; - case VertexPosition::BOTTOM_LEFT_FRONT_CORNER_3D: // c - starId = getVertexStarC(p.data(), localStarId); - break; - case VertexPosition::BOTTOM_RIGHT_FRONT_CORNER_3D: // d - starId = getVertexStarD(p.data(), localStarId); - break; - case VertexPosition::TOP_LEFT_BACK_CORNER_3D: // e - starId = getVertexStarE(p.data(), localStarId); - break; - case VertexPosition::TOP_RIGHT_BACK_CORNER_3D: // f - starId = getVertexStarF(p.data(), localStarId); - break; - case VertexPosition::BOTTOM_LEFT_BACK_CORNER_3D: // g - starId = getVertexStarG(p.data(), localStarId); - break; - case VertexPosition::BOTTOM_RIGHT_BACK_CORNER_3D: // h - starId = getVertexStarH(p.data(), localStarId); - break; - case VertexPosition::CENTER_2D: - starId = getVertexStar2dABCD(p.data(), localStarId); - break; - case VertexPosition::TOP_EDGE_2D: - starId = getVertexStar2dAB(p.data(), localStarId); - break; - case VertexPosition::BOTTOM_EDGE_2D: - starId = getVertexStar2dCD(p.data(), localStarId); - break; - case VertexPosition::LEFT_EDGE_2D: - starId = getVertexStar2dAC(p.data(), localStarId); - break; - case VertexPosition::RIGHT_EDGE_2D: - starId = getVertexStar2dBD(p.data(), localStarId); - break; - case VertexPosition::TOP_LEFT_CORNER_2D: // a - starId = getVertexStar2dA(p.data(), localStarId); - break; - case VertexPosition::TOP_RIGHT_CORNER_2D: // b - starId = getVertexStar2dB(p.data(), localStarId); - break; - case VertexPosition::BOTTOM_LEFT_CORNER_2D: // c - starId = getVertexStar2dC(p.data(), localStarId); - break; - case VertexPosition::BOTTOM_RIGHT_CORNER_2D: // d - starId = getVertexStar2dD(p.data(), localStarId); - break; - default: // 1D - starId = -1; - break; - } - - return 0; -} - const vector> * ImplicitTriangulation::TTK_TRIANGULATION_INTERNAL(getVertexStars)() { @@ -1085,135 +311,6 @@ const vector> * return &vertexStarList_; } -template -int ImplicitTriangulationCRTP::TTK_TRIANGULATION_INTERNAL( - getVertexPoint)(const SimplexId &vertexId, - float &x, - float &y, - float &z) const { - - if(dimensionality_ == 3) { - const auto &p = this->underlying().getVertexCoords(vertexId); - - x = origin_[0] + spacing_[0] * p[0]; - y = origin_[1] + spacing_[1] * p[1]; - z = origin_[2] + spacing_[2] * p[2]; - } else if(dimensionality_ == 2) { - const auto &p = this->underlying().getVertexCoords(vertexId); - - if(dimensions_[0] > 1 and dimensions_[1] > 1) { - x = origin_[0] + spacing_[0] * p[0]; - y = origin_[1] + spacing_[1] * p[1]; - z = origin_[2]; - } else if(dimensions_[1] > 1 and dimensions_[2] > 1) { - x = origin_[0]; - y = origin_[1] + spacing_[1] * p[0]; - z = origin_[2] + spacing_[2] * p[1]; - } else if(dimensions_[0] > 1 and dimensions_[2] > 1) { - x = origin_[0] + spacing_[0] * p[0]; - y = origin_[1]; - z = origin_[2] + spacing_[2] * p[1]; - } - } else if(dimensionality_ == 1) { - if(dimensions_[0] > 1) { - x = origin_[0] + spacing_[0] * vertexId; - y = origin_[1]; - z = origin_[2]; - } else if(dimensions_[1] > 1) { - x = origin_[0]; - y = origin_[1] + spacing_[1] * vertexId; - z = origin_[2]; - } else if(dimensions_[2] > 1) { - x = origin_[0]; - y = origin_[1]; - z = origin_[2] + spacing_[2] * vertexId; - } - } - - return 0; -} - -template -int ImplicitTriangulationCRTP::getEdgeVertexInternal( - const SimplexId &edgeId, - const int &localVertexId, - SimplexId &vertexId) const { -#ifndef TTK_ENABLE_KAMIKAZE - if(edgeId < 0 or edgeId >= edgeNumber_) - return -1; - if(localVertexId < 0 or localVertexId >= 2) - return -2; -#endif - - const auto &p = this->underlying().getEdgeCoords(edgeId); - - const auto helper3d = [&](const SimplexId a, const SimplexId b) -> SimplexId { - if(isAccelerated_) { - const auto tmp = p[0] + (p[1] << div_[0]) + (p[2] << div_[1]); - return (localVertexId == 0) ? tmp + a : tmp + b; - } else { - const auto tmp = p[0] + (p[1] * vshift_[0]) + (p[2] * vshift_[1]); - return (localVertexId == 0) ? tmp + a : tmp + b; - } - }; - - const auto helper2d = [&](const SimplexId a, const SimplexId b) -> SimplexId { - if(isAccelerated_) { - const auto tmp = p[0] + (p[1] << div_[0]); - return localVertexId == 0 ? tmp + a : tmp + b; - } else { - const auto tmp = p[0] + (p[1] * vshift_[0]); - return localVertexId == 0 ? tmp + a : tmp + b; - } - }; - - switch(this->underlying().getEdgePosition(edgeId)) { - CASE_EDGE_POSITION_L_3D: - vertexId = helper3d(0, 1); - break; - CASE_EDGE_POSITION_H_3D: - vertexId = helper3d(0, vshift_[0]); - break; - CASE_EDGE_POSITION_P_3D: - vertexId = helper3d(0, vshift_[1]); - break; - CASE_EDGE_POSITION_D1_3D: - vertexId = helper3d(1, vshift_[0]); - break; - CASE_EDGE_POSITION_D2_3D: - vertexId = helper3d(0, vshift_[0] + vshift_[1]); - break; - CASE_EDGE_POSITION_D3_3D: - vertexId = helper3d(1, vshift_[1]); - break; - case EdgePosition::D4_3D: - vertexId = helper3d(1, vshift_[0] + vshift_[1]); - break; - - CASE_EDGE_POSITION_L_2D: - vertexId = helper2d(0, 1); - break; - CASE_EDGE_POSITION_H_2D: - vertexId = helper2d(0, vshift_[0]); - break; - case EdgePosition::D1_2D: - vertexId = helper2d(1, vshift_[0]); - break; - - case EdgePosition::FIRST_EDGE_1D: - vertexId = localVertexId == 0 ? 0 : 1; - break; - case EdgePosition::LAST_EDGE_1D: - vertexId = localVertexId == 0 ? edgeNumber_ - 1 : edgeNumber_; - break; - case EdgePosition::CENTER_1D: - vertexId = localVertexId == 0 ? edgeId : edgeId + 1; - break; - } - - return 0; -} - const vector> * ImplicitTriangulation::TTK_TRIANGULATION_INTERNAL(getEdges)() { @@ -1235,228 +332,6 @@ const vector> * return &edgeList_; } -template -SimplexId ImplicitTriangulationCRTP::getEdgeTriangleNumberInternal( - const SimplexId &edgeId) const { -#ifndef TTK_ENABLE_KAMIKAZE - if(edgeId < 0 or edgeId >= edgeNumber_) - return -1; -#endif - - switch(this->underlying().getEdgePosition(edgeId)) { - case EdgePosition::L_xnn_3D: - case EdgePosition::H_nyn_3D: - case EdgePosition::P_nnz_3D: - case EdgePosition::D4_3D: - return 6; - case EdgePosition::L_x0n_3D: - case EdgePosition::L_xNn_3D: - case EdgePosition::L_xn0_3D: - case EdgePosition::L_xnN_3D: - case EdgePosition::H_ny0_3D: - case EdgePosition::H_nyN_3D: - case EdgePosition::H_0yn_3D: - case EdgePosition::H_Nyn_3D: - case EdgePosition::P_n0z_3D: - case EdgePosition::P_nNz_3D: - case EdgePosition::P_0nz_3D: - case EdgePosition::P_Nnz_3D: - case EdgePosition::D1_xyn_3D: - case EdgePosition::D2_nyz_3D: - case EdgePosition::D3_xnz_3D: - return 4; - case EdgePosition::L_x00_3D: - case EdgePosition::L_xNN_3D: - case EdgePosition::H_0yN_3D: - case EdgePosition::H_Ny0_3D: - case EdgePosition::P_0Nz_3D: - case EdgePosition::P_N0z_3D: - case EdgePosition::D1_xy0_3D: - case EdgePosition::D1_xyN_3D: - case EdgePosition::D2_0yz_3D: - case EdgePosition::D2_Nyz_3D: - case EdgePosition::D3_x0z_3D: - case EdgePosition::D3_xNz_3D: - return 3; - case EdgePosition::L_xN0_3D: - case EdgePosition::L_x0N_3D: - case EdgePosition::H_0y0_3D: - case EdgePosition::H_NyN_3D: - case EdgePosition::P_00z_3D: - case EdgePosition::P_NNz_3D: - case EdgePosition::L_xn_2D: - case EdgePosition::H_ny_2D: - case EdgePosition::D1_2D: - return 2; - case EdgePosition::L_x0_2D: - case EdgePosition::L_xN_2D: - case EdgePosition::H_0y_2D: - case EdgePosition::H_Ny_2D: - return 1; - - default: // 1D - break; - } - - return 0; -} - -template -int ImplicitTriangulationCRTP::getEdgeTriangleInternal( - const SimplexId &edgeId, - const int &localTriangleId, - SimplexId &triangleId) const { -#ifndef TTK_ENABLE_KAMIKAZE - if(localTriangleId < 0 - or localTriangleId >= getEdgeTriangleNumberInternal(edgeId)) - return -1; -#endif - - const auto &p = this->underlying().getEdgeCoords(edgeId); - - switch(this->underlying().getEdgePosition(edgeId)) { - case EdgePosition::L_xnn_3D: - triangleId = getEdgeTriangleL_xnn(p.data(), localTriangleId); - break; - case EdgePosition::L_xn0_3D: - triangleId = getEdgeTriangleL_xn0(p.data(), localTriangleId); - break; - case EdgePosition::L_xnN_3D: - triangleId = getEdgeTriangleL_xnN(p.data(), localTriangleId); - break; - case EdgePosition::L_x0n_3D: - triangleId = getEdgeTriangleL_x0n(p.data(), localTriangleId); - break; - case EdgePosition::L_x00_3D: - triangleId = getEdgeTriangleL_x00(p.data(), localTriangleId); - break; - case EdgePosition::L_x0N_3D: - triangleId = getEdgeTriangleL_x0N(p.data(), localTriangleId); - break; - case EdgePosition::L_xNn_3D: - triangleId = getEdgeTriangleL_xNn(p.data(), localTriangleId); - break; - case EdgePosition::L_xN0_3D: - triangleId = getEdgeTriangleL_xN0(p.data(), localTriangleId); - break; - case EdgePosition::L_xNN_3D: - triangleId = getEdgeTriangleL_xNN(p.data(), localTriangleId); - break; - case EdgePosition::H_nyn_3D: - triangleId = getEdgeTriangleH_nyn(p.data(), localTriangleId); - break; - case EdgePosition::H_ny0_3D: - triangleId = getEdgeTriangleH_ny0(p.data(), localTriangleId); - break; - case EdgePosition::H_nyN_3D: - triangleId = getEdgeTriangleH_nyN(p.data(), localTriangleId); - break; - case EdgePosition::H_0yn_3D: - triangleId = getEdgeTriangleH_0yn(p.data(), localTriangleId); - break; - case EdgePosition::H_0y0_3D: - triangleId = getEdgeTriangleH_0y0(p.data(), localTriangleId); - break; - case EdgePosition::H_0yN_3D: - triangleId = getEdgeTriangleH_0yN(p.data(), localTriangleId); - break; - case EdgePosition::H_Nyn_3D: - triangleId = getEdgeTriangleH_Nyn(p.data(), localTriangleId); - break; - case EdgePosition::H_Ny0_3D: - triangleId = getEdgeTriangleH_Ny0(p.data(), localTriangleId); - break; - case EdgePosition::H_NyN_3D: - triangleId = getEdgeTriangleH_NyN(p.data(), localTriangleId); - break; - case EdgePosition::P_nnz_3D: - triangleId = getEdgeTriangleP_nnz(p.data(), localTriangleId); - break; - case EdgePosition::P_n0z_3D: - triangleId = getEdgeTriangleP_n0z(p.data(), localTriangleId); - break; - case EdgePosition::P_nNz_3D: - triangleId = getEdgeTriangleP_nNz(p.data(), localTriangleId); - break; - case EdgePosition::P_0nz_3D: - triangleId = getEdgeTriangleP_0nz(p.data(), localTriangleId); - break; - case EdgePosition::P_00z_3D: - triangleId = getEdgeTriangleP_00z(p.data(), localTriangleId); - break; - case EdgePosition::P_0Nz_3D: - triangleId = getEdgeTriangleP_0Nz(p.data(), localTriangleId); - break; - case EdgePosition::P_Nnz_3D: - triangleId = getEdgeTriangleP_Nnz(p.data(), localTriangleId); - break; - case EdgePosition::P_N0z_3D: - triangleId = getEdgeTriangleP_N0z(p.data(), localTriangleId); - break; - case EdgePosition::P_NNz_3D: - triangleId = getEdgeTriangleP_NNz(p.data(), localTriangleId); - break; - case EdgePosition::D1_xyn_3D: - triangleId = getEdgeTriangleD1_xyn(p.data(), localTriangleId); - break; - case EdgePosition::D1_xy0_3D: - triangleId = getEdgeTriangleD1_xy0(p.data(), localTriangleId); - break; - case EdgePosition::D1_xyN_3D: - triangleId = getEdgeTriangleD1_xyN(p.data(), localTriangleId); - break; - case EdgePosition::D2_nyz_3D: - triangleId = getEdgeTriangleD2_nyz(p.data(), localTriangleId); - break; - case EdgePosition::D2_0yz_3D: - triangleId = getEdgeTriangleD2_0yz(p.data(), localTriangleId); - break; - case EdgePosition::D2_Nyz_3D: - triangleId = getEdgeTriangleD2_Nyz(p.data(), localTriangleId); - break; - case EdgePosition::D3_xnz_3D: - triangleId = getEdgeTriangleD3_xnz(p.data(), localTriangleId); - break; - case EdgePosition::D3_x0z_3D: - triangleId = getEdgeTriangleD3_x0z(p.data(), localTriangleId); - break; - case EdgePosition::D3_xNz_3D: - triangleId = getEdgeTriangleD3_xNz(p.data(), localTriangleId); - break; - case EdgePosition::D4_3D: - triangleId = getEdgeTriangleD4_xyz(p.data(), localTriangleId); - break; - - case EdgePosition::L_xn_2D: - triangleId = getEdgeTriangleL_xn(p.data(), localTriangleId); - break; - case EdgePosition::L_x0_2D: - triangleId = getEdgeTriangleL_x0(p.data(), localTriangleId); - break; - case EdgePosition::L_xN_2D: - triangleId = getEdgeTriangleL_xN(p.data(), localTriangleId); - break; - case EdgePosition::H_ny_2D: - triangleId = getEdgeTriangleH_ny(p.data(), localTriangleId); - break; - case EdgePosition::H_0y_2D: - triangleId = getEdgeTriangleH_0y(p.data(), localTriangleId); - break; - case EdgePosition::H_Ny_2D: - triangleId = getEdgeTriangleH_Ny(p.data(), localTriangleId); - break; - case EdgePosition::D1_2D: - triangleId = getEdgeTriangleD1_xy(p.data(), localTriangleId); - break; - - default: // 1D - triangleId = -1; - break; - } - - return 0; -} - const vector> * ImplicitTriangulation::getEdgeTrianglesInternal() { if(edgeTriangleList_.empty()) { @@ -1476,63 +351,6 @@ const vector> * return &edgeTriangleList_; } -SimplexId ImplicitTriangulation::TTK_TRIANGULATION_INTERNAL(getEdgeLinkNumber)( - const SimplexId &edgeId) const { - return TTK_TRIANGULATION_INTERNAL(getEdgeStarNumber)(edgeId); -} - -template -int ImplicitTriangulationCRTP::TTK_TRIANGULATION_INTERNAL(getEdgeLink)( - const SimplexId &edgeId, const int &localLinkId, SimplexId &linkId) const { - -#ifndef TTK_ENABLE_KAMIKAZE - if(localLinkId < 0 or localLinkId >= getEdgeLinkNumber(edgeId)) - return -1; -#endif - - const auto &p = this->underlying().getEdgeCoords(edgeId); - - switch(this->underlying().getEdgePosition(edgeId)) { - CASE_EDGE_POSITION_L_3D: - linkId = getEdgeLinkL(p.data(), localLinkId); - break; - CASE_EDGE_POSITION_H_3D: - linkId = getEdgeLinkH(p.data(), localLinkId); - break; - CASE_EDGE_POSITION_P_3D: - linkId = getEdgeLinkP(p.data(), localLinkId); - break; - CASE_EDGE_POSITION_D1_3D: - linkId = getEdgeLinkD1(p.data(), localLinkId); - break; - CASE_EDGE_POSITION_D2_3D: - linkId = getEdgeLinkD2(p.data(), localLinkId); - break; - CASE_EDGE_POSITION_D3_3D: - linkId = getEdgeLinkD3(p.data(), localLinkId); - break; - case EdgePosition::D4_3D: - linkId = getEdgeLinkD4(p.data(), localLinkId); - break; - - CASE_EDGE_POSITION_L_2D: - linkId = getEdgeLink2dL(p.data(), localLinkId); - break; - CASE_EDGE_POSITION_H_2D: - linkId = getEdgeLink2dH(p.data(), localLinkId); - break; - case EdgePosition::D1_2D: - linkId = getEdgeLink2dD1(p.data(), localLinkId); - break; - - default: // 1D - linkId = -1; - break; - } - - return 0; -} - const vector> * ImplicitTriangulation::TTK_TRIANGULATION_INTERNAL(getEdgeLinks)() { @@ -1553,126 +371,6 @@ const vector> * return &edgeLinkList_; } -template -SimplexId ImplicitTriangulationCRTP::TTK_TRIANGULATION_INTERNAL( - getEdgeStarNumber)(const SimplexId &edgeId) const { - -#ifndef TTK_ENABLE_KAMIKAZE - if(edgeId < 0 or edgeId >= edgeNumber_) - return -1; -#endif - - switch(this->underlying().getEdgePosition(edgeId)) { - case EdgePosition::L_xnn_3D: - case EdgePosition::H_nyn_3D: - case EdgePosition::P_nnz_3D: - case EdgePosition::D4_3D: - return 6; - case EdgePosition::D1_xyn_3D: - case EdgePosition::D2_nyz_3D: - case EdgePosition::D3_xnz_3D: - return 4; - case EdgePosition::L_x0n_3D: - case EdgePosition::L_xNn_3D: - case EdgePosition::L_xn0_3D: - case EdgePosition::L_xnN_3D: - case EdgePosition::H_ny0_3D: - case EdgePosition::H_nyN_3D: - case EdgePosition::H_0yn_3D: - case EdgePosition::H_Nyn_3D: - case EdgePosition::P_n0z_3D: - case EdgePosition::P_nNz_3D: - case EdgePosition::P_0nz_3D: - case EdgePosition::P_Nnz_3D: - return 3; - case EdgePosition::L_x00_3D: - case EdgePosition::L_xNN_3D: - case EdgePosition::H_0yN_3D: - case EdgePosition::H_Ny0_3D: - case EdgePosition::P_0Nz_3D: - case EdgePosition::P_N0z_3D: - case EdgePosition::D1_xy0_3D: - case EdgePosition::D1_xyN_3D: - case EdgePosition::D2_0yz_3D: - case EdgePosition::D2_Nyz_3D: - case EdgePosition::D3_x0z_3D: - case EdgePosition::D3_xNz_3D: - case EdgePosition::L_xn_2D: - case EdgePosition::H_ny_2D: - case EdgePosition::D1_2D: - return 2; - case EdgePosition::L_xN0_3D: - case EdgePosition::L_x0N_3D: - case EdgePosition::H_0y0_3D: - case EdgePosition::H_NyN_3D: - case EdgePosition::P_00z_3D: - case EdgePosition::P_NNz_3D: - case EdgePosition::L_x0_2D: - case EdgePosition::L_xN_2D: - case EdgePosition::H_0y_2D: - case EdgePosition::H_Ny_2D: - return 1; - - default: // 1D - break; - } - - return 0; -} - -template -int ImplicitTriangulationCRTP::TTK_TRIANGULATION_INTERNAL(getEdgeStar)( - const SimplexId &edgeId, const int &localStarId, SimplexId &starId) const { - -#ifndef TTK_ENABLE_KAMIKAZE - if(localStarId < 0 or localStarId >= getEdgeStarNumber(edgeId)) - return -1; -#endif - - const auto &p = this->underlying().getEdgeCoords(edgeId); - - switch(this->underlying().getEdgePosition(edgeId)) { - CASE_EDGE_POSITION_L_3D: - starId = getEdgeStarL(p.data(), localStarId); - break; - CASE_EDGE_POSITION_H_3D: - starId = getEdgeStarH(p.data(), localStarId); - break; - CASE_EDGE_POSITION_P_3D: - starId = getEdgeStarP(p.data(), localStarId); - break; - CASE_EDGE_POSITION_D1_3D: - starId = getEdgeStarD1(p.data(), localStarId); - break; - CASE_EDGE_POSITION_D2_3D: - starId = getEdgeStarD2(p.data(), localStarId); - break; - CASE_EDGE_POSITION_D3_3D: - starId = getEdgeStarD3(p.data(), localStarId); - break; - case EdgePosition::D4_3D: - starId - = p[2] * tetshift_[1] + p[1] * tetshift_[0] + p[0] * 6 + localStarId; - break; - - CASE_EDGE_POSITION_L_2D: - starId = getEdgeStar2dL(p.data(), localStarId); - break; - CASE_EDGE_POSITION_H_2D: - starId = getEdgeStar2dH(p.data(), localStarId); - break; - case EdgePosition::D1_2D: - starId = p[0] * 2 + p[1] * tshift_[0] + localStarId; - break; - - default: // 1D - starId = -1; - break; - } - - return 0; -} - const vector> * ImplicitTriangulation::TTK_TRIANGULATION_INTERNAL(getEdgeStars)() { diff --git a/core/base/implicitTriangulation/ImplicitTriangulation.h b/core/base/implicitTriangulation/ImplicitTriangulation.h index daa8f69d75..370315bb93 100644 --- a/core/base/implicitTriangulation/ImplicitTriangulation.h +++ b/core/base/implicitTriangulation/ImplicitTriangulation.h @@ -15,6 +15,57 @@ // base code includes #include +#define CASE_EDGE_POSITION_L_3D \ + case EdgePosition::L_xnn_3D: \ + case EdgePosition::L_xn0_3D: \ + case EdgePosition::L_xnN_3D: \ + case EdgePosition::L_x0n_3D: \ + case EdgePosition::L_x00_3D: \ + case EdgePosition::L_x0N_3D: \ + case EdgePosition::L_xNn_3D: \ + case EdgePosition::L_xN0_3D: \ + case EdgePosition::L_xNN_3D +#define CASE_EDGE_POSITION_H_3D \ + case EdgePosition::H_nyn_3D: \ + case EdgePosition::H_ny0_3D: \ + case EdgePosition::H_nyN_3D: \ + case EdgePosition::H_0yn_3D: \ + case EdgePosition::H_0y0_3D: \ + case EdgePosition::H_0yN_3D: \ + case EdgePosition::H_Nyn_3D: \ + case EdgePosition::H_Ny0_3D: \ + case EdgePosition::H_NyN_3D +#define CASE_EDGE_POSITION_P_3D \ + case EdgePosition::P_nnz_3D: \ + case EdgePosition::P_n0z_3D: \ + case EdgePosition::P_nNz_3D: \ + case EdgePosition::P_0nz_3D: \ + case EdgePosition::P_00z_3D: \ + case EdgePosition::P_0Nz_3D: \ + case EdgePosition::P_Nnz_3D: \ + case EdgePosition::P_N0z_3D: \ + case EdgePosition::P_NNz_3D +#define CASE_EDGE_POSITION_D1_3D \ + case EdgePosition::D1_xyn_3D: \ + case EdgePosition::D1_xy0_3D: \ + case EdgePosition::D1_xyN_3D +#define CASE_EDGE_POSITION_D2_3D \ + case EdgePosition::D2_nyz_3D: \ + case EdgePosition::D2_0yz_3D: \ + case EdgePosition::D2_Nyz_3D +#define CASE_EDGE_POSITION_D3_3D \ + case EdgePosition::D3_xnz_3D: \ + case EdgePosition::D3_x0z_3D: \ + case EdgePosition::D3_xNz_3D +#define CASE_EDGE_POSITION_L_2D \ + case EdgePosition::L_xn_2D: \ + case EdgePosition::L_x0_2D: \ + case EdgePosition::L_xN_2D +#define CASE_EDGE_POSITION_H_2D \ + case EdgePosition::H_ny_2D: \ + case EdgePosition::H_0y_2D: \ + case EdgePosition::H_Ny_2D + namespace ttk { class ImplicitTriangulation : public RegularGridTriangulation { @@ -77,8 +128,11 @@ namespace ttk { return dimensionality_; } - SimplexId TTK_TRIANGULATION_INTERNAL(getEdgeLinkNumber)( - const SimplexId &edgeId) const override; + inline SimplexId TTK_TRIANGULATION_INTERNAL(getEdgeLinkNumber)( + const SimplexId &edgeId) const override { + + return TTK_TRIANGULATION_INTERNAL(getEdgeStarNumber)(edgeId); + } const std::vector> * TTK_TRIANGULATION_INTERNAL(getEdgeLinks)() override; @@ -168,14 +222,18 @@ namespace ttk { const std::vector> * TTK_TRIANGULATION_INTERNAL(getTriangles)() override; - SimplexId - getVertexEdgeNumberInternal(const SimplexId &vertexId) const override; + inline SimplexId + getVertexEdgeNumberInternal(const SimplexId &vertexId) const override { + return TTK_TRIANGULATION_INTERNAL(getVertexNeighborNumber)(vertexId); + } const std::vector> * getVertexEdgesInternal() override; - SimplexId TTK_TRIANGULATION_INTERNAL(getVertexLinkNumber)( - const SimplexId &vertexId) const override; + inline SimplexId TTK_TRIANGULATION_INTERNAL(getVertexLinkNumber)( + const SimplexId &vertexId) const override { + return TTK_TRIANGULATION_INTERNAL(getVertexStarNumber)(vertexId); + } const std::vector> * TTK_TRIANGULATION_INTERNAL(getVertexLinks)() override; @@ -193,8 +251,26 @@ namespace ttk { return !vertexNumber_; } - bool TTK_TRIANGULATION_INTERNAL(isTriangleOnBoundary)( - const SimplexId &triangleId) const override; + inline bool TTK_TRIANGULATION_INTERNAL(isTriangleOnBoundary)( + const SimplexId &triangleId) const override { + +#ifdef TTK_ENABLE_MPI + if(this->metaGrid_ != nullptr) { + return this->isTriangleOnGlobalBoundaryInternal(triangleId); + } +#endif // TTK_ENABLE_MPI + +#ifndef TTK_ENABLE_KAMIKAZE + if(triangleId < 0 or triangleId >= triangleNumber_) + return false; +#endif // !TTK_ENABLE_KAMIKAZE + + if(dimensionality_ == 3) + return (TTK_TRIANGULATION_INTERNAL(getTriangleStarNumber)(triangleId) + == 1); + + return false; + } int setInputGrid(const float &xOrigin, const float &yOrigin, @@ -513,7 +589,16 @@ namespace ttk { // acceleration functions int checkAcceleration(); - bool isPowerOfTwo(unsigned long long int v, unsigned long long int &r); + inline bool isPowerOfTwo(unsigned long long int v, + unsigned long long int &r) const { + if(v && !(v & (v - 1))) { + r = 0; + while(v >>= 1) + r++; + return true; + } + return false; + } //\cond // 2D // @@ -912,11 +997,60 @@ namespace ttk { return -1; } - bool TTK_TRIANGULATION_INTERNAL(isVertexOnBoundary)( - const SimplexId &vertexId) const override; + inline bool TTK_TRIANGULATION_INTERNAL(isVertexOnBoundary)( + const SimplexId &vertexId) const override { +#ifdef TTK_ENABLE_MPI + if(this->metaGrid_ != nullptr) { + return this->isVertexOnGlobalBoundaryInternal(vertexId); + } +#endif // TTK_ENABLE_MPI + +#ifndef TTK_ENABLE_KAMIKAZE + if(vertexId < 0 or vertexId >= vertexNumber_) + return false; +#endif // !TTK_ENABLE_KAMIKAZE + + switch(this->underlying().getVertexPosition(vertexId)) { + case VertexPosition::CENTER_3D: + case VertexPosition::CENTER_2D: + case VertexPosition::CENTER_1D: + return false; + default: + return true; + } + } + + inline bool TTK_TRIANGULATION_INTERNAL(isEdgeOnBoundary)( + const SimplexId &edgeId) const override { + +#ifdef TTK_ENABLE_MPI + if(this->metaGrid_ != nullptr) { + return this->isEdgeOnGlobalBoundaryInternal(edgeId); + } +#endif // TTK_ENABLE_MPI + +#ifndef TTK_ENABLE_KAMIKAZE + if(edgeId < 0 or edgeId >= edgeNumber_) + return false; +#endif // !TTK_ENABLE_KAMIKAZE - bool TTK_TRIANGULATION_INTERNAL(isEdgeOnBoundary)( - const SimplexId &edgeId) const override; + switch(this->underlying().getEdgePosition(edgeId)) { + case EdgePosition::L_xnn_3D: + case EdgePosition::H_nyn_3D: + case EdgePosition::P_nnz_3D: + case EdgePosition::D1_xyn_3D: + case EdgePosition::D2_nyz_3D: + case EdgePosition::D3_xnz_3D: + case EdgePosition::D4_3D: + case EdgePosition::L_xn_2D: + case EdgePosition::H_ny_2D: + case EdgePosition::D1_2D: + return false; + default: + break; + } + return true; + } inline int TTK_TRIANGULATION_INTERNAL(getVertexNeighbor)( const SimplexId &vertexId, @@ -1056,58 +1190,1142 @@ namespace ttk { return 0; } - int getVertexEdgeInternal(const SimplexId &vertexId, - const int &id, - SimplexId &edgeId) const override; + inline int getVertexEdgeInternal(const SimplexId &vertexId, + const int &localEdgeId, + SimplexId &edgeId) const override { - SimplexId - getVertexTriangleNumberInternal(const SimplexId &vertexId) const override; +#ifndef TTK_ENABLE_KAMIKAZE + if(localEdgeId < 0 + or localEdgeId >= getVertexEdgeNumberInternal(vertexId)) + return -1; +#endif + // e--------f + // /| /| + // / | / | + // a--g-----b--h + // | / | / + // |/ |/ + // c--------d + // + // Classement des "Edges" et dans cet ordre: + // L: largeur (type ab) + // H: hauteur (type ac) + // P: profondeur (type ae) + // D1: diagonale1 (type bc) + // D2: diagonale2 (type ag) + // D3: diagonale3 (type be) + // D4: diagonale4 (type bg) + + const auto &p = this->underlying().getVertexCoords(vertexId); + + switch(this->underlying().getVertexPosition(vertexId)) { + case VertexPosition::CENTER_3D: + edgeId = getVertexEdgeABCDEFGH(p.data(), localEdgeId); + break; + case VertexPosition::FRONT_FACE_3D: + edgeId = getVertexEdgeABDC(p.data(), localEdgeId); + break; + case VertexPosition::BACK_FACE_3D: + edgeId = getVertexEdgeEFHG(p.data(), localEdgeId); + break; + case VertexPosition::TOP_FACE_3D: + edgeId = getVertexEdgeAEFB(p.data(), localEdgeId); + break; + case VertexPosition::BOTTOM_FACE_3D: + edgeId = getVertexEdgeGHDC(p.data(), localEdgeId); + break; + case VertexPosition::LEFT_FACE_3D: + edgeId = getVertexEdgeAEGC(p.data(), localEdgeId); + break; + case VertexPosition::RIGHT_FACE_3D: + edgeId = getVertexEdgeBFHD(p.data(), localEdgeId); + break; + case VertexPosition::TOP_FRONT_EDGE_3D: // ab + edgeId = getVertexEdgeAB(p.data(), localEdgeId); + break; + case VertexPosition::BOTTOM_FRONT_EDGE_3D: // cd + edgeId = getVertexEdgeCD(p.data(), localEdgeId); + break; + case VertexPosition::LEFT_FRONT_EDGE_3D: // ac + edgeId = getVertexEdgeAC(p.data(), localEdgeId); + break; + case VertexPosition::RIGHT_FRONT_EDGE_3D: // bd + edgeId = getVertexEdgeBD(p.data(), localEdgeId); + break; + case VertexPosition::TOP_BACK_EDGE_3D: // ef + edgeId = getVertexEdgeEF(p.data(), localEdgeId); + break; + case VertexPosition::BOTTOM_BACK_EDGE_3D: // gh + edgeId = getVertexEdgeGH(p.data(), localEdgeId); + break; + case VertexPosition::LEFT_BACK_EDGE_3D: // eg + edgeId = getVertexEdgeEG(p.data(), localEdgeId); + break; + case VertexPosition::RIGHT_BACK_EDGE_3D: // fh + edgeId = getVertexEdgeFH(p.data(), localEdgeId); + break; + case VertexPosition::TOP_LEFT_EDGE_3D: // ae + edgeId = getVertexEdgeAE(p.data(), localEdgeId); + break; + case VertexPosition::TOP_RIGHT_EDGE_3D: // bf + edgeId = getVertexEdgeBF(p.data(), localEdgeId); + break; + case VertexPosition::BOTTOM_LEFT_EDGE_3D: // cg + edgeId = getVertexEdgeCG(p.data(), localEdgeId); + break; + case VertexPosition::BOTTOM_RIGHT_EDGE_3D: // dh + edgeId = getVertexEdgeDH(p.data(), localEdgeId); + break; + case VertexPosition::TOP_LEFT_FRONT_CORNER_3D: // a + edgeId = getVertexEdgeA(p.data(), localEdgeId); + break; + case VertexPosition::TOP_RIGHT_FRONT_CORNER_3D: // b + edgeId = getVertexEdgeB(p.data(), localEdgeId); + break; + case VertexPosition::BOTTOM_LEFT_FRONT_CORNER_3D: // c + edgeId = getVertexEdgeC(p.data(), localEdgeId); + break; + case VertexPosition::BOTTOM_RIGHT_FRONT_CORNER_3D: // d + edgeId = getVertexEdgeD(p.data(), localEdgeId); + break; + case VertexPosition::TOP_LEFT_BACK_CORNER_3D: // e + edgeId = getVertexEdgeE(p.data(), localEdgeId); + break; + case VertexPosition::TOP_RIGHT_BACK_CORNER_3D: // f + edgeId = getVertexEdgeF(p.data(), localEdgeId); + break; + case VertexPosition::BOTTOM_LEFT_BACK_CORNER_3D: // g + edgeId = getVertexEdgeG(p.data(), localEdgeId); + break; + case VertexPosition::BOTTOM_RIGHT_BACK_CORNER_3D: // h + edgeId = getVertexEdgeH(p.data(), localEdgeId); + break; + case VertexPosition::CENTER_2D: + edgeId = getVertexEdge2dABCD(p.data(), localEdgeId); + break; + case VertexPosition::TOP_EDGE_2D: + edgeId = getVertexEdge2dAB(p.data(), localEdgeId); + break; + case VertexPosition::BOTTOM_EDGE_2D: + edgeId = getVertexEdge2dCD(p.data(), localEdgeId); + break; + case VertexPosition::LEFT_EDGE_2D: + edgeId = getVertexEdge2dAC(p.data(), localEdgeId); + break; + case VertexPosition::RIGHT_EDGE_2D: + edgeId = getVertexEdge2dBD(p.data(), localEdgeId); + break; + case VertexPosition::TOP_LEFT_CORNER_2D: // a + edgeId = getVertexEdge2dA(p.data(), localEdgeId); + break; + case VertexPosition::TOP_RIGHT_CORNER_2D: // b + edgeId = getVertexEdge2dB(p.data(), localEdgeId); + break; + case VertexPosition::BOTTOM_LEFT_CORNER_2D: // c + edgeId = getVertexEdge2dC(p.data(), localEdgeId); + break; + case VertexPosition::BOTTOM_RIGHT_CORNER_2D: // d + edgeId = getVertexEdge2dD(p.data(), localEdgeId); + break; + case VertexPosition::CENTER_1D: + edgeId = (localEdgeId == 0 ? vertexId : vertexId - 1); + break; + case VertexPosition::LEFT_CORNER_1D: + edgeId = vertexId; + break; + case VertexPosition::RIGHT_CORNER_1D: + edgeId = vertexId - 1; + break; + default: + edgeId = -1; + } - int getVertexTriangleInternal(const SimplexId &vertexId, - const int &id, - SimplexId &triangleId) const override; + return 0; + } - int TTK_TRIANGULATION_INTERNAL(getVertexLink)( - const SimplexId &vertexId, - const int &localLinkId, - SimplexId &linkId) const override; + inline SimplexId getVertexTriangleNumberInternal( + const SimplexId &vertexId) const override { - SimplexId TTK_TRIANGULATION_INTERNAL(getVertexStarNumber)( - const SimplexId &vertexId) const override; +#ifndef TTK_ENABLE_KAMIKAZE + if(vertexId < 0 or vertexId >= vertexNumber_) + return -1; +#endif - int TTK_TRIANGULATION_INTERNAL(getVertexStar)( - const SimplexId &vertexId, - const int &localStarId, - SimplexId &starId) const override; + switch(this->underlying().getVertexPosition(vertexId)) { + case VertexPosition::CENTER_3D: + return 36; + case VertexPosition::FRONT_FACE_3D: + case VertexPosition::BACK_FACE_3D: + case VertexPosition::TOP_FACE_3D: + case VertexPosition::BOTTOM_FACE_3D: + case VertexPosition::LEFT_FACE_3D: + case VertexPosition::RIGHT_FACE_3D: + return 21; + case VertexPosition::TOP_FRONT_EDGE_3D: // ab + case VertexPosition::RIGHT_FRONT_EDGE_3D: // bd + case VertexPosition::BOTTOM_BACK_EDGE_3D: // gh + case VertexPosition::LEFT_BACK_EDGE_3D: // eg + case VertexPosition::BOTTOM_LEFT_EDGE_3D: // cg + case VertexPosition::TOP_RIGHT_EDGE_3D: // bf + return 15; + case VertexPosition::TOP_RIGHT_FRONT_CORNER_3D: // b + case VertexPosition::BOTTOM_LEFT_BACK_CORNER_3D: // g + return 12; + case VertexPosition::TOP_BACK_EDGE_3D: // ef + case VertexPosition::BOTTOM_FRONT_EDGE_3D: // cd + case VertexPosition::LEFT_FRONT_EDGE_3D: // ac + case VertexPosition::TOP_LEFT_EDGE_3D: // ae + case VertexPosition::RIGHT_BACK_EDGE_3D: // fh + case VertexPosition::BOTTOM_RIGHT_EDGE_3D: // dh + return 9; + case VertexPosition::TOP_LEFT_FRONT_CORNER_3D: // a + case VertexPosition::BOTTOM_LEFT_FRONT_CORNER_3D: // c + case VertexPosition::BOTTOM_RIGHT_FRONT_CORNER_3D: // d + case VertexPosition::TOP_LEFT_BACK_CORNER_3D: // e + case VertexPosition::TOP_RIGHT_BACK_CORNER_3D: // f + case VertexPosition::BOTTOM_RIGHT_BACK_CORNER_3D: // h + return 5; + default: // 1D + 2D + break; + } - int TTK_TRIANGULATION_INTERNAL(getVertexPoint)(const SimplexId &vertexId, - float &x, - float &y, - float &z) const override; + return 0; + } - int getEdgeVertexInternal(const SimplexId &edgeId, - const int &localVertexId, - SimplexId &vertexId) const override; + inline int getVertexTriangleInternal(const SimplexId &vertexId, + const int &localTriangleId, + SimplexId &triangleId) const override { +#ifndef TTK_ENABLE_KAMIKAZE + if(localTriangleId < 0 + or localTriangleId >= getVertexTriangleNumberInternal(vertexId)) + return -1; +#endif - SimplexId - getEdgeTriangleNumberInternal(const SimplexId &edgeId) const override; + const auto &p = this->underlying().getVertexCoords(vertexId); - int getEdgeTriangleInternal(const SimplexId &edgeId, - const int &id, - SimplexId &triangleId) const override; + switch(this->underlying().getVertexPosition(vertexId)) { + case VertexPosition::CENTER_3D: + triangleId = getVertexTriangleABCDEFGH(p.data(), localTriangleId); + break; + case VertexPosition::FRONT_FACE_3D: + triangleId = getVertexTriangleABDC(p.data(), localTriangleId); + break; + case VertexPosition::BACK_FACE_3D: + triangleId = getVertexTriangleEFHG(p.data(), localTriangleId); + break; + case VertexPosition::TOP_FACE_3D: + triangleId = getVertexTriangleAEFB(p.data(), localTriangleId); + break; + case VertexPosition::BOTTOM_FACE_3D: + triangleId = getVertexTriangleGHDC(p.data(), localTriangleId); + break; + case VertexPosition::LEFT_FACE_3D: + triangleId = getVertexTriangleAEGC(p.data(), localTriangleId); + break; + case VertexPosition::RIGHT_FACE_3D: + triangleId = getVertexTriangleBFHD(p.data(), localTriangleId); + break; + case VertexPosition::TOP_FRONT_EDGE_3D: // ab + triangleId = getVertexTriangleAB(p.data(), localTriangleId); + break; + case VertexPosition::BOTTOM_FRONT_EDGE_3D: // cd + triangleId = getVertexTriangleCD(p.data(), localTriangleId); + break; + case VertexPosition::LEFT_FRONT_EDGE_3D: // ac + triangleId = getVertexTriangleAC(p.data(), localTriangleId); + break; + case VertexPosition::RIGHT_FRONT_EDGE_3D: // bd + triangleId = getVertexTriangleBD(p.data(), localTriangleId); + break; + case VertexPosition::TOP_BACK_EDGE_3D: // ef + triangleId = getVertexTriangleEF(p.data(), localTriangleId); + break; + case VertexPosition::BOTTOM_BACK_EDGE_3D: // gh + triangleId = getVertexTriangleGH(p.data(), localTriangleId); + break; + case VertexPosition::LEFT_BACK_EDGE_3D: // eg + triangleId = getVertexTriangleEG(p.data(), localTriangleId); + break; + case VertexPosition::RIGHT_BACK_EDGE_3D: // fh + triangleId = getVertexTriangleFH(p.data(), localTriangleId); + break; + case VertexPosition::TOP_LEFT_EDGE_3D: // ae + triangleId = getVertexTriangleAE(p.data(), localTriangleId); + break; + case VertexPosition::TOP_RIGHT_EDGE_3D: // bf + triangleId = getVertexTriangleBF(p.data(), localTriangleId); + break; + case VertexPosition::BOTTOM_LEFT_EDGE_3D: // cg + triangleId = getVertexTriangleCG(p.data(), localTriangleId); + break; + case VertexPosition::BOTTOM_RIGHT_EDGE_3D: // dh + triangleId = getVertexTriangleDH(p.data(), localTriangleId); + break; + case VertexPosition::TOP_LEFT_FRONT_CORNER_3D: // a + triangleId = getVertexTriangleA(p.data(), localTriangleId); + break; + case VertexPosition::TOP_RIGHT_FRONT_CORNER_3D: // b + triangleId = getVertexTriangleB(p.data(), localTriangleId); + break; + case VertexPosition::BOTTOM_LEFT_FRONT_CORNER_3D: // c + triangleId = getVertexTriangleC(p.data(), localTriangleId); + break; + case VertexPosition::BOTTOM_RIGHT_FRONT_CORNER_3D: // d + triangleId = getVertexTriangleD(p.data(), localTriangleId); + break; + case VertexPosition::TOP_LEFT_BACK_CORNER_3D: // e + triangleId = getVertexTriangleE(p.data(), localTriangleId); + break; + case VertexPosition::TOP_RIGHT_BACK_CORNER_3D: // f + triangleId = getVertexTriangleF(p.data(), localTriangleId); + break; + case VertexPosition::BOTTOM_LEFT_BACK_CORNER_3D: // g + triangleId = getVertexTriangleG(p.data(), localTriangleId); + break; + case VertexPosition::BOTTOM_RIGHT_BACK_CORNER_3D: // h + triangleId = getVertexTriangleH(p.data(), localTriangleId); + break; + default: // 1D + 2D + triangleId = -1; + break; + } + + return 0; + } - int - TTK_TRIANGULATION_INTERNAL(getEdgeLink)(const SimplexId &edgeId, - const int &localLinkId, - SimplexId &linkId) const override; + inline int TTK_TRIANGULATION_INTERNAL(getVertexLink)( + const SimplexId &vertexId, + const int &localLinkId, + SimplexId &linkId) const override { + +#ifndef TTK_ENABLE_KAMIKAZE + if(localLinkId < 0 or localLinkId >= getVertexLinkNumber(vertexId)) + return -1; +#endif // !TTK_ENABLE_KAMIKAZE - int - TTK_TRIANGULATION_INTERNAL(getEdgeStar)(const SimplexId &edgeId, - const int &localStarId, - SimplexId &starId) const override; + const auto &p = this->underlying().getVertexCoords(vertexId); - SimplexId TTK_TRIANGULATION_INTERNAL(getEdgeStarNumber)( - const SimplexId &edgeId) const override; + switch(this->underlying().getVertexPosition(vertexId)) { + case VertexPosition::CENTER_3D: + linkId = getVertexLinkABCDEFGH(p.data(), localLinkId); + break; + case VertexPosition::FRONT_FACE_3D: + linkId = getVertexLinkABDC(p.data(), localLinkId); + break; + case VertexPosition::BACK_FACE_3D: + linkId = getVertexLinkEFHG(p.data(), localLinkId); + break; + case VertexPosition::TOP_FACE_3D: + linkId = getVertexLinkAEFB(p.data(), localLinkId); + break; + case VertexPosition::BOTTOM_FACE_3D: + linkId = getVertexLinkGHDC(p.data(), localLinkId); + break; + case VertexPosition::LEFT_FACE_3D: + linkId = getVertexLinkAEGC(p.data(), localLinkId); + break; + case VertexPosition::RIGHT_FACE_3D: + linkId = getVertexLinkBFHD(p.data(), localLinkId); + break; + case VertexPosition::TOP_FRONT_EDGE_3D: // ab + linkId = getVertexLinkAB(p.data(), localLinkId); + break; + case VertexPosition::BOTTOM_FRONT_EDGE_3D: // cd + linkId = getVertexLinkCD(p.data(), localLinkId); + break; + case VertexPosition::LEFT_FRONT_EDGE_3D: // ac + linkId = getVertexLinkAC(p.data(), localLinkId); + break; + case VertexPosition::RIGHT_FRONT_EDGE_3D: // bd + linkId = getVertexLinkBD(p.data(), localLinkId); + break; + case VertexPosition::TOP_BACK_EDGE_3D: // ef + linkId = getVertexLinkEF(p.data(), localLinkId); + break; + case VertexPosition::BOTTOM_BACK_EDGE_3D: // gh + linkId = getVertexLinkGH(p.data(), localLinkId); + break; + case VertexPosition::LEFT_BACK_EDGE_3D: // eg + linkId = getVertexLinkEG(p.data(), localLinkId); + break; + case VertexPosition::RIGHT_BACK_EDGE_3D: // fh + linkId = getVertexLinkFH(p.data(), localLinkId); + break; + case VertexPosition::TOP_LEFT_EDGE_3D: // ae + linkId = getVertexLinkAE(p.data(), localLinkId); + break; + case VertexPosition::TOP_RIGHT_EDGE_3D: // bf + linkId = getVertexLinkBF(p.data(), localLinkId); + break; + case VertexPosition::BOTTOM_LEFT_EDGE_3D: // cg + linkId = getVertexLinkCG(p.data(), localLinkId); + break; + case VertexPosition::BOTTOM_RIGHT_EDGE_3D: // dh + linkId = getVertexLinkDH(p.data(), localLinkId); + break; + case VertexPosition::TOP_LEFT_FRONT_CORNER_3D: // a + linkId = getVertexLinkA(p.data(), localLinkId); + break; + case VertexPosition::TOP_RIGHT_FRONT_CORNER_3D: // b + linkId = getVertexLinkB(p.data(), localLinkId); + break; + case VertexPosition::BOTTOM_LEFT_FRONT_CORNER_3D: // c + linkId = getVertexLinkC(p.data(), localLinkId); + break; + case VertexPosition::BOTTOM_RIGHT_FRONT_CORNER_3D: // d + linkId = getVertexLinkD(p.data(), localLinkId); + break; + case VertexPosition::TOP_LEFT_BACK_CORNER_3D: // e + linkId = getVertexLinkE(p.data(), localLinkId); + break; + case VertexPosition::TOP_RIGHT_BACK_CORNER_3D: // f + linkId = getVertexLinkF(p.data(), localLinkId); + break; + case VertexPosition::BOTTOM_LEFT_BACK_CORNER_3D: // g + linkId = getVertexLinkG(p.data(), localLinkId); + break; + case VertexPosition::BOTTOM_RIGHT_BACK_CORNER_3D: // h + linkId = getVertexLinkH(p.data(), localLinkId); + break; + case VertexPosition::CENTER_2D: + linkId = getVertexLink2dABCD(p.data(), localLinkId); + break; + case VertexPosition::TOP_EDGE_2D: + linkId = getVertexLink2dAB(p.data(), localLinkId); + break; + case VertexPosition::BOTTOM_EDGE_2D: + linkId = getVertexLink2dCD(p.data(), localLinkId); + break; + case VertexPosition::LEFT_EDGE_2D: + linkId = getVertexLink2dAC(p.data(), localLinkId); + break; + case VertexPosition::RIGHT_EDGE_2D: + linkId = getVertexLink2dBD(p.data(), localLinkId); + break; + case VertexPosition::TOP_LEFT_CORNER_2D: // a + linkId = getVertexLink2dA(p.data(), localLinkId); + break; + case VertexPosition::TOP_RIGHT_CORNER_2D: // b + linkId = getVertexLink2dB(p.data(), localLinkId); + break; + case VertexPosition::BOTTOM_LEFT_CORNER_2D: // c + linkId = getVertexLink2dC(p.data(), localLinkId); + break; + case VertexPosition::BOTTOM_RIGHT_CORNER_2D: // d + linkId = getVertexLink2dD(p.data(), localLinkId); + break; + default: // 1D + linkId = -1; + break; + }; + + return 0; + } + + inline SimplexId TTK_TRIANGULATION_INTERNAL(getVertexStarNumber)( + const SimplexId &vertexId) const override { + +#ifndef TTK_ENABLE_KAMIKAZE + if(vertexId < 0 or vertexId >= vertexNumber_) + return -1; +#endif // !TTK_ENABLE_KAMIKAZE + + switch(this->underlying().getVertexPosition(vertexId)) { + case VertexPosition::CENTER_3D: + return 24; + case VertexPosition::FRONT_FACE_3D: + case VertexPosition::BACK_FACE_3D: + case VertexPosition::TOP_FACE_3D: + case VertexPosition::BOTTOM_FACE_3D: + case VertexPosition::LEFT_FACE_3D: + case VertexPosition::RIGHT_FACE_3D: + return 12; + case VertexPosition::TOP_FRONT_EDGE_3D: // ab + case VertexPosition::RIGHT_FRONT_EDGE_3D: // bd + case VertexPosition::BOTTOM_BACK_EDGE_3D: // gh + case VertexPosition::LEFT_BACK_EDGE_3D: // eg + case VertexPosition::BOTTOM_LEFT_EDGE_3D: // cg + case VertexPosition::TOP_RIGHT_EDGE_3D: // bf + return 8; + case VertexPosition::TOP_RIGHT_FRONT_CORNER_3D: // b + case VertexPosition::BOTTOM_LEFT_BACK_CORNER_3D: // g + case VertexPosition::CENTER_2D: + return 6; + case VertexPosition::TOP_BACK_EDGE_3D: // ef + case VertexPosition::BOTTOM_FRONT_EDGE_3D: // cd + case VertexPosition::LEFT_FRONT_EDGE_3D: // ac + case VertexPosition::TOP_LEFT_EDGE_3D: // ae + case VertexPosition::RIGHT_BACK_EDGE_3D: // fh + case VertexPosition::BOTTOM_RIGHT_EDGE_3D: // dh + return 4; + case VertexPosition::TOP_EDGE_2D: // ab + case VertexPosition::BOTTOM_EDGE_2D: // cd + case VertexPosition::LEFT_EDGE_2D: // ac + case VertexPosition::RIGHT_EDGE_2D: // bd + return 3; + case VertexPosition::TOP_LEFT_FRONT_CORNER_3D: // a + case VertexPosition::BOTTOM_LEFT_FRONT_CORNER_3D: // c + case VertexPosition::BOTTOM_RIGHT_FRONT_CORNER_3D: // d + case VertexPosition::TOP_LEFT_BACK_CORNER_3D: // e + case VertexPosition::TOP_RIGHT_BACK_CORNER_3D: // f + case VertexPosition::BOTTOM_RIGHT_BACK_CORNER_3D: // h + case VertexPosition::TOP_RIGHT_CORNER_2D: // b + case VertexPosition::BOTTOM_LEFT_CORNER_2D: // c + return 2; + case VertexPosition::TOP_LEFT_CORNER_2D: // a + case VertexPosition::BOTTOM_RIGHT_CORNER_2D: // d + return 1; + default: // 1D + break; + } + + return 0; + } + + inline int TTK_TRIANGULATION_INTERNAL(getVertexStar)( + const SimplexId &vertexId, + const int &localStarId, + SimplexId &starId) const override { + +#ifndef TTK_ENABLE_KAMIKAZE + if(localStarId < 0 or localStarId >= getVertexStarNumber(vertexId)) + return -1; +#endif // !TTK_ENABLE_KAMIKAZE + + const auto &p = this->underlying().getVertexCoords(vertexId); + + switch(this->underlying().getVertexPosition(vertexId)) { + case VertexPosition::CENTER_3D: + starId = getVertexStarABCDEFGH(p.data(), localStarId); + break; + case VertexPosition::FRONT_FACE_3D: + starId = getVertexStarABDC(p.data(), localStarId); + break; + case VertexPosition::BACK_FACE_3D: + starId = getVertexStarEFHG(p.data(), localStarId); + break; + case VertexPosition::TOP_FACE_3D: + starId = getVertexStarAEFB(p.data(), localStarId); + break; + case VertexPosition::BOTTOM_FACE_3D: + starId = getVertexStarGHDC(p.data(), localStarId); + break; + case VertexPosition::LEFT_FACE_3D: + starId = getVertexStarAEGC(p.data(), localStarId); + break; + case VertexPosition::RIGHT_FACE_3D: + starId = getVertexStarBFHD(p.data(), localStarId); + break; + case VertexPosition::TOP_FRONT_EDGE_3D: // ab + starId = getVertexStarAB(p.data(), localStarId); + break; + case VertexPosition::BOTTOM_FRONT_EDGE_3D: // cd + starId = getVertexStarCD(p.data(), localStarId); + break; + case VertexPosition::LEFT_FRONT_EDGE_3D: // ac + starId = getVertexStarAC(p.data(), localStarId); + break; + case VertexPosition::RIGHT_FRONT_EDGE_3D: // bd + starId = getVertexStarBD(p.data(), localStarId); + break; + case VertexPosition::TOP_BACK_EDGE_3D: // ef + starId = getVertexStarEF(p.data(), localStarId); + break; + case VertexPosition::BOTTOM_BACK_EDGE_3D: // gh + starId = getVertexStarGH(p.data(), localStarId); + break; + case VertexPosition::LEFT_BACK_EDGE_3D: // eg + starId = getVertexStarEG(p.data(), localStarId); + break; + case VertexPosition::RIGHT_BACK_EDGE_3D: // fh + starId = getVertexStarFH(p.data(), localStarId); + break; + case VertexPosition::TOP_LEFT_EDGE_3D: // ae + starId = getVertexStarAE(p.data(), localStarId); + break; + case VertexPosition::TOP_RIGHT_EDGE_3D: // bf + starId = getVertexStarBF(p.data(), localStarId); + break; + case VertexPosition::BOTTOM_LEFT_EDGE_3D: // cg + starId = getVertexStarCG(p.data(), localStarId); + break; + case VertexPosition::BOTTOM_RIGHT_EDGE_3D: // dh + starId = getVertexStarDH(p.data(), localStarId); + break; + case VertexPosition::TOP_LEFT_FRONT_CORNER_3D: // a + starId = getVertexStarA(p.data(), localStarId); + break; + case VertexPosition::TOP_RIGHT_FRONT_CORNER_3D: // b + starId = getVertexStarB(p.data(), localStarId); + break; + case VertexPosition::BOTTOM_LEFT_FRONT_CORNER_3D: // c + starId = getVertexStarC(p.data(), localStarId); + break; + case VertexPosition::BOTTOM_RIGHT_FRONT_CORNER_3D: // d + starId = getVertexStarD(p.data(), localStarId); + break; + case VertexPosition::TOP_LEFT_BACK_CORNER_3D: // e + starId = getVertexStarE(p.data(), localStarId); + break; + case VertexPosition::TOP_RIGHT_BACK_CORNER_3D: // f + starId = getVertexStarF(p.data(), localStarId); + break; + case VertexPosition::BOTTOM_LEFT_BACK_CORNER_3D: // g + starId = getVertexStarG(p.data(), localStarId); + break; + case VertexPosition::BOTTOM_RIGHT_BACK_CORNER_3D: // h + starId = getVertexStarH(p.data(), localStarId); + break; + case VertexPosition::CENTER_2D: + starId = getVertexStar2dABCD(p.data(), localStarId); + break; + case VertexPosition::TOP_EDGE_2D: + starId = getVertexStar2dAB(p.data(), localStarId); + break; + case VertexPosition::BOTTOM_EDGE_2D: + starId = getVertexStar2dCD(p.data(), localStarId); + break; + case VertexPosition::LEFT_EDGE_2D: + starId = getVertexStar2dAC(p.data(), localStarId); + break; + case VertexPosition::RIGHT_EDGE_2D: + starId = getVertexStar2dBD(p.data(), localStarId); + break; + case VertexPosition::TOP_LEFT_CORNER_2D: // a + starId = getVertexStar2dA(p.data(), localStarId); + break; + case VertexPosition::TOP_RIGHT_CORNER_2D: // b + starId = getVertexStar2dB(p.data(), localStarId); + break; + case VertexPosition::BOTTOM_LEFT_CORNER_2D: // c + starId = getVertexStar2dC(p.data(), localStarId); + break; + case VertexPosition::BOTTOM_RIGHT_CORNER_2D: // d + starId = getVertexStar2dD(p.data(), localStarId); + break; + default: // 1D + starId = -1; + break; + } + + return 0; + } + + inline int TTK_TRIANGULATION_INTERNAL(getVertexPoint)( + const SimplexId &vertexId, float &x, float &y, float &z) const override { + if(dimensionality_ == 3) { + const auto &p = this->underlying().getVertexCoords(vertexId); + + x = origin_[0] + spacing_[0] * p[0]; + y = origin_[1] + spacing_[1] * p[1]; + z = origin_[2] + spacing_[2] * p[2]; + } else if(dimensionality_ == 2) { + const auto &p = this->underlying().getVertexCoords(vertexId); + + if(dimensions_[0] > 1 and dimensions_[1] > 1) { + x = origin_[0] + spacing_[0] * p[0]; + y = origin_[1] + spacing_[1] * p[1]; + z = origin_[2]; + } else if(dimensions_[1] > 1 and dimensions_[2] > 1) { + x = origin_[0]; + y = origin_[1] + spacing_[1] * p[0]; + z = origin_[2] + spacing_[2] * p[1]; + } else if(dimensions_[0] > 1 and dimensions_[2] > 1) { + x = origin_[0] + spacing_[0] * p[0]; + y = origin_[1]; + z = origin_[2] + spacing_[2] * p[1]; + } + } else if(dimensionality_ == 1) { + if(dimensions_[0] > 1) { + x = origin_[0] + spacing_[0] * vertexId; + y = origin_[1]; + z = origin_[2]; + } else if(dimensions_[1] > 1) { + x = origin_[0]; + y = origin_[1] + spacing_[1] * vertexId; + z = origin_[2]; + } else if(dimensions_[2] > 1) { + x = origin_[0]; + y = origin_[1]; + z = origin_[2] + spacing_[2] * vertexId; + } + } + + return 0; + } + + inline int getEdgeVertexInternal(const SimplexId &edgeId, + const int &localVertexId, + SimplexId &vertexId) const override { + +#ifndef TTK_ENABLE_KAMIKAZE + if(edgeId < 0 or edgeId >= edgeNumber_) + return -1; + if(localVertexId < 0 or localVertexId >= 2) + return -2; +#endif + + const auto &p = this->underlying().getEdgeCoords(edgeId); + + const auto helper3d + = [&](const SimplexId a, const SimplexId b) -> SimplexId { + if(isAccelerated_) { + const auto tmp = p[0] + (p[1] << div_[0]) + (p[2] << div_[1]); + return (localVertexId == 0) ? tmp + a : tmp + b; + } else { + const auto tmp = p[0] + (p[1] * vshift_[0]) + (p[2] * vshift_[1]); + return (localVertexId == 0) ? tmp + a : tmp + b; + } + }; + + const auto helper2d + = [&](const SimplexId a, const SimplexId b) -> SimplexId { + if(isAccelerated_) { + const auto tmp = p[0] + (p[1] << div_[0]); + return localVertexId == 0 ? tmp + a : tmp + b; + } else { + const auto tmp = p[0] + (p[1] * vshift_[0]); + return localVertexId == 0 ? tmp + a : tmp + b; + } + }; + + switch(this->underlying().getEdgePosition(edgeId)) { + CASE_EDGE_POSITION_L_3D: + vertexId = helper3d(0, 1); + break; + CASE_EDGE_POSITION_H_3D: + vertexId = helper3d(0, vshift_[0]); + break; + CASE_EDGE_POSITION_P_3D: + vertexId = helper3d(0, vshift_[1]); + break; + CASE_EDGE_POSITION_D1_3D: + vertexId = helper3d(1, vshift_[0]); + break; + CASE_EDGE_POSITION_D2_3D: + vertexId = helper3d(0, vshift_[0] + vshift_[1]); + break; + CASE_EDGE_POSITION_D3_3D: + vertexId = helper3d(1, vshift_[1]); + break; + case EdgePosition::D4_3D: + vertexId = helper3d(1, vshift_[0] + vshift_[1]); + break; + CASE_EDGE_POSITION_L_2D: + vertexId = helper2d(0, 1); + break; + CASE_EDGE_POSITION_H_2D: + vertexId = helper2d(0, vshift_[0]); + break; + case EdgePosition::D1_2D: + vertexId = helper2d(1, vshift_[0]); + break; + + case EdgePosition::FIRST_EDGE_1D: + vertexId = localVertexId == 0 ? 0 : 1; + break; + case EdgePosition::LAST_EDGE_1D: + vertexId = localVertexId == 0 ? edgeNumber_ - 1 : edgeNumber_; + break; + case EdgePosition::CENTER_1D: + vertexId = localVertexId == 0 ? edgeId : edgeId + 1; + break; + } + + return 0; + } + + inline SimplexId + getEdgeTriangleNumberInternal(const SimplexId &edgeId) const override { + +#ifndef TTK_ENABLE_KAMIKAZE + if(edgeId < 0 or edgeId >= edgeNumber_) + return -1; +#endif + + switch(this->underlying().getEdgePosition(edgeId)) { + case EdgePosition::L_xnn_3D: + case EdgePosition::H_nyn_3D: + case EdgePosition::P_nnz_3D: + case EdgePosition::D4_3D: + return 6; + case EdgePosition::L_x0n_3D: + case EdgePosition::L_xNn_3D: + case EdgePosition::L_xn0_3D: + case EdgePosition::L_xnN_3D: + case EdgePosition::H_ny0_3D: + case EdgePosition::H_nyN_3D: + case EdgePosition::H_0yn_3D: + case EdgePosition::H_Nyn_3D: + case EdgePosition::P_n0z_3D: + case EdgePosition::P_nNz_3D: + case EdgePosition::P_0nz_3D: + case EdgePosition::P_Nnz_3D: + case EdgePosition::D1_xyn_3D: + case EdgePosition::D2_nyz_3D: + case EdgePosition::D3_xnz_3D: + return 4; + case EdgePosition::L_x00_3D: + case EdgePosition::L_xNN_3D: + case EdgePosition::H_0yN_3D: + case EdgePosition::H_Ny0_3D: + case EdgePosition::P_0Nz_3D: + case EdgePosition::P_N0z_3D: + case EdgePosition::D1_xy0_3D: + case EdgePosition::D1_xyN_3D: + case EdgePosition::D2_0yz_3D: + case EdgePosition::D2_Nyz_3D: + case EdgePosition::D3_x0z_3D: + case EdgePosition::D3_xNz_3D: + return 3; + case EdgePosition::L_xN0_3D: + case EdgePosition::L_x0N_3D: + case EdgePosition::H_0y0_3D: + case EdgePosition::H_NyN_3D: + case EdgePosition::P_00z_3D: + case EdgePosition::P_NNz_3D: + case EdgePosition::L_xn_2D: + case EdgePosition::H_ny_2D: + case EdgePosition::D1_2D: + return 2; + case EdgePosition::L_x0_2D: + case EdgePosition::L_xN_2D: + case EdgePosition::H_0y_2D: + case EdgePosition::H_Ny_2D: + return 1; + + default: // 1D + break; + } + + return 0; + } + + inline int getEdgeTriangleInternal(const SimplexId &edgeId, + const int &localTriangleId, + SimplexId &triangleId) const override { +#ifndef TTK_ENABLE_KAMIKAZE + if(localTriangleId < 0 + or localTriangleId >= getEdgeTriangleNumberInternal(edgeId)) + return -1; +#endif + + const auto &p = this->underlying().getEdgeCoords(edgeId); + + switch(this->underlying().getEdgePosition(edgeId)) { + case EdgePosition::L_xnn_3D: + triangleId = getEdgeTriangleL_xnn(p.data(), localTriangleId); + break; + case EdgePosition::L_xn0_3D: + triangleId = getEdgeTriangleL_xn0(p.data(), localTriangleId); + break; + case EdgePosition::L_xnN_3D: + triangleId = getEdgeTriangleL_xnN(p.data(), localTriangleId); + break; + case EdgePosition::L_x0n_3D: + triangleId = getEdgeTriangleL_x0n(p.data(), localTriangleId); + break; + case EdgePosition::L_x00_3D: + triangleId = getEdgeTriangleL_x00(p.data(), localTriangleId); + break; + case EdgePosition::L_x0N_3D: + triangleId = getEdgeTriangleL_x0N(p.data(), localTriangleId); + break; + case EdgePosition::L_xNn_3D: + triangleId = getEdgeTriangleL_xNn(p.data(), localTriangleId); + break; + case EdgePosition::L_xN0_3D: + triangleId = getEdgeTriangleL_xN0(p.data(), localTriangleId); + break; + case EdgePosition::L_xNN_3D: + triangleId = getEdgeTriangleL_xNN(p.data(), localTriangleId); + break; + case EdgePosition::H_nyn_3D: + triangleId = getEdgeTriangleH_nyn(p.data(), localTriangleId); + break; + case EdgePosition::H_ny0_3D: + triangleId = getEdgeTriangleH_ny0(p.data(), localTriangleId); + break; + case EdgePosition::H_nyN_3D: + triangleId = getEdgeTriangleH_nyN(p.data(), localTriangleId); + break; + case EdgePosition::H_0yn_3D: + triangleId = getEdgeTriangleH_0yn(p.data(), localTriangleId); + break; + case EdgePosition::H_0y0_3D: + triangleId = getEdgeTriangleH_0y0(p.data(), localTriangleId); + break; + case EdgePosition::H_0yN_3D: + triangleId = getEdgeTriangleH_0yN(p.data(), localTriangleId); + break; + case EdgePosition::H_Nyn_3D: + triangleId = getEdgeTriangleH_Nyn(p.data(), localTriangleId); + break; + case EdgePosition::H_Ny0_3D: + triangleId = getEdgeTriangleH_Ny0(p.data(), localTriangleId); + break; + case EdgePosition::H_NyN_3D: + triangleId = getEdgeTriangleH_NyN(p.data(), localTriangleId); + break; + case EdgePosition::P_nnz_3D: + triangleId = getEdgeTriangleP_nnz(p.data(), localTriangleId); + break; + case EdgePosition::P_n0z_3D: + triangleId = getEdgeTriangleP_n0z(p.data(), localTriangleId); + break; + case EdgePosition::P_nNz_3D: + triangleId = getEdgeTriangleP_nNz(p.data(), localTriangleId); + break; + case EdgePosition::P_0nz_3D: + triangleId = getEdgeTriangleP_0nz(p.data(), localTriangleId); + break; + case EdgePosition::P_00z_3D: + triangleId = getEdgeTriangleP_00z(p.data(), localTriangleId); + break; + case EdgePosition::P_0Nz_3D: + triangleId = getEdgeTriangleP_0Nz(p.data(), localTriangleId); + break; + case EdgePosition::P_Nnz_3D: + triangleId = getEdgeTriangleP_Nnz(p.data(), localTriangleId); + break; + case EdgePosition::P_N0z_3D: + triangleId = getEdgeTriangleP_N0z(p.data(), localTriangleId); + break; + case EdgePosition::P_NNz_3D: + triangleId = getEdgeTriangleP_NNz(p.data(), localTriangleId); + break; + case EdgePosition::D1_xyn_3D: + triangleId = getEdgeTriangleD1_xyn(p.data(), localTriangleId); + break; + case EdgePosition::D1_xy0_3D: + triangleId = getEdgeTriangleD1_xy0(p.data(), localTriangleId); + break; + case EdgePosition::D1_xyN_3D: + triangleId = getEdgeTriangleD1_xyN(p.data(), localTriangleId); + break; + case EdgePosition::D2_nyz_3D: + triangleId = getEdgeTriangleD2_nyz(p.data(), localTriangleId); + break; + case EdgePosition::D2_0yz_3D: + triangleId = getEdgeTriangleD2_0yz(p.data(), localTriangleId); + break; + case EdgePosition::D2_Nyz_3D: + triangleId = getEdgeTriangleD2_Nyz(p.data(), localTriangleId); + break; + case EdgePosition::D3_xnz_3D: + triangleId = getEdgeTriangleD3_xnz(p.data(), localTriangleId); + break; + case EdgePosition::D3_x0z_3D: + triangleId = getEdgeTriangleD3_x0z(p.data(), localTriangleId); + break; + case EdgePosition::D3_xNz_3D: + triangleId = getEdgeTriangleD3_xNz(p.data(), localTriangleId); + break; + case EdgePosition::D4_3D: + triangleId = getEdgeTriangleD4_xyz(p.data(), localTriangleId); + break; + + case EdgePosition::L_xn_2D: + triangleId = getEdgeTriangleL_xn(p.data(), localTriangleId); + break; + case EdgePosition::L_x0_2D: + triangleId = getEdgeTriangleL_x0(p.data(), localTriangleId); + break; + case EdgePosition::L_xN_2D: + triangleId = getEdgeTriangleL_xN(p.data(), localTriangleId); + break; + case EdgePosition::H_ny_2D: + triangleId = getEdgeTriangleH_ny(p.data(), localTriangleId); + break; + case EdgePosition::H_0y_2D: + triangleId = getEdgeTriangleH_0y(p.data(), localTriangleId); + break; + case EdgePosition::H_Ny_2D: + triangleId = getEdgeTriangleH_Ny(p.data(), localTriangleId); + break; + case EdgePosition::D1_2D: + triangleId = getEdgeTriangleD1_xy(p.data(), localTriangleId); + break; + + default: // 1D + triangleId = -1; + break; + } + + return 0; + } + + inline int TTK_TRIANGULATION_INTERNAL(getEdgeLink)( + const SimplexId &edgeId, + const int &localLinkId, + SimplexId &linkId) const override { + +#ifndef TTK_ENABLE_KAMIKAZE + if(localLinkId < 0 or localLinkId >= getEdgeLinkNumber(edgeId)) + return -1; +#endif + + const auto &p = this->underlying().getEdgeCoords(edgeId); + + switch(this->underlying().getEdgePosition(edgeId)) { + CASE_EDGE_POSITION_L_3D: + linkId = getEdgeLinkL(p.data(), localLinkId); + break; + CASE_EDGE_POSITION_H_3D: + linkId = getEdgeLinkH(p.data(), localLinkId); + break; + CASE_EDGE_POSITION_P_3D: + linkId = getEdgeLinkP(p.data(), localLinkId); + break; + CASE_EDGE_POSITION_D1_3D: + linkId = getEdgeLinkD1(p.data(), localLinkId); + break; + CASE_EDGE_POSITION_D2_3D: + linkId = getEdgeLinkD2(p.data(), localLinkId); + break; + CASE_EDGE_POSITION_D3_3D: + linkId = getEdgeLinkD3(p.data(), localLinkId); + break; + case EdgePosition::D4_3D: + linkId = getEdgeLinkD4(p.data(), localLinkId); + break; + + CASE_EDGE_POSITION_L_2D: + linkId = getEdgeLink2dL(p.data(), localLinkId); + break; + CASE_EDGE_POSITION_H_2D: + linkId = getEdgeLink2dH(p.data(), localLinkId); + break; + case EdgePosition::D1_2D: + linkId = getEdgeLink2dD1(p.data(), localLinkId); + break; + + default: // 1D + linkId = -1; + break; + } + + return 0; + } + + inline int TTK_TRIANGULATION_INTERNAL(getEdgeStar)( + const SimplexId &edgeId, + const int &localStarId, + SimplexId &starId) const override { +#ifndef TTK_ENABLE_KAMIKAZE + if(localStarId < 0 or localStarId >= getEdgeStarNumber(edgeId)) + return -1; +#endif + + const auto &p = this->underlying().getEdgeCoords(edgeId); + + switch(this->underlying().getEdgePosition(edgeId)) { + CASE_EDGE_POSITION_L_3D: + starId = getEdgeStarL(p.data(), localStarId); + break; + CASE_EDGE_POSITION_H_3D: + starId = getEdgeStarH(p.data(), localStarId); + break; + CASE_EDGE_POSITION_P_3D: + starId = getEdgeStarP(p.data(), localStarId); + break; + CASE_EDGE_POSITION_D1_3D: + starId = getEdgeStarD1(p.data(), localStarId); + break; + CASE_EDGE_POSITION_D2_3D: + starId = getEdgeStarD2(p.data(), localStarId); + break; + CASE_EDGE_POSITION_D3_3D: + starId = getEdgeStarD3(p.data(), localStarId); + break; + case EdgePosition::D4_3D: + starId = p[2] * tetshift_[1] + p[1] * tetshift_[0] + p[0] * 6 + + localStarId; + break; + + CASE_EDGE_POSITION_L_2D: + starId = getEdgeStar2dL(p.data(), localStarId); + break; + CASE_EDGE_POSITION_H_2D: + starId = getEdgeStar2dH(p.data(), localStarId); + break; + case EdgePosition::D1_2D: + starId = p[0] * 2 + p[1] * tshift_[0] + localStarId; + break; + + default: // 1D + starId = -1; + break; + } + + return 0; + } + + inline SimplexId TTK_TRIANGULATION_INTERNAL(getEdgeStarNumber)( + const SimplexId &edgeId) const override { + +#ifndef TTK_ENABLE_KAMIKAZE + if(edgeId < 0 or edgeId >= edgeNumber_) + return -1; +#endif + + switch(this->underlying().getEdgePosition(edgeId)) { + case EdgePosition::L_xnn_3D: + case EdgePosition::H_nyn_3D: + case EdgePosition::P_nnz_3D: + case EdgePosition::D4_3D: + return 6; + case EdgePosition::D1_xyn_3D: + case EdgePosition::D2_nyz_3D: + case EdgePosition::D3_xnz_3D: + return 4; + case EdgePosition::L_x0n_3D: + case EdgePosition::L_xNn_3D: + case EdgePosition::L_xn0_3D: + case EdgePosition::L_xnN_3D: + case EdgePosition::H_ny0_3D: + case EdgePosition::H_nyN_3D: + case EdgePosition::H_0yn_3D: + case EdgePosition::H_Nyn_3D: + case EdgePosition::P_n0z_3D: + case EdgePosition::P_nNz_3D: + case EdgePosition::P_0nz_3D: + case EdgePosition::P_Nnz_3D: + return 3; + case EdgePosition::L_x00_3D: + case EdgePosition::L_xNN_3D: + case EdgePosition::H_0yN_3D: + case EdgePosition::H_Ny0_3D: + case EdgePosition::P_0Nz_3D: + case EdgePosition::P_N0z_3D: + case EdgePosition::D1_xy0_3D: + case EdgePosition::D1_xyN_3D: + case EdgePosition::D2_0yz_3D: + case EdgePosition::D2_Nyz_3D: + case EdgePosition::D3_x0z_3D: + case EdgePosition::D3_xNz_3D: + case EdgePosition::L_xn_2D: + case EdgePosition::H_ny_2D: + case EdgePosition::D1_2D: + return 2; + case EdgePosition::L_xN0_3D: + case EdgePosition::L_x0N_3D: + case EdgePosition::H_0y0_3D: + case EdgePosition::H_NyN_3D: + case EdgePosition::P_00z_3D: + case EdgePosition::P_NNz_3D: + case EdgePosition::L_x0_2D: + case EdgePosition::L_xN_2D: + case EdgePosition::H_0y_2D: + case EdgePosition::H_Ny_2D: + return 1; + + default: // 1D + break; + } + + return 0; + } int getTriangleVertexInternal(const SimplexId &triangleId, const int &localVertexId, From 0e4eee9b9cec77bbacb0d514f345857510539094 Mon Sep 17 00:00:00 2001 From: Julien Tierny Date: Thu, 21 Sep 2023 12:29:13 +0200 Subject: [PATCH 03/12] further implicit in-lining --- .../ImplicitTriangulation.cpp | 912 --------- .../ImplicitTriangulation.h | 1643 +++++++++++++---- 2 files changed, 1299 insertions(+), 1256 deletions(-) diff --git a/core/base/implicitTriangulation/ImplicitTriangulation.cpp b/core/base/implicitTriangulation/ImplicitTriangulation.cpp index 02e8394ad8..373f25b844 100644 --- a/core/base/implicitTriangulation/ImplicitTriangulation.cpp +++ b/core/base/implicitTriangulation/ImplicitTriangulation.cpp @@ -391,172 +391,6 @@ const vector> * return &edgeStarList_; } -template -int ImplicitTriangulationCRTP::getTriangleVertexInternal( - const SimplexId &triangleId, - const int &localVertexId, - SimplexId &vertexId) const { -#ifndef TTK_ENABLE_KAMIKAZE - if(triangleId < 0 or triangleId >= triangleNumber_) - return -1; - if(localVertexId < 0 or localVertexId >= 3) - return -2; -#endif - - // e--------f - // /| /| - // / | / | - // a--g-----b--h - // | / | / - // |/ |/ - // c--------d - // - // Classement des "Triangles" et dans cet ordre: - // F: face (type abc/bcd) - // C: cote (type abe/bef) - // H: haut (type acg/aeg) - // D1: diagonale1 (type bdg/beg) - // D2: diagonale2 (type abg/bgh) - // D3: diagonale3 (type bcg/bfg) - - const auto &p = this->underlying().getTriangleCoords(triangleId); - vertexId = -1; - - switch(this->underlying().getTrianglePosition(triangleId)) { - case TrianglePosition::F_3D: - vertexId = getTriangleVertexF(p.data(), localVertexId); - break; - case TrianglePosition::H_3D: - vertexId = getTriangleVertexH(p.data(), localVertexId); - break; - case TrianglePosition::C_3D: - vertexId = getTriangleVertexC(p.data(), localVertexId); - break; - case TrianglePosition::D1_3D: - vertexId = getTriangleVertexD1(p.data(), localVertexId); - break; - case TrianglePosition::D2_3D: - vertexId = getTriangleVertexD2(p.data(), localVertexId); - break; - case TrianglePosition::D3_3D: - vertexId = getTriangleVertexD3(p.data(), localVertexId); - break; - case TrianglePosition::TOP_2D: - switch(localVertexId) { - break; - case 0: - vertexId = p[0] / 2 + p[1] * vshift_[0]; - break; - case 1: - vertexId = p[0] / 2 + p[1] * vshift_[0] + 1; - break; - case 2: - vertexId = p[0] / 2 + p[1] * vshift_[0] + vshift_[0]; - break; - } - break; - case TrianglePosition::BOTTOM_2D: - switch(localVertexId) { - break; - case 0: - vertexId = p[0] / 2 + p[1] * vshift_[0] + 1; - break; - case 1: - vertexId = p[0] / 2 + p[1] * vshift_[0] + vshift_[0] + 1; - break; - case 2: - vertexId = p[0] / 2 + p[1] * vshift_[0] + vshift_[0]; - break; - } - } - - return 0; -} - -template -int ImplicitTriangulationCRTP::getTriangleEdgeInternal( - const SimplexId &triangleId, - const int &localEdgeId, - SimplexId &edgeId) const { -#ifndef TTK_ENABLE_KAMIKAZE - if(triangleId < 0 or triangleId >= triangleNumber_) - return -1; - if(localEdgeId < 0 or localEdgeId >= 3) - return -2; -#endif - - const auto &p = this->underlying().getTriangleCoords(triangleId); - const auto par = triangleId % 2; - edgeId = -1; - - switch(this->underlying().getTrianglePosition(triangleId)) { - case TrianglePosition::F_3D: - edgeId = (par == 1) ? getTriangleEdgeF_1(p.data(), localEdgeId) - : getTriangleEdgeF_0(p.data(), localEdgeId); - break; - case TrianglePosition::H_3D: - edgeId = (par == 1) ? getTriangleEdgeH_1(p.data(), localEdgeId) - : getTriangleEdgeH_0(p.data(), localEdgeId); - break; - case TrianglePosition::C_3D: - edgeId = (par == 1) ? getTriangleEdgeC_1(p.data(), localEdgeId) - : getTriangleEdgeC_0(p.data(), localEdgeId); - break; - case TrianglePosition::D1_3D: - edgeId = (par == 1) ? getTriangleEdgeD1_1(p.data(), localEdgeId) - : getTriangleEdgeD1_0(p.data(), localEdgeId); - break; - case TrianglePosition::D2_3D: - edgeId = (par == 1) ? getTriangleEdgeD2_1(p.data(), localEdgeId) - : getTriangleEdgeD2_0(p.data(), localEdgeId); - break; - case TrianglePosition::D3_3D: - edgeId = (par == 1) ? getTriangleEdgeD3_1(p.data(), localEdgeId) - : getTriangleEdgeD3_0(p.data(), localEdgeId); - break; - case TrianglePosition::TOP_2D: - switch(localEdgeId) { - break; - case 0: - edgeId = p[0] / 2 + p[1] * eshift_[0]; - break; - case 1: - edgeId = esetshift_[0] + p[0] / 2 + p[1] * eshift_[2]; - break; - case 2: - edgeId = esetshift_[1] + p[0] / 2 + p[1] * eshift_[4]; - break; - } - break; - case TrianglePosition::BOTTOM_2D: - switch(localEdgeId) { - break; - case 0: - edgeId = p[0] / 2 + (p[1] + 1) * eshift_[0]; - break; - case 1: - edgeId = esetshift_[0] + (p[0] + 1) / 2 + p[1] * eshift_[2]; - break; - case 2: - edgeId = esetshift_[1] + p[0] / 2 + p[1] * eshift_[4]; - break; - } - } - - return 0; -} - -int ImplicitTriangulation::getTriangleEdgesInternal( - vector> &edges) const { - edges.resize(triangleNumber_); - for(SimplexId i = 0; i < triangleNumber_; ++i) { - edges[i].resize(3); - for(int j = 0; j < 3; ++j) - getTriangleEdgeInternal(i, j, edges[i][j]); - } - return 0; -} - const vector> * ImplicitTriangulation::getTriangleEdgesInternal() { if(triangleEdgeVector_.empty()) { @@ -590,51 +424,6 @@ const vector> * return &triangleList_; } -template -int ImplicitTriangulationCRTP::TTK_TRIANGULATION_INTERNAL( - getTriangleLink)(const SimplexId &triangleId, - const int &localLinkId, - SimplexId &linkId) const { - -#ifndef TTK_ENABLE_KAMIKAZE - if(localLinkId < 0 or localLinkId >= getTriangleLinkNumber(triangleId)) - return -1; -#endif - - const auto &p = this->underlying().getTriangleCoords(triangleId); - - switch(this->underlying().getTrianglePosition(triangleId)) { - case TrianglePosition::F_3D: - linkId = getTriangleLinkF(p.data(), localLinkId); - break; - case TrianglePosition::H_3D: - linkId = getTriangleLinkH(p.data(), localLinkId); - break; - case TrianglePosition::C_3D: - linkId = getTriangleLinkC(p.data(), localLinkId); - break; - case TrianglePosition::D1_3D: - linkId = getTriangleLinkD1(p.data(), localLinkId); - break; - case TrianglePosition::D2_3D: - linkId = getTriangleLinkD2(p.data(), localLinkId); - break; - case TrianglePosition::D3_3D: - linkId = getTriangleLinkD3(p.data(), localLinkId); - break; - default: // 2D - linkId = -1; - break; - } - - return 0; -} - -SimplexId ImplicitTriangulation::TTK_TRIANGULATION_INTERNAL( - getTriangleLinkNumber)(const SimplexId &triangleId) const { - return TTK_TRIANGULATION_INTERNAL(getTriangleStarNumber)(triangleId); -} - const vector> * ImplicitTriangulation::TTK_TRIANGULATION_INTERNAL(getTriangleLinks)() { if(triangleLinkList_.empty()) { @@ -653,75 +442,6 @@ const vector> * return &triangleLinkList_; } -template -SimplexId ImplicitTriangulationCRTP::TTK_TRIANGULATION_INTERNAL( - getTriangleStarNumber)(const SimplexId &triangleId) const { - -#ifndef TTK_ENABLE_KAMIKAZE - if(triangleId < 0 or triangleId >= triangleNumber_) - return -1; -#endif - - const auto &p = this->underlying().getTriangleCoords(triangleId); - - switch(this->underlying().getTrianglePosition(triangleId)) { - case TrianglePosition::F_3D: - return (p[2] > 0 and p[2] < nbvoxels_[2]) ? 2 : 1; - case TrianglePosition::H_3D: - return (p[1] > 0 and p[1] < nbvoxels_[1]) ? 2 : 1; - case TrianglePosition::C_3D: - return (p[0] < 2 or p[0] >= (dimensions_[0] * 2 - 2)) ? 1 : 2; - - case TrianglePosition::D1_3D: - case TrianglePosition::D2_3D: - case TrianglePosition::D3_3D: - return 2; - default: // 2D - break; - } - return 0; -} - -template -int ImplicitTriangulationCRTP::TTK_TRIANGULATION_INTERNAL( - getTriangleStar)(const SimplexId &triangleId, - const int &localStarId, - SimplexId &starId) const { - -#ifndef TTK_ENABLE_KAMIKAZE - if(localStarId < 0 or localStarId >= getTriangleStarNumber(triangleId)) - return -1; -#endif - - const auto &p = this->underlying().getTriangleCoords(triangleId); - - switch(this->underlying().getTrianglePosition(triangleId)) { - case TrianglePosition::F_3D: - starId = getTriangleStarF(p.data(), localStarId); - break; - case TrianglePosition::H_3D: - starId = getTriangleStarH(p.data(), localStarId); - break; - case TrianglePosition::C_3D: - starId = getTriangleStarC(p.data(), localStarId); - break; - case TrianglePosition::D1_3D: - starId = getTriangleStarD1(p.data(), localStarId); - break; - case TrianglePosition::D2_3D: - starId = getTriangleStarD2(p.data(), localStarId); - break; - case TrianglePosition::D3_3D: - starId = getTriangleStarD3(p.data(), localStarId); - break; - default: // 2D - starId = -1; - break; - } - - return 0; -} - const vector> * ImplicitTriangulation::TTK_TRIANGULATION_INTERNAL(getTriangleStars)() { @@ -741,129 +461,6 @@ const vector> * return &triangleStarList_; } -template -SimplexId ImplicitTriangulationCRTP::getTriangleNeighborNumber( - const SimplexId &triangleId) const { -#ifndef TTK_ENABLE_KAMIKAZE - if(triangleId < 0 or triangleId >= triangleNumber_) - return -1; -#endif - - if(dimensionality_ == 2) { - const auto &p = this->underlying().getTriangleCoords(triangleId); - const SimplexId id = triangleId % 2; - - if(id) { - if(p[0] / 2 == nbvoxels_[Di_] - 1 and p[1] == nbvoxels_[Dj_] - 1) - return 1; - else if(p[0] / 2 == nbvoxels_[Di_] - 1 or p[1] == nbvoxels_[Dj_] - 1) - return 2; - else - return 3; - } else { - if(p[0] == 0 and p[1] == 0) - return 1; - else if(p[0] == 0 or p[1] == 0) - return 2; - else - return 3; - } - } - - return 0; -} - -template -int ImplicitTriangulationCRTP::getTriangleNeighbor( - const SimplexId &triangleId, - const int &localNeighborId, - SimplexId &neighborId) const { -#ifndef TTK_ENABLE_KAMIKAZE - if(localNeighborId < 0 - or localNeighborId >= getTriangleNeighborNumber(triangleId)) - return -1; -#endif - - neighborId = -1; - - if(dimensionality_ == 2) { - const auto &p = this->underlying().getTriangleCoords(triangleId); - const SimplexId id = triangleId % 2; - - if(id) { - if(p[0] / 2 == nbvoxels_[Di_] - 1 and p[1] == nbvoxels_[Dj_] - 1) - neighborId = triangleId - 1; - else if(p[0] / 2 == nbvoxels_[Di_] - 1) { - switch(localNeighborId) { - case 0: - neighborId = triangleId - 1; - break; - case 1: - neighborId = triangleId + tshift_[0] - 1; - break; - } - } else if(p[1] == nbvoxels_[Dj_] - 1) { - switch(localNeighborId) { - case 0: - neighborId = triangleId - 1; - break; - case 1: - neighborId = triangleId + 1; - break; - } - } else { - switch(localNeighborId) { - case 0: - neighborId = triangleId - 1; - break; - case 1: - neighborId = triangleId + 1; - break; - case 2: - neighborId = triangleId + tshift_[0] - 1; - break; - } - } - } else { - if(p[0] == 0 and p[1] == 0) - neighborId = triangleId + 1; - else if(p[0] == 0) { - switch(localNeighborId) { - case 0: - neighborId = triangleId + 1; - break; - case 1: - neighborId = triangleId - tshift_[0] + 1; - break; - } - } else if(p[1] == 0) { - switch(localNeighborId) { - case 0: - neighborId = triangleId + 1; - break; - case 1: - neighborId = triangleId - 1; - break; - } - } else { - switch(localNeighborId) { - case 0: - neighborId = triangleId + 1; - break; - case 1: - neighborId = triangleId - 1; - break; - case 2: - neighborId = triangleId - tshift_[0] + 1; - break; - } - } - } - } - - return 0; -} - int ImplicitTriangulation::getTriangleNeighbors( vector> &neighbors) { neighbors.resize(triangleNumber_); @@ -875,323 +472,6 @@ int ImplicitTriangulation::getTriangleNeighbors( return 0; } -template -int ImplicitTriangulationCRTP::getTetrahedronVertex( - const SimplexId &tetId, const int &localVertexId, SimplexId &vertexId) const { -#ifndef TTK_ENABLE_KAMIKAZE - if(tetId < 0 or tetId >= tetrahedronNumber_) - return -1; - if(localVertexId < 0 or localVertexId >= 4) - return -2; -#endif - - vertexId = -1; - - if(dimensionality_ == 3) { - const SimplexId id = tetId % 6; - const auto &c = this->underlying().getTetrahedronCoords(tetId); - const auto p{c.data()}; - - switch(id) { - case 0: - vertexId = getTetrahedronVertexABCG(p, localVertexId); - break; - case 1: - vertexId = getTetrahedronVertexBCDG(p, localVertexId); - break; - case 2: - vertexId = getTetrahedronVertexABEG(p, localVertexId); - break; - case 3: - vertexId = getTetrahedronVertexBEFG(p, localVertexId); - break; - case 4: - vertexId = getTetrahedronVertexBFGH(p, localVertexId); - break; - case 5: - vertexId = getTetrahedronVertexBDGH(p, localVertexId); - break; - } - } - return 0; -} - -template -int ImplicitTriangulationCRTP::getTetrahedronEdge( - const SimplexId &tetId, const int &localEdgeId, SimplexId &edgeId) const { -#ifndef TTK_ENABLE_KAMIKAZE - if(tetId < 0 or tetId >= tetrahedronNumber_) - return -1; - if(localEdgeId < 0 or localEdgeId >= 6) - return -2; -#endif - - edgeId = -1; - - if(dimensionality_ == 3) { - const SimplexId id = tetId % 6; - const auto &c = this->underlying().getTetrahedronCoords(tetId); - const auto p{c.data()}; - - switch(id) { - case 0: - edgeId = getTetrahedronEdgeABCG(p, localEdgeId); - break; - case 1: - edgeId = getTetrahedronEdgeBCDG(p, localEdgeId); - break; - case 2: - edgeId = getTetrahedronEdgeABEG(p, localEdgeId); - break; - case 3: - edgeId = getTetrahedronEdgeBEFG(p, localEdgeId); - break; - case 4: - edgeId = getTetrahedronEdgeBFGH(p, localEdgeId); - break; - case 5: - edgeId = getTetrahedronEdgeBDGH(p, localEdgeId); - break; - } - } - - return 0; -} - -int ImplicitTriangulation::getTetrahedronEdges( - vector> &edges) const { - edges.resize(tetrahedronNumber_); - for(SimplexId i = 0; i < tetrahedronNumber_; ++i) { - edges[i].resize(6); - for(int j = 0; j < 6; ++j) - getTetrahedronEdge(i, j, edges[i][j]); - } - - return 0; -} - -template -int ImplicitTriangulationCRTP::getTetrahedronTriangle( - const SimplexId &tetId, - const int &localTriangleId, - SimplexId &triangleId) const { -#ifndef TTK_ENABLE_KAMIKAZE - if(tetId < 0 or tetId >= tetrahedronNumber_) - return -1; - if(localTriangleId < 0 or localTriangleId >= 4) - return -2; -#endif - - triangleId = -1; - - if(dimensionality_ == 3) { - const SimplexId id = tetId % 6; - const auto &c = this->underlying().getTetrahedronCoords(tetId); - const auto p{c.data()}; - - switch(id) { - case 0: - triangleId = getTetrahedronTriangleABCG(p, localTriangleId); - break; - case 1: - triangleId = getTetrahedronTriangleBCDG(p, localTriangleId); - break; - case 2: - triangleId = getTetrahedronTriangleABEG(p, localTriangleId); - break; - case 3: - triangleId = getTetrahedronTriangleBEFG(p, localTriangleId); - break; - case 4: - triangleId = getTetrahedronTriangleBFGH(p, localTriangleId); - break; - case 5: - triangleId = getTetrahedronTriangleBDGH(p, localTriangleId); - break; - } - } - - return 0; -} - -int ImplicitTriangulation::getTetrahedronTriangles( - vector> &triangles) const { - triangles.resize(tetrahedronNumber_); - for(SimplexId i = 0; i < tetrahedronNumber_; ++i) { - triangles[i].resize(4); - for(int j = 0; j < 4; ++j) - getTetrahedronTriangle(i, j, triangles[i][j]); - } - - return 0; -} - -template -SimplexId ImplicitTriangulationCRTP::getTetrahedronNeighborNumber( - const SimplexId &tetId) const { -#ifndef TTK_ENABLE_KAMIKAZE - if(tetId < 0 or tetId >= tetrahedronNumber_) - return -1; -#endif - - if(dimensionality_ == 3) { - const SimplexId id = tetId % 6; - const auto &c = this->underlying().getTetrahedronCoords(tetId); - const auto p{c.data()}; - - switch(id) { - case 0: // ABCG - if(p[0] == 0 and p[2] == 0) - return 2; - else if(p[0] == 0 or p[2] == 0) - return 3; - else - return 4; - break; - case 1: // BCDG - if(p[1] == nbvoxels_[1] - 1 and p[2] == 0) - return 2; - else if(p[1] == nbvoxels_[1] - 1 or p[2] == 0) - return 3; - else - return 4; - break; - case 2: // ABEG - if(p[0] == 0 and p[1] == 0) - return 2; - else if(p[0] == 0 or p[1] == 0) - return 3; - else - return 4; - break; - case 3: // BEFG - if(p[1] == 0 and p[2] == nbvoxels_[2] - 1) - return 2; - else if(p[1] == 0 or p[2] == nbvoxels_[2] - 1) - return 3; - else - return 4; - break; - case 4: // BFGH - if(p[0] == nbvoxels_[0] - 1 and p[2] == nbvoxels_[2] - 1) - return 2; - else if(p[0] == nbvoxels_[0] - 1 or p[2] == nbvoxels_[2] - 1) - return 3; - else - return 4; - break; - case 5: // BDGH - if(p[0] == nbvoxels_[0] - 1 and p[1] == nbvoxels_[1] - 1) - return 2; - else if(p[0] == nbvoxels_[0] - 1 or p[1] == nbvoxels_[1] - 1) - return 3; - else - return 4; - break; - } - } - - return 0; -} - -template -int ImplicitTriangulationCRTP::getTetrahedronNeighbor( - const SimplexId &tetId, - const int &localNeighborId, - SimplexId &neighborId) const { -#ifndef TTK_ENABLE_KAMIKAZE - if(localNeighborId < 0 - or localNeighborId >= getTetrahedronNeighborNumber(tetId)) - return -1; -#endif - - neighborId = -1; - - if(dimensionality_ == 3) { - const SimplexId id = tetId % 6; - const auto &c = this->underlying().getTetrahedronCoords(tetId); - const auto p{c.data()}; - - switch(id) { - case 0: - neighborId = getTetrahedronNeighborABCG(tetId, p, localNeighborId); - break; - case 1: - neighborId = getTetrahedronNeighborBCDG(tetId, p, localNeighborId); - break; - case 2: - neighborId = getTetrahedronNeighborABEG(tetId, p, localNeighborId); - break; - case 3: - neighborId = getTetrahedronNeighborBEFG(tetId, p, localNeighborId); - break; - case 4: - neighborId = getTetrahedronNeighborBFGH(tetId, p, localNeighborId); - break; - case 5: - neighborId = getTetrahedronNeighborBDGH(tetId, p, localNeighborId); - break; - } - } - - return 0; -} - -int ImplicitTriangulation::getTetrahedronNeighbors( - vector> &neighbors) { - neighbors.resize(tetrahedronNumber_); - for(SimplexId i = 0; i < tetrahedronNumber_; ++i) { - neighbors[i].resize(getTetrahedronNeighborNumber(i)); - for(SimplexId j = 0; j < (SimplexId)neighbors[i].size(); ++j) - getTetrahedronNeighbor(i, j, neighbors[i][j]); - } - - return 0; -} - -SimplexId ImplicitTriangulation::TTK_TRIANGULATION_INTERNAL( - getCellVertexNumber)(const SimplexId & /*cellId*/) const { - return dimensionality_ + 1; -} - -int ImplicitTriangulation::TTK_TRIANGULATION_INTERNAL(getCellVertex)( - const SimplexId &cellId, - const int &localVertexId, - SimplexId &vertexId) const { - - if(dimensionality_ == 3) - getTetrahedronVertex(cellId, localVertexId, vertexId); - else if(dimensionality_ == 2) - getTriangleVertexInternal(cellId, localVertexId, vertexId); - else if(dimensionality_ == 1) - getEdgeVertexInternal(cellId, localVertexId, vertexId); - - return 0; -} - -SimplexId ImplicitTriangulation::getCellEdgeNumberInternal( - const SimplexId & /*cellId*/) const { - if(dimensionality_ == 3) - return 6; - else if(dimensionality_ == 2) - return 3; - - return 0; -} - -int ImplicitTriangulation::getCellEdgeInternal(const SimplexId &cellId, - const int &localEdgeId, - SimplexId &edgeId) const { - if(dimensionality_ == 3) - getTetrahedronEdge(cellId, localEdgeId, edgeId); - else if(dimensionality_ == 2) - getTriangleEdgeInternal(cellId, localEdgeId, edgeId); - else if(dimensionality_ == 1) - getCellNeighbor(cellId, localEdgeId, edgeId); - - return 0; -} - const vector> *ImplicitTriangulation::getCellEdgesInternal() { if(cellEdgeVector_.empty()) { Timer t; @@ -1208,16 +488,6 @@ const vector> *ImplicitTriangulation::getCellEdgesInternal() { return &cellEdgeVector_; } -int ImplicitTriangulation::getCellTriangleInternal( - const SimplexId &cellId, - const int &localTriangleId, - SimplexId &triangleId) const { - if(dimensionality_ == 3) - getTetrahedronTriangle(cellId, localTriangleId, triangleId); - - return 0; -} - const vector> * ImplicitTriangulation::getCellTrianglesInternal() { if(cellTriangleVector_.empty()) { @@ -1233,36 +503,6 @@ const vector> * return &cellTriangleVector_; } -SimplexId ImplicitTriangulation::TTK_TRIANGULATION_INTERNAL( - getCellNeighborNumber)(const SimplexId &cellId) const { - if(dimensionality_ == 3) - return getTetrahedronNeighborNumber(cellId); - else if(dimensionality_ == 2) - return getTriangleNeighborNumber(cellId); - else if(dimensionality_ == 1) { - printErr("getCellNeighborNumber() not implemented in 1D! (TODO)"); - return -1; - } - - return 0; -} - -int ImplicitTriangulation::TTK_TRIANGULATION_INTERNAL(getCellNeighbor)( - const SimplexId &cellId, - const int &localNeighborId, - SimplexId &neighborId) const { - if(dimensionality_ == 3) - getTetrahedronNeighbor(cellId, localNeighborId, neighborId); - else if(dimensionality_ == 2) - getTriangleNeighbor(cellId, localNeighborId, neighborId); - else if(dimensionality_ == 1) { - printErr("getCellNeighbor() not implemented in 1D! (TODO)"); - return -1; - } - - return 0; -} - const vector> * ImplicitTriangulation::TTK_TRIANGULATION_INTERNAL(getCellNeighbors)() { if(cellNeighborList_.empty()) { @@ -1798,158 +1038,6 @@ void ttk::ImplicitTriangulation::createMetaGrid(const double *const bounds) { this->metaGrid_->preconditionBoundaryTriangles(); } -std::array - ttk::ImplicitTriangulation::getVertGlobalCoords(const SimplexId lvid) const { - - // local vertex coordinates - std::array p{}; - if(this->dimensionality_ == 3) { - this->vertexToPosition(lvid, p.data()); - } else if(this->dimensionality_ == 2) { - this->vertexToPosition2d(lvid, p.data()); - } - - // global vertex coordinates - p[0] += this->localGridOffset_[0]; - p[1] += this->localGridOffset_[1]; - p[2] += this->localGridOffset_[2]; - - return p; -} - -std::array - ttk::ImplicitTriangulation::getVertLocalCoords(const SimplexId gvid) const { - - // global vertex coordinates - std::array p{}; - if(this->dimensionality_ == 3) { - this->metaGrid_->vertexToPosition(gvid, p.data()); - } else if(this->dimensionality_ == 2) { - this->metaGrid_->vertexToPosition2d(gvid, p.data()); - } - - // local vertex coordinates - p[0] -= this->localGridOffset_[0]; - p[1] -= this->localGridOffset_[1]; - p[2] -= this->localGridOffset_[2]; - - return p; -} - -bool ImplicitTriangulation::isVertexOnGlobalBoundaryInternal( - const SimplexId lvid) const { - - if(!ttk::isRunningWithMPI()) { - return this->isVertexOnBoundary(lvid); - } - -#ifndef TTK_ENABLE_KAMIKAZE - if(lvid > this->TTK_TRIANGULATION_INTERNAL(getNumberOfVertices)() - 1 - || lvid < 0) { - return false; - } - if(this->metaGrid_ == nullptr) { - return false; - } -#endif // TTK_ENABLE_KAMIKAZE - - const auto gvid{this->getVertexGlobalIdInternal(lvid)}; - if(gvid == -1) { - return false; - } - return this->metaGrid_->isVertexOnBoundary(gvid); -} - -bool ImplicitTriangulation::isEdgeOnGlobalBoundaryInternal( - const SimplexId leid) const { - - if(!ttk::isRunningWithMPI()) { - return this->isEdgeOnBoundary(leid); - } - -#ifndef TTK_ENABLE_KAMIKAZE - if(leid > this->getNumberOfEdgesInternal() - 1 || leid < 0) { - return false; - } - if(this->metaGrid_ == nullptr) { - return false; - } -#endif // TTK_ENABLE_KAMIKAZE - - const auto geid{this->getEdgeGlobalIdInternal(leid)}; - if(geid == -1) { - return false; - } - return this->metaGrid_->isEdgeOnBoundary(geid); -} - -bool ImplicitTriangulation::isTriangleOnGlobalBoundaryInternal( - const SimplexId ltid) const { - - if(!ttk::isRunningWithMPI()) { - return this->isTriangleOnBoundary(ltid); - } - -#ifndef TTK_ENABLE_KAMIKAZE - if(ltid > this->getNumberOfTrianglesInternal() - 1 || ltid < 0) { - return false; - } - if(this->metaGrid_ == nullptr) { - return false; - } -#endif // TTK_ENABLE_KAMIKAZE - - const auto gtid{this->getTriangleGlobalIdInternal(ltid)}; - if(gtid == -1) { - return false; - } - return this->metaGrid_->isTriangleOnBoundary(gtid); -} - -int ttk::ImplicitTriangulation::getCellRankInternal( - const SimplexId lcid) const { - - const int nTetraPerCube{this->dimensionality_ == 3 ? 6 : 2}; - const auto locCubeId{lcid / nTetraPerCube}; - - if(this->cellGhost_[locCubeId] == 0) { - return ttk::MPIrank_; - } - -#ifndef TTK_ENABLE_KAMIKAZE - if(this->neighborRanks_.empty() && ttk::MPIsize_ > 1) { - this->printErr("Empty neighborsRanks_!"); - return -1; - } -#endif // TTK_ENABLE_KAMIKAZE - - const auto nVertsCell{this->getCellVertexNumber(lcid)}; - std::vector inRank(nVertsCell); - for(const auto neigh : this->neighborRanks_) { - std::fill(inRank.begin(), inRank.end(), false); - const auto &bbox{this->neighborCellBBoxes_[neigh]}; - for(SimplexId i = 0; i < nVertsCell; ++i) { - SimplexId v{}; - this->getCellVertex(lcid, i, v); - if(this->vertexGhost_[v] == 0) { - inRank[i] = true; - } else { - const auto p{this->getVertGlobalCoords(v)}; - if(p[0] >= bbox[0] && p[0] <= bbox[1] && p[1] >= bbox[2] - && p[1] <= bbox[3] && p[2] >= bbox[4] && p[2] <= bbox[5]) { - inRank[i] = true; - } - } - } - if(std::all_of( - inRank.begin(), inRank.end(), [](const bool v) { return v; })) { - return neigh; - } - } - - return -1; -} - #endif // TTK_ENABLE_MPI // explicit instantiations diff --git a/core/base/implicitTriangulation/ImplicitTriangulation.h b/core/base/implicitTriangulation/ImplicitTriangulation.h index 370315bb93..a7bac3de3c 100644 --- a/core/base/implicitTriangulation/ImplicitTriangulation.h +++ b/core/base/implicitTriangulation/ImplicitTriangulation.h @@ -83,28 +83,78 @@ namespace ttk { return this->dimensions_; } - int getCellEdgeInternal(const SimplexId &cellId, - const int &id, - SimplexId &edgeId) const override; + inline int getCellEdgeInternal(const SimplexId &cellId, + const int &localEdgeId, + SimplexId &edgeId) const override { - SimplexId getCellEdgeNumberInternal(const SimplexId &cellId) const override; + if(dimensionality_ == 3) + getTetrahedronEdge(cellId, localEdgeId, edgeId); + else if(dimensionality_ == 2) + getTriangleEdgeInternal(cellId, localEdgeId, edgeId); + else if(dimensionality_ == 1) + getCellNeighbor(cellId, localEdgeId, edgeId); + + return 0; + } + + inline SimplexId + getCellEdgeNumberInternal(const SimplexId &cellId) const override { + + TTK_FORCE_USE(cellId); + if(dimensionality_ == 3) + return 6; + else if(dimensionality_ == 2) + return 3; + + return 0; + } const std::vector> *getCellEdgesInternal() override; - int TTK_TRIANGULATION_INTERNAL(getCellNeighbor)( + inline int TTK_TRIANGULATION_INTERNAL(getCellNeighbor)( const SimplexId &cellId, const int &localNeighborId, - SimplexId &neighborId) const override; + SimplexId &neighborId) const override { - SimplexId TTK_TRIANGULATION_INTERNAL(getCellNeighborNumber)( - const SimplexId &cellId) const override; + if(dimensionality_ == 3) + getTetrahedronNeighbor(cellId, localNeighborId, neighborId); + else if(dimensionality_ == 2) + getTriangleNeighbor(cellId, localNeighborId, neighborId); + else if(dimensionality_ == 1) { + printErr("getCellNeighbor() not implemented in 1D! (TODO)"); + return -1; + } + + return 0; + } + + inline SimplexId TTK_TRIANGULATION_INTERNAL(getCellNeighborNumber)( + const SimplexId &cellId) const override { + + if(dimensionality_ == 3) + return getTetrahedronNeighborNumber(cellId); + else if(dimensionality_ == 2) + return getTriangleNeighborNumber(cellId); + else if(dimensionality_ == 1) { + printErr("getCellNeighborNumber() not implemented in 1D! (TODO)"); + return -1; + } + + return 0; + } const std::vector> * TTK_TRIANGULATION_INTERNAL(getCellNeighbors)() override; - int getCellTriangleInternal(const SimplexId &cellId, - const int &id, - SimplexId &triangleId) const override; + inline int getCellTriangleInternal(const SimplexId &cellId, + const int &localTriangleId, + SimplexId &triangleId) const override { + + if(dimensionality_ == 3) + getTetrahedronTriangle(cellId, localTriangleId, triangleId); + + return 0; + } SimplexId getCellTriangleNumberInternal( const SimplexId & /*cellId*/) const override { @@ -116,13 +166,26 @@ namespace ttk { const std::vector> * getCellTrianglesInternal() override; - int TTK_TRIANGULATION_INTERNAL(getCellVertex)( + inline int TTK_TRIANGULATION_INTERNAL(getCellVertex)( const SimplexId &cellId, const int &localVertexId, - SimplexId &vertexId) const override; + SimplexId &vertexId) const override { - SimplexId TTK_TRIANGULATION_INTERNAL(getCellVertexNumber)( - const SimplexId &cellId) const override; + if(dimensionality_ == 3) + getTetrahedronVertex(cellId, localVertexId, vertexId); + else if(dimensionality_ == 2) + getTriangleVertexInternal(cellId, localVertexId, vertexId); + else if(dimensionality_ == 1) + getEdgeVertexInternal(cellId, localVertexId, vertexId); + + return 0; + } + + inline SimplexId TTK_TRIANGULATION_INTERNAL(getCellVertexNumber)( + const SimplexId &cellId) const override { + TTK_FORCE_USE(cellId); + return dimensionality_ + 1; + } int TTK_TRIANGULATION_INTERNAL(getDimensionality)() const override { return dimensionality_; @@ -166,14 +229,34 @@ namespace ttk { const int &id, SimplexId &edgeId) const = 0; - int getTetrahedronEdges(std::vector> &edges) const; + inline int + getTetrahedronEdges(std::vector> &edges) const { + edges.resize(tetrahedronNumber_); + for(SimplexId i = 0; i < tetrahedronNumber_; ++i) { + edges[i].resize(6); + for(int j = 0; j < 6; ++j) + getTetrahedronEdge(i, j, edges[i][j]); + } + + return 0; + } virtual int getTetrahedronTriangle(const SimplexId &tetId, const int &id, SimplexId &triangleId) const = 0; - int getTetrahedronTriangles( - std::vector> &triangles) const; + inline int getTetrahedronTriangles( + std::vector> &triangles) const { + + triangles.resize(tetrahedronNumber_); + for(SimplexId i = 0; i < tetrahedronNumber_; ++i) { + triangles[i].resize(4); + for(int j = 0; j < 4; ++j) + getTetrahedronTriangle(i, j, triangles[i][j]); + } + + return 0; + } virtual int getTetrahedronNeighbor(const SimplexId &tetId, const int &localNeighborId, @@ -182,7 +265,18 @@ namespace ttk { virtual SimplexId getTetrahedronNeighborNumber(const SimplexId &tetId) const = 0; - int getTetrahedronNeighbors(std::vector> &neighbors); + inline int + getTetrahedronNeighbors(std::vector> &neighbors) { + + neighbors.resize(tetrahedronNumber_); + for(SimplexId i = 0; i < tetrahedronNumber_; ++i) { + neighbors[i].resize(getTetrahedronNeighborNumber(i)); + for(SimplexId j = 0; j < (SimplexId)neighbors[i].size(); ++j) + getTetrahedronNeighbor(i, j, neighbors[i][j]); + } + + return 0; + } virtual int getTetrahedronVertex(const SimplexId &tetId, const int &localVertexId, @@ -198,11 +292,23 @@ namespace ttk { const std::vector> * getTriangleEdgesInternal() override; - int getTriangleEdgesInternal( - std::vector> &edges) const; + inline int getTriangleEdgesInternal( + std::vector> &edges) const { - SimplexId TTK_TRIANGULATION_INTERNAL(getTriangleLinkNumber)( - const SimplexId &triangleId) const override; + edges.resize(triangleNumber_); + for(SimplexId i = 0; i < triangleNumber_; ++i) { + edges[i].resize(3); + for(int j = 0; j < 3; ++j) + getTriangleEdgeInternal(i, j, edges[i][j]); + } + return 0; + } + + inline SimplexId TTK_TRIANGULATION_INTERNAL(getTriangleLinkNumber)( + const SimplexId &triangleId) const override { + + return TTK_TRIANGULATION_INTERNAL(getTriangleStarNumber)(triangleId); + } const std::vector> * TTK_TRIANGULATION_INTERNAL(getTriangleLinks)() override; @@ -326,19 +432,160 @@ namespace ttk { public: void createMetaGrid(const double *const bounds) override; - int getCellRankInternal(const SimplexId lcid) const override; + inline int getCellRankInternal(const SimplexId lcid) const override { + const int nTetraPerCube{this->dimensionality_ == 3 ? 6 : 2}; + const auto locCubeId{lcid / nTetraPerCube}; + + if(this->cellGhost_[locCubeId] == 0) { + return ttk::MPIrank_; + } + +#ifndef TTK_ENABLE_KAMIKAZE + if(this->neighborRanks_.empty() && ttk::MPIsize_ > 1) { + this->printErr("Empty neighborsRanks_!"); + return -1; + } +#endif // TTK_ENABLE_KAMIKAZE + + const auto nVertsCell{this->getCellVertexNumber(lcid)}; + std::vector inRank(nVertsCell); + for(const auto neigh : this->neighborRanks_) { + std::fill(inRank.begin(), inRank.end(), false); + const auto &bbox{this->neighborCellBBoxes_[neigh]}; + for(SimplexId i = 0; i < nVertsCell; ++i) { + SimplexId v{}; + this->getCellVertex(lcid, i, v); + if(this->vertexGhost_[v] == 0) { + inRank[i] = true; + } else { + const auto p{this->getVertGlobalCoords(v)}; + if(p[0] >= bbox[0] && p[0] <= bbox[1] && p[1] >= bbox[2] + && p[1] <= bbox[3] && p[2] >= bbox[4] && p[2] <= bbox[5]) { + inRank[i] = true; + } + } + } + if(std::all_of( + inRank.begin(), inRank.end(), [](const bool v) { return v; })) { + return neigh; + } + } + + return -1; + } protected: - bool isVertexOnGlobalBoundaryInternal(const SimplexId lvid) const override; - bool isEdgeOnGlobalBoundaryInternal(const SimplexId leid) const override; - bool - isTriangleOnGlobalBoundaryInternal(const SimplexId ltid) const override; + inline bool + isVertexOnGlobalBoundaryInternal(const SimplexId lvid) const override { + + if(!ttk::isRunningWithMPI()) { + // NOTE: perf killer + return this->isVertexOnBoundary(lvid); + } + +#ifndef TTK_ENABLE_KAMIKAZE + if(lvid > this->TTK_TRIANGULATION_INTERNAL(getNumberOfVertices)() - 1 + || lvid < 0) { + return false; + } + if(this->metaGrid_ == nullptr) { + return false; + } +#endif // TTK_ENABLE_KAMIKAZE + + const auto gvid{this->getVertexGlobalIdInternal(lvid)}; + if(gvid == -1) { + return false; + } + return this->metaGrid_->isVertexOnBoundary(gvid); + } + + inline bool + isEdgeOnGlobalBoundaryInternal(const SimplexId leid) const override { + + if(!ttk::isRunningWithMPI()) { + // NOTE: perf killer + return this->isEdgeOnBoundary(leid); + } + +#ifndef TTK_ENABLE_KAMIKAZE + if(leid > this->getNumberOfEdgesInternal() - 1 || leid < 0) { + return false; + } + if(this->metaGrid_ == nullptr) { + return false; + } +#endif // TTK_ENABLE_KAMIKAZE + + const auto geid{this->getEdgeGlobalIdInternal(leid)}; + if(geid == -1) { + return false; + } + return this->metaGrid_->isEdgeOnBoundary(geid); + } + + inline bool + isTriangleOnGlobalBoundaryInternal(const SimplexId ltid) const override { + + if(!ttk::isRunningWithMPI()) { + // NOTE: perf killer + return this->isTriangleOnBoundary(ltid); + } + +#ifndef TTK_ENABLE_KAMIKAZE + if(ltid > this->getNumberOfTrianglesInternal() - 1 || ltid < 0) { + return false; + } + if(this->metaGrid_ == nullptr) { + return false; + } +#endif // TTK_ENABLE_KAMIKAZE + + const auto gtid{this->getTriangleGlobalIdInternal(ltid)}; + if(gtid == -1) { + return false; + } + return this->metaGrid_->isTriangleOnBoundary(gtid); + } private: - std::array - getVertGlobalCoords(const SimplexId lvid) const override; - std::array - getVertLocalCoords(const SimplexId gvid) const override; + inline std::array + getVertGlobalCoords(const SimplexId lvid) const override { + + // local vertex coordinates + std::array p{}; + if(this->dimensionality_ == 3) { + this->vertexToPosition(lvid, p.data()); + } else if(this->dimensionality_ == 2) { + this->vertexToPosition2d(lvid, p.data()); + } + + // global vertex coordinates + p[0] += this->localGridOffset_[0]; + p[1] += this->localGridOffset_[1]; + p[2] += this->localGridOffset_[2]; + + return p; + } + + inline std::array + getVertLocalCoords(const SimplexId gvid) const override { + + // global vertex coordinates + std::array p{}; + if(this->dimensionality_ == 3) { + this->metaGrid_->vertexToPosition(gvid, p.data()); + } else if(this->dimensionality_ == 2) { + this->metaGrid_->vertexToPosition2d(gvid, p.data()); + } + + // local vertex coordinates + p[0] -= this->localGridOffset_[0]; + p[1] -= this->localGridOffset_[1]; + p[2] -= this->localGridOffset_[2]; + + return p; + } #endif // TTK_ENABLE_MPI @@ -609,50 +856,72 @@ namespace ttk { void triangleToPosition2d(const SimplexId triangle, SimplexId p[2]) const override; - SimplexId getVertexEdge2dA(const SimplexId p[2], const int id) const; - SimplexId getVertexEdge2dB(const SimplexId p[2], const int id) const; - SimplexId getVertexEdge2dC(const SimplexId p[2], const int id) const; - SimplexId getVertexEdge2dD(const SimplexId p[2], const int id) const; - SimplexId getVertexEdge2dAB(const SimplexId p[2], const int id) const; - SimplexId getVertexEdge2dCD(const SimplexId p[2], const int id) const; - SimplexId getVertexEdge2dAC(const SimplexId p[2], const int id) const; - SimplexId getVertexEdge2dBD(const SimplexId p[2], const int id) const; - SimplexId getVertexEdge2dABCD(const SimplexId p[2], const int id) const; - - SimplexId getVertexStar2dA(const SimplexId p[2], const int id) const; - SimplexId getVertexStar2dB(const SimplexId p[2], const int id) const; - SimplexId getVertexStar2dC(const SimplexId p[2], const int id) const; - SimplexId getVertexStar2dD(const SimplexId p[2], const int id) const; - SimplexId getVertexStar2dAB(const SimplexId p[2], const int id) const; - SimplexId getVertexStar2dCD(const SimplexId p[2], const int id) const; - SimplexId getVertexStar2dAC(const SimplexId p[2], const int id) const; - SimplexId getVertexStar2dBD(const SimplexId p[2], const int id) const; - SimplexId getVertexStar2dABCD(const SimplexId p[2], const int id) const; - - SimplexId getVertexLink2dA(const SimplexId p[2], const int id) const; - SimplexId getVertexLink2dB(const SimplexId p[2], const int id) const; - SimplexId getVertexLink2dC(const SimplexId p[2], const int id) const; - SimplexId getVertexLink2dD(const SimplexId p[2], const int id) const; - SimplexId getVertexLink2dAB(const SimplexId p[2], const int id) const; - SimplexId getVertexLink2dCD(const SimplexId p[2], const int id) const; - SimplexId getVertexLink2dAC(const SimplexId p[2], const int id) const; - SimplexId getVertexLink2dBD(const SimplexId p[2], const int id) const; - SimplexId getVertexLink2dABCD(const SimplexId p[2], const int id) const; - - SimplexId getEdgeTriangleL_x0(const SimplexId p[3], const int id) const; - SimplexId getEdgeTriangleL_xn(const SimplexId p[3], const int id) const; - SimplexId getEdgeTriangleL_xN(const SimplexId p[3], const int id) const; - SimplexId getEdgeTriangleH_0y(const SimplexId p[3], const int id) const; - SimplexId getEdgeTriangleH_ny(const SimplexId p[3], const int id) const; - SimplexId getEdgeTriangleH_Ny(const SimplexId p[3], const int id) const; - SimplexId getEdgeTriangleD1_xy(const SimplexId p[3], const int id) const; - - SimplexId getEdgeLink2dL(const SimplexId p[2], const int id) const; - SimplexId getEdgeLink2dH(const SimplexId p[2], const int id) const; - SimplexId getEdgeLink2dD1(const SimplexId p[2], const int id) const; - - SimplexId getEdgeStar2dL(const SimplexId p[2], const int id) const; - SimplexId getEdgeStar2dH(const SimplexId p[2], const int id) const; + inline SimplexId getVertexEdge2dA(const SimplexId p[2], const int id) const; + inline SimplexId getVertexEdge2dB(const SimplexId p[2], const int id) const; + inline SimplexId getVertexEdge2dC(const SimplexId p[2], const int id) const; + inline SimplexId getVertexEdge2dD(const SimplexId p[2], const int id) const; + inline SimplexId getVertexEdge2dAB(const SimplexId p[2], + const int id) const; + inline SimplexId getVertexEdge2dCD(const SimplexId p[2], + const int id) const; + inline SimplexId getVertexEdge2dAC(const SimplexId p[2], + const int id) const; + inline SimplexId getVertexEdge2dBD(const SimplexId p[2], + const int id) const; + inline SimplexId getVertexEdge2dABCD(const SimplexId p[2], + const int id) const; + + inline SimplexId getVertexStar2dA(const SimplexId p[2], const int id) const; + inline SimplexId getVertexStar2dB(const SimplexId p[2], const int id) const; + inline SimplexId getVertexStar2dC(const SimplexId p[2], const int id) const; + inline SimplexId getVertexStar2dD(const SimplexId p[2], const int id) const; + inline SimplexId getVertexStar2dAB(const SimplexId p[2], + const int id) const; + inline SimplexId getVertexStar2dCD(const SimplexId p[2], + const int id) const; + inline SimplexId getVertexStar2dAC(const SimplexId p[2], + const int id) const; + inline SimplexId getVertexStar2dBD(const SimplexId p[2], + const int id) const; + inline SimplexId getVertexStar2dABCD(const SimplexId p[2], + const int id) const; + + inline SimplexId getVertexLink2dA(const SimplexId p[2], const int id) const; + inline SimplexId getVertexLink2dB(const SimplexId p[2], const int id) const; + inline SimplexId getVertexLink2dC(const SimplexId p[2], const int id) const; + inline SimplexId getVertexLink2dD(const SimplexId p[2], const int id) const; + inline SimplexId getVertexLink2dAB(const SimplexId p[2], + const int id) const; + inline SimplexId getVertexLink2dCD(const SimplexId p[2], + const int id) const; + inline SimplexId getVertexLink2dAC(const SimplexId p[2], + const int id) const; + inline SimplexId getVertexLink2dBD(const SimplexId p[2], + const int id) const; + inline SimplexId getVertexLink2dABCD(const SimplexId p[2], + const int id) const; + + inline SimplexId getEdgeTriangleL_x0(const SimplexId p[3], + const int id) const; + inline SimplexId getEdgeTriangleL_xn(const SimplexId p[3], + const int id) const; + inline SimplexId getEdgeTriangleL_xN(const SimplexId p[3], + const int id) const; + inline SimplexId getEdgeTriangleH_0y(const SimplexId p[3], + const int id) const; + inline SimplexId getEdgeTriangleH_ny(const SimplexId p[3], + const int id) const; + inline SimplexId getEdgeTriangleH_Ny(const SimplexId p[3], + const int id) const; + inline SimplexId getEdgeTriangleD1_xy(const SimplexId p[3], + const int id) const; + + inline SimplexId getEdgeLink2dL(const SimplexId p[2], const int id) const; + inline SimplexId getEdgeLink2dH(const SimplexId p[2], const int id) const; + inline SimplexId getEdgeLink2dD1(const SimplexId p[2], const int id) const; + + inline SimplexId getEdgeStar2dL(const SimplexId p[2], const int id) const; + inline SimplexId getEdgeStar2dH(const SimplexId p[2], const int id) const; // 3D // void vertexToPosition(const SimplexId vertex, @@ -665,263 +934,377 @@ namespace ttk { void tetrahedronToPosition(const SimplexId tetrahedron, SimplexId p[3]) const override; - SimplexId getVertexEdgeA(const SimplexId p[3], const int id) const; - SimplexId getVertexEdgeB(const SimplexId p[3], const int id) const; - SimplexId getVertexEdgeC(const SimplexId p[3], const int id) const; - SimplexId getVertexEdgeD(const SimplexId p[3], const int id) const; - SimplexId getVertexEdgeE(const SimplexId p[3], const int id) const; - SimplexId getVertexEdgeF(const SimplexId p[3], const int id) const; - SimplexId getVertexEdgeG(const SimplexId p[3], const int id) const; - SimplexId getVertexEdgeH(const SimplexId p[3], const int id) const; - SimplexId getVertexEdgeAB(const SimplexId p[3], const int id) const; - SimplexId getVertexEdgeCD(const SimplexId p[3], const int id) const; - SimplexId getVertexEdgeEF(const SimplexId p[3], const int id) const; - SimplexId getVertexEdgeGH(const SimplexId p[3], const int id) const; - SimplexId getVertexEdgeAC(const SimplexId p[3], const int id) const; - SimplexId getVertexEdgeBD(const SimplexId p[3], const int id) const; - SimplexId getVertexEdgeEG(const SimplexId p[3], const int id) const; - SimplexId getVertexEdgeFH(const SimplexId p[3], const int id) const; - SimplexId getVertexEdgeAE(const SimplexId p[3], const int id) const; - SimplexId getVertexEdgeBF(const SimplexId p[3], const int id) const; - SimplexId getVertexEdgeCG(const SimplexId p[3], const int id) const; - SimplexId getVertexEdgeDH(const SimplexId p[3], const int id) const; - SimplexId getVertexEdgeABDC(const SimplexId p[3], const int id) const; - SimplexId getVertexEdgeEFHG(const SimplexId p[3], const int id) const; - SimplexId getVertexEdgeAEGC(const SimplexId p[3], const int id) const; - SimplexId getVertexEdgeBFHD(const SimplexId p[3], const int id) const; - SimplexId getVertexEdgeAEFB(const SimplexId p[3], const int id) const; - SimplexId getVertexEdgeGHDC(const SimplexId p[3], const int id) const; - SimplexId getVertexEdgeABCDEFGH(const SimplexId p[3], const int id) const; - - SimplexId getVertexTriangleA(const SimplexId p[3], const int id) const; - SimplexId getVertexTriangleB(const SimplexId p[3], const int id) const; - SimplexId getVertexTriangleC(const SimplexId p[3], const int id) const; - SimplexId getVertexTriangleD(const SimplexId p[3], const int id) const; - SimplexId getVertexTriangleE(const SimplexId p[3], const int id) const; - SimplexId getVertexTriangleF(const SimplexId p[3], const int id) const; - SimplexId getVertexTriangleG(const SimplexId p[3], const int id) const; - SimplexId getVertexTriangleH(const SimplexId p[3], const int id) const; - SimplexId getVertexTriangleAB(const SimplexId p[3], const int id) const; - SimplexId getVertexTriangleCD(const SimplexId p[3], const int id) const; - SimplexId getVertexTriangleEF(const SimplexId p[3], const int id) const; - SimplexId getVertexTriangleGH(const SimplexId p[3], const int id) const; - SimplexId getVertexTriangleAC(const SimplexId p[3], const int id) const; - SimplexId getVertexTriangleBD(const SimplexId p[3], const int id) const; - SimplexId getVertexTriangleEG(const SimplexId p[3], const int id) const; - SimplexId getVertexTriangleFH(const SimplexId p[3], const int id) const; - SimplexId getVertexTriangleAE(const SimplexId p[3], const int id) const; - SimplexId getVertexTriangleBF(const SimplexId p[3], const int id) const; - SimplexId getVertexTriangleCG(const SimplexId p[3], const int id) const; - SimplexId getVertexTriangleDH(const SimplexId p[3], const int id) const; - SimplexId getVertexTriangleABDC(const SimplexId p[3], const int id) const; - SimplexId getVertexTriangleEFHG(const SimplexId p[3], const int id) const; - SimplexId getVertexTriangleAEGC(const SimplexId p[3], const int id) const; - SimplexId getVertexTriangleBFHD(const SimplexId p[3], const int id) const; - SimplexId getVertexTriangleAEFB(const SimplexId p[3], const int id) const; - SimplexId getVertexTriangleGHDC(const SimplexId p[3], const int id) const; - SimplexId getVertexTriangleABCDEFGH(const SimplexId p[3], - const int id) const; - - SimplexId getVertexLinkA(const SimplexId p[3], const int id) const; - SimplexId getVertexLinkB(const SimplexId p[3], const int id) const; - SimplexId getVertexLinkC(const SimplexId p[3], const int id) const; - SimplexId getVertexLinkD(const SimplexId p[3], const int id) const; - SimplexId getVertexLinkE(const SimplexId p[3], const int id) const; - SimplexId getVertexLinkF(const SimplexId p[3], const int id) const; - SimplexId getVertexLinkG(const SimplexId p[3], const int id) const; - SimplexId getVertexLinkH(const SimplexId p[3], const int id) const; - SimplexId getVertexLinkAB(const SimplexId p[3], const int id) const; - SimplexId getVertexLinkCD(const SimplexId p[3], const int id) const; - SimplexId getVertexLinkEF(const SimplexId p[3], const int id) const; - SimplexId getVertexLinkGH(const SimplexId p[3], const int id) const; - SimplexId getVertexLinkAC(const SimplexId p[3], const int id) const; - SimplexId getVertexLinkBD(const SimplexId p[3], const int id) const; - SimplexId getVertexLinkEG(const SimplexId p[3], const int id) const; - SimplexId getVertexLinkFH(const SimplexId p[3], const int id) const; - SimplexId getVertexLinkAE(const SimplexId p[3], const int id) const; - SimplexId getVertexLinkBF(const SimplexId p[3], const int id) const; - SimplexId getVertexLinkCG(const SimplexId p[3], const int id) const; - SimplexId getVertexLinkDH(const SimplexId p[3], const int id) const; - SimplexId getVertexLinkABDC(const SimplexId p[3], const int id) const; - SimplexId getVertexLinkEFHG(const SimplexId p[3], const int id) const; - SimplexId getVertexLinkAEGC(const SimplexId p[3], const int id) const; - SimplexId getVertexLinkBFHD(const SimplexId p[3], const int id) const; - SimplexId getVertexLinkAEFB(const SimplexId p[3], const int id) const; - SimplexId getVertexLinkGHDC(const SimplexId p[3], const int id) const; - SimplexId getVertexLinkABCDEFGH(const SimplexId p[3], const int id) const; - - SimplexId getVertexStarA(const SimplexId p[3], const int id) const; - SimplexId getVertexStarB(const SimplexId p[3], const int id) const; - SimplexId getVertexStarC(const SimplexId p[3], const int id) const; - SimplexId getVertexStarD(const SimplexId p[3], const int id) const; - SimplexId getVertexStarE(const SimplexId p[3], const int id) const; - SimplexId getVertexStarF(const SimplexId p[3], const int id) const; - SimplexId getVertexStarG(const SimplexId p[3], const int id) const; - SimplexId getVertexStarH(const SimplexId p[3], const int id) const; - SimplexId getVertexStarAB(const SimplexId p[3], const int id) const; - SimplexId getVertexStarCD(const SimplexId p[3], const int id) const; - SimplexId getVertexStarEF(const SimplexId p[3], const int id) const; - SimplexId getVertexStarGH(const SimplexId p[3], const int id) const; - SimplexId getVertexStarAC(const SimplexId p[3], const int id) const; - SimplexId getVertexStarBD(const SimplexId p[3], const int id) const; - SimplexId getVertexStarEG(const SimplexId p[3], const int id) const; - SimplexId getVertexStarFH(const SimplexId p[3], const int id) const; - SimplexId getVertexStarAE(const SimplexId p[3], const int id) const; - SimplexId getVertexStarBF(const SimplexId p[3], const int id) const; - SimplexId getVertexStarCG(const SimplexId p[3], const int id) const; - SimplexId getVertexStarDH(const SimplexId p[3], const int id) const; - SimplexId getVertexStarABDC(const SimplexId p[3], const int id) const; - SimplexId getVertexStarEFHG(const SimplexId p[3], const int id) const; - SimplexId getVertexStarAEGC(const SimplexId p[3], const int id) const; - SimplexId getVertexStarBFHD(const SimplexId p[3], const int id) const; - SimplexId getVertexStarAEFB(const SimplexId p[3], const int id) const; - SimplexId getVertexStarGHDC(const SimplexId p[3], const int id) const; - SimplexId getVertexStarABCDEFGH(const SimplexId p[3], const int id) const; - - SimplexId getEdgeTriangleL_x00(const SimplexId p[3], const int id) const; - SimplexId getEdgeTriangleL_x0n(const SimplexId p[3], const int id) const; - SimplexId getEdgeTriangleL_x0N(const SimplexId p[3], const int id) const; - SimplexId getEdgeTriangleL_xn0(const SimplexId p[3], const int id) const; - SimplexId getEdgeTriangleL_xnn(const SimplexId p[3], const int id) const; - SimplexId getEdgeTriangleL_xnN(const SimplexId p[3], const int id) const; - SimplexId getEdgeTriangleL_xN0(const SimplexId p[3], const int id) const; - SimplexId getEdgeTriangleL_xNn(const SimplexId p[3], const int id) const; - SimplexId getEdgeTriangleL_xNN(const SimplexId p[3], const int id) const; - - SimplexId getEdgeTriangleH_0y0(const SimplexId p[3], const int id) const; - SimplexId getEdgeTriangleH_0yn(const SimplexId p[3], const int id) const; - SimplexId getEdgeTriangleH_0yN(const SimplexId p[3], const int id) const; - SimplexId getEdgeTriangleH_ny0(const SimplexId p[3], const int id) const; - SimplexId getEdgeTriangleH_nyn(const SimplexId p[3], const int id) const; - SimplexId getEdgeTriangleH_nyN(const SimplexId p[3], const int id) const; - SimplexId getEdgeTriangleH_Ny0(const SimplexId p[3], const int id) const; - SimplexId getEdgeTriangleH_Nyn(const SimplexId p[3], const int id) const; - SimplexId getEdgeTriangleH_NyN(const SimplexId p[3], const int id) const; - - SimplexId getEdgeTriangleP_00z(const SimplexId p[3], const int id) const; - SimplexId getEdgeTriangleP_0nz(const SimplexId p[3], const int id) const; - SimplexId getEdgeTriangleP_0Nz(const SimplexId p[3], const int id) const; - SimplexId getEdgeTriangleP_n0z(const SimplexId p[3], const int id) const; - SimplexId getEdgeTriangleP_nnz(const SimplexId p[3], const int id) const; - SimplexId getEdgeTriangleP_nNz(const SimplexId p[3], const int id) const; - SimplexId getEdgeTriangleP_N0z(const SimplexId p[3], const int id) const; - SimplexId getEdgeTriangleP_Nnz(const SimplexId p[3], const int id) const; - SimplexId getEdgeTriangleP_NNz(const SimplexId p[3], const int id) const; - - SimplexId getEdgeTriangleD1_xy0(const SimplexId p[3], const int id) const; - SimplexId getEdgeTriangleD1_xyn(const SimplexId p[3], const int id) const; - SimplexId getEdgeTriangleD1_xyN(const SimplexId p[3], const int id) const; - - SimplexId getEdgeTriangleD2_0yz(const SimplexId p[3], const int id) const; - SimplexId getEdgeTriangleD2_nyz(const SimplexId p[3], const int id) const; - SimplexId getEdgeTriangleD2_Nyz(const SimplexId p[3], const int id) const; - - SimplexId getEdgeTriangleD3_x0z(const SimplexId p[3], const int id) const; - SimplexId getEdgeTriangleD3_xnz(const SimplexId p[3], const int id) const; - SimplexId getEdgeTriangleD3_xNz(const SimplexId p[3], const int id) const; - - SimplexId getEdgeTriangleD4_xyz(const SimplexId p[3], const int id) const; - - SimplexId getEdgeLinkL(const SimplexId p[3], const int id) const; - SimplexId getEdgeLinkH(const SimplexId p[3], const int id) const; - SimplexId getEdgeLinkP(const SimplexId p[3], const int id) const; - SimplexId getEdgeLinkD1(const SimplexId p[3], const int id) const; - SimplexId getEdgeLinkD2(const SimplexId p[3], const int id) const; - SimplexId getEdgeLinkD3(const SimplexId p[3], const int id) const; - SimplexId getEdgeLinkD4(const SimplexId p[3], const int id) const; - - SimplexId getEdgeStarL(const SimplexId p[3], const int id) const; - SimplexId getEdgeStarH(const SimplexId p[3], const int id) const; - SimplexId getEdgeStarP(const SimplexId p[3], const int id) const; - SimplexId getEdgeStarD1(const SimplexId p[3], const int id) const; - SimplexId getEdgeStarD2(const SimplexId p[3], const int id) const; - SimplexId getEdgeStarD3(const SimplexId p[3], const int id) const; - - SimplexId getTriangleVertexF(const SimplexId p[3], const int id) const; - SimplexId getTriangleVertexH(const SimplexId p[3], const int id) const; - SimplexId getTriangleVertexC(const SimplexId p[3], const int id) const; - SimplexId getTriangleVertexD1(const SimplexId p[3], const int id) const; - SimplexId getTriangleVertexD2(const SimplexId p[3], const int id) const; - SimplexId getTriangleVertexD3(const SimplexId p[3], const int id) const; - - SimplexId getTriangleEdgeF_0(const SimplexId p[3], const int id) const; - SimplexId getTriangleEdgeF_1(const SimplexId p[3], const int id) const; - SimplexId getTriangleEdgeH_0(const SimplexId p[3], const int id) const; - SimplexId getTriangleEdgeH_1(const SimplexId p[3], const int id) const; - SimplexId getTriangleEdgeC_0(const SimplexId p[3], const int id) const; - SimplexId getTriangleEdgeC_1(const SimplexId p[3], const int id) const; - SimplexId getTriangleEdgeD1_0(const SimplexId p[3], const int id) const; - SimplexId getTriangleEdgeD1_1(const SimplexId p[3], const int id) const; - SimplexId getTriangleEdgeD2_0(const SimplexId p[3], const int id) const; - SimplexId getTriangleEdgeD2_1(const SimplexId p[3], const int id) const; - SimplexId getTriangleEdgeD3_0(const SimplexId p[3], const int id) const; - SimplexId getTriangleEdgeD3_1(const SimplexId p[3], const int id) const; - - SimplexId getTriangleLinkF(const SimplexId p[3], const int id) const; - SimplexId getTriangleLinkH(const SimplexId p[3], const int id) const; - SimplexId getTriangleLinkC(const SimplexId p[3], const int id) const; - SimplexId getTriangleLinkD1(const SimplexId p[3], const int id) const; - SimplexId getTriangleLinkD2(const SimplexId p[3], const int id) const; - SimplexId getTriangleLinkD3(const SimplexId p[3], const int id) const; - - SimplexId getTriangleStarF(const SimplexId p[3], const int id) const; - SimplexId getTriangleStarH(const SimplexId p[3], const int id) const; - SimplexId getTriangleStarC(const SimplexId p[3], const int id) const; - SimplexId getTriangleStarD1(const SimplexId p[3], const int id) const; - SimplexId getTriangleStarD2(const SimplexId p[3], const int id) const; - SimplexId getTriangleStarD3(const SimplexId p[3], const int id) const; - - SimplexId getTetrahedronVertexABCG(const SimplexId p[3], + inline SimplexId getVertexEdgeA(const SimplexId p[3], const int id) const; + inline SimplexId getVertexEdgeB(const SimplexId p[3], const int id) const; + inline SimplexId getVertexEdgeC(const SimplexId p[3], const int id) const; + inline SimplexId getVertexEdgeD(const SimplexId p[3], const int id) const; + inline SimplexId getVertexEdgeE(const SimplexId p[3], const int id) const; + inline SimplexId getVertexEdgeF(const SimplexId p[3], const int id) const; + inline SimplexId getVertexEdgeG(const SimplexId p[3], const int id) const; + inline SimplexId getVertexEdgeH(const SimplexId p[3], const int id) const; + inline SimplexId getVertexEdgeAB(const SimplexId p[3], const int id) const; + inline SimplexId getVertexEdgeCD(const SimplexId p[3], const int id) const; + inline SimplexId getVertexEdgeEF(const SimplexId p[3], const int id) const; + inline SimplexId getVertexEdgeGH(const SimplexId p[3], const int id) const; + inline SimplexId getVertexEdgeAC(const SimplexId p[3], const int id) const; + inline SimplexId getVertexEdgeBD(const SimplexId p[3], const int id) const; + inline SimplexId getVertexEdgeEG(const SimplexId p[3], const int id) const; + inline SimplexId getVertexEdgeFH(const SimplexId p[3], const int id) const; + inline SimplexId getVertexEdgeAE(const SimplexId p[3], const int id) const; + inline SimplexId getVertexEdgeBF(const SimplexId p[3], const int id) const; + inline SimplexId getVertexEdgeCG(const SimplexId p[3], const int id) const; + inline SimplexId getVertexEdgeDH(const SimplexId p[3], const int id) const; + inline SimplexId getVertexEdgeABDC(const SimplexId p[3], const int id) const; - SimplexId getTetrahedronVertexBCDG(const SimplexId p[3], + inline SimplexId getVertexEdgeEFHG(const SimplexId p[3], const int id) const; - SimplexId getTetrahedronVertexABEG(const SimplexId p[3], + inline SimplexId getVertexEdgeAEGC(const SimplexId p[3], const int id) const; - SimplexId getTetrahedronVertexBEFG(const SimplexId p[3], + inline SimplexId getVertexEdgeBFHD(const SimplexId p[3], const int id) const; - SimplexId getTetrahedronVertexBFGH(const SimplexId p[3], + inline SimplexId getVertexEdgeAEFB(const SimplexId p[3], const int id) const; - SimplexId getTetrahedronVertexBDGH(const SimplexId p[3], + inline SimplexId getVertexEdgeGHDC(const SimplexId p[3], const int id) const; + inline SimplexId getVertexEdgeABCDEFGH(const SimplexId p[3], + const int id) const; - SimplexId getTetrahedronEdgeABCG(const SimplexId p[3], const int id) const; - SimplexId getTetrahedronEdgeBCDG(const SimplexId p[3], const int id) const; - SimplexId getTetrahedronEdgeABEG(const SimplexId p[3], const int id) const; - SimplexId getTetrahedronEdgeBEFG(const SimplexId p[3], const int id) const; - SimplexId getTetrahedronEdgeBFGH(const SimplexId p[3], const int id) const; - SimplexId getTetrahedronEdgeBDGH(const SimplexId p[3], const int id) const; - - SimplexId getTetrahedronTriangleABCG(const SimplexId p[3], + inline SimplexId getVertexTriangleA(const SimplexId p[3], + const int id) const; + inline SimplexId getVertexTriangleB(const SimplexId p[3], + const int id) const; + inline SimplexId getVertexTriangleC(const SimplexId p[3], + const int id) const; + inline SimplexId getVertexTriangleD(const SimplexId p[3], + const int id) const; + inline SimplexId getVertexTriangleE(const SimplexId p[3], + const int id) const; + inline SimplexId getVertexTriangleF(const SimplexId p[3], + const int id) const; + inline SimplexId getVertexTriangleG(const SimplexId p[3], + const int id) const; + inline SimplexId getVertexTriangleH(const SimplexId p[3], + const int id) const; + inline SimplexId getVertexTriangleAB(const SimplexId p[3], + const int id) const; + inline SimplexId getVertexTriangleCD(const SimplexId p[3], const int id) const; - SimplexId getTetrahedronTriangleBCDG(const SimplexId p[3], + inline SimplexId getVertexTriangleEF(const SimplexId p[3], const int id) const; - SimplexId getTetrahedronTriangleABEG(const SimplexId p[3], + inline SimplexId getVertexTriangleGH(const SimplexId p[3], const int id) const; - SimplexId getTetrahedronTriangleBEFG(const SimplexId p[3], + inline SimplexId getVertexTriangleAC(const SimplexId p[3], + const int id) const; + inline SimplexId getVertexTriangleBD(const SimplexId p[3], + const int id) const; + inline SimplexId getVertexTriangleEG(const SimplexId p[3], + const int id) const; + inline SimplexId getVertexTriangleFH(const SimplexId p[3], + const int id) const; + inline SimplexId getVertexTriangleAE(const SimplexId p[3], + const int id) const; + inline SimplexId getVertexTriangleBF(const SimplexId p[3], + const int id) const; + inline SimplexId getVertexTriangleCG(const SimplexId p[3], + const int id) const; + inline SimplexId getVertexTriangleDH(const SimplexId p[3], + const int id) const; + inline SimplexId getVertexTriangleABDC(const SimplexId p[3], + const int id) const; + inline SimplexId getVertexTriangleEFHG(const SimplexId p[3], + const int id) const; + inline SimplexId getVertexTriangleAEGC(const SimplexId p[3], + const int id) const; + inline SimplexId getVertexTriangleBFHD(const SimplexId p[3], + const int id) const; + inline SimplexId getVertexTriangleAEFB(const SimplexId p[3], + const int id) const; + inline SimplexId getVertexTriangleGHDC(const SimplexId p[3], + const int id) const; + inline SimplexId getVertexTriangleABCDEFGH(const SimplexId p[3], + const int id) const; + + inline SimplexId getVertexLinkA(const SimplexId p[3], const int id) const; + inline SimplexId getVertexLinkB(const SimplexId p[3], const int id) const; + inline SimplexId getVertexLinkC(const SimplexId p[3], const int id) const; + inline SimplexId getVertexLinkD(const SimplexId p[3], const int id) const; + inline SimplexId getVertexLinkE(const SimplexId p[3], const int id) const; + inline SimplexId getVertexLinkF(const SimplexId p[3], const int id) const; + inline SimplexId getVertexLinkG(const SimplexId p[3], const int id) const; + inline SimplexId getVertexLinkH(const SimplexId p[3], const int id) const; + inline SimplexId getVertexLinkAB(const SimplexId p[3], const int id) const; + inline SimplexId getVertexLinkCD(const SimplexId p[3], const int id) const; + inline SimplexId getVertexLinkEF(const SimplexId p[3], const int id) const; + inline SimplexId getVertexLinkGH(const SimplexId p[3], const int id) const; + inline SimplexId getVertexLinkAC(const SimplexId p[3], const int id) const; + inline SimplexId getVertexLinkBD(const SimplexId p[3], const int id) const; + inline SimplexId getVertexLinkEG(const SimplexId p[3], const int id) const; + inline SimplexId getVertexLinkFH(const SimplexId p[3], const int id) const; + inline SimplexId getVertexLinkAE(const SimplexId p[3], const int id) const; + inline SimplexId getVertexLinkBF(const SimplexId p[3], const int id) const; + inline SimplexId getVertexLinkCG(const SimplexId p[3], const int id) const; + inline SimplexId getVertexLinkDH(const SimplexId p[3], const int id) const; + inline SimplexId getVertexLinkABDC(const SimplexId p[3], + const int id) const; + inline SimplexId getVertexLinkEFHG(const SimplexId p[3], + const int id) const; + inline SimplexId getVertexLinkAEGC(const SimplexId p[3], + const int id) const; + inline SimplexId getVertexLinkBFHD(const SimplexId p[3], + const int id) const; + inline SimplexId getVertexLinkAEFB(const SimplexId p[3], + const int id) const; + inline SimplexId getVertexLinkGHDC(const SimplexId p[3], + const int id) const; + inline SimplexId getVertexLinkABCDEFGH(const SimplexId p[3], + const int id) const; + + inline SimplexId getVertexStarA(const SimplexId p[3], const int id) const; + inline SimplexId getVertexStarB(const SimplexId p[3], const int id) const; + inline SimplexId getVertexStarC(const SimplexId p[3], const int id) const; + inline SimplexId getVertexStarD(const SimplexId p[3], const int id) const; + inline SimplexId getVertexStarE(const SimplexId p[3], const int id) const; + inline SimplexId getVertexStarF(const SimplexId p[3], const int id) const; + inline SimplexId getVertexStarG(const SimplexId p[3], const int id) const; + inline SimplexId getVertexStarH(const SimplexId p[3], const int id) const; + inline SimplexId getVertexStarAB(const SimplexId p[3], const int id) const; + inline SimplexId getVertexStarCD(const SimplexId p[3], const int id) const; + inline SimplexId getVertexStarEF(const SimplexId p[3], const int id) const; + inline SimplexId getVertexStarGH(const SimplexId p[3], const int id) const; + inline SimplexId getVertexStarAC(const SimplexId p[3], const int id) const; + inline SimplexId getVertexStarBD(const SimplexId p[3], const int id) const; + inline SimplexId getVertexStarEG(const SimplexId p[3], const int id) const; + inline SimplexId getVertexStarFH(const SimplexId p[3], const int id) const; + inline SimplexId getVertexStarAE(const SimplexId p[3], const int id) const; + inline SimplexId getVertexStarBF(const SimplexId p[3], const int id) const; + inline SimplexId getVertexStarCG(const SimplexId p[3], const int id) const; + inline SimplexId getVertexStarDH(const SimplexId p[3], const int id) const; + inline SimplexId getVertexStarABDC(const SimplexId p[3], + const int id) const; + inline SimplexId getVertexStarEFHG(const SimplexId p[3], + const int id) const; + inline SimplexId getVertexStarAEGC(const SimplexId p[3], + const int id) const; + inline SimplexId getVertexStarBFHD(const SimplexId p[3], + const int id) const; + inline SimplexId getVertexStarAEFB(const SimplexId p[3], + const int id) const; + inline SimplexId getVertexStarGHDC(const SimplexId p[3], + const int id) const; + inline SimplexId getVertexStarABCDEFGH(const SimplexId p[3], + const int id) const; + + inline SimplexId getEdgeTriangleL_x00(const SimplexId p[3], + const int id) const; + inline SimplexId getEdgeTriangleL_x0n(const SimplexId p[3], + const int id) const; + inline SimplexId getEdgeTriangleL_x0N(const SimplexId p[3], + const int id) const; + inline SimplexId getEdgeTriangleL_xn0(const SimplexId p[3], + const int id) const; + inline SimplexId getEdgeTriangleL_xnn(const SimplexId p[3], + const int id) const; + inline SimplexId getEdgeTriangleL_xnN(const SimplexId p[3], + const int id) const; + inline SimplexId getEdgeTriangleL_xN0(const SimplexId p[3], + const int id) const; + inline SimplexId getEdgeTriangleL_xNn(const SimplexId p[3], + const int id) const; + inline SimplexId getEdgeTriangleL_xNN(const SimplexId p[3], + const int id) const; + + inline SimplexId getEdgeTriangleH_0y0(const SimplexId p[3], + const int id) const; + inline SimplexId getEdgeTriangleH_0yn(const SimplexId p[3], + const int id) const; + inline SimplexId getEdgeTriangleH_0yN(const SimplexId p[3], + const int id) const; + inline SimplexId getEdgeTriangleH_ny0(const SimplexId p[3], + const int id) const; + inline SimplexId getEdgeTriangleH_nyn(const SimplexId p[3], + const int id) const; + inline SimplexId getEdgeTriangleH_nyN(const SimplexId p[3], + const int id) const; + inline SimplexId getEdgeTriangleH_Ny0(const SimplexId p[3], + const int id) const; + inline SimplexId getEdgeTriangleH_Nyn(const SimplexId p[3], + const int id) const; + inline SimplexId getEdgeTriangleH_NyN(const SimplexId p[3], + const int id) const; + + inline SimplexId getEdgeTriangleP_00z(const SimplexId p[3], + const int id) const; + inline SimplexId getEdgeTriangleP_0nz(const SimplexId p[3], + const int id) const; + inline SimplexId getEdgeTriangleP_0Nz(const SimplexId p[3], + const int id) const; + inline SimplexId getEdgeTriangleP_n0z(const SimplexId p[3], + const int id) const; + inline SimplexId getEdgeTriangleP_nnz(const SimplexId p[3], + const int id) const; + inline SimplexId getEdgeTriangleP_nNz(const SimplexId p[3], + const int id) const; + inline SimplexId getEdgeTriangleP_N0z(const SimplexId p[3], + const int id) const; + inline SimplexId getEdgeTriangleP_Nnz(const SimplexId p[3], + const int id) const; + inline SimplexId getEdgeTriangleP_NNz(const SimplexId p[3], + const int id) const; + + inline SimplexId getEdgeTriangleD1_xy0(const SimplexId p[3], + const int id) const; + inline SimplexId getEdgeTriangleD1_xyn(const SimplexId p[3], + const int id) const; + inline SimplexId getEdgeTriangleD1_xyN(const SimplexId p[3], + const int id) const; + + inline SimplexId getEdgeTriangleD2_0yz(const SimplexId p[3], + const int id) const; + inline SimplexId getEdgeTriangleD2_nyz(const SimplexId p[3], + const int id) const; + inline SimplexId getEdgeTriangleD2_Nyz(const SimplexId p[3], + const int id) const; + + inline SimplexId getEdgeTriangleD3_x0z(const SimplexId p[3], + const int id) const; + inline SimplexId getEdgeTriangleD3_xnz(const SimplexId p[3], + const int id) const; + inline SimplexId getEdgeTriangleD3_xNz(const SimplexId p[3], + const int id) const; + + inline SimplexId getEdgeTriangleD4_xyz(const SimplexId p[3], + const int id) const; + + inline SimplexId getEdgeLinkL(const SimplexId p[3], const int id) const; + inline SimplexId getEdgeLinkH(const SimplexId p[3], const int id) const; + inline SimplexId getEdgeLinkP(const SimplexId p[3], const int id) const; + inline SimplexId getEdgeLinkD1(const SimplexId p[3], const int id) const; + inline SimplexId getEdgeLinkD2(const SimplexId p[3], const int id) const; + inline SimplexId getEdgeLinkD3(const SimplexId p[3], const int id) const; + inline SimplexId getEdgeLinkD4(const SimplexId p[3], const int id) const; + + inline SimplexId getEdgeStarL(const SimplexId p[3], const int id) const; + inline SimplexId getEdgeStarH(const SimplexId p[3], const int id) const; + inline SimplexId getEdgeStarP(const SimplexId p[3], const int id) const; + inline SimplexId getEdgeStarD1(const SimplexId p[3], const int id) const; + inline SimplexId getEdgeStarD2(const SimplexId p[3], const int id) const; + inline SimplexId getEdgeStarD3(const SimplexId p[3], const int id) const; + + inline SimplexId getTriangleVertexF(const SimplexId p[3], + const int id) const; + inline SimplexId getTriangleVertexH(const SimplexId p[3], + const int id) const; + inline SimplexId getTriangleVertexC(const SimplexId p[3], + const int id) const; + inline SimplexId getTriangleVertexD1(const SimplexId p[3], const int id) const; - SimplexId getTetrahedronTriangleBFGH(const SimplexId p[3], + inline SimplexId getTriangleVertexD2(const SimplexId p[3], const int id) const; - SimplexId getTetrahedronTriangleBDGH(const SimplexId p[3], + inline SimplexId getTriangleVertexD3(const SimplexId p[3], const int id) const; - SimplexId getTetrahedronNeighborABCG(const SimplexId t, - const SimplexId p[3], + inline SimplexId getTriangleEdgeF_0(const SimplexId p[3], + const int id) const; + inline SimplexId getTriangleEdgeF_1(const SimplexId p[3], + const int id) const; + inline SimplexId getTriangleEdgeH_0(const SimplexId p[3], + const int id) const; + inline SimplexId getTriangleEdgeH_1(const SimplexId p[3], + const int id) const; + inline SimplexId getTriangleEdgeC_0(const SimplexId p[3], + const int id) const; + inline SimplexId getTriangleEdgeC_1(const SimplexId p[3], + const int id) const; + inline SimplexId getTriangleEdgeD1_0(const SimplexId p[3], const int id) const; - SimplexId getTetrahedronNeighborBCDG(const SimplexId t, - const SimplexId p[3], + inline SimplexId getTriangleEdgeD1_1(const SimplexId p[3], const int id) const; - SimplexId getTetrahedronNeighborABEG(const SimplexId t, - const SimplexId p[3], + inline SimplexId getTriangleEdgeD2_0(const SimplexId p[3], const int id) const; - SimplexId getTetrahedronNeighborBEFG(const SimplexId t, - const SimplexId p[3], + inline SimplexId getTriangleEdgeD2_1(const SimplexId p[3], const int id) const; - SimplexId getTetrahedronNeighborBFGH(const SimplexId t, - const SimplexId p[3], + inline SimplexId getTriangleEdgeD3_0(const SimplexId p[3], const int id) const; - SimplexId getTetrahedronNeighborBDGH(const SimplexId t, - const SimplexId p[3], + inline SimplexId getTriangleEdgeD3_1(const SimplexId p[3], const int id) const; + + inline SimplexId getTriangleLinkF(const SimplexId p[3], const int id) const; + inline SimplexId getTriangleLinkH(const SimplexId p[3], const int id) const; + inline SimplexId getTriangleLinkC(const SimplexId p[3], const int id) const; + inline SimplexId getTriangleLinkD1(const SimplexId p[3], + const int id) const; + inline SimplexId getTriangleLinkD2(const SimplexId p[3], + const int id) const; + inline SimplexId getTriangleLinkD3(const SimplexId p[3], + const int id) const; + + inline SimplexId getTriangleStarF(const SimplexId p[3], const int id) const; + inline SimplexId getTriangleStarH(const SimplexId p[3], const int id) const; + inline SimplexId getTriangleStarC(const SimplexId p[3], const int id) const; + inline SimplexId getTriangleStarD1(const SimplexId p[3], + const int id) const; + inline SimplexId getTriangleStarD2(const SimplexId p[3], + const int id) const; + inline SimplexId getTriangleStarD3(const SimplexId p[3], + const int id) const; + + inline SimplexId getTetrahedronVertexABCG(const SimplexId p[3], + const int id) const; + inline SimplexId getTetrahedronVertexBCDG(const SimplexId p[3], + const int id) const; + inline SimplexId getTetrahedronVertexABEG(const SimplexId p[3], + const int id) const; + inline SimplexId getTetrahedronVertexBEFG(const SimplexId p[3], + const int id) const; + inline SimplexId getTetrahedronVertexBFGH(const SimplexId p[3], + const int id) const; + inline SimplexId getTetrahedronVertexBDGH(const SimplexId p[3], + const int id) const; + + inline SimplexId getTetrahedronEdgeABCG(const SimplexId p[3], + const int id) const; + inline SimplexId getTetrahedronEdgeBCDG(const SimplexId p[3], + const int id) const; + inline SimplexId getTetrahedronEdgeABEG(const SimplexId p[3], + const int id) const; + inline SimplexId getTetrahedronEdgeBEFG(const SimplexId p[3], + const int id) const; + inline SimplexId getTetrahedronEdgeBFGH(const SimplexId p[3], + const int id) const; + inline SimplexId getTetrahedronEdgeBDGH(const SimplexId p[3], + const int id) const; + + inline SimplexId getTetrahedronTriangleABCG(const SimplexId p[3], + const int id) const; + inline SimplexId getTetrahedronTriangleBCDG(const SimplexId p[3], + const int id) const; + inline SimplexId getTetrahedronTriangleABEG(const SimplexId p[3], + const int id) const; + inline SimplexId getTetrahedronTriangleBEFG(const SimplexId p[3], + const int id) const; + inline SimplexId getTetrahedronTriangleBFGH(const SimplexId p[3], + const int id) const; + inline SimplexId getTetrahedronTriangleBDGH(const SimplexId p[3], + const int id) const; + + inline SimplexId getTetrahedronNeighborABCG(const SimplexId t, + const SimplexId p[3], + const int id) const; + inline SimplexId getTetrahedronNeighborBCDG(const SimplexId t, + const SimplexId p[3], + const int id) const; + inline SimplexId getTetrahedronNeighborABEG(const SimplexId t, + const SimplexId p[3], + const int id) const; + inline SimplexId getTetrahedronNeighborBEFG(const SimplexId t, + const SimplexId p[3], + const int id) const; + inline SimplexId getTetrahedronNeighborBFGH(const SimplexId t, + const SimplexId p[3], + const int id) const; + inline SimplexId getTetrahedronNeighborBDGH(const SimplexId t, + const SimplexId p[3], + const int id) const; //\endcond }; @@ -2327,52 +2710,624 @@ namespace ttk { return 0; } - int getTriangleVertexInternal(const SimplexId &triangleId, - const int &localVertexId, - SimplexId &vertexId) const override; + inline int getTriangleVertexInternal(const SimplexId &triangleId, + const int &localVertexId, + SimplexId &vertexId) const override { - int getTriangleEdgeInternal(const SimplexId &triangleId, - const int &id, - SimplexId &edgeId) const override; +#ifndef TTK_ENABLE_KAMIKAZE + if(triangleId < 0 or triangleId >= triangleNumber_) + return -1; + if(localVertexId < 0 or localVertexId >= 3) + return -2; +#endif - int TTK_TRIANGULATION_INTERNAL(getTriangleLink)( + // e--------f + // /| /| + // / | / | + // a--g-----b--h + // | / | / + // |/ |/ + // c--------d + // + // Classement des "Triangles" et dans cet ordre: + // F: face (type abc/bcd) + // C: cote (type abe/bef) + // H: haut (type acg/aeg) + // D1: diagonale1 (type bdg/beg) + // D2: diagonale2 (type abg/bgh) + // D3: diagonale3 (type bcg/bfg) + + const auto &p = this->underlying().getTriangleCoords(triangleId); + vertexId = -1; + + switch(this->underlying().getTrianglePosition(triangleId)) { + case TrianglePosition::F_3D: + vertexId = getTriangleVertexF(p.data(), localVertexId); + break; + case TrianglePosition::H_3D: + vertexId = getTriangleVertexH(p.data(), localVertexId); + break; + case TrianglePosition::C_3D: + vertexId = getTriangleVertexC(p.data(), localVertexId); + break; + case TrianglePosition::D1_3D: + vertexId = getTriangleVertexD1(p.data(), localVertexId); + break; + case TrianglePosition::D2_3D: + vertexId = getTriangleVertexD2(p.data(), localVertexId); + break; + case TrianglePosition::D3_3D: + vertexId = getTriangleVertexD3(p.data(), localVertexId); + break; + case TrianglePosition::TOP_2D: + switch(localVertexId) { + break; + case 0: + vertexId = p[0] / 2 + p[1] * vshift_[0]; + break; + case 1: + vertexId = p[0] / 2 + p[1] * vshift_[0] + 1; + break; + case 2: + vertexId = p[0] / 2 + p[1] * vshift_[0] + vshift_[0]; + break; + } + break; + case TrianglePosition::BOTTOM_2D: + switch(localVertexId) { + break; + case 0: + vertexId = p[0] / 2 + p[1] * vshift_[0] + 1; + break; + case 1: + vertexId = p[0] / 2 + p[1] * vshift_[0] + vshift_[0] + 1; + break; + case 2: + vertexId = p[0] / 2 + p[1] * vshift_[0] + vshift_[0]; + break; + } + } + + return 0; + } + + inline int getTriangleEdgeInternal(const SimplexId &triangleId, + const int &localEdgeId, + SimplexId &edgeId) const override { + +#ifndef TTK_ENABLE_KAMIKAZE + if(triangleId < 0 or triangleId >= triangleNumber_) + return -1; + if(localEdgeId < 0 or localEdgeId >= 3) + return -2; +#endif + + const auto &p = this->underlying().getTriangleCoords(triangleId); + const auto par = triangleId % 2; + edgeId = -1; + + switch(this->underlying().getTrianglePosition(triangleId)) { + case TrianglePosition::F_3D: + edgeId = (par == 1) ? getTriangleEdgeF_1(p.data(), localEdgeId) + : getTriangleEdgeF_0(p.data(), localEdgeId); + break; + case TrianglePosition::H_3D: + edgeId = (par == 1) ? getTriangleEdgeH_1(p.data(), localEdgeId) + : getTriangleEdgeH_0(p.data(), localEdgeId); + break; + case TrianglePosition::C_3D: + edgeId = (par == 1) ? getTriangleEdgeC_1(p.data(), localEdgeId) + : getTriangleEdgeC_0(p.data(), localEdgeId); + break; + case TrianglePosition::D1_3D: + edgeId = (par == 1) ? getTriangleEdgeD1_1(p.data(), localEdgeId) + : getTriangleEdgeD1_0(p.data(), localEdgeId); + break; + case TrianglePosition::D2_3D: + edgeId = (par == 1) ? getTriangleEdgeD2_1(p.data(), localEdgeId) + : getTriangleEdgeD2_0(p.data(), localEdgeId); + break; + case TrianglePosition::D3_3D: + edgeId = (par == 1) ? getTriangleEdgeD3_1(p.data(), localEdgeId) + : getTriangleEdgeD3_0(p.data(), localEdgeId); + break; + case TrianglePosition::TOP_2D: + switch(localEdgeId) { + break; + case 0: + edgeId = p[0] / 2 + p[1] * eshift_[0]; + break; + case 1: + edgeId = esetshift_[0] + p[0] / 2 + p[1] * eshift_[2]; + break; + case 2: + edgeId = esetshift_[1] + p[0] / 2 + p[1] * eshift_[4]; + break; + } + break; + case TrianglePosition::BOTTOM_2D: + switch(localEdgeId) { + break; + case 0: + edgeId = p[0] / 2 + (p[1] + 1) * eshift_[0]; + break; + case 1: + edgeId = esetshift_[0] + (p[0] + 1) / 2 + p[1] * eshift_[2]; + break; + case 2: + edgeId = esetshift_[1] + p[0] / 2 + p[1] * eshift_[4]; + break; + } + } + + return 0; + } + + inline int TTK_TRIANGULATION_INTERNAL(getTriangleLink)( const SimplexId &triangleId, const int &localLinkId, - SimplexId &linkId) const override; + SimplexId &linkId) const override { - int TTK_TRIANGULATION_INTERNAL(getTriangleStar)( +#ifndef TTK_ENABLE_KAMIKAZE + if(localLinkId < 0 or localLinkId >= getTriangleLinkNumber(triangleId)) + return -1; +#endif + + const auto &p = this->underlying().getTriangleCoords(triangleId); + + switch(this->underlying().getTrianglePosition(triangleId)) { + case TrianglePosition::F_3D: + linkId = getTriangleLinkF(p.data(), localLinkId); + break; + case TrianglePosition::H_3D: + linkId = getTriangleLinkH(p.data(), localLinkId); + break; + case TrianglePosition::C_3D: + linkId = getTriangleLinkC(p.data(), localLinkId); + break; + case TrianglePosition::D1_3D: + linkId = getTriangleLinkD1(p.data(), localLinkId); + break; + case TrianglePosition::D2_3D: + linkId = getTriangleLinkD2(p.data(), localLinkId); + break; + case TrianglePosition::D3_3D: + linkId = getTriangleLinkD3(p.data(), localLinkId); + break; + default: // 2D + linkId = -1; + break; + } + + return 0; + } + + inline int TTK_TRIANGULATION_INTERNAL(getTriangleStar)( const SimplexId &triangleId, const int &localStarId, - SimplexId &starId) const override; + SimplexId &starId) const override { + +#ifndef TTK_ENABLE_KAMIKAZE + if(localStarId < 0 or localStarId >= getTriangleStarNumber(triangleId)) + return -1; +#endif + + const auto &p = this->underlying().getTriangleCoords(triangleId); - SimplexId TTK_TRIANGULATION_INTERNAL(getTriangleStarNumber)( - const SimplexId &triangleId) const override; + switch(this->underlying().getTrianglePosition(triangleId)) { + case TrianglePosition::F_3D: + starId = getTriangleStarF(p.data(), localStarId); + break; + case TrianglePosition::H_3D: + starId = getTriangleStarH(p.data(), localStarId); + break; + case TrianglePosition::C_3D: + starId = getTriangleStarC(p.data(), localStarId); + break; + case TrianglePosition::D1_3D: + starId = getTriangleStarD1(p.data(), localStarId); + break; + case TrianglePosition::D2_3D: + starId = getTriangleStarD2(p.data(), localStarId); + break; + case TrianglePosition::D3_3D: + starId = getTriangleStarD3(p.data(), localStarId); + break; + default: // 2D + starId = -1; + break; + } - int getTriangleNeighbor(const SimplexId &triangleId, - const int &localNeighborId, - SimplexId &neighborId) const override; + return 0; + } - SimplexId - getTriangleNeighborNumber(const SimplexId &triangleId) const override; + inline SimplexId TTK_TRIANGULATION_INTERNAL(getTriangleStarNumber)( + const SimplexId &triangleId) const override { - int getTetrahedronVertex(const SimplexId &tetId, - const int &localVertexId, - SimplexId &vertexId) const override; +#ifndef TTK_ENABLE_KAMIKAZE + if(triangleId < 0 or triangleId >= triangleNumber_) + return -1; +#endif - int getTetrahedronEdge(const SimplexId &tetId, - const int &id, - SimplexId &edgeId) const override; + const auto &p = this->underlying().getTriangleCoords(triangleId); - int getTetrahedronTriangle(const SimplexId &tetId, - const int &id, - SimplexId &triangleId) const override; + switch(this->underlying().getTrianglePosition(triangleId)) { + case TrianglePosition::F_3D: + return (p[2] > 0 and p[2] < nbvoxels_[2]) ? 2 : 1; + case TrianglePosition::H_3D: + return (p[1] > 0 and p[1] < nbvoxels_[1]) ? 2 : 1; + case TrianglePosition::C_3D: + return (p[0] < 2 or p[0] >= (dimensions_[0] * 2 - 2)) ? 1 : 2; - SimplexId - getTetrahedronNeighborNumber(const SimplexId &tetId) const override; + case TrianglePosition::D1_3D: + case TrianglePosition::D2_3D: + case TrianglePosition::D3_3D: + return 2; + default: // 2D + break; + } + return 0; + } - int getTetrahedronNeighbor(const SimplexId &tetId, - const int &localNeighborId, - SimplexId &neighborId) const override; + inline int getTriangleNeighbor(const SimplexId &triangleId, + const int &localNeighborId, + SimplexId &neighborId) const override { + +#ifndef TTK_ENABLE_KAMIKAZE + if(localNeighborId < 0 + or localNeighborId >= getTriangleNeighborNumber(triangleId)) + return -1; +#endif + + neighborId = -1; + + if(dimensionality_ == 2) { + const auto &p = this->underlying().getTriangleCoords(triangleId); + const SimplexId id = triangleId % 2; + + if(id) { + if(p[0] / 2 == nbvoxels_[Di_] - 1 and p[1] == nbvoxels_[Dj_] - 1) + neighborId = triangleId - 1; + else if(p[0] / 2 == nbvoxels_[Di_] - 1) { + switch(localNeighborId) { + case 0: + neighborId = triangleId - 1; + break; + case 1: + neighborId = triangleId + tshift_[0] - 1; + break; + } + } else if(p[1] == nbvoxels_[Dj_] - 1) { + switch(localNeighborId) { + case 0: + neighborId = triangleId - 1; + break; + case 1: + neighborId = triangleId + 1; + break; + } + } else { + switch(localNeighborId) { + case 0: + neighborId = triangleId - 1; + break; + case 1: + neighborId = triangleId + 1; + break; + case 2: + neighborId = triangleId + tshift_[0] - 1; + break; + } + } + } else { + if(p[0] == 0 and p[1] == 0) + neighborId = triangleId + 1; + else if(p[0] == 0) { + switch(localNeighborId) { + case 0: + neighborId = triangleId + 1; + break; + case 1: + neighborId = triangleId - tshift_[0] + 1; + break; + } + } else if(p[1] == 0) { + switch(localNeighborId) { + case 0: + neighborId = triangleId + 1; + break; + case 1: + neighborId = triangleId - 1; + break; + } + } else { + switch(localNeighborId) { + case 0: + neighborId = triangleId + 1; + break; + case 1: + neighborId = triangleId - 1; + break; + case 2: + neighborId = triangleId - tshift_[0] + 1; + break; + } + } + } + } + + return 0; + } + + inline SimplexId + getTriangleNeighborNumber(const SimplexId &triangleId) const override { + +#ifndef TTK_ENABLE_KAMIKAZE + if(triangleId < 0 or triangleId >= triangleNumber_) + return -1; +#endif + + if(dimensionality_ == 2) { + const auto &p = this->underlying().getTriangleCoords(triangleId); + const SimplexId id = triangleId % 2; + + if(id) { + if(p[0] / 2 == nbvoxels_[Di_] - 1 and p[1] == nbvoxels_[Dj_] - 1) + return 1; + else if(p[0] / 2 == nbvoxels_[Di_] - 1 or p[1] == nbvoxels_[Dj_] - 1) + return 2; + else + return 3; + } else { + if(p[0] == 0 and p[1] == 0) + return 1; + else if(p[0] == 0 or p[1] == 0) + return 2; + else + return 3; + } + } + + return 0; + } + + inline int getTetrahedronVertex(const SimplexId &tetId, + const int &localVertexId, + SimplexId &vertexId) const override { + +#ifndef TTK_ENABLE_KAMIKAZE + if(tetId < 0 or tetId >= tetrahedronNumber_) + return -1; + if(localVertexId < 0 or localVertexId >= 4) + return -2; +#endif + + vertexId = -1; + + if(dimensionality_ == 3) { + const SimplexId id = tetId % 6; + const auto &c = this->underlying().getTetrahedronCoords(tetId); + const auto p{c.data()}; + + switch(id) { + case 0: + vertexId = getTetrahedronVertexABCG(p, localVertexId); + break; + case 1: + vertexId = getTetrahedronVertexBCDG(p, localVertexId); + break; + case 2: + vertexId = getTetrahedronVertexABEG(p, localVertexId); + break; + case 3: + vertexId = getTetrahedronVertexBEFG(p, localVertexId); + break; + case 4: + vertexId = getTetrahedronVertexBFGH(p, localVertexId); + break; + case 5: + vertexId = getTetrahedronVertexBDGH(p, localVertexId); + break; + } + } + return 0; + } + + inline int getTetrahedronEdge(const SimplexId &tetId, + const int &localEdgeId, + SimplexId &edgeId) const override { + +#ifndef TTK_ENABLE_KAMIKAZE + if(tetId < 0 or tetId >= tetrahedronNumber_) + return -1; + if(localEdgeId < 0 or localEdgeId >= 6) + return -2; +#endif + + edgeId = -1; + + if(dimensionality_ == 3) { + const SimplexId id = tetId % 6; + const auto &c = this->underlying().getTetrahedronCoords(tetId); + const auto p{c.data()}; + + switch(id) { + case 0: + edgeId = getTetrahedronEdgeABCG(p, localEdgeId); + break; + case 1: + edgeId = getTetrahedronEdgeBCDG(p, localEdgeId); + break; + case 2: + edgeId = getTetrahedronEdgeABEG(p, localEdgeId); + break; + case 3: + edgeId = getTetrahedronEdgeBEFG(p, localEdgeId); + break; + case 4: + edgeId = getTetrahedronEdgeBFGH(p, localEdgeId); + break; + case 5: + edgeId = getTetrahedronEdgeBDGH(p, localEdgeId); + break; + } + } + + return 0; + } + + inline int getTetrahedronTriangle(const SimplexId &tetId, + const int &localTriangleId, + SimplexId &triangleId) const override { + +#ifndef TTK_ENABLE_KAMIKAZE + if(tetId < 0 or tetId >= tetrahedronNumber_) + return -1; + if(localTriangleId < 0 or localTriangleId >= 4) + return -2; +#endif + + triangleId = -1; + + if(dimensionality_ == 3) { + const SimplexId id = tetId % 6; + const auto &c = this->underlying().getTetrahedronCoords(tetId); + const auto p{c.data()}; + + switch(id) { + case 0: + triangleId = getTetrahedronTriangleABCG(p, localTriangleId); + break; + case 1: + triangleId = getTetrahedronTriangleBCDG(p, localTriangleId); + break; + case 2: + triangleId = getTetrahedronTriangleABEG(p, localTriangleId); + break; + case 3: + triangleId = getTetrahedronTriangleBEFG(p, localTriangleId); + break; + case 4: + triangleId = getTetrahedronTriangleBFGH(p, localTriangleId); + break; + case 5: + triangleId = getTetrahedronTriangleBDGH(p, localTriangleId); + break; + } + } + + return 0; + } + + inline SimplexId + getTetrahedronNeighborNumber(const SimplexId &tetId) const override { + +#ifndef TTK_ENABLE_KAMIKAZE + if(tetId < 0 or tetId >= tetrahedronNumber_) + return -1; +#endif + + if(dimensionality_ == 3) { + const SimplexId id = tetId % 6; + const auto &c = this->underlying().getTetrahedronCoords(tetId); + const auto p{c.data()}; + + switch(id) { + case 0: // ABCG + if(p[0] == 0 and p[2] == 0) + return 2; + else if(p[0] == 0 or p[2] == 0) + return 3; + else + return 4; + break; + case 1: // BCDG + if(p[1] == nbvoxels_[1] - 1 and p[2] == 0) + return 2; + else if(p[1] == nbvoxels_[1] - 1 or p[2] == 0) + return 3; + else + return 4; + break; + case 2: // ABEG + if(p[0] == 0 and p[1] == 0) + return 2; + else if(p[0] == 0 or p[1] == 0) + return 3; + else + return 4; + break; + case 3: // BEFG + if(p[1] == 0 and p[2] == nbvoxels_[2] - 1) + return 2; + else if(p[1] == 0 or p[2] == nbvoxels_[2] - 1) + return 3; + else + return 4; + break; + case 4: // BFGH + if(p[0] == nbvoxels_[0] - 1 and p[2] == nbvoxels_[2] - 1) + return 2; + else if(p[0] == nbvoxels_[0] - 1 or p[2] == nbvoxels_[2] - 1) + return 3; + else + return 4; + break; + case 5: // BDGH + if(p[0] == nbvoxels_[0] - 1 and p[1] == nbvoxels_[1] - 1) + return 2; + else if(p[0] == nbvoxels_[0] - 1 or p[1] == nbvoxels_[1] - 1) + return 3; + else + return 4; + break; + } + } + + return 0; + } + + inline int getTetrahedronNeighbor(const SimplexId &tetId, + const int &localNeighborId, + SimplexId &neighborId) const override { + +#ifndef TTK_ENABLE_KAMIKAZE + if(localNeighborId < 0 + or localNeighborId >= getTetrahedronNeighborNumber(tetId)) + return -1; +#endif + + neighborId = -1; + + if(dimensionality_ == 3) { + const SimplexId id = tetId % 6; + const auto &c = this->underlying().getTetrahedronCoords(tetId); + const auto p{c.data()}; + + switch(id) { + case 0: + neighborId = getTetrahedronNeighborABCG(tetId, p, localNeighborId); + break; + case 1: + neighborId = getTetrahedronNeighborBCDG(tetId, p, localNeighborId); + break; + case 2: + neighborId = getTetrahedronNeighborABEG(tetId, p, localNeighborId); + break; + case 3: + neighborId = getTetrahedronNeighborBEFG(tetId, p, localNeighborId); + break; + case 4: + neighborId = getTetrahedronNeighborBFGH(tetId, p, localNeighborId); + break; + case 5: + neighborId = getTetrahedronNeighborBDGH(tetId, p, localNeighborId); + break; + } + } + + return 0; + } }; } // namespace ttk From 22097548d883b0e38c1b5d3cc41c76e113086717 Mon Sep 17 00:00:00 2001 From: Julien Tierny Date: Thu, 21 Sep 2023 13:58:40 +0200 Subject: [PATCH 04/12] removed TTK_FORCE_USE --- core/base/implicitTriangulation/ImplicitTriangulation.h | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/core/base/implicitTriangulation/ImplicitTriangulation.h b/core/base/implicitTriangulation/ImplicitTriangulation.h index a7bac3de3c..288c365b48 100644 --- a/core/base/implicitTriangulation/ImplicitTriangulation.h +++ b/core/base/implicitTriangulation/ImplicitTriangulation.h @@ -98,9 +98,8 @@ namespace ttk { } inline SimplexId - getCellEdgeNumberInternal(const SimplexId &cellId) const override { + getCellEdgeNumberInternal(const SimplexId & /*cellId*/) const override { - TTK_FORCE_USE(cellId); if(dimensionality_ == 3) return 6; else if(dimensionality_ == 2) @@ -182,8 +181,8 @@ namespace ttk { } inline SimplexId TTK_TRIANGULATION_INTERNAL(getCellVertexNumber)( - const SimplexId &cellId) const override { - TTK_FORCE_USE(cellId); + const SimplexId & /*cellId*/) const override { + return dimensionality_ + 1; } From c8194d0de71db3cd34496893489eeac66d9d571a Mon Sep 17 00:00:00 2001 From: Julien Tierny Date: Sat, 23 Sep 2023 07:11:34 +0200 Subject: [PATCH 05/12] finished in-lining implicit triangulation --- .../implicitTriangulation/ImplicitTriangulation.cpp | 11 ----------- .../implicitTriangulation/ImplicitTriangulation.h | 12 +++++++++++- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/core/base/implicitTriangulation/ImplicitTriangulation.cpp b/core/base/implicitTriangulation/ImplicitTriangulation.cpp index 373f25b844..7c1dfc6ed1 100644 --- a/core/base/implicitTriangulation/ImplicitTriangulation.cpp +++ b/core/base/implicitTriangulation/ImplicitTriangulation.cpp @@ -461,17 +461,6 @@ const vector> * return &triangleStarList_; } -int ImplicitTriangulation::getTriangleNeighbors( - vector> &neighbors) { - neighbors.resize(triangleNumber_); - for(SimplexId i = 0; i < triangleNumber_; ++i) { - neighbors[i].resize(getTriangleNeighborNumber(i)); - for(SimplexId j = 0; j < (SimplexId)neighbors[i].size(); ++j) - getTriangleNeighbor(i, j, neighbors[i][j]); - } - return 0; -} - const vector> *ImplicitTriangulation::getCellEdgesInternal() { if(cellEdgeVector_.empty()) { Timer t; diff --git a/core/base/implicitTriangulation/ImplicitTriangulation.h b/core/base/implicitTriangulation/ImplicitTriangulation.h index 288c365b48..4e99041dc8 100644 --- a/core/base/implicitTriangulation/ImplicitTriangulation.h +++ b/core/base/implicitTriangulation/ImplicitTriangulation.h @@ -319,7 +319,17 @@ namespace ttk { virtual SimplexId getTriangleNeighborNumber(const SimplexId &triangleId) const = 0; - int getTriangleNeighbors(std::vector> &neighbors); + inline int + getTriangleNeighbors(std::vector> &neighbors) { + + neighbors.resize(triangleNumber_); + for(SimplexId i = 0; i < triangleNumber_; ++i) { + neighbors[i].resize(getTriangleNeighborNumber(i)); + for(SimplexId j = 0; j < (SimplexId)neighbors[i].size(); ++j) + getTriangleNeighbor(i, j, neighbors[i][j]); + } + return 0; + } const std::vector> * TTK_TRIANGULATION_INTERNAL(getTriangleStars)() override; From 57d718175b7decded1fa5db79f9cd7c63546bc46 Mon Sep 17 00:00:00 2001 From: Julien Tierny Date: Sat, 23 Sep 2023 07:22:46 +0200 Subject: [PATCH 06/12] marking in-line functions as final --- .../ImplicitPreconditions.h | 16 +- .../ImplicitTriangulation.h | 203 +++++++++--------- 2 files changed, 107 insertions(+), 112 deletions(-) diff --git a/core/base/implicitTriangulation/ImplicitPreconditions.h b/core/base/implicitTriangulation/ImplicitPreconditions.h index ed92bd8a90..adc0e40256 100644 --- a/core/base/implicitTriangulation/ImplicitPreconditions.h +++ b/core/base/implicitTriangulation/ImplicitPreconditions.h @@ -13,10 +13,10 @@ namespace ttk { this->setDebugMsgPrefix("ImplicitTriangulationWithPreconditions"); } - int preconditionVerticesInternal() override; - int preconditionEdgesInternal() override; - int preconditionTrianglesInternal() override; - int preconditionTetrahedronsInternal() override; + int preconditionVerticesInternal() final; + int preconditionEdgesInternal() final; + int preconditionTrianglesInternal() final; + int preconditionTetrahedronsInternal() final; inline VertexPosition getVertexPosition(const SimplexId v) const { return this->vertexPositions_[v]; @@ -83,16 +83,16 @@ namespace ttk { this->setDebugMsgPrefix("ImplicitTriangulationNoPreconditions"); } - inline int preconditionVerticesInternal() override { + inline int preconditionVerticesInternal() final { return 0; } - inline int preconditionEdgesInternal() override { + inline int preconditionEdgesInternal() final { return 0; } - inline int preconditionTrianglesInternal() override { + inline int preconditionTrianglesInternal() final { return 0; } - inline int preconditionTetrahedronsInternal() override { + inline int preconditionTetrahedronsInternal() final { return 0; } diff --git a/core/base/implicitTriangulation/ImplicitTriangulation.h b/core/base/implicitTriangulation/ImplicitTriangulation.h index 4e99041dc8..f25a316bc1 100644 --- a/core/base/implicitTriangulation/ImplicitTriangulation.h +++ b/core/base/implicitTriangulation/ImplicitTriangulation.h @@ -79,13 +79,13 @@ namespace ttk { ImplicitTriangulation &operator=(const ImplicitTriangulation &) = default; ImplicitTriangulation &operator=(ImplicitTriangulation &&) = default; - inline const std::array &getGridDimensions() const override { + inline const std::array &getGridDimensions() const final { return this->dimensions_; } inline int getCellEdgeInternal(const SimplexId &cellId, const int &localEdgeId, - SimplexId &edgeId) const override { + SimplexId &edgeId) const final { if(dimensionality_ == 3) getTetrahedronEdge(cellId, localEdgeId, edgeId); @@ -98,7 +98,7 @@ namespace ttk { } inline SimplexId - getCellEdgeNumberInternal(const SimplexId & /*cellId*/) const override { + getCellEdgeNumberInternal(const SimplexId & /*cellId*/) const final { if(dimensionality_ == 3) return 6; @@ -108,12 +108,12 @@ namespace ttk { return 0; } - const std::vector> *getCellEdgesInternal() override; + const std::vector> *getCellEdgesInternal() final; inline int TTK_TRIANGULATION_INTERNAL(getCellNeighbor)( const SimplexId &cellId, const int &localNeighborId, - SimplexId &neighborId) const override { + SimplexId &neighborId) const final { if(dimensionality_ == 3) getTetrahedronNeighbor(cellId, localNeighborId, neighborId); @@ -128,7 +128,7 @@ namespace ttk { } inline SimplexId TTK_TRIANGULATION_INTERNAL(getCellNeighborNumber)( - const SimplexId &cellId) const override { + const SimplexId &cellId) const final { if(dimensionality_ == 3) return getTetrahedronNeighborNumber(cellId); @@ -143,11 +143,11 @@ namespace ttk { } const std::vector> * - TTK_TRIANGULATION_INTERNAL(getCellNeighbors)() override; + TTK_TRIANGULATION_INTERNAL(getCellNeighbors)() final; inline int getCellTriangleInternal(const SimplexId &cellId, const int &localTriangleId, - SimplexId &triangleId) const override { + SimplexId &triangleId) const final { if(dimensionality_ == 3) getTetrahedronTriangle(cellId, localTriangleId, triangleId); @@ -155,20 +155,19 @@ namespace ttk { return 0; } - SimplexId getCellTriangleNumberInternal( - const SimplexId & /*cellId*/) const override { + inline SimplexId + getCellTriangleNumberInternal(const SimplexId & /*cellId*/) const final { // NOTE: the output is always 4 here. let's keep the function in there // in case of further generalization to CW-complexes return 4; } - const std::vector> * - getCellTrianglesInternal() override; + const std::vector> *getCellTrianglesInternal() final; inline int TTK_TRIANGULATION_INTERNAL(getCellVertex)( const SimplexId &cellId, const int &localVertexId, - SimplexId &vertexId) const override { + SimplexId &vertexId) const final { if(dimensionality_ == 3) getTetrahedronVertex(cellId, localVertexId, vertexId); @@ -181,46 +180,47 @@ namespace ttk { } inline SimplexId TTK_TRIANGULATION_INTERNAL(getCellVertexNumber)( - const SimplexId & /*cellId*/) const override { + const SimplexId & /*cellId*/) const final { return dimensionality_ + 1; } - int TTK_TRIANGULATION_INTERNAL(getDimensionality)() const override { + inline int TTK_TRIANGULATION_INTERNAL(getDimensionality)() const final { return dimensionality_; } inline SimplexId TTK_TRIANGULATION_INTERNAL(getEdgeLinkNumber)( - const SimplexId &edgeId) const override { + const SimplexId &edgeId) const final { return TTK_TRIANGULATION_INTERNAL(getEdgeStarNumber)(edgeId); } const std::vector> * - TTK_TRIANGULATION_INTERNAL(getEdgeLinks)() override; + TTK_TRIANGULATION_INTERNAL(getEdgeLinks)() final; const std::vector> * - TTK_TRIANGULATION_INTERNAL(getEdgeStars)() override; + TTK_TRIANGULATION_INTERNAL(getEdgeStars)() final; - const std::vector> * - getEdgeTrianglesInternal() override; + const std::vector> *getEdgeTrianglesInternal() final; const std::vector> * - TTK_TRIANGULATION_INTERNAL(getEdges)() override; + TTK_TRIANGULATION_INTERNAL(getEdges)() final; - SimplexId TTK_TRIANGULATION_INTERNAL(getNumberOfCells)() const override { + inline SimplexId + TTK_TRIANGULATION_INTERNAL(getNumberOfCells)() const final { return cellNumber_; } - SimplexId getNumberOfEdgesInternal() const override { + inline SimplexId getNumberOfEdgesInternal() const final { return edgeNumber_; } - SimplexId getNumberOfTrianglesInternal() const override { + inline SimplexId getNumberOfTrianglesInternal() const final { return triangleNumber_; } - SimplexId TTK_TRIANGULATION_INTERNAL(getNumberOfVertices)() const override { + inline SimplexId + TTK_TRIANGULATION_INTERNAL(getNumberOfVertices)() const final { return vertexNumber_; } @@ -281,15 +281,14 @@ namespace ttk { const int &localVertexId, SimplexId &vertexId) const = 0; - SimplexId getTriangleEdgeNumberInternal( - const SimplexId & /*triangleId*/) const override { + inline SimplexId getTriangleEdgeNumberInternal( + const SimplexId & /*triangleId*/) const final { // NOTE: the output is always 3 here. let's keep the function in there // in case of further generalization to CW-complexes return 3; } - const std::vector> * - getTriangleEdgesInternal() override; + const std::vector> *getTriangleEdgesInternal() final; inline int getTriangleEdgesInternal( std::vector> &edges) const { @@ -304,13 +303,13 @@ namespace ttk { } inline SimplexId TTK_TRIANGULATION_INTERNAL(getTriangleLinkNumber)( - const SimplexId &triangleId) const override { + const SimplexId &triangleId) const final { return TTK_TRIANGULATION_INTERNAL(getTriangleStarNumber)(triangleId); } const std::vector> * - TTK_TRIANGULATION_INTERNAL(getTriangleLinks)() override; + TTK_TRIANGULATION_INTERNAL(getTriangleLinks)() final; virtual int getTriangleNeighbor(const SimplexId &triangleId, const int &localNeighborId, @@ -332,42 +331,41 @@ namespace ttk { } const std::vector> * - TTK_TRIANGULATION_INTERNAL(getTriangleStars)() override; + TTK_TRIANGULATION_INTERNAL(getTriangleStars)() final; const std::vector> * - TTK_TRIANGULATION_INTERNAL(getTriangles)() override; + TTK_TRIANGULATION_INTERNAL(getTriangles)() final; inline SimplexId - getVertexEdgeNumberInternal(const SimplexId &vertexId) const override { + getVertexEdgeNumberInternal(const SimplexId &vertexId) const final { return TTK_TRIANGULATION_INTERNAL(getVertexNeighborNumber)(vertexId); } - const std::vector> * - getVertexEdgesInternal() override; + const std::vector> *getVertexEdgesInternal() final; inline SimplexId TTK_TRIANGULATION_INTERNAL(getVertexLinkNumber)( - const SimplexId &vertexId) const override { + const SimplexId &vertexId) const final { return TTK_TRIANGULATION_INTERNAL(getVertexStarNumber)(vertexId); } const std::vector> * - TTK_TRIANGULATION_INTERNAL(getVertexLinks)() override; + TTK_TRIANGULATION_INTERNAL(getVertexLinks)() final; const std::vector> * - TTK_TRIANGULATION_INTERNAL(getVertexNeighbors)() override; + TTK_TRIANGULATION_INTERNAL(getVertexNeighbors)() final; const std::vector> * - TTK_TRIANGULATION_INTERNAL(getVertexStars)() override; + TTK_TRIANGULATION_INTERNAL(getVertexStars)() final; const std::vector> * - getVertexTrianglesInternal() override; + getVertexTrianglesInternal() final; - inline bool isEmpty() const override { + inline bool isEmpty() const final { return !vertexNumber_; } inline bool TTK_TRIANGULATION_INTERNAL(isTriangleOnBoundary)( - const SimplexId &triangleId) const override { + const SimplexId &triangleId) const final { #ifdef TTK_ENABLE_MPI if(this->metaGrid_ != nullptr) { @@ -395,10 +393,10 @@ namespace ttk { const float &zSpacing, const SimplexId &xDim, const SimplexId &yDim, - const SimplexId &zDim) override; + const SimplexId &zDim) final; virtual int preconditionVerticesInternal() = 0; - int preconditionVertexNeighborsInternal() override; + int preconditionVertexNeighborsInternal() final; int preconditionEdgesInternal() override = 0; int preconditionTrianglesInternal() override = 0; virtual int preconditionTetrahedronsInternal() = 0; @@ -422,8 +420,7 @@ namespace ttk { return 0; } - inline int getCellVTKIDInternal(const int &ttkId, - int &vtkId) const override { + inline int getCellVTKIDInternal(const int &ttkId, int &vtkId) const final { #ifndef TTK_ENABLE_KAMIKAZE if(ttkId < 0) { return -1; @@ -437,11 +434,11 @@ namespace ttk { #ifdef TTK_ENABLE_MPI protected: - int preconditionDistributedCells() override; + int preconditionDistributedCells() final; public: - void createMetaGrid(const double *const bounds) override; - inline int getCellRankInternal(const SimplexId lcid) const override { + void createMetaGrid(const double *const bounds) final; + inline int getCellRankInternal(const SimplexId lcid) const final { const int nTetraPerCube{this->dimensionality_ == 3 ? 6 : 2}; const auto locCubeId{lcid / nTetraPerCube}; @@ -485,7 +482,7 @@ namespace ttk { protected: inline bool - isVertexOnGlobalBoundaryInternal(const SimplexId lvid) const override { + isVertexOnGlobalBoundaryInternal(const SimplexId lvid) const final { if(!ttk::isRunningWithMPI()) { // NOTE: perf killer @@ -510,7 +507,7 @@ namespace ttk { } inline bool - isEdgeOnGlobalBoundaryInternal(const SimplexId leid) const override { + isEdgeOnGlobalBoundaryInternal(const SimplexId leid) const final { if(!ttk::isRunningWithMPI()) { // NOTE: perf killer @@ -534,7 +531,7 @@ namespace ttk { } inline bool - isTriangleOnGlobalBoundaryInternal(const SimplexId ltid) const override { + isTriangleOnGlobalBoundaryInternal(const SimplexId ltid) const final { if(!ttk::isRunningWithMPI()) { // NOTE: perf killer @@ -559,7 +556,7 @@ namespace ttk { private: inline std::array - getVertGlobalCoords(const SimplexId lvid) const override { + getVertGlobalCoords(const SimplexId lvid) const final { // local vertex coordinates std::array p{}; @@ -578,7 +575,7 @@ namespace ttk { } inline std::array - getVertLocalCoords(const SimplexId gvid) const override { + getVertLocalCoords(const SimplexId gvid) const final { // global vertex coordinates std::array p{}; @@ -858,12 +855,11 @@ namespace ttk { //\cond // 2D // - void vertexToPosition2d(const SimplexId vertex, - SimplexId p[2]) const override; + void vertexToPosition2d(const SimplexId vertex, SimplexId p[2]) const final; void edgeToPosition2d(const SimplexId edge, const int k, SimplexId p[2]) const; void triangleToPosition2d(const SimplexId triangle, - SimplexId p[2]) const override; + SimplexId p[2]) const final; inline SimplexId getVertexEdge2dA(const SimplexId p[2], const int id) const; inline SimplexId getVertexEdge2dB(const SimplexId p[2], const int id) const; @@ -933,15 +929,14 @@ namespace ttk { inline SimplexId getEdgeStar2dH(const SimplexId p[2], const int id) const; // 3D // - void vertexToPosition(const SimplexId vertex, - SimplexId p[3]) const override; + void vertexToPosition(const SimplexId vertex, SimplexId p[3]) const final; void edgeToPosition(const SimplexId edge, const int k, SimplexId p[3]) const; void triangleToPosition(const SimplexId triangle, const int k, - SimplexId p[3]) const override; + SimplexId p[3]) const final; void tetrahedronToPosition(const SimplexId tetrahedron, - SimplexId p[3]) const override; + SimplexId p[3]) const final; inline SimplexId getVertexEdgeA(const SimplexId p[3], const int id) const; inline SimplexId getVertexEdgeB(const SimplexId p[3], const int id) const; @@ -1328,7 +1323,7 @@ namespace ttk { public: inline SimplexId TTK_TRIANGULATION_INTERNAL(getVertexNeighborNumber)( - const SimplexId &vertexId) const override { + const SimplexId &vertexId) const final { #ifndef TTK_ENABLE_KAMIKAZE if(vertexId < 0 or vertexId >= vertexNumber_) @@ -1390,7 +1385,7 @@ namespace ttk { } inline bool TTK_TRIANGULATION_INTERNAL(isVertexOnBoundary)( - const SimplexId &vertexId) const override { + const SimplexId &vertexId) const final { #ifdef TTK_ENABLE_MPI if(this->metaGrid_ != nullptr) { return this->isVertexOnGlobalBoundaryInternal(vertexId); @@ -1413,7 +1408,7 @@ namespace ttk { } inline bool TTK_TRIANGULATION_INTERNAL(isEdgeOnBoundary)( - const SimplexId &edgeId) const override { + const SimplexId &edgeId) const final { #ifdef TTK_ENABLE_MPI if(this->metaGrid_ != nullptr) { @@ -1447,7 +1442,7 @@ namespace ttk { inline int TTK_TRIANGULATION_INTERNAL(getVertexNeighbor)( const SimplexId &vertexId, const int &localNeighborId, - SimplexId &neighborId) const override { + SimplexId &neighborId) const final { #ifndef TTK_ENABLE_KAMIKAZE if(localNeighborId < 0 @@ -1584,7 +1579,7 @@ namespace ttk { inline int getVertexEdgeInternal(const SimplexId &vertexId, const int &localEdgeId, - SimplexId &edgeId) const override { + SimplexId &edgeId) const final { #ifndef TTK_ENABLE_KAMIKAZE if(localEdgeId < 0 @@ -1735,8 +1730,8 @@ namespace ttk { return 0; } - inline SimplexId getVertexTriangleNumberInternal( - const SimplexId &vertexId) const override { + inline SimplexId + getVertexTriangleNumberInternal(const SimplexId &vertexId) const final { #ifndef TTK_ENABLE_KAMIKAZE if(vertexId < 0 or vertexId >= vertexNumber_) @@ -1786,7 +1781,7 @@ namespace ttk { inline int getVertexTriangleInternal(const SimplexId &vertexId, const int &localTriangleId, - SimplexId &triangleId) const override { + SimplexId &triangleId) const final { #ifndef TTK_ENABLE_KAMIKAZE if(localTriangleId < 0 or localTriangleId >= getVertexTriangleNumberInternal(vertexId)) @@ -1885,10 +1880,10 @@ namespace ttk { return 0; } - inline int TTK_TRIANGULATION_INTERNAL(getVertexLink)( - const SimplexId &vertexId, - const int &localLinkId, - SimplexId &linkId) const override { + inline int + TTK_TRIANGULATION_INTERNAL(getVertexLink)(const SimplexId &vertexId, + const int &localLinkId, + SimplexId &linkId) const final { #ifndef TTK_ENABLE_KAMIKAZE if(localLinkId < 0 or localLinkId >= getVertexLinkNumber(vertexId)) @@ -2015,7 +2010,7 @@ namespace ttk { } inline SimplexId TTK_TRIANGULATION_INTERNAL(getVertexStarNumber)( - const SimplexId &vertexId) const override { + const SimplexId &vertexId) const final { #ifndef TTK_ENABLE_KAMIKAZE if(vertexId < 0 or vertexId >= vertexNumber_) @@ -2074,10 +2069,10 @@ namespace ttk { return 0; } - inline int TTK_TRIANGULATION_INTERNAL(getVertexStar)( - const SimplexId &vertexId, - const int &localStarId, - SimplexId &starId) const override { + inline int + TTK_TRIANGULATION_INTERNAL(getVertexStar)(const SimplexId &vertexId, + const int &localStarId, + SimplexId &starId) const final { #ifndef TTK_ENABLE_KAMIKAZE if(localStarId < 0 or localStarId >= getVertexStarNumber(vertexId)) @@ -2204,7 +2199,7 @@ namespace ttk { } inline int TTK_TRIANGULATION_INTERNAL(getVertexPoint)( - const SimplexId &vertexId, float &x, float &y, float &z) const override { + const SimplexId &vertexId, float &x, float &y, float &z) const final { if(dimensionality_ == 3) { const auto &p = this->underlying().getVertexCoords(vertexId); @@ -2248,7 +2243,7 @@ namespace ttk { inline int getEdgeVertexInternal(const SimplexId &edgeId, const int &localVertexId, - SimplexId &vertexId) const override { + SimplexId &vertexId) const final { #ifndef TTK_ENABLE_KAMIKAZE if(edgeId < 0 or edgeId >= edgeNumber_) @@ -2328,7 +2323,7 @@ namespace ttk { } inline SimplexId - getEdgeTriangleNumberInternal(const SimplexId &edgeId) const override { + getEdgeTriangleNumberInternal(const SimplexId &edgeId) const final { #ifndef TTK_ENABLE_KAMIKAZE if(edgeId < 0 or edgeId >= edgeNumber_) @@ -2395,7 +2390,7 @@ namespace ttk { inline int getEdgeTriangleInternal(const SimplexId &edgeId, const int &localTriangleId, - SimplexId &triangleId) const override { + SimplexId &triangleId) const final { #ifndef TTK_ENABLE_KAMIKAZE if(localTriangleId < 0 or localTriangleId >= getEdgeTriangleNumberInternal(edgeId)) @@ -2547,10 +2542,10 @@ namespace ttk { return 0; } - inline int TTK_TRIANGULATION_INTERNAL(getEdgeLink)( - const SimplexId &edgeId, - const int &localLinkId, - SimplexId &linkId) const override { + inline int + TTK_TRIANGULATION_INTERNAL(getEdgeLink)(const SimplexId &edgeId, + const int &localLinkId, + SimplexId &linkId) const final { #ifndef TTK_ENABLE_KAMIKAZE if(localLinkId < 0 or localLinkId >= getEdgeLinkNumber(edgeId)) @@ -2600,10 +2595,10 @@ namespace ttk { return 0; } - inline int TTK_TRIANGULATION_INTERNAL(getEdgeStar)( - const SimplexId &edgeId, - const int &localStarId, - SimplexId &starId) const override { + inline int + TTK_TRIANGULATION_INTERNAL(getEdgeStar)(const SimplexId &edgeId, + const int &localStarId, + SimplexId &starId) const final { #ifndef TTK_ENABLE_KAMIKAZE if(localStarId < 0 or localStarId >= getEdgeStarNumber(edgeId)) return -1; @@ -2654,7 +2649,7 @@ namespace ttk { } inline SimplexId TTK_TRIANGULATION_INTERNAL(getEdgeStarNumber)( - const SimplexId &edgeId) const override { + const SimplexId &edgeId) const final { #ifndef TTK_ENABLE_KAMIKAZE if(edgeId < 0 or edgeId >= edgeNumber_) @@ -2721,7 +2716,7 @@ namespace ttk { inline int getTriangleVertexInternal(const SimplexId &triangleId, const int &localVertexId, - SimplexId &vertexId) const override { + SimplexId &vertexId) const final { #ifndef TTK_ENABLE_KAMIKAZE if(triangleId < 0 or triangleId >= triangleNumber_) @@ -2802,7 +2797,7 @@ namespace ttk { inline int getTriangleEdgeInternal(const SimplexId &triangleId, const int &localEdgeId, - SimplexId &edgeId) const override { + SimplexId &edgeId) const final { #ifndef TTK_ENABLE_KAMIKAZE if(triangleId < 0 or triangleId >= triangleNumber_) @@ -2875,7 +2870,7 @@ namespace ttk { inline int TTK_TRIANGULATION_INTERNAL(getTriangleLink)( const SimplexId &triangleId, const int &localLinkId, - SimplexId &linkId) const override { + SimplexId &linkId) const final { #ifndef TTK_ENABLE_KAMIKAZE if(localLinkId < 0 or localLinkId >= getTriangleLinkNumber(triangleId)) @@ -2914,7 +2909,7 @@ namespace ttk { inline int TTK_TRIANGULATION_INTERNAL(getTriangleStar)( const SimplexId &triangleId, const int &localStarId, - SimplexId &starId) const override { + SimplexId &starId) const final { #ifndef TTK_ENABLE_KAMIKAZE if(localStarId < 0 or localStarId >= getTriangleStarNumber(triangleId)) @@ -2951,7 +2946,7 @@ namespace ttk { } inline SimplexId TTK_TRIANGULATION_INTERNAL(getTriangleStarNumber)( - const SimplexId &triangleId) const override { + const SimplexId &triangleId) const final { #ifndef TTK_ENABLE_KAMIKAZE if(triangleId < 0 or triangleId >= triangleNumber_) @@ -2980,7 +2975,7 @@ namespace ttk { inline int getTriangleNeighbor(const SimplexId &triangleId, const int &localNeighborId, - SimplexId &neighborId) const override { + SimplexId &neighborId) const final { #ifndef TTK_ENABLE_KAMIKAZE if(localNeighborId < 0 @@ -3069,7 +3064,7 @@ namespace ttk { } inline SimplexId - getTriangleNeighborNumber(const SimplexId &triangleId) const override { + getTriangleNeighborNumber(const SimplexId &triangleId) const final { #ifndef TTK_ENABLE_KAMIKAZE if(triangleId < 0 or triangleId >= triangleNumber_) @@ -3102,7 +3097,7 @@ namespace ttk { inline int getTetrahedronVertex(const SimplexId &tetId, const int &localVertexId, - SimplexId &vertexId) const override { + SimplexId &vertexId) const final { #ifndef TTK_ENABLE_KAMIKAZE if(tetId < 0 or tetId >= tetrahedronNumber_) @@ -3144,7 +3139,7 @@ namespace ttk { inline int getTetrahedronEdge(const SimplexId &tetId, const int &localEdgeId, - SimplexId &edgeId) const override { + SimplexId &edgeId) const final { #ifndef TTK_ENABLE_KAMIKAZE if(tetId < 0 or tetId >= tetrahedronNumber_) @@ -3187,7 +3182,7 @@ namespace ttk { inline int getTetrahedronTriangle(const SimplexId &tetId, const int &localTriangleId, - SimplexId &triangleId) const override { + SimplexId &triangleId) const final { #ifndef TTK_ENABLE_KAMIKAZE if(tetId < 0 or tetId >= tetrahedronNumber_) @@ -3229,7 +3224,7 @@ namespace ttk { } inline SimplexId - getTetrahedronNeighborNumber(const SimplexId &tetId) const override { + getTetrahedronNeighborNumber(const SimplexId &tetId) const final { #ifndef TTK_ENABLE_KAMIKAZE if(tetId < 0 or tetId >= tetrahedronNumber_) @@ -3298,7 +3293,7 @@ namespace ttk { inline int getTetrahedronNeighbor(const SimplexId &tetId, const int &localNeighborId, - SimplexId &neighborId) const override { + SimplexId &neighborId) const final { #ifndef TTK_ENABLE_KAMIKAZE if(localNeighborId < 0 From fbd49c99c4e7a8b56df91f925161e22b77c19382 Mon Sep 17 00:00:00 2001 From: Julien Tierny Date: Thu, 28 Sep 2023 11:37:14 +0200 Subject: [PATCH 07/12] Revert, back to inlining `getVertexNeighbor` This reverts commit 57d718175b7decded1fa5db79f9cd7c63546bc46. --- .../ImplicitPreconditions.h | 16 +- .../ImplicitTriangulation.h | 203 +++++++++--------- 2 files changed, 112 insertions(+), 107 deletions(-) diff --git a/core/base/implicitTriangulation/ImplicitPreconditions.h b/core/base/implicitTriangulation/ImplicitPreconditions.h index adc0e40256..ed92bd8a90 100644 --- a/core/base/implicitTriangulation/ImplicitPreconditions.h +++ b/core/base/implicitTriangulation/ImplicitPreconditions.h @@ -13,10 +13,10 @@ namespace ttk { this->setDebugMsgPrefix("ImplicitTriangulationWithPreconditions"); } - int preconditionVerticesInternal() final; - int preconditionEdgesInternal() final; - int preconditionTrianglesInternal() final; - int preconditionTetrahedronsInternal() final; + int preconditionVerticesInternal() override; + int preconditionEdgesInternal() override; + int preconditionTrianglesInternal() override; + int preconditionTetrahedronsInternal() override; inline VertexPosition getVertexPosition(const SimplexId v) const { return this->vertexPositions_[v]; @@ -83,16 +83,16 @@ namespace ttk { this->setDebugMsgPrefix("ImplicitTriangulationNoPreconditions"); } - inline int preconditionVerticesInternal() final { + inline int preconditionVerticesInternal() override { return 0; } - inline int preconditionEdgesInternal() final { + inline int preconditionEdgesInternal() override { return 0; } - inline int preconditionTrianglesInternal() final { + inline int preconditionTrianglesInternal() override { return 0; } - inline int preconditionTetrahedronsInternal() final { + inline int preconditionTetrahedronsInternal() override { return 0; } diff --git a/core/base/implicitTriangulation/ImplicitTriangulation.h b/core/base/implicitTriangulation/ImplicitTriangulation.h index f25a316bc1..4e99041dc8 100644 --- a/core/base/implicitTriangulation/ImplicitTriangulation.h +++ b/core/base/implicitTriangulation/ImplicitTriangulation.h @@ -79,13 +79,13 @@ namespace ttk { ImplicitTriangulation &operator=(const ImplicitTriangulation &) = default; ImplicitTriangulation &operator=(ImplicitTriangulation &&) = default; - inline const std::array &getGridDimensions() const final { + inline const std::array &getGridDimensions() const override { return this->dimensions_; } inline int getCellEdgeInternal(const SimplexId &cellId, const int &localEdgeId, - SimplexId &edgeId) const final { + SimplexId &edgeId) const override { if(dimensionality_ == 3) getTetrahedronEdge(cellId, localEdgeId, edgeId); @@ -98,7 +98,7 @@ namespace ttk { } inline SimplexId - getCellEdgeNumberInternal(const SimplexId & /*cellId*/) const final { + getCellEdgeNumberInternal(const SimplexId & /*cellId*/) const override { if(dimensionality_ == 3) return 6; @@ -108,12 +108,12 @@ namespace ttk { return 0; } - const std::vector> *getCellEdgesInternal() final; + const std::vector> *getCellEdgesInternal() override; inline int TTK_TRIANGULATION_INTERNAL(getCellNeighbor)( const SimplexId &cellId, const int &localNeighborId, - SimplexId &neighborId) const final { + SimplexId &neighborId) const override { if(dimensionality_ == 3) getTetrahedronNeighbor(cellId, localNeighborId, neighborId); @@ -128,7 +128,7 @@ namespace ttk { } inline SimplexId TTK_TRIANGULATION_INTERNAL(getCellNeighborNumber)( - const SimplexId &cellId) const final { + const SimplexId &cellId) const override { if(dimensionality_ == 3) return getTetrahedronNeighborNumber(cellId); @@ -143,11 +143,11 @@ namespace ttk { } const std::vector> * - TTK_TRIANGULATION_INTERNAL(getCellNeighbors)() final; + TTK_TRIANGULATION_INTERNAL(getCellNeighbors)() override; inline int getCellTriangleInternal(const SimplexId &cellId, const int &localTriangleId, - SimplexId &triangleId) const final { + SimplexId &triangleId) const override { if(dimensionality_ == 3) getTetrahedronTriangle(cellId, localTriangleId, triangleId); @@ -155,19 +155,20 @@ namespace ttk { return 0; } - inline SimplexId - getCellTriangleNumberInternal(const SimplexId & /*cellId*/) const final { + SimplexId getCellTriangleNumberInternal( + const SimplexId & /*cellId*/) const override { // NOTE: the output is always 4 here. let's keep the function in there // in case of further generalization to CW-complexes return 4; } - const std::vector> *getCellTrianglesInternal() final; + const std::vector> * + getCellTrianglesInternal() override; inline int TTK_TRIANGULATION_INTERNAL(getCellVertex)( const SimplexId &cellId, const int &localVertexId, - SimplexId &vertexId) const final { + SimplexId &vertexId) const override { if(dimensionality_ == 3) getTetrahedronVertex(cellId, localVertexId, vertexId); @@ -180,47 +181,46 @@ namespace ttk { } inline SimplexId TTK_TRIANGULATION_INTERNAL(getCellVertexNumber)( - const SimplexId & /*cellId*/) const final { + const SimplexId & /*cellId*/) const override { return dimensionality_ + 1; } - inline int TTK_TRIANGULATION_INTERNAL(getDimensionality)() const final { + int TTK_TRIANGULATION_INTERNAL(getDimensionality)() const override { return dimensionality_; } inline SimplexId TTK_TRIANGULATION_INTERNAL(getEdgeLinkNumber)( - const SimplexId &edgeId) const final { + const SimplexId &edgeId) const override { return TTK_TRIANGULATION_INTERNAL(getEdgeStarNumber)(edgeId); } const std::vector> * - TTK_TRIANGULATION_INTERNAL(getEdgeLinks)() final; + TTK_TRIANGULATION_INTERNAL(getEdgeLinks)() override; const std::vector> * - TTK_TRIANGULATION_INTERNAL(getEdgeStars)() final; + TTK_TRIANGULATION_INTERNAL(getEdgeStars)() override; - const std::vector> *getEdgeTrianglesInternal() final; + const std::vector> * + getEdgeTrianglesInternal() override; const std::vector> * - TTK_TRIANGULATION_INTERNAL(getEdges)() final; + TTK_TRIANGULATION_INTERNAL(getEdges)() override; - inline SimplexId - TTK_TRIANGULATION_INTERNAL(getNumberOfCells)() const final { + SimplexId TTK_TRIANGULATION_INTERNAL(getNumberOfCells)() const override { return cellNumber_; } - inline SimplexId getNumberOfEdgesInternal() const final { + SimplexId getNumberOfEdgesInternal() const override { return edgeNumber_; } - inline SimplexId getNumberOfTrianglesInternal() const final { + SimplexId getNumberOfTrianglesInternal() const override { return triangleNumber_; } - inline SimplexId - TTK_TRIANGULATION_INTERNAL(getNumberOfVertices)() const final { + SimplexId TTK_TRIANGULATION_INTERNAL(getNumberOfVertices)() const override { return vertexNumber_; } @@ -281,14 +281,15 @@ namespace ttk { const int &localVertexId, SimplexId &vertexId) const = 0; - inline SimplexId getTriangleEdgeNumberInternal( - const SimplexId & /*triangleId*/) const final { + SimplexId getTriangleEdgeNumberInternal( + const SimplexId & /*triangleId*/) const override { // NOTE: the output is always 3 here. let's keep the function in there // in case of further generalization to CW-complexes return 3; } - const std::vector> *getTriangleEdgesInternal() final; + const std::vector> * + getTriangleEdgesInternal() override; inline int getTriangleEdgesInternal( std::vector> &edges) const { @@ -303,13 +304,13 @@ namespace ttk { } inline SimplexId TTK_TRIANGULATION_INTERNAL(getTriangleLinkNumber)( - const SimplexId &triangleId) const final { + const SimplexId &triangleId) const override { return TTK_TRIANGULATION_INTERNAL(getTriangleStarNumber)(triangleId); } const std::vector> * - TTK_TRIANGULATION_INTERNAL(getTriangleLinks)() final; + TTK_TRIANGULATION_INTERNAL(getTriangleLinks)() override; virtual int getTriangleNeighbor(const SimplexId &triangleId, const int &localNeighborId, @@ -331,41 +332,42 @@ namespace ttk { } const std::vector> * - TTK_TRIANGULATION_INTERNAL(getTriangleStars)() final; + TTK_TRIANGULATION_INTERNAL(getTriangleStars)() override; const std::vector> * - TTK_TRIANGULATION_INTERNAL(getTriangles)() final; + TTK_TRIANGULATION_INTERNAL(getTriangles)() override; inline SimplexId - getVertexEdgeNumberInternal(const SimplexId &vertexId) const final { + getVertexEdgeNumberInternal(const SimplexId &vertexId) const override { return TTK_TRIANGULATION_INTERNAL(getVertexNeighborNumber)(vertexId); } - const std::vector> *getVertexEdgesInternal() final; + const std::vector> * + getVertexEdgesInternal() override; inline SimplexId TTK_TRIANGULATION_INTERNAL(getVertexLinkNumber)( - const SimplexId &vertexId) const final { + const SimplexId &vertexId) const override { return TTK_TRIANGULATION_INTERNAL(getVertexStarNumber)(vertexId); } const std::vector> * - TTK_TRIANGULATION_INTERNAL(getVertexLinks)() final; + TTK_TRIANGULATION_INTERNAL(getVertexLinks)() override; const std::vector> * - TTK_TRIANGULATION_INTERNAL(getVertexNeighbors)() final; + TTK_TRIANGULATION_INTERNAL(getVertexNeighbors)() override; const std::vector> * - TTK_TRIANGULATION_INTERNAL(getVertexStars)() final; + TTK_TRIANGULATION_INTERNAL(getVertexStars)() override; const std::vector> * - getVertexTrianglesInternal() final; + getVertexTrianglesInternal() override; - inline bool isEmpty() const final { + inline bool isEmpty() const override { return !vertexNumber_; } inline bool TTK_TRIANGULATION_INTERNAL(isTriangleOnBoundary)( - const SimplexId &triangleId) const final { + const SimplexId &triangleId) const override { #ifdef TTK_ENABLE_MPI if(this->metaGrid_ != nullptr) { @@ -393,10 +395,10 @@ namespace ttk { const float &zSpacing, const SimplexId &xDim, const SimplexId &yDim, - const SimplexId &zDim) final; + const SimplexId &zDim) override; virtual int preconditionVerticesInternal() = 0; - int preconditionVertexNeighborsInternal() final; + int preconditionVertexNeighborsInternal() override; int preconditionEdgesInternal() override = 0; int preconditionTrianglesInternal() override = 0; virtual int preconditionTetrahedronsInternal() = 0; @@ -420,7 +422,8 @@ namespace ttk { return 0; } - inline int getCellVTKIDInternal(const int &ttkId, int &vtkId) const final { + inline int getCellVTKIDInternal(const int &ttkId, + int &vtkId) const override { #ifndef TTK_ENABLE_KAMIKAZE if(ttkId < 0) { return -1; @@ -434,11 +437,11 @@ namespace ttk { #ifdef TTK_ENABLE_MPI protected: - int preconditionDistributedCells() final; + int preconditionDistributedCells() override; public: - void createMetaGrid(const double *const bounds) final; - inline int getCellRankInternal(const SimplexId lcid) const final { + void createMetaGrid(const double *const bounds) override; + inline int getCellRankInternal(const SimplexId lcid) const override { const int nTetraPerCube{this->dimensionality_ == 3 ? 6 : 2}; const auto locCubeId{lcid / nTetraPerCube}; @@ -482,7 +485,7 @@ namespace ttk { protected: inline bool - isVertexOnGlobalBoundaryInternal(const SimplexId lvid) const final { + isVertexOnGlobalBoundaryInternal(const SimplexId lvid) const override { if(!ttk::isRunningWithMPI()) { // NOTE: perf killer @@ -507,7 +510,7 @@ namespace ttk { } inline bool - isEdgeOnGlobalBoundaryInternal(const SimplexId leid) const final { + isEdgeOnGlobalBoundaryInternal(const SimplexId leid) const override { if(!ttk::isRunningWithMPI()) { // NOTE: perf killer @@ -531,7 +534,7 @@ namespace ttk { } inline bool - isTriangleOnGlobalBoundaryInternal(const SimplexId ltid) const final { + isTriangleOnGlobalBoundaryInternal(const SimplexId ltid) const override { if(!ttk::isRunningWithMPI()) { // NOTE: perf killer @@ -556,7 +559,7 @@ namespace ttk { private: inline std::array - getVertGlobalCoords(const SimplexId lvid) const final { + getVertGlobalCoords(const SimplexId lvid) const override { // local vertex coordinates std::array p{}; @@ -575,7 +578,7 @@ namespace ttk { } inline std::array - getVertLocalCoords(const SimplexId gvid) const final { + getVertLocalCoords(const SimplexId gvid) const override { // global vertex coordinates std::array p{}; @@ -855,11 +858,12 @@ namespace ttk { //\cond // 2D // - void vertexToPosition2d(const SimplexId vertex, SimplexId p[2]) const final; + void vertexToPosition2d(const SimplexId vertex, + SimplexId p[2]) const override; void edgeToPosition2d(const SimplexId edge, const int k, SimplexId p[2]) const; void triangleToPosition2d(const SimplexId triangle, - SimplexId p[2]) const final; + SimplexId p[2]) const override; inline SimplexId getVertexEdge2dA(const SimplexId p[2], const int id) const; inline SimplexId getVertexEdge2dB(const SimplexId p[2], const int id) const; @@ -929,14 +933,15 @@ namespace ttk { inline SimplexId getEdgeStar2dH(const SimplexId p[2], const int id) const; // 3D // - void vertexToPosition(const SimplexId vertex, SimplexId p[3]) const final; + void vertexToPosition(const SimplexId vertex, + SimplexId p[3]) const override; void edgeToPosition(const SimplexId edge, const int k, SimplexId p[3]) const; void triangleToPosition(const SimplexId triangle, const int k, - SimplexId p[3]) const final; + SimplexId p[3]) const override; void tetrahedronToPosition(const SimplexId tetrahedron, - SimplexId p[3]) const final; + SimplexId p[3]) const override; inline SimplexId getVertexEdgeA(const SimplexId p[3], const int id) const; inline SimplexId getVertexEdgeB(const SimplexId p[3], const int id) const; @@ -1323,7 +1328,7 @@ namespace ttk { public: inline SimplexId TTK_TRIANGULATION_INTERNAL(getVertexNeighborNumber)( - const SimplexId &vertexId) const final { + const SimplexId &vertexId) const override { #ifndef TTK_ENABLE_KAMIKAZE if(vertexId < 0 or vertexId >= vertexNumber_) @@ -1385,7 +1390,7 @@ namespace ttk { } inline bool TTK_TRIANGULATION_INTERNAL(isVertexOnBoundary)( - const SimplexId &vertexId) const final { + const SimplexId &vertexId) const override { #ifdef TTK_ENABLE_MPI if(this->metaGrid_ != nullptr) { return this->isVertexOnGlobalBoundaryInternal(vertexId); @@ -1408,7 +1413,7 @@ namespace ttk { } inline bool TTK_TRIANGULATION_INTERNAL(isEdgeOnBoundary)( - const SimplexId &edgeId) const final { + const SimplexId &edgeId) const override { #ifdef TTK_ENABLE_MPI if(this->metaGrid_ != nullptr) { @@ -1442,7 +1447,7 @@ namespace ttk { inline int TTK_TRIANGULATION_INTERNAL(getVertexNeighbor)( const SimplexId &vertexId, const int &localNeighborId, - SimplexId &neighborId) const final { + SimplexId &neighborId) const override { #ifndef TTK_ENABLE_KAMIKAZE if(localNeighborId < 0 @@ -1579,7 +1584,7 @@ namespace ttk { inline int getVertexEdgeInternal(const SimplexId &vertexId, const int &localEdgeId, - SimplexId &edgeId) const final { + SimplexId &edgeId) const override { #ifndef TTK_ENABLE_KAMIKAZE if(localEdgeId < 0 @@ -1730,8 +1735,8 @@ namespace ttk { return 0; } - inline SimplexId - getVertexTriangleNumberInternal(const SimplexId &vertexId) const final { + inline SimplexId getVertexTriangleNumberInternal( + const SimplexId &vertexId) const override { #ifndef TTK_ENABLE_KAMIKAZE if(vertexId < 0 or vertexId >= vertexNumber_) @@ -1781,7 +1786,7 @@ namespace ttk { inline int getVertexTriangleInternal(const SimplexId &vertexId, const int &localTriangleId, - SimplexId &triangleId) const final { + SimplexId &triangleId) const override { #ifndef TTK_ENABLE_KAMIKAZE if(localTriangleId < 0 or localTriangleId >= getVertexTriangleNumberInternal(vertexId)) @@ -1880,10 +1885,10 @@ namespace ttk { return 0; } - inline int - TTK_TRIANGULATION_INTERNAL(getVertexLink)(const SimplexId &vertexId, - const int &localLinkId, - SimplexId &linkId) const final { + inline int TTK_TRIANGULATION_INTERNAL(getVertexLink)( + const SimplexId &vertexId, + const int &localLinkId, + SimplexId &linkId) const override { #ifndef TTK_ENABLE_KAMIKAZE if(localLinkId < 0 or localLinkId >= getVertexLinkNumber(vertexId)) @@ -2010,7 +2015,7 @@ namespace ttk { } inline SimplexId TTK_TRIANGULATION_INTERNAL(getVertexStarNumber)( - const SimplexId &vertexId) const final { + const SimplexId &vertexId) const override { #ifndef TTK_ENABLE_KAMIKAZE if(vertexId < 0 or vertexId >= vertexNumber_) @@ -2069,10 +2074,10 @@ namespace ttk { return 0; } - inline int - TTK_TRIANGULATION_INTERNAL(getVertexStar)(const SimplexId &vertexId, - const int &localStarId, - SimplexId &starId) const final { + inline int TTK_TRIANGULATION_INTERNAL(getVertexStar)( + const SimplexId &vertexId, + const int &localStarId, + SimplexId &starId) const override { #ifndef TTK_ENABLE_KAMIKAZE if(localStarId < 0 or localStarId >= getVertexStarNumber(vertexId)) @@ -2199,7 +2204,7 @@ namespace ttk { } inline int TTK_TRIANGULATION_INTERNAL(getVertexPoint)( - const SimplexId &vertexId, float &x, float &y, float &z) const final { + const SimplexId &vertexId, float &x, float &y, float &z) const override { if(dimensionality_ == 3) { const auto &p = this->underlying().getVertexCoords(vertexId); @@ -2243,7 +2248,7 @@ namespace ttk { inline int getEdgeVertexInternal(const SimplexId &edgeId, const int &localVertexId, - SimplexId &vertexId) const final { + SimplexId &vertexId) const override { #ifndef TTK_ENABLE_KAMIKAZE if(edgeId < 0 or edgeId >= edgeNumber_) @@ -2323,7 +2328,7 @@ namespace ttk { } inline SimplexId - getEdgeTriangleNumberInternal(const SimplexId &edgeId) const final { + getEdgeTriangleNumberInternal(const SimplexId &edgeId) const override { #ifndef TTK_ENABLE_KAMIKAZE if(edgeId < 0 or edgeId >= edgeNumber_) @@ -2390,7 +2395,7 @@ namespace ttk { inline int getEdgeTriangleInternal(const SimplexId &edgeId, const int &localTriangleId, - SimplexId &triangleId) const final { + SimplexId &triangleId) const override { #ifndef TTK_ENABLE_KAMIKAZE if(localTriangleId < 0 or localTriangleId >= getEdgeTriangleNumberInternal(edgeId)) @@ -2542,10 +2547,10 @@ namespace ttk { return 0; } - inline int - TTK_TRIANGULATION_INTERNAL(getEdgeLink)(const SimplexId &edgeId, - const int &localLinkId, - SimplexId &linkId) const final { + inline int TTK_TRIANGULATION_INTERNAL(getEdgeLink)( + const SimplexId &edgeId, + const int &localLinkId, + SimplexId &linkId) const override { #ifndef TTK_ENABLE_KAMIKAZE if(localLinkId < 0 or localLinkId >= getEdgeLinkNumber(edgeId)) @@ -2595,10 +2600,10 @@ namespace ttk { return 0; } - inline int - TTK_TRIANGULATION_INTERNAL(getEdgeStar)(const SimplexId &edgeId, - const int &localStarId, - SimplexId &starId) const final { + inline int TTK_TRIANGULATION_INTERNAL(getEdgeStar)( + const SimplexId &edgeId, + const int &localStarId, + SimplexId &starId) const override { #ifndef TTK_ENABLE_KAMIKAZE if(localStarId < 0 or localStarId >= getEdgeStarNumber(edgeId)) return -1; @@ -2649,7 +2654,7 @@ namespace ttk { } inline SimplexId TTK_TRIANGULATION_INTERNAL(getEdgeStarNumber)( - const SimplexId &edgeId) const final { + const SimplexId &edgeId) const override { #ifndef TTK_ENABLE_KAMIKAZE if(edgeId < 0 or edgeId >= edgeNumber_) @@ -2716,7 +2721,7 @@ namespace ttk { inline int getTriangleVertexInternal(const SimplexId &triangleId, const int &localVertexId, - SimplexId &vertexId) const final { + SimplexId &vertexId) const override { #ifndef TTK_ENABLE_KAMIKAZE if(triangleId < 0 or triangleId >= triangleNumber_) @@ -2797,7 +2802,7 @@ namespace ttk { inline int getTriangleEdgeInternal(const SimplexId &triangleId, const int &localEdgeId, - SimplexId &edgeId) const final { + SimplexId &edgeId) const override { #ifndef TTK_ENABLE_KAMIKAZE if(triangleId < 0 or triangleId >= triangleNumber_) @@ -2870,7 +2875,7 @@ namespace ttk { inline int TTK_TRIANGULATION_INTERNAL(getTriangleLink)( const SimplexId &triangleId, const int &localLinkId, - SimplexId &linkId) const final { + SimplexId &linkId) const override { #ifndef TTK_ENABLE_KAMIKAZE if(localLinkId < 0 or localLinkId >= getTriangleLinkNumber(triangleId)) @@ -2909,7 +2914,7 @@ namespace ttk { inline int TTK_TRIANGULATION_INTERNAL(getTriangleStar)( const SimplexId &triangleId, const int &localStarId, - SimplexId &starId) const final { + SimplexId &starId) const override { #ifndef TTK_ENABLE_KAMIKAZE if(localStarId < 0 or localStarId >= getTriangleStarNumber(triangleId)) @@ -2946,7 +2951,7 @@ namespace ttk { } inline SimplexId TTK_TRIANGULATION_INTERNAL(getTriangleStarNumber)( - const SimplexId &triangleId) const final { + const SimplexId &triangleId) const override { #ifndef TTK_ENABLE_KAMIKAZE if(triangleId < 0 or triangleId >= triangleNumber_) @@ -2975,7 +2980,7 @@ namespace ttk { inline int getTriangleNeighbor(const SimplexId &triangleId, const int &localNeighborId, - SimplexId &neighborId) const final { + SimplexId &neighborId) const override { #ifndef TTK_ENABLE_KAMIKAZE if(localNeighborId < 0 @@ -3064,7 +3069,7 @@ namespace ttk { } inline SimplexId - getTriangleNeighborNumber(const SimplexId &triangleId) const final { + getTriangleNeighborNumber(const SimplexId &triangleId) const override { #ifndef TTK_ENABLE_KAMIKAZE if(triangleId < 0 or triangleId >= triangleNumber_) @@ -3097,7 +3102,7 @@ namespace ttk { inline int getTetrahedronVertex(const SimplexId &tetId, const int &localVertexId, - SimplexId &vertexId) const final { + SimplexId &vertexId) const override { #ifndef TTK_ENABLE_KAMIKAZE if(tetId < 0 or tetId >= tetrahedronNumber_) @@ -3139,7 +3144,7 @@ namespace ttk { inline int getTetrahedronEdge(const SimplexId &tetId, const int &localEdgeId, - SimplexId &edgeId) const final { + SimplexId &edgeId) const override { #ifndef TTK_ENABLE_KAMIKAZE if(tetId < 0 or tetId >= tetrahedronNumber_) @@ -3182,7 +3187,7 @@ namespace ttk { inline int getTetrahedronTriangle(const SimplexId &tetId, const int &localTriangleId, - SimplexId &triangleId) const final { + SimplexId &triangleId) const override { #ifndef TTK_ENABLE_KAMIKAZE if(tetId < 0 or tetId >= tetrahedronNumber_) @@ -3224,7 +3229,7 @@ namespace ttk { } inline SimplexId - getTetrahedronNeighborNumber(const SimplexId &tetId) const final { + getTetrahedronNeighborNumber(const SimplexId &tetId) const override { #ifndef TTK_ENABLE_KAMIKAZE if(tetId < 0 or tetId >= tetrahedronNumber_) @@ -3293,7 +3298,7 @@ namespace ttk { inline int getTetrahedronNeighbor(const SimplexId &tetId, const int &localNeighborId, - SimplexId &neighborId) const final { + SimplexId &neighborId) const override { #ifndef TTK_ENABLE_KAMIKAZE if(localNeighborId < 0 From 1519d5726fdbb8b2170a87d93544dfcbb627d661 Mon Sep 17 00:00:00 2001 From: Julien Tierny Date: Thu, 28 Sep 2023 11:37:45 +0200 Subject: [PATCH 08/12] Revert "finished in-lining implicit triangulation" This reverts commit c8194d0de71db3cd34496893489eeac66d9d571a. --- .../implicitTriangulation/ImplicitTriangulation.cpp | 11 +++++++++++ .../implicitTriangulation/ImplicitTriangulation.h | 12 +----------- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/core/base/implicitTriangulation/ImplicitTriangulation.cpp b/core/base/implicitTriangulation/ImplicitTriangulation.cpp index 7c1dfc6ed1..373f25b844 100644 --- a/core/base/implicitTriangulation/ImplicitTriangulation.cpp +++ b/core/base/implicitTriangulation/ImplicitTriangulation.cpp @@ -461,6 +461,17 @@ const vector> * return &triangleStarList_; } +int ImplicitTriangulation::getTriangleNeighbors( + vector> &neighbors) { + neighbors.resize(triangleNumber_); + for(SimplexId i = 0; i < triangleNumber_; ++i) { + neighbors[i].resize(getTriangleNeighborNumber(i)); + for(SimplexId j = 0; j < (SimplexId)neighbors[i].size(); ++j) + getTriangleNeighbor(i, j, neighbors[i][j]); + } + return 0; +} + const vector> *ImplicitTriangulation::getCellEdgesInternal() { if(cellEdgeVector_.empty()) { Timer t; diff --git a/core/base/implicitTriangulation/ImplicitTriangulation.h b/core/base/implicitTriangulation/ImplicitTriangulation.h index 4e99041dc8..288c365b48 100644 --- a/core/base/implicitTriangulation/ImplicitTriangulation.h +++ b/core/base/implicitTriangulation/ImplicitTriangulation.h @@ -319,17 +319,7 @@ namespace ttk { virtual SimplexId getTriangleNeighborNumber(const SimplexId &triangleId) const = 0; - inline int - getTriangleNeighbors(std::vector> &neighbors) { - - neighbors.resize(triangleNumber_); - for(SimplexId i = 0; i < triangleNumber_; ++i) { - neighbors[i].resize(getTriangleNeighborNumber(i)); - for(SimplexId j = 0; j < (SimplexId)neighbors[i].size(); ++j) - getTriangleNeighbor(i, j, neighbors[i][j]); - } - return 0; - } + int getTriangleNeighbors(std::vector> &neighbors); const std::vector> * TTK_TRIANGULATION_INTERNAL(getTriangleStars)() override; From 1b27694bed70dec363db172f54d320b63fa7f197 Mon Sep 17 00:00:00 2001 From: Julien Tierny Date: Thu, 28 Sep 2023 11:37:52 +0200 Subject: [PATCH 09/12] Revert "removed TTK_FORCE_USE" This reverts commit 22097548d883b0e38c1b5d3cc41c76e113086717. --- core/base/implicitTriangulation/ImplicitTriangulation.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/core/base/implicitTriangulation/ImplicitTriangulation.h b/core/base/implicitTriangulation/ImplicitTriangulation.h index 288c365b48..a7bac3de3c 100644 --- a/core/base/implicitTriangulation/ImplicitTriangulation.h +++ b/core/base/implicitTriangulation/ImplicitTriangulation.h @@ -98,8 +98,9 @@ namespace ttk { } inline SimplexId - getCellEdgeNumberInternal(const SimplexId & /*cellId*/) const override { + getCellEdgeNumberInternal(const SimplexId &cellId) const override { + TTK_FORCE_USE(cellId); if(dimensionality_ == 3) return 6; else if(dimensionality_ == 2) @@ -181,8 +182,8 @@ namespace ttk { } inline SimplexId TTK_TRIANGULATION_INTERNAL(getCellVertexNumber)( - const SimplexId & /*cellId*/) const override { - + const SimplexId &cellId) const override { + TTK_FORCE_USE(cellId); return dimensionality_ + 1; } From 8c6efab58505cda3bea778747271b0528c388d09 Mon Sep 17 00:00:00 2001 From: Julien Tierny Date: Thu, 28 Sep 2023 11:37:53 +0200 Subject: [PATCH 10/12] Revert "further implicit in-lining" This reverts commit 0e4eee9b9cec77bbacb0d514f345857510539094. --- .../ImplicitTriangulation.cpp | 912 +++++++++ .../ImplicitTriangulation.h | 1643 ++++------------- 2 files changed, 1256 insertions(+), 1299 deletions(-) diff --git a/core/base/implicitTriangulation/ImplicitTriangulation.cpp b/core/base/implicitTriangulation/ImplicitTriangulation.cpp index 373f25b844..02e8394ad8 100644 --- a/core/base/implicitTriangulation/ImplicitTriangulation.cpp +++ b/core/base/implicitTriangulation/ImplicitTriangulation.cpp @@ -391,6 +391,172 @@ const vector> * return &edgeStarList_; } +template +int ImplicitTriangulationCRTP::getTriangleVertexInternal( + const SimplexId &triangleId, + const int &localVertexId, + SimplexId &vertexId) const { +#ifndef TTK_ENABLE_KAMIKAZE + if(triangleId < 0 or triangleId >= triangleNumber_) + return -1; + if(localVertexId < 0 or localVertexId >= 3) + return -2; +#endif + + // e--------f + // /| /| + // / | / | + // a--g-----b--h + // | / | / + // |/ |/ + // c--------d + // + // Classement des "Triangles" et dans cet ordre: + // F: face (type abc/bcd) + // C: cote (type abe/bef) + // H: haut (type acg/aeg) + // D1: diagonale1 (type bdg/beg) + // D2: diagonale2 (type abg/bgh) + // D3: diagonale3 (type bcg/bfg) + + const auto &p = this->underlying().getTriangleCoords(triangleId); + vertexId = -1; + + switch(this->underlying().getTrianglePosition(triangleId)) { + case TrianglePosition::F_3D: + vertexId = getTriangleVertexF(p.data(), localVertexId); + break; + case TrianglePosition::H_3D: + vertexId = getTriangleVertexH(p.data(), localVertexId); + break; + case TrianglePosition::C_3D: + vertexId = getTriangleVertexC(p.data(), localVertexId); + break; + case TrianglePosition::D1_3D: + vertexId = getTriangleVertexD1(p.data(), localVertexId); + break; + case TrianglePosition::D2_3D: + vertexId = getTriangleVertexD2(p.data(), localVertexId); + break; + case TrianglePosition::D3_3D: + vertexId = getTriangleVertexD3(p.data(), localVertexId); + break; + case TrianglePosition::TOP_2D: + switch(localVertexId) { + break; + case 0: + vertexId = p[0] / 2 + p[1] * vshift_[0]; + break; + case 1: + vertexId = p[0] / 2 + p[1] * vshift_[0] + 1; + break; + case 2: + vertexId = p[0] / 2 + p[1] * vshift_[0] + vshift_[0]; + break; + } + break; + case TrianglePosition::BOTTOM_2D: + switch(localVertexId) { + break; + case 0: + vertexId = p[0] / 2 + p[1] * vshift_[0] + 1; + break; + case 1: + vertexId = p[0] / 2 + p[1] * vshift_[0] + vshift_[0] + 1; + break; + case 2: + vertexId = p[0] / 2 + p[1] * vshift_[0] + vshift_[0]; + break; + } + } + + return 0; +} + +template +int ImplicitTriangulationCRTP::getTriangleEdgeInternal( + const SimplexId &triangleId, + const int &localEdgeId, + SimplexId &edgeId) const { +#ifndef TTK_ENABLE_KAMIKAZE + if(triangleId < 0 or triangleId >= triangleNumber_) + return -1; + if(localEdgeId < 0 or localEdgeId >= 3) + return -2; +#endif + + const auto &p = this->underlying().getTriangleCoords(triangleId); + const auto par = triangleId % 2; + edgeId = -1; + + switch(this->underlying().getTrianglePosition(triangleId)) { + case TrianglePosition::F_3D: + edgeId = (par == 1) ? getTriangleEdgeF_1(p.data(), localEdgeId) + : getTriangleEdgeF_0(p.data(), localEdgeId); + break; + case TrianglePosition::H_3D: + edgeId = (par == 1) ? getTriangleEdgeH_1(p.data(), localEdgeId) + : getTriangleEdgeH_0(p.data(), localEdgeId); + break; + case TrianglePosition::C_3D: + edgeId = (par == 1) ? getTriangleEdgeC_1(p.data(), localEdgeId) + : getTriangleEdgeC_0(p.data(), localEdgeId); + break; + case TrianglePosition::D1_3D: + edgeId = (par == 1) ? getTriangleEdgeD1_1(p.data(), localEdgeId) + : getTriangleEdgeD1_0(p.data(), localEdgeId); + break; + case TrianglePosition::D2_3D: + edgeId = (par == 1) ? getTriangleEdgeD2_1(p.data(), localEdgeId) + : getTriangleEdgeD2_0(p.data(), localEdgeId); + break; + case TrianglePosition::D3_3D: + edgeId = (par == 1) ? getTriangleEdgeD3_1(p.data(), localEdgeId) + : getTriangleEdgeD3_0(p.data(), localEdgeId); + break; + case TrianglePosition::TOP_2D: + switch(localEdgeId) { + break; + case 0: + edgeId = p[0] / 2 + p[1] * eshift_[0]; + break; + case 1: + edgeId = esetshift_[0] + p[0] / 2 + p[1] * eshift_[2]; + break; + case 2: + edgeId = esetshift_[1] + p[0] / 2 + p[1] * eshift_[4]; + break; + } + break; + case TrianglePosition::BOTTOM_2D: + switch(localEdgeId) { + break; + case 0: + edgeId = p[0] / 2 + (p[1] + 1) * eshift_[0]; + break; + case 1: + edgeId = esetshift_[0] + (p[0] + 1) / 2 + p[1] * eshift_[2]; + break; + case 2: + edgeId = esetshift_[1] + p[0] / 2 + p[1] * eshift_[4]; + break; + } + } + + return 0; +} + +int ImplicitTriangulation::getTriangleEdgesInternal( + vector> &edges) const { + edges.resize(triangleNumber_); + for(SimplexId i = 0; i < triangleNumber_; ++i) { + edges[i].resize(3); + for(int j = 0; j < 3; ++j) + getTriangleEdgeInternal(i, j, edges[i][j]); + } + return 0; +} + const vector> * ImplicitTriangulation::getTriangleEdgesInternal() { if(triangleEdgeVector_.empty()) { @@ -424,6 +590,51 @@ const vector> * return &triangleList_; } +template +int ImplicitTriangulationCRTP::TTK_TRIANGULATION_INTERNAL( + getTriangleLink)(const SimplexId &triangleId, + const int &localLinkId, + SimplexId &linkId) const { + +#ifndef TTK_ENABLE_KAMIKAZE + if(localLinkId < 0 or localLinkId >= getTriangleLinkNumber(triangleId)) + return -1; +#endif + + const auto &p = this->underlying().getTriangleCoords(triangleId); + + switch(this->underlying().getTrianglePosition(triangleId)) { + case TrianglePosition::F_3D: + linkId = getTriangleLinkF(p.data(), localLinkId); + break; + case TrianglePosition::H_3D: + linkId = getTriangleLinkH(p.data(), localLinkId); + break; + case TrianglePosition::C_3D: + linkId = getTriangleLinkC(p.data(), localLinkId); + break; + case TrianglePosition::D1_3D: + linkId = getTriangleLinkD1(p.data(), localLinkId); + break; + case TrianglePosition::D2_3D: + linkId = getTriangleLinkD2(p.data(), localLinkId); + break; + case TrianglePosition::D3_3D: + linkId = getTriangleLinkD3(p.data(), localLinkId); + break; + default: // 2D + linkId = -1; + break; + } + + return 0; +} + +SimplexId ImplicitTriangulation::TTK_TRIANGULATION_INTERNAL( + getTriangleLinkNumber)(const SimplexId &triangleId) const { + return TTK_TRIANGULATION_INTERNAL(getTriangleStarNumber)(triangleId); +} + const vector> * ImplicitTriangulation::TTK_TRIANGULATION_INTERNAL(getTriangleLinks)() { if(triangleLinkList_.empty()) { @@ -442,6 +653,75 @@ const vector> * return &triangleLinkList_; } +template +SimplexId ImplicitTriangulationCRTP::TTK_TRIANGULATION_INTERNAL( + getTriangleStarNumber)(const SimplexId &triangleId) const { + +#ifndef TTK_ENABLE_KAMIKAZE + if(triangleId < 0 or triangleId >= triangleNumber_) + return -1; +#endif + + const auto &p = this->underlying().getTriangleCoords(triangleId); + + switch(this->underlying().getTrianglePosition(triangleId)) { + case TrianglePosition::F_3D: + return (p[2] > 0 and p[2] < nbvoxels_[2]) ? 2 : 1; + case TrianglePosition::H_3D: + return (p[1] > 0 and p[1] < nbvoxels_[1]) ? 2 : 1; + case TrianglePosition::C_3D: + return (p[0] < 2 or p[0] >= (dimensions_[0] * 2 - 2)) ? 1 : 2; + + case TrianglePosition::D1_3D: + case TrianglePosition::D2_3D: + case TrianglePosition::D3_3D: + return 2; + default: // 2D + break; + } + return 0; +} + +template +int ImplicitTriangulationCRTP::TTK_TRIANGULATION_INTERNAL( + getTriangleStar)(const SimplexId &triangleId, + const int &localStarId, + SimplexId &starId) const { + +#ifndef TTK_ENABLE_KAMIKAZE + if(localStarId < 0 or localStarId >= getTriangleStarNumber(triangleId)) + return -1; +#endif + + const auto &p = this->underlying().getTriangleCoords(triangleId); + + switch(this->underlying().getTrianglePosition(triangleId)) { + case TrianglePosition::F_3D: + starId = getTriangleStarF(p.data(), localStarId); + break; + case TrianglePosition::H_3D: + starId = getTriangleStarH(p.data(), localStarId); + break; + case TrianglePosition::C_3D: + starId = getTriangleStarC(p.data(), localStarId); + break; + case TrianglePosition::D1_3D: + starId = getTriangleStarD1(p.data(), localStarId); + break; + case TrianglePosition::D2_3D: + starId = getTriangleStarD2(p.data(), localStarId); + break; + case TrianglePosition::D3_3D: + starId = getTriangleStarD3(p.data(), localStarId); + break; + default: // 2D + starId = -1; + break; + } + + return 0; +} + const vector> * ImplicitTriangulation::TTK_TRIANGULATION_INTERNAL(getTriangleStars)() { @@ -461,6 +741,129 @@ const vector> * return &triangleStarList_; } +template +SimplexId ImplicitTriangulationCRTP::getTriangleNeighborNumber( + const SimplexId &triangleId) const { +#ifndef TTK_ENABLE_KAMIKAZE + if(triangleId < 0 or triangleId >= triangleNumber_) + return -1; +#endif + + if(dimensionality_ == 2) { + const auto &p = this->underlying().getTriangleCoords(triangleId); + const SimplexId id = triangleId % 2; + + if(id) { + if(p[0] / 2 == nbvoxels_[Di_] - 1 and p[1] == nbvoxels_[Dj_] - 1) + return 1; + else if(p[0] / 2 == nbvoxels_[Di_] - 1 or p[1] == nbvoxels_[Dj_] - 1) + return 2; + else + return 3; + } else { + if(p[0] == 0 and p[1] == 0) + return 1; + else if(p[0] == 0 or p[1] == 0) + return 2; + else + return 3; + } + } + + return 0; +} + +template +int ImplicitTriangulationCRTP::getTriangleNeighbor( + const SimplexId &triangleId, + const int &localNeighborId, + SimplexId &neighborId) const { +#ifndef TTK_ENABLE_KAMIKAZE + if(localNeighborId < 0 + or localNeighborId >= getTriangleNeighborNumber(triangleId)) + return -1; +#endif + + neighborId = -1; + + if(dimensionality_ == 2) { + const auto &p = this->underlying().getTriangleCoords(triangleId); + const SimplexId id = triangleId % 2; + + if(id) { + if(p[0] / 2 == nbvoxels_[Di_] - 1 and p[1] == nbvoxels_[Dj_] - 1) + neighborId = triangleId - 1; + else if(p[0] / 2 == nbvoxels_[Di_] - 1) { + switch(localNeighborId) { + case 0: + neighborId = triangleId - 1; + break; + case 1: + neighborId = triangleId + tshift_[0] - 1; + break; + } + } else if(p[1] == nbvoxels_[Dj_] - 1) { + switch(localNeighborId) { + case 0: + neighborId = triangleId - 1; + break; + case 1: + neighborId = triangleId + 1; + break; + } + } else { + switch(localNeighborId) { + case 0: + neighborId = triangleId - 1; + break; + case 1: + neighborId = triangleId + 1; + break; + case 2: + neighborId = triangleId + tshift_[0] - 1; + break; + } + } + } else { + if(p[0] == 0 and p[1] == 0) + neighborId = triangleId + 1; + else if(p[0] == 0) { + switch(localNeighborId) { + case 0: + neighborId = triangleId + 1; + break; + case 1: + neighborId = triangleId - tshift_[0] + 1; + break; + } + } else if(p[1] == 0) { + switch(localNeighborId) { + case 0: + neighborId = triangleId + 1; + break; + case 1: + neighborId = triangleId - 1; + break; + } + } else { + switch(localNeighborId) { + case 0: + neighborId = triangleId + 1; + break; + case 1: + neighborId = triangleId - 1; + break; + case 2: + neighborId = triangleId - tshift_[0] + 1; + break; + } + } + } + } + + return 0; +} + int ImplicitTriangulation::getTriangleNeighbors( vector> &neighbors) { neighbors.resize(triangleNumber_); @@ -472,6 +875,323 @@ int ImplicitTriangulation::getTriangleNeighbors( return 0; } +template +int ImplicitTriangulationCRTP::getTetrahedronVertex( + const SimplexId &tetId, const int &localVertexId, SimplexId &vertexId) const { +#ifndef TTK_ENABLE_KAMIKAZE + if(tetId < 0 or tetId >= tetrahedronNumber_) + return -1; + if(localVertexId < 0 or localVertexId >= 4) + return -2; +#endif + + vertexId = -1; + + if(dimensionality_ == 3) { + const SimplexId id = tetId % 6; + const auto &c = this->underlying().getTetrahedronCoords(tetId); + const auto p{c.data()}; + + switch(id) { + case 0: + vertexId = getTetrahedronVertexABCG(p, localVertexId); + break; + case 1: + vertexId = getTetrahedronVertexBCDG(p, localVertexId); + break; + case 2: + vertexId = getTetrahedronVertexABEG(p, localVertexId); + break; + case 3: + vertexId = getTetrahedronVertexBEFG(p, localVertexId); + break; + case 4: + vertexId = getTetrahedronVertexBFGH(p, localVertexId); + break; + case 5: + vertexId = getTetrahedronVertexBDGH(p, localVertexId); + break; + } + } + return 0; +} + +template +int ImplicitTriangulationCRTP::getTetrahedronEdge( + const SimplexId &tetId, const int &localEdgeId, SimplexId &edgeId) const { +#ifndef TTK_ENABLE_KAMIKAZE + if(tetId < 0 or tetId >= tetrahedronNumber_) + return -1; + if(localEdgeId < 0 or localEdgeId >= 6) + return -2; +#endif + + edgeId = -1; + + if(dimensionality_ == 3) { + const SimplexId id = tetId % 6; + const auto &c = this->underlying().getTetrahedronCoords(tetId); + const auto p{c.data()}; + + switch(id) { + case 0: + edgeId = getTetrahedronEdgeABCG(p, localEdgeId); + break; + case 1: + edgeId = getTetrahedronEdgeBCDG(p, localEdgeId); + break; + case 2: + edgeId = getTetrahedronEdgeABEG(p, localEdgeId); + break; + case 3: + edgeId = getTetrahedronEdgeBEFG(p, localEdgeId); + break; + case 4: + edgeId = getTetrahedronEdgeBFGH(p, localEdgeId); + break; + case 5: + edgeId = getTetrahedronEdgeBDGH(p, localEdgeId); + break; + } + } + + return 0; +} + +int ImplicitTriangulation::getTetrahedronEdges( + vector> &edges) const { + edges.resize(tetrahedronNumber_); + for(SimplexId i = 0; i < tetrahedronNumber_; ++i) { + edges[i].resize(6); + for(int j = 0; j < 6; ++j) + getTetrahedronEdge(i, j, edges[i][j]); + } + + return 0; +} + +template +int ImplicitTriangulationCRTP::getTetrahedronTriangle( + const SimplexId &tetId, + const int &localTriangleId, + SimplexId &triangleId) const { +#ifndef TTK_ENABLE_KAMIKAZE + if(tetId < 0 or tetId >= tetrahedronNumber_) + return -1; + if(localTriangleId < 0 or localTriangleId >= 4) + return -2; +#endif + + triangleId = -1; + + if(dimensionality_ == 3) { + const SimplexId id = tetId % 6; + const auto &c = this->underlying().getTetrahedronCoords(tetId); + const auto p{c.data()}; + + switch(id) { + case 0: + triangleId = getTetrahedronTriangleABCG(p, localTriangleId); + break; + case 1: + triangleId = getTetrahedronTriangleBCDG(p, localTriangleId); + break; + case 2: + triangleId = getTetrahedronTriangleABEG(p, localTriangleId); + break; + case 3: + triangleId = getTetrahedronTriangleBEFG(p, localTriangleId); + break; + case 4: + triangleId = getTetrahedronTriangleBFGH(p, localTriangleId); + break; + case 5: + triangleId = getTetrahedronTriangleBDGH(p, localTriangleId); + break; + } + } + + return 0; +} + +int ImplicitTriangulation::getTetrahedronTriangles( + vector> &triangles) const { + triangles.resize(tetrahedronNumber_); + for(SimplexId i = 0; i < tetrahedronNumber_; ++i) { + triangles[i].resize(4); + for(int j = 0; j < 4; ++j) + getTetrahedronTriangle(i, j, triangles[i][j]); + } + + return 0; +} + +template +SimplexId ImplicitTriangulationCRTP::getTetrahedronNeighborNumber( + const SimplexId &tetId) const { +#ifndef TTK_ENABLE_KAMIKAZE + if(tetId < 0 or tetId >= tetrahedronNumber_) + return -1; +#endif + + if(dimensionality_ == 3) { + const SimplexId id = tetId % 6; + const auto &c = this->underlying().getTetrahedronCoords(tetId); + const auto p{c.data()}; + + switch(id) { + case 0: // ABCG + if(p[0] == 0 and p[2] == 0) + return 2; + else if(p[0] == 0 or p[2] == 0) + return 3; + else + return 4; + break; + case 1: // BCDG + if(p[1] == nbvoxels_[1] - 1 and p[2] == 0) + return 2; + else if(p[1] == nbvoxels_[1] - 1 or p[2] == 0) + return 3; + else + return 4; + break; + case 2: // ABEG + if(p[0] == 0 and p[1] == 0) + return 2; + else if(p[0] == 0 or p[1] == 0) + return 3; + else + return 4; + break; + case 3: // BEFG + if(p[1] == 0 and p[2] == nbvoxels_[2] - 1) + return 2; + else if(p[1] == 0 or p[2] == nbvoxels_[2] - 1) + return 3; + else + return 4; + break; + case 4: // BFGH + if(p[0] == nbvoxels_[0] - 1 and p[2] == nbvoxels_[2] - 1) + return 2; + else if(p[0] == nbvoxels_[0] - 1 or p[2] == nbvoxels_[2] - 1) + return 3; + else + return 4; + break; + case 5: // BDGH + if(p[0] == nbvoxels_[0] - 1 and p[1] == nbvoxels_[1] - 1) + return 2; + else if(p[0] == nbvoxels_[0] - 1 or p[1] == nbvoxels_[1] - 1) + return 3; + else + return 4; + break; + } + } + + return 0; +} + +template +int ImplicitTriangulationCRTP::getTetrahedronNeighbor( + const SimplexId &tetId, + const int &localNeighborId, + SimplexId &neighborId) const { +#ifndef TTK_ENABLE_KAMIKAZE + if(localNeighborId < 0 + or localNeighborId >= getTetrahedronNeighborNumber(tetId)) + return -1; +#endif + + neighborId = -1; + + if(dimensionality_ == 3) { + const SimplexId id = tetId % 6; + const auto &c = this->underlying().getTetrahedronCoords(tetId); + const auto p{c.data()}; + + switch(id) { + case 0: + neighborId = getTetrahedronNeighborABCG(tetId, p, localNeighborId); + break; + case 1: + neighborId = getTetrahedronNeighborBCDG(tetId, p, localNeighborId); + break; + case 2: + neighborId = getTetrahedronNeighborABEG(tetId, p, localNeighborId); + break; + case 3: + neighborId = getTetrahedronNeighborBEFG(tetId, p, localNeighborId); + break; + case 4: + neighborId = getTetrahedronNeighborBFGH(tetId, p, localNeighborId); + break; + case 5: + neighborId = getTetrahedronNeighborBDGH(tetId, p, localNeighborId); + break; + } + } + + return 0; +} + +int ImplicitTriangulation::getTetrahedronNeighbors( + vector> &neighbors) { + neighbors.resize(tetrahedronNumber_); + for(SimplexId i = 0; i < tetrahedronNumber_; ++i) { + neighbors[i].resize(getTetrahedronNeighborNumber(i)); + for(SimplexId j = 0; j < (SimplexId)neighbors[i].size(); ++j) + getTetrahedronNeighbor(i, j, neighbors[i][j]); + } + + return 0; +} + +SimplexId ImplicitTriangulation::TTK_TRIANGULATION_INTERNAL( + getCellVertexNumber)(const SimplexId & /*cellId*/) const { + return dimensionality_ + 1; +} + +int ImplicitTriangulation::TTK_TRIANGULATION_INTERNAL(getCellVertex)( + const SimplexId &cellId, + const int &localVertexId, + SimplexId &vertexId) const { + + if(dimensionality_ == 3) + getTetrahedronVertex(cellId, localVertexId, vertexId); + else if(dimensionality_ == 2) + getTriangleVertexInternal(cellId, localVertexId, vertexId); + else if(dimensionality_ == 1) + getEdgeVertexInternal(cellId, localVertexId, vertexId); + + return 0; +} + +SimplexId ImplicitTriangulation::getCellEdgeNumberInternal( + const SimplexId & /*cellId*/) const { + if(dimensionality_ == 3) + return 6; + else if(dimensionality_ == 2) + return 3; + + return 0; +} + +int ImplicitTriangulation::getCellEdgeInternal(const SimplexId &cellId, + const int &localEdgeId, + SimplexId &edgeId) const { + if(dimensionality_ == 3) + getTetrahedronEdge(cellId, localEdgeId, edgeId); + else if(dimensionality_ == 2) + getTriangleEdgeInternal(cellId, localEdgeId, edgeId); + else if(dimensionality_ == 1) + getCellNeighbor(cellId, localEdgeId, edgeId); + + return 0; +} + const vector> *ImplicitTriangulation::getCellEdgesInternal() { if(cellEdgeVector_.empty()) { Timer t; @@ -488,6 +1208,16 @@ const vector> *ImplicitTriangulation::getCellEdgesInternal() { return &cellEdgeVector_; } +int ImplicitTriangulation::getCellTriangleInternal( + const SimplexId &cellId, + const int &localTriangleId, + SimplexId &triangleId) const { + if(dimensionality_ == 3) + getTetrahedronTriangle(cellId, localTriangleId, triangleId); + + return 0; +} + const vector> * ImplicitTriangulation::getCellTrianglesInternal() { if(cellTriangleVector_.empty()) { @@ -503,6 +1233,36 @@ const vector> * return &cellTriangleVector_; } +SimplexId ImplicitTriangulation::TTK_TRIANGULATION_INTERNAL( + getCellNeighborNumber)(const SimplexId &cellId) const { + if(dimensionality_ == 3) + return getTetrahedronNeighborNumber(cellId); + else if(dimensionality_ == 2) + return getTriangleNeighborNumber(cellId); + else if(dimensionality_ == 1) { + printErr("getCellNeighborNumber() not implemented in 1D! (TODO)"); + return -1; + } + + return 0; +} + +int ImplicitTriangulation::TTK_TRIANGULATION_INTERNAL(getCellNeighbor)( + const SimplexId &cellId, + const int &localNeighborId, + SimplexId &neighborId) const { + if(dimensionality_ == 3) + getTetrahedronNeighbor(cellId, localNeighborId, neighborId); + else if(dimensionality_ == 2) + getTriangleNeighbor(cellId, localNeighborId, neighborId); + else if(dimensionality_ == 1) { + printErr("getCellNeighbor() not implemented in 1D! (TODO)"); + return -1; + } + + return 0; +} + const vector> * ImplicitTriangulation::TTK_TRIANGULATION_INTERNAL(getCellNeighbors)() { if(cellNeighborList_.empty()) { @@ -1038,6 +1798,158 @@ void ttk::ImplicitTriangulation::createMetaGrid(const double *const bounds) { this->metaGrid_->preconditionBoundaryTriangles(); } +std::array + ttk::ImplicitTriangulation::getVertGlobalCoords(const SimplexId lvid) const { + + // local vertex coordinates + std::array p{}; + if(this->dimensionality_ == 3) { + this->vertexToPosition(lvid, p.data()); + } else if(this->dimensionality_ == 2) { + this->vertexToPosition2d(lvid, p.data()); + } + + // global vertex coordinates + p[0] += this->localGridOffset_[0]; + p[1] += this->localGridOffset_[1]; + p[2] += this->localGridOffset_[2]; + + return p; +} + +std::array + ttk::ImplicitTriangulation::getVertLocalCoords(const SimplexId gvid) const { + + // global vertex coordinates + std::array p{}; + if(this->dimensionality_ == 3) { + this->metaGrid_->vertexToPosition(gvid, p.data()); + } else if(this->dimensionality_ == 2) { + this->metaGrid_->vertexToPosition2d(gvid, p.data()); + } + + // local vertex coordinates + p[0] -= this->localGridOffset_[0]; + p[1] -= this->localGridOffset_[1]; + p[2] -= this->localGridOffset_[2]; + + return p; +} + +bool ImplicitTriangulation::isVertexOnGlobalBoundaryInternal( + const SimplexId lvid) const { + + if(!ttk::isRunningWithMPI()) { + return this->isVertexOnBoundary(lvid); + } + +#ifndef TTK_ENABLE_KAMIKAZE + if(lvid > this->TTK_TRIANGULATION_INTERNAL(getNumberOfVertices)() - 1 + || lvid < 0) { + return false; + } + if(this->metaGrid_ == nullptr) { + return false; + } +#endif // TTK_ENABLE_KAMIKAZE + + const auto gvid{this->getVertexGlobalIdInternal(lvid)}; + if(gvid == -1) { + return false; + } + return this->metaGrid_->isVertexOnBoundary(gvid); +} + +bool ImplicitTriangulation::isEdgeOnGlobalBoundaryInternal( + const SimplexId leid) const { + + if(!ttk::isRunningWithMPI()) { + return this->isEdgeOnBoundary(leid); + } + +#ifndef TTK_ENABLE_KAMIKAZE + if(leid > this->getNumberOfEdgesInternal() - 1 || leid < 0) { + return false; + } + if(this->metaGrid_ == nullptr) { + return false; + } +#endif // TTK_ENABLE_KAMIKAZE + + const auto geid{this->getEdgeGlobalIdInternal(leid)}; + if(geid == -1) { + return false; + } + return this->metaGrid_->isEdgeOnBoundary(geid); +} + +bool ImplicitTriangulation::isTriangleOnGlobalBoundaryInternal( + const SimplexId ltid) const { + + if(!ttk::isRunningWithMPI()) { + return this->isTriangleOnBoundary(ltid); + } + +#ifndef TTK_ENABLE_KAMIKAZE + if(ltid > this->getNumberOfTrianglesInternal() - 1 || ltid < 0) { + return false; + } + if(this->metaGrid_ == nullptr) { + return false; + } +#endif // TTK_ENABLE_KAMIKAZE + + const auto gtid{this->getTriangleGlobalIdInternal(ltid)}; + if(gtid == -1) { + return false; + } + return this->metaGrid_->isTriangleOnBoundary(gtid); +} + +int ttk::ImplicitTriangulation::getCellRankInternal( + const SimplexId lcid) const { + + const int nTetraPerCube{this->dimensionality_ == 3 ? 6 : 2}; + const auto locCubeId{lcid / nTetraPerCube}; + + if(this->cellGhost_[locCubeId] == 0) { + return ttk::MPIrank_; + } + +#ifndef TTK_ENABLE_KAMIKAZE + if(this->neighborRanks_.empty() && ttk::MPIsize_ > 1) { + this->printErr("Empty neighborsRanks_!"); + return -1; + } +#endif // TTK_ENABLE_KAMIKAZE + + const auto nVertsCell{this->getCellVertexNumber(lcid)}; + std::vector inRank(nVertsCell); + for(const auto neigh : this->neighborRanks_) { + std::fill(inRank.begin(), inRank.end(), false); + const auto &bbox{this->neighborCellBBoxes_[neigh]}; + for(SimplexId i = 0; i < nVertsCell; ++i) { + SimplexId v{}; + this->getCellVertex(lcid, i, v); + if(this->vertexGhost_[v] == 0) { + inRank[i] = true; + } else { + const auto p{this->getVertGlobalCoords(v)}; + if(p[0] >= bbox[0] && p[0] <= bbox[1] && p[1] >= bbox[2] + && p[1] <= bbox[3] && p[2] >= bbox[4] && p[2] <= bbox[5]) { + inRank[i] = true; + } + } + } + if(std::all_of( + inRank.begin(), inRank.end(), [](const bool v) { return v; })) { + return neigh; + } + } + + return -1; +} + #endif // TTK_ENABLE_MPI // explicit instantiations diff --git a/core/base/implicitTriangulation/ImplicitTriangulation.h b/core/base/implicitTriangulation/ImplicitTriangulation.h index a7bac3de3c..370315bb93 100644 --- a/core/base/implicitTriangulation/ImplicitTriangulation.h +++ b/core/base/implicitTriangulation/ImplicitTriangulation.h @@ -83,78 +83,28 @@ namespace ttk { return this->dimensions_; } - inline int getCellEdgeInternal(const SimplexId &cellId, - const int &localEdgeId, - SimplexId &edgeId) const override { + int getCellEdgeInternal(const SimplexId &cellId, + const int &id, + SimplexId &edgeId) const override; - if(dimensionality_ == 3) - getTetrahedronEdge(cellId, localEdgeId, edgeId); - else if(dimensionality_ == 2) - getTriangleEdgeInternal(cellId, localEdgeId, edgeId); - else if(dimensionality_ == 1) - getCellNeighbor(cellId, localEdgeId, edgeId); - - return 0; - } - - inline SimplexId - getCellEdgeNumberInternal(const SimplexId &cellId) const override { - - TTK_FORCE_USE(cellId); - if(dimensionality_ == 3) - return 6; - else if(dimensionality_ == 2) - return 3; - - return 0; - } + SimplexId getCellEdgeNumberInternal(const SimplexId &cellId) const override; const std::vector> *getCellEdgesInternal() override; - inline int TTK_TRIANGULATION_INTERNAL(getCellNeighbor)( + int TTK_TRIANGULATION_INTERNAL(getCellNeighbor)( const SimplexId &cellId, const int &localNeighborId, - SimplexId &neighborId) const override { + SimplexId &neighborId) const override; - if(dimensionality_ == 3) - getTetrahedronNeighbor(cellId, localNeighborId, neighborId); - else if(dimensionality_ == 2) - getTriangleNeighbor(cellId, localNeighborId, neighborId); - else if(dimensionality_ == 1) { - printErr("getCellNeighbor() not implemented in 1D! (TODO)"); - return -1; - } - - return 0; - } - - inline SimplexId TTK_TRIANGULATION_INTERNAL(getCellNeighborNumber)( - const SimplexId &cellId) const override { - - if(dimensionality_ == 3) - return getTetrahedronNeighborNumber(cellId); - else if(dimensionality_ == 2) - return getTriangleNeighborNumber(cellId); - else if(dimensionality_ == 1) { - printErr("getCellNeighborNumber() not implemented in 1D! (TODO)"); - return -1; - } - - return 0; - } + SimplexId TTK_TRIANGULATION_INTERNAL(getCellNeighborNumber)( + const SimplexId &cellId) const override; const std::vector> * TTK_TRIANGULATION_INTERNAL(getCellNeighbors)() override; - inline int getCellTriangleInternal(const SimplexId &cellId, - const int &localTriangleId, - SimplexId &triangleId) const override { - - if(dimensionality_ == 3) - getTetrahedronTriangle(cellId, localTriangleId, triangleId); - - return 0; - } + int getCellTriangleInternal(const SimplexId &cellId, + const int &id, + SimplexId &triangleId) const override; SimplexId getCellTriangleNumberInternal( const SimplexId & /*cellId*/) const override { @@ -166,26 +116,13 @@ namespace ttk { const std::vector> * getCellTrianglesInternal() override; - inline int TTK_TRIANGULATION_INTERNAL(getCellVertex)( + int TTK_TRIANGULATION_INTERNAL(getCellVertex)( const SimplexId &cellId, const int &localVertexId, - SimplexId &vertexId) const override { + SimplexId &vertexId) const override; - if(dimensionality_ == 3) - getTetrahedronVertex(cellId, localVertexId, vertexId); - else if(dimensionality_ == 2) - getTriangleVertexInternal(cellId, localVertexId, vertexId); - else if(dimensionality_ == 1) - getEdgeVertexInternal(cellId, localVertexId, vertexId); - - return 0; - } - - inline SimplexId TTK_TRIANGULATION_INTERNAL(getCellVertexNumber)( - const SimplexId &cellId) const override { - TTK_FORCE_USE(cellId); - return dimensionality_ + 1; - } + SimplexId TTK_TRIANGULATION_INTERNAL(getCellVertexNumber)( + const SimplexId &cellId) const override; int TTK_TRIANGULATION_INTERNAL(getDimensionality)() const override { return dimensionality_; @@ -229,34 +166,14 @@ namespace ttk { const int &id, SimplexId &edgeId) const = 0; - inline int - getTetrahedronEdges(std::vector> &edges) const { - edges.resize(tetrahedronNumber_); - for(SimplexId i = 0; i < tetrahedronNumber_; ++i) { - edges[i].resize(6); - for(int j = 0; j < 6; ++j) - getTetrahedronEdge(i, j, edges[i][j]); - } - - return 0; - } + int getTetrahedronEdges(std::vector> &edges) const; virtual int getTetrahedronTriangle(const SimplexId &tetId, const int &id, SimplexId &triangleId) const = 0; - inline int getTetrahedronTriangles( - std::vector> &triangles) const { - - triangles.resize(tetrahedronNumber_); - for(SimplexId i = 0; i < tetrahedronNumber_; ++i) { - triangles[i].resize(4); - for(int j = 0; j < 4; ++j) - getTetrahedronTriangle(i, j, triangles[i][j]); - } - - return 0; - } + int getTetrahedronTriangles( + std::vector> &triangles) const; virtual int getTetrahedronNeighbor(const SimplexId &tetId, const int &localNeighborId, @@ -265,18 +182,7 @@ namespace ttk { virtual SimplexId getTetrahedronNeighborNumber(const SimplexId &tetId) const = 0; - inline int - getTetrahedronNeighbors(std::vector> &neighbors) { - - neighbors.resize(tetrahedronNumber_); - for(SimplexId i = 0; i < tetrahedronNumber_; ++i) { - neighbors[i].resize(getTetrahedronNeighborNumber(i)); - for(SimplexId j = 0; j < (SimplexId)neighbors[i].size(); ++j) - getTetrahedronNeighbor(i, j, neighbors[i][j]); - } - - return 0; - } + int getTetrahedronNeighbors(std::vector> &neighbors); virtual int getTetrahedronVertex(const SimplexId &tetId, const int &localVertexId, @@ -292,23 +198,11 @@ namespace ttk { const std::vector> * getTriangleEdgesInternal() override; - inline int getTriangleEdgesInternal( - std::vector> &edges) const { + int getTriangleEdgesInternal( + std::vector> &edges) const; - edges.resize(triangleNumber_); - for(SimplexId i = 0; i < triangleNumber_; ++i) { - edges[i].resize(3); - for(int j = 0; j < 3; ++j) - getTriangleEdgeInternal(i, j, edges[i][j]); - } - return 0; - } - - inline SimplexId TTK_TRIANGULATION_INTERNAL(getTriangleLinkNumber)( - const SimplexId &triangleId) const override { - - return TTK_TRIANGULATION_INTERNAL(getTriangleStarNumber)(triangleId); - } + SimplexId TTK_TRIANGULATION_INTERNAL(getTriangleLinkNumber)( + const SimplexId &triangleId) const override; const std::vector> * TTK_TRIANGULATION_INTERNAL(getTriangleLinks)() override; @@ -432,160 +326,19 @@ namespace ttk { public: void createMetaGrid(const double *const bounds) override; - inline int getCellRankInternal(const SimplexId lcid) const override { - const int nTetraPerCube{this->dimensionality_ == 3 ? 6 : 2}; - const auto locCubeId{lcid / nTetraPerCube}; - - if(this->cellGhost_[locCubeId] == 0) { - return ttk::MPIrank_; - } - -#ifndef TTK_ENABLE_KAMIKAZE - if(this->neighborRanks_.empty() && ttk::MPIsize_ > 1) { - this->printErr("Empty neighborsRanks_!"); - return -1; - } -#endif // TTK_ENABLE_KAMIKAZE - - const auto nVertsCell{this->getCellVertexNumber(lcid)}; - std::vector inRank(nVertsCell); - for(const auto neigh : this->neighborRanks_) { - std::fill(inRank.begin(), inRank.end(), false); - const auto &bbox{this->neighborCellBBoxes_[neigh]}; - for(SimplexId i = 0; i < nVertsCell; ++i) { - SimplexId v{}; - this->getCellVertex(lcid, i, v); - if(this->vertexGhost_[v] == 0) { - inRank[i] = true; - } else { - const auto p{this->getVertGlobalCoords(v)}; - if(p[0] >= bbox[0] && p[0] <= bbox[1] && p[1] >= bbox[2] - && p[1] <= bbox[3] && p[2] >= bbox[4] && p[2] <= bbox[5]) { - inRank[i] = true; - } - } - } - if(std::all_of( - inRank.begin(), inRank.end(), [](const bool v) { return v; })) { - return neigh; - } - } - - return -1; - } + int getCellRankInternal(const SimplexId lcid) const override; protected: - inline bool - isVertexOnGlobalBoundaryInternal(const SimplexId lvid) const override { - - if(!ttk::isRunningWithMPI()) { - // NOTE: perf killer - return this->isVertexOnBoundary(lvid); - } - -#ifndef TTK_ENABLE_KAMIKAZE - if(lvid > this->TTK_TRIANGULATION_INTERNAL(getNumberOfVertices)() - 1 - || lvid < 0) { - return false; - } - if(this->metaGrid_ == nullptr) { - return false; - } -#endif // TTK_ENABLE_KAMIKAZE - - const auto gvid{this->getVertexGlobalIdInternal(lvid)}; - if(gvid == -1) { - return false; - } - return this->metaGrid_->isVertexOnBoundary(gvid); - } - - inline bool - isEdgeOnGlobalBoundaryInternal(const SimplexId leid) const override { - - if(!ttk::isRunningWithMPI()) { - // NOTE: perf killer - return this->isEdgeOnBoundary(leid); - } - -#ifndef TTK_ENABLE_KAMIKAZE - if(leid > this->getNumberOfEdgesInternal() - 1 || leid < 0) { - return false; - } - if(this->metaGrid_ == nullptr) { - return false; - } -#endif // TTK_ENABLE_KAMIKAZE - - const auto geid{this->getEdgeGlobalIdInternal(leid)}; - if(geid == -1) { - return false; - } - return this->metaGrid_->isEdgeOnBoundary(geid); - } - - inline bool - isTriangleOnGlobalBoundaryInternal(const SimplexId ltid) const override { - - if(!ttk::isRunningWithMPI()) { - // NOTE: perf killer - return this->isTriangleOnBoundary(ltid); - } - -#ifndef TTK_ENABLE_KAMIKAZE - if(ltid > this->getNumberOfTrianglesInternal() - 1 || ltid < 0) { - return false; - } - if(this->metaGrid_ == nullptr) { - return false; - } -#endif // TTK_ENABLE_KAMIKAZE - - const auto gtid{this->getTriangleGlobalIdInternal(ltid)}; - if(gtid == -1) { - return false; - } - return this->metaGrid_->isTriangleOnBoundary(gtid); - } + bool isVertexOnGlobalBoundaryInternal(const SimplexId lvid) const override; + bool isEdgeOnGlobalBoundaryInternal(const SimplexId leid) const override; + bool + isTriangleOnGlobalBoundaryInternal(const SimplexId ltid) const override; private: - inline std::array - getVertGlobalCoords(const SimplexId lvid) const override { - - // local vertex coordinates - std::array p{}; - if(this->dimensionality_ == 3) { - this->vertexToPosition(lvid, p.data()); - } else if(this->dimensionality_ == 2) { - this->vertexToPosition2d(lvid, p.data()); - } - - // global vertex coordinates - p[0] += this->localGridOffset_[0]; - p[1] += this->localGridOffset_[1]; - p[2] += this->localGridOffset_[2]; - - return p; - } - - inline std::array - getVertLocalCoords(const SimplexId gvid) const override { - - // global vertex coordinates - std::array p{}; - if(this->dimensionality_ == 3) { - this->metaGrid_->vertexToPosition(gvid, p.data()); - } else if(this->dimensionality_ == 2) { - this->metaGrid_->vertexToPosition2d(gvid, p.data()); - } - - // local vertex coordinates - p[0] -= this->localGridOffset_[0]; - p[1] -= this->localGridOffset_[1]; - p[2] -= this->localGridOffset_[2]; - - return p; - } + std::array + getVertGlobalCoords(const SimplexId lvid) const override; + std::array + getVertLocalCoords(const SimplexId gvid) const override; #endif // TTK_ENABLE_MPI @@ -856,72 +609,50 @@ namespace ttk { void triangleToPosition2d(const SimplexId triangle, SimplexId p[2]) const override; - inline SimplexId getVertexEdge2dA(const SimplexId p[2], const int id) const; - inline SimplexId getVertexEdge2dB(const SimplexId p[2], const int id) const; - inline SimplexId getVertexEdge2dC(const SimplexId p[2], const int id) const; - inline SimplexId getVertexEdge2dD(const SimplexId p[2], const int id) const; - inline SimplexId getVertexEdge2dAB(const SimplexId p[2], - const int id) const; - inline SimplexId getVertexEdge2dCD(const SimplexId p[2], - const int id) const; - inline SimplexId getVertexEdge2dAC(const SimplexId p[2], - const int id) const; - inline SimplexId getVertexEdge2dBD(const SimplexId p[2], - const int id) const; - inline SimplexId getVertexEdge2dABCD(const SimplexId p[2], - const int id) const; - - inline SimplexId getVertexStar2dA(const SimplexId p[2], const int id) const; - inline SimplexId getVertexStar2dB(const SimplexId p[2], const int id) const; - inline SimplexId getVertexStar2dC(const SimplexId p[2], const int id) const; - inline SimplexId getVertexStar2dD(const SimplexId p[2], const int id) const; - inline SimplexId getVertexStar2dAB(const SimplexId p[2], - const int id) const; - inline SimplexId getVertexStar2dCD(const SimplexId p[2], - const int id) const; - inline SimplexId getVertexStar2dAC(const SimplexId p[2], - const int id) const; - inline SimplexId getVertexStar2dBD(const SimplexId p[2], - const int id) const; - inline SimplexId getVertexStar2dABCD(const SimplexId p[2], - const int id) const; - - inline SimplexId getVertexLink2dA(const SimplexId p[2], const int id) const; - inline SimplexId getVertexLink2dB(const SimplexId p[2], const int id) const; - inline SimplexId getVertexLink2dC(const SimplexId p[2], const int id) const; - inline SimplexId getVertexLink2dD(const SimplexId p[2], const int id) const; - inline SimplexId getVertexLink2dAB(const SimplexId p[2], - const int id) const; - inline SimplexId getVertexLink2dCD(const SimplexId p[2], - const int id) const; - inline SimplexId getVertexLink2dAC(const SimplexId p[2], - const int id) const; - inline SimplexId getVertexLink2dBD(const SimplexId p[2], - const int id) const; - inline SimplexId getVertexLink2dABCD(const SimplexId p[2], - const int id) const; - - inline SimplexId getEdgeTriangleL_x0(const SimplexId p[3], - const int id) const; - inline SimplexId getEdgeTriangleL_xn(const SimplexId p[3], - const int id) const; - inline SimplexId getEdgeTriangleL_xN(const SimplexId p[3], - const int id) const; - inline SimplexId getEdgeTriangleH_0y(const SimplexId p[3], - const int id) const; - inline SimplexId getEdgeTriangleH_ny(const SimplexId p[3], - const int id) const; - inline SimplexId getEdgeTriangleH_Ny(const SimplexId p[3], - const int id) const; - inline SimplexId getEdgeTriangleD1_xy(const SimplexId p[3], - const int id) const; - - inline SimplexId getEdgeLink2dL(const SimplexId p[2], const int id) const; - inline SimplexId getEdgeLink2dH(const SimplexId p[2], const int id) const; - inline SimplexId getEdgeLink2dD1(const SimplexId p[2], const int id) const; - - inline SimplexId getEdgeStar2dL(const SimplexId p[2], const int id) const; - inline SimplexId getEdgeStar2dH(const SimplexId p[2], const int id) const; + SimplexId getVertexEdge2dA(const SimplexId p[2], const int id) const; + SimplexId getVertexEdge2dB(const SimplexId p[2], const int id) const; + SimplexId getVertexEdge2dC(const SimplexId p[2], const int id) const; + SimplexId getVertexEdge2dD(const SimplexId p[2], const int id) const; + SimplexId getVertexEdge2dAB(const SimplexId p[2], const int id) const; + SimplexId getVertexEdge2dCD(const SimplexId p[2], const int id) const; + SimplexId getVertexEdge2dAC(const SimplexId p[2], const int id) const; + SimplexId getVertexEdge2dBD(const SimplexId p[2], const int id) const; + SimplexId getVertexEdge2dABCD(const SimplexId p[2], const int id) const; + + SimplexId getVertexStar2dA(const SimplexId p[2], const int id) const; + SimplexId getVertexStar2dB(const SimplexId p[2], const int id) const; + SimplexId getVertexStar2dC(const SimplexId p[2], const int id) const; + SimplexId getVertexStar2dD(const SimplexId p[2], const int id) const; + SimplexId getVertexStar2dAB(const SimplexId p[2], const int id) const; + SimplexId getVertexStar2dCD(const SimplexId p[2], const int id) const; + SimplexId getVertexStar2dAC(const SimplexId p[2], const int id) const; + SimplexId getVertexStar2dBD(const SimplexId p[2], const int id) const; + SimplexId getVertexStar2dABCD(const SimplexId p[2], const int id) const; + + SimplexId getVertexLink2dA(const SimplexId p[2], const int id) const; + SimplexId getVertexLink2dB(const SimplexId p[2], const int id) const; + SimplexId getVertexLink2dC(const SimplexId p[2], const int id) const; + SimplexId getVertexLink2dD(const SimplexId p[2], const int id) const; + SimplexId getVertexLink2dAB(const SimplexId p[2], const int id) const; + SimplexId getVertexLink2dCD(const SimplexId p[2], const int id) const; + SimplexId getVertexLink2dAC(const SimplexId p[2], const int id) const; + SimplexId getVertexLink2dBD(const SimplexId p[2], const int id) const; + SimplexId getVertexLink2dABCD(const SimplexId p[2], const int id) const; + + SimplexId getEdgeTriangleL_x0(const SimplexId p[3], const int id) const; + SimplexId getEdgeTriangleL_xn(const SimplexId p[3], const int id) const; + SimplexId getEdgeTriangleL_xN(const SimplexId p[3], const int id) const; + SimplexId getEdgeTriangleH_0y(const SimplexId p[3], const int id) const; + SimplexId getEdgeTriangleH_ny(const SimplexId p[3], const int id) const; + SimplexId getEdgeTriangleH_Ny(const SimplexId p[3], const int id) const; + SimplexId getEdgeTriangleD1_xy(const SimplexId p[3], const int id) const; + + SimplexId getEdgeLink2dL(const SimplexId p[2], const int id) const; + SimplexId getEdgeLink2dH(const SimplexId p[2], const int id) const; + SimplexId getEdgeLink2dD1(const SimplexId p[2], const int id) const; + + SimplexId getEdgeStar2dL(const SimplexId p[2], const int id) const; + SimplexId getEdgeStar2dH(const SimplexId p[2], const int id) const; // 3D // void vertexToPosition(const SimplexId vertex, @@ -934,377 +665,263 @@ namespace ttk { void tetrahedronToPosition(const SimplexId tetrahedron, SimplexId p[3]) const override; - inline SimplexId getVertexEdgeA(const SimplexId p[3], const int id) const; - inline SimplexId getVertexEdgeB(const SimplexId p[3], const int id) const; - inline SimplexId getVertexEdgeC(const SimplexId p[3], const int id) const; - inline SimplexId getVertexEdgeD(const SimplexId p[3], const int id) const; - inline SimplexId getVertexEdgeE(const SimplexId p[3], const int id) const; - inline SimplexId getVertexEdgeF(const SimplexId p[3], const int id) const; - inline SimplexId getVertexEdgeG(const SimplexId p[3], const int id) const; - inline SimplexId getVertexEdgeH(const SimplexId p[3], const int id) const; - inline SimplexId getVertexEdgeAB(const SimplexId p[3], const int id) const; - inline SimplexId getVertexEdgeCD(const SimplexId p[3], const int id) const; - inline SimplexId getVertexEdgeEF(const SimplexId p[3], const int id) const; - inline SimplexId getVertexEdgeGH(const SimplexId p[3], const int id) const; - inline SimplexId getVertexEdgeAC(const SimplexId p[3], const int id) const; - inline SimplexId getVertexEdgeBD(const SimplexId p[3], const int id) const; - inline SimplexId getVertexEdgeEG(const SimplexId p[3], const int id) const; - inline SimplexId getVertexEdgeFH(const SimplexId p[3], const int id) const; - inline SimplexId getVertexEdgeAE(const SimplexId p[3], const int id) const; - inline SimplexId getVertexEdgeBF(const SimplexId p[3], const int id) const; - inline SimplexId getVertexEdgeCG(const SimplexId p[3], const int id) const; - inline SimplexId getVertexEdgeDH(const SimplexId p[3], const int id) const; - inline SimplexId getVertexEdgeABDC(const SimplexId p[3], + SimplexId getVertexEdgeA(const SimplexId p[3], const int id) const; + SimplexId getVertexEdgeB(const SimplexId p[3], const int id) const; + SimplexId getVertexEdgeC(const SimplexId p[3], const int id) const; + SimplexId getVertexEdgeD(const SimplexId p[3], const int id) const; + SimplexId getVertexEdgeE(const SimplexId p[3], const int id) const; + SimplexId getVertexEdgeF(const SimplexId p[3], const int id) const; + SimplexId getVertexEdgeG(const SimplexId p[3], const int id) const; + SimplexId getVertexEdgeH(const SimplexId p[3], const int id) const; + SimplexId getVertexEdgeAB(const SimplexId p[3], const int id) const; + SimplexId getVertexEdgeCD(const SimplexId p[3], const int id) const; + SimplexId getVertexEdgeEF(const SimplexId p[3], const int id) const; + SimplexId getVertexEdgeGH(const SimplexId p[3], const int id) const; + SimplexId getVertexEdgeAC(const SimplexId p[3], const int id) const; + SimplexId getVertexEdgeBD(const SimplexId p[3], const int id) const; + SimplexId getVertexEdgeEG(const SimplexId p[3], const int id) const; + SimplexId getVertexEdgeFH(const SimplexId p[3], const int id) const; + SimplexId getVertexEdgeAE(const SimplexId p[3], const int id) const; + SimplexId getVertexEdgeBF(const SimplexId p[3], const int id) const; + SimplexId getVertexEdgeCG(const SimplexId p[3], const int id) const; + SimplexId getVertexEdgeDH(const SimplexId p[3], const int id) const; + SimplexId getVertexEdgeABDC(const SimplexId p[3], const int id) const; + SimplexId getVertexEdgeEFHG(const SimplexId p[3], const int id) const; + SimplexId getVertexEdgeAEGC(const SimplexId p[3], const int id) const; + SimplexId getVertexEdgeBFHD(const SimplexId p[3], const int id) const; + SimplexId getVertexEdgeAEFB(const SimplexId p[3], const int id) const; + SimplexId getVertexEdgeGHDC(const SimplexId p[3], const int id) const; + SimplexId getVertexEdgeABCDEFGH(const SimplexId p[3], const int id) const; + + SimplexId getVertexTriangleA(const SimplexId p[3], const int id) const; + SimplexId getVertexTriangleB(const SimplexId p[3], const int id) const; + SimplexId getVertexTriangleC(const SimplexId p[3], const int id) const; + SimplexId getVertexTriangleD(const SimplexId p[3], const int id) const; + SimplexId getVertexTriangleE(const SimplexId p[3], const int id) const; + SimplexId getVertexTriangleF(const SimplexId p[3], const int id) const; + SimplexId getVertexTriangleG(const SimplexId p[3], const int id) const; + SimplexId getVertexTriangleH(const SimplexId p[3], const int id) const; + SimplexId getVertexTriangleAB(const SimplexId p[3], const int id) const; + SimplexId getVertexTriangleCD(const SimplexId p[3], const int id) const; + SimplexId getVertexTriangleEF(const SimplexId p[3], const int id) const; + SimplexId getVertexTriangleGH(const SimplexId p[3], const int id) const; + SimplexId getVertexTriangleAC(const SimplexId p[3], const int id) const; + SimplexId getVertexTriangleBD(const SimplexId p[3], const int id) const; + SimplexId getVertexTriangleEG(const SimplexId p[3], const int id) const; + SimplexId getVertexTriangleFH(const SimplexId p[3], const int id) const; + SimplexId getVertexTriangleAE(const SimplexId p[3], const int id) const; + SimplexId getVertexTriangleBF(const SimplexId p[3], const int id) const; + SimplexId getVertexTriangleCG(const SimplexId p[3], const int id) const; + SimplexId getVertexTriangleDH(const SimplexId p[3], const int id) const; + SimplexId getVertexTriangleABDC(const SimplexId p[3], const int id) const; + SimplexId getVertexTriangleEFHG(const SimplexId p[3], const int id) const; + SimplexId getVertexTriangleAEGC(const SimplexId p[3], const int id) const; + SimplexId getVertexTriangleBFHD(const SimplexId p[3], const int id) const; + SimplexId getVertexTriangleAEFB(const SimplexId p[3], const int id) const; + SimplexId getVertexTriangleGHDC(const SimplexId p[3], const int id) const; + SimplexId getVertexTriangleABCDEFGH(const SimplexId p[3], + const int id) const; + + SimplexId getVertexLinkA(const SimplexId p[3], const int id) const; + SimplexId getVertexLinkB(const SimplexId p[3], const int id) const; + SimplexId getVertexLinkC(const SimplexId p[3], const int id) const; + SimplexId getVertexLinkD(const SimplexId p[3], const int id) const; + SimplexId getVertexLinkE(const SimplexId p[3], const int id) const; + SimplexId getVertexLinkF(const SimplexId p[3], const int id) const; + SimplexId getVertexLinkG(const SimplexId p[3], const int id) const; + SimplexId getVertexLinkH(const SimplexId p[3], const int id) const; + SimplexId getVertexLinkAB(const SimplexId p[3], const int id) const; + SimplexId getVertexLinkCD(const SimplexId p[3], const int id) const; + SimplexId getVertexLinkEF(const SimplexId p[3], const int id) const; + SimplexId getVertexLinkGH(const SimplexId p[3], const int id) const; + SimplexId getVertexLinkAC(const SimplexId p[3], const int id) const; + SimplexId getVertexLinkBD(const SimplexId p[3], const int id) const; + SimplexId getVertexLinkEG(const SimplexId p[3], const int id) const; + SimplexId getVertexLinkFH(const SimplexId p[3], const int id) const; + SimplexId getVertexLinkAE(const SimplexId p[3], const int id) const; + SimplexId getVertexLinkBF(const SimplexId p[3], const int id) const; + SimplexId getVertexLinkCG(const SimplexId p[3], const int id) const; + SimplexId getVertexLinkDH(const SimplexId p[3], const int id) const; + SimplexId getVertexLinkABDC(const SimplexId p[3], const int id) const; + SimplexId getVertexLinkEFHG(const SimplexId p[3], const int id) const; + SimplexId getVertexLinkAEGC(const SimplexId p[3], const int id) const; + SimplexId getVertexLinkBFHD(const SimplexId p[3], const int id) const; + SimplexId getVertexLinkAEFB(const SimplexId p[3], const int id) const; + SimplexId getVertexLinkGHDC(const SimplexId p[3], const int id) const; + SimplexId getVertexLinkABCDEFGH(const SimplexId p[3], const int id) const; + + SimplexId getVertexStarA(const SimplexId p[3], const int id) const; + SimplexId getVertexStarB(const SimplexId p[3], const int id) const; + SimplexId getVertexStarC(const SimplexId p[3], const int id) const; + SimplexId getVertexStarD(const SimplexId p[3], const int id) const; + SimplexId getVertexStarE(const SimplexId p[3], const int id) const; + SimplexId getVertexStarF(const SimplexId p[3], const int id) const; + SimplexId getVertexStarG(const SimplexId p[3], const int id) const; + SimplexId getVertexStarH(const SimplexId p[3], const int id) const; + SimplexId getVertexStarAB(const SimplexId p[3], const int id) const; + SimplexId getVertexStarCD(const SimplexId p[3], const int id) const; + SimplexId getVertexStarEF(const SimplexId p[3], const int id) const; + SimplexId getVertexStarGH(const SimplexId p[3], const int id) const; + SimplexId getVertexStarAC(const SimplexId p[3], const int id) const; + SimplexId getVertexStarBD(const SimplexId p[3], const int id) const; + SimplexId getVertexStarEG(const SimplexId p[3], const int id) const; + SimplexId getVertexStarFH(const SimplexId p[3], const int id) const; + SimplexId getVertexStarAE(const SimplexId p[3], const int id) const; + SimplexId getVertexStarBF(const SimplexId p[3], const int id) const; + SimplexId getVertexStarCG(const SimplexId p[3], const int id) const; + SimplexId getVertexStarDH(const SimplexId p[3], const int id) const; + SimplexId getVertexStarABDC(const SimplexId p[3], const int id) const; + SimplexId getVertexStarEFHG(const SimplexId p[3], const int id) const; + SimplexId getVertexStarAEGC(const SimplexId p[3], const int id) const; + SimplexId getVertexStarBFHD(const SimplexId p[3], const int id) const; + SimplexId getVertexStarAEFB(const SimplexId p[3], const int id) const; + SimplexId getVertexStarGHDC(const SimplexId p[3], const int id) const; + SimplexId getVertexStarABCDEFGH(const SimplexId p[3], const int id) const; + + SimplexId getEdgeTriangleL_x00(const SimplexId p[3], const int id) const; + SimplexId getEdgeTriangleL_x0n(const SimplexId p[3], const int id) const; + SimplexId getEdgeTriangleL_x0N(const SimplexId p[3], const int id) const; + SimplexId getEdgeTriangleL_xn0(const SimplexId p[3], const int id) const; + SimplexId getEdgeTriangleL_xnn(const SimplexId p[3], const int id) const; + SimplexId getEdgeTriangleL_xnN(const SimplexId p[3], const int id) const; + SimplexId getEdgeTriangleL_xN0(const SimplexId p[3], const int id) const; + SimplexId getEdgeTriangleL_xNn(const SimplexId p[3], const int id) const; + SimplexId getEdgeTriangleL_xNN(const SimplexId p[3], const int id) const; + + SimplexId getEdgeTriangleH_0y0(const SimplexId p[3], const int id) const; + SimplexId getEdgeTriangleH_0yn(const SimplexId p[3], const int id) const; + SimplexId getEdgeTriangleH_0yN(const SimplexId p[3], const int id) const; + SimplexId getEdgeTriangleH_ny0(const SimplexId p[3], const int id) const; + SimplexId getEdgeTriangleH_nyn(const SimplexId p[3], const int id) const; + SimplexId getEdgeTriangleH_nyN(const SimplexId p[3], const int id) const; + SimplexId getEdgeTriangleH_Ny0(const SimplexId p[3], const int id) const; + SimplexId getEdgeTriangleH_Nyn(const SimplexId p[3], const int id) const; + SimplexId getEdgeTriangleH_NyN(const SimplexId p[3], const int id) const; + + SimplexId getEdgeTriangleP_00z(const SimplexId p[3], const int id) const; + SimplexId getEdgeTriangleP_0nz(const SimplexId p[3], const int id) const; + SimplexId getEdgeTriangleP_0Nz(const SimplexId p[3], const int id) const; + SimplexId getEdgeTriangleP_n0z(const SimplexId p[3], const int id) const; + SimplexId getEdgeTriangleP_nnz(const SimplexId p[3], const int id) const; + SimplexId getEdgeTriangleP_nNz(const SimplexId p[3], const int id) const; + SimplexId getEdgeTriangleP_N0z(const SimplexId p[3], const int id) const; + SimplexId getEdgeTriangleP_Nnz(const SimplexId p[3], const int id) const; + SimplexId getEdgeTriangleP_NNz(const SimplexId p[3], const int id) const; + + SimplexId getEdgeTriangleD1_xy0(const SimplexId p[3], const int id) const; + SimplexId getEdgeTriangleD1_xyn(const SimplexId p[3], const int id) const; + SimplexId getEdgeTriangleD1_xyN(const SimplexId p[3], const int id) const; + + SimplexId getEdgeTriangleD2_0yz(const SimplexId p[3], const int id) const; + SimplexId getEdgeTriangleD2_nyz(const SimplexId p[3], const int id) const; + SimplexId getEdgeTriangleD2_Nyz(const SimplexId p[3], const int id) const; + + SimplexId getEdgeTriangleD3_x0z(const SimplexId p[3], const int id) const; + SimplexId getEdgeTriangleD3_xnz(const SimplexId p[3], const int id) const; + SimplexId getEdgeTriangleD3_xNz(const SimplexId p[3], const int id) const; + + SimplexId getEdgeTriangleD4_xyz(const SimplexId p[3], const int id) const; + + SimplexId getEdgeLinkL(const SimplexId p[3], const int id) const; + SimplexId getEdgeLinkH(const SimplexId p[3], const int id) const; + SimplexId getEdgeLinkP(const SimplexId p[3], const int id) const; + SimplexId getEdgeLinkD1(const SimplexId p[3], const int id) const; + SimplexId getEdgeLinkD2(const SimplexId p[3], const int id) const; + SimplexId getEdgeLinkD3(const SimplexId p[3], const int id) const; + SimplexId getEdgeLinkD4(const SimplexId p[3], const int id) const; + + SimplexId getEdgeStarL(const SimplexId p[3], const int id) const; + SimplexId getEdgeStarH(const SimplexId p[3], const int id) const; + SimplexId getEdgeStarP(const SimplexId p[3], const int id) const; + SimplexId getEdgeStarD1(const SimplexId p[3], const int id) const; + SimplexId getEdgeStarD2(const SimplexId p[3], const int id) const; + SimplexId getEdgeStarD3(const SimplexId p[3], const int id) const; + + SimplexId getTriangleVertexF(const SimplexId p[3], const int id) const; + SimplexId getTriangleVertexH(const SimplexId p[3], const int id) const; + SimplexId getTriangleVertexC(const SimplexId p[3], const int id) const; + SimplexId getTriangleVertexD1(const SimplexId p[3], const int id) const; + SimplexId getTriangleVertexD2(const SimplexId p[3], const int id) const; + SimplexId getTriangleVertexD3(const SimplexId p[3], const int id) const; + + SimplexId getTriangleEdgeF_0(const SimplexId p[3], const int id) const; + SimplexId getTriangleEdgeF_1(const SimplexId p[3], const int id) const; + SimplexId getTriangleEdgeH_0(const SimplexId p[3], const int id) const; + SimplexId getTriangleEdgeH_1(const SimplexId p[3], const int id) const; + SimplexId getTriangleEdgeC_0(const SimplexId p[3], const int id) const; + SimplexId getTriangleEdgeC_1(const SimplexId p[3], const int id) const; + SimplexId getTriangleEdgeD1_0(const SimplexId p[3], const int id) const; + SimplexId getTriangleEdgeD1_1(const SimplexId p[3], const int id) const; + SimplexId getTriangleEdgeD2_0(const SimplexId p[3], const int id) const; + SimplexId getTriangleEdgeD2_1(const SimplexId p[3], const int id) const; + SimplexId getTriangleEdgeD3_0(const SimplexId p[3], const int id) const; + SimplexId getTriangleEdgeD3_1(const SimplexId p[3], const int id) const; + + SimplexId getTriangleLinkF(const SimplexId p[3], const int id) const; + SimplexId getTriangleLinkH(const SimplexId p[3], const int id) const; + SimplexId getTriangleLinkC(const SimplexId p[3], const int id) const; + SimplexId getTriangleLinkD1(const SimplexId p[3], const int id) const; + SimplexId getTriangleLinkD2(const SimplexId p[3], const int id) const; + SimplexId getTriangleLinkD3(const SimplexId p[3], const int id) const; + + SimplexId getTriangleStarF(const SimplexId p[3], const int id) const; + SimplexId getTriangleStarH(const SimplexId p[3], const int id) const; + SimplexId getTriangleStarC(const SimplexId p[3], const int id) const; + SimplexId getTriangleStarD1(const SimplexId p[3], const int id) const; + SimplexId getTriangleStarD2(const SimplexId p[3], const int id) const; + SimplexId getTriangleStarD3(const SimplexId p[3], const int id) const; + + SimplexId getTetrahedronVertexABCG(const SimplexId p[3], const int id) const; - inline SimplexId getVertexEdgeEFHG(const SimplexId p[3], + SimplexId getTetrahedronVertexBCDG(const SimplexId p[3], const int id) const; - inline SimplexId getVertexEdgeAEGC(const SimplexId p[3], + SimplexId getTetrahedronVertexABEG(const SimplexId p[3], const int id) const; - inline SimplexId getVertexEdgeBFHD(const SimplexId p[3], + SimplexId getTetrahedronVertexBEFG(const SimplexId p[3], const int id) const; - inline SimplexId getVertexEdgeAEFB(const SimplexId p[3], + SimplexId getTetrahedronVertexBFGH(const SimplexId p[3], const int id) const; - inline SimplexId getVertexEdgeGHDC(const SimplexId p[3], + SimplexId getTetrahedronVertexBDGH(const SimplexId p[3], const int id) const; - inline SimplexId getVertexEdgeABCDEFGH(const SimplexId p[3], - const int id) const; - inline SimplexId getVertexTriangleA(const SimplexId p[3], - const int id) const; - inline SimplexId getVertexTriangleB(const SimplexId p[3], - const int id) const; - inline SimplexId getVertexTriangleC(const SimplexId p[3], - const int id) const; - inline SimplexId getVertexTriangleD(const SimplexId p[3], - const int id) const; - inline SimplexId getVertexTriangleE(const SimplexId p[3], - const int id) const; - inline SimplexId getVertexTriangleF(const SimplexId p[3], - const int id) const; - inline SimplexId getVertexTriangleG(const SimplexId p[3], - const int id) const; - inline SimplexId getVertexTriangleH(const SimplexId p[3], - const int id) const; - inline SimplexId getVertexTriangleAB(const SimplexId p[3], - const int id) const; - inline SimplexId getVertexTriangleCD(const SimplexId p[3], - const int id) const; - inline SimplexId getVertexTriangleEF(const SimplexId p[3], - const int id) const; - inline SimplexId getVertexTriangleGH(const SimplexId p[3], - const int id) const; - inline SimplexId getVertexTriangleAC(const SimplexId p[3], - const int id) const; - inline SimplexId getVertexTriangleBD(const SimplexId p[3], - const int id) const; - inline SimplexId getVertexTriangleEG(const SimplexId p[3], - const int id) const; - inline SimplexId getVertexTriangleFH(const SimplexId p[3], - const int id) const; - inline SimplexId getVertexTriangleAE(const SimplexId p[3], - const int id) const; - inline SimplexId getVertexTriangleBF(const SimplexId p[3], + SimplexId getTetrahedronEdgeABCG(const SimplexId p[3], const int id) const; + SimplexId getTetrahedronEdgeBCDG(const SimplexId p[3], const int id) const; + SimplexId getTetrahedronEdgeABEG(const SimplexId p[3], const int id) const; + SimplexId getTetrahedronEdgeBEFG(const SimplexId p[3], const int id) const; + SimplexId getTetrahedronEdgeBFGH(const SimplexId p[3], const int id) const; + SimplexId getTetrahedronEdgeBDGH(const SimplexId p[3], const int id) const; + + SimplexId getTetrahedronTriangleABCG(const SimplexId p[3], const int id) const; - inline SimplexId getVertexTriangleCG(const SimplexId p[3], + SimplexId getTetrahedronTriangleBCDG(const SimplexId p[3], const int id) const; - inline SimplexId getVertexTriangleDH(const SimplexId p[3], + SimplexId getTetrahedronTriangleABEG(const SimplexId p[3], const int id) const; - inline SimplexId getVertexTriangleABDC(const SimplexId p[3], - const int id) const; - inline SimplexId getVertexTriangleEFHG(const SimplexId p[3], - const int id) const; - inline SimplexId getVertexTriangleAEGC(const SimplexId p[3], - const int id) const; - inline SimplexId getVertexTriangleBFHD(const SimplexId p[3], - const int id) const; - inline SimplexId getVertexTriangleAEFB(const SimplexId p[3], - const int id) const; - inline SimplexId getVertexTriangleGHDC(const SimplexId p[3], - const int id) const; - inline SimplexId getVertexTriangleABCDEFGH(const SimplexId p[3], - const int id) const; - - inline SimplexId getVertexLinkA(const SimplexId p[3], const int id) const; - inline SimplexId getVertexLinkB(const SimplexId p[3], const int id) const; - inline SimplexId getVertexLinkC(const SimplexId p[3], const int id) const; - inline SimplexId getVertexLinkD(const SimplexId p[3], const int id) const; - inline SimplexId getVertexLinkE(const SimplexId p[3], const int id) const; - inline SimplexId getVertexLinkF(const SimplexId p[3], const int id) const; - inline SimplexId getVertexLinkG(const SimplexId p[3], const int id) const; - inline SimplexId getVertexLinkH(const SimplexId p[3], const int id) const; - inline SimplexId getVertexLinkAB(const SimplexId p[3], const int id) const; - inline SimplexId getVertexLinkCD(const SimplexId p[3], const int id) const; - inline SimplexId getVertexLinkEF(const SimplexId p[3], const int id) const; - inline SimplexId getVertexLinkGH(const SimplexId p[3], const int id) const; - inline SimplexId getVertexLinkAC(const SimplexId p[3], const int id) const; - inline SimplexId getVertexLinkBD(const SimplexId p[3], const int id) const; - inline SimplexId getVertexLinkEG(const SimplexId p[3], const int id) const; - inline SimplexId getVertexLinkFH(const SimplexId p[3], const int id) const; - inline SimplexId getVertexLinkAE(const SimplexId p[3], const int id) const; - inline SimplexId getVertexLinkBF(const SimplexId p[3], const int id) const; - inline SimplexId getVertexLinkCG(const SimplexId p[3], const int id) const; - inline SimplexId getVertexLinkDH(const SimplexId p[3], const int id) const; - inline SimplexId getVertexLinkABDC(const SimplexId p[3], - const int id) const; - inline SimplexId getVertexLinkEFHG(const SimplexId p[3], - const int id) const; - inline SimplexId getVertexLinkAEGC(const SimplexId p[3], - const int id) const; - inline SimplexId getVertexLinkBFHD(const SimplexId p[3], - const int id) const; - inline SimplexId getVertexLinkAEFB(const SimplexId p[3], - const int id) const; - inline SimplexId getVertexLinkGHDC(const SimplexId p[3], - const int id) const; - inline SimplexId getVertexLinkABCDEFGH(const SimplexId p[3], - const int id) const; - - inline SimplexId getVertexStarA(const SimplexId p[3], const int id) const; - inline SimplexId getVertexStarB(const SimplexId p[3], const int id) const; - inline SimplexId getVertexStarC(const SimplexId p[3], const int id) const; - inline SimplexId getVertexStarD(const SimplexId p[3], const int id) const; - inline SimplexId getVertexStarE(const SimplexId p[3], const int id) const; - inline SimplexId getVertexStarF(const SimplexId p[3], const int id) const; - inline SimplexId getVertexStarG(const SimplexId p[3], const int id) const; - inline SimplexId getVertexStarH(const SimplexId p[3], const int id) const; - inline SimplexId getVertexStarAB(const SimplexId p[3], const int id) const; - inline SimplexId getVertexStarCD(const SimplexId p[3], const int id) const; - inline SimplexId getVertexStarEF(const SimplexId p[3], const int id) const; - inline SimplexId getVertexStarGH(const SimplexId p[3], const int id) const; - inline SimplexId getVertexStarAC(const SimplexId p[3], const int id) const; - inline SimplexId getVertexStarBD(const SimplexId p[3], const int id) const; - inline SimplexId getVertexStarEG(const SimplexId p[3], const int id) const; - inline SimplexId getVertexStarFH(const SimplexId p[3], const int id) const; - inline SimplexId getVertexStarAE(const SimplexId p[3], const int id) const; - inline SimplexId getVertexStarBF(const SimplexId p[3], const int id) const; - inline SimplexId getVertexStarCG(const SimplexId p[3], const int id) const; - inline SimplexId getVertexStarDH(const SimplexId p[3], const int id) const; - inline SimplexId getVertexStarABDC(const SimplexId p[3], - const int id) const; - inline SimplexId getVertexStarEFHG(const SimplexId p[3], - const int id) const; - inline SimplexId getVertexStarAEGC(const SimplexId p[3], - const int id) const; - inline SimplexId getVertexStarBFHD(const SimplexId p[3], - const int id) const; - inline SimplexId getVertexStarAEFB(const SimplexId p[3], - const int id) const; - inline SimplexId getVertexStarGHDC(const SimplexId p[3], - const int id) const; - inline SimplexId getVertexStarABCDEFGH(const SimplexId p[3], - const int id) const; - - inline SimplexId getEdgeTriangleL_x00(const SimplexId p[3], - const int id) const; - inline SimplexId getEdgeTriangleL_x0n(const SimplexId p[3], - const int id) const; - inline SimplexId getEdgeTriangleL_x0N(const SimplexId p[3], - const int id) const; - inline SimplexId getEdgeTriangleL_xn0(const SimplexId p[3], - const int id) const; - inline SimplexId getEdgeTriangleL_xnn(const SimplexId p[3], - const int id) const; - inline SimplexId getEdgeTriangleL_xnN(const SimplexId p[3], - const int id) const; - inline SimplexId getEdgeTriangleL_xN0(const SimplexId p[3], - const int id) const; - inline SimplexId getEdgeTriangleL_xNn(const SimplexId p[3], - const int id) const; - inline SimplexId getEdgeTriangleL_xNN(const SimplexId p[3], - const int id) const; - - inline SimplexId getEdgeTriangleH_0y0(const SimplexId p[3], - const int id) const; - inline SimplexId getEdgeTriangleH_0yn(const SimplexId p[3], - const int id) const; - inline SimplexId getEdgeTriangleH_0yN(const SimplexId p[3], - const int id) const; - inline SimplexId getEdgeTriangleH_ny0(const SimplexId p[3], - const int id) const; - inline SimplexId getEdgeTriangleH_nyn(const SimplexId p[3], - const int id) const; - inline SimplexId getEdgeTriangleH_nyN(const SimplexId p[3], - const int id) const; - inline SimplexId getEdgeTriangleH_Ny0(const SimplexId p[3], - const int id) const; - inline SimplexId getEdgeTriangleH_Nyn(const SimplexId p[3], - const int id) const; - inline SimplexId getEdgeTriangleH_NyN(const SimplexId p[3], - const int id) const; - - inline SimplexId getEdgeTriangleP_00z(const SimplexId p[3], - const int id) const; - inline SimplexId getEdgeTriangleP_0nz(const SimplexId p[3], - const int id) const; - inline SimplexId getEdgeTriangleP_0Nz(const SimplexId p[3], - const int id) const; - inline SimplexId getEdgeTriangleP_n0z(const SimplexId p[3], - const int id) const; - inline SimplexId getEdgeTriangleP_nnz(const SimplexId p[3], - const int id) const; - inline SimplexId getEdgeTriangleP_nNz(const SimplexId p[3], - const int id) const; - inline SimplexId getEdgeTriangleP_N0z(const SimplexId p[3], - const int id) const; - inline SimplexId getEdgeTriangleP_Nnz(const SimplexId p[3], - const int id) const; - inline SimplexId getEdgeTriangleP_NNz(const SimplexId p[3], - const int id) const; - - inline SimplexId getEdgeTriangleD1_xy0(const SimplexId p[3], - const int id) const; - inline SimplexId getEdgeTriangleD1_xyn(const SimplexId p[3], - const int id) const; - inline SimplexId getEdgeTriangleD1_xyN(const SimplexId p[3], - const int id) const; - - inline SimplexId getEdgeTriangleD2_0yz(const SimplexId p[3], - const int id) const; - inline SimplexId getEdgeTriangleD2_nyz(const SimplexId p[3], - const int id) const; - inline SimplexId getEdgeTriangleD2_Nyz(const SimplexId p[3], - const int id) const; - - inline SimplexId getEdgeTriangleD3_x0z(const SimplexId p[3], - const int id) const; - inline SimplexId getEdgeTriangleD3_xnz(const SimplexId p[3], - const int id) const; - inline SimplexId getEdgeTriangleD3_xNz(const SimplexId p[3], - const int id) const; - - inline SimplexId getEdgeTriangleD4_xyz(const SimplexId p[3], - const int id) const; - - inline SimplexId getEdgeLinkL(const SimplexId p[3], const int id) const; - inline SimplexId getEdgeLinkH(const SimplexId p[3], const int id) const; - inline SimplexId getEdgeLinkP(const SimplexId p[3], const int id) const; - inline SimplexId getEdgeLinkD1(const SimplexId p[3], const int id) const; - inline SimplexId getEdgeLinkD2(const SimplexId p[3], const int id) const; - inline SimplexId getEdgeLinkD3(const SimplexId p[3], const int id) const; - inline SimplexId getEdgeLinkD4(const SimplexId p[3], const int id) const; - - inline SimplexId getEdgeStarL(const SimplexId p[3], const int id) const; - inline SimplexId getEdgeStarH(const SimplexId p[3], const int id) const; - inline SimplexId getEdgeStarP(const SimplexId p[3], const int id) const; - inline SimplexId getEdgeStarD1(const SimplexId p[3], const int id) const; - inline SimplexId getEdgeStarD2(const SimplexId p[3], const int id) const; - inline SimplexId getEdgeStarD3(const SimplexId p[3], const int id) const; - - inline SimplexId getTriangleVertexF(const SimplexId p[3], - const int id) const; - inline SimplexId getTriangleVertexH(const SimplexId p[3], - const int id) const; - inline SimplexId getTriangleVertexC(const SimplexId p[3], - const int id) const; - inline SimplexId getTriangleVertexD1(const SimplexId p[3], + SimplexId getTetrahedronTriangleBEFG(const SimplexId p[3], const int id) const; - inline SimplexId getTriangleVertexD2(const SimplexId p[3], + SimplexId getTetrahedronTriangleBFGH(const SimplexId p[3], const int id) const; - inline SimplexId getTriangleVertexD3(const SimplexId p[3], + SimplexId getTetrahedronTriangleBDGH(const SimplexId p[3], const int id) const; - inline SimplexId getTriangleEdgeF_0(const SimplexId p[3], - const int id) const; - inline SimplexId getTriangleEdgeF_1(const SimplexId p[3], - const int id) const; - inline SimplexId getTriangleEdgeH_0(const SimplexId p[3], - const int id) const; - inline SimplexId getTriangleEdgeH_1(const SimplexId p[3], - const int id) const; - inline SimplexId getTriangleEdgeC_0(const SimplexId p[3], - const int id) const; - inline SimplexId getTriangleEdgeC_1(const SimplexId p[3], - const int id) const; - inline SimplexId getTriangleEdgeD1_0(const SimplexId p[3], + SimplexId getTetrahedronNeighborABCG(const SimplexId t, + const SimplexId p[3], const int id) const; - inline SimplexId getTriangleEdgeD1_1(const SimplexId p[3], + SimplexId getTetrahedronNeighborBCDG(const SimplexId t, + const SimplexId p[3], const int id) const; - inline SimplexId getTriangleEdgeD2_0(const SimplexId p[3], + SimplexId getTetrahedronNeighborABEG(const SimplexId t, + const SimplexId p[3], const int id) const; - inline SimplexId getTriangleEdgeD2_1(const SimplexId p[3], + SimplexId getTetrahedronNeighborBEFG(const SimplexId t, + const SimplexId p[3], const int id) const; - inline SimplexId getTriangleEdgeD3_0(const SimplexId p[3], + SimplexId getTetrahedronNeighborBFGH(const SimplexId t, + const SimplexId p[3], const int id) const; - inline SimplexId getTriangleEdgeD3_1(const SimplexId p[3], + SimplexId getTetrahedronNeighborBDGH(const SimplexId t, + const SimplexId p[3], const int id) const; - - inline SimplexId getTriangleLinkF(const SimplexId p[3], const int id) const; - inline SimplexId getTriangleLinkH(const SimplexId p[3], const int id) const; - inline SimplexId getTriangleLinkC(const SimplexId p[3], const int id) const; - inline SimplexId getTriangleLinkD1(const SimplexId p[3], - const int id) const; - inline SimplexId getTriangleLinkD2(const SimplexId p[3], - const int id) const; - inline SimplexId getTriangleLinkD3(const SimplexId p[3], - const int id) const; - - inline SimplexId getTriangleStarF(const SimplexId p[3], const int id) const; - inline SimplexId getTriangleStarH(const SimplexId p[3], const int id) const; - inline SimplexId getTriangleStarC(const SimplexId p[3], const int id) const; - inline SimplexId getTriangleStarD1(const SimplexId p[3], - const int id) const; - inline SimplexId getTriangleStarD2(const SimplexId p[3], - const int id) const; - inline SimplexId getTriangleStarD3(const SimplexId p[3], - const int id) const; - - inline SimplexId getTetrahedronVertexABCG(const SimplexId p[3], - const int id) const; - inline SimplexId getTetrahedronVertexBCDG(const SimplexId p[3], - const int id) const; - inline SimplexId getTetrahedronVertexABEG(const SimplexId p[3], - const int id) const; - inline SimplexId getTetrahedronVertexBEFG(const SimplexId p[3], - const int id) const; - inline SimplexId getTetrahedronVertexBFGH(const SimplexId p[3], - const int id) const; - inline SimplexId getTetrahedronVertexBDGH(const SimplexId p[3], - const int id) const; - - inline SimplexId getTetrahedronEdgeABCG(const SimplexId p[3], - const int id) const; - inline SimplexId getTetrahedronEdgeBCDG(const SimplexId p[3], - const int id) const; - inline SimplexId getTetrahedronEdgeABEG(const SimplexId p[3], - const int id) const; - inline SimplexId getTetrahedronEdgeBEFG(const SimplexId p[3], - const int id) const; - inline SimplexId getTetrahedronEdgeBFGH(const SimplexId p[3], - const int id) const; - inline SimplexId getTetrahedronEdgeBDGH(const SimplexId p[3], - const int id) const; - - inline SimplexId getTetrahedronTriangleABCG(const SimplexId p[3], - const int id) const; - inline SimplexId getTetrahedronTriangleBCDG(const SimplexId p[3], - const int id) const; - inline SimplexId getTetrahedronTriangleABEG(const SimplexId p[3], - const int id) const; - inline SimplexId getTetrahedronTriangleBEFG(const SimplexId p[3], - const int id) const; - inline SimplexId getTetrahedronTriangleBFGH(const SimplexId p[3], - const int id) const; - inline SimplexId getTetrahedronTriangleBDGH(const SimplexId p[3], - const int id) const; - - inline SimplexId getTetrahedronNeighborABCG(const SimplexId t, - const SimplexId p[3], - const int id) const; - inline SimplexId getTetrahedronNeighborBCDG(const SimplexId t, - const SimplexId p[3], - const int id) const; - inline SimplexId getTetrahedronNeighborABEG(const SimplexId t, - const SimplexId p[3], - const int id) const; - inline SimplexId getTetrahedronNeighborBEFG(const SimplexId t, - const SimplexId p[3], - const int id) const; - inline SimplexId getTetrahedronNeighborBFGH(const SimplexId t, - const SimplexId p[3], - const int id) const; - inline SimplexId getTetrahedronNeighborBDGH(const SimplexId t, - const SimplexId p[3], - const int id) const; //\endcond }; @@ -2710,624 +2327,52 @@ namespace ttk { return 0; } - inline int getTriangleVertexInternal(const SimplexId &triangleId, - const int &localVertexId, - SimplexId &vertexId) const override { + int getTriangleVertexInternal(const SimplexId &triangleId, + const int &localVertexId, + SimplexId &vertexId) const override; -#ifndef TTK_ENABLE_KAMIKAZE - if(triangleId < 0 or triangleId >= triangleNumber_) - return -1; - if(localVertexId < 0 or localVertexId >= 3) - return -2; -#endif + int getTriangleEdgeInternal(const SimplexId &triangleId, + const int &id, + SimplexId &edgeId) const override; - // e--------f - // /| /| - // / | / | - // a--g-----b--h - // | / | / - // |/ |/ - // c--------d - // - // Classement des "Triangles" et dans cet ordre: - // F: face (type abc/bcd) - // C: cote (type abe/bef) - // H: haut (type acg/aeg) - // D1: diagonale1 (type bdg/beg) - // D2: diagonale2 (type abg/bgh) - // D3: diagonale3 (type bcg/bfg) - - const auto &p = this->underlying().getTriangleCoords(triangleId); - vertexId = -1; - - switch(this->underlying().getTrianglePosition(triangleId)) { - case TrianglePosition::F_3D: - vertexId = getTriangleVertexF(p.data(), localVertexId); - break; - case TrianglePosition::H_3D: - vertexId = getTriangleVertexH(p.data(), localVertexId); - break; - case TrianglePosition::C_3D: - vertexId = getTriangleVertexC(p.data(), localVertexId); - break; - case TrianglePosition::D1_3D: - vertexId = getTriangleVertexD1(p.data(), localVertexId); - break; - case TrianglePosition::D2_3D: - vertexId = getTriangleVertexD2(p.data(), localVertexId); - break; - case TrianglePosition::D3_3D: - vertexId = getTriangleVertexD3(p.data(), localVertexId); - break; - case TrianglePosition::TOP_2D: - switch(localVertexId) { - break; - case 0: - vertexId = p[0] / 2 + p[1] * vshift_[0]; - break; - case 1: - vertexId = p[0] / 2 + p[1] * vshift_[0] + 1; - break; - case 2: - vertexId = p[0] / 2 + p[1] * vshift_[0] + vshift_[0]; - break; - } - break; - case TrianglePosition::BOTTOM_2D: - switch(localVertexId) { - break; - case 0: - vertexId = p[0] / 2 + p[1] * vshift_[0] + 1; - break; - case 1: - vertexId = p[0] / 2 + p[1] * vshift_[0] + vshift_[0] + 1; - break; - case 2: - vertexId = p[0] / 2 + p[1] * vshift_[0] + vshift_[0]; - break; - } - } - - return 0; - } - - inline int getTriangleEdgeInternal(const SimplexId &triangleId, - const int &localEdgeId, - SimplexId &edgeId) const override { - -#ifndef TTK_ENABLE_KAMIKAZE - if(triangleId < 0 or triangleId >= triangleNumber_) - return -1; - if(localEdgeId < 0 or localEdgeId >= 3) - return -2; -#endif - - const auto &p = this->underlying().getTriangleCoords(triangleId); - const auto par = triangleId % 2; - edgeId = -1; - - switch(this->underlying().getTrianglePosition(triangleId)) { - case TrianglePosition::F_3D: - edgeId = (par == 1) ? getTriangleEdgeF_1(p.data(), localEdgeId) - : getTriangleEdgeF_0(p.data(), localEdgeId); - break; - case TrianglePosition::H_3D: - edgeId = (par == 1) ? getTriangleEdgeH_1(p.data(), localEdgeId) - : getTriangleEdgeH_0(p.data(), localEdgeId); - break; - case TrianglePosition::C_3D: - edgeId = (par == 1) ? getTriangleEdgeC_1(p.data(), localEdgeId) - : getTriangleEdgeC_0(p.data(), localEdgeId); - break; - case TrianglePosition::D1_3D: - edgeId = (par == 1) ? getTriangleEdgeD1_1(p.data(), localEdgeId) - : getTriangleEdgeD1_0(p.data(), localEdgeId); - break; - case TrianglePosition::D2_3D: - edgeId = (par == 1) ? getTriangleEdgeD2_1(p.data(), localEdgeId) - : getTriangleEdgeD2_0(p.data(), localEdgeId); - break; - case TrianglePosition::D3_3D: - edgeId = (par == 1) ? getTriangleEdgeD3_1(p.data(), localEdgeId) - : getTriangleEdgeD3_0(p.data(), localEdgeId); - break; - case TrianglePosition::TOP_2D: - switch(localEdgeId) { - break; - case 0: - edgeId = p[0] / 2 + p[1] * eshift_[0]; - break; - case 1: - edgeId = esetshift_[0] + p[0] / 2 + p[1] * eshift_[2]; - break; - case 2: - edgeId = esetshift_[1] + p[0] / 2 + p[1] * eshift_[4]; - break; - } - break; - case TrianglePosition::BOTTOM_2D: - switch(localEdgeId) { - break; - case 0: - edgeId = p[0] / 2 + (p[1] + 1) * eshift_[0]; - break; - case 1: - edgeId = esetshift_[0] + (p[0] + 1) / 2 + p[1] * eshift_[2]; - break; - case 2: - edgeId = esetshift_[1] + p[0] / 2 + p[1] * eshift_[4]; - break; - } - } - - return 0; - } - - inline int TTK_TRIANGULATION_INTERNAL(getTriangleLink)( + int TTK_TRIANGULATION_INTERNAL(getTriangleLink)( const SimplexId &triangleId, const int &localLinkId, - SimplexId &linkId) const override { + SimplexId &linkId) const override; -#ifndef TTK_ENABLE_KAMIKAZE - if(localLinkId < 0 or localLinkId >= getTriangleLinkNumber(triangleId)) - return -1; -#endif - - const auto &p = this->underlying().getTriangleCoords(triangleId); - - switch(this->underlying().getTrianglePosition(triangleId)) { - case TrianglePosition::F_3D: - linkId = getTriangleLinkF(p.data(), localLinkId); - break; - case TrianglePosition::H_3D: - linkId = getTriangleLinkH(p.data(), localLinkId); - break; - case TrianglePosition::C_3D: - linkId = getTriangleLinkC(p.data(), localLinkId); - break; - case TrianglePosition::D1_3D: - linkId = getTriangleLinkD1(p.data(), localLinkId); - break; - case TrianglePosition::D2_3D: - linkId = getTriangleLinkD2(p.data(), localLinkId); - break; - case TrianglePosition::D3_3D: - linkId = getTriangleLinkD3(p.data(), localLinkId); - break; - default: // 2D - linkId = -1; - break; - } - - return 0; - } - - inline int TTK_TRIANGULATION_INTERNAL(getTriangleStar)( + int TTK_TRIANGULATION_INTERNAL(getTriangleStar)( const SimplexId &triangleId, const int &localStarId, - SimplexId &starId) const override { - -#ifndef TTK_ENABLE_KAMIKAZE - if(localStarId < 0 or localStarId >= getTriangleStarNumber(triangleId)) - return -1; -#endif - - const auto &p = this->underlying().getTriangleCoords(triangleId); + SimplexId &starId) const override; - switch(this->underlying().getTrianglePosition(triangleId)) { - case TrianglePosition::F_3D: - starId = getTriangleStarF(p.data(), localStarId); - break; - case TrianglePosition::H_3D: - starId = getTriangleStarH(p.data(), localStarId); - break; - case TrianglePosition::C_3D: - starId = getTriangleStarC(p.data(), localStarId); - break; - case TrianglePosition::D1_3D: - starId = getTriangleStarD1(p.data(), localStarId); - break; - case TrianglePosition::D2_3D: - starId = getTriangleStarD2(p.data(), localStarId); - break; - case TrianglePosition::D3_3D: - starId = getTriangleStarD3(p.data(), localStarId); - break; - default: // 2D - starId = -1; - break; - } + SimplexId TTK_TRIANGULATION_INTERNAL(getTriangleStarNumber)( + const SimplexId &triangleId) const override; - return 0; - } + int getTriangleNeighbor(const SimplexId &triangleId, + const int &localNeighborId, + SimplexId &neighborId) const override; - inline SimplexId TTK_TRIANGULATION_INTERNAL(getTriangleStarNumber)( - const SimplexId &triangleId) const override { + SimplexId + getTriangleNeighborNumber(const SimplexId &triangleId) const override; -#ifndef TTK_ENABLE_KAMIKAZE - if(triangleId < 0 or triangleId >= triangleNumber_) - return -1; -#endif + int getTetrahedronVertex(const SimplexId &tetId, + const int &localVertexId, + SimplexId &vertexId) const override; - const auto &p = this->underlying().getTriangleCoords(triangleId); + int getTetrahedronEdge(const SimplexId &tetId, + const int &id, + SimplexId &edgeId) const override; - switch(this->underlying().getTrianglePosition(triangleId)) { - case TrianglePosition::F_3D: - return (p[2] > 0 and p[2] < nbvoxels_[2]) ? 2 : 1; - case TrianglePosition::H_3D: - return (p[1] > 0 and p[1] < nbvoxels_[1]) ? 2 : 1; - case TrianglePosition::C_3D: - return (p[0] < 2 or p[0] >= (dimensions_[0] * 2 - 2)) ? 1 : 2; + int getTetrahedronTriangle(const SimplexId &tetId, + const int &id, + SimplexId &triangleId) const override; - case TrianglePosition::D1_3D: - case TrianglePosition::D2_3D: - case TrianglePosition::D3_3D: - return 2; - default: // 2D - break; - } - return 0; - } + SimplexId + getTetrahedronNeighborNumber(const SimplexId &tetId) const override; - inline int getTriangleNeighbor(const SimplexId &triangleId, - const int &localNeighborId, - SimplexId &neighborId) const override { - -#ifndef TTK_ENABLE_KAMIKAZE - if(localNeighborId < 0 - or localNeighborId >= getTriangleNeighborNumber(triangleId)) - return -1; -#endif - - neighborId = -1; - - if(dimensionality_ == 2) { - const auto &p = this->underlying().getTriangleCoords(triangleId); - const SimplexId id = triangleId % 2; - - if(id) { - if(p[0] / 2 == nbvoxels_[Di_] - 1 and p[1] == nbvoxels_[Dj_] - 1) - neighborId = triangleId - 1; - else if(p[0] / 2 == nbvoxels_[Di_] - 1) { - switch(localNeighborId) { - case 0: - neighborId = triangleId - 1; - break; - case 1: - neighborId = triangleId + tshift_[0] - 1; - break; - } - } else if(p[1] == nbvoxels_[Dj_] - 1) { - switch(localNeighborId) { - case 0: - neighborId = triangleId - 1; - break; - case 1: - neighborId = triangleId + 1; - break; - } - } else { - switch(localNeighborId) { - case 0: - neighborId = triangleId - 1; - break; - case 1: - neighborId = triangleId + 1; - break; - case 2: - neighborId = triangleId + tshift_[0] - 1; - break; - } - } - } else { - if(p[0] == 0 and p[1] == 0) - neighborId = triangleId + 1; - else if(p[0] == 0) { - switch(localNeighborId) { - case 0: - neighborId = triangleId + 1; - break; - case 1: - neighborId = triangleId - tshift_[0] + 1; - break; - } - } else if(p[1] == 0) { - switch(localNeighborId) { - case 0: - neighborId = triangleId + 1; - break; - case 1: - neighborId = triangleId - 1; - break; - } - } else { - switch(localNeighborId) { - case 0: - neighborId = triangleId + 1; - break; - case 1: - neighborId = triangleId - 1; - break; - case 2: - neighborId = triangleId - tshift_[0] + 1; - break; - } - } - } - } - - return 0; - } - - inline SimplexId - getTriangleNeighborNumber(const SimplexId &triangleId) const override { - -#ifndef TTK_ENABLE_KAMIKAZE - if(triangleId < 0 or triangleId >= triangleNumber_) - return -1; -#endif - - if(dimensionality_ == 2) { - const auto &p = this->underlying().getTriangleCoords(triangleId); - const SimplexId id = triangleId % 2; - - if(id) { - if(p[0] / 2 == nbvoxels_[Di_] - 1 and p[1] == nbvoxels_[Dj_] - 1) - return 1; - else if(p[0] / 2 == nbvoxels_[Di_] - 1 or p[1] == nbvoxels_[Dj_] - 1) - return 2; - else - return 3; - } else { - if(p[0] == 0 and p[1] == 0) - return 1; - else if(p[0] == 0 or p[1] == 0) - return 2; - else - return 3; - } - } - - return 0; - } - - inline int getTetrahedronVertex(const SimplexId &tetId, - const int &localVertexId, - SimplexId &vertexId) const override { - -#ifndef TTK_ENABLE_KAMIKAZE - if(tetId < 0 or tetId >= tetrahedronNumber_) - return -1; - if(localVertexId < 0 or localVertexId >= 4) - return -2; -#endif - - vertexId = -1; - - if(dimensionality_ == 3) { - const SimplexId id = tetId % 6; - const auto &c = this->underlying().getTetrahedronCoords(tetId); - const auto p{c.data()}; - - switch(id) { - case 0: - vertexId = getTetrahedronVertexABCG(p, localVertexId); - break; - case 1: - vertexId = getTetrahedronVertexBCDG(p, localVertexId); - break; - case 2: - vertexId = getTetrahedronVertexABEG(p, localVertexId); - break; - case 3: - vertexId = getTetrahedronVertexBEFG(p, localVertexId); - break; - case 4: - vertexId = getTetrahedronVertexBFGH(p, localVertexId); - break; - case 5: - vertexId = getTetrahedronVertexBDGH(p, localVertexId); - break; - } - } - return 0; - } - - inline int getTetrahedronEdge(const SimplexId &tetId, - const int &localEdgeId, - SimplexId &edgeId) const override { - -#ifndef TTK_ENABLE_KAMIKAZE - if(tetId < 0 or tetId >= tetrahedronNumber_) - return -1; - if(localEdgeId < 0 or localEdgeId >= 6) - return -2; -#endif - - edgeId = -1; - - if(dimensionality_ == 3) { - const SimplexId id = tetId % 6; - const auto &c = this->underlying().getTetrahedronCoords(tetId); - const auto p{c.data()}; - - switch(id) { - case 0: - edgeId = getTetrahedronEdgeABCG(p, localEdgeId); - break; - case 1: - edgeId = getTetrahedronEdgeBCDG(p, localEdgeId); - break; - case 2: - edgeId = getTetrahedronEdgeABEG(p, localEdgeId); - break; - case 3: - edgeId = getTetrahedronEdgeBEFG(p, localEdgeId); - break; - case 4: - edgeId = getTetrahedronEdgeBFGH(p, localEdgeId); - break; - case 5: - edgeId = getTetrahedronEdgeBDGH(p, localEdgeId); - break; - } - } - - return 0; - } - - inline int getTetrahedronTriangle(const SimplexId &tetId, - const int &localTriangleId, - SimplexId &triangleId) const override { - -#ifndef TTK_ENABLE_KAMIKAZE - if(tetId < 0 or tetId >= tetrahedronNumber_) - return -1; - if(localTriangleId < 0 or localTriangleId >= 4) - return -2; -#endif - - triangleId = -1; - - if(dimensionality_ == 3) { - const SimplexId id = tetId % 6; - const auto &c = this->underlying().getTetrahedronCoords(tetId); - const auto p{c.data()}; - - switch(id) { - case 0: - triangleId = getTetrahedronTriangleABCG(p, localTriangleId); - break; - case 1: - triangleId = getTetrahedronTriangleBCDG(p, localTriangleId); - break; - case 2: - triangleId = getTetrahedronTriangleABEG(p, localTriangleId); - break; - case 3: - triangleId = getTetrahedronTriangleBEFG(p, localTriangleId); - break; - case 4: - triangleId = getTetrahedronTriangleBFGH(p, localTriangleId); - break; - case 5: - triangleId = getTetrahedronTriangleBDGH(p, localTriangleId); - break; - } - } - - return 0; - } - - inline SimplexId - getTetrahedronNeighborNumber(const SimplexId &tetId) const override { - -#ifndef TTK_ENABLE_KAMIKAZE - if(tetId < 0 or tetId >= tetrahedronNumber_) - return -1; -#endif - - if(dimensionality_ == 3) { - const SimplexId id = tetId % 6; - const auto &c = this->underlying().getTetrahedronCoords(tetId); - const auto p{c.data()}; - - switch(id) { - case 0: // ABCG - if(p[0] == 0 and p[2] == 0) - return 2; - else if(p[0] == 0 or p[2] == 0) - return 3; - else - return 4; - break; - case 1: // BCDG - if(p[1] == nbvoxels_[1] - 1 and p[2] == 0) - return 2; - else if(p[1] == nbvoxels_[1] - 1 or p[2] == 0) - return 3; - else - return 4; - break; - case 2: // ABEG - if(p[0] == 0 and p[1] == 0) - return 2; - else if(p[0] == 0 or p[1] == 0) - return 3; - else - return 4; - break; - case 3: // BEFG - if(p[1] == 0 and p[2] == nbvoxels_[2] - 1) - return 2; - else if(p[1] == 0 or p[2] == nbvoxels_[2] - 1) - return 3; - else - return 4; - break; - case 4: // BFGH - if(p[0] == nbvoxels_[0] - 1 and p[2] == nbvoxels_[2] - 1) - return 2; - else if(p[0] == nbvoxels_[0] - 1 or p[2] == nbvoxels_[2] - 1) - return 3; - else - return 4; - break; - case 5: // BDGH - if(p[0] == nbvoxels_[0] - 1 and p[1] == nbvoxels_[1] - 1) - return 2; - else if(p[0] == nbvoxels_[0] - 1 or p[1] == nbvoxels_[1] - 1) - return 3; - else - return 4; - break; - } - } - - return 0; - } - - inline int getTetrahedronNeighbor(const SimplexId &tetId, - const int &localNeighborId, - SimplexId &neighborId) const override { - -#ifndef TTK_ENABLE_KAMIKAZE - if(localNeighborId < 0 - or localNeighborId >= getTetrahedronNeighborNumber(tetId)) - return -1; -#endif - - neighborId = -1; - - if(dimensionality_ == 3) { - const SimplexId id = tetId % 6; - const auto &c = this->underlying().getTetrahedronCoords(tetId); - const auto p{c.data()}; - - switch(id) { - case 0: - neighborId = getTetrahedronNeighborABCG(tetId, p, localNeighborId); - break; - case 1: - neighborId = getTetrahedronNeighborBCDG(tetId, p, localNeighborId); - break; - case 2: - neighborId = getTetrahedronNeighborABEG(tetId, p, localNeighborId); - break; - case 3: - neighborId = getTetrahedronNeighborBEFG(tetId, p, localNeighborId); - break; - case 4: - neighborId = getTetrahedronNeighborBFGH(tetId, p, localNeighborId); - break; - case 5: - neighborId = getTetrahedronNeighborBDGH(tetId, p, localNeighborId); - break; - } - } - - return 0; - } + int getTetrahedronNeighbor(const SimplexId &tetId, + const int &localNeighborId, + SimplexId &neighborId) const override; }; } // namespace ttk From 88c9078e32fb3fb802fbfe0ae05a1663bc98ad60 Mon Sep 17 00:00:00 2001 From: Julien Tierny Date: Thu, 28 Sep 2023 11:37:55 +0200 Subject: [PATCH 11/12] Revert "further in-lining for the implicit triangulation" This reverts commit a53067d9dccee9f6e7264a3606aefe7175805610. --- .../connectedComponents/ConnectedComponents.h | 2 +- core/base/fiberSurface/FiberSurface.h | 2 +- .../ImplicitTriangulation.cpp | 1302 ++++++++++++++++ .../ImplicitTriangulation.h | 1324 +---------------- 4 files changed, 1357 insertions(+), 1273 deletions(-) diff --git a/core/base/connectedComponents/ConnectedComponents.h b/core/base/connectedComponents/ConnectedComponents.h index 7d99580a23..6598487015 100644 --- a/core/base/connectedComponents/ConnectedComponents.h +++ b/core/base/connectedComponents/ConnectedComponents.h @@ -63,7 +63,7 @@ namespace ttk { TID id = seed; float size = 0; - float x = 0, y = 0, z = 0; + float x, y, z; float center[3] = {0, 0, 0}; while(!stack.empty()) { diff --git a/core/base/fiberSurface/FiberSurface.h b/core/base/fiberSurface/FiberSurface.h index 2f901f01e7..a292602d83 100644 --- a/core/base/fiberSurface/FiberSurface.h +++ b/core/base/fiberSurface/FiberSurface.h @@ -764,7 +764,7 @@ inline int ttk::FiberSurface::computeCase0( Geometry::computeBarycentricCoordinates( p0.data(), p1.data(), p.data(), baryCentrics, 2); - float pA[3] = {0, 0, 0}, pB[3] = {0, 0, 0}; + float pA[3], pB[3]; if(triangulation) { triangulation->getVertexPoint(vertexId0, pA[0], pA[1], pA[2]); triangulation->getVertexPoint(vertexId1, pB[0], pB[1], pB[2]); diff --git a/core/base/implicitTriangulation/ImplicitTriangulation.cpp b/core/base/implicitTriangulation/ImplicitTriangulation.cpp index 02e8394ad8..21b1edb2ee 100644 --- a/core/base/implicitTriangulation/ImplicitTriangulation.cpp +++ b/core/base/implicitTriangulation/ImplicitTriangulation.cpp @@ -5,6 +5,57 @@ using namespace std; using namespace ttk; +#define CASE_EDGE_POSITION_L_3D \ + case EdgePosition::L_xnn_3D: \ + case EdgePosition::L_xn0_3D: \ + case EdgePosition::L_xnN_3D: \ + case EdgePosition::L_x0n_3D: \ + case EdgePosition::L_x00_3D: \ + case EdgePosition::L_x0N_3D: \ + case EdgePosition::L_xNn_3D: \ + case EdgePosition::L_xN0_3D: \ + case EdgePosition::L_xNN_3D +#define CASE_EDGE_POSITION_H_3D \ + case EdgePosition::H_nyn_3D: \ + case EdgePosition::H_ny0_3D: \ + case EdgePosition::H_nyN_3D: \ + case EdgePosition::H_0yn_3D: \ + case EdgePosition::H_0y0_3D: \ + case EdgePosition::H_0yN_3D: \ + case EdgePosition::H_Nyn_3D: \ + case EdgePosition::H_Ny0_3D: \ + case EdgePosition::H_NyN_3D +#define CASE_EDGE_POSITION_P_3D \ + case EdgePosition::P_nnz_3D: \ + case EdgePosition::P_n0z_3D: \ + case EdgePosition::P_nNz_3D: \ + case EdgePosition::P_0nz_3D: \ + case EdgePosition::P_00z_3D: \ + case EdgePosition::P_0Nz_3D: \ + case EdgePosition::P_Nnz_3D: \ + case EdgePosition::P_N0z_3D: \ + case EdgePosition::P_NNz_3D +#define CASE_EDGE_POSITION_D1_3D \ + case EdgePosition::D1_xyn_3D: \ + case EdgePosition::D1_xy0_3D: \ + case EdgePosition::D1_xyN_3D +#define CASE_EDGE_POSITION_D2_3D \ + case EdgePosition::D2_nyz_3D: \ + case EdgePosition::D2_0yz_3D: \ + case EdgePosition::D2_Nyz_3D +#define CASE_EDGE_POSITION_D3_3D \ + case EdgePosition::D3_xnz_3D: \ + case EdgePosition::D3_x0z_3D: \ + case EdgePosition::D3_xNz_3D +#define CASE_EDGE_POSITION_L_2D \ + case EdgePosition::L_xn_2D: \ + case EdgePosition::L_x0_2D: \ + case EdgePosition::L_xN_2D +#define CASE_EDGE_POSITION_H_2D \ + case EdgePosition::H_ny_2D: \ + case EdgePosition::H_0y_2D: \ + case EdgePosition::H_Ny_2D + ImplicitTriangulation::ImplicitTriangulation() : cellNumber_{}, vertexNumber_{}, edgeNumber_{}, triangleNumber_{}, tetrahedronNumber_{}, isAccelerated_{} { @@ -217,6 +268,95 @@ int ImplicitTriangulation::checkAcceleration() { return 0; } +bool ImplicitTriangulation::isPowerOfTwo(unsigned long long int v, + unsigned long long int &r) { + if(v && !(v & (v - 1))) { + r = 0; + while(v >>= 1) + r++; + return true; + } + return false; +} + +template +bool ImplicitTriangulationCRTP::TTK_TRIANGULATION_INTERNAL( + isVertexOnBoundary)(const SimplexId &vertexId) const { + +#ifdef TTK_ENABLE_MPI + if(this->metaGrid_ != nullptr) { + return this->isVertexOnGlobalBoundaryInternal(vertexId); + } +#endif // TTK_ENABLE_MPI + +#ifndef TTK_ENABLE_KAMIKAZE + if(vertexId < 0 or vertexId >= vertexNumber_) + return false; +#endif // !TTK_ENABLE_KAMIKAZE + + switch(this->underlying().getVertexPosition(vertexId)) { + case VertexPosition::CENTER_3D: + case VertexPosition::CENTER_2D: + case VertexPosition::CENTER_1D: + return false; + default: + return true; + } +} + +template +bool ImplicitTriangulationCRTP::TTK_TRIANGULATION_INTERNAL( + isEdgeOnBoundary)(const SimplexId &edgeId) const { + +#ifdef TTK_ENABLE_MPI + if(this->metaGrid_ != nullptr) { + return this->isEdgeOnGlobalBoundaryInternal(edgeId); + } +#endif // TTK_ENABLE_MPI + +#ifndef TTK_ENABLE_KAMIKAZE + if(edgeId < 0 or edgeId >= edgeNumber_) + return false; +#endif // !TTK_ENABLE_KAMIKAZE + + switch(this->underlying().getEdgePosition(edgeId)) { + case EdgePosition::L_xnn_3D: + case EdgePosition::H_nyn_3D: + case EdgePosition::P_nnz_3D: + case EdgePosition::D1_xyn_3D: + case EdgePosition::D2_nyz_3D: + case EdgePosition::D3_xnz_3D: + case EdgePosition::D4_3D: + case EdgePosition::L_xn_2D: + case EdgePosition::H_ny_2D: + case EdgePosition::D1_2D: + return false; + default: + break; + } + return true; +} + +bool ImplicitTriangulation::TTK_TRIANGULATION_INTERNAL(isTriangleOnBoundary)( + const SimplexId &triangleId) const { + +#ifdef TTK_ENABLE_MPI + if(this->metaGrid_ != nullptr) { + return this->isTriangleOnGlobalBoundaryInternal(triangleId); + } +#endif // TTK_ENABLE_MPI + +#ifndef TTK_ENABLE_KAMIKAZE + if(triangleId < 0 or triangleId >= triangleNumber_) + return false; +#endif // !TTK_ENABLE_KAMIKAZE + + if(dimensionality_ == 3) + return (TTK_TRIANGULATION_INTERNAL(getTriangleStarNumber)(triangleId) == 1); + + return false; +} + const vector> * ImplicitTriangulation::TTK_TRIANGULATION_INTERNAL(getVertexNeighbors)() { if(vertexNeighborList_.empty()) { @@ -235,6 +375,162 @@ const vector> * return &vertexNeighborList_; } +SimplexId ImplicitTriangulation::getVertexEdgeNumberInternal( + const SimplexId &vertexId) const { + return TTK_TRIANGULATION_INTERNAL(getVertexNeighborNumber)(vertexId); +} + +template +int ImplicitTriangulationCRTP::getVertexEdgeInternal( + const SimplexId &vertexId, const int &localEdgeId, SimplexId &edgeId) const { +#ifndef TTK_ENABLE_KAMIKAZE + if(localEdgeId < 0 or localEdgeId >= getVertexEdgeNumberInternal(vertexId)) + return -1; +#endif + // e--------f + // /| /| + // / | / | + // a--g-----b--h + // | / | / + // |/ |/ + // c--------d + // + // Classement des "Edges" et dans cet ordre: + // L: largeur (type ab) + // H: hauteur (type ac) + // P: profondeur (type ae) + // D1: diagonale1 (type bc) + // D2: diagonale2 (type ag) + // D3: diagonale3 (type be) + // D4: diagonale4 (type bg) + + const auto &p = this->underlying().getVertexCoords(vertexId); + + switch(this->underlying().getVertexPosition(vertexId)) { + case VertexPosition::CENTER_3D: + edgeId = getVertexEdgeABCDEFGH(p.data(), localEdgeId); + break; + case VertexPosition::FRONT_FACE_3D: + edgeId = getVertexEdgeABDC(p.data(), localEdgeId); + break; + case VertexPosition::BACK_FACE_3D: + edgeId = getVertexEdgeEFHG(p.data(), localEdgeId); + break; + case VertexPosition::TOP_FACE_3D: + edgeId = getVertexEdgeAEFB(p.data(), localEdgeId); + break; + case VertexPosition::BOTTOM_FACE_3D: + edgeId = getVertexEdgeGHDC(p.data(), localEdgeId); + break; + case VertexPosition::LEFT_FACE_3D: + edgeId = getVertexEdgeAEGC(p.data(), localEdgeId); + break; + case VertexPosition::RIGHT_FACE_3D: + edgeId = getVertexEdgeBFHD(p.data(), localEdgeId); + break; + case VertexPosition::TOP_FRONT_EDGE_3D: // ab + edgeId = getVertexEdgeAB(p.data(), localEdgeId); + break; + case VertexPosition::BOTTOM_FRONT_EDGE_3D: // cd + edgeId = getVertexEdgeCD(p.data(), localEdgeId); + break; + case VertexPosition::LEFT_FRONT_EDGE_3D: // ac + edgeId = getVertexEdgeAC(p.data(), localEdgeId); + break; + case VertexPosition::RIGHT_FRONT_EDGE_3D: // bd + edgeId = getVertexEdgeBD(p.data(), localEdgeId); + break; + case VertexPosition::TOP_BACK_EDGE_3D: // ef + edgeId = getVertexEdgeEF(p.data(), localEdgeId); + break; + case VertexPosition::BOTTOM_BACK_EDGE_3D: // gh + edgeId = getVertexEdgeGH(p.data(), localEdgeId); + break; + case VertexPosition::LEFT_BACK_EDGE_3D: // eg + edgeId = getVertexEdgeEG(p.data(), localEdgeId); + break; + case VertexPosition::RIGHT_BACK_EDGE_3D: // fh + edgeId = getVertexEdgeFH(p.data(), localEdgeId); + break; + case VertexPosition::TOP_LEFT_EDGE_3D: // ae + edgeId = getVertexEdgeAE(p.data(), localEdgeId); + break; + case VertexPosition::TOP_RIGHT_EDGE_3D: // bf + edgeId = getVertexEdgeBF(p.data(), localEdgeId); + break; + case VertexPosition::BOTTOM_LEFT_EDGE_3D: // cg + edgeId = getVertexEdgeCG(p.data(), localEdgeId); + break; + case VertexPosition::BOTTOM_RIGHT_EDGE_3D: // dh + edgeId = getVertexEdgeDH(p.data(), localEdgeId); + break; + case VertexPosition::TOP_LEFT_FRONT_CORNER_3D: // a + edgeId = getVertexEdgeA(p.data(), localEdgeId); + break; + case VertexPosition::TOP_RIGHT_FRONT_CORNER_3D: // b + edgeId = getVertexEdgeB(p.data(), localEdgeId); + break; + case VertexPosition::BOTTOM_LEFT_FRONT_CORNER_3D: // c + edgeId = getVertexEdgeC(p.data(), localEdgeId); + break; + case VertexPosition::BOTTOM_RIGHT_FRONT_CORNER_3D: // d + edgeId = getVertexEdgeD(p.data(), localEdgeId); + break; + case VertexPosition::TOP_LEFT_BACK_CORNER_3D: // e + edgeId = getVertexEdgeE(p.data(), localEdgeId); + break; + case VertexPosition::TOP_RIGHT_BACK_CORNER_3D: // f + edgeId = getVertexEdgeF(p.data(), localEdgeId); + break; + case VertexPosition::BOTTOM_LEFT_BACK_CORNER_3D: // g + edgeId = getVertexEdgeG(p.data(), localEdgeId); + break; + case VertexPosition::BOTTOM_RIGHT_BACK_CORNER_3D: // h + edgeId = getVertexEdgeH(p.data(), localEdgeId); + break; + case VertexPosition::CENTER_2D: + edgeId = getVertexEdge2dABCD(p.data(), localEdgeId); + break; + case VertexPosition::TOP_EDGE_2D: + edgeId = getVertexEdge2dAB(p.data(), localEdgeId); + break; + case VertexPosition::BOTTOM_EDGE_2D: + edgeId = getVertexEdge2dCD(p.data(), localEdgeId); + break; + case VertexPosition::LEFT_EDGE_2D: + edgeId = getVertexEdge2dAC(p.data(), localEdgeId); + break; + case VertexPosition::RIGHT_EDGE_2D: + edgeId = getVertexEdge2dBD(p.data(), localEdgeId); + break; + case VertexPosition::TOP_LEFT_CORNER_2D: // a + edgeId = getVertexEdge2dA(p.data(), localEdgeId); + break; + case VertexPosition::TOP_RIGHT_CORNER_2D: // b + edgeId = getVertexEdge2dB(p.data(), localEdgeId); + break; + case VertexPosition::BOTTOM_LEFT_CORNER_2D: // c + edgeId = getVertexEdge2dC(p.data(), localEdgeId); + break; + case VertexPosition::BOTTOM_RIGHT_CORNER_2D: // d + edgeId = getVertexEdge2dD(p.data(), localEdgeId); + break; + case VertexPosition::CENTER_1D: + edgeId = (localEdgeId == 0 ? vertexId : vertexId - 1); + break; + case VertexPosition::LEFT_CORNER_1D: + edgeId = vertexId; + break; + case VertexPosition::RIGHT_CORNER_1D: + edgeId = vertexId - 1; + break; + default: + edgeId = -1; + } + + return 0; +} + const vector> * ImplicitTriangulation::getVertexEdgesInternal() { if(vertexEdgeList_.empty()) { @@ -254,6 +550,158 @@ const vector> * return &vertexEdgeList_; } +template +SimplexId ImplicitTriangulationCRTP::getVertexTriangleNumberInternal( + const SimplexId &vertexId) const { +#ifndef TTK_ENABLE_KAMIKAZE + if(vertexId < 0 or vertexId >= vertexNumber_) + return -1; +#endif + + switch(this->underlying().getVertexPosition(vertexId)) { + case VertexPosition::CENTER_3D: + return 36; + case VertexPosition::FRONT_FACE_3D: + case VertexPosition::BACK_FACE_3D: + case VertexPosition::TOP_FACE_3D: + case VertexPosition::BOTTOM_FACE_3D: + case VertexPosition::LEFT_FACE_3D: + case VertexPosition::RIGHT_FACE_3D: + return 21; + case VertexPosition::TOP_FRONT_EDGE_3D: // ab + case VertexPosition::RIGHT_FRONT_EDGE_3D: // bd + case VertexPosition::BOTTOM_BACK_EDGE_3D: // gh + case VertexPosition::LEFT_BACK_EDGE_3D: // eg + case VertexPosition::BOTTOM_LEFT_EDGE_3D: // cg + case VertexPosition::TOP_RIGHT_EDGE_3D: // bf + return 15; + case VertexPosition::TOP_RIGHT_FRONT_CORNER_3D: // b + case VertexPosition::BOTTOM_LEFT_BACK_CORNER_3D: // g + return 12; + case VertexPosition::TOP_BACK_EDGE_3D: // ef + case VertexPosition::BOTTOM_FRONT_EDGE_3D: // cd + case VertexPosition::LEFT_FRONT_EDGE_3D: // ac + case VertexPosition::TOP_LEFT_EDGE_3D: // ae + case VertexPosition::RIGHT_BACK_EDGE_3D: // fh + case VertexPosition::BOTTOM_RIGHT_EDGE_3D: // dh + return 9; + case VertexPosition::TOP_LEFT_FRONT_CORNER_3D: // a + case VertexPosition::BOTTOM_LEFT_FRONT_CORNER_3D: // c + case VertexPosition::BOTTOM_RIGHT_FRONT_CORNER_3D: // d + case VertexPosition::TOP_LEFT_BACK_CORNER_3D: // e + case VertexPosition::TOP_RIGHT_BACK_CORNER_3D: // f + case VertexPosition::BOTTOM_RIGHT_BACK_CORNER_3D: // h + return 5; + default: // 1D + 2D + break; + } + + return 0; +} + +template +int ImplicitTriangulationCRTP::getVertexTriangleInternal( + const SimplexId &vertexId, + const int &localTriangleId, + SimplexId &triangleId) const { +#ifndef TTK_ENABLE_KAMIKAZE + if(localTriangleId < 0 + or localTriangleId >= getVertexTriangleNumberInternal(vertexId)) + return -1; +#endif + + const auto &p = this->underlying().getVertexCoords(vertexId); + + switch(this->underlying().getVertexPosition(vertexId)) { + case VertexPosition::CENTER_3D: + triangleId = getVertexTriangleABCDEFGH(p.data(), localTriangleId); + break; + case VertexPosition::FRONT_FACE_3D: + triangleId = getVertexTriangleABDC(p.data(), localTriangleId); + break; + case VertexPosition::BACK_FACE_3D: + triangleId = getVertexTriangleEFHG(p.data(), localTriangleId); + break; + case VertexPosition::TOP_FACE_3D: + triangleId = getVertexTriangleAEFB(p.data(), localTriangleId); + break; + case VertexPosition::BOTTOM_FACE_3D: + triangleId = getVertexTriangleGHDC(p.data(), localTriangleId); + break; + case VertexPosition::LEFT_FACE_3D: + triangleId = getVertexTriangleAEGC(p.data(), localTriangleId); + break; + case VertexPosition::RIGHT_FACE_3D: + triangleId = getVertexTriangleBFHD(p.data(), localTriangleId); + break; + case VertexPosition::TOP_FRONT_EDGE_3D: // ab + triangleId = getVertexTriangleAB(p.data(), localTriangleId); + break; + case VertexPosition::BOTTOM_FRONT_EDGE_3D: // cd + triangleId = getVertexTriangleCD(p.data(), localTriangleId); + break; + case VertexPosition::LEFT_FRONT_EDGE_3D: // ac + triangleId = getVertexTriangleAC(p.data(), localTriangleId); + break; + case VertexPosition::RIGHT_FRONT_EDGE_3D: // bd + triangleId = getVertexTriangleBD(p.data(), localTriangleId); + break; + case VertexPosition::TOP_BACK_EDGE_3D: // ef + triangleId = getVertexTriangleEF(p.data(), localTriangleId); + break; + case VertexPosition::BOTTOM_BACK_EDGE_3D: // gh + triangleId = getVertexTriangleGH(p.data(), localTriangleId); + break; + case VertexPosition::LEFT_BACK_EDGE_3D: // eg + triangleId = getVertexTriangleEG(p.data(), localTriangleId); + break; + case VertexPosition::RIGHT_BACK_EDGE_3D: // fh + triangleId = getVertexTriangleFH(p.data(), localTriangleId); + break; + case VertexPosition::TOP_LEFT_EDGE_3D: // ae + triangleId = getVertexTriangleAE(p.data(), localTriangleId); + break; + case VertexPosition::TOP_RIGHT_EDGE_3D: // bf + triangleId = getVertexTriangleBF(p.data(), localTriangleId); + break; + case VertexPosition::BOTTOM_LEFT_EDGE_3D: // cg + triangleId = getVertexTriangleCG(p.data(), localTriangleId); + break; + case VertexPosition::BOTTOM_RIGHT_EDGE_3D: // dh + triangleId = getVertexTriangleDH(p.data(), localTriangleId); + break; + case VertexPosition::TOP_LEFT_FRONT_CORNER_3D: // a + triangleId = getVertexTriangleA(p.data(), localTriangleId); + break; + case VertexPosition::TOP_RIGHT_FRONT_CORNER_3D: // b + triangleId = getVertexTriangleB(p.data(), localTriangleId); + break; + case VertexPosition::BOTTOM_LEFT_FRONT_CORNER_3D: // c + triangleId = getVertexTriangleC(p.data(), localTriangleId); + break; + case VertexPosition::BOTTOM_RIGHT_FRONT_CORNER_3D: // d + triangleId = getVertexTriangleD(p.data(), localTriangleId); + break; + case VertexPosition::TOP_LEFT_BACK_CORNER_3D: // e + triangleId = getVertexTriangleE(p.data(), localTriangleId); + break; + case VertexPosition::TOP_RIGHT_BACK_CORNER_3D: // f + triangleId = getVertexTriangleF(p.data(), localTriangleId); + break; + case VertexPosition::BOTTOM_LEFT_BACK_CORNER_3D: // g + triangleId = getVertexTriangleG(p.data(), localTriangleId); + break; + case VertexPosition::BOTTOM_RIGHT_BACK_CORNER_3D: // h + triangleId = getVertexTriangleH(p.data(), localTriangleId); + break; + default: // 1D + 2D + triangleId = -1; + break; + } + + return 0; +} + const vector> * ImplicitTriangulation::getVertexTrianglesInternal() { if(vertexTriangleList_.empty()) { @@ -273,6 +721,141 @@ const vector> * return &vertexTriangleList_; } +SimplexId ImplicitTriangulation::TTK_TRIANGULATION_INTERNAL( + getVertexLinkNumber)(const SimplexId &vertexId) const { + return TTK_TRIANGULATION_INTERNAL(getVertexStarNumber)(vertexId); +} + +template +int ImplicitTriangulationCRTP::TTK_TRIANGULATION_INTERNAL( + getVertexLink)(const SimplexId &vertexId, + const int &localLinkId, + SimplexId &linkId) const { + +#ifndef TTK_ENABLE_KAMIKAZE + if(localLinkId < 0 or localLinkId >= getVertexLinkNumber(vertexId)) + return -1; +#endif // !TTK_ENABLE_KAMIKAZE + + const auto &p = this->underlying().getVertexCoords(vertexId); + + switch(this->underlying().getVertexPosition(vertexId)) { + case VertexPosition::CENTER_3D: + linkId = getVertexLinkABCDEFGH(p.data(), localLinkId); + break; + case VertexPosition::FRONT_FACE_3D: + linkId = getVertexLinkABDC(p.data(), localLinkId); + break; + case VertexPosition::BACK_FACE_3D: + linkId = getVertexLinkEFHG(p.data(), localLinkId); + break; + case VertexPosition::TOP_FACE_3D: + linkId = getVertexLinkAEFB(p.data(), localLinkId); + break; + case VertexPosition::BOTTOM_FACE_3D: + linkId = getVertexLinkGHDC(p.data(), localLinkId); + break; + case VertexPosition::LEFT_FACE_3D: + linkId = getVertexLinkAEGC(p.data(), localLinkId); + break; + case VertexPosition::RIGHT_FACE_3D: + linkId = getVertexLinkBFHD(p.data(), localLinkId); + break; + case VertexPosition::TOP_FRONT_EDGE_3D: // ab + linkId = getVertexLinkAB(p.data(), localLinkId); + break; + case VertexPosition::BOTTOM_FRONT_EDGE_3D: // cd + linkId = getVertexLinkCD(p.data(), localLinkId); + break; + case VertexPosition::LEFT_FRONT_EDGE_3D: // ac + linkId = getVertexLinkAC(p.data(), localLinkId); + break; + case VertexPosition::RIGHT_FRONT_EDGE_3D: // bd + linkId = getVertexLinkBD(p.data(), localLinkId); + break; + case VertexPosition::TOP_BACK_EDGE_3D: // ef + linkId = getVertexLinkEF(p.data(), localLinkId); + break; + case VertexPosition::BOTTOM_BACK_EDGE_3D: // gh + linkId = getVertexLinkGH(p.data(), localLinkId); + break; + case VertexPosition::LEFT_BACK_EDGE_3D: // eg + linkId = getVertexLinkEG(p.data(), localLinkId); + break; + case VertexPosition::RIGHT_BACK_EDGE_3D: // fh + linkId = getVertexLinkFH(p.data(), localLinkId); + break; + case VertexPosition::TOP_LEFT_EDGE_3D: // ae + linkId = getVertexLinkAE(p.data(), localLinkId); + break; + case VertexPosition::TOP_RIGHT_EDGE_3D: // bf + linkId = getVertexLinkBF(p.data(), localLinkId); + break; + case VertexPosition::BOTTOM_LEFT_EDGE_3D: // cg + linkId = getVertexLinkCG(p.data(), localLinkId); + break; + case VertexPosition::BOTTOM_RIGHT_EDGE_3D: // dh + linkId = getVertexLinkDH(p.data(), localLinkId); + break; + case VertexPosition::TOP_LEFT_FRONT_CORNER_3D: // a + linkId = getVertexLinkA(p.data(), localLinkId); + break; + case VertexPosition::TOP_RIGHT_FRONT_CORNER_3D: // b + linkId = getVertexLinkB(p.data(), localLinkId); + break; + case VertexPosition::BOTTOM_LEFT_FRONT_CORNER_3D: // c + linkId = getVertexLinkC(p.data(), localLinkId); + break; + case VertexPosition::BOTTOM_RIGHT_FRONT_CORNER_3D: // d + linkId = getVertexLinkD(p.data(), localLinkId); + break; + case VertexPosition::TOP_LEFT_BACK_CORNER_3D: // e + linkId = getVertexLinkE(p.data(), localLinkId); + break; + case VertexPosition::TOP_RIGHT_BACK_CORNER_3D: // f + linkId = getVertexLinkF(p.data(), localLinkId); + break; + case VertexPosition::BOTTOM_LEFT_BACK_CORNER_3D: // g + linkId = getVertexLinkG(p.data(), localLinkId); + break; + case VertexPosition::BOTTOM_RIGHT_BACK_CORNER_3D: // h + linkId = getVertexLinkH(p.data(), localLinkId); + break; + case VertexPosition::CENTER_2D: + linkId = getVertexLink2dABCD(p.data(), localLinkId); + break; + case VertexPosition::TOP_EDGE_2D: + linkId = getVertexLink2dAB(p.data(), localLinkId); + break; + case VertexPosition::BOTTOM_EDGE_2D: + linkId = getVertexLink2dCD(p.data(), localLinkId); + break; + case VertexPosition::LEFT_EDGE_2D: + linkId = getVertexLink2dAC(p.data(), localLinkId); + break; + case VertexPosition::RIGHT_EDGE_2D: + linkId = getVertexLink2dBD(p.data(), localLinkId); + break; + case VertexPosition::TOP_LEFT_CORNER_2D: // a + linkId = getVertexLink2dA(p.data(), localLinkId); + break; + case VertexPosition::TOP_RIGHT_CORNER_2D: // b + linkId = getVertexLink2dB(p.data(), localLinkId); + break; + case VertexPosition::BOTTOM_LEFT_CORNER_2D: // c + linkId = getVertexLink2dC(p.data(), localLinkId); + break; + case VertexPosition::BOTTOM_RIGHT_CORNER_2D: // d + linkId = getVertexLink2dD(p.data(), localLinkId); + break; + default: // 1D + linkId = -1; + break; + }; + + return 0; +} + const vector> * ImplicitTriangulation::TTK_TRIANGULATION_INTERNAL(getVertexLinks)() { if(vertexLinkList_.empty()) { @@ -292,6 +875,197 @@ const vector> * return &vertexLinkList_; } +template +SimplexId ImplicitTriangulationCRTP::TTK_TRIANGULATION_INTERNAL( + getVertexStarNumber)(const SimplexId &vertexId) const { + +#ifndef TTK_ENABLE_KAMIKAZE + if(vertexId < 0 or vertexId >= vertexNumber_) + return -1; +#endif // !TTK_ENABLE_KAMIKAZE + + switch(this->underlying().getVertexPosition(vertexId)) { + case VertexPosition::CENTER_3D: + return 24; + case VertexPosition::FRONT_FACE_3D: + case VertexPosition::BACK_FACE_3D: + case VertexPosition::TOP_FACE_3D: + case VertexPosition::BOTTOM_FACE_3D: + case VertexPosition::LEFT_FACE_3D: + case VertexPosition::RIGHT_FACE_3D: + return 12; + case VertexPosition::TOP_FRONT_EDGE_3D: // ab + case VertexPosition::RIGHT_FRONT_EDGE_3D: // bd + case VertexPosition::BOTTOM_BACK_EDGE_3D: // gh + case VertexPosition::LEFT_BACK_EDGE_3D: // eg + case VertexPosition::BOTTOM_LEFT_EDGE_3D: // cg + case VertexPosition::TOP_RIGHT_EDGE_3D: // bf + return 8; + case VertexPosition::TOP_RIGHT_FRONT_CORNER_3D: // b + case VertexPosition::BOTTOM_LEFT_BACK_CORNER_3D: // g + case VertexPosition::CENTER_2D: + return 6; + case VertexPosition::TOP_BACK_EDGE_3D: // ef + case VertexPosition::BOTTOM_FRONT_EDGE_3D: // cd + case VertexPosition::LEFT_FRONT_EDGE_3D: // ac + case VertexPosition::TOP_LEFT_EDGE_3D: // ae + case VertexPosition::RIGHT_BACK_EDGE_3D: // fh + case VertexPosition::BOTTOM_RIGHT_EDGE_3D: // dh + return 4; + case VertexPosition::TOP_EDGE_2D: // ab + case VertexPosition::BOTTOM_EDGE_2D: // cd + case VertexPosition::LEFT_EDGE_2D: // ac + case VertexPosition::RIGHT_EDGE_2D: // bd + return 3; + case VertexPosition::TOP_LEFT_FRONT_CORNER_3D: // a + case VertexPosition::BOTTOM_LEFT_FRONT_CORNER_3D: // c + case VertexPosition::BOTTOM_RIGHT_FRONT_CORNER_3D: // d + case VertexPosition::TOP_LEFT_BACK_CORNER_3D: // e + case VertexPosition::TOP_RIGHT_BACK_CORNER_3D: // f + case VertexPosition::BOTTOM_RIGHT_BACK_CORNER_3D: // h + case VertexPosition::TOP_RIGHT_CORNER_2D: // b + case VertexPosition::BOTTOM_LEFT_CORNER_2D: // c + return 2; + case VertexPosition::TOP_LEFT_CORNER_2D: // a + case VertexPosition::BOTTOM_RIGHT_CORNER_2D: // d + return 1; + default: // 1D + break; + } + + return 0; +} + +template +int ImplicitTriangulationCRTP::TTK_TRIANGULATION_INTERNAL( + getVertexStar)(const SimplexId &vertexId, + const int &localStarId, + SimplexId &starId) const { + +#ifndef TTK_ENABLE_KAMIKAZE + if(localStarId < 0 or localStarId >= getVertexStarNumber(vertexId)) + return -1; +#endif // !TTK_ENABLE_KAMIKAZE + + const auto &p = this->underlying().getVertexCoords(vertexId); + + switch(this->underlying().getVertexPosition(vertexId)) { + case VertexPosition::CENTER_3D: + starId = getVertexStarABCDEFGH(p.data(), localStarId); + break; + case VertexPosition::FRONT_FACE_3D: + starId = getVertexStarABDC(p.data(), localStarId); + break; + case VertexPosition::BACK_FACE_3D: + starId = getVertexStarEFHG(p.data(), localStarId); + break; + case VertexPosition::TOP_FACE_3D: + starId = getVertexStarAEFB(p.data(), localStarId); + break; + case VertexPosition::BOTTOM_FACE_3D: + starId = getVertexStarGHDC(p.data(), localStarId); + break; + case VertexPosition::LEFT_FACE_3D: + starId = getVertexStarAEGC(p.data(), localStarId); + break; + case VertexPosition::RIGHT_FACE_3D: + starId = getVertexStarBFHD(p.data(), localStarId); + break; + case VertexPosition::TOP_FRONT_EDGE_3D: // ab + starId = getVertexStarAB(p.data(), localStarId); + break; + case VertexPosition::BOTTOM_FRONT_EDGE_3D: // cd + starId = getVertexStarCD(p.data(), localStarId); + break; + case VertexPosition::LEFT_FRONT_EDGE_3D: // ac + starId = getVertexStarAC(p.data(), localStarId); + break; + case VertexPosition::RIGHT_FRONT_EDGE_3D: // bd + starId = getVertexStarBD(p.data(), localStarId); + break; + case VertexPosition::TOP_BACK_EDGE_3D: // ef + starId = getVertexStarEF(p.data(), localStarId); + break; + case VertexPosition::BOTTOM_BACK_EDGE_3D: // gh + starId = getVertexStarGH(p.data(), localStarId); + break; + case VertexPosition::LEFT_BACK_EDGE_3D: // eg + starId = getVertexStarEG(p.data(), localStarId); + break; + case VertexPosition::RIGHT_BACK_EDGE_3D: // fh + starId = getVertexStarFH(p.data(), localStarId); + break; + case VertexPosition::TOP_LEFT_EDGE_3D: // ae + starId = getVertexStarAE(p.data(), localStarId); + break; + case VertexPosition::TOP_RIGHT_EDGE_3D: // bf + starId = getVertexStarBF(p.data(), localStarId); + break; + case VertexPosition::BOTTOM_LEFT_EDGE_3D: // cg + starId = getVertexStarCG(p.data(), localStarId); + break; + case VertexPosition::BOTTOM_RIGHT_EDGE_3D: // dh + starId = getVertexStarDH(p.data(), localStarId); + break; + case VertexPosition::TOP_LEFT_FRONT_CORNER_3D: // a + starId = getVertexStarA(p.data(), localStarId); + break; + case VertexPosition::TOP_RIGHT_FRONT_CORNER_3D: // b + starId = getVertexStarB(p.data(), localStarId); + break; + case VertexPosition::BOTTOM_LEFT_FRONT_CORNER_3D: // c + starId = getVertexStarC(p.data(), localStarId); + break; + case VertexPosition::BOTTOM_RIGHT_FRONT_CORNER_3D: // d + starId = getVertexStarD(p.data(), localStarId); + break; + case VertexPosition::TOP_LEFT_BACK_CORNER_3D: // e + starId = getVertexStarE(p.data(), localStarId); + break; + case VertexPosition::TOP_RIGHT_BACK_CORNER_3D: // f + starId = getVertexStarF(p.data(), localStarId); + break; + case VertexPosition::BOTTOM_LEFT_BACK_CORNER_3D: // g + starId = getVertexStarG(p.data(), localStarId); + break; + case VertexPosition::BOTTOM_RIGHT_BACK_CORNER_3D: // h + starId = getVertexStarH(p.data(), localStarId); + break; + case VertexPosition::CENTER_2D: + starId = getVertexStar2dABCD(p.data(), localStarId); + break; + case VertexPosition::TOP_EDGE_2D: + starId = getVertexStar2dAB(p.data(), localStarId); + break; + case VertexPosition::BOTTOM_EDGE_2D: + starId = getVertexStar2dCD(p.data(), localStarId); + break; + case VertexPosition::LEFT_EDGE_2D: + starId = getVertexStar2dAC(p.data(), localStarId); + break; + case VertexPosition::RIGHT_EDGE_2D: + starId = getVertexStar2dBD(p.data(), localStarId); + break; + case VertexPosition::TOP_LEFT_CORNER_2D: // a + starId = getVertexStar2dA(p.data(), localStarId); + break; + case VertexPosition::TOP_RIGHT_CORNER_2D: // b + starId = getVertexStar2dB(p.data(), localStarId); + break; + case VertexPosition::BOTTOM_LEFT_CORNER_2D: // c + starId = getVertexStar2dC(p.data(), localStarId); + break; + case VertexPosition::BOTTOM_RIGHT_CORNER_2D: // d + starId = getVertexStar2dD(p.data(), localStarId); + break; + default: // 1D + starId = -1; + break; + } + + return 0; +} + const vector> * ImplicitTriangulation::TTK_TRIANGULATION_INTERNAL(getVertexStars)() { @@ -311,6 +1085,135 @@ const vector> * return &vertexStarList_; } +template +int ImplicitTriangulationCRTP::TTK_TRIANGULATION_INTERNAL( + getVertexPoint)(const SimplexId &vertexId, + float &x, + float &y, + float &z) const { + + if(dimensionality_ == 3) { + const auto &p = this->underlying().getVertexCoords(vertexId); + + x = origin_[0] + spacing_[0] * p[0]; + y = origin_[1] + spacing_[1] * p[1]; + z = origin_[2] + spacing_[2] * p[2]; + } else if(dimensionality_ == 2) { + const auto &p = this->underlying().getVertexCoords(vertexId); + + if(dimensions_[0] > 1 and dimensions_[1] > 1) { + x = origin_[0] + spacing_[0] * p[0]; + y = origin_[1] + spacing_[1] * p[1]; + z = origin_[2]; + } else if(dimensions_[1] > 1 and dimensions_[2] > 1) { + x = origin_[0]; + y = origin_[1] + spacing_[1] * p[0]; + z = origin_[2] + spacing_[2] * p[1]; + } else if(dimensions_[0] > 1 and dimensions_[2] > 1) { + x = origin_[0] + spacing_[0] * p[0]; + y = origin_[1]; + z = origin_[2] + spacing_[2] * p[1]; + } + } else if(dimensionality_ == 1) { + if(dimensions_[0] > 1) { + x = origin_[0] + spacing_[0] * vertexId; + y = origin_[1]; + z = origin_[2]; + } else if(dimensions_[1] > 1) { + x = origin_[0]; + y = origin_[1] + spacing_[1] * vertexId; + z = origin_[2]; + } else if(dimensions_[2] > 1) { + x = origin_[0]; + y = origin_[1]; + z = origin_[2] + spacing_[2] * vertexId; + } + } + + return 0; +} + +template +int ImplicitTriangulationCRTP::getEdgeVertexInternal( + const SimplexId &edgeId, + const int &localVertexId, + SimplexId &vertexId) const { +#ifndef TTK_ENABLE_KAMIKAZE + if(edgeId < 0 or edgeId >= edgeNumber_) + return -1; + if(localVertexId < 0 or localVertexId >= 2) + return -2; +#endif + + const auto &p = this->underlying().getEdgeCoords(edgeId); + + const auto helper3d = [&](const SimplexId a, const SimplexId b) -> SimplexId { + if(isAccelerated_) { + const auto tmp = p[0] + (p[1] << div_[0]) + (p[2] << div_[1]); + return (localVertexId == 0) ? tmp + a : tmp + b; + } else { + const auto tmp = p[0] + (p[1] * vshift_[0]) + (p[2] * vshift_[1]); + return (localVertexId == 0) ? tmp + a : tmp + b; + } + }; + + const auto helper2d = [&](const SimplexId a, const SimplexId b) -> SimplexId { + if(isAccelerated_) { + const auto tmp = p[0] + (p[1] << div_[0]); + return localVertexId == 0 ? tmp + a : tmp + b; + } else { + const auto tmp = p[0] + (p[1] * vshift_[0]); + return localVertexId == 0 ? tmp + a : tmp + b; + } + }; + + switch(this->underlying().getEdgePosition(edgeId)) { + CASE_EDGE_POSITION_L_3D: + vertexId = helper3d(0, 1); + break; + CASE_EDGE_POSITION_H_3D: + vertexId = helper3d(0, vshift_[0]); + break; + CASE_EDGE_POSITION_P_3D: + vertexId = helper3d(0, vshift_[1]); + break; + CASE_EDGE_POSITION_D1_3D: + vertexId = helper3d(1, vshift_[0]); + break; + CASE_EDGE_POSITION_D2_3D: + vertexId = helper3d(0, vshift_[0] + vshift_[1]); + break; + CASE_EDGE_POSITION_D3_3D: + vertexId = helper3d(1, vshift_[1]); + break; + case EdgePosition::D4_3D: + vertexId = helper3d(1, vshift_[0] + vshift_[1]); + break; + + CASE_EDGE_POSITION_L_2D: + vertexId = helper2d(0, 1); + break; + CASE_EDGE_POSITION_H_2D: + vertexId = helper2d(0, vshift_[0]); + break; + case EdgePosition::D1_2D: + vertexId = helper2d(1, vshift_[0]); + break; + + case EdgePosition::FIRST_EDGE_1D: + vertexId = localVertexId == 0 ? 0 : 1; + break; + case EdgePosition::LAST_EDGE_1D: + vertexId = localVertexId == 0 ? edgeNumber_ - 1 : edgeNumber_; + break; + case EdgePosition::CENTER_1D: + vertexId = localVertexId == 0 ? edgeId : edgeId + 1; + break; + } + + return 0; +} + const vector> * ImplicitTriangulation::TTK_TRIANGULATION_INTERNAL(getEdges)() { @@ -332,6 +1235,228 @@ const vector> * return &edgeList_; } +template +SimplexId ImplicitTriangulationCRTP::getEdgeTriangleNumberInternal( + const SimplexId &edgeId) const { +#ifndef TTK_ENABLE_KAMIKAZE + if(edgeId < 0 or edgeId >= edgeNumber_) + return -1; +#endif + + switch(this->underlying().getEdgePosition(edgeId)) { + case EdgePosition::L_xnn_3D: + case EdgePosition::H_nyn_3D: + case EdgePosition::P_nnz_3D: + case EdgePosition::D4_3D: + return 6; + case EdgePosition::L_x0n_3D: + case EdgePosition::L_xNn_3D: + case EdgePosition::L_xn0_3D: + case EdgePosition::L_xnN_3D: + case EdgePosition::H_ny0_3D: + case EdgePosition::H_nyN_3D: + case EdgePosition::H_0yn_3D: + case EdgePosition::H_Nyn_3D: + case EdgePosition::P_n0z_3D: + case EdgePosition::P_nNz_3D: + case EdgePosition::P_0nz_3D: + case EdgePosition::P_Nnz_3D: + case EdgePosition::D1_xyn_3D: + case EdgePosition::D2_nyz_3D: + case EdgePosition::D3_xnz_3D: + return 4; + case EdgePosition::L_x00_3D: + case EdgePosition::L_xNN_3D: + case EdgePosition::H_0yN_3D: + case EdgePosition::H_Ny0_3D: + case EdgePosition::P_0Nz_3D: + case EdgePosition::P_N0z_3D: + case EdgePosition::D1_xy0_3D: + case EdgePosition::D1_xyN_3D: + case EdgePosition::D2_0yz_3D: + case EdgePosition::D2_Nyz_3D: + case EdgePosition::D3_x0z_3D: + case EdgePosition::D3_xNz_3D: + return 3; + case EdgePosition::L_xN0_3D: + case EdgePosition::L_x0N_3D: + case EdgePosition::H_0y0_3D: + case EdgePosition::H_NyN_3D: + case EdgePosition::P_00z_3D: + case EdgePosition::P_NNz_3D: + case EdgePosition::L_xn_2D: + case EdgePosition::H_ny_2D: + case EdgePosition::D1_2D: + return 2; + case EdgePosition::L_x0_2D: + case EdgePosition::L_xN_2D: + case EdgePosition::H_0y_2D: + case EdgePosition::H_Ny_2D: + return 1; + + default: // 1D + break; + } + + return 0; +} + +template +int ImplicitTriangulationCRTP::getEdgeTriangleInternal( + const SimplexId &edgeId, + const int &localTriangleId, + SimplexId &triangleId) const { +#ifndef TTK_ENABLE_KAMIKAZE + if(localTriangleId < 0 + or localTriangleId >= getEdgeTriangleNumberInternal(edgeId)) + return -1; +#endif + + const auto &p = this->underlying().getEdgeCoords(edgeId); + + switch(this->underlying().getEdgePosition(edgeId)) { + case EdgePosition::L_xnn_3D: + triangleId = getEdgeTriangleL_xnn(p.data(), localTriangleId); + break; + case EdgePosition::L_xn0_3D: + triangleId = getEdgeTriangleL_xn0(p.data(), localTriangleId); + break; + case EdgePosition::L_xnN_3D: + triangleId = getEdgeTriangleL_xnN(p.data(), localTriangleId); + break; + case EdgePosition::L_x0n_3D: + triangleId = getEdgeTriangleL_x0n(p.data(), localTriangleId); + break; + case EdgePosition::L_x00_3D: + triangleId = getEdgeTriangleL_x00(p.data(), localTriangleId); + break; + case EdgePosition::L_x0N_3D: + triangleId = getEdgeTriangleL_x0N(p.data(), localTriangleId); + break; + case EdgePosition::L_xNn_3D: + triangleId = getEdgeTriangleL_xNn(p.data(), localTriangleId); + break; + case EdgePosition::L_xN0_3D: + triangleId = getEdgeTriangleL_xN0(p.data(), localTriangleId); + break; + case EdgePosition::L_xNN_3D: + triangleId = getEdgeTriangleL_xNN(p.data(), localTriangleId); + break; + case EdgePosition::H_nyn_3D: + triangleId = getEdgeTriangleH_nyn(p.data(), localTriangleId); + break; + case EdgePosition::H_ny0_3D: + triangleId = getEdgeTriangleH_ny0(p.data(), localTriangleId); + break; + case EdgePosition::H_nyN_3D: + triangleId = getEdgeTriangleH_nyN(p.data(), localTriangleId); + break; + case EdgePosition::H_0yn_3D: + triangleId = getEdgeTriangleH_0yn(p.data(), localTriangleId); + break; + case EdgePosition::H_0y0_3D: + triangleId = getEdgeTriangleH_0y0(p.data(), localTriangleId); + break; + case EdgePosition::H_0yN_3D: + triangleId = getEdgeTriangleH_0yN(p.data(), localTriangleId); + break; + case EdgePosition::H_Nyn_3D: + triangleId = getEdgeTriangleH_Nyn(p.data(), localTriangleId); + break; + case EdgePosition::H_Ny0_3D: + triangleId = getEdgeTriangleH_Ny0(p.data(), localTriangleId); + break; + case EdgePosition::H_NyN_3D: + triangleId = getEdgeTriangleH_NyN(p.data(), localTriangleId); + break; + case EdgePosition::P_nnz_3D: + triangleId = getEdgeTriangleP_nnz(p.data(), localTriangleId); + break; + case EdgePosition::P_n0z_3D: + triangleId = getEdgeTriangleP_n0z(p.data(), localTriangleId); + break; + case EdgePosition::P_nNz_3D: + triangleId = getEdgeTriangleP_nNz(p.data(), localTriangleId); + break; + case EdgePosition::P_0nz_3D: + triangleId = getEdgeTriangleP_0nz(p.data(), localTriangleId); + break; + case EdgePosition::P_00z_3D: + triangleId = getEdgeTriangleP_00z(p.data(), localTriangleId); + break; + case EdgePosition::P_0Nz_3D: + triangleId = getEdgeTriangleP_0Nz(p.data(), localTriangleId); + break; + case EdgePosition::P_Nnz_3D: + triangleId = getEdgeTriangleP_Nnz(p.data(), localTriangleId); + break; + case EdgePosition::P_N0z_3D: + triangleId = getEdgeTriangleP_N0z(p.data(), localTriangleId); + break; + case EdgePosition::P_NNz_3D: + triangleId = getEdgeTriangleP_NNz(p.data(), localTriangleId); + break; + case EdgePosition::D1_xyn_3D: + triangleId = getEdgeTriangleD1_xyn(p.data(), localTriangleId); + break; + case EdgePosition::D1_xy0_3D: + triangleId = getEdgeTriangleD1_xy0(p.data(), localTriangleId); + break; + case EdgePosition::D1_xyN_3D: + triangleId = getEdgeTriangleD1_xyN(p.data(), localTriangleId); + break; + case EdgePosition::D2_nyz_3D: + triangleId = getEdgeTriangleD2_nyz(p.data(), localTriangleId); + break; + case EdgePosition::D2_0yz_3D: + triangleId = getEdgeTriangleD2_0yz(p.data(), localTriangleId); + break; + case EdgePosition::D2_Nyz_3D: + triangleId = getEdgeTriangleD2_Nyz(p.data(), localTriangleId); + break; + case EdgePosition::D3_xnz_3D: + triangleId = getEdgeTriangleD3_xnz(p.data(), localTriangleId); + break; + case EdgePosition::D3_x0z_3D: + triangleId = getEdgeTriangleD3_x0z(p.data(), localTriangleId); + break; + case EdgePosition::D3_xNz_3D: + triangleId = getEdgeTriangleD3_xNz(p.data(), localTriangleId); + break; + case EdgePosition::D4_3D: + triangleId = getEdgeTriangleD4_xyz(p.data(), localTriangleId); + break; + + case EdgePosition::L_xn_2D: + triangleId = getEdgeTriangleL_xn(p.data(), localTriangleId); + break; + case EdgePosition::L_x0_2D: + triangleId = getEdgeTriangleL_x0(p.data(), localTriangleId); + break; + case EdgePosition::L_xN_2D: + triangleId = getEdgeTriangleL_xN(p.data(), localTriangleId); + break; + case EdgePosition::H_ny_2D: + triangleId = getEdgeTriangleH_ny(p.data(), localTriangleId); + break; + case EdgePosition::H_0y_2D: + triangleId = getEdgeTriangleH_0y(p.data(), localTriangleId); + break; + case EdgePosition::H_Ny_2D: + triangleId = getEdgeTriangleH_Ny(p.data(), localTriangleId); + break; + case EdgePosition::D1_2D: + triangleId = getEdgeTriangleD1_xy(p.data(), localTriangleId); + break; + + default: // 1D + triangleId = -1; + break; + } + + return 0; +} + const vector> * ImplicitTriangulation::getEdgeTrianglesInternal() { if(edgeTriangleList_.empty()) { @@ -351,6 +1476,63 @@ const vector> * return &edgeTriangleList_; } +SimplexId ImplicitTriangulation::TTK_TRIANGULATION_INTERNAL(getEdgeLinkNumber)( + const SimplexId &edgeId) const { + return TTK_TRIANGULATION_INTERNAL(getEdgeStarNumber)(edgeId); +} + +template +int ImplicitTriangulationCRTP::TTK_TRIANGULATION_INTERNAL(getEdgeLink)( + const SimplexId &edgeId, const int &localLinkId, SimplexId &linkId) const { + +#ifndef TTK_ENABLE_KAMIKAZE + if(localLinkId < 0 or localLinkId >= getEdgeLinkNumber(edgeId)) + return -1; +#endif + + const auto &p = this->underlying().getEdgeCoords(edgeId); + + switch(this->underlying().getEdgePosition(edgeId)) { + CASE_EDGE_POSITION_L_3D: + linkId = getEdgeLinkL(p.data(), localLinkId); + break; + CASE_EDGE_POSITION_H_3D: + linkId = getEdgeLinkH(p.data(), localLinkId); + break; + CASE_EDGE_POSITION_P_3D: + linkId = getEdgeLinkP(p.data(), localLinkId); + break; + CASE_EDGE_POSITION_D1_3D: + linkId = getEdgeLinkD1(p.data(), localLinkId); + break; + CASE_EDGE_POSITION_D2_3D: + linkId = getEdgeLinkD2(p.data(), localLinkId); + break; + CASE_EDGE_POSITION_D3_3D: + linkId = getEdgeLinkD3(p.data(), localLinkId); + break; + case EdgePosition::D4_3D: + linkId = getEdgeLinkD4(p.data(), localLinkId); + break; + + CASE_EDGE_POSITION_L_2D: + linkId = getEdgeLink2dL(p.data(), localLinkId); + break; + CASE_EDGE_POSITION_H_2D: + linkId = getEdgeLink2dH(p.data(), localLinkId); + break; + case EdgePosition::D1_2D: + linkId = getEdgeLink2dD1(p.data(), localLinkId); + break; + + default: // 1D + linkId = -1; + break; + } + + return 0; +} + const vector> * ImplicitTriangulation::TTK_TRIANGULATION_INTERNAL(getEdgeLinks)() { @@ -371,6 +1553,126 @@ const vector> * return &edgeLinkList_; } +template +SimplexId ImplicitTriangulationCRTP::TTK_TRIANGULATION_INTERNAL( + getEdgeStarNumber)(const SimplexId &edgeId) const { + +#ifndef TTK_ENABLE_KAMIKAZE + if(edgeId < 0 or edgeId >= edgeNumber_) + return -1; +#endif + + switch(this->underlying().getEdgePosition(edgeId)) { + case EdgePosition::L_xnn_3D: + case EdgePosition::H_nyn_3D: + case EdgePosition::P_nnz_3D: + case EdgePosition::D4_3D: + return 6; + case EdgePosition::D1_xyn_3D: + case EdgePosition::D2_nyz_3D: + case EdgePosition::D3_xnz_3D: + return 4; + case EdgePosition::L_x0n_3D: + case EdgePosition::L_xNn_3D: + case EdgePosition::L_xn0_3D: + case EdgePosition::L_xnN_3D: + case EdgePosition::H_ny0_3D: + case EdgePosition::H_nyN_3D: + case EdgePosition::H_0yn_3D: + case EdgePosition::H_Nyn_3D: + case EdgePosition::P_n0z_3D: + case EdgePosition::P_nNz_3D: + case EdgePosition::P_0nz_3D: + case EdgePosition::P_Nnz_3D: + return 3; + case EdgePosition::L_x00_3D: + case EdgePosition::L_xNN_3D: + case EdgePosition::H_0yN_3D: + case EdgePosition::H_Ny0_3D: + case EdgePosition::P_0Nz_3D: + case EdgePosition::P_N0z_3D: + case EdgePosition::D1_xy0_3D: + case EdgePosition::D1_xyN_3D: + case EdgePosition::D2_0yz_3D: + case EdgePosition::D2_Nyz_3D: + case EdgePosition::D3_x0z_3D: + case EdgePosition::D3_xNz_3D: + case EdgePosition::L_xn_2D: + case EdgePosition::H_ny_2D: + case EdgePosition::D1_2D: + return 2; + case EdgePosition::L_xN0_3D: + case EdgePosition::L_x0N_3D: + case EdgePosition::H_0y0_3D: + case EdgePosition::H_NyN_3D: + case EdgePosition::P_00z_3D: + case EdgePosition::P_NNz_3D: + case EdgePosition::L_x0_2D: + case EdgePosition::L_xN_2D: + case EdgePosition::H_0y_2D: + case EdgePosition::H_Ny_2D: + return 1; + + default: // 1D + break; + } + + return 0; +} + +template +int ImplicitTriangulationCRTP::TTK_TRIANGULATION_INTERNAL(getEdgeStar)( + const SimplexId &edgeId, const int &localStarId, SimplexId &starId) const { + +#ifndef TTK_ENABLE_KAMIKAZE + if(localStarId < 0 or localStarId >= getEdgeStarNumber(edgeId)) + return -1; +#endif + + const auto &p = this->underlying().getEdgeCoords(edgeId); + + switch(this->underlying().getEdgePosition(edgeId)) { + CASE_EDGE_POSITION_L_3D: + starId = getEdgeStarL(p.data(), localStarId); + break; + CASE_EDGE_POSITION_H_3D: + starId = getEdgeStarH(p.data(), localStarId); + break; + CASE_EDGE_POSITION_P_3D: + starId = getEdgeStarP(p.data(), localStarId); + break; + CASE_EDGE_POSITION_D1_3D: + starId = getEdgeStarD1(p.data(), localStarId); + break; + CASE_EDGE_POSITION_D2_3D: + starId = getEdgeStarD2(p.data(), localStarId); + break; + CASE_EDGE_POSITION_D3_3D: + starId = getEdgeStarD3(p.data(), localStarId); + break; + case EdgePosition::D4_3D: + starId + = p[2] * tetshift_[1] + p[1] * tetshift_[0] + p[0] * 6 + localStarId; + break; + + CASE_EDGE_POSITION_L_2D: + starId = getEdgeStar2dL(p.data(), localStarId); + break; + CASE_EDGE_POSITION_H_2D: + starId = getEdgeStar2dH(p.data(), localStarId); + break; + case EdgePosition::D1_2D: + starId = p[0] * 2 + p[1] * tshift_[0] + localStarId; + break; + + default: // 1D + starId = -1; + break; + } + + return 0; +} + const vector> * ImplicitTriangulation::TTK_TRIANGULATION_INTERNAL(getEdgeStars)() { diff --git a/core/base/implicitTriangulation/ImplicitTriangulation.h b/core/base/implicitTriangulation/ImplicitTriangulation.h index 370315bb93..daa8f69d75 100644 --- a/core/base/implicitTriangulation/ImplicitTriangulation.h +++ b/core/base/implicitTriangulation/ImplicitTriangulation.h @@ -15,57 +15,6 @@ // base code includes #include -#define CASE_EDGE_POSITION_L_3D \ - case EdgePosition::L_xnn_3D: \ - case EdgePosition::L_xn0_3D: \ - case EdgePosition::L_xnN_3D: \ - case EdgePosition::L_x0n_3D: \ - case EdgePosition::L_x00_3D: \ - case EdgePosition::L_x0N_3D: \ - case EdgePosition::L_xNn_3D: \ - case EdgePosition::L_xN0_3D: \ - case EdgePosition::L_xNN_3D -#define CASE_EDGE_POSITION_H_3D \ - case EdgePosition::H_nyn_3D: \ - case EdgePosition::H_ny0_3D: \ - case EdgePosition::H_nyN_3D: \ - case EdgePosition::H_0yn_3D: \ - case EdgePosition::H_0y0_3D: \ - case EdgePosition::H_0yN_3D: \ - case EdgePosition::H_Nyn_3D: \ - case EdgePosition::H_Ny0_3D: \ - case EdgePosition::H_NyN_3D -#define CASE_EDGE_POSITION_P_3D \ - case EdgePosition::P_nnz_3D: \ - case EdgePosition::P_n0z_3D: \ - case EdgePosition::P_nNz_3D: \ - case EdgePosition::P_0nz_3D: \ - case EdgePosition::P_00z_3D: \ - case EdgePosition::P_0Nz_3D: \ - case EdgePosition::P_Nnz_3D: \ - case EdgePosition::P_N0z_3D: \ - case EdgePosition::P_NNz_3D -#define CASE_EDGE_POSITION_D1_3D \ - case EdgePosition::D1_xyn_3D: \ - case EdgePosition::D1_xy0_3D: \ - case EdgePosition::D1_xyN_3D -#define CASE_EDGE_POSITION_D2_3D \ - case EdgePosition::D2_nyz_3D: \ - case EdgePosition::D2_0yz_3D: \ - case EdgePosition::D2_Nyz_3D -#define CASE_EDGE_POSITION_D3_3D \ - case EdgePosition::D3_xnz_3D: \ - case EdgePosition::D3_x0z_3D: \ - case EdgePosition::D3_xNz_3D -#define CASE_EDGE_POSITION_L_2D \ - case EdgePosition::L_xn_2D: \ - case EdgePosition::L_x0_2D: \ - case EdgePosition::L_xN_2D -#define CASE_EDGE_POSITION_H_2D \ - case EdgePosition::H_ny_2D: \ - case EdgePosition::H_0y_2D: \ - case EdgePosition::H_Ny_2D - namespace ttk { class ImplicitTriangulation : public RegularGridTriangulation { @@ -128,11 +77,8 @@ namespace ttk { return dimensionality_; } - inline SimplexId TTK_TRIANGULATION_INTERNAL(getEdgeLinkNumber)( - const SimplexId &edgeId) const override { - - return TTK_TRIANGULATION_INTERNAL(getEdgeStarNumber)(edgeId); - } + SimplexId TTK_TRIANGULATION_INTERNAL(getEdgeLinkNumber)( + const SimplexId &edgeId) const override; const std::vector> * TTK_TRIANGULATION_INTERNAL(getEdgeLinks)() override; @@ -222,18 +168,14 @@ namespace ttk { const std::vector> * TTK_TRIANGULATION_INTERNAL(getTriangles)() override; - inline SimplexId - getVertexEdgeNumberInternal(const SimplexId &vertexId) const override { - return TTK_TRIANGULATION_INTERNAL(getVertexNeighborNumber)(vertexId); - } + SimplexId + getVertexEdgeNumberInternal(const SimplexId &vertexId) const override; const std::vector> * getVertexEdgesInternal() override; - inline SimplexId TTK_TRIANGULATION_INTERNAL(getVertexLinkNumber)( - const SimplexId &vertexId) const override { - return TTK_TRIANGULATION_INTERNAL(getVertexStarNumber)(vertexId); - } + SimplexId TTK_TRIANGULATION_INTERNAL(getVertexLinkNumber)( + const SimplexId &vertexId) const override; const std::vector> * TTK_TRIANGULATION_INTERNAL(getVertexLinks)() override; @@ -251,26 +193,8 @@ namespace ttk { return !vertexNumber_; } - inline bool TTK_TRIANGULATION_INTERNAL(isTriangleOnBoundary)( - const SimplexId &triangleId) const override { - -#ifdef TTK_ENABLE_MPI - if(this->metaGrid_ != nullptr) { - return this->isTriangleOnGlobalBoundaryInternal(triangleId); - } -#endif // TTK_ENABLE_MPI - -#ifndef TTK_ENABLE_KAMIKAZE - if(triangleId < 0 or triangleId >= triangleNumber_) - return false; -#endif // !TTK_ENABLE_KAMIKAZE - - if(dimensionality_ == 3) - return (TTK_TRIANGULATION_INTERNAL(getTriangleStarNumber)(triangleId) - == 1); - - return false; - } + bool TTK_TRIANGULATION_INTERNAL(isTriangleOnBoundary)( + const SimplexId &triangleId) const override; int setInputGrid(const float &xOrigin, const float &yOrigin, @@ -589,16 +513,7 @@ namespace ttk { // acceleration functions int checkAcceleration(); - inline bool isPowerOfTwo(unsigned long long int v, - unsigned long long int &r) const { - if(v && !(v & (v - 1))) { - r = 0; - while(v >>= 1) - r++; - return true; - } - return false; - } + bool isPowerOfTwo(unsigned long long int v, unsigned long long int &r); //\cond // 2D // @@ -997,60 +912,11 @@ namespace ttk { return -1; } - inline bool TTK_TRIANGULATION_INTERNAL(isVertexOnBoundary)( - const SimplexId &vertexId) const override { -#ifdef TTK_ENABLE_MPI - if(this->metaGrid_ != nullptr) { - return this->isVertexOnGlobalBoundaryInternal(vertexId); - } -#endif // TTK_ENABLE_MPI - -#ifndef TTK_ENABLE_KAMIKAZE - if(vertexId < 0 or vertexId >= vertexNumber_) - return false; -#endif // !TTK_ENABLE_KAMIKAZE - - switch(this->underlying().getVertexPosition(vertexId)) { - case VertexPosition::CENTER_3D: - case VertexPosition::CENTER_2D: - case VertexPosition::CENTER_1D: - return false; - default: - return true; - } - } - - inline bool TTK_TRIANGULATION_INTERNAL(isEdgeOnBoundary)( - const SimplexId &edgeId) const override { - -#ifdef TTK_ENABLE_MPI - if(this->metaGrid_ != nullptr) { - return this->isEdgeOnGlobalBoundaryInternal(edgeId); - } -#endif // TTK_ENABLE_MPI - -#ifndef TTK_ENABLE_KAMIKAZE - if(edgeId < 0 or edgeId >= edgeNumber_) - return false; -#endif // !TTK_ENABLE_KAMIKAZE + bool TTK_TRIANGULATION_INTERNAL(isVertexOnBoundary)( + const SimplexId &vertexId) const override; - switch(this->underlying().getEdgePosition(edgeId)) { - case EdgePosition::L_xnn_3D: - case EdgePosition::H_nyn_3D: - case EdgePosition::P_nnz_3D: - case EdgePosition::D1_xyn_3D: - case EdgePosition::D2_nyz_3D: - case EdgePosition::D3_xnz_3D: - case EdgePosition::D4_3D: - case EdgePosition::L_xn_2D: - case EdgePosition::H_ny_2D: - case EdgePosition::D1_2D: - return false; - default: - break; - } - return true; - } + bool TTK_TRIANGULATION_INTERNAL(isEdgeOnBoundary)( + const SimplexId &edgeId) const override; inline int TTK_TRIANGULATION_INTERNAL(getVertexNeighbor)( const SimplexId &vertexId, @@ -1190,1142 +1056,58 @@ namespace ttk { return 0; } - inline int getVertexEdgeInternal(const SimplexId &vertexId, - const int &localEdgeId, - SimplexId &edgeId) const override { - -#ifndef TTK_ENABLE_KAMIKAZE - if(localEdgeId < 0 - or localEdgeId >= getVertexEdgeNumberInternal(vertexId)) - return -1; -#endif - // e--------f - // /| /| - // / | / | - // a--g-----b--h - // | / | / - // |/ |/ - // c--------d - // - // Classement des "Edges" et dans cet ordre: - // L: largeur (type ab) - // H: hauteur (type ac) - // P: profondeur (type ae) - // D1: diagonale1 (type bc) - // D2: diagonale2 (type ag) - // D3: diagonale3 (type be) - // D4: diagonale4 (type bg) - - const auto &p = this->underlying().getVertexCoords(vertexId); - - switch(this->underlying().getVertexPosition(vertexId)) { - case VertexPosition::CENTER_3D: - edgeId = getVertexEdgeABCDEFGH(p.data(), localEdgeId); - break; - case VertexPosition::FRONT_FACE_3D: - edgeId = getVertexEdgeABDC(p.data(), localEdgeId); - break; - case VertexPosition::BACK_FACE_3D: - edgeId = getVertexEdgeEFHG(p.data(), localEdgeId); - break; - case VertexPosition::TOP_FACE_3D: - edgeId = getVertexEdgeAEFB(p.data(), localEdgeId); - break; - case VertexPosition::BOTTOM_FACE_3D: - edgeId = getVertexEdgeGHDC(p.data(), localEdgeId); - break; - case VertexPosition::LEFT_FACE_3D: - edgeId = getVertexEdgeAEGC(p.data(), localEdgeId); - break; - case VertexPosition::RIGHT_FACE_3D: - edgeId = getVertexEdgeBFHD(p.data(), localEdgeId); - break; - case VertexPosition::TOP_FRONT_EDGE_3D: // ab - edgeId = getVertexEdgeAB(p.data(), localEdgeId); - break; - case VertexPosition::BOTTOM_FRONT_EDGE_3D: // cd - edgeId = getVertexEdgeCD(p.data(), localEdgeId); - break; - case VertexPosition::LEFT_FRONT_EDGE_3D: // ac - edgeId = getVertexEdgeAC(p.data(), localEdgeId); - break; - case VertexPosition::RIGHT_FRONT_EDGE_3D: // bd - edgeId = getVertexEdgeBD(p.data(), localEdgeId); - break; - case VertexPosition::TOP_BACK_EDGE_3D: // ef - edgeId = getVertexEdgeEF(p.data(), localEdgeId); - break; - case VertexPosition::BOTTOM_BACK_EDGE_3D: // gh - edgeId = getVertexEdgeGH(p.data(), localEdgeId); - break; - case VertexPosition::LEFT_BACK_EDGE_3D: // eg - edgeId = getVertexEdgeEG(p.data(), localEdgeId); - break; - case VertexPosition::RIGHT_BACK_EDGE_3D: // fh - edgeId = getVertexEdgeFH(p.data(), localEdgeId); - break; - case VertexPosition::TOP_LEFT_EDGE_3D: // ae - edgeId = getVertexEdgeAE(p.data(), localEdgeId); - break; - case VertexPosition::TOP_RIGHT_EDGE_3D: // bf - edgeId = getVertexEdgeBF(p.data(), localEdgeId); - break; - case VertexPosition::BOTTOM_LEFT_EDGE_3D: // cg - edgeId = getVertexEdgeCG(p.data(), localEdgeId); - break; - case VertexPosition::BOTTOM_RIGHT_EDGE_3D: // dh - edgeId = getVertexEdgeDH(p.data(), localEdgeId); - break; - case VertexPosition::TOP_LEFT_FRONT_CORNER_3D: // a - edgeId = getVertexEdgeA(p.data(), localEdgeId); - break; - case VertexPosition::TOP_RIGHT_FRONT_CORNER_3D: // b - edgeId = getVertexEdgeB(p.data(), localEdgeId); - break; - case VertexPosition::BOTTOM_LEFT_FRONT_CORNER_3D: // c - edgeId = getVertexEdgeC(p.data(), localEdgeId); - break; - case VertexPosition::BOTTOM_RIGHT_FRONT_CORNER_3D: // d - edgeId = getVertexEdgeD(p.data(), localEdgeId); - break; - case VertexPosition::TOP_LEFT_BACK_CORNER_3D: // e - edgeId = getVertexEdgeE(p.data(), localEdgeId); - break; - case VertexPosition::TOP_RIGHT_BACK_CORNER_3D: // f - edgeId = getVertexEdgeF(p.data(), localEdgeId); - break; - case VertexPosition::BOTTOM_LEFT_BACK_CORNER_3D: // g - edgeId = getVertexEdgeG(p.data(), localEdgeId); - break; - case VertexPosition::BOTTOM_RIGHT_BACK_CORNER_3D: // h - edgeId = getVertexEdgeH(p.data(), localEdgeId); - break; - case VertexPosition::CENTER_2D: - edgeId = getVertexEdge2dABCD(p.data(), localEdgeId); - break; - case VertexPosition::TOP_EDGE_2D: - edgeId = getVertexEdge2dAB(p.data(), localEdgeId); - break; - case VertexPosition::BOTTOM_EDGE_2D: - edgeId = getVertexEdge2dCD(p.data(), localEdgeId); - break; - case VertexPosition::LEFT_EDGE_2D: - edgeId = getVertexEdge2dAC(p.data(), localEdgeId); - break; - case VertexPosition::RIGHT_EDGE_2D: - edgeId = getVertexEdge2dBD(p.data(), localEdgeId); - break; - case VertexPosition::TOP_LEFT_CORNER_2D: // a - edgeId = getVertexEdge2dA(p.data(), localEdgeId); - break; - case VertexPosition::TOP_RIGHT_CORNER_2D: // b - edgeId = getVertexEdge2dB(p.data(), localEdgeId); - break; - case VertexPosition::BOTTOM_LEFT_CORNER_2D: // c - edgeId = getVertexEdge2dC(p.data(), localEdgeId); - break; - case VertexPosition::BOTTOM_RIGHT_CORNER_2D: // d - edgeId = getVertexEdge2dD(p.data(), localEdgeId); - break; - case VertexPosition::CENTER_1D: - edgeId = (localEdgeId == 0 ? vertexId : vertexId - 1); - break; - case VertexPosition::LEFT_CORNER_1D: - edgeId = vertexId; - break; - case VertexPosition::RIGHT_CORNER_1D: - edgeId = vertexId - 1; - break; - default: - edgeId = -1; - } - - return 0; - } + int getVertexEdgeInternal(const SimplexId &vertexId, + const int &id, + SimplexId &edgeId) const override; - inline SimplexId getVertexTriangleNumberInternal( - const SimplexId &vertexId) const override { + SimplexId + getVertexTriangleNumberInternal(const SimplexId &vertexId) const override; -#ifndef TTK_ENABLE_KAMIKAZE - if(vertexId < 0 or vertexId >= vertexNumber_) - return -1; -#endif + int getVertexTriangleInternal(const SimplexId &vertexId, + const int &id, + SimplexId &triangleId) const override; - switch(this->underlying().getVertexPosition(vertexId)) { - case VertexPosition::CENTER_3D: - return 36; - case VertexPosition::FRONT_FACE_3D: - case VertexPosition::BACK_FACE_3D: - case VertexPosition::TOP_FACE_3D: - case VertexPosition::BOTTOM_FACE_3D: - case VertexPosition::LEFT_FACE_3D: - case VertexPosition::RIGHT_FACE_3D: - return 21; - case VertexPosition::TOP_FRONT_EDGE_3D: // ab - case VertexPosition::RIGHT_FRONT_EDGE_3D: // bd - case VertexPosition::BOTTOM_BACK_EDGE_3D: // gh - case VertexPosition::LEFT_BACK_EDGE_3D: // eg - case VertexPosition::BOTTOM_LEFT_EDGE_3D: // cg - case VertexPosition::TOP_RIGHT_EDGE_3D: // bf - return 15; - case VertexPosition::TOP_RIGHT_FRONT_CORNER_3D: // b - case VertexPosition::BOTTOM_LEFT_BACK_CORNER_3D: // g - return 12; - case VertexPosition::TOP_BACK_EDGE_3D: // ef - case VertexPosition::BOTTOM_FRONT_EDGE_3D: // cd - case VertexPosition::LEFT_FRONT_EDGE_3D: // ac - case VertexPosition::TOP_LEFT_EDGE_3D: // ae - case VertexPosition::RIGHT_BACK_EDGE_3D: // fh - case VertexPosition::BOTTOM_RIGHT_EDGE_3D: // dh - return 9; - case VertexPosition::TOP_LEFT_FRONT_CORNER_3D: // a - case VertexPosition::BOTTOM_LEFT_FRONT_CORNER_3D: // c - case VertexPosition::BOTTOM_RIGHT_FRONT_CORNER_3D: // d - case VertexPosition::TOP_LEFT_BACK_CORNER_3D: // e - case VertexPosition::TOP_RIGHT_BACK_CORNER_3D: // f - case VertexPosition::BOTTOM_RIGHT_BACK_CORNER_3D: // h - return 5; - default: // 1D + 2D - break; - } + int TTK_TRIANGULATION_INTERNAL(getVertexLink)( + const SimplexId &vertexId, + const int &localLinkId, + SimplexId &linkId) const override; - return 0; - } + SimplexId TTK_TRIANGULATION_INTERNAL(getVertexStarNumber)( + const SimplexId &vertexId) const override; - inline int getVertexTriangleInternal(const SimplexId &vertexId, - const int &localTriangleId, - SimplexId &triangleId) const override { -#ifndef TTK_ENABLE_KAMIKAZE - if(localTriangleId < 0 - or localTriangleId >= getVertexTriangleNumberInternal(vertexId)) - return -1; -#endif + int TTK_TRIANGULATION_INTERNAL(getVertexStar)( + const SimplexId &vertexId, + const int &localStarId, + SimplexId &starId) const override; - const auto &p = this->underlying().getVertexCoords(vertexId); + int TTK_TRIANGULATION_INTERNAL(getVertexPoint)(const SimplexId &vertexId, + float &x, + float &y, + float &z) const override; - switch(this->underlying().getVertexPosition(vertexId)) { - case VertexPosition::CENTER_3D: - triangleId = getVertexTriangleABCDEFGH(p.data(), localTriangleId); - break; - case VertexPosition::FRONT_FACE_3D: - triangleId = getVertexTriangleABDC(p.data(), localTriangleId); - break; - case VertexPosition::BACK_FACE_3D: - triangleId = getVertexTriangleEFHG(p.data(), localTriangleId); - break; - case VertexPosition::TOP_FACE_3D: - triangleId = getVertexTriangleAEFB(p.data(), localTriangleId); - break; - case VertexPosition::BOTTOM_FACE_3D: - triangleId = getVertexTriangleGHDC(p.data(), localTriangleId); - break; - case VertexPosition::LEFT_FACE_3D: - triangleId = getVertexTriangleAEGC(p.data(), localTriangleId); - break; - case VertexPosition::RIGHT_FACE_3D: - triangleId = getVertexTriangleBFHD(p.data(), localTriangleId); - break; - case VertexPosition::TOP_FRONT_EDGE_3D: // ab - triangleId = getVertexTriangleAB(p.data(), localTriangleId); - break; - case VertexPosition::BOTTOM_FRONT_EDGE_3D: // cd - triangleId = getVertexTriangleCD(p.data(), localTriangleId); - break; - case VertexPosition::LEFT_FRONT_EDGE_3D: // ac - triangleId = getVertexTriangleAC(p.data(), localTriangleId); - break; - case VertexPosition::RIGHT_FRONT_EDGE_3D: // bd - triangleId = getVertexTriangleBD(p.data(), localTriangleId); - break; - case VertexPosition::TOP_BACK_EDGE_3D: // ef - triangleId = getVertexTriangleEF(p.data(), localTriangleId); - break; - case VertexPosition::BOTTOM_BACK_EDGE_3D: // gh - triangleId = getVertexTriangleGH(p.data(), localTriangleId); - break; - case VertexPosition::LEFT_BACK_EDGE_3D: // eg - triangleId = getVertexTriangleEG(p.data(), localTriangleId); - break; - case VertexPosition::RIGHT_BACK_EDGE_3D: // fh - triangleId = getVertexTriangleFH(p.data(), localTriangleId); - break; - case VertexPosition::TOP_LEFT_EDGE_3D: // ae - triangleId = getVertexTriangleAE(p.data(), localTriangleId); - break; - case VertexPosition::TOP_RIGHT_EDGE_3D: // bf - triangleId = getVertexTriangleBF(p.data(), localTriangleId); - break; - case VertexPosition::BOTTOM_LEFT_EDGE_3D: // cg - triangleId = getVertexTriangleCG(p.data(), localTriangleId); - break; - case VertexPosition::BOTTOM_RIGHT_EDGE_3D: // dh - triangleId = getVertexTriangleDH(p.data(), localTriangleId); - break; - case VertexPosition::TOP_LEFT_FRONT_CORNER_3D: // a - triangleId = getVertexTriangleA(p.data(), localTriangleId); - break; - case VertexPosition::TOP_RIGHT_FRONT_CORNER_3D: // b - triangleId = getVertexTriangleB(p.data(), localTriangleId); - break; - case VertexPosition::BOTTOM_LEFT_FRONT_CORNER_3D: // c - triangleId = getVertexTriangleC(p.data(), localTriangleId); - break; - case VertexPosition::BOTTOM_RIGHT_FRONT_CORNER_3D: // d - triangleId = getVertexTriangleD(p.data(), localTriangleId); - break; - case VertexPosition::TOP_LEFT_BACK_CORNER_3D: // e - triangleId = getVertexTriangleE(p.data(), localTriangleId); - break; - case VertexPosition::TOP_RIGHT_BACK_CORNER_3D: // f - triangleId = getVertexTriangleF(p.data(), localTriangleId); - break; - case VertexPosition::BOTTOM_LEFT_BACK_CORNER_3D: // g - triangleId = getVertexTriangleG(p.data(), localTriangleId); - break; - case VertexPosition::BOTTOM_RIGHT_BACK_CORNER_3D: // h - triangleId = getVertexTriangleH(p.data(), localTriangleId); - break; - default: // 1D + 2D - triangleId = -1; - break; - } + int getEdgeVertexInternal(const SimplexId &edgeId, + const int &localVertexId, + SimplexId &vertexId) const override; - return 0; - } + SimplexId + getEdgeTriangleNumberInternal(const SimplexId &edgeId) const override; - inline int TTK_TRIANGULATION_INTERNAL(getVertexLink)( - const SimplexId &vertexId, - const int &localLinkId, - SimplexId &linkId) const override { + int getEdgeTriangleInternal(const SimplexId &edgeId, + const int &id, + SimplexId &triangleId) const override; -#ifndef TTK_ENABLE_KAMIKAZE - if(localLinkId < 0 or localLinkId >= getVertexLinkNumber(vertexId)) - return -1; -#endif // !TTK_ENABLE_KAMIKAZE + int + TTK_TRIANGULATION_INTERNAL(getEdgeLink)(const SimplexId &edgeId, + const int &localLinkId, + SimplexId &linkId) const override; - const auto &p = this->underlying().getVertexCoords(vertexId); + int + TTK_TRIANGULATION_INTERNAL(getEdgeStar)(const SimplexId &edgeId, + const int &localStarId, + SimplexId &starId) const override; - switch(this->underlying().getVertexPosition(vertexId)) { - case VertexPosition::CENTER_3D: - linkId = getVertexLinkABCDEFGH(p.data(), localLinkId); - break; - case VertexPosition::FRONT_FACE_3D: - linkId = getVertexLinkABDC(p.data(), localLinkId); - break; - case VertexPosition::BACK_FACE_3D: - linkId = getVertexLinkEFHG(p.data(), localLinkId); - break; - case VertexPosition::TOP_FACE_3D: - linkId = getVertexLinkAEFB(p.data(), localLinkId); - break; - case VertexPosition::BOTTOM_FACE_3D: - linkId = getVertexLinkGHDC(p.data(), localLinkId); - break; - case VertexPosition::LEFT_FACE_3D: - linkId = getVertexLinkAEGC(p.data(), localLinkId); - break; - case VertexPosition::RIGHT_FACE_3D: - linkId = getVertexLinkBFHD(p.data(), localLinkId); - break; - case VertexPosition::TOP_FRONT_EDGE_3D: // ab - linkId = getVertexLinkAB(p.data(), localLinkId); - break; - case VertexPosition::BOTTOM_FRONT_EDGE_3D: // cd - linkId = getVertexLinkCD(p.data(), localLinkId); - break; - case VertexPosition::LEFT_FRONT_EDGE_3D: // ac - linkId = getVertexLinkAC(p.data(), localLinkId); - break; - case VertexPosition::RIGHT_FRONT_EDGE_3D: // bd - linkId = getVertexLinkBD(p.data(), localLinkId); - break; - case VertexPosition::TOP_BACK_EDGE_3D: // ef - linkId = getVertexLinkEF(p.data(), localLinkId); - break; - case VertexPosition::BOTTOM_BACK_EDGE_3D: // gh - linkId = getVertexLinkGH(p.data(), localLinkId); - break; - case VertexPosition::LEFT_BACK_EDGE_3D: // eg - linkId = getVertexLinkEG(p.data(), localLinkId); - break; - case VertexPosition::RIGHT_BACK_EDGE_3D: // fh - linkId = getVertexLinkFH(p.data(), localLinkId); - break; - case VertexPosition::TOP_LEFT_EDGE_3D: // ae - linkId = getVertexLinkAE(p.data(), localLinkId); - break; - case VertexPosition::TOP_RIGHT_EDGE_3D: // bf - linkId = getVertexLinkBF(p.data(), localLinkId); - break; - case VertexPosition::BOTTOM_LEFT_EDGE_3D: // cg - linkId = getVertexLinkCG(p.data(), localLinkId); - break; - case VertexPosition::BOTTOM_RIGHT_EDGE_3D: // dh - linkId = getVertexLinkDH(p.data(), localLinkId); - break; - case VertexPosition::TOP_LEFT_FRONT_CORNER_3D: // a - linkId = getVertexLinkA(p.data(), localLinkId); - break; - case VertexPosition::TOP_RIGHT_FRONT_CORNER_3D: // b - linkId = getVertexLinkB(p.data(), localLinkId); - break; - case VertexPosition::BOTTOM_LEFT_FRONT_CORNER_3D: // c - linkId = getVertexLinkC(p.data(), localLinkId); - break; - case VertexPosition::BOTTOM_RIGHT_FRONT_CORNER_3D: // d - linkId = getVertexLinkD(p.data(), localLinkId); - break; - case VertexPosition::TOP_LEFT_BACK_CORNER_3D: // e - linkId = getVertexLinkE(p.data(), localLinkId); - break; - case VertexPosition::TOP_RIGHT_BACK_CORNER_3D: // f - linkId = getVertexLinkF(p.data(), localLinkId); - break; - case VertexPosition::BOTTOM_LEFT_BACK_CORNER_3D: // g - linkId = getVertexLinkG(p.data(), localLinkId); - break; - case VertexPosition::BOTTOM_RIGHT_BACK_CORNER_3D: // h - linkId = getVertexLinkH(p.data(), localLinkId); - break; - case VertexPosition::CENTER_2D: - linkId = getVertexLink2dABCD(p.data(), localLinkId); - break; - case VertexPosition::TOP_EDGE_2D: - linkId = getVertexLink2dAB(p.data(), localLinkId); - break; - case VertexPosition::BOTTOM_EDGE_2D: - linkId = getVertexLink2dCD(p.data(), localLinkId); - break; - case VertexPosition::LEFT_EDGE_2D: - linkId = getVertexLink2dAC(p.data(), localLinkId); - break; - case VertexPosition::RIGHT_EDGE_2D: - linkId = getVertexLink2dBD(p.data(), localLinkId); - break; - case VertexPosition::TOP_LEFT_CORNER_2D: // a - linkId = getVertexLink2dA(p.data(), localLinkId); - break; - case VertexPosition::TOP_RIGHT_CORNER_2D: // b - linkId = getVertexLink2dB(p.data(), localLinkId); - break; - case VertexPosition::BOTTOM_LEFT_CORNER_2D: // c - linkId = getVertexLink2dC(p.data(), localLinkId); - break; - case VertexPosition::BOTTOM_RIGHT_CORNER_2D: // d - linkId = getVertexLink2dD(p.data(), localLinkId); - break; - default: // 1D - linkId = -1; - break; - }; - - return 0; - } - - inline SimplexId TTK_TRIANGULATION_INTERNAL(getVertexStarNumber)( - const SimplexId &vertexId) const override { - -#ifndef TTK_ENABLE_KAMIKAZE - if(vertexId < 0 or vertexId >= vertexNumber_) - return -1; -#endif // !TTK_ENABLE_KAMIKAZE - - switch(this->underlying().getVertexPosition(vertexId)) { - case VertexPosition::CENTER_3D: - return 24; - case VertexPosition::FRONT_FACE_3D: - case VertexPosition::BACK_FACE_3D: - case VertexPosition::TOP_FACE_3D: - case VertexPosition::BOTTOM_FACE_3D: - case VertexPosition::LEFT_FACE_3D: - case VertexPosition::RIGHT_FACE_3D: - return 12; - case VertexPosition::TOP_FRONT_EDGE_3D: // ab - case VertexPosition::RIGHT_FRONT_EDGE_3D: // bd - case VertexPosition::BOTTOM_BACK_EDGE_3D: // gh - case VertexPosition::LEFT_BACK_EDGE_3D: // eg - case VertexPosition::BOTTOM_LEFT_EDGE_3D: // cg - case VertexPosition::TOP_RIGHT_EDGE_3D: // bf - return 8; - case VertexPosition::TOP_RIGHT_FRONT_CORNER_3D: // b - case VertexPosition::BOTTOM_LEFT_BACK_CORNER_3D: // g - case VertexPosition::CENTER_2D: - return 6; - case VertexPosition::TOP_BACK_EDGE_3D: // ef - case VertexPosition::BOTTOM_FRONT_EDGE_3D: // cd - case VertexPosition::LEFT_FRONT_EDGE_3D: // ac - case VertexPosition::TOP_LEFT_EDGE_3D: // ae - case VertexPosition::RIGHT_BACK_EDGE_3D: // fh - case VertexPosition::BOTTOM_RIGHT_EDGE_3D: // dh - return 4; - case VertexPosition::TOP_EDGE_2D: // ab - case VertexPosition::BOTTOM_EDGE_2D: // cd - case VertexPosition::LEFT_EDGE_2D: // ac - case VertexPosition::RIGHT_EDGE_2D: // bd - return 3; - case VertexPosition::TOP_LEFT_FRONT_CORNER_3D: // a - case VertexPosition::BOTTOM_LEFT_FRONT_CORNER_3D: // c - case VertexPosition::BOTTOM_RIGHT_FRONT_CORNER_3D: // d - case VertexPosition::TOP_LEFT_BACK_CORNER_3D: // e - case VertexPosition::TOP_RIGHT_BACK_CORNER_3D: // f - case VertexPosition::BOTTOM_RIGHT_BACK_CORNER_3D: // h - case VertexPosition::TOP_RIGHT_CORNER_2D: // b - case VertexPosition::BOTTOM_LEFT_CORNER_2D: // c - return 2; - case VertexPosition::TOP_LEFT_CORNER_2D: // a - case VertexPosition::BOTTOM_RIGHT_CORNER_2D: // d - return 1; - default: // 1D - break; - } - - return 0; - } - - inline int TTK_TRIANGULATION_INTERNAL(getVertexStar)( - const SimplexId &vertexId, - const int &localStarId, - SimplexId &starId) const override { - -#ifndef TTK_ENABLE_KAMIKAZE - if(localStarId < 0 or localStarId >= getVertexStarNumber(vertexId)) - return -1; -#endif // !TTK_ENABLE_KAMIKAZE - - const auto &p = this->underlying().getVertexCoords(vertexId); - - switch(this->underlying().getVertexPosition(vertexId)) { - case VertexPosition::CENTER_3D: - starId = getVertexStarABCDEFGH(p.data(), localStarId); - break; - case VertexPosition::FRONT_FACE_3D: - starId = getVertexStarABDC(p.data(), localStarId); - break; - case VertexPosition::BACK_FACE_3D: - starId = getVertexStarEFHG(p.data(), localStarId); - break; - case VertexPosition::TOP_FACE_3D: - starId = getVertexStarAEFB(p.data(), localStarId); - break; - case VertexPosition::BOTTOM_FACE_3D: - starId = getVertexStarGHDC(p.data(), localStarId); - break; - case VertexPosition::LEFT_FACE_3D: - starId = getVertexStarAEGC(p.data(), localStarId); - break; - case VertexPosition::RIGHT_FACE_3D: - starId = getVertexStarBFHD(p.data(), localStarId); - break; - case VertexPosition::TOP_FRONT_EDGE_3D: // ab - starId = getVertexStarAB(p.data(), localStarId); - break; - case VertexPosition::BOTTOM_FRONT_EDGE_3D: // cd - starId = getVertexStarCD(p.data(), localStarId); - break; - case VertexPosition::LEFT_FRONT_EDGE_3D: // ac - starId = getVertexStarAC(p.data(), localStarId); - break; - case VertexPosition::RIGHT_FRONT_EDGE_3D: // bd - starId = getVertexStarBD(p.data(), localStarId); - break; - case VertexPosition::TOP_BACK_EDGE_3D: // ef - starId = getVertexStarEF(p.data(), localStarId); - break; - case VertexPosition::BOTTOM_BACK_EDGE_3D: // gh - starId = getVertexStarGH(p.data(), localStarId); - break; - case VertexPosition::LEFT_BACK_EDGE_3D: // eg - starId = getVertexStarEG(p.data(), localStarId); - break; - case VertexPosition::RIGHT_BACK_EDGE_3D: // fh - starId = getVertexStarFH(p.data(), localStarId); - break; - case VertexPosition::TOP_LEFT_EDGE_3D: // ae - starId = getVertexStarAE(p.data(), localStarId); - break; - case VertexPosition::TOP_RIGHT_EDGE_3D: // bf - starId = getVertexStarBF(p.data(), localStarId); - break; - case VertexPosition::BOTTOM_LEFT_EDGE_3D: // cg - starId = getVertexStarCG(p.data(), localStarId); - break; - case VertexPosition::BOTTOM_RIGHT_EDGE_3D: // dh - starId = getVertexStarDH(p.data(), localStarId); - break; - case VertexPosition::TOP_LEFT_FRONT_CORNER_3D: // a - starId = getVertexStarA(p.data(), localStarId); - break; - case VertexPosition::TOP_RIGHT_FRONT_CORNER_3D: // b - starId = getVertexStarB(p.data(), localStarId); - break; - case VertexPosition::BOTTOM_LEFT_FRONT_CORNER_3D: // c - starId = getVertexStarC(p.data(), localStarId); - break; - case VertexPosition::BOTTOM_RIGHT_FRONT_CORNER_3D: // d - starId = getVertexStarD(p.data(), localStarId); - break; - case VertexPosition::TOP_LEFT_BACK_CORNER_3D: // e - starId = getVertexStarE(p.data(), localStarId); - break; - case VertexPosition::TOP_RIGHT_BACK_CORNER_3D: // f - starId = getVertexStarF(p.data(), localStarId); - break; - case VertexPosition::BOTTOM_LEFT_BACK_CORNER_3D: // g - starId = getVertexStarG(p.data(), localStarId); - break; - case VertexPosition::BOTTOM_RIGHT_BACK_CORNER_3D: // h - starId = getVertexStarH(p.data(), localStarId); - break; - case VertexPosition::CENTER_2D: - starId = getVertexStar2dABCD(p.data(), localStarId); - break; - case VertexPosition::TOP_EDGE_2D: - starId = getVertexStar2dAB(p.data(), localStarId); - break; - case VertexPosition::BOTTOM_EDGE_2D: - starId = getVertexStar2dCD(p.data(), localStarId); - break; - case VertexPosition::LEFT_EDGE_2D: - starId = getVertexStar2dAC(p.data(), localStarId); - break; - case VertexPosition::RIGHT_EDGE_2D: - starId = getVertexStar2dBD(p.data(), localStarId); - break; - case VertexPosition::TOP_LEFT_CORNER_2D: // a - starId = getVertexStar2dA(p.data(), localStarId); - break; - case VertexPosition::TOP_RIGHT_CORNER_2D: // b - starId = getVertexStar2dB(p.data(), localStarId); - break; - case VertexPosition::BOTTOM_LEFT_CORNER_2D: // c - starId = getVertexStar2dC(p.data(), localStarId); - break; - case VertexPosition::BOTTOM_RIGHT_CORNER_2D: // d - starId = getVertexStar2dD(p.data(), localStarId); - break; - default: // 1D - starId = -1; - break; - } - - return 0; - } - - inline int TTK_TRIANGULATION_INTERNAL(getVertexPoint)( - const SimplexId &vertexId, float &x, float &y, float &z) const override { - if(dimensionality_ == 3) { - const auto &p = this->underlying().getVertexCoords(vertexId); - - x = origin_[0] + spacing_[0] * p[0]; - y = origin_[1] + spacing_[1] * p[1]; - z = origin_[2] + spacing_[2] * p[2]; - } else if(dimensionality_ == 2) { - const auto &p = this->underlying().getVertexCoords(vertexId); - - if(dimensions_[0] > 1 and dimensions_[1] > 1) { - x = origin_[0] + spacing_[0] * p[0]; - y = origin_[1] + spacing_[1] * p[1]; - z = origin_[2]; - } else if(dimensions_[1] > 1 and dimensions_[2] > 1) { - x = origin_[0]; - y = origin_[1] + spacing_[1] * p[0]; - z = origin_[2] + spacing_[2] * p[1]; - } else if(dimensions_[0] > 1 and dimensions_[2] > 1) { - x = origin_[0] + spacing_[0] * p[0]; - y = origin_[1]; - z = origin_[2] + spacing_[2] * p[1]; - } - } else if(dimensionality_ == 1) { - if(dimensions_[0] > 1) { - x = origin_[0] + spacing_[0] * vertexId; - y = origin_[1]; - z = origin_[2]; - } else if(dimensions_[1] > 1) { - x = origin_[0]; - y = origin_[1] + spacing_[1] * vertexId; - z = origin_[2]; - } else if(dimensions_[2] > 1) { - x = origin_[0]; - y = origin_[1]; - z = origin_[2] + spacing_[2] * vertexId; - } - } - - return 0; - } - - inline int getEdgeVertexInternal(const SimplexId &edgeId, - const int &localVertexId, - SimplexId &vertexId) const override { - -#ifndef TTK_ENABLE_KAMIKAZE - if(edgeId < 0 or edgeId >= edgeNumber_) - return -1; - if(localVertexId < 0 or localVertexId >= 2) - return -2; -#endif - - const auto &p = this->underlying().getEdgeCoords(edgeId); - - const auto helper3d - = [&](const SimplexId a, const SimplexId b) -> SimplexId { - if(isAccelerated_) { - const auto tmp = p[0] + (p[1] << div_[0]) + (p[2] << div_[1]); - return (localVertexId == 0) ? tmp + a : tmp + b; - } else { - const auto tmp = p[0] + (p[1] * vshift_[0]) + (p[2] * vshift_[1]); - return (localVertexId == 0) ? tmp + a : tmp + b; - } - }; - - const auto helper2d - = [&](const SimplexId a, const SimplexId b) -> SimplexId { - if(isAccelerated_) { - const auto tmp = p[0] + (p[1] << div_[0]); - return localVertexId == 0 ? tmp + a : tmp + b; - } else { - const auto tmp = p[0] + (p[1] * vshift_[0]); - return localVertexId == 0 ? tmp + a : tmp + b; - } - }; - - switch(this->underlying().getEdgePosition(edgeId)) { - CASE_EDGE_POSITION_L_3D: - vertexId = helper3d(0, 1); - break; - CASE_EDGE_POSITION_H_3D: - vertexId = helper3d(0, vshift_[0]); - break; - CASE_EDGE_POSITION_P_3D: - vertexId = helper3d(0, vshift_[1]); - break; - CASE_EDGE_POSITION_D1_3D: - vertexId = helper3d(1, vshift_[0]); - break; - CASE_EDGE_POSITION_D2_3D: - vertexId = helper3d(0, vshift_[0] + vshift_[1]); - break; - CASE_EDGE_POSITION_D3_3D: - vertexId = helper3d(1, vshift_[1]); - break; - case EdgePosition::D4_3D: - vertexId = helper3d(1, vshift_[0] + vshift_[1]); - break; - CASE_EDGE_POSITION_L_2D: - vertexId = helper2d(0, 1); - break; - CASE_EDGE_POSITION_H_2D: - vertexId = helper2d(0, vshift_[0]); - break; - case EdgePosition::D1_2D: - vertexId = helper2d(1, vshift_[0]); - break; - - case EdgePosition::FIRST_EDGE_1D: - vertexId = localVertexId == 0 ? 0 : 1; - break; - case EdgePosition::LAST_EDGE_1D: - vertexId = localVertexId == 0 ? edgeNumber_ - 1 : edgeNumber_; - break; - case EdgePosition::CENTER_1D: - vertexId = localVertexId == 0 ? edgeId : edgeId + 1; - break; - } - - return 0; - } - - inline SimplexId - getEdgeTriangleNumberInternal(const SimplexId &edgeId) const override { - -#ifndef TTK_ENABLE_KAMIKAZE - if(edgeId < 0 or edgeId >= edgeNumber_) - return -1; -#endif - - switch(this->underlying().getEdgePosition(edgeId)) { - case EdgePosition::L_xnn_3D: - case EdgePosition::H_nyn_3D: - case EdgePosition::P_nnz_3D: - case EdgePosition::D4_3D: - return 6; - case EdgePosition::L_x0n_3D: - case EdgePosition::L_xNn_3D: - case EdgePosition::L_xn0_3D: - case EdgePosition::L_xnN_3D: - case EdgePosition::H_ny0_3D: - case EdgePosition::H_nyN_3D: - case EdgePosition::H_0yn_3D: - case EdgePosition::H_Nyn_3D: - case EdgePosition::P_n0z_3D: - case EdgePosition::P_nNz_3D: - case EdgePosition::P_0nz_3D: - case EdgePosition::P_Nnz_3D: - case EdgePosition::D1_xyn_3D: - case EdgePosition::D2_nyz_3D: - case EdgePosition::D3_xnz_3D: - return 4; - case EdgePosition::L_x00_3D: - case EdgePosition::L_xNN_3D: - case EdgePosition::H_0yN_3D: - case EdgePosition::H_Ny0_3D: - case EdgePosition::P_0Nz_3D: - case EdgePosition::P_N0z_3D: - case EdgePosition::D1_xy0_3D: - case EdgePosition::D1_xyN_3D: - case EdgePosition::D2_0yz_3D: - case EdgePosition::D2_Nyz_3D: - case EdgePosition::D3_x0z_3D: - case EdgePosition::D3_xNz_3D: - return 3; - case EdgePosition::L_xN0_3D: - case EdgePosition::L_x0N_3D: - case EdgePosition::H_0y0_3D: - case EdgePosition::H_NyN_3D: - case EdgePosition::P_00z_3D: - case EdgePosition::P_NNz_3D: - case EdgePosition::L_xn_2D: - case EdgePosition::H_ny_2D: - case EdgePosition::D1_2D: - return 2; - case EdgePosition::L_x0_2D: - case EdgePosition::L_xN_2D: - case EdgePosition::H_0y_2D: - case EdgePosition::H_Ny_2D: - return 1; - - default: // 1D - break; - } - - return 0; - } - - inline int getEdgeTriangleInternal(const SimplexId &edgeId, - const int &localTriangleId, - SimplexId &triangleId) const override { -#ifndef TTK_ENABLE_KAMIKAZE - if(localTriangleId < 0 - or localTriangleId >= getEdgeTriangleNumberInternal(edgeId)) - return -1; -#endif - - const auto &p = this->underlying().getEdgeCoords(edgeId); - - switch(this->underlying().getEdgePosition(edgeId)) { - case EdgePosition::L_xnn_3D: - triangleId = getEdgeTriangleL_xnn(p.data(), localTriangleId); - break; - case EdgePosition::L_xn0_3D: - triangleId = getEdgeTriangleL_xn0(p.data(), localTriangleId); - break; - case EdgePosition::L_xnN_3D: - triangleId = getEdgeTriangleL_xnN(p.data(), localTriangleId); - break; - case EdgePosition::L_x0n_3D: - triangleId = getEdgeTriangleL_x0n(p.data(), localTriangleId); - break; - case EdgePosition::L_x00_3D: - triangleId = getEdgeTriangleL_x00(p.data(), localTriangleId); - break; - case EdgePosition::L_x0N_3D: - triangleId = getEdgeTriangleL_x0N(p.data(), localTriangleId); - break; - case EdgePosition::L_xNn_3D: - triangleId = getEdgeTriangleL_xNn(p.data(), localTriangleId); - break; - case EdgePosition::L_xN0_3D: - triangleId = getEdgeTriangleL_xN0(p.data(), localTriangleId); - break; - case EdgePosition::L_xNN_3D: - triangleId = getEdgeTriangleL_xNN(p.data(), localTriangleId); - break; - case EdgePosition::H_nyn_3D: - triangleId = getEdgeTriangleH_nyn(p.data(), localTriangleId); - break; - case EdgePosition::H_ny0_3D: - triangleId = getEdgeTriangleH_ny0(p.data(), localTriangleId); - break; - case EdgePosition::H_nyN_3D: - triangleId = getEdgeTriangleH_nyN(p.data(), localTriangleId); - break; - case EdgePosition::H_0yn_3D: - triangleId = getEdgeTriangleH_0yn(p.data(), localTriangleId); - break; - case EdgePosition::H_0y0_3D: - triangleId = getEdgeTriangleH_0y0(p.data(), localTriangleId); - break; - case EdgePosition::H_0yN_3D: - triangleId = getEdgeTriangleH_0yN(p.data(), localTriangleId); - break; - case EdgePosition::H_Nyn_3D: - triangleId = getEdgeTriangleH_Nyn(p.data(), localTriangleId); - break; - case EdgePosition::H_Ny0_3D: - triangleId = getEdgeTriangleH_Ny0(p.data(), localTriangleId); - break; - case EdgePosition::H_NyN_3D: - triangleId = getEdgeTriangleH_NyN(p.data(), localTriangleId); - break; - case EdgePosition::P_nnz_3D: - triangleId = getEdgeTriangleP_nnz(p.data(), localTriangleId); - break; - case EdgePosition::P_n0z_3D: - triangleId = getEdgeTriangleP_n0z(p.data(), localTriangleId); - break; - case EdgePosition::P_nNz_3D: - triangleId = getEdgeTriangleP_nNz(p.data(), localTriangleId); - break; - case EdgePosition::P_0nz_3D: - triangleId = getEdgeTriangleP_0nz(p.data(), localTriangleId); - break; - case EdgePosition::P_00z_3D: - triangleId = getEdgeTriangleP_00z(p.data(), localTriangleId); - break; - case EdgePosition::P_0Nz_3D: - triangleId = getEdgeTriangleP_0Nz(p.data(), localTriangleId); - break; - case EdgePosition::P_Nnz_3D: - triangleId = getEdgeTriangleP_Nnz(p.data(), localTriangleId); - break; - case EdgePosition::P_N0z_3D: - triangleId = getEdgeTriangleP_N0z(p.data(), localTriangleId); - break; - case EdgePosition::P_NNz_3D: - triangleId = getEdgeTriangleP_NNz(p.data(), localTriangleId); - break; - case EdgePosition::D1_xyn_3D: - triangleId = getEdgeTriangleD1_xyn(p.data(), localTriangleId); - break; - case EdgePosition::D1_xy0_3D: - triangleId = getEdgeTriangleD1_xy0(p.data(), localTriangleId); - break; - case EdgePosition::D1_xyN_3D: - triangleId = getEdgeTriangleD1_xyN(p.data(), localTriangleId); - break; - case EdgePosition::D2_nyz_3D: - triangleId = getEdgeTriangleD2_nyz(p.data(), localTriangleId); - break; - case EdgePosition::D2_0yz_3D: - triangleId = getEdgeTriangleD2_0yz(p.data(), localTriangleId); - break; - case EdgePosition::D2_Nyz_3D: - triangleId = getEdgeTriangleD2_Nyz(p.data(), localTriangleId); - break; - case EdgePosition::D3_xnz_3D: - triangleId = getEdgeTriangleD3_xnz(p.data(), localTriangleId); - break; - case EdgePosition::D3_x0z_3D: - triangleId = getEdgeTriangleD3_x0z(p.data(), localTriangleId); - break; - case EdgePosition::D3_xNz_3D: - triangleId = getEdgeTriangleD3_xNz(p.data(), localTriangleId); - break; - case EdgePosition::D4_3D: - triangleId = getEdgeTriangleD4_xyz(p.data(), localTriangleId); - break; - - case EdgePosition::L_xn_2D: - triangleId = getEdgeTriangleL_xn(p.data(), localTriangleId); - break; - case EdgePosition::L_x0_2D: - triangleId = getEdgeTriangleL_x0(p.data(), localTriangleId); - break; - case EdgePosition::L_xN_2D: - triangleId = getEdgeTriangleL_xN(p.data(), localTriangleId); - break; - case EdgePosition::H_ny_2D: - triangleId = getEdgeTriangleH_ny(p.data(), localTriangleId); - break; - case EdgePosition::H_0y_2D: - triangleId = getEdgeTriangleH_0y(p.data(), localTriangleId); - break; - case EdgePosition::H_Ny_2D: - triangleId = getEdgeTriangleH_Ny(p.data(), localTriangleId); - break; - case EdgePosition::D1_2D: - triangleId = getEdgeTriangleD1_xy(p.data(), localTriangleId); - break; - - default: // 1D - triangleId = -1; - break; - } - - return 0; - } - - inline int TTK_TRIANGULATION_INTERNAL(getEdgeLink)( - const SimplexId &edgeId, - const int &localLinkId, - SimplexId &linkId) const override { - -#ifndef TTK_ENABLE_KAMIKAZE - if(localLinkId < 0 or localLinkId >= getEdgeLinkNumber(edgeId)) - return -1; -#endif - - const auto &p = this->underlying().getEdgeCoords(edgeId); - - switch(this->underlying().getEdgePosition(edgeId)) { - CASE_EDGE_POSITION_L_3D: - linkId = getEdgeLinkL(p.data(), localLinkId); - break; - CASE_EDGE_POSITION_H_3D: - linkId = getEdgeLinkH(p.data(), localLinkId); - break; - CASE_EDGE_POSITION_P_3D: - linkId = getEdgeLinkP(p.data(), localLinkId); - break; - CASE_EDGE_POSITION_D1_3D: - linkId = getEdgeLinkD1(p.data(), localLinkId); - break; - CASE_EDGE_POSITION_D2_3D: - linkId = getEdgeLinkD2(p.data(), localLinkId); - break; - CASE_EDGE_POSITION_D3_3D: - linkId = getEdgeLinkD3(p.data(), localLinkId); - break; - case EdgePosition::D4_3D: - linkId = getEdgeLinkD4(p.data(), localLinkId); - break; - - CASE_EDGE_POSITION_L_2D: - linkId = getEdgeLink2dL(p.data(), localLinkId); - break; - CASE_EDGE_POSITION_H_2D: - linkId = getEdgeLink2dH(p.data(), localLinkId); - break; - case EdgePosition::D1_2D: - linkId = getEdgeLink2dD1(p.data(), localLinkId); - break; - - default: // 1D - linkId = -1; - break; - } - - return 0; - } - - inline int TTK_TRIANGULATION_INTERNAL(getEdgeStar)( - const SimplexId &edgeId, - const int &localStarId, - SimplexId &starId) const override { -#ifndef TTK_ENABLE_KAMIKAZE - if(localStarId < 0 or localStarId >= getEdgeStarNumber(edgeId)) - return -1; -#endif - - const auto &p = this->underlying().getEdgeCoords(edgeId); - - switch(this->underlying().getEdgePosition(edgeId)) { - CASE_EDGE_POSITION_L_3D: - starId = getEdgeStarL(p.data(), localStarId); - break; - CASE_EDGE_POSITION_H_3D: - starId = getEdgeStarH(p.data(), localStarId); - break; - CASE_EDGE_POSITION_P_3D: - starId = getEdgeStarP(p.data(), localStarId); - break; - CASE_EDGE_POSITION_D1_3D: - starId = getEdgeStarD1(p.data(), localStarId); - break; - CASE_EDGE_POSITION_D2_3D: - starId = getEdgeStarD2(p.data(), localStarId); - break; - CASE_EDGE_POSITION_D3_3D: - starId = getEdgeStarD3(p.data(), localStarId); - break; - case EdgePosition::D4_3D: - starId = p[2] * tetshift_[1] + p[1] * tetshift_[0] + p[0] * 6 - + localStarId; - break; - - CASE_EDGE_POSITION_L_2D: - starId = getEdgeStar2dL(p.data(), localStarId); - break; - CASE_EDGE_POSITION_H_2D: - starId = getEdgeStar2dH(p.data(), localStarId); - break; - case EdgePosition::D1_2D: - starId = p[0] * 2 + p[1] * tshift_[0] + localStarId; - break; - - default: // 1D - starId = -1; - break; - } - - return 0; - } - - inline SimplexId TTK_TRIANGULATION_INTERNAL(getEdgeStarNumber)( - const SimplexId &edgeId) const override { - -#ifndef TTK_ENABLE_KAMIKAZE - if(edgeId < 0 or edgeId >= edgeNumber_) - return -1; -#endif - - switch(this->underlying().getEdgePosition(edgeId)) { - case EdgePosition::L_xnn_3D: - case EdgePosition::H_nyn_3D: - case EdgePosition::P_nnz_3D: - case EdgePosition::D4_3D: - return 6; - case EdgePosition::D1_xyn_3D: - case EdgePosition::D2_nyz_3D: - case EdgePosition::D3_xnz_3D: - return 4; - case EdgePosition::L_x0n_3D: - case EdgePosition::L_xNn_3D: - case EdgePosition::L_xn0_3D: - case EdgePosition::L_xnN_3D: - case EdgePosition::H_ny0_3D: - case EdgePosition::H_nyN_3D: - case EdgePosition::H_0yn_3D: - case EdgePosition::H_Nyn_3D: - case EdgePosition::P_n0z_3D: - case EdgePosition::P_nNz_3D: - case EdgePosition::P_0nz_3D: - case EdgePosition::P_Nnz_3D: - return 3; - case EdgePosition::L_x00_3D: - case EdgePosition::L_xNN_3D: - case EdgePosition::H_0yN_3D: - case EdgePosition::H_Ny0_3D: - case EdgePosition::P_0Nz_3D: - case EdgePosition::P_N0z_3D: - case EdgePosition::D1_xy0_3D: - case EdgePosition::D1_xyN_3D: - case EdgePosition::D2_0yz_3D: - case EdgePosition::D2_Nyz_3D: - case EdgePosition::D3_x0z_3D: - case EdgePosition::D3_xNz_3D: - case EdgePosition::L_xn_2D: - case EdgePosition::H_ny_2D: - case EdgePosition::D1_2D: - return 2; - case EdgePosition::L_xN0_3D: - case EdgePosition::L_x0N_3D: - case EdgePosition::H_0y0_3D: - case EdgePosition::H_NyN_3D: - case EdgePosition::P_00z_3D: - case EdgePosition::P_NNz_3D: - case EdgePosition::L_x0_2D: - case EdgePosition::L_xN_2D: - case EdgePosition::H_0y_2D: - case EdgePosition::H_Ny_2D: - return 1; - - default: // 1D - break; - } - - return 0; - } + SimplexId TTK_TRIANGULATION_INTERNAL(getEdgeStarNumber)( + const SimplexId &edgeId) const override; int getTriangleVertexInternal(const SimplexId &triangleId, const int &localVertexId, From c45ae45731fad1872f107ca790adacd35a72a387 Mon Sep 17 00:00:00 2001 From: Julien Tierny Date: Thu, 28 Sep 2023 12:05:56 +0200 Subject: [PATCH 12/12] adding final keyword to inlining --- core/base/implicitTriangulation/ImplicitTriangulation.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/base/implicitTriangulation/ImplicitTriangulation.h b/core/base/implicitTriangulation/ImplicitTriangulation.h index daa8f69d75..b172db6036 100644 --- a/core/base/implicitTriangulation/ImplicitTriangulation.h +++ b/core/base/implicitTriangulation/ImplicitTriangulation.h @@ -851,7 +851,7 @@ namespace ttk { public: inline SimplexId TTK_TRIANGULATION_INTERNAL(getVertexNeighborNumber)( - const SimplexId &vertexId) const override { + const SimplexId &vertexId) const final { #ifndef TTK_ENABLE_KAMIKAZE if(vertexId < 0 or vertexId >= vertexNumber_) @@ -921,7 +921,7 @@ namespace ttk { inline int TTK_TRIANGULATION_INTERNAL(getVertexNeighbor)( const SimplexId &vertexId, const int &localNeighborId, - SimplexId &neighborId) const override { + SimplexId &neighborId) const final { #ifndef TTK_ENABLE_KAMIKAZE if(localNeighborId < 0