??xml version="1.0" encoding="utf-8" standalone="yes"?>999911111:C++博客-首页原创_֍?/title><link>//www.owiwv.icu/</link><description>专注于C++技?/description><language>zh - ڲͼ//www.owiwv.icu/eryar/archive/2019/08/06/animation.htmleryareryarTue, 06 Aug 2019 03:07:00 GMT//www.owiwv.icu/eryar/archive/2019/08/06/animation.html//www.owiwv.icu/eryar/comments/216643.html//www.owiwv.icu/eryar/archive/2019/08/06/animation.html#Feedback0//www.owiwv.icu/eryar/comments/commentRss/216643.html//www.owiwv.icu/eryar/services/trackbacks/216643.htmlOpenCASCADE动画功能

 

eryar@163.com


1.Introduction

OpenCASCADE提供了类AIS_Animation{来实现单的动画功能?/span>

 

从其cd可以看出Q动d能有两种Q一U是相机的动?/span>AnimationCameraQ一U是模型的动?/span>AnimationObject。因?/span>OpenCASCADE不像OpenSceneGraph那样是专门做仿真动画的,内置多线E,OpenCASCADE中的动画可以理解Z?/span>while(true) {update();}Q即在动L间内对相机或模型的v始位|和l止位置q行插值ƈ更新来实现动甅R对于简单的动画效果Q这U方式是够用了?/span>

 

2. Examples

?/span>OpenCASCADE的源码文件夹中提供了动画用法的示例,分别演示了模型变换、视囑֏换及动M存成视频文gQ当然这个功能需要引入第三方?/span>FFmpegQ?/span>

OpenCASCADE中动M间位|的生成采用了类gp_TrsfNLerpq行插倹{?/span>

 Ҏ其注释是对一个变换的三个部分分别q行U性插|旋{部分采用四元数类q行插倹{这U插值方式不可能满复杂动画的要求,不过可以把这个类当成一个插值的例子?/span>

?/span>Draw Test Harness中输入以下命令:

source tests/v3d/anim/propeller

vanim anim -play -playSpeed 0.1

卛_以让一个螺旋桨动v来了Q?/span>

其实q个螺旋桨动L个复杂的例子Q包含了视图动画和模型动甅R对于简单的CZQ可以参考另外几个文Ӟ里面的例子是相对单的?/span>

 

3. Conclusion

OpenCASCADE7.3版本中引入了单动ȝ功能Q结合其试案例Q找到其实现源码Q可以方便地在程序中实现单的动画功能。其中动L持两U方式:一U是视图支画Q一U是模型动画。视囑֊M般用于两个视图之间的动画q渡Q如从主视图切换CԒ视图中间加一个动画过渡;模型动画可用于简单的动画仿真?/span>

 

 

 

 

 

 

 

 



eryar 2019-08-06 11:07 发表评论
]]>
使用CString GetBuffer自适应获取计算机名U?/title><link>//www.owiwv.icu/qinqing1984/archive/2019/07/31/216616.html</link><dc:creator>春秋十二?/dc:creator><author>春秋十二?/author><pubDate>Wed, 31 Jul 2019 04:51:00 GMT</pubDate><guid>//www.owiwv.icu/qinqing1984/archive/2019/07/31/216616.html</guid><wfw:comment>//www.owiwv.icu/qinqing1984/comments/216616.html</wfw:comment><comments>//www.owiwv.icu/qinqing1984/archive/2019/07/31/216616.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>//www.owiwv.icu/qinqing1984/comments/commentRss/216616.html</wfw:commentRss><trackback:ping>//www.owiwv.icu/qinqing1984/services/trackbacks/216616.html</trackback:ping><description><![CDATA[   Z减少E序中的编码,灉|按需理字符串空_使用了ATL中的CStringc,代码如下<br /> <div style="background-color: #eeeeee; font-size: 13px; border: 1px solid #cccccc; padding: 4px 5px 4px 4px; width: 98%; word-break: break-all;"><!--<br /> <br /> Code highlighting produced by Actipro CodeHighlighter (freeware)<br /> //www.CodeHighlighter.com/<br /> <br /> --><span style="color: #008080; "> 1</span>         CString bstrComPathName;<br /> <span style="color: #008080; "> 2</span>         WCHAR componentPathName[1];<br /> <span style="color: #008080; "> 3</span>         DWORD dwNameLen = 1;    <br /> <span style="color: #008080; "> 4</span> <br /> <span style="color: #008080; "> 5</span>         <span style="color: #0000FF; ">if</span> (!GetComputerNameEx(<span style="color: #ff00ff;">ComputerNamePhysicalDnsFullyQualified</span>, componentPathName, &dwNameLen))<br /> <span style="color: #008080; "> 6</span>         { <br /> <span style="color: #008080; "> 7</span>             DWORD dwErr = GetLastError();<br /> <span style="color: #008080; "> 8</span>             <span style="color: #0000FF; ">if</span>(<span style="color: #ff0000;">ERROR_MORE_DATA</span>==dwErr)<br /> <span style="color: #008080; "> 9</span>             {            <br /> <span style="color: #008080; ">10</span>                 <span style="color: #0000FF; ">if</span> (!GetComputerNameEx(ComputerNamePhysicalDnsFullyQualified, bstrComPathName.<span style="color: #993366;"><strong class="oese">GetBuffer</strong></span>(dwNameLen), &dwNameLen))<br /> <span style="color: #008080; ">11</span>                 { <br /> <span style="color: #008080; ">12</span>                     zlog_error(g_zc, "GetComputerNameEx with ComputerNamePhysicalDnsFullyQualified fail: %d", GetLastError());<br /> <span style="color: #008080; ">13</span>                     <span style="color: #0000FF; ">return</span> -1;<br /> <span style="color: #008080; ">14</span>                 }<br /> <span style="color: #008080; ">15</span>             }<br /> <span style="color: #008080; ">16</span>             <span style="color: #0000FF; ">else</span><br /> <span style="color: #008080; ">17</span>             {<br /> <span style="color: #008080; ">18</span>                 zlog_error(g_zc, "GetComputerNameEx with ComputerNamePhysicalDnsFullyQualified for fail: %d", dwErr);<br /> <span style="color: #008080; ">19</span>                 <span style="color: #0000FF; ">return</span> -1;<br /> <span style="color: #008080; ">20</span>             }<br /> <span style="color: #008080; ">21</span>         }                <br /> <span style="color: #008080; ">22</span>         bstrComPathName.<span style="color: #993366;"><strong class="oese">ReleaseBuffer</strong></span>(); </div>     需要注意的是,GetBufferҎ虽提供方便了直接修改CString对象的内部缓冲区Q但q背了面向对象设计的原则Q由公开Ҏ修改内部数据Q,因此不保证对象的完整性,在操作完成后一定要调用ReleaseBuffer<img src ="//www.owiwv.icu/qinqing1984/aggbug/216616.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="//www.owiwv.icu/qinqing1984/" target="_blank">春秋十二?/a> 2019-07-31 12:51 <a href="//www.owiwv.icu/qinqing1984/archive/2019/07/31/216616.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>PipeCAD ?/title><link>//www.owiwv.icu/eryar/archive/2019/07/24/pipecad.html</link><dc:creator>eryar</dc:creator><author>eryar</author><pubDate>Wed, 24 Jul 2019 15:28:00 GMT</pubDate><guid>//www.owiwv.icu/eryar/archive/2019/07/24/pipecad.html</guid><wfw:comment>//www.owiwv.icu/eryar/comments/216597.html</wfw:comment><comments>//www.owiwv.icu/eryar/archive/2019/07/24/pipecad.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>//www.owiwv.icu/eryar/comments/commentRss/216597.html</wfw:commentRss><trackback:ping>//www.owiwv.icu/eryar/services/trackbacks/216597.html</trackback:ping><description><![CDATA[<p style="margin-top: 0.42cm; margin-bottom: 0.21cm; line-height: 100%; page-break-after: avoid;" align="center"><span style="font-family: Liberation Sans, serif;"><span style="font-size: xx-large;"><strong class="oese">PipeCAD </strong></span></span><span style="font-family: Noto Sans CJK SC Regular;"><span style="font-size: xx-large;"><span lang="zh-CN"><strong class="oese">?/strong></span></span></span></p> <p style="margin-top: 0.42cm; margin-bottom: 0.21cm; line-height: 100%; page-break-after: avoid;" align="center"> </p> <!-- p { margin-bottom: 0.25cm; direction: ltr; color: #000000; line-height: 115%; text-align: left; }p.western { font-family: "Liberation Serif", serif; font-size: 12pt; }p.cjk { font-family: "Noto Sans CJK SC Regular"; font-size: 12pt; }p.ctl { font-family: "Lohit Devanagari"; font-size: 12pt; } --> <p> </p> <p>PipeCAD的定位是中小型项目的道设计软gQ主要有道建模、设备徏模以及管道ISO囑֏q面囑֊能。程序的操作方式量参考PDMSQ考虑灉|性、易于用。如果用来和国内其他道设计软g来对比,主要优势是Z独立囑Şq_Q不依赖W三方图形^台如AutoCADQ程序安装好卛_q行?/p> <p class="western" style="margin-bottom: 0cm; line-height: 100%;"><span style="font-family: Noto Sans CJK SC Regular;"><span lang="zh-CN">已经搭徏好程序框Ӟ也是量?/span></span>PDMS<span style="font-family: Noto Sans CJK SC Regular;"><span lang="zh-CN">的设计树保持一_支持</span></span>Undo/Redo<span style="font-family: Noto Sans CJK SC Regular;"><span lang="zh-CN">?/span></span></p> <!-- p { margin-bottom: 0.25cm; direction: ltr; color: #000000; line-height: 115%; text-align: left; }p.western { font-family: "Liberation Serif", serif; font-size: 12pt; }p.cjk { font-family: "Noto Sans CJK SC Regular"; font-size: 12pt; }p.ctl { font-family: "Lohit Devanagari"; font-size: 12pt; } --> <p><img src="https://img2018.cnblogs.com/blog/327602/201907/327602-20190724225425330-697139731.png" alt="" /></p> <p class="western" style="margin-bottom: 0cm; line-height: 100%;"><span style="font-family: Noto Sans CJK SC Regular;"><span lang="zh-CN">因ؓ?/span></span>PipeStd<span style="font-family: Noto Sans CJK SC Regular;"><span lang="zh-CN">模块来定义管件图形,所以可以基于此来开发导入管道数据交换常见的</span></span>PCF/IDF<span style="font-family: Noto Sans CJK SC Regular;"><span lang="zh-CN">文g。通过定义道</span></span>Specification<span style="font-family: Noto Sans CJK SC Regular;"><span lang="zh-CN">Q可以方便地?/span></span>PCF/IDF<span style="font-family: Noto Sans CJK SC Regular;"><span lang="zh-CN">中的g数据q行匚wQ从而真实还原其三维模型。下图所CZؓ一个法兰的参数化模型?/span></span></p> <p class="western" style="margin-bottom: 0cm; line-height: 100%;"><span style="font-family: Noto Sans CJK SC Regular;"><span lang="zh-CN"><img src="https://img2018.cnblogs.com/blog/327602/201907/327602-20190724225458241-1651796036.png" alt="" /></span></span></p> <p class="western" style="margin-bottom: 0cm; line-height: 100%;"><span style="font-family: Noto Sans CJK SC Regular;"><span lang="zh-CN">先开发导?/span></span>IDF<span style="font-family: Noto Sans CJK SC Regular;"><span lang="zh-CN">Q?/span></span>ISOGEN Data File<span style="font-family: Noto Sans CJK SC Regular;"><span lang="zh-CN">Q来?/span></span>Intergraph PDS and AVEVA PDMS<span style="font-family: Noto Sans CJK SC Regular;"><span lang="zh-CN">Q?/span></span>PCF<span style="font-family: Noto Sans CJK SC Regular;"><span lang="zh-CN">Q?/span></span>Piping Component File<span style="font-family: Noto Sans CJK SC Regular;"><span lang="zh-CN">Q来?/span></span>Intergraph SmartPlant 3D<span style="font-family: Noto Sans CJK SC Regular;"><span lang="zh-CN">{?/span></span>ISOGEN<span style="font-family: Noto Sans CJK SC Regular;"><span lang="zh-CN">的设计YӞQ实C设计?/span></span>/<span style="font-family: Noto Sans CJK SC Regular;"><span lang="zh-CN">工程设计公司的设计数据无~对接。导入管?/span></span>IDF/PCF<span style="font-family: Noto Sans CJK SC Regular;"><span lang="zh-CN">文g后,可以方便地查看三l模型,q且通过点击相应g的三l模型,在属性窗口中会显C出g相关的信息,如管道等U、管件类型、材料代受材料描q等?/span></span></p> <p class="western" style="margin-bottom: 0cm; line-height: 100%;"><span style="font-family: Noto Sans CJK SC Regular;"><span lang="zh-CN"><img src="https://img2018.cnblogs.com/blog/327602/201907/327602-20190724225555454-973890436.png" alt="" /></span></span></p> <p class="western" style="margin-bottom: 0cm; line-height: 100%;"><span style="font-family: Noto Sans CJK SC Regular;"><span lang="zh-CN">下面录一个简单的视频来介l一下程序的用法及现在已l实现的功能Q?/span></span></p> <p class="western" style="margin-bottom: 0cm; line-height: 100%;"><span style="font-family: Noto Sans CJK SC Regular;"><span lang="zh-CN"><img src="https://img2018.cnblogs.com/blog/327602/201907/327602-20190724225621159-1372735712.gif" alt="" /></span></span></p> <p class="western" style="margin-bottom: 0cm; line-height: 100%;"> </p> <!-- p { margin-bottom: 0.25cm; direction: ltr; color: #000000; line-height: 115%; text-align: left; }p.western { font-family: "Liberation Serif", serif; font-size: 12pt; }p.cjk { font-family: "Noto Sans CJK SC Regular"; font-size: 12pt; }p.ctl { font-family: "Lohit Devanagari"; font-size: 12pt; } --> <p class="western" style="margin-bottom: 0cm; line-height: 100%;"> </p> <p class="western" style="margin-bottom: 0cm; line-height: 100%;"> </p> <p class="western" style="margin-bottom: 0cm; line-height: 100%;"> </p> <!-- p { margin-bottom: 0.25cm; direction: ltr; color: #000000; line-height: 115%; text-align: left; }p.western { font-family: "Liberation Serif", serif; font-size: 12pt; }p.cjk { font-family: "Noto Sans CJK SC Regular"; font-size: 12pt; }p.ctl { font-family: "Lohit Devanagari"; font-size: 12pt; } --> <p class="western" style="margin-bottom: 0cm; line-height: 100%;"> </p> <p class="western" style="margin-bottom: 0cm; line-height: 100%;"> </p> <p class="western" style="margin-bottom: 0cm; line-height: 100%;"> </p> <!-- p { margin-bottom: 0.25cm; direction: ltr; color: #000000; line-height: 115%; text-align: left; }p.western { font-family: "Liberation Serif", serif; font-size: 12pt; }p.cjk { font-family: "Noto Sans CJK SC Regular"; font-size: 12pt; }p.ctl { font-family: "Lohit Devanagari"; font-size: 12pt; } --> <p> </p><img src ="//www.owiwv.icu/eryar/aggbug/216597.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="//www.owiwv.icu/eryar/" target="_blank">eryar</a> 2019-07-24 23:28 <a href="//www.owiwv.icu/eryar/archive/2019/07/24/pipecad.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>PipeCAD之管道标准库PipeStd(3) - ڲͼ//www.owiwv.icu/eryar/archive/2019/07/15/pipestd3.htmleryareryarMon, 15 Jul 2019 11:04:00 GMT//www.owiwv.icu/eryar/archive/2019/07/15/pipestd3.html//www.owiwv.icu/eryar/comments/216555.html//www.owiwv.icu/eryar/archive/2019/07/15/pipestd3.html#Feedback0//www.owiwv.icu/eryar/comments/commentRss/216555.html//www.owiwv.icu/eryar/services/trackbacks/216555.htmlPipeCAD之管道标准库PipeStd(3)

Key Words: PipeCAD, PipeStd, Pipe Design 3D, Linux

1. Introduction
    道标准部g库程序PipeStd的思\与PDMS的ParagoncMQ主要也是采用参数化的方式来表示g。在PipeStd中定义好g的参数化模型及管道等U数据后Q就可以为后面管道的建模打好基础?br />    E序主要用C++开发,所以可以跨q_q行Q即可以在Linuxpȝ中运行,也可以在Windowspȝ中运行。如下图所CZؓE序在Ubuntupȝ中运行的截图Q?/p>


E序界面主要分ؓ两部分:数据D树和三维视图区。数据导航树中显C定义的g数据和管道等U信息。三l视囑֌用来昄参数化的g模型。上图三l显C区昄的是一个法兰型?br />
2. Catalogue
    g参数化模型的定义昄在Catalogue中,考虑到管件标准有限且便于自定义,卛_以定义Q何三l模型,所以提供了参数化徏模的方式Q?/p>


通过参数化的方式q戯定义g的模型,理论上可以定义Q意三l模型?/p>

上图为定义的阀门参数化模型?br />
3. Specification
    道{Specification是用来控制管道徏模时的材料,只有加入到管道等U中的管件才能在建模的时候用,q样避免管道三l徏模的时候选择了错误的材。管道等U是由材料控制工E师或管理员来控制?/p>


上图的设计导航树上有一个SPEC WorldQ显C定义的所有管道等U数据?br />
4. Conclusion
    有了g参数化模型及道{数据Q下一步可以在此基上实C个管道徏模出囄E序。程序自d发,可以跨^台运行?/p>

eryar 2019-07-15 19:04 发表评论
]]>
Installing Node.js and Express on Ubuntu - ڲͼ//www.owiwv.icu/eryar/archive/2019/07/08/ubuntu_nodejs.htmleryareryarMon, 08 Jul 2019 04:10:00 GMT//www.owiwv.icu/eryar/archive/2019/07/08/ubuntu_nodejs.html//www.owiwv.icu/eryar/comments/216511.html//www.owiwv.icu/eryar/archive/2019/07/08/ubuntu_nodejs.html#Feedback0//www.owiwv.icu/eryar/comments/commentRss/216511.html//www.owiwv.icu/eryar/services/trackbacks/216511.htmlInstalling Node.js and Express on Ubuntu

1. 在nodejs官网上下载Linux Binaries(已经包含了npm):

2. 安装Node.js
下蝲后解压,q在解压的文件夹中启动Terminal后,输入命oQ?br />    sudo cp * /usr/local/ -r
再输入命令:
    node -v
    npm -v
查看E序版本Q来是否成功安装:


3. 安装express
    npm install -g express-generator

4. 试Node和Express
用Cesium来测试一下安装是否成功,q入到Cesium源码文g夹,输入命oQ?br />Node server.js


表示启动成功Q在览器中输入|址Q//localhost:8080/


点击链接Hello World出现下面的这个地球:





eryar 2019-07-08 12:10 发表评论
]]>
Boost test vs2013 fatal error C1001 - ڲͼ//www.owiwv.icu/eryar/archive/2019/07/06/boost_test.htmleryareryarSat, 06 Jul 2019 04:54:00 GMT//www.owiwv.icu/eryar/archive/2019/07/06/boost_test.html//www.owiwv.icu/eryar/comments/216504.html//www.owiwv.icu/eryar/archive/2019/07/06/boost_test.html#Feedback0//www.owiwv.icu/eryar/comments/commentRss/216504.html//www.owiwv.icu/eryar/services/trackbacks/216504.html999911111:Boost test vs2013 fatal error C1001

?span style="font-family: 'Times New Roman';">Visual Studio 2013中?/span>boost?/span>test模块时会报致命错误,如下图所C:

输出报错信息如下Q?/p>

1>------ Build started: Project: Test, Configuration: Debug Win32 ------

1>  main.cpp

1>d:\boost_1_70_0\boost\type_traits\common_type.hpp(47): fatal error C1001: An internal error has occurred in the compiler.

1>  (compiler file 'msc1.cpp', line 1325)

1>   To work around this problem, try simplifying or changing the program near the locations listed above.

1>  Please choose the Technical Support command on the Visual C++ 

1>   Help menu, or open the Technical Support help file for more information

========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

 

定位到报错文件是common_type.hppQ?/span>

 

可以看出是因为CXX11的原因,因ؓVS2013不支?/span>C++11Q所?/span>boost提供了一个宏定义来设|是否支?/span>CXX11Q?/span>

BOOST_NO_CXX11_TEMPLATE_ALIASES

在Project->Properties->C/C++->Preprocessor中设|即可:

 

 


Z方便大家在移动端也能看到我的博文和讨Z,现已注册微信公众PƢ迎大家扫描下方二维码关注?/h5>Shing Liu(eryar@163.com)


eryar 2019-07-06 12:54 发表评论
]]>
最二乘法拟合直线 - ڲͼ//www.owiwv.icu/eryar/archive/2019/07/04/fitline.htmleryareryarThu, 04 Jul 2019 08:26:00 GMT//www.owiwv.icu/eryar/archive/2019/07/04/fitline.html//www.owiwv.icu/eryar/comments/216484.html//www.owiwv.icu/eryar/archive/2019/07/04/fitline.html#Feedback0//www.owiwv.icu/eryar/comments/commentRss/216484.html//www.owiwv.icu/eryar/services/trackbacks/216484.html最二乘法拟合直线

在科学实验和生实践中,l常需要从一l实验数据出发寻求函?/span>y=f(x)的一个近D辑ּQ也UCؓl验公式。从几何上看Q就是希望根据给定的m个点Q求曲线y=f(x)的一条近似曲Uѝ因此这是个曲线拟合问题?/span>

当我们要求近似曲U严格通过l定的每个点Ӟq是插值算法。对于本文所q的直线拟合来说Q如果用插值算法,则只需要两个点够了。实际直U拟合数据可能满不了这个条ӞZ便于计算Q分析与应用Q我们较多地Ҏ“使测量点到直U距ȝqx和最?rdquo;的原则来拟合。按最二乘原则选择拟合曲线的方法,UCؓ最二乘法Q?/span>Method of Least SquaresQ?/span>

利用最二乘法拟合曲线的一般步骤是Q?/span>

  • 实验数据显C出来,分析曲线的Ş式;

  • 定拟合曲线的Ş式。对于本文来_曲线形式是直U,y=a+bx;

  • 建立法方E组q对其进行求解;

 

因ؓOpenCASCADE中数据结构及法丰富Q所以用OpenCASCADE可以快速实现直U的最二乘法拟合法。下面给出具体实C码:

#include <iostream>
#include <gp_Lin2d.hxx>
#include <gp_Pnt2d.hxx>
#include <TColgp_Array1OfPnt2d.hxx>
#include <math_Vector.hxx>
#include <math_SVD.hxx>
#include <math_Gauss.hxx>
#include <math_GaussLeastSquare.hxx>
#include <OSD_Chronometer.hxx>
void fitLine(const TColgp_Array1OfPnt2d& thePoints,
             const std::string& theFileName,
             gp_Lin2d& theLine)
{
    math_Vector aB(1, 2, 0.0);
    math_Vector aX(1, 2, 0.0);
    math_Matrix aM(1, 2, 1, 2);
    Standard_Real aSxi = 0.0;
    Standard_Real aSyi = 0.0;
    Standard_Real aSxx = 0.0;
    Standard_Real aSxy = 0.0;
    std::ofstream aDrawFile(theFileName);
    for (Standard_Integer i = thePoints.Lower(); i <= thePoints.Upper(); ++i)
    {
        const gp_Pnt2d& aPoint = thePoints.Value(i);
        aSxi += aPoint.X();
        aSyi += aPoint.Y();
        aSxx += aPoint.X() * aPoint.X();
        aSxy += aPoint.X() * aPoint.Y();
        aDrawFile << "vpoint p" << i << " " <<
                     aPoint.X() << " " << aPoint.Y() << " 0" << std::endl;
    }
    aM(1, 1) = thePoints.Size();
    aM(1, 2) = aSxi;
    aM(2, 1) = aSxi;
    aM(2, 2) = aSxx;
    aB(1) = aSyi;
    aB(2) = aSxy;
    OSD_Chronometer aChronometer;
    aChronometer.Start();
    math_Gauss aSolver(aM);
    //math_GaussLeastSquare aSolver(aM);
    //math_SVD aSolver(aM);
    aSolver.Solve(aB, aX);
    if (aSolver.IsDone())
    {
        Standard_Real aA = aX(1);
        Standard_Real aB = aX(2);
        gp_Pnt2d aP1(0.0, aA);
        gp_Pnt2d aP2(-aA/aB, 0.0);
        theLine.SetLocation(aP1);
        theLine.SetDirection(gp_Vec2d(aP1, aP2).XY());
        aDrawFile << "vaxis l "
                  << aP1.X() << " " << aP1.Y() << " 0 "
                  << aP2.X() << " " << aP2.Y() << " 0 " << std::endl;
        std::cout << "===================" << std::endl;
        aX.Dump(std::cout);
    }
    aChronometer.Stop();
    aChronometer.Show();
}
int main()
{
    gp_Lin2d aLine;
    // Test data 1
    TColgp_Array1OfPnt2d aPoints1(1, 6);
    aPoints1.SetValue(1, gp_Pnt2d(36.9, 181.0));
    aPoints1.SetValue(2, gp_Pnt2d(46.7, 197.0));
    aPoints1.SetValue(3, gp_Pnt2d(63.7, 235.0));
    aPoints1.SetValue(4, gp_Pnt2d(77.8, 270.0));
    aPoints1.SetValue(5, gp_Pnt2d(84.0, 283.0));
    aPoints1.SetValue(6, gp_Pnt2d(87.5, 292.0));
    fitLine(aPoints1, "fit1.tcl", aLine);
    // Test data 2
    TColgp_Array1OfPnt2d aPoints2(0, 7);
    aPoints2.SetValue(0, gp_Pnt2d(0.0, 27.0));
    aPoints2.SetValue(1, gp_Pnt2d(1.0, 26.8));
    aPoints2.SetValue(2, gp_Pnt2d(2.0, 26.5));
    aPoints2.SetValue(3, gp_Pnt2d(3.0, 26.3));
    aPoints2.SetValue(4, gp_Pnt2d(4.0, 26.1));
    aPoints2.SetValue(5, gp_Pnt2d(5.0, 25.7));
    aPoints2.SetValue(6, gp_Pnt2d(6.0, 25.3));
    aPoints2.SetValue(7, gp_Pnt2d(7.0, 24.8));
    fitLine(aPoints2, "fit2.tcl", aLine);
    return 0;
}

在函?/span>fitLine()中,Ҏ拟合点徏立法方程l,q?/span>math_Gauss来对法方E组q行求解。其实也可以使用math_GaussLeastSquare或?/span>math_SVD{求解法方程l。在d?/span>main()中测试了两组数据。测试数?/span>1来自易大义等《计方法》,试数据2来自《高{数学》。程序运行结果如下图所C:

与书中计结果吻合?/span>


׃需要将计算l果昄出来Q所以在fitLine()函数中增加了输出Draw脚本文g的代码,实际q用时可这部分代码L。将E序生成的脚本文件加载到Draw中,卛_得到下面两个图:

试数据1拟合直线


试数据2拟合直线


lg所qͼ对于二维直线的最二乘法拟合法的关键是对徏立的法方E组q行求解?/span>OpenCASCADE?/span>math包中提供了一些解方程l的cd以直接用。对于没有?/span>OpenCASCADE的开发环境的情况Q也可以使用其他矩阵库,?/span>Eigen{用得很q泛?/span>Eigen官方|站Q?/span>//eigen.tuxfamily.org/index.php?title=Main_Page


计结果导?/span>Draw脚本可视化,可以方便直观地查看拟合结果。如果熟悉其他脚本库?/span>Python?/span>matplotlibQ也可以cM处理来将l果可视化?/span>



eryar 2019-07-04 16:26 发表评论
]]>
RvmTranslator for Linux - ڲͼ//www.owiwv.icu/eryar/archive/2019/06/24/rvmtranslator_linux.htmleryareryarMon, 24 Jun 2019 11:27:00 GMT//www.owiwv.icu/eryar/archive/2019/06/24/rvmtranslator_linux.html//www.owiwv.icu/eryar/comments/216449.html//www.owiwv.icu/eryar/archive/2019/06/24/rvmtranslator_linux.html#Feedback0//www.owiwv.icu/eryar/comments/commentRss/216449.html//www.owiwv.icu/eryar/services/trackbacks/216449.htmlRvmTranslator for Linux
eryar@163.com

RvmTranslator can translate the RVM file exported by AVEVA Plant(PDMS)/AVEVA Marine to STEP, IGES, STL, DXF, 3D PDF, OBJ, 3DXML, IFC,.etc. So it can be used for exchanging model data between other CAD software, such as Autodesk AutoCAD, Plant3d, 3ds Max, CATIA, Solidworks, Pro/E, Unity3d, .etc.
RvmTranslator可以AVEVA PDMS/Plant/Marine中导出的RVM文gq行可视化,以及RVM转换成常见的三维文g格式。如STEPQIGESQSTLQDXF, OBJ, 3DPDF, 3DXML, IFC{,便于与其他CADpȝq行数据交换Q如Autodesk AutoCAD, Plant3d, 3ds Max, CATIA, Solidworks, Pro/E, Unity3d, Bentley{?br />
׃使用的是跨^台的Qt{开源库Q现在将RvmTranslatorUL到Linuxpȝ中,如下图所CZؓRvmTranslator在Ubuntupȝ中的界面Q?br />

支持RVM文g中的中文字符Q?br />

RVM是AVEVA的一个统一模型格式Q包括其收购的船舶系lTribon也可以导出RVM格式的文件?/p>

上图体结构,


上图舶管路,因ؓ船体I间相对狭小Q船舶管路布|的密集些?br />
在Ubuntupȝ上试了下开发环境,觉得q比较顺手。开发的IDE可以用Qt CreatorQ基本满编码,调试的要求。用Qt Creatorq有一个好处就是方便代码的跨^台移植,在Ubuntu上的代码以Qt?.pro形式保存Q可以直接在Visual Studio中用Qt VS Addin打开~译?br />


Z方便大家在移动端也能看到我的博文和讨Z,现已注册微信公众PƢ迎大家扫描下方二维码关注?/h5> Shing Liu(eryar@163.com)


eryar 2019-06-24 19:27 发表评论
]]>
RvmTranslator7.1 - ڲͼ//www.owiwv.icu/eryar/archive/2019/06/15/rvmtranslator7_1.htmleryareryarSat, 15 Jun 2019 02:04:00 GMT//www.owiwv.icu/eryar/archive/2019/06/15/rvmtranslator7_1.html//www.owiwv.icu/eryar/comments/216404.html//www.owiwv.icu/eryar/archive/2019/06/15/rvmtranslator7_1.html#Feedback0//www.owiwv.icu/eryar/comments/commentRss/216404.html//www.owiwv.icu/eryar/services/trackbacks/216404.html

RvmTranslator7.1

eryar@163.com

 

RvmTranslator can translate the RVM file exported by AVEVA Plant(PDMS)/AVEVA Marine to STEP, IGES, STL, DXF, 3D PDF, OBJ, 3DXML, IFC,.etc. So it can be used for exchanging model data between other CAD software, such as Autodesk AutoCAD, Plant3d, 3ds Max, CATIA, Solidworks, Pro/E, Unity3d, .etc.

RvmTranslator可以?/span>AVEVA PDMS/Plant/Marine中导出的RVM文gq行可视化,以及?/span>RVM转换成常见的三维文g格式。如STEPQ?/span>IGESQ?/span>STLQ?/span>DXF, OBJ, 3DPDF, 3DXML, IFC{,便于与其?/span>CADpȝq行数据交换Q如Autodesk AutoCAD, Plant3d, 3ds Max, CATIA, Solidworks, Pro/E, Unity3d, Bentley{?/span>

RvmTranslator7.1修复了设计树上中文显C问题:

下蝲RvmTranslator7.1: https://share.weiyun.com/5I8biQw

 


Z方便大家在移动端也能看到我的博文和讨Z,现已注册微信公众PƢ迎大家扫描下方二维码关注?/h5> Shing Liu(eryar@163.com)


eryar 2019-06-15 10:04 发表评论
]]>
OpenCASCADE直线与^面求?/title><link>//www.owiwv.icu/eryar/archive/2019/06/03/lineplaneint.html</link><dc:creator>eryar</dc:creator><author>eryar</author><pubDate>Mon, 03 Jun 2019 08:40:00 GMT</pubDate><guid>//www.owiwv.icu/eryar/archive/2019/06/03/lineplaneint.html</guid><wfw:comment>//www.owiwv.icu/eryar/comments/216393.html</wfw:comment><comments>//www.owiwv.icu/eryar/archive/2019/06/03/lineplaneint.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>//www.owiwv.icu/eryar/comments/commentRss/216393.html</wfw:commentRss><trackback:ping>//www.owiwv.icu/eryar/services/trackbacks/216393.html</trackback:ping><description><![CDATA[ <h2 align="center"><strong class="oese">OpenCASCADE<span style="font-family: 宋体;">直线与^面求?/span></strong></h2> <p><span style="font-family: 宋体;">在《解析几何》相关的书中都给Z直线和^面的一般方E和参数方程。其中直U的一般方E有点向式Ş式的?/span></p> <p align="center"><img src="https://img2018.cnblogs.com/blog/534255/201906/534255-20190603162247978-832152196.png" alt="" /></p> <p><span style="font-family: 宋体;">׃q空间一点可作且只能作一条直U^行于已知直线Q所以当直线上一点(</span>x0, y0, z0)<span style="font-family: 宋体;">和它的一方向向量Q?/span><span style="font-family: Calibri;">m,n,p)</span><span style="font-family: 宋体;">为已知时Q直U就完全定了。所以在</span><span style="font-family: Calibri;">OpenCASCADE</span><span style="font-family: 宋体;">中直U类</span><span style="font-family: Calibri;">gp_Lin</span><span style="font-family: 宋体;">有一个构造函敎ͼ</span></p> <p>gp_Lin (const gp_Pnt &P, const gp_Dir &V) <span style="font-family: 宋体;">即通过点和方向来构造直Uѝ由直线的点向式方程Ҏ导出直线的参数方E:</span></p> <p align="center"><img src="https://img2018.cnblogs.com/blog/534255/201906/534255-20190603162257277-2017434532.png" alt="" /></p> <p><span style="font-family: 宋体;">其中</span>OpenCASCADE<span style="font-family: 宋体;">的直U是用参数方E来表示的?/span></p> <p><span style="font-family: 宋体;">同理对于q面而言Q过I间一点可以作而且只能作一q面垂直于一已知直线Q所以^面的一点(</span>x0,y0,z0)<span style="font-family: 宋体;">和它的一个法U方?/span><span style="font-family: Calibri;">(A, B, C)</span><span style="font-family: 宋体;">为已知时Q^面就完全定了。所以^面方E也有点向式的:</span></p> <p><img src="https://img2018.cnblogs.com/blog/534255/201906/534255-20190603162309663-376377789.png" alt="" /></p> <p><span style="font-family: 宋体;">从一个点和两个不q的向量确定一个^面作论的出发点,可以得出q面的参数方E:</span></p> <p><img src="https://img2018.cnblogs.com/blog/534255/201906/534255-20190603162317894-220894722.png" alt="" /> </p> <p><span style="font-family: 宋体;">如上图所C,已知一个点</span>M0(x0,y0,z0)<span style="font-family: 宋体;">Q向?/span><span style="font-family: Calibri;">v1(x1,y1,z1)</span><span style="font-family: 宋体;">和向?/span><span style="font-family: Calibri;">v2(x2,y2,z2)</span><span style="font-family: 宋体;">Q我们来求点</span><span style="font-family: Calibri;">M0</span><span style="font-family: 宋体;">和向?/span><span style="font-family: Calibri;">V1</span><span style="font-family: 宋体;">Q?/span><span style="font-family: Calibri;">V2</span><span style="font-family: 宋体;">定的^面方E。点</span><span style="font-family: Calibri;">M(x,y,z)</span><span style="font-family: 宋体;">在^面上的充要条件是向量</span><span style="font-family: Calibri;">M0M</span><span style="font-family: 宋体;">?/span><span style="font-family: Calibri;">V1, V2</span><span style="font-family: 宋体;">共面。因为向?/span><span style="font-family: Calibri;">V1, V2</span><span style="font-family: 宋体;">不^行,所以共面的充要条g是存在唯一的一对实?/span><span style="font-family: Calibri;">u, v</span><span style="font-family: 宋体;">使:</span></p> <p><img src="https://img2018.cnblogs.com/blog/534255/201906/534255-20190603162331852-1495156293.png" alt="" /></p> <p><span style="font-family: 宋体;">向量</span>M0M<span style="font-family: 宋体;">?/span><span style="font-family: Calibri;">V1</span><span style="font-family: 宋体;">Q?/span><span style="font-family: Calibri;">V2</span><span style="font-family: 宋体;">共面的充要条件是Q?/span></p> <p><img src="https://img2018.cnblogs.com/blog/534255/201906/534255-20190603162530489-1079184086.png" alt="" /></p> <p><span style="font-family: 宋体;">Ҏq面的参数方E可知,要确定一个^面从参数方程的角度来看需要一个点和两个方向。从参数方程推导Z般方E的q程也是计算q面一般方E系数的Ҏ?/span></p> <p><span style="font-family: 宋体;">Ҏ直线的参数方E及q面的一般方E可以推导出直线与^面交点的计算公式Q推DE如下:</span></p> <p><img src="https://img2018.cnblogs.com/blog/534255/201906/534255-20190603162537534-652366768.png" alt="" /></p> <p><span style="font-family: 宋体;">从上面的推导q程可以看出Q计直U与q面的交点主要就是计参?/span>t<span style="font-family: 宋体;">Q当</span><span style="font-family: Calibri;">t</span><span style="font-family: 宋体;">求出后代入直U参数方E即可得C点坐标。从参数</span><span style="font-family: Calibri;">t</span><span style="font-family: 宋体;">的计公式可知,有个Ҏ情况是分母为零的情况,此时是直U与q面q共面需要特别处理?/span></p> <p><span style="font-family: 宋体;">?/span>OpenCASCADE<span style="font-family: 宋体;">中提供了直线与^面求交的计算c?/span><span style="font-family: Calibri;">IntAna_IntConicQuad</span><span style="font-family: 宋体;">Q其实现源码如下Q?/span></p> <p> </p> <div class="cnblogs_code"> <pre><span style="color: #0000ff;">void</span> IntAna_IntConicQuad::Perform (<span style="color: #0000ff;">const</span> gp_Lin& L, <span style="color: #0000ff;">const</span> gp_Pln&<span style="color: #000000;"> P, </span><span style="color: #0000ff;">const</span><span style="color: #000000;"> Standard_Real Tolang, </span><span style="color: #0000ff;">const</span><span style="color: #000000;"> Standard_Real Tol, </span><span style="color: #0000ff;">const</span><span style="color: #000000;"> Standard_Real Len) { </span><span style="color: #008000;">//</span><span style="color: #008000;"> Tolang represente la tolerance angulaire a partir de laquelle on considere </span><span style="color: #008000;">//</span><span style="color: #008000;"> que l angle entre 2 vecteurs est nul. On raisonnera sur le cosinus de cet </span><span style="color: #008000;">//</span><span style="color: #008000;"> angle, (on a Cos(t) equivalent a t au voisinage de Pi/2).</span> <span style="color: #000000;"> done</span>=<span style="color: #000000;">Standard_False; Standard_Real A,B,C,D; Standard_Real Al,Bl,Cl; Standard_Real Dis,Direc; P.Coefficients(A,B,C,D); gp_Pnt Orig(L.Location()); L.Direction().Coord(Al,Bl,Cl); Direc</span>=A*Al+B*Bl+C*<span style="color: #000000;">Cl; Dis </span>= A*Orig.X() + B*Orig.Y() + C*Orig.Z() +<span style="color: #000000;"> D; </span><span style="color: #008000;">// </span> parallel=<span style="color: #000000;">Standard_False; </span><span style="color: #0000ff;">if</span> (Abs(Direc) <<span style="color: #000000;"> Tolang) { parallel</span>=<span style="color: #000000;">Standard_True; </span><span style="color: #0000ff;">if</span> (Len!=<span style="color: #800080;">0</span> && Direc!=<span style="color: #800080;">0</span><span style="color: #000000;">) { </span><span style="color: #008000;">//</span><span style="color: #008000;">check the distance from bounding point of the line to the plane</span> <span style="color: #000000;"> gp_Pnt aP1, aP2; </span><span style="color: #008000;">// </span> aP1.SetCoord(Orig.X()-Dis*A, Orig.Y()-Dis*B, Orig.Z()-Dis*<span style="color: #000000;">C); aP2.SetCoord(aP1.X()</span>+Len*Al, aP1.Y()+Len*Bl, aP1.Z()+Len*<span style="color: #000000;">Cl); </span><span style="color: #0000ff;">if</span> (P.Distance(aP2) ><span style="color: #000000;"> Tol) { parallel</span>=<span style="color: #000000;">Standard_False; } } } </span><span style="color: #0000ff;">if</span><span style="color: #000000;"> (parallel) { </span><span style="color: #0000ff;">if</span> (Abs(Dis) <<span style="color: #000000;"> Tolang) { inquadric</span>=<span style="color: #000000;">Standard_True; } </span><span style="color: #0000ff;">else</span><span style="color: #000000;"> { inquadric</span>=<span style="color: #000000;">Standard_False; } } </span><span style="color: #0000ff;">else</span><span style="color: #000000;"> { parallel</span>=<span style="color: #000000;">Standard_False; inquadric</span>=<span style="color: #000000;">Standard_False; nbpts </span>= <span style="color: #800080;">1</span><span style="color: #000000;">; paramonc [</span><span style="color: #800080;">0</span>] = - Dis/<span style="color: #000000;">Direc; pnts[</span><span style="color: #800080;">0</span>].SetCoord(Orig.X()+paramonc[<span style="color: #800080;">0</span>]*<span style="color: #000000;">Al, Orig.Y()</span>+paramonc[<span style="color: #800080;">0</span>]*<span style="color: #000000;">Bl, Orig.Z()</span>+paramonc[<span style="color: #800080;">0</span>]*<span style="color: #000000;">Cl); } done</span>=<span style="color: #000000;">Standard_True; }</span></pre> </div> <p> </p> <p><span style="font-family: 宋体;">从上qC码中可以看出其计思\也是先计参?/span>t<span style="font-family: 宋体;">Q还加了一个特D用法,卛_参数</span><span style="font-family: Calibri;">Len!=0</span><span style="font-family: 宋体;">且参?/span><span style="font-family: Calibri;">t</span><span style="font-family: 宋体;">的分?/span><span style="font-family: Calibri;">!=0</span><span style="font-family: 宋体;">旉新判断直U与q面的^行状态。这个用法虽然有q状态的重新判断Q但是如果不q没有计算交点的处理。所以用这个函数时Q参?/span><span style="font-family: Calibri;">Len</span><span style="font-family: 宋体;">可以用默认?/span><span style="font-family: Calibri;">0</span><span style="font-family: 宋体;">Q即不用q段处理逻辑。还有个不严谨的地方是这里的实数判断没有用区间判断法?/span></p> <img src ="//www.owiwv.icu/eryar/aggbug/216393.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="//www.owiwv.icu/eryar/" target="_blank">eryar</a> 2019-06-03 16:40 <a href="//www.owiwv.icu/eryar/archive/2019/06/03/lineplaneint.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>RvmTranslator7.0-OBJ - ڲͼ//www.owiwv.icu/eryar/archive/2019/05/29/rvmtranslator_obj.htmleryareryarWed, 29 May 2019 13:04:00 GMT//www.owiwv.icu/eryar/archive/2019/05/29/rvmtranslator_obj.html//www.owiwv.icu/eryar/comments/216387.html//www.owiwv.icu/eryar/archive/2019/05/29/rvmtranslator_obj.html#Feedback0//www.owiwv.icu/eryar/comments/commentRss/216387.html//www.owiwv.icu/eryar/services/trackbacks/216387.htmlRvmTranslator7.0-OBJ

eryar@163.com

 

RvmTranslator can translate the RVM file exported by AVEVA Plant(PDMS)/AVEVA Marine to STEP, IGES, STL, DXF, 3D PDF, OBJ, 3DXML, IFC,.etc. So it can be used for exchanging model data between other CAD software, such as Autodesk AutoCAD, Plant3d, 3ds Max, CATIA, Solidworks, Pro/E, Unity3d, .etc.

 

RvmTranslator可以?/span>AVEVA PDMS/Plant/Marine中导出的RVM文gq行可视化,以及?/span>RVM转换成常见的三维文g格式。如STEPQ?/span>IGESQ?/span>STLQ?/span>DXF, OBJ, 3DPDF, 3DXML, IFC{,便于与其?/span>CADpȝq行数据交换Q如Autodesk AutoCAD, Plant3d, 3ds Max, CATIA, Solidworks, Pro/E, Unity3d, Bentley{?/span>

OBJ文g?/span>Alias|Wavefront公司为它的一套基于工作站?/span>3D建模和动画Y?/span>"Advanced Visualizer"开发的一U标?/span>3D模型文g格式Q很适合用于3D软g模型之间的互|也可以通过Mayad。比如你?/span>3dsMax?/span>LightWave中徏了一个模型,x它调?/span>Maya里面渲染或动画,导出OBJ文g是一U很好的选择。目前几乎所有知名的3D软g都支?/span>OBJ文g的读写,不过其中很多需要通过插g才能实现?/span>RvmTranslator可以?/span>PDMS模型转换?/span>OBJ格式?/span>

 

上图?/span>RvmTranslator转换的工厂模型?/span>

上图?/span>RvmTranslator转换的船体模型?/span>

 

Download RvmTranslator

 https://share.weiyun.com/5fcHSBC



eryar 2019-05-29 21:04 发表评论
]]>
OpenCASCADE License FAQs - ڲͼ//www.owiwv.icu/eryar/archive/2019/05/29/occ_license_faq.htmleryareryarWed, 29 May 2019 13:03:00 GMT//www.owiwv.icu/eryar/archive/2019/05/29/occ_license_faq.html//www.owiwv.icu/eryar/comments/216386.html//www.owiwv.icu/eryar/archive/2019/05/29/occ_license_faq.html#Feedback0//www.owiwv.icu/eryar/comments/commentRss/216386.html//www.owiwv.icu/eryar/services/trackbacks/216386.htmlOpenCASCADE License FAQs

 

l常用h问我使用OpenCASCADE开发商业Y件是否需要付费,下面?/span>OpenCASCADE的官方网站上截取其回{翻译成中文Q官方网址Q?/span>https://www.opencascade.com/content/faqs ?/span>

 

译l一?/span>Open CASCADE TechnologyUCؓ OCCT?/span>

 

OCCT许可?/span>GPL兼容吗?

是的Q从版本6.7.0开始,OCCT是根?/span>GNU LGPL版本2.1的条ƾ(以及一些小的附加权限)发布的,因此它与GNU GPL版本2及更高版本完全兼宏V?/span>

但是Q?/span>OCCT版本6.6.0及更早版本是Ҏ自定义许可证Q?/span>OCCT Public LicenseQ发布的?该许可在目的和意图方面类gGNU LGPLQ但?/span>GNU GPL不兼宏V?/span>

 

我可以?/span>OCCTҎGPLQ?/span>LGPL或其他许可(包括专有Q分发我的Y件品吗Q?/span>

是的你可以?/span> 但是Q您应始l确保最l品许可证W合产品中用的库的许可证要求?/span> 从版?/span>6.7.0开始,OCCTҎGNU LGPL版本2.1的条ƾ(以及一些小的附加权限)发布Q用该库的软g产品的要求在LGPL文本的第6部分中描q?如果您的最l品的许可与其中用的库的许可有Q何冲H,您需要采取措施(例如Q对此类最l品许可进行适当的修改)以解决Q何矛盾?/span>

如果有疑问ƈ避免可能的误解,误pL们获取徏议,我们很乐意回{您Ҏ事可能有的Q何疑问?/span>

 

我可以?/span>Open CASCADE技术制作商业品ƈq行销售吗Q?如果是,是否有Q何限Ӟ

是的Q您可以在商业应用程序中使用Open CASCADE技术(OCCTQ库Q而无需支付M开发许可费或运行时Ҏ版税。您的义务是要明注意您的Y件?/span>Open CASCADE技术(OPEN CASCADE公司的商标)Q在您的产品中提?/span>OCCT许可证的副本Qƈ遵@许可证本w的其他要求?从版?/span>6.7.0开始,此许可证?/span>GNU LGPL版本2.1Q具有一些小的附加权限)。另h意,OCCT使用“pȝ要求”面上列出的W三方组件?W三方组件的使用受其相应许可证的U束?/span>

 

 

如果我想发布自己使用OCCT的YӞ我是否有义务重新分发整个安装包,或者我只能分发我需要的部分代码Q?/span>

q样是允许的q期望您仅分发你的程序用到的库和资源?/span>

 

 

我对OCCT的用是否会늊M其他许可或专利?

您不需要Q何特定的安排来?/span>OCCT开源分发中包含的Q何算法。多q来Q我们一直没有听说过客户或用户?/span>Open CASCADE技术的M专利问题?/span>

 

 

我是否有义务使用OCCT的时候开源应用程序的完整源代码?

不,你不是?/span> 披露您的应用E序源代码的军_取决于您?/span>



eryar 2019-05-29 21:03 发表评论
]]>
OpenCASCADE点向q面投媄 - ڲͼ//www.owiwv.icu/eryar/archive/2019/05/29/projlib.htmleryareryarWed, 29 May 2019 13:02:00 GMT//www.owiwv.icu/eryar/archive/2019/05/29/projlib.html//www.owiwv.icu/eryar/comments/216385.html//www.owiwv.icu/eryar/archive/2019/05/29/projlib.html#Feedback0//www.owiwv.icu/eryar/comments/commentRss/216385.html//www.owiwv.icu/eryar/services/trackbacks/216385.htmlOpenCASCADE点向q面投媄

 

OpenCASCADE?/span>ProjLibcL供了解析曲线Q直Uѝ圆、椭圆、抛物线、双曲线Q向解析曲面Q^面、圆柱面、圆锥面、球面、圆环面Q投q功能Q主要用来计三l曲U在二维参数I间的参数?/span>

 

其中点向q面投媄是最单的情况Q本文主要介l点向^面投q注意事项?/span>ProjLibcL个工LQ因为其函数都是静态函数。点向^面投影很单,直接?/span>ProjLib::Project(aPlane, aPoint)卛_?/span>

 

其实C码如下:

gp_Pnt2d  ProjLib::Project(const gp_Pln& Pl, const gp_Pnt& P)
{
  Standard_Real U, V;
  ElSLib::Parameters(Pl, P, U, V);
  return gp_Pnt2d(U,V);
}
inline void ElSLib::Parameters(const gp_Pln& Pl,
          const gp_Pnt& P,
          Standard_Real& U,
          Standard_Real& V) {
  ElSLib::PlaneParameters(Pl.Position(),P,U,V);
}
void ElSLib::PlaneParameters (const gp_Ax3& Pos,
         const gp_Pnt& P,
         Standard_Real& U,
         Standard_Real& V)
{
  gp_Trsf T;
  T.SetTransformation (Pos);
  gp_Pnt Ploc = P.Transformed (T);
  U = Ploc.X();
  V = Ploc.Y();
}

从上面的代码可以看出Q点向^面投影实现就是将点变换到q面所在的坐标pM。用这个类向^面投p注意的事Ҏq面的构造。^?/span>gp_Pln有如下构造函敎ͼ

 

默认构造函敎ͼ构造了一?/span>XOYq面

Z一个坐标系gp_Ax3构造^?/span>

Z一个点和一个方向构造^?/span>

Zq面的系数方E,?/span>AX+BY+CZ+D=0

前两个构造函数很清晰Q而第三个构造函数即Z一个点和一个方向构造^面的方式没有明确Q注释不清晰。这里的方向指定了^面的法向Q但是还~少一个方向来定一个坐标系Q所以用这个构造函数来生成q面的时候,需要理解其生成另外一个方向的法是不是自己需要的?/span>

gp_Pln::gp_Pln (const gp_Pnt& P,
  const gp_Dir& V)
{
  Standard_Real A = V.X();
  Standard_Real B = V.Y();
  Standard_Real C = V.Z();
  Standard_Real Aabs = A;
  if (Aabs < 0) Aabs = - Aabs;
  Standard_Real Babs = B;
  if (Babs < 0) Babs = - Babs;
  Standard_Real Cabs = C;
  if (Cabs < 0) Cabs = - Cabs;
  //  pour determiner l'axe X :
  //  on dit que le produit scalaire Vx.V = 0. 
  //  et on recherche le max(A,B,C) pour faire la division.
  //  l'une des coordonnees du vecteur est nulle. 
  if( Babs <= Aabs && Babs <= Cabs) {
    if (Aabs > Cabs)  pos = gp_Ax3 (P, V, gp_Dir (-C,0., A));
    else              pos = gp_Ax3 (P, V, gp_Dir ( C,0.,-A));
  }
  else if( Aabs <= Babs && Aabs <= Cabs) {
    if (Babs > Cabs)  pos = gp_Ax3 (P, V, gp_Dir (0.,-C, B));
    else              pos = gp_Ax3 (P, V, gp_Dir (0., C,-B));
  }
  else {
    if (Aabs > Babs)  pos = gp_Ax3 (P, V, gp_Dir (-B, A,0.));
    else              pos = gp_Ax3 (P, V, gp_Dir ( B,-A,0.));
  }
}

当这里确定^面坐标系的方式与需要的不一致时Q在使用投媄法的时候就会生问题?/span>



eryar 2019-05-29 21:02 发表评论
]]>
Compile OpenCASCADE7.3 with VS2008 - ڲͼ//www.owiwv.icu/eryar/archive/2019/04/18/compile_occ730_vs2008.htmleryareryarWed, 17 Apr 2019 23:17:00 GMT//www.owiwv.icu/eryar/archive/2019/04/18/compile_occ730_vs2008.html//www.owiwv.icu/eryar/comments/216353.html//www.owiwv.icu/eryar/archive/2019/04/18/compile_occ730_vs2008.html#Feedback0//www.owiwv.icu/eryar/comments/commentRss/216353.html//www.owiwv.icu/eryar/services/trackbacks/216353.html

Compile OpenCASCADE7.3 with VS2008

eryar@163.com

 

1. 概述

?span style="margin: 0px; padding: 0px; font-family: "Times New Roman";">OpenCASCADE的源码文件夹中有?/span>adm文g夹,里面提供了各个^C~译源码的项目文件。其中在Windows操作pȝ中用微软的Visual Studio?/span>msvc文g夹中提供?/span>VS相应版本的项目文件。所以在使用批处理对OpenCASCADE源码q行~译的时候,会根?/span>vc的版本来启动相应版本?/span>visual studio。如果文件夹中没有对应的VS版本Q就打不开相应?/span>VS?/span>

 

在最新版本的OpenCASCADE7.3.0中,没有提供VS2008的项目文件。所以对于想?/span>OpenCASCADE用于老的pȝQ如XPpȝ中时Q或者主E序是用VS2008~译的,q时需要将OpenCASCADE?/span>VS2008来编译了?/span>

2. 生成VS

其实OpenCASCADE?/span>VS目都是采用Tcl脚本生成的,而且生成的脚本里面还保留了对VS2008的支持。下面就介绍一下如何生?/span>VS目。在OpenCASCADE源码文g夹中有个批处理文?/span>genproj.bat

 

׃q个批处理会调用Tcl文g中的命oQ所以需要将Tcl加入到环境变?/span>PATH中以便于q行Tcl脚本文g中的命o。如上图?/span>

SET "PATH=%PATH%;D:\OpenCASCADE-7.3.0\tcltk-86-64\bin;"

是Tcl加入到PATH的一U方法,配置好这个就可以直接双击genproj.batQ运行截囑֦下:

 

Ҏgenproj.bat中的注释可知genprojq可以带上参敎ͼW一个参数是VS~译器的版本Q第二个参数是操作系l。我们要生成Windows操作pȝ?/span>VS2008的项目,所以输入参敎ͼ

genproj vc9 wnt

q样q成了VS2008的项目了Q?/span>

 


Z方便大家在移动端也能看到我的博文和讨Z,现已注册微信公众PƢ迎大家扫描下方二维码关注?/h5>Shing Liu(eryar@163.com)


ڲͼ 2019-04-18 07:17 发表评论
]]>