0025418: Debug output to be limited to OCC development environment
[occt.git] / src / STEPConstruct / STEPConstruct_UnitContext.cxx
1 // Created on: 1996-01-18
2 // Created by: Frederic MAUPAS
3 // Copyright (c) 1996-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 //abv 17.11.99: renamed from StepPDR_MakeUnitAndToleranceContext and merged with STEPControl_Unit
18 //abv 30.02.00: ability to write file in units other than MM
19
20 #include <STEPConstruct_UnitContext.ixx>
21
22 #include <TCollection_HAsciiString.hxx>
23
24 #include <StepBasic_SiUnit.hxx>
25 #include <StepBasic_SiPrefix.hxx>
26 #include <StepBasic_NamedUnit.hxx>
27 #include <StepBasic_LengthUnit.hxx>
28 #include <StepBasic_PlaneAngleUnit.hxx>
29 #include <StepBasic_SolidAngleUnit.hxx>
30 #include <StepBasic_SiUnitAndLengthUnit.hxx>
31 #include <StepBasic_SiUnitAndPlaneAngleUnit.hxx>
32 #include <StepBasic_SiUnitAndSolidAngleUnit.hxx>
33 #include <StepBasic_SiUnitAndAreaUnit.hxx>
34 #include <StepBasic_SiUnitAndVolumeUnit.hxx>
35 #include <StepBasic_UncertaintyMeasureWithUnit.hxx>
36 #include <StepBasic_DimensionalExponents.hxx>
37 #include <StepBasic_MeasureValueMember.hxx>
38 #include <StepBasic_MeasureWithUnit.hxx>
39 #include <StepBasic_LengthMeasureWithUnit.hxx>
40 #include <StepBasic_PlaneAngleMeasureWithUnit.hxx>
41 #include <StepBasic_SolidAngleMeasureWithUnit.hxx>
42 #include <StepBasic_ConversionBasedUnitAndLengthUnit.hxx>
43 #include <StepBasic_ConversionBasedUnitAndPlaneAngleUnit.hxx>
44 #include <StepBasic_ConversionBasedUnitAndSolidAngleUnit.hxx>
45 #include <StepBasic_ConversionBasedUnitAndAreaUnit.hxx>
46 #include <StepBasic_ConversionBasedUnitAndVolumeUnit.hxx>
47 #include <StepBasic_HArray1OfNamedUnit.hxx>
48 #include <StepBasic_HArray1OfUncertaintyMeasureWithUnit.hxx>
49 #include <UnitsMethods.hxx>
50 #include <Interface_Static.hxx>
51
52 //=======================================================================
53 //function : STEPConstruct_UnitContext
54 //purpose  : 
55 //=======================================================================
56
57 STEPConstruct_UnitContext::STEPConstruct_UnitContext() : done(Standard_False)
58 {
59   lengthDone = planeAngleDone = solidAngleDone = hasUncertainty = 
60     areaDone = volumeDone = Standard_False;
61   //pdn file r_47-sd.stp initalize field.
62   theUncertainty = RealLast();
63 }
64
65 //=======================================================================
66 //function : Init
67 //purpose  : 
68 //=======================================================================
69
70 void STEPConstruct_UnitContext::Init(const Standard_Real Tol3d) 
71 {
72   done = Standard_True;
73
74   GRC = new StepGeom_GeomRepContextAndGlobUnitAssCtxAndGlobUncertaintyAssCtx;
75   Handle(TCollection_HAsciiString) contextID =
76     new TCollection_HAsciiString("Context #1"); // ?????
77   
78   Handle(TCollection_HAsciiString) contextType =
79    new TCollection_HAsciiString("3D Context with UNIT and UNCERTAINTY");
80
81   // Units : LengthUnit and PlaneAngleUnit (no SolidAngleUnit appliable)
82
83   Handle(StepBasic_NamedUnit) lengthUnit;
84   Standard_CString uName = 0;
85   Standard_Boolean hasPref = Standard_True;
86   StepBasic_SiPrefix siPref = StepBasic_spMilli;
87   switch ( Interface_Static::IVal ( "write.step.unit" ) ) {
88   case  1 : uName = "INCH";             break;
89   default :
90   case  2 :                             break;
91   case  4 : uName = "FOOT";             break;
92   case  5 : uName = "MILE";             break;
93   case  6 : hasPref = Standard_False;   break;
94   case  7 : siPref = StepBasic_spKilo;  break;
95   case  8 : uName = "MIL";              break;
96   case  9 : siPref = StepBasic_spMicro; break;
97   case 10 : siPref = StepBasic_spCenti; break;
98   case 11 : uName = "MICROINCH";        break;
99   }
100   
101   Handle(StepBasic_SiUnitAndLengthUnit) siUnit =
102     new StepBasic_SiUnitAndLengthUnit;
103   siUnit->Init(hasPref,siPref,StepBasic_sunMetre);
104
105   if ( uName ) { // for non-metric units, create conversion_based_unit
106     Handle(StepBasic_MeasureValueMember) val = new StepBasic_MeasureValueMember;
107     val->SetName("LENGTH_UNIT");
108     val->SetReal ( UnitsMethods::GetLengthFactorValue ( Interface_Static::IVal ( "write.step.unit" ) ) );
109
110     Handle(StepBasic_LengthMeasureWithUnit) measure = new StepBasic_LengthMeasureWithUnit;
111     StepBasic_Unit Unit;
112     Unit.SetValue ( siUnit );
113     measure->Init ( val, Unit );
114
115     Handle(StepBasic_DimensionalExponents) theDimExp = new StepBasic_DimensionalExponents;
116     theDimExp->Init ( 1., 0., 0., 0., 0., 0., 0. );
117     
118     Handle(TCollection_HAsciiString) convName = new TCollection_HAsciiString ( uName );
119     Handle(StepBasic_ConversionBasedUnitAndLengthUnit) convUnit =
120       new StepBasic_ConversionBasedUnitAndLengthUnit;
121     convUnit->Init ( theDimExp, convName, measure );
122     
123     lengthUnit = convUnit;
124   }
125   else lengthUnit = siUnit;
126   
127   Handle(StepBasic_SiUnitAndPlaneAngleUnit) radianUnit =
128     new StepBasic_SiUnitAndPlaneAngleUnit;
129   radianUnit ->Init(Standard_False,
130                     StepBasic_spMilli,    // the unit is radian, no prefix
131                     StepBasic_sunRadian);
132
133   Handle(StepBasic_HArray1OfNamedUnit) units =
134     new StepBasic_HArray1OfNamedUnit(1, 3);
135
136   Handle(StepBasic_SiUnitAndSolidAngleUnit) sradUnit =
137     new StepBasic_SiUnitAndSolidAngleUnit;
138   sradUnit ->Init(Standard_False,
139                   StepBasic_spMilli,    // the unit is steradian, no prefix
140                   StepBasic_sunSteradian);
141
142   units->SetValue(1, lengthUnit);
143   units->SetValue(2, radianUnit);
144   units->SetValue(3, sradUnit);
145
146   // Uncertainty : 3D confusion Tolerance
147
148   Handle(StepBasic_HArray1OfUncertaintyMeasureWithUnit) Tols = 
149     new StepBasic_HArray1OfUncertaintyMeasureWithUnit(1,1);
150   Handle(StepBasic_UncertaintyMeasureWithUnit) theTol3d = 
151     new StepBasic_UncertaintyMeasureWithUnit;
152   
153   Handle(TCollection_HAsciiString) TolName = 
154     new TCollection_HAsciiString("distance_accuracy_value");
155   Handle(TCollection_HAsciiString) TolDesc =
156     new TCollection_HAsciiString("confusion accuracy");
157   
158   Handle(StepBasic_MeasureValueMember) mvs = new StepBasic_MeasureValueMember;
159   mvs->SetName("LENGTH_MEASURE");
160   mvs->SetReal ( Tol3d / UnitsMethods::LengthFactor() );
161   StepBasic_Unit Unit;
162   Unit.SetValue ( lengthUnit );
163   theTol3d->Init(mvs, Unit, TolName, TolDesc);
164   Tols->SetValue(1, theTol3d);
165
166   GRC->Init(contextID, contextType, 3, units, Tols);
167 }
168   
169 //=======================================================================
170 //function : IsDone
171 //purpose  : 
172 //=======================================================================
173
174 Standard_Boolean STEPConstruct_UnitContext::IsDone() const
175 {
176   return done;
177 }
178
179 //=======================================================================
180 //function : Value
181 //purpose  : 
182 //=======================================================================
183
184 Handle(StepGeom_GeomRepContextAndGlobUnitAssCtxAndGlobUncertaintyAssCtx) STEPConstruct_UnitContext::Value() const
185 {
186   return GRC;
187 }
188
189 // ==========================================================================
190 // Method  : ConvertSiPrefix
191 // Purpose : Computes SiPrefix conversion
192 // ==========================================================================
193
194 Standard_Real STEPConstruct_UnitContext::ConvertSiPrefix (const StepBasic_SiPrefix aPrefix)
195 {
196   switch(aPrefix)
197     {
198     case StepBasic_spExa:      return 1.E+18;
199     case StepBasic_spPeta:     return 1.E+15;
200     case StepBasic_spTera:     return 1.E+12;
201     case StepBasic_spGiga:     return 1.E+9;
202     case StepBasic_spMega:     return 1.E+6;
203     case StepBasic_spKilo:     return 1.E+3;
204     case StepBasic_spHecto:    return 1.E+2;
205     case StepBasic_spDeca:     return 1.E+1;
206     case StepBasic_spDeci:     return 1.E-1;
207     case StepBasic_spCenti:    return 1.E-2;
208     case StepBasic_spMilli:    return 1.E-3;
209     case StepBasic_spMicro:    return 1.E-6;
210     case StepBasic_spNano:     return 1.E-9;
211     case StepBasic_spPico:     return 1.E-12;
212     case StepBasic_spFemto:    return 1.E-15;
213     case StepBasic_spAtto:     return 1.E-18;
214     default:
215       break;
216     }
217   return 1.;
218 }
219
220
221 // ==========================================================================
222 // Method  : STEPConstruct_UnitContext::SiUnitNameFactor
223 // Purpose : 
224 // ==========================================================================
225
226 Standard_Boolean STEPConstruct_UnitContext::SiUnitNameFactor(const Handle(StepBasic_SiUnit)& aSiUnit,
227                                                     Standard_Real& theSIUNFactor) const
228 {
229   theSIUNFactor = 1.;
230   switch ( aSiUnit->Name() )
231   {
232   case StepBasic_sunMetre:
233   case StepBasic_sunRadian:
234   case StepBasic_sunSteradian: 
235     return Standard_True;
236   default:
237 //      cout << "Unknown SiUnitName : " << aSiUnit->Name() << endl;
238     return Standard_False;
239   }
240 }
241
242 // ==========================================================================
243 // Method  : STEPConstruct_UnitContext::ComputeFactors
244 // Purpose : 
245 // ==========================================================================
246
247 Standard_Integer STEPConstruct_UnitContext::ComputeFactors(const Handle(StepRepr_GlobalUnitAssignedContext)& aContext)
248 {
249   Standard_Integer status = 0;
250
251   // Initialise the default value
252   // status : 0 if OK, else 1 2 3
253   lengthFactor = solidAngleFactor = 1.;
254   planeAngleFactor = M_PI/180.;
255 //  Standard_Real theLExp   = 1.;
256 //  Standard_Real thePAExp  = 0.;
257 //  Standard_Real theSAExp  = 0.;
258   lengthDone = planeAngleDone = solidAngleDone = Standard_False;
259   
260   if (aContext.IsNull()) {
261 #ifdef OCCT_DEBUG
262     cout<<" -- STEPConstruct_UnitContext:ComputeFactor, Context undefined -> default"<<endl;
263 #endif
264     return 1;
265   }
266
267   // Start Computation
268   Handle(StepBasic_HArray1OfNamedUnit) theUnits = aContext->Units();
269   Standard_Integer nbU = aContext->NbUnits();
270   
271   for (Standard_Integer i = 1; i <= nbU; i++) {
272     Handle(StepBasic_NamedUnit) theNamedUnit = aContext->UnitsValue(i);
273     status = ComputeFactors(theNamedUnit);
274 #ifdef OCCT_DEBUG
275     if(status == -1)
276       cout << " -- STEPConstruct_UnitContext:ComputeFactor: Unit item no." << i << " is not recognized" << endl;
277 #endif    
278   }
279   return status;
280
281
282
283 Standard_Integer STEPConstruct_UnitContext::ComputeFactors(const Handle(StepBasic_NamedUnit)& aUnit)
284 {
285
286   //:f3 abv 8 Apr 98: ProSTEP TR8 tr8_as_sd_sw: the case of unrecognized entity
287   if ( aUnit.IsNull() ) 
288     return -1;
289
290   Standard_Integer status = 0;
291   Standard_Real theFactor= 0.; 
292   Standard_Real theSIUNF  = 0.;
293   
294   Standard_Real parameter= 0.;
295   Standard_Boolean parameterDone = Standard_False;
296   if(aUnit->IsKind(STANDARD_TYPE(StepBasic_ConversionBasedUnit))) {
297     Handle(StepBasic_ConversionBasedUnit) theCBU =
298       Handle(StepBasic_ConversionBasedUnit)::DownCast(aUnit);
299 //    Handle(StepBasic_DimensionalExponents) theDimExp = theCBU->Dimensions();
300     Handle(StepBasic_MeasureWithUnit) theMWU;
301     if(!theCBU.IsNull()) {
302        theMWU = theCBU->ConversionFactor();
303        // sln 8.10.2001: the case of unrecognized entity
304        if(theMWU.IsNull())
305          return -1;
306       //if (!theMWU->IsKind(STANDARD_TYPE(StepBasic_LengthMeasureWithUnit))) { gka
307       //        return 2;
308       //}
309       Handle(StepBasic_NamedUnit) theTargetUnit = theMWU->UnitComponent().NamedUnit();
310       //StepBasic_Unit theTargetUnit = theMWU->UnitComponent();
311       Standard_Real theSIPFactor = 1.;
312         
313       //:f5 abv 24 Apr 98: ProSTEP TR8 tr8_bv1_tc: INCHES
314 //gka   Handle(StepBasic_SiUnitAndLengthUnit) theSUALU =
315 //      Handle(StepBasic_SiUnitAndLengthUnit)::DownCast(theTargetUnit);
316 //      Handle(StepBasic_SiUnit) theSIU;
317 //      if ( ! theSUALU.IsNull() ) theSIU = Handle(StepBasic_SiUnit)::DownCast(theSUALU);
318     Handle(StepBasic_SiUnit) theSIU =  //f5
319       Handle(StepBasic_SiUnit)::DownCast(theTargetUnit);//f5
320       
321       if (!theSIU.IsNull()) {
322         if (theSIU->HasPrefix()) {
323           // Treat the prefix
324           StepBasic_SiPrefix aPrefix = theSIU->Prefix();
325           theSIPFactor = ConvertSiPrefix(aPrefix); 
326         }
327         // Treat the SiUnitName
328         if (!SiUnitNameFactor(theSIU,theSIUNF)) status = 11; // et continue
329         //cout << "The SiUnitNameFactor is :";
330         //cout << theSIUNF << endl;
331       }
332       else {
333         //      cout << "Recursive algo required - Aborted" << endl;
334         return 3;
335       }
336       Standard_Real theMVAL = theMWU->ValueComponent();
337       theFactor = theSIPFactor * theMVAL; // * theSIUNF * pow(10.,theLExp)
338     }
339     parameter = theFactor;
340     if(!parameterDone) {
341       parameterDone = Standard_True;
342     }
343     else {
344       status = 14;
345 #ifdef OCCT_DEBUG
346       cout << "Error in the file : parameter double defined" << endl;
347 #endif
348     }
349   }    
350   else if (aUnit->IsKind(STANDARD_TYPE(StepBasic_SiUnit))) {
351     Handle(StepBasic_SiUnit) theSIU = Handle(StepBasic_SiUnit)::DownCast(aUnit);
352     Standard_Real theSIPFactor = 1.;
353     if (theSIU->HasPrefix()) {
354       // Treat the prefix
355       StepBasic_SiPrefix aPrefix = theSIU->Prefix();
356       theSIPFactor = ConvertSiPrefix(aPrefix); 
357     }
358     
359     // Treat the SiUnitName
360     if (!SiUnitNameFactor(theSIU,theSIUNF)) status = 11;
361     
362     // final computation for lengthFactor
363     theFactor = theSIPFactor * theSIUNF;
364     parameter = theFactor;
365     if (!parameterDone) {
366       parameterDone = Standard_True;
367     }
368     else {
369       status = 14;
370 #ifdef OCCT_DEBUG
371       cout << "Error in the file : parameter double defined" << endl;
372 #endif
373     }
374   }
375   
376   // Defining a type of unit
377   if(!parameterDone) {
378 #ifdef OCCT_DEBUG
379     cout << "Unit Type not implemented" << endl;
380 #endif 
381     return 0;
382   }
383   
384   if (aUnit->IsKind(STANDARD_TYPE(StepBasic_ConversionBasedUnitAndLengthUnit))||
385       aUnit->IsKind(STANDARD_TYPE(StepBasic_SiUnitAndLengthUnit))) {
386 #ifdef METER
387     lengthFactor = parameter;
388 #else
389     lengthFactor = parameter * 1000. / UnitsMethods::GetCasCadeLengthUnit();
390 #endif    
391     if(!lengthDone) 
392       lengthDone = Standard_True;
393     else {
394       status = 14;
395 #ifdef OCCT_DEBUG
396       cout << "Error in the file : LengthFactor double defined" << endl;
397 #endif    
398     }
399   }  // end of LengthUnit
400   else if (aUnit->IsKind(STANDARD_TYPE(StepBasic_ConversionBasedUnitAndPlaneAngleUnit))||
401            aUnit->IsKind(STANDARD_TYPE(StepBasic_SiUnitAndPlaneAngleUnit))) {
402     planeAngleFactor = parameter;
403     planeAngleDone = Standard_True;     
404   }  // end of PlaneAngleUnit
405   else if (aUnit->IsKind(STANDARD_TYPE(StepBasic_ConversionBasedUnitAndSolidAngleUnit))||
406            aUnit->IsKind(STANDARD_TYPE(StepBasic_SiUnitAndSolidAngleUnit))) {
407     solidAngleFactor = parameter;
408     solidAngleDone = Standard_True;
409   }  // end of SolidAngleUnit 
410   else if (aUnit->IsKind(STANDARD_TYPE(StepBasic_ConversionBasedUnitAndAreaUnit)) ||
411            aUnit->IsKind(STANDARD_TYPE(StepBasic_SiUnitAndAreaUnit))) {
412     Standard_Real af;
413 #ifdef METER   
414     af = parameter;
415 #else
416     af = parameter * 1000. / UnitsMethods::GetCasCadeLengthUnit();
417 #endif    
418     areaDone = Standard_True;
419     areaFactor = pow(af,2);
420   }
421   else if (aUnit->IsKind(STANDARD_TYPE(StepBasic_ConversionBasedUnitAndVolumeUnit)) ||
422            aUnit->IsKind(STANDARD_TYPE(StepBasic_SiUnitAndVolumeUnit))) {
423     Standard_Real af;
424 #ifdef METER   
425     af = parameter;
426 #else
427     af = parameter * 1000. / UnitsMethods::GetCasCadeLengthUnit();
428 #endif
429     volumeDone = Standard_True;
430     volumeFactor = pow(af,3);
431   }   
432   return status;
433 }
434
435
436 // ==========================================================================
437 // Method  : STEPConstruct_UnitContext::ComputeTolerance
438 // Purpose : 
439 // ==========================================================================
440
441 Standard_Integer STEPConstruct_UnitContext::ComputeTolerance
442 (const Handle(StepRepr_GlobalUncertaintyAssignedContext)& aContext)
443 {
444   Standard_Integer status = 0;
445     // Decode the Uncertainty information (geometric accuracy)
446
447   hasUncertainty = Standard_False;
448   Standard_Integer nbUncertainty = 0;
449     
450   if (!aContext.IsNull()) nbUncertainty = aContext->NbUncertainty();
451   else return 40;
452
453   for (Standard_Integer un = 1 ; un <= nbUncertainty ; un ++) {
454     Handle(StepBasic_UncertaintyMeasureWithUnit) aUMWU = aContext->UncertaintyValue(un);
455     if (aUMWU.IsNull()) {
456 #ifdef OCCT_DEBUG
457       cout<<"BAD Uncertainty Measure with Units, n0."<<un<<endl;
458 #endif
459       continue;
460     }
461     // Decode the associated Unit
462     Handle(StepBasic_SiUnitAndLengthUnit) aUnit = 
463       Handle(StepBasic_SiUnitAndLengthUnit)::DownCast(aUMWU->UnitComponent().NamedUnit());
464     if (!aUnit.IsNull()) {
465       // Extract Uncertainty value
466       Standard_Real LengthUncertainty = aUMWU->ValueComponent();
467       // Update it according to the Length Unit Factor
468       //pdn r_47-sd.stp to choose minimal uncertainty
469       if(theUncertainty > LengthUncertainty) theUncertainty =  LengthUncertainty;
470       hasUncertainty = Standard_True;
471
472     } else {
473       Handle(StepBasic_ConversionBasedUnitAndLengthUnit) aCBULU =
474         Handle(StepBasic_ConversionBasedUnitAndLengthUnit)::DownCast(aUMWU->UnitComponent().NamedUnit());
475       if (!aCBULU.IsNull()) {
476         // Extract Uncertainty value
477         Standard_Real LengthUncertainty = aUMWU->ValueComponent();
478         // Update it according to the Length Unit Factor
479         //pdn r_47-sd.stp to choose minimal uncertainty
480         if(theUncertainty > LengthUncertainty) theUncertainty =  LengthUncertainty; // *lengthFactor; fait par appelant
481         hasUncertainty = Standard_True;
482       }
483     }
484   }
485
486 #ifdef OCCT_DEBUG
487   if (hasUncertainty) cout << "UNCERTAINTY read as " << theUncertainty << endl;
488 #endif
489   return status;
490 }
491
492 // ==========================================================================
493 // Method  : STEPConstruct_UnitContext::LengthFactor
494 // Purpose : 
495 // ==========================================================================
496 Standard_Real STEPConstruct_UnitContext::LengthFactor() const 
497 {  return lengthFactor;  }
498
499 // ==========================================================================
500 // Method  : STEPConstruct_UnitContext::PlaneAngleFactor
501 // Purpose : 
502 // ==========================================================================
503 Standard_Real STEPConstruct_UnitContext::PlaneAngleFactor() const 
504 {  return planeAngleFactor;  }
505
506 // ==========================================================================
507 // Method  : STEPConstruct_UnitContext::SolidAngleFactor
508 // Purpose : 
509 // ==========================================================================
510 Standard_Real STEPConstruct_UnitContext::SolidAngleFactor() const 
511 {  return solidAngleFactor;  }
512
513 // ==========================================================================
514 // Method  : STEPConstruct_UnitContext::Uncertainty
515 // Purpose : 
516 // ==========================================================================
517 Standard_Real STEPConstruct_UnitContext::Uncertainty () const 
518 {  return theUncertainty;  }
519
520 // ==========================================================================
521 // Method  : STEPConstruct_UnitContext::HasUncertainty
522 // Purpose : 
523 // ==========================================================================
524 Standard_Boolean STEPConstruct_UnitContext::HasUncertainty () const 
525 {  return hasUncertainty;  }
526
527 // ==========================================================================
528 // Method  : STEPConstruct_UnitContext::LengthDone
529 // Purpose : 
530 // ==========================================================================
531 Standard_Boolean STEPConstruct_UnitContext::LengthDone() const
532 {  return lengthDone;  }
533
534 // ==========================================================================
535 // Method  : STEPConstruct_UnitContext::PlaneAngleDone
536 // Purpose : 
537 // ==========================================================================
538 Standard_Boolean STEPConstruct_UnitContext::PlaneAngleDone() const
539 {  return planeAngleDone;  }
540
541 // ==========================================================================
542 // Method  : STEPConstruct_UnitContext::SolidAngleDone
543 // Purpose : 
544 // ==========================================================================
545 Standard_Boolean STEPConstruct_UnitContext::SolidAngleDone() const
546 {  return solidAngleDone;  }
547
548 // ==========================================================================
549 // Method  : STEPConstruct_UnitContext::StatusMessage
550 // Purpose : 
551 // ==========================================================================
552 Standard_CString  STEPConstruct_UnitContext::StatusMessage (const Standard_Integer status) const
553 {
554   switch (status) {
555   case  0 : return "";
556   case  1 : return "No GlobalUnitAssignedContext, default taken";
557   case  2 : return "No LengthMeasureWithUnit, default taken";
558   case  3 : return "No SiUnit for LengthMeasure undefined, default taken";
559   case  4 : return "No PlaneAngleMeasureWithUnit, default taken";
560   case  5 : return "No SiUnit for PlaneAngleMeasure undefined, default taken";
561   case  6 : return "No SolidAngleMeasureWithUnit, default taken";
562   case  7 : return "No SiUnit for SolidAngleMeasure undefined, default taken";
563
564   case 11 : return "Length Unit not recognized, default taken";
565   case 12 : return "Plane Angle Unit not recognized, default taken";
566   case 13 : return "Solid Angle Unit not recognized, default taken";
567   case 14 : return "At least one unit is twice defined";
568
569   case 40 : return "Bad GlobalUncertaintyAssignedContext, default unit taken";
570
571   default : break;
572   }
573
574   return "Badly defined units, default taken";
575 }
576
577 Standard_Real STEPConstruct_UnitContext::AreaFactor() const
578 {
579   return areaFactor;
580 }
581
582 Standard_Real STEPConstruct_UnitContext::VolumeFactor() const
583 {
584   return volumeFactor;
585 }
586
587 Standard_Boolean STEPConstruct_UnitContext::AreaDone() const
588 {
589   return areaDone;
590 }
591
592 Standard_Boolean STEPConstruct_UnitContext::VolumeDone() const
593 {
594   return volumeDone;
595 }