From d9e34610b60b8855dd47a886eeb606c372681dc7 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me?= Date: Tue, 15 Dec 2020 20:02:26 +0100 Subject: [PATCH] Remove STL export implementation --- src/ConnectorAPI/Test/TestExportSTL.py | 159 ------------------ src/ConnectorAPI/Test/tests.set | 1 - src/ExchangeAPI/ExchangeAPI_Export.cpp | 93 ---------- src/ExchangeAPI/ExchangeAPI_Export.h | 42 +---- .../ExchangePlugin_ExportFeature.cpp | 74 -------- .../ExchangePlugin_ExportFeature.h | 63 ------- src/ExchangePlugin/export_widget.xml | 58 ------- src/GeomAlgoAPI/CMakeLists.txt | 2 - src/GeomAlgoAPI/GeomAlgoAPI_STLExport.cpp | 88 ---------- src/GeomAlgoAPI/GeomAlgoAPI_STLExport.h | 39 ----- src/PythonAPI/model/exchange/__init__.py | 2 +- 11 files changed, 3 insertions(+), 618 deletions(-) delete mode 100644 src/ConnectorAPI/Test/TestExportSTL.py delete mode 100644 src/GeomAlgoAPI/GeomAlgoAPI_STLExport.cpp delete mode 100644 src/GeomAlgoAPI/GeomAlgoAPI_STLExport.h diff --git a/src/ConnectorAPI/Test/TestExportSTL.py b/src/ConnectorAPI/Test/TestExportSTL.py deleted file mode 100644 index edc7eaf01..000000000 --- a/src/ConnectorAPI/Test/TestExportSTL.py +++ /dev/null @@ -1,159 +0,0 @@ -# Copyright (C) 2014-2020 CEA/DEN, EDF R&D -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License, or (at your option) any later version. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# -# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -# - -""" - TestExport.py - Unit test of ExchangePlugin_TestExport class -""" -#========================================================================= -# Initialization of the test -#========================================================================= - -import salome - -import os -import math -from tempfile import TemporaryDirectory - -import GEOM - -from ModelAPI import * - -from salome.shaper import model - -from salome.geom import geomBuilder - -from GeomAlgoAPI import * - -__updated__ = "2015-05-22" - -salome.salome_init(1) -geompy = geomBuilder.New() - -#========================================================================= -# Help functions -#========================================================================= -def removeFile(theFileName): - try: os.remove(theFileName) - except OSError: pass - assert not os.path.exists(theFileName), \ - "Can not remove file {0}".format(theFileName) - -#========================================================================= -# test Export STL -#========================================================================= -def testExportSTL(theFile, theDelta, theErrorExpected = False): - - model.begin() - partSet = model.moduleDocument() - Part_1 = model.addPart(partSet) - Part_1_doc = Part_1.document() - Box_1 = model.addBox(Part_1_doc, 10, 10, 10) - Box_2 = model.addBox(Part_1_doc, 20, 20, 20) - model.do() - - # First export to GEOM - model.exportToGEOM(Part_1_doc) - model.end() - - theSurface = 600 - - print("theFile=",theFile) - - # deflection relative 0.0001 et Ascii - model.exportToSTL(Part_1_doc, theFile, model.selection("SOLID","Box_1_1"),0.0001, 0.5, True,False) - - #== assert os.path.exists(theFile) - - # Check results - test_stl_1 = geompy.ImportSTL(theFile) - Props = geompy.BasicProperties(test_stl_1) - print("\nBasic Properties:") - print(" Wires length: ", Props[0]) - print(" Surface area: ", Props[1]) - print(" Volume : ", Props[2]) - - aRefSurface = theSurface - aResSurface = Props[1] - assert (math.fabs(aResSurface - aRefSurface) < theDelta), "The volume is wrong: expected = {0}, real = {1}".format(aRefSurface, aResSurface) - - removeFile(theFile) - - theSurface = 600 - # deflection relative 0.0001 et binaire - model.exportToSTL(Part_1_doc, theFile, model.selection("SOLID", "Box_1_1" ),0.0001, 0.5, True,True) - - # Check results - test_stl_1 = geompy.ImportSTL(theFile) - Props = geompy.BasicProperties(test_stl_1) - print("\nBasic Properties:") - print(" Wires length: ", Props[0]) - print(" Surface area: ", Props[1]) - print(" Volume : ", Props[2]) - - aRefSurface = theSurface - aResSurface = Props[1] - assert (math.fabs(aResSurface - aRefSurface) < theDelta), "The volume is wrong: expected = {0}, real = {1}".format(aRefSurface, aResSurface) - - removeFile(theFile) - - theSurface = 600 - # deflection absolue et AScii - model.exportToSTL(Part_1_doc, theFile, model.selection("SOLID", "Box_1_1" ),0.0001, 0.5, False, False) - - # Check results - test_stl_1 = geompy.ImportSTL(theFile) - Props = geompy.BasicProperties(test_stl_1) - print("\nBasic Properties:") - print(" Wires length: ", Props[0]) - print(" Surface area: ", Props[1]) - print(" Volume : ", Props[2]) - - aRefSurface = theSurface - aResSurface = Props[1] - assert (math.fabs(aResSurface - aRefSurface) < theDelta), "The volume is wrong: expected = {0}, real = {1}".format(aRefSurface, aResSurface) - - theSurface = 600 - # deflection absolue et binaire - model.exportToSTL(Part_1_doc, theFile, model.selection("SOLID", "Box_1_1" ),0.0001, 0.5, False,True) - - # Check results - test_stl_1 = geompy.ImportSTL(theFile) - Props = geompy.BasicProperties(test_stl_1) - print("\nBasic Properties:") - print(" Wires length: ", Props[0]) - print(" Surface area: ", Props[1]) - print(" Volume : ", Props[2]) - - aRefSurface = theSurface - aResSurface = Props[1] - assert (math.fabs(aResSurface - aRefSurface) < theDelta), "The volume is wrong: expected = {0}, real = {1}".format(aRefSurface, aResSurface) - - model.end() - -if __name__ == '__main__': - with TemporaryDirectory() as tmp_dir: - aRealSurface = 0.00192878 - #========================================================================= - # Export a shape into STL - #========================================================================= - testExportSTL(os.path.join(tmp_dir, "export.stl"), 10 ** -5, True) - #========================================================================= - # End of test - #========================================================================= diff --git a/src/ConnectorAPI/Test/tests.set b/src/ConnectorAPI/Test/tests.set index 3f4eb7ec2..d36ac9209 100644 --- a/src/ConnectorAPI/Test/tests.set +++ b/src/ConnectorAPI/Test/tests.set @@ -27,6 +27,5 @@ SET(TEST_NAMES Test17917 Test18887 Test3195 - TestExportSTL TestImportSTEP ) diff --git a/src/ExchangeAPI/ExchangeAPI_Export.cpp b/src/ExchangeAPI/ExchangeAPI_Export.cpp index 4e9b4b9c3..2d08afd22 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) @@ -190,33 +145,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 +180,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/ExchangePlugin/ExchangePlugin_ExportFeature.cpp b/src/ExchangePlugin/ExchangePlugin_ExportFeature.cpp index 08a9cde70..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/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/GeomAlgoAPI/CMakeLists.txt b/src/GeomAlgoAPI/CMakeLists.txt index a03ae213f..c1dc76e4c 100644 --- a/src/GeomAlgoAPI/CMakeLists.txt +++ b/src/GeomAlgoAPI/CMakeLists.txt @@ -49,7 +49,6 @@ SET(PROJECT_HEADERS GeomAlgoAPI_IGESImport.h GeomAlgoAPI_BREPExport.h GeomAlgoAPI_STEPExport.h - GeomAlgoAPI_STLExport.h GeomAlgoAPI_IGESExport.h GeomAlgoAPI_Transform.h GeomAlgoAPI_ShapeTools.h @@ -116,7 +115,6 @@ SET(PROJECT_SOURCES GeomAlgoAPI_IGESImport.cpp GeomAlgoAPI_BREPExport.cpp GeomAlgoAPI_STEPExport.cpp - GeomAlgoAPI_STLExport.cpp GeomAlgoAPI_IGESExport.cpp GeomAlgoAPI_Transform.cpp GeomAlgoAPI_ShapeTools.cpp diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_STLExport.cpp b/src/GeomAlgoAPI/GeomAlgoAPI_STLExport.cpp deleted file mode 100644 index b9928428b..000000000 --- a/src/GeomAlgoAPI/GeomAlgoAPI_STLExport.cpp +++ /dev/null @@ -1,88 +0,0 @@ -// Copyright (C) 2014-2020 CEA/DEN, EDF R&D -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#include "GeomAlgoAPI_STLExport.h" - -#include "GeomAlgoAPI_Tools.h" - -#include - -// OOCT includes -#include -#include -#include -#include -#include -#include -#include - - - -#define MAX2(X, Y) ( Abs(X) > Abs(Y) ? Abs(X) : Abs(Y) ) -#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) -{ - #ifdef _DEBUG - std::cout << "Export STl into file " << theFileName << std::endl; - #endif - - if (!theShape.get()) { - theError = "STl Export failed: An invalid argument"; - return false; - } - - try - { - // Set "C" numeric locale to save numbers correctly - GeomAlgoAPI_Tools::Localizer loc; - - double lDeflection = aDeflection; - 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 ) { - 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; - } - //Compute triangulation - BRepTools::Clean( aCopyShape ); - BRepMesh_IncrementalMesh aMesh( aCopyShape, lDeflection ); - aWriter.Write( aCopyShape, theFileName.c_str() ); - - return true; - } - catch( Standard_Failure ) - { - theError = "Exception catched in STlExport"; - } - return false; -} diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_STLExport.h b/src/GeomAlgoAPI/GeomAlgoAPI_STLExport.h deleted file mode 100644 index e256c037d..000000000 --- a/src/GeomAlgoAPI/GeomAlgoAPI_STLExport.h +++ /dev/null @@ -1,39 +0,0 @@ -// Copyright (C) 2014-2020 CEA/DEN, EDF R&D -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#ifndef GEOMALGOAPI_STLEXPORT_H_ -#define GEOMALGOAPI_STLEXPORT_H_ - -#include - -#include - -#include - -/// 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); - -#endif /* GEOMALGOAPI_STLEXPORT_H_ */ diff --git a/src/PythonAPI/model/exchange/__init__.py b/src/PythonAPI/model/exchange/__init__.py index 800ab45f9..e95dd3bac 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, addImportSTEP, exportToFile, exportToXAO from ExchangeAPI import exportPart, importPart from .tools import * -- 2.39.2