Commit | Line | Data |
---|---|---|
b311480e | 1 | // Created on: 2000-08-15 |
2 | // Created by: Andrey BETENEV | |
973c2be1 | 3 | // Copyright (c) 2000-2014 OPEN CASCADE SAS |
7fd59977 | 4 | // |
973c2be1 | 5 | // This file is part of Open CASCADE Technology software library. |
b311480e | 6 | // |
d5f74e42 | 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 | |
973c2be1 | 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. | |
7fd59977 | 12 | // |
973c2be1 | 13 | // Alternatively, this file may be used under the terms of Open CASCADE |
14 | // commercial license or contractual agreement. | |
b311480e | 15 | |
16 | // CURRENT LIMITATIONS: | |
7fd59977 | 17 | // when val props and names assigned to instance of |
18 | // component in assembly, it is in fact supposed that only one CDSR corresponds | |
19 | // to such shape. This can be wrong and should be handled more carefully | |
20 | // (analysis of SDRs which the CDSR links should be done) | |
7fd59977 | 21 | // Names and validation props are supported for top-level shapes only |
22 | ||
7fd59977 | 23 | #include <BRep_Builder.hxx> |
1603a497 | 24 | #include <GeomToStep_MakeAxis2Placement3d.hxx> |
18f7c9a5 | 25 | #include <GeomToStep_MakeCartesianPoint.hxx> |
7fd59977 | 26 | #include <HeaderSection_FileSchema.hxx> |
42cf5bc1 | 27 | #include <Interface_EntityIterator.hxx> |
28 | #include <Interface_Static.hxx> | |
29 | #include <Message_Messenger.hxx> | |
7fd59977 | 30 | #include <MoniTool_DataMapIteratorOfDataMapOfShapeTransient.hxx> |
b0cef606 | 31 | #include <NCollection_Vector.hxx> |
42cf5bc1 | 32 | #include <OSD_Path.hxx> |
7fd59977 | 33 | #include <Quantity_TypeOfColor.hxx> |
42cf5bc1 | 34 | #include <StepAP214_Protocol.hxx> |
b0cef606 | 35 | #include <StepAP242_DraughtingModelItemAssociation.hxx> |
6595eee7 | 36 | #include <StepAP242_GeometricItemSpecificUsage.hxx> |
42cf5bc1 | 37 | #include <StepBasic_DerivedUnit.hxx> |
38 | #include <StepBasic_DerivedUnitElement.hxx> | |
39 | #include <StepBasic_HArray1OfDerivedUnitElement.hxx> | |
40 | #include <StepBasic_LengthMeasureWithUnit.hxx> | |
7fd59977 | 41 | #include <StepBasic_MeasureValueMember.hxx> |
42cf5bc1 | 42 | #include <StepBasic_Product.hxx> |
43 | #include <StepBasic_ProductDefinition.hxx> | |
44 | #include <StepBasic_ProductDefinitionFormation.hxx> | |
45 | #include <StepBasic_ProductDefinitionRelationship.hxx> | |
7fd59977 | 46 | #include <StepBasic_SiUnitAndLengthUnit.hxx> |
42cf5bc1 | 47 | #include <StepBasic_SiUnitAndMassUnit.hxx> |
6595eee7 | 48 | #include <StepBasic_SiUnitAndPlaneAngleUnit.hxx> |
42cf5bc1 | 49 | #include <STEPCAFControl_ActorWrite.hxx> |
50 | #include <STEPCAFControl_Controller.hxx> | |
42cf5bc1 | 51 | #include <STEPCAFControl_ExternFile.hxx> |
42cf5bc1 | 52 | #include <STEPCAFControl_Writer.hxx> |
53 | #include <STEPConstruct.hxx> | |
54 | #include <STEPConstruct_DataMapOfAsciiStringTransient.hxx> | |
55 | #include <STEPConstruct_DataMapOfPointTransient.hxx> | |
56 | #include <STEPConstruct_ExternRefs.hxx> | |
727b5ad9 | 57 | #include <STEPCAFControl_GDTProperty.hxx> |
42cf5bc1 | 58 | #include <STEPConstruct_Styles.hxx> |
59 | #include <STEPConstruct_ValidationProps.hxx> | |
60 | #include <STEPControl_StepModelType.hxx> | |
61 | #include <STEPControl_Writer.hxx> | |
7fd59977 | 62 | #include <StepData_Logical.hxx> |
42cf5bc1 | 63 | #include <StepData_StepModel.hxx> |
7fd59977 | 64 | #include <StepDimTol_AngularityTolerance.hxx> |
65 | #include <StepDimTol_CircularRunoutTolerance.hxx> | |
66 | #include <StepDimTol_CoaxialityTolerance.hxx> | |
67 | #include <StepDimTol_ConcentricityTolerance.hxx> | |
7fd59977 | 68 | #include <StepDimTol_CylindricityTolerance.hxx> |
42cf5bc1 | 69 | #include <StepDimTol_Datum.hxx> |
70 | #include <StepDimTol_DatumFeature.hxx> | |
71 | #include <StepDimTol_DatumReference.hxx> | |
6595eee7 | 72 | #include <StepDimTol_DatumReferenceElement.hxx> |
73 | #include <StepDimTol_DatumSystem.hxx> | |
74 | #include <StepDimTol_DatumSystemOrReference.hxx> | |
75 | #include <StepDimTol_DatumTarget.hxx> | |
7fd59977 | 76 | #include <StepDimTol_FlatnessTolerance.hxx> |
6595eee7 | 77 | #include <StepDimTol_GeometricToleranceType.hxx> |
42cf5bc1 | 78 | #include <StepDimTol_GeometricToleranceWithDatumReference.hxx> |
6595eee7 | 79 | #include <StepDimTol_GeometricToleranceWithModifiers.hxx> |
80 | #include <StepDimTol_GeoTolAndGeoTolWthDatRef.hxx> | |
81 | #include <StepDimTol_GeoTolAndGeoTolWthDatRefAndGeoTolWthMaxTol.hxx> | |
82 | #include <StepDimTol_GeoTolAndGeoTolWthDatRefAndGeoTolWthMod.hxx> | |
42cf5bc1 | 83 | #include <StepDimTol_GeoTolAndGeoTolWthDatRefAndModGeoTolAndPosTol.hxx> |
6595eee7 | 84 | #include <StepDimTol_GeoTolAndGeoTolWthMaxTol.hxx> |
85 | #include <StepDimTol_GeoTolAndGeoTolWthMod.hxx> | |
42cf5bc1 | 86 | #include <StepDimTol_HArray1OfDatumReference.hxx> |
6595eee7 | 87 | #include <StepDimTol_HArray1OfDatumReferenceElement.hxx> |
88 | #include <StepDimTol_HArray1OfDatumReferenceModifier.hxx> | |
89 | #include <StepDimTol_HArray1OfDatumSystemOrReference.hxx> | |
7fd59977 | 90 | #include <StepDimTol_LineProfileTolerance.hxx> |
42cf5bc1 | 91 | #include <StepDimTol_ModifiedGeometricTolerance.hxx> |
92 | #include <StepDimTol_ParallelismTolerance.hxx> | |
93 | #include <StepDimTol_PerpendicularityTolerance.hxx> | |
6595eee7 | 94 | #include <StepDimTol_PlacedDatumTargetFeature.hxx> |
7fd59977 | 95 | #include <StepDimTol_PositionTolerance.hxx> |
96 | #include <StepDimTol_RoundnessTolerance.hxx> | |
6595eee7 | 97 | #include <StepDimTol_RunoutZoneDefinition.hxx> |
98 | #include <StepDimTol_RunoutZoneOrientation.hxx> | |
7fd59977 | 99 | #include <StepDimTol_StraightnessTolerance.hxx> |
100 | #include <StepDimTol_SurfaceProfileTolerance.hxx> | |
42cf5bc1 | 101 | #include <StepDimTol_SymmetryTolerance.hxx> |
6595eee7 | 102 | #include <StepDimTol_ToleranceZone.hxx> |
103 | #include <StepDimTol_ToleranceZoneForm.hxx> | |
42cf5bc1 | 104 | #include <StepDimTol_TotalRunoutTolerance.hxx> |
6595eee7 | 105 | #include <StepGeom_Axis2Placement3d.hxx> |
106 | #include <StepGeom_CartesianPoint.hxx> | |
107 | #include <StepGeom_Direction.hxx> | |
42cf5bc1 | 108 | #include <StepGeom_GeometricRepresentationContextAndGlobalUnitAssignedContext.hxx> |
109 | #include <StepGeom_GeomRepContextAndGlobUnitAssCtxAndGlobUncertaintyAssCtx.hxx> | |
b0cef606 | 110 | #include <StepGeom_Plane.hxx> |
42cf5bc1 | 111 | #include <StepGeom_Surface.hxx> |
6595eee7 | 112 | #include <StepRepr_CompGroupShAspAndCompShAspAndDatumFeatAndShAsp.hxx> |
113 | #include <StepRepr_CompositeShapeAspect.hxx> | |
b7b2f85a | 114 | #include <StepRepr_ConstructiveGeometryRepresentation.hxx> |
115 | #include <StepRepr_ConstructiveGeometryRepresentationRelationship.hxx> | |
116 | #include <StepRepr_DerivedShapeAspect.hxx> | |
7fd59977 | 117 | #include <StepRepr_DescriptiveRepresentationItem.hxx> |
6595eee7 | 118 | #include <StepRepr_FeatureForDatumTargetRelationship.hxx> |
42cf5bc1 | 119 | #include <StepRepr_HArray1OfRepresentationItem.hxx> |
7fd59977 | 120 | #include <StepRepr_MeasureRepresentationItem.hxx> |
42cf5bc1 | 121 | #include <StepRepr_NextAssemblyUsageOccurrence.hxx> |
122 | #include <StepRepr_ProductDefinitionShape.hxx> | |
123 | #include <StepRepr_PropertyDefinition.hxx> | |
6595eee7 | 124 | #include <StepRepr_RepresentedDefinition.hxx> |
42cf5bc1 | 125 | #include <StepRepr_Representation.hxx> |
ec357c5c | 126 | #include <StepRepr_RepresentationItem.hxx> |
42cf5bc1 | 127 | #include <StepRepr_ReprItemAndLengthMeasureWithUnit.hxx> |
6595eee7 | 128 | #include <StepRepr_ReprItemAndLengthMeasureWithUnitAndQRI.hxx> |
129 | #include <StepRepr_ReprItemAndPlaneAngleMeasureWithUnit.hxx> | |
130 | #include <StepRepr_ReprItemAndPlaneAngleMeasureWithUnitAndQRI.hxx> | |
42cf5bc1 | 131 | #include <StepRepr_ShapeAspect.hxx> |
b7b2f85a | 132 | #include <StepRepr_ShapeAspectDerivingRelationship.hxx> |
42cf5bc1 | 133 | #include <StepRepr_ShapeAspectRelationship.hxx> |
134 | #include <StepRepr_SpecifiedHigherUsageOccurrence.hxx> | |
135 | #include <StepRepr_ValueRange.hxx> | |
136 | #include <StepShape_AdvancedFace.hxx> | |
6595eee7 | 137 | #include <StepShape_AngleRelator.hxx> |
138 | #include <StepShape_AngularLocation.hxx> | |
139 | #include <StepShape_AngularSize.hxx> | |
42cf5bc1 | 140 | #include <StepShape_ConnectedFaceSet.hxx> |
141 | #include <StepShape_ContextDependentShapeRepresentation.hxx> | |
6595eee7 | 142 | #include <StepShape_DimensionalCharacteristic.hxx> |
42cf5bc1 | 143 | #include <StepShape_DimensionalCharacteristicRepresentation.hxx> |
6595eee7 | 144 | #include <StepShape_DimensionalLocation.hxx> |
145 | #include <StepShape_DimensionalLocationWithPath.hxx> | |
42cf5bc1 | 146 | #include <StepShape_DimensionalSize.hxx> |
6595eee7 | 147 | #include <StepShape_DimensionalSizeWithPath.hxx> |
42cf5bc1 | 148 | #include <StepShape_EdgeCurve.hxx> |
149 | #include <StepShape_EdgeLoop.hxx> | |
150 | #include <StepShape_FaceBound.hxx> | |
6595eee7 | 151 | #include <StepShape_LimitsAndFits.hxx> |
42cf5bc1 | 152 | #include <StepShape_OrientedEdge.hxx> |
6595eee7 | 153 | #include <StepShape_PlusMinusTolerance.hxx> |
154 | #include <StepShape_QualifiedRepresentationItem.hxx> | |
42cf5bc1 | 155 | #include <StepShape_ShapeDefinitionRepresentation.hxx> |
156 | #include <StepShape_ShapeDimensionRepresentation.hxx> | |
157 | #include <StepShape_ShapeRepresentation.hxx> | |
6595eee7 | 158 | #include <StepShape_ShapeRepresentationWithParameters.hxx> |
159 | #include <StepShape_ToleranceValue.hxx> | |
160 | #include <StepShape_TypeQualifier.hxx> | |
161 | #include <StepShape_ValueFormatTypeQualifier.hxx> | |
b0cef606 | 162 | #include <StepVisual_AnnotationPlane.hxx> |
42cf5bc1 | 163 | #include <StepVisual_CurveStyle.hxx> |
b0cef606 | 164 | #include <StepVisual_DraughtingCallout.hxx> |
165 | #include <StepVisual_DraughtingModel.hxx> | |
42cf5bc1 | 166 | #include <StepVisual_HArray1OfInvisibleItem.hxx> |
167 | #include <StepVisual_HArray1OfLayeredItem.hxx> | |
168 | #include <StepVisual_HArray1OfPresentationStyleAssignment.hxx> | |
169 | #include <StepVisual_HArray1OfPresentationStyleSelect.hxx> | |
170 | #include <StepVisual_Invisibility.hxx> | |
171 | #include <StepVisual_InvisibleItem.hxx> | |
172 | #include <StepVisual_MechanicalDesignGeometricPresentationRepresentation.hxx> | |
b0cef606 | 173 | #include <StepVisual_NullStyleMember.hxx> |
42cf5bc1 | 174 | #include <StepVisual_PointStyle.hxx> |
175 | #include <StepVisual_PresentationLayerAssignment.hxx> | |
ec357c5c | 176 | #include <StepVisual_PresentationRepresentation.hxx> |
42cf5bc1 | 177 | #include <StepVisual_PresentationStyleAssignment.hxx> |
178 | #include <StepVisual_PresentationStyleByContext.hxx> | |
179 | #include <StepVisual_StyledItem.hxx> | |
180 | #include <StepVisual_SurfaceStyleUsage.hxx> | |
b0cef606 | 181 | #include <StepVisual_TessellatedAnnotationOccurrence.hxx> |
182 | #include <StepVisual_TessellatedGeometricSet.hxx> | |
42cf5bc1 | 183 | #include <TCollection_AsciiString.hxx> |
184 | #include <TCollection_HAsciiString.hxx> | |
185 | #include <TColStd_HArray1OfReal.hxx> | |
186 | #include <TColStd_HArray1OfTransient.hxx> | |
187 | #include <TColStd_HSequenceOfTransient.hxx> | |
6595eee7 | 188 | #include <TColStd_MapOfAsciiString.hxx> |
42cf5bc1 | 189 | #include <TColStd_MapOfTransient.hxx> |
190 | #include <TDataStd_Name.hxx> | |
191 | #include <TDataStd_TreeNode.hxx> | |
192 | #include <TDataStd_UAttribute.hxx> | |
193 | #include <TDF_AttributeSequence.hxx> | |
194 | #include <TDF_ChildIterator.hxx> | |
195 | #include <TDF_Label.hxx> | |
196 | #include <TDF_LabelSequence.hxx> | |
197 | #include <TDF_Tool.hxx> | |
198 | #include <TDocStd_Document.hxx> | |
199 | #include <TopoDS_Compound.hxx> | |
200 | #include <TopoDS_Iterator.hxx> | |
201 | #include <TopoDS_Shape.hxx> | |
202 | #include <TopTools_MapOfShape.hxx> | |
203 | #include <TopTools_SequenceOfShape.hxx> | |
204 | #include <Transfer_ActorOfFinderProcess.hxx> | |
205 | #include <Transfer_Binder.hxx> | |
206 | #include <Transfer_FinderProcess.hxx> | |
207 | #include <Transfer_TransientListBinder.hxx> | |
208 | #include <TransferBRep.hxx> | |
209 | #include <TransferBRep_ShapeMapper.hxx> | |
6595eee7 | 210 | #include <XCAFDimTolObjects_DatumObject.hxx> |
211 | #include <XCAFDimTolObjects_DimensionFormVariance.hxx> | |
212 | #include <XCAFDimTolObjects_DimensionGrade.hxx> | |
213 | #include <XCAFDimTolObjects_DimensionObject.hxx> | |
214 | #include <XCAFDimTolObjects_DimensionModif.hxx> | |
215 | #include <XCAFDimTolObjects_DimensionModifiersSequence.hxx> | |
216 | #include <XCAFDimTolObjects_DimensionQualifier.hxx> | |
217 | #include <XCAFDimTolObjects_GeomToleranceObject.hxx> | |
42cf5bc1 | 218 | #include <XCAFDoc.hxx> |
219 | #include <XCAFDoc_Area.hxx> | |
220 | #include <XCAFDoc_Centroid.hxx> | |
221 | #include <XCAFDoc_ColorTool.hxx> | |
222 | #include <XCAFDoc_Datum.hxx> | |
6595eee7 | 223 | #include <XCAFDoc_Dimension.hxx> |
42cf5bc1 | 224 | #include <XCAFDoc_DimTol.hxx> |
225 | #include <XCAFDoc_DimTolTool.hxx> | |
226 | #include <XCAFDoc_DocumentTool.hxx> | |
6595eee7 | 227 | #include <XCAFDoc_GeomTolerance.hxx> |
42cf5bc1 | 228 | #include <XCAFDoc_GraphNode.hxx> |
229 | #include <XCAFDoc_LayerTool.hxx> | |
230 | #include <XCAFDoc_Material.hxx> | |
231 | #include <XCAFDoc_MaterialTool.hxx> | |
232 | #include <XCAFDoc_ShapeTool.hxx> | |
233 | #include <XCAFDoc_Volume.hxx> | |
234 | #include <XCAFPrs.hxx> | |
235 | #include <XCAFPrs_DataMapIteratorOfDataMapOfStyleShape.hxx> | |
236 | #include <XCAFPrs_DataMapOfShapeStyle.hxx> | |
237 | #include <XCAFPrs_DataMapOfStyleShape.hxx> | |
238 | #include <XCAFPrs_Style.hxx> | |
239 | #include <XSControl_TransferWriter.hxx> | |
240 | #include <XSControl_WorkSession.hxx> | |
7fd59977 | 241 | |
42cf5bc1 | 242 | // added by skl 15.01.2004 for D> writing |
243 | //#include <StepRepr_CompoundItemDefinition.hxx> | |
244 | //#include <StepRepr_CompoundItemDefinitionMember.hxx> | |
245 | // added by skl 12.02.2004 for writing materials | |
7fd59977 | 246 | //======================================================================= |
247 | //function : GetLabelName | |
248 | //purpose : auxilary function: take name of label and append it to str | |
249 | //======================================================================= | |
250 | static Standard_Boolean GetLabelName (const TDF_Label &L, Handle(TCollection_HAsciiString) &str) | |
251 | { | |
252 | Handle(TDataStd_Name) N; | |
253 | if ( ! L.FindAttribute ( TDataStd_Name::GetID(), N ) ) return Standard_False; | |
254 | TCollection_ExtendedString name = N->Get(); | |
255 | if ( name.Length() <=0 ) return Standard_False; | |
256 | ||
257 | // set name, converting it to Ascii and removing spaces | |
258 | TCollection_AsciiString buf ( name, '?' ); | |
259 | buf.LeftAdjust(); | |
260 | buf.RightAdjust(); | |
261 | buf.ChangeAll(' ','_'); | |
262 | str->AssignCat ( buf.ToCString() ); | |
263 | return Standard_True; | |
264 | } | |
265 | ||
266 | ||
267 | //======================================================================= | |
268 | //function : STEPCAFControl_Writer | |
269 | //purpose : | |
270 | //======================================================================= | |
271 | ||
272 | STEPCAFControl_Writer::STEPCAFControl_Writer () : | |
273 | myColorMode( Standard_True ), | |
274 | myNameMode ( Standard_True ), | |
275 | myLayerMode( Standard_True ), | |
276 | myPropsMode( Standard_True ), | |
277 | mySHUOMode ( Standard_True ), | |
278 | myDGTMode ( Standard_True ), | |
279 | myMatMode ( Standard_True ) | |
280 | { | |
281 | STEPCAFControl_Controller::Init(); | |
282 | Handle(XSControl_WorkSession) WS = new XSControl_WorkSession; | |
283 | Init ( WS ); | |
284 | } | |
285 | ||
286 | ||
287 | //======================================================================= | |
288 | //function : STEPCAFControl_Writer | |
289 | //purpose : | |
290 | //======================================================================= | |
291 | ||
292 | STEPCAFControl_Writer::STEPCAFControl_Writer (const Handle(XSControl_WorkSession)& WS, | |
293 | const Standard_Boolean scratch) | |
294 | { | |
295 | STEPCAFControl_Controller::Init(); | |
296 | Init ( WS, scratch ); | |
297 | myColorMode = Standard_True; | |
298 | myNameMode = Standard_True; | |
299 | myLayerMode = Standard_True; | |
300 | myPropsMode = Standard_True; | |
301 | mySHUOMode = Standard_True; | |
302 | } | |
303 | ||
304 | ||
305 | //======================================================================= | |
306 | //function : Init | |
307 | //purpose : | |
308 | //======================================================================= | |
309 | ||
310 | void STEPCAFControl_Writer::Init (const Handle(XSControl_WorkSession)& WS, | |
311 | const Standard_Boolean scratch) | |
312 | { | |
313 | WS->SelectNorm ( "STEP" ); | |
314 | myWriter.SetWS (WS,scratch); | |
997e128f | 315 | myFiles.Clear(); |
7fd59977 | 316 | myLabEF.Clear(); |
317 | myLabels.Clear(); | |
1209c1b9 | 318 | myGDTPresentationDM = new StepVisual_DraughtingModel(); |
319 | myGDTPrsCurveStyle = new StepVisual_HArray1OfPresentationStyleAssignment(1, 1); | |
7fd59977 | 320 | } |
321 | ||
322 | ||
323 | //======================================================================= | |
324 | //function : Write | |
325 | //purpose : | |
326 | //======================================================================= | |
327 | ||
328 | IFSelect_ReturnStatus STEPCAFControl_Writer::Write (const Standard_CString filename) | |
329 | { | |
330 | IFSelect_ReturnStatus status = myWriter.Write ( filename ); | |
331 | ||
332 | // get directory name of the main file | |
333 | OSD_Path mainfile ( filename ); | |
334 | mainfile.SetName ( "" ); | |
335 | mainfile.SetExtension ( "" ); | |
336 | TCollection_AsciiString dpath; | |
337 | mainfile.SystemName ( dpath ); | |
338 | ||
997e128f | 339 | NCollection_DataMap<TCollection_AsciiString, Handle(STEPCAFControl_ExternFile)>::Iterator it(myFiles); |
7fd59977 | 340 | for ( ; it.More(); it.Next() ) { |
341 | Handle(STEPCAFControl_ExternFile) EF = it.Value(); | |
342 | if ( EF->GetWriteStatus() != IFSelect_RetVoid ) continue; | |
343 | ||
344 | // construct extern file name | |
345 | TCollection_AsciiString fname = OSD_Path::AbsolutePath ( dpath, EF->GetName()->String() ); | |
346 | if ( fname.Length() <= 0 ) fname = EF->GetName()->String(); | |
0797d9d3 | 347 | #ifdef OCCT_DEBUG |
7fd59977 | 348 | cout << "Writing external file: " << fname.ToCString() << endl; |
349 | #endif | |
350 | ||
351 | EF->SetWriteStatus ( EF->GetWS()->SendAll ( fname.ToCString() ) ); | |
352 | } | |
353 | ||
354 | return status; | |
355 | } | |
356 | ||
357 | ||
358 | //======================================================================= | |
359 | //function : Transfer | |
360 | //purpose : | |
361 | //======================================================================= | |
362 | ||
1b44ab4b | 363 | Standard_Boolean STEPCAFControl_Writer::Transfer( const Handle(TDocStd_Document) &doc, |
7fd59977 | 364 | const STEPControl_StepModelType mode, |
1b44ab4b | 365 | const Standard_CString multi ) |
7fd59977 | 366 | { |
367 | Handle(XCAFDoc_ShapeTool) STool = XCAFDoc_DocumentTool::ShapeTool( doc->Main() ); | |
368 | if ( STool.IsNull() ) return Standard_False; | |
369 | ||
370 | TDF_LabelSequence labels; | |
371 | STool->GetFreeShapes ( labels ); | |
372 | return Transfer ( myWriter, labels, mode, multi ); | |
373 | } | |
374 | ||
375 | ||
376 | //======================================================================= | |
377 | //function : Transfer | |
378 | //purpose : | |
379 | //======================================================================= | |
380 | ||
1b44ab4b | 381 | Standard_Boolean STEPCAFControl_Writer::Transfer( const TDF_Label& L, |
7fd59977 | 382 | const STEPControl_StepModelType mode, |
1b44ab4b | 383 | const Standard_CString multi ) |
7fd59977 | 384 | { |
385 | TDF_LabelSequence labels; | |
386 | labels.Append ( L ); | |
387 | return Transfer ( myWriter, labels, mode, multi ); | |
388 | } | |
389 | ||
1b44ab4b | 390 | //======================================================================= |
391 | //function : Transfer | |
392 | //purpose : | |
393 | //======================================================================= | |
394 | ||
395 | Standard_Boolean STEPCAFControl_Writer::Transfer( const TDF_LabelSequence& labels, | |
396 | const STEPControl_StepModelType mode, | |
397 | const Standard_CString multi ) | |
398 | { | |
399 | return Transfer( myWriter, labels, mode, multi ); | |
400 | } | |
7fd59977 | 401 | |
402 | //======================================================================= | |
403 | //function : Perform | |
404 | //purpose : | |
405 | //======================================================================= | |
406 | ||
407 | Standard_Boolean STEPCAFControl_Writer::Perform (const Handle(TDocStd_Document) &doc, | |
408 | const Standard_CString filename) | |
409 | { | |
410 | if ( ! Transfer ( doc ) ) return Standard_False; | |
411 | return Write ( filename ) == IFSelect_RetDone; | |
412 | } | |
413 | ||
414 | ||
415 | //======================================================================= | |
416 | //function : Perform | |
417 | //purpose : | |
418 | //======================================================================= | |
419 | ||
420 | Standard_Boolean STEPCAFControl_Writer::Perform (const Handle(TDocStd_Document) &doc, | |
421 | const TCollection_AsciiString &filename) | |
422 | { | |
423 | if ( ! Transfer ( doc ) ) return Standard_False; | |
424 | return Write ( filename.ToCString() ) == IFSelect_RetDone; | |
425 | } | |
426 | ||
427 | ||
428 | //======================================================================= | |
429 | //function : ExternFiles | |
430 | //purpose : | |
431 | //======================================================================= | |
432 | ||
997e128f | 433 | const NCollection_DataMap<TCollection_AsciiString, Handle(STEPCAFControl_ExternFile)>& STEPCAFControl_Writer::ExternFiles () const |
7fd59977 | 434 | { |
435 | return myFiles; | |
436 | } | |
437 | ||
438 | ||
439 | //======================================================================= | |
440 | //function : ExternFile | |
441 | //purpose : | |
442 | //======================================================================= | |
443 | ||
444 | Standard_Boolean STEPCAFControl_Writer::ExternFile (const TDF_Label &L, | |
445 | Handle(STEPCAFControl_ExternFile) &ef) const | |
446 | { | |
447 | ef.Nullify(); | |
448 | if ( ! myLabEF.IsBound ( L ) ) return Standard_False; | |
449 | ef = myLabEF.Find ( L ); | |
450 | return Standard_True; | |
451 | } | |
452 | ||
453 | ||
454 | //======================================================================= | |
455 | //function : ExternFile | |
456 | //purpose : | |
457 | //======================================================================= | |
458 | ||
459 | Standard_Boolean STEPCAFControl_Writer::ExternFile (const Standard_CString name, | |
460 | Handle(STEPCAFControl_ExternFile) &ef) const | |
461 | { | |
462 | ef.Nullify(); | |
997e128f | 463 | if ( ! myFiles.IsEmpty() || ! myFiles.IsBound ( name ) ) |
7fd59977 | 464 | return Standard_False; |
997e128f | 465 | ef = myFiles.Find( name ); |
7fd59977 | 466 | return Standard_True; |
467 | } | |
468 | ||
469 | ||
470 | //======================================================================= | |
471 | //function : Writer | |
472 | //purpose : | |
473 | //======================================================================= | |
474 | ||
475 | STEPControl_Writer &STEPCAFControl_Writer::ChangeWriter () | |
476 | { | |
477 | return myWriter; | |
478 | } | |
479 | ||
480 | ||
481 | //======================================================================= | |
482 | //function : Writer | |
483 | //purpose : | |
484 | //======================================================================= | |
485 | ||
486 | const STEPControl_Writer &STEPCAFControl_Writer::Writer () const | |
487 | { | |
488 | return myWriter; | |
489 | } | |
490 | ||
491 | ||
492 | //======================================================================= | |
493 | //function : Transfer | |
494 | //purpose : | |
495 | //======================================================================= | |
496 | ||
497 | Standard_Boolean STEPCAFControl_Writer::Transfer (STEPControl_Writer &writer, | |
498 | const TDF_LabelSequence &labels, | |
499 | const STEPControl_StepModelType mode, | |
500 | const Standard_CString multi, | |
501 | const Standard_Boolean isExternFile) | |
502 | { | |
503 | if ( labels.Length() <=0 ) return Standard_False; | |
504 | ||
505 | Handle(STEPCAFControl_ActorWrite) Actor = | |
506 | Handle(STEPCAFControl_ActorWrite)::DownCast ( writer.WS()->NormAdaptor()->ActorWrite() ); | |
507 | ||
508 | // translate free top-level shapes of the DECAF document | |
7fd59977 | 509 | Standard_Integer ap = Interface_Static::IVal ("write.step.schema"); |
510 | TDF_LabelSequence sublabels; | |
511 | for ( Standard_Integer i=1; i <= labels.Length(); i++ ) { | |
512 | TDF_Label L = labels.Value(i); | |
513 | TopoDS_Shape dummy; | |
514 | if ( myLabels.IsBound ( L ) ) continue; // already processed | |
515 | ||
516 | TopoDS_Shape shape = XCAFDoc_ShapeTool::GetShape ( L ); | |
517 | if ( shape.IsNull() ) continue; | |
518 | ||
519 | // write shape either as a whole, or as multifile (with extern refs) | |
f5e92b04 | 520 | if ( ! multi ) { |
7fd59977 | 521 | Actor->SetStdMode ( Standard_False ); |
522 | ||
7fd59977 | 523 | TDF_LabelSequence comp; |
f5e92b04 | 524 | |
525 | //for case when only part of assemby structure should be written in the document | |
526 | //if specified label is component of the assembly then | |
527 | //in order to save location of this component in the high-level assembly | |
528 | //and save name of high-level assembly it is necessary to represent structure of high-level assembly | |
529 | //as assembly with one component specified by current label. | |
530 | //For that compound containing only specified component is binded to the label of the high-level assembly. | |
531 | //The such way full structure of high-level assembly was replaced on the assembly contaning one component. | |
532 | if ( XCAFDoc_ShapeTool::IsComponent ( L ) ) | |
533 | { | |
534 | TopoDS_Compound aComp; | |
535 | BRep_Builder aB; | |
536 | aB.MakeCompound(aComp); | |
537 | aB.Add(aComp, shape); | |
538 | shape = aComp; | |
539 | comp.Append(L); | |
540 | TDF_Label ref; | |
541 | if ( XCAFDoc_ShapeTool::GetReferredShape ( L, ref ) ) | |
542 | { | |
543 | if(XCAFDoc_ShapeTool::IsAssembly ( ref)) | |
544 | XCAFDoc_ShapeTool::GetComponents ( ref, comp, Standard_True ); | |
545 | } | |
546 | L = L.Father(); | |
547 | } | |
548 | else | |
549 | { | |
550 | // fill sequence of (sub) shapes for which attributes should be written | |
551 | // and set actor to handle assemblies in a proper way | |
552 | if(XCAFDoc_ShapeTool::IsAssembly ( L )) | |
553 | XCAFDoc_ShapeTool::GetComponents ( L, comp, Standard_True ); | |
554 | } | |
555 | ||
7fd59977 | 556 | for ( Standard_Integer k=1; k <= comp.Length(); k++ ) { |
f5e92b04 | 557 | TDF_Label ref; |
558 | if ( ! XCAFDoc_ShapeTool::GetReferredShape ( comp(k), ref ) ) continue; | |
559 | if ( ! myLabels.IsBound ( ref ) ) { | |
560 | TopoDS_Shape refS = XCAFDoc_ShapeTool::GetShape ( ref ); | |
561 | myLabels.Bind ( ref, refS ); | |
562 | sublabels.Append ( ref ); | |
563 | if ( XCAFDoc_ShapeTool::IsAssembly ( ref ) ) | |
564 | Actor->RegisterAssembly ( refS ); | |
565 | } | |
7fd59977 | 566 | } |
567 | myLabels.Bind ( L, shape ); | |
568 | sublabels.Append ( L ); | |
569 | if ( XCAFDoc_ShapeTool::IsAssembly ( L ) ) | |
f5e92b04 | 570 | Actor->RegisterAssembly ( shape ); |
7fd59977 | 571 | |
572 | writer.Transfer(shape,mode,Standard_False); | |
573 | Actor->SetStdMode ( Standard_True ); // restore default behaviour | |
574 | } | |
575 | else { | |
576 | // translate final solids | |
577 | TopoDS_Shape Sass = TransferExternFiles ( L, mode, sublabels, multi ); | |
578 | ||
579 | // translate main assembly structure | |
580 | /* | |
581 | if ( ap == 3 ) { // if AP203, switch to AP214 | |
582 | Interface_Static::SetCVal ("write.step.schema", "AP214DIS"); | |
583 | Handle(StepData_StepModel) model = | |
584 | Handle(StepData_StepModel)::DownCast ( writer.WS()->Model() ); | |
585 | if ( model->HasHeaderEntity(STANDARD_TYPE(HeaderSection_FileSchema)) ) { | |
586 | Handle(HeaderSection_FileSchema) fs = | |
587 | Handle(HeaderSection_FileSchema)::DownCast ( model->HeaderEntity(STANDARD_TYPE(HeaderSection_FileSchema)) ); | |
588 | Handle(TCollection_HAsciiString) str = fs->SchemaIdentifiersValue ( 1 ); | |
589 | Handle(TCollection_HAsciiString) ap214 = new TCollection_HAsciiString ( "AUTOMOTIVE_DESIGN" ); | |
590 | if ( str->Search ( ap214 ) <0 ) { | |
591 | str->Clear(); | |
592 | str->AssignCat ( ap214 ); | |
593 | } | |
594 | } | |
595 | } | |
596 | */ | |
597 | Standard_Integer assemblymode = Interface_Static::IVal ("write.step.assembly"); | |
598 | Interface_Static::SetCVal ("write.step.assembly", "On"); | |
599 | writer.Transfer ( Sass, STEPControl_AsIs ); | |
600 | Interface_Static::SetIVal ("write.step.assembly", assemblymode); | |
601 | Interface_Static::SetIVal ("write.step.schema", ap); | |
602 | } | |
603 | } | |
604 | ||
605 | writer.WS()->ComputeGraph(Standard_True );// added by skl 03.11.2003 since we use | |
606 | // writer.Transfer() wihtout compute graph | |
607 | ||
608 | // write names | |
609 | if ( GetNameMode() ) | |
610 | WriteNames ( writer.WS(), sublabels ); | |
611 | ||
612 | if ( !multi ) { | |
613 | // write colors | |
614 | if ( GetColorMode() ) | |
615 | WriteColors ( writer.WS(), sublabels ); | |
616 | ||
617 | // write layers | |
618 | if ( GetLayerMode() ) | |
619 | WriteLayers ( writer.WS(), sublabels ); | |
620 | ||
621 | // write SHUO entities | |
622 | if ( GetSHUOMode() && !isExternFile ) | |
623 | // do not store SHUO for extern reference for the moment | |
624 | WriteSHUOs ( writer.WS(), sublabels ); | |
625 | ||
626 | // write G&DTs | |
d658f275 | 627 | if(GetDimTolMode()) { |
628 | if (ap == 5) { | |
629 | WriteDGTsAP242(writer.WS(), sublabels); | |
630 | } | |
631 | else { | |
632 | WriteDGTs(writer.WS(), sublabels); | |
633 | } | |
634 | } | |
7fd59977 | 635 | |
636 | // write Materials | |
637 | if(GetMaterialMode()) | |
638 | WriteMaterials(writer.WS(),sublabels); | |
639 | ||
640 | // register all MDGPRs in model | |
7f56eba8 | 641 | const Handle(Interface_InterfaceModel) &Model = writer.WS()->Model(); |
7fd59977 | 642 | MoniTool_DataMapIteratorOfDataMapOfShapeTransient anItr(myMapCompMDGPR); |
7f56eba8 | 643 | for (; anItr.More(); anItr.Next()) |
7fd59977 | 644 | Model->AddWithRefs( anItr.Value() ); |
7fd59977 | 645 | } |
646 | ||
647 | if ( multi ) { // external refs | |
648 | WriteExternRefs ( writer.WS(), sublabels ); | |
649 | } | |
650 | ||
651 | // write validation props | |
652 | // if ( multi && ap ==3 ) { | |
653 | // Interface_Static::SetCVal ("write.step.schema", "AP214DIS"); | |
654 | // } | |
655 | if ( GetPropsMode() ) | |
656 | WriteValProps ( writer.WS(), sublabels, multi ); | |
657 | ||
658 | Interface_Static::SetIVal ("write.step.schema", ap); | |
659 | ||
660 | // refresh graph | |
661 | writer.WS()->ComputeGraph ( Standard_True ); | |
662 | ||
02a0b964 | 663 | /* ================================ |
664 | * Write names for the sub-shapes | |
665 | * ================================ */ | |
666 | ||
dde68833 | 667 | if (Interface_Static::IVal("write.stepcaf.subshapes.name") != 0) |
02a0b964 | 668 | { |
7f56eba8 | 669 | const Handle(XSControl_TransferWriter) &TW = this->ChangeWriter().WS()->TransferWriter(); |
670 | const Handle(Transfer_FinderProcess) &FP = TW->FinderProcess(); | |
02a0b964 | 671 | |
672 | for ( int i = 1; i <= labels.Length(); i++ ) | |
673 | { | |
674 | TDF_Label L = labels.Value(i); | |
675 | ||
676 | for ( TDF_ChildIterator it(L, Standard_True); it.More(); it.Next() ) | |
677 | { | |
678 | TDF_Label SubL = it.Value(); | |
679 | ||
680 | // Access name recorded in OCAF TDataStd_Name attribute | |
681 | Handle(TCollection_HAsciiString) hSubName = new TCollection_HAsciiString; | |
682 | if ( !GetLabelName(SubL, hSubName) ) | |
683 | continue; | |
684 | ||
685 | // Access topological data | |
686 | TopoDS_Shape SubS = XCAFDoc_ShapeTool::GetShape(SubL); | |
687 | if ( SubS.IsNull() ) | |
688 | continue; | |
689 | ||
690 | // Access the correspondent STEP Representation Item | |
691 | Handle(StepRepr_RepresentationItem) RI; | |
692 | Handle(TransferBRep_ShapeMapper) aShMapper = TransferBRep::ShapeMapper(FP, SubS); | |
693 | if ( !FP->FindTypedTransient(aShMapper, STANDARD_TYPE(StepRepr_RepresentationItem), RI) ) | |
694 | continue; | |
695 | ||
696 | // Record the name | |
697 | RI->SetName(hSubName); | |
698 | } | |
699 | } | |
700 | } | |
701 | ||
7fd59977 | 702 | return Standard_True; |
703 | } | |
704 | ||
705 | ||
706 | //======================================================================= | |
707 | //function : TransferExternFiles | |
708 | //purpose : | |
709 | //======================================================================= | |
710 | ||
711 | TopoDS_Shape STEPCAFControl_Writer::TransferExternFiles (const TDF_Label &L, | |
712 | const STEPControl_StepModelType mode, | |
713 | TDF_LabelSequence &labels, | |
714 | const Standard_CString prefix) | |
715 | { | |
716 | // if label already translated, just return the shape | |
717 | if ( myLabels.IsBound ( L ) ) { | |
718 | return myLabels.Find ( L ); | |
719 | } | |
720 | ||
721 | TopoDS_Compound C; | |
722 | BRep_Builder B; | |
723 | B.MakeCompound ( C ); | |
f5e92b04 | 724 | //labels.Append ( L ); |
7fd59977 | 725 | // if not assembly, write to separate file |
f5e92b04 | 726 | if ( ! XCAFDoc_ShapeTool::IsAssembly ( L ) && !XCAFDoc_ShapeTool::IsComponent ( L )) { |
727 | labels.Append ( L ); | |
7fd59977 | 728 | // prepare for transfer |
729 | Handle(XSControl_WorkSession) newWS = new XSControl_WorkSession; | |
730 | newWS->SelectNorm ( "STEP" ); | |
731 | STEPControl_Writer sw ( newWS, Standard_True ); | |
732 | TDF_LabelSequence Lseq; | |
733 | Lseq.Append ( L ); | |
734 | ||
735 | // construct the name for extern file | |
736 | Handle(TCollection_HAsciiString) basename = new TCollection_HAsciiString; | |
737 | if ( prefix && prefix[0] ) basename->AssignCat ( prefix ); | |
738 | GetLabelName ( L, basename ); | |
739 | Handle(TCollection_HAsciiString) name = new TCollection_HAsciiString ( basename ); | |
740 | name->AssignCat ( ".stp" ); | |
997e128f | 741 | if ( myFiles.IsBound( name->ToCString() ) ) { // avoid confusions |
7fd59977 | 742 | for ( Standard_Integer k=1; k < 32000; k++ ) { |
997e128f | 743 | name = new TCollection_HAsciiString ( basename ); |
744 | name->AssignCat ( "_" ); | |
745 | name->AssignCat ( TCollection_AsciiString ( k ).ToCString() ); | |
746 | name->AssignCat ( ".stp" ); | |
747 | if ( ! myFiles.IsBound ( name->ToCString() ) ) break; | |
7fd59977 | 748 | } |
749 | } | |
750 | ||
751 | // translate and record extern file | |
752 | Handle(STEPCAFControl_ExternFile) EF = new STEPCAFControl_ExternFile; | |
753 | EF->SetWS ( newWS ); | |
754 | EF->SetName ( name ); | |
755 | EF->SetLabel ( L ); | |
756 | Standard_Integer assemblymode = Interface_Static::IVal ("write.step.assembly"); | |
757 | Interface_Static::SetCVal ("write.step.assembly", "Off"); | |
758 | const Standard_CString multi = 0; | |
759 | EF->SetTransferStatus ( Transfer ( sw, Lseq, mode, multi, Standard_True ) ); | |
760 | Interface_Static::SetIVal ("write.step.assembly", assemblymode); | |
761 | myLabEF.Bind ( L, EF ); | |
997e128f | 762 | myFiles.Bind ( name->ToCString(), EF ); |
7fd59977 | 763 | |
764 | // return empty compound as replacement for the shape | |
765 | myLabels.Bind ( L, C ); | |
766 | return C; | |
767 | } | |
f5e92b04 | 768 | TDF_LabelSequence comp; |
769 | TDF_Label aCurL = L; | |
770 | //if specified shape is component then high-level assembly is considered | |
771 | //to get valid structure with location | |
772 | if ( XCAFDoc_ShapeTool::IsComponent ( L ) ) | |
773 | { | |
774 | comp.Append(L); | |
775 | aCurL = L.Father(); | |
776 | } | |
7fd59977 | 777 | // else iterate on components add create structure of empty compounds |
778 | // representing the assembly | |
f5e92b04 | 779 | else if (XCAFDoc_ShapeTool::IsAssembly ( L )) |
780 | XCAFDoc_ShapeTool::GetComponents ( L, comp, Standard_False ); | |
781 | ||
782 | labels.Append ( aCurL ); | |
7fd59977 | 783 | for ( Standard_Integer k=1; k <= comp.Length(); k++ ) { |
784 | TDF_Label lab = comp(k); | |
785 | TDF_Label ref; | |
786 | if ( ! XCAFDoc_ShapeTool::GetReferredShape ( lab, ref ) ) continue; | |
787 | TopoDS_Shape Scomp = TransferExternFiles ( ref, mode, labels, prefix ); | |
788 | Scomp.Location ( XCAFDoc_ShapeTool::GetLocation ( lab ) ); | |
789 | B.Add ( C, Scomp ); | |
790 | } | |
f5e92b04 | 791 | myLabels.Bind ( aCurL, C ); |
7fd59977 | 792 | return C; |
793 | } | |
794 | ||
795 | ||
796 | //======================================================================= | |
797 | //function : WriteExternRefs | |
798 | //purpose : | |
799 | //======================================================================= | |
800 | ||
801 | Standard_Boolean STEPCAFControl_Writer::WriteExternRefs (const Handle(XSControl_WorkSession) &WS, | |
802 | const TDF_LabelSequence &labels) const | |
803 | { | |
804 | if ( labels.Length() <=0 ) return Standard_False; | |
805 | ||
7f56eba8 | 806 | const Handle(XSControl_TransferWriter) &TW = WS->TransferWriter(); |
807 | const Handle(Transfer_FinderProcess) &FP = TW->FinderProcess(); | |
7fd59977 | 808 | STEPConstruct_ExternRefs EFTool ( WS ); |
809 | Standard_Integer schema = Interface_Static::IVal("write.step.schema"); | |
810 | for ( Standard_Integer k=1; k <= labels.Length(); k++ ) { | |
811 | TDF_Label lab = labels(k); | |
812 | if ( XCAFDoc_ShapeTool::IsAssembly ( lab ) ) continue; // skip assemblies | |
813 | ||
814 | // get extern file | |
815 | Handle(STEPCAFControl_ExternFile) EF; | |
816 | if ( ! ExternFile ( lab, EF ) ) continue; // should never be | |
817 | ||
818 | // find SDR | |
819 | if ( ! myLabels.IsBound ( lab ) ) continue; // not recorded as translated, skip | |
820 | TopoDS_Shape S = myLabels.Find ( lab ); | |
821 | ||
822 | Handle(StepShape_ShapeDefinitionRepresentation) SDR; | |
823 | Handle(TransferBRep_ShapeMapper) mapper = TransferBRep::ShapeMapper ( FP, S ); | |
824 | if ( ! FP->FindTypedTransient ( mapper, STANDARD_TYPE(StepShape_ShapeDefinitionRepresentation), SDR ) ) { | |
0797d9d3 | 825 | #ifdef OCCT_DEBUG |
7fd59977 | 826 | cout << "Warning: Cannot find SDR for " << S.TShape()->DynamicType()->Name() << endl; |
827 | #endif | |
828 | continue; | |
829 | } | |
830 | ||
831 | // add extern ref | |
832 | const Standard_CString format = (const Standard_CString) ( schema == 3 ? "STEP AP203" : "STEP AP214" ); | |
833 | // try to get PD from SDR | |
834 | StepRepr_RepresentedDefinition RD = SDR->Definition(); | |
835 | Handle(StepRepr_PropertyDefinition) aPropDef = RD.PropertyDefinition(); | |
836 | if (aPropDef.IsNull()) { | |
0797d9d3 | 837 | #ifdef OCCT_DEBUG |
7fd59977 | 838 | cout << "Warning: STEPCAFControl_Writer::WriteExternRefs StepRepr_PropertyDefinition is null for " << S.TShape()->DynamicType()->Name() << endl; |
839 | #endif | |
840 | continue; | |
841 | } | |
842 | StepRepr_CharacterizedDefinition CharDef = aPropDef->Definition(); | |
843 | Handle(StepBasic_ProductDefinition) PD = CharDef.ProductDefinition(); | |
844 | if (PD.IsNull()) { | |
0797d9d3 | 845 | #ifdef OCCT_DEBUG |
7fd59977 | 846 | cout << "Warning: STEPCAFControl_Writer::WriteExternRefs StepBasic_ProductDefinition is null for " << S.TShape()->DynamicType()->Name() << endl; |
847 | #endif | |
848 | continue; | |
849 | } | |
850 | EFTool.AddExternRef ( EF->GetName()->ToCString(), PD, format ); | |
851 | } | |
852 | EFTool.WriteExternRefs(schema); | |
853 | return Standard_True; | |
854 | } | |
855 | ||
856 | ||
857 | //======================================================================= | |
858 | //function : FindEntities | |
859 | //purpose : auxilary | |
860 | //======================================================================= | |
861 | static Standard_Integer FindEntities (const Handle(Transfer_FinderProcess) &FP, | |
862 | const TopoDS_Shape &S, | |
863 | TopLoc_Location &L, | |
864 | TColStd_SequenceOfTransient &seqRI) | |
865 | { | |
866 | Handle(StepRepr_RepresentationItem) item = STEPConstruct::FindEntity ( FP, S, L ); | |
867 | ||
868 | if ( ! item.IsNull() ) { | |
869 | seqRI.Append ( item ); | |
870 | return 1; | |
871 | } | |
872 | ||
873 | // may be S was splited during shape processing | |
874 | Handle(TransferBRep_ShapeMapper) mapper = TransferBRep::ShapeMapper ( FP, S ); | |
875 | Handle(Transfer_Binder) bnd = FP->Find ( mapper ); | |
876 | if ( bnd.IsNull() ) return 0; | |
877 | ||
878 | Handle(Transfer_TransientListBinder) TransientListBinder = | |
879 | //Handle(Transfer_TransientListBinder)::DownCast( bnd->Next(Standard_True) ); | |
880 | Handle(Transfer_TransientListBinder)::DownCast( bnd ); | |
881 | Standard_Integer nres=0; | |
882 | if ( TransientListBinder.IsNull() && S.ShapeType() == TopAbs_COMPOUND) | |
883 | { | |
884 | for ( TopoDS_Iterator it(S); it.More(); it.Next() ) { | |
51740958 | 885 | Handle(StepRepr_RepresentationItem) aLocalItem = STEPConstruct::FindEntity ( FP, it.Value(), L ); |
886 | if (aLocalItem.IsNull() ) continue; | |
7fd59977 | 887 | nres++; |
51740958 | 888 | seqRI.Append (aLocalItem); |
7fd59977 | 889 | } |
890 | } | |
72523826 | 891 | else if(!TransientListBinder.IsNull()) |
7fd59977 | 892 | { |
72523826 | 893 | |
7fd59977 | 894 | const Standard_Integer nb = TransientListBinder->NbTransients(); |
895 | for (Standard_Integer i=1; i<=nb; i++) { | |
896 | Handle(Standard_Transient) t = TransientListBinder->Transient(i); | |
897 | item = Handle(StepRepr_RepresentationItem)::DownCast(t); | |
898 | if ( item.IsNull() ) continue; | |
899 | nres++; | |
900 | seqRI.Append ( item ); | |
901 | } | |
902 | } | |
903 | /* works but is obsolete: another approach | |
904 | if (i<=nb) { | |
905 | TopoDS_Shape comp = TransferBRep::ShapeResult(bnd); | |
906 | if ( ! comp.IsNull() && comp.ShapeType() < S.ShapeType() ) { | |
907 | for ( TopoDS_Iterator it(comp); it.More(); it.Next() ) { | |
908 | MakeSTEPStyles(Styles, it.Value(), settings, STEPstyle, | |
909 | Map, ( hasOwn ? &style : 0 ) ); | |
910 | } | |
911 | } | |
912 | } | |
913 | */ | |
914 | return nres; | |
915 | } | |
916 | ||
917 | ||
918 | //======================================================================= | |
919 | //function : getStyledItem | |
920 | //purpose : auxilary | |
921 | //======================================================================= | |
922 | static Standard_Boolean getStyledItem(const TopoDS_Shape& S, | |
923 | const Handle(XCAFDoc_ShapeTool)& STool, | |
924 | const STEPConstruct_Styles &Styles, | |
925 | Handle(StepVisual_StyledItem) &resSelItem, | |
926 | const MoniTool_DataMapOfShapeTransient& myMapCompMDGPR) | |
927 | { | |
928 | TDF_Label aTopShL = STool->FindShape(S, Standard_False); | |
929 | TopoDS_Shape aTopLevSh = STool->GetShape( aTopShL ); | |
930 | Standard_Boolean found = Standard_False; | |
931 | if ( !aTopLevSh.IsNull() && myMapCompMDGPR.IsBound( aTopLevSh ) ) { | |
932 | Handle(StepVisual_PresentationRepresentation) aMDGPR = | |
933 | Handle(StepVisual_PresentationRepresentation)::DownCast( myMapCompMDGPR.Find( aTopLevSh ) ); | |
934 | Handle(StepRepr_HArray1OfRepresentationItem) anSelItmHArr = aMDGPR->Items(); | |
935 | // search for PSA of Monifold solid | |
936 | if ( !anSelItmHArr.IsNull() ) | |
937 | { | |
938 | for (Standard_Integer si = 1; si <= anSelItmHArr->Length(); si++) { | |
939 | Handle(StepVisual_StyledItem) aSelItm = | |
940 | Handle(StepVisual_StyledItem)::DownCast(anSelItmHArr->Value(si)); | |
941 | ||
942 | if ( aSelItm.IsNull() ) | |
943 | continue; | |
944 | ||
945 | // check that it is a stiled item for monifold solid brep | |
946 | TopLoc_Location Loc; | |
947 | TColStd_SequenceOfTransient aNewseqRI; | |
948 | FindEntities ( Styles.FinderProcess(), aTopLevSh, Loc, aNewseqRI ); | |
949 | if ( aNewseqRI.Length() > 0 ) | |
950 | { | |
951 | ||
952 | Handle(StepRepr_RepresentationItem) anItem = aSelItm->Item(); | |
953 | Standard_Boolean isSameMonSolBR = Standard_False; | |
954 | for (Standard_Integer mi = 1; mi <= aNewseqRI.Length(); mi++) { | |
955 | if ( !anItem.IsNull() && anItem == aNewseqRI.Value( mi ) ) { | |
956 | isSameMonSolBR = Standard_True; | |
957 | break; | |
958 | } | |
959 | } | |
960 | if (!isSameMonSolBR) | |
961 | continue; | |
962 | } | |
963 | ||
964 | ||
965 | for (Standard_Integer jsi = 1; jsi <= aSelItm->NbStyles() && !found; jsi++) { | |
a9dde4a3 | 966 | Handle(StepVisual_PresentationStyleAssignment) aFatherPSA = aSelItm->StylesValue(jsi); |
7fd59977 | 967 | // check for PSA for top-level (not Presentation style by contex for NAUO) |
968 | if (aFatherPSA.IsNull() || aFatherPSA->IsKind(STANDARD_TYPE(StepVisual_PresentationStyleByContext))) | |
969 | continue; | |
970 | resSelItem = aSelItm; | |
971 | found = Standard_True; | |
972 | } | |
973 | } | |
974 | } | |
975 | } | |
976 | return found; | |
977 | } | |
978 | ||
979 | ||
980 | //======================================================================= | |
981 | //function : setDefaultInstanceColor | |
982 | //purpose : auxilary | |
983 | //======================================================================= | |
984 | static Standard_Boolean setDefaultInstanceColor (const Handle(StepVisual_StyledItem) &aSelItm, | |
985 | Handle(StepVisual_PresentationStyleAssignment)& PSA) | |
986 | { | |
987 | Standard_Boolean found = Standard_False; | |
988 | for (Standard_Integer jsi = 1; jsi <= aSelItm->NbStyles() && !found; jsi++) { | |
a9dde4a3 | 989 | Handle(StepVisual_PresentationStyleAssignment) aFatherPSA = aSelItm->StylesValue(jsi); |
7fd59977 | 990 | // check for PSA for top-level (not Presentation style by contex for NAUO) |
991 | if (aFatherPSA.IsNull() || aFatherPSA->IsKind(STANDARD_TYPE(StepVisual_PresentationStyleByContext))) | |
992 | return Standard_False; | |
993 | ||
994 | // get style select from father PSA | |
995 | if (aFatherPSA->NbStyles() > 0) { | |
996 | Handle(StepVisual_HArray1OfPresentationStyleSelect) aFatherStyles = | |
997 | new StepVisual_HArray1OfPresentationStyleSelect(1, aFatherPSA->NbStyles()); | |
998 | for (Standard_Integer k = 1; k <= aFatherPSA->NbStyles(); k++) { | |
999 | StepVisual_PresentationStyleSelect PSS; | |
1000 | StepVisual_PresentationStyleSelect olDPSS = aFatherPSA->StylesValue(k); | |
1001 | if (!olDPSS.PointStyle().IsNull()) | |
1002 | PSS.SetValue (olDPSS.PointStyle()); | |
1003 | else if (!olDPSS.CurveStyle().IsNull()) | |
1004 | PSS.SetValue (olDPSS.CurveStyle()); | |
1005 | else if (!olDPSS.SurfaceStyleUsage().IsNull()) | |
1006 | PSS.SetValue (olDPSS.SurfaceStyleUsage()); | |
1007 | else { | |
1008 | found = Standard_False; | |
1009 | break; | |
1010 | } | |
1011 | //aFatherStyles->SetValue( k, PSS ); | |
1012 | aFatherStyles->SetValue( k, olDPSS ); | |
1013 | found = Standard_True; | |
1014 | } | |
1015 | // init PSA of NAUO | |
1016 | if (found) { | |
1017 | PSA->Init( aFatherStyles ); | |
1018 | } | |
1019 | } | |
1020 | ||
1021 | } | |
1022 | return found; | |
1023 | } | |
1024 | ||
1025 | ||
1026 | //======================================================================= | |
1027 | //function : MakeSTEPStyles | |
1028 | //purpose : auxilary | |
1029 | //======================================================================= | |
1030 | static void MakeSTEPStyles (STEPConstruct_Styles &Styles, | |
1031 | const TopoDS_Shape &S, | |
1032 | const XCAFPrs_DataMapOfShapeStyle &settings, | |
1033 | Handle(StepVisual_StyledItem) &override, | |
1034 | TopTools_MapOfShape &Map, | |
1035 | const MoniTool_DataMapOfShapeTransient& myMapCompMDGPR, | |
1036 | STEPConstruct_DataMapOfAsciiStringTransient &DPDCs, | |
1037 | STEPConstruct_DataMapOfPointTransient &ColRGBs, | |
1038 | const Handle(XCAFDoc_ColorTool)& CTool, | |
1039 | const XCAFPrs_Style *inherit = 0, | |
1040 | const Standard_Boolean isComponent = Standard_False) | |
1041 | { | |
1042 | // skip already processed shapes | |
1043 | if ( ! Map.Add ( S ) ) return; | |
1044 | ||
1045 | // check if shape has its own style (r inherits from ancestor) | |
1046 | XCAFPrs_Style style; | |
1047 | if ( inherit ) style = *inherit; | |
1048 | if ( settings.IsBound(S) ) { | |
1049 | XCAFPrs_Style own = settings.Find(S); | |
1050 | if ( !own.IsVisible() ) style.SetVisibility ( Standard_False ); | |
1051 | if ( own.IsSetColorCurv() ) style.SetColorCurv ( own.GetColorCurv() ); | |
1052 | if ( own.IsSetColorSurf() ) style.SetColorSurf ( own.GetColorSurf() ); | |
1053 | } | |
1054 | ||
1055 | // translate colors to STEP | |
1056 | Handle(StepVisual_Colour) surfColor, curvColor; | |
1057 | if ( style.IsSetColorSurf() ) | |
1058 | surfColor = Styles.EncodeColor(style.GetColorSurf(),DPDCs,ColRGBs); | |
1059 | if ( style.IsSetColorCurv() ) | |
1060 | curvColor = Styles.EncodeColor(style.GetColorCurv(),DPDCs,ColRGBs); | |
1061 | ||
1062 | Standard_Boolean hasOwn = ( ! surfColor.IsNull() || | |
1063 | ! curvColor.IsNull() || | |
1064 | ! style.IsVisible() ); | |
1065 | ||
1066 | // find target item and assign style to it | |
1067 | Handle(StepVisual_StyledItem) STEPstyle = override; | |
1068 | if ( hasOwn ) { | |
1069 | if ( S.ShapeType() != TopAbs_COMPOUND || isComponent ) { // skip compounds, let subshapes inherit its colors | |
1070 | TopLoc_Location L; | |
1071 | TColStd_SequenceOfTransient seqRI; | |
1072 | Standard_Integer nb = FindEntities ( Styles.FinderProcess(), S, L, seqRI ); | |
0797d9d3 | 1073 | #ifdef OCCT_DEBUG |
7fd59977 | 1074 | if ( nb <=0 ) cout << "Warning: Cannot find RI for " << S.TShape()->DynamicType()->Name() << endl; |
1075 | #endif | |
1076 | //Get overridden style gka 10.06.03 | |
1077 | if ( isComponent && nb) | |
1078 | getStyledItem(S, CTool->ShapeTool(), Styles, override,myMapCompMDGPR); | |
1079 | ||
1080 | ||
1081 | for ( Standard_Integer i=1; i <= nb; i++ ) { | |
1082 | Handle(StepRepr_RepresentationItem) item = | |
1083 | Handle(StepRepr_RepresentationItem)::DownCast(seqRI(i)); | |
1084 | Handle(StepVisual_PresentationStyleAssignment) PSA; | |
1085 | if ( style.IsVisible() || !surfColor.IsNull() || !curvColor.IsNull() ) { | |
1086 | PSA = Styles.MakeColorPSA ( item, surfColor, curvColor, isComponent ); | |
1087 | } | |
1088 | else { | |
1089 | // default white color | |
1090 | surfColor = Styles.EncodeColor(Quantity_Color(1,1,1,Quantity_TOC_RGB),DPDCs,ColRGBs); | |
1091 | PSA = Styles.MakeColorPSA ( item, surfColor, curvColor, isComponent ); | |
1092 | if ( isComponent ) | |
1093 | setDefaultInstanceColor( override, PSA); | |
1094 | ||
1095 | } // end of component case | |
1096 | ||
1097 | STEPstyle = Styles.AddStyle ( item, PSA, override ); | |
1098 | hasOwn = Standard_False; | |
1099 | } | |
1100 | } | |
1101 | } | |
1102 | ||
1103 | // iterate on subshapes (except vertices :) | |
1104 | if ( S.ShapeType() == TopAbs_EDGE ) return; | |
1105 | if ( !isComponent ) // PTV 10.02.2003 | |
1106 | for ( TopoDS_Iterator it(S); it.More(); it.Next() ) { | |
1107 | MakeSTEPStyles ( Styles, it.Value(), settings, STEPstyle, | |
1108 | Map, myMapCompMDGPR, DPDCs, ColRGBs, CTool, | |
1109 | ( hasOwn ? &style : 0 ) ); | |
1110 | } | |
1111 | } | |
1112 | ||
1113 | /* | |
1114 | static Standard_Boolean getFatherColor (const TDF_Label& L, | |
1115 | const Handle(XCAFDoc_ColorTool)& CTool, | |
1116 | XCAFPrs_Style& style) | |
1117 | { | |
1118 | Standard_Boolean done = Standard_False; | |
1119 | TopoDS_Shape aSh = CTool->ShapeTool()->GetShape( L ); | |
1120 | TDF_Label aFL = CTool->ShapeTool()->FindShape( aSh ); | |
1121 | if (aFL.IsNull() || aFL == L) | |
1122 | return done; | |
1123 | Quantity_Color C; | |
1124 | if ( CTool->GetColor ( aFL, XCAFDoc_ColorGen, C ) ) { | |
1125 | style.SetColorCurv ( C ); | |
1126 | style.SetColorSurf ( C ); | |
1127 | done = Standard_True; | |
1128 | } | |
1129 | if ( CTool->GetColor ( aFL, XCAFDoc_ColorSurf, C ) ) { | |
1130 | style.SetColorSurf ( C ); | |
1131 | done = Standard_True; | |
1132 | } | |
1133 | if ( CTool->GetColor ( aFL, XCAFDoc_ColorCurv, C ) ) { | |
1134 | style.SetColorCurv ( C ); | |
1135 | done = Standard_True; | |
1136 | } | |
1137 | ||
1138 | return done; | |
1139 | } | |
1140 | */ | |
1141 | ||
1142 | ||
1143 | //======================================================================= | |
1144 | //function : WriteColors | |
1145 | //purpose : | |
1146 | //======================================================================= | |
1147 | ||
1148 | Standard_Boolean STEPCAFControl_Writer::WriteColors (const Handle(XSControl_WorkSession) &WS, | |
1149 | const TDF_LabelSequence &labels) | |
1150 | { | |
1151 | if ( labels.Length() <=0 ) return Standard_False; | |
1152 | ||
1153 | // Iterate on shapes in the document | |
1154 | Handle(XCAFDoc_ColorTool) CTool = XCAFDoc_DocumentTool::ColorTool( labels(1) ); | |
1155 | if ( CTool.IsNull() ) return Standard_False; | |
1156 | ||
1157 | STEPConstruct_Styles Styles ( WS ); | |
1158 | STEPConstruct_DataMapOfAsciiStringTransient DPDCs; | |
1159 | STEPConstruct_DataMapOfPointTransient ColRGBs; | |
1160 | for ( Standard_Integer i=1; i <= labels.Length(); i++ ) { | |
1161 | TDF_Label L = labels.Value(i); | |
1162 | ||
1163 | Handle(XCAFDoc_ShapeTool) aSTool = XCAFDoc_DocumentTool::ShapeTool( labels(1) ); | |
1164 | // Skip assemblies: colors assigned to assemblies and their instances | |
1165 | // are not supported (it is not clear how to encode that in STEP) | |
1166 | if ( XCAFDoc_ShapeTool::IsAssembly ( L ) ) { | |
0797d9d3 | 1167 | #ifdef OCCT_DEBUG |
7fd59977 | 1168 | cout << "Warning: Cannot write color for Assembly" << endl; |
1169 | cout << "Info: Check for colors assigned to components in assembly" << endl; | |
1170 | #endif | |
1171 | // PTV 22.01.2003 Write color for instances. | |
1172 | TDF_LabelSequence compLabels; | |
1173 | if ( aSTool.IsNull() ) | |
1174 | continue; | |
1175 | if (!aSTool->GetComponents(L, compLabels)) | |
1176 | continue; | |
1177 | WriteColors(WS, compLabels); | |
1178 | continue; | |
1179 | } | |
1180 | Styles.ClearStyles(); | |
1181 | ||
1182 | // get a target shape and try to find corresponding context | |
1183 | // (all the colors set under that label will be put into that context) | |
1184 | TopoDS_Shape S; | |
1185 | if ( ! XCAFDoc_ShapeTool::GetShape ( L, S ) ) continue; | |
1186 | Standard_Boolean isComponent = aSTool->IsComponent( L ); | |
1187 | TopoDS_Shape aTopSh = S; | |
1188 | Handle(StepRepr_RepresentationContext) Context = Styles.FindContext ( S ); | |
1189 | if ( isComponent ) { | |
1190 | TDF_Label aTopShL = aSTool->FindShape(S, Standard_False); | |
1191 | if (aTopShL.IsNull()) | |
1192 | continue; | |
1193 | aTopSh = aSTool->GetShape( aTopShL ); | |
1194 | Context = Styles.FindContext ( aTopSh ); | |
1195 | } | |
1196 | if ( Context.IsNull() ) | |
1197 | continue; | |
1198 | ||
1199 | // collect settings set on that label | |
1200 | XCAFPrs_DataMapOfShapeStyle settings; | |
1201 | TDF_LabelSequence seq; | |
1202 | seq.Append ( L ); | |
1203 | XCAFDoc_ShapeTool::GetSubShapes ( L, seq ); | |
1204 | Standard_Boolean isVisible = Standard_True; | |
1205 | for ( Standard_Integer j = 1; j <= seq.Length(); j++ ) { | |
1206 | TDF_Label lab = seq.Value(j); | |
1207 | XCAFPrs_Style style; | |
1208 | Quantity_Color C; | |
574d7236 | 1209 | if ( lab == L ) { |
7fd59977 | 1210 | // check for invisible status of object on label |
1211 | if ( !CTool->IsVisible( lab ) ) { | |
1212 | isVisible = Standard_False; | |
1213 | style.SetVisibility( Standard_False ); | |
1214 | } | |
1215 | } | |
1216 | if ( CTool->GetColor ( lab, XCAFDoc_ColorGen, C ) ) { | |
ec99ba32 G |
1217 | style.SetColorCurv ( C ); |
1218 | style.SetColorSurf ( C ); | |
7fd59977 | 1219 | } |
1220 | if ( CTool->GetColor ( lab, XCAFDoc_ColorSurf, C ) ) | |
ec99ba32 | 1221 | style.SetColorSurf ( C ); |
7fd59977 | 1222 | if ( CTool->GetColor ( lab, XCAFDoc_ColorCurv, C ) ) |
ec99ba32 G |
1223 | style.SetColorCurv ( C ); |
1224 | ||
7fd59977 | 1225 | // commented, cause we are need to take reference from |
1226 | // if ( isComponent && lab == L && !isVisible) | |
1227 | // if ( !style.IsSetColorSurf() && !style.IsSetColorCurv() ) { | |
1228 | // getFatherColor ( L, CTool, style); | |
1229 | // } | |
1230 | if ( ! style.IsSetColorCurv() && ! style.IsSetColorSurf() && isVisible ) continue; | |
1231 | ||
1232 | TopoDS_Shape sub = XCAFDoc_ShapeTool::GetShape ( lab ); | |
1233 | settings.Bind ( sub, style ); | |
1234 | } | |
1235 | ||
1236 | if ( settings.Extent() <=0 ) continue; | |
1237 | ||
1238 | // iterate on subshapes and create STEP styles | |
1239 | Handle(StepVisual_StyledItem) override; | |
1240 | TopTools_MapOfShape Map; | |
1241 | ||
1242 | MakeSTEPStyles(Styles,S,settings,override,Map,myMapCompMDGPR,DPDCs,ColRGBs,CTool,0,isComponent); | |
1243 | ||
1244 | // create MDGPR and record it in model | |
1245 | Handle(StepVisual_MechanicalDesignGeometricPresentationRepresentation) aMDGPR; | |
1246 | ||
1247 | if (!isComponent) { | |
1248 | if ( myMapCompMDGPR.IsBound( aTopSh )) { | |
0797d9d3 | 1249 | #ifdef OCCT_DEBUG |
7fd59977 | 1250 | cerr << "Error: Current Top-Level shape have MDGPR already " << endl; |
1251 | #endif | |
1252 | } | |
1253 | Styles.CreateMDGPR ( Context, aMDGPR ); | |
1254 | if (!aMDGPR.IsNull()) | |
1255 | myMapCompMDGPR.Bind( aTopSh, aMDGPR ); | |
1256 | } | |
1257 | else { | |
1258 | // create SDR and add to model. | |
7f56eba8 | 1259 | const Handle(XSControl_TransferWriter) &TW = WS->TransferWriter(); |
1260 | const Handle(Transfer_FinderProcess) &FP = TW->FinderProcess(); | |
7fd59977 | 1261 | Handle(TransferBRep_ShapeMapper) mapper = TransferBRep::ShapeMapper ( FP, S ); |
1262 | Handle(StepShape_ContextDependentShapeRepresentation) CDSR; | |
1263 | if ( FP->FindTypedTransient(mapper, | |
1264 | STANDARD_TYPE(StepShape_ContextDependentShapeRepresentation), | |
1265 | CDSR) ) { | |
1266 | // create SDR for NAUO | |
1267 | Handle(StepRepr_ProductDefinitionShape) nullPDS; // important to be NULL | |
1268 | Styles.CreateNAUOSRD( Context, CDSR, nullPDS ); | |
1269 | ||
1270 | // search for MDGPR of the component top-level shape | |
1271 | if ( myMapCompMDGPR.IsBound( aTopSh )) { | |
1272 | aMDGPR = Handle(StepVisual_MechanicalDesignGeometricPresentationRepresentation)::DownCast( myMapCompMDGPR.Find( aTopSh ) ); | |
1273 | } else { | |
1274 | aMDGPR = new StepVisual_MechanicalDesignGeometricPresentationRepresentation; | |
1275 | Handle(TCollection_HAsciiString) ReprName = new TCollection_HAsciiString ( "" ); | |
1276 | aMDGPR->SetName( ReprName ); | |
1277 | aMDGPR->SetContextOfItems( Context ); | |
1278 | myMapCompMDGPR.Bind ( aTopSh, aMDGPR ); | |
1279 | } | |
1280 | Handle(StepRepr_HArray1OfRepresentationItem) oldItems = aMDGPR->Items(); | |
1281 | Standard_Integer oldLengthlen = 0; | |
1282 | if (!oldItems.IsNull()) | |
1283 | oldLengthlen = oldItems->Length(); | |
1284 | const Standard_Integer nbIt = oldLengthlen + Styles.NbStyles(); | |
1285 | if(!nbIt) | |
1286 | continue; | |
1287 | Handle(StepRepr_HArray1OfRepresentationItem) newItems = | |
1288 | new StepRepr_HArray1OfRepresentationItem(1, nbIt); | |
1289 | Standard_Integer si; | |
1290 | Standard_Integer el = 1; | |
1291 | for ( si=1; si <= oldLengthlen; si++ ) | |
1292 | newItems->SetValue( el++, oldItems->Value( si ) ); | |
1293 | for ( si=1; si <= Styles.NbStyles(); si++ ) { | |
a9dde4a3 | 1294 | newItems->SetValue( el++, Styles.Style(si)); |
7fd59977 | 1295 | } |
574d7236 | 1296 | |
7fd59977 | 1297 | if (newItems->Length() > 0) |
1298 | aMDGPR->SetItems( newItems ); | |
1299 | } //end of work with CDSR | |
1300 | } | |
574d7236 | 1301 | if ( !isVisible ) { |
1302 | // create invisibility item and refer for stiledItem | |
1303 | Handle(StepVisual_Invisibility) Invsblt = new StepVisual_Invisibility(); | |
1304 | Handle(StepVisual_HArray1OfInvisibleItem) HInvsblItm = | |
1305 | new StepVisual_HArray1OfInvisibleItem (1,Styles.NbStyles()); | |
1306 | // put all style item into the harray | |
1307 | for ( Standard_Integer si=1; si <= Styles.NbStyles(); si++ ) { | |
a9dde4a3 | 1308 | Handle(StepRepr_RepresentationItem) styledItm = Styles.Style(si); |
574d7236 | 1309 | StepVisual_InvisibleItem anInvItem; |
1310 | anInvItem.SetValue( styledItm ); | |
1311 | HInvsblItm->SetValue( si, anInvItem ); | |
1312 | } | |
1313 | // set the invisibility of items | |
1314 | Invsblt->Init( HInvsblItm ); | |
1315 | WS->Model()->AddWithRefs( Invsblt ); | |
1316 | } | |
7fd59977 | 1317 | } |
1318 | ||
1319 | return Standard_True; | |
1320 | } | |
1321 | ||
1322 | ||
1323 | //======================================================================= | |
1324 | //function : WriteNames | |
1325 | //purpose : | |
1326 | //======================================================================= | |
1327 | ||
1328 | Standard_Boolean STEPCAFControl_Writer::WriteNames (const Handle(XSControl_WorkSession) &WS, | |
1329 | const TDF_LabelSequence &labels) const | |
1330 | { | |
1331 | if ( labels.Length() <=0 ) return Standard_False; | |
1332 | ||
1333 | // get working data | |
7f56eba8 | 1334 | const Handle(XSControl_TransferWriter) &TW = WS->TransferWriter(); |
1335 | const Handle(Transfer_FinderProcess) &FP = TW->FinderProcess(); | |
7fd59977 | 1336 | |
1337 | // Iterate on requested shapes | |
1338 | for ( Standard_Integer i=1; i <= labels.Length(); i++ ) { | |
1339 | TDF_Label L = labels.Value(i); | |
1340 | ||
1341 | // get name | |
1342 | Handle(TCollection_HAsciiString) hName = new TCollection_HAsciiString; | |
1343 | if ( ! GetLabelName (L, hName) ) continue; | |
1344 | // Handle(TDataStd_Name) N; | |
1345 | // if ( ! L.FindAttribute ( TDataStd_Name::GetID(), N ) ) continue; | |
1346 | // TCollection_ExtendedString name = N->Get(); | |
1347 | // if ( name.Length() <=0 ) continue; | |
1348 | ||
1349 | // find target STEP entity for the current shape | |
1350 | // TopoDS_Shape S; | |
1351 | // if ( ! XCAFDoc_ShapeTool::GetShape ( L, S ) ) continue; | |
1352 | if ( ! myLabels.IsBound ( L ) ) continue; // not recorded as translated, skip | |
1353 | TopoDS_Shape S = myLabels.Find ( L ); | |
1354 | ||
1355 | Handle(StepShape_ShapeDefinitionRepresentation) SDR; | |
1356 | Handle(TransferBRep_ShapeMapper) mapper = TransferBRep::ShapeMapper ( FP, S ); | |
1357 | if ( ! FP->FindTypedTransient ( mapper, STANDARD_TYPE(StepShape_ShapeDefinitionRepresentation), SDR ) ) { | |
0797d9d3 | 1358 | #ifdef OCCT_DEBUG |
7fd59977 | 1359 | cout << "Warning: Cannot find SDR for " << S.TShape()->DynamicType()->Name() << endl; |
1360 | #endif | |
1361 | continue; | |
1362 | } | |
1363 | ||
1364 | // set the name to the PRODUCT | |
1365 | Handle(StepRepr_PropertyDefinition) PropD = SDR->Definition().PropertyDefinition(); | |
1366 | if ( PropD.IsNull() ) continue; | |
1367 | Handle(StepBasic_ProductDefinition) PD = PropD->Definition().ProductDefinition(); | |
1368 | if ( PD.IsNull() ) continue; | |
1369 | Handle(StepBasic_Product) Prod = PD->Formation()->OfProduct(); | |
1370 | ||
1371 | Prod->SetId ( hName ); | |
1372 | Prod->SetName ( hName ); | |
1373 | ||
1374 | // write names for components of assemblies | |
1375 | if ( XCAFDoc_ShapeTool::IsAssembly ( L ) ) { | |
1376 | TDF_LabelSequence seq; | |
1377 | XCAFDoc_ShapeTool::GetComponents ( L, seq ); | |
1378 | for (Standard_Integer k=1; k <= seq.Length(); k++) { | |
1379 | TDF_Label lab = seq(k); | |
1380 | ||
1381 | // get shape with correct location | |
1382 | TDF_Label Lref; | |
1383 | if ( ! XCAFDoc_ShapeTool::GetReferredShape ( lab, Lref ) || | |
1384 | ! myLabels.IsBound ( Lref ) ) continue; | |
1385 | S = myLabels.Find ( Lref ); | |
1386 | S.Move ( XCAFDoc_ShapeTool::GetLocation ( lab ) ); | |
1387 | ||
1388 | hName = new TCollection_HAsciiString; | |
1389 | if ( ! GetLabelName (lab, hName) ) continue; | |
1390 | ||
1391 | // find the target CDSR corresponding to a shape | |
1392 | mapper = TransferBRep::ShapeMapper ( FP, S ); | |
1393 | Handle(Transfer_Binder) binder = FP->Find ( mapper ); | |
1394 | Handle(StepShape_ContextDependentShapeRepresentation) CDSR; | |
1395 | if ( ! FP->FindTypedTransient (mapper,STANDARD_TYPE(StepShape_ContextDependentShapeRepresentation), CDSR) ) | |
1396 | continue; | |
1397 | Handle(StepRepr_ProductDefinitionShape) PDS = CDSR->RepresentedProductRelation(); | |
1398 | Handle(StepBasic_ProductDefinitionRelationship) NAUO = PDS->Definition().ProductDefinitionRelationship(); | |
1399 | if ( ! NAUO.IsNull() ) NAUO->SetName ( hName ); | |
1400 | } | |
1401 | } | |
1402 | } | |
1403 | ||
1404 | return Standard_True; | |
1405 | } | |
1406 | ||
1407 | ||
1408 | //======================================================================= | |
1409 | //function : WritePropsForLabel | |
1410 | //purpose : | |
1411 | //======================================================================= | |
1412 | static Standard_Boolean WritePropsForLabel(const Handle(XSControl_WorkSession) &WS, | |
1413 | const Handle(XCAFDoc_ShapeTool) &aSTool, | |
1414 | const STEPCAFControl_DataMapOfLabelShape &myLabels, | |
1415 | const TDF_Label &L, | |
1416 | const Standard_CString multi) | |
1417 | { | |
1418 | if(L.IsNull()) return Standard_False; | |
1419 | ||
1420 | STEPConstruct_ValidationProps Props ( WS ); | |
1421 | ||
1422 | TopoDS_Shape S = aSTool->GetShape(L); | |
1423 | if(S.IsNull()) return Standard_False; | |
1424 | ||
1425 | if ( ! multi || XCAFDoc_ShapeTool::IsAssembly ( L ) ) { | |
1426 | // write area | |
1427 | Handle(XCAFDoc_Area) A; | |
1428 | L.FindAttribute ( XCAFDoc_Area::GetID(), A ); | |
1429 | if ( ! A.IsNull() ) { | |
1430 | Props.AddArea ( S, A->Get() ); | |
1431 | } | |
1432 | // write volume | |
1433 | Handle(XCAFDoc_Volume) V; | |
1434 | L.FindAttribute ( XCAFDoc_Volume::GetID(), V ); | |
1435 | if ( ! V.IsNull() ) { | |
1436 | Props.AddVolume ( S, V->Get() ); | |
1437 | } | |
1438 | } | |
1439 | // write centroid | |
1440 | Handle(XCAFDoc_Centroid) C; | |
1441 | L.FindAttribute ( XCAFDoc_Centroid::GetID(), C ); | |
1442 | if ( ! C.IsNull() ) { | |
1443 | Props.AddCentroid ( S, C->Get() ); | |
1444 | } | |
1445 | ||
1446 | if( XCAFDoc_ShapeTool::IsCompound(L) || XCAFDoc_ShapeTool::IsAssembly(L) ) { | |
1447 | if(L.HasChild()) { | |
1448 | for(Standard_Integer ich=1; ich<=L.NbChildren(); ich++) { | |
1449 | WritePropsForLabel(WS,aSTool,myLabels,L.FindChild(ich),multi); | |
1450 | } | |
1451 | } | |
1452 | } | |
1453 | ||
1454 | return Standard_True; | |
1455 | } | |
1456 | ||
1457 | ||
1458 | //======================================================================= | |
1459 | //function : WriteValProps | |
1460 | //purpose : | |
1461 | //======================================================================= | |
1462 | ||
1463 | Standard_Boolean STEPCAFControl_Writer::WriteValProps (const Handle(XSControl_WorkSession) &WS, | |
1464 | const TDF_LabelSequence &labels, | |
1465 | const Standard_CString multi) const | |
1466 | { | |
1467 | if ( labels.Length() <=0 ) return Standard_False; | |
1468 | ||
1469 | // get working data | |
1470 | // STEPConstruct_ValidationProps Props ( WS ); | |
1471 | Handle(XCAFDoc_ShapeTool) aSTool = XCAFDoc_DocumentTool::ShapeTool( labels(1) ); | |
1472 | ||
1473 | // Iterate on requested shapes | |
1474 | for ( Standard_Integer i=1; i <= labels.Length(); i++ ) { | |
1475 | TDF_Label L = labels.Value(i); | |
1476 | ||
1477 | WritePropsForLabel(WS,aSTool,myLabels,L,multi); | |
1478 | /* | |
1479 | // find target STEP entity for the current shape | |
1480 | if ( ! myLabels.IsBound ( L ) ) continue; // not recorded as translated, skip | |
1481 | TopoDS_Shape S = myLabels.Find ( L ); | |
1482 | ||
1483 | // write area and volume (except for components in multifile mode) | |
1484 | if ( ! multi || XCAFDoc_ShapeTool::IsAssembly ( L ) ) { | |
1485 | Handle(XCAFDoc_Area) A; | |
1486 | L.FindAttribute ( XCAFDoc_Area::GetID(), A ); | |
1487 | if ( ! A.IsNull() ) Props.AddArea ( S, A->Get() ); | |
1488 | ||
1489 | Handle(XCAFDoc_Volume) V; | |
1490 | L.FindAttribute ( XCAFDoc_Volume::GetID(), V ); | |
1491 | if ( ! V.IsNull() ) Props.AddVolume ( S, V->Get() ); | |
1492 | } | |
1493 | ||
1494 | // write centroid | |
1495 | Handle(XCAFDoc_Centroid) C; | |
1496 | L.FindAttribute ( XCAFDoc_Centroid::GetID(), C ); | |
1497 | if ( ! C.IsNull() ) Props.AddCentroid ( S, C->Get() ); | |
1498 | ||
1499 | // write centroid for components of assemblies | |
1500 | if ( XCAFDoc_ShapeTool::IsAssembly ( L ) ) { | |
1501 | TDF_LabelSequence seq; | |
1502 | XCAFDoc_ShapeTool::GetComponents ( L, seq ); | |
1503 | for (Standard_Integer k=1; k <= seq.Length(); k++) { | |
1504 | TDF_Label lab = seq(k); | |
1505 | ||
1506 | // get shape with correct location | |
1507 | TDF_Label Lref; | |
1508 | if ( ! XCAFDoc_ShapeTool::GetReferredShape ( lab, Lref ) || | |
1509 | ! myLabels.IsBound ( Lref ) ) continue; | |
1510 | TopLoc_Location Loc = XCAFDoc_ShapeTool::GetLocation ( lab ); | |
1511 | S = myLabels.Find ( Lref ); | |
1512 | S.Move ( Loc ); | |
1513 | ||
1514 | C.Nullify(); | |
1515 | lab.FindAttribute ( XCAFDoc_Centroid::GetID(), C ); | |
1516 | // if centroid is not assigned to an instance, | |
1517 | // use (shifted) centroid of original shape | |
1518 | gp_Pnt center; | |
1519 | if ( C.IsNull() ) { | |
1520 | Lref.FindAttribute ( XCAFDoc_Centroid::GetID(), C ); | |
1521 | if ( C.IsNull() ) continue; | |
1522 | center = C->Get().Transformed ( Loc.Transformation() ); | |
1523 | } | |
1524 | else center = C->Get(); | |
1525 | ||
1526 | Props.AddCentroid ( S, center, Standard_True ); | |
1527 | } | |
1528 | } | |
1529 | */ | |
1530 | } | |
1531 | ||
1532 | return Standard_True; | |
1533 | } | |
1534 | ||
1535 | ||
1536 | //======================================================================= | |
1537 | //function : WriteLayers | |
1538 | //purpose : | |
1539 | //======================================================================= | |
1540 | ||
1541 | Standard_Boolean STEPCAFControl_Writer::WriteLayers (const Handle(XSControl_WorkSession) &WS, | |
1542 | const TDF_LabelSequence &labels ) const | |
1543 | { | |
1544 | ||
1545 | if ( labels.Length() <=0 ) return Standard_False; | |
1546 | ||
1547 | // get working data | |
7f56eba8 | 1548 | const Handle(Interface_InterfaceModel) &Model = WS->Model(); |
1549 | const Handle(XSControl_TransferWriter) &TW = WS->TransferWriter(); | |
1550 | const Handle(Transfer_FinderProcess) &FP = TW->FinderProcess(); | |
7fd59977 | 1551 | Handle(XCAFDoc_LayerTool) LTool = XCAFDoc_DocumentTool::LayerTool( labels(1) ); |
1552 | if (LTool.IsNull() ) return Standard_False; | |
1553 | ||
1554 | TDF_LabelSequence LayerLS; | |
1555 | LTool->GetLayerLabels(LayerLS); | |
1556 | if ( LayerLS.Length() <=0 ) return Standard_False; | |
1557 | ||
1558 | // Iterate on requested layers and for each layer take set of shapes. | |
1559 | for ( Standard_Integer i=1; i <= LayerLS.Length(); i++ ) { | |
1560 | TDF_Label L = LayerLS.Value(i); | |
1561 | ||
1562 | // get labels of shapes in that layer | |
1563 | TDF_LabelSequence ShapeLs; | |
1564 | LTool->GetShapesOfLayer(L, ShapeLs); | |
1565 | if ( ShapeLs.Length() <=0 ) continue; | |
1566 | ||
1567 | // name of layer: if not set, is considered as being empty | |
1568 | Handle(TCollection_HAsciiString) hName = new TCollection_HAsciiString; | |
1569 | GetLabelName ( L, hName ); | |
1570 | ||
1571 | // Find target STEP entity for each shape and add to StepVisual_PresentationLayerAssignment items. | |
1572 | TColStd_SequenceOfTransient seqRI; | |
1573 | for ( Standard_Integer j=1; j <= ShapeLs.Length(); j++) { | |
1574 | TDF_Label shLabel = ShapeLs.Value(j); | |
1575 | if ( shLabel.IsNull() ) continue; | |
1576 | ||
1577 | // there is no way to assign layer to instance in STEP | |
1578 | if ( XCAFDoc_ShapeTool::IsAssembly ( shLabel ) || | |
1579 | XCAFDoc_ShapeTool::IsReference ( shLabel ) ) | |
1580 | continue; | |
1581 | ||
1582 | // check that the shape is one of (uub)labels written during current transfer | |
1583 | Standard_Integer k = 1; | |
1584 | for ( ; k <= labels.Length(); k++ ) | |
1585 | if ( shLabel.IsDescendant ( labels(k) ) ) break; | |
1586 | if ( k > labels.Length() ) continue; | |
1587 | ||
1588 | // get target STEP entity | |
1589 | TopoDS_Shape oneShape = XCAFDoc_ShapeTool::GetShape(shLabel); | |
1590 | ||
1591 | TopLoc_Location Loc; | |
1592 | Standard_Integer nb = | |
1593 | FindEntities ( FP, oneShape, Loc, seqRI ); | |
1594 | if ( nb <=0 ) | |
1595 | FP->Messenger() << "Warning: Cannot find RI for " << oneShape.TShape()->DynamicType()->Name() << endl; | |
1596 | } | |
1597 | if ( seqRI.Length() <= 0 ) continue; | |
1598 | ||
1599 | // analyze visibility | |
1600 | Handle(StepVisual_PresentationLayerAssignment) StepLayerAs = new StepVisual_PresentationLayerAssignment; | |
1601 | Handle(TCollection_HAsciiString) descr; | |
1602 | Handle(TDataStd_UAttribute) aUAttr; | |
1603 | Standard_Boolean isLinv = Standard_False; | |
1604 | if (L.FindAttribute(XCAFDoc::InvisibleGUID(), aUAttr)) { | |
1605 | descr = new TCollection_HAsciiString ("invisible"); | |
0797d9d3 | 1606 | #ifdef OCCT_DEBUG |
7fd59977 | 1607 | FP->Messenger() << "\tLayer \"" << hName->String().ToCString() << "\" is invisible"<<endl; |
1608 | #endif | |
1609 | isLinv = Standard_True; | |
1610 | } | |
1611 | else descr = new TCollection_HAsciiString ("visible"); | |
1612 | ||
1613 | // create layer entity | |
1614 | Handle(StepVisual_HArray1OfLayeredItem) HArrayOfLItem = | |
1615 | new StepVisual_HArray1OfLayeredItem ( 1, seqRI.Length() ); | |
1616 | for (Standard_Integer i1 = 1; i1<=seqRI.Length(); i1++) { | |
1617 | StepVisual_LayeredItem LI; | |
1618 | LI.SetValue ( seqRI.Value(i1) ); | |
1619 | HArrayOfLItem->SetValue( i1, LI ); | |
1620 | } | |
1621 | StepLayerAs->Init(hName, descr, HArrayOfLItem); | |
1622 | Model->AddWithRefs( StepLayerAs ); | |
1623 | // PTV 23.01.2003 add the invisibility AFTER adding layer into the model. | |
1624 | // add the invisibility for the layer | |
1625 | if (isLinv) { | |
1626 | // Invisibility Item for containig invisible layers. | |
1627 | Handle(StepVisual_HArray1OfInvisibleItem) HInvsblItm = new StepVisual_HArray1OfInvisibleItem (1,1); | |
1628 | StepVisual_InvisibleItem InvIt; | |
1629 | InvIt.SetValue( StepLayerAs ); | |
1630 | HInvsblItm->SetValue( 1, InvIt); | |
1631 | ||
1632 | Handle(StepVisual_Invisibility) Invsblt = new StepVisual_Invisibility(); | |
1633 | Invsblt->Init( HInvsblItm ); | |
1634 | Model->AddWithRefs( Invsblt ); | |
1635 | } | |
1636 | } | |
1637 | return Standard_True; | |
1638 | } | |
1639 | ||
1640 | ||
1641 | //======================================================================= | |
1642 | //function : getSHUOstyle | |
1643 | //purpose : auxilary | |
1644 | //======================================================================= | |
1645 | static Standard_Boolean getSHUOstyle(const TDF_Label& aSHUOlab, | |
1646 | const Handle(XCAFDoc_ColorTool)& CTool, | |
1647 | XCAFPrs_Style& SHUOstyle) | |
1648 | { | |
1649 | Quantity_Color C; | |
1650 | if (!CTool->IsVisible( aSHUOlab ) ) | |
1651 | SHUOstyle.SetVisibility(Standard_False); | |
1652 | else { | |
1653 | if ( CTool->GetColor ( aSHUOlab, XCAFDoc_ColorGen, C ) ) { | |
1654 | SHUOstyle.SetColorCurv ( C ); | |
1655 | SHUOstyle.SetColorSurf ( C ); | |
1656 | } | |
1657 | if ( CTool->GetColor ( aSHUOlab, XCAFDoc_ColorSurf, C ) ) | |
1658 | SHUOstyle.SetColorSurf ( C ); | |
1659 | if ( CTool->GetColor ( aSHUOlab, XCAFDoc_ColorCurv, C ) ) | |
1660 | SHUOstyle.SetColorCurv ( C ); | |
1661 | } | |
1662 | if ( !SHUOstyle.IsSetColorCurv() && | |
1663 | !SHUOstyle.IsSetColorSurf() && | |
1664 | SHUOstyle.IsVisible() ) | |
1665 | return Standard_False; | |
1666 | return Standard_True; | |
1667 | } | |
1668 | ||
1669 | ||
1670 | //======================================================================= | |
1671 | //function : getProDefinitionOfNAUO | |
1672 | //purpose : auxilary | |
1673 | //======================================================================= | |
1674 | static Standard_Boolean getProDefinitionOfNAUO(const Handle(XSControl_WorkSession)& WS, | |
1675 | const TopoDS_Shape& theShape, | |
1676 | Handle(StepBasic_ProductDefinition)& PD, | |
1677 | Handle(StepRepr_NextAssemblyUsageOccurrence)& NAUO, | |
1678 | Standard_Boolean IsRelating) | |
1679 | { | |
1680 | if ( theShape.IsNull() ) | |
1681 | return Standard_False; | |
1682 | // get CDSR | |
7f56eba8 | 1683 | const Handle(XSControl_TransferWriter) &TW = WS->TransferWriter(); |
1684 | const Handle(Transfer_FinderProcess) &FP = TW->FinderProcess(); | |
7fd59977 | 1685 | Handle(StepShape_ContextDependentShapeRepresentation) CDSR; |
1686 | Handle(TransferBRep_ShapeMapper) mapper = TransferBRep::ShapeMapper ( FP, theShape ); | |
1687 | if (!FP->FindTypedTransient(mapper, | |
1688 | STANDARD_TYPE(StepShape_ContextDependentShapeRepresentation), | |
1689 | CDSR)) | |
1690 | return Standard_False; | |
1691 | // get PDS of NAUO | |
1692 | Handle(StepRepr_ProductDefinitionShape) PDS = CDSR->RepresentedProductRelation(); | |
1693 | if (PDS.IsNull()) | |
1694 | return Standard_False; | |
1695 | // get the NAUO entity | |
1696 | Interface_Graph aGraph = WS->HGraph()->Graph(); | |
1697 | Interface_EntityIterator subs = aGraph.Shareds(PDS); | |
1698 | for ( subs.Start(); subs.More(); subs.Next() ) { | |
1699 | if (!subs.Value()->IsKind(STANDARD_TYPE(StepRepr_NextAssemblyUsageOccurrence))) | |
1700 | continue; | |
1701 | NAUO = Handle(StepRepr_NextAssemblyUsageOccurrence)::DownCast(subs.Value()); | |
1702 | break; | |
1703 | } | |
1704 | if ( NAUO.IsNull() ) | |
1705 | return Standard_False; | |
1706 | // get Relatinf or Related product definition | |
1707 | if ( !IsRelating ) | |
1708 | PD = NAUO->RelatedProductDefinition(); | |
1709 | else | |
1710 | PD = NAUO->RelatingProductDefinition(); | |
1711 | if ( PD.IsNull() ) | |
1712 | return Standard_False; | |
1713 | return Standard_True; | |
1714 | } | |
1715 | ||
1716 | ||
1717 | //======================================================================= | |
1718 | //function : writeSHUO | |
1719 | //purpose : auxilary | |
1720 | //======================================================================= | |
1721 | static Standard_Boolean writeSHUO (const Handle(XCAFDoc_GraphNode)& theSHUO, | |
1722 | const Handle(XCAFDoc_ShapeTool)& theSTool, | |
1723 | const Handle(XSControl_WorkSession)& WS, | |
1724 | Handle(StepRepr_SpecifiedHigherUsageOccurrence)& theTopSHUO, | |
1725 | TopoDS_Shape& NAUOShape, | |
1726 | Handle(StepBasic_ProductDefinition)& theRelatingPD, | |
1727 | Standard_Boolean& isDeepest) | |
1728 | { | |
1729 | // set the ProductDefinitionRelationship descriptin information as empty strings. | |
1730 | Handle(TCollection_HAsciiString) EmptyString = new TCollection_HAsciiString(""); | |
1731 | ||
1732 | TDF_LabelSequence aNextUsageLabs; | |
1733 | theSTool->GetSHUONextUsage( theSHUO->Label(), aNextUsageLabs ); | |
1734 | Handle(XCAFDoc_GraphNode) NuSHUO; | |
1735 | if ( theTopSHUO.IsNull() ) { | |
1736 | // the top SHUO | |
1737 | if (aNextUsageLabs.Length() < 1) | |
1738 | return Standard_False; | |
1739 | theSTool->GetSHUO( aNextUsageLabs.Value(1), NuSHUO ); | |
1740 | if (NuSHUO.IsNull()) | |
1741 | return Standard_False; | |
1742 | // get relating product definition | |
1743 | TopoDS_Shape aTopCompShape = theSTool->GetShape( theSHUO->Label().Father() ); | |
1744 | Handle(StepRepr_NextAssemblyUsageOccurrence) UUNAUO; | |
1745 | if (!getProDefinitionOfNAUO( WS, aTopCompShape, | |
1746 | theRelatingPD, UUNAUO, Standard_True )) | |
1747 | return Standard_False; | |
1748 | // get related product definition | |
1749 | TopoDS_Shape aNUShape = theSTool->GetShape( NuSHUO->Label().Father() ); | |
1750 | Handle(StepBasic_ProductDefinition) aRelatedPD; | |
1751 | Handle(StepRepr_NextAssemblyUsageOccurrence) NUNAUO; | |
1752 | if (!getProDefinitionOfNAUO( WS, aNUShape, | |
1753 | aRelatedPD, NUNAUO, Standard_False )) | |
1754 | return Standard_False; | |
1755 | ||
1756 | theTopSHUO = new StepRepr_SpecifiedHigherUsageOccurrence; | |
1757 | // create deepest shuo EmptyString | |
1758 | theTopSHUO->Init(/*id*/EmptyString, /*name*/EmptyString, | |
1759 | /*no description*/Standard_False,/*description*/EmptyString, | |
1760 | theRelatingPD, aRelatedPD, | |
1761 | /*no ACURefDesignator*/Standard_False,/*ACURefDesignator*/EmptyString, | |
1762 | /*upper_usage*/UUNAUO, /*next_usage*/NUNAUO); | |
1763 | // write the other SHUO. | |
1764 | if(!writeSHUO( NuSHUO, theSTool, WS, theTopSHUO, NAUOShape, theRelatingPD, isDeepest )) { | |
1765 | theTopSHUO.Nullify(); | |
1766 | return Standard_False; | |
1767 | } | |
1768 | ||
1769 | return Standard_True; | |
1770 | } | |
1771 | // Handle(XCAFDoc_GraphNode) NuSHUO; | |
1772 | if ( aNextUsageLabs.Length() > 0) { | |
1773 | // store SHUO recursive | |
0797d9d3 | 1774 | #ifdef OCCT_DEBUG |
7fd59977 | 1775 | if ( aNextUsageLabs.Length() > 1 ) |
1776 | cout << "Warning: store only one next_usage of current SHUO" << endl; | |
1777 | #endif | |
1778 | theSTool->GetSHUO( aNextUsageLabs.Value(1), NuSHUO ); | |
1779 | Handle(StepRepr_SpecifiedHigherUsageOccurrence) aNUEntSHUO = | |
1780 | new StepRepr_SpecifiedHigherUsageOccurrence; | |
1781 | if (!writeSHUO( NuSHUO, theSTool, WS, aNUEntSHUO, NAUOShape, theRelatingPD, isDeepest )) | |
1782 | return Standard_False; | |
1783 | ||
1784 | // store the deepest SHUO to the dociment | |
1785 | TopoDS_Shape aNUSh, aUUSh; | |
1786 | aNUSh = theSTool->GetShape( NuSHUO->Label().Father() ); | |
1787 | aUUSh = theSTool->GetShape( theSHUO->Label().Father() ); | |
1788 | // get relating PD with upper_usage and related PD with next_usage | |
1789 | Handle(StepBasic_ProductDefinition) nullPD;// no need to use,case have shared <theRelatingPD> | |
1790 | Handle(StepBasic_ProductDefinition) aRelatedPD; | |
1791 | Handle(StepRepr_NextAssemblyUsageOccurrence) UUNAUO, NUNAUO; | |
1792 | if (!getProDefinitionOfNAUO( WS, aUUSh, nullPD, UUNAUO, Standard_True ) || | |
1793 | !getProDefinitionOfNAUO( WS, aNUSh, aRelatedPD, NUNAUO, Standard_False )) { | |
0797d9d3 | 1794 | #ifdef OCCT_DEBUG |
7fd59977 | 1795 | cout << "Warning: cannot get related or relating PD" << endl; |
1796 | #endif | |
1797 | return Standard_False; | |
1798 | } | |
1799 | aNUEntSHUO->Init(/*id*/EmptyString, /*name*/EmptyString, | |
1800 | /*no description*/Standard_False,/*description*/EmptyString, | |
1801 | theRelatingPD, aRelatedPD, | |
1802 | /*no ACURefDesignator*/Standard_False,/*ACURefDesignator*/EmptyString, | |
1803 | /*upper_usage*/theTopSHUO, /*next_usage*/NUNAUO); | |
1804 | if ( isDeepest ) { | |
1805 | isDeepest = Standard_False; | |
1806 | } | |
1807 | WS->Model()->AddWithRefs ( aNUEntSHUO ); | |
1808 | return Standard_True; | |
1809 | } // end of recurse storing | |
1810 | ||
1811 | // get shape | |
1812 | TDF_Label aShapeL = theSHUO->Label().Father(); | |
1813 | NAUOShape = theSTool->GetShape( aShapeL ); | |
1814 | // return to the deepest level from SHUO shape level | |
1815 | // it is because SHUO is attribute on deep level and shape level. | |
1816 | isDeepest = Standard_True; | |
1817 | return Standard_True; | |
1818 | } | |
1819 | ||
1820 | ||
1821 | //======================================================================= | |
1822 | //function : createSHUOStyledItem | |
1823 | //purpose : auxilary | |
1824 | //======================================================================= | |
1825 | static Standard_Boolean createSHUOStyledItem (const XCAFPrs_Style& style, | |
1826 | const Handle(StepRepr_ProductDefinitionShape)& PDS, | |
1827 | const Handle(XSControl_WorkSession) &WS, | |
1828 | const TopoDS_Shape& Sh, | |
1829 | const Handle(XCAFDoc_ShapeTool)& STool, | |
1830 | MoniTool_DataMapOfShapeTransient& myMapCompMDGPR) | |
1831 | { | |
1832 | // create styled item for the indicated SHUO and store to the model | |
1833 | STEPConstruct_Styles Styles( WS ); | |
1834 | // translate colors to STEP | |
1835 | Handle(StepVisual_Colour) surfColor, curvColor; | |
1836 | if ( style.IsSetColorSurf() ) | |
1837 | surfColor = Styles.EncodeColor ( style.GetColorSurf() ); | |
1838 | if ( style.IsSetColorCurv() ) | |
1839 | curvColor = Styles.EncodeColor ( style.GetColorCurv() ); | |
1840 | Standard_Boolean isComponent = Standard_True;// cause need to get PSBC | |
1841 | Handle(StepRepr_RepresentationItem) item; | |
1842 | // set default color for invisible SHUO. | |
1843 | Standard_Boolean isSetDefaultColor = Standard_False; | |
1844 | if (surfColor.IsNull() && curvColor.IsNull() && !style.IsVisible() ) { | |
1845 | surfColor = Styles.EncodeColor ( Quantity_Color( 1, 1, 1, Quantity_TOC_RGB ) ); | |
1846 | isSetDefaultColor = Standard_True; | |
1847 | } | |
1848 | Handle(StepVisual_PresentationStyleAssignment) PSA = | |
1849 | Styles.MakeColorPSA ( item, surfColor, curvColor, isComponent ); | |
1850 | Handle(StepVisual_StyledItem) override; //null styled item | |
1851 | ||
1852 | // find the repr item of the shape | |
7f56eba8 | 1853 | const Handle(XSControl_TransferWriter) &TW = WS->TransferWriter(); |
1854 | const Handle(Transfer_FinderProcess) &FP = TW->FinderProcess(); | |
7fd59977 | 1855 | Handle(TransferBRep_ShapeMapper) mapper = TransferBRep::ShapeMapper ( FP, Sh ); |
1856 | Handle(StepShape_ContextDependentShapeRepresentation) CDSR; | |
1857 | FP->FindTypedTransient(mapper, | |
1858 | STANDARD_TYPE(StepShape_ContextDependentShapeRepresentation), | |
1859 | CDSR); | |
1860 | if ( CDSR.IsNull() ) | |
1861 | return Standard_False; | |
1862 | // find context | |
1863 | Handle(StepRepr_RepresentationContext) Context = Styles.FindContext( Sh ); | |
1864 | TopoDS_Shape aTopSh = Sh; | |
1865 | if (Context.IsNull()) { | |
1866 | TDF_Label aTopShL = STool->FindShape(Sh, Standard_False); | |
1867 | if (aTopShL.IsNull()) | |
1868 | return Standard_False; | |
1869 | aTopSh = STool->GetShape( aTopShL ); | |
1870 | Context = Styles.FindContext ( aTopSh ); | |
1871 | } | |
1872 | if (Context.IsNull()) | |
1873 | return Standard_False; | |
1874 | // get representation item of the shape | |
1875 | TopLoc_Location L; | |
1876 | TColStd_SequenceOfTransient seqRI; | |
1877 | FindEntities ( FP, Sh, L, seqRI ); | |
0797d9d3 | 1878 | #ifdef OCCT_DEBUG |
7fd59977 | 1879 | if ( seqRI.Length() <=0 ) |
1880 | FP->Messenger() << "Warning: Cannot find RI for " << Sh.TShape()->DynamicType()->Name() << endl; | |
1881 | #endif | |
1882 | item = Handle(StepRepr_RepresentationItem)::DownCast(seqRI(1)); | |
1883 | //get overridden styled item | |
1884 | getStyledItem(Sh,STool, Styles, override,myMapCompMDGPR); | |
1885 | ||
1886 | // get STEP STYLED ITEM | |
1887 | Handle(StepVisual_StyledItem) STEPstyle = Styles.AddStyle ( item, PSA, override ); | |
1888 | // create SR, SDR and all necessary references between them and ST, PDS, PSBC, GRC | |
1889 | Styles.CreateNAUOSRD( Context, CDSR, PDS ); | |
1890 | ||
1891 | // add step styled item of SHUO to the model | |
1892 | // do it by additing styled item to the MDGPR | |
1893 | if ( !aTopSh.IsNull() && !myMapCompMDGPR.IsBound( aTopSh ) ) { | |
1894 | // create MDGPR and record it in model | |
0797d9d3 | 1895 | #ifdef OCCT_DEBUG |
7fd59977 | 1896 | cout << "Warning: " << __FILE__ << ": Create new MDGPR for SHUO instance" << endl; |
1897 | #endif | |
1898 | Handle(StepVisual_MechanicalDesignGeometricPresentationRepresentation) aMDGPR; | |
1899 | Styles.CreateMDGPR ( Context, aMDGPR ); | |
1900 | if (!aMDGPR.IsNull()) | |
1901 | myMapCompMDGPR.Bind( aTopSh, aMDGPR ); | |
1902 | } | |
1903 | else if ( !aTopSh.IsNull() && myMapCompMDGPR.IsBound( aTopSh ) ) { | |
1904 | // get MDGPR of the top-level shape | |
1905 | Handle(StepVisual_PresentationRepresentation) aMDGPR = | |
1906 | Handle(StepVisual_PresentationRepresentation)::DownCast( myMapCompMDGPR.Find( aTopSh ) ); | |
1907 | // get old styled items to not lose it | |
1908 | Handle(StepRepr_HArray1OfRepresentationItem) oldItems = aMDGPR->Items(); | |
1909 | Standard_Integer oldLengthlen = 0; | |
1910 | if (!oldItems.IsNull()) | |
1911 | oldLengthlen = oldItems->Length(); | |
1912 | // create new array of styled items by an olds and new one | |
1913 | Handle(StepRepr_HArray1OfRepresentationItem) newItems = | |
1914 | new StepRepr_HArray1OfRepresentationItem(1, oldLengthlen + 1); | |
1915 | Standard_Integer si; | |
1916 | Standard_Integer el = 1; | |
1917 | for ( si=1; si <= oldLengthlen; si++ ) | |
1918 | newItems->SetValue( el++, oldItems->Value( si ) ); | |
a9dde4a3 | 1919 | newItems->SetValue (el++, STEPstyle); |
7fd59977 | 1920 | // init MDGPR be new array of styled items |
1921 | if (newItems->Length() > 0) | |
1922 | aMDGPR->SetItems( newItems ); | |
1923 | } | |
1924 | else { | |
1925 | WS->Model()->AddWithRefs ( STEPstyle ); // add as root to the model, but it is not good | |
0797d9d3 | 1926 | #ifdef OCCT_DEBUG |
7fd59977 | 1927 | cout << "Warning: " << __FILE__ << ": adds styled item of SHUO as root, casue cannot find MDGPR" << endl; |
1928 | #endif | |
1929 | } | |
1930 | // create invisibility item for the styled item | |
1931 | if ( !style.IsVisible() ) { | |
1932 | if (isSetDefaultColor) { | |
1933 | // try to set default color from top-level shape | |
1934 | ||
1935 | setDefaultInstanceColor(override, PSA); | |
1936 | } | |
1937 | // create invisibility item and refer for stiledItem | |
1938 | Handle(StepVisual_Invisibility) Invsblt = new StepVisual_Invisibility(); | |
1939 | Handle(StepVisual_HArray1OfInvisibleItem) HInvsblItm = | |
1940 | new StepVisual_HArray1OfInvisibleItem (1,1); | |
1941 | // put all style item into the harray | |
1942 | StepVisual_InvisibleItem anInvItem; | |
1943 | anInvItem.SetValue( STEPstyle ); | |
1944 | HInvsblItm->SetValue( 1, anInvItem ); | |
1945 | Invsblt->Init( HInvsblItm ); | |
1946 | WS->Model()->AddWithRefs( Invsblt ); | |
1947 | } | |
1948 | ||
1949 | return Standard_True; | |
1950 | } | |
1951 | ||
1952 | ||
1953 | //======================================================================= | |
1954 | //function : WriteSHUOs | |
1955 | //purpose : | |
1956 | //======================================================================= | |
1957 | ||
1958 | Standard_Boolean STEPCAFControl_Writer::WriteSHUOs (const Handle(XSControl_WorkSession) &WS, | |
1959 | const TDF_LabelSequence &labels ) | |
1960 | { | |
1961 | if ( labels.Length() <=0 ) return Standard_False; | |
1962 | ||
1963 | // get working data | |
7fd59977 | 1964 | Handle(XCAFDoc_ColorTool) CTool = XCAFDoc_DocumentTool::ColorTool( labels(1) ); |
1965 | if (CTool.IsNull() ) | |
1966 | return Standard_False; | |
1967 | // map of transfered SHUO | |
1968 | TColStd_MapOfTransient aMapOfMainSHUO; | |
7fd59977 | 1969 | // Iterate on requested shapes |
1970 | for ( Standard_Integer i=1; i <= labels.Length(); i++ ) { | |
1971 | TDF_Label L = labels.Value(i); | |
1972 | if ( ! myLabels.IsBound ( L ) ) continue; // not recorded as translated, skip | |
7fd59977 | 1973 | if ( XCAFDoc_ShapeTool::IsAssembly ( L ) ) { |
1974 | TDF_LabelSequence seq; | |
1975 | XCAFDoc_ShapeTool::GetComponents ( L, seq ); | |
1976 | // iterates on components of assembly | |
1977 | for (Standard_Integer k=1; k <= seq.Length(); k++) { | |
1978 | TDF_Label lab = seq(k); | |
1979 | TDF_AttributeSequence anAttrSeq; | |
1980 | CTool->ShapeTool()->GetAllComponentSHUO( lab, anAttrSeq ); | |
1981 | // work with SHUO | |
1982 | for (Standard_Integer j = 1; j <= anAttrSeq.Length(); j++) { | |
1983 | Handle(XCAFDoc_GraphNode) aSHUO = | |
1984 | Handle(XCAFDoc_GraphNode)::DownCast(anAttrSeq.Value( j )); | |
1985 | // take label of SHUO | |
1986 | TDF_Label aSHUOlab = aSHUO->Label(); | |
1987 | TDF_LabelSequence aUpLabels; | |
1988 | // check is it SHUO of upper_usage | |
1989 | CTool->ShapeTool()->GetSHUOUpperUsage( aSHUOlab, aUpLabels ); | |
1990 | if ( aUpLabels.Length() > 0 ) | |
1991 | continue; // transfer only main SHUO | |
1992 | if ( aMapOfMainSHUO.Contains( aSHUO ) ) | |
1993 | continue; // do not try to transfer SHUO twice | |
1994 | aMapOfMainSHUO.Add( aSHUO ); | |
1995 | // check if it is styled SHUO | |
1996 | XCAFPrs_Style SHUOstyle; | |
1997 | if ( !getSHUOstyle ( aSHUOlab, CTool, SHUOstyle ) ) { | |
0797d9d3 | 1998 | #ifdef OCCT_DEBUG |
7fd59977 | 1999 | cout << "Warning: " << __FILE__ << ": do not store SHUO without any style to the STEP model" << endl; |
2000 | #endif | |
2001 | continue; | |
2002 | } | |
2003 | // write SHUO to the model amd then add structure type. | |
2004 | TopoDS_Shape NAUOShape; // shape of the deepest NAUO in the SHUO structure | |
2005 | Standard_Boolean isDeepest = Standard_False; | |
2006 | Handle(StepRepr_SpecifiedHigherUsageOccurrence) anEntOfSHUO; | |
2007 | Handle(StepBasic_ProductDefinition) aRelatingPD; | |
2008 | // create the top SHUO and all other. | |
2009 | writeSHUO( aSHUO, CTool->ShapeTool(), WS, anEntOfSHUO, NAUOShape, aRelatingPD, isDeepest ); | |
2010 | if ( anEntOfSHUO.IsNull() || NAUOShape.IsNull() ) { | |
0797d9d3 | 2011 | #ifdef OCCT_DEBUG |
7fd59977 | 2012 | cout << "Warning: " << __FILE__ << ": Cannot store SHUO" << endl; |
2013 | #endif | |
2014 | continue; | |
2015 | } | |
2016 | // create new Product Definition Shape for TOP SHUO | |
0797d9d3 | 2017 | #ifdef OCCT_DEBUG |
7fd59977 | 2018 | cout << "Info: " << __FILE__ << ": Create NEW PDS for current SHUO " << endl; |
2019 | #endif | |
2020 | Handle(StepRepr_ProductDefinitionShape) PDS = new StepRepr_ProductDefinitionShape; | |
2021 | Handle(TCollection_HAsciiString) aPDSname = new TCollection_HAsciiString("SHUO"); | |
2022 | Handle(TCollection_HAsciiString) descrStr = new TCollection_HAsciiString(""); | |
2023 | StepRepr_CharacterizedDefinition aCharDef; | |
2024 | aCharDef.SetValue( anEntOfSHUO ); | |
2025 | PDS->Init( aPDSname, Standard_False, descrStr, aCharDef ); | |
2026 | ||
2027 | // create styled item for SHUO and add to the model | |
2028 | createSHUOStyledItem ( SHUOstyle, PDS, WS, NAUOShape, CTool->ShapeTool(), myMapCompMDGPR ); | |
2029 | ||
2030 | } // end work with SHUO | |
2031 | } // end of an assembly components | |
2032 | } // end of IsAssembly case | |
2033 | // nothing to do if it is not assembly | |
2034 | continue; | |
2035 | } // end of iterates on indicated labels | |
2036 | return Standard_True; | |
2037 | } | |
2038 | ||
2039 | ||
2040 | //======================================================================= | |
2041 | //function : FindPDSforDGT | |
2042 | //purpose : auxilary: find PDS for AdvancedFace or EdgeCurve for creation | |
2043 | // needed ShapeAspect in D> structure | |
2044 | //======================================================================= | |
2045 | static Standard_Boolean FindPDSforDGT(const Interface_Graph &aGraph, | |
2046 | const Handle(Standard_Transient) &ent, | |
2047 | Handle(StepRepr_ProductDefinitionShape) &PDS, | |
2048 | Handle(StepRepr_RepresentationContext) &RC, | |
2049 | Handle(StepShape_AdvancedFace) &AF, | |
2050 | Handle(StepShape_EdgeCurve) &EC) | |
2051 | { | |
aff18753 | 2052 | if (ent.IsNull()) |
2053 | return Standard_False; | |
7fd59977 | 2054 | if( !ent->IsKind(STANDARD_TYPE(StepShape_EdgeCurve)) && |
2055 | !ent->IsKind(STANDARD_TYPE(StepShape_AdvancedFace)) ) | |
2056 | return Standard_False; | |
2057 | ||
2058 | AF = Handle(StepShape_AdvancedFace)::DownCast(ent); | |
aff18753 | 2059 | if( AF.IsNull() ) { |
7fd59977 | 2060 | EC = Handle(StepShape_EdgeCurve)::DownCast(ent); |
2061 | Interface_EntityIterator subs = aGraph.Sharings(EC); | |
2062 | for(subs.Start(); subs.More() && AF.IsNull(); subs.Next()) { | |
2063 | Handle(StepShape_OrientedEdge) OE = Handle(StepShape_OrientedEdge)::DownCast(subs.Value()); | |
2064 | if(OE.IsNull()) continue; | |
2065 | Interface_EntityIterator subs1 = aGraph.Sharings(OE); | |
2066 | for(subs1.Start(); subs1.More() && AF.IsNull(); subs1.Next()) { | |
2067 | Handle(StepShape_EdgeLoop) EL = Handle(StepShape_EdgeLoop)::DownCast(subs1.Value()); | |
2068 | if(EL.IsNull()) continue; | |
2069 | Interface_EntityIterator subs2 = aGraph.Sharings(EL); | |
2070 | for(subs2.Start(); subs2.More() && AF.IsNull(); subs2.Next()) { | |
2071 | Handle(StepShape_FaceBound) FB = Handle(StepShape_FaceBound)::DownCast(subs2.Value()); | |
2072 | if(FB.IsNull()) continue; | |
2073 | Interface_EntityIterator subs3 = aGraph.Sharings(FB); | |
2074 | for(subs3.Start(); subs3.More() && AF.IsNull(); subs3.Next()) { | |
2075 | AF = Handle(StepShape_AdvancedFace)::DownCast(subs3.Value()); | |
2076 | } | |
2077 | } | |
2078 | } | |
2079 | } | |
2080 | } | |
2081 | if(AF.IsNull()) return Standard_False; | |
2082 | ||
2083 | Interface_EntityIterator subs = aGraph.Sharings(AF); | |
2084 | for(subs.Start(); subs.More() && PDS.IsNull(); subs.Next()) { | |
2085 | Handle(StepShape_ConnectedFaceSet) CFS = | |
2086 | Handle(StepShape_ConnectedFaceSet)::DownCast(subs.Value()); | |
2087 | if(CFS.IsNull()) continue; | |
2088 | Interface_EntityIterator subs1 = aGraph.Sharings(CFS); | |
2089 | for(subs1.Start(); subs1.More() && PDS.IsNull(); subs1.Next()) { | |
2090 | Handle(StepRepr_RepresentationItem) RI = | |
2091 | Handle(StepRepr_RepresentationItem)::DownCast(subs1.Value()); | |
2092 | if(RI.IsNull()) continue; | |
2093 | Interface_EntityIterator subs2 = aGraph.Sharings(RI); | |
2094 | for(subs2.Start(); subs2.More() && PDS.IsNull(); subs2.Next()) { | |
2095 | Handle(StepShape_ShapeRepresentation) SR = | |
2096 | Handle(StepShape_ShapeRepresentation)::DownCast(subs2.Value()); | |
2097 | if(SR.IsNull()) continue; | |
2098 | RC = SR->ContextOfItems(); | |
2099 | Interface_EntityIterator subs3 = aGraph.Sharings(SR); | |
2100 | for(subs3.Start(); subs3.More() && PDS.IsNull(); subs3.Next()) { | |
2101 | Handle(StepShape_ShapeDefinitionRepresentation) SDR = | |
2102 | Handle(StepShape_ShapeDefinitionRepresentation)::DownCast(subs3.Value()); | |
2103 | if(SDR.IsNull()) continue; | |
2104 | Handle(StepRepr_PropertyDefinition) PropD = SDR->Definition().PropertyDefinition(); | |
2105 | if(PropD.IsNull()) continue; | |
2106 | PDS = Handle(StepRepr_ProductDefinitionShape)::DownCast(PropD); | |
2107 | } | |
2108 | } | |
2109 | } | |
2110 | } | |
2111 | ||
2112 | return Standard_True; | |
2113 | } | |
2114 | ||
43d3f6d8 | 2115 | //======================================================================= |
2116 | //function : FindPDS | |
2117 | //purpose : auxilary: find Product_definition_shape entity for given entity | |
2118 | //======================================================================= | |
2119 | static Handle(StepRepr_ProductDefinitionShape) FindPDS(const Interface_Graph &theGraph, | |
2120 | const Handle(Standard_Transient) &theEnt, | |
2121 | Handle(StepRepr_RepresentationContext) &theRC) | |
2122 | { | |
2123 | if (theEnt.IsNull()) | |
2124 | return NULL; | |
2125 | Handle(StepRepr_ProductDefinitionShape) aPDS; | |
2126 | ||
2127 | // try to find shape_representation in sharings | |
2128 | Interface_EntityIterator anIter = theGraph.Sharings(theEnt); | |
2129 | for (anIter.Start(); anIter.More() && aPDS.IsNull(); anIter.Next()) { | |
2130 | Handle(StepShape_ShapeRepresentation) aSR = Handle(StepShape_ShapeRepresentation)::DownCast(anIter.Value()); | |
2131 | if (aSR.IsNull()) | |
2132 | continue; | |
2133 | theRC = aSR->ContextOfItems(); | |
2134 | Interface_EntityIterator aSDRIt = theGraph.Sharings(aSR); | |
2135 | for (aSDRIt.Start(); aSDRIt.More() && aPDS.IsNull(); aSDRIt.Next()) { | |
2136 | Handle(StepShape_ShapeDefinitionRepresentation) aSDR = | |
2137 | Handle(StepShape_ShapeDefinitionRepresentation)::DownCast(aSDRIt.Value()); | |
2138 | if (aSDR.IsNull()) continue; | |
2139 | Handle(StepRepr_PropertyDefinition) aPropD = aSDR->Definition().PropertyDefinition(); | |
2140 | if (aPropD.IsNull()) continue; | |
2141 | aPDS = Handle(StepRepr_ProductDefinitionShape)::DownCast(aPropD); | |
2142 | } | |
2143 | } | |
2144 | if (!aPDS.IsNull()) | |
2145 | return aPDS; | |
2146 | ||
2147 | anIter = theGraph.Sharings(theEnt); | |
2148 | for (anIter.Start(); anIter.More(); anIter.Next()) { | |
2149 | if (anIter.Value()->IsKind(STANDARD_TYPE(StepShape_TopologicalRepresentationItem)) || | |
2150 | anIter.Value()->IsKind(STANDARD_TYPE(StepGeom_GeometricRepresentationItem))) | |
2151 | { | |
2152 | aPDS = FindPDS(theGraph, anIter.Value(), theRC); | |
2153 | if (!aPDS.IsNull()) | |
2154 | return aPDS; | |
2155 | } | |
2156 | } | |
2157 | ||
2158 | return aPDS; | |
2159 | } | |
2160 | ||
6595eee7 | 2161 | //======================================================================= |
2162 | //function : GetUnit | |
2163 | //purpose : auxiliary | |
2164 | //======================================================================= | |
6595eee7 | 2165 | static StepBasic_Unit GetUnit(const Handle(StepRepr_RepresentationContext)& theRC, |
2166 | const Standard_Boolean isAngle = Standard_False) | |
2167 | { | |
2168 | StepBasic_Unit aUnit; | |
2169 | if (isAngle) { | |
2170 | Handle(StepBasic_SiUnitAndPlaneAngleUnit) aSiPAU; | |
2171 | Handle(StepGeom_GeometricRepresentationContextAndGlobalUnitAssignedContext) aCtx = | |
2172 | Handle(StepGeom_GeometricRepresentationContextAndGlobalUnitAssignedContext)::DownCast(theRC); | |
2173 | if(!aCtx.IsNull()) { | |
2174 | for(Standard_Integer j = 1; j <= aCtx->NbUnits(); j++) { | |
2175 | if(aCtx->UnitsValue(j)->IsKind(STANDARD_TYPE(StepBasic_SiUnitAndPlaneAngleUnit))) { | |
2176 | aSiPAU = Handle(StepBasic_SiUnitAndPlaneAngleUnit)::DownCast(aCtx->UnitsValue(j)); | |
2177 | break; | |
2178 | } | |
2179 | } | |
2180 | } | |
2181 | if(aSiPAU.IsNull()) { | |
2182 | Handle(StepGeom_GeomRepContextAndGlobUnitAssCtxAndGlobUncertaintyAssCtx) aCtx1 = | |
2183 | Handle(StepGeom_GeomRepContextAndGlobUnitAssCtxAndGlobUncertaintyAssCtx)::DownCast(theRC); | |
2184 | if(!aCtx1.IsNull()) { | |
2185 | for(Standard_Integer j = 1; j <= aCtx1->NbUnits(); j++) { | |
2186 | if(aCtx1->UnitsValue(j)->IsKind(STANDARD_TYPE(StepBasic_SiUnitAndPlaneAngleUnit))) { | |
2187 | aSiPAU = Handle(StepBasic_SiUnitAndPlaneAngleUnit)::DownCast(aCtx1->UnitsValue(j)); | |
2188 | break; | |
2189 | } | |
2190 | } | |
2191 | } | |
2192 | } | |
2193 | if(aSiPAU.IsNull()) | |
2194 | aSiPAU = new StepBasic_SiUnitAndPlaneAngleUnit; | |
2195 | aUnit.SetValue(aSiPAU); | |
2196 | } | |
2197 | else { | |
2198 | Handle(StepBasic_SiUnitAndLengthUnit) aSiLU; | |
2199 | Handle(StepGeom_GeometricRepresentationContextAndGlobalUnitAssignedContext) aCtx = | |
2200 | Handle(StepGeom_GeometricRepresentationContextAndGlobalUnitAssignedContext)::DownCast(theRC); | |
2201 | if(!aCtx.IsNull()) { | |
2202 | for(Standard_Integer j = 1; j <= aCtx->NbUnits(); j++) { | |
2203 | if(aCtx->UnitsValue(j)->IsKind(STANDARD_TYPE(StepBasic_SiUnitAndLengthUnit))) { | |
2204 | aSiLU = Handle(StepBasic_SiUnitAndLengthUnit)::DownCast(aCtx->UnitsValue(j)); | |
2205 | break; | |
2206 | } | |
2207 | } | |
2208 | } | |
2209 | if(aSiLU.IsNull()) { | |
2210 | Handle(StepGeom_GeomRepContextAndGlobUnitAssCtxAndGlobUncertaintyAssCtx) aCtx1 = | |
2211 | Handle(StepGeom_GeomRepContextAndGlobUnitAssCtxAndGlobUncertaintyAssCtx)::DownCast(theRC); | |
2212 | if(!aCtx1.IsNull()) { | |
2213 | for(Standard_Integer j = 1; j <= aCtx1->NbUnits(); j++) { | |
2214 | if(aCtx1->UnitsValue(j)->IsKind(STANDARD_TYPE(StepBasic_SiUnitAndLengthUnit))) { | |
2215 | aSiLU = Handle(StepBasic_SiUnitAndLengthUnit)::DownCast(aCtx1->UnitsValue(j)); | |
2216 | break; | |
2217 | } | |
2218 | } | |
2219 | } | |
2220 | } | |
2221 | if(aSiLU.IsNull()) | |
2222 | aSiLU = new StepBasic_SiUnitAndLengthUnit; | |
2223 | aUnit.SetValue(aSiLU); | |
2224 | } | |
2225 | return aUnit; | |
2226 | } | |
2227 | ||
2228 | //======================================================================= | |
2229 | //function : CreateDimValue | |
2230 | //purpose : auxiliary | |
2231 | //====================================================================== | |
2232 | static Handle(StepRepr_ReprItemAndMeasureWithUnit) CreateDimValue(const Standard_Real theValue, | |
2233 | const StepBasic_Unit theUnit, | |
2234 | const Handle(TCollection_HAsciiString)& theName, | |
2235 | const Standard_CString theMeasureName, | |
2236 | const Standard_Boolean isAngle, | |
2237 | const Standard_Boolean isQualified = Standard_False, | |
2238 | const Handle(StepShape_QualifiedRepresentationItem)& theQRI = NULL) | |
2239 | { | |
2240 | Handle(StepRepr_RepresentationItem) aReprItem = new StepRepr_RepresentationItem(); | |
2241 | aReprItem->Init(new TCollection_HAsciiString(theName)); | |
2242 | Handle(StepBasic_MeasureWithUnit) aMWU = new StepBasic_MeasureWithUnit(); | |
2243 | Handle(StepBasic_MeasureValueMember) aValueMember = new StepBasic_MeasureValueMember(); | |
2244 | aValueMember->SetName(theMeasureName); | |
2245 | aValueMember->SetReal(theValue); | |
2246 | aMWU->Init(aValueMember, theUnit); | |
2247 | if (isQualified) { | |
2248 | if (isAngle) { | |
2249 | // Angle & with qualifiers | |
2250 | Handle(StepRepr_ReprItemAndPlaneAngleMeasureWithUnitAndQRI) anItem = | |
2251 | new StepRepr_ReprItemAndPlaneAngleMeasureWithUnitAndQRI(); | |
2252 | anItem->Init(aMWU, aReprItem, theQRI); | |
2253 | return anItem; | |
2254 | } | |
2255 | else { | |
2256 | // Length & with qualifiers | |
2257 | Handle(StepRepr_ReprItemAndLengthMeasureWithUnitAndQRI) anItem = | |
2258 | new StepRepr_ReprItemAndLengthMeasureWithUnitAndQRI(); | |
2259 | anItem->Init(aMWU, aReprItem, theQRI); | |
2260 | return anItem; | |
2261 | } | |
2262 | } | |
2263 | else { | |
2264 | if (isAngle) { | |
2265 | // Angle & without qualifiers | |
2266 | Handle(StepRepr_ReprItemAndPlaneAngleMeasureWithUnit) anItem = | |
2267 | new StepRepr_ReprItemAndPlaneAngleMeasureWithUnit(); | |
2268 | anItem->Init(aMWU, aReprItem); | |
2269 | return anItem; | |
2270 | } | |
2271 | else { | |
2272 | // Length & without qualifiers | |
2273 | Handle(StepRepr_ReprItemAndLengthMeasureWithUnit) anItem = | |
2274 | new StepRepr_ReprItemAndLengthMeasureWithUnit(); | |
2275 | anItem->Init(aMWU, aReprItem); | |
2276 | return anItem; | |
2277 | } | |
2278 | } | |
2279 | } | |
2280 | ||
2281 | //======================================================================= | |
2282 | //function : WriteShapeAspect | |
2283 | //purpose : auxiliary (write Shape_Aspect entity for given shape) | |
2284 | //======================================================================= | |
2285 | ||
1209c1b9 | 2286 | Handle(StepRepr_ShapeAspect) STEPCAFControl_Writer::WriteShapeAspect (const Handle(XSControl_WorkSession) &WS, |
2287 | const TDF_Label theLabel, | |
2288 | const TopoDS_Shape theShape, | |
2289 | Handle(StepRepr_RepresentationContext)& theRC, | |
2290 | Handle(StepAP242_GeometricItemSpecificUsage)& theGISU) | |
6595eee7 | 2291 | { |
2292 | // Get working data | |
7f56eba8 | 2293 | const Handle(Interface_InterfaceModel) &Model = WS->Model(); |
2294 | const Handle(XSControl_TransferWriter) &TW = WS->TransferWriter(); | |
2295 | const Handle(Transfer_FinderProcess) &FP = TW->FinderProcess(); | |
6595eee7 | 2296 | const Handle(Interface_HGraph) aHGraph = WS->HGraph(); |
2297 | if (aHGraph.IsNull()) | |
2298 | return NULL; | |
2299 | Interface_Graph aGraph = aHGraph->Graph(); | |
2300 | ||
2301 | TopLoc_Location aLoc; | |
2302 | TColStd_SequenceOfTransient aSeqRI; | |
2303 | FindEntities( FP, theShape, aLoc, aSeqRI ); | |
2304 | if ( aSeqRI.Length() <= 0 ) { | |
2305 | FP->Messenger() << "Warning: Cannot find RI for "<<theShape.TShape()->DynamicType()->Name()<<endl; | |
2306 | return NULL; | |
2307 | } | |
2308 | ||
2309 | Handle(StepRepr_ProductDefinitionShape) aPDS; | |
2310 | Handle(StepRepr_RepresentationContext) aRC; | |
2311 | Handle(Standard_Transient) anEnt = aSeqRI.Value(1); | |
43d3f6d8 | 2312 | aPDS = FindPDS(aGraph, anEnt, aRC); |
6595eee7 | 2313 | if(aPDS.IsNull()) |
2314 | return NULL; | |
2315 | ||
2316 | theRC = aRC; | |
2317 | // Shape_Aspect | |
2318 | Handle(TCollection_HAsciiString) aName = new TCollection_HAsciiString(); | |
2319 | Handle(TDataStd_Name) aNameAttr; | |
2320 | if (theLabel.FindAttribute(TDataStd_Name::GetID(), aNameAttr)) { | |
2321 | aName = new TCollection_HAsciiString(TCollection_AsciiString(aNameAttr->Get(), '?')); | |
2322 | Standard_Integer aFirstSpace = aName->Search(" "); | |
2323 | if (aFirstSpace != -1) | |
2324 | aName = aName->SubString(aFirstSpace + 1, aName->Length()); | |
2325 | else | |
2326 | aName = new TCollection_HAsciiString(); | |
2327 | } | |
2328 | Handle(TCollection_HAsciiString) aDescription = new TCollection_HAsciiString(); | |
2329 | Handle(StepRepr_ShapeAspect) aSA = new StepRepr_ShapeAspect; | |
2330 | aSA->Init(aName, aDescription, aPDS, StepData_LTrue); | |
2331 | ||
2332 | // Geometric_Item_Specific_Usage | |
2333 | Handle(StepAP242_GeometricItemSpecificUsage) aGISU = new StepAP242_GeometricItemSpecificUsage(); | |
2334 | StepAP242_ItemIdentifiedRepresentationUsageDefinition aDefinition; | |
2335 | aDefinition.SetValue(aSA); | |
2336 | Handle(StepRepr_HArray1OfRepresentationItem) anReprItems = new StepRepr_HArray1OfRepresentationItem(1, 1); | |
2337 | Handle(StepRepr_RepresentationItem) anIdentifiedItem = Handle(StepRepr_RepresentationItem)::DownCast(anEnt); | |
2338 | anReprItems->SetValue(1, anIdentifiedItem); | |
2339 | Interface_EntityIterator subs = aGraph.Sharings(aPDS); | |
2340 | Handle(StepShape_ShapeDefinitionRepresentation) aSDR; | |
2341 | for (subs.Start(); subs.More() && aSDR.IsNull(); subs.Next()) { | |
2342 | Handle(Standard_Transient) anEntity = subs.Value(); | |
2343 | aSDR = Handle(StepShape_ShapeDefinitionRepresentation)::DownCast(anEntity); | |
2344 | } | |
2345 | if (aSDR.IsNull()) | |
2346 | return NULL; | |
2347 | ||
2348 | // Set entities to model | |
2349 | aGISU->Init(aName, aDescription, aDefinition, aSDR->UsedRepresentation(), anReprItems); | |
2350 | Model->AddWithRefs(aSA); | |
2351 | Model->AddWithRefs(aGISU); | |
2352 | theGISU = aGISU; | |
2353 | return aSA; | |
2354 | } | |
2355 | ||
b0cef606 | 2356 | //======================================================================= |
2357 | //function : WritePresentation | |
2358 | //purpose : auxiliary (write annotation plane and presentation) | |
2359 | //====================================================================== | |
1209c1b9 | 2360 | void STEPCAFControl_Writer::WritePresentation(const Handle(XSControl_WorkSession) &WS, |
2361 | const TopoDS_Shape thePresentation, | |
2362 | const Handle(TCollection_HAsciiString)& thePrsName, | |
2363 | const Standard_Boolean hasSemantic, | |
2364 | const Standard_Boolean hasPlane, | |
2365 | const gp_Ax2 theAnnotationPlane, | |
2366 | const gp_Pnt theTextPosition, | |
2367 | const Handle(Standard_Transient) theDimension) | |
b0cef606 | 2368 | { |
2369 | if (thePresentation.IsNull()) | |
2370 | return; | |
2371 | // Get working data | |
7f56eba8 | 2372 | const Handle(Interface_InterfaceModel) &aModel = WS->Model(); |
b0cef606 | 2373 | |
2374 | // Presentation | |
2375 | Handle(StepVisual_TessellatedGeometricSet) aGeomSet = STEPCAFControl_GDTProperty::GetTessellation(thePresentation); | |
2376 | Handle(StepVisual_TessellatedAnnotationOccurrence) aTAO = new StepVisual_TessellatedAnnotationOccurrence(); | |
1209c1b9 | 2377 | aTAO->Init(new TCollection_HAsciiString(), myGDTPrsCurveStyle, aGeomSet); |
b0cef606 | 2378 | StepVisual_DraughtingCalloutElement aDCElement; |
2379 | aDCElement.SetValue(aTAO); | |
2380 | Handle(StepVisual_HArray1OfDraughtingCalloutElement) aTAOs = new StepVisual_HArray1OfDraughtingCalloutElement(1, 1); | |
2381 | aTAOs->SetValue(1, aDCElement); | |
2382 | Handle(StepVisual_DraughtingCallout) aDCallout = new StepVisual_DraughtingCallout(); | |
43d3f6d8 | 2383 | Handle(TCollection_HAsciiString) aPrsName = thePrsName.IsNull() ? new TCollection_HAsciiString() : thePrsName; |
2384 | aDCallout->Init(aPrsName, aTAOs); | |
b0cef606 | 2385 | Handle(StepRepr_HArray1OfRepresentationItem) aDCsForDMIA = new StepRepr_HArray1OfRepresentationItem(1, 1); |
2386 | aDCsForDMIA->SetValue(1, aDCallout); | |
1209c1b9 | 2387 | myGDTAnnotations.Append(aDCallout); |
b0cef606 | 2388 | StepAP242_ItemIdentifiedRepresentationUsageDefinition aDimension; |
2389 | aDimension.SetValue(theDimension); | |
1209c1b9 | 2390 | Handle(TCollection_HAsciiString) aDMIAName; |
2391 | if (hasSemantic) | |
2392 | aDMIAName = new TCollection_HAsciiString("PMI representation to presentation link"); | |
2393 | else | |
2394 | aDMIAName = new TCollection_HAsciiString(); | |
b0cef606 | 2395 | Handle(StepAP242_DraughtingModelItemAssociation) aDMIA = |
2396 | new StepAP242_DraughtingModelItemAssociation(); | |
1209c1b9 | 2397 | aDMIA->Init(aDMIAName, new TCollection_HAsciiString(), aDimension, myGDTPresentationDM, aDCsForDMIA); |
b0cef606 | 2398 | aModel->AddWithRefs(aDMIA); |
2399 | ||
1209c1b9 | 2400 | if (!hasPlane) |
2401 | return; | |
2402 | ||
b0cef606 | 2403 | // Annotation plane |
2404 | // Presentation Style | |
2405 | Handle(StepVisual_NullStyleMember) aNullStyle = new StepVisual_NullStyleMember(); | |
2406 | aNullStyle->SetEnumText(0, ".NULL."); | |
2407 | StepVisual_PresentationStyleSelect aStyleItem; | |
2408 | aStyleItem.SetValue(aNullStyle); | |
2409 | Handle(StepVisual_HArray1OfPresentationStyleSelect) aStyles = new StepVisual_HArray1OfPresentationStyleSelect(1, 1); | |
2410 | aStyles->SetValue(1, aStyleItem); | |
2411 | Handle(StepVisual_PresentationStyleAssignment) aPrsStyle = new StepVisual_PresentationStyleAssignment(); | |
2412 | aPrsStyle->Init(aStyles); | |
1209c1b9 | 2413 | Handle(StepVisual_HArray1OfPresentationStyleAssignment) aPrsStyles = |
b0cef606 | 2414 | new StepVisual_HArray1OfPresentationStyleAssignment(1, 1); |
2415 | aPrsStyles->SetValue(1, aPrsStyle); | |
2416 | // Plane | |
2417 | Handle(StepGeom_Plane) aPlane = new StepGeom_Plane(); | |
1603a497 | 2418 | GeomToStep_MakeAxis2Placement3d anAxisMaker(theAnnotationPlane); |
2419 | Handle(StepGeom_Axis2Placement3d) anAxis = anAxisMaker.Value(); | |
f0bf70e8 | 2420 | // Set text position to plane origin |
2421 | Handle(StepGeom_CartesianPoint) aTextPos = new StepGeom_CartesianPoint(); | |
2422 | Handle(TColStd_HArray1OfReal) aCoords = new TColStd_HArray1OfReal(1, 3); | |
2423 | for (Standard_Integer i = 1; i <= 3; i++) | |
2424 | aCoords->SetValue(i, theTextPosition.Coord(i)); | |
2425 | aTextPos->Init(new TCollection_HAsciiString(), aCoords); | |
2426 | anAxis->SetLocation(aTextPos); | |
b0cef606 | 2427 | aPlane->Init(new TCollection_HAsciiString(), anAxis); |
2428 | // Annotation plane element | |
2429 | StepVisual_AnnotationPlaneElement aPlaneElement; | |
2430 | aPlaneElement.SetValue(aDCallout); | |
2431 | Handle(StepVisual_HArray1OfAnnotationPlaneElement) aDCsForAnnPln = new StepVisual_HArray1OfAnnotationPlaneElement(1, 1); | |
2432 | aDCsForAnnPln->SetValue(1, aPlaneElement); | |
2433 | // Init AnnotationPlane entity | |
2434 | Handle(StepVisual_AnnotationPlane) anAnnPlane = new StepVisual_AnnotationPlane(); | |
2435 | anAnnPlane->Init(new TCollection_HAsciiString(), aPrsStyles, aPlane, aDCsForAnnPln); | |
1209c1b9 | 2436 | myGDTAnnotations.Append(anAnnPlane); |
0b622d67 | 2437 | aModel->AddWithRefs(anAnnPlane); |
2438 | } | |
2439 | ||
6595eee7 | 2440 | //======================================================================= |
2441 | //function : WriteDatumAP242 | |
2442 | //purpose : auxiliary (write Datum entity for given shape or write all | |
2443 | // necessary entities and link them to already written datum | |
2444 | // in case of multiple features association) | |
2445 | //======================================================================= | |
1209c1b9 | 2446 | Handle(StepDimTol_Datum) STEPCAFControl_Writer::WriteDatumAP242(const Handle(XSControl_WorkSession) &WS, |
2447 | const TDF_LabelSequence theShapeL, | |
2448 | const TDF_Label theDatumL, | |
2449 | const Standard_Boolean isFirstDTarget, | |
2450 | const Handle(StepDimTol_Datum) theWrittenDatum) | |
6595eee7 | 2451 | { |
2452 | // Get working data | |
7f56eba8 | 2453 | const Handle(Interface_InterfaceModel) &Model = WS->Model(); |
2454 | const Handle(XSControl_TransferWriter) &TW = WS->TransferWriter(); | |
2455 | const Handle(Transfer_FinderProcess) &FP = TW->FinderProcess(); | |
6595eee7 | 2456 | const Handle(Interface_HGraph) aHGraph = WS->HGraph(); |
2457 | if (aHGraph.IsNull()) | |
2458 | return NULL; | |
2459 | Interface_Graph aGraph = aHGraph->Graph(); | |
2460 | ||
2461 | Handle(StepRepr_ShapeAspect) aSA; | |
400af1bc | 2462 | Handle(StepRepr_RepresentationContext) aRC; |
2463 | Handle(StepRepr_ProductDefinitionShape) aPDS; | |
2464 | NCollection_Sequence<Handle(StepRepr_ShapeAspect)> aSASeq; | |
6595eee7 | 2465 | Handle(StepAP242_GeometricItemSpecificUsage) aGISU; |
400af1bc | 2466 | Standard_Integer aSANum = 0, aGISUNum = 0; |
6595eee7 | 2467 | // Link with datum feature |
400af1bc | 2468 | for (Standard_Integer i = 1; i <= theShapeL.Length(); i++) { |
2469 | Handle(Standard_Transient) anEnt; | |
2470 | TopoDS_Shape aShape; | |
2471 | TopLoc_Location aLoc; | |
2472 | TColStd_SequenceOfTransient aSeqRI; | |
2473 | ||
2474 | aShape = XCAFDoc_ShapeTool::GetShape(theShapeL.Value(i)); | |
2475 | FindEntities(FP, aShape, aLoc, aSeqRI); | |
2476 | if (aSeqRI.Length() <= 0) { | |
2477 | FP->Messenger() << "Warning: Cannot find RI for " << aShape.TShape()->DynamicType()->Name() << endl; | |
2478 | continue; | |
2479 | } | |
2480 | anEnt = aSeqRI.Value(1); | |
2481 | aPDS = FindPDS(aGraph, anEnt, aRC); | |
2482 | if (aPDS.IsNull()) | |
2483 | continue; | |
6595eee7 | 2484 | |
400af1bc | 2485 | Handle(StepRepr_ShapeAspect) aCurrentSA = WriteShapeAspect(WS, theDatumL, aShape, aRC, aGISU); |
2486 | if (aCurrentSA.IsNull()) | |
2487 | continue; | |
2488 | aSASeq.Append(aCurrentSA); | |
2489 | aSANum = Model->Number(aCurrentSA); | |
2490 | aGISUNum = Model->Number(aGISU); | |
2491 | } | |
2492 | if (aPDS.IsNull()) { | |
2493 | // Workaround for datums without shape | |
1209c1b9 | 2494 | aPDS = myGDTCommonPDS; |
400af1bc | 2495 | Interface_EntityIterator aSDRIt = aGraph.Sharings(aPDS); |
2496 | Handle(StepShape_ShapeDefinitionRepresentation) aSDR; | |
2497 | for (aSDRIt.Start(); aSDRIt.More() && aSDR.IsNull(); aSDRIt.Next()) | |
2498 | aSDR = Handle(StepShape_ShapeDefinitionRepresentation)::DownCast(aSDRIt.Value()); | |
2499 | if (!aSDR.IsNull()) { | |
2500 | Handle(StepRepr_Representation) aRepr = aSDR->UsedRepresentation(); | |
2501 | if (!aRepr.IsNull()) | |
2502 | aRC = aRepr->ContextOfItems(); | |
2503 | } | |
6595eee7 | 2504 | } |
6595eee7 | 2505 | |
400af1bc | 2506 | |
6595eee7 | 2507 | // Find if datum has datum targets and get common datum attributes |
2508 | Handle(XCAFDoc_Datum) aDatumAttr; | |
2509 | if (!theDatumL.FindAttribute(XCAFDoc_Datum::GetID(), aDatumAttr)) | |
2510 | return NULL; | |
2511 | Handle(XCAFDimTolObjects_DatumObject) anObject = aDatumAttr->GetObject(); | |
2512 | if (anObject.IsNull()) | |
2513 | return NULL; | |
2514 | Standard_Boolean isSimpleDatum = !anObject->IsDatumTarget(); | |
2515 | Handle(TCollection_HAsciiString) anIdentifier = anObject->GetName(); | |
2516 | Handle(TCollection_HAsciiString) aTargetId = (anObject->GetDatumTargetNumber() == 0 ? | |
2517 | new TCollection_HAsciiString() : new TCollection_HAsciiString(anObject->GetDatumTargetNumber())); | |
2518 | ||
2519 | // If datum type is area, but there is no area in object, write as simple datum | |
2520 | if (anObject->GetDatumTargetType() == XCAFDimTolObjects_DatumTargetType_Area && | |
2521 | anObject->GetDatumTarget().IsNull()) | |
2522 | isSimpleDatum = Standard_True; | |
2523 | ||
2524 | // Simple datum | |
2525 | if (isSimpleDatum) { | |
400af1bc | 2526 | if (aSASeq.Length() == 0) { |
2527 | // Create empty datum with name and presentation only | |
2528 | Handle(StepDimTol_DatumFeature) aDF = new StepDimTol_DatumFeature(); | |
2529 | aDF->Init(new TCollection_HAsciiString(), new TCollection_HAsciiString(), aPDS, StepData_LTrue); | |
2530 | aSA = aDF; | |
2531 | Model->AddWithRefs(aDF); | |
2532 | } | |
2533 | else if (aSASeq.Length() == 1) { | |
2534 | Handle(StepDimTol_DatumFeature) aDF = new StepDimTol_DatumFeature(); | |
2535 | aDF->Init(new TCollection_HAsciiString(), new TCollection_HAsciiString(), aPDS, StepData_LTrue); | |
2536 | Model->ReplaceEntity(aSANum, aDF); | |
2537 | aSA = aDF; | |
2538 | StepAP242_ItemIdentifiedRepresentationUsageDefinition aDefinition; | |
2539 | aDefinition.SetValue(aDF); | |
2540 | aGISU->SetDefinition(aDefinition); | |
2541 | Model->ReplaceEntity(aGISUNum, aGISU); | |
2542 | } | |
2543 | else if (aSASeq.Length() > 1) { | |
2544 | Handle(StepRepr_CompShAspAndDatumFeatAndShAsp) aDF = new StepRepr_CompShAspAndDatumFeatAndShAsp(); | |
2545 | aDF->Init(new TCollection_HAsciiString(), new TCollection_HAsciiString(), aPDS, StepData_LTrue); | |
2546 | for (Standard_Integer i = 1; i <= aSASeq.Length(); i++) { | |
2547 | Handle(StepRepr_ShapeAspectRelationship) aSAR = new StepRepr_ShapeAspectRelationship(); | |
2548 | aSAR->Init(new TCollection_HAsciiString(), Standard_False, new TCollection_HAsciiString(), aDF, aSASeq.Value(i)); | |
2549 | Model->AddWithRefs(aSAR); | |
2550 | } | |
2551 | aSA = aDF; | |
2552 | Model->AddWithRefs(aDF); | |
2553 | } | |
6595eee7 | 2554 | } |
2555 | // Datum with datum targets | |
2556 | else { | |
2557 | XCAFDimTolObjects_DatumTargetType aDatumType = anObject->GetDatumTargetType(); | |
2558 | Handle(StepDimTol_DatumTarget) aDatumTarget; | |
2559 | // Note: the given way to write such datum type may be incorrect (too little information) | |
2560 | if (aDatumType == XCAFDimTolObjects_DatumTargetType_Area) { | |
2561 | TopoDS_Shape aDTShape = anObject->GetDatumTarget(); | |
2562 | Handle(StepAP242_GeometricItemSpecificUsage) anAreaGISU; | |
2563 | Handle(StepRepr_ShapeAspect) anAreaSA = WriteShapeAspect(WS, theDatumL, aDTShape, aRC, anAreaGISU); | |
2564 | aSANum = Model->Number(anAreaSA); | |
2565 | aGISUNum = Model->Number(anAreaGISU); | |
2566 | Handle(StepDimTol_DatumTarget) aDT = new StepDimTol_DatumTarget(); | |
2567 | aDT->Init(new TCollection_HAsciiString(), new TCollection_HAsciiString("area"), anAreaSA->OfShape(), | |
400af1bc | 2568 | StepData_LTrue, aTargetId); |
6595eee7 | 2569 | Model->ReplaceEntity(aSANum, aDT); |
2570 | StepAP242_ItemIdentifiedRepresentationUsageDefinition aDefinition; | |
2571 | aDefinition.SetValue(aDT); | |
2572 | anAreaGISU->SetDefinition(aDefinition); | |
2573 | Model->ReplaceEntity(aGISUNum, anAreaGISU); | |
400af1bc | 2574 | } |
6595eee7 | 2575 | else { |
2576 | Handle(StepDimTol_PlacedDatumTargetFeature) aPDTF = new StepDimTol_PlacedDatumTargetFeature(); | |
727b5ad9 | 2577 | aPDTF->Init(new TCollection_HAsciiString(), STEPCAFControl_GDTProperty::GetDatumTargetName(aDatumType), |
6595eee7 | 2578 | aPDS, StepData_LTrue, aTargetId); |
2579 | Model->AddWithRefs(aPDTF); | |
2580 | aDatumTarget = aPDTF; | |
2581 | // Datum targets | |
2582 | Handle(StepRepr_PropertyDefinition) aPD = new StepRepr_PropertyDefinition(); | |
2583 | StepRepr_CharacterizedDefinition aCDefinition; | |
2584 | aCDefinition.SetValue(aPDTF); | |
2585 | aPD->Init(new TCollection_HAsciiString(), Standard_False, NULL, aCDefinition); | |
400af1bc | 2586 | if (anObject->HasDatumTargetParams()) { |
2587 | // write all parameters of datum target | |
2588 | Handle(StepShape_ShapeRepresentationWithParameters) aSRWP = new StepShape_ShapeRepresentationWithParameters(); | |
2589 | // Common for all datum targets | |
2590 | StepBasic_Unit aUnit = GetUnit(aRC); | |
2591 | gp_Ax2 aDTAxis = anObject->GetDatumTargetAxis(); | |
1603a497 | 2592 | GeomToStep_MakeAxis2Placement3d anAxisMaker(aDTAxis); |
2593 | Handle(StepGeom_Axis2Placement3d) anA2P3D = anAxisMaker.Value(); | |
400af1bc | 2594 | anA2P3D->SetName(new TCollection_HAsciiString("orientation")); |
2595 | Handle(StepRepr_HArray1OfRepresentationItem) anItems; | |
2596 | // Process each datum target type | |
2597 | if (aDatumType == XCAFDimTolObjects_DatumTargetType_Point) { | |
2598 | anItems = new StepRepr_HArray1OfRepresentationItem(1, 1); | |
6595eee7 | 2599 | } |
400af1bc | 2600 | else { |
2601 | Handle(TCollection_HAsciiString) aTargetValueName; | |
2602 | if (aDatumType == XCAFDimTolObjects_DatumTargetType_Line) { | |
2603 | anItems = new StepRepr_HArray1OfRepresentationItem(1, 2); | |
2604 | aTargetValueName = new TCollection_HAsciiString("target length"); | |
2605 | } | |
2606 | else if (aDatumType == XCAFDimTolObjects_DatumTargetType_Rectangle) { | |
2607 | anItems = new StepRepr_HArray1OfRepresentationItem(1, 3); | |
2608 | aTargetValueName = new TCollection_HAsciiString("target length"); | |
2609 | // Additional value | |
2610 | Handle(StepRepr_ReprItemAndMeasureWithUnit) aTargetValue = CreateDimValue(anObject->GetDatumTargetWidth(), | |
2611 | aUnit, new TCollection_HAsciiString("target width"), "POSITIVE_LENGTH_MEASURE", Standard_False); | |
2612 | anItems->SetValue(2, aTargetValue); | |
2613 | Model->AddWithRefs(aTargetValue); | |
2614 | } | |
2615 | else if (aDatumType == XCAFDimTolObjects_DatumTargetType_Circle) { | |
2616 | anItems = new StepRepr_HArray1OfRepresentationItem(1, 2); | |
2617 | aTargetValueName = new TCollection_HAsciiString("target diameter"); | |
2618 | } | |
2619 | // Value | |
2620 | Handle(StepRepr_ReprItemAndMeasureWithUnit) aTargetValue = CreateDimValue(anObject->GetDatumTargetLength(), | |
2621 | aUnit, aTargetValueName, "POSITIVE_LENGTH_MEASURE", Standard_False); | |
2622 | anItems->SetValue(1, aTargetValue); | |
6595eee7 | 2623 | Model->AddWithRefs(aTargetValue); |
2624 | } | |
400af1bc | 2625 | anItems->SetValue(anItems->Length(), anA2P3D); |
2626 | aSRWP->Init(new TCollection_HAsciiString(), anItems, aRC); | |
2627 | // Create and write auxiliary entities | |
2628 | Handle(StepShape_ShapeDefinitionRepresentation) aSDR = new StepShape_ShapeDefinitionRepresentation(); | |
2629 | StepRepr_RepresentedDefinition aRDefinition; | |
2630 | aRDefinition.SetValue(aPD); | |
2631 | aSDR->Init(aRDefinition, aSRWP); | |
2632 | Model->AddWithRefs(aPD); | |
2633 | Model->AddWithRefs(aSRWP); | |
2634 | Model->AddWithRefs(aSDR); | |
6595eee7 | 2635 | } |
6595eee7 | 2636 | } |
2637 | // Link datum target to datum feature | |
400af1bc | 2638 | // if aSASeq.Length() == 0 nothing to do |
2639 | if (aSASeq.Length() == 1) { | |
2640 | Handle(StepRepr_FeatureForDatumTargetRelationship) aFFDTR = new StepRepr_FeatureForDatumTargetRelationship(); | |
2641 | aFFDTR->Init(new TCollection_HAsciiString(), Standard_False, NULL, aSASeq.Value(1), aDatumTarget); | |
2642 | Model->AddWithRefs(aFFDTR); | |
2643 | } | |
2644 | else if (aSASeq.Length() > 1) { | |
2645 | Handle(StepRepr_CompositeShapeAspect) aCompSA = new StepRepr_CompositeShapeAspect(); | |
2646 | aCompSA->Init(new TCollection_HAsciiString(), new TCollection_HAsciiString(), aPDS, aSASeq.Value(1)->ProductDefinitional()); | |
2647 | for (Standard_Integer i = 1; i <= aSASeq.Length(); i++) { | |
2648 | Handle(StepRepr_ShapeAspectRelationship) aSAR = new StepRepr_ShapeAspectRelationship(); | |
2649 | aSAR->Init(new TCollection_HAsciiString(), Standard_False, new TCollection_HAsciiString(), aCompSA, aSASeq.Value(i)); | |
2650 | Model->AddWithRefs(aSAR); | |
2651 | } | |
2652 | Handle(StepRepr_FeatureForDatumTargetRelationship) aFFDTR = new StepRepr_FeatureForDatumTargetRelationship(); | |
2653 | aFFDTR->Init(new TCollection_HAsciiString(), Standard_False, NULL, aCompSA, aDatumTarget); | |
2654 | Model->AddWithRefs(aFFDTR); | |
2655 | } | |
6595eee7 | 2656 | aSA = aDatumTarget; |
2657 | } | |
2658 | ||
2659 | // Datum | |
2660 | Handle(StepDimTol_Datum) aDatum = theWrittenDatum; | |
2661 | if (isFirstDTarget) { | |
2662 | aDatum = new StepDimTol_Datum(); | |
400af1bc | 2663 | aDatum->Init(new TCollection_HAsciiString(), new TCollection_HAsciiString(), aPDS, StepData_LFalse, anIdentifier); |
6595eee7 | 2664 | Model->AddWithRefs(aDatum); |
2665 | } | |
2666 | ||
2667 | // Shape_Aspect_Relationship | |
400af1bc | 2668 | if (!aSA.IsNull()) { |
2669 | Handle(StepRepr_ShapeAspectRelationship) aSAR = new StepRepr_ShapeAspectRelationship(); | |
2670 | aSAR->Init(new TCollection_HAsciiString(), Standard_False, NULL, aSA, aDatum); | |
2671 | Model->AddWithRefs(aSAR); | |
2672 | } | |
6595eee7 | 2673 | |
b0cef606 | 2674 | //Annotation plane and Presentation |
1209c1b9 | 2675 | WritePresentation(WS, anObject->GetPresentation(), anObject->GetPresentationName(), Standard_True, anObject->HasPlane(), |
2676 | anObject->GetPlane(), anObject->GetPointTextAttach(), aSA); | |
b0cef606 | 2677 | |
6595eee7 | 2678 | return aDatum; |
2679 | } | |
2680 | ||
2681 | //======================================================================= | |
2682 | //function : WriteDimValues | |
2683 | //purpose : auxiliary (write all data for given dimension: values, | |
2684 | // qualifiers, modifiers, orientation and tolerance class) | |
2685 | //====================================================================== | |
2686 | static void WriteDimValues(const Handle(XSControl_WorkSession) &WS, | |
2687 | const Handle(XCAFDimTolObjects_DimensionObject) theObject, | |
2688 | const Handle(StepRepr_RepresentationContext) theRC, | |
2689 | const StepShape_DimensionalCharacteristic theDimension) | |
2690 | { | |
2691 | // Get working data | |
7f56eba8 | 2692 | const Handle(Interface_InterfaceModel) &aModel = WS->Model(); |
6595eee7 | 2693 | XCAFDimTolObjects_DimensionModifiersSequence aModifiers = theObject->GetModifiers(); |
2694 | Handle(Standard_Transient) aDim = theDimension.Value(); | |
2695 | Standard_Boolean isAngle = aDim->IsKind(STANDARD_TYPE(StepShape_AngularLocation)) || | |
2696 | aDim->IsKind(STANDARD_TYPE(StepShape_AngularSize)); | |
2697 | ||
2698 | // Unit | |
2699 | StepBasic_Unit aUnit = GetUnit(theRC, isAngle); | |
2700 | Standard_CString aMeasureName; | |
2701 | if (isAngle) | |
2702 | aMeasureName = "POSITIVE_PLANE_ANGLE_MEASURE"; | |
2703 | else | |
2704 | aMeasureName = "POSITIVE_LENGTH_MEASURE"; | |
2705 | ||
2706 | // Values | |
2707 | Handle(StepRepr_HArray1OfRepresentationItem) aValues; | |
7644c7f4 | 2708 | Standard_Integer aNbItems = 1, aValIt = 1; |
6595eee7 | 2709 | if (theObject->IsDimWithRange()) |
7644c7f4 | 2710 | aNbItems += 2; |
6595eee7 | 2711 | if (aModifiers.Length() > 0) |
7644c7f4 | 2712 | aNbItems++; |
6595eee7 | 2713 | if (theObject->GetType() == XCAFDimTolObjects_DimensionType_Location_Oriented) |
7644c7f4 | 2714 | aNbItems++; |
2715 | aNbItems += theObject->NbDescriptions(); | |
2716 | aValues = new StepRepr_HArray1OfRepresentationItem(1, aNbItems); | |
6595eee7 | 2717 | |
2718 | // Nominal value | |
2719 | Standard_Real aNominal = theObject->GetValue(); | |
2720 | Standard_Integer aLeftNbDigits, aRightNbDigits; | |
2721 | theObject->GetNbOfDecimalPlaces(aLeftNbDigits, aRightNbDigits); | |
2722 | Standard_Integer aNbQualifiers = 0; | |
2723 | if (theObject->HasQualifier() && !isAngle) | |
2724 | aNbQualifiers++; | |
2725 | if (aLeftNbDigits > 0 || aRightNbDigits > 0) | |
2726 | aNbQualifiers++; | |
2727 | // With qualifiers | |
2728 | if (aNbQualifiers > 0) { | |
2729 | Handle(StepShape_QualifiedRepresentationItem) aQRI = new StepShape_QualifiedRepresentationItem(); | |
2730 | Handle(StepShape_HArray1OfValueQualifier) aQualifiers = new StepShape_HArray1OfValueQualifier(1, aNbQualifiers); | |
2731 | // Type qualifier | |
2732 | if (theObject->HasQualifier() && !isAngle) { | |
2733 | StepShape_ValueQualifier anItem; | |
2734 | Handle(StepShape_TypeQualifier) aType = new StepShape_TypeQualifier(); | |
2735 | XCAFDimTolObjects_DimensionQualifier aQualifier = theObject->GetQualifier(); | |
727b5ad9 | 2736 | aType->Init(STEPCAFControl_GDTProperty::GetDimQualifierName(aQualifier)); |
6595eee7 | 2737 | aModel->AddWithRefs(aType); |
2738 | anItem.SetValue(aType); | |
2739 | aQualifiers->SetValue(1, anItem); | |
2740 | } | |
2741 | // Number of decimal places | |
2742 | if (aLeftNbDigits > 0 || aRightNbDigits > 0) { | |
2743 | StepShape_ValueQualifier anItem; | |
2744 | Handle(StepShape_ValueFormatTypeQualifier) aType = new StepShape_ValueFormatTypeQualifier(); | |
2745 | Handle(TCollection_HAsciiString) aFormatType = new TCollection_HAsciiString("NR2 "); | |
2746 | aFormatType->AssignCat(new TCollection_HAsciiString(aLeftNbDigits)); | |
2747 | aFormatType->AssignCat(new TCollection_HAsciiString(".")); | |
2748 | aFormatType->AssignCat(new TCollection_HAsciiString(aRightNbDigits)); | |
2749 | aType->Init(aFormatType); | |
2750 | aModel->AddWithRefs(aType); | |
2751 | anItem.SetValue(aType); | |
2752 | aQualifiers->SetValue(aNbQualifiers, anItem); | |
2753 | } | |
2754 | // Set qualifiers | |
2755 | aQRI->SetQualifiers(aQualifiers); | |
2756 | Handle(StepRepr_ReprItemAndMeasureWithUnit) anItem = CreateDimValue(aNominal, aUnit, | |
2757 | new TCollection_HAsciiString("nominal value"), aMeasureName, isAngle, Standard_True, aQRI); | |
7644c7f4 | 2758 | aValues->SetValue(aValIt, anItem); |
2759 | aValIt++; | |
6595eee7 | 2760 | } |
2761 | // Without qualifiers | |
2762 | else { | |
2763 | Handle(StepRepr_ReprItemAndMeasureWithUnit) anItem = CreateDimValue(aNominal, aUnit, | |
2764 | new TCollection_HAsciiString("nominal value"), aMeasureName, isAngle); | |
7644c7f4 | 2765 | aValues->SetValue(aValIt, anItem); |
2766 | aValIt++; | |
6595eee7 | 2767 | } |
7644c7f4 | 2768 | |
6595eee7 | 2769 | // Ranges |
2770 | if (theObject->IsDimWithRange()) { | |
2771 | Handle(StepRepr_ReprItemAndMeasureWithUnit) aLowerItem = CreateDimValue(theObject->GetLowerBound(), aUnit, | |
2772 | new TCollection_HAsciiString("lower limit"), aMeasureName, isAngle); | |
2773 | Handle(StepRepr_ReprItemAndMeasureWithUnit) anUpperItem = CreateDimValue(theObject->GetUpperBound(), aUnit, | |
2774 | new TCollection_HAsciiString("upper limit"), aMeasureName, isAngle); | |
7644c7f4 | 2775 | aValues->SetValue(aValIt, aLowerItem); |
2776 | aValIt++; | |
2777 | aValues->SetValue(aValIt, anUpperItem); | |
2778 | aValIt++; | |
6595eee7 | 2779 | } |
2780 | ||
2781 | // Modifiers | |
2782 | if (aModifiers.Length() > 0) { | |
2783 | Handle(StepRepr_CompoundRepresentationItem) aCompoundRI = new StepRepr_CompoundRepresentationItem(); | |
2784 | Handle (StepRepr_HArray1OfRepresentationItem) aModifItems = | |
2785 | new StepRepr_HArray1OfRepresentationItem(1, aModifiers.Length()); | |
2786 | for (Standard_Integer i = 1; i <= aModifiers.Length(); i++) { | |
2787 | XCAFDimTolObjects_DimensionModif aModif = aModifiers.Value(i); | |
2788 | Handle(StepRepr_DescriptiveRepresentationItem) aModifItem = | |
2789 | new StepRepr_DescriptiveRepresentationItem(); | |
727b5ad9 | 2790 | aModifItem->Init(new TCollection_HAsciiString(), STEPCAFControl_GDTProperty::GetDimModifierName(aModif)); |
6595eee7 | 2791 | aModel->AddWithRefs(aModifItem); |
2792 | aModifItems->SetValue(i, aModifItem); | |
2793 | } | |
2794 | aCompoundRI->Init(new TCollection_HAsciiString(), aModifItems); | |
7644c7f4 | 2795 | aValues->SetValue(aValIt, aCompoundRI); |
2796 | aValIt++; | |
6595eee7 | 2797 | } |
2798 | ||
2799 | // Orientation | |
2800 | if (theObject->GetType() == XCAFDimTolObjects_DimensionType_Location_Oriented) { | |
2801 | Handle(StepGeom_Axis2Placement3d) anOrientation = new StepGeom_Axis2Placement3d(); | |
2802 | gp_Dir aDir; | |
2803 | theObject->GetDirection(aDir); | |
b7b2f85a | 2804 | GeomToStep_MakeCartesianPoint MkPoint(gp_Pnt(0, 0, 0)); |
18f7c9a5 | 2805 | Handle(StepGeom_CartesianPoint) aLoc = MkPoint.Value(); |
6595eee7 | 2806 | Handle(StepGeom_Direction) anAxis = new StepGeom_Direction(); |
2807 | Handle(TColStd_HArray1OfReal) aCoords = new TColStd_HArray1OfReal(1, 3); | |
2808 | aCoords->SetValue(1, aDir.X()); | |
2809 | aCoords->SetValue(2, aDir.Y()); | |
2810 | aCoords->SetValue(3, aDir.Z()); | |
2811 | anAxis->Init(new TCollection_HAsciiString(), aCoords); | |
2812 | anOrientation->Init(new TCollection_HAsciiString("orientation"), aLoc, Standard_True, anAxis, Standard_False, NULL); | |
7644c7f4 | 2813 | aValues->SetValue(aValIt, anOrientation); |
2814 | aValIt++; | |
2815 | } | |
2816 | ||
2817 | // Descriptions | |
2818 | if (theObject->HasDescriptions()) { | |
2819 | for (Standard_Integer i = 0; i < theObject->NbDescriptions(); i++) { | |
2820 | Handle(StepRepr_DescriptiveRepresentationItem) aDRI = new StepRepr_DescriptiveRepresentationItem(); | |
2821 | aDRI->Init(theObject->GetDescriptionName(i), theObject->GetDescription(i)); | |
2822 | aValues->SetValue(aValIt, aDRI); | |
2823 | aValIt++; | |
2824 | } | |
6595eee7 | 2825 | } |
2826 | ||
2827 | for (Standard_Integer i = 1; i <= aValues->Length(); i++) | |
2828 | aModel->AddWithRefs(aValues->Value(i)); | |
2829 | ||
2830 | // Create resulting Shape_Dimension_Representation | |
2831 | Handle(StepShape_ShapeDimensionRepresentation) aSDR = new StepShape_ShapeDimensionRepresentation(); | |
2832 | aSDR->Init(new TCollection_HAsciiString(), aValues, theRC); | |
2833 | aModel->AddWithRefs(aSDR); | |
2834 | Handle(StepShape_DimensionalCharacteristicRepresentation) aDCR = new StepShape_DimensionalCharacteristicRepresentation(); | |
2835 | aDCR->Init(theDimension, aSDR); | |
2836 | aModel->AddWithRefs(aDCR); | |
2837 | ||
2838 | // Plus_Minus_Tolerance | |
2839 | if (theObject->IsDimWithPlusMinusTolerance()) { | |
2840 | Handle(TCollection_HAsciiString) aDummyName = new TCollection_HAsciiString(aMeasureName); | |
2841 | aDummyName = aDummyName->SubString(9, aDummyName->Length()); //delete "POSITIVE_" | |
2842 | aMeasureName = aDummyName->ToCString(); | |
2843 | Standard_Real aLowerTolValue = -theObject->GetLowerTolValue(), | |
2844 | anUpperTolValue = theObject->GetUpperTolValue(); | |
2845 | // Upper | |
2846 | Handle(StepBasic_MeasureWithUnit) anUpperMWU = new StepBasic_MeasureWithUnit(); | |
2847 | Handle(StepBasic_MeasureValueMember) anUpperValue = new StepBasic_MeasureValueMember(); | |
2848 | anUpperValue->SetName(aMeasureName); | |
2849 | anUpperValue->SetReal(anUpperTolValue); | |
2850 | anUpperMWU->Init(anUpperValue, aUnit); | |
2851 | aModel->AddWithRefs(anUpperMWU); | |
2852 | // Lower | |
2853 | Handle(StepBasic_MeasureWithUnit) aLowerMWU = new StepBasic_MeasureWithUnit(); | |
2854 | Handle(StepBasic_MeasureValueMember) aLowerValue = new StepBasic_MeasureValueMember(); | |
2855 | aLowerValue->SetName(aMeasureName); | |
2856 | aLowerValue->SetReal(aLowerTolValue); | |
2857 | aLowerMWU->Init(aLowerValue, aUnit); | |
2858 | aModel->AddWithRefs(aLowerMWU); | |
2859 | // Tolerance | |
2860 | Handle(StepShape_ToleranceValue) aTolValue = new StepShape_ToleranceValue(); | |
2861 | aTolValue->Init(aLowerMWU, anUpperMWU); | |
2862 | aModel->AddWithRefs(aTolValue); | |
2863 | StepShape_ToleranceMethodDefinition aMethod; | |
2864 | aMethod.SetValue(aTolValue); | |
2865 | Handle(StepShape_PlusMinusTolerance) aPlusMinusTol = new StepShape_PlusMinusTolerance(); | |
2866 | aPlusMinusTol->Init(aMethod, theDimension); | |
2867 | aModel->AddWithRefs(aPlusMinusTol); | |
2868 | } | |
2869 | // Tolerance class | |
2870 | if (theObject->IsDimWithClassOfTolerance()) { | |
2871 | Standard_Boolean isHole; | |
2872 | XCAFDimTolObjects_DimensionFormVariance aFormVariance; | |
2873 | XCAFDimTolObjects_DimensionGrade aGrade; | |
2874 | if (!theObject->GetClassOfTolerance(isHole, aFormVariance, aGrade)) | |
2875 | return; | |
727b5ad9 | 2876 | Handle(StepShape_LimitsAndFits) aLAF = STEPCAFControl_GDTProperty::GetLimitsAndFits(isHole, aFormVariance, aGrade); |
6595eee7 | 2877 | aModel->AddWithRefs(aLAF); |
2878 | StepShape_ToleranceMethodDefinition aMethod; | |
2879 | aMethod.SetValue(aLAF); | |
2880 | Handle(StepShape_PlusMinusTolerance) aPlusMinusTol = new StepShape_PlusMinusTolerance(); | |
2881 | aPlusMinusTol->Init(aMethod, theDimension); | |
2882 | aModel->AddWithRefs(aPlusMinusTol); | |
2883 | } | |
2884 | } | |
2885 | ||
b7b2f85a | 2886 | //======================================================================= |
2887 | //function : WriteDerivedGeometry | |
2888 | //purpose : auxiliary (write connection point for dimensions) | |
2889 | //====================================================================== | |
2890 | static void WriteDerivedGeometry (const Handle(XSControl_WorkSession) &WS, | |
2891 | const Handle(XCAFDimTolObjects_DimensionObject)& theObject, | |
2892 | const Handle(StepRepr_ConstructiveGeometryRepresentation) theRepr, | |
2893 | Handle(StepRepr_ShapeAspect)& theFirstSA, | |
2894 | Handle(StepRepr_ShapeAspect)& theSecondSA, | |
2895 | NCollection_Vector<Handle(StepGeom_CartesianPoint)>& thePnts) | |
2896 | { | |
2897 | const Handle(Interface_InterfaceModel) &aModel = WS->Model(); | |
2898 | // First point | |
2899 | if (theObject->HasPoint()) { | |
2900 | GeomToStep_MakeCartesianPoint aPointMaker(theObject->GetPoint()); | |
2901 | Handle(StepGeom_CartesianPoint) aPoint = aPointMaker.Value(); | |
2902 | thePnts.Append(aPoint); | |
2903 | Handle(StepRepr_DerivedShapeAspect) aDSA = new StepRepr_DerivedShapeAspect(); | |
2904 | aDSA->Init(new TCollection_HAsciiString(), new TCollection_HAsciiString(), theFirstSA->OfShape(), StepData_LFalse); | |
2905 | Handle(StepAP242_GeometricItemSpecificUsage) aGISU = new StepAP242_GeometricItemSpecificUsage(); | |
2906 | StepAP242_ItemIdentifiedRepresentationUsageDefinition aDefinition; | |
2907 | aDefinition.SetValue(aDSA); | |
2908 | Handle(StepRepr_HArray1OfRepresentationItem) anItem = new StepRepr_HArray1OfRepresentationItem(1, 1); | |
2909 | anItem->SetValue(1, aPoint); | |
2910 | aGISU->Init(new TCollection_HAsciiString(), new TCollection_HAsciiString(), aDefinition, theRepr, anItem); | |
2911 | Handle(StepRepr_ShapeAspectDerivingRelationship) aSADR = new StepRepr_ShapeAspectDerivingRelationship(); | |
2912 | aSADR->Init(new TCollection_HAsciiString(), Standard_False, new TCollection_HAsciiString(), aDSA, theFirstSA); | |
2913 | theFirstSA = aDSA; | |
2914 | aModel->AddWithRefs(aGISU); | |
2915 | aModel->AddWithRefs(aSADR); | |
2916 | } | |
2917 | ||
2918 | // Second point (for locations) | |
2919 | if (theObject->HasPoint2()) { | |
2920 | GeomToStep_MakeCartesianPoint aPointMaker(theObject->GetPoint2()); | |
2921 | Handle(StepGeom_CartesianPoint) aPoint = aPointMaker.Value(); | |
2922 | thePnts.Append(aPoint); | |
2923 | Handle(StepRepr_DerivedShapeAspect) aDSA = new StepRepr_DerivedShapeAspect(); | |
2924 | aDSA->Init(new TCollection_HAsciiString(), new TCollection_HAsciiString(), theFirstSA->OfShape(), StepData_LFalse); | |
2925 | Handle(StepAP242_GeometricItemSpecificUsage) aGISU = new StepAP242_GeometricItemSpecificUsage(); | |
2926 | StepAP242_ItemIdentifiedRepresentationUsageDefinition aDefinition; | |
2927 | aDefinition.SetValue(aDSA); | |
2928 | Handle(StepRepr_HArray1OfRepresentationItem) anItem = new StepRepr_HArray1OfRepresentationItem(1, 1); | |
2929 | anItem->SetValue(1, aPoint); | |
2930 | aGISU->Init(new TCollection_HAsciiString(), new TCollection_HAsciiString(), aDefinition, theRepr, anItem); | |
2931 | Handle(StepRepr_ShapeAspectDerivingRelationship) aSADR = new StepRepr_ShapeAspectDerivingRelationship(); | |
2932 | aSADR->Init(new TCollection_HAsciiString(), Standard_False, new TCollection_HAsciiString(), aDSA, theSecondSA); | |
2933 | theSecondSA = aDSA; | |
2934 | aModel->AddWithRefs(aGISU); | |
2935 | aModel->AddWithRefs(aSADR); | |
2936 | } | |
2937 | } | |
2938 | ||
6595eee7 | 2939 | //======================================================================= |
2940 | //function : WriteDatumSystem | |
2941 | //purpose : auxiliary (write Write datum system for given | |
2942 | // geometric_tolerance) | |
2943 | //====================================================================== | |
2944 | static Handle(StepDimTol_HArray1OfDatumSystemOrReference) WriteDatumSystem(const Handle(XSControl_WorkSession) &WS, | |
2945 | const TDF_Label theGeomTolL, | |
2946 | const TDF_LabelSequence theDatumSeq, | |
2947 | const STEPConstruct_DataMapOfAsciiStringTransient theDatumMap, | |
2948 | const Handle(StepRepr_RepresentationContext)& theRC) | |
2949 | { | |
2950 | // Get working data | |
7f56eba8 | 2951 | const Handle(Interface_InterfaceModel) &Model = WS->Model(); |
6595eee7 | 2952 | const Handle(Interface_HGraph) aHGraph = WS->HGraph(); |
2953 | if (aHGraph.IsNull()) | |
2954 | return NULL; | |
2955 | Interface_Graph aGraph = aHGraph->Graph(); | |
2956 | Handle(XCAFDoc_GeomTolerance) aGTAttr; | |
2957 | if (!theGeomTolL.FindAttribute(XCAFDoc_GeomTolerance::GetID(), aGTAttr)) | |
2958 | return NULL; | |
2959 | Handle(XCAFDimTolObjects_GeomToleranceObject) anObject = aGTAttr->GetObject(); | |
2960 | if (anObject.IsNull()) | |
2961 | return NULL; | |
2962 | ||
2963 | // Unit | |
2964 | StepBasic_Unit aUnit = GetUnit(theRC); | |
2965 | ||
2966 | XCAFDimTolObjects_DatumObjectSequence aDatums; | |
2967 | Standard_Integer aMaxDatumNum = 0; | |
2968 | for (Standard_Integer i = 1; i <= theDatumSeq.Length(); i++) { | |
2969 | Handle(XCAFDoc_Datum) aDatumAttr; | |
2970 | if (!theDatumSeq.Value(i).FindAttribute(XCAFDoc_Datum::GetID(), aDatumAttr)) | |
2971 | continue; | |
2972 | Handle(XCAFDimTolObjects_DatumObject) aDatumObj = aDatumAttr->GetObject(); | |
2973 | if (aDatumObj.IsNull()) | |
2974 | continue; | |
2975 | aDatums.Append(aDatumObj); | |
2976 | aMaxDatumNum = Max(aMaxDatumNum, aDatumObj->GetPosition()); | |
2977 | } | |
c1070321 | 2978 | if (aMaxDatumNum == 0) |
2979 | return NULL; | |
6595eee7 | 2980 | |
2981 | Handle(StepDimTol_HArray1OfDatumReferenceCompartment) aConstituents = | |
2982 | new StepDimTol_HArray1OfDatumReferenceCompartment(1, aMaxDatumNum); | |
2983 | // Auxiliary datum to initialize attributes in Datum_System | |
2984 | Handle(StepDimTol_Datum) aFirstDatum; | |
2985 | Standard_Integer aConstituentsNum = 0; | |
2986 | for (Standard_Integer i = 1; i <= aMaxDatumNum; i++) { | |
2987 | // Collect datums with i-th position | |
2988 | XCAFDimTolObjects_DatumObjectSequence aDatumSeqPos; | |
2989 | for (Standard_Integer j = 1; j <= aDatums.Length(); j++) | |
2990 | if (aDatums.Value(j)->GetPosition() == i) | |
2991 | aDatumSeqPos.Append(aDatums.Value(j)); | |
2992 | if (aDatumSeqPos.Length() < 1) | |
2993 | continue; | |
2994 | ||
2995 | aConstituentsNum++; | |
2996 | // Initialize Datum_Reference_Compartment | |
2997 | StepDimTol_DatumOrCommonDatum aDatumRef; | |
2998 | Handle(StepDimTol_DatumReferenceCompartment) aCompartment = | |
2999 | new StepDimTol_DatumReferenceCompartment(); | |
3000 | Handle(StepDimTol_HArray1OfDatumReferenceModifier) aModifiers; | |
3001 | if (aDatumSeqPos.Length() == 1) { | |
3002 | // Datum entity | |
aa00364d | 3003 | Handle(Standard_Transient) aFDValue; |
f3ec3b37 | 3004 | if (theDatumMap.Find(aDatumSeqPos.Value(1)->GetName()->String(), aFDValue) && !aFDValue.IsNull()) |
aa00364d | 3005 | aFirstDatum = Handle(StepDimTol_Datum)::DownCast (aFDValue); |
6595eee7 | 3006 | aDatumRef.SetValue(aFirstDatum); |
3007 | // Modifiers | |
3008 | XCAFDimTolObjects_DatumModifiersSequence aSimpleModifiers = aDatumSeqPos.Value(1)->GetModifiers(); | |
3009 | XCAFDimTolObjects_DatumModifWithValue aModifWithVal; | |
3010 | Standard_Real aValue = 0; | |
3011 | aDatumSeqPos.Value(1)->GetModifierWithValue(aModifWithVal, aValue); | |
727b5ad9 | 3012 | aModifiers = STEPCAFControl_GDTProperty::GetDatumRefModifiers(aSimpleModifiers, aModifWithVal, aValue, aUnit); |
6595eee7 | 3013 | // Add Datum_Reference_Modifier_With_Value |
3014 | if (!aModifiers.IsNull()) { | |
3015 | Handle(StepDimTol_DatumReferenceModifierWithValue) aDRMWV = | |
3016 | aModifiers->Value(aModifiers->Length()).DatumReferenceModifierWithValue(); | |
3017 | if (!aDRMWV.IsNull()) { | |
3018 | Model->AddWithRefs(aDRMWV); | |
3019 | } | |
3020 | } | |
3021 | } | |
3022 | else { | |
3023 | Handle(StepDimTol_HArray1OfDatumReferenceElement) aCommonDatumList = new StepDimTol_HArray1OfDatumReferenceElement(1, aDatumSeqPos.Length()); | |
3024 | for (Standard_Integer j = 1; j <= aDatumSeqPos.Length(); j++) { | |
3025 | // Datum entity | |
3026 | Handle(StepDimTol_Datum) aDatum; | |
aa00364d | 3027 | Handle(Standard_Transient) aDValue; |
3028 | if (theDatumMap.Find(aDatumSeqPos.Value(j)->GetName()->String(), aDValue)) | |
3029 | aDatum = Handle(StepDimTol_Datum)::DownCast (aDValue); | |
6595eee7 | 3030 | StepDimTol_DatumOrCommonDatum anElemDatumRef; |
3031 | anElemDatumRef.SetValue(aDatum); | |
3032 | if (aFirstDatum.IsNull()) | |
3033 | aFirstDatum = aDatum; | |
3034 | // Modifiers | |
3035 | XCAFDimTolObjects_DatumModifiersSequence aSimpleModifiers = aDatumSeqPos.Value(j)->GetModifiers(); | |
3036 | XCAFDimTolObjects_DatumModifWithValue aModifWithVal; | |
3037 | Standard_Real aValue = 0; | |
3038 | aDatumSeqPos.Value(j)->GetModifierWithValue(aModifWithVal, aValue); | |
3039 | Handle(StepDimTol_HArray1OfDatumReferenceModifier) anElemModifiers = | |
727b5ad9 | 3040 | STEPCAFControl_GDTProperty::GetDatumRefModifiers(aSimpleModifiers, aModifWithVal, aValue, aUnit); |
6595eee7 | 3041 | // Add Datum_Reference_Modifier_With_Value |
3042 | if (!anElemModifiers.IsNull()) { | |
3043 | Handle(StepDimTol_DatumReferenceModifierWithValue) aDRMWV = | |
f3ec3b37 | 3044 | anElemModifiers->Value(anElemModifiers->Length()).DatumReferenceModifierWithValue(); |
6595eee7 | 3045 | if (!aDRMWV.IsNull()) { |
3046 | Model->AddWithRefs(aDRMWV); | |
3047 | } | |
3048 | } | |
3049 | // Datum_Reference_Element | |
3050 | Handle(StepDimTol_DatumReferenceElement) anElement = new StepDimTol_DatumReferenceElement(); | |
3051 | anElement->Init(new TCollection_HAsciiString(), new TCollection_HAsciiString(), aDatum->OfShape(), | |
3052 | aDatum->ProductDefinitional(), anElemDatumRef, !anElemModifiers.IsNull(), anElemModifiers); | |
3053 | Model->AddWithRefs(anElement); | |
3054 | aCommonDatumList->SetValue(j, anElement); | |
3055 | } | |
3056 | aDatumRef.SetValue(aCommonDatumList); | |
3057 | } | |
3058 | aCompartment->Init(new TCollection_HAsciiString(), new TCollection_HAsciiString(), aFirstDatum->OfShape(), | |
3059 | aFirstDatum->ProductDefinitional(), aDatumRef, !aModifiers.IsNull(), aModifiers); | |
3060 | Model->AddWithRefs(aCompartment); | |
3061 | aConstituents->SetValue(aConstituentsNum, aCompartment); | |
3062 | } | |
3063 | // Remove null elements from aConstituents | |
3064 | Standard_Integer aNbConstituents = 0; | |
3065 | for (Standard_Integer i = 1; i <= aConstituents->Length(); i++) | |
3066 | if (!aConstituents->Value(i).IsNull()) | |
3067 | aNbConstituents++; | |
3068 | Handle(StepDimTol_HArray1OfDatumReferenceCompartment) aResConstituents = | |
3069 | new StepDimTol_HArray1OfDatumReferenceCompartment(1, aNbConstituents); | |
3070 | Standard_Integer aConstituentsIt = 0; | |
3071 | for (Standard_Integer i = 1; i <= aConstituents->Length(); i++) | |
3072 | if (!aConstituents->Value(i).IsNull()) { | |
3073 | aConstituentsIt++; | |
3074 | aResConstituents->SetValue(aConstituentsIt, aConstituents->Value(i)); | |
3075 | } | |
3076 | ||
3077 | Handle(StepDimTol_HArray1OfDatumSystemOrReference) aDatumSystem; | |
3078 | Handle(StepDimTol_DatumSystem) aDS = new StepDimTol_DatumSystem(); | |
3079 | aDS->Init(new TCollection_HAsciiString(), new TCollection_HAsciiString(), aFirstDatum->OfShape(), | |
3080 | aFirstDatum->ProductDefinitional(), aResConstituents); | |
3081 | Model->AddWithRefs(aDS); | |
3082 | StepDimTol_DatumSystemOrReference anArrayValue; | |
3083 | anArrayValue.SetValue(aDS); | |
3084 | aDatumSystem = new StepDimTol_HArray1OfDatumSystemOrReference(1, 1); | |
3085 | aDatumSystem->SetValue(1, anArrayValue); | |
3086 | ||
3087 | // Axis | |
3088 | if (anObject->HasAxis()) { | |
1603a497 | 3089 | GeomToStep_MakeAxis2Placement3d anAxisMaker(anObject->GetAxis()); |
3090 | Handle(StepGeom_Axis2Placement3d) anAxis = anAxisMaker.Value(); | |
b0cef606 | 3091 | anAxis->SetName(new TCollection_HAsciiString("orientation")); |
6595eee7 | 3092 | Handle(StepAP242_GeometricItemSpecificUsage) aGISU = new StepAP242_GeometricItemSpecificUsage(); |
3093 | StepAP242_ItemIdentifiedRepresentationUsageDefinition aDefinition; | |
3094 | aDefinition.SetValue(aDS); | |
3095 | Handle(StepRepr_HArray1OfRepresentationItem) anReprItems = new StepRepr_HArray1OfRepresentationItem(1, 1); | |
a9dde4a3 | 3096 | Handle(StepRepr_RepresentationItem) anIdentifiedItem = anAxis; |
6595eee7 | 3097 | anReprItems->SetValue(1, anIdentifiedItem); |
3098 | Interface_EntityIterator subs = aGraph.Sharings(aFirstDatum->OfShape()); | |
3099 | Handle(StepShape_ShapeDefinitionRepresentation) aSDR; | |
3100 | for (subs.Start(); subs.More() && aSDR.IsNull(); subs.Next()) { | |
3101 | Handle(Standard_Transient) anEntity = subs.Value(); | |
3102 | aSDR = Handle(StepShape_ShapeDefinitionRepresentation)::DownCast(anEntity); | |
3103 | } | |
3104 | if (aSDR.IsNull()) | |
3105 | return aDatumSystem; | |
3106 | ||
3107 | aGISU->Init(new TCollection_HAsciiString(), new TCollection_HAsciiString(), | |
3108 | aDefinition, aSDR->UsedRepresentation(), anReprItems); | |
3109 | Model->AddWithRefs(anAxis); | |
3110 | Model->AddWithRefs(aGISU); | |
3111 | } | |
3112 | ||
3113 | return aDatumSystem; | |
3114 | } | |
3115 | ||
3116 | //======================================================================= | |
3117 | //function : WriteToleranceZone | |
3118 | //purpose : auxiliary (write tolerace zones) | |
3119 | //======================================================================= | |
1209c1b9 | 3120 | void STEPCAFControl_Writer::WriteToleranceZone (const Handle(XSControl_WorkSession) &WS, |
3121 | const Handle(XCAFDimTolObjects_GeomToleranceObject)& theObject, | |
3122 | const Handle(StepDimTol_GeometricTolerance)& theEntity, | |
3123 | const Handle(StepRepr_RepresentationContext)& theRC) | |
6595eee7 | 3124 | { |
3125 | // Get working data | |
7f56eba8 | 3126 | const Handle(Interface_InterfaceModel) &Model = WS->Model(); |
6595eee7 | 3127 | if (theEntity.IsNull() || theObject.IsNull()) |
3128 | return; | |
3129 | ||
3130 | // Return if there is no tolerance zones | |
3131 | if (theObject->GetTypeOfValue() == XCAFDimTolObjects_GeomToleranceTypeValue_None && | |
3132 | theObject->GetZoneModifier() != XCAFDimTolObjects_GeomToleranceZoneModif_Runout) | |
3133 | return; | |
3134 | ||
3135 | // Create Tolerance_Zone | |
3136 | Handle(StepDimTol_ToleranceZoneForm) aForm = new StepDimTol_ToleranceZoneForm(); | |
3137 | Model->AddWithRefs(aForm); | |
727b5ad9 | 3138 | aForm->Init(STEPCAFControl_GDTProperty::GetTolValueType(theObject->GetTypeOfValue())); |
6595eee7 | 3139 | Handle(StepDimTol_HArray1OfToleranceZoneTarget) aZoneTargetArray = new StepDimTol_HArray1OfToleranceZoneTarget(1, 1); |
3140 | StepDimTol_ToleranceZoneTarget aTarget; | |
3141 | aTarget.SetValue(theEntity); | |
3142 | aZoneTargetArray->SetValue(1, aTarget); | |
3143 | Handle(StepDimTol_ToleranceZone) aZone = new StepDimTol_ToleranceZone(); | |
3144 | aZone->Init(new TCollection_HAsciiString(), new TCollection_HAsciiString(), | |
3145 | theEntity->TolerancedShapeAspect().ShapeAspect()->OfShape(), StepData_LFalse, | |
3146 | aZoneTargetArray, aForm); | |
3147 | Model->AddWithRefs(aZone); | |
3148 | ||
3149 | // Runout_Tolerance_Zone | |
3150 | Handle(StepBasic_PlaneAngleMeasureWithUnit) aPAMWU = new StepBasic_PlaneAngleMeasureWithUnit(); | |
3151 | Handle(StepBasic_MeasureValueMember) aValueMember = new StepBasic_MeasureValueMember(); | |
3152 | aValueMember->SetName("PLANE_ANGLE_MEASURE"); | |
3153 | aValueMember->SetReal(theObject->GetValueOfZoneModifier()); | |
3154 | aPAMWU->Init(aValueMember, GetUnit(theRC, Standard_True)); | |
3155 | Handle(StepDimTol_RunoutZoneOrientation) anOrientation = new StepDimTol_RunoutZoneOrientation(); | |
3156 | anOrientation->Init(aPAMWU); | |
3157 | Handle(StepDimTol_RunoutZoneDefinition) aDefinition = new StepDimTol_RunoutZoneDefinition(); | |
3158 | aDefinition->Init(aZone, NULL, anOrientation); | |
3159 | Model->AddWithRefs(aDefinition); | |
3160 | Model->AddWithRefs(anOrientation); | |
3161 | Model->AddWithRefs(aPAMWU); | |
3162 | } | |
3163 | ||
3164 | //======================================================================= | |
3165 | //function : WriteGeomTolerance | |
3166 | //purpose : auxiliary (write Geometric_Tolerance entity for given shapes, | |
3167 | // label and datum system) | |
3168 | //====================================================================== | |
1209c1b9 | 3169 | void STEPCAFControl_Writer::WriteGeomTolerance (const Handle(XSControl_WorkSession) &WS, |
3170 | const TDF_LabelSequence theShapeSeqL, | |
3171 | const TDF_Label theGeomTolL, | |
3172 | const Handle(StepDimTol_HArray1OfDatumSystemOrReference)& theDatumSystem, | |
3173 | const Handle(StepRepr_RepresentationContext)& theRC) | |
6595eee7 | 3174 | { |
3175 | // Get working data | |
7f56eba8 | 3176 | const Handle(Interface_InterfaceModel) &Model = WS->Model(); |
6595eee7 | 3177 | Handle(XCAFDoc_GeomTolerance) aGTAttr; |
3178 | if (!theGeomTolL.FindAttribute(XCAFDoc_GeomTolerance::GetID(), aGTAttr)) | |
3179 | return; | |
3180 | Handle(XCAFDimTolObjects_GeomToleranceObject) anObject = aGTAttr->GetObject(); | |
3181 | if (anObject.IsNull()) | |
3182 | return; | |
3183 | ||
3184 | // Value | |
3185 | Handle(StepBasic_LengthMeasureWithUnit) aLMWU = new StepBasic_LengthMeasureWithUnit(); | |
3186 | StepBasic_Unit aUnit = GetUnit(theRC); | |
3187 | Handle(StepBasic_MeasureValueMember) aValueMember = new StepBasic_MeasureValueMember(); | |
3188 | aValueMember->SetName("LENGTH_MEASURE"); | |
3189 | aValueMember->SetReal(anObject->GetValue()); | |
3190 | aLMWU->Init(aValueMember, aUnit); | |
3191 | Model->AddWithRefs(aLMWU); | |
3192 | ||
3193 | // Geometric_Tolerance target | |
3194 | Handle(StepRepr_ShapeAspect) aMainSA; | |
3195 | Handle(StepRepr_RepresentationContext) dummyRC; | |
3196 | Handle(StepAP242_GeometricItemSpecificUsage) dummyGISU; | |
3197 | if (theShapeSeqL.Length() == 1) { | |
3198 | TopoDS_Shape aShape = XCAFDoc_ShapeTool::GetShape(theShapeSeqL.Value(1)); | |
3199 | aMainSA = WriteShapeAspect(WS, theGeomTolL, aShape, dummyRC, dummyGISU); | |
3200 | Model->AddWithRefs(aMainSA); | |
3201 | } | |
3202 | else { | |
3203 | Handle(StepRepr_CompositeShapeAspect) aCSA; | |
3204 | for (Standard_Integer i = 1; i <= theShapeSeqL.Length(); i++) { | |
3205 | TopoDS_Shape aShape = XCAFDoc_ShapeTool::GetShape(theShapeSeqL.Value(i)); | |
3206 | Handle(StepRepr_ShapeAspect) aSA = WriteShapeAspect(WS, theGeomTolL, aShape, dummyRC, dummyGISU); | |
3207 | if (aSA.IsNull()) | |
3208 | continue; | |
3209 | if (aCSA.IsNull()) { | |
3210 | aCSA = new StepRepr_CompositeShapeAspect(); | |
3211 | aCSA->Init(aSA->Name(), aSA->Description(), aSA->OfShape(), aSA->ProductDefinitional()); | |
3212 | Model->AddWithRefs(aCSA); | |
3213 | } | |
3214 | Handle(StepRepr_ShapeAspectRelationship) aSAR = new StepRepr_ShapeAspectRelationship(); | |
3215 | aSAR->Init(new TCollection_HAsciiString(), Standard_False, NULL, aCSA, aSA); | |
3216 | Model->AddWithRefs(aSAR); | |
3217 | } | |
3218 | aMainSA = aCSA; | |
3219 | } | |
3220 | StepDimTol_GeometricToleranceTarget aGTTarget; | |
3221 | aGTTarget.SetValue(aMainSA); | |
3222 | ||
3223 | Standard_Boolean isWithModif = Standard_False, | |
3224 | isWithDatRef = Standard_False, | |
3225 | isWithMaxTol = Standard_False; | |
3226 | // Modifiers | |
3227 | // Simple modifiers | |
3228 | XCAFDimTolObjects_GeomToleranceModifiersSequence aModifiers = anObject->GetModifiers(); | |
3229 | Handle(StepDimTol_HArray1OfGeometricToleranceModifier) aModifArray; | |
3230 | Handle(StepBasic_LengthMeasureWithUnit) aMaxLMWU; | |
3231 | Standard_Integer aModifNb = aModifiers.Length(); | |
3232 | if (anObject->GetMaterialRequirementModifier() != XCAFDimTolObjects_GeomToleranceMatReqModif_None) | |
3233 | aModifNb++; | |
51663cb4 | 3234 | for (Standard_Integer i = 1; i <= aModifiers.Length(); i++) |
6595eee7 | 3235 | if (aModifiers.Value(i) == XCAFDimTolObjects_GeomToleranceModif_All_Around || |
3236 | aModifiers.Value(i) == XCAFDimTolObjects_GeomToleranceModif_All_Over) | |
3237 | aModifNb--; | |
3238 | if (aModifNb > 0) { | |
3239 | isWithModif = Standard_True; | |
3240 | aModifArray = new StepDimTol_HArray1OfGeometricToleranceModifier(1, aModifNb); | |
3241 | Standard_Integer k = 1; | |
3242 | for (Standard_Integer i = 1; i <= aModifiers.Length(); i++) { | |
3243 | if (aModifiers.Value(i) == XCAFDimTolObjects_GeomToleranceModif_All_Around || | |
3244 | aModifiers.Value(i) == XCAFDimTolObjects_GeomToleranceModif_All_Over) | |
3245 | continue; | |
3246 | StepDimTol_GeometricToleranceModifier aModif = | |
727b5ad9 | 3247 | STEPCAFControl_GDTProperty::GetGeomToleranceModifier(aModifiers.Value(i)); |
6595eee7 | 3248 | aModifArray->SetValue(k, aModif); |
3249 | k++; | |
3250 | } | |
3251 | if (anObject->GetMaterialRequirementModifier() == XCAFDimTolObjects_GeomToleranceMatReqModif_L) { | |
3252 | aModifArray->SetValue(aModifNb, StepDimTol_GTMLeastMaterialRequirement); | |
3253 | } | |
3254 | else if (anObject->GetMaterialRequirementModifier() == XCAFDimTolObjects_GeomToleranceMatReqModif_M) { | |
3255 | aModifArray->SetValue(aModifNb, StepDimTol_GTMMaximumMaterialRequirement); | |
3256 | } | |
3257 | // Modifier with value | |
3258 | if (anObject->GetMaxValueModifier() != 0) { | |
3259 | isWithMaxTol = Standard_True; | |
3260 | aMaxLMWU = new StepBasic_LengthMeasureWithUnit(); | |
c7854818 | 3261 | Handle(StepBasic_MeasureValueMember) aModifierValueMember = new StepBasic_MeasureValueMember(); |
3262 | aModifierValueMember->SetName("LENGTH_MEASURE"); | |
3263 | aModifierValueMember->SetReal(anObject->GetMaxValueModifier()); | |
3264 | aMaxLMWU->Init(aModifierValueMember, aUnit); | |
6595eee7 | 3265 | Model->AddWithRefs(aMaxLMWU); |
3266 | } | |
3267 | } | |
3268 | ||
3269 | // Datum Reference | |
3270 | isWithDatRef = !theDatumSystem.IsNull(); | |
3271 | ||
3272 | // Collect all attributes | |
3273 | Handle(TCollection_HAsciiString) aName = new TCollection_HAsciiString(), | |
3274 | aDescription = new TCollection_HAsciiString(); | |
3275 | Handle(StepDimTol_GeometricToleranceWithDatumReference) aGTWDR = | |
3276 | new StepDimTol_GeometricToleranceWithDatumReference(); | |
3277 | aGTWDR->SetDatumSystem(theDatumSystem); | |
3278 | Handle(StepDimTol_GeometricToleranceWithModifiers) aGTWM = | |
3279 | new StepDimTol_GeometricToleranceWithModifiers(); | |
3280 | aGTWM->SetModifiers(aModifArray); | |
3281 | StepDimTol_GeometricToleranceType aType = | |
727b5ad9 | 3282 | STEPCAFControl_GDTProperty::GetGeomToleranceType(anObject->GetType()); |
6595eee7 | 3283 | |
3284 | // Init and write necessary subtype of Geometric_Tolerance entity | |
3285 | Handle(StepDimTol_GeometricTolerance) aGeomTol; | |
3286 | if (isWithModif) { | |
3287 | if (isWithMaxTol) { | |
3288 | if (isWithDatRef) { | |
3289 | // Geometric_Tolerance & Geometric_Tolerance_With_Datum_Reference & | |
3290 | //Geometric_Tolerance_With_Maximum_Tolerance & Geometric_Tolerance_With_Modifiers | |
3291 | Handle(StepDimTol_GeoTolAndGeoTolWthDatRefAndGeoTolWthMaxTol) aResult = | |
3292 | new StepDimTol_GeoTolAndGeoTolWthDatRefAndGeoTolWthMaxTol(); | |
3293 | aResult->Init(aName, aDescription, aLMWU, aGTTarget, aGTWDR, aGTWM, aMaxLMWU, aType); | |
3294 | aGeomTol = aResult; | |
3295 | } | |
3296 | else { | |
3297 | // Geometric_Tolerance & Geometric_Tolerance_With_Maximum_Tolerance & Geometric_Tolerance_With_Modifiers | |
3298 | Handle(StepDimTol_GeoTolAndGeoTolWthMaxTol) aResult = | |
3299 | new StepDimTol_GeoTolAndGeoTolWthMaxTol(); | |
3300 | aResult->Init(aName, aDescription, aLMWU, aGTTarget, aGTWM, aMaxLMWU, aType); | |
3301 | aGeomTol = aResult; | |
3302 | } | |
3303 | } | |
3304 | else { | |
3305 | if (isWithDatRef) { | |
3306 | // Geometric_Tolerance & Geometric_Tolerance_With_Datum_Reference & Geometric_Tolerance_With_Modifiers | |
3307 | Handle(StepDimTol_GeoTolAndGeoTolWthDatRefAndGeoTolWthMod) aResult = | |
3308 | new StepDimTol_GeoTolAndGeoTolWthDatRefAndGeoTolWthMod(); | |
3309 | aResult->Init(aName, aDescription, aLMWU, aGTTarget, aGTWDR, aGTWM, aType); | |
3310 | aGeomTol = aResult; | |
3311 | } | |
3312 | else { | |
3313 | // Geometric_Tolerance & Geometric_Tolerance_With_Modifiers | |
3314 | Handle(StepDimTol_GeoTolAndGeoTolWthMod) aResult = | |
3315 | new StepDimTol_GeoTolAndGeoTolWthMod(); | |
3316 | aResult->Init(aName, aDescription, aLMWU, aGTTarget, aGTWM, aType); | |
3317 | aGeomTol = aResult; | |
3318 | } | |
3319 | } | |
3320 | } | |
3321 | else { | |
3322 | if (isWithDatRef) { | |
3323 | // Geometric_Tolerance & Geometric_Tolerance_With_Datum_Reference | |
3324 | Handle(StepDimTol_GeoTolAndGeoTolWthDatRef) aResult = | |
3325 | new StepDimTol_GeoTolAndGeoTolWthDatRef(); | |
3326 | aResult->Init(aName, aDescription, aLMWU, aGTTarget, aGTWDR, aType); | |
3327 | aGeomTol = aResult; | |
3328 | } | |
3329 | else { | |
3330 | // Geometric_Tolerance | |
3331 | Handle(StepDimTol_GeometricTolerance) aResult = | |
727b5ad9 | 3332 | STEPCAFControl_GDTProperty::GetGeomTolerance(anObject->GetType()); |
6595eee7 | 3333 | if (!aResult.IsNull()) { |
3334 | aResult->Init(aName, aDescription, aLMWU, aGTTarget); | |
3335 | aGeomTol = aResult; | |
3336 | } | |
3337 | } | |
3338 | } | |
3339 | Model->AddWithRefs(aGeomTol); | |
3340 | WriteToleranceZone(WS, anObject, aGeomTol, theRC); | |
b0cef606 | 3341 | //Annotation plane and Presentation |
1209c1b9 | 3342 | WritePresentation(WS, anObject->GetPresentation(), anObject->GetPresentationName(), Standard_True, anObject->HasPlane(), |
3343 | anObject->GetPlane(), anObject->GetPointTextAttach(), aGeomTol); | |
6595eee7 | 3344 | } |
7fd59977 | 3345 | |
3346 | //======================================================================= | |
3347 | //function : WriteDGTs | |
3348 | //purpose : | |
3349 | //======================================================================= | |
7fd59977 | 3350 | Standard_Boolean STEPCAFControl_Writer::WriteDGTs (const Handle(XSControl_WorkSession) &WS, |
3351 | const TDF_LabelSequence &labels ) const | |
3352 | { | |
3353 | ||
3354 | if ( labels.Length() <=0 ) return Standard_False; | |
6595eee7 | 3355 | |
7fd59977 | 3356 | // get working data |
7f56eba8 | 3357 | const Handle(Interface_InterfaceModel) &Model = WS->Model(); |
3358 | const Handle(XSControl_TransferWriter) &TW = WS->TransferWriter(); | |
3359 | const Handle(Transfer_FinderProcess) &FP = TW->FinderProcess(); | |
9e20ed57 | 3360 | |
3361 | const Handle(Interface_HGraph) aHGraph = WS->HGraph(); | |
3362 | if(aHGraph.IsNull()) | |
3363 | return Standard_False; | |
3364 | ||
3365 | Interface_Graph aGraph = aHGraph->Graph(); | |
7fd59977 | 3366 | Handle(XCAFDoc_DimTolTool) DGTTool = XCAFDoc_DocumentTool::DimTolTool( labels(1) ); |
3367 | if(DGTTool.IsNull() ) return Standard_False; | |
3368 | ||
3369 | TDF_LabelSequence DGTLabels; | |
6595eee7 | 3370 | |
7fd59977 | 3371 | STEPConstruct_DataMapOfAsciiStringTransient DatumMap; |
3372 | ||
3373 | // write Datums | |
6595eee7 | 3374 | DGTLabels.Clear(); |
7fd59977 | 3375 | DGTTool->GetDatumLabels(DGTLabels); |
3376 | if(DGTLabels.Length()<=0) return Standard_False; | |
3377 | Standard_Integer i; | |
3378 | for(i=1; i<=DGTLabels.Length(); i++) { | |
3379 | TDF_Label DatumL = DGTLabels.Value(i); | |
9ebaae37 | 3380 | TDF_LabelSequence ShapeL; |
1c9d3225 | 3381 | TDF_LabelSequence aNullSeq; |
3382 | if(!DGTTool->GetRefShapeLabel(DatumL,ShapeL,aNullSeq)) continue; | |
7fd59977 | 3383 | // find target shape |
9ebaae37 | 3384 | TopoDS_Shape aShape = XCAFDoc_ShapeTool::GetShape(ShapeL.Value(1)); |
7fd59977 | 3385 | TopLoc_Location Loc; |
3386 | TColStd_SequenceOfTransient seqRI; | |
3387 | FindEntities( FP, aShape, Loc, seqRI ); | |
3388 | if ( seqRI.Length() <= 0 ) { | |
3389 | FP->Messenger() << "Warning: Cannot find RI for "<<aShape.TShape()->DynamicType()->Name()<<endl; | |
3390 | continue; | |
3391 | } | |
3392 | Handle(StepRepr_ProductDefinitionShape) PDS; | |
3393 | Handle(StepRepr_RepresentationContext) RC; | |
3394 | Handle(Standard_Transient) ent = seqRI.Value(1); | |
3395 | Handle(StepShape_AdvancedFace) AF; | |
3396 | Handle(StepShape_EdgeCurve) EC; | |
3397 | FindPDSforDGT(aGraph,ent,PDS,RC,AF,EC); | |
3398 | if(PDS.IsNull()) continue; | |
3399 | //cout<<"Model->Number(PDS)="<<Model->Number(PDS)<<endl; | |
3400 | Handle(XCAFDoc_Datum) DatumAttr; | |
3401 | if(!DatumL.FindAttribute(XCAFDoc_Datum::GetID(),DatumAttr)) continue; | |
3402 | Handle(TCollection_HAsciiString) aName = DatumAttr->GetName(); | |
3403 | Handle(TCollection_HAsciiString) aDescription = DatumAttr->GetDescription(); | |
3404 | Handle(TCollection_HAsciiString) anIdentification = DatumAttr->GetIdentification(); | |
3405 | Handle(StepDimTol_DatumFeature) DF = new StepDimTol_DatumFeature; | |
3406 | Handle(StepDimTol_Datum) aDatum = new StepDimTol_Datum; | |
3407 | DF->Init(aName, new TCollection_HAsciiString, PDS, StepData_LTrue); | |
3408 | Model->AddWithRefs(DF); | |
3409 | aDatum->Init(aName, new TCollection_HAsciiString, PDS, StepData_LFalse, anIdentification); | |
3410 | Model->AddWithRefs(aDatum); | |
3411 | Handle(StepRepr_ShapeAspectRelationship) SAR = new StepRepr_ShapeAspectRelationship; | |
3412 | SAR->SetName(aName); | |
3413 | SAR->SetRelatingShapeAspect(DF); | |
3414 | SAR->SetRelatedShapeAspect(aDatum); | |
3415 | Model->AddWithRefs(SAR); | |
3416 | // write chain for DatumFeature | |
3417 | StepRepr_CharacterizedDefinition CD; | |
3418 | CD.SetValue(DF); | |
3419 | Handle(StepRepr_PropertyDefinition) PropD = new StepRepr_PropertyDefinition; | |
3420 | PropD->Init(aName,Standard_True,aDescription,CD); | |
3421 | Model->AddWithRefs(PropD); | |
3422 | StepRepr_RepresentedDefinition RD; | |
3423 | RD.SetValue(PropD); | |
3424 | Handle(StepShape_ShapeRepresentation) SR = new StepShape_ShapeRepresentation; | |
3425 | Handle(StepRepr_HArray1OfRepresentationItem) HARI = | |
3426 | new StepRepr_HArray1OfRepresentationItem(1,1); | |
3427 | HARI->SetValue(1,AF); | |
3428 | SR->Init(aName,HARI,RC); | |
3429 | Handle(StepShape_ShapeDefinitionRepresentation) SDR = new StepShape_ShapeDefinitionRepresentation; | |
3430 | SDR->Init(RD,SR); | |
3431 | Model->AddWithRefs(SDR); | |
3432 | // write chain for Datum | |
3433 | StepRepr_CharacterizedDefinition CD1; | |
3434 | CD1.SetValue(aDatum); | |
3435 | Handle(StepRepr_PropertyDefinition) PropD1 = new StepRepr_PropertyDefinition; | |
3436 | PropD1->Init(aName,Standard_True,aDescription,CD1); | |
3437 | Model->AddWithRefs(PropD1); | |
3438 | StepRepr_RepresentedDefinition RD1; | |
3439 | RD1.SetValue(PropD1); | |
3440 | Handle(StepShape_ShapeRepresentation) SR1 = new StepShape_ShapeRepresentation; | |
3441 | Handle(StepRepr_HArray1OfRepresentationItem) HARI1 = | |
3442 | new StepRepr_HArray1OfRepresentationItem(1,1); | |
3443 | HARI1->SetValue(1,AF->FaceGeometry()); | |
3444 | SR1->Init(aName,HARI1,RC); | |
3445 | Model->AddWithRefs(SR1); | |
3446 | Handle(StepShape_ShapeDefinitionRepresentation) SDR1 = new StepShape_ShapeDefinitionRepresentation; | |
3447 | SDR1->Init(RD1,SR1); | |
3448 | Model->AddWithRefs(SDR1); | |
3449 | // add created Datum into Map | |
3450 | TCollection_AsciiString stmp(aName->ToCString()); | |
3451 | stmp.AssignCat(aDescription->ToCString()); | |
3452 | stmp.AssignCat(anIdentification->ToCString()); | |
3453 | DatumMap.Bind(stmp,aDatum); | |
3454 | } | |
3455 | ||
3456 | // write Tolerances and Dimensions | |
3457 | DGTLabels.Clear(); | |
3458 | DGTTool->GetDimTolLabels(DGTLabels); | |
3459 | if(DGTLabels.Length()<=0) return Standard_False; | |
3460 | for(i=1; i<=DGTLabels.Length(); i++) { | |
3461 | TDF_Label DimTolL = DGTLabels.Value(i); | |
9ebaae37 | 3462 | TDF_LabelSequence ShapeL; |
1c9d3225 | 3463 | TDF_LabelSequence aNullSeq; |
3464 | if(!DGTTool->GetRefShapeLabel(DimTolL,ShapeL,aNullSeq)) continue; | |
7fd59977 | 3465 | // find target shape |
9ebaae37 | 3466 | TopoDS_Shape aShape = XCAFDoc_ShapeTool::GetShape(ShapeL.Value(1)); |
7fd59977 | 3467 | TopLoc_Location Loc; |
3468 | TColStd_SequenceOfTransient seqRI; | |
3469 | FindEntities( FP, aShape, Loc, seqRI ); | |
3470 | if ( seqRI.Length() <= 0 ) { | |
3471 | FP->Messenger() << "Warning: Cannot find RI for "<<aShape.TShape()->DynamicType()->Name()<<endl; | |
3472 | continue; | |
3473 | } | |
3474 | Handle(StepRepr_ProductDefinitionShape) PDS; | |
3475 | Handle(StepRepr_RepresentationContext) RC; | |
3476 | Handle(Standard_Transient) ent = seqRI.Value(1); | |
3477 | Handle(StepShape_AdvancedFace) AF; | |
3478 | Handle(StepShape_EdgeCurve) EC; | |
3479 | FindPDSforDGT(aGraph,ent,PDS,RC,AF,EC); | |
3480 | if(PDS.IsNull()) continue; | |
3481 | //cout<<"Model->Number(PDS)="<<Model->Number(PDS)<<endl; | |
3482 | ||
3483 | Handle(XCAFDoc_DimTol) DimTolAttr; | |
3484 | if(!DimTolL.FindAttribute(XCAFDoc_DimTol::GetID(),DimTolAttr)) continue; | |
3485 | Standard_Integer kind = DimTolAttr->GetKind(); | |
3486 | Handle(TColStd_HArray1OfReal) aVal = DimTolAttr->GetVal(); | |
3487 | Handle(TCollection_HAsciiString) aName = DimTolAttr->GetName(); | |
3488 | Handle(TCollection_HAsciiString) aDescription = DimTolAttr->GetDescription(); | |
3489 | ||
3490 | // common part of writing D> entities | |
3491 | StepRepr_CharacterizedDefinition CD; | |
3492 | Handle(StepRepr_ShapeAspect) SA = new StepRepr_ShapeAspect; | |
3493 | SA->Init(aName, new TCollection_HAsciiString, PDS, StepData_LTrue); | |
3494 | Model->AddWithRefs(SA); | |
3495 | CD.SetValue(SA); | |
3496 | Handle(StepRepr_PropertyDefinition) PropD = new StepRepr_PropertyDefinition; | |
3497 | PropD->Init(aName,Standard_True,aDescription,CD); | |
3498 | Model->AddWithRefs(PropD); | |
3499 | StepRepr_RepresentedDefinition RD; | |
3500 | RD.SetValue(PropD); | |
3501 | Handle(StepShape_ShapeRepresentation) SR = new StepShape_ShapeRepresentation; | |
3502 | Handle(StepRepr_HArray1OfRepresentationItem) HARI = | |
3503 | new StepRepr_HArray1OfRepresentationItem(1,1); | |
3504 | if(kind<20) | |
3505 | HARI->SetValue(1,EC); | |
3506 | else | |
3507 | HARI->SetValue(1,AF); | |
3508 | SR->Init(aName,HARI,RC); | |
3509 | Handle(StepShape_ShapeDefinitionRepresentation) SDR = new StepShape_ShapeDefinitionRepresentation; | |
3510 | SDR->Init(RD,SR); | |
3511 | Model->AddWithRefs(SDR); | |
3512 | // define aUnit for creation LengthMeasureWithUnit (common for all) | |
3513 | StepBasic_Unit aUnit; | |
3514 | Handle(StepBasic_SiUnitAndLengthUnit) SLU; | |
3515 | Handle(StepGeom_GeometricRepresentationContextAndGlobalUnitAssignedContext) Ctx = | |
3516 | Handle(StepGeom_GeometricRepresentationContextAndGlobalUnitAssignedContext)::DownCast(RC); | |
3517 | if(!Ctx.IsNull()) { | |
3518 | for(Standard_Integer j=1; j<=Ctx->NbUnits(); j++) { | |
3519 | if(Ctx->UnitsValue(j)->IsKind(STANDARD_TYPE(StepBasic_SiUnitAndLengthUnit))) { | |
3520 | SLU = Handle(StepBasic_SiUnitAndLengthUnit)::DownCast(Ctx->UnitsValue(j)); | |
3521 | break; | |
3522 | } | |
3523 | } | |
3524 | } | |
3525 | if(SLU.IsNull()) { | |
3526 | Handle(StepGeom_GeomRepContextAndGlobUnitAssCtxAndGlobUncertaintyAssCtx) Ctx1 = | |
3527 | Handle(StepGeom_GeomRepContextAndGlobUnitAssCtxAndGlobUncertaintyAssCtx)::DownCast(RC); | |
3528 | if(!Ctx1.IsNull()) { | |
3529 | for(Standard_Integer j=1; j<=Ctx1->NbUnits(); j++) { | |
3530 | if(Ctx1->UnitsValue(j)->IsKind(STANDARD_TYPE(StepBasic_SiUnitAndLengthUnit))) { | |
3531 | SLU = Handle(StepBasic_SiUnitAndLengthUnit)::DownCast(Ctx1->UnitsValue(j)); | |
3532 | break; | |
3533 | } | |
3534 | } | |
3535 | } | |
3536 | } | |
3537 | if(SLU.IsNull()) { | |
3538 | SLU = new StepBasic_SiUnitAndLengthUnit; | |
3539 | } | |
3540 | aUnit.SetValue(SLU); | |
3541 | ||
3542 | // specific part of writing D> entities | |
3543 | if(kind<20) { //dimension | |
3544 | Handle(StepShape_DimensionalSize) DimSize = new StepShape_DimensionalSize; | |
3545 | DimSize->Init(SA,aDescription); | |
3546 | Model->AddWithRefs(DimSize); | |
3547 | if(aVal->Length()>1) { | |
3548 | // create MeasureWithUnits | |
3549 | Handle(StepBasic_MeasureValueMember) MVM1 = new StepBasic_MeasureValueMember; | |
3550 | MVM1->SetName("POSITIVE_LENGTH_MEASURE"); | |
3551 | MVM1->SetReal(aVal->Value(1)); | |
3552 | Handle(StepBasic_MeasureWithUnit) MWU1 = new StepBasic_MeasureWithUnit; | |
3553 | MWU1->Init(MVM1,aUnit); | |
3554 | Handle(StepBasic_MeasureValueMember) MVM2 = new StepBasic_MeasureValueMember; | |
3555 | MVM2->SetName("POSITIVE_LENGTH_MEASURE"); | |
3556 | MVM2->SetReal(aVal->Value(2)); | |
3557 | Handle(StepBasic_MeasureWithUnit) MWU2 = new StepBasic_MeasureWithUnit; | |
3558 | MWU2->Init(MVM2,aUnit); | |
3559 | Handle(StepRepr_RepresentationItem) RI1 = new StepRepr_RepresentationItem; | |
3560 | RI1->Init(new TCollection_HAsciiString("lower limit")); | |
3561 | Handle(StepRepr_RepresentationItem) RI2 = new StepRepr_RepresentationItem; | |
3562 | RI2->Init(new TCollection_HAsciiString("upper limit")); | |
3563 | Handle(StepRepr_ReprItemAndLengthMeasureWithUnit) RILMU1 = | |
3564 | new StepRepr_ReprItemAndLengthMeasureWithUnit; | |
3565 | RILMU1->Init(MWU1,RI1); | |
3566 | Handle(StepRepr_ReprItemAndLengthMeasureWithUnit) RILMU2 = | |
3567 | new StepRepr_ReprItemAndLengthMeasureWithUnit; | |
3568 | RILMU2->Init(MWU2,RI2); | |
3569 | Model->AddWithRefs(RILMU1); | |
3570 | Model->AddWithRefs(RILMU2); | |
3571 | //Handle(StepRepr_CompoundItemDefinitionMember) CIDM = | |
3572 | // new StepRepr_CompoundItemDefinitionMember; | |
3573 | //Handle(TColStd_HArray1OfTransient) ArrTr = new TColStd_HArray1OfTransient(1,2); | |
3574 | //ArrTr->SetValue(1,RILMU1); | |
3575 | //ArrTr->SetValue(2,RILMU2); | |
3576 | //CIDM->SetArrTransient(ArrTr); | |
3577 | //CIDM->SetName("SET_REPRESENTATION_ITEM"); | |
3578 | //StepRepr_CompoundItemDefinition CID; | |
3579 | //CID.SetValue(CIDM); | |
3580 | Handle(StepRepr_HArray1OfRepresentationItem) HARIVR = | |
3581 | new StepRepr_HArray1OfRepresentationItem(1,2); | |
3582 | HARIVR->SetValue(1,RILMU1); | |
3583 | HARIVR->SetValue(2,RILMU2); | |
3584 | Handle(StepRepr_ValueRange) VR = new StepRepr_ValueRange; | |
3585 | //VR->Init(aName,CID); | |
3586 | VR->Init(aName,HARIVR); | |
3587 | Model->AddEntity(VR); | |
3588 | Handle(StepShape_ShapeDimensionRepresentation) SDimR = | |
3589 | new StepShape_ShapeDimensionRepresentation; | |
51740958 | 3590 | Handle(StepRepr_HArray1OfRepresentationItem) aHARI = |
7fd59977 | 3591 | new StepRepr_HArray1OfRepresentationItem(1,1); |
51740958 | 3592 | aHARI->SetValue(1,VR); |
3593 | SDimR->Init(aName,aHARI,RC); | |
7fd59977 | 3594 | Model->AddWithRefs(SDimR); |
3595 | Handle(StepShape_DimensionalCharacteristicRepresentation) DimCharR = | |
3596 | new StepShape_DimensionalCharacteristicRepresentation; | |
3597 | StepShape_DimensionalCharacteristic DimChar; | |
3598 | DimChar.SetValue(DimSize); | |
3599 | DimCharR->Init(DimChar,SDimR); | |
3600 | Model->AddEntity(DimCharR); | |
3601 | } | |
3602 | } | |
3603 | else if(kind<50) { //tolerance | |
3604 | if(kind<35) { // tolerance with datum system | |
3605 | TDF_LabelSequence DatumLabels; | |
9ebaae37 | 3606 | DGTTool->GetDatumOfTolerLabels(DimTolL,DatumLabels); |
7fd59977 | 3607 | Standard_Integer NbDR = DatumLabels.Length(); |
3608 | Handle(StepDimTol_HArray1OfDatumReference) HADR = new StepDimTol_HArray1OfDatumReference(1,NbDR); | |
3609 | for(Standard_Integer j=1; j<=NbDR; j++) { | |
3610 | Handle(XCAFDoc_Datum) DatumAttr; | |
3611 | TDF_Label DatumL = DatumLabels.Value(j); | |
3612 | if(!DatumL.FindAttribute(XCAFDoc_Datum::GetID(),DatumAttr)) continue; | |
3613 | Handle(TCollection_HAsciiString) aNameD = DatumAttr->GetName(); | |
3614 | Handle(TCollection_HAsciiString) aDescriptionD = DatumAttr->GetDescription(); | |
3615 | Handle(TCollection_HAsciiString) anIdentificationD = DatumAttr->GetIdentification(); | |
3616 | TCollection_AsciiString stmp(aNameD->ToCString()); | |
3617 | stmp.AssignCat(aDescriptionD->ToCString()); | |
3618 | stmp.AssignCat(anIdentificationD->ToCString()); | |
3619 | if(DatumMap.IsBound(stmp)) { | |
3620 | Handle(StepDimTol_Datum) aDatum = | |
3621 | Handle(StepDimTol_Datum)::DownCast(DatumMap.Find(stmp)); | |
3622 | Handle(StepDimTol_DatumReference) DR = new StepDimTol_DatumReference; | |
3623 | DR->Init(j,aDatum); | |
3624 | Model->AddWithRefs(DR); | |
3625 | HADR->SetValue(j,DR); | |
3626 | } | |
3627 | } | |
3628 | // create LengthMeasureWithUnit | |
3629 | Handle(StepBasic_MeasureValueMember) MVM = new StepBasic_MeasureValueMember; | |
3630 | MVM->SetName("LENGTH_MEASURE"); | |
3631 | MVM->SetReal(aVal->Value(1)); | |
3632 | Handle(StepBasic_LengthMeasureWithUnit) LMWU = new StepBasic_LengthMeasureWithUnit; | |
3633 | LMWU->Init(MVM,aUnit); | |
3634 | // create tolerance by it's type | |
3635 | if(kind<24) { | |
3636 | Handle(StepDimTol_GeometricToleranceWithDatumReference) GTWDR = | |
3637 | new StepDimTol_GeometricToleranceWithDatumReference; | |
3638 | GTWDR->SetDatumSystem(HADR); | |
3639 | Handle(StepDimTol_ModifiedGeometricTolerance) MGT = | |
3640 | new StepDimTol_ModifiedGeometricTolerance; | |
3641 | if(kind==21) MGT->SetModifier(StepDimTol_MaximumMaterialCondition); | |
3642 | else if(kind==22) MGT->SetModifier(StepDimTol_LeastMaterialCondition); | |
3643 | else if(kind==23) MGT->SetModifier(StepDimTol_RegardlessOfFeatureSize); | |
3644 | Handle(StepDimTol_GeoTolAndGeoTolWthDatRefAndModGeoTolAndPosTol) GTComplex = | |
3645 | new StepDimTol_GeoTolAndGeoTolWthDatRefAndModGeoTolAndPosTol; | |
3646 | GTComplex->Init(aName,aDescription,LMWU,SA,GTWDR,MGT); | |
3647 | Model->AddWithRefs(GTComplex); | |
3648 | } | |
3649 | else if(kind==24) { | |
3650 | Handle(StepDimTol_AngularityTolerance) aToler = | |
3651 | new StepDimTol_AngularityTolerance; | |
3652 | aToler->Init(aName,aDescription,LMWU,SA,HADR); | |
3653 | Model->AddWithRefs(aToler); | |
3654 | } | |
3655 | else if(kind==25) { | |
3656 | Handle(StepDimTol_CircularRunoutTolerance) aToler = | |
3657 | new StepDimTol_CircularRunoutTolerance; | |
3658 | aToler->Init(aName,aDescription,LMWU,SA,HADR); | |
3659 | Model->AddWithRefs(aToler); | |
3660 | } | |
3661 | else if(kind==26) { | |
3662 | Handle(StepDimTol_CoaxialityTolerance) aToler = | |
3663 | new StepDimTol_CoaxialityTolerance; | |
3664 | aToler->Init(aName,aDescription,LMWU,SA,HADR); | |
3665 | Model->AddWithRefs(aToler); | |
3666 | } | |
3667 | else if(kind==27) { | |
3668 | Handle(StepDimTol_ConcentricityTolerance) aToler = | |
3669 | new StepDimTol_ConcentricityTolerance; | |
3670 | aToler->Init(aName,aDescription,LMWU,SA,HADR); | |
3671 | Model->AddWithRefs(aToler); | |
3672 | } | |
3673 | else if(kind==28) { | |
3674 | Handle(StepDimTol_ParallelismTolerance) aToler = | |
3675 | new StepDimTol_ParallelismTolerance; | |
3676 | aToler->Init(aName,aDescription,LMWU,SA,HADR); | |
3677 | Model->AddWithRefs(aToler); | |
3678 | } | |
3679 | else if(kind==29) { | |
3680 | Handle(StepDimTol_PerpendicularityTolerance) aToler = | |
3681 | new StepDimTol_PerpendicularityTolerance; | |
3682 | aToler->Init(aName,aDescription,LMWU,SA,HADR); | |
3683 | Model->AddWithRefs(aToler); | |
3684 | } | |
3685 | else if(kind==30) { | |
3686 | Handle(StepDimTol_SymmetryTolerance) aToler = | |
3687 | new StepDimTol_SymmetryTolerance; | |
3688 | aToler->Init(aName,aDescription,LMWU,SA,HADR); | |
3689 | Model->AddWithRefs(aToler); | |
3690 | } | |
3691 | else if(kind==31) { | |
3692 | Handle(StepDimTol_TotalRunoutTolerance) aToler = | |
3693 | new StepDimTol_TotalRunoutTolerance; | |
3694 | aToler->Init(aName,aDescription,LMWU,SA,HADR); | |
3695 | Model->AddWithRefs(aToler); | |
3696 | } | |
3697 | } | |
3698 | } | |
3699 | } | |
3700 | ||
3701 | return Standard_True; | |
3702 | } | |
3703 | ||
6595eee7 | 3704 | //======================================================================= |
3705 | //function : WriteDGTsAP242 | |
3706 | //purpose : | |
3707 | //======================================================================= | |
3708 | ||
3709 | Standard_Boolean STEPCAFControl_Writer::WriteDGTsAP242 (const Handle(XSControl_WorkSession) &WS, | |
1209c1b9 | 3710 | const TDF_LabelSequence &labels ) |
6595eee7 | 3711 | { |
3712 | // Get working data | |
7f56eba8 | 3713 | const Handle(Interface_InterfaceModel) &aModel = WS->Model(); |
6595eee7 | 3714 | |
3715 | const Handle(Interface_HGraph) aHGraph = WS->HGraph(); | |
3716 | if(aHGraph.IsNull()) | |
3717 | return Standard_False; | |
3718 | ||
3719 | Interface_Graph aGraph = aHGraph->Graph(); | |
3720 | Handle(XCAFDoc_DimTolTool) DGTTool = XCAFDoc_DocumentTool::DimTolTool(labels(1)); | |
3721 | if(DGTTool.IsNull()) | |
3722 | return Standard_False; | |
3723 | ||
b0cef606 | 3724 | // Common entities for presentation |
b0cef606 | 3725 | STEPConstruct_Styles aStyles (WS); |
3726 | Handle(StepVisual_Colour) aCurvColor = aStyles.EncodeColor(Quantity_NOC_WHITE); | |
3727 | Handle(StepRepr_RepresentationItem) anItem = NULL; | |
1209c1b9 | 3728 | myGDTPrsCurveStyle->SetValue(1, aStyles.MakeColorPSA(anItem, aCurvColor, aCurvColor)); |
400af1bc | 3729 | Interface_EntityIterator aModelIter = aModel->Entities(); |
1209c1b9 | 3730 | for (; aModelIter.More() && myGDTCommonPDS.IsNull(); aModelIter.Next()) |
3731 | myGDTCommonPDS = Handle(StepRepr_ProductDefinitionShape)::DownCast(aModelIter.Value()); | |
b0cef606 | 3732 | |
6595eee7 | 3733 | TDF_LabelSequence aDGTLabels; |
3734 | STEPConstruct_DataMapOfAsciiStringTransient aDatumMap; | |
3735 | Handle(StepRepr_RepresentationContext) aRC; | |
3736 | ||
3737 | //------------- // | |
3738 | // write Datums // | |
3739 | //--------------// | |
3740 | DGTTool->GetDatumLabels(aDGTLabels); | |
3741 | // Find all shapes with datums | |
3742 | TColStd_MapOfAsciiString aNameIdMap; | |
3743 | for(Standard_Integer i = 1; i <= aDGTLabels.Length(); i++) { | |
3744 | TDF_Label aDatumL = aDGTLabels.Value(i); | |
400af1bc | 3745 | TDF_LabelSequence aShapeL, aNullSeq; |
3746 | DGTTool->GetRefShapeLabel(aDatumL, aShapeL, aNullSeq); | |
6595eee7 | 3747 | Handle(XCAFDoc_Datum) aDatumAttr; |
3748 | aDatumL.FindAttribute(XCAFDoc_Datum::GetID(), aDatumAttr); | |
3749 | Handle(XCAFDimTolObjects_DatumObject) anObject = aDatumAttr->GetObject(); | |
3750 | TCollection_AsciiString aDatumName = anObject->GetName()->String(); | |
3751 | TCollection_AsciiString aDatumTargetId = TCollection_AsciiString(anObject->GetDatumTargetNumber()); | |
3752 | if (!aNameIdMap.Add(aDatumName.Cat(aDatumTargetId))) | |
3753 | continue; | |
aa00364d | 3754 | Handle(Standard_Transient) aWrittenDatum; |
6595eee7 | 3755 | Standard_Boolean isFirstDT = !aDatumMap.Find(aDatumName, aWrittenDatum); |
400af1bc | 3756 | Handle(StepDimTol_Datum) aDatum = WriteDatumAP242(WS, aShapeL, aDatumL, isFirstDT, |
aa00364d | 3757 | Handle(StepDimTol_Datum)::DownCast (aWrittenDatum)); |
6595eee7 | 3758 | // Add created Datum into Map |
3759 | aDatumMap.Bind(aDatumName, aDatum); | |
3760 | } | |
3761 | ||
3762 | //----------------- // | |
3763 | // write Dimensions // | |
3764 | //------------------// | |
3765 | aDGTLabels.Clear(); | |
3766 | DGTTool->GetDimensionLabels(aDGTLabels); | |
b7b2f85a | 3767 | // Auxiliary entities for derived geometry |
3768 | Handle(StepRepr_ConstructiveGeometryRepresentation) aCGRepr = | |
3769 | new StepRepr_ConstructiveGeometryRepresentation(); | |
3770 | Handle(StepRepr_ConstructiveGeometryRepresentationRelationship) aCGReprRel = | |
3771 | new StepRepr_ConstructiveGeometryRepresentationRelationship(); | |
3772 | NCollection_Vector<Handle(StepGeom_CartesianPoint)> aConnectionPnts; | |
3773 | Handle(StepRepr_RepresentationContext) dummyRC; | |
3774 | Handle(StepAP242_GeometricItemSpecificUsage) dummyGISU; | |
6595eee7 | 3775 | for (Standard_Integer i = 1; i <= aDGTLabels.Length(); i++) { |
3776 | TDF_Label aDimensionL = aDGTLabels.Value(i); | |
3777 | TDF_LabelSequence aFirstShapeL, aSecondShapeL; | |
6595eee7 | 3778 | Handle(XCAFDoc_Dimension) aDimAttr; |
3779 | if (!aDimensionL.FindAttribute(XCAFDoc_Dimension::GetID(),aDimAttr)) | |
3780 | continue; | |
3781 | Handle(XCAFDimTolObjects_DimensionObject) anObject = aDimAttr->GetObject(); | |
3782 | if (anObject.IsNull()) | |
3783 | continue; | |
0b622d67 | 3784 | if (anObject->GetType() == XCAFDimTolObjects_DimensionType_CommonLabel) |
3785 | { | |
1209c1b9 | 3786 | Handle(StepRepr_ShapeAspect) aSA = new StepRepr_ShapeAspect(); |
3787 | aSA->Init(new TCollection_HAsciiString(), new TCollection_HAsciiString(), myGDTCommonPDS, StepData_LTrue); | |
3788 | aModel->AddWithRefs(aSA); | |
3789 | WritePresentation(WS, anObject->GetPresentation(), anObject->GetPresentationName(), anObject->HasPlane(), | |
3790 | Standard_False, anObject->GetPlane(), anObject->GetPointTextAttach(), aSA); | |
0b622d67 | 3791 | } |
3792 | ||
3793 | if (!DGTTool->GetRefShapeLabel(aDimensionL, aFirstShapeL, aSecondShapeL)) | |
3794 | continue; | |
6595eee7 | 3795 | |
3796 | // Write links with shapes | |
6595eee7 | 3797 | Handle(StepRepr_ShapeAspect) aFirstSA, aSecondSA; |
3798 | if (aFirstShapeL.Length() == 1) { | |
3799 | TopoDS_Shape aShape = XCAFDoc_ShapeTool::GetShape(aFirstShapeL.Value(1)); | |
3800 | aFirstSA = WriteShapeAspect(WS, aDimensionL, aShape, dummyRC, dummyGISU); | |
3801 | if (aRC.IsNull() && !dummyRC.IsNull()) | |
3802 | aRC = dummyRC; | |
3803 | } | |
3804 | else if (aFirstShapeL.Length() > 1) { | |
3805 | Handle(StepRepr_CompositeShapeAspect) aCSA; | |
3806 | for (Standard_Integer shIt = 1; shIt <= aFirstShapeL.Length(); shIt++) { | |
3807 | TopoDS_Shape aShape = XCAFDoc_ShapeTool::GetShape(aFirstShapeL.Value(shIt)); | |
3808 | Handle(StepRepr_ShapeAspect) aSA = WriteShapeAspect(WS, aDimensionL, aShape, dummyRC, dummyGISU); | |
f3ec3b37 | 3809 | if (aSA.IsNull()) |
3810 | continue; | |
3811 | if (aCSA.IsNull()) { | |
6595eee7 | 3812 | aCSA = new StepRepr_CompositeShapeAspect(); |
3813 | aCSA->Init(aSA->Name(), aSA->Description(), aSA->OfShape(), aSA->ProductDefinitional()); | |
3814 | aModel->AddWithRefs(aCSA); | |
6595eee7 | 3815 | } |
f3ec3b37 | 3816 | Handle(StepRepr_ShapeAspectRelationship) aSAR = new StepRepr_ShapeAspectRelationship(); |
3817 | aSAR->Init(new TCollection_HAsciiString(), Standard_False, new TCollection_HAsciiString(), aCSA, aSA); | |
3818 | aModel->AddWithRefs(aSAR); | |
6595eee7 | 3819 | if (aRC.IsNull() && !dummyRC.IsNull()) |
3820 | aRC = dummyRC; | |
3821 | } | |
3822 | aFirstSA = aCSA; | |
3823 | } | |
3824 | if (aSecondShapeL.Length() == 1) { | |
3825 | TopoDS_Shape aShape = XCAFDoc_ShapeTool::GetShape(aSecondShapeL.Value(1)); | |
3826 | aSecondSA = WriteShapeAspect(WS, aDimensionL, aShape, dummyRC, dummyGISU); | |
3827 | if (aRC.IsNull() && !dummyRC.IsNull()) | |
3828 | aRC = dummyRC; | |
3829 | } | |
3830 | else if (aSecondShapeL.Length() > 1) { | |
3831 | Handle(StepRepr_CompositeShapeAspect) aCSA; | |
3832 | for (Standard_Integer shIt = 1; shIt <= aSecondShapeL.Length(); shIt++) { | |
3833 | TopoDS_Shape aShape = XCAFDoc_ShapeTool::GetShape(aSecondShapeL.Value(shIt)); | |
3834 | Handle(StepRepr_ShapeAspect) aSA = WriteShapeAspect(WS, aDimensionL, aShape, dummyRC, dummyGISU); | |
3835 | if (aCSA.IsNull() && !aSA.IsNull()) | |
c48e2889 | 3836 | { |
6595eee7 | 3837 | aCSA = new StepRepr_CompositeShapeAspect(); |
c48e2889 | 3838 | } |
3839 | aCSA->Init(aSA->Name(), aSA->Description(), aSA->OfShape(), aSA->ProductDefinitional()); | |
6595eee7 | 3840 | if (!aSA.IsNull()) { |
3841 | Handle(StepRepr_ShapeAspectRelationship) aSAR = new StepRepr_ShapeAspectRelationship(); | |
3842 | aSAR->Init(new TCollection_HAsciiString(), Standard_False, new TCollection_HAsciiString(), aCSA, aSA); | |
3843 | aModel->AddWithRefs(aSAR); | |
3844 | } | |
3845 | if (aRC.IsNull() && !dummyRC.IsNull()) | |
3846 | aRC = dummyRC; | |
3847 | } | |
3848 | aSecondSA = aCSA; | |
3849 | } | |
3850 | ||
1209c1b9 | 3851 | if (anObject->GetType() == XCAFDimTolObjects_DimensionType_DimensionPresentation) |
3852 | { | |
3853 | WritePresentation(WS, anObject->GetPresentation(), anObject->GetPresentationName(), anObject->HasPlane(), | |
3854 | Standard_False, anObject->GetPlane(), anObject->GetPointTextAttach(), aFirstSA); | |
3855 | continue; | |
3856 | } | |
3857 | ||
6595eee7 | 3858 | // Write dimensions |
3859 | StepShape_DimensionalCharacteristic aDimension; | |
b7b2f85a | 3860 | if (anObject->HasPoint() || anObject->HasPoint2()) |
3861 | WriteDerivedGeometry(WS, anObject, aCGRepr, aFirstSA, aSecondSA, aConnectionPnts); | |
6595eee7 | 3862 | XCAFDimTolObjects_DimensionType aDimType = anObject->GetType(); |
727b5ad9 | 3863 | if (STEPCAFControl_GDTProperty::IsDimensionalLocation(aDimType)) { |
6595eee7 | 3864 | // Dimensional_Location |
3865 | Handle(StepShape_DimensionalLocation) aDim = new StepShape_DimensionalLocation(); | |
727b5ad9 | 3866 | aDim->Init(STEPCAFControl_GDTProperty::GetDimTypeName(aDimType), Standard_False, NULL, aFirstSA, aSecondSA); |
6595eee7 | 3867 | aDimension.SetValue(aDim); |
3868 | } | |
3869 | else if (aDimType == XCAFDimTolObjects_DimensionType_Location_Angular) { | |
3870 | // Angular_Location | |
3871 | Handle(StepShape_AngularLocation) aDim = new StepShape_AngularLocation(); | |
3872 | StepShape_AngleRelator aRelator = StepShape_Equal; | |
3873 | if (anObject->HasQualifier()) { | |
3874 | XCAFDimTolObjects_DimensionQualifier aQualifier = anObject->GetQualifier(); | |
3875 | switch (aQualifier) { | |
3876 | case XCAFDimTolObjects_DimensionQualifier_Min: aRelator = StepShape_Small; | |
3877 | break; | |
3878 | case XCAFDimTolObjects_DimensionQualifier_Max: aRelator = StepShape_Large; | |
3879 | break; | |
3880 | default: aRelator = StepShape_Equal; | |
3881 | } | |
3882 | } | |
3883 | aDim->Init(new TCollection_HAsciiString(), Standard_False, NULL, aFirstSA, aSecondSA, aRelator); | |
3884 | aDimension.SetValue(aDim); | |
3885 | } | |
3886 | else if (aDimType == XCAFDimTolObjects_DimensionType_Location_WithPath) { | |
3887 | // Dimensional_Location_With_Path | |
3888 | Handle(StepShape_DimensionalLocationWithPath) aDim = new StepShape_DimensionalLocationWithPath(); | |
3889 | Handle(StepRepr_ShapeAspect) aPathSA = WriteShapeAspect(WS, aDimensionL, anObject->GetPath(), dummyRC, dummyGISU); | |
3890 | aDim->Init(new TCollection_HAsciiString(), Standard_False, NULL, aFirstSA, aSecondSA, aPathSA); | |
3891 | aDimension.SetValue(aDim); | |
3892 | } | |
727b5ad9 | 3893 | else if (STEPCAFControl_GDTProperty::IsDimensionalSize(aDimType)) { |
6595eee7 | 3894 | // Dimensional_Size |
3895 | Handle(StepShape_DimensionalSize) aDim = new StepShape_DimensionalSize(); | |
727b5ad9 | 3896 | aDim->Init(aFirstSA, STEPCAFControl_GDTProperty::GetDimTypeName(aDimType)); |
6595eee7 | 3897 | aDimension.SetValue(aDim); |
3898 | } | |
3899 | else if (aDimType == XCAFDimTolObjects_DimensionType_Size_Angular) { | |
3900 | // Angular_Size | |
3901 | Handle(StepShape_AngularSize) aDim = new StepShape_AngularSize(); | |
3902 | StepShape_AngleRelator aRelator = StepShape_Equal; | |
3903 | if (anObject->HasQualifier()) { | |
3904 | XCAFDimTolObjects_DimensionQualifier aQualifier = anObject->GetQualifier(); | |
3905 | switch (aQualifier) { | |
3906 | case XCAFDimTolObjects_DimensionQualifier_Min: aRelator = StepShape_Small; | |
3907 | break; | |
3908 | case XCAFDimTolObjects_DimensionQualifier_Max: aRelator = StepShape_Large; | |
3909 | break; | |
3910 | default: aRelator = StepShape_Equal; | |
3911 | } | |
3912 | } | |
3913 | aDim->Init(aFirstSA, new TCollection_HAsciiString(), aRelator); | |
3914 | aDimension.SetValue(aDim); | |
3915 | } | |
3916 | else if (aDimType == XCAFDimTolObjects_DimensionType_Size_WithPath) { | |
3917 | // Dimensional_Size_With_Path | |
3918 | Handle(StepShape_DimensionalSizeWithPath) aDim = new StepShape_DimensionalSizeWithPath(); | |
3919 | Handle(StepRepr_ShapeAspect) aPathSA = WriteShapeAspect(WS, aDimensionL, anObject->GetPath(), dummyRC, dummyGISU); | |
3920 | aDim->Init(aFirstSA, new TCollection_HAsciiString(), aPathSA); | |
3921 | aDimension.SetValue(aDim); | |
3922 | } | |
3923 | ||
3924 | // Write values | |
3925 | WriteDimValues(WS, anObject, aRC, aDimension); | |
b0cef606 | 3926 | //Annotation plane and Presentation |
1209c1b9 | 3927 | WritePresentation(WS, anObject->GetPresentation(), anObject->GetPresentationName(), Standard_True, anObject->HasPlane(), |
3928 | anObject->GetPlane(), anObject->GetPointTextAttach(), aDimension.Value()); | |
6595eee7 | 3929 | } |
b7b2f85a | 3930 | // Write Derived geometry |
3931 | if (aConnectionPnts.Length() > 0) { | |
3932 | Handle(StepRepr_HArray1OfRepresentationItem) anItems = new StepRepr_HArray1OfRepresentationItem(1, aConnectionPnts.Length()); | |
3933 | for (Standard_Integer i = 0; i < aConnectionPnts.Length(); i++) | |
3934 | anItems->SetValue(i + 1, aConnectionPnts(i)); | |
3935 | aCGRepr->Init(new TCollection_HAsciiString(), anItems, dummyRC); | |
3936 | aCGReprRel->Init(new TCollection_HAsciiString(), new TCollection_HAsciiString(), dummyGISU->UsedRepresentation(), aCGRepr); | |
3937 | aModel->AddWithRefs(aCGReprRel); | |
3938 | } | |
6595eee7 | 3939 | |
3940 | //----------------------------// | |
3941 | // write Geometric Tolerances // | |
3942 | //----------------------------// | |
3943 | aDGTLabels.Clear(); | |
3944 | DGTTool->GetGeomToleranceLabels(aDGTLabels); | |
3945 | for (Standard_Integer i = 1; i <= aDGTLabels.Length(); i++) { | |
3946 | TDF_Label aGeomTolL = aDGTLabels.Value(i); | |
3947 | TDF_LabelSequence aFirstShapeL, aNullSeqL; | |
3948 | if (!DGTTool->GetRefShapeLabel(aGeomTolL, aFirstShapeL, aNullSeqL)) | |
3949 | continue; | |
3950 | TDF_LabelSequence aDatumSeq; | |
3951 | DGTTool->GetDatumWithObjectOfTolerLabels(aGeomTolL, aDatumSeq); | |
3952 | Handle(StepDimTol_HArray1OfDatumSystemOrReference) aDatumSystem; | |
3953 | if (aDatumSeq.Length() > 0) | |
3954 | aDatumSystem = WriteDatumSystem(WS, aGeomTolL, aDatumSeq, aDatumMap, aRC); | |
3955 | WriteGeomTolerance(WS, aFirstShapeL, aGeomTolL, aDatumSystem, aRC); | |
3956 | } | |
3957 | ||
b0cef606 | 3958 | // Write Draughting model for Annotation Planes |
1209c1b9 | 3959 | if (myGDTAnnotations.Length() == 0) |
b0cef606 | 3960 | return Standard_True; |
3961 | ||
3962 | Handle(StepRepr_HArray1OfRepresentationItem) aItems = | |
1209c1b9 | 3963 | new StepRepr_HArray1OfRepresentationItem(1, myGDTAnnotations.Length()); |
b0cef606 | 3964 | for (Standard_Integer i = 1; i <= aItems->Length(); i++) { |
1209c1b9 | 3965 | aItems->SetValue(i, myGDTAnnotations.Value(i - 1)); |
b0cef606 | 3966 | } |
1209c1b9 | 3967 | myGDTPresentationDM->Init(new TCollection_HAsciiString(), aItems, aRC); |
3968 | aModel->AddWithRefs(myGDTPresentationDM); | |
b0cef606 | 3969 | |
6595eee7 | 3970 | return Standard_True; |
3971 | } | |
7fd59977 | 3972 | |
3973 | //======================================================================= | |
3974 | //function : FindPDSforRI | |
3975 | //purpose : auxilary: | |
3976 | //======================================================================= | |
3977 | static Standard_Boolean FindPDSforRI(const Interface_Graph &aGraph, | |
3978 | const Handle(Standard_Transient) &ent, | |
3979 | Handle(StepRepr_ProductDefinitionShape) &PDS, | |
3980 | Handle(StepRepr_RepresentationContext) &RC) | |
3981 | { | |
aff18753 | 3982 | if(ent.IsNull() || !ent->IsKind(STANDARD_TYPE(StepRepr_RepresentationItem))) |
3983 | return Standard_False; | |
7fd59977 | 3984 | Interface_EntityIterator subs = aGraph.Sharings(ent); |
3985 | for(subs.Start(); subs.More() && PDS.IsNull(); subs.Next()) { | |
3986 | Handle(StepShape_ShapeRepresentation) SR = | |
3987 | Handle(StepShape_ShapeRepresentation)::DownCast(subs.Value()); | |
3988 | if(SR.IsNull()) continue; | |
3989 | RC = SR->ContextOfItems(); | |
3990 | Interface_EntityIterator subs1 = aGraph.Sharings(SR); | |
3991 | for(subs1.Start(); subs1.More() && PDS.IsNull(); subs1.Next()) { | |
3992 | Handle(StepShape_ShapeDefinitionRepresentation) SDR = | |
3993 | Handle(StepShape_ShapeDefinitionRepresentation)::DownCast(subs1.Value()); | |
3994 | if(SDR.IsNull()) continue; | |
3995 | Handle(StepRepr_PropertyDefinition) PropD = SDR->Definition().PropertyDefinition(); | |
3996 | if(PropD.IsNull()) continue; | |
3997 | PDS = Handle(StepRepr_ProductDefinitionShape)::DownCast(PropD); | |
3998 | } | |
3999 | } | |
4000 | return Standard_True; | |
4001 | } | |
4002 | ||
4003 | ||
4004 | //======================================================================= | |
4005 | //function : WriteMaterials | |
4006 | //purpose : | |
4007 | //======================================================================= | |
4008 | ||
4009 | Standard_Boolean STEPCAFControl_Writer::WriteMaterials (const Handle(XSControl_WorkSession) &WS, | |
4010 | const TDF_LabelSequence &labels ) const | |
4011 | { | |
4012 | ||
4013 | if ( labels.Length() <=0 ) return Standard_False; | |
4014 | ||
4015 | // get working data | |
7f56eba8 | 4016 | const Handle(Interface_InterfaceModel) &Model = WS->Model(); |
4017 | const Handle(XSControl_TransferWriter) &TW = WS->TransferWriter(); | |
4018 | const Handle(Transfer_FinderProcess) &FP = TW->FinderProcess(); | |
9e20ed57 | 4019 | |
4020 | const Handle(Interface_HGraph) aHGraph = WS->HGraph(); | |
4021 | if(aHGraph.IsNull()) | |
4022 | return Standard_False; | |
4023 | ||
7fd59977 | 4024 | Interface_Graph aGraph = WS->HGraph()->Graph(); |
4025 | Handle(XCAFDoc_ShapeTool) ShTool = XCAFDoc_DocumentTool::ShapeTool( labels(1) ); | |
4026 | if(ShTool.IsNull() ) return Standard_False; | |
4027 | Handle(XCAFDoc_MaterialTool) MatTool = XCAFDoc_DocumentTool::MaterialTool( labels(1) ); | |
4028 | if(MatTool.IsNull() ) return Standard_False; | |
4029 | ||
4030 | STEPConstruct_DataMapOfAsciiStringTransient MapDRI,MapMRI; | |
4031 | TDF_LabelSequence TopLabels; | |
4032 | ShTool->GetShapes(TopLabels); | |
4033 | for(Standard_Integer i=1; i<=TopLabels.Length(); i++) { | |
4034 | TDF_Label ShL = TopLabels.Value(i); | |
4035 | Handle(TDataStd_TreeNode) Node; | |
4036 | if( ShL.FindAttribute(XCAFDoc::MaterialRefGUID(),Node) && Node->HasFather() ) { | |
4037 | // find PDS for current shape | |
4038 | TopoDS_Shape aShape = XCAFDoc_ShapeTool::GetShape(ShL); | |
4039 | TopLoc_Location Loc; | |
4040 | TColStd_SequenceOfTransient seqRI; | |
4041 | FindEntities( FP, aShape, Loc, seqRI ); | |
4042 | if(seqRI.Length()<=0) continue; | |
4043 | Handle(StepRepr_ProductDefinitionShape) PDS; | |
4044 | Handle(StepRepr_RepresentationContext) RC; | |
4045 | Handle(Standard_Transient) ent = seqRI.Value(1); | |
4046 | FindPDSforRI(aGraph,ent,PDS,RC); | |
4047 | if(PDS.IsNull()) continue; | |
1d2b1ccb G |
4048 | Handle(StepBasic_ProductDefinition) aProdDef = |
4049 | PDS->Definition().ProductDefinition(); | |
4050 | if(aProdDef.IsNull()) | |
4051 | continue; | |
7fd59977 | 4052 | // write material entities |
4053 | TDF_Label MatL = Node->Father()->Label(); | |
4054 | Handle(TCollection_HAsciiString) aName; | |
4055 | Handle(TCollection_HAsciiString) aDescription; | |
4056 | Standard_Real aDensity; | |
4057 | Handle(TCollection_HAsciiString) aDensName; | |
4058 | Handle(TCollection_HAsciiString) aDensValType; | |
41e259eb | 4059 | Handle(StepRepr_Representation) RepDRI; |
4060 | Handle(StepRepr_Representation) RepMRI; | |
7fd59977 | 4061 | if(MatTool->GetMaterial(MatL,aName,aDescription,aDensity,aDensName,aDensValType)) { |
4062 | if(aName->Length()==0) continue; | |
4063 | TCollection_AsciiString aKey(aName->ToCString()); | |
4064 | if(MapDRI.IsBound(aKey)) { | |
4065 | RepDRI = Handle(StepRepr_Representation)::DownCast(MapDRI.Find(aKey)); | |
4066 | if(MapMRI.IsBound(aKey)) { | |
4067 | RepMRI = Handle(StepRepr_Representation)::DownCast(MapMRI.Find(aKey)); | |
4068 | } | |
4069 | } | |
4070 | else { | |
4071 | // write DRI | |
4072 | Handle(StepRepr_DescriptiveRepresentationItem) DRI = new StepRepr_DescriptiveRepresentationItem; | |
4073 | DRI->Init(aName,aDescription); | |
4074 | Handle(StepRepr_HArray1OfRepresentationItem) HARI = new StepRepr_HArray1OfRepresentationItem(1,1); | |
4075 | HARI->SetValue(1,DRI); | |
41e259eb | 4076 | RepDRI = new StepRepr_Representation(); |
7fd59977 | 4077 | RepDRI->Init(new TCollection_HAsciiString("material name"),HARI,RC); |
4078 | Model->AddWithRefs(RepDRI); | |
4079 | // write MRI | |
41e259eb | 4080 | if( aDensity > 0 ) { |
7fd59977 | 4081 | // mass |
4082 | Handle(StepBasic_SiUnitAndMassUnit) SMU = new StepBasic_SiUnitAndMassUnit; | |
4083 | SMU->SetName(StepBasic_sunGram); | |
4084 | Handle(StepBasic_DerivedUnitElement) DUE1 = new StepBasic_DerivedUnitElement; | |
4085 | DUE1->Init(SMU,3.0); | |
4086 | // length | |
4087 | Handle(StepBasic_SiUnitAndLengthUnit) SLU = new StepBasic_SiUnitAndLengthUnit; | |
4088 | SLU->Init(Standard_True,StepBasic_spCenti,StepBasic_sunMetre); | |
4089 | Handle(StepBasic_DerivedUnitElement) DUE2 = new StepBasic_DerivedUnitElement; | |
4090 | DUE2->Init(SLU,2.0); | |
4091 | // other | |
4092 | Handle(StepBasic_HArray1OfDerivedUnitElement) HADUE = new StepBasic_HArray1OfDerivedUnitElement(1,2); | |
4093 | HADUE->SetValue(1,DUE1); | |
4094 | HADUE->SetValue(2,DUE2); | |
4095 | Handle(StepBasic_DerivedUnit) DU = new StepBasic_DerivedUnit; | |
4096 | DU->Init(HADUE); | |
4097 | Model->AddWithRefs(DU); | |
4098 | StepBasic_Unit aUnit; | |
4099 | aUnit.SetValue(DU); | |
4100 | Handle(StepBasic_MeasureValueMember) MVM = new StepBasic_MeasureValueMember; | |
4101 | MVM->SetName(aDensValType->ToCString()); | |
4102 | MVM->SetReal(aDensity); | |
4103 | Handle(StepRepr_MeasureRepresentationItem) MRI = new StepRepr_MeasureRepresentationItem; | |
4104 | MRI->Init(aDensName,MVM,aUnit); | |
4105 | HARI = new StepRepr_HArray1OfRepresentationItem(1,1); | |
4106 | HARI->SetValue(1,MRI); | |
41e259eb | 4107 | RepMRI = new StepRepr_Representation(); |
7fd59977 | 4108 | RepMRI->Init(new TCollection_HAsciiString("density"),HARI,RC); |
4109 | Model->AddWithRefs(RepMRI); | |
4110 | } | |
4111 | //WriteNewMaterial(Model,aName,aDescription,aDensity,aDensName,aDensValType,RC,RepDRI,RepMRI); | |
4112 | MapDRI.Bind(aKey,RepDRI); | |
41e259eb | 4113 | if ( !RepMRI.IsNull() ) MapMRI.Bind (aKey, RepMRI); |
4114 | } | |
4115 | } | |
4116 | ||
4117 | if( !RepDRI.IsNull() ) | |
4118 | { | |
4119 | StepRepr_CharacterizedDefinition CD1; | |
4120 | CD1.SetValue(aProdDef); | |
4121 | Handle(StepRepr_PropertyDefinition) PropD1 = new StepRepr_PropertyDefinition; | |
4122 | PropD1->Init(new TCollection_HAsciiString("material property"),Standard_True, | |
4123 | new TCollection_HAsciiString("material name"),CD1); | |
4124 | Model->AddWithRefs(PropD1); | |
4125 | StepRepr_RepresentedDefinition RD1; | |
4126 | RD1.SetValue(PropD1); | |
4127 | Handle(StepRepr_PropertyDefinitionRepresentation) PDR1 = | |
4128 | new StepRepr_PropertyDefinitionRepresentation; | |
4129 | PDR1->Init(RD1,RepDRI); | |
4130 | Model->AddWithRefs(PDR1); | |
4131 | ||
4132 | if( !RepMRI.IsNull() ) | |
4133 | { | |
4134 | StepRepr_CharacterizedDefinition CD2; | |
4135 | CD2.SetValue (aProdDef); | |
4136 | Handle (StepRepr_PropertyDefinition) PropD2 = new StepRepr_PropertyDefinition; | |
4137 | PropD2->Init (new TCollection_HAsciiString ("material property"), Standard_True, | |
4138 | new TCollection_HAsciiString ("density"), CD2); | |
4139 | Model->AddWithRefs (PropD2); | |
4140 | StepRepr_RepresentedDefinition RD2; | |
4141 | RD2.SetValue (PropD2); | |
4142 | Handle (StepRepr_PropertyDefinitionRepresentation) PDR2 = | |
4143 | new StepRepr_PropertyDefinitionRepresentation; | |
4144 | PDR2->Init (RD2, RepMRI); | |
4145 | Model->AddWithRefs (PDR2); | |
7fd59977 | 4146 | } |
4147 | } | |
7fd59977 | 4148 | } |
4149 | } | |
4150 | ||
4151 | return Standard_True; | |
4152 | } | |
4153 | ||
4154 | ||
4155 | //======================================================================= | |
4156 | //function : SetColorMode | |
4157 | //purpose : | |
4158 | //======================================================================= | |
4159 | ||
4160 | void STEPCAFControl_Writer::SetColorMode (const Standard_Boolean colormode) | |
4161 | { | |
4162 | myColorMode = colormode; | |
4163 | } | |
4164 | ||
4165 | ||
4166 | //======================================================================= | |
4167 | //function : GetColorMode | |
4168 | //purpose : | |
4169 | //======================================================================= | |
4170 | ||
4171 | Standard_Boolean STEPCAFControl_Writer::GetColorMode () const | |
4172 | { | |
4173 | return myColorMode; | |
4174 | } | |
4175 | ||
4176 | ||
4177 | //======================================================================= | |
4178 | //function : SetNameMode | |
4179 | //purpose : | |
4180 | //======================================================================= | |
4181 | ||
4182 | void STEPCAFControl_Writer::SetNameMode (const Standard_Boolean namemode) | |
4183 | { | |
4184 | myNameMode = namemode; | |
4185 | } | |
4186 | ||
4187 | ||
4188 | //======================================================================= | |
4189 | //function : GetNameMode | |
4190 | //purpose : | |
4191 | //======================================================================= | |
4192 | ||
4193 | Standard_Boolean STEPCAFControl_Writer::GetNameMode () const | |
4194 | { | |
4195 | return myNameMode; | |
4196 | } | |
4197 | ||
4198 | ||
4199 | //======================================================================= | |
4200 | //function : SetLayerMode | |
4201 | //purpose : | |
4202 | //======================================================================= | |
4203 | ||
4204 | void STEPCAFControl_Writer::SetLayerMode (const Standard_Boolean layermode) | |
4205 | { | |
4206 | myLayerMode = layermode; | |
4207 | } | |
4208 | ||
4209 | ||
4210 | //======================================================================= | |
4211 | //function : GetLayerMode | |
4212 | //purpose : | |
4213 | //======================================================================= | |
4214 | ||
4215 | Standard_Boolean STEPCAFControl_Writer::GetLayerMode () const | |
4216 | { | |
4217 | return myLayerMode; | |
4218 | } | |
4219 | ||
4220 | ||
4221 | //======================================================================= | |
4222 | //function : SetPropsMode | |
4223 | //purpose : | |
4224 | //======================================================================= | |
4225 | ||
4226 | void STEPCAFControl_Writer::SetPropsMode (const Standard_Boolean propsmode) | |
4227 | { | |
4228 | myPropsMode = propsmode; | |
4229 | } | |
4230 | ||
4231 | ||
4232 | //======================================================================= | |
4233 | //function : GetPropsMode | |
4234 | //purpose : | |
4235 | //======================================================================= | |
4236 | ||
4237 | Standard_Boolean STEPCAFControl_Writer::GetPropsMode () const | |
4238 | { | |
4239 | return myPropsMode; | |
4240 | } | |
4241 | ||
4242 | ||
4243 | //======================================================================= | |
4244 | //function : SetSHUOMode | |
4245 | //purpose : | |
4246 | //======================================================================= | |
4247 | ||
4248 | void STEPCAFControl_Writer::SetSHUOMode (const Standard_Boolean mode) | |
4249 | { | |
4250 | mySHUOMode = mode; | |
4251 | } | |
4252 | ||
4253 | ||
4254 | //======================================================================= | |
4255 | //function : GetSHUOMode | |
4256 | //purpose : | |
4257 | //======================================================================= | |
4258 | ||
4259 | Standard_Boolean STEPCAFControl_Writer::GetSHUOMode () const | |
4260 | { | |
4261 | return mySHUOMode; | |
4262 | } | |
4263 | ||
4264 | ||
4265 | //======================================================================= | |
4266 | //function : SetDimTolMode | |
4267 | //purpose : | |
4268 | //======================================================================= | |
4269 | ||
4270 | void STEPCAFControl_Writer::SetDimTolMode(const Standard_Boolean dimtolmode) | |
4271 | { | |
4272 | myDGTMode = dimtolmode; | |
4273 | } | |
4274 | ||
4275 | ||
4276 | //======================================================================= | |
4277 | //function : GetDimTolMode | |
4278 | //purpose : | |
4279 | //======================================================================= | |
4280 | ||
4281 | Standard_Boolean STEPCAFControl_Writer::GetDimTolMode() const | |
4282 | { | |
4283 | return myDGTMode; | |
4284 | } | |
4285 | ||
4286 | ||
4287 | //======================================================================= | |
4288 | //function : SetMaterialMode | |
4289 | //purpose : | |
4290 | //======================================================================= | |
4291 | ||
4292 | void STEPCAFControl_Writer::SetMaterialMode(const Standard_Boolean matmode) | |
4293 | { | |
4294 | myMatMode = matmode; | |
4295 | } | |
4296 | ||
4297 | ||
4298 | //======================================================================= | |
4299 | //function : GetMaterialMode | |
4300 | //purpose : | |
4301 | //======================================================================= | |
4302 | ||
4303 | Standard_Boolean STEPCAFControl_Writer::GetMaterialMode() const | |
4304 | { | |
4305 | return myMatMode; | |
4306 | } |