blending -- Creation of surface between outlines¶
This module focuses on automated envelope generations, based on interface outlines.
The user has only to define the interface outlines or surfaces to join, and the algorithm makes the surface. No more pain to imagine some fancy geometries.
Formal definitions¶
- interface: a surface or an outline (a loop) with associated exterior normals.
- node: a group of interfaces meant to be attached together by a blended surface.
In order to generate envelopes, this module asks for cutting all the surfaces to join into 'nodes'. The algorithm decides how to join shortly all the outlines in a node. Once splited in nodes, you only need to generate node junctions for each, and concatenate the resulting meshes.
Details¶
The blended surfaces are created between interfaces, linked as the points of a convex polyedron of the interfaces directions to the node center.
Example¶
>>> x, y, z = vec3(1, 0, 0), vec3(0, 1, 0), vec3(0, 0, 1)
>>> # 1. A surface can be passed: the surface outlines and
>>> # normals will be used as the generated surface tangents
>>> # 2. Wire or primitives can be passed: the wire loops are used
>>> # and the approximate normal to the wire plane
>>> # 3. More parameters when building directly the interface
>>> m = junction(
... extrusion(2 * z, web(Circle((vec3(0), z), 1))), # 1.
... Circle((2 * x, x), 0.5), # 2.
... (Circle((2 * y, y), 0.5), "tangent", 2.0), # 3.
... generate="normal",
... )
To come in a next version
>>> # create junction for each iterable of interface,
>>> # if some are not interfaces, they are used
>>> # as placeholder objects for auto-determined interfaces
>>> multijunction(
... (surf1, surf2, 42, surf5),
... (42, surf3, surf4),
... generate='straight',
... )
General mesh generation¶
junction(*args, center=None, tangents='normal', weight=1.0, match='length', resolution=None)
¶
Join several outlines with a blended surface

tangents:
'straight' no interpolation, straight lines
'normal' interpolated surface starts normal to the interfaces
'tangent' interpolated surface starts tangent to the interfaces
weight:
factor applied on the tangents before passing to `interpol2` or `intri_smooth`
the resulting tangent is computed in point `a` as `weight * distance(a,b) * normalize(tangent[a])`
match:
'length' share the outline between 2 matched points to assign the same length to both sides
'corner' split the curve to share around a corner
center:
position of the center of the junction node used to determine connexion between interfaces
can be usefull for particularly weird and ambiguous interfaces
Note
match method 'corner' is not yet implemented
Source code in madcad/blending.py
152 153 154 155 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 184 185 186 187 188 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 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 | |
blendloop(interface, center=None, tangents='tangent', weight=1.0, resolution=None)
¶
Blend inside a loop interface

see `junction` for the parameters.
Source code in madcad/blending.py
387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 | |
blendpair(*interfaces, match='length', tangents='tangent', weight=1.0, resolution=None)
¶
Blend between a pair of interfaces

match:
`'length'`, `'closest'` refer to `match_*` in this module
see `junction` for the other parameters.
Source code in madcad/blending.py
415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 | |
blenditer(parameters, div, interpol)
¶
Create a blended surface using the matching parameters and the given interpolation parameters is an iterable of tuples of arguments for the interpolation function interpol receive the elements iterated and the interpolation position at the end
Source code in madcad/blending.py
465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 | |
Misc tools¶
match_length(line1, line2)
¶
Yield couples of point indices where the curved absciss are the closest
Source code in madcad/blending.py
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 | |
match_closest(line1, line2)
¶
Yield couples of points by cutting each line at the curvilign absciss of the points of the other
Source code in madcad/blending.py
350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 | |
Small utilities¶
join(mesh, line1, line2)
¶
Simple straight surface created from matching couples of line1 and line2 using mesh indices for lines
Source code in madcad/blending.py
538 539 540 541 542 543 544 545 546 547 548 549 550 551 | |
trijoin(pts, ptgts, div)
¶
Simple straight surface created between 3 points, interpolation is only on the sides
Source code in madcad/blending.py
553 554 555 556 557 558 559 560 561 562 563 564 565 566 | |