1 // Created on: 2000-08-15
2 // Created by: Andrey BETENEV
3 // Copyright (c) 2000-2014 OPEN CASCADE SAS
5 // This file is part of Open CASCADE Technology software library.
7 // This library is free software; you can redistribute it and/or modify it under
8 // the terms of the GNU Lesser General Public License version 2.1 as published
9 // by the Free Software Foundation, with special exception defined in the file
10 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
11 // distribution for complete text of the license and disclaimer of any warranty.
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
17 #include <BRep_Builder.hxx>
18 #include <Interface_EntityIterator.hxx>
19 #include <Interface_InterfaceModel.hxx>
20 #include <StepData_StepModel.hxx>
21 #include <HeaderSection_FileSchema.hxx>
22 #include <Interface_Static.hxx>
23 #include <NCollection_DataMap.hxx>
24 #include <OSD_Path.hxx>
25 #include <Quantity_Color.hxx>
26 #include <StepAP214_AppliedExternalIdentificationAssignment.hxx>
27 #include <StepBasic_ConversionBasedUnitAndLengthUnit.hxx>
28 #include <StepBasic_ConversionBasedUnitAndPlaneAngleUnit.hxx>
29 #include <StepBasic_ConversionBasedUnitAndMassUnit.hxx>
30 #include <StepBasic_DerivedUnit.hxx>
31 #include <StepBasic_DerivedUnitElement.hxx>
32 #include <StepBasic_MeasureValueMember.hxx>
33 #include <StepBasic_MeasureWithUnit.hxx>
34 #include <StepBasic_NamedUnit.hxx>
35 #include <StepBasic_Product.hxx>
36 #include <StepBasic_ProductDefinition.hxx>
37 #include <StepBasic_ProductDefinitionFormation.hxx>
38 #include <StepBasic_ProductDefinitionRelationship.hxx>
39 #include <StepBasic_SiUnit.hxx>
40 #include <StepBasic_Unit.hxx>
41 #include <STEPCAFControl_Controller.hxx>
42 #include <STEPCAFControl_DataMapIteratorOfDataMapOfShapePD.hxx>
43 #include <STEPCAFControl_DataMapOfPDExternFile.hxx>
44 #include <STEPCAFControl_DataMapOfSDRExternFile.hxx>
45 #include <STEPCAFControl_DataMapOfShapePD.hxx>
46 #include <STEPCAFControl_DictionaryOfExternFile.hxx>
47 #include <STEPCAFControl_ExternFile.hxx>
48 #include <STEPCAFControl_Reader.hxx>
49 #include <STEPConstruct.hxx>
50 #include <STEPConstruct_Assembly.hxx>
51 #include <STEPConstruct_ExternRefs.hxx>
52 #include <STEPConstruct_Styles.hxx>
53 #include <STEPConstruct_Tool.hxx>
54 #include <STEPConstruct_UnitContext.hxx>
55 #include <STEPConstruct_ValidationProps.hxx>
56 #include <STEPControl_Reader.hxx>
57 #include <StepGeom_GeometricRepresentationItem.hxx>
58 #include <StepGeom_Axis2Placement3d.hxx>
59 #include <StepGeom_Direction.hxx>
60 #include <StepDimTol_AngularityTolerance.hxx>
61 #include <StepDimTol_CircularRunoutTolerance.hxx>
62 #include <StepDimTol_CoaxialityTolerance.hxx>
63 #include <StepDimTol_ConcentricityTolerance.hxx>
64 #include <StepDimTol_CylindricityTolerance.hxx>
65 #include <StepDimTol_Datum.hxx>
66 #include <StepDimTol_DatumFeature.hxx>
67 #include <StepDimTol_DatumReference.hxx>
68 #include <StepDimTol_DatumReferenceElement.hxx>
69 #include <StepDimTol_DatumReferenceCompartment.hxx>
70 #include <StepDimTol_DatumSystem.hxx>
71 #include <StepDimTol_FlatnessTolerance.hxx>
72 #include <StepDimTol_GeometricTolerance.hxx>
73 #include <StepDimTol_GeometricToleranceWithDatumReference.hxx>
74 #include <StepDimTol_GeoTolAndGeoTolWthDatRefAndModGeoTolAndPosTol.hxx>
75 #include <StepDimTol_GeoTolAndGeoTolWthDatRef.hxx>
76 #include <StepDimTol_GeoTolAndGeoTolWthDatRefAndGeoTolWthMaxTol.hxx>
77 #include <StepDimTol_GeoTolAndGeoTolWthDatRefAndUneqDisGeoTol.hxx>
78 #include <StepDimTol_GeoTolAndGeoTolWthMaxTol.hxx>
79 #include <StepDimTol_HArray1OfDatumReference.hxx>
80 #include <StepDimTol_LineProfileTolerance.hxx>
81 #include <StepDimTol_ModifiedGeometricTolerance.hxx>
82 #include <StepDimTol_ParallelismTolerance.hxx>
83 #include <StepDimTol_PerpendicularityTolerance.hxx>
84 #include <StepDimTol_PositionTolerance.hxx>
85 #include <StepDimTol_ProjectedZoneDefinition.hxx>
86 #include <StepDimTol_RoundnessTolerance.hxx>
87 #include <StepDimTol_RunoutZoneDefinition.hxx>
88 #include <StepDimTol_StraightnessTolerance.hxx>
89 #include <StepDimTol_SurfaceProfileTolerance.hxx>
90 #include <StepDimTol_SymmetryTolerance.hxx>
91 #include <StepDimTol_ToleranceZone.hxx>
92 #include <StepDimTol_ToleranceZoneForm.hxx>
93 #include <StepDimTol_TotalRunoutTolerance.hxx>
94 #include <StepDimTol_GeometricToleranceWithModifiers.hxx>
95 #include <StepDimTol_HArray1OfGeometricToleranceModifier.hxx>
96 #include <StepDimTol_GeoTolAndGeoTolWthDatRefAndGeoTolWthMod.hxx>
97 #include <StepDimTol_GeoTolAndGeoTolWthMod.hxx>
98 #include <StepDimTol_GeometricToleranceWithMaximumTolerance.hxx>
99 #include <StepDimTol_PlacedDatumTargetFeature.hxx>
100 #include <StepRepr_AssemblyComponentUsage.hxx>
101 #include <StepRepr_CharacterizedDefinition.hxx>
102 #include <StepRepr_CompoundRepresentationItem.hxx>
103 #include <StepRepr_DescriptiveRepresentationItem.hxx>
104 #include <StepRepr_HArray1OfRepresentationItem.hxx>
105 #include <StepRepr_MeasureRepresentationItem.hxx>
106 #include <StepRepr_NextAssemblyUsageOccurrence.hxx>
107 #include <StepRepr_ProductDefinitionShape.hxx>
108 #include <StepRepr_PropertyDefinition.hxx>
109 #include <StepRepr_PropertyDefinitionRepresentation.hxx>
110 #include <StepRepr_Representation.hxx>
111 #include <StepRepr_RepresentationItem.hxx>
112 #include <StepRepr_HArray1OfRepresentationItem.hxx>
113 #include <StepRepr_RepresentationRelationship.hxx>
114 #include <StepRepr_RepresentedDefinition.hxx>
115 #include <StepRepr_ReprItemAndLengthMeasureWithUnit.hxx>
116 #include <StepRepr_ReprItemAndPlaneAngleMeasureWithUnit.hxx>
117 #include <StepRepr_SequenceOfRepresentationItem.hxx>
118 #include <StepRepr_ShapeAspect.hxx>
119 #include <StepRepr_CompositeShapeAspect.hxx>
120 #include <StepRepr_AllAroundShapeAspect.hxx>
121 #include <StepRepr_CompShAspAndDatumFeatAndShAsp.hxx>
122 #include <StepRepr_ShapeAspectRelationship.hxx>
123 #include <StepRepr_ShapeRepresentationRelationship.hxx>
124 #include <StepRepr_SpecifiedHigherUsageOccurrence.hxx>
125 #include <StepRepr_ValueRange.hxx>
126 #include <StepRepr_FeatureForDatumTargetRelationship.hxx>
127 #include <StepShape_AdvancedFace.hxx>
128 #include <StepShape_AdvancedBrepShapeRepresentation.hxx>
129 #include <StepShape_AngleRelator.hxx>
130 #include <StepShape_AngularSize.hxx>
131 #include <StepShape_AngularLocation.hxx>
132 #include <StepShape_ClosedShell.hxx>
133 #include <StepShape_ConnectedFaceSet.hxx>
134 #include <StepShape_ContextDependentShapeRepresentation.hxx>
135 #include <StepRepr_CompGroupShAspAndCompShAspAndDatumFeatAndShAsp.hxx>
136 #include <StepRepr_CompShAspAndDatumFeatAndShAsp.hxx>
137 #include <StepShape_DimensionalCharacteristicRepresentation.hxx>
138 #include <StepShape_DimensionalSizeWithPath.hxx>
139 #include <StepShape_DimensionalLocationWithPath.hxx>
140 #include <StepShape_ShapeDimensionRepresentationItem.hxx>
141 #include <StepShape_ShapeRepresentationWithParameters.hxx>
142 #include <StepShape_HArray1OfShapeDimensionRepresentationItem.hxx>
143 #include <StepShape_DimensionalSize.hxx>
144 #include <StepShape_DimensionalLocation.hxx>
145 #include <StepShape_EdgeCurve.hxx>
146 #include <StepShape_EdgeLoop.hxx>
147 #include <StepShape_GeometricSet.hxx>
148 #include <StepShape_HArray1OfFace.hxx>
149 #include <StepShape_HArray1OfFaceBound.hxx>
150 #include <StepShape_HArray1OfOrientedEdge.hxx>
151 #include <StepShape_HArray1OfShell.hxx>
152 #include <StepShape_LimitsAndFits.hxx>
153 #include <StepShape_Loop.hxx>
154 #include <StepShape_ManifoldSolidBrep.hxx>
155 #include <StepShape_PlusMinusTolerance.hxx>
156 #include <StepShape_QualifiedRepresentationItem.hxx>
157 #include <StepShape_OpenShell.hxx>
158 #include <StepShape_ShapeDefinitionRepresentation.hxx>
159 #include <StepShape_ShapeDimensionRepresentation.hxx>
160 #include <StepShape_ShapeRepresentation.hxx>
161 #include <StepShape_ShellBasedSurfaceModel.hxx>
162 #include <StepShape_SolidModel.hxx>
163 #include <StepShape_ToleranceMethodDefinition.hxx>
164 #include <StepShape_ToleranceValue.hxx>
165 #include <StepShape_ValueFormatTypeQualifier.hxx>
166 #include <StepShape_Vertex.hxx>
167 #include <StepVisual_Invisibility.hxx>
168 #include <StepVisual_LayeredItem.hxx>
169 #include <StepVisual_PresentationLayerAssignment.hxx>
170 #include <StepVisual_PresentationStyleByContext.hxx>
171 #include <StepVisual_StyleContextSelect.hxx>
172 #include <StepVisual_StyledItem.hxx>
173 #include <StepShape_TypeQualifier.hxx>
174 #include <TCollection_AsciiString.hxx>
175 #include <TCollection_HAsciiString.hxx>
176 #include <TColStd_HArray1OfReal.hxx>
177 #include <TColStd_HArray1OfTransient.hxx>
178 #include <TColStd_HSequenceOfTransient.hxx>
179 #include <TColStd_IndexedDataMapOfTransientTransient.hxx>
180 #include <TColStd_MapIteratorOfMapOfTransient.hxx>
181 #include <TColStd_MapOfTransient.hxx>
182 #include <TColStd_SequenceOfHAsciiString.hxx>
183 #include <TDataStd_Name.hxx>
184 #include <TDataStd_TreeNode.hxx>
185 #include <TDataStd_UAttribute.hxx>
186 #include <TDF_Label.hxx>
187 #include <TDF_Tool.hxx>
188 #include <TDocStd_Document.hxx>
189 #include <TNaming_NamedShape.hxx>
190 #include <TopoDS.hxx>
191 #include <TopoDS_Compound.hxx>
192 #include <TopoDS_Iterator.hxx>
193 #include <TopoDS_Shape.hxx>
194 #include <TopTools_ListIteratorOfListOfShape.hxx>
195 #include <TopTools_ListOfShape.hxx>
196 #include <TopTools_MapOfShape.hxx>
197 #include <Transfer_Binder.hxx>
198 #include <Transfer_TransientProcess.hxx>
199 #include <TransferBRep.hxx>
200 #include <XCAFDoc.hxx>
201 #include <XCAFDoc_Area.hxx>
202 #include <XCAFDoc_Centroid.hxx>
203 #include <XCAFDoc_ColorTool.hxx>
204 #include <XCAFDoc_DataMapOfShapeLabel.hxx>
205 #include <XCAFDoc_DimTolTool.hxx>
206 #include <XCAFDoc_Dimension.hxx>
207 #include <XCAFDoc_Datum.hxx>
208 #include <XCAFDoc_GeomTolerance.hxx>
209 #include <XCAFDoc_DocumentTool.hxx>
210 #include <XCAFDoc_GraphNode.hxx>
211 #include <XCAFDoc_LayerTool.hxx>
212 #include <XCAFDoc_MaterialTool.hxx>
213 #include <XCAFDoc_ShapeTool.hxx>
214 #include <XCAFDoc_Volume.hxx>
215 #include <XCAFDimTolObjects_DimensionModifiersSequence.hxx>
216 #include <XCAFDimTolObjects_GeomToleranceType.hxx>
217 #include <XCAFDimTolObjects_DimensionObject.hxx>
218 #include <XCAFDimTolObjects_GeomToleranceObject.hxx>
219 #include <XCAFDimTolObjects_DatumObject.hxx>
220 #include <XSControl_TransferReader.hxx>
221 #include <XSControl_WorkSession.hxx>
222 #include <StepAP242_GeometricItemSpecificUsage.hxx>
223 #include <StepGeom_CartesianPoint.hxx>
224 #include <STEPCAFControl_GDTProperty.hxx>
225 // skl 21.08.2003 for reading G&DT
226 //#include <StepRepr_CompoundItemDefinition.hxx>
227 //#include <StepRepr_CompoundItemDefinitionMember.hxx>
228 //#include <StepBasic_ConversionBasedUnit.hxx>
229 //#include <TDataStd_Real.hxx>
230 //#include <TDataStd_Constraint.hxx>
231 //#include <TDataStd_ConstraintEnum.hxx>
232 //#include <TNaming_Tool.hxx>
233 //#include <AIS_InteractiveObject.hxx>
234 //#include <TPrsStd_ConstraintTools.hxx>
235 //#include <AIS_DiameterDimension.hxx>
236 //#include <TPrsStd_Position.hxx>
237 //#include <TPrsStd_AISPresentation.hxx>
238 //#include <TNaming_Builder.hxx>
240 //! Converts address of the passed shape (TShape) to string.
241 //! \param theShape [in] Shape to dump.
242 //! \return corresponding string.
243 TCollection_AsciiString AddrToString(const TopoDS_Shape& theShape)
245 std::string anAddrStr;
246 std::ostringstream ost;
247 ost << theShape.TShape().get();
248 anAddrStr = ost.str();
250 TCollection_AsciiString aStr =
251 TCollection_AsciiString("[").Cat( anAddrStr.c_str() ).Cat("]");
257 //=======================================================================
259 //purpose : global function to check equality of topological shapes
260 //=======================================================================
262 inline Standard_Boolean IsEqual(const TopoDS_Shape& theShape1,
263 const TopoDS_Shape& theShape2)
265 return theShape1.IsEqual(theShape2);
268 //=======================================================================
269 //function : AllocateSubLabel
271 //=======================================================================
273 static TDF_Label AllocateSubLabel(TDF_Label& theRoot)
275 return TDF_TagSource::NewChild(theRoot);
278 //=======================================================================
279 //function : STEPCAFControl_Reader
281 //=======================================================================
283 STEPCAFControl_Reader::STEPCAFControl_Reader ():
284 myColorMode( Standard_True ),
285 myNameMode ( Standard_True ),
286 myLayerMode( Standard_True ),
287 myPropsMode( Standard_True ),
288 mySHUOMode ( Standard_False ),
289 myGDTMode ( Standard_True ),
290 myMatMode ( Standard_True )
292 STEPCAFControl_Controller::Init();
293 myFiles = new STEPCAFControl_DictionaryOfExternFile;
297 //=======================================================================
298 //function : STEPCAFControl_Reader
300 //=======================================================================
302 STEPCAFControl_Reader::STEPCAFControl_Reader (const Handle(XSControl_WorkSession)& WS,
303 const Standard_Boolean scratch) :
304 myColorMode( Standard_True ),
305 myNameMode ( Standard_True ),
306 myLayerMode( Standard_True ),
307 myPropsMode( Standard_True ),
308 mySHUOMode ( Standard_False ),
309 myGDTMode ( Standard_True ),
310 myMatMode ( Standard_True )
312 STEPCAFControl_Controller::Init();
313 Init ( WS, scratch );
317 //=======================================================================
320 //=======================================================================
322 void STEPCAFControl_Reader::Init (const Handle(XSControl_WorkSession)& WS,
323 const Standard_Boolean scratch)
325 // necessary only in Writer, to set good actor: WS->SelectNorm ( "STEP" );
326 myReader.SetWS (WS,scratch);
327 myFiles = new STEPCAFControl_DictionaryOfExternFile;
331 //=======================================================================
332 //function : ReadFile
334 //=======================================================================
336 IFSelect_ReturnStatus STEPCAFControl_Reader::ReadFile (const Standard_CString filename)
338 return myReader.ReadFile ( filename );
342 //=======================================================================
343 //function : NbRootsForTransfer
345 //=======================================================================
347 Standard_Integer STEPCAFControl_Reader::NbRootsForTransfer ()
349 return myReader.NbRootsForTransfer();
353 //=======================================================================
354 //function : TransferOneRoot
356 //=======================================================================
358 Standard_Boolean STEPCAFControl_Reader::TransferOneRoot (const Standard_Integer num,
359 Handle(TDocStd_Document) &doc)
361 TDF_LabelSequence Lseq;
362 return Transfer ( myReader, num, doc, Lseq );
366 //=======================================================================
367 //function : Transfer
369 //=======================================================================
371 Standard_Boolean STEPCAFControl_Reader::Transfer (Handle(TDocStd_Document) &doc)
373 TDF_LabelSequence Lseq;
374 return Transfer ( myReader, 0, doc, Lseq );
378 //=======================================================================
381 //=======================================================================
383 Standard_Boolean STEPCAFControl_Reader::Perform (const Standard_CString filename,
384 Handle(TDocStd_Document) &doc)
386 if ( ReadFile ( filename ) != IFSelect_RetDone ) return Standard_False;
387 return Transfer ( doc );
391 //=======================================================================
394 //=======================================================================
396 Standard_Boolean STEPCAFControl_Reader::Perform (const TCollection_AsciiString &filename,
397 Handle(TDocStd_Document) &doc)
399 if ( ReadFile ( filename.ToCString() ) != IFSelect_RetDone ) return Standard_False;
400 return Transfer ( doc );
404 //=======================================================================
405 //function : ExternFiles
407 //=======================================================================
409 const Handle(STEPCAFControl_DictionaryOfExternFile) &STEPCAFControl_Reader::ExternFiles () const
415 //=======================================================================
416 //function : ExternFile
418 //=======================================================================
420 Standard_Boolean STEPCAFControl_Reader::ExternFile (const Standard_CString name,
421 Handle(STEPCAFControl_ExternFile) &ef) const
424 if ( myFiles.IsNull() || ! myFiles->HasItem ( name ) )
425 return Standard_False;
426 ef = myFiles->Item ( name );
427 return Standard_True;
431 //=======================================================================
434 //=======================================================================
436 STEPControl_Reader &STEPCAFControl_Reader::ChangeReader ()
442 //=======================================================================
445 //=======================================================================
447 const STEPControl_Reader &STEPCAFControl_Reader::Reader () const
453 //=======================================================================
454 //function : FillShapesMap
455 //purpose : auxiliary: fill a map by all compounds and their components
456 //=======================================================================
458 static void FillShapesMap (const TopoDS_Shape &S, TopTools_MapOfShape &map)
464 if ( S.ShapeType() != TopAbs_COMPOUND ) return;
465 for ( TopoDS_Iterator it(S); it.More(); it.Next() )
466 FillShapesMap ( it.Value(), map );
470 //=======================================================================
471 //function : Transfer
472 //purpose : basic working method
473 //=======================================================================
475 Standard_Boolean STEPCAFControl_Reader::Transfer (STEPControl_Reader &reader,
476 const Standard_Integer nroot,
477 Handle(TDocStd_Document) &doc,
478 TDF_LabelSequence &Lseq,
479 const Standard_Boolean asOne)
481 reader.ClearShapes();
485 Standard_Integer num = reader.NbRootsForTransfer();
486 if ( num <=0 ) return Standard_False;
488 if ( nroot > num ) return Standard_False;
489 reader.TransferOneRoot ( nroot );
492 for ( i=1; i <= num; i++ ) reader.TransferOneRoot ( i );
494 num = reader.NbShapes();
495 if ( num <=0 ) return Standard_False;
497 // Fill a map of (top-level) shapes resulting from that transfer
498 // Only these shapes will be considered further
499 TopTools_MapOfShape ShapesMap, NewShapesMap;
500 for ( i=1; i <= num; i++ ) FillShapesMap ( reader.Shape(i), ShapesMap );
502 // Collect information on shapes originating from SDRs
503 // this will be used to distinguish compounds representing assemblies
504 // from the ones representing hybrid models and shape sets
505 STEPCAFControl_DataMapOfShapePD ShapePDMap;
506 STEPCAFControl_DataMapOfPDExternFile PDFileMap;
507 Handle(Interface_InterfaceModel) Model = reader.Model();
508 Handle(Transfer_TransientProcess) TP = reader.WS()->TransferReader()->TransientProcess();
509 Standard_Integer nb = Model->NbEntities();
511 Handle(TColStd_HSequenceOfTransient) SeqPDS = new TColStd_HSequenceOfTransient;
513 for (i = 1; i <= nb; i ++) {
514 Handle(Standard_Transient) enti = Model->Value(i);
515 if(enti->IsKind(STANDARD_TYPE(StepRepr_ProductDefinitionShape))) {
516 // sequence for acceleration ReadMaterials
517 SeqPDS->Append(enti);
519 if ( enti->IsKind ( STANDARD_TYPE(StepBasic_ProductDefinition ) ) ) {
520 Handle(StepBasic_ProductDefinition) PD =
521 Handle(StepBasic_ProductDefinition)::DownCast(enti);
522 Standard_Integer index = TP->MapIndex(PD);
524 Handle(Transfer_Binder) binder = TP->MapItem (index);
525 TopoDS_Shape S = TransferBRep::ShapeResult(binder);
526 if ( ! S.IsNull() && ShapesMap.Contains(S) ) {
528 ShapePDMap.Bind ( S, PD );
529 Handle(STEPCAFControl_ExternFile) EF;
530 PDFileMap.Bind ( PD, EF );
534 if ( enti->IsKind ( STANDARD_TYPE(StepShape_ShapeRepresentation) ) ) {
535 Standard_Integer index = TP->MapIndex(enti);
537 Handle(Transfer_Binder) binder = TP->MapItem (index);
538 TopoDS_Shape S = TransferBRep::ShapeResult(binder);
539 if ( ! S.IsNull() && ShapesMap.Contains(S) )
545 // get directory name of the main file
546 OSD_Path mainfile ( reader.WS()->LoadedFile() );
547 mainfile.SetName ( "" );
548 mainfile.SetExtension ( "" );
549 TCollection_AsciiString dpath;
550 mainfile.SystemName ( dpath );
552 // Load external references (only for relevant SDRs)
553 // and fill map SDR -> extern file
554 STEPConstruct_ExternRefs ExtRefs ( reader.WS() );
555 ExtRefs.LoadExternRefs();
556 for ( i=1; i <= ExtRefs.NbExternRefs(); i++ ) {
557 // check extern ref format
558 Handle(TCollection_HAsciiString) format = ExtRefs.Format(i);
559 if ( ! format.IsNull() ) {
560 static Handle(TCollection_HAsciiString) ap203 = new TCollection_HAsciiString ( "STEP AP203" );
561 static Handle(TCollection_HAsciiString) ap214 = new TCollection_HAsciiString ( "STEP AP214" );
562 if ( ! format->IsSameString ( ap203, Standard_False ) &&
563 ! format->IsSameString ( ap214, Standard_False ) ) {
565 cout << "Warning: STEPCAFControl_Reader::Transfer: Extern document is neither STEP AP203 nor AP214" << endl;
572 else cout << "Warning: STEPCAFControl_Reader::Transfer: Extern document format not defined" << endl;
575 // get and check filename of the current extern ref
576 const Standard_CString filename = ExtRefs.FileName(i);
579 cout<<"filename="<<filename<<endl;
582 if ( ! filename || ! filename[0] ) {
584 cout << "Warning: STEPCAFControl_Reader::Transfer: Extern reference file name is empty" << endl;
586 continue; // not a valid extern ref
589 // compute true path to the extern file
590 TCollection_AsciiString fullname = OSD_Path::AbsolutePath ( dpath, filename );
591 if ( fullname.Length() <= 0 ) fullname = filename;
595 char *mainfile = reader.WS()->LoadedFile();
596 if ( ! mainfile ) mainfile = "";
597 Standard_Integer slash = 0;
598 for ( Standard_Integer k=0; mainfile[k]; k++ )
599 if ( mainfile[k] == '/' ) slash = k;
600 strncpy ( fullname, mainfile, slash );
601 sprintf ( &fullname[slash], "%s%s", ( mainfile[0] ? "/" : "" ), filename );
604 // get and check PD associated with the current extern ref
605 Handle(StepBasic_ProductDefinition) PD = ExtRefs.ProdDef(i);
606 if ( PD.IsNull() ) continue; // not a valid extern ref
607 if ( ! PDFileMap.IsBound ( PD ) ) continue; // this PD is not concerned by current transfer
609 // read extern file (or use existing data) and record its data
610 Handle(STEPCAFControl_ExternFile) EF =
611 ReadExternFile ( filename, fullname.ToCString(), doc );
612 PDFileMap.Bind ( PD, EF );
615 // and insert them to the document
616 Handle(XCAFDoc_ShapeTool) STool = XCAFDoc_DocumentTool::ShapeTool( doc->Main() );
617 if ( STool.IsNull() ) return Standard_False;
618 XCAFDoc_DataMapOfShapeLabel map;
620 Lseq.Append ( AddShape ( reader.OneShape(), STool, NewShapesMap, ShapePDMap, PDFileMap, map ) );
622 for ( i=1; i <= num; i++ ) {
623 Lseq.Append ( AddShape ( reader.Shape(i), STool, NewShapesMap, ShapePDMap, PDFileMap, map ) );
628 if ( GetColorMode() )
629 ReadColors ( reader.WS(), doc, PDFileMap, map );
633 ReadNames ( reader.WS(), doc, PDFileMap, map );
635 // read validation props
636 if ( GetPropsMode() )
637 ReadValProps ( reader.WS(), doc, PDFileMap, map );
640 if ( GetLayerMode() )
641 ReadLayers ( reader.WS(), doc );
643 // read SHUO entities from STEP model
645 ReadSHUOs ( reader.WS(), doc, PDFileMap, map );
647 // read GDT entities from STEP model
649 ReadGDTs(reader.WS(),doc);
651 // read Material entities from STEP model
653 ReadMaterials(reader.WS(),doc,SeqPDS);
655 // Expand resulting CAF structure for sub-shapes (optionally with their
656 // names) if requested
657 ExpandSubShapes(STool, map, ShapePDMap);
659 return Standard_True;
662 //=======================================================================
663 //function : AddShape
665 //=======================================================================
667 TDF_Label STEPCAFControl_Reader::AddShape (const TopoDS_Shape &S,
668 const Handle(XCAFDoc_ShapeTool) &STool,
669 const TopTools_MapOfShape &NewShapesMap,
670 const STEPCAFControl_DataMapOfShapePD &ShapePDMap,
671 const STEPCAFControl_DataMapOfPDExternFile &PDFileMap,
672 XCAFDoc_DataMapOfShapeLabel &ShapeLabelMap) const
674 // if shape has already been mapped, just return corresponding label
675 if ( ShapeLabelMap.IsBound ( S ) ) {
676 return ShapeLabelMap.Find ( S );
679 // if shape is located, create instance
680 if ( ! S.Location().IsIdentity() ) {
684 AddShape ( S0, STool, NewShapesMap, ShapePDMap, PDFileMap, ShapeLabelMap );
685 TDF_Label L = STool->AddShape ( S, Standard_False ); // should create reference
686 ShapeLabelMap.Bind ( S, L );
690 // if shape is not compound, simple add it
691 if ( S.ShapeType() != TopAbs_COMPOUND ) {
692 TDF_Label L = STool->AddShape ( S, Standard_False );
693 ShapeLabelMap.Bind ( S, L );
697 // for compounds, compute number of subshapes and check whether this is assembly
698 Standard_Boolean isAssembly = Standard_False;
699 Standard_Integer nbComponents = 0;
701 for ( it.Initialize(S); it.More(); it.Next(), nbComponents++ ) {
702 TopoDS_Shape Sub0 = it.Value();
704 Sub0.Location ( loc );
705 if ( NewShapesMap.Contains ( Sub0 ) ) isAssembly = Standard_True;
708 // if(nbComponents>0) isAssembly = Standard_True;
710 // check whether it has associated external ref
711 TColStd_SequenceOfHAsciiString SHAS;
712 if ( ShapePDMap.IsBound ( S ) && PDFileMap.IsBound ( ShapePDMap.Find(S) ) ) {
713 Handle(STEPCAFControl_ExternFile) EF = PDFileMap.Find ( ShapePDMap.Find(S) );
714 if ( ! EF.IsNull() ) {
715 // (store information on extern refs in the document)
716 SHAS.Append(EF->GetName());
717 // if yes, just return corresponding label
718 if ( ! EF->GetLabel().IsNull() ) {
719 // but if components >0, ignore extern ref!
720 if ( nbComponents <=0 ) {
721 ShapeLabelMap.Bind ( S, EF->GetLabel() );
722 STool->SetExternRefs(EF->GetLabel(),SHAS);
723 return EF->GetLabel();
727 if ( ! EF->GetLabel().IsNull() )
728 cout << "Warning: STEPCAFControl_Reader::AddShape: Non-empty shape with external ref; ref is ignored" << endl;
729 else if ( nbComponents <=0 )
730 cout << "Warning: STEPCAFControl_Reader::AddShape: Result of reading extern ref is Null" << endl;
735 // add compound either as a whole,
736 if ( ! isAssembly ) {
737 TDF_Label L = STool->AddShape ( S, Standard_False );
738 if ( SHAS.Length() >0 ) STool->SetExternRefs(L,SHAS);
739 ShapeLabelMap.Bind ( S, L );
743 // or as assembly, component-by-component
744 TDF_Label L = STool->NewShape();
745 for ( it.Initialize(S); it.More(); it.Next(), nbComponents++ ) {
746 TopoDS_Shape Sub0 = it.Value();
748 Sub0.Location ( loc );
749 TDF_Label subL = AddShape ( Sub0, STool, NewShapesMap, ShapePDMap, PDFileMap, ShapeLabelMap );
750 if ( ! subL.IsNull() ) {
751 STool->AddComponent ( L, subL, it.Value().Location() );
754 if ( SHAS.Length() >0 ) STool->SetExternRefs(L,SHAS);
755 ShapeLabelMap.Bind ( S, L );
756 //STool->SetShape ( L, S ); // it is necessary for assemblies OCC1747 // commemted by skl for OCC2941
761 //=======================================================================
762 //function : ReadExternFile
764 //=======================================================================
766 Handle(STEPCAFControl_ExternFile) STEPCAFControl_Reader::ReadExternFile (const Standard_CString file,
767 const Standard_CString fullname,
768 Handle(TDocStd_Document)& doc)
770 // if the file is already read, associate it with SDR
771 if ( myFiles->HasItem ( file, Standard_True ) ) {
772 return myFiles->Item ( file );
776 cout << "Reading extern file: " << fullname << endl;
779 // create new WorkSession and Reader
780 Handle(XSControl_WorkSession) newWS = new XSControl_WorkSession;
781 newWS->SelectNorm ( "STEP" );
782 STEPControl_Reader sr ( newWS, Standard_False );
784 // start to fill the resulting ExternFile structure
785 Handle(STEPCAFControl_ExternFile) EF = new STEPCAFControl_ExternFile;
787 EF->SetName ( new TCollection_HAsciiString ( file ) );
790 EF->SetLoadStatus ( sr.ReadFile ( fullname ) );
792 // transfer in single-result mode
793 if ( EF->GetLoadStatus() == IFSelect_RetDone ) {
794 TDF_LabelSequence labels;
795 EF->SetTransferStatus ( Transfer ( sr, 0, doc, labels, Standard_True ) );
796 if ( labels.Length() >0 ) EF->SetLabel ( labels.Value(1) );
799 // add read file to dictionary
800 myFiles->SetItem ( file, EF );
806 //=======================================================================
807 //function : SetColorToSubshape
809 //=======================================================================
810 static void SetColorToSubshape(const Handle(XCAFDoc_ColorTool) & CTool,
811 const TopoDS_Shape & S,
812 const Quantity_Color& col,
813 const XCAFDoc_ColorType type)
815 for (TopoDS_Iterator it(S); it.More(); it.Next())
816 if (! CTool->SetColor( it.Value(), col, type)) break;
820 //=======================================================================
821 //function : findStyledSR
823 //=======================================================================
824 static void findStyledSR (const Handle(StepVisual_StyledItem) &style,
825 Handle(StepShape_ShapeRepresentation)& aSR)
827 // search Shape Represenatation for component styled item
828 for ( Standard_Integer j=1; j <= style->NbStyles(); j++ ) {
829 Handle(StepVisual_PresentationStyleByContext) PSA =
830 Handle(StepVisual_PresentationStyleByContext)::DownCast(style->StylesValue ( j ));
833 StepVisual_StyleContextSelect aStyleCntxSlct = PSA->StyleContext();
834 Handle(StepShape_ShapeRepresentation) aCurrentSR =
835 Handle(StepShape_ShapeRepresentation)::DownCast(aStyleCntxSlct.Representation());
836 if ( aCurrentSR.IsNull() )
844 //=======================================================================
845 //function : ReadColors
847 //=======================================================================
849 Standard_Boolean STEPCAFControl_Reader::ReadColors (const Handle(XSControl_WorkSession) &WS,
850 Handle(TDocStd_Document)& Doc,
851 const STEPCAFControl_DataMapOfPDExternFile &PDFileMap,
852 const XCAFDoc_DataMapOfShapeLabel &ShapeLabelMap) const
854 STEPConstruct_Styles Styles ( WS );
855 if ( ! Styles.LoadStyles() ) {
857 cout << "Warning: no styles are found in the model" << endl;
859 return Standard_False;
861 // searching for invisible items in the model
862 Handle(TColStd_HSequenceOfTransient) aHSeqOfInvisStyle = new TColStd_HSequenceOfTransient;
863 Styles.LoadInvisStyles( aHSeqOfInvisStyle );
865 Handle(XCAFDoc_ColorTool) CTool = XCAFDoc_DocumentTool::ColorTool( Doc->Main() );
866 if ( CTool.IsNull() ) return Standard_False;
868 // parse and search for color attributes
869 Standard_Integer nb = Styles.NbStyles();
870 for ( Standard_Integer i=1; i <= nb; i++ ) {
871 Handle(StepVisual_StyledItem) style = Styles.Style ( i );
872 if ( style.IsNull() ) continue;
874 Standard_Boolean IsVisible = Standard_True;
875 // check the visibility of styled item.
876 for (Standard_Integer si = 1; si <= aHSeqOfInvisStyle->Length(); si++ ) {
877 if ( style != aHSeqOfInvisStyle->Value( si ) )
879 // found that current style is invisible.
880 IsVisible = Standard_False;
884 Handle(StepVisual_Colour) SurfCol, BoundCol, CurveCol;
885 // check if it is component style
886 Standard_Boolean IsComponent = Standard_False;
887 if ( ! Styles.GetColors ( style, SurfCol, BoundCol, CurveCol, IsComponent ) && IsVisible )
891 TopoDS_Shape S = STEPConstruct::FindShape ( Styles.TransientProcess(), style->Item() );
892 Standard_Boolean isSkipSHUOstyle = Standard_False;
893 // take shape with real location.
894 while ( IsComponent ) {
896 Handle(StepShape_ShapeRepresentation) aSR;
897 findStyledSR( style, aSR );
898 // search for SR along model
901 // Handle(Interface_InterfaceModel) Model = WS->Model();
902 Handle(XSControl_TransferReader) TR = WS->TransferReader();
903 Handle(Transfer_TransientProcess) TP = TR->TransientProcess();
904 Interface_EntityIterator subs = WS->HGraph()->Graph().Sharings( aSR );
905 Handle(StepShape_ShapeDefinitionRepresentation) aSDR;
906 for (subs.Start(); subs.More(); subs.Next()) {
907 aSDR = Handle(StepShape_ShapeDefinitionRepresentation)::DownCast(subs.Value());
910 StepRepr_RepresentedDefinition aPDSselect = aSDR->Definition();
911 Handle(StepRepr_ProductDefinitionShape) PDS =
912 Handle(StepRepr_ProductDefinitionShape)::DownCast(aPDSselect.PropertyDefinition());
915 StepRepr_CharacterizedDefinition aCharDef = PDS->Definition();
917 Handle(StepRepr_AssemblyComponentUsage) ACU =
918 Handle(StepRepr_AssemblyComponentUsage)::DownCast(aCharDef.ProductDefinitionRelationship());
919 // PTV 10.02.2003 skip styled item that refer to SHUO
920 if (ACU->IsKind(STANDARD_TYPE(StepRepr_SpecifiedHigherUsageOccurrence))) {
921 isSkipSHUOstyle = Standard_True;
924 Handle(StepRepr_NextAssemblyUsageOccurrence) NAUO =
925 Handle(StepRepr_NextAssemblyUsageOccurrence)::DownCast(ACU);
930 // PTV 10.02.2003 to find component of assembly CORRECTLY
931 STEPConstruct_Tool Tool( WS );
932 TDF_Label aShLab = FindInstance ( NAUO, CTool->ShapeTool(), Tool, PDFileMap, ShapeLabelMap );
933 aSh = CTool->ShapeTool()->GetShape(aShLab);
934 // Handle(Transfer_Binder) binder = TP->Find(NAUO);
935 // if ( binder.IsNull() || ! binder->HasResult() )
937 // aSh = TransferBRep::ShapeResult ( TP, binder );
946 continue; // skip styled item which refer to SHUO
951 if ( ! SurfCol.IsNull() ) {
953 Styles.DecodeColor ( SurfCol, col );
954 if ( ! CTool->SetColor ( S, col, XCAFDoc_ColorSurf ))
955 SetColorToSubshape( CTool, S, col, XCAFDoc_ColorSurf );
957 if ( ! BoundCol.IsNull() ) {
959 Styles.DecodeColor ( BoundCol, col );
960 if ( ! CTool->SetColor ( S, col, XCAFDoc_ColorCurv ))
961 SetColorToSubshape( CTool, S, col, XCAFDoc_ColorCurv );
963 if ( ! CurveCol.IsNull() ) {
965 Styles.DecodeColor ( CurveCol, col );
966 if ( ! CTool->SetColor ( S, col, XCAFDoc_ColorCurv ))
967 SetColorToSubshape( CTool, S, col, XCAFDoc_ColorCurv );
970 // sets the invisibility for shape.
972 if ( CTool->ShapeTool()->Search( S, aInvL ) )
973 CTool->SetVisibility( aInvL, Standard_False );
976 CTool->ReverseChainsOfTreeNodes();
977 return Standard_True;
980 //=======================================================================
981 //function : GetLabelFromPD
983 //=======================================================================
985 static TDF_Label GetLabelFromPD (const Handle(StepBasic_ProductDefinition) &PD,
986 const Handle(XCAFDoc_ShapeTool) &STool,
987 const Handle(Transfer_TransientProcess) &TP,
988 const STEPCAFControl_DataMapOfPDExternFile &PDFileMap,
989 const XCAFDoc_DataMapOfShapeLabel &ShapeLabelMap)
992 if ( PDFileMap.IsBound ( PD ) ) {
993 Handle(STEPCAFControl_ExternFile) EF = PDFileMap.Find ( PD );
994 if ( ! EF.IsNull() ) {
996 if ( ! L.IsNull() ) return L;
1001 Handle(Transfer_Binder) binder = TP->Find(PD);
1002 if ( binder.IsNull() || ! binder->HasResult() ) return L;
1003 S = TransferBRep::ShapeResult ( TP, binder );
1004 if ( S.IsNull() ) return L;
1006 if ( S.IsNull() ) return L;
1007 if ( ShapeLabelMap.IsBound ( S ) )
1008 L = ShapeLabelMap.Find ( S );
1010 STool->Search ( S, L, Standard_True, Standard_True, Standard_False );
1014 //=======================================================================
1015 //function : FindInstance
1017 //=======================================================================
1019 TDF_Label STEPCAFControl_Reader::FindInstance (const Handle(StepRepr_NextAssemblyUsageOccurrence) &NAUO,
1020 const Handle(XCAFDoc_ShapeTool) &STool,
1021 const STEPConstruct_Tool &Tool,
1022 const STEPCAFControl_DataMapOfPDExternFile &PDFileMap,
1023 const XCAFDoc_DataMapOfShapeLabel &ShapeLabelMap)
1027 // get shape resulting from CDSR (in fact, only location is interesting)
1028 Handle(Transfer_TransientProcess) TP = Tool.TransientProcess();
1029 Handle(Transfer_Binder) binder = TP->Find(NAUO);
1030 if ( binder.IsNull() || ! binder->HasResult() ) {
1032 cout << "Error: STEPCAFControl_Reader::FindInstance: NAUO is not mapped to shape" << endl;
1037 TopoDS_Shape S = TransferBRep::ShapeResult ( TP, binder );
1040 cout << "Error: STEPCAFControl_Reader::FindInstance: NAUO is not mapped to shape" << endl;
1045 // find component`s original label
1046 Handle(StepBasic_ProductDefinition) PD = NAUO->RelatedProductDefinition();
1047 if ( PD.IsNull() ) return L;
1048 TDF_Label Lref = GetLabelFromPD ( PD, STool, TP, PDFileMap, ShapeLabelMap );
1049 if ( Lref.IsNull() ) return L;
1051 // find main shape (assembly) label
1053 PD = NAUO->RelatingProductDefinition();
1054 if ( PD.IsNull() ) return L;
1055 TDF_Label L0 = GetLabelFromPD ( PD, STool, TP, PDFileMap, ShapeLabelMap );
1056 if ( L0.IsNull() ) return L;
1058 // if CDSR and NAUO are reversed, swap labels
1059 Handle(StepShape_ContextDependentShapeRepresentation) CDSR;
1060 Interface_EntityIterator subs1 = Tool.Graph().Sharings(NAUO);
1061 for (subs1.Start(); subs1.More(); subs1.Next()) {
1062 Handle(StepRepr_ProductDefinitionShape) PDS =
1063 Handle(StepRepr_ProductDefinitionShape)::DownCast(subs1.Value());
1064 if(PDS.IsNull()) continue;
1065 Interface_EntityIterator subs2 = Tool.Graph().Sharings(PDS);
1066 for (subs2.Start(); subs2.More(); subs2.Next()) {
1067 Handle(StepShape_ContextDependentShapeRepresentation) CDSRtmp =
1068 Handle(StepShape_ContextDependentShapeRepresentation)::DownCast(subs2.Value());
1069 if (CDSRtmp.IsNull()) continue;
1073 if (CDSR.IsNull()) return L;
1074 // if ( STEPConstruct_Assembly::CheckSRRReversesNAUO ( Tool.Model(), CDSR ) ) {
1075 // TDF_Label Lsw = L0; L0 = Lref; Lref = Lsw;
1078 // iterate on components to find proper one
1079 TDF_LabelSequence seq;
1080 XCAFDoc_ShapeTool::GetComponents ( L0, seq );
1081 for ( Standard_Integer k=1; L.IsNull() && k <= seq.Length(); k++ ) {
1082 TDF_Label Lcomp = seq(k), Lref2;
1083 if ( XCAFDoc_ShapeTool::GetReferredShape ( Lcomp, Lref2 ) &&
1085 S.Location() == XCAFDoc_ShapeTool::GetLocation ( Lcomp ) )
1092 //=======================================================================
1093 //function : ReadNames
1095 //=======================================================================
1097 Standard_Boolean STEPCAFControl_Reader::ReadNames (const Handle(XSControl_WorkSession) &WS,
1098 Handle(TDocStd_Document)& Doc,
1099 const STEPCAFControl_DataMapOfPDExternFile &PDFileMap,
1100 const XCAFDoc_DataMapOfShapeLabel &ShapeLabelMap) const
1102 // get starting data
1103 Handle(Interface_InterfaceModel) Model = WS->Model();
1104 Handle(XSControl_TransferReader) TR = WS->TransferReader();
1105 Handle(Transfer_TransientProcess) TP = TR->TransientProcess();
1106 Handle(XCAFDoc_ShapeTool) STool = XCAFDoc_DocumentTool::ShapeTool( Doc->Main() );
1107 if ( STool.IsNull() ) return Standard_False;
1108 STEPConstruct_Tool Tool ( WS );
1110 // iterate on model to find all SDRs and CDSRs
1111 Standard_Integer nb = Model->NbEntities();
1112 Handle(Standard_Type) tNAUO = STANDARD_TYPE(StepRepr_NextAssemblyUsageOccurrence);
1113 Handle(Standard_Type) tPD = STANDARD_TYPE(StepBasic_ProductDefinition);
1114 Handle(TCollection_HAsciiString) name;
1116 for (Standard_Integer i = 1; i <= nb; i++) {
1117 Handle(Standard_Transient) enti = Model->Value(i);
1119 // get description of NAUO
1120 if ( enti->DynamicType() == tNAUO ) {
1122 Handle(StepRepr_NextAssemblyUsageOccurrence) NAUO =
1123 Handle(StepRepr_NextAssemblyUsageOccurrence)::DownCast(enti);
1124 if(NAUO.IsNull()) continue;
1125 Interface_EntityIterator subs = WS->Graph().Sharings(NAUO);
1126 for (subs.Start(); subs.More(); subs.Next()) {
1127 Handle(StepRepr_ProductDefinitionShape) PDS =
1128 Handle(StepRepr_ProductDefinitionShape)::DownCast(subs.Value());
1129 if(PDS.IsNull()) continue;
1130 Handle(StepBasic_ProductDefinitionRelationship) PDR = PDS->Definition().ProductDefinitionRelationship();
1131 if ( PDR.IsNull() ) continue;
1132 if ( PDR->HasDescription() &&
1133 PDR->Description()->Length() >0 ) name = PDR->Description();
1134 else if ( !PDR->Name().IsNull() && PDR->Name()->Length() >0 ) name = PDR->Name();
1135 else if ( !PDR->Id().IsNull()) name = PDR->Id();
1136 else name = new TCollection_HAsciiString;
1138 // find proper label
1139 L = FindInstance ( NAUO, STool, Tool, PDFileMap, ShapeLabelMap );
1140 if ( L.IsNull() ) continue;
1141 TCollection_ExtendedString str ( name->String() );
1142 TDataStd_Name::Set ( L, str );
1145 // for PD get name of associated product
1146 if ( enti->DynamicType() == tPD ) {
1148 Handle(StepBasic_ProductDefinition) PD =
1149 Handle(StepBasic_ProductDefinition)::DownCast(enti);
1150 if(PD.IsNull()) continue;
1151 Handle(StepBasic_Product) Prod = (!PD->Formation().IsNull() ? PD->Formation()->OfProduct() : NULL);
1153 name = new TCollection_HAsciiString;
1154 else if (!Prod->Name().IsNull() && Prod->Name()->UsefullLength() > 0)
1155 name = Prod->Name();
1156 else if (!Prod->Id().IsNull())
1159 name = new TCollection_HAsciiString;
1160 L = GetLabelFromPD ( PD, STool, TP, PDFileMap, ShapeLabelMap );
1161 if ( L.IsNull() ) continue;
1162 TCollection_ExtendedString str ( name->String() );
1163 TDataStd_Name::Set ( L, str );
1165 // set a name to the document
1166 //TCollection_ExtendedString str ( name->String() );
1167 //TDataStd_Name::Set ( L, str );
1170 return Standard_True;
1173 //=======================================================================
1174 //function : GetLabelFromPD
1176 //=======================================================================
1178 static TDF_Label GetLabelFromPD (const Handle(StepBasic_ProductDefinition) &PD,
1179 const Handle(XCAFDoc_ShapeTool) &STool,
1180 const STEPConstruct_ValidationProps &Props,
1181 const STEPCAFControl_DataMapOfPDExternFile &PDFileMap,
1182 const XCAFDoc_DataMapOfShapeLabel &ShapeLabelMap)
1185 if ( PDFileMap.IsBound ( PD ) ) {
1186 Handle(STEPCAFControl_ExternFile) EF = PDFileMap.Find ( PD );
1187 if ( ! EF.IsNull() ) {
1189 if ( ! L.IsNull() ) return L;
1192 TopoDS_Shape S = Props.GetPropShape ( PD );
1193 if ( S.IsNull() ) return L;
1194 if ( ShapeLabelMap.IsBound ( S ) )
1195 L = ShapeLabelMap.Find ( S );
1197 STool->Search ( S, L, Standard_True, Standard_True, Standard_False );
1201 //=======================================================================
1202 //function : ReadValProps
1204 //=======================================================================
1206 Standard_Boolean STEPCAFControl_Reader::ReadValProps (const Handle(XSControl_WorkSession) &WS,
1207 Handle(TDocStd_Document)& Doc,
1208 const STEPCAFControl_DataMapOfPDExternFile &PDFileMap,
1209 const XCAFDoc_DataMapOfShapeLabel &ShapeLabelMap) const
1211 // get starting data
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;
1218 // load props from the STEP model
1219 TColStd_SequenceOfTransient props;
1220 STEPConstruct_ValidationProps Props ( WS );
1221 if ( ! Props.LoadProps ( props ) ) {
1223 cout << "Warning: no validation props found in the model" << endl;
1225 return Standard_False;
1228 // interpret props one by one
1229 for (Standard_Integer i = 1; i <= props.Length(); i ++) {
1230 Handle(StepRepr_PropertyDefinitionRepresentation) PDR =
1231 Handle(StepRepr_PropertyDefinitionRepresentation)::DownCast ( props.Value(i) );
1232 if ( PDR.IsNull() ) continue;
1236 Handle(StepRepr_PropertyDefinition) PD = PDR->Definition().PropertyDefinition();
1237 Interface_EntityIterator subs = Props.Graph().Shareds(PD);
1238 for (subs.Start(); L.IsNull() && subs.More(); subs.Next()) {
1239 if ( subs.Value()->IsKind(STANDARD_TYPE(StepRepr_ProductDefinitionShape)) ) {
1240 Handle(StepRepr_ProductDefinitionShape) PDS = Handle(StepRepr_ProductDefinitionShape)::DownCast(subs.Value());
1241 if(PDS.IsNull()) continue;
1242 // find corresponding NAUO
1243 Handle(StepRepr_NextAssemblyUsageOccurrence) NAUO;
1244 Interface_EntityIterator subs1 = Props.Graph().Shareds(PDS);
1245 for (subs1.Start(); NAUO.IsNull() && subs1.More(); subs1.Next()) {
1246 if ( subs1.Value()->IsKind(STANDARD_TYPE(StepRepr_NextAssemblyUsageOccurrence)) )
1247 NAUO = Handle(StepRepr_NextAssemblyUsageOccurrence)::DownCast(subs1.Value());
1249 if ( !NAUO.IsNull() ) {
1250 L = FindInstance ( NAUO, STool, WS, PDFileMap, ShapeLabelMap );
1251 if ( L.IsNull() ) continue;
1254 // find corresponding ProductDefinition:
1255 Handle(StepBasic_ProductDefinition) ProdDef;
1256 Interface_EntityIterator subsPDS = Props.Graph().Shareds(PDS);
1257 for (subsPDS.Start(); ProdDef.IsNull() && subsPDS.More(); subsPDS.Next()) {
1258 if ( subsPDS.Value()->IsKind(STANDARD_TYPE(StepBasic_ProductDefinition)) )
1259 ProdDef = Handle(StepBasic_ProductDefinition)::DownCast(subsPDS.Value());
1261 if ( ProdDef.IsNull() ) continue;
1262 L = GetLabelFromPD ( ProdDef, STool, Props, PDFileMap, ShapeLabelMap );
1266 if ( subs.Value()->IsKind(STANDARD_TYPE(StepRepr_ShapeAspect)) ) {
1267 Handle(StepRepr_ShapeAspect) SA = Handle(StepRepr_ShapeAspect)::DownCast(subs.Value());
1268 if(SA.IsNull()) continue;
1269 // find ShapeRepresentation
1270 Handle(StepShape_ShapeRepresentation) SR;
1271 Interface_EntityIterator subs1 = Props.Graph().Sharings(SA);
1272 for(subs1.Start(); subs1.More() && SR.IsNull(); subs1.Next()) {
1273 Handle(StepRepr_PropertyDefinition) PropD1 =
1274 Handle(StepRepr_PropertyDefinition)::DownCast(subs1.Value());
1275 if(PropD1.IsNull()) continue;
1276 Interface_EntityIterator subs2 = Props.Graph().Sharings(PropD1);
1277 for(subs2.Start(); subs2.More() && SR.IsNull(); subs2.Next()) {
1278 Handle(StepShape_ShapeDefinitionRepresentation) SDR =
1279 Handle(StepShape_ShapeDefinitionRepresentation)::DownCast(subs2.Value());
1280 if(SDR.IsNull()) continue;
1281 SR = Handle(StepShape_ShapeRepresentation)::DownCast(SDR->UsedRepresentation());
1284 if(SR.IsNull()) continue;
1285 Handle(Transfer_Binder) binder;
1286 for(Standard_Integer ir=1; ir<=SR->NbItems() && binder.IsNull(); ir++) {
1287 if(SR->ItemsValue(ir)->IsKind(STANDARD_TYPE(StepShape_SolidModel))) {
1288 Handle(StepShape_SolidModel) SM =
1289 Handle(StepShape_SolidModel)::DownCast(SR->ItemsValue(ir));
1290 binder = TP->Find(SM);
1292 else if(SR->ItemsValue(ir)->IsKind(STANDARD_TYPE(StepShape_ShellBasedSurfaceModel))) {
1293 Handle(StepShape_ShellBasedSurfaceModel) SBSM =
1294 Handle(StepShape_ShellBasedSurfaceModel)::DownCast(SR->ItemsValue(ir));
1295 binder = TP->Find(SBSM);
1297 else if(SR->ItemsValue(ir)->IsKind(STANDARD_TYPE(StepShape_GeometricSet))) {
1298 Handle(StepShape_GeometricSet) GS =
1299 Handle(StepShape_GeometricSet)::DownCast(SR->ItemsValue(ir));
1300 binder = TP->Find(GS);
1303 if ( binder.IsNull() || ! binder->HasResult() ) continue;
1305 S = TransferBRep::ShapeResult ( TP, binder );
1306 if(S.IsNull()) continue;
1307 if ( ShapeLabelMap.IsBound ( S ) )
1308 L = ShapeLabelMap.Find ( S );
1310 STool->Search ( S, L, Standard_True, Standard_True, Standard_True );
1314 if(L.IsNull()) continue;
1316 // decode validation properties
1317 Handle(StepRepr_Representation) rep = PDR->UsedRepresentation();
1318 for ( Standard_Integer j=1; j <= rep->NbItems(); j++ ) {
1319 Handle(StepRepr_RepresentationItem) ent = rep->ItemsValue(j);
1320 Standard_Boolean isArea;
1323 if ( Props.GetPropReal ( ent, val, isArea ) ) {
1324 if ( isArea ) XCAFDoc_Area::Set ( L, val );
1325 else XCAFDoc_Volume::Set ( L, val );
1327 else if ( Props.GetPropPnt ( ent, rep->ContextOfItems(), pos ) ) {
1328 XCAFDoc_Centroid::Set ( L, pos );
1332 return Standard_True;
1335 //=======================================================================
1336 //function : ReadLayers
1338 //=======================================================================
1340 Standard_Boolean STEPCAFControl_Reader::ReadLayers (const Handle(XSControl_WorkSession) &WS,
1341 Handle(TDocStd_Document)& Doc) const
1343 Handle(Interface_InterfaceModel) Model = WS->Model();
1344 Handle(XSControl_TransferReader) TR = WS->TransferReader();
1345 Handle(Transfer_TransientProcess) TP = TR->TransientProcess();
1346 Handle(XCAFDoc_ShapeTool) STool = XCAFDoc_DocumentTool::ShapeTool( Doc->Main() );
1347 if ( STool.IsNull() ) return Standard_False;
1348 Handle(XCAFDoc_LayerTool) LTool = XCAFDoc_DocumentTool::LayerTool( Doc->Main() );
1349 if ( LTool.IsNull() ) return Standard_False;
1351 Handle(Standard_Type) tSVPLA = STANDARD_TYPE(StepVisual_PresentationLayerAssignment);
1352 Standard_Integer nb = Model->NbEntities();
1353 Handle(TCollection_HAsciiString) name;
1355 for (Standard_Integer i = 1; i <= nb; i ++) {
1356 Handle(Standard_Transient) enti = Model->Value(i);
1357 if ( ! enti->IsKind ( tSVPLA ) ) continue;
1358 Handle(StepVisual_PresentationLayerAssignment) SVPLA =
1359 Handle(StepVisual_PresentationLayerAssignment)::DownCast(enti);
1361 Handle(TCollection_HAsciiString) descr = SVPLA->Description();
1362 Handle(TCollection_HAsciiString) hName = SVPLA->Name();
1363 TCollection_ExtendedString aLayerName ( hName->String() );
1365 // find a target shape and its label in the document
1366 for (Standard_Integer j = 1; j <= SVPLA->NbAssignedItems(); j++ ) {
1367 StepVisual_LayeredItem LI = SVPLA->AssignedItemsValue(j);
1368 Handle(Transfer_Binder) binder = TP->Find( LI.Value() );
1369 if ( binder.IsNull() || ! binder->HasResult() ) continue;
1371 TopoDS_Shape S = TransferBRep::ShapeResult ( TP, binder );
1372 if ( S.IsNull() ) continue;
1375 if ( ! STool->Search ( S, shL, Standard_True, Standard_True, Standard_True ) ) continue;
1376 LTool->SetLayer ( shL, aLayerName );
1379 // check invisibility
1380 Interface_EntityIterator subs = WS->Graph().Sharings(SVPLA);
1381 for (subs.Start(); subs.More(); subs.Next()) {
1382 if ( ! subs.Value()->IsKind(STANDARD_TYPE(StepVisual_Invisibility)) ) continue;
1384 cout<< "\tLayer \"" << aLayerName << "\" is invisible"<<endl;
1386 //TDF_Label InvLayerLab = LTool->FindLayer(aLayerName);
1387 TDF_Label InvLayerLab = LTool->AddLayer(aLayerName); //skl for OCC3926
1388 Handle(TDataStd_UAttribute) aUAttr;
1389 aUAttr->Set( InvLayerLab, XCAFDoc::InvisibleGUID() );
1392 return Standard_True;
1395 //=======================================================================
1396 //function : ReadSHUOs
1398 //=======================================================================
1400 static Standard_Boolean findNextSHUOlevel (const Handle(XSControl_WorkSession) &WS,
1401 const Handle(StepRepr_SpecifiedHigherUsageOccurrence)& SHUO,
1402 const Handle(XCAFDoc_ShapeTool)& STool,
1403 const STEPCAFControl_DataMapOfPDExternFile &PDFileMap,
1404 const XCAFDoc_DataMapOfShapeLabel &ShapeLabelMap,
1405 TDF_LabelSequence& aLabels)
1407 Interface_EntityIterator subs = WS->HGraph()->Graph().Sharings(SHUO);
1408 Handle(StepRepr_SpecifiedHigherUsageOccurrence) subSHUO;
1409 for (subs.Start(); subs.More(); subs.Next()) {
1410 if (subs.Value()->IsKind(STANDARD_TYPE(StepRepr_SpecifiedHigherUsageOccurrence))) {
1411 subSHUO = Handle(StepRepr_SpecifiedHigherUsageOccurrence)::DownCast(subs.Value());
1415 if (subSHUO.IsNull())
1416 return Standard_False;
1418 Handle(StepRepr_NextAssemblyUsageOccurrence) NUNAUO = subSHUO->NextUsage();
1419 if (NUNAUO.IsNull())
1420 return Standard_False;
1421 // Handle(Interface_InterfaceModel) Model = WS->Model();
1422 // Handle(XSControl_TransferReader) TR = WS->TransferReader();
1423 // Handle(Transfer_TransientProcess) TP = TR->TransientProcess();
1424 // Handle(Transfer_Binder) binder = TP->Find(NUNAUO);
1425 // if ( binder.IsNull() || ! binder->HasResult() )
1426 // return Standard_False;
1427 // TopoDS_Shape NUSh = TransferBRep::ShapeResult ( TP, binder );
1428 // get label of NAUO next level
1430 STEPConstruct_Tool Tool( WS );
1431 NULab = STEPCAFControl_Reader::FindInstance ( NUNAUO, STool, Tool, PDFileMap, ShapeLabelMap );
1432 // STool->Search(NUSh, NUlab);
1434 return Standard_False;
1435 aLabels.Append( NULab );
1436 // and check by recurse.
1437 findNextSHUOlevel( WS, subSHUO, STool, PDFileMap, ShapeLabelMap, aLabels );
1438 return Standard_True;
1442 //=======================================================================
1443 //function : setSHUOintoDoc
1444 //purpose : auxilary
1445 //=======================================================================
1446 static TDF_Label setSHUOintoDoc (const Handle(XSControl_WorkSession) &WS,
1447 const Handle(StepRepr_SpecifiedHigherUsageOccurrence)& SHUO,
1448 const Handle(XCAFDoc_ShapeTool)& STool,
1449 const STEPCAFControl_DataMapOfPDExternFile &PDFileMap,
1450 const XCAFDoc_DataMapOfShapeLabel &ShapeLabelMap)
1452 TDF_Label aMainLabel;
1453 // get upper usage NAUO from SHUO.
1454 Handle(StepRepr_NextAssemblyUsageOccurrence) UUNAUO =
1455 Handle(StepRepr_NextAssemblyUsageOccurrence)::DownCast(SHUO->UpperUsage());
1456 Handle(StepRepr_NextAssemblyUsageOccurrence) NUNAUO = SHUO->NextUsage();
1457 if ( UUNAUO.IsNull() || NUNAUO.IsNull() ) {
1459 cout << "Warning: " << __FILE__ <<": Upper_usage or Next_usage of styled SHUO is null. Skip it" << endl;
1463 // Handle(Interface_InterfaceModel) Model = WS->Model();
1464 // Handle(XSControl_TransferReader) TR = WS->TransferReader();
1465 // Handle(Transfer_TransientProcess) TP = TR->TransientProcess();
1466 // TopoDS_Shape UUSh, NUSh;
1467 // Handle(Transfer_Binder) binder = TP->Find(UUNAUO);
1468 // if ( binder.IsNull() || ! binder->HasResult() )
1469 // return aMainLabel;
1470 // UUSh = TransferBRep::ShapeResult ( TP, binder );
1471 // binder = TP->Find(NUNAUO);
1472 // if ( binder.IsNull() || ! binder->HasResult() )
1473 // return aMainLabel;
1474 // NUSh = TransferBRep::ShapeResult ( TP, binder );
1476 // get first labels for first SHUO attribute
1477 TDF_Label UULab, NULab;
1478 STEPConstruct_Tool Tool( WS );
1479 UULab = STEPCAFControl_Reader::FindInstance ( UUNAUO, STool, Tool, PDFileMap, ShapeLabelMap );
1480 NULab = STEPCAFControl_Reader::FindInstance ( NUNAUO, STool, Tool, PDFileMap, ShapeLabelMap );
1482 // STool->Search(UUSh, UULab);
1483 // STool->Search(NUSh, NULab);
1484 if (UULab.IsNull() || NULab.IsNull()) return aMainLabel;
1485 //create sequence fo labels to set SHUO structure into the document
1486 TDF_LabelSequence ShuoLabels;
1487 ShuoLabels.Append( UULab );
1488 ShuoLabels.Append( NULab );
1489 // add all other labels of sub SHUO entities
1490 findNextSHUOlevel( WS, SHUO, STool, PDFileMap, ShapeLabelMap, ShuoLabels );
1491 // last accord for SHUO
1492 Handle(XCAFDoc_GraphNode) anSHUOAttr;
1493 if ( STool->SetSHUO( ShuoLabels, anSHUOAttr ) )
1494 aMainLabel = anSHUOAttr->Label();
1500 //=======================================================================
1501 //function : ReadSHUOs
1503 //=======================================================================
1505 Standard_Boolean STEPCAFControl_Reader::ReadSHUOs (const Handle(XSControl_WorkSession) &WS,
1506 Handle(TDocStd_Document)& Doc,
1507 const STEPCAFControl_DataMapOfPDExternFile &PDFileMap,
1508 const XCAFDoc_DataMapOfShapeLabel &ShapeLabelMap) const
1510 // the big part code duplication from ReadColors.
1511 // It is possible to share this code functionality, just to decide how ???
1512 Handle(XCAFDoc_ColorTool) CTool = XCAFDoc_DocumentTool::ColorTool( Doc->Main() );
1513 Handle(XCAFDoc_ShapeTool) STool = CTool->ShapeTool();
1515 STEPConstruct_Styles Styles ( WS );
1516 if ( ! Styles.LoadStyles() ) {
1518 cout << "Warning: no styles are found in the model" << endl;
1520 return Standard_False;
1522 // searching for invisible items in the model
1523 Handle(TColStd_HSequenceOfTransient) aHSeqOfInvisStyle = new TColStd_HSequenceOfTransient;
1524 Styles.LoadInvisStyles( aHSeqOfInvisStyle );
1525 // parse and search for color attributes
1526 Standard_Integer nb = Styles.NbStyles();
1527 for ( Standard_Integer i=1; i <= nb; i++ ) {
1528 Handle(StepVisual_StyledItem) style = Styles.Style ( i );
1529 if ( style.IsNull() ) continue;
1531 Standard_Boolean IsVisible = Standard_True;
1532 // check the visibility of styled item.
1533 for (Standard_Integer si = 1; si <= aHSeqOfInvisStyle->Length(); si++ ) {
1534 if ( style != aHSeqOfInvisStyle->Value( si ) )
1536 // found that current style is invisible.
1538 cout << "Warning: item No " << i << "(" << style->Item()->DynamicType()->Name() << ") is invisible" << endl;
1540 IsVisible = Standard_False;
1544 Handle(StepVisual_Colour) SurfCol, BoundCol, CurveCol;
1545 // check if it is component style
1546 Standard_Boolean IsComponent = Standard_False;
1547 if ( ! Styles.GetColors ( style, SurfCol, BoundCol, CurveCol, IsComponent ) && IsVisible )
1551 Handle(StepShape_ShapeRepresentation) aSR;
1552 findStyledSR( style, aSR );
1553 // search for SR along model
1556 Interface_EntityIterator subs = WS->HGraph()->Graph().Sharings( aSR );
1557 Handle(StepShape_ShapeDefinitionRepresentation) aSDR;
1558 for (subs.Start(); subs.More(); subs.Next()) {
1559 aSDR = Handle(StepShape_ShapeDefinitionRepresentation)::DownCast(subs.Value());
1560 if ( aSDR.IsNull() )
1562 StepRepr_RepresentedDefinition aPDSselect = aSDR->Definition();
1563 Handle(StepRepr_ProductDefinitionShape) PDS =
1564 Handle(StepRepr_ProductDefinitionShape)::DownCast(aPDSselect.PropertyDefinition());
1567 StepRepr_CharacterizedDefinition aCharDef = PDS->Definition();
1568 Handle(StepRepr_SpecifiedHigherUsageOccurrence) SHUO =
1569 Handle(StepRepr_SpecifiedHigherUsageOccurrence)::DownCast(aCharDef.ProductDefinitionRelationship());
1570 if ( SHUO.IsNull() )
1573 // set the SHUO structure to the document
1574 TDF_Label aLabelForStyle = setSHUOintoDoc( WS, SHUO, STool, PDFileMap, ShapeLabelMap );
1575 if ( aLabelForStyle.IsNull() ) {
1577 cout << "Warning: " << __FILE__ <<": coudnot create SHUO structure in the document" << endl;
1581 // now set the style to the SHUO main label.
1582 if ( ! SurfCol.IsNull() ) {
1584 Styles.DecodeColor ( SurfCol, col );
1585 CTool->SetColor ( aLabelForStyle, col, XCAFDoc_ColorSurf );
1587 if ( ! BoundCol.IsNull() ) {
1589 Styles.DecodeColor ( BoundCol, col );
1590 CTool->SetColor ( aLabelForStyle, col, XCAFDoc_ColorCurv );
1592 if ( ! CurveCol.IsNull() ) {
1594 Styles.DecodeColor ( CurveCol, col );
1595 CTool->SetColor ( aLabelForStyle, col, XCAFDoc_ColorCurv );
1598 // sets the invisibility for shape.
1599 CTool->SetVisibility( aLabelForStyle, Standard_False );
1601 } // end search SHUO by SDR
1602 } // end iterates on styles
1604 return Standard_True;
1608 //=======================================================================
1609 //function : GetLengthConversionFactor
1611 //=======================================================================
1612 static Standard_Boolean GetLengthConversionFactor(Handle(StepBasic_NamedUnit)& NU,
1613 Standard_Real& afact)
1616 if( !NU->IsKind(STANDARD_TYPE(StepBasic_ConversionBasedUnitAndLengthUnit)) ) return Standard_False;
1617 Handle(StepBasic_ConversionBasedUnitAndLengthUnit) CBULU =
1618 Handle(StepBasic_ConversionBasedUnitAndLengthUnit)::DownCast(NU);
1619 Handle(StepBasic_MeasureWithUnit) MWUCBU = CBULU->ConversionFactor();
1620 afact = MWUCBU->ValueComponent();
1621 StepBasic_Unit anUnit2 = MWUCBU->UnitComponent();
1622 if(anUnit2.CaseNum(anUnit2.Value())==1) {
1623 Handle(StepBasic_NamedUnit) NU2 = anUnit2.NamedUnit();
1624 if(NU2->IsKind(STANDARD_TYPE(StepBasic_SiUnit))) {
1625 Handle(StepBasic_SiUnit) SU = Handle(StepBasic_SiUnit)::DownCast(NU2);
1626 if(SU->Name()==StepBasic_sunMetre) {
1628 afact *= STEPConstruct_UnitContext::ConvertSiPrefix (SU->Prefix());
1634 return Standard_True;
1638 //=======================================================================
1639 //function : GetAngleConversionFactor
1641 //=======================================================================
1642 static Standard_Boolean GetAngleConversionFactor(Handle(StepBasic_NamedUnit)& NU,
1643 Standard_Real& afact)
1646 if( !NU->IsKind(STANDARD_TYPE(StepBasic_ConversionBasedUnitAndPlaneAngleUnit)) ) return Standard_False;
1647 Handle(StepBasic_ConversionBasedUnitAndPlaneAngleUnit) CBULU =
1648 Handle(StepBasic_ConversionBasedUnitAndPlaneAngleUnit)::DownCast(NU);
1649 Handle(StepBasic_MeasureWithUnit) MWUCBU = CBULU->ConversionFactor();
1650 afact = MWUCBU->ValueComponent();
1651 StepBasic_Unit anUnit2 = MWUCBU->UnitComponent();
1652 if(anUnit2.CaseNum(anUnit2.Value())==1) {
1653 Handle(StepBasic_NamedUnit) NU2 = anUnit2.NamedUnit();
1654 if(NU2->IsKind(STANDARD_TYPE(StepBasic_SiUnit))) {
1655 Handle(StepBasic_SiUnit) SU = Handle(StepBasic_SiUnit)::DownCast(NU2);
1656 if(SU->Name()==StepBasic_sunRadian) {
1658 afact *= STEPConstruct_UnitContext::ConvertSiPrefix (SU->Prefix());
1659 // convert radian to deg
1664 return Standard_True;
1667 //=======================================================================
1668 //function : GetMassConversionFactor
1670 //=======================================================================
1671 static Standard_Boolean GetMassConversionFactor(Handle(StepBasic_NamedUnit)& NU,
1672 Standard_Real& afact)
1675 if( !NU->IsKind(STANDARD_TYPE(StepBasic_ConversionBasedUnitAndMassUnit)) ) return Standard_False;
1676 Handle(StepBasic_ConversionBasedUnitAndMassUnit) CBUMU =
1677 Handle(StepBasic_ConversionBasedUnitAndMassUnit)::DownCast(NU);
1678 Handle(StepBasic_MeasureWithUnit) MWUCBU = CBUMU->ConversionFactor();
1679 afact = MWUCBU->ValueComponent();
1680 StepBasic_Unit anUnit2 = MWUCBU->UnitComponent();
1681 if(anUnit2.CaseNum(anUnit2.Value())==1) {
1682 Handle(StepBasic_NamedUnit) NU2 = anUnit2.NamedUnit();
1683 if(NU2->IsKind(STANDARD_TYPE(StepBasic_SiUnit))) {
1684 Handle(StepBasic_SiUnit) SU = Handle(StepBasic_SiUnit)::DownCast(NU2);
1685 if(SU->Name()==StepBasic_sunGram) {
1687 afact *= STEPConstruct_UnitContext::ConvertSiPrefix (SU->Prefix());
1691 return Standard_True;
1695 //=======================================================================
1696 //function : ReadDatums
1697 //purpose : auxilary
1698 //=======================================================================
1699 static Standard_Boolean ReadDatums(const Handle(XCAFDoc_ShapeTool) &STool,
1700 const Handle(XCAFDoc_DimTolTool) &DGTTool,
1701 const Interface_Graph &graph,
1702 Handle(Transfer_TransientProcess) &TP,
1703 const TDF_Label TolerL,
1704 const Handle(StepDimTol_GeometricToleranceWithDatumReference) GTWDR)
1706 if(GTWDR.IsNull()) return Standard_False;
1707 Handle(StepDimTol_HArray1OfDatumReference) HADR = GTWDR->DatumSystem();
1708 if(HADR.IsNull()) return Standard_False;
1709 for(Standard_Integer idr=1; idr<=HADR->Length(); idr++) {
1710 Handle(StepDimTol_DatumReference) DR = HADR->Value(idr);
1711 Handle(StepDimTol_Datum) aDatum = DR->ReferencedDatum();
1712 if(aDatum.IsNull()) continue;
1713 Interface_EntityIterator subs4 = graph.Sharings(aDatum);
1714 for(subs4.Start(); subs4.More(); subs4.Next()) {
1715 Handle(StepRepr_ShapeAspectRelationship) SAR =
1716 Handle(StepRepr_ShapeAspectRelationship)::DownCast(subs4.Value());
1717 if(SAR.IsNull()) continue;
1718 Handle(StepDimTol_DatumFeature) DF =
1719 Handle(StepDimTol_DatumFeature)::DownCast(SAR->RelatingShapeAspect());
1720 if(DF.IsNull()) continue;
1721 Interface_EntityIterator subs5 = graph.Sharings(DF);
1722 Handle(StepRepr_PropertyDefinition) PropDef;
1723 for(subs5.Start(); subs5.More() && PropDef.IsNull(); subs5.Next()) {
1724 PropDef = Handle(StepRepr_PropertyDefinition)::DownCast(subs5.Value());
1726 if(PropDef.IsNull()) continue;
1727 Handle(StepShape_AdvancedFace) AF;
1728 subs5 = graph.Sharings(PropDef);
1729 for(subs5.Start(); subs5.More(); subs5.Next()) {
1730 Handle(StepShape_ShapeDefinitionRepresentation) SDR =
1731 Handle(StepShape_ShapeDefinitionRepresentation)::DownCast(subs5.Value());
1733 Handle(StepRepr_Representation) Repr = SDR->UsedRepresentation();
1734 if( !Repr.IsNull() && Repr->NbItems()>0 ) {
1735 Handle(StepRepr_RepresentationItem) RI = Repr->ItemsValue(1);
1736 AF = Handle(StepShape_AdvancedFace)::DownCast(RI);
1740 if(AF.IsNull()) return Standard_False;
1741 Standard_Integer index = TP->MapIndex(AF);
1744 Handle(Transfer_Binder) binder = TP->MapItem(index);
1745 aSh = TransferBRep::ShapeResult(binder);
1747 if(aSh.IsNull()) continue;
1749 if( !STool->Search(aSh, shL, Standard_True, Standard_True, Standard_True) ) continue;
1750 DGTTool->SetDatum(shL,TolerL,PropDef->Name(),PropDef->Description(),aDatum->Identification());
1753 return Standard_True;
1757 //=======================================================================
1758 //function : setDatumToXCAF
1760 //=======================================================================
1761 static Standard_Boolean setDatumToXCAF(const Handle(StepDimTol_Datum)& theDat,
1762 const TDF_Label theGDTL,
1763 const Standard_Integer thePositionCounter,
1764 const XCAFDimTolObjects_DatumModifiersSequence& aXCAFModifiers,
1765 const XCAFDimTolObjects_DatumModifWithValue aXCAFModifWithVal,
1766 const Standard_Real aModifValue,
1767 const Handle(TDocStd_Document)& theDoc,
1768 const Handle(XSControl_WorkSession)& theWS)
1770 Handle(XCAFDoc_ShapeTool) aSTool = XCAFDoc_DocumentTool::ShapeTool( theDoc->Main() );
1771 Handle(XCAFDoc_DimTolTool) aDGTTool = XCAFDoc_DocumentTool::DimTolTool( theDoc->Main() );
1772 Handle(XSControl_TransferReader) aTR = theWS->TransferReader();
1773 Handle(Transfer_TransientProcess) aTP = aTR->TransientProcess();
1774 const Interface_Graph& aGraph = aTP->Graph();
1775 Handle(XCAFDoc_Datum) aDat;
1777 Standard_Boolean aRefShapeIsFound = Standard_False;
1778 Standard_Boolean aFirstStep = Standard_True;
1779 Interface_EntityIterator anIterD = aGraph.Sharings(theDat);
1780 for(anIterD.Start(); anIterD.More(); anIterD.Next()) {
1781 Handle(StepRepr_ShapeAspectRelationship) aSAR =
1782 Handle(StepRepr_ShapeAspectRelationship)::DownCast(anIterD.Value());
1783 if(aSAR.IsNull()) continue;
1785 Handle(StepRepr_ShapeAspect) aSA = aSAR->RelatingShapeAspect();
1786 if (aSA.IsNull()) continue;
1787 Handle(StepAP242_GeometricItemSpecificUsage) aPGISU;
1788 if(aSA->IsKind(STANDARD_TYPE(StepRepr_CompShAspAndDatumFeatAndShAsp)))
1790 //processing for complex entity
1791 Interface_EntityIterator anIterC = aGraph.Sharings(aSA);
1792 for(anIterC.Start(); anIterC.More(); anIterC.Next()) {
1793 Handle(StepRepr_ShapeAspectRelationship) SAR =
1794 Handle(StepRepr_ShapeAspectRelationship)::DownCast(anIterC.Value());
1795 if(SAR.IsNull()) continue;
1796 Handle(StepRepr_ShapeAspect) aS = SAR->RelatedShapeAspect();
1797 if(aS.IsNull()) continue;
1798 Interface_EntityIterator anIterSA = aGraph.Sharings(aS);
1799 for(anIterSA.Start(); anIterSA.More() && aPGISU.IsNull(); anIterSA.Next()) {
1800 aPGISU = Handle(StepAP242_GeometricItemSpecificUsage)::DownCast(anIterSA.Value());
1802 if(!aPGISU.IsNull()){
1808 else if(aSA->IsKind(STANDARD_TYPE(StepDimTol_PlacedDatumTargetFeature)))
1810 //processing for datum target
1811 Interface_EntityIterator anIterDTF = aGraph.Sharings(aSA);
1812 for(anIterDTF.Start(); anIterDTF.More(); anIterDTF.Next()) {
1813 if(anIterDTF.Value()->IsKind(STANDARD_TYPE(StepRepr_FeatureForDatumTargetRelationship)))
1815 Handle(StepRepr_FeatureForDatumTargetRelationship) aFFDTR =
1816 Handle(StepRepr_FeatureForDatumTargetRelationship)::DownCast(anIterDTF.Value());
1817 Handle(StepRepr_ShapeAspect) aTmpSA = aFFDTR->RelatedShapeAspect();
1818 Interface_EntityIterator anIterDSWP = aGraph.Sharings(aTmpSA);
1819 for(anIterDSWP.Start(); anIterDSWP.More() && aPGISU.IsNull(); anIterDSWP.Next()) {
1820 aPGISU = Handle(StepAP242_GeometricItemSpecificUsage)::DownCast(anIterDSWP.Value());
1825 if (aSA.IsNull()) continue;
1826 Interface_EntityIterator anIterDSWP = aGraph.Sharings(aSA);
1827 for(anIterDSWP.Start(); anIterDSWP.More() && aPGISU.IsNull(); anIterDSWP.Next()) {
1828 aPGISU = Handle(StepAP242_GeometricItemSpecificUsage)::DownCast(anIterDSWP.Value());
1830 if(aPGISU.IsNull()) continue;
1831 // get representation item
1832 Handle(StepRepr_RepresentationItem) aRI;
1833 for(Standard_Integer i = 1 ; i <= aPGISU->NbIdentifiedItem() && aRI.IsNull(); i++)
1835 aRI = aPGISU->IdentifiedItemValue(i);
1837 if(aRI.IsNull()) continue;
1838 Standard_Integer index = aTP->MapIndex(aRI);
1841 Handle(Transfer_Binder) binder = aTP->MapItem(index);
1842 aSh = TransferBRep::ShapeResult(binder);
1844 if(aSh.IsNull()) continue;
1845 if( !aSTool->Search(aSh, aShL, Standard_True, Standard_True, Standard_True) ) continue;
1846 Handle(TDataStd_TreeNode) aNode;
1847 if(aFirstStep && aShL.FindAttribute(XCAFDoc::DatumRefGUID(),aNode) && aNode->HasFirst() &&
1848 aNode->First()->Label().FindAttribute(XCAFDoc_Datum::GetID(),aDat))
1850 //if datums already attached, not need add datum target
1851 aRefShapeIsFound = Standard_True;
1853 aFirstStep = Standard_False;
1854 Handle(XCAFDimTolObjects_DatumObject) aDatObj;
1855 if(aSA->IsKind(STANDARD_TYPE(StepDimTol_PlacedDatumTargetFeature)))
1857 if(!aRefShapeIsFound)
1859 //if datum targers not yet added
1860 TDF_Label aDatL = aDGTTool->AddDatum();
1861 aDat = XCAFDoc_Datum::Set(aDatL);
1862 aDGTTool->SetDatum(aShL, aDatL);
1863 aDatObj = aDat->GetObject();
1864 aDatObj->SetName(theDat->Identification());
1865 aDatObj->SetPosition (thePositionCounter);
1866 if(!aXCAFModifiers.IsEmpty())
1867 aDatObj->SetModifiers(aXCAFModifiers);
1868 if (aXCAFModifWithVal != XCAFDimTolObjects_DatumModifWithValue_None)
1869 aDatObj->SetModifierWithValue(aXCAFModifWithVal, aModifValue);
1870 aDGTTool->SetDatumToGeomTol(aDatL, theGDTL);
1871 Handle(StepDimTol_PlacedDatumTargetFeature) aPDTF = Handle(StepDimTol_PlacedDatumTargetFeature)::DownCast(aSA);
1872 if (aPDTF->TargetId()->IsIntegerValue())
1873 aDatObj->SetDatumTargetNumber(aPDTF->TargetId()->IntegerValue());
1875 aDatObj->SetDatumTargetNumber(0);
1876 aDatObj->IsDatumTarget(Standard_True);
1877 XCAFDimTolObjects_DatumTargetType aType;
1878 if(STEPCAFControl_GDTProperty::GetDatumTargetType(aSA->Description(),aType))
1880 aDatObj->SetDatumTargetType(aType);
1881 if(aType == XCAFDimTolObjects_DatumTargetType_Area)
1883 Interface_EntityIterator anIterDTF = aGraph.Shareds(aSA);
1884 for(anIterDTF.Start(); anIterDTF.More(); anIterDTF.Next()) {
1885 if(anIterDTF.Value()->IsKind(STANDARD_TYPE(StepAP242_GeometricItemSpecificUsage)))
1887 Handle(StepAP242_GeometricItemSpecificUsage) aGISU
1888 = Handle(StepAP242_GeometricItemSpecificUsage)::DownCast(anIterDSWP.Value());
1889 Handle(StepRepr_RepresentationItem) anItem;
1890 if(aPGISU->NbIdentifiedItem() > 0) {
1891 anItem = aPGISU->IdentifiedItemValue(1);
1893 if(anItem.IsNull()) continue;
1894 Standard_Integer anItemIndex = aTP->MapIndex(anItem);
1895 if(anItemIndex >0) {
1896 Handle(Transfer_Binder) binder = aTP->MapItem(anItemIndex);
1897 TopoDS_Shape anItemShape = TransferBRep::ShapeResult(binder);
1898 aDatObj->SetDatumTarget(anItemShape);
1905 Interface_EntityIterator anIterDTF = aGraph.Shareds(aSA);
1906 for(anIterDTF.Start(); anIterDTF.More(); anIterDTF.Next()) {
1907 if(anIterDTF.Value()->IsKind(STANDARD_TYPE(StepRepr_PropertyDefinition)))
1909 Interface_EntityIterator anIterPD = aGraph.Shareds(anIterDTF.Value());
1910 for(anIterPD.Start(); anIterPD.More(); anIterPD.Next()) {
1911 if(anIterPD.Value()->IsKind(STANDARD_TYPE(StepShape_ShapeDefinitionRepresentation)))
1913 Interface_EntityIterator anIterSDR = aGraph.Sharings(anIterPD.Value());
1914 for(anIterSDR.Start(); anIterSDR.More(); anIterSDR.Next()) {
1915 if(anIterSDR.Value()->IsKind(STANDARD_TYPE(StepShape_ShapeRepresentationWithParameters)))
1917 Handle(StepShape_ShapeRepresentationWithParameters) aSRWP
1918 = Handle(StepShape_ShapeRepresentationWithParameters)::DownCast(anIterSDR.Value());
1919 for(Standard_Integer r = aSRWP->Items()->Lower(); r <= aSRWP->Items()->Upper(); r++)
1921 if(aSRWP->ItemsValue(r)->IsKind(STANDARD_TYPE(StepGeom_Axis2Placement3d)))
1923 Handle(StepGeom_Axis2Placement3d) anAx
1924 = Handle(StepGeom_Axis2Placement3d)::DownCast(aSRWP->ItemsValue(r));
1925 Handle(TColStd_HArray1OfReal) aDirArr = anAx->Axis()->DirectionRatios();
1926 Handle(TColStd_HArray1OfReal) aDirRArr = anAx->RefDirection()->DirectionRatios();
1927 Handle(TColStd_HArray1OfReal) aLocArr = anAx->Location()->Coordinates();
1931 if(!aDirArr.IsNull() && aDirArr->Length() > 2 &&
1932 !aDirRArr.IsNull() && aDirRArr->Length() > 2 &&
1933 !aLocArr.IsNull() && aLocArr->Length() > 2)
1935 aDir.SetCoord(aDirArr->Lower(), aDirArr->Lower()+1, aDirArr->Lower()+2);
1936 aDirR.SetCoord(aDirRArr->Lower(), aDirRArr->Lower()+1, aDirRArr->Lower()+2);
1937 aPnt.SetCoord(aLocArr->Lower(), aLocArr->Lower()+1, aLocArr->Lower()+2);
1938 gp_Ax2 anA(aPnt, aDir, aDirR);
1939 aDatObj->SetDatumTargetAxis(anA);
1942 else if(aSRWP->ItemsValue(r)->IsKind(STANDARD_TYPE(StepRepr_ReprItemAndLengthMeasureWithUnit)))
1944 Handle(StepRepr_ReprItemAndLengthMeasureWithUnit) aM =
1945 Handle(StepRepr_ReprItemAndLengthMeasureWithUnit)::DownCast(aSRWP->ItemsValue(r));
1946 Standard_Real aVal = aM->GetMeasureWithUnit()->ValueComponent();
1947 StepBasic_Unit anUnit = aM->GetMeasureWithUnit()->UnitComponent();
1948 Standard_Real aFact=1.;
1949 if(anUnit.IsNull()) continue;
1950 if( !(anUnit.CaseNum(anUnit.Value())==1) ) continue;
1951 Handle(StepBasic_NamedUnit) NU = anUnit.NamedUnit();
1952 if(GetLengthConversionFactor(NU,aFact)) aVal=aVal*aFact;
1953 if(aM->Name()->String().IsEqual("target length") ||
1954 aM->Name()->String().IsEqual("target diameter"))
1955 aDatObj->SetDatumTargetLength(aVal);
1957 aDatObj->SetDatumTargetWidth(aVal);
1972 //processing for darum feature
1973 TDF_Label aDatL = aDGTTool->AddDatum();
1974 aDat = XCAFDoc_Datum::Set(aDatL);
1975 aDGTTool->SetDatum(aShL, aDatL);
1976 aDatObj = aDat->GetObject();
1977 aDatObj->SetName(theDat->Identification());
1978 aDatObj->SetPosition (thePositionCounter);
1979 if(!aXCAFModifiers.IsEmpty())
1980 aDatObj->SetModifiers(aXCAFModifiers);
1981 if (aXCAFModifWithVal != XCAFDimTolObjects_DatumModifWithValue_None)
1982 aDatObj->SetModifierWithValue(aXCAFModifWithVal, aModifValue);
1983 aDGTTool->SetDatumToGeomTol(aDatL, theGDTL);
1985 if(!aDatObj.IsNull())
1986 aDat->SetObject(aDatObj);
1988 return !aDat.IsNull();
1992 //=======================================================================
1993 //function : ReadDatums
1994 //purpose : auxilary
1995 //=======================================================================
1996 static Standard_Boolean readDatumsAP242(const Handle(Standard_Transient)& theEnt,
1997 const TDF_Label theGDTL,
1998 const Handle(TDocStd_Document)& theDoc,
1999 const Handle(XSControl_WorkSession)& theWS)
2001 Handle(XCAFDoc_ShapeTool) aSTool = XCAFDoc_DocumentTool::ShapeTool( theDoc->Main() );
2002 Handle(XCAFDoc_DimTolTool) aDGTTool = XCAFDoc_DocumentTool::DimTolTool( theDoc->Main() );
2003 Handle(XSControl_TransferReader) aTR = theWS->TransferReader();
2004 Handle(Transfer_TransientProcess) aTP = aTR->TransientProcess();
2005 const Interface_Graph& aGraph = aTP->Graph();
2007 Interface_EntityIterator anIter = aGraph.Shareds(theEnt);
2008 for(anIter.Start(); anIter.More(); anIter.Next()) {
2009 Handle(Standard_Transient) anAtr = anIter.Value();
2010 if(anAtr->IsKind(STANDARD_TYPE(StepDimTol_DatumSystem)))
2012 Standard_Integer aPositionCounter = 0;//position on frame
2013 Handle(StepDimTol_DatumSystem) aDS = Handle(StepDimTol_DatumSystem)::DownCast(anAtr);
2014 Interface_EntityIterator anIterDS = aGraph.Sharings(aDS);
2015 for(anIterDS.Start(); anIterDS.More(); anIterDS.Next()) {
2016 Handle(Standard_Transient) anAtrDS = anIterDS.Value();
2017 if(anAtrDS->IsKind(STANDARD_TYPE(StepAP242_GeometricItemSpecificUsage)))
2020 Handle(StepAP242_GeometricItemSpecificUsage)aAxGISUI
2021 = Handle(StepAP242_GeometricItemSpecificUsage)::DownCast(anAtrDS);
2022 if (aAxGISUI->IdentifiedItemValue(1)->IsKind(STANDARD_TYPE(StepGeom_Axis2Placement3d)))
2024 Handle(StepGeom_Axis2Placement3d) anAx
2025 = Handle(StepGeom_Axis2Placement3d)::DownCast(aAxGISUI->IdentifiedItemValue(1));
2026 Handle(XCAFDoc_GeomTolerance) aTol;
2027 if(theGDTL.FindAttribute(XCAFDoc_GeomTolerance::GetID(), aTol))
2029 Handle(XCAFDimTolObjects_GeomToleranceObject) anObj = aTol->GetObject();
2030 Handle(TColStd_HArray1OfReal) aDirArr = anAx->Axis()->DirectionRatios();
2031 Handle(TColStd_HArray1OfReal) aDirRArr = anAx->RefDirection()->DirectionRatios();
2032 Handle(TColStd_HArray1OfReal) aLocArr = anAx->Location()->Coordinates();
2036 if(!aDirArr.IsNull() && aDirArr->Length() > 2 &&
2037 !aDirRArr.IsNull() && aDirRArr->Length() > 2 &&
2038 !aLocArr.IsNull() && aLocArr->Length() > 2)
2040 aDir.SetCoord(aDirArr->Lower(), aDirArr->Lower()+1, aDirArr->Lower()+2);
2041 aDirR.SetCoord(aDirRArr->Lower(), aDirRArr->Lower()+1, aDirRArr->Lower()+2);
2042 aPnt.SetCoord(aLocArr->Lower(), aLocArr->Lower()+1, aLocArr->Lower()+2);
2043 gp_Ax2 anA(aPnt, aDir, aDirR);
2044 anObj->SetAxis(anA);
2045 aTol->SetObject(anObj);
2051 if (aDS->NbConstituents() > 0)
2053 //get datum feature and datum target from datum system
2054 Handle(StepDimTol_HArray1OfDatumReferenceCompartment) aDRCA = aDS->Constituents();
2057 for(Standard_Integer i = aDRCA->Lower(); i <= aDRCA->Upper(); i++)
2059 Handle(StepDimTol_DatumReferenceCompartment) aDRC = aDRCA->Value(i);
2061 Handle(StepDimTol_HArray1OfDatumReferenceModifier) aModif = aDRC->Modifiers();
2062 XCAFDimTolObjects_DatumModifiersSequence aXCAFModifiers;
2063 XCAFDimTolObjects_DatumModifWithValue aXCAFModifWithVal = XCAFDimTolObjects_DatumModifWithValue_None;
2064 Standard_Real aModifValue = 0;
2065 if(!aModif.IsNull())
2067 for(Standard_Integer m = aModif->Lower(); m <= aModif->Upper(); m++)
2069 if(aModif->Value(m).CaseNumber() == 2)
2070 aXCAFModifiers.Append(
2071 (XCAFDimTolObjects_DatumSingleModif)aModif->Value(m).
2072 SimpleDatumReferenceModifierMember()->Value());
2073 else if (aModif->Value(m).CaseNumber() == 1)
2075 aXCAFModifWithVal = (XCAFDimTolObjects_DatumModifWithValue)(aModif->Value(m).DatumReferenceModifierWithValue()->ModifierType() + 1);
2076 Standard_Real aVal = aModif->Value(m).DatumReferenceModifierWithValue()->ModifierValue()->ValueComponent();
2077 StepBasic_Unit anUnit = aModif->Value(m).DatumReferenceModifierWithValue()->ModifierValue()->UnitComponent();
2078 Standard_Real aFact=1.;
2079 if(anUnit.IsNull()) continue;
2080 if( !(anUnit.CaseNum(anUnit.Value())==1) ) continue;
2081 Handle(StepBasic_NamedUnit) NU = anUnit.NamedUnit();
2082 if(GetLengthConversionFactor(NU,aFact)) aVal=aVal*aFact;
2088 Interface_EntityIterator anIterDRC = aGraph.Shareds(aDRC);
2089 for(anIterDRC.Start(); anIterDRC.More(); anIterDRC.Next()) {
2091 if(anIterDRC.Value()->IsKind(STANDARD_TYPE(StepDimTol_Datum)))
2093 Handle(StepDimTol_Datum) aD = Handle(StepDimTol_Datum)::DownCast(anIterDRC.Value());
2094 setDatumToXCAF(aD, theGDTL, aPositionCounter, aXCAFModifiers, aXCAFModifWithVal, aModifValue,theDoc, theWS);
2096 else if(anIterDRC.Value()->IsKind(STANDARD_TYPE(StepDimTol_DatumReferenceElement)))
2098 Handle(StepDimTol_DatumReferenceElement) aDRE
2099 = Handle(StepDimTol_DatumReferenceElement)::DownCast(anIterDRC.Value());
2100 //get modifiers from group of datums
2101 Handle(StepDimTol_HArray1OfDatumReferenceModifier) aModifE = aDRE->Modifiers();
2102 if(!aModifE.IsNull())
2104 for(Standard_Integer k = aModifE->Lower(); k <= aModifE->Upper(); k++)
2106 if(aModifE->Value(k).CaseNumber() == 1)
2107 aXCAFModifiers.Append(
2108 (XCAFDimTolObjects_DatumSingleModif)aModifE->Value(k).
2109 SimpleDatumReferenceModifierMember()->Value());
2110 else if (aModifE->Value(k).CaseNumber() == 2)
2112 aXCAFModifWithVal = (XCAFDimTolObjects_DatumModifWithValue)(aModifE->Value(k).DatumReferenceModifierWithValue()->ModifierType() + 1);
2113 Standard_Real aVal = aModifE->Value(k).DatumReferenceModifierWithValue()->ModifierValue()->ValueComponent();
2114 StepBasic_Unit anUnit = aModifE->Value(k).DatumReferenceModifierWithValue()->ModifierValue()->UnitComponent();
2115 Standard_Real aFact=1.;
2116 if(anUnit.IsNull()) continue;
2117 if( !(anUnit.CaseNum(anUnit.Value())==1) ) continue;
2118 Handle(StepBasic_NamedUnit) NU = anUnit.NamedUnit();
2119 if(GetLengthConversionFactor(NU,aFact)) aVal=aVal*aFact;
2124 Interface_EntityIterator anIterDRE = aGraph.Shareds(aDRE);
2125 for(anIterDRE.Start(); anIterDRE.More(); anIterDRE.Next()) {
2126 if(anIterDRE.Value()->IsKind(STANDARD_TYPE(StepDimTol_Datum)))
2128 Handle(StepDimTol_Datum) aD = Handle(StepDimTol_Datum)::DownCast(anIterDRE.Value());
2129 setDatumToXCAF(aD, theGDTL, aPositionCounter, aXCAFModifiers, aXCAFModifWithVal, aModifValue,theDoc, theWS);
2139 return Standard_True;
2142 //=======================================================================
2143 //function : craeteGeomTolObjectInXCAF
2145 //=======================================================================
2146 static TDF_Label createGDTObjectInXCAF(const Handle(Standard_Transient)& theEnt,
2147 const Handle(TDocStd_Document)& theDoc,
2148 const Handle(XSControl_WorkSession)& theWS)
2151 if(!theEnt->IsKind(STANDARD_TYPE(StepShape_DimensionalSize)) &&
2152 !theEnt->IsKind(STANDARD_TYPE(StepShape_DimensionalLocation)) &&
2153 !theEnt->IsKind(STANDARD_TYPE(StepDimTol_GeometricTolerance)))
2158 Handle(XCAFDoc_ShapeTool) aSTool = XCAFDoc_DocumentTool::ShapeTool( theDoc->Main() );
2159 Handle(XCAFDoc_DimTolTool) aDGTTool = XCAFDoc_DocumentTool::DimTolTool( theDoc->Main() );
2160 Handle(XSControl_TransferReader) aTR = theWS->TransferReader();
2161 Handle(Transfer_TransientProcess) aTP = aTR->TransientProcess();
2162 const Interface_Graph& aGraph = aTP->Graph();
2163 Standard_Boolean isAllAround = Standard_False;
2164 Standard_Boolean isAllOver = Standard_False;
2166 // find RepresentationItem for current Ent
2167 NCollection_Sequence<Handle(Standard_Transient)> aSeqRI1, aSeqRI2;
2169 Interface_EntityIterator anIter = aGraph.Shareds(theEnt);
2170 for(anIter.Start(); anIter.More(); anIter.Next()) {
2171 Handle(Standard_Transient) anAtr = anIter.Value();
2172 NCollection_Sequence<Handle(StepRepr_ShapeAspect)> aSAs;
2173 if(anAtr->IsKind(STANDARD_TYPE(StepRepr_ProductDefinitionShape)))
2175 //if associating tolerances with part (All-Over)
2176 Interface_EntityIterator anIterSDR = aGraph.Sharings(anAtr);
2177 for(anIterSDR.Start(); anIterSDR.More(); anIterSDR.Next())
2179 Handle(Standard_Transient) anAtrSDR = anIterSDR.Value();
2180 if(anAtrSDR->IsKind(STANDARD_TYPE(StepShape_ShapeDefinitionRepresentation)))
2182 isAllOver = Standard_True;
2183 Interface_EntityIterator anIterABSR = aGraph.Shareds(anAtrSDR);
2184 for(anIterABSR.Start(); anIterABSR.More(); anIterABSR.Next())
2186 Handle(Standard_Transient) anAtrABSR = anIterABSR.Value();
2187 if(anAtrABSR->IsKind(STANDARD_TYPE(StepShape_AdvancedBrepShapeRepresentation)))
2189 aSeqRI1.Append(anAtrABSR);
2195 else if(anAtr->IsKind(STANDARD_TYPE(StepShape_DimensionalLocation)) ||
2196 anAtr->IsKind(STANDARD_TYPE(StepShape_DimensionalSize)))
2198 //if tolerance attached to dimension
2199 Interface_EntityIterator anIterDim = aGraph.Shareds(anAtr);
2200 for(anIterDim.Start(); anIterDim.More(); anIterDim.Next())
2202 Handle(Standard_Transient) anAtrDim = anIterDim.Value();
2203 if(anAtrDim->IsKind(STANDARD_TYPE(StepRepr_CompositeShapeAspect)) ||
2204 anAtrDim->IsKind(STANDARD_TYPE(StepRepr_CompShAspAndDatumFeatAndShAsp)))
2206 Interface_EntityIterator anIterCSA = aGraph.Sharings(anAtrDim);
2207 for(anIterCSA.Start(); anIterCSA.More(); anIterCSA.Next()) {
2208 if (anIterCSA.Value()->IsKind(STANDARD_TYPE(StepRepr_ShapeAspectRelationship))){
2209 Interface_EntityIterator anIterSAR = aGraph.Shareds(anIterCSA.Value());
2210 for(anIterSAR.Start(); anIterSAR.More(); anIterSAR.Next()) {
2211 if (anIterSAR.Value()->IsKind(STANDARD_TYPE(StepRepr_ShapeAspect))){
2212 aSAs.Append(Handle(StepRepr_ShapeAspect)::DownCast(anIterSAR.Value()));
2218 else if(anAtrDim->IsKind(STANDARD_TYPE(StepRepr_ShapeAspect)))
2220 aSAs.Append( Handle(StepRepr_ShapeAspect)::DownCast(anAtrDim));
2224 else if(anAtr->IsKind(STANDARD_TYPE(StepRepr_CompositeShapeAspect)) ||
2225 anAtr->IsKind(STANDARD_TYPE(StepRepr_CompShAspAndDatumFeatAndShAsp)))
2227 //processing for composite entity
2228 Handle(Standard_Transient) anAtrTmp = anAtr;
2229 if(anAtr->IsKind(STANDARD_TYPE(StepRepr_AllAroundShapeAspect)))
2231 // if applyed AllAround Modifier
2232 isAllAround = Standard_True;
2233 Interface_EntityIterator anIterAASA = aGraph.Sharings(anAtrTmp);
2234 for(anIterAASA.Start(); anIterAASA.More(); anIterAASA.Next()) {
2235 if (anIterAASA.Value()->IsKind(STANDARD_TYPE(StepRepr_ShapeAspectRelationship))){
2236 Interface_EntityIterator anIterSAR = aGraph.Shareds(anIterAASA.Value());
2237 for(anIterSAR.Start(); anIterSAR.More(); anIterSAR.Next()) {
2238 if ((anIterSAR.Value()->IsKind(STANDARD_TYPE(StepRepr_CompositeShapeAspect)) ||
2239 anIterSAR.Value()->IsKind(STANDARD_TYPE(StepRepr_CompShAspAndDatumFeatAndShAsp))) &&
2240 anAtrTmp != anIterSAR.Value()){
2241 anAtrTmp = anIterSAR.Value();
2248 Interface_EntityIterator anIterCSA = aGraph.Sharings(anAtrTmp);
2249 for(anIterCSA.Start(); anIterCSA.More(); anIterCSA.Next()) {
2250 if (anIterCSA.Value()->IsKind(STANDARD_TYPE(StepRepr_ShapeAspectRelationship))){
2251 Interface_EntityIterator anIterSAR = aGraph.Shareds(anIterCSA.Value());
2252 for(anIterSAR.Start(); anIterSAR.More(); anIterSAR.Next()) {
2253 if (anIterSAR.Value()->IsKind(STANDARD_TYPE(StepRepr_ShapeAspect))){
2254 aSAs.Append(Handle(StepRepr_ShapeAspect)::DownCast(anIterSAR.Value()));
2260 else if(anAtr->IsKind(STANDARD_TYPE(StepRepr_ShapeAspect)))
2263 aSAs.Append( Handle(StepRepr_ShapeAspect)::DownCast(anAtr));
2267 //get representation items
2268 NCollection_Sequence<Handle(Standard_Transient)> aSeqRI;
2269 for(Standard_Integer i = aSAs.Lower(); i <= aSAs.Upper(); i++)
2271 Interface_EntityIterator anIterSA = aGraph.Sharings(aSAs.Value(i));
2272 Handle(StepAP242_GeometricItemSpecificUsage) aGISU;
2273 Handle(StepRepr_PropertyDefinition) PropD;
2274 for(anIterSA.Start(); anIterSA.More() && aGISU.IsNull() && PropD.IsNull(); anIterSA.Next()) {
2275 aGISU = Handle(StepAP242_GeometricItemSpecificUsage)::DownCast(anIterSA.Value());
2276 PropD = Handle(StepRepr_PropertyDefinition)::DownCast(anIterSA.Value());
2278 if(!PropD.IsNull())//for old version
2280 Handle(StepRepr_RepresentationItem) RI;
2281 Interface_EntityIterator subs4 = aGraph.Sharings(PropD);
2282 for(subs4.Start(); subs4.More(); subs4.Next()) {
2283 Handle(StepShape_ShapeDefinitionRepresentation) SDR =
2284 Handle(StepShape_ShapeDefinitionRepresentation)::DownCast(subs4.Value());
2286 Handle(StepRepr_Representation) Repr = SDR->UsedRepresentation();
2287 if( !Repr.IsNull() && Repr->NbItems()>0 ) {
2288 RI = Repr->ItemsValue(1);
2292 if(RI.IsNull()) continue;
2294 if(theEnt->IsKind(STANDARD_TYPE(StepShape_DimensionalSize))) {
2296 Handle(StepShape_EdgeCurve) EC = Handle(StepShape_EdgeCurve)::DownCast(RI);
2297 if(EC.IsNull()) continue;
2298 Handle(TCollection_HAsciiString) aName;
2299 Handle(StepShape_DimensionalSize) DimSize =
2300 Handle(StepShape_DimensionalSize)::DownCast(theEnt);
2301 Standard_Real dim1=-1.,dim2=-1.;
2302 subs4 = aGraph.Sharings(DimSize);
2303 for(subs4.Start(); subs4.More(); subs4.Next()) {
2304 Handle(StepShape_DimensionalCharacteristicRepresentation) DimCharR =
2305 Handle(StepShape_DimensionalCharacteristicRepresentation)::DownCast(subs4.Value());
2306 if(!DimCharR.IsNull()) {
2307 Handle(StepShape_ShapeDimensionRepresentation) SDimR = DimCharR->Representation();
2308 if(!SDimR.IsNull() && SDimR->NbItems()>0) {
2309 Handle(StepRepr_RepresentationItem) anItem = SDimR->ItemsValue(1);
2310 Handle(StepRepr_ValueRange) VR = Handle(StepRepr_ValueRange)::DownCast(anItem);
2313 //StepRepr_CompoundItemDefinition CID = VR->ItemElement();
2314 //if(CID.IsNull()) continue;
2315 //Handle(StepRepr_CompoundItemDefinitionMember) CIDM =
2316 // Handle(StepRepr_CompoundItemDefinitionMember)::DownCast(CID.Value());
2317 //if(CIDM.IsNull()) continue;
2318 //if(CIDM->ArrTransient().IsNull()) continue;
2319 //Handle(StepRepr_HArray1OfRepresentationItem) HARI;
2320 //if(CID.CaseMem(CIDM)==1)
2321 // HARI = CID.ListRepresentationItem();
2322 //if(CID.CaseMem(CIDM)==2)
2323 // HARI = CID.SetRepresentationItem();
2324 Handle(StepRepr_HArray1OfRepresentationItem) HARI = VR->ItemElement();
2325 if(HARI.IsNull()) continue;
2326 if(HARI->Length()>0) {
2327 Handle(StepRepr_RepresentationItem) RI1 = HARI->Value(1);
2328 if(RI1.IsNull()) continue;
2329 if(RI1->IsKind(STANDARD_TYPE(StepRepr_ReprItemAndLengthMeasureWithUnit))) {
2330 Handle(StepRepr_ReprItemAndLengthMeasureWithUnit) RILMWU =
2331 Handle(StepRepr_ReprItemAndLengthMeasureWithUnit)::DownCast(RI1);
2332 dim1 = RILMWU->GetMeasureWithUnit()->ValueComponent();
2333 StepBasic_Unit anUnit = RILMWU->GetMeasureWithUnit()->UnitComponent();
2334 Standard_Real afact=1.;
2335 if(anUnit.IsNull()) continue;
2336 if( !(anUnit.CaseNum(anUnit.Value())==1) ) continue;
2337 Handle(StepBasic_NamedUnit) NU = anUnit.NamedUnit();
2338 if(GetLengthConversionFactor(NU,afact)) dim1=dim1*afact;
2341 if(HARI->Length()>1) {
2342 Handle(StepRepr_RepresentationItem) RI2 = HARI->Value(2);
2343 if(RI2.IsNull()) continue;
2344 if(RI2->IsKind(STANDARD_TYPE(StepRepr_ReprItemAndLengthMeasureWithUnit))) {
2345 Handle(StepRepr_ReprItemAndLengthMeasureWithUnit) RILMWU =
2346 Handle(StepRepr_ReprItemAndLengthMeasureWithUnit)::DownCast(RI2);
2347 dim2 = RILMWU->GetMeasureWithUnit()->ValueComponent();
2348 StepBasic_Unit anUnit = RILMWU->GetMeasureWithUnit()->UnitComponent();
2349 Standard_Real afact=1.;
2350 if(anUnit.IsNull()) continue;
2351 if( !(anUnit.CaseNum(anUnit.Value())==1) ) continue;
2352 Handle(StepBasic_NamedUnit) NU = anUnit.NamedUnit();
2353 if(GetLengthConversionFactor(NU,afact)) dim2 = dim2*afact;
2360 if(dim1<0) continue;
2361 if(dim2<0) dim2=dim1;
2362 //cout<<"DimensionalSize: dim1="<<dim1<<" dim2="<<dim2<<endl;
2363 // now we know edge_curve and value range therefore
2364 // we can create corresponding D> labels
2365 Standard_Integer index = aTP->MapIndex(EC);
2368 Handle(Transfer_Binder) binder = aTP->MapItem(index);
2369 aSh = TransferBRep::ShapeResult(binder);
2371 if(aSh.IsNull()) continue;
2373 if( !aSTool->Search(aSh, shL, Standard_True, Standard_True, Standard_True) ) continue;
2374 Handle(TColStd_HArray1OfReal) arr = new TColStd_HArray1OfReal(1,2);
2375 arr->SetValue(1,dim1);
2376 arr->SetValue(2,dim2);
2377 aDGTTool->SetDimTol(shL,1,arr,aName,DimSize->Name());
2379 // read tolerances and datums
2380 else if(theEnt->IsKind(STANDARD_TYPE(StepDimTol_GeometricTolerance))) {
2381 Handle(StepDimTol_GeometricTolerance) GT =
2382 Handle(StepDimTol_GeometricTolerance)::DownCast(theEnt);
2383 // read common data for tolerance
2384 //Standard_Real dim = GT->Magnitude()->ValueComponent();
2385 Handle (StepBasic_MeasureWithUnit) dim3 = GT->Magnitude();
2386 if(dim3.IsNull()) continue;
2387 Standard_Real dim = dim3->ValueComponent();
2388 StepBasic_Unit anUnit = GT->Magnitude()->UnitComponent();
2389 Standard_Real afact=1.;
2390 if(anUnit.IsNull()) continue;
2391 if( !(anUnit.CaseNum(anUnit.Value())==1) ) continue;
2392 Handle(StepBasic_NamedUnit) NU = anUnit.NamedUnit();
2393 if(GetLengthConversionFactor(NU,afact)) dim = dim*afact;
2394 //cout<<"GeometricTolerance: Magnitude = "<<dim<<endl;
2395 Handle(TColStd_HArray1OfReal) arr = new TColStd_HArray1OfReal(1,1);
2396 arr->SetValue(1,dim);
2397 Handle(TCollection_HAsciiString) aName = GT->Name();
2398 Handle(TCollection_HAsciiString) aDescription = GT->Description();
2399 Handle(StepShape_AdvancedFace) AF = Handle(StepShape_AdvancedFace)::DownCast(RI);
2400 if(AF.IsNull()) continue;
2401 Standard_Integer index = aTP->MapIndex(AF);
2404 Handle(Transfer_Binder) binder = aTP->MapItem(index);
2405 aSh = TransferBRep::ShapeResult(binder);
2407 if(aSh.IsNull()) continue;
2409 if( !aSTool->Search(aSh, shL, Standard_True, Standard_True, Standard_True) ) continue;
2410 // read specific data for tolerance
2411 if(GT->IsKind(STANDARD_TYPE(StepDimTol_GeoTolAndGeoTolWthDatRefAndModGeoTolAndPosTol))) {
2412 Handle(StepDimTol_GeoTolAndGeoTolWthDatRefAndModGeoTolAndPosTol) GTComplex =
2413 Handle(StepDimTol_GeoTolAndGeoTolWthDatRefAndModGeoTolAndPosTol)::DownCast(theEnt);
2414 Standard_Integer kind=20;
2415 Handle(StepDimTol_ModifiedGeometricTolerance) MGT =
2416 GTComplex->GetModifiedGeometricTolerance();
2418 kind = kind + MGT->Modifier()+1;
2420 TDF_Label TolerL = aDGTTool->SetDimTol(shL,kind,arr,aName,aDescription);
2421 // translate datums connected with this tolerance
2422 Handle(StepDimTol_GeometricToleranceWithDatumReference) GTWDR =
2423 GTComplex->GetGeometricToleranceWithDatumReference();
2424 if(!GTWDR.IsNull()) {
2425 ReadDatums(aSTool,aDGTTool,aGraph,aTP,TolerL,GTWDR);
2428 else if(GT->IsKind(STANDARD_TYPE(StepDimTol_GeometricToleranceWithDatumReference))) {
2429 Handle(StepDimTol_GeometricToleranceWithDatumReference) GTWDR =
2430 Handle(StepDimTol_GeometricToleranceWithDatumReference)::DownCast(theEnt);
2431 if(GTWDR.IsNull()) continue;
2432 Standard_Integer kind = 0;
2433 if (GTWDR->IsKind(STANDARD_TYPE(StepDimTol_AngularityTolerance))) kind = 24;
2434 else if(GTWDR->IsKind(STANDARD_TYPE(StepDimTol_CircularRunoutTolerance))) kind = 25;
2435 else if(GTWDR->IsKind(STANDARD_TYPE(StepDimTol_CoaxialityTolerance))) kind = 26;
2436 else if(GTWDR->IsKind(STANDARD_TYPE(StepDimTol_ConcentricityTolerance))) kind = 27;
2437 else if(GTWDR->IsKind(STANDARD_TYPE(StepDimTol_ParallelismTolerance))) kind = 28;
2438 else if(GTWDR->IsKind(STANDARD_TYPE(StepDimTol_PerpendicularityTolerance))) kind = 29;
2439 else if(GTWDR->IsKind(STANDARD_TYPE(StepDimTol_SymmetryTolerance))) kind = 30;
2440 else if(GTWDR->IsKind(STANDARD_TYPE(StepDimTol_TotalRunoutTolerance))) kind = 31;
2441 //cout<<"GTWDR: kind="<<kind<<endl;
2442 TDF_Label TolerL = aDGTTool->SetDimTol(shL,kind,arr,aName,aDescription);
2443 ReadDatums(aSTool,aDGTTool,aGraph,aTP,TolerL,GTWDR);
2445 else if(GT->IsKind(STANDARD_TYPE(StepDimTol_ModifiedGeometricTolerance))) {
2446 Handle(StepDimTol_ModifiedGeometricTolerance) MGT =
2447 Handle(StepDimTol_ModifiedGeometricTolerance)::DownCast(theEnt);
2448 Standard_Integer kind = 35 + MGT->Modifier();
2449 aDGTTool->SetDimTol(shL,kind,arr,aName,aDescription);
2451 else if(GT->IsKind(STANDARD_TYPE(StepDimTol_CylindricityTolerance))) {
2452 aDGTTool->SetDimTol(shL,38,arr,aName,aDescription);
2454 else if(GT->IsKind(STANDARD_TYPE(StepDimTol_FlatnessTolerance))) {
2455 aDGTTool->SetDimTol(shL,39,arr,aName,aDescription);
2457 else if(GT->IsKind(STANDARD_TYPE(StepDimTol_LineProfileTolerance))) {
2458 aDGTTool->SetDimTol(shL,40,arr,aName,aDescription);
2460 else if(GT->IsKind(STANDARD_TYPE(StepDimTol_PositionTolerance))) {
2461 aDGTTool->SetDimTol(shL,41,arr,aName,aDescription);
2463 else if(GT->IsKind(STANDARD_TYPE(StepDimTol_RoundnessTolerance))) {
2464 aDGTTool->SetDimTol(shL,42,arr,aName,aDescription);
2466 else if(GT->IsKind(STANDARD_TYPE(StepDimTol_StraightnessTolerance))) {
2467 aDGTTool->SetDimTol(shL,43,arr,aName,aDescription);
2469 else if(GT->IsKind(STANDARD_TYPE(StepDimTol_SurfaceProfileTolerance))) {
2470 aDGTTool->SetDimTol(shL,44,arr,aName,aDescription);
2476 if(aGISU.IsNull()) continue;
2477 if(aGISU->NbIdentifiedItem() > 0) {
2478 aSeqRI.Append(aGISU->IdentifiedItemValue(1));
2482 if(!aSeqRI.IsEmpty())
2484 if(aSeqRI1.IsEmpty())
2491 if(aSeqRI1.IsEmpty()) return aGDTL;
2493 TDF_LabelSequence aShLS1, aShLS2;
2495 for(Standard_Integer i = aSeqRI1.Lower(); i <= aSeqRI1.Upper() ;i++)
2497 Standard_Integer anIndex = aTP->MapIndex(aSeqRI1.Value(i));
2500 Handle(Transfer_Binder) aBinder = aTP->MapItem(anIndex);
2501 aSh = TransferBRep::ShapeResult(aBinder);
2506 aSTool->Search(aSh, aShL, Standard_True, Standard_True, Standard_True);
2507 aShLS1.Append(aShL);
2510 if (!aSeqRI2.IsEmpty())
2512 //for dimensional location
2513 for(Standard_Integer i = aSeqRI2.Lower(); i <= aSeqRI2.Upper() ;i++)
2515 Standard_Integer anIndex = aTP->MapIndex(aSeqRI2.Value(i));
2518 Handle(Transfer_Binder) aBinder = aTP->MapItem(anIndex);
2519 aSh = TransferBRep::ShapeResult(aBinder);
2524 aSTool->Search(aSh, aShL, Standard_True, Standard_True, Standard_True);
2525 aShLS2.Append(aShL);
2530 if(!aShLS1.IsEmpty())
2533 if(!theEnt->IsKind(STANDARD_TYPE(StepDimTol_GeometricTolerance)))
2535 aGDTL = aDGTTool->AddDimension();
2536 Handle(XCAFDoc_Dimension) aDim = XCAFDoc_Dimension::Set(aGDTL);
2537 TCollection_AsciiString aStr("DGT:Dimensional_");
2538 if(theEnt->IsKind(STANDARD_TYPE(StepShape_DimensionalSize)))
2540 aStr.AssignCat("Size");
2542 else if(theEnt->IsKind(STANDARD_TYPE(StepShape_DimensionalLocation)))
2544 aStr.AssignCat("Location");
2546 TDataStd_Name::Set(aGDTL, aStr);
2548 if(!aShLS2.IsEmpty())
2550 aDGTTool->SetDimension(aShLS1, aShLS2, aGDTL);
2554 TDF_LabelSequence aEmptySeq;
2555 aDGTTool->SetDimension(aShLS1, aEmptySeq, aGDTL);
2560 aGDTL = aDGTTool->AddGeomTolerance();
2561 Handle(XCAFDoc_GeomTolerance) aGTol = XCAFDoc_GeomTolerance::Set(aGDTL);
2562 TCollection_AsciiString aStr("DGT:GeomTolerance");
2563 TDataStd_Name::Set(aGDTL, aStr);
2564 aDGTTool->SetGeomTolerance(aShLS1, aGDTL);
2565 Handle(XCAFDimTolObjects_GeomToleranceObject) anObj = aGTol->GetObject();
2567 anObj->AddModifier(XCAFDimTolObjects_GeomToleranceModif_All_Around);
2569 anObj->AddModifier(XCAFDimTolObjects_GeomToleranceModif_All_Over);
2570 aGTol->SetObject(anObj);
2572 readDatumsAP242(theEnt, aGDTL, theDoc, theWS);
2577 //=======================================================================
2578 //function : setDimObjectToXCAF
2580 //=======================================================================
2581 static void setDimObjectToXCAF(const Handle(Standard_Transient)& theEnt,
2582 const TDF_Label& aDimL,
2583 const Handle(TDocStd_Document)& theDoc,
2584 const Handle(XSControl_WorkSession)& theWS)
2586 Handle(XCAFDoc_ShapeTool) aSTool = XCAFDoc_DocumentTool::ShapeTool( theDoc->Main() );
2587 Handle(XCAFDoc_DimTolTool) aDGTTool = XCAFDoc_DocumentTool::DimTolTool( theDoc->Main() );
2588 Handle(XSControl_TransferReader) aTR = theWS->TransferReader();
2589 Handle(Transfer_TransientProcess) aTP = aTR->TransientProcess();
2590 const Interface_Graph& aGraph = aTP->Graph();
2591 Handle(XCAFDimTolObjects_DimensionObject) aDimObj;
2592 if(!theEnt->IsKind(STANDARD_TYPE(StepShape_DimensionalSize)) &&
2593 !theEnt->IsKind(STANDARD_TYPE(StepShape_DimensionalLocation)))
2596 Handle(StepShape_DimensionalSize) aDimSize =
2597 Handle(StepShape_DimensionalSize)::DownCast(theEnt);
2598 Handle(StepShape_DimensionalLocation) aDimLocation =
2599 Handle(StepShape_DimensionalLocation)::DownCast(theEnt);
2601 Standard_Real aDim1=-1.,aDim2=-1.,aDim3=-1.;
2602 Handle(StepShape_TypeQualifier) aTQ;
2603 Handle(StepShape_ValueFormatTypeQualifier) aVFTQ;
2604 Handle(StepShape_ToleranceValue) aTV;
2605 Handle(StepShape_LimitsAndFits) aLAF;
2606 Handle(StepRepr_CompoundRepresentationItem) aCRI;
2607 Handle(StepGeom_Axis2Placement3d) anAP;
2609 Interface_EntityIterator anIterDim;
2610 if(!aDimSize.IsNull())
2612 anIterDim = aGraph.Sharings(aDimSize);
2616 anIterDim = aGraph.Sharings(aDimLocation);
2618 for(anIterDim.Start(); anIterDim.More(); anIterDim.Next()) {
2619 Handle(StepShape_DimensionalCharacteristicRepresentation) aDCR =
2620 Handle(StepShape_DimensionalCharacteristicRepresentation)::DownCast(anIterDim.Value());
2621 Handle(StepShape_PlusMinusTolerance) aPMT =
2622 Handle(StepShape_PlusMinusTolerance)::DownCast(anIterDim.Value());
2623 if(!aDCR.IsNull()) {
2624 Handle(StepShape_ShapeDimensionRepresentation) aSDR = aDCR->Representation();
2625 if(!aSDR.IsNull()) {
2626 Handle(StepRepr_HArray1OfRepresentationItem) aHARI = aSDR->Items();
2630 for(Standard_Integer nr = aHARI->Lower(); nr <= aHARI->Upper(); nr++)
2632 Handle(StepRepr_RepresentationItem) aDRI = aHARI->Value(nr);
2633 if(aDRI.IsNull()) continue;
2635 if(aDRI->IsKind(STANDARD_TYPE(StepRepr_ReprItemAndLengthMeasureWithUnit))) {
2637 Handle(StepRepr_ReprItemAndLengthMeasureWithUnit) aRILMWU =
2638 Handle(StepRepr_ReprItemAndLengthMeasureWithUnit)::DownCast(aDRI);
2639 Standard_Real aVal = aRILMWU->GetMeasureWithUnit()->ValueComponent();
2640 StepBasic_Unit anUnit = aRILMWU->GetMeasureWithUnit()->UnitComponent();
2641 Standard_Real aFact=1.;
2642 if(anUnit.IsNull()) continue;
2643 if( !(anUnit.CaseNum(anUnit.Value())==1) ) continue;
2644 Handle(StepBasic_NamedUnit) NU = anUnit.NamedUnit();
2645 if(GetLengthConversionFactor(NU,aFact)) aVal=aVal*aFact;
2650 Standard_Real aTmp = aDim1;
2656 else if(aVal > aDim2)
2672 else if(aDRI->IsKind(STANDARD_TYPE(StepRepr_ReprItemAndPlaneAngleMeasureWithUnit))) {
2674 Handle(StepRepr_ReprItemAndPlaneAngleMeasureWithUnit) aRIPAMWU =
2675 Handle(StepRepr_ReprItemAndPlaneAngleMeasureWithUnit)::DownCast(aDRI);
2676 Standard_Real aVal = aRIPAMWU->GetMeasureWithUnit()->ValueComponent();
2677 StepBasic_Unit anUnit = aRIPAMWU->GetMeasureWithUnit()->UnitComponent();
2678 Standard_Real aFact=1.;
2679 if(anUnit.IsNull()) continue;
2680 if( !(anUnit.CaseNum(anUnit.Value())==1) ) continue;
2681 Handle(StepBasic_NamedUnit) NU = anUnit.NamedUnit();
2682 if(GetAngleConversionFactor(NU,aFact)) aVal=aVal*aFact;
2687 Standard_Real aTmp = aDim1;
2693 else if(aVal > aDim2)
2709 else if(aDRI->IsKind(STANDARD_TYPE(StepShape_QualifiedRepresentationItem))) {
2711 Handle(StepShape_QualifiedRepresentationItem) aQRI =
2712 Handle(StepShape_QualifiedRepresentationItem)::DownCast(aDRI);
2713 for(Standard_Integer l = 1; l <= aQRI->NbQualifiers(); l++)
2715 aTQ = aQRI->Qualifiers()->Value(l).TypeQualifier();
2716 aVFTQ = aQRI->Qualifiers()->Value(l).ValueFormatTypeQualifier();
2719 else if(aDRI->IsKind(STANDARD_TYPE(StepRepr_CompoundRepresentationItem))) {
2720 aCRI = Handle(StepRepr_CompoundRepresentationItem)::DownCast(aDRI);
2722 else if(aDRI->IsKind(STANDARD_TYPE(StepGeom_Axis2Placement3d)))
2724 anAP = Handle(StepGeom_Axis2Placement3d)::DownCast(aDRI);
2730 else if (!aPMT.IsNull())
2732 StepShape_ToleranceMethodDefinition aTMD = aPMT->Range();
2733 if(aPMT.IsNull()) continue;
2734 if(aTMD.CaseNumber() == 1)
2735 //! 1 -> ToleranceValue from StepShape
2736 //! 2 -> LimitsAndFits from StepShape
2738 //plus minus tolerance
2739 aTV = aTMD.ToleranceValue();
2740 if (aTV.IsNull()) continue;
2742 Standard_Real aVal = aTV->UpperBound()->ValueComponent();
2743 StepBasic_Unit anUnit = aTV->UpperBound()->UnitComponent();
2744 Standard_Real aFact=1.;
2745 if(anUnit.IsNull()) continue;
2746 if( !(anUnit.CaseNum(anUnit.Value())==1) ) continue;
2747 Handle(StepBasic_NamedUnit) NU = anUnit.NamedUnit();
2748 if(GetLengthConversionFactor(NU,aFact)) aVal=aVal*aFact;
2751 aVal = aTV->LowerBound()->ValueComponent();
2752 anUnit = aTV->LowerBound()->UnitComponent();
2754 if(anUnit.IsNull()) continue;
2755 if( !(anUnit.CaseNum(anUnit.Value())==1) ) continue;
2756 NU = anUnit.NamedUnit();
2757 if(GetLengthConversionFactor(NU,aFact)) aVal=aVal*aFact;
2762 // calss of tolerance
2763 aLAF = aTMD.LimitsAndFits();
2770 aDimObj = new XCAFDimTolObjects_DimensionObject();
2772 aDimObj->SetValue(aDim1);
2775 Handle(TColStd_HArray1OfReal) anArr = new TColStd_HArray1OfReal(1,2);
2776 anArr->SetValue(1,aDim1);
2777 anArr->SetValue(2,aDim2);
2778 aDimObj->SetValues(anArr);
2782 Handle(TColStd_HArray1OfReal) anArr = new TColStd_HArray1OfReal(1,3);
2783 anArr->SetValue(1,aDim1);
2784 anArr->SetValue(2,aDim2);
2785 anArr->SetValue(3,aDim3);
2786 aDimObj->SetValues(anArr);
2790 XCAFDimTolObjects_DimensionQualifier aQ;
2791 if (STEPCAFControl_GDTProperty::GetDimQualifierType(aTQ->Name(), aQ))
2793 aDimObj->SetQualifier(aQ);
2797 if (!aVFTQ.IsNull())
2799 //A typical value would be 'NR2 2.2'
2800 TCollection_HAsciiString aFormat = aVFTQ->FormatType();
2801 Standard_Integer i = aFormat.Location(1,' ',1,aFormat.Length());
2802 aFormat.SubString(i+1,i+1)->IntegerValue();
2803 aDimObj->SetNbOfDecimalPlaces(aFormat.SubString(i+1,i+1)->IntegerValue(),
2804 aFormat.SubString(i+3,i+3)->IntegerValue());
2809 //get class of tolerance
2810 Standard_Boolean aHolle = Standard_False;
2811 XCAFDimTolObjects_DimensionFormVariance aFV = XCAFDimTolObjects_DimensionFormVariance_None;
2812 XCAFDimTolObjects_DimensionGrade aG = XCAFDimTolObjects_DimensionGrade_IT01;
2813 STEPCAFControl_GDTProperty::GetDimClassOfTolerance(aLAF, aHolle, aFV, aG);
2814 aDimObj->SetClassOfTolerance(aHolle, aFV, aG);
2817 if (!aCRI.IsNull() && aCRI->ItemElement()->Length() > 0)
2820 XCAFDimTolObjects_DimensionModifiersSequence aModifiers;
2821 STEPCAFControl_GDTProperty::GetDimModifiers(aCRI, aModifiers);
2822 if(aModifiers.Length() > 0)
2823 aDimObj->SetModifiers(aModifiers);
2826 Handle(TCollection_HAsciiString) aName;
2827 if(!aDimSize.IsNull())
2829 aName = aDimSize->Name();
2833 aName = aDimLocation->Name();
2835 XCAFDimTolObjects_DimensionType aType = XCAFDimTolObjects_DimensionType_Location_None;
2836 if (!STEPCAFControl_GDTProperty::GetDimType(aName, aType))
2838 if(!aDimSize.IsNull())
2840 Handle(StepShape_AngularSize) anAngSize=
2841 Handle(StepShape_AngularSize)::DownCast(aDimSize);
2842 if(!anAngSize.IsNull())
2844 //get qualifier for angular value
2845 aType = XCAFDimTolObjects_DimensionType_Size_Angular;
2846 if(anAngSize->AngleSelection() == StepShape_Equal)
2847 aDimObj->SetQualifier(XCAFDimTolObjects_DimensionQualifier_Avg);
2848 else if (anAngSize->AngleSelection() == StepShape_Large)
2849 aDimObj->SetQualifier(XCAFDimTolObjects_DimensionQualifier_Max);
2850 else if (anAngSize->AngleSelection() == StepShape_Small)
2851 aDimObj->SetQualifier(XCAFDimTolObjects_DimensionQualifier_Min);
2856 Handle(StepShape_AngularLocation) anAngLoc=
2857 Handle(StepShape_AngularLocation)::DownCast(aDimLocation);
2858 if(!anAngLoc.IsNull())
2860 //get qualifier for angular value
2861 aType = XCAFDimTolObjects_DimensionType_Location_Angular;
2862 if(anAngLoc->AngleSelection() == StepShape_Equal)
2863 aDimObj->SetQualifier(XCAFDimTolObjects_DimensionQualifier_Avg);
2864 else if (anAngLoc->AngleSelection() == StepShape_Large)
2865 aDimObj->SetQualifier(XCAFDimTolObjects_DimensionQualifier_Max);
2866 else if (anAngLoc->AngleSelection() == StepShape_Small)
2867 aDimObj->SetQualifier(XCAFDimTolObjects_DimensionQualifier_Min);
2870 if(aType == XCAFDimTolObjects_DimensionType_Location_None)
2872 Handle(StepRepr_ShapeAspect) aPSA;
2873 if(!aDimSize.IsNull())
2875 Handle(StepShape_DimensionalSizeWithPath) aDimSizeWithPath=
2876 Handle(StepShape_DimensionalSizeWithPath)::DownCast(aDimSize);
2877 if (!aDimSizeWithPath.IsNull())
2879 aType = XCAFDimTolObjects_DimensionType_Size_WithPath;
2880 aPSA = aDimSizeWithPath->Path();
2885 Handle(StepShape_DimensionalLocationWithPath) aDimLocWithPath=
2886 Handle(StepShape_DimensionalLocationWithPath)::DownCast(aDimLocation);
2887 if (!aDimLocWithPath.IsNull())
2889 aType = XCAFDimTolObjects_DimensionType_Location_WithPath;
2890 aPSA = aDimLocWithPath->Path();
2896 //for DimensionalLocationWithPath
2897 Handle(StepGeom_GeometricRepresentationItem) aGRI;
2898 Handle(StepAP242_GeometricItemSpecificUsage) aPGISU;
2899 Interface_EntityIterator anIterDSWP = aGraph.Sharings(aPSA);
2900 for(anIterDSWP.Start(); anIterDSWP.More() && aPGISU.IsNull(); anIterDSWP.Next()) {
2901 aPGISU = Handle(StepAP242_GeometricItemSpecificUsage)::DownCast(anIterDSWP.Value());
2903 if(aPGISU.IsNull()) return;
2904 if(aPGISU->NbIdentifiedItem() > 0) {
2905 aGRI = Handle(StepGeom_GeometricRepresentationItem)::DownCast(aPGISU->IdentifiedItemValue(1));
2907 if(aGRI.IsNull()) return;
2908 Handle(StepRepr_RepresentationItem) aPRI;
2909 Interface_EntityIterator anIterGRI = aGraph.Sharings(aGRI);
2910 for(anIterGRI.Start(); anIterGRI.More() && aPGISU.IsNull(); anIterGRI.Next()) {
2911 aPRI = Handle(StepRepr_RepresentationItem)::DownCast(anIterGRI.Value());
2913 Standard_Integer anIndex = aTP->MapIndex(aPRI);
2916 Handle(Transfer_Binder) aBinder = aTP->MapItem(anIndex);
2917 aSh = TopoDS::Edge(TransferBRep::ShapeResult(aBinder));
2919 if(aSh.IsNull()) return;
2920 aDimObj->SetPath(aSh);
2922 else if(!anAP.IsNull())
2924 if(anAP->Name()->String().IsEqual("orientation") && !anAP->Axis().IsNull())
2926 //for Oriented Dimensional Location
2927 Handle(TColStd_HArray1OfReal) aDirArr = anAP->RefDirection()->DirectionRatios();
2929 if(!aDirArr.IsNull() && aDirArr->Length() > 2)
2931 aDir.SetCoord(aDirArr->Lower(), aDirArr->Lower()+1, aDirArr->Lower()+2);
2932 aDimObj->SetDirection(aDir);
2934 else if(aDirArr->Length() > 1)
2936 aDir.SetCoord(aDirArr->Lower(), aDirArr->Lower()+1, 0);
2937 aDimObj->SetDirection(aDir);
2943 aDimObj->SetType(aType);
2945 if(!aDimObj.IsNull())
2947 Handle(XCAFDoc_Dimension) aDim;
2948 if(aDimL.FindAttribute(XCAFDoc_Dimension::GetID(),aDim))
2950 aDim->SetObject(aDimObj);
2955 //=======================================================================
2956 //function : getTolType
2958 //=======================================================================
2959 static Standard_Boolean getTolType(const Handle(Standard_Transient)& theEnt,
2960 XCAFDimTolObjects_GeomToleranceType& theType)
2962 if(!theEnt->IsKind(STANDARD_TYPE(StepDimTol_GeometricTolerance)))
2963 return Standard_False;
2964 theType = XCAFDimTolObjects_GeomToleranceType_None;
2965 if (theEnt->IsKind(STANDARD_TYPE(StepDimTol_GeoTolAndGeoTolWthDatRef)))
2967 Handle(StepDimTol_GeoTolAndGeoTolWthDatRef) anE = Handle(StepDimTol_GeoTolAndGeoTolWthDatRef)::DownCast(theEnt);
2968 theType = STEPCAFControl_GDTProperty::GetGeomToleranceType(anE->GetToleranceType());
2970 else if (theEnt->IsKind(STANDARD_TYPE(StepDimTol_GeoTolAndGeoTolWthDatRefAndGeoTolWthMaxTol)))
2972 Handle(StepDimTol_GeoTolAndGeoTolWthDatRefAndGeoTolWthMaxTol) anE =
2973 Handle(StepDimTol_GeoTolAndGeoTolWthDatRefAndGeoTolWthMaxTol)::DownCast(theEnt);
2974 theType = STEPCAFControl_GDTProperty::GetGeomToleranceType(anE->GetToleranceType());
2976 else if (theEnt->IsKind(STANDARD_TYPE(StepDimTol_GeoTolAndGeoTolWthDatRefAndGeoTolWthMod)))
2978 Handle(StepDimTol_GeoTolAndGeoTolWthDatRefAndGeoTolWthMod) anE =
2979 Handle(StepDimTol_GeoTolAndGeoTolWthDatRefAndGeoTolWthMod)::DownCast(theEnt);
2980 theType = STEPCAFControl_GDTProperty::GetGeomToleranceType(anE->GetToleranceType());
2982 else if (theEnt->IsKind(STANDARD_TYPE(StepDimTol_GeoTolAndGeoTolWthMaxTol)))
2984 Handle(StepDimTol_GeoTolAndGeoTolWthMaxTol) anE =
2985 Handle(StepDimTol_GeoTolAndGeoTolWthMaxTol)::DownCast(theEnt);
2986 theType = STEPCAFControl_GDTProperty::GetGeomToleranceType(anE->GetToleranceType());
2988 else if (theEnt->IsKind(STANDARD_TYPE(StepDimTol_GeoTolAndGeoTolWthMod)))
2990 Handle(StepDimTol_GeoTolAndGeoTolWthMod) anE =
2991 Handle(StepDimTol_GeoTolAndGeoTolWthMod)::DownCast(theEnt);
2992 theType = STEPCAFControl_GDTProperty::GetGeomToleranceType(anE->GetToleranceType());
2994 else if (theEnt->IsKind(STANDARD_TYPE(StepDimTol_GeoTolAndGeoTolWthDatRefAndUneqDisGeoTol)))
2996 Handle(StepDimTol_GeoTolAndGeoTolWthDatRefAndUneqDisGeoTol) anE =
2997 Handle(StepDimTol_GeoTolAndGeoTolWthDatRefAndUneqDisGeoTol)::DownCast(theEnt);
2998 theType = STEPCAFControl_GDTProperty::GetGeomToleranceType(anE->GetToleranceType());
3000 else if(theEnt->IsKind(STANDARD_TYPE(StepDimTol_AngularityTolerance)))
3002 theType = XCAFDimTolObjects_GeomToleranceType_Angularity;
3004 else if(theEnt->IsKind(STANDARD_TYPE(StepDimTol_CircularRunoutTolerance)))
3006 theType = XCAFDimTolObjects_GeomToleranceType_CircularRunout;
3008 else if(theEnt->IsKind(STANDARD_TYPE(StepDimTol_RoundnessTolerance)))
3010 theType = XCAFDimTolObjects_GeomToleranceType_CircularityOrRoundness;
3012 else if(theEnt->IsKind(STANDARD_TYPE(StepDimTol_CoaxialityTolerance)))
3014 theType = XCAFDimTolObjects_GeomToleranceType_Coaxiality;
3016 else if(theEnt->IsKind(STANDARD_TYPE(StepDimTol_ConcentricityTolerance)))
3018 theType = XCAFDimTolObjects_GeomToleranceType_Concentricity;
3020 else if(theEnt->IsKind(STANDARD_TYPE(StepDimTol_CylindricityTolerance)))
3022 theType = XCAFDimTolObjects_GeomToleranceType_Cylindricity;
3024 else if(theEnt->IsKind(STANDARD_TYPE(StepDimTol_FlatnessTolerance)))
3026 theType = XCAFDimTolObjects_GeomToleranceType_Flatness;
3028 else if(theEnt->IsKind(STANDARD_TYPE(StepDimTol_ParallelismTolerance)))
3030 theType = XCAFDimTolObjects_GeomToleranceType_Parallelism;
3032 else if(theEnt->IsKind(STANDARD_TYPE(StepDimTol_PerpendicularityTolerance)))
3034 theType = XCAFDimTolObjects_GeomToleranceType_Perpendicularity;
3036 else if(theEnt->IsKind(STANDARD_TYPE(StepDimTol_PositionTolerance)) ||
3037 theEnt->IsKind(STANDARD_TYPE(StepDimTol_GeoTolAndGeoTolWthDatRefAndModGeoTolAndPosTol)))
3039 theType = XCAFDimTolObjects_GeomToleranceType_Position;
3041 else if(theEnt->IsKind(STANDARD_TYPE(StepDimTol_LineProfileTolerance)))
3043 theType = XCAFDimTolObjects_GeomToleranceType_ProfileOfLine;
3045 else if(theEnt->IsKind(STANDARD_TYPE(StepDimTol_SurfaceProfileTolerance)))
3047 theType = XCAFDimTolObjects_GeomToleranceType_ProfileOfSurface;
3049 else if(theEnt->IsKind(STANDARD_TYPE(StepDimTol_StraightnessTolerance)))
3051 theType = XCAFDimTolObjects_GeomToleranceType_Straightness;
3053 else if(theEnt->IsKind(STANDARD_TYPE(StepDimTol_SymmetryTolerance)))
3055 theType = XCAFDimTolObjects_GeomToleranceType_Symmetry;
3057 else if(theEnt->IsKind(STANDARD_TYPE(StepDimTol_TotalRunoutTolerance)))
3059 theType = XCAFDimTolObjects_GeomToleranceType_TotalRunout;
3061 return Standard_True;
3063 //=======================================================================
3064 //function : setGeomTolObjectToXCAF
3066 //=======================================================================
3067 static void setGeomTolObjectToXCAF(const Handle(Standard_Transient)& theEnt,
3068 const TDF_Label& theTolL,
3069 const Handle(TDocStd_Document)& theDoc,
3070 const Handle(XSControl_WorkSession)& theWS)
3072 Handle(XCAFDoc_ShapeTool) aSTool = XCAFDoc_DocumentTool::ShapeTool( theDoc->Main() );
3073 Handle(XCAFDoc_DimTolTool) aDGTTool = XCAFDoc_DocumentTool::DimTolTool( theDoc->Main() );
3074 Handle(XSControl_TransferReader) aTR = theWS->TransferReader();
3075 Handle(Transfer_TransientProcess) aTP = aTR->TransientProcess();
3076 const Interface_Graph& aGraph = aTP->Graph();
3077 Handle(XCAFDoc_GeomTolerance) aGTol;
3078 if(!theTolL.FindAttribute(XCAFDoc_GeomTolerance::GetID(), aGTol))
3082 Handle(XCAFDimTolObjects_GeomToleranceObject) aTolObj = aGTol->GetObject();
3083 Handle(StepDimTol_GeometricTolerance) aTolEnt = Handle(StepDimTol_GeometricTolerance)::DownCast(theEnt);
3085 XCAFDimTolObjects_GeomToleranceType aType = XCAFDimTolObjects_GeomToleranceType_None;
3086 getTolType(theEnt, aType);
3087 aTolObj->SetType(aType);
3088 if(!aTolEnt->Magnitude().IsNull()){
3090 Standard_Real aVal = aTolEnt->Magnitude()->ValueComponent();
3091 StepBasic_Unit anUnit = aTolEnt->Magnitude()->UnitComponent();
3092 Standard_Real aFact=1.;
3093 if(anUnit.IsNull()) return;
3094 if( !(anUnit.CaseNum(anUnit.Value())==1) ) return;
3095 Handle(StepBasic_NamedUnit) NU = anUnit.NamedUnit();
3096 if(GetLengthConversionFactor(NU,aFact))
3098 aTolObj->SetValue(aVal);
3101 XCAFDimTolObjects_GeomToleranceTypeValue aTypeV = XCAFDimTolObjects_GeomToleranceTypeValue_None;
3102 Interface_EntityIterator anIter = aGraph.Sharings(aTolEnt);
3103 for(anIter.Start(); anIter.More(); anIter.Next()) {
3104 if(anIter.Value()->IsKind(STANDARD_TYPE(StepDimTol_ToleranceZone))){
3105 Handle(StepDimTol_ToleranceZoneForm) aForm
3106 = Handle(StepDimTol_ToleranceZone)::DownCast(anIter.Value())->Form();
3107 STEPCAFControl_GDTProperty::GetTolValueType(aForm->Name(), aTypeV);
3108 Interface_EntityIterator anIt = aGraph.Sharings(anIter.Value());
3109 for(anIt.Start(); anIt.More(); anIt.Next()) {
3110 if(anIt.Value()->IsKind(STANDARD_TYPE(StepDimTol_ProjectedZoneDefinition))){
3111 Handle(StepDimTol_ProjectedZoneDefinition) aPZone
3112 = Handle(StepDimTol_ProjectedZoneDefinition)::DownCast(anIt.Value());
3113 if(!aPZone->ProjectionLength().IsNull())
3115 Standard_Real aVal = aPZone->ProjectionLength()->ValueComponent();
3116 StepBasic_Unit anUnit = aPZone->ProjectionLength()->UnitComponent();
3117 Standard_Real aFact=1.;
3118 if(anUnit.IsNull()) return;
3119 if( !(anUnit.CaseNum(anUnit.Value())==1) ) return;
3120 Handle(StepBasic_NamedUnit) NU = anUnit.NamedUnit();
3121 if(GetLengthConversionFactor(NU,aFact))
3123 aTolObj->SetValueOfZoneModifier(aVal);
3124 aTolObj->SetZoneModifier(XCAFDimTolObjects_GeomToleranceZoneModif_Projected);
3127 else if (anIt.Value()->IsKind(STANDARD_TYPE(StepDimTol_RunoutZoneDefinition)))
3129 Handle(StepDimTol_RunoutZoneDefinition) aRZone
3130 = Handle(StepDimTol_RunoutZoneDefinition)::DownCast(anIt.Value());
3131 if(!aRZone->Orientation().IsNull())
3133 Standard_Real aVal = aRZone->Orientation()->Angle()->ValueComponent();
3134 StepBasic_Unit anUnit = aRZone->Orientation()->Angle()->UnitComponent();
3135 Standard_Real aFact=1.;
3136 if(anUnit.IsNull()) continue;
3137 if( !(anUnit.CaseNum(anUnit.Value())==1) ) continue;
3138 Handle(StepBasic_NamedUnit) NU = anUnit.NamedUnit();
3139 if(GetAngleConversionFactor(NU,aFact)) aVal=aVal*aFact;
3140 aTolObj->SetValueOfZoneModifier(aVal);
3141 aTolObj->SetZoneModifier(XCAFDimTolObjects_GeomToleranceZoneModif_Runout);
3145 aTolObj->SetTypeOfValue(aTypeV);
3148 Handle(StepDimTol_HArray1OfGeometricToleranceModifier) aModifiers;
3149 if (aTolEnt->IsKind(STANDARD_TYPE(StepDimTol_GeometricToleranceWithModifiers)))
3151 aModifiers = Handle(StepDimTol_GeometricToleranceWithModifiers)::DownCast(aTolEnt)->Modifiers();
3153 else if (aTolEnt->IsKind(STANDARD_TYPE(StepDimTol_GeoTolAndGeoTolWthDatRefAndGeoTolWthMod)))
3155 aModifiers = Handle(StepDimTol_GeoTolAndGeoTolWthDatRefAndGeoTolWthMod)
3156 ::DownCast(aTolEnt)->GetGeometricToleranceWithModifiers()->Modifiers();
3158 else if (aTolEnt->IsKind(STANDARD_TYPE(StepDimTol_GeoTolAndGeoTolWthMod)))
3160 aModifiers = Handle(StepDimTol_GeoTolAndGeoTolWthMod)
3161 ::DownCast(aTolEnt)->GetGeometricToleranceWithModifiers()->Modifiers();
3163 else if (aTolEnt->IsKind(STANDARD_TYPE(StepDimTol_GeoTolAndGeoTolWthMaxTol)))
3165 aModifiers = Handle(StepDimTol_GeoTolAndGeoTolWthMaxTol)
3166 ::DownCast(aTolEnt)->GetGeometricToleranceWithModifiers()->Modifiers();
3168 else if (aTolEnt->IsKind(STANDARD_TYPE(StepDimTol_GeoTolAndGeoTolWthDatRefAndGeoTolWthMaxTol)))
3170 aModifiers = Handle(StepDimTol_GeoTolAndGeoTolWthDatRefAndGeoTolWthMaxTol)
3171 ::DownCast(aTolEnt)->GetGeometricToleranceWithModifiers()->Modifiers();
3173 if(!aModifiers.IsNull())
3175 for(Standard_Integer i = aModifiers->Lower(); i <= aModifiers->Upper(); i++)
3177 if(aModifiers->Value(i) == StepDimTol_GTMLeastMaterialRequirement)
3178 aTolObj->SetMaterialRequirementModifier(XCAFDimTolObjects_GeomToleranceMatReqModif_L);
3179 else if (aModifiers->Value(i) == StepDimTol_GTMMaximumMaterialRequirement)
3180 aTolObj->SetMaterialRequirementModifier(XCAFDimTolObjects_GeomToleranceMatReqModif_M);
3182 aTolObj->AddModifier((XCAFDimTolObjects_GeomToleranceModif)aModifiers->Value(i));
3185 Standard_Real aVal = 0;
3186 StepBasic_Unit anUnit;
3187 if (aTolEnt->IsKind(STANDARD_TYPE(StepDimTol_GeometricToleranceWithMaximumTolerance)))
3189 Handle(StepDimTol_GeometricToleranceWithMaximumTolerance) aMax = Handle(StepDimTol_GeometricToleranceWithMaximumTolerance)::DownCast(aTolEnt);
3190 aVal = aMax->MaximumUpperTolerance()->ValueComponent();
3191 anUnit = aMax->MaximumUpperTolerance()->UnitComponent();
3193 else if (aTolEnt->IsKind(STANDARD_TYPE(StepDimTol_GeoTolAndGeoTolWthMaxTol)))
3195 Handle(StepDimTol_GeoTolAndGeoTolWthMaxTol) aMax =
3196 Handle(StepDimTol_GeoTolAndGeoTolWthMaxTol)::DownCast(aTolEnt);
3197 aVal = aMax->GetMaxTolerance()->ValueComponent();
3198 anUnit = aMax->GetMaxTolerance()->UnitComponent();
3200 else if (aTolEnt->IsKind(STANDARD_TYPE(StepDimTol_GeoTolAndGeoTolWthDatRefAndGeoTolWthMaxTol)))
3202 Handle(StepDimTol_GeoTolAndGeoTolWthDatRefAndGeoTolWthMaxTol) aMax =
3203 Handle(StepDimTol_GeoTolAndGeoTolWthDatRefAndGeoTolWthMaxTol)::DownCast(aTolEnt);
3204 aVal = aMax->GetMaxTolerance()->ValueComponent();
3205 anUnit = aMax->GetMaxTolerance()->UnitComponent();
3207 if (!anUnit.IsNull() && (anUnit.CaseNum(anUnit.Value()) == 1))
3209 Standard_Real aFact=1.;
3210 Handle(StepBasic_NamedUnit) NU = anUnit.NamedUnit();
3211 if(GetAngleConversionFactor(NU,aFact)) aVal=aVal*aFact;
3212 aTolObj->SetMaxValueModifier(aVal);
3215 aGTol->SetObject(aTolObj);
3218 //=======================================================================
3219 //function : ReadGDTs
3221 //=======================================================================
3223 Standard_Boolean STEPCAFControl_Reader::ReadGDTs(const Handle(XSControl_WorkSession)& theWS,
3224 Handle(TDocStd_Document)& theDoc) const
3226 Handle(Interface_InterfaceModel) aModel = theWS->Model();
3227 Handle(StepData_StepModel) aSM = Handle(StepData_StepModel)::DownCast(aModel);
3228 Interface_EntityIterator anI = aSM->Header();
3229 Handle(HeaderSection_FileSchema) aH;
3230 for(anI.Start(); anI.More() && aH.IsNull();anI.Next())
3231 aH = Handle(HeaderSection_FileSchema)::DownCast(anI.Value());
3232 Handle(XCAFDoc_ShapeTool) aSTool = XCAFDoc_DocumentTool::ShapeTool( theDoc->Main() );
3233 Handle(XSControl_TransferReader) aTR = theWS->TransferReader();
3234 Handle(Transfer_TransientProcess) aTP = aTR->TransientProcess();
3235 Handle(XCAFDoc_DimTolTool) aDGTTool = XCAFDoc_DocumentTool::DimTolTool( theDoc->Main() );
3236 if ( aDGTTool.IsNull() ) return Standard_False;
3238 Standard_Integer nb = aModel->NbEntities();
3239 for(Standard_Integer i=1; i<=nb; i++) {
3240 Handle(Standard_Transient) anEnt = aModel->Value(i);
3241 if(anEnt->IsKind(STANDARD_TYPE(StepShape_DimensionalSize)) ||
3242 anEnt->IsKind(STANDARD_TYPE(StepShape_DimensionalLocation)) ||
3243 anEnt->IsKind(STANDARD_TYPE(StepDimTol_GeometricTolerance))) {
3244 TDF_Label aGDTL = createGDTObjectInXCAF(anEnt,theDoc,theWS);
3245 if(!aGDTL.IsNull()){
3246 if(anEnt->IsKind(STANDARD_TYPE(StepDimTol_GeometricTolerance))){
3247 setGeomTolObjectToXCAF(anEnt, aGDTL,theDoc,theWS);
3250 setDimObjectToXCAF(anEnt, aGDTL,theDoc,theWS);
3255 return Standard_True;
3259 //=======================================================================
3260 //function : FindSolidForPDS
3261 //purpose : auxilary
3262 //=======================================================================
3264 static Handle(StepShape_SolidModel) FindSolidForPDS(const Handle(StepRepr_ProductDefinitionShape) &PDS,
3265 const Interface_Graph &graph)
3267 Handle(StepShape_SolidModel) SM;
3268 Interface_EntityIterator subs = graph.Sharings(PDS);
3269 Handle(StepShape_ShapeRepresentation) SR;
3270 for(subs.Start(); subs.More() && SM.IsNull(); subs.Next()) {
3271 Handle(StepShape_ShapeDefinitionRepresentation) SDR =
3272 Handle(StepShape_ShapeDefinitionRepresentation)::DownCast(subs.Value());
3273 if(SDR.IsNull()) continue;
3274 SR = Handle(StepShape_ShapeRepresentation)::DownCast(SDR->UsedRepresentation());
3275 if(SR.IsNull()) continue;
3276 for(Standard_Integer i=1; i<=SR->NbItems() && SM.IsNull(); i++) {
3277 SM = Handle(StepShape_SolidModel)::DownCast(SR->ItemsValue(i));
3280 Interface_EntityIterator subs1 = graph.Sharings(SR);
3281 for(subs1.Start(); subs1.More() && SM.IsNull(); subs1.Next()) {
3282 Handle(StepRepr_RepresentationRelationship) RR =
3283 Handle(StepRepr_RepresentationRelationship)::DownCast(subs1.Value());
3284 if(RR.IsNull()) continue;
3285 Handle(StepShape_ShapeRepresentation) SR2;
3286 if(RR->Rep1()==SR) SR2 = Handle(StepShape_ShapeRepresentation)::DownCast(RR->Rep2());
3287 else SR2 = Handle(StepShape_ShapeRepresentation)::DownCast(RR->Rep1());
3288 if(SR2.IsNull()) continue;
3289 for(Standard_Integer i2=1; i2<=SR2->NbItems() && SM.IsNull(); i2++) {
3290 SM = Handle(StepShape_SolidModel)::DownCast(SR2->ItemsValue(i2));
3299 //=======================================================================
3300 //function : ReadMaterials
3302 //=======================================================================
3304 Standard_Boolean STEPCAFControl_Reader::ReadMaterials(const Handle(XSControl_WorkSession) &WS,
3305 Handle(TDocStd_Document)& Doc,
3306 const Handle(TColStd_HSequenceOfTransient) &SeqPDS) const
3308 Handle(Interface_InterfaceModel) Model = WS->Model();
3309 Handle(XCAFDoc_ShapeTool) STool = XCAFDoc_DocumentTool::ShapeTool( Doc->Main() );
3310 Handle(XSControl_TransferReader) TR = WS->TransferReader();
3311 Handle(Transfer_TransientProcess) TP = TR->TransientProcess();
3312 Handle(XCAFDoc_MaterialTool) MatTool = XCAFDoc_DocumentTool::MaterialTool( Doc->Main() );
3313 if(MatTool.IsNull()) return Standard_False;
3315 const Interface_Graph& graph = TP->Graph();
3316 for(Standard_Integer i=1; i<=SeqPDS->Length(); i++) {
3317 Handle(StepRepr_ProductDefinitionShape) PDS =
3318 Handle(StepRepr_ProductDefinitionShape)::DownCast(SeqPDS->Value(i));
3321 Handle(StepBasic_ProductDefinition) aProdDef = PDS->Definition().ProductDefinition();
3322 if(aProdDef.IsNull())
3324 Handle(TCollection_HAsciiString) aName = new TCollection_HAsciiString("");
3325 Handle(TCollection_HAsciiString) aDescription = new TCollection_HAsciiString("");
3326 Handle(TCollection_HAsciiString) aDensName = new TCollection_HAsciiString("");
3327 Handle(TCollection_HAsciiString) aDensValType = new TCollection_HAsciiString("");
3328 Standard_Real aDensity=0;
3329 Interface_EntityIterator subs = graph.Sharings( aProdDef);
3330 for(subs.Start(); subs.More(); subs.Next()) {
3331 Handle(StepRepr_PropertyDefinition) PropD =
3332 Handle(StepRepr_PropertyDefinition)::DownCast(subs.Value());
3333 if(PropD.IsNull()) continue;
3334 Interface_EntityIterator subs1 = graph.Sharings(PropD);
3335 for(subs1.Start(); subs1.More(); subs1.Next()) {
3336 Handle(StepRepr_PropertyDefinitionRepresentation) PDR =
3337 Handle(StepRepr_PropertyDefinitionRepresentation)::DownCast(subs1.Value());
3338 if(PDR.IsNull()) continue;
3339 Handle(StepRepr_Representation) Repr = PDR->UsedRepresentation();
3340 if(Repr.IsNull()) continue;
3341 Standard_Integer ir;
3342 for(ir=1; ir<=Repr->NbItems(); ir++) {
3343 Handle(StepRepr_RepresentationItem) RI = Repr->ItemsValue(ir);
3344 if(RI.IsNull()) continue;
3345 if(RI->IsKind(STANDARD_TYPE(StepRepr_DescriptiveRepresentationItem))) {
3346 // find name and description for material
3347 Handle(StepRepr_DescriptiveRepresentationItem) DRI =
3348 Handle(StepRepr_DescriptiveRepresentationItem)::DownCast(RI);
3349 aName = DRI->Name();
3351 aDescription = DRI->Description();
3353 aName = aDescription;
3355 if(RI->IsKind(STANDARD_TYPE(StepRepr_MeasureRepresentationItem))) {
3356 // try to find density for material
3357 Handle(StepRepr_MeasureRepresentationItem) MRI =
3358 Handle(StepRepr_MeasureRepresentationItem)::DownCast(RI);
3359 aDensity = MRI->Measure()->ValueComponent();
3360 aDensName = MRI->Name();
3361 aDensValType = new TCollection_HAsciiString(MRI->Measure()->ValueComponentMember()->Name());
3362 StepBasic_Unit aUnit = MRI->Measure()->UnitComponent();
3363 if(!aUnit.IsNull()) {
3364 Handle(StepBasic_DerivedUnit) DU = aUnit.DerivedUnit();
3365 if(DU.IsNull()) continue;
3366 for(Standard_Integer idu=1; idu<=DU->NbElements(); idu++) {
3367 Handle(StepBasic_DerivedUnitElement) DUE = DU->ElementsValue(idu);
3368 Handle(StepBasic_NamedUnit) NU = DUE->Unit();
3369 Standard_Real afact=1.;
3370 if(NU->IsKind(STANDARD_TYPE(StepBasic_ConversionBasedUnitAndLengthUnit))) {
3371 if(GetLengthConversionFactor(NU,afact)) aDensity = aDensity/(afact*afact*afact);
3372 // transfer length value for Density from millimeter to santimeter
3373 // in order to result density has dimension gram/(sm*sm*sm)
3374 aDensity = aDensity*1000.;
3376 if(NU->IsKind(STANDARD_TYPE(StepBasic_ConversionBasedUnitAndMassUnit))) {
3377 if(GetMassConversionFactor(NU,afact)) aDensity=aDensity*afact;
3386 if( aName.IsNull() || aName->Length()==0 )
3388 // find shape label amd create Material link
3390 Handle(StepShape_SolidModel) SM = FindSolidForPDS(PDS,graph);
3392 Standard_Integer index = TP->MapIndex(SM);
3394 Handle(Transfer_Binder) binder = TP->MapItem(index);
3395 if(!binder.IsNull())
3396 aSh = TransferBRep::ShapeResult(binder);
3399 if(aSh.IsNull()) continue;
3401 if( !STool->Search(aSh, shL, Standard_True, Standard_True, Standard_True) ) continue;
3402 MatTool->SetMaterial(shL,aName,aDescription,aDensity,aDensName,aDensValType);
3405 return Standard_True;
3408 //=======================================================================
3409 //function : SettleShapeData
3411 //=======================================================================
3413 TDF_Label STEPCAFControl_Reader::SettleShapeData(const Handle(StepRepr_RepresentationItem)& theItem,
3415 const Handle(XCAFDoc_ShapeTool)& theShapeTool,
3416 const Handle(Transfer_TransientProcess)& TP) const
3418 TDF_Label aResult = theLab;
3420 Handle(TCollection_HAsciiString) hName = theItem->Name();
3421 if ( hName.IsNull() || hName->IsEmpty() )
3424 Handle(Transfer_Binder) aBinder = TP->Find(theItem);
3425 if ( aBinder.IsNull() )
3428 TopoDS_Shape aShape = TransferBRep::ShapeResult(aBinder);
3429 if ( aShape.IsNull() )
3432 // Allocate sub-Label
3433 aResult = AllocateSubLabel(theLab);
3435 TCollection_AsciiString aName = hName->String();
3436 TDataStd_Name::Set(aResult, aName);
3437 theShapeTool->SetShape(aResult, aShape);
3442 //=======================================================================
3443 //function : ExpandSubShapes
3445 //=======================================================================
3447 void STEPCAFControl_Reader::ExpandSubShapes(const Handle(XCAFDoc_ShapeTool)& ShapeTool,
3448 const XCAFDoc_DataMapOfShapeLabel& ShapeLabelMap,
3449 const STEPCAFControl_DataMapOfShapePD& ShapePDMap) const
3451 const Handle(Transfer_TransientProcess)& TP = Reader().WS()->TransferReader()->TransientProcess();
3452 NCollection_DataMap<TopoDS_Shape, Handle(TCollection_HAsciiString)> ShapeNameMap;
3453 TColStd_MapOfTransient aRepItems;
3455 // Read translation control variables
3456 Standard_Boolean doReadSNames = (Interface_Static::IVal("read.stepcaf.subshapes.name") > 0);
3458 if ( !doReadSNames )
3461 const Interface_Graph& Graph = Reader().WS()->Graph();
3463 for ( STEPCAFControl_DataMapIteratorOfDataMapOfShapePD it(ShapePDMap); it.More(); it.Next() )
3465 const TopoDS_Shape& aRootShape = it.Key();
3466 const Handle(StepBasic_ProductDefinition)& aPDef = it.Value();
3467 if ( aPDef.IsNull() )
3470 // Find SDR by Product
3471 Handle(StepShape_ShapeDefinitionRepresentation) aSDR;
3472 Interface_EntityIterator entIt = Graph.TypedSharings( aPDef, STANDARD_TYPE(StepShape_ShapeDefinitionRepresentation) );
3473 for ( entIt.Start(); entIt.More(); entIt.Next() )
3475 const Handle(Standard_Transient)& aReferer = entIt.Value();
3476 aSDR = Handle(StepShape_ShapeDefinitionRepresentation)::DownCast(aReferer);
3477 if ( !aSDR.IsNull() )
3481 if ( aSDR.IsNull() )
3484 // Access shape representation
3485 Handle(StepShape_ShapeRepresentation)
3486 aShapeRepr = Handle(StepShape_ShapeRepresentation)::DownCast( aSDR->UsedRepresentation() );
3488 if ( aShapeRepr.IsNull() )
3491 // Access representation items
3492 Handle(StepRepr_HArray1OfRepresentationItem) aReprItems = aShapeRepr->Items();
3494 if ( aReprItems.IsNull() )
3497 if ( !ShapeLabelMap.IsBound(aRootShape) )
3500 TDF_Label aRootLab = ShapeLabelMap.Find(aRootShape);
3502 StepRepr_SequenceOfRepresentationItem aMSBSeq;
3503 StepRepr_SequenceOfRepresentationItem aSBSMSeq;
3505 // Iterate over the top level representation items collecting the
3506 // topological containers to expand
3507 for ( Standard_Integer i = aReprItems->Lower(); i <= aReprItems->Upper(); ++i )
3509 Handle(StepRepr_RepresentationItem) aTRepr = aReprItems->Value(i);
3510 if ( aTRepr->IsKind( STANDARD_TYPE(StepShape_ManifoldSolidBrep) ) )
3511 aMSBSeq.Append(aTRepr);
3512 else if ( aTRepr->IsKind( STANDARD_TYPE(StepShape_ShellBasedSurfaceModel) ) )
3513 aSBSMSeq.Append(aTRepr);
3516 // Insert intermediate OCAF Labels for SOLIDs in case there are more
3517 // than one Manifold Solid BRep in the Shape Representation
3518 Standard_Boolean doInsertSolidLab = (aMSBSeq.Length() > 1);
3520 // Expand Manifold Solid BReps
3521 for ( Standard_Integer i = 1; i <= aMSBSeq.Length(); ++i )
3523 const Handle(StepRepr_RepresentationItem)& aManiRepr = aMSBSeq.Value(i);
3525 // Put additional Label for SOLID
3527 if ( doInsertSolidLab )
3528 aManiLab = SettleShapeData(aManiRepr, aRootLab, ShapeTool, TP);
3530 aManiLab = aRootLab;
3532 ExpandManifoldSolidBrep(aManiLab, aMSBSeq.Value(i), TP, ShapeTool);
3535 // Expand Shell-Based Surface Models
3536 for ( Standard_Integer i = 1; i <= aSBSMSeq.Length(); ++i )
3537 ExpandSBSM(aRootLab, aSBSMSeq.Value(i), TP, ShapeTool);
3541 //=======================================================================
3542 //function : ExpandManifoldSolidBrep
3544 //=======================================================================
3546 void STEPCAFControl_Reader::ExpandManifoldSolidBrep(TDF_Label& ShapeLab,
3547 const Handle(StepRepr_RepresentationItem)& Repr,
3548 const Handle(Transfer_TransientProcess)& TP,
3549 const Handle(XCAFDoc_ShapeTool)& ShapeTool) const
3551 // Access outer shell
3552 Handle(StepShape_ManifoldSolidBrep) aMSB = Handle(StepShape_ManifoldSolidBrep)::DownCast(Repr);
3553 Handle(StepShape_ConnectedFaceSet) aShell = aMSB->Outer();
3555 // Expand shell contents to CAF tree
3556 ExpandShell(aShell, ShapeLab, TP, ShapeTool);
3559 //=======================================================================
3560 //function : ExpandSBSM
3562 //=======================================================================
3564 void STEPCAFControl_Reader::ExpandSBSM(TDF_Label& ShapeLab,
3565 const Handle(StepRepr_RepresentationItem)& Repr,
3566 const Handle(Transfer_TransientProcess)& TP,
3567 const Handle(XCAFDoc_ShapeTool)& ShapeTool) const
3569 Handle(StepShape_ShellBasedSurfaceModel) aSBSM = Handle(StepShape_ShellBasedSurfaceModel)::DownCast(Repr);
3571 // Access boundary shells
3572 Handle(StepShape_HArray1OfShell) aShells = aSBSM->SbsmBoundary();
3573 for ( Standard_Integer s = aShells->Lower(); s <= aShells->Upper(); ++s )
3575 const StepShape_Shell& aShell = aShells->Value(s);
3576 Handle(StepShape_ConnectedFaceSet) aCFS;
3577 Handle(StepShape_OpenShell) anOpenShell = aShell.OpenShell();
3578 Handle(StepShape_ClosedShell) aClosedShell = aShell.ClosedShell();
3580 if ( !anOpenShell.IsNull() )
3583 aCFS = aClosedShell;
3585 ExpandShell(aCFS, ShapeLab, TP, ShapeTool);
3589 //=======================================================================
3590 //function : ExpandShell
3592 //=======================================================================
3594 void STEPCAFControl_Reader::ExpandShell(const Handle(StepShape_ConnectedFaceSet)& Shell,
3596 const Handle(Transfer_TransientProcess)& TP,
3597 const Handle(XCAFDoc_ShapeTool)& ShapeTool) const
3600 TDF_Label aShellLab = SettleShapeData(Shell, RootLab, ShapeTool, TP);
3603 Handle(StepShape_HArray1OfFace) aFaces = Shell->CfsFaces();
3604 for ( Standard_Integer f = aFaces->Lower(); f <= aFaces->Upper(); ++f )
3606 const Handle(StepShape_Face)& aFace = aFaces->Value(f);
3609 TDF_Label aFaceLab = SettleShapeData(aFace, aShellLab, ShapeTool, TP);
3611 // Access face bounds
3612 Handle(StepShape_HArray1OfFaceBound) aWires = aFace->Bounds();
3613 for ( Standard_Integer w = aWires->Lower(); w <= aWires->Upper(); ++w )
3615 const Handle(StepShape_Loop)& aWire = aWires->Value(w)->Bound();
3618 TDF_Label aWireLab = SettleShapeData(aWire, aFaceLab, ShapeTool, TP);
3620 // Access wire edges
3621 // Currently only EDGE LOOPs are considered (!)
3622 if ( !aWire->IsInstance( STANDARD_TYPE(StepShape_EdgeLoop) ) )
3626 Handle(StepShape_EdgeLoop) anEdgeLoop = Handle(StepShape_EdgeLoop)::DownCast(aWire);
3627 Handle(StepShape_HArray1OfOrientedEdge) anEdges = anEdgeLoop->EdgeList();
3628 for ( Standard_Integer e = anEdges->Lower(); e <= anEdges->Upper(); ++e )
3630 Handle(StepShape_Edge) anEdge = anEdges->Value(e)->EdgeElement();
3633 TDF_Label anEdgeLab = SettleShapeData(anEdge, aWireLab, ShapeTool, TP);
3636 Handle(StepShape_Vertex) aV1 = anEdge->EdgeStart();
3637 Handle(StepShape_Vertex) aV2 = anEdge->EdgeEnd();
3640 SettleShapeData(aV1, anEdgeLab, ShapeTool, TP);
3641 SettleShapeData(aV2, anEdgeLab, ShapeTool, TP);
3647 //=======================================================================
3648 //function : SetColorMode
3650 //=======================================================================
3652 void STEPCAFControl_Reader::SetColorMode (const Standard_Boolean colormode)
3654 myColorMode = colormode;
3657 //=======================================================================
3658 //function : GetColorMode
3660 //=======================================================================
3662 Standard_Boolean STEPCAFControl_Reader::GetColorMode () const
3667 //=======================================================================
3668 //function : SetNameMode
3670 //=======================================================================
3672 void STEPCAFControl_Reader::SetNameMode (const Standard_Boolean namemode)
3674 myNameMode = namemode;
3677 //=======================================================================
3678 //function : GetNameMode
3680 //=======================================================================
3682 Standard_Boolean STEPCAFControl_Reader::GetNameMode () const
3687 //=======================================================================
3688 //function : SetLayerMode
3690 //=======================================================================
3692 void STEPCAFControl_Reader::SetLayerMode (const Standard_Boolean layermode)
3694 myLayerMode = layermode;
3697 //=======================================================================
3698 //function : GetLayerMode
3700 //=======================================================================
3702 Standard_Boolean STEPCAFControl_Reader::GetLayerMode () const
3707 //=======================================================================
3708 //function : SetPropsMode
3710 //=======================================================================
3712 void STEPCAFControl_Reader::SetPropsMode (const Standard_Boolean propsmode)
3714 myPropsMode = propsmode;
3717 //=======================================================================
3718 //function : GetPropsMode
3720 //=======================================================================
3722 Standard_Boolean STEPCAFControl_Reader::GetPropsMode () const
3727 //=======================================================================
3728 //function : SetSHUOMode
3730 //=======================================================================
3732 void STEPCAFControl_Reader::SetSHUOMode (const Standard_Boolean mode)
3737 //=======================================================================
3738 //function : GetSHUOMode
3740 //=======================================================================
3742 Standard_Boolean STEPCAFControl_Reader::GetSHUOMode () const
3747 //=======================================================================
3748 //function : SetGDTMode
3750 //=======================================================================
3752 void STEPCAFControl_Reader::SetGDTMode (const Standard_Boolean gdtmode)
3754 myGDTMode = gdtmode;
3757 //=======================================================================
3758 //function : GetGDTMode
3760 //=======================================================================
3762 Standard_Boolean STEPCAFControl_Reader::GetGDTMode () const
3768 //=======================================================================
3769 //function : SetMatMode
3771 //=======================================================================
3773 void STEPCAFControl_Reader::SetMatMode (const Standard_Boolean matmode)
3775 myMatMode = matmode;
3778 //=======================================================================
3779 //function : GetMatMode
3781 //=======================================================================
3783 Standard_Boolean STEPCAFControl_Reader::GetMatMode () const