Wire - mesh of points, or suite of points

../../_images/mesh-wire.png
class Wire(points=None, indices=None, tracks=None, groups=None, options=None)[source]

This class defines a mesh of points, used for two purposes:

  • curves, wires, paths, storing the ordered suite of point indices
  • cloud points, points extracted from other mesh, storing the unordered points indices

Most of the methods of Wire are intended for the first use case.

conventions:

  • A curve is considered closed (or to be a loop) when its final index is the same as the first.
  • tracks are matching indices, giving a group each index. But for curves, track[i] gives a group for edge (indices[i], indices[i+1])
points

points buffer

indices

indices of the line’s points in the buffer

tracks

group index for each point in indices it can be used to associate groups to points or to edges (if to edges, then take care to still have as many track as indices)

groups

data associated to each point (or edge)

options

custom informations for the entire wire

__add__(other)[source]

append the indices and points of the other wire

__iadd__(other)[source]

append the indices and points of the other wire

__len__()[source]
__iter__()[source]
__getitem__(i)[source]

return the ith point of the wire, useful to use the wire in a same way as list of points

equivalent to self.points[self.indices[i]]

own(**kwargs) Self

Return a copy of the current mesh, which attributes are referencing the original data or duplicates if demanded

Example

>>> b = a.own(points=True, faces=False)
>>> b.points is a.points
False
>>> b.faces is a.faces
True
option(**kwargs) self

Update the internal options with the given dictionary and the keywords arguments. This is only a shortcut to set options in a method style.

transform(trans) Self

Apply the transform to the points of the mesh, returning the new transformed mesh

mergeclose(limit=None)[source]

merge close points ONLY WHEN they are already linked by an edge. the meaning of this method is different than Web.mergeclose()

mergepoints(merges) self[source]

merge points with the merge dictionnary {src index: dst index} merged points are not removed from the buffer.

mergegroups(defs=None, merges=None) self

Merge the groups according to the merge dictionary The new groups associated can be specified with defs The former unused groups are not removed from the buffer and the new ones are appended

If merges is not provided, all groups are merged, and defs is the data associated to the only group after the merge

strippoints()[source]

remove points that are used by no edge if used is provided, these points will be removed without usage verification

no reindex table is returned as its generation costs more than the stripping operation

stripgroups() list

Remove groups that are used by no faces. return the reindex list.

finish() self
Finish and clean the mesh
note that this operation can cost as much as other transformation operation job done
  • mergeclose
  • strippoints
  • stripgroups
  • check
check()[source]

raise if the internal data are not consistent

isvalid()

Return true if the internal data is consistent (all indices referes to actual points and groups)

pointnear(point: dvec3) int

Return the nearest point the the given location

pointat(point: dvec3, neigh=1e-13) int

Return the index of the first point at the given location, or None

groupnear(point: dvec3) int[source]

return group id if the edge the closest to the given point

edgenear(point: dvec3) int[source]

return the index of the closest edge to the given point

group(groups)[source]

extract a part of the mesh corresponding to the designated groups.

Groups can be be given in either the following ways:
  • a set of group indices

    This can be useful to combine with other functions. However it can be difficult for a user script to keep track of which index correspond to which created group

  • an iterable of group qualifiers

    This is the best way to designate groups, and is meant to be used in combination with self.qual(). This mode selects every group having all the input qualifiers

Example

>>> # create a mesh with only the given groups
>>> mesh.group({1, 3, 8, 9})
<Mesh ...>
>>> # create a mesh with all the groups having the following qualifiers
>>> mesh.group(['extrusion', 'arc'])
<Mesh ...>
length() float[source]

curviform length of the wire (sum of all edges length)

surface() float[source]

return the surface enclosed by the web if planar and is a loop (else it has no meaning)

barycenter() dvec3[source]

curve barycenter

barycenter_points() dvec3

Barycenter of points used

box() Box

Return the extreme coordinates of the mesh (vec3, vec3)

normal() dvec3[source]

return an approximated normal to the curve as if it was the outline of a flat surface. if this is not a loop the result is undefined.

edgepoints(e) tuple[source]

shorthand to the tuple of points forming edge e

edgedirection(e) dvec3[source]

direction of edge e

edge(i) uvec2[source]

ith edge of the wire

edges() typedlist[source]

list of successive edges of the wire

vertexnormals(loop=False)[source]

return the opposed direction to the curvature in each point this is called normal because it would be the normal to a surface whose section would be that wire

tangents(loop=False)[source]

return approximated tangents to the curve as if it was a surface section. if this is not a loop the result is undefined.

flip() Wire[source]

reverse direction of all edges

close() self[source]

make a loop of the wire by appending its first point to its end

segmented(group=None) Wire[source]

return a copy of the mesh with a group each edge

if group is specified, it will be the new definition put in each groups