File: point.h

package info (click to toggle)
meshlab 2020.09%2Bdfsg1-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 45,124 kB
  • sloc: cpp: 400,238; ansic: 31,952; javascript: 1,578; sh: 387; yacc: 238; lex: 139; python: 86; makefile: 29
file content (129 lines) | stat: -rw-r--r-- 4,643 bytes parent folder | download | duplicates (3)
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
/****************************************************************************
* VCGLib                                                            o o     *
* Visual and Computer Graphics Library                            o     o   *
*                                                                _   O  _   *
* Copyright(C) 2004-2016                                           \/)\/    *
* Visual Computing Lab                                            /\/|      *
* ISTI - Italian National Research Council                           |      *
*                                                                    \      *
* All rights reserved.                                                      *
*                                                                           *
* 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; either version 2 of the License, or         *
* (at your option) any later version.                                       *
*                                                                           *
* 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 (http://www.gnu.org/licenses/gpl.txt)          *
* for more details.                                                         *
*                                                                           *
****************************************************************************/

#ifndef VCG_USE_EIGEN
#include "deprecated_point.h"
#else

#ifndef __VCGLIB_POINT
#define __VCGLIB_POINT

#include "../math/eigen.h"
#include <vcg/math/base.h>
#include <vcg/space/space.h>

namespace vcg {
template<typename Scalar> class Point2;
template<typename Scalar> class Point3;
template<typename Scalar> class Point4;

namespace ndim{
template <int Size, typename Scalar> class Point;
}
}

namespace vcg {
namespace ndim{

/** \addtogroup space */
/*@{*/
/**
		The templated class for representing a point in R^N space.
		The class is templated over the ScalarType class that is used to represent coordinates.
		PointBase provides the interface and the common operators for points
		of any dimensionality.
	*/
template <int N, class S> class Point : public Eigen::Matrix<S,N,1>
{
//----------------------------------------
// template typedef part
// use it as follow: typename Point<N,S>::Type instead of simply Point<N,S>
//----------------------------------------
public:
	typedef Eigen::Matrix<S,N,1> Type;
//----------------------------------------
// inheritence part
//----------------------------------------
private:
	typedef Eigen::Matrix<S,N,1> _Base;
public:

	using _Base::coeff;
	using _Base::coeffRef;
	using _Base::setZero;
	using _Base::data;
	using _Base::V;

	_EIGEN_GENERIC_PUBLIC_INTERFACE(Point,_Base);
	VCG_EIGEN_INHERIT_ASSIGNMENT_OPERATORS(Point)

	inline Point() : Base() {}
	template<typename OtherDerived>
	inline Point(const Eigen::MatrixBase<OtherDerived>& other) : Base(other) {}

	/// slower version, more stable (double precision only)
	inline S StableDot (const Point& p) const;

		/// Signed area operator
		/// a % b returns the signed area of the parallelogram inside a and b
		// inline S operator % ( PointType const & p ) const;

}; // end class definition


typedef Eigen::Matrix<short ,2,1> Point2s;
typedef Eigen::Matrix<int   ,2,1> Point2i;
typedef Eigen::Matrix<float ,2,1> Point2f;
typedef Eigen::Matrix<double,2,1> Point2d;
typedef Eigen::Matrix<short ,2,1> Vector2s;
typedef Eigen::Matrix<int   ,2,1> Vector2i;
typedef Eigen::Matrix<float ,2,1> Vector2f;
typedef Eigen::Matrix<double,2,1> Vector2d;

typedef Eigen::Matrix<short ,3,1> Point3s;
typedef Eigen::Matrix<int   ,3,1> Point3i;
typedef Eigen::Matrix<float ,3,1> Point3f;
typedef Eigen::Matrix<double,3,1> Point3d;
typedef Eigen::Matrix<short ,3,1> Vector3s;
typedef Eigen::Matrix<int   ,3,1> Vector3i;
typedef Eigen::Matrix<float ,3,1> Vector3f;
typedef Eigen::Matrix<double,3,1> Vector3d;


typedef Eigen::Matrix<short ,4,1> Point4s;
typedef Eigen::Matrix<int   ,4,1> Point4i;
typedef Eigen::Matrix<float ,4,1> Point4f;
typedef Eigen::Matrix<double,4,1> Point4d;
typedef Eigen::Matrix<short ,4,1> Vector4s;
typedef Eigen::Matrix<int   ,4,1> Vector4i;
typedef Eigen::Matrix<float ,4,1> Vector4f;
typedef Eigen::Matrix<double,4,1> Vector4d;


/*@}*/

} // end namespace ndim
} // end namespace vcg
#endif

#endif