-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathextract_hex_edge.cc
More file actions
126 lines (113 loc) · 3.73 KB
/
Copy pathextract_hex_edge.cc
File metadata and controls
126 lines (113 loc) · 3.73 KB
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
//#############################################################################
//#
//# Copyright 2008-2025, Mississippi State University
//#
//# This file is part of the Loci Framework.
//#
//# The Loci Framework is free software: you can redistribute it and/or modify
//# it under the terms of the Lesser GNU General Public License as published by
//# the Free Software Foundation, either version 3 of the License, or
//# (at your option) any later version.
//#
//# The Loci Framework is distributed in the hope that it will be useful,
//# but WITHOUT ANY WARRANTY; without even the implied warranty of
//# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
//# Lesser GNU General Public License for more details.
//#
//# You should have received a copy of the Lesser GNU General Public License
//# along with the Loci Framework. If not, see <http://www.gnu.org/licenses>
//#
//#############################################################################
#include <vector>
#include <queue>
#include <iostream>
#include "tables.h"
using std::queue;
using std::cerr;
using std::endl;
//using namespace std;
/**
* @file extract_hex_edge.cc
* @brief Extracts one quad-face edge refinement plan from a face refinement
* plan.
*
* The implementation walks the face plan in breadth-first order without
* constructing a Face or QuadFace tree. `edgeIDTable` selects which child
* branches contribute to the requested edge, and `edgeCodeTable` maps face
* split codes to edge split codes.
*/
/**
* Extracts the refinement plan for one edge of a quadrilateral face.
*
* The output vector is replaced with the extracted edge plan. Leading and
* trailing no-op entries, including the special propagation code `8`, are
* trimmed after extraction.
*
* @param facePlan Breadth-first quad-face refinement plan.
* @param edgePlan Output edge plan for edge @p dd.
* @param dd Quad-face edge index, used to select `edgeIDTable` and
* `edgeCodeTable` rows.
*/
void extract_quad_edge(const std::vector<char>& facePlan, std::vector<char>& edgePlan, unsigned int dd) {
//output edgeCodeTable
/* for(int i=0; i<12; i++){
if(i%3==0) cout<< endl;
cout << edgeCodeTable[i] <<',';
}
cout << endl << endl;
*/
//output edgeIDTable
/* for(int i=0; i<12; i++){
if(i%3 == 0)cout <<endl;
cout <<'{';
for(int j=0; j<edgeIDTable[i].size(); j++) cout<<edgeIDTable[i][j]<<',';
cout <<'}';
}
cout << endl;
*/
if(facePlan.size() == 0) {
edgePlan.clear() ;
return ;
}
unsigned int index = 0 ;
queue<bool> Q ;
Q.push(true) ;
bool needExtract ;
char faceCode, edgeCode ;
while(!Q.empty()) {
needExtract = Q.front() ;
if(index >= facePlan.size()) {
break ;
}else {
faceCode = facePlan[index++] ;
}
//cout << "faceCode: " << faceCode <<endl ;
if(needExtract) {
if(faceCode == 0) {
edgeCode = 0 ;
}else {
edgeCode = edgeCodeTable[dd*3 + faceCode-1] ;
}
edgePlan.push_back(edgeCode) ;
//cout << "face: " << faceCode <<" " << "edge: " << edgeCode << endl ;
}
if(faceCode != 0) {
std::vector<bool> childrenID = edgeIDTable[dd*3+faceCode-1] ;
if(!needExtract) {
for(unsigned int i = 0; i < childrenID.size(); i++)childrenID[i] = 0 ;
}
for(unsigned int i = 0; i < childrenID.size(); i++) {
Q.push(childrenID[i]) ;
}
}
Q.pop() ;
}
// delete 0 and 8 in the beginning of edgeplan
while((edgePlan.size() != 0) && ((edgePlan.front() == 0)||(edgePlan.front() == 8))) {
edgePlan.erase(edgePlan.begin()) ;
}
// delete 0 and 8 at the end of faceplan
while((edgePlan.size() != 0) && ((edgePlan.back() == 0)||(edgePlan.back() == 8))) {
edgePlan.pop_back() ;
}
}