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. jquery 重复事件

    采用jquery时刻.其他活动均达到. 相反1对1的. 例如:onclick="$(document).keypress(function (key) {  if (key.keyCode ...

  2. BCM策略路由交换芯片

    BCM几个交换芯片的寄存器和相关的路由 EGR_L3_NEXT_HOP.EGR_L3_INTF.ING_L3_NEXT_HOP BCM XGS系列SDK中和路由相关的几个命令 l3 l3table. ...

  3. Hadoop2.2.0--Hadoop Federation、Automatic HA、Yarn完全分布式集群结构

    Hadoop有很多的上场时间,与系统上线.手头的事情略少.So,抓紧时间去通过一遍Hadoop2在下面Hadoop联盟(Federation).Hadoop2可用性(HA)及Yarn的全然分布式配置. ...

  4. PHP 7: PHP 变量和常量的定义

    原文:PHP 7: PHP 变量和常量的定义 本章说说变量的定义.如果对于变量和常量的定义,你会注意几个方面呢?你可能会想到: 如何定义变量,它和C# 等语言有什么不同呢? 变量区分大小写吗? PHP ...

  5. windows下oracle数据库定时备份与压缩批处理脚本(win7/win2008亲测通过)

    第一种方式:全备份,并直接覆盖原来的备份文件,固定命名. 脚本: @echo off exp system/a123@HZPG file=e:\db_backup\oradata.dmp log=e: ...

  6. Android slidingmenu详细解释 滑动的优化

    Android slidingmenu 详细解释 性能优化 转载请注明:   http://blog.csdn.net/aaawqqq 简单介绍 SlidingMenu 是github 上Androi ...

  7. 实例学习SSIS(一)--制作一个简单的ETL包

    原文:实例学习SSIS(一)--制作一个简单的ETL包 导读: 实例学习SSIS(一)--制作一个简单的ETL包 实例学习SSIS(二)--使用迭代 实例学习SSIS(三)--使用包配置 实例学习SS ...

  8. sql datalength与len区别用法

    原文:sql datalength与len区别用法 len ( string_expression )参数:要计算的字符串 len() 函数len 函数返回文本字段中值的长度. sql len() 语 ...

  9. 谈谈Oracle dba_free_space

    谈谈Oracle dba_free_space 博客分类: ORACLE管理 OracleSQLC#C++C  顾名思义,dba_free_space指的是Oracle还有多少表空间剩余空间,其视图结 ...

  10. NET Framework 4.5新特性 数据库的连接加密保护。

    NET Framework 4.5新特性 (一) 数据库的连接加密保护. NET Framework 4.5 ado.net数据库连接支持使用SecureString内存流方式保密文本.  一旦使用这 ...