Wire -- mesh of points, or suite of points¶

Wire(points=None, indices=None, tracks=None, groups=None, options=None)
¶
Bases: NMesh
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])
Attributes:
| Name | Type | Description |
|---|---|---|
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 |
Source code in madcad/mesh/wire.py
36 37 38 39 40 41 | |
Special methods
__add__(other)
¶
append the indices and points of the other wire
Source code in madcad/mesh/wire.py
54 55 56 57 58 59 60 61 62 63 64 65 66 | |
__iadd__(other)
¶
append the indices and points of the other wire
Source code in madcad/mesh/wire.py
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 | |
__len__()
¶
Source code in madcad/mesh/wire.py
43 | |
__iter__()
¶
Source code in madcad/mesh/wire.py
44 | |
__getitem__(i)
¶
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]]
Source code in madcad/mesh/wire.py
45 46 47 48 49 50 51 52 | |
Data management
own(**kwargs)
¶
Return a copy of the current mesh, which attributes are referencing the original data or duplicates if demanded
Examples:
>>> b = a.own(points=True, faces=False)
>>> b.points is a.points
False
>>> b.faces is a.faces
True
Source code in madcad/mesh/container.py
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 | |
option(**kwargs)
¶
Update the internal options with the given dictionary and the keywords arguments. This is only a shortcut to set options in a method style.
Source code in madcad/mesh/container.py
43 44 45 46 47 48 | |
transform(trans)
¶
Apply the transform to the points of the mesh, returning the new transformed mesh
Source code in madcad/mesh/container.py
50 51 52 53 54 55 | |
mergeclose(limit=None)
¶
merge close points ONLY WHEN they are already linked by an edge.
the meaning of this method is different than Web.mergeclose()
Source code in madcad/mesh/wire.py
139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 | |
mergepoints(merges)
¶
merge points with the merge dictionnary {src index: dst index} merged points are not removed from the buffer.
Source code in madcad/mesh/wire.py
124 125 126 127 128 129 130 131 132 133 134 135 136 137 | |
mergegroups(defs=None, merges=None)
¶
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
Source code in madcad/mesh/container.py
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 | |
strippoints()
¶
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
Source code in madcad/mesh/wire.py
112 113 114 115 116 117 118 119 120 121 122 | |
stripgroups()
¶
Remove groups that are used by no faces. return the reindex list.
Source code in madcad/mesh/container.py
74 75 76 77 | |
finish()
¶
Finish and clean the mesh note that this operation can cost as much as other transformation operation job done
- mergeclose
- strippoints
- stripgroups
- check
Source code in madcad/mesh/container.py
100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 | |
Mesh checks
check()
¶
raise if the internal data are not consistent
Source code in madcad/mesh/wire.py
165 166 167 168 169 170 171 172 173 174 175 | |
isvalid()
¶
Return true if the internal data is consistent (all indices referes to actual points and groups)
Source code in madcad/mesh/container.py
118 119 120 121 122 | |
Selection methods
pointnear(point)
¶
Return the nearest point the the given location
Source code in madcad/mesh/container.py
131 132 133 134 | |
pointat(point, neigh=NUMPREC)
¶
Return the index of the first point at the given location, or None
Source code in madcad/mesh/container.py
126 127 128 129 | |
groupnear(point)
¶
return group id if the edge the closest to the given point
Source code in madcad/mesh/wire.py
180 181 182 | |
edgenear(point)
¶
return the index of the closest edge to the given point
Source code in madcad/mesh/wire.py
184 185 186 187 | |
group(groups)
¶
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
Examples:
>>> # 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 ...>
Source code in madcad/mesh/wire.py
189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 | |
Extraction methods
length()
¶
curviform length of the wire (sum of all edges length)
Source code in madcad/mesh/wire.py
247 248 249 250 251 252 | |
surface()
¶
return the surface enclosed by the web if planar and is a loop (else it has no meaning)
Source code in madcad/mesh/wire.py
254 255 256 257 258 259 260 | |
barycenter()
¶
curve barycenter
Source code in madcad/mesh/wire.py
262 263 264 265 266 267 268 269 270 271 272 273 | |
barycenter_points()
¶
Barycenter of points used
Source code in madcad/mesh/container.py
249 250 251 | |
box()
¶
Return the extreme coordinates of the mesh (vec3, vec3)
Source code in madcad/mesh/container.py
237 238 239 240 241 242 243 244 245 246 247 | |
normal()
¶
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.
Source code in madcad/mesh/wire.py
275 276 277 278 279 280 281 282 283 | |
edgepoints(e)
¶
shorthand to the tuple of points forming edge e
Source code in madcad/mesh/wire.py
226 227 228 229 230 | |
edgedirection(e)
¶
direction of edge e
Source code in madcad/mesh/wire.py
232 233 234 235 236 | |
edge(i)
¶
ith edge of the wire
Source code in madcad/mesh/wire.py
239 240 241 | |
edges()
¶
list of successive edges of the wire
Source code in madcad/mesh/wire.py
243 244 245 | |
vertexnormals(loop=False)
¶
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
Source code in madcad/mesh/wire.py
285 286 287 288 289 290 291 292 293 294 | |
tangents(loop=False)
¶
return approximated tangents to the curve as if it was a surface section. if this is not a loop the result is undefined.
Source code in madcad/mesh/wire.py
296 297 298 299 300 301 302 303 304 305 | |
flip()
¶
reverse direction of all edges
Source code in madcad/mesh/wire.py
332 333 334 335 336 337 338 339 340 341 342 | |
close()
¶
make a loop of the wire by appending its first point to its end
Source code in madcad/mesh/wire.py
344 345 346 347 348 349 350 | |
segmented(group=None)
¶
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
Source code in madcad/mesh/wire.py
360 361 362 363 364 365 366 367 368 369 370 | |