Esempio n. 1
0
void PeriodicExploration::update_mesh() {
    const size_t dim = m_vertices.cols();

    const size_t num_vertices = m_vertices.rows();
    const size_t num_faces = m_faces.rows();
    const size_t vertex_per_face = m_faces.cols();
    const size_t num_voxels = m_voxels.rows();
    const size_t vertex_per_voxel = m_voxels.cols();

    VectorF flattened_vertices = Eigen::Map<VectorF>(m_vertices.data(),
            num_vertices * dim);
    VectorI flattened_faces = Eigen::Map<VectorI>(m_faces.data(), num_faces *
            vertex_per_face);
    VectorI flattened_voxels = Eigen::Map<VectorI>(m_voxels.data(), num_voxels *
            vertex_per_voxel);
    VectorF face_sources = m_face_sources.cast<Float>();

    MeshFactory factory;
    factory.load_data(
            flattened_vertices, flattened_faces, flattened_voxels,
            dim, vertex_per_face, vertex_per_voxel);
    m_mesh = factory.create_shared();

    m_mesh->add_attribute("face_source");
    m_mesh->set_attribute("face_source", face_sources);
}
Esempio n. 2
0
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);
}
Esempio n. 3
0
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);
}