1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93
|
//##########################################################################
//# #
//# CLOUDCOMPARE #
//# #
//# This program is free software; you can redistribute it and/or modify #
//# it under the terms of the GNU General Public License as published by #
//# the Free Software Foundation; version 2 or later of the License. #
//# #
//# This program is distributed in the hope that it will be useful, #
//# but WITHOUT ANY WARRANTY; without even the implied warranty of #
//# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
//# GNU General Public License for more details. #
//# #
//# COPYRIGHT: EDF R&D / TELECOM ParisTech (ENST-TSI) #
//# #
//##########################################################################
#include "ccShiftedObject.h"
//local
#include "ccLog.h"
#include "ccSerializableObject.h"
ccShiftedObject::ccShiftedObject(QString name)
: ccHObject(name)
, m_globalShift(0,0,0)
, m_globalScale(1.0)
{
}
ccShiftedObject::ccShiftedObject(const ccShiftedObject& s)
: ccHObject(s)
, m_globalShift(s.m_globalShift)
, m_globalScale(s.m_globalScale)
{
}
void ccShiftedObject::setGlobalShift(const CCVector3d& shift)
{
m_globalShift = shift;
}
void ccShiftedObject::setGlobalShift(double x, double y, double z)
{
m_globalShift.x = x;
m_globalShift.y = y;
m_globalShift.z = z;
}
void ccShiftedObject::setGlobalScale(double scale)
{
if (scale == 0)
{
ccLog::Warning("[setGlobalScale] Invalid scale (zero)!");
m_globalScale = 1.0;
}
else
{
m_globalScale = scale;
}
}
bool ccShiftedObject::saveShiftInfoToFile(QFile& out) const
{
//'coordinates shift'
if (out.write((const char*)m_globalShift.u,sizeof(double)*3) < 0)
return ccSerializableObject::WriteError();
//'global scale'
if (out.write((const char*)&m_globalScale,sizeof(double)) < 0)
return ccSerializableObject::WriteError();
return true;
}
bool ccShiftedObject::loadShiftInfoFromFile(QFile& in)
{
//'coordinates shift'
if (in.read((char*)m_globalShift.u,sizeof(double)*3) < 0)
return ccSerializableObject::ReadError();
//'global scale'
if (in.read((char*)&m_globalScale,sizeof(double)) < 0)
return ccSerializableObject::ReadError();
return true;
}
bool ccShiftedObject::getGlobalBB(CCVector3d& minCorner, CCVector3d& maxCorner)
{
ccBBox box = getOwnBB(false);
minCorner = toGlobal3d(box.minCorner());
maxCorner = toGlobal3d(box.maxCorner());
return box.isValid();
}
|