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

pythonocc进阶学习:投影projection

1.点 到 线,(直线,曲线)等上的投影

@staticmethod  # 点到Lin的投影
def Project_Pnt_To_Lin(p: gp_Pnt, lin: gp_Lin):Edge = BRepBuilderAPI_MakeEdge(lin).Edge()curve = BRep_Tool.Curve(Edge)proPnt = GeomAPI_ProjectPointOnCurve(p, curve[0])NearestPoint = proPnt.NearestPoint()return NearestPoint

2.点 到面上的投影

@staticmethod  # 点到Pln的投影
def project_point_on_plane(plane, point):pl = plane.Pln()aa, bb = projlib_Project(pl, point).Coord()point = plane.Value(aa, bb)return point

3.wire至shape上的投影:
参考:http://www.cppblog.com/eryar/archive/2016/08/16/214182.html

BRepProj_Projection
在这里插入图片描述

from OCC.Core.BRepBuilderAPI import BRepBuilderAPI_MakeEdge, BRepBuilderAPI_MakeWire, BRepBuilderAPI_Transform
from OCC.Core.BRepOffsetAPI import BRepOffsetAPI_ThruSections
from OCC.Core.BRepPrimAPI import BRepPrimAPI_MakeSphere
from OCC.Core.BRepProj import BRepProj_Projection
from OCC.Core.GC import GC_MakeArcOfCircle, GC_MakeSegment
from OCC.Core.TopoDS import topods
from OCC.Core.gp import gp_Pnt, gp_Trsf, gp_Dir,gp_OX
from OCC.Display.SimpleGui import init_displaydisplay, start_display, add_menu, add_function_to_menu = init_display()
sphere = BRepPrimAPI_MakeSphere(50).Shape()height = 70
width = 50
thickness = 30print("creating bottle")
# The points we'll use to create the profile of the bottle's body
aPnt1 = gp_Pnt(-width / 2.0, 0, 0)
aPnt2 = gp_Pnt(-width / 2.0, -thickness / 4.0, 0)
aPnt3 = gp_Pnt(0, -thickness / 2.0, 0)
aPnt4 = gp_Pnt(width / 2.0, -thickness / 4.0, 0)
aPnt5 = gp_Pnt(width / 2.0, 0, 0)aArcOfCircle = GC_MakeArcOfCircle(aPnt2, aPnt3, aPnt4)
aSegment1 = GC_MakeSegment(aPnt1, aPnt2)
aSegment2 = GC_MakeSegment(aPnt4, aPnt5)# Could also construct the line edges directly using the points instead of the resulting line
aEdge1 = BRepBuilderAPI_MakeEdge(aSegment1.Value())
aEdge2 = BRepBuilderAPI_MakeEdge(aArcOfCircle.Value())
aEdge3 = BRepBuilderAPI_MakeEdge(aSegment2.Value())# Create a wire out of the edges
aWire = BRepBuilderAPI_MakeWire(aEdge1.Edge(), aEdge2.Edge(), aEdge3.Edge())# Quick way to specify the X axis
xAxis = gp_OX()# Set up the mirror
aTrsf = gp_Trsf()
aTrsf.SetMirror(xAxis)# Apply the mirror transformation
aBRespTrsf = BRepBuilderAPI_Transform(aWire.Wire(), aTrsf)# Get the mirrored shape back out of the transformation and convert back to a wire
aMirroredShape = aBRespTrsf.Shape()# A wire instead of a generic shape now
aMirroredWire = topods.Wire(aMirroredShape)# Combine the two constituent wires
mkWire = BRepBuilderAPI_MakeWire()
mkWire.Add(aWire.Wire())
mkWire.Add(aMirroredWire)
myWireProfile = mkWire.Wire()
display.DisplayShape(myWireProfile, color='yellow', transparency=0.9, update=True)res = BRepProj_Projection(myWireProfile, Box1, gp_Dir(0, 0, 1)) # api
wire1 = res.Current()
res.Next()
wire2 = res.Current()generator = BRepOffsetAPI_ThruSections(True)
generator.AddWire(myWireProfile)
generator.AddWire(wire2)
generator.Build()
display.DisplayShape(generator.Shape(), color='black', transparency=0.9, update=True)
display.DisplayShape(sphere, color='black', transparency=0.9, update=True)
# display.DisplayShape(res.Current(), color='black', transparency=0.9, update=True)
start_display()

在这里插入图片描述

4.空间curve至pln的投影
GeomProjLib–》函数描述

from OCC.Core import GeomProjLib
from OCC.Core.Geom import Geom_Planefrom OCC.Core.gp import gp_Pnt, gp_Trsf, gp_Dir,gp_OX
from OCC.Display.SimpleGui import init_display
from OCC.Core.GeomAPI import GeomAPI_Interpolate
from OCC.Core.TColgp import TColgp_HArray1OfPnt
from OCC.Core.gp import gp_Pntdisplay, start_display, add_menu, add_function_to_menu = init_display()print("creating Plane")
plane = Geom_Plane(gp_Pnt(0,0,0),gp_Dir(0,0,1))print("creating bspline")
points = []
points=TColgp_HArray1OfPnt(1,3)
p1=gp_Pnt(0,6,2)
p2=gp_Pnt(2,1,3)
p3=gp_Pnt(6,2,1)points.SetValue(1,p1)
points.SetValue(2,p2)
points.SetValue(3,p3)
interp=GeomAPI_Interpolate(points,False,0.0001)
interp.Perform()
curve=interp.Curve() #Geom_BsplineCurve# project
proj=GeomProjLib.geomprojlib.ProjectOnPlane(curve,plane, gp_Dir(0, 0, 1),True)# display original curve and projected curve
display.DisplayShape(curve,color='blue',update=True)
display.DisplayShape(proj, color='red', update=True)start_display()

在这里插入图片描述

相关文章:

pythonocc进阶学习:投影projection

1.点 到 线,(直线,曲线)等上的投影 staticmethod # 点到Lin的投影 def Project_Pnt_To_Lin(p: gp_Pnt, lin: gp_Lin):Edge BRepBuilderAPI_MakeEdge(lin).Edge()curve BRep_Tool.Curve(Edge)proPnt GeomAPI_ProjectPointOnCurve(p, curve[0])Neares…...

Scractch3.0_Arduino_ESP32_学习随记_显示网络天气(二)

这里写目录标题 目的器材程序联系我们 目的 通过C02获取网络天气。并在屏上显示 器材 硬件: 齐护机器人C02 购买地址 软件: scratch3.0 下载地址:官网下载 程序 使用的是公开免费的API,对请求间隔和次数有限制,如果连续获取可能会被封IP&#xff…...

Mysql压力测试(sysbench)

目录 配置项目环境: 参考:采用sysbench压测mysql详解_dream21st的博客-CSDN博客 实验步骤: 1、安装sysbench工具 2、在master上创建用户和库,配置用户的权限可以使他可以访问库(Mysql的主从复制) 3、基…...

TBDS MPP参数列表

TBDS MPP参数列表 namesettingdescriptionapplication_namessqlSets the application name to be reported in statistics and logs.archive_cleanup_commandSets the shell command that will be executed at every restart point.archive_command(disabled)Sets the shell co…...

C# OpenCvSharp 读取rtsp流

效果 项目 代码 using OpenCvSharp; using OpenCvSharp.Extensions; using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading; using Syste…...

每日后端面试5题 第七天

一、内连接和外连接查询有什么区别? 内连接只查询出两表的交集; 外连接会查询出某表的全部与两表的交集。 二、Nginx的作用 1.反向代理 前端把请求发送给nginx,再由nginx将请求发送给后端服务器。 2.负载均衡 提高访问速度&#xff1b…...

计算机视觉的应用10-图片中的表格结构识别与提取实战

大家好,我是微学AI,今天给大家介绍一下计算机视觉的应用10-图片中的表格结构识别与提取实战,表格结构识别在信息处理领域中具有广泛应用,但由于表格的多样性和复杂性,以及难以准确解析的布局和格式,传统的方…...

P4178 Tree (点分治)

题目链接 一:我们考虑树上两点之间的路径有什么情况 1:经过根节点(即在根节点的两端) 2:不经过根节点(完全在一颗子树的一侧) 二:我们考虑这两种路径是否可以归为一类 1&#xff1…...

Kubernetes 二进制搭建

Kubernetes 二进制搭建 一、二进制搭建 Kubernetes v1.201.1 部署准备1.2 操作系统初始化配置1.3 部署 etcd 集群1.3.1 etcd 作为服务发现系统,有以下的特点1.3.2 准备签发证书环境1.3.3 在 master01 节点上操作1.3.4 生成证书 1.4 部署 docker引擎1.4.1 部署 Maste…...

QT QtXlsx安装使用

QtXlsx介绍 QtXlsx是一个可以读取和写入Excel文件的库。它不需要Microsoft Excel,可以在Qt5支持的任何平台上使用。 这里一定是需要QT5支持的。 须知安装QtXlsx时,需要下载perl 1.安装perl 这里选择官网下载安装即可。 官网地址:https://p…...

Java医院信息化HIS管理系统源码

HIS模板分为两种:病历模板和报表模板。模板管理是运营管理的核心组成部分,是基层卫生健康云中各医疗机构定制电子病历和报表的地方,各医疗机构可根据自身特点特色定制电子病历和报表,制作的电子病历及报表可直接在业务系统中使用。…...

【Uni-App】uview 开发多端应用,密码显示隐藏功能不生效问题

出现的问题: 使用uview组件u-input框密码绑定时会出现右侧密码显隐图标不显示的问题 思路: 1.看了下uview源码,发现这有一段注释,我们需要把源码修改一下,问题出在这里 这行代码修改为 :password"password || …...

人工智能算法-SVM, KNN

目录 SVM, KNN区别 一、KNN算法概述 算法的描述: 二、关于K的取值 K的取法: 三、关于距离的选取 Euclidean Distance 定义: 四、总结 SVM, KNN区别...

计算机网络—TCP

这里写目录标题 TCP头格式有哪些为什么需要TCP,TCP工作在哪什么是TCP什么是TCP连接如何确定一个TCP连接TCP和UDP的区别,以及场景TCP和UDP能共用一个端口?TCP的建立TCP三次握手过程为什么是三次握手、不是两次、四次why每次建立连接&#xff0…...

Oracle到DM实时数据同步实施方案

目录 1 项目概述 2 需求分析 3 实施操作 3.1 历史数据全量同步 3.2 增量数据实时同步 4 问题总结 4.1 字符型非空约束 4.2 字符型唯一索引尾部空格 1 项目概述 将Oracle 11g RAC生产环境数据同步到DM8分析环境,Oracle数据库大小1.5T,日增归档10…...

WebRTC | 音视频实时通信的本质

目录 一、音视频实时通信的两种指标 1. 实时通信延迟指标 2. 视频相关的基本概念 3. 音视频服务质量指标 二、解决实时通信的主要矛盾 1. 增加带宽 A. 提供更优质的接入服务 B. 保证云端网络的带宽和质量 C. 更合理的路由调度策略 2. 减少数据量 A. 采用更好的压缩算…...

ApiPost的使用

1. 设计接口 请求参数的介绍 Query:相当于get请求,写的参数在地址栏中可以看到 Body: 相当于 post请求,请求参数不在地址栏中显示。 请求表单类型,用form-data json文件类型,用row 2. 预期响应期望 设置完每一项点一下生成响应…...

6、CCS 配置工程头文件批量添加路径的方法

1、进入到图示的框框里 2、编辑好需要添加的路径,并按ctrl c 3、选中include paths(-I)框框里的最后一条路径 4、然后ctrl v,这样路径就复制到预定义路径里了...

Visual Studio配置PCL库

Visual Studio配置PCL库 Debug和Release配置新建项目配置属性表测试参考 Debug和Release Debug和Release的配置过程一模一样,唯一区别就在于最后一步插入的附加依赖项不同,因此下面以debug为例。 配置新建项目 1、新建一个C空项目,模式设置…...

数据分析 | 为什么Bagging算法的效果优于单个评估器

1. 回归问题如何降低方差 以随机森林为例,假设随机森林中含有n个弱评估器,由于子样本集的相似性以及使用的是同种模型,因此各模型有近似相等的方差和偏差,因此假设任意弱评估器上输出结果为,方差均为,则随机森林的输出…...

pytorch3d+pytorch1.10+MinkowskiEngine安装

1、配置pytorch1.10cuda11.0 pip install torch1.10.1cu111 torchvision0.11.2cu111 torchaudio0.10.1 -f https://download.pytorch.org/whl/cu111/torch_stable.html 2、配置 MinkowskiEngine库 不按下面步骤,出现错误 1、下载MinkowskiEngine0.5.4到本地 2、查看…...

Leetcode 1892. 页面推荐Ⅱ

1.题目基本信息 1.1.题目描述 表: Friendship ---------------------- | Column Name | Type | ---------------------- | user1_id | int | | user2_id | int | ---------------------- (user1_id,user2_id) 是 Friendship 表的主键(具有唯一值的列的组合…...

第16节 Node.js 文件系统

Node.js 提供一组类似 UNIX(POSIX)标准的文件操作API。 Node 导入文件系统模块(fs)语法如下所示: var fs require("fs") 异步和同步 Node.js 文件系统(fs 模块)模块中的方法均有异步和同步版本&#xff…...

【WPF】从普通 ItemsControl 到支持筛选的 ItemsControl:深入掌握 CollectionViewSource 用法

✨ 从普通 ItemsControl 到支持筛选的 ItemsControl:深入掌握 CollectionViewSource 用法 在日常 WPF 开发中,我们经常需要对数据进行筛选、排序、分组等操作,而原生的 ItemsControl 并不直接支持这些功能。本文将介绍如何通过 CollectionVi…...

蓝桥杯国赛题2022

首先这个题应该是一个01背包,背包容量为2022,有2022个物品,第i个物品的体积为i,只不过这里有两个限制条件,一个限制条件是和为2022,另一个限制条件为10个数,两个限制条件那就把加一维&#xff0…...

动态规划之网格图模型(二)

文章目录 动态规划之网格图模型(二)LeetCode 931. 下降路径最小和思路Golang 代码 LeetCode 2684. 矩阵中移动的最大次数思路Golang 代码 LeetCode 2304. 网格中的最小路径代价思路Golang 代码 LeetCode 1289. 下降路径最小和 II思路Golang 代码 LeetCod…...

AI推荐系统演进史:从协同过滤到图神经网络与强化学习的融合

每一次滑动手机屏幕,电商平台向你推荐心仪商品的背后,是超过百亿量级的浮点运算。从早期的“猜你喜欢”到如今的“比你更懂你”,商品推荐引擎已悄然完成从简单规则到深度智能的技术跃迁。 一、协同过滤:推荐系统的基石与演进 协同…...

LlamaIndex 工作流简介以及基础工作流

什么是工作流? 工作流是一种由事件驱动、基于步骤的应用程序执行流程控制方式。 你的应用程序被划分为多个称为“步骤(Steps)”的部分,这些步骤由“事件(Events)”触发,并且它们自身也会发出事…...

创客匠人:以 AI 利器赋能创始人 IP 打造,加速知识变现新路径

在知识付费与个人 IP 崛起的时代,创客匠人作为行业领先的技术服务商,正通过 AI 工具重构创始人 IP 打造与知识变现的生态。其推出的三大 AI 利器 ——AI 销售信、免训数字人、AI 智能客服,精准解决 IP 运营中的核心痛点。 以 AI 销售信为例&…...

LMG1020YFFR 电子元器件详解

LMG1020YFFR 电子元器件详解 基本概述 LMG1020YFFR是德州仪器(TI)生产的一款高性能、低侧栅极驱动器,属于其GaN(氮化镓)功率器件驱动产品系列。 主要功能特性 驱动能力: 峰值输出电流:5A/-5A 可驱动GaN FETs、SiC MOSFETs和高速硅MOSFETs…...