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 <Geom_Axis2Placement.hxx>
19 #include <Geom_CartesianPoint.hxx>
20 #include <Geom_Plane.hxx>
21 #include <Interface_EntityIterator.hxx>
22 #include <Interface_InterfaceModel.hxx>
23 #include <StepData_StepModel.hxx>
24 #include <HeaderSection_FileSchema.hxx>
25 #include <Interface_Static.hxx>
26 #include <NCollection_DataMap.hxx>
27 #include <OSD_Path.hxx>
28 #include <Quantity_Color.hxx>
29 #include <StepAP214_AppliedExternalIdentificationAssignment.hxx>
30 #include <StepBasic_ConversionBasedUnitAndLengthUnit.hxx>
31 #include <StepBasic_ConversionBasedUnitAndPlaneAngleUnit.hxx>
32 #include <StepBasic_ConversionBasedUnitAndMassUnit.hxx>
33 #include <StepBasic_DerivedUnit.hxx>
34 #include <StepBasic_DerivedUnitElement.hxx>
35 #include <StepBasic_MeasureValueMember.hxx>
36 #include <StepBasic_MeasureWithUnit.hxx>
37 #include <StepBasic_NamedUnit.hxx>
38 #include <StepBasic_Product.hxx>
39 #include <StepBasic_ProductDefinition.hxx>
40 #include <StepBasic_ProductDefinitionFormation.hxx>
41 #include <StepBasic_ProductDefinitionRelationship.hxx>
42 #include <StepBasic_SiUnit.hxx>
43 #include <StepBasic_SiUnitAndLengthUnit.hxx>
44 #include <StepBasic_Unit.hxx>
45 #include <STEPCAFControl_Controller.hxx>
46 #include <STEPCAFControl_DataMapIteratorOfDataMapOfShapePD.hxx>
47 #include <STEPCAFControl_DataMapOfPDExternFile.hxx>
48 #include <STEPCAFControl_DataMapOfSDRExternFile.hxx>
49 #include <STEPCAFControl_DataMapOfShapePD.hxx>
50 #include <STEPCAFControl_ExternFile.hxx>
51 #include <STEPCAFControl_Reader.hxx>
52 #include <STEPConstruct.hxx>
53 #include <STEPConstruct_Assembly.hxx>
54 #include <STEPConstruct_ExternRefs.hxx>
55 #include <STEPConstruct_Styles.hxx>
56 #include <STEPConstruct_Tool.hxx>
57 #include <STEPConstruct_UnitContext.hxx>
58 #include <STEPConstruct_ValidationProps.hxx>
59 #include <STEPControl_Reader.hxx>
60 #include <StepGeom_GeometricRepresentationItem.hxx>
61 #include <StepGeom_Axis2Placement3d.hxx>
62 #include <StepGeom_Direction.hxx>
63 #include <StepDimTol_AngularityTolerance.hxx>
64 #include <StepDimTol_CircularRunoutTolerance.hxx>
65 #include <StepDimTol_CoaxialityTolerance.hxx>
66 #include <StepDimTol_ConcentricityTolerance.hxx>
67 #include <StepDimTol_CylindricityTolerance.hxx>
68 #include <StepDimTol_Datum.hxx>
69 #include <StepDimTol_DatumFeature.hxx>
70 #include <StepDimTol_DatumReference.hxx>
71 #include <StepDimTol_DatumReferenceElement.hxx>
72 #include <StepDimTol_DatumReferenceCompartment.hxx>
73 #include <StepDimTol_DatumSystem.hxx>
74 #include <StepDimTol_FlatnessTolerance.hxx>
75 #include <StepDimTol_GeometricTolerance.hxx>
76 #include <StepDimTol_GeometricToleranceWithDatumReference.hxx>
77 #include <StepDimTol_GeoTolAndGeoTolWthDatRefAndModGeoTolAndPosTol.hxx>
78 #include <StepDimTol_GeoTolAndGeoTolWthDatRef.hxx>
79 #include <StepDimTol_GeoTolAndGeoTolWthDatRefAndGeoTolWthMaxTol.hxx>
80 #include <StepDimTol_GeoTolAndGeoTolWthDatRefAndUneqDisGeoTol.hxx>
81 #include <StepDimTol_GeoTolAndGeoTolWthMaxTol.hxx>
82 #include <StepDimTol_HArray1OfDatumReference.hxx>
83 #include <StepDimTol_LineProfileTolerance.hxx>
84 #include <StepDimTol_ModifiedGeometricTolerance.hxx>
85 #include <StepDimTol_ParallelismTolerance.hxx>
86 #include <StepDimTol_PerpendicularityTolerance.hxx>
87 #include <StepDimTol_PositionTolerance.hxx>
88 #include <StepDimTol_ProjectedZoneDefinition.hxx>
89 #include <StepDimTol_RoundnessTolerance.hxx>
90 #include <StepDimTol_RunoutZoneDefinition.hxx>
91 #include <StepDimTol_StraightnessTolerance.hxx>
92 #include <StepDimTol_SurfaceProfileTolerance.hxx>
93 #include <StepDimTol_SymmetryTolerance.hxx>
94 #include <StepDimTol_ToleranceZone.hxx>
95 #include <StepDimTol_ToleranceZoneForm.hxx>
96 #include <StepDimTol_TotalRunoutTolerance.hxx>
97 #include <StepDimTol_GeometricToleranceWithModifiers.hxx>
98 #include <StepDimTol_HArray1OfGeometricToleranceModifier.hxx>
99 #include <StepDimTol_GeoTolAndGeoTolWthDatRefAndGeoTolWthMod.hxx>
100 #include <StepDimTol_GeoTolAndGeoTolWthMod.hxx>
101 #include <StepDimTol_GeometricToleranceWithMaximumTolerance.hxx>
102 #include <StepGeom_Axis2Placement3d.hxx>
103 #include <StepGeom_GeometricRepresentationContextAndGlobalUnitAssignedContext.hxx>
104 #include <StepGeom_GeomRepContextAndGlobUnitAssCtxAndGlobUncertaintyAssCtx.hxx>
105 #include <StepGeom_Plane.hxx>
106 #include <StepGeom_Polyline.hxx>
107 #include <StepDimTol_PlacedDatumTargetFeature.hxx>
108 #include <StepRepr_AssemblyComponentUsage.hxx>
109 #include <StepRepr_CharacterizedDefinition.hxx>
110 #include <StepRepr_CompoundRepresentationItem.hxx>
111 #include <StepRepr_DerivedShapeAspect.hxx>
112 #include <StepRepr_DescriptiveRepresentationItem.hxx>
113 #include <StepRepr_HArray1OfRepresentationItem.hxx>
114 #include <StepRepr_MappedItem.hxx>
115 #include <StepRepr_MeasureRepresentationItem.hxx>
116 #include <StepRepr_NextAssemblyUsageOccurrence.hxx>
117 #include <StepRepr_ProductDefinitionShape.hxx>
118 #include <StepRepr_PropertyDefinition.hxx>
119 #include <StepRepr_PropertyDefinitionRepresentation.hxx>
120 #include <StepRepr_Representation.hxx>
121 #include <StepRepr_RepresentationItem.hxx>
122 #include <StepRepr_HArray1OfRepresentationItem.hxx>
123 #include <StepRepr_RepresentationMap.hxx>
124 #include <StepRepr_RepresentationRelationship.hxx>
125 #include <StepRepr_RepresentedDefinition.hxx>
126 #include <StepRepr_ReprItemAndLengthMeasureWithUnit.hxx>
127 #include <StepRepr_ReprItemAndPlaneAngleMeasureWithUnit.hxx>
128 #include <StepRepr_SequenceOfRepresentationItem.hxx>
129 #include <StepRepr_ShapeAspect.hxx>
130 #include <StepRepr_ShapeAspectDerivingRelationship.hxx>
131 #include <StepRepr_CompositeShapeAspect.hxx>
132 #include <StepRepr_AllAroundShapeAspect.hxx>
133 #include <StepRepr_CompShAspAndDatumFeatAndShAsp.hxx>
134 #include <StepRepr_ShapeAspectRelationship.hxx>
135 #include <StepRepr_ShapeRepresentationRelationship.hxx>
136 #include <StepRepr_SpecifiedHigherUsageOccurrence.hxx>
137 #include <StepRepr_ValueRange.hxx>
138 #include <StepRepr_FeatureForDatumTargetRelationship.hxx>
139 #include <StepShape_AdvancedFace.hxx>
140 #include <StepShape_AdvancedBrepShapeRepresentation.hxx>
141 #include <StepShape_AngleRelator.hxx>
142 #include <StepShape_AngularSize.hxx>
143 #include <StepShape_AngularLocation.hxx>
144 #include <StepShape_ClosedShell.hxx>
145 #include <StepShape_ConnectedFaceSet.hxx>
146 #include <StepShape_ContextDependentShapeRepresentation.hxx>
147 #include <StepRepr_CompGroupShAspAndCompShAspAndDatumFeatAndShAsp.hxx>
148 #include <StepRepr_CompShAspAndDatumFeatAndShAsp.hxx>
149 #include <StepShape_DimensionalCharacteristicRepresentation.hxx>
150 #include <StepShape_DimensionalSizeWithPath.hxx>
151 #include <StepShape_DimensionalLocationWithPath.hxx>
152 #include <StepShape_ShapeDimensionRepresentationItem.hxx>
153 #include <StepShape_ShapeRepresentationWithParameters.hxx>
154 #include <StepShape_HArray1OfShapeDimensionRepresentationItem.hxx>
155 #include <StepShape_DimensionalSize.hxx>
156 #include <StepShape_DimensionalLocation.hxx>
157 #include <StepShape_EdgeCurve.hxx>
158 #include <StepShape_EdgeLoop.hxx>
159 #include <StepShape_GeometricCurveSet.hxx>
160 #include <StepShape_GeometricSet.hxx>
161 #include <StepShape_HArray1OfFace.hxx>
162 #include <StepShape_HArray1OfFaceBound.hxx>
163 #include <StepShape_HArray1OfOrientedEdge.hxx>
164 #include <StepShape_HArray1OfShell.hxx>
165 #include <StepShape_LimitsAndFits.hxx>
166 #include <StepShape_Loop.hxx>
167 #include <StepShape_ManifoldSolidBrep.hxx>
168 #include <StepShape_PlusMinusTolerance.hxx>
169 #include <StepShape_QualifiedRepresentationItem.hxx>
170 #include <StepShape_OpenShell.hxx>
171 #include <StepShape_ShapeDefinitionRepresentation.hxx>
172 #include <StepShape_ShapeDimensionRepresentation.hxx>
173 #include <StepShape_ShapeRepresentation.hxx>
174 #include <StepShape_ShellBasedSurfaceModel.hxx>
175 #include <StepShape_SolidModel.hxx>
176 #include <StepShape_ToleranceMethodDefinition.hxx>
177 #include <StepShape_ToleranceValue.hxx>
178 #include <StepShape_ValueFormatTypeQualifier.hxx>
179 #include <StepShape_Vertex.hxx>
180 #include <StepToGeom.hxx>
181 #include <StepVisual_AnnotationCurveOccurrence.hxx>
182 #include <StepVisual_AnnotationFillArea.hxx>
183 #include <StepVisual_AnnotationPlane.hxx>
184 #include <StepVisual_CameraModelD3.hxx>
185 #include <StepVisual_CameraModelD3MultiClipping.hxx>
186 #include <StepVisual_CameraModelD3MultiClippingIntersection.hxx>
187 #include <StepVisual_CameraModelD3MultiClippingUnion.hxx>
188 #include <StepVisual_CoordinatesList.hxx>
189 #include <StepVisual_HArray1OfCameraModelD3MultiClippingInterectionSelect.hxx>
190 #include <StepVisual_HArray1OfCameraModelD3MultiClippingUnionSelect.hxx>
191 #include <StepVisual_DraughtingCallout.hxx>
192 #include <StepVisual_DraughtingCalloutElement.hxx>
193 #include <StepVisual_DraughtingModel.hxx>
194 #include <StepVisual_Invisibility.hxx>
195 #include <StepVisual_LayeredItem.hxx>
196 #include <StepVisual_PlanarBox.hxx>
197 #include <StepVisual_PresentationLayerAssignment.hxx>
198 #include <StepVisual_PresentationStyleByContext.hxx>
199 #include <StepVisual_StyleContextSelect.hxx>
200 #include <StepVisual_StyledItem.hxx>
201 #include <StepVisual_ViewVolume.hxx>
202 #include <StepShape_TypeQualifier.hxx>
203 #include <TCollection_AsciiString.hxx>
204 #include <TCollection_HAsciiString.hxx>
205 #include <TColStd_HArray1OfReal.hxx>
206 #include <TColStd_HArray1OfTransient.hxx>
207 #include <TColStd_HSequenceOfTransient.hxx>
208 #include <TColStd_IndexedDataMapOfTransientTransient.hxx>
209 #include <TColStd_MapIteratorOfMapOfTransient.hxx>
210 #include <TColStd_MapOfTransient.hxx>
211 #include <TColStd_SequenceOfHAsciiString.hxx>
212 #include <TDataStd_Name.hxx>
213 #include <TDataStd_TreeNode.hxx>
214 #include <TDataStd_UAttribute.hxx>
215 #include <TDF_Label.hxx>
216 #include <TDF_Tool.hxx>
217 #include <TDocStd_Document.hxx>
218 #include <TNaming_NamedShape.hxx>
219 #include <TopExp_Explorer.hxx>
220 #include <TopoDS.hxx>
221 #include <TopoDS_Compound.hxx>
222 #include <TopoDS_Iterator.hxx>
223 #include <TopoDS_Shape.hxx>
224 #include <TopTools_ListIteratorOfListOfShape.hxx>
225 #include <TopTools_ListOfShape.hxx>
226 #include <TopTools_MapOfShape.hxx>
227 #include <Transfer_Binder.hxx>
228 #include <Transfer_TransientProcess.hxx>
229 #include <TransferBRep.hxx>
230 #include <XCAFDoc.hxx>
231 #include <XCAFDoc_Area.hxx>
232 #include <XCAFDoc_Centroid.hxx>
233 #include <XCAFDoc_ClippingPlaneTool.hxx>
234 #include <XCAFDoc_ColorTool.hxx>
235 #include <XCAFDoc_DataMapOfShapeLabel.hxx>
236 #include <XCAFDoc_DimTolTool.hxx>
237 #include <XCAFDoc_Dimension.hxx>
238 #include <XCAFDoc_Datum.hxx>
239 #include <XCAFDoc_GeomTolerance.hxx>
240 #include <XCAFDoc_DocumentTool.hxx>
241 #include <XCAFDoc_GraphNode.hxx>
242 #include <XCAFDoc_LayerTool.hxx>
243 #include <XCAFDoc_MaterialTool.hxx>
244 #include <XCAFDoc_ShapeTool.hxx>
245 #include <XCAFDoc_View.hxx>
246 #include <XCAFDoc_ViewTool.hxx>
247 #include <XCAFDoc_Volume.hxx>
248 #include <XCAFDimTolObjects_DimensionModifiersSequence.hxx>
249 #include <XCAFDimTolObjects_GeomToleranceType.hxx>
250 #include <XCAFDimTolObjects_DimensionObject.hxx>
251 #include <XCAFDimTolObjects_GeomToleranceObject.hxx>
252 #include <XCAFDimTolObjects_DatumObject.hxx>
253 #include <XCAFView_Object.hxx>
254 #include <XSControl_TransferReader.hxx>
255 #include <XSControl_WorkSession.hxx>
256 #include <StepAP242_DraughtingModelItemAssociation.hxx>
257 #include <StepAP242_GeometricItemSpecificUsage.hxx>
258 #include <StepGeom_CartesianPoint.hxx>
259 #include <STEPCAFControl_GDTProperty.hxx>
260 #include <StepVisual_TessellatedAnnotationOccurrence.hxx>
261 #include <StepVisual_TessellatedAnnotationOccurrence.hxx>
262 #include <StepVisual_TessellatedItem.hxx>
263 #include <StepVisual_TessellatedGeometricSet.hxx>
264 #include <StepVisual_TessellatedCurveSet.hxx>
265 #include <StepVisual_CoordinatesList.hxx>
266 #include <NCollection_Vector.hxx>
268 #include <TColgp_HArray1OfXYZ.hxx>
269 #include <BRepBuilderAPI_MakeEdge.hxx>
270 #include <BRepTools.hxx>
271 #include <Transfer_ActorOfTransientProcess.hxx>
272 #include <Bnd_Box.hxx>
273 #include <BRepBndLib.hxx>
275 // skl 21.08.2003 for reading G&DT
276 //#include <StepRepr_CompoundItemDefinition.hxx>
277 //#include <StepRepr_CompoundItemDefinitionMember.hxx>
278 //#include <StepBasic_ConversionBasedUnit.hxx>
279 //#include <TDataStd_Real.hxx>
280 //#include <TDataStd_Constraint.hxx>
281 //#include <TDataStd_ConstraintEnum.hxx>
282 //#include <TNaming_Tool.hxx>
283 //#include <AIS_InteractiveObject.hxx>
284 //#include <TPrsStd_ConstraintTools.hxx>
285 //#include <AIS_DiameterDimension.hxx>
286 //#include <TPrsStd_Position.hxx>
287 //#include <TPrsStd_AISPresentation.hxx>
288 //#include <TNaming_Builder.hxx>
290 //! Converts address of the passed shape (TShape) to string.
291 //! \param theShape [in] Shape to dump.
292 //! \return corresponding string.
293 TCollection_AsciiString AddrToString(const TopoDS_Shape& theShape)
295 std::string anAddrStr;
296 std::ostringstream ost;
297 ost << theShape.TShape().get();
298 anAddrStr = ost.str();
300 TCollection_AsciiString aStr =
301 TCollection_AsciiString("[").Cat( anAddrStr.c_str() ).Cat("]");
307 //=======================================================================
308 //function : AllocateSubLabel
310 //=======================================================================
312 static TDF_Label AllocateSubLabel(TDF_Label& theRoot)
314 return TDF_TagSource::NewChild(theRoot);
317 //=======================================================================
318 //function : STEPCAFControl_Reader
320 //=======================================================================
322 STEPCAFControl_Reader::STEPCAFControl_Reader ():
323 myColorMode( Standard_True ),
324 myNameMode ( Standard_True ),
325 myLayerMode( Standard_True ),
326 myPropsMode( Standard_True ),
327 mySHUOMode ( Standard_False ),
328 myGDTMode ( Standard_True ),
329 myMatMode(Standard_True),
330 myViewMode(Standard_True)
332 STEPCAFControl_Controller::Init();
336 //=======================================================================
337 //function : STEPCAFControl_Reader
339 //=======================================================================
341 STEPCAFControl_Reader::STEPCAFControl_Reader (const Handle(XSControl_WorkSession)& WS,
342 const Standard_Boolean scratch) :
343 myColorMode( Standard_True ),
344 myNameMode ( Standard_True ),
345 myLayerMode( Standard_True ),
346 myPropsMode( Standard_True ),
347 mySHUOMode ( Standard_False ),
348 myGDTMode ( Standard_True ),
349 myMatMode(Standard_True),
350 myViewMode(Standard_True)
352 STEPCAFControl_Controller::Init();
353 Init ( WS, scratch );
357 //=======================================================================
360 //=======================================================================
362 void STEPCAFControl_Reader::Init (const Handle(XSControl_WorkSession)& WS,
363 const Standard_Boolean scratch)
365 // necessary only in Writer, to set good actor: WS->SelectNorm ( "STEP" );
366 myReader.SetWS (WS,scratch);
371 //=======================================================================
372 //function : ReadFile
374 //=======================================================================
376 IFSelect_ReturnStatus STEPCAFControl_Reader::ReadFile (const Standard_CString filename)
378 return myReader.ReadFile ( filename );
382 //=======================================================================
383 //function : NbRootsForTransfer
385 //=======================================================================
387 Standard_Integer STEPCAFControl_Reader::NbRootsForTransfer ()
389 return myReader.NbRootsForTransfer();
393 //=======================================================================
394 //function : TransferOneRoot
396 //=======================================================================
398 Standard_Boolean STEPCAFControl_Reader::TransferOneRoot (const Standard_Integer num,
399 Handle(TDocStd_Document) &doc)
401 TDF_LabelSequence Lseq;
402 return Transfer ( myReader, num, doc, Lseq );
406 //=======================================================================
407 //function : Transfer
409 //=======================================================================
411 Standard_Boolean STEPCAFControl_Reader::Transfer (Handle(TDocStd_Document) &doc)
413 TDF_LabelSequence Lseq;
414 return Transfer ( myReader, 0, doc, Lseq );
418 //=======================================================================
421 //=======================================================================
423 Standard_Boolean STEPCAFControl_Reader::Perform (const Standard_CString filename,
424 Handle(TDocStd_Document) &doc)
426 if ( ReadFile ( filename ) != IFSelect_RetDone ) return Standard_False;
427 return Transfer ( doc );
431 //=======================================================================
434 //=======================================================================
436 Standard_Boolean STEPCAFControl_Reader::Perform (const TCollection_AsciiString &filename,
437 Handle(TDocStd_Document) &doc)
439 if ( ReadFile ( filename.ToCString() ) != IFSelect_RetDone ) return Standard_False;
440 return Transfer ( doc );
444 //=======================================================================
445 //function : ExternFiles
447 //=======================================================================
449 const NCollection_DataMap<TCollection_AsciiString, Handle(STEPCAFControl_ExternFile)>& STEPCAFControl_Reader::ExternFiles () const
455 //=======================================================================
456 //function : ExternFile
458 //=======================================================================
460 Standard_Boolean STEPCAFControl_Reader::ExternFile (const Standard_CString name,
461 Handle(STEPCAFControl_ExternFile) &ef) const
464 if ( myFiles.IsEmpty() || !myFiles.IsBound ( name ) )
465 return Standard_False;
466 ef = myFiles.Find ( name );
467 return Standard_True;
471 //=======================================================================
474 //=======================================================================
476 STEPControl_Reader &STEPCAFControl_Reader::ChangeReader ()
482 //=======================================================================
485 //=======================================================================
487 const STEPControl_Reader &STEPCAFControl_Reader::Reader () const
493 //=======================================================================
494 //function : FillShapesMap
495 //purpose : auxiliary: fill a map by all compounds and their components
496 //=======================================================================
498 static void FillShapesMap (const TopoDS_Shape &S, TopTools_MapOfShape &map)
504 if ( S.ShapeType() != TopAbs_COMPOUND ) return;
505 for ( TopoDS_Iterator it(S); it.More(); it.Next() )
506 FillShapesMap ( it.Value(), map );
510 //=======================================================================
511 //function : Transfer
512 //purpose : basic working method
513 //=======================================================================
515 Standard_Boolean STEPCAFControl_Reader::Transfer (STEPControl_Reader &reader,
516 const Standard_Integer nroot,
517 Handle(TDocStd_Document) &doc,
518 TDF_LabelSequence &Lseq,
519 const Standard_Boolean asOne)
521 reader.ClearShapes();
525 Standard_Integer num = reader.NbRootsForTransfer();
526 if ( num <=0 ) return Standard_False;
528 if ( nroot > num ) return Standard_False;
529 reader.TransferOneRoot ( nroot );
532 for ( i=1; i <= num; i++ ) reader.TransferOneRoot ( i );
534 num = reader.NbShapes();
535 if ( num <=0 ) return Standard_False;
537 // Fill a map of (top-level) shapes resulting from that transfer
538 // Only these shapes will be considered further
539 TopTools_MapOfShape ShapesMap, NewShapesMap;
540 for ( i=1; i <= num; i++ ) FillShapesMap ( reader.Shape(i), ShapesMap );
542 // Collect information on shapes originating from SDRs
543 // this will be used to distinguish compounds representing assemblies
544 // from the ones representing hybrid models and shape sets
545 STEPCAFControl_DataMapOfShapePD ShapePDMap;
546 STEPCAFControl_DataMapOfPDExternFile PDFileMap;
547 Handle(Interface_InterfaceModel) Model = reader.Model();
548 const Handle(Transfer_TransientProcess) &TP = reader.WS()->TransferReader()->TransientProcess();
549 Standard_Integer nb = Model->NbEntities();
551 Handle(TColStd_HSequenceOfTransient) SeqPDS = new TColStd_HSequenceOfTransient;
553 for (i = 1; i <= nb; i ++) {
554 Handle(Standard_Transient) enti = Model->Value(i);
555 if(enti->IsKind(STANDARD_TYPE(StepRepr_ProductDefinitionShape))) {
556 // sequence for acceleration ReadMaterials
557 SeqPDS->Append(enti);
559 if ( enti->IsKind ( STANDARD_TYPE(StepBasic_ProductDefinition ) ) ) {
560 Handle(StepBasic_ProductDefinition) PD =
561 Handle(StepBasic_ProductDefinition)::DownCast(enti);
562 Standard_Integer index = TP->MapIndex(PD);
564 Handle(Transfer_Binder) binder = TP->MapItem (index);
565 TopoDS_Shape S = TransferBRep::ShapeResult(binder);
566 if ( ! S.IsNull() && ShapesMap.Contains(S) ) {
568 ShapePDMap.Bind ( S, PD );
569 Handle(STEPCAFControl_ExternFile) EF;
570 PDFileMap.Bind ( PD, EF );
574 if ( enti->IsKind ( STANDARD_TYPE(StepShape_ShapeRepresentation) ) ) {
575 Standard_Integer index = TP->MapIndex(enti);
577 Handle(Transfer_Binder) binder = TP->MapItem (index);
578 TopoDS_Shape S = TransferBRep::ShapeResult(binder);
579 if ( ! S.IsNull() && ShapesMap.Contains(S) )
585 // get directory name of the main file
586 OSD_Path mainfile ( reader.WS()->LoadedFile() );
587 mainfile.SetName ( "" );
588 mainfile.SetExtension ( "" );
589 TCollection_AsciiString dpath;
590 mainfile.SystemName ( dpath );
592 // Load external references (only for relevant SDRs)
593 // and fill map SDR -> extern file
594 STEPConstruct_ExternRefs ExtRefs ( reader.WS() );
595 ExtRefs.LoadExternRefs();
596 for ( i=1; i <= ExtRefs.NbExternRefs(); i++ ) {
597 // check extern ref format
598 Handle(TCollection_HAsciiString) format = ExtRefs.Format(i);
599 if ( ! format.IsNull() ) {
600 static Handle(TCollection_HAsciiString) ap203 = new TCollection_HAsciiString ( "STEP AP203" );
601 static Handle(TCollection_HAsciiString) ap214 = new TCollection_HAsciiString ( "STEP AP214" );
602 if ( ! format->IsSameString ( ap203, Standard_False ) &&
603 ! format->IsSameString ( ap214, Standard_False ) ) {
605 cout << "Warning: STEPCAFControl_Reader::Transfer: Extern document is neither STEP AP203 nor AP214" << endl;
612 else cout << "Warning: STEPCAFControl_Reader::Transfer: Extern document format not defined" << endl;
615 // get and check filename of the current extern ref
616 const Standard_CString filename = ExtRefs.FileName(i);
619 cout<<"filename="<<filename<<endl;
622 if ( ! filename || ! filename[0] ) {
624 cout << "Warning: STEPCAFControl_Reader::Transfer: Extern reference file name is empty" << endl;
626 continue; // not a valid extern ref
629 // compute true path to the extern file
630 TCollection_AsciiString fullname = OSD_Path::AbsolutePath ( dpath, filename );
631 if ( fullname.Length() <= 0 ) fullname = filename;
635 char *mainfile = reader.WS()->LoadedFile();
636 if ( ! mainfile ) mainfile = "";
637 Standard_Integer slash = 0;
638 for ( Standard_Integer k=0; mainfile[k]; k++ )
639 if ( mainfile[k] == '/' ) slash = k;
640 strncpy ( fullname, mainfile, slash );
641 sprintf ( &fullname[slash], "%s%s", ( mainfile[0] ? "/" : "" ), filename );
644 // get and check PD associated with the current extern ref
645 Handle(StepBasic_ProductDefinition) PD = ExtRefs.ProdDef(i);
646 if ( PD.IsNull() ) continue; // not a valid extern ref
647 if ( ! PDFileMap.IsBound ( PD ) ) continue; // this PD is not concerned by current transfer
649 // read extern file (or use existing data) and record its data
650 Handle(STEPCAFControl_ExternFile) EF =
651 ReadExternFile ( filename, fullname.ToCString(), doc );
652 PDFileMap.Bind ( PD, EF );
655 // and insert them to the document
656 Handle(XCAFDoc_ShapeTool) STool = XCAFDoc_DocumentTool::ShapeTool( doc->Main() );
657 if ( STool.IsNull() ) return Standard_False;
658 XCAFDoc_DataMapOfShapeLabel map;
660 Lseq.Append ( AddShape ( reader.OneShape(), STool, NewShapesMap, ShapePDMap, PDFileMap, map ) );
662 for ( i=1; i <= num; i++ ) {
663 Lseq.Append ( AddShape ( reader.Shape(i), STool, NewShapesMap, ShapePDMap, PDFileMap, map ) );
668 if ( GetColorMode() )
669 ReadColors ( reader.WS(), doc, PDFileMap, map );
673 ReadNames ( reader.WS(), doc, PDFileMap, map );
675 // read validation props
676 if ( GetPropsMode() )
677 ReadValProps ( reader.WS(), doc, PDFileMap, map );
680 if ( GetLayerMode() )
681 ReadLayers ( reader.WS(), doc );
683 // read SHUO entities from STEP model
685 ReadSHUOs ( reader.WS(), doc, PDFileMap, map );
687 // read GDT entities from STEP model
689 ReadGDTs(reader.WS(),doc);
691 // read Material entities from STEP model
693 ReadMaterials(reader.WS(),doc,SeqPDS);
695 // read View entities from STEP model
697 ReadViews(reader.WS(), doc);
699 // Expand resulting CAF structure for sub-shapes (optionally with their
700 // names) if requested
701 ExpandSubShapes(STool, map, ShapePDMap);
703 // Update assembly compounds
704 STool->UpdateAssemblies();
706 return Standard_True;
709 //=======================================================================
710 //function : AddShape
712 //=======================================================================
714 TDF_Label STEPCAFControl_Reader::AddShape (const TopoDS_Shape &S,
715 const Handle(XCAFDoc_ShapeTool) &STool,
716 const TopTools_MapOfShape &NewShapesMap,
717 const STEPCAFControl_DataMapOfShapePD &ShapePDMap,
718 const STEPCAFControl_DataMapOfPDExternFile &PDFileMap,
719 XCAFDoc_DataMapOfShapeLabel &ShapeLabelMap) const
721 // if shape has already been mapped, just return corresponding label
722 if ( ShapeLabelMap.IsBound ( S ) ) {
723 return ShapeLabelMap.Find ( S );
726 // if shape is located, create instance
727 if ( ! S.Location().IsIdentity() ) {
731 AddShape ( S0, STool, NewShapesMap, ShapePDMap, PDFileMap, ShapeLabelMap );
732 TDF_Label L = STool->AddShape ( S, Standard_False ); // should create reference
733 ShapeLabelMap.Bind ( S, L );
737 // if shape is not compound, simple add it
738 if ( S.ShapeType() != TopAbs_COMPOUND ) {
739 TDF_Label L = STool->AddShape ( S, Standard_False );
740 ShapeLabelMap.Bind ( S, L );
744 // for compounds, compute number of subshapes and check whether this is assembly
745 Standard_Boolean isAssembly = Standard_False;
746 Standard_Integer nbComponents = 0;
748 for ( it.Initialize(S); it.More(); it.Next(), nbComponents++ ) {
749 TopoDS_Shape Sub0 = it.Value();
751 Sub0.Location ( loc );
752 if ( NewShapesMap.Contains ( Sub0 ) ) isAssembly = Standard_True;
755 // if(nbComponents>0) isAssembly = Standard_True;
757 // check whether it has associated external ref
758 TColStd_SequenceOfHAsciiString SHAS;
759 if ( ShapePDMap.IsBound ( S ) && PDFileMap.IsBound ( ShapePDMap.Find(S) ) ) {
760 Handle(STEPCAFControl_ExternFile) EF = PDFileMap.Find ( ShapePDMap.Find(S) );
761 if ( ! EF.IsNull() ) {
762 // (store information on extern refs in the document)
763 SHAS.Append(EF->GetName());
764 // if yes, just return corresponding label
765 if ( ! EF->GetLabel().IsNull() ) {
766 // but if components >0, ignore extern ref!
767 if ( nbComponents <=0 ) {
768 ShapeLabelMap.Bind ( S, EF->GetLabel() );
769 STool->SetExternRefs(EF->GetLabel(),SHAS);
770 return EF->GetLabel();
774 if ( ! EF->GetLabel().IsNull() )
775 cout << "Warning: STEPCAFControl_Reader::AddShape: Non-empty shape with external ref; ref is ignored" << endl;
776 else if ( nbComponents <=0 )
777 cout << "Warning: STEPCAFControl_Reader::AddShape: Result of reading extern ref is Null" << endl;
782 // add compound either as a whole,
783 if ( ! isAssembly ) {
784 TDF_Label L = STool->AddShape ( S, Standard_False );
785 if ( SHAS.Length() >0 ) STool->SetExternRefs(L,SHAS);
786 ShapeLabelMap.Bind ( S, L );
790 // or as assembly, component-by-component
791 TDF_Label L = STool->NewShape();
792 for ( it.Initialize(S); it.More(); it.Next(), nbComponents++ ) {
793 TopoDS_Shape Sub0 = it.Value();
795 Sub0.Location ( loc );
796 TDF_Label subL = AddShape ( Sub0, STool, NewShapesMap, ShapePDMap, PDFileMap, ShapeLabelMap );
797 if ( ! subL.IsNull() ) {
798 STool->AddComponent ( L, subL, it.Value().Location() );
801 if ( SHAS.Length() >0 ) STool->SetExternRefs(L,SHAS);
802 ShapeLabelMap.Bind ( S, L );
803 //STool->SetShape ( L, S ); // it is necessary for assemblies OCC1747 // commemted by skl for OCC2941
808 //=======================================================================
809 //function : ReadExternFile
811 //=======================================================================
813 Handle(STEPCAFControl_ExternFile) STEPCAFControl_Reader::ReadExternFile (const Standard_CString file,
814 const Standard_CString fullname,
815 Handle(TDocStd_Document)& doc)
817 // if the file is already read, associate it with SDR
818 if ( myFiles.IsBound ( file ) ) {
819 return myFiles.ChangeFind ( file );
823 cout << "Reading extern file: " << fullname << endl;
826 // create new WorkSession and Reader
827 Handle(XSControl_WorkSession) newWS = new XSControl_WorkSession;
828 newWS->SelectNorm ( "STEP" );
829 STEPControl_Reader sr ( newWS, Standard_False );
831 // start to fill the resulting ExternFile structure
832 Handle(STEPCAFControl_ExternFile) EF = new STEPCAFControl_ExternFile;
834 EF->SetName ( new TCollection_HAsciiString ( file ) );
837 EF->SetLoadStatus ( sr.ReadFile ( fullname ) );
839 // transfer in single-result mode
840 if ( EF->GetLoadStatus() == IFSelect_RetDone ) {
841 TDF_LabelSequence labels;
842 EF->SetTransferStatus ( Transfer ( sr, 0, doc, labels, Standard_True ) );
843 if ( labels.Length() >0 ) EF->SetLabel ( labels.Value(1) );
846 // add read file to dictionary
847 myFiles.Bind( file, EF );
853 //=======================================================================
854 //function : SetColorToSubshape
856 //=======================================================================
857 static void SetColorToSubshape(const Handle(XCAFDoc_ColorTool) & CTool,
858 const TopoDS_Shape & S,
859 const Quantity_Color& col,
860 const XCAFDoc_ColorType type)
862 for (TopoDS_Iterator it(S); it.More(); it.Next())
863 if (! CTool->SetColor( it.Value(), col, type)) break;
867 //=======================================================================
868 //function : findStyledSR
870 //=======================================================================
871 static void findStyledSR (const Handle(StepVisual_StyledItem) &style,
872 Handle(StepShape_ShapeRepresentation)& aSR)
874 // search Shape Represenatation for component styled item
875 for ( Standard_Integer j=1; j <= style->NbStyles(); j++ ) {
876 Handle(StepVisual_PresentationStyleByContext) PSA =
877 Handle(StepVisual_PresentationStyleByContext)::DownCast(style->StylesValue ( j ));
880 StepVisual_StyleContextSelect aStyleCntxSlct = PSA->StyleContext();
881 Handle(StepShape_ShapeRepresentation) aCurrentSR =
882 Handle(StepShape_ShapeRepresentation)::DownCast(aStyleCntxSlct.Representation());
883 if ( aCurrentSR.IsNull() )
891 //=======================================================================
892 //function : ReadColors
894 //=======================================================================
896 Standard_Boolean STEPCAFControl_Reader::ReadColors (const Handle(XSControl_WorkSession) &WS,
897 Handle(TDocStd_Document)& Doc,
898 const STEPCAFControl_DataMapOfPDExternFile &PDFileMap,
899 const XCAFDoc_DataMapOfShapeLabel &ShapeLabelMap) const
901 STEPConstruct_Styles Styles ( WS );
902 if ( ! Styles.LoadStyles() ) {
904 cout << "Warning: no styles are found in the model" << endl;
906 return Standard_False;
908 // searching for invisible items in the model
909 Handle(TColStd_HSequenceOfTransient) aHSeqOfInvisStyle = new TColStd_HSequenceOfTransient;
910 Styles.LoadInvisStyles( aHSeqOfInvisStyle );
912 Handle(XCAFDoc_ColorTool) CTool = XCAFDoc_DocumentTool::ColorTool( Doc->Main() );
913 if ( CTool.IsNull() ) return Standard_False;
915 // parse and search for color attributes
916 Standard_Integer nb = Styles.NbStyles();
917 for ( Standard_Integer i=1; i <= nb; i++ ) {
918 Handle(StepVisual_StyledItem) style = Styles.Style ( i );
919 if ( style.IsNull() ) continue;
921 Standard_Boolean IsVisible = Standard_True;
922 // check the visibility of styled item.
923 for (Standard_Integer si = 1; si <= aHSeqOfInvisStyle->Length(); si++ ) {
924 if ( style != aHSeqOfInvisStyle->Value( si ) )
926 // found that current style is invisible.
927 IsVisible = Standard_False;
931 Handle(StepVisual_Colour) SurfCol, BoundCol, CurveCol;
932 // check if it is component style
933 Standard_Boolean IsComponent = Standard_False;
934 if ( ! Styles.GetColors ( style, SurfCol, BoundCol, CurveCol, IsComponent ) && IsVisible )
938 NCollection_Vector<Handle(Standard_Transient)> anItems;
939 if (!style->Item().IsNull()) {
940 anItems.Append(style->Item());
942 else if (!style->ItemAP242().Representation().IsNull()){
943 //special case for AP242: item can be Reprsentation
944 Handle(StepRepr_Representation) aRepr = style->ItemAP242().Representation();
945 for (Standard_Integer j = 1; j <= aRepr->Items()->Length(); j++)
946 anItems.Append(aRepr->Items()->Value(j));
948 for (Standard_Integer itemIt = 0; itemIt < anItems.Length(); itemIt++) {
949 TopoDS_Shape S = STEPConstruct::FindShape ( Styles.TransientProcess(),
950 Handle(StepRepr_RepresentationItem)::DownCast(anItems.Value(itemIt)) );
951 Standard_Boolean isSkipSHUOstyle = Standard_False;
952 // take shape with real location.
953 while ( IsComponent ) {
955 Handle(StepShape_ShapeRepresentation) aSR;
956 findStyledSR( style, aSR );
957 // search for SR along model
960 Interface_EntityIterator subs = WS->HGraph()->Graph().Sharings( aSR );
961 Handle(StepShape_ShapeDefinitionRepresentation) aSDR;
962 for (subs.Start(); subs.More(); subs.Next()) {
963 aSDR = Handle(StepShape_ShapeDefinitionRepresentation)::DownCast(subs.Value());
966 StepRepr_RepresentedDefinition aPDSselect = aSDR->Definition();
967 Handle(StepRepr_ProductDefinitionShape) PDS =
968 Handle(StepRepr_ProductDefinitionShape)::DownCast(aPDSselect.PropertyDefinition());
971 StepRepr_CharacterizedDefinition aCharDef = PDS->Definition();
973 Handle(StepRepr_AssemblyComponentUsage) ACU =
974 Handle(StepRepr_AssemblyComponentUsage)::DownCast(aCharDef.ProductDefinitionRelationship());
977 // PTV 10.02.2003 skip styled item that refer to SHUO
978 if (ACU->IsKind(STANDARD_TYPE(StepRepr_SpecifiedHigherUsageOccurrence))) {
979 isSkipSHUOstyle = Standard_True;
982 Handle(StepRepr_NextAssemblyUsageOccurrence) NAUO =
983 Handle(StepRepr_NextAssemblyUsageOccurrence)::DownCast(ACU);
988 // PTV 10.02.2003 to find component of assembly CORRECTLY
989 STEPConstruct_Tool Tool( WS );
990 TDF_Label aShLab = FindInstance ( NAUO, CTool->ShapeTool(), Tool, PDFileMap, ShapeLabelMap );
991 aSh = CTool->ShapeTool()->GetShape(aShLab);
1000 continue; // skip styled item which refer to SHUO
1005 if ( ! SurfCol.IsNull() ) {
1007 Styles.DecodeColor ( SurfCol, col );
1008 if ( ! CTool->SetColor ( S, col, XCAFDoc_ColorSurf ))
1009 SetColorToSubshape( CTool, S, col, XCAFDoc_ColorSurf );
1011 if ( ! BoundCol.IsNull() ) {
1013 Styles.DecodeColor ( BoundCol, col );
1014 if ( ! CTool->SetColor ( S, col, XCAFDoc_ColorCurv ))
1015 SetColorToSubshape( CTool, S, col, XCAFDoc_ColorCurv );
1017 if ( ! CurveCol.IsNull() ) {
1019 Styles.DecodeColor ( CurveCol, col );
1020 if ( ! CTool->SetColor ( S, col, XCAFDoc_ColorCurv ))
1021 SetColorToSubshape( CTool, S, col, XCAFDoc_ColorCurv );
1024 // sets the invisibility for shape.
1026 if ( CTool->ShapeTool()->Search( S, aInvL ) )
1027 CTool->SetVisibility( aInvL, Standard_False );
1031 CTool->ReverseChainsOfTreeNodes();
1032 return Standard_True;
1035 //=======================================================================
1036 //function : GetLabelFromPD
1038 //=======================================================================
1040 static TDF_Label GetLabelFromPD (const Handle(StepBasic_ProductDefinition) &PD,
1041 const Handle(XCAFDoc_ShapeTool) &STool,
1042 const Handle(Transfer_TransientProcess) &TP,
1043 const STEPCAFControl_DataMapOfPDExternFile &PDFileMap,
1044 const XCAFDoc_DataMapOfShapeLabel &ShapeLabelMap)
1047 if ( PDFileMap.IsBound ( PD ) ) {
1048 Handle(STEPCAFControl_ExternFile) EF = PDFileMap.Find ( PD );
1049 if ( ! EF.IsNull() ) {
1051 if ( ! L.IsNull() ) return L;
1056 Handle(Transfer_Binder) binder = TP->Find(PD);
1057 if ( binder.IsNull() || ! binder->HasResult() ) return L;
1058 S = TransferBRep::ShapeResult ( TP, binder );
1059 if ( S.IsNull() ) return L;
1061 if ( S.IsNull() ) return L;
1062 if ( ShapeLabelMap.IsBound ( S ) )
1063 L = ShapeLabelMap.Find ( S );
1065 STool->Search ( S, L, Standard_True, Standard_True, Standard_False );
1069 //=======================================================================
1070 //function : FindInstance
1072 //=======================================================================
1074 TDF_Label STEPCAFControl_Reader::FindInstance (const Handle(StepRepr_NextAssemblyUsageOccurrence) &NAUO,
1075 const Handle(XCAFDoc_ShapeTool) &STool,
1076 const STEPConstruct_Tool &Tool,
1077 const STEPCAFControl_DataMapOfPDExternFile &PDFileMap,
1078 const XCAFDoc_DataMapOfShapeLabel &ShapeLabelMap)
1082 // get shape resulting from CDSR (in fact, only location is interesting)
1083 Handle(Transfer_TransientProcess) TP = Tool.TransientProcess();
1084 Handle(Transfer_Binder) binder = TP->Find(NAUO);
1085 if ( binder.IsNull() || ! binder->HasResult() ) {
1087 cout << "Error: STEPCAFControl_Reader::FindInstance: NAUO is not mapped to shape" << endl;
1092 TopoDS_Shape S = TransferBRep::ShapeResult ( TP, binder );
1095 cout << "Error: STEPCAFControl_Reader::FindInstance: NAUO is not mapped to shape" << endl;
1100 // find component`s original label
1101 Handle(StepBasic_ProductDefinition) PD = NAUO->RelatedProductDefinition();
1102 if ( PD.IsNull() ) return L;
1103 TDF_Label Lref = GetLabelFromPD ( PD, STool, TP, PDFileMap, ShapeLabelMap );
1104 if ( Lref.IsNull() ) return L;
1106 // find main shape (assembly) label
1108 PD = NAUO->RelatingProductDefinition();
1109 if ( PD.IsNull() ) return L;
1110 TDF_Label L0 = GetLabelFromPD ( PD, STool, TP, PDFileMap, ShapeLabelMap );
1111 if ( L0.IsNull() ) return L;
1113 // if CDSR and NAUO are reversed, swap labels
1114 Handle(StepShape_ContextDependentShapeRepresentation) CDSR;
1115 Interface_EntityIterator subs1 = Tool.Graph().Sharings(NAUO);
1116 for (subs1.Start(); subs1.More(); subs1.Next()) {
1117 Handle(StepRepr_ProductDefinitionShape) PDS =
1118 Handle(StepRepr_ProductDefinitionShape)::DownCast(subs1.Value());
1119 if(PDS.IsNull()) continue;
1120 Interface_EntityIterator subs2 = Tool.Graph().Sharings(PDS);
1121 for (subs2.Start(); subs2.More(); subs2.Next()) {
1122 Handle(StepShape_ContextDependentShapeRepresentation) CDSRtmp =
1123 Handle(StepShape_ContextDependentShapeRepresentation)::DownCast(subs2.Value());
1124 if (CDSRtmp.IsNull()) continue;
1128 if (CDSR.IsNull()) return L;
1129 // if ( STEPConstruct_Assembly::CheckSRRReversesNAUO ( Tool.Model(), CDSR ) ) {
1130 // TDF_Label Lsw = L0; L0 = Lref; Lref = Lsw;
1133 // iterate on components to find proper one
1134 TDF_LabelSequence seq;
1135 XCAFDoc_ShapeTool::GetComponents ( L0, seq );
1136 for ( Standard_Integer k=1; L.IsNull() && k <= seq.Length(); k++ ) {
1137 TDF_Label Lcomp = seq(k), Lref2;
1138 if ( XCAFDoc_ShapeTool::GetReferredShape ( Lcomp, Lref2 ) &&
1140 S.Location() == XCAFDoc_ShapeTool::GetLocation ( Lcomp ) )
1147 //=======================================================================
1148 //function : ReadNames
1150 //=======================================================================
1152 Standard_Boolean STEPCAFControl_Reader::ReadNames (const Handle(XSControl_WorkSession) &WS,
1153 Handle(TDocStd_Document)& Doc,
1154 const STEPCAFControl_DataMapOfPDExternFile &PDFileMap,
1155 const XCAFDoc_DataMapOfShapeLabel &ShapeLabelMap) const
1157 // get starting data
1158 const Handle(Interface_InterfaceModel) &Model = WS->Model();
1159 const Handle(XSControl_TransferReader) &TR = WS->TransferReader();
1160 const Handle(Transfer_TransientProcess) &TP = TR->TransientProcess();
1161 Handle(XCAFDoc_ShapeTool) STool = XCAFDoc_DocumentTool::ShapeTool( Doc->Main() );
1162 if ( STool.IsNull() ) return Standard_False;
1163 STEPConstruct_Tool Tool ( WS );
1165 // iterate on model to find all SDRs and CDSRs
1166 Standard_Integer nb = Model->NbEntities();
1167 Handle(Standard_Type) tNAUO = STANDARD_TYPE(StepRepr_NextAssemblyUsageOccurrence);
1168 Handle(Standard_Type) tPD = STANDARD_TYPE(StepBasic_ProductDefinition);
1169 Handle(TCollection_HAsciiString) name;
1171 for (Standard_Integer i = 1; i <= nb; i++) {
1172 Handle(Standard_Transient) enti = Model->Value(i);
1174 // get description of NAUO
1175 if ( enti->DynamicType() == tNAUO ) {
1177 Handle(StepRepr_NextAssemblyUsageOccurrence) NAUO =
1178 Handle(StepRepr_NextAssemblyUsageOccurrence)::DownCast(enti);
1179 if(NAUO.IsNull()) continue;
1180 Interface_EntityIterator subs = WS->Graph().Sharings(NAUO);
1181 for (subs.Start(); subs.More(); subs.Next()) {
1182 Handle(StepRepr_ProductDefinitionShape) PDS =
1183 Handle(StepRepr_ProductDefinitionShape)::DownCast(subs.Value());
1184 if(PDS.IsNull()) continue;
1185 Handle(StepBasic_ProductDefinitionRelationship) PDR = PDS->Definition().ProductDefinitionRelationship();
1186 if ( PDR.IsNull() ) continue;
1187 if ( PDR->HasDescription() &&
1188 PDR->Description()->UsefullLength() >0 ) name = PDR->Description();
1189 else if ( !PDR->Name().IsNull() && PDR->Name()->UsefullLength() >0 ) name = PDR->Name();
1190 else if ( !PDR->Id().IsNull()) name = PDR->Id();
1191 else name = new TCollection_HAsciiString;
1193 // find proper label
1194 L = FindInstance ( NAUO, STool, Tool, PDFileMap, ShapeLabelMap );
1195 if ( L.IsNull() ) continue;
1196 TCollection_ExtendedString str ( name->String() );
1197 TDataStd_Name::Set ( L, str );
1200 // for PD get name of associated product
1201 if ( enti->DynamicType() == tPD ) {
1203 Handle(StepBasic_ProductDefinition) PD =
1204 Handle(StepBasic_ProductDefinition)::DownCast(enti);
1205 if(PD.IsNull()) continue;
1206 Handle(StepBasic_Product) Prod = (!PD->Formation().IsNull() ? PD->Formation()->OfProduct() : NULL);
1208 name = new TCollection_HAsciiString;
1209 else if (!Prod->Name().IsNull() && Prod->Name()->UsefullLength() > 0)
1210 name = Prod->Name();
1211 else if (!Prod->Id().IsNull())
1214 name = new TCollection_HAsciiString;
1215 L = GetLabelFromPD ( PD, STool, TP, PDFileMap, ShapeLabelMap );
1216 if ( L.IsNull() ) continue;
1217 TCollection_ExtendedString str ( name->String() );
1218 TDataStd_Name::Set ( L, str );
1220 // set a name to the document
1221 //TCollection_ExtendedString str ( name->String() );
1222 //TDataStd_Name::Set ( L, str );
1225 return Standard_True;
1228 //=======================================================================
1229 //function : GetLabelFromPD
1231 //=======================================================================
1233 static TDF_Label GetLabelFromPD (const Handle(StepBasic_ProductDefinition) &PD,
1234 const Handle(XCAFDoc_ShapeTool) &STool,
1235 const STEPConstruct_ValidationProps &Props,
1236 const STEPCAFControl_DataMapOfPDExternFile &PDFileMap,
1237 const XCAFDoc_DataMapOfShapeLabel &ShapeLabelMap)
1240 if ( PDFileMap.IsBound ( PD ) ) {
1241 Handle(STEPCAFControl_ExternFile) EF = PDFileMap.Find ( PD );
1242 if ( ! EF.IsNull() ) {
1244 if ( ! L.IsNull() ) return L;
1247 TopoDS_Shape S = Props.GetPropShape ( PD );
1248 if ( S.IsNull() ) return L;
1249 if ( ShapeLabelMap.IsBound ( S ) )
1250 L = ShapeLabelMap.Find ( S );
1252 STool->Search ( S, L, Standard_True, Standard_True, Standard_False );
1256 //=======================================================================
1257 //function : ReadValProps
1259 //=======================================================================
1261 Standard_Boolean STEPCAFControl_Reader::ReadValProps (const Handle(XSControl_WorkSession) &WS,
1262 Handle(TDocStd_Document)& Doc,
1263 const STEPCAFControl_DataMapOfPDExternFile &PDFileMap,
1264 const XCAFDoc_DataMapOfShapeLabel &ShapeLabelMap) const
1266 // get starting data
1267 const Handle(XSControl_TransferReader) &TR = WS->TransferReader();
1268 const Handle(Transfer_TransientProcess) &TP = TR->TransientProcess();
1269 Handle(XCAFDoc_ShapeTool) STool = XCAFDoc_DocumentTool::ShapeTool( Doc->Main() );
1270 if ( STool.IsNull() ) return Standard_False;
1272 // load props from the STEP model
1273 TColStd_SequenceOfTransient props;
1274 STEPConstruct_ValidationProps Props ( WS );
1275 if ( ! Props.LoadProps ( props ) ) {
1277 cout << "Warning: no validation props found in the model" << endl;
1279 return Standard_False;
1282 // interpret props one by one
1283 for (Standard_Integer i = 1; i <= props.Length(); i ++) {
1284 Handle(StepRepr_PropertyDefinitionRepresentation) PDR =
1285 Handle(StepRepr_PropertyDefinitionRepresentation)::DownCast ( props.Value(i) );
1286 if ( PDR.IsNull() ) continue;
1290 Handle(StepRepr_PropertyDefinition) PD = PDR->Definition().PropertyDefinition();
1291 Interface_EntityIterator subs = Props.Graph().Shareds(PD);
1292 for (subs.Start(); L.IsNull() && subs.More(); subs.Next()) {
1293 if ( subs.Value()->IsKind(STANDARD_TYPE(StepRepr_ProductDefinitionShape)) ) {
1294 Handle(StepRepr_ProductDefinitionShape) PDS = Handle(StepRepr_ProductDefinitionShape)::DownCast(subs.Value());
1295 if(PDS.IsNull()) continue;
1296 // find corresponding NAUO
1297 Handle(StepRepr_NextAssemblyUsageOccurrence) NAUO;
1298 Interface_EntityIterator subs1 = Props.Graph().Shareds(PDS);
1299 for (subs1.Start(); NAUO.IsNull() && subs1.More(); subs1.Next()) {
1300 if ( subs1.Value()->IsKind(STANDARD_TYPE(StepRepr_NextAssemblyUsageOccurrence)) )
1301 NAUO = Handle(StepRepr_NextAssemblyUsageOccurrence)::DownCast(subs1.Value());
1303 if ( !NAUO.IsNull() ) {
1304 L = FindInstance ( NAUO, STool, WS, PDFileMap, ShapeLabelMap );
1305 if ( L.IsNull() ) continue;
1308 // find corresponding ProductDefinition:
1309 Handle(StepBasic_ProductDefinition) ProdDef;
1310 Interface_EntityIterator subsPDS = Props.Graph().Shareds(PDS);
1311 for (subsPDS.Start(); ProdDef.IsNull() && subsPDS.More(); subsPDS.Next()) {
1312 if ( subsPDS.Value()->IsKind(STANDARD_TYPE(StepBasic_ProductDefinition)) )
1313 ProdDef = Handle(StepBasic_ProductDefinition)::DownCast(subsPDS.Value());
1315 if ( ProdDef.IsNull() ) continue;
1316 L = GetLabelFromPD ( ProdDef, STool, Props, PDFileMap, ShapeLabelMap );
1320 if ( subs.Value()->IsKind(STANDARD_TYPE(StepRepr_ShapeAspect)) ) {
1321 Handle(StepRepr_ShapeAspect) SA = Handle(StepRepr_ShapeAspect)::DownCast(subs.Value());
1322 if(SA.IsNull()) continue;
1323 // find ShapeRepresentation
1324 Handle(StepShape_ShapeRepresentation) SR;
1325 Interface_EntityIterator subs1 = Props.Graph().Sharings(SA);
1326 for(subs1.Start(); subs1.More() && SR.IsNull(); subs1.Next()) {
1327 Handle(StepRepr_PropertyDefinition) PropD1 =
1328 Handle(StepRepr_PropertyDefinition)::DownCast(subs1.Value());
1329 if(PropD1.IsNull()) continue;
1330 Interface_EntityIterator subs2 = Props.Graph().Sharings(PropD1);
1331 for(subs2.Start(); subs2.More() && SR.IsNull(); subs2.Next()) {
1332 Handle(StepShape_ShapeDefinitionRepresentation) SDR =
1333 Handle(StepShape_ShapeDefinitionRepresentation)::DownCast(subs2.Value());
1334 if(SDR.IsNull()) continue;
1335 SR = Handle(StepShape_ShapeRepresentation)::DownCast(SDR->UsedRepresentation());
1338 if(SR.IsNull()) continue;
1339 Handle(Transfer_Binder) binder;
1340 for(Standard_Integer ir=1; ir<=SR->NbItems() && binder.IsNull(); ir++) {
1341 if(SR->ItemsValue(ir)->IsKind(STANDARD_TYPE(StepShape_SolidModel))) {
1342 Handle(StepShape_SolidModel) SM =
1343 Handle(StepShape_SolidModel)::DownCast(SR->ItemsValue(ir));
1344 binder = TP->Find(SM);
1346 else if(SR->ItemsValue(ir)->IsKind(STANDARD_TYPE(StepShape_ShellBasedSurfaceModel))) {
1347 Handle(StepShape_ShellBasedSurfaceModel) SBSM =
1348 Handle(StepShape_ShellBasedSurfaceModel)::DownCast(SR->ItemsValue(ir));
1349 binder = TP->Find(SBSM);
1351 else if(SR->ItemsValue(ir)->IsKind(STANDARD_TYPE(StepShape_GeometricSet))) {
1352 Handle(StepShape_GeometricSet) GS =
1353 Handle(StepShape_GeometricSet)::DownCast(SR->ItemsValue(ir));
1354 binder = TP->Find(GS);
1357 if ( binder.IsNull() || ! binder->HasResult() ) continue;
1359 S = TransferBRep::ShapeResult ( TP, binder );
1360 if(S.IsNull()) continue;
1361 if ( ShapeLabelMap.IsBound ( S ) )
1362 L = ShapeLabelMap.Find ( S );
1364 STool->Search ( S, L, Standard_True, Standard_True, Standard_True );
1368 if(L.IsNull()) continue;
1370 // decode validation properties
1371 Handle(StepRepr_Representation) rep = PDR->UsedRepresentation();
1372 for ( Standard_Integer j=1; j <= rep->NbItems(); j++ ) {
1373 Handle(StepRepr_RepresentationItem) ent = rep->ItemsValue(j);
1374 Standard_Boolean isArea;
1377 if ( Props.GetPropReal ( ent, val, isArea ) ) {
1378 if ( isArea ) XCAFDoc_Area::Set ( L, val );
1379 else XCAFDoc_Volume::Set ( L, val );
1381 else if ( Props.GetPropPnt ( ent, rep->ContextOfItems(), pos ) ) {
1382 XCAFDoc_Centroid::Set ( L, pos );
1386 return Standard_True;
1389 //=======================================================================
1390 //function : ReadLayers
1392 //=======================================================================
1394 Standard_Boolean STEPCAFControl_Reader::ReadLayers (const Handle(XSControl_WorkSession) &WS,
1395 Handle(TDocStd_Document)& Doc) const
1397 const Handle(Interface_InterfaceModel) &Model = WS->Model();
1398 const Handle(XSControl_TransferReader) &TR = WS->TransferReader();
1399 const Handle(Transfer_TransientProcess) &TP = TR->TransientProcess();
1400 Handle(XCAFDoc_ShapeTool) STool = XCAFDoc_DocumentTool::ShapeTool( Doc->Main() );
1401 if ( STool.IsNull() ) return Standard_False;
1402 Handle(XCAFDoc_LayerTool) LTool = XCAFDoc_DocumentTool::LayerTool( Doc->Main() );
1403 if ( LTool.IsNull() ) return Standard_False;
1405 Handle(Standard_Type) tSVPLA = STANDARD_TYPE(StepVisual_PresentationLayerAssignment);
1406 Standard_Integer nb = Model->NbEntities();
1407 Handle(TCollection_HAsciiString) name;
1409 for (Standard_Integer i = 1; i <= nb; i ++) {
1410 Handle(Standard_Transient) enti = Model->Value(i);
1411 if ( ! enti->IsKind ( tSVPLA ) ) continue;
1412 Handle(StepVisual_PresentationLayerAssignment) SVPLA =
1413 Handle(StepVisual_PresentationLayerAssignment)::DownCast(enti);
1414 if (SVPLA->AssignedItems().IsNull())
1417 Handle(TCollection_HAsciiString) descr = SVPLA->Description();
1418 Handle(TCollection_HAsciiString) hName = SVPLA->Name();
1419 TCollection_ExtendedString aLayerName ( hName->String() );
1421 // find a target shape and its label in the document
1422 for (Standard_Integer j = 1; j <= SVPLA->NbAssignedItems(); j++ ) {
1423 StepVisual_LayeredItem LI = SVPLA->AssignedItemsValue(j);
1424 Handle(Transfer_Binder) binder = TP->Find( LI.Value() );
1425 if ( binder.IsNull() || ! binder->HasResult() ) continue;
1427 TopoDS_Shape S = TransferBRep::ShapeResult ( TP, binder );
1428 if ( S.IsNull() ) continue;
1431 if ( ! STool->Search ( S, shL, Standard_True, Standard_True, Standard_True ) ) continue;
1432 LTool->SetLayer ( shL, aLayerName );
1435 // check invisibility
1436 Interface_EntityIterator subs = WS->Graph().Sharings(SVPLA);
1437 for (subs.Start(); subs.More(); subs.Next()) {
1438 if ( ! subs.Value()->IsKind(STANDARD_TYPE(StepVisual_Invisibility)) ) continue;
1440 cout<< "\tLayer \"" << aLayerName << "\" is invisible"<<endl;
1442 //TDF_Label InvLayerLab = LTool->FindLayer(aLayerName);
1443 TDF_Label InvLayerLab = LTool->AddLayer(aLayerName); //skl for OCC3926
1444 Handle(TDataStd_UAttribute) aUAttr;
1445 aUAttr->Set( InvLayerLab, XCAFDoc::InvisibleGUID() );
1448 return Standard_True;
1451 //=======================================================================
1452 //function : ReadSHUOs
1454 //=======================================================================
1456 static Standard_Boolean findNextSHUOlevel (const Handle(XSControl_WorkSession) &WS,
1457 const Handle(StepRepr_SpecifiedHigherUsageOccurrence)& SHUO,
1458 const Handle(XCAFDoc_ShapeTool)& STool,
1459 const STEPCAFControl_DataMapOfPDExternFile &PDFileMap,
1460 const XCAFDoc_DataMapOfShapeLabel &ShapeLabelMap,
1461 TDF_LabelSequence& aLabels)
1463 Interface_EntityIterator subs = WS->HGraph()->Graph().Sharings(SHUO);
1464 Handle(StepRepr_SpecifiedHigherUsageOccurrence) subSHUO;
1465 for (subs.Start(); subs.More(); subs.Next()) {
1466 if (subs.Value()->IsKind(STANDARD_TYPE(StepRepr_SpecifiedHigherUsageOccurrence))) {
1467 subSHUO = Handle(StepRepr_SpecifiedHigherUsageOccurrence)::DownCast(subs.Value());
1471 if (subSHUO.IsNull())
1472 return Standard_False;
1474 Handle(StepRepr_NextAssemblyUsageOccurrence) NUNAUO = subSHUO->NextUsage();
1475 if (NUNAUO.IsNull())
1476 return Standard_False;
1477 // Handle(Interface_InterfaceModel) Model = WS->Model();
1478 // Handle(XSControl_TransferReader) TR = WS->TransferReader();
1479 // Handle(Transfer_TransientProcess) TP = TR->TransientProcess();
1480 // Handle(Transfer_Binder) binder = TP->Find(NUNAUO);
1481 // if ( binder.IsNull() || ! binder->HasResult() )
1482 // return Standard_False;
1483 // TopoDS_Shape NUSh = TransferBRep::ShapeResult ( TP, binder );
1484 // get label of NAUO next level
1486 STEPConstruct_Tool Tool( WS );
1487 NULab = STEPCAFControl_Reader::FindInstance ( NUNAUO, STool, Tool, PDFileMap, ShapeLabelMap );
1488 // STool->Search(NUSh, NUlab);
1490 return Standard_False;
1491 aLabels.Append( NULab );
1492 // and check by recurse.
1493 findNextSHUOlevel( WS, subSHUO, STool, PDFileMap, ShapeLabelMap, aLabels );
1494 return Standard_True;
1498 //=======================================================================
1499 //function : setSHUOintoDoc
1500 //purpose : auxilary
1501 //=======================================================================
1502 static TDF_Label setSHUOintoDoc (const Handle(XSControl_WorkSession) &WS,
1503 const Handle(StepRepr_SpecifiedHigherUsageOccurrence)& SHUO,
1504 const Handle(XCAFDoc_ShapeTool)& STool,
1505 const STEPCAFControl_DataMapOfPDExternFile &PDFileMap,
1506 const XCAFDoc_DataMapOfShapeLabel &ShapeLabelMap)
1508 TDF_Label aMainLabel;
1509 // get upper usage NAUO from SHUO.
1510 Handle(StepRepr_NextAssemblyUsageOccurrence) UUNAUO =
1511 Handle(StepRepr_NextAssemblyUsageOccurrence)::DownCast(SHUO->UpperUsage());
1512 Handle(StepRepr_NextAssemblyUsageOccurrence) NUNAUO = SHUO->NextUsage();
1513 if ( UUNAUO.IsNull() || NUNAUO.IsNull() ) {
1515 cout << "Warning: " << __FILE__ <<": Upper_usage or Next_usage of styled SHUO is null. Skip it" << endl;
1519 // Handle(Interface_InterfaceModel) Model = WS->Model();
1520 // Handle(XSControl_TransferReader) TR = WS->TransferReader();
1521 // Handle(Transfer_TransientProcess) TP = TR->TransientProcess();
1522 // TopoDS_Shape UUSh, NUSh;
1523 // Handle(Transfer_Binder) binder = TP->Find(UUNAUO);
1524 // if ( binder.IsNull() || ! binder->HasResult() )
1525 // return aMainLabel;
1526 // UUSh = TransferBRep::ShapeResult ( TP, binder );
1527 // binder = TP->Find(NUNAUO);
1528 // if ( binder.IsNull() || ! binder->HasResult() )
1529 // return aMainLabel;
1530 // NUSh = TransferBRep::ShapeResult ( TP, binder );
1532 // get first labels for first SHUO attribute
1533 TDF_Label UULab, NULab;
1534 STEPConstruct_Tool Tool( WS );
1535 UULab = STEPCAFControl_Reader::FindInstance ( UUNAUO, STool, Tool, PDFileMap, ShapeLabelMap );
1536 NULab = STEPCAFControl_Reader::FindInstance ( NUNAUO, STool, Tool, PDFileMap, ShapeLabelMap );
1538 // STool->Search(UUSh, UULab);
1539 // STool->Search(NUSh, NULab);
1540 if (UULab.IsNull() || NULab.IsNull()) return aMainLabel;
1541 //create sequence fo labels to set SHUO structure into the document
1542 TDF_LabelSequence ShuoLabels;
1543 ShuoLabels.Append( UULab );
1544 ShuoLabels.Append( NULab );
1545 // add all other labels of sub SHUO entities
1546 findNextSHUOlevel( WS, SHUO, STool, PDFileMap, ShapeLabelMap, ShuoLabels );
1547 // last accord for SHUO
1548 Handle(XCAFDoc_GraphNode) anSHUOAttr;
1549 if ( STool->SetSHUO( ShuoLabels, anSHUOAttr ) )
1550 aMainLabel = anSHUOAttr->Label();
1556 //=======================================================================
1557 //function : ReadSHUOs
1559 //=======================================================================
1561 Standard_Boolean STEPCAFControl_Reader::ReadSHUOs (const Handle(XSControl_WorkSession) &WS,
1562 Handle(TDocStd_Document)& Doc,
1563 const STEPCAFControl_DataMapOfPDExternFile &PDFileMap,
1564 const XCAFDoc_DataMapOfShapeLabel &ShapeLabelMap) const
1566 // the big part code duplication from ReadColors.
1567 // It is possible to share this code functionality, just to decide how ???
1568 Handle(XCAFDoc_ColorTool) CTool = XCAFDoc_DocumentTool::ColorTool( Doc->Main() );
1569 Handle(XCAFDoc_ShapeTool) STool = CTool->ShapeTool();
1571 STEPConstruct_Styles Styles ( WS );
1572 if ( ! Styles.LoadStyles() ) {
1574 cout << "Warning: no styles are found in the model" << endl;
1576 return Standard_False;
1578 // searching for invisible items in the model
1579 Handle(TColStd_HSequenceOfTransient) aHSeqOfInvisStyle = new TColStd_HSequenceOfTransient;
1580 Styles.LoadInvisStyles( aHSeqOfInvisStyle );
1581 // parse and search for color attributes
1582 Standard_Integer nb = Styles.NbStyles();
1583 for ( Standard_Integer i=1; i <= nb; i++ ) {
1584 Handle(StepVisual_StyledItem) style = Styles.Style ( i );
1585 if ( style.IsNull() ) continue;
1587 Standard_Boolean IsVisible = Standard_True;
1588 // check the visibility of styled item.
1589 for (Standard_Integer si = 1; si <= aHSeqOfInvisStyle->Length(); si++ ) {
1590 if ( style != aHSeqOfInvisStyle->Value( si ) )
1592 // found that current style is invisible.
1594 cout << "Warning: item No " << i << "(" << style->Item()->DynamicType()->Name() << ") is invisible" << endl;
1596 IsVisible = Standard_False;
1600 Handle(StepVisual_Colour) SurfCol, BoundCol, CurveCol;
1601 // check if it is component style
1602 Standard_Boolean IsComponent = Standard_False;
1603 if ( ! Styles.GetColors ( style, SurfCol, BoundCol, CurveCol, IsComponent ) && IsVisible )
1607 Handle(StepShape_ShapeRepresentation) aSR;
1608 findStyledSR( style, aSR );
1609 // search for SR along model
1612 Interface_EntityIterator subs = WS->HGraph()->Graph().Sharings( aSR );
1613 Handle(StepShape_ShapeDefinitionRepresentation) aSDR;
1614 for (subs.Start(); subs.More(); subs.Next()) {
1615 aSDR = Handle(StepShape_ShapeDefinitionRepresentation)::DownCast(subs.Value());
1616 if ( aSDR.IsNull() )
1618 StepRepr_RepresentedDefinition aPDSselect = aSDR->Definition();
1619 Handle(StepRepr_ProductDefinitionShape) PDS =
1620 Handle(StepRepr_ProductDefinitionShape)::DownCast(aPDSselect.PropertyDefinition());
1623 StepRepr_CharacterizedDefinition aCharDef = PDS->Definition();
1624 Handle(StepRepr_SpecifiedHigherUsageOccurrence) SHUO =
1625 Handle(StepRepr_SpecifiedHigherUsageOccurrence)::DownCast(aCharDef.ProductDefinitionRelationship());
1626 if ( SHUO.IsNull() )
1629 // set the SHUO structure to the document
1630 TDF_Label aLabelForStyle = setSHUOintoDoc( WS, SHUO, STool, PDFileMap, ShapeLabelMap );
1631 if ( aLabelForStyle.IsNull() ) {
1633 cout << "Warning: " << __FILE__ <<": coudnot create SHUO structure in the document" << endl;
1637 // now set the style to the SHUO main label.
1638 if ( ! SurfCol.IsNull() ) {
1640 Styles.DecodeColor ( SurfCol, col );
1641 CTool->SetColor ( aLabelForStyle, col, XCAFDoc_ColorSurf );
1643 if ( ! BoundCol.IsNull() ) {
1645 Styles.DecodeColor ( BoundCol, col );
1646 CTool->SetColor ( aLabelForStyle, col, XCAFDoc_ColorCurv );
1648 if ( ! CurveCol.IsNull() ) {
1650 Styles.DecodeColor ( CurveCol, col );
1651 CTool->SetColor ( aLabelForStyle, col, XCAFDoc_ColorCurv );
1654 // sets the invisibility for shape.
1655 CTool->SetVisibility( aLabelForStyle, Standard_False );
1657 } // end search SHUO by SDR
1658 } // end iterates on styles
1660 return Standard_True;
1664 //=======================================================================
1665 //function : GetLengthConversionFactor
1667 //=======================================================================
1668 static Standard_Boolean GetLengthConversionFactor(const Handle(StepBasic_NamedUnit)& NU,
1669 Standard_Real& afact)
1672 if( !NU->IsKind(STANDARD_TYPE(StepBasic_ConversionBasedUnitAndLengthUnit)) ) return Standard_False;
1673 Handle(StepBasic_ConversionBasedUnitAndLengthUnit) CBULU =
1674 Handle(StepBasic_ConversionBasedUnitAndLengthUnit)::DownCast(NU);
1675 Handle(StepBasic_MeasureWithUnit) MWUCBU = CBULU->ConversionFactor();
1676 afact = MWUCBU->ValueComponent();
1677 StepBasic_Unit anUnit2 = MWUCBU->UnitComponent();
1678 if(anUnit2.CaseNum(anUnit2.Value())==1) {
1679 Handle(StepBasic_NamedUnit) NU2 = anUnit2.NamedUnit();
1680 if(NU2->IsKind(STANDARD_TYPE(StepBasic_SiUnit))) {
1681 Handle(StepBasic_SiUnit) SU = Handle(StepBasic_SiUnit)::DownCast(NU2);
1682 if(SU->Name()==StepBasic_sunMetre) {
1684 afact *= STEPConstruct_UnitContext::ConvertSiPrefix (SU->Prefix());
1690 return Standard_True;
1693 //=======================================================================
1694 //function : GetLengthConversionFactorFromContext
1696 //=======================================================================
1697 static Standard_Boolean GetLengthConversionFactorFromContext(const Handle(StepRepr_RepresentationContext)& theRC,
1698 Standard_Real& theFact)
1702 return Standard_False;
1703 Handle(StepBasic_ConversionBasedUnitAndLengthUnit) aSiLU;
1704 Handle(StepGeom_GeometricRepresentationContextAndGlobalUnitAssignedContext) aCtx =
1705 Handle(StepGeom_GeometricRepresentationContextAndGlobalUnitAssignedContext)::DownCast(theRC);
1706 if (!aCtx.IsNull()) {
1707 for (Standard_Integer j = 1; j <= aCtx->NbUnits(); j++) {
1708 if (aCtx->UnitsValue(j)->IsKind(STANDARD_TYPE(StepBasic_ConversionBasedUnitAndLengthUnit))) {
1709 aSiLU = Handle(StepBasic_ConversionBasedUnitAndLengthUnit)::DownCast(aCtx->UnitsValue(j));
1714 if (aSiLU.IsNull()) {
1715 Handle(StepGeom_GeomRepContextAndGlobUnitAssCtxAndGlobUncertaintyAssCtx) aCtx1 =
1716 Handle(StepGeom_GeomRepContextAndGlobUnitAssCtxAndGlobUncertaintyAssCtx)::DownCast(theRC);
1717 if (!aCtx1.IsNull()) {
1718 for (Standard_Integer j = 1; j <= aCtx1->NbUnits(); j++) {
1719 if (aCtx1->UnitsValue(j)->IsKind(STANDARD_TYPE(StepBasic_ConversionBasedUnitAndLengthUnit))) {
1720 aSiLU = Handle(StepBasic_ConversionBasedUnitAndLengthUnit)::DownCast(aCtx1->UnitsValue(j));
1727 return Standard_False;
1728 return GetLengthConversionFactor(aSiLU, theFact);
1732 //=======================================================================
1733 //function : GetAngleConversionFactor
1735 //=======================================================================
1736 static Standard_Boolean GetAngleConversionFactor(Handle(StepBasic_NamedUnit)& NU,
1737 Standard_Real& afact)
1740 if( !NU->IsKind(STANDARD_TYPE(StepBasic_ConversionBasedUnitAndPlaneAngleUnit)) ) return Standard_False;
1741 Handle(StepBasic_ConversionBasedUnitAndPlaneAngleUnit) CBULU =
1742 Handle(StepBasic_ConversionBasedUnitAndPlaneAngleUnit)::DownCast(NU);
1743 Handle(StepBasic_MeasureWithUnit) MWUCBU = CBULU->ConversionFactor();
1744 afact = MWUCBU->ValueComponent();
1745 StepBasic_Unit anUnit2 = MWUCBU->UnitComponent();
1746 if(anUnit2.CaseNum(anUnit2.Value())==1) {
1747 Handle(StepBasic_NamedUnit) NU2 = anUnit2.NamedUnit();
1748 if(NU2->IsKind(STANDARD_TYPE(StepBasic_SiUnit))) {
1749 Handle(StepBasic_SiUnit) SU = Handle(StepBasic_SiUnit)::DownCast(NU2);
1750 if(SU->Name()==StepBasic_sunRadian) {
1752 afact *= STEPConstruct_UnitContext::ConvertSiPrefix (SU->Prefix());
1753 // convert radian to deg
1758 return Standard_True;
1761 //=======================================================================
1762 //function : GetMassConversionFactor
1764 //=======================================================================
1765 static Standard_Boolean GetMassConversionFactor(Handle(StepBasic_NamedUnit)& NU,
1766 Standard_Real& afact)
1769 if( !NU->IsKind(STANDARD_TYPE(StepBasic_ConversionBasedUnitAndMassUnit)) ) return Standard_False;
1770 Handle(StepBasic_ConversionBasedUnitAndMassUnit) CBUMU =
1771 Handle(StepBasic_ConversionBasedUnitAndMassUnit)::DownCast(NU);
1772 Handle(StepBasic_MeasureWithUnit) MWUCBU = CBUMU->ConversionFactor();
1773 afact = MWUCBU->ValueComponent();
1774 StepBasic_Unit anUnit2 = MWUCBU->UnitComponent();
1775 if(anUnit2.CaseNum(anUnit2.Value())==1) {
1776 Handle(StepBasic_NamedUnit) NU2 = anUnit2.NamedUnit();
1777 if(NU2->IsKind(STANDARD_TYPE(StepBasic_SiUnit))) {
1778 Handle(StepBasic_SiUnit) SU = Handle(StepBasic_SiUnit)::DownCast(NU2);
1779 if(SU->Name()==StepBasic_sunGram) {
1781 afact *= STEPConstruct_UnitContext::ConvertSiPrefix (SU->Prefix());
1785 return Standard_True;
1788 //=======================================================================
1789 //function : readPMIPresentation
1790 //purpose : read polyline or tessellated presentation for
1791 // (Annotation_Curve_Occurrence or Draughting_Callout)
1792 //=======================================================================
1793 Standard_Boolean readPMIPresentation(const Handle(Standard_Transient)& thePresentEntity,
1794 const Handle(XSControl_TransferReader)& theTR,
1795 const Standard_Real theFact,
1796 TopoDS_Shape& thePresentation,
1797 Handle(TCollection_HAsciiString)& thePresentName,
1800 if (thePresentEntity.IsNull())
1801 return Standard_False;
1802 Handle(Transfer_TransientProcess) aTP = theTR->TransientProcess();
1803 Handle(StepVisual_AnnotationOccurrence) anAO;
1804 NCollection_Vector<Handle(StepVisual_StyledItem)> anAnnotations;
1805 if (thePresentEntity->IsKind(STANDARD_TYPE(StepVisual_AnnotationOccurrence)))
1807 anAO = Handle(StepVisual_AnnotationOccurrence)::DownCast(thePresentEntity);
1808 if (!anAO.IsNull()) {
1809 thePresentName = anAO->Name();
1810 anAnnotations.Append(anAO);
1813 else if (thePresentEntity->IsKind(STANDARD_TYPE(StepVisual_DraughtingCallout)))
1815 Handle(StepVisual_DraughtingCallout) aDCallout =
1816 Handle(StepVisual_DraughtingCallout)::DownCast(thePresentEntity);
1817 thePresentName = aDCallout->Name();
1818 for (Standard_Integer i = 1; i <= aDCallout->NbContents() && anAO.IsNull(); i++) {
1819 anAO = Handle(StepVisual_AnnotationOccurrence)::DownCast(aDCallout->ContentsValue(i).Value());
1822 anAnnotations.Append(anAO);
1825 Handle(StepVisual_TessellatedAnnotationOccurrence) aTesselation =
1826 aDCallout->ContentsValue(i).TessellatedAnnotationOccurrence();
1827 if (!aTesselation.IsNull())
1828 anAnnotations.Append(aTesselation);
1832 if (!anAnnotations.Length())
1833 return Standard_False;
1837 TopoDS_Compound aResAnnotation;
1838 aB.MakeCompound(aResAnnotation);
1840 Standard_Integer i = 0;
1842 Standard_Integer nbShapes = 0;
1843 for (; i < anAnnotations.Length(); i++)
1845 Handle(StepVisual_StyledItem) anItem = anAnnotations(i);
1846 anAO = Handle(StepVisual_AnnotationOccurrence)::DownCast(anItem);
1847 TopoDS_Shape anAnnotationShape;
1850 Handle(StepRepr_RepresentationItem) aCurveItem = anAO->Item();
1851 anAnnotationShape = STEPConstruct::FindShape(aTP, aCurveItem);
1852 if (anAnnotationShape.IsNull())
1854 Handle(Transfer_Binder) binder = theTR->Actor()->Transfer(aCurveItem, aTP);
1855 if (!binder.IsNull() && binder->HasResult()) {
1856 anAnnotationShape = TransferBRep::ShapeResult(aTP, binder);
1860 //case of tessellated entities
1863 Handle(StepRepr_RepresentationItem) aTessItem = anItem->Item();
1864 if (aTessItem.IsNull())
1866 Handle(StepVisual_TessellatedGeometricSet) aTessSet = Handle(StepVisual_TessellatedGeometricSet)::DownCast(aTessItem);
1867 if (aTessSet.IsNull())
1869 NCollection_Handle<StepVisual_Array1OfTessellatedItem> aListItems = aTessSet->Items();
1870 Standard_Integer nb = aListItems.IsNull() ? 0 : aListItems->Length();
1871 Handle(StepVisual_TessellatedCurveSet) aTessCurve;
1872 for (Standard_Integer n = 1; n <= nb && aTessCurve.IsNull(); n++)
1874 aTessCurve = Handle(StepVisual_TessellatedCurveSet)::DownCast(aListItems->Value(n));
1876 if (aTessCurve.IsNull())
1878 Handle(StepVisual_CoordinatesList) aCoordList = aTessCurve->CoordList();
1879 if (aCoordList.IsNull())
1881 Handle(TColgp_HArray1OfXYZ) aPoints = aCoordList->Points();
1883 if (aPoints.IsNull() || aPoints->Length() == 0)
1885 NCollection_Handle<StepVisual_VectorOfHSequenceOfInteger> aCurves = aTessCurve->Curves();
1886 Standard_Integer aNbC = (aCurves.IsNull() ? 0 : aCurves->Length());
1887 TopoDS_Compound aComp;
1888 aB.MakeCompound(aComp);
1890 Standard_Integer k = 0;
1891 for (; k < aNbC; k++)
1893 Handle(TColStd_HSequenceOfInteger) anIndexes = aCurves->Value(k);
1897 for (Standard_Integer n = 1; n < anIndexes->Length(); n++)
1899 Standard_Integer ind = anIndexes->Value(n);
1900 Standard_Integer indnext = anIndexes->Value(n + 1);
1901 if (ind > aPoints->Length() || indnext > aPoints->Length())
1903 gp_Pnt aP1(aPoints->Value(ind) * theFact);
1904 gp_Pnt aP2(aPoints->Value(indnext) * theFact);
1905 BRepBuilderAPI_MakeEdge aMaker(aP1, aP2);
1906 if (aMaker.IsDone())
1908 TopoDS_Edge aCurE = aMaker.Edge();
1909 aB.Add(aCurW, aCurE);
1912 aB.Add(aComp, aCurW);
1914 anAnnotationShape = aComp;
1916 if (!anAnnotationShape.IsNull())
1919 aB.Add(aResAnnotation, anAnnotationShape);
1920 if (i == anAnnotations.Length() - 1)
1921 BRepBndLib::AddClose(anAnnotationShape, aBox);
1925 thePresentation = aResAnnotation;
1927 return (nbShapes > 0);
1930 //=======================================================================
1931 //function : readAnnotationPlane
1932 //purpose : read annotation plane
1933 //=======================================================================
1934 Standard_Boolean readAnnotationPlane(const Handle(StepVisual_AnnotationPlane) theAnnotationPlane,
1935 const Standard_Real theFact,
1938 if (theAnnotationPlane.IsNull())
1939 return Standard_False;
1940 Handle(StepRepr_RepresentationItem) aPlaneItem = theAnnotationPlane->Item();
1941 if (aPlaneItem.IsNull())
1942 return Standard_False;
1943 Handle(StepGeom_Axis2Placement3d) aA2P3D;
1944 //retrieve axes from AnnotationPlane
1945 if (aPlaneItem->IsKind(STANDARD_TYPE(StepGeom_Plane))) {
1946 Handle(StepGeom_Plane) aPlane = Handle(StepGeom_Plane)::DownCast(aPlaneItem);
1947 aA2P3D = aPlane->Position();
1949 else if (aPlaneItem->IsKind(STANDARD_TYPE(StepVisual_PlanarBox))) {
1950 Handle(StepVisual_PlanarBox) aBox = Handle(StepVisual_PlanarBox)::DownCast(aPlaneItem);
1951 aA2P3D = aBox->Placement().Axis2Placement3d();
1953 if (aA2P3D.IsNull())
1954 return Standard_False;
1957 Handle(Geom_Axis2Placement) anAxis = StepToGeom::MakeAxis2Placement(aA2P3D);
1958 aPlaneAxes = anAxis->Ax2();
1959 gp_XYZ aLocPos = aPlaneAxes.Location().XYZ();
1961 aPlaneAxes.SetLocation(aLocPos);
1962 thePlane = aPlaneAxes;
1963 return Standard_True;
1966 //=======================================================================
1967 //function : readAnnotation
1968 //purpose : read annotation plane and position for given GDT
1969 // (Dimension, Geometric_Tolerance, Datum_Feature or Placed_Datum_Target_Feature)
1970 //=======================================================================
1971 void readAnnotation(const Handle(XSControl_TransferReader)& theTR,
1972 const Handle(Standard_Transient)& theGDT,
1973 const Handle(Standard_Transient)& theDimObject)
1975 if (theGDT.IsNull() || theDimObject.IsNull())
1977 Handle(TCollection_HAsciiString) aPresentName;
1978 TopoDS_Compound aResAnnotation;
1979 Handle(Transfer_TransientProcess) aTP = theTR->TransientProcess();
1980 const Interface_Graph& aGraph = aTP->Graph();
1981 // find the proper DraughtingModelItemAssociation
1982 Interface_EntityIterator subs = aGraph.Sharings(theGDT);
1983 Handle(StepAP242_DraughtingModelItemAssociation) aDMIA;
1984 for (subs.Start(); subs.More() && aDMIA.IsNull(); subs.Next()) {
1985 if (!subs.Value()->IsKind(STANDARD_TYPE(StepAP242_DraughtingModelItemAssociation)))
1987 aDMIA = Handle(StepAP242_DraughtingModelItemAssociation)::DownCast(subs.Value());
1988 Handle(TCollection_HAsciiString) aName = aDMIA->Name();
1990 if (!aName->Search(new TCollection_HAsciiString("pmi representation to presentation link"))) {
1994 if (aDMIA.IsNull() || aDMIA->NbIdentifiedItem() == 0)
1998 Handle(StepVisual_DraughtingModel) aDModel =
1999 Handle(StepVisual_DraughtingModel)::DownCast(aDMIA->UsedRepresentation());
2000 Standard_Real aFact = 1;
2001 if (!aDModel.IsNull())
2002 GetLengthConversionFactorFromContext(aDModel->ContextOfItems(), aFact);
2004 // retrieve AnnotationPlane
2005 Handle(StepRepr_RepresentationItem) aDMIAE = aDMIA->IdentifiedItemValue(1);
2006 if (aDMIAE.IsNull())
2009 subs = aGraph.Sharings(aDMIAE);
2010 Handle(StepVisual_AnnotationPlane) anAnPlane;
2011 for (subs.Start(); subs.More() && anAnPlane.IsNull(); subs.Next()) {
2012 anAnPlane = Handle(StepVisual_AnnotationPlane)::DownCast(subs.Value());
2014 Standard_Boolean isHasPlane = readAnnotationPlane(anAnPlane, aFact, aPlaneAxes);
2016 // set plane axes to XCAF
2018 if (theDimObject->IsKind(STANDARD_TYPE(XCAFDimTolObjects_DimensionObject))) {
2019 Handle(XCAFDimTolObjects_DimensionObject) anObj =
2020 Handle(XCAFDimTolObjects_DimensionObject)::DownCast(theDimObject);
2021 Handle(TColgp_HArray1OfPnt) aPnts = new TColgp_HArray1OfPnt(1, 1);
2022 anObj->SetPlane(aPlaneAxes);
2024 else if (theDimObject->IsKind(STANDARD_TYPE(XCAFDimTolObjects_DatumObject))) {
2025 Handle(XCAFDimTolObjects_DatumObject) anObj =
2026 Handle(XCAFDimTolObjects_DatumObject)::DownCast(theDimObject);
2027 anObj->SetPlane(aPlaneAxes);
2029 else if (theDimObject->IsKind(STANDARD_TYPE(XCAFDimTolObjects_GeomToleranceObject))) {
2030 Handle(XCAFDimTolObjects_GeomToleranceObject) anObj =
2031 Handle(XCAFDimTolObjects_GeomToleranceObject)::DownCast(theDimObject);
2032 anObj->SetPlane(aPlaneAxes);
2036 // Retrieve presentation
2038 if (!readPMIPresentation(aDMIAE, theTR, aFact, aResAnnotation, aPresentName, aBox))
2040 gp_Pnt aPtext(0., 0., 0.);
2041 // if Annotation plane location inside bounding box set it to text position
2042 // else set the center of bounding box to text position
2045 Standard_Real aXmin, aYmin, aZmin, aXmax, aYmax, aZmax;
2046 aBox.Get(aXmin, aYmin, aZmin, aXmax, aYmax, aZmax);
2047 if (isHasPlane && !aBox.IsOut(aPlaneAxes.Location())) {
2048 aPtext = aPlaneAxes.Location();
2051 aPtext = gp_Pnt((aXmin + aXmax) * 0.5, (aYmin + aYmax) * 0.5, (aZmin + aZmax) * 0.5);
2055 aPtext = aPlaneAxes.Location();
2058 // set point to XCAF
2059 if (theDimObject->IsKind(STANDARD_TYPE(XCAFDimTolObjects_DimensionObject))) {
2060 Handle(XCAFDimTolObjects_DimensionObject) anObj =
2061 Handle(XCAFDimTolObjects_DimensionObject)::DownCast(theDimObject);
2062 anObj->SetPointTextAttach(aPtext);
2063 anObj->SetPresentation(aResAnnotation, aPresentName);
2065 else if (theDimObject->IsKind(STANDARD_TYPE(XCAFDimTolObjects_DatumObject))) {
2066 Handle(XCAFDimTolObjects_DatumObject) anObj =
2067 Handle(XCAFDimTolObjects_DatumObject)::DownCast(theDimObject);
2068 anObj->SetPointTextAttach(aPtext);
2069 anObj->SetPresentation(aResAnnotation, aPresentName);
2071 else if (theDimObject->IsKind(STANDARD_TYPE(XCAFDimTolObjects_GeomToleranceObject))) {
2072 Handle(XCAFDimTolObjects_GeomToleranceObject) anObj =
2073 Handle(XCAFDimTolObjects_GeomToleranceObject)::DownCast(theDimObject);
2074 anObj->SetPointTextAttach(aPtext);
2075 anObj->SetPresentation(aResAnnotation, aPresentName);
2080 //=======================================================================
2081 //function : readConnectionPoints
2082 //purpose : read connection points for given dimension
2083 //=======================================================================
2084 void readConnectionPoints(const Handle(XSControl_TransferReader)& theTR,
2085 const Handle(Standard_Transient) theGDT,
2086 const Handle(XCAFDimTolObjects_DimensionObject)& theDimObject)
2088 if (theGDT.IsNull() || theDimObject.IsNull())
2090 Handle(Transfer_TransientProcess) aTP = theTR->TransientProcess();
2091 const Interface_Graph& aGraph = aTP->Graph();
2094 Standard_Real aFact = 1;
2095 Handle(StepShape_ShapeDimensionRepresentation) aSDR = NULL;
2096 for (Interface_EntityIterator anIt = aGraph.Sharings(theGDT); aSDR.IsNull() && anIt.More(); anIt.Next()) {
2097 aSDR = Handle(StepShape_ShapeDimensionRepresentation)::DownCast(anIt.Value());
2100 GetLengthConversionFactorFromContext(aSDR->ContextOfItems(), aFact);
2102 if (theGDT->IsKind(STANDARD_TYPE(StepShape_DimensionalSize))) {
2103 // retrieve derived geometry
2104 Handle(StepShape_DimensionalSize) aDim = Handle(StepShape_DimensionalSize)::DownCast(theGDT);
2105 Handle(StepRepr_DerivedShapeAspect) aDSA = Handle(StepRepr_DerivedShapeAspect)::DownCast(aDim->AppliesTo());
2108 Handle(StepAP242_GeometricItemSpecificUsage) aGISU = NULL;
2109 for (Interface_EntityIterator anIt = aGraph.Sharings(aDSA); aGISU.IsNull() && anIt.More(); anIt.Next()) {
2110 aGISU = Handle(StepAP242_GeometricItemSpecificUsage)::DownCast(anIt.Value());
2112 if (aGISU.IsNull() || aGISU->NbIdentifiedItem() == 0)
2114 Handle(StepGeom_CartesianPoint) aPoint = Handle(StepGeom_CartesianPoint)::DownCast(aGISU->IdentifiedItem()->Value(1));
2115 if (aPoint.IsNull()) {
2116 // try Axis2Placement3d.location instead of CartesianPoint
2117 Handle(StepGeom_Axis2Placement3d) anA2P3D =
2118 Handle(StepGeom_Axis2Placement3d)::DownCast(aGISU->IdentifiedItem()->Value(1));
2119 if (anA2P3D.IsNull())
2121 aPoint = anA2P3D->Location();
2124 // set connection point to object
2125 gp_Pnt aPnt(aPoint->CoordinatesValue(1) * aFact, aPoint->CoordinatesValue(2) * aFact, aPoint->CoordinatesValue(3) * aFact);
2126 theDimObject->SetPoint(aPnt);
2128 else if (theGDT->IsKind(STANDARD_TYPE(StepShape_DimensionalLocation))) {
2129 // retrieve derived geometry
2130 Handle(StepShape_DimensionalLocation) aDim = Handle(StepShape_DimensionalLocation)::DownCast(theGDT);
2131 Handle(StepRepr_DerivedShapeAspect) aDSA1 = Handle(StepRepr_DerivedShapeAspect)::DownCast(aDim->RelatingShapeAspect());
2132 Handle(StepRepr_DerivedShapeAspect) aDSA2 = Handle(StepRepr_DerivedShapeAspect)::DownCast(aDim->RelatedShapeAspect());
2133 if (aDSA1.IsNull() && aDSA2.IsNull())
2135 Handle(StepAP242_GeometricItemSpecificUsage) aGISU1 = NULL;
2136 Handle(StepAP242_GeometricItemSpecificUsage) aGISU2 = NULL;
2137 if (!aDSA1.IsNull()) {
2138 for (Interface_EntityIterator anIt = aGraph.Sharings(aDSA1); aGISU1.IsNull() && anIt.More(); anIt.Next()) {
2139 aGISU1 = Handle(StepAP242_GeometricItemSpecificUsage)::DownCast(anIt.Value());
2142 if (!aDSA2.IsNull()) {
2143 for (Interface_EntityIterator anIt = aGraph.Sharings(aDSA2); aGISU2.IsNull() && anIt.More(); anIt.Next()) {
2144 aGISU2 = Handle(StepAP242_GeometricItemSpecificUsage)::DownCast(anIt.Value());
2148 if (!aGISU1.IsNull() && aGISU1->NbIdentifiedItem() > 0) {
2149 Handle(StepGeom_CartesianPoint) aPoint = Handle(StepGeom_CartesianPoint)::DownCast(aGISU1->IdentifiedItem()->Value(1));
2150 if (aPoint.IsNull()) {
2151 // try Axis2Placement3d.location instead of CartesianPoint
2152 Handle(StepGeom_Axis2Placement3d) anA2P3D =
2153 Handle(StepGeom_Axis2Placement3d)::DownCast(aGISU1->IdentifiedItem()->Value(1));
2154 if (!anA2P3D.IsNull())
2155 aPoint = anA2P3D->Location();
2157 if (!aPoint.IsNull()) {
2158 // set connection point to object
2159 gp_Pnt aPnt(aPoint->CoordinatesValue(1) * aFact, aPoint->CoordinatesValue(2) * aFact, aPoint->CoordinatesValue(3) * aFact);
2160 theDimObject->SetPoint(aPnt);
2164 if (!aGISU2.IsNull() && aGISU2->NbIdentifiedItem() > 0) {
2165 Handle(StepGeom_CartesianPoint) aPoint = Handle(StepGeom_CartesianPoint)::DownCast(aGISU2->IdentifiedItem()->Value(1));
2166 if (aPoint.IsNull()) {
2167 // try Axis2Placement3d.location instead of CartesianPoint
2168 Handle(StepGeom_Axis2Placement3d) anA2P3D =
2169 Handle(StepGeom_Axis2Placement3d)::DownCast(aGISU2->IdentifiedItem()->Value(1));
2170 if (!anA2P3D.IsNull())
2171 aPoint = anA2P3D->Location();
2173 if (!aPoint.IsNull()) {
2174 // set connection point to object
2175 gp_Pnt aPnt(aPoint->CoordinatesValue(1) * aFact, aPoint->CoordinatesValue(2) * aFact, aPoint->CoordinatesValue(3) * aFact);
2176 theDimObject->SetPoint2(aPnt);
2182 //=======================================================================
2183 //function : ReadDatums
2184 //purpose : auxilary
2185 //=======================================================================
2186 static Standard_Boolean ReadDatums(const Handle(XCAFDoc_ShapeTool) &STool,
2187 const Handle(XCAFDoc_DimTolTool) &DGTTool,
2188 const Interface_Graph &graph,
2189 const Handle(Transfer_TransientProcess) &TP,
2190 const TDF_Label TolerL,
2191 const Handle(StepDimTol_GeometricToleranceWithDatumReference) GTWDR)
2193 if(GTWDR.IsNull()) return Standard_False;
2194 Handle(StepDimTol_HArray1OfDatumReference) HADR = GTWDR->DatumSystem();
2195 if(HADR.IsNull()) return Standard_False;
2196 for(Standard_Integer idr=1; idr<=HADR->Length(); idr++) {
2197 Handle(StepDimTol_DatumReference) DR = HADR->Value(idr);
2198 Handle(StepDimTol_Datum) aDatum = DR->ReferencedDatum();
2199 if(aDatum.IsNull()) continue;
2200 Interface_EntityIterator subs4 = graph.Sharings(aDatum);
2201 for(subs4.Start(); subs4.More(); subs4.Next()) {
2202 Handle(StepRepr_ShapeAspectRelationship) SAR =
2203 Handle(StepRepr_ShapeAspectRelationship)::DownCast(subs4.Value());
2204 if(SAR.IsNull()) continue;
2205 Handle(StepDimTol_DatumFeature) DF =
2206 Handle(StepDimTol_DatumFeature)::DownCast(SAR->RelatingShapeAspect());
2207 if(DF.IsNull()) continue;
2208 Interface_EntityIterator subs5 = graph.Sharings(DF);
2209 Handle(StepRepr_PropertyDefinition) PropDef;
2210 for(subs5.Start(); subs5.More() && PropDef.IsNull(); subs5.Next()) {
2211 PropDef = Handle(StepRepr_PropertyDefinition)::DownCast(subs5.Value());
2213 if(PropDef.IsNull()) continue;
2214 Handle(StepShape_AdvancedFace) AF;
2215 subs5 = graph.Sharings(PropDef);
2216 for(subs5.Start(); subs5.More(); subs5.Next()) {
2217 Handle(StepShape_ShapeDefinitionRepresentation) SDR =
2218 Handle(StepShape_ShapeDefinitionRepresentation)::DownCast(subs5.Value());
2220 Handle(StepRepr_Representation) Repr = SDR->UsedRepresentation();
2221 if( !Repr.IsNull() && Repr->NbItems()>0 ) {
2222 Handle(StepRepr_RepresentationItem) RI = Repr->ItemsValue(1);
2223 AF = Handle(StepShape_AdvancedFace)::DownCast(RI);
2227 if(AF.IsNull()) return Standard_False;
2228 Standard_Integer index = TP->MapIndex(AF);
2231 Handle(Transfer_Binder) binder = TP->MapItem(index);
2232 aSh = TransferBRep::ShapeResult(binder);
2234 if(aSh.IsNull()) continue;
2236 if( !STool->Search(aSh, shL, Standard_True, Standard_True, Standard_True) ) continue;
2237 DGTTool->SetDatum(shL,TolerL,PropDef->Name(),PropDef->Description(),aDatum->Identification());
2240 return Standard_True;
2243 //=======================================================================
2244 //function : FindShapeIndexForDGT
2245 //purpose : auxiliary find shape index in map og imported shapes
2246 //=======================================================================
2247 static Standard_Integer FindShapeIndexForDGT(const Handle(Standard_Transient)& theEnt,
2248 const Handle(XSControl_WorkSession)& theWS)
2250 const Handle(Transfer_TransientProcess) &aTP = theWS->TransferReader()->TransientProcess();
2251 // try to find index of given entity
2252 Standard_Integer anIndex = aTP->MapIndex(theEnt);
2255 // if theEnt is a geometry item try to find its topological item
2256 const Interface_Graph& aGraph = aTP->Graph();
2257 Interface_EntityIterator anIter = aGraph.Sharings(theEnt);
2258 for (anIter.Start(); anIter.More(); anIter.Next()) {
2259 if (anIter.Value()->IsKind(STANDARD_TYPE(StepShape_TopologicalRepresentationItem)))
2261 anIndex = aTP->MapIndex(anIter.Value());
2269 //=======================================================================
2270 //function : collectShapeAspect
2272 //=======================================================================
2273 static void collectShapeAspect(const Handle(StepRepr_ShapeAspect)& theSA,
2274 const Handle(XSControl_WorkSession)& theWS,
2275 NCollection_Sequence<Handle(StepRepr_ShapeAspect)>& theSAs)
2279 Handle(XSControl_TransferReader) aTR = theWS->TransferReader();
2280 Handle(Transfer_TransientProcess) aTP = aTR->TransientProcess();
2281 const Interface_Graph& aGraph = aTP->Graph();
2282 // Retrieve Shape_Aspect, connected to Representation_Item from Derived_Shape_Aspect
2283 if (theSA->IsKind(STANDARD_TYPE(StepRepr_DerivedShapeAspect))) {
2284 Interface_EntityIterator anIter = aGraph.Sharings(theSA);
2285 Handle(StepRepr_ShapeAspectDerivingRelationship) aSADR = NULL;
2286 for (; aSADR.IsNull() && anIter.More(); anIter.Next()) {
2287 aSADR = Handle(StepRepr_ShapeAspectDerivingRelationship)::DownCast(anIter.Value());
2289 if (!aSADR.IsNull())
2290 collectShapeAspect(aSADR->RelatedShapeAspect(), theWS, theSAs);
2292 else if (theSA->IsKind(STANDARD_TYPE(StepDimTol_DatumFeature)) ||
2293 theSA->IsKind(STANDARD_TYPE(StepDimTol_DatumTarget))) {
2294 theSAs.Append(theSA);
2298 // Find all children Shape_Aspect
2299 Standard_Boolean isSimple = Standard_True;
2300 Interface_EntityIterator anIter = aGraph.Sharings(theSA);
2301 for (; anIter.More(); anIter.Next()) {
2302 if (anIter.Value()->IsKind(STANDARD_TYPE(StepRepr_ShapeAspectRelationship)) &&
2303 !anIter.Value()->IsKind(STANDARD_TYPE(StepShape_DimensionalLocation))) {
2304 Handle(StepRepr_ShapeAspectRelationship) aSAR =
2305 Handle(StepRepr_ShapeAspectRelationship)::DownCast(anIter.Value());
2306 if (aSAR->RelatingShapeAspect() == theSA && !aSAR->RelatedShapeAspect().IsNull()
2307 && !aSAR->RelatedShapeAspect()->IsKind(STANDARD_TYPE(StepDimTol_Datum))) {
2308 collectShapeAspect(aSAR->RelatedShapeAspect(), theWS, theSAs);
2309 isSimple = Standard_False;
2313 // If not Composite_Shape_Aspect (or subtype) append to sequence.
2315 theSAs.Append(theSA);
2319 //=======================================================================
2320 //function : getShapeLabel
2322 //=======================================================================
2324 static TDF_Label getShapeLabel(const Handle(StepRepr_RepresentationItem)& theItem,
2325 const Handle(XSControl_WorkSession)& theWS,
2326 const Handle(XCAFDoc_ShapeTool)& theShapeTool)
2329 const Handle(Transfer_TransientProcess) &aTP = theWS->TransferReader()->TransientProcess();
2330 Standard_Integer index = FindShapeIndexForDGT(theItem, theWS);
2331 TopoDS_Shape aShape;
2333 Handle(Transfer_Binder) aBinder = aTP->MapItem(index);
2334 aShape = TransferBRep::ShapeResult(aBinder);
2336 if (aShape.IsNull())
2338 theShapeTool->Search(aShape, aShapeL, Standard_True, Standard_True, Standard_True);
2342 //=======================================================================
2343 //function : setDatumToXCAF
2345 //=======================================================================
2347 Standard_Boolean STEPCAFControl_Reader::setDatumToXCAF(const Handle(StepDimTol_Datum)& theDat,
2348 const TDF_Label theGDTL,
2349 const Standard_Integer thePositionCounter,
2350 const XCAFDimTolObjects_DatumModifiersSequence& theXCAFModifiers,
2351 const XCAFDimTolObjects_DatumModifWithValue theXCAFModifWithVal,
2352 const Standard_Real theModifValue,
2353 const Handle(TDocStd_Document)& theDoc,
2354 const Handle(XSControl_WorkSession)& theWS)
2356 Handle(XCAFDoc_ShapeTool) aSTool = XCAFDoc_DocumentTool::ShapeTool(theDoc->Main());
2357 Handle(XCAFDoc_DimTolTool) aDGTTool = XCAFDoc_DocumentTool::DimTolTool(theDoc->Main());
2358 const Handle(XSControl_TransferReader) &aTR = theWS->TransferReader();
2359 const Handle(Transfer_TransientProcess) &aTP = aTR->TransientProcess();
2360 const Interface_Graph& aGraph = aTP->Graph();
2361 Handle(XCAFDoc_Datum) aDat;
2362 TDF_LabelSequence aShapeLabels;
2363 Handle(XCAFDimTolObjects_DatumObject) aDatObj = new XCAFDimTolObjects_DatumObject();
2365 // Collect all links to shapes
2366 NCollection_Sequence<Handle(StepRepr_ShapeAspect)> aSAs;
2367 Interface_EntityIterator anIterD = aGraph.Sharings(theDat);
2368 for (anIterD.Start(); anIterD.More(); anIterD.Next()) {
2369 Handle(StepRepr_ShapeAspectRelationship) aSAR = Handle(StepRepr_ShapeAspectRelationship)::DownCast(anIterD.Value());
2370 if (aSAR.IsNull() || aSAR->RelatingShapeAspect().IsNull())
2372 collectShapeAspect(aSAR->RelatingShapeAspect(), theWS, aSAs);
2373 Handle(StepDimTol_DatumFeature) aDF = Handle(StepDimTol_DatumFeature)::DownCast(aSAR->RelatingShapeAspect());
2374 if (!aSAR->RelatingShapeAspect()->IsKind(STANDARD_TYPE(StepDimTol_DatumTarget)))
2375 readAnnotation(aTR, aSAR->RelatingShapeAspect(), aDatObj);
2378 // Collect shape labels
2379 for (Standard_Integer i = 1; i <= aSAs.Length(); i++) {
2380 Handle(StepRepr_ShapeAspect) aSA = aSAs.Value(i);
2383 // Skip datum targets
2384 if (aSA->IsKind(STANDARD_TYPE(StepDimTol_DatumTarget)))
2387 // Process all connected GISU
2388 Interface_EntityIterator anIter = aGraph.Sharings(aSA);
2389 for (; anIter.More(); anIter.Next()) {
2390 Handle(StepAP242_GeometricItemSpecificUsage) aGISU = Handle(StepAP242_GeometricItemSpecificUsage)::DownCast(anIter.Value());
2393 for (Standard_Integer j = 1; j <= aGISU->NbIdentifiedItem(); j++) {
2394 TDF_Label aShapeL = getShapeLabel(aGISU->IdentifiedItemValue(j), theWS, aSTool);
2395 if (!aShapeL.IsNull())
2396 aShapeLabels.Append(aShapeL);
2401 // Process datum targets and create objects for them
2402 Standard_Boolean isExistDatumTarget = Standard_False;
2403 for (Standard_Integer i = 1; i <= aSAs.Length(); i++) {
2404 Handle(StepDimTol_PlacedDatumTargetFeature) aDT = Handle(StepDimTol_PlacedDatumTargetFeature)::DownCast(aSAs.Value(i));
2407 Handle(XCAFDimTolObjects_DatumObject) aDatTargetObj = new XCAFDimTolObjects_DatumObject();
2408 XCAFDimTolObjects_DatumTargetType aType;
2409 if (!STEPCAFControl_GDTProperty::GetDatumTargetType(aDT->Description(), aType))
2411 aDatTargetObj->SetDatumTargetType(aType);
2412 Standard_Boolean isValidDT = Standard_False;
2414 // Feature for datum target
2415 TDF_LabelSequence aDTShapeLabels;
2416 Interface_EntityIterator aDTIter = aGraph.Sharings(aDT);
2417 Handle(StepRepr_FeatureForDatumTargetRelationship) aRelationship;
2418 for (; aDTIter.More() && aRelationship.IsNull(); aDTIter.Next()) {
2419 aRelationship = Handle(StepRepr_FeatureForDatumTargetRelationship)::DownCast(aDTIter.Value());
2421 if (!aRelationship.IsNull()) {
2422 Handle(StepRepr_ShapeAspect) aSA = aRelationship->RelatingShapeAspect();
2423 Interface_EntityIterator aSAIter = aGraph.Sharings(aSA);
2424 for (; aSAIter.More(); aSAIter.Next()) {
2425 Handle(StepAP242_GeometricItemSpecificUsage) aGISU = Handle(StepAP242_GeometricItemSpecificUsage)::DownCast(aSAIter.Value());
2428 for (Standard_Integer j = 1; j <= aGISU->NbIdentifiedItem(); j++) {
2429 TDF_Label aShapeL = getShapeLabel(aGISU->IdentifiedItemValue(j), theWS, aSTool);
2430 if (!aShapeL.IsNull()) {
2431 aDTShapeLabels.Append(aShapeL);
2432 isValidDT = Standard_True;
2438 if (aType != XCAFDimTolObjects_DatumTargetType_Area && !isValidDT) {
2439 // Try another way of feature connection
2440 for (aDTIter.Start(); aDTIter.More(); aDTIter.Next()) {
2441 Handle(StepAP242_GeometricItemSpecificUsage) aGISU = Handle(StepAP242_GeometricItemSpecificUsage)::DownCast(aDTIter.Value());
2444 for (Standard_Integer j = 1; j <= aGISU->NbIdentifiedItem(); j++) {
2445 TDF_Label aShapeL = getShapeLabel(aGISU->IdentifiedItemValue(j), theWS, aSTool);
2446 if (!aShapeL.IsNull()) {
2447 aDTShapeLabels.Append(aShapeL);
2448 isValidDT = Standard_True;
2454 if (aType == XCAFDimTolObjects_DatumTargetType_Area) {
2455 // Area datum target
2456 Interface_EntityIterator anIterDTF = aGraph.Shareds(aDT);
2457 Handle(StepAP242_GeometricItemSpecificUsage) aGISU;
2458 for (; anIterDTF.More() && aGISU.IsNull(); anIterDTF.Next()) {
2459 aGISU = Handle(StepAP242_GeometricItemSpecificUsage)::DownCast(anIterDTF.Value());
2461 Handle(StepRepr_RepresentationItem) anItem;
2462 if (aGISU->NbIdentifiedItem() > 0)
2463 anItem = aGISU->IdentifiedItemValue(1);
2464 if (anItem.IsNull())
2466 Standard_Integer anItemIndex = FindShapeIndexForDGT(anItem, theWS);
2467 if (anItemIndex > 0) {
2468 Handle(Transfer_Binder) aBinder = aTP->MapItem(anItemIndex);
2469 TopoDS_Shape anItemShape = TransferBRep::ShapeResult(aBinder);
2470 aDatTargetObj->SetDatumTarget(anItemShape);
2471 isValidDT = Standard_True;
2475 // Point/line/rectangle/circle datum targets
2476 Interface_EntityIterator anIter = aGraph.Sharings(aDT);
2477 Handle(StepRepr_PropertyDefinition) aPD;
2478 for (; anIter.More() && aPD.IsNull(); anIter.Next()) {
2479 aPD = Handle(StepRepr_PropertyDefinition)::DownCast(anIter.Value());
2481 if (!aPD.IsNull()) {
2482 anIter = aGraph.Sharings(aPD);
2483 Handle(StepShape_ShapeDefinitionRepresentation) aSDR;
2484 for (; anIter.More() && aSDR.IsNull(); anIter.Next()) {
2485 aSDR = Handle(StepShape_ShapeDefinitionRepresentation)::DownCast(anIter.Value());
2487 if (!aSDR.IsNull()) {
2488 Handle(StepShape_ShapeRepresentationWithParameters) aSRWP
2489 = Handle(StepShape_ShapeRepresentationWithParameters)::DownCast(aSDR->UsedRepresentation());
2490 if (!aSRWP.IsNull()) {
2491 isValidDT = Standard_True;
2492 // Collect parameters of datum target
2493 for (Standard_Integer j = aSRWP->Items()->Lower(); j <= aSRWP->Items()->Upper(); j++)
2495 if (aSRWP->ItemsValue(j).IsNull())
2497 if (aSRWP->ItemsValue(j)->IsKind(STANDARD_TYPE(StepGeom_Axis2Placement3d)))
2499 Handle(StepGeom_Axis2Placement3d) anAx
2500 = Handle(StepGeom_Axis2Placement3d)::DownCast(aSRWP->ItemsValue(j));
2501 Handle(Geom_Axis2Placement) anAxis = StepToGeom::MakeAxis2Placement(anAx);
2502 aDatTargetObj->SetDatumTargetAxis(anAxis->Ax2());
2504 else if (aSRWP->ItemsValue(j)->IsKind(STANDARD_TYPE(StepRepr_ReprItemAndLengthMeasureWithUnit)))
2506 Handle(StepRepr_ReprItemAndLengthMeasureWithUnit) aM =
2507 Handle(StepRepr_ReprItemAndLengthMeasureWithUnit)::DownCast(aSRWP->ItemsValue(j));
2508 Standard_Real aVal = aM->GetMeasureWithUnit()->ValueComponent();
2509 StepBasic_Unit anUnit = aM->GetMeasureWithUnit()->UnitComponent();
2510 Standard_Real aFact = 1.;
2511 if (anUnit.IsNull())
2513 Handle(StepBasic_NamedUnit) aNU = anUnit.NamedUnit();
2516 if (GetLengthConversionFactor(aNU, aFact))
2517 aVal = aVal * aFact;
2518 if (aM->Name()->String().IsEqual("target length") ||
2519 aM->Name()->String().IsEqual("target diameter"))
2520 aDatTargetObj->SetDatumTargetLength(aVal);
2522 aDatTargetObj->SetDatumTargetWidth(aVal);
2530 // Create datum target object
2532 TDF_Label aDatL = aDGTTool->AddDatum();
2533 myGDTMap.Bind(aDT, aDatL);
2534 aDGTTool->Lock(aDatL);
2535 aDat = XCAFDoc_Datum::Set(aDatL);
2536 aDGTTool->SetDatum(aDTShapeLabels, aDatL);
2537 aDatTargetObj->SetName(theDat->Identification());
2538 aDatTargetObj->SetPosition(thePositionCounter);
2539 if (!theXCAFModifiers.IsEmpty())
2540 aDatTargetObj->SetModifiers(theXCAFModifiers);
2541 if (theXCAFModifWithVal != XCAFDimTolObjects_DatumModifWithValue_None)
2542 aDatTargetObj->SetModifierWithValue(theXCAFModifWithVal, theModifValue);
2543 aDGTTool->SetDatumToGeomTol(aDatL, theGDTL);
2544 aDatTargetObj->IsDatumTarget(Standard_True);
2545 aDatTargetObj->SetDatumTargetNumber(aDT->TargetId()->IntegerValue());
2546 readAnnotation(aTR, aDT, aDatTargetObj);
2547 aDat->SetObject(aDatTargetObj);
2548 isExistDatumTarget = Standard_True;
2552 if (aShapeLabels.Length() > 0 || !isExistDatumTarget) {
2553 // Create object for datum
2554 TDF_Label aDatL = aDGTTool->AddDatum();
2555 myGDTMap.Bind(theDat, aDatL);
2556 // bind datum label with all reference datum_feature entities
2557 for (Standard_Integer i = 1; i <= aSAs.Length(); i++) {
2558 Handle(StepRepr_ShapeAspect) aSA = aSAs.Value(i);
2559 if (aSA.IsNull() || aSA->IsKind(STANDARD_TYPE(StepDimTol_DatumTarget)))
2561 myGDTMap.Bind(aSA, aDatL);
2563 aDGTTool->Lock(aDatL);
2564 aDat = XCAFDoc_Datum::Set(aDatL);
2565 aDGTTool->SetDatum(aShapeLabels, aDatL);
2566 aDatObj->SetName(theDat->Identification());
2567 aDatObj->SetPosition(thePositionCounter);
2568 if (!theXCAFModifiers.IsEmpty())
2569 aDatObj->SetModifiers(theXCAFModifiers);
2570 if (theXCAFModifWithVal != XCAFDimTolObjects_DatumModifWithValue_None)
2571 aDatObj->SetModifierWithValue(theXCAFModifWithVal, theModifValue);
2572 aDGTTool->SetDatumToGeomTol(aDatL, theGDTL);
2573 if (aDatObj->GetPresentation().IsNull()) {
2574 // Try find annotation connected to datum entity (not right case, according recommended practices)
2575 readAnnotation(aTR, theDat, aDatObj);
2577 aDat->SetObject(aDatObj);
2580 return Standard_True;
2584 //=======================================================================
2585 //function : ReadDatums
2586 //purpose : auxilary
2587 //=======================================================================
2588 Standard_Boolean STEPCAFControl_Reader::readDatumsAP242(const Handle(Standard_Transient)& theEnt,
2589 const TDF_Label theGDTL,
2590 const Handle(TDocStd_Document)& theDoc,
2591 const Handle(XSControl_WorkSession)& theWS)
2593 const Handle(XSControl_TransferReader) &aTR = theWS->TransferReader();
2594 const Handle(Transfer_TransientProcess) &aTP = aTR->TransientProcess();
2595 const Interface_Graph& aGraph = aTP->Graph();
2597 Interface_EntityIterator anIter = aGraph.Shareds(theEnt);
2598 for(anIter.Start(); anIter.More(); anIter.Next()) {
2599 Handle(Standard_Transient) anAtr = anIter.Value();
2600 if(anAtr->IsKind(STANDARD_TYPE(StepDimTol_DatumSystem)))
2602 Standard_Integer aPositionCounter = 0;//position on frame
2603 Handle(StepDimTol_DatumSystem) aDS = Handle(StepDimTol_DatumSystem)::DownCast(anAtr);
2604 Interface_EntityIterator anIterDS = aGraph.Sharings(aDS);
2605 for(anIterDS.Start(); anIterDS.More(); anIterDS.Next()) {
2606 Handle(Standard_Transient) anAtrDS = anIterDS.Value();
2607 if(anAtrDS->IsKind(STANDARD_TYPE(StepAP242_GeometricItemSpecificUsage)))
2610 Handle(StepAP242_GeometricItemSpecificUsage)aAxGISUI
2611 = Handle(StepAP242_GeometricItemSpecificUsage)::DownCast(anAtrDS);
2612 if (aAxGISUI->IdentifiedItemValue(1)->IsKind(STANDARD_TYPE(StepGeom_Axis2Placement3d)))
2614 Handle(StepGeom_Axis2Placement3d) anAx
2615 = Handle(StepGeom_Axis2Placement3d)::DownCast(aAxGISUI->IdentifiedItemValue(1));
2616 Handle(XCAFDoc_GeomTolerance) aTol;
2617 if(theGDTL.FindAttribute(XCAFDoc_GeomTolerance::GetID(), aTol))
2619 Handle(XCAFDimTolObjects_GeomToleranceObject) anObj = aTol->GetObject();
2620 Handle(TColStd_HArray1OfReal) aDirArr = anAx->Axis()->DirectionRatios();
2621 Handle(TColStd_HArray1OfReal) aDirRArr = anAx->RefDirection()->DirectionRatios();
2622 Handle(TColStd_HArray1OfReal) aLocArr = anAx->Location()->Coordinates();
2626 if(!aDirArr.IsNull() && aDirArr->Length() > 2 &&
2627 !aDirRArr.IsNull() && aDirRArr->Length() > 2 &&
2628 !aLocArr.IsNull() && aLocArr->Length() > 2)
2630 aDir.SetCoord(aDirArr->Lower(), aDirArr->Lower()+1, aDirArr->Lower()+2);
2631 aDirR.SetCoord(aDirRArr->Lower(), aDirRArr->Lower()+1, aDirRArr->Lower()+2);
2632 aPnt.SetCoord(aLocArr->Lower(), aLocArr->Lower()+1, aLocArr->Lower()+2);
2633 gp_Ax2 anA(aPnt, aDir, aDirR);
2634 anObj->SetAxis(anA);
2635 aTol->SetObject(anObj);
2641 if (aDS->NbConstituents() > 0)
2643 //get datum feature and datum target from datum system
2644 Handle(StepDimTol_HArray1OfDatumReferenceCompartment) aDRCA = aDS->Constituents();
2647 for(Standard_Integer i = aDRCA->Lower(); i <= aDRCA->Upper(); i++)
2649 Handle(StepDimTol_DatumReferenceCompartment) aDRC = aDRCA->Value(i);
2651 Handle(StepDimTol_HArray1OfDatumReferenceModifier) aModif = aDRC->Modifiers();
2652 XCAFDimTolObjects_DatumModifiersSequence aXCAFModifiers;
2653 XCAFDimTolObjects_DatumModifWithValue aXCAFModifWithVal = XCAFDimTolObjects_DatumModifWithValue_None;
2654 Standard_Real aModifValue = 0;
2655 if(!aModif.IsNull())
2657 for(Standard_Integer m = aModif->Lower(); m <= aModif->Upper(); m++)
2659 if(aModif->Value(m).CaseNumber() == 2)
2660 aXCAFModifiers.Append(
2661 (XCAFDimTolObjects_DatumSingleModif)aModif->Value(m).
2662 SimpleDatumReferenceModifierMember()->Value());
2663 else if (aModif->Value(m).CaseNumber() == 1)
2665 aXCAFModifWithVal = (XCAFDimTolObjects_DatumModifWithValue)(aModif->Value(m).DatumReferenceModifierWithValue()->ModifierType() + 1);
2666 Standard_Real aVal = aModif->Value(m).DatumReferenceModifierWithValue()->ModifierValue()->ValueComponent();
2667 StepBasic_Unit anUnit = aModif->Value(m).DatumReferenceModifierWithValue()->ModifierValue()->UnitComponent();
2668 Standard_Real aFact=1.;
2669 if(anUnit.IsNull()) continue;
2670 if( !(anUnit.CaseNum(anUnit.Value())==1) ) continue;
2671 Handle(StepBasic_NamedUnit) NU = anUnit.NamedUnit();
2672 if(GetLengthConversionFactor(NU,aFact)) aVal=aVal*aFact;
2678 Interface_EntityIterator anIterDRC = aGraph.Shareds(aDRC);
2679 for(anIterDRC.Start(); anIterDRC.More(); anIterDRC.Next()) {
2681 if(anIterDRC.Value()->IsKind(STANDARD_TYPE(StepDimTol_Datum)))
2683 Handle(StepDimTol_Datum) aD = Handle(StepDimTol_Datum)::DownCast(anIterDRC.Value());
2684 setDatumToXCAF(aD, theGDTL, aPositionCounter, aXCAFModifiers, aXCAFModifWithVal, aModifValue,theDoc, theWS);
2686 else if(anIterDRC.Value()->IsKind(STANDARD_TYPE(StepDimTol_DatumReferenceElement)))
2688 Handle(StepDimTol_DatumReferenceElement) aDRE
2689 = Handle(StepDimTol_DatumReferenceElement)::DownCast(anIterDRC.Value());
2690 //get modifiers from group of datums
2691 Handle(StepDimTol_HArray1OfDatumReferenceModifier) aModifE = aDRE->Modifiers();
2692 if(!aModifE.IsNull())
2694 for(Standard_Integer k = aModifE->Lower(); k <= aModifE->Upper(); k++)
2696 if(aModifE->Value(k).CaseNumber() == 2)
2697 aXCAFModifiers.Append(
2698 (XCAFDimTolObjects_DatumSingleModif)aModifE->Value(k).
2699 SimpleDatumReferenceModifierMember()->Value());
2700 else if (aModifE->Value(k).CaseNumber() == 1)
2702 aXCAFModifWithVal = (XCAFDimTolObjects_DatumModifWithValue)(aModifE->Value(k).DatumReferenceModifierWithValue()->ModifierType() + 1);
2703 Standard_Real aVal = aModifE->Value(k).DatumReferenceModifierWithValue()->ModifierValue()->ValueComponent();
2704 StepBasic_Unit anUnit = aModifE->Value(k).DatumReferenceModifierWithValue()->ModifierValue()->UnitComponent();
2705 Standard_Real aFact=1.;
2706 if(anUnit.IsNull()) continue;
2707 if( !(anUnit.CaseNum(anUnit.Value())==1) ) continue;
2708 Handle(StepBasic_NamedUnit) NU = anUnit.NamedUnit();
2709 if(GetLengthConversionFactor(NU,aFact)) aVal=aVal*aFact;
2714 Interface_EntityIterator anIterDRE = aGraph.Shareds(aDRE);
2715 for(anIterDRE.Start(); anIterDRE.More(); anIterDRE.Next()) {
2716 if(anIterDRE.Value()->IsKind(STANDARD_TYPE(StepDimTol_Datum)))
2718 Handle(StepDimTol_Datum) aD = Handle(StepDimTol_Datum)::DownCast(anIterDRE.Value());
2719 setDatumToXCAF(aD, theGDTL, aPositionCounter, aXCAFModifiers, aXCAFModifWithVal, aModifValue,theDoc, theWS);
2729 return Standard_True;
2732 //=======================================================================
2733 //function : createGeomTolObjectInXCAF
2735 //=======================================================================
2736 TDF_Label STEPCAFControl_Reader::createGDTObjectInXCAF(const Handle(Standard_Transient)& theEnt,
2737 const Handle(TDocStd_Document)& theDoc,
2738 const Handle(XSControl_WorkSession)& theWS)
2741 if(!theEnt->IsKind(STANDARD_TYPE(StepShape_DimensionalSize)) &&
2742 !theEnt->IsKind(STANDARD_TYPE(StepShape_DimensionalLocation)) &&
2743 !theEnt->IsKind(STANDARD_TYPE(StepDimTol_GeometricTolerance)))
2747 // protection against invalid input
2748 if (theEnt->IsKind(STANDARD_TYPE(StepDimTol_GeometricTolerance))) {
2749 Handle(StepDimTol_GeometricTolerance) aGeomTol = Handle(StepDimTol_GeometricTolerance)::DownCast(theEnt);
2750 if (aGeomTol->TolerancedShapeAspect().IsNull())
2753 if (theEnt->IsKind(STANDARD_TYPE(StepShape_DimensionalSize))) {
2754 Handle(StepShape_DimensionalSize) aDim = Handle(StepShape_DimensionalSize)::DownCast(theEnt);
2755 if (aDim->AppliesTo().IsNull())
2758 if (theEnt->IsKind(STANDARD_TYPE(StepShape_DimensionalLocation))) {
2759 Handle(StepShape_DimensionalLocation) aDim = Handle(StepShape_DimensionalLocation)::DownCast(theEnt);
2760 if (aDim->RelatedShapeAspect().IsNull() || aDim->RelatingShapeAspect().IsNull())
2764 Handle(XCAFDoc_ShapeTool) aSTool = XCAFDoc_DocumentTool::ShapeTool( theDoc->Main() );
2765 Handle(XCAFDoc_DimTolTool) aDGTTool = XCAFDoc_DocumentTool::DimTolTool( theDoc->Main() );
2766 const Handle(XSControl_TransferReader) &aTR = theWS->TransferReader();
2767 const Handle(Transfer_TransientProcess) &aTP = aTR->TransientProcess();
2768 const Interface_Graph& aGraph = aTP->Graph();
2769 Standard_Boolean isAllAround = Standard_False;
2770 Standard_Boolean isAllOver = Standard_False;
2772 // find RepresentationItem for current Ent
2773 NCollection_Sequence<Handle(Standard_Transient)> aSeqRI1, aSeqRI2;
2775 // Collect all Shape_Aspect entities
2776 Interface_EntityIterator anIter = aGraph.Shareds(theEnt);
2777 for(anIter.Start(); anIter.More(); anIter.Next()) {
2778 Handle(Standard_Transient) anAtr = anIter.Value();
2779 NCollection_Sequence<Handle(StepRepr_ShapeAspect)> aSAs;
2780 if(anAtr->IsKind(STANDARD_TYPE(StepRepr_ProductDefinitionShape)))
2782 //if associating tolerances with part (All-Over)
2783 Interface_EntityIterator anIterSDR = aGraph.Sharings(anAtr);
2784 for(anIterSDR.Start(); anIterSDR.More(); anIterSDR.Next())
2786 Handle(Standard_Transient) anAtrSDR = anIterSDR.Value();
2787 if(anAtrSDR->IsKind(STANDARD_TYPE(StepShape_ShapeDefinitionRepresentation)))
2789 isAllOver = Standard_True;
2790 Interface_EntityIterator anIterABSR = aGraph.Shareds(anAtrSDR);
2791 for(anIterABSR.Start(); anIterABSR.More(); anIterABSR.Next())
2793 Handle(Standard_Transient) anAtrABSR = anIterABSR.Value();
2794 if(anAtrABSR->IsKind(STANDARD_TYPE(StepShape_AdvancedBrepShapeRepresentation)))
2796 aSeqRI1.Append(anAtrABSR);
2802 else if(anAtr->IsKind(STANDARD_TYPE(StepShape_DimensionalLocation)) ||
2803 anAtr->IsKind(STANDARD_TYPE(StepShape_DimensionalSize)))
2805 //if tolerance attached to dimension
2806 Interface_EntityIterator anIterDim = aGraph.Shareds(anAtr);
2807 for(anIterDim.Start(); anIterDim.More(); anIterDim.Next())
2809 Handle(StepRepr_ShapeAspect) aSA = Handle(StepRepr_ShapeAspect)::DownCast(anIterDim.Value());
2811 collectShapeAspect(aSA, theWS, aSAs);
2815 else if(anAtr->IsKind(STANDARD_TYPE(StepRepr_ShapeAspect)))
2817 if(anAtr->IsKind(STANDARD_TYPE(StepRepr_AllAroundShapeAspect)))
2819 // if applyed AllAround Modifier
2820 isAllAround = Standard_True;
2822 // dimensions and default tolerances
2823 Handle(StepRepr_ShapeAspect) aSA = Handle(StepRepr_ShapeAspect)::DownCast(anAtr);
2825 collectShapeAspect(aSA, theWS, aSAs);
2829 // Collect all representation items
2832 //get representation items
2833 NCollection_Sequence<Handle(Standard_Transient)> aSeqRI;
2834 for(Standard_Integer i = aSAs.Lower(); i <= aSAs.Upper(); i++)
2836 Interface_EntityIterator anIterSA = aGraph.Sharings(aSAs.Value(i));
2837 Handle(StepAP242_GeometricItemSpecificUsage) aGISU;
2838 Handle(StepRepr_PropertyDefinition) PropD;
2839 for(anIterSA.Start(); anIterSA.More() && aGISU.IsNull() && PropD.IsNull(); anIterSA.Next()) {
2840 aGISU = Handle(StepAP242_GeometricItemSpecificUsage)::DownCast(anIterSA.Value());
2841 PropD = Handle(StepRepr_PropertyDefinition)::DownCast(anIterSA.Value());
2843 if(!PropD.IsNull())//for old version
2845 Handle(StepRepr_RepresentationItem) RI;
2846 Interface_EntityIterator subs4 = aGraph.Sharings(PropD);
2847 for(subs4.Start(); subs4.More(); subs4.Next()) {
2848 Handle(StepShape_ShapeDefinitionRepresentation) SDR =
2849 Handle(StepShape_ShapeDefinitionRepresentation)::DownCast(subs4.Value());
2851 Handle(StepRepr_Representation) Repr = SDR->UsedRepresentation();
2852 if( !Repr.IsNull() && Repr->NbItems()>0 ) {
2853 RI = Repr->ItemsValue(1);
2857 if(RI.IsNull()) continue;
2859 if(theEnt->IsKind(STANDARD_TYPE(StepShape_DimensionalSize))) {
2861 Handle(StepShape_EdgeCurve) EC = Handle(StepShape_EdgeCurve)::DownCast(RI);
2862 if(EC.IsNull()) continue;
2863 Handle(TCollection_HAsciiString) aName;
2864 Handle(StepShape_DimensionalSize) DimSize =
2865 Handle(StepShape_DimensionalSize)::DownCast(theEnt);
2866 Standard_Real dim1=-1.,dim2=-1.;
2867 subs4 = aGraph.Sharings(DimSize);
2868 for(subs4.Start(); subs4.More(); subs4.Next()) {
2869 Handle(StepShape_DimensionalCharacteristicRepresentation) DimCharR =
2870 Handle(StepShape_DimensionalCharacteristicRepresentation)::DownCast(subs4.Value());
2871 if(!DimCharR.IsNull()) {
2872 Handle(StepShape_ShapeDimensionRepresentation) SDimR = DimCharR->Representation();
2873 if(!SDimR.IsNull() && SDimR->NbItems()>0) {
2874 Handle(StepRepr_RepresentationItem) anItem = SDimR->ItemsValue(1);
2875 Handle(StepRepr_ValueRange) VR = Handle(StepRepr_ValueRange)::DownCast(anItem);
2878 //StepRepr_CompoundItemDefinition CID = VR->ItemElement();
2879 //if(CID.IsNull()) continue;
2880 //Handle(StepRepr_CompoundItemDefinitionMember) CIDM =
2881 // Handle(StepRepr_CompoundItemDefinitionMember)::DownCast(CID.Value());
2882 //if(CIDM.IsNull()) continue;
2883 //if(CIDM->ArrTransient().IsNull()) continue;
2884 //Handle(StepRepr_HArray1OfRepresentationItem) HARI;
2885 //if(CID.CaseMem(CIDM)==1)
2886 // HARI = CID.ListRepresentationItem();
2887 //if(CID.CaseMem(CIDM)==2)
2888 // HARI = CID.SetRepresentationItem();
2889 Handle(StepRepr_HArray1OfRepresentationItem) HARI = VR->ItemElement();
2890 if(HARI.IsNull()) continue;
2891 if(HARI->Length()>0) {
2892 Handle(StepRepr_RepresentationItem) RI1 = HARI->Value(1);
2893 if(RI1.IsNull()) continue;
2894 if(RI1->IsKind(STANDARD_TYPE(StepRepr_ReprItemAndLengthMeasureWithUnit))) {
2895 Handle(StepRepr_ReprItemAndLengthMeasureWithUnit) RILMWU =
2896 Handle(StepRepr_ReprItemAndLengthMeasureWithUnit)::DownCast(RI1);
2897 dim1 = RILMWU->GetMeasureWithUnit()->ValueComponent();
2898 StepBasic_Unit anUnit = RILMWU->GetMeasureWithUnit()->UnitComponent();
2899 Standard_Real afact=1.;
2900 if(anUnit.IsNull()) continue;
2901 if( !(anUnit.CaseNum(anUnit.Value())==1) ) continue;
2902 Handle(StepBasic_NamedUnit) NU = anUnit.NamedUnit();
2903 if(GetLengthConversionFactor(NU,afact)) dim1=dim1*afact;
2906 if(HARI->Length()>1) {
2907 Handle(StepRepr_RepresentationItem) RI2 = HARI->Value(2);
2908 if(RI2.IsNull()) continue;
2909 if(RI2->IsKind(STANDARD_TYPE(StepRepr_ReprItemAndLengthMeasureWithUnit))) {
2910 Handle(StepRepr_ReprItemAndLengthMeasureWithUnit) RILMWU =
2911 Handle(StepRepr_ReprItemAndLengthMeasureWithUnit)::DownCast(RI2);
2912 dim2 = RILMWU->GetMeasureWithUnit()->ValueComponent();
2913 StepBasic_Unit anUnit = RILMWU->GetMeasureWithUnit()->UnitComponent();
2914 Standard_Real afact=1.;
2915 if(anUnit.IsNull()) continue;
2916 if( !(anUnit.CaseNum(anUnit.Value())==1) ) continue;
2917 Handle(StepBasic_NamedUnit) NU = anUnit.NamedUnit();
2918 if(GetLengthConversionFactor(NU,afact)) dim2 = dim2*afact;
2925 if(dim1<0) continue;
2926 if(dim2<0) dim2=dim1;
2927 //cout<<"DimensionalSize: dim1="<<dim1<<" dim2="<<dim2<<endl;
2928 // now we know edge_curve and value range therefore
2929 // we can create corresponding D> labels
2930 Standard_Integer index = aTP->MapIndex(EC);
2933 Handle(Transfer_Binder) binder = aTP->MapItem(index);
2934 aSh = TransferBRep::ShapeResult(binder);
2936 if(aSh.IsNull()) continue;
2938 if( !aSTool->Search(aSh, shL, Standard_True, Standard_True, Standard_True) ) continue;
2939 Handle(TColStd_HArray1OfReal) arr = new TColStd_HArray1OfReal(1,2);
2940 arr->SetValue(1,dim1);
2941 arr->SetValue(2,dim2);
2942 aDGTTool->SetDimTol(shL,1,arr,aName,DimSize->Name());
2944 // read tolerances and datums
2945 else if(theEnt->IsKind(STANDARD_TYPE(StepDimTol_GeometricTolerance))) {
2946 Handle(StepDimTol_GeometricTolerance) GT =
2947 Handle(StepDimTol_GeometricTolerance)::DownCast(theEnt);
2948 // read common data for tolerance
2949 //Standard_Real dim = GT->Magnitude()->ValueComponent();
2950 Handle (StepBasic_MeasureWithUnit) dim3 = GT->Magnitude();
2951 if(dim3.IsNull()) continue;
2952 Standard_Real dim = dim3->ValueComponent();
2953 StepBasic_Unit anUnit = GT->Magnitude()->UnitComponent();
2954 Standard_Real afact=1.;
2955 if(anUnit.IsNull()) continue;
2956 if( !(anUnit.CaseNum(anUnit.Value())==1) ) continue;
2957 Handle(StepBasic_NamedUnit) NU = anUnit.NamedUnit();
2958 if(GetLengthConversionFactor(NU,afact)) dim = dim*afact;
2959 //cout<<"GeometricTolerance: Magnitude = "<<dim<<endl;
2960 Handle(TColStd_HArray1OfReal) arr = new TColStd_HArray1OfReal(1,1);
2961 arr->SetValue(1,dim);
2962 Handle(TCollection_HAsciiString) aName = GT->Name();
2963 Handle(TCollection_HAsciiString) aDescription = GT->Description();
2964 Handle(StepShape_AdvancedFace) AF = Handle(StepShape_AdvancedFace)::DownCast(RI);
2965 if(AF.IsNull()) continue;
2966 Standard_Integer index = aTP->MapIndex(AF);
2969 Handle(Transfer_Binder) binder = aTP->MapItem(index);
2970 aSh = TransferBRep::ShapeResult(binder);
2972 if(aSh.IsNull()) continue;
2974 if( !aSTool->Search(aSh, shL, Standard_True, Standard_True, Standard_True) ) continue;
2975 // read specific data for tolerance
2976 if(GT->IsKind(STANDARD_TYPE(StepDimTol_GeoTolAndGeoTolWthDatRefAndModGeoTolAndPosTol))) {
2977 Handle(StepDimTol_GeoTolAndGeoTolWthDatRefAndModGeoTolAndPosTol) GTComplex =
2978 Handle(StepDimTol_GeoTolAndGeoTolWthDatRefAndModGeoTolAndPosTol)::DownCast(theEnt);
2979 Standard_Integer kind=20;
2980 Handle(StepDimTol_ModifiedGeometricTolerance) MGT =
2981 GTComplex->GetModifiedGeometricTolerance();
2983 kind = kind + MGT->Modifier()+1;
2985 TDF_Label TolerL = aDGTTool->SetDimTol(shL,kind,arr,aName,aDescription);
2986 // translate datums connected with this tolerance
2987 Handle(StepDimTol_GeometricToleranceWithDatumReference) GTWDR =
2988 GTComplex->GetGeometricToleranceWithDatumReference();
2989 if(!GTWDR.IsNull()) {
2990 ReadDatums(aSTool,aDGTTool,aGraph,aTP,TolerL,GTWDR);
2993 else if(GT->IsKind(STANDARD_TYPE(StepDimTol_GeometricToleranceWithDatumReference))) {
2994 Handle(StepDimTol_GeometricToleranceWithDatumReference) GTWDR =
2995 Handle(StepDimTol_GeometricToleranceWithDatumReference)::DownCast(theEnt);
2996 if(GTWDR.IsNull()) continue;
2997 Standard_Integer kind = 0;
2998 if (GTWDR->IsKind(STANDARD_TYPE(StepDimTol_AngularityTolerance))) kind = 24;
2999 else if(GTWDR->IsKind(STANDARD_TYPE(StepDimTol_CircularRunoutTolerance))) kind = 25;
3000 else if(GTWDR->IsKind(STANDARD_TYPE(StepDimTol_CoaxialityTolerance))) kind = 26;
3001 else if(GTWDR->IsKind(STANDARD_TYPE(StepDimTol_ConcentricityTolerance))) kind = 27;
3002 else if(GTWDR->IsKind(STANDARD_TYPE(StepDimTol_ParallelismTolerance))) kind = 28;
3003 else if(GTWDR->IsKind(STANDARD_TYPE(StepDimTol_PerpendicularityTolerance))) kind = 29;
3004 else if(GTWDR->IsKind(STANDARD_TYPE(StepDimTol_SymmetryTolerance))) kind = 30;
3005 else if(GTWDR->IsKind(STANDARD_TYPE(StepDimTol_TotalRunoutTolerance))) kind = 31;
3006 //cout<<"GTWDR: kind="<<kind<<endl;
3007 TDF_Label TolerL = aDGTTool->SetDimTol(shL,kind,arr,aName,aDescription);
3008 ReadDatums(aSTool,aDGTTool,aGraph,aTP,TolerL,GTWDR);
3010 else if(GT->IsKind(STANDARD_TYPE(StepDimTol_ModifiedGeometricTolerance))) {
3011 Handle(StepDimTol_ModifiedGeometricTolerance) MGT =
3012 Handle(StepDimTol_ModifiedGeometricTolerance)::DownCast(theEnt);
3013 Standard_Integer kind = 35 + MGT->Modifier();
3014 aDGTTool->SetDimTol(shL,kind,arr,aName,aDescription);
3016 else if(GT->IsKind(STANDARD_TYPE(StepDimTol_CylindricityTolerance))) {
3017 aDGTTool->SetDimTol(shL,38,arr,aName,aDescription);
3019 else if(GT->IsKind(STANDARD_TYPE(StepDimTol_FlatnessTolerance))) {
3020 aDGTTool->SetDimTol(shL,39,arr,aName,aDescription);
3022 else if(GT->IsKind(STANDARD_TYPE(StepDimTol_LineProfileTolerance))) {
3023 aDGTTool->SetDimTol(shL,40,arr,aName,aDescription);
3025 else if(GT->IsKind(STANDARD_TYPE(StepDimTol_PositionTolerance))) {
3026 aDGTTool->SetDimTol(shL,41,arr,aName,aDescription);
3028 else if(GT->IsKind(STANDARD_TYPE(StepDimTol_RoundnessTolerance))) {
3029 aDGTTool->SetDimTol(shL,42,arr,aName,aDescription);
3031 else if(GT->IsKind(STANDARD_TYPE(StepDimTol_StraightnessTolerance))) {
3032 aDGTTool->SetDimTol(shL,43,arr,aName,aDescription);
3034 else if(GT->IsKind(STANDARD_TYPE(StepDimTol_SurfaceProfileTolerance))) {
3035 aDGTTool->SetDimTol(shL,44,arr,aName,aDescription);
3041 if(aGISU.IsNull()) continue;
3042 Standard_Integer j =1;
3043 for ( ; j <= aGISU->NbIdentifiedItem(); j++) {
3044 aSeqRI.Append(aGISU->IdentifiedItemValue(j));
3048 if(!aSeqRI.IsEmpty())
3050 if(aSeqRI1.IsEmpty())
3057 if(aSeqRI1.IsEmpty())
3060 TDF_LabelSequence aShLS1, aShLS2;
3063 for(Standard_Integer i = aSeqRI1.Lower(); i <= aSeqRI1.Upper() ;i++)
3065 Standard_Integer anIndex = FindShapeIndexForDGT(aSeqRI1.Value(i), theWS);
3068 Handle(Transfer_Binder) aBinder = aTP->MapItem(anIndex);
3069 aSh = TransferBRep::ShapeResult(aBinder);
3074 aSTool->Search(aSh, aShL, Standard_True, Standard_True, Standard_True);
3075 aShLS1.Append(aShL);
3078 if (!aSeqRI2.IsEmpty())
3080 //for dimensional location
3081 for(Standard_Integer i = aSeqRI2.Lower(); i <= aSeqRI2.Upper() ;i++)
3083 Standard_Integer anIndex = FindShapeIndexForDGT(aSeqRI2.Value(i), theWS);
3086 Handle(Transfer_Binder) aBinder = aTP->MapItem(anIndex);
3087 aSh = TransferBRep::ShapeResult(aBinder);
3092 aSTool->Search(aSh, aShL, Standard_True, Standard_True, Standard_True);
3093 aShLS2.Append(aShL);
3098 if(!aShLS1.IsEmpty())
3101 if(!theEnt->IsKind(STANDARD_TYPE(StepDimTol_GeometricTolerance)))
3103 aGDTL = aDGTTool->AddDimension();
3104 myGDTMap.Bind(theEnt, aGDTL);
3105 aDGTTool->Lock(aGDTL);
3106 Handle(XCAFDoc_Dimension) aDim = XCAFDoc_Dimension::Set(aGDTL);
3107 TCollection_AsciiString aStr("DGT:Dimensional_");
3108 if(theEnt->IsKind(STANDARD_TYPE(StepShape_DimensionalSize)))
3110 aStr.AssignCat("Size");
3112 else if(theEnt->IsKind(STANDARD_TYPE(StepShape_DimensionalLocation)))
3114 aStr.AssignCat("Location");
3116 TDataStd_Name::Set(aGDTL, aStr);
3118 if(!aShLS2.IsEmpty())
3120 aDGTTool->SetDimension(aShLS1, aShLS2, aGDTL);
3124 TDF_LabelSequence aEmptySeq;
3125 aDGTTool->SetDimension(aShLS1, aEmptySeq, aGDTL);
3130 aGDTL = aDGTTool->AddGeomTolerance();
3131 myGDTMap.Bind(theEnt, aGDTL);
3132 aDGTTool->Lock(aGDTL);
3133 Handle(XCAFDoc_GeomTolerance) aGTol = XCAFDoc_GeomTolerance::Set(aGDTL);
3134 TCollection_AsciiString aStr("DGT:GeomTolerance");
3135 TDataStd_Name::Set(aGDTL, aStr);
3136 aDGTTool->SetGeomTolerance(aShLS1, aGDTL);
3137 Handle(XCAFDimTolObjects_GeomToleranceObject) anObj = aGTol->GetObject();
3139 anObj->AddModifier(XCAFDimTolObjects_GeomToleranceModif_All_Around);
3141 anObj->AddModifier(XCAFDimTolObjects_GeomToleranceModif_All_Over);
3142 aGTol->SetObject(anObj);
3144 readDatumsAP242(theEnt, aGDTL, theDoc, theWS);
3149 //=======================================================================
3150 //function : setDimObjectToXCAF
3152 //=======================================================================
3153 static void setDimObjectToXCAF(const Handle(Standard_Transient)& theEnt,
3154 const TDF_Label& aDimL,
3155 const Handle(TDocStd_Document)& theDoc,
3156 const Handle(XSControl_WorkSession)& theWS)
3158 Handle(XCAFDoc_ShapeTool) aSTool = XCAFDoc_DocumentTool::ShapeTool( theDoc->Main() );
3159 Handle(XCAFDoc_DimTolTool) aDGTTool = XCAFDoc_DocumentTool::DimTolTool( theDoc->Main() );
3160 const Handle(XSControl_TransferReader) &aTR = theWS->TransferReader();
3161 const Handle(Transfer_TransientProcess) &aTP = aTR->TransientProcess();
3162 const Interface_Graph& aGraph = aTP->Graph();
3163 Handle(XCAFDimTolObjects_DimensionObject) aDimObj;
3164 if(!theEnt->IsKind(STANDARD_TYPE(StepShape_DimensionalSize)) &&
3165 !theEnt->IsKind(STANDARD_TYPE(StepShape_DimensionalLocation)))
3168 Handle(StepShape_DimensionalSize) aDimSize =
3169 Handle(StepShape_DimensionalSize)::DownCast(theEnt);
3170 Handle(StepShape_DimensionalLocation) aDimLocation =
3171 Handle(StepShape_DimensionalLocation)::DownCast(theEnt);
3173 aDimObj = new XCAFDimTolObjects_DimensionObject();
3174 Standard_Real aDim1=-1.,aDim2=-1.,aDim3=-1.;
3175 Handle(StepShape_TypeQualifier) aTQ;
3176 Handle(StepShape_ValueFormatTypeQualifier) aVFTQ;
3177 Handle(StepShape_ToleranceValue) aTV;
3178 Handle(StepShape_LimitsAndFits) aLAF;
3179 Handle(StepRepr_CompoundRepresentationItem) aCRI;
3180 Handle(StepGeom_Axis2Placement3d) anAP;
3182 Interface_EntityIterator anIterDim;
3183 if(!aDimSize.IsNull())
3185 anIterDim = aGraph.Sharings(aDimSize);
3189 anIterDim = aGraph.Sharings(aDimLocation);
3191 for(anIterDim.Start(); anIterDim.More(); anIterDim.Next()) {
3192 Handle(StepShape_DimensionalCharacteristicRepresentation) aDCR =
3193 Handle(StepShape_DimensionalCharacteristicRepresentation)::DownCast(anIterDim.Value());
3194 Handle(StepShape_PlusMinusTolerance) aPMT =
3195 Handle(StepShape_PlusMinusTolerance)::DownCast(anIterDim.Value());
3196 if(!aDCR.IsNull()) {
3197 Handle(StepShape_ShapeDimensionRepresentation) aSDR = aDCR->Representation();
3198 if(!aSDR.IsNull()) {
3199 Handle(StepRepr_HArray1OfRepresentationItem) aHARI = aSDR->Items();
3203 for(Standard_Integer nr = aHARI->Lower(); nr <= aHARI->Upper(); nr++)
3205 Handle(StepRepr_RepresentationItem) aDRI = aHARI->Value(nr);
3206 if(aDRI.IsNull()) continue;
3208 if(aDRI->IsKind(STANDARD_TYPE(StepRepr_ReprItemAndLengthMeasureWithUnit))) {
3210 Handle(StepRepr_ReprItemAndLengthMeasureWithUnit) aRILMWU =
3211 Handle(StepRepr_ReprItemAndLengthMeasureWithUnit)::DownCast(aDRI);
3212 Standard_Real aVal = aRILMWU->GetMeasureWithUnit()->ValueComponent();
3213 StepBasic_Unit anUnit = aRILMWU->GetMeasureWithUnit()->UnitComponent();
3214 Standard_Real aFact=1.;
3215 if(anUnit.IsNull()) continue;
3216 if( !(anUnit.CaseNum(anUnit.Value())==1) ) continue;
3217 Handle(StepBasic_NamedUnit) NU = anUnit.NamedUnit();
3218 if(GetLengthConversionFactor(NU,aFact)) aVal=aVal*aFact;
3223 Standard_Real aTmp = aDim1;
3229 else if(aVal > aDim2)
3245 else if(aDRI->IsKind(STANDARD_TYPE(StepRepr_ReprItemAndPlaneAngleMeasureWithUnit))) {
3247 Handle(StepRepr_ReprItemAndPlaneAngleMeasureWithUnit) aRIPAMWU =
3248 Handle(StepRepr_ReprItemAndPlaneAngleMeasureWithUnit)::DownCast(aDRI);
3249 Standard_Real aVal = aRIPAMWU->GetMeasureWithUnit()->ValueComponent();
3250 StepBasic_Unit anUnit = aRIPAMWU->GetMeasureWithUnit()->UnitComponent();
3251 Standard_Real aFact=1.;
3252 if(anUnit.IsNull()) continue;
3253 if( !(anUnit.CaseNum(anUnit.Value())==1) ) continue;
3254 Handle(StepBasic_NamedUnit) NU = anUnit.NamedUnit();
3255 if(GetAngleConversionFactor(NU,aFact)) aVal=aVal*aFact;
3260 Standard_Real aTmp = aDim1;
3266 else if(aVal > aDim2)
3282 else if(aDRI->IsKind(STANDARD_TYPE(StepShape_QualifiedRepresentationItem))) {
3284 Handle(StepShape_QualifiedRepresentationItem) aQRI =
3285 Handle(StepShape_QualifiedRepresentationItem)::DownCast(aDRI);
3286 for(Standard_Integer l = 1; l <= aQRI->NbQualifiers(); l++)
3288 aTQ = aQRI->Qualifiers()->Value(l).TypeQualifier();
3289 aVFTQ = aQRI->Qualifiers()->Value(l).ValueFormatTypeQualifier();
3292 else if (aDRI->IsKind(STANDARD_TYPE(StepRepr_DescriptiveRepresentationItem))) {
3293 Handle(StepRepr_DescriptiveRepresentationItem) aDescription =
3294 Handle(StepRepr_DescriptiveRepresentationItem)::DownCast(aDRI);
3295 aDimObj->AddDescription(aDescription->Description(), aDescription->Name());
3297 else if(aDRI->IsKind(STANDARD_TYPE(StepRepr_CompoundRepresentationItem))) {
3298 aCRI = Handle(StepRepr_CompoundRepresentationItem)::DownCast(aDRI);
3300 else if(aDRI->IsKind(STANDARD_TYPE(StepGeom_Axis2Placement3d)))
3302 anAP = Handle(StepGeom_Axis2Placement3d)::DownCast(aDRI);
3308 else if (!aPMT.IsNull())
3310 StepShape_ToleranceMethodDefinition aTMD = aPMT->Range();
3311 if(aPMT.IsNull()) continue;
3312 if(aTMD.CaseNumber() == 1)
3313 //! 1 -> ToleranceValue from StepShape
3314 //! 2 -> LimitsAndFits from StepShape
3316 //plus minus tolerance
3317 aTV = aTMD.ToleranceValue();
3318 if (aTV.IsNull()) continue;
3320 Standard_Real aVal = aTV->UpperBound()->ValueComponent();
3321 StepBasic_Unit anUnit = aTV->UpperBound()->UnitComponent();
3322 Standard_Real aFact=1.;
3323 if(anUnit.IsNull()) continue;
3324 if( !(anUnit.CaseNum(anUnit.Value())==1) ) continue;
3325 Handle(StepBasic_NamedUnit) NU = anUnit.NamedUnit();
3326 if(GetLengthConversionFactor(NU,aFact)) aVal=aVal*aFact;
3329 aVal = aTV->LowerBound()->ValueComponent();
3330 anUnit = aTV->LowerBound()->UnitComponent();
3332 if(anUnit.IsNull()) continue;
3333 if( !(anUnit.CaseNum(anUnit.Value())==1) ) continue;
3334 NU = anUnit.NamedUnit();
3335 if(GetLengthConversionFactor(NU,aFact)) aVal=aVal*aFact;
3340 // class of tolerance
3341 aLAF = aTMD.LimitsAndFits();
3349 aDimObj->SetValue(aDim1);
3352 Handle(TColStd_HArray1OfReal) anArr = new TColStd_HArray1OfReal(1,2);
3353 anArr->SetValue(1,aDim1);
3354 anArr->SetValue(2,aDim2);
3355 aDimObj->SetValues(anArr);
3359 Handle(TColStd_HArray1OfReal) anArr = new TColStd_HArray1OfReal(1,3);
3360 anArr->SetValue(1,aDim1);
3361 anArr->SetValue(2,aDim2);
3362 anArr->SetValue(3,aDim3);
3363 aDimObj->SetValues(anArr);
3367 XCAFDimTolObjects_DimensionQualifier aQ;
3368 if (STEPCAFControl_GDTProperty::GetDimQualifierType(aTQ->Name(), aQ))
3370 aDimObj->SetQualifier(aQ);
3374 if (!aVFTQ.IsNull())
3376 //A typical value would be 'NR2 2.2'
3377 TCollection_HAsciiString aFormat = aVFTQ->FormatType();
3378 Standard_Integer i = aFormat.Location(1,' ',1,aFormat.Length());
3379 aFormat.SubString(i+1,i+1)->IntegerValue();
3380 aDimObj->SetNbOfDecimalPlaces(aFormat.SubString(i+1,i+1)->IntegerValue(),
3381 aFormat.SubString(i+3,i+3)->IntegerValue());
3386 //get class of tolerance
3387 Standard_Boolean aHolle = Standard_False;
3388 XCAFDimTolObjects_DimensionFormVariance aFV = XCAFDimTolObjects_DimensionFormVariance_None;
3389 XCAFDimTolObjects_DimensionGrade aG = XCAFDimTolObjects_DimensionGrade_IT01;
3390 STEPCAFControl_GDTProperty::GetDimClassOfTolerance(aLAF, aHolle, aFV, aG);
3391 aDimObj->SetClassOfTolerance(aHolle, aFV, aG);
3394 if (!aCRI.IsNull() && aCRI->ItemElement()->Length() > 0)
3397 XCAFDimTolObjects_DimensionModifiersSequence aModifiers;
3398 STEPCAFControl_GDTProperty::GetDimModifiers(aCRI, aModifiers);
3399 if(aModifiers.Length() > 0)
3400 aDimObj->SetModifiers(aModifiers);
3403 Handle(TCollection_HAsciiString) aName;
3404 if(!aDimSize.IsNull())
3406 aName = aDimSize->Name();
3410 aName = aDimLocation->Name();
3412 XCAFDimTolObjects_DimensionType aType = XCAFDimTolObjects_DimensionType_Location_None;
3413 if (!STEPCAFControl_GDTProperty::GetDimType(aName, aType))
3415 if(!aDimSize.IsNull())
3417 Handle(StepShape_AngularSize) anAngSize=
3418 Handle(StepShape_AngularSize)::DownCast(aDimSize);
3419 if(!anAngSize.IsNull())
3421 //get qualifier for angular value
3422 aType = XCAFDimTolObjects_DimensionType_Size_Angular;
3423 if(anAngSize->AngleSelection() == StepShape_Equal)
3424 aDimObj->SetQualifier(XCAFDimTolObjects_DimensionQualifier_Avg);
3425 else if (anAngSize->AngleSelection() == StepShape_Large)
3426 aDimObj->SetQualifier(XCAFDimTolObjects_DimensionQualifier_Max);
3427 else if (anAngSize->AngleSelection() == StepShape_Small)
3428 aDimObj->SetQualifier(XCAFDimTolObjects_DimensionQualifier_Min);
3433 Handle(StepShape_AngularLocation) anAngLoc=
3434 Handle(StepShape_AngularLocation)::DownCast(aDimLocation);
3435 if(!anAngLoc.IsNull())
3437 //get qualifier for angular value
3438 aType = XCAFDimTolObjects_DimensionType_Location_Angular;
3439 if(anAngLoc->AngleSelection() == StepShape_Equal)
3440 aDimObj->SetQualifier(XCAFDimTolObjects_DimensionQualifier_Avg);
3441 else if (anAngLoc->AngleSelection() == StepShape_Large)
3442 aDimObj->SetQualifier(XCAFDimTolObjects_DimensionQualifier_Max);
3443 else if (anAngLoc->AngleSelection() == StepShape_Small)
3444 aDimObj->SetQualifier(XCAFDimTolObjects_DimensionQualifier_Min);
3447 if(aType == XCAFDimTolObjects_DimensionType_Location_None)
3449 Handle(StepRepr_ShapeAspect) aPSA;
3450 if(!aDimSize.IsNull())
3452 Handle(StepShape_DimensionalSizeWithPath) aDimSizeWithPath=
3453 Handle(StepShape_DimensionalSizeWithPath)::DownCast(aDimSize);
3454 if (!aDimSizeWithPath.IsNull())
3456 aType = XCAFDimTolObjects_DimensionType_Size_WithPath;
3457 aPSA = aDimSizeWithPath->Path();
3462 Handle(StepShape_DimensionalLocationWithPath) aDimLocWithPath=
3463 Handle(StepShape_DimensionalLocationWithPath)::DownCast(aDimLocation);
3464 if (!aDimLocWithPath.IsNull())
3466 aType = XCAFDimTolObjects_DimensionType_Location_WithPath;
3467 aPSA = aDimLocWithPath->Path();
3473 //for DimensionalLocationWithPath
3474 Handle(StepGeom_GeometricRepresentationItem) aGRI;
3475 Handle(StepAP242_GeometricItemSpecificUsage) aPGISU;
3476 Interface_EntityIterator anIterDSWP = aGraph.Sharings(aPSA);
3477 for(anIterDSWP.Start(); anIterDSWP.More() && aPGISU.IsNull(); anIterDSWP.Next()) {
3478 aPGISU = Handle(StepAP242_GeometricItemSpecificUsage)::DownCast(anIterDSWP.Value());
3480 if(aPGISU.IsNull()) return;
3481 if(aPGISU->NbIdentifiedItem() > 0) {
3482 aGRI = Handle(StepGeom_GeometricRepresentationItem)::DownCast(aPGISU->IdentifiedItemValue(1));
3484 if(aGRI.IsNull()) return;
3485 Handle(StepRepr_RepresentationItem) aPRI;
3486 Interface_EntityIterator anIterGRI = aGraph.Sharings(aGRI);
3487 for(anIterGRI.Start(); anIterGRI.More() && aPGISU.IsNull(); anIterGRI.Next()) {
3488 aPRI = Handle(StepRepr_RepresentationItem)::DownCast(anIterGRI.Value());
3490 Standard_Integer anIndex = FindShapeIndexForDGT(aPRI, theWS);
3493 Handle(Transfer_Binder) aBinder = aTP->MapItem(anIndex);
3494 aSh = TopoDS::Edge(TransferBRep::ShapeResult(aBinder));
3496 if(aSh.IsNull()) return;
3497 aDimObj->SetPath(aSh);
3499 else if(!anAP.IsNull())
3501 if(anAP->Name()->String().IsEqual("orientation") && !anAP->Axis().IsNull())
3503 //for Oriented Dimensional Location
3504 Handle(TColStd_HArray1OfReal) aDirArr = anAP->RefDirection()->DirectionRatios();
3506 if(!aDirArr.IsNull() && aDirArr->Length() > 2)
3508 aDir.SetCoord(aDirArr->Lower(), aDirArr->Lower()+1, aDirArr->Lower()+2);
3509 aDimObj->SetDirection(aDir);
3511 else if(aDirArr->Length() > 1)
3513 aDir.SetCoord(aDirArr->Lower(), aDirArr->Lower()+1, 0);
3514 aDimObj->SetDirection(aDir);
3520 aDimObj->SetType(aType);
3523 if(!aDimObj.IsNull())
3526 Handle(XCAFDoc_Dimension) aDim;
3528 if(aDimL.FindAttribute(XCAFDoc_Dimension::GetID(),aDim))
3530 readAnnotation(aTR, theEnt, aDimObj);
3531 readConnectionPoints(aTR, theEnt, aDimObj);
3532 aDim->SetObject(aDimObj);
3537 //=======================================================================
3538 //function : getTolType
3540 //=======================================================================
3541 static Standard_Boolean getTolType(const Handle(Standard_Transient)& theEnt,
3542 XCAFDimTolObjects_GeomToleranceType& theType)
3544 if(theEnt.IsNull() || !theEnt->IsKind(STANDARD_TYPE(StepDimTol_GeometricTolerance)))
3545 return Standard_False;
3546 theType = XCAFDimTolObjects_GeomToleranceType_None;
3547 if (theEnt->IsKind(STANDARD_TYPE(StepDimTol_GeoTolAndGeoTolWthDatRef)))
3549 Handle(StepDimTol_GeoTolAndGeoTolWthDatRef) anE = Handle(StepDimTol_GeoTolAndGeoTolWthDatRef)::DownCast(theEnt);
3550 theType = STEPCAFControl_GDTProperty::GetGeomToleranceType(anE->GetToleranceType());
3552 else if (theEnt->IsKind(STANDARD_TYPE(StepDimTol_GeoTolAndGeoTolWthDatRefAndGeoTolWthMaxTol)))
3554 Handle(StepDimTol_GeoTolAndGeoTolWthDatRefAndGeoTolWthMaxTol) anE =
3555 Handle(StepDimTol_GeoTolAndGeoTolWthDatRefAndGeoTolWthMaxTol)::DownCast(theEnt);
3556 theType = STEPCAFControl_GDTProperty::GetGeomToleranceType(anE->GetToleranceType());
3558 else if (theEnt->IsKind(STANDARD_TYPE(StepDimTol_GeoTolAndGeoTolWthDatRefAndGeoTolWthMod)))
3560 Handle(StepDimTol_GeoTolAndGeoTolWthDatRefAndGeoTolWthMod) anE =
3561 Handle(StepDimTol_GeoTolAndGeoTolWthDatRefAndGeoTolWthMod)::DownCast(theEnt);
3562 theType = STEPCAFControl_GDTProperty::GetGeomToleranceType(anE->GetToleranceType());
3564 else if (theEnt->IsKind(STANDARD_TYPE(StepDimTol_GeoTolAndGeoTolWthMaxTol)))
3566 Handle(StepDimTol_GeoTolAndGeoTolWthMaxTol) anE =
3567 Handle(StepDimTol_GeoTolAndGeoTolWthMaxTol)::DownCast(theEnt);
3568 theType = STEPCAFControl_GDTProperty::GetGeomToleranceType(anE->GetToleranceType());
3570 else if (theEnt->IsKind(STANDARD_TYPE(StepDimTol_GeoTolAndGeoTolWthMod)))
3572 Handle(StepDimTol_GeoTolAndGeoTolWthMod) anE =
3573 Handle(StepDimTol_GeoTolAndGeoTolWthMod)::DownCast(theEnt);
3574 theType = STEPCAFControl_GDTProperty::GetGeomToleranceType(anE->GetToleranceType());
3576 else if (theEnt->IsKind(STANDARD_TYPE(StepDimTol_GeoTolAndGeoTolWthDatRefAndUneqDisGeoTol)))
3578 Handle(StepDimTol_GeoTolAndGeoTolWthDatRefAndUneqDisGeoTol) anE =
3579 Handle(StepDimTol_GeoTolAndGeoTolWthDatRefAndUneqDisGeoTol)::DownCast(theEnt);
3580 theType = STEPCAFControl_GDTProperty::GetGeomToleranceType(anE->GetToleranceType());
3582 else if(theEnt->IsKind(STANDARD_TYPE(StepDimTol_AngularityTolerance)))
3584 theType = XCAFDimTolObjects_GeomToleranceType_Angularity;
3586 else if(theEnt->IsKind(STANDARD_TYPE(StepDimTol_CircularRunoutTolerance)))
3588 theType = XCAFDimTolObjects_GeomToleranceType_CircularRunout;
3590 else if(theEnt->IsKind(STANDARD_TYPE(StepDimTol_RoundnessTolerance)))
3592 theType = XCAFDimTolObjects_GeomToleranceType_CircularityOrRoundness;
3594 else if(theEnt->IsKind(STANDARD_TYPE(StepDimTol_CoaxialityTolerance)))
3596 theType = XCAFDimTolObjects_GeomToleranceType_Coaxiality;
3598 else if(theEnt->IsKind(STANDARD_TYPE(StepDimTol_ConcentricityTolerance)))
3600 theType = XCAFDimTolObjects_GeomToleranceType_Concentricity;
3602 else if(theEnt->IsKind(STANDARD_TYPE(StepDimTol_CylindricityTolerance)))
3604 theType = XCAFDimTolObjects_GeomToleranceType_Cylindricity;
3606 else if(theEnt->IsKind(STANDARD_TYPE(StepDimTol_FlatnessTolerance)))
3608 theType = XCAFDimTolObjects_GeomToleranceType_Flatness;
3610 else if(theEnt->IsKind(STANDARD_TYPE(StepDimTol_ParallelismTolerance)))
3612 theType = XCAFDimTolObjects_GeomToleranceType_Parallelism;
3614 else if(theEnt->IsKind(STANDARD_TYPE(StepDimTol_PerpendicularityTolerance)))
3616 theType = XCAFDimTolObjects_GeomToleranceType_Perpendicularity;
3618 else if(theEnt->IsKind(STANDARD_TYPE(StepDimTol_PositionTolerance)) ||
3619 theEnt->IsKind(STANDARD_TYPE(StepDimTol_GeoTolAndGeoTolWthDatRefAndModGeoTolAndPosTol)))
3621 theType = XCAFDimTolObjects_GeomToleranceType_Position;
3623 else if(theEnt->IsKind(STANDARD_TYPE(StepDimTol_LineProfileTolerance)))
3625 theType = XCAFDimTolObjects_GeomToleranceType_ProfileOfLine;
3627 else if(theEnt->IsKind(STANDARD_TYPE(StepDimTol_SurfaceProfileTolerance)))
3629 theType = XCAFDimTolObjects_GeomToleranceType_ProfileOfSurface;
3631 else if(theEnt->IsKind(STANDARD_TYPE(StepDimTol_StraightnessTolerance)))
3633 theType = XCAFDimTolObjects_GeomToleranceType_Straightness;
3635 else if(theEnt->IsKind(STANDARD_TYPE(StepDimTol_SymmetryTolerance)))
3637 theType = XCAFDimTolObjects_GeomToleranceType_Symmetry;
3639 else if(theEnt->IsKind(STANDARD_TYPE(StepDimTol_TotalRunoutTolerance)))
3641 theType = XCAFDimTolObjects_GeomToleranceType_TotalRunout;
3643 return Standard_True;
3645 //=======================================================================
3646 //function : setGeomTolObjectToXCAF
3648 //=======================================================================
3649 static void setGeomTolObjectToXCAF(const Handle(Standard_Transient)& theEnt,
3650 const TDF_Label& theTolL,
3651 const Handle(TDocStd_Document)& theDoc,
3652 const Handle(XSControl_WorkSession)& theWS)
3654 Handle(XCAFDoc_ShapeTool) aSTool = XCAFDoc_DocumentTool::ShapeTool( theDoc->Main() );
3655 Handle(XCAFDoc_DimTolTool) aDGTTool = XCAFDoc_DocumentTool::DimTolTool( theDoc->Main() );
3656 const Handle(XSControl_TransferReader) &aTR = theWS->TransferReader();
3657 const Handle(Transfer_TransientProcess) &aTP = aTR->TransientProcess();
3658 const Interface_Graph& aGraph = aTP->Graph();
3659 Handle(XCAFDoc_GeomTolerance) aGTol;
3660 if(!theTolL.FindAttribute(XCAFDoc_GeomTolerance::GetID(), aGTol))
3664 Handle(XCAFDimTolObjects_GeomToleranceObject) aTolObj = aGTol->GetObject();
3665 Handle(StepDimTol_GeometricTolerance) aTolEnt = Handle(StepDimTol_GeometricTolerance)::DownCast(theEnt);
3667 XCAFDimTolObjects_GeomToleranceType aType = XCAFDimTolObjects_GeomToleranceType_None;
3668 getTolType(theEnt, aType);
3669 aTolObj->SetType(aType);
3670 if(!aTolEnt->Magnitude().IsNull()){
3672 Standard_Real aVal = aTolEnt->Magnitude()->ValueComponent();
3673 StepBasic_Unit anUnit = aTolEnt->Magnitude()->UnitComponent();
3674 Standard_Real aFact=1.;
3675 if(anUnit.IsNull()) return;
3676 if( !(anUnit.CaseNum(anUnit.Value())==1) ) return;
3677 Handle(StepBasic_NamedUnit) NU = anUnit.NamedUnit();
3678 if(GetLengthConversionFactor(NU,aFact))
3680 aTolObj->SetValue(aVal);
3683 XCAFDimTolObjects_GeomToleranceTypeValue aTypeV = XCAFDimTolObjects_GeomToleranceTypeValue_None;
3684 Interface_EntityIterator anIter = aGraph.Sharings(aTolEnt);
3685 for(anIter.Start(); anIter.More(); anIter.Next()) {
3686 if(anIter.Value()->IsKind(STANDARD_TYPE(StepDimTol_ToleranceZone))){
3687 Handle(StepDimTol_ToleranceZoneForm) aForm
3688 = Handle(StepDimTol_ToleranceZone)::DownCast(anIter.Value())->Form();
3689 STEPCAFControl_GDTProperty::GetTolValueType(aForm->Name(), aTypeV);
3690 Interface_EntityIterator anIt = aGraph.Sharings(anIter.Value());
3691 for(anIt.Start(); anIt.More(); anIt.Next()) {
3692 if(anIt.Value()->IsKind(STANDARD_TYPE(StepDimTol_ProjectedZoneDefinition))){
3693 Handle(StepDimTol_ProjectedZoneDefinition) aPZone
3694 = Handle(StepDimTol_ProjectedZoneDefinition)::DownCast(anIt.Value());
3695 if(!aPZone->ProjectionLength().IsNull())
3697 Standard_Real aVal = aPZone->ProjectionLength()->ValueComponent();
3698 StepBasic_Unit anUnit = aPZone->ProjectionLength()->UnitComponent();
3699 Standard_Real aFact=1.;
3700 if(anUnit.IsNull()) return;
3701 if( !(anUnit.CaseNum(anUnit.Value())==1) ) return;
3702 Handle(StepBasic_NamedUnit) NU = anUnit.NamedUnit();
3703 if(GetLengthConversionFactor(NU,aFact))
3705 aTolObj->SetValueOfZoneModifier(aVal);
3706 aTolObj->SetZoneModifier(XCAFDimTolObjects_GeomToleranceZoneModif_Projected);
3709 else if (anIt.Value()->IsKind(STANDARD_TYPE(StepDimTol_RunoutZoneDefinition)))
3711 Handle(StepDimTol_RunoutZoneDefinition) aRZone
3712 = Handle(StepDimTol_RunoutZoneDefinition)::DownCast(anIt.Value());
3713 if(!aRZone->Orientation().IsNull())
3715 Standard_Real aVal = aRZone->Orientation()->Angle()->ValueComponent();
3716 StepBasic_Unit anUnit = aRZone->Orientation()->Angle()->UnitComponent();
3717 Standard_Real aFact=1.;
3718 if(anUnit.IsNull()) continue;
3719 if( !(anUnit.CaseNum(anUnit.Value())==1) ) continue;
3720 Handle(StepBasic_NamedUnit) NU = anUnit.NamedUnit();
3721 if(GetAngleConversionFactor(NU,aFact)) aVal=aVal*aFact;
3722 aTolObj->SetValueOfZoneModifier(aVal);
3723 aTolObj->SetZoneModifier(XCAFDimTolObjects_GeomToleranceZoneModif_Runout);
3727 aTolObj->SetTypeOfValue(aTypeV);
3730 Handle(StepDimTol_HArray1OfGeometricToleranceModifier) aModifiers;
3731 if (aTolEnt->IsKind(STANDARD_TYPE(StepDimTol_GeometricToleranceWithModifiers)))
3733 aModifiers = Handle(StepDimTol_GeometricToleranceWithModifiers)::DownCast(aTolEnt)->Modifiers();
3735 else if (aTolEnt->IsKind(STANDARD_TYPE(StepDimTol_GeoTolAndGeoTolWthDatRefAndGeoTolWthMod)))
3737 aModifiers = Handle(StepDimTol_GeoTolAndGeoTolWthDatRefAndGeoTolWthMod)
3738 ::DownCast(aTolEnt)->GetGeometricToleranceWithModifiers()->Modifiers();
3740 else if (aTolEnt->IsKind(STANDARD_TYPE(StepDimTol_GeoTolAndGeoTolWthMod)))
3742 aModifiers = Handle(StepDimTol_GeoTolAndGeoTolWthMod)
3743 ::DownCast(aTolEnt)->GetGeometricToleranceWithModifiers()->Modifiers();
3745 else if (aTolEnt->IsKind(STANDARD_TYPE(StepDimTol_GeoTolAndGeoTolWthMaxTol)))
3747 aModifiers = Handle(StepDimTol_GeoTolAndGeoTolWthMaxTol)
3748 ::DownCast(aTolEnt)->GetGeometricToleranceWithModifiers()->Modifiers();
3750 else if (aTolEnt->IsKind(STANDARD_TYPE(StepDimTol_GeoTolAndGeoTolWthDatRefAndGeoTolWthMaxTol)))
3752 aModifiers = Handle(StepDimTol_GeoTolAndGeoTolWthDatRefAndGeoTolWthMaxTol)
3753 ::DownCast(aTolEnt)->GetGeometricToleranceWithModifiers()->Modifiers();
3755 if(!aModifiers.IsNull())
3757 for(Standard_Integer i = aModifiers->Lower(); i <= aModifiers->Upper(); i++)
3759 if(aModifiers->Value(i) == StepDimTol_GTMLeastMaterialRequirement)
3760 aTolObj->SetMaterialRequirementModifier(XCAFDimTolObjects_GeomToleranceMatReqModif_L);
3761 else if (aModifiers->Value(i) == StepDimTol_GTMMaximumMaterialRequirement)
3762 aTolObj->SetMaterialRequirementModifier(XCAFDimTolObjects_GeomToleranceMatReqModif_M);
3764 aTolObj->AddModifier((XCAFDimTolObjects_GeomToleranceModif)aModifiers->Value(i));
3767 Standard_Real aVal = 0;
3768 StepBasic_Unit anUnit;
3769 if (aTolEnt->IsKind(STANDARD_TYPE(StepDimTol_GeometricToleranceWithMaximumTolerance)))
3771 Handle(StepDimTol_GeometricToleranceWithMaximumTolerance) aMax = Handle(StepDimTol_GeometricToleranceWithMaximumTolerance)::DownCast(aTolEnt);
3772 aVal = aMax->MaximumUpperTolerance()->ValueComponent();
3773 anUnit = aMax->MaximumUpperTolerance()->UnitComponent();
3775 else if (aTolEnt->IsKind(STANDARD_TYPE(StepDimTol_GeoTolAndGeoTolWthMaxTol)))
3777 Handle(StepDimTol_GeoTolAndGeoTolWthMaxTol) aMax =
3778 Handle(StepDimTol_GeoTolAndGeoTolWthMaxTol)::DownCast(aTolEnt);
3779 aVal = aMax->GetMaxTolerance()->ValueComponent();
3780 anUnit = aMax->GetMaxTolerance()->UnitComponent();
3782 else if (aTolEnt->IsKind(STANDARD_TYPE(StepDimTol_GeoTolAndGeoTolWthDatRefAndGeoTolWthMaxTol)))
3784 Handle(StepDimTol_GeoTolAndGeoTolWthDatRefAndGeoTolWthMaxTol) aMax =
3785 Handle(StepDimTol_GeoTolAndGeoTolWthDatRefAndGeoTolWthMaxTol)::DownCast(aTolEnt);
3786 aVal = aMax->GetMaxTolerance()->ValueComponent();
3787 anUnit = aMax->GetMaxTolerance()->UnitComponent();
3789 if (!anUnit.IsNull() && (anUnit.CaseNum(anUnit.Value()) == 1))
3791 Standard_Real aFact=1.;
3792 Handle(StepBasic_NamedUnit) NU = anUnit.NamedUnit();
3793 if(GetAngleConversionFactor(NU,aFact)) aVal=aVal*aFact;
3794 aTolObj->SetMaxValueModifier(aVal);
3797 readAnnotation(aTR, theEnt, aTolObj);
3798 aGTol->SetObject(aTolObj);
3801 //=======================================================================
3802 //function : ReadGDTs
3804 //=======================================================================
3806 Standard_Boolean STEPCAFControl_Reader::ReadGDTs(const Handle(XSControl_WorkSession)& theWS,
3807 Handle(TDocStd_Document)& theDoc)
3809 const Handle(Interface_InterfaceModel) &aModel = theWS->Model();
3810 const Interface_Graph& aGraph = theWS->Graph();
3811 const Handle(XSControl_TransferReader) &aTR = theWS->TransferReader();
3812 Handle(StepData_StepModel) aSM = Handle(StepData_StepModel)::DownCast(aModel);
3813 Interface_EntityIterator anI = aSM->Header();
3814 Handle(HeaderSection_FileSchema) aH;
3815 for(anI.Start(); anI.More() && aH.IsNull();anI.Next())
3816 aH = Handle(HeaderSection_FileSchema)::DownCast(anI.Value());
3817 Handle(XCAFDoc_ShapeTool) aSTool = XCAFDoc_DocumentTool::ShapeTool( theDoc->Main() );
3818 Handle(XCAFDoc_DimTolTool) aDGTTool = XCAFDoc_DocumentTool::DimTolTool( theDoc->Main() );
3819 if ( aDGTTool.IsNull() ) return Standard_False;
3821 Standard_Integer nb = aModel->NbEntities();
3822 for(Standard_Integer i=1; i<=nb; i++) {
3823 Handle(Standard_Transient) anEnt = aModel->Value(i);
3824 if(anEnt->IsKind(STANDARD_TYPE(StepShape_DimensionalSize)) ||
3825 anEnt->IsKind(STANDARD_TYPE(StepShape_DimensionalLocation)) ||
3826 anEnt->IsKind(STANDARD_TYPE(StepDimTol_GeometricTolerance))) {
3827 TDF_Label aGDTL = createGDTObjectInXCAF(anEnt,theDoc,theWS);
3828 if(!aGDTL.IsNull()){
3829 if(anEnt->IsKind(STANDARD_TYPE(StepDimTol_GeometricTolerance))){
3830 setGeomTolObjectToXCAF(anEnt, aGDTL,theDoc,theWS);
3833 setDimObjectToXCAF(anEnt, aGDTL,theDoc,theWS);
3837 else if (anEnt->IsKind(STANDARD_TYPE(StepVisual_DraughtingCallout)) ||
3838 anEnt->IsKind(STANDARD_TYPE(StepVisual_AnnotationOccurrence)))
3840 // Protection against import presentation twice
3841 Handle(StepVisual_DraughtingCallout) aDC;
3842 for (Interface_EntityIterator anIter = aGraph.Sharings(anEnt); anIter.More() && aDC.IsNull(); anIter.Next()) {
3843 aDC = Handle(StepVisual_DraughtingCallout)::DownCast(anIter.Value());
3847 // Read presentations for PMIs without semantic data.
3848 Handle(StepAP242_DraughtingModelItemAssociation) aDMIA;
3849 TDF_LabelSequence aShapesL;
3850 for (Interface_EntityIterator anIter = aGraph.Sharings(anEnt); anIter.More() && aDMIA.IsNull(); anIter.Next()) {
3851 aDMIA = Handle(StepAP242_DraughtingModelItemAssociation)::DownCast(anIter.Value());
3853 if (!aDMIA.IsNull()) {
3854 // Check entity, skip all, attached to GDTs
3855 Handle(StepRepr_ShapeAspect) aDefinition = aDMIA->Definition().ShapeAspect();
3856 if (!aDefinition.IsNull()) {
3857 Standard_Boolean isConnectedToGDT = Standard_False;
3858 // Skip if definition is a datum
3859 if (aDefinition->IsKind(STANDARD_TYPE(StepDimTol_Datum)) ||
3860 aDefinition->IsKind(STANDARD_TYPE(StepDimTol_DatumTarget)) ||
3861 aDefinition->IsKind(STANDARD_TYPE(StepDimTol_DatumFeature)) ||
3862 aDefinition->IsKind(STANDARD_TYPE(StepRepr_CompShAspAndDatumFeatAndShAsp))) {
3863 isConnectedToGDT = Standard_True;
3865 // Skip if any GDT is applied to definition
3866 for (Interface_EntityIterator anIter = aGraph.Sharings(aDefinition); anIter.More() && !isConnectedToGDT; anIter.Next()) {
3867 if (anIter.Value()->IsKind(STANDARD_TYPE(StepShape_DimensionalSize)) ||
3868 anIter.Value()->IsKind(STANDARD_TYPE(StepShape_DimensionalLocation)) ||
3869 anIter.Value()->IsKind(STANDARD_TYPE(StepDimTol_GeometricTolerance))) {
3870 isConnectedToGDT = Standard_True;
3873 Handle(StepRepr_ShapeAspectRelationship) aSAR = Handle(StepRepr_ShapeAspectRelationship)::DownCast(anIter.Value());
3874 if (!aSAR.IsNull()) {
3875 Handle(StepRepr_ShapeAspect) aSA = aSAR->RelatedShapeAspect();
3876 if (!aSA.IsNull()) {
3877 if (aSA->IsKind(STANDARD_TYPE(StepDimTol_Datum)) ||
3878 aSA->IsKind(STANDARD_TYPE(StepDimTol_DatumTarget)) ||
3879 aSA->IsKind(STANDARD_TYPE(StepDimTol_DatumFeature)) ||
3880 aSA->IsKind(STANDARD_TYPE(StepRepr_CompShAspAndDatumFeatAndShAsp))) {
3881 isConnectedToGDT = Standard_True;
3883 for (Interface_EntityIterator aDimIter = aGraph.Sharings(aSA); aDimIter.More() && !isConnectedToGDT; aDimIter.Next()) {
3884 if (aDimIter.Value()->IsKind(STANDARD_TYPE(StepShape_DimensionalSize)) ||
3885 aDimIter.Value()->IsKind(STANDARD_TYPE(StepShape_DimensionalLocation)) ||
3886 aDimIter.Value()->IsKind(STANDARD_TYPE(StepDimTol_GeometricTolerance))) {
3887 isConnectedToGDT = Standard_True;
3894 if (isConnectedToGDT)
3897 else if (aDMIA->Definition().PropertyDefinition().IsNull())
3901 NCollection_Sequence<Handle(StepRepr_ShapeAspect)> aSAs;
3902 collectShapeAspect(aDefinition, theWS, aSAs);
3903 for (Standard_Integer aSAIt = 1; aSAIt <= aSAs.Length(); aSAIt++) {
3904 Handle(StepAP242_GeometricItemSpecificUsage) aGISU;
3905 for (Interface_EntityIterator anIter = aGraph.Sharings(aSAs.Value(aSAIt)); anIter.More() && aGISU.IsNull(); anIter.Next())
3906 aGISU = Handle(StepAP242_GeometricItemSpecificUsage)::DownCast(anIter.Value());
3909 for (Standard_Integer anItemIt = 1; anItemIt <= aGISU->NbIdentifiedItem(); anItemIt++) {
3910 TDF_Label aLabel = getShapeLabel(aGISU->IdentifiedItemValue(anItemIt), theWS, XCAFDoc_DocumentTool::ShapeTool(theDoc->Main()));
3911 if (!aLabel.IsNull())
3912 aShapesL.Append(aLabel);
3916 Standard_Boolean isCommonLabel = (aShapesL.Length() == 0);
3919 Standard_Real aFact = 1.0;
3920 if (!aDMIA.IsNull() && !aDMIA->UsedRepresentation().IsNull())
3921 GetLengthConversionFactorFromContext(aDMIA->UsedRepresentation()->ContextOfItems(), aFact);
3924 TopoDS_Shape aPresentation;
3925 Handle(TCollection_HAsciiString) aPresentName;
3927 if (!readPMIPresentation(anEnt, aTR, aFact, aPresentation, aPresentName, aBox))
3930 Handle(StepVisual_AnnotationPlane) anAnPlane;
3931 for (Interface_EntityIterator anIter = aGraph.Sharings(anEnt); anIter.More() && anAnPlane.IsNull(); anIter.Next())
3932 anAnPlane = Handle(StepVisual_AnnotationPlane)::DownCast(anIter.Value());
3934 // Set object to XCAF
3935 TDF_Label aGDTL = aDGTTool->AddDimension();
3936 myGDTMap.Bind(anEnt, aGDTL);
3937 aDGTTool->Lock(aGDTL);
3938 Handle(XCAFDimTolObjects_DimensionObject) aDimObj = new XCAFDimTolObjects_DimensionObject();
3939 Handle(XCAFDoc_Dimension) aDim = XCAFDoc_Dimension::Set(aGDTL);
3940 TCollection_AsciiString aStr("DGT:");
3941 if (isCommonLabel) {
3942 aStr.AssignCat("Common_label");
3943 aDimObj->SetType(XCAFDimTolObjects_DimensionType_CommonLabel);
3946 aStr.AssignCat("Dimension");
3947 aDimObj->SetType(XCAFDimTolObjects_DimensionType_DimensionPresentation);
3949 TDataStd_Name::Set(aGDTL, aStr);
3950 TDF_LabelSequence anEmptySeq2;
3951 aDGTTool->SetDimension(aShapesL, anEmptySeq2, aGDTL);
3953 if (!anAnPlane.IsNull()) {
3954 if (readAnnotationPlane(anAnPlane, aFact, aPlaneAxes))
3955 aDimObj->SetPlane(aPlaneAxes);
3957 aDimObj->SetPresentation(aPresentation, aPresentName);
3958 aDim->SetObject(aDimObj);
3961 return Standard_True;
3965 //=======================================================================
3966 //function : FindSolidForPDS
3967 //purpose : auxilary
3968 //=======================================================================
3970 static Handle(StepShape_SolidModel) FindSolidForPDS(const Handle(StepRepr_ProductDefinitionShape) &PDS,
3971 const Interface_Graph &graph)
3973 Handle(StepShape_SolidModel) SM;
3974 Interface_EntityIterator subs = graph.Sharings(PDS);
3975 Handle(StepShape_ShapeRepresentation) SR;
3976 for(subs.Start(); subs.More() && SM.IsNull(); subs.Next()) {
3977 Handle(StepShape_ShapeDefinitionRepresentation) SDR =
3978 Handle(StepShape_ShapeDefinitionRepresentation)::DownCast(subs.Value());
3979 if(SDR.IsNull()) continue;
3980 SR = Handle(StepShape_ShapeRepresentation)::DownCast(SDR->UsedRepresentation());
3981 if(SR.IsNull()) continue;
3982 for(Standard_Integer i=1; i<=SR->NbItems() && SM.IsNull(); i++) {
3983 SM = Handle(StepShape_SolidModel)::DownCast(SR->ItemsValue(i));
3986 Interface_EntityIterator subs1 = graph.Sharings(SR);
3987 for(subs1.Start(); subs1.More() && SM.IsNull(); subs1.Next()) {
3988 Handle(StepRepr_RepresentationRelationship) RR =
3989 Handle(StepRepr_RepresentationRelationship)::DownCast(subs1.Value());
3990 if(RR.IsNull()) continue;
3991 Handle(StepShape_ShapeRepresentation) SR2;
3992 if(RR->Rep1()==SR) SR2 = Handle(StepShape_ShapeRepresentation)::DownCast(RR->Rep2());
3993 else SR2 = Handle(StepShape_ShapeRepresentation)::DownCast(RR->Rep1());
3994 if(SR2.IsNull()) continue;
3995 for(Standard_Integer i2=1; i2<=SR2->NbItems() && SM.IsNull(); i2++) {
3996 SM = Handle(StepShape_SolidModel)::DownCast(SR2->ItemsValue(i2));
4005 //=======================================================================
4006 //function : ReadMaterials
4008 //=======================================================================
4010 Standard_Boolean STEPCAFControl_Reader::ReadMaterials(const Handle(XSControl_WorkSession) &WS,
4011 Handle(TDocStd_Document)& Doc,
4012 const Handle(TColStd_HSequenceOfTransient) &SeqPDS) const
4014 const Handle(XSControl_TransferReader) &TR = WS->TransferReader();
4015 const Handle(Transfer_TransientProcess) &TP = TR->TransientProcess();
4016 Handle(XCAFDoc_ShapeTool) STool = XCAFDoc_DocumentTool::ShapeTool( Doc->Main() );
4017 Handle(XCAFDoc_MaterialTool) MatTool = XCAFDoc_DocumentTool::MaterialTool( Doc->Main() );
4018 if(MatTool.IsNull()) return Standard_False;
4020 const Interface_Graph& graph = TP->Graph();
4021 for(Standard_Integer i=1; i<=SeqPDS->Length(); i++) {
4022 Handle(StepRepr_ProductDefinitionShape) PDS =
4023 Handle(StepRepr_ProductDefinitionShape)::DownCast(SeqPDS->Value(i));
4026 Handle(StepBasic_ProductDefinition) aProdDef = PDS->Definition().ProductDefinition();
4027 if(aProdDef.IsNull())
4029 Handle(TCollection_HAsciiString) aName = new TCollection_HAsciiString("");
4030 Handle(TCollection_HAsciiString) aDescription = new TCollection_HAsciiString("");
4031 Handle(TCollection_HAsciiString) aDensName = new TCollection_HAsciiString("");
4032 Handle(TCollection_HAsciiString) aDensValType = new TCollection_HAsciiString("");
4033 Standard_Real aDensity=0;
4034 Interface_EntityIterator subs = graph.Sharings( aProdDef);
4035 for(subs.Start(); subs.More(); subs.Next()) {
4036 Handle(StepRepr_PropertyDefinition) PropD =
4037 Handle(StepRepr_PropertyDefinition)::DownCast(subs.Value());
4038 if(PropD.IsNull()) continue;
4039 Interface_EntityIterator subs1 = graph.Sharings(PropD);
4040 for(subs1.Start(); subs1.More(); subs1.Next()) {
4041 Handle(StepRepr_PropertyDefinitionRepresentation) PDR =
4042 Handle(StepRepr_PropertyDefinitionRepresentation)::DownCast(subs1.Value());
4043 if(PDR.IsNull()) continue;
4044 Handle(StepRepr_Representation) Repr = PDR->UsedRepresentation();
4045 if(Repr.IsNull()) continue;
4046 Standard_Integer ir;
4047 for(ir=1; ir<=Repr->NbItems(); ir++) {
4048 Handle(StepRepr_RepresentationItem) RI = Repr->ItemsValue(ir);
4049 if(RI.IsNull()) continue;
4050 if(RI->IsKind(STANDARD_TYPE(StepRepr_DescriptiveRepresentationItem))) {
4051 // find name and description for material
4052 Handle(StepRepr_DescriptiveRepresentationItem) DRI =
4053 Handle(StepRepr_DescriptiveRepresentationItem)::DownCast(RI);
4054 aName = DRI->Name();
4056 aDescription = DRI->Description();
4058 aName = aDescription;
4060 if(RI->IsKind(STANDARD_TYPE(StepRepr_MeasureRepresentationItem))) {
4061 // try to find density for material
4062 Handle(StepRepr_MeasureRepresentationItem) MRI =
4063 Handle(StepRepr_MeasureRepresentationItem)::DownCast(RI);
4064 aDensity = MRI->Measure()->ValueComponent();
4065 aDensName = MRI->Name();
4066 aDensValType = new TCollection_HAsciiString(MRI->Measure()->ValueComponentMember()->Name());
4067 StepBasic_Unit aUnit = MRI->Measure()->UnitComponent();
4068 if(!aUnit.IsNull()) {
4069 Handle(StepBasic_DerivedUnit) DU = aUnit.DerivedUnit();
4070 if(DU.IsNull()) continue;
4071 for(Standard_Integer idu=1; idu<=DU->NbElements(); idu++) {
4072 Handle(StepBasic_DerivedUnitElement) DUE = DU->ElementsValue(idu);
4073 Handle(StepBasic_NamedUnit) NU = DUE->Unit();
4074 Standard_Real afact=1.;
4075 if(NU->IsKind(STANDARD_TYPE(StepBasic_ConversionBasedUnitAndLengthUnit))) {
4076 if(GetLengthConversionFactor(NU,afact)) aDensity = aDensity/(afact*afact*afact);
4077 // transfer length value for Density from millimeter to santimeter
4078 // in order to result density has dimension gram/(sm*sm*sm)
4079 aDensity = aDensity*1000.;
4081 if(NU->IsKind(STANDARD_TYPE(StepBasic_ConversionBasedUnitAndMassUnit))) {
4082 if(GetMassConversionFactor(NU,afact)) aDensity=aDensity*afact;
4091 if( aName.IsNull() || aName->Length()==0 )
4093 // find shape label amd create Material link
4095 Handle(StepShape_SolidModel) SM = FindSolidForPDS(PDS,graph);
4097 Standard_Integer index = TP->MapIndex(SM);
4099 Handle(Transfer_Binder) binder = TP->MapItem(index);
4100 if(!binder.IsNull())
4101 aSh = TransferBRep::ShapeResult(binder);
4104 if(aSh.IsNull()) continue;
4106 if( !STool->Search(aSh, shL, Standard_True, Standard_True, Standard_True) ) continue;
4107 MatTool->SetMaterial(shL,aName,aDescription,aDensity,aDensName,aDensValType);
4110 return Standard_True;
4113 //=======================================================================
4114 //function : collectViewShapes
4115 //purpose : collect all labels of representations in given representation
4116 //=======================================================================
4118 void collectViewShapes(const Handle(XSControl_WorkSession)& theWS,
4119 const Handle(TDocStd_Document)& theDoc,
4120 const Handle(StepRepr_Representation) theRepr,
4121 TDF_LabelSequence& theShapes)
4123 Handle(XSControl_TransferReader) aTR = theWS->TransferReader();
4124 Handle(Transfer_TransientProcess) aTP = aTR->TransientProcess();
4125 const Interface_Graph& aGraph = aTP->Graph();
4126 Handle(XCAFDoc_ShapeTool) aSTool = XCAFDoc_DocumentTool::ShapeTool(theDoc->Main());
4127 Standard_Integer anIndex = aTP->MapIndex(theRepr);
4130 Handle(Transfer_Binder) aBinder = aTP->MapItem(anIndex);
4131 aSh = TransferBRep::ShapeResult(aBinder);
4133 if (!aSh.IsNull()) {
4135 aSTool->FindShape(aSh, aShL);
4137 theShapes.Append(aShL);
4139 Interface_EntityIterator anIter = aGraph.Sharings(theRepr);
4140 for (; anIter.More(); anIter.Next()) {
4141 if (!anIter.Value()->IsKind(STANDARD_TYPE(StepRepr_RepresentationRelationship)))
4143 Handle(StepRepr_RepresentationRelationship) aReprRelationship = Handle(StepRepr_RepresentationRelationship)::DownCast(anIter.Value());
4144 if (aReprRelationship->Rep1() != theRepr)
4145 collectViewShapes(theWS, theDoc, aReprRelationship->Rep1(), theShapes);
4149 //=======================================================================
4150 //function : buildClippingPlanes
4152 //=======================================================================
4153 Handle(TCollection_HAsciiString) buildClippingPlanes(const Handle(StepGeom_GeometricRepresentationItem)& theClippingCameraModel,
4154 TDF_LabelSequence& theClippingPlanes,
4155 const Handle(XCAFDoc_ClippingPlaneTool) theTool)
4157 Handle(TCollection_HAsciiString) anExpression = new TCollection_HAsciiString();
4158 NCollection_Sequence<Handle(StepGeom_GeometricRepresentationItem)> aPlanes;
4159 Handle(TCollection_HAsciiString) anOperation = new TCollection_HAsciiString("*");
4162 if (theClippingCameraModel->IsKind(STANDARD_TYPE(StepVisual_CameraModelD3MultiClipping))) {
4163 Handle(StepVisual_CameraModelD3MultiClipping) aCameraModel =
4164 Handle(StepVisual_CameraModelD3MultiClipping)::DownCast(theClippingCameraModel);
4165 // Root of clipping planes tree
4166 if (aCameraModel->ShapeClipping()->Length() == 1) {
4167 Handle(StepVisual_CameraModelD3MultiClippingUnion) aCameraModelUnion =
4168 aCameraModel->ShapeClipping()->Value(1).CameraModelD3MultiClippingUnion();
4169 if (!aCameraModelUnion.IsNull())
4170 return buildClippingPlanes(aCameraModelUnion, theClippingPlanes, theTool);
4172 for (Standard_Integer i = 1; i <= aCameraModel->ShapeClipping()->Length(); i++) {
4173 aPlanes.Append(Handle(StepGeom_GeometricRepresentationItem)::DownCast(aCameraModel->ShapeClipping()->Value(i).Value()));
4176 else if (theClippingCameraModel->IsKind(STANDARD_TYPE(StepVisual_CameraModelD3MultiClippingUnion))) {
4177 Handle(StepVisual_CameraModelD3MultiClippingUnion) aCameraModel =
4178 Handle(StepVisual_CameraModelD3MultiClippingUnion)::DownCast(theClippingCameraModel);
4179 anOperation = new TCollection_HAsciiString("+");
4180 for (Standard_Integer i = 1; i <= aCameraModel->ShapeClipping()->Length(); i++) {
4181 aPlanes.Append(Handle(StepGeom_GeometricRepresentationItem)::DownCast(aCameraModel->ShapeClipping()->Value(i).Value()));
4184 else if (theClippingCameraModel->IsKind(STANDARD_TYPE(StepVisual_CameraModelD3MultiClippingIntersection))) {
4185 Handle(StepVisual_CameraModelD3MultiClippingIntersection) aCameraModel =
4186 Handle(StepVisual_CameraModelD3MultiClippingIntersection)::DownCast(theClippingCameraModel);
4187 for (Standard_Integer i = 1; i <= aCameraModel->ShapeClipping()->Length(); i++) {
4188 aPlanes.Append(Handle(StepGeom_GeometricRepresentationItem)::DownCast(aCameraModel->ShapeClipping()->Value(i).Value()));
4192 anExpression->AssignCat("(");
4193 for (Standard_Integer i = 1; i <= aPlanes.Length(); i++) {
4194 Handle(StepGeom_Plane) aPlaneEnt = Handle(StepGeom_Plane)::DownCast(aPlanes.Value(i));
4195 if (!aPlaneEnt.IsNull()) {
4196 Handle(Geom_Plane) aPlane = StepToGeom::MakePlane(aPlaneEnt);
4197 if (!aPlane.IsNull()) {
4198 TDF_Label aPlaneL = theTool->AddClippingPlane(aPlane->Pln(), aPlaneEnt->Name());
4199 theClippingPlanes.Append(aPlaneL);
4200 TCollection_AsciiString anEntry;
4201 TDF_Tool::Entry(aPlaneL, anEntry);
4202 anExpression->AssignCat(new TCollection_HAsciiString(anEntry));
4206 anExpression->AssignCat(buildClippingPlanes(aPlanes.Value(i), theClippingPlanes, theTool));
4208 anExpression->AssignCat(anOperation);
4210 // Insert brace instead of operation after last operand.
4211 anExpression->SetValue(anExpression->Length(), ')');
4212 return anExpression;
4216 //=======================================================================
4217 //function : ReadViews
4219 //=======================================================================
4220 Standard_Boolean STEPCAFControl_Reader::ReadViews(const Handle(XSControl_WorkSession)& theWS, Handle(TDocStd_Document)& theDoc) const
4222 const Handle(Interface_InterfaceModel) &aModel = theWS->Model();
4223 Handle(XCAFDoc_ShapeTool) aSTool = XCAFDoc_DocumentTool::ShapeTool(theDoc->Main());
4224 Handle(XCAFDoc_DimTolTool) aDGTTool = XCAFDoc_DocumentTool::DimTolTool(theDoc->Main());
4225 Handle(XCAFDoc_ViewTool) aViewTool = XCAFDoc_DocumentTool::ViewTool(theDoc->Main());
4226 if (aDGTTool.IsNull()) return Standard_False;
4228 Standard_Integer nb = aModel->NbEntities();
4229 for (Standard_Integer i = 1; i <= nb; i++) {
4230 Handle(Standard_Transient) anEnt = aModel->Value(i);
4231 if (!anEnt->IsKind(STANDARD_TYPE(StepVisual_CameraModelD3)))
4233 Handle(XCAFView_Object) anObj = new XCAFView_Object();
4234 // Import attributes of view
4235 Handle(StepVisual_CameraModelD3) aCameraModel = Handle(StepVisual_CameraModelD3)::DownCast(anEnt);
4236 anObj->SetName(aCameraModel->Name());
4237 Handle(Geom_Axis2Placement) anAxis = StepToGeom::MakeAxis2Placement(aCameraModel->ViewReferenceSystem());
4238 anObj->SetViewDirection(anAxis->Direction());
4239 anObj->SetUpDirection(anAxis->Direction() ^ anAxis->XDirection());
4240 Handle(StepVisual_ViewVolume) aViewVolume = aCameraModel->PerspectiveOfVolume();
4241 XCAFView_ProjectionType aType = XCAFView_ProjectionType_NoCamera;
4242 if (aViewVolume->ProjectionType() == StepVisual_copCentral)
4243 aType = XCAFView_ProjectionType_Central;
4244 else if (aViewVolume->ProjectionType() == StepVisual_copParallel)
4245 aType = XCAFView_ProjectionType_Parallel;
4246 anObj->SetType(aType);
4247 Handle(Geom_CartesianPoint) aPoint = StepToGeom::MakeCartesianPoint(aViewVolume->ProjectionPoint());
4248 anObj->SetProjectionPoint(aPoint->Pnt());
4249 anObj->SetZoomFactor(aViewVolume->ViewPlaneDistance());
4250 anObj->SetWindowHorizontalSize(aViewVolume->ViewWindow()->SizeInX());
4251 anObj->SetWindowVerticalSize(aViewVolume->ViewWindow()->SizeInY());
4252 if (aViewVolume->FrontPlaneClipping())
4253 anObj->SetFrontPlaneDistance(aViewVolume->FrontPlaneDistance());
4254 if (aViewVolume->BackPlaneClipping())
4255 anObj->SetBackPlaneDistance(aViewVolume->BackPlaneDistance());
4256 anObj->SetViewVolumeSidesClipping(aViewVolume->ViewVolumeSidesClipping());
4258 Handle(StepVisual_CameraModelD3MultiClipping) aClippingCameraModel =
4259 Handle(StepVisual_CameraModelD3MultiClipping)::DownCast(aCameraModel);
4260 TDF_LabelSequence aClippingPlanes;
4261 if (!aClippingCameraModel.IsNull()) {
4262 Handle(TCollection_HAsciiString) aClippingExpression;
4263 Handle(XCAFDoc_ClippingPlaneTool) aClippingPlaneTool = XCAFDoc_DocumentTool::ClippingPlaneTool(theDoc->Main());
4264 aClippingExpression = buildClippingPlanes(aClippingCameraModel, aClippingPlanes, aClippingPlaneTool);
4265 anObj->SetClippingExpression(aClippingExpression);
4267 // Collect shapes and GDTs
4268 TDF_LabelSequence aShapes, aGDTs;
4269 Handle(XSControl_TransferReader) aTR = theWS->TransferReader();
4270 Handle(Transfer_TransientProcess) aTP = aTR->TransientProcess();
4271 const Interface_Graph& aGraph = aTP->Graph();
4272 Handle(StepVisual_DraughtingModel) aDModel;
4273 Interface_EntityIterator anIter = aGraph.Sharings(aCameraModel);
4274 for (; anIter.More() && aDModel.IsNull(); anIter.Next()) {
4275 aDModel = Handle(StepVisual_DraughtingModel)::DownCast(anIter.Value());
4277 if (aDModel.IsNull())
4278 return Standard_False;
4280 anIter = aGraph.Shareds(aDModel);
4281 for (; anIter.More(); anIter.Next()) {
4282 if (anIter.Value()->IsKind(STANDARD_TYPE(StepRepr_MappedItem))) {
4283 Handle(StepRepr_MappedItem) anItem = Handle(StepRepr_MappedItem)::DownCast(anIter.Value());
4284 Handle(StepRepr_Representation) aRepr = anItem->MappingSource()->MappedRepresentation();
4285 collectViewShapes(theWS, theDoc, aRepr, aShapes);
4287 else if (anIter.Value()->IsKind(STANDARD_TYPE(StepVisual_AnnotationOccurrence)) ||
4288 anIter.Value()->IsKind(STANDARD_TYPE(StepVisual_DraughtingCallout))) {
4289 Interface_EntityIterator aDMIAIter = aGraph.Sharings(anIter.Value());
4290 for (; aDMIAIter.More(); aDMIAIter.Next()) {
4291 if (!aDMIAIter.Value()->IsKind(STANDARD_TYPE(StepAP242_DraughtingModelItemAssociation)))
4293 Handle(StepAP242_DraughtingModelItemAssociation) aDMIA =
4294 Handle(StepAP242_DraughtingModelItemAssociation)::DownCast(aDMIAIter.Value());
4296 Standard_Boolean isFind = myGDTMap.Find(aDMIA->Definition().Value(), aGDTL);
4298 isFind = myGDTMap.Find(anIter.Value(), aGDTL);
4301 aGDTs.Append(aGDTL);
4304 else if (anIter.Value()->IsKind(STANDARD_TYPE(StepVisual_AnnotationPlane))) {
4305 Handle(StepVisual_AnnotationPlane) aPlane = Handle(StepVisual_AnnotationPlane)::DownCast(anIter.Value());
4306 for (Standard_Integer j = 1; j <= aPlane->NbElements(); j++) {
4307 Interface_EntityIterator aDMIAIter = aGraph.Sharings(anIter.Value());
4308 for (; aDMIAIter.More(); aDMIAIter.Next()) {
4309 if (!aDMIAIter.Value()->IsKind(STANDARD_TYPE(StepAP242_DraughtingModelItemAssociation)))
4311 Handle(StepAP242_DraughtingModelItemAssociation) aDMIA =
4312 Handle(StepAP242_DraughtingModelItemAssociation)::DownCast(aDMIAIter.Value());
4314 Standard_Boolean isFind = myGDTMap.Find(aDMIA->Definition().Value(), aGDTL);
4316 aGDTs.Append(aGDTL);
4321 TDF_Label aViewL = aViewTool->AddView();
4322 Handle(XCAFDoc_View) aView = XCAFDoc_View::Set(aViewL);
4323 aView->SetObject(anObj);
4324 aViewTool->SetView(aShapes, aGDTs, aClippingPlanes, aViewL);
4325 aViewTool->Lock(aViewL);
4327 return Standard_True;
4330 //=======================================================================
4331 //function : SettleShapeData
4333 //=======================================================================
4335 TDF_Label STEPCAFControl_Reader::SettleShapeData(const Handle(StepRepr_RepresentationItem)& theItem,
4337 const Handle(XCAFDoc_ShapeTool)& theShapeTool,
4338 const Handle(Transfer_TransientProcess)& TP) const
4340 TDF_Label aResult = theLab;
4342 Handle(TCollection_HAsciiString) hName = theItem->Name();
4343 if ( hName.IsNull() || hName->IsEmpty() )
4346 Handle(Transfer_Binder) aBinder = TP->Find(theItem);
4347 if ( aBinder.IsNull() )
4350 TopoDS_Shape aShape = TransferBRep::ShapeResult(aBinder);
4351 if ( aShape.IsNull() )
4354 // Allocate sub-Label
4355 aResult = AllocateSubLabel(theLab);
4357 TCollection_AsciiString aName = hName->String();
4358 TDataStd_Name::Set(aResult, aName);
4359 theShapeTool->SetShape(aResult, aShape);
4364 //=======================================================================
4365 //function : ExpandSubShapes
4367 //=======================================================================
4369 void STEPCAFControl_Reader::ExpandSubShapes(const Handle(XCAFDoc_ShapeTool)& ShapeTool,
4370 const XCAFDoc_DataMapOfShapeLabel& ShapeLabelMap,
4371 const STEPCAFControl_DataMapOfShapePD& ShapePDMap) const
4373 const Handle(Transfer_TransientProcess)& TP = Reader().WS()->TransferReader()->TransientProcess();
4374 NCollection_DataMap<TopoDS_Shape, Handle(TCollection_HAsciiString)> ShapeNameMap;
4375 TColStd_MapOfTransient aRepItems;
4377 // Read translation control variables
4378 Standard_Boolean doReadSNames = (Interface_Static::IVal("read.stepcaf.subshapes.name") > 0);
4380 if ( !doReadSNames )
4383 const Interface_Graph& Graph = Reader().WS()->Graph();
4385 for ( STEPCAFControl_DataMapIteratorOfDataMapOfShapePD it(ShapePDMap); it.More(); it.Next() )
4387 const TopoDS_Shape& aRootShape = it.Key();
4388 const Handle(StepBasic_ProductDefinition)& aPDef = it.Value();
4389 if ( aPDef.IsNull() )
4392 // Find SDR by Product
4393 Handle(StepShape_ShapeDefinitionRepresentation) aSDR;
4394 Interface_EntityIterator entIt = Graph.TypedSharings( aPDef, STANDARD_TYPE(StepShape_ShapeDefinitionRepresentation) );
4395 for ( entIt.Start(); entIt.More(); entIt.Next() )
4397 const Handle(Standard_Transient)& aReferer = entIt.Value();
4398 aSDR = Handle(StepShape_ShapeDefinitionRepresentation)::DownCast(aReferer);
4399 if ( !aSDR.IsNull() )
4403 if ( aSDR.IsNull() )
4406 // Access shape representation
4407 Handle(StepShape_ShapeRepresentation)
4408 aShapeRepr = Handle(StepShape_ShapeRepresentation)::DownCast( aSDR->UsedRepresentation() );
4410 if ( aShapeRepr.IsNull() )
4413 // Access representation items
4414 Handle(StepRepr_HArray1OfRepresentationItem) aReprItems = aShapeRepr->Items();
4416 if ( aReprItems.IsNull() )
4419 if ( !ShapeLabelMap.IsBound(aRootShape) )
4422 TDF_Label aRootLab = ShapeLabelMap.Find(aRootShape);
4424 StepRepr_SequenceOfRepresentationItem aMSBSeq;
4425 StepRepr_SequenceOfRepresentationItem aSBSMSeq;
4427 // Iterate over the top level representation items collecting the
4428 // topological containers to expand
4429 for ( Standard_Integer i = aReprItems->Lower(); i <= aReprItems->Upper(); ++i )
4431 Handle(StepRepr_RepresentationItem) aTRepr = aReprItems->Value(i);
4432 if ( aTRepr->IsKind( STANDARD_TYPE(StepShape_ManifoldSolidBrep) ) )
4433 aMSBSeq.Append(aTRepr);
4434 else if ( aTRepr->IsKind( STANDARD_TYPE(StepShape_ShellBasedSurfaceModel) ) )
4435 aSBSMSeq.Append(aTRepr);
4438 // Insert intermediate OCAF Labels for SOLIDs in case there are more
4439 // than one Manifold Solid BRep in the Shape Representation
4440 Standard_Boolean doInsertSolidLab = (aMSBSeq.Length() > 1);
4442 // Expand Manifold Solid BReps
4443 for ( Standard_Integer i = 1; i <= aMSBSeq.Length(); ++i )
4445 const Handle(StepRepr_RepresentationItem)& aManiRepr = aMSBSeq.Value(i);
4447 // Put additional Label for SOLID
4449 if ( doInsertSolidLab )
4450 aManiLab = SettleShapeData(aManiRepr, aRootLab, ShapeTool, TP);
4452 aManiLab = aRootLab;
4454 ExpandManifoldSolidBrep(aManiLab, aMSBSeq.Value(i), TP, ShapeTool);
4457 // Expand Shell-Based Surface Models
4458 for ( Standard_Integer i = 1; i <= aSBSMSeq.Length(); ++i )
4459 ExpandSBSM(aRootLab, aSBSMSeq.Value(i), TP, ShapeTool);
4463 //=======================================================================
4464 //function : ExpandManifoldSolidBrep
4466 //=======================================================================
4468 void STEPCAFControl_Reader::ExpandManifoldSolidBrep(TDF_Label& ShapeLab,
4469 const Handle(StepRepr_RepresentationItem)& Repr,
4470 const Handle(Transfer_TransientProcess)& TP,
4471 const Handle(XCAFDoc_ShapeTool)& ShapeTool) const
4473 // Access outer shell
4474 Handle(StepShape_ManifoldSolidBrep) aMSB = Handle(StepShape_ManifoldSolidBrep)::DownCast(Repr);
4475 Handle(StepShape_ConnectedFaceSet) aShell = aMSB->Outer();
4477 // Expand shell contents to CAF tree
4478 ExpandShell(aShell, ShapeLab, TP, ShapeTool);
4481 //=======================================================================
4482 //function : ExpandSBSM
4484 //=======================================================================
4486 void STEPCAFControl_Reader::ExpandSBSM(TDF_Label& ShapeLab,
4487 const Handle(StepRepr_RepresentationItem)& Repr,
4488 const Handle(Transfer_TransientProcess)& TP,
4489 const Handle(XCAFDoc_ShapeTool)& ShapeTool) const
4491 Handle(StepShape_ShellBasedSurfaceModel) aSBSM = Handle(StepShape_ShellBasedSurfaceModel)::DownCast(Repr);
4493 // Access boundary shells
4494 Handle(StepShape_HArray1OfShell) aShells = aSBSM->SbsmBoundary();
4495 for ( Standard_Integer s = aShells->Lower(); s <= aShells->Upper(); ++s )
4497 const StepShape_Shell& aShell = aShells->Value(s);
4498 Handle(StepShape_ConnectedFaceSet) aCFS;
4499 Handle(StepShape_OpenShell) anOpenShell = aShell.OpenShell();
4500 Handle(StepShape_ClosedShell) aClosedShell = aShell.ClosedShell();
4502 if ( !anOpenShell.IsNull() )
4505 aCFS = aClosedShell;
4507 ExpandShell(aCFS, ShapeLab, TP, ShapeTool);
4511 //=======================================================================
4512 //function : ExpandShell
4514 //=======================================================================
4516 void STEPCAFControl_Reader::ExpandShell(const Handle(StepShape_ConnectedFaceSet)& Shell,
4518 const Handle(Transfer_TransientProcess)& TP,
4519 const Handle(XCAFDoc_ShapeTool)& ShapeTool) const
4522 TDF_Label aShellLab = SettleShapeData(Shell, RootLab, ShapeTool, TP);
4525 Handle(StepShape_HArray1OfFace) aFaces = Shell->CfsFaces();
4526 for ( Standard_Integer f = aFaces->Lower(); f <= aFaces->Upper(); ++f )
4528 const Handle(StepShape_Face)& aFace = aFaces->Value(f);
4531 TDF_Label aFaceLab = SettleShapeData(aFace, aShellLab, ShapeTool, TP);
4533 // Access face bounds
4534 Handle(StepShape_HArray1OfFaceBound) aWires = aFace->Bounds();
4535 for ( Standard_Integer w = aWires->Lower(); w <= aWires->Upper(); ++w )
4537 const Handle(StepShape_Loop)& aWire = aWires->Value(w)->Bound();
4540 TDF_Label aWireLab = SettleShapeData(aWire, aFaceLab, ShapeTool, TP);
4542 // Access wire edges
4543 // Currently only EDGE LOOPs are considered (!)
4544 if ( !aWire->IsInstance( STANDARD_TYPE(StepShape_EdgeLoop) ) )
4548 Handle(StepShape_EdgeLoop) anEdgeLoop = Handle(StepShape_EdgeLoop)::DownCast(aWire);
4549 Handle(StepShape_HArray1OfOrientedEdge) anEdges = anEdgeLoop->EdgeList();
4550 for ( Standard_Integer e = anEdges->Lower(); e <= anEdges->Upper(); ++e )
4552 Handle(StepShape_Edge) anEdge = anEdges->Value(e)->EdgeElement();
4555 TDF_Label anEdgeLab = SettleShapeData(anEdge, aWireLab, ShapeTool, TP);
4558 Handle(StepShape_Vertex) aV1 = anEdge->EdgeStart();
4559 Handle(StepShape_Vertex) aV2 = anEdge->EdgeEnd();
4562 SettleShapeData(aV1, anEdgeLab, ShapeTool, TP);
4563 SettleShapeData(aV2, anEdgeLab, ShapeTool, TP);
4569 //=======================================================================
4570 //function : SetColorMode
4572 //=======================================================================
4574 void STEPCAFControl_Reader::SetColorMode (const Standard_Boolean colormode)
4576 myColorMode = colormode;
4579 //=======================================================================
4580 //function : GetColorMode
4582 //=======================================================================
4584 Standard_Boolean STEPCAFControl_Reader::GetColorMode () const
4589 //=======================================================================
4590 //function : SetNameMode
4592 //=======================================================================
4594 void STEPCAFControl_Reader::SetNameMode (const Standard_Boolean namemode)
4596 myNameMode = namemode;
4599 //=======================================================================
4600 //function : GetNameMode
4602 //=======================================================================
4604 Standard_Boolean STEPCAFControl_Reader::GetNameMode () const
4609 //=======================================================================
4610 //function : SetLayerMode
4612 //=======================================================================
4614 void STEPCAFControl_Reader::SetLayerMode (const Standard_Boolean layermode)
4616 myLayerMode = layermode;
4619 //=======================================================================
4620 //function : GetLayerMode
4622 //=======================================================================
4624 Standard_Boolean STEPCAFControl_Reader::GetLayerMode () const
4629 //=======================================================================
4630 //function : SetPropsMode
4632 //=======================================================================
4634 void STEPCAFControl_Reader::SetPropsMode (const Standard_Boolean propsmode)
4636 myPropsMode = propsmode;
4639 //=======================================================================
4640 //function : GetPropsMode
4642 //=======================================================================
4644 Standard_Boolean STEPCAFControl_Reader::GetPropsMode () const
4649 //=======================================================================
4650 //function : SetSHUOMode
4652 //=======================================================================
4654 void STEPCAFControl_Reader::SetSHUOMode (const Standard_Boolean mode)
4659 //=======================================================================
4660 //function : GetSHUOMode
4662 //=======================================================================
4664 Standard_Boolean STEPCAFControl_Reader::GetSHUOMode () const
4669 //=======================================================================
4670 //function : SetGDTMode
4672 //=======================================================================
4674 void STEPCAFControl_Reader::SetGDTMode (const Standard_Boolean gdtmode)
4676 myGDTMode = gdtmode;
4679 //=======================================================================
4680 //function : GetGDTMode
4682 //=======================================================================
4684 Standard_Boolean STEPCAFControl_Reader::GetGDTMode () const
4690 //=======================================================================
4691 //function : SetMatMode
4693 //=======================================================================
4695 void STEPCAFControl_Reader::SetMatMode (const Standard_Boolean matmode)
4697 myMatMode = matmode;
4700 //=======================================================================
4701 //function : GetMatMode
4703 //=======================================================================
4705 Standard_Boolean STEPCAFControl_Reader::GetMatMode () const
4710 //=======================================================================
4711 //function : SetViewMode
4713 //=======================================================================
4715 void STEPCAFControl_Reader::SetViewMode(const Standard_Boolean viewmode)
4717 myViewMode = viewmode;
4720 //=======================================================================
4721 //function : GetViewMode
4723 //=======================================================================
4725 Standard_Boolean STEPCAFControl_Reader::GetViewMode() const