错误的BoundingBox维提取pythonocc

问题描述

我正在尝试从STP文件提取盒子尺寸,并且它适用于某些示例,但是不幸的是,我在其他压缩后的STP文件提取错误的示例

https://github.com/tpaviot/pythonocc-demos/files/5272793/Test.zip

我得到了“ x”的结果值:6.802000200000001 但是正确的值是6.24,以此类推,y和z值依此类推。

这是我的代码

from future import print_function

from OCC.Extend.DataExchange import read_step_file
from OCC.Core.IFSelect import IFSelect_RetDone
from OCC.Core.Bnd import Bnd_Box
from OCC.Core.BRepBndLib import brepbndlib_Add
from OCC.Core.BRepMesh import BRepMesh_IncrementalMesh
from OCC.Core.STEPControl import STEPControl_Reader

shapes = read_step_file('path/to/stpfile')

def read_stp_file(file_path):
step_reader = STEPControl_Reader()
status = step_reader.ReadFile(file_path)
if status == IFSelect_RetDone:
fails_only = False
step_reader.TransferRoots()
shape = step_reader.Shape(1)
return shape
else:
print("Error: can't read file.")

bBox = Bnd_Box()

use_mesh = True
mesh = BRepMesh_IncrementalMesh()
mesh.SetParallelDefault(True)
mesh.SetShape(shapes)
mesh.Perform()
assert mesh.IsDone()
brepbndlib_Add(shapes,bBox,use_mesh)
xmin,ymin,zmin,xmax,ymax,zmax = bBox.Get()
print('x value : >>>> ',xmax - xmin)

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)