Point Cloud Library (PCL)
1.7.1
Main Page
Modules
Namespaces
Classes
surface
include
pcl
surface
3rdparty
poisson4
vector.h
1
/*
2
Copyright (c) 2006, Michael Kazhdan and Matthew Bolitho
3
All rights reserved.
4
5
Redistribution and use in source and binary forms, with or without modification,
6
are permitted provided that the following conditions are met:
7
8
Redistributions of source code must retain the above copyright notice, this list of
9
conditions and the following disclaimer. Redistributions in binary form must reproduce
10
the above copyright notice, this list of conditions and the following disclaimer
11
in the documentation and/or other materials provided with the distribution.
12
13
Neither the name of the Johns Hopkins University nor the names of its contributors
14
may be used to endorse or promote products derived from this software without specific
15
prior written permission.
16
17
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
18
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO THE IMPLIED WARRANTIES
19
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
20
SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
21
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
22
TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
23
BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
25
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
26
DAMAGE.
27
*/
28
29
#ifndef __VECTOR_HPP
30
#define __VECTOR_HPP
31
32
#define Assert assert
33
#include <assert.h>
34
35
36
namespace
pcl
37
{
38
namespace
poisson
39
{
40
template
<
class
T>
41
class
Vector
42
{
43
public
:
44
Vector
();
45
Vector
(
const
Vector<T>
& V );
46
Vector
(
size_t
N );
47
Vector
(
size_t
N, T* pV );
48
~Vector
();
49
50
const
T&
operator ()
(
size_t
i)
const
;
51
T&
operator ()
(
size_t
i);
52
const
T&
operator []
(
size_t
i)
const
;
53
T&
operator []
(
size_t
i);
54
55
void
SetZero
();
56
57
size_t
Dimensions
()
const
;
58
void
Resize
(
size_t
N );
59
60
Vector
operator *
(
const
T& A)
const
;
61
Vector
operator /
(
const
T& A)
const
;
62
Vector
operator -
(
const
Vector
& V)
const
;
63
Vector
operator +
(
const
Vector
& V)
const
;
64
65
Vector
&
operator *=
(
const
T& A);
66
Vector
&
operator /=
(
const
T& A);
67
Vector
&
operator +=
(
const
Vector
& V);
68
Vector
&
operator -=
(
const
Vector
& V);
69
70
Vector
&
AddScaled
(
const
Vector
& V,
const
T& scale);
71
Vector
&
SubtractScaled
(
const
Vector
& V,
const
T& scale);
72
static
void
Add
(
const
Vector
& V1,
const
T& scale1,
const
Vector
& V2,
const
T& scale2,
Vector
& Out);
73
static
void
Add
(
const
Vector
& V1,
const
T& scale1,
const
Vector
& V2,
Vector
& Out);
74
75
Vector
operator -
()
const
;
76
77
Vector
&
operator =
(
const
Vector
& V);
78
79
T
Dot
(
const
Vector
& V )
const
;
80
81
T
Length
()
const
;
82
83
T
Norm
(
size_t
Ln )
const
;
84
void
Normalize
();
85
86
bool
write
( FILE* fp )
const
;
87
bool
write
(
const
char
* fileName )
const
;
88
bool
read
( FILE* fp );
89
bool
read
(
const
char
* fileName );
90
91
T*
m_pV
;
92
protected
:
93
size_t
m_N
;
94
95
};
96
97
template
<
class
T,
int
Dim>
98
class
NVector
99
{
100
public
:
101
NVector
();
102
NVector
(
const
NVector
& V );
103
NVector
(
size_t
N );
104
NVector
(
size_t
N, T* pV );
105
~NVector
();
106
107
const
T*
operator ()
(
size_t
i)
const
;
108
T*
operator ()
(
size_t
i);
109
const
T*
operator []
(
size_t
i)
const
;
110
T*
operator []
(
size_t
i);
111
112
void
SetZero
();
113
114
size_t
Dimensions
()
const
;
115
void
Resize
(
size_t
N );
116
117
NVector
operator *
(
const
T& A)
const
;
118
NVector
operator /
(
const
T& A)
const
;
119
NVector
operator -
(
const
NVector
& V)
const
;
120
NVector
operator +
(
const
NVector
& V)
const
;
121
122
NVector
&
operator *=
(
const
T& A);
123
NVector
&
operator /=
(
const
T& A);
124
NVector
&
operator +=
(
const
NVector
& V);
125
NVector
&
operator -=
(
const
NVector
& V);
126
127
NVector
&
AddScaled
(
const
NVector
& V,
const
T& scale);
128
NVector
&
SubtractScaled
(
const
NVector
& V,
const
T& scale);
129
static
void
Add
(
const
NVector
& V1,
const
T& scale1,
const
NVector
& V2,
const
T& scale2,
NVector
& Out);
130
static
void
Add
(
const
NVector
& V1,
const
T& scale1,
const
NVector
& V2,
NVector
& Out);
131
132
NVector
operator -
()
const
;
133
134
NVector
&
operator =
(
const
NVector
& V);
135
136
T
Dot
(
const
NVector
& V )
const
;
137
138
T
Length
()
const
;
139
140
T
Norm
(
size_t
Ln )
const
;
141
void
Normalize
();
142
143
T*
m_pV
;
144
protected
:
145
size_t
m_N
;
146
147
};
148
149
}
150
}
151
152
153
#include "vector.hpp"
154
155
#endif