libsurf
Programmer's Documentation

ttinode.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_TTINODE_H
16 #define SURF_TTINODE_H
17 
18 #include "forward.h"
19 #include <vector>
20 #include <genua/svector.h>
21 
22 class TTIntersection;
23 
29 class TTiNode
30 {
31  public:
32 
34  TTiNode() : bEnforced(false) {
35  std::fill(mpp, mpp+3, (const MeshComponent*) 0);
36  }
37 
39  TTiNode(const Vct3 & pt) : p(pt), bEnforced(false) {
40  std::fill(mpp, mpp+3, (const MeshComponent*) 0);
41  assert(std::isfinite(dot(pt,pt)));
42  }
43 
45  bool attach(const TTIntersection & sa, const TTIntersection & sb);
46 
48  void parametric(uint k, const MeshComponent *s, const Vct2 & uv) {
49  assert(k < 3);
50  mpp[k] = s;
51  q[k] = uv;
52  }
53 
55  uint addParametric(const MeshComponent *s, const Vct2 & uv, uint ctr[]) {
56  uint k;
57  for (k = 0; k < 3; ++k) {
58  if (mpp[k] == s or mpp[k] == 0)
59  break;
60  }
61  assert(k < 3);
62  mpp[k] = s;
63  q[k] += uv; // accumulate uv, divided by count in average()
64  ++ctr[k];
65  return k;
66  }
67 
69  void average(const uint ctr[]);
70 
72  const Vct3 & location() const {return p;}
73 
75  const Vct3 & normal() const {return nrm;}
76 
78  uint index(const MeshComponent *s) const {
79  for (int k=0; k<3; ++k) {
80  if (mpp[k] == s)
81  return k;
82  }
83  return NotFound;
84  }
85 
87  const Vct2 & parameter(uint k) const {
88  assert(k < 3);
89  return q[k];
90  }
91 
93  bool enforced() const {return bEnforced;}
94 
96  void enforced(bool flag) {bEnforced = flag;}
97 
99  Real gap() const;
100 
102  void snapToBoundary(Real tol);
103 
105  bool onBoundary(Real tol = gmepsilon) const;
106 
108  void localCriteria(Real & maxlen, Real & minlen, Real & maxphi) const;
109 
111  Real reproject(int niter, Real maxdst, Real dtol);
112 
114  void mesh2surface();
115 
116  private:
117 
119  const MeshComponent *mpp[3];
120 
122  Vct2 q[3];
123 
125  Vct3 p, nrm;
126 
128  bool bEnforced;
129 };
130 
131 typedef std::vector<TTiNode> TTiNodeArray;
132 
133 #endif
uint index(const MeshComponent *s) const
find index of patch pointer
Definition: ttinode.h:78
Vct2 q[3]
parameter space coordinates on three surfaces
Definition: ttinode.h:122
Real reproject(int niter, Real maxdst, Real dtol)
reduce gap by means of repeated projection
Definition: ttinode.cpp:100
const Vct2 & parameter(uint k) const
access uv-parameter on patch k
Definition: ttinode.h:87
void enforced(bool flag)
change enforcement status
Definition: ttinode.h:96
TTiNode(const Vct3 &pt)
define node with 3D point alone
Definition: ttinode.h:39
void average(const uint ctr[])
compute average
Definition: ttinode.cpp:23
void mesh2surface()
replace position in mesh by mean location on surfaces
Definition: ttinode.cpp:141
const Vct3 & location() const
location in 3D space
Definition: ttinode.h:72
bool bEnforced
indicates that one attached intersection was enforced
Definition: ttinode.h:128
Triangle-triangle intersection.
Definition: ttintersection.h:37
bool onBoundary(Real tol=gmepsilon) const
return true if this node is on any surface boundary
Definition: ttinode.cpp:177
void localCriteria(Real &maxlen, Real &minlen, Real &maxphi) const
determine local filter criteria from attached components
Definition: ttinode.cpp:193
void parametric(uint k, const MeshComponent *s, const Vct2 &uv)
set surface and parametric point association
Definition: ttinode.h:48
Point shared by two (or more) intersection segments.
Definition: ttinode.h:29
const MeshComponent * mpp[3]
for now, a node may be on max three surfaces
Definition: ttinode.h:119
Mesh component.
Definition: meshcomponent.h:36
Vct3 p
location and normal in physical space
Definition: ttinode.h:125
Real gap() const
gap between defined surfaces
Definition: ttinode.cpp:81
uint addParametric(const MeshComponent *s, const Vct2 &uv, uint ctr[])
add parametric values for averaging
Definition: ttinode.h:55
bool attach(const TTIntersection &sa, const TTIntersection &sb)
standard attachment to two intersection segments
Definition: ttinode.cpp:35
const Vct3 & normal() const
normal in 3D space
Definition: ttinode.h:75
void snapToBoundary(Real tol)
move parameter towards boundary if within tol
Definition: ttinode.cpp:159
bool enforced() const
true if one of the attached segments is enforced
Definition: ttinode.h:93
TTiNode()
undefined node
Definition: ttinode.h:34
Generated on Wed Jan 19 2022 03:03:15 for libsurf by   doxygen 1.8.5