-
-
Notifications
You must be signed in to change notification settings - Fork 402
Open
Description
Problem Summary
When using ShapeUpgrade_UnifySameDomain with UnifyFaces=True, I experience:
First call in a Python session takes 75-90 seconds (lazy initialization)
Environment
- OpenCascade Version: 7.8.1 (via pythonocc-core)
- Python Version: 3.12
- OS: macOS (darwin 25.2.0)
Minimal Reproduction
Original Code
from OCC.Core.STEPControl import STEPControl_Reader
from OCC.Core.ShapeUpgrade import ShapeUpgrade_UnifySameDomain
# Read STEP file
reader = STEPControl_Reader()
reader.ReadFile("file_with_multiple_threads.step") # 465 faces
reader.TransferRoots()
shape = reader.OneShape()
# Unify faces (SLOW!)
unify = ShapeUpgrade_UnifySameDomain(
shape,
True, # UnifyEdges
True, # UnifyFaces - THIS IS THE BOTTLENECK
False # ConcatBSplines
)
unify.Build()
unified_shape = unify.Shape()Fast Alternative
# Just read the file, no unification
reader = STEPControl_Reader()
reader.ReadFile("file_with_multiple_threads.step")
reader.TransferRoots()
shape = reader.OneShape()
# Result: 465 faces (no reduction)
# Problem: Circular planes split into hemispheres, cylinders splitCurrent Workaround
I observed that a warm-up strategy to mitigate the cold start:
# Warm up with small file
def warmup_cad_reader(warmup_file: str = "small_file.stp"):
"""Process small file to initialize OpenCascade caches"""
reader = STEPControl_Reader()
reader.ReadFile(warmup_file)
reader.TransferRoots()
shape = reader.OneShape()
unify = ShapeUpgrade_UnifySameDomain(shape, True, True, False)
unify.Build()
return TrueCurrent Optimizations Applied
unify = ShapeUpgrade_UnifySameDomain(shape, True, True, False)
unify.SetLinearTolerance(5e-4) # 0.5mm tolerance
unify.SetAngularTolerance(0.1) # ~5.7 degrees
unify.SetSafeInputMode(False) # Skip extra validation
unify.AllowInternalEdges(True) # Handle complex topology
unify.Build()Questions
-
Cold Start Penalty:
- Why does the first call to
ShapeUpgrade_UnifySameDomain.Build()take 75-90 seconds? - Is there a way to pre-initialize these internal caches without processing a file?
- Why does the first call to
-
Performance Optimization:
- Is there a way to make face unification faster while maintaining accuracy?
- Can the O(n²) face comparison be optimized (spatial indexing, parallel processing)?
-
Alternative Approaches:
- Is there a different algorithm or class that can merge split faces more efficiently?
Would love to discuss and know more about this @tpaviot
Metadata
Metadata
Assignees
Labels
No labels