0030640: Visualization, Graphic3d_Camera - add option creating Projection matrix...
[occt.git] / src / Graphic3d / Graphic3d_CubeMapPacked.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_CubeMapPacked_HeaderFile
16 #define _Graphic3d_CubeMapPacked_HeaderFile
17
18 #include <Graphic3d_CubeMap.hxx>
19 #include <NCollection_Array1.hxx>
20 #include <OSD_Path.hxx>
21
22 //! Class is intended to process cubemap packed into single image plane.
23 class Graphic3d_CubeMapPacked : public Graphic3d_CubeMap
24 {
25   DEFINE_STANDARD_RTTIEXT(Graphic3d_CubeMapPacked, Graphic3d_CubeMap)
26 public:
27
28   //! Initialization to load cubemap from file.
29   //! @theFileName - path to the cubemap image
30   //! @theOrder - array containing six different indexes of cubemap sides which maps tile grid to cubemap sides
31   Standard_EXPORT Graphic3d_CubeMapPacked (const TCollection_AsciiString&        theFileName,
32                                            const Graphic3d_ValidatedCubeMapOrder theOrder = Graphic3d_CubeMapOrder::Default());
33
34   //! Initialization to set cubemap directly by PixMap.
35   //! @thePixMap - origin PixMap
36   //! @theOrder - array containing six different indexes of cubemap sides which maps tile grid to cubemap sides
37   Standard_EXPORT Graphic3d_CubeMapPacked (const Handle(Image_PixMap)&           theImage,
38                                            const Graphic3d_ValidatedCubeMapOrder theOrder = Graphic3d_CubeMapOrder::Default());
39
40   //! Returns current cubemap side as compressed PixMap.
41   Standard_EXPORT virtual Handle(Image_CompressedPixMap) CompressedValue (const Handle(Image_SupportedFormats)& theSupported) Standard_OVERRIDE;
42
43   //! Returns current cubemap side as PixMap.
44   //! Resulting PixMap is memory wrapper over original image.
45   //! Returns null handle if current side or whole cubemap is invalid.
46   //! Origin image has to contain six quad tiles having one sizes without any gaps to be valid.  
47   Standard_EXPORT virtual Handle(Image_PixMap) Value (const Handle(Image_SupportedFormats)& theSupported) Standard_OVERRIDE;
48
49   //! Empty destructor.
50   ~Graphic3d_CubeMapPacked() {}
51
52 private:
53
54   //! Checks whether given tiles order is valid.
55   static Standard_Boolean checkOrder (const NCollection_Array1<unsigned int>& theOrder);
56
57   //! Checks whether given pixmap is valid to contain six tiles.
58   static Standard_Boolean checkImage (const Handle(Image_PixMap)& theImage,
59                                       unsigned int&               theTileNumberX);
60
61   //! Tries to load image from file and checks it after that.
62   //! Does nothing in case of fail.
63   void tryLoadImage (const Handle(Image_SupportedFormats)& theSupported,
64                      const TCollection_AsciiString &theFilePath);
65
66 protected:
67
68   Graphic3d_CubeMapOrder myOrder;       //!< order mapping tile grit to cubemap sides
69   unsigned int           myTileNumberX; //!< width of tile grid
70
71 };
72
73 DEFINE_STANDARD_HANDLE(Graphic3d_CubeMapPacked, Graphic3d_CubeMap)
74
75 #endif // _Graphic3d_CubeMapPacked_HeaderFile