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. 项目开发经常使用PHP功能

    日期操作 为了便于存储.比较和交付.我们通常使用strtotime()功能转换的日期UNIX时间戳.有仅用于在显示给用户时date()成经常使用的时间格式. strtotime()  函数将不论什么英 ...

  2. dojo的TabContainer添加ContentPane假设closable,怎么不闭幕后予以销毁ContentPane

    其主要思想是新的TabContainer的扩展类,重载其closeChild属性,使得其在关闭子容器时.不调用该子容器的destroyRecursive方法. define([ "dojo/ ...

  3. Swift编程语言学习12 ——实例方法(Instance Methods)和类型方法(Type Methods)

    方法是与某些特定类型相关联的函数.类.结构体.枚举都能够定义实例方法:实例方法为给定类型的实例封装了详细的任务与功能.类.结构体.枚举也能够定义类型方法:类型方法与类型本身相关联.类型方法与 Obje ...

  4. Win7搭建NodeJs开发环境

    Win7搭建NodeJs开发环境以及HelloWorld展示—图解 Windows 7系统下搭建NodeJs开发环境(NodeJs+WebStrom)以及Hello World!展示,大体思路如下:第 ...

  5. 判断文件是否存在,不存在创建文件&&判断文件夹是否存在,不存在创建文件夹

    1.判断文件是否存在,不存在创建文件 File file=new File("C:\\Users\\QPING\\Desktop\\JavaScript\\2.htm"); if( ...

  6. Mongodb操作之查询(循序渐进对比SQL语句)

    工具推荐:Robomongo,可自行百度寻找下载源,个人比较推荐这个工具,相比较mongoVUE则更加灵活. 集合简单查询方法 mongodb语法:db.collection.find()  //co ...

  7. linux有用技巧:使用快照制作虚拟机

    在日常的学习其中,假设遇到了集群和负载均衡类的实验,须要用到大量的虚拟机,假设一个一个的去创建,显然是很费力和低效的.所以今天交给大家怎样用快照来制作虚拟机.想要多少给你多少^_^.仅仅要内存够用! ...

  8. 2.4 LINQ中使用where子句指定筛选条件

    本篇讲解的内容有: 使用where筛选过滤LINQ查询 带逻辑的where筛选 多个where筛选子句 [1.使用where筛选过滤LINQ查询] 通常一个LINQ查询不会如前面的示例代码这么简单,经 ...

  9. Unity3D开发必备神器(Visual Studio Tools for Unity)

    Unity3D开发必备神器(Visual Studio Tools for Unity) 开发Unity3D程序你用的什么IDE呢? 1.MonoDevelop 2.VS 可能你的回答是这样的,我用的 ...

  10. sql2005还原超长sql脚本,还原超大脚本文件

    原文:sql2005还原超长sql脚本,还原超大脚本文件 从外网把数据库用导出脚本的方式导出来了,280M的样子,导是导出来了,但是在本机执行sql脚本的时候,直接就是out of memory,之前 ...