Presentation is loading. Please wait.

Presentation is loading. Please wait.

OpenCascade.

Similar presentations


Presentation on theme: "OpenCascade."— 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 Advanced Algorithms
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 Advanced Samples Mesh Framework Express Mesher
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

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

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

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

19 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();

20 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 :

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

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

23 In the header file : In the source 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 //...

24 Geometry

25 I - Review Of Geometry Analytic Geometry Parametric 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.

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

27 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

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

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

30 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

31 II - Elementary Geometry

32 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

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

34 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

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

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

37 Elementary Geometry Overview

38 Basic Geometry Packages

39 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

40 Primitives Of Basic Geometry

41 III - Advanced Geometry
Advanced Geometry Package

42 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)

43 Primitives Of Advanced Geometry

44

45

46

47 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

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

49 IV - Geometry Digest

50 Points Basic : From points : - gp_Pnt(X,Y,Z) - gp::Origin()
- 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.

51 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

52 Projections : From intersections :
- onto curves : GeomAPI_ProjectPointOnCurve class - onto surfaces : GeomAPI_ProjectPointOnSurf class From intersections : - see GeomAPI_IntCS class

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

54 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

55 Extremas : Extrapolation : Information :
- 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.

56 Surfaces From points : From curves :
- 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.

57 Extremas : Extrapolation : Information :
- see GeomAPI_ExtremaSurfaceSurface class Extrapolation : - see GeomLib::ExtentSurfaceByLength() method : extends the bounded surface Surf along one of its boundaries Information : - see GeomLProp_SurfaceTool class

58 Topology

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

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

61

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

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

64 II - Data Structure

65 Topological Data Structure
Shape Hierarchy

66 A shape is defined by : A TShape (TopoDS package)
A local coordinate system (TopLoc package) An orientation (TopAbs package)

67 The TShape class is provided in the TopoDS package.
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.

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

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

70 Graph Structure All the shapes can be subdivided into sub-shapes according to the following graph :

71 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]

72 TopoDS_Shape are manipulated by value
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

73 // 1 -- correct if (aShape
// 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;

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

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

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

77 Example : TopExp_Explorer Exp; for (Exp.Init(aShape,TopAbs_EDGE); Exp.More(); Exp.Next()) { TopoDS_Edge myEdge; myEdge = TopoDS::Edge(Exp.Current()); }

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

79 TopExp::MapShapesAndAncestors() method returns all the entities that reference another one.

80 BRepFilletAPI_MakeChamfer MC(theBox);
// add all the edges to chamfer TopTools_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); }

81 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().

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

83 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

84 Topology And 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

85 Generated entities are : (Store geometric information)
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

86 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)

87 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)

88 The SameParameter property forces a point to have the same parameter value on the 3D curve and each 2D curves.

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

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

91 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

92 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);

93 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);

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

95 IV - Modeling Algorithms
- BRepAlgoAPI - BRepBuilderAPI - BRepFilletAPI - BRepFeat : Specific package for Advanced Modeling - BRepOffsetAPI - BRepPrimAPI

96 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

97 BRepPrimAPI Package BRepPrimAPI_MakeBox :

98 1 - Creating primitive objects :
BRepPrimAPI_MakeWedge :

99 BRepPrimAPI_MakeSphere

100 1 - Creating primitive objects :
BRepPrimAPI_MakeCone :

101 1 - Creating primitive objects :
BRepPrimAPI_MakeCylinder :

102 1 - Creating primitive objects :
BRepPrimAPI_MakeTorus :

103 2 - Creating sweeps : BRepPrimAPI_MakeHalfSpace : Builds solid from a face or a shell and a point

104 2 - Creating sweeps : - BRepPrimAPI_MakePrism : Makes a linear prism from a shape - BRepPrimAPI_MakeRevol : : Makes a revolved sweep

105 BRepAlgoAPI Package BRepAlgoAPI_Cut

106 BRepAlgoAPI_Fuse

107 BRepAlgoAPI_Common

108 BRepAlgoAPI_Section

109 BRepFilletAPI Package
BRepFilletAPI_MakeFillet BRepFilletAPI_MakeFillet2d BRepFilletAPI_MakeChamfer

110 BRepOffsetAPI Package
BRepOffsetAPI_MakeThickSolid : BRepOffsetAPI_DraftAngle :

111 BRepOffsetAPI_MakePipe :
BRepOffsetAPI_MakeEvolved :

112 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

113 V – Topology Digest

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

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

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

117

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

119 Mechanical features The LinearForm class is used to build a rib or a groove along a developable, planar surface.

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

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

122

123

124

125 Visualization

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

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

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

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

130 Views are sets of graphic objects arranged in a display list
Views are sets of graphic objects arranged in a display list. A view has 2 states : Degenerated (normal mode) Non-Degenerated (Hidden Line mode).

131 Application Interactive Services (AIS) is a set of high level classes allowing you to simply manage display and dynamic selection in a viewer.

132 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

133 Presentation Packages

134 Selection Packages

135 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);

136 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)

137 An Interactive Context has two operating modes :
A default mode named Neutral Point A local Presentation mode named Local Context

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

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

140 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);

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

142 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

143 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

144 3. The Objects: AIS_Shape, AIS_ConnectedInteractive,
AIS_ConnectedShape, AIS_MultipleConnectedInteractive, AIS_MultipleConnectedShape.

145 An Interactive Object can have some graphic attributes which are specific to it, such as color, material or default visualization mode.

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

147 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 (...)

148 III - Presentation

149 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, ...

150 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);

151 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

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

153 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

154 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()

155 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 Vertex 2 - Edge Wire 4 - Face Shell 6 – Solid Compsolid 8 - Compound

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

157 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

158 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);

159 Application Framework

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

161 OCAF Advantages Development task Without OCAF With OCAF
Geometry creation To do Data organization Simplified Saving data in a file Provided Application infrastructure Undo / Redo Copy / Paste

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

163 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

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

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

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

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

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

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

170 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 = T1 : Open a command to modify some specobjects T = T0 : The document contains 3 specobjects : A1, A2, A3

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

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

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

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

175 II - Components Overview

176 Application

177 Document

178 Label

179 Attribute

180 Data Storage

181 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

182 Standard Attributes

183 Shape Attributes NamedShape

184 Tracking Shape Evolution

185 Presentation Attributes

186 IV - Modification And Regeneration

187 Organisation Attribute

188 Recomputation Attribute

189 Evaluation Of Selection

190


Download ppt "OpenCascade."

Similar presentations


Ads by Google