MakeHalfSpace Runtime Error - Only when run on Linux

Forums: 

I am working on a code to use the BRepPrimAPI_MakeHalfSpace command.  It works with Windows 7, but has an error on Linux (CentOS 7.7).  The error is:

Traceback (most recent call last):
  File "Example_Case_Fail.py", line 10, in <module>
    half_space_obj = BRepPrimAPI_MakeHalfSpace(temp_face, gp_pnt_obj)
  File "./.conda/envs/occt/lib/python3.7/site-packages/OCC/Core/BRepPrimAPI.py", line 238, in __init__
    _BRepPrimAPI.BRepPrimAPI_MakeHalfSpace_swiginit(self, _BRepPrimAPI.new_BRepPrimAPI_MakeHalfSpace(*args))
RuntimeError: Standard_ConstructionError
gp_Dir() - input vector has zero norm
wrapper details:
  * symname: new_BRepPrimAPI_MakeHalfSpace
  * wrapname: _wrap_new_BRepPrimAPI_MakeHalfSpace__SWIG_0
  * fulldecl: BRepPrimAPI_MakeHalfSpace::BRepPrimAPI_MakeHalfSpace(TopoDS_Face const &,gp_Pnt const &)

The code I am running is:

from OCC.Core.BRepBuilderAPI import BRepBuilderAPI_MakeFace
from OCC.Core.BRepPrimAPI import BRepPrimAPI_MakeHalfSpace
from OCC.Core.gp import gp_Pnt, gp_Dir, gp_Pln
    
gp_pnt_obj = gp_Pnt(0., 0., 0.)
gp_dir_obj = gp_Dir(1, 0, 0)
gp_pln_obj = gp_Pln(gp_pnt_obj, gp_dir_obj)
face_obj = BRepBuilderAPI_MakeFace(gp_pln_obj)
temp_face = face_obj.Face()
half_space_obj = BRepPrimAPI_MakeHalfSpace(temp_face, gp_pnt_obj)
temp_shape = half_space_obj.Shape()

Any help would be greatly appreciated.

Forum supervisor's picture

Hello Cory,

There is a mistake in the input data - the point gp_pnt_obj should not lay on the face temp_face.
This point selects the side of the face that will be the external to the halfspace, so placing it on the face makes such selection ambiguous.

Should you wish to benefit from our qualified assistance, please, consider our support services.
Do not hesitate to contact us for more information.

Best regards,
Forum supervisor

carthur3_154564's picture

Added the point and the vector to get a new point and it worked wonders.

Excellent help!