// Begin License: // Copyright (C) 2006-2008 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 the GNU General Public // License version 2.0 as published by the Free Software Foundation // and appearing in the file LICENSE.GPL2 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 #include #include #include #include #include #include #include #include #include namespace carve { namespace poly { struct Object; template class Vertex : public tagable { public: typedef carve::geom::vector 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 size_t operator()(const Vertex * const &v) const { return (size_t)v; } template size_t operator()(const std::pair *, const Vertex *> &v) const { size_t r = (size_t)v.first; size_t s = (size_t)v.second; return r ^ ((s >> 16) | (s << 16)); } }; template double distance(const Vertex *v1, const Vertex *v2) { return distance(v1->v, v2->v); } template double distance(const Vertex &v1, const Vertex &v2) { return distance(v1.v, v2.v); } struct vec_adapt_vertex_ref { template const typename Vertex::vector_t &operator()(const Vertex &v) const { return v.v; } template typename Vertex::vector_t &operator()(Vertex &v) const { return v.v; } }; struct vec_adapt_vertex_ptr { template const typename Vertex::vector_t &operator()(const Vertex *v) const { return v->v; } template typename Vertex::vector_t &operator()(Vertex *v) const { return v->v; } }; } }