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