16 vector<int> indRmvVert, indRmvEdge, indRmvSurf, indRmvVolu;
18 newparent = meshchild;
19 nDim = newparent.WhatDim();
22 switch (newparent.WhatDim())
31 n = int(newparent.surfs.size());
33 flag = n != int(elmMapping.size());
36 for (ii = 0; ii < n; ii++)
38 if (newparent.surfs.find(elmMapping[ii]) == -1)
47 n = int(newparent.volus.size());
49 flag = n != int(elmMapping.size());
52 for (ii = 0; ii < n; ii++)
54 if (newparent.volus.find(elmMapping[ii]) == -1)
77 for (ii = 0; ii < n; ii++)
79 newparent.SwitchIndex(nDim + 1, newparent.verts(ii)->index, elmMapping[ii]);
83 for (ii = 0; ii < n; ii++)
85 newparent.SwitchIndex(nDim + 1, newparent.edges(ii)->index, elmMapping[ii]);
89 for (ii = 0; ii < n; ii++)
91 newparent.SwitchIndex(nDim + 1, newparent.surfs(ii)->index, elmMapping[ii]);
95 for (ii = 0; ii < n; ii++)
97 newparent.SwitchIndex(nDim + 1, newparent.volus(ii)->index, elmMapping[ii]);
101 newparent.TightenConnectivity();
109 for (ii = 0; ii < newparent.surfs.size(); ++ii)
111 if (newparent.surfs(ii)->voluind[0] == newparent.surfs(ii)->voluind[1])
113 newparent.RemoveIndex(3, newparent.surfs(ii)->index);
114 indRmvSurf.push_back(newparent.surfs(ii)->index);
122 for (ii = 0; ii < newparent.edges.size(); ++ii)
124 if (newparent.edges(ii)->surfind.size() == 1)
126 newparent.RemoveIndex(2, newparent.edges(ii)->index);
127 indRmvEdge.push_back(newparent.edges(ii)->index);
133 for (ii = 0; ii < newparent.edges.size(); ++ii)
135 if (newparent.edges(ii)->surfind.size() == 0)
137 newparent.RemoveIndex(2, newparent.edges(ii)->index);
138 indRmvEdge.push_back(newparent.edges(ii)->index);
145 for (ii = 0; ii < newparent.verts.size(); ++ii)
147 if (newparent.verts(ii)->edgeind.size() == 0)
149 indRmvVert.push_back(newparent.verts(ii)->index);
156 hashedMapping.vec = elmMapping;
157 hashedMapping.GenerateHash();
166 for (ii = 0; ii < n; ++ii)
168 if (hashedMapping.find(newparent.surfs(ii)->index) == -1)
170 indRmvSurf.push_back(newparent.surfs(ii)->index);
175 for (ii = 0; ii < n; ++ii)
177 if (hashedMapping.find(newparent.volus(ii)->index) == -1)
179 indRmvVolu.push_back(newparent.volus(ii)->index);
194 newparent.surfs.remove(indRmvSurf);
195 newparent.edges.remove(indRmvEdge);
196 newparent.verts.remove(indRmvVert);
197 newparent.volus.remove(indRmvVolu);
199 newparent.PrepareForUse();
202 void CartesianMapping(
const mesh &meshin, vector<int> &elmMapping, vector<int> &dims)
204 int ii, jj, kk, n, nBox, sub;
205 coordvec minCoord, maxCoord, cellCoord, deltaCoord;
206 vector<int> boxMap, vertList, edgeList;
208 n = meshin.verts.size();
210 minCoord = meshin.verts(0)->coord;
211 maxCoord = meshin.verts(0)->coord;
212 for (ii = 1; ii < n; ii++)
214 minCoord.min(meshin.verts(ii)->coord);
215 maxCoord.max(meshin.verts(ii)->coord);
217 deltaCoord = maxCoord;
218 deltaCoord.substract(minCoord.usedata());
221 for (ii = 0; ii < 3; ++ii)
223 dims[ii] = dims[ii] > 0 ? dims[ii] : 1;
224 deltaCoord[ii] = dims[ii] > 0 ? deltaCoord[ii] : 2;
225 minCoord[ii] = dims[ii] > 0 ? minCoord[ii] : minCoord[ii] - 1;
226 maxCoord[ii] = dims[ii] > 0 ? maxCoord[ii] : maxCoord[ii] + 1;
227 nBox = nBox * dims[ii];
229 boxMap.assign(nBox, 0);
231 if (meshin.WhatDim() == 3)
233 elmMapping.assign(meshin.volus.size(), 0);
235 n = meshin.volus.size();
236 for (ii = 0; ii < n; ii++)
239 ConcatenateVectorField(meshin.surfs, &surf::edgeind, meshin.surfs.find_list(meshin.volus(ii)->surfind));
240 vertList = ConcatenateVectorField(meshin.edges, &edge::vertind, meshin.edges.find_list(edgeList));
241 vertList = meshin.verts.find_list(vertList);
244 kk = int(vertList.size());
245 cellCoord.assign(0.0, 0.0, 0.0);
246 for (jj = 0; jj < kk; ++jj)
248 cellCoord.add(meshin.verts(vertList[jj])->coord);
250 cellCoord.div(
double(kk));
252 cellCoord.substract(minCoord.usedata());
253 cellCoord.div(deltaCoord.usedata());
254 for (jj = 0; jj < 3; ++jj)
256 cellCoord[jj] = cellCoord[jj] * double(dims[jj]);
257 cellCoord[jj] = floor(cellCoord[jj]);
258 cellCoord[jj] = (cellCoord[jj] >= double(dims[jj])) ?
double(dims[jj] - 1) : cellCoord[jj];
260 sub = int(cellCoord[0]) + (dims[0]) *
int(cellCoord[1]) + (dims[0]) * (dims[1]) * int(cellCoord[2]);
265 if (boxMap[sub] == 0)
268 boxMap[sub] = meshin.volus(ii)->index;
269 elmMapping[ii] = boxMap[sub];
274 elmMapping[ii] = boxMap[sub];
278 else if (meshin.WhatDim() == 2)
280 elmMapping.assign(meshin.surfs.size(), 0);
282 n = meshin.surfs.size();
283 for (ii = 0; ii < n; ii++)
286 ConcatenateVectorField(meshin.edges, &edge::vertind, meshin.edges.find_list(meshin.surfs(ii)->edgeind));
287 vertList = meshin.verts.find_list(vertList);
290 kk = int(vertList.size());
291 cellCoord.assign(0.0, 0.0, 0.0);
292 for (jj = 0; jj < kk; ++jj)
294 cellCoord.add(meshin.verts(vertList[jj])->coord);
296 cellCoord.div(
double(kk));
298 cellCoord.substract(minCoord.usedata());
299 cellCoord.div(deltaCoord.usedata());
300 for (jj = 0; jj < 3; ++jj)
302 cellCoord[jj] = cellCoord[jj] * double(dims[jj]);
303 cellCoord[jj] = floor(cellCoord[jj]);
304 cellCoord[jj] = (cellCoord[jj] >= double(dims[jj])) ?
double(dims[jj] - 1) : cellCoord[jj];
306 sub = int(cellCoord[0]) + (dims[0]) *
int(cellCoord[1]) + (dims[0]) * (dims[1]) * int(cellCoord[2]);
311 if (boxMap[sub] == 0)
314 boxMap[sub] = meshin.surfs(ii)->index;
315 elmMapping[ii] = boxMap[sub];
320 elmMapping[ii] = boxMap[sub];
Handles the use and norm of a vector for which the norm and the unit value might be needed.
Provides all the mesh tools used for the generation of 3D grids and geometries.
Tools for the refinement and coarsening of meshes.
void CoarsenMesh(const mesh &meshchild, mesh &newparent, const std::vector< int > &elmMapping)
Provides the error and warning system used by the RSVS3D project.
#define RSVS3D_ERROR_ARGUMENT(M)
Throw a invalid_argument.