5 std::vector<chi_mesh::SurfaceMesh *> &patches)
7 typedef std::vector<chi_mesh::Face> FaceList;
8 typedef std::vector<FaceList*> FaceListCollection;
11 FaceList unsorted_faces;
12 FaceList::iterator cur_face;
13 for (cur_face = this->
faces_.begin();
14 cur_face != this->faces_.end();
17 unsorted_faces.push_back((*cur_face));
21 FaceListCollection co_planar_lists;
24 FaceList* first_list =
new FaceList;
25 co_planar_lists.push_back(first_list);
26 first_list->push_back(unsorted_faces.back());
27 unsorted_faces.pop_back();
30 FaceList::reverse_iterator us_face;
31 for (us_face = unsorted_faces.rbegin();
32 us_face != unsorted_faces.rend();
35 bool matchFound =
false;
38 FaceListCollection::iterator existing_list;
39 for (existing_list = co_planar_lists.begin();
40 existing_list != co_planar_lists.end();
43 for (cur_face = (*existing_list)->begin();
44 cur_face != (*existing_list)->end();
50 if (fabs(n1.
Dot(n2))>(1.0-1.0e-4))
52 (*existing_list)->push_back(unsorted_faces.back());
53 unsorted_faces.pop_back();
58 if (matchFound){
break;}
64 printf(
"New list created\n");
65 FaceList* new_list =
new FaceList;
66 new_list->push_back(unsorted_faces.back());
67 unsorted_faces.pop_back();
68 co_planar_lists.push_back(new_list);
72 printf(
"Number of co-planar collections=%lu\n",co_planar_lists.size());
74 FaceListCollection patch_list_collection;
77 FaceListCollection::iterator existing_list;
78 for (existing_list = co_planar_lists.begin();
79 existing_list != co_planar_lists.end();
83 FaceListCollection inner_patch_list_collection;
87 FaceList unused_faces;
88 for (cur_face = (*existing_list)->begin();
89 cur_face != (*existing_list)->end();
92 unused_faces.push_back((*cur_face));
96 FaceList* first_patch_list =
new FaceList;
97 inner_patch_list_collection.push_back(first_patch_list);
98 first_patch_list->push_back(unused_faces.back());
99 unused_faces.pop_back();
102 while (unused_faces.size()>0)
105 bool updateMade =
false;
106 FaceList::iterator us_face_f;
107 for (us_face_f = unused_faces.begin();
108 us_face_f != unused_faces.end();
112 FaceListCollection::iterator inner_list;
113 for (inner_list = inner_patch_list_collection.begin();
114 inner_list != inner_patch_list_collection.end();
117 for (cur_face = (*inner_list)->begin();
118 cur_face != (*inner_list)->end();
122 for (
int e=0; e<3; e++)
124 int vi = (*us_face_f).v_index[e];
125 for (
int e2=0; e2<3; e2++)
127 int vf = (*cur_face).v_index[e2];
131 (*inner_list)->push_back(*us_face_f);
132 unused_faces.erase(us_face_f);
137 if (updateMade){
break;}
139 if (updateMade){
break;}
141 if (updateMade){
break;}
144 if (updateMade){
break;}
149 FaceList* new_patch_list =
new FaceList;
150 inner_patch_list_collection.push_back(new_patch_list);
151 new_patch_list->push_back(unused_faces.back());
152 unused_faces.pop_back();
157 FaceListCollection::iterator inner_list;
158 for (inner_list = inner_patch_list_collection.begin();
159 inner_list != inner_patch_list_collection.end();
162 patch_list_collection.push_back(*inner_list);
167 printf(
"Number of patches = %lu\n", patch_list_collection.size());
170 FaceListCollection::iterator outer_patch;
171 for (outer_patch = patch_list_collection.begin();
172 outer_patch != patch_list_collection.end();
178 std::vector<int*> vertex_mapping;
180 for (cur_face = (*outer_patch)->begin();
181 cur_face != (*outer_patch)->end();
188 for (
int e=0;e<3;e++)
193 bool already_there =
false;
194 int* already_there_mapping;
195 std::vector<int*>::iterator cur_map;
196 for (cur_map = vertex_mapping.begin();
197 cur_map != vertex_mapping.end();
200 if ((*cur_map)[0] == vi)
202 already_there =
true;
203 already_there_mapping = (*cur_map);
211 newFace.
v_index[e] = already_there_mapping[1];
217 int* newMapping =
new int[2];
219 newMapping[1] = new_surface->
vertices_.size();
222 vertex_mapping.push_back(newMapping);
224 newFace.
v_index[e] = newMapping[1];
238 for (
int e=0;e<3;e++)
244 new_surface->
faces_.push_back(newFace);
248 patches.push_back(new_surface);
void SplitByPatch(std::vector< chi_mesh::SurfaceMesh * > &patches)
void UpdateInternalConnectivity()
std::vector< chi_mesh::Vertex > vertices_
std::vector< chi_mesh::Face > faces_
Vector3 Dot(const chi_mesh::TensorRank2Dim3 &that) const