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