1 // Copyright (C) 2007-2010 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 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.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 // File : StdMeshers_Quadrangle_2D.cxx
23 // Author : Paul RASCLE, EDF
26 #include "StdMeshers_Quadrangle_2D.hxx"
28 #include "StdMeshers_FaceSide.hxx"
30 #include "StdMeshers_QuadrangleParams.hxx"
32 #include "SMESH_Gen.hxx"
33 #include "SMESH_Mesh.hxx"
34 #include "SMESH_subMesh.hxx"
35 #include "SMESH_MesherHelper.hxx"
36 #include "SMESH_Block.hxx"
37 #include "SMESH_Comment.hxx"
39 #include "SMDS_MeshElement.hxx"
40 #include "SMDS_MeshNode.hxx"
41 #include "SMDS_EdgePosition.hxx"
42 #include "SMDS_FacePosition.hxx"
44 #include <BRep_Tool.hxx>
45 #include <Geom_Surface.hxx>
46 #include <NCollection_DefineArray2.hxx>
47 #include <Precision.hxx>
48 #include <TColStd_SequenceOfReal.hxx>
49 #include <TColStd_SequenceOfInteger.hxx>
50 #include <TColgp_SequenceOfXY.hxx>
52 #include <TopExp_Explorer.hxx>
53 #include <TopTools_ListIteratorOfListOfShape.hxx>
54 #include <TopTools_MapOfShape.hxx>
57 #include "utilities.h"
58 #include "Utils_ExceptHandlers.hxx"
60 #ifndef StdMeshers_Array2OfNode_HeaderFile
61 #define StdMeshers_Array2OfNode_HeaderFile
62 typedef const SMDS_MeshNode* SMDS_MeshNodePtr;
63 DEFINE_BASECOLLECTION (StdMeshers_BaseCollectionNodePtr, SMDS_MeshNodePtr)
64 DEFINE_ARRAY2(StdMeshers_Array2OfNode,
65 StdMeshers_BaseCollectionNodePtr, SMDS_MeshNodePtr)
71 typedef SMESH_Comment TComm;
73 //=============================================================================
77 //=============================================================================
79 StdMeshers_Quadrangle_2D::StdMeshers_Quadrangle_2D (int hypId, int studyId,
81 : SMESH_2D_Algo(hypId, studyId, gen)
83 MESSAGE("StdMeshers_Quadrangle_2D::StdMeshers_Quadrangle_2D");
84 _name = "Quadrangle_2D";
85 _shapeType = (1 << TopAbs_FACE);
86 _compatibleHypothesis.push_back("QuadrangleParams");
87 _compatibleHypothesis.push_back("QuadranglePreference");
88 _compatibleHypothesis.push_back("TrianglePreference");
92 //=============================================================================
96 //=============================================================================
98 StdMeshers_Quadrangle_2D::~StdMeshers_Quadrangle_2D()
100 MESSAGE("StdMeshers_Quadrangle_2D::~StdMeshers_Quadrangle_2D");
103 //=============================================================================
107 //=============================================================================
109 bool StdMeshers_Quadrangle_2D::CheckHypothesis
111 const TopoDS_Shape& aShape,
112 SMESH_Hypothesis::Hypothesis_Status& aStatus)
115 aStatus = SMESH_Hypothesis::HYP_OK;
117 const list <const SMESHDS_Hypothesis * >& hyps =
118 GetUsedHypothesis(aMesh, aShape, false);
119 const SMESHDS_Hypothesis * aHyp = 0;
122 myQuadType = QUAD_STANDARD;
123 myQuadranglePreference = false;
124 myTrianglePreference = false;
126 bool isFirstParams = true;
128 // First assigned hypothesis (if any) is processed now
129 if (hyps.size() > 0) {
131 if (strcmp("QuadrangleParams", aHyp->GetName()) == 0) {
132 const StdMeshers_QuadrangleParams* aHyp1 =
133 (const StdMeshers_QuadrangleParams*)aHyp;
134 myTriaVertexID = aHyp1->GetTriaVertex();
135 myQuadType = aHyp1->GetQuadType();
136 if (myQuadType == QUAD_QUADRANGLE_PREF ||
137 myQuadType == QUAD_QUADRANGLE_PREF_REVERSED)
138 myQuadranglePreference = true;
139 else if (myQuadType == QUAD_TRIANGLE_PREF)
140 myTrianglePreference = true;
142 else if (strcmp("QuadranglePreference", aHyp->GetName()) == 0) {
143 isFirstParams = false;
144 myQuadranglePreference = true;
146 else if (strcmp("TrianglePreference", aHyp->GetName()) == 0){
147 isFirstParams = false;
148 myTrianglePreference = true;
151 isFirstParams = false;
155 // Second(last) assigned hypothesis (if any) is processed now
156 if (hyps.size() > 1) {
159 if (strcmp("QuadranglePreference", aHyp->GetName()) == 0) {
160 myQuadranglePreference = true;
161 myTrianglePreference = false;
162 myQuadType = QUAD_STANDARD;
164 else if (strcmp("TrianglePreference", aHyp->GetName()) == 0){
165 myQuadranglePreference = false;
166 myTrianglePreference = true;
167 myQuadType = QUAD_STANDARD;
171 const StdMeshers_QuadrangleParams* aHyp2 =
172 (const StdMeshers_QuadrangleParams*)aHyp;
173 myTriaVertexID = aHyp2->GetTriaVertex();
175 if (!myQuadranglePreference && !myTrianglePreference) { // priority of hypos
176 myQuadType = aHyp2->GetQuadType();
177 if (myQuadType == QUAD_QUADRANGLE_PREF ||
178 myQuadType == QUAD_QUADRANGLE_PREF_REVERSED)
179 myQuadranglePreference = true;
180 else if (myQuadType == QUAD_TRIANGLE_PREF)
181 myTrianglePreference = true;
189 //=============================================================================
193 //=============================================================================
195 bool StdMeshers_Quadrangle_2D::Compute (SMESH_Mesh& aMesh,
196 const TopoDS_Shape& aShape)// throw (SALOME_Exception)
198 // PAL14921. Enable catching std::bad_alloc and Standard_OutOfMemory outside
199 //Unexpect aCatchSalomeException);
201 SMESHDS_Mesh * meshDS = aMesh.GetMeshDS();
202 aMesh.GetSubMesh(aShape);
204 SMESH_MesherHelper helper (aMesh);
207 _quadraticMesh = myTool->IsQuadraticSubMesh(aShape);
209 FaceQuadStruct *quad = CheckNbEdges(aMesh, aShape);
210 std::auto_ptr<FaceQuadStruct> quadDeleter (quad); // to delete quad at exit from Compute()
214 if (myQuadranglePreference) {
215 int n1 = quad->side[0]->NbPoints();
216 int n2 = quad->side[1]->NbPoints();
217 int n3 = quad->side[2]->NbPoints();
218 int n4 = quad->side[3]->NbPoints();
219 int nfull = n1+n2+n3+n4;
222 if (nfull == ntmp && ((n1 != n3) || (n2 != n4))) {
223 // special path for using only quandrangle faces
224 bool ok = ComputeQuadPref(aMesh, aShape, quad);
228 else if (myQuadType == QUAD_REDUCED) {
229 int n1 = quad->side[0]->NbPoints();
230 int n2 = quad->side[1]->NbPoints();
231 int n3 = quad->side[2]->NbPoints();
232 int n4 = quad->side[3]->NbPoints();
235 int n13tmp = n13/2; n13tmp = n13tmp*2;
236 int n24tmp = n24/2; n24tmp = n24tmp*2;
237 if ((n1 == n3 && n2 != n4 && n24tmp == n24) ||
238 (n2 == n4 && n1 != n3 && n13tmp == n13)) {
239 bool ok = ComputeReduced(aMesh, aShape, quad);
244 // set normalized grid on unit square in parametric domain
246 if (!SetNormalizedGrid(aMesh, aShape, quad))
249 // --- compute 3D values on points, store points & quadrangles
251 int nbdown = quad->side[0]->NbPoints();
252 int nbup = quad->side[2]->NbPoints();
254 int nbright = quad->side[1]->NbPoints();
255 int nbleft = quad->side[3]->NbPoints();
257 int nbhoriz = Min(nbdown, nbup);
258 int nbvertic = Min(nbright, nbleft);
260 const TopoDS_Face& F = TopoDS::Face(aShape);
261 Handle(Geom_Surface) S = BRep_Tool::Surface(F);
263 // internal mesh nodes
264 int i, j, geomFaceID = meshDS->ShapeToIndex(F);
265 for (i = 1; i < nbhoriz - 1; i++) {
266 for (j = 1; j < nbvertic - 1; j++) {
267 int ij = j * nbhoriz + i;
268 double u = quad->uv_grid[ij].u;
269 double v = quad->uv_grid[ij].v;
270 gp_Pnt P = S->Value(u, v);
271 SMDS_MeshNode * node = meshDS->AddNode(P.X(), P.Y(), P.Z());
272 meshDS->SetNodeOnFace(node, geomFaceID, u, v);
273 quad->uv_grid[ij].node = node;
280 // --.--.--.--.--.-- nbvertic
286 // ---.----.----.--- 0
287 // 0 > > > > > > > > nbhoriz
293 int iup = nbhoriz - 1;
294 if (quad->isEdgeOut[3]) { ilow++; } else { if (quad->isEdgeOut[1]) iup--; }
297 int jup = nbvertic - 1;
298 if (quad->isEdgeOut[0]) { jlow++; } else { if (quad->isEdgeOut[2]) jup--; }
300 // regular quadrangles
301 for (i = ilow; i < iup; i++) {
302 for (j = jlow; j < jup; j++) {
303 const SMDS_MeshNode *a, *b, *c, *d;
304 a = quad->uv_grid[j * nbhoriz + i].node;
305 b = quad->uv_grid[j * nbhoriz + i + 1].node;
306 c = quad->uv_grid[(j + 1) * nbhoriz + i + 1].node;
307 d = quad->uv_grid[(j + 1) * nbhoriz + i].node;
308 SMDS_MeshFace* face = myTool->AddFace(a, b, c, d);
310 meshDS->SetMeshElementOnShape(face, geomFaceID);
315 const vector<UVPtStruct>& uv_e0 = quad->side[0]->GetUVPtStruct(true,0);
316 const vector<UVPtStruct>& uv_e1 = quad->side[1]->GetUVPtStruct(false,1);
317 const vector<UVPtStruct>& uv_e2 = quad->side[2]->GetUVPtStruct(true,1);
318 const vector<UVPtStruct>& uv_e3 = quad->side[3]->GetUVPtStruct(false,0);
320 if (uv_e0.empty() || uv_e1.empty() || uv_e2.empty() || uv_e3.empty())
321 return error(COMPERR_BAD_INPUT_MESH);
323 double eps = Precision::Confusion();
325 // Boundary quadrangles
327 if (quad->isEdgeOut[0]) {
330 // |___|___|___|___|___|___|
332 // |___|___|___|___|___|___|
334 // |___|___|___|___|___|___| __ first row of the regular grid
335 // . . . . . . . . . __ down edge nodes
337 // >->->->->->->->->->->->-> -- direction of processing
339 int g = 0; // number of last processed node in the regular grid
341 // number of last node of the down edge to be processed
342 int stop = nbdown - 1;
343 // if right edge is out, we will stop at a node, previous to the last one
344 if (quad->isEdgeOut[1]) stop--;
346 // for each node of the down edge find nearest node
347 // in the first row of the regular grid and link them
348 for (i = 0; i < stop; i++) {
349 const SMDS_MeshNode *a, *b, *c, *d;
351 b = uv_e0[i + 1].node;
352 gp_Pnt pb (b->X(), b->Y(), b->Z());
354 // find node c in the regular grid, which will be linked with node b
357 // right bound reached, link with the rightmost node
359 c = quad->uv_grid[nbhoriz + iup].node;
362 // find in the grid node c, nearest to the b
363 double mind = RealLast();
364 for (int k = g; k <= iup; k++) {
366 const SMDS_MeshNode *nk;
367 if (k < ilow) // this can be, if left edge is out
368 nk = uv_e3[1].node; // get node from the left edge
370 nk = quad->uv_grid[nbhoriz + k].node; // get one of middle nodes
372 gp_Pnt pnk (nk->X(), nk->Y(), nk->Z());
373 double dist = pb.Distance(pnk);
374 if (dist < mind - eps) {
384 if (near == g) { // make triangle
385 SMDS_MeshFace* face = myTool->AddFace(a, b, c);
386 if (face) meshDS->SetMeshElementOnShape(face, geomFaceID);
388 else { // make quadrangle
392 d = quad->uv_grid[nbhoriz + near - 1].node;
393 //SMDS_MeshFace* face = meshDS->AddFace(a, b, c, d);
395 if (!myTrianglePreference){
396 SMDS_MeshFace* face = myTool->AddFace(a, b, c, d);
397 if (face) meshDS->SetMeshElementOnShape(face, geomFaceID);
400 SplitQuad(meshDS, geomFaceID, a, b, c, d);
403 // if node d is not at position g - make additional triangles
405 for (int k = near - 1; k > g; k--) {
406 c = quad->uv_grid[nbhoriz + k].node;
410 d = quad->uv_grid[nbhoriz + k - 1].node;
411 SMDS_MeshFace* face = myTool->AddFace(a, c, d);
412 if (face) meshDS->SetMeshElementOnShape(face, geomFaceID);
419 if (quad->isEdgeOut[2]) {
422 // <-<-<-<-<-<-<-<-<-<-<-<-< -- direction of processing
424 // . . . . . . . . . __ up edge nodes
425 // ___ ___ ___ ___ ___ ___ __ first row of the regular grid
427 // |___|___|___|___|___|___|
429 // |___|___|___|___|___|___|
432 int g = nbhoriz - 1; // last processed node in the regular grid
435 // if left edge is out, we will stop at a second node
436 if (quad->isEdgeOut[3]) stop++;
438 // for each node of the up edge find nearest node
439 // in the first row of the regular grid and link them
440 for (i = nbup - 1; i > stop; i--) {
441 const SMDS_MeshNode *a, *b, *c, *d;
443 b = uv_e2[i - 1].node;
444 gp_Pnt pb (b->X(), b->Y(), b->Z());
446 // find node c in the grid, which will be linked with node b
448 if (i == stop + 1) { // left bound reached, link with the leftmost node
449 c = quad->uv_grid[nbhoriz*(nbvertic - 2) + ilow].node;
452 // find node c in the grid, nearest to the b
453 double mind = RealLast();
454 for (int k = g; k >= ilow; k--) {
455 const SMDS_MeshNode *nk;
457 nk = uv_e1[nbright - 2].node;
459 nk = quad->uv_grid[nbhoriz*(nbvertic - 2) + k].node;
460 gp_Pnt pnk (nk->X(), nk->Y(), nk->Z());
461 double dist = pb.Distance(pnk);
462 if (dist < mind - eps) {
472 if (near == g) { // make triangle
473 SMDS_MeshFace* face = myTool->AddFace(a, b, c);
474 if (face) meshDS->SetMeshElementOnShape(face, geomFaceID);
476 else { // make quadrangle
478 d = uv_e1[nbright - 2].node;
480 d = quad->uv_grid[nbhoriz*(nbvertic - 2) + near + 1].node;
481 //SMDS_MeshFace* face = meshDS->AddFace(a, b, c, d);
482 if (!myTrianglePreference){
483 SMDS_MeshFace* face = myTool->AddFace(a, b, c, d);
484 if (face) meshDS->SetMeshElementOnShape(face, geomFaceID);
487 SplitQuad(meshDS, geomFaceID, a, b, c, d);
490 if (near + 1 < g) { // if d not is at g - make additional triangles
491 for (int k = near + 1; k < g; k++) {
492 c = quad->uv_grid[nbhoriz*(nbvertic - 2) + k].node;
494 d = uv_e1[nbright - 2].node;
496 d = quad->uv_grid[nbhoriz*(nbvertic - 2) + k + 1].node;
497 SMDS_MeshFace* face = myTool->AddFace(a, c, d);
498 if (face) meshDS->SetMeshElementOnShape(face, geomFaceID);
507 // right or left boundary quadrangles
508 if (quad->isEdgeOut[1]) {
509 // MESSAGE("right edge is out");
510 int g = 0; // last processed node in the grid
511 int stop = nbright - 1;
512 if (quad->isEdgeOut[2]) stop--;
513 for (i = 0; i < stop; i++) {
514 const SMDS_MeshNode *a, *b, *c, *d;
516 b = uv_e1[i + 1].node;
517 gp_Pnt pb (b->X(), b->Y(), b->Z());
519 // find node c in the grid, nearest to the b
521 if (i == stop - 1) { // up bondary reached
522 c = quad->uv_grid[nbhoriz*(jup + 1) - 2].node;
525 double mind = RealLast();
526 for (int k = g; k <= jup; k++) {
527 const SMDS_MeshNode *nk;
529 nk = uv_e0[nbdown - 2].node;
531 nk = quad->uv_grid[nbhoriz*(k + 1) - 2].node;
532 gp_Pnt pnk (nk->X(), nk->Y(), nk->Z());
533 double dist = pb.Distance(pnk);
534 if (dist < mind - eps) {
544 if (near == g) { // make triangle
545 SMDS_MeshFace* face = myTool->AddFace(a, b, c);
546 if (face) meshDS->SetMeshElementOnShape(face, geomFaceID);
548 else { // make quadrangle
550 d = uv_e0[nbdown - 2].node;
552 d = quad->uv_grid[nbhoriz*near - 2].node;
553 //SMDS_MeshFace* face = meshDS->AddFace(a, b, c, d);
555 if (!myTrianglePreference){
556 SMDS_MeshFace* face = myTool->AddFace(a, b, c, d);
557 if (face) meshDS->SetMeshElementOnShape(face, geomFaceID);
560 SplitQuad(meshDS, geomFaceID, a, b, c, d);
563 if (near - 1 > g) { // if d not is at g - make additional triangles
564 for (int k = near - 1; k > g; k--) {
565 c = quad->uv_grid[nbhoriz*(k + 1) - 2].node;
567 d = uv_e0[nbdown - 2].node;
569 d = quad->uv_grid[nbhoriz*k - 2].node;
570 SMDS_MeshFace* face = myTool->AddFace(a, c, d);
571 if (face) meshDS->SetMeshElementOnShape(face, geomFaceID);
578 if (quad->isEdgeOut[3]) {
579 // MESSAGE("left edge is out");
580 int g = nbvertic - 1; // last processed node in the grid
582 if (quad->isEdgeOut[0]) stop++;
583 for (i = nbleft - 1; i > stop; i--) {
584 const SMDS_MeshNode *a, *b, *c, *d;
586 b = uv_e3[i - 1].node;
587 gp_Pnt pb (b->X(), b->Y(), b->Z());
589 // find node c in the grid, nearest to the b
591 if (i == stop + 1) { // down bondary reached
592 c = quad->uv_grid[nbhoriz*jlow + 1].node;
595 double mind = RealLast();
596 for (int k = g; k >= jlow; k--) {
597 const SMDS_MeshNode *nk;
601 nk = quad->uv_grid[nbhoriz*k + 1].node;
602 gp_Pnt pnk (nk->X(), nk->Y(), nk->Z());
603 double dist = pb.Distance(pnk);
604 if (dist < mind - eps) {
614 if (near == g) { // make triangle
615 SMDS_MeshFace* face = myTool->AddFace(a, b, c);
616 if (face) meshDS->SetMeshElementOnShape(face, geomFaceID);
618 else { // make quadrangle
622 d = quad->uv_grid[nbhoriz*(near + 1) + 1].node;
623 //SMDS_MeshFace* face = meshDS->AddFace(a, b, c, d);
624 if (!myTrianglePreference){
625 SMDS_MeshFace* face = myTool->AddFace(a, b, c, d);
626 if (face) meshDS->SetMeshElementOnShape(face, geomFaceID);
629 SplitQuad(meshDS, geomFaceID, a, b, c, d);
632 if (near + 1 < g) { // if d not is at g - make additional triangles
633 for (int k = near + 1; k < g; k++) {
634 c = quad->uv_grid[nbhoriz*k + 1].node;
638 d = quad->uv_grid[nbhoriz*(k + 1) + 1].node;
639 SMDS_MeshFace* face = myTool->AddFace(a, c, d);
640 if (face) meshDS->SetMeshElementOnShape(face, geomFaceID);
654 //=============================================================================
658 //=============================================================================
660 bool StdMeshers_Quadrangle_2D::Evaluate(SMESH_Mesh& aMesh,
661 const TopoDS_Shape& aShape,
662 MapShapeNbElems& aResMap)
665 aMesh.GetSubMesh(aShape);
667 std::vector<int> aNbNodes(4);
668 bool IsQuadratic = false;
669 if (!CheckNbEdgesForEvaluate(aMesh, aShape, aResMap, aNbNodes, IsQuadratic)) {
670 std::vector<int> aResVec(SMDSEntity_Last);
671 for (int i=SMDSEntity_Node; i<SMDSEntity_Last; i++) aResVec[i] = 0;
672 SMESH_subMesh * sm = aMesh.GetSubMesh(aShape);
673 aResMap.insert(std::make_pair(sm,aResVec));
674 SMESH_ComputeErrorPtr& smError = sm->GetComputeError();
675 smError.reset(new SMESH_ComputeError(COMPERR_ALGO_FAILED,"Submesh can not be evaluated",this));
679 if (myQuadranglePreference) {
680 int n1 = aNbNodes[0];
681 int n2 = aNbNodes[1];
682 int n3 = aNbNodes[2];
683 int n4 = aNbNodes[3];
684 int nfull = n1+n2+n3+n4;
687 if (nfull==ntmp && ((n1!=n3) || (n2!=n4))) {
688 // special path for using only quandrangle faces
689 return EvaluateQuadPref(aMesh, aShape, aNbNodes, aResMap, IsQuadratic);
694 int nbdown = aNbNodes[0];
695 int nbup = aNbNodes[2];
697 int nbright = aNbNodes[1];
698 int nbleft = aNbNodes[3];
700 int nbhoriz = Min(nbdown, nbup);
701 int nbvertic = Min(nbright, nbleft);
703 int dh = Max(nbdown, nbup) - nbhoriz;
704 int dv = Max(nbright, nbleft) - nbvertic;
711 int nbNodes = (nbhoriz-2)*(nbvertic-2);
712 //int nbFaces3 = dh + dv + kdh*(nbvertic-1)*2 + kdv*(nbhoriz-1)*2;
713 int nbFaces3 = dh + dv;
714 //if (kdh==1 && kdv==1) nbFaces3 -= 2;
715 //if (dh>0 && dv>0) nbFaces3 -= 2;
716 //int nbFaces4 = (nbhoriz-1-kdh)*(nbvertic-1-kdv);
717 int nbFaces4 = (nbhoriz-1)*(nbvertic-1);
719 std::vector<int> aVec(SMDSEntity_Last);
720 for (int i=SMDSEntity_Node; i<SMDSEntity_Last; i++) aVec[i] = 0;
722 aVec[SMDSEntity_Quad_Triangle] = nbFaces3;
723 aVec[SMDSEntity_Quad_Quadrangle] = nbFaces4;
724 int nbbndedges = nbdown + nbup + nbright + nbleft -4;
725 int nbintedges = (nbFaces4*4 + nbFaces3*3 - nbbndedges) / 2;
726 aVec[SMDSEntity_Node] = nbNodes + nbintedges;
727 if (aNbNodes.size()==5) {
728 aVec[SMDSEntity_Quad_Triangle] = nbFaces3 + aNbNodes[3] -1;
729 aVec[SMDSEntity_Quad_Quadrangle] = nbFaces4 - aNbNodes[3] +1;
733 aVec[SMDSEntity_Node] = nbNodes;
734 aVec[SMDSEntity_Triangle] = nbFaces3;
735 aVec[SMDSEntity_Quadrangle] = nbFaces4;
736 if (aNbNodes.size()==5) {
737 aVec[SMDSEntity_Triangle] = nbFaces3 + aNbNodes[3] - 1;
738 aVec[SMDSEntity_Quadrangle] = nbFaces4 - aNbNodes[3] + 1;
741 SMESH_subMesh * sm = aMesh.GetSubMesh(aShape);
742 aResMap.insert(std::make_pair(sm,aVec));
748 //================================================================================
750 * \brief Return true if only two given edges meat at their common vertex
752 //================================================================================
754 static bool twoEdgesMeatAtVertex(const TopoDS_Edge& e1,
755 const TopoDS_Edge& e2,
759 if (!TopExp::CommonVertex(e1, e2, v))
761 TopTools_ListIteratorOfListOfShape ancestIt(mesh.GetAncestors(v));
762 for (; ancestIt.More() ; ancestIt.Next())
763 if (ancestIt.Value().ShapeType() == TopAbs_EDGE)
764 if (!e1.IsSame(ancestIt.Value()) && !e2.IsSame(ancestIt.Value()))
769 //=============================================================================
773 //=============================================================================
775 FaceQuadStruct* StdMeshers_Quadrangle_2D::CheckNbEdges(SMESH_Mesh & aMesh,
776 const TopoDS_Shape & aShape)
777 //throw(SALOME_Exception)
779 TopoDS_Face F = TopoDS::Face(aShape);
780 if ( F.Orientation() >= TopAbs_INTERNAL ) F.Orientation( TopAbs_FORWARD );
781 const bool ignoreMediumNodes = _quadraticMesh;
783 // verify 1 wire only, with 4 edges
785 list< TopoDS_Edge > edges;
786 list< int > nbEdgesInWire;
787 int nbWire = SMESH_Block::GetOrderedEdges (F, V, edges, nbEdgesInWire);
789 error(COMPERR_BAD_SHAPE, TComm("Wrong number of wires: ") << nbWire);
792 FaceQuadStruct* quad = new FaceQuadStruct;
794 quad->side.reserve(nbEdgesInWire.front());
798 list< TopoDS_Edge >::iterator edgeIt = edges.begin();
799 if (nbEdgesInWire.front() == 3) // exactly 3 edges
801 SMESH_Comment comment;
802 SMESHDS_Mesh* meshDS = aMesh.GetMeshDS();
803 if (myTriaVertexID == -1)
805 comment << "No Base vertex parameter provided for a trilateral geometrical face";
809 TopoDS_Vertex V = TopoDS::Vertex(meshDS->IndexToShape(myTriaVertexID));
811 TopoDS_Edge E1,E2,E3;
812 for (; edgeIt != edges.end(); ++edgeIt) {
813 TopoDS_Edge E = *edgeIt;
814 TopoDS_Vertex VF, VL;
815 TopExp::Vertices(E, VF, VL, true);
818 else if (VL.IsSame(V))
823 if (!E1.IsNull() && !E2.IsNull() && !E3.IsNull())
825 quad->side.push_back(new StdMeshers_FaceSide(F, E1, &aMesh, true, ignoreMediumNodes));
826 quad->side.push_back(new StdMeshers_FaceSide(F, E2, &aMesh, true, ignoreMediumNodes));
827 quad->side.push_back(new StdMeshers_FaceSide(F, E3, &aMesh, false,ignoreMediumNodes));
828 const vector<UVPtStruct>& UVPSleft = quad->side[0]->GetUVPtStruct(true,0);
829 /* vector<UVPtStruct>& UVPStop = */quad->side[1]->GetUVPtStruct(false,1);
830 /* vector<UVPtStruct>& UVPSright = */quad->side[2]->GetUVPtStruct(true,1);
831 const SMDS_MeshNode* aNode = UVPSleft[0].node;
832 gp_Pnt2d aPnt2d(UVPSleft[0].u, UVPSleft[0].v);
833 quad->side.push_back(new StdMeshers_FaceSide(aNode, aPnt2d, quad->side[1]));
837 comment << "Invalid Base vertex parameter: " << myTriaVertexID << " is not among [";
838 TopTools_MapOfShape vMap;
839 for (TopExp_Explorer v(aShape, TopAbs_VERTEX); v.More(); v.Next())
840 if (vMap.Add(v.Current()))
841 comment << meshDS->ShapeToIndex(v.Current()) << (vMap.Extent()==3 ? "]" : ", ");
847 else if (nbEdgesInWire.front() == 4) { // exactly 4 edges
848 for (; edgeIt != edges.end(); ++edgeIt, nbSides++)
849 quad->side.push_back(new StdMeshers_FaceSide(F, *edgeIt, &aMesh,
850 nbSides<TOP_SIDE, ignoreMediumNodes));
852 else if (nbEdgesInWire.front() > 4) { // more than 4 edges - try to unite some
853 list< TopoDS_Edge > sideEdges;
854 while (!edges.empty()) {
856 sideEdges.splice(sideEdges.end(), edges, edges.begin()); // edges.front() -> sideEdges.end()
857 bool sameSide = true;
858 while (!edges.empty() && sameSide) {
859 sameSide = SMESH_Algo::IsContinuous(sideEdges.back(), edges.front());
861 sideEdges.splice(sideEdges.end(), edges, edges.begin());
863 if (nbSides == 0) { // go backward from the first edge
865 while (!edges.empty() && sameSide) {
866 sameSide = SMESH_Algo::IsContinuous(sideEdges.front(), edges.back());
868 sideEdges.splice(sideEdges.begin(), edges, --edges.end());
871 quad->side.push_back(new StdMeshers_FaceSide(F, sideEdges, &aMesh,
872 nbSides<TOP_SIDE, ignoreMediumNodes));
875 // issue 20222. Try to unite only edges shared by two same faces
877 // delete found sides
878 { FaceQuadStruct cleaner(*quad); }
880 quad->side.reserve(nbEdgesInWire.front());
883 SMESH_Block::GetOrderedEdges (F, V, edges, nbEdgesInWire);
884 while (!edges.empty()) {
886 sideEdges.splice(sideEdges.end(), edges, edges.begin());
887 bool sameSide = true;
888 while (!edges.empty() && sameSide) {
890 SMESH_Algo::IsContinuous(sideEdges.back(), edges.front()) &&
891 twoEdgesMeatAtVertex(sideEdges.back(), edges.front(), aMesh);
893 sideEdges.splice(sideEdges.end(), edges, edges.begin());
895 if (nbSides == 0) { // go backward from the first edge
897 while (!edges.empty() && sameSide) {
899 SMESH_Algo::IsContinuous(sideEdges.front(), edges.back()) &&
900 twoEdgesMeatAtVertex(sideEdges.front(), edges.back(), aMesh);
902 sideEdges.splice(sideEdges.begin(), edges, --edges.end());
905 quad->side.push_back(new StdMeshers_FaceSide(F, sideEdges, &aMesh,
906 nbSides<TOP_SIDE, ignoreMediumNodes));
913 MESSAGE ("StdMeshers_Quadrangle_2D. Edge IDs of " << nbSides << " sides:\n");
914 for (int i = 0; i < nbSides; ++i) {
916 for (int e = 0; e < quad->side[i]->NbEdges(); ++e)
917 MESSAGE (myTool->GetMeshDS()->ShapeToIndex(quad->side[i]->Edge(e)) << " ");
923 nbSides = nbEdgesInWire.front();
924 error(COMPERR_BAD_SHAPE, TComm("Face must have 4 sides but not ") << nbSides);
933 //=============================================================================
937 //=============================================================================
939 bool StdMeshers_Quadrangle_2D::CheckNbEdgesForEvaluate(SMESH_Mesh& aMesh,
940 const TopoDS_Shape & aShape,
941 MapShapeNbElems& aResMap,
942 std::vector<int>& aNbNodes,
946 const TopoDS_Face & F = TopoDS::Face(aShape);
948 // verify 1 wire only, with 4 edges
950 list< TopoDS_Edge > edges;
951 list< int > nbEdgesInWire;
952 int nbWire = SMESH_Block::GetOrderedEdges (F, V, edges, nbEdgesInWire);
960 list< TopoDS_Edge >::iterator edgeIt = edges.begin();
961 SMESH_subMesh * sm = aMesh.GetSubMesh(*edgeIt);
962 MapShapeNbElemsItr anIt = aResMap.find(sm);
963 if (anIt==aResMap.end()) {
966 std::vector<int> aVec = (*anIt).second;
967 IsQuadratic = (aVec[SMDSEntity_Quad_Edge] > aVec[SMDSEntity_Edge]);
968 if (nbEdgesInWire.front() == 3) { // exactly 3 edges
969 if (myTriaVertexID>0) {
970 SMESHDS_Mesh* meshDS = aMesh.GetMeshDS();
971 TopoDS_Vertex V = TopoDS::Vertex(meshDS->IndexToShape(myTriaVertexID));
973 TopoDS_Edge E1,E2,E3;
974 for (; edgeIt != edges.end(); ++edgeIt) {
975 TopoDS_Edge E = TopoDS::Edge(*edgeIt);
976 TopoDS_Vertex VF, VL;
977 TopExp::Vertices(E, VF, VL, true);
980 else if (VL.IsSame(V))
985 SMESH_subMesh * sm = aMesh.GetSubMesh(E1);
986 MapShapeNbElemsItr anIt = aResMap.find(sm);
987 if (anIt==aResMap.end()) return false;
988 std::vector<int> aVec = (*anIt).second;
990 aNbNodes[0] = (aVec[SMDSEntity_Node]-1)/2 + 2;
992 aNbNodes[0] = aVec[SMDSEntity_Node] + 2;
993 sm = aMesh.GetSubMesh(E2);
994 anIt = aResMap.find(sm);
995 if (anIt==aResMap.end()) return false;
996 aVec = (*anIt).second;
998 aNbNodes[1] = (aVec[SMDSEntity_Node]-1)/2 + 2;
1000 aNbNodes[1] = aVec[SMDSEntity_Node] + 2;
1001 sm = aMesh.GetSubMesh(E3);
1002 anIt = aResMap.find(sm);
1003 if (anIt==aResMap.end()) return false;
1004 aVec = (*anIt).second;
1006 aNbNodes[2] = (aVec[SMDSEntity_Node]-1)/2 + 2;
1008 aNbNodes[2] = aVec[SMDSEntity_Node] + 2;
1009 aNbNodes[3] = aNbNodes[1];
1015 if (nbEdgesInWire.front() == 4) { // exactly 4 edges
1016 for (; edgeIt != edges.end(); edgeIt++) {
1017 SMESH_subMesh * sm = aMesh.GetSubMesh(*edgeIt);
1018 MapShapeNbElemsItr anIt = aResMap.find(sm);
1019 if (anIt==aResMap.end()) {
1022 std::vector<int> aVec = (*anIt).second;
1024 aNbNodes[nbSides] = (aVec[SMDSEntity_Node]-1)/2 + 2;
1026 aNbNodes[nbSides] = aVec[SMDSEntity_Node] + 2;
1030 else if (nbEdgesInWire.front() > 4) { // more than 4 edges - try to unite some
1031 list< TopoDS_Edge > sideEdges;
1032 while (!edges.empty()) {
1034 sideEdges.splice(sideEdges.end(), edges, edges.begin()); // edges.front() -> sideEdges.end()
1035 bool sameSide = true;
1036 while (!edges.empty() && sameSide) {
1037 sameSide = SMESH_Algo::IsContinuous(sideEdges.back(), edges.front());
1039 sideEdges.splice(sideEdges.end(), edges, edges.begin());
1041 if (nbSides == 0) { // go backward from the first edge
1043 while (!edges.empty() && sameSide) {
1044 sameSide = SMESH_Algo::IsContinuous(sideEdges.front(), edges.back());
1046 sideEdges.splice(sideEdges.begin(), edges, --edges.end());
1049 list<TopoDS_Edge>::iterator ite = sideEdges.begin();
1050 aNbNodes[nbSides] = 1;
1051 for (; ite!=sideEdges.end(); ite++) {
1052 SMESH_subMesh * sm = aMesh.GetSubMesh(*ite);
1053 MapShapeNbElemsItr anIt = aResMap.find(sm);
1054 if (anIt==aResMap.end()) {
1057 std::vector<int> aVec = (*anIt).second;
1059 aNbNodes[nbSides] += (aVec[SMDSEntity_Node]-1)/2 + 1;
1061 aNbNodes[nbSides] += aVec[SMDSEntity_Node] + 1;
1065 // issue 20222. Try to unite only edges shared by two same faces
1068 SMESH_Block::GetOrderedEdges (F, V, edges, nbEdgesInWire);
1069 while (!edges.empty()) {
1071 sideEdges.splice(sideEdges.end(), edges, edges.begin());
1072 bool sameSide = true;
1073 while (!edges.empty() && sameSide) {
1075 SMESH_Algo::IsContinuous(sideEdges.back(), edges.front()) &&
1076 twoEdgesMeatAtVertex(sideEdges.back(), edges.front(), aMesh);
1078 sideEdges.splice(sideEdges.end(), edges, edges.begin());
1080 if (nbSides == 0) { // go backward from the first edge
1082 while (!edges.empty() && sameSide) {
1084 SMESH_Algo::IsContinuous(sideEdges.front(), edges.back()) &&
1085 twoEdgesMeatAtVertex(sideEdges.front(), edges.back(), aMesh);
1087 sideEdges.splice(sideEdges.begin(), edges, --edges.end());
1090 list<TopoDS_Edge>::iterator ite = sideEdges.begin();
1091 aNbNodes[nbSides] = 1;
1092 for (; ite!=sideEdges.end(); ite++) {
1093 SMESH_subMesh * sm = aMesh.GetSubMesh(*ite);
1094 MapShapeNbElemsItr anIt = aResMap.find(sm);
1095 if (anIt==aResMap.end()) {
1098 std::vector<int> aVec = (*anIt).second;
1100 aNbNodes[nbSides] += (aVec[SMDSEntity_Node]-1)/2 + 1;
1102 aNbNodes[nbSides] += aVec[SMDSEntity_Node] + 1;
1110 nbSides = nbEdgesInWire.front();
1111 error(COMPERR_BAD_SHAPE, TComm("Face must have 4 sides but not ") << nbSides);
1119 //=============================================================================
1123 //=============================================================================
1125 FaceQuadStruct *StdMeshers_Quadrangle_2D::CheckAnd2Dcompute
1126 (SMESH_Mesh & aMesh,
1127 const TopoDS_Shape & aShape,
1128 const bool CreateQuadratic) //throw(SALOME_Exception)
1130 _quadraticMesh = CreateQuadratic;
1132 FaceQuadStruct *quad = CheckNbEdges(aMesh, aShape);
1134 if (!quad) return 0;
1136 // set normalized grid on unit square in parametric domain
1137 bool stat = SetNormalizedGrid(aMesh, aShape, quad);
1139 if (quad) delete quad;
1146 //=============================================================================
1150 //=============================================================================
1152 faceQuadStruct::~faceQuadStruct()
1154 for (int i = 0; i < side.size(); i++) {
1155 if (side[i]) delete side[i];
1157 if (uv_grid) delete [] uv_grid;
1161 inline const vector<UVPtStruct>& GetUVPtStructIn(FaceQuadStruct* quad, int i, int nbSeg)
1163 bool isXConst = (i == BOTTOM_SIDE || i == TOP_SIDE);
1164 double constValue = (i == BOTTOM_SIDE || i == LEFT_SIDE) ? 0 : 1;
1166 quad->isEdgeOut[i] ?
1167 quad->side[i]->SimulateUVPtStruct(nbSeg,isXConst,constValue) :
1168 quad->side[i]->GetUVPtStruct(isXConst,constValue);
1170 inline gp_UV CalcUV(double x, double y,
1171 const gp_UV& a0,const gp_UV& a1,const gp_UV& a2,const gp_UV& a3,
1172 const gp_UV& p0,const gp_UV& p1,const gp_UV& p2,const gp_UV& p3)
1175 ((1 - y) * p0 + x * p1 + y * p2 + (1 - x) * p3 ) -
1176 ((1 - x) * (1 - y) * a0 + x * (1 - y) * a1 + x * y * a2 + (1 - x) * y * a3);
1180 //=============================================================================
1184 //=============================================================================
1186 bool StdMeshers_Quadrangle_2D::SetNormalizedGrid (SMESH_Mesh & aMesh,
1187 const TopoDS_Shape& aShape,
1188 FaceQuadStruct* & quad) //throw (SALOME_Exception)
1190 // Algorithme décrit dans "Génération automatique de maillages"
1191 // P.L. GEORGE, MASSON, § 6.4.1 p. 84-85
1192 // traitement dans le domaine paramétrique 2d u,v
1193 // transport - projection sur le carré unité
1195 // MESSAGE("StdMeshers_Quadrangle_2D::SetNormalizedGrid");
1196 // const TopoDS_Face& F = TopoDS::Face(aShape);
1198 // 1 --- find orientation of the 4 edges, by test on extrema
1201 // |<----north-2-------^ a3 -------------> a2
1203 // west-3 east-1 =right | |
1207 // v----south-0--------> a0 -------------> a1
1212 // 3 --- 2D normalized values on unit square [0..1][0..1]
1214 int nbhoriz = Min(quad->side[0]->NbPoints(), quad->side[2]->NbPoints());
1215 int nbvertic = Min(quad->side[1]->NbPoints(), quad->side[3]->NbPoints());
1217 quad->isEdgeOut[0] = (quad->side[0]->NbPoints() > quad->side[2]->NbPoints());
1218 quad->isEdgeOut[1] = (quad->side[1]->NbPoints() > quad->side[3]->NbPoints());
1219 quad->isEdgeOut[2] = (quad->side[2]->NbPoints() > quad->side[0]->NbPoints());
1220 quad->isEdgeOut[3] = (quad->side[3]->NbPoints() > quad->side[1]->NbPoints());
1222 UVPtStruct *uv_grid = quad->uv_grid = new UVPtStruct[nbvertic * nbhoriz];
1224 const vector<UVPtStruct>& uv_e0 = GetUVPtStructIn(quad, 0, nbhoriz - 1);
1225 const vector<UVPtStruct>& uv_e1 = GetUVPtStructIn(quad, 1, nbvertic - 1);
1226 const vector<UVPtStruct>& uv_e2 = GetUVPtStructIn(quad, 2, nbhoriz - 1);
1227 const vector<UVPtStruct>& uv_e3 = GetUVPtStructIn(quad, 3, nbvertic - 1);
1229 if (uv_e0.empty() || uv_e1.empty() || uv_e2.empty() || uv_e3.empty())
1230 //return error("Can't find nodes on sides");
1231 return error(COMPERR_BAD_INPUT_MESH);
1233 // nodes Id on "in" edges
1234 if (! quad->isEdgeOut[0]) {
1236 for (int i = 0; i < nbhoriz; i++) { // down
1237 int ij = j * nbhoriz + i;
1238 uv_grid[ij].node = uv_e0[i].node;
1241 if (! quad->isEdgeOut[1]) {
1242 int i = nbhoriz - 1;
1243 for (int j = 0; j < nbvertic; j++) { // right
1244 int ij = j * nbhoriz + i;
1245 uv_grid[ij].node = uv_e1[j].node;
1248 if (! quad->isEdgeOut[2]) {
1249 int j = nbvertic - 1;
1250 for (int i = 0; i < nbhoriz; i++) { // up
1251 int ij = j * nbhoriz + i;
1252 uv_grid[ij].node = uv_e2[i].node;
1255 if (! quad->isEdgeOut[3]) {
1257 for (int j = 0; j < nbvertic; j++) { // left
1258 int ij = j * nbhoriz + i;
1259 uv_grid[ij].node = uv_e3[j].node;
1263 // normalized 2d values on grid
1264 for (int i = 0; i < nbhoriz; i++) {
1265 for (int j = 0; j < nbvertic; j++) {
1266 int ij = j * nbhoriz + i;
1267 // --- droite i cste : x = x0 + y(x1-x0)
1268 double x0 = uv_e0[i].normParam; // bas - sud
1269 double x1 = uv_e2[i].normParam; // haut - nord
1270 // --- droite j cste : y = y0 + x(y1-y0)
1271 double y0 = uv_e3[j].normParam; // gauche-ouest
1272 double y1 = uv_e1[j].normParam; // droite - est
1273 // --- intersection : x=x0+(y0+x(y1-y0))(x1-x0)
1274 double x = (x0 + y0 * (x1 - x0)) / (1 - (y1 - y0) * (x1 - x0));
1275 double y = y0 + x * (y1 - y0);
1278 //MESSAGE("-xy-01 "<<x0<<" "<<x1<<" "<<y0<<" "<<y1);
1279 //MESSAGE("-xy-norm "<<i<<" "<<j<<" "<<x<<" "<<y);
1283 // 4 --- projection on 2d domain (u,v)
1284 gp_UV a0(uv_e0.front().u, uv_e0.front().v);
1285 gp_UV a1(uv_e0.back().u, uv_e0.back().v);
1286 gp_UV a2(uv_e2.back().u, uv_e2.back().v);
1287 gp_UV a3(uv_e2.front().u, uv_e2.front().v);
1289 for (int i = 0; i < nbhoriz; i++) {
1290 for (int j = 0; j < nbvertic; j++) {
1291 int ij = j * nbhoriz + i;
1292 double x = uv_grid[ij].x;
1293 double y = uv_grid[ij].y;
1294 double param_0 = uv_e0[0].normParam + x * (uv_e0.back().normParam - uv_e0[0].normParam); // sud
1295 double param_2 = uv_e2[0].normParam + x * (uv_e2.back().normParam - uv_e2[0].normParam); // nord
1296 double param_1 = uv_e1[0].normParam + y * (uv_e1.back().normParam - uv_e1[0].normParam); // est
1297 double param_3 = uv_e3[0].normParam + y * (uv_e3.back().normParam - uv_e3[0].normParam); // ouest
1299 //MESSAGE("params "<<param_0<<" "<<param_1<<" "<<param_2<<" "<<param_3);
1300 gp_UV p0 = quad->side[0]->Value2d(param_0).XY();
1301 gp_UV p1 = quad->side[1]->Value2d(param_1).XY();
1302 gp_UV p2 = quad->side[2]->Value2d(param_2).XY();
1303 gp_UV p3 = quad->side[3]->Value2d(param_3).XY();
1305 gp_UV uv = CalcUV(x,y, a0,a1,a2,a3, p0,p1,p2,p3);
1307 uv_grid[ij].u = uv.X();
1308 uv_grid[ij].v = uv.Y();
1314 //=======================================================================
1315 //function : ShiftQuad
1316 //purpose : auxilary function for ComputeQuadPref
1317 //=======================================================================
1319 static void ShiftQuad(FaceQuadStruct* quad, const int num, bool)
1321 StdMeshers_FaceSide* side[4] = { quad->side[0], quad->side[1], quad->side[2], quad->side[3] };
1322 for (int i = BOTTOM_SIDE; i < NB_SIDES; ++i) {
1323 int id = (i + num) % NB_SIDES;
1324 bool wasForward = (i < TOP_SIDE);
1325 bool newForward = (id < TOP_SIDE);
1326 if (wasForward != newForward)
1327 side[ i ]->Reverse();
1328 quad->side[ id ] = side[ i ];
1332 //=======================================================================
1334 //purpose : auxilary function for ComputeQuadPref
1335 //=======================================================================
1337 static gp_UV CalcUV(double x0, double x1, double y0, double y1,
1338 FaceQuadStruct* quad,
1339 const gp_UV& a0, const gp_UV& a1,
1340 const gp_UV& a2, const gp_UV& a3)
1342 const vector<UVPtStruct>& uv_eb = quad->side[0]->GetUVPtStruct(true,0);
1343 const vector<UVPtStruct>& uv_er = quad->side[1]->GetUVPtStruct(false,1);
1344 const vector<UVPtStruct>& uv_et = quad->side[2]->GetUVPtStruct(true,1);
1345 const vector<UVPtStruct>& uv_el = quad->side[3]->GetUVPtStruct(false,0);
1347 double x = (x0 + y0 * (x1 - x0)) / (1 - (y1 - y0) * (x1 - x0));
1348 double y = y0 + x * (y1 - y0);
1350 double param_b = uv_eb[0].normParam + x * (uv_eb.back().normParam - uv_eb[0].normParam);
1351 double param_t = uv_et[0].normParam + x * (uv_et.back().normParam - uv_et[0].normParam);
1352 double param_r = uv_er[0].normParam + y * (uv_er.back().normParam - uv_er[0].normParam);
1353 double param_l = uv_el[0].normParam + y * (uv_el.back().normParam - uv_el[0].normParam);
1355 gp_UV p0 = quad->side[BOTTOM_SIDE]->Value2d(param_b).XY();
1356 gp_UV p1 = quad->side[RIGHT_SIDE ]->Value2d(param_r).XY();
1357 gp_UV p2 = quad->side[TOP_SIDE ]->Value2d(param_t).XY();
1358 gp_UV p3 = quad->side[LEFT_SIDE ]->Value2d(param_l).XY();
1360 gp_UV uv = CalcUV(x,y, a0,a1,a2,a3, p0,p1,p2,p3);
1365 //=======================================================================
1366 //function : CalcUV2
1367 //purpose : auxilary function for ComputeQuadPref
1368 //=======================================================================
1370 static gp_UV CalcUV2(double x, double y,
1371 FaceQuadStruct* quad,
1372 const gp_UV& a0, const gp_UV& a1,
1373 const gp_UV& a2, const gp_UV& a3)
1375 gp_UV p0 = quad->side[BOTTOM_SIDE]->Value2d(x).XY();
1376 gp_UV p1 = quad->side[RIGHT_SIDE ]->Value2d(y).XY();
1377 gp_UV p2 = quad->side[TOP_SIDE ]->Value2d(x).XY();
1378 gp_UV p3 = quad->side[LEFT_SIDE ]->Value2d(y).XY();
1380 gp_UV uv = CalcUV(x,y, a0,a1,a2,a3, p0,p1,p2,p3);
1386 //=======================================================================
1388 * Create only quandrangle faces
1390 //=======================================================================
1392 bool StdMeshers_Quadrangle_2D::ComputeQuadPref (SMESH_Mesh & aMesh,
1393 const TopoDS_Shape& aShape,
1394 FaceQuadStruct* quad)
1396 // Auxilary key in order to keep old variant
1397 // of meshing after implementation new variant
1398 // for bug 0016220 from Mantis.
1399 bool OldVersion = false;
1400 if (myQuadType == QUAD_QUADRANGLE_PREF_REVERSED)
1403 SMESHDS_Mesh * meshDS = aMesh.GetMeshDS();
1404 const TopoDS_Face& F = TopoDS::Face(aShape);
1405 Handle(Geom_Surface) S = BRep_Tool::Surface(F);
1407 int i,j,geomFaceID = meshDS->ShapeToIndex(F);
1409 int nb = quad->side[0]->NbPoints();
1410 int nr = quad->side[1]->NbPoints();
1411 int nt = quad->side[2]->NbPoints();
1412 int nl = quad->side[3]->NbPoints();
1413 int dh = abs(nb-nt);
1414 int dv = abs(nr-nl);
1418 // it is a base case => not shift quad but me be replacement is need
1419 ShiftQuad(quad,0,WisF);
1422 // we have to shift quad on 2
1423 ShiftQuad(quad,2,WisF);
1428 // we have to shift quad on 1
1429 ShiftQuad(quad,1,WisF);
1432 // we have to shift quad on 3
1433 ShiftQuad(quad,3,WisF);
1437 nb = quad->side[0]->NbPoints();
1438 nr = quad->side[1]->NbPoints();
1439 nt = quad->side[2]->NbPoints();
1440 nl = quad->side[3]->NbPoints();
1443 int nbh = Max(nb,nt);
1444 int nbv = Max(nr,nl);
1448 // ----------- Old version ---------------
1449 // orientation of face and 3 main domain for future faces
1455 // left | | | | rigth
1462 // ----------- New version ---------------
1463 // orientation of face and 3 main domain for future faces
1469 // left |/________\| rigth
1485 const vector<UVPtStruct>& uv_eb = quad->side[0]->GetUVPtStruct(true,0);
1486 const vector<UVPtStruct>& uv_er = quad->side[1]->GetUVPtStruct(false,1);
1487 const vector<UVPtStruct>& uv_et = quad->side[2]->GetUVPtStruct(true,1);
1488 const vector<UVPtStruct>& uv_el = quad->side[3]->GetUVPtStruct(false,0);
1490 if (uv_eb.size() != nb || uv_er.size() != nr || uv_et.size() != nt || uv_el.size() != nl)
1491 return error(COMPERR_BAD_INPUT_MESH);
1493 // arrays for normalized params
1494 //cout<<"Dump B:"<<endl;
1495 TColStd_SequenceOfReal npb, npr, npt, npl;
1496 for (i=0; i<nb; i++) {
1497 npb.Append(uv_eb[i].normParam);
1498 //cout<<"i="<<i<<" par="<<uv_eb[i].normParam<<" npar="<<uv_eb[i].normParam;
1499 //const SMDS_MeshNode* N = uv_eb[i].node;
1500 //cout<<" node("<<N->X()<<","<<N->Y()<<","<<N->Z()<<")"<<endl;
1502 for (i=0; i<nr; i++) {
1503 npr.Append(uv_er[i].normParam);
1505 for (i=0; i<nt; i++) {
1506 npt.Append(uv_et[i].normParam);
1508 for (i=0; i<nl; i++) {
1509 npl.Append(uv_el[i].normParam);
1514 // add some params to right and left after the first param
1517 double dpr = (npr.Value(2) - npr.Value(1))/(dr+1);
1518 for (i=1; i<=dr; i++) {
1519 npr.InsertAfter(1,npr.Value(2)-dpr);
1523 dpr = (npl.Value(2) - npl.Value(1))/(dl+1);
1524 for (i=1; i<=dl; i++) {
1525 npl.InsertAfter(1,npl.Value(2)-dpr);
1529 //for (i=1; i<=npb.Length(); i++) {
1530 // cout<<" "<<npb.Value(i);
1534 gp_XY a0(uv_eb.front().u, uv_eb.front().v);
1535 gp_XY a1(uv_eb.back().u, uv_eb.back().v);
1536 gp_XY a2(uv_et.back().u, uv_et.back().v);
1537 gp_XY a3(uv_et.front().u, uv_et.front().v);
1538 //cout<<" a0("<<a0.X()<<","<<a0.Y()<<")"<<" a1("<<a1.X()<<","<<a1.Y()<<")"
1539 // <<" a2("<<a2.X()<<","<<a2.Y()<<")"<<" a3("<<a3.X()<<","<<a3.Y()<<")"<<endl;
1541 int nnn = Min(nr,nl);
1542 // auxilary sequence of XY for creation nodes
1543 // in the bottom part of central domain
1544 // Length of UVL and UVR must be == nbv-nnn
1545 TColgp_SequenceOfXY UVL, UVR, UVT;
1548 // step1: create faces for left domain
1549 StdMeshers_Array2OfNode NodesL(1,dl+1,1,nl);
1551 for (j=1; j<=nl; j++)
1552 NodesL.SetValue(1,j,uv_el[j-1].node);
1555 for (i=1; i<=dl; i++)
1556 NodesL.SetValue(i+1,nl,uv_et[i].node);
1557 // create and add needed nodes
1558 TColgp_SequenceOfXY UVtmp;
1559 for (i=1; i<=dl; i++) {
1560 double x0 = npt.Value(i+1);
1563 double y0 = npl.Value(i+1);
1564 double y1 = npr.Value(i+1);
1565 gp_UV UV = CalcUV(x0, x1, y0, y1, quad, a0, a1, a2, a3);
1566 gp_Pnt P = S->Value(UV.X(),UV.Y());
1567 SMDS_MeshNode * N = meshDS->AddNode(P.X(), P.Y(), P.Z());
1568 meshDS->SetNodeOnFace(N, geomFaceID, UV.X(), UV.Y());
1569 NodesL.SetValue(i+1,1,N);
1570 if (UVL.Length()<nbv-nnn) UVL.Append(UV);
1572 for (j=2; j<nl; j++) {
1573 double y0 = npl.Value(dl+j);
1574 double y1 = npr.Value(dl+j);
1575 gp_UV UV = CalcUV(x0, x1, y0, y1, quad, a0, a1, a2, a3);
1576 gp_Pnt P = S->Value(UV.X(),UV.Y());
1577 SMDS_MeshNode* N = meshDS->AddNode(P.X(), P.Y(), P.Z());
1578 meshDS->SetNodeOnFace(N, geomFaceID, UV.X(), UV.Y());
1579 NodesL.SetValue(i+1,j,N);
1580 if (i==dl) UVtmp.Append(UV);
1583 for (i=1; i<=UVtmp.Length() && UVL.Length()<nbv-nnn; i++) {
1584 UVL.Append(UVtmp.Value(i));
1586 //cout<<"Dump NodesL:"<<endl;
1587 //for (i=1; i<=dl+1; i++) {
1589 // for (j=1; j<=nl; j++) {
1590 // cout<<" ("<<NodesL.Value(i,j)->X()<<","<<NodesL.Value(i,j)->Y()<<","<<NodesL.Value(i,j)->Z()<<")";
1595 for (i=1; i<=dl; i++) {
1596 for (j=1; j<nl; j++) {
1599 myTool->AddFace(NodesL.Value(i,j), NodesL.Value(i+1,j),
1600 NodesL.Value(i+1,j+1), NodesL.Value(i,j+1));
1601 if (F) meshDS->SetMeshElementOnShape(F, geomFaceID);
1605 myTool->AddFace(NodesL.Value(i,j), NodesL.Value(i,j+1),
1606 NodesL.Value(i+1,j+1), NodesL.Value(i+1,j));
1607 if (F) meshDS->SetMeshElementOnShape(F, geomFaceID);
1613 // fill UVL using c2d
1614 for (i=1; i<npl.Length() && UVL.Length()<nbv-nnn; i++) {
1615 UVL.Append(gp_UV (uv_el[i].u, uv_el[i].v));
1619 // step2: create faces for right domain
1620 StdMeshers_Array2OfNode NodesR(1,dr+1,1,nr);
1622 for (j=1; j<=nr; j++)
1623 NodesR.SetValue(1,j,uv_er[nr-j].node);
1626 for (i=1; i<=dr; i++)
1627 NodesR.SetValue(i+1,1,uv_et[nt-1-i].node);
1628 // create and add needed nodes
1629 TColgp_SequenceOfXY UVtmp;
1630 for (i=1; i<=dr; i++) {
1631 double x0 = npt.Value(nt-i);
1634 double y0 = npl.Value(i+1);
1635 double y1 = npr.Value(i+1);
1636 gp_UV UV = CalcUV(x0, x1, y0, y1, quad, a0, a1, a2, a3);
1637 gp_Pnt P = S->Value(UV.X(),UV.Y());
1638 SMDS_MeshNode * N = meshDS->AddNode(P.X(), P.Y(), P.Z());
1639 meshDS->SetNodeOnFace(N, geomFaceID, UV.X(), UV.Y());
1640 NodesR.SetValue(i+1,nr,N);
1641 if (UVR.Length()<nbv-nnn) UVR.Append(UV);
1643 for (j=2; j<nr; j++) {
1644 double y0 = npl.Value(nbv-j+1);
1645 double y1 = npr.Value(nbv-j+1);
1646 gp_UV UV = CalcUV(x0, x1, y0, y1, quad, a0, a1, a2, a3);
1647 gp_Pnt P = S->Value(UV.X(),UV.Y());
1648 SMDS_MeshNode* N = meshDS->AddNode(P.X(), P.Y(), P.Z());
1649 meshDS->SetNodeOnFace(N, geomFaceID, UV.X(), UV.Y());
1650 NodesR.SetValue(i+1,j,N);
1651 if (i==dr) UVtmp.Prepend(UV);
1654 for (i=1; i<=UVtmp.Length() && UVR.Length()<nbv-nnn; i++) {
1655 UVR.Append(UVtmp.Value(i));
1658 for (i=1; i<=dr; i++) {
1659 for (j=1; j<nr; j++) {
1662 myTool->AddFace(NodesR.Value(i,j), NodesR.Value(i+1,j),
1663 NodesR.Value(i+1,j+1), NodesR.Value(i,j+1));
1664 if (F) meshDS->SetMeshElementOnShape(F, geomFaceID);
1668 myTool->AddFace(NodesR.Value(i,j), NodesR.Value(i,j+1),
1669 NodesR.Value(i+1,j+1), NodesR.Value(i+1,j));
1670 if (F) meshDS->SetMeshElementOnShape(F, geomFaceID);
1676 // fill UVR using c2d
1677 for (i=1; i<npr.Length() && UVR.Length()<nbv-nnn; i++) {
1678 UVR.Append(gp_UV(uv_er[i].u, uv_er[i].v));
1682 // step3: create faces for central domain
1683 StdMeshers_Array2OfNode NodesC(1,nb,1,nbv);
1684 // add first line using NodesL
1685 for (i=1; i<=dl+1; i++)
1686 NodesC.SetValue(1,i,NodesL(i,1));
1687 for (i=2; i<=nl; i++)
1688 NodesC.SetValue(1,dl+i,NodesL(dl+1,i));
1689 // add last line using NodesR
1690 for (i=1; i<=dr+1; i++)
1691 NodesC.SetValue(nb,i,NodesR(i,nr));
1692 for (i=1; i<nr; i++)
1693 NodesC.SetValue(nb,dr+i+1,NodesR(dr+1,nr-i));
1694 // add top nodes (last columns)
1695 for (i=dl+2; i<nbh-dr; i++)
1696 NodesC.SetValue(i-dl,nbv,uv_et[i-1].node);
1697 // add bottom nodes (first columns)
1698 for (i=2; i<nb; i++)
1699 NodesC.SetValue(i,1,uv_eb[i-1].node);
1701 // create and add needed nodes
1702 // add linear layers
1703 for (i=2; i<nb; i++) {
1704 double x0 = npt.Value(dl+i);
1706 for (j=1; j<nnn; j++) {
1707 double y0 = npl.Value(nbv-nnn+j);
1708 double y1 = npr.Value(nbv-nnn+j);
1709 gp_UV UV = CalcUV(x0, x1, y0, y1, quad, a0, a1, a2, a3);
1710 gp_Pnt P = S->Value(UV.X(),UV.Y());
1711 SMDS_MeshNode* N = meshDS->AddNode(P.X(), P.Y(), P.Z());
1712 meshDS->SetNodeOnFace(N, geomFaceID, UV.X(), UV.Y());
1713 NodesC.SetValue(i,nbv-nnn+j,N);
1718 // add diagonal layers
1719 //cout<<"UVL.Length()="<<UVL.Length()<<" UVR.Length()="<<UVR.Length()<<endl;
1720 //cout<<"Dump UVL:"<<endl;
1721 //for (i=1; i<=UVL.Length(); i++) {
1722 // cout<<" ("<<UVL.Value(i).X()<<","<<UVL.Value(i).Y()<<")";
1725 gp_UV A2 = UVR.Value(nbv-nnn);
1726 gp_UV A3 = UVL.Value(nbv-nnn);
1727 for (i=1; i<nbv-nnn; i++) {
1728 gp_UV p1 = UVR.Value(i);
1729 gp_UV p3 = UVL.Value(i);
1730 double y = i / double(nbv-nnn);
1731 for (j=2; j<nb; j++) {
1732 double x = npb.Value(j);
1733 gp_UV p0( uv_eb[j-1].u, uv_eb[j-1].v );
1734 gp_UV p2 = UVT.Value( j-1 );
1735 gp_UV UV = CalcUV(x, y, a0, a1, A2, A3, p0,p1,p2,p3 );
1736 gp_Pnt P = S->Value(UV.X(),UV.Y());
1737 SMDS_MeshNode* N = meshDS->AddNode(P.X(), P.Y(), P.Z());
1738 meshDS->SetNodeOnFace(N, geomFaceID, UV.X(),UV.Y());
1739 NodesC.SetValue(j,i+1,N);
1743 for (i=1; i<nb; i++) {
1744 for (j=1; j<nbv; j++) {
1747 myTool->AddFace(NodesC.Value(i,j), NodesC.Value(i+1,j),
1748 NodesC.Value(i+1,j+1), NodesC.Value(i,j+1));
1749 if (F) meshDS->SetMeshElementOnShape(F, geomFaceID);
1753 myTool->AddFace(NodesC.Value(i,j), NodesC.Value(i,j+1),
1754 NodesC.Value(i+1,j+1), NodesC.Value(i+1,j));
1755 if (F) meshDS->SetMeshElementOnShape(F, geomFaceID);
1761 else { // New version (!OldVersion)
1762 // step1: create faces for bottom rectangle domain
1763 StdMeshers_Array2OfNode NodesBRD(1,nb,1,nnn-1);
1764 // fill UVL and UVR using c2d
1765 for (j=0; j<nb; j++) {
1766 NodesBRD.SetValue(j+1,1,uv_eb[j].node);
1768 for (i=1; i<nnn-1; i++) {
1769 NodesBRD.SetValue(1,i+1,uv_el[i].node);
1770 NodesBRD.SetValue(nb,i+1,uv_er[i].node);
1771 for (j=2; j<nb; j++) {
1772 double x = npb.Value(j);
1773 double y = (1-x) * npl.Value(i+1) + x * npr.Value(i+1);
1774 gp_UV UV = CalcUV2(x, y, quad, a0, a1, a2, a3);
1775 gp_Pnt P = S->Value(UV.X(),UV.Y());
1776 SMDS_MeshNode* N = meshDS->AddNode(P.X(), P.Y(), P.Z());
1777 meshDS->SetNodeOnFace(N, geomFaceID, UV.X(),UV.Y());
1778 NodesBRD.SetValue(j,i+1,N);
1781 for (j=1; j<nnn-1; j++) {
1782 for (i=1; i<nb; i++) {
1785 myTool->AddFace(NodesBRD.Value(i,j), NodesBRD.Value(i+1,j),
1786 NodesBRD.Value(i+1,j+1), NodesBRD.Value(i,j+1));
1787 if (F) meshDS->SetMeshElementOnShape(F, geomFaceID);
1791 myTool->AddFace(NodesBRD.Value(i,j), NodesBRD.Value(i,j+1),
1792 NodesBRD.Value(i+1,j+1), NodesBRD.Value(i+1,j));
1793 if (F) meshDS->SetMeshElementOnShape(F, geomFaceID);
1797 int drl = abs(nr-nl);
1798 // create faces for region C
1799 StdMeshers_Array2OfNode NodesC(1,nb,1,drl+1+addv);
1800 // add nodes from previous region
1801 for (j=1; j<=nb; j++) {
1802 NodesC.SetValue(j,1,NodesBRD.Value(j,nnn-1));
1804 if ((drl+addv) > 0) {
1809 TColgp_SequenceOfXY UVtmp;
1810 double drparam = npr.Value(nr) - npr.Value(nnn-1);
1811 double dlparam = npl.Value(nnn) - npl.Value(nnn-1);
1813 for (i=1; i<=drl; i++) {
1814 // add existed nodes from right edge
1815 NodesC.SetValue(nb,i+1,uv_er[nnn+i-2].node);
1816 //double dtparam = npt.Value(i+1);
1817 y1 = npr.Value(nnn+i-1); // param on right edge
1818 double dpar = (y1 - npr.Value(nnn-1))/drparam;
1819 y0 = npl.Value(nnn-1) + dpar*dlparam; // param on left edge
1820 double dy = y1 - y0;
1821 for (j=1; j<nb; j++) {
1822 double x = npt.Value(i+1) + npb.Value(j)*(1-npt.Value(i+1));
1823 double y = y0 + dy*x;
1824 gp_UV UV = CalcUV2(x, y, quad, a0, a1, a2, a3);
1825 gp_Pnt P = S->Value(UV.X(),UV.Y());
1826 SMDS_MeshNode* N = meshDS->AddNode(P.X(), P.Y(), P.Z());
1827 meshDS->SetNodeOnFace(N, geomFaceID, UV.X(), UV.Y());
1828 NodesC.SetValue(j,i+1,N);
1831 double dy0 = (1-y0)/(addv+1);
1832 double dy1 = (1-y1)/(addv+1);
1833 for (i=1; i<=addv; i++) {
1834 double yy0 = y0 + dy0*i;
1835 double yy1 = y1 + dy1*i;
1836 double dyy = yy1 - yy0;
1837 for (j=1; j<=nb; j++) {
1838 double x = npt.Value(i+1+drl) +
1839 npb.Value(j) * (npt.Value(nt-i) - npt.Value(i+1+drl));
1840 double y = yy0 + dyy*x;
1841 gp_UV UV = CalcUV2(x, y, quad, a0, a1, a2, a3);
1842 gp_Pnt P = S->Value(UV.X(),UV.Y());
1843 SMDS_MeshNode* N = meshDS->AddNode(P.X(), P.Y(), P.Z());
1844 meshDS->SetNodeOnFace(N, geomFaceID, UV.X(), UV.Y());
1845 NodesC.SetValue(j,i+drl+1,N);
1852 TColgp_SequenceOfXY UVtmp;
1853 double dlparam = npl.Value(nl) - npl.Value(nnn-1);
1854 double drparam = npr.Value(nnn) - npr.Value(nnn-1);
1855 double y0 = npl.Value(nnn-1);
1856 double y1 = npr.Value(nnn-1);
1857 for (i=1; i<=drl; i++) {
1858 // add existed nodes from right edge
1859 NodesC.SetValue(1,i+1,uv_el[nnn+i-2].node);
1860 y0 = npl.Value(nnn+i-1); // param on left edge
1861 double dpar = (y0 - npl.Value(nnn-1))/dlparam;
1862 y1 = npr.Value(nnn-1) + dpar*drparam; // param on right edge
1863 double dy = y1 - y0;
1864 for (j=2; j<=nb; j++) {
1865 double x = npb.Value(j)*npt.Value(nt-i);
1866 double y = y0 + dy*x;
1867 gp_UV UV = CalcUV2(x, y, quad, a0, a1, a2, a3);
1868 gp_Pnt P = S->Value(UV.X(),UV.Y());
1869 SMDS_MeshNode* N = meshDS->AddNode(P.X(), P.Y(), P.Z());
1870 meshDS->SetNodeOnFace(N, geomFaceID, UV.X(), UV.Y());
1871 NodesC.SetValue(j,i+1,N);
1874 double dy0 = (1-y0)/(addv+1);
1875 double dy1 = (1-y1)/(addv+1);
1876 for (i=1; i<=addv; i++) {
1877 double yy0 = y0 + dy0*i;
1878 double yy1 = y1 + dy1*i;
1879 double dyy = yy1 - yy0;
1880 for (j=1; j<=nb; j++) {
1881 double x = npt.Value(i+1) +
1882 npb.Value(j) * (npt.Value(nt-i-drl) - npt.Value(i+1));
1883 double y = yy0 + dyy*x;
1884 gp_UV UV = CalcUV2(x, y, quad, a0, a1, a2, a3);
1885 gp_Pnt P = S->Value(UV.X(),UV.Y());
1886 SMDS_MeshNode* N = meshDS->AddNode(P.X(), P.Y(), P.Z());
1887 meshDS->SetNodeOnFace(N, geomFaceID, UV.X(), UV.Y());
1888 NodesC.SetValue(j,i+drl+1,N);
1893 for (j=1; j<=drl+addv; j++) {
1894 for (i=1; i<nb; i++) {
1897 myTool->AddFace(NodesC.Value(i,j), NodesC.Value(i+1,j),
1898 NodesC.Value(i+1,j+1), NodesC.Value(i,j+1));
1899 if (F) meshDS->SetMeshElementOnShape(F, geomFaceID);
1903 myTool->AddFace(NodesC.Value(i,j), NodesC.Value(i,j+1),
1904 NodesC.Value(i+1,j+1), NodesC.Value(i+1,j));
1905 if (F) meshDS->SetMeshElementOnShape(F, geomFaceID);
1910 StdMeshers_Array2OfNode NodesLast(1,nt,1,2);
1911 for (i=1; i<=nt; i++) {
1912 NodesLast.SetValue(i,2,uv_et[i-1].node);
1915 for (i=n1; i<drl+addv+1; i++) {
1917 NodesLast.SetValue(nnn,1,NodesC.Value(1,i));
1919 for (i=1; i<=nb; i++) {
1921 NodesLast.SetValue(nnn,1,NodesC.Value(i,drl+addv+1));
1923 for (i=drl+addv; i>=n2; i--) {
1925 NodesLast.SetValue(nnn,1,NodesC.Value(nb,i));
1927 for (i=1; i<nt; i++) {
1930 myTool->AddFace(NodesLast.Value(i,1), NodesLast.Value(i+1,1),
1931 NodesLast.Value(i+1,2), NodesLast.Value(i,2));
1932 if (F) meshDS->SetMeshElementOnShape(F, geomFaceID);
1936 myTool->AddFace(NodesLast.Value(i,1), NodesLast.Value(i,2),
1937 NodesLast.Value(i+1,2), NodesLast.Value(i+1,2));
1938 if (F) meshDS->SetMeshElementOnShape(F, geomFaceID);
1941 } // if ((drl+addv) > 0)
1943 } // end new version implementation
1950 //=======================================================================
1952 * Evaluate only quandrangle faces
1954 //=======================================================================
1956 bool StdMeshers_Quadrangle_2D::EvaluateQuadPref(SMESH_Mesh & aMesh,
1957 const TopoDS_Shape& aShape,
1958 std::vector<int>& aNbNodes,
1959 MapShapeNbElems& aResMap,
1962 // Auxilary key in order to keep old variant
1963 // of meshing after implementation new variant
1964 // for bug 0016220 from Mantis.
1965 bool OldVersion = false;
1966 if (myQuadType == QUAD_QUADRANGLE_PREF_REVERSED)
1969 const TopoDS_Face& F = TopoDS::Face(aShape);
1970 Handle(Geom_Surface) S = BRep_Tool::Surface(F);
1972 int nb = aNbNodes[0];
1973 int nr = aNbNodes[1];
1974 int nt = aNbNodes[2];
1975 int nl = aNbNodes[3];
1976 int dh = abs(nb-nt);
1977 int dv = abs(nr-nl);
1981 // it is a base case => not shift
1984 // we have to shift on 2
1993 // we have to shift quad on 1
2000 // we have to shift quad on 3
2010 int nbh = Max(nb,nt);
2011 int nbv = Max(nr,nl);
2026 // add some params to right and left after the first param
2033 int nnn = Min(nr,nl);
2038 // step1: create faces for left domain
2040 nbNodes += dl*(nl-1);
2041 nbFaces += dl*(nl-1);
2043 // step2: create faces for right domain
2045 nbNodes += dr*(nr-1);
2046 nbFaces += dr*(nr-1);
2048 // step3: create faces for central domain
2049 nbNodes += (nb-2)*(nnn-1) + (nbv-nnn-1)*(nb-2);
2050 nbFaces += (nb-1)*(nbv-1);
2052 else { // New version (!OldVersion)
2053 nbNodes += (nnn-2)*(nb-2);
2054 nbFaces += (nnn-2)*(nb-1);
2055 int drl = abs(nr-nl);
2056 nbNodes += drl*(nb-1) + addv*nb;
2057 nbFaces += (drl+addv)*(nb-1) + (nt-1);
2058 } // end new version implementation
2060 std::vector<int> aVec(SMDSEntity_Last);
2061 for (int i=SMDSEntity_Node; i<SMDSEntity_Last; i++) aVec[i] = 0;
2063 aVec[SMDSEntity_Quad_Quadrangle] = nbFaces;
2064 aVec[SMDSEntity_Node] = nbNodes + nbFaces*4;
2065 if (aNbNodes.size()==5) {
2066 aVec[SMDSEntity_Quad_Triangle] = aNbNodes[3] - 1;
2067 aVec[SMDSEntity_Quad_Quadrangle] = nbFaces - aNbNodes[3] + 1;
2071 aVec[SMDSEntity_Node] = nbNodes;
2072 aVec[SMDSEntity_Quadrangle] = nbFaces;
2073 if (aNbNodes.size()==5) {
2074 aVec[SMDSEntity_Triangle] = aNbNodes[3] - 1;
2075 aVec[SMDSEntity_Quadrangle] = nbFaces - aNbNodes[3] + 1;
2078 SMESH_subMesh * sm = aMesh.GetSubMesh(aShape);
2079 aResMap.insert(std::make_pair(sm,aVec));
2085 //=============================================================================
2086 /*! Split quadrangle in to 2 triangles by smallest diagonal
2089 //=============================================================================
2090 void StdMeshers_Quadrangle_2D::SplitQuad(SMESHDS_Mesh *theMeshDS,
2092 const SMDS_MeshNode* theNode1,
2093 const SMDS_MeshNode* theNode2,
2094 const SMDS_MeshNode* theNode3,
2095 const SMDS_MeshNode* theNode4)
2097 gp_Pnt a(theNode1->X(),theNode1->Y(),theNode1->Z());
2098 gp_Pnt b(theNode2->X(),theNode2->Y(),theNode2->Z());
2099 gp_Pnt c(theNode3->X(),theNode3->Y(),theNode3->Z());
2100 gp_Pnt d(theNode4->X(),theNode4->Y(),theNode4->Z());
2101 SMDS_MeshFace* face;
2102 if (a.Distance(c) > b.Distance(d)){
2103 face = myTool->AddFace(theNode2, theNode4 , theNode1);
2104 if (face) theMeshDS->SetMeshElementOnShape(face, theFaceID);
2105 face = myTool->AddFace(theNode2, theNode3, theNode4);
2106 if (face) theMeshDS->SetMeshElementOnShape(face, theFaceID);
2110 face = myTool->AddFace(theNode1, theNode2 ,theNode3);
2111 if (face) theMeshDS->SetMeshElementOnShape(face, theFaceID);
2112 face = myTool->AddFace(theNode1, theNode3, theNode4);
2113 if (face) theMeshDS->SetMeshElementOnShape(face, theFaceID);
2117 //=======================================================================
2119 * Implementation of Reduced algorithm (meshing with quadrangles only)
2121 //=======================================================================
2122 bool StdMeshers_Quadrangle_2D::ComputeReduced (SMESH_Mesh & aMesh,
2123 const TopoDS_Shape& aShape,
2124 FaceQuadStruct* quad)
2126 SMESHDS_Mesh * meshDS = aMesh.GetMeshDS();
2127 const TopoDS_Face& F = TopoDS::Face(aShape);
2128 Handle(Geom_Surface) S = BRep_Tool::Surface(F);
2129 int i,j,geomFaceID = meshDS->ShapeToIndex(F);
2131 int nb = quad->side[0]->NbPoints();
2132 int nr = quad->side[1]->NbPoints();
2133 int nt = quad->side[2]->NbPoints();
2134 int nl = quad->side[3]->NbPoints();
2136 // Simple Reduce 8->6->4->2 (3 steps) Multiple Reduce 8->2 (1 step)
2138 // .-----.-----.-----.-----. .-----.-----.-----.-----.
2139 // | / \ | / \ | | / \ | / \ |
2140 // | / .--.--. \ | | / \ | / \ |
2141 // | / / | \ \ | | / .----.----. \ |
2142 // .---.---.---.---.---.---. | / / \ | / \ \ |
2143 // | / / \ | / \ \ | | / / \ | / \ \ |
2144 // | / / .-.-. \ \ | | / / .---.---. \ \ |
2145 // | / / / | \ \ \ | | / / / \ | / \ \ \ |
2146 // .--.--.--.--.--.--.--.--. | / / / \ | / \ \ \ |
2147 // | / / / \ | / \ \ \ | | / / / .-.-. \ \ \ |
2148 // | / / / .-.-. \ \ \ | | / / / / | \ \ \ \ |
2149 // | / / / / | \ \ \ \ | | / / / / | \ \ \ \ |
2150 // .-.-.-.--.--.--.--.-.-.-. .-.-.-.--.--.--.--.-.-.-.
2152 bool MultipleReduce = false;
2165 else if (nb == nt) {
2166 nl1 = nb; // and == nt
2167 nr1 = nb; // and == nt
2181 // number of rows and columns
2182 int nrows = nr1 - 1; // and also == nl1 - 1
2183 int ncol_top = nt1 - 1;
2184 int ncol_bot = nb1 - 1;
2185 int npair_top = ncol_top / 2;
2186 // maximum number of bottom elements for "linear" simple reduce
2187 //int max_lin = ncol_top + npair_top * 2 * nrows;
2188 // maximum number of bottom elements for "tree" simple reduce
2189 int max_tree = npair_top * pow(2.0, nrows + 1);
2190 if (ncol_top > npair_top * 2) {
2191 int delta = ncol_bot - max_tree;
2192 for (int irow = 1; irow < nrows; irow++) {
2193 int nfour = delta / 4;
2196 if (delta <= (ncol_top - npair_top * 2))
2197 max_tree = ncol_bot;
2200 if (ncol_bot > max_tree)
2201 MultipleReduce = true;
2204 if (MultipleReduce) { // == ComputeQuadPref QUAD_QUADRANGLE_PREF_REVERSED
2205 //==================================================
2206 int dh = abs(nb-nt);
2207 int dv = abs(nr-nl);
2211 // it is a base case => not shift quad but may be replacement is need
2212 ShiftQuad(quad,0,true);
2215 // we have to shift quad on 2
2216 ShiftQuad(quad,2,true);
2221 // we have to shift quad on 1
2222 ShiftQuad(quad,1,true);
2225 // we have to shift quad on 3
2226 ShiftQuad(quad,3,true);
2230 nb = quad->side[0]->NbPoints();
2231 nr = quad->side[1]->NbPoints();
2232 nt = quad->side[2]->NbPoints();
2233 nl = quad->side[3]->NbPoints();
2236 int nbh = Max(nb,nt);
2237 int nbv = Max(nr,nl);
2250 const vector<UVPtStruct>& uv_eb = quad->side[0]->GetUVPtStruct(true,0);
2251 const vector<UVPtStruct>& uv_er = quad->side[1]->GetUVPtStruct(false,1);
2252 const vector<UVPtStruct>& uv_et = quad->side[2]->GetUVPtStruct(true,1);
2253 const vector<UVPtStruct>& uv_el = quad->side[3]->GetUVPtStruct(false,0);
2255 if (uv_eb.size() != nb || uv_er.size() != nr || uv_et.size() != nt || uv_el.size() != nl)
2256 return error(COMPERR_BAD_INPUT_MESH);
2258 // arrays for normalized params
2259 TColStd_SequenceOfReal npb, npr, npt, npl;
2260 for (j = 0; j < nb; j++) {
2261 npb.Append(uv_eb[j].normParam);
2263 for (i = 0; i < nr; i++) {
2264 npr.Append(uv_er[i].normParam);
2266 for (j = 0; j < nt; j++) {
2267 npt.Append(uv_et[j].normParam);
2269 for (i = 0; i < nl; i++) {
2270 npl.Append(uv_el[i].normParam);
2274 // orientation of face and 3 main domain for future faces
2280 // left | | | | rigth
2287 // add some params to right and left after the first param
2290 double dpr = (npr.Value(2) - npr.Value(1))/(dr+1);
2291 for (i=1; i<=dr; i++) {
2292 npr.InsertAfter(1,npr.Value(2)-dpr);
2296 dpr = (npl.Value(2) - npl.Value(1))/(dl+1);
2297 for (i=1; i<=dl; i++) {
2298 npl.InsertAfter(1,npl.Value(2)-dpr);
2301 gp_XY a0 (uv_eb.front().u, uv_eb.front().v);
2302 gp_XY a1 (uv_eb.back().u, uv_eb.back().v);
2303 gp_XY a2 (uv_et.back().u, uv_et.back().v);
2304 gp_XY a3 (uv_et.front().u, uv_et.front().v);
2306 int nnn = Min(nr,nl);
2307 // auxilary sequence of XY for creation nodes
2308 // in the bottom part of central domain
2309 // it's length must be == nbv-nnn-1
2310 TColgp_SequenceOfXY UVL;
2311 TColgp_SequenceOfXY UVR;
2312 //==================================================
2314 // step1: create faces for left domain
2315 StdMeshers_Array2OfNode NodesL(1,dl+1,1,nl);
2317 for (j=1; j<=nl; j++)
2318 NodesL.SetValue(1,j,uv_el[j-1].node);
2321 for (i=1; i<=dl; i++)
2322 NodesL.SetValue(i+1,nl,uv_et[i].node);
2323 // create and add needed nodes
2324 TColgp_SequenceOfXY UVtmp;
2325 for (i=1; i<=dl; i++) {
2326 double x0 = npt.Value(i+1);
2329 double y0 = npl.Value(i+1);
2330 double y1 = npr.Value(i+1);
2331 gp_UV UV = CalcUV(x0, x1, y0, y1, quad, a0, a1, a2, a3);
2332 gp_Pnt P = S->Value(UV.X(),UV.Y());
2333 SMDS_MeshNode * N = meshDS->AddNode(P.X(), P.Y(), P.Z());
2334 meshDS->SetNodeOnFace(N, geomFaceID, UV.X(), UV.Y());
2335 NodesL.SetValue(i+1,1,N);
2336 if (UVL.Length()<nbv-nnn-1) UVL.Append(UV);
2338 for (j=2; j<nl; j++) {
2339 double y0 = npl.Value(dl+j);
2340 double y1 = npr.Value(dl+j);
2341 gp_UV UV = CalcUV(x0, x1, y0, y1, quad, a0, a1, a2, a3);
2342 gp_Pnt P = S->Value(UV.X(),UV.Y());
2343 SMDS_MeshNode* N = meshDS->AddNode(P.X(), P.Y(), P.Z());
2344 meshDS->SetNodeOnFace(N, geomFaceID, UV.X(), UV.Y());
2345 NodesL.SetValue(i+1,j,N);
2346 if (i==dl) UVtmp.Append(UV);
2349 for (i=1; i<=UVtmp.Length() && UVL.Length()<nbv-nnn-1; i++) {
2350 UVL.Append(UVtmp.Value(i));
2353 for (i=1; i<=dl; i++) {
2354 for (j=1; j<nl; j++) {
2356 myTool->AddFace(NodesL.Value(i,j), NodesL.Value(i+1,j),
2357 NodesL.Value(i+1,j+1), NodesL.Value(i,j+1));
2358 if (F) meshDS->SetMeshElementOnShape(F, geomFaceID);
2363 // fill UVL using c2d
2364 for (i=1; i<npl.Length() && UVL.Length()<nbv-nnn-1; i++) {
2365 UVL.Append(gp_UV (uv_el[i].u, uv_el[i].v));
2369 // step2: create faces for right domain
2370 StdMeshers_Array2OfNode NodesR(1,dr+1,1,nr);
2372 for (j=1; j<=nr; j++)
2373 NodesR.SetValue(1,j,uv_er[nr-j].node);
2376 for (i=1; i<=dr; i++)
2377 NodesR.SetValue(i+1,1,uv_et[nt-1-i].node);
2378 // create and add needed nodes
2379 TColgp_SequenceOfXY UVtmp;
2380 for (i=1; i<=dr; i++) {
2381 double x0 = npt.Value(nt-i);
2384 double y0 = npl.Value(i+1);
2385 double y1 = npr.Value(i+1);
2386 gp_UV UV = CalcUV(x0, x1, y0, y1, quad, a0, a1, a2, a3);
2387 gp_Pnt P = S->Value(UV.X(),UV.Y());
2388 SMDS_MeshNode * N = meshDS->AddNode(P.X(), P.Y(), P.Z());
2389 meshDS->SetNodeOnFace(N, geomFaceID, UV.X(), UV.Y());
2390 NodesR.SetValue(i+1,nr,N);
2391 if (UVR.Length()<nbv-nnn-1) UVR.Append(UV);
2393 for (j=2; j<nr; j++) {
2394 double y0 = npl.Value(nbv-j+1);
2395 double y1 = npr.Value(nbv-j+1);
2396 gp_UV UV = CalcUV(x0, x1, y0, y1, quad, a0, a1, a2, a3);
2397 gp_Pnt P = S->Value(UV.X(),UV.Y());
2398 SMDS_MeshNode* N = meshDS->AddNode(P.X(), P.Y(), P.Z());
2399 meshDS->SetNodeOnFace(N, geomFaceID, UV.X(), UV.Y());
2400 NodesR.SetValue(i+1,j,N);
2401 if (i==dr) UVtmp.Prepend(UV);
2404 for (i=1; i<=UVtmp.Length() && UVR.Length()<nbv-nnn-1; i++) {
2405 UVR.Append(UVtmp.Value(i));
2408 for (i=1; i<=dr; i++) {
2409 for (j=1; j<nr; j++) {
2411 myTool->AddFace(NodesR.Value(i,j), NodesR.Value(i+1,j),
2412 NodesR.Value(i+1,j+1), NodesR.Value(i,j+1));
2413 if (F) meshDS->SetMeshElementOnShape(F, geomFaceID);
2418 // fill UVR using c2d
2419 for (i=1; i<npr.Length() && UVR.Length()<nbv-nnn-1; i++) {
2420 UVR.Append(gp_UV(uv_er[i].u, uv_er[i].v));
2424 // step3: create faces for central domain
2425 StdMeshers_Array2OfNode NodesC(1,nb,1,nbv);
2426 // add first line using NodesL
2427 for (i=1; i<=dl+1; i++)
2428 NodesC.SetValue(1,i,NodesL(i,1));
2429 for (i=2; i<=nl; i++)
2430 NodesC.SetValue(1,dl+i,NodesL(dl+1,i));
2431 // add last line using NodesR
2432 for (i=1; i<=dr+1; i++)
2433 NodesC.SetValue(nb,i,NodesR(i,nr));
2434 for (i=1; i<nr; i++)
2435 NodesC.SetValue(nb,dr+i+1,NodesR(dr+1,nr-i));
2436 // add top nodes (last columns)
2437 for (i=dl+2; i<nbh-dr; i++)
2438 NodesC.SetValue(i-dl,nbv,uv_et[i-1].node);
2439 // add bottom nodes (first columns)
2440 for (i=2; i<nb; i++)
2441 NodesC.SetValue(i,1,uv_eb[i-1].node);
2443 // create and add needed nodes
2444 // add linear layers
2445 for (i=2; i<nb; i++) {
2446 double x0 = npt.Value(dl+i);
2448 for (j=1; j<nnn; j++) {
2449 double y0 = npl.Value(nbv-nnn+j);
2450 double y1 = npr.Value(nbv-nnn+j);
2451 gp_UV UV = CalcUV(x0, x1, y0, y1, quad, a0, a1, a2, a3);
2452 gp_Pnt P = S->Value(UV.X(),UV.Y());
2453 SMDS_MeshNode* N = meshDS->AddNode(P.X(), P.Y(), P.Z());
2454 meshDS->SetNodeOnFace(N, geomFaceID, UV.X(), UV.Y());
2455 NodesC.SetValue(i,nbv-nnn+j,N);
2458 // add diagonal layers
2459 for (i=1; i<nbv-nnn; i++) {
2460 double du = UVR.Value(i).X() - UVL.Value(i).X();
2461 double dv = UVR.Value(i).Y() - UVL.Value(i).Y();
2462 for (j=2; j<nb; j++) {
2463 double u = UVL.Value(i).X() + du*npb.Value(j);
2464 double v = UVL.Value(i).Y() + dv*npb.Value(j);
2465 gp_Pnt P = S->Value(u,v);
2466 SMDS_MeshNode* N = meshDS->AddNode(P.X(), P.Y(), P.Z());
2467 meshDS->SetNodeOnFace(N, geomFaceID, u, v);
2468 NodesC.SetValue(j,i+1,N);
2472 for (i=1; i<nb; i++) {
2473 for (j=1; j<nbv; j++) {
2475 myTool->AddFace(NodesC.Value(i,j), NodesC.Value(i+1,j),
2476 NodesC.Value(i+1,j+1), NodesC.Value(i,j+1));
2477 if (F) meshDS->SetMeshElementOnShape(F, geomFaceID);
2481 } // end Multiple Reduce implementation
2482 else { // Simple Reduce (!MultipleReduce)
2483 //=========================================================
2486 // it is a base case => not shift quad
2487 //ShiftQuad(quad,0,true);
2490 // we have to shift quad on 2
2491 ShiftQuad(quad,2,true);
2496 // we have to shift quad on 1
2497 ShiftQuad(quad,1,true);
2500 // we have to shift quad on 3
2501 ShiftQuad(quad,3,true);
2505 nb = quad->side[0]->NbPoints();
2506 nr = quad->side[1]->NbPoints();
2507 nt = quad->side[2]->NbPoints();
2508 nl = quad->side[3]->NbPoints();
2510 // number of rows and columns
2511 int nrows = nr - 1; // and also == nl - 1
2512 int ncol_top = nt - 1;
2513 int ncol_bot = nb - 1;
2514 int npair_top = ncol_top / 2;
2515 // maximum number of bottom elements for "linear" simple reduce
2516 int max_lin = ncol_top + npair_top * 2 * nrows;
2517 // maximum number of bottom elements for "tree" simple reduce
2518 //int max_tree = npair_top * pow(2, nrows + 1);
2520 //if (ncol_bot > max_tree)
2521 // MultipleReduce = true;
2523 const vector<UVPtStruct>& uv_eb = quad->side[0]->GetUVPtStruct(true,0);
2524 const vector<UVPtStruct>& uv_er = quad->side[1]->GetUVPtStruct(false,1);
2525 const vector<UVPtStruct>& uv_et = quad->side[2]->GetUVPtStruct(true,1);
2526 const vector<UVPtStruct>& uv_el = quad->side[3]->GetUVPtStruct(false,0);
2528 if (uv_eb.size() != nb || uv_er.size() != nr || uv_et.size() != nt || uv_el.size() != nl)
2529 return error(COMPERR_BAD_INPUT_MESH);
2531 // arrays for normalized params
2532 TColStd_SequenceOfReal npb, npr, npt, npl;
2533 for (j = 0; j < nb; j++) {
2534 npb.Append(uv_eb[j].normParam);
2536 for (i = 0; i < nr; i++) {
2537 npr.Append(uv_er[i].normParam);
2539 for (j = 0; j < nt; j++) {
2540 npt.Append(uv_et[j].normParam);
2542 for (i = 0; i < nl; i++) {
2543 npl.Append(uv_el[i].normParam);
2546 // We will ajust new points to this grid
2547 if (!SetNormalizedGrid(aMesh, aShape, quad))
2551 gp_XY a0 (uv_eb.front().u, uv_eb.front().v);
2552 gp_XY a1 (uv_eb.back().u, uv_eb.back().v);
2553 gp_XY a2 (uv_et.back().u, uv_et.back().v);
2554 gp_XY a3 (uv_et.front().u, uv_et.front().v);
2555 //=========================================================
2557 TColStd_SequenceOfInteger curr_base, next_base;
2558 TColStd_SequenceOfReal curr_par_u, curr_par_v;
2559 TColStd_SequenceOfReal next_par_u, next_par_v;
2560 StdMeshers_Array2OfNode NodesBRD (1,nb, 1,nr);
2561 for (j = 1; j <= nb; j++) {
2562 NodesBRD.SetValue(j, 1, uv_eb[j - 1].node); // bottom
2563 curr_base.Append(j);
2564 next_base.Append(-1);
2565 curr_par_u.Append(uv_eb[j-1].u);
2566 curr_par_v.Append(uv_eb[j-1].v);
2567 next_par_u.Append(0.);
2568 next_par_v.Append(0.);
2570 for (j = 1; j <= nt; j++) {
2571 NodesBRD.SetValue(j, nr, uv_et[j - 1].node); // top
2574 int curr_base_len = nb;
2575 int next_base_len = 0;
2577 if (ncol_bot > max_lin) {
2578 // "tree" simple reduce 2->4->8->16->32->...
2580 // .---------------.---------------.---------------.---------------. nr
2581 // | \ | / | \ | / |
2582 // | \ .-------.-------. / | \ .-------.-------. / |
2583 // | | | | | | | | |
2584 // .-------.-------.-------.-------.-------.-------.-------.-------.
2585 // |\ | /|\ | /|\ | /|\ | /|
2586 // | \.---.---./ | \.---.---./ | \.---.---./ | \.---.---./ | i
2587 // | | | | | | | | | | | | | | | | |
2588 // .---.---.---.---.---.---.---.---.---.---.---.---.---.---.---.---.
2589 // |\ | /|\ | /|\ | /|\ | /|\ | /|\ | /|\ | /|\ | /|
2590 // | .-.-. | .-.-. | .-.-. | .-.-. | .-.-. | .-.-. | .-.-. | .-.-. |
2591 // | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
2592 // .-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-. 1
2595 for (i = 1; i < nr; i++) { // layer by layer
2597 NodesBRD.SetValue(1, i+1, uv_el[i].node);
2598 next_base.SetValue(++next_base_len, 1);
2600 NodesBRD.SetValue(nb, i+1, uv_er[i].node);
2602 next_par_u.SetValue(next_base_len, uv_el[i].u);
2603 next_par_v.SetValue(next_base_len, uv_el[i].v);
2605 // to stop reducing, if number of nodes reaches nt
2606 int delta = curr_base_len - nt;
2608 //double du = uv_er[i].u - uv_el[i].u;
2609 //double dv = uv_er[i].v - uv_el[i].v;
2611 // to calculate normalized parameter, we must know number of points in next layer
2612 int nb_four = (curr_base_len - 1) / 4;
2613 int nb_next = nb_four*2 + (curr_base_len - nb_four*4);
2614 if (nb_next < nt) nb_next = nt;
2616 for (j = 1; j + 4 <= curr_base_len && delta > 0; j += 4, delta -= 2) {
2617 // add one "HH": nodes a,b,c,d,e and faces 1,2,3,4,5,6
2619 // .-----a-----b i + 1
2632 const SMDS_MeshNode* Na;
2634 next_base.SetValue(next_base_len, curr_base.Value(j + 2));
2635 if (i + 1 == nr) { // top
2636 Na = uv_et[next_base_len - 1].node;
2637 NodesBRD.SetValue(next_base.Value(next_base_len), i + 1, Na);
2638 u = uv_et[next_base_len - 1].u;
2639 v = uv_et[next_base_len - 1].v;
2642 //double norm_par = double(next_base_len - 1)/double(nb_next - 1);
2643 //u = uv_el[i].u + du * norm_par;
2644 //v = uv_el[i].v + dv * norm_par;
2646 double rel = double(next_base_len - 1) * double(nt - 1) / double(nb_next - 1) + 1;
2647 int nearest_node_j = (int)rel;
2648 rel -= nearest_node_j;
2649 int ij = (i + 1 - 1) * nt + (nearest_node_j - 1);
2650 double u1 = quad->uv_grid[ij].u;
2651 double v1 = quad->uv_grid[ij].v;
2652 double u2 = quad->uv_grid[ij + 1].u;
2653 double v2 = quad->uv_grid[ij + 1].v;
2654 double duj = (u2 - u1) * rel;
2655 double dvj = (v2 - v1) * rel;
2659 //u = uv_el[i].u + du*npb.Value(curr_base.Value(j + 2));
2660 //v = uv_el[i].v + dv*npb.Value(curr_base.Value(j + 2));
2661 gp_Pnt P = S->Value(u,v);
2662 SMDS_MeshNode* Na1 = meshDS->AddNode(P.X(), P.Y(), P.Z());
2663 meshDS->SetNodeOnFace(Na1, geomFaceID, u, v);
2664 NodesBRD.SetValue(next_base.Value(next_base_len), i + 1, Na1);
2667 next_par_u.SetValue(next_base_len, u);
2668 next_par_v.SetValue(next_base_len, v);
2671 const SMDS_MeshNode* Nb;
2673 next_base.SetValue(next_base_len, curr_base.Value(j + 4));
2674 if (i + 1 == nr) { // top
2675 Nb = uv_et[next_base_len - 1].node;
2676 NodesBRD.SetValue(next_base.Value(next_base_len), i + 1, Nb);
2677 u = uv_et[next_base_len - 1].u;
2678 v = uv_et[next_base_len - 1].v;
2680 else if (j + 4 == curr_base_len) { // right
2681 Nb = NodesBRD.Value(next_base.Value(next_base_len), i + 1);
2686 //double norm_par = double(next_base_len - 1)/double(nb_next - 1);
2687 //u = uv_el[i].u + du * norm_par;
2688 //v = uv_el[i].v + dv * norm_par;
2690 double rel = double(next_base_len - 1) * double(nt - 1) / double(nb_next - 1) + 1;
2691 int nearest_node_j = (int)rel;
2692 rel -= nearest_node_j;
2693 int ij = (i + 1 - 1) * nt + (nearest_node_j - 1);
2694 double u1 = quad->uv_grid[ij].u;
2695 double v1 = quad->uv_grid[ij].v;
2696 double u2 = quad->uv_grid[ij + 1].u;
2697 double v2 = quad->uv_grid[ij + 1].v;
2698 double duj = (u2 - u1) * rel;
2699 double dvj = (v2 - v1) * rel;
2703 //u = uv_el[i].u + du*npb.Value(curr_base.Value(j + 4));
2704 //v = uv_el[i].v + dv*npb.Value(curr_base.Value(j + 4));
2705 gp_Pnt P = S->Value(u,v);
2706 SMDS_MeshNode* Nb1 = meshDS->AddNode(P.X(), P.Y(), P.Z());
2707 meshDS->SetNodeOnFace(Nb1, geomFaceID, u, v);
2708 NodesBRD.SetValue(next_base.Value(next_base_len), i + 1, Nb1);
2711 next_par_u.SetValue(next_base_len, u);
2712 next_par_v.SetValue(next_base_len, v);
2715 u = (curr_par_u.Value(j + 2) + next_par_u.Value(next_base_len - 2)) / 2.0;
2716 v = (curr_par_v.Value(j + 2) + next_par_v.Value(next_base_len - 2)) / 2.0;
2717 gp_Pnt P = S->Value(u,v);
2718 SMDS_MeshNode* Nc = meshDS->AddNode(P.X(), P.Y(), P.Z());
2719 meshDS->SetNodeOnFace(Nc, geomFaceID, u, v);
2722 u = (curr_par_u.Value(j + 2) + next_par_u.Value(next_base_len - 1)) / 2.0;
2723 v = (curr_par_v.Value(j + 2) + next_par_v.Value(next_base_len - 1)) / 2.0;
2725 SMDS_MeshNode* Nd = meshDS->AddNode(P.X(), P.Y(), P.Z());
2726 meshDS->SetNodeOnFace(Nd, geomFaceID, u, v);
2729 u = (curr_par_u.Value(j + 2) + next_par_u.Value(next_base_len)) / 2.0;
2730 v = (curr_par_v.Value(j + 2) + next_par_v.Value(next_base_len)) / 2.0;
2732 SMDS_MeshNode* Ne = meshDS->AddNode(P.X(), P.Y(), P.Z());
2733 meshDS->SetNodeOnFace(Ne, geomFaceID, u, v);
2736 SMDS_MeshFace* F1 = myTool->AddFace(NodesBRD.Value(curr_base.Value(j + 0), i),
2737 NodesBRD.Value(curr_base.Value(j + 1), i),
2739 NodesBRD.Value(next_base.Value(next_base_len - 2), i + 1));
2740 if (F1) meshDS->SetMeshElementOnShape(F1, geomFaceID);
2742 SMDS_MeshFace* F2 = myTool->AddFace(NodesBRD.Value(curr_base.Value(j + 1), i),
2743 NodesBRD.Value(curr_base.Value(j + 2), i),
2745 if (F2) meshDS->SetMeshElementOnShape(F2, geomFaceID);
2747 SMDS_MeshFace* F3 = myTool->AddFace(NodesBRD.Value(curr_base.Value(j + 2), i),
2748 NodesBRD.Value(curr_base.Value(j + 3), i),
2750 if (F3) meshDS->SetMeshElementOnShape(F3, geomFaceID);
2752 SMDS_MeshFace* F4 = myTool->AddFace(NodesBRD.Value(curr_base.Value(j + 3), i),
2753 NodesBRD.Value(curr_base.Value(j + 4), i),
2755 if (F4) meshDS->SetMeshElementOnShape(F4, geomFaceID);
2757 SMDS_MeshFace* F5 = myTool->AddFace(Nc, Nd, Na,
2758 NodesBRD.Value(next_base.Value(next_base_len - 2), i + 1));
2759 if (F5) meshDS->SetMeshElementOnShape(F5, geomFaceID);
2761 SMDS_MeshFace* F6 = myTool->AddFace(Nd, Ne, Nb, Na);
2762 if (F6) meshDS->SetMeshElementOnShape(F6, geomFaceID);
2765 // not reduced side elements (if any)
2766 for (; j < curr_base_len; j++) {
2768 const SMDS_MeshNode* Nf;
2770 next_base.SetValue(++next_base_len, curr_base.Value(j + 1));
2771 if (i + 1 == nr) { // top
2772 Nf = uv_et[next_base_len - 1].node;
2773 NodesBRD.SetValue(next_base.Value(next_base_len), i + 1, Nf);
2774 u = uv_et[next_base_len - 1].u;
2775 v = uv_et[next_base_len - 1].v;
2777 else if (j + 1 == curr_base_len) { // right
2778 Nf = NodesBRD.Value(next_base.Value(next_base_len), i + 1);
2783 //double norm_par = double(next_base_len - 1)/double(nb_next - 1);
2784 //u = uv_el[i].u + du * norm_par;
2785 //v = uv_el[i].v + dv * norm_par;
2787 double rel = double(next_base_len - 1) * double(nt - 1) / double(nb_next - 1) + 1;
2788 int nearest_node_j = (int)rel;
2789 rel -= nearest_node_j;
2790 int ij = (i + 1 - 1) * nt + (nearest_node_j - 1);
2791 double u1 = quad->uv_grid[ij].u;
2792 double v1 = quad->uv_grid[ij].v;
2793 double u2 = quad->uv_grid[ij + 1].u;
2794 double v2 = quad->uv_grid[ij + 1].v;
2795 double duj = (u2 - u1) * rel;
2796 double dvj = (v2 - v1) * rel;
2800 //u = uv_el[i].u + du*npb.Value(curr_base.Value(j + 1));
2801 //v = uv_el[i].v + dv*npb.Value(curr_base.Value(j + 1));
2802 gp_Pnt P = S->Value(u,v);
2803 SMDS_MeshNode* Nf1 = meshDS->AddNode(P.X(), P.Y(), P.Z());
2804 meshDS->SetNodeOnFace(Nf1, geomFaceID, u, v);
2805 NodesBRD.SetValue(next_base.Value(next_base_len), i + 1, Nf1);
2808 next_par_u.SetValue(next_base_len, u);
2809 next_par_v.SetValue(next_base_len, v);
2810 SMDS_MeshFace* F1 = myTool->AddFace(NodesBRD.Value(curr_base.Value(j), i),
2811 NodesBRD.Value(curr_base.Value(j + 1), i),
2812 NodesBRD.Value(next_base.Value(next_base_len), i + 1),
2813 NodesBRD.Value(next_base.Value(next_base_len - 1), i + 1));
2814 if (F1) meshDS->SetMeshElementOnShape(F1, geomFaceID);
2817 curr_base_len = next_base_len;
2818 curr_base = next_base;
2819 curr_par_u = next_par_u;
2820 curr_par_v = next_par_v;
2823 } // end "tree" simple reduce
2825 // "linear" simple reduce 4->8->12->16 (3 steps)
2827 // .---------------.---------------.---------------.---------------. nr
2828 // | \ | / | \ | / |
2829 // | \ .-------.-------. / | \ .-------.-------. / |
2830 // | | | | | | | | |
2831 // .-------.-------.-------.-------.-------.-------.-------.-------.
2832 // | / \ | / \ | / \ | / \ |
2833 // | / \.----.----./ \ | / \.----.----./ \ | i
2834 // | / | | | \ | / | | | \ |
2835 // .-----.----.----.----.----.-----.-----.----.----.----.----.-----.
2836 // | / / \ | / \ \ | / / \ | / \ \ |
2837 // | / / .-.-. \ \ | / / .-.-. \ \ |
2838 // | / / / | \ \ \ | / / / | \ \ \ |
2839 // .---.---.---.---.---.---.---.---.---.---.---.---.---.---.---.---. 1
2842 // nt = 5, nb = 7, nr = 4
2843 //int delta_all = 2;
2844 //int delta_one_col = 6;
2846 //int remainder = 2;
2847 //if (remainder > 0) nb_col++;
2849 //int free_left = 1;
2851 //int free_middle = 4;
2853 int delta_all = nb - nt;
2854 int delta_one_col = (nr - 1) * 2;
2855 int nb_col = delta_all / delta_one_col;
2856 int remainder = delta_all - nb_col * delta_one_col;
2857 if (remainder > 0) {
2860 int free_left = ((nt - 1) - nb_col * 2) / 2;
2861 free_left += nr - 2;
2862 int free_middle = (nr - 2) * 2;
2863 if (remainder > 0 && nb_col == 1) {
2864 int nb_rows_short_col = remainder / 2;
2865 int nb_rows_thrown = (nr - 1) - nb_rows_short_col;
2866 free_left -= nb_rows_thrown;
2869 // nt = 5, nb = 17, nr = 4
2870 //int delta_all = 12;
2871 //int delta_one_col = 6;
2873 //int remainder = 0;
2874 //int free_left = 2;
2875 //int free_middle = 4;
2877 for (i = 1; i < nr; i++, free_middle -= 2, free_left -= 1) { // layer by layer
2879 NodesBRD.SetValue(1, i+1, uv_el[i].node);
2880 next_base.SetValue(++next_base_len, 1);
2882 NodesBRD.SetValue(nb, i+1, uv_er[i].node);
2885 next_par_u.SetValue(next_base_len, uv_el[i].u);
2886 next_par_v.SetValue(next_base_len, uv_el[i].v);
2888 // to calculate normalized parameter, we must know number of points in next layer
2889 int nb_next = curr_base_len - nb_col * 2;
2890 if (remainder > 0 && i > remainder / 2)
2891 // take into account short "column"
2893 if (nb_next < nt) nb_next = nt;
2895 // not reduced left elements
2896 for (j = 1; j <= free_left; j++) {
2898 const SMDS_MeshNode* Nf;
2900 next_base.SetValue(++next_base_len, curr_base.Value(j + 1));
2901 if (i + 1 == nr) { // top
2902 Nf = uv_et[next_base_len - 1].node;
2903 NodesBRD.SetValue(next_base.Value(next_base_len), i + 1, Nf);
2904 u = uv_et[next_base_len - 1].u;
2905 v = uv_et[next_base_len - 1].v;
2909 double rel = double(next_base_len - 1) * double(nt - 1) / double(nb_next - 1) + 1;
2910 int nearest_node_j = (int)rel;
2911 rel -= nearest_node_j;
2912 int ij = (i + 1 - 1) * nt + (nearest_node_j - 1);
2913 double u1 = quad->uv_grid[ij].u;
2914 double v1 = quad->uv_grid[ij].v;
2915 double u2 = quad->uv_grid[ij + 1].u;
2916 double v2 = quad->uv_grid[ij + 1].v;
2917 double duj = (u2 - u1) * rel;
2918 double dvj = (v2 - v1) * rel;
2922 gp_Pnt P = S->Value(u,v);
2923 SMDS_MeshNode* Nf1 = meshDS->AddNode(P.X(), P.Y(), P.Z());
2924 meshDS->SetNodeOnFace(Nf1, geomFaceID, u, v);
2925 NodesBRD.SetValue(next_base.Value(next_base_len), i + 1, Nf1);
2928 next_par_u.SetValue(next_base_len, u);
2929 next_par_v.SetValue(next_base_len, v);
2930 SMDS_MeshFace* F1 = myTool->AddFace(NodesBRD.Value(curr_base.Value(j), i),
2931 NodesBRD.Value(curr_base.Value(j + 1), i),
2932 NodesBRD.Value(next_base.Value(next_base_len), i + 1),
2933 NodesBRD.Value(next_base.Value(next_base_len - 1), i + 1));
2934 if (F1) meshDS->SetMeshElementOnShape(F1, geomFaceID);
2937 for (int icol = 1; icol <= nb_col; icol++) {
2939 if (remainder > 0 && icol == nb_col && i > remainder / 2)
2940 // stop short "column"
2943 // add one "HH": nodes a,b,c,d,e and faces 1,2,3,4,5,6
2945 // .-----a-----b i + 1
2958 const SMDS_MeshNode* Na;
2960 next_base.SetValue(next_base_len, curr_base.Value(j + 2));
2961 if (i + 1 == nr) { // top
2962 Na = uv_et[next_base_len - 1].node;
2963 NodesBRD.SetValue(next_base.Value(next_base_len), i + 1, Na);
2964 u = uv_et[next_base_len - 1].u;
2965 v = uv_et[next_base_len - 1].v;
2969 double rel = double(next_base_len - 1) * double(nt - 1) / double(nb_next - 1) + 1;
2970 int nearest_node_j = (int)rel;
2971 rel -= nearest_node_j;
2972 int ij = (i + 1 - 1) * nt + (nearest_node_j - 1);
2973 double u1 = quad->uv_grid[ij].u;
2974 double v1 = quad->uv_grid[ij].v;
2975 double u2 = quad->uv_grid[ij + 1].u;
2976 double v2 = quad->uv_grid[ij + 1].v;
2977 double duj = (u2 - u1) * rel;
2978 double dvj = (v2 - v1) * rel;
2982 gp_Pnt P = S->Value(u,v);
2983 SMDS_MeshNode* Na1 = meshDS->AddNode(P.X(), P.Y(), P.Z());
2984 meshDS->SetNodeOnFace(Na1, geomFaceID, u, v);
2985 NodesBRD.SetValue(next_base.Value(next_base_len), i + 1, Na1);
2988 next_par_u.SetValue(next_base_len, u);
2989 next_par_v.SetValue(next_base_len, v);
2992 const SMDS_MeshNode* Nb;
2994 next_base.SetValue(next_base_len, curr_base.Value(j + 4));
2995 if (i + 1 == nr) { // top
2996 Nb = uv_et[next_base_len - 1].node;
2997 NodesBRD.SetValue(next_base.Value(next_base_len), i + 1, Nb);
2998 u = uv_et[next_base_len - 1].u;
2999 v = uv_et[next_base_len - 1].v;
3001 else if (j + 4 == curr_base_len) { // right
3002 Nb = NodesBRD.Value(next_base.Value(next_base_len), i + 1);
3008 double rel = double(next_base_len - 1) * double(nt - 1) / double(nb_next - 1) + 1;
3009 int nearest_node_j = (int)rel;
3010 rel -= nearest_node_j;
3011 int ij = (i + 1 - 1) * nt + (nearest_node_j - 1);
3012 double u1 = quad->uv_grid[ij].u;
3013 double v1 = quad->uv_grid[ij].v;
3014 double u2 = quad->uv_grid[ij + 1].u;
3015 double v2 = quad->uv_grid[ij + 1].v;
3016 double duj = (u2 - u1) * rel;
3017 double dvj = (v2 - v1) * rel;
3021 gp_Pnt P = S->Value(u,v);
3022 SMDS_MeshNode* Nb1 = meshDS->AddNode(P.X(), P.Y(), P.Z());
3023 meshDS->SetNodeOnFace(Nb1, geomFaceID, u, v);
3024 NodesBRD.SetValue(next_base.Value(next_base_len), i + 1, Nb1);
3027 next_par_u.SetValue(next_base_len, u);
3028 next_par_v.SetValue(next_base_len, v);
3031 u = (curr_par_u.Value(j + 2) + next_par_u.Value(next_base_len - 2)) / 2.0;
3032 v = (curr_par_v.Value(j + 2) + next_par_v.Value(next_base_len - 2)) / 2.0;
3033 gp_Pnt P = S->Value(u,v);
3034 SMDS_MeshNode* Nc = meshDS->AddNode(P.X(), P.Y(), P.Z());
3035 meshDS->SetNodeOnFace(Nc, geomFaceID, u, v);
3038 u = (curr_par_u.Value(j + 2) + next_par_u.Value(next_base_len - 1)) / 2.0;
3039 v = (curr_par_v.Value(j + 2) + next_par_v.Value(next_base_len - 1)) / 2.0;
3041 SMDS_MeshNode* Nd = meshDS->AddNode(P.X(), P.Y(), P.Z());
3042 meshDS->SetNodeOnFace(Nd, geomFaceID, u, v);
3045 u = (curr_par_u.Value(j + 2) + next_par_u.Value(next_base_len)) / 2.0;
3046 v = (curr_par_v.Value(j + 2) + next_par_v.Value(next_base_len)) / 2.0;
3048 SMDS_MeshNode* Ne = meshDS->AddNode(P.X(), P.Y(), P.Z());
3049 meshDS->SetNodeOnFace(Ne, geomFaceID, u, v);
3052 SMDS_MeshFace* F1 = myTool->AddFace(NodesBRD.Value(curr_base.Value(j + 0), i),
3053 NodesBRD.Value(curr_base.Value(j + 1), i),
3055 NodesBRD.Value(next_base.Value(next_base_len - 2), i + 1));
3056 if (F1) meshDS->SetMeshElementOnShape(F1, geomFaceID);
3058 SMDS_MeshFace* F2 = myTool->AddFace(NodesBRD.Value(curr_base.Value(j + 1), i),
3059 NodesBRD.Value(curr_base.Value(j + 2), i),
3061 if (F2) meshDS->SetMeshElementOnShape(F2, geomFaceID);
3063 SMDS_MeshFace* F3 = myTool->AddFace(NodesBRD.Value(curr_base.Value(j + 2), i),
3064 NodesBRD.Value(curr_base.Value(j + 3), i),
3066 if (F3) meshDS->SetMeshElementOnShape(F3, geomFaceID);
3068 SMDS_MeshFace* F4 = myTool->AddFace(NodesBRD.Value(curr_base.Value(j + 3), i),
3069 NodesBRD.Value(curr_base.Value(j + 4), i),
3071 if (F4) meshDS->SetMeshElementOnShape(F4, geomFaceID);
3073 SMDS_MeshFace* F5 = myTool->AddFace(Nc, Nd, Na,
3074 NodesBRD.Value(next_base.Value(next_base_len - 2), i + 1));
3075 if (F5) meshDS->SetMeshElementOnShape(F5, geomFaceID);
3077 SMDS_MeshFace* F6 = myTool->AddFace(Nd, Ne, Nb, Na);
3078 if (F6) meshDS->SetMeshElementOnShape(F6, geomFaceID);
3082 // not reduced middle elements
3083 if (icol < nb_col) {
3084 if (remainder > 0 && icol == nb_col - 1 && i > remainder / 2)
3085 // pass middle elements before stopped short "column"
3088 int free_add = free_middle;
3089 if (remainder > 0 && icol == nb_col - 1)
3090 // next "column" is short
3091 free_add -= (nr - 1) - (remainder / 2);
3093 for (int imiddle = 1; imiddle <= free_add; imiddle++) {
3094 // f (i + 1, j + imiddle)
3095 const SMDS_MeshNode* Nf;
3097 next_base.SetValue(++next_base_len, curr_base.Value(j + imiddle));
3098 if (i + 1 == nr) { // top
3099 Nf = uv_et[next_base_len - 1].node;
3100 NodesBRD.SetValue(next_base.Value(next_base_len), i + 1, Nf);
3101 u = uv_et[next_base_len - 1].u;
3102 v = uv_et[next_base_len - 1].v;
3104 else if (j + imiddle == curr_base_len) { // right
3105 Nf = NodesBRD.Value(next_base.Value(next_base_len), i + 1);
3111 double rel = double(next_base_len - 1) * double(nt - 1) / double(nb_next - 1) + 1;
3112 int nearest_node_j = (int)rel;
3113 rel -= nearest_node_j;
3114 int ij = (i + 1 - 1) * nt + (nearest_node_j - 1);
3115 double u1 = quad->uv_grid[ij].u;
3116 double v1 = quad->uv_grid[ij].v;
3117 double u2 = quad->uv_grid[ij + 1].u;
3118 double v2 = quad->uv_grid[ij + 1].v;
3119 double duj = (u2 - u1) * rel;
3120 double dvj = (v2 - v1) * rel;
3124 gp_Pnt P = S->Value(u,v);
3125 SMDS_MeshNode* Nf1 = meshDS->AddNode(P.X(), P.Y(), P.Z());
3126 meshDS->SetNodeOnFace(Nf1, geomFaceID, u, v);
3127 NodesBRD.SetValue(next_base.Value(next_base_len), i + 1, Nf1);
3130 next_par_u.SetValue(next_base_len, u);
3131 next_par_v.SetValue(next_base_len, v);
3132 SMDS_MeshFace* F1 = myTool->AddFace(NodesBRD.Value(curr_base.Value(j - 1 + imiddle), i),
3133 NodesBRD.Value(curr_base.Value(j + imiddle), i),
3134 NodesBRD.Value(next_base.Value(next_base_len), i + 1),
3135 NodesBRD.Value(next_base.Value(next_base_len - 1), i + 1));
3136 if (F1) meshDS->SetMeshElementOnShape(F1, geomFaceID);
3142 // not reduced right elements
3143 for (; j < curr_base_len; j++) {
3145 const SMDS_MeshNode* Nf;
3147 next_base.SetValue(++next_base_len, curr_base.Value(j + 1));
3148 if (i + 1 == nr) { // top
3149 Nf = uv_et[next_base_len - 1].node;
3150 NodesBRD.SetValue(next_base.Value(next_base_len), i + 1, Nf);
3151 u = uv_et[next_base_len - 1].u;
3152 v = uv_et[next_base_len - 1].v;
3154 else if (j + 1 == curr_base_len) { // right
3155 Nf = NodesBRD.Value(next_base.Value(next_base_len), i + 1);
3161 double rel = double(next_base_len - 1) * double(nt - 1) / double(nb_next - 1) + 1;
3162 int nearest_node_j = (int)rel;
3163 rel -= nearest_node_j;
3164 int ij = (i + 1 - 1) * nt + (nearest_node_j - 1);
3165 double u1 = quad->uv_grid[ij].u;
3166 double v1 = quad->uv_grid[ij].v;
3167 double u2 = quad->uv_grid[ij + 1].u;
3168 double v2 = quad->uv_grid[ij + 1].v;
3169 double duj = (u2 - u1) * rel;
3170 double dvj = (v2 - v1) * rel;
3174 gp_Pnt P = S->Value(u,v);
3175 SMDS_MeshNode* Nf1 = meshDS->AddNode(P.X(), P.Y(), P.Z());
3176 meshDS->SetNodeOnFace(Nf1, geomFaceID, u, v);
3177 NodesBRD.SetValue(next_base.Value(next_base_len), i + 1, Nf1);
3180 next_par_u.SetValue(next_base_len, u);
3181 next_par_v.SetValue(next_base_len, v);
3182 SMDS_MeshFace* F1 = myTool->AddFace(NodesBRD.Value(curr_base.Value(j), i),
3183 NodesBRD.Value(curr_base.Value(j + 1), i),
3184 NodesBRD.Value(next_base.Value(next_base_len), i + 1),
3185 NodesBRD.Value(next_base.Value(next_base_len - 1), i + 1));
3186 if (F1) meshDS->SetMeshElementOnShape(F1, geomFaceID);
3189 curr_base_len = next_base_len;
3190 curr_base = next_base;
3191 curr_par_u = next_par_u;
3192 curr_par_v = next_par_v;
3195 } // end "linear" simple reduce
3196 } // end Simple Reduce implementation