1 // Created on: 1990-12-13
2 // Created by: Remi Lequette
3 // Copyright (c) 1990-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
6 // This file is part of Open CASCADE Technology software library.
8 // This library is free software; you can redistribute it and/or modify it under
9 // the terms of the GNU Lesser General Public License version 2.1 as published
10 // by the Free Software Foundation, with special exception defined in the file
11 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
12 // distribution for complete text of the license and disclaimer of any warranty.
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
17 #ifndef _TopoDS_TShape_HeaderFile
18 #define _TopoDS_TShape_HeaderFile
20 #include <Standard_Type.hxx>
22 #include <TopAbs_ShapeEnum.hxx>
23 #include <TopoDS_ListOfShape.hxx>
25 class TopoDS_Iterator;
28 // resolve name collisions with X11 headers
33 //! A TShape is a topological structure describing a
34 //! set of points in a 2D or 3D space.
36 //! A topological shape is a structure made from other
37 //! shapes. This is a deferred class used to support
38 //! topological objects.
40 //! TShapes are defined by their optional domain
41 //! (geometry) and their components (other TShapes
42 //! with Locations and Orientations). The components
43 //! are stored in a List of Shapes.
45 //! A TShape contains the following boolean flags :
47 //! - Free : Free or Frozen.
48 //! - Modified : Has been modified.
49 //! - Checked : Has been checked.
50 //! - Orientable : Can be oriented.
51 //! - Closed : Is closed (note that only Wires and Shells may be closed).
52 //! - Infinite : Is infinite.
53 //! - Convex : Is convex.
55 //! Users have no direct access to the classes derived
56 //! from TShape. They handle them with the classes
57 //! derived from Shape.
58 class TopoDS_TShape : public Standard_Transient
63 //! Returns the free flag.
64 Standard_Boolean Free() const { return ((myFlags & TopoDS_TShape_Flags_Free) != 0); }
66 //! Sets the free flag.
67 void Free (Standard_Boolean theIsFree) { setFlag (TopoDS_TShape_Flags_Free, theIsFree); }
69 //! Returns the locked flag.
70 Standard_Boolean Locked() const { return ((myFlags & TopoDS_TShape_Flags_Locked) != 0); }
72 //! Sets the locked flag.
73 void Locked (Standard_Boolean theIsLocked) { setFlag (TopoDS_TShape_Flags_Locked, theIsLocked); }
75 //! Returns the modification flag.
76 Standard_Boolean Modified() const { return ((myFlags & TopoDS_TShape_Flags_Modified) != 0); }
78 //! Sets the modification flag.
79 void Modified (Standard_Boolean theIsModified)
81 setFlag (TopoDS_TShape_Flags_Modified, theIsModified);
84 setFlag (TopoDS_TShape_Flags_Checked, false); // when a TShape is modified it is also unchecked
88 //! Returns the checked flag.
89 Standard_Boolean Checked() const { return ((myFlags & TopoDS_TShape_Flags_Checked) != 0); }
91 //! Sets the checked flag.
92 void Checked (Standard_Boolean theIsChecked) { setFlag (TopoDS_TShape_Flags_Checked, theIsChecked); }
94 //! Returns the orientability flag.
95 Standard_Boolean Orientable() const { return ((myFlags & TopoDS_TShape_Flags_Orientable) != 0); }
97 //! Sets the orientability flag.
98 void Orientable (Standard_Boolean theIsOrientable) { setFlag (TopoDS_TShape_Flags_Orientable, theIsOrientable); }
100 //! Returns the closedness flag.
101 Standard_Boolean Closed() const { return ((myFlags & TopoDS_TShape_Flags_Closed) != 0); }
103 //! Sets the closedness flag.
104 void Closed (Standard_Boolean theIsClosed) { setFlag (TopoDS_TShape_Flags_Closed, theIsClosed); }
106 //! Returns the infinity flag.
107 Standard_Boolean Infinite() const { return ((myFlags & TopoDS_TShape_Flags_Infinite) != 0); }
109 //! Sets the infinity flag.
110 void Infinite (Standard_Boolean theIsInfinite) { setFlag (TopoDS_TShape_Flags_Infinite, theIsInfinite); }
112 //! Returns the convexness flag.
113 Standard_Boolean Convex() const { return ((myFlags & TopoDS_TShape_Flags_Convex) != 0); }
115 //! Sets the convexness flag.
116 void Convex (Standard_Boolean theIsConvex) { setFlag (TopoDS_TShape_Flags_Convex, theIsConvex); }
118 //! Returns the type as a term of the ShapeEnum enum :
119 //! VERTEX, EDGE, WIRE, FACE, ....
120 Standard_EXPORT virtual TopAbs_ShapeEnum ShapeType() const = 0;
122 //! Returns a copy of the TShape with no sub-shapes.
123 Standard_EXPORT virtual Handle(TopoDS_TShape) EmptyCopy() const = 0;
125 //! Returns the number of direct sub-shapes (children).
126 //! @sa TopoDS_Iterator for accessing sub-shapes
127 Standard_Integer NbChildren() const { return myShapes.Size(); }
129 //! Dumps the content of me into the stream
130 Standard_EXPORT void DumpJson (Standard_OStream& theOStream, const Standard_Integer theDepth = -1) const;
132 friend class TopoDS_Iterator;
133 friend class TopoDS_Builder;
136 DEFINE_STANDARD_RTTIEXT(TopoDS_TShape,Standard_Transient)
140 //! Constructs an empty TShape.
144 //! Orientable : True
149 : myFlags (TopoDS_TShape_Flags_Free
150 | TopoDS_TShape_Flags_Modified
151 | TopoDS_TShape_Flags_Orientable) {}
155 // Defined mask values
156 enum TopoDS_TShape_Flags
158 TopoDS_TShape_Flags_Free = 0x001,
159 TopoDS_TShape_Flags_Modified = 0x002,
160 TopoDS_TShape_Flags_Checked = 0x004,
161 TopoDS_TShape_Flags_Orientable = 0x008,
162 TopoDS_TShape_Flags_Closed = 0x010,
163 TopoDS_TShape_Flags_Infinite = 0x020,
164 TopoDS_TShape_Flags_Convex = 0x040,
165 TopoDS_TShape_Flags_Locked = 0x080
169 void setFlag (TopoDS_TShape_Flags theFlag,
170 Standard_Boolean theIsOn)
172 if (theIsOn) myFlags |= (Standard_Integer )theFlag;
173 else myFlags &= ~(Standard_Integer )theFlag;
178 TopoDS_ListOfShape myShapes;
179 Standard_Integer myFlags;
182 DEFINE_STANDARD_HANDLE(TopoDS_TShape, Standard_Transient)
184 #endif // _TopoDS_TShape_HeaderFile