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