Chapter 1.3 – Polygonizing a circle

Contents

  • Using standard containers of OpenCASCADE from the TCol… package
  • Quick concept of handles
  • Matrix operations using math_Matrix

Introduction

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:

  • TColgp_Array1OfPnt for storing a set of points
  • TColgp_HArray1OfPnt a flavour of the above, allows for passing around smart pointers to arrays (or passing around handles)
  • math_Matrix, class that allows for storing and operating on matrices

Continue reading “Chapter 1.3 – Polygonizing a circle”

Chapter 1.3 – Polygonizing a circle

Chapter 1.2 – Curves from the gp package

Contents

  • 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

Introduction

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”

Chapter 1.2 – Curves from the gp package

Chapter 1.1 – Points and transformations

Contents

  • Creating points in 3D space
  • Accessing properties of points
  • Applying transformations such as rotation or mirroring

Introduction

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”

Chapter 1.1 – Points and transformations

Chapter O – Box with hole

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:
Box with hole

Continue reading “Chapter O – Box with hole”

Chapter O – Box with hole