Commit 00bac43d authored by David Flynn's avatar David Flynn
Browse files

refactor: rename pcc::PCCVector3<T> to pcc::Vec3<T>

This is part of a series attempting to remove unhelpful typedefs.
parent 6980ddc2
...@@ -479,14 +479,14 @@ AttributeEncoder::encodeReflectancesPred( ...@@ -479,14 +479,14 @@ AttributeEncoder::encodeReflectancesPred(
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
PCCVector3<int64_t> Vec3<int64_t>
AttributeEncoder::computeColorResiduals( AttributeEncoder::computeColorResiduals(
const PCCColor3B color, const PCCColor3B color,
const PCCColor3B predictedColor, const PCCColor3B predictedColor,
const int64_t qs, const int64_t qs,
const int64_t qs2) const int64_t qs2)
{ {
PCCVector3<int64_t> residuals; Vec3<int64_t> residuals;
const int64_t quantAttValue = color[0]; const int64_t quantAttValue = color[0];
const int64_t quantPredAttValue = predictedColor[0]; const int64_t quantPredAttValue = predictedColor[0];
const int64_t delta = PCCQuantization(quantAttValue - quantPredAttValue, qs); const int64_t delta = PCCQuantization(quantAttValue - quantPredAttValue, qs);
...@@ -540,7 +540,7 @@ AttributeEncoder::computeColorPredictionWeights( ...@@ -540,7 +540,7 @@ AttributeEncoder::computeColorPredictionWeights(
// base case: weighted average of n neighbours // base case: weighted average of n neighbours
predictor.predMode = 0; predictor.predMode = 0;
PCCColor3B attrPred = predictor.predictColor(pointCloud, indexesLOD); PCCColor3B attrPred = predictor.predictColor(pointCloud, indexesLOD);
PCCVector3<int64_t> attrResidualQuant = Vec3<int64_t> attrResidualQuant =
computeColorResiduals(attrValue, attrPred, qs, qs2); computeColorResiduals(attrValue, attrPred, qs, qs2);
double best_score = attrResidualQuant[0] + attrResidualQuant[1] double best_score = attrResidualQuant[0] + attrResidualQuant[1]
......
...@@ -98,7 +98,7 @@ protected: ...@@ -98,7 +98,7 @@ protected:
PCCPointSet3& pointCloud, PCCPointSet3& pointCloud,
PCCResidualsEncoder& encoder); PCCResidualsEncoder& encoder);
static PCCVector3<int64_t> computeColorResiduals( static Vec3<int64_t> computeColorResiduals(
const PCCColor3B color, const PCCColor3B color,
const PCCColor3B predictedColor, const PCCColor3B predictedColor,
const int64_t qs, const int64_t qs,
......
...@@ -43,12 +43,12 @@ namespace pcc { ...@@ -43,12 +43,12 @@ namespace pcc {
void void
updateGeometryOccupancyAtlas( updateGeometryOccupancyAtlas(
const PCCVector3<uint32_t>& currentPosition, const Vec3<uint32_t>& currentPosition,
const int nodeSizeLog2, const int nodeSizeLog2,
const pcc::ringbuf<PCCOctree3Node>& fifo, const pcc::ringbuf<PCCOctree3Node>& fifo,
const pcc::ringbuf<PCCOctree3Node>::iterator& fifoCurrLvlEnd, const pcc::ringbuf<PCCOctree3Node>::iterator& fifoCurrLvlEnd,
MortonMap3D* occupancyAtlas, MortonMap3D* occupancyAtlas,
PCCVector3<uint32_t>* atlasOrigin) Vec3<uint32_t>* atlasOrigin)
{ {
const uint32_t mask = (1 << occupancyAtlas->cubeSizeLog2()) - 1; const uint32_t mask = (1 << occupancyAtlas->cubeSizeLog2()) - 1;
const int shift = occupancyAtlas->cubeSizeLog2() + nodeSizeLog2; const int shift = occupancyAtlas->cubeSizeLog2() + nodeSizeLog2;
...@@ -78,7 +78,7 @@ updateGeometryOccupancyAtlas( ...@@ -78,7 +78,7 @@ updateGeometryOccupancyAtlas(
void void
updateGeometryOccupancyAtlasOccChild( updateGeometryOccupancyAtlasOccChild(
const PCCVector3<uint32_t>& pos, const Vec3<uint32_t>& pos,
int nodeSizeLog2, int nodeSizeLog2,
uint8_t childOccupancy, uint8_t childOccupancy,
MortonMap3D* occupancyAtlas) MortonMap3D* occupancyAtlas)
...@@ -135,7 +135,7 @@ updatePatternFromNeighOccupancy( ...@@ -135,7 +135,7 @@ updatePatternFromNeighOccupancy(
GeometryNeighPattern GeometryNeighPattern
makeGeometryNeighPattern( makeGeometryNeighPattern(
bool adjacent_child_contextualization_enabled_flag, bool adjacent_child_contextualization_enabled_flag,
const PCCVector3<uint32_t>& position, const Vec3<uint32_t>& position,
const int nodeSizeLog2, const int nodeSizeLog2,
const MortonMap3D& occupancyAtlas) const MortonMap3D& occupancyAtlas)
{ {
......
...@@ -172,22 +172,22 @@ struct GeometryNeighPattern { ...@@ -172,22 +172,22 @@ struct GeometryNeighPattern {
// the neighbour pattern and derive external adjacency counts for each child. // the neighbour pattern and derive external adjacency counts for each child.
GeometryNeighPattern makeGeometryNeighPattern( GeometryNeighPattern makeGeometryNeighPattern(
bool adjacent_child_contextualization_enabled_flag, bool adjacent_child_contextualization_enabled_flag,
const PCCVector3<uint32_t>& currentPosition, const Vec3<uint32_t>& currentPosition,
const int nodeSizeLog2, const int nodeSizeLog2,
const MortonMap3D& occupancyAtlas); const MortonMap3D& occupancyAtlas);
// populate (if necessary) the occupancy atlas with occupancy information // populate (if necessary) the occupancy atlas with occupancy information
// from @fifo. // from @fifo.
void updateGeometryOccupancyAtlas( void updateGeometryOccupancyAtlas(
const PCCVector3<uint32_t>& position, const Vec3<uint32_t>& position,
const int nodeSizeLog2, const int nodeSizeLog2,
const ringbuf<PCCOctree3Node>& fifo, const ringbuf<PCCOctree3Node>& fifo,
const ringbuf<PCCOctree3Node>::iterator& fifoCurrLvlEnd, const ringbuf<PCCOctree3Node>::iterator& fifoCurrLvlEnd,
MortonMap3D* occupancyAtlas, MortonMap3D* occupancyAtlas,
PCCVector3<uint32_t>* atlasOrigin); Vec3<uint32_t>* atlasOrigin);
void updateGeometryOccupancyAtlasOccChild( void updateGeometryOccupancyAtlasOccChild(
const PCCVector3<uint32_t>& pos, const Vec3<uint32_t>& pos,
int nodeSizeLog2, int nodeSizeLog2,
uint8_t childOccupancy, uint8_t childOccupancy,
MortonMap3D* occupancyAtlas); MortonMap3D* occupancyAtlas);
......
...@@ -49,7 +49,7 @@ ...@@ -49,7 +49,7 @@
namespace pcc { namespace pcc {
/// Vector dim 3 /// Vector dim 3
template<typename T> template<typename T>
class PCCVector3 { class Vec3 {
public: public:
T* begin() { return &data[0]; } T* begin() { return &data[0]; }
const T* begin() const { return &data[0]; } const T* begin() const { return &data[0]; }
...@@ -87,54 +87,54 @@ public: ...@@ -87,54 +87,54 @@ public:
{ {
return std::max(data[2], std::max(abs(data[0]), abs(data[1]))); return std::max(data[2], std::max(abs(data[0]), abs(data[1])));
} }
PCCVector3& operator=(const PCCVector3& rhs) Vec3& operator=(const Vec3& rhs)
{ {
memcpy(data, rhs.data, sizeof(data)); memcpy(data, rhs.data, sizeof(data));
return *this; return *this;
} }
PCCVector3& operator+=(const PCCVector3& rhs) Vec3& operator+=(const Vec3& rhs)
{ {
data[0] += rhs.data[0]; data[0] += rhs.data[0];
data[1] += rhs.data[1]; data[1] += rhs.data[1];
data[2] += rhs.data[2]; data[2] += rhs.data[2];
return *this; return *this;
} }
PCCVector3& operator-=(const PCCVector3& rhs) Vec3& operator-=(const Vec3& rhs)
{ {
data[0] -= rhs.data[0]; data[0] -= rhs.data[0];
data[1] -= rhs.data[1]; data[1] -= rhs.data[1];
data[2] -= rhs.data[2]; data[2] -= rhs.data[2];
return *this; return *this;
} }
PCCVector3& operator-=(const T a) Vec3& operator-=(const T a)
{ {
data[0] -= a; data[0] -= a;
data[1] -= a; data[1] -= a;
data[2] -= a; data[2] -= a;
return *this; return *this;
} }
PCCVector3& operator+=(const T a) Vec3& operator+=(const T a)
{ {
data[0] += a; data[0] += a;
data[1] += a; data[1] += a;
data[2] += a; data[2] += a;
return *this; return *this;
} }
PCCVector3& operator<<=(int val) Vec3& operator<<=(int val)
{ {
data[0] <<= val; data[0] <<= val;
data[1] <<= val; data[1] <<= val;
data[2] <<= val; data[2] <<= val;
return *this; return *this;
} }
PCCVector3& operator>>=(int val) Vec3& operator>>=(int val)
{ {
data[0] >>= val; data[0] >>= val;
data[1] >>= val; data[1] >>= val;
data[2] >>= val; data[2] >>= val;
return *this; return *this;
} }
PCCVector3& operator/=(const T a) Vec3& operator/=(const T a)
{ {
assert(a != 0); assert(a != 0);
data[0] /= a; data[0] /= a;
...@@ -142,95 +142,83 @@ public: ...@@ -142,95 +142,83 @@ public:
data[2] /= a; data[2] /= a;
return *this; return *this;
} }
PCCVector3& operator*=(const T a) Vec3& operator*=(const T a)
{ {
data[0] *= a; data[0] *= a;
data[1] *= a; data[1] *= a;
data[2] *= a; data[2] *= a;
return *this; return *this;
} }
PCCVector3& operator=(const T a) Vec3& operator=(const T a)
{ {
data[0] = a; data[0] = a;
data[1] = a; data[1] = a;
data[2] = a; data[2] = a;
return *this; return *this;
} }
PCCVector3& operator=(const T* const rhs) Vec3& operator=(const T* const rhs)
{ {
data[0] = rhs[0]; data[0] = rhs[0];
data[1] = rhs[1]; data[1] = rhs[1];
data[2] = rhs[2]; data[2] = rhs[2];
return *this; return *this;
} }
T operator*(const PCCVector3& rhs) const T operator*(const Vec3& rhs) const
{ {
return ( return (
data[0] * rhs.data[0] + data[1] * rhs.data[1] + data[2] * rhs.data[2]); data[0] * rhs.data[0] + data[1] * rhs.data[1] + data[2] * rhs.data[2]);
} }
PCCVector3 operator-() const Vec3 operator-() const { return Vec3<T>(-data[0], -data[1], -data[2]); }
friend Vec3 operator+(const Vec3& lhs, const Vec3& rhs)
{ {
return PCCVector3<T>(-data[0], -data[1], -data[2]); return Vec3<T>(
}
friend PCCVector3 operator+(const PCCVector3& lhs, const PCCVector3& rhs)
{
return PCCVector3<T>(
lhs.data[0] + rhs.data[0], lhs.data[1] + rhs.data[1], lhs.data[0] + rhs.data[0], lhs.data[1] + rhs.data[1],
lhs.data[2] + rhs.data[2]); lhs.data[2] + rhs.data[2]);
} }
friend PCCVector3 operator+(const T lhs, const PCCVector3& rhs) friend Vec3 operator+(const T lhs, const Vec3& rhs)
{ {
return PCCVector3<T>( return Vec3<T>(lhs + rhs.data[0], lhs + rhs.data[1], lhs + rhs.data[2]);
lhs + rhs.data[0], lhs + rhs.data[1], lhs + rhs.data[2]);
} }
friend PCCVector3 operator+(const PCCVector3& lhs, const T rhs) friend Vec3 operator+(const Vec3& lhs, const T rhs)
{ {
return PCCVector3<T>( return Vec3<T>(lhs.data[0] + rhs, lhs.data[1] + rhs, lhs.data[2] + rhs);
lhs.data[0] + rhs, lhs.data[1] + rhs, lhs.data[2] + rhs);
} }
friend PCCVector3 operator-(const PCCVector3& lhs, const PCCVector3& rhs) friend Vec3 operator-(const Vec3& lhs, const Vec3& rhs)
{ {
return PCCVector3<T>( return Vec3<T>(
lhs.data[0] - rhs.data[0], lhs.data[1] - rhs.data[1], lhs.data[0] - rhs.data[0], lhs.data[1] - rhs.data[1],
lhs.data[2] - rhs.data[2]); lhs.data[2] - rhs.data[2]);
} }
friend PCCVector3 operator-(const T lhs, const PCCVector3& rhs) friend Vec3 operator-(const T lhs, const Vec3& rhs)
{ {
return PCCVector3<T>( return Vec3<T>(lhs - rhs.data[0], lhs - rhs.data[1], lhs - rhs.data[2]);
lhs - rhs.data[0], lhs - rhs.data[1], lhs - rhs.data[2]);
} }
friend PCCVector3 operator-(const PCCVector3& lhs, const T rhs) friend Vec3 operator-(const Vec3& lhs, const T rhs)
{ {
return PCCVector3<T>( return Vec3<T>(lhs.data[0] - rhs, lhs.data[1] - rhs, lhs.data[2] - rhs);
lhs.data[0] - rhs, lhs.data[1] - rhs, lhs.data[2] - rhs);
} }
friend PCCVector3 operator*(const T lhs, const PCCVector3& rhs) friend Vec3 operator*(const T lhs, const Vec3& rhs)
{ {
return PCCVector3<T>( return Vec3<T>(lhs * rhs.data[0], lhs * rhs.data[1], lhs * rhs.data[2]);
lhs * rhs.data[0], lhs * rhs.data[1], lhs * rhs.data[2]);
} }
friend PCCVector3 operator*(const PCCVector3& lhs, const T rhs) friend Vec3 operator*(const Vec3& lhs, const T rhs)
{ {
return PCCVector3<T>( return Vec3<T>(lhs.data[0] * rhs, lhs.data[1] * rhs, lhs.data[2] * rhs);
lhs.data[0] * rhs, lhs.data[1] * rhs, lhs.data[2] * rhs);
} }
friend PCCVector3 operator/(const PCCVector3& lhs, const T rhs) friend Vec3 operator/(const Vec3& lhs, const T rhs)
{ {
assert(rhs != 0); assert(rhs != 0);
return PCCVector3<T>( return Vec3<T>(lhs.data[0] / rhs, lhs.data[1] / rhs, lhs.data[2] / rhs);
lhs.data[0] / rhs, lhs.data[1] / rhs, lhs.data[2] / rhs);
} }
friend PCCVector3 operator<<(const PCCVector3& lhs, int val) friend Vec3 operator<<(const Vec3& lhs, int val)
{ {
return PCCVector3<T>( return Vec3<T>(lhs.data[0] << val, lhs.data[1] << val, lhs.data[2] << val);
lhs.data[0] << val, lhs.data[1] << val, lhs.data[2] << val);
} }
friend PCCVector3 operator>>(const PCCVector3& lhs, int val) friend Vec3 operator>>(const Vec3& lhs, int val)
{ {
return PCCVector3<T>( return Vec3<T>(lhs.data[0] >> val, lhs.data[1] >> val, lhs.data[2] >> val);
lhs.data[0] >> val, lhs.data[1] >> val, lhs.data[2] >> val);
} }
bool operator<(const PCCVector3& rhs) const bool operator<(const Vec3& rhs) const
{ {
if (data[0] == rhs.data[0]) { if (data[0] == rhs.data[0]) {
if (data[1] == rhs.data[1]) { if (data[1] == rhs.data[1]) {
...@@ -240,7 +228,7 @@ public: ...@@ -240,7 +228,7 @@ public:
} }
return (data[0] < rhs.data[0]); return (data[0] < rhs.data[0]);
} }
bool operator>(const PCCVector3& rhs) const bool operator>(const Vec3& rhs) const
{ {
if (data[0] == rhs.data[0]) { if (data[0] == rhs.data[0]) {
if (data[1] == rhs.data[1]) { if (data[1] == rhs.data[1]) {
...@@ -250,43 +238,43 @@ public: ...@@ -250,43 +238,43 @@ public:
} }
return (data[0] > rhs.data[0]); return (data[0] > rhs.data[0]);
} }
bool operator==(const PCCVector3& rhs) const bool operator==(const Vec3& rhs) const
{ {
return ( return (
data[0] == rhs.data[0] && data[1] == rhs.data[1] data[0] == rhs.data[0] && data[1] == rhs.data[1]
&& data[2] == rhs.data[2]); && data[2] == rhs.data[2]);
} }
bool operator!=(const PCCVector3& rhs) const bool operator!=(const Vec3& rhs) const
{ {
return ( return (
data[0] != rhs.data[0] || data[1] != rhs.data[1] data[0] != rhs.data[0] || data[1] != rhs.data[1]
|| data[2] != rhs.data[2]); || data[2] != rhs.data[2]);
} }
friend std::ostream& operator<<(std::ostream& os, const PCCVector3& vec) friend std::ostream& operator<<(std::ostream& os, const Vec3& vec)
{ {
os << vec[0] << " " << vec[1] << " " << vec[2] << std::endl; os << vec[0] << " " << vec[1] << " " << vec[2] << std::endl;
return os; return os;
} }
friend std::istream& operator>>(std::istream& is, PCCVector3& vec) friend std::istream& operator>>(std::istream& is, Vec3& vec)
{ {
is >> vec[0] >> vec[1] >> vec[2]; is >> vec[0] >> vec[1] >> vec[2];
return is; return is;
} }
PCCVector3(const T a) { data[0] = data[1] = data[2] = a; } Vec3(const T a) { data[0] = data[1] = data[2] = a; }
PCCVector3(const T x, const T y, const T z) Vec3(const T x, const T y, const T z)
{ {
data[0] = x; data[0] = x;
data[1] = y; data[1] = y;
data[2] = z; data[2] = z;
} }
PCCVector3(const PCCVector3& vec) Vec3(const Vec3& vec)
{ {
data[0] = vec.data[0]; data[0] = vec.data[0];
data[1] = vec.data[1]; data[1] = vec.data[1];
data[2] = vec.data[2]; data[2] = vec.data[2];
} }
PCCVector3() = default; Vec3() = default;
~PCCVector3(void) = default; ~Vec3(void) = default;
private: private:
T data[3]; T data[3];
...@@ -294,9 +282,9 @@ private: ...@@ -294,9 +282,9 @@ private:
template<typename T> template<typename T>
struct PCCBox3 { struct PCCBox3 {
PCCVector3<T> min; Vec3<T> min;
PCCVector3<T> max; Vec3<T> max;
bool contains(const PCCVector3<T> point) const bool contains(const Vec3<T> point) const
{ {
return !( return !(
point.x() < min.x() || point.x() > max.x() || point.y() < min.y() point.x() < min.x() || point.x() > max.x() || point.y() < min.y()
...@@ -321,7 +309,7 @@ struct PCCBox3 { ...@@ -321,7 +309,7 @@ struct PCCBox3 {
&& max.z() >= box.min.z() && min.z() <= box.max.z(); && max.z() >= box.min.z() && min.z() <= box.max.z();
} }
T getDist2(const PCCVector3<T>& point) const T getDist2(const Vec3<T>& point) const
{ {
const T dx = std::max(std::max(min[0] - point[0], 0.0), point[0] - max[0]); const T dx = std::max(std::max(min[0] - point[0], 0.0), point[0] - max[0]);
const T dy = std::max(std::max(min[1] - point[1], 0.0), point[1] - max[1]); const T dy = std::max(std::max(min[1] - point[1], 0.0), point[1] - max[1]);
...@@ -343,12 +331,10 @@ struct PCCBox3 { ...@@ -343,12 +331,10 @@ struct PCCBox3 {
} }
}; };
typedef PCCVector3<double> PCCVector3D; typedef Vec3<double> PCCVector3D;
typedef PCCVector3<double> PCCPoint3D; typedef Vec3<double> PCCPoint3D;
typedef PCCBox3<double> PCCBox3D; typedef PCCBox3<double> PCCBox3D;
typedef PCCVector3<uint8_t> PCCColor3B; typedef Vec3<uint8_t> PCCColor3B;
template<typename T>
using Vec3 = PCCVector3<T>;
template<typename T> template<typename T>
T T
...@@ -384,7 +370,7 @@ mortonAddr(const int32_t x, const int32_t y, const int32_t z) ...@@ -384,7 +370,7 @@ mortonAddr(const int32_t x, const int32_t y, const int32_t z)
template<typename T> template<typename T>
uint64_t uint64_t
mortonAddr(const PCCVector3<T>& vec, int depth) mortonAddr(const Vec3<T>& vec, int depth)
{ {
int x = int(vec.x()) >> depth; int x = int(vec.x()) >> depth;
int y = int(vec.y()) >> depth; int y = int(vec.y()) >> depth;
......
...@@ -58,19 +58,19 @@ namespace pcc { ...@@ -58,19 +58,19 @@ namespace pcc {
inline void inline void
quantizePositionsUniq( quantizePositionsUniq(
const float scaleFactor, const float scaleFactor,
const PCCVector3<int> offset, const Vec3<int> offset,
const PCCBox3<int> clamp, const PCCBox3<int> clamp,
const PCCPointSet3& src, const PCCPointSet3& src,