File indexing completed on 2026-10-02 09:12:28
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 <NCollection_Vec2.hxx>
0018 #include <Standard_TypeDef.hxx>
0019 #include <Standard_Integer.hxx>
0020 #include <Standard_OStream.hxx>
0021
0022
0023 class Graphic3d_CameraTile
0024 {
0025 public:
0026 NCollection_Vec2<int> TotalSize;
0027 NCollection_Vec2<int> TileSize;
0028
0029 NCollection_Vec2<int> Offset;
0030 bool IsTopDown;
0031
0032
0033 public:
0034
0035
0036
0037 Graphic3d_CameraTile()
0038 : IsTopDown(false)
0039 {
0040 }
0041
0042
0043 bool IsValid() const
0044 {
0045 return TotalSize.x() > 0 && TotalSize.y() > 0 && TileSize.x() > 0 && TileSize.y() > 0;
0046 }
0047
0048
0049 NCollection_Vec2<int> OffsetLowerLeft() const
0050 {
0051 return NCollection_Vec2<int>(Offset.x(),
0052 !IsTopDown ? Offset.y() : 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() = (std::max)(Offset.x(), 0);
0065 aTile.Offset.y() = (std::max)(Offset.y(), 0);
0066
0067 const int anX = (std::min)(Offset.x() + TileSize.x(), TotalSize.x());
0068 const int anY = (std::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 NCollection_Vec2<int> anOffset1 = OffsetLowerLeft();
0078 const NCollection_Vec2<int> anOffset2 = theOther.OffsetLowerLeft();
0079 return TotalSize.x() == theOther.TotalSize.x() && TotalSize.y() == theOther.TotalSize.y()
0080 && TileSize.x() == theOther.TileSize.x() && TileSize.y() == theOther.TileSize.y()
0081 && anOffset1.x() == anOffset2.x() && anOffset1.y() == anOffset2.y();
0082 }
0083
0084
0085 Standard_EXPORT void DumpJson(Standard_OStream& theOStream, int theDepth = -1) const;
0086 };
0087
0088 #endif