File indexing completed on 2025-01-18 10:03:47
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014 #ifndef _Graphic3d_CameraTile_HeaderFile
0015 #define _Graphic3d_CameraTile_HeaderFile
0016
0017 #include <Graphic3d_Vec2.hxx>
0018 #include <Standard_Integer.hxx>
0019 #include <Standard_OStream.hxx>
0020 #include <Standard_TypeDef.hxx>
0021
0022
0023 class Graphic3d_CameraTile
0024 {
0025 public:
0026
0027 Graphic3d_Vec2i TotalSize;
0028 Graphic3d_Vec2i TileSize;
0029 Graphic3d_Vec2i Offset;
0030 bool IsTopDown;
0031
0032 public:
0033
0034
0035
0036
0037 Graphic3d_CameraTile() : IsTopDown (false) {}
0038
0039
0040 bool IsValid() const
0041 {
0042 return TotalSize.x() > 0 && TotalSize.y() > 0
0043 && TileSize.x() > 0 && TileSize.y() > 0;
0044 }
0045
0046
0047 Graphic3d_Vec2i OffsetLowerLeft() const
0048 {
0049 return Graphic3d_Vec2i (Offset.x(),
0050 !IsTopDown
0051 ? Offset.y()
0052 : TotalSize.y() - Offset.y() - 1);
0053 }
0054
0055
0056 Graphic3d_CameraTile Cropped() const
0057 {
0058 Graphic3d_CameraTile aTile = *this;
0059 if (!IsValid())
0060 {
0061 return aTile;
0062 }
0063
0064 aTile.Offset.x() = Max (Offset.x(), 0);
0065 aTile.Offset.y() = Max (Offset.y(), 0);
0066
0067 const Standard_Integer anX = Min (Offset.x() + TileSize.x(), TotalSize.x());
0068 const Standard_Integer anY = Min (Offset.y() + TileSize.y(), TotalSize.y());
0069 aTile.TileSize.x() = anX - Offset.x();
0070 aTile.TileSize.y() = anY - Offset.y();
0071 return aTile;
0072 }
0073
0074
0075 bool operator== (const Graphic3d_CameraTile& theOther) const
0076 {
0077 const Graphic3d_Vec2i anOffset1 = OffsetLowerLeft();
0078 const Graphic3d_Vec2i anOffset2 = theOther.OffsetLowerLeft();
0079 return TotalSize.x() == theOther.TotalSize.x()
0080 && TotalSize.y() == theOther.TotalSize.y()
0081 && TileSize.x() == theOther.TileSize.x()
0082 && TileSize.y() == theOther.TileSize.y()
0083 && anOffset1.x() == anOffset2.x()
0084 && anOffset1.y() == anOffset2.y();
0085 }
0086
0087
0088 Standard_EXPORT void DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth = -1) const;
0089
0090 };
0091
0092 #endif