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

Class WireNetwork

python/pymesh/wires/WireNetwork.py:7–328  ·  view source on GitHub ↗

Data structure for wire network. A wire network consists of a list of vertices and a list of edges. Thus, it is very similar to a graph except all vertices have their positions specified. Optionally, each vertex and edge could be associated with one or more attributes. Attribu

Source from the content-addressed store, hash-verified

5import PyMesh
6
7class WireNetwork(object):
8 """ Data structure for wire network.
9
10 A wire network consists of a list of vertices and a list of edges.
11 Thus, it is very similar to a graph except all vertices have their positions
12 specified. Optionally, each vertex and edge could be associated with one or
13 more attributes.
14
15 Attributes:
16
17 dim (``int``): The dimension of the embedding space of this wire network.
18 Must be 2 or 3.
19
20 vertices (:py:class:`numpy.ndarray`): A ``V`` by ``dim`` vertex matrix.
21 One vertex per row.
22
23 edges (:py:class:`numpy.ndarray`): A ``E`` by 2 edge matrix.
24 One edge per row.
25
26 num_vertices (``int``): The number of vertices (i.e. ``V``).
27
28 num_edges (``int``): The number of edges (i.e. ``E``).
29
30 bbox (:py:class:`numpy.ndarray`): A 2 by ``dim`` matrix with first and
31 second rows being the minimum and maximum corners of the bounding
32 box respectively.
33
34 bbox_center (:py:class:`numpy.ndarray`): Center of the ``bbox``.
35
36 centroid (:py:class:`numpy.ndarray`): Average of all ``vertices``.
37
38 wire_lengths (:py:class:`numpy.ndarray`): An array of lengths of all
39 edges.
40
41 total_wire_length (``float``): Sum of ``wire_lengths``.
42
43 attribute_names (:py:class:`list` of :py:class:`str`): The names of all
44 defined attributes.
45 """
46
47 @classmethod
48 def create_empty(cls):
49 """ Handy factory method to create an empty wire network.
50 """
51 return cls()
52
53 @classmethod
54 def create_from_file(cls, wire_file):
55 """ Handy factory method to load data from a file.
56 """
57 wire_network = cls()
58 wire_network.load_from_file(wire_file)
59 return wire_network
60
61 @classmethod
62 def create_from_data(cls, vertices, edges):
63 """ Handy factory method to create wire network from ``vertices`` and
64 ``edges``.

Callers 5

wire_networkMethod · 0.90
load_wiresMethod · 0.90
load_wireFunction · 0.90
generate_supportsFunction · 0.90
load_wireFunction · 0.90

Calls

no outgoing calls

Tested by 1

load_wiresMethod · 0.72