如何定义曲面的法向量?先将曲面转换为平面,然后定义平面向量?调试:不再需要沮丧?

问题描述

从以前的 Python 代码 (2.7) 调试到 (3.7) 时出现错误消息。 (从 pythonocc-core==0.18.1 到 pythonocc-core=7.4.1) 首先我应用了 2to3.py,但是代码需要一些进一步的调试。 以下代码导致“plane = OCC.Core.Geom.Geom_Plane(Surface)”错误 我该如何解决这个问题?

代码

for idx,Elementpolygon in enumerate(polygons):
# The space boundary must have a corresponding building element.
if self.IfcFile.by_guid(CurrentSpace).BoundedBy[idx].RelatedBuildingElement!=None:
# Generate the pythonOCC face corresponding to the geometric representation of the space boundary
ElementFace = self.__CreateFaceAndRemoveopenings(Elementpolygon,polygons,CurrentSpace,idx,RelatedBuildingElement)
# Identify the normal vector to the face
Surface = OCC.Core.BRep.BRep_Tool.Surface(ElementFace)
plane = OCC.Core.Geom.Geom_Plane(Surface) #Todo check OCC documentation for changes (downcast no longer needed,error handling: surface need not be a plane ?)
face_bBox = OCC.Core.Bnd.Bnd_Box()
OCC.Core.BRepBndLib.brepbndlib_Add(ElementFace,face_bBox)
face_center = get_bounding_Box_center(face_bBox).XYZ()
vv = face_center - SpaceBoxCenter.XYZ()
face_normal = plane.Axis().Direction().XYZ()
if face_normal.Dot(vv)>=0:
face_normal = face_normal
else:
face_normal = plane.Axis().Direction().XYZ().Reversed()

错误信息:

File "C:\00_PhD\Dev\ifc2modelica\Envelop\CreateNetworkEnvelop.py",line 586,in CreateNetwork
plane = OCC.Core.Geom.Geom_Plane(Surface) #Todo check OCC documentation for changes (downcast     no longer needed,error handling: surface need not be a plane ?)
File "C:\workdir\Programs\Anaconda3\envs\py37_64\lib\site-packages\OCC\Core\Geom.py",line 7941,in __init__
_Geom.Geom_Plane_swiginit(self,_Geom.new_Geom_Plane(*args))
TypeError: Wrong number or type of arguments for overloaded function 'new_Geom_Plane'.
Possible C/C++ prototypes are:
    Geom_Plane::Geom_Plane(gp_Ax3 const &)
    Geom_Plane::Geom_Plane(gp_Pln const &)
    Geom_Plane::Geom_Plane(gp_Pnt const &,gp_Dir const &)
    Geom_Plane::Geom_Plane(Standard_Real const,Standard_Real const,Standard_Real const)

解决方法

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

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

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