Web -- mesh of edges¶

Web(points=None, edges=None, tracks=None, groups=None, options=None)
¶
Bases: NMesh
set of bipoint edges, used to represent wires this definition is very close to the definition of Mesh, but with edges instead of triangles
Note
a Wire instance can contain non-connex geometries (like many separated outlines, called islands), or even non-linear meshing (like intersecting curves). In the purpose of part design, many functions may need more regular characteristics, so checking methods exists and it is up to the user to ensure the mesh do provide them when calling the demanding functions
Attributes:
| Name | Type | Description |
|---|---|---|
points |
typedlist of vec3 for points |
|
edges |
typedlist of couples for edges, the couple is oriented (meanings of this depends on the usage) |
|
tracks |
typedlist of integers giving the group each line belong to |
|
groups |
custom information for each group |
|
options |
custom informations for the entire web |
Source code in madcad/mesh/web.py
32 33 34 35 36 37 | |
Special methods
__add__(other)
¶
return a new mesh concatenating the faces and points of both meshes
Source code in madcad/mesh/web.py
39 40 41 42 43 44 45 46 47 48 49 50 51 | |
__iadd__(other)
¶
append the faces and points of the other mesh
Source code in madcad/mesh/web.py
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 | |
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 points below the specified distance, or below the precision return a dictionary of points remapping {src index: dst index}
O(n) implementation thanks to hashing
Source code in madcad/mesh/container.py
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 | |
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/web.py
95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 | |
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 faces, return the reindex list. if used is provided, these points will be removed without usage verification
return a table of the reindex made
Source code in madcad/mesh/web.py
86 87 88 89 90 91 92 93 | |
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()
¶
check that the internal data references are good (indices and list lengths)
Source code in madcad/mesh/web.py
129 130 131 132 133 134 135 136 137 138 139 140 141 | |
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 | |
isline()
¶
true if each point is used at most 2 times by edges
Source code in madcad/mesh/web.py
116 117 118 119 120 121 122 123 | |
isloop()
¶
true if the wire form a loop
Source code in madcad/mesh/web.py
125 126 127 | |
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/web.py
147 148 149 | |
edgenear(point)
¶
return the index of the closest edge to the given point
Source code in madcad/mesh/web.py
151 152 153 154 | |
group(quals)
¶
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/web.py
156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 | |
replace(mesh, groups=None)
¶
replace the given groups by the given mesh. If groups is not specified, it will take the matching groups (with same index) in the current mesh
Source code in madcad/mesh/web.py
185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 | |
qualify(*quals, select=None, replace=False)
¶
Set a new qualifier for the given groups
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
quals
|
the qualifiers to enable for the selected mesh groups |
()
|
|
select
|
iterable
|
if specified, only the groups having all those qualifiers will be added the new qualifiers |
None
|
replace
|
bool
|
if True, the qualifiers in select will be removed |
False
|
Examples:
>>> pool = meshb.qualify('part-a') + meshb.qualify('part-b')
>>> set(meshb.faces) == set(pool.group('part-b').faces)
True
>>> chamfer(mesh, ...).qualify('my-group', select='chamfer', replace=True)
>>> mesh.group('my-group')
<Mesh ...>
Source code in madcad/mesh/container.py
136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 | |
qualified_indices(quals)
¶
Yield the faces indices when their associated group are matching the requirements
Source code in madcad/mesh/container.py
170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 | |
qualified_groups(quals)
¶
Yield the groups indices when they are matching the requirements
Source code in madcad/mesh/container.py
197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 | |
Extraction methods
maxnum()
¶
Maximum numeric value of the mesh, use this to get an hint on its size or to evaluate the numeric precision
Source code in madcad/mesh/container.py
216 217 218 219 220 221 222 223 | |
precision(propag=3)
¶
Numeric coordinate precision of operations on this mesh, allowed by the floating point precision
Source code in madcad/mesh/container.py
225 226 227 | |
length()
¶
total length of edges
Source code in madcad/mesh/web.py
375 376 377 378 379 380 | |
surface()
¶
return the surface enclosed by the web if planar and is composed of loops (else it has no meaning)
Source code in madcad/mesh/web.py
382 383 384 385 386 387 388 | |
barycenter()
¶
curve barycenter of the mesh
Source code in madcad/mesh/web.py
390 391 392 393 394 395 396 397 398 399 400 | |
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 | |
usepointat(point, neigh=NUMPREC)
¶
Return the index of the first point in the mesh at the location. If none is found, insert it and return the index
Source code in madcad/mesh/container.py
229 230 231 232 233 234 235 | |
edgepoints(e)
¶
tuple of the points for edge e
the edge can be given using its index in self.edges or using a tuple of point idinces
Source code in madcad/mesh/web.py
206 207 208 209 210 211 212 | |
edgedirection(e)
¶
direction of edge e
the edge can be given using its index in self.edges or using a tuple of point idinces
Source code in madcad/mesh/web.py
214 215 216 217 218 219 220 | |
extremities()
¶
return the points that are ending arcs 1D equivalent of Mesh.outlines()
Source code in madcad/mesh/web.py
266 267 268 269 270 | |
groupextremities()
¶
return the extremities of each group. 1D equivalent of Mesh.groupoutlines()
On a frontier between multiple groups, there is as many points as groups, each associated to a group.
Source code in madcad/mesh/web.py
295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 | |
frontiers(*args)
¶
return a Wire of points that split the given groups appart.
The arguments are groups indices or lists of group qualifiers (as set in `qualify()`). If there is one only argument it is considered as as list of arguments.
- if no argument is given, then return the frontiers between every groups
- to include the groups extremities that are on the group border but not at the frontier with an other group, add `None` to the group set
Examples:
>>> w = Web([...], [uvec2(0,1), uvec2(1,2)], [0, 1], [...])
>>> w.frontiers(0,1).indices
[1]
>>> # equivalent to
>>> w.frontiers({0,1}).indices
[1]
>>> w.frontiers(0,None).indices
[0]
Source code in madcad/mesh/web.py
319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 | |
arcs()
¶
return the contiguous portions of this web
Source code in madcad/mesh/web.py
449 450 451 452 | |
islands()
¶
return the unconnected parts of the mesh as several meshes
Source code in madcad/mesh/web.py
435 436 437 438 439 440 441 442 443 444 445 446 447 | |
groupislands()
¶
return the same web but with a new group each island
Source code in madcad/mesh/web.py
427 428 429 430 431 432 433 | |
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/web.py
229 230 231 232 233 234 235 236 237 238 | |
flip()
¶
reverse direction of all edges
Source code in madcad/mesh/web.py
222 223 224 225 226 227 | |