From a2c43dba0a6cb0632f9c795ee2055e7ea562b996 Mon Sep 17 00:00:00 2001 From: Sergey POKHODENKO Date: Thu, 14 May 2015 15:05:43 +0300 Subject: [PATCH] Issue #529 : 4.07. Import IGES, export to BREP, STEP, IGES - Export BREP --- src/ExchangePlugin/CMakeLists.txt | 4 +-- .../ExchangePlugin_ExportFeature.cpp | 8 ++--- src/GeomAlgoAPI/CMakeLists.txt | 2 ++ src/GeomAlgoAPI/GeomAlgoAPI_BREPExport.cpp | 31 +++++++++++++++++++ src/GeomAlgoAPI/GeomAlgoAPI_BREPExport.h | 30 ++++++++++++++++++ src/GeomAlgoAPI/GeomAlgoAPI_IGESExport.h | 2 +- 6 files changed, 70 insertions(+), 7 deletions(-) create mode 100644 src/GeomAlgoAPI/GeomAlgoAPI_BREPExport.cpp create mode 100644 src/GeomAlgoAPI/GeomAlgoAPI_BREPExport.h diff --git a/src/ExchangePlugin/CMakeLists.txt b/src/ExchangePlugin/CMakeLists.txt index dc2e3a917..2440dd129 100644 --- a/src/ExchangePlugin/CMakeLists.txt +++ b/src/ExchangePlugin/CMakeLists.txt @@ -8,7 +8,7 @@ INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/src/Events ${PROJECT_SOURCE_DIR}/src/GeomAPI ${PROJECT_SOURCE_DIR}/src/GeomAlgoAPI ${CAS_INCLUDE_DIRS} -) +) SET(PROJECT_HEADERS ExchangePlugin.h @@ -17,7 +17,7 @@ SET(PROJECT_HEADERS ExchangePlugin_ExportFeature.h ExchangePlugin_Validators.h ) - + SET(PROJECT_SOURCES ExchangePlugin_Plugin.cpp ExchangePlugin_ImportFeature.cpp diff --git a/src/ExchangePlugin/ExchangePlugin_ExportFeature.cpp b/src/ExchangePlugin/ExchangePlugin_ExportFeature.cpp index 57843ebc3..3ad9783e2 100644 --- a/src/ExchangePlugin/ExchangePlugin_ExportFeature.cpp +++ b/src/ExchangePlugin/ExchangePlugin_ExportFeature.cpp @@ -3,12 +3,12 @@ /* * ExchangePlugin_ExportFeature.cpp * - * Created on: Aug 28, 2014 - * Author: sbh + * Created on: May 14, 2015 + * Author: spo */ #include -//#include +#include //#include #include @@ -107,7 +107,7 @@ bool ExchangePlugin_ExportFeature::exportFile(const std::string& theFileName, TopoDS_Shape aShape(theShape->impl()); bool aResult = true; if (aFormatName == "BREP") { -// aShape = BREPExport::Export(aFileName, aFormatName, anError, anUnknownLabel); + aResult = BREPExport::Export(aFileName, aFormatName, aShape, anError, anUnknownLabel); } else if (aFormatName == "STEP" || aFormatName == "STP") { // aShape = STEPExport::Export(aFileName, aFormatName, anError, anUnknownLabel); } else if (aFormatName == "IGES") { diff --git a/src/GeomAlgoAPI/CMakeLists.txt b/src/GeomAlgoAPI/CMakeLists.txt index 44dd3cb42..2dfd6048f 100644 --- a/src/GeomAlgoAPI/CMakeLists.txt +++ b/src/GeomAlgoAPI/CMakeLists.txt @@ -22,6 +22,7 @@ SET(PROJECT_HEADERS GeomAlgoAPI_BREPImport.h GeomAlgoAPI_STEPImport.h GeomAlgoAPI_IGESImport.h + GeomAlgoAPI_BREPExport.h GeomAlgoAPI_IGESExport.h ) @@ -41,6 +42,7 @@ SET(PROJECT_SOURCES GeomAlgoAPI_BREPImport.cpp GeomAlgoAPI_STEPImport.cpp GeomAlgoAPI_IGESImport.cpp + GeomAlgoAPI_BREPExport.cpp GeomAlgoAPI_IGESExport.cpp ) diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_BREPExport.cpp b/src/GeomAlgoAPI/GeomAlgoAPI_BREPExport.cpp new file mode 100644 index 000000000..0499c7587 --- /dev/null +++ b/src/GeomAlgoAPI/GeomAlgoAPI_BREPExport.cpp @@ -0,0 +1,31 @@ +// Copyright (C) 2014-20xx CEA/DEN, EDF R&D + +#include + +#include +#include + +//============================================================================= +/*! + * + */ +//============================================================================= +//extern "C" { +namespace BREPExport { +bool Export(const TCollection_AsciiString& theFileName, + const TCollection_AsciiString&, + const TopoDS_Shape& theShape, + TCollection_AsciiString& theError, const TDF_Label&) +{ + #ifdef _DEBUG + std::cout << "Export BREP into file " << theFileName << std::endl; + #endif + if ( !BRepTools::Write( theShape, theFileName.ToCString() ) ) { + theError = "BREP Export failed"; + return false; + } + return true; +} + +} +//} diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_BREPExport.h b/src/GeomAlgoAPI/GeomAlgoAPI_BREPExport.h new file mode 100644 index 000000000..90496b0e4 --- /dev/null +++ b/src/GeomAlgoAPI/GeomAlgoAPI_BREPExport.h @@ -0,0 +1,30 @@ +// Copyright (C) 2014-20xx CEA/DEN, EDF R&D + +/* + * GEOMALGOAPI_BREPExport.h + * + * Created on: May 14, 2015 + * Author: spo + */ + +#ifndef GEOMALGOAPI_BREPEXPORT_H_ +#define GEOMALGOAPI_BREPEXPORT_H_ + +#include + +#include +#include +#include + +namespace BREPExport { + +/// Implementation of the export BREP files algorithms +GEOMALGOAPI_EXPORT +bool Export(const TCollection_AsciiString& theFileName, + const TCollection_AsciiString& theFormatName, + const TopoDS_Shape& theShape, + TCollection_AsciiString& theError, const TDF_Label&); + +} + +#endif /* GEOMALGOAPI_BREPEXPORT_H_ */ diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_IGESExport.h b/src/GeomAlgoAPI/GeomAlgoAPI_IGESExport.h index 7a7f28d41..e52a263e7 100644 --- a/src/GeomAlgoAPI/GeomAlgoAPI_IGESExport.h +++ b/src/GeomAlgoAPI/GeomAlgoAPI_IGESExport.h @@ -18,7 +18,7 @@ namespace IGESExport { -/// Implementation of the import IGES files algorithms +/// Implementation of the export IGES files algorithms GEOMALGOAPI_EXPORT bool Export(const TCollection_AsciiString& theFileName, const TCollection_AsciiString& theFormatName, -- 2.30.2