]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Issue #529 : 4.07. Import IGES, export to BREP, STEP, IGES - Remove redundant code...
authorSergey POKHODENKO <sergey.pokhodenko@opencascade.com>
Mon, 18 May 2015 07:04:30 +0000 (10:04 +0300)
committerSergey POKHODENKO <sergey.pokhodenko@opencascade.com>
Tue, 19 May 2015 07:58:20 +0000 (10:58 +0300)
16 files changed:
src/ExchangePlugin/ExchangePlugin_ExportFeature.cpp
src/ExchangePlugin/ExchangePlugin_ExportFeature.h
src/ExchangePlugin/ExchangePlugin_ImportFeature.cpp
src/GeomAlgoAPI/GeomAlgoAPI_BREPExport.cpp
src/GeomAlgoAPI/GeomAlgoAPI_BREPExport.h
src/GeomAlgoAPI/GeomAlgoAPI_BREPImport.cpp
src/GeomAlgoAPI/GeomAlgoAPI_BREPImport.h
src/GeomAlgoAPI/GeomAlgoAPI_IGESExport.cpp
src/GeomAlgoAPI/GeomAlgoAPI_IGESExport.h
src/GeomAlgoAPI/GeomAlgoAPI_IGESImport.cpp
src/GeomAlgoAPI/GeomAlgoAPI_IGESImport.h
src/GeomAlgoAPI/GeomAlgoAPI_STEPExport.cpp
src/GeomAlgoAPI/GeomAlgoAPI_STEPExport.h
src/GeomAlgoAPI/GeomAlgoAPI_STEPImport.cpp
src/GeomAlgoAPI/GeomAlgoAPI_STEPImport.h
src/ModuleBase/ModuleBase_WidgetFileSelector.cpp

index 166bda9b6d0287516560df662ddce0a020ba61d0..a67b57bccb115ce7d649bfd812bbf93b194ef1a3 100644 (file)
@@ -89,7 +89,7 @@ void ExchangePlugin_ExportFeature::execute()
   AttributeSelectionListPtr aSelectionListAttr =
       this->selectionList(ExchangePlugin_ExportFeature::SELECTION_LIST_ID());
   std::list<std::shared_ptr<GeomAPI_Shape> > aShapes;
-  for ( int i = 0, aSize = aSelectionListAttr->size(); i < aSize; ++i ) {
+  for (int i = 0, aSize = aSelectionListAttr->size(); i < aSize; ++i) {
     aShapes.push_back(aSelectionListAttr->value(i)->value());
   }
   std::shared_ptr<GeomAPI_Shape> aShape =
@@ -98,35 +98,24 @@ void ExchangePlugin_ExportFeature::execute()
   exportFile(aFilePath, aFormat, aShape);
 }
 
-std::list<std::string> ExchangePlugin_ExportFeature::getFormats() const
-{
-  // This value is a copy of string_list attribute of format_choice in plugin-Exchange.xml
-  // XPath:plugin-Exchange.xml:string(//*[@id="format_choice"]/@string_list)
-  std::string aFormats = "BREP STEP IGES-5.1 IGES-5.3";
-  return ExchangePlugin_Tools::split(aFormats, ' ');
-}
-
 bool ExchangePlugin_ExportFeature::exportFile(const std::string& theFileName,
                                               const std::string& theFormat,
                                               std::shared_ptr<GeomAPI_Shape> theShape)
 {
   // retrieve the file and plugin library names
   TCollection_AsciiString aFileName(theFileName.c_str());
-  OSD_Path aPath(aFileName);
   TCollection_AsciiString aFormatName(theFormat.c_str());
 
   // Perform the export
   TCollection_AsciiString anError;
-  TDF_Label anUnknownLabel = TDF_Label();
-
   TopoDS_Shape aShape(theShape->impl<TopoDS_Shape>());
   bool aResult = false;
   if (aFormatName == "BREP") {
-    aResult = BREPExport::Export(aFileName, aFormatName, aShape, anError, anUnknownLabel);
+    aResult = BREPExport::Export(aFileName, aFormatName, aShape, anError);
   } else if (aFormatName == "STEP") {
-    aResult = STEPExport::Export(aFileName, aFormatName, aShape, anError, anUnknownLabel);
+    aResult = STEPExport::Export(aFileName, aFormatName, aShape, anError);
   } else if (aFormatName.SubString(1, 4) == "IGES") {
-    aResult = IGESExport::Export(aFileName, aFormatName, aShape, anError, anUnknownLabel);
+    aResult = IGESExport::Export(aFileName, aFormatName, aShape, anError);
   } else {
     anError = TCollection_AsciiString("Unsupported format ") + aFormatName;
   }
index fb45a27fc92f08420cc4633fa47a401ad8fa925f..6613f9609713883c68d51d22b329894cb1c6c7aa 100644 (file)
@@ -17,7 +17,7 @@
  */
 class ExchangePlugin_ExportFeature : public ModelAPI_Feature
 {
- public:
+public:
   inline static const std::string& ID()
   {
     static const std::string MY_EXPORT_ID("Export");
index f5bf2bb11ac97ee686b6ef8b18daea22612cd5fc..ea085c13f9c4673f540d9889dc854f080f991d63 100644 (file)
@@ -63,11 +63,12 @@ void ExchangePlugin_ImportFeature::initAttributes()
  */
 void ExchangePlugin_ImportFeature::execute()
 {
-  AttributeStringPtr aFilePathAttr = std::dynamic_pointer_cast<ModelAPI_AttributeString>(
-      data()->attribute(ExchangePlugin_ImportFeature::FILE_PATH_ID()));
+  AttributeStringPtr aFilePathAttr =
+      this->string(ExchangePlugin_ImportFeature::FILE_PATH_ID());
   std::string aFilePath = aFilePathAttr->value();
-  if(aFilePath.empty())
+  if (aFilePath.empty())
     return;
+
   importFile(aFilePath);
 }
 
@@ -76,26 +77,25 @@ 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 aFormatName = aPath.Extension();
+  TCollection_AsciiString anExtension = aPath.Extension();
   // ".brep" -> "BREP", TCollection_AsciiString are numbered from 1
-  aFormatName = aFormatName.SubString(2, aFormatName.Length());
-  aFormatName.UpperCase();
+  anExtension = anExtension.SubString(2, anExtension.Length());
+  anExtension.UpperCase();
 
   // Perform the import
   TCollection_AsciiString anError;
-  TDF_Label anUnknownLabel = TDF_Label();
 
   TopoDS_Shape aShape;
-  if (aFormatName == "BREP") {
-    aShape = BREPImport::Import(aFileName, aFormatName, anError, anUnknownLabel);
-  } else if (aFormatName == "STEP" || aFormatName == "STP") {
-    aShape = STEPImport::Import(aFileName, aFormatName, anError, anUnknownLabel);
-  } else if (aFormatName == "IGES") {
-    aShape = IGESImport::Import(aFileName, aFormatName, anError, anUnknownLabel);
+  if (anExtension == "BREP") {
+    aShape = BREPImport::Import(aFileName, anExtension, anError);
+  } else if (anExtension == "STEP" || anExtension == "STP") {
+    aShape = STEPImport::Import(aFileName, anExtension, anError);
+  } else if (anExtension == "IGES") {
+    aShape = IGESImport::Import(aFileName, anExtension, anError);
   }
    // Check if shape is valid
   if ( aShape.IsNull() ) {
-     const static std::string aShapeError = 
+     const static std::string aShapeError =
        "An error occurred while importing " + theFileName + ": " + anError.ToCString();
      setError(aShapeError);
      return false;
@@ -127,8 +127,4 @@ void ExchangePlugin_ImportFeature::loadNamingDS(
   int aTag(1);
   std::string aNameMS = "Shape";
   theResultBody->loadFirstLevel(theGeomShape, aNameMS, aTag);
-  //std::string aNameDE = "DiscEdges";
-  //theResultBody->loadDisconnectedEdges(theGeomShape, aNameDE, aTag);
-  //std::string aNameDV = "DiscVertexes";
-  //theResultBody->loadDisconnectedVertexes(theGeomShape, aNameDV, aTag); 
 }
index 0499c7587bd094fb3e32f9085234f412f5f0a2c3..506a082645e816ee5831cc0a3c86eff803dc4501 100644 (file)
@@ -15,7 +15,7 @@ namespace BREPExport {
 bool Export(const TCollection_AsciiString& theFileName,
             const TCollection_AsciiString&,
             const TopoDS_Shape& theShape,
-            TCollection_AsciiString& theError, const TDF_Label&)
+            TCollection_AsciiString& theError)
 {
   #ifdef _DEBUG
   std::cout << "Export BREP into file " << theFileName << std::endl;
index 90496b0e4589c342b61704cd8d84a3914748e74d..88acbf5a1fe4105d680a682477bf11cce7ae9340 100644 (file)
@@ -23,7 +23,7 @@ GEOMALGOAPI_EXPORT
 bool Export(const TCollection_AsciiString& theFileName,
             const TCollection_AsciiString& theFormatName,
             const TopoDS_Shape& theShape,
-            TCollection_AsciiString& theError, const TDF_Label&);
+            TCollection_AsciiString& theError);
 
 }
 
index 2df29ebc080dedf4445d8563d8b6b54616c14d78..32cb7c95a67c461068f2ff681051729acfac2513 100644 (file)
@@ -14,7 +14,7 @@
 namespace BREPImport {
 TopoDS_Shape Import(const TCollection_AsciiString& theFileName,
                     const TCollection_AsciiString&,
-                    TCollection_AsciiString& theError, const TDF_Label&)
+                    TCollection_AsciiString& theError)
 {
   #ifdef _DEBUG
   std::cout << "Import BREP from file " << theFileName << std::endl;
index aa0c7202dd8fc62a6de4fadaa696db6ff74fbc62..6afbdf0cad1d1c830fe72af945630c70723455a9 100644 (file)
@@ -22,7 +22,7 @@ namespace BREPImport {
 GEOMALGOAPI_EXPORT
 TopoDS_Shape Import(const TCollection_AsciiString& theFileName,
                     const TCollection_AsciiString& theFormatName,
-                    TCollection_AsciiString& theError, const TDF_Label&);
+                    TCollection_AsciiString& theError);
 
 }
 
index 425f58102edc13c6b2ee7a671e770618836c512f..593c49670f5e04629cb840a2e213ea439f1a889d 100644 (file)
@@ -83,7 +83,7 @@ namespace IGESExport {
 bool Export(const TCollection_AsciiString& theFileName,
             const TCollection_AsciiString& theFormatName,
             const TopoDS_Shape& theShape,
-            TCollection_AsciiString& theError, const TDF_Label&)
+            TCollection_AsciiString& theError)
 {
   // theFormatName expected "IGES-5.1", "IGES-5.3"...
   TCollection_AsciiString aVersion = theFormatName.Token("-", 2);
index e52a263e78e76c251e3355f785b44c73a573d9b6..4f0f3cc3411866511b1579f2eeff0b802d51800a 100644 (file)
@@ -23,7 +23,7 @@ GEOMALGOAPI_EXPORT
 bool Export(const TCollection_AsciiString& theFileName,
             const TCollection_AsciiString& theFormatName,
             const TopoDS_Shape& theShape,
-            TCollection_AsciiString& theError, const TDF_Label&);
+            TCollection_AsciiString& theError);
 
 }
 
index 481c13521d08c225ddaa68bbb99b0f17d8888319..8e20cb32aec65b37fb6cbe8b2551efb1605bdeaa 100644 (file)
@@ -15,7 +15,7 @@
 namespace IGESImport {
 TopoDS_Shape Import(const TCollection_AsciiString& theFileName,
                     const TCollection_AsciiString&,
-                    TCollection_AsciiString& theError, const TDF_Label&)
+                    TCollection_AsciiString& theError)
 {
   #ifdef _DEBUG
   std::cout << "Import IGES from file " << theFileName << std::endl;
index c01f7c1d542675acc8dfd842a753450915da56ad..9bdb3ad84515fdd4abfd2ded6c9818a603edba97 100644 (file)
@@ -22,7 +22,7 @@ namespace IGESImport {
 GEOMALGOAPI_EXPORT
 TopoDS_Shape Import(const TCollection_AsciiString& theFileName,
                     const TCollection_AsciiString& theFormatName,
-                    TCollection_AsciiString& theError, const TDF_Label&);
+                    TCollection_AsciiString& theError);
 
 }
 
index 5cc71b056557a402f0ce7a83d08e1ec0b5f060e1..734d91fb82b4da7a4709b537c894403cff49b8f0 100644 (file)
@@ -12,8 +12,7 @@ namespace STEPExport {
 bool Export(const TCollection_AsciiString& theFileName,
             const TCollection_AsciiString& theFormatName,
             const TopoDS_Shape& theShape,
-            TCollection_AsciiString& theError,
-            const TDF_Label& theShapeLabel)
+            TCollection_AsciiString& theError)
 {
   #ifdef _DEBUG
   std::cout << "Export STEP into file " << theFileName.ToCString() << std::endl;
index f0bcec1729a7f7f5e368cf0dbd1733b15cbcc063..e05a59ff1d52eac335c540635087e4d28f4ee6c1 100644 (file)
@@ -30,8 +30,7 @@ GEOMALGOAPI_EXPORT
 bool Export(const TCollection_AsciiString& theFileName,
             const TCollection_AsciiString& theFormatName,
             const TopoDS_Shape& theShape,
-            TCollection_AsciiString& theError,
-            const TDF_Label& theShapeLabel);
+            TCollection_AsciiString& theError);
 }
 
 #endif /* GEOMALGOAPI_STEPEXPORT_H_ */
index 8ed138604b6ebfea7cf7d14f52b1fbe35e2feb3c..4bc7f2f6488b334be9f229440f06679317eb8700 100644 (file)
@@ -366,8 +366,7 @@ Handle(TCollection_HAsciiString) GetValue (const TCollection_AsciiString& theFil
 
 TopoDS_Shape Import (const TCollection_AsciiString& theFileName,
                      const TCollection_AsciiString& theFormatName,
-                     TCollection_AsciiString&       theError,
-                     const TDF_Label&               theShapeLabel)
+                     TCollection_AsciiString&       theError)
 {
   TopoDS_Shape aResShape;
 
index dc3299669ccc6d877b7b88bd5f4955aff45dce15..5955ddbf11a13792b62f84379e769d476fd06cda 100644 (file)
@@ -28,8 +28,8 @@ Handle(TCollection_HAsciiString) GetValue(const TCollection_AsciiString& theFile
 /// Implementation of the import STEP files algorithms
 GEOMALGOAPI_EXPORT
 TopoDS_Shape Import(const TCollection_AsciiString& theFileName,
-                    const TCollection_AsciiString& theFormatName, TCollection_AsciiString& theError,
-                    const TDF_Label& theShapeLabel);
+                    const TCollection_AsciiString& theFormatName,
+                    TCollection_AsciiString& theError);
 }
 
 #endif /* GEOMALGOAPI_STEPIMPORT_H_ */
index 5da22f5ebf6ccedab6b9e37ffc91377e0adea482..3292d70f228ac8df147ad4f46f07cc449e47e85f 100644 (file)
@@ -146,9 +146,11 @@ QStringList ModuleBase_WidgetFileSelector::getValidatorFormats() const
 {
   SessionPtr aMgr = ModelAPI_Session::get();
   ModelAPI_ValidatorsFactory* aFactory = aMgr->validators();
+
   std::list<ModelAPI_Validator*> allValidators;
   std::list<std::list<std::string> > allArguments;
   aFactory->validators(myFeature->getKind(), myAttributeID, allValidators, allArguments);
+
   QStringList aResult;
   std::list<std::string> anArgumentList = allArguments.front();
   std::list<std::string>::const_iterator it = anArgumentList.begin();