libsurf
Programmer's Documentation

tticonnection.h (r6227/r5385)
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_TTICONNECTION_H
16 #define SURF_TTICONNECTION_H
17 
18 #include <genua/svector.h>
19 #include <genua/defines.h>
20 
21 class MeshComponent;
22 class TTIntersector;
23 
34 {
35 public:
36 
38  TTiConnection() : acomp(0), bcomp(0) {}
39 
41  TTiConnection(const MeshComponent *ac, const Vct2 & a1, const Vct2 & a2,
42  const MeshComponent *bc, const Vct2 & b1, const Vct2 & b2)
43  : acomp(ac), bcomp(bc), ap1(a1), ap2(a2), bp1(b1), bp2(b2) {}
44 
46  void vconnect(const MeshComponent *ac, const MeshComponent *bc,
47  bool samesense=true) {
48  acomp = ac;
49  bcomp = bc;
50  ap1 = vct(0.0, 1.0);
51  ap2 = vct(1.0, 1.0);
52  if (samesense) {
53  bp1 = vct(0.0, 0.0);
54  bp2 = vct(1.0, 0.0);
55  } else {
56  bp1 = vct(1.0, 0.0);
57  bp2 = vct(0.0, 0.0);
58  }
59  }
60 
62  void uconnect(const MeshComponent *ac, const MeshComponent *bc,
63  bool samesense=true) {
64  acomp = ac;
65  bcomp = bc;
66  ap1 = vct(1.0, 0.0);
67  ap2 = vct(1.0, 1.0);
68  if (samesense) {
69  bp1 = vct(0.0, 0.0);
70  bp2 = vct(0.0, 1.0);
71  } else {
72  bp1 = vct(0.0, 1.0);
73  bp2 = vct(0.0, 0.0);
74  }
75  }
76 
78  bool appendSegments(TTIntersector & tti);
79 
80 private:
81 
82  struct ConVertex
83  {
84  public:
85  ConVertex() : cmp(0), vix(NotFound) {}
86  ConVertex(const MeshComponent *c, Real t, uint v)
87  : cmp(c), tc(t), vix(v) {}
88  bool operator< (const ConVertex & a) const {return tc < a.tc;}
89  bool operator== (const ConVertex & a) const {return tc == a.tc;}
90  const Vct3 & pos() const;
91  public:
92  const MeshComponent *cmp;
93  Real tc; // edge/border arclength parameter
94  uint vix; // vertex index
95  };
96 
97  typedef std::vector<ConVertex> ConVertexArray;
98 
100  bool collectCandidates(const MeshComponent *comp,
101  const Vct2 & p1, const Vct2 & p2,
102  Indices & edg);
103 
105  bool connectedPair(uint ae, uint be, Vct3 st[]) const;
106 
108  uint triangleFromEdge(const TTIntersector & tti,
109  const MeshComponent *comp, uint eix) const;
110 
112  uint triangleFromVertex(const TTIntersector & tti,
113  const MeshComponent *comp, uint vix) const;
114 
116  uint nearestEdge(const MeshComponent *cmp, const Indices & edges,
117  const Vct3 & p) const;
118 
119 private:
120 
122  const MeshComponent *acomp, *bcomp;
123 
125  Vct2 ap1, ap2, bp1, bp2;
126 
128  ConVertexArray bvx;
129 };
130 
131 typedef std::vector<TTiConnection> TTiConnectionArray;
132 
133 #endif // TTICONNECTION_H
Edge-edge connection between surfaces.
Definition: tticonnection.h:33
bool collectCandidates(const MeshComponent *comp, const Vct2 &p1, const Vct2 &p2, Indices &edg)
determine all edges of component which are on segment p1,p2
Definition: tticonnection.cpp:319
ConVertexArray bvx
connection vertices
Definition: tticonnection.h:128
bool connectedPair(uint ae, uint be, Vct3 st[]) const
test a pair of edges for possible connection
Definition: tticonnection.cpp:174
uint triangleFromEdge(const TTIntersector &tti, const MeshComponent *comp, uint eix) const
find the intersector triangle index from boundary edge
Definition: tticonnection.cpp:411
Mesh component.
Definition: meshcomponent.h:36
void vconnect(const MeshComponent *ac, const MeshComponent *bc, bool samesense=true)
connect v=1 of a with v=0 of b
Definition: tticonnection.h:46
TTiConnection(const MeshComponent *ac, const Vct2 &a1, const Vct2 &a2, const MeshComponent *bc, const Vct2 &b1, const Vct2 &b2)
construct connection, general form
Definition: tticonnection.h:41
bool appendSegments(TTIntersector &tti)
add intersection segments to intersector, requires sorted faces in tti
Definition: tticonnection.cpp:74
Vct2 ap1
connections are single linear segments
Definition: tticonnection.h:125
void uconnect(const MeshComponent *ac, const MeshComponent *bc, bool samesense=true)
connect u=1 of a with u=0 of b
Definition: tticonnection.h:62
TTiConnection()
undefined connection
Definition: tticonnection.h:38
Intersect triangle meshes.
Definition: ttintersector.h:36
Definition: tticonnection.h:82
uint triangleFromVertex(const TTIntersector &tti, const MeshComponent *comp, uint vix) const
find the intersector triangle index from boundary vertex
Definition: tticonnection.cpp:449
uint nearestEdge(const MeshComponent *cmp, const Indices &edges, const Vct3 &p) const
find the edge for which the foorpoint of p is nearest p
Definition: tticonnection.cpp:427
const MeshComponent * acomp
connected components
Definition: tticonnection.h:122
Generated on Mon Jan 24 2022 03:03:16 for libsurf by   doxygen 1.8.5