API Reference
base
BottomUpEdgeIterator
A mixin class that adds the ability to iterate over edges from lower-level entities (vertices).
Source code in src/occwl/base.py
365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 |
|
edge_continuity(edge)
Get the neighboring faces' continuity at given edge
Parameters:
Name | Type | Description | Default |
---|---|---|---|
edge
|
Edge
|
Edge |
required |
Returns:
Name | Type | Description |
---|---|---|
GeomAbs_Shape |
enum describing the continuity order |
Source code in src/occwl/base.py
370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 |
|
edges_from_vertex(vertex)
Get an iterator to go over the edges adjacent to a vertex
Parameters:
Name | Type | Description | Default |
---|---|---|---|
face
|
Face
|
Input face |
required |
Returns:
Type | Description |
---|---|
Iterator[occwl.edge.Edge]: Edge iterator |
Source code in src/occwl/base.py
386 387 388 389 390 391 392 393 394 395 396 397 398 399 |
|
BottomUpFaceIterator
A mixin class that adds the ability to iterate over faces from lower-level entities (vertices and edges).
Source code in src/occwl/base.py
312 313 314 315 316 317 318 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 |
|
edge_continuity(edge)
Get the neighboring faces' continuity at given edge
Parameters:
Name | Type | Description | Default |
---|---|---|---|
edge
|
Edge
|
Edge |
required |
Returns:
Name | Type | Description |
---|---|---|
GeomAbs_Shape |
enum describing the continuity order |
Source code in src/occwl/base.py
347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 |
|
faces_from_edge(edge)
Get an iterator to go over the faces adjacent to an edge
Parameters:
Name | Type | Description | Default |
---|---|---|---|
edge
|
Edge
|
Input edge |
required |
Returns:
Type | Description |
---|---|
Iterator[occwl.face.Face]: Face iterator |
Source code in src/occwl/base.py
317 318 319 320 321 322 323 324 325 326 327 328 329 330 |
|
faces_from_vertex(vertex)
Get an iterator to go over the faces adjacent to a vertex
Parameters:
Name | Type | Description | Default |
---|---|---|---|
edge
|
Vertex
|
Input vertex |
required |
Returns:
Type | Description |
---|---|
Iterator[occwl.face.Face]: Face iterator |
Source code in src/occwl/base.py
332 333 334 335 336 337 338 339 340 341 342 343 344 345 |
|
BoundingBoxMixin
A mixin class that adds the ability to compute approximate and exact bounding box of the Shape.
Source code in src/occwl/base.py
560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 |
|
box()
Get a quick bounding box of the Shape
Returns:
Name | Type | Description |
---|---|---|
Box |
Bounding box |
Source code in src/occwl/base.py
565 566 567 568 569 570 571 572 573 574 575 |
|
exact_box(use_shapetolerance=False)
Get a slow, but accurate box for the Shape.
Returns:
Name | Type | Description |
---|---|---|
Box |
Bounding box |
Source code in src/occwl/base.py
577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 |
|
scale_to_box(box_side, copy=True)
Translate and scale the Shape so it fits exactly into the [-box_side, box_side]^3 box
Returns:
Type | Description |
---|---|
occwl..: The scaled version of this Shape |
Source code in src/occwl/base.py
594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 |
|
scale_to_unit_box(copy=True)
Translate and scale the Shape so it fits exactly into the [-1, 1]^3 box
Returns: The scaled version of this shape
Source code in src/occwl/base.py
628 629 630 631 632 633 634 635 636 637 638 639 640 641 |
|
EdgeContainerMixin
A mixin class that adds the ability to perform operations on the edges in the shape
Source code in src/occwl/base.py
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 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 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 |
|
edges()
Get an iterator to go over all edges in the Shape
Returns:
Type | Description |
---|---|
Iterator[occwl.edge.Edge]: Edge iterator |
Source code in src/occwl/base.py
59 60 61 62 63 64 65 66 67 |
|
find_closest_edge_slow(datum)
Find the closest edge to the given datum point. The function is for testing only. It will be slow as it loops over all edges in the Shape. A quick way to find the closest entity is to call Shape.find_closest_point_data(), but then you may get a face, edge or vertex back.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
datum
|
ndarray or tuple
|
3D datum point |
required |
Returns:
Name | Type | Description |
---|---|---|
Face |
The closest face in the Shape |
Source code in src/occwl/base.py
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 |
|
num_edges()
Number of edges in the Shape
Returns:
Name | Type | Description |
---|---|---|
int |
Number of edges |
Source code in src/occwl/base.py
50 51 52 53 54 55 56 57 |
|
split_all_closed_edges(max_tol=0.01, precision=0.01, num_splits=1)
Split all the closed edges in this shape
Parameters:
Name | Type | Description | Default |
---|---|---|---|
max_tol
|
float
|
Maximum tolerance allowed. Defaults to 0.01. |
0.01
|
precision
|
float
|
Precision of the tool when splitting. Defaults to 0.01. |
0.01
|
num_splits
|
int
|
Number of splits to perform. Each split edge will result in num_splits + 1 edges. Defaults to 1. |
1
|
Returns:
Type | Description |
---|---|
occwl..: Shape with closed edges split |
Source code in src/occwl/base.py
101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 |
|
vertices_from_edge(edge)
Get an iterator to go over the vertices bounding an edge
Parameters:
Name | Type | Description | Default |
---|---|---|---|
edge
|
Edge
|
Input edge |
required |
Returns:
Type | Description |
---|---|
Iterator[occwl.vertex.Vertex]: Vertex iterator |
Source code in src/occwl/base.py
69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
|
FaceContainerMixin
A mixin class that adds the ability to perform operations on the faces in the shape
Source code in src/occwl/base.py
151 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 |
|
edges_from_face(face)
Get an iterator to go over the edges in a face
Parameters:
Name | Type | Description | Default |
---|---|---|---|
face
|
Face
|
Input face |
required |
Returns:
Type | Description |
---|---|
Iterator[occwl.edge.Edge]: Edge iterator |
Source code in src/occwl/base.py
190 191 192 193 194 195 196 197 198 199 200 201 202 203 |
|
faces()
Get an iterator to go over all faces in the Shape
Returns:
Type | Description |
---|---|
Iterator[occwl.face.Face]: Face iterator |
Source code in src/occwl/base.py
165 166 167 168 169 170 171 172 173 |
|
find_closest_face_slow(datum)
Find the closest face to the given datum point. The function is for testing only. It will be slow as it loops over all faces in the Shape. A quick way to find the closest entity is to call Shape.find_closest_point_data(), but then you may get a face, edge or vertex back.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
datum
|
ndarray or tuple
|
3D datum point |
required |
Returns:
Name | Type | Description |
---|---|---|
Face |
The closest face in the Shape |
Source code in src/occwl/base.py
220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 |
|
num_faces()
Number of faces in the Shape
Returns:
Name | Type | Description |
---|---|---|
int |
Number of faces |
Source code in src/occwl/base.py
156 157 158 159 160 161 162 163 |
|
split_all_closed_faces(max_tol=0.01, precision=0.01, num_splits=1)
Split all the closed faces in this shape
Parameters:
Name | Type | Description | Default |
---|---|---|---|
max_tol
|
float
|
Maximum tolerance allowed. Defaults to 0.01. |
0.01
|
precision
|
float
|
Precision of the tool when splitting. Defaults to 0.01. |
0.01
|
num_splits
|
int
|
Number of splits to perform. Each split face will result in num_splits + 1 faces. Defaults to 1. |
1
|
Returns:
Type | Description |
---|---|
occwl..: Shape with closed faces split |
Source code in src/occwl/base.py
237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 |
|
vertices_from_face(face)
Get an iterator to go over the vertices in a face
Parameters:
Name | Type | Description | Default |
---|---|---|---|
face
|
Face
|
Input face |
required |
Returns:
Type | Description |
---|---|
Iterator[occwl.vertex.Vertex]: Vertex iterator |
Source code in src/occwl/base.py
175 176 177 178 179 180 181 182 183 184 185 186 187 188 |
|
wires_from_face(face)
Get an iterator to go over the wires bounding a face
Parameters:
Name | Type | Description | Default |
---|---|---|---|
face
|
Face
|
Input face |
required |
Returns:
Type | Description |
---|---|
Iterator[occwl.wire.Wire]: Wire iterator |
Source code in src/occwl/base.py
205 206 207 208 209 210 211 212 213 214 215 216 217 218 |
|
ShellContainerMixin
A mixin class that adds the ability to perform operations on the shells in the shape
Source code in src/occwl/base.py
262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 |
|
num_shells()
Number of shells in the Shape
Returns:
Name | Type | Description |
---|---|---|
int |
Number of shells |
Source code in src/occwl/base.py
267 268 269 270 271 272 273 274 |
|
shells()
Get an iterator to go over all shells in the Shape
Returns:
Type | Description |
---|---|
Iterator[occwl.shell.Shell]: Shell iterator |
Source code in src/occwl/base.py
276 277 278 279 280 281 282 283 284 |
|
SolidContainerMixin
A mixin class that adds the ability to perform operations on the solids in the shape
Source code in src/occwl/base.py
287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 |
|
num_solids()
Number of solids in the Compound
Returns:
Name | Type | Description |
---|---|---|
int |
Number of solids |
Source code in src/occwl/base.py
292 293 294 295 296 297 298 299 |
|
solids()
Get an iterator to go over all solids in the Compound
Returns:
Type | Description |
---|---|
Iterator[occwl.solid.Solid]: Solid iterator |
Source code in src/occwl/base.py
301 302 303 304 305 306 307 308 309 |
|
SurfacePropertiesMixin
A mixin class that adds the ability to query surface properties (e.g. area).
Source code in src/occwl/base.py
489 490 491 492 493 494 495 496 497 498 499 500 501 502 |
|
area()
Compute the area of the Shape
Returns:
Name | Type | Description |
---|---|---|
float |
Area |
Source code in src/occwl/base.py
493 494 495 496 497 498 499 500 501 502 |
|
TriangulatorMixin
A mixin class that adds the ability to triangulate the faces that are present in the shape.
Source code in src/occwl/base.py
402 403 404 405 406 407 408 409 410 411 412 413 414 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 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 |
|
get_triangles(triangle_face_tol=0.01, tol_relative_to_face=True, angle_tol_rads=0.1)
Compute and get the tessellation of the entire shape
Parameters:
Name | Type | Description | Default |
---|---|---|---|
triangle_face_tol
|
float
|
Toelrance between triangle and surface. Defaults to 0.01. |
0.01
|
tol_relative_to_face
|
bool
|
Whether tolerance is relative to face size |
True
|
angle_tol_rads
|
float
|
Angle tolerance in radians. Defaults to 0.1. |
0.1
|
Returns:
Type | Description |
---|---|
2D np.ndarray (float): Vertices or None if triangulation failed |
|
2D np.ndarray (int): Faces or None if triangulation failed |
Source code in src/occwl/base.py
451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 |
|
triangulate(triangle_face_tol=0.01, tol_relative_to_face=True, angle_tol_rads=0.1)
Triangulate all the faces in the shape. You can then get the triangles from each face separately using face.get_triangles(). If you wanted triangles for the entire shape then call shape.get_triangles() below. For more details see https://old.opencascade.com/doc/occt-7.1.0/overview/html/occt_user_guides__modeling_algos.html#occt_modalg_11
Parameters:
Name | Type | Description | Default |
---|---|---|---|
triangle_face_tol
|
float
|
Tolerance between triangle and surface. Defaults to 0.01. |
0.01
|
tol_relative_to_face
|
bool
|
Whether tolerance is relative to face size |
True
|
angle_tol_rads
|
float
|
Angle tolerance in radians. Defaults to 0.1. |
0.1
|
Returns:
Name | Type | Description |
---|---|---|
bool |
Is successful |
Source code in src/occwl/base.py
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 |
|
VertexContainerMixin
A mixin class that adds the ability to perform operations on the vertices in the shape
Source code in src/occwl/base.py
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
|
num_vertices()
Number of vertices in the Shape
Returns:
Name | Type | Description |
---|---|---|
int |
Number of vertices |
Source code in src/occwl/base.py
25 26 27 28 29 30 31 32 |
|
vertices()
Get an iterator to go over all vertices in the Shape
Returns:
Type | Description |
---|---|
Iterator[occwl.vertex.Vertex]: Vertex iterator |
Source code in src/occwl/base.py
34 35 36 37 38 39 40 41 42 |
|
VolumePropertiesMixin
A mixin class that adds the ability to query volumetric properties (e.g. volume, center of mass, etc.).
Source code in src/occwl/base.py
505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 |
|
center_of_mass(tolerance=1e-09)
Compute the center of mass of the Shape
Parameters:
Name | Type | Description | Default |
---|---|---|---|
tolerance
|
float
|
Tolerance. Defaults to 1e-9. |
1e-09
|
Returns:
Type | Description |
---|---|
np.ndarray: 3D point |
Source code in src/occwl/base.py
523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 |
|
moment_of_inertia(point, direction, tolerance=1e-09)
Compute the moment of inertia about an axis
Parameters:
Name | Type | Description | Default |
---|---|---|---|
point
|
ndarray
|
3D point (origin of the axis) |
required |
direction
|
ndarray
|
3D direction of the axis |
required |
tolerance
|
float
|
Tolerance. Defaults to 1e-9. |
1e-09
|
Returns:
Name | Type | Description |
---|---|---|
float |
Moment of inertia |
Source code in src/occwl/base.py
539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 |
|
volume(tolerance=1e-09)
Compute the volume of the Shape
Parameters:
Name | Type | Description | Default |
---|---|---|---|
tolerance
|
float
|
Tolerance. Defaults to 1e-9. |
1e-09
|
Returns:
Name | Type | Description |
---|---|---|
float |
Volume |
Source code in src/occwl/base.py
509 510 511 512 513 514 515 516 517 518 519 520 521 |
|
WireContainerMixin
A mixin class that adds the ability to perform operations on the wires in the shape
Source code in src/occwl/base.py
126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 |
|
num_wires()
Number of wires in the Shape
Returns:
Name | Type | Description |
---|---|---|
int |
Number of wires |
Source code in src/occwl/base.py
131 132 133 134 135 136 137 138 |
|
wires()
Get an iterator to go over all wires in the Shape
Returns:
Type | Description |
---|---|
Iterator[occwl.wire.Wire]: Wire iterator |
Source code in src/occwl/base.py
140 141 142 143 144 145 146 147 148 |
|
compound
Compound
Bases: Shape
, BottomUpFaceIterator
, BoundingBoxMixin
, BottomUpEdgeIterator
, EdgeContainerMixin
, FaceContainerMixin
, SolidContainerMixin
, ShellContainerMixin
, SurfacePropertiesMixin
, TriangulatorMixin
, VertexContainerMixin
, VolumePropertiesMixin
, WireContainerMixin
A compound which can be worked with as many shapes lumped together.
Source code in src/occwl/compound.py
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 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 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 |
|
__eq__(other)
Equality check for the shape
NOTE: This function only checks if the shape is the same. It doesn't check the edge orienation for example, so
edge1 == edge2
does not necessarily mean
edge1.reversed() == edge2.reversed()
Source code in src/occwl/shape.py
144 145 146 147 148 149 150 151 152 153 154 155 156 157 |
|
__hash__()
Hash for the shape
Returns:
Name | Type | Description |
---|---|---|
int |
Hash value |
Source code in src/occwl/shape.py
135 136 137 138 139 140 141 142 |
|
area()
Compute the area of the Shape
Returns:
Name | Type | Description |
---|---|---|
float |
Area |
Source code in src/occwl/base.py
493 494 495 496 497 498 499 500 501 502 |
|
box()
Get a quick bounding box of the Shape
Returns:
Name | Type | Description |
---|---|---|
Box |
Bounding box |
Source code in src/occwl/base.py
565 566 567 568 569 570 571 572 573 574 575 |
|
center_of_mass(tolerance=1e-09)
Compute the center of mass of the Shape
Parameters:
Name | Type | Description | Default |
---|---|---|---|
tolerance
|
float
|
Tolerance. Defaults to 1e-9. |
1e-09
|
Returns:
Type | Description |
---|---|
np.ndarray: 3D point |
Source code in src/occwl/base.py
523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 |
|
convert_geometric_identity_transforms_to_identity()
Open Cascade models sometimes contain transforms which are "geometrically" identify transforms, but the identity flag is not set.
This function checks each transform and sets the flag if the appropriate.
Source code in src/occwl/shape.py
371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 |
|
edge_continuity(edge)
Get the neighboring faces' continuity at given edge
Parameters:
Name | Type | Description | Default |
---|---|---|---|
edge
|
Edge
|
Edge |
required |
Returns:
Name | Type | Description |
---|---|---|
GeomAbs_Shape |
enum describing the continuity order |
Source code in src/occwl/base.py
347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 |
|
edges()
Get an iterator to go over all edges in the Shape
Returns:
Type | Description |
---|---|
Iterator[occwl.edge.Edge]: Edge iterator |
Source code in src/occwl/base.py
59 60 61 62 63 64 65 66 67 |
|
edges_from_face(face)
Get an iterator to go over the edges in a face
Parameters:
Name | Type | Description | Default |
---|---|---|---|
face
|
Face
|
Input face |
required |
Returns:
Type | Description |
---|---|
Iterator[occwl.edge.Edge]: Edge iterator |
Source code in src/occwl/base.py
190 191 192 193 194 195 196 197 198 199 200 201 202 203 |
|
edges_from_vertex(vertex)
Get an iterator to go over the edges adjacent to a vertex
Parameters:
Name | Type | Description | Default |
---|---|---|---|
face
|
Face
|
Input face |
required |
Returns:
Type | Description |
---|---|
Iterator[occwl.edge.Edge]: Edge iterator |
Source code in src/occwl/base.py
386 387 388 389 390 391 392 393 394 395 396 397 398 399 |
|
exact_box(use_shapetolerance=False)
Get a slow, but accurate box for the Shape.
Returns:
Name | Type | Description |
---|---|---|
Box |
Bounding box |
Source code in src/occwl/base.py
577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 |
|
faces()
Get an iterator to go over all faces in the Shape
Returns:
Type | Description |
---|---|
Iterator[occwl.face.Face]: Face iterator |
Source code in src/occwl/base.py
165 166 167 168 169 170 171 172 173 |
|
faces_from_edge(edge)
Get an iterator to go over the faces adjacent to an edge
Parameters:
Name | Type | Description | Default |
---|---|---|---|
edge
|
Edge
|
Input edge |
required |
Returns:
Type | Description |
---|---|
Iterator[occwl.face.Face]: Face iterator |
Source code in src/occwl/base.py
317 318 319 320 321 322 323 324 325 326 327 328 329 330 |
|
faces_from_vertex(vertex)
Get an iterator to go over the faces adjacent to a vertex
Parameters:
Name | Type | Description | Default |
---|---|---|---|
edge
|
Vertex
|
Input vertex |
required |
Returns:
Type | Description |
---|---|
Iterator[occwl.face.Face]: Face iterator |
Source code in src/occwl/base.py
332 333 334 335 336 337 338 339 340 341 342 343 344 345 |
|
find_closest_edge_slow(datum)
Find the closest edge to the given datum point. The function is for testing only. It will be slow as it loops over all edges in the Shape. A quick way to find the closest entity is to call Shape.find_closest_point_data(), but then you may get a face, edge or vertex back.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
datum
|
ndarray or tuple
|
3D datum point |
required |
Returns:
Name | Type | Description |
---|---|---|
Face |
The closest face in the Shape |
Source code in src/occwl/base.py
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 |
|
find_closest_face_slow(datum)
Find the closest face to the given datum point. The function is for testing only. It will be slow as it loops over all faces in the Shape. A quick way to find the closest entity is to call Shape.find_closest_point_data(), but then you may get a face, edge or vertex back.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
datum
|
ndarray or tuple
|
3D datum point |
required |
Returns:
Name | Type | Description |
---|---|---|
Face |
The closest face in the Shape |
Source code in src/occwl/base.py
220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 |
|
find_closest_point_data(datum)
Find the information about the closest point on this shape
Parameters:
Name | Type | Description | Default |
---|---|---|---|
datum
|
ndarray
|
3D Point |
required |
Returns:
Name | Type | Description |
---|---|---|
ClosestPointData |
Data about the closest point on this shape |
|
None |
if error |
Source code in src/occwl/shape.py
251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 |
|
get_triangles(triangle_face_tol=0.01, tol_relative_to_face=True, angle_tol_rads=0.1)
Compute and get the tessellation of the entire shape
Parameters:
Name | Type | Description | Default |
---|---|---|---|
triangle_face_tol
|
float
|
Toelrance between triangle and surface. Defaults to 0.01. |
0.01
|
tol_relative_to_face
|
bool
|
Whether tolerance is relative to face size |
True
|
angle_tol_rads
|
float
|
Angle tolerance in radians. Defaults to 0.1. |
0.1
|
Returns:
Type | Description |
---|---|
2D np.ndarray (float): Vertices or None if triangulation failed |
|
2D np.ndarray (int): Faces or None if triangulation failed |
Source code in src/occwl/base.py
451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 |
|
load_from_occ_native(filename, verbosity=False)
staticmethod
Load everything from the OCC native .brep file format into a single occwl.compound.Compound.
Saving to and loading from the native file format
is between one and two orders of magnitude faster than loading from STEP, so it is recommended for large scale data processing
Parameters:
Name | Type | Description | Default |
---|---|---|---|
filename
|
str or Path
|
.brep filename |
required |
verbosity
|
bool
|
Whether to print detailed information while loading |
False
|
Returns:
Type | Description |
---|---|
occwl.compound.Compound: Compound shape |
Source code in src/occwl/compound.py
101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 |
|
load_from_step(filename, verbosity=False)
staticmethod
Load everything from a STEP file as a single Compound
Parameters:
Name | Type | Description | Default |
---|---|---|---|
filename
|
str or Path
|
STEP filename |
required |
verbosity
|
bool
|
Whether to print detailed information while loading |
False
|
Returns:
Type | Description |
---|---|
occwl.compound.Compound: Compound shape |
Source code in src/occwl/compound.py
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
|
load_step_with_attributes(step_filename)
staticmethod
Load shapes from a step file with the name information. Other attributes could be retro-fitted
Parameters:
Name | Type | Description | Default |
---|---|---|---|
step_filename
|
str
|
Path to STEP file |
required |
Returns:
Type | Description |
---|---|
occwl.Compound, dict occwl.Shape to attributes |
Source code in src/occwl/compound.py
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 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 97 98 |
|
moment_of_inertia(point, direction, tolerance=1e-09)
Compute the moment of inertia about an axis
Parameters:
Name | Type | Description | Default |
---|---|---|---|
point
|
ndarray
|
3D point (origin of the axis) |
required |
direction
|
ndarray
|
3D direction of the axis |
required |
tolerance
|
float
|
Tolerance. Defaults to 1e-9. |
1e-09
|
Returns:
Name | Type | Description |
---|---|---|
float |
Moment of inertia |
Source code in src/occwl/base.py
539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 |
|
num_edges()
Number of edges in the Shape
Returns:
Name | Type | Description |
---|---|---|
int |
Number of edges |
Source code in src/occwl/base.py
50 51 52 53 54 55 56 57 |
|
num_faces()
Number of faces in the Shape
Returns:
Name | Type | Description |
---|---|---|
int |
Number of faces |
Source code in src/occwl/base.py
156 157 158 159 160 161 162 163 |
|
num_shells()
Number of shells in the Shape
Returns:
Name | Type | Description |
---|---|---|
int |
Number of shells |
Source code in src/occwl/base.py
267 268 269 270 271 272 273 274 |
|
num_solids()
Number of solids in the Compound
Returns:
Name | Type | Description |
---|---|---|
int |
Number of solids |
Source code in src/occwl/base.py
292 293 294 295 296 297 298 299 |
|
num_vertices()
Number of vertices in the Shape
Returns:
Name | Type | Description |
---|---|---|
int |
Number of vertices |
Source code in src/occwl/base.py
25 26 27 28 29 30 31 32 |
|
num_wires()
Number of wires in the Shape
Returns:
Name | Type | Description |
---|---|---|
int |
Number of wires |
Source code in src/occwl/base.py
131 132 133 134 135 136 137 138 |
|
occwl_shape(topods_shape)
staticmethod
Static method to create an occwl shape of the appropriate class from the given topods_shape Args: topods_shape (OCC.Core.TopoDS.TopoDS_Vertex/Edge/Face/Wire/Shell/Solid): TopoDS shape
Returns:
Type | Description |
---|---|
One of occwl.compound.Compound occwl.solid.Solid occwl.face.Face occwl.edge.Edge occwl.vertex.Vertex occwl.wire.Wire occwl.shell.Shell |
Raises: Exception: [description]
Source code in src/occwl/shape.py
89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 |
|
reversed()
Whether this shape is reversed.
- For an edge this is whether the edge is reversed with respect to the curve geometry
- For a face this is whether the face is reversed with respect to the surface geometry
- For a vertex this is whether the vertex is at the upper or lower parameter value on the edges curve
Returns:
Name | Type | Description |
---|---|---|
bool |
If rational |
Source code in src/occwl/shape.py
236 237 238 239 240 241 242 243 244 245 246 247 248 |
|
rotate_axis_angle(axis, angle_radians, origin=np.zeros(3, dtype=(np.float32)))
Rotate the shape about the given axis by the given angle in radians
Parameters:
Name | Type | Description | Default |
---|---|---|---|
axis
|
ndarray
|
Rotation axis |
required |
angle_radians
|
float
|
Angle in radians |
required |
Source code in src/occwl/shape.py
285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 |
|
rotate_euler_angles(angles_xyz_radians)
Rotate the shape by the given Euler angles in radians
Parameters:
Name | Type | Description | Default |
---|---|---|---|
angle_xyz_radians
|
ndarray
|
3D array with angles to rotate about x-axis, y-axis and z-axis respectively in radians |
required |
Source code in src/occwl/shape.py
302 303 304 305 306 307 308 309 310 311 312 313 314 315 |
|
save_shapes_to_occ_native(filename, shapes, with_triangles=False, with_normals=False, format_version=None)
staticmethod
Save this shape into a native OCC binary .brep file.
Saving to and loading from the native file format
is between one and two orders of magnitude faster than loading from STEP, so it is recommended for large scale data processing
Parameters:
Name | Type | Description | Default |
---|---|---|---|
filename
|
str or Path
|
.brep filename |
required |
with_triangles
|
bool
|
Whether to save triangle data cached in the shape. |
False
|
with_normals
|
bool
|
Whether to save vertex normals cached in the shape |
False
|
format_version
|
int
|
Use None to save to the latest version 1 - first revision 2 - added storing of CurveOnSurface UV Points 3 - [OCCT 7.6] added storing of per-vertex normal information and dropped storing of CurveOnSurface UV Points |
None
|
Source code in src/occwl/shape.py
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 |
|
save_to_occ_native(filename, verbosity=False, with_triangles=False, with_normals=False, format_version=None)
Save this shape into a native OCC binary .brep file.
Saving to and loading from the native file format
is between one and two orders of magnitude faster than loading from STEP, so it is recommended for large scale data processing
Parameters:
Name | Type | Description | Default |
---|---|---|---|
filename
|
str or Path
|
.brep filename |
required |
with_triangles
|
bool
|
Whether to save triangle data cached in the shape. |
False
|
with_normals
|
bool
|
Whether to save vertex normals cached in the shape |
False
|
format_version
|
int
|
Use None to save to the latest version 1 - first revision 2 - added storing of CurveOnSurface UV Points 3 - [OCCT 7.6] added storing of per-vertex normal information and dropped storing of CurveOnSurface UV Points |
None
|
Source code in src/occwl/shape.py
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 |
|
scale(scale_vector)
Scale the shape by the given 3D vector
Parameters:
Name | Type | Description | Default |
---|---|---|---|
scale_vector
|
ndarray
|
3D array with scales to resize the shape along the x-axis, y-axis and z-axis respectively |
required |
Source code in src/occwl/shape.py
317 318 319 320 321 322 323 324 325 326 |
|
scale_to_box(box_side, copy=True)
Translate and scale the Shape so it fits exactly into the [-box_side, box_side]^3 box
Returns:
Type | Description |
---|---|
occwl..: The scaled version of this Shape |
Source code in src/occwl/base.py
594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 |
|
scale_to_unit_box(copy=True)
Translate and scale the Shape so it fits exactly into the [-1, 1]^3 box
Returns: The scaled version of this shape
Source code in src/occwl/base.py
628 629 630 631 632 633 634 635 636 637 638 639 640 641 |
|
set_transform_to_identity()
When an assembly is loaded from a STEP file the solids will be transformed relative to their local coordinate system. i.e. they are placed in the assembly root components coordinate system.
When working with individual bodies you often want them to be axis aligned, in which case you want to remove the assembly transform. This function removes it for you.
If however you want to bake the transform into the bodies and suppress the asserts from parts of occwl which don't cope with transforms then use the transform() function below with copy=True
Source code in src/occwl/shape.py
346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 |
|
shells()
Get an iterator to go over all shells in the Shape
Returns:
Type | Description |
---|---|
Iterator[occwl.shell.Shell]: Shell iterator |
Source code in src/occwl/base.py
276 277 278 279 280 281 282 283 284 |
|
solids()
Get an iterator to go over all solids in the Compound
Returns:
Type | Description |
---|---|
Iterator[occwl.solid.Solid]: Solid iterator |
Source code in src/occwl/base.py
301 302 303 304 305 306 307 308 309 |
|
split_all_closed_edges(max_tol=0.01, precision=0.01, num_splits=1)
Split all the closed edges in this shape
Parameters:
Name | Type | Description | Default |
---|---|---|---|
max_tol
|
float
|
Maximum tolerance allowed. Defaults to 0.01. |
0.01
|
precision
|
float
|
Precision of the tool when splitting. Defaults to 0.01. |
0.01
|
num_splits
|
int
|
Number of splits to perform. Each split edge will result in num_splits + 1 edges. Defaults to 1. |
1
|
Returns:
Type | Description |
---|---|
occwl..: Shape with closed edges split |
Source code in src/occwl/base.py
101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 |
|
split_all_closed_faces(max_tol=0.01, precision=0.01, num_splits=1)
Split all the closed faces in this shape
Parameters:
Name | Type | Description | Default |
---|---|---|---|
max_tol
|
float
|
Maximum tolerance allowed. Defaults to 0.01. |
0.01
|
precision
|
float
|
Precision of the tool when splitting. Defaults to 0.01. |
0.01
|
num_splits
|
int
|
Number of splits to perform. Each split face will result in num_splits + 1 faces. Defaults to 1. |
1
|
Returns:
Type | Description |
---|---|
occwl..: Shape with closed faces split |
Source code in src/occwl/base.py
237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 |
|
topods_shape()
Get the underlying OCC shape
Returns:
Type | Description |
---|---|
OCC.Core.TopoDS.TopoDS_Vertex/Edge/Face/Wire/Shell/Solid: OCC TopoDS_* |
Source code in src/occwl/shape.py
80 81 82 83 84 85 86 87 |
|
transform(a, copy=True)
Apply the given 3x4 transform matrix to the solid.
copy (bool) True - Copy entities and apply the transform to
the underlying geometry
False - Apply the transform to the topods Locator
if possible
Source code in src/occwl/shape.py
400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 |
|
translate(offset)
Translate the shape by an offset vector
Parameters:
Name | Type | Description | Default |
---|---|---|---|
offset
|
ndarray
|
Offset vector |
required |
Source code in src/occwl/shape.py
276 277 278 279 280 281 282 283 |
|
triangulate(triangle_face_tol=0.01, tol_relative_to_face=True, angle_tol_rads=0.1)
Triangulate all the faces in the shape. You can then get the triangles from each face separately using face.get_triangles(). If you wanted triangles for the entire shape then call shape.get_triangles() below. For more details see https://old.opencascade.com/doc/occt-7.1.0/overview/html/occt_user_guides__modeling_algos.html#occt_modalg_11
Parameters:
Name | Type | Description | Default |
---|---|---|---|
triangle_face_tol
|
float
|
Tolerance between triangle and surface. Defaults to 0.01. |
0.01
|
tol_relative_to_face
|
bool
|
Whether tolerance is relative to face size |
True
|
angle_tol_rads
|
float
|
Angle tolerance in radians. Defaults to 0.1. |
0.1
|
Returns:
Name | Type | Description |
---|---|---|
bool |
Is successful |
Source code in src/occwl/base.py
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 |
|
valid(return_analyzer=False)
Check if the shape is valid
Parameters:
Name | Type | Description | Default |
---|---|---|---|
return_analyzer
|
bool
|
Whether to return the BRepCheck_Analyzer object for more inspection |
False
|
Returns:
Name | Type | Description |
---|---|---|
bool |
Whether the shape is valid |
|
BRepCheck_Analyzer [optional]: if return_analyzer is True |
Source code in src/occwl/shape.py
328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 |
|
vertices()
Get an iterator to go over all vertices in the Shape
Returns:
Type | Description |
---|---|
Iterator[occwl.vertex.Vertex]: Vertex iterator |
Source code in src/occwl/base.py
34 35 36 37 38 39 40 41 42 |
|
vertices_from_edge(edge)
Get an iterator to go over the vertices bounding an edge
Parameters:
Name | Type | Description | Default |
---|---|---|---|
edge
|
Edge
|
Input edge |
required |
Returns:
Type | Description |
---|---|
Iterator[occwl.vertex.Vertex]: Vertex iterator |
Source code in src/occwl/base.py
69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
|
vertices_from_face(face)
Get an iterator to go over the vertices in a face
Parameters:
Name | Type | Description | Default |
---|---|---|---|
face
|
Face
|
Input face |
required |
Returns:
Type | Description |
---|---|
Iterator[occwl.vertex.Vertex]: Vertex iterator |
Source code in src/occwl/base.py
175 176 177 178 179 180 181 182 183 184 185 186 187 188 |
|
volume(tolerance=1e-09)
Compute the volume of the Shape
Parameters:
Name | Type | Description | Default |
---|---|---|---|
tolerance
|
float
|
Tolerance. Defaults to 1e-9. |
1e-09
|
Returns:
Name | Type | Description |
---|---|---|
float |
Volume |
Source code in src/occwl/base.py
509 510 511 512 513 514 515 516 517 518 519 520 521 |
|
wires()
Get an iterator to go over all wires in the Shape
Returns:
Type | Description |
---|---|
Iterator[occwl.wire.Wire]: Wire iterator |
Source code in src/occwl/base.py
140 141 142 143 144 145 146 147 148 |
|
wires_from_face(face)
Get an iterator to go over the wires bounding a face
Parameters:
Name | Type | Description | Default |
---|---|---|---|
face
|
Face
|
Input face |
required |
Returns:
Type | Description |
---|---|
Iterator[occwl.wire.Wire]: Wire iterator |
Source code in src/occwl/base.py
205 206 207 208 209 210 211 212 213 214 215 216 217 218 |
|
edge
Edge
Bases: Shape
, VertexContainerMixin
, BoundingBoxMixin
A topological edge in a solid model Represents a 3D curve bounded by vertices
Source code in src/occwl/edge.py
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 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 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 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 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 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 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 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 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 413 414 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 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 |
|
__eq__(other)
Equality check for the shape
NOTE: This function only checks if the shape is the same. It doesn't check the edge orienation for example, so
edge1 == edge2
does not necessarily mean
edge1.reversed() == edge2.reversed()
Source code in src/occwl/shape.py
144 145 146 147 148 149 150 151 152 153 154 155 156 157 |
|
__hash__()
Hash for the shape
Returns:
Name | Type | Description |
---|---|---|
int |
Hash value |
Source code in src/occwl/shape.py
135 136 137 138 139 140 141 142 |
|
box()
Get a quick bounding box of the Shape
Returns:
Name | Type | Description |
---|---|---|
Box |
Bounding box |
Source code in src/occwl/base.py
565 566 567 568 569 570 571 572 573 574 575 |
|
closed_curve()
Returns whether the 3D curve of this edge is closed. i.e. the start and edge points are coincident.
Returns:
Name | Type | Description |
---|---|---|
bool |
If closed |
Source code in src/occwl/edge.py
293 294 295 296 297 298 299 300 301 |
|
closed_edge()
Returns whether the edge forms a closed ring. i.e. whether the start and end vertices are the same.
Returns:
Name | Type | Description |
---|---|---|
bool |
If closed |
Source code in src/occwl/edge.py
303 304 305 306 307 308 309 310 311 |
|
continuity(face1, face2)
Get the order of continuity among a pair of faces
Parameters:
Name | Type | Description | Default |
---|---|---|---|
face1
|
Face
|
First face |
required |
face2
|
Face
|
Second face |
required |
Returns:
Name | Type | Description |
---|---|---|
GeomAbs_Shape |
enum describing the continuity order |
Source code in src/occwl/edge.py
355 356 357 358 359 360 361 362 363 364 365 366 367 368 |
|
convert_geometric_identity_transforms_to_identity()
Open Cascade models sometimes contain transforms which are "geometrically" identify transforms, but the identity flag is not set.
This function checks each transform and sets the flag if the appropriate.
Source code in src/occwl/shape.py
371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 |
|
curve()
Get the edge curve geometry
Returns:
Type | Description |
---|---|
OCC.Geom.Handle_Geom_Curve: Interface to all curve geometry |
Source code in src/occwl/edge.py
223 224 225 226 227 228 229 230 |
|
curve_type()
Get the type of the curve geometry
Returns:
Name | Type | Description |
---|---|---|
str |
Type of the curve geometry |
Source code in src/occwl/edge.py
371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 |
|
curve_type_enum()
Get the type of the curve geometry as an OCC.Core.GeomAbs enum
Returns:
Type | Description |
---|---|
OCC.Core.GeomAbs: Type of the curve geometry |
Source code in src/occwl/edge.py
399 400 401 402 403 404 405 406 |
|
end_vertex()
Returns the ending vertex of the edge while considering the edge orientation
Returns:
Type | Description |
---|---|
occwl.vertex.Vertex: End vertex |
Source code in src/occwl/edge.py
159 160 161 162 163 164 165 166 |
|
exact_box(use_shapetolerance=False)
Get a slow, but accurate box for the Shape.
Returns:
Name | Type | Description |
---|---|---|
Box |
Bounding box |
Source code in src/occwl/base.py
577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 |
|
find_closest_point_data(datum)
Find the information about the closest point on this shape
Parameters:
Name | Type | Description | Default |
---|---|---|---|
datum
|
ndarray
|
3D Point |
required |
Returns:
Name | Type | Description |
---|---|---|
ClosestPointData |
Data about the closest point on this shape |
|
None |
if error |
Source code in src/occwl/shape.py
251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 |
|
find_left_and_right_faces(faces)
Given a list of 1 or 2 faces which are adjacent to this edge, we want to return the left and right face when looking from outside the solid.
Edge direction
^
|
Left | Right
face | face
|
In the case of a cylinder the left and right face will be the same.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
faces
|
list(occwl.face.Face
|
The faces |
required |
Returns:
Type | Description |
---|---|
occwl.face.Face, occwl.face.Face: The left and then right face |
|
or |
|
None, None if the left and right faces cannot be found |
Source code in src/occwl/edge.py
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 |
|
first_derivative(u)
Compute the first derivative of the edge geometry at given parameter
Parameters:
Name | Type | Description | Default |
---|---|---|---|
u
|
float
|
Curve parameter |
required |
Returns:
Type | Description |
---|---|
np.ndarray: 3D vector |
Source code in src/occwl/edge.py
191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 |
|
get_polyline(deflection=0.0005, algorithm='QuasiUniformDeflection')
Get a polyline, represented as a sequence of points, from this edge
Parameters:
Name | Type | Description | Default |
---|---|---|---|
deflection
|
float
|
Lower deflection results in more precision and therefore more points |
0.0005
|
algorithm
|
string
|
Algorithm to use, can be one of: QuasiUniformDeflection, UniformAbscissa, or UniformDeflection |
'QuasiUniformDeflection'
|
Returns:
Type | Description |
---|---|
2D np.ndarray: Points |
Source code in src/occwl/edge.py
465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 |
|
has_curve()
Does this edge have a valid curve? Some edges don't. For example the edge at the pole of a sphere.
Returns:
Name | Type | Description |
---|---|---|
bool |
Whether this edge has a valid curve |
Source code in src/occwl/edge.py
260 261 262 263 264 265 266 267 268 269 |
|
has_pcurve(face)
Whether this edge has a pcurve associated to the given face
Parameters:
Name | Type | Description | Default |
---|---|---|---|
face
|
Face
|
Face |
required |
Returns:
Name | Type | Description |
---|---|---|
bool |
If pcurve exists |
Source code in src/occwl/edge.py
325 326 327 328 329 330 331 332 333 334 335 |
|
length()
Compute the length of the edge curve
Returns:
Name | Type | Description |
---|---|---|
float |
Length of the edge curve |
Source code in src/occwl/edge.py
210 211 212 213 214 215 216 217 218 219 220 221 |
|
make_arc_of_circle(pt1, pt2, pt3)
staticmethod
Make an arc edge
Parameters:
Name | Type | Description | Default |
---|---|---|---|
pt1
|
np.ndarray or list or tuple with 3D point
|
Start point |
required |
pt2
|
np.ndarray or list or tuple with 3D point
|
Mid (not necessarily at the middle) point |
required |
pt3
|
np.ndarray or list or tuple with 3D point
|
End point |
required |
Returns:
Type | Description |
---|---|
occwl.edge.Edge: Edge |
|
or None: if error |
Source code in src/occwl/edge.py
111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 |
|
make_circle(center, radius, direction=(0, 0, 1))
staticmethod
Make a circular edge
Parameters:
Name | Type | Description | Default |
---|---|---|---|
center
|
np.ndarray or list or tuple with 3D point
|
Center of the circle |
required |
radius
|
float
|
Radius of the circle |
required |
direction
|
np.ndarray or list or tuple with 3D unit vector
|
Normal of the circle's face. Defaults to (0, 0, 1). |
(0, 0, 1)
|
Returns:
Type | Description |
---|---|
occwl.edge.Edge: Edge |
|
or None: if error |
Source code in src/occwl/edge.py
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 |
|
make_line_from_points(start_point, end_point)
staticmethod
Make an edge from two given points
Parameters:
Name | Type | Description | Default |
---|---|---|---|
start_point
|
np.ndarray 3D vector
|
Starting point |
required |
end_point
|
np.ndarray 3D vector
|
Ending point |
required |
Returns:
Type | Description |
---|---|
occwl.Edge: Edge joining the two given vertices |
|
or None: if error |
Source code in src/occwl/edge.py
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
|
make_line_from_vertices(start_vertex, end_vertex)
staticmethod
Make an edge from two given vertices
Parameters:
Name | Type | Description | Default |
---|---|---|---|
start_vertex
|
Vertex
|
Starting vertex |
required |
end_vertex
|
Vertex
|
Ending vertex |
required |
Returns:
Type | Description |
---|---|
occwl.Edge: Edge joining the two given vertices |
|
or None: if error |
Source code in src/occwl/edge.py
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
|
num_vertices()
Number of vertices in the Shape
Returns:
Name | Type | Description |
---|---|---|
int |
Number of vertices |
Source code in src/occwl/base.py
25 26 27 28 29 30 31 32 |
|
occwl_shape(topods_shape)
staticmethod
Static method to create an occwl shape of the appropriate class from the given topods_shape Args: topods_shape (OCC.Core.TopoDS.TopoDS_Vertex/Edge/Face/Wire/Shell/Solid): TopoDS shape
Returns:
Type | Description |
---|---|
One of occwl.compound.Compound occwl.solid.Solid occwl.face.Face occwl.edge.Edge occwl.vertex.Vertex occwl.wire.Wire occwl.shell.Shell |
Raises: Exception: [description]
Source code in src/occwl/shape.py
89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 |
|
periodic()
Whether this edge is periodic
Returns:
Name | Type | Description |
---|---|---|
bool |
If periodic |
Source code in src/occwl/edge.py
337 338 339 340 341 342 343 344 |
|
point(u)
Evaluate the edge geometry at given parameter
Parameters:
Name | Type | Description | Default |
---|---|---|---|
u
|
float
|
Curve parameter |
required |
Returns:
Type | Description |
---|---|
np.ndarray: 3D Point |
Source code in src/occwl/edge.py
131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 |
|
rational()
Whether this edge geometry is rational
Returns:
Name | Type | Description |
---|---|---|
bool |
If rational |
Source code in src/occwl/edge.py
346 347 348 349 350 351 352 353 |
|
reversed()
Whether this shape is reversed.
- For an edge this is whether the edge is reversed with respect to the curve geometry
- For a face this is whether the face is reversed with respect to the surface geometry
- For a vertex this is whether the vertex is at the upper or lower parameter value on the edges curve
Returns:
Name | Type | Description |
---|---|---|
bool |
If rational |
Source code in src/occwl/shape.py
236 237 238 239 240 241 242 243 244 245 246 247 248 |
|
reversed_edge()
Return a copy of this edge with the orientation reversed.
Returns:
Type | Description |
---|---|
occwl.edge.Edge: An edge with the opposite orientation to this edge. |
Source code in src/occwl/edge.py
284 285 286 287 288 289 290 291 |
|
rotate_axis_angle(axis, angle_radians, origin=np.zeros(3, dtype=(np.float32)))
Rotate the shape about the given axis by the given angle in radians
Parameters:
Name | Type | Description | Default |
---|---|---|---|
axis
|
ndarray
|
Rotation axis |
required |
angle_radians
|
float
|
Angle in radians |
required |
Source code in src/occwl/shape.py
285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 |
|
rotate_euler_angles(angles_xyz_radians)
Rotate the shape by the given Euler angles in radians
Parameters:
Name | Type | Description | Default |
---|---|---|---|
angle_xyz_radians
|
ndarray
|
3D array with angles to rotate about x-axis, y-axis and z-axis respectively in radians |
required |
Source code in src/occwl/shape.py
302 303 304 305 306 307 308 309 310 311 312 313 314 315 |
|
save_shapes_to_occ_native(filename, shapes, with_triangles=False, with_normals=False, format_version=None)
staticmethod
Save this shape into a native OCC binary .brep file.
Saving to and loading from the native file format
is between one and two orders of magnitude faster than loading from STEP, so it is recommended for large scale data processing
Parameters:
Name | Type | Description | Default |
---|---|---|---|
filename
|
str or Path
|
.brep filename |
required |
with_triangles
|
bool
|
Whether to save triangle data cached in the shape. |
False
|
with_normals
|
bool
|
Whether to save vertex normals cached in the shape |
False
|
format_version
|
int
|
Use None to save to the latest version 1 - first revision 2 - added storing of CurveOnSurface UV Points 3 - [OCCT 7.6] added storing of per-vertex normal information and dropped storing of CurveOnSurface UV Points |
None
|
Source code in src/occwl/shape.py
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 |
|
save_to_occ_native(filename, verbosity=False, with_triangles=False, with_normals=False, format_version=None)
Save this shape into a native OCC binary .brep file.
Saving to and loading from the native file format
is between one and two orders of magnitude faster than loading from STEP, so it is recommended for large scale data processing
Parameters:
Name | Type | Description | Default |
---|---|---|---|
filename
|
str or Path
|
.brep filename |
required |
with_triangles
|
bool
|
Whether to save triangle data cached in the shape. |
False
|
with_normals
|
bool
|
Whether to save vertex normals cached in the shape |
False
|
format_version
|
int
|
Use None to save to the latest version 1 - first revision 2 - added storing of CurveOnSurface UV Points 3 - [OCCT 7.6] added storing of per-vertex normal information and dropped storing of CurveOnSurface UV Points |
None
|
Source code in src/occwl/shape.py
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 |
|
scale(scale_vector)
Scale the shape by the given 3D vector
Parameters:
Name | Type | Description | Default |
---|---|---|---|
scale_vector
|
ndarray
|
3D array with scales to resize the shape along the x-axis, y-axis and z-axis respectively |
required |
Source code in src/occwl/shape.py
317 318 319 320 321 322 323 324 325 326 |
|
scale_to_box(box_side, copy=True)
Translate and scale the Shape so it fits exactly into the [-box_side, box_side]^3 box
Returns:
Type | Description |
---|---|
occwl..: The scaled version of this Shape |
Source code in src/occwl/base.py
594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 |
|
scale_to_unit_box(copy=True)
Translate and scale the Shape so it fits exactly into the [-1, 1]^3 box
Returns: The scaled version of this shape
Source code in src/occwl/base.py
628 629 630 631 632 633 634 635 636 637 638 639 640 641 |
|
seam(face)
Whether this edge is a seam
Parameters:
Name | Type | Description | Default |
---|---|---|---|
face
|
Face
|
Face where the edge lives |
required |
Returns:
Name | Type | Description |
---|---|---|
bool |
If seam |
Source code in src/occwl/edge.py
313 314 315 316 317 318 319 320 321 322 323 |
|
set_transform_to_identity()
When an assembly is loaded from a STEP file the solids will be transformed relative to their local coordinate system. i.e. they are placed in the assembly root components coordinate system.
When working with individual bodies you often want them to be axis aligned, in which case you want to remove the assembly transform. This function removes it for you.
If however you want to bake the transform into the bodies and suppress the asserts from parts of occwl which don't cope with transforms then use the transform() function below with copy=True
Source code in src/occwl/shape.py
346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 |
|
specific_curve()
Get the specific edge curve geometry
Returns:
Type | Description |
---|---|
OCC.Geom.Handle_Geom_*: Specific geometry type for the curve geometry or None if the curve type is GeomAbs_OtherCurve |
Source code in src/occwl/edge.py
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 |
|
start_vertex()
Returns the starting vertex of the edge while considering the edge orientation
Returns:
Type | Description |
---|---|
occwl.vertex.Vertex: Start vertex |
Source code in src/occwl/edge.py
150 151 152 153 154 155 156 157 |
|
tangent(u)
Compute the tangent of the edge geometry at given parameter
Parameters:
Name | Type | Description | Default |
---|---|---|---|
u
|
float
|
Curve parameter |
required |
Returns:
Type | Description |
---|---|
np.ndarray: 3D unit vector |
Source code in src/occwl/edge.py
168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 |
|
tolerance()
Get tolerance of this edge. The 3d curve of the edge should not deviate from the surfaces of adjacent faces by more than this value
Returns:
Type | Description |
---|---|
float The edge tolerance |
Source code in src/occwl/edge.py
408 409 410 411 412 413 414 415 416 |
|
topods_shape()
Get the underlying OCC shape
Returns:
Type | Description |
---|---|
OCC.Core.TopoDS.TopoDS_Vertex/Edge/Face/Wire/Shell/Solid: OCC TopoDS_* |
Source code in src/occwl/shape.py
80 81 82 83 84 85 86 87 |
|
transform(a, copy=True)
Apply the given 3x4 transform matrix to the solid.
copy (bool) True - Copy entities and apply the transform to
the underlying geometry
False - Apply the transform to the topods Locator
if possible
Source code in src/occwl/shape.py
400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 |
|
translate(offset)
Translate the shape by an offset vector
Parameters:
Name | Type | Description | Default |
---|---|---|---|
offset
|
ndarray
|
Offset vector |
required |
Source code in src/occwl/shape.py
276 277 278 279 280 281 282 283 |
|
u_bounds()
Parameter domain of the curve
Returns:
Type | Description |
---|---|
occwl.geometry.Interval: a 1D interval [u_min, u_max] |
Source code in src/occwl/edge.py
271 272 273 274 275 276 277 278 279 280 281 282 |
|
valid(return_analyzer=False)
Check if the shape is valid
Parameters:
Name | Type | Description | Default |
---|---|---|---|
return_analyzer
|
bool
|
Whether to return the BRepCheck_Analyzer object for more inspection |
False
|
Returns:
Name | Type | Description |
---|---|---|
bool |
Whether the shape is valid |
|
BRepCheck_Analyzer [optional]: if return_analyzer is True |
Source code in src/occwl/shape.py
328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 |
|
vertices()
Get an iterator to go over all vertices in the Shape
Returns:
Type | Description |
---|---|
Iterator[occwl.vertex.Vertex]: Vertex iterator |
Source code in src/occwl/base.py
34 35 36 37 38 39 40 41 42 |
|
edge_data_extractor
A class to extract points and normals from the two faces adjacent to an edge. This can then be used to compute the edges convexity.
EdgeDataExtractor
Source code in src/occwl/edge_data_extractor.py
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 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 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 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 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 |
|
__init__(edge, faces, num_samples=10, use_arclength_params=True)
Compute point and normal data for an oriented edge of the model. The arrays of points, tangents and normals are all oriented based on the orientation flag of the edge.
You can access the data from the member numpy arrays
EdgeDataExtractor.points
EdgeDataExtractor.tangests
EdgeDataExtractor.left_normals
EdgeDataExtractor.right_normals
If a problem was detected during the calculation then EdgeDataExtractor.good == false
Source code in src/occwl/edge_data_extractor.py
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
|
edge_convexity(angle_tol_rads)
Compute the convexity of the edge
Source code in src/occwl/edge_data_extractor.py
91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 |
|
sanity_check_uvs(uvs, edge_tolerance)
Assert that the points we get by evaluating uvs on both sides of the edge are within the specified tolerance.
This function is intended for testing/debugging
Source code in src/occwl/edge_data_extractor.py
109 110 111 112 113 114 115 116 117 118 119 120 121 |
|
entity_mapper
The entity mapper allows you to map between occwl entities and integer identifiers which can be used as indices into arrays of feature vectors or the rows and columns of incidence matrices.
NOTE:
Only oriented edges which are used by wires are included in the oriented
edge map. In the case of edges which are open (i.e. they are adjacent
to a hole in the solid), only one oriented edge is present. Use the function
EntityMapper.oriented_edge_exists(oriented_edge)
to check if an oriented edge is used by a wire and known to the entity mapper.
EntityMapper
This class allows us to map between occwl entities and integer identifiers which can be used as indices into arrays of feature vectors or the rows and columns of incidence matrices.
Source code in src/occwl/entity_mapper.py
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 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 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 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 |
|
__init__(solid)
Create a mapper object for solid
Args:
solid (occwl.solid.Solid): A single solid
Source code in src/occwl/entity_mapper.py
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
|
edge_index(edge)
Find the index of an edge
Source code in src/occwl/entity_mapper.py
73 74 75 76 77 78 |
|
face_index(face)
Find the index of a face
Source code in src/occwl/entity_mapper.py
59 60 61 62 63 64 |
|
oriented_edge_index(oriented_edge)
Find the index of a oriented edge. i.e. a coedge
Source code in src/occwl/entity_mapper.py
80 81 82 83 84 85 86 87 |
|
vertex_index(vertex)
Find the index of a vertex
Source code in src/occwl/entity_mapper.py
95 96 97 98 99 100 |
|
wire_index(wire)
Find the index of a wire
Source code in src/occwl/entity_mapper.py
66 67 68 69 70 71 |
|
face
Face
Bases: Shape
, BoundingBoxMixin
, TriangulatorMixin
, WireContainerMixin
, EdgeContainerMixin
, VertexContainerMixin
, SurfacePropertiesMixin
A topological face in a solid model Represents a 3D surface bounded by a Wire
Source code in src/occwl/face.py
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 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 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 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 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 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 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 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 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 413 414 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 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 |
|
__eq__(other)
Equality check for the shape
NOTE: This function only checks if the shape is the same. It doesn't check the edge orienation for example, so
edge1 == edge2
does not necessarily mean
edge1.reversed() == edge2.reversed()
Source code in src/occwl/shape.py
144 145 146 147 148 149 150 151 152 153 154 155 156 157 |
|
__hash__()
Hash for the shape
Returns:
Name | Type | Description |
---|---|---|
int |
Hash value |
Source code in src/occwl/shape.py
135 136 137 138 139 140 141 142 |
|
area()
Compute the area of the Shape
Returns:
Name | Type | Description |
---|---|---|
float |
Area |
Source code in src/occwl/base.py
493 494 495 496 497 498 499 500 501 502 |
|
box()
Get a quick bounding box of the Shape
Returns:
Name | Type | Description |
---|---|---|
Box |
Bounding box |
Source code in src/occwl/base.py
565 566 567 568 569 570 571 572 573 574 575 |
|
closed_u()
Whether the surface is closed along the U-direction
Returns:
Name | Type | Description |
---|---|---|
bool |
Is closed along U |
Source code in src/occwl/face.py
483 484 485 486 487 488 489 490 491 |
|
closed_v()
Whether the surface is closed along the V-direction
Returns:
Name | Type | Description |
---|---|---|
bool |
Is closed along V |
Source code in src/occwl/face.py
493 494 495 496 497 498 499 500 501 |
|
convert_geometric_identity_transforms_to_identity()
Open Cascade models sometimes contain transforms which are "geometrically" identify transforms, but the identity flag is not set.
This function checks each transform and sets the flag if the appropriate.
Source code in src/occwl/shape.py
371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 |
|
edges()
Get an iterator to go over all edges in the Shape
Returns:
Type | Description |
---|---|
Iterator[occwl.edge.Edge]: Edge iterator |
Source code in src/occwl/base.py
59 60 61 62 63 64 65 66 67 |
|
exact_box(use_shapetolerance=False)
Get a slow, but accurate box for the Shape.
Returns:
Name | Type | Description |
---|---|---|
Box |
Bounding box |
Source code in src/occwl/base.py
577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 |
|
find_closest_edge_slow(datum)
Find the closest edge to the given datum point. The function is for testing only. It will be slow as it loops over all edges in the Shape. A quick way to find the closest entity is to call Shape.find_closest_point_data(), but then you may get a face, edge or vertex back.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
datum
|
ndarray or tuple
|
3D datum point |
required |
Returns:
Name | Type | Description |
---|---|---|
Face |
The closest face in the Shape |
Source code in src/occwl/base.py
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 |
|
find_closest_point_data(datum)
Find the information about the closest point on this shape
Parameters:
Name | Type | Description | Default |
---|---|---|---|
datum
|
ndarray
|
3D Point |
required |
Returns:
Name | Type | Description |
---|---|---|
ClosestPointData |
Data about the closest point on this shape |
|
None |
if error |
Source code in src/occwl/shape.py
251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 |
|
gaussian_curvature(uv)
Compute the gaussian curvature of the surface geometry at given parameter
Parameters:
Name | Type | Description | Default |
---|---|---|---|
uv
|
ndarray or tuple
|
Surface parameter |
required |
Returns:
Name | Type | Description |
---|---|---|
float |
Gaussian curvature |
Source code in src/occwl/face.py
328 329 330 331 332 333 334 335 336 337 338 339 340 |
|
get_triangles(return_normals=False)
Get the tessellation of this face as a triangle mesh NOTE: First you must call shape.triangulate_all_faces() Then call this method to get the triangles for the face.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
return_normals
|
bool
|
Return vertex normals |
False
|
Returns:
Type | Description |
---|---|
2D np.ndarray: Vertices |
|
2D np.ndarray: Faces |
|
2D np.ndarray: Vertex Normals (when return_normals is True) |
Source code in src/occwl/face.py
523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 |
|
inside(uv)
Check if the uv-coordinate is inside the visible region of the face (excludes points that lie on the boundary)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
uv
|
ndarray or tuple
|
Surface parameter |
required |
Returns:
Name | Type | Description |
---|---|---|
bool |
Is inside |
Source code in src/occwl/face.py
146 147 148 149 150 151 152 153 154 155 156 157 |
|
is_left_of(edge)
Is this face on the left hand side of the given edge. We take the orientation of the edge into account here
Edge direction
^
|
Left | Right
face | face
|
Args: edge (occwl.edge.Edge): Edge
Returns:
Name | Type | Description |
---|---|---|
bool |
True if the face is to the left of the edge |
Source code in src/occwl/face.py
291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 |
|
make_from_wires(wires)
staticmethod
Make a face from PLANAR wires
Parameters:
Name | Type | Description | Default |
---|---|---|---|
wires
|
List[Wire]
|
List of wires |
required |
Returns:
Type | Description |
---|---|
occwl.face.Face or None: Returns a Face or None if the operation failed |
Source code in src/occwl/face.py
127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 |
|
make_nsided(edges, continuity='C0', points=None)
staticmethod
Make an n-sided fill-in face with the given edges, their continuities, and optionally a set of punctual points
Parameters:
Name | Type | Description | Default |
---|---|---|---|
edges
|
List[Edge]
|
A list of edges for creating the fill-in face |
required |
continuity
|
str or List[str]
|
A single string or a list of strings, one for each given edge. Must be one of "C0", "C1", "G1", "C2", "G2", "C3" |
'C0'
|
points
|
ndarray
|
Set of points to constrain the fill-in surface. Defaults to None. |
None
|
Returns:
Type | Description |
---|---|
occwl.face.Face: Filled-in face |
Source code in src/occwl/face.py
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 |
|
make_prism(profile_edge, vector, return_first_last_shapes=False)
staticmethod
Make a face from a profile edge by sweeping/extrusion
Parameters:
Name | Type | Description | Default |
---|---|---|---|
profile_edge
|
Edge
|
Edge |
required |
vector
|
ndarray
|
Direction and length of extrusion |
required |
return_first_last_shapes
|
bool
|
Whether to return the base and top shapes of the result. Defaults to False. |
False
|
Returns:
Type | Description |
---|---|
occwl.Face: Face created by sweeping the edge |
|
or None: if error |
|
occwl.Edge, occwl.Edge (optional): Returns the base and top edges of return_first_last_shapes is True. |
Source code in src/occwl/face.py
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
|
max_curvature(uv)
Compute the maximum curvature of the surface geometry at given parameter
Parameters:
Name | Type | Description | Default |
---|---|---|---|
uv
|
ndarray or tuple
|
Surface parameter |
required |
Returns:
Name | Type | Description |
---|---|---|
float |
Max. curvature |
Source code in src/occwl/face.py
376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 |
|
mean_curvature(uv)
Compute the mean curvature of the surface geometry at given parameter
Parameters:
Name | Type | Description | Default |
---|---|---|---|
uv
|
ndarray or tuple
|
Surface parameter |
required |
Returns:
Name | Type | Description |
---|---|---|
float |
Mean curvature |
Source code in src/occwl/face.py
359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 |
|
min_curvature(uv)
Compute the minimum curvature of the surface geometry at given parameter
Parameters:
Name | Type | Description | Default |
---|---|---|---|
uv
|
ndarray or tuple
|
Surface parameter |
required |
Returns:
Name | Type | Description |
---|---|---|
float |
Min. curvature |
Source code in src/occwl/face.py
342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 |
|
normal(uv)
Compute the normal of the surface geometry at given parameter
Parameters:
Name | Type | Description | Default |
---|---|---|---|
uv
|
ndarray or tuple
|
Surface parameter |
required |
Returns:
Type | Description |
---|---|
np.ndarray: 3D unit normal vector |
Source code in src/occwl/face.py
269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 |
|
num_edges()
Number of edges in the Shape
Returns:
Name | Type | Description |
---|---|---|
int |
Number of edges |
Source code in src/occwl/base.py
50 51 52 53 54 55 56 57 |
|
num_vertices()
Number of vertices in the Shape
Returns:
Name | Type | Description |
---|---|---|
int |
Number of vertices |
Source code in src/occwl/base.py
25 26 27 28 29 30 31 32 |
|
num_wires()
Number of wires in the Shape
Returns:
Name | Type | Description |
---|---|---|
int |
Number of wires |
Source code in src/occwl/base.py
131 132 133 134 135 136 137 138 |
|
occwl_shape(topods_shape)
staticmethod
Static method to create an occwl shape of the appropriate class from the given topods_shape Args: topods_shape (OCC.Core.TopoDS.TopoDS_Vertex/Edge/Face/Wire/Shell/Solid): TopoDS shape
Returns:
Type | Description |
---|---|
One of occwl.compound.Compound occwl.solid.Solid occwl.face.Face occwl.edge.Edge occwl.vertex.Vertex occwl.wire.Wire occwl.shell.Shell |
Raises: Exception: [description]
Source code in src/occwl/shape.py
89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 |
|
pcurve(edge)
Get the given edge's curve geometry as a 2D parametric curve on this face
Parameters:
Name | Type | Description | Default |
---|---|---|---|
edge
|
Edge
|
Edge |
required |
Returns:
Name | Type | Description |
---|---|---|
Geom2d_Curve |
2D curve |
|
Interval |
domain of the parametric curve |
Source code in src/occwl/face.py
393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 |
|
periodic_u()
Whether the surface is periodic along the U-direction
Returns:
Name | Type | Description |
---|---|---|
bool |
Is periodic along U |
Source code in src/occwl/face.py
503 504 505 506 507 508 509 510 511 |
|
periodic_v()
Whether the surface is periodic along the V-direction
Returns:
Name | Type | Description |
---|---|---|
bool |
Is periodic along V |
Source code in src/occwl/face.py
513 514 515 516 517 518 519 520 521 |
|
point(uv)
Evaluate the face geometry at given parameter
Parameters:
Name | Type | Description | Default |
---|---|---|---|
uv
|
ndarray or tuple
|
Surface parameter |
required |
Returns:
Type | Description |
---|---|
np.ndarray: 3D Point |
Source code in src/occwl/face.py
232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 |
|
point_to_parameter(pt)
Get the UV parameter by projecting the point on this face
Parameters:
Name | Type | Description | Default |
---|---|---|---|
pt
|
ndarray
|
3D point |
required |
Returns:
Type | Description |
---|---|
np.ndarray: UV-coordinate |
Source code in src/occwl/face.py
422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 |
|
reversed()
Whether this shape is reversed.
- For an edge this is whether the edge is reversed with respect to the curve geometry
- For a face this is whether the face is reversed with respect to the surface geometry
- For a vertex this is whether the vertex is at the upper or lower parameter value on the edges curve
Returns:
Name | Type | Description |
---|---|---|
bool |
If rational |
Source code in src/occwl/shape.py
236 237 238 239 240 241 242 243 244 245 246 247 248 |
|
reversed_face()
Return a copy of this face with the orientation reversed.
Returns:
Type | Description |
---|---|
occwl.face.Face: A face with the opposite orientation to this face. |
Source code in src/occwl/face.py
190 191 192 193 194 195 196 197 |
|
rotate_axis_angle(axis, angle_radians, origin=np.zeros(3, dtype=(np.float32)))
Rotate the shape about the given axis by the given angle in radians
Parameters:
Name | Type | Description | Default |
---|---|---|---|
axis
|
ndarray
|
Rotation axis |
required |
angle_radians
|
float
|
Angle in radians |
required |
Source code in src/occwl/shape.py
285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 |
|
rotate_euler_angles(angles_xyz_radians)
Rotate the shape by the given Euler angles in radians
Parameters:
Name | Type | Description | Default |
---|---|---|---|
angle_xyz_radians
|
ndarray
|
3D array with angles to rotate about x-axis, y-axis and z-axis respectively in radians |
required |
Source code in src/occwl/shape.py
302 303 304 305 306 307 308 309 310 311 312 313 314 315 |
|
save_shapes_to_occ_native(filename, shapes, with_triangles=False, with_normals=False, format_version=None)
staticmethod
Save this shape into a native OCC binary .brep file.
Saving to and loading from the native file format
is between one and two orders of magnitude faster than loading from STEP, so it is recommended for large scale data processing
Parameters:
Name | Type | Description | Default |
---|---|---|---|
filename
|
str or Path
|
.brep filename |
required |
with_triangles
|
bool
|
Whether to save triangle data cached in the shape. |
False
|
with_normals
|
bool
|
Whether to save vertex normals cached in the shape |
False
|
format_version
|
int
|
Use None to save to the latest version 1 - first revision 2 - added storing of CurveOnSurface UV Points 3 - [OCCT 7.6] added storing of per-vertex normal information and dropped storing of CurveOnSurface UV Points |
None
|
Source code in src/occwl/shape.py
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 |
|
save_to_occ_native(filename, verbosity=False, with_triangles=False, with_normals=False, format_version=None)
Save this shape into a native OCC binary .brep file.
Saving to and loading from the native file format
is between one and two orders of magnitude faster than loading from STEP, so it is recommended for large scale data processing
Parameters:
Name | Type | Description | Default |
---|---|---|---|
filename
|
str or Path
|
.brep filename |
required |
with_triangles
|
bool
|
Whether to save triangle data cached in the shape. |
False
|
with_normals
|
bool
|
Whether to save vertex normals cached in the shape |
False
|
format_version
|
int
|
Use None to save to the latest version 1 - first revision 2 - added storing of CurveOnSurface UV Points 3 - [OCCT 7.6] added storing of per-vertex normal information and dropped storing of CurveOnSurface UV Points |
None
|
Source code in src/occwl/shape.py
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 |
|
scale(scale_vector)
Scale the shape by the given 3D vector
Parameters:
Name | Type | Description | Default |
---|---|---|---|
scale_vector
|
ndarray
|
3D array with scales to resize the shape along the x-axis, y-axis and z-axis respectively |
required |
Source code in src/occwl/shape.py
317 318 319 320 321 322 323 324 325 326 |
|
scale_to_box(box_side, copy=True)
Translate and scale the Shape so it fits exactly into the [-box_side, box_side]^3 box
Returns:
Type | Description |
---|---|
occwl..: The scaled version of this Shape |
Source code in src/occwl/base.py
594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 |
|
scale_to_unit_box(copy=True)
Translate and scale the Shape so it fits exactly into the [-1, 1]^3 box
Returns: The scaled version of this shape
Source code in src/occwl/base.py
628 629 630 631 632 633 634 635 636 637 638 639 640 641 |
|
set_transform_to_identity()
When an assembly is loaded from a STEP file the solids will be transformed relative to their local coordinate system. i.e. they are placed in the assembly root components coordinate system.
When working with individual bodies you often want them to be axis aligned, in which case you want to remove the assembly transform. This function removes it for you.
If however you want to bake the transform into the bodies and suppress the asserts from parts of occwl which don't cope with transforms then use the transform() function below with copy=True
Source code in src/occwl/shape.py
346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 |
|
specific_surface()
Get the specific face surface geometry
Returns:
Type | Description |
---|---|
OCC.Geom.Handle_Geom_*: Specific geometry type for the surface geometry |
Source code in src/occwl/face.py
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 |
|
split_all_closed_edges(max_tol=0.01, precision=0.01, num_splits=1)
Split all the closed edges in this shape
Parameters:
Name | Type | Description | Default |
---|---|---|---|
max_tol
|
float
|
Maximum tolerance allowed. Defaults to 0.01. |
0.01
|
precision
|
float
|
Precision of the tool when splitting. Defaults to 0.01. |
0.01
|
num_splits
|
int
|
Number of splits to perform. Each split edge will result in num_splits + 1 edges. Defaults to 1. |
1
|
Returns:
Type | Description |
---|---|
occwl..: Shape with closed edges split |
Source code in src/occwl/base.py
101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 |
|
surface()
Get the face surface geometry
Returns:
Type | Description |
---|---|
OCC.Geom.Handle_Geom_Surface: Interface to all surface geometry |
Source code in src/occwl/face.py
172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 |
|
surface_type()
Get the type of the surface geometry
Returns:
Name | Type | Description |
---|---|---|
str |
Type of the surface geometry |
Source code in src/occwl/face.py
442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 |
|
surface_type_enum()
Get the type of the surface geometry as an OCC.Core.GeomAbs enum
Returns:
Type | Description |
---|---|
OCC.Core.GeomAbs: Type of the surface geometry |
Source code in src/occwl/face.py
474 475 476 477 478 479 480 481 |
|
tangent(uv)
Compute the tangents of the surface geometry at given parameter
Parameters:
Name | Type | Description | Default |
---|---|---|---|
uv
|
ndarray or tuple
|
Surface parameter |
required |
Returns:
Type | Description |
---|---|
Pair of np.ndarray or None: 3D unit vectors |
Source code in src/occwl/face.py
248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 |
|
topods_shape()
Get the underlying OCC shape
Returns:
Type | Description |
---|---|
OCC.Core.TopoDS.TopoDS_Vertex/Edge/Face/Wire/Shell/Solid: OCC TopoDS_* |
Source code in src/occwl/shape.py
80 81 82 83 84 85 86 87 |
|
transform(a, copy=True)
Apply the given 3x4 transform matrix to the solid.
copy (bool) True - Copy entities and apply the transform to
the underlying geometry
False - Apply the transform to the topods Locator
if possible
Source code in src/occwl/shape.py
400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 |
|
translate(offset)
Translate the shape by an offset vector
Parameters:
Name | Type | Description | Default |
---|---|---|---|
offset
|
ndarray
|
Offset vector |
required |
Source code in src/occwl/shape.py
276 277 278 279 280 281 282 283 |
|
triangulate(triangle_face_tol=0.01, tol_relative_to_face=True, angle_tol_rads=0.1)
Triangulate all the faces in the shape. You can then get the triangles from each face separately using face.get_triangles(). If you wanted triangles for the entire shape then call shape.get_triangles() below. For more details see https://old.opencascade.com/doc/occt-7.1.0/overview/html/occt_user_guides__modeling_algos.html#occt_modalg_11
Parameters:
Name | Type | Description | Default |
---|---|---|---|
triangle_face_tol
|
float
|
Tolerance between triangle and surface. Defaults to 0.01. |
0.01
|
tol_relative_to_face
|
bool
|
Whether tolerance is relative to face size |
True
|
angle_tol_rads
|
float
|
Angle tolerance in radians. Defaults to 0.1. |
0.1
|
Returns:
Name | Type | Description |
---|---|---|
bool |
Is successful |
Source code in src/occwl/base.py
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 |
|
uv_bounds()
Get the UV-domain bounds of this face's surface geometry
Returns:
Name | Type | Description |
---|---|---|
Box |
UV-domain bounds |
Source code in src/occwl/face.py
410 411 412 413 414 415 416 417 418 419 420 |
|
valid(return_analyzer=False)
Check if the shape is valid
Parameters:
Name | Type | Description | Default |
---|---|---|---|
return_analyzer
|
bool
|
Whether to return the BRepCheck_Analyzer object for more inspection |
False
|
Returns:
Name | Type | Description |
---|---|---|
bool |
Whether the shape is valid |
|
BRepCheck_Analyzer [optional]: if return_analyzer is True |
Source code in src/occwl/shape.py
328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 |
|
vertices()
Get an iterator to go over all vertices in the Shape
Returns:
Type | Description |
---|---|
Iterator[occwl.vertex.Vertex]: Vertex iterator |
Source code in src/occwl/base.py
34 35 36 37 38 39 40 41 42 |
|
vertices_from_edge(edge)
Get an iterator to go over the vertices bounding an edge
Parameters:
Name | Type | Description | Default |
---|---|---|---|
edge
|
Edge
|
Input edge |
required |
Returns:
Type | Description |
---|---|
Iterator[occwl.vertex.Vertex]: Vertex iterator |
Source code in src/occwl/base.py
69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
|
visibility_status(uv)
Check if the uv-coordinate in on the visible region of the face
Parameters:
Name | Type | Description | Default |
---|---|---|---|
uv
|
ndarray or tuple
|
Surface parameter |
required |
Returns:
Name | Type | Description |
---|---|---|
int |
TopAbs_STATE enum
|
0: TopAbs_IN, 1: TopAbs_OUT, 2: TopAbs_ON, 3: TopAbs_UNKNOWN |
Source code in src/occwl/face.py
159 160 161 162 163 164 165 166 167 168 169 170 |
|
wires()
Get an iterator to go over all wires in the Shape
Returns:
Type | Description |
---|---|
Iterator[occwl.wire.Wire]: Wire iterator |
Source code in src/occwl/base.py
140 141 142 143 144 145 146 147 148 |
|
geometry
arc_length_param_finder
Tools for finding an arc-length parameterization from an edge, curve interval or surface iso-parametric curve
ArcLengthParamFinder
Source code in src/occwl/geometry/arc_length_param_finder.py
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 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 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 |
|
__init__(points=None, us=None, edge=None, num_arc_length_samples=100)
Create a class to generate arc-length parameters
Parameters:
Name | Type | Description | Default |
---|---|---|---|
points
|
list(np.array
|
Point samples on the curve |
None
|
us
|
list(float
|
u parameters on the curve |
None
|
edge
|
Edge
|
An edge |
None
|
num_arc_length_samples
|
int
|
The number of samples to use the the calculation |
100
|
Source code in src/occwl/geometry/arc_length_param_finder.py
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
|
find_arc_length_parameters(num_samples)
Find a list of u parameters which provides an equal arc length list for the given points and us
Source code in src/occwl/geometry/arc_length_param_finder.py
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 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 97 98 99 100 101 102 |
|
box
Box
A 2d or 3d box for points defined as numpy arrays
Source code in src/occwl/geometry/box.py
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
|
interval
Interval
Source code in src/occwl/geometry/interval.py
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
|
interpolate(t)
Return a position inside the interval which interpolates between a and b. i.e. If t==0 then return a If t==1 then return b If 0<t<1 then return a value inside the interval
Source code in src/occwl/geometry/interval.py
54 55 56 57 58 59 60 61 62 |
|
invalid()
An invalid interval is uninitialized. It can be thought of as an intervale containing no points
Source code in src/occwl/geometry/interval.py
13 14 15 16 17 18 19 |
|
graph
face_adjacency(shape, self_loops=False)
Creates a face adjacency graph from the given shape (Solid or Compound)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
shape
|
Shell, Solid, or Compound
|
Shape |
required |
self_loops
|
bool
|
Whether to add self loops in the graph. Defaults to False. |
False
|
Returns:
Name | Type | Description |
---|---|---|
nx.DiGraph: Each B-rep face is mapped to a node with its index and each B-rep edge is mapped to an edge in the graph Node attributes: - "face": contains the B-rep face Edge attributes: - "edge": contains the B-rep (ordered) edge - "edge_idx": index of the (ordered) edge in the solid |
||
None |
if the shape is non-manifold or open |
Source code in src/occwl/graph.py
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
|
vertex_adjacency(shape, self_loops=False)
Creates a vertex adjacency graph from the given shape (Wire, Solid or Compound)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
shape
|
Wire, Face, Shell, Solid, or Compound
|
Shape |
required |
self_loops
|
bool
|
Whether to add self loops in the graph. Defaults to False. |
False
|
Returns:
Type | Description |
---|---|
nx.DiGraph: Each B-rep vertex is mapped to a node with its index and each B-rep edge is mapped to an edge in the graph Node attributes: - "vertex": contains the B-rep vertex Edge attributes: - "edge": contains the B-rep (ordered) edge - "edge_idx": index of the (ordered) edge in the solid |
Source code in src/occwl/graph.py
60 61 62 63 64 65 66 67 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 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 |
|
io
load_single_compound_from_step(step_filename)
Load data from a STEP file as a single compound
Parameters:
Name | Type | Description | Default |
---|---|---|---|
step_filename
|
str
|
Path to STEP file |
required |
Returns:
Type | Description |
---|---|
List of occwl.Compound: a single compound containing all shapes in the file |
Source code in src/occwl/io.py
13 14 15 16 17 18 19 20 21 22 23 24 25 |
|
load_step(step_filename)
Load solids from a STEP file
Parameters:
Name | Type | Description | Default |
---|---|---|---|
step_filename
|
str
|
Path to STEP file |
required |
Returns:
Type | Description |
---|---|
List of occwl.Solid: a list of solid models from the file |
Source code in src/occwl/io.py
28 29 30 31 32 33 34 35 36 37 38 39 |
|
save_step(list_of_solids, filename)
Save solids into a STEP file
Parameters:
Name | Type | Description | Default |
---|---|---|---|
list_of_solids
|
List[Solid]
|
List of solids |
required |
filename
|
Path or str
|
Output STEP file name |
required |
Returns:
Name | Type | Description |
---|---|---|
bool |
Whether successful |
Source code in src/occwl/io.py
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
|
save_stl(shape, filename, binary=True)
Saves a tesselated entity as a STL file NOTE: Call Solid.triangulate_all_faces() first
Parameters:
Name | Type | Description | Default |
---|---|---|---|
shape
|
[type]
|
[description] |
required |
filename
|
[type]
|
[description] |
required |
binary
|
bool
|
[description]. Defaults to True. |
True
|
Source code in src/occwl/io.py
102 103 104 105 106 107 108 109 110 111 112 113 |
|
save_svg(shape, filename, export_hidden_edges=True, location=(0, 0, 0), direction=(1, 1, 1), color='black', line_width=0.1)
Saves the shape outline as an SVG file
Parameters:
Name | Type | Description | Default |
---|---|---|---|
shape
|
Any occwl topology type
|
Any topological entity |
required |
filename
|
str
|
Path to output SVG |
required |
export_hidden_edges
|
bool
|
Whether to render hidden edges as dotted lines in the SVG. Defaults to True. |
True
|
location
|
tuple
|
Location. Defaults to (0, 0, 0). |
(0, 0, 0)
|
direction
|
tuple
|
Direction. Defaults to (1, 1, 1). |
(1, 1, 1)
|
color
|
str
|
Color of the paths in SVG. Defaults to "black". |
'black'
|
line_width
|
float
|
Width of each path. Defaults to 0.1. |
0.1
|
Source code in src/occwl/io.py
61 62 63 64 65 66 67 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 97 98 99 |
|
jupyter_viewer
JupyterViewer
A viewer for models in a Jupyter notebook
Source code in src/occwl/jupyter_viewer.py
110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 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 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 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 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 |
|
__init__(size=(640, 480), background_color='white')
Construct the Viewer
Args:
Source code in src/occwl/jupyter_viewer.py
115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 |
|
display(shape, update=False, shape_color=None, render_edges=False, edge_color=None, transparency=0.0)
Display a shape (must be a Solid, Face, or Edge)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
shape
|
Solid, Face, or Edge
|
Shape to display |
required |
update
|
bool
|
Whether to update and repaint. Defaults to False. |
False
|
shape_color
|
[type]
|
Color of the shape. |
None
|
edge_color
|
[type]
|
Color of the shape's edges. Can be 'WHITE', 'BLUE', 'RED', 'GREEN', 'YELLOW', 'CYAN', 'BLACK', 'ORANGE' or [r,g,b] Defaults to None. |
None
|
render_edges
|
bool
|
Whether to render edges |
False
|
transparency
|
float
|
Defaults to 0. (opaque). 0. is fully opaque, 1. is fully transparent. |
0.0
|
Source code in src/occwl/jupyter_viewer.py
134 135 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 |
|
display_face_colormap(solid, values_for_faces, color_map='rainbow', update=False, render_edges=False, edge_color=None, transparency=0.0)
Display a solid with the faces colored according to some scalar function.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
solid
|
(Solid,)
|
Solid to display |
required |
update
|
bool
|
Whether to update and repaint. Defaults to False. |
False
|
color_map
|
str
|
Choose from https://matplotlib.org/stable/tutorials/colors/colormaps.html |
'rainbow'
|
values_for_faces
|
(list, array)
|
Array of values, one for each face |
required |
render_edges
|
bool
|
Whether to render edges |
False
|
transparency
|
float
|
Defaults to 0. (opaque). 0. is fully opaque, 1. is fully transparent. |
0.0
|
Source code in src/occwl/jupyter_viewer.py
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 |
|
display_lines(start_points, end_points, line_color='blue', line_width=1, update=False)
Display points a set of points
Parameters:
Name | Type | Description | Default |
---|---|---|---|
start_points
|
array
|
Array of start_points size [ num_points x 3 ] |
required |
end_points
|
array
|
Array of end_points size [ num_points x 3 ] |
required |
Source code in src/occwl/jupyter_viewer.py
256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 |
|
display_points(points, normals=None, point_color='red', point_width=4, update=False)
Display a set of points
Parameters:
Name | Type | Description | Default |
---|---|---|---|
points
|
array
|
Array of points size [ num_points x 3 ] |
required |
Source code in src/occwl/jupyter_viewer.py
233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 |
|
display_unit_vectors(points, directions, line_color='blue', line_width=2, update=False)
Display a set of unit vectors
Parameters:
Name | Type | Description | Default |
---|---|---|---|
points
|
array
|
Array of points size [ num_points x 3 ] |
required |
directions
|
array
|
Array of directions size [ num_points x 3 ] |
required |
Source code in src/occwl/jupyter_viewer.py
280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 |
|
selected_edge_indices(entity_mapper)
Get the selected edge indices
Returns:
Type | Description |
---|---|
np.ndarray(int) : List of indices of selected edges |
Source code in src/occwl/jupyter_viewer.py
351 352 353 354 355 356 357 358 359 360 361 |
|
selected_edges()
Get the selected edges
Returns:
Type | Description |
---|---|
List[Face]: List of selected edges |
Source code in src/occwl/jupyter_viewer.py
342 343 344 345 346 347 348 349 |
|
selected_face_indices(entity_mapper)
Get the selected face indices
Returns:
Type | Description |
---|---|
np.ndarray(int) : List of indices of selected faces |
Source code in src/occwl/jupyter_viewer.py
330 331 332 333 334 335 336 337 338 339 340 |
|
selected_faces()
Get the selected faces
Returns:
Type | Description |
---|---|
List[Face]: List of selected faces |
Source code in src/occwl/jupyter_viewer.py
320 321 322 323 324 325 326 327 |
|
show()
Show the viewer
Source code in src/occwl/jupyter_viewer.py
364 365 366 367 368 |
|
MultiSelectJupyterRenderer
Bases: JupyterRenderer
This class derived from JupyterRenderer allows more than one shape to be selected at a time.
Source code in src/occwl/jupyter_viewer.py
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 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 97 98 99 100 101 102 103 104 105 106 107 |
|
add_lines(start_arr, end_arr, line_color='blue', line_width=2, update=False)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
start_arr
|
array
|
A numpy array of points [ num_points x 3 ] |
required |
end_arr
|
array
|
A numpy array of points [ num_points x 3 ] |
required |
line_color
|
str
|
color for the points |
'blue'
|
vertex_width
|
int
|
vertex width in pixels |
required |
update
|
bool
|
Update the display |
False
|
Source code in src/occwl/jupyter_viewer.py
89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 |
|
add_points(points_array, vertex_color='red', vertex_width=5, update=False)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
points_array
|
array
|
A numpy array of points [ num_points x 3 ] |
required |
vertex_color
|
str
|
color for the points |
'red'
|
vertex_width
|
int
|
vertex width in pixels |
5
|
update
|
bool
|
Update the display |
False
|
Source code in src/occwl/jupyter_viewer.py
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
|
click(value)
called whenever a shape or edge is clicked
Source code in src/occwl/jupyter_viewer.py
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
|
shape
Base class for faces, edges and vertices
ClosestPointData
A class to record information about the closest point on a shape to some datum point
Source code in src/occwl/shape.py
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
|
__init__(dist_shape_shape)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
dist_shape_shape
|
BRepExtrema_DistShapeShape
|
OCC class for distance to a shape |
required |
Source code in src/occwl/shape.py
40 41 42 43 44 45 46 47 48 |
|
Shape
Source code in src/occwl/shape.py
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 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 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 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 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 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 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 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 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 413 414 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 |
|
__eq__(other)
Equality check for the shape
NOTE: This function only checks if the shape is the same. It doesn't check the edge orienation for example, so
edge1 == edge2
does not necessarily mean
edge1.reversed() == edge2.reversed()
Source code in src/occwl/shape.py
144 145 146 147 148 149 150 151 152 153 154 155 156 157 |
|
__hash__()
Hash for the shape
Returns:
Name | Type | Description |
---|---|---|
int |
Hash value |
Source code in src/occwl/shape.py
135 136 137 138 139 140 141 142 |
|
__init__(topods_shape)
Construct the Shape (this class is not meant to be instantiated directly)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
topods_shape
|
TopoDS_Vertex / Edge / Face / Wire / Shell / Solid
|
OCC TopoDS_* as provided by the derived class |
required |
Raises:
Type | Description |
---|---|
Exception
|
[description] |
Source code in src/occwl/shape.py
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
|
convert_geometric_identity_transforms_to_identity()
Open Cascade models sometimes contain transforms which are "geometrically" identify transforms, but the identity flag is not set.
This function checks each transform and sets the flag if the appropriate.
Source code in src/occwl/shape.py
371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 |
|
find_closest_point_data(datum)
Find the information about the closest point on this shape
Parameters:
Name | Type | Description | Default |
---|---|---|---|
datum
|
ndarray
|
3D Point |
required |
Returns:
Name | Type | Description |
---|---|---|
ClosestPointData |
Data about the closest point on this shape |
|
None |
if error |
Source code in src/occwl/shape.py
251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 |
|
occwl_shape(topods_shape)
staticmethod
Static method to create an occwl shape of the appropriate class from the given topods_shape Args: topods_shape (OCC.Core.TopoDS.TopoDS_Vertex/Edge/Face/Wire/Shell/Solid): TopoDS shape
Returns:
Type | Description |
---|---|
One of occwl.compound.Compound occwl.solid.Solid occwl.face.Face occwl.edge.Edge occwl.vertex.Vertex occwl.wire.Wire occwl.shell.Shell |
Raises: Exception: [description]
Source code in src/occwl/shape.py
89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 |
|
reversed()
Whether this shape is reversed.
- For an edge this is whether the edge is reversed with respect to the curve geometry
- For a face this is whether the face is reversed with respect to the surface geometry
- For a vertex this is whether the vertex is at the upper or lower parameter value on the edges curve
Returns:
Name | Type | Description |
---|---|---|
bool |
If rational |
Source code in src/occwl/shape.py
236 237 238 239 240 241 242 243 244 245 246 247 248 |
|
rotate_axis_angle(axis, angle_radians, origin=np.zeros(3, dtype=(np.float32)))
Rotate the shape about the given axis by the given angle in radians
Parameters:
Name | Type | Description | Default |
---|---|---|---|
axis
|
ndarray
|
Rotation axis |
required |
angle_radians
|
float
|
Angle in radians |
required |
Source code in src/occwl/shape.py
285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 |
|
rotate_euler_angles(angles_xyz_radians)
Rotate the shape by the given Euler angles in radians
Parameters:
Name | Type | Description | Default |
---|---|---|---|
angle_xyz_radians
|
ndarray
|
3D array with angles to rotate about x-axis, y-axis and z-axis respectively in radians |
required |
Source code in src/occwl/shape.py
302 303 304 305 306 307 308 309 310 311 312 313 314 315 |
|
save_shapes_to_occ_native(filename, shapes, with_triangles=False, with_normals=False, format_version=None)
staticmethod
Save this shape into a native OCC binary .brep file.
Saving to and loading from the native file format
is between one and two orders of magnitude faster than loading from STEP, so it is recommended for large scale data processing
Parameters:
Name | Type | Description | Default |
---|---|---|---|
filename
|
str or Path
|
.brep filename |
required |
with_triangles
|
bool
|
Whether to save triangle data cached in the shape. |
False
|
with_normals
|
bool
|
Whether to save vertex normals cached in the shape |
False
|
format_version
|
int
|
Use None to save to the latest version 1 - first revision 2 - added storing of CurveOnSurface UV Points 3 - [OCCT 7.6] added storing of per-vertex normal information and dropped storing of CurveOnSurface UV Points |
None
|
Source code in src/occwl/shape.py
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 |
|
save_to_occ_native(filename, verbosity=False, with_triangles=False, with_normals=False, format_version=None)
Save this shape into a native OCC binary .brep file.
Saving to and loading from the native file format
is between one and two orders of magnitude faster than loading from STEP, so it is recommended for large scale data processing
Parameters:
Name | Type | Description | Default |
---|---|---|---|
filename
|
str or Path
|
.brep filename |
required |
with_triangles
|
bool
|
Whether to save triangle data cached in the shape. |
False
|
with_normals
|
bool
|
Whether to save vertex normals cached in the shape |
False
|
format_version
|
int
|
Use None to save to the latest version 1 - first revision 2 - added storing of CurveOnSurface UV Points 3 - [OCCT 7.6] added storing of per-vertex normal information and dropped storing of CurveOnSurface UV Points |
None
|
Source code in src/occwl/shape.py
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 |
|
scale(scale_vector)
Scale the shape by the given 3D vector
Parameters:
Name | Type | Description | Default |
---|---|---|---|
scale_vector
|
ndarray
|
3D array with scales to resize the shape along the x-axis, y-axis and z-axis respectively |
required |
Source code in src/occwl/shape.py
317 318 319 320 321 322 323 324 325 326 |
|
set_transform_to_identity()
When an assembly is loaded from a STEP file the solids will be transformed relative to their local coordinate system. i.e. they are placed in the assembly root components coordinate system.
When working with individual bodies you often want them to be axis aligned, in which case you want to remove the assembly transform. This function removes it for you.
If however you want to bake the transform into the bodies and suppress the asserts from parts of occwl which don't cope with transforms then use the transform() function below with copy=True
Source code in src/occwl/shape.py
346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 |
|
topods_shape()
Get the underlying OCC shape
Returns:
Type | Description |
---|---|
OCC.Core.TopoDS.TopoDS_Vertex/Edge/Face/Wire/Shell/Solid: OCC TopoDS_* |
Source code in src/occwl/shape.py
80 81 82 83 84 85 86 87 |
|
transform(a, copy=True)
Apply the given 3x4 transform matrix to the solid.
copy (bool) True - Copy entities and apply the transform to
the underlying geometry
False - Apply the transform to the topods Locator
if possible
Source code in src/occwl/shape.py
400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 |
|
translate(offset)
Translate the shape by an offset vector
Parameters:
Name | Type | Description | Default |
---|---|---|---|
offset
|
ndarray
|
Offset vector |
required |
Source code in src/occwl/shape.py
276 277 278 279 280 281 282 283 |
|
valid(return_analyzer=False)
Check if the shape is valid
Parameters:
Name | Type | Description | Default |
---|---|---|---|
return_analyzer
|
bool
|
Whether to return the BRepCheck_Analyzer object for more inspection |
False
|
Returns:
Name | Type | Description |
---|---|---|
bool |
Whether the shape is valid |
|
BRepCheck_Analyzer [optional]: if return_analyzer is True |
Source code in src/occwl/shape.py
328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 |
|
shell
Shell
Bases: BottomUpFaceIterator
, BottomUpEdgeIterator
, BoundingBoxMixin
, VertexContainerMixin
, EdgeContainerMixin
, WireContainerMixin
, FaceContainerMixin
, SurfacePropertiesMixin
, TriangulatorMixin
, Shape
A shell is a sewed set of faces.
Source code in src/occwl/shell.py
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
|
__eq__(other)
Equality check for the shape
NOTE: This function only checks if the shape is the same. It doesn't check the edge orienation for example, so
edge1 == edge2
does not necessarily mean
edge1.reversed() == edge2.reversed()
Source code in src/occwl/shape.py
144 145 146 147 148 149 150 151 152 153 154 155 156 157 |
|
__hash__()
Hash for the shape
Returns:
Name | Type | Description |
---|---|---|
int |
Hash value |
Source code in src/occwl/shape.py
135 136 137 138 139 140 141 142 |
|
area()
Compute the area of the Shape
Returns:
Name | Type | Description |
---|---|---|
float |
Area |
Source code in src/occwl/base.py
493 494 495 496 497 498 499 500 501 502 |
|
box()
Get a quick bounding box of the Shape
Returns:
Name | Type | Description |
---|---|---|
Box |
Bounding box |
Source code in src/occwl/base.py
565 566 567 568 569 570 571 572 573 574 575 |
|
convert_geometric_identity_transforms_to_identity()
Open Cascade models sometimes contain transforms which are "geometrically" identify transforms, but the identity flag is not set.
This function checks each transform and sets the flag if the appropriate.
Source code in src/occwl/shape.py
371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 |
|
edge_continuity(edge)
Get the neighboring faces' continuity at given edge
Parameters:
Name | Type | Description | Default |
---|---|---|---|
edge
|
Edge
|
Edge |
required |
Returns:
Name | Type | Description |
---|---|---|
GeomAbs_Shape |
enum describing the continuity order |
Source code in src/occwl/base.py
347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 |
|
edges()
Get an iterator to go over all edges in the Shape
Returns:
Type | Description |
---|---|
Iterator[occwl.edge.Edge]: Edge iterator |
Source code in src/occwl/base.py
59 60 61 62 63 64 65 66 67 |
|
edges_from_face(face)
Get an iterator to go over the edges in a face
Parameters:
Name | Type | Description | Default |
---|---|---|---|
face
|
Face
|
Input face |
required |
Returns:
Type | Description |
---|---|
Iterator[occwl.edge.Edge]: Edge iterator |
Source code in src/occwl/base.py
190 191 192 193 194 195 196 197 198 199 200 201 202 203 |
|
edges_from_vertex(vertex)
Get an iterator to go over the edges adjacent to a vertex
Parameters:
Name | Type | Description | Default |
---|---|---|---|
face
|
Face
|
Input face |
required |
Returns:
Type | Description |
---|---|
Iterator[occwl.edge.Edge]: Edge iterator |
Source code in src/occwl/base.py
386 387 388 389 390 391 392 393 394 395 396 397 398 399 |
|
exact_box(use_shapetolerance=False)
Get a slow, but accurate box for the Shape.
Returns:
Name | Type | Description |
---|---|---|
Box |
Bounding box |
Source code in src/occwl/base.py
577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 |
|
faces()
Get an iterator to go over all faces in the Shape
Returns:
Type | Description |
---|---|
Iterator[occwl.face.Face]: Face iterator |
Source code in src/occwl/base.py
165 166 167 168 169 170 171 172 173 |
|
faces_from_edge(edge)
Get an iterator to go over the faces adjacent to an edge
Parameters:
Name | Type | Description | Default |
---|---|---|---|
edge
|
Edge
|
Input edge |
required |
Returns:
Type | Description |
---|---|
Iterator[occwl.face.Face]: Face iterator |
Source code in src/occwl/base.py
317 318 319 320 321 322 323 324 325 326 327 328 329 330 |
|
faces_from_vertex(vertex)
Get an iterator to go over the faces adjacent to a vertex
Parameters:
Name | Type | Description | Default |
---|---|---|---|
edge
|
Vertex
|
Input vertex |
required |
Returns:
Type | Description |
---|---|
Iterator[occwl.face.Face]: Face iterator |
Source code in src/occwl/base.py
332 333 334 335 336 337 338 339 340 341 342 343 344 345 |
|
find_closest_edge_slow(datum)
Find the closest edge to the given datum point. The function is for testing only. It will be slow as it loops over all edges in the Shape. A quick way to find the closest entity is to call Shape.find_closest_point_data(), but then you may get a face, edge or vertex back.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
datum
|
ndarray or tuple
|
3D datum point |
required |
Returns:
Name | Type | Description |
---|---|---|
Face |
The closest face in the Shape |
Source code in src/occwl/base.py
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 |
|
find_closest_face_slow(datum)
Find the closest face to the given datum point. The function is for testing only. It will be slow as it loops over all faces in the Shape. A quick way to find the closest entity is to call Shape.find_closest_point_data(), but then you may get a face, edge or vertex back.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
datum
|
ndarray or tuple
|
3D datum point |
required |
Returns:
Name | Type | Description |
---|---|---|
Face |
The closest face in the Shape |
Source code in src/occwl/base.py
220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 |
|
find_closest_point_data(datum)
Find the information about the closest point on this shape
Parameters:
Name | Type | Description | Default |
---|---|---|---|
datum
|
ndarray
|
3D Point |
required |
Returns:
Name | Type | Description |
---|---|---|
ClosestPointData |
Data about the closest point on this shape |
|
None |
if error |
Source code in src/occwl/shape.py
251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 |
|
get_triangles(triangle_face_tol=0.01, tol_relative_to_face=True, angle_tol_rads=0.1)
Compute and get the tessellation of the entire shape
Parameters:
Name | Type | Description | Default |
---|---|---|---|
triangle_face_tol
|
float
|
Toelrance between triangle and surface. Defaults to 0.01. |
0.01
|
tol_relative_to_face
|
bool
|
Whether tolerance is relative to face size |
True
|
angle_tol_rads
|
float
|
Angle tolerance in radians. Defaults to 0.1. |
0.1
|
Returns:
Type | Description |
---|---|
2D np.ndarray (float): Vertices or None if triangulation failed |
|
2D np.ndarray (int): Faces or None if triangulation failed |
Source code in src/occwl/base.py
451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 |
|
make_by_sewing_faces(faces)
staticmethod
Make a shell by sewing a set of faces with overlapping edges
Parameters:
Name | Type | Description | Default |
---|---|---|---|
faces
|
List[Face]
|
List of faces |
required |
Returns:
Type | Description |
---|---|
Shell or None: Sewed shell or None if the output was not a Shell |
Source code in src/occwl/shell.py
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
|
num_edges()
Number of edges in the Shape
Returns:
Name | Type | Description |
---|---|---|
int |
Number of edges |
Source code in src/occwl/base.py
50 51 52 53 54 55 56 57 |
|
num_faces()
Number of faces in the Shape
Returns:
Name | Type | Description |
---|---|---|
int |
Number of faces |
Source code in src/occwl/base.py
156 157 158 159 160 161 162 163 |
|
num_vertices()
Number of vertices in the Shape
Returns:
Name | Type | Description |
---|---|---|
int |
Number of vertices |
Source code in src/occwl/base.py
25 26 27 28 29 30 31 32 |
|
num_wires()
Number of wires in the Shape
Returns:
Name | Type | Description |
---|---|---|
int |
Number of wires |
Source code in src/occwl/base.py
131 132 133 134 135 136 137 138 |
|
occwl_shape(topods_shape)
staticmethod
Static method to create an occwl shape of the appropriate class from the given topods_shape Args: topods_shape (OCC.Core.TopoDS.TopoDS_Vertex/Edge/Face/Wire/Shell/Solid): TopoDS shape
Returns:
Type | Description |
---|---|
One of occwl.compound.Compound occwl.solid.Solid occwl.face.Face occwl.edge.Edge occwl.vertex.Vertex occwl.wire.Wire occwl.shell.Shell |
Raises: Exception: [description]
Source code in src/occwl/shape.py
89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 |
|
reversed()
Whether this shape is reversed.
- For an edge this is whether the edge is reversed with respect to the curve geometry
- For a face this is whether the face is reversed with respect to the surface geometry
- For a vertex this is whether the vertex is at the upper or lower parameter value on the edges curve
Returns:
Name | Type | Description |
---|---|---|
bool |
If rational |
Source code in src/occwl/shape.py
236 237 238 239 240 241 242 243 244 245 246 247 248 |
|
rotate_axis_angle(axis, angle_radians, origin=np.zeros(3, dtype=(np.float32)))
Rotate the shape about the given axis by the given angle in radians
Parameters:
Name | Type | Description | Default |
---|---|---|---|
axis
|
ndarray
|
Rotation axis |
required |
angle_radians
|
float
|
Angle in radians |
required |
Source code in src/occwl/shape.py
285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 |
|
rotate_euler_angles(angles_xyz_radians)
Rotate the shape by the given Euler angles in radians
Parameters:
Name | Type | Description | Default |
---|---|---|---|
angle_xyz_radians
|
ndarray
|
3D array with angles to rotate about x-axis, y-axis and z-axis respectively in radians |
required |
Source code in src/occwl/shape.py
302 303 304 305 306 307 308 309 310 311 312 313 314 315 |
|
save_shapes_to_occ_native(filename, shapes, with_triangles=False, with_normals=False, format_version=None)
staticmethod
Save this shape into a native OCC binary .brep file.
Saving to and loading from the native file format
is between one and two orders of magnitude faster than loading from STEP, so it is recommended for large scale data processing
Parameters:
Name | Type | Description | Default |
---|---|---|---|
filename
|
str or Path
|
.brep filename |
required |
with_triangles
|
bool
|
Whether to save triangle data cached in the shape. |
False
|
with_normals
|
bool
|
Whether to save vertex normals cached in the shape |
False
|
format_version
|
int
|
Use None to save to the latest version 1 - first revision 2 - added storing of CurveOnSurface UV Points 3 - [OCCT 7.6] added storing of per-vertex normal information and dropped storing of CurveOnSurface UV Points |
None
|
Source code in src/occwl/shape.py
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 |
|
save_to_occ_native(filename, verbosity=False, with_triangles=False, with_normals=False, format_version=None)
Save this shape into a native OCC binary .brep file.
Saving to and loading from the native file format
is between one and two orders of magnitude faster than loading from STEP, so it is recommended for large scale data processing
Parameters:
Name | Type | Description | Default |
---|---|---|---|
filename
|
str or Path
|
.brep filename |
required |
with_triangles
|
bool
|
Whether to save triangle data cached in the shape. |
False
|
with_normals
|
bool
|
Whether to save vertex normals cached in the shape |
False
|
format_version
|
int
|
Use None to save to the latest version 1 - first revision 2 - added storing of CurveOnSurface UV Points 3 - [OCCT 7.6] added storing of per-vertex normal information and dropped storing of CurveOnSurface UV Points |
None
|
Source code in src/occwl/shape.py
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 |
|
scale(scale_vector)
Scale the shape by the given 3D vector
Parameters:
Name | Type | Description | Default |
---|---|---|---|
scale_vector
|
ndarray
|
3D array with scales to resize the shape along the x-axis, y-axis and z-axis respectively |
required |
Source code in src/occwl/shape.py
317 318 319 320 321 322 323 324 325 326 |
|
scale_to_box(box_side, copy=True)
Translate and scale the Shape so it fits exactly into the [-box_side, box_side]^3 box
Returns:
Type | Description |
---|---|
occwl..: The scaled version of this Shape |
Source code in src/occwl/base.py
594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 |
|
scale_to_unit_box(copy=True)
Translate and scale the Shape so it fits exactly into the [-1, 1]^3 box
Returns: The scaled version of this shape
Source code in src/occwl/base.py
628 629 630 631 632 633 634 635 636 637 638 639 640 641 |
|
set_transform_to_identity()
When an assembly is loaded from a STEP file the solids will be transformed relative to their local coordinate system. i.e. they are placed in the assembly root components coordinate system.
When working with individual bodies you often want them to be axis aligned, in which case you want to remove the assembly transform. This function removes it for you.
If however you want to bake the transform into the bodies and suppress the asserts from parts of occwl which don't cope with transforms then use the transform() function below with copy=True
Source code in src/occwl/shape.py
346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 |
|
split_all_closed_edges(max_tol=0.01, precision=0.01, num_splits=1)
Split all the closed edges in this shape
Parameters:
Name | Type | Description | Default |
---|---|---|---|
max_tol
|
float
|
Maximum tolerance allowed. Defaults to 0.01. |
0.01
|
precision
|
float
|
Precision of the tool when splitting. Defaults to 0.01. |
0.01
|
num_splits
|
int
|
Number of splits to perform. Each split edge will result in num_splits + 1 edges. Defaults to 1. |
1
|
Returns:
Type | Description |
---|---|
occwl..: Shape with closed edges split |
Source code in src/occwl/base.py
101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 |
|
split_all_closed_faces(max_tol=0.01, precision=0.01, num_splits=1)
Split all the closed faces in this shape
Parameters:
Name | Type | Description | Default |
---|---|---|---|
max_tol
|
float
|
Maximum tolerance allowed. Defaults to 0.01. |
0.01
|
precision
|
float
|
Precision of the tool when splitting. Defaults to 0.01. |
0.01
|
num_splits
|
int
|
Number of splits to perform. Each split face will result in num_splits + 1 faces. Defaults to 1. |
1
|
Returns:
Type | Description |
---|---|
occwl..: Shape with closed faces split |
Source code in src/occwl/base.py
237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 |
|
topods_shape()
Get the underlying OCC shape
Returns:
Type | Description |
---|---|
OCC.Core.TopoDS.TopoDS_Vertex/Edge/Face/Wire/Shell/Solid: OCC TopoDS_* |
Source code in src/occwl/shape.py
80 81 82 83 84 85 86 87 |
|
transform(a, copy=True)
Apply the given 3x4 transform matrix to the solid.
copy (bool) True - Copy entities and apply the transform to
the underlying geometry
False - Apply the transform to the topods Locator
if possible
Source code in src/occwl/shape.py
400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 |
|
translate(offset)
Translate the shape by an offset vector
Parameters:
Name | Type | Description | Default |
---|---|---|---|
offset
|
ndarray
|
Offset vector |
required |
Source code in src/occwl/shape.py
276 277 278 279 280 281 282 283 |
|
triangulate(triangle_face_tol=0.01, tol_relative_to_face=True, angle_tol_rads=0.1)
Triangulate all the faces in the shape. You can then get the triangles from each face separately using face.get_triangles(). If you wanted triangles for the entire shape then call shape.get_triangles() below. For more details see https://old.opencascade.com/doc/occt-7.1.0/overview/html/occt_user_guides__modeling_algos.html#occt_modalg_11
Parameters:
Name | Type | Description | Default |
---|---|---|---|
triangle_face_tol
|
float
|
Tolerance between triangle and surface. Defaults to 0.01. |
0.01
|
tol_relative_to_face
|
bool
|
Whether tolerance is relative to face size |
True
|
angle_tol_rads
|
float
|
Angle tolerance in radians. Defaults to 0.1. |
0.1
|
Returns:
Name | Type | Description |
---|---|---|
bool |
Is successful |
Source code in src/occwl/base.py
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 |
|
valid(return_analyzer=False)
Check if the shape is valid
Parameters:
Name | Type | Description | Default |
---|---|---|---|
return_analyzer
|
bool
|
Whether to return the BRepCheck_Analyzer object for more inspection |
False
|
Returns:
Name | Type | Description |
---|---|---|
bool |
Whether the shape is valid |
|
BRepCheck_Analyzer [optional]: if return_analyzer is True |
Source code in src/occwl/shape.py
328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 |
|
vertices()
Get an iterator to go over all vertices in the Shape
Returns:
Type | Description |
---|---|
Iterator[occwl.vertex.Vertex]: Vertex iterator |
Source code in src/occwl/base.py
34 35 36 37 38 39 40 41 42 |
|
vertices_from_edge(edge)
Get an iterator to go over the vertices bounding an edge
Parameters:
Name | Type | Description | Default |
---|---|---|---|
edge
|
Edge
|
Input edge |
required |
Returns:
Type | Description |
---|---|
Iterator[occwl.vertex.Vertex]: Vertex iterator |
Source code in src/occwl/base.py
69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
|
vertices_from_face(face)
Get an iterator to go over the vertices in a face
Parameters:
Name | Type | Description | Default |
---|---|---|---|
face
|
Face
|
Input face |
required |
Returns:
Type | Description |
---|---|
Iterator[occwl.vertex.Vertex]: Vertex iterator |
Source code in src/occwl/base.py
175 176 177 178 179 180 181 182 183 184 185 186 187 188 |
|
wires()
Get an iterator to go over all wires in the Shape
Returns:
Type | Description |
---|---|
Iterator[occwl.wire.Wire]: Wire iterator |
Source code in src/occwl/base.py
140 141 142 143 144 145 146 147 148 |
|
wires_from_face(face)
Get an iterator to go over the wires bounding a face
Parameters:
Name | Type | Description | Default |
---|---|---|---|
face
|
Face
|
Input face |
required |
Returns:
Type | Description |
---|---|
Iterator[occwl.wire.Wire]: Wire iterator |
Source code in src/occwl/base.py
205 206 207 208 209 210 211 212 213 214 215 216 217 218 |
|
solid
Solid
Bases: Shape
, VertexContainerMixin
, EdgeContainerMixin
, ShellContainerMixin
, WireContainerMixin
, FaceContainerMixin
, BottomUpFaceIterator
, BottomUpEdgeIterator
, SurfacePropertiesMixin
, VolumePropertiesMixin
, BoundingBoxMixin
, TriangulatorMixin
A solid model
Source code in src/occwl/solid.py
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 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 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 |
|
__eq__(other)
Equality check for the shape
NOTE: This function only checks if the shape is the same. It doesn't check the edge orienation for example, so
edge1 == edge2
does not necessarily mean
edge1.reversed() == edge2.reversed()
Source code in src/occwl/shape.py
144 145 146 147 148 149 150 151 152 153 154 155 156 157 |
|
__hash__()
Hash for the shape
Returns:
Name | Type | Description |
---|---|---|
int |
Hash value |
Source code in src/occwl/shape.py
135 136 137 138 139 140 141 142 |
|
area()
Compute the area of the Shape
Returns:
Name | Type | Description |
---|---|---|
float |
Area |
Source code in src/occwl/base.py
493 494 495 496 497 498 499 500 501 502 |
|
box()
Get a quick bounding box of the Shape
Returns:
Name | Type | Description |
---|---|---|
Box |
Bounding box |
Source code in src/occwl/base.py
565 566 567 568 569 570 571 572 573 574 575 |
|
center_of_mass(tolerance=1e-09)
Compute the center of mass of the Shape
Parameters:
Name | Type | Description | Default |
---|---|---|---|
tolerance
|
float
|
Tolerance. Defaults to 1e-9. |
1e-09
|
Returns:
Type | Description |
---|---|
np.ndarray: 3D point |
Source code in src/occwl/base.py
523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 |
|
convert_geometric_identity_transforms_to_identity()
Open Cascade models sometimes contain transforms which are "geometrically" identify transforms, but the identity flag is not set.
This function checks each transform and sets the flag if the appropriate.
Source code in src/occwl/shape.py
371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 |
|
edge_continuity(edge)
Get the neighboring faces' continuity at given edge
Parameters:
Name | Type | Description | Default |
---|---|---|---|
edge
|
Edge
|
Edge |
required |
Returns:
Name | Type | Description |
---|---|---|
GeomAbs_Shape |
enum describing the continuity order |
Source code in src/occwl/base.py
347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 |
|
edges()
Get an iterator to go over all edges in the Shape
Returns:
Type | Description |
---|---|
Iterator[occwl.edge.Edge]: Edge iterator |
Source code in src/occwl/base.py
59 60 61 62 63 64 65 66 67 |
|
edges_from_face(face)
Get an iterator to go over the edges in a face
Parameters:
Name | Type | Description | Default |
---|---|---|---|
face
|
Face
|
Input face |
required |
Returns:
Type | Description |
---|---|
Iterator[occwl.edge.Edge]: Edge iterator |
Source code in src/occwl/base.py
190 191 192 193 194 195 196 197 198 199 200 201 202 203 |
|
edges_from_vertex(vertex)
Get an iterator to go over the edges adjacent to a vertex
Parameters:
Name | Type | Description | Default |
---|---|---|---|
face
|
Face
|
Input face |
required |
Returns:
Type | Description |
---|---|
Iterator[occwl.edge.Edge]: Edge iterator |
Source code in src/occwl/base.py
386 387 388 389 390 391 392 393 394 395 396 397 398 399 |
|
exact_box(use_shapetolerance=False)
Get a slow, but accurate box for the Shape.
Returns:
Name | Type | Description |
---|---|---|
Box |
Bounding box |
Source code in src/occwl/base.py
577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 |
|
faces()
Get an iterator to go over all faces in the Shape
Returns:
Type | Description |
---|---|
Iterator[occwl.face.Face]: Face iterator |
Source code in src/occwl/base.py
165 166 167 168 169 170 171 172 173 |
|
faces_from_edge(edge)
Get an iterator to go over the faces adjacent to an edge
Parameters:
Name | Type | Description | Default |
---|---|---|---|
edge
|
Edge
|
Input edge |
required |
Returns:
Type | Description |
---|---|
Iterator[occwl.face.Face]: Face iterator |
Source code in src/occwl/base.py
317 318 319 320 321 322 323 324 325 326 327 328 329 330 |
|
faces_from_vertex(vertex)
Get an iterator to go over the faces adjacent to a vertex
Parameters:
Name | Type | Description | Default |
---|---|---|---|
edge
|
Vertex
|
Input vertex |
required |
Returns:
Type | Description |
---|---|
Iterator[occwl.face.Face]: Face iterator |
Source code in src/occwl/base.py
332 333 334 335 336 337 338 339 340 341 342 343 344 345 |
|
find_closest_edge_slow(datum)
Find the closest edge to the given datum point. The function is for testing only. It will be slow as it loops over all edges in the Shape. A quick way to find the closest entity is to call Shape.find_closest_point_data(), but then you may get a face, edge or vertex back.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
datum
|
ndarray or tuple
|
3D datum point |
required |
Returns:
Name | Type | Description |
---|---|---|
Face |
The closest face in the Shape |
Source code in src/occwl/base.py
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 |
|
find_closest_face_slow(datum)
Find the closest face to the given datum point. The function is for testing only. It will be slow as it loops over all faces in the Shape. A quick way to find the closest entity is to call Shape.find_closest_point_data(), but then you may get a face, edge or vertex back.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
datum
|
ndarray or tuple
|
3D datum point |
required |
Returns:
Name | Type | Description |
---|---|---|
Face |
The closest face in the Shape |
Source code in src/occwl/base.py
220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 |
|
find_closest_point_data(datum)
Find the information about the closest point on this shape
Parameters:
Name | Type | Description | Default |
---|---|---|---|
datum
|
ndarray
|
3D Point |
required |
Returns:
Name | Type | Description |
---|---|---|
ClosestPointData |
Data about the closest point on this shape |
|
None |
if error |
Source code in src/occwl/shape.py
251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 |
|
get_triangles(triangle_face_tol=0.01, tol_relative_to_face=True, angle_tol_rads=0.1)
Compute and get the tessellation of the entire shape
Parameters:
Name | Type | Description | Default |
---|---|---|---|
triangle_face_tol
|
float
|
Toelrance between triangle and surface. Defaults to 0.01. |
0.01
|
tol_relative_to_face
|
bool
|
Whether tolerance is relative to face size |
True
|
angle_tol_rads
|
float
|
Angle tolerance in radians. Defaults to 0.1. |
0.1
|
Returns:
Type | Description |
---|---|
2D np.ndarray (float): Vertices or None if triangulation failed |
|
2D np.ndarray (int): Faces or None if triangulation failed |
Source code in src/occwl/base.py
451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 |
|
is_closed()
Checks and returns if the solid is closed (has no holes)
Returns:
Name | Type | Description |
---|---|---|
bool |
If closed |
Source code in src/occwl/solid.py
100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 |
|
moment_of_inertia(point, direction, tolerance=1e-09)
Compute the moment of inertia about an axis
Parameters:
Name | Type | Description | Default |
---|---|---|---|
point
|
ndarray
|
3D point (origin of the axis) |
required |
direction
|
ndarray
|
3D direction of the axis |
required |
tolerance
|
float
|
Tolerance. Defaults to 1e-9. |
1e-09
|
Returns:
Name | Type | Description |
---|---|---|
float |
Moment of inertia |
Source code in src/occwl/base.py
539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 |
|
num_edges()
Number of edges in the Shape
Returns:
Name | Type | Description |
---|---|---|
int |
Number of edges |
Source code in src/occwl/base.py
50 51 52 53 54 55 56 57 |
|
num_faces()
Number of faces in the Shape
Returns:
Name | Type | Description |
---|---|---|
int |
Number of faces |
Source code in src/occwl/base.py
156 157 158 159 160 161 162 163 |
|
num_shells()
Number of shells in the Shape
Returns:
Name | Type | Description |
---|---|---|
int |
Number of shells |
Source code in src/occwl/base.py
267 268 269 270 271 272 273 274 |
|
num_vertices()
Number of vertices in the Shape
Returns:
Name | Type | Description |
---|---|---|
int |
Number of vertices |
Source code in src/occwl/base.py
25 26 27 28 29 30 31 32 |
|
num_wires()
Number of wires in the Shape
Returns:
Name | Type | Description |
---|---|---|
int |
Number of wires |
Source code in src/occwl/base.py
131 132 133 134 135 136 137 138 |
|
occwl_shape(topods_shape)
staticmethod
Static method to create an occwl shape of the appropriate class from the given topods_shape Args: topods_shape (OCC.Core.TopoDS.TopoDS_Vertex/Edge/Face/Wire/Shell/Solid): TopoDS shape
Returns:
Type | Description |
---|---|
One of occwl.compound.Compound occwl.solid.Solid occwl.face.Face occwl.edge.Edge occwl.vertex.Vertex occwl.wire.Wire occwl.shell.Shell |
Raises: Exception: [description]
Source code in src/occwl/shape.py
89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 |
|
reversed()
Whether this shape is reversed.
- For an edge this is whether the edge is reversed with respect to the curve geometry
- For a face this is whether the face is reversed with respect to the surface geometry
- For a vertex this is whether the vertex is at the upper or lower parameter value on the edges curve
Returns:
Name | Type | Description |
---|---|---|
bool |
If rational |
Source code in src/occwl/shape.py
236 237 238 239 240 241 242 243 244 245 246 247 248 |
|
rotate_axis_angle(axis, angle_radians, origin=np.zeros(3, dtype=(np.float32)))
Rotate the shape about the given axis by the given angle in radians
Parameters:
Name | Type | Description | Default |
---|---|---|---|
axis
|
ndarray
|
Rotation axis |
required |
angle_radians
|
float
|
Angle in radians |
required |
Source code in src/occwl/shape.py
285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 |
|
rotate_euler_angles(angles_xyz_radians)
Rotate the shape by the given Euler angles in radians
Parameters:
Name | Type | Description | Default |
---|---|---|---|
angle_xyz_radians
|
ndarray
|
3D array with angles to rotate about x-axis, y-axis and z-axis respectively in radians |
required |
Source code in src/occwl/shape.py
302 303 304 305 306 307 308 309 310 311 312 313 314 315 |
|
save_shapes_to_occ_native(filename, shapes, with_triangles=False, with_normals=False, format_version=None)
staticmethod
Save this shape into a native OCC binary .brep file.
Saving to and loading from the native file format
is between one and two orders of magnitude faster than loading from STEP, so it is recommended for large scale data processing
Parameters:
Name | Type | Description | Default |
---|---|---|---|
filename
|
str or Path
|
.brep filename |
required |
with_triangles
|
bool
|
Whether to save triangle data cached in the shape. |
False
|
with_normals
|
bool
|
Whether to save vertex normals cached in the shape |
False
|
format_version
|
int
|
Use None to save to the latest version 1 - first revision 2 - added storing of CurveOnSurface UV Points 3 - [OCCT 7.6] added storing of per-vertex normal information and dropped storing of CurveOnSurface UV Points |
None
|
Source code in src/occwl/shape.py
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 |
|
save_to_occ_native(filename, verbosity=False, with_triangles=False, with_normals=False, format_version=None)
Save this shape into a native OCC binary .brep file.
Saving to and loading from the native file format
is between one and two orders of magnitude faster than loading from STEP, so it is recommended for large scale data processing
Parameters:
Name | Type | Description | Default |
---|---|---|---|
filename
|
str or Path
|
.brep filename |
required |
with_triangles
|
bool
|
Whether to save triangle data cached in the shape. |
False
|
with_normals
|
bool
|
Whether to save vertex normals cached in the shape |
False
|
format_version
|
int
|
Use None to save to the latest version 1 - first revision 2 - added storing of CurveOnSurface UV Points 3 - [OCCT 7.6] added storing of per-vertex normal information and dropped storing of CurveOnSurface UV Points |
None
|
Source code in src/occwl/shape.py
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 |
|
scale(scale_vector)
Scale the shape by the given 3D vector
Parameters:
Name | Type | Description | Default |
---|---|---|---|
scale_vector
|
ndarray
|
3D array with scales to resize the shape along the x-axis, y-axis and z-axis respectively |
required |
Source code in src/occwl/shape.py
317 318 319 320 321 322 323 324 325 326 |
|
scale_to_box(box_side, copy=True)
Translate and scale the Shape so it fits exactly into the [-box_side, box_side]^3 box
Returns:
Type | Description |
---|---|
occwl..: The scaled version of this Shape |
Source code in src/occwl/base.py
594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 |
|
scale_to_unit_box(copy=True)
Translate and scale the Shape so it fits exactly into the [-1, 1]^3 box
Returns: The scaled version of this shape
Source code in src/occwl/base.py
628 629 630 631 632 633 634 635 636 637 638 639 640 641 |
|
set_transform_to_identity()
When an assembly is loaded from a STEP file the solids will be transformed relative to their local coordinate system. i.e. they are placed in the assembly root components coordinate system.
When working with individual bodies you often want them to be axis aligned, in which case you want to remove the assembly transform. This function removes it for you.
If however you want to bake the transform into the bodies and suppress the asserts from parts of occwl which don't cope with transforms then use the transform() function below with copy=True
Source code in src/occwl/shape.py
346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 |
|
shells()
Get an iterator to go over all shells in the Shape
Returns:
Type | Description |
---|---|
Iterator[occwl.shell.Shell]: Shell iterator |
Source code in src/occwl/base.py
276 277 278 279 280 281 282 283 284 |
|
split_all_closed_edges(max_tol=0.01, precision=0.01, num_splits=1)
Split all the closed edges in this shape
Parameters:
Name | Type | Description | Default |
---|---|---|---|
max_tol
|
float
|
Maximum tolerance allowed. Defaults to 0.01. |
0.01
|
precision
|
float
|
Precision of the tool when splitting. Defaults to 0.01. |
0.01
|
num_splits
|
int
|
Number of splits to perform. Each split edge will result in num_splits + 1 edges. Defaults to 1. |
1
|
Returns:
Type | Description |
---|---|
occwl..: Shape with closed edges split |
Source code in src/occwl/base.py
101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 |
|
split_all_closed_faces(max_tol=0.01, precision=0.01, num_splits=1)
Split all the closed faces in this shape
Parameters:
Name | Type | Description | Default |
---|---|---|---|
max_tol
|
float
|
Maximum tolerance allowed. Defaults to 0.01. |
0.01
|
precision
|
float
|
Precision of the tool when splitting. Defaults to 0.01. |
0.01
|
num_splits
|
int
|
Number of splits to perform. Each split face will result in num_splits + 1 faces. Defaults to 1. |
1
|
Returns:
Type | Description |
---|---|
occwl..: Shape with closed faces split |
Source code in src/occwl/base.py
237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 |
|
topods_shape()
Get the underlying OCC shape
Returns:
Type | Description |
---|---|
OCC.Core.TopoDS.TopoDS_Vertex/Edge/Face/Wire/Shell/Solid: OCC TopoDS_* |
Source code in src/occwl/shape.py
80 81 82 83 84 85 86 87 |
|
transform(a, copy=True)
Apply the given 3x4 transform matrix to the solid.
copy (bool) True - Copy entities and apply the transform to
the underlying geometry
False - Apply the transform to the topods Locator
if possible
Source code in src/occwl/shape.py
400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 |
|
translate(offset)
Translate the shape by an offset vector
Parameters:
Name | Type | Description | Default |
---|---|---|---|
offset
|
ndarray
|
Offset vector |
required |
Source code in src/occwl/shape.py
276 277 278 279 280 281 282 283 |
|
triangulate(triangle_face_tol=0.01, tol_relative_to_face=True, angle_tol_rads=0.1)
Triangulate all the faces in the shape. You can then get the triangles from each face separately using face.get_triangles(). If you wanted triangles for the entire shape then call shape.get_triangles() below. For more details see https://old.opencascade.com/doc/occt-7.1.0/overview/html/occt_user_guides__modeling_algos.html#occt_modalg_11
Parameters:
Name | Type | Description | Default |
---|---|---|---|
triangle_face_tol
|
float
|
Tolerance between triangle and surface. Defaults to 0.01. |
0.01
|
tol_relative_to_face
|
bool
|
Whether tolerance is relative to face size |
True
|
angle_tol_rads
|
float
|
Angle tolerance in radians. Defaults to 0.1. |
0.1
|
Returns:
Name | Type | Description |
---|---|---|
bool |
Is successful |
Source code in src/occwl/base.py
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 |
|
valid(return_analyzer=False)
Check if the shape is valid
Parameters:
Name | Type | Description | Default |
---|---|---|---|
return_analyzer
|
bool
|
Whether to return the BRepCheck_Analyzer object for more inspection |
False
|
Returns:
Name | Type | Description |
---|---|---|
bool |
Whether the shape is valid |
|
BRepCheck_Analyzer [optional]: if return_analyzer is True |
Source code in src/occwl/shape.py
328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 |
|
vertices()
Get an iterator to go over all vertices in the Shape
Returns:
Type | Description |
---|---|
Iterator[occwl.vertex.Vertex]: Vertex iterator |
Source code in src/occwl/base.py
34 35 36 37 38 39 40 41 42 |
|
vertices_from_edge(edge)
Get an iterator to go over the vertices bounding an edge
Parameters:
Name | Type | Description | Default |
---|---|---|---|
edge
|
Edge
|
Input edge |
required |
Returns:
Type | Description |
---|---|
Iterator[occwl.vertex.Vertex]: Vertex iterator |
Source code in src/occwl/base.py
69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
|
vertices_from_face(face)
Get an iterator to go over the vertices in a face
Parameters:
Name | Type | Description | Default |
---|---|---|---|
face
|
Face
|
Input face |
required |
Returns:
Type | Description |
---|---|
Iterator[occwl.vertex.Vertex]: Vertex iterator |
Source code in src/occwl/base.py
175 176 177 178 179 180 181 182 183 184 185 186 187 188 |
|
volume(tolerance=1e-09)
Compute the volume of the Shape
Parameters:
Name | Type | Description | Default |
---|---|---|---|
tolerance
|
float
|
Tolerance. Defaults to 1e-9. |
1e-09
|
Returns:
Name | Type | Description |
---|---|---|
float |
Volume |
Source code in src/occwl/base.py
509 510 511 512 513 514 515 516 517 518 519 520 521 |
|
wires()
Get an iterator to go over all wires in the Shape
Returns:
Type | Description |
---|---|
Iterator[occwl.wire.Wire]: Wire iterator |
Source code in src/occwl/base.py
140 141 142 143 144 145 146 147 148 |
|
wires_from_face(face)
Get an iterator to go over the wires bounding a face
Parameters:
Name | Type | Description | Default |
---|---|---|---|
face
|
Face
|
Input face |
required |
Returns:
Type | Description |
---|---|
Iterator[occwl.wire.Wire]: Wire iterator |
Source code in src/occwl/base.py
205 206 207 208 209 210 211 212 213 214 215 216 217 218 |
|
uvgrid
ugrid(edge, num_u=10, us=False, method='point', reverse_order_with_edge=True)
Creates a 1D UV-grid of samples from the given edge edge (occwl.edge.Edge): A B-rep edge num_u (int): Number of samples along the curve. Defaults to 10/ us (bool): Return the u values at which the quantity were evaluated method (str): Name of the method in the occwl.edge.Edge object to be called (the method has to accept the u value as argument). Defaults to "point". Returns: np.ndarray: 1D array of quantity evaluated on the edge geometry np.ndarray (optional): 1D array of u-values where evaluation was done
Source code in src/occwl/uvgrid.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 97 98 99 100 101 102 103 104 105 106 |
|
uvgrid(face, num_u=10, num_v=10, uvs=False, method='point', reverse_order_with_face=True)
Creates a 2D UV-grid of samples from the given face
Parameters:
Name | Type | Description | Default |
---|---|---|---|
face
|
Face
|
A B-rep face |
required |
num_u
|
int
|
Number of samples along u-direction. Defaults to 10. |
10
|
num_v
|
int
|
Number of samples along v-direction. Defaults to 10. |
10
|
uvs
|
bool
|
Return the surface UVs where quantities are evaluated. Defaults to False. |
False
|
method
|
str
|
Name of the method in the occwl.face.Face object to be called (the method has to accept the uv value as argument). Defaults to "point". |
'point'
|
Returns:
Type | Description |
---|---|
np.ndarray: 2D array of quantity evaluated on the face geometry |
|
np.ndarray (optional): 2D array of uv-values where evaluation was done |
Source code in src/occwl/uvgrid.py
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
|
vertex
Vertex
Bases: Shape
A topological vertex in a solid model Represents a 3D geometric point
Source code in src/occwl/vertex.py
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
|
__eq__(other)
Equality check for the shape
NOTE: This function only checks if the shape is the same. It doesn't check the edge orienation for example, so
edge1 == edge2
does not necessarily mean
edge1.reversed() == edge2.reversed()
Source code in src/occwl/shape.py
144 145 146 147 148 149 150 151 152 153 154 155 156 157 |
|
__hash__()
Hash for the shape
Returns:
Name | Type | Description |
---|---|---|
int |
Hash value |
Source code in src/occwl/shape.py
135 136 137 138 139 140 141 142 |
|
__init__(topods_vertex)
Constructor to initialize a vertex from a TodoDS_Vertex
Parameters:
Name | Type | Description | Default |
---|---|---|---|
topods_vertex
|
TopoDS_Vertex
|
OCC Vertex |
required |
Source code in src/occwl/vertex.py
18 19 20 21 22 23 24 25 26 |
|
convert_geometric_identity_transforms_to_identity()
Open Cascade models sometimes contain transforms which are "geometrically" identify transforms, but the identity flag is not set.
This function checks each transform and sets the flag if the appropriate.
Source code in src/occwl/shape.py
371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 |
|
find_closest_point_data(datum)
Find the information about the closest point on this shape
Parameters:
Name | Type | Description | Default |
---|---|---|---|
datum
|
ndarray
|
3D Point |
required |
Returns:
Name | Type | Description |
---|---|---|
ClosestPointData |
Data about the closest point on this shape |
|
None |
if error |
Source code in src/occwl/shape.py
251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 |
|
make_vertex(point)
staticmethod
Create a vertex from a 3D point
Parameters:
Name | Type | Description | Default |
---|---|---|---|
point
|
ndarray
|
3D Point |
required |
Returns:
Type | Description |
---|---|
occwl.Vertex: Vertex representing the 3D point |
Source code in src/occwl/vertex.py
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
|
occwl_shape(topods_shape)
staticmethod
Static method to create an occwl shape of the appropriate class from the given topods_shape Args: topods_shape (OCC.Core.TopoDS.TopoDS_Vertex/Edge/Face/Wire/Shell/Solid): TopoDS shape
Returns:
Type | Description |
---|---|
One of occwl.compound.Compound occwl.solid.Solid occwl.face.Face occwl.edge.Edge occwl.vertex.Vertex occwl.wire.Wire occwl.shell.Shell |
Raises: Exception: [description]
Source code in src/occwl/shape.py
89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 |
|
point()
3D point stored in this vertex
Returns:
Type | Description |
---|---|
np.ndarray: 3D Point |
Source code in src/occwl/vertex.py
44 45 46 47 48 49 50 51 52 |
|
reversed()
Whether this shape is reversed.
- For an edge this is whether the edge is reversed with respect to the curve geometry
- For a face this is whether the face is reversed with respect to the surface geometry
- For a vertex this is whether the vertex is at the upper or lower parameter value on the edges curve
Returns:
Name | Type | Description |
---|---|---|
bool |
If rational |
Source code in src/occwl/shape.py
236 237 238 239 240 241 242 243 244 245 246 247 248 |
|
rotate_axis_angle(axis, angle_radians, origin=np.zeros(3, dtype=(np.float32)))
Rotate the shape about the given axis by the given angle in radians
Parameters:
Name | Type | Description | Default |
---|---|---|---|
axis
|
ndarray
|
Rotation axis |
required |
angle_radians
|
float
|
Angle in radians |
required |
Source code in src/occwl/shape.py
285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 |
|
rotate_euler_angles(angles_xyz_radians)
Rotate the shape by the given Euler angles in radians
Parameters:
Name | Type | Description | Default |
---|---|---|---|
angle_xyz_radians
|
ndarray
|
3D array with angles to rotate about x-axis, y-axis and z-axis respectively in radians |
required |
Source code in src/occwl/shape.py
302 303 304 305 306 307 308 309 310 311 312 313 314 315 |
|
save_shapes_to_occ_native(filename, shapes, with_triangles=False, with_normals=False, format_version=None)
staticmethod
Save this shape into a native OCC binary .brep file.
Saving to and loading from the native file format
is between one and two orders of magnitude faster than loading from STEP, so it is recommended for large scale data processing
Parameters:
Name | Type | Description | Default |
---|---|---|---|
filename
|
str or Path
|
.brep filename |
required |
with_triangles
|
bool
|
Whether to save triangle data cached in the shape. |
False
|
with_normals
|
bool
|
Whether to save vertex normals cached in the shape |
False
|
format_version
|
int
|
Use None to save to the latest version 1 - first revision 2 - added storing of CurveOnSurface UV Points 3 - [OCCT 7.6] added storing of per-vertex normal information and dropped storing of CurveOnSurface UV Points |
None
|
Source code in src/occwl/shape.py
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 |
|
save_to_occ_native(filename, verbosity=False, with_triangles=False, with_normals=False, format_version=None)
Save this shape into a native OCC binary .brep file.
Saving to and loading from the native file format
is between one and two orders of magnitude faster than loading from STEP, so it is recommended for large scale data processing
Parameters:
Name | Type | Description | Default |
---|---|---|---|
filename
|
str or Path
|
.brep filename |
required |
with_triangles
|
bool
|
Whether to save triangle data cached in the shape. |
False
|
with_normals
|
bool
|
Whether to save vertex normals cached in the shape |
False
|
format_version
|
int
|
Use None to save to the latest version 1 - first revision 2 - added storing of CurveOnSurface UV Points 3 - [OCCT 7.6] added storing of per-vertex normal information and dropped storing of CurveOnSurface UV Points |
None
|
Source code in src/occwl/shape.py
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 |
|
scale(scale_vector)
Scale the shape by the given 3D vector
Parameters:
Name | Type | Description | Default |
---|---|---|---|
scale_vector
|
ndarray
|
3D array with scales to resize the shape along the x-axis, y-axis and z-axis respectively |
required |
Source code in src/occwl/shape.py
317 318 319 320 321 322 323 324 325 326 |
|
set_transform_to_identity()
When an assembly is loaded from a STEP file the solids will be transformed relative to their local coordinate system. i.e. they are placed in the assembly root components coordinate system.
When working with individual bodies you often want them to be axis aligned, in which case you want to remove the assembly transform. This function removes it for you.
If however you want to bake the transform into the bodies and suppress the asserts from parts of occwl which don't cope with transforms then use the transform() function below with copy=True
Source code in src/occwl/shape.py
346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 |
|
topods_shape()
Get the underlying OCC shape
Returns:
Type | Description |
---|---|
OCC.Core.TopoDS.TopoDS_Vertex/Edge/Face/Wire/Shell/Solid: OCC TopoDS_* |
Source code in src/occwl/shape.py
80 81 82 83 84 85 86 87 |
|
transform(a, copy=True)
Apply the given 3x4 transform matrix to the solid.
copy (bool) True - Copy entities and apply the transform to
the underlying geometry
False - Apply the transform to the topods Locator
if possible
Source code in src/occwl/shape.py
400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 |
|
translate(offset)
Translate the shape by an offset vector
Parameters:
Name | Type | Description | Default |
---|---|---|---|
offset
|
ndarray
|
Offset vector |
required |
Source code in src/occwl/shape.py
276 277 278 279 280 281 282 283 |
|
valid(return_analyzer=False)
Check if the shape is valid
Parameters:
Name | Type | Description | Default |
---|---|---|---|
return_analyzer
|
bool
|
Whether to return the BRepCheck_Analyzer object for more inspection |
False
|
Returns:
Name | Type | Description |
---|---|---|
bool |
Whether the shape is valid |
|
BRepCheck_Analyzer [optional]: if return_analyzer is True |
Source code in src/occwl/shape.py
328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 |
|
viewer
OffscreenRenderer
Bases: _BaseViewer
Offscreen renderer that doesn't create a window. Useful for batch rendering.
Source code in src/occwl/viewer.py
550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 |
|
__init__(size=(1024, 768), axes=True, background_top_color=[206, 215, 222], background_bottom_color=[128, 128, 128])
Construct the OffscreenRenderer
Parameters:
Name | Type | Description | Default |
---|---|---|---|
size
|
Optional[Tuple[int, int]]
|
Size of the viewer window. Defaults to (1024, 768). |
(1024, 768)
|
axes
|
Optional[bool]
|
Show arrows for coordinate axes. Defaults to True. |
True
|
background_top_color
|
Optional[List[int]]
|
Background color at the top. Defaults to [206, 215, 222]. |
[206, 215, 222]
|
background_bottom_color
|
Optional[List[int]]
|
Background color at the bottom. Defaults to [128, 128, 128]. |
[128, 128, 128]
|
Source code in src/occwl/viewer.py
554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 |
|
clear()
Clear all shapes from the viewer
Source code in src/occwl/viewer.py
246 247 248 249 250 |
|
disable_antialiasing()
Disable antialiasing
Source code in src/occwl/viewer.py
333 334 335 336 337 |
|
display(shape, update=False, color=None, transparency=0.0)
Display a shape (must be a Solid, Face, or Edge)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
shape
|
Solid, Face, or Edge
|
Shape to display |
required |
update
|
bool
|
Whether to update and repaint. Defaults to False. |
False
|
color
|
str or tuple
|
Color of the shape. If str, can be 'WHITE', 'BLUE', 'RED', 'GREEN', 'YELLOW', 'CYAN', 'BLACK', or 'ORANGE'. Defaults to None. |
None
|
transparency
|
float
|
How transparent the shape is. Defaults to 0.0. |
0.0
|
Source code in src/occwl/viewer.py
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 |
|
display_lines(origins, directions, color=None, thickness=1, style='solid')
Display a set of lines
Parameters:
Name | Type | Description | Default |
---|---|---|---|
origins
|
2D np.ndarray of size #points x 3
|
Origin points of the arrows |
required |
directions
|
2D np.ndarray of size #points x 3
|
Unit vectors for directions of the arrows |
required |
color
|
tuple of 3 floats or 2D np.ndarray of size #points x 3 or str
|
RGB color (can be a single color or per-point colors). Defaults to None. |
None
|
thickness
|
float
|
Thickness of the lines |
1
|
style
|
str
|
Style for the lines. Must be one of ('solid', 'dash', 'dot', 'dotdash'). Defaults to 'solid'. |
'solid'
|
Source code in src/occwl/viewer.py
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 |
|
display_points(pts, color=None, scale=10, marker='ball')
Display a set of points
Parameters:
Name | Type | Description | Default |
---|---|---|---|
points
|
ndarray
|
Points to display |
required |
color
|
tuple of 3 floats or np.ndarray of size #points x 3 or str
|
RGB color (can be a single color or per-point colors). Defaults to None. |
None
|
scale
|
float
|
Scale of the points |
10
|
marker
|
str
|
Marker type for the point. Must be one of ('point', 'star', 'ball', 'x', 'o'). Defaults to 'ball'. |
'ball'
|
Source code in src/occwl/viewer.py
113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 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 |
|
display_text(xyz, text, height=None, color=None)
Display a text
Parameters:
Name | Type | Description | Default |
---|---|---|---|
xyz
|
tuple of floats or 1D np.ndarray of 2 or 3
|
Coordinate in model space where text would appear |
required |
text
|
str
|
Text to display |
required |
height
|
float
|
Height of the text font. Defaults to None. |
None
|
color
|
tuple of 3 floats
|
RGB color. Defaults to None. |
None
|
Source code in src/occwl/viewer.py
99 100 101 102 103 104 105 106 107 108 109 110 111 |
|
enable_antialiasing()
Enable antialiasing
Source code in src/occwl/viewer.py
327 328 329 330 331 |
|
fit()
Fit the camera to the scene
Source code in src/occwl/viewer.py
252 253 254 255 256 |
|
hide_axes()
Hide the XYZ-axes widget
Source code in src/occwl/viewer.py
321 322 323 324 325 |
|
hide_face_boundary()
Hide the edges bounding each face
Source code in src/occwl/viewer.py
357 358 359 360 361 |
|
orthographic()
Set orthographic camera projection
Source code in src/occwl/viewer.py
265 266 267 268 269 270 |
|
perspective()
Set perspective camera projection
Source code in src/occwl/viewer.py
258 259 260 261 262 263 |
|
save_image(filename=None)
Save a screenshot of the viewer
Parameters:
Name | Type | Description | Default |
---|---|---|---|
filename
|
str or Path
|
Image file to save the screenshot. Defaults to None. If None, writes a PNG file named with the current timestamp |
None
|
Source code in src/occwl/viewer.py
286 287 288 289 290 291 292 293 294 295 296 297 298 |
|
selected_shapes()
Get the selected shapes
Returns:
Type | Description |
---|---|
List[TopoDS_Shape]: List of selected shapes |
Source code in src/occwl/viewer.py
235 236 237 238 239 240 241 242 243 244 |
|
set_background_color(top_color, bottom_color)
Set the background gradient color
Parameters:
Name | Type | Description | Default |
---|---|---|---|
top_color
|
List / Tuple[int, int, int]
|
Top color |
required |
bottom_color
|
List / Tuple[int, int, int]
|
Bottom color |
required |
Source code in src/occwl/viewer.py
339 340 341 342 343 344 345 346 347 348 349 |
|
set_size(width, height)
Set the size of the framebuffer
Parameters:
Name | Type | Description | Default |
---|---|---|---|
width
|
int
|
Width of the framebuffer |
required |
height
|
int
|
Height of the framebuffer |
required |
Source code in src/occwl/viewer.py
363 364 365 366 367 368 369 370 371 |
|
shaded()
Shade all shapes
Source code in src/occwl/viewer.py
279 280 281 282 283 284 |
|
show_axes()
Show the XYZ-axes widget
Source code in src/occwl/viewer.py
315 316 317 318 319 |
|
show_face_boundary()
Show the edges bounding each face
Source code in src/occwl/viewer.py
351 352 353 354 355 |
|
use_flat_shading()
Use no interpolation when computing color for fragments in a triangle
Source code in src/occwl/viewer.py
379 380 381 382 383 |
|
use_gouraud_shading()
Compute colors per vertex and interpolate
Source code in src/occwl/viewer.py
373 374 375 376 377 |
|
use_phong_shading()
Compute colors per fragment
Source code in src/occwl/viewer.py
385 386 387 388 389 |
|
use_rasterization()
Render using rasterization
Source code in src/occwl/viewer.py
300 301 302 303 304 |
|
use_raytracing(depth=3)
Render using raytracing
Parameters:
Name | Type | Description | Default |
---|---|---|---|
depth
|
int
|
Number of bounces for rays Defaults to 3. |
3
|
Source code in src/occwl/viewer.py
306 307 308 309 310 311 312 313 |
|
wireframe()
Set all shapes to appear as wireframes
Source code in src/occwl/viewer.py
272 273 274 275 276 277 |
|
Viewer
Bases: _BaseViewer
A Viewer for topological entities
Source code in src/occwl/viewer.py
402 403 404 405 406 407 408 409 410 411 412 413 414 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 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 |
|
__init__(backend=None, size=(1024, 768), axes=True, background_gradient_color1=[206, 215, 222], background_gradient_color2=[128, 128, 128])
Construct the Viewer
Parameters:
Name | Type | Description | Default |
---|---|---|---|
backend
|
str
|
Backend use to create the viewer. Must be one of wx, pyqt4, pyqt5 or pyside. Defaults to None. |
None
|
size
|
Optional[Tuple[int, int]]
|
Size of the viewer window. Defaults to (1024, 768). |
(1024, 768)
|
axes
|
Optional[bool]
|
Show arrows for coordinate axes. Defaults to True. |
True
|
background_gradient_color1
|
Optional[List[int]]
|
Background color at the top. Defaults to [206, 215, 222]. |
[206, 215, 222]
|
background_gradient_color2
|
Optional[List[int]]
|
Background color at the bottom. Defaults to [128, 128, 128]. |
[128, 128, 128]
|
Source code in src/occwl/viewer.py
407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 |
|
add_menu(name)
Add a custom menu to the viewer
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name
|
str
|
Name of the menu |
required |
Source code in src/occwl/viewer.py
486 487 488 489 490 491 492 493 |
|
add_submenu(menu, callback)
Add a sub-menu to an existing menu
Parameters:
Name | Type | Description | Default |
---|---|---|---|
menu
|
str
|
Name of the menu |
required |
callback
|
function
|
Function to be added as a sub-menu. The name of the function will appear under menu. |
required |
Source code in src/occwl/viewer.py
495 496 497 498 499 500 501 502 503 |
|
clear()
Clear all shapes from the viewer
Source code in src/occwl/viewer.py
246 247 248 249 250 |
|
disable_antialiasing()
Disable antialiasing
Source code in src/occwl/viewer.py
333 334 335 336 337 |
|
display(shape, update=False, color=None, transparency=0.0)
Display a shape (must be a Solid, Face, or Edge)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
shape
|
Solid, Face, or Edge
|
Shape to display |
required |
update
|
bool
|
Whether to update and repaint. Defaults to False. |
False
|
color
|
str or tuple
|
Color of the shape. If str, can be 'WHITE', 'BLUE', 'RED', 'GREEN', 'YELLOW', 'CYAN', 'BLACK', or 'ORANGE'. Defaults to None. |
None
|
transparency
|
float
|
How transparent the shape is. Defaults to 0.0. |
0.0
|
Source code in src/occwl/viewer.py
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 |
|
display_lines(origins, directions, color=None, thickness=1, style='solid')
Display a set of lines
Parameters:
Name | Type | Description | Default |
---|---|---|---|
origins
|
2D np.ndarray of size #points x 3
|
Origin points of the arrows |
required |
directions
|
2D np.ndarray of size #points x 3
|
Unit vectors for directions of the arrows |
required |
color
|
tuple of 3 floats or 2D np.ndarray of size #points x 3 or str
|
RGB color (can be a single color or per-point colors). Defaults to None. |
None
|
thickness
|
float
|
Thickness of the lines |
1
|
style
|
str
|
Style for the lines. Must be one of ('solid', 'dash', 'dot', 'dotdash'). Defaults to 'solid'. |
'solid'
|
Source code in src/occwl/viewer.py
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 |
|
display_points(pts, color=None, scale=10, marker='ball')
Display a set of points
Parameters:
Name | Type | Description | Default |
---|---|---|---|
points
|
ndarray
|
Points to display |
required |
color
|
tuple of 3 floats or np.ndarray of size #points x 3 or str
|
RGB color (can be a single color or per-point colors). Defaults to None. |
None
|
scale
|
float
|
Scale of the points |
10
|
marker
|
str
|
Marker type for the point. Must be one of ('point', 'star', 'ball', 'x', 'o'). Defaults to 'ball'. |
'ball'
|
Source code in src/occwl/viewer.py
113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 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 |
|
display_text(xyz, text, height=None, color=None)
Display a text
Parameters:
Name | Type | Description | Default |
---|---|---|---|
xyz
|
tuple of floats or 1D np.ndarray of 2 or 3
|
Coordinate in model space where text would appear |
required |
text
|
str
|
Text to display |
required |
height
|
float
|
Height of the text font. Defaults to None. |
None
|
color
|
tuple of 3 floats
|
RGB color. Defaults to None. |
None
|
Source code in src/occwl/viewer.py
99 100 101 102 103 104 105 106 107 108 109 110 111 |
|
enable_antialiasing()
Enable antialiasing
Source code in src/occwl/viewer.py
327 328 329 330 331 |
|
exit()
Exit the viewer
Source code in src/occwl/viewer.py
505 506 507 508 509 510 511 |
|
fit()
Fit the camera to the scene
Source code in src/occwl/viewer.py
252 253 254 255 256 |
|
hide_axes()
Hide the XYZ-axes widget
Source code in src/occwl/viewer.py
321 322 323 324 325 |
|
hide_face_boundary()
Hide the edges bounding each face
Source code in src/occwl/viewer.py
357 358 359 360 361 |
|
on_select(callback)
Callback to execute when a selection is made
Parameters:
Name | Type | Description | Default |
---|---|---|---|
callback
|
function
|
Called when a selection is made. Must have signature: def callback(selected_shapes, mouse_x, mouse_y) |
required |
Source code in src/occwl/viewer.py
438 439 440 441 442 443 444 445 446 447 448 449 450 451 |
|
orthographic()
Set orthographic camera projection
Source code in src/occwl/viewer.py
265 266 267 268 269 270 |
|
perspective()
Set perspective camera projection
Source code in src/occwl/viewer.py
258 259 260 261 262 263 |
|
save_image(filename=None)
Save a screenshot of the viewer
Parameters:
Name | Type | Description | Default |
---|---|---|---|
filename
|
str or Path
|
Image file to save the screenshot. Defaults to None. If None, writes a PNG file named with the current timestamp |
None
|
Source code in src/occwl/viewer.py
286 287 288 289 290 291 292 293 294 295 296 297 298 |
|
selected_shapes()
Get the selected shapes
Returns:
Type | Description |
---|---|
List[TopoDS_Shape]: List of selected shapes |
Source code in src/occwl/viewer.py
469 470 471 472 473 474 475 476 477 478 |
|
selection_mode_edge()
Allow edges to be selected
Source code in src/occwl/viewer.py
519 520 521 522 523 |
|
selection_mode_face()
Allow faces to be selected
Source code in src/occwl/viewer.py
525 526 527 528 529 |
|
selection_mode_none()
Allow no shapes to be selected
Source code in src/occwl/viewer.py
543 544 545 546 547 |
|
selection_mode_shell()
Allow all shapes to be selected
Source code in src/occwl/viewer.py
531 532 533 534 535 |
|
selection_mode_solid()
Allow no shapes to be selected
Source code in src/occwl/viewer.py
537 538 539 540 541 |
|
selection_mode_vertex()
Allow vertices to be selected
Source code in src/occwl/viewer.py
513 514 515 516 517 |
|
set_background_color(top_color, bottom_color)
Set the background gradient color
Parameters:
Name | Type | Description | Default |
---|---|---|---|
top_color
|
List / Tuple[int, int, int]
|
Top color |
required |
bottom_color
|
List / Tuple[int, int, int]
|
Bottom color |
required |
Source code in src/occwl/viewer.py
339 340 341 342 343 344 345 346 347 348 349 |
|
set_size(width, height)
Set the size of the framebuffer
Parameters:
Name | Type | Description | Default |
---|---|---|---|
width
|
int
|
Width of the framebuffer |
required |
height
|
int
|
Height of the framebuffer |
required |
Source code in src/occwl/viewer.py
363 364 365 366 367 368 369 370 371 |
|
shaded()
Shade all shapes
Source code in src/occwl/viewer.py
279 280 281 282 283 284 |
|
show()
Show the viewer
Source code in src/occwl/viewer.py
480 481 482 483 484 |
|
show_axes()
Show the XYZ-axes widget
Source code in src/occwl/viewer.py
315 316 317 318 319 |
|
show_face_boundary()
Show the edges bounding each face
Source code in src/occwl/viewer.py
351 352 353 354 355 |
|
use_flat_shading()
Use no interpolation when computing color for fragments in a triangle
Source code in src/occwl/viewer.py
379 380 381 382 383 |
|
use_gouraud_shading()
Compute colors per vertex and interpolate
Source code in src/occwl/viewer.py
373 374 375 376 377 |
|
use_phong_shading()
Compute colors per fragment
Source code in src/occwl/viewer.py
385 386 387 388 389 |
|
use_rasterization()
Render using rasterization
Source code in src/occwl/viewer.py
300 301 302 303 304 |
|
use_raytracing(depth=3)
Render using raytracing
Parameters:
Name | Type | Description | Default |
---|---|---|---|
depth
|
int
|
Number of bounces for rays Defaults to 3. |
3
|
Source code in src/occwl/viewer.py
306 307 308 309 310 311 312 313 |
|
wireframe()
Set all shapes to appear as wireframes
Source code in src/occwl/viewer.py
272 273 274 275 276 277 |
|
wire
Wire
Bases: Shape
A topological wire in a solid model Represents a closed loop of edges
Source code in src/occwl/wire.py
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
|
__eq__(other)
Equality check for the shape
NOTE: This function only checks if the shape is the same. It doesn't check the edge orienation for example, so
edge1 == edge2
does not necessarily mean
edge1.reversed() == edge2.reversed()
Source code in src/occwl/shape.py
144 145 146 147 148 149 150 151 152 153 154 155 156 157 |
|
__hash__()
Hash for the shape
Returns:
Name | Type | Description |
---|---|---|
int |
Hash value |
Source code in src/occwl/shape.py
135 136 137 138 139 140 141 142 |
|
__init__(topods_wire)
Construct a Wire
Parameters:
Name | Type | Description | Default |
---|---|---|---|
topods_wire
|
TopoDS_Wire
|
OCC wire type |
required |
Source code in src/occwl/wire.py
18 19 20 21 22 23 24 25 26 27 |
|
convert_geometric_identity_transforms_to_identity()
Open Cascade models sometimes contain transforms which are "geometrically" identify transforms, but the identity flag is not set.
This function checks each transform and sets the flag if the appropriate.
Source code in src/occwl/shape.py
371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 |
|
find_closest_point_data(datum)
Find the information about the closest point on this shape
Parameters:
Name | Type | Description | Default |
---|---|---|---|
datum
|
ndarray
|
3D Point |
required |
Returns:
Name | Type | Description |
---|---|---|
ClosestPointData |
Data about the closest point on this shape |
|
None |
if error |
Source code in src/occwl/shape.py
251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 |
|
make_from_edges(edges)
staticmethod
Make a wire from connected edges
Parameters:
Name | Type | Description | Default |
---|---|---|---|
edges
|
List[Edge]
|
List of edges |
required |
Returns:
Type | Description |
---|---|
occwl.wire.Wire or None: Returns a Wire or None if the operation failed |
Source code in src/occwl/wire.py
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
|
occwl_shape(topods_shape)
staticmethod
Static method to create an occwl shape of the appropriate class from the given topods_shape Args: topods_shape (OCC.Core.TopoDS.TopoDS_Vertex/Edge/Face/Wire/Shell/Solid): TopoDS shape
Returns:
Type | Description |
---|---|
One of occwl.compound.Compound occwl.solid.Solid occwl.face.Face occwl.edge.Edge occwl.vertex.Vertex occwl.wire.Wire occwl.shell.Shell |
Raises: Exception: [description]
Source code in src/occwl/shape.py
89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 |
|
ordered_edges()
Get an iterator to go over the edges while respecting the wire ordering
Returns:
Type | Description |
---|---|
Iterator[occwl.edge.Edge]: An iterator to edges |
Source code in src/occwl/wire.py
48 49 50 51 52 53 54 55 |
|
ordered_vertices()
Get an iterator to go over the vertices while respecting the wire ordering
Returns:
Type | Description |
---|---|
Iterator[occwl.vertex.Vertex]: An iterator to vertices |
Source code in src/occwl/wire.py
57 58 59 60 61 62 63 64 |
|
reversed()
Whether this shape is reversed.
- For an edge this is whether the edge is reversed with respect to the curve geometry
- For a face this is whether the face is reversed with respect to the surface geometry
- For a vertex this is whether the vertex is at the upper or lower parameter value on the edges curve
Returns:
Name | Type | Description |
---|---|---|
bool |
If rational |
Source code in src/occwl/shape.py
236 237 238 239 240 241 242 243 244 245 246 247 248 |
|
rotate_axis_angle(axis, angle_radians, origin=np.zeros(3, dtype=(np.float32)))
Rotate the shape about the given axis by the given angle in radians
Parameters:
Name | Type | Description | Default |
---|---|---|---|
axis
|
ndarray
|
Rotation axis |
required |
angle_radians
|
float
|
Angle in radians |
required |
Source code in src/occwl/shape.py
285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 |
|
rotate_euler_angles(angles_xyz_radians)
Rotate the shape by the given Euler angles in radians
Parameters:
Name | Type | Description | Default |
---|---|---|---|
angle_xyz_radians
|
ndarray
|
3D array with angles to rotate about x-axis, y-axis and z-axis respectively in radians |
required |
Source code in src/occwl/shape.py
302 303 304 305 306 307 308 309 310 311 312 313 314 315 |
|
save_shapes_to_occ_native(filename, shapes, with_triangles=False, with_normals=False, format_version=None)
staticmethod
Save this shape into a native OCC binary .brep file.
Saving to and loading from the native file format
is between one and two orders of magnitude faster than loading from STEP, so it is recommended for large scale data processing
Parameters:
Name | Type | Description | Default |
---|---|---|---|
filename
|
str or Path
|
.brep filename |
required |
with_triangles
|
bool
|
Whether to save triangle data cached in the shape. |
False
|
with_normals
|
bool
|
Whether to save vertex normals cached in the shape |
False
|
format_version
|
int
|
Use None to save to the latest version 1 - first revision 2 - added storing of CurveOnSurface UV Points 3 - [OCCT 7.6] added storing of per-vertex normal information and dropped storing of CurveOnSurface UV Points |
None
|
Source code in src/occwl/shape.py
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 |
|
save_to_occ_native(filename, verbosity=False, with_triangles=False, with_normals=False, format_version=None)
Save this shape into a native OCC binary .brep file.
Saving to and loading from the native file format
is between one and two orders of magnitude faster than loading from STEP, so it is recommended for large scale data processing
Parameters:
Name | Type | Description | Default |
---|---|---|---|
filename
|
str or Path
|
.brep filename |
required |
with_triangles
|
bool
|
Whether to save triangle data cached in the shape. |
False
|
with_normals
|
bool
|
Whether to save vertex normals cached in the shape |
False
|
format_version
|
int
|
Use None to save to the latest version 1 - first revision 2 - added storing of CurveOnSurface UV Points 3 - [OCCT 7.6] added storing of per-vertex normal information and dropped storing of CurveOnSurface UV Points |
None
|
Source code in src/occwl/shape.py
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 |
|
scale(scale_vector)
Scale the shape by the given 3D vector
Parameters:
Name | Type | Description | Default |
---|---|---|---|
scale_vector
|
ndarray
|
3D array with scales to resize the shape along the x-axis, y-axis and z-axis respectively |
required |
Source code in src/occwl/shape.py
317 318 319 320 321 322 323 324 325 326 |
|
set_transform_to_identity()
When an assembly is loaded from a STEP file the solids will be transformed relative to their local coordinate system. i.e. they are placed in the assembly root components coordinate system.
When working with individual bodies you often want them to be axis aligned, in which case you want to remove the assembly transform. This function removes it for you.
If however you want to bake the transform into the bodies and suppress the asserts from parts of occwl which don't cope with transforms then use the transform() function below with copy=True
Source code in src/occwl/shape.py
346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 |
|
topods_shape()
Get the underlying OCC shape
Returns:
Type | Description |
---|---|
OCC.Core.TopoDS.TopoDS_Vertex/Edge/Face/Wire/Shell/Solid: OCC TopoDS_* |
Source code in src/occwl/shape.py
80 81 82 83 84 85 86 87 |
|
transform(a, copy=True)
Apply the given 3x4 transform matrix to the solid.
copy (bool) True - Copy entities and apply the transform to
the underlying geometry
False - Apply the transform to the topods Locator
if possible
Source code in src/occwl/shape.py
400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 |
|
translate(offset)
Translate the shape by an offset vector
Parameters:
Name | Type | Description | Default |
---|---|---|---|
offset
|
ndarray
|
Offset vector |
required |
Source code in src/occwl/shape.py
276 277 278 279 280 281 282 283 |
|
valid(return_analyzer=False)
Check if the shape is valid
Parameters:
Name | Type | Description | Default |
---|---|---|---|
return_analyzer
|
bool
|
Whether to return the BRepCheck_Analyzer object for more inspection |
False
|
Returns:
Name | Type | Description |
---|---|---|
bool |
Whether the shape is valid |
|
BRepCheck_Analyzer [optional]: if return_analyzer is True |
Source code in src/occwl/shape.py
328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 |
|