0029902: Data Exchange, XCAF - provide extended Material definition for visualization...
[occt.git] / src / RWObj / RWObj_MtlReader.hxx
1 // Author: Kirill Gavrilov
2 // Copyright (c) 2015-2019 OPEN CASCADE SAS
3 //
4 // This file is part of Open CASCADE Technology software library.
5 //
6 // This library is free software; you can redistribute it and/or modify it under
7 // the terms of the GNU Lesser General Public License version 2.1 as published
8 // by the Free Software Foundation, with special exception defined in the file
9 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
10 // distribution for complete text of the license and disclaimer of any warranty.
11 //
12 // Alternatively, this file may be used under the terms of Open CASCADE
13 // commercial license or contractual agreement.
14
15 #ifndef _RWObj_MtlReader_HeaderFile
16 #define _RWObj_MtlReader_HeaderFile
17
18 #include <Graphic3d_Vec3.hxx>
19 #include <RWObj_Material.hxx>
20 #include <NCollection_DataMap.hxx>
21
22 //! Reader of mtl files.
23 class RWObj_MtlReader
24 {
25 public:
26
27   //! Main constructor.
28   RWObj_MtlReader (NCollection_DataMap<TCollection_AsciiString, RWObj_Material>& theMaterials);
29
30   //! Destructor.
31   ~RWObj_MtlReader();
32
33   //! Read the file.
34   bool Read (const TCollection_AsciiString& theFolder,
35              const TCollection_AsciiString& theFile);
36
37 private:
38
39   //! Validate scalar value
40   bool validateScalar (const Standard_Real theValue);
41
42   //! Validate RGB color
43   bool validateColor (const Graphic3d_Vec3& theVec);
44
45   //! Process texture path.
46   void processTexturePath (TCollection_AsciiString& theTexturePath,
47                            const TCollection_AsciiString& theFolder);
48
49 private:
50
51   FILE* myFile;
52   TCollection_AsciiString myPath;
53   NCollection_DataMap<TCollection_AsciiString, RWObj_Material>* myMaterials;
54   int myNbLines;
55
56 };
57
58 #endif // _RWObj_MtlReader_HeaderFile