
Mon, 12/18/2023 - 14:46
Dear developers,
I'm trying to use a clipplane on an AIS_Shape built from an stl-file. The clipplane's hatching(/Capping) works fine for .brep but shows a hollow cross-section for .stl. The way I am building it is (note that I'm using the pythonocc-wrapper of OpenCascade):
from OCC.Core.Graphic3d import Graphic3d_ClipPlane
from OCC.Core.Quantity import Quantity_Color, Quantity_TOC_RGB
from OCC.Core.TopoDS import TopoDS_Face
from OCC.Core.BRep import BRep_Builder
from OCC.Core.RWStl import rwstl
# Import stl file
stlReader = rwstl()
poly_triangulation = stlReader.ReadFile(file_name.stl)
# Convert to shape
shape = TopoDS_Face()
builder = BRep_Builder()
builder.MakeFace(shape , poly_triangulation )
# Convert to AIS_Shape
ais_shp = display.DisplayShape(shape )[0]
# Clip plane
clip_plane_1 = Graphic3d_ClipPlane()
# Set hatch on
clip_plane_1.SetCapping(True)
clip_plane_1.SetCappingHatch(True)
# Set clip plane color
aMat = clip_plane_1.CappingMaterial()
aColor = Quantity_Color(0.5, 0.6, 0.7, Quantity_TOC_RGB)
aMat.SetAmbientColor(aColor)
aMat.SetDiffuseColor(aColor)
clip_plane_1.SetCappingMaterial(aMat)
# Add clip plane
ais_shp.AddClipPlane(clip_plane_1)
In CAD Assistant it is possible to assign a hatching profile to the part. But I'm not sure how to do it in code. Any ideas?
Thanks in advance and kind Regards,
Thieme
Wed, 12/20/2023 - 10:04
OCCT Viewer enables capping algorithm for watertight closed meshes only. In case of
AIS_Shape
- it is done forTopoDS_Solid
shapes. This is because capping algorithm will produce visual artifacts on open shells.STL files, although called 'solids', usually contain arbitrary triangulations (sometimes watertight, sometimes open shells). Do that without extra efforts AIS viewer will not consider them closed and will not enable capping.
You may try to build
TopoDS_Solid
out of imported STL file, or force Closed flags within AIS presentation builder (Graphic3d_Group::SetClosed()
).As sort of a hack (just for demonstration), istead of subclassing AIS object, this could be enforced also after presentation is already computed:
Wed, 12/27/2023 - 16:40
Thank you so much, your code did the trick!!
Thanks a lot,
Thieme