View Issue Details

IDProjectCategoryView StatusLast Update
0032855CommunityOCCT:Modeling Algorithmspublic2023-08-01 15:08
Reporterydk001001 Assigned Toazv 
PrioritynormalSeverityminor 
Status assignedResolutionopen 
PlatformWindowsOSVC++ 2015 
Product Version7.4.0 
Target VersionUnscheduled 
Summary0032855: BRepOffsetAPI_MakeThickSolid - some characters cannot be hollowed out
DescriptionBRepOffsetAPI_MakeThickSolid----- Some characters can be hollowed out, but some can't ,help python_OCC


Thank you for checking. I consulted a lot of people, but I couldn't solve it. I'm confused.
Steps To ReproduceBRepOffsetAPI_MakeThickSolid----- Some characters can be hollowed out, but some can't ,help python_OCC

from OCC.Core.Addons import text_to_brep, Font_FontAspect_Bold, Font_FA_Regular
from OCC.Core.BRepAdaptor import BRepAdaptor_Surface
from OCC.Core.TopExp import TopExp_Explorer
from OCC.Core.TopAbs import TopAbs_VERTEX, TopAbs_EDGE, TopAbs_FACE
from OCC.Core.GeomAbs import GeomAbs_Plane
from OCC.Display.backend import load_backend
from OCC.Core.TopTools import TopTools_ListOfShape
from OCC.Core.BRepOffsetAPI import BRepOffsetAPI_MakeThickSolid  #maketicksolidbysimple
from OCC.Display.OCCViewer import rgb_color
load_backend('qt-pyqt5')
from OCC.Core.gp import (gp_Pnt, gp_OX,gp_OY, gp_Vec, gp_Trsf, gp_DZ, gp_Ax2, gp_Ax3,
                         gp_Pnt2d, gp_Dir2d, gp_Ax2d, gp_Pln)
from OCC.Core.TopoDS import topods, TopoDS_Compound, TopoDS_Face
from OCC.Core.BRepPrimAPI import BRepPrimAPI_MakePrism, BRepPrimAPI_MakeCylinder,BRepPrimAPI_MakeBox
from OCC.Core.BRepBuilderAPI import BRepBuilderAPI_MakeFace, BRepBuilderAPI_Transform

from OCC.Core.BRep import BRep_Tool_Surface, BRep_Builder
from OCC.Core.Geom import Geom_Plane, Geom_CylindricalSurface

from OCC.Core.ShapeFix import ShapeFix_Shape,ShapeFix_Wireframe


def  build_zi_Shapefix():



    zi_hou = 10
    zihao = 30
    txt_Str = 'U'  #不可以DEFHIJKLMNT   QUVWXYZ   ,可以:0 ,ABCIQOPRSU
    txt_Str = 'H'  # 不可以DEFHIJKLMNT   QUVWXYZ   ,可以:0 ,ABCIQOPRSU
    txt_Font = 'Arial'
    aPrismVec = gp_Vec(0, 0, zi_hou)  # Vec face
    # D_Shape_Zi = text_to_brep(txt_Str, txt_Font, Font_FA_Regular, zihao, True)  #全部失败 #复合曲线是
    D_Shape_Zi = text_to_brep(txt_Str, txt_Font, Font_FA_Regular, zihao, False)  # 部分成功	复合曲线否fisCompositeCurve (bool)
    shape= BRepPrimAPI_MakePrism(D_Shape_Zi, aPrismVec).Shape()  # 形成字符模板TopoDS_Shape


    # display.DisplayShape(shape, update=True, color=rgb_color(0.5, 0.5, 0))  # 显示图 蓝


    def face_is_plane1(face):
        # 如果是平面,则返回True
        hs = BRep_Tool_Surface(face)
        downcast_result = Geom_Plane.DownCast(hs)
        if downcast_result is None:
            return False
        else:
            return True

    def surface_plane_from_face(aFace):
        """
        Returns the geometric plane entity from a planar surface
        """
        return Geom_Plane.DownCast(BRep_Tool_Surface(aFace))

    def scoop(shape, thickness):
        faceToRemove = None
        zMax = 1
        aFaceExplorer = TopExp_Explorer(shape, TopAbs_FACE)
        while aFaceExplorer.More():
            aFace = topods.Face(aFaceExplorer.Current())
            if face_is_plane1(aFace):
                aPlane = surface_plane_from_face(aFace)
                aPnt = aPlane.Location()
                aZ = aPnt.Z()
                # aZ = aPnt.Y()
                if aZ > zMax:# aZ < zMax---他砍掉了侧面:
                    zMax = aZ
                    faceToRemove = aFace
            aFaceExplorer.Next()

        facesToRemove = TopTools_ListOfShape()
        facesToRemove.Append(faceToRemove)

        shapeFixer = ShapeFix_Shape()
        shapeFixer.Init(shape)
        shapeFixer.SetPrecision(1)  # 精度
        shapeFixer.MaxTolerance()  # 最大允许公差 Prec# 1e-4
        shapeFixer.Perform()
        shape = shapeFixer.Shape()
        # display.DisplayShape(shape, update=True)  # 显示图 蓝
        # 第一个参数是shape,第二个是要删除的面的集合,第三个是变化后的厚度,第四个是偏差
        scoopShape = BRepOffsetAPI_MakeThickSolid(shape, facesToRemove, thickness, 0.001)
        # 1 S(TopoDS_Shape &) –
        # 2 ClosingFaces(TopTools_ListOfShape &) –
        # 3 Offset(float) –
        # 4 Tol(float) –
        # 5 Mode(BRepOffset_Mode) – default
        # 6 value is BRepOffset_Skin
        # 7 Intersection(bool) – default
        # 8 value is Standard_False
        # 9 SelfInter(bool) – default
        # 10 value is Standard_False
        # 11 Join(GeomAbs_JoinType) – default
        # 12 value is GeomAbs_Arc

        # BRepBuilderAPI.BRepBuilderAPI_MakeShape_Shape
        # step_writer.SetTolerance(1e-4)
        return scoopShape

    #挖空
    shape=scoop(shape, 1).Shape()

    # shapeFixer1 = ShapeFix_Shape()
    # shapeFixer1.Init(shape)
    # shapeFixer1.SetPrecision(1e-04)  # 精度
    # shapeFixer1.MaxTolerance()  # 最大允许公差 Prec#
    # shapeFixer1.Perform()
    # shape = shapeFixer1.Shape()

    # ShapeFix_FixSmallSolid_1=ShapeFix_Solid(shape)
    # ShapeFix_FixSmallSolid_1.Init(shape)
    # ShapeFix_FixSmallSolid_1.SetPrecision(1e-04)  # 精度
    # ShapeFix_FixSmallSolid_1.MaxTolerance()  # 最大允许公差 Prec#
    # ShapeFix_FixSmallSolid_1.Perform()
    # shape = ShapeFix_FixSmallSolid_1.FixShape()

    display.DisplayShape(shape, update=True, color=rgb_color(1, 1, 0.1))  # 显示图 蓝



if __name__ == "__main__":

    from OCC.Display.SimpleGui import init_display

    display, start_display, add_menu, add_function_to_menu = init_display()
    display.display_triedron()  # 坐標顯示
    display.set_bg_gradient_color([206, 215, 222], [0, 128, 0])  # 设置背景渐变色
    add_menu('管件字挖空管理')

    add_function_to_menu('管件字挖空管理',build_zi_Shapefix)

    start_display()


DRAW reproducer:
text2brep tu "U" -font font=Arial
prism pu tu 0 0 10
explode pu F
offsetshape ru pu 1.0 0.001 pu_19
# OK. Offset performed successfully.

text2brep th "H" -font font=Arial
prism ph th 0 0 10
explode ph F
offsetshape rh ph 1.0 0.001 ph_14
# ERROR. offsetperform operation not done.
TagsNo tags attached.
Test case number

Attached Files

  • bulid_zi_wakongtest.zip (2,092 bytes)
  • image.png (9,911 bytes)

Activities

ydk001001

2022-02-24 11:48

reporter  

bulid_zi_wakongtest.zip (2,092 bytes)

kgv

2022-02-24 20:20

developer   ~0107058

I can't reproduce the problem with symbols "U" and "H" - could you please provide your screenshots?
pload MODELING VISUALIZATION
set zi_hou   10
set zihao    30
#set txt_Str  "U"
set txt_Str  "H"
set txt_Font "Arial"
text2brep t "$txt_Str" -font "$txt_Font" -height $zihao
prism p t 0.0 0.0 $zi_hou

vinit View1
vdisplay p -dispMode 1
vfit
image.png (9,911 bytes)

kgv

2022-02-24 20:24

developer   ~0107059

OK, I see that the question is about `BRepOffsetAPI_MakeThickSolid` class.
Cannot find any Draw Harness command using this builder.

azv

2022-02-24 22:40

administrator   ~0107060

I confirm the issue in BRepOffsetAPI_MakeThickSolid. Here is DRAW script to reproduce the problem:
text2brep tu "U" -font font=Arial
prism pu tu 0 0 10
explode pu F
offsetshape ru pu 1.0 0.001 pu_19
# OK. Offset performed successfully.

text2brep th "H" -font font=Arial
prism ph th 0 0 10
explode ph F
offsetshape rh ph 1.0 0.001 ph_14
# ERROR. offsetperform operation not done.


We will investigate the root of the problem.

Issue History

Date Modified Username Field Change
2022-02-24 11:48 ydk001001 New Issue
2022-02-24 11:48 ydk001001 Assigned To => a3an
2022-02-24 11:48 ydk001001 File Added: bulid_zi_wakongtest.zip
2022-02-24 20:20 kgv Note Added: 0107058
2022-02-24 20:20 kgv File Added: image.png
2022-02-24 20:20 kgv Assigned To a3an => ydk001001
2022-02-24 20:21 kgv Status new => feedback
2022-02-24 20:22 kgv Category OCCT:Coding => OCCT:Modeling Algorithms
2022-02-24 20:22 kgv Description Updated
2022-02-24 20:22 kgv Steps to Reproduce Updated
2022-02-24 20:24 kgv Note Added: 0107059
2022-02-24 20:25 kgv Status feedback => assigned
2022-02-24 20:25 kgv Target Version => 7.7.0
2022-02-24 20:25 kgv Summary BRepOffsetAPI_MakeThickSolid----- Some characters can be hollowed out, but some can't ,help python_OCC => BRepOffsetAPI_MakeThickSolid - some characters cannot be hollowed out
2022-02-24 20:25 kgv Assigned To ydk001001 => azv
2022-02-24 20:25 kgv Steps to Reproduce Updated
2022-02-24 22:40 azv Note Added: 0107060
2022-02-24 22:40 azv Steps to Reproduce Updated
2022-05-20 15:03 azv Severity just a question => minor
2022-10-24 10:41 szy Target Version 7.7.0 => 7.8.0
2023-08-01 15:08 dpasukhi Target Version 7.8.0 => Unscheduled