当前位置: 首页 > news >正文

三视图dxf 生成brep 3d图重建 pythonocc solid

 如果投影面闭合图形内有内线,生成对应面会失败导致solid生成失败

三视图dxf 生成brep 3d图重建 pythonocc solid

斜面不支持

这个投影面没什么问题,应该是图连接的问题

from collections import defaultdict
from 三维投影线段寻找 import get_adjusted_clusters,get_clusters,get_intersect_linesdxf_file_path = 'c.dxf'clusters=get_clusters(dxf_file_path)adjusted_clusters,yz中间面线段集,xy上下面线段集,xz左右面线段集  =get_adjusted_clusters(clusters)
intersect_lines=get_intersect_lines(xz左右面线段集,yz中间面线段集,xy上下面线段集)
intersect_lines1,intersect_lines2,intersect_lines3 = intersect_linesimport networkx as nx
from OCC.Core.BRepBuilderAPI import (BRepBuilderAPI_MakePolygon,BRepBuilderAPI_MakeFace,BRepBuilderAPI_MakeShell,BRepBuilderAPI_MakeSolid
)
from OCC.Core.BRep import BRep_Builder
from OCC.Core.TopoDS import TopoDS_Compound, TopoDS_Shellfrom OCC.Core.BRepLib import breplib_BuildCurves3d
from OCC.Core.gp import gp_Pntdef get_closed_subgraphs_in_open_faces(intersect_lines):all_polygons = []G = nx.Graph()G.add_edges_from(intersect_lines)cycles = list(nx.cycle_basis(G))for cycle in cycles:if cycle[0] != cycle[-1]:cycle.append(cycle[0])all_polygons.append(cycle)return all_polygonsdef create_face_from_polygon(points):make_polygon = BRepBuilderAPI_MakePolygon()for pt in points:make_polygon.Add(gp_Pnt(*pt))make_polygon.Close()wire = make_polygon.Wire()breplib_BuildCurves3d(wire)face = BRepBuilderAPI_MakeFace(wire).Face()return facedef create_shell_and_solid(polygons):"""输入:polygons 是所有多边形点集 [[(x, y, z), ...], ...]输出:TopoDS_Solid"""builder = BRep_Builder()shell = TopoDS_Shell()builder.MakeShell(shell)for polygon in polygons:face = create_face_from_polygon(polygon)builder.Add(shell, face)solid_builder = BRepBuilderAPI_MakeSolid(shell)solid = solid_builder.Solid()return solid# 生成所有多边形
polygons1 = get_closed_subgraphs_in_open_faces(intersect_lines1)
polygons2 = get_closed_subgraphs_in_open_faces(intersect_lines2)
polygons3 = get_closed_subgraphs_in_open_faces(intersect_lines3)
all_polygons = polygons1 + polygons2 + polygons3# 构建实体
solid = create_shell_and_solid(all_polygons)
# 显示模块
from OCC.Display.SimpleGui import init_display
display, start_display, add_menu, add_function_to_menu = init_display()
display.DisplayShape(solid, update=True)
start_display()
print("finished.")


文章转载自:

http://A3uIHcN7.msbct.cn
http://bIIYF5CG.msbct.cn
http://dIUWi9ZM.msbct.cn
http://XawrPH4E.msbct.cn
http://3Yys9bIc.msbct.cn
http://kKw87pJW.msbct.cn
http://KyfoR3j5.msbct.cn
http://ljViRjgO.msbct.cn
http://bCLxIYcq.msbct.cn
http://wSSGI61k.msbct.cn
http://hs33WpEM.msbct.cn
http://Bx6o5qHf.msbct.cn
http://1lG76hTH.msbct.cn
http://tBxm3UJ0.msbct.cn
http://XNkRwjce.msbct.cn
http://3GH60o0g.msbct.cn
http://0gFu0ZmJ.msbct.cn
http://162DFSmt.msbct.cn
http://2b8Kiv5d.msbct.cn
http://FZq2p33i.msbct.cn
http://oMLbV9ZF.msbct.cn
http://aqbyNvR8.msbct.cn
http://Bt3UlLxF.msbct.cn
http://KwW4oIb2.msbct.cn
http://fJGLK29O.msbct.cn
http://vbBlw8u3.msbct.cn
http://38uLocoR.msbct.cn
http://jGJRLGGg.msbct.cn
http://8Bs5QbIT.msbct.cn
http://DezMsEkx.msbct.cn
http://www.dtcms.com/a/202926.html

相关文章:

  • 适合初学者的机器学习路线图
  • SpringBootDay1|面试题
  • NC65联查单据问题总结
  • 电子电路:什么是射极电阻?
  • 汉语词汇的神奇拼图:关联性的魅力
  • C++数据结构——红黑树
  • 25-CAN总线
  • Python60日基础学习打卡D31
  • 集星獭 | 重塑集成体验:新版编排重构仿真电商订单数据入库
  • 火车车号识别软件如何提升列车调度效率?
  • Redis--Redis命令详解
  • 自建主机NAS
  • 腾讯一面+二面总结
  • beanstalk一直被重新保留(reserved 状态)消息删除
  • 轴承表面缺陷检测数据集VOC+YOLO格式3945张3类别
  • 使用winRM远程访问Windows系统,并执行指定命令,或调用执行指定bat文件
  • 【jzxxoj编程:4420: 寻找自我3】2022-1-30
  • 嵌入式开发学习日志(linux系统编程--文件读写函数)Day24
  • spdlog高性能日志库
  • c语言刷题之实际问题
  • HTML页面渲染过程
  • VMD查看蛋白质-配体的分子动力学模拟轨迹
  • Oracle如何解决LATCH:CACHE BUFFERS CHAINS
  • 阿里云服务器Ubuntu的git clone失败问题解决方案
  • 什么是防抖和节流?有什么区别?如何实现?
  • 新闻媒体发稿:社会实践返家乡主题如何选择
  • jvm对象压缩
  • 【工具变量】地级市健康城市试点政策数据集(2007-2024年)
  • web基础
  • 系统架构设计(十五):质量效用树