Commit 10b50842 authored by YIxin-Hu's avatar YIxin-Hu
Browse files

add is_uninserted_face_covered()

parent 0dd4f130
Loading
Loading
Loading
Loading
+4 −0
Original line number Original line Diff line number Diff line
@@ -20,6 +20,10 @@ namespace floatTetWild {
        return -1;
        return -1;
    }
    }


    inline GEO::vec3 to_geo_p(const Vector3& p){
        return GEO::vec3(p[0], p[1], p[2]);
    }

    void get_all_edges(const Mesh& mesh, std::vector<std::array<int, 2>>& edges);
    void get_all_edges(const Mesh& mesh, std::vector<std::array<int, 2>>& edges);
    void get_all_edges(const Mesh& mesh, const std::vector<int>& t_ids, std::vector<std::array<int, 2>>& edges, bool skip_freezed = false);
    void get_all_edges(const Mesh& mesh, const std::vector<int>& t_ids, std::vector<std::array<int, 2>>& edges, bool skip_freezed = false);


+4 −4
Original line number Original line Diff line number Diff line
@@ -1395,8 +1395,8 @@ void floatTetWild::untangle(Mesh &mesh) {
//    return;
//    return;
    auto &tet_vertices = mesh.tet_vertices;
    auto &tet_vertices = mesh.tet_vertices;
    auto &tets = mesh.tets;
    auto &tets = mesh.tets;
//    static const Scalar zero_area = 1e2 * SCALAR_ZERO_2;
    static const Scalar zero_area = 1e2 * SCALAR_ZERO_2;
    static const Scalar zero_area = 1e-10;
//    static const Scalar zero_area = 1e-10;
    static const std::vector<std::array<int, 4>> face_pairs = {{{0, 1, 2, 3}},
    static const std::vector<std::array<int, 4>> face_pairs = {{{0, 1, 2, 3}},
                                                               {{0, 2, 1, 3}},
                                                               {{0, 2, 1, 3}},
                                                               {{0, 3, 1, 2}}};
                                                               {{0, 3, 1, 2}}};
@@ -1407,8 +1407,8 @@ void floatTetWild::untangle(Mesh &mesh) {
        auto &t = tets[t_id];
        auto &t = tets[t_id];
        if (t.is_removed)
        if (t.is_removed)
            continue;
            continue;
        if (t.quality < 1e7)
//        if (t.quality < 1e7)
//        if (t.quality < 1e10)
        if (t.quality < 1e10)
            continue;
            continue;
        int cnt_on_surface = 0;
        int cnt_on_surface = 0;
        bool has_degenerate_face = false;
        bool has_degenerate_face = false;
+56 −0
Original line number Original line Diff line number Diff line
@@ -596,6 +596,10 @@ bool floatTetWild::insert_one_triangle(int insert_f_id, const std::vector<Vector
    std::vector<int> subdivide_t_ids;
    std::vector<int> subdivide_t_ids;
    if (!cut_mesh.get_intersecting_edges_and_points(points, map_edge_to_intersecting_point, subdivide_t_ids)) {
    if (!cut_mesh.get_intersecting_edges_and_points(points, map_edge_to_intersecting_point, subdivide_t_ids)) {
//        time_get_intersecting_edges_and_points += timer.getElapsedTime();
//        time_get_intersecting_edges_and_points += timer.getElapsedTime();
        if(is_again){
            if(is_uninserted_face_covered(insert_f_id, input_vertices, input_faces, cut_t_ids, mesh))
                return true;
        }
        cout<<"FAIL get_intersecting_edges_and_points"<<endl;
        cout<<"FAIL get_intersecting_edges_and_points"<<endl;
        return false;
        return false;
    }
    }
@@ -620,6 +624,10 @@ bool floatTetWild::insert_one_triangle(int insert_f_id, const std::vector<Vector
                        cut_t_ids, is_mark_surface,
                        cut_t_ids, is_mark_surface,
                        new_tets, new_track_surface_fs, modified_t_ids)) {
                        new_tets, new_track_surface_fs, modified_t_ids)) {
//        time_subdivide_tets += timer.getElapsedTime();
//        time_subdivide_tets += timer.getElapsedTime();
        if(is_again){
            if(is_uninserted_face_covered(insert_f_id, input_vertices, input_faces, cut_t_ids, mesh))
                return true;
        }
        cout<<"FAIL subdivide_tets"<<endl;
        cout<<"FAIL subdivide_tets"<<endl;
        return false;
        return false;
    }
    }
@@ -2741,6 +2749,54 @@ void floatTetWild::mark_surface_fs(const std::vector<Vector3> &input_vertices, c
    }
    }
}
}


bool floatTetWild::is_uninserted_face_covered(int uninserted_f_id, const std::vector<Vector3> &input_vertices, const std::vector<Vector3i> &input_faces,
        const std::vector<int>& cut_t_ids, Mesh &mesh){

    std::array<Vector3, 3> vs = {{input_vertices[input_faces[uninserted_f_id][0]],
                                         input_vertices[input_faces[uninserted_f_id][1]],
                                         input_vertices[input_faces[uninserted_f_id][2]]}};
    std::vector<GEO::vec3> ps;
    sample_triangle(vs, ps, mesh.params.dd);

    std::vector<int> n_t_ids;
    for(int t_id: cut_t_ids) {
        for (int j = 0; j < 4; j++)
            n_t_ids.insert(n_t_ids.end(), mesh.tet_vertices[mesh.tets[t_id][j]].conn_tets.begin(),
                           mesh.tet_vertices[mesh.tets[t_id][j]].conn_tets.end());
    }
    vector_unique(n_t_ids);

    std::vector<std::array<int, 3>> faces;
    for(int t_id: n_t_ids) {
        for (int j = 0; j < 4; j++){
            if(mesh.tets[t_id].is_surface_fs[j] != NOT_SURFACE) {
                faces.push_back(
                        {{mesh.tets[t_id][(j + 1) % 4], mesh.tets[t_id][(j + 2) % 4], mesh.tets[t_id][(j + 3) % 4]}});
                std::sort(faces.back().begin(), faces.back().end());
            }
        }
    }
    vector_unique(faces);

    for(auto& p: ps){
        bool is_valid = false;
        for(auto& f: faces) {
            double dis_2 = GEO::Geom::point_triangle_squared_distance(p, to_geo_p(mesh.tet_vertices[f[0]].pos),
                                                                      to_geo_p(mesh.tet_vertices[f[1]].pos),
                                                                      to_geo_p(mesh.tet_vertices[f[2]].pos));
            if (dis_2 < mesh.params.eps_2) {
                is_valid = true;
                break;
            }
        }
        if(!is_valid)
            return false;
    }

    cout<<"covered!!!!!!!"<<endl;
    return true;
}

int floatTetWild::get_opp_t_id(int t_id, int j, const Mesh &mesh){
int floatTetWild::get_opp_t_id(int t_id, int j, const Mesh &mesh){
    std::vector<int> tmp;
    std::vector<int> tmp;
    set_intersection(mesh.tet_vertices[mesh.tets[t_id][(j + 1) % 4]].conn_tets,
    set_intersection(mesh.tet_vertices[mesh.tets[t_id][(j + 1) % 4]].conn_tets,
+3 −0
Original line number Original line Diff line number Diff line
@@ -92,6 +92,9 @@ namespace floatTetWild {
            bool is_again);
            bool is_again);


    ///other
    ///other
    bool is_uninserted_face_covered(int uninserted_f_id, const std::vector<Vector3> &input_vertices, const std::vector<Vector3i> &input_faces,
                                    const std::vector<int>& cut_t_ids, Mesh &mesh);

    void mark_surface_fs(const std::vector<Vector3> &input_vertices, const std::vector<Vector3i> &input_faces,
    void mark_surface_fs(const std::vector<Vector3> &input_vertices, const std::vector<Vector3i> &input_faces,
                         const std::vector<int> &input_tags,
                         const std::vector<int> &input_tags,
                         std::vector<std::array<std::vector<int>, 4>> &track_surface_fs,
                         std::vector<std::array<std::vector<int>, 4>> &track_surface_fs,