opencascade
DESCRIPTION
OpenCascade. Preliminaries. Introduction. Open CASCADE Technology is a powerful open source C++ library, consisting of thousands of classes and providing solutions in the area of Surface and solid modeling : to model any type of object, - PowerPoint PPT PresentationTRANSCRIPT
![Page 1: OpenCascade](https://reader033.vdocuments.mx/reader033/viewer/2022061409/568147f1550346895db52859/html5/thumbnails/1.jpg)
OpenCascade
![Page 2: OpenCascade](https://reader033.vdocuments.mx/reader033/viewer/2022061409/568147f1550346895db52859/html5/thumbnails/2.jpg)
Preliminaries
![Page 3: OpenCascade](https://reader033.vdocuments.mx/reader033/viewer/2022061409/568147f1550346895db52859/html5/thumbnails/3.jpg)
Introduction Open CASCADE Technology is a powerful
open source C++ library, consisting of thousands of classes and providing solutions in the area of Surface and solid modeling : to model any type of
object, 3D and 2D visualization : to display and animate
objects, Data exchange : to import and export standard
CAD formats, Rapid application development : to manipulate
custom application data. and in many others in CAD/CAM/CAE, not
excluding AEC, GIS and PDM.
![Page 4: OpenCascade](https://reader033.vdocuments.mx/reader033/viewer/2022061409/568147f1550346895db52859/html5/thumbnails/4.jpg)
Open CASCADE Technology is designed for industrial development of 3D modeling, numeric simulation and visualization applications which require guaranteed quality, reliability and a robust set of tools.
Open CASCADE Technology libraries are distributed in open source for multiple platforms, and protected by Open CASCADE Public License which allows unconditional commercial usage of our code and binaries.
![Page 5: OpenCascade](https://reader033.vdocuments.mx/reader033/viewer/2022061409/568147f1550346895db52859/html5/thumbnails/5.jpg)
Advanced Components Advanced Data Exchange
DXF Import / Export ACIS SAT Import / Export Parasolid XT Import Catia V5 Import
Advanced Algorithms Surface from Scattered Points Canonical Recognition Collision Detection
![Page 6: OpenCascade](https://reader033.vdocuments.mx/reader033/viewer/2022061409/568147f1550346895db52859/html5/thumbnails/6.jpg)
Mesh related Mesh Framework Express Mesher
Advanced Samples Advanced XDE Advanced OCAF Shape Healer Kitchen Demo Camshaft Drive
![Page 7: OpenCascade](https://reader033.vdocuments.mx/reader033/viewer/2022061409/568147f1550346895db52859/html5/thumbnails/7.jpg)
Object Libraries Modules
![Page 8: OpenCascade](https://reader033.vdocuments.mx/reader033/viewer/2022061409/568147f1550346895db52859/html5/thumbnails/8.jpg)
Each module contains several libraries, each library contains classes grouped into packages :
![Page 9: OpenCascade](https://reader033.vdocuments.mx/reader033/viewer/2022061409/568147f1550346895db52859/html5/thumbnails/9.jpg)
Directories Structure
![Page 10: OpenCascade](https://reader033.vdocuments.mx/reader033/viewer/2022061409/568147f1550346895db52859/html5/thumbnails/10.jpg)
What You Should Know To pass through the training
successfully it is necessary to know : C++ Object Oriented Language Programming technologies
In addition, the following knowledge may be useful : Common mathematics, algebra, geometry Basics of Computer Aided Design
![Page 11: OpenCascade](https://reader033.vdocuments.mx/reader033/viewer/2022061409/568147f1550346895db52859/html5/thumbnails/11.jpg)
Standard Types
![Page 12: OpenCascade](https://reader033.vdocuments.mx/reader033/viewer/2022061409/568147f1550346895db52859/html5/thumbnails/12.jpg)
II Notion Of Handles What Is A Handle
In a concept of Object Oriented Language, an object is an instance of a data type. The definition of this object determines the way it can be used.
Data types fall into two categories according to the way they are manipulated : either by value, or by reference (pointer).
![Page 13: OpenCascade](https://reader033.vdocuments.mx/reader033/viewer/2022061409/568147f1550346895db52859/html5/thumbnails/13.jpg)
C++ usual problems linked to usage of pointers are : Syntax difficulties : Where do I put "*", "&",
etc. ? Management difficulties : When should I
delete my objects ? To cope with the last issue, Open CASCADE
Technology provides so called Handle mechanism that is an implementation of smart pointer mechanism. With this mechanism, referenced objects created on the heap are automatically destroyed when no longer in use.
![Page 14: OpenCascade](https://reader033.vdocuments.mx/reader033/viewer/2022061409/568147f1550346895db52859/html5/thumbnails/14.jpg)
The Handle Mechanism In general, the Handle mechanism is
based on two elements : a counter that stores the number of
references to an object in memory, a pointer to an object in memory.
Every time a new handle to an object is created, the object's reference counter is incremented.
![Page 15: OpenCascade](https://reader033.vdocuments.mx/reader033/viewer/2022061409/568147f1550346895db52859/html5/thumbnails/15.jpg)
![Page 16: OpenCascade](https://reader033.vdocuments.mx/reader033/viewer/2022061409/568147f1550346895db52859/html5/thumbnails/16.jpg)
Every time a handle to an object is removed, the object's reference counter is decremented. As soon as the reference counter reaches 0, the object is automatically deleted.
This way the reference counter secures the delete function.
![Page 17: OpenCascade](https://reader033.vdocuments.mx/reader033/viewer/2022061409/568147f1550346895db52859/html5/thumbnails/17.jpg)
Use Of Handles In the program, the handles are
manipulated as conventional pointers : Declaration of a handle : Handle(Geom_BezierCurve)
aBezierCurve;// Note: a new handle points to nothing
Allocation of a handled object : aBezierCurve = new Geom_BezierCurve(...);// Note: operator 'new' is overloaded to benefit from the custom memory management
De-referencing the handle : Standard_Integer NbPoles = aBezierCurve->NbPoles();// Note: operator ?>?is overloaded to provide access to the handled object
To be manipulated by handle, objects have to inherit MMgt_TShared class.
![Page 18: OpenCascade](https://reader033.vdocuments.mx/reader033/viewer/2022061409/568147f1550346895db52859/html5/thumbnails/18.jpg)
Getting Type Of A Handled Object A specific mechanism allows you to find out
the type of an object pointed to by a handle via DynamicType method :
Handle(Standard_Type) aType = aGeom->DynamicType(); Two methods inherited from MMgt_TShared
can be applied to check the type of an object : IsInstance(TheType) : returns Standard_True if
the object is an instance of "TheType" if (aGeom->IsInstance(STANDARD_TYPE(Geom_BezierCurve)))
IsKind(TheType) : returns Standard_True if the object is an instance of "TheType" or an instance of any class that inherits "TheType"
if (aGeom->IsKind(STANDARD_TYPE(Geom_BoundedCurve)))
The macro STANDARD_TYPE returns the object type from a class name.
![Page 19: OpenCascade](https://reader033.vdocuments.mx/reader033/viewer/2022061409/568147f1550346895db52859/html5/thumbnails/19.jpg)
Specific Methods Applicable On Handle IsNull() : returns Standard_True if
the Handle refers to nothing. if (aBezierCurve.IsNull()) ...
Nullify() : nullifies the reference to the object (the reference counter is decremented). aBezierCurve.Nullify();
![Page 20: OpenCascade](https://reader033.vdocuments.mx/reader033/viewer/2022061409/568147f1550346895db52859/html5/thumbnails/20.jpg)
DownCast() : converts the given reference into a reference to a specified class. In pure C++, if B inherits A, we can assign b to a, but not a to b. Using DownCast this is possible :
![Page 21: OpenCascade](https://reader033.vdocuments.mx/reader033/viewer/2022061409/568147f1550346895db52859/html5/thumbnails/21.jpg)
Example :
Handle(Geom_BezierCurve) aBezierCurve = Handle(Geom_BezierCurve)::DownCast(aCurve);
If the DownCast operation fails, the result is a null Handle
![Page 22: OpenCascade](https://reader033.vdocuments.mx/reader033/viewer/2022061409/568147f1550346895db52859/html5/thumbnails/22.jpg)
Definition Of A New Handled Class
Creation Of A Handled Class The users can create theirs own handled
classes (AIS classes for example). These classes must inherit MMgt_TShared or its descendants.
Creating a new handled class it is necessary to respect the following procedure : Define the header file for the handled class, Implement the handled class in the source
file. Once the header file is defined, creation
of the Handle class is automatic.
![Page 23: OpenCascade](https://reader033.vdocuments.mx/reader033/viewer/2022061409/568147f1550346895db52859/html5/thumbnails/23.jpg)
In the header file : #include <Standard_Macro.hxx>
#include <AIS_Shape.hxx>#include <Standard_DefineHandle.hxx>// Your class has to inherit MMgt_TShared or its descendant
DEFINE_STANDARD_HANDLE(MyClass,AIS_Shape)class MyClass : public AIS_Shape
{ // Declare the methods of your class here//...
DEFINE_STANDARD_RTTIEXT(MyClass) }; In the source file :
#include <MyClass.hxx>IMPLEMENT_STANDARD_HANDLE(MyClass,AIS_Shape)
IMPLEMENT_STANDARD_RTTI(MyClass,AIS_Shape)// Define the methods of your class here
//...
![Page 24: OpenCascade](https://reader033.vdocuments.mx/reader033/viewer/2022061409/568147f1550346895db52859/html5/thumbnails/24.jpg)
Geometry
![Page 25: OpenCascade](https://reader033.vdocuments.mx/reader033/viewer/2022061409/568147f1550346895db52859/html5/thumbnails/25.jpg)
I - Review Of Geometry Analytic Geometry
Defined by an explicit equation of type f(x,y) = 0
Parametric Geometry : Defined by a set of equations depending
on one or more parameters.
![Page 26: OpenCascade](https://reader033.vdocuments.mx/reader033/viewer/2022061409/568147f1550346895db52859/html5/thumbnails/26.jpg)
Mathematics Of Surface modeling Conic : Circle, Parabola, Hyperbola … Bezier Curves : B-Splines :
![Page 27: OpenCascade](https://reader033.vdocuments.mx/reader033/viewer/2022061409/568147f1550346895db52859/html5/thumbnails/27.jpg)
Complex surfaces can also be based on curves which can themselves be defined by points. Two numerical methods (or a combination of them) are used to model a curve using points :
Interpolation Smoothing or Approximation
![Page 28: OpenCascade](https://reader033.vdocuments.mx/reader033/viewer/2022061409/568147f1550346895db52859/html5/thumbnails/28.jpg)
Interpolation : This is the simplest method, curves pass through all points.
![Page 29: OpenCascade](https://reader033.vdocuments.mx/reader033/viewer/2022061409/568147f1550346895db52859/html5/thumbnails/29.jpg)
Approximation : A single or a set of piece-wise continuous curves is fitted onto points using defined geometric constraints (tangency, curvature, tolerance...).
![Page 30: OpenCascade](https://reader033.vdocuments.mx/reader033/viewer/2022061409/568147f1550346895db52859/html5/thumbnails/30.jpg)
Geometry Versus Topology It is important to understand the differences
between geometry and topology when using Open CASCADE.
Geometry is representation of simple shapes which have a mathematical description (Cylinder, Planes, Bezier and B-Splines surfaces...).
Topology involves structuring geometry in order to : Delimit a geometric region limited by boundaries Group regions together to define complex
shapes
![Page 31: OpenCascade](https://reader033.vdocuments.mx/reader033/viewer/2022061409/568147f1550346895db52859/html5/thumbnails/31.jpg)
II - Elementary Geometry
![Page 32: OpenCascade](https://reader033.vdocuments.mx/reader033/viewer/2022061409/568147f1550346895db52859/html5/thumbnails/32.jpg)
Open CASCADE Reusable Components
Global Structure The Open CASCADE libraries contain
components The components comprise 3 aspects:
Abstraction, Presentation, Control Each of these aspects contains
packages These in turn contain classes and
functions as seen previously
![Page 33: OpenCascade](https://reader033.vdocuments.mx/reader033/viewer/2022061409/568147f1550346895db52859/html5/thumbnails/33.jpg)
The Component Design Model Open CASCADE is a set of components
the user can manipulate or enlarge by adding his own components.
Each component is structured as shown below :
![Page 34: OpenCascade](https://reader033.vdocuments.mx/reader033/viewer/2022061409/568147f1550346895db52859/html5/thumbnails/34.jpg)
Example : Model Design structure of a 2D circle
Data abstraction : An axis and a radius The Constructors of such a circle are : Default
constructor, Constructor with an axis and a radius (NB : No circle construction with 3 points is allowed
in standard creation. You have to build a CircleFactory as a control.)
Control : To build a circle with a center and a radius To build a circle with 3 points ... (Note : Each control has a method to return the
abstract object) Presentation : The object you display in a
viewer
![Page 35: OpenCascade](https://reader033.vdocuments.mx/reader033/viewer/2022061409/568147f1550346895db52859/html5/thumbnails/35.jpg)
Benefits Data Abstraction is perennial : new
controls can be added without changing the Data Abstraction.
Data Abstraction is minimal : Controls are created as needed during the session.
Controls have a lifetime : Intermediate results can be queried before validation.
![Page 36: OpenCascade](https://reader033.vdocuments.mx/reader033/viewer/2022061409/568147f1550346895db52859/html5/thumbnails/36.jpg)
Component Implementation Data Abstraction, Controls and
Presentation are in separate packages.
Applied Controls in Open CASCADE can be : Direct constructions (Make…) Constraint constructions (in 2D) Algorithms (intersect, boolean operations,
etc.)
![Page 37: OpenCascade](https://reader033.vdocuments.mx/reader033/viewer/2022061409/568147f1550346895db52859/html5/thumbnails/37.jpg)
Elementary Geometry Overview
![Page 38: OpenCascade](https://reader033.vdocuments.mx/reader033/viewer/2022061409/568147f1550346895db52859/html5/thumbnails/38.jpg)
Basic Geometry Packages
![Page 39: OpenCascade](https://reader033.vdocuments.mx/reader033/viewer/2022061409/568147f1550346895db52859/html5/thumbnails/39.jpg)
Use Of Basic Geometry Basic Geometry is manipulated by
value Basic Geometry has no inheritance Use On-Line documentation to get
more information about these packages
![Page 40: OpenCascade](https://reader033.vdocuments.mx/reader033/viewer/2022061409/568147f1550346895db52859/html5/thumbnails/40.jpg)
Primitives Of Basic Geometry
![Page 41: OpenCascade](https://reader033.vdocuments.mx/reader033/viewer/2022061409/568147f1550346895db52859/html5/thumbnails/41.jpg)
III - Advanced Geometry Advanced Geometry Package
![Page 42: OpenCascade](https://reader033.vdocuments.mx/reader033/viewer/2022061409/568147f1550346895db52859/html5/thumbnails/42.jpg)
Use Of Advanced Geometry Hierarchy of classes is STEP compliant Entities from Geom and Geom2d are
manipulated by HANDLE (useful to share data without copying them)
Provide tools to go back and forth from Geom to gp Example :
Handle(Geom_Circle) C = new Geom_Circle(gp_Circ c);
gp_Circ c = C->Circ(); Entities from GC, GCE2d and Geom2dGcc
are manipulated by VALUE (Control Classes)
![Page 43: OpenCascade](https://reader033.vdocuments.mx/reader033/viewer/2022061409/568147f1550346895db52859/html5/thumbnails/43.jpg)
Primitives Of Advanced Geometry
![Page 44: OpenCascade](https://reader033.vdocuments.mx/reader033/viewer/2022061409/568147f1550346895db52859/html5/thumbnails/44.jpg)
![Page 45: OpenCascade](https://reader033.vdocuments.mx/reader033/viewer/2022061409/568147f1550346895db52859/html5/thumbnails/45.jpg)
![Page 46: OpenCascade](https://reader033.vdocuments.mx/reader033/viewer/2022061409/568147f1550346895db52859/html5/thumbnails/46.jpg)
![Page 47: OpenCascade](https://reader033.vdocuments.mx/reader033/viewer/2022061409/568147f1550346895db52859/html5/thumbnails/47.jpg)
Constraint Geometry Constrained geometry creation
involves to qualify solutions and arguments
outside : The solution and argument are outside each other
enclosing : The solution encompasses the argument
enclosed : The solution is encompassed by the argument
![Page 48: OpenCascade](https://reader033.vdocuments.mx/reader033/viewer/2022061409/568147f1550346895db52859/html5/thumbnails/48.jpg)
Arguments are ordered. This means that we have an implicit orientation:
By convention, the interior of a contour is on the left according to the positive direction of the contour description.
![Page 49: OpenCascade](https://reader033.vdocuments.mx/reader033/viewer/2022061409/568147f1550346895db52859/html5/thumbnails/49.jpg)
IV - Geometry Digest
![Page 50: OpenCascade](https://reader033.vdocuments.mx/reader033/viewer/2022061409/568147f1550346895db52859/html5/thumbnails/50.jpg)
Points Basic :
- gp_Pnt(X,Y,Z)- gp::Origin()
From points : - gp_Pnt::Barycenter() : compute the barycenter of 2
points - gp_Pnt::Translate() translates a point.- gp_Pnt::Translated() translates a point (the initial point is duplicated).- gp_Pnt::Rotate() rotates a point.- gp_Pnt::Rotated() rotates a point (the initial point is duplicated).- GProp_PEquation::Point() : returns the mean point of a collection of points, considered to be coincident.
![Page 51: OpenCascade](https://reader033.vdocuments.mx/reader033/viewer/2022061409/568147f1550346895db52859/html5/thumbnails/51.jpg)
From curve : - gp_Circle::Location() : returns the
center of the circle (or the origin of a line)- GCPnts and CPnts packages : to compute points on a 2D or 3D curve - LProp_CLProps to compute a local point on a curve - Geom_Curve::D0() : computes a point identified by a given parameter
![Page 52: OpenCascade](https://reader033.vdocuments.mx/reader033/viewer/2022061409/568147f1550346895db52859/html5/thumbnails/52.jpg)
Projections : - onto curves :
GeomAPI_ProjectPointOnCurve class- onto surfaces : GeomAPI_ProjectPointOnSurf class
From intersections : - see GeomAPI_IntCS class
![Page 53: OpenCascade](https://reader033.vdocuments.mx/reader033/viewer/2022061409/568147f1550346895db52859/html5/thumbnails/53.jpg)
Curves Building curves from points :
- FairCurve_Batten : constructs curves with a constant or linearly increasing section. These curves are two-dimensional, and simulate physical splines or battens.- GeomAPI_PointsToBSpline : builds a 3D BSpline curve which approximates a set of points, with a given continuity.
![Page 54: OpenCascade](https://reader033.vdocuments.mx/reader033/viewer/2022061409/568147f1550346895db52859/html5/thumbnails/54.jpg)
Projections of curves : - onto planes : see GeomAPI::To2d(),
GeomAPI::To3d() methods- onto any surface : see GeomProjLib::Project() method
Intersections : - Geom2dAPI_InterCurveCurve :
intersection between two 2D curves - GeomAPI_IntSS : intersection curves between two surfaces
![Page 55: OpenCascade](https://reader033.vdocuments.mx/reader033/viewer/2022061409/568147f1550346895db52859/html5/thumbnails/55.jpg)
Extremas : - GeomAPI_ExtremaCurveCurve :
extrema between two curves.- GeomAPI_ExtremaCurveSurface : extrema between a curve and a surface.
Extrapolation : - GeomLib::ExtentCurveToPoint()
method is used to extend a bounded curve C to a point P.
Information : - GeomLProp_CurveTool class provides
methods to query local properties of curves.
![Page 56: OpenCascade](https://reader033.vdocuments.mx/reader033/viewer/2022061409/568147f1550346895db52859/html5/thumbnails/56.jpg)
Surfaces From points :
- GeomAPI_PointsToBSplineSurface : builds a BSpline surface which approximates or interpolates a set of points.- GeomPlate_BuildAveragePlane computes an average inertial plane with an array of points.- GeomPlate_BuildPlateSurface builds a plate surface so that it conforms to given curve and / or point constraints.
From curves : - see GeomFill package : builds a ruled
surface between two curves.
![Page 57: OpenCascade](https://reader033.vdocuments.mx/reader033/viewer/2022061409/568147f1550346895db52859/html5/thumbnails/57.jpg)
Extremas : - see GeomAPI_ExtremaSurfaceSurface
class Extrapolation :
- see GeomLib::ExtentSurfaceByLength() method : extends the bounded surface Surf along one of its boundaries
Information : - see GeomLProp_SurfaceTool class
![Page 58: OpenCascade](https://reader033.vdocuments.mx/reader033/viewer/2022061409/568147f1550346895db52859/html5/thumbnails/58.jpg)
Topology
![Page 59: OpenCascade](https://reader033.vdocuments.mx/reader033/viewer/2022061409/568147f1550346895db52859/html5/thumbnails/59.jpg)
I - Review Of Topology Topological Concepts
Topology is the limitation (in the sense of boundary) of a geometric object
Topology is mainly used to describe : Restrictions of a given object Connexity between objects (i.e. how
objects are connected together) In Open CASCADE, topological entities
are called shapes.
![Page 60: OpenCascade](https://reader033.vdocuments.mx/reader033/viewer/2022061409/568147f1550346895db52859/html5/thumbnails/60.jpg)
Topological Entities Vertex Edge Wire Face Shell : a set of faces connected by their
edges. Solid : a part of space limited by shells. Compound : a group of any type of the
topological objects. Compsolid : a set of solids connected by
their faces.
![Page 61: OpenCascade](https://reader033.vdocuments.mx/reader033/viewer/2022061409/568147f1550346895db52859/html5/thumbnails/61.jpg)
![Page 62: OpenCascade](https://reader033.vdocuments.mx/reader033/viewer/2022061409/568147f1550346895db52859/html5/thumbnails/62.jpg)
Shapes Creation Shapes can be created following one
of these two concepts : ABSTRACT TOPOLOGY (TopoDS) : In
this case, the data structure description is built around the notion of reference to an object.
Example : an edge is described by its boundaries which are two vertices.
![Page 63: OpenCascade](https://reader033.vdocuments.mx/reader033/viewer/2022061409/568147f1550346895db52859/html5/thumbnails/63.jpg)
BOUNDARY REPRESENTATION (BRep) : Boundary Representation gives a complete description of an object by associating topological and geometric information. In this case, objects are described by their boundaries.
Example : an edge lies on a curve and is bounded by two vertices.
![Page 64: OpenCascade](https://reader033.vdocuments.mx/reader033/viewer/2022061409/568147f1550346895db52859/html5/thumbnails/64.jpg)
II - Data Structure
![Page 65: OpenCascade](https://reader033.vdocuments.mx/reader033/viewer/2022061409/568147f1550346895db52859/html5/thumbnails/65.jpg)
Topological Data Structure
Shape Hierarchy
![Page 66: OpenCascade](https://reader033.vdocuments.mx/reader033/viewer/2022061409/568147f1550346895db52859/html5/thumbnails/66.jpg)
A shape is defined by : A TShape (TopoDS package) A local coordinate system (TopLoc
package) An orientation (TopAbs package)
![Page 67: OpenCascade](https://reader033.vdocuments.mx/reader033/viewer/2022061409/568147f1550346895db52859/html5/thumbnails/67.jpg)
TShape : A TShape is a pointer which describes the object in its default coordinate system. It is never used directly, what is manipulated is the Shape. The TShape class is provided in the
TopoDS package.
![Page 68: OpenCascade](https://reader033.vdocuments.mx/reader033/viewer/2022061409/568147f1550346895db52859/html5/thumbnails/68.jpg)
Location : The location is described by defining a local coordinate system which references a shape at different positions from that of its definition. Example : all these boxes share the
same TShape (manipulated by handle) but can have different locations.
![Page 69: OpenCascade](https://reader033.vdocuments.mx/reader033/viewer/2022061409/568147f1550346895db52859/html5/thumbnails/69.jpg)
Shapes Connexity Two objects are connected if they
share a same Sub-Shape. Example : Let's consider two edges TE1 and
TE2. Each of them is limited by its boundaries which are vertices (V1F and V1L for TE1 and V2F and V2L for TE2). When these two edges are connected together, they share a common vertex TV2.
![Page 70: OpenCascade](https://reader033.vdocuments.mx/reader033/viewer/2022061409/568147f1550346895db52859/html5/thumbnails/70.jpg)
Graph Structure All the shapes can be subdivided into
sub-shapes according to the following graph :
![Page 71: OpenCascade](https://reader033.vdocuments.mx/reader033/viewer/2022061409/568147f1550346895db52859/html5/thumbnails/71.jpg)
TopoDS_Shape Methods The TopoDS classes provides methods
that allow you to control creation of shapes.
IsNull(), Nullify() : Access to TShape Location(), Move(), Moved() : Access to location Orientation(), Oriented(),Reverse(), Reversed() :
Access to orientation ShapeType() : Returns the type of the TopoDS_Shape IsPartner() : Checks if two shapes have the same TShape
but different location and orientation IsSame() : Checks if two shapes have same TShape and
location but different orientation IsEqual() : Checks if two shapes have same TShape,
location and orientation [equivalent to ‘==‘ operator]
![Page 72: OpenCascade](https://reader033.vdocuments.mx/reader033/viewer/2022061409/568147f1550346895db52859/html5/thumbnails/72.jpg)
TopoDS_Shape are manipulated by value. That is why special methods are implemented to supply DownCast functionality (reminder : DownCast uses Handle) :
TopoDS::Vertex(...) Returns a TopoDS_Vertex TopoDS::Edge(...) Returns a TopoDS_Edge TopoDS::Wire(...) Returns a TopoDS_Wire TopoDS::Face(...) Returns a TopoDS_Face TopoDS::Shell(...) Returns a TopoDS_Shell TopoDS::Solid(...) Returns a TopoDS_Solid TopoDS::CompSolid(...) Returns a TopoDS_CompSolid TopoDS::Compound(...) Returns a TopoDS_Compound
![Page 73: OpenCascade](https://reader033.vdocuments.mx/reader033/viewer/2022061409/568147f1550346895db52859/html5/thumbnails/73.jpg)
// 1 -- correct if (aShape.Shapetype() == TopAbs_VERTEX) { TopoDS_Vertex V; V = TopoDS::Vertex(aShape); }else
// 2 -- correct if (aShape.Shapetype() == TopAbs_VERTEX) TopoDS_Vertex V2 = TopoDS::Vertex(aShape);
// 3 -- rejected by compiler if (aShape.Shapetype() == TopAbs_VERTEX) TopoDS_Vertex V3 = aShape;
![Page 74: OpenCascade](https://reader033.vdocuments.mx/reader033/viewer/2022061409/568147f1550346895db52859/html5/thumbnails/74.jpg)
Topological Tools TopTools package provides basic
tools to act on topological data structure.
TopExp package provides tools for exploring the data structure described with the TopoDS package.
![Page 75: OpenCascade](https://reader033.vdocuments.mx/reader033/viewer/2022061409/568147f1550346895db52859/html5/thumbnails/75.jpg)
Basic Tools The TopTools package provides
utilities for the topological data structure : Some classes, to hash a shape based on
the TShape with or without Location and Orientation.
Some classes for writing and reading Location and Shapes.
Instantiation of TCollections for shapes. For more details about these tools, you
can consult the on-line documentation.
![Page 76: OpenCascade](https://reader033.vdocuments.mx/reader033/viewer/2022061409/568147f1550346895db52859/html5/thumbnails/76.jpg)
Exploring Shapes Exploring a topological data structure
means finding all the sub-objects of a given type that compose this shape. General tools to explore a shape are
available. Some of them are described below. For the others, consult the on-line documentation.
TopExp_Explorer class allows to explore a shape and returns all sub-shapes contained in it with the possibility to select a kind of entities (for example, only faces).
![Page 77: OpenCascade](https://reader033.vdocuments.mx/reader033/viewer/2022061409/568147f1550346895db52859/html5/thumbnails/77.jpg)
Example : TopExp_Explorer Exp;
for (Exp.Init(aShape,TopAbs_EDGE); Exp.More(); Exp.Next()) { TopoDS_Edge myEdge; myEdge = TopoDS::Edge(Exp.Current()); }
![Page 78: OpenCascade](https://reader033.vdocuments.mx/reader033/viewer/2022061409/568147f1550346895db52859/html5/thumbnails/78.jpg)
BRepTools_WireExplorer class is used to return the edges of a wire in their order of connexion.
TopExp::MapShapes() method allows to explore shapes but detects common elements and puts results in a map.
![Page 79: OpenCascade](https://reader033.vdocuments.mx/reader033/viewer/2022061409/568147f1550346895db52859/html5/thumbnails/79.jpg)
TopExp::MapShapesAndAncestors() method returns all the entities that reference another one.
![Page 80: OpenCascade](https://reader033.vdocuments.mx/reader033/viewer/2022061409/568147f1550346895db52859/html5/thumbnails/80.jpg)
BRepFilletAPI_MakeChamfer MC(theBox);// add all the edges to chamferTopTools_IndexedDataMapOfShapeListOfShape M;/* put each edge (E1, E2, E3 and E4) in a map M and bind it with the list
of faces which reference it (F1, F5, ...). */TopExp::MapShapesAndAncestors(theBox,
TopAbs_EDGE,TopAbs_FACE,M);Standard_Integer i;for (i = 1; i<=M.Extent(); i++) { /* Explore M and return the key associated with index i (an edge or a
face) */TopoDS_Edge E = TopoDS::Edge(M.FindKey(i));TopoDS_Face F = TopoDS::Face(M.FindFromIndex(i).First());/* use all edges by applying Add() method to generate the chamfer. */MC.Add(5,5,E,F);}
![Page 81: OpenCascade](https://reader033.vdocuments.mx/reader033/viewer/2022061409/568147f1550346895db52859/html5/thumbnails/81.jpg)
In Open CASCADE, there is no back pointer from sub-shapes to shapes.
So if you want to find all the faces which contain a given vertex or a given face, you have to use this tool : TopExp::MapShapesAndAncestors().
![Page 82: OpenCascade](https://reader033.vdocuments.mx/reader033/viewer/2022061409/568147f1550346895db52859/html5/thumbnails/82.jpg)
III - Boundary Representation
BRep Introduction The Boundary Representation
describes the data structure for modeling objects in three dimensions.
In BRep modeling, entities are represented by their frontiers or their boundaries.
![Page 83: OpenCascade](https://reader033.vdocuments.mx/reader033/viewer/2022061409/568147f1550346895db52859/html5/thumbnails/83.jpg)
BRep mixes Geometry with Topology : Geometry : a face lies on a surface, an
edge lies on a curve and a vertex lies on a point ;
Topology : connectivity of shapes. BRep description lies on two packages
: TopoDS package is used to describe the
topological structure of objects, Geom (and Geom2d) packages are used
to describe the geometry of these objects
![Page 84: OpenCascade](https://reader033.vdocuments.mx/reader033/viewer/2022061409/568147f1550346895db52859/html5/thumbnails/84.jpg)
Topology And Geometry In BRep
Geometry in BRep BRep_TVertex, BRep_TEdge or
BRep_TFace are defined to add geometric information on the BRep model.
BRep_TFace, BRep_TEdge and BRep_TVertex inherit from TopoDS_TShape.
The geometric information is not stored in the same way according to the topological entity
![Page 85: OpenCascade](https://reader033.vdocuments.mx/reader033/viewer/2022061409/568147f1550346895db52859/html5/thumbnails/85.jpg)
Topology In BRep Generated entities are : (Store
geometric information) Space limited by faces BRep_TFace Surface limited by edges BRep_TEdge Curve limited by Vertices BRep_Tvertex
BRep_TFace, BRep_TEdge and
BRep_TVertex inherit from TopoDS_Tshape
![Page 86: OpenCascade](https://reader033.vdocuments.mx/reader033/viewer/2022061409/568147f1550346895db52859/html5/thumbnails/86.jpg)
Geometry In BRep_TVertex BRep_TVertex Geometry is stored as :
A 3D point (gp_Pnt) A list of points on curves (Geom_Curve,
parameter) A list of points on surfaces (Uparameter,
Vparameter , Geom_Surface)
![Page 87: OpenCascade](https://reader033.vdocuments.mx/reader033/viewer/2022061409/568147f1550346895db52859/html5/thumbnails/87.jpg)
Geometry In BRep_TEdge BRep_TEdge Geometry is stored as :
A Geom_Curve and the 2 vertices parameter
A list of curves on surfaces (Geom2d_Curve, V1parameter, V2parameter, Geom_Surface, V1UVCoord V2UVCoord)
![Page 88: OpenCascade](https://reader033.vdocuments.mx/reader033/viewer/2022061409/568147f1550346895db52859/html5/thumbnails/88.jpg)
The SameParameter property forces a point to have the same parameter value on the 3D curve and each 2D curves.
![Page 89: OpenCascade](https://reader033.vdocuments.mx/reader033/viewer/2022061409/568147f1550346895db52859/html5/thumbnails/89.jpg)
Geometry In BRep_TFace BRep_TFace Geometry is stored as a
Geom_Surface Note that for the BRep_TFace, it is
necessary to define a location with the TopLoc package.
![Page 90: OpenCascade](https://reader033.vdocuments.mx/reader033/viewer/2022061409/568147f1550346895db52859/html5/thumbnails/90.jpg)
BRep Tools Two packages propose tools to
manipulate BRep models : The BRep package provides classes :
to access the geometric information in the data structure : the BRep_Tool class,
to set a precision for topology entities : the BRep_Builder class.
The BRepAdaptor package provides classes to access the geometry of the BRep models.
![Page 91: OpenCascade](https://reader033.vdocuments.mx/reader033/viewer/2022061409/568147f1550346895db52859/html5/thumbnails/91.jpg)
The BRep_Tool Class BRep_Tool class provides methods to
access the geometric information in a model : Tolerance(...) Returns a Standard_Real Surface(...) Returns a Geom_Surface Curve(...) Returns a Geom_Curve CurveOnSurface(...) Returns a
Geom2d_Curve Pnt(...) Returns a gp_Pnt
![Page 92: OpenCascade](https://reader033.vdocuments.mx/reader033/viewer/2022061409/568147f1550346895db52859/html5/thumbnails/92.jpg)
The BRep_Builder Class Among the tools, we find the BRep_Builder
class which provides the methods for creating a model step by step by associating geometry and topology. This class enables you to :
1. Change precision / Tolerance... Standard_Real aTol = 1e-4;/* a Vertex is created from point P with tolerance
Precision::Confusion() */TopoDS_Vertex aVertex = BRepBuilderAPI_MakeVertex(P);BRep_Builder aBuilder;/* The tolerance Precision::Confusion() becomes aTol */aBuilder.UpdateVertex(aVertex, aTol);
![Page 93: OpenCascade](https://reader033.vdocuments.mx/reader033/viewer/2022061409/568147f1550346895db52859/html5/thumbnails/93.jpg)
2. Build a compound TopoDS_Compound aComp;BRep_Builder aBuilder; /* Create a new compound */aBuilder.MakeCompound(aComp); //Make an
empty result/* Add a shape to compound */aBuilder.Add(aComp, aShape1);
![Page 94: OpenCascade](https://reader033.vdocuments.mx/reader033/viewer/2022061409/568147f1550346895db52859/html5/thumbnails/94.jpg)
The BRepAdaptor Package This package provides classes to perform
geometric computation directly on topological data structure.
The classes defined in BRepAdaptor are : BRepAdaptor_Surface allows to see a face
like a Surface from package Adaptor2d. BRepAdaptor_Curve allows to see an edge
like a Curve from package Adaptor3d. BRepAdaptor_Curve2d allows to see a curve
on a face like a Curve2d from package Adaptor2d.
![Page 95: OpenCascade](https://reader033.vdocuments.mx/reader033/viewer/2022061409/568147f1550346895db52859/html5/thumbnails/95.jpg)
IV - Modeling Algorithms - BRepAlgoAPI
- BRepBuilderAPI- BRepFilletAPI- BRepFeat : Specific package for Advanced Modeling- BRepOffsetAPI- BRepPrimAPI
![Page 96: OpenCascade](https://reader033.vdocuments.mx/reader033/viewer/2022061409/568147f1550346895db52859/html5/thumbnails/96.jpg)
BRepBuilderAPI Package 1 - Building objects :
BRepBuilderAPI_MakeVertex : Builds a vertex from points
BRepBuilderAPI_MakeEdge, MakeEdge2d : Builds edges from curves
BRepBuilderAPI_MakePolygon : Builds wire from points BRepBuilderAPI_MakeWire : Builds a wire from edges BRepBuilderAPI_MakeFace : Builds a face from a
surface BRepBuilderAPI_MakeShell : Builds a shell from non C2
surface BRepBuilderAPI_MakeSolid : Builds a solid from shell
2 - Modifying objects : BRepBuilderAPI_Transform : Applies transformation to
a shape BRepBuilderAPI_Copy : Duplicates shapes
![Page 97: OpenCascade](https://reader033.vdocuments.mx/reader033/viewer/2022061409/568147f1550346895db52859/html5/thumbnails/97.jpg)
BRepPrimAPI Package BRepPrimAPI_MakeBox :
![Page 98: OpenCascade](https://reader033.vdocuments.mx/reader033/viewer/2022061409/568147f1550346895db52859/html5/thumbnails/98.jpg)
1 - Creating primitive objects : BRepPrimAPI_MakeWedge :
![Page 99: OpenCascade](https://reader033.vdocuments.mx/reader033/viewer/2022061409/568147f1550346895db52859/html5/thumbnails/99.jpg)
BR
epPrim
API_M
ake
Sph
ere
![Page 100: OpenCascade](https://reader033.vdocuments.mx/reader033/viewer/2022061409/568147f1550346895db52859/html5/thumbnails/100.jpg)
1 - Creating primitive objects : BRepPrimAPI_MakeCone :
![Page 101: OpenCascade](https://reader033.vdocuments.mx/reader033/viewer/2022061409/568147f1550346895db52859/html5/thumbnails/101.jpg)
1 - Creating primitive objects : BRepPrimAPI_MakeCylinder :
![Page 102: OpenCascade](https://reader033.vdocuments.mx/reader033/viewer/2022061409/568147f1550346895db52859/html5/thumbnails/102.jpg)
1 - Creating primitive objects : BRepPrimAPI_MakeTorus :
![Page 103: OpenCascade](https://reader033.vdocuments.mx/reader033/viewer/2022061409/568147f1550346895db52859/html5/thumbnails/103.jpg)
2 - Creating sweeps : BRepPrimAPI_MakeHalfSpace :
Builds solid from a face or a shell and a point
![Page 104: OpenCascade](https://reader033.vdocuments.mx/reader033/viewer/2022061409/568147f1550346895db52859/html5/thumbnails/104.jpg)
2 - Creating sweeps : - BRepPrimAPI_MakePrism : Makes a linear
prism from a shape - BRepPrimAPI_MakeRevol : : Makes a revolved
sweep
![Page 105: OpenCascade](https://reader033.vdocuments.mx/reader033/viewer/2022061409/568147f1550346895db52859/html5/thumbnails/105.jpg)
BRepAlgoAPI Package BRepAlgoAPI_Cut
![Page 106: OpenCascade](https://reader033.vdocuments.mx/reader033/viewer/2022061409/568147f1550346895db52859/html5/thumbnails/106.jpg)
BRepAlgoAPI_Fuse
![Page 107: OpenCascade](https://reader033.vdocuments.mx/reader033/viewer/2022061409/568147f1550346895db52859/html5/thumbnails/107.jpg)
BRepAlgoAPI_Common
![Page 108: OpenCascade](https://reader033.vdocuments.mx/reader033/viewer/2022061409/568147f1550346895db52859/html5/thumbnails/108.jpg)
BRepAlgoAPI_Section
![Page 109: OpenCascade](https://reader033.vdocuments.mx/reader033/viewer/2022061409/568147f1550346895db52859/html5/thumbnails/109.jpg)
BRepFilletAPI Package BRepFilletAPI_MakeFillet BRepFilletAPI_MakeFillet2d BRepFilletAPI_MakeChamfer
![Page 110: OpenCascade](https://reader033.vdocuments.mx/reader033/viewer/2022061409/568147f1550346895db52859/html5/thumbnails/110.jpg)
BRepOffsetAPI Package BRepOffsetAPI_MakeThickSolid : BRepOffsetAPI_DraftAngle :
![Page 111: OpenCascade](https://reader033.vdocuments.mx/reader033/viewer/2022061409/568147f1550346895db52859/html5/thumbnails/111.jpg)
BRepOffsetAPI_MakePipe : BRepOffsetAPI_MakeEvolved :
![Page 112: OpenCascade](https://reader033.vdocuments.mx/reader033/viewer/2022061409/568147f1550346895db52859/html5/thumbnails/112.jpg)
BRepOffsetAPI_ThruSections : Builds shell or solid from wire
BRepOffsetAPI_Sewing builds a shell from a set of faces including connectivity
BRepOffsetAPI_FindContiguousEdges : finds the contiguous edges among a set of shapes within the given tolerance
![Page 113: OpenCascade](https://reader033.vdocuments.mx/reader033/viewer/2022061409/568147f1550346895db52859/html5/thumbnails/113.jpg)
V – Topology Digest
![Page 114: OpenCascade](https://reader033.vdocuments.mx/reader033/viewer/2022061409/568147f1550346895db52859/html5/thumbnails/114.jpg)
VI - Features “ Feature” is used to qualify an element
of shape which characterizes a form such as a boss, a hole, a rib, slots, etc. In that sense features are extensions of the classical boundary representation of shapes.
The BRepFeat package is used to create and manipulate form and mechanical features in a Boundary Representation framework. Features can be depressions or protrusions.
![Page 115: OpenCascade](https://reader033.vdocuments.mx/reader033/viewer/2022061409/568147f1550346895db52859/html5/thumbnails/115.jpg)
The BRepFeat classes are used to build :
Form features including the following types :
- Draft Prism; - Prism; - Pipe; - Revolved feature.
Mechanical features including : - ribs
- protrusions grooves (or slots)- depressions along planar(linear) surfaces or revolution
surfaces.
![Page 116: OpenCascade](https://reader033.vdocuments.mx/reader033/viewer/2022061409/568147f1550346895db52859/html5/thumbnails/116.jpg)
The BRepFeat_MakePrism class describes functions to build a prism feature, that means a prism interacting with a shape.
The BRepFeat_MakeRevol class is used to build revolved shells from basis shapes.
![Page 117: OpenCascade](https://reader033.vdocuments.mx/reader033/viewer/2022061409/568147f1550346895db52859/html5/thumbnails/117.jpg)
![Page 118: OpenCascade](https://reader033.vdocuments.mx/reader033/viewer/2022061409/568147f1550346895db52859/html5/thumbnails/118.jpg)
The MakeDPrism class describes functions to build draft prism topologies from basic shape surfaces.
The MakePipe class constructs compound shapes with pipe features.
These topologies can be depression or protrusion.
![Page 119: OpenCascade](https://reader033.vdocuments.mx/reader033/viewer/2022061409/568147f1550346895db52859/html5/thumbnails/119.jpg)
Mechanical features The LinearForm class is used to build
a rib or a groove along a developable, planar surface.
![Page 120: OpenCascade](https://reader033.vdocuments.mx/reader033/viewer/2022061409/568147f1550346895db52859/html5/thumbnails/120.jpg)
The Gluer Class It is used to glue two solids along faces. The contact faces of the glued shapes must have
no part outside the contact faces of the basic shape.
This class is created or initialized from two shapes.
![Page 121: OpenCascade](https://reader033.vdocuments.mx/reader033/viewer/2022061409/568147f1550346895db52859/html5/thumbnails/121.jpg)
The SplitShape Class BRepFeat_SplitShape class is used
to split faces of a shape with wires or edges. The shape containing the new entities is rebuilt, sharing the unmodified ones.
![Page 122: OpenCascade](https://reader033.vdocuments.mx/reader033/viewer/2022061409/568147f1550346895db52859/html5/thumbnails/122.jpg)
![Page 123: OpenCascade](https://reader033.vdocuments.mx/reader033/viewer/2022061409/568147f1550346895db52859/html5/thumbnails/123.jpg)
![Page 124: OpenCascade](https://reader033.vdocuments.mx/reader033/viewer/2022061409/568147f1550346895db52859/html5/thumbnails/124.jpg)
![Page 125: OpenCascade](https://reader033.vdocuments.mx/reader033/viewer/2022061409/568147f1550346895db52859/html5/thumbnails/125.jpg)
Visualization
![Page 126: OpenCascade](https://reader033.vdocuments.mx/reader033/viewer/2022061409/568147f1550346895db52859/html5/thumbnails/126.jpg)
I - Introduction Visualization in Open CASCADE is
managed by a set of tools independent of the definition of the objects.
This allows: to define as many modes of presentation
as you want for a same object, to define as many modes of selection as
you want for a same object.
![Page 127: OpenCascade](https://reader033.vdocuments.mx/reader033/viewer/2022061409/568147f1550346895db52859/html5/thumbnails/127.jpg)
These presentation or selection modes are available: either from ready-to-use algorithms which
create graphic presentations from geometric models
either from user defined algorithms which create specific graphic presentation.
![Page 128: OpenCascade](https://reader033.vdocuments.mx/reader033/viewer/2022061409/568147f1550346895db52859/html5/thumbnails/128.jpg)
Display is managed through the presentation services and selection through the selection services. With these services, data structures and
algorithms are provided to display objects of your application, and to support the graphical selection of these objects.
Such a graphical application created with these tools uses Viewers, Views and AIS (Application Interactive Services).
![Page 129: OpenCascade](https://reader033.vdocuments.mx/reader033/viewer/2022061409/568147f1550346895db52859/html5/thumbnails/129.jpg)
Key Words Viewers manage a list of views and
thus allow visualizing objects. Note that each object is displayed in all views. Any number of viewers can be created in an application for different purposes.
![Page 130: OpenCascade](https://reader033.vdocuments.mx/reader033/viewer/2022061409/568147f1550346895db52859/html5/thumbnails/130.jpg)
Views are sets of graphic objects arranged in a display list. A view has 2 states : Degenerated (normal mode) Non-Degenerated (Hidden Line mode).
![Page 131: OpenCascade](https://reader033.vdocuments.mx/reader033/viewer/2022061409/568147f1550346895db52859/html5/thumbnails/131.jpg)
Application Interactive Services (AIS) is a set of high level classes allowing you to simply manage display and dynamic selection in a viewer.
![Page 132: OpenCascade](https://reader033.vdocuments.mx/reader033/viewer/2022061409/568147f1550346895db52859/html5/thumbnails/132.jpg)
Presentation Packages
Selection packages
Basic Management
PrsMgr SelectMgr
2D objects V2d and Graphic2d
SelectBasics, Select2d, Select3d and StdSelect
3D objects V3d, Prs3d, Graphic3d and StdPrs
![Page 133: OpenCascade](https://reader033.vdocuments.mx/reader033/viewer/2022061409/568147f1550346895db52859/html5/thumbnails/133.jpg)
Presentation Packages
![Page 134: OpenCascade](https://reader033.vdocuments.mx/reader033/viewer/2022061409/568147f1550346895db52859/html5/thumbnails/134.jpg)
Selection Packages
![Page 135: OpenCascade](https://reader033.vdocuments.mx/reader033/viewer/2022061409/568147f1550346895db52859/html5/thumbnails/135.jpg)
II - Application Interactive Services
Interactive Context The interactive context is the
central entity which pilots visualizations and selections.
The constructor of an Interactive Context defines a principal viewer : AIS_InteractiveContext(const Handle(V3d_Viewer)& MainViewer);
![Page 136: OpenCascade](https://reader033.vdocuments.mx/reader033/viewer/2022061409/568147f1550346895db52859/html5/thumbnails/136.jpg)
The Interactive Context allows you to manage the graphic and "selectable" behavior of interactive objects by providing useful mechanisms like: Graphic Presentation (Display(), Highlight(),
Erase() ... methods) Dynamic Selection (MoveTo(), Select(),
ShiftSelect() ... methods) Selection results (InitSelected(),
MoreSelected() ... methods) Shape oriented methods (SelectedShape() ...
methods)
![Page 137: OpenCascade](https://reader033.vdocuments.mx/reader033/viewer/2022061409/568147f1550346895db52859/html5/thumbnails/137.jpg)
An Interactive Context has two operating modes : A default mode named Neutral Point A local Presentation mode named Local
Context
![Page 138: OpenCascade](https://reader033.vdocuments.mx/reader033/viewer/2022061409/568147f1550346895db52859/html5/thumbnails/138.jpg)
Opening Local Contexts allows you to : Prepare and use a temporary
presentation as well as a selection environment without disturbing the neutral point.
Break down a shape into sub-shapes. Each selection mode represents a breakdown into sensitive primitives. (for a shape, there are 7 selection modes : selection of the shape, selection of the vertices, edges, wires, faces, shells, and the constituent solids.)
![Page 139: OpenCascade](https://reader033.vdocuments.mx/reader033/viewer/2022061409/568147f1550346895db52859/html5/thumbnails/139.jpg)
You can open several local contexts (identified by an index), but only the last is active.
Standard_Integer OpenLocalContext();
Some functions can only be used in Local Context state. Others have context specific behaviors.
![Page 140: OpenCascade](https://reader033.vdocuments.mx/reader033/viewer/2022061409/568147f1550346895db52859/html5/thumbnails/140.jpg)
When closing the local context, you return to the state in which you were before opening it (neutral point or previous local context in the stack).
void CloseLocalContext(const Standard_Integer Index=-1);
![Page 141: OpenCascade](https://reader033.vdocuments.mx/reader033/viewer/2022061409/568147f1550346895db52859/html5/thumbnails/141.jpg)
Objects temporarily put in a local context are not recognized by other local contexts.
All objects visualized at Neutral Point or only a few one can be recognized by all local contexts.
![Page 142: OpenCascade](https://reader033.vdocuments.mx/reader033/viewer/2022061409/568147f1550346895db52859/html5/thumbnails/142.jpg)
Interactive Object An Interactive Object is a virtual entity
which can be presented and selected. There are 3 kinds of Interactive
Objects available in AIS package: 1. The construction elements: AIS_Point,
AIS_Axis, AIS_Line, AIS_Circle, AIS_Plane, AIS_Trihedron
![Page 143: OpenCascade](https://reader033.vdocuments.mx/reader033/viewer/2022061409/568147f1550346895db52859/html5/thumbnails/143.jpg)
2. The Relations concerning dimensions and constraints :
AIS_ConcentricRelation, AIS_FixRelation, AIS_IdenticRelation, AIS_ParallelRelation, AIS_PerpendicularRelation, AIS_Relation, AIS_SymmetricRelation, AIS_TangentRelation,
AIS_AngleDimension, AIS_Chamf2dDimension, AIS_Chamf3dDimension,
AIS_DiameterDimension, AIS_DimensionOwner, AIS_LengthDimension,
AIS_OffsetDimension, AIS_RadiusDimension
![Page 144: OpenCascade](https://reader033.vdocuments.mx/reader033/viewer/2022061409/568147f1550346895db52859/html5/thumbnails/144.jpg)
3. The Objects: AIS_Shape, AIS_ConnectedInteractive, AIS_ConnectedShape, AIS_MultipleConnectedInteractive, AIS_MultipleConnectedShape.
![Page 145: OpenCascade](https://reader033.vdocuments.mx/reader033/viewer/2022061409/568147f1550346895db52859/html5/thumbnails/145.jpg)
An Interactive Object can have some graphic attributes which are specific to it, such as color, material or default visualization mode.
![Page 146: OpenCascade](https://reader033.vdocuments.mx/reader033/viewer/2022061409/568147f1550346895db52859/html5/thumbnails/146.jpg)
Use Of AIS Interactive Objects You can reuse standard interactive
objects, but you can also implement your own classes of interactive objects, provided you respect certain rules.
Modifying an interactive object which is already known by the Context must be done using Context functions. You can call the interactive object available functions only if this object has not been loaded into an Interactive Context.
![Page 147: OpenCascade](https://reader033.vdocuments.mx/reader033/viewer/2022061409/568147f1550346895db52859/html5/thumbnails/147.jpg)
User-Defined Interactive Objects Computation of various presentations
of an interactive object is done in Compute functions.
These are automatically called at a visualization or an update request. They have to be redefined for new Interactive Objects. Selection : ComputeSelection (...) Presentation : Compute (...)
![Page 148: OpenCascade](https://reader033.vdocuments.mx/reader033/viewer/2022061409/568147f1550346895db52859/html5/thumbnails/148.jpg)
III - Presentation
![Page 149: OpenCascade](https://reader033.vdocuments.mx/reader033/viewer/2022061409/568147f1550346895db52859/html5/thumbnails/149.jpg)
Use the AIS_InteractiveContext to Display an object void AIS_InteractiveContext::Display(const
Handle(AIS_InteractiveObject)&); By default, the interactive object takes the
graphic attributes of the context in which it is visualized : visualization mode, type of lines, number of isoparameters, ...
![Page 150: OpenCascade](https://reader033.vdocuments.mx/reader033/viewer/2022061409/568147f1550346895db52859/html5/thumbnails/150.jpg)
Each interactive object can have its own visualization attributes: SetDisplayMode(), SetColor(),
SetMaterial(), SetTransparency() A presentation is identified with an
index. By convention, the default representation mode is 0 (wireframe). You can manage the presentation mode at 2 levels :
void SetDisplayMode(const Handle(AIS_InteractiveObject)&, const Standard_Integer aMode);
void SetDisplayMode(const Standard_Integer aMode);
![Page 151: OpenCascade](https://reader033.vdocuments.mx/reader033/viewer/2022061409/568147f1550346895db52859/html5/thumbnails/151.jpg)
Example : an AIS_Shape has 3 visualization modes : mode 0 : Wireframe (default mode) mode 1 : Shading (depending on the type
of shape) mode 2 : Bounding Box
![Page 152: OpenCascade](https://reader033.vdocuments.mx/reader033/viewer/2022061409/568147f1550346895db52859/html5/thumbnails/152.jpg)
IV - Selection Management of selection differs
according to the operating mode : Neutral point or Local Context.
The majority of visualization functions can be used in both, but some of these are specific to each.
![Page 153: OpenCascade](https://reader033.vdocuments.mx/reader033/viewer/2022061409/568147f1550346895db52859/html5/thumbnails/153.jpg)
At Neutral Point A mechanism allows you to highlight
detected entities in the Interactive Context at neutral point
It is possible to: Pre-highlight objects detected at mouse
position MoveTo(), HasDetected(), DetectInteractive()
Select objects at mouse position
![Page 154: OpenCascade](https://reader033.vdocuments.mx/reader033/viewer/2022061409/568147f1550346895db52859/html5/thumbnails/154.jpg)
In A Local Context A mechanism allows you to highlight
detected entities in the Interactive Context in a Local Context
It is possible to: Pre-highlight objects detected at mouse
position MoveTo(), HasDetected(), DetectInteractive(),
DetectedShape()
Select objects at mouse position Select(), ShiftSelect(), InitSelected(),
MoreSelected(), NextSelected(), Applicative(), SelectedShape()
![Page 155: OpenCascade](https://reader033.vdocuments.mx/reader033/viewer/2022061409/568147f1550346895db52859/html5/thumbnails/155.jpg)
Difference Between NP And LC In a Local Context an interactive object
can have an indefinite number of modes of selection. These modes are identified by an index, the default is 0 (It is the only available mode at Neutral Point).
Example : Selection modes for AIS_Shape are : 0 - Shape 1 - Vertex 2 - Edge 3 - Wire 4 - Face 5 - Shell 6 – Solid 7 - Compsolid 8 - Compound
![Page 156: OpenCascade](https://reader033.vdocuments.mx/reader033/viewer/2022061409/568147f1550346895db52859/html5/thumbnails/156.jpg)
At Neutral Point, it is not advisable to activate other identification modes than the default selection mode 0. It is better to open a local context in order to activate specific selection modes.
![Page 157: OpenCascade](https://reader033.vdocuments.mx/reader033/viewer/2022061409/568147f1550346895db52859/html5/thumbnails/157.jpg)
Filter Selection is based on the concept of
dynamic detection which allows to highlight objects when the mouse cursor moves over them. This makes the user be sure that the picked object is the correct one.
Filters allow you to refine the dynamic detection context
![Page 158: OpenCascade](https://reader033.vdocuments.mx/reader033/viewer/2022061409/568147f1550346895db52859/html5/thumbnails/158.jpg)
Users can program their own filters and load them into the interactive context. For instance: Edges based on circles
myAISContext->OpenLocalContext();myAISContext->ActivateStandardMode(TopAbs_EDGE);Handle(StdSelect_EdgeFilter) EdgeFilter = new StdSelect_EdgeFilter(StdSelect_Circle);myAISContext->AddFilter(EdgeFilter);
![Page 159: OpenCascade](https://reader033.vdocuments.mx/reader033/viewer/2022061409/568147f1550346895db52859/html5/thumbnails/159.jpg)
Application Framework
![Page 160: OpenCascade](https://reader033.vdocuments.mx/reader033/viewer/2022061409/568147f1550346895db52859/html5/thumbnails/160.jpg)
I - OCAF Overview What Is OCAF
OCAF is an Application Framework which increases the productivity of development significantly.
OCAF provides a solution for structurization and handling of Application Data, based on the Application / Document architecture.
Because OCAF can handle data and algorithms from Open CASCADE libraries, it is the logical complement of these libraries.
![Page 161: OpenCascade](https://reader033.vdocuments.mx/reader033/viewer/2022061409/568147f1550346895db52859/html5/thumbnails/161.jpg)
OCAF Advantages
Development task Without OCAF
With OCAF
Geometry creation To do To do
Data organization To do Simplified
Saving data in a file
To do Provided
Application infrastructure
To do Provided
Undo / Redo To do Provided
Copy / Paste To do Provided
![Page 162: OpenCascade](https://reader033.vdocuments.mx/reader033/viewer/2022061409/568147f1550346895db52859/html5/thumbnails/162.jpg)
OCAF Architecture An OCAF application manages a
document which contains a specific hierarchical structure.
Application data is attached to this structure in the form of attributes.
![Page 163: OpenCascade](https://reader033.vdocuments.mx/reader033/viewer/2022061409/568147f1550346895db52859/html5/thumbnails/163.jpg)
OCAF Services OCAF assures the following services :
Document management : an OCAF application manages the creation of documents
Associativity between data, in the sense of sharing data between objects
Undo / Redo mechanism applied on the commands
Persistence : saving and restoring documents Modification of document and recomputation
of data Library of ready to use basic objects for
CAD/CAM
![Page 164: OpenCascade](https://reader033.vdocuments.mx/reader033/viewer/2022061409/568147f1550346895db52859/html5/thumbnails/164.jpg)
Basic Concepts APPLICATION : An application manages the
lifecycle (new, close) and the persistence of documents (open, save, save as).
DOCUMENT : A document is produced by an application. It is a container of specobjects. Each specobject has a unique identifier in the document.
SPECOBJECT : A specobject is a set of specifications defining one object. For example, a specobject may contain the form, the name, the color ... of a single object.
![Page 165: OpenCascade](https://reader033.vdocuments.mx/reader033/viewer/2022061409/568147f1550346895db52859/html5/thumbnails/165.jpg)
ATTRIBUTE : An attribute is one characteristic (or view) of an object such as its name, or its form. A specobject is defined by a set of attributes. An attribute is defined by a type and a value.
REFERENCE KEY : The reference key is an invariant reference which may refer to any type of data used in an application. In its transient form it is a label in the data framework, and the data is attached to it in the form of attributes. In its persistent form it is an entry of the label. The entry allows you to retrieve data from a previous session.
LABEL : The label is the identifier of a specobject within the document. It can be seen as a private address of a specobject within a document.
![Page 166: OpenCascade](https://reader033.vdocuments.mx/reader033/viewer/2022061409/568147f1550346895db52859/html5/thumbnails/166.jpg)
GUID or ID : The Global Universal Identifier is an absolutely unique number. OCAF uses IDs in several cases. One of them is to characterize a type of attribute.
![Page 167: OpenCascade](https://reader033.vdocuments.mx/reader033/viewer/2022061409/568147f1550346895db52859/html5/thumbnails/167.jpg)
COMMAND : A command is a set of actions which allow to add, to remove or to modify specobjects in the document. The commands are specific to a type of document.
UNDO/REDO : The Undo/Redo mechanism is applied on the commands.
COPY/PASTE : The Copy/Paste mechanism allows copying of data within a document or between documents.
![Page 168: OpenCascade](https://reader033.vdocuments.mx/reader033/viewer/2022061409/568147f1550346895db52859/html5/thumbnails/168.jpg)
Specobject Representation A specobject is defined by a set of its
attributes, and is identified by a label in the document.
As soon as you know the label that identifies a specobect, from that label you can retrieve an attribute, and from the attribute you can retrieve the value.
![Page 169: OpenCascade](https://reader033.vdocuments.mx/reader033/viewer/2022061409/568147f1550346895db52859/html5/thumbnails/169.jpg)
In OCAF, only one attribute with a given ID can be attached to a single label. To allow several attributes of the same type in the definition of a specobject, sub-labels are used. These sub-labels may contain complementary information, arguments to construct the specobject, etc. Labels and sub-labels are organized in the form of a tree :
•As you may see on the diagram the "Shape" attribute is associated with the first label and the first sub-label.
![Page 170: OpenCascade](https://reader033.vdocuments.mx/reader033/viewer/2022061409/568147f1550346895db52859/html5/thumbnails/170.jpg)
Command Mechanism In OCAF, the modifications of documents are
made within commands. Commands are based on transactions mechanism that allows to undo / redo changes. The following example illustrates the steps of a command execution :
T = T0 :The document contains 3 specobjects : A1, A2, A3
T = T1 :Open a command to modify some specobjects
![Page 171: OpenCascade](https://reader033.vdocuments.mx/reader033/viewer/2022061409/568147f1550346895db52859/html5/thumbnails/171.jpg)
Finalizing A Command At this step, two choices are possible -
commit the command or abort it : T = T2 :
Commit the Command Values generated in the command are
validated. Delta for Undo is generated.
![Page 172: OpenCascade](https://reader033.vdocuments.mx/reader033/viewer/2022061409/568147f1550346895db52859/html5/thumbnails/172.jpg)
When you commit the command, A’1 becomes the usual value within the document. A1 gets to the delta which contains the list of the modifications associated with the time.
![Page 173: OpenCascade](https://reader033.vdocuments.mx/reader033/viewer/2022061409/568147f1550346895db52859/html5/thumbnails/173.jpg)
T = T2 :Abort the Command
Values generated in the command are lost. The document restores the initial state
When you abort the command, the document gets back in its initial state (T=T0). This can be useful if some errors are generated during the modifications. By aborting the command, the initial values are recovered.
![Page 174: OpenCascade](https://reader033.vdocuments.mx/reader033/viewer/2022061409/568147f1550346895db52859/html5/thumbnails/174.jpg)
The undo/redo mechanism is available for a command :
After the Undo, A1 becomes the usual value again and A’1 gets to the delta.
![Page 175: OpenCascade](https://reader033.vdocuments.mx/reader033/viewer/2022061409/568147f1550346895db52859/html5/thumbnails/175.jpg)
II - Components Overview
![Page 176: OpenCascade](https://reader033.vdocuments.mx/reader033/viewer/2022061409/568147f1550346895db52859/html5/thumbnails/176.jpg)
Application
![Page 177: OpenCascade](https://reader033.vdocuments.mx/reader033/viewer/2022061409/568147f1550346895db52859/html5/thumbnails/177.jpg)
Document
![Page 178: OpenCascade](https://reader033.vdocuments.mx/reader033/viewer/2022061409/568147f1550346895db52859/html5/thumbnails/178.jpg)
Label
![Page 179: OpenCascade](https://reader033.vdocuments.mx/reader033/viewer/2022061409/568147f1550346895db52859/html5/thumbnails/179.jpg)
Attribute
![Page 180: OpenCascade](https://reader033.vdocuments.mx/reader033/viewer/2022061409/568147f1550346895db52859/html5/thumbnails/180.jpg)
Data Storage
![Page 181: OpenCascade](https://reader033.vdocuments.mx/reader033/viewer/2022061409/568147f1550346895db52859/html5/thumbnails/181.jpg)
III - Ready to use attributes OCAF provides a set of ready-to-use
attributes which represent typical data used in CAD. These include : Standard attributes : provide functionality to
work with basic data types, such as numeric values, strings etc.
Shape attributes : provide functionality to work with Open CASCADE shapes, such as naming information and tracking of shape evolution
Presentation attributes : provide functionality to work with Application Interactive Services (AIS)
Function attributes : implement the function mechanism of OCAF
![Page 182: OpenCascade](https://reader033.vdocuments.mx/reader033/viewer/2022061409/568147f1550346895db52859/html5/thumbnails/182.jpg)
Standard Attributes
![Page 183: OpenCascade](https://reader033.vdocuments.mx/reader033/viewer/2022061409/568147f1550346895db52859/html5/thumbnails/183.jpg)
Shape Attributes NamedShape
![Page 184: OpenCascade](https://reader033.vdocuments.mx/reader033/viewer/2022061409/568147f1550346895db52859/html5/thumbnails/184.jpg)
Tracking Shape Evolution
![Page 185: OpenCascade](https://reader033.vdocuments.mx/reader033/viewer/2022061409/568147f1550346895db52859/html5/thumbnails/185.jpg)
Presentation Attributes
![Page 186: OpenCascade](https://reader033.vdocuments.mx/reader033/viewer/2022061409/568147f1550346895db52859/html5/thumbnails/186.jpg)
IV - Modification And Regeneration
![Page 187: OpenCascade](https://reader033.vdocuments.mx/reader033/viewer/2022061409/568147f1550346895db52859/html5/thumbnails/187.jpg)
Organisation Attribute
![Page 188: OpenCascade](https://reader033.vdocuments.mx/reader033/viewer/2022061409/568147f1550346895db52859/html5/thumbnails/188.jpg)
Recomputation Attribute
![Page 189: OpenCascade](https://reader033.vdocuments.mx/reader033/viewer/2022061409/568147f1550346895db52859/html5/thumbnails/189.jpg)
Evaluation Of Selection
![Page 190: OpenCascade](https://reader033.vdocuments.mx/reader033/viewer/2022061409/568147f1550346895db52859/html5/thumbnails/190.jpg)