2
// Copyright (C) 2006-2011 Tobias Sargeant (tobias.sargeant@gmail.com).
3
// All rights reserved.
5
// This file is part of the Carve CSG Library (http://carve-csg.com/)
7
// This file may be used under the terms of the GNU General Public
8
// License version 2.0 as published by the Free Software Foundation
9
// and appearing in the file LICENSE.GPL2 included in the packaging of
12
// This file is provided "AS IS" with NO WARRANTY OF ANY KIND,
13
// INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR
14
// A PARTICULAR PURPOSE.
20
#include <carve/carve.hpp>
22
#include <carve/geom2d.hpp>
23
#include <carve/vector.hpp>
24
#include <carve/matrix.hpp>
25
#include <carve/geom3d.hpp>
26
#include <carve/aabb.hpp>
27
#include <carve/tag.hpp>
42
template<unsigned ndim>
43
class Vertex : public tagable {
45
typedef carve::geom::vector<ndim> vector_t;
51
Vertex() : tagable(), v() {
57
Vertex(const vector_t &_v) : tagable(), v(_v) {
63
struct hash_vertex_ptr {
64
template<unsigned ndim>
65
size_t operator()(const Vertex<ndim> * const &v) const {
69
template<unsigned ndim>
70
size_t operator()(const std::pair<const Vertex<ndim> *, const Vertex<ndim> *> &v) const {
71
size_t r = (size_t)v.first;
72
size_t s = (size_t)v.second;
73
return r ^ ((s >> 16) | (s << 16));
80
template<unsigned ndim>
81
double distance(const Vertex<ndim> *v1, const Vertex<ndim> *v2) {
82
return distance(v1->v, v2->v);
85
template<unsigned ndim>
86
double distance(const Vertex<ndim> &v1, const Vertex<ndim> &v2) {
87
return distance(v1.v, v2.v);
90
struct vec_adapt_vertex_ref {
91
template<unsigned ndim>
92
const typename Vertex<ndim>::vector_t &operator()(const Vertex<ndim> &v) const { return v.v; }
94
template<unsigned ndim>
95
typename Vertex<ndim>::vector_t &operator()(Vertex<ndim> &v) const { return v.v; }
100
struct vec_adapt_vertex_ptr {
101
template<unsigned ndim>
102
const typename Vertex<ndim>::vector_t &operator()(const Vertex<ndim> *v) const { return v->v; }
104
template<unsigned ndim>
105
typename Vertex<ndim>::vector_t &operator()(Vertex<ndim> *v) const { return v->v; }