In the latest chapter of the OccTutorials series, we are advancing to a bit more interesting area of OpenCASCADE. We make our first encounter with the Geom_Geometry class, more precisely Geom_Curves and Geom_BezierCurves. I will show how to create Bezier curves, rotate them, scale them, and compute their length using OpenCASCADE’s built-in numerical quadrature routines.
The curves are written into a STEP file, so that you can check them out using FreeCAD.
Check out the code at:
- Using standard containers of OpenCASCADE from the TCol… package
- Quick concept of handles
- Matrix operations using math_Matrix
This example will introduce two basic elements from OpenCASCADE: standard collections and handles. As for standard collections, they very much resemble the containers of the standard library of C++ (like vectors or lists), but they come as built in types of OpenCASCADE. Similarly, handles are pretty much equivalent to shared_ptr-s of boost or the C++11 standard – they incorporate reference counting and automatic destruction, for example. Our working example today is going to be a classic geometric exercise – calculating the area of a polygonized circle. The main classes we will talk about are:
Continue reading “Chapter 1.3 – Polygonizing a circle”
- Creating a circle with a location, orientation and radius
- Applying scaling transformations
- Evaluating points on the circumference of the circle
- Using some member functions to compute area and perimeter of the circle
In this example, we are going to learn how to create a circle from the gp package. We are going to use the following new classes:
- gp_Ax2 to define the coordinate system of the circle
- gp_Circ circle class from the gp package
- ElCLib, the Elementary Curve computations Library to evaluate points on the circle
Continue reading “Chapter 1.2 – Curves from the gp package”
- Creating points in 3D space
- Accessing properties of points
- Applying transformations such as rotation or mirroring
In this example, we are going to learn how to create simple points in the Cartesian coordinate system and applying simple transformations on them. The classes that we are going to talk about are:
- gp_Pnt for handling points
- gp_Trsf for dealing with transformations
- gp_Ax1 defining the necessary axes for rotation and mirroring.
Continue reading “Chapter 1.1 – Points and transformations”
The latest tutorial of the OccTutorial series is out! Check out Chapter 1.6 if you want to see how to use BSplClib for evaluating B-Spline curves and curve tangents!
Coming up is a detailed discussion on what is happening in the file.
Where to find the information about OpenCASCADE classes?
Whenever learning a new library, a very important question is where to find documentation about the classes and functions that the library provides. Concerning OpenCASCADE, reading about these features is possible through a Doxygen-generated documentation.
Unfortunately, the reference manual of older releases is not available online. You can only browse the latest release at the official OpenCASCADE website:
This is rather problematic, as the easily-installable OpenCASCADE Community Edition is usually delayed by a couple releases, especially in major Linux distributions. (For example, at the time of writing this article, the latest stable official release of OpenCASCADE was 6.9.1, whereas Ubuntu repositories provide us 6.7.0). This brings us to the next point:
Continue reading “Browsing OpenCASCADE documentation”
Making a simple shape in OpenCASCADE
This first example aims to demonstrate some of the features that OpenCASCADE provides. With a couple of lines of code, we are going to build a very simple shape: a box with a cylindrical hole inside, then export it into a STEP file, which we can later open with FreeCAD. After this, we let OpenCASCADE to compute some physical properties of the shape for us: the volume, its center of gravity, and its principal axes of inertia. The end result will look like this in FreeCAD:
Continue reading “Chapter O – Box with hole”
Welcome to OpenCASCADE tutorials!
What is this page about
If you are interested in learning one of the most capable and most popular open source CAD kernels, you are at the right place! OpenCASCADE is a really powerful library, written in C++, with a lot of capabilites ranging from simple curve computations to heavy-weighted CAD applications, involving data exchange through standard CAD formats and all kind of visualization features. The possibilities using OpenCASCADE are really endless…
The library has been succesfully applied in various projects all revolving around geometric modeling, one of my favourites being the FreeCAD project.
This page is going to host guides and tutorials on how to use the library, starting from the very basic elements of OpenCASCADE up to more detailed things, such as how to create a viewer application.
The source code is available at the following Github repository:
Make sure you clone the repository, and if you want to stay up to date with the latest additions, add yourself as a watcher!
Leave a comment if you have specific requests on what you would like to see in the tutorial series!