ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
ecvGlobalShiftManager.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 // CV_CORE_LIB
11 #include <CVGeom.h>
12 
13 // LOCAL
14 #include "CV_io.h"
15 
16 // Qt
17 #include <QString>
18 
19 // STL
20 #include <vector>
21 
22 class ccHObject;
23 
27 public:
29  enum Mode {
33  ALWAYS_DISPLAY_DIALOG
34  };
35 
38  static bool Handle(const CCVector3d& P,
39  double diagonal,
40  Mode mode,
41  bool useInputCoordinatesShiftIfPossible,
42  CCVector3d& coordinatesShift,
43  bool* preserveCoordinateShift,
44  double* coordinatesScale,
45  bool* applyAll = 0);
46 
48  static bool NeedShift(const CCVector3d& P);
50  static bool NeedShift(double d);
52  static bool NeedRescale(double d);
53 
55  static CCVector3d BestShift(const CCVector3d& P);
58  static double BestScale(double d);
59 
61  static double MaxCoordinateAbsValue() { return MAX_COORDINATE_ABS_VALUE; }
63  static void SetMaxCoordinateAbsValue(double value) {
64  MAX_COORDINATE_ABS_VALUE = value;
65  }
66 
68  static double MaxBoundgBoxDiagonal() { return MAX_DIAGONAL_LENGTH; }
70  static void SetMaxBoundgBoxDiagonal(double value) {
71  MAX_DIAGONAL_LENGTH = value;
72  }
73 
75  static void StoreShift(const CCVector3d& shift,
76  double scale,
77  bool preserve = true);
78 
79 public: // Shift and scale info
81  struct ShiftInfo {
83  double scale;
84  QString name;
85  bool preserve;
86 
88  ShiftInfo(QString str = QString("unnamed"))
89  : shift(0, 0, 0), scale(1.0), name(str), preserve(true) {}
91  ShiftInfo(QString str, const CCVector3d& T, double s = 1.0)
92  : shift(T), scale(s), name(str), preserve(true) {}
93  };
94 
95  static bool GetLast(ShiftInfo& info);
96  static bool GetLast(std::vector<ShiftInfo>& infos);
97 
98 protected:
99  // Max acceptable coordinate value
101 
102  // Max acceptable diagonal length
103  static double MAX_DIAGONAL_LENGTH;
104 };
ecvGlobalShiftManager::SetMaxBoundgBoxDiagonal
static void SetMaxBoundgBoxDiagonal(double value)
Sets the max bounding-box diagonal.
Definition: ecvGlobalShiftManager.h:70
ecvGlobalShiftManager::ShiftInfo::shift
CCVector3d shift
Definition: ecvGlobalShiftManager.h:82
ecvGlobalShiftManager::NO_DIALOG_AUTO_SHIFT
@ NO_DIALOG_AUTO_SHIFT
Definition: ecvGlobalShiftManager.h:31
ecvGlobalShiftManager::ShiftInfo
Shift and scale info.
Definition: ecvGlobalShiftManager.h:81
ecvGlobalShiftManager::MaxBoundgBoxDiagonal
static double MaxBoundgBoxDiagonal()
Returns max bounding-box diagonal.
Definition: ecvGlobalShiftManager.h:68
Vector3Tpl< double >
CV_io.h
ecvGlobalShiftManager::ShiftInfo::ShiftInfo
ShiftInfo(QString str, const CCVector3d &T, double s=1.0)
Constructor from a vector and a scale value.
Definition: ecvGlobalShiftManager.h:91
CVGeom.h
CV_IO_LIB_API
#define CV_IO_LIB_API
Definition: CV_io.h:15
ecvGlobalShiftManager::SetMaxCoordinateAbsValue
static void SetMaxCoordinateAbsValue(double value)
Sets the max coordinate (absolute) value.
Definition: ecvGlobalShiftManager.h:63
ecvGlobalShiftManager::NO_DIALOG
@ NO_DIALOG
Definition: ecvGlobalShiftManager.h:30
ecvGlobalShiftManager::MAX_COORDINATE_ABS_VALUE
static double MAX_COORDINATE_ABS_VALUE
Definition: ecvGlobalShiftManager.h:100
ecvGlobalShiftManager::MaxCoordinateAbsValue
static double MaxCoordinateAbsValue()
Returns the max coordinate (absolute) value.
Definition: ecvGlobalShiftManager.h:61
ecvGlobalShiftManager::ShiftInfo::preserve
bool preserve
Definition: ecvGlobalShiftManager.h:85
ecvGlobalShiftManager::DIALOG_IF_NECESSARY
@ DIALOG_IF_NECESSARY
Definition: ecvGlobalShiftManager.h:32
ccHObject
Hierarchical CLOUDVIEWER Object.
Definition: ecvHObject.h:25
ecvGlobalShiftManager::Mode
Mode
Strategy to handle coordinates shift/scale.
Definition: ecvGlobalShiftManager.h:29
ecvGlobalShiftManager::ShiftInfo::scale
double scale
Definition: ecvGlobalShiftManager.h:83
ecvGlobalShiftManager::MAX_DIAGONAL_LENGTH
static double MAX_DIAGONAL_LENGTH
Definition: ecvGlobalShiftManager.h:103
ecvGlobalShiftManager::ShiftInfo::name
QString name
Definition: ecvGlobalShiftManager.h:84
ecvGlobalShiftManager
Definition: ecvGlobalShiftManager.h:26
ecvGlobalShiftManager::ShiftInfo::ShiftInfo
ShiftInfo(QString str=QString("unnamed"))
Default constructor.
Definition: ecvGlobalShiftManager.h:88
name
std::string name
Definition: FileIOFactory.cpp:129