栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Python

pythonocc

Python 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

pythonocc


# 放样改写
from OCC.Core.AIS import AIS_Shape
from OCC.Core.BRepBuilderAPI import BRepBuilderAPI_MakeEdge, BRepBuilderAPI_MakeWire
from OCC.Core.BRepOffsetAPI import BRepOffsetAPI_ThruSections
from OCC.Core.gp import gp_Pnt
from OCC.Display.SimpleGui import init_display
from OCC.Display.OCCViewer import rgb_color
from OCC.Core.GC import GC_MakeSegment, GC_MakeCircle, GC_MakeArcOfCircle, GC_MakeEllipse

def build_auto_wire():
    # 做第一条封闭曲线(四边形)
    gp_n = [0, 1, 2, 3, 4, 5, 6, 7, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]
    gp_x = [40, 82.5, 42.5, 0, 8, 8, 8, 8, 12, 12, 16, 16, 16, 20, 20, 24, 24, 28, 28, 32, 36, 40, 44, 48]
    gp_y = [0, 25, 93, 68, 19, 23, 28, 28, 28, 31, 31, 34, 37, 37, 40, 43, 49, 49, 56, 56, 62, 62, 70, 70]
    gp_z = [0, 0, 0, 0, 160, 190, 220, 250, 310, 370, 430, 490, 550, 660, 770, 875, 990, 1090, 1210,
            1420, 1640, 1860, 2070, 2300]
    dict_gp_x = dict(zip(gp_n, gp_x))
    dict_gp_y = dict(zip(gp_n, gp_y))
    dict_gp_z = dict(zip(gp_n, gp_z))

    dict_select_num = 3

    aWire = BRepBuilderAPI_MakeWire()  # Create a wire out of the edges
    for i in range(0, dict_select_num):
        if i < dict_select_num - 1:
            aSegment = GC_MakeSegment(gp_Pnt(dict_gp_x[i], dict_gp_y[i], dict_gp_z[i]),
                                      gp_Pnt(dict_gp_x[i + 1], dict_gp_y[i + 1], dict_gp_z[i + 1]))

            anEdge = BRepBuilderAPI_MakeEdge(aSegment.Value())
            aWire.Add(anEdge.Edge())
        else:
            aSegment = GC_MakeSegment(gp_Pnt(dict_gp_x[i], dict_gp_y[i], dict_gp_z[i]),
                                      gp_Pnt(dict_gp_x[0], dict_gp_y[0], dict_gp_z[0]))

            anEdge = BRepBuilderAPI_MakeEdge(aSegment.Value())
            aWire.Add(anEdge.Edge())
    display.DisplayShape(aWire.Shape(), update=True, color=rgb_color(0.1, 0.2, 1))  #

def build_auto_MakeEdge():
    # 做第一条封闭曲线(四边形)
    gp_n = [0, 1, 2, 3, 4, 5, 6, 7, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]
    gp_x = [40, 82.5, 42.5, 0, 8, 8, 8, 8, 12, 12, 16, 16, 16, 20, 20, 24, 24, 28, 28, 32, 36, 40, 44, 48]
    gp_y = [0, 25, 93, 68, 19, 23, 28, 28, 28, 31, 31, 34, 37, 37, 40, 43, 49, 49, 56, 56, 62, 62, 70, 70]
    gp_z = [0, 0, 0, 0, 160, 190, 220, 250, 310, 370, 430, 490, 550, 660, 770, 875, 990, 1090, 1210,
            1420, 1640, 1860, 2070, 2300]
    dict_gp_x = dict(zip(gp_n, gp_x))
    dict_gp_y = dict(zip(gp_n, gp_y))
    dict_gp_z = dict(zip(gp_n, gp_z))

    dict_select_num = 3

    aWire = BRepBuilderAPI_MakeEdge()  # Create a wire out of the edges
    for i in range(0, dict_select_num):
        if i < dict_select_num - 1:
            aSegment = GC_MakeSegment(gp_Pnt(dict_gp_x[i], dict_gp_y[i], dict_gp_z[i]),
                                      gp_Pnt(dict_gp_x[i + 1], dict_gp_y[i + 1], dict_gp_z[i + 1]))

            anEdge = BRepBuilderAPI_MakeEdge(aSegment.Value())
            aWire.Add(anEdge.Edge())
        else:
            aSegment = GC_MakeSegment(gp_Pnt(dict_gp_x[i], dict_gp_y[i], dict_gp_z[i]),
                                      gp_Pnt(dict_gp_x[0], dict_gp_y[0], dict_gp_z[0]))

            anEdge = BRepBuilderAPI_MakeEdge(aSegment.Value())
            aWire.Add(anEdge.Edge())
    display.DisplayShape(aWire.Shape(), update=True, color=rgb_color(0.1, 0.2, 1))  #


def fangyang():
    # 做第一条封闭曲线(四边形)
    gp_n = [0, 1, 2, 3, 4, 5, 6, 7, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]
    gp_x = [40, 50, 60, 30, 8, 8, 8, 8, 12, 12, 16, 16, 16, 20, 20, 24, 24, 28, 28, 32, 36, 40, 44, 48]
    gp_y = [0, 25, 93, 68, 50, 23, 28, 28, 28, 31, 31, 34, 37, 37, 40, 43, 49, 49, 56, 56, 62, 62, 70, 70]
    gp_z = [0, 0, 0, 0, 0, 0, 220, 250, 310, 370, 430, 490, 550, 660, 770, 875, 990, 1090, 1210,
            1420, 1640, 1860, 2070, 2300]
    dict_gp_x = dict(zip(gp_n, gp_x ))
    dict_gp_y = dict(zip(gp_n, gp_y ))
    dict_gp_z = dict(zip(gp_n, gp_z ))

    dict_select_num=5

    BRep_Wire_down = BRepBuilderAPI_MakeWire()  # Create a wire out of the edges
    for i in range(0, dict_select_num):

        if i
转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/331545.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号