42cf5bc1 |
1 | // Created on: 2004-01-09 |
2 | // Created by: Sergey KUUL |
3 | // Copyright (c) 2004-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 _XCAFDoc_DimTolTool_HeaderFile |
17 | #define _XCAFDoc_DimTolTool_HeaderFile |
18 | |
19 | #include <Standard.hxx> |
20 | #include <Standard_Type.hxx> |
21 | |
c99ad5d7 |
22 | #include <TDataStd_GenericEmpty.hxx> |
42cf5bc1 |
23 | #include <Standard_Boolean.hxx> |
24 | #include <TDF_LabelSequence.hxx> |
25 | #include <Standard_Integer.hxx> |
26 | #include <TColStd_HArray1OfReal.hxx> |
5df609e7 |
27 | #include <TopoDS_Shape.hxx> |
61ace3dc |
28 | #include <NCollection_IndexedDataMap.hxx> |
29 | #include <NCollection_DataMap.hxx> |
5df609e7 |
30 | |
42cf5bc1 |
31 | class XCAFDoc_ShapeTool; |
32 | class TDF_Label; |
33 | class Standard_GUID; |
34 | class TCollection_HAsciiString; |
35 | class TDF_Attribute; |
36 | class TDF_RelocationTable; |
37 | |
38 | |
39 | class XCAFDoc_DimTolTool; |
c99ad5d7 |
40 | DEFINE_STANDARD_HANDLE(XCAFDoc_DimTolTool, TDataStd_GenericEmpty) |
42cf5bc1 |
41 | |
a8a3b37c |
42 | //! Attribute containing GD&T section of XCAF document. |
43 | //! Provide tools for GD&T section management. |
c99ad5d7 |
44 | class XCAFDoc_DimTolTool : public TDataStd_GenericEmpty |
42cf5bc1 |
45 | { |
46 | |
47 | public: |
48 | |
49 | |
50 | Standard_EXPORT XCAFDoc_DimTolTool(); |
51 | |
a8a3b37c |
52 | //! Creates (if not exist) DimTolTool attribute. |
42cf5bc1 |
53 | Standard_EXPORT static Handle(XCAFDoc_DimTolTool) Set (const TDF_Label& L); |
54 | |
a8a3b37c |
55 | //! Returns the standard GD&T tool GUID. |
42cf5bc1 |
56 | Standard_EXPORT static const Standard_GUID& GetID(); |
57 | |
a8a3b37c |
58 | //! Returns the label under which GD&T table is stored. |
42cf5bc1 |
59 | Standard_EXPORT TDF_Label BaseLabel() const; |
60 | |
61 | //! Returns internal XCAFDoc_ShapeTool tool |
62 | Standard_EXPORT const Handle(XCAFDoc_ShapeTool)& ShapeTool(); |
9ebaae37 |
63 | |
a8a3b37c |
64 | //! Returns True if the label belongs to a GD&T table and |
65 | //! is a Dimension definition. |
9ebaae37 |
66 | Standard_EXPORT Standard_Boolean IsDimension (const TDF_Label& theLab) const; |
67 | |
a8a3b37c |
68 | //! Returns a sequence of Dimension labels currently stored |
69 | //! in the GD&T table. |
9ebaae37 |
70 | Standard_EXPORT void GetDimensionLabels (TDF_LabelSequence& theLabels) const; |
71 | |
a8a3b37c |
72 | //! Sets a dimension to sequences target labels. |
73 | Standard_EXPORT void SetDimension (const TDF_LabelSequence& theFirstLS, |
74 | const TDF_LabelSequence& theSecondLS, |
75 | const TDF_Label& theDimL) const; |
1c9d3225 |
76 | |
a8a3b37c |
77 | //! Sets a dimension to target labels. |
78 | Standard_EXPORT void SetDimension(const TDF_Label& theFirstL, |
79 | const TDF_Label& theSecondL, |
80 | const TDF_Label& theDimL) const; |
9ebaae37 |
81 | |
a8a3b37c |
82 | //! Sets a dimension to the target label. |
83 | Standard_EXPORT void SetDimension (const TDF_Label& theL, |
84 | const TDF_Label& theDimL) const; |
9ebaae37 |
85 | |
a8a3b37c |
86 | //! Returns all Dimension labels defined for theShapeL. |
87 | Standard_EXPORT Standard_Boolean GetRefDimensionLabels (const TDF_Label& theShapeL, |
88 | TDF_LabelSequence& theDimensions) const; |
9ebaae37 |
89 | |
a8a3b37c |
90 | //! Adds a dimension definition to the GD&T table and returns its label. |
9ebaae37 |
91 | Standard_EXPORT TDF_Label AddDimension() ; |
92 | |
a8a3b37c |
93 | //! Returns True if the label belongs to the GD&T table and is a dimension tolerance. |
9ebaae37 |
94 | Standard_EXPORT Standard_Boolean IsGeomTolerance (const TDF_Label& theLab) const; |
95 | |
a8a3b37c |
96 | //! Returns a sequence of Tolerance labels currently stored in the GD&T table. |
9ebaae37 |
97 | Standard_EXPORT void GetGeomToleranceLabels (TDF_LabelSequence& theLabels) const; |
98 | |
a8a3b37c |
99 | //! Sets a geometry tolerance from theGeomTolL to theL label. |
100 | //! Checks if theGeomTolL is a geometry tolerance definition first. |
101 | Standard_EXPORT void SetGeomTolerance (const TDF_Label& theL, |
102 | const TDF_Label& theGeomTolL) const; |
1c9d3225 |
103 | |
a8a3b37c |
104 | //! Sets a geometry tolerance from theGeomTolL to sequence of labels theL. |
105 | //! Checks if theGeomTolL is a geometry tolerance definition first. |
106 | Standard_EXPORT void SetGeomTolerance(const TDF_LabelSequence& theL, |
107 | const TDF_Label& theGeomTolL) const; |
9ebaae37 |
108 | |
a8a3b37c |
109 | //! Returns all GeomTolerance labels defined for theShapeL. |
110 | Standard_EXPORT Standard_Boolean GetRefGeomToleranceLabels (const TDF_Label& theShapeL, |
111 | TDF_LabelSequence& theDimTols) const; |
9ebaae37 |
112 | |
a8a3b37c |
113 | //! Adds a GeomTolerance definition to the GD&T table and returns its label. |
9ebaae37 |
114 | Standard_EXPORT TDF_Label AddGeomTolerance(); |
42cf5bc1 |
115 | |
a8a3b37c |
116 | //! Returns True if theLab belongs to the GD&T table and is a dmension tolerance. |
117 | Standard_EXPORT Standard_Boolean IsDimTol(const TDF_Label& theLab) const; |
42cf5bc1 |
118 | |
a8a3b37c |
119 | //! Returns a sequence of D>s currently stored in the GD&T table. |
42cf5bc1 |
120 | Standard_EXPORT void GetDimTolLabels (TDF_LabelSequence& Labels) const; |
121 | |
a8a3b37c |
122 | //! Finds a dimension tolerance definition in the GD&T table |
123 | //! sutisfying the specified kind, values, name and description |
124 | //! and returns its label if found. |
125 | //! Returns False if dimension tolerance is not found in DGTtable. |
126 | Standard_EXPORT Standard_Boolean FindDimTol (const Standard_Integer theKind, |
127 | const Handle(TColStd_HArray1OfReal)& theVal, |
128 | const Handle(TCollection_HAsciiString)& theName, |
129 | const Handle(TCollection_HAsciiString)& theDescription, |
130 | TDF_Label& lab) const; |
131 | |
132 | //! Finds a dimension tolerance in the GD&T table |
133 | //! sutisfying the specified kind, values, name and description |
134 | //! and returns its label if found (or Null label else). |
135 | Standard_EXPORT TDF_Label FindDimTol (const Standard_Integer theKind, |
136 | const Handle(TColStd_HArray1OfReal)& theVal, |
137 | const Handle(TCollection_HAsciiString)& theName, |
138 | const Handle(TCollection_HAsciiString)& theDescription) const; |
139 | |
140 | //! Adds a a dimension tolerance definition with the specified |
141 | //! kind, value, name and description to the GD&T table and returns its label. |
142 | Standard_EXPORT TDF_Label AddDimTol (const Standard_Integer theKind, |
143 | const Handle(TColStd_HArray1OfReal)& theVal, |
144 | const Handle(TCollection_HAsciiString)& theName, |
145 | const Handle(TCollection_HAsciiString)& theDescription) const; |
146 | |
147 | //! Sets existing dimension tolerance to theL label. |
148 | Standard_EXPORT void SetDimTol (const TDF_Label& theL, |
149 | const TDF_Label& theDimTolL) const; |
150 | |
151 | //! Creates a dimension tolerance and sets it to theL label. |
152 | Standard_EXPORT TDF_Label SetDimTol (const TDF_Label& theL, |
153 | const Standard_Integer theKind, |
154 | const Handle(TColStd_HArray1OfReal)& theVal, |
155 | const Handle(TCollection_HAsciiString)& theName, |
156 | const Handle(TCollection_HAsciiString)& theDescription) const; |
157 | |
158 | //! Gets all shape labels reffered by theL label of the GD&T table. |
159 | //! Returns False if there are no shape labels added to the sequences. |
160 | Standard_EXPORT Standard_Boolean GetRefShapeLabel (const TDF_Label& theL, |
161 | TDF_LabelSequence& theShapeLFirst, |
162 | TDF_LabelSequence& theShapeLSecond) const; |
163 | |
164 | //! Returns dimension tolerance assigned to theDimTolL label. |
165 | //! Returns False if no such dimension tolerance is assigned. |
166 | Standard_EXPORT Standard_Boolean GetDimTol (const TDF_Label& theDimTolL, |
167 | Standard_Integer& theKind, |
168 | Handle(TColStd_HArray1OfReal)& theVal, |
169 | Handle(TCollection_HAsciiString)& theName, |
170 | Handle(TCollection_HAsciiString)& theDescription) const; |
171 | |
172 | //! Returns True if label belongs to the GD&T table and |
173 | //! is a Datum definition. |
42cf5bc1 |
174 | Standard_EXPORT Standard_Boolean IsDatum (const TDF_Label& lab) const; |
175 | |
a8a3b37c |
176 | //! Returns a sequence of Datums currently stored |
177 | //! in the GD&T table. |
42cf5bc1 |
178 | Standard_EXPORT void GetDatumLabels (TDF_LabelSequence& Labels) const; |
179 | |
a8a3b37c |
180 | //! Finds a datum sutisfying the specified name, description and |
181 | //! identification and returns its label if found. |
182 | Standard_EXPORT Standard_Boolean FindDatum (const Handle(TCollection_HAsciiString)& theName, |
183 | const Handle(TCollection_HAsciiString)& theDescription, |
184 | const Handle(TCollection_HAsciiString)& theIdentification, |
185 | TDF_Label& lab) const; |
42cf5bc1 |
186 | |
a8a3b37c |
187 | //! Adds a datum definition to the GD&T table and returns its label. |
188 | Standard_EXPORT TDF_Label AddDatum (const Handle(TCollection_HAsciiString)& theName, |
189 | const Handle(TCollection_HAsciiString)& theDescription, |
190 | const Handle(TCollection_HAsciiString)& theIdentification) const; |
9ebaae37 |
191 | |
a8a3b37c |
192 | //! Adds a datum definition to the GD&T table and returns its label. |
9ebaae37 |
193 | Standard_EXPORT TDF_Label AddDatum() ; |
42cf5bc1 |
194 | |
a8a3b37c |
195 | //! Sets a datum to the sequence of shape labels. |
196 | Standard_EXPORT void SetDatum (const TDF_LabelSequence& theShapeLabels, |
197 | const TDF_Label& theDatumL) const; |
198 | |
199 | //! Sets a datum to theL label and binds it with theTolerL label. |
200 | //! A datum with the specified name, description and identification |
201 | //! is created if it isn't found in the GD&T table. |
202 | Standard_EXPORT void SetDatum (const TDF_Label& theL, |
203 | const TDF_Label& theTolerL, |
204 | const Handle(TCollection_HAsciiString)& theName, |
205 | const Handle(TCollection_HAsciiString)& theDescription, |
206 | const Handle(TCollection_HAsciiString)& theIdentification) const; |
207 | |
208 | //! Sets a datum from theDatumL label to theToletL label. |
209 | Standard_EXPORT void SetDatumToGeomTol (const TDF_Label& theDatumL, |
210 | const TDF_Label& theTolerL) const; |
211 | |
212 | //! Returns datum assigned to theDatumL label. |
213 | //! Returns False if no such datum is assigned. |
214 | Standard_EXPORT Standard_Boolean GetDatum (const TDF_Label& theDatumL, |
215 | Handle(TCollection_HAsciiString)& theName, |
216 | Handle(TCollection_HAsciiString)& theDescription, |
217 | Handle(TCollection_HAsciiString)& theIdentification) const; |
218 | |
219 | //! Returns all Datum labels defined for theDimTolL label. |
220 | Standard_EXPORT Standard_Boolean GetDatumOfTolerLabels (const TDF_Label& theDimTolL, |
221 | TDF_LabelSequence& theDatums) const; |
222 | |
223 | //! Returns all Datum labels with XCAFDimTolObjects_DatumObject defined for label theDimTolL. |
224 | Standard_EXPORT Standard_Boolean GetDatumWithObjectOfTolerLabels (const TDF_Label& theDimTolL, |
225 | TDF_LabelSequence& theDatums) const; |
226 | |
227 | //! Returns all GeomToleranses labels defined for theDatumL label. |
228 | Standard_EXPORT Standard_Boolean GetTolerOfDatumLabels (const TDF_Label& theDatumL, |
229 | TDF_LabelSequence& theTols) const; |
230 | |
231 | //! Returns Datum label defined for theShapeL label. |
232 | Standard_EXPORT Standard_Boolean GetRefDatumLabel (const TDF_Label& theShapeL, |
233 | TDF_LabelSequence& theDatum) const; |
234 | |
235 | //! Returns true if the given GDT is marked as locked. |
0c63f2f8 |
236 | Standard_EXPORT Standard_Boolean IsLocked(const TDF_Label& theViewL) const; |
237 | |
a8a3b37c |
238 | //! Mark the given GDT as locked. |
0c63f2f8 |
239 | Standard_EXPORT void Lock(const TDF_Label& theViewL) const; |
240 | |
61ace3dc |
241 | //! fill the map GDT label -> shape presentation |
242 | Standard_EXPORT void GetGDTPresentations(NCollection_IndexedDataMap<TDF_Label, TopoDS_Shape, TDF_LabelMapHasher>& theGDTLabelToShape) const; |
243 | |
244 | //! Set shape presentation for GDT labels according to given map (theGDTLabelToPrs) |
245 | //! theGDTLabelToPrsName map is an additional argument, can be used to set presentation names. |
246 | //! If label is not in the theGDTLabelToPrsName map, the presentation name will be empty |
247 | Standard_EXPORT void SetGDTPresentations(NCollection_IndexedDataMap<TDF_Label, TopoDS_Shape, TDF_LabelMapHasher>& theGDTLabelToPrs); |
248 | |
a8a3b37c |
249 | //! Unlock the given GDT. |
0c63f2f8 |
250 | Standard_EXPORT void Unlock(const TDF_Label& theViewL) const; |
5df609e7 |
251 | |
79104795 |
252 | Standard_EXPORT const Standard_GUID& ID() const Standard_OVERRIDE; |
c99ad5d7 |
253 | |
bc73b006 |
254 | |
255 | //! Dumps the content of me into the stream |
256 | Standard_EXPORT virtual void DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth = -1) const Standard_OVERRIDE; |
42cf5bc1 |
257 | |
258 | |
c99ad5d7 |
259 | DEFINE_DERIVED_ATTRIBUTE(XCAFDoc_DimTolTool,TDataStd_GenericEmpty) |
42cf5bc1 |
260 | |
261 | |
262 | private: |
263 | |
264 | |
265 | Handle(XCAFDoc_ShapeTool) myShapeTool; |
266 | |
267 | |
268 | }; |
269 | |
270 | |
271 | |
272 | |
273 | |
274 | |
275 | |
276 | #endif // _XCAFDoc_DimTolTool_HeaderFile |