Salome HOME
Fix Import/Export tests
[modules/shaper.git] / src / ExchangePlugin / ExchangePlugin_ImportFeature.cpp
index 1716adb37e54150fb7e59e74c704f895024d5fe1..e2d29c9c85ad7b2c8255a96617f8e068d9c1e5b0 100644 (file)
 #include <Config_PropManager.h>
 
 #include <ModelAPI_AttributeString.h>
+#include <ModelAPI_BodyBuilder.h>
 #include <ModelAPI_Data.h>
 #include <ModelAPI_Document.h>
 #include <ModelAPI_Object.h>
 #include <ModelAPI_ResultBody.h>
 
-#include <TopoDS_Shape.hxx>
-
 #include <algorithm>
 #include <string>
 #ifdef _DEBUG
@@ -79,16 +78,16 @@ bool ExchangePlugin_ImportFeature::importFile(const std::string& theFileName)
   // Perform the import
   std::string anError;
 
-  TopoDS_Shape aShape;
+  std::shared_ptr<GeomAPI_Shape> aGeomShape;
   if (anExtension == "BREP" || anExtension == "BRP") {
-    aShape = BREPImport::Import(theFileName, anExtension, anError);
+    aGeomShape = BREPImport(theFileName, anExtension, anError);
   } else if (anExtension == "STEP" || anExtension == "STP") {
-    aShape = STEPImport::Import(theFileName, anExtension, anError);
+    aGeomShape = STEPImport(theFileName, anExtension, anError);
   } else if (anExtension == "IGES" || anExtension == "IGS") {
-    aShape = IGESImport::Import(theFileName, anExtension, anError);
+    aGeomShape = IGESImport(theFileName, anExtension, anError);
   }
    // Check if shape is valid
-  if ( aShape.IsNull() ) {
+  if ( aGeomShape->isNull() ) {
     const static std::string aShapeError =
       "An error occurred while importing " + theFileName + ": " + anError;
     setError(aShapeError);
@@ -99,8 +98,6 @@ bool ExchangePlugin_ImportFeature::importFile(const std::string& theFileName)
   std::string anObjectName = GeomAlgoAPI_Tools::File_Tools::name(theFileName);
   data()->setName(anObjectName);
   std::shared_ptr<ModelAPI_ResultBody> aResultBody = document()->createBody(data());
-  std::shared_ptr<GeomAPI_Shape> aGeomShape(new GeomAPI_Shape);
-  aGeomShape->setImpl(new TopoDS_Shape(aShape));
 
   //LoadNamingDS of the imported shape
   loadNamingDS(aGeomShape, aResultBody);
@@ -116,9 +113,9 @@ void ExchangePlugin_ImportFeature::loadNamingDS(
     std::shared_ptr<ModelAPI_ResultBody> theResultBody)
 {
   //load result
-  theResultBody->store(theGeomShape);
+  theResultBody->getBodyBuilder()->store(theGeomShape);
 
   int aTag(1);
   std::string aNameMS = "Shape";
-  theResultBody->loadFirstLevel(theGeomShape, aNameMS, aTag);
+  theResultBody->getBodyBuilder()->loadFirstLevel(theGeomShape, aNameMS, aTag);
 }