0024428: Implementation of LGPL license
[occt.git] / src / MDataXtd / MDataXtd.cxx
CommitLineData
b311480e 1// Created by: DAUTRY Philippe
2// Copyright (c) 1997-1999 Matra Datavision
973c2be1 3// Copyright (c) 1999-2014 OPEN CASCADE SAS
b311480e 4//
973c2be1 5// This file is part of Open CASCADE Technology software library.
b311480e 6//
973c2be1 7// This library is free software; you can redistribute it and / or modify it
8// under the terms of the GNU Lesser General Public 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.
b311480e 12//
973c2be1 13// Alternatively, this file may be used under the terms of Open CASCADE
14// commercial license or contractual agreement.
b311480e 15
7fd59977 16// ------------
7fd59977 17// modified Sergey Zaritchny
18// Version: 0.0
b311480e 19//Version Date Purpose
7fd59977 20// 0.0 Aug 4 1997 Creation
21
22
23
24#include <MDataXtd.ixx>
25#include <MDF_ASDriverTable.hxx>
26#include <MDF_ARDriverTable.hxx>
27#include <CDM_MessageDriver.hxx>
7fd59977 28// Storage
7fd59977 29#include <MDataXtd_ShapeStorageDriver.hxx>
30#include <MDataXtd_PointStorageDriver.hxx>
31#include <MDataXtd_AxisStorageDriver.hxx>
32#include <MDataXtd_PlaneStorageDriver.hxx>
33#include <MDataXtd_GeometryStorageDriver.hxx>
34#include <MDataXtd_ConstraintStorageDriver.hxx>
35#include <MDataXtd_PlacementStorageDriver.hxx>
36#include <MDataXtd_PatternStdStorageDriver.hxx>
37
7fd59977 38// Retrieval
7fd59977 39#include <MDataXtd_ShapeRetrievalDriver.hxx>
40#include <MDataXtd_PointRetrievalDriver.hxx>
41#include <MDataXtd_AxisRetrievalDriver.hxx>
42#include <MDataXtd_PlaneRetrievalDriver.hxx>
43#include <MDataXtd_GeometryRetrievalDriver.hxx>
44#include <MDataXtd_ConstraintRetrievalDriver.hxx>
45#include <MDataXtd_PlacementRetrievalDriver.hxx>
46#include <MDataXtd_PatternStdRetrievalDriver.hxx>
47
7fd59977 48// enums
7fd59977 49#include <TDataStd_RealEnum.hxx>
50#include <TDataXtd_ConstraintEnum.hxx>
51#include <TDataXtd_GeometryEnum.hxx>
52#include <Standard_DomainError.hxx>
53#include <MgtGeom.hxx>
54#include <Geom_Curve.hxx>
55#include <Geom_Surface.hxx>
56#include <Geom_Point.hxx>
57#include <Geom_Axis1Placement.hxx>
58#include <Geom_Axis2Placement.hxx>
59#include <Geom_Direction.hxx>
60#include <Geom_VectorWithMagnitude.hxx>
61#include <PGeom_Curve.hxx>
62#include <PGeom_Surface.hxx>
63#include <PGeom_Point.hxx>
64#include <PGeom_Axis1Placement.hxx>
65#include <PGeom_Axis2Placement.hxx>
66#include <PGeom_Direction.hxx>
67#include <PGeom_VectorWithMagnitude.hxx>
68#include <Standard_NullObject.hxx>
69
70//=======================================================================
71//function : AddStorageDriver
72//purpose :
73//=======================================================================
74
75void MDataXtd::AddStorageDrivers
76(const Handle(MDF_ASDriverHSequence)& aDriverSeq, const Handle(CDM_MessageDriver)& theMsgDriver)
77{
78 aDriverSeq->Append(new MDataXtd_ShapeStorageDriver(theMsgDriver));
79 aDriverSeq->Append(new MDataXtd_PointStorageDriver(theMsgDriver));
80 aDriverSeq->Append(new MDataXtd_AxisStorageDriver(theMsgDriver));
81 aDriverSeq->Append(new MDataXtd_PlaneStorageDriver(theMsgDriver));
82 aDriverSeq->Append(new MDataXtd_GeometryStorageDriver(theMsgDriver));
83 aDriverSeq->Append(new MDataXtd_ConstraintStorageDriver(theMsgDriver));
84 aDriverSeq->Append(new MDataXtd_PlacementStorageDriver(theMsgDriver));
85 aDriverSeq->Append(new MDataXtd_PatternStdStorageDriver(theMsgDriver));
86}
87
88
89//=======================================================================
90//function : AddRetrievalDriver
91//purpose :
92//=======================================================================
93
94void MDataXtd::AddRetrievalDrivers
95(const Handle(MDF_ARDriverHSequence)& aDriverSeq,const Handle(CDM_MessageDriver)& theMsgDriver)
96{
97 aDriverSeq->Append(new MDataXtd_ShapeRetrievalDriver(theMsgDriver));
98 aDriverSeq->Append(new MDataXtd_PointRetrievalDriver(theMsgDriver));
99 aDriverSeq->Append(new MDataXtd_AxisRetrievalDriver(theMsgDriver));
100 aDriverSeq->Append(new MDataXtd_PlaneRetrievalDriver(theMsgDriver));
101 aDriverSeq->Append(new MDataXtd_GeometryRetrievalDriver(theMsgDriver));
102 aDriverSeq->Append(new MDataXtd_ConstraintRetrievalDriver(theMsgDriver));
103 aDriverSeq->Append(new MDataXtd_PlacementRetrievalDriver(theMsgDriver));
104 aDriverSeq->Append(new MDataXtd_PatternStdRetrievalDriver(theMsgDriver));
105}
106
107//=======================================================================
108//function : ConstraintTypeToInteger
109//purpose :
110//=======================================================================
111
112Standard_Integer MDataXtd::ConstraintTypeToInteger(const TDataXtd_ConstraintEnum e)
113{
114 switch (e) {
115 // planar constraints
116 case TDataXtd_RADIUS : return 0;
117 case TDataXtd_DIAMETER : return 1;
118 case TDataXtd_MINOR_RADIUS : return 2;
119 case TDataXtd_MAJOR_RADIUS : return 3;
120 case TDataXtd_TANGENT : return 4;
121 case TDataXtd_PARALLEL : return 5;
122 case TDataXtd_PERPENDICULAR : return 6;
123 case TDataXtd_CONCENTRIC : return 7;
124 case TDataXtd_COINCIDENT : return 8;
125 case TDataXtd_DISTANCE : return 9;
126 case TDataXtd_ANGLE : return 10;
127 case TDataXtd_EQUAL_RADIUS : return 11;
128 case TDataXtd_SYMMETRY : return 12;
129 case TDataXtd_MIDPOINT : return 13;
130 case TDataXtd_EQUAL_DISTANCE : return 14;
131 case TDataXtd_FIX : return 15;
132 case TDataXtd_RIGID : return 16;
133 // placement constraints
134 case TDataXtd_FROM : return 17;
135 case TDataXtd_AXIS : return 18;
136 case TDataXtd_MATE : return 19;
137 case TDataXtd_ALIGN_FACES : return 20;
138 case TDataXtd_ALIGN_AXES : return 21;
139 case TDataXtd_AXES_ANGLE : return 22;
140 case TDataXtd_FACES_ANGLE : return 23;
141 case TDataXtd_ROUND : return 24;
142 case TDataXtd_OFFSET : return 25;
143
144 default:
145 Standard_DomainError::Raise("TDataXtd_ConstraintEnum; enum term unknown");
146 }
147 return 0;
148}
149
150//=======================================================================
151//function : IntegerToConstraintType
152//purpose :
153//=======================================================================
154
155TDataXtd_ConstraintEnum MDataXtd::IntegerToConstraintType(const Standard_Integer i)
156{
157 switch(i)
158 {
159 // planar constraints
160 case 0 : return TDataXtd_RADIUS;
161 case 1 : return TDataXtd_DIAMETER;
162 case 2 : return TDataXtd_MINOR_RADIUS;
163 case 3 : return TDataXtd_MAJOR_RADIUS;
164 case 4 : return TDataXtd_TANGENT;
165 case 5 : return TDataXtd_PARALLEL;
166 case 6 : return TDataXtd_PERPENDICULAR;
167 case 7 : return TDataXtd_CONCENTRIC;
168 case 8 : return TDataXtd_COINCIDENT;
169 case 9 : return TDataXtd_DISTANCE;
170 case 10 : return TDataXtd_ANGLE;
171 case 11 : return TDataXtd_EQUAL_RADIUS;
172 case 12 : return TDataXtd_SYMMETRY;
173 case 13 : return TDataXtd_MIDPOINT;
174 case 14 : return TDataXtd_EQUAL_DISTANCE;
175 case 15 : return TDataXtd_FIX;
176 case 16 : return TDataXtd_RIGID;
177 // placement constraints
178 case 17 : return TDataXtd_FROM;
179 case 18 : return TDataXtd_AXIS;
180 case 19 : return TDataXtd_MATE;
181 case 20 : return TDataXtd_ALIGN_FACES;
182 case 21 : return TDataXtd_ALIGN_AXES;
183 case 22 : return TDataXtd_AXES_ANGLE;
184 case 23 : return TDataXtd_FACES_ANGLE;
185 case 24 : return TDataXtd_ROUND;
186 case 25 : return TDataXtd_OFFSET;
187 default :
188 Standard_DomainError::Raise("TDataXtd_ConstraintEnum; enum term unknown ");
189 }
190 return TDataXtd_TANGENT;
191}
192
193//=======================================================================
194//function : GeometryTypeToInteger
195//purpose :
196//=======================================================================
197
198Standard_Integer MDataXtd::GeometryTypeToInteger(const TDataXtd_GeometryEnum e)
199{
200 switch (e) {
201 case TDataXtd_ANY_GEOM : return 0;
202 case TDataXtd_POINT : return 1;
203 case TDataXtd_LINE : return 2;
204 case TDataXtd_CIRCLE : return 3;
205 case TDataXtd_ELLIPSE : return 4;
206
207 default:
208 Standard_DomainError::Raise("TDataXtd_GeometryEnum; enum term unknown");
209 }
210 return 0;
211}
212
213//=======================================================================
214//function : IntegerToGeometryType
215//purpose :
216//=======================================================================
217
218TDataXtd_GeometryEnum MDataXtd::IntegerToGeometryType(const Standard_Integer i)
219{
220 switch(i)
221 {
222 case 0 : return TDataXtd_ANY_GEOM;
223 case 1 : return TDataXtd_POINT;
224 case 2 : return TDataXtd_LINE;
225 case 3 : return TDataXtd_CIRCLE;
226 case 4 : return TDataXtd_ELLIPSE;
227
228 default :
229 Standard_DomainError::Raise("TDataXtd_GeometryEnum; enum term unknown ");
230 }
231 return TDataXtd_ANY_GEOM;
232}
233
234Handle(Geom_Geometry) MDataXtd::Translate (const Handle(PGeom_Geometry)& Geometry) {
235 Handle(Standard_Type) GeometryType = Geometry->DynamicType ();
236
237 if (GeometryType == STANDARD_TYPE(PGeom_Surface)) {
238 Handle(PGeom_Surface)& Surface = (Handle(PGeom_Surface)&) Geometry;
239 return MgtGeom::Translate (Surface);
240 }
241 else if (GeometryType == STANDARD_TYPE(PGeom_Curve)) {
242 Handle(PGeom_Curve)& Curve = (Handle(PGeom_Curve)&) Geometry;
243 return MgtGeom::Translate (Curve);
244 }
245 else if (GeometryType == STANDARD_TYPE(PGeom_Point)) {
246 Handle(PGeom_Point)& Point = (Handle(PGeom_Point)&) Geometry;
247 return MgtGeom::Translate (Point);
248 }
249 else if (GeometryType == STANDARD_TYPE(PGeom_Axis1Placement)) {
250 Handle(PGeom_Axis1Placement)& Axis1 = (Handle(PGeom_Axis1Placement)&) Geometry;
251 return MgtGeom::Translate (Axis1);
252 }
253 else if (GeometryType == STANDARD_TYPE(Geom_Axis2Placement)) {
254 Handle(PGeom_Axis2Placement)& Axis2 = (Handle(PGeom_Axis2Placement)&) Geometry;
255 return MgtGeom::Translate (Axis2);
256 }
257 else if (GeometryType == STANDARD_TYPE(PGeom_Direction)) {
258 Handle(PGeom_Direction)& Dir = (Handle(PGeom_Direction)&) Geometry;
259 return MgtGeom::Translate (Dir);
260 }
261 else if (GeometryType == STANDARD_TYPE(PGeom_VectorWithMagnitude)) {
262 Handle(PGeom_VectorWithMagnitude)& Vec = (Handle(PGeom_VectorWithMagnitude)&) Geometry;
263 return MgtGeom::Translate (Vec);
264 }
265 else {
266 Standard_NullObject::Raise("No mapping for the current Persistent Geometry");
267 }
268
269 Handle(Geom_Surface) dummy;
270 return dummy;
271}
272
273
274Handle(PGeom_Geometry) MDataXtd::Translate (const Handle(Geom_Geometry)& Geometry) {
275
276 Handle(Standard_Type) GeometryType = Geometry->DynamicType ();
277
278 if (GeometryType == STANDARD_TYPE(Geom_Surface)) {
279 Handle(Geom_Surface)& Surface = (Handle(Geom_Surface)&) Geometry;
280 return MgtGeom::Translate (Surface);
281 }
282 else if (GeometryType == STANDARD_TYPE(Geom_Curve)) {
283 Handle(Geom_Curve)& Curve = (Handle(Geom_Curve)&) Geometry;
284 return MgtGeom::Translate (Curve);
285 }
286 else if (GeometryType == STANDARD_TYPE(Geom_Point)) {
287 Handle(Geom_Point)& Point = (Handle(Geom_Point)&) Geometry;
288 return MgtGeom::Translate (Point);
289 }
290 else if (GeometryType == STANDARD_TYPE(Geom_Axis1Placement)) {
291 Handle(Geom_Axis1Placement)& Axis1 = (Handle(Geom_Axis1Placement)&) Geometry;
292 return MgtGeom::Translate (Axis1);
293 }
294 else if (GeometryType == STANDARD_TYPE(Geom_Axis2Placement)) {
295 Handle(Geom_Axis2Placement)& Axis2 = (Handle(Geom_Axis2Placement)&) Geometry;
296 return MgtGeom::Translate (Axis2);
297 }
298 else if (GeometryType == STANDARD_TYPE(Geom_Direction)) {
299 Handle(Geom_Direction)& Dir = (Handle(Geom_Direction)&) Geometry;
300 return MgtGeom::Translate (Dir);
301 }
302 else if (GeometryType == STANDARD_TYPE(Geom_VectorWithMagnitude)) {
303 Handle(Geom_VectorWithMagnitude)& Vec = (Handle(Geom_VectorWithMagnitude)&) Geometry;
304 return MgtGeom::Translate (Vec);
305 }
306 else {
307 Standard_NullObject::Raise("No mapping for the current Transient Geometry");
308 }
309
310 Handle(PGeom_Surface) dummy;
311 return dummy;
312}
313
314
315