xc
VertexMap.h
1 // -*-c++-*-
2 //----------------------------------------------------------------------------
3 // xc utils library; general purpose classes and functions.
4 //
5 // Copyright (C) Luis C. Pérez Tato
6 //
7 // XC utils is free software: you can redistribute it and/or modify
8 // it under the terms of the GNU General Public License as published by
9 // the Free Software Foundation, either version 3 of the License, or
10 // (at your option) any later version.
11 //
12 // This software is distributed in the hope that it will be useful, but
13 // WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 // GNU General Public License for more details.
16 //
17 // You should have received a copy of the GNU General Public License
18 // along with this program.
19 // If not, see <http://www.gnu.org/licenses/>.
20 //----------------------------------------------------------------------------
21 //VERTEXMAP.h
22 
23 #ifndef VERTEXMAP_H
24 #define VERTEXMAP_H
25 
26 #include <vector>
27 #include "utility/utils/stl/TripletMap.h"
28 #include "utility/geom/pos_vec/Pos3d.h"
29 #include "Polyhedron3d.h"
30 
31 //Convenience classes to generate polyhedrons from
32 //half-space intersections.
33 
34 class Pos3dList;
35 
36 
38 //
41  {
42  size_t v0;
43  size_t v1;
44  public:
45  VerticesArista(const size_t &i,const size_t &j);
46  void swap(void);
47  const size_t &getVI(void) const
48  { return v0; }
49  const size_t &getVJ(void) const
50  { return v1; }
51  bool comparteVertices(const VerticesArista &other) const;
52  friend bool operator==(const VerticesArista &,const VerticesArista &);
53  };
54 
55 bool operator==(const VerticesArista &,const VerticesArista &);
56 
58 //
60 class VerticesCara: public std::list<size_t>
61  {
62  bool visitada;
63  public:
64  typedef std::list<size_t> base;
65  typedef base::iterator iterator;
66  typedef base::const_iterator const_iterator;
67  VerticesCara(void);
68  void setVisitada(const bool &);
69  const bool &yaVisitada(void) const;
70  void swap(void);
71  Pos3dList getPosVertices(const std::vector<Pos3d> &) const;
72  Pos3d getCentroide(const std::vector<Pos3d> &) const;
73  std::list<VerticesArista> getEdges(void) const;
74  bool tieneArista(const VerticesArista &) const;
75  bool tieneAristaOrientada(const VerticesArista &) const;
76  std::deque<VerticesCara> compartenArista(const std::deque<VerticesCara> &) const;
77  void Print(std::ostream &os) const;
78  };
79 
80 std::ostream &operator<<(std::ostream &, const VerticesCara &);
81 
83 //
85 class VertexMap
86  {
87  std::vector<Pos3d> vertices;
88  std::deque<VerticesCara > caras;
89  public:
91  const std::vector<Pos3d> &getVertices(void) const;
92  Pos3d getCentroide(void) const;
93  size_t getNumVertices(void) const;
94  size_t getNumCaras(void) const;
95  const std::deque<VerticesCara> &getCaras(void) const;
96  const VerticesCara &getCara(const size_t &) const;
97  std::deque<VerticesCara *> tienenArista(const VerticesArista &);
98  void makeConsistent(void);
99  void Print(std::ostream &os) const;
100  };
101 
102 std::ostream &operator<<(std::ostream &, const VertexMap &);
103 
105 class BuildFromVertexMap: public CGAL::Modifier_base<Polyhedron3d::HalfedgeDS>
106  {
107  const VertexMap vertex_map;
108  public:
110  void operator()(Polyhedron3d::HalfedgeDS &);
111  };
112 #endif
Vertices of a polyhedron face.
Definition: VertexMap.h:60
Mapa tipo «tensor disperso».
Definition: TripletMap.h:42
Vertices of a polyhedron edge.
Definition: VertexMap.h:40
Polyhedron vertex map.
Definition: VertexMap.h:85
Creates a polyhedron from a vertex map.
Definition: VertexMap.h:105
List of 3D positions.
Definition: Pos3dList.h:36
Posición en tres dimensiones.
Definition: Pos3d.h:44