1 // Copyright (C) 2014-2016 CEA/DEN, EDF R&D, OPEN CASCADE
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 #include "STEPPlugin_ImportDriver.hxx"
22 #include "STEPPlugin_IImport.hxx"
25 #include <utilities.h>
26 #include <Basics_Utils.hxx>
29 #include "GEOM_Function.hxx"
30 #include "GEOMImpl_Types.hxx"
33 #include <TDF_ChildIDIterator.hxx>
34 #include <TDF_Label.hxx>
35 #include <TDataStd_Name.hxx>
36 #include <TDataStd_Comment.hxx>
37 #include <TNaming_Builder.hxx>
38 #include <TNaming_NamedShape.hxx>
39 #include <Interface_EntityIterator.hxx>
40 #include <Interface_Graph.hxx>
41 #include <Interface_InterfaceModel.hxx>
42 #include <Interface_Static.hxx>
43 #include <STEPControl_Reader.hxx>
44 #include <StepBasic_Product.hxx>
45 #include <StepBasic_ProductDefinition.hxx>
46 #include <StepBasic_ProductDefinitionFormation.hxx>
47 #include <StepGeom_GeometricRepresentationItem.hxx>
48 #include <StepShape_TopologicalRepresentationItem.hxx>
49 #include <StepRepr_DescriptiveRepresentationItem.hxx>
50 #include <StepRepr_NextAssemblyUsageOccurrence.hxx>
51 #include <StepRepr_ProductDefinitionShape.hxx>
52 #include <StepRepr_PropertyDefinitionRepresentation.hxx>
53 #include <StepRepr_Representation.hxx>
54 #include <TransferBRep.hxx>
55 #include <Transfer_TransientProcess.hxx>
56 #include <XSControl_TransferReader.hxx>
57 #include <XSControl_WorkSession.hxx>
58 #include <BRep_Builder.hxx>
60 #include <TopExp_Explorer.hxx>
61 #include <TopTools_DataMapOfShapeShape.hxx>
62 #include <TopTools_IndexedMapOfShape.hxx>
63 #include <TopTools_ListIteratorOfListOfShape.hxx>
64 #include <TopTools_ListOfShape.hxx>
65 #include <TopTools_MapOfShape.hxx>
66 #include <TopoDS_Compound.hxx>
67 #include <TopoDS_Iterator.hxx>
68 #include <TColStd_SequenceOfAsciiString.hxx>
70 #include <StdFail_NotDone.hxx>
71 #include <Standard_Failure.hxx>
72 #include <Standard_ErrorHandler.hxx> // CAREFUL ! position of this file is critic : see Lucien PIGNOLONI / OCC
76 //=============================================================================
80 //=============================================================================
82 TopoDS_Shape GetShape(const Handle(Standard_Transient) &theEnti,
83 const Handle(Transfer_TransientProcess) &theTP)
86 Handle(Transfer_Binder) aBinder = theTP->Find(theEnti);
88 if (aBinder.IsNull()) {
92 aResult = TransferBRep::ShapeResult(aBinder);
97 //=============================================================================
101 //=============================================================================
103 TDF_Label GetLabel(const Handle(Standard_Transient) &theEnti,
104 const TDF_Label &theShapeLabel,
105 const TopoDS_Shape &aShape)
110 (STANDARD_TYPE(StepGeom_GeometricRepresentationItem))) {
111 // check all named shapes using iterator
112 TDF_ChildIDIterator anIt
113 (theShapeLabel, TDataStd_Name::GetID(), Standard_True);
115 for (; anIt.More(); anIt.Next()) {
116 Handle(TDataStd_Name) nameAttr =
117 Handle(TDataStd_Name)::DownCast(anIt.Value());
119 if (nameAttr.IsNull()) {
123 TDF_Label aLab = nameAttr->Label();
124 Handle(TNaming_NamedShape) shAttr;
126 if (aLab.FindAttribute(TNaming_NamedShape::GetID(), shAttr) &&
127 shAttr->Get().IsEqual(aShape)) {
133 // create label and set shape
134 if (aResult.IsNull()) {
137 aResult = aTag.NewChild(theShapeLabel);
139 TNaming_Builder tnBuild (aResult);
141 tnBuild.Generated(aShape);
147 //=============================================================================
151 //=============================================================================
153 Standard_Boolean GetAllParents(const TopoDS_Shape &theShape,
154 const TopoDS_Shape &theSubShape,
155 TopTools_ListOfShape &theParents)
157 const TopAbs_ShapeEnum aSubShType = theSubShape.ShapeType();
158 Standard_Boolean aResult = Standard_False;
160 if (theShape.ShapeType() >= aSubShType) {
161 return aResult; // NULL shape
164 TopoDS_Iterator anIt(theShape);
165 TopTools_MapOfShape aMapFence;
167 for (; anIt.More(); anIt.Next()) {
168 const TopoDS_Shape &aSubShape = anIt.Value();
170 if (aMapFence.Add(aSubShape)) {
171 if (theSubShape.IsSame(aSubShape)) {
172 // The sub-shape is found. theShape is its parent.
173 theParents.Append(theShape);
174 aResult = Standard_True;
178 if (aSubShape.ShapeType() < aSubShType) {
179 if (GetAllParents(aSubShape, theSubShape, theParents)) {
180 // The sub-shape is found.
181 theParents.Append(theShape);
182 aResult = Standard_True;
192 //=============================================================================
194 * BuildModifiedShape()
196 //=============================================================================
198 TopoDS_Shape BuildModifiedShape
199 (const TopoDS_Shape &theShape,
200 TopTools_DataMapOfShapeShape &theMapModified)
202 // Check if the shape is modified.
203 TopoDS_Shape aFwdShape = theShape.Oriented(TopAbs_FORWARD);
204 TopoDS_Iterator anIt(aFwdShape);
205 Standard_Boolean isModified = Standard_False;
207 for (; anIt.More(); anIt.Next()) {
208 if (theMapModified.IsBound(anIt.Value())) {
209 isModified = Standard_True;
214 TopoDS_Shape aResult;
217 BRep_Builder aBuilder;
219 aResult = aFwdShape.EmptyCopied();
221 for (anIt.Initialize(aFwdShape); anIt.More(); anIt.Next()) {
222 const TopoDS_Shape &aSubShape = anIt.Value();
224 if (theMapModified.IsBound(aSubShape)) {
225 TopoDS_Shape aModifSubShape = theMapModified.Find(aSubShape);
227 if (aModifSubShape.IsNull()) {
228 // Recursively compute the sub-shape.
229 aModifSubShape = BuildModifiedShape(aSubShape, theMapModified);
232 aBuilder.Add(aResult, aModifSubShape);
234 aBuilder.Add(aResult, aSubShape);
238 // Set the result shape orienation.
239 aResult.Orientation(theShape.Orientation());
240 theMapModified.Bind(theShape, aResult);
248 //=============================================================================
252 //=============================================================================
254 TopoDS_Shape CreateAssemblies
255 (const STEPControl_Reader &theReader,
256 const TopoDS_Shape &theShape,
257 TopTools_DataMapOfShapeShape &theMapShapeAssembly)
259 TopoDS_Shape aResult = theShape;
260 Handle(XSControl_TransferReader) aTR = theReader.WS()->TransferReader();
261 TopTools_ListOfShape aListAssemblies;
264 Handle(Interface_InterfaceModel) aModel = theReader.WS()->Model();
265 Handle(Transfer_TransientProcess) aTP = aTR->TransientProcess();
266 Standard_Integer aNbEntities = aModel->NbEntities();
268 Handle(Standard_Type) aNAUOType =
269 STANDARD_TYPE(StepRepr_NextAssemblyUsageOccurrence);
271 for (i = 1; i <= aNbEntities; i++) {
272 Handle(Standard_Transient) anEnti = aModel->Value(i);
274 if (anEnti->IsKind(aNAUOType)) {
275 // This is an assembly. Find target shape
276 TopoDS_Shape aShape = GetShape(anEnti, aTP);
278 if (aShape.IsNull()) {
282 if (aShape.ShapeType() != TopAbs_COMPOUND) {
283 aListAssemblies.Append(aShape);
289 // Create assemblies.
290 if (!aListAssemblies.IsEmpty()) {
291 TopTools_ListIteratorOfListOfShape anIter(aListAssemblies);
292 BRep_Builder aBuilder;
294 for (; anIter.More(); anIter.Next()) {
295 const TopoDS_Shape &aShape = anIter.Value();
296 TopTools_ListOfShape aParents;
298 if (GetAllParents(theShape, aShape, aParents) &&
299 aParents.First().ShapeType() == TopAbs_COMPOUND) {
300 TopoDS_Compound aComp;
301 TopTools_ListIteratorOfListOfShape aParentIter(aParents);
303 // Fill theMapShapeAssembly.
304 for (; aParentIter.More(); aParentIter.Next()) {
305 theMapShapeAssembly.Bind(aParentIter.Value(), TopoDS_Shape());
308 aBuilder.MakeCompound(aComp);
309 aBuilder.Add(aComp, aShape);
310 theMapShapeAssembly.Bind(aShape, aComp);
314 // Build a new shape.
315 aResult = BuildModifiedShape(theShape, theMapShapeAssembly);
321 //=============================================================================
325 //=============================================================================
327 void StoreName(const Handle(Standard_Transient) &theEnti,
328 const TopTools_IndexedMapOfShape &theIndices,
329 const Handle(XSControl_WorkSession) &theWS,
330 const Handle(Transfer_TransientProcess) &theTP,
331 const TDF_Label &theShapeLabel,
332 TopTools_DataMapOfShapeShape &theMapShapeAssembly)
334 Handle(TCollection_HAsciiString) aName;
336 if (theEnti->IsKind(STANDARD_TYPE(StepShape_TopologicalRepresentationItem)) ||
337 theEnti->IsKind(STANDARD_TYPE(StepGeom_GeometricRepresentationItem))) {
338 aName = Handle(StepRepr_RepresentationItem)::DownCast(theEnti)->Name();
339 } else if (theEnti->IsKind(STANDARD_TYPE(StepRepr_NextAssemblyUsageOccurrence))) {
340 Handle(StepRepr_NextAssemblyUsageOccurrence) aNAUO =
341 Handle(StepRepr_NextAssemblyUsageOccurrence)::DownCast(theEnti);
343 Interface_EntityIterator aSubs = theWS->Graph().Sharings(aNAUO);
345 for (aSubs.Start(); aSubs.More(); aSubs.Next()) {
346 Handle(StepRepr_ProductDefinitionShape) aPDS =
347 Handle(StepRepr_ProductDefinitionShape)::DownCast(aSubs.Value());
353 Handle(StepBasic_ProductDefinitionRelationship) aPDR =
354 aPDS->Definition().ProductDefinitionRelationship();
360 if (aPDR->HasDescription() && aPDR->Description()->UsefullLength() >0) {
361 aName = aPDR->Description();
362 } else if (!aPDR->Name().IsNull() && aPDR->Name()->UsefullLength() >0 ) {
363 aName = aPDR->Name();
364 } else if (!aPDR->Id().IsNull()) {
369 Handle(StepBasic_ProductDefinition) PD =
370 Handle(StepBasic_ProductDefinition)::DownCast(theEnti);
372 if (PD.IsNull() == Standard_False) {
373 Handle(StepBasic_Product) Prod = PD->Formation()->OfProduct();
374 aName = Prod->Name();
378 bool isValidName = false;
380 if (aName.IsNull() == Standard_False) {
383 if (aName->UsefullLength() < 1) {
385 } else if (aName->UsefullLength() == 4 &&
386 toupper (aName->Value(1)) == 'N' &&
387 toupper (aName->Value(2)) == 'O' &&
388 toupper (aName->Value(3)) == 'N' &&
389 toupper (aName->Value(4)) == 'E') {
393 // special check to pass names like "Open CASCADE STEP translator 6.3 1"
394 TCollection_AsciiString aSkipName ("Open CASCADE STEP translator");
396 if (aName->Length() >= aSkipName.Length()) {
397 if (aName->String().SubString
398 (1, aSkipName.Length()).IsEqual(aSkipName)) {
406 TCollection_ExtendedString aNameExt (aName->ToCString());
409 TopoDS_Shape S = GetShape(theEnti, theTP);
411 if (theMapShapeAssembly.IsBound(S)) {
412 S = theMapShapeAssembly.Find(S);
419 // as PRODUCT can be included in the main shape
420 // several times, we look here for all iclusions.
421 Standard_Integer isub, nbSubs = theIndices.Extent();
423 for (isub = 1; isub <= nbSubs; isub++) {
424 TopoDS_Shape aSub = theIndices.FindKey(isub);
426 if (aSub.IsPartner(S)) {
427 TDF_Label L = GetLabel(theEnti, theShapeLabel, aSub);
430 TDataStd_Name::Set(L, aNameExt);
436 //=============================================================================
440 //=============================================================================
442 void StoreMaterial( const Handle(Standard_Transient) &theEnti,
443 const TopTools_IndexedMapOfShape &theIndices,
444 const Handle(Transfer_TransientProcess) &theTP,
445 const TDF_Label &theShapeLabel )
447 // Treat Product Definition Shape only.
448 Handle(StepRepr_ProductDefinitionShape) aPDS =
449 Handle(StepRepr_ProductDefinitionShape)::DownCast(theEnti);
450 Handle(StepBasic_ProductDefinition) aProdDef;
452 if(aPDS.IsNull() == Standard_False) {
453 // Product Definition Shape ==> Product Definition
454 aProdDef = aPDS->Definition().ProductDefinition();
457 if (aProdDef.IsNull() == Standard_False) {
458 // Product Definition ==> Property Definition
459 const Interface_Graph &aGraph = theTP->Graph();
460 Interface_EntityIterator aSubs = aGraph.Sharings(aProdDef);
463 for(aSubs.Start(); aSubs.More(); aSubs.Next()) {
464 Handle(StepRepr_PropertyDefinition) aPropD =
465 Handle(StepRepr_PropertyDefinition)::DownCast(aSubs.Value());
467 if(aPropD.IsNull() == Standard_False) {
468 // Property Definition ==> Representation.
469 Interface_EntityIterator aSubs1 = aGraph.Sharings(aPropD);
471 for(aSubs1.Start(); aSubs1.More(); aSubs1.Next()) {
472 Handle(StepRepr_PropertyDefinitionRepresentation) aPDR =
473 Handle(StepRepr_PropertyDefinitionRepresentation)::
474 DownCast(aSubs1.Value());
476 if(aPDR.IsNull() == Standard_False) {
477 // Property Definition ==> Material Name.
478 Handle(StepRepr_Representation) aRepr = aPDR->UsedRepresentation();
480 if(aRepr.IsNull() == Standard_False) {
483 for(ir = 1; ir <= aRepr->NbItems(); ir++) {
484 Handle(StepRepr_RepresentationItem) aRI = aRepr->ItemsValue(ir);
485 Handle(StepRepr_DescriptiveRepresentationItem) aDRI =
486 Handle(StepRepr_DescriptiveRepresentationItem)::DownCast(aRI);
488 if(aDRI.IsNull() == Standard_False) {
489 // Get shape from Product Definition
490 Handle(TCollection_HAsciiString) aMatName = aDRI->Name();
492 if(aMatName.IsNull() == Standard_False) {
493 TCollection_ExtendedString
494 aMatNameExt (aMatName->ToCString());
496 if (aShape.IsNull()) {
498 aShape = GetShape(aProdDef, theTP);
500 if (aShape.IsNull()) {
505 // as PRODUCT can be included in the main shape
506 // several times, we look here for all iclusions.
507 Standard_Integer isub, nbSubs = theIndices.Extent();
509 for (isub = 1; isub <= nbSubs; isub++) {
510 TopoDS_Shape aSub = theIndices.FindKey(isub);
512 if (aSub.IsPartner(aShape)) {
514 GetLabel(aProdDef, theShapeLabel, aSub);
517 TDataStd_Comment::Set(aLabel, aMatNameExt);
531 TCollection_AsciiString ToNamedUnit( const TCollection_AsciiString& unit )
533 TCollection_AsciiString result = unit;
535 if ( result == "mil" ) result = "milliinch";
539 TCollection_AsciiString ToOcctUnit( const TCollection_AsciiString& unit, TCollection_AsciiString& error )
541 TCollection_AsciiString result = "M", u = ToNamedUnit(unit);
546 else if (u == "milliinch")
548 else if (u == "microinch")
550 else if (u == "foot")
552 else if (u == "mile")
554 else if (u == "metre")
556 else if (u == "kilometre")
558 else if (u == "millimetre")
560 else if (u == "centimetre")
562 else if (u == "micrometre")
564 else if (u.IsEmpty())
567 error = "The file contains not supported units";
569 // TODO (for other units)
576 } // end of namespace
578 //=======================================================================
581 //=======================================================================
582 const Standard_GUID& STEPPlugin_ImportDriver::GetID()
584 static Standard_GUID aGUID("a25f88df-461b-45c0-ab6b-a82101fe6ce7");
588 //=======================================================================
589 //function : STEPPlugin_ImportDriver
591 //=======================================================================
592 STEPPlugin_ImportDriver::STEPPlugin_ImportDriver()
596 //=======================================================================
599 //=======================================================================
600 Standard_Integer STEPPlugin_ImportDriver::Execute(LOGBOOK& log) const
602 if( Label().IsNull() ) return 0;
603 Handle(GEOM_Function) aFunction = GEOM_Function::GetFunction( Label() );
605 STEPPlugin_IImport aData( aFunction );
607 TCollection_AsciiString aFileName = aData.GetFileName().ToCString();
608 bool anIsIgnoreUnits = aData.GetIsIgnoreUnits();
609 bool isCreateAssemblies = aData.GetIsCreateAssemblies();
610 TDF_Label aShapeLabel = aFunction->GetNamingEntry();
612 MESSAGE("Import STEP from file " << aFileName.ToCString() );
614 TopoDS_Shape aResShape;
615 TCollection_AsciiString anError;
617 // Set "C" numeric locale to save numbers correctly
618 Kernel_Utils::Localizer loc;
620 STEPControl_Reader aReader;
622 //VSR: 16/09/09: Convert to METERS
623 Interface_Static::SetCVal("xstep.cascade.unit","M");
624 Interface_Static::SetIVal("read.step.ideas", 1);
625 Interface_Static::SetIVal("read.step.nonmanifold", 1);
628 TopoDS_Compound compound;
629 B.MakeCompound(compound);
634 IFSelect_ReturnStatus status = aReader.ReadFile(aFileName.ToCString());
635 if (status == IFSelect_RetDone) {
636 // Regard or not the model units
637 if( anIsIgnoreUnits ) {
638 // set UnitFlag to units from file
639 TColStd_SequenceOfAsciiString anUnitLengthNames;
640 TColStd_SequenceOfAsciiString anUnitAngleNames;
641 TColStd_SequenceOfAsciiString anUnitSolidAngleNames;
642 aReader.FileUnits(anUnitLengthNames, anUnitAngleNames, anUnitSolidAngleNames);
643 if (anUnitLengthNames.Length() > 0) {
644 TCollection_AsciiString aLenUnits = ToOcctUnit(anUnitLengthNames.First(), anError);
645 Interface_Static::SetCVal("xstep.cascade.unit", aLenUnits.ToCString());
649 // Need re-scale a model (set UnitFlag to 'meter')
650 Interface_Static::SetCVal("xstep.cascade.unit","M");
653 Standard_Boolean failsonly = Standard_False;
654 aReader.PrintCheckLoad(failsonly, IFSelect_ItemsByEntity);
657 Standard_Integer aNbRoots = aReader.NbRootsForTransfer();
660 aReader.PrintCheckTransfer(failsonly, IFSelect_ItemsByEntity);
662 for (i = 1; i <= aNbRoots; i++) {
663 aReader.TransferRoot(i);
666 // Create result shape
667 const Standard_Integer aNbShapes = aReader.NbShapes();
668 TopTools_ListOfShape aListResShapes;
670 if (isCreateAssemblies) {
671 for (i = 1; i <= aNbShapes; i++) {
672 TopoDS_Shape aShape = aReader.Shape(i);
674 if (aShape.IsNull()) {
678 aListResShapes.Append(aShape);
681 for (i = 1; i <= aNbShapes; i++) {
682 TopoDS_Shape aShape = aReader.Shape(i);
684 if (aShape.IsNull()) {
688 if (aShape.ShapeType() == TopAbs_COMPOUND) {
690 TopoDS_Shape aSubShape;
691 TopoDS_Iterator anIt (aShape, Standard_True, Standard_True);
693 for (; anIt.More(); anIt.Next()) {
695 aSubShape = anIt.Value();
699 // Use the single sub-shape
700 aListResShapes.Append(aSubShape);
701 } else if (aNbSub > 1) {
703 aListResShapes.Append(aShape);
706 // Use the shape itself
707 aListResShapes.Append(aShape);
712 // Construct result shape.
713 if (!aListResShapes.IsEmpty()) {
714 if (aListResShapes.Extent() == 1) {
715 // Use the single shape.
716 aResShape = aListResShapes.First();
718 // Make a compound of result shapes.
719 TopTools_ListIteratorOfListOfShape anIt(aListResShapes);
721 for (; anIt.More(); anIt.Next()) {
722 B.Add(compound, anIt.Value());
725 aResShape = compound;
729 if( aResShape.IsNull() ) {
730 StdFail_NotDone::Raise("Null result shape");
734 // Check if any BRep entity has been read, there must be at least a vertex
735 if ( !TopExp_Explorer( aResShape, TopAbs_VERTEX ).More() )
736 StdFail_NotDone::Raise( "No geometrical data in the imported file." );
738 // Create assemblies in the shape, if they are not created yet.
739 TopTools_DataMapOfShapeShape aMapShapeAssembly;
741 if (isCreateAssemblies) {
742 aResShape = CreateAssemblies(aReader, aResShape, aMapShapeAssembly);
745 // BEGIN: Store names and materials of sub-shapes from file
746 TopTools_IndexedMapOfShape anIndices;
747 TopExp::MapShapes(aResShape, anIndices);
749 Handle(Interface_InterfaceModel) Model = aReader.WS()->Model();
750 Handle(XSControl_TransferReader) TR = aReader.WS()->TransferReader();
752 Handle(Transfer_TransientProcess) TP = TR->TransientProcess();
754 Standard_Integer nb = Model->NbEntities();
756 for (Standard_Integer ie = 1; ie <= nb; ie++) {
757 Handle(Standard_Transient) enti = Model->Value(ie);
760 StoreName(enti, anIndices, aReader.WS(),
761 TP, aShapeLabel, aMapShapeAssembly);
764 StoreMaterial(enti, anIndices, TP, aShapeLabel);
767 // END: Store names and materials
771 case IFSelect_RetVoid:
772 anError = "Nothing created or No data to process";
774 case IFSelect_RetError:
775 anError = "Error in command or input data";
777 case IFSelect_RetFail:
778 anError = "Execution was run, but has failed";
780 case IFSelect_RetStop:
781 anError = "Execution has been stopped. Quite possible, an exception was raised";
786 anError = "Wrong format of the imported file. Can't import file.";
790 catch( Standard_Failure ) {
791 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
792 anError = aFail->GetMessageString();
796 if( aResShape.IsNull() ) {
797 StdFail_NotDone::Raise( anError.ToCString() );
801 aFunction->SetValue( aResShape );
803 #if OCC_VERSION_MAJOR < 7
804 log.SetTouched(Label());
806 log->SetTouched(Label());
812 //================================================================================
814 * \brief Returns a name of creation operation and names and values of creation parameters
816 //================================================================================
818 bool STEPPlugin_ImportDriver::
819 GetCreationInformation( std::string& theOperationName,
820 std::vector<GEOM_Param>& theParams )
822 if( Label().IsNull() ) return 0;
823 Handle(GEOM_Function) function = GEOM_Function::GetFunction( Label() );
825 STEPPlugin_IImport aCI( function );
826 Standard_Integer aType = function->GetType();
828 theOperationName = "ImportSTEP";
832 AddParam( theParams, "File name", aCI.GetFileName() );
833 if( aCI.GetIsIgnoreUnits() )
834 AddParam( theParams, "Format", "STEP_SCALE" );
835 AddParam( theParams, "Create Assemblies", aCI.GetIsCreateAssemblies() );
843 TCollection_AsciiString
844 STEPPlugin_ImportDriver::GetValue( const TCollection_AsciiString& theFileName,
845 const TCollection_AsciiString& theParameterName,
846 TCollection_AsciiString& theError )
848 TCollection_AsciiString aValue;
850 if (theParameterName != "LEN_UNITS") {
851 theError = theParameterName + " parameter reading is not supported by STEP plugin";
852 return TCollection_AsciiString();
855 // Set "C" numeric locale to save numbers correctly
856 Kernel_Utils::Localizer loc;
858 STEPControl_Reader aReader;
860 Interface_Static::SetCVal( "xstep.cascade.unit","M" );
861 Interface_Static::SetIVal( "read.step.ideas", 1 );
862 Interface_Static::SetIVal( "read.step.nonmanifold", 1 );
866 IFSelect_ReturnStatus status = aReader.ReadFile( theFileName.ToCString() );
867 if (status == IFSelect_RetDone) {
868 TColStd_SequenceOfAsciiString anUnitLengthNames;
869 TColStd_SequenceOfAsciiString anUnitAngleNames;
870 TColStd_SequenceOfAsciiString anUnitSolidAngleNames;
871 aReader.FileUnits(anUnitLengthNames, anUnitAngleNames, anUnitSolidAngleNames);
872 if (anUnitLengthNames.Length() > 0)
873 aValue = ToNamedUnit( anUnitLengthNames.First() );
876 theError = theFileName + " reading failed";
879 catch( Standard_Failure ) {
880 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
881 theError = aFail->GetMessageString();
886 OCCT_IMPLEMENT_STANDARD_RTTIEXT( STEPPlugin_ImportDriver, GEOM_BaseDriver );