42cf5bc1 |
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 |
5 | // |
6 | // This file is part of Open CASCADE Technology software library. |
7 | // |
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. |
13 | // |
14 | // Alternatively, this file may be used under the terms of Open CASCADE |
15 | // commercial license or contractual agreement. |
16 | |
17 | #ifndef _TopoDS_TShape_HeaderFile |
18 | #define _TopoDS_TShape_HeaderFile |
19 | |
42cf5bc1 |
20 | #include <Standard_Type.hxx> |
b2d1851c |
21 | #include <TopAbs.hxx> |
42cf5bc1 |
22 | #include <TopAbs_ShapeEnum.hxx> |
b2d1851c |
23 | #include <TopoDS_ListOfShape.hxx> |
9fd2d2c3 |
24 | |
42cf5bc1 |
25 | class TopoDS_Iterator; |
26 | class TopoDS_Builder; |
27 | |
9fd2d2c3 |
28 | // resolve name collisions with X11 headers |
29 | #ifdef Convex |
30 | #undef Convex |
31 | #endif |
42cf5bc1 |
32 | |
42cf5bc1 |
33 | //! A TShape is a topological structure describing a |
34 | //! set of points in a 2D or 3D space. |
35 | //! |
36 | //! A topological shape is a structure made from other |
37 | //! shapes. This is a deferred class used to support |
38 | //! topological objects. |
39 | //! |
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. |
44 | //! |
45 | //! A TShape contains the following boolean flags : |
46 | //! |
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. |
54 | //! |
55 | //! Users have no direct access to the classes derived |
56 | //! from TShape. They handle them with the classes |
57 | //! derived from Shape. |
25e59720 |
58 | class TopoDS_TShape : public Standard_Transient |
42cf5bc1 |
59 | { |
60 | |
61 | public: |
62 | |
42cf5bc1 |
63 | //! Returns the free flag. |
b2d1851c |
64 | Standard_Boolean Free() const { return ((myFlags & TopoDS_TShape_Flags_Free) != 0); } |
65 | |
42cf5bc1 |
66 | //! Sets the free flag. |
b2d1851c |
67 | void Free (Standard_Boolean theIsFree) { setFlag (TopoDS_TShape_Flags_Free, theIsFree); } |
68 | |
42cf5bc1 |
69 | //! Returns the locked flag. |
b2d1851c |
70 | Standard_Boolean Locked() const { return ((myFlags & TopoDS_TShape_Flags_Locked) != 0); } |
71 | |
42cf5bc1 |
72 | //! Sets the locked flag. |
b2d1851c |
73 | void Locked (Standard_Boolean theIsLocked) { setFlag (TopoDS_TShape_Flags_Locked, theIsLocked); } |
74 | |
42cf5bc1 |
75 | //! Returns the modification flag. |
b2d1851c |
76 | Standard_Boolean Modified() const { return ((myFlags & TopoDS_TShape_Flags_Modified) != 0); } |
77 | |
42cf5bc1 |
78 | //! Sets the modification flag. |
b2d1851c |
79 | void Modified (Standard_Boolean theIsModified) |
80 | { |
81 | setFlag (TopoDS_TShape_Flags_Modified, theIsModified); |
82 | if (theIsModified) |
83 | { |
84 | setFlag (TopoDS_TShape_Flags_Checked, false); // when a TShape is modified it is also unchecked |
85 | } |
86 | } |
87 | |
42cf5bc1 |
88 | //! Returns the checked flag. |
b2d1851c |
89 | Standard_Boolean Checked() const { return ((myFlags & TopoDS_TShape_Flags_Checked) != 0); } |
90 | |
42cf5bc1 |
91 | //! Sets the checked flag. |
b2d1851c |
92 | void Checked (Standard_Boolean theIsChecked) { setFlag (TopoDS_TShape_Flags_Checked, theIsChecked); } |
93 | |
42cf5bc1 |
94 | //! Returns the orientability flag. |
b2d1851c |
95 | Standard_Boolean Orientable() const { return ((myFlags & TopoDS_TShape_Flags_Orientable) != 0); } |
96 | |
42cf5bc1 |
97 | //! Sets the orientability flag. |
b2d1851c |
98 | void Orientable (Standard_Boolean theIsOrientable) { setFlag (TopoDS_TShape_Flags_Orientable, theIsOrientable); } |
99 | |
42cf5bc1 |
100 | //! Returns the closedness flag. |
b2d1851c |
101 | Standard_Boolean Closed() const { return ((myFlags & TopoDS_TShape_Flags_Closed) != 0); } |
102 | |
42cf5bc1 |
103 | //! Sets the closedness flag. |
b2d1851c |
104 | void Closed (Standard_Boolean theIsClosed) { setFlag (TopoDS_TShape_Flags_Closed, theIsClosed); } |
105 | |
42cf5bc1 |
106 | //! Returns the infinity flag. |
b2d1851c |
107 | Standard_Boolean Infinite() const { return ((myFlags & TopoDS_TShape_Flags_Infinite) != 0); } |
108 | |
42cf5bc1 |
109 | //! Sets the infinity flag. |
b2d1851c |
110 | void Infinite (Standard_Boolean theIsInfinite) { setFlag (TopoDS_TShape_Flags_Infinite, theIsInfinite); } |
111 | |
42cf5bc1 |
112 | //! Returns the convexness flag. |
b2d1851c |
113 | Standard_Boolean Convex() const { return ((myFlags & TopoDS_TShape_Flags_Convex) != 0); } |
114 | |
42cf5bc1 |
115 | //! Sets the convexness flag. |
b2d1851c |
116 | void Convex (Standard_Boolean theIsConvex) { setFlag (TopoDS_TShape_Flags_Convex, theIsConvex); } |
117 | |
42cf5bc1 |
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; |
121 | |
122 | //! Returns a copy of the TShape with no sub-shapes. |
123 | Standard_EXPORT virtual Handle(TopoDS_TShape) EmptyCopy() const = 0; |
124 | |
b2d1851c |
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(); } |
42cf5bc1 |
128 | |
129 | friend class TopoDS_Iterator; |
130 | friend class TopoDS_Builder; |
131 | |
132 | |
25e59720 |
133 | DEFINE_STANDARD_RTTIEXT(TopoDS_TShape,Standard_Transient) |
42cf5bc1 |
134 | |
135 | protected: |
136 | |
42cf5bc1 |
137 | //! Constructs an empty TShape. |
138 | //! Free : True |
139 | //! Modified : True |
140 | //! Checked : False |
141 | //! Orientable : True |
142 | //! Closed : False |
143 | //! Infinite : False |
144 | //! Convex : False |
b2d1851c |
145 | TopoDS_TShape() |
146 | : myFlags (TopoDS_TShape_Flags_Free |
147 | | TopoDS_TShape_Flags_Modified |
148 | | TopoDS_TShape_Flags_Orientable) {} |
42cf5bc1 |
149 | |
b2d1851c |
150 | private: |
42cf5bc1 |
151 | |
b2d1851c |
152 | // Defined mask values |
153 | enum TopoDS_TShape_Flags |
154 | { |
155 | TopoDS_TShape_Flags_Free = 0x001, |
156 | TopoDS_TShape_Flags_Modified = 0x002, |
157 | TopoDS_TShape_Flags_Checked = 0x004, |
158 | TopoDS_TShape_Flags_Orientable = 0x008, |
159 | TopoDS_TShape_Flags_Closed = 0x010, |
160 | TopoDS_TShape_Flags_Infinite = 0x020, |
161 | TopoDS_TShape_Flags_Convex = 0x040, |
162 | TopoDS_TShape_Flags_Locked = 0x080 |
163 | }; |
164 | |
165 | //! Set bit flag. |
166 | void setFlag (TopoDS_TShape_Flags theFlag, |
167 | Standard_Boolean theIsOn) |
168 | { |
169 | if (theIsOn) myFlags |= (Standard_Integer )theFlag; |
170 | else myFlags &= ~(Standard_Integer )theFlag; |
171 | } |
42cf5bc1 |
172 | |
173 | private: |
174 | |
42cf5bc1 |
175 | TopoDS_ListOfShape myShapes; |
b2d1851c |
176 | Standard_Integer myFlags; |
42cf5bc1 |
177 | }; |
178 | |
b2d1851c |
179 | DEFINE_STANDARD_HANDLE(TopoDS_TShape, Standard_Transient) |
42cf5bc1 |
180 | |
181 | #endif // _TopoDS_TShape_HeaderFile |