+
+//==================================================================================================
+GeomShapePtr STEPImportAttributs(const std::string& theFileName,
+ std::shared_ptr<ModelAPI_ResultBody> theResultBody,
+ const bool theScalInterUnits,
+ const bool theMaterials,
+ const bool /*theColor*/,
+ std::map< std::wstring,
+ std::list<std::wstring>>& theMaterialShape,
+ std::string& theError)
+{
+
+ try {
+ STEPControl_Reader aReader;
+ std::shared_ptr<GeomAPI_Shape> aGeomShape(new GeomAPI_Shape);
+
+ Interface_Static::SetCVal("xstep.cascade.unit", "M");
+ Interface_Static::SetIVal("read.step.ideas", 1);
+ Interface_Static::SetIVal("read.step.nonmanifold", 1);
+
+ try {
+ OCC_CATCH_SIGNALS;
+
+ IFSelect_ReturnStatus status = aReader.ReadFile(theFileName.c_str());
+
+ if (status == IFSelect_RetDone) {
+ // Regard or not the model units
+ if( !readUnits(aReader, theScalInterUnits, theError)) {
+ aGeomShape->setImpl(new TopoDS_Shape());
+ return aGeomShape;
+ }
+ }
+ } catch (Standard_Failure const& anException) {
+ theError = anException.GetMessageString();
+ aGeomShape->setImpl(new TopoDS_Shape());
+ return aGeomShape;
+ }
+
+ STEPCAFControl_Reader aCafreader;
+ aCafreader.SetColorMode(true);
+ aCafreader.SetNameMode(true);
+ aCafreader.SetMatMode(true);
+
+ if (aCafreader.ReadFile(theFileName.c_str()) != IFSelect_RetDone) {
+ theError = "Wrong format of the imported file. Can't import file.";
+ aGeomShape->setImpl(new TopoDS_Shape());
+ return aGeomShape;
+ }
+
+ return readAttributes(aCafreader,
+ theResultBody,
+ theMaterials,
+ theMaterialShape,
+ theError);
+ } catch (OSD_Exception&) {
+ //Try to load STEP file without colors...
+ return STEPImport(theFileName, "", theScalInterUnits, theError);
+ }
+}