1 // Author: Ilya Khramov
2 // Copyright (c) 2019 OPEN CASCADE SAS
4 // This file is part of Open CASCADE Technology software library.
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.
12 // Alternatively, this file may be used under the terms of Open CASCADE
13 // commercial license or contractual agreement.
15 #ifndef _Graphic3d_CubeMapPacked_HeaderFile
16 #define _Graphic3d_CubeMapPacked_HeaderFile
18 #include <Graphic3d_CubeMap.hxx>
19 #include <NCollection_Array1.hxx>
20 #include <OSD_Path.hxx>
22 //! Class is intended to process cubemap packed into single image plane.
23 class Graphic3d_CubeMapPacked : public Graphic3d_CubeMap
25 DEFINE_STANDARD_RTTIEXT(Graphic3d_CubeMapPacked, Graphic3d_CubeMap)
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());
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());
40 //! Returns current cubemap side as compressed PixMap.
41 Standard_EXPORT virtual Handle(Image_CompressedPixMap) CompressedValue (const Handle(Image_SupportedFormats)& theSupported) Standard_OVERRIDE;
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;
50 ~Graphic3d_CubeMapPacked() {}
54 //! Checks whether given tiles order is valid.
55 static Standard_Boolean checkOrder (const NCollection_Array1<unsigned int>& theOrder);
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);
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);
68 Graphic3d_CubeMapOrder myOrder; //!< order mapping tile grit to cubemap sides
69 unsigned int myTileNumberX; //!< width of tile grid
73 DEFINE_STANDARD_HANDLE(Graphic3d_CubeMapPacked, Graphic3d_CubeMap)
75 #endif // _Graphic3d_CubeMapPacked_HeaderFile