A Simple Opencascade Qt demo-occqt

Source: Internet
Author: User

A Simple Opencascade Qt demo-occqt

[Email protected]

Abstract. Opencascade has provided the Qt samples in the Samples directory, but they is 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, an D visualization. Most of OCCT functionality are avaiable in the form of C + + libraries. OCCT can is best applied in development of software dealing with 3D modeling (CAD), manufacturing/measuring (CAM) or numeric Al simulation (CAE).

Opencascade technology is free software; 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 this is widely used for developing application software with graphical user I Nterface (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 this lets you create stunning user interfaces with amazing performance. We want to the achieve optimal results by using Qt building blocks on the best possible, which are 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 c An 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 has provided many samples to show their functions, but there is a lots codes, it's a little complicated for t He beginner. I Write a simple program to try Opencascade in a straightforward. I hope the demo can help understand the usage of opencascade.

The demo is based on OpenCASCADE6.8.0 and Qt5.4. Because of There is 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 was 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 are 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 are used for the pick and multi-select operation, single click can pick a shape; Drag left button would 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 would be hilighted and now does 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. MakePrimitives

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 are in the following picture:

Figure 3.1 Primitives in OCCQT

4.Modeling Algorithms

Modeling algorithms is the outstanding advantage of Opencascade. OCCQT just give a example for the usage, you can check the documents and Opencascade reference manual to a loo K. The modeling algorithms in the OCCQT is:

V Fillet;

V Chamfer;

V Extrude;

V Revol;

V Loft.

Figure 4.1 Modeling algorithms in OCCQT

5.Boolean Operations

The Boolean operations is used to create new shapes from the combinations of the shapes,

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

topods_shape afusedshape = brepalgoapi_fuse (S1, S2);
Topods_shape acommonshape = Brepalgoapi_common (S1, S2);
Topods_shape acuttedshape = brepalgoapi_cut (S1, S2);

You can try the this in OCCQT:

Figure 5.1 Boolean operations in OCCQT

6. Conclusion

From the simple code demo, I hope it would 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 has a try, then you can feedback or track the modification of OCCQT.

enjoy!

PDF version:a Simple Opencascade Qt deom-occqt

A Simple Opencascade Qt demo-occqt

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.