42cf5bc1 |
1 | // Created on: 2009-04-06 |
2 | // Created by: Sergey ZARITCHNY |
3 | // Copyright (c) 2009-2014 OPEN CASCADE SAS |
4 | // |
5 | // This file is part of Open CASCADE Technology software library. |
6 | // |
7 | // This library is free software; you can redistribute it and/or modify it under |
8 | // the terms of the GNU Lesser General Public License version 2.1 as published |
9 | // by the Free Software Foundation, with special exception defined in the file |
10 | // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT |
11 | // distribution for complete text of the license and disclaimer of any warranty. |
12 | // |
13 | // Alternatively, this file may be used under the terms of Open CASCADE |
14 | // commercial license or contractual agreement. |
15 | |
16 | #ifndef _TDataXtd_Constraint_HeaderFile |
17 | #define _TDataXtd_Constraint_HeaderFile |
18 | |
19 | #include <Standard.hxx> |
20 | #include <Standard_Type.hxx> |
21 | |
22 | #include <TDataXtd_ConstraintEnum.hxx> |
23 | #include <Standard_Boolean.hxx> |
24 | #include <TDF_Attribute.hxx> |
25 | #include <Standard_Integer.hxx> |
26 | #include <TDF_LabelList.hxx> |
27 | #include <Standard_OStream.hxx> |
28 | class TDataStd_Real; |
29 | class TDF_Attribute; |
30 | class Standard_GUID; |
31 | class TDF_Label; |
32 | class TNaming_NamedShape; |
33 | class TDF_RelocationTable; |
34 | class TDF_DataSet; |
35 | |
36 | |
37 | class TDataXtd_Constraint; |
38 | DEFINE_STANDARD_HANDLE(TDataXtd_Constraint, TDF_Attribute) |
39 | |
40 | //! The groundwork to define constraint attributes. |
41 | //! The constraint attribute contains the following sorts of data: |
42 | //! - Type whether the constraint attribute is a |
43 | //! geometric constraint or a dimension |
44 | //! - Value the real number value of a numeric |
45 | //! constraint such as an angle or a radius |
46 | //! - Geometries to identify the geometries |
47 | //! underlying the topological attributes which |
48 | //! define the constraint (up to 4) |
49 | //! - Plane for 2D constraints. |
50 | class TDataXtd_Constraint : public TDF_Attribute |
51 | { |
52 | |
53 | public: |
54 | |
55 | |
56 | //! Returns the GUID for constraints. |
57 | Standard_EXPORT static const Standard_GUID& GetID(); |
58 | |
59 | //! Finds or creates the 2D constraint attribute |
60 | //! defined by the planar topological attribute plane |
61 | //! and the label label. |
62 | //! Constraint methods |
63 | //! ================== |
64 | Standard_EXPORT static Handle(TDataXtd_Constraint) Set (const TDF_Label& label); |
65 | |
66 | Standard_EXPORT TDataXtd_Constraint(); |
67 | |
68 | |
69 | //! Finds or creates the constraint attribute defined |
70 | //! by the topological attribute G1 and the constraint type type. |
71 | Standard_EXPORT void Set (const TDataXtd_ConstraintEnum type, const Handle(TNaming_NamedShape)& G1); |
72 | |
73 | |
74 | //! Finds or creates the constraint attribute defined |
75 | //! by the topological attributes G1 and G2, and by |
76 | //! the constraint type type. |
77 | Standard_EXPORT void Set (const TDataXtd_ConstraintEnum type, const Handle(TNaming_NamedShape)& G1, const Handle(TNaming_NamedShape)& G2); |
78 | |
79 | |
80 | //! Finds or creates the constraint attribute defined |
81 | //! by the topological attributes G1, G2 and G3, and |
82 | //! by the constraint type type. |
83 | Standard_EXPORT void Set (const TDataXtd_ConstraintEnum type, const Handle(TNaming_NamedShape)& G1, const Handle(TNaming_NamedShape)& G2, const Handle(TNaming_NamedShape)& G3); |
84 | |
85 | |
86 | //! Finds or creates the constraint attribute defined |
87 | //! by the topological attributes G1, G2, G3 and G4, |
88 | //! and by the constraint type type. |
89 | //! methods to read constraint fields |
90 | //! ================================= |
91 | Standard_EXPORT void Set (const TDataXtd_ConstraintEnum type, const Handle(TNaming_NamedShape)& G1, const Handle(TNaming_NamedShape)& G2, const Handle(TNaming_NamedShape)& G3, const Handle(TNaming_NamedShape)& G4); |
92 | |
93 | |
94 | //! Returns true if this constraint attribute is valid. |
95 | //! By default, true is returned. |
96 | //! When the value of a dimension is changed or |
97 | //! when a geometry is moved, false is returned |
98 | //! until the solver sets it back to true. |
99 | Standard_EXPORT Standard_Boolean Verified() const; |
100 | |
101 | |
102 | //! Returns the type of constraint. |
103 | //! This will be an element of the |
104 | //! TDataXtd_ConstraintEnum enumeration. |
105 | Standard_EXPORT TDataXtd_ConstraintEnum GetType() const; |
106 | |
107 | //! Returns true if this constraint attribute is |
108 | //! two-dimensional. |
109 | Standard_EXPORT Standard_Boolean IsPlanar() const; |
110 | |
111 | //! Returns the topological attribute of the plane |
112 | //! used for planar - i.e., 2D - constraints. |
113 | //! This plane is attached to another label. |
114 | //! If the constraint is not planar, in other words, 3D, |
115 | //! this function will return a null handle. |
116 | Standard_EXPORT const Handle(TNaming_NamedShape)& GetPlane() const; |
117 | |
118 | //! Returns true if this constraint attribute is a |
119 | //! dimension, and therefore has a value. |
120 | Standard_EXPORT Standard_Boolean IsDimension() const; |
121 | |
122 | //! Returns the value of a dimension. |
123 | //! This value is a reference to a TDataStd_Real attribute. |
124 | //! If the attribute is not a dimension, this value will |
125 | //! be 0. Use IsDimension to test this condition. |
126 | Standard_EXPORT const Handle(TDataStd_Real)& GetValue() const; |
127 | |
128 | |
129 | //! Returns the number of geometry attributes in this constraint attribute. |
130 | //! This number will be between 1 and 4. |
131 | Standard_EXPORT Standard_Integer NbGeometries() const; |
132 | |
133 | //! Returns the integer index Index used to access |
134 | //! the array of the constraint or stored geometries of a dimension |
135 | //! Index has a value between 1 and 4. |
136 | //! methods to write constraint fields (use builder) |
137 | //! ================================== |
138 | Standard_EXPORT Handle(TNaming_NamedShape) GetGeometry (const Standard_Integer Index) const; |
139 | |
140 | //! Removes the geometries involved in the |
141 | //! constraint or dimension from the array of |
142 | //! topological attributes where they are stored. |
143 | Standard_EXPORT void ClearGeometries(); |
144 | |
145 | //! Finds or creates the type of constraint CTR. |
146 | Standard_EXPORT void SetType (const TDataXtd_ConstraintEnum CTR); |
147 | |
148 | //! Finds or creates the plane of the 2D constraint |
149 | //! attribute, defined by the planar topological attribute plane. |
150 | Standard_EXPORT void SetPlane (const Handle(TNaming_NamedShape)& plane); |
151 | |
152 | |
153 | //! Finds or creates the real number value V of the dimension constraint attribute. |
154 | Standard_EXPORT void SetValue (const Handle(TDataStd_Real)& V); |
155 | |
156 | |
157 | //! Finds or creates the underlying geometry of the |
158 | //! constraint defined by the topological attribute G |
159 | //! and the integer index Index. |
160 | Standard_EXPORT void SetGeometry (const Standard_Integer Index, const Handle(TNaming_NamedShape)& G); |
161 | |
162 | |
163 | //! Returns true if this constraint attribute defined by status is valid. |
164 | //! By default, true is returned. |
165 | //! When the value of a dimension is changed or |
166 | //! when a geometry is moved, false is returned until |
167 | //! the solver sets it back to true. |
168 | //! If status is false, Verified is set to false. |
169 | Standard_EXPORT void Verified (const Standard_Boolean status); |
170 | |
171 | Standard_EXPORT void Inverted (const Standard_Boolean status); |
172 | |
173 | Standard_EXPORT Standard_Boolean Inverted() const; |
174 | |
175 | Standard_EXPORT void Reversed (const Standard_Boolean status); |
176 | |
177 | Standard_EXPORT Standard_Boolean Reversed() const; |
178 | |
179 | //! collects constraints on Childs for label <aLabel> |
180 | Standard_EXPORT static void CollectChildConstraints (const TDF_Label& aLabel, TDF_LabelList& TheList); |
181 | |
182 | Standard_EXPORT const Standard_GUID& ID() const; |
183 | |
184 | Standard_EXPORT void Restore (const Handle(TDF_Attribute)& With); |
185 | |
186 | Standard_EXPORT Handle(TDF_Attribute) NewEmpty() const; |
187 | |
188 | Standard_EXPORT void Paste (const Handle(TDF_Attribute)& Into, const Handle(TDF_RelocationTable)& RT) const; |
189 | |
190 | Standard_EXPORT virtual Standard_OStream& Dump (Standard_OStream& anOS) const Standard_OVERRIDE; |
191 | |
192 | Standard_EXPORT virtual void References (const Handle(TDF_DataSet)& DS) const Standard_OVERRIDE; |
193 | |
194 | |
195 | |
196 | |
197 | DEFINE_STANDARD_RTTI(TDataXtd_Constraint,TDF_Attribute) |
198 | |
199 | protected: |
200 | |
201 | |
202 | |
203 | |
204 | private: |
205 | |
206 | |
207 | TDataXtd_ConstraintEnum myType; |
208 | Handle(TDataStd_Real) myValue; |
209 | Handle(TDF_Attribute) myGeometries[4]; |
210 | Handle(TDF_Attribute) myPlane; |
211 | Standard_Boolean myIsReversed; |
212 | Standard_Boolean myIsInverted; |
213 | Standard_Boolean myIsVerified; |
214 | |
215 | |
216 | }; |
217 | |
218 | |
219 | |
220 | |
221 | |
222 | |
223 | |
224 | #endif // _TDataXtd_Constraint_HeaderFile |