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