A Simple OpenCASCADE Qt Demo-occQt

A Simple OpenCASCADE Qt Demo-occQt

eryar@163.com

Abstract. OpenCASCADE have provided the Qt samples in the samples directory, but they are a little complicated. So I decide write a simple OpenCASCADE Qt demo for the OpenCASCADE beginners. 

Key Words. OpenCASCADE6.8.0, Qt5.4

1. Introduction

OpenCASCADE is a software development platform providing services for 3D surface and solid modeling, CAD data exchange, and visualization. Most of OCCT functionality is avaiable in the form of C++ libraries. OCCT can be best applied in development of software dealing with 3D modeling(CAD), manufacturing/measuring(CAM) or numerical simulation(CAE). 

OpenCASCADE Technology is free software; you can redistribute it and or modify it under the terms of the GNU Lesser General Public License(LGPL) version 2.1, with additional exception. You can get the OpenCASCADE from here: http://www.opencascade.org/

Figure 1.1 OpenCASCADE6.8.0 Release Notes

Qt is a cross-platform application framework that is widely used for developing application software with graphical user interface(GUI). Qt is free and open source software distributed under the terms of the GNU Lesser General Public License. 

Qt Services

Qt is a powerful framework that lets you create stunning user interfaces with amazing performance. We want to help you to achieve optimal results by using Qt building blocks in the best possible way, which is why we offer an extensive range of Qt advisory services. 

Code Less, Create More. Easily create connected devices, UIs and applications that run anywhere on any device. 

Figure 1.2 Qt Ads

You can develop your program in the following manner:

Figure 1.3 A application based on Qt and OpenCASCADE

You can use Qt for the GUI development, and for data management such as restore data from file or undo/redo support, you can choose OCAF, and for modeling algorithms, you can use OpenCASCADE. 

You can also use the Model/View/Controller of Qt to manage the data and undo/redo mechnism, to accelarate the developing.

OpenCASCADE have provided many samples to show its functions, but there are a lots codes, it is a little complicated for the beginner. I write a simple program to try OpenCASCADE in a straightforward way. I hope the demo can help you to understand the usage of OpenCASCADE.

The demo is based on OpenCASCADE6.8.0 and Qt5.4. Because of there are many bug fixes in OpenCASCADE new version6.8.0, especially the visualization module. So I update the code for the previous demo Qt with OpenCASCADE and add something new: 

http://www.cppblog.com/eryar/archive/2013/08/18/202617.aspx

2.View Operations

In occQt there are three operations to manipulate the view: pan, zoom and rotate, the following picture is the main window of occQt:

Figure 2.1 occQt GUI

The options is for the middle button of the mouse, you can dragged the middle button of the mouse to pan, zoom and rotate the view. And the mouse left button is used for the pick and multi-select operation, single click you can pick a shape; drag left button will select all the shapes in the rectangle.

Figure 2.2 Click mouse left button to pick

Figure 2.3 Drag mouse left button to multi-select

The selected shapes will be hilighted, but now do not provide any operations for the selected shapes.

And also provide the Reset and Fit All function for the view:

Figure 2.4 Reset and Fit all for the view

3.Make Primitives

OpenCASCADE provides simple API for the construction of primitives, such as box, cone, sphere, cylinder, and torus, .etc. You can make a primitive by a simple class in OpenCASCADE, the sample code as follows:

TopoDS_Shape aTopoBox = BRepPrimAPI_MakeBox(3.0, 4.0, 5.0);
TopoDS_Shape aTopoCone = BRepPrimAPI_MakeCone(3.0, 0.0, 5.0);
TopoDS_Shape aTopoSphere = BRepPrimAPI_MakeSphere(3.0);
TopoDS_Shape aTopoCylinder = BRepPrimAPI_MakeCylinder(3.0, 5.0);
TopoDS_Shape aTopoTorus = BRepPrimAPI_MakeTorus(3.0, 1.0);

And the shapes in the viewer is in the following picture:

Figure 3.1 Primitives in occQt

4.Modeling Algorithms

Modeling algorithms is the outstanding advantage of OpenCASCADE. But in occQt just give a example for the usage, you can check the documents and OpenCASCADE reference manual to have a look. The modeling algorithms in the occQt are:

v Fillet;

v Chamfer; 

v Extrude;

v Revol;

v loft.

Figure 4.1 Modeling Algorithms in occQt

5.Boolean Operations

Boolean operations are used to create new shapes from the combinations of two shapes,

The class to perform this is simple to use, they are:

TopoDS_Shape aFusedShape = BRepAlgoAPI_Fuse(S1, S2);
TopoDS_Shape aCommonShape = BRepAlgoAPI_Common(S1, S2);
TopoDS_Shape aCuttedShape = BRepAlgoAPI_Cut(S1, S2);

You can try this in occQt:

Figure 5.1 Boolean operations in occQt

6. Conclusion

From the simple code demo, I hope it will help you to understand OpenCASCADE easily. Thanks for OpenCASCADE and Qt the amazing work. 

I put the code to GitHub: https://github.com/eryar/occQt/. You can download and have a try, then you can feedback or track the modification of occQt.

Enjoy!

PDF Version: A Simple OpenCASCADE Qt Deom-occQt

时间: 2014-12-29

A Simple OpenCASCADE Qt Demo-occQt的相关文章

OpenCASCADE Outline

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

Use Qt in Debian for OpenCASCADE

Use Qt in Debian for OpenCASCADE eryar@163.com Recently several OpenCASCADE enthusiasts want to build my simple Qt demo about OpenCASCADE on ubuntu system, but could not compile it successfully. Because I only compiled the occQt in Windows system, do

Qt简介以及如何配置Qt使用VS2010进行开发

Qt是神马东西? Qt – 一个跨平台应用程序和UI开发框架 它包括跨平台类库.集成开发工具和跨平台 IDE.使用 Qt 您只需一次性开发应用程序,无须重新编写源代码,便可跨不同桌面和嵌入式操作系统部署这些应用程序. Qt 主要是由 诺基亚 开发和维护的.Qt通过开源授权(LGPL 和 GPL)以及商业授权的方式对 Qt 进行授权.在Linux下Qt可是大名鼎鼎,Linux的KDE图形界面就是基于Qt开发的. Qt的最大好处是跨平台,可以看到上图,Qt可以支持windows,Mac os,lin

一起谈.NET技术,Qt简介以及如何配置Qt使用VS2010进行开发

Qt是神马东西? Qt – 一个跨平台应用程序和UI开发框架 它包括跨平台类库.集成开发工具和跨平台 IDE.使用 Qt 您只需一次性开发应用程序,无须重新编写源代码,便可跨不同桌面和嵌入式操作系统部署这些应用程序. Qt 主要是由 诺基亚 开发和维护的.Qt通过开源授权(LGPL 和 GPL)以及商业授权的方式对 Qt 进行授权.在Linux下Qt可是大名鼎鼎,Linux的KDE图形界面就是基于Qt开发的. Qt的最大好处是跨平台,可以看到上图,Qt可以支持windows,Mac os,lin

Qt简介以“.NET研究”及如何配置Qt使用VS2010进行开发

Qt是神马东西? Qt – 一个跨平台应用程序和UI开发框架 它包括跨平台类库.集成开发工具和跨平台 IDE.使用 Qt 您只需一次性开发应用程序,无须重新编写源代码,便可跨不同桌面和嵌入式操作系统部署这些应用程序. Qt 主要是由 诺基亚 开发和维护的.Qt通过开源授权(LGPL 和 GPL)以及商业授权的方式对 Qt 进行授权.在Linux下Qt可是大名鼎鼎,Linux的KDE图形界面就是基于Qt开发的. Qt的最大好处是跨平台,可以看到上图,Qt可以支持windows,Mac os,lin

webjx收集45个jQuery导航插件和教程

45个jQuery 导航插件及教程.新用户访问一个网站的最初15-20妙会对他们对网站的喜好影响很大,促使他们决定去留.所以开发一个直观易用,风格恰当的导航帮助用户开始是非常重要的.这篇文章列出的这些教程不仅体现了jQuery的强大,也展示了导航创意设计的众多可能. Horizontal Menu Navigation Plugins and Tutorials Mega Drop Down Menu w/ CSS & jQuery DemoAccording to usability expe

用ajax来控制书签和回退按钮

ajax|按钮|控制|书签 这篇文章描述了一个支持ajax应用书签和回退按钮的开源的javascript库.在这个指南的最后,开发者将会得出一个甚至不是google maps 或者 gmail那样处理的ajax的解决方案:健壮的,可用的书签和向前向后的动作能够象其他的web页面一样正确的工作. ajax:怎样去控制书签和回退按钮 这篇文章说明了一个重要的成果,ajax应用目前面对着书签和回退按钮的应用,描述了非常简单的历史库(really simple history),一个开源的解决这类问题的

通过MULE集成服务的几种方式

6. 配置模式 Mule 3.0版本提供了"pattern"的机制.Pattern总结了实际使用过程中的常见场景,以简化的服务配置方式提供. 6.1 简单服务模式(simple service pattern) 简单服务模式用于简化同步服务调用的配置,对应消息传递方式中的请求-响应方式. 图 简单服务模式 简单服务模式通过simple-service 元素配置,主要的元素属性包括: 属性 说明 address 服务监听的地址,如vm:in component-class Compone

ESB知识点介绍

Mule ESB 学习笔记   2013-06-19 13:55:08|  分类: 程序 |  标签:mule3  esb  |字号 订阅 附-学习资料: Mule in Action,by David Dossot & John D'Emic Mule 官方文档 DZone Refcardz #40: Core Mule 1. 简介 Mule ESB是一个基于Java的轻量级企业服务总线和集成平台,允许开发人员快速便利地连接多个应用,并支持应用间的数据交换.Mule ESB支持集成现有系统而无