libsurf
Programmer's Documentation

topovertex.h (r6227/r5398)
1 
2 /* Copyright (C) 2015 David Eller <david@larosterna.com>
3  *
4  * Commercial License Usage
5  * Licensees holding valid commercial licenses may use this file in accordance
6  * with the terms contained in their respective non-exclusive license agreement.
7  * For further information contact david@larosterna.com .
8  *
9  * GNU General Public License Usage
10  * Alternatively, this file may be used under the terms of the GNU General
11  * Public License version 3.0 as published by the Free Software Foundation and
12  * appearing in the file gpl.txt included in the packaging of this file.
13  */
14 
15 #ifndef SURF_TOPOVERTEX_H
16 #define SURF_TOPOVERTEX_H
17 
18 #include "forward.h"
19 #include <genua/point.h>
20 
27 {
28 public:
29 
30  enum Corner {NoCorner, SouthWest, SouthEast, NorthEast, NorthWest};
31 
33  explicit TopoVertex(const Vct3 &p) : m_position(p) {}
34 
36  TopoVertex(const Topology &topo, uint iface, const Vct2 &uvp);
37 
39  TopoVertex(const Topology &topo, uint ifa, const Vct2 &uva,
40  uint ifb, const Vct2 &uvb);
41 
43  uint append(uint iface, const Vct2 &uvp);
44 
46  void merge(const TopoVertex &v);
47 
49  uint findFace(uint iface) const {
50  const int nf = m_faces.size();
51  for (int i=0; i<nf; ++i)
52  if (m_faces[i] == iface)
53  return i;
54  return NotFound;
55  }
56 
58  const Vct3 &pos() const {return m_position;}
59 
61  bool closeTo(const TopoVertex &v, Real tol = gmepsilon) const {
62  return (sq(m_position - v.m_position) < sq(tol));
63  }
64 
66  const Indices & faces() const {return m_faces;}
67 
69  const PointList<2> & uvpos() const {return m_uvp;}
70 
72  const Vct2 &uvpos(uint k) const {return m_uvp[k];}
73 
75  int cornerType(uint gface) const {
76  uint k = findFace(gface);
77  if (k != NotFound)
78  return classifyCorner(m_uvp[k]);
79  else
80  return NoCorner;
81  }
82 
84  void print(uint k, std::ostream &os) const;
85 
87  static int classifyCorner(const Vct2 &p) {
88  Real u(p[0]), v(p[1]);
89  if (u == 0 and v == 0)
90  return SouthWest;
91  else if (u == 1 and v == 0)
92  return SouthEast;
93  else if (u == 1 and v == 1)
94  return NorthEast;
95  else if (u == 0 and v == 1)
96  return NorthWest;
97  return NoCorner;
98  }
99 
100 private:
101 
104 
106  Indices m_faces;
107 
110 };
111 
112 #endif // TOPOVERTEX_H
const PointList< 2 > & uvpos() const
parameter-space location on faces
Definition: topovertex.h:69
const Vct2 & uvpos(uint k) const
parameter-space location on face k
Definition: topovertex.h:72
int cornerType(uint gface) const
classify vertex corner on global face index gface
Definition: topovertex.h:75
void merge(const TopoVertex &v)
merge with another vertex
Definition: topovertex.cpp:47
static int classifyCorner(const Vct2 &p)
classify a vertex according to corner description
Definition: topovertex.h:87
Topological vertex.
Definition: topovertex.h:26
TopoVertex(const Vct3 &p)
create vertex
Definition: topovertex.h:33
Container for topology information.
Definition: topology.h:30
uint findFace(uint iface) const
find local index of face iface
Definition: topovertex.h:49
bool closeTo(const TopoVertex &v, Real tol=gmepsilon) const
test whether vertex is close to another one
Definition: topovertex.h:61
PointList< 2 > m_uvp
parameter-space location on faces
Definition: topovertex.h:109
const Indices & faces() const
faces to which this vertex is attached
Definition: topovertex.h:66
void print(uint k, std::ostream &os) const
plain text debugging output
Definition: topovertex.cpp:57
uint append(uint iface, const Vct2 &uvp)
append face
Definition: topovertex.cpp:39
Vct3 m_position
location in 3D space
Definition: topovertex.h:103
const Vct3 & pos() const
access location
Definition: topovertex.h:58
Indices m_faces
indices of faces on which this point lies
Definition: topovertex.h:106
Generated on Mon Jan 24 2022 03:03:16 for libsurf by   doxygen 1.8.5