예제 #1
0
void InflatorEngine::save_mesh(const std::string& filename,
        const MatrixFr& vertices, const MatrixIr& faces, VectorF debug) {
    VectorF flattened_vertices(vertices.rows() * vertices.cols());
    std::copy(vertices.data(), vertices.data() + vertices.rows() *
            vertices.cols(), flattened_vertices.data());
    VectorI flattened_faces(faces.rows() * faces.cols());
    std::copy(faces.data(), faces.data() + faces.rows() * faces.cols(),
            flattened_faces.data());
    VectorI voxels = VectorI::Zero(0);

    Mesh::Ptr mesh = MeshFactory().load_data(
            flattened_vertices, flattened_faces, voxels,
            vertices.cols(), faces.cols(), 0).create_shared();
    mesh->add_attribute("debug");
    mesh->set_attribute("debug", debug);

    MeshWriter::Ptr writer = MeshWriter::create(filename);
    writer->with_attribute("debug");
    writer->write_mesh(*mesh);
}
예제 #2
0
파일: Boundary.cpp 프로젝트: qnzhou/PyMesh
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);
}
예제 #3
0
파일: Boundary.cpp 프로젝트: qnzhou/PyMesh
Boundary::Ptr Boundary::extract_volume_boundary_raw(
        MatrixFr& vertices, MatrixIr& voxels) {
    VectorF flattened_vertices = Eigen::Map<VectorF>(vertices.data(),
            vertices.rows() * vertices.cols());
    VectorI faces = VectorI::Zero(0);
    VectorI flattened_voxels = Eigen::Map<VectorI>(voxels.data(),
            voxels.rows() * voxels.cols());

    size_t vertex_per_voxel = voxels.cols();
    size_t vertex_per_face=0;
    if (vertex_per_voxel == 4) vertex_per_face = 3;
    else if (vertex_per_voxel == 8) vertex_per_face = 4;
    else {
        throw RuntimeError("Unknown voxel type.");
    }

    MeshFactory factory;
    Mesh::Ptr mesh = factory.load_data(flattened_vertices, faces,
            flattened_voxels, vertices.cols(), vertex_per_face,
            vertex_per_voxel).create();

    return extract_volume_boundary(*mesh);
}