Welcome to mirror list, hosted at ThFree Co, Russian Federation.

vertex_decl.hpp « carve « include « carve « extern - git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 4719b72c0ee2e4173854c3bbb7880723eeace55b (plain)
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
// Begin License:
// Copyright (C) 2006-2014 Tobias Sargeant (tobias.sargeant@gmail.com).
// All rights reserved.
//
// This file is part of the Carve CSG Library (http://carve-csg.com/)
//
// This file may be used under the terms of either the GNU General
// Public License version 2 or 3 (at your option) as published by the
// Free Software Foundation and appearing in the files LICENSE.GPL2
// and LICENSE.GPL3 included in the packaging of this file.
//
// This file is provided "AS IS" with NO WARRANTY OF ANY KIND,
// INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE.
// End:


#pragma once

#include <carve/carve.hpp>

#include <carve/geom2d.hpp>
#include <carve/vector.hpp>
#include <carve/matrix.hpp>
#include <carve/geom3d.hpp>
#include <carve/aabb.hpp>
#include <carve/tag.hpp>

#include <vector>
#include <list>
#include <map>

namespace carve {
  namespace poly {



    struct Object;



    template<unsigned ndim>
    class Vertex : public tagable {
    public:
      typedef carve::geom::vector<ndim> vector_t;
      typedef Object obj_t;

      vector_t v;
      obj_t *owner;

      Vertex() : tagable(), v() {
      }

      ~Vertex() {
      }

      Vertex(const vector_t &_v) : tagable(), v(_v) {
      }
    };



    struct hash_vertex_ptr {
      template<unsigned ndim>
      size_t operator()(const Vertex<ndim> * const &v) const {
        return (size_t)v;
      }

      template<unsigned ndim>
      size_t operator()(const std::pair<const Vertex<ndim> *, const Vertex<ndim> *> &v) const {
        size_t r = (size_t)v.first;
        size_t s = (size_t)v.second;
        return r ^ ((s >> 16) | (s << 16));
      }

    };



    template<unsigned ndim>
    double distance(const Vertex<ndim> *v1, const Vertex<ndim> *v2) {
      return distance(v1->v, v2->v);
    }

    template<unsigned ndim>
    double distance(const Vertex<ndim> &v1, const Vertex<ndim> &v2) {
      return distance(v1.v, v2.v);
    }

    struct vec_adapt_vertex_ref {
      template<unsigned ndim>
      const typename Vertex<ndim>::vector_t &operator()(const Vertex<ndim> &v) const { return v.v; }

      template<unsigned ndim>
      typename Vertex<ndim>::vector_t &operator()(Vertex<ndim> &v) const { return v.v; }
    };



    struct vec_adapt_vertex_ptr {
      template<unsigned ndim>
      const typename Vertex<ndim>::vector_t &operator()(const Vertex<ndim> *v) const { return v->v; }

      template<unsigned ndim>
      typename Vertex<ndim>::vector_t &operator()(Vertex<ndim> *v) const { return v->v; }
    };



  }
}