예제 #1
0
void TilerEngine::remove_duplicated_vertices(WireNetwork& wire_network, Float tol) {
    const size_t num_input_vertices = wire_network.get_num_vertices();

    DuplicatedVertexRemoval remover(wire_network.get_vertices(), wire_network.get_edges());
    remover.run(tol);
    MatrixFr vertices = remover.get_vertices();
    MatrixIr edges = remover.get_faces();
    VectorI index_map = remover.get_index_map();
    assert(num_input_vertices == index_map.size());

    wire_network.set_vertices(vertices);
    wire_network.set_edges(edges);

    const size_t num_output_vertices = wire_network.get_num_vertices();
    std::vector<std::string> attr_names = wire_network.get_attribute_names();
    for (auto itr : attr_names) {
        const std::string& name = itr;
        if (wire_network.is_vertex_attribute(name)) {
            MatrixFr values = wire_network.get_attribute(name);
            MatrixFr updated_values = MatrixFr::Zero(num_output_vertices, values.cols());
            VectorF count = VectorF::Zero(num_output_vertices);
            for (size_t i=0; i<num_input_vertices; i++) {
                size_t j = index_map[i];
                updated_values.row(j) += values.row(i);
                count[j] += 1;
            }

            for (size_t i=0; i<num_output_vertices; i++) {
                assert(count[i] > 0);
                updated_values.row(i) /= count[i];
            }
            wire_network.set_attribute(name, updated_values);
        }
    }
}
예제 #2
0
파일: AABBTiler.cpp 프로젝트: qnzhou/PyMesh
void AABBTiler::evaluate_thickness_parameters(WireNetwork& wire_network,
        const AABBTiler::FuncList& funcs) {
    assert(m_params);
    const size_t num_vertices = wire_network.get_num_vertices();
    const size_t num_edges = wire_network.get_num_edges();
    const size_t num_unit_vertices = m_unit_wire_network->get_num_vertices();
    const size_t num_unit_edges = m_unit_wire_network->get_num_edges();

    size_t num_thickness_entries, thickness_index_stride;
    if (m_params->get_thickness_type() == ParameterCommon::VERTEX) {
        thickness_index_stride = num_unit_vertices;
        num_thickness_entries = num_vertices;
        wire_network.add_attribute("thickness", true);
    } else {
        thickness_index_stride = num_unit_edges;
        num_thickness_entries = num_edges;
        wire_network.add_attribute("thickness", false);
    }
    MatrixFr thickness(num_thickness_entries, 1);

    ParameterCommon::Variables vars;
    size_t count=0;
    for (auto f : funcs) {
        VectorF local_thickness = m_params->evaluate_thickness(vars);
        thickness.block(count * thickness_index_stride, 0,
                thickness_index_stride, 1) = local_thickness;
        count++;
    }
    wire_network.set_attribute("thickness", thickness);
}
예제 #3
0
void TilerEngine::remove_duplicated_edges(WireNetwork& wire_network) {
    const size_t num_edges = wire_network.get_num_edges();

    const MatrixIr& edges = wire_network.get_edges();
    std::vector<bool> mask = create_duplication_mask(edges);

    MatrixIr updated_edges = filter(edges, mask);
    wire_network.set_edges(updated_edges);

    std::vector<std::string> attr_names = wire_network.get_attribute_names();
    for (auto itr : attr_names) {
        const std::string& name = itr;
        if (!wire_network.is_vertex_attribute(name)) {
            MatrixFr values = wire_network.get_attribute(name);
            MatrixFr updated_values = filter(values, mask);
            wire_network.set_attribute(name, updated_values);
        }
    }
}
예제 #4
0
void TilerEngine::update_attributes(WireNetwork& wire_network, size_t num_repetitions) {
    std::vector<std::string> attr_names = m_unit_wire_network->get_attribute_names();
    for (auto itr : attr_names) {
        const std::string& name = itr;
        wire_network.add_attribute(name,
                m_unit_wire_network->is_vertex_attribute(name), false);

        const MatrixFr& values = m_unit_wire_network->get_attribute(name);
        const size_t rows = values.rows();
        const size_t cols = values.cols();
        MatrixFr tiled_values(rows * num_repetitions, cols);

        for (size_t i=0; i<num_repetitions; i++) {
            tiled_values.block(i*rows, 0, rows, cols) = values;
        }

        wire_network.set_attribute(name, tiled_values);
    }
}
예제 #5
0
파일: AABBTiler.cpp 프로젝트: qnzhou/PyMesh
void AABBTiler::evaluate_offset_parameters(WireNetwork& wire_network,
        const AABBTiler::FuncList& funcs) {
    const size_t dim = wire_network.get_dim();
    const size_t num_vertices = wire_network.get_num_vertices();
    const size_t num_unit_vertices = m_unit_wire_network->get_num_vertices();

    wire_network.add_attribute("vertex_offset", true);
    MatrixFr attr_value(num_vertices, dim);

    ParameterCommon::Variables vars;
    const MatrixFr& ori_vertices = m_unit_wire_network->get_vertices();
    size_t count=0;
    for (auto f : funcs) {
        MatrixFr local_offseted_vertices = ori_vertices + m_params->evaluate_offset(vars);
        attr_value.block(count * num_unit_vertices, 0,
                num_unit_vertices, dim) = f(local_offseted_vertices);
        count++;
    }

    attr_value = attr_value - wire_network.get_vertices();
    wire_network.set_attribute("vertex_offset", attr_value);
}