0030520: VIS - IVtkTools_ShapePicker::GetPickPosition() returns incorrect point
[occt.git] / src / RWStl / RWStl.hxx
1 // Created on: 2017-06-13
2 // Created by: Alexander MALYSHEV
3 // Copyright (c) 2017 OPEN CASCADE SAS
4 //
5 // This file is part of Open CASCADE Technology software library.
6 //
7 // This library is free software; you can redistribute it and/or modify it under
8 // the terms of the GNU Lesser General Public License version 2.1 as published
9 // by the Free Software Foundation, with special exception defined in the file
10 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
11 // distribution for complete text of the license and disclaimer of any warranty.
12 //
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
15
16 #ifndef _RWStl_HeaderFile
17 #define _RWStl_HeaderFile
18
19 #include <Message_ProgressIndicator.hxx>
20 #include <OSD_Path.hxx>
21 #include <Poly_Triangulation.hxx>
22 #include <Standard_Macro.hxx>
23
24 //! This class provides methods to read and write triangulation from / to the STL files.
25 class RWStl
26 {
27 public:
28
29   //! Write triangulation to binary STL file.
30   //! binary format of an STL file.
31   //! Returns false if the cannot be opened;
32   Standard_EXPORT static Standard_Boolean WriteBinary (const Handle(Poly_Triangulation)& theMesh,
33                                                        const OSD_Path& thePath,
34                                                        const Handle(Message_ProgressIndicator)& theProgInd = Handle(Message_ProgressIndicator)());
35   
36   //! write the meshing in a file following the
37   //! Ascii  format of an STL file.
38   //! Returns false if the cannot be opened;
39   Standard_EXPORT static Standard_Boolean WriteAscii (const Handle(Poly_Triangulation)& theMesh,
40                                                       const OSD_Path& thePath,
41                                                       const Handle(Message_ProgressIndicator)& theProgInd = Handle(Message_ProgressIndicator)());
42   
43   //! Read specified STL file and returns its content as triangulation.
44   //! In case of error, returns Null handle.
45   Standard_EXPORT static Handle(Poly_Triangulation) ReadFile (const OSD_Path& theFile,
46                                                               const Handle(Message_ProgressIndicator)& aProgInd = Handle(Message_ProgressIndicator)());
47
48   //! Read specified STL file and returns its content as triangulation.
49   //! In case of error, returns Null handle.
50   Standard_EXPORT static Handle(Poly_Triangulation) ReadFile (const Standard_CString theFile,
51                                                               const Handle(Message_ProgressIndicator)& aProgInd = Handle(Message_ProgressIndicator)());
52
53   //! Read triangulation from a binary STL file
54   //! In case of error, returns Null handle.
55   Standard_EXPORT static Handle(Poly_Triangulation) ReadBinary (const OSD_Path& thePath,
56                                                                 const Handle(Message_ProgressIndicator)& theProgInd = Handle(Message_ProgressIndicator)());
57   
58   //! Read triangulation from an Ascii STL file
59   //! In case of error, returns Null handle.
60   Standard_EXPORT static Handle(Poly_Triangulation) ReadAscii (const OSD_Path& thePath,
61                                                                const Handle(Message_ProgressIndicator)& theProgInd = Handle(Message_ProgressIndicator)());
62
63 private:
64
65   //! Write ASCII version.
66   static Standard_Boolean writeASCII (const Handle(Poly_Triangulation)& theMesh,
67                                       FILE *theFile,
68                                       const Handle(Message_ProgressIndicator)& theProgInd);
69
70   //! Write binary version.
71   static Standard_Boolean writeBinary (const Handle(Poly_Triangulation)& theMesh,
72                                        FILE *theFile,
73                                        const Handle(Message_ProgressIndicator)& theProgInd);
74 };
75
76 #endif