ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
ecvShiftedObject.h
Go to the documentation of this file.
1 // ----------------------------------------------------------------------------
2 // - CloudViewer: www.cloudViewer.org -
3 // ----------------------------------------------------------------------------
4 // Copyright (c) 2018-2024 www.cloudViewer.org
5 // SPDX-License-Identifier: MIT
6 // ----------------------------------------------------------------------------
7 
8 #pragma once
9 
10 // Local
11 #include "ecvHObject.h"
12 
14 
19 public:
21  ccShiftedObject(QString name = QString());
24 
26 
28  void copyGlobalShiftAndScale(const ccShiftedObject& s);
29 
31 
33  virtual inline void setGlobalShift(double x, double y, double z) {
34  return setGlobalShift(CCVector3d(x, y, z));
35  }
36 
38 
41  virtual void setGlobalShift(const CCVector3d& shift);
42 
44 
46  virtual const CCVector3d& getGlobalShift() const { return m_globalShift; }
47 
50  virtual void setGlobalScale(double scale);
51 
53  virtual double getGlobalScale() const { return m_globalScale; }
54 
56  inline bool isShifted() const {
57  const CCVector3d& globalShift = getGlobalShift();
58  return (globalShift.x != 0 || globalShift.y != 0 ||
59  globalShift.z != 0 || getGlobalScale() != 1.0);
60  }
61 
63  template <typename T>
64  inline CCVector3d toGlobal3d(const Vector3Tpl<T>& Plocal) const {
65  // Pglobal = Plocal/scale - shift
66  return Plocal.toDouble() / getGlobalScale() - getGlobalShift();
67  }
68 
70  template <typename T>
71  inline CCVector3d toLocal3d(const Vector3Tpl<T>& Pglobal) const {
72  // Plocal = (Pglobal + shift) * scale
73  return (Pglobal.toDouble() + getGlobalShift()) * getGlobalScale();
74  }
76  template <typename T>
77  inline CCVector3 toLocal3pc(const Vector3Tpl<T>& Pglobal) const {
78  CCVector3d Plocal =
79  Pglobal.toDouble() * getGlobalScale() + getGlobalShift();
80  return Plocal.toPC();
81  }
82 
83  // inherited from ccHObject
84  bool getOwnGlobalBB(CCVector3d& minCorner, CCVector3d& maxCorner) override;
85  GlobalBoundingBox getOwnGlobalBB(bool withGLFeatures = false) override;
86 
87 protected:
89  bool saveShiftInfoToFile(QFile& out) const;
91  bool loadShiftInfoFromFile(QFile& in);
92 
95 
97  double m_globalScale;
98 };
x
normal_z x
Definition: my_point_types.h:165
Tuple3Tpl::x
Type x
Definition: CVGeom.h:137
ccShiftedObject::m_globalScale
double m_globalScale
Global scale (typically applied at loading time)
Definition: ecvShiftedObject.h:97
ccShiftedObject::isShifted
bool isShifted() const
Returns whether the cloud is shifted or not.
Definition: ecvShiftedObject.h:56
ccHObject::getOwnGlobalBB
virtual GlobalBoundingBox getOwnGlobalBB(bool withGLFeatures=false)
Definition: ecvHObject.cpp:1654
Vector3Tpl::toPC
Vector3Tpl< PointCoordinateType > toPC() const
Definition: CVGeom.h:263
CCVector3d
Vector3Tpl< double > CCVector3d
Double 3D Vector.
Definition: CVGeom.h:804
ccShiftedObject::getGlobalShift
virtual const CCVector3d & getGlobalShift() const
Returns the shift applied to original coordinates.
Definition: ecvShiftedObject.h:46
y
normal_z y
Definition: my_point_types.h:168
Vector3Tpl::toDouble
Vector3Tpl< double > toDouble() const
Cast operator to a double vector (explicit call version)
Definition: CVGeom.h:255
Vector3Tpl< double >
ccShiftedObject::toLocal3pc
CCVector3 toLocal3pc(const Vector3Tpl< T > &Pglobal) const
Returns the point projected into the local (shifted) coordinates system.
Definition: ecvShiftedObject.h:77
ccShiftedObject::m_globalShift
CCVector3d m_globalShift
Global shift (typically applied at loading time)
Definition: ecvShiftedObject.h:94
ccShiftedObject
Shifted entity interface.
Definition: ecvShiftedObject.h:18
Tuple3Tpl::z
Type z
Definition: CVGeom.h:137
ccShiftedObject::toGlobal3d
CCVector3d toGlobal3d(const Vector3Tpl< T > &Plocal) const
Returns the point back-projected into the original coordinates system.
Definition: ecvShiftedObject.h:64
ccShiftedObject::toLocal3d
CCVector3d toLocal3d(const Vector3Tpl< T > &Pglobal) const
Returns the point projected into the local (shifted) coordinates system.
Definition: ecvShiftedObject.h:71
ccShiftedObject::getGlobalScale
virtual double getGlobalScale() const
Returns the scale applied to original coordinates.
Definition: ecvShiftedObject.h:53
ccShiftedObject::setGlobalShift
virtual void setGlobalShift(double x, double y, double z)
Sets shift applied to original coordinates (information storage only)
Definition: ecvShiftedObject.h:33
ccHObject
Hierarchical CLOUDVIEWER Object.
Definition: ecvHObject.h:25
Tuple3Tpl::y
Type y
Definition: CVGeom.h:137
CV_DB_LIB_API
#define CV_DB_LIB_API
Definition: CV_db.h:15
z
normal_z z
Definition: my_point_types.h:165
ecvHObject.h
name
std::string name
Definition: FileIOFactory.cpp:129