eb7d5e6eed90e629069109d249ade71fb9bd69b9
[occt.git] / src / STEPControl / STEPControl_Reader.cxx
1 // Copyright (c) 1999-2014 OPEN CASCADE SAS
2 //
3 // This file is part of Open CASCADE Technology software library.
4 //
5 // This library is free software; you can redistribute it and/or modify it under
6 // the terms of the GNU Lesser General Public License version 2.1 as published
7 // by the Free Software Foundation, with special exception defined in the file
8 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
9 // distribution for complete text of the license and disclaimer of any warranty.
10 //
11 // Alternatively, this file may be used under the terms of Open CASCADE
12 // commercial license or contractual agreement.
13
14
15 #include <Interface_EntityIterator.hxx>
16 #include <Interface_Graph.hxx>
17 #include <Interface_ShareFlags.hxx>
18 #include <Interface_Static.hxx>
19 #include <StepBasic_ApplicationContext.hxx>
20 #include <StepBasic_ConversionBasedUnit.hxx>
21 #include <StepBasic_DocumentProductEquivalence.hxx>
22 #include <StepBasic_HArray1OfNamedUnit.hxx>
23 #include <StepBasic_LengthMeasureWithUnit.hxx>
24 #include <StepBasic_MeasureWithUnit.hxx>
25 #include <StepBasic_NamedUnit.hxx>
26 #include <StepBasic_PlaneAngleMeasureWithUnit.hxx>
27 #include <StepBasic_ProductDefinition.hxx>
28 #include <StepBasic_ProductDefinitionContext.hxx>
29 #include <StepBasic_ProductDefinitionFormation.hxx>
30 #include <StepBasic_ProductDefinitionFormationRelationship.hxx>
31 #include <StepBasic_ProductDefinitionWithAssociatedDocuments.hxx>
32 #include <StepBasic_SiPrefix.hxx>
33 #include <StepBasic_SiUnit.hxx>
34 #include <StepBasic_SiUnitAndLengthUnit.hxx>
35 #include <StepBasic_SiUnitAndPlaneAngleUnit.hxx>
36 #include <StepBasic_SiUnitAndSolidAngleUnit.hxx>
37 #include <StepBasic_SiUnitName.hxx>
38 #include <StepBasic_SolidAngleMeasureWithUnit.hxx>
39 #include <StepBasic_SolidAngleUnit.hxx>
40 #include <STEPConstruct_UnitContext.hxx>
41 #include <STEPControl_ActorRead.hxx>
42 #include <STEPControl_Controller.hxx>
43 #include <STEPControl_Reader.hxx>
44 #include <StepData_StepModel.hxx>
45 #include <StepGeom_GeometricRepresentationContextAndGlobalUnitAssignedContext.hxx>
46 #include <StepGeom_GeomRepContextAndGlobUnitAssCtxAndGlobUncertaintyAssCtx.hxx>
47 #include <StepRepr_GlobalUncertaintyAssignedContext.hxx>
48 #include <StepRepr_GlobalUnitAssignedContext.hxx>
49 #include <StepRepr_MappedItem.hxx>
50 #include <StepRepr_NextAssemblyUsageOccurrence.hxx>
51 #include <StepRepr_ProductDefinitionShape.hxx>
52 #include <StepRepr_PropertyDefinition.hxx>
53 #include <StepRepr_RepresentationContext.hxx>
54 #include <StepRepr_RepresentationMap.hxx>
55 #include <StepRepr_RepresentationRelationship.hxx>
56 #include <StepRepr_ShapeAspect.hxx>
57 #include <StepShape_ShapeDefinitionRepresentation.hxx>
58 #include <StepShape_ShapeRepresentation.hxx>
59 #include <TCollection_AsciiString.hxx>
60 #include <TColStd_Array1OfAsciiString.hxx>
61 #include <TColStd_Array1OfReal.hxx>
62 #include <TColStd_HSequenceOfTransient.hxx>
63 #include <TColStd_MapOfAsciiString.hxx>
64 #include <TColStd_SequenceOfAsciiString.hxx>
65 #include <Transfer_TransientProcess.hxx>
66 #include <XSControl_Controller.hxx>
67 #include <XSControl_TransferReader.hxx>
68 #include <XSControl_WorkSession.hxx>
69
70 //=======================================================================
71 //function : STEPControl_Reader
72 //purpose  : 
73 //=======================================================================
74 STEPControl_Reader::STEPControl_Reader ()
75 {
76   STEPControl_Controller::Init();
77   SetNorm ("STEP");
78 }
79
80 //=======================================================================
81 //function : STEPControl_Reader
82 //purpose  : 
83 //=======================================================================
84
85 STEPControl_Reader::STEPControl_Reader
86   (const Handle(XSControl_WorkSession)& WS, const Standard_Boolean scratch)
87 {
88   STEPControl_Controller::Init();
89   SetWS (WS,scratch);
90   SetNorm ("STEP");
91 }
92
93 //=======================================================================
94 //function : StepModel
95 //purpose  : 
96 //=======================================================================
97
98 Handle(StepData_StepModel) STEPControl_Reader::StepModel () const
99 {
100   return Handle(StepData_StepModel)::DownCast(Model());
101 }
102
103 //=======================================================================
104 //function : TransferRoot
105 //purpose  : 
106 //=======================================================================
107
108 Standard_Boolean STEPControl_Reader::TransferRoot (const Standard_Integer num)
109 {
110   return TransferOneRoot (num);
111 }
112
113 //=======================================================================
114 //function : NbRootsForTransfer
115 //purpose  : 
116 //=======================================================================
117
118 Standard_Integer STEPControl_Reader::NbRootsForTransfer() 
119 {
120   if (therootsta) return theroots.Length();
121   therootsta = Standard_True;
122
123   //theroots.Clear();
124   Standard_Integer nb = Model()->NbEntities();
125   for (Standard_Integer i = 1; i <= nb; i ++) {
126     Handle(Standard_Transient) ent = Model()->Value(i);
127     if(ent->IsKind(STANDARD_TYPE(StepBasic_ProductDefinition))) {
128       // PTV 31.01.2003 TRJ11 exclude Product Definition With Associated Document from roots
129       if (ent->IsKind(STANDARD_TYPE(StepBasic_ProductDefinitionWithAssociatedDocuments))) {
130         // check if PDWAD-> PDF <-Document_Product_Equivalence.
131         Standard_Boolean iSexclude = Standard_False;
132         Handle(StepBasic_ProductDefinitionWithAssociatedDocuments) PDWAD =
133           Handle(StepBasic_ProductDefinitionWithAssociatedDocuments)::DownCast(ent);
134         Interface_EntityIterator PDWADsubs = WS()->Graph().Shareds(PDWAD);
135         for (PDWADsubs.Start(); PDWADsubs.More(); PDWADsubs.Next()) {
136           if ( !PDWADsubs.Value()->IsKind(STANDARD_TYPE(StepBasic_ProductDefinitionFormation)))
137             continue;
138           Handle(StepBasic_ProductDefinitionFormation) localPDF = 
139             Handle(StepBasic_ProductDefinitionFormation)::DownCast(PDWADsubs.Value());
140           Interface_EntityIterator PDFsubs = WS()->Graph().Sharings(localPDF);
141           for( PDFsubs.Start(); PDFsubs.More(); PDFsubs.Next() )
142             if (PDFsubs.Value()->IsKind(STANDARD_TYPE(StepBasic_DocumentProductEquivalence))) {
143               iSexclude = Standard_True;
144               break;
145             }
146           if (iSexclude)
147             break;
148         }
149         if (iSexclude) {
150 #ifdef OCCT_DEBUG
151           cout << "Warning: STEPControl_Reader::NbRootsForTransfer exclude PDWAD from roots" << endl;
152 #endif
153           continue;
154         }
155       }
156       Handle(StepBasic_ProductDefinition) PD = 
157         Handle(StepBasic_ProductDefinition)::DownCast(ent);
158       Standard_Boolean IsRoot = Standard_True;
159       const Interface_Graph& graph = WS()->Graph();
160       // determinate roots used NextAssemblyUsageOccurrence
161       Interface_EntityIterator subs = graph.Sharings(PD);
162       for(subs.Start(); subs.More(); subs.Next()) {
163         Handle(StepRepr_NextAssemblyUsageOccurrence) NAUO = 
164           Handle(StepRepr_NextAssemblyUsageOccurrence)::DownCast(subs.Value());
165         if (NAUO.IsNull()) continue;
166         if (PD==NAUO->RelatedProductDefinition()) IsRoot=Standard_False;
167       }
168       // determinate roots used ProductDefinitionContext
169       if(IsRoot) {
170         const char *str1 = Interface_Static::CVal("read.step.product.context");
171         Standard_Integer ICS = Interface_Static::IVal("read.step.product.context");
172         if(ICS>1) {
173           subs = graph.Shareds(PD);
174           for(subs.Start(); subs.More(); subs.Next()) {
175             Handle(StepBasic_ProductDefinitionContext) PDC = 
176               Handle(StepBasic_ProductDefinitionContext)::DownCast(subs.Value());
177             if (PDC.IsNull()) continue;
178             const char *str2 = PDC->LifeCycleStage()->String().ToCString();
179             const char *str3 = PDC->Name()->String().ToCString();
180             if( !( strcasecmp(str1,str2)==0 || strcasecmp(str1,str3)==0 ) )
181               IsRoot=Standard_False;
182           }
183         }
184       }
185       // determinate roots used ProductDefinitionFormationRelationship
186       //subs = graph.Shareds(PD);
187       //for(subs.Start(); subs.More(); subs.Next()) {
188       //  Handle(StepBasic_ProductDefinitionFormation) PDF = 
189       //    Handle(StepBasic_ProductDefinitionFormation)::DownCast(subs.Value());
190       //  if (PDF.IsNull()) continue;
191       //  Interface_EntityIterator subs1 = graph.Sharings(PDF);
192       //  for(subs1.Start(); subs1.More(); subs1.Next()) {
193       //    Handle(StepBasic_ProductDefinitionFormationRelationship) PDFR = 
194       //      Handle(StepBasic_ProductDefinitionFormationRelationship)::DownCast(subs1.Value());
195       //    if (PDFR.IsNull()) continue;
196       //    if (PDF==PDFR->RelatedProductDefinition()) IsRoot=Standard_False;
197       //  }
198       //}
199       if (IsRoot) {
200         theroots.Append(ent);
201         WS()->MapReader()->RootsForTransfer()->Append(ent);
202       }
203     }
204     TCollection_AsciiString aProdMode = Interface_Static::CVal("read.step.product.mode");
205     if(!aProdMode.IsEqual("ON")) {
206       if(ent->IsKind(STANDARD_TYPE(StepShape_ShapeDefinitionRepresentation))) {
207         Standard_Boolean IsRoot = Standard_True;
208         Handle(StepShape_ShapeDefinitionRepresentation) SDR =
209           Handle(StepShape_ShapeDefinitionRepresentation)::DownCast(ent);
210         Handle(StepRepr_PropertyDefinition) PropDef = SDR->Definition().PropertyDefinition();
211         if(!PropDef.IsNull()) {
212           Handle(StepBasic_ProductDefinition) PD = PropDef->Definition().ProductDefinition();
213           if(!PD.IsNull()) IsRoot = Standard_False;
214           if(IsRoot) {
215             Handle(StepRepr_ShapeAspect) SA = PropDef->Definition().ShapeAspect();
216             if(!SA.IsNull()) {
217               Handle(StepRepr_ProductDefinitionShape) PDS = SA->OfShape();
218               PD = PDS->Definition().ProductDefinition();
219               if(!PD.IsNull()) IsRoot = Standard_False;
220             }
221           }
222           if(IsRoot) {
223             Handle(StepRepr_NextAssemblyUsageOccurrence) NAUO =
224               Handle(StepRepr_NextAssemblyUsageOccurrence)::DownCast(PropDef->Definition().ProductDefinitionRelationship());
225             if(!NAUO.IsNull()) IsRoot = Standard_False;
226           }
227           if(IsRoot) {
228             Handle(StepShape_ShapeRepresentation) SR =
229               Handle(StepShape_ShapeRepresentation)::DownCast(SDR->UsedRepresentation());
230             if(SR.IsNull()) IsRoot = Standard_False;
231           }
232         }
233         if(IsRoot) {
234           theroots.Append(ent);
235           WS()->MapReader()->RootsForTransfer()->Append(ent);
236         }
237       }
238       if(ent->IsKind(STANDARD_TYPE(StepShape_ShapeRepresentation))) {
239         Standard_Boolean IsRoot = Standard_True;
240         Handle(StepShape_ShapeRepresentation) SR =
241           Handle(StepShape_ShapeRepresentation)::DownCast(ent);
242         const Interface_Graph& graph = WS()->Graph();
243         Interface_EntityIterator subs = graph.Sharings(SR);
244         for(subs.Start(); subs.More() && IsRoot; subs.Next()) {
245           Handle(StepShape_ShapeDefinitionRepresentation) SDR = 
246             Handle(StepShape_ShapeDefinitionRepresentation)::DownCast(subs.Value());
247           if(!SDR.IsNull()) IsRoot = Standard_False;
248           if(IsRoot) {
249             Handle(StepRepr_RepresentationRelationship) RR =
250               Handle(StepRepr_RepresentationRelationship)::DownCast(subs.Value());
251             if(!RR.IsNull()) {
252               Handle(StepShape_ShapeRepresentation) SR2 =
253                 Handle(StepShape_ShapeRepresentation)::DownCast(RR->Rep1());
254               if(SR==SR2)
255                 SR2 = Handle(StepShape_ShapeRepresentation)::DownCast(RR->Rep2());
256               Interface_EntityIterator subs2 = graph.Sharings(SR2);
257               for(subs2.Start(); subs2.More(); subs2.Next()) {
258                 Handle(StepShape_ShapeDefinitionRepresentation) SDR2 = 
259                   Handle(StepShape_ShapeDefinitionRepresentation)::DownCast(subs2.Value());
260                 if(!SDR2.IsNull()) IsRoot = Standard_False;
261                 //else {
262                 //  if(SR==SRR->Rep2()) IsRoot = Standard_False;
263                 //}
264               }
265             }
266           }
267           if(IsRoot) {
268             Handle(StepRepr_RepresentationMap) RM =
269               Handle(StepRepr_RepresentationMap)::DownCast(subs.Value());
270             if(!RM.IsNull()) {
271               Interface_EntityIterator subs2 = graph.Sharings(RM);
272               for(subs2.Start(); subs2.More(); subs2.Next()) {
273                 Handle(StepRepr_MappedItem) MI = Handle(StepRepr_MappedItem)::DownCast(subs2.Value());
274                 if(!MI.IsNull()) {
275                   Interface_EntityIterator subs3 = graph.Sharings(MI);
276                   for(subs3.Start(); subs3.More(); subs3.Next()) {
277                     Handle(StepShape_ShapeRepresentation) SR2 =
278                       Handle(StepShape_ShapeRepresentation)::DownCast(subs3.Value());
279                     if(!SR2.IsNull()) IsRoot = Standard_False;
280                   }
281                 }
282               }
283             }
284           }
285         }
286         if(IsRoot) {
287           theroots.Append(ent);
288           WS()->MapReader()->RootsForTransfer()->Append(ent);
289         }
290       }
291     }
292
293   }
294
295
296   return theroots.Length();
297 }
298
299 //=======================================================================
300 //function : FileUnits
301 //purpose  : 
302 //=======================================================================
303
304 void STEPControl_Reader::FileUnits( TColStd_SequenceOfAsciiString& theUnitLengthNames,
305                                    TColStd_SequenceOfAsciiString& theUnitAngleNames,
306                                    TColStd_SequenceOfAsciiString& theUnitSolidAngleNames) 
307 {
308   Standard_Integer nbroots = NbRootsForTransfer();
309   if(!nbroots)
310     return;
311   enum
312   {
313     LENGTH = 0,
314     ANLGE =  1,
315     SOLID_ANGLE = 2
316   };
317   const Interface_Graph& graph = WS()->Graph();
318   TColStd_MapOfAsciiString aMapUnits[3];
319
320   for(Standard_Integer i = 1; i <= nbroots; i++)
321   {
322     Handle(Standard_Transient) anEnt = theroots(i);
323     Standard_Integer num   = graph.EntityNumber(anEnt);
324     if(!num )
325       continue;
326     Handle(StepBasic_ProductDefinition) aProdDef = 
327       Handle(StepBasic_ProductDefinition)::DownCast(anEnt);
328     Handle(StepShape_ShapeDefinitionRepresentation) aShapeDefRepr;
329     if(!aProdDef.IsNull())
330     {
331       Interface_EntityIterator subsPD = graph.Sharings(aProdDef);
332       for(subsPD.Start(); subsPD.More() && aShapeDefRepr.IsNull(); subsPD.Next()) 
333       {
334         Handle(StepRepr_ProductDefinitionShape) aProdDefShape =
335           Handle(StepRepr_ProductDefinitionShape)::DownCast(subsPD.Value());
336         if(aProdDefShape.IsNull())
337           continue;
338         Interface_EntityIterator subsSR = graph.Sharings(aProdDefShape);
339         Handle(StepShape_ShapeRepresentation) SR;
340         for(subsSR.Start(); subsSR.More() && aShapeDefRepr.IsNull(); subsSR.Next())
341         {
342           Handle(StepShape_ShapeDefinitionRepresentation) aCurShapeDefRepr =
343             Handle(StepShape_ShapeDefinitionRepresentation)::DownCast(subsSR.Value());
344           if(aCurShapeDefRepr.IsNull()) 
345             continue;
346           Handle(StepRepr_Representation) aUseRepr = aCurShapeDefRepr->UsedRepresentation();
347           if(aUseRepr.IsNull())
348             continue;
349           Handle(StepShape_ShapeRepresentation) aShapeRepr = 
350             Handle(StepShape_ShapeRepresentation)::DownCast(aUseRepr);
351           if(aShapeRepr.IsNull()) 
352             continue;
353           aShapeDefRepr = aCurShapeDefRepr;
354
355         }
356
357
358       }
359
360     }
361     else
362       aShapeDefRepr = Handle(StepShape_ShapeDefinitionRepresentation)::DownCast(anEnt);
363     if(!aShapeDefRepr.IsNull())
364     {
365       Handle(StepShape_ShapeRepresentation) aShapeRepr =
366         Handle(StepShape_ShapeRepresentation)::DownCast(aShapeDefRepr->UsedRepresentation());
367       Handle(StepRepr_RepresentationContext) aRepCont = aShapeRepr->ContextOfItems();
368       if (aRepCont.IsNull())
369         continue;
370       TColStd_Array1OfAsciiString aNameUnits(1,3);
371       TColStd_Array1OfReal aFactorUnits(1,3);
372       if(findUnits(aRepCont,aNameUnits,aFactorUnits))
373       {
374         Standard_Integer k = LENGTH;
375         for ( ; k <= SOLID_ANGLE ; k++)
376         {
377           if(!aMapUnits[k].Contains(aNameUnits(k+1)))
378           {
379             aMapUnits[k].Add(aNameUnits(k+1));
380             TColStd_SequenceOfAsciiString& anUnitSeq = (k == LENGTH ? 
381                 theUnitLengthNames : ( k == ANLGE ? theUnitAngleNames : theUnitSolidAngleNames ));
382             anUnitSeq.Append(aNameUnits(k+1));
383           }
384         }
385       }
386
387     }
388
389   }
390   //for case when units was not found through PDF or SDR
391   if(theUnitLengthNames.IsEmpty())
392   {
393     Handle(Interface_InterfaceModel) aModel = WS()->Model();
394     if(aModel.IsNull())
395       return;
396     Standard_Integer nb = aModel->NbEntities();
397     for(Standard_Integer i = 1; i <= nb; i++)
398     {
399       Handle(Standard_Transient) anEnt = aModel->Value(i);
400       Handle(StepRepr_RepresentationContext) aRepCont = Handle(StepRepr_RepresentationContext)::DownCast(anEnt);
401       if (aRepCont.IsNull())
402         continue;
403       TColStd_Array1OfAsciiString aNameUnits(1,3);
404       TColStd_Array1OfReal aFactorUnits(1,3);
405       if(findUnits(aRepCont,aNameUnits,aFactorUnits))
406       {
407         Standard_Integer k = LENGTH;
408         for ( ; k <= SOLID_ANGLE ; k++)
409         {
410           if(!aMapUnits[k].Contains(aNameUnits(k+1)))
411           {
412             aMapUnits[k].Add(aNameUnits(k+1));
413             TColStd_SequenceOfAsciiString& anUnitSeq = (k == LENGTH ? 
414                theUnitLengthNames : ( k == ANLGE ? theUnitAngleNames : theUnitSolidAngleNames ));
415             anUnitSeq.Append(aNameUnits(k+1));
416           }
417         }
418       }
419     }
420   }
421 }
422
423 //=======================================================================
424 //function : getSiName
425 //purpose  : 
426 //=======================================================================
427
428 inline static TCollection_AsciiString getSiName(const Handle(StepBasic_SiUnit)& theUnit)
429 {
430  
431   TCollection_AsciiString aName;
432   if (theUnit->HasPrefix()) {
433     switch (theUnit->Prefix()) {
434       case StepBasic_spExa:   aName += "exa"; break;
435       case StepBasic_spPeta: aName += "peta"; break;
436       case StepBasic_spTera: aName += "tera"; break;
437       case StepBasic_spGiga: aName += "giga"; break;
438       case StepBasic_spMega:  aName += "mega"; break;
439       case StepBasic_spHecto: aName += "hecto"; break;
440       case StepBasic_spDeca:  aName += "deca"; break;
441       case StepBasic_spDeci:  aName += "deci"; break;
442       
443       case StepBasic_spPico:  aName += "pico"; break;
444       case StepBasic_spFemto: aName += "femto"; break;
445       case StepBasic_spAtto:  aName += "atto"; break;
446       
447       case StepBasic_spKilo : aName += "kilo"; break;
448       case StepBasic_spCenti :aName += "centi"; break;
449       case StepBasic_spMilli :aName += "milli"; break;
450       case StepBasic_spMicro :aName += "micro"; break;
451       case StepBasic_spNano :aName += "nano"; break;
452       default: break;
453     };
454   }
455   
456   switch(theUnit->Name()) {
457     case StepBasic_sunMetre : aName += "metre"; break;
458     case StepBasic_sunRadian : aName += "radian"; break;
459     case StepBasic_sunSteradian : aName += "steradian"; break; 
460     default: break;
461   };
462   return aName;
463 }
464
465 //=======================================================================
466 //function : findUnits
467 //purpose  : 
468 //=======================================================================
469
470 Standard_Boolean STEPControl_Reader::findUnits(
471        const Handle(StepRepr_RepresentationContext)& theRepCont,
472        TColStd_Array1OfAsciiString& theNameUnits,
473        TColStd_Array1OfReal& theFactorUnits)
474 {
475    Handle(StepRepr_GlobalUnitAssignedContext) aContext;
476   Handle(StepRepr_GlobalUncertaintyAssignedContext) aTol;
477
478   if (theRepCont->IsKind(STANDARD_TYPE(StepGeom_GeometricRepresentationContextAndGlobalUnitAssignedContext))) {
479     aContext = Handle(StepGeom_GeometricRepresentationContextAndGlobalUnitAssignedContext)::
480       DownCast(theRepCont)->GlobalUnitAssignedContext();
481   }
482
483  
484   if (theRepCont->IsKind(STANDARD_TYPE(StepGeom_GeomRepContextAndGlobUnitAssCtxAndGlobUncertaintyAssCtx))) {
485     aContext = Handle(StepGeom_GeomRepContextAndGlobUnitAssCtxAndGlobUncertaintyAssCtx)::
486       DownCast(theRepCont)->GlobalUnitAssignedContext();
487    
488   }
489   if(aContext.IsNull())
490     return Standard_False;
491   // Start Computation
492   Handle(StepBasic_HArray1OfNamedUnit) anUnits = aContext->Units();
493   Standard_Integer nbU = aContext->NbUnits();
494   Standard_Integer nbFind = 0;
495   for (Standard_Integer i = 1; i <= nbU; i++) {
496     Handle(StepBasic_NamedUnit) aNamedUnit = aContext->UnitsValue(i);
497     Handle(StepBasic_ConversionBasedUnit) aConvUnit =
498       Handle(StepBasic_ConversionBasedUnit)::DownCast(aNamedUnit);
499     Standard_Integer anInd = 0;
500     TCollection_AsciiString aName;
501     Standard_Real anUnitFact = 0;
502     if( !aConvUnit.IsNull() )
503     {
504       Handle(StepBasic_MeasureWithUnit) aMeasWithUnit = 
505         aConvUnit->ConversionFactor();
506       
507        if(aMeasWithUnit.IsNull())
508          continue;
509        
510        if( aMeasWithUnit->IsKind(STANDARD_TYPE(StepBasic_LengthMeasureWithUnit)) )
511          anInd = 1;
512        else if( aMeasWithUnit->IsKind(STANDARD_TYPE(StepBasic_PlaneAngleMeasureWithUnit)) )
513          anInd = 2;
514        else if( aMeasWithUnit->IsKind(STANDARD_TYPE(StepBasic_SolidAngleMeasureWithUnit)) )
515          anInd = 3;
516       if(!anInd)
517         continue;
518       aName = aConvUnit->Name()->String(); 
519       anUnitFact = aMeasWithUnit->ValueComponent();
520     }
521     else
522     {
523       Handle(StepBasic_SiUnit) aSiUnit = Handle(StepBasic_SiUnit)::DownCast(aNamedUnit);
524       if( aSiUnit.IsNull())
525         continue;
526       if(aSiUnit->IsKind(STANDARD_TYPE(StepBasic_SiUnitAndLengthUnit)))
527         anInd =1;
528       else if(aSiUnit->IsKind(STANDARD_TYPE(StepBasic_SiUnitAndPlaneAngleUnit)))
529         anInd = 2;
530       else if(aSiUnit->IsKind(STANDARD_TYPE(StepBasic_SiUnitAndSolidAngleUnit)))
531         anInd = 3;
532       if( !anInd )
533          continue;
534       anUnitFact = (!aSiUnit->HasPrefix()  ? 
535                     1. : STEPConstruct_UnitContext::ConvertSiPrefix(aSiUnit->Prefix()));
536       aName = getSiName(aSiUnit);
537       
538            
539     }
540     if( !anInd )
541       continue;
542  
543    theNameUnits.SetValue(anInd, aName);
544    theFactorUnits.SetValue(anInd, anUnitFact);
545     nbFind++;
546        
547    }
548     
549   return (nbFind);
550 }
551