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());
797 list< TopoDS_Edge >::iterator edgeIt = edges.begin();
798 if (nbEdgesInWire.front() == 3) // exactly 3 edges
800 SMESH_Comment comment;
801 SMESHDS_Mesh* meshDS = aMesh.GetMeshDS();
802 if (myTriaVertexID == -1)
804 comment << "No Base vertex parameter provided for a trilateral geometrical face";
808 TopoDS_Vertex V = TopoDS::Vertex(meshDS->IndexToShape(myTriaVertexID));
810 TopoDS_Edge E1,E2,E3;
811 for (; edgeIt != edges.end(); ++edgeIt) {
812 TopoDS_Edge E = *edgeIt;
813 TopoDS_Vertex VF, VL;
814 TopExp::Vertices(E, VF, VL, true);
817 else if (VL.IsSame(V))
822 if (!E1.IsNull() && !E2.IsNull() && !E3.IsNull())
824 quad->side.push_back(new StdMeshers_FaceSide(F, E1, &aMesh, true, ignoreMediumNodes));
825 quad->side.push_back(new StdMeshers_FaceSide(F, E2, &aMesh, true, ignoreMediumNodes));
826 quad->side.push_back(new StdMeshers_FaceSide(F, E3, &aMesh, false,ignoreMediumNodes));
827 const vector<UVPtStruct>& UVPSleft = quad->side[0]->GetUVPtStruct(true,0);
828 /* vector<UVPtStruct>& UVPStop = */quad->side[1]->GetUVPtStruct(false,1);
829 /* vector<UVPtStruct>& UVPSright = */quad->side[2]->GetUVPtStruct(true,1);
830 const SMDS_MeshNode* aNode = UVPSleft[0].node;
831 gp_Pnt2d aPnt2d(UVPSleft[0].u, UVPSleft[0].v);
832 quad->side.push_back(new StdMeshers_FaceSide(aNode, aPnt2d, quad->side[1]));
836 comment << "Invalid Base vertex parameter: " << myTriaVertexID << " is not among [";
837 TopTools_MapOfShape vMap;
838 for (TopExp_Explorer v(aShape, TopAbs_VERTEX); v.More(); v.Next())
839 if (vMap.Add(v.Current()))
840 comment << meshDS->ShapeToIndex(v.Current()) << (vMap.Extent()==3 ? "]" : ", ");
846 else if (nbEdgesInWire.front() == 4) { // exactly 4 edges
847 for (; edgeIt != edges.end(); ++edgeIt, nbSides++)
848 quad->side.push_back(new StdMeshers_FaceSide(F, *edgeIt, &aMesh,
849 nbSides<TOP_SIDE, ignoreMediumNodes));
851 else if (nbEdgesInWire.front() > 4) { // more than 4 edges - try to unite some
852 list< TopoDS_Edge > sideEdges;
853 while (!edges.empty()) {
855 sideEdges.splice(sideEdges.end(), edges, edges.begin()); // edges.front() -> sideEdges.end()
856 bool sameSide = true;
857 while (!edges.empty() && sameSide) {
858 sameSide = SMESH_Algo::IsContinuous(sideEdges.back(), edges.front());
860 sideEdges.splice(sideEdges.end(), edges, edges.begin());
862 if (nbSides == 0) { // go backward from the first edge
864 while (!edges.empty() && sameSide) {
865 sameSide = SMESH_Algo::IsContinuous(sideEdges.front(), edges.back());
867 sideEdges.splice(sideEdges.begin(), edges, --edges.end());
870 quad->side.push_back(new StdMeshers_FaceSide(F, sideEdges, &aMesh,
871 nbSides<TOP_SIDE, ignoreMediumNodes));
874 // issue 20222. Try to unite only edges shared by two same faces
876 // delete found sides
877 { FaceQuadStruct cleaner(*quad); }
879 quad->side.reserve(nbEdgesInWire.front());
882 SMESH_Block::GetOrderedEdges (F, V, edges, nbEdgesInWire);
883 while (!edges.empty()) {
885 sideEdges.splice(sideEdges.end(), edges, edges.begin());
886 bool sameSide = true;
887 while (!edges.empty() && sameSide) {
889 SMESH_Algo::IsContinuous(sideEdges.back(), edges.front()) &&
890 twoEdgesMeatAtVertex(sideEdges.back(), edges.front(), aMesh);
892 sideEdges.splice(sideEdges.end(), edges, edges.begin());
894 if (nbSides == 0) { // go backward from the first edge
896 while (!edges.empty() && sameSide) {
898 SMESH_Algo::IsContinuous(sideEdges.front(), edges.back()) &&
899 twoEdgesMeatAtVertex(sideEdges.front(), edges.back(), aMesh);
901 sideEdges.splice(sideEdges.begin(), edges, --edges.end());
904 quad->side.push_back(new StdMeshers_FaceSide(F, sideEdges, &aMesh,
905 nbSides<TOP_SIDE, ignoreMediumNodes));
912 MESSAGE ("StdMeshers_Quadrangle_2D. Edge IDs of " << nbSides << " sides:\n");
913 for (int i = 0; i < nbSides; ++i) {
915 for (int e = 0; e < quad->side[i]->NbEdges(); ++e)
916 MESSAGE (myTool->GetMeshDS()->ShapeToIndex(quad->side[i]->Edge(e)) << " ");
922 nbSides = nbEdgesInWire.front();
923 error(COMPERR_BAD_SHAPE, TComm("Face must have 4 sides but not ") << nbSides);
932 //=============================================================================
936 //=============================================================================
938 bool StdMeshers_Quadrangle_2D::CheckNbEdgesForEvaluate(SMESH_Mesh& aMesh,
939 const TopoDS_Shape & aShape,
940 MapShapeNbElems& aResMap,
941 std::vector<int>& aNbNodes,
945 const TopoDS_Face & F = TopoDS::Face(aShape);
947 // verify 1 wire only, with 4 edges
949 list< TopoDS_Edge > edges;
950 list< int > nbEdgesInWire;
951 int nbWire = SMESH_Block::GetOrderedEdges (F, V, edges, nbEdgesInWire);
959 list< TopoDS_Edge >::iterator edgeIt = edges.begin();
960 SMESH_subMesh * sm = aMesh.GetSubMesh(*edgeIt);
961 MapShapeNbElemsItr anIt = aResMap.find(sm);
962 if (anIt==aResMap.end()) {
965 std::vector<int> aVec = (*anIt).second;
966 IsQuadratic = (aVec[SMDSEntity_Quad_Edge] > aVec[SMDSEntity_Edge]);
967 if (nbEdgesInWire.front() == 3) { // exactly 3 edges
968 if (myTriaVertexID>0) {
969 SMESHDS_Mesh* meshDS = aMesh.GetMeshDS();
970 TopoDS_Vertex V = TopoDS::Vertex(meshDS->IndexToShape(myTriaVertexID));
972 TopoDS_Edge E1,E2,E3;
973 for (; edgeIt != edges.end(); ++edgeIt) {
974 TopoDS_Edge E = TopoDS::Edge(*edgeIt);
975 TopoDS_Vertex VF, VL;
976 TopExp::Vertices(E, VF, VL, true);
979 else if (VL.IsSame(V))
984 SMESH_subMesh * sm = aMesh.GetSubMesh(E1);
985 MapShapeNbElemsItr anIt = aResMap.find(sm);
986 if (anIt==aResMap.end()) return false;
987 std::vector<int> aVec = (*anIt).second;
989 aNbNodes[0] = (aVec[SMDSEntity_Node]-1)/2 + 2;
991 aNbNodes[0] = aVec[SMDSEntity_Node] + 2;
992 sm = aMesh.GetSubMesh(E2);
993 anIt = aResMap.find(sm);
994 if (anIt==aResMap.end()) return false;
995 aVec = (*anIt).second;
997 aNbNodes[1] = (aVec[SMDSEntity_Node]-1)/2 + 2;
999 aNbNodes[1] = aVec[SMDSEntity_Node] + 2;
1000 sm = aMesh.GetSubMesh(E3);
1001 anIt = aResMap.find(sm);
1002 if (anIt==aResMap.end()) return false;
1003 aVec = (*anIt).second;
1005 aNbNodes[2] = (aVec[SMDSEntity_Node]-1)/2 + 2;
1007 aNbNodes[2] = aVec[SMDSEntity_Node] + 2;
1008 aNbNodes[3] = aNbNodes[1];
1014 if (nbEdgesInWire.front() == 4) { // exactly 4 edges
1015 for (; edgeIt != edges.end(); edgeIt++) {
1016 SMESH_subMesh * sm = aMesh.GetSubMesh(*edgeIt);
1017 MapShapeNbElemsItr anIt = aResMap.find(sm);
1018 if (anIt==aResMap.end()) {
1021 std::vector<int> aVec = (*anIt).second;
1023 aNbNodes[nbSides] = (aVec[SMDSEntity_Node]-1)/2 + 2;
1025 aNbNodes[nbSides] = aVec[SMDSEntity_Node] + 2;
1029 else if (nbEdgesInWire.front() > 4) { // more than 4 edges - try to unite some
1030 list< TopoDS_Edge > sideEdges;
1031 while (!edges.empty()) {
1033 sideEdges.splice(sideEdges.end(), edges, edges.begin()); // edges.front() -> sideEdges.end()
1034 bool sameSide = true;
1035 while (!edges.empty() && sameSide) {
1036 sameSide = SMESH_Algo::IsContinuous(sideEdges.back(), edges.front());
1038 sideEdges.splice(sideEdges.end(), edges, edges.begin());
1040 if (nbSides == 0) { // go backward from the first edge
1042 while (!edges.empty() && sameSide) {
1043 sameSide = SMESH_Algo::IsContinuous(sideEdges.front(), edges.back());
1045 sideEdges.splice(sideEdges.begin(), edges, --edges.end());
1048 list<TopoDS_Edge>::iterator ite = sideEdges.begin();
1049 aNbNodes[nbSides] = 1;
1050 for (; ite!=sideEdges.end(); ite++) {
1051 SMESH_subMesh * sm = aMesh.GetSubMesh(*ite);
1052 MapShapeNbElemsItr anIt = aResMap.find(sm);
1053 if (anIt==aResMap.end()) {
1056 std::vector<int> aVec = (*anIt).second;
1058 aNbNodes[nbSides] += (aVec[SMDSEntity_Node]-1)/2 + 1;
1060 aNbNodes[nbSides] += aVec[SMDSEntity_Node] + 1;
1064 // issue 20222. Try to unite only edges shared by two same faces
1067 SMESH_Block::GetOrderedEdges (F, V, edges, nbEdgesInWire);
1068 while (!edges.empty()) {
1070 sideEdges.splice(sideEdges.end(), edges, edges.begin());
1071 bool sameSide = true;
1072 while (!edges.empty() && sameSide) {
1074 SMESH_Algo::IsContinuous(sideEdges.back(), edges.front()) &&
1075 twoEdgesMeatAtVertex(sideEdges.back(), edges.front(), aMesh);
1077 sideEdges.splice(sideEdges.end(), edges, edges.begin());
1079 if (nbSides == 0) { // go backward from the first edge
1081 while (!edges.empty() && sameSide) {
1083 SMESH_Algo::IsContinuous(sideEdges.front(), edges.back()) &&
1084 twoEdgesMeatAtVertex(sideEdges.front(), edges.back(), aMesh);
1086 sideEdges.splice(sideEdges.begin(), edges, --edges.end());
1089 list<TopoDS_Edge>::iterator ite = sideEdges.begin();
1090 aNbNodes[nbSides] = 1;
1091 for (; ite!=sideEdges.end(); ite++) {
1092 SMESH_subMesh * sm = aMesh.GetSubMesh(*ite);
1093 MapShapeNbElemsItr anIt = aResMap.find(sm);
1094 if (anIt==aResMap.end()) {
1097 std::vector<int> aVec = (*anIt).second;
1099 aNbNodes[nbSides] += (aVec[SMDSEntity_Node]-1)/2 + 1;
1101 aNbNodes[nbSides] += aVec[SMDSEntity_Node] + 1;
1109 nbSides = nbEdgesInWire.front();
1110 error(COMPERR_BAD_SHAPE, TComm("Face must have 4 sides but not ") << nbSides);
1118 //=============================================================================
1122 //=============================================================================
1124 FaceQuadStruct *StdMeshers_Quadrangle_2D::CheckAnd2Dcompute
1125 (SMESH_Mesh & aMesh,
1126 const TopoDS_Shape & aShape,
1127 const bool CreateQuadratic) //throw(SALOME_Exception)
1129 _quadraticMesh = CreateQuadratic;
1131 FaceQuadStruct *quad = CheckNbEdges(aMesh, aShape);
1133 if (!quad) return 0;
1135 // set normalized grid on unit square in parametric domain
1136 bool stat = SetNormalizedGrid(aMesh, aShape, quad);
1138 if (quad) delete quad;
1145 //=============================================================================
1149 //=============================================================================
1151 faceQuadStruct::~faceQuadStruct()
1153 for (int i = 0; i < side.size(); i++) {
1154 if (side[i]) delete side[i];
1156 if (uv_grid) delete [] uv_grid;
1160 inline const vector<UVPtStruct>& GetUVPtStructIn(FaceQuadStruct* quad, int i, int nbSeg)
1162 bool isXConst = (i == BOTTOM_SIDE || i == TOP_SIDE);
1163 double constValue = (i == BOTTOM_SIDE || i == LEFT_SIDE) ? 0 : 1;
1165 quad->isEdgeOut[i] ?
1166 quad->side[i]->SimulateUVPtStruct(nbSeg,isXConst,constValue) :
1167 quad->side[i]->GetUVPtStruct(isXConst,constValue);
1169 inline gp_UV CalcUV(double x, double y,
1170 const gp_UV& a0,const gp_UV& a1,const gp_UV& a2,const gp_UV& a3,
1171 const gp_UV& p0,const gp_UV& p1,const gp_UV& p2,const gp_UV& p3)
1174 ((1 - y) * p0 + x * p1 + y * p2 + (1 - x) * p3 ) -
1175 ((1 - x) * (1 - y) * a0 + x * (1 - y) * a1 + x * y * a2 + (1 - x) * y * a3);
1179 //=============================================================================
1183 //=============================================================================
1185 bool StdMeshers_Quadrangle_2D::SetNormalizedGrid (SMESH_Mesh & aMesh,
1186 const TopoDS_Shape& aShape,
1187 FaceQuadStruct* & quad) //throw (SALOME_Exception)
1189 // Algorithme décrit dans "Génération automatique de maillages"
1190 // P.L. GEORGE, MASSON, § 6.4.1 p. 84-85
1191 // traitement dans le domaine paramétrique 2d u,v
1192 // transport - projection sur le carré unité
1194 // MESSAGE("StdMeshers_Quadrangle_2D::SetNormalizedGrid");
1195 // const TopoDS_Face& F = TopoDS::Face(aShape);
1197 // 1 --- find orientation of the 4 edges, by test on extrema
1200 // |<----north-2-------^ a3 -------------> a2
1202 // west-3 east-1 =right | |
1206 // v----south-0--------> a0 -------------> a1
1211 // 3 --- 2D normalized values on unit square [0..1][0..1]
1213 int nbhoriz = Min(quad->side[0]->NbPoints(), quad->side[2]->NbPoints());
1214 int nbvertic = Min(quad->side[1]->NbPoints(), quad->side[3]->NbPoints());
1216 quad->isEdgeOut[0] = (quad->side[0]->NbPoints() > quad->side[2]->NbPoints());
1217 quad->isEdgeOut[1] = (quad->side[1]->NbPoints() > quad->side[3]->NbPoints());
1218 quad->isEdgeOut[2] = (quad->side[2]->NbPoints() > quad->side[0]->NbPoints());
1219 quad->isEdgeOut[3] = (quad->side[3]->NbPoints() > quad->side[1]->NbPoints());
1221 UVPtStruct *uv_grid = quad->uv_grid = new UVPtStruct[nbvertic * nbhoriz];
1223 const vector<UVPtStruct>& uv_e0 = GetUVPtStructIn(quad, 0, nbhoriz - 1);
1224 const vector<UVPtStruct>& uv_e1 = GetUVPtStructIn(quad, 1, nbvertic - 1);
1225 const vector<UVPtStruct>& uv_e2 = GetUVPtStructIn(quad, 2, nbhoriz - 1);
1226 const vector<UVPtStruct>& uv_e3 = GetUVPtStructIn(quad, 3, nbvertic - 1);
1228 if (uv_e0.empty() || uv_e1.empty() || uv_e2.empty() || uv_e3.empty())
1229 //return error("Can't find nodes on sides");
1230 return error(COMPERR_BAD_INPUT_MESH);
1232 // nodes Id on "in" edges
1233 if (! quad->isEdgeOut[0]) {
1235 for (int i = 0; i < nbhoriz; i++) { // down
1236 int ij = j * nbhoriz + i;
1237 uv_grid[ij].node = uv_e0[i].node;
1240 if (! quad->isEdgeOut[1]) {
1241 int i = nbhoriz - 1;
1242 for (int j = 0; j < nbvertic; j++) { // right
1243 int ij = j * nbhoriz + i;
1244 uv_grid[ij].node = uv_e1[j].node;
1247 if (! quad->isEdgeOut[2]) {
1248 int j = nbvertic - 1;
1249 for (int i = 0; i < nbhoriz; i++) { // up
1250 int ij = j * nbhoriz + i;
1251 uv_grid[ij].node = uv_e2[i].node;
1254 if (! quad->isEdgeOut[3]) {
1256 for (int j = 0; j < nbvertic; j++) { // left
1257 int ij = j * nbhoriz + i;
1258 uv_grid[ij].node = uv_e3[j].node;
1262 // normalized 2d values on grid
1263 for (int i = 0; i < nbhoriz; i++) {
1264 for (int j = 0; j < nbvertic; j++) {
1265 int ij = j * nbhoriz + i;
1266 // --- droite i cste : x = x0 + y(x1-x0)
1267 double x0 = uv_e0[i].normParam; // bas - sud
1268 double x1 = uv_e2[i].normParam; // haut - nord
1269 // --- droite j cste : y = y0 + x(y1-y0)
1270 double y0 = uv_e3[j].normParam; // gauche-ouest
1271 double y1 = uv_e1[j].normParam; // droite - est
1272 // --- intersection : x=x0+(y0+x(y1-y0))(x1-x0)
1273 double x = (x0 + y0 * (x1 - x0)) / (1 - (y1 - y0) * (x1 - x0));
1274 double y = y0 + x * (y1 - y0);
1277 //MESSAGE("-xy-01 "<<x0<<" "<<x1<<" "<<y0<<" "<<y1);
1278 //MESSAGE("-xy-norm "<<i<<" "<<j<<" "<<x<<" "<<y);
1282 // 4 --- projection on 2d domain (u,v)
1283 gp_UV a0(uv_e0.front().u, uv_e0.front().v);
1284 gp_UV a1(uv_e0.back().u, uv_e0.back().v);
1285 gp_UV a2(uv_e2.back().u, uv_e2.back().v);
1286 gp_UV a3(uv_e2.front().u, uv_e2.front().v);
1288 for (int i = 0; i < nbhoriz; i++) {
1289 for (int j = 0; j < nbvertic; j++) {
1290 int ij = j * nbhoriz + i;
1291 double x = uv_grid[ij].x;
1292 double y = uv_grid[ij].y;
1293 double param_0 = uv_e0[0].normParam + x * (uv_e0.back().normParam - uv_e0[0].normParam); // sud
1294 double param_2 = uv_e2[0].normParam + x * (uv_e2.back().normParam - uv_e2[0].normParam); // nord
1295 double param_1 = uv_e1[0].normParam + y * (uv_e1.back().normParam - uv_e1[0].normParam); // est
1296 double param_3 = uv_e3[0].normParam + y * (uv_e3.back().normParam - uv_e3[0].normParam); // ouest
1298 //MESSAGE("params "<<param_0<<" "<<param_1<<" "<<param_2<<" "<<param_3);
1299 gp_UV p0 = quad->side[0]->Value2d(param_0).XY();
1300 gp_UV p1 = quad->side[1]->Value2d(param_1).XY();
1301 gp_UV p2 = quad->side[2]->Value2d(param_2).XY();
1302 gp_UV p3 = quad->side[3]->Value2d(param_3).XY();
1304 gp_UV uv = CalcUV(x,y, a0,a1,a2,a3, p0,p1,p2,p3);
1306 uv_grid[ij].u = uv.X();
1307 uv_grid[ij].v = uv.Y();
1313 //=======================================================================
1314 //function : ShiftQuad
1315 //purpose : auxilary function for ComputeQuadPref
1316 //=======================================================================
1318 static void ShiftQuad(FaceQuadStruct* quad, const int num, bool)
1320 StdMeshers_FaceSide* side[4] = { quad->side[0], quad->side[1], quad->side[2], quad->side[3] };
1321 for (int i = BOTTOM_SIDE; i < NB_SIDES; ++i) {
1322 int id = (i + num) % NB_SIDES;
1323 bool wasForward = (i < TOP_SIDE);
1324 bool newForward = (id < TOP_SIDE);
1325 if (wasForward != newForward)
1326 side[ i ]->Reverse();
1327 quad->side[ id ] = side[ i ];
1331 //=======================================================================
1333 //purpose : auxilary function for ComputeQuadPref
1334 //=======================================================================
1336 static gp_UV CalcUV(double x0, double x1, double y0, double y1,
1337 FaceQuadStruct* quad,
1338 const gp_UV& a0, const gp_UV& a1,
1339 const gp_UV& a2, const gp_UV& a3)
1341 const vector<UVPtStruct>& uv_eb = quad->side[0]->GetUVPtStruct(true,0);
1342 const vector<UVPtStruct>& uv_er = quad->side[1]->GetUVPtStruct(false,1);
1343 const vector<UVPtStruct>& uv_et = quad->side[2]->GetUVPtStruct(true,1);
1344 const vector<UVPtStruct>& uv_el = quad->side[3]->GetUVPtStruct(false,0);
1346 double x = (x0 + y0 * (x1 - x0)) / (1 - (y1 - y0) * (x1 - x0));
1347 double y = y0 + x * (y1 - y0);
1349 double param_b = uv_eb[0].normParam + x * (uv_eb.back().normParam - uv_eb[0].normParam);
1350 double param_t = uv_et[0].normParam + x * (uv_et.back().normParam - uv_et[0].normParam);
1351 double param_r = uv_er[0].normParam + y * (uv_er.back().normParam - uv_er[0].normParam);
1352 double param_l = uv_el[0].normParam + y * (uv_el.back().normParam - uv_el[0].normParam);
1354 gp_UV p0 = quad->side[BOTTOM_SIDE]->Value2d(param_b).XY();
1355 gp_UV p1 = quad->side[RIGHT_SIDE ]->Value2d(param_r).XY();
1356 gp_UV p2 = quad->side[TOP_SIDE ]->Value2d(param_t).XY();
1357 gp_UV p3 = quad->side[LEFT_SIDE ]->Value2d(param_l).XY();
1359 gp_UV uv = CalcUV(x,y, a0,a1,a2,a3, p0,p1,p2,p3);
1364 //=======================================================================
1365 //function : CalcUV2
1366 //purpose : auxilary function for ComputeQuadPref
1367 //=======================================================================
1369 static gp_UV CalcUV2(double x, double y,
1370 FaceQuadStruct* quad,
1371 const gp_UV& a0, const gp_UV& a1,
1372 const gp_UV& a2, const gp_UV& a3)
1374 gp_UV p0 = quad->side[BOTTOM_SIDE]->Value2d(x).XY();
1375 gp_UV p1 = quad->side[RIGHT_SIDE ]->Value2d(y).XY();
1376 gp_UV p2 = quad->side[TOP_SIDE ]->Value2d(x).XY();
1377 gp_UV p3 = quad->side[LEFT_SIDE ]->Value2d(y).XY();
1379 gp_UV uv = CalcUV(x,y, a0,a1,a2,a3, p0,p1,p2,p3);
1385 //=======================================================================
1387 * Create only quandrangle faces
1389 //=======================================================================
1391 bool StdMeshers_Quadrangle_2D::ComputeQuadPref (SMESH_Mesh & aMesh,
1392 const TopoDS_Shape& aShape,
1393 FaceQuadStruct* quad)
1395 // Auxilary key in order to keep old variant
1396 // of meshing after implementation new variant
1397 // for bug 0016220 from Mantis.
1398 bool OldVersion = false;
1399 if (myQuadType == QUAD_QUADRANGLE_PREF_REVERSED)
1402 SMESHDS_Mesh * meshDS = aMesh.GetMeshDS();
1403 const TopoDS_Face& F = TopoDS::Face(aShape);
1404 Handle(Geom_Surface) S = BRep_Tool::Surface(F);
1406 int i,j,geomFaceID = meshDS->ShapeToIndex(F);
1408 int nb = quad->side[0]->NbPoints();
1409 int nr = quad->side[1]->NbPoints();
1410 int nt = quad->side[2]->NbPoints();
1411 int nl = quad->side[3]->NbPoints();
1412 int dh = abs(nb-nt);
1413 int dv = abs(nr-nl);
1417 // it is a base case => not shift quad but me be replacement is need
1418 ShiftQuad(quad,0,WisF);
1421 // we have to shift quad on 2
1422 ShiftQuad(quad,2,WisF);
1427 // we have to shift quad on 1
1428 ShiftQuad(quad,1,WisF);
1431 // we have to shift quad on 3
1432 ShiftQuad(quad,3,WisF);
1436 nb = quad->side[0]->NbPoints();
1437 nr = quad->side[1]->NbPoints();
1438 nt = quad->side[2]->NbPoints();
1439 nl = quad->side[3]->NbPoints();
1442 int nbh = Max(nb,nt);
1443 int nbv = Max(nr,nl);
1447 // ----------- Old version ---------------
1448 // orientation of face and 3 main domain for future faces
1454 // left | | | | rigth
1461 // ----------- New version ---------------
1462 // orientation of face and 3 main domain for future faces
1468 // left |/________\| rigth
1484 const vector<UVPtStruct>& uv_eb = quad->side[0]->GetUVPtStruct(true,0);
1485 const vector<UVPtStruct>& uv_er = quad->side[1]->GetUVPtStruct(false,1);
1486 const vector<UVPtStruct>& uv_et = quad->side[2]->GetUVPtStruct(true,1);
1487 const vector<UVPtStruct>& uv_el = quad->side[3]->GetUVPtStruct(false,0);
1489 if (uv_eb.size() != nb || uv_er.size() != nr || uv_et.size() != nt || uv_el.size() != nl)
1490 return error(COMPERR_BAD_INPUT_MESH);
1492 // arrays for normalized params
1493 //cout<<"Dump B:"<<endl;
1494 TColStd_SequenceOfReal npb, npr, npt, npl;
1495 for (i=0; i<nb; i++) {
1496 npb.Append(uv_eb[i].normParam);
1497 //cout<<"i="<<i<<" par="<<uv_eb[i].normParam<<" npar="<<uv_eb[i].normParam;
1498 //const SMDS_MeshNode* N = uv_eb[i].node;
1499 //cout<<" node("<<N->X()<<","<<N->Y()<<","<<N->Z()<<")"<<endl;
1501 for (i=0; i<nr; i++) {
1502 npr.Append(uv_er[i].normParam);
1504 for (i=0; i<nt; i++) {
1505 npt.Append(uv_et[i].normParam);
1507 for (i=0; i<nl; i++) {
1508 npl.Append(uv_el[i].normParam);
1513 // add some params to right and left after the first param
1516 double dpr = (npr.Value(2) - npr.Value(1))/(dr+1);
1517 for (i=1; i<=dr; i++) {
1518 npr.InsertAfter(1,npr.Value(2)-dpr);
1522 dpr = (npl.Value(2) - npl.Value(1))/(dl+1);
1523 for (i=1; i<=dl; i++) {
1524 npl.InsertAfter(1,npl.Value(2)-dpr);
1528 //for (i=1; i<=npb.Length(); i++) {
1529 // cout<<" "<<npb.Value(i);
1533 gp_XY a0(uv_eb.front().u, uv_eb.front().v);
1534 gp_XY a1(uv_eb.back().u, uv_eb.back().v);
1535 gp_XY a2(uv_et.back().u, uv_et.back().v);
1536 gp_XY a3(uv_et.front().u, uv_et.front().v);
1537 //cout<<" a0("<<a0.X()<<","<<a0.Y()<<")"<<" a1("<<a1.X()<<","<<a1.Y()<<")"
1538 // <<" a2("<<a2.X()<<","<<a2.Y()<<")"<<" a3("<<a3.X()<<","<<a3.Y()<<")"<<endl;
1540 int nnn = Min(nr,nl);
1541 // auxilary sequence of XY for creation nodes
1542 // in the bottom part of central domain
1543 // Length of UVL and UVR must be == nbv-nnn
1544 TColgp_SequenceOfXY UVL, UVR, UVT;
1547 // step1: create faces for left domain
1548 StdMeshers_Array2OfNode NodesL(1,dl+1,1,nl);
1550 for (j=1; j<=nl; j++)
1551 NodesL.SetValue(1,j,uv_el[j-1].node);
1554 for (i=1; i<=dl; i++)
1555 NodesL.SetValue(i+1,nl,uv_et[i].node);
1556 // create and add needed nodes
1557 TColgp_SequenceOfXY UVtmp;
1558 for (i=1; i<=dl; i++) {
1559 double x0 = npt.Value(i+1);
1562 double y0 = npl.Value(i+1);
1563 double y1 = npr.Value(i+1);
1564 gp_UV UV = CalcUV(x0, x1, y0, y1, quad, a0, a1, a2, a3);
1565 gp_Pnt P = S->Value(UV.X(),UV.Y());
1566 SMDS_MeshNode * N = meshDS->AddNode(P.X(), P.Y(), P.Z());
1567 meshDS->SetNodeOnFace(N, geomFaceID, UV.X(), UV.Y());
1568 NodesL.SetValue(i+1,1,N);
1569 if (UVL.Length()<nbv-nnn) UVL.Append(UV);
1571 for (j=2; j<nl; j++) {
1572 double y0 = npl.Value(dl+j);
1573 double y1 = npr.Value(dl+j);
1574 gp_UV UV = CalcUV(x0, x1, y0, y1, quad, a0, a1, a2, a3);
1575 gp_Pnt P = S->Value(UV.X(),UV.Y());
1576 SMDS_MeshNode* N = meshDS->AddNode(P.X(), P.Y(), P.Z());
1577 meshDS->SetNodeOnFace(N, geomFaceID, UV.X(), UV.Y());
1578 NodesL.SetValue(i+1,j,N);
1579 if (i==dl) UVtmp.Append(UV);
1582 for (i=1; i<=UVtmp.Length() && UVL.Length()<nbv-nnn; i++) {
1583 UVL.Append(UVtmp.Value(i));
1585 //cout<<"Dump NodesL:"<<endl;
1586 //for (i=1; i<=dl+1; i++) {
1588 // for (j=1; j<=nl; j++) {
1589 // cout<<" ("<<NodesL.Value(i,j)->X()<<","<<NodesL.Value(i,j)->Y()<<","<<NodesL.Value(i,j)->Z()<<")";
1594 for (i=1; i<=dl; i++) {
1595 for (j=1; j<nl; j++) {
1598 myTool->AddFace(NodesL.Value(i,j), NodesL.Value(i+1,j),
1599 NodesL.Value(i+1,j+1), NodesL.Value(i,j+1));
1600 if (F) meshDS->SetMeshElementOnShape(F, geomFaceID);
1604 myTool->AddFace(NodesL.Value(i,j), NodesL.Value(i,j+1),
1605 NodesL.Value(i+1,j+1), NodesL.Value(i+1,j));
1606 if (F) meshDS->SetMeshElementOnShape(F, geomFaceID);
1612 // fill UVL using c2d
1613 for (i=1; i<npl.Length() && UVL.Length()<nbv-nnn; i++) {
1614 UVL.Append(gp_UV (uv_el[i].u, uv_el[i].v));
1618 // step2: create faces for right domain
1619 StdMeshers_Array2OfNode NodesR(1,dr+1,1,nr);
1621 for (j=1; j<=nr; j++)
1622 NodesR.SetValue(1,j,uv_er[nr-j].node);
1625 for (i=1; i<=dr; i++)
1626 NodesR.SetValue(i+1,1,uv_et[nt-1-i].node);
1627 // create and add needed nodes
1628 TColgp_SequenceOfXY UVtmp;
1629 for (i=1; i<=dr; i++) {
1630 double x0 = npt.Value(nt-i);
1633 double y0 = npl.Value(i+1);
1634 double y1 = npr.Value(i+1);
1635 gp_UV UV = CalcUV(x0, x1, y0, y1, quad, a0, a1, a2, a3);
1636 gp_Pnt P = S->Value(UV.X(),UV.Y());
1637 SMDS_MeshNode * N = meshDS->AddNode(P.X(), P.Y(), P.Z());
1638 meshDS->SetNodeOnFace(N, geomFaceID, UV.X(), UV.Y());
1639 NodesR.SetValue(i+1,nr,N);
1640 if (UVR.Length()<nbv-nnn) UVR.Append(UV);
1642 for (j=2; j<nr; j++) {
1643 double y0 = npl.Value(nbv-j+1);
1644 double y1 = npr.Value(nbv-j+1);
1645 gp_UV UV = CalcUV(x0, x1, y0, y1, quad, a0, a1, a2, a3);
1646 gp_Pnt P = S->Value(UV.X(),UV.Y());
1647 SMDS_MeshNode* N = meshDS->AddNode(P.X(), P.Y(), P.Z());
1648 meshDS->SetNodeOnFace(N, geomFaceID, UV.X(), UV.Y());
1649 NodesR.SetValue(i+1,j,N);
1650 if (i==dr) UVtmp.Prepend(UV);
1653 for (i=1; i<=UVtmp.Length() && UVR.Length()<nbv-nnn; i++) {
1654 UVR.Append(UVtmp.Value(i));
1657 for (i=1; i<=dr; i++) {
1658 for (j=1; j<nr; j++) {
1661 myTool->AddFace(NodesR.Value(i,j), NodesR.Value(i+1,j),
1662 NodesR.Value(i+1,j+1), NodesR.Value(i,j+1));
1663 if (F) meshDS->SetMeshElementOnShape(F, geomFaceID);
1667 myTool->AddFace(NodesR.Value(i,j), NodesR.Value(i,j+1),
1668 NodesR.Value(i+1,j+1), NodesR.Value(i+1,j));
1669 if (F) meshDS->SetMeshElementOnShape(F, geomFaceID);
1675 // fill UVR using c2d
1676 for (i=1; i<npr.Length() && UVR.Length()<nbv-nnn; i++) {
1677 UVR.Append(gp_UV(uv_er[i].u, uv_er[i].v));
1681 // step3: create faces for central domain
1682 StdMeshers_Array2OfNode NodesC(1,nb,1,nbv);
1683 // add first line using NodesL
1684 for (i=1; i<=dl+1; i++)
1685 NodesC.SetValue(1,i,NodesL(i,1));
1686 for (i=2; i<=nl; i++)
1687 NodesC.SetValue(1,dl+i,NodesL(dl+1,i));
1688 // add last line using NodesR
1689 for (i=1; i<=dr+1; i++)
1690 NodesC.SetValue(nb,i,NodesR(i,nr));
1691 for (i=1; i<nr; i++)
1692 NodesC.SetValue(nb,dr+i+1,NodesR(dr+1,nr-i));
1693 // add top nodes (last columns)
1694 for (i=dl+2; i<nbh-dr; i++)
1695 NodesC.SetValue(i-dl,nbv,uv_et[i-1].node);
1696 // add bottom nodes (first columns)
1697 for (i=2; i<nb; i++)
1698 NodesC.SetValue(i,1,uv_eb[i-1].node);
1700 // create and add needed nodes
1701 // add linear layers
1702 for (i=2; i<nb; i++) {
1703 double x0 = npt.Value(dl+i);
1705 for (j=1; j<nnn; j++) {
1706 double y0 = npl.Value(nbv-nnn+j);
1707 double y1 = npr.Value(nbv-nnn+j);
1708 gp_UV UV = CalcUV(x0, x1, y0, y1, quad, a0, a1, a2, a3);
1709 gp_Pnt P = S->Value(UV.X(),UV.Y());
1710 SMDS_MeshNode* N = meshDS->AddNode(P.X(), P.Y(), P.Z());
1711 meshDS->SetNodeOnFace(N, geomFaceID, UV.X(), UV.Y());
1712 NodesC.SetValue(i,nbv-nnn+j,N);
1717 // add diagonal layers
1718 //cout<<"UVL.Length()="<<UVL.Length()<<" UVR.Length()="<<UVR.Length()<<endl;
1719 //cout<<"Dump UVL:"<<endl;
1720 //for (i=1; i<=UVL.Length(); i++) {
1721 // cout<<" ("<<UVL.Value(i).X()<<","<<UVL.Value(i).Y()<<")";
1724 gp_UV A2 = UVR.Value(nbv-nnn);
1725 gp_UV A3 = UVL.Value(nbv-nnn);
1726 for (i=1; i<nbv-nnn; i++) {
1727 gp_UV p1 = UVR.Value(i);
1728 gp_UV p3 = UVL.Value(i);
1729 double y = i / double(nbv-nnn);
1730 for (j=2; j<nb; j++) {
1731 double x = npb.Value(j);
1732 gp_UV p0( uv_eb[j-1].u, uv_eb[j-1].v );
1733 gp_UV p2 = UVT.Value( j-1 );
1734 gp_UV UV = CalcUV(x, y, a0, a1, A2, A3, p0,p1,p2,p3 );
1735 gp_Pnt P = S->Value(UV.X(),UV.Y());
1736 SMDS_MeshNode* N = meshDS->AddNode(P.X(), P.Y(), P.Z());
1737 meshDS->SetNodeOnFace(N, geomFaceID, UV.X(),UV.Y());
1738 NodesC.SetValue(j,i+1,N);
1742 for (i=1; i<nb; i++) {
1743 for (j=1; j<nbv; j++) {
1746 myTool->AddFace(NodesC.Value(i,j), NodesC.Value(i+1,j),
1747 NodesC.Value(i+1,j+1), NodesC.Value(i,j+1));
1748 if (F) meshDS->SetMeshElementOnShape(F, geomFaceID);
1752 myTool->AddFace(NodesC.Value(i,j), NodesC.Value(i,j+1),
1753 NodesC.Value(i+1,j+1), NodesC.Value(i+1,j));
1754 if (F) meshDS->SetMeshElementOnShape(F, geomFaceID);
1760 else { // New version (!OldVersion)
1761 // step1: create faces for bottom rectangle domain
1762 StdMeshers_Array2OfNode NodesBRD(1,nb,1,nnn-1);
1763 // fill UVL and UVR using c2d
1764 for (j=0; j<nb; j++) {
1765 NodesBRD.SetValue(j+1,1,uv_eb[j].node);
1767 for (i=1; i<nnn-1; i++) {
1768 NodesBRD.SetValue(1,i+1,uv_el[i].node);
1769 NodesBRD.SetValue(nb,i+1,uv_er[i].node);
1770 for (j=2; j<nb; j++) {
1771 double x = npb.Value(j);
1772 double y = (1-x) * npl.Value(i+1) + x * npr.Value(i+1);
1773 gp_UV UV = CalcUV2(x, y, quad, a0, a1, a2, a3);
1774 gp_Pnt P = S->Value(UV.X(),UV.Y());
1775 SMDS_MeshNode* N = meshDS->AddNode(P.X(), P.Y(), P.Z());
1776 meshDS->SetNodeOnFace(N, geomFaceID, UV.X(),UV.Y());
1777 NodesBRD.SetValue(j,i+1,N);
1780 for (j=1; j<nnn-1; j++) {
1781 for (i=1; i<nb; i++) {
1784 myTool->AddFace(NodesBRD.Value(i,j), NodesBRD.Value(i+1,j),
1785 NodesBRD.Value(i+1,j+1), NodesBRD.Value(i,j+1));
1786 if (F) meshDS->SetMeshElementOnShape(F, geomFaceID);
1790 myTool->AddFace(NodesBRD.Value(i,j), NodesBRD.Value(i,j+1),
1791 NodesBRD.Value(i+1,j+1), NodesBRD.Value(i+1,j));
1792 if (F) meshDS->SetMeshElementOnShape(F, geomFaceID);
1796 int drl = abs(nr-nl);
1797 // create faces for region C
1798 StdMeshers_Array2OfNode NodesC(1,nb,1,drl+1+addv);
1799 // add nodes from previous region
1800 for (j=1; j<=nb; j++) {
1801 NodesC.SetValue(j,1,NodesBRD.Value(j,nnn-1));
1803 if ((drl+addv) > 0) {
1808 TColgp_SequenceOfXY UVtmp;
1809 double drparam = npr.Value(nr) - npr.Value(nnn-1);
1810 double dlparam = npl.Value(nnn) - npl.Value(nnn-1);
1812 for (i=1; i<=drl; i++) {
1813 // add existed nodes from right edge
1814 NodesC.SetValue(nb,i+1,uv_er[nnn+i-2].node);
1815 //double dtparam = npt.Value(i+1);
1816 y1 = npr.Value(nnn+i-1); // param on right edge
1817 double dpar = (y1 - npr.Value(nnn-1))/drparam;
1818 y0 = npl.Value(nnn-1) + dpar*dlparam; // param on left edge
1819 double dy = y1 - y0;
1820 for (j=1; j<nb; j++) {
1821 double x = npt.Value(i+1) + npb.Value(j)*(1-npt.Value(i+1));
1822 double y = y0 + dy*x;
1823 gp_UV UV = CalcUV2(x, y, quad, a0, a1, a2, a3);
1824 gp_Pnt P = S->Value(UV.X(),UV.Y());
1825 SMDS_MeshNode* N = meshDS->AddNode(P.X(), P.Y(), P.Z());
1826 meshDS->SetNodeOnFace(N, geomFaceID, UV.X(), UV.Y());
1827 NodesC.SetValue(j,i+1,N);
1830 double dy0 = (1-y0)/(addv+1);
1831 double dy1 = (1-y1)/(addv+1);
1832 for (i=1; i<=addv; i++) {
1833 double yy0 = y0 + dy0*i;
1834 double yy1 = y1 + dy1*i;
1835 double dyy = yy1 - yy0;
1836 for (j=1; j<=nb; j++) {
1837 double x = npt.Value(i+1+drl) +
1838 npb.Value(j) * (npt.Value(nt-i) - npt.Value(i+1+drl));
1839 double y = yy0 + dyy*x;
1840 gp_UV UV = CalcUV2(x, y, quad, a0, a1, a2, a3);
1841 gp_Pnt P = S->Value(UV.X(),UV.Y());
1842 SMDS_MeshNode* N = meshDS->AddNode(P.X(), P.Y(), P.Z());
1843 meshDS->SetNodeOnFace(N, geomFaceID, UV.X(), UV.Y());
1844 NodesC.SetValue(j,i+drl+1,N);
1851 TColgp_SequenceOfXY UVtmp;
1852 double dlparam = npl.Value(nl) - npl.Value(nnn-1);
1853 double drparam = npr.Value(nnn) - npr.Value(nnn-1);
1854 double y0 = npl.Value(nnn-1);
1855 double y1 = npr.Value(nnn-1);
1856 for (i=1; i<=drl; i++) {
1857 // add existed nodes from right edge
1858 NodesC.SetValue(1,i+1,uv_el[nnn+i-2].node);
1859 y0 = npl.Value(nnn+i-1); // param on left edge
1860 double dpar = (y0 - npl.Value(nnn-1))/dlparam;
1861 y1 = npr.Value(nnn-1) + dpar*drparam; // param on right edge
1862 double dy = y1 - y0;
1863 for (j=2; j<=nb; j++) {
1864 double x = npb.Value(j)*npt.Value(nt-i);
1865 double y = y0 + dy*x;
1866 gp_UV UV = CalcUV2(x, y, quad, a0, a1, a2, a3);
1867 gp_Pnt P = S->Value(UV.X(),UV.Y());
1868 SMDS_MeshNode* N = meshDS->AddNode(P.X(), P.Y(), P.Z());
1869 meshDS->SetNodeOnFace(N, geomFaceID, UV.X(), UV.Y());
1870 NodesC.SetValue(j,i+1,N);
1873 double dy0 = (1-y0)/(addv+1);
1874 double dy1 = (1-y1)/(addv+1);
1875 for (i=1; i<=addv; i++) {
1876 double yy0 = y0 + dy0*i;
1877 double yy1 = y1 + dy1*i;
1878 double dyy = yy1 - yy0;
1879 for (j=1; j<=nb; j++) {
1880 double x = npt.Value(i+1) +
1881 npb.Value(j) * (npt.Value(nt-i-drl) - npt.Value(i+1));
1882 double y = yy0 + dyy*x;
1883 gp_UV UV = CalcUV2(x, y, quad, a0, a1, a2, a3);
1884 gp_Pnt P = S->Value(UV.X(),UV.Y());
1885 SMDS_MeshNode* N = meshDS->AddNode(P.X(), P.Y(), P.Z());
1886 meshDS->SetNodeOnFace(N, geomFaceID, UV.X(), UV.Y());
1887 NodesC.SetValue(j,i+drl+1,N);
1892 for (j=1; j<=drl+addv; j++) {
1893 for (i=1; i<nb; i++) {
1896 myTool->AddFace(NodesC.Value(i,j), NodesC.Value(i+1,j),
1897 NodesC.Value(i+1,j+1), NodesC.Value(i,j+1));
1898 if (F) meshDS->SetMeshElementOnShape(F, geomFaceID);
1902 myTool->AddFace(NodesC.Value(i,j), NodesC.Value(i,j+1),
1903 NodesC.Value(i+1,j+1), NodesC.Value(i+1,j));
1904 if (F) meshDS->SetMeshElementOnShape(F, geomFaceID);
1909 StdMeshers_Array2OfNode NodesLast(1,nt,1,2);
1910 for (i=1; i<=nt; i++) {
1911 NodesLast.SetValue(i,2,uv_et[i-1].node);
1914 for (i=n1; i<drl+addv+1; i++) {
1916 NodesLast.SetValue(nnn,1,NodesC.Value(1,i));
1918 for (i=1; i<=nb; i++) {
1920 NodesLast.SetValue(nnn,1,NodesC.Value(i,drl+addv+1));
1922 for (i=drl+addv; i>=n2; i--) {
1924 NodesLast.SetValue(nnn,1,NodesC.Value(nb,i));
1926 for (i=1; i<nt; i++) {
1929 myTool->AddFace(NodesLast.Value(i,1), NodesLast.Value(i+1,1),
1930 NodesLast.Value(i+1,2), NodesLast.Value(i,2));
1931 if (F) meshDS->SetMeshElementOnShape(F, geomFaceID);
1935 myTool->AddFace(NodesLast.Value(i,1), NodesLast.Value(i,2),
1936 NodesLast.Value(i+1,2), NodesLast.Value(i+1,2));
1937 if (F) meshDS->SetMeshElementOnShape(F, geomFaceID);
1940 } // if ((drl+addv) > 0)
1942 } // end new version implementation
1949 //=======================================================================
1951 * Evaluate only quandrangle faces
1953 //=======================================================================
1955 bool StdMeshers_Quadrangle_2D::EvaluateQuadPref(SMESH_Mesh & aMesh,
1956 const TopoDS_Shape& aShape,
1957 std::vector<int>& aNbNodes,
1958 MapShapeNbElems& aResMap,
1961 // Auxilary key in order to keep old variant
1962 // of meshing after implementation new variant
1963 // for bug 0016220 from Mantis.
1964 bool OldVersion = false;
1965 if (myQuadType == QUAD_QUADRANGLE_PREF_REVERSED)
1968 const TopoDS_Face& F = TopoDS::Face(aShape);
1969 Handle(Geom_Surface) S = BRep_Tool::Surface(F);
1971 int nb = aNbNodes[0];
1972 int nr = aNbNodes[1];
1973 int nt = aNbNodes[2];
1974 int nl = aNbNodes[3];
1975 int dh = abs(nb-nt);
1976 int dv = abs(nr-nl);
1980 // it is a base case => not shift
1983 // we have to shift on 2
1992 // we have to shift quad on 1
1999 // we have to shift quad on 3
2009 int nbh = Max(nb,nt);
2010 int nbv = Max(nr,nl);
2025 // add some params to right and left after the first param
2032 int nnn = Min(nr,nl);
2037 // step1: create faces for left domain
2039 nbNodes += dl*(nl-1);
2040 nbFaces += dl*(nl-1);
2042 // step2: create faces for right domain
2044 nbNodes += dr*(nr-1);
2045 nbFaces += dr*(nr-1);
2047 // step3: create faces for central domain
2048 nbNodes += (nb-2)*(nnn-1) + (nbv-nnn-1)*(nb-2);
2049 nbFaces += (nb-1)*(nbv-1);
2051 else { // New version (!OldVersion)
2052 nbNodes += (nnn-2)*(nb-2);
2053 nbFaces += (nnn-2)*(nb-1);
2054 int drl = abs(nr-nl);
2055 nbNodes += drl*(nb-1) + addv*nb;
2056 nbFaces += (drl+addv)*(nb-1) + (nt-1);
2057 } // end new version implementation
2059 std::vector<int> aVec(SMDSEntity_Last);
2060 for (int i=SMDSEntity_Node; i<SMDSEntity_Last; i++) aVec[i] = 0;
2062 aVec[SMDSEntity_Quad_Quadrangle] = nbFaces;
2063 aVec[SMDSEntity_Node] = nbNodes + nbFaces*4;
2064 if (aNbNodes.size()==5) {
2065 aVec[SMDSEntity_Quad_Triangle] = aNbNodes[3] - 1;
2066 aVec[SMDSEntity_Quad_Quadrangle] = nbFaces - aNbNodes[3] + 1;
2070 aVec[SMDSEntity_Node] = nbNodes;
2071 aVec[SMDSEntity_Quadrangle] = nbFaces;
2072 if (aNbNodes.size()==5) {
2073 aVec[SMDSEntity_Triangle] = aNbNodes[3] - 1;
2074 aVec[SMDSEntity_Quadrangle] = nbFaces - aNbNodes[3] + 1;
2077 SMESH_subMesh * sm = aMesh.GetSubMesh(aShape);
2078 aResMap.insert(std::make_pair(sm,aVec));
2084 //=============================================================================
2085 /*! Split quadrangle in to 2 triangles by smallest diagonal
2088 //=============================================================================
2089 void StdMeshers_Quadrangle_2D::SplitQuad(SMESHDS_Mesh *theMeshDS,
2091 const SMDS_MeshNode* theNode1,
2092 const SMDS_MeshNode* theNode2,
2093 const SMDS_MeshNode* theNode3,
2094 const SMDS_MeshNode* theNode4)
2096 gp_Pnt a(theNode1->X(),theNode1->Y(),theNode1->Z());
2097 gp_Pnt b(theNode2->X(),theNode2->Y(),theNode2->Z());
2098 gp_Pnt c(theNode3->X(),theNode3->Y(),theNode3->Z());
2099 gp_Pnt d(theNode4->X(),theNode4->Y(),theNode4->Z());
2100 SMDS_MeshFace* face;
2101 if (a.Distance(c) > b.Distance(d)){
2102 face = myTool->AddFace(theNode2, theNode4 , theNode1);
2103 if (face) theMeshDS->SetMeshElementOnShape(face, theFaceID);
2104 face = myTool->AddFace(theNode2, theNode3, theNode4);
2105 if (face) theMeshDS->SetMeshElementOnShape(face, theFaceID);
2109 face = myTool->AddFace(theNode1, theNode2 ,theNode3);
2110 if (face) theMeshDS->SetMeshElementOnShape(face, theFaceID);
2111 face = myTool->AddFace(theNode1, theNode3, theNode4);
2112 if (face) theMeshDS->SetMeshElementOnShape(face, theFaceID);
2116 //=======================================================================
2118 * Implementation of Reduced algorithm (meshing with quadrangles only)
2120 //=======================================================================
2121 bool StdMeshers_Quadrangle_2D::ComputeReduced (SMESH_Mesh & aMesh,
2122 const TopoDS_Shape& aShape,
2123 FaceQuadStruct* quad)
2125 SMESHDS_Mesh * meshDS = aMesh.GetMeshDS();
2126 const TopoDS_Face& F = TopoDS::Face(aShape);
2127 Handle(Geom_Surface) S = BRep_Tool::Surface(F);
2128 int i,j,geomFaceID = meshDS->ShapeToIndex(F);
2130 int nb = quad->side[0]->NbPoints();
2131 int nr = quad->side[1]->NbPoints();
2132 int nt = quad->side[2]->NbPoints();
2133 int nl = quad->side[3]->NbPoints();
2135 // Simple Reduce 8->6->4->2 (3 steps) Multiple Reduce 8->2 (1 step)
2137 // .-----.-----.-----.-----. .-----.-----.-----.-----.
2138 // | / \ | / \ | | / \ | / \ |
2139 // | / .--.--. \ | | / \ | / \ |
2140 // | / / | \ \ | | / .----.----. \ |
2141 // .---.---.---.---.---.---. | / / \ | / \ \ |
2142 // | / / \ | / \ \ | | / / \ | / \ \ |
2143 // | / / .-.-. \ \ | | / / .---.---. \ \ |
2144 // | / / / | \ \ \ | | / / / \ | / \ \ \ |
2145 // .--.--.--.--.--.--.--.--. | / / / \ | / \ \ \ |
2146 // | / / / \ | / \ \ \ | | / / / .-.-. \ \ \ |
2147 // | / / / .-.-. \ \ \ | | / / / / | \ \ \ \ |
2148 // | / / / / | \ \ \ \ | | / / / / | \ \ \ \ |
2149 // .-.-.-.--.--.--.--.-.-.-. .-.-.-.--.--.--.--.-.-.-.
2151 bool MultipleReduce = false;
2164 else if (nb == nt) {
2165 nl1 = nb; // and == nt
2166 nr1 = nb; // and == nt
2180 // number of rows and columns
2181 int nrows = nr1 - 1; // and also == nl1 - 1
2182 int ncol_top = nt1 - 1;
2183 int ncol_bot = nb1 - 1;
2184 int npair_top = ncol_top / 2;
2185 // maximum number of bottom elements for "linear" simple reduce
2186 //int max_lin = ncol_top + npair_top * 2 * nrows;
2187 // maximum number of bottom elements for "tree" simple reduce
2188 int max_tree = npair_top * pow(2.0, nrows + 1);
2189 if (ncol_top > npair_top * 2) {
2190 int delta = ncol_bot - max_tree;
2191 for (int irow = 1; irow < nrows; irow++) {
2192 int nfour = delta / 4;
2195 if (delta <= (ncol_top - npair_top * 2))
2196 max_tree = ncol_bot;
2199 if (ncol_bot > max_tree)
2200 MultipleReduce = true;
2203 if (MultipleReduce) { // == ComputeQuadPref QUAD_QUADRANGLE_PREF_REVERSED
2204 //==================================================
2205 int dh = abs(nb-nt);
2206 int dv = abs(nr-nl);
2210 // it is a base case => not shift quad but may be replacement is need
2211 ShiftQuad(quad,0,true);
2214 // we have to shift quad on 2
2215 ShiftQuad(quad,2,true);
2220 // we have to shift quad on 1
2221 ShiftQuad(quad,1,true);
2224 // we have to shift quad on 3
2225 ShiftQuad(quad,3,true);
2229 nb = quad->side[0]->NbPoints();
2230 nr = quad->side[1]->NbPoints();
2231 nt = quad->side[2]->NbPoints();
2232 nl = quad->side[3]->NbPoints();
2235 int nbh = Max(nb,nt);
2236 int nbv = Max(nr,nl);
2249 const vector<UVPtStruct>& uv_eb = quad->side[0]->GetUVPtStruct(true,0);
2250 const vector<UVPtStruct>& uv_er = quad->side[1]->GetUVPtStruct(false,1);
2251 const vector<UVPtStruct>& uv_et = quad->side[2]->GetUVPtStruct(true,1);
2252 const vector<UVPtStruct>& uv_el = quad->side[3]->GetUVPtStruct(false,0);
2254 if (uv_eb.size() != nb || uv_er.size() != nr || uv_et.size() != nt || uv_el.size() != nl)
2255 return error(COMPERR_BAD_INPUT_MESH);
2257 // arrays for normalized params
2258 TColStd_SequenceOfReal npb, npr, npt, npl;
2259 for (j = 0; j < nb; j++) {
2260 npb.Append(uv_eb[j].normParam);
2262 for (i = 0; i < nr; i++) {
2263 npr.Append(uv_er[i].normParam);
2265 for (j = 0; j < nt; j++) {
2266 npt.Append(uv_et[j].normParam);
2268 for (i = 0; i < nl; i++) {
2269 npl.Append(uv_el[i].normParam);
2273 // orientation of face and 3 main domain for future faces
2279 // left | | | | rigth
2286 // add some params to right and left after the first param
2289 double dpr = (npr.Value(2) - npr.Value(1))/(dr+1);
2290 for (i=1; i<=dr; i++) {
2291 npr.InsertAfter(1,npr.Value(2)-dpr);
2295 dpr = (npl.Value(2) - npl.Value(1))/(dl+1);
2296 for (i=1; i<=dl; i++) {
2297 npl.InsertAfter(1,npl.Value(2)-dpr);
2300 gp_XY a0 (uv_eb.front().u, uv_eb.front().v);
2301 gp_XY a1 (uv_eb.back().u, uv_eb.back().v);
2302 gp_XY a2 (uv_et.back().u, uv_et.back().v);
2303 gp_XY a3 (uv_et.front().u, uv_et.front().v);
2305 int nnn = Min(nr,nl);
2306 // auxilary sequence of XY for creation nodes
2307 // in the bottom part of central domain
2308 // it's length must be == nbv-nnn-1
2309 TColgp_SequenceOfXY UVL;
2310 TColgp_SequenceOfXY UVR;
2311 //==================================================
2313 // step1: create faces for left domain
2314 StdMeshers_Array2OfNode NodesL(1,dl+1,1,nl);
2316 for (j=1; j<=nl; j++)
2317 NodesL.SetValue(1,j,uv_el[j-1].node);
2320 for (i=1; i<=dl; i++)
2321 NodesL.SetValue(i+1,nl,uv_et[i].node);
2322 // create and add needed nodes
2323 TColgp_SequenceOfXY UVtmp;
2324 for (i=1; i<=dl; i++) {
2325 double x0 = npt.Value(i+1);
2328 double y0 = npl.Value(i+1);
2329 double y1 = npr.Value(i+1);
2330 gp_UV UV = CalcUV(x0, x1, y0, y1, quad, a0, a1, a2, a3);
2331 gp_Pnt P = S->Value(UV.X(),UV.Y());
2332 SMDS_MeshNode * N = meshDS->AddNode(P.X(), P.Y(), P.Z());
2333 meshDS->SetNodeOnFace(N, geomFaceID, UV.X(), UV.Y());
2334 NodesL.SetValue(i+1,1,N);
2335 if (UVL.Length()<nbv-nnn-1) UVL.Append(UV);
2337 for (j=2; j<nl; j++) {
2338 double y0 = npl.Value(dl+j);
2339 double y1 = npr.Value(dl+j);
2340 gp_UV UV = CalcUV(x0, x1, y0, y1, quad, a0, a1, a2, a3);
2341 gp_Pnt P = S->Value(UV.X(),UV.Y());
2342 SMDS_MeshNode* N = meshDS->AddNode(P.X(), P.Y(), P.Z());
2343 meshDS->SetNodeOnFace(N, geomFaceID, UV.X(), UV.Y());
2344 NodesL.SetValue(i+1,j,N);
2345 if (i==dl) UVtmp.Append(UV);
2348 for (i=1; i<=UVtmp.Length() && UVL.Length()<nbv-nnn-1; i++) {
2349 UVL.Append(UVtmp.Value(i));
2352 for (i=1; i<=dl; i++) {
2353 for (j=1; j<nl; j++) {
2355 myTool->AddFace(NodesL.Value(i,j), NodesL.Value(i+1,j),
2356 NodesL.Value(i+1,j+1), NodesL.Value(i,j+1));
2357 if (F) meshDS->SetMeshElementOnShape(F, geomFaceID);
2362 // fill UVL using c2d
2363 for (i=1; i<npl.Length() && UVL.Length()<nbv-nnn-1; i++) {
2364 UVL.Append(gp_UV (uv_el[i].u, uv_el[i].v));
2368 // step2: create faces for right domain
2369 StdMeshers_Array2OfNode NodesR(1,dr+1,1,nr);
2371 for (j=1; j<=nr; j++)
2372 NodesR.SetValue(1,j,uv_er[nr-j].node);
2375 for (i=1; i<=dr; i++)
2376 NodesR.SetValue(i+1,1,uv_et[nt-1-i].node);
2377 // create and add needed nodes
2378 TColgp_SequenceOfXY UVtmp;
2379 for (i=1; i<=dr; i++) {
2380 double x0 = npt.Value(nt-i);
2383 double y0 = npl.Value(i+1);
2384 double y1 = npr.Value(i+1);
2385 gp_UV UV = CalcUV(x0, x1, y0, y1, quad, a0, a1, a2, a3);
2386 gp_Pnt P = S->Value(UV.X(),UV.Y());
2387 SMDS_MeshNode * N = meshDS->AddNode(P.X(), P.Y(), P.Z());
2388 meshDS->SetNodeOnFace(N, geomFaceID, UV.X(), UV.Y());
2389 NodesR.SetValue(i+1,nr,N);
2390 if (UVR.Length()<nbv-nnn-1) UVR.Append(UV);
2392 for (j=2; j<nr; j++) {
2393 double y0 = npl.Value(nbv-j+1);
2394 double y1 = npr.Value(nbv-j+1);
2395 gp_UV UV = CalcUV(x0, x1, y0, y1, quad, a0, a1, a2, a3);
2396 gp_Pnt P = S->Value(UV.X(),UV.Y());
2397 SMDS_MeshNode* N = meshDS->AddNode(P.X(), P.Y(), P.Z());
2398 meshDS->SetNodeOnFace(N, geomFaceID, UV.X(), UV.Y());
2399 NodesR.SetValue(i+1,j,N);
2400 if (i==dr) UVtmp.Prepend(UV);
2403 for (i=1; i<=UVtmp.Length() && UVR.Length()<nbv-nnn-1; i++) {
2404 UVR.Append(UVtmp.Value(i));
2407 for (i=1; i<=dr; i++) {
2408 for (j=1; j<nr; j++) {
2410 myTool->AddFace(NodesR.Value(i,j), NodesR.Value(i+1,j),
2411 NodesR.Value(i+1,j+1), NodesR.Value(i,j+1));
2412 if (F) meshDS->SetMeshElementOnShape(F, geomFaceID);
2417 // fill UVR using c2d
2418 for (i=1; i<npr.Length() && UVR.Length()<nbv-nnn-1; i++) {
2419 UVR.Append(gp_UV(uv_er[i].u, uv_er[i].v));
2423 // step3: create faces for central domain
2424 StdMeshers_Array2OfNode NodesC(1,nb,1,nbv);
2425 // add first line using NodesL
2426 for (i=1; i<=dl+1; i++)
2427 NodesC.SetValue(1,i,NodesL(i,1));
2428 for (i=2; i<=nl; i++)
2429 NodesC.SetValue(1,dl+i,NodesL(dl+1,i));
2430 // add last line using NodesR
2431 for (i=1; i<=dr+1; i++)
2432 NodesC.SetValue(nb,i,NodesR(i,nr));
2433 for (i=1; i<nr; i++)
2434 NodesC.SetValue(nb,dr+i+1,NodesR(dr+1,nr-i));
2435 // add top nodes (last columns)
2436 for (i=dl+2; i<nbh-dr; i++)
2437 NodesC.SetValue(i-dl,nbv,uv_et[i-1].node);
2438 // add bottom nodes (first columns)
2439 for (i=2; i<nb; i++)
2440 NodesC.SetValue(i,1,uv_eb[i-1].node);
2442 // create and add needed nodes
2443 // add linear layers
2444 for (i=2; i<nb; i++) {
2445 double x0 = npt.Value(dl+i);
2447 for (j=1; j<nnn; j++) {
2448 double y0 = npl.Value(nbv-nnn+j);
2449 double y1 = npr.Value(nbv-nnn+j);
2450 gp_UV UV = CalcUV(x0, x1, y0, y1, quad, a0, a1, a2, a3);
2451 gp_Pnt P = S->Value(UV.X(),UV.Y());
2452 SMDS_MeshNode* N = meshDS->AddNode(P.X(), P.Y(), P.Z());
2453 meshDS->SetNodeOnFace(N, geomFaceID, UV.X(), UV.Y());
2454 NodesC.SetValue(i,nbv-nnn+j,N);
2457 // add diagonal layers
2458 for (i=1; i<nbv-nnn; i++) {
2459 double du = UVR.Value(i).X() - UVL.Value(i).X();
2460 double dv = UVR.Value(i).Y() - UVL.Value(i).Y();
2461 for (j=2; j<nb; j++) {
2462 double u = UVL.Value(i).X() + du*npb.Value(j);
2463 double v = UVL.Value(i).Y() + dv*npb.Value(j);
2464 gp_Pnt P = S->Value(u,v);
2465 SMDS_MeshNode* N = meshDS->AddNode(P.X(), P.Y(), P.Z());
2466 meshDS->SetNodeOnFace(N, geomFaceID, u, v);
2467 NodesC.SetValue(j,i+1,N);
2471 for (i=1; i<nb; i++) {
2472 for (j=1; j<nbv; j++) {
2474 myTool->AddFace(NodesC.Value(i,j), NodesC.Value(i+1,j),
2475 NodesC.Value(i+1,j+1), NodesC.Value(i,j+1));
2476 if (F) meshDS->SetMeshElementOnShape(F, geomFaceID);
2480 } // end Multiple Reduce implementation
2481 else { // Simple Reduce (!MultipleReduce)
2482 //=========================================================
2485 // it is a base case => not shift quad
2486 //ShiftQuad(quad,0,true);
2489 // we have to shift quad on 2
2490 ShiftQuad(quad,2,true);
2495 // we have to shift quad on 1
2496 ShiftQuad(quad,1,true);
2499 // we have to shift quad on 3
2500 ShiftQuad(quad,3,true);
2504 nb = quad->side[0]->NbPoints();
2505 nr = quad->side[1]->NbPoints();
2506 nt = quad->side[2]->NbPoints();
2507 nl = quad->side[3]->NbPoints();
2509 // number of rows and columns
2510 int nrows = nr - 1; // and also == nl - 1
2511 int ncol_top = nt - 1;
2512 int ncol_bot = nb - 1;
2513 int npair_top = ncol_top / 2;
2514 // maximum number of bottom elements for "linear" simple reduce
2515 int max_lin = ncol_top + npair_top * 2 * nrows;
2516 // maximum number of bottom elements for "tree" simple reduce
2517 //int max_tree = npair_top * pow(2, nrows + 1);
2519 //if (ncol_bot > max_tree)
2520 // MultipleReduce = true;
2522 const vector<UVPtStruct>& uv_eb = quad->side[0]->GetUVPtStruct(true,0);
2523 const vector<UVPtStruct>& uv_er = quad->side[1]->GetUVPtStruct(false,1);
2524 const vector<UVPtStruct>& uv_et = quad->side[2]->GetUVPtStruct(true,1);
2525 const vector<UVPtStruct>& uv_el = quad->side[3]->GetUVPtStruct(false,0);
2527 if (uv_eb.size() != nb || uv_er.size() != nr || uv_et.size() != nt || uv_el.size() != nl)
2528 return error(COMPERR_BAD_INPUT_MESH);
2530 // arrays for normalized params
2531 TColStd_SequenceOfReal npb, npr, npt, npl;
2532 for (j = 0; j < nb; j++) {
2533 npb.Append(uv_eb[j].normParam);
2535 for (i = 0; i < nr; i++) {
2536 npr.Append(uv_er[i].normParam);
2538 for (j = 0; j < nt; j++) {
2539 npt.Append(uv_et[j].normParam);
2541 for (i = 0; i < nl; i++) {
2542 npl.Append(uv_el[i].normParam);
2545 // We will ajust new points to this grid
2546 if (!SetNormalizedGrid(aMesh, aShape, quad))
2550 gp_XY a0 (uv_eb.front().u, uv_eb.front().v);
2551 gp_XY a1 (uv_eb.back().u, uv_eb.back().v);
2552 gp_XY a2 (uv_et.back().u, uv_et.back().v);
2553 gp_XY a3 (uv_et.front().u, uv_et.front().v);
2554 //=========================================================
2556 TColStd_SequenceOfInteger curr_base, next_base;
2557 TColStd_SequenceOfReal curr_par_u, curr_par_v;
2558 TColStd_SequenceOfReal next_par_u, next_par_v;
2559 StdMeshers_Array2OfNode NodesBRD (1,nb, 1,nr);
2560 for (j = 1; j <= nb; j++) {
2561 NodesBRD.SetValue(j, 1, uv_eb[j - 1].node); // bottom
2562 curr_base.Append(j);
2563 next_base.Append(-1);
2564 curr_par_u.Append(uv_eb[j-1].u);
2565 curr_par_v.Append(uv_eb[j-1].v);
2566 next_par_u.Append(0.);
2567 next_par_v.Append(0.);
2569 for (j = 1; j <= nt; j++) {
2570 NodesBRD.SetValue(j, nr, uv_et[j - 1].node); // top
2573 int curr_base_len = nb;
2574 int next_base_len = 0;
2576 if (ncol_bot > max_lin) {
2577 // "tree" simple reduce 2->4->8->16->32->...
2579 // .---------------.---------------.---------------.---------------. nr
2580 // | \ | / | \ | / |
2581 // | \ .-------.-------. / | \ .-------.-------. / |
2582 // | | | | | | | | |
2583 // .-------.-------.-------.-------.-------.-------.-------.-------.
2584 // |\ | /|\ | /|\ | /|\ | /|
2585 // | \.---.---./ | \.---.---./ | \.---.---./ | \.---.---./ | i
2586 // | | | | | | | | | | | | | | | | |
2587 // .---.---.---.---.---.---.---.---.---.---.---.---.---.---.---.---.
2588 // |\ | /|\ | /|\ | /|\ | /|\ | /|\ | /|\ | /|\ | /|
2589 // | .-.-. | .-.-. | .-.-. | .-.-. | .-.-. | .-.-. | .-.-. | .-.-. |
2590 // | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
2591 // .-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-. 1
2594 for (i = 1; i < nr; i++) { // layer by layer
2596 NodesBRD.SetValue(1, i+1, uv_el[i].node);
2597 next_base.SetValue(++next_base_len, 1);
2599 NodesBRD.SetValue(nb, i+1, uv_er[i].node);
2601 next_par_u.SetValue(next_base_len, uv_el[i].u);
2602 next_par_v.SetValue(next_base_len, uv_el[i].v);
2604 // to stop reducing, if number of nodes reaches nt
2605 int delta = curr_base_len - nt;
2607 //double du = uv_er[i].u - uv_el[i].u;
2608 //double dv = uv_er[i].v - uv_el[i].v;
2610 // to calculate normalized parameter, we must know number of points in next layer
2611 int nb_four = (curr_base_len - 1) / 4;
2612 int nb_next = nb_four*2 + (curr_base_len - nb_four*4);
2613 if (nb_next < nt) nb_next = nt;
2615 for (j = 1; j + 4 <= curr_base_len && delta > 0; j += 4, delta -= 2) {
2616 // add one "HH": nodes a,b,c,d,e and faces 1,2,3,4,5,6
2618 // .-----a-----b i + 1
2631 const SMDS_MeshNode* Na;
2633 next_base.SetValue(next_base_len, curr_base.Value(j + 2));
2634 if (i + 1 == nr) { // top
2635 Na = uv_et[next_base_len - 1].node;
2636 NodesBRD.SetValue(next_base.Value(next_base_len), i + 1, Na);
2637 u = uv_et[next_base_len - 1].u;
2638 v = uv_et[next_base_len - 1].v;
2641 //double norm_par = double(next_base_len - 1)/double(nb_next - 1);
2642 //u = uv_el[i].u + du * norm_par;
2643 //v = uv_el[i].v + dv * norm_par;
2645 double rel = double(next_base_len - 1) * double(nt - 1) / double(nb_next - 1) + 1;
2646 int nearest_node_j = (int)rel;
2647 rel -= nearest_node_j;
2648 int ij = (i + 1 - 1) * nt + (nearest_node_j - 1);
2649 double u1 = quad->uv_grid[ij].u;
2650 double v1 = quad->uv_grid[ij].v;
2651 double u2 = quad->uv_grid[ij + 1].u;
2652 double v2 = quad->uv_grid[ij + 1].v;
2653 double duj = (u2 - u1) * rel;
2654 double dvj = (v2 - v1) * rel;
2658 //u = uv_el[i].u + du*npb.Value(curr_base.Value(j + 2));
2659 //v = uv_el[i].v + dv*npb.Value(curr_base.Value(j + 2));
2660 gp_Pnt P = S->Value(u,v);
2661 SMDS_MeshNode* Na1 = meshDS->AddNode(P.X(), P.Y(), P.Z());
2662 meshDS->SetNodeOnFace(Na1, geomFaceID, u, v);
2663 NodesBRD.SetValue(next_base.Value(next_base_len), i + 1, Na1);
2666 next_par_u.SetValue(next_base_len, u);
2667 next_par_v.SetValue(next_base_len, v);
2670 const SMDS_MeshNode* Nb;
2672 next_base.SetValue(next_base_len, curr_base.Value(j + 4));
2673 if (i + 1 == nr) { // top
2674 Nb = uv_et[next_base_len - 1].node;
2675 NodesBRD.SetValue(next_base.Value(next_base_len), i + 1, Nb);
2676 u = uv_et[next_base_len - 1].u;
2677 v = uv_et[next_base_len - 1].v;
2679 else if (j + 4 == curr_base_len) { // right
2680 Nb = NodesBRD.Value(next_base.Value(next_base_len), i + 1);
2685 //double norm_par = double(next_base_len - 1)/double(nb_next - 1);
2686 //u = uv_el[i].u + du * norm_par;
2687 //v = uv_el[i].v + dv * norm_par;
2689 double rel = double(next_base_len - 1) * double(nt - 1) / double(nb_next - 1) + 1;
2690 int nearest_node_j = (int)rel;
2691 rel -= nearest_node_j;
2692 int ij = (i + 1 - 1) * nt + (nearest_node_j - 1);
2693 double u1 = quad->uv_grid[ij].u;
2694 double v1 = quad->uv_grid[ij].v;
2695 double u2 = quad->uv_grid[ij + 1].u;
2696 double v2 = quad->uv_grid[ij + 1].v;
2697 double duj = (u2 - u1) * rel;
2698 double dvj = (v2 - v1) * rel;
2702 //u = uv_el[i].u + du*npb.Value(curr_base.Value(j + 4));
2703 //v = uv_el[i].v + dv*npb.Value(curr_base.Value(j + 4));
2704 gp_Pnt P = S->Value(u,v);
2705 SMDS_MeshNode* Nb1 = meshDS->AddNode(P.X(), P.Y(), P.Z());
2706 meshDS->SetNodeOnFace(Nb1, geomFaceID, u, v);
2707 NodesBRD.SetValue(next_base.Value(next_base_len), i + 1, Nb1);
2710 next_par_u.SetValue(next_base_len, u);
2711 next_par_v.SetValue(next_base_len, v);
2714 u = (curr_par_u.Value(j + 2) + next_par_u.Value(next_base_len - 2)) / 2.0;
2715 v = (curr_par_v.Value(j + 2) + next_par_v.Value(next_base_len - 2)) / 2.0;
2716 gp_Pnt P = S->Value(u,v);
2717 SMDS_MeshNode* Nc = meshDS->AddNode(P.X(), P.Y(), P.Z());
2718 meshDS->SetNodeOnFace(Nc, geomFaceID, u, v);
2721 u = (curr_par_u.Value(j + 2) + next_par_u.Value(next_base_len - 1)) / 2.0;
2722 v = (curr_par_v.Value(j + 2) + next_par_v.Value(next_base_len - 1)) / 2.0;
2724 SMDS_MeshNode* Nd = meshDS->AddNode(P.X(), P.Y(), P.Z());
2725 meshDS->SetNodeOnFace(Nd, geomFaceID, u, v);
2728 u = (curr_par_u.Value(j + 2) + next_par_u.Value(next_base_len)) / 2.0;
2729 v = (curr_par_v.Value(j + 2) + next_par_v.Value(next_base_len)) / 2.0;
2731 SMDS_MeshNode* Ne = meshDS->AddNode(P.X(), P.Y(), P.Z());
2732 meshDS->SetNodeOnFace(Ne, geomFaceID, u, v);
2735 SMDS_MeshFace* F1 = myTool->AddFace(NodesBRD.Value(curr_base.Value(j + 0), i),
2736 NodesBRD.Value(curr_base.Value(j + 1), i),
2738 NodesBRD.Value(next_base.Value(next_base_len - 2), i + 1));
2739 if (F1) meshDS->SetMeshElementOnShape(F1, geomFaceID);
2741 SMDS_MeshFace* F2 = myTool->AddFace(NodesBRD.Value(curr_base.Value(j + 1), i),
2742 NodesBRD.Value(curr_base.Value(j + 2), i),
2744 if (F2) meshDS->SetMeshElementOnShape(F2, geomFaceID);
2746 SMDS_MeshFace* F3 = myTool->AddFace(NodesBRD.Value(curr_base.Value(j + 2), i),
2747 NodesBRD.Value(curr_base.Value(j + 3), i),
2749 if (F3) meshDS->SetMeshElementOnShape(F3, geomFaceID);
2751 SMDS_MeshFace* F4 = myTool->AddFace(NodesBRD.Value(curr_base.Value(j + 3), i),
2752 NodesBRD.Value(curr_base.Value(j + 4), i),
2754 if (F4) meshDS->SetMeshElementOnShape(F4, geomFaceID);
2756 SMDS_MeshFace* F5 = myTool->AddFace(Nc, Nd, Na,
2757 NodesBRD.Value(next_base.Value(next_base_len - 2), i + 1));
2758 if (F5) meshDS->SetMeshElementOnShape(F5, geomFaceID);
2760 SMDS_MeshFace* F6 = myTool->AddFace(Nd, Ne, Nb, Na);
2761 if (F6) meshDS->SetMeshElementOnShape(F6, geomFaceID);
2764 // not reduced side elements (if any)
2765 for (; j < curr_base_len; j++) {
2767 const SMDS_MeshNode* Nf;
2769 next_base.SetValue(++next_base_len, curr_base.Value(j + 1));
2770 if (i + 1 == nr) { // top
2771 Nf = uv_et[next_base_len - 1].node;
2772 NodesBRD.SetValue(next_base.Value(next_base_len), i + 1, Nf);
2773 u = uv_et[next_base_len - 1].u;
2774 v = uv_et[next_base_len - 1].v;
2776 else if (j + 1 == curr_base_len) { // right
2777 Nf = NodesBRD.Value(next_base.Value(next_base_len), i + 1);
2782 //double norm_par = double(next_base_len - 1)/double(nb_next - 1);
2783 //u = uv_el[i].u + du * norm_par;
2784 //v = uv_el[i].v + dv * norm_par;
2786 double rel = double(next_base_len - 1) * double(nt - 1) / double(nb_next - 1) + 1;
2787 int nearest_node_j = (int)rel;
2788 rel -= nearest_node_j;
2789 int ij = (i + 1 - 1) * nt + (nearest_node_j - 1);
2790 double u1 = quad->uv_grid[ij].u;
2791 double v1 = quad->uv_grid[ij].v;
2792 double u2 = quad->uv_grid[ij + 1].u;
2793 double v2 = quad->uv_grid[ij + 1].v;
2794 double duj = (u2 - u1) * rel;
2795 double dvj = (v2 - v1) * rel;
2799 //u = uv_el[i].u + du*npb.Value(curr_base.Value(j + 1));
2800 //v = uv_el[i].v + dv*npb.Value(curr_base.Value(j + 1));
2801 gp_Pnt P = S->Value(u,v);
2802 SMDS_MeshNode* Nf1 = meshDS->AddNode(P.X(), P.Y(), P.Z());
2803 meshDS->SetNodeOnFace(Nf1, geomFaceID, u, v);
2804 NodesBRD.SetValue(next_base.Value(next_base_len), i + 1, Nf1);
2807 next_par_u.SetValue(next_base_len, u);
2808 next_par_v.SetValue(next_base_len, v);
2809 SMDS_MeshFace* F1 = myTool->AddFace(NodesBRD.Value(curr_base.Value(j), i),
2810 NodesBRD.Value(curr_base.Value(j + 1), i),
2811 NodesBRD.Value(next_base.Value(next_base_len), i + 1),
2812 NodesBRD.Value(next_base.Value(next_base_len - 1), i + 1));
2813 if (F1) meshDS->SetMeshElementOnShape(F1, geomFaceID);
2816 curr_base_len = next_base_len;
2817 curr_base = next_base;
2818 curr_par_u = next_par_u;
2819 curr_par_v = next_par_v;
2822 } // end "tree" simple reduce
2824 // "linear" simple reduce 4->8->12->16 (3 steps)
2826 // .---------------.---------------.---------------.---------------. nr
2827 // | \ | / | \ | / |
2828 // | \ .-------.-------. / | \ .-------.-------. / |
2829 // | | | | | | | | |
2830 // .-------.-------.-------.-------.-------.-------.-------.-------.
2831 // | / \ | / \ | / \ | / \ |
2832 // | / \.----.----./ \ | / \.----.----./ \ | i
2833 // | / | | | \ | / | | | \ |
2834 // .-----.----.----.----.----.-----.-----.----.----.----.----.-----.
2835 // | / / \ | / \ \ | / / \ | / \ \ |
2836 // | / / .-.-. \ \ | / / .-.-. \ \ |
2837 // | / / / | \ \ \ | / / / | \ \ \ |
2838 // .---.---.---.---.---.---.---.---.---.---.---.---.---.---.---.---. 1
2841 // nt = 5, nb = 7, nr = 4
2842 //int delta_all = 2;
2843 //int delta_one_col = 6;
2845 //int remainder = 2;
2846 //if (remainder > 0) nb_col++;
2848 //int free_left = 1;
2850 //int free_middle = 4;
2852 int delta_all = nb - nt;
2853 int delta_one_col = (nr - 1) * 2;
2854 int nb_col = delta_all / delta_one_col;
2855 int remainder = delta_all - nb_col * delta_one_col;
2856 if (remainder > 0) {
2859 int free_left = ((nt - 1) - nb_col * 2) / 2;
2860 free_left += nr - 2;
2861 int free_middle = (nr - 2) * 2;
2862 if (remainder > 0 && nb_col == 1) {
2863 int nb_rows_short_col = remainder / 2;
2864 int nb_rows_thrown = (nr - 1) - nb_rows_short_col;
2865 free_left -= nb_rows_thrown;
2868 // nt = 5, nb = 17, nr = 4
2869 //int delta_all = 12;
2870 //int delta_one_col = 6;
2872 //int remainder = 0;
2873 //int free_left = 2;
2874 //int free_middle = 4;
2876 for (i = 1; i < nr; i++, free_middle -= 2, free_left -= 1) { // layer by layer
2878 NodesBRD.SetValue(1, i+1, uv_el[i].node);
2879 next_base.SetValue(++next_base_len, 1);
2881 NodesBRD.SetValue(nb, i+1, uv_er[i].node);
2884 next_par_u.SetValue(next_base_len, uv_el[i].u);
2885 next_par_v.SetValue(next_base_len, uv_el[i].v);
2887 // to calculate normalized parameter, we must know number of points in next layer
2888 int nb_next = curr_base_len - nb_col * 2;
2889 if (remainder > 0 && i > remainder / 2)
2890 // take into account short "column"
2892 if (nb_next < nt) nb_next = nt;
2894 // not reduced left elements
2895 for (j = 1; j <= free_left; j++) {
2897 const SMDS_MeshNode* Nf;
2899 next_base.SetValue(++next_base_len, curr_base.Value(j + 1));
2900 if (i + 1 == nr) { // top
2901 Nf = uv_et[next_base_len - 1].node;
2902 NodesBRD.SetValue(next_base.Value(next_base_len), i + 1, Nf);
2903 u = uv_et[next_base_len - 1].u;
2904 v = uv_et[next_base_len - 1].v;
2908 double rel = double(next_base_len - 1) * double(nt - 1) / double(nb_next - 1) + 1;
2909 int nearest_node_j = (int)rel;
2910 rel -= nearest_node_j;
2911 int ij = (i + 1 - 1) * nt + (nearest_node_j - 1);
2912 double u1 = quad->uv_grid[ij].u;
2913 double v1 = quad->uv_grid[ij].v;
2914 double u2 = quad->uv_grid[ij + 1].u;
2915 double v2 = quad->uv_grid[ij + 1].v;
2916 double duj = (u2 - u1) * rel;
2917 double dvj = (v2 - v1) * rel;
2921 gp_Pnt P = S->Value(u,v);
2922 SMDS_MeshNode* Nf1 = meshDS->AddNode(P.X(), P.Y(), P.Z());
2923 meshDS->SetNodeOnFace(Nf1, geomFaceID, u, v);
2924 NodesBRD.SetValue(next_base.Value(next_base_len), i + 1, Nf1);
2927 next_par_u.SetValue(next_base_len, u);
2928 next_par_v.SetValue(next_base_len, v);
2929 SMDS_MeshFace* F1 = myTool->AddFace(NodesBRD.Value(curr_base.Value(j), i),
2930 NodesBRD.Value(curr_base.Value(j + 1), i),
2931 NodesBRD.Value(next_base.Value(next_base_len), i + 1),
2932 NodesBRD.Value(next_base.Value(next_base_len - 1), i + 1));
2933 if (F1) meshDS->SetMeshElementOnShape(F1, geomFaceID);
2936 for (int icol = 1; icol <= nb_col; icol++) {
2938 if (remainder > 0 && icol == nb_col && i > remainder / 2)
2939 // stop short "column"
2942 // add one "HH": nodes a,b,c,d,e and faces 1,2,3,4,5,6
2944 // .-----a-----b i + 1
2957 const SMDS_MeshNode* Na;
2959 next_base.SetValue(next_base_len, curr_base.Value(j + 2));
2960 if (i + 1 == nr) { // top
2961 Na = uv_et[next_base_len - 1].node;
2962 NodesBRD.SetValue(next_base.Value(next_base_len), i + 1, Na);
2963 u = uv_et[next_base_len - 1].u;
2964 v = uv_et[next_base_len - 1].v;
2968 double rel = double(next_base_len - 1) * double(nt - 1) / double(nb_next - 1) + 1;
2969 int nearest_node_j = (int)rel;
2970 rel -= nearest_node_j;
2971 int ij = (i + 1 - 1) * nt + (nearest_node_j - 1);
2972 double u1 = quad->uv_grid[ij].u;
2973 double v1 = quad->uv_grid[ij].v;
2974 double u2 = quad->uv_grid[ij + 1].u;
2975 double v2 = quad->uv_grid[ij + 1].v;
2976 double duj = (u2 - u1) * rel;
2977 double dvj = (v2 - v1) * rel;
2981 gp_Pnt P = S->Value(u,v);
2982 SMDS_MeshNode* Na1 = meshDS->AddNode(P.X(), P.Y(), P.Z());
2983 meshDS->SetNodeOnFace(Na1, geomFaceID, u, v);
2984 NodesBRD.SetValue(next_base.Value(next_base_len), i + 1, Na1);
2987 next_par_u.SetValue(next_base_len, u);
2988 next_par_v.SetValue(next_base_len, v);
2991 const SMDS_MeshNode* Nb;
2993 next_base.SetValue(next_base_len, curr_base.Value(j + 4));
2994 if (i + 1 == nr) { // top
2995 Nb = uv_et[next_base_len - 1].node;
2996 NodesBRD.SetValue(next_base.Value(next_base_len), i + 1, Nb);
2997 u = uv_et[next_base_len - 1].u;
2998 v = uv_et[next_base_len - 1].v;
3000 else if (j + 4 == curr_base_len) { // right
3001 Nb = NodesBRD.Value(next_base.Value(next_base_len), i + 1);
3007 double rel = double(next_base_len - 1) * double(nt - 1) / double(nb_next - 1) + 1;
3008 int nearest_node_j = (int)rel;
3009 rel -= nearest_node_j;
3010 int ij = (i + 1 - 1) * nt + (nearest_node_j - 1);
3011 double u1 = quad->uv_grid[ij].u;
3012 double v1 = quad->uv_grid[ij].v;
3013 double u2 = quad->uv_grid[ij + 1].u;
3014 double v2 = quad->uv_grid[ij + 1].v;
3015 double duj = (u2 - u1) * rel;
3016 double dvj = (v2 - v1) * rel;
3020 gp_Pnt P = S->Value(u,v);
3021 SMDS_MeshNode* Nb1 = meshDS->AddNode(P.X(), P.Y(), P.Z());
3022 meshDS->SetNodeOnFace(Nb1, geomFaceID, u, v);
3023 NodesBRD.SetValue(next_base.Value(next_base_len), i + 1, Nb1);
3026 next_par_u.SetValue(next_base_len, u);
3027 next_par_v.SetValue(next_base_len, v);
3030 u = (curr_par_u.Value(j + 2) + next_par_u.Value(next_base_len - 2)) / 2.0;
3031 v = (curr_par_v.Value(j + 2) + next_par_v.Value(next_base_len - 2)) / 2.0;
3032 gp_Pnt P = S->Value(u,v);
3033 SMDS_MeshNode* Nc = meshDS->AddNode(P.X(), P.Y(), P.Z());
3034 meshDS->SetNodeOnFace(Nc, geomFaceID, u, v);
3037 u = (curr_par_u.Value(j + 2) + next_par_u.Value(next_base_len - 1)) / 2.0;
3038 v = (curr_par_v.Value(j + 2) + next_par_v.Value(next_base_len - 1)) / 2.0;
3040 SMDS_MeshNode* Nd = meshDS->AddNode(P.X(), P.Y(), P.Z());
3041 meshDS->SetNodeOnFace(Nd, geomFaceID, u, v);
3044 u = (curr_par_u.Value(j + 2) + next_par_u.Value(next_base_len)) / 2.0;
3045 v = (curr_par_v.Value(j + 2) + next_par_v.Value(next_base_len)) / 2.0;
3047 SMDS_MeshNode* Ne = meshDS->AddNode(P.X(), P.Y(), P.Z());
3048 meshDS->SetNodeOnFace(Ne, geomFaceID, u, v);
3051 SMDS_MeshFace* F1 = myTool->AddFace(NodesBRD.Value(curr_base.Value(j + 0), i),
3052 NodesBRD.Value(curr_base.Value(j + 1), i),
3054 NodesBRD.Value(next_base.Value(next_base_len - 2), i + 1));
3055 if (F1) meshDS->SetMeshElementOnShape(F1, geomFaceID);
3057 SMDS_MeshFace* F2 = myTool->AddFace(NodesBRD.Value(curr_base.Value(j + 1), i),
3058 NodesBRD.Value(curr_base.Value(j + 2), i),
3060 if (F2) meshDS->SetMeshElementOnShape(F2, geomFaceID);
3062 SMDS_MeshFace* F3 = myTool->AddFace(NodesBRD.Value(curr_base.Value(j + 2), i),
3063 NodesBRD.Value(curr_base.Value(j + 3), i),
3065 if (F3) meshDS->SetMeshElementOnShape(F3, geomFaceID);
3067 SMDS_MeshFace* F4 = myTool->AddFace(NodesBRD.Value(curr_base.Value(j + 3), i),
3068 NodesBRD.Value(curr_base.Value(j + 4), i),
3070 if (F4) meshDS->SetMeshElementOnShape(F4, geomFaceID);
3072 SMDS_MeshFace* F5 = myTool->AddFace(Nc, Nd, Na,
3073 NodesBRD.Value(next_base.Value(next_base_len - 2), i + 1));
3074 if (F5) meshDS->SetMeshElementOnShape(F5, geomFaceID);
3076 SMDS_MeshFace* F6 = myTool->AddFace(Nd, Ne, Nb, Na);
3077 if (F6) meshDS->SetMeshElementOnShape(F6, geomFaceID);
3081 // not reduced middle elements
3082 if (icol < nb_col) {
3083 if (remainder > 0 && icol == nb_col - 1 && i > remainder / 2)
3084 // pass middle elements before stopped short "column"
3087 int free_add = free_middle;
3088 if (remainder > 0 && icol == nb_col - 1)
3089 // next "column" is short
3090 free_add -= (nr - 1) - (remainder / 2);
3092 for (int imiddle = 1; imiddle <= free_add; imiddle++) {
3093 // f (i + 1, j + imiddle)
3094 const SMDS_MeshNode* Nf;
3096 next_base.SetValue(++next_base_len, curr_base.Value(j + imiddle));
3097 if (i + 1 == nr) { // top
3098 Nf = uv_et[next_base_len - 1].node;
3099 NodesBRD.SetValue(next_base.Value(next_base_len), i + 1, Nf);
3100 u = uv_et[next_base_len - 1].u;
3101 v = uv_et[next_base_len - 1].v;
3103 else if (j + imiddle == curr_base_len) { // right
3104 Nf = NodesBRD.Value(next_base.Value(next_base_len), i + 1);
3110 double rel = double(next_base_len - 1) * double(nt - 1) / double(nb_next - 1) + 1;
3111 int nearest_node_j = (int)rel;
3112 rel -= nearest_node_j;
3113 int ij = (i + 1 - 1) * nt + (nearest_node_j - 1);
3114 double u1 = quad->uv_grid[ij].u;
3115 double v1 = quad->uv_grid[ij].v;
3116 double u2 = quad->uv_grid[ij + 1].u;
3117 double v2 = quad->uv_grid[ij + 1].v;
3118 double duj = (u2 - u1) * rel;
3119 double dvj = (v2 - v1) * rel;
3123 gp_Pnt P = S->Value(u,v);
3124 SMDS_MeshNode* Nf1 = meshDS->AddNode(P.X(), P.Y(), P.Z());
3125 meshDS->SetNodeOnFace(Nf1, geomFaceID, u, v);
3126 NodesBRD.SetValue(next_base.Value(next_base_len), i + 1, Nf1);
3129 next_par_u.SetValue(next_base_len, u);
3130 next_par_v.SetValue(next_base_len, v);
3131 SMDS_MeshFace* F1 = myTool->AddFace(NodesBRD.Value(curr_base.Value(j - 1 + imiddle), i),
3132 NodesBRD.Value(curr_base.Value(j + imiddle), i),
3133 NodesBRD.Value(next_base.Value(next_base_len), i + 1),
3134 NodesBRD.Value(next_base.Value(next_base_len - 1), i + 1));
3135 if (F1) meshDS->SetMeshElementOnShape(F1, geomFaceID);
3141 // not reduced right elements
3142 for (; j < curr_base_len; j++) {
3144 const SMDS_MeshNode* Nf;
3146 next_base.SetValue(++next_base_len, curr_base.Value(j + 1));
3147 if (i + 1 == nr) { // top
3148 Nf = uv_et[next_base_len - 1].node;
3149 NodesBRD.SetValue(next_base.Value(next_base_len), i + 1, Nf);
3150 u = uv_et[next_base_len - 1].u;
3151 v = uv_et[next_base_len - 1].v;
3153 else if (j + 1 == curr_base_len) { // right
3154 Nf = NodesBRD.Value(next_base.Value(next_base_len), i + 1);
3160 double rel = double(next_base_len - 1) * double(nt - 1) / double(nb_next - 1) + 1;
3161 int nearest_node_j = (int)rel;
3162 rel -= nearest_node_j;
3163 int ij = (i + 1 - 1) * nt + (nearest_node_j - 1);
3164 double u1 = quad->uv_grid[ij].u;
3165 double v1 = quad->uv_grid[ij].v;
3166 double u2 = quad->uv_grid[ij + 1].u;
3167 double v2 = quad->uv_grid[ij + 1].v;
3168 double duj = (u2 - u1) * rel;
3169 double dvj = (v2 - v1) * rel;
3173 gp_Pnt P = S->Value(u,v);
3174 SMDS_MeshNode* Nf1 = meshDS->AddNode(P.X(), P.Y(), P.Z());
3175 meshDS->SetNodeOnFace(Nf1, geomFaceID, u, v);
3176 NodesBRD.SetValue(next_base.Value(next_base_len), i + 1, Nf1);
3179 next_par_u.SetValue(next_base_len, u);
3180 next_par_v.SetValue(next_base_len, v);
3181 SMDS_MeshFace* F1 = myTool->AddFace(NodesBRD.Value(curr_base.Value(j), i),
3182 NodesBRD.Value(curr_base.Value(j + 1), i),
3183 NodesBRD.Value(next_base.Value(next_base_len), i + 1),
3184 NodesBRD.Value(next_base.Value(next_base_len - 1), i + 1));
3185 if (F1) meshDS->SetMeshElementOnShape(F1, geomFaceID);
3188 curr_base_len = next_base_len;
3189 curr_base = next_base;
3190 curr_par_u = next_par_u;
3191 curr_par_v = next_par_v;
3194 } // end "linear" simple reduce
3195 } // end Simple Reduce implementation