Hello World of OpenCascade

 

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. 程序的源代码如下所示:

/*

*    Copyright (c) 2013 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;

return 0;

}

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

 
 

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. 后台自动启动appium

    首先说明,本人用的exe方式安装的appium. 新建一个.vbs文件,写入以下脚本,记得把D盘换成你自己的盘符. 1.后面taskkill好像没有实际作用..加就加了吧. Set ws = Crea ...

  2. Android[安德鲁斯] 文本Air Video 远程播放电脑视频

    苹果iOS下列.目前应用Air Video,能力iOS由Wifi远程直接播放电脑视频,无需看视频复制到手机.非常好用!最近使用Android打电话.展望类别似应用,找了很长一段时间没有找到.在仔细的思 ...

  3. 使用JFinal框架中Validator

    Validator是JFinal框架中的校验组件,在Validator类中提供了我们经常使用的校验方法,而Validator本身实现了Interceptor接口,所以Validator也相当于一个拦截 ...

  4. sgu139Help Needed!推断15数码是否有解,以及推断N数码是否有解的推论

    是这种,要你推断一个15数码是否有解. 我不会,找了这样一个方法. 将16个数按出现顺序存放在一维数组里面, 然后累加每一个数的逆序对数目, 还要加上0到终态的曼哈顿距离,得到一个数x. 因为最后的状 ...

  5. PyCharm 使用简介

    PyCharm 使用简介 最近由于项目需要,领导要求使用python以方便扩展,没有办法,赶鸭子上架花了2天时间翻完了python的初级教程然后就开始写代码.有一款好的IDE可以帮助我快速上手一门新语 ...

  6. 日积月累系列之省市选择器(js源码)

    省市选择器是大家经常用到的, 但网上找的省市选择器都不是很实用,于是自己写了移动端的省市选择器. 界面: 源码结构: 演示地址:http://component.cform.cn/city/ 演示二维 ...

  7. TestNg的xml配置

    TestNG中,可以通过配置xml来运行某一类.包.方法. 1.通过TestNg运行某一个类 <?xml version="1.0" encoding="UTF-8 ...

  8. [翻译]在Django项目中添加谷歌统计(Google Analytics)

    原文:<Google Analytics tracking code into Django projects, the easy way> 对我来说,制作一个可扩展的Django应用随时 ...

  9. leetcode第33题--Search for a Range

    Given a sorted array of integers, find the starting and ending position of a given target value. You ...

  10. [翻译]初识SQL Server 2005 Reporting Services Part 3

    原文:[翻译]初识SQL Server 2005 Reporting Services Part 3 这是关于SSRS文章中四部分的第三部分.Part 1提供了一个创建基本报表的递阶教程.Part 2 ...