0022627: Change OCCT memory management defaults
[occt.git] / src / STEPCAFControl / STEPCAFControl_Reader.cxx
CommitLineData
7fd59977 1// File: STEPCAFControl_Reader.cxx
2// Created: Tue Aug 15 12:42:41 2000
3// Author: Andrey BETENEV
4// <abv@doomox.nnov.matra-dtv.fr>
5
6#include <STEPCAFControl_Reader.ixx>
7
8#include <Quantity_Color.hxx>
9#include <TCollection_HAsciiString.hxx>
10#include <TopoDS_Shape.hxx>
11#include <TopoDS_Iterator.hxx>
12#include <TopTools_MapOfShape.hxx>
13#include <TopoDS_Compound.hxx>
14
15#include <Transfer_TransientProcess.hxx>
16#include <TransferBRep.hxx>
17#include <Transfer_Binder.hxx>
18#include <Interface_InterfaceModel.hxx>
19#include <XSControl_TransferReader.hxx>
20
21#include <StepBasic_Product.hxx>
22#include <StepBasic_ProductDefinition.hxx>
23#include <StepBasic_ProductDefinitionRelationship.hxx>
24#include <StepBasic_ProductDefinitionFormation.hxx>
25#include <StepShape_ContextDependentShapeRepresentation.hxx>
26#include <StepShape_ShapeDefinitionRepresentation.hxx>
27#include <StepShape_ShapeDefinitionRepresentation.hxx>
28#include <StepRepr_ProductDefinitionShape.hxx>
29#include <StepRepr_PropertyDefinition.hxx>
30#include <StepRepr_ShapeAspect.hxx>
31#include <StepRepr_MeasureRepresentationItem.hxx>
32#include <StepRepr_DescriptiveRepresentationItem.hxx>
33#include <StepVisual_StyledItem.hxx>
34#include <StepAP214_AppliedExternalIdentificationAssignment.hxx>
35
36#include <STEPConstruct.hxx>
37#include <STEPConstruct_Styles.hxx>
38#include <STEPConstruct_ExternRefs.hxx>
39#include <STEPConstruct_UnitContext.hxx>
40#include <STEPCAFControl_Controller.hxx>
41#include <STEPCAFControl_DataMapOfSDRExternFile.hxx>
42
43#include <TDataStd_Name.hxx>
44#include <TDF_Label.hxx>
45#include <XCAFDoc_ColorTool.hxx>
46#include <XCAFDoc_ShapeTool.hxx>
47#include <XCAFDoc_DocumentTool.hxx>
48#include <XCAFDoc_DimTolTool.hxx>
49#include <XCAFDoc_MaterialTool.hxx>
50#include <XCAFDoc_DataMapOfShapeLabel.hxx>
51#include <STEPConstruct_ValidationProps.hxx>
52#include <StepRepr_Representation.hxx>
53#include <XCAFDoc_Area.hxx>
54#include <XCAFDoc_Volume.hxx>
55#include <XCAFDoc_Centroid.hxx>
56#include <StepVisual_PresentationLayerAssignment.hxx>
57#include <TColStd_HSequenceOfTransient.hxx>
58#include <StepVisual_LayeredItem.hxx>
59#include <XCAFDoc_LayerTool.hxx>
60#include <Interface_EntityIterator.hxx>
61#include <StepRepr_ShapeRepresentationRelationship.hxx>
62#include <STEPConstruct_Assembly.hxx>
63#include <TDF_Tool.hxx>
64#include <StepVisual_Invisibility.hxx>
65#include <TDataStd_UAttribute.hxx>
66#include <XCAFDoc.hxx>
67#include <OSD_Path.hxx>
68#include <TColStd_SequenceOfHAsciiString.hxx>
69
70#include <TDataStd_TreeNode.hxx>
71#include <TNaming_NamedShape.hxx>
72#include <BRep_Builder.hxx>
73
74#include <STEPCAFControl_DataMapOfShapePD.hxx>
75#include <STEPCAFControl_DataMapOfPDExternFile.hxx>
76#include <StepVisual_PresentationStyleByContext.hxx>
77#include <StepVisual_StyleContextSelect.hxx>
78#include <StepRepr_RepresentedDefinition.hxx>
79#include <StepRepr_CharacterizedDefinition.hxx>
80#include <StepRepr_SpecifiedHigherUsageOccurrence.hxx>
81#include <XCAFDoc_GraphNode.hxx>
82#include <STEPCAFControl_Reader.hxx>
83
84// skl 21.08.2003 for reading G&DT
85#include <StepShape_DimensionalSize.hxx>
86#include <StepDimTol_GeometricTolerance.hxx>
87#include <StepShape_EdgeCurve.hxx>
88#include <StepShape_DimensionalCharacteristicRepresentation.hxx>
89#include <StepShape_ShapeDimensionRepresentation.hxx>
90#include <StepRepr_ValueRange.hxx>
91#include <StepRepr_ReprItemAndLengthMeasureWithUnit.hxx>
92#include <StepBasic_MeasureWithUnit.hxx>
93#include <StepDimTol_GeoTolAndGeoTolWthDatRefAndModGeoTolAndPosTol.hxx>
94#include <StepDimTol_ModifiedGeometricTolerance.hxx>
95#include <StepDimTol_GeometricToleranceWithDatumReference.hxx>
96//#include <StepRepr_CompoundItemDefinition.hxx>
97//#include <StepRepr_CompoundItemDefinitionMember.hxx>
98#include <TColStd_HArray1OfTransient.hxx>
99#include <StepRepr_HArray1OfRepresentationItem.hxx>
100#include <TColStd_IndexedDataMapOfTransientTransient.hxx>
101//#include <StepBasic_ConversionBasedUnit.hxx>
102#include <StepBasic_Unit.hxx>
103#include <StepBasic_NamedUnit.hxx>
104#include <StepBasic_SiUnit.hxx>
105#include <StepBasic_ConversionBasedUnitAndLengthUnit.hxx>
106#include <StepBasic_ConversionBasedUnitAndMassUnit.hxx>
107#include <StepBasic_DerivedUnit.hxx>
108#include <StepBasic_DerivedUnitElement.hxx>
109#include <StepBasic_MeasureValueMember.hxx>
110
111//#include <TDataStd_Real.hxx>
112//#include <TDataStd_Constraint.hxx>
113//#include <TDataStd_ConstraintEnum.hxx>
114//#include <TNaming_Tool.hxx>
115//#include <AIS_InteractiveObject.hxx>
116//#include <TPrsStd_ConstraintTools.hxx>
117//#include <AIS_DiameterDimension.hxx>
118//#include <TPrsStd_Position.hxx>
119//#include <TPrsStd_AISPresentation.hxx>
120//#include <TNaming_Builder.hxx>
121#include <TColStd_HArray1OfReal.hxx>
122#include <StepShape_AdvancedFace.hxx>
123#include <StepDimTol_HArray1OfDatumReference.hxx>
124#include <StepDimTol_DatumReference.hxx>
125#include <StepDimTol_Datum.hxx>
126#include <StepDimTol_DatumFeature.hxx>
127#include <StepRepr_ShapeAspectRelationship.hxx>
128
129#include <StepDimTol_AngularityTolerance.hxx>
130#include <StepDimTol_CircularRunoutTolerance.hxx>
131#include <StepDimTol_CoaxialityTolerance.hxx>
132#include <StepDimTol_ConcentricityTolerance.hxx>
133#include <StepDimTol_ParallelismTolerance.hxx>
134#include <StepDimTol_PerpendicularityTolerance.hxx>
135#include <StepDimTol_SymmetryTolerance.hxx>
136#include <StepDimTol_TotalRunoutTolerance.hxx>
137#include <StepDimTol_CylindricityTolerance.hxx>
138#include <StepDimTol_FlatnessTolerance.hxx>
139#include <StepDimTol_LineProfileTolerance.hxx>
140#include <StepDimTol_PositionTolerance.hxx>
141#include <StepDimTol_RoundnessTolerance.hxx>
142#include <StepDimTol_StraightnessTolerance.hxx>
143#include <StepDimTol_SurfaceProfileTolerance.hxx>
144
145#include <StepShape_SolidModel.hxx>
146#include <StepShape_ShellBasedSurfaceModel.hxx>
147#include <StepShape_GeometricSet.hxx>
1d2b1ccb 148#include <StepBasic_ProductDefinition.hxx>
7fd59977 149
150//#include <BRepTools.hxx>
151
152
153//=======================================================================
154//function : STEPCAFControl_Reader
155//purpose :
156//=======================================================================
157
158STEPCAFControl_Reader::STEPCAFControl_Reader ():
159 myColorMode( Standard_True ),
160 myNameMode ( Standard_True ),
161 myLayerMode( Standard_True ),
162 myPropsMode( Standard_True ),
163 myGDTMode ( Standard_True ),
164 myMatMode ( Standard_True )
165{
166 STEPCAFControl_Controller::Init();
167 myFiles = new STEPCAFControl_DictionaryOfExternFile;
168}
169
170
171//=======================================================================
172//function : STEPCAFControl_Reader
173//purpose :
174//=======================================================================
175
176STEPCAFControl_Reader::STEPCAFControl_Reader (const Handle(XSControl_WorkSession)& WS,
177 const Standard_Boolean scratch) :
178 myColorMode( Standard_True ),
179 myNameMode ( Standard_True ),
180 myLayerMode( Standard_True ),
181 myPropsMode( Standard_True ),
182 myGDTMode ( Standard_True ),
183 myMatMode ( Standard_True )
184{
185 STEPCAFControl_Controller::Init();
186 Init ( WS, scratch );
187}
188
189
190//=======================================================================
191//function : Init
192//purpose :
193//=======================================================================
194
195void STEPCAFControl_Reader::Init (const Handle(XSControl_WorkSession)& WS,
196 const Standard_Boolean scratch)
197{
198// necessary only in Writer, to set good actor: WS->SelectNorm ( "STEP" );
199 myReader.SetWS (WS,scratch);
200 myFiles = new STEPCAFControl_DictionaryOfExternFile;
201}
202
203
204//=======================================================================
205//function : ReadFile
206//purpose :
207//=======================================================================
208
209IFSelect_ReturnStatus STEPCAFControl_Reader::ReadFile (const Standard_CString filename)
210{
211 return myReader.ReadFile ( filename );
212}
213
214
215//=======================================================================
216//function : NbRootsForTransfer
217//purpose :
218//=======================================================================
219
220Standard_Integer STEPCAFControl_Reader::NbRootsForTransfer ()
221{
222 return myReader.NbRootsForTransfer();
223}
224
225
226//=======================================================================
227//function : TransferOneRoot
228//purpose :
229//=======================================================================
230
231Standard_Boolean STEPCAFControl_Reader::TransferOneRoot (const Standard_Integer num,
232 Handle(TDocStd_Document) &doc)
233{
234 TDF_LabelSequence Lseq;
235 return Transfer ( myReader, num, doc, Lseq );
236}
237
238
239//=======================================================================
240//function : Transfer
241//purpose :
242//=======================================================================
243
244Standard_Boolean STEPCAFControl_Reader::Transfer (Handle(TDocStd_Document) &doc)
245{
246 TDF_LabelSequence Lseq;
247 return Transfer ( myReader, 0, doc, Lseq );
248}
249
250
251//=======================================================================
252//function : Perform
253//purpose :
254//=======================================================================
255
256Standard_Boolean STEPCAFControl_Reader::Perform (const Standard_CString filename,
257 Handle(TDocStd_Document) &doc)
258{
259 if ( ReadFile ( filename ) != IFSelect_RetDone ) return Standard_False;
260 return Transfer ( doc );
261}
262
263
264//=======================================================================
265//function : Perform
266//purpose :
267//=======================================================================
268
269Standard_Boolean STEPCAFControl_Reader::Perform (const TCollection_AsciiString &filename,
270 Handle(TDocStd_Document) &doc)
271{
272 if ( ReadFile ( filename.ToCString() ) != IFSelect_RetDone ) return Standard_False;
273 return Transfer ( doc );
274}
275
276
277//=======================================================================
278//function : ExternFiles
279//purpose :
280//=======================================================================
281
282const Handle(STEPCAFControl_DictionaryOfExternFile) &STEPCAFControl_Reader::ExternFiles () const
283{
284 return myFiles;
285}
286
287
288//=======================================================================
289//function : ExternFile
290//purpose :
291//=======================================================================
292
293Standard_Boolean STEPCAFControl_Reader::ExternFile (const Standard_CString name,
294 Handle(STEPCAFControl_ExternFile) &ef) const
295{
296 ef.Nullify();
297 if ( myFiles.IsNull() || ! myFiles->HasItem ( name ) )
298 return Standard_False;
299 ef = myFiles->Item ( name );
300 return Standard_True;
301}
302
303
304//=======================================================================
305//function : Reader
306//purpose :
307//=======================================================================
308
309STEPControl_Reader &STEPCAFControl_Reader::ChangeReader ()
310{
311 return myReader;
312}
313
314
315//=======================================================================
316//function : Reader
317//purpose :
318//=======================================================================
319
320const STEPControl_Reader &STEPCAFControl_Reader::Reader () const
321{
322 return myReader;
323}
324
325
326//=======================================================================
327//function : FillShapesMap
328//purpose : auxiliary: fill a map by all compounds and their components
329//=======================================================================
330
331static void FillShapesMap (const TopoDS_Shape &S, TopTools_MapOfShape &map)
332{
333 TopoDS_Shape S0 = S;
334 TopLoc_Location loc;
335 S0.Location ( loc );
336 map.Add ( S0 );
337 if ( S.ShapeType() != TopAbs_COMPOUND ) return;
338 for ( TopoDS_Iterator it(S); it.More(); it.Next() )
339 FillShapesMap ( it.Value(), map );
340}
341
342
343//=======================================================================
344//function : Transfer
345//purpose : basic working method
346//=======================================================================
347
348Standard_Boolean STEPCAFControl_Reader::Transfer (STEPControl_Reader &reader,
349 const Standard_Integer nroot,
350 Handle(TDocStd_Document) &doc,
351 TDF_LabelSequence &Lseq,
352 const Standard_Boolean asOne)
353{
354 reader.ClearShapes();
355 Standard_Integer i;
356
357 // Read all shapes
358 Standard_Integer num = reader.NbRootsForTransfer();
359 if ( num <=0 ) return Standard_False;
360 if ( nroot ) {
361 if ( nroot > num ) return Standard_False;
362 reader.TransferOneRoot ( num );
363 }
364 else {
365 for ( i=1; i <= num; i++ ) reader.TransferOneRoot ( i );
366 }
367 num = reader.NbShapes();
368 if ( num <=0 ) return Standard_False;
369
370 // Fill a map of (top-level) shapes resulting from that transfer
371 // Only these shapes will be considered further
372 TopTools_MapOfShape ShapesMap, NewShapesMap;
373 for ( i=1; i <= num; i++ ) FillShapesMap ( reader.Shape(i), ShapesMap );
374
375 // Collect information on shapes originating from SDRs
376 // this will be used to distinguish compounds representing assemblies
377 // from the ones representing hybrid models and shape sets
378 STEPCAFControl_DataMapOfShapePD ShapePDMap;
379 STEPCAFControl_DataMapOfPDExternFile PDFileMap;
380 Handle(Interface_InterfaceModel) Model = reader.Model();
381 Handle(Transfer_TransientProcess) TP = reader.WS()->TransferReader()->TransientProcess();
382 Standard_Integer nb = Model->NbEntities();
383
384 Handle(TColStd_HSequenceOfTransient) SeqPDS = new TColStd_HSequenceOfTransient;
385
386 for (i = 1; i <= nb; i ++) {
387 Handle(Standard_Transient) enti = Model->Value(i);
388 if(enti->IsKind(STANDARD_TYPE(StepRepr_ProductDefinitionShape))) {
389 // sequence for acceleration ReadMaterials
390 SeqPDS->Append(enti);
391 }
392 if ( enti->IsKind ( STANDARD_TYPE(StepBasic_ProductDefinition ) ) ) {
393 Handle(StepBasic_ProductDefinition) PD =
394 Handle(StepBasic_ProductDefinition)::DownCast(enti);
395 Standard_Integer index = TP->MapIndex(PD);
396 if ( index >0 ) {
397 Handle(Transfer_Binder) binder = TP->MapItem (index);
398 TopoDS_Shape S = TransferBRep::ShapeResult(binder);
399 if ( ! S.IsNull() && ShapesMap.Contains(S) ) {
400 NewShapesMap.Add(S);
401 ShapePDMap.Bind ( S, PD );
402 Handle(STEPCAFControl_ExternFile) EF;
403 PDFileMap.Bind ( PD, EF );
404 }
405 }
406 }
407 if ( enti->IsKind ( STANDARD_TYPE(StepShape_ShapeRepresentation) ) ) {
408 Standard_Integer index = TP->MapIndex(enti);
409 if ( index >0 ) {
410 Handle(Transfer_Binder) binder = TP->MapItem (index);
411 TopoDS_Shape S = TransferBRep::ShapeResult(binder);
412 if ( ! S.IsNull() && ShapesMap.Contains(S) )
413 NewShapesMap.Add(S);
414 }
415 }
416 }
417
418 // get directory name of the main file
419 OSD_Path mainfile ( reader.WS()->LoadedFile() );
420 mainfile.SetName ( "" );
421 mainfile.SetExtension ( "" );
422 TCollection_AsciiString dpath;
423 mainfile.SystemName ( dpath );
424
425 // Load external references (only for relevant SDRs)
426 // and fill map SDR -> extern file
427 STEPConstruct_ExternRefs ExtRefs ( reader.WS() );
428 ExtRefs.LoadExternRefs();
429 for ( i=1; i <= ExtRefs.NbExternRefs(); i++ ) {
430 // check extern ref format
431 Handle(TCollection_HAsciiString) format = ExtRefs.Format(i);
432 if ( ! format.IsNull() ) {
433 static Handle(TCollection_HAsciiString) ap203 = new TCollection_HAsciiString ( "STEP AP203" );
434 static Handle(TCollection_HAsciiString) ap214 = new TCollection_HAsciiString ( "STEP AP214" );
435 if ( ! format->IsSameString ( ap203, Standard_False ) &&
436 ! format->IsSameString ( ap214, Standard_False ) ) {
437#ifdef DEB
438 cout << "Warning: STEPCAFControl_Reader::Transfer: Extern document is neither STEP AP203 nor AP214" << endl;
439#else
440 continue;
441#endif
442 }
443 }
444#ifdef DEB
445 else cout << "Warning: STEPCAFControl_Reader::Transfer: Extern document format not defined" << endl;
446#endif
447
448 // get and check filename of the current extern ref
449 const Standard_CString filename = ExtRefs.FileName(i);
450
451cout<<"filename="<<filename<<endl;
452
453 if ( ! filename || ! filename[0] ) {
454#ifdef DEB
455 cout << "Warning: STEPCAFControl_Reader::Transfer: Extern reference file name is empty" << endl;
456#endif
457 continue; // not a valid extern ref
458 }
459
460 // compute true path to the extern file
461 TCollection_AsciiString fullname = OSD_Path::AbsolutePath ( dpath, filename );
462 if ( fullname.Length() <= 0 ) fullname = filename;
463
464/*
465 char fullname[1024];
466 char *mainfile = reader.WS()->LoadedFile();
467 if ( ! mainfile ) mainfile = "";
468 Standard_Integer slash = 0;
469 for ( Standard_Integer k=0; mainfile[k]; k++ )
470 if ( mainfile[k] == '/' ) slash = k;
471 strncpy ( fullname, mainfile, slash );
472 sprintf ( &fullname[slash], "%s%s", ( mainfile[0] ? "/" : "" ), filename );
473*/
474
475 // get and check PD associated with the current extern ref
476 Handle(StepBasic_ProductDefinition) PD = ExtRefs.ProdDef(i);
477 if ( PD.IsNull() ) continue; // not a valid extern ref
478 if ( ! PDFileMap.IsBound ( PD ) ) continue; // this PD is not concerned by current transfer
479
480 // read extern file (or use existing data) and record its data
481 Handle(STEPCAFControl_ExternFile) EF =
482 ReadExternFile ( filename, fullname.ToCString(), doc );
483 PDFileMap.Bind ( PD, EF );
484 }
485
486 // and insert them to the document
487 Handle(XCAFDoc_ShapeTool) STool = XCAFDoc_DocumentTool::ShapeTool( doc->Main() );
488 if ( STool.IsNull() ) return Standard_False;
489 XCAFDoc_DataMapOfShapeLabel map;
490 if ( asOne )
491 Lseq.Append ( AddShape ( reader.OneShape(), STool, NewShapesMap, ShapePDMap, PDFileMap, map ) );
492 else {
493 for ( i=1; i <= num; i++ ) {
494 Lseq.Append ( AddShape ( reader.Shape(i), STool, NewShapesMap, ShapePDMap, PDFileMap, map ) );
495 }
496 }
497
498 // read colors
499 if ( GetColorMode() )
500 ReadColors ( reader.WS(), doc, PDFileMap, map );
501
502 // read names
503 if ( GetNameMode() )
504 ReadNames ( reader.WS(), doc, PDFileMap, map );
505
506 // read validation props
507 if ( GetPropsMode() )
508 ReadValProps ( reader.WS(), doc, PDFileMap, map );
509
510 // read layers
511 if ( GetLayerMode() )
512 ReadLayers ( reader.WS(), doc );
513
514 // read SHUO entities from STEP model
515 if ( GetSHUOMode() )
516 ReadSHUOs ( reader.WS(), doc, PDFileMap, map );
517
518 // read GDT entities from STEP model
519 if(GetGDTMode())
520 ReadGDTs(reader.WS(),doc);
521
522 // read Material entities from STEP model
523 if(GetMatMode())
524 ReadMaterials(reader.WS(),doc,SeqPDS);
525
526 // cout << "Ready !!" << endl;
527
528 return Standard_True;
529}
530
531//=======================================================================
532//function : AddShape
533//purpose :
534//=======================================================================
535
536TDF_Label STEPCAFControl_Reader::AddShape (const TopoDS_Shape &S,
537 const Handle(XCAFDoc_ShapeTool) &STool,
538 const TopTools_MapOfShape &NewShapesMap,
539 const STEPCAFControl_DataMapOfShapePD &ShapePDMap,
540 const STEPCAFControl_DataMapOfPDExternFile &PDFileMap,
541 XCAFDoc_DataMapOfShapeLabel &ShapeLabelMap) const
542{
543 // if shape has already been mapped, just return corresponding label
544 if ( ShapeLabelMap.IsBound ( S ) ) {
545 return ShapeLabelMap.Find ( S );
546 }
547
548 // if shape is located, create instance
549 if ( ! S.Location().IsIdentity() ) {
550 TopoDS_Shape S0 = S;
551 TopLoc_Location loc;
552 S0.Location ( loc );
553 AddShape ( S0, STool, NewShapesMap, ShapePDMap, PDFileMap, ShapeLabelMap );
554 TDF_Label L = STool->AddShape ( S, Standard_False ); // should create reference
555 ShapeLabelMap.Bind ( S, L );
556 return L;
557 }
558
559 // if shape is not compound, simple add it
560 if ( S.ShapeType() != TopAbs_COMPOUND ) {
561 TDF_Label L = STool->AddShape ( S, Standard_False );
562 ShapeLabelMap.Bind ( S, L );
563 return L;
564 }
565
566 // for compounds, compute number of subshapes and check whether this is assembly
567 Standard_Boolean isAssembly = Standard_False;
568 Standard_Integer nbComponents = 0;
569 TopoDS_Iterator it;
570 for ( it.Initialize(S); it.More(); it.Next(), nbComponents++ ) {
571 TopoDS_Shape Sub0 = it.Value();
572 TopLoc_Location loc;
573 Sub0.Location ( loc );
574 if ( NewShapesMap.Contains ( Sub0 ) ) isAssembly = Standard_True;
575 }
576
577// if(nbComponents>0) isAssembly = Standard_True;
578
579 // check whether it has associated external ref
580 TColStd_SequenceOfHAsciiString SHAS;
581 if ( ShapePDMap.IsBound ( S ) && PDFileMap.IsBound ( ShapePDMap.Find(S) ) ) {
582 Handle(STEPCAFControl_ExternFile) EF = PDFileMap.Find ( ShapePDMap.Find(S) );
583 if ( ! EF.IsNull() ) {
584 // (store information on extern refs in the document)
585 SHAS.Append(EF->GetName());
586 // if yes, just return corresponding label
587 if ( ! EF->GetLabel().IsNull() ) {
588 // but if components >0, ignore extern ref!
589 if ( nbComponents <=0 ) {
590 ShapeLabelMap.Bind ( S, EF->GetLabel() );
591 STool->SetExternRefs(EF->GetLabel(),SHAS);
592 return EF->GetLabel();
593 }
594 }
595#ifdef DEB
596 if ( ! EF->GetLabel().IsNull() )
597 cout << "Warning: STEPCAFControl_Reader::AddShape: Non-empty shape with external ref; ref is ignored" << endl;
598 else if ( nbComponents <=0 )
599 cout << "Warning: STEPCAFControl_Reader::AddShape: Result of reading extern ref is Null" << endl;
600#endif
601 }
602 }
603
604 // add compound either as a whole,
605 if ( ! isAssembly ) {
606 TDF_Label L = STool->AddShape ( S, Standard_False );
607 if ( SHAS.Length() >0 ) STool->SetExternRefs(L,SHAS);
608 ShapeLabelMap.Bind ( S, L );
609 return L;
610 }
611
612 // or as assembly, component-by-component
613 TDF_Label L = STool->NewShape();
614 for ( it.Initialize(S); it.More(); it.Next(), nbComponents++ ) {
615 TopoDS_Shape Sub0 = it.Value();
616 TopLoc_Location loc;
617 Sub0.Location ( loc );
618 TDF_Label subL = AddShape ( Sub0, STool, NewShapesMap, ShapePDMap, PDFileMap, ShapeLabelMap );
619 if ( ! subL.IsNull() ) {
620 STool->AddComponent ( L, subL, it.Value().Location() );
621 }
622 }
623 if ( SHAS.Length() >0 ) STool->SetExternRefs(L,SHAS);
624 ShapeLabelMap.Bind ( S, L );
625 //STool->SetShape ( L, S ); // it is necessary for assemblies OCC1747 // commemted by skl for OCC2941
626
627 return L;
628}
629
630//=======================================================================
631//function : ReadExternFile
632//purpose :
633//=======================================================================
634
635Handle(STEPCAFControl_ExternFile) STEPCAFControl_Reader::ReadExternFile (const Standard_CString file,
636 const Standard_CString fullname,
637 Handle(TDocStd_Document)& doc)
638{
639 // if the file is already read, associate it with SDR
640 if ( myFiles->HasItem ( file, Standard_True ) ) {
641 return myFiles->Item ( file );
642 }
643
644#ifdef DEB
645 cout << "Reading extern file: " << fullname << endl;
646#endif
647
648 // create new WorkSession and Reader
649 Handle(XSControl_WorkSession) newWS = new XSControl_WorkSession;
650 newWS->SelectNorm ( "STEP" );
651 STEPControl_Reader sr ( newWS, Standard_False );
652
653 // start to fill the resulting ExternFile structure
654 Handle(STEPCAFControl_ExternFile) EF = new STEPCAFControl_ExternFile;
655 EF->SetWS ( newWS );
656 EF->SetName ( new TCollection_HAsciiString ( file ) );
657
658 // read file
659 EF->SetLoadStatus ( sr.ReadFile ( fullname ) );
660
661 // transfer in single-result mode
662 if ( EF->GetLoadStatus() == IFSelect_RetDone ) {
663 TDF_LabelSequence labels;
664 EF->SetTransferStatus ( Transfer ( sr, 0, doc, labels, Standard_True ) );
665 if ( labels.Length() >0 ) EF->SetLabel ( labels.Value(1) );
666 }
667
668 // add read file to dictionary
669 myFiles->SetItem ( file, EF );
670
671 return EF;
672}
673
674
675//=======================================================================
676//function : SetColorToSubshape
677//purpose : auxilary
678//=======================================================================
679static void SetColorToSubshape(const Handle(XCAFDoc_ColorTool) & CTool,
680 const TopoDS_Shape & S,
681 const Quantity_Color& col,
682 const XCAFDoc_ColorType type)
683{
684 for (TopoDS_Iterator it(S); it.More(); it.Next())
685 if (! CTool->SetColor( it.Value(), col, type)) break;
686}
687
688
689//=======================================================================
690//function : findStyledSR
691//purpose : auxilary
692//=======================================================================
693static void findStyledSR (const Handle(StepVisual_StyledItem) &style,
694 Handle(StepShape_ShapeRepresentation)& aSR)
695{
696 // search Shape Represenatation for component styled item
697 for ( Standard_Integer j=1; j <= style->NbStyles(); j++ ) {
698 Handle(StepVisual_PresentationStyleByContext) PSA =
699 Handle(StepVisual_PresentationStyleByContext)::DownCast(style->StylesValue ( j ));
700 if ( PSA.IsNull() )
701 continue;
702 StepVisual_StyleContextSelect aStyleCntxSlct = PSA->StyleContext();
703 Handle(StepShape_ShapeRepresentation) aCurrentSR =
704 Handle(StepShape_ShapeRepresentation)::DownCast(aStyleCntxSlct.Representation());
705 if ( aCurrentSR.IsNull() )
706 continue;
707 aSR = aCurrentSR;
708 break;
709 }
710}
711
712
713//=======================================================================
714//function : ReadColors
715//purpose :
716//=======================================================================
717
718Standard_Boolean STEPCAFControl_Reader::ReadColors (const Handle(XSControl_WorkSession) &WS,
719 Handle(TDocStd_Document)& Doc,
720 const STEPCAFControl_DataMapOfPDExternFile &PDFileMap,
721 const XCAFDoc_DataMapOfShapeLabel &ShapeLabelMap) const
722{
723 STEPConstruct_Styles Styles ( WS );
724 if ( ! Styles.LoadStyles() ) {
725#ifdef DEB
726 cout << "Warning: no styles are found in the model" << endl;
727#endif
728 return Standard_False;
729 }
730 // searching for invisible items in the model
731 Handle(TColStd_HSequenceOfTransient) aHSeqOfInvisStyle = new TColStd_HSequenceOfTransient;
732 Styles.LoadInvisStyles( aHSeqOfInvisStyle );
733
734 Handle(XCAFDoc_ColorTool) CTool = XCAFDoc_DocumentTool::ColorTool( Doc->Main() );
735 if ( CTool.IsNull() ) return Standard_False;
736
737 // parse and search for color attributes
738 Standard_Integer nb = Styles.NbStyles();
739 for ( Standard_Integer i=1; i <= nb; i++ ) {
740 Handle(StepVisual_StyledItem) style = Styles.Style ( i );
741 if ( style.IsNull() ) continue;
742
743 Standard_Boolean IsVisible = Standard_True;
744 // check the visibility of styled item.
745 for (Standard_Integer si = 1; si <= aHSeqOfInvisStyle->Length(); si++ ) {
746 if ( style != aHSeqOfInvisStyle->Value( si ) )
747 continue;
748 // found that current style is invisible.
749#ifdef DEB
750 cout << "Warning: item No " << i << "(" << style->Item()->DynamicType()->Name() << ") is invisible" << endl;
751#endif
752 IsVisible = Standard_False;
753 break;
754 }
755
756 Handle(StepVisual_Colour) SurfCol, BoundCol, CurveCol;
757 // check if it is component style
758 Standard_Boolean IsComponent = Standard_False;
759 if ( ! Styles.GetColors ( style, SurfCol, BoundCol, CurveCol, IsComponent ) && IsVisible )
760 continue;
761
762 // find shape
763 TopoDS_Shape S = STEPConstruct::FindShape ( Styles.TransientProcess(), style->Item() );
764 Standard_Boolean isSkipSHUOstyle = Standard_False;
765 // take shape with real location.
766 while ( IsComponent ) {
767 // take SR of NAUO
768 Handle(StepShape_ShapeRepresentation) aSR;
769 findStyledSR( style, aSR );
770 // search for SR along model
771 if (aSR.IsNull())
772 break;
773// Handle(Interface_InterfaceModel) Model = WS->Model();
774 Handle(XSControl_TransferReader) TR = WS->TransferReader();
775 Handle(Transfer_TransientProcess) TP = TR->TransientProcess();
776 Interface_EntityIterator subs = WS->HGraph()->Graph().Sharings( aSR );
777 Handle(StepShape_ShapeDefinitionRepresentation) aSDR;
778 for (subs.Start(); subs.More(); subs.Next()) {
779 aSDR = Handle(StepShape_ShapeDefinitionRepresentation)::DownCast(subs.Value());
780 if ( aSDR.IsNull() )
781 continue;
782 StepRepr_RepresentedDefinition aPDSselect = aSDR->Definition();
783 Handle(StepRepr_ProductDefinitionShape) PDS =
784 Handle(StepRepr_ProductDefinitionShape)::DownCast(aPDSselect.PropertyDefinition());
785 if ( PDS.IsNull() )
786 continue;
787 StepRepr_CharacterizedDefinition aCharDef = PDS->Definition();
788
789 Handle(StepRepr_AssemblyComponentUsage) ACU =
790 Handle(StepRepr_AssemblyComponentUsage)::DownCast(aCharDef.ProductDefinitionRelationship());
791 // PTV 10.02.2003 skip styled item that refer to SHUO
792 if (ACU->IsKind(STANDARD_TYPE(StepRepr_SpecifiedHigherUsageOccurrence))) {
793 isSkipSHUOstyle = Standard_True;
794 break;
795 }
796 Handle(StepRepr_NextAssemblyUsageOccurrence) NAUO =
797 Handle(StepRepr_NextAssemblyUsageOccurrence)::DownCast(ACU);
798 if ( NAUO.IsNull() )
799 continue;
800
801 TopoDS_Shape aSh;
802 // PTV 10.02.2003 to find component of assembly CORRECTLY
803 STEPConstruct_Tool Tool( WS );
804 TDF_Label aShLab = FindInstance ( NAUO, CTool->ShapeTool(), Tool, PDFileMap, ShapeLabelMap );
805 aSh = CTool->ShapeTool()->GetShape(aShLab);
806// Handle(Transfer_Binder) binder = TP->Find(NAUO);
807// if ( binder.IsNull() || ! binder->HasResult() )
808// continue;
809// aSh = TransferBRep::ShapeResult ( TP, binder );
810 if (!aSh.IsNull()) {
811 S = aSh;
812 break;
813 }
814 }
815 break;
816 }
817 if (isSkipSHUOstyle)
818 continue; // skip styled item which refer to SHUO
819
820 if ( S.IsNull() ) {
821#ifdef DEB
822 cout << "Warning: item No " << i << "(" << style->Item()->DynamicType()->Name() << ") is not mapped to shape" << endl;
823#endif
824 continue;
825 }
826
827 if ( ! SurfCol.IsNull() ) {
828 Quantity_Color col;
829 Styles.DecodeColor ( SurfCol, col );
830 if ( ! CTool->SetColor ( S, col, XCAFDoc_ColorSurf ))
831 SetColorToSubshape( CTool, S, col, XCAFDoc_ColorSurf );
832 }
833 if ( ! BoundCol.IsNull() ) {
834 Quantity_Color col;
835 Styles.DecodeColor ( BoundCol, col );
836 if ( ! CTool->SetColor ( S, col, XCAFDoc_ColorCurv ))
837 SetColorToSubshape( CTool, S, col, XCAFDoc_ColorCurv );
838 }
839 if ( ! CurveCol.IsNull() ) {
840 Quantity_Color col;
841 Styles.DecodeColor ( CurveCol, col );
842 if ( ! CTool->SetColor ( S, col, XCAFDoc_ColorCurv ))
843 SetColorToSubshape( CTool, S, col, XCAFDoc_ColorCurv );
844 }
845 if ( !IsVisible ) {
846 // sets the invisibility for shape.
847 TDF_Label aInvL;
848 if ( CTool->ShapeTool()->Search( S, aInvL ) )
849 CTool->SetVisibility( aInvL, Standard_False );
850 }
851 }
852 CTool->ReverseChainsOfTreeNodes();
853 return Standard_True;
854}
855
856//=======================================================================
857//function : GetLabelFromPD
858//purpose :
859//=======================================================================
860
861static TDF_Label GetLabelFromPD (const Handle(StepBasic_ProductDefinition) &PD,
862 const Handle(XCAFDoc_ShapeTool) &STool,
863 const Handle(Transfer_TransientProcess) &TP,
864 const STEPCAFControl_DataMapOfPDExternFile &PDFileMap,
865 const XCAFDoc_DataMapOfShapeLabel &ShapeLabelMap)
866{
867 TDF_Label L;
868 if ( PDFileMap.IsBound ( PD ) ) {
869 Handle(STEPCAFControl_ExternFile) EF = PDFileMap.Find ( PD );
870 if ( ! EF.IsNull() ) {
871 L = EF->GetLabel();
872 if ( ! L.IsNull() ) return L;
873 }
874 }
875
876 TopoDS_Shape S;
877 Handle(Transfer_Binder) binder = TP->Find(PD);
878 if ( binder.IsNull() || ! binder->HasResult() ) return L;
879 S = TransferBRep::ShapeResult ( TP, binder );
880 if ( S.IsNull() ) return L;
881
882 if ( S.IsNull() ) return L;
883 if ( ShapeLabelMap.IsBound ( S ) )
884 L = ShapeLabelMap.Find ( S );
885 if ( L.IsNull() )
886 STool->Search ( S, L, Standard_True, Standard_True, Standard_False );
887 return L;
888}
889
890//=======================================================================
891//function : FindInstance
892//purpose :
893//=======================================================================
894
895TDF_Label STEPCAFControl_Reader::FindInstance (const Handle(StepRepr_NextAssemblyUsageOccurrence) &NAUO,
896 const Handle(XCAFDoc_ShapeTool) &STool,
897 const STEPConstruct_Tool &Tool,
898 const STEPCAFControl_DataMapOfPDExternFile &PDFileMap,
899 const XCAFDoc_DataMapOfShapeLabel &ShapeLabelMap)
900{
901 TDF_Label L;
902
903 // get shape resulting from CDSR (in fact, only location is interesting)
904 Handle(Transfer_TransientProcess) TP = Tool.TransientProcess();
905 Handle(Transfer_Binder) binder = TP->Find(NAUO);
906 if ( binder.IsNull() || ! binder->HasResult() ) {
907#ifdef DEB
908 cout << "Error: STEPCAFControl_Reader::FindInstance: NAUO is not mapped to shape" << endl;
909#endif
910 return L;
911 }
912
913 TopoDS_Shape S = TransferBRep::ShapeResult ( TP, binder );
914 if ( S.IsNull() ) {
915#ifdef DEB
916 cout << "Error: STEPCAFControl_Reader::FindInstance: NAUO is not mapped to shape" << endl;
917#endif
918 return L;
919 }
920
921 // find component`s original label
922 Handle(StepBasic_ProductDefinition) PD = NAUO->RelatedProductDefinition();
923 if ( PD.IsNull() ) return L;
924 TDF_Label Lref = GetLabelFromPD ( PD, STool, TP, PDFileMap, ShapeLabelMap );
925 if ( Lref.IsNull() ) return L;
926
927 // find main shape (assembly) label
928 PD.Nullify();
929 PD = NAUO->RelatingProductDefinition();
930 if ( PD.IsNull() ) return L;
931 TDF_Label L0 = GetLabelFromPD ( PD, STool, TP, PDFileMap, ShapeLabelMap );
932 if ( L0.IsNull() ) return L;
933
934 // if CDSR and NAUO are reversed, swap labels
935 Handle(StepShape_ContextDependentShapeRepresentation) CDSR;
936 Interface_EntityIterator subs1 = Tool.Graph().Sharings(NAUO);
937 for (subs1.Start(); subs1.More(); subs1.Next()) {
938 Handle(StepRepr_ProductDefinitionShape) PDS =
939 Handle(StepRepr_ProductDefinitionShape)::DownCast(subs1.Value());
940 if(PDS.IsNull()) continue;
941 Interface_EntityIterator subs2 = Tool.Graph().Sharings(PDS);
942 for (subs2.Start(); subs2.More(); subs2.Next()) {
943 Handle(StepShape_ContextDependentShapeRepresentation) CDSRtmp =
944 Handle(StepShape_ContextDependentShapeRepresentation)::DownCast(subs2.Value());
945 if (CDSRtmp.IsNull()) continue;
946 CDSR = CDSRtmp;
947 }
948 }
949 if (CDSR.IsNull()) return L;
950// if ( STEPConstruct_Assembly::CheckSRRReversesNAUO ( Tool.Model(), CDSR ) ) {
951// TDF_Label Lsw = L0; L0 = Lref; Lref = Lsw;
952// }
953
954 // iterate on components to find proper one
955 TDF_LabelSequence seq;
956 XCAFDoc_ShapeTool::GetComponents ( L0, seq );
957 for ( Standard_Integer k=1; L.IsNull() && k <= seq.Length(); k++ ) {
958 TDF_Label Lcomp = seq(k), Lref2;
959 if ( XCAFDoc_ShapeTool::GetReferredShape ( Lcomp, Lref2 ) &&
960 Lref2 == Lref &&
961 S.Location() == XCAFDoc_ShapeTool::GetLocation ( Lcomp ) )
962 L = Lcomp;
963 }
964
965 return L;
966}
967
968//=======================================================================
969//function : ReadNames
970//purpose :
971//=======================================================================
972
973Standard_Boolean STEPCAFControl_Reader::ReadNames (const Handle(XSControl_WorkSession) &WS,
974 Handle(TDocStd_Document)& Doc,
975 const STEPCAFControl_DataMapOfPDExternFile &PDFileMap,
976 const XCAFDoc_DataMapOfShapeLabel &ShapeLabelMap) const
977{
978 // get starting data
979 Handle(Interface_InterfaceModel) Model = WS->Model();
980 Handle(XSControl_TransferReader) TR = WS->TransferReader();
981 Handle(Transfer_TransientProcess) TP = TR->TransientProcess();
982 Handle(XCAFDoc_ShapeTool) STool = XCAFDoc_DocumentTool::ShapeTool( Doc->Main() );
983 if ( STool.IsNull() ) return Standard_False;
984 STEPConstruct_Tool Tool ( WS );
985
986 // iterate on model to find all SDRs and CDSRs
987 Standard_Integer nb = Model->NbEntities();
988 Handle(Standard_Type) tNAUO = STANDARD_TYPE(StepRepr_NextAssemblyUsageOccurrence);
989 Handle(Standard_Type) tPD = STANDARD_TYPE(StepBasic_ProductDefinition);
990 Handle(TCollection_HAsciiString) name;
991 TDF_Label L;
992 for (Standard_Integer i = 1; i <= nb; i++) {
993 Handle(Standard_Transient) enti = Model->Value(i);
994
995 // get description of NAUO
996 if ( enti->DynamicType() == tNAUO ) {
997 L.Nullify();
998 Handle(StepRepr_NextAssemblyUsageOccurrence) NAUO =
999 Handle(StepRepr_NextAssemblyUsageOccurrence)::DownCast(enti);
1000 if(NAUO.IsNull()) continue;
1001 Interface_EntityIterator subs = WS->Graph().Sharings(NAUO);
1002 for (subs.Start(); subs.More(); subs.Next()) {
1003 Handle(StepRepr_ProductDefinitionShape) PDS =
1004 Handle(StepRepr_ProductDefinitionShape)::DownCast(subs.Value());
1005 if(PDS.IsNull()) continue;
1006 Handle(StepBasic_ProductDefinitionRelationship) PDR = PDS->Definition().ProductDefinitionRelationship();
1007 if ( PDR.IsNull() ) continue;
1008 if ( PDR->HasDescription() &&
1009 PDR->Description()->Length() >0 ) name = PDR->Description();
1010 else if ( PDR->Name()->Length() >0 ) name = PDR->Name();
1011 else name = PDR->Id();
1012 }
1013 // find proper label
1014 L = FindInstance ( NAUO, STool, Tool, PDFileMap, ShapeLabelMap );
1015 if ( L.IsNull() ) continue;
1016 TCollection_ExtendedString str ( name->String() );
1017 TDataStd_Name::Set ( L, str );
1018 }
1019
1020 // for PD get name of associated product
1021 if ( enti->DynamicType() == tPD ) {
1022 L.Nullify();
1023 Handle(StepBasic_ProductDefinition) PD =
1024 Handle(StepBasic_ProductDefinition)::DownCast(enti);
1025 if(PD.IsNull()) continue;
1026 Handle(StepBasic_Product) Prod = PD->Formation()->OfProduct();
1027 if(Prod->Name()->UsefullLength()>0) name = Prod->Name();
1028 else name = Prod->Id();
1029 L = GetLabelFromPD ( PD, STool, TP, PDFileMap, ShapeLabelMap );
1030 if ( L.IsNull() ) continue;
1031 TCollection_ExtendedString str ( name->String() );
1032 TDataStd_Name::Set ( L, str );
1033 }
1034 // set a name to the document
1035 //TCollection_ExtendedString str ( name->String() );
1036 //TDataStd_Name::Set ( L, str );
1037 }
1038
1039 return Standard_True;
1040}
1041
1042//=======================================================================
1043//function : GetLabelFromPD
1044//purpose :
1045//=======================================================================
1046
1047static TDF_Label GetLabelFromPD (const Handle(StepBasic_ProductDefinition) &PD,
1048 const Handle(XCAFDoc_ShapeTool) &STool,
1049 const STEPConstruct_ValidationProps &Props,
1050 const STEPCAFControl_DataMapOfPDExternFile &PDFileMap,
1051 const XCAFDoc_DataMapOfShapeLabel &ShapeLabelMap)
1052{
1053 TDF_Label L;
1054 if ( PDFileMap.IsBound ( PD ) ) {
1055 Handle(STEPCAFControl_ExternFile) EF = PDFileMap.Find ( PD );
1056 if ( ! EF.IsNull() ) {
1057 L = EF->GetLabel();
1058 if ( ! L.IsNull() ) return L;
1059 }
1060 }
1061 TopoDS_Shape S = Props.GetPropShape ( PD );
1062 if ( S.IsNull() ) return L;
1063 if ( ShapeLabelMap.IsBound ( S ) )
1064 L = ShapeLabelMap.Find ( S );
1065 if ( L.IsNull() )
1066 STool->Search ( S, L, Standard_True, Standard_True, Standard_False );
1067 return L;
1068}
1069
1070//=======================================================================
1071//function : ReadValProps
1072//purpose :
1073//=======================================================================
1074
1075Standard_Boolean STEPCAFControl_Reader::ReadValProps (const Handle(XSControl_WorkSession) &WS,
1076 Handle(TDocStd_Document)& Doc,
1077 const STEPCAFControl_DataMapOfPDExternFile &PDFileMap,
1078 const XCAFDoc_DataMapOfShapeLabel &ShapeLabelMap) const
1079{
1080 // get starting data
1081 Handle(Interface_InterfaceModel) Model = WS->Model();
1082 Handle(XSControl_TransferReader) TR = WS->TransferReader();
1083 Handle(Transfer_TransientProcess) TP = TR->TransientProcess();
1084 Handle(XCAFDoc_ShapeTool) STool = XCAFDoc_DocumentTool::ShapeTool( Doc->Main() );
1085 if ( STool.IsNull() ) return Standard_False;
1086
1087 // load props from the STEP model
1088 TColStd_SequenceOfTransient props;
1089 STEPConstruct_ValidationProps Props ( WS );
1090 if ( ! Props.LoadProps ( props ) ) {
1091#ifdef DEB
1092 cout << "Warning: no validation props found in the model" << endl;
1093#endif
1094 return Standard_False;
1095 }
1096
1097 // interpret props one by one
1098 for (Standard_Integer i = 1; i <= props.Length(); i ++) {
1099 Handle(StepRepr_PropertyDefinitionRepresentation) PDR =
1100 Handle(StepRepr_PropertyDefinitionRepresentation)::DownCast ( props.Value(i) );
1101 if ( PDR.IsNull() ) continue;
1102
1103 TDF_Label L;
1104
1105 Handle(StepRepr_PropertyDefinition) PD = PDR->Definition().PropertyDefinition();
1106 Interface_EntityIterator subs = Props.Graph().Shareds(PD);
1107 for (subs.Start(); L.IsNull() && subs.More(); subs.Next()) {
1108 if ( subs.Value()->IsKind(STANDARD_TYPE(StepRepr_ProductDefinitionShape)) ) {
1109 Handle(StepRepr_ProductDefinitionShape) PDS = Handle(StepRepr_ProductDefinitionShape)::DownCast(subs.Value());
1110 if(PDS.IsNull()) continue;
1111 // find corresponding NAUO
1112 Handle(StepRepr_NextAssemblyUsageOccurrence) NAUO;
1113 Interface_EntityIterator subs1 = Props.Graph().Shareds(PDS);
1114 for (subs1.Start(); NAUO.IsNull() && subs1.More(); subs1.Next()) {
1115 if ( subs1.Value()->IsKind(STANDARD_TYPE(StepRepr_NextAssemblyUsageOccurrence)) )
1116 NAUO = Handle(StepRepr_NextAssemblyUsageOccurrence)::DownCast(subs1.Value());
1117 }
1118 if ( !NAUO.IsNull() ) {
1119 L = FindInstance ( NAUO, STool, WS, PDFileMap, ShapeLabelMap );
1120 if ( L.IsNull() ) continue;
1121 }
1122 else {
1123 // find corresponding ProductDefinition:
1124 Handle(StepBasic_ProductDefinition) ProdDef;
1125 Interface_EntityIterator subsPDS = Props.Graph().Shareds(PDS);
1126 for (subsPDS.Start(); ProdDef.IsNull() && subsPDS.More(); subsPDS.Next()) {
1127 if ( subsPDS.Value()->IsKind(STANDARD_TYPE(StepBasic_ProductDefinition)) )
1128 ProdDef = Handle(StepBasic_ProductDefinition)::DownCast(subsPDS.Value());
1129 }
1130 if ( ProdDef.IsNull() ) continue;
1131 L = GetLabelFromPD ( ProdDef, STool, Props, PDFileMap, ShapeLabelMap );
1132 }
1133 }
1134
1135 if ( subs.Value()->IsKind(STANDARD_TYPE(StepRepr_ShapeAspect)) ) {
1136 Handle(StepRepr_ShapeAspect) SA = Handle(StepRepr_ShapeAspect)::DownCast(subs.Value());
1137 if(SA.IsNull()) continue;
1138 // find ShapeRepresentation
1139 Handle(StepShape_ShapeRepresentation) SR;
1140 Interface_EntityIterator subs1 = Props.Graph().Sharings(SA);
1141 for(subs1.Start(); subs1.More() && SR.IsNull(); subs1.Next()) {
1142 Handle(StepRepr_PropertyDefinition) PropD1 =
1143 Handle(StepRepr_PropertyDefinition)::DownCast(subs1.Value());
1144 if(PropD1.IsNull()) continue;
1145 Interface_EntityIterator subs2 = Props.Graph().Sharings(PropD1);
1146 for(subs2.Start(); subs2.More() && SR.IsNull(); subs2.Next()) {
1147 Handle(StepShape_ShapeDefinitionRepresentation) SDR =
1148 Handle(StepShape_ShapeDefinitionRepresentation)::DownCast(subs2.Value());
1149 if(SDR.IsNull()) continue;
1150 SR = Handle(StepShape_ShapeRepresentation)::DownCast(SDR->UsedRepresentation());
1151 }
1152 }
1153 if(SR.IsNull()) continue;
1154 Handle(Transfer_Binder) binder;
1155 for(Standard_Integer ir=1; ir<=SR->NbItems() && binder.IsNull(); ir++) {
1156 if(SR->ItemsValue(ir)->IsKind(STANDARD_TYPE(StepShape_SolidModel))) {
1157 Handle(StepShape_SolidModel) SM =
1158 Handle(StepShape_SolidModel)::DownCast(SR->ItemsValue(ir));
1159 binder = TP->Find(SM);
1160 }
1161 else if(SR->ItemsValue(ir)->IsKind(STANDARD_TYPE(StepShape_ShellBasedSurfaceModel))) {
1162 Handle(StepShape_ShellBasedSurfaceModel) SBSM =
1163 Handle(StepShape_ShellBasedSurfaceModel)::DownCast(SR->ItemsValue(ir));
1164 binder = TP->Find(SBSM);
1165 }
1166 else if(SR->ItemsValue(ir)->IsKind(STANDARD_TYPE(StepShape_GeometricSet))) {
1167 Handle(StepShape_GeometricSet) GS =
1168 Handle(StepShape_GeometricSet)::DownCast(SR->ItemsValue(ir));
1169 binder = TP->Find(GS);
1170 }
1171 }
1172 if ( binder.IsNull() || ! binder->HasResult() ) continue;
1173 TopoDS_Shape S;
1174 S = TransferBRep::ShapeResult ( TP, binder );
1175 if(S.IsNull()) continue;
1176 if ( ShapeLabelMap.IsBound ( S ) )
1177 L = ShapeLabelMap.Find ( S );
1178 if ( L.IsNull() )
1179 STool->Search ( S, L, Standard_True, Standard_True, Standard_True );
1180 }
1181 }
1182
1183 if(L.IsNull()) continue;
1184
1185 // decode validation properties
1186 Handle(StepRepr_Representation) rep = PDR->UsedRepresentation();
1187 for ( Standard_Integer j=1; j <= rep->NbItems(); j++ ) {
1188 Handle(StepRepr_RepresentationItem) ent = rep->ItemsValue(j);
1189 Standard_Boolean isArea;
1190 Standard_Real val;
1191 gp_Pnt pos;
1192 if ( Props.GetPropReal ( ent, val, isArea ) ) {
1193 if ( isArea ) XCAFDoc_Area::Set ( L, val );
1194 else XCAFDoc_Volume::Set ( L, val );
1195 }
1196 else if ( Props.GetPropPnt ( ent, rep->ContextOfItems(), pos ) ) {
1197 XCAFDoc_Centroid::Set ( L, pos );
1198 }
1199 }
1200 }
1201 return Standard_True;
1202}
1203
1204//=======================================================================
1205//function : ReadLayers
1206//purpose :
1207//=======================================================================
1208
1209Standard_Boolean STEPCAFControl_Reader::ReadLayers (const Handle(XSControl_WorkSession) &WS,
1210 Handle(TDocStd_Document)& Doc) const
1211{
1212 Handle(Interface_InterfaceModel) Model = WS->Model();
1213 Handle(XSControl_TransferReader) TR = WS->TransferReader();
1214 Handle(Transfer_TransientProcess) TP = TR->TransientProcess();
1215 Handle(XCAFDoc_ShapeTool) STool = XCAFDoc_DocumentTool::ShapeTool( Doc->Main() );
1216 if ( STool.IsNull() ) return Standard_False;
1217 Handle(XCAFDoc_LayerTool) LTool = XCAFDoc_DocumentTool::LayerTool( Doc->Main() );
1218 if ( LTool.IsNull() ) return Standard_False;
1219
1220 Handle(Standard_Type) tSVPLA = STANDARD_TYPE(StepVisual_PresentationLayerAssignment);
1221 Standard_Integer nb = Model->NbEntities();
1222 Handle(TCollection_HAsciiString) name;
1223
1224 for (Standard_Integer i = 1; i <= nb; i ++) {
1225 Handle(Standard_Transient) enti = Model->Value(i);
1226 if ( ! enti->IsKind ( tSVPLA ) ) continue;
1227 Handle(StepVisual_PresentationLayerAssignment) SVPLA =
1228 Handle(StepVisual_PresentationLayerAssignment)::DownCast(enti);
1229
1230 Handle(TCollection_HAsciiString) descr = SVPLA->Description();
1231 Handle(TCollection_HAsciiString) hName = SVPLA->Name();
1232 TCollection_ExtendedString aLayerName ( hName->String() );
1233
1234 // find a target shape and its label in the document
1235 for (Standard_Integer j = 1; j <= SVPLA->NbAssignedItems(); j++ ) {
1236 StepVisual_LayeredItem LI = SVPLA->AssignedItemsValue(j);
1237 Handle(Transfer_Binder) binder = TP->Find( LI.Value() );
1238 if ( binder.IsNull() || ! binder->HasResult() ) continue;
1239
1240 TopoDS_Shape S = TransferBRep::ShapeResult ( TP, binder );
1241 if ( S.IsNull() ) continue;
1242
1243 TDF_Label shL;
1244 if ( ! STool->Search ( S, shL, Standard_True, Standard_True, Standard_True ) ) continue;
1245 LTool->SetLayer ( shL, aLayerName );
1246 }
1247
1248 // check invisibility
1249 Interface_EntityIterator subs = WS->Graph().Sharings(SVPLA);
1250 for (subs.Start(); subs.More(); subs.Next()) {
1251 if ( ! subs.Value()->IsKind(STANDARD_TYPE(StepVisual_Invisibility)) ) continue;
1252#ifdef DEB
1253 cout<< "\tLayer \"" << aLayerName << "\" is invisible"<<endl;
1254#endif
1255 //TDF_Label InvLayerLab = LTool->FindLayer(aLayerName);
1256 TDF_Label InvLayerLab = LTool->AddLayer(aLayerName); //skl for OCC3926
1257 Handle(TDataStd_UAttribute) aUAttr;
1258 aUAttr->Set( InvLayerLab, XCAFDoc::InvisibleGUID() );
1259 }
1260 }
1261 return Standard_True;
1262}
1263
1264//=======================================================================
1265//function : ReadSHUOs
1266//purpose :
1267//=======================================================================
1268
1269static Standard_Boolean findNextSHUOlevel (const Handle(XSControl_WorkSession) &WS,
1270 const Handle(StepRepr_SpecifiedHigherUsageOccurrence)& SHUO,
1271 const Handle(XCAFDoc_ShapeTool)& STool,
1272 const STEPCAFControl_DataMapOfPDExternFile &PDFileMap,
1273 const XCAFDoc_DataMapOfShapeLabel &ShapeLabelMap,
1274 TDF_LabelSequence& aLabels)
1275{
1276 Interface_EntityIterator subs = WS->HGraph()->Graph().Sharings(SHUO);
1277 Handle(StepRepr_SpecifiedHigherUsageOccurrence) subSHUO;
1278 for (subs.Start(); subs.More(); subs.Next()) {
1279 if (subs.Value()->IsKind(STANDARD_TYPE(StepRepr_SpecifiedHigherUsageOccurrence))) {
1280 subSHUO = Handle(StepRepr_SpecifiedHigherUsageOccurrence)::DownCast(subs.Value());
1281 break;
1282 }
1283 }
1284 if (subSHUO.IsNull())
1285 return Standard_False;
1286
1287 Handle(StepRepr_NextAssemblyUsageOccurrence) NUNAUO =
1288 Handle(StepRepr_NextAssemblyUsageOccurrence)::DownCast(subSHUO->NextUsage());
1289 if (NUNAUO.IsNull())
1290 return Standard_False;
1291// Handle(Interface_InterfaceModel) Model = WS->Model();
1292// Handle(XSControl_TransferReader) TR = WS->TransferReader();
1293// Handle(Transfer_TransientProcess) TP = TR->TransientProcess();
1294// Handle(Transfer_Binder) binder = TP->Find(NUNAUO);
1295// if ( binder.IsNull() || ! binder->HasResult() )
1296// return Standard_False;
1297// TopoDS_Shape NUSh = TransferBRep::ShapeResult ( TP, binder );
1298 // get label of NAUO next level
1299 TDF_Label NULab;
1300 STEPConstruct_Tool Tool( WS );
1301 NULab = STEPCAFControl_Reader::FindInstance ( NUNAUO, STool, Tool, PDFileMap, ShapeLabelMap );
1302// STool->Search(NUSh, NUlab);
1303 if (NULab.IsNull())
1304 return Standard_False;
1305 aLabels.Append( NULab );
1306 // and check by recurse.
1307 findNextSHUOlevel( WS, subSHUO, STool, PDFileMap, ShapeLabelMap, aLabels );
1308 return Standard_True;
1309}
1310
1311
1312//=======================================================================
1313//function : setSHUOintoDoc
1314//purpose : auxilary
1315//=======================================================================
1316static TDF_Label setSHUOintoDoc (const Handle(XSControl_WorkSession) &WS,
1317 const Handle(StepRepr_SpecifiedHigherUsageOccurrence)& SHUO,
1318 const Handle(XCAFDoc_ShapeTool)& STool,
1319 const STEPCAFControl_DataMapOfPDExternFile &PDFileMap,
1320 const XCAFDoc_DataMapOfShapeLabel &ShapeLabelMap)
1321{
1322 TDF_Label aMainLabel;
1323 // get upper usage NAUO from SHUO.
1324 Handle(StepRepr_NextAssemblyUsageOccurrence) UUNAUO =
1325 Handle(StepRepr_NextAssemblyUsageOccurrence)::DownCast(SHUO->UpperUsage());
1326 Handle(StepRepr_NextAssemblyUsageOccurrence) NUNAUO =
1327 Handle(StepRepr_NextAssemblyUsageOccurrence)::DownCast(SHUO->NextUsage());
1328 if ( UUNAUO.IsNull() || NUNAUO.IsNull() ) {
1329#ifdef DEB
1330 cout << "Warning: " << __FILE__ <<": Upper_usage or Next_usage of styled SHUO is null. Skip it" << endl;
1331#endif
1332 return aMainLabel;
1333 }
1334// Handle(Interface_InterfaceModel) Model = WS->Model();
1335// Handle(XSControl_TransferReader) TR = WS->TransferReader();
1336// Handle(Transfer_TransientProcess) TP = TR->TransientProcess();
1337// TopoDS_Shape UUSh, NUSh;
1338// Handle(Transfer_Binder) binder = TP->Find(UUNAUO);
1339// if ( binder.IsNull() || ! binder->HasResult() )
1340// return aMainLabel;
1341// UUSh = TransferBRep::ShapeResult ( TP, binder );
1342// binder = TP->Find(NUNAUO);
1343// if ( binder.IsNull() || ! binder->HasResult() )
1344// return aMainLabel;
1345// NUSh = TransferBRep::ShapeResult ( TP, binder );
1346
1347 // get first labels for first SHUO attribute
1348 TDF_Label UULab, NULab;
1349 STEPConstruct_Tool Tool( WS );
1350 UULab = STEPCAFControl_Reader::FindInstance ( UUNAUO, STool, Tool, PDFileMap, ShapeLabelMap );
1351 NULab = STEPCAFControl_Reader::FindInstance ( NUNAUO, STool, Tool, PDFileMap, ShapeLabelMap );
1352
1353// STool->Search(UUSh, UULab);
1354// STool->Search(NUSh, NULab);
1355 if (UULab.IsNull() || NULab.IsNull()) return aMainLabel;
1356 //create sequence fo labels to set SHUO structure into the document
1357 TDF_LabelSequence ShuoLabels;
1358 ShuoLabels.Append( UULab );
1359 ShuoLabels.Append( NULab );
1360 // add all other labels of sub SHUO entities
1361 findNextSHUOlevel( WS, SHUO, STool, PDFileMap, ShapeLabelMap, ShuoLabels );
1362 // last accord for SHUO
1363 Handle(XCAFDoc_GraphNode) anSHUOAttr;
1364 if ( STool->SetSHUO( ShuoLabels, anSHUOAttr ) )
1365 aMainLabel = anSHUOAttr->Label();
1366
1367 return aMainLabel;
1368}
1369
1370
1371//=======================================================================
1372//function : ReadSHUOs
1373//purpose :
1374//=======================================================================
1375
1376Standard_Boolean STEPCAFControl_Reader::ReadSHUOs (const Handle(XSControl_WorkSession) &WS,
1377 Handle(TDocStd_Document)& Doc,
1378 const STEPCAFControl_DataMapOfPDExternFile &PDFileMap,
1379 const XCAFDoc_DataMapOfShapeLabel &ShapeLabelMap) const
1380{
1381 // the big part code duplication from ReadColors.
1382 // It is possible to share this code functionality, just to decide how ???
1383 Handle(XCAFDoc_ColorTool) CTool = XCAFDoc_DocumentTool::ColorTool( Doc->Main() );
1384 Handle(XCAFDoc_ShapeTool) STool = CTool->ShapeTool();
1385
1386 STEPConstruct_Styles Styles ( WS );
1387 if ( ! Styles.LoadStyles() ) {
1388#ifdef DEB
1389 cout << "Warning: no styles are found in the model" << endl;
1390#endif
1391 return Standard_False;
1392 }
1393 // searching for invisible items in the model
1394 Handle(TColStd_HSequenceOfTransient) aHSeqOfInvisStyle = new TColStd_HSequenceOfTransient;
1395 Styles.LoadInvisStyles( aHSeqOfInvisStyle );
1396 // parse and search for color attributes
1397 Standard_Integer nb = Styles.NbStyles();
1398 for ( Standard_Integer i=1; i <= nb; i++ ) {
1399 Handle(StepVisual_StyledItem) style = Styles.Style ( i );
1400 if ( style.IsNull() ) continue;
1401
1402 Standard_Boolean IsVisible = Standard_True;
1403 // check the visibility of styled item.
1404 for (Standard_Integer si = 1; si <= aHSeqOfInvisStyle->Length(); si++ ) {
1405 if ( style != aHSeqOfInvisStyle->Value( si ) )
1406 continue;
1407 // found that current style is invisible.
1408#ifdef DEB
1409 cout << "Warning: item No " << i << "(" << style->Item()->DynamicType()->Name() << ") is invisible" << endl;
1410#endif
1411 IsVisible = Standard_False;
1412 break;
1413 }
1414
1415 Handle(StepVisual_Colour) SurfCol, BoundCol, CurveCol;
1416 // check if it is component style
1417 Standard_Boolean IsComponent = Standard_False;
1418 if ( ! Styles.GetColors ( style, SurfCol, BoundCol, CurveCol, IsComponent ) && IsVisible )
1419 continue;
1420 if (!IsComponent)
1421 continue;
1422 Handle(StepShape_ShapeRepresentation) aSR;
1423 findStyledSR( style, aSR );
1424 // search for SR along model
1425 if ( aSR.IsNull() )
1426 continue;
1427 Interface_EntityIterator subs = WS->HGraph()->Graph().Sharings( aSR );
1428 Handle(StepShape_ShapeDefinitionRepresentation) aSDR;
1429 for (subs.Start(); subs.More(); subs.Next()) {
1430 aSDR = Handle(StepShape_ShapeDefinitionRepresentation)::DownCast(subs.Value());
1431 if ( aSDR.IsNull() )
1432 continue;
1433 StepRepr_RepresentedDefinition aPDSselect = aSDR->Definition();
1434 Handle(StepRepr_ProductDefinitionShape) PDS =
1435 Handle(StepRepr_ProductDefinitionShape)::DownCast(aPDSselect.PropertyDefinition());
1436 if ( PDS.IsNull() )
1437 continue;
1438 StepRepr_CharacterizedDefinition aCharDef = PDS->Definition();
1439 Handle(StepRepr_SpecifiedHigherUsageOccurrence) SHUO =
1440 Handle(StepRepr_SpecifiedHigherUsageOccurrence)::DownCast(aCharDef.ProductDefinitionRelationship());
1441 if ( SHUO.IsNull() )
1442 continue;
1443
1444 // set the SHUO structure to the document
1445 TDF_Label aLabelForStyle = setSHUOintoDoc( WS, SHUO, STool, PDFileMap, ShapeLabelMap );
1446 if ( aLabelForStyle.IsNull() ) {
1447#ifdef DEB
1448 cout << "Warning: " << __FILE__ <<": coudnot create SHUO structure in the document" << endl;
1449#endif
1450 continue;
1451 }
1452 // now set the style to the SHUO main label.
1453 if ( ! SurfCol.IsNull() ) {
1454 Quantity_Color col;
1455 Styles.DecodeColor ( SurfCol, col );
1456 CTool->SetColor ( aLabelForStyle, col, XCAFDoc_ColorSurf );
1457 }
1458 if ( ! BoundCol.IsNull() ) {
1459 Quantity_Color col;
1460 Styles.DecodeColor ( BoundCol, col );
1461 CTool->SetColor ( aLabelForStyle, col, XCAFDoc_ColorCurv );
1462 }
1463 if ( ! CurveCol.IsNull() ) {
1464 Quantity_Color col;
1465 Styles.DecodeColor ( CurveCol, col );
1466 CTool->SetColor ( aLabelForStyle, col, XCAFDoc_ColorCurv );
1467 }
1468 if ( !IsVisible )
1469 // sets the invisibility for shape.
1470 CTool->SetVisibility( aLabelForStyle, Standard_False );
1471
1472 } // end search SHUO by SDR
1473 } // end iterates on styles
1474
1475 return Standard_True;
1476}
1477
1478
1479//=======================================================================
1480//function : GetLengthConversionFactor
1481//purpose :
1482//=======================================================================
1483static Standard_Boolean GetLengthConversionFactor(Handle(StepBasic_NamedUnit)& NU,
1484 Standard_Real& afact)
1485{
1486 afact=1.;
1487 if( !NU->IsKind(STANDARD_TYPE(StepBasic_ConversionBasedUnitAndLengthUnit)) ) return Standard_False;
1488 Handle(StepBasic_ConversionBasedUnitAndLengthUnit) CBULU =
1489 Handle(StepBasic_ConversionBasedUnitAndLengthUnit)::DownCast(NU);
1490 Handle(StepBasic_MeasureWithUnit) MWUCBU = CBULU->ConversionFactor();
1491 afact = MWUCBU->ValueComponent();
1492 StepBasic_Unit anUnit2 = MWUCBU->UnitComponent();
1493 if(anUnit2.CaseNum(anUnit2.Value())==1) {
1494 Handle(StepBasic_NamedUnit) NU2 = anUnit2.NamedUnit();
1495 if(NU2->IsKind(STANDARD_TYPE(StepBasic_SiUnit))) {
1496 Handle(StepBasic_SiUnit) SU = Handle(StepBasic_SiUnit)::DownCast(NU2);
1497 if(SU->Name()==StepBasic_sunMetre) {
1498 if(SU->HasPrefix())
1499 afact *= STEPConstruct_UnitContext::ConvertSiPrefix (SU->Prefix());
1500 // convert m to mm
1501 afact *= 1000.;
1502 }
1503 }
1504 }
1505 return Standard_True;
1506}
1507
1508
1509//=======================================================================
1510//function : GetMassConversionFactor
1511//purpose :
1512//=======================================================================
1513static Standard_Boolean GetMassConversionFactor(Handle(StepBasic_NamedUnit)& NU,
1514 Standard_Real& afact)
1515{
1516 afact=1.;
1517 if( !NU->IsKind(STANDARD_TYPE(StepBasic_ConversionBasedUnitAndMassUnit)) ) return Standard_False;
1518 Handle(StepBasic_ConversionBasedUnitAndMassUnit) CBUMU =
1519 Handle(StepBasic_ConversionBasedUnitAndMassUnit)::DownCast(NU);
1520 Handle(StepBasic_MeasureWithUnit) MWUCBU = CBUMU->ConversionFactor();
1521 afact = MWUCBU->ValueComponent();
1522 StepBasic_Unit anUnit2 = MWUCBU->UnitComponent();
1523 if(anUnit2.CaseNum(anUnit2.Value())==1) {
1524 Handle(StepBasic_NamedUnit) NU2 = anUnit2.NamedUnit();
1525 if(NU2->IsKind(STANDARD_TYPE(StepBasic_SiUnit))) {
1526 Handle(StepBasic_SiUnit) SU = Handle(StepBasic_SiUnit)::DownCast(NU2);
1527 if(SU->Name()==StepBasic_sunGram) {
1528 if(SU->HasPrefix())
1529 afact *= STEPConstruct_UnitContext::ConvertSiPrefix (SU->Prefix());
1530 }
1531 }
1532 }
1533 return Standard_True;
1534}
1535
1536
1537//=======================================================================
1538//function : ReadDatums
1539//purpose : auxilary
1540//=======================================================================
1541static Standard_Boolean ReadDatums(const Handle(XCAFDoc_ShapeTool) &STool,
1542 const Handle(XCAFDoc_DimTolTool) &DGTTool,
1543 const Interface_Graph &graph,
1544 Handle(Transfer_TransientProcess) &TP,
1545 const TDF_Label TolerL,
1546 const Handle(StepDimTol_GeometricToleranceWithDatumReference) GTWDR)
1547{
1548 if(GTWDR.IsNull()) return Standard_False;
1549 Handle(StepDimTol_HArray1OfDatumReference) HADR = GTWDR->DatumSystem();
1550 if(HADR.IsNull()) return Standard_False;
1551 for(Standard_Integer idr=1; idr<=HADR->Length(); idr++) {
1552 Handle(StepDimTol_DatumReference) DR = HADR->Value(idr);
1553 Handle(StepDimTol_Datum) aDatum = DR->ReferencedDatum();
1554 if(aDatum.IsNull()) continue;
1555 Interface_EntityIterator subs4 = graph.Sharings(aDatum);
1556 for(subs4.Start(); subs4.More(); subs4.Next()) {
1557 Handle(StepRepr_ShapeAspectRelationship) SAR =
1558 Handle(StepRepr_ShapeAspectRelationship)::DownCast(subs4.Value());
1559 if(SAR.IsNull()) continue;
1560 Handle(StepDimTol_DatumFeature) DF =
1561 Handle(StepDimTol_DatumFeature)::DownCast(SAR->RelatingShapeAspect());
1562 if(DF.IsNull()) continue;
1563 Interface_EntityIterator subs5 = graph.Sharings(DF);
1564 Handle(StepRepr_PropertyDefinition) PropDef;
1565 for(subs5.Start(); subs5.More() && PropDef.IsNull(); subs5.Next()) {
1566 PropDef = Handle(StepRepr_PropertyDefinition)::DownCast(subs5.Value());
1567 }
1568 if(PropDef.IsNull()) continue;
1569 Handle(StepShape_AdvancedFace) AF;
1570 subs5 = graph.Sharings(PropDef);
1571 for(subs5.Start(); subs5.More(); subs5.Next()) {
1572 Handle(StepShape_ShapeDefinitionRepresentation) SDR =
1573 Handle(StepShape_ShapeDefinitionRepresentation)::DownCast(subs5.Value());
1574 if(!SDR.IsNull()) {
1575 Handle(StepRepr_Representation) Repr = SDR->UsedRepresentation();
1576 if( !Repr.IsNull() && Repr->NbItems()>0 ) {
1577 Handle(StepRepr_RepresentationItem) RI = Repr->ItemsValue(1);
1578 AF = Handle(StepShape_AdvancedFace)::DownCast(RI);
1579 }
1580 }
1581 }
1582 if(AF.IsNull()) return Standard_False;
1583 Standard_Integer index = TP->MapIndex(AF);
1584 TopoDS_Shape aSh;
1585 if(index >0) {
1586 Handle(Transfer_Binder) binder = TP->MapItem(index);
1587 aSh = TransferBRep::ShapeResult(binder);
1588 }
1589 if(aSh.IsNull()) continue;
1590 TDF_Label shL;
1591 if( !STool->Search(aSh, shL, Standard_True, Standard_True, Standard_True) ) continue;
1592 DGTTool->SetDatum(shL,TolerL,PropDef->Name(),PropDef->Description(),aDatum->Identification());
1593 }
1594 }
1595 return Standard_True;
1596}
1597
1598
1599//=======================================================================
1600//function : ReadGDTs
1601//purpose :
1602//=======================================================================
1603
1604Standard_Boolean STEPCAFControl_Reader::ReadGDTs(const Handle(XSControl_WorkSession) &WS,
1605 Handle(TDocStd_Document)& Doc) const
1606{
1607 Handle(Interface_InterfaceModel) Model = WS->Model();
1608 Handle(XCAFDoc_ShapeTool) STool = XCAFDoc_DocumentTool::ShapeTool( Doc->Main() );
1609 Handle(XSControl_TransferReader) TR = WS->TransferReader();
1610 Handle(Transfer_TransientProcess) TP = TR->TransientProcess();
1611 Handle(XCAFDoc_DimTolTool) DGTTool = XCAFDoc_DocumentTool::DimTolTool( Doc->Main() );
1612 if ( DGTTool.IsNull() ) return Standard_False;
1613
1614 Standard_Integer nb = Model->NbEntities();
1615 const Interface_Graph& graph = TP->Graph();
1616 for(Standard_Integer i=1; i<=nb; i++) {
1617 Handle(Standard_Transient) ent = Model->Value(i);
1618 if(ent->IsKind(STANDARD_TYPE(StepRepr_ShapeAspect))) {
1619 Handle(StepRepr_ShapeAspect) SA = Handle(StepRepr_ShapeAspect)::DownCast(ent);
1620 // find RepresentationItem for current ShapeAspect
1621 Handle(StepRepr_RepresentationItem) RI;
1622 Handle(StepRepr_PropertyDefinition) PropD;
1623 Interface_EntityIterator subs3 = graph.Sharings(SA);
1624 for(subs3.Start(); subs3.More() && PropD.IsNull(); subs3.Next()) {
1625 PropD = Handle(StepRepr_PropertyDefinition)::DownCast(subs3.Value());
1626 }
1627 if(PropD.IsNull()) continue;
1628 Interface_EntityIterator subs4 = graph.Sharings(PropD);
1629 for(subs4.Start(); subs4.More(); subs4.Next()) {
1630 Handle(StepShape_ShapeDefinitionRepresentation) SDR =
1631 Handle(StepShape_ShapeDefinitionRepresentation)::DownCast(subs4.Value());
1632 if(!SDR.IsNull()) {
1633 Handle(StepRepr_Representation) Repr = SDR->UsedRepresentation();
1634 if( !Repr.IsNull() && Repr->NbItems()>0 ) {
1635 RI = Repr->ItemsValue(1);
1636 }
1637 }
1638 }
1639 if(RI.IsNull()) continue;
1640 // read DGT entities:
1641 subs3 = graph.Sharings(SA);
1642 for(subs3.Start(); subs3.More(); subs3.Next()) {
1643 if(subs3.Value()->IsKind(STANDARD_TYPE(StepShape_DimensionalSize))) {
1644 // read dimensions
1645 Handle(StepShape_EdgeCurve) EC = Handle(StepShape_EdgeCurve)::DownCast(RI);
1646 if(EC.IsNull()) continue;
1647 Handle(TCollection_HAsciiString) aName;
1648 Handle(StepShape_DimensionalSize) DimSize =
1649 Handle(StepShape_DimensionalSize)::DownCast(subs3.Value());
1650 Standard_Real dim1=-1.,dim2=-1.;
1651 subs4 = graph.Sharings(DimSize);
1652 for(subs4.Start(); subs4.More(); subs4.Next()) {
1653 Handle(StepShape_DimensionalCharacteristicRepresentation) DimCharR =
1654 Handle(StepShape_DimensionalCharacteristicRepresentation)::DownCast(subs4.Value());
1655 if(!DimCharR.IsNull()) {
1656 Handle(StepShape_ShapeDimensionRepresentation) SDimR = DimCharR->Representation();
1657 if(!SDimR.IsNull() && SDimR->NbItems()>0) {
1658 Handle(StepRepr_RepresentationItem) RI = SDimR->ItemsValue(1);
1659 Handle(StepRepr_ValueRange) VR = Handle(StepRepr_ValueRange)::DownCast(RI);
1660 if(!VR.IsNull()) {
1661 aName = VR->Name();
1662 //StepRepr_CompoundItemDefinition CID = VR->ItemElement();
1663 //if(CID.IsNull()) continue;
1664 //Handle(StepRepr_CompoundItemDefinitionMember) CIDM =
1665 // Handle(StepRepr_CompoundItemDefinitionMember)::DownCast(CID.Value());
1666 //if(CIDM.IsNull()) continue;
1667 //if(CIDM->ArrTransient().IsNull()) continue;
1668 //Handle(StepRepr_HArray1OfRepresentationItem) HARI;
1669 //if(CID.CaseMem(CIDM)==1)
1670 // HARI = CID.ListRepresentationItem();
1671 //if(CID.CaseMem(CIDM)==2)
1672 // HARI = CID.SetRepresentationItem();
1673 Handle(StepRepr_HArray1OfRepresentationItem) HARI = VR->ItemElement();
1674 if(HARI.IsNull()) continue;
1675 if(HARI->Length()>0) {
1676 Handle(StepRepr_RepresentationItem) RI1 =
1677 Handle(StepRepr_RepresentationItem)::DownCast(HARI->Value(1));
1678 if(RI1.IsNull()) continue;
1679 if(RI1->IsKind(STANDARD_TYPE(StepRepr_ReprItemAndLengthMeasureWithUnit))) {
1680 Handle(StepRepr_ReprItemAndLengthMeasureWithUnit) RILMWU =
1681 Handle(StepRepr_ReprItemAndLengthMeasureWithUnit)::DownCast(RI1);
1682 dim1 = RILMWU->GetMeasureWithUnit()->ValueComponent();
1683 StepBasic_Unit anUnit = RILMWU->GetMeasureWithUnit()->UnitComponent();
1684 Standard_Real afact=1.;
1685 if(anUnit.IsNull()) continue;
1686 if( !(anUnit.CaseNum(anUnit.Value())==1) ) continue;
1687 Handle(StepBasic_NamedUnit) NU = anUnit.NamedUnit();
1688 if(GetLengthConversionFactor(NU,afact)) dim1=dim1*afact;
1689 }
1690 }
1691 if(HARI->Length()>1) {
1692 Handle(StepRepr_RepresentationItem) RI2 =
1693 Handle(StepRepr_RepresentationItem)::DownCast(HARI->Value(2));
1694 if(RI2.IsNull()) continue;
1695 if(RI2->IsKind(STANDARD_TYPE(StepRepr_ReprItemAndLengthMeasureWithUnit))) {
1696 Handle(StepRepr_ReprItemAndLengthMeasureWithUnit) RILMWU =
1697 Handle(StepRepr_ReprItemAndLengthMeasureWithUnit)::DownCast(RI2);
1698 dim2 = RILMWU->GetMeasureWithUnit()->ValueComponent();
1699 StepBasic_Unit anUnit = RILMWU->GetMeasureWithUnit()->UnitComponent();
1700 Standard_Real afact=1.;
1701 if(anUnit.IsNull()) continue;
1702 if( !(anUnit.CaseNum(anUnit.Value())==1) ) continue;
1703 Handle(StepBasic_NamedUnit) NU = anUnit.NamedUnit();
1704 if(GetLengthConversionFactor(NU,afact)) dim2 = dim2*afact;
1705 }
1706 }
1707 }
1708 }
1709 }
1710 }
1711 if(dim1<0) continue;
1712 if(dim2<0) dim2=dim1;
1713 //cout<<"DimensionalSize: dim1="<<dim1<<" dim2="<<dim2<<endl;
1714 // now we know edge_curve and value range therefore
1715 // we can create corresponding D&GT labels
1716 Standard_Integer index = TP->MapIndex(EC);
1717 TopoDS_Shape aSh;
1718 if(index >0) {
1719 Handle(Transfer_Binder) binder = TP->MapItem(index);
1720 aSh = TransferBRep::ShapeResult(binder);
1721 }
1722 if(aSh.IsNull()) continue;
1723 TDF_Label shL;
1724 if( !STool->Search(aSh, shL, Standard_True, Standard_True, Standard_True) ) continue;
1725 Handle(TColStd_HArray1OfReal) arr = new TColStd_HArray1OfReal(1,2);
1726 arr->SetValue(1,dim1);
1727 arr->SetValue(2,dim2);
1728 DGTTool->SetDimTol(shL,1,arr,aName,DimSize->Name());
1729 }
1730 // read tolerances and datums
1731 else if(subs3.Value()->IsKind(STANDARD_TYPE(StepDimTol_GeometricTolerance))) {
1732 Handle(StepDimTol_GeometricTolerance) GT =
1733 Handle(StepDimTol_GeometricTolerance)::DownCast(subs3.Value());
1734 // read common data for tolerance
1735 //Standard_Real dim = GT->Magnitude()->ValueComponent();
1736 Handle (StepBasic_MeasureWithUnit) dim3 = GT->Magnitude();
1737 if(dim3.IsNull()) continue;
1738 Standard_Real dim = dim3->ValueComponent();
1739 StepBasic_Unit anUnit = GT->Magnitude()->UnitComponent();
1740 Standard_Real afact=1.;
1741 if(anUnit.IsNull()) continue;
1742 if( !(anUnit.CaseNum(anUnit.Value())==1) ) continue;
1743 Handle(StepBasic_NamedUnit) NU = anUnit.NamedUnit();
1744 if(GetLengthConversionFactor(NU,afact)) dim = dim*afact;
1745 //cout<<"GeometricTolerance: Magnitude = "<<dim<<endl;
1746 Handle(TColStd_HArray1OfReal) arr = new TColStd_HArray1OfReal(1,1);
1747 arr->SetValue(1,dim);
1748 Handle(TCollection_HAsciiString) aName = GT->Name();
1749 Handle(TCollection_HAsciiString) aDescription = GT->Description();
1750 Handle(StepShape_AdvancedFace) AF = Handle(StepShape_AdvancedFace)::DownCast(RI);
1751 if(AF.IsNull()) continue;
1752 Standard_Integer index = TP->MapIndex(AF);
1753 TopoDS_Shape aSh;
1754 if(index >0) {
1755 Handle(Transfer_Binder) binder = TP->MapItem(index);
1756 aSh = TransferBRep::ShapeResult(binder);
1757 }
1758 if(aSh.IsNull()) continue;
1759 TDF_Label shL;
1760 if( !STool->Search(aSh, shL, Standard_True, Standard_True, Standard_True) ) continue;
1761 // read specific data for tolerance
1762 if(GT->IsKind(STANDARD_TYPE(StepDimTol_GeoTolAndGeoTolWthDatRefAndModGeoTolAndPosTol))) {
1763 Handle(StepDimTol_GeoTolAndGeoTolWthDatRefAndModGeoTolAndPosTol) GTComplex =
1764 Handle(StepDimTol_GeoTolAndGeoTolWthDatRefAndModGeoTolAndPosTol)::DownCast(subs3.Value());
1765 Standard_Integer kind=20;
1766 Handle(StepDimTol_ModifiedGeometricTolerance) MGT =
1767 GTComplex->GetModifiedGeometricTolerance();
1768 if(!MGT.IsNull()) {
1769 kind = kind + MGT->Modifier()+1;
1770 }
1771 TDF_Label TolerL = DGTTool->SetDimTol(shL,kind,arr,aName,aDescription);
1772 // translate datums connected with this tolerance
1773 Handle(StepDimTol_GeometricToleranceWithDatumReference) GTWDR =
1774 GTComplex->GetGeometricToleranceWithDatumReference();
1775 if(!GTWDR.IsNull()) {
1776 ReadDatums(STool,DGTTool,graph,TP,TolerL,GTWDR);
1777 }
1778 }
1779 else if(GT->IsKind(STANDARD_TYPE(StepDimTol_GeometricToleranceWithDatumReference))) {
1780 Handle(StepDimTol_GeometricToleranceWithDatumReference) GTWDR =
1781 Handle(StepDimTol_GeometricToleranceWithDatumReference)::DownCast(subs3.Value());
1782 if(GTWDR.IsNull()) continue;
1783 Standard_Integer kind = 0;
1784 if (GTWDR->IsKind(STANDARD_TYPE(StepDimTol_AngularityTolerance))) kind = 24;
1785 else if(GTWDR->IsKind(STANDARD_TYPE(StepDimTol_CircularRunoutTolerance))) kind = 25;
1786 else if(GTWDR->IsKind(STANDARD_TYPE(StepDimTol_CoaxialityTolerance))) kind = 26;
1787 else if(GTWDR->IsKind(STANDARD_TYPE(StepDimTol_ConcentricityTolerance))) kind = 27;
1788 else if(GTWDR->IsKind(STANDARD_TYPE(StepDimTol_ParallelismTolerance))) kind = 28;
1789 else if(GTWDR->IsKind(STANDARD_TYPE(StepDimTol_PerpendicularityTolerance))) kind = 29;
1790 else if(GTWDR->IsKind(STANDARD_TYPE(StepDimTol_SymmetryTolerance))) kind = 30;
1791 else if(GTWDR->IsKind(STANDARD_TYPE(StepDimTol_TotalRunoutTolerance))) kind = 31;
1792 //cout<<"GTWDR: kind="<<kind<<endl;
1793 TDF_Label TolerL = DGTTool->SetDimTol(shL,kind,arr,aName,aDescription);
1794 ReadDatums(STool,DGTTool,graph,TP,TolerL,GTWDR);
1795 }
1796 else if(GT->IsKind(STANDARD_TYPE(StepDimTol_ModifiedGeometricTolerance))) {
1797 Handle(StepDimTol_ModifiedGeometricTolerance) MGT =
1798 Handle(StepDimTol_ModifiedGeometricTolerance)::DownCast(subs3.Value());
1799 Standard_Integer kind = 35 + MGT->Modifier();
1800 DGTTool->SetDimTol(shL,kind,arr,aName,aDescription);
1801 }
1802 else if(GT->IsKind(STANDARD_TYPE(StepDimTol_CylindricityTolerance))) {
1803 DGTTool->SetDimTol(shL,38,arr,aName,aDescription);
1804 }
1805 else if(GT->IsKind(STANDARD_TYPE(StepDimTol_FlatnessTolerance))) {
1806 DGTTool->SetDimTol(shL,39,arr,aName,aDescription);
1807 }
1808 else if(GT->IsKind(STANDARD_TYPE(StepDimTol_LineProfileTolerance))) {
1809 DGTTool->SetDimTol(shL,40,arr,aName,aDescription);
1810 }
1811 else if(GT->IsKind(STANDARD_TYPE(StepDimTol_PositionTolerance))) {
1812 DGTTool->SetDimTol(shL,41,arr,aName,aDescription);
1813 }
1814 else if(GT->IsKind(STANDARD_TYPE(StepDimTol_RoundnessTolerance))) {
1815 DGTTool->SetDimTol(shL,42,arr,aName,aDescription);
1816 }
1817 else if(GT->IsKind(STANDARD_TYPE(StepDimTol_StraightnessTolerance))) {
1818 DGTTool->SetDimTol(shL,43,arr,aName,aDescription);
1819 }
1820 else if(GT->IsKind(STANDARD_TYPE(StepDimTol_SurfaceProfileTolerance))) {
1821 DGTTool->SetDimTol(shL,44,arr,aName,aDescription);
1822 }
1823 }
1824 }
1825 }
1826 }
1827
1828 return Standard_True;
1829}
1830
1831
1832//=======================================================================
1833//function : FindSolidForPDS
1834//purpose : auxilary
1835//=======================================================================
1836
1837static Handle(StepShape_SolidModel) FindSolidForPDS(const Handle(StepRepr_ProductDefinitionShape) &PDS,
1838 const Interface_Graph &graph)
1839{
1840 Handle(StepShape_SolidModel) SM;
1841 Interface_EntityIterator subs = graph.Sharings(PDS);
1842 Handle(StepShape_ShapeRepresentation) SR;
1843 for(subs.Start(); subs.More() && SM.IsNull(); subs.Next()) {
1844 Handle(StepShape_ShapeDefinitionRepresentation) SDR =
1845 Handle(StepShape_ShapeDefinitionRepresentation)::DownCast(subs.Value());
1846 if(SDR.IsNull()) continue;
1847 SR = Handle(StepShape_ShapeRepresentation)::DownCast(SDR->UsedRepresentation());
1848 if(SR.IsNull()) continue;
1849 for(Standard_Integer i=1; i<=SR->NbItems() && SM.IsNull(); i++) {
1850 SM = Handle(StepShape_SolidModel)::DownCast(SR->ItemsValue(i));
1851 }
1852 if(SM.IsNull()) {
1853 Interface_EntityIterator subs1 = graph.Sharings(SR);
1854 for(subs1.Start(); subs1.More() && SM.IsNull(); subs1.Next()) {
1855 Handle(StepRepr_RepresentationRelationship) RR =
1856 Handle(StepRepr_RepresentationRelationship)::DownCast(subs1.Value());
1857 if(RR.IsNull()) continue;
1858 Handle(StepShape_ShapeRepresentation) SR2;
1859 if(RR->Rep1()==SR) SR2 = Handle(StepShape_ShapeRepresentation)::DownCast(RR->Rep2());
1860 else SR2 = Handle(StepShape_ShapeRepresentation)::DownCast(RR->Rep1());
1861 if(SR2.IsNull()) continue;
1862 for(Standard_Integer i2=1; i2<=SR2->NbItems() && SM.IsNull(); i2++) {
1863 SM = Handle(StepShape_SolidModel)::DownCast(SR2->ItemsValue(i2));
1864 }
1865 }
1866 }
1867 }
1868 return SM;
1869}
1870
1871
1872//=======================================================================
1873//function : ReadMaterials
1874//purpose :
1875//=======================================================================
1876
1877Standard_Boolean STEPCAFControl_Reader::ReadMaterials(const Handle(XSControl_WorkSession) &WS,
1878 Handle(TDocStd_Document)& Doc,
1879 const Handle(TColStd_HSequenceOfTransient) &SeqPDS) const
1880{
1881 Handle(Interface_InterfaceModel) Model = WS->Model();
1882 Handle(XCAFDoc_ShapeTool) STool = XCAFDoc_DocumentTool::ShapeTool( Doc->Main() );
1883 Handle(XSControl_TransferReader) TR = WS->TransferReader();
1884 Handle(Transfer_TransientProcess) TP = TR->TransientProcess();
1885 Handle(XCAFDoc_MaterialTool) MatTool = XCAFDoc_DocumentTool::MaterialTool( Doc->Main() );
1886 if(MatTool.IsNull()) return Standard_False;
1887
1888 const Interface_Graph& graph = TP->Graph();
1889 for(Standard_Integer i=1; i<=SeqPDS->Length(); i++) {
1890 Handle(StepRepr_ProductDefinitionShape) PDS =
1891 Handle(StepRepr_ProductDefinitionShape)::DownCast(SeqPDS->Value(i));
1d2b1ccb
G
1892 if(PDS.IsNull())
1893 continue;
1894 Handle(StepBasic_ProductDefinition) aProdDef = PDS->Definition().ProductDefinition();
1895 if(aProdDef.IsNull())
1896 continue;
7fd59977 1897 Handle(TCollection_HAsciiString) aName = new TCollection_HAsciiString("");
1898 Handle(TCollection_HAsciiString) aDescription = new TCollection_HAsciiString("");
1899 Handle(TCollection_HAsciiString) aDensName = new TCollection_HAsciiString("");
1900 Handle(TCollection_HAsciiString) aDensValType = new TCollection_HAsciiString("");
1901 Standard_Real aDensity=0;
1d2b1ccb 1902 Interface_EntityIterator subs = graph.Sharings( aProdDef);
7fd59977 1903 for(subs.Start(); subs.More(); subs.Next()) {
1904 Handle(StepRepr_PropertyDefinition) PropD =
1905 Handle(StepRepr_PropertyDefinition)::DownCast(subs.Value());
1906 if(PropD.IsNull()) continue;
1907 Interface_EntityIterator subs1 = graph.Sharings(PropD);
1908 for(subs1.Start(); subs1.More(); subs1.Next()) {
1909 Handle(StepRepr_PropertyDefinitionRepresentation) PDR =
1910 Handle(StepRepr_PropertyDefinitionRepresentation)::DownCast(subs1.Value());
1911 if(PDR.IsNull()) continue;
1912 Handle(StepRepr_Representation) Repr = PDR->UsedRepresentation();
1913 if(Repr.IsNull()) continue;
1914 Standard_Integer ir;
1915 for(ir=1; ir<=Repr->NbItems(); ir++) {
1916 Handle(StepRepr_RepresentationItem) RI = Repr->ItemsValue(ir);
1917 if(RI.IsNull()) continue;
1918 if(RI->IsKind(STANDARD_TYPE(StepRepr_DescriptiveRepresentationItem))) {
1919 // find name and description for material
1920 Handle(StepRepr_DescriptiveRepresentationItem) DRI =
1921 Handle(StepRepr_DescriptiveRepresentationItem)::DownCast(RI);
1922 aName = DRI->Name();
1923 aDescription = DRI->Description();
1924 }
1925 if(RI->IsKind(STANDARD_TYPE(StepRepr_MeasureRepresentationItem))) {
1926 // try to find density for material
1927 Handle(StepRepr_MeasureRepresentationItem) MRI =
1928 Handle(StepRepr_MeasureRepresentationItem)::DownCast(RI);
1929 aDensity = MRI->Measure()->ValueComponent();
1930 aDensName = MRI->Name();
1931 aDensValType = new TCollection_HAsciiString(MRI->Measure()->ValueComponentMember()->Name());
1932 StepBasic_Unit aUnit = MRI->Measure()->UnitComponent();
1933 if(!aUnit.IsNull()) {
1934 Handle(StepBasic_DerivedUnit) DU = aUnit.DerivedUnit();
1935 if(DU.IsNull()) continue;
1936 for(Standard_Integer idu=1; idu<=DU->NbElements(); idu++) {
1937 Handle(StepBasic_DerivedUnitElement) DUE = DU->ElementsValue(idu);
1938 Handle(StepBasic_NamedUnit) NU = DUE->Unit();
1939 Standard_Real afact=1.;
1940 if(NU->IsKind(STANDARD_TYPE(StepBasic_ConversionBasedUnitAndLengthUnit))) {
1941 if(GetLengthConversionFactor(NU,afact)) aDensity = aDensity/(afact*afact*afact);
1942 // transfer length value for Density from millimeter to santimeter
1943 // in order to result density has dimension gram/(sm*sm*sm)
1944 aDensity = aDensity*1000.;
1945 }
1946 if(NU->IsKind(STANDARD_TYPE(StepBasic_ConversionBasedUnitAndMassUnit))) {
1947 if(GetMassConversionFactor(NU,afact)) aDensity=aDensity*afact;
1948 }
1949 }
1950 }
1951 }
1952 }
1953 }
1954 }
1955 if( aName->Length()==0 ) continue;
1956 // find shape label amd create Material link
1957 TopoDS_Shape aSh;
1958 Handle(StepShape_SolidModel) SM = FindSolidForPDS(PDS,graph);
1959 if(!SM.IsNull()) {
1960 Standard_Integer index = TP->MapIndex(SM);
1961 if(index >0) {
1962 Handle(Transfer_Binder) binder = TP->MapItem(index);
1963 if(!binder.IsNull())
1964 aSh = TransferBRep::ShapeResult(binder);
1965 }
1966 }
1967 if(aSh.IsNull()) continue;
1968 TDF_Label shL;
1969 if( !STool->Search(aSh, shL, Standard_True, Standard_True, Standard_True) ) continue;
1970 MatTool->SetMaterial(shL,aName,aDescription,aDensity,aDensName,aDensValType);
1971 }
1972
1973 return Standard_True;
1974}
1975
1976
1977//=======================================================================
1978//function : SetColorMode
1979//purpose :
1980//=======================================================================
1981
1982void STEPCAFControl_Reader::SetColorMode (const Standard_Boolean colormode)
1983{
1984 myColorMode = colormode;
1985}
1986
1987//=======================================================================
1988//function : GetColorMode
1989//purpose :
1990//=======================================================================
1991
1992Standard_Boolean STEPCAFControl_Reader::GetColorMode () const
1993{
1994 return myColorMode;
1995}
1996
1997//=======================================================================
1998//function : SetNameMode
1999//purpose :
2000//=======================================================================
2001
2002void STEPCAFControl_Reader::SetNameMode (const Standard_Boolean namemode)
2003{
2004 myNameMode = namemode;
2005}
2006
2007//=======================================================================
2008//function : GetNameMode
2009//purpose :
2010//=======================================================================
2011
2012Standard_Boolean STEPCAFControl_Reader::GetNameMode () const
2013{
2014 return myNameMode;
2015}
2016
2017//=======================================================================
2018//function : SetLayerMode
2019//purpose :
2020//=======================================================================
2021
2022void STEPCAFControl_Reader::SetLayerMode (const Standard_Boolean layermode)
2023{
2024 myLayerMode = layermode;
2025}
2026
2027//=======================================================================
2028//function : GetLayerMode
2029//purpose :
2030//=======================================================================
2031
2032Standard_Boolean STEPCAFControl_Reader::GetLayerMode () const
2033{
2034 return myLayerMode;
2035}
2036
2037//=======================================================================
2038//function : SetPropsMode
2039//purpose :
2040//=======================================================================
2041
2042void STEPCAFControl_Reader::SetPropsMode (const Standard_Boolean propsmode)
2043{
2044 myPropsMode = propsmode;
2045}
2046
2047//=======================================================================
2048//function : GetPropsMode
2049//purpose :
2050//=======================================================================
2051
2052Standard_Boolean STEPCAFControl_Reader::GetPropsMode () const
2053{
2054 return myPropsMode;
2055}
2056
2057//=======================================================================
2058//function : SetSHUOMode
2059//purpose :
2060//=======================================================================
2061
2062void STEPCAFControl_Reader::SetSHUOMode (const Standard_Boolean mode)
2063{
2064 mySHUOMode = mode;
2065}
2066
2067//=======================================================================
2068//function : GetSHUOMode
2069//purpose :
2070//=======================================================================
2071
2072Standard_Boolean STEPCAFControl_Reader::GetSHUOMode () const
2073{
2074 return mySHUOMode;
2075}
2076
2077//=======================================================================
2078//function : SetGDTMode
2079//purpose :
2080//=======================================================================
2081
2082void STEPCAFControl_Reader::SetGDTMode (const Standard_Boolean gdtmode)
2083{
2084 myGDTMode = gdtmode;
2085}
2086
2087//=======================================================================
2088//function : GetGDTMode
2089//purpose :
2090//=======================================================================
2091
2092Standard_Boolean STEPCAFControl_Reader::GetGDTMode () const
2093{
2094 return myGDTMode;
2095}
2096
2097
2098//=======================================================================
2099//function : SetMatMode
2100//purpose :
2101//=======================================================================
2102
2103void STEPCAFControl_Reader::SetMatMode (const Standard_Boolean matmode)
2104{
2105 myMatMode = matmode;
2106}
2107
2108//=======================================================================
2109//function : GetMatMode
2110//purpose :
2111//=======================================================================
2112
2113Standard_Boolean STEPCAFControl_Reader::GetMatMode () const
2114{
2115 return myMatMode;
2116}