Panda3D
Loading...
Searching...
No Matches
eggMesherEdge.I
Go to the documentation of this file.
1/**
2 * PANDA 3D SOFTWARE
3 * Copyright (c) Carnegie Mellon University. All rights reserved.
4 *
5 * All use of this software is subject to the terms of the revised BSD
6 * license. You should have received a copy of this license along
7 * with this source code in a file named "LICENSE."
8 *
9 * @file eggMesherEdge.I
10 * @author drose
11 * @date 2005-03-13
12 */
13
14/**
15 * Defines an edge as a pair of vertices. The _opposite pointer should be
16 * filled in explicitly by the caller.
17 */
19EggMesherEdge(int vi_a, int vi_b) : _vi_a(vi_a), _vi_b(vi_b) {
20 _opposite = nullptr;
21}
22
23/**
24 *
25 */
26INLINE EggMesherEdge::
27EggMesherEdge(const EggMesherEdge &copy) :
28 _vi_a(copy._vi_a),
29 _vi_b(copy._vi_b),
30 _strips(copy._strips),
31 _opposite(copy._opposite)
32{
33}
34
35/**
36 * Returns true if the edge contains the indicated vertex index, false
37 * otherwise.
38 */
39INLINE bool EggMesherEdge::
40contains_vertex(int vi) const {
41 return (_vi_a == vi || _vi_b == vi);
42}
43
44/**
45 * Returns true if this edge represents the same line segment as the other
46 * edge, in either direction.
47 */
48INLINE bool EggMesherEdge::
49matches(const EggMesherEdge &other) const {
50 return ((_vi_a == other._vi_a && _vi_b == other._vi_b) ||
51 (_vi_b == other._vi_a && _vi_a == other._vi_b));
52}
53
54/**
55 * Returns an arbitrary pointer that is used to represent both this edge and
56 * its opposite. this->common_ptr() is guaranteed to be the same as
57 * this->_opposite->common_ptr().
58 */
60common_ptr() {
61 return (std::min)(this, _opposite);
62}
63
64/**
65 *
66 */
67INLINE bool EggMesherEdge::
68operator == (const EggMesherEdge &other) const {
69 return _vi_a == other._vi_a && _vi_b == other._vi_b;
70}
71
72/**
73 *
74 */
75INLINE bool EggMesherEdge::
76operator != (const EggMesherEdge &other) const {
77 return !operator == (other);
78}
79
80/**
81 * Defines an arbitrary ordering for edges, used for putting edges in a sorted
82 * container.
83 */
84INLINE bool EggMesherEdge::
85operator < (const EggMesherEdge &other) const {
86 if (_vi_a != other._vi_a) {
87 return _vi_a < other._vi_a;
88 }
89 return _vi_b < other._vi_b;
90}
91
92/**
93 * Returns the length of the edge in model units.
94 */
95INLINE double EggMesherEdge::
96compute_length(const EggVertexPool *vertex_pool) const {
97 LPoint3d a = vertex_pool->get_vertex(_vi_a)->get_pos3();
98 LPoint3d b = vertex_pool->get_vertex(_vi_b)->get_pos3();
99 return (a - b).length();
100}
101
102/**
103 * Returns a 3-component vector that represents the lengths of the sides of
104 * the smalled axis-aligned box that contains the edge. That is, the
105 * projection the edge onto each axis.
106 */
107INLINE LVecBase3d EggMesherEdge::
108compute_box(const EggVertexPool *vertex_pool) const {
109 LPoint3d a = vertex_pool->get_vertex(_vi_a)->get_pos3();
110 LPoint3d b = vertex_pool->get_vertex(_vi_b)->get_pos3();
111 LVector3d v = (a - b);
112 return LVecBase3d(fabs(v[0]), fabs(v[1]), fabs(v[2]));
113}
Represents one edge of a triangle, as used by the EggMesher to discover connected triangles.
EggMesherEdge(int vi_a, int vi_b)
Defines an edge as a pair of vertices.
double compute_length(const EggVertexPool *vertex_pool) const
Returns the length of the edge in model units.
bool matches(const EggMesherEdge &other) const
Returns true if this edge represents the same line segment as the other edge, in either direction.
EggMesherEdge * common_ptr()
Returns an arbitrary pointer that is used to represent both this edge and its opposite.
bool operator<(const EggMesherEdge &other) const
Defines an arbitrary ordering for edges, used for putting edges in a sorted container.
LVecBase3d compute_box(const EggVertexPool *vertex_pool) const
Returns a 3-component vector that represents the lengths of the sides of the smalled axis-aligned box...
bool contains_vertex(int vi) const
Returns true if the edge contains the indicated vertex index, false otherwise.
A collection of vertices.
EggVertex * get_vertex(int index) const
Returns the vertex in the pool with the indicated index number, or NULL if no vertices have that inde...
LVertexd get_pos3() const
Valid if get_num_dimensions() returns 3 or 4.
Definition eggVertex.I:131