MCPcopy Create free account
hub / github.com/PyMesh/PyMesh / compute

Method compute

tools/Wires/WireNetwork/WireConnectivity.cpp:12–38  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

10using namespace PyMesh;
11
12void WireConnectivity::compute() {
13 const size_t num_vertices = m_wire_network->get_num_vertices();
14 const size_t num_edges = m_wire_network->get_num_edges();
15 std::vector<std::list<size_t> > adjacencies(num_vertices);
16
17 const MatrixIr& edges = m_wire_network->get_edges();
18 for (size_t i=0; i<num_edges; i++) {
19 const VectorI& edge = edges.row(i);
20 adjacencies[edge[0]].push_back(edge[1]);
21 adjacencies[edge[1]].push_back(edge[0]);
22 }
23
24 size_t count=0;
25 m_vertex_adjacency_index.resize(num_vertices+1);
26 m_vertex_adjacency_index[0] = 0;
27 std::list<size_t> all_adjacencies;
28 for (auto adj : adjacencies) {
29 m_vertex_adjacency_index[count+1] =
30 m_vertex_adjacency_index[count] + adj.size();
31 all_adjacencies.splice(all_adjacencies.end(), adj);
32 count++;
33 }
34
35 m_vertex_adjacencies.resize(all_adjacencies.size());
36 std::copy(all_adjacencies.begin(), all_adjacencies.end(),
37 m_vertex_adjacencies.data());
38}
39
40void WireConnectivity::reset() {
41 m_vertex_adjacencies.resize(0);

Callers 1

compute_connectivityMethod · 0.45

Calls 6

get_num_verticesMethod · 0.45
get_num_edgesMethod · 0.45
get_edgesMethod · 0.45
sizeMethod · 0.45
endMethod · 0.45
beginMethod · 0.45

Tested by

no test coverage detected