ImagingTools Core SDK
CPointsBasedObject.h
1// SPDX-License-Identifier: LGPL-2.1-or-later OR GPL-2.0-or-later OR GPL-3.0-or-later OR LicenseRef-ImtCore-Commercial
2#pragma once
3
4
5// STL includes
6#include <vector>
7
8// ACF includes
9#include <istd/TRange.h>
10
11// ImtCore includes
12#include <imt3d/IPointsBasedObject.h>
13
14
15namespace imt3d
16{
17
18
23{
24public:
26
27 // reimplemented (imt3d::IPointsBasedObject)
28 virtual PointFormat GetPointFormat() const override;
29 virtual int GetPointsCount() const override;
30 virtual const void* GetPointData(int pointIndex) const override;
31 virtual void* GetPointData(int pointIndex) override;
32 virtual void* GetData() override;
33 virtual const void* GetData() const override;
34 virtual int GetPointBytesSize() const override;
35
36
37 // reimplemented (imt3d::IObject3d)
38 virtual bool IsEmpty() const override;
39 virtual i3d::CVector3d GetCenter() const override;
40 virtual void MoveCenterTo(const i3d::CVector3d& position) override;
41 virtual CCuboid GetBoundingCuboid() const override;
42
43 // reimplemented (iser::ISerializable)
44 virtual bool Serialize(iser::IArchive& archive) override;
45
46 // reimplemented (istd::IChangeable)
47 virtual int GetSupportedOperations() const override;
48 virtual bool CopyFrom(const IChangeable& object, CompatibilityMode mode = CM_WITHOUT_REFS) override;
49 virtual bool IsEqual(const IChangeable& object) const override;
50 virtual istd::IChangeableUniquePtr CloneMe(CompatibilityMode mode = CM_WITHOUT_REFS) const override;
51 virtual bool ResetData(CompatibilityMode mode = CM_WITHOUT_REFS) override;
52
53protected:
54 bool Create(PointFormat pointFormat);
55 bool Create(PointFormat pointFormat, int pointsCount, const void* dataPtr);
56 bool Append(int pointsCount, const void* dataPtr);
57 int GetDataSize() const;
58 void EnsureCenterCalculated() const;
59 void EnsureCuboidCalculated() const;
60
61 template <typename PointType> const PointType*
62 TGetPointData(int pointIndex, bool validOnly = false) const;
63 template <typename PointType> PointType*
64 TGetPointData(int pointIndex, bool validOnly = false);
65 template <typename PointType> bool TIsPointValid(const PointType& pointData) const;
66 template <typename PointType> void TEnsureCenterCalculated() const;
67 template <typename PointType> void TEnsureCuboidCalculated() const;
68 template <typename PointType> void TMoveCenterTo(const i3d::CVector3d& position);
69 template <typename PointType> void GetBoundingRanges(istd::CRange& xRange, istd::CRange& yRange, istd::CRange& zRange) const;
70
71 // reimplemented (istd::IChangeable)
72 virtual void OnEndChanges(const ChangeSet& changes) override;
73
74protected:
75 static int GetPointBytesSize(PointFormat pointFormat);
76 static int GetBufferSize(PointFormat pointFormat, int pointsCount);
77
78protected:
79 std::vector<uint8_t> m_data;
80 PointFormat m_pointFormat;
81 int m_pointsCount;
82
83 mutable i3d::CVector3d m_cloudCenter;
84 mutable CCuboid m_boundingCuboid;
85 mutable bool m_isCenterCalculationValid;
86 mutable bool m_isCuboidCalculationValid;
87};
88
89
90} // namespace imt3d
91
92