From 4a99d20021ff5986963c86529b3da492d2ce8666 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me?= Date: Mon, 12 Oct 2020 15:14:41 +0200 Subject: [PATCH] Remove STL export and Step import sources --- src/ExchangeAPI/ExchangeAPI_Export.cpp | 94 -------- src/ExchangeAPI/ExchangeAPI_Export.h | 42 +--- src/ExchangeAPI/ExchangeAPI_Import.cpp | 68 +----- src/ExchangeAPI/ExchangeAPI_Import.h | 39 +--- src/ExchangePlugin/CMakeLists.txt | 1 - .../ExchangePlugin_ExportFeature.cpp | 74 ------- .../ExchangePlugin_ExportFeature.h | 63 ------ src/ExchangePlugin/ExchangePlugin_Import.cpp | 93 ++------ src/ExchangePlugin/ExchangePlugin_Import.h | 47 ---- .../ExchangePlugin_ImportFeature.cpp | 201 +----------------- .../ExchangePlugin_ImportFeature.h | 44 ---- src/ExchangePlugin/ExchangePlugin_msg_fr.ts | 79 ------- src/ExchangePlugin/export_widget.xml | 58 ----- src/ExchangePlugin/plugin-Exchange.xml | 61 +----- src/GeomAlgoAPI/CMakeLists.txt | 5 - src/GeomAlgoAPI/GeomAlgoAPI_STEPImport.cpp | 100 +-------- src/GeomAlgoAPI/GeomAlgoAPI_STEPImport.h | 15 +- src/GeomAlgoAPI/GeomAlgoAPI_STLExport.cpp | 28 ++- src/GeomAlgoAPI/GeomAlgoAPI_STLExport.h | 11 +- src/Model/Model_Objects.cpp | 21 +- src/Model/Model_Objects.h | 10 +- src/Model/Model_ResultBody.cpp | 70 +----- src/Model/Model_ResultBody.h | 19 +- src/ModelAPI/ModelAPI_Feature.h | 5 - src/ModelAPI/ModelAPI_ResultBody.h | 17 -- src/PythonAPI/model/exchange/__init__.py | 2 +- 26 files changed, 76 insertions(+), 1191 deletions(-) diff --git a/src/ExchangeAPI/ExchangeAPI_Export.cpp b/src/ExchangeAPI/ExchangeAPI_Export.cpp index 4e9b4b9c3..000e178ab 100644 --- a/src/ExchangeAPI/ExchangeAPI_Export.cpp +++ b/src/ExchangeAPI/ExchangeAPI_Export.cpp @@ -53,51 +53,6 @@ ExchangeAPI_Export::ExchangeAPI_Export(const std::shared_ptr& apply(); // finish operation to make sure the export is done on the current state of the history } -// Constructor with values for STL of selected result export. -ExchangeAPI_Export::ExchangeAPI_Export(const std::shared_ptr& theFeature, - const std::string & theFilePath, - const ModelHighAPI_Selection& theSelectedShape, - double aDeflectionRelative, - double aDeflectionAbsolute, - const bool anIsRelative, - const bool anIsASCII) - : ModelHighAPI_Interface(theFeature) -{ - initialize(); - fillAttribute("STL", theFeature->string(ExchangePlugin_ExportFeature::EXPORT_TYPE_ID())); - fillAttribute(theFilePath, theFeature->string(ExchangePlugin_ExportFeature::STL_FILE_PATH_ID())); - - if (anIsRelative) { - fillAttribute(ExchangePlugin_ExportFeature::STL_DEFLECTION_TYPE_RELATIVE(), - theFeature->string(ExchangePlugin_ExportFeature::STL_DEFLECTION_TYPE()) ); - fillAttribute(aDeflectionRelative, - theFeature->real(ExchangePlugin_ExportFeature::STL_RELATIVE()) ); - } - else { - fillAttribute(ExchangePlugin_ExportFeature::STL_DEFLECTION_TYPE_ABSOLUTE(), - theFeature->string(ExchangePlugin_ExportFeature::STL_DEFLECTION_TYPE()) ); - fillAttribute(aDeflectionAbsolute, - theFeature->real(ExchangePlugin_ExportFeature::STL_ABSOLUTE()) ); - } - - if(anIsASCII){ - fillAttribute(ExchangePlugin_ExportFeature::STL_FILE_TYPE_ASCII(), - theFeature->string(ExchangePlugin_ExportFeature::STL_FILE_TYPE())); - } - else - { - fillAttribute(ExchangePlugin_ExportFeature::STL_FILE_TYPE_BINARY(), - theFeature->string(ExchangePlugin_ExportFeature::STL_FILE_TYPE())); - } - - fillAttribute(theSelectedShape,theFeature->selection(ExchangePlugin_ExportFeature::STL_OBJECT_SELECTED())); - fillAttribute("STL", theFeature->string(ExchangePlugin_ExportFeature::FILE_FORMAT_ID())); - execute(); - apply(); // finish operation to make sure the export is done on the current state of the history -} - - - ExchangeAPI_Export::ExchangeAPI_Export(const std::shared_ptr& theFeature, const std::string & theFilePath, const ModelHighAPI_Selection& theResult, const std::string & theAuthor, const std::string & theGeometryName) @@ -119,7 +74,6 @@ ExchangeAPI_Export::ExchangeAPI_Export(const std::shared_ptr& } - /// Constructor with values for export in other formats than XAO. ExchangeAPI_Export::ExchangeAPI_Export(const std::shared_ptr& theFeature, const std::string & theFilePath, @@ -190,33 +144,6 @@ void ExchangeAPI_Export::dump(ModelHighAPI_Dumper& theDumper) const theDumper << ", '" << theGeometryName << "'"; theDumper << ")" << std::endl; } - else if (exportType == "STL") { - std::string aTmpSTLFile = - aBase->string(ExchangePlugin_ExportFeature::STL_FILE_PATH_ID())->value(); - correctSeparators(aTmpSTLFile); - theDumper << "exportToSTL(" << aDocName << ", '" << aTmpSTLFile << "'" ; - AttributeSelectionPtr aShapeSelected = - aBase->selection(ExchangePlugin_ExportFeature::STL_OBJECT_SELECTED()); - - theDumper<<","<< aShapeSelected; - - theDumper <<","<< stlabsolute() <<","<< stlrelative(); - - if (stldeflectionType()->value() == ExchangePlugin_ExportFeature::STL_DEFLECTION_TYPE_RELATIVE()) { - theDumper <<","<< "True"; - } - else { - theDumper <<","<< "False"; - } - - if (stlfileType()->value() == ExchangePlugin_ExportFeature::STL_FILE_TYPE_BINARY()) { - theDumper << "False"; - } - else { - theDumper << "True"; - } - theDumper << ")" << std::endl; - } else { std::string aFilePath = aBase->string(ExchangePlugin_ExportFeature::FILE_PATH_ID())->value(); correctSeparators(aFilePath); @@ -252,27 +179,6 @@ ExportPtr exportToXAO(const std::shared_ptr & thePart, return ExportPtr(new ExchangeAPI_Export(aFeature, theFilePath, theAuthor, theGeometryName)); } -ExportPtr exportToSTL(const std::shared_ptr & thePart, - const std::string & theFilePath, - const ModelHighAPI_Selection& theSelectedShape, - double aDeflectionRelative, - double aDeflectionAbsolute, - const bool anIsRelative, - const bool anIsASCII) -{ - apply(); // finish previous operation to make sure all previous operations are done - std::shared_ptr aFeature = - thePart->addFeature(ExchangePlugin_ExportFeature::ID()); - - return ExportPtr(new ExchangeAPI_Export(aFeature, - theFilePath, - theSelectedShape, - aDeflectionRelative, - aDeflectionAbsolute, - anIsRelative, - anIsASCII)); -} - ExportPtr exportToXAO(const std::shared_ptr & thePart, const std::string & theFilePath, const ModelHighAPI_Selection& theSelectedShape, const std::string & /*theAuthor*/, const std::string & /*theGeometryName*/) diff --git a/src/ExchangeAPI/ExchangeAPI_Export.h b/src/ExchangeAPI/ExchangeAPI_Export.h index d867da1bf..24211c9fa 100644 --- a/src/ExchangeAPI/ExchangeAPI_Export.h +++ b/src/ExchangeAPI/ExchangeAPI_Export.h @@ -51,16 +51,6 @@ public: const std::string & theFilePath, const std::string & theAuthor = std::string(), const std::string & theGeometryName = std::string()); - - /// Constructor with values for STL of selected result export. - EXCHANGEAPI_EXPORT - explicit ExchangeAPI_Export(const std::shared_ptr& theFeature, - const std::string & theFilePath, - const ModelHighAPI_Selection& theSelectedShape, - double aDeflectionRelative , - double aDeflectionAbsolute, - const bool anIsRelative, - const bool anIsASCII); /// Constructor with values for XAO of selected result export. EXCHANGEAPI_EXPORT @@ -81,7 +71,7 @@ public: EXCHANGEAPI_EXPORT virtual ~ExchangeAPI_Export(); - INTERFACE_15(ExchangePlugin_ExportFeature::ID(), + INTERFACE_7(ExchangePlugin_ExportFeature::ID(), exportType, ExchangePlugin_ExportFeature::EXPORT_TYPE_ID(), ModelAPI_AttributeString, /** ExportType */, filePath, ExchangePlugin_ExportFeature::FILE_PATH_ID(), @@ -95,23 +85,7 @@ public: xaoAuthor, ExchangePlugin_ExportFeature::XAO_AUTHOR_ID(), ModelAPI_AttributeString, /** xao author */, xaoGeometryName, ExchangePlugin_ExportFeature::XAO_GEOMETRY_NAME_ID(), - ModelAPI_AttributeString, /** xao geometry name */, - stlFilePath, ExchangePlugin_ExportFeature::STL_FILE_PATH_ID(), - ModelAPI_AttributeString, /** stl_file_path */, - stlobjectselected, ExchangePlugin_ExportFeature::STL_OBJECT_SELECTED(), - ModelAPI_AttributeSelection, /** Object selected to export in stl file*/, - stldeflectionType, ExchangePlugin_ExportFeature::STL_DEFLECTION_TYPE(), - ModelAPI_AttributeString, /** Type of the defelection */, - stlrelative, ExchangePlugin_ExportFeature::STL_RELATIVE(), - ModelAPI_AttributeDouble, /** Relative*/, - stlabsolute, ExchangePlugin_ExportFeature::STL_ABSOLUTE(), - ModelAPI_AttributeDouble, /** Absolute */, - stlfileType, ExchangePlugin_ExportFeature::STL_FILE_TYPE(), - ModelAPI_AttributeString, /** Type of the stl file*/, - stldeflectionTypeabsolute, ExchangePlugin_ExportFeature::STL_DEFLECTION_TYPE_ABSOLUTE(), - ModelAPI_AttributeString, /** Type of the defelection */, - stldeflectionTyperelative, ExchangePlugin_ExportFeature::STL_DEFLECTION_TYPE_RELATIVE(), - ModelAPI_AttributeString, /** Type of the defelection */) + ModelAPI_AttributeString, /** xao geometry name */) /// Dump wrapped feature EXCHANGEAPI_EXPORT @@ -139,18 +113,6 @@ ExportPtr exportToXAO(const std::shared_ptr & thePart, const std::string & theAuthor = std::string(), const std::string & theGeometryName = std::string()); -/**\ingroup CPPHighAPI - * \brief Exports to STL file the result of the current document - */ -EXCHANGEAPI_EXPORT -ExportPtr exportToSTL(const std::shared_ptr & thePart, - const std::string & theFilePath, - const ModelHighAPI_Selection& theSelectedShape, - double aDeflectionRelative, - double aDeflectionAbsolute, - const bool anIsRelative, - const bool anIsASCII); - /**\ingroup CPPHighAPI * \brief Exports to XAO file the selected result with groups parts related to it only. */ diff --git a/src/ExchangeAPI/ExchangeAPI_Import.cpp b/src/ExchangeAPI/ExchangeAPI_Import.cpp index d5d7ea2a9..b1a6c832d 100644 --- a/src/ExchangeAPI/ExchangeAPI_Import.cpp +++ b/src/ExchangeAPI/ExchangeAPI_Import.cpp @@ -28,8 +28,6 @@ #include #include #include -#include - //-------------------------------------------------------------------------------------- #include @@ -49,43 +47,16 @@ ExchangeAPI_Import::ExchangeAPI_Import( setFilePath(theFilePath); } -ExchangeAPI_Import::ExchangeAPI_Import( - const std::shared_ptr & theFeature, - const std::string & theFilePath, - const bool anScalInterUnits, - const bool anMaterials, - const bool anColor) -: ModelHighAPI_Interface(theFeature) -{ - if (initialize()) - setParameters(theFilePath,anScalInterUnits,anMaterials,anColor); -} - ExchangeAPI_Import::~ExchangeAPI_Import() { } -//-------------------------------------------------------------------------------------- -void ExchangeAPI_Import::setParameters(const std::string & theFilePath, - const bool anScalInterUnits, - const bool anMaterials, - const bool anColor) -{ - fillAttribute(theFilePath, mystepfilePath); - fillAttribute("STEP", feature()->string(ExchangePlugin_ImportFeature::IMPORT_TYPE_ID())); - fillAttribute(anScalInterUnits, feature()->boolean(ExchangePlugin_ImportFeature::STEP_SCALE_INTER_UNITS_ID())); - fillAttribute(anMaterials, feature()->boolean(ExchangePlugin_ImportFeature::STEP_MATERIALS_ID())); - fillAttribute(anColor, feature()->boolean(ExchangePlugin_ImportFeature::STEP_COLORS_ID())); - execute(); -} - //-------------------------------------------------------------------------------------- void ExchangeAPI_Import::setFilePath(const std::string & theFilePath) { fillAttribute(theFilePath, myfilePath); - std::string anExtension = GeomAlgoAPI_Tools::File_Tools::extension(theFilePath); - fillAttribute(anExtension, feature()->string(ExchangePlugin_ImportFeature::IMPORT_TYPE_ID())); + execute(); } @@ -95,16 +66,7 @@ void ExchangeAPI_Import::dump(ModelHighAPI_Dumper& theDumper) const FeaturePtr aBase = feature(); std::string aPartName = theDumper.name(aBase->document()); - AttributeStringPtr aImportTypeAttr = aBase->string(ExchangePlugin_ImportFeature::IMPORT_TYPE_ID()); - std::string aFormat = aImportTypeAttr->value(); - std::string aFilePath; - if (aFormat == "STEP" || aFormat == "STP") - { - aFilePath = aBase->string(ExchangePlugin_ImportFeature::STEP_FILE_PATH_ID())->value(); - }else{ - aFilePath = aBase->string(ExchangePlugin_ImportFeature::FILE_PATH_ID())->value(); - } - + std::string aFilePath = aBase->string(ExchangePlugin_ImportFeature::FILE_PATH_ID())->value(); std::string aFrom = "\\"; std::string aTo = "\\\\"; for(std::size_t aPos = aFilePath.find(aFrom); @@ -113,19 +75,9 @@ void ExchangeAPI_Import::dump(ModelHighAPI_Dumper& theDumper) const aFilePath.replace(aPos, aFrom.size(), aTo); aPos += aTo.size(); } - std::string anExtension = GeomAlgoAPI_Tools::File_Tools::extension(aFilePath); - if( anExtension == "STP" || anExtension == "STEP"){ - theDumper << aBase << " = model.addImportStep(" << aPartName << ", \"" - << aFilePath << "\"" ; - - theDumper << ", " << scalinterunits()->value() - << ", " << materials()->value() - << ", " << colors()->value() << ")"<< std::endl; - }else{ - theDumper << aBase << " = model.addImport(" << aPartName << ", \"" - << aFilePath << "\")" << std::endl; - } + theDumper << aBase << " = model.addImport(" << aPartName << ", \"" + << aFilePath << "\")" << std::endl; // to make import have results theDumper << "model.do()" << std::endl; @@ -150,18 +102,6 @@ ImportPtr addImport( return ImportPtr(new ExchangeAPI_Import(aFeature, theFilePath)); } -ImportPtr addImportStep( - const std::shared_ptr & thePart, - const std::string & theFilePath, - const bool anScalInterUnits, - const bool anMaterials, - const bool anColor ) -{ - std::shared_ptr aFeature = thePart->addFeature(ExchangeAPI_Import::ID()); - return ImportPtr(new ExchangeAPI_Import(aFeature, theFilePath, - anScalInterUnits, anMaterials, anColor)); -} - void importPart(const std::shared_ptr & thePart, const std::string & theFilePath, const ModelHighAPI_Reference & theAfterThis) diff --git a/src/ExchangeAPI/ExchangeAPI_Import.h b/src/ExchangeAPI/ExchangeAPI_Import.h index d95a45389..f38db9bbb 100644 --- a/src/ExchangeAPI/ExchangeAPI_Import.h +++ b/src/ExchangeAPI/ExchangeAPI_Import.h @@ -46,43 +46,18 @@ public: EXCHANGEAPI_EXPORT ExchangeAPI_Import(const std::shared_ptr & theFeature, const std::string & theFilePath); - - /// Constructor with values for Step file - EXCHANGEAPI_EXPORT - ExchangeAPI_Import(const std::shared_ptr & theFeature, - const std::string & theFilePath, - const bool anScalInterUnits, - const bool anMaterials, - const bool anColor); - /// Destructor EXCHANGEAPI_EXPORT virtual ~ExchangeAPI_Import(); - INTERFACE_6(ExchangePlugin_ImportFeature::ID(), + INTERFACE_1(ExchangePlugin_ImportFeature::ID(), filePath, ExchangePlugin_ImportFeature::FILE_PATH_ID(), - ModelAPI_AttributeString, /** File path */, - stepimporttype, ExchangePlugin_ImportFeature::IMPORT_TYPE_ID(), - ModelAPI_AttributeString, /**import type */, - stepfilePath, ExchangePlugin_ImportFeature::STEP_FILE_PATH_ID(), - ModelAPI_AttributeString, /**step File path */, - scalinterunits, ExchangePlugin_ImportFeature::STEP_SCALE_INTER_UNITS_ID(), - ModelAPI_AttributeBoolean, /** Scale internationals units */, - materials, ExchangePlugin_ImportFeature::STEP_MATERIALS_ID(), - ModelAPI_AttributeBoolean, /** Materials */, - colors, ExchangePlugin_ImportFeature::STEP_COLORS_ID(), - ModelAPI_AttributeBoolean, /** Colors */ + ModelAPI_AttributeString, /** File path */ ) /// Set point values EXCHANGEAPI_EXPORT void setFilePath(const std::string & theFilePath); - - EXCHANGEAPI_EXPORT - void setParameters(const std::string & theFilePath, - const bool anScalInterUnits, - const bool anMaterials, - const bool anColor); /// Dump wrapped feature EXCHANGEAPI_EXPORT @@ -99,16 +74,6 @@ EXCHANGEAPI_EXPORT ImportPtr addImport(const std::shared_ptr & thePart, const std::string & theFilePath); -/**\ingroup CPPHighAPI - * \brief Create Import Step feature - */ -EXCHANGEAPI_EXPORT -ImportPtr addImportStep(const std::shared_ptr & thePart, - const std::string & theFilePath, - const bool anScalInterUnits, - const bool anMaterials, - const bool anColor); - /** \ingroup CPPHighAPI * \brief Import features from the file to the document after the current feature (or to the end). */ diff --git a/src/ExchangePlugin/CMakeLists.txt b/src/ExchangePlugin/CMakeLists.txt index 3df98bece..67880c8e6 100644 --- a/src/ExchangePlugin/CMakeLists.txt +++ b/src/ExchangePlugin/CMakeLists.txt @@ -31,7 +31,6 @@ INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/src/Events ${PROJECT_SOURCE_DIR}/src/XAO ${PROJECT_SOURCE_DIR}/src/ConstructionPlugin ${PROJECT_SOURCE_DIR}/src/PartSetPlugin - ${OpenCASCADE_INCLUDE_DIR} ) SET(PROJECT_HEADERS diff --git a/src/ExchangePlugin/ExchangePlugin_ExportFeature.cpp b/src/ExchangePlugin/ExchangePlugin_ExportFeature.cpp index 6a8f36cb1..d898a08e5 100644 --- a/src/ExchangePlugin/ExchangePlugin_ExportFeature.cpp +++ b/src/ExchangePlugin/ExchangePlugin_ExportFeature.cpp @@ -27,7 +27,6 @@ #include #endif - #include #include @@ -35,7 +34,6 @@ #include #include #include -#include #include #include @@ -50,7 +48,6 @@ #include #include #include -#include #include #include #include @@ -71,8 +68,6 @@ #include -#include - ExchangePlugin_ExportFeature::ExchangePlugin_ExportFeature() { } @@ -103,27 +98,9 @@ void ExchangePlugin_ExportFeature::initAttributes() ModelAPI_AttributeString::typeId()); data()->addAttribute(ExchangePlugin_ExportFeature::XAO_SELECTION_LIST_ID(), ModelAPI_AttributeSelectionList::typeId()); - data()->addAttribute(ExchangePlugin_ExportFeature::STL_FILE_PATH_ID(), - ModelAPI_AttributeString::typeId()); - data()->addAttribute(ExchangePlugin_ExportFeature::STL_OBJECT_SELECTED(), - ModelAPI_AttributeSelection::typeId()); - data()->addAttribute(ExchangePlugin_ExportFeature::STL_DEFLECTION_TYPE(), - ModelAPI_AttributeString::typeId()); - data()->addAttribute(ExchangePlugin_ExportFeature::STL_RELATIVE(), - ModelAPI_AttributeDouble::typeId()); - - double defelection = Config_PropManager::real("Visualization", "body_deflection"); - real(ExchangePlugin_ExportFeature::STL_RELATIVE())->setValue(defelection); - - data()->addAttribute(ExchangePlugin_ExportFeature::STL_ABSOLUTE(), - ModelAPI_AttributeDouble::typeId()); - data()->addAttribute(ExchangePlugin_ExportFeature::STL_FILE_TYPE(), - ModelAPI_AttributeString::typeId()); ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), ExchangePlugin_ExportFeature::XAO_FILE_PATH_ID()); - ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), - ExchangePlugin_ExportFeature::STL_FILE_PATH_ID()); ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), ExchangePlugin_ExportFeature::XAO_AUTHOR_ID()); ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), @@ -151,11 +128,6 @@ void ExchangePlugin_ExportFeature::attributeChanged(const std::string& theID) string(ExchangePlugin_ExportFeature::FILE_PATH_ID())->setValue( string(ExchangePlugin_ExportFeature::XAO_FILE_PATH_ID())->value()); } - else if (theID == STL_FILE_PATH_ID()) { - string(ExchangePlugin_ExportFeature::FILE_PATH_ID())->setValue( - string(ExchangePlugin_ExportFeature::STL_FILE_PATH_ID())->value()); - } - } /* @@ -198,9 +170,6 @@ void ExchangePlugin_ExportFeature::exportFile(const std::string& theFileName, if (aFormatName == "XAO") { exportXAO(theFileName); return; - }else if (aFormatName == "STL") { - exportSTL(theFileName); - return; } // make shape for export from selected shapes @@ -347,49 +316,6 @@ static bool isInResults(AttributeSelectionListPtr theSelection, return false; } -void ExchangePlugin_ExportFeature::exportSTL(const std::string& theFileName) -{ - // Get shape. - AttributeSelectionPtr aSelection = selection(STL_OBJECT_SELECTED()); - GeomShapePtr aShape = aSelection->value(); - if (!aShape.get()) { - aShape = aSelection->context()->shape(); - } - - // Get relative value and percent flag. - double aValue; - bool anIsRelative = false; - bool anIsASCII = false; - - if (string(STL_DEFLECTION_TYPE())->value() == STL_DEFLECTION_TYPE_RELATIVE()) { - aValue = real(STL_RELATIVE())->value(); - anIsRelative = true; - } else { - aValue = real(STL_ABSOLUTE())->value(); - } - - if (string(STL_FILE_TYPE())->value() == STL_FILE_TYPE_ASCII()) { - anIsASCII = true; - } - // Perform the export - std::string anError; - bool aResult = false; - - aResult = STLExport(theFileName, - "STL", - aShape, - aValue, - anIsRelative, - anIsASCII, - anError); - - if (!aResult || !anError.empty()) { - setError("An error occurred while exporting " + theFileName + ": " + anError); - return; - } -} - - void ExchangePlugin_ExportFeature::exportXAO(const std::string& theFileName) { try { diff --git a/src/ExchangePlugin/ExchangePlugin_ExportFeature.h b/src/ExchangePlugin/ExchangePlugin_ExportFeature.h index bc975ea5b..1067d99af 100644 --- a/src/ExchangePlugin/ExchangePlugin_ExportFeature.h +++ b/src/ExchangePlugin/ExchangePlugin_ExportFeature.h @@ -60,66 +60,6 @@ public: static const std::string MY_XAO_FILE_PATH_ID("xao_file_path"); return MY_XAO_FILE_PATH_ID; } - /// attribute name of stl file path - inline static const std::string& STL_FILE_PATH_ID() - { - static const std::string MY_STL_FILE_PATH_ID("stl_file_path"); - return MY_STL_FILE_PATH_ID; - } - /// Attribute name for selected object to export in stl file path. - inline static const std::string& STL_OBJECT_SELECTED() - { - static const std::string ATTR_ID("stl_object_selected"); - return ATTR_ID; - } - /// Attribute name for deflection type. - inline static const std::string& STL_DEFLECTION_TYPE() - { - static const std::string ATTR_ID("stl_deflection_type"); - return ATTR_ID; - } - /// Attribute name for deflection type relative. - inline static const std::string& STL_DEFLECTION_TYPE_RELATIVE() - { - static const std::string ATTR_ID("stl_deflection_type_relative"); - return ATTR_ID; - } - /// Attribute name for deflection type absolute. - inline static const std::string& STL_DEFLECTION_TYPE_ABSOLUTE() - { - static const std::string ATTR_ID("stl_deflection_type_absolute"); - return ATTR_ID; - } - /// Attribute name for relative. - inline static const std::string& STL_RELATIVE() - { - static const std::string ATTR_ID("stl_relative"); - return ATTR_ID; - } - /// Attribute name for absolute. - inline static const std::string& STL_ABSOLUTE() - { - static const std::string ATTR_ID("stl_absolute"); - return ATTR_ID; - } - /// Attribute name for stl file type. - inline static const std::string& STL_FILE_TYPE() - { - static const std::string ATTR_ID("stl_file_type"); - return ATTR_ID; - } - /// Attribute name for stl file type ascii. - inline static const std::string& STL_FILE_TYPE_ASCII() - { - static const std::string ATTR_ID("stl_file_type_acii"); - return ATTR_ID; - } - /// Attribute name for stl file type binary. - inline static const std::string& STL_FILE_TYPE_BINARY() - { - static const std::string ATTR_ID("stl_file_type_binary"); - return ATTR_ID; - } /// attribute name of file format inline static const std::string& FILE_FORMAT_ID() { @@ -189,9 +129,6 @@ protected: /// Performs export to XAO file EXCHANGEPLUGIN_EXPORT void exportXAO(const std::string& theFileName); - - /// Performs export to STL file - EXCHANGEPLUGIN_EXPORT void exportSTL(const std::string& theFileName); }; #endif /* EXPORT_EXPORTFEATURE_H_ */ diff --git a/src/ExchangePlugin/ExchangePlugin_Import.cpp b/src/ExchangePlugin/ExchangePlugin_Import.cpp index 304d456d5..b5a51ff08 100644 --- a/src/ExchangePlugin/ExchangePlugin_Import.cpp +++ b/src/ExchangePlugin/ExchangePlugin_Import.cpp @@ -27,7 +27,6 @@ #include #include #include -#include #include #include #include @@ -82,15 +81,8 @@ ExchangePlugin_Import::~ExchangePlugin_Import() void ExchangePlugin_Import::initAttributes() { data()->addAttribute(FILE_PATH_ID(), ModelAPI_AttributeString::typeId()); - data()->addAttribute(STEP_FILE_PATH_ID(), ModelAPI_AttributeString::typeId()); - data()->addAttribute(IMPORT_TYPE_ID(), ModelAPI_AttributeString::typeId()); data()->addAttribute(TARGET_PART_ID(), ModelAPI_AttributeInteger::typeId()); data()->addAttribute(TARGET_PARTS_LIST_ID(), ModelAPI_AttributeStringArray::typeId()); - data()->addAttribute(STEP_TARGET_PART_ID(), ModelAPI_AttributeInteger::typeId()); - data()->addAttribute(STEP_TARGET_PARTS_LIST_ID(), ModelAPI_AttributeStringArray::typeId()); - data()->addAttribute(STEP_MATERIALS_ID(), ModelAPI_AttributeBoolean::typeId()); - data()->addAttribute(STEP_COLORS_ID(), ModelAPI_AttributeBoolean::typeId()); - data()->addAttribute(STEP_SCALE_INTER_UNITS_ID(), ModelAPI_AttributeBoolean::typeId()); } /* @@ -98,61 +90,26 @@ void ExchangePlugin_Import::initAttributes() */ void ExchangePlugin_Import::execute() { - AttributeStringPtr aFormatAttr = - this->string(ExchangePlugin_Import::IMPORT_TYPE_ID()); - std::string aFormat = aFormatAttr->value(); - - AttributeStringPtr aFilePathAttr; - std::string aFilePath; - AttributeStringArrayPtr aPartsAttr; - AttributeIntegerPtr aTargetAttr; - if (aFormat == "STEP" || aFormat == "STP") - { - aFilePathAttr = string(ExchangePlugin_Import::STEP_FILE_PATH_ID()); - aFilePath = aFilePathAttr->value(); - // get the document where to import - aPartsAttr = stringArray(STEP_TARGET_PARTS_LIST_ID()); - aTargetAttr = integer(STEP_TARGET_PART_ID()); - }else{ - aFilePathAttr = string(ExchangePlugin_Import::FILE_PATH_ID()); - aFilePath = aFilePathAttr->value(); - // get the document where to import - aPartsAttr = stringArray(TARGET_PARTS_LIST_ID()); - aTargetAttr = integer(TARGET_PART_ID()); - } - + AttributeStringPtr aFilePathAttr = string(ExchangePlugin_Import::FILE_PATH_ID()); + std::string aFilePath = aFilePathAttr->value(); if (aFilePath.empty()) { - setError("File path is empty."); - return; + setError("File path is empty."); + return; } + + // get the document where to import + AttributeStringArrayPtr aPartsAttr = stringArray(TARGET_PARTS_LIST_ID()); + AttributeIntegerPtr aTargetAttr = integer(TARGET_PART_ID()); SessionPtr aSession = ModelAPI_Session::get(); - DocumentPtr aDoc = findDocument(aSession->moduleDocument(), + DocumentPtr aDoc = + findDocument(aSession->moduleDocument(), Locale::Convert::toWString(aPartsAttr->value(aTargetAttr->value()))); if (aDoc.get()) { FeaturePtr aImportFeature = aDoc->addFeature(ExchangePlugin_ImportFeature::ID()); DataPtr aData = aImportFeature->data(); - AttributeStringPtr aPathAttr; - if (aFormat == "STEP" || aFormat == "STP") - { - aPathAttr = aData->string(ExchangePlugin_ImportFeature::STEP_FILE_PATH_ID()); - }else - { - aPathAttr = aData->string(ExchangePlugin_ImportFeature::FILE_PATH_ID()); - } - - AttributeStringPtr aImportTypeAttr = aData->string(ExchangePlugin_ImportFeature::IMPORT_TYPE_ID()); - - aData->boolean(ExchangePlugin_ImportFeature::STEP_MATERIALS_ID()) - ->setValue(boolean(ExchangePlugin_Import::STEP_MATERIALS_ID())->value()); - aData->boolean(ExchangePlugin_ImportFeature::STEP_COLORS_ID()) - ->setValue(boolean(ExchangePlugin_Import::STEP_COLORS_ID())->value()); - aData->boolean(ExchangePlugin_ImportFeature::STEP_SCALE_INTER_UNITS_ID()) - ->setValue(boolean(ExchangePlugin_Import::STEP_SCALE_INTER_UNITS_ID())->value()); - + AttributeStringPtr aPathAttr = aData->string(ExchangePlugin_ImportFeature::FILE_PATH_ID()); aPathAttr->setValue(aFilePathAttr->value()); - aImportTypeAttr->setValue(aFormat); - aImportFeature->execute(); } } @@ -160,31 +117,14 @@ void ExchangePlugin_Import::execute() void ExchangePlugin_Import::attributeChanged(const std::string& theID) { - AttributeStringPtr aFilePathAttr; - AttributeStringArrayPtr aPartsAttr; - AttributeIntegerPtr aTargetAttr; - - if (theID == FILE_PATH_ID() ||theID == STEP_FILE_PATH_ID() ) { - aFilePathAttr = string(FILE_PATH_ID()); - if (theID == FILE_PATH_ID() && aFilePathAttr->value().empty()) + if (theID == FILE_PATH_ID()) { + AttributeStringPtr aFilePathAttr = string(FILE_PATH_ID()); + if (aFilePathAttr->value().empty()) return; - aPartsAttr = stringArray(TARGET_PARTS_LIST_ID()); - aTargetAttr = integer(TARGET_PART_ID()); - - updatePart(aPartsAttr, aTargetAttr); - aFilePathAttr = string(STEP_FILE_PATH_ID()); - if (theID == STEP_FILE_PATH_ID() && aFilePathAttr->value().empty()) - return; + AttributeStringArrayPtr aPartsAttr = stringArray(TARGET_PARTS_LIST_ID()); + AttributeIntegerPtr aTargetAttr = integer(TARGET_PART_ID()); - aPartsAttr = stringArray(STEP_TARGET_PARTS_LIST_ID()); - aTargetAttr = integer(STEP_TARGET_PART_ID()); - updatePart(aPartsAttr, aTargetAttr); - } -} - -void ExchangePlugin_Import::updatePart(AttributeStringArrayPtr &aPartsAttr, AttributeIntegerPtr &aTargetAttr) -{ // update the list of target parts SessionPtr aSession = ModelAPI_Session::get(); DocumentPtr aDoc = document(); @@ -219,4 +159,5 @@ void ExchangePlugin_Import::updatePart(AttributeStringArrayPtr &aPartsAttr, Attr aTargetAttr->setValue(0); } } + } } diff --git a/src/ExchangePlugin/ExchangePlugin_Import.h b/src/ExchangePlugin/ExchangePlugin_Import.h index 38d3e05e7..c09b3ebab 100644 --- a/src/ExchangePlugin/ExchangePlugin_Import.h +++ b/src/ExchangePlugin/ExchangePlugin_Import.h @@ -24,8 +24,6 @@ #include #include -#include -#include #include @@ -45,12 +43,6 @@ class ExchangePlugin_Import : public ModelAPI_Feature static const std::string MY_IMPORT_ID("ImportMacro"); return MY_IMPORT_ID; } - /// Feature kind - inline static const std::string& IMPORT_TYPE_ID() - { - static const std::string MY_IMPORT_TYPE_ID("ImportType"); - return MY_IMPORT_TYPE_ID; - } /// attribute name of file path inline static const std::string& FILE_PATH_ID() { @@ -69,42 +61,6 @@ class ExchangePlugin_Import : public ModelAPI_Feature static const std::string MY_TARGET_PARTS_LIST_ID("target_parts_list"); return MY_TARGET_PARTS_LIST_ID; } - /// attribute name of step file path - inline static const std::string& STEP_FILE_PATH_ID() - { - static const std::string MY_STEP_FILE_PATH_ID("step_file_path"); - return MY_STEP_FILE_PATH_ID; - } - /// attribute name of step target part - inline static const std::string& STEP_TARGET_PART_ID() - { - static const std::string MY_STEP_TARGET_PART_ID("step_target_part"); - return MY_STEP_TARGET_PART_ID; - } - /// attribute name of list ofstep target parts - inline static const std::string& STEP_TARGET_PARTS_LIST_ID() - { - static const std::string MY_STEP_TARGET_PARTS_LIST_ID("step_target_parts_list"); - return MY_STEP_TARGET_PARTS_LIST_ID; - } - /// attribute name of step Scale to International System Units - inline static const std::string& STEP_SCALE_INTER_UNITS_ID() - { - static const std::string MY_STEP_SCALE_INTER_UNITS_ID("step_scale_inter_units"); - return MY_STEP_SCALE_INTER_UNITS_ID; - } - /// attribute name of step materiels - inline static const std::string& STEP_MATERIALS_ID() - { - static const std::string MY_STEP_MATERIALS_ID("step_materials"); - return MY_STEP_MATERIALS_ID; - } - /// attribute name of step colors - inline static const std::string& STEP_COLORS_ID() - { - static const std::string MY_STEP_COLORS_ID("step_colours"); - return MY_STEP_COLORS_ID; - } /// Default constructor EXCHANGEPLUGIN_EXPORT ExchangePlugin_Import(); /// Default destructor @@ -123,9 +79,6 @@ class ExchangePlugin_Import : public ModelAPI_Feature /// \param theID identifier of changed attribute EXCHANGEPLUGIN_EXPORT virtual void attributeChanged(const std::string& theID); - EXCHANGEPLUGIN_EXPORT - void updatePart(AttributeStringArrayPtr &aPartsAttr, AttributeIntegerPtr &aTargetAttr); - /// Computes or recomputes the results EXCHANGEPLUGIN_EXPORT virtual void execute(); diff --git a/src/ExchangePlugin/ExchangePlugin_ImportFeature.cpp b/src/ExchangePlugin/ExchangePlugin_ImportFeature.cpp index 402b660e9..ade0a3115 100644 --- a/src/ExchangePlugin/ExchangePlugin_ImportFeature.cpp +++ b/src/ExchangePlugin/ExchangePlugin_ImportFeature.cpp @@ -32,7 +32,6 @@ #include #include -#include #include #include @@ -43,8 +42,6 @@ #include #include #include -#include -#include #include #include #include @@ -63,10 +60,6 @@ #include -#include -#include - - ExchangePlugin_ImportFeature::ExchangePlugin_ImportFeature() { } @@ -84,16 +77,10 @@ void ExchangePlugin_ImportFeature::initAttributes() data()->addAttribute(ExchangePlugin_ImportFeature::FILE_PATH_ID(), ModelAPI_AttributeString::typeId()); AttributePtr aFeaturesAttribute = - data()->addAttribute(ExchangePlugin_ImportFeature::FEATURES_ID(), + data()->addAttribute(ExchangePlugin_ImportFeature::FEATURES_ID(), ModelAPI_AttributeRefList::typeId()); - data()->addAttribute(STEP_FILE_PATH_ID(), ModelAPI_AttributeString::typeId()); - data()->addAttribute(IMPORT_TYPE_ID(), ModelAPI_AttributeString::typeId()); - data()->addAttribute(STEP_MATERIALS_ID(), ModelAPI_AttributeBoolean::typeId()); - data()->addAttribute(STEP_COLORS_ID(), ModelAPI_AttributeBoolean::typeId()); - data()->addAttribute(STEP_SCALE_INTER_UNITS_ID(), ModelAPI_AttributeBoolean::typeId()); - aFeaturesAttribute->setIsArgument(false); - + ModelAPI_Session::get()->validators()->registerNotObligatory( getKind(), ExchangePlugin_ImportFeature::FEATURES_ID()); } @@ -103,15 +90,7 @@ void ExchangePlugin_ImportFeature::initAttributes() */ void ExchangePlugin_ImportFeature::execute() { - AttributeStringPtr aImportTypeAttr = string(ExchangePlugin_ImportFeature::IMPORT_TYPE_ID()); - std::string aFormat = aImportTypeAttr->value(); - AttributeStringPtr aFilePathAttr; - if (aFormat == "STEP" || aFormat == "STP") - { - aFilePathAttr = string(ExchangePlugin_ImportFeature::STEP_FILE_PATH_ID()); - }else{ - aFilePathAttr = string(ExchangePlugin_ImportFeature::FILE_PATH_ID()); - } + AttributeStringPtr aFilePathAttr = string(ExchangePlugin_ImportFeature::FILE_PATH_ID()); std::string aFilePath = aFilePathAttr->value(); if (aFilePath.empty()) { setError("File path is empty."); @@ -122,7 +101,7 @@ void ExchangePlugin_ImportFeature::execute() } std::shared_ptr ExchangePlugin_ImportFeature::createResultBody( - std::shared_ptr aGeomShape) + std::shared_ptr aGeomShape) { std::shared_ptr aResultBody = document()->createBody(data()); //LoadNamingDS of the imported shape @@ -143,47 +122,10 @@ void ExchangePlugin_ImportFeature::importFile(const std::string& theFileName) // Perform the import std::string anError; std::shared_ptr aGeomShape; - - std::map< std::wstring, std::list> theMaterialShape; - - std::string anObjectName = GeomAlgoAPI_Tools::File_Tools::name(theFileName); - data()->setName(Locale::Convert::toWString(anObjectName)); - - ResultBodyPtr result = document()->createBody(data()); - - bool anColorGroupSelected = boolean(ExchangePlugin_ImportFeature::STEP_COLORS_ID())->value(); - bool anMaterialsGroupSelected = boolean(ExchangePlugin_ImportFeature::STEP_MATERIALS_ID())->value(); - if (anExtension == "BREP" || anExtension == "BRP") { aGeomShape = BREPImport(theFileName, anExtension, anError); } else if (anExtension == "STEP" || anExtension == "STP") { - bool anScalInterUnits = boolean(ExchangePlugin_ImportFeature::STEP_SCALE_INTER_UNITS_ID())->value(); - - - try{ - - result->clearShapeNameAndColor(); - // Process groups/fields - std::shared_ptr aRefListOfGroups = - std::dynamic_pointer_cast(data()->attribute(FEATURES_ID())); - - // Remove previous groups/fields stored in RefList - std::list anGroupList = aRefListOfGroups->list(); - std::list::iterator anGroupIt = anGroupList.begin(); - for (; anGroupIt != anGroupList.end(); ++anGroupIt) { - std::shared_ptr aFeature = ModelAPI_Feature::feature(*anGroupIt); - if (aFeature) - document()->removeFeature(aFeature); - } - - aGeomShape = STEPImportAttributs(theFileName, result, anScalInterUnits, - anMaterialsGroupSelected, anColorGroupSelected,theMaterialShape,anError); - - } - catch (OSD_Exception& e) { - //Try to load STEP file without colors... - aGeomShape = STEPImport(theFileName, anExtension,anScalInterUnits,anError); - } + aGeomShape = STEPImport(theFileName, anExtension, anError); } else if (anExtension == "IGES" || anExtension == "IGS") { aGeomShape = IGESImport(theFileName, anExtension, anError); } else { @@ -197,138 +139,12 @@ void ExchangePlugin_ImportFeature::importFile(const std::string& theFileName) } // Pass the results into the model + std::string anObjectName = GeomAlgoAPI_Tools::File_Tools::name(theFileName); + data()->setName(Locale::Convert::toWString(anObjectName)); - loadNamingDS(aGeomShape, result); - - // create color group - if (anColorGroupSelected) - { - setColorGroups(result); - } - - // create Materiel group - if (anMaterialsGroupSelected){ - setMaterielGroup(result,theMaterialShape); - } - - setResult(result); - -} - -void ExchangePlugin_ImportFeature::setColorGroups(std::shared_ptr theResultBody) -{ - std::vector aColor; - int indice = 1; - std::list< std::vector > aColorsRead; - - - ModelAPI_Tools::getColor(theResultBody, aColor); - if (!aColor.empty() ){ - std::wstringstream colorName; - colorName< allRes; - ModelAPI_Tools::allSubs(theResultBody, allRes); - for(std::list::iterator aRes = allRes.begin(); aRes != allRes.end(); ++aRes) { - ModelAPI_Tools::getColor(*aRes, aColor); - if (!aColor.empty() ){ - auto it = std::find(aColorsRead.begin(), aColorsRead.end(), aColor); - if ( it == aColorsRead.end() ){ - std::wstringstream colorName; - colorName< theResultBody, - std::vector &theColor, - const std::wstring& theName ) -{ - std::vector aColor; - std::shared_ptr aGroupFeature = addFeature("Group"); - - // group name - aGroupFeature->data()->setName(theName); - - // fill selection - AttributeSelectionListPtr aSelectionList = aGroupFeature->selectionList("group_list"); - - ModelAPI_Tools::getColor(theResultBody, aColor); - if (!aColor.empty() ){ - if( aColor == theColor ) { - GeomShapePtr aShape = theResultBody->shape(); - aSelectionList->setSelectionType(aShape->shapeTypeStr() ); - aSelectionList->append(theResultBody,aShape); - } - } - // add element with the same color - std::list allRes; - ModelAPI_Tools::allSubs(theResultBody, allRes); - for(std::list::iterator aRes = allRes.begin(); - aRes != allRes.end(); ++aRes) { - ModelAPI_Tools::getColor(*aRes, aColor); - GeomShapePtr aShape = (*aRes)->shape(); - - if (!aColor.empty() ){ - if( aRes->get() && aColor == theColor ) { - aSelectionList->setSelectionType(aShape->shapeTypeStr() ); - aSelectionList->append(theResultBody,aShape); - } - } - } - - if (aSelectionList->size() == 0 ){ - document()->removeFeature(aGroupFeature); - } + setResult(createResultBody(aGeomShape)); } -void ExchangePlugin_ImportFeature::setMaterielGroup(std::shared_ptr theResultBody, - std::map< std::wstring, std::list> &theMaterialShape) -{ - int indice = 1; - std::map< std::wstring, std::list>::iterator it; - for( it = theMaterialShape.begin(); it != theMaterialShape.end(); ++it) { - - std::shared_ptr aGroupFeature = addFeature("Group"); - // group name - aGroupFeature->data()->setName((*it).first); - - // fill selection - AttributeSelectionListPtr aSelectionList = aGroupFeature->selectionList("group_list"); - std::string aSelectionType = "solid" ; - aSelectionList->setSelectionType(aSelectionType); - GeomShapePtr aShape = theResultBody->shape(); - - std::list allRes; - ModelAPI_Tools::allSubs(theResultBody, allRes); - for(std::list::iterator aRes = allRes.begin(); aRes != allRes.end(); ++aRes) { - - GeomShapePtr aShape = (*aRes)->shape(); - for(std::list::iterator aResMat = it->second.begin(); - aResMat != it->second.end(); ++aResMat) { - if( aRes->get() && ((*aRes)->data()->name() == (*aResMat))) - { - aSelectionList->append(theResultBody,aShape); - break; - } - } - } - if (aSelectionList->size() == 0){ - document()->removeFeature(aGroupFeature); - } - } -} - - - void ExchangePlugin_ImportFeature::importXAO(const std::string& theFileName) { try { @@ -599,6 +415,7 @@ void ExchangePlugin_ImportFeature::loadNamingDS( { //load result theResultBody->store(theGeomShape); + std::string aNameMS = "Shape"; theResultBody->loadFirstLevel(theGeomShape, aNameMS); } diff --git a/src/ExchangePlugin/ExchangePlugin_ImportFeature.h b/src/ExchangePlugin/ExchangePlugin_ImportFeature.h index 2875d83ab..c087af2ab 100644 --- a/src/ExchangePlugin/ExchangePlugin_ImportFeature.h +++ b/src/ExchangePlugin/ExchangePlugin_ImportFeature.h @@ -24,7 +24,6 @@ #include #include -#include #include @@ -44,48 +43,18 @@ class ExchangePlugin_ImportFeature : public ModelAPI_CompositeFeature static const std::string MY_IMPORT_ID("Import"); return MY_IMPORT_ID; } - /// Feature kind - inline static const std::string& IMPORT_TYPE_ID() - { - static const std::string MY_IMPORT_TYPE_ID("ImportType"); - return MY_IMPORT_TYPE_ID; - } /// attribute name of file path inline static const std::string& FILE_PATH_ID() { static const std::string MY_FILE_PATH_ID("file_path"); return MY_FILE_PATH_ID; } - /// attribute name of file path - inline static const std::string& STEP_FILE_PATH_ID() - { - static const std::string MY_STEP_FILE_PATH_ID("step_file_path"); - return MY_STEP_FILE_PATH_ID; - } /// All features (list of references) inline static const std::string& FEATURES_ID() { static const std::string MY_FEATURES_ID("Features"); return MY_FEATURES_ID; } - /// attribute name of step Scale to International System Units - inline static const std::string& STEP_SCALE_INTER_UNITS_ID() - { - static const std::string MY_STEP_SCALE_INTER_UNITS_ID("step_scale_inter_units"); - return MY_STEP_SCALE_INTER_UNITS_ID; - } - /// attribute name of step materiels - inline static const std::string& STEP_MATERIALS_ID() - { - static const std::string MY_STEP_MATERIALS_ID("step_materials"); - return MY_STEP_MATERIALS_ID; - } - /// attribute name of step colors - inline static const std::string& STEP_COLORS_ID() - { - static const std::string MY_STEP_COLORS_ID("step_colours"); - return MY_STEP_COLORS_ID; - } /// Default constructor EXCHANGEPLUGIN_EXPORT ExchangePlugin_ImportFeature(); /// Default destructor @@ -139,19 +108,6 @@ private: /// Loads Naming data structure to the document void loadNamingDS(std::shared_ptr theGeomShape, std::shared_ptr theResultBody); - - // Set groups of color - void setColorGroups(std::shared_ptr theResultBody); - - // set a group of color - void setColorGroup(std::shared_ptr theResultBody, - std::vector &aColor, - const std::wstring& theName ); - - // set Materiel group of color - void setMaterielGroup(std::shared_ptr theResultBody, - std::map< std::wstring, std::list> &theMaterialShape); - }; #endif /* IMPORT_IMPORTFEATURE_H_ */ diff --git a/src/ExchangePlugin/ExchangePlugin_msg_fr.ts b/src/ExchangePlugin/ExchangePlugin_msg_fr.ts index 110053a1d..3e4061b1e 100644 --- a/src/ExchangePlugin/ExchangePlugin_msg_fr.ts +++ b/src/ExchangePlugin/ExchangePlugin_msg_fr.ts @@ -134,10 +134,6 @@ XAO XAO - - STL - STL - Export:file_path @@ -197,81 +193,6 @@ Veuillez saisir le nom de la géométrie - - Export:stl_file_path - - Export file - Fichier d'export - - - - Export:stl_file_path:ExchangePlugin_ExportFormat - - %1 is not initialized. - %1 n'est pas initialisé. - - - File name is empty. - Le nom du fichier est vide. - - - - Export:stl_object_selected - - Object - Objet - - - Object to export. - Objet à exporter. - - - - Export:stl_file_type - - File type - type du fichier - - - Binary - Binaire - - - ASCII - ASCII - - - - Export:Deflection - - Deflection - Déflection - - - Relative - Relative - - - Relative value. - Valeur relative - - - Calculate by size of shape - Calcul par rapport à la taille de la shape - - - Absolute - Absolue - - - Value indicate by user - Valeur indiquée par l'utilisateur - - - Absolute value. - Valeur absolue. - - diff --git a/src/ExchangePlugin/export_widget.xml b/src/ExchangePlugin/export_widget.xml index d77786ee5..9e134b805 100644 --- a/src/ExchangePlugin/export_widget.xml +++ b/src/ExchangePlugin/export_widget.xml @@ -31,63 +31,5 @@ placeholder="Please input the geometry name"> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/ExchangePlugin/plugin-Exchange.xml b/src/ExchangePlugin/plugin-Exchange.xml index 275ceb69b..7f240ba69 100644 --- a/src/ExchangePlugin/plugin-Exchange.xml +++ b/src/ExchangePlugin/plugin-Exchange.xml @@ -4,70 +4,19 @@ - - - - - + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + diff --git a/src/GeomAlgoAPI/CMakeLists.txt b/src/GeomAlgoAPI/CMakeLists.txt index a03ae213f..95e749c10 100644 --- a/src/GeomAlgoAPI/CMakeLists.txt +++ b/src/GeomAlgoAPI/CMakeLists.txt @@ -45,11 +45,9 @@ SET(PROJECT_HEADERS GeomAlgoAPI_Placement.h GeomAlgoAPI_BREPImport.h GeomAlgoAPI_STEPImport.h - GeomAlgoAPI_STEPImportXCAF.h GeomAlgoAPI_IGESImport.h GeomAlgoAPI_BREPExport.h GeomAlgoAPI_STEPExport.h - GeomAlgoAPI_STLExport.h GeomAlgoAPI_IGESExport.h GeomAlgoAPI_Transform.h GeomAlgoAPI_ShapeTools.h @@ -112,11 +110,9 @@ SET(PROJECT_SOURCES GeomAlgoAPI_Placement.cpp GeomAlgoAPI_BREPImport.cpp GeomAlgoAPI_STEPImport.cpp - GeomAlgoAPI_STEPImportXCAF.cpp GeomAlgoAPI_IGESImport.cpp GeomAlgoAPI_BREPExport.cpp GeomAlgoAPI_STEPExport.cpp - GeomAlgoAPI_STLExport.cpp GeomAlgoAPI_IGESExport.cpp GeomAlgoAPI_Transform.cpp GeomAlgoAPI_ShapeTools.cpp @@ -180,7 +176,6 @@ INCLUDE_DIRECTORIES( ../GeomAlgoImpl ../ModelAPI ../XAO - ${PROJECT_SOURCE_DIR}/src/Locale ${OpenCASCADE_INCLUDE_DIR} ) diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_STEPImport.cpp b/src/GeomAlgoAPI/GeomAlgoAPI_STEPImport.cpp index 9e20ba201..3a824f106 100644 --- a/src/GeomAlgoAPI/GeomAlgoAPI_STEPImport.cpp +++ b/src/GeomAlgoAPI/GeomAlgoAPI_STEPImport.cpp @@ -54,36 +54,22 @@ #include #include #include +#include -#include -#include -#include -#include -#include -#include -#include -#include -#include #include -#include #include #include // CAREFUL ! position of this file is critic : see Lucien PIGNOLONI / OCC - -// ---------------------------------------------------------------------------- - std::shared_ptr STEPImport(const std::string& theFileName, const std::string& theFormatName, - const bool anScalInterUnits, std::string& theError) { - TopoDS_Shape aResShape; // Set "C" numeric locale to save numbers correctly // Kernel_Utils::Localizer loc; - + STEPControl_Reader aReader; //VSR: 16/09/09: Convert to METERS @@ -103,7 +89,7 @@ std::shared_ptr STEPImport(const std::string& theFileName, if (status == IFSelect_RetDone) { // Regard or not the model units - if (!anScalInterUnits) { + if (theFormatName == "STEP_SCALE") { // set UnitFlag to units from file TColStd_SequenceOfAsciiString anUnitLengthNames; TColStd_SequenceOfAsciiString anUnitAngleNames; @@ -208,83 +194,3 @@ std::shared_ptr STEPImport(const std::string& theFileName, aGeomShape->setImpl(new TopoDS_Shape(aResShape)); return aGeomShape; } - - -std::shared_ptr STEPImportAttributs(const std::string& theFileName, - std::shared_ptr theResultBody, - const bool anScalInterUnits, - const bool anMaterials, - const bool anColor, - std::map< std::wstring, std::list> &theMaterialShape, - std::string& theError) -{ - - STEPControl_Reader aReader; - std::shared_ptr aGeomShape(new GeomAPI_Shape); - //VSR: 16/09/09: Convert to METERS - 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 (!anScalInterUnits) { - // set UnitFlag to units from file - TColStd_SequenceOfAsciiString anUnitLengthNames; - TColStd_SequenceOfAsciiString anUnitAngleNames; - TColStd_SequenceOfAsciiString anUnitSolidAngleNames; - aReader.FileUnits(anUnitLengthNames, anUnitAngleNames, anUnitSolidAngleNames); - if (anUnitLengthNames.Length() > 0) { - TCollection_AsciiString aLenUnits = anUnitLengthNames.First(); - if (aLenUnits == "millimetre") - Interface_Static::SetCVal("xstep.cascade.unit", "MM"); - else if (aLenUnits == "centimetre") - Interface_Static::SetCVal("xstep.cascade.unit", "CM"); - else if (aLenUnits == "metre" || aLenUnits.IsEmpty()) - Interface_Static::SetCVal("xstep.cascade.unit", "M"); - else if (aLenUnits == "INCH") - Interface_Static::SetCVal("xstep.cascade.unit", "INCH"); - else { - theError = "The file contains not supported units."; - aGeomShape->setImpl(new TopoDS_Shape()); - return aGeomShape; - } - // TODO (for other units than mm, cm, m or inch) - //else if (aLenUnits == "") - // Interface_Static::SetCVal("xstep.cascade.unit", "???"); - } - } - else { - //cout<<"need re-scale a model"<setImpl(new TopoDS_Shape()); - return aGeomShape; - } - - STEPCAFControl_Reader cafreader; - cafreader.SetColorMode(true); - cafreader.SetNameMode(true); - cafreader.SetMatMode(true); - - if(cafreader.ReadFile(theFileName.c_str()) != IFSelect_RetDone) { - theError = "Wrong format of the imported file. Can't import file."; - std::shared_ptr aGeomShape(new GeomAPI_Shape); - aGeomShape->setImpl(new TopoDS_Shape()); - return aGeomShape; - } - - return readAttributes(cafreader,theResultBody,anMaterials, theMaterialShape, "STEP-XCAF"); - } - diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_STEPImport.h b/src/GeomAlgoAPI/GeomAlgoAPI_STEPImport.h index 9433a0a70..470791a3b 100644 --- a/src/GeomAlgoAPI/GeomAlgoAPI_STEPImport.h +++ b/src/GeomAlgoAPI/GeomAlgoAPI_STEPImport.h @@ -23,26 +23,13 @@ #include #include -#include - -#include +#include /// Implementation of the import STEP files algorithms GEOMALGOAPI_EXPORT std::shared_ptr STEPImport(const std::string& theFileName, const std::string& theFormatName, - const bool anScalInterUnits, std::string& theError); -/// Implementation of the import STEP files algorithms with Attributs (Name, Color, Materials) -GEOMALGOAPI_EXPORT -std::shared_ptr STEPImportAttributs(const std::string& theFileName, - std::shared_ptr theResultBody, - const bool anScalInterUnits, - const bool anMaterials, - const bool anColor, - std::map< std::wstring, std::list> &theMaterialShape, - std::string& theError); - #endif /* GEOMALGOAPI_STEPIMPORT_H_ */ diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_STLExport.cpp b/src/GeomAlgoAPI/GeomAlgoAPI_STLExport.cpp index e7d82b642..a11aa6565 100644 --- a/src/GeomAlgoAPI/GeomAlgoAPI_STLExport.cpp +++ b/src/GeomAlgoAPI/GeomAlgoAPI_STLExport.cpp @@ -38,12 +38,11 @@ #define MAX3(X, Y, Z) ( MAX2 ( MAX2(X, Y) , Z ) ) bool STLExport(const std::string& theFileName, - const std::string& /*theFormatName*/, - const std::shared_ptr& theShape, - const double aDeflection, - const bool anIsRelative, - const bool anIsASCII, - std::string& theError) + const std::shared_ptr& theShape, + const double theDeflection, + const bool theIsRelative, + const bool theIsASCII, + std::string& theError) { #ifdef _DEBUG std::cout << "Export STl into file " << theFileName << std::endl; @@ -56,28 +55,27 @@ bool STLExport(const std::string& theFileName, try { - // Set "C" numeric locale to save numbers correctly - GeomAlgoAPI_Tools::Localizer loc; - double lDeflection = aDeflection; + double lDeflection = theDeflection; StlAPI_Writer aWriter; // copy source shape BRepBuilderAPI_Copy aCopy( theShape->impl(), Standard_False ); TopoDS_Shape aCopyShape = aCopy.Shape(); // ASCII mode - aWriter.ASCIIMode() = anIsASCII; - if ( anIsRelative ) { + aWriter.ASCIIMode() = theIsASCII; + if ( theIsRelative ) { Standard_Real aXmin, aYmin, aZmin, aXmax, aYmax, aZmax; Bnd_Box bndBox; BRepBndLib::Add( theShape->impl(), bndBox ); bndBox.Get( aXmin, aYmin, aZmin, aXmax, aYmax, aZmax ); - lDeflection = MAX3( aXmax-aXmin, aYmax-aYmin, aZmax-aZmin ) * aDeflection; + lDeflection = MAX3( aXmax-aXmin, aYmax-aYmin, aZmax-aZmin ) * theDeflection; } //Compute triangulation - BRepTools::Clean( aCopyShape ); BRepMesh_IncrementalMesh aMesh( aCopyShape, lDeflection ); - aWriter.Write( aCopyShape, theFileName.c_str() ); - + if (!aWriter.Write( aCopyShape, theFileName.c_str())) { + theError = "STL Export failed"; + return false; + } return true; } catch( Standard_Failure ) diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_STLExport.h b/src/GeomAlgoAPI/GeomAlgoAPI_STLExport.h index 327dce41e..7c36584b1 100644 --- a/src/GeomAlgoAPI/GeomAlgoAPI_STLExport.h +++ b/src/GeomAlgoAPI/GeomAlgoAPI_STLExport.h @@ -29,11 +29,10 @@ /// Implementation of the export STL files algorithms GEOMALGOAPI_EXPORT bool STLExport(const std::string& theFileName, - const std::string& /*theFormatName*/, - const std::shared_ptr& theShape, - const double aDeflection, - const bool anIsRelative, - const bool anIsASCII, - std::string& theError); + const std::shared_ptr& theShape, + const double theDeflection, + const bool theIsRelative, + const bool theIsASCII, + std::string& theError); #endif /* GEOMALGOAPI_STLEXPORT_H_ */ diff --git a/src/Model/Model_Objects.cpp b/src/Model/Model_Objects.cpp index 63380e3e2..2c32988e2 100644 --- a/src/Model/Model_Objects.cpp +++ b/src/Model/Model_Objects.cpp @@ -1226,8 +1226,7 @@ bool Model_Objects::hasCustomName(DataPtr theFeatureData, void Model_Objects::storeResult(std::shared_ptr theFeatureData, std::shared_ptr theResult, - const int theResultIndex, - const std::wstring& theNameShape) + const int theResultIndex) { theResult->init(); theResult->setDoc(myDoc); @@ -1241,15 +1240,11 @@ void Model_Objects::storeResult(std::shared_ptr theFeatureData, theResult->data()->setName(L""); } else { std::wstringstream aName; - if( theNameShape != L"" ){ - aName << theNameShape; - }else{ - aName << aNewName; - // if there are several results (issue #899: any number of result), - // add unique prefix starting from second - if (theResultIndex > 0 || theResult->groupName() == ModelAPI_ResultBody::group()) - aName << "_" << theResultIndex + 1; - } + aName << aNewName; + // if there are several results (issue #899: any number of result), + // add unique prefix starting from second + if (theResultIndex > 0 || theResult->groupName() == ModelAPI_ResultBody::group()) + aName << "_" << theResultIndex + 1; aNewName = aName.str(); } theResult->data()->setName(aNewName); @@ -1274,7 +1269,7 @@ std::shared_ptr Model_Objects::createConstruction( } std::shared_ptr Model_Objects::createBody( - const std::shared_ptr& theFeatureData, const int theIndex,const std::wstring& theNameShape ) + const std::shared_ptr& theFeatureData, const int theIndex) { TDF_Label aLab = resultLabel(theFeatureData, theIndex); TDataStd_Comment::Set(aLab, ModelAPI_ResultBody::group().c_str()); @@ -1285,7 +1280,7 @@ std::shared_ptr Model_Objects::createBody( } if (!aResult.get()) { aResult = std::shared_ptr(new Model_ResultBody); - storeResult(theFeatureData, aResult, theIndex,theNameShape); + storeResult(theFeatureData, aResult, theIndex); } return aResult; } diff --git a/src/Model/Model_Objects.h b/src/Model/Model_Objects.h index fe3811543..c929be8ce 100644 --- a/src/Model/Model_Objects.h +++ b/src/Model/Model_Objects.h @@ -124,8 +124,7 @@ class Model_Objects const std::shared_ptr& theFeatureData, const int theIndex = 0); /// Creates a body result std::shared_ptr createBody( - const std::shared_ptr& theFeatureData, const int theIndex = 0, - const std::wstring& theNameShape = L""); + const std::shared_ptr& theFeatureData, const int theIndex = 0); /// Creates a part result std::shared_ptr createPart( const std::shared_ptr& theFeatureData, const int theIndex = 0); @@ -220,13 +219,12 @@ class Model_Objects //! Initializes the data fields of the feature void initData(ObjectPtr theObj, TDF_Label theLab, const int theTag); - - //! Allows to store the result in the data tree of the document + + //! Allows to store the result in the data tree of the document //! (attaches 'data' of result to tree) void storeResult(std::shared_ptr theFeatureData, std::shared_ptr theResult, - const int theResultIndex = 0, - const std::wstring& theNameShape = L""); + const int theResultIndex = 0); //! returns the label of result by index; creates this label if it was not created before TDF_Label resultLabel(const std::shared_ptr& theFeatureData, diff --git a/src/Model/Model_ResultBody.cpp b/src/Model/Model_ResultBody.cpp index 74b932c81..7d6918c6a 100644 --- a/src/Model/Model_ResultBody.cpp +++ b/src/Model/Model_ResultBody.cpp @@ -30,8 +30,6 @@ #include #include #include -#include -#include #include #include @@ -235,54 +233,6 @@ void Model_ResultBody::updateConcealment() } } -void Model_ResultBody::addShapeColor( const std::wstring& theName,std::vector& color) { - - if( myColorsShape.find(theName) == myColorsShape.end()) - myColorsShape[ theName ] = color; -} - -std::wstring Model_ResultBody::addShapeName(std::shared_ptr theshape,const std::wstring& theName ){ - - int indice = 1; - std::wstringstream aName; - aName << theName; - while(myNamesShape.find(aName.str()) != myNamesShape.end() ){ - aName.str(L""); - aName << theName << L"__" << indice; - indice++; - } - myNamesShape[ aName.str() ] = theshape; - - return aName.str(); -} - -std::wstring Model_ResultBody::findShapeName(std::shared_ptr theshape){ - - TopoDS_Shape aShape = theshape->impl(); - for (std::map< std::wstring, std::shared_ptr >::iterator it = myNamesShape.begin(); - it != myNamesShape.end(); - ++it) - { - TopoDS_Shape curSelectedShape = (*it).second->impl(); - if( (aShape.IsSame(curSelectedShape))) { - return (*it).first; - } - - } - return L"material not found" ; -} - - -void Model_ResultBody::setShapeName(std::map< std::wstring, std::shared_ptr > &theshapename, - std::map< std::wstring, std::vector> & theColorsShape) -{ - myNamesShape = theshapename; - myColorsShape = theColorsShape; -} -void Model_ResultBody::clearShapeNameAndColor(){ - myNamesShape.clear(); - myColorsShape.clear(); -} void Model_ResultBody::updateSubs(const std::shared_ptr& theThisShape, const bool theShapeChanged) { @@ -312,31 +262,13 @@ void Model_ResultBody::updateSubs(const std::shared_ptr& theThisS aShape->setImpl(new TopoDS_Shape(aShapesIter.Value())); ResultBodyPtr aSub; if (mySubs.size() <= aSubIndex) { // it is needed to create a new sub-result - std::wstring thenameshape = L""; - // find shape name read - for (std::map< std::wstring, std::shared_ptr >::iterator it = myNamesShape.begin(); - it != myNamesShape.end(); - ++it) - { - TopoDS_Shape curSelectedShape = (*it).second->impl(); - if( !(aShapesIter.Value().IsSame(curSelectedShape))) continue; - thenameshape = (*it).first; - break; - } - aSub = anObjects->createBody(this->data(), aSubIndex,thenameshape); - //finf color read - std::map< std::wstring, std::vector>::iterator itColor = myColorsShape.find(thenameshape); - if(itColor != myColorsShape.end()){ - ModelAPI_Tools::setColor(aSub,(*itColor).second); - } - aSub->setShapeName(myNamesShape,myColorsShape); + aSub = anObjects->createBody(this->data(), aSubIndex); mySubs.push_back(aSub); mySubsMap[aSub] = int(mySubs.size() - 1); if (isConcealed()) { // for issue #2579 note7 aSub->ModelAPI_ResultBody::setIsConcealed(true); std::dynamic_pointer_cast(aSub)->updateConcealment(); } - } else { // just update shape of this result aSub = mySubs[aSubIndex]; } diff --git a/src/Model/Model_ResultBody.h b/src/Model/Model_ResultBody.h index fe3987642..94e9d9b7c 100644 --- a/src/Model/Model_ResultBody.h +++ b/src/Model/Model_ResultBody.h @@ -117,7 +117,7 @@ protected: /// Makes a body on the given feature Model_ResultBody(); -/// Updates the sub-bodies if shape of this object is composite-solid + /// Updates the sub-bodies if shape of this object is composite-solid void updateSubs(const std::shared_ptr& theThisShape, const bool theShapeChanged = true); @@ -134,23 +134,6 @@ protected: const std::list& theAllOlds, std::list& theOldForSub); friend class Model_Objects; - - // Add shape Name for read shape in step file - std::wstring addShapeName(std::shared_ptr,const std::wstring& theName) override; - // Add color for shape Name read shape in step file - void addShapeColor( const std::wstring& theName,std::vector& color) override; - // Set the map of name and color read shape in step file - void setShapeName(std::map< std::wstring, std::shared_ptr > &theshapename,std::map< std::wstring, std::vector> & theColorsShape) override; - // find the name of shapp read in step file - std::wstring findShapeName(std::shared_ptr theshape) override; - // Clear the map of name and color read shape in step file - void clearShapeNameAndColor() override; - - // map with the name read in step file and shape - std::map< std::wstring, std::shared_ptr > myNamesShape; - // map with the name contruct and color read - std::map< std::wstring, std::vector> myColorsShape; - }; #endif diff --git a/src/ModelAPI/ModelAPI_Feature.h b/src/ModelAPI/ModelAPI_Feature.h index 811845db2..a700139ec 100644 --- a/src/ModelAPI/ModelAPI_Feature.h +++ b/src/ModelAPI/ModelAPI_Feature.h @@ -193,11 +193,6 @@ class ModelAPI_Feature : public ModelAPI_Object { return data()->intArray(theID); } - /// Returns the double array attribute by the identifier - inline std::shared_ptr realArray(const std::string& theID) - { - return data()->realArray(theID); - } /// Returns the reference attribute by the identifier inline std::shared_ptr refattr(const std::string& theID) { diff --git a/src/ModelAPI/ModelAPI_ResultBody.h b/src/ModelAPI/ModelAPI_ResultBody.h index 11fdd2421..c88fb08fc 100644 --- a/src/ModelAPI/ModelAPI_ResultBody.h +++ b/src/ModelAPI/ModelAPI_ResultBody.h @@ -24,8 +24,6 @@ #include #include #include -#include -#include class ModelAPI_BodyBuilder; class GeomAlgoAPI_MakeShape; @@ -184,26 +182,11 @@ public: /// Cleans cash related to the already stored elements MODELAPI_EXPORT virtual void cleanCash() = 0; - - // Add shape Name for read shape in step file - MODELAPI_EXPORT virtual std::wstring addShapeName(std::shared_ptr,const std::wstring& theName) = 0; - // Add color for shape Name read shape in step file - MODELAPI_EXPORT virtual void addShapeColor(const std::wstring& theName,std::vector& color) = 0; - // Set the map of name and color read shape in step file - MODELAPI_EXPORT virtual void setShapeName(std::map< std::wstring, std::shared_ptr > &theshapename, - std::map< std::wstring, std::vector> & theColorsShape) = 0; - // Clear the map of name and color read shape in step file - MODELAPI_EXPORT virtual void clearShapeNameAndColor() = 0; - // find the name of shapp read in step file - MODELAPI_EXPORT virtual std::wstring findShapeName(std::shared_ptr theshape) = 0; - protected: /// Default constructor accessible only from Model_Objects MODELAPI_EXPORT ModelAPI_ResultBody(); - - }; //! Pointer on feature object diff --git a/src/PythonAPI/model/exchange/__init__.py b/src/PythonAPI/model/exchange/__init__.py index 84b62bcc3..a37fdd678 100644 --- a/src/PythonAPI/model/exchange/__init__.py +++ b/src/PythonAPI/model/exchange/__init__.py @@ -19,7 +19,7 @@ """Package for Exchange plugin for the Parametric Geometry API of the Modeler. """ -from ExchangeAPI import addImport, addImportStep, exportToFile, exportToXAO, exportToSTL +from ExchangeAPI import addImport, exportToFile, exportToXAO from ExchangeAPI import exportPart, importPart from .tools import * -- 2.39.2