-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathPrimitive.cpp
More file actions
211 lines (172 loc) · 5.2 KB
/
Copy pathPrimitive.cpp
File metadata and controls
211 lines (172 loc) · 5.2 KB
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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
/***********************************************************************
Primitive - Base class for geometric primitives (planes, spheres, ...)
that can be extracted from point clouds.
Copyright (c) 2007-2022 Oliver Kreylos
This file is part of the LiDAR processing and analysis package.
The LiDAR processing and analysis package 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; either
version 2 of the License, or (at your option) any later version.
The LiDAR processing and analysis package 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.
You should have received a copy of the GNU General Public License along
with the LiDAR processing and analysis package; if not, write to the
Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA
***********************************************************************/
#include "Primitive.h"
#include <Misc/StringMarshaller.h>
#include <IO/File.h>
#include <Cluster/MulticastPipe.h>
#if USE_COLLABORATION
#include <Collaboration2/DataType.icpp>
#endif
/*************************************
Methods of class Primitive::DragState:
*************************************/
Primitive::DragState::~DragState(void)
{
}
/**********************************
Static elements of class Primitive:
**********************************/
#if USE_COLLABORATION
DataType::TypeID Primitive::scalarType=DataType::TypeID(-1);
DataType::TypeID Primitive::pointType=DataType::TypeID(-1);
DataType::TypeID Primitive::vectorType=DataType::TypeID(-1);
DataType::TypeID Primitive::type=DataType::TypeID(-1);
#endif
/**************************
Methods of class Primitive:
**************************/
Primitive::Primitive(void)
:
#if USE_COLLABORATION
objectId(0),
#endif
numPoints(0),rms(0),
surfaceColor(0.6f,0.6f,0.1f,0.5f),
gridColor(0.2f,0.2f,0.2f),
version(1)
{
}
Primitive::Primitive(IO::File& file,const Vector& translation)
:
#if USE_COLLABORATION
objectId(0),
#endif
surfaceColor(0.6f,0.6f,0.1f,0.5f),
gridColor(0.2f,0.2f,0.2f),
version(1)
{
/* Read the primitive: */
Primitive::read(file,translation);
}
Primitive::Primitive(Cluster::MulticastPipe* pipe)
:
#if USE_COLLABORATION
objectId(0),
#endif
surfaceColor(0.6f,0.6f,0.1f,0.5f),
gridColor(0.2f,0.2f,0.2f),
version(1)
{
/* Read the primitive: */
Primitive::read(pipe);
}
Primitive::~Primitive(void)
{
}
void Primitive::setLabel(const std::string& newLabel)
{
label=newLabel;
}
void Primitive::write(IO::File& file,const Vector& translation) const
{
/* Write the number of points and the approximation RMS: */
file.write(numPoints);
file.write(rms);
/* Write the primitive label: */
Misc::writeCppString(label,file);
}
void Primitive::read(IO::File& file,const Vector& translation)
{
/* Read the number of points and the approximation RMS: */
file.read(numPoints);
file.read(rms);
/* Read the primitive label: */
Misc::readCppString(file,label);
}
void Primitive::write(Cluster::MulticastPipe* pipe) const
{
/* Write the number of points and the approximation RMS: */
pipe->write(numPoints);
pipe->write(rms);
/* Write the primitive label: */
Misc::writeCppString(label,*pipe);
}
void Primitive::read(Cluster::MulticastPipe* pipe)
{
/* Read the number of points and the approximation RMS: */
pipe->read(numPoints);
pipe->read(rms);
/* Read the primitive label: */
Misc::readCppString(*pipe,label);
}
#if USE_COLLABORATION
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Winvalid-offsetof"
void Primitive::registerType(DataType& dataType)
{
/* Register base types: */
scalarType=dataType.getAtomicType<Misc::Float64>();
pointType=dataType.createFixedArray(3,scalarType);
vectorType=dataType.createFixedArray(3,scalarType);
/* Register the primitive structure: */
DataType::StructureElement elements[]=
{
{DataType::getAtomicType<Misc::UInt64>(),offsetof(Primitive,numPoints)},
{scalarType,offsetof(Primitive,rms)},
{DataType::String,offsetof(Primitive,label)}
};
type=dataType.createStructure(3,elements,sizeof(Primitive));
}
#pragma GCC diagnostic pop
DataType::TypeID Primitive::getType(void) const
{
return type;
}
void Primitive::setObjectId(KoinoniaProtocol::ObjectID newObjectId)
{
objectId=newObjectId;
}
#endif
void Primitive::setSurfaceColor(const Primitive::Color& newSurfaceColor)
{
surfaceColor=newSurfaceColor;
++version;
}
void Primitive::setGridColor(const Primitive::Color& newGridColor)
{
gridColor=newGridColor;
++version;
}
Primitive::DragState* Primitive::pick(const Primitive::Point& pickPoint,Primitive::Scalar& maxPickDistance2)
{
/* Base primitives cannot be picked: */
return 0;
}
void Primitive::drag(Primitive::DragState* dragState,const Primitive::Point& dragPoint)
{
/* Don't drag by default, even if the pick succeeded */
}
void Primitive::glRenderAction(GLContextData& contextData) const
{
/* Don't draw anything */
}
void Primitive::glRenderActionTransparent(GLContextData& contextData) const
{
/* Don't draw anything */
}