X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FGeomAlgoAPI%2FGeomAlgoAPI_IGESExport.cpp;h=c4d9add35d01336f89341f2061786c1be8314968;hb=580f1752efd9d3e8c2890c4016b04dafd639bab7;hp=4a7b52bf61db89d73a34a4d3e898272c4f142f82;hpb=eaa34d7803a364b8da51b6dde8b0ee3c469ae27a;p=modules%2Fshaper.git diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_IGESExport.cpp b/src/GeomAlgoAPI/GeomAlgoAPI_IGESExport.cpp index 4a7b52bf6..c4d9add35 100644 --- a/src/GeomAlgoAPI/GeomAlgoAPI_IGESExport.cpp +++ b/src/GeomAlgoAPI/GeomAlgoAPI_IGESExport.cpp @@ -1,10 +1,12 @@ // Copyright (C) 2014-20xx CEA/DEN, EDF R&D +// File: GEOMALGOAPI_IGESExport.cpp +// Created: Dec 24, 2014 +// Author: Sergey BELASH + #include -//// KERNEL includes -//#include -//#include +#include "GeomAlgoAPI_Tools.h" // OOCT includes #include @@ -76,30 +78,38 @@ int KindOfBRep (const TopoDS_Shape& theShape) } //============================================================================= -//extern "C" { -namespace IGESExport { - -bool Export(const TCollection_AsciiString& theFileName, - const TCollection_AsciiString&, - const TopoDS_Shape& theShape, - TCollection_AsciiString& theError, const TDF_Label&) +bool IGESExport(const std::string& theFileName, + const std::string& theFormatName, + const std::shared_ptr& theShape, + std::string& theError) { - //TODO(spo): pass version as argument of the function - TCollection_AsciiString aVersion = "5.3"; + #ifdef _DEBUG + std::cout << "Export IGES into file " << theFileName << std::endl; + #endif + + if (!theShape.get()) { + theError = "IGES Export failed: An invalid argument"; + return false; + } + + // theFormatName expected "IGES-5.1", "IGES-5.3"... + TCollection_AsciiString aFormatName(theFormatName.c_str()); + TCollection_AsciiString aVersion = aFormatName.Token("-", 2); + #ifdef _DEBUG + if (!aVersion.IsEqual("5.1") || !aVersion.IsEqual("5.3")) + std::cout << "Warning: unrecognized version " << aVersion.ToCString() + << ". Default version: 5.1." << std::endl; + #endif // define, whether to write only faces (5.1 IGES format) // or shells and solids also (5.3 IGES format) int aBrepMode = 0; if( aVersion.IsEqual( "5.3" ) ) aBrepMode = 1; - #ifdef _DEBUG - std::cout << "Export IGES into file " << theFileName.ToCString() << std::endl; - #endif - // Mantis issue 0021350: check being exported shape, as some stand-alone // entities (edges, wires and vertices) cannot be saved in BRepMode if( aBrepMode == 1 ) { - int aKind = KindOfBRep( theShape ); + int aKind = KindOfBRep( theShape->impl() ); if( aKind == -1 ) { theError = "EXPORT_IGES_HETEROGENEOUS_COMPOUND"; return false; @@ -109,8 +119,8 @@ bool Export(const TCollection_AsciiString& theFileName, aBrepMode = aKind; } -// // Set "C" numeric locale to save numbers correctly -// Kernel_Utils::Localizer loc; + // Set "C" numeric locale to save numbers correctly + GeomAlgoAPI_Tools::Localizer loc; // initialize writer IGESControl_Controller::Init(); @@ -122,13 +132,9 @@ bool Export(const TCollection_AsciiString& theFileName, Interface_Static::SetCVal( "write.precision.mode", "Max" ); // perform shape writing - if( ICW.AddShape( theShape ) ) { + if( ICW.AddShape( theShape->impl() ) ) { ICW.ComputeModel(); - return (bool)ICW.Write( theFileName.ToCString() ); + return ICW.Write(theFileName.c_str()) == Standard_True; } return false; } - -} - -//}