1 // SMESH SMESH : implementaion of SMESH idl descriptions
3 // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
24 // File : SMESH_Hexa_3D.cxx
25 // Author : Paul RASCLE, EDF
30 #include "SMESH_Hexa_3D.hxx"
31 #include "SMESH_Quadrangle_2D.hxx"
32 #include "SMESH_Gen.hxx"
33 #include "SMESH_Mesh.hxx"
35 #include "SMDS_MeshElement.hxx"
36 #include "SMDS_MeshNode.hxx"
37 #include "SMDS_FacePosition.hxx"
40 #include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
41 #include <TopTools_ListOfShape.hxx>
42 #include <TopTools_ListIteratorOfListOfShape.hxx>
43 #include <TColStd_ListIteratorOfListOfInteger.hxx>
45 #include <BRep_Tool.hxx>
46 #include <Geom_Surface.hxx>
47 #include <Geom_Curve.hxx>
48 #include <Geom2d_Curve.hxx>
49 #include <Handle_Geom2d_Curve.hxx>
50 #include <Handle_Geom_Curve.hxx>
52 #include "utilities.h"
54 //=============================================================================
58 //=============================================================================
60 SMESH_Hexa_3D::SMESH_Hexa_3D(int hypId, int studyId,
61 SMESH_Gen * gen):SMESH_3D_Algo(hypId, studyId, gen)
63 MESSAGE("SMESH_Hexa_3D::SMESH_Hexa_3D");
65 // _shapeType = TopAbs_SOLID;
66 _shapeType = (1 << TopAbs_SHELL) | (1 << TopAbs_SOLID); // 1 bit /shape type
67 // MESSAGE("_shapeType octal " << oct << _shapeType);
68 for (int i = 0; i < 6; i++)
72 //=============================================================================
76 //=============================================================================
78 SMESH_Hexa_3D::~SMESH_Hexa_3D()
80 MESSAGE("SMESH_Hexa_3D::~SMESH_Hexa_3D");
83 //=============================================================================
87 //=============================================================================
89 bool SMESH_Hexa_3D::CheckHypothesis(SMESH_Mesh & aMesh,
90 const TopoDS_Shape & aShape)
92 MESSAGE("SMESH_Hexa_3D::CheckHypothesis");
101 //=============================================================================
103 * Hexahedron mesh on hexaedron like form
104 * -0. - shape and face mesh verification
105 * -1. - identify faces and vertices of the "cube"
106 * -2. - Algorithm from:
107 * "Application de l'interpolation transfinie à la création de maillages
108 * C0 ou G1 continus sur des triangles, quadrangles, tetraedres, pentaedres
109 * et hexaedres déformés."
110 * Alain PERONNET - 8 janvier 1999
112 //=============================================================================
114 bool SMESH_Hexa_3D::Compute(SMESH_Mesh & aMesh,
115 const TopoDS_Shape & aShape)throw(SALOME_Exception)
117 MESSAGE("SMESH_Hexa_3D::Compute");
120 SMESHDS_Mesh * meshDS = aMesh.GetMeshDS();
121 SMESH_subMesh *theSubMesh = aMesh.GetSubMesh(aShape);
122 //const SMESHDS_SubMesh *& subMeshDS = theSubMesh->GetSubMeshDS();
124 // 0. - shape and face mesh verification
125 // 0.1 - shape must be a solid (or a shell) with 6 faces
128 vector < SMESH_subMesh * >meshFaces;
129 for (TopExp_Explorer exp(aShape, TopAbs_FACE); exp.More(); exp.Next())
131 SMESH_subMesh *aSubMesh = aMesh.GetSubMeshContaining(exp.Current());
133 meshFaces.push_back(aSubMesh);
135 if (meshFaces.size() != 6)
137 SCRUTE(meshFaces.size());
142 // 0.2 - is each face meshed with Quadrangle_2D? (so, with a wire of 4 edges)
145 for (int i = 0; i < 6; i++)
147 TopoDS_Shape aShape = meshFaces[i]->GetSubShape();
148 SMESH_Algo *algo = _gen->GetAlgo(aMesh, aShape);
149 string algoName = algo->GetName();
150 if (algoName != "Quadrangle_2D")
157 SMESH_Quadrangle_2D *quadAlgo =
158 dynamic_cast < SMESH_Quadrangle_2D * >(algo);
162 _quads[i] = quadAlgo->CheckAnd2Dcompute(aMesh, aShape);
163 // *** to delete after usage
165 catch(SALOME_Exception & S_ex)
168 // *** throw exception
173 // 1. - identify faces and vertices of the "cube"
174 // 1.1 - ancestor maps vertex->edges in the cube
177 TopTools_IndexedDataMapOfShapeListOfShape MS;
178 TopExp::MapShapesAndAncestors(aShape, TopAbs_VERTEX, TopAbs_EDGE, MS);
180 // 1.2 - first face is choosen as face Y=0 of the unit cube
183 const TopoDS_Shape & aFace = meshFaces[0]->GetSubShape();
184 const TopoDS_Face & F = TopoDS::Face(aFace);
186 // 1.3 - identify the 4 vertices of the face Y=0: V000, V100, V101, V001
190 TopoDS_Edge E = _quads[0]->edge[i]; //edge will be Y=0,Z=0 on unit cube
192 Handle(Geom2d_Curve) C2d = BRep_Tool::CurveOnSurface(E, F, f, l);
193 TopoDS_Vertex VFirst, VLast;
194 TopExp::Vertices(E, VFirst, VLast); // corresponds to f and l
196 (((l - f) * (_quads[0]->last[i] - _quads[0]->first[i])) > 0);
200 _cube.V000 = VFirst; // will be (0,0,0) on the unit cube
201 _cube.V100 = VLast; // will be (1,0,0) on the unit cube
210 E = _quads[0]->edge[i];
211 C2d = BRep_Tool::CurveOnSurface(E, F, f, l);
212 TopExp::Vertices(E, VFirst, VLast);
213 isForward = (((l - f) * (_quads[0]->last[i] - _quads[0]->first[i])) > 0);
215 _cube.V101 = VLast; // will be (1,0,1) on the unit cube
220 E = _quads[0]->edge[i];
221 C2d = BRep_Tool::CurveOnSurface(E, F, f, l);
222 TopExp::Vertices(E, VFirst, VLast);
223 isForward = (((l - f) * (_quads[0]->last[i] - _quads[0]->first[i])) > 0);
225 _cube.V001 = VLast; // will be (0,0,1) on the unit cube
229 // 1.4 - find edge X=0, Z=0 (ancestor of V000 not in face Y=0)
230 // - find edge X=1, Z=0 (ancestor of V100 not in face Y=0)
231 // - find edge X=1, Z=1 (ancestor of V101 not in face Y=0)
232 // - find edge X=0, Z=1 (ancestor of V001 not in face Y=0)
235 TopoDS_Edge E_0Y0 = EdgeNotInFace(aMesh, aShape, F, _cube.V000, MS);
236 ASSERT(!E_0Y0.IsNull());
238 TopoDS_Edge E_1Y0 = EdgeNotInFace(aMesh, aShape, F, _cube.V100, MS);
239 ASSERT(!E_1Y0.IsNull());
241 TopoDS_Edge E_1Y1 = EdgeNotInFace(aMesh, aShape, F, _cube.V101, MS);
242 ASSERT(!E_1Y1.IsNull());
244 TopoDS_Edge E_0Y1 = EdgeNotInFace(aMesh, aShape, F, _cube.V001, MS);
245 ASSERT(!E_0Y1.IsNull());
247 // 1.5 - identify the 4 vertices in face Y=1: V010, V110, V111, V011
250 TopExp::Vertices(E_0Y0, VFirst, VLast);
251 if (VFirst.IsSame(_cube.V000))
256 TopExp::Vertices(E_1Y0, VFirst, VLast);
257 if (VFirst.IsSame(_cube.V100))
262 TopExp::Vertices(E_1Y1, VFirst, VLast);
263 if (VFirst.IsSame(_cube.V101))
268 TopExp::Vertices(E_0Y1, VFirst, VLast);
269 if (VFirst.IsSame(_cube.V001))
274 // 1.6 - find remaining faces given 4 vertices
278 _cube.quad_Y0 = _quads[_indY0];
280 _indY1 = GetFaceIndex(aMesh, aShape, meshFaces,
281 _cube.V010, _cube.V011, _cube.V110, _cube.V111);
282 _cube.quad_Y1 = _quads[_indY1];
284 _indZ0 = GetFaceIndex(aMesh, aShape, meshFaces,
285 _cube.V000, _cube.V010, _cube.V100, _cube.V110);
286 _cube.quad_Z0 = _quads[_indZ0];
288 _indZ1 = GetFaceIndex(aMesh, aShape, meshFaces,
289 _cube.V001, _cube.V011, _cube.V101, _cube.V111);
290 _cube.quad_Z1 = _quads[_indZ1];
292 _indX0 = GetFaceIndex(aMesh, aShape, meshFaces,
293 _cube.V000, _cube.V001, _cube.V010, _cube.V011);
294 _cube.quad_X0 = _quads[_indX0];
296 _indX1 = GetFaceIndex(aMesh, aShape, meshFaces,
297 _cube.V100, _cube.V101, _cube.V110, _cube.V111);
298 _cube.quad_X1 = _quads[_indX1];
302 // 1.7 - get convertion coefs from face 2D normalized to 3D normalized
304 Conv2DStruct cx0; // for face X=0
305 Conv2DStruct cx1; // for face X=1
311 GetConv2DCoefs(*_cube.quad_X0, meshFaces[_indX0]->GetSubShape(),
312 _cube.V000, _cube.V010, _cube.V011, _cube.V001, cx0);
313 GetConv2DCoefs(*_cube.quad_X1, meshFaces[_indX1]->GetSubShape(),
314 _cube.V100, _cube.V110, _cube.V111, _cube.V101, cx1);
315 GetConv2DCoefs(*_cube.quad_Y0, meshFaces[_indY0]->GetSubShape(),
316 _cube.V000, _cube.V100, _cube.V101, _cube.V001, cy0);
317 GetConv2DCoefs(*_cube.quad_Y1, meshFaces[_indY1]->GetSubShape(),
318 _cube.V010, _cube.V110, _cube.V111, _cube.V011, cy1);
319 GetConv2DCoefs(*_cube.quad_Z0, meshFaces[_indZ0]->GetSubShape(),
320 _cube.V000, _cube.V100, _cube.V110, _cube.V010, cz0);
321 GetConv2DCoefs(*_cube.quad_Z1, meshFaces[_indZ1]->GetSubShape(),
322 _cube.V001, _cube.V101, _cube.V111, _cube.V011, cz1);
324 // 1.8 - create a 3D structure for normalized values
327 int nbx = _cube.quad_Y0->nbPts[0];
328 int nby = _cube.quad_Y0->nbPts[1];
331 nbz = _cube.quad_X0->nbPts[1];
333 nbz = _cube.quad_X0->nbPts[0];
339 // Adding NB To my point of vue that definition of nbx nby and nbz
340 // seems to be true (but maybe I am wrong). Of course any comments
341 // or other suggestions are welcome !!!!
344 nbx = _cube.quad_Z0->nbPts[0];
345 double det = cz0.a1*cz0.b2 - cz0.a2*cz0.b1;
346 if (cz0.a1 == 0.) nbx = _cube.quad_Z0->nbPts[1];
348 nby = _cube.quad_X0->nbPts[0];
349 det = cx0.a1*cx0.b2 - cx0.a2*cx0.b1;
350 if (cx0.a1 == 0.) nby = _cube.quad_X0->nbPts[1];
352 nbz = _cube.quad_Y0->nbPts[0];
353 det = cy0.a1*cy0.b2 - cy0.a2*cy0.b1;
354 if (cy0.a1 != 0.) nbz = _cube.quad_Y0->nbPts[1];
360 int nbxyz = nbx * nby * nbz;
361 Point3DStruct *np = new Point3DStruct[nbxyz];
363 // 1.9 - store node indexes of faces
366 const TopoDS_Face & F = TopoDS::Face(meshFaces[_indX0]->GetSubShape());
368 faceQuadStruct *quad = _cube.quad_X0;
369 int i = 0; // j = x/face , k = y/face
370 int nbdown = quad->nbPts[0];
371 int nbright = quad->nbPts[1];
374 SMDS_Iterator<const SMDS_MeshNode *> * itf=
375 aMesh.GetSubMesh(F)->GetSubMeshDS()->GetNodes();
379 const SMDS_MeshNode * node = itf->next();
380 const SMDS_FacePosition* fpos
381 = static_cast<const SMDS_FacePosition*>(node->GetPosition());
382 double ri = fpos->GetUParameter();
383 double rj = fpos->GetVParameter();
386 int ij1 = j1 * nbdown + i1;
387 quad->uv_grid[ij1].node = node;
391 for (int i1 = 0; i1 < nbdown; i1++)
392 for (int j1 = 0; j1 < nbright; j1++)
394 int ij1 = j1 * nbdown + i1;
395 int j = cx0.ia * i1 + cx0.ib * j1 + cx0.ic; // j = x/face
396 int k = cx0.ja * i1 + cx0.jb * j1 + cx0.jc; // k = y/face
397 int ijk = k * nbx * nby + j * nbx + i;
398 //MESSAGE(" "<<ij1<<" "<<i<<" "<<j<<" "<<ijk);
399 np[ijk].node = quad->uv_grid[ij1].node;
400 //SCRUTE(np[ijk].nodeId);
405 const TopoDS_Face & F = TopoDS::Face(meshFaces[_indX1]->GetSubShape());
407 SMDS_Iterator<const SMDS_MeshNode *> * itf=
408 aMesh.GetSubMesh(F)->GetSubMeshDS()->GetNodes();
410 faceQuadStruct *quad = _cube.quad_X1;
411 int i = nbx - 1; // j = x/face , k = y/face
412 int nbdown = quad->nbPts[0];
413 int nbright = quad->nbPts[1];
417 const SMDS_MeshNode * node = itf->next();
418 const SMDS_FacePosition* fpos
419 = static_cast<const SMDS_FacePosition*>(node->GetPosition());
420 double ri = fpos->GetUParameter();
421 double rj = fpos->GetVParameter();
424 int ij1 = j1 * nbdown + i1;
425 quad->uv_grid[ij1].node = node;
429 for (int i1 = 0; i1 < nbdown; i1++)
430 for (int j1 = 0; j1 < nbright; j1++)
432 int ij1 = j1 * nbdown + i1;
433 int j = cx1.ia * i1 + cx1.ib * j1 + cx1.ic; // j = x/face
434 int k = cx1.ja * i1 + cx1.jb * j1 + cx1.jc; // k = y/face
435 int ijk = k * nbx * nby + j * nbx + i;
436 //MESSAGE(" "<<ij1<<" "<<i<<" "<<j<<" "<<ijk);
437 np[ijk].node = quad->uv_grid[ij1].node;
438 //SCRUTE(np[ijk].nodeId);
443 const TopoDS_Face & F = TopoDS::Face(meshFaces[_indY0]->GetSubShape());
445 SMDS_Iterator<const SMDS_MeshNode *> * itf=
446 aMesh.GetSubMesh(F)->GetSubMeshDS()->GetNodes();
448 faceQuadStruct *quad = _cube.quad_Y0;
449 int j = 0; // i = x/face , k = y/face
450 int nbdown = quad->nbPts[0];
451 int nbright = quad->nbPts[1];
455 const SMDS_MeshNode * node = itf->next();
456 const SMDS_FacePosition * fpos
457 = static_cast<const SMDS_FacePosition*>(node->GetPosition());
458 double ri = fpos->GetUParameter();
459 double rj = fpos->GetVParameter();
462 int ij1 = j1 * nbdown + i1;
463 quad->uv_grid[ij1].node = node;
467 for (int i1 = 0; i1 < nbdown; i1++)
468 for (int j1 = 0; j1 < nbright; j1++)
470 int ij1 = j1 * nbdown + i1;
471 int i = cy0.ia * i1 + cy0.ib * j1 + cy0.ic; // i = x/face
472 int k = cy0.ja * i1 + cy0.jb * j1 + cy0.jc; // k = y/face
473 int ijk = k * nbx * nby + j * nbx + i;
474 //MESSAGE(" "<<ij1<<" "<<i<<" "<<j<<" "<<ijk);
475 np[ijk].node = quad->uv_grid[ij1].node;
476 //SCRUTE(np[ijk].nodeId);
481 const TopoDS_Face & F = TopoDS::Face(meshFaces[_indY1]->GetSubShape());
483 SMDS_Iterator<const SMDS_MeshNode *> * itf=
484 aMesh.GetSubMesh(F)->GetSubMeshDS()->GetNodes();
486 faceQuadStruct *quad = _cube.quad_Y1;
487 int j = nby - 1; // i = x/face , k = y/face
488 int nbdown = quad->nbPts[0];
489 int nbright = quad->nbPts[1];
493 const SMDS_MeshNode * node = itf->next();
494 const SMDS_FacePosition* fpos =
495 static_cast<const SMDS_FacePosition *>(node->GetPosition());
496 double ri = fpos->GetUParameter();
497 double rj = fpos->GetVParameter();
500 int ij1 = j1 * nbdown + i1;
501 quad->uv_grid[ij1].node = node;
504 for (int i1 = 0; i1 < nbdown; i1++)
505 for (int j1 = 0; j1 < nbright; j1++)
507 int ij1 = j1 * nbdown + i1;
508 int i = cy1.ia * i1 + cy1.ib * j1 + cy1.ic; // i = x/face
509 int k = cy1.ja * i1 + cy1.jb * j1 + cy1.jc; // k = y/face
510 int ijk = k * nbx * nby + j * nbx + i;
511 //MESSAGE(" "<<ij1<<" "<<i<<" "<<j<<" "<<ijk);
512 np[ijk].node = quad->uv_grid[ij1].node;
513 //SCRUTE(np[ijk].nodeId);
518 const TopoDS_Face & F = TopoDS::Face(meshFaces[_indZ0]->GetSubShape());
520 SMDS_Iterator<const SMDS_MeshNode *> * itf=
521 aMesh.GetSubMesh(F)->GetSubMeshDS()->GetNodes();
523 faceQuadStruct *quad = _cube.quad_Z0;
524 int k = 0; // i = x/face , j = y/face
525 int nbdown = quad->nbPts[0];
526 int nbright = quad->nbPts[1];
530 const SMDS_MeshNode * node = itf->next();
531 const SMDS_FacePosition * fpos
532 = static_cast<const SMDS_FacePosition*>(node->GetPosition());
533 double ri = fpos->GetUParameter();
534 double rj = fpos->GetVParameter();
537 int ij1 = j1 * nbdown + i1;
538 quad->uv_grid[ij1].node = node;
541 for (int i1 = 0; i1 < nbdown; i1++)
542 for (int j1 = 0; j1 < nbright; j1++)
544 int ij1 = j1 * nbdown + i1;
545 int i = cz0.ia * i1 + cz0.ib * j1 + cz0.ic; // i = x/face
546 int j = cz0.ja * i1 + cz0.jb * j1 + cz0.jc; // j = y/face
547 int ijk = k * nbx * nby + j * nbx + i;
548 //MESSAGE(" "<<ij1<<" "<<i<<" "<<j<<" "<<ijk);
549 np[ijk].node = quad->uv_grid[ij1].node;
550 //SCRUTE(np[ijk].nodeId);
555 const TopoDS_Face & F = TopoDS::Face(meshFaces[_indZ1]->GetSubShape());
557 SMDS_Iterator<const SMDS_MeshNode *> * itf=
558 aMesh.GetSubMesh(F)->GetSubMeshDS()->GetNodes();
560 faceQuadStruct *quad = _cube.quad_Z1;
561 int k = nbz - 1; // i = x/face , j = y/face
562 int nbdown = quad->nbPts[0];
563 int nbright = quad->nbPts[1];
567 const SMDS_MeshNode * node = itf->next();
568 const SMDS_FacePosition* fpos
569 = static_cast<const SMDS_FacePosition*>(node->GetPosition());
570 double ri = fpos->GetUParameter();
571 double rj = fpos->GetVParameter();
574 int ij1 = j1 * nbdown + i1;
575 quad->uv_grid[ij1].node = node;
578 for (int i1 = 0; i1 < nbdown; i1++)
579 for (int j1 = 0; j1 < nbright; j1++)
581 int ij1 = j1 * nbdown + i1;
582 int i = cz1.ia * i1 + cz1.ib * j1 + cz1.ic; // i = x/face
583 int j = cz1.ja * i1 + cz1.jb * j1 + cz1.jc; // j = y/face
584 int ijk = k * nbx * nby + j * nbx + i;
585 //MESSAGE(" "<<ij1<<" "<<i<<" "<<j<<" "<<ijk);
586 np[ijk].node = quad->uv_grid[ij1].node;
587 //SCRUTE(np[ijk].nodeId);
591 // 2.0 - for each node of the cube:
592 // - get the 8 points 3D = 8 vertices of the cube
593 // - get the 12 points 3D on the 12 edges of the cube
594 // - get the 6 points 3D on the 6 faces with their ID
595 // - compute the point 3D
596 // - store the point 3D in SMESHDS, store its ID in 3D structure
599 TopExp_Explorer exp(aShape, TopAbs_SHELL);
602 aShell = TopoDS::Shell(exp.Current());
606 MESSAGE("no shell...");
610 Pt3 p000, p001, p010, p011, p100, p101, p110, p111;
611 Pt3 px00, px01, px10, px11;
612 Pt3 p0y0, p0y1, p1y0, p1y1;
613 Pt3 p00z, p01z, p10z, p11z;
614 Pt3 pxy0, pxy1, px0z, px1z, p0yz, p1yz;
616 GetPoint(p000, 0, 0, 0, nbx, nby, nbz, np, meshDS);
617 GetPoint(p001, 0, 0, nbz - 1, nbx, nby, nbz, np, meshDS);
618 GetPoint(p010, 0, nby - 1, 0, nbx, nby, nbz, np, meshDS);
619 GetPoint(p011, 0, nby - 1, nbz - 1, nbx, nby, nbz, np, meshDS);
620 GetPoint(p100, nbx - 1, 0, 0, nbx, nby, nbz, np, meshDS);
621 GetPoint(p101, nbx - 1, 0, nbz - 1, nbx, nby, nbz, np, meshDS);
622 GetPoint(p110, nbx - 1, nby - 1, 0, nbx, nby, nbz, np, meshDS);
623 GetPoint(p111, nbx - 1, nby - 1, nbz - 1, nbx, nby, nbz, np, meshDS);
625 for (int i = 1; i < nbx - 1; i++)
627 for (int j = 1; j < nby - 1; j++)
629 for (int k = 1; k < nbz - 1; k++)
631 // *** seulement maillage regulier
632 // 12 points on edges
633 GetPoint(px00, i, 0, 0, nbx, nby, nbz, np, meshDS);
634 GetPoint(px01, i, 0, nbz - 1, nbx, nby, nbz, np, meshDS);
635 GetPoint(px10, i, nby - 1, 0, nbx, nby, nbz, np, meshDS);
636 GetPoint(px11, i, nby - 1, nbz - 1, nbx, nby, nbz, np, meshDS);
638 GetPoint(p0y0, 0, j, 0, nbx, nby, nbz, np, meshDS);
639 GetPoint(p0y1, 0, j, nbz - 1, nbx, nby, nbz, np, meshDS);
640 GetPoint(p1y0, nbx - 1, j, 0, nbx, nby, nbz, np, meshDS);
641 GetPoint(p1y1, nbx - 1, j, nbz - 1, nbx, nby, nbz, np, meshDS);
643 GetPoint(p00z, 0, 0, k, nbx, nby, nbz, np, meshDS);
644 GetPoint(p01z, 0, nby - 1, k, nbx, nby, nbz, np, meshDS);
645 GetPoint(p10z, nbx - 1, 0, k, nbx, nby, nbz, np, meshDS);
646 GetPoint(p11z, nbx - 1, nby - 1, k, nbx, nby, nbz, np, meshDS);
648 // 12 points on faces
649 GetPoint(pxy0, i, j, 0, nbx, nby, nbz, np, meshDS);
650 GetPoint(pxy1, i, j, nbz - 1, nbx, nby, nbz, np, meshDS);
651 GetPoint(px0z, i, 0, k, nbx, nby, nbz, np, meshDS);
652 GetPoint(px1z, i, nby - 1, k, nbx, nby, nbz, np, meshDS);
653 GetPoint(p0yz, 0, j, k, nbx, nby, nbz, np, meshDS);
654 GetPoint(p1yz, nbx - 1, j, k, nbx, nby, nbz, np, meshDS);
656 int ijk = k * nbx * nby + j * nbx + i;
657 double x = double (i) / double (nbx - 1); // *** seulement
658 double y = double (j) / double (nby - 1); // *** maillage
659 double z = double (k) / double (nbz - 1); // *** regulier
662 for (int i = 0; i < 3; i++)
665 (1 - x) * p0yz[i] + x * p1yz[i]
666 + (1 - y) * px0z[i] + y * px1z[i]
667 + (1 - z) * pxy0[i] + z * pxy1[i]
668 - (1 - x) * ((1 - y) * p00z[i] + y * p01z[i])
669 - x * ((1 - y) * p10z[i] + y * p11z[i])
670 - (1 - y) * ((1 - z) * px00[i] + z * px01[i])
671 - y * ((1 - z) * px10[i] + z * px11[i])
672 - (1 - z) * ((1 - x) * p0y0[i] + x * p1y0[i])
673 - z * ((1 - x) * p0y1[i] + x * p1y1[i])
674 + (1 - x) * ((1 - y) * ((1 - z) * p000[i] + z * p001[i])
675 + y * ((1 - z) * p010[i] + z * p011[i]))
676 + x * ((1 - y) * ((1 - z) * p100[i] + z * p101[i])
677 + y * ((1 - z) * p110[i] + z * p111[i]));
680 SMDS_MeshNode * node = meshDS->AddNode(X[0], X[1], X[2]);
682 //meshDS->SetNodeInVolume(node, TopoDS::Solid(aShape));
683 meshDS->SetNodeInVolume(node, aShell);
688 //2.1 - for each node of the cube (less 3 *1 Faces):
689 // - store hexahedron in SMESHDS
690 MESSAGE("Storing hexahedron into the DS");
691 for (int i = 0; i < nbx - 1; i++)
692 for (int j = 0; j < nby - 1; j++)
693 for (int k = 0; k < nbz - 1; k++)
695 int n1 = k * nbx * nby + j * nbx + i;
696 int n2 = k * nbx * nby + j * nbx + i + 1;
697 int n3 = k * nbx * nby + (j + 1) * nbx + i + 1;
698 int n4 = k * nbx * nby + (j + 1) * nbx + i;
699 int n5 = (k + 1) * nbx * nby + j * nbx + i;
700 int n6 = (k + 1) * nbx * nby + j * nbx + i + 1;
701 int n7 = (k + 1) * nbx * nby + (j + 1) * nbx + i + 1;
702 int n8 = (k + 1) * nbx * nby + (j + 1) * nbx + i;
704 // MESSAGE(" "<<n1<<" "<<n2<<" "<<n3<<" "<<n4<<" "<<n5<<" "<<n6<<" "<<n7<<" "<<n8);
705 //MESSAGE(" "<<np[n1].nodeId<<" "<<np[n2].nodeId<<" "<<np[n3].nodeId<<" "<<np[n4].nodeId<<" "<<np[n5].nodeId<<" "<<np[n6].nodeId<<" "<<np[n7].nodeId<<" "<<np[n8].nodeId);
707 SMDS_MeshVolume * elt = meshDS->AddVolume(np[n1].node,
716 meshDS->SetMeshElementOnShape(elt, aShell);
718 // *** 5 tetrahedres ... verifier orientations,
719 // mettre en coherence &vec quadrangles-> triangles
720 // choisir afficher 1 parmi edges, face et volumes
721 // int tetra1 = meshDS->AddVolume(np[n1].nodeId,
725 // int tetra2 = meshDS->AddVolume(np[n2].nodeId,
729 // int tetra3 = meshDS->AddVolume(np[n5].nodeId,
733 // int tetra4 = meshDS->AddVolume(np[n5].nodeId,
737 // int tetra5 = meshDS->AddVolume(np[n5].nodeId,
744 MESSAGE("End of SMESH_Hexa_3D::Compute()");
748 //=============================================================================
752 //=============================================================================
754 void SMESH_Hexa_3D::GetPoint(Pt3 p, int i, int j, int k, int nbx, int nby,
755 int nbz, Point3DStruct * np, const SMESHDS_Mesh * meshDS)
757 int ijk = k * nbx * nby + j * nbx + i;
758 const SMDS_MeshNode * node = np[ijk].node;
762 //MESSAGE(" "<<i<<" "<<j<<" "<<k<<" "<<p[0]<<" "<<p[1]<<" "<<p[2]);
765 //=============================================================================
769 //=============================================================================
771 int SMESH_Hexa_3D::GetFaceIndex(SMESH_Mesh & aMesh,
772 const TopoDS_Shape & aShape,
773 const vector < SMESH_subMesh * >&meshFaces,
774 const TopoDS_Vertex & V0,
775 const TopoDS_Vertex & V1,
776 const TopoDS_Vertex & V2, const TopoDS_Vertex & V3)
778 MESSAGE("SMESH_Hexa_3D::GetFaceIndex");
780 for (int i = 1; i < 6; i++)
782 const TopoDS_Shape & aFace = meshFaces[i]->GetSubShape();
783 //const TopoDS_Face& F = TopoDS::Face(aFace);
784 TopTools_IndexedMapOfShape M;
785 TopExp::MapShapes(aFace, TopAbs_VERTEX, M);
786 bool verticesInShape = false;
791 verticesInShape = true;
798 ASSERT(faceIndex > 0);
803 //=============================================================================
807 //=============================================================================
810 SMESH_Hexa_3D::EdgeNotInFace(SMESH_Mesh & aMesh,
811 const TopoDS_Shape & aShape,
812 const TopoDS_Face & aFace,
813 const TopoDS_Vertex & aVertex,
814 const TopTools_IndexedDataMapOfShapeListOfShape & MS)
816 MESSAGE("SMESH_Hexa_3D::EdgeNotInFace");
817 TopTools_IndexedDataMapOfShapeListOfShape MF;
818 TopExp::MapShapesAndAncestors(aFace, TopAbs_VERTEX, TopAbs_EDGE, MF);
819 const TopTools_ListOfShape & ancestorsInSolid = MS.FindFromKey(aVertex);
820 const TopTools_ListOfShape & ancestorsInFace = MF.FindFromKey(aVertex);
821 SCRUTE(ancestorsInSolid.Extent());
822 SCRUTE(ancestorsInFace.Extent());
823 ASSERT(ancestorsInSolid.Extent() == 6); // 6 (edges doublees)
824 ASSERT(ancestorsInFace.Extent() == 2);
828 TopTools_ListIteratorOfListOfShape its(ancestorsInSolid);
829 for (; its.More(); its.Next())
831 TopoDS_Shape ancestor = its.Value();
832 TopTools_ListIteratorOfListOfShape itf(ancestorsInFace);
833 bool isInFace = false;
834 for (; itf.More(); itf.Next())
836 TopoDS_Shape ancestorInFace = itf.Value();
837 if (ancestorInFace.IsSame(ancestor))
845 E = TopoDS::Edge(ancestor);
852 //=============================================================================
856 //=============================================================================
858 void SMESH_Hexa_3D::GetConv2DCoefs(const faceQuadStruct & quad,
859 const TopoDS_Shape & aShape,
860 const TopoDS_Vertex & V0,
861 const TopoDS_Vertex & V1,
862 const TopoDS_Vertex & V2, const TopoDS_Vertex & V3, Conv2DStruct & conv)
864 MESSAGE("SMESH_Hexa_3D::GetConv2DCoefs");
865 const TopoDS_Face & F = TopoDS::Face(aShape);
866 TopoDS_Edge E = quad.edge[0];
868 Handle(Geom2d_Curve) C2d = BRep_Tool::CurveOnSurface(E, F, f, l);
869 TopoDS_Vertex VFirst, VLast;
870 TopExp::Vertices(E, VFirst, VLast); // corresponds to f and l
871 bool isForward = (((l - f) * (quad.last[0] - quad.first[0])) > 0);
872 TopoDS_Vertex VA, VB;
883 int a1, b1, c1, a2, b2, c2;
896 ASSERT(VB.IsSame(V3));
916 ASSERT(VB.IsSame(V0));
936 ASSERT(VB.IsSame(V1));
956 ASSERT(VB.IsSame(V2));
964 MESSAGE("X = " << c1 << "+ " << a1 << "*x + " << b1 << "*y");
965 MESSAGE("Y = " << c2 << "+ " << a2 << "*x + " << b2 << "*y");
973 int nbdown = quad.nbPts[0];
974 int nbright = quad.nbPts[1];
978 int (c1 * a1 * a1) * (nbdown - 1) + int (c1 * b1 * b1) * (nbright - 1);
982 int (c2 * a2 * a2) * (nbdown - 1) + int (c2 * b2 * b2) * (nbright - 1);
983 MESSAGE("I " << conv.ia << " " << conv.ib << " " << conv.ic);
984 MESSAGE("J " << conv.ja << " " << conv.jb << " " << conv.jc);
987 //=============================================================================
991 //=============================================================================
993 ostream & SMESH_Hexa_3D::SaveTo(ostream & save)
998 //=============================================================================
1002 //=============================================================================
1004 istream & SMESH_Hexa_3D::LoadFrom(istream & load)
1006 return load >> (*this);
1009 //=============================================================================
1013 //=============================================================================
1015 ostream & operator <<(ostream & save, SMESH_Hexa_3D & hyp)
1020 //=============================================================================
1024 //=============================================================================
1026 istream & operator >>(istream & load, SMESH_Hexa_3D & hyp)