7 #include "GmshConfig.h"
17 #if defined(HAVE_QUADTRI)
18 #include "QuadTriExtruded2D.h"
34 std::set<std::pair<MVertex *, MVertex *> > *constrainedEdges,
35 MLine *source,
int tri_quad_flag)
38 if(v[0] == v[1] || v[1] == v[3])
40 else if(v[0] == v[2] || v[2] == v[3])
42 else if(v[0] == v[3] || v[1] == v[2])
43 Msg::Error(
"Incoherent extruded quadrangle in surface %d", to->
tag());
46 if((ep->
mesh.
Recombine && tri_quad_flag != 2) || tri_quad_flag == 1) {
50 std::pair<MVertex *, MVertex *> p1(std::min(v[1], v[2]),
51 std::max(v[1], v[2]));
52 std::pair<MVertex *, MVertex *> p2(std::min(v[0], v[3]),
53 std::max(v[0], v[3]));
54 if(constrainedEdges->count(p1)) {
58 else if(constrainedEdges->count(p2)) {
66 else if(!constrainedEdges) {
71 std::pair<MVertex *, MVertex *> p(std::min(v[1], v[2]),
72 std::max(v[1], v[2]));
73 if(constrainedEdges->count(p)) {
87 std::set<std::pair<MVertex *, MVertex *> > *constrainedEdges)
92 if(!constrainedEdges) {
94 std::vector<MVertex *> extruded_vertices;
100 double x = v->
x(), y = v->
y(),
z = v->
z();
120 extruded_vertices.push_back(newv);
128 int tri_quad_flag = 0;
130 #if defined(HAVE_QUADTRI)
136 bool detectQuadToTriLateral =
false;
137 bool quadToTri_valid =
138 IsValidQuadToTriLateral(to, &tri_quad_flag, &detectQuadToTriLateral);
139 if(detectQuadToTriLateral && !quadToTri_valid)
140 Msg::Error(
"Mesh of QuadToTri lateral surface %d likely has errors",
147 for(std::size_t i = 0; i < from->
lines.size(); i++) {
152 std::vector<MVertex *> verts;
153 double x[4] = {v0->
x(), v1->
x(), v0->
x(), v1->
x()};
154 double y[4] = {v0->
y(), v1->
y(), v0->
y(), v1->
y()};
155 double z[4] = {v0->
z(), v1->
z(), v0->
z(), v1->
z()};
156 for(
int p = 0; p < 2; p++) {
157 ep->
Extrude(j, k, x[p], y[p],
z[p]);
158 ep->
Extrude(j, k + 1, x[p + 2], y[p + 2],
z[p + 2]);
160 for(
int p = 0; p < 4; p++) {
163 Msg::Error(
"Could not find extruded node (%.16g, %.16g, %.16g) "
165 x[p], y[p],
z[p], to->
tag());
168 verts.push_back(tmp);
186 mesh_vertices.insert(mesh_vertices.end(), embedded.begin(), embedded.end());
189 for(std::size_t i = 0; i < mesh_vertices.size(); i++) {
191 double x = v->
x(), y = v->
y(),
z = v->
z();
210 #if defined(HAVE_QUADTRI)
216 bool detectQuadToTriTop =
false;
217 int quadToTri_valid =
218 IsValidQuadToTriTop(to, &
quadToTri, &detectQuadToTriTop);
219 bool is_toroidal = quadToTri_valid >= 2 ? true :
false;
220 bool is_noaddverts = quadToTri_valid == 3 ? true :
false;
221 if(detectQuadToTriTop && !quadToTri_valid && !is_toroidal) {
222 Msg::Error(
"Mesh of QuadToTri top surface %d likely has errors", to->
tag());
227 if(is_toroidal && is_noaddverts) {
228 GFace *root = findRootSourceFaceForFace(from);
230 ReplaceBndQuadsInFace(root);
232 "To facilitate QuadToTri interface on surface %d, source "
233 "surface %d was re-meshed with all triangles on boundary. "
234 "To avoid this, use QuadTriAddVerts instead of QuadTriNoNewVerts",
241 for(std::size_t i = 0; i < from->
triangles.size(); i++) {
242 std::vector<MVertex *> verts;
243 for(
int j = 0; j < 3; j++) {
245 double x = v->
x(), y = v->
y(),
z = v->
z();
251 "Could not find extruded node (%.16g, %.16g, %.16g) in surface %d", x,
255 verts.push_back(tmp);
260 #if defined(HAVE_QUADTRI)
263 if(detectQuadToTriTop && !is_toroidal) {
264 if(!MeshQuadToTriTopSurface(from, to, pos))
265 Msg::Error(
"Mesh of QuadToTri top surface %d failed", to->
tag());
271 for(std::size_t i = 0; i < from->
quadrangles.size(); i++) {
272 std::vector<MVertex *> verts;
273 for(
int j = 0; j < 4; j++) {
275 double x = v->
x(), y = v->
y(),
z = v->
z();
281 "Could not find extruded node (%.16g, %.16g, %.16g) in surface %d", x,
285 verts.push_back(tmp);
292 GFace *gf, std::set<std::pair<MVertex *, MVertex *> > *constrainedEdges)
303 std::vector<GEdge *>
const &
edges = gf->
edges();
304 for(
auto it =
edges.begin(); it !=
edges.end(); it++) {
305 pos.
insert((*it)->mesh_vertices);
306 if((*it)->getBeginVertex())
307 pos.
insert((*it)->getBeginVertex()->mesh_vertices);
308 if((*it)->getEndVertex()) pos.
insert((*it)->getEndVertex()->mesh_vertices);