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..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_) @@ -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 final { + +#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,