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
|
// Copyright (c) 2007-2009 INRIA (France).
// All rights reserved.
//
// This file is part of CGAL (www.cgal.org).
//
// $URL: https://github.com/CGAL/cgal/blob/v6.1.1/Point_set_processing_3/include/CGAL/Point_with_normal_3.h $
// $Id: include/CGAL/Point_with_normal_3.h 08b27d3db14 $
// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial
//
//
// Author(s) : Laurent Saboret, Pierre Alliez
#ifndef CGAL_POINT_WITH_NORMAL_3_H
#define CGAL_POINT_WITH_NORMAL_3_H
#include <CGAL/license/Point_set_processing_3.h>
#include <CGAL/Point_3.h>
#include <CGAL/Vector_3.h>
#include <CGAL/Origin.h>
#include <CGAL/value_type_traits.h>
#include <CGAL/property_map.h>
namespace CGAL {
/// \cond SKIP_IN_MANUAL
/// The Point_with_normal_3 class represents a 3D point with:
/// - a position,
/// - a normal (oriented).
///
/// @heading Parameters:
/// @param Gt Geometric traits class.
template<class Gt>
class Point_with_normal_3 : public Gt::Point_3
{
// Private types
private:
typedef typename Gt::Point_3 Base;
// Public types
public:
typedef Gt Geom_traits; ///< Geometric traits class
typedef typename Geom_traits::FT FT;
typedef typename Geom_traits::RT RT;
typedef typename Geom_traits::Point_3 Point; ///< typedef to Geom_traits::Point_3
typedef typename Geom_traits::Vector_3 Vector; ///< typedef to Geom_traits::Vector_3
// Public methods
public:
/// Point is (0,0,0) by default.
/// Normal is (0,0,0) by default.
Point_with_normal_3(const Origin& o = ORIGIN)
: Base(o)
{
}
Point_with_normal_3(FT x, FT y, FT z,
const Vector& normal = NULL_VECTOR)
: Base(x,y,z),
m_normal(normal)
{
}
Point_with_normal_3(RT hx, RT hy, RT hz, RT hw,
const Vector& normal = NULL_VECTOR)
: Base(hx,hy,hz,hw),
m_normal(normal)
{
}
Point_with_normal_3(const Point& point,
const Vector& normal = NULL_VECTOR)
: Base(point),
m_normal(normal)
{
}
/// Copy constructor
Point_with_normal_3(const Point_with_normal_3& pwn)
: Base(pwn),
m_normal(pwn.normal())
{
}
template <class K>
Point_with_normal_3(const Point_with_normal_3<K>& pwn)
: Base(pwn),
m_normal(pwn.normal())
{
}
/// Operator =()
Point_with_normal_3& operator=(const Point_with_normal_3& pwn)
{
Base::operator=(pwn);
m_normal = pwn.normal();
return *this;
}
/// Gets/sets position.
const Point& position() const { return *this; }
Point& position() { return *this; }
/// Gets/sets normal.
const Vector& normal() const { return m_normal; }
Vector& normal() { return m_normal; }
// Data
private:
Vector m_normal;
};
//=========================================================================
/// Property map that accesses the normal vector from a Point_with_normal_3 object
///
/// @heading Is Model for the Concepts:
/// \cgalModels{LvaluePropertyMap}
///
/// @heading Parameters:
/// @param Gt Geometric traits class.
template <class Gt>
struct Normal_of_point_with_normal_map
{
typedef Normal_of_point_with_normal_map<Gt> Self;
typedef Point_with_normal_3<Gt> Point_with_normal; ///< Position + normal
typedef typename Gt::Vector_3 Vector; /// normal
typedef Point_with_normal key_type;
typedef Vector value_type;
typedef const value_type& reference;
typedef boost::lvalue_property_map_tag category;
/// Access a property map element
value_type& operator[](key_type& k) const { return k.normal(); }
/// \name Put/get free functions
/// @{
friend reference get(const Self&, const key_type& k) { return k.normal(); }
friend void put(const Self&, key_type& k, const value_type& v) { k.normal() = v; }
/// @};}
};
/// Free function to create a Normal_of_point_with_normal_map property map.
///
/// @relates Normal_of_point_with_normal_map
template <class Point_with_normal> // Point_with_normal type
Normal_of_point_with_normal_map<
typename CGAL::Kernel_traits<Point_with_normal>::Kernel>
make_normal_of_point_with_normal_map(Point_with_normal)
{
return Normal_of_point_with_normal_map<typename CGAL::Kernel_traits<Point_with_normal>::Kernel>();
}
/// \endcond
} //namespace CGAL
#endif //CGAL_POINT_WITH_NORMAL_3_H
|