GLC_lib  2.5.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
glc_pointcloud.cpp
Go to the documentation of this file.
1 /****************************************************************************
2 
3  This file is part of the GLC-lib library.
4  Copyright (C) 2005-2008 Laurent Ribon (laumaya@users.sourceforge.net)
5  http://glc-lib.sourceforge.net
6 
7  GLC-lib is free software; you can redistribute it and/or modify
8  it under the terms of the GNU Lesser General Public License as published by
9  the Free Software Foundation; either version 3 of the License, or
10  (at your option) any later version.
11 
12  GLC-lib is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  GNU Lesser General Public License for more details.
16 
17  You should have received a copy of the GNU Lesser General Public License
18  along with GLC-lib; if not, write to the Free Software
19  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 
21  *****************************************************************************/
23 
24 #include "glc_pointcloud.h"
25 
27 : GLC_Geometry("Point Cloud", true)
28 {
29 
30 }
31 
33 : GLC_Geometry(pointCloud)
34 {
35 
36 
37 }
38 
40 {
41 
42 }
43 
45 // Get Functions
48 {
49  if (NULL == GLC_Geometry::m_pBoundingBox)
50  {
52  if (! m_WireData.isEmpty())
53  {
55  }
56  }
58 }
59 
61 {
62  return new GLC_PointCloud(*this);
63 }
64 
66 // Set Functions
68 
69 GLC_uint GLC_PointCloud::addPoint(const QList<GLC_Point3d>& pointsList)
70 {
71  const int pointCount= pointsList.size();
72  const int size= pointCount * 3;
73  GLfloatVector data(size);
74  for (int i= 0; i < pointCount; ++i)
75  {
76  const GLC_Point3d currentPoint(pointsList.at(i));
77  data[i * 3]= static_cast<float>(currentPoint.x());
78  data[i * 3 + 1]= static_cast<float>(currentPoint.y());
79  data[i * 3 + 2]= static_cast<float>(currentPoint.z());
80  }
82 }
83 
84 GLC_uint GLC_PointCloud::addPoint(const QList<GLC_Point3df>& pointsList)
85 {
86  const int pointCount= pointsList.size();
87  const int size= pointCount * 3;
88  GLfloatVector data(size);
89  for (int i= 0; i < pointCount; ++i)
90  {
91  const GLC_Point3df currentPoint(pointsList.at(i));
92  data[i * 3]= currentPoint.x();
93  data[i * 3 + 1]= currentPoint.y();
94  data[i * 3 + 2]= currentPoint.z();
95  }
97 }
98 
99 void GLC_PointCloud::addColors(const QList<QColor>& colors)
100 {
101  const int colorCount= colors.count();
102  const int size= colorCount * 4;
103  GLfloatVector data(size);
104  for (int i= 0; i < colorCount; ++i)
105  {
106  QColor color= colors.at(i);
107  data[i * 4]= static_cast<GLfloat>(color.redF());
108  data[i * 4 + 1]= static_cast<GLfloat>(color.greenF());
109  data[i * 4 + 2]= static_cast<GLfloat>(color.blueF());
110  data[i * 4 + 3]= static_cast<GLfloat>(color.alphaF());
111  }
112 
114 }
115 
117 {
118  if (this != &pointCloud)
119  {
120  GLC_Geometry::operator=(pointCloud);
121  }
122  return *this;
123 }
124 
126 // OpenGL Functions
128 void GLC_PointCloud::glDraw(const GLC_RenderProperties& renderProperties)
129 {
131  {
132  GLC_Geometry::m_WireData.glDraw(renderProperties, GL_POINTS);
133  }
134 }
135 

©2005-2013 Laurent Ribon