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 | ||
23 | #include <STEPCAFControl_Writer.ixx> | |
24 | #include <STEPControl_StepModelType.hxx> | |
25 | #include <XCAFDoc_ShapeTool.hxx> | |
26 | #include <TDF_LabelSequence.hxx> | |
27 | #include <TopoDS_Shape.hxx> | |
28 | #include <XCAFPrs_DataMapOfShapeStyle.hxx> | |
29 | #include <XCAFPrs.hxx> | |
30 | #include <XCAFPrs_DataMapOfStyleShape.hxx> | |
31 | #include <XCAFPrs_Style.hxx> | |
32 | #include <XCAFPrs_DataMapIteratorOfDataMapOfStyleShape.hxx> | |
33 | #include <TopTools_SequenceOfShape.hxx> | |
34 | #include <TopoDS_Iterator.hxx> | |
35 | #include <STEPConstruct_Styles.hxx> | |
36 | #include <XCAFDoc_ColorTool.hxx> | |
37 | #include <STEPConstruct.hxx> | |
38 | #include <TopTools_MapOfShape.hxx> | |
39 | #include <XSControl_TransferWriter.hxx> | |
40 | #include <TDataStd_Name.hxx> | |
41 | #include <StepShape_ShapeDefinitionRepresentation.hxx> | |
42 | #include <TransferBRep_ShapeMapper.hxx> | |
43 | #include <TransferBRep.hxx> | |
44 | #include <StepRepr_PropertyDefinition.hxx> | |
45 | #include <StepBasic_ProductDefinition.hxx> | |
46 | #include <StepBasic_Product.hxx> | |
47 | #include <TCollection_HAsciiString.hxx> | |
48 | #include <TCollection_AsciiString.hxx> | |
49 | #include <Transfer_FinderProcess.hxx> | |
50 | #include <StepBasic_ProductDefinitionFormation.hxx> | |
51 | #include <XCAFDoc_DocumentTool.hxx> | |
52 | #include <TDF_Label.hxx> | |
53 | #include <STEPCAFControl_Controller.hxx> | |
54 | #include <STEPCAFControl_IteratorOfDictionaryOfExternFile.hxx> | |
55 | #include <STEPConstruct_ExternRefs.hxx> | |
56 | #include <Interface_Static.hxx> | |
57 | #include <TopoDS_Compound.hxx> | |
58 | #include <BRep_Builder.hxx> | |
59 | #include <Transfer_ActorOfFinderProcess.hxx> | |
60 | #include <STEPCAFControl_ActorWrite.hxx> | |
61 | #include <STEPConstruct_ValidationProps.hxx> | |
62 | #include <XCAFDoc_Area.hxx> | |
63 | #include <XCAFDoc_Volume.hxx> | |
64 | #include <XCAFDoc_Centroid.hxx> | |
65 | #include <StepShape_ContextDependentShapeRepresentation.hxx> | |
66 | #include <StepRepr_ProductDefinitionShape.hxx> | |
67 | #include <StepBasic_ProductDefinitionRelationship.hxx> | |
68 | #include <XCAFDoc_GraphNode.hxx> | |
69 | #include <XCAFDoc_LayerTool.hxx> | |
70 | #include <StepVisual_PresentationLayerAssignment.hxx> | |
71 | #include <XCAFDoc.hxx> | |
72 | #include <StepVisual_HArray1OfLayeredItem.hxx> | |
73 | #include <TColStd_HSequenceOfTransient.hxx> | |
74 | #include <TDF_Tool.hxx> | |
75 | #include <Message_Messenger.hxx> | |
02a0b964 | 76 | #include <TDF_ChildIterator.hxx> |
7fd59977 | 77 | |
78 | #include <Transfer_Binder.hxx> | |
79 | #include <Transfer_TransientListBinder.hxx> | |
80 | #include <StepVisual_InvisibleItem.hxx> | |
81 | #include <TDataStd_UAttribute.hxx> | |
82 | #include <StepVisual_Invisibility.hxx> | |
83 | #include <StepVisual_HArray1OfInvisibleItem.hxx> | |
84 | #include <HeaderSection_FileSchema.hxx> | |
85 | #include <StepData_StepModel.hxx> | |
86 | #include <StepAP214_Protocol.hxx> | |
87 | #include <OSD_Path.hxx> | |
88 | #include <XSControl_WorkSession.hxx> | |
89 | #include <StepRepr_HArray1OfRepresentationItem.hxx> | |
90 | #include <MoniTool_DataMapIteratorOfDataMapOfShapeTransient.hxx> | |
91 | #include <StepRepr_Representation.hxx> | |
92 | #include <StepVisual_MechanicalDesignGeometricPresentationRepresentation.hxx> | |
93 | #include <Quantity_TypeOfColor.hxx> | |
94 | #include <StepVisual_HArray1OfPresentationStyleAssignment.hxx> | |
95 | #include <StepVisual_PresentationStyleAssignment.hxx> | |
96 | #include <StepVisual_StyledItem.hxx> | |
97 | #include <StepVisual_PresentationStyleByContext.hxx> | |
98 | #include <StepVisual_HArray1OfPresentationStyleSelect.hxx> | |
c04c30b3 | 99 | #include <StepVisual_PointStyle.hxx> |
100 | #include <StepVisual_CurveStyle.hxx> | |
101 | #include <StepVisual_SurfaceStyleUsage.hxx> | |
7fd59977 | 102 | #include <TDF_AttributeSequence.hxx> |
103 | #include <TColStd_MapOfTransient.hxx> | |
7fd59977 | 104 | #include <StepRepr_NextAssemblyUsageOccurrence.hxx> |
105 | #include <Interface_EntityIterator.hxx> | |
106 | #include <StepRepr_SpecifiedHigherUsageOccurrence.hxx> | |
107 | ||
108 | // added by skl 15.01.2004 for D> writing | |
109 | #include <XCAFDoc_DimTolTool.hxx> | |
110 | #include <XCAFDoc_DimTol.hxx> | |
111 | #include <XCAFDoc_Datum.hxx> | |
112 | #include <STEPConstruct_DataMapOfAsciiStringTransient.hxx> | |
113 | #include <STEPConstruct_DataMapOfPointTransient.hxx> | |
114 | #include <StepBasic_MeasureValueMember.hxx> | |
115 | #include <StepBasic_SiUnitAndLengthUnit.hxx> | |
116 | #include <StepGeom_GeometricRepresentationContextAndGlobalUnitAssignedContext.hxx> | |
117 | #include <StepGeom_GeomRepContextAndGlobUnitAssCtxAndGlobUncertaintyAssCtx.hxx> | |
c04c30b3 | 118 | #include <StepGeom_Surface.hxx> |
7fd59977 | 119 | #include <StepBasic_LengthMeasureWithUnit.hxx> |
120 | #include <StepShape_EdgeCurve.hxx> | |
121 | #include <StepShape_AdvancedFace.hxx> | |
122 | #include <StepShape_OrientedEdge.hxx> | |
123 | #include <StepShape_EdgeLoop.hxx> | |
124 | #include <StepShape_FaceBound.hxx> | |
125 | #include <StepShape_ConnectedFaceSet.hxx> | |
126 | #include <StepShape_ShapeRepresentation.hxx> | |
127 | #include <StepShape_DimensionalSize.hxx> | |
128 | #include <StepShape_ShapeDimensionRepresentation.hxx> | |
129 | #include <StepShape_DimensionalCharacteristicRepresentation.hxx> | |
130 | #include <StepRepr_ShapeAspect.hxx> | |
131 | #include <StepRepr_ShapeAspectRelationship.hxx> | |
132 | #include <StepRepr_ReprItemAndLengthMeasureWithUnit.hxx> | |
133 | //#include <StepRepr_CompoundItemDefinition.hxx> | |
134 | //#include <StepRepr_CompoundItemDefinitionMember.hxx> | |
135 | #include <StepRepr_ValueRange.hxx> | |
136 | #include <StepData_Logical.hxx> | |
137 | #include <StepDimTol_DatumFeature.hxx> | |
138 | #include <StepDimTol_Datum.hxx> | |
139 | #include <StepDimTol_DatumReference.hxx> | |
140 | #include <StepDimTol_HArray1OfDatumReference.hxx> | |
141 | #include <StepDimTol_GeoTolAndGeoTolWthDatRefAndModGeoTolAndPosTol.hxx> | |
142 | #include <StepDimTol_ModifiedGeometricTolerance.hxx> | |
143 | #include <StepDimTol_GeometricToleranceWithDatumReference.hxx> | |
144 | #include <StepDimTol_AngularityTolerance.hxx> | |
145 | #include <StepDimTol_CircularRunoutTolerance.hxx> | |
146 | #include <StepDimTol_CoaxialityTolerance.hxx> | |
147 | #include <StepDimTol_ConcentricityTolerance.hxx> | |
148 | #include <StepDimTol_ParallelismTolerance.hxx> | |
149 | #include <StepDimTol_PerpendicularityTolerance.hxx> | |
150 | #include <StepDimTol_SymmetryTolerance.hxx> | |
151 | #include <StepDimTol_TotalRunoutTolerance.hxx> | |
152 | #include <StepDimTol_CylindricityTolerance.hxx> | |
153 | #include <StepDimTol_FlatnessTolerance.hxx> | |
154 | #include <StepDimTol_LineProfileTolerance.hxx> | |
155 | #include <StepDimTol_PositionTolerance.hxx> | |
156 | #include <StepDimTol_RoundnessTolerance.hxx> | |
157 | #include <StepDimTol_StraightnessTolerance.hxx> | |
158 | #include <StepDimTol_SurfaceProfileTolerance.hxx> | |
159 | #include <TColStd_HArray1OfReal.hxx> | |
160 | #include <TColStd_HArray1OfTransient.hxx> | |
161 | ||
162 | // added by skl 12.02.2004 for writing materials | |
163 | #include <XCAFDoc_MaterialTool.hxx> | |
164 | #include <XCAFDoc_Material.hxx> | |
165 | #include <TDataStd_TreeNode.hxx> | |
166 | #include <StepRepr_DescriptiveRepresentationItem.hxx> | |
167 | #include <StepBasic_SiUnitAndMassUnit.hxx> | |
168 | #include <StepBasic_DerivedUnitElement.hxx> | |
169 | #include <StepBasic_HArray1OfDerivedUnitElement.hxx> | |
170 | #include <StepBasic_DerivedUnit.hxx> | |
171 | #include <StepRepr_MeasureRepresentationItem.hxx> | |
1d2b1ccb | 172 | #include <StepBasic_ProductDefinition.hxx> |
ec357c5c | 173 | #include <StepRepr_RepresentationItem.hxx> |
174 | #include <StepVisual_PresentationRepresentation.hxx> | |
7fd59977 | 175 | |
176 | //======================================================================= | |
177 | //function : GetLabelName | |
178 | //purpose : auxilary function: take name of label and append it to str | |
179 | //======================================================================= | |
180 | static Standard_Boolean GetLabelName (const TDF_Label &L, Handle(TCollection_HAsciiString) &str) | |
181 | { | |
182 | Handle(TDataStd_Name) N; | |
183 | if ( ! L.FindAttribute ( TDataStd_Name::GetID(), N ) ) return Standard_False; | |
184 | TCollection_ExtendedString name = N->Get(); | |
185 | if ( name.Length() <=0 ) return Standard_False; | |
186 | ||
187 | // set name, converting it to Ascii and removing spaces | |
188 | TCollection_AsciiString buf ( name, '?' ); | |
189 | buf.LeftAdjust(); | |
190 | buf.RightAdjust(); | |
191 | buf.ChangeAll(' ','_'); | |
192 | str->AssignCat ( buf.ToCString() ); | |
193 | return Standard_True; | |
194 | } | |
195 | ||
196 | ||
197 | //======================================================================= | |
198 | //function : STEPCAFControl_Writer | |
199 | //purpose : | |
200 | //======================================================================= | |
201 | ||
202 | STEPCAFControl_Writer::STEPCAFControl_Writer () : | |
203 | myColorMode( Standard_True ), | |
204 | myNameMode ( Standard_True ), | |
205 | myLayerMode( Standard_True ), | |
206 | myPropsMode( Standard_True ), | |
207 | mySHUOMode ( Standard_True ), | |
208 | myDGTMode ( Standard_True ), | |
209 | myMatMode ( Standard_True ) | |
210 | { | |
211 | STEPCAFControl_Controller::Init(); | |
212 | Handle(XSControl_WorkSession) WS = new XSControl_WorkSession; | |
213 | Init ( WS ); | |
214 | } | |
215 | ||
216 | ||
217 | //======================================================================= | |
218 | //function : STEPCAFControl_Writer | |
219 | //purpose : | |
220 | //======================================================================= | |
221 | ||
222 | STEPCAFControl_Writer::STEPCAFControl_Writer (const Handle(XSControl_WorkSession)& WS, | |
223 | const Standard_Boolean scratch) | |
224 | { | |
225 | STEPCAFControl_Controller::Init(); | |
226 | Init ( WS, scratch ); | |
227 | myColorMode = Standard_True; | |
228 | myNameMode = Standard_True; | |
229 | myLayerMode = Standard_True; | |
230 | myPropsMode = Standard_True; | |
231 | mySHUOMode = Standard_True; | |
232 | } | |
233 | ||
234 | ||
235 | //======================================================================= | |
236 | //function : Init | |
237 | //purpose : | |
238 | //======================================================================= | |
239 | ||
240 | void STEPCAFControl_Writer::Init (const Handle(XSControl_WorkSession)& WS, | |
241 | const Standard_Boolean scratch) | |
242 | { | |
243 | WS->SelectNorm ( "STEP" ); | |
244 | myWriter.SetWS (WS,scratch); | |
245 | myFiles = new STEPCAFControl_DictionaryOfExternFile; | |
246 | myLabEF.Clear(); | |
247 | myLabels.Clear(); | |
248 | } | |
249 | ||
250 | ||
251 | //======================================================================= | |
252 | //function : Write | |
253 | //purpose : | |
254 | //======================================================================= | |
255 | ||
256 | IFSelect_ReturnStatus STEPCAFControl_Writer::Write (const Standard_CString filename) | |
257 | { | |
258 | IFSelect_ReturnStatus status = myWriter.Write ( filename ); | |
259 | ||
260 | // get directory name of the main file | |
261 | OSD_Path mainfile ( filename ); | |
262 | mainfile.SetName ( "" ); | |
263 | mainfile.SetExtension ( "" ); | |
264 | TCollection_AsciiString dpath; | |
265 | mainfile.SystemName ( dpath ); | |
266 | ||
267 | STEPCAFControl_IteratorOfDictionaryOfExternFile it ( myFiles ); | |
268 | for ( ; it.More(); it.Next() ) { | |
269 | Handle(STEPCAFControl_ExternFile) EF = it.Value(); | |
270 | if ( EF->GetWriteStatus() != IFSelect_RetVoid ) continue; | |
271 | ||
272 | // construct extern file name | |
273 | TCollection_AsciiString fname = OSD_Path::AbsolutePath ( dpath, EF->GetName()->String() ); | |
274 | if ( fname.Length() <= 0 ) fname = EF->GetName()->String(); | |
0797d9d3 | 275 | #ifdef OCCT_DEBUG |
7fd59977 | 276 | cout << "Writing external file: " << fname.ToCString() << endl; |
277 | #endif | |
278 | ||
279 | EF->SetWriteStatus ( EF->GetWS()->SendAll ( fname.ToCString() ) ); | |
280 | } | |
281 | ||
282 | return status; | |
283 | } | |
284 | ||
285 | ||
286 | //======================================================================= | |
287 | //function : Transfer | |
288 | //purpose : | |
289 | //======================================================================= | |
290 | ||
291 | Standard_Boolean STEPCAFControl_Writer::Transfer (const Handle(TDocStd_Document) &doc, | |
292 | const STEPControl_StepModelType mode, | |
293 | const Standard_CString multi) | |
294 | { | |
295 | Handle(XCAFDoc_ShapeTool) STool = XCAFDoc_DocumentTool::ShapeTool( doc->Main() ); | |
296 | if ( STool.IsNull() ) return Standard_False; | |
297 | ||
298 | TDF_LabelSequence labels; | |
299 | STool->GetFreeShapes ( labels ); | |
300 | return Transfer ( myWriter, labels, mode, multi ); | |
301 | } | |
302 | ||
303 | ||
304 | //======================================================================= | |
305 | //function : Transfer | |
306 | //purpose : | |
307 | //======================================================================= | |
308 | ||
309 | Standard_Boolean STEPCAFControl_Writer::Transfer (const TDF_Label &L, | |
310 | const STEPControl_StepModelType mode, | |
311 | const Standard_CString multi) | |
312 | { | |
313 | TDF_LabelSequence labels; | |
314 | labels.Append ( L ); | |
315 | return Transfer ( myWriter, labels, mode, multi ); | |
316 | } | |
317 | ||
318 | ||
319 | //======================================================================= | |
320 | //function : Perform | |
321 | //purpose : | |
322 | //======================================================================= | |
323 | ||
324 | Standard_Boolean STEPCAFControl_Writer::Perform (const Handle(TDocStd_Document) &doc, | |
325 | const Standard_CString filename) | |
326 | { | |
327 | if ( ! Transfer ( doc ) ) return Standard_False; | |
328 | return Write ( filename ) == IFSelect_RetDone; | |
329 | } | |
330 | ||
331 | ||
332 | //======================================================================= | |
333 | //function : Perform | |
334 | //purpose : | |
335 | //======================================================================= | |
336 | ||
337 | Standard_Boolean STEPCAFControl_Writer::Perform (const Handle(TDocStd_Document) &doc, | |
338 | const TCollection_AsciiString &filename) | |
339 | { | |
340 | if ( ! Transfer ( doc ) ) return Standard_False; | |
341 | return Write ( filename.ToCString() ) == IFSelect_RetDone; | |
342 | } | |
343 | ||
344 | ||
345 | //======================================================================= | |
346 | //function : ExternFiles | |
347 | //purpose : | |
348 | //======================================================================= | |
349 | ||
350 | const Handle(STEPCAFControl_DictionaryOfExternFile) &STEPCAFControl_Writer::ExternFiles () const | |
351 | { | |
352 | return myFiles; | |
353 | } | |
354 | ||
355 | ||
356 | //======================================================================= | |
357 | //function : ExternFile | |
358 | //purpose : | |
359 | //======================================================================= | |
360 | ||
361 | Standard_Boolean STEPCAFControl_Writer::ExternFile (const TDF_Label &L, | |
362 | Handle(STEPCAFControl_ExternFile) &ef) const | |
363 | { | |
364 | ef.Nullify(); | |
365 | if ( ! myLabEF.IsBound ( L ) ) return Standard_False; | |
366 | ef = myLabEF.Find ( L ); | |
367 | return Standard_True; | |
368 | } | |
369 | ||
370 | ||
371 | //======================================================================= | |
372 | //function : ExternFile | |
373 | //purpose : | |
374 | //======================================================================= | |
375 | ||
376 | Standard_Boolean STEPCAFControl_Writer::ExternFile (const Standard_CString name, | |
377 | Handle(STEPCAFControl_ExternFile) &ef) const | |
378 | { | |
379 | ef.Nullify(); | |
380 | if ( ! myFiles.IsNull() || ! myFiles->HasItem ( name ) ) | |
381 | return Standard_False; | |
382 | ef = myFiles->Item ( name ); | |
383 | return Standard_True; | |
384 | } | |
385 | ||
386 | ||
387 | //======================================================================= | |
388 | //function : Writer | |
389 | //purpose : | |
390 | //======================================================================= | |
391 | ||
392 | STEPControl_Writer &STEPCAFControl_Writer::ChangeWriter () | |
393 | { | |
394 | return myWriter; | |
395 | } | |
396 | ||
397 | ||
398 | //======================================================================= | |
399 | //function : Writer | |
400 | //purpose : | |
401 | //======================================================================= | |
402 | ||
403 | const STEPControl_Writer &STEPCAFControl_Writer::Writer () const | |
404 | { | |
405 | return myWriter; | |
406 | } | |
407 | ||
408 | ||
409 | //======================================================================= | |
410 | //function : Transfer | |
411 | //purpose : | |
412 | //======================================================================= | |
413 | ||
414 | Standard_Boolean STEPCAFControl_Writer::Transfer (STEPControl_Writer &writer, | |
415 | const TDF_LabelSequence &labels, | |
416 | const STEPControl_StepModelType mode, | |
417 | const Standard_CString multi, | |
418 | const Standard_Boolean isExternFile) | |
419 | { | |
420 | if ( labels.Length() <=0 ) return Standard_False; | |
421 | ||
422 | Handle(STEPCAFControl_ActorWrite) Actor = | |
423 | Handle(STEPCAFControl_ActorWrite)::DownCast ( writer.WS()->NormAdaptor()->ActorWrite() ); | |
424 | ||
425 | // translate free top-level shapes of the DECAF document | |
7fd59977 | 426 | Standard_Integer ap = Interface_Static::IVal ("write.step.schema"); |
427 | TDF_LabelSequence sublabels; | |
428 | for ( Standard_Integer i=1; i <= labels.Length(); i++ ) { | |
429 | TDF_Label L = labels.Value(i); | |
430 | TopoDS_Shape dummy; | |
431 | if ( myLabels.IsBound ( L ) ) continue; // already processed | |
432 | ||
433 | TopoDS_Shape shape = XCAFDoc_ShapeTool::GetShape ( L ); | |
434 | if ( shape.IsNull() ) continue; | |
435 | ||
436 | // write shape either as a whole, or as multifile (with extern refs) | |
437 | if ( ! multi /* || ! XCAFDoc_ShapeTool::IsAssembly ( L ) */ ) { | |
438 | Actor->SetStdMode ( Standard_False ); | |
439 | ||
440 | // fill sequence of (sub) shapes for which attributes should be written | |
441 | // and set actor to handle assemblies in a proper way | |
442 | TDF_LabelSequence comp; | |
443 | XCAFDoc_ShapeTool::GetComponents ( L, comp, Standard_True ); | |
444 | for ( Standard_Integer k=1; k <= comp.Length(); k++ ) { | |
445 | TDF_Label ref; | |
446 | if ( ! XCAFDoc_ShapeTool::GetReferredShape ( comp(k), ref ) ) continue; | |
447 | if ( ! myLabels.IsBound ( ref ) ) { | |
448 | TopoDS_Shape refS = XCAFDoc_ShapeTool::GetShape ( ref ); | |
449 | myLabels.Bind ( ref, refS ); | |
450 | sublabels.Append ( ref ); | |
451 | if ( XCAFDoc_ShapeTool::IsAssembly ( ref ) ) | |
452 | Actor->RegisterAssembly ( refS ); | |
453 | } | |
454 | } | |
455 | myLabels.Bind ( L, shape ); | |
456 | sublabels.Append ( L ); | |
457 | if ( XCAFDoc_ShapeTool::IsAssembly ( L ) ) | |
458 | Actor->RegisterAssembly ( shape ); | |
459 | ||
460 | writer.Transfer(shape,mode,Standard_False); | |
461 | Actor->SetStdMode ( Standard_True ); // restore default behaviour | |
462 | } | |
463 | else { | |
464 | // translate final solids | |
465 | TopoDS_Shape Sass = TransferExternFiles ( L, mode, sublabels, multi ); | |
466 | ||
467 | // translate main assembly structure | |
468 | /* | |
469 | if ( ap == 3 ) { // if AP203, switch to AP214 | |
470 | Interface_Static::SetCVal ("write.step.schema", "AP214DIS"); | |
471 | Handle(StepData_StepModel) model = | |
472 | Handle(StepData_StepModel)::DownCast ( writer.WS()->Model() ); | |
473 | if ( model->HasHeaderEntity(STANDARD_TYPE(HeaderSection_FileSchema)) ) { | |
474 | Handle(HeaderSection_FileSchema) fs = | |
475 | Handle(HeaderSection_FileSchema)::DownCast ( model->HeaderEntity(STANDARD_TYPE(HeaderSection_FileSchema)) ); | |
476 | Handle(TCollection_HAsciiString) str = fs->SchemaIdentifiersValue ( 1 ); | |
477 | Handle(TCollection_HAsciiString) ap214 = new TCollection_HAsciiString ( "AUTOMOTIVE_DESIGN" ); | |
478 | if ( str->Search ( ap214 ) <0 ) { | |
479 | str->Clear(); | |
480 | str->AssignCat ( ap214 ); | |
481 | } | |
482 | } | |
483 | } | |
484 | */ | |
485 | Standard_Integer assemblymode = Interface_Static::IVal ("write.step.assembly"); | |
486 | Interface_Static::SetCVal ("write.step.assembly", "On"); | |
487 | writer.Transfer ( Sass, STEPControl_AsIs ); | |
488 | Interface_Static::SetIVal ("write.step.assembly", assemblymode); | |
489 | Interface_Static::SetIVal ("write.step.schema", ap); | |
490 | } | |
491 | } | |
492 | ||
493 | writer.WS()->ComputeGraph(Standard_True );// added by skl 03.11.2003 since we use | |
494 | // writer.Transfer() wihtout compute graph | |
495 | ||
496 | // write names | |
497 | if ( GetNameMode() ) | |
498 | WriteNames ( writer.WS(), sublabels ); | |
499 | ||
500 | if ( !multi ) { | |
501 | // write colors | |
502 | if ( GetColorMode() ) | |
503 | WriteColors ( writer.WS(), sublabels ); | |
504 | ||
505 | // write layers | |
506 | if ( GetLayerMode() ) | |
507 | WriteLayers ( writer.WS(), sublabels ); | |
508 | ||
509 | // write SHUO entities | |
510 | if ( GetSHUOMode() && !isExternFile ) | |
511 | // do not store SHUO for extern reference for the moment | |
512 | WriteSHUOs ( writer.WS(), sublabels ); | |
513 | ||
514 | // write G&DTs | |
515 | if(GetDimTolMode()) | |
516 | WriteDGTs(writer.WS(),sublabels); | |
517 | ||
518 | // write Materials | |
519 | if(GetMaterialMode()) | |
520 | WriteMaterials(writer.WS(),sublabels); | |
521 | ||
522 | // register all MDGPRs in model | |
523 | MoniTool_DataMapIteratorOfDataMapOfShapeTransient anItr(myMapCompMDGPR); | |
524 | for (; anItr.More(); anItr.Next()) { | |
525 | Handle(Interface_InterfaceModel) Model = writer.WS()->Model(); | |
526 | Model->AddWithRefs( anItr.Value() ); | |
527 | } | |
528 | } | |
529 | ||
530 | if ( multi ) { // external refs | |
531 | WriteExternRefs ( writer.WS(), sublabels ); | |
532 | } | |
533 | ||
534 | // write validation props | |
535 | // if ( multi && ap ==3 ) { | |
536 | // Interface_Static::SetCVal ("write.step.schema", "AP214DIS"); | |
537 | // } | |
538 | if ( GetPropsMode() ) | |
539 | WriteValProps ( writer.WS(), sublabels, multi ); | |
540 | ||
541 | Interface_Static::SetIVal ("write.step.schema", ap); | |
542 | ||
543 | // refresh graph | |
544 | writer.WS()->ComputeGraph ( Standard_True ); | |
545 | ||
02a0b964 | 546 | /* ================================ |
547 | * Write names for the sub-shapes | |
548 | * ================================ */ | |
549 | ||
550 | if ( Interface_Static::IVal("write.stepcaf.subshapes.name") ) | |
551 | { | |
552 | Handle(XSControl_TransferWriter) TW = this->ChangeWriter().WS()->TransferWriter(); | |
553 | Handle(Transfer_FinderProcess) FP = TW->FinderProcess(); | |
554 | ||
555 | for ( int i = 1; i <= labels.Length(); i++ ) | |
556 | { | |
557 | TDF_Label L = labels.Value(i); | |
558 | ||
559 | for ( TDF_ChildIterator it(L, Standard_True); it.More(); it.Next() ) | |
560 | { | |
561 | TDF_Label SubL = it.Value(); | |
562 | ||
563 | // Access name recorded in OCAF TDataStd_Name attribute | |
564 | Handle(TCollection_HAsciiString) hSubName = new TCollection_HAsciiString; | |
565 | if ( !GetLabelName(SubL, hSubName) ) | |
566 | continue; | |
567 | ||
568 | // Access topological data | |
569 | TopoDS_Shape SubS = XCAFDoc_ShapeTool::GetShape(SubL); | |
570 | if ( SubS.IsNull() ) | |
571 | continue; | |
572 | ||
573 | // Access the correspondent STEP Representation Item | |
574 | Handle(StepRepr_RepresentationItem) RI; | |
575 | Handle(TransferBRep_ShapeMapper) aShMapper = TransferBRep::ShapeMapper(FP, SubS); | |
576 | if ( !FP->FindTypedTransient(aShMapper, STANDARD_TYPE(StepRepr_RepresentationItem), RI) ) | |
577 | continue; | |
578 | ||
579 | // Record the name | |
580 | RI->SetName(hSubName); | |
581 | } | |
582 | } | |
583 | } | |
584 | ||
7fd59977 | 585 | return Standard_True; |
586 | } | |
587 | ||
588 | ||
589 | //======================================================================= | |
590 | //function : TransferExternFiles | |
591 | //purpose : | |
592 | //======================================================================= | |
593 | ||
594 | TopoDS_Shape STEPCAFControl_Writer::TransferExternFiles (const TDF_Label &L, | |
595 | const STEPControl_StepModelType mode, | |
596 | TDF_LabelSequence &labels, | |
597 | const Standard_CString prefix) | |
598 | { | |
599 | // if label already translated, just return the shape | |
600 | if ( myLabels.IsBound ( L ) ) { | |
601 | return myLabels.Find ( L ); | |
602 | } | |
603 | ||
604 | TopoDS_Compound C; | |
605 | BRep_Builder B; | |
606 | B.MakeCompound ( C ); | |
607 | labels.Append ( L ); | |
608 | ||
609 | // if not assembly, write to separate file | |
610 | if ( ! XCAFDoc_ShapeTool::IsAssembly ( L ) ) { | |
611 | ||
612 | // prepare for transfer | |
613 | Handle(XSControl_WorkSession) newWS = new XSControl_WorkSession; | |
614 | newWS->SelectNorm ( "STEP" ); | |
615 | STEPControl_Writer sw ( newWS, Standard_True ); | |
616 | TDF_LabelSequence Lseq; | |
617 | Lseq.Append ( L ); | |
618 | ||
619 | // construct the name for extern file | |
620 | Handle(TCollection_HAsciiString) basename = new TCollection_HAsciiString; | |
621 | if ( prefix && prefix[0] ) basename->AssignCat ( prefix ); | |
622 | GetLabelName ( L, basename ); | |
623 | Handle(TCollection_HAsciiString) name = new TCollection_HAsciiString ( basename ); | |
624 | name->AssignCat ( ".stp" ); | |
625 | if ( myFiles->HasItem ( name->ToCString() ) ) { // avoid confusions | |
626 | for ( Standard_Integer k=1; k < 32000; k++ ) { | |
627 | name = new TCollection_HAsciiString ( basename ); | |
628 | name->AssignCat ( "_" ); | |
629 | name->AssignCat ( TCollection_AsciiString ( k ).ToCString() ); | |
630 | name->AssignCat ( ".stp" ); | |
631 | if ( ! myFiles->HasItem ( name->ToCString() ) ) break; | |
632 | } | |
633 | } | |
634 | ||
635 | // translate and record extern file | |
636 | Handle(STEPCAFControl_ExternFile) EF = new STEPCAFControl_ExternFile; | |
637 | EF->SetWS ( newWS ); | |
638 | EF->SetName ( name ); | |
639 | EF->SetLabel ( L ); | |
640 | Standard_Integer assemblymode = Interface_Static::IVal ("write.step.assembly"); | |
641 | Interface_Static::SetCVal ("write.step.assembly", "Off"); | |
642 | const Standard_CString multi = 0; | |
643 | EF->SetTransferStatus ( Transfer ( sw, Lseq, mode, multi, Standard_True ) ); | |
644 | Interface_Static::SetIVal ("write.step.assembly", assemblymode); | |
645 | myLabEF.Bind ( L, EF ); | |
646 | myFiles->SetItem ( name->ToCString(), EF ); | |
647 | ||
648 | // return empty compound as replacement for the shape | |
649 | myLabels.Bind ( L, C ); | |
650 | return C; | |
651 | } | |
652 | ||
653 | // else iterate on components add create structure of empty compounds | |
654 | // representing the assembly | |
655 | TDF_LabelSequence comp; | |
656 | XCAFDoc_ShapeTool::GetComponents ( L, comp, Standard_False ); | |
657 | for ( Standard_Integer k=1; k <= comp.Length(); k++ ) { | |
658 | TDF_Label lab = comp(k); | |
659 | TDF_Label ref; | |
660 | if ( ! XCAFDoc_ShapeTool::GetReferredShape ( lab, ref ) ) continue; | |
661 | TopoDS_Shape Scomp = TransferExternFiles ( ref, mode, labels, prefix ); | |
662 | Scomp.Location ( XCAFDoc_ShapeTool::GetLocation ( lab ) ); | |
663 | B.Add ( C, Scomp ); | |
664 | } | |
665 | myLabels.Bind ( L, C ); | |
666 | return C; | |
667 | } | |
668 | ||
669 | ||
670 | //======================================================================= | |
671 | //function : WriteExternRefs | |
672 | //purpose : | |
673 | //======================================================================= | |
674 | ||
675 | Standard_Boolean STEPCAFControl_Writer::WriteExternRefs (const Handle(XSControl_WorkSession) &WS, | |
676 | const TDF_LabelSequence &labels) const | |
677 | { | |
678 | if ( labels.Length() <=0 ) return Standard_False; | |
679 | ||
680 | Handle(XSControl_TransferWriter) TW = WS->TransferWriter(); | |
681 | Handle(Transfer_FinderProcess) FP = TW->FinderProcess(); | |
682 | STEPConstruct_ExternRefs EFTool ( WS ); | |
683 | Standard_Integer schema = Interface_Static::IVal("write.step.schema"); | |
684 | for ( Standard_Integer k=1; k <= labels.Length(); k++ ) { | |
685 | TDF_Label lab = labels(k); | |
686 | if ( XCAFDoc_ShapeTool::IsAssembly ( lab ) ) continue; // skip assemblies | |
687 | ||
688 | // get extern file | |
689 | Handle(STEPCAFControl_ExternFile) EF; | |
690 | if ( ! ExternFile ( lab, EF ) ) continue; // should never be | |
691 | ||
692 | // find SDR | |
693 | if ( ! myLabels.IsBound ( lab ) ) continue; // not recorded as translated, skip | |
694 | TopoDS_Shape S = myLabels.Find ( lab ); | |
695 | ||
696 | Handle(StepShape_ShapeDefinitionRepresentation) SDR; | |
697 | Handle(TransferBRep_ShapeMapper) mapper = TransferBRep::ShapeMapper ( FP, S ); | |
698 | if ( ! FP->FindTypedTransient ( mapper, STANDARD_TYPE(StepShape_ShapeDefinitionRepresentation), SDR ) ) { | |
0797d9d3 | 699 | #ifdef OCCT_DEBUG |
7fd59977 | 700 | cout << "Warning: Cannot find SDR for " << S.TShape()->DynamicType()->Name() << endl; |
701 | #endif | |
702 | continue; | |
703 | } | |
704 | ||
705 | // add extern ref | |
706 | const Standard_CString format = (const Standard_CString) ( schema == 3 ? "STEP AP203" : "STEP AP214" ); | |
707 | // try to get PD from SDR | |
708 | StepRepr_RepresentedDefinition RD = SDR->Definition(); | |
709 | Handle(StepRepr_PropertyDefinition) aPropDef = RD.PropertyDefinition(); | |
710 | if (aPropDef.IsNull()) { | |
0797d9d3 | 711 | #ifdef OCCT_DEBUG |
7fd59977 | 712 | cout << "Warning: STEPCAFControl_Writer::WriteExternRefs StepRepr_PropertyDefinition is null for " << S.TShape()->DynamicType()->Name() << endl; |
713 | #endif | |
714 | continue; | |
715 | } | |
716 | StepRepr_CharacterizedDefinition CharDef = aPropDef->Definition(); | |
717 | Handle(StepBasic_ProductDefinition) PD = CharDef.ProductDefinition(); | |
718 | if (PD.IsNull()) { | |
0797d9d3 | 719 | #ifdef OCCT_DEBUG |
7fd59977 | 720 | cout << "Warning: STEPCAFControl_Writer::WriteExternRefs StepBasic_ProductDefinition is null for " << S.TShape()->DynamicType()->Name() << endl; |
721 | #endif | |
722 | continue; | |
723 | } | |
724 | EFTool.AddExternRef ( EF->GetName()->ToCString(), PD, format ); | |
725 | } | |
726 | EFTool.WriteExternRefs(schema); | |
727 | return Standard_True; | |
728 | } | |
729 | ||
730 | ||
731 | //======================================================================= | |
732 | //function : FindEntities | |
733 | //purpose : auxilary | |
734 | //======================================================================= | |
735 | static Standard_Integer FindEntities (const Handle(Transfer_FinderProcess) &FP, | |
736 | const TopoDS_Shape &S, | |
737 | TopLoc_Location &L, | |
738 | TColStd_SequenceOfTransient &seqRI) | |
739 | { | |
740 | Handle(StepRepr_RepresentationItem) item = STEPConstruct::FindEntity ( FP, S, L ); | |
741 | ||
742 | if ( ! item.IsNull() ) { | |
743 | seqRI.Append ( item ); | |
744 | return 1; | |
745 | } | |
746 | ||
747 | // may be S was splited during shape processing | |
748 | Handle(TransferBRep_ShapeMapper) mapper = TransferBRep::ShapeMapper ( FP, S ); | |
749 | Handle(Transfer_Binder) bnd = FP->Find ( mapper ); | |
750 | if ( bnd.IsNull() ) return 0; | |
751 | ||
752 | Handle(Transfer_TransientListBinder) TransientListBinder = | |
753 | //Handle(Transfer_TransientListBinder)::DownCast( bnd->Next(Standard_True) ); | |
754 | Handle(Transfer_TransientListBinder)::DownCast( bnd ); | |
755 | Standard_Integer nres=0; | |
756 | if ( TransientListBinder.IsNull() && S.ShapeType() == TopAbs_COMPOUND) | |
757 | { | |
758 | for ( TopoDS_Iterator it(S); it.More(); it.Next() ) { | |
759 | Handle(StepRepr_RepresentationItem) item = STEPConstruct::FindEntity ( FP, it.Value(), L ); | |
760 | if ( item.IsNull() ) continue; | |
761 | nres++; | |
762 | seqRI.Append ( item ); | |
763 | } | |
764 | } | |
765 | else | |
766 | { | |
767 | const Standard_Integer nb = TransientListBinder->NbTransients(); | |
768 | for (Standard_Integer i=1; i<=nb; i++) { | |
769 | Handle(Standard_Transient) t = TransientListBinder->Transient(i); | |
770 | item = Handle(StepRepr_RepresentationItem)::DownCast(t); | |
771 | if ( item.IsNull() ) continue; | |
772 | nres++; | |
773 | seqRI.Append ( item ); | |
774 | } | |
775 | } | |
776 | /* works but is obsolete: another approach | |
777 | if (i<=nb) { | |
778 | TopoDS_Shape comp = TransferBRep::ShapeResult(bnd); | |
779 | if ( ! comp.IsNull() && comp.ShapeType() < S.ShapeType() ) { | |
780 | for ( TopoDS_Iterator it(comp); it.More(); it.Next() ) { | |
781 | MakeSTEPStyles(Styles, it.Value(), settings, STEPstyle, | |
782 | Map, ( hasOwn ? &style : 0 ) ); | |
783 | } | |
784 | } | |
785 | } | |
786 | */ | |
787 | return nres; | |
788 | } | |
789 | ||
790 | ||
791 | //======================================================================= | |
792 | //function : getStyledItem | |
793 | //purpose : auxilary | |
794 | //======================================================================= | |
795 | static Standard_Boolean getStyledItem(const TopoDS_Shape& S, | |
796 | const Handle(XCAFDoc_ShapeTool)& STool, | |
797 | const STEPConstruct_Styles &Styles, | |
798 | Handle(StepVisual_StyledItem) &resSelItem, | |
799 | const MoniTool_DataMapOfShapeTransient& myMapCompMDGPR) | |
800 | { | |
801 | TDF_Label aTopShL = STool->FindShape(S, Standard_False); | |
802 | TopoDS_Shape aTopLevSh = STool->GetShape( aTopShL ); | |
803 | Standard_Boolean found = Standard_False; | |
804 | if ( !aTopLevSh.IsNull() && myMapCompMDGPR.IsBound( aTopLevSh ) ) { | |
805 | Handle(StepVisual_PresentationRepresentation) aMDGPR = | |
806 | Handle(StepVisual_PresentationRepresentation)::DownCast( myMapCompMDGPR.Find( aTopLevSh ) ); | |
807 | Handle(StepRepr_HArray1OfRepresentationItem) anSelItmHArr = aMDGPR->Items(); | |
808 | // search for PSA of Monifold solid | |
809 | if ( !anSelItmHArr.IsNull() ) | |
810 | { | |
811 | for (Standard_Integer si = 1; si <= anSelItmHArr->Length(); si++) { | |
812 | Handle(StepVisual_StyledItem) aSelItm = | |
813 | Handle(StepVisual_StyledItem)::DownCast(anSelItmHArr->Value(si)); | |
814 | ||
815 | if ( aSelItm.IsNull() ) | |
816 | continue; | |
817 | ||
818 | // check that it is a stiled item for monifold solid brep | |
819 | TopLoc_Location Loc; | |
820 | TColStd_SequenceOfTransient aNewseqRI; | |
821 | FindEntities ( Styles.FinderProcess(), aTopLevSh, Loc, aNewseqRI ); | |
822 | if ( aNewseqRI.Length() > 0 ) | |
823 | { | |
824 | ||
825 | Handle(StepRepr_RepresentationItem) anItem = aSelItm->Item(); | |
826 | Standard_Boolean isSameMonSolBR = Standard_False; | |
827 | for (Standard_Integer mi = 1; mi <= aNewseqRI.Length(); mi++) { | |
828 | if ( !anItem.IsNull() && anItem == aNewseqRI.Value( mi ) ) { | |
829 | isSameMonSolBR = Standard_True; | |
830 | break; | |
831 | } | |
832 | } | |
833 | if (!isSameMonSolBR) | |
834 | continue; | |
835 | } | |
836 | ||
837 | ||
838 | for (Standard_Integer jsi = 1; jsi <= aSelItm->NbStyles() && !found; jsi++) { | |
839 | Handle(StepVisual_PresentationStyleAssignment) aFatherPSA = | |
840 | Handle(StepVisual_PresentationStyleAssignment)::DownCast(aSelItm->StylesValue(jsi)); | |
841 | // check for PSA for top-level (not Presentation style by contex for NAUO) | |
842 | if (aFatherPSA.IsNull() || aFatherPSA->IsKind(STANDARD_TYPE(StepVisual_PresentationStyleByContext))) | |
843 | continue; | |
844 | resSelItem = aSelItm; | |
845 | found = Standard_True; | |
846 | } | |
847 | } | |
848 | } | |
849 | } | |
850 | return found; | |
851 | } | |
852 | ||
853 | ||
854 | //======================================================================= | |
855 | //function : setDefaultInstanceColor | |
856 | //purpose : auxilary | |
857 | //======================================================================= | |
858 | static Standard_Boolean setDefaultInstanceColor (const Handle(StepVisual_StyledItem) &aSelItm, | |
859 | Handle(StepVisual_PresentationStyleAssignment)& PSA) | |
860 | { | |
861 | Standard_Boolean found = Standard_False; | |
862 | for (Standard_Integer jsi = 1; jsi <= aSelItm->NbStyles() && !found; jsi++) { | |
863 | Handle(StepVisual_PresentationStyleAssignment) aFatherPSA = | |
864 | Handle(StepVisual_PresentationStyleAssignment)::DownCast(aSelItm->StylesValue(jsi)); | |
865 | // check for PSA for top-level (not Presentation style by contex for NAUO) | |
866 | if (aFatherPSA.IsNull() || aFatherPSA->IsKind(STANDARD_TYPE(StepVisual_PresentationStyleByContext))) | |
867 | return Standard_False; | |
868 | ||
869 | // get style select from father PSA | |
870 | if (aFatherPSA->NbStyles() > 0) { | |
871 | Handle(StepVisual_HArray1OfPresentationStyleSelect) aFatherStyles = | |
872 | new StepVisual_HArray1OfPresentationStyleSelect(1, aFatherPSA->NbStyles()); | |
873 | for (Standard_Integer k = 1; k <= aFatherPSA->NbStyles(); k++) { | |
874 | StepVisual_PresentationStyleSelect PSS; | |
875 | StepVisual_PresentationStyleSelect olDPSS = aFatherPSA->StylesValue(k); | |
876 | if (!olDPSS.PointStyle().IsNull()) | |
877 | PSS.SetValue (olDPSS.PointStyle()); | |
878 | else if (!olDPSS.CurveStyle().IsNull()) | |
879 | PSS.SetValue (olDPSS.CurveStyle()); | |
880 | else if (!olDPSS.SurfaceStyleUsage().IsNull()) | |
881 | PSS.SetValue (olDPSS.SurfaceStyleUsage()); | |
882 | else { | |
883 | found = Standard_False; | |
884 | break; | |
885 | } | |
886 | //aFatherStyles->SetValue( k, PSS ); | |
887 | aFatherStyles->SetValue( k, olDPSS ); | |
888 | found = Standard_True; | |
889 | } | |
890 | // init PSA of NAUO | |
891 | if (found) { | |
892 | PSA->Init( aFatherStyles ); | |
893 | } | |
894 | } | |
895 | ||
896 | } | |
897 | return found; | |
898 | } | |
899 | ||
900 | ||
901 | //======================================================================= | |
902 | //function : MakeSTEPStyles | |
903 | //purpose : auxilary | |
904 | //======================================================================= | |
905 | static void MakeSTEPStyles (STEPConstruct_Styles &Styles, | |
906 | const TopoDS_Shape &S, | |
907 | const XCAFPrs_DataMapOfShapeStyle &settings, | |
908 | Handle(StepVisual_StyledItem) &override, | |
909 | TopTools_MapOfShape &Map, | |
910 | const MoniTool_DataMapOfShapeTransient& myMapCompMDGPR, | |
911 | STEPConstruct_DataMapOfAsciiStringTransient &DPDCs, | |
912 | STEPConstruct_DataMapOfPointTransient &ColRGBs, | |
913 | const Handle(XCAFDoc_ColorTool)& CTool, | |
914 | const XCAFPrs_Style *inherit = 0, | |
915 | const Standard_Boolean isComponent = Standard_False) | |
916 | { | |
917 | // skip already processed shapes | |
918 | if ( ! Map.Add ( S ) ) return; | |
919 | ||
920 | // check if shape has its own style (r inherits from ancestor) | |
921 | XCAFPrs_Style style; | |
922 | if ( inherit ) style = *inherit; | |
923 | if ( settings.IsBound(S) ) { | |
924 | XCAFPrs_Style own = settings.Find(S); | |
925 | if ( !own.IsVisible() ) style.SetVisibility ( Standard_False ); | |
926 | if ( own.IsSetColorCurv() ) style.SetColorCurv ( own.GetColorCurv() ); | |
927 | if ( own.IsSetColorSurf() ) style.SetColorSurf ( own.GetColorSurf() ); | |
928 | } | |
929 | ||
930 | // translate colors to STEP | |
931 | Handle(StepVisual_Colour) surfColor, curvColor; | |
932 | if ( style.IsSetColorSurf() ) | |
933 | surfColor = Styles.EncodeColor(style.GetColorSurf(),DPDCs,ColRGBs); | |
934 | if ( style.IsSetColorCurv() ) | |
935 | curvColor = Styles.EncodeColor(style.GetColorCurv(),DPDCs,ColRGBs); | |
936 | ||
937 | Standard_Boolean hasOwn = ( ! surfColor.IsNull() || | |
938 | ! curvColor.IsNull() || | |
939 | ! style.IsVisible() ); | |
940 | ||
941 | // find target item and assign style to it | |
942 | Handle(StepVisual_StyledItem) STEPstyle = override; | |
943 | if ( hasOwn ) { | |
944 | if ( S.ShapeType() != TopAbs_COMPOUND || isComponent ) { // skip compounds, let subshapes inherit its colors | |
945 | TopLoc_Location L; | |
946 | TColStd_SequenceOfTransient seqRI; | |
947 | Standard_Integer nb = FindEntities ( Styles.FinderProcess(), S, L, seqRI ); | |
0797d9d3 | 948 | #ifdef OCCT_DEBUG |
7fd59977 | 949 | if ( nb <=0 ) cout << "Warning: Cannot find RI for " << S.TShape()->DynamicType()->Name() << endl; |
950 | #endif | |
951 | //Get overridden style gka 10.06.03 | |
952 | if ( isComponent && nb) | |
953 | getStyledItem(S, CTool->ShapeTool(), Styles, override,myMapCompMDGPR); | |
954 | ||
955 | ||
956 | for ( Standard_Integer i=1; i <= nb; i++ ) { | |
957 | Handle(StepRepr_RepresentationItem) item = | |
958 | Handle(StepRepr_RepresentationItem)::DownCast(seqRI(i)); | |
959 | Handle(StepVisual_PresentationStyleAssignment) PSA; | |
960 | if ( style.IsVisible() || !surfColor.IsNull() || !curvColor.IsNull() ) { | |
961 | PSA = Styles.MakeColorPSA ( item, surfColor, curvColor, isComponent ); | |
962 | } | |
963 | else { | |
964 | // default white color | |
965 | surfColor = Styles.EncodeColor(Quantity_Color(1,1,1,Quantity_TOC_RGB),DPDCs,ColRGBs); | |
966 | PSA = Styles.MakeColorPSA ( item, surfColor, curvColor, isComponent ); | |
967 | if ( isComponent ) | |
968 | setDefaultInstanceColor( override, PSA); | |
969 | ||
970 | } // end of component case | |
971 | ||
972 | STEPstyle = Styles.AddStyle ( item, PSA, override ); | |
973 | hasOwn = Standard_False; | |
974 | } | |
975 | } | |
976 | } | |
977 | ||
978 | // iterate on subshapes (except vertices :) | |
979 | if ( S.ShapeType() == TopAbs_EDGE ) return; | |
980 | if ( !isComponent ) // PTV 10.02.2003 | |
981 | for ( TopoDS_Iterator it(S); it.More(); it.Next() ) { | |
982 | MakeSTEPStyles ( Styles, it.Value(), settings, STEPstyle, | |
983 | Map, myMapCompMDGPR, DPDCs, ColRGBs, CTool, | |
984 | ( hasOwn ? &style : 0 ) ); | |
985 | } | |
986 | } | |
987 | ||
988 | /* | |
989 | static Standard_Boolean getFatherColor (const TDF_Label& L, | |
990 | const Handle(XCAFDoc_ColorTool)& CTool, | |
991 | XCAFPrs_Style& style) | |
992 | { | |
993 | Standard_Boolean done = Standard_False; | |
994 | TopoDS_Shape aSh = CTool->ShapeTool()->GetShape( L ); | |
995 | TDF_Label aFL = CTool->ShapeTool()->FindShape( aSh ); | |
996 | if (aFL.IsNull() || aFL == L) | |
997 | return done; | |
998 | Quantity_Color C; | |
999 | if ( CTool->GetColor ( aFL, XCAFDoc_ColorGen, C ) ) { | |
1000 | style.SetColorCurv ( C ); | |
1001 | style.SetColorSurf ( C ); | |
1002 | done = Standard_True; | |
1003 | } | |
1004 | if ( CTool->GetColor ( aFL, XCAFDoc_ColorSurf, C ) ) { | |
1005 | style.SetColorSurf ( C ); | |
1006 | done = Standard_True; | |
1007 | } | |
1008 | if ( CTool->GetColor ( aFL, XCAFDoc_ColorCurv, C ) ) { | |
1009 | style.SetColorCurv ( C ); | |
1010 | done = Standard_True; | |
1011 | } | |
1012 | ||
1013 | return done; | |
1014 | } | |
1015 | */ | |
1016 | ||
1017 | ||
1018 | //======================================================================= | |
1019 | //function : WriteColors | |
1020 | //purpose : | |
1021 | //======================================================================= | |
1022 | ||
1023 | Standard_Boolean STEPCAFControl_Writer::WriteColors (const Handle(XSControl_WorkSession) &WS, | |
1024 | const TDF_LabelSequence &labels) | |
1025 | { | |
1026 | if ( labels.Length() <=0 ) return Standard_False; | |
1027 | ||
1028 | // Iterate on shapes in the document | |
1029 | Handle(XCAFDoc_ColorTool) CTool = XCAFDoc_DocumentTool::ColorTool( labels(1) ); | |
1030 | if ( CTool.IsNull() ) return Standard_False; | |
1031 | ||
1032 | STEPConstruct_Styles Styles ( WS ); | |
1033 | STEPConstruct_DataMapOfAsciiStringTransient DPDCs; | |
1034 | STEPConstruct_DataMapOfPointTransient ColRGBs; | |
1035 | for ( Standard_Integer i=1; i <= labels.Length(); i++ ) { | |
1036 | TDF_Label L = labels.Value(i); | |
1037 | ||
1038 | Handle(XCAFDoc_ShapeTool) aSTool = XCAFDoc_DocumentTool::ShapeTool( labels(1) ); | |
1039 | // Skip assemblies: colors assigned to assemblies and their instances | |
1040 | // are not supported (it is not clear how to encode that in STEP) | |
1041 | if ( XCAFDoc_ShapeTool::IsAssembly ( L ) ) { | |
0797d9d3 | 1042 | #ifdef OCCT_DEBUG |
7fd59977 | 1043 | cout << "Warning: Cannot write color for Assembly" << endl; |
1044 | cout << "Info: Check for colors assigned to components in assembly" << endl; | |
1045 | #endif | |
1046 | // PTV 22.01.2003 Write color for instances. | |
1047 | TDF_LabelSequence compLabels; | |
1048 | if ( aSTool.IsNull() ) | |
1049 | continue; | |
1050 | if (!aSTool->GetComponents(L, compLabels)) | |
1051 | continue; | |
1052 | WriteColors(WS, compLabels); | |
1053 | continue; | |
1054 | } | |
1055 | Styles.ClearStyles(); | |
1056 | ||
1057 | // get a target shape and try to find corresponding context | |
1058 | // (all the colors set under that label will be put into that context) | |
1059 | TopoDS_Shape S; | |
1060 | if ( ! XCAFDoc_ShapeTool::GetShape ( L, S ) ) continue; | |
1061 | Standard_Boolean isComponent = aSTool->IsComponent( L ); | |
1062 | TopoDS_Shape aTopSh = S; | |
1063 | Handle(StepRepr_RepresentationContext) Context = Styles.FindContext ( S ); | |
1064 | if ( isComponent ) { | |
1065 | TDF_Label aTopShL = aSTool->FindShape(S, Standard_False); | |
1066 | if (aTopShL.IsNull()) | |
1067 | continue; | |
1068 | aTopSh = aSTool->GetShape( aTopShL ); | |
1069 | Context = Styles.FindContext ( aTopSh ); | |
1070 | } | |
1071 | if ( Context.IsNull() ) | |
1072 | continue; | |
1073 | ||
1074 | // collect settings set on that label | |
1075 | XCAFPrs_DataMapOfShapeStyle settings; | |
1076 | TDF_LabelSequence seq; | |
1077 | seq.Append ( L ); | |
1078 | XCAFDoc_ShapeTool::GetSubShapes ( L, seq ); | |
1079 | Standard_Boolean isVisible = Standard_True; | |
1080 | for ( Standard_Integer j = 1; j <= seq.Length(); j++ ) { | |
1081 | TDF_Label lab = seq.Value(j); | |
1082 | XCAFPrs_Style style; | |
1083 | Quantity_Color C; | |
574d7236 | 1084 | if ( lab == L ) { |
7fd59977 | 1085 | // check for invisible status of object on label |
1086 | if ( !CTool->IsVisible( lab ) ) { | |
1087 | isVisible = Standard_False; | |
1088 | style.SetVisibility( Standard_False ); | |
1089 | } | |
1090 | } | |
1091 | if ( CTool->GetColor ( lab, XCAFDoc_ColorGen, C ) ) { | |
ec99ba32 G |
1092 | style.SetColorCurv ( C ); |
1093 | style.SetColorSurf ( C ); | |
7fd59977 | 1094 | } |
1095 | if ( CTool->GetColor ( lab, XCAFDoc_ColorSurf, C ) ) | |
ec99ba32 | 1096 | style.SetColorSurf ( C ); |
7fd59977 | 1097 | if ( CTool->GetColor ( lab, XCAFDoc_ColorCurv, C ) ) |
ec99ba32 G |
1098 | style.SetColorCurv ( C ); |
1099 | ||
7fd59977 | 1100 | // commented, cause we are need to take reference from |
1101 | // if ( isComponent && lab == L && !isVisible) | |
1102 | // if ( !style.IsSetColorSurf() && !style.IsSetColorCurv() ) { | |
1103 | // getFatherColor ( L, CTool, style); | |
1104 | // } | |
1105 | if ( ! style.IsSetColorCurv() && ! style.IsSetColorSurf() && isVisible ) continue; | |
1106 | ||
1107 | TopoDS_Shape sub = XCAFDoc_ShapeTool::GetShape ( lab ); | |
1108 | settings.Bind ( sub, style ); | |
1109 | } | |
1110 | ||
1111 | if ( settings.Extent() <=0 ) continue; | |
1112 | ||
1113 | // iterate on subshapes and create STEP styles | |
1114 | Handle(StepVisual_StyledItem) override; | |
1115 | TopTools_MapOfShape Map; | |
1116 | ||
1117 | MakeSTEPStyles(Styles,S,settings,override,Map,myMapCompMDGPR,DPDCs,ColRGBs,CTool,0,isComponent); | |
1118 | ||
1119 | // create MDGPR and record it in model | |
1120 | Handle(StepVisual_MechanicalDesignGeometricPresentationRepresentation) aMDGPR; | |
1121 | ||
1122 | if (!isComponent) { | |
1123 | if ( myMapCompMDGPR.IsBound( aTopSh )) { | |
0797d9d3 | 1124 | #ifdef OCCT_DEBUG |
7fd59977 | 1125 | cerr << "Error: Current Top-Level shape have MDGPR already " << endl; |
1126 | #endif | |
1127 | } | |
1128 | Styles.CreateMDGPR ( Context, aMDGPR ); | |
1129 | if (!aMDGPR.IsNull()) | |
1130 | myMapCompMDGPR.Bind( aTopSh, aMDGPR ); | |
1131 | } | |
1132 | else { | |
1133 | // create SDR and add to model. | |
1134 | Handle(XSControl_TransferWriter) TW = WS->TransferWriter(); | |
1135 | Handle(Transfer_FinderProcess) FP = TW->FinderProcess(); | |
1136 | Handle(TransferBRep_ShapeMapper) mapper = TransferBRep::ShapeMapper ( FP, S ); | |
1137 | Handle(StepShape_ContextDependentShapeRepresentation) CDSR; | |
1138 | if ( FP->FindTypedTransient(mapper, | |
1139 | STANDARD_TYPE(StepShape_ContextDependentShapeRepresentation), | |
1140 | CDSR) ) { | |
1141 | // create SDR for NAUO | |
1142 | Handle(StepRepr_ProductDefinitionShape) nullPDS; // important to be NULL | |
1143 | Styles.CreateNAUOSRD( Context, CDSR, nullPDS ); | |
1144 | ||
1145 | // search for MDGPR of the component top-level shape | |
1146 | if ( myMapCompMDGPR.IsBound( aTopSh )) { | |
1147 | aMDGPR = Handle(StepVisual_MechanicalDesignGeometricPresentationRepresentation)::DownCast( myMapCompMDGPR.Find( aTopSh ) ); | |
1148 | } else { | |
1149 | aMDGPR = new StepVisual_MechanicalDesignGeometricPresentationRepresentation; | |
1150 | Handle(TCollection_HAsciiString) ReprName = new TCollection_HAsciiString ( "" ); | |
1151 | aMDGPR->SetName( ReprName ); | |
1152 | aMDGPR->SetContextOfItems( Context ); | |
1153 | myMapCompMDGPR.Bind ( aTopSh, aMDGPR ); | |
1154 | } | |
1155 | Handle(StepRepr_HArray1OfRepresentationItem) oldItems = aMDGPR->Items(); | |
1156 | Standard_Integer oldLengthlen = 0; | |
1157 | if (!oldItems.IsNull()) | |
1158 | oldLengthlen = oldItems->Length(); | |
1159 | const Standard_Integer nbIt = oldLengthlen + Styles.NbStyles(); | |
1160 | if(!nbIt) | |
1161 | continue; | |
1162 | Handle(StepRepr_HArray1OfRepresentationItem) newItems = | |
1163 | new StepRepr_HArray1OfRepresentationItem(1, nbIt); | |
1164 | Standard_Integer si; | |
1165 | Standard_Integer el = 1; | |
1166 | for ( si=1; si <= oldLengthlen; si++ ) | |
1167 | newItems->SetValue( el++, oldItems->Value( si ) ); | |
1168 | for ( si=1; si <= Styles.NbStyles(); si++ ) { | |
1169 | newItems->SetValue( el++, Handle(StepRepr_RepresentationItem)::DownCast(Styles.Style(si))); | |
1170 | // WP->Model()->AddWithRefs ( Handle(StepRepr_RepresentationItem)::DownCast (Styles.Style(si))); | |
1171 | } | |
574d7236 | 1172 | |
7fd59977 | 1173 | if (newItems->Length() > 0) |
1174 | aMDGPR->SetItems( newItems ); | |
1175 | } //end of work with CDSR | |
1176 | } | |
574d7236 | 1177 | if ( !isVisible ) { |
1178 | // create invisibility item and refer for stiledItem | |
1179 | Handle(StepVisual_Invisibility) Invsblt = new StepVisual_Invisibility(); | |
1180 | Handle(StepVisual_HArray1OfInvisibleItem) HInvsblItm = | |
1181 | new StepVisual_HArray1OfInvisibleItem (1,Styles.NbStyles()); | |
1182 | // put all style item into the harray | |
1183 | for ( Standard_Integer si=1; si <= Styles.NbStyles(); si++ ) { | |
1184 | Handle(StepRepr_RepresentationItem) styledItm = | |
1185 | Handle(StepRepr_RepresentationItem)::DownCast(Styles.Style(si)); | |
1186 | StepVisual_InvisibleItem anInvItem; | |
1187 | anInvItem.SetValue( styledItm ); | |
1188 | HInvsblItm->SetValue( si, anInvItem ); | |
1189 | } | |
1190 | // set the invisibility of items | |
1191 | Invsblt->Init( HInvsblItm ); | |
1192 | WS->Model()->AddWithRefs( Invsblt ); | |
1193 | } | |
7fd59977 | 1194 | } |
1195 | ||
1196 | return Standard_True; | |
1197 | } | |
1198 | ||
1199 | ||
1200 | //======================================================================= | |
1201 | //function : WriteNames | |
1202 | //purpose : | |
1203 | //======================================================================= | |
1204 | ||
1205 | Standard_Boolean STEPCAFControl_Writer::WriteNames (const Handle(XSControl_WorkSession) &WS, | |
1206 | const TDF_LabelSequence &labels) const | |
1207 | { | |
1208 | if ( labels.Length() <=0 ) return Standard_False; | |
1209 | ||
1210 | // get working data | |
1211 | Handle(Interface_InterfaceModel) Model = WS->Model(); | |
1212 | Handle(XSControl_TransferWriter) TW = WS->TransferWriter(); | |
1213 | Handle(Transfer_FinderProcess) FP = TW->FinderProcess(); | |
1214 | // Handle(XCAFDoc_ShapeTool) STool = XCAFDoc_DocumentTool::ShapeTool( labels(1) ); | |
1215 | // if ( STool.IsNull() ) return Standard_False; | |
1216 | ||
1217 | // Iterate on requested shapes | |
1218 | for ( Standard_Integer i=1; i <= labels.Length(); i++ ) { | |
1219 | TDF_Label L = labels.Value(i); | |
1220 | ||
1221 | // get name | |
1222 | Handle(TCollection_HAsciiString) hName = new TCollection_HAsciiString; | |
1223 | if ( ! GetLabelName (L, hName) ) continue; | |
1224 | // Handle(TDataStd_Name) N; | |
1225 | // if ( ! L.FindAttribute ( TDataStd_Name::GetID(), N ) ) continue; | |
1226 | // TCollection_ExtendedString name = N->Get(); | |
1227 | // if ( name.Length() <=0 ) continue; | |
1228 | ||
1229 | // find target STEP entity for the current shape | |
1230 | // TopoDS_Shape S; | |
1231 | // if ( ! XCAFDoc_ShapeTool::GetShape ( L, S ) ) continue; | |
1232 | if ( ! myLabels.IsBound ( L ) ) continue; // not recorded as translated, skip | |
1233 | TopoDS_Shape S = myLabels.Find ( L ); | |
1234 | ||
1235 | Handle(StepShape_ShapeDefinitionRepresentation) SDR; | |
1236 | Handle(TransferBRep_ShapeMapper) mapper = TransferBRep::ShapeMapper ( FP, S ); | |
1237 | if ( ! FP->FindTypedTransient ( mapper, STANDARD_TYPE(StepShape_ShapeDefinitionRepresentation), SDR ) ) { | |
0797d9d3 | 1238 | #ifdef OCCT_DEBUG |
7fd59977 | 1239 | cout << "Warning: Cannot find SDR for " << S.TShape()->DynamicType()->Name() << endl; |
1240 | #endif | |
1241 | continue; | |
1242 | } | |
1243 | ||
1244 | // set the name to the PRODUCT | |
1245 | Handle(StepRepr_PropertyDefinition) PropD = SDR->Definition().PropertyDefinition(); | |
1246 | if ( PropD.IsNull() ) continue; | |
1247 | Handle(StepBasic_ProductDefinition) PD = PropD->Definition().ProductDefinition(); | |
1248 | if ( PD.IsNull() ) continue; | |
1249 | Handle(StepBasic_Product) Prod = PD->Formation()->OfProduct(); | |
1250 | ||
1251 | Prod->SetId ( hName ); | |
1252 | Prod->SetName ( hName ); | |
1253 | ||
1254 | // write names for components of assemblies | |
1255 | if ( XCAFDoc_ShapeTool::IsAssembly ( L ) ) { | |
1256 | TDF_LabelSequence seq; | |
1257 | XCAFDoc_ShapeTool::GetComponents ( L, seq ); | |
1258 | for (Standard_Integer k=1; k <= seq.Length(); k++) { | |
1259 | TDF_Label lab = seq(k); | |
1260 | ||
1261 | // get shape with correct location | |
1262 | TDF_Label Lref; | |
1263 | if ( ! XCAFDoc_ShapeTool::GetReferredShape ( lab, Lref ) || | |
1264 | ! myLabels.IsBound ( Lref ) ) continue; | |
1265 | S = myLabels.Find ( Lref ); | |
1266 | S.Move ( XCAFDoc_ShapeTool::GetLocation ( lab ) ); | |
1267 | ||
1268 | hName = new TCollection_HAsciiString; | |
1269 | if ( ! GetLabelName (lab, hName) ) continue; | |
1270 | ||
1271 | // find the target CDSR corresponding to a shape | |
1272 | mapper = TransferBRep::ShapeMapper ( FP, S ); | |
1273 | Handle(Transfer_Binder) binder = FP->Find ( mapper ); | |
1274 | Handle(StepShape_ContextDependentShapeRepresentation) CDSR; | |
1275 | if ( ! FP->FindTypedTransient (mapper,STANDARD_TYPE(StepShape_ContextDependentShapeRepresentation), CDSR) ) | |
1276 | continue; | |
1277 | Handle(StepRepr_ProductDefinitionShape) PDS = CDSR->RepresentedProductRelation(); | |
1278 | Handle(StepBasic_ProductDefinitionRelationship) NAUO = PDS->Definition().ProductDefinitionRelationship(); | |
1279 | if ( ! NAUO.IsNull() ) NAUO->SetName ( hName ); | |
1280 | } | |
1281 | } | |
1282 | } | |
1283 | ||
1284 | return Standard_True; | |
1285 | } | |
1286 | ||
1287 | ||
1288 | //======================================================================= | |
1289 | //function : WritePropsForLabel | |
1290 | //purpose : | |
1291 | //======================================================================= | |
1292 | static Standard_Boolean WritePropsForLabel(const Handle(XSControl_WorkSession) &WS, | |
1293 | const Handle(XCAFDoc_ShapeTool) &aSTool, | |
1294 | const STEPCAFControl_DataMapOfLabelShape &myLabels, | |
1295 | const TDF_Label &L, | |
1296 | const Standard_CString multi) | |
1297 | { | |
1298 | if(L.IsNull()) return Standard_False; | |
1299 | ||
1300 | STEPConstruct_ValidationProps Props ( WS ); | |
1301 | ||
1302 | TopoDS_Shape S = aSTool->GetShape(L); | |
1303 | if(S.IsNull()) return Standard_False; | |
1304 | ||
1305 | if ( ! multi || XCAFDoc_ShapeTool::IsAssembly ( L ) ) { | |
1306 | // write area | |
1307 | Handle(XCAFDoc_Area) A; | |
1308 | L.FindAttribute ( XCAFDoc_Area::GetID(), A ); | |
1309 | if ( ! A.IsNull() ) { | |
1310 | Props.AddArea ( S, A->Get() ); | |
1311 | } | |
1312 | // write volume | |
1313 | Handle(XCAFDoc_Volume) V; | |
1314 | L.FindAttribute ( XCAFDoc_Volume::GetID(), V ); | |
1315 | if ( ! V.IsNull() ) { | |
1316 | Props.AddVolume ( S, V->Get() ); | |
1317 | } | |
1318 | } | |
1319 | // write centroid | |
1320 | Handle(XCAFDoc_Centroid) C; | |
1321 | L.FindAttribute ( XCAFDoc_Centroid::GetID(), C ); | |
1322 | if ( ! C.IsNull() ) { | |
1323 | Props.AddCentroid ( S, C->Get() ); | |
1324 | } | |
1325 | ||
1326 | if( XCAFDoc_ShapeTool::IsCompound(L) || XCAFDoc_ShapeTool::IsAssembly(L) ) { | |
1327 | if(L.HasChild()) { | |
1328 | for(Standard_Integer ich=1; ich<=L.NbChildren(); ich++) { | |
1329 | WritePropsForLabel(WS,aSTool,myLabels,L.FindChild(ich),multi); | |
1330 | } | |
1331 | } | |
1332 | } | |
1333 | ||
1334 | return Standard_True; | |
1335 | } | |
1336 | ||
1337 | ||
1338 | //======================================================================= | |
1339 | //function : WriteValProps | |
1340 | //purpose : | |
1341 | //======================================================================= | |
1342 | ||
1343 | Standard_Boolean STEPCAFControl_Writer::WriteValProps (const Handle(XSControl_WorkSession) &WS, | |
1344 | const TDF_LabelSequence &labels, | |
1345 | const Standard_CString multi) const | |
1346 | { | |
1347 | if ( labels.Length() <=0 ) return Standard_False; | |
1348 | ||
1349 | // get working data | |
1350 | // STEPConstruct_ValidationProps Props ( WS ); | |
1351 | Handle(XCAFDoc_ShapeTool) aSTool = XCAFDoc_DocumentTool::ShapeTool( labels(1) ); | |
1352 | ||
1353 | // Iterate on requested shapes | |
1354 | for ( Standard_Integer i=1; i <= labels.Length(); i++ ) { | |
1355 | TDF_Label L = labels.Value(i); | |
1356 | ||
1357 | WritePropsForLabel(WS,aSTool,myLabels,L,multi); | |
1358 | /* | |
1359 | // find target STEP entity for the current shape | |
1360 | if ( ! myLabels.IsBound ( L ) ) continue; // not recorded as translated, skip | |
1361 | TopoDS_Shape S = myLabels.Find ( L ); | |
1362 | ||
1363 | // write area and volume (except for components in multifile mode) | |
1364 | if ( ! multi || XCAFDoc_ShapeTool::IsAssembly ( L ) ) { | |
1365 | Handle(XCAFDoc_Area) A; | |
1366 | L.FindAttribute ( XCAFDoc_Area::GetID(), A ); | |
1367 | if ( ! A.IsNull() ) Props.AddArea ( S, A->Get() ); | |
1368 | ||
1369 | Handle(XCAFDoc_Volume) V; | |
1370 | L.FindAttribute ( XCAFDoc_Volume::GetID(), V ); | |
1371 | if ( ! V.IsNull() ) Props.AddVolume ( S, V->Get() ); | |
1372 | } | |
1373 | ||
1374 | // write centroid | |
1375 | Handle(XCAFDoc_Centroid) C; | |
1376 | L.FindAttribute ( XCAFDoc_Centroid::GetID(), C ); | |
1377 | if ( ! C.IsNull() ) Props.AddCentroid ( S, C->Get() ); | |
1378 | ||
1379 | // write centroid for components of assemblies | |
1380 | if ( XCAFDoc_ShapeTool::IsAssembly ( L ) ) { | |
1381 | TDF_LabelSequence seq; | |
1382 | XCAFDoc_ShapeTool::GetComponents ( L, seq ); | |
1383 | for (Standard_Integer k=1; k <= seq.Length(); k++) { | |
1384 | TDF_Label lab = seq(k); | |
1385 | ||
1386 | // get shape with correct location | |
1387 | TDF_Label Lref; | |
1388 | if ( ! XCAFDoc_ShapeTool::GetReferredShape ( lab, Lref ) || | |
1389 | ! myLabels.IsBound ( Lref ) ) continue; | |
1390 | TopLoc_Location Loc = XCAFDoc_ShapeTool::GetLocation ( lab ); | |
1391 | S = myLabels.Find ( Lref ); | |
1392 | S.Move ( Loc ); | |
1393 | ||
1394 | C.Nullify(); | |
1395 | lab.FindAttribute ( XCAFDoc_Centroid::GetID(), C ); | |
1396 | // if centroid is not assigned to an instance, | |
1397 | // use (shifted) centroid of original shape | |
1398 | gp_Pnt center; | |
1399 | if ( C.IsNull() ) { | |
1400 | Lref.FindAttribute ( XCAFDoc_Centroid::GetID(), C ); | |
1401 | if ( C.IsNull() ) continue; | |
1402 | center = C->Get().Transformed ( Loc.Transformation() ); | |
1403 | } | |
1404 | else center = C->Get(); | |
1405 | ||
1406 | Props.AddCentroid ( S, center, Standard_True ); | |
1407 | } | |
1408 | } | |
1409 | */ | |
1410 | } | |
1411 | ||
1412 | return Standard_True; | |
1413 | } | |
1414 | ||
1415 | ||
1416 | //======================================================================= | |
1417 | //function : WriteLayers | |
1418 | //purpose : | |
1419 | //======================================================================= | |
1420 | ||
1421 | Standard_Boolean STEPCAFControl_Writer::WriteLayers (const Handle(XSControl_WorkSession) &WS, | |
1422 | const TDF_LabelSequence &labels ) const | |
1423 | { | |
1424 | ||
1425 | if ( labels.Length() <=0 ) return Standard_False; | |
1426 | ||
1427 | // get working data | |
1428 | Handle(Interface_InterfaceModel) Model = WS->Model(); | |
1429 | Handle(XSControl_TransferWriter) TW = WS->TransferWriter(); | |
1430 | Handle(Transfer_FinderProcess) FP = TW->FinderProcess(); | |
1431 | Handle(XCAFDoc_LayerTool) LTool = XCAFDoc_DocumentTool::LayerTool( labels(1) ); | |
1432 | if (LTool.IsNull() ) return Standard_False; | |
1433 | ||
1434 | TDF_LabelSequence LayerLS; | |
1435 | LTool->GetLayerLabels(LayerLS); | |
1436 | if ( LayerLS.Length() <=0 ) return Standard_False; | |
1437 | ||
1438 | // Iterate on requested layers and for each layer take set of shapes. | |
1439 | for ( Standard_Integer i=1; i <= LayerLS.Length(); i++ ) { | |
1440 | TDF_Label L = LayerLS.Value(i); | |
1441 | ||
1442 | // get labels of shapes in that layer | |
1443 | TDF_LabelSequence ShapeLs; | |
1444 | LTool->GetShapesOfLayer(L, ShapeLs); | |
1445 | if ( ShapeLs.Length() <=0 ) continue; | |
1446 | ||
1447 | // name of layer: if not set, is considered as being empty | |
1448 | Handle(TCollection_HAsciiString) hName = new TCollection_HAsciiString; | |
1449 | GetLabelName ( L, hName ); | |
1450 | ||
1451 | // Find target STEP entity for each shape and add to StepVisual_PresentationLayerAssignment items. | |
1452 | TColStd_SequenceOfTransient seqRI; | |
1453 | for ( Standard_Integer j=1; j <= ShapeLs.Length(); j++) { | |
1454 | TDF_Label shLabel = ShapeLs.Value(j); | |
1455 | if ( shLabel.IsNull() ) continue; | |
1456 | ||
1457 | // there is no way to assign layer to instance in STEP | |
1458 | if ( XCAFDoc_ShapeTool::IsAssembly ( shLabel ) || | |
1459 | XCAFDoc_ShapeTool::IsReference ( shLabel ) ) | |
1460 | continue; | |
1461 | ||
1462 | // check that the shape is one of (uub)labels written during current transfer | |
1463 | Standard_Integer k = 1; | |
1464 | for ( ; k <= labels.Length(); k++ ) | |
1465 | if ( shLabel.IsDescendant ( labels(k) ) ) break; | |
1466 | if ( k > labels.Length() ) continue; | |
1467 | ||
1468 | // get target STEP entity | |
1469 | TopoDS_Shape oneShape = XCAFDoc_ShapeTool::GetShape(shLabel); | |
1470 | ||
1471 | TopLoc_Location Loc; | |
1472 | Standard_Integer nb = | |
1473 | FindEntities ( FP, oneShape, Loc, seqRI ); | |
1474 | if ( nb <=0 ) | |
1475 | FP->Messenger() << "Warning: Cannot find RI for " << oneShape.TShape()->DynamicType()->Name() << endl; | |
1476 | } | |
1477 | if ( seqRI.Length() <= 0 ) continue; | |
1478 | ||
1479 | // analyze visibility | |
1480 | Handle(StepVisual_PresentationLayerAssignment) StepLayerAs = new StepVisual_PresentationLayerAssignment; | |
1481 | Handle(TCollection_HAsciiString) descr; | |
1482 | Handle(TDataStd_UAttribute) aUAttr; | |
1483 | Standard_Boolean isLinv = Standard_False; | |
1484 | if (L.FindAttribute(XCAFDoc::InvisibleGUID(), aUAttr)) { | |
1485 | descr = new TCollection_HAsciiString ("invisible"); | |
0797d9d3 | 1486 | #ifdef OCCT_DEBUG |
7fd59977 | 1487 | FP->Messenger() << "\tLayer \"" << hName->String().ToCString() << "\" is invisible"<<endl; |
1488 | #endif | |
1489 | isLinv = Standard_True; | |
1490 | } | |
1491 | else descr = new TCollection_HAsciiString ("visible"); | |
1492 | ||
1493 | // create layer entity | |
1494 | Handle(StepVisual_HArray1OfLayeredItem) HArrayOfLItem = | |
1495 | new StepVisual_HArray1OfLayeredItem ( 1, seqRI.Length() ); | |
1496 | for (Standard_Integer i1 = 1; i1<=seqRI.Length(); i1++) { | |
1497 | StepVisual_LayeredItem LI; | |
1498 | LI.SetValue ( seqRI.Value(i1) ); | |
1499 | HArrayOfLItem->SetValue( i1, LI ); | |
1500 | } | |
1501 | StepLayerAs->Init(hName, descr, HArrayOfLItem); | |
1502 | Model->AddWithRefs( StepLayerAs ); | |
1503 | // PTV 23.01.2003 add the invisibility AFTER adding layer into the model. | |
1504 | // add the invisibility for the layer | |
1505 | if (isLinv) { | |
1506 | // Invisibility Item for containig invisible layers. | |
1507 | Handle(StepVisual_HArray1OfInvisibleItem) HInvsblItm = new StepVisual_HArray1OfInvisibleItem (1,1); | |
1508 | StepVisual_InvisibleItem InvIt; | |
1509 | InvIt.SetValue( StepLayerAs ); | |
1510 | HInvsblItm->SetValue( 1, InvIt); | |
1511 | ||
1512 | Handle(StepVisual_Invisibility) Invsblt = new StepVisual_Invisibility(); | |
1513 | Invsblt->Init( HInvsblItm ); | |
1514 | Model->AddWithRefs( Invsblt ); | |
1515 | } | |
1516 | } | |
1517 | return Standard_True; | |
1518 | } | |
1519 | ||
1520 | ||
1521 | //======================================================================= | |
1522 | //function : getSHUOstyle | |
1523 | //purpose : auxilary | |
1524 | //======================================================================= | |
1525 | static Standard_Boolean getSHUOstyle(const TDF_Label& aSHUOlab, | |
1526 | const Handle(XCAFDoc_ColorTool)& CTool, | |
1527 | XCAFPrs_Style& SHUOstyle) | |
1528 | { | |
1529 | Quantity_Color C; | |
1530 | if (!CTool->IsVisible( aSHUOlab ) ) | |
1531 | SHUOstyle.SetVisibility(Standard_False); | |
1532 | else { | |
1533 | if ( CTool->GetColor ( aSHUOlab, XCAFDoc_ColorGen, C ) ) { | |
1534 | SHUOstyle.SetColorCurv ( C ); | |
1535 | SHUOstyle.SetColorSurf ( C ); | |
1536 | } | |
1537 | if ( CTool->GetColor ( aSHUOlab, XCAFDoc_ColorSurf, C ) ) | |
1538 | SHUOstyle.SetColorSurf ( C ); | |
1539 | if ( CTool->GetColor ( aSHUOlab, XCAFDoc_ColorCurv, C ) ) | |
1540 | SHUOstyle.SetColorCurv ( C ); | |
1541 | } | |
1542 | if ( !SHUOstyle.IsSetColorCurv() && | |
1543 | !SHUOstyle.IsSetColorSurf() && | |
1544 | SHUOstyle.IsVisible() ) | |
1545 | return Standard_False; | |
1546 | return Standard_True; | |
1547 | } | |
1548 | ||
1549 | ||
1550 | //======================================================================= | |
1551 | //function : getProDefinitionOfNAUO | |
1552 | //purpose : auxilary | |
1553 | //======================================================================= | |
1554 | static Standard_Boolean getProDefinitionOfNAUO(const Handle(XSControl_WorkSession)& WS, | |
1555 | const TopoDS_Shape& theShape, | |
1556 | Handle(StepBasic_ProductDefinition)& PD, | |
1557 | Handle(StepRepr_NextAssemblyUsageOccurrence)& NAUO, | |
1558 | Standard_Boolean IsRelating) | |
1559 | { | |
1560 | if ( theShape.IsNull() ) | |
1561 | return Standard_False; | |
1562 | // get CDSR | |
1563 | Handle(XSControl_TransferWriter) TW = WS->TransferWriter(); | |
1564 | Handle(Transfer_FinderProcess) FP = TW->FinderProcess(); | |
1565 | Handle(StepShape_ContextDependentShapeRepresentation) CDSR; | |
1566 | Handle(TransferBRep_ShapeMapper) mapper = TransferBRep::ShapeMapper ( FP, theShape ); | |
1567 | if (!FP->FindTypedTransient(mapper, | |
1568 | STANDARD_TYPE(StepShape_ContextDependentShapeRepresentation), | |
1569 | CDSR)) | |
1570 | return Standard_False; | |
1571 | // get PDS of NAUO | |
1572 | Handle(StepRepr_ProductDefinitionShape) PDS = CDSR->RepresentedProductRelation(); | |
1573 | if (PDS.IsNull()) | |
1574 | return Standard_False; | |
1575 | // get the NAUO entity | |
1576 | Interface_Graph aGraph = WS->HGraph()->Graph(); | |
1577 | Interface_EntityIterator subs = aGraph.Shareds(PDS); | |
1578 | for ( subs.Start(); subs.More(); subs.Next() ) { | |
1579 | if (!subs.Value()->IsKind(STANDARD_TYPE(StepRepr_NextAssemblyUsageOccurrence))) | |
1580 | continue; | |
1581 | NAUO = Handle(StepRepr_NextAssemblyUsageOccurrence)::DownCast(subs.Value()); | |
1582 | break; | |
1583 | } | |
1584 | if ( NAUO.IsNull() ) | |
1585 | return Standard_False; | |
1586 | // get Relatinf or Related product definition | |
1587 | if ( !IsRelating ) | |
1588 | PD = NAUO->RelatedProductDefinition(); | |
1589 | else | |
1590 | PD = NAUO->RelatingProductDefinition(); | |
1591 | if ( PD.IsNull() ) | |
1592 | return Standard_False; | |
1593 | return Standard_True; | |
1594 | } | |
1595 | ||
1596 | ||
1597 | //======================================================================= | |
1598 | //function : writeSHUO | |
1599 | //purpose : auxilary | |
1600 | //======================================================================= | |
1601 | static Standard_Boolean writeSHUO (const Handle(XCAFDoc_GraphNode)& theSHUO, | |
1602 | const Handle(XCAFDoc_ShapeTool)& theSTool, | |
1603 | const Handle(XSControl_WorkSession)& WS, | |
1604 | Handle(StepRepr_SpecifiedHigherUsageOccurrence)& theTopSHUO, | |
1605 | TopoDS_Shape& NAUOShape, | |
1606 | Handle(StepBasic_ProductDefinition)& theRelatingPD, | |
1607 | Standard_Boolean& isDeepest) | |
1608 | { | |
1609 | // set the ProductDefinitionRelationship descriptin information as empty strings. | |
1610 | Handle(TCollection_HAsciiString) EmptyString = new TCollection_HAsciiString(""); | |
1611 | ||
1612 | TDF_LabelSequence aNextUsageLabs; | |
1613 | theSTool->GetSHUONextUsage( theSHUO->Label(), aNextUsageLabs ); | |
1614 | Handle(XCAFDoc_GraphNode) NuSHUO; | |
1615 | if ( theTopSHUO.IsNull() ) { | |
1616 | // the top SHUO | |
1617 | if (aNextUsageLabs.Length() < 1) | |
1618 | return Standard_False; | |
1619 | theSTool->GetSHUO( aNextUsageLabs.Value(1), NuSHUO ); | |
1620 | if (NuSHUO.IsNull()) | |
1621 | return Standard_False; | |
1622 | // get relating product definition | |
1623 | TopoDS_Shape aTopCompShape = theSTool->GetShape( theSHUO->Label().Father() ); | |
1624 | Handle(StepRepr_NextAssemblyUsageOccurrence) UUNAUO; | |
1625 | if (!getProDefinitionOfNAUO( WS, aTopCompShape, | |
1626 | theRelatingPD, UUNAUO, Standard_True )) | |
1627 | return Standard_False; | |
1628 | // get related product definition | |
1629 | TopoDS_Shape aNUShape = theSTool->GetShape( NuSHUO->Label().Father() ); | |
1630 | Handle(StepBasic_ProductDefinition) aRelatedPD; | |
1631 | Handle(StepRepr_NextAssemblyUsageOccurrence) NUNAUO; | |
1632 | if (!getProDefinitionOfNAUO( WS, aNUShape, | |
1633 | aRelatedPD, NUNAUO, Standard_False )) | |
1634 | return Standard_False; | |
1635 | ||
1636 | theTopSHUO = new StepRepr_SpecifiedHigherUsageOccurrence; | |
1637 | // create deepest shuo EmptyString | |
1638 | theTopSHUO->Init(/*id*/EmptyString, /*name*/EmptyString, | |
1639 | /*no description*/Standard_False,/*description*/EmptyString, | |
1640 | theRelatingPD, aRelatedPD, | |
1641 | /*no ACURefDesignator*/Standard_False,/*ACURefDesignator*/EmptyString, | |
1642 | /*upper_usage*/UUNAUO, /*next_usage*/NUNAUO); | |
1643 | // write the other SHUO. | |
1644 | if(!writeSHUO( NuSHUO, theSTool, WS, theTopSHUO, NAUOShape, theRelatingPD, isDeepest )) { | |
1645 | theTopSHUO.Nullify(); | |
1646 | return Standard_False; | |
1647 | } | |
1648 | ||
1649 | return Standard_True; | |
1650 | } | |
1651 | // Handle(XCAFDoc_GraphNode) NuSHUO; | |
1652 | if ( aNextUsageLabs.Length() > 0) { | |
1653 | // store SHUO recursive | |
0797d9d3 | 1654 | #ifdef OCCT_DEBUG |
7fd59977 | 1655 | if ( aNextUsageLabs.Length() > 1 ) |
1656 | cout << "Warning: store only one next_usage of current SHUO" << endl; | |
1657 | #endif | |
1658 | theSTool->GetSHUO( aNextUsageLabs.Value(1), NuSHUO ); | |
1659 | Handle(StepRepr_SpecifiedHigherUsageOccurrence) aNUEntSHUO = | |
1660 | new StepRepr_SpecifiedHigherUsageOccurrence; | |
1661 | if (!writeSHUO( NuSHUO, theSTool, WS, aNUEntSHUO, NAUOShape, theRelatingPD, isDeepest )) | |
1662 | return Standard_False; | |
1663 | ||
1664 | // store the deepest SHUO to the dociment | |
1665 | TopoDS_Shape aNUSh, aUUSh; | |
1666 | aNUSh = theSTool->GetShape( NuSHUO->Label().Father() ); | |
1667 | aUUSh = theSTool->GetShape( theSHUO->Label().Father() ); | |
1668 | // get relating PD with upper_usage and related PD with next_usage | |
1669 | Handle(StepBasic_ProductDefinition) nullPD;// no need to use,case have shared <theRelatingPD> | |
1670 | Handle(StepBasic_ProductDefinition) aRelatedPD; | |
1671 | Handle(StepRepr_NextAssemblyUsageOccurrence) UUNAUO, NUNAUO; | |
1672 | if (!getProDefinitionOfNAUO( WS, aUUSh, nullPD, UUNAUO, Standard_True ) || | |
1673 | !getProDefinitionOfNAUO( WS, aNUSh, aRelatedPD, NUNAUO, Standard_False )) { | |
0797d9d3 | 1674 | #ifdef OCCT_DEBUG |
7fd59977 | 1675 | cout << "Warning: cannot get related or relating PD" << endl; |
1676 | #endif | |
1677 | return Standard_False; | |
1678 | } | |
1679 | aNUEntSHUO->Init(/*id*/EmptyString, /*name*/EmptyString, | |
1680 | /*no description*/Standard_False,/*description*/EmptyString, | |
1681 | theRelatingPD, aRelatedPD, | |
1682 | /*no ACURefDesignator*/Standard_False,/*ACURefDesignator*/EmptyString, | |
1683 | /*upper_usage*/theTopSHUO, /*next_usage*/NUNAUO); | |
1684 | if ( isDeepest ) { | |
1685 | isDeepest = Standard_False; | |
1686 | } | |
1687 | WS->Model()->AddWithRefs ( aNUEntSHUO ); | |
1688 | return Standard_True; | |
1689 | } // end of recurse storing | |
1690 | ||
1691 | // get shape | |
1692 | TDF_Label aShapeL = theSHUO->Label().Father(); | |
1693 | NAUOShape = theSTool->GetShape( aShapeL ); | |
1694 | // return to the deepest level from SHUO shape level | |
1695 | // it is because SHUO is attribute on deep level and shape level. | |
1696 | isDeepest = Standard_True; | |
1697 | return Standard_True; | |
1698 | } | |
1699 | ||
1700 | ||
1701 | //======================================================================= | |
1702 | //function : createSHUOStyledItem | |
1703 | //purpose : auxilary | |
1704 | //======================================================================= | |
1705 | static Standard_Boolean createSHUOStyledItem (const XCAFPrs_Style& style, | |
1706 | const Handle(StepRepr_ProductDefinitionShape)& PDS, | |
1707 | const Handle(XSControl_WorkSession) &WS, | |
1708 | const TopoDS_Shape& Sh, | |
1709 | const Handle(XCAFDoc_ShapeTool)& STool, | |
1710 | MoniTool_DataMapOfShapeTransient& myMapCompMDGPR) | |
1711 | { | |
1712 | // create styled item for the indicated SHUO and store to the model | |
1713 | STEPConstruct_Styles Styles( WS ); | |
1714 | // translate colors to STEP | |
1715 | Handle(StepVisual_Colour) surfColor, curvColor; | |
1716 | if ( style.IsSetColorSurf() ) | |
1717 | surfColor = Styles.EncodeColor ( style.GetColorSurf() ); | |
1718 | if ( style.IsSetColorCurv() ) | |
1719 | curvColor = Styles.EncodeColor ( style.GetColorCurv() ); | |
1720 | Standard_Boolean isComponent = Standard_True;// cause need to get PSBC | |
1721 | Handle(StepRepr_RepresentationItem) item; | |
1722 | // set default color for invisible SHUO. | |
1723 | Standard_Boolean isSetDefaultColor = Standard_False; | |
1724 | if (surfColor.IsNull() && curvColor.IsNull() && !style.IsVisible() ) { | |
1725 | surfColor = Styles.EncodeColor ( Quantity_Color( 1, 1, 1, Quantity_TOC_RGB ) ); | |
1726 | isSetDefaultColor = Standard_True; | |
1727 | } | |
1728 | Handle(StepVisual_PresentationStyleAssignment) PSA = | |
1729 | Styles.MakeColorPSA ( item, surfColor, curvColor, isComponent ); | |
1730 | Handle(StepVisual_StyledItem) override; //null styled item | |
1731 | ||
1732 | // find the repr item of the shape | |
1733 | Handle(XSControl_TransferWriter) TW = WS->TransferWriter(); | |
1734 | Handle(Transfer_FinderProcess) FP = TW->FinderProcess(); | |
1735 | Handle(TransferBRep_ShapeMapper) mapper = TransferBRep::ShapeMapper ( FP, Sh ); | |
1736 | Handle(StepShape_ContextDependentShapeRepresentation) CDSR; | |
1737 | FP->FindTypedTransient(mapper, | |
1738 | STANDARD_TYPE(StepShape_ContextDependentShapeRepresentation), | |
1739 | CDSR); | |
1740 | if ( CDSR.IsNull() ) | |
1741 | return Standard_False; | |
1742 | // find context | |
1743 | Handle(StepRepr_RepresentationContext) Context = Styles.FindContext( Sh ); | |
1744 | TopoDS_Shape aTopSh = Sh; | |
1745 | if (Context.IsNull()) { | |
1746 | TDF_Label aTopShL = STool->FindShape(Sh, Standard_False); | |
1747 | if (aTopShL.IsNull()) | |
1748 | return Standard_False; | |
1749 | aTopSh = STool->GetShape( aTopShL ); | |
1750 | Context = Styles.FindContext ( aTopSh ); | |
1751 | } | |
1752 | if (Context.IsNull()) | |
1753 | return Standard_False; | |
1754 | // get representation item of the shape | |
1755 | TopLoc_Location L; | |
1756 | TColStd_SequenceOfTransient seqRI; | |
1757 | FindEntities ( FP, Sh, L, seqRI ); | |
0797d9d3 | 1758 | #ifdef OCCT_DEBUG |
7fd59977 | 1759 | if ( seqRI.Length() <=0 ) |
1760 | FP->Messenger() << "Warning: Cannot find RI for " << Sh.TShape()->DynamicType()->Name() << endl; | |
1761 | #endif | |
1762 | item = Handle(StepRepr_RepresentationItem)::DownCast(seqRI(1)); | |
1763 | //get overridden styled item | |
1764 | getStyledItem(Sh,STool, Styles, override,myMapCompMDGPR); | |
1765 | ||
1766 | // get STEP STYLED ITEM | |
1767 | Handle(StepVisual_StyledItem) STEPstyle = Styles.AddStyle ( item, PSA, override ); | |
1768 | // create SR, SDR and all necessary references between them and ST, PDS, PSBC, GRC | |
1769 | Styles.CreateNAUOSRD( Context, CDSR, PDS ); | |
1770 | ||
1771 | // add step styled item of SHUO to the model | |
1772 | // do it by additing styled item to the MDGPR | |
1773 | if ( !aTopSh.IsNull() && !myMapCompMDGPR.IsBound( aTopSh ) ) { | |
1774 | // create MDGPR and record it in model | |
0797d9d3 | 1775 | #ifdef OCCT_DEBUG |
7fd59977 | 1776 | cout << "Warning: " << __FILE__ << ": Create new MDGPR for SHUO instance" << endl; |
1777 | #endif | |
1778 | Handle(StepVisual_MechanicalDesignGeometricPresentationRepresentation) aMDGPR; | |
1779 | Styles.CreateMDGPR ( Context, aMDGPR ); | |
1780 | if (!aMDGPR.IsNull()) | |
1781 | myMapCompMDGPR.Bind( aTopSh, aMDGPR ); | |
1782 | } | |
1783 | else if ( !aTopSh.IsNull() && myMapCompMDGPR.IsBound( aTopSh ) ) { | |
1784 | // get MDGPR of the top-level shape | |
1785 | Handle(StepVisual_PresentationRepresentation) aMDGPR = | |
1786 | Handle(StepVisual_PresentationRepresentation)::DownCast( myMapCompMDGPR.Find( aTopSh ) ); | |
1787 | // get old styled items to not lose it | |
1788 | Handle(StepRepr_HArray1OfRepresentationItem) oldItems = aMDGPR->Items(); | |
1789 | Standard_Integer oldLengthlen = 0; | |
1790 | if (!oldItems.IsNull()) | |
1791 | oldLengthlen = oldItems->Length(); | |
1792 | // create new array of styled items by an olds and new one | |
1793 | Handle(StepRepr_HArray1OfRepresentationItem) newItems = | |
1794 | new StepRepr_HArray1OfRepresentationItem(1, oldLengthlen + 1); | |
1795 | Standard_Integer si; | |
1796 | Standard_Integer el = 1; | |
1797 | for ( si=1; si <= oldLengthlen; si++ ) | |
1798 | newItems->SetValue( el++, oldItems->Value( si ) ); | |
1799 | newItems->SetValue( el++, Handle(StepRepr_RepresentationItem)::DownCast(STEPstyle) ); | |
1800 | // init MDGPR be new array of styled items | |
1801 | if (newItems->Length() > 0) | |
1802 | aMDGPR->SetItems( newItems ); | |
1803 | } | |
1804 | else { | |
1805 | WS->Model()->AddWithRefs ( STEPstyle ); // add as root to the model, but it is not good | |
0797d9d3 | 1806 | #ifdef OCCT_DEBUG |
7fd59977 | 1807 | cout << "Warning: " << __FILE__ << ": adds styled item of SHUO as root, casue cannot find MDGPR" << endl; |
1808 | #endif | |
1809 | } | |
1810 | // create invisibility item for the styled item | |
1811 | if ( !style.IsVisible() ) { | |
1812 | if (isSetDefaultColor) { | |
1813 | // try to set default color from top-level shape | |
1814 | ||
1815 | setDefaultInstanceColor(override, PSA); | |
1816 | } | |
1817 | // create invisibility item and refer for stiledItem | |
1818 | Handle(StepVisual_Invisibility) Invsblt = new StepVisual_Invisibility(); | |
1819 | Handle(StepVisual_HArray1OfInvisibleItem) HInvsblItm = | |
1820 | new StepVisual_HArray1OfInvisibleItem (1,1); | |
1821 | // put all style item into the harray | |
1822 | StepVisual_InvisibleItem anInvItem; | |
1823 | anInvItem.SetValue( STEPstyle ); | |
1824 | HInvsblItm->SetValue( 1, anInvItem ); | |
1825 | Invsblt->Init( HInvsblItm ); | |
1826 | WS->Model()->AddWithRefs( Invsblt ); | |
1827 | } | |
1828 | ||
1829 | return Standard_True; | |
1830 | } | |
1831 | ||
1832 | ||
1833 | //======================================================================= | |
1834 | //function : WriteSHUOs | |
1835 | //purpose : | |
1836 | //======================================================================= | |
1837 | ||
1838 | Standard_Boolean STEPCAFControl_Writer::WriteSHUOs (const Handle(XSControl_WorkSession) &WS, | |
1839 | const TDF_LabelSequence &labels ) | |
1840 | { | |
1841 | if ( labels.Length() <=0 ) return Standard_False; | |
1842 | ||
1843 | // get working data | |
1844 | Handle(Interface_InterfaceModel) Model = WS->Model(); | |
1845 | Handle(XSControl_TransferWriter) TW = WS->TransferWriter(); | |
1846 | Handle(Transfer_FinderProcess) FP = TW->FinderProcess(); | |
1847 | Handle(XCAFDoc_ColorTool) CTool = XCAFDoc_DocumentTool::ColorTool( labels(1) ); | |
1848 | if (CTool.IsNull() ) | |
1849 | return Standard_False; | |
1850 | // map of transfered SHUO | |
1851 | TColStd_MapOfTransient aMapOfMainSHUO; | |
1852 | // TColStd_IndexedDataMapOfTransientTransient aIndxMapOfSHUOEnt; | |
1853 | // Iterate on requested shapes | |
1854 | for ( Standard_Integer i=1; i <= labels.Length(); i++ ) { | |
1855 | TDF_Label L = labels.Value(i); | |
1856 | if ( ! myLabels.IsBound ( L ) ) continue; // not recorded as translated, skip | |
1857 | // TopoDS_Shape S = myLabels.Find ( L ); | |
1858 | if ( XCAFDoc_ShapeTool::IsAssembly ( L ) ) { | |
1859 | TDF_LabelSequence seq; | |
1860 | XCAFDoc_ShapeTool::GetComponents ( L, seq ); | |
1861 | // iterates on components of assembly | |
1862 | for (Standard_Integer k=1; k <= seq.Length(); k++) { | |
1863 | TDF_Label lab = seq(k); | |
1864 | TDF_AttributeSequence anAttrSeq; | |
1865 | CTool->ShapeTool()->GetAllComponentSHUO( lab, anAttrSeq ); | |
1866 | // work with SHUO | |
1867 | for (Standard_Integer j = 1; j <= anAttrSeq.Length(); j++) { | |
1868 | Handle(XCAFDoc_GraphNode) aSHUO = | |
1869 | Handle(XCAFDoc_GraphNode)::DownCast(anAttrSeq.Value( j )); | |
1870 | // take label of SHUO | |
1871 | TDF_Label aSHUOlab = aSHUO->Label(); | |
1872 | TDF_LabelSequence aUpLabels; | |
1873 | // check is it SHUO of upper_usage | |
1874 | CTool->ShapeTool()->GetSHUOUpperUsage( aSHUOlab, aUpLabels ); | |
1875 | if ( aUpLabels.Length() > 0 ) | |
1876 | continue; // transfer only main SHUO | |
1877 | if ( aMapOfMainSHUO.Contains( aSHUO ) ) | |
1878 | continue; // do not try to transfer SHUO twice | |
1879 | aMapOfMainSHUO.Add( aSHUO ); | |
1880 | // check if it is styled SHUO | |
1881 | XCAFPrs_Style SHUOstyle; | |
1882 | if ( !getSHUOstyle ( aSHUOlab, CTool, SHUOstyle ) ) { | |
0797d9d3 | 1883 | #ifdef OCCT_DEBUG |
7fd59977 | 1884 | cout << "Warning: " << __FILE__ << ": do not store SHUO without any style to the STEP model" << endl; |
1885 | #endif | |
1886 | continue; | |
1887 | } | |
1888 | // write SHUO to the model amd then add structure type. | |
1889 | TopoDS_Shape NAUOShape; // shape of the deepest NAUO in the SHUO structure | |
1890 | Standard_Boolean isDeepest = Standard_False; | |
1891 | Handle(StepRepr_SpecifiedHigherUsageOccurrence) anEntOfSHUO; | |
1892 | Handle(StepBasic_ProductDefinition) aRelatingPD; | |
1893 | // create the top SHUO and all other. | |
1894 | writeSHUO( aSHUO, CTool->ShapeTool(), WS, anEntOfSHUO, NAUOShape, aRelatingPD, isDeepest ); | |
1895 | if ( anEntOfSHUO.IsNull() || NAUOShape.IsNull() ) { | |
0797d9d3 | 1896 | #ifdef OCCT_DEBUG |
7fd59977 | 1897 | cout << "Warning: " << __FILE__ << ": Cannot store SHUO" << endl; |
1898 | #endif | |
1899 | continue; | |
1900 | } | |
1901 | // create new Product Definition Shape for TOP SHUO | |
0797d9d3 | 1902 | #ifdef OCCT_DEBUG |
7fd59977 | 1903 | cout << "Info: " << __FILE__ << ": Create NEW PDS for current SHUO " << endl; |
1904 | #endif | |
1905 | Handle(StepRepr_ProductDefinitionShape) PDS = new StepRepr_ProductDefinitionShape; | |
1906 | Handle(TCollection_HAsciiString) aPDSname = new TCollection_HAsciiString("SHUO"); | |
1907 | Handle(TCollection_HAsciiString) descrStr = new TCollection_HAsciiString(""); | |
1908 | StepRepr_CharacterizedDefinition aCharDef; | |
1909 | aCharDef.SetValue( anEntOfSHUO ); | |
1910 | PDS->Init( aPDSname, Standard_False, descrStr, aCharDef ); | |
1911 | ||
1912 | // create styled item for SHUO and add to the model | |
1913 | createSHUOStyledItem ( SHUOstyle, PDS, WS, NAUOShape, CTool->ShapeTool(), myMapCompMDGPR ); | |
1914 | ||
1915 | } // end work with SHUO | |
1916 | } // end of an assembly components | |
1917 | } // end of IsAssembly case | |
1918 | // nothing to do if it is not assembly | |
1919 | continue; | |
1920 | } // end of iterates on indicated labels | |
1921 | return Standard_True; | |
1922 | } | |
1923 | ||
1924 | ||
1925 | //======================================================================= | |
1926 | //function : FindPDSforDGT | |
1927 | //purpose : auxilary: find PDS for AdvancedFace or EdgeCurve for creation | |
1928 | // needed ShapeAspect in D> structure | |
1929 | //======================================================================= | |
1930 | static Standard_Boolean FindPDSforDGT(const Interface_Graph &aGraph, | |
1931 | const Handle(Standard_Transient) &ent, | |
1932 | Handle(StepRepr_ProductDefinitionShape) &PDS, | |
1933 | Handle(StepRepr_RepresentationContext) &RC, | |
1934 | Handle(StepShape_AdvancedFace) &AF, | |
1935 | Handle(StepShape_EdgeCurve) &EC) | |
1936 | { | |
1937 | if( !ent->IsKind(STANDARD_TYPE(StepShape_EdgeCurve)) && | |
1938 | !ent->IsKind(STANDARD_TYPE(StepShape_AdvancedFace)) ) | |
1939 | return Standard_False; | |
1940 | ||
1941 | AF = Handle(StepShape_AdvancedFace)::DownCast(ent); | |
1942 | if( ent->IsKind(STANDARD_TYPE(StepShape_EdgeCurve)) ) { | |
1943 | EC = Handle(StepShape_EdgeCurve)::DownCast(ent); | |
1944 | Interface_EntityIterator subs = aGraph.Sharings(EC); | |
1945 | for(subs.Start(); subs.More() && AF.IsNull(); subs.Next()) { | |
1946 | Handle(StepShape_OrientedEdge) OE = Handle(StepShape_OrientedEdge)::DownCast(subs.Value()); | |
1947 | if(OE.IsNull()) continue; | |
1948 | Interface_EntityIterator subs1 = aGraph.Sharings(OE); | |
1949 | for(subs1.Start(); subs1.More() && AF.IsNull(); subs1.Next()) { | |
1950 | Handle(StepShape_EdgeLoop) EL = Handle(StepShape_EdgeLoop)::DownCast(subs1.Value()); | |
1951 | if(EL.IsNull()) continue; | |
1952 | Interface_EntityIterator subs2 = aGraph.Sharings(EL); | |
1953 | for(subs2.Start(); subs2.More() && AF.IsNull(); subs2.Next()) { | |
1954 | Handle(StepShape_FaceBound) FB = Handle(StepShape_FaceBound)::DownCast(subs2.Value()); | |
1955 | if(FB.IsNull()) continue; | |
1956 | Interface_EntityIterator subs3 = aGraph.Sharings(FB); | |
1957 | for(subs3.Start(); subs3.More() && AF.IsNull(); subs3.Next()) { | |
1958 | AF = Handle(StepShape_AdvancedFace)::DownCast(subs3.Value()); | |
1959 | } | |
1960 | } | |
1961 | } | |
1962 | } | |
1963 | } | |
1964 | if(AF.IsNull()) return Standard_False; | |
1965 | ||
1966 | Interface_EntityIterator subs = aGraph.Sharings(AF); | |
1967 | for(subs.Start(); subs.More() && PDS.IsNull(); subs.Next()) { | |
1968 | Handle(StepShape_ConnectedFaceSet) CFS = | |
1969 | Handle(StepShape_ConnectedFaceSet)::DownCast(subs.Value()); | |
1970 | if(CFS.IsNull()) continue; | |
1971 | Interface_EntityIterator subs1 = aGraph.Sharings(CFS); | |
1972 | for(subs1.Start(); subs1.More() && PDS.IsNull(); subs1.Next()) { | |
1973 | Handle(StepRepr_RepresentationItem) RI = | |
1974 | Handle(StepRepr_RepresentationItem)::DownCast(subs1.Value()); | |
1975 | if(RI.IsNull()) continue; | |
1976 | Interface_EntityIterator subs2 = aGraph.Sharings(RI); | |
1977 | for(subs2.Start(); subs2.More() && PDS.IsNull(); subs2.Next()) { | |
1978 | Handle(StepShape_ShapeRepresentation) SR = | |
1979 | Handle(StepShape_ShapeRepresentation)::DownCast(subs2.Value()); | |
1980 | if(SR.IsNull()) continue; | |
1981 | RC = SR->ContextOfItems(); | |
1982 | Interface_EntityIterator subs3 = aGraph.Sharings(SR); | |
1983 | for(subs3.Start(); subs3.More() && PDS.IsNull(); subs3.Next()) { | |
1984 | Handle(StepShape_ShapeDefinitionRepresentation) SDR = | |
1985 | Handle(StepShape_ShapeDefinitionRepresentation)::DownCast(subs3.Value()); | |
1986 | if(SDR.IsNull()) continue; | |
1987 | Handle(StepRepr_PropertyDefinition) PropD = SDR->Definition().PropertyDefinition(); | |
1988 | if(PropD.IsNull()) continue; | |
1989 | PDS = Handle(StepRepr_ProductDefinitionShape)::DownCast(PropD); | |
1990 | } | |
1991 | } | |
1992 | } | |
1993 | } | |
1994 | ||
1995 | return Standard_True; | |
1996 | } | |
1997 | ||
1998 | ||
1999 | //======================================================================= | |
2000 | //function : WriteDGTs | |
2001 | //purpose : | |
2002 | //======================================================================= | |
2003 | ||
2004 | Standard_Boolean STEPCAFControl_Writer::WriteDGTs (const Handle(XSControl_WorkSession) &WS, | |
2005 | const TDF_LabelSequence &labels ) const | |
2006 | { | |
2007 | ||
2008 | if ( labels.Length() <=0 ) return Standard_False; | |
2009 | ||
2010 | // get working data | |
2011 | Handle(Interface_InterfaceModel) Model = WS->Model(); | |
2012 | Handle(XSControl_TransferWriter) TW = WS->TransferWriter(); | |
2013 | Handle(Transfer_FinderProcess) FP = TW->FinderProcess(); | |
9e20ed57 | 2014 | |
2015 | const Handle(Interface_HGraph) aHGraph = WS->HGraph(); | |
2016 | if(aHGraph.IsNull()) | |
2017 | return Standard_False; | |
2018 | ||
2019 | Interface_Graph aGraph = aHGraph->Graph(); | |
7fd59977 | 2020 | Handle(XCAFDoc_DimTolTool) DGTTool = XCAFDoc_DocumentTool::DimTolTool( labels(1) ); |
2021 | if(DGTTool.IsNull() ) return Standard_False; | |
2022 | ||
2023 | TDF_LabelSequence DGTLabels; | |
2024 | STEPConstruct_DataMapOfAsciiStringTransient DatumMap; | |
2025 | ||
2026 | // write Datums | |
2027 | DGTTool->GetDatumLabels(DGTLabels); | |
2028 | if(DGTLabels.Length()<=0) return Standard_False; | |
2029 | Standard_Integer i; | |
2030 | for(i=1; i<=DGTLabels.Length(); i++) { | |
2031 | TDF_Label DatumL = DGTLabels.Value(i); | |
2032 | TDF_Label ShapeL; | |
2033 | if(!DGTTool->GetRefShapeLabel(DatumL,ShapeL)) continue; | |
2034 | // find target shape | |
2035 | TopoDS_Shape aShape = XCAFDoc_ShapeTool::GetShape(ShapeL); | |
2036 | TopLoc_Location Loc; | |
2037 | TColStd_SequenceOfTransient seqRI; | |
2038 | FindEntities( FP, aShape, Loc, seqRI ); | |
2039 | if ( seqRI.Length() <= 0 ) { | |
2040 | FP->Messenger() << "Warning: Cannot find RI for "<<aShape.TShape()->DynamicType()->Name()<<endl; | |
2041 | continue; | |
2042 | } | |
2043 | Handle(StepRepr_ProductDefinitionShape) PDS; | |
2044 | Handle(StepRepr_RepresentationContext) RC; | |
2045 | Handle(Standard_Transient) ent = seqRI.Value(1); | |
2046 | Handle(StepShape_AdvancedFace) AF; | |
2047 | Handle(StepShape_EdgeCurve) EC; | |
2048 | FindPDSforDGT(aGraph,ent,PDS,RC,AF,EC); | |
2049 | if(PDS.IsNull()) continue; | |
2050 | //cout<<"Model->Number(PDS)="<<Model->Number(PDS)<<endl; | |
2051 | Handle(XCAFDoc_Datum) DatumAttr; | |
2052 | if(!DatumL.FindAttribute(XCAFDoc_Datum::GetID(),DatumAttr)) continue; | |
2053 | Handle(TCollection_HAsciiString) aName = DatumAttr->GetName(); | |
2054 | Handle(TCollection_HAsciiString) aDescription = DatumAttr->GetDescription(); | |
2055 | Handle(TCollection_HAsciiString) anIdentification = DatumAttr->GetIdentification(); | |
2056 | Handle(StepDimTol_DatumFeature) DF = new StepDimTol_DatumFeature; | |
2057 | Handle(StepDimTol_Datum) aDatum = new StepDimTol_Datum; | |
2058 | DF->Init(aName, new TCollection_HAsciiString, PDS, StepData_LTrue); | |
2059 | Model->AddWithRefs(DF); | |
2060 | aDatum->Init(aName, new TCollection_HAsciiString, PDS, StepData_LFalse, anIdentification); | |
2061 | Model->AddWithRefs(aDatum); | |
2062 | Handle(StepRepr_ShapeAspectRelationship) SAR = new StepRepr_ShapeAspectRelationship; | |
2063 | SAR->SetName(aName); | |
2064 | SAR->SetRelatingShapeAspect(DF); | |
2065 | SAR->SetRelatedShapeAspect(aDatum); | |
2066 | Model->AddWithRefs(SAR); | |
2067 | // write chain for DatumFeature | |
2068 | StepRepr_CharacterizedDefinition CD; | |
2069 | CD.SetValue(DF); | |
2070 | Handle(StepRepr_PropertyDefinition) PropD = new StepRepr_PropertyDefinition; | |
2071 | PropD->Init(aName,Standard_True,aDescription,CD); | |
2072 | Model->AddWithRefs(PropD); | |
2073 | StepRepr_RepresentedDefinition RD; | |
2074 | RD.SetValue(PropD); | |
2075 | Handle(StepShape_ShapeRepresentation) SR = new StepShape_ShapeRepresentation; | |
2076 | Handle(StepRepr_HArray1OfRepresentationItem) HARI = | |
2077 | new StepRepr_HArray1OfRepresentationItem(1,1); | |
2078 | HARI->SetValue(1,AF); | |
2079 | SR->Init(aName,HARI,RC); | |
2080 | Handle(StepShape_ShapeDefinitionRepresentation) SDR = new StepShape_ShapeDefinitionRepresentation; | |
2081 | SDR->Init(RD,SR); | |
2082 | Model->AddWithRefs(SDR); | |
2083 | // write chain for Datum | |
2084 | StepRepr_CharacterizedDefinition CD1; | |
2085 | CD1.SetValue(aDatum); | |
2086 | Handle(StepRepr_PropertyDefinition) PropD1 = new StepRepr_PropertyDefinition; | |
2087 | PropD1->Init(aName,Standard_True,aDescription,CD1); | |
2088 | Model->AddWithRefs(PropD1); | |
2089 | StepRepr_RepresentedDefinition RD1; | |
2090 | RD1.SetValue(PropD1); | |
2091 | Handle(StepShape_ShapeRepresentation) SR1 = new StepShape_ShapeRepresentation; | |
2092 | Handle(StepRepr_HArray1OfRepresentationItem) HARI1 = | |
2093 | new StepRepr_HArray1OfRepresentationItem(1,1); | |
2094 | HARI1->SetValue(1,AF->FaceGeometry()); | |
2095 | SR1->Init(aName,HARI1,RC); | |
2096 | Model->AddWithRefs(SR1); | |
2097 | Handle(StepShape_ShapeDefinitionRepresentation) SDR1 = new StepShape_ShapeDefinitionRepresentation; | |
2098 | SDR1->Init(RD1,SR1); | |
2099 | Model->AddWithRefs(SDR1); | |
2100 | // add created Datum into Map | |
2101 | TCollection_AsciiString stmp(aName->ToCString()); | |
2102 | stmp.AssignCat(aDescription->ToCString()); | |
2103 | stmp.AssignCat(anIdentification->ToCString()); | |
2104 | DatumMap.Bind(stmp,aDatum); | |
2105 | } | |
2106 | ||
2107 | // write Tolerances and Dimensions | |
2108 | DGTLabels.Clear(); | |
2109 | DGTTool->GetDimTolLabels(DGTLabels); | |
2110 | if(DGTLabels.Length()<=0) return Standard_False; | |
2111 | for(i=1; i<=DGTLabels.Length(); i++) { | |
2112 | TDF_Label DimTolL = DGTLabels.Value(i); | |
2113 | TDF_Label ShapeL; | |
2114 | if(!DGTTool->GetRefShapeLabel(DimTolL,ShapeL)) continue; | |
2115 | // find target shape | |
2116 | TopoDS_Shape aShape = XCAFDoc_ShapeTool::GetShape(ShapeL); | |
2117 | TopLoc_Location Loc; | |
2118 | TColStd_SequenceOfTransient seqRI; | |
2119 | FindEntities( FP, aShape, Loc, seqRI ); | |
2120 | if ( seqRI.Length() <= 0 ) { | |
2121 | FP->Messenger() << "Warning: Cannot find RI for "<<aShape.TShape()->DynamicType()->Name()<<endl; | |
2122 | continue; | |
2123 | } | |
2124 | Handle(StepRepr_ProductDefinitionShape) PDS; | |
2125 | Handle(StepRepr_RepresentationContext) RC; | |
2126 | Handle(Standard_Transient) ent = seqRI.Value(1); | |
2127 | Handle(StepShape_AdvancedFace) AF; | |
2128 | Handle(StepShape_EdgeCurve) EC; | |
2129 | FindPDSforDGT(aGraph,ent,PDS,RC,AF,EC); | |
2130 | if(PDS.IsNull()) continue; | |
2131 | //cout<<"Model->Number(PDS)="<<Model->Number(PDS)<<endl; | |
2132 | ||
2133 | Handle(XCAFDoc_DimTol) DimTolAttr; | |
2134 | if(!DimTolL.FindAttribute(XCAFDoc_DimTol::GetID(),DimTolAttr)) continue; | |
2135 | Standard_Integer kind = DimTolAttr->GetKind(); | |
2136 | Handle(TColStd_HArray1OfReal) aVal = DimTolAttr->GetVal(); | |
2137 | Handle(TCollection_HAsciiString) aName = DimTolAttr->GetName(); | |
2138 | Handle(TCollection_HAsciiString) aDescription = DimTolAttr->GetDescription(); | |
2139 | ||
2140 | // common part of writing D> entities | |
2141 | StepRepr_CharacterizedDefinition CD; | |
2142 | Handle(StepRepr_ShapeAspect) SA = new StepRepr_ShapeAspect; | |
2143 | SA->Init(aName, new TCollection_HAsciiString, PDS, StepData_LTrue); | |
2144 | Model->AddWithRefs(SA); | |
2145 | CD.SetValue(SA); | |
2146 | Handle(StepRepr_PropertyDefinition) PropD = new StepRepr_PropertyDefinition; | |
2147 | PropD->Init(aName,Standard_True,aDescription,CD); | |
2148 | Model->AddWithRefs(PropD); | |
2149 | StepRepr_RepresentedDefinition RD; | |
2150 | RD.SetValue(PropD); | |
2151 | Handle(StepShape_ShapeRepresentation) SR = new StepShape_ShapeRepresentation; | |
2152 | Handle(StepRepr_HArray1OfRepresentationItem) HARI = | |
2153 | new StepRepr_HArray1OfRepresentationItem(1,1); | |
2154 | if(kind<20) | |
2155 | HARI->SetValue(1,EC); | |
2156 | else | |
2157 | HARI->SetValue(1,AF); | |
2158 | SR->Init(aName,HARI,RC); | |
2159 | Handle(StepShape_ShapeDefinitionRepresentation) SDR = new StepShape_ShapeDefinitionRepresentation; | |
2160 | SDR->Init(RD,SR); | |
2161 | Model->AddWithRefs(SDR); | |
2162 | // define aUnit for creation LengthMeasureWithUnit (common for all) | |
2163 | StepBasic_Unit aUnit; | |
2164 | Handle(StepBasic_SiUnitAndLengthUnit) SLU; | |
2165 | Handle(StepGeom_GeometricRepresentationContextAndGlobalUnitAssignedContext) Ctx = | |
2166 | Handle(StepGeom_GeometricRepresentationContextAndGlobalUnitAssignedContext)::DownCast(RC); | |
2167 | if(!Ctx.IsNull()) { | |
2168 | for(Standard_Integer j=1; j<=Ctx->NbUnits(); j++) { | |
2169 | if(Ctx->UnitsValue(j)->IsKind(STANDARD_TYPE(StepBasic_SiUnitAndLengthUnit))) { | |
2170 | SLU = Handle(StepBasic_SiUnitAndLengthUnit)::DownCast(Ctx->UnitsValue(j)); | |
2171 | break; | |
2172 | } | |
2173 | } | |
2174 | } | |
2175 | if(SLU.IsNull()) { | |
2176 | Handle(StepGeom_GeomRepContextAndGlobUnitAssCtxAndGlobUncertaintyAssCtx) Ctx1 = | |
2177 | Handle(StepGeom_GeomRepContextAndGlobUnitAssCtxAndGlobUncertaintyAssCtx)::DownCast(RC); | |
2178 | if(!Ctx1.IsNull()) { | |
2179 | for(Standard_Integer j=1; j<=Ctx1->NbUnits(); j++) { | |
2180 | if(Ctx1->UnitsValue(j)->IsKind(STANDARD_TYPE(StepBasic_SiUnitAndLengthUnit))) { | |
2181 | SLU = Handle(StepBasic_SiUnitAndLengthUnit)::DownCast(Ctx1->UnitsValue(j)); | |
2182 | break; | |
2183 | } | |
2184 | } | |
2185 | } | |
2186 | } | |
2187 | if(SLU.IsNull()) { | |
2188 | SLU = new StepBasic_SiUnitAndLengthUnit; | |
2189 | } | |
2190 | aUnit.SetValue(SLU); | |
2191 | ||
2192 | // specific part of writing D> entities | |
2193 | if(kind<20) { //dimension | |
2194 | Handle(StepShape_DimensionalSize) DimSize = new StepShape_DimensionalSize; | |
2195 | DimSize->Init(SA,aDescription); | |
2196 | Model->AddWithRefs(DimSize); | |
2197 | if(aVal->Length()>1) { | |
2198 | // create MeasureWithUnits | |
2199 | Handle(StepBasic_MeasureValueMember) MVM1 = new StepBasic_MeasureValueMember; | |
2200 | MVM1->SetName("POSITIVE_LENGTH_MEASURE"); | |
2201 | MVM1->SetReal(aVal->Value(1)); | |
2202 | Handle(StepBasic_MeasureWithUnit) MWU1 = new StepBasic_MeasureWithUnit; | |
2203 | MWU1->Init(MVM1,aUnit); | |
2204 | Handle(StepBasic_MeasureValueMember) MVM2 = new StepBasic_MeasureValueMember; | |
2205 | MVM2->SetName("POSITIVE_LENGTH_MEASURE"); | |
2206 | MVM2->SetReal(aVal->Value(2)); | |
2207 | Handle(StepBasic_MeasureWithUnit) MWU2 = new StepBasic_MeasureWithUnit; | |
2208 | MWU2->Init(MVM2,aUnit); | |
2209 | Handle(StepRepr_RepresentationItem) RI1 = new StepRepr_RepresentationItem; | |
2210 | RI1->Init(new TCollection_HAsciiString("lower limit")); | |
2211 | Handle(StepRepr_RepresentationItem) RI2 = new StepRepr_RepresentationItem; | |
2212 | RI2->Init(new TCollection_HAsciiString("upper limit")); | |
2213 | Handle(StepRepr_ReprItemAndLengthMeasureWithUnit) RILMU1 = | |
2214 | new StepRepr_ReprItemAndLengthMeasureWithUnit; | |
2215 | RILMU1->Init(MWU1,RI1); | |
2216 | Handle(StepRepr_ReprItemAndLengthMeasureWithUnit) RILMU2 = | |
2217 | new StepRepr_ReprItemAndLengthMeasureWithUnit; | |
2218 | RILMU2->Init(MWU2,RI2); | |
2219 | Model->AddWithRefs(RILMU1); | |
2220 | Model->AddWithRefs(RILMU2); | |
2221 | //Handle(StepRepr_CompoundItemDefinitionMember) CIDM = | |
2222 | // new StepRepr_CompoundItemDefinitionMember; | |
2223 | //Handle(TColStd_HArray1OfTransient) ArrTr = new TColStd_HArray1OfTransient(1,2); | |
2224 | //ArrTr->SetValue(1,RILMU1); | |
2225 | //ArrTr->SetValue(2,RILMU2); | |
2226 | //CIDM->SetArrTransient(ArrTr); | |
2227 | //CIDM->SetName("SET_REPRESENTATION_ITEM"); | |
2228 | //StepRepr_CompoundItemDefinition CID; | |
2229 | //CID.SetValue(CIDM); | |
2230 | Handle(StepRepr_HArray1OfRepresentationItem) HARIVR = | |
2231 | new StepRepr_HArray1OfRepresentationItem(1,2); | |
2232 | HARIVR->SetValue(1,RILMU1); | |
2233 | HARIVR->SetValue(2,RILMU2); | |
2234 | Handle(StepRepr_ValueRange) VR = new StepRepr_ValueRange; | |
2235 | //VR->Init(aName,CID); | |
2236 | VR->Init(aName,HARIVR); | |
2237 | Model->AddEntity(VR); | |
2238 | Handle(StepShape_ShapeDimensionRepresentation) SDimR = | |
2239 | new StepShape_ShapeDimensionRepresentation; | |
2240 | Handle(StepRepr_HArray1OfRepresentationItem) HARI = | |
2241 | new StepRepr_HArray1OfRepresentationItem(1,1); | |
2242 | HARI->SetValue(1,VR); | |
2243 | SDimR->Init(aName,HARI,RC); | |
2244 | Model->AddWithRefs(SDimR); | |
2245 | Handle(StepShape_DimensionalCharacteristicRepresentation) DimCharR = | |
2246 | new StepShape_DimensionalCharacteristicRepresentation; | |
2247 | StepShape_DimensionalCharacteristic DimChar; | |
2248 | DimChar.SetValue(DimSize); | |
2249 | DimCharR->Init(DimChar,SDimR); | |
2250 | Model->AddEntity(DimCharR); | |
2251 | } | |
2252 | } | |
2253 | else if(kind<50) { //tolerance | |
2254 | if(kind<35) { // tolerance with datum system | |
2255 | TDF_LabelSequence DatumLabels; | |
2256 | DGTTool->GetDatumTolerLabels(DimTolL,DatumLabels); | |
2257 | Standard_Integer NbDR = DatumLabels.Length(); | |
2258 | Handle(StepDimTol_HArray1OfDatumReference) HADR = new StepDimTol_HArray1OfDatumReference(1,NbDR); | |
2259 | for(Standard_Integer j=1; j<=NbDR; j++) { | |
2260 | Handle(XCAFDoc_Datum) DatumAttr; | |
2261 | TDF_Label DatumL = DatumLabels.Value(j); | |
2262 | if(!DatumL.FindAttribute(XCAFDoc_Datum::GetID(),DatumAttr)) continue; | |
2263 | Handle(TCollection_HAsciiString) aNameD = DatumAttr->GetName(); | |
2264 | Handle(TCollection_HAsciiString) aDescriptionD = DatumAttr->GetDescription(); | |
2265 | Handle(TCollection_HAsciiString) anIdentificationD = DatumAttr->GetIdentification(); | |
2266 | TCollection_AsciiString stmp(aNameD->ToCString()); | |
2267 | stmp.AssignCat(aDescriptionD->ToCString()); | |
2268 | stmp.AssignCat(anIdentificationD->ToCString()); | |
2269 | if(DatumMap.IsBound(stmp)) { | |
2270 | Handle(StepDimTol_Datum) aDatum = | |
2271 | Handle(StepDimTol_Datum)::DownCast(DatumMap.Find(stmp)); | |
2272 | Handle(StepDimTol_DatumReference) DR = new StepDimTol_DatumReference; | |
2273 | DR->Init(j,aDatum); | |
2274 | Model->AddWithRefs(DR); | |
2275 | HADR->SetValue(j,DR); | |
2276 | } | |
2277 | } | |
2278 | // create LengthMeasureWithUnit | |
2279 | Handle(StepBasic_MeasureValueMember) MVM = new StepBasic_MeasureValueMember; | |
2280 | MVM->SetName("LENGTH_MEASURE"); | |
2281 | MVM->SetReal(aVal->Value(1)); | |
2282 | Handle(StepBasic_LengthMeasureWithUnit) LMWU = new StepBasic_LengthMeasureWithUnit; | |
2283 | LMWU->Init(MVM,aUnit); | |
2284 | // create tolerance by it's type | |
2285 | if(kind<24) { | |
2286 | Handle(StepDimTol_GeometricToleranceWithDatumReference) GTWDR = | |
2287 | new StepDimTol_GeometricToleranceWithDatumReference; | |
2288 | GTWDR->SetDatumSystem(HADR); | |
2289 | Handle(StepDimTol_ModifiedGeometricTolerance) MGT = | |
2290 | new StepDimTol_ModifiedGeometricTolerance; | |
2291 | if(kind==21) MGT->SetModifier(StepDimTol_MaximumMaterialCondition); | |
2292 | else if(kind==22) MGT->SetModifier(StepDimTol_LeastMaterialCondition); | |
2293 | else if(kind==23) MGT->SetModifier(StepDimTol_RegardlessOfFeatureSize); | |
2294 | Handle(StepDimTol_GeoTolAndGeoTolWthDatRefAndModGeoTolAndPosTol) GTComplex = | |
2295 | new StepDimTol_GeoTolAndGeoTolWthDatRefAndModGeoTolAndPosTol; | |
2296 | GTComplex->Init(aName,aDescription,LMWU,SA,GTWDR,MGT); | |
2297 | Model->AddWithRefs(GTComplex); | |
2298 | } | |
2299 | else if(kind==24) { | |
2300 | Handle(StepDimTol_AngularityTolerance) aToler = | |
2301 | new StepDimTol_AngularityTolerance; | |
2302 | aToler->Init(aName,aDescription,LMWU,SA,HADR); | |
2303 | Model->AddWithRefs(aToler); | |
2304 | } | |
2305 | else if(kind==25) { | |
2306 | Handle(StepDimTol_CircularRunoutTolerance) aToler = | |
2307 | new StepDimTol_CircularRunoutTolerance; | |
2308 | aToler->Init(aName,aDescription,LMWU,SA,HADR); | |
2309 | Model->AddWithRefs(aToler); | |
2310 | } | |
2311 | else if(kind==26) { | |
2312 | Handle(StepDimTol_CoaxialityTolerance) aToler = | |
2313 | new StepDimTol_CoaxialityTolerance; | |
2314 | aToler->Init(aName,aDescription,LMWU,SA,HADR); | |
2315 | Model->AddWithRefs(aToler); | |
2316 | } | |
2317 | else if(kind==27) { | |
2318 | Handle(StepDimTol_ConcentricityTolerance) aToler = | |
2319 | new StepDimTol_ConcentricityTolerance; | |
2320 | aToler->Init(aName,aDescription,LMWU,SA,HADR); | |
2321 | Model->AddWithRefs(aToler); | |
2322 | } | |
2323 | else if(kind==28) { | |
2324 | Handle(StepDimTol_ParallelismTolerance) aToler = | |
2325 | new StepDimTol_ParallelismTolerance; | |
2326 | aToler->Init(aName,aDescription,LMWU,SA,HADR); | |
2327 | Model->AddWithRefs(aToler); | |
2328 | } | |
2329 | else if(kind==29) { | |
2330 | Handle(StepDimTol_PerpendicularityTolerance) aToler = | |
2331 | new StepDimTol_PerpendicularityTolerance; | |
2332 | aToler->Init(aName,aDescription,LMWU,SA,HADR); | |
2333 | Model->AddWithRefs(aToler); | |
2334 | } | |
2335 | else if(kind==30) { | |
2336 | Handle(StepDimTol_SymmetryTolerance) aToler = | |
2337 | new StepDimTol_SymmetryTolerance; | |
2338 | aToler->Init(aName,aDescription,LMWU,SA,HADR); | |
2339 | Model->AddWithRefs(aToler); | |
2340 | } | |
2341 | else if(kind==31) { | |
2342 | Handle(StepDimTol_TotalRunoutTolerance) aToler = | |
2343 | new StepDimTol_TotalRunoutTolerance; | |
2344 | aToler->Init(aName,aDescription,LMWU,SA,HADR); | |
2345 | Model->AddWithRefs(aToler); | |
2346 | } | |
2347 | } | |
2348 | } | |
2349 | } | |
2350 | ||
2351 | return Standard_True; | |
2352 | } | |
2353 | ||
2354 | ||
2355 | //======================================================================= | |
2356 | //function : FindPDSforRI | |
2357 | //purpose : auxilary: | |
2358 | //======================================================================= | |
2359 | static Standard_Boolean FindPDSforRI(const Interface_Graph &aGraph, | |
2360 | const Handle(Standard_Transient) &ent, | |
2361 | Handle(StepRepr_ProductDefinitionShape) &PDS, | |
2362 | Handle(StepRepr_RepresentationContext) &RC) | |
2363 | { | |
2364 | if(!ent->IsKind(STANDARD_TYPE(StepRepr_RepresentationItem))) return Standard_False; | |
2365 | Interface_EntityIterator subs = aGraph.Sharings(ent); | |
2366 | for(subs.Start(); subs.More() && PDS.IsNull(); subs.Next()) { | |
2367 | Handle(StepShape_ShapeRepresentation) SR = | |
2368 | Handle(StepShape_ShapeRepresentation)::DownCast(subs.Value()); | |
2369 | if(SR.IsNull()) continue; | |
2370 | RC = SR->ContextOfItems(); | |
2371 | Interface_EntityIterator subs1 = aGraph.Sharings(SR); | |
2372 | for(subs1.Start(); subs1.More() && PDS.IsNull(); subs1.Next()) { | |
2373 | Handle(StepShape_ShapeDefinitionRepresentation) SDR = | |
2374 | Handle(StepShape_ShapeDefinitionRepresentation)::DownCast(subs1.Value()); | |
2375 | if(SDR.IsNull()) continue; | |
2376 | Handle(StepRepr_PropertyDefinition) PropD = SDR->Definition().PropertyDefinition(); | |
2377 | if(PropD.IsNull()) continue; | |
2378 | PDS = Handle(StepRepr_ProductDefinitionShape)::DownCast(PropD); | |
2379 | } | |
2380 | } | |
2381 | return Standard_True; | |
2382 | } | |
2383 | ||
2384 | ||
2385 | //======================================================================= | |
2386 | //function : WriteMaterials | |
2387 | //purpose : | |
2388 | //======================================================================= | |
2389 | ||
2390 | Standard_Boolean STEPCAFControl_Writer::WriteMaterials (const Handle(XSControl_WorkSession) &WS, | |
2391 | const TDF_LabelSequence &labels ) const | |
2392 | { | |
2393 | ||
2394 | if ( labels.Length() <=0 ) return Standard_False; | |
2395 | ||
2396 | // get working data | |
2397 | Handle(Interface_InterfaceModel) Model = WS->Model(); | |
2398 | Handle(XSControl_TransferWriter) TW = WS->TransferWriter(); | |
2399 | Handle(Transfer_FinderProcess) FP = TW->FinderProcess(); | |
9e20ed57 | 2400 | |
2401 | const Handle(Interface_HGraph) aHGraph = WS->HGraph(); | |
2402 | if(aHGraph.IsNull()) | |
2403 | return Standard_False; | |
2404 | ||
7fd59977 | 2405 | Interface_Graph aGraph = WS->HGraph()->Graph(); |
2406 | Handle(XCAFDoc_ShapeTool) ShTool = XCAFDoc_DocumentTool::ShapeTool( labels(1) ); | |
2407 | if(ShTool.IsNull() ) return Standard_False; | |
2408 | Handle(XCAFDoc_MaterialTool) MatTool = XCAFDoc_DocumentTool::MaterialTool( labels(1) ); | |
2409 | if(MatTool.IsNull() ) return Standard_False; | |
2410 | ||
2411 | STEPConstruct_DataMapOfAsciiStringTransient MapDRI,MapMRI; | |
2412 | TDF_LabelSequence TopLabels; | |
2413 | ShTool->GetShapes(TopLabels); | |
2414 | for(Standard_Integer i=1; i<=TopLabels.Length(); i++) { | |
2415 | TDF_Label ShL = TopLabels.Value(i); | |
2416 | Handle(TDataStd_TreeNode) Node; | |
2417 | if( ShL.FindAttribute(XCAFDoc::MaterialRefGUID(),Node) && Node->HasFather() ) { | |
2418 | // find PDS for current shape | |
2419 | TopoDS_Shape aShape = XCAFDoc_ShapeTool::GetShape(ShL); | |
2420 | TopLoc_Location Loc; | |
2421 | TColStd_SequenceOfTransient seqRI; | |
2422 | FindEntities( FP, aShape, Loc, seqRI ); | |
2423 | if(seqRI.Length()<=0) continue; | |
2424 | Handle(StepRepr_ProductDefinitionShape) PDS; | |
2425 | Handle(StepRepr_RepresentationContext) RC; | |
2426 | Handle(Standard_Transient) ent = seqRI.Value(1); | |
2427 | FindPDSforRI(aGraph,ent,PDS,RC); | |
2428 | if(PDS.IsNull()) continue; | |
1d2b1ccb G |
2429 | Handle(StepBasic_ProductDefinition) aProdDef = |
2430 | PDS->Definition().ProductDefinition(); | |
2431 | if(aProdDef.IsNull()) | |
2432 | continue; | |
7fd59977 | 2433 | // write material entities |
2434 | TDF_Label MatL = Node->Father()->Label(); | |
2435 | Handle(TCollection_HAsciiString) aName; | |
2436 | Handle(TCollection_HAsciiString) aDescription; | |
2437 | Standard_Real aDensity; | |
2438 | Handle(TCollection_HAsciiString) aDensName; | |
2439 | Handle(TCollection_HAsciiString) aDensValType; | |
41e259eb | 2440 | Handle(StepRepr_Representation) RepDRI; |
2441 | Handle(StepRepr_Representation) RepMRI; | |
7fd59977 | 2442 | if(MatTool->GetMaterial(MatL,aName,aDescription,aDensity,aDensName,aDensValType)) { |
2443 | if(aName->Length()==0) continue; | |
2444 | TCollection_AsciiString aKey(aName->ToCString()); | |
2445 | if(MapDRI.IsBound(aKey)) { | |
2446 | RepDRI = Handle(StepRepr_Representation)::DownCast(MapDRI.Find(aKey)); | |
2447 | if(MapMRI.IsBound(aKey)) { | |
2448 | RepMRI = Handle(StepRepr_Representation)::DownCast(MapMRI.Find(aKey)); | |
2449 | } | |
2450 | } | |
2451 | else { | |
2452 | // write DRI | |
2453 | Handle(StepRepr_DescriptiveRepresentationItem) DRI = new StepRepr_DescriptiveRepresentationItem; | |
2454 | DRI->Init(aName,aDescription); | |
2455 | Handle(StepRepr_HArray1OfRepresentationItem) HARI = new StepRepr_HArray1OfRepresentationItem(1,1); | |
2456 | HARI->SetValue(1,DRI); | |
41e259eb | 2457 | RepDRI = new StepRepr_Representation(); |
7fd59977 | 2458 | RepDRI->Init(new TCollection_HAsciiString("material name"),HARI,RC); |
2459 | Model->AddWithRefs(RepDRI); | |
2460 | // write MRI | |
41e259eb | 2461 | if( aDensity > 0 ) { |
7fd59977 | 2462 | // mass |
2463 | Handle(StepBasic_SiUnitAndMassUnit) SMU = new StepBasic_SiUnitAndMassUnit; | |
2464 | SMU->SetName(StepBasic_sunGram); | |
2465 | Handle(StepBasic_DerivedUnitElement) DUE1 = new StepBasic_DerivedUnitElement; | |
2466 | DUE1->Init(SMU,3.0); | |
2467 | // length | |
2468 | Handle(StepBasic_SiUnitAndLengthUnit) SLU = new StepBasic_SiUnitAndLengthUnit; | |
2469 | SLU->Init(Standard_True,StepBasic_spCenti,StepBasic_sunMetre); | |
2470 | Handle(StepBasic_DerivedUnitElement) DUE2 = new StepBasic_DerivedUnitElement; | |
2471 | DUE2->Init(SLU,2.0); | |
2472 | // other | |
2473 | Handle(StepBasic_HArray1OfDerivedUnitElement) HADUE = new StepBasic_HArray1OfDerivedUnitElement(1,2); | |
2474 | HADUE->SetValue(1,DUE1); | |
2475 | HADUE->SetValue(2,DUE2); | |
2476 | Handle(StepBasic_DerivedUnit) DU = new StepBasic_DerivedUnit; | |
2477 | DU->Init(HADUE); | |
2478 | Model->AddWithRefs(DU); | |
2479 | StepBasic_Unit aUnit; | |
2480 | aUnit.SetValue(DU); | |
2481 | Handle(StepBasic_MeasureValueMember) MVM = new StepBasic_MeasureValueMember; | |
2482 | MVM->SetName(aDensValType->ToCString()); | |
2483 | MVM->SetReal(aDensity); | |
2484 | Handle(StepRepr_MeasureRepresentationItem) MRI = new StepRepr_MeasureRepresentationItem; | |
2485 | MRI->Init(aDensName,MVM,aUnit); | |
2486 | HARI = new StepRepr_HArray1OfRepresentationItem(1,1); | |
2487 | HARI->SetValue(1,MRI); | |
41e259eb | 2488 | RepMRI = new StepRepr_Representation(); |
7fd59977 | 2489 | RepMRI->Init(new TCollection_HAsciiString("density"),HARI,RC); |
2490 | Model->AddWithRefs(RepMRI); | |
2491 | } | |
2492 | //WriteNewMaterial(Model,aName,aDescription,aDensity,aDensName,aDensValType,RC,RepDRI,RepMRI); | |
2493 | MapDRI.Bind(aKey,RepDRI); | |
41e259eb | 2494 | if ( !RepMRI.IsNull() ) MapMRI.Bind (aKey, RepMRI); |
2495 | } | |
2496 | } | |
2497 | ||
2498 | if( !RepDRI.IsNull() ) | |
2499 | { | |
2500 | StepRepr_CharacterizedDefinition CD1; | |
2501 | CD1.SetValue(aProdDef); | |
2502 | Handle(StepRepr_PropertyDefinition) PropD1 = new StepRepr_PropertyDefinition; | |
2503 | PropD1->Init(new TCollection_HAsciiString("material property"),Standard_True, | |
2504 | new TCollection_HAsciiString("material name"),CD1); | |
2505 | Model->AddWithRefs(PropD1); | |
2506 | StepRepr_RepresentedDefinition RD1; | |
2507 | RD1.SetValue(PropD1); | |
2508 | Handle(StepRepr_PropertyDefinitionRepresentation) PDR1 = | |
2509 | new StepRepr_PropertyDefinitionRepresentation; | |
2510 | PDR1->Init(RD1,RepDRI); | |
2511 | Model->AddWithRefs(PDR1); | |
2512 | ||
2513 | if( !RepMRI.IsNull() ) | |
2514 | { | |
2515 | StepRepr_CharacterizedDefinition CD2; | |
2516 | CD2.SetValue (aProdDef); | |
2517 | Handle (StepRepr_PropertyDefinition) PropD2 = new StepRepr_PropertyDefinition; | |
2518 | PropD2->Init (new TCollection_HAsciiString ("material property"), Standard_True, | |
2519 | new TCollection_HAsciiString ("density"), CD2); | |
2520 | Model->AddWithRefs (PropD2); | |
2521 | StepRepr_RepresentedDefinition RD2; | |
2522 | RD2.SetValue (PropD2); | |
2523 | Handle (StepRepr_PropertyDefinitionRepresentation) PDR2 = | |
2524 | new StepRepr_PropertyDefinitionRepresentation; | |
2525 | PDR2->Init (RD2, RepMRI); | |
2526 | Model->AddWithRefs (PDR2); | |
7fd59977 | 2527 | } |
2528 | } | |
7fd59977 | 2529 | } |
2530 | } | |
2531 | ||
2532 | return Standard_True; | |
2533 | } | |
2534 | ||
2535 | ||
2536 | //======================================================================= | |
2537 | //function : SetColorMode | |
2538 | //purpose : | |
2539 | //======================================================================= | |
2540 | ||
2541 | void STEPCAFControl_Writer::SetColorMode (const Standard_Boolean colormode) | |
2542 | { | |
2543 | myColorMode = colormode; | |
2544 | } | |
2545 | ||
2546 | ||
2547 | //======================================================================= | |
2548 | //function : GetColorMode | |
2549 | //purpose : | |
2550 | //======================================================================= | |
2551 | ||
2552 | Standard_Boolean STEPCAFControl_Writer::GetColorMode () const | |
2553 | { | |
2554 | return myColorMode; | |
2555 | } | |
2556 | ||
2557 | ||
2558 | //======================================================================= | |
2559 | //function : SetNameMode | |
2560 | //purpose : | |
2561 | //======================================================================= | |
2562 | ||
2563 | void STEPCAFControl_Writer::SetNameMode (const Standard_Boolean namemode) | |
2564 | { | |
2565 | myNameMode = namemode; | |
2566 | } | |
2567 | ||
2568 | ||
2569 | //======================================================================= | |
2570 | //function : GetNameMode | |
2571 | //purpose : | |
2572 | //======================================================================= | |
2573 | ||
2574 | Standard_Boolean STEPCAFControl_Writer::GetNameMode () const | |
2575 | { | |
2576 | return myNameMode; | |
2577 | } | |
2578 | ||
2579 | ||
2580 | //======================================================================= | |
2581 | //function : SetLayerMode | |
2582 | //purpose : | |
2583 | //======================================================================= | |
2584 | ||
2585 | void STEPCAFControl_Writer::SetLayerMode (const Standard_Boolean layermode) | |
2586 | { | |
2587 | myLayerMode = layermode; | |
2588 | } | |
2589 | ||
2590 | ||
2591 | //======================================================================= | |
2592 | //function : GetLayerMode | |
2593 | //purpose : | |
2594 | //======================================================================= | |
2595 | ||
2596 | Standard_Boolean STEPCAFControl_Writer::GetLayerMode () const | |
2597 | { | |
2598 | return myLayerMode; | |
2599 | } | |
2600 | ||
2601 | ||
2602 | //======================================================================= | |
2603 | //function : SetPropsMode | |
2604 | //purpose : | |
2605 | //======================================================================= | |
2606 | ||
2607 | void STEPCAFControl_Writer::SetPropsMode (const Standard_Boolean propsmode) | |
2608 | { | |
2609 | myPropsMode = propsmode; | |
2610 | } | |
2611 | ||
2612 | ||
2613 | //======================================================================= | |
2614 | //function : GetPropsMode | |
2615 | //purpose : | |
2616 | //======================================================================= | |
2617 | ||
2618 | Standard_Boolean STEPCAFControl_Writer::GetPropsMode () const | |
2619 | { | |
2620 | return myPropsMode; | |
2621 | } | |
2622 | ||
2623 | ||
2624 | //======================================================================= | |
2625 | //function : SetSHUOMode | |
2626 | //purpose : | |
2627 | //======================================================================= | |
2628 | ||
2629 | void STEPCAFControl_Writer::SetSHUOMode (const Standard_Boolean mode) | |
2630 | { | |
2631 | mySHUOMode = mode; | |
2632 | } | |
2633 | ||
2634 | ||
2635 | //======================================================================= | |
2636 | //function : GetSHUOMode | |
2637 | //purpose : | |
2638 | //======================================================================= | |
2639 | ||
2640 | Standard_Boolean STEPCAFControl_Writer::GetSHUOMode () const | |
2641 | { | |
2642 | return mySHUOMode; | |
2643 | } | |
2644 | ||
2645 | ||
2646 | //======================================================================= | |
2647 | //function : SetDimTolMode | |
2648 | //purpose : | |
2649 | //======================================================================= | |
2650 | ||
2651 | void STEPCAFControl_Writer::SetDimTolMode(const Standard_Boolean dimtolmode) | |
2652 | { | |
2653 | myDGTMode = dimtolmode; | |
2654 | } | |
2655 | ||
2656 | ||
2657 | //======================================================================= | |
2658 | //function : GetDimTolMode | |
2659 | //purpose : | |
2660 | //======================================================================= | |
2661 | ||
2662 | Standard_Boolean STEPCAFControl_Writer::GetDimTolMode() const | |
2663 | { | |
2664 | return myDGTMode; | |
2665 | } | |
2666 | ||
2667 | ||
2668 | //======================================================================= | |
2669 | //function : SetMaterialMode | |
2670 | //purpose : | |
2671 | //======================================================================= | |
2672 | ||
2673 | void STEPCAFControl_Writer::SetMaterialMode(const Standard_Boolean matmode) | |
2674 | { | |
2675 | myMatMode = matmode; | |
2676 | } | |
2677 | ||
2678 | ||
2679 | //======================================================================= | |
2680 | //function : GetMaterialMode | |
2681 | //purpose : | |
2682 | //======================================================================= | |
2683 | ||
2684 | Standard_Boolean STEPCAFControl_Writer::GetMaterialMode() const | |
2685 | { | |
2686 | return myMatMode; | |
2687 | } |