opencascade-使用指南.ppt_第1页
opencascade-使用指南.ppt_第2页
opencascade-使用指南.ppt_第3页
opencascade-使用指南.ppt_第4页
opencascade-使用指南.ppt_第5页
已阅读5页,还剩185页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、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, 3D and 2D visualization : to display and animate objects, Data exch

2、ange : 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.,Open CASCADE Technology is designed for industrial development of 3D modeling, numeric simulation and visualizat

3、ion 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.,Advanc

4、ed 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,Mesh related Mesh Framework Express Mesher Advanced Samples Advanced XDE Advanced OCAF Sha

5、pe Healer Kitchen Demo Camshaft Drive,Object Libraries Modules,Each module contains several libraries, each library contains classes grouped into packages :,Directories Structure,What You Should Know,To pass through the training successfully it is necessary to know : C+ Object Oriented Language Prog

6、ramming technologies In addition, the following knowledge may be useful : Common mathematics, algebra, geometry Basics of Computer Aided Design,Standard Types,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 th

7、is 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).,C+ usual problems linked to usage of pointers are : Syntax difficulties : Where do I put *, / Note: a new handle points to nothing A

8、llocation 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

9、 To be manipulated by handle, objects have to inherit MMgt_TShared class.,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 M

10、Mgt_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 c

11、lass that inherits TheType if (aGeom-IsKind(STANDARD_TYPE(Geom_BoundedCurve) The macro STANDARD_TYPE returns the object type from a class name.,Specific Methods Applicable On Handle,IsNull() : returns Standard_True if the Handle refers to nothing. if (aBezierCurve.IsNull() . Nullify() : nullifies th

12、e reference to the object (the reference counter is decremented). aBezierCurve.Nullify();,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 :,Example :Handle(Geom_BezierC

13、urve) aBezierCurve = Handle(Geom_BezierCurve):DownCast(aCurve); If the DownCast operation fails, the result is a null Handle,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_TShare

14、d 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.,In the header file : #incl

15、ude #include #include / 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 IMPLEMENT_STANDARD_HANDLE(MyClass,AI

16、S_Shape) IMPLEMENT_STANDARD_RTTI(MyClass,AIS_Shape) / Define the methods of your class here/.,Geometry,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.,Mathematics Of S

17、urface modeling,Conic : Circle, Parabola, Hyperbola Bezier Curves : B-Splines :,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,I

18、nterpolation : This is the simplest method, curves pass through all points.,Approximation : A single or a set of piece-wise continuous curves is fitted onto points using defined geometric constraints (tangency, curvature, tolerance.).,Geometry Versus Topology,It is important to understand the differ

19、ences 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 Gro

20、up regions together to define complex shapes,II - Elementary Geometry,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 cl

21、asses and functions as seen previously,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 :,Example : Model Design structure of a 2D circle Data abstraction : An axis and a radius

22、 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 wi

23、th 3 points . (Note : Each control has a method to return the abstract object) Presentation : The object you display in a viewer,Benefits,Data Abstraction is perennial : new controls can be added without changing the Data Abstraction. Data Abstraction is minimal : Controls are created as needed duri

24、ng the session. Controls have a lifetime : Intermediate results can be queried before validation.,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) Algo

25、rithms (intersect, boolean operations, etc.),Elementary Geometry Overview,Basic Geometry Packages,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,Primitives Of Basic Geometry,III - A

26、dvanced Geometry,Advanced Geometry Package,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

27、_Circle(gp_Circ c); gp_Circ c = C-Circ(); Entities from GC, GCE2d and Geom2dGcc are manipulated by VALUE (Control Classes),Primitives Of Advanced Geometry,Constraint Geometry,Constrained geometry creation involves to qualify solutions and arguments outside : The solution and argument are outside eac

28、h other enclosing : The solution encompasses the argument enclosed : The solution is encompassed by the argument,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 descript

29、ion.,IV - Geometry Digest,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

30、: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.,From curve : - gp_Circle:Location() : returns the center of the circle (or the origin of a line)- GCPnts and CPnts packages : to com

31、pute 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,Projections : - onto curves : GeomAPI_ProjectPointOnCurve class- onto surfaces : GeomAPI_ProjectPointOnSurf class From intersections : - see GeomAP

32、I_IntCS class,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 point

33、s, with a given continuity.,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 surfa

34、ces,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 me

35、thods to query local properties of curves.,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 buil

36、ds 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.,Extremas : - see GeomAPI_ExtremaSurfaceSurface class Extrapolation : - see GeomLib:ExtentSurfaceByLength() method : extends the bounded

37、surface Surf along one of its boundaries Information : - see GeomLProp_SurfaceTool class,Topology,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 bet

38、ween objects (i.e. how objects are connected together) In Open CASCADE, topological entities are called shapes.,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 obj

39、ects. Compsolid : a set of solids connected by their faces.,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 it

40、s boundaries which are two vertices.,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 t

41、wo vertices.,II - Data Structure,Topological Data Structure,Shape Hierarchy,A shape is defined by : A TShape (TopoDS package) A local coordinate system (TopLoc package) An orientation (TopAbs package),TShape : A TShape is a pointer which describes the object in its default coordinate system. It is n

42、ever used directly, what is manipulated is the Shape. The TShape class is provided in the TopoDS package.,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 T

43、Shape (manipulated by handle) but can have different locations.,Shapes Connexity,Two objects are connected if they share a same Sub-Shape. Example : Lets 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 t

44、hese two edges are connected together, they share a common vertex TV2.,Graph Structure,All the shapes can be subdivided into sub-shapes according to the following graph :,TopoDS_Shape Methods,The TopoDS classes provides methods that allow you to control creation of shapes. IsNull(), Nullify() : Acce

45、ss 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

46、 two shapes have same TShape and location but different orientation IsEqual() : Checks if two shapes have same TShape, location and orientation equivalent to = operator,TopoDS_Shape are manipulated by value. That is why special methods are implemented to supply DownCast functionality (reminder : Dow

47、nCast 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 To

48、poDS:Compound(.) Returns a TopoDS_Compound,/ 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

49、_VERTEX) TopoDS_Vertex V3 = aShape;,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.,Basic Tools,The TopTools package provides utilities for the topological

50、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.,Exploring Sh

51、apes,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

52、and returns all sub-shapes contained in it with the possibility to select a kind of entities (for example, only faces).,Example : TopExp_Explorer Exp; for (Exp.Init(aShape,TopAbs_EDGE); Exp.More(); Exp.Next() TopoDS_Edge myEdge; myEdge = TopoDS:Edge(Exp.Current(); ,BRepTools_WireExplorer class is us

53、ed 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.,TopExp:MapShapesAndAncestors() method returns all the entities that reference another one.,BRepFilletAPI_MakeChamfer MC(theBox); / a

54、dd 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()

55、; 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); ,In Open CASCADE, there is no

56、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().,III - Boundary Representation,BRep Introduction The Boundary Representation describes the data structure for modeling

57、 objects in three dimensions. In BRep modeling, entities are represented by their frontiers or their boundaries.,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

58、 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,Topology And Geometry In BRep,Geometry in BRep BRep_TVertex, BRep_TEdge or BRep_TFace are defined to add geometric information on the

59、 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,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,Geometry In BRep_TVertex,B

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论