Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inlining queries for the (fully) implicit triangulation #972

Merged
merged 12 commits into from
Sep 29, 2023
330 changes: 0 additions & 330 deletions core/base/implicitTriangulation/ImplicitPreconditions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<SimplexId, 3> 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::SimplexId, 3>
ttk::ImplicitNoPreconditions::getEdgeCoords(const SimplexId e) const {
std::array<SimplexId, 3> 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::SimplexId, 3>
ttk::ImplicitNoPreconditions::getTriangleCoords(const SimplexId t) const {
std::array<SimplexId, 3> 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;
}
Loading
Loading