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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283 | //
// File: CubitQuadFacetData.cpp
//
// Owner: sjowen
//
#include "CubitQuadFacetData.hpp"
#include "CubitPoint.hpp"
#include "CubitFacetEdge.hpp"
#include "CubitFacetEdgeData.hpp"
#include "CubitFacet.hpp"
#include "CubitFacetData.hpp"
//===========================================================================
// Function: CubitQuadFacetData
// Purpose: constructor
// Notes: defines a quad facet given two existing triangle facets.
// The points on the facet are also passed in so the quad
// can be oriented with respect to its triangles
// Date: 4/11/01
// Author: sjowen
//===========================================================================
CubitQuadFacetData::CubitQuadFacetData(
CubitFacet *tri_facets[2],
CubitPoint *points[4] )
{
myTriangleFacets[0] = tri_facets[0];
myTriangleFacets[1] = tri_facets[1];
CubitBoolean found = CUBIT_FALSE;<--- Variable 'found' is assigned a value that is never used.
CubitPoint *pt;
int ii, jj, kk;
for (jj=0; jj<2; jj++)
{
for (kk=0; kk<3; kk++)
{
pt = myTriangleFacets[jj]->point(kk);
found = CUBIT_FALSE;
for (ii=0; ii<4 && !found; ii++)
{
if (points[ii] == pt)
{
triToQuadIndex[jj][kk] = ii;
found = CUBIT_TRUE;
}
}
// If assertion occurs, the that points passed to the constructor do
// not match the points on the triangle facets
assert(found == CUBIT_TRUE);
}
}
}
//===========================================================================
// Function: CubitQuadFacetData
// Purpose: constructor
// Notes: defines a quad facet given its ordered point array.
// Two triangle facets are created
// Date: 4/11/01
// Author: sjowen
//===========================================================================
CubitQuadFacetData::CubitQuadFacetData(
CubitPoint *point0, CubitPoint *point1,
CubitPoint *point2, CubitPoint *point3 )
{
// The orientation of the triangles in the quad is arbitrary.
// We may want to split based on some other criteria (ie. angles)
myTriangleFacets[0] = new CubitFacetData( point0, point1, point2 );
myTriangleFacets[1] = new CubitFacetData( point2, point3, point0 );
triToQuadIndex[0][0] = 0;
triToQuadIndex[0][1] = 1;
triToQuadIndex[0][2] = 2;
triToQuadIndex[1][0] = 2;
triToQuadIndex[1][1] = 3;
triToQuadIndex[1][2] = 0;
}
//===========================================================================
// Function: CubitQuadFacetData
// Purpose: constructor
// Notes: defines a quad facet given its ordered edge array.
// Two triangle facets are created
// Date: 4/11/01
// Author: sjowen
//===========================================================================
CubitQuadFacetData::CubitQuadFacetData(
CubitFacetEdge *e0, CubitFacetEdge *e1,
CubitFacetEdge *e2, CubitFacetEdge *e3 )
{
// create the diagonal edge
CubitPoint *p0 = e3->shared_point(e0);
CubitPoint *p2 = e1->shared_point(e2);
assert(p0 != NULL && p2 != NULL);
CubitFacetEdge *e4 = (CubitFacetEdge *) new CubitFacetEdgeData( p0, p2 );
// create the triangles
myTriangleFacets[0] = new CubitFacetData( e1, e4, e0 );
myTriangleFacets[1] = new CubitFacetData( e3, e4, e2 );
triToQuadIndex[0][0] = 0;
triToQuadIndex[0][1] = 1;
triToQuadIndex[0][2] = 2;
triToQuadIndex[1][0] = 2;
triToQuadIndex[1][1] = 3;
triToQuadIndex[1][2] = 0;
}
//===========================================================================
// Function: CubitQuadFacetData
// Purpose: constructor
// Notes: defines a quad facet given its ordered point array.
// Two triangle facets are created
// Date: 4/11/01
// Author: sjowen
//===========================================================================
CubitQuadFacetData::CubitQuadFacetData(
CubitPoint *points[4] )
{
// The orientation of the triangles in the quad is arbitrary.
// We may want to split based on some other criteria (ie. angles)
myTriangleFacets[0] = new CubitFacetData( points[0], points[1], points[2] );
myTriangleFacets[1] = new CubitFacetData( points[2], points[3], points[0] );
triToQuadIndex[0][0] = 0;
triToQuadIndex[0][1] = 1;
triToQuadIndex[0][2] = 2;
triToQuadIndex[1][0] = 2;
triToQuadIndex[1][1] = 3;
triToQuadIndex[1][2] = 0;
}
//===========================================================================
// Function: ~CubitQuadFacetData
// Purpose: destructor
// Date: 4/11/01
// Author: sjowen
//===========================================================================
CubitQuadFacetData::~CubitQuadFacetData()
{
if (myTriangleFacets[0] == NULL && myTriangleFacets[1] == NULL)
return;
assert(myTriangleFacets[0] && myTriangleFacets[1]);
// determine the dialogonal edge
CubitPoint *p0 = this->point(0);
CubitPoint *p2 = this->point(2);
CubitFacetEdge *dedge = NULL;
if (p0 != NULL && p2 != NULL)
{
dedge = p0->shared_edge(p2);
}
// delete both triangles
delete myTriangleFacets[0];
delete myTriangleFacets[1];
// delete the dialgonal edge
if (dedge != NULL)
{
delete dedge;
}
}
//===========================================================================
// Function: ~CubitQuadFacetData
// Purpose: destructor
// Date: 4/11/01
// Author: sjowen
//===========================================================================
void CubitQuadFacetData::remove_tri_facets( )
{
myTriangleFacets[0] = NULL;
myTriangleFacets[1] = NULL;
}
//===========================================================================
// Function: points
// Purpose: get the points from the facet
// Date: 4/11/01
// Author: sjowen
//===========================================================================
void CubitQuadFacetData::points(
CubitPoint *thepoints[4] )
{
thepoints[triToQuadIndex[0][0]] = myTriangleFacets[0]->point(0);
thepoints[triToQuadIndex[0][1]] = myTriangleFacets[0]->point(1);
thepoints[triToQuadIndex[0][2]] = myTriangleFacets[0]->point(2);
thepoints[triToQuadIndex[1][0]] = myTriangleFacets[1]->point(0);
thepoints[triToQuadIndex[1][1]] = myTriangleFacets[1]->point(1);
thepoints[triToQuadIndex[1][2]] = myTriangleFacets[1]->point(2);
}
//===========================================================================
// Function: point
// Purpose: get the point from the facet
// Date: 11/28/2002
// Author: sjowen
//===========================================================================
CubitPoint *CubitQuadFacetData::point( int index )
{
int ii, jj;
for (ii=0; ii<2; ii++)
{
for (jj=0; jj<3; jj++)
{
if (triToQuadIndex[ii][jj] == index)
{
return myTriangleFacets[ii]->point(jj);
}
}
}
assert(0); // index is probably out of range
return NULL;
}
//===========================================================================
// Function: edge
// Purpose: get the edge from the facet
// Date: 11/28/2002
// Author: sjowen
//===========================================================================
CubitFacetEdge *CubitQuadFacetData::edge( int index )
{
int ii, jj;
CubitPoint *p0 = NULL;
CubitPoint *p1 = NULL;
int index1 = (index + 1) % 4;
for (ii=0; ii<2; ii++)
{
for (jj=0; jj<3; jj++)
{
if (triToQuadIndex[ii][jj] == index)
{
p0 = myTriangleFacets[ii]->point(jj);
}
else if ( triToQuadIndex[ii][jj] == index1 )
{
p1 = myTriangleFacets[ii]->point(jj);
}
}
}
assert(p0 != NULL && p1 != NULL); // index is probably out of range
return p0->shared_edge( p1 );
}
//===========================================================================
// Function: get_tri_facet
// Purpose: return the underlying triangle of which the point_ptr is a vertex
// Date: 11/28/2002
// Author: sjowen
//===========================================================================
CubitFacet *CubitQuadFacetData::get_tri_facet_at_point( CubitPoint *point_ptr )
{
int ii, jj;
for (ii=0; ii<2; ii++)
{
for (jj=0; jj<3; jj++)
{
if (myTriangleFacets[ii]->point(jj) == point_ptr)
{
return myTriangleFacets[ii];
}
}
}
assert(0); // point isn't on facet
return NULL;
}
|