Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:04:52

0001 // Created on: 2017-06-13
0002 // Created by: Alexander MALYSHEV
0003 // Copyright (c) 2017 OPEN CASCADE SAS
0004 //
0005 // This file is part of Open CASCADE Technology software library.
0006 //
0007 // This library is free software; you can redistribute it and/or modify it under
0008 // the terms of the GNU Lesser General Public License version 2.1 as published
0009 // by the Free Software Foundation, with special exception defined in the file
0010 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
0011 // distribution for complete text of the license and disclaimer of any warranty.
0012 //
0013 // Alternatively, this file may be used under the terms of Open CASCADE
0014 // commercial license or contractual agreement.
0015 
0016 #ifndef _RWStl_HeaderFile
0017 #define _RWStl_HeaderFile
0018 
0019 #include <OSD_Path.hxx>
0020 #include <Poly_Triangulation.hxx>
0021 #include <Standard_Macro.hxx>
0022 #include <Message_ProgressScope.hxx>
0023 #include <NCollection_Sequence.hxx>
0024 
0025 //! This class provides methods to read and write triangulation from / to the STL files.
0026 class RWStl
0027 {
0028 public:
0029 
0030   //! Write triangulation to binary STL file.
0031   //! binary format of an STL file.
0032   //! Returns false if the cannot be opened;
0033   Standard_EXPORT static Standard_Boolean WriteBinary (const Handle(Poly_Triangulation)& theMesh,
0034                                                        const OSD_Path& thePath,
0035                                                        const Message_ProgressRange& theProgress = Message_ProgressRange());
0036   
0037   //! write the meshing in a file following the
0038   //! Ascii  format of an STL file.
0039   //! Returns false if the cannot be opened;
0040   Standard_EXPORT static Standard_Boolean WriteAscii (const Handle(Poly_Triangulation)& theMesh,
0041                                                       const OSD_Path& thePath,
0042                                                       const Message_ProgressRange& theProgress = Message_ProgressRange());
0043   
0044   //! Read specified STL file and returns its content as triangulation.
0045   //! In case of error, returns Null handle.
0046   Standard_EXPORT static Handle(Poly_Triangulation) ReadFile (const OSD_Path& theFile,
0047                                                               const Message_ProgressRange& theProgress = Message_ProgressRange());
0048 
0049   //! Read specified STL file and returns its content as triangulation.
0050   //! In case of error, returns Null handle.
0051   static Handle(Poly_Triangulation) ReadFile (const Standard_CString theFile,
0052                                               const Message_ProgressRange& theProgress = Message_ProgressRange())
0053   {
0054     return ReadFile (theFile, M_PI / 2.0, theProgress);
0055   }
0056 
0057   //! Read specified STL file and returns its content as triangulation.
0058   //! @param[in] theFile file path to read
0059   //! @param[in] theMergeAngle maximum angle in radians between triangles to merge equal nodes; M_PI/2 means ignore angle
0060   //! @param[in] theProgress progress indicator
0061   //! @return result triangulation or NULL in case of error
0062   Standard_EXPORT static Handle(Poly_Triangulation) ReadFile (const Standard_CString theFile,
0063                                                               const Standard_Real theMergeAngle,
0064                                                               const Message_ProgressRange& theProgress = Message_ProgressRange());
0065   
0066   //! Read specified STL file and fills triangulation list for multi-domain case.
0067   //! @param[in] theFile file path to read
0068   //! @param[in] theMergeAngle maximum angle in radians between triangles to merge equal nodes; M_PI/2 means ignore angle
0069   //! @param[out] theTriangList triangulation list for multi-domain case
0070   //! @param[in] theProgress progress indicator
0071   Standard_EXPORT static void ReadFile(const Standard_CString theFile,
0072                                        const Standard_Real theMergeAngle,
0073                                        NCollection_Sequence<Handle(Poly_Triangulation)>& theTriangList,
0074                                        const Message_ProgressRange& theProgress = Message_ProgressRange());
0075   
0076   //! Read triangulation from a binary STL file
0077   //! In case of error, returns Null handle.
0078   Standard_EXPORT static Handle(Poly_Triangulation) ReadBinary (const OSD_Path& thePath,
0079                                                                 const Message_ProgressRange& theProgress = Message_ProgressRange());
0080   
0081   //! Read triangulation from an Ascii STL file
0082   //! In case of error, returns Null handle.
0083   Standard_EXPORT static Handle(Poly_Triangulation) ReadAscii (const OSD_Path& thePath,
0084                                                                const Message_ProgressRange& theProgress = Message_ProgressRange());
0085 
0086 private:
0087 
0088   //! Write ASCII version.
0089   static Standard_Boolean writeASCII (const Handle(Poly_Triangulation)& theMesh,
0090                                       FILE *theFile,
0091                                       const Message_ProgressRange& theProgress);
0092 
0093   //! Write binary version.
0094   static Standard_Boolean writeBinary (const Handle(Poly_Triangulation)& theMesh,
0095                                        FILE *theFile,
0096                                        const Message_ProgressRange& theProgress);
0097 };
0098 
0099 #endif