当前位置: 首页>>代码示例>>C++>>正文


C++ MatrixIr类代码示例

本文整理汇总了C++中MatrixIr的典型用法代码示例。如果您正苦于以下问题:C++ MatrixIr类的具体用法?C++ MatrixIr怎么用?C++ MatrixIr使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了MatrixIr类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: generate_joint

void SimpleInflator::generate_joint(
        const MatrixFr& pts, const VectorI& source_ids, size_t vertex_index) {
    const size_t dim = m_wire_network->get_dim();
    ConvexHullEngine::Ptr convex_hull = ConvexHullEngine::create(dim, "qhull");
    convex_hull->run(pts);

    MatrixFr vertices = convex_hull->get_vertices();
    MatrixIr faces = convex_hull->get_faces();
    VectorI  index_map = convex_hull->get_index_map();

    if (dim == 2) {
        // Need to triangulate the loop.
        const size_t num_vertices = vertices.rows();
        TriangleWrapper tri(vertices, faces);
        tri.run(std::numeric_limits<Float>::max(), false, false, false);
        vertices = tri.get_vertices();
        faces = tri.get_faces();
        assert(vertices.rows() == num_vertices);
    }

    m_vertex_list.push_back(vertices);
    const size_t num_faces = faces.rows();
    for (size_t i=0; i<num_faces; i++) {
        const auto& face = faces.row(i);
        if (dim == 3) {
            auto ori_indices = map_indices(face, index_map);
            if (belong_to_the_same_loop(ori_indices, source_ids)) continue;
        }
        m_face_list.push_back(face.array() + m_num_vertex_accumulated);
        m_face_source_list.push_back(vertex_index+1);
    }

    m_num_vertex_accumulated += vertices.rows();
}
开发者ID:gaoyue17,项目名称:PyMesh,代码行数:34,代码来源:SimpleInflator.cpp

示例2: raw_to_geomesh

GeoMeshPtr GeogramMeshUtils::raw_to_geomesh(
        const MatrixFr& vertices, const MatrixIr& faces) {
    const size_t dim = vertices.cols();
    const size_t vertex_per_face = faces.cols();
    const size_t num_vertices = vertices.rows();
    const size_t num_faces = faces.rows();

    if (vertex_per_face != 3) {
        throw NotImplementedError("Converting non-triangle mesh to "
                "Geogram mesh is not yet implemented");
    }

    auto geo_mesh = std::make_shared<GeoMesh>(dim, false);
    geo_mesh->vertices.clear();
    geo_mesh->vertices.create_vertices(num_vertices);
    geo_mesh->facets.clear();
    geo_mesh->facets.create_triangles(num_faces);

    for (size_t i=0; i<num_vertices; i++) {
        auto& p = geo_mesh->vertices.point(i);
        for (size_t j=0; j<dim; j++) {
            p[j] = vertices(i,j);
        }
    }

    for (size_t i=0; i<num_faces; i++) {
        geo_mesh->facets.set_vertex(i, 0, faces(i,0));
        geo_mesh->facets.set_vertex(i, 1, faces(i,1));
        geo_mesh->facets.set_vertex(i, 2, faces(i,2));
    }

    return geo_mesh;
}
开发者ID:qnzhou,项目名称:PyMesh,代码行数:33,代码来源:GeogramMeshUtils.cpp

示例3: create_mesh

    CarveMeshPtr create_mesh(const MatrixFr& vertices, const MatrixIr& faces) {
        const size_t num_vertices = vertices.rows();
        const size_t num_faces = faces.rows();

        if (vertices.cols() != 3) {
            throw NotImplementedError("Only 3D mesh is supported.");
        }
        if (faces.cols() != 3) {
            throw NotImplementedError("Only triangle mesh is supported.");
        }

        std::vector<CarveVector> points;

        for (size_t i=0; i<num_vertices; i++) {
            const auto& v = vertices.row(i);
            CarveVector p;
            p.v[0] = v[0];
            p.v[1] = v[1];
            p.v[2] = v[2];
            points.push_back(p);
        }

        std::vector<int> raw_faces;
        raw_faces.reserve(num_faces * 4);
        for (size_t i=0; i<num_faces; i++) {
            raw_faces.push_back(3);
            raw_faces.push_back(faces(i,0));
            raw_faces.push_back(faces(i,1));
            raw_faces.push_back(faces(i,2));
        }

        return CarveMeshPtr(new CarveMesh(points, num_faces, raw_faces));
    }
开发者ID:gaoyue17,项目名称:PyMesh,代码行数:33,代码来源:CarveEngine.cpp

示例4: generate_end_loops

void SimpleInflator::generate_end_loops() {
    const size_t num_edges = m_wire_network->get_num_edges();

    const MatrixFr vertices = m_wire_network->get_vertices();
    const MatrixIr edges = m_wire_network->get_edges();
    const MatrixFr edge_thickness = get_edge_thickness();
    for (size_t i=0; i<num_edges; i++) {
        const VectorI& edge = edges.row(i);
        const VectorF& v1 = vertices.row(edge[0]);
        const VectorF& v2 = vertices.row(edge[1]);
        Float edge_len = (v2 - v1).norm();
        MatrixFr loop_1 = m_profile->place(v1, v2,
                m_end_loop_offsets[edge[0]],
                edge_thickness(i, 0),
                m_rel_correction, m_abs_correction, m_correction_cap,
                m_spread_const);
        assert(loop_is_valid(loop_1, v1, v2));
        MatrixFr loop_2 = m_profile->place(v1, v2,
                edge_len - m_end_loop_offsets[edge[1]],
                edge_thickness(i, 1),
                m_rel_correction, m_abs_correction, m_correction_cap,
                m_spread_const);
        assert(loop_is_valid(loop_2, v1, v2));
        m_end_loops.push_back(std::make_pair(loop_1, loop_2));
    }
}
开发者ID:gaoyue17,项目名称:PyMesh,代码行数:26,代码来源:SimpleInflator.cpp

示例5: NotImplementedError

SelfIntersection::SelfIntersection(
        const MatrixFr& vertices, const MatrixIr& faces)
: m_faces(faces) {
    const size_t num_vertices = vertices.rows();
    const size_t dim = vertices.cols();
    const size_t num_faces = faces.rows();
    const size_t vertex_per_face = faces.cols();

    if (dim != 3) {
        throw NotImplementedError(
                "Self intersection check only support 3D");
    }
    if (vertex_per_face != 3) {
        throw NotImplementedError(
                "Self intersection check only works with triangles");
    }

    m_points.resize(num_vertices);
    for (size_t i=0; i<num_vertices; i++) {
        m_points[i] = Point_3(
                vertices(i,0),
                vertices(i,1),
                vertices(i,2));
    }
}
开发者ID:luozhipi,项目名称:PyMesh,代码行数:25,代码来源:SelfIntersection.cpp

示例6: extract_mesh

    void extract_mesh(const C3t3& c3t3,
            MatrixFr& vertices, MatrixIr& faces, MatrixIr& voxels) {
        const Tr& tr = c3t3.triangulation();
        size_t num_vertices = tr.number_of_vertices();
        size_t num_faces = c3t3.number_of_facets_in_complex();
        size_t num_voxels = c3t3.number_of_cells_in_complex();

        vertices.resize(num_vertices, 3);
        faces.resize(num_faces, 3);
        voxels.resize(num_voxels, 4);

        std::map<Tr::Vertex_handle, int> V;
        size_t inum = 0;
        for(auto vit = tr.finite_vertices_begin();
                vit != tr.finite_vertices_end(); ++vit) {
            V[vit] = inum;
            const auto& p = vit->point();
            vertices.row(inum) = Vector3F(p.x(), p.y(), p.z()).transpose();
            assert(inum < num_vertices);
            inum++;
        }
        assert(inum == num_vertices);

        size_t face_count = 0;
        for(auto fit = c3t3.facets_in_complex_begin();
                fit != c3t3.facets_in_complex_end(); ++fit) {
            assert(face_count < num_faces);
            for (int i=0; i<3; i++) {
                if (i != fit->second) {
                    const auto& vh = (*fit).first->vertex(i);
                    assert(V.find(vh) != V.end());
                    const int vid = V[vh];
                    faces(face_count, i) = vid;
                }
            }
            face_count++;
        }
        assert(face_count == num_faces);

        size_t voxel_count = 0;
        for(auto cit = c3t3.cells_in_complex_begin() ;
                cit != c3t3.cells_in_complex_end(); ++cit ) {
            assert(voxel_count < num_voxels);
            for (int i=0; i<4; i++) {
                assert(V.find(cit->vertex(i)) != V.end());
                const size_t vid = V[cit->vertex(i)];
                voxels(voxel_count, i) = vid;
            }
            voxel_count++;
        }
        assert(voxel_count == num_voxels);
    }
开发者ID:gaoyue17,项目名称:PyMesh,代码行数:52,代码来源:CGALMeshGen.cpp

示例7: extract_surface_boundary_raw

Boundary::Ptr Boundary::extract_surface_boundary_raw(
        MatrixFr& vertices, MatrixIr& faces) {
    VectorF flattened_vertices = Eigen::Map<VectorF>(vertices.data(),
            vertices.rows() * vertices.cols());
    VectorI flattened_faces = Eigen::Map<VectorI>(faces.data(),
            faces.rows() * faces.cols());
    VectorI voxels = VectorI::Zero(0);

    MeshFactory factory;
    Mesh::Ptr mesh = factory.load_data(flattened_vertices, flattened_faces,
            voxels, vertices.cols(), faces.cols(), 0).create();

    return extract_surface_boundary(*mesh);
}
开发者ID:qnzhou,项目名称:PyMesh,代码行数:14,代码来源:Boundary.cpp

示例8: reorientate_triangles

    void reorientate_triangles(const MatrixFr& vertices, MatrixIr& faces,
            const VectorF& n) {
        assert(vertices.cols() == 3);
        assert(faces.cols() == 3);

        const VectorI& f = faces.row(0);
        const Vector3F& v0 = vertices.row(f[0]);
        const Vector3F& v1 = vertices.row(f[1]);
        const Vector3F& v2 = vertices.row(f[2]);

        Float projected_area = (v1-v0).cross(v2-v0).dot(n);
        if (projected_area < 0) {
            faces.col(2).swap(faces.col(1));
        }
    }
开发者ID:luozhipi,项目名称:PyMesh,代码行数:15,代码来源:BoundaryRemesher.cpp

示例9: extract_data

    void extract_data(CarveMeshPtr mesh, MatrixFr& vertices, MatrixIr& faces) {
        typedef CarveMesh::vertex_t CarveVertex;
        const size_t num_vertices = mesh->vertex_storage.size();
        vertices.resize(num_vertices, 3);
        for (size_t i=0; i<num_vertices; i++) {
            const auto& v = mesh->vertex_storage[i];
            vertices(i,0) = v.v.x;
            vertices(i,1) = v.v.y;
            vertices(i,2) = v.v.z;
        }

        const size_t num_faces = mesh->faceEnd() - mesh->faceBegin();
        faces.resize(num_faces, 3);
        for (auto itr=mesh->faceBegin(); itr != mesh->faceEnd(); itr++) {
            std::vector<CarveVertex* > vts;
            (*itr)->getVertices(vts);
            assert(vts.size() == 3);

            // WARNING:
            // Here is my guess on how to extract vertex index.
            // Carve's documentation is not clear on how to do this.  
            const size_t fid = itr - mesh->faceBegin();
            faces(fid, 0) = vts[0] - &mesh->vertex_storage[0];
            faces(fid, 1) = vts[1] - &mesh->vertex_storage[0];
            faces(fid, 2) = vts[2] - &mesh->vertex_storage[0];
        }
    }
开发者ID:gaoyue17,项目名称:PyMesh,代码行数:27,代码来源:CarveEngine.cpp

示例10: create_box

 void create_box(const VectorF& bbox_min, const VectorF& bbox_max,
         MatrixFr& box_vertices, MatrixIr& box_faces) {
     box_vertices.resize(8, 3);
     box_faces.resize(12, 3);
     box_vertices << bbox_min[0], bbox_min[1], bbox_min[2],
                     bbox_max[0], bbox_min[1], bbox_min[2],
                     bbox_max[0], bbox_max[1], bbox_min[2],
                     bbox_min[0], bbox_max[1], bbox_min[2],
                     bbox_min[0], bbox_min[1], bbox_max[2],
                     bbox_max[0], bbox_min[1], bbox_max[2],
                     bbox_max[0], bbox_max[1], bbox_max[2],
                     bbox_min[0], bbox_max[1], bbox_max[2];
     box_faces << 1, 2, 5,
                  5, 2, 6,
                  3, 4, 7,
                  3, 0, 4,
                  2, 3, 6,
                  3, 7, 6,
                  0, 1, 5,
                  0, 5, 4,
                  4, 5, 6,
                  4, 6, 7,
                  0, 3, 2,
                  0, 2, 1;
 }
开发者ID:gaoyue17,项目名称:PyMesh,代码行数:25,代码来源:PeriodicInflator3D.cpp

示例11: compute_edge_map

    EdgeMap compute_edge_map(const MatrixIr& faces) {
        assert(faces.cols() == 3);
        EdgeMap result;
        const size_t num_faces = faces.rows();
        for (size_t i=0; i<num_faces; i++) {
            const Vector3I& f = faces.row(i);
            Triplet e0(f[1], f[2]);
            Triplet e1(f[2], f[0]);
            Triplet e2(f[0], f[1]);

            result.insert(e0, i);
            result.insert(e1, i);
            result.insert(e2, i);
        }

        return result;
    }
开发者ID:gaoyue17,项目名称:PyMesh,代码行数:17,代码来源:MeshValidation.cpp

示例12: get_num_cells

WireNetwork::Ptr MixedMeshTiler::tile() {
    const size_t num_cells = get_num_cells();
    auto transforms = get_tiling_operators();
    auto vars_array = extract_attributes(m_mesh);
    VectorI pattern_id = m_mesh->get_attribute("pattern_id").cast<int>();
    assert(pattern_id.size() == num_cells);

    m_tiled_vertices.clear();
    m_tiled_edges.clear();
    m_tiled_thicknesses.clear();
    m_tiled_offsets.clear();

    size_t v_count = 0;
    auto transform_itr = transforms.begin();
    for (size_t i=0; i<num_cells; i++) {
        set_active_wire_network(pattern_id[i]);
        scale_to_unit_box();
        append_vertices(*transform_itr);
        append_edges(v_count);
        append_thicknesses(vars_array[i]);
        append_offsets(vars_array[i], *transform_itr);

        v_count += m_unit_wire_network->get_num_vertices();
        transform_itr++;
    }

    MatrixFr vertices = vstack(m_tiled_vertices);
    MatrixIr edges = vstack(m_tiled_edges);
    MatrixFr thicknesses = vstack(m_tiled_thicknesses);
    MatrixFr offsets = vstack(m_tiled_offsets);
    assert(edges.minCoeff() >= 0);
    assert(edges.maxCoeff() < vertices.rows());

    WireNetwork::Ptr tiled_network =
        WireNetwork::create_raw(vertices, edges);

    tiled_network->add_attribute("thickness",
            m_target_type == ParameterCommon::VERTEX);
    tiled_network->set_attribute("thickness", thicknesses);
    tiled_network->add_attribute("vertex_offset", true);
    tiled_network->set_attribute("vertex_offset", offsets);

    clean_up(*tiled_network);
    return tiled_network;
}
开发者ID:gaoyue17,项目名称:PyMesh,代码行数:45,代码来源:MixedMeshTiler.cpp

示例13: generate_polyhedron

 Polyhedron generate_polyhedron(
         const MatrixFr& vertices, const MatrixIr& faces) {
     Polyhedron P;
     PolyhedronBuilder<HalfedgeDS> triangle(vertices, faces);
     P.delegate(triangle);
     assert(vertices.rows() == P.size_of_vertices());
     assert(faces.rows() == P.size_of_facets());
     return P;
 }
开发者ID:gaoyue17,项目名称:PyMesh,代码行数:9,代码来源:CGALMeshGen.cpp

示例14: create_duplication_mask

    std::vector<bool> create_duplication_mask(const MatrixIr& edges) {
        const size_t num_edges = edges.rows();

        std::unordered_set<Triplet, hash> unique_set;
        std::vector<bool> mask(num_edges, false);

        for (size_t i=0; i<num_edges; i++) {
            const auto& edge = edges.row(i);
            Triplet key(edge[0], edge[1]);
            auto itr = unique_set.find(key);
            if (itr == unique_set.end()) {
                unique_set.insert(key);
            } else {
                mask[i] = true;
            }
        }

        return mask;
    }
开发者ID:gaoyue17,项目名称:PyMesh,代码行数:19,代码来源:TilerEngine.cpp

示例15: get_triangle_bboxes

 std::vector<Box> get_triangle_bboxes(
         const SelfIntersection::Points& pts, const MatrixIr& faces) {
     const size_t num_faces = faces.rows();
     std::vector<Box> boxes;
     boxes.reserve(num_faces);
     for (size_t i=0; i<num_faces; i++) {
         const Vector3I f = faces.row(i);
         const std::vector<SelfIntersection::Point_3> corners{
             pts[f[0]], pts[f[1]], pts[f[2]]
         };
         if (CGAL::collinear(pts[f[0]], pts[f[1]], pts[f[2]])) {
             // Triangle is degenerated.
             continue;
         }
         boxes.emplace_back(CGAL::bbox_3(corners.begin(), corners.end()));
         boxes.back().set_id(i);
     }
     return boxes;
 }
开发者ID:luozhipi,项目名称:PyMesh,代码行数:19,代码来源:SelfIntersection.cpp


注:本文中的MatrixIr类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。