28 if (scale == 1.0 && shift.
norm2d() == 0) {
34 if (shiftInfo.scale == scale &&
35 (shiftInfo.shift - shift).norm2d() == 0) {
62 }
catch (
const std::bad_alloc&) {
63 CVLog::Warning(
"[ecvGlobalShiftManager::GetLast] Not enough memory");
85 bool useInputCoordinatesShiftIfPossible,
87 bool* preserveCoordinateShift,
88 double* coordinatesScale,
90 assert(diagonal >= 0);
91 if (preserveCoordinateShift) {
92 *preserveCoordinateShift =
true;
108 if (mode ==
NO_DIALOG && !useInputCoordinatesShiftIfPossible) {
110 if (coordinatesScale) {
111 *coordinatesScale = 1.0;
113 if (preserveCoordinateShift) {
114 *preserveCoordinateShift =
false;
117 if (needShift || needRescale) {
119 "[ecvGlobalShiftManager] Entity has very big coordinates: "
120 "original accuracy may be lost! (you should apply a Global "
128 if (needShift || useInputCoordinatesShiftIfPossible || needRescale ||
132 if (useInputCoordinatesShiftIfPossible &&
137 || (!
NeedShift(P * scale + coordinatesShift) &&
148 if (!
NeedShift(P * shiftInfo.scale + shiftInfo.shift) &&
150 coordinatesShift = shiftInfo.shift;
151 if (coordinatesScale) {
152 *coordinatesScale = shiftInfo.scale;
154 if (preserveCoordinateShift) {
155 *preserveCoordinateShift = shiftInfo.preserve;
163 if (coordinatesShift.
norm2() != 0 || scale != 1.0) {
179 if (preserveCoordinateShift) {
180 *preserveCoordinateShift =
true;
183 if (coordinatesScale && needRescale) {
185 if (preserveCoordinateShift) {
186 *preserveCoordinateShift =
true;
190 scale = *coordinatesScale;
203 if (!coordinatesScale) {
209 if (useInputCoordinatesShiftIfPossible) {
211 shift = coordinatesShift;
212 if (coordinatesScale) {
213 scale = *coordinatesScale;
246 for (
size_t i =
static_cast<size_t>(std::max(0, index + 1));
259 sasDlg.
showTitle(needShift || needRescale);
265 coordinatesShift = sasDlg.
getShift();
266 if (coordinatesScale) {
267 *coordinatesScale = sasDlg.
getScale();
269 if (preserveCoordinateShift) {
281 if (coordinatesScale) {
282 *coordinatesScale = 1.0;
284 if (preserveCoordinateShift) {
285 *preserveCoordinateShift =
false;
301 shift.
x =
static_cast<int>(shift.
x / 100) * 100.0;
302 shift.
y =
static_cast<int>(shift.
y / 100) * 100.0;
303 shift.
z =
static_cast<int>(shift.
z / 100) * 100.0;
311 : pow(10.0, -
static_cast<double>(
constexpr double ZERO_TOLERANCE_D
Vector3Tpl< double > CCVector3d
Double 3D Vector.
static bool Warning(const char *format,...)
Prints out a formatted warning message in console.
Type norm2() const
Returns vector square norm.
double norm2d() const
Returns vector square norm (forces double precision output)
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 BestScale(double d)
static bool NeedShift(const CCVector3d &P)
Returns whether a particular point (coordinates) is too big or not.
static double MAX_DIAGONAL_LENGTH
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 bool GetLast(ShiftInfo &info)
static double MAX_COORDINATE_ABS_VALUE
Dialog for selection of cloud center.
bool preserveShiftOnSave() const
Returns whether the global shift should be preserved or not.
void setPreserveShiftOnSave(bool state)
Sets whether the global shift should be preserved or not.
CCVector3d getShift() const
Returns shift.
void setCurrentProfile(int index)
Sets the current combo-box entry (profile)
size_t infoCount() const
Returns the number of info currently stored.
void showWarning(bool state)
Whether to show or not the warning about non pertinent shift information.
int addShiftInfo(const ecvGlobalShiftManager::ShiftInfo &info)
Adds shift info to the combox.
void showApplyAllButton(bool state)
Whether to show the 'Apply all' button or not.
void showScaleItems(bool state)
Whether to show dialog items related to scale.
void showTitle(bool state)
Whether to show or not the title.
bool applyAll() const
Whether shift should be applied to all files.
bool addFileInfo()
Adds information from default file (if any)
void showPreserveShiftOnSave(bool state)
Whether to show or not the 'Preserve shift on save' checkbox.
double getScale() const
Returns scale.
bool getInfo(size_t index, ecvGlobalShiftManager::ShiftInfo &info) const
Returns a given input info.
static std::vector< ecvGlobalShiftManager::ShiftInfo > s_lastInfoBuffer
MiniVec< float, N > ceil(const MiniVec< float, N > &a)