// 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 namespace carve { namespace poly { class EdgeConnectivityInfo; struct Polyhedron : public Geometry<3> { private: Polyhedron(); // not implemented Polyhedron &operator=(const Polyhedron &); // not implemented // *** initialization bool initSpatialIndex(); void initVertexConnectivity(); bool initEdgeConnectivity(const EdgeConnectivityInfo &); void buildEdgeFaceMap(EdgeConnectivityInfo &); void setFaceAndVertexOwner(); bool initConnectivity(); bool markManifolds(); bool calcManifoldEmbedding(); bool init(); void faceRecalc(); void commonFaceInit(bool _recalc); public: typedef std::unordered_map VVMap; static void collectFaceVertices(std::vector &faces, std::vector &vertices, carve::csg::VVMap &vmap); static void collectFaceVertices(std::vector &faces, std::vector &vertices); std::vector manifold_is_closed; std::vector manifold_is_negative; carve::geom3d::AABB aabb; carve::csg::Octree octree; // *** construction of Polyhedron objects Polyhedron(const Polyhedron &); // copy a single manifold Polyhedron(const Polyhedron &, int m_id); // copy a subset of manifolds Polyhedron(const Polyhedron &, const std::vector &selected_manifolds); Polyhedron(std::vector &_faces, std::vector &_vertices, bool _recalc = false); Polyhedron(std::vector &_faces, bool _recalc = false); Polyhedron(std::list &_faces, bool _recalc = false); Polyhedron(const std::vector &vertices, int n_faces, const std::vector &face_indices); ~Polyhedron(); // *** containment queries void testVertexAgainstClosedManifolds(const carve::geom3d::Vector &v, std::map &result, bool ignore_orentation) const; PointClass containsVertex(const carve::geom3d::Vector &v, const face_t **hit_face = NULL, bool even_odd = false, int manifold_id = -1) const; // *** locality queries void findEdgesNear(const carve::geom::aabb<3> &aabb, std::vector &edges) const; void findEdgesNear(const carve::geom3d::LineSegment &l, std::vector &edges) const; void findEdgesNear(const carve::geom3d::Vector &v, std::vector &edges) const; void findEdgesNear(const face_t &face, std::vector &edges) const; void findEdgesNear(const edge_t &edge, std::vector &edges) const; void findFacesNear(const carve::geom::aabb<3> &aabb, std::vector &faces) const; void findFacesNear(const carve::geom3d::LineSegment &l, std::vector &faces) const; void findFacesNear(const edge_t &edge, std::vector &faces) const; // *** manifold queries inline bool vertexOnManifold(const vertex_t *v, int m_id) const; inline bool edgeOnManifold(const edge_t *e, int m_id) const; template int vertexManifolds(const vertex_t *v, T result) const; template int edgeManifolds(const edge_t *e, T result) const; size_t manifoldCount() const; bool hasOpenManifolds() const; // *** transformation // flip face directions void invertAll(); void invert(const std::vector &selected_manifolds); void invert(int m_id); void invert(); // matrix transform of vertices void transform(const carve::math::Matrix &xform); // arbitrary function transform of vertices template void transform(const T &xform); void print(std::ostream &) const; void canonicalize(); }; std::ostream &operator<<(std::ostream &, const Polyhedron &); } }