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

 1 /*
 2 *    Copyright (c) 2013 eryar All Rights Reserved.
 3 *
 4 *        File    : Main.cpp
 5 *        Author  : eryar@163.com
 6 *        Date    : 2013-08-22 18:52
 7 *        Version : 1.0v
 8 *
 9 *    Description : Hello World program of OpenCascade.
10 *
11 */
12 
13 #include <iostream>
14 
15 // OpenCascade library.
16 //#define WNT
17 #include <Standard_CString.hxx>
18 
19 int main(void)
20 {
21     Standard_CString strHelloWorld("Hello World!");
22     Standard_CString strHelloOcct("Hello OpenCascade!");
23 
24     std::cout << strHelloWorld << std::endl;
25     std::cout << strHelloOcct << std::endl;
26 
27     return 0;
28 }
29 

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

Figure 2.3 Program output

5. 程序代码说明:

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

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

1 // check if WNT macro is not defined but compiler is MSVC 
2 #if defined(_MSC_VER) && !defined(WNT) 
3 #error "Wrong compiler options has been detected. Add /DWNT option for proper compilation!!!!!" 
4 #endif 

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

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

三、结论 Conclusion

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

 

PDF Version: Hello World of OpenCascade

时间: 2024-10-31 15:28:57

Hello World of OpenCascade的相关文章

OpenCascade Primitives BRep-Torus

OpenCascade Primitives BRep-Torus eryar@163.com Abstract. BRep is short for Boundary Representation. Boundary Representation gives a complete description of an object by associating topological and geometric information for solid modeling. In this ca

Make Helix Curve in OpenCASCADE

Make Helix Curve in OpenCASCADE eryar@163.com Abstract. OpenCASCADE does not provide helix curve directly, but you can build a helix curve by the pcurve of a surface(curve on surface). When you understand the pcurve of a surface, you can make a helix

Building OpenCASCADE on Debian

Building OpenCASCADE on Debian eryar@163.com Abstract. When you are familiar with OpenCASCADE on Windows, you should try it on Linux operating system, because of Debian is also open source like OpenCASCADE. The paper is focus on how to building the O

OpenCascade Chinese Text Rendering

OpenCascade Chinese Text Rendering eryar@163.com Abstract. OpenCascade uses advanced text rendering powered by FTGL library. The FreeType provides vector text rendering, as a result the text can be rotated and zoomed without quality loss. FreeType al

FreeType in OpenCASCADE

FreeType in OpenCASCADE eryar@163.com Abstract. FreeType is required for text display in the 3D viewer. FreeType is a software font engine that is designed to be small, efficient, highly customizable, and portable while capable of producing high-qual

OpenCASCADE Coordinate Transforms

OpenCASCADE Coordinate Transforms eryar@163.com Abstract. The purpose of the OpenGL graphics processing pipeline is to convert 3D descriptions of objects into a 2D image that can be displayed. In many ways, this process is similar to using a camera t

Use PSO to find minimum in OpenCASCADE

Use PSO to find minimum in OpenCASCADE eryar@163.com Abstract. Starting from OCCT6.8.0 will include one more algorithm for solving global optimization problems. Its development has been triggered by insufficient performance and robustness of existing

OpenCASCADE Root-Finding Algorithm

OpenCASCADE Root-Finding Algorithm eryar@163.com Abstract. A root-finding algorithm is a numerical method, or algorithm, for finding a value x such that f(x)=0, for a given function f. Such an x is called a root of the function f. In OpenCASCADE math

OpenCASCADE Outline

OpenCASCADE Outline eryar@163.com      有网友反映blog中关于OpenCASCADE的文章比较杂乱,不太好找,最好能提供一个大纲,这样方便查找.于是决定将这些学习时写的文章整理下,方便对OpenCASCADE的学习理解.其实在http://www.cnblogs.com/opencascade中,已经将文章按目录重新发表了一遍.可以按OpenCASCADE的模块的顺序来学习,也可以挑选自己感兴趣的部分来学习.      由于本人水平所限,文中的错误不妥之处