1 / 190

OpenCascade

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,

borna
Télécharger la présentation

OpenCascade

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. OpenCascade

  2. Preliminaries

  3. 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.

  4. 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.

  5. 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

  6. Mesh related • Mesh Framework • Express Mesher • Advanced Samples • Advanced XDE • Advanced OCAF • Shape Healer • Kitchen Demo • Camshaft Drive

  7. Object Libraries Modules

  8. Each module contains several libraries, each library contains classes grouped into packages :

  9. Directories Structure

  10. 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

  11. Standard Types

  12. 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).

  13. 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.

  14. 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.

  15. 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.

  16. 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.

  17. 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.

  18. 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();

  19. 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 :

  20. Example :Handle(Geom_BezierCurve) aBezierCurve = Handle(Geom_BezierCurve)::DownCast(aCurve); • If the DownCast operation fails, the result is a null Handle

  21. 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.

  22. 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//...

  23. Geometry

  24. 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.

  25. Mathematics Of Surface modeling • Conic : Circle, Parabola, Hyperbola … • Bezier Curves : • B-Splines :

  26. 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

  27. Interpolation : This is the simplest method, curves pass through all points.

  28. Approximation : A single or a set of piece-wise continuous curves is fitted onto points using defined geometric constraints (tangency, curvature, tolerance...).

  29. 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

  30. II - Elementary Geometry

  31. 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

  32. 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 :

  33. 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

  34. 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.

  35. 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.)

  36. Elementary Geometry Overview

  37. Basic Geometry Packages

  38. 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

  39. Primitives Of Basic Geometry

  40. III - Advanced Geometry • Advanced Geometry Package

  41. 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)

  42. Primitives Of Advanced Geometry

  43. 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

  44. 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.

  45. IV - Geometry Digest

  46. 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.

More Related