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.

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/

wps_clip_image-20312

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. 

wps_clip_image-25919

Figure 1.2 Qt Ads

You can develop your program in the following manner:

wps_clip_image-19414

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:

wps_clip_image-12250

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.

wps_clip_image-19038

Figure 2.2 Click mouse left button to pick

wps_clip_image-15699

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:

wps_clip_image-6756

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:

wps_clip_image-10519

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.

wps_clip_image-29758

Figure 4.1 Modeling Algorithms in occQt

5.Boolean Operations

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

wps_clip_image-12858

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:

wps_clip_image-19041

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!

目录
相关文章
OpenCascade 6.7.1 and Qt 5
OpenCascade 6.7.1 and Qt 5 eryar@163.com   Keywords: OpenCascade 6.7.1, Qt5, Demo   从OpenCascade6.
1158 0
|
4月前
|
数据安全/隐私保护 C++ 计算机视觉
Qt(C++)开发一款图片防盗用水印制作小工具
文本水印是一种常用的防盗用手段,可以将文本信息嵌入到图片、视频等文件中,用于识别和证明文件的版权归属。在数字化和网络化的时代,大量的原创作品容易被不法分子盗用或侵犯版权,因此加入文本水印成为了保护原创作品和维护知识产权的必要手段。 通常情况下,文本水印可以包含版权声明、制作者姓名、日期、网址等信息,以帮助识别文件的来源和版权归属。同时,为了增强防盗用效果,文本水印通常会采用字体、颜色、角度等多种组合方式,使得水印难以被删除或篡改,有效地降低了盗用意愿和风险。 开发人员可以使用图像处理技术和编程语言实现文本水印的功能,例如使用Qt的QPainter类进行文本绘制操作,将文本信息嵌入到图片中,
176 1
Qt(C++)开发一款图片防盗用水印制作小工具
|
3月前
|
监控 C++ 容器
【qt】MDI多文档界面开发
【qt】MDI多文档界面开发
80 0
|
2月前
|
开发工具 C++
qt开发技巧与三个问题点
本文介绍了三个Qt开发中的常见问题及其解决方法,并提供了一些实用的开发技巧。
|
2月前
|
3月前
|
C++
C++ Qt开发:QUdpSocket网络通信组件
QUdpSocket是Qt网络编程中一个非常有用的组件,它提供了在UDP协议下进行数据发送和接收的能力。通过简单的方法和信号,可以轻松实现基于UDP的网络通信。不过,需要注意的是,UDP协议本身不保证数据的可靠传输,因此在使用QUdpSocket时,可能需要在应用层实现一些机制来保证数据的完整性和顺序,或者选择在适用的场景下使用UDP协议。
134 2
Qt开发网络嗅探器02
Qt开发网络嗅探器02
|
3月前
|
存储 运维 监控
Qt开发网络嗅探器01
Qt开发网络嗅探器01
|
3月前
|
网络协议 容器
Qt开发网络嗅探器03
Qt开发网络嗅探器03
|
3月前
【qt】多窗口开发
【qt】多窗口开发
54 0