Back to index

salome-geom  6.5.0
STLExport.cxx
Go to the documentation of this file.
00001 // Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
00002 //
00003 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
00004 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
00005 //
00006 // This library is free software; you can redistribute it and/or
00007 // modify it under the terms of the GNU Lesser General Public
00008 // License as published by the Free Software Foundation; either
00009 // version 2.1 of the License.
00010 //
00011 // This library is distributed in the hope that it will be useful,
00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014 // Lesser General Public License for more details.
00015 //
00016 // You should have received a copy of the GNU Lesser General Public
00017 // License along with this library; if not, write to the Free Software
00018 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00019 //
00020 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00021 //
00022 
00023 // File:        STLExport.cxx
00024 // Created:     Wed May 19 14:53:52 2004
00025 // Author:      Pavel TELKOV
00026 //              <ptv@mutex.nnov.opencascade.com>
00027 //
00028 #include "utilities.h"
00029 
00030 #include <StlAPI_Writer.hxx>
00031 
00032 #include <TCollection_AsciiString.hxx>
00033 #include <TopoDS_Shape.hxx>
00034 
00035 #ifdef WIN32
00036 # if defined STLEXPORT_EXPORTS || defined STLExport_EXPORTS
00037 #  define STLEXPORT_EXPORT __declspec( dllexport )
00038 # else
00039 #  define STLEXPORT_EXPORT __declspec( dllimport )
00040 # endif
00041 #else
00042 # define STLEXPORT_EXPORT
00043 #endif
00044 
00045 //=============================================================================
00049 //=============================================================================
00050 
00051 extern "C"
00052 {
00053   STLEXPORT_EXPORT
00054   int Export(const TopoDS_Shape& theShape,
00055              const TCollection_AsciiString& theFileName,
00056              const TCollection_AsciiString& theFormatName)
00057   {
00058     MESSAGE("Export STL into file " << theFileName.ToCString());
00059 
00060     try
00061     {
00062       StlAPI_Writer aWriter;
00063       bool aIsASCIIMode;
00064       aIsASCIIMode = (theFormatName.IsEqual("STL_ASCII")) ? true : false;
00065       aWriter.ASCIIMode() = aIsASCIIMode;
00066       aWriter.Write(theShape, theFileName.ToCString()) ;
00067       return 1;
00068     }
00069     catch(Standard_Failure)
00070     {
00071       //THROW_SALOME_CORBA_EXCEPTION("Exception catched in STLExport", SALOME::BAD_PARAM);
00072     }
00073     return 0;
00074   }
00075 }