0031642: Visualization - crash in Graphic3d_Structure::SetVisual() on redisplaying...
[occt.git] / src / Graphic3d / Graphic3d_CubeMapSeparate.hxx
1 // Author: Ilya Khramov
2 // Copyright (c) 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 _Graphic3d_CubeMapSeparate_HeaderFile
16 #define _Graphic3d_CubeMapSeparate_HeaderFile
17
18 #include <Graphic3d_CubeMap.hxx>
19 #include <NCollection_Array1.hxx>
20 #include <OSD_Path.hxx>
21
22 //! Class to manage cubemap located in six different images.
23 class Graphic3d_CubeMapSeparate : public Graphic3d_CubeMap
24 {
25   DEFINE_STANDARD_RTTIEXT(Graphic3d_CubeMapSeparate, Graphic3d_CubeMap)
26 public:
27
28   //! Initializes cubemap to be loaded from file.
29   //! @thePaths - array of paths to separate image files (has to have size equal 6).
30   Standard_EXPORT Graphic3d_CubeMapSeparate (const NCollection_Array1<TCollection_AsciiString>& thePaths);
31
32   //! Initializes cubemap to be setted directly from PixMaps.
33   //! @theImages - array if PixMaps (has to have size equal 6).
34   Standard_EXPORT Graphic3d_CubeMapSeparate(const NCollection_Array1<Handle(Image_PixMap)>& theImages);
35
36   //! Returns current cubemap side as compressed PixMap.
37   Standard_EXPORT virtual Handle(Image_CompressedPixMap) CompressedValue (const Handle(Image_SupportedFormats)& theSupported) Standard_OVERRIDE;
38
39   //! Returns current side of cubemap as PixMap.
40   //! Returns null handle if current side or whole cubemap is invalid.
41   //! All origin images have to have the same sizes, format and quad shapes to form valid cubemap.
42   Standard_EXPORT virtual Handle(Image_PixMap) Value (const Handle(Image_SupportedFormats)& theSupported) Standard_OVERRIDE;
43
44   //! Returns NULL.
45   virtual Handle(Image_PixMap) GetImage (const Handle(Image_SupportedFormats)& ) Standard_OVERRIDE
46   {
47     return Handle(Image_PixMap)();
48   }
49
50   //! Checks if a texture class is valid or not.
51   //! Returns true if the construction of the class is correct.
52   Standard_EXPORT Standard_Boolean IsDone() const Standard_OVERRIDE;
53
54   //! Empty destructor.
55   ~Graphic3d_CubeMapSeparate() {}
56
57 protected:
58
59   OSD_Path             myPaths[6];  //!< array of paths to cubemap images
60   Handle(Image_PixMap) myImages[6]; //!< array of cubemap images
61
62   Standard_Size        mySize;      //!< size of each side of cubemap
63   Image_Format         myFormat;    //!< format each side of cubemap
64
65 private:
66
67   //! Nulifies whole images array.
68   void resetImages();
69
70 };
71
72 DEFINE_STANDARD_HANDLE(Graphic3d_CubeMapSeparate, Graphic3d_CubeMap)
73
74 #endif // _Graphic3d_CubeMapSeparate_HeaderFile