forked from davinakano/tri-quad-mesh-converter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmeshref.h
122 lines (76 loc) · 2.4 KB
/
meshref.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
#ifndef MESHREF_H
#define MESHREF_H
#include "types.h"
#include "macros.h"
#include "vtkReader.h"
#include "stdlib.h"
#include <sstream>
class MeshRef{
public:
QMesh* mesh;
geodesics* geo;
adgFDCel* adg;
MeshRef(QMesh* m, geodesics* g, adgFDCel* a){
mesh = m;
geo = g;
adg = a;
}
~MeshRef(){
}
geodesics::GP* findMiddlePoint( QFace* qf, geodesics::GP* v1, geodesics::GP* v2 ) {
ASSERT( qf );
ASSERT( v1 );
ASSERT( v2 );
std::list< geodesics::GP* > lv;
geo->setRegion( qf );
geo->compute(v1,v2,lv);
ASSERT( lv.size() > 1 );
geodesics::GP *g = NULL;
if ( lv.size() == 2 ) {
// pegar o meio
// g = ?
} else {
std::list< geodesics::GP* >::iterator it = lv.begin();
for ( unsigned i=0 ; i < lv.size()/2 ; i++)
it++;
g = *it;
}
return g;
}
void split(QHalfedge* Qh){
QHalfedge* Qh2;
Qh2 = Qh;
std::list< geodesics::GP* > gpList;
do {
geodesics::GP* gpMiddle = findMiddlePoint( Qh2->get_face(), Qh2->get_origin()->get_attributes().getGP() ,
Qh2->get_next()->get_origin()->get_attributes().getGP() );
ASSERT( gpMiddle );
gpList.push_back(gpMiddle);
Qh2 = Qh2->get_next()->get_next()->get_mate();
} while (Qh != Qh2);
double *points = new double[3*gpList.size()];
int i = 0;
std::list< geodesics::GP* >::iterator itgpList = gpList.begin();
for ( ; itgpList != gpList.end() ; itgpList++ )
{
double x,y,z;
geodesics::GP* gpoint = *itgpList;
gpoint->get_coords(adg,x,y,z);
points[3*i] = x;
points[3*i+1] = y;
points[3*i+2] = z;
i++;
}
QOperators qop(mesh);
std::list< QVertex* > qvList;
qvList = qop.split_strip(Qh, gpList.size(), points);
ASSERT( gpList.size() == qvList.size() );
itgpList = gpList.begin();
for ( std::list< QVertex* >::iterator itqvList = qvList.begin(); itqvList != qvList.end() ; itqvList++){
QVertex* q = *itqvList;
q->get_attributes().setGP(*itgpList);
itgpList++;
}
}
};
#endif // MESHREF_H