Update sample
Browse files
sample
CHANGED
|
@@ -17,3 +17,82 @@ Formula (inverse-frequency, mean-normalized):
|
|
| 17 |
|
| 18 |
Computed weights (class 0..6):
|
| 19 |
[0.189313, 0.312012, 1.356881, 2.309691, 0.639101, 0.517706, 1.675296]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 17 |
|
| 18 |
Computed weights (class 0..6):
|
| 19 |
[0.189313, 0.312012, 1.356881, 2.309691, 0.639101, 0.517706, 1.675296]
|
| 20 |
+
|
| 21 |
+
|
| 22 |
+
|
| 23 |
+
|
| 24 |
+
|
| 25 |
+
|
| 26 |
+
### Check No of faces
|
| 27 |
+
|
| 28 |
+
# compare_step_faces.py
|
| 29 |
+
from OCC.Core.STEPControl import STEPControl_Reader
|
| 30 |
+
from OCC.Core.IFSelect import IFSelect_RetDone
|
| 31 |
+
from OCC.Core.TopExp import TopExp_Explorer
|
| 32 |
+
from OCC.Core.TopAbs import TopAbs_FACE
|
| 33 |
+
from OCC.Core.TopoDS import topods
|
| 34 |
+
|
| 35 |
+
try:
|
| 36 |
+
# pythonocc (common) helper
|
| 37 |
+
from OCC.Extend.TopologyUtils import TopologyExplorer
|
| 38 |
+
except Exception as e:
|
| 39 |
+
TopologyExplorer = None
|
| 40 |
+
|
| 41 |
+
from occwl.io import load_step
|
| 42 |
+
|
| 43 |
+
|
| 44 |
+
def _load_shape_stepcontrol(step_path: str):
|
| 45 |
+
reader = STEPControl_Reader()
|
| 46 |
+
status = reader.ReadFile(step_path)
|
| 47 |
+
if status != IFSelect_RetDone:
|
| 48 |
+
raise RuntimeError(f"STEP read failed: status={status}")
|
| 49 |
+
reader.TransferRoots()
|
| 50 |
+
shape = reader.OneShape()
|
| 51 |
+
return shape
|
| 52 |
+
|
| 53 |
+
|
| 54 |
+
def count_faces_method1(step_path: str) -> int:
|
| 55 |
+
if TopologyExplorer is None:
|
| 56 |
+
raise RuntimeError("TopologyExplorer not available. Check pythonocc installation.")
|
| 57 |
+
shape = _load_shape_stepcontrol(step_path)
|
| 58 |
+
top_exp = TopologyExplorer(shape, ignore_orientation=True)
|
| 59 |
+
faces = [f for f in top_exp.faces()]
|
| 60 |
+
return len(faces)
|
| 61 |
+
|
| 62 |
+
|
| 63 |
+
def count_faces_method2(step_path: str) -> int:
|
| 64 |
+
shape = _load_shape_stepcontrol(step_path)
|
| 65 |
+
explorer = TopExp_Explorer(shape, TopAbs_FACE)
|
| 66 |
+
count = 0
|
| 67 |
+
while explorer.More():
|
| 68 |
+
_face = topods.Face(explorer.Current())
|
| 69 |
+
count += 1
|
| 70 |
+
explorer.Next()
|
| 71 |
+
return count
|
| 72 |
+
|
| 73 |
+
|
| 74 |
+
def count_faces_method3(step_path: str) -> int:
|
| 75 |
+
solids = load_step(step_path)
|
| 76 |
+
if len(solids) != 1:
|
| 77 |
+
raise RuntimeError(f"Expected 1 solid, got {len(solids)}")
|
| 78 |
+
solid = solids[0]
|
| 79 |
+
faces = [f for f in solid.faces()]
|
| 80 |
+
return len(faces)
|
| 81 |
+
|
| 82 |
+
|
| 83 |
+
def compare_counts(step_path: str):
|
| 84 |
+
m1 = count_faces_method1(step_path)
|
| 85 |
+
m2 = count_faces_method2(step_path)
|
| 86 |
+
m3 = count_faces_method3(step_path)
|
| 87 |
+
|
| 88 |
+
print(f"Method 1 (TopologyExplorer): {m1}")
|
| 89 |
+
print(f"Method 2 (TopExp_Explorer): {m2}")
|
| 90 |
+
print(f"Method 3 (occwl load_step): {m3}")
|
| 91 |
+
|
| 92 |
+
all_same = (m1 == m2 == m3)
|
| 93 |
+
print(f"All methods match: {all_same}")
|
| 94 |
+
|
| 95 |
+
|
| 96 |
+
if __name__ == "__main__":
|
| 97 |
+
step_path = r"C:\Users\FCI\Desktop\0m-3623639.stp"
|
| 98 |
+
compare_counts(step_path)
|