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 };
#define CV_IO_LIB_API
Definition: CV_io.h:15
std::string name
Hierarchical CLOUDVIEWER Object.
Definition: ecvHObject.h:25
static void StoreShift(const CCVector3d &shift, double scale, bool preserve=true)
Adds a new shift / scale couple.
static bool Handle(const CCVector3d &P, double diagonal, Mode mode, bool useInputCoordinatesShiftIfPossible, CCVector3d &coordinatesShift, bool *preserveCoordinateShift, double *coordinatesScale, bool *applyAll=0)
static double MaxCoordinateAbsValue()
Returns the max coordinate (absolute) value.
static bool NeedShift(double d)
Returns whether a particular point coordinate is too big or not.
static bool GetLast(std::vector< ShiftInfo > &infos)
static bool GetLast(ShiftInfo &info)
static void SetMaxCoordinateAbsValue(double value)
Sets the max coordinate (absolute) value.
static void SetMaxBoundgBoxDiagonal(double value)
Sets the max bounding-box diagonal.
static bool NeedShift(const CCVector3d &P)
Returns whether a particular point (coordinates) is too big or not.
static CCVector3d BestShift(const CCVector3d &P)
Suggests a shift for a given point expressed in global coordinate space.
static bool NeedRescale(double d)
Returns whether a particular dimension (e.g. diagonal) is too big or not.
Mode
Strategy to handle coordinates shift/scale.
static double MaxBoundgBoxDiagonal()
Returns max bounding-box diagonal.
static double MAX_COORDINATE_ABS_VALUE
static double BestScale(double d)
ShiftInfo(QString str=QString("unnamed"))
Default constructor.
ShiftInfo(QString str, const CCVector3d &T, double s=1.0)
Constructor from a vector and a scale value.