Hello World of OpenCascade

eryar@163.com

摘要Abstract:以一个经典的Hello World程序为例开始对开源几何造型内核OpenCascade的学习。

关键字Key Words:OpenCascade、Qt、Hello World

一、引言 Introduction

OpenCascade编译成功后,看着大量的代码,无从下手。本文以Hello World程序为例,详细说明使用OpenCascade进行编程需要注意的事项,以便对OpenCascade做进一步学习。

选择的编程工具为Qt Creator,因为其也是开源的,其版本信息如下图所示:

Figure 1.1 About Qt Creator

二、Hello World of OpenCascade

1. 新建工程:在Qt Creator中创建一个新的工程,选择Non-Qt Project -> Plain C++ Project,如下图所示:

Figure 2.1 Create a Plain C++ project in Qt Creator

2. 在工程文件中添加头文件路径及所需要用到的库文件,如下图所示:

Figure 2.2 Set header file path and library

3. 程序的源代码如下所示:

/*

eryar All Rights Reserved.

*

*        File    : Main.cpp

*        Author  : eryar@163.com

*        Date    : 2013-08-22 18:52

*        Version : 1.0v

*

*    Description : Hello World program of OpenCascade.

*

*/

#include <iostream>

// OpenCascade library.

#define WNT

#include <Standard_CString.hxx>

int main(void)

{

Standard_CString strHelloWorld("Hello World!");

Standard_CString strHelloOcct("Hello OpenCascade!");

std::cout << strHelloWorld << std::endl;

std::cout << strHelloOcct << std::endl;

;

}

4. 程序输出结果如下图所示:

Figure 2.3 Program output

5. 程序代码说明:

l #include <iostream>:使用了C++的标准输入输出,如:std::cout;

l #define WNT:告知OpenCascade程序运行在Windows平台上。若不设置,当编译器为MSVC时,会出现如下编译错误:

// check if WNT macro is not defined but compiler is MSVC

#if defined(_MSC_VER) && !defined(WNT)

#error "Wrong compiler options has been detected. Add /DWNT option for proper compilation!!!!!"

#endif

l #include <Standard_CString.hxx>:使用OpenCascade中的字符串;

l 使用了两个字符串变量分别输出“Hello World!”和“Hello OpenCascade!”;

三、结论 Conclusion

在Qt Creator中以一个简单的示例程序,详细说明了在Windows平台使用OpenCascade开发需要注意的事项,为进一步研究、学习、使用OpenCascade奠定基础。

PDF Version: Hello World of OpenCascade

Hello World of OpenCascade的更多相关文章

  1. OpenCASCADE AIS Manipulator

    OpenCASCADE AIS Manipulator eryar@163.com Abstract. OpenCASCADE7.1.0 introduces new built-in interac ...

  2. Convert BSpline Curve to Arc Spline in OpenCASCADE

    Convert BSpline Curve to Arc Spline in OpenCASCADE eryar@163.com Abstract. The paper based on OpenCA ...

  3. OpenCASCADE Shape Location

    OpenCASCADE Shape Location eryar@163.com Abstract. The TopLoc package of OpenCASCADE gives resources ...

  4. OpenCASCADE BRep Projection

    OpenCASCADE BRep Projection eryar@163.com 一网友发邮件问我下图所示的效果如何在OpenCASCADE中实现,我的想法是先构造出螺旋线,再将螺旋线投影到面上. ...

  5. OpenCASCADE Expression Interpreter by Flex & Bison

    OpenCASCADE Expression Interpreter by Flex & Bison eryar@163.com Abstract. OpenCASCADE provide d ...

  6. OpenCASCADE Data Exchange - 3D PDF

    OpenCASCADE Data Exchange - 3D PDF eryar@163.com Abstract. Today most 3D engineering model data are ...

  7. OpenCASCADE Interpolations and Approximations

    OpenCASCADE Interpolations and Approximations eryar@163.com Abstract. In modeling, it is often requi ...

  8. OpenCASCADE Ring Type Spring Modeling

    OpenCASCADE Ring Type Spring Modeling eryar@163.com Abstract. The general method to directly create ...

  9. OpenCASCADE Interpolation - Lagrange

    OpenCASCADE Interpolation - Lagrange eryar@163.com Abstract. Power basis polynomial is the most simp ...

  10. OpenGL Shader in OpenCASCADE

    OpenGL Shader in OpenCASCADE eryar@163.com Abstract. As implementation of one of the strategic steps ...

随机推荐

  1. topcoder SRM 628 DIV2 BracketExpressions

    先用dfs搜索所有的情况,然后判断每种情况是不是括号匹配 #include <vector> #include <string> #include <list> # ...

  2. display:table-cell

    布局神器display:table-cell Author:owenhong2015-06-17 随着时间的推进,ie6.ie7在中国浏览器市场的占有率越来越低的情况,我现在工作的团队,经过用户访问数 ...

  3. 【模拟】POJ 3087

    直达–>POJ 3087 Shuffle'm Up 题意:一开始没怎么看明白,注意现是从S2里拿牌放在最底下,再放S1,这样交叉放(我一开始以为是S1和S2随意哪个先放,分别模拟取最小),然后在 ...

  4. 【Java】JDK类 CountDownLatch

    一个同步辅助类,在完成一组正在其他线程中执行的操作之前,它允许一个或多个线程一直等待. 用给定的计数 初始化 CountDownLatch.由于调用了 countDown() 方法,所以在当前计数到达 ...

  5. 我听说 C...

    我听说在 c 语言的世界里,goto 和异常处理都是声名狼藉的东西,而我认为它们在一起就能化解各自的问题.

  6. jQuery的加法运算.

    jQuery的加法运算. 加法运算 ?想必大家听到这都会不屑了,加法运算这是多么简单的运算.然而有的时候在jQuery也让人挺头疼的. 常规的是: var num1 = 123; var num2=1 ...

  7. 关于Linux系统下错误“浮点数异常(核心已转储)”的分析

    1.问题发现 有这样一段代码: #include <stdio.h> int main() { int a, b, num1, num2, temp; printf("pleas ...

  8. Android中获取选择图片与获取拍照返回结果差异

    导语: 如今的安卓应用在选择图片的处理上大多合并使用拍照和从相册中选择这两种方式 今天在写一个这样的功能时遇到一个尴尬的问题,同样是拍照获取图片功能,在不同手机上运行的效果不一样,下面是在某型手机上测 ...

  9. CentOS7 编译安装 Mongodb (实测 笔记 Centos 7.0 + Mongodb 2.6.6)

    环境: 系统硬件:vmware vsphere (CPU:2*4核,内存2G,双网卡) 系统版本:CentOS-7.0-1406-x86_64-DVD.iso 安装步骤: 1.准备 1.1 显示系统版 ...

  10. PHP date函数时间相差8个小时解决办法

    php中date时间相差8个小时的解决办法 作者: PHP中文网|标签:|2016-7-25 08:46 在Windows上,在默认的PHP配置下,date函数返回的时间值和当地时间总是相差8小时,即 ...