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 94 95 96 97 98 99
|
//##########################################################################
//# #
//# 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) #
//# #
//##########################################################################
//Always first
#include "ccIncludeGL.h"
#include "ccBBox.h"
void ccBBox::draw(CC_DRAW_CONTEXT& context, const ccColor::Rgb& col) const
{
if (!m_valid)
return;
//get the set of OpenGL functions (version 2.1)
QOpenGLFunctions_2_1 *glFunc = context.glFunctions<QOpenGLFunctions_2_1>();
assert( glFunc != nullptr );
if ( glFunc == nullptr )
return;
ccGL::Color3v(glFunc, col.rgb);
glFunc->glBegin(GL_LINE_LOOP);
ccGL::Vertex3v(glFunc, m_bbMin.u);
ccGL::Vertex3(glFunc, m_bbMax.x, m_bbMin.y, m_bbMin.z);
ccGL::Vertex3(glFunc, m_bbMax.x, m_bbMax.y, m_bbMin.z);
ccGL::Vertex3(glFunc, m_bbMin.x, m_bbMax.y, m_bbMin.z);
glFunc->glEnd();
glFunc->glBegin(GL_LINE_LOOP);
ccGL::Vertex3(glFunc, m_bbMin.x, m_bbMin.y, m_bbMax.z);
ccGL::Vertex3(glFunc, m_bbMax.x, m_bbMin.y, m_bbMax.z);
ccGL::Vertex3v(glFunc, m_bbMax.u);
ccGL::Vertex3(glFunc, m_bbMin.x, m_bbMax.y, m_bbMax.z);
glFunc->glEnd();
glFunc->glBegin(GL_LINES);
ccGL::Vertex3v(glFunc, m_bbMin.u);
ccGL::Vertex3(glFunc, m_bbMin.x, m_bbMin.y, m_bbMax.z);
ccGL::Vertex3(glFunc, m_bbMax.x, m_bbMin.y, m_bbMin.z);
ccGL::Vertex3(glFunc, m_bbMax.x, m_bbMin.y, m_bbMax.z);
ccGL::Vertex3(glFunc, m_bbMax.x, m_bbMax.y, m_bbMin.z);
ccGL::Vertex3v(glFunc, m_bbMax.u);
ccGL::Vertex3(glFunc, m_bbMin.x, m_bbMax.y, m_bbMin.z);
ccGL::Vertex3(glFunc, m_bbMin.x, m_bbMax.y, m_bbMax.z);
glFunc->glEnd();
}
const ccBBox ccBBox::operator * (const ccGLMatrix& mat)
{
ccBBox rotatedBox;
if (m_valid)
{
rotatedBox.add(mat * m_bbMin);
rotatedBox.add(mat * CCVector3(m_bbMin.x,m_bbMin.y,m_bbMax.z));
rotatedBox.add(mat * CCVector3(m_bbMin.x,m_bbMax.y,m_bbMin.z));
rotatedBox.add(mat * CCVector3(m_bbMax.x,m_bbMin.y,m_bbMin.z));
rotatedBox.add(mat * m_bbMax);
rotatedBox.add(mat * CCVector3(m_bbMin.x,m_bbMax.y,m_bbMax.z));
rotatedBox.add(mat * CCVector3(m_bbMax.x,m_bbMax.y,m_bbMin.z));
rotatedBox.add(mat * CCVector3(m_bbMax.x,m_bbMin.y,m_bbMax.z));
}
return rotatedBox;
}
const ccBBox ccBBox::operator * (const ccGLMatrixd& mat)
{
ccBBox rotatedBox;
if (m_valid)
{
rotatedBox.add(mat * m_bbMin);
rotatedBox.add(mat * CCVector3(m_bbMin.x,m_bbMin.y,m_bbMax.z));
rotatedBox.add(mat * CCVector3(m_bbMin.x,m_bbMax.y,m_bbMin.z));
rotatedBox.add(mat * CCVector3(m_bbMax.x,m_bbMin.y,m_bbMin.z));
rotatedBox.add(mat * m_bbMax);
rotatedBox.add(mat * CCVector3(m_bbMin.x,m_bbMax.y,m_bbMax.z));
rotatedBox.add(mat * CCVector3(m_bbMax.x,m_bbMax.y,m_bbMin.z));
rotatedBox.add(mat * CCVector3(m_bbMax.x,m_bbMin.y,m_bbMax.z));
}
return rotatedBox;
}
|