]> SALOME platform Git repositories - modules/geom.git/blob - src/STLImport/STLImport.cxx
Salome HOME
0022315: EDF 2722 GEOM: Import STL in GEOM
[modules/geom.git] / src / STLImport / STLImport.cxx
1 // Copyright (C) 2007-2013  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
10 //
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 // Lesser General Public License for more details.
15 //
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
19 //
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22
23 // File:        STLImport.cxx
24 // Author:      Sergey KHROMOV
25
26
27 #include "utilities.h"
28 #include <StlAPI_Reader.hxx>
29 #include <TCollection_AsciiString.hxx>
30 #include <TopoDS_Shape.hxx>
31 #include <TDF_Label.hxx>
32
33
34 #ifdef WIN32
35   #if defined STLIMPORT_EXPORTS || defined STLImport_EXPORTS
36     #define STLIMPORT_EXPORT __declspec( dllexport )
37   #else
38     #define STLIMPORT_EXPORT __declspec( dllimport )
39   #endif
40 #else
41   #define STLIMPORT_EXPORT
42 #endif
43
44
45 //=============================================================================
46 /*!
47  *
48  */
49 //=============================================================================
50
51 extern "C"
52 {
53 STLIMPORT_EXPORT
54   TopoDS_Shape Import (const TCollection_AsciiString& theFileName,
55                        const TCollection_AsciiString& /*theFormatName*/,
56                        TCollection_AsciiString&       theError,
57                        const TDF_Label&)
58   {
59     MESSAGE("Import STL from file " << theFileName.ToCString());
60
61     StlAPI_Reader aReader;
62     TopoDS_Shape aShape;
63
64     aReader.Read(aShape, theFileName.ToCString());
65
66     if (aShape.IsNull()) {
67       theError = "STL Import failed";
68     }
69
70     return aShape;
71   }
72 }