Commit 7404f0a0 authored by YIxin-Hu's avatar YIxin-Hu
Browse files

fixing is_boundary_edge

parent 3c5c7c10
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -5,7 +5,7 @@

#define TET_MODIFIED 100

void floatTetWild::edge_splitting(Mesh& mesh) {
void floatTetWild::edge_splitting(Mesh& mesh, const AABBWrapper& tree) {
    auto &tets = mesh.tets;
    auto &tet_vertices = mesh.tet_vertices;

@@ -64,7 +64,7 @@ void floatTetWild::edge_splitting(Mesh& mesh) {
            continue;

        std::vector<std::array<int, 2>> new_edges;
        if (split_an_edge(mesh, v_ids[0], v_ids[1], is_repush, new_edges, is_splittable))
        if (split_an_edge(mesh, v_ids[0], v_ids[1], is_repush, new_edges, is_splittable, tree))
            suc_counter++;
        else
            is_repush = false;
@@ -99,7 +99,7 @@ void floatTetWild::edge_splitting(Mesh& mesh) {
}

bool floatTetWild::split_an_edge(Mesh& mesh, int v1_id, int v2_id, bool is_repush,
        std::vector<std::array<int, 2>>& new_edges, std::vector<bool>& is_splittable) {
        std::vector<std::array<int, 2>>& new_edges, std::vector<bool>& is_splittable, const AABBWrapper& tree) {
    auto &tet_vertices = mesh.tet_vertices;
    auto &tets = mesh.tets;

@@ -173,7 +173,7 @@ bool floatTetWild::split_an_edge(Mesh& mesh, int v1_id, int v2_id, bool is_repus
    tet_vertices[v_id].sizing_scalar = (tet_vertices[v1_id].sizing_scalar + tet_vertices[v2_id].sizing_scalar) / 2;
    tet_vertices[v_id].is_on_bbox = is_bbox_edge(mesh, v1_id, v2_id, old_t_ids);
    tet_vertices[v_id].is_on_surface = is_surface_edge(mesh, v1_id, v2_id, old_t_ids);
    tet_vertices[v_id].is_on_boundary = is_boundary_edge(mesh, v1_id, v2_id);
    tet_vertices[v_id].is_on_boundary = is_boundary_edge(mesh, v1_id, v2_id, tree);
    if(!mesh.is_input_all_inserted && tet_vertices[v_id].is_on_boundary) {
        tet_vertices[v_id].is_on_cut = (tet_vertices[v1_id].is_on_cut && tet_vertices[v2_id].is_on_cut);
    }
+3 −2
Original line number Diff line number Diff line
@@ -2,12 +2,13 @@
#define FLOATTETWILD_EDGESPLITTING_H

#include <floattetwild/Mesh.hpp>
#include <floattetwild/AABBWrapper.h>

namespace floatTetWild {
    void edge_splitting(Mesh &mesh);
    void edge_splitting(Mesh &mesh, const AABBWrapper& tree);

    bool split_an_edge(Mesh &mesh, int v1_id, int v2_id, bool is_repush, std::vector<std::array<int, 2>> &new_edges,
                       std::vector<bool> &is_splittable);
                       std::vector<bool> &is_splittable, const AABBWrapper& tree);
}

#endif //FLOATTETWILD_EDGESPLITTING_H
+44 −24
Original line number Diff line number Diff line
@@ -244,34 +244,54 @@ bool floatTetWild::is_surface_edge(const Mesh& mesh, int v1_id, int v2_id, const
    return false;
}

bool floatTetWild::is_boundary_edge(const Mesh& mesh, int v1_id, int v2_id) {
bool floatTetWild::is_boundary_edge(const Mesh& mesh, int v1_id, int v2_id, const AABBWrapper& tree) {
    if (!mesh.tet_vertices[v1_id].is_on_boundary || !mesh.tet_vertices[v2_id].is_on_boundary)
        return false;

    if(!mesh.is_input_all_inserted)
        return true;

    int cnt = 0;
    for (int t_id: mesh.tet_vertices[v1_id].conn_tets) {
        std::array<int, 4> opp_js;
        int ii = 0;
        for (int j = 0; j < 4; j++) {
            if (mesh.tets[t_id][j] == v1_id || mesh.tets[t_id][j] == v2_id)
                continue;
            opp_js[ii++] = j;
        }
        if (ii == 2) {
            if (mesh.tets[t_id].is_surface_fs[opp_js[0]] != NOT_SURFACE)
                cnt++;
            if (mesh.tets[t_id].is_surface_fs[opp_js[1]] != NOT_SURFACE)
                cnt++;
            if (cnt > 2)
                return false;
    std::vector<GEO::vec3> ps;
    ps.push_back(GEO::vec3(mesh.tet_vertices[v1_id].pos[0], mesh.tet_vertices[v1_id].pos[1],
            mesh.tet_vertices[v1_id].pos[2]));
    int p0_id = 0;
    Scalar l = get_edge_length(mesh, v1_id, v2_id);
    int N = l / mesh.params.dd + 1;
    ps.push_back(GEO::vec3(mesh.tet_vertices[v2_id][0], mesh.tet_vertices[v2_id][1],
                           mesh.tet_vertices[v2_id][2]));
    int p1_id = ps.size() - 1;
    for (Scalar j = 1; j < N - 1; j++) {
        ps.push_back(ps[p0_id] * (j / N) + ps[p1_id] * (1 - j / N));
    }

    GEO::index_t prev_facet;
    if(!mesh.is_input_all_inserted) {
        return !tree.is_out_tmp_b_envelope(ps, mesh.params.eps_2, prev_facet);
    }else {
        return !tree.is_out_b_envelope(ps, mesh.params.eps_2, prev_facet);
    }
    if (cnt == 2)
        return true;
    return false;

//    if(!mesh.is_input_all_inserted)
//        return true;
//
//    int cnt = 0;
//    for (int t_id: mesh.tet_vertices[v1_id].conn_tets) {
//        std::array<int, 4> opp_js;
//        int ii = 0;
//        for (int j = 0; j < 4; j++) {
//            if (mesh.tets[t_id][j] == v1_id || mesh.tets[t_id][j] == v2_id)
//                continue;
//            opp_js[ii++] = j;
//        }
//        if (ii == 2) {
//            if (mesh.tets[t_id].is_surface_fs[opp_js[0]] != NOT_SURFACE)
//                cnt++;
//            if (mesh.tets[t_id].is_surface_fs[opp_js[1]] != NOT_SURFACE)
//                cnt++;
//            if (cnt > 2)
//                return false;
//        }
//    }
//    if (cnt == 2)
//        return true;
//    return false;
}

bool floatTetWild::is_valid_edge(const Mesh& mesh, int v1_id, int v2_id) {
@@ -487,7 +507,7 @@ bool floatTetWild::is_out_boundary_envelope(const Mesh& mesh, int v_id, const Ve
    std::vector<int> b_v_ids;
    b_v_ids.reserve(tmp_b_v_ids.size());
    for(int b_v_id:tmp_b_v_ids){
        if(is_boundary_edge(mesh, v_id, b_v_id))
        if(is_boundary_edge(mesh, v_id, b_v_id, tree))
            b_v_ids.push_back(b_v_id);
    }
    if(b_v_ids.empty())
+1 −1
Original line number Diff line number Diff line
@@ -45,7 +45,7 @@ namespace floatTetWild {

    bool is_bbox_edge(const Mesh& mesh, int v1_id, int v2_id, const std::vector<int>& n12_t_ids);
    bool is_surface_edge(const Mesh& mesh, int v1_id, int v2_id, const std::vector<int>& n12_t_ids);
    bool is_boundary_edge(const Mesh& mesh, int v1_id, int v2_id);
    bool is_boundary_edge(const Mesh& mesh, int v1_id, int v2_id, const AABBWrapper& tree);
    bool is_valid_edge(const Mesh& mesh, int v1_id, int v2_id);
    bool is_valid_edge(const Mesh& mesh, int v1_id, int v2_id, const std::vector<int>& n12_t_ids);

+1 −1
Original line number Diff line number Diff line
@@ -296,7 +296,7 @@ void floatTetWild::operation(const std::vector<Vector3> &input_vertices, const s
    for (int i = 0; i < ops[0]; i++) {
        igl_timer.start();
        cout << "edge splitting..." << endl;
        edge_splitting(mesh);
        edge_splitting(mesh, tree);
        time = igl_timer.getElapsedTime();
        cout << "edge splitting done!" << endl;
        cout << "time = " << time << "s" << endl;