X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FExchangePlugin%2FExchangePlugin_ImportFeature.cpp;h=a0e7ebaaf1fd5faf309e0069699598563b43a292;hb=1490e92974d2c0bdcdbecd6fa9388e31dccfa363;hp=b10ae4cf1453d2700ba5e19d9ce9f070b345816c;hpb=34256ae486b79ee986202cd88e13dc5ca2e9d2ec;p=modules%2Fshaper.git diff --git a/src/ExchangePlugin/ExchangePlugin_ImportFeature.cpp b/src/ExchangePlugin/ExchangePlugin_ImportFeature.cpp index b10ae4cf1..a0e7ebaaf 100644 --- a/src/ExchangePlugin/ExchangePlugin_ImportFeature.cpp +++ b/src/ExchangePlugin/ExchangePlugin_ImportFeature.cpp @@ -5,23 +5,23 @@ // Author: Sergey BELASH #include + #include -#include #include +#include +#include #include + #include #include #include +#include #include #include #include #include -#include -#include -#include -#include #include #include @@ -72,38 +72,32 @@ void ExchangePlugin_ImportFeature::execute() bool ExchangePlugin_ImportFeature::importFile(const std::string& theFileName) { // retrieve the file and plugin library names - TCollection_AsciiString aFileName(theFileName.c_str()); - OSD_Path aPath(aFileName); - TCollection_AsciiString anExtension = aPath.Extension(); - // ".brep" -> "BREP", TCollection_AsciiString are numbered from 1 - anExtension = anExtension.SubString(2, anExtension.Length()); - anExtension.UpperCase(); + // ".brep" -> "BREP" + std::string anExtension = GeomAlgoAPI_Tools::File_Tools::extension(theFileName); // Perform the import - TCollection_AsciiString anError; + std::string anError; - TopoDS_Shape aShape; + std::shared_ptr aGeomShape; if (anExtension == "BREP" || anExtension == "BRP") { - aShape = BREPImport::Import(aFileName, anExtension, anError); + aGeomShape = BREPImport(theFileName, anExtension, anError); } else if (anExtension == "STEP" || anExtension == "STP") { - aShape = STEPImport::Import(aFileName, anExtension, anError); + aGeomShape = STEPImport(theFileName, anExtension, anError); } else if (anExtension == "IGES" || anExtension == "IGS") { - aShape = IGESImport::Import(aFileName, anExtension, anError); + aGeomShape = IGESImport(theFileName, anExtension, anError); } // Check if shape is valid - if ( aShape.IsNull() ) { - const static std::string aShapeError = - "An error occurred while importing " + theFileName + ": " + anError.ToCString(); - setError(aShapeError); - return false; - } + if ( aGeomShape->isNull() ) { + const static std::string aShapeError = + "An error occurred while importing " + theFileName + ": " + anError; + setError(aShapeError); + return false; + } // Pass the results into the model - std::string anObjectName = aPath.Name().ToCString(); + std::string anObjectName = GeomAlgoAPI_Tools::File_Tools::name(theFileName); data()->setName(anObjectName); std::shared_ptr aResultBody = document()->createBody(data()); - std::shared_ptr aGeomShape(new GeomAPI_Shape); - aGeomShape->setImpl(new TopoDS_Shape(aShape)); //LoadNamingDS of the imported shape loadNamingDS(aGeomShape, aResultBody);