libsurf
Programmer's Documentation

ttintersection.h (r6227/r5385)
1 /* Copyright (C) 2015 David Eller <david@larosterna.com>
2  *
3  * This program is free software; you can redistribute it and/or modify it under
4  * the terms of the GNU General Public License as published by the Free Software
5  * Foundation; either version 2 of the License, or (at your option) any later
6  * version. This program is distributed in the hope that it will be useful, but
7  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
8  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
9  * details. You should have received a copy of the GNU General Public License
10  * along with this program; if not, write to the Free Software Foundation,
11  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
12  */
13 
14 #ifndef SURF_TTINTERSECTION_H
15 #define SURF_TTINTERSECTION_H
16 
17 #include <deque>
18 #include <boost/shared_ptr.hpp>
19 #include <genua/svector.h>
20 #include <genua/defines.h>
21 #include "surface.h"
22 
23 class TriFace;
24 class TTIntersector;
25 class MeshFields;
26 class MeshComponent;
27 
28 class TTIntersection;
29 typedef boost::shared_ptr<TTIntersection> TTIntersectionPtr;
30 typedef std::deque<TTIntersectionPtr> TTIntersectionArray;
31 
38 {
39  public:
40 
41  enum TTiConTop {tti_s2s, tti_s2t, tti_t2s, tti_t2t, tti_none};
42 
44  TTIntersection() : itor(0), bEnforced(false) {}
45 
47  TTIntersection(const TTIntersector *tti, uint t1, uint t2);
48 
50  TTIntersection(const TTIntersector *tti, uint t1, uint t2,
51  const Vct3 & ps, const Vct3 & pt);
52 
54  bool enforced() const {return bEnforced;}
55 
57  uint first() const {return itri1;}
58 
60  uint second() const {return itri2;}
61 
63  const MeshComponent *firstPatch() const;
64 
66  const MeshComponent *secondPatch() const;
67 
69  void source(uint i) {nsrc = i;}
70 
72  void target(uint i) {ntrg = i;}
73 
75  uint source() const {return nsrc;}
76 
78  uint target() const {return ntrg;}
79 
81  uint opposed(uint n) const {
82  if (n == nsrc)
83  return ntrg;
84  else if (n == ntrg)
85  return nsrc;
86  else
87  return NotFound;
88  }
89 
91  const Vct3 & srcPoint() const {return isrc;}
92 
94  const Vct3 & trgPoint() const {return itrg;}
95 
97  void srcParameter(Vct2 & q1, Vct2 & q2) const;
98 
100  void trgParameter(Vct2 & q1, Vct2 & q2) const;
101 
103  void srcOnBoundary(Real tol, bool & ubound, bool & vbound) const;
104 
106  void trgOnBoundary(Real tol, bool & ubound, bool & vbound) const;
107 
109  void surfaces(SurfacePtr & psf1, SurfacePtr & psf2) const;
110 
112  TTiConTop nearestConnection(const TTIntersection & a, Real & dist) const;
113 
115  Real length() const {return norm(isrc-itrg);}
116 
118  Real localDimension() const;
119 
121  bool intersect();
122 
124  void addViz(MeshFields & mvz) const;
125 
127  Real intersectsFace(uint tt) const;
128 
130  TTIntersectionPtr split(Real t);
131 
132  private:
133 
135  Vct2 uvProjection(const TriFace & f, const Vct3 & p) const;
136 
137  private:
138 
140  Vct3 isrc, itrg;
141 
144 
146  uint itri1, itri2;
147 
149  uint nsrc, ntrg;
150 
152  bool bEnforced;
153 };
154 
155 inline bool operator< (const TTIntersectionPtr & a, const TTIntersectionPtr & b)
156 {
157  uint a1 = a->first();
158  uint b1 = b->first();
159  if (a1 < b1)
160  return true;
161  else if (a1 > b1)
162  return false;
163  else
164  return (a->second() < b->second());
165 }
166 
167 inline bool operator== (const TTIntersectionPtr & a, const TTIntersectionPtr & b)
168 {
169  return ((a->first() == b->first()) and (a->second() == b->second()));
170 }
171 
172 inline bool less_by_nodes(const TTIntersectionPtr & a, const TTIntersectionPtr & b)
173 {
174  uint a1 = a->source();
175  uint b1 = b->source();
176  if (a1 < b1)
177  return true;
178  else if (a1 > b1)
179  return false;
180  else
181  return (a->target() < b->target());
182 }
183 
184 inline bool equal_by_nodes(const TTIntersectionPtr & a, const TTIntersectionPtr & b)
185 {
186  return ((a->source() == b->source()) and (a->target() == b->target()));
187 }
188 
189 #endif
void srcOnBoundary(Real tol, bool &ubound, bool &vbound) const
check if source point is on a boundary
Definition: ttintersection.cpp:152
const MeshComponent * secondPatch() const
access mesh patch
Definition: ttintersection.cpp:55
TTIntersection()
undefined intersection
Definition: ttintersection.h:44
uint nsrc
nodes corresponding to isrc and itrg
Definition: ttintersection.h:149
bool enforced() const
return whether this intersection was enforced explicitly
Definition: ttintersection.h:54
Triangle-triangle intersection.
Definition: ttintersection.h:37
Mesh component.
Definition: meshcomponent.h:36
void surfaces(SurfacePtr &psf1, SurfacePtr &psf2) const
pointer to surfaces
Definition: ttintersection.cpp:180
Real intersectsFace(uint tt) const
check if this intersection segment intersects test triangle tt
Definition: ttintersection.cpp:191
void trgParameter(Vct2 &q1, Vct2 &q2) const
parameter position of trg point
Definition: ttintersection.cpp:144
const TTIntersector * itor
pointer to intersector
Definition: ttintersection.h:143
void trgOnBoundary(Real tol, bool &ubound, bool &vbound) const
check if target point is on a boundary
Definition: ttintersection.cpp:166
void srcParameter(Vct2 &q1, Vct2 &q2) const
parameter position of src point
Definition: ttintersection.cpp:136
TTIntersectionPtr split(Real t)
split, change this and return a new segment at triangle tt
Definition: ttintersection.cpp:228
const MeshComponent * firstPatch() const
access mesh patch
Definition: ttintersection.cpp:47
void addViz(MeshFields &mvz) const
add line to visualization object
Definition: ttintersection.cpp:264
uint target() const
access node number
Definition: ttintersection.h:78
TTiConTop nearestConnection(const TTIntersection &a, Real &dist) const
compute likely connection pattern
Definition: ttintersection.cpp:91
bool bEnforced
enforced point - cannot be filtered out
Definition: ttintersection.h:152
uint second() const
access triangle index
Definition: ttintersection.h:60
Intersect triangle meshes.
Definition: ttintersector.h:36
const Vct3 & srcPoint() const
access segment start point
Definition: ttintersection.h:91
Vct3 isrc
intersection points in space
Definition: ttintersection.h:140
void source(uint i)
set node number
Definition: ttintersection.h:69
uint itri1
triangles involved
Definition: ttintersection.h:146
Real length() const
segment length
Definition: ttintersection.h:115
Vct2 uvProjection(const TriFace &f, const Vct3 &p) const
compute parametric value of a projection
Definition: ttintersection.cpp:114
uint source() const
access node number
Definition: ttintersection.h:75
void target(uint i)
set node number
Definition: ttintersection.h:72
bool intersect()
compute 3d intersection using Guige&#39;s method
Definition: ttintersection.cpp:63
uint first() const
access triangle index
Definition: ttintersection.h:57
const Vct3 & trgPoint() const
access segment start point
Definition: ttintersection.h:94
uint opposed(uint n) const
opposed node
Definition: ttintersection.h:81
Real localDimension() const
local length: minimum of sqrt(area) of both triangles
Definition: ttintersection.cpp:245
Generated on Wed Jan 19 2022 03:03:15 for libsurf by   doxygen 1.8.5