Salome HOME
Merge from OCC_development_generic_2006
[modules/smesh.git] / src / StdMeshers / StdMeshers_Quadrangle_2D.cxx
1 //  SMESH SMESH : implementaion of SMESH idl descriptions
2 //
3 //  Copyright (C) 2003  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 //  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS 
5 // 
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. 
10 // 
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. 
15 // 
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 
19 // 
20 //  See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
21 //
22 //
23 //
24 //  File   : StdMeshers_Quadrangle_2D.cxx
25 //           Moved here from SMESH_Quadrangle_2D.cxx
26 //  Author : Paul RASCLE, EDF
27 //  Module : SMESH
28 //  $Header$
29
30 using namespace std;
31 #include "StdMeshers_Quadrangle_2D.hxx"
32 #include "SMESH_Gen.hxx"
33 #include "SMESH_Mesh.hxx"
34 #include "SMESH_subMesh.hxx"
35
36 #include "SMDS_MeshElement.hxx"
37 #include "SMDS_MeshNode.hxx"
38 #include "SMDS_EdgePosition.hxx"
39 #include "SMDS_FacePosition.hxx"
40
41 #include <BRep_Tool.hxx>
42 #include <BRepTools.hxx>
43 #include <BRepTools_WireExplorer.hxx>
44
45 #include <Geom_Surface.hxx>
46 #include <Geom_Curve.hxx>
47 #include <Geom2d_Curve.hxx>
48 #include <GeomAdaptor_Curve.hxx>
49 #include <GCPnts_UniformAbscissa.hxx>
50
51 #include <Precision.hxx>
52 #include <gp_Pnt2d.hxx>
53 #include <TColStd_ListIteratorOfListOfInteger.hxx>
54 #include <TColStd_SequenceOfReal.hxx>
55 #include <TColgp_SequenceOfXY.hxx>
56
57 #include "utilities.h"
58 #include "Utils_ExceptHandlers.hxx"
59
60 #ifndef StdMeshers_Array2OfNode_HeaderFile
61 #define StdMeshers_Array2OfNode_HeaderFile
62 typedef const SMDS_MeshNode* SMDS_MeshNodePtr;
63 #include <NCollection_DefineArray2.hxx>
64 DEFINE_BASECOLLECTION (StdMeshers_BaseCollectionNodePtr, SMDS_MeshNodePtr)
65 DEFINE_ARRAY2(StdMeshers_Array2OfNode,
66               StdMeshers_BaseCollectionNodePtr, SMDS_MeshNodePtr)
67 #endif
68
69
70 //=============================================================================
71 /*!
72  *  
73  */
74 //=============================================================================
75
76 StdMeshers_Quadrangle_2D::StdMeshers_Quadrangle_2D (int hypId, int studyId, SMESH_Gen* gen)
77      : SMESH_2D_Algo(hypId, studyId, gen)
78 {
79   MESSAGE("StdMeshers_Quadrangle_2D::StdMeshers_Quadrangle_2D");
80   _name = "Quadrangle_2D";
81   _shapeType = (1 << TopAbs_FACE);
82   _compatibleHypothesis.push_back("QuadranglePreference");
83 }
84
85 //=============================================================================
86 /*!
87  *  
88  */
89 //=============================================================================
90
91 StdMeshers_Quadrangle_2D::~StdMeshers_Quadrangle_2D()
92 {
93   MESSAGE("StdMeshers_Quadrangle_2D::~StdMeshers_Quadrangle_2D");
94 }
95
96 //=============================================================================
97 /*!
98  *  
99  */
100 //=============================================================================
101
102 bool StdMeshers_Quadrangle_2D::CheckHypothesis
103                          (SMESH_Mesh&                          aMesh,
104                           const TopoDS_Shape&                  aShape,
105                           SMESH_Hypothesis::Hypothesis_Status& aStatus)
106 {
107   bool isOk = true;
108   aStatus = SMESH_Hypothesis::HYP_OK;
109
110   // there is only one compatible Hypothesis so far
111   const list <const SMESHDS_Hypothesis * >&hyps = GetUsedHypothesis(aMesh, aShape);
112   myQuadranglePreference = hyps.size() > 0;
113
114   return isOk;
115 }
116
117 //=============================================================================
118 /*!
119  *  
120  */
121 //=============================================================================
122
123 bool StdMeshers_Quadrangle_2D::Compute (SMESH_Mesh& aMesh,
124                                         const TopoDS_Shape& aShape) throw (SALOME_Exception)
125 {
126   Unexpect aCatch(SalomeException);
127   //MESSAGE("StdMeshers_Quadrangle_2D::Compute");
128   SMESHDS_Mesh * meshDS = aMesh.GetMeshDS();
129   aMesh.GetSubMesh(aShape);
130
131   //FaceQuadStruct *quad = CheckAnd2Dcompute(aMesh, aShape);
132   FaceQuadStruct* quad = CheckNbEdges(aMesh, aShape);
133
134   if (!quad)
135     return false;
136
137   if(myQuadranglePreference) {
138     int n1 = quad->nbPts[0];
139     int n2 = quad->nbPts[1];
140     int n3 = quad->nbPts[2];
141     int n4 = quad->nbPts[3];
142     int nfull = n1+n2+n3+n4;
143     int ntmp = nfull/2;
144     ntmp = ntmp*2;
145     if( nfull==ntmp && ( (n1!=n3) || (n2!=n4) ) ) {
146       // special path for using only quandrangle faces
147       return ComputeQuadPref(aMesh, aShape, quad);
148     }
149   }
150
151   // set normalized grid on unit square in parametric domain
152   SetNormalizedGrid(aMesh, aShape, quad);
153   if (!quad)
154     return false;
155
156   // --- compute 3D values on points, store points & quadrangles
157
158   int nbdown  = quad->nbPts[0];
159   int nbup    = quad->nbPts[2];
160
161   int nbright = quad->nbPts[1];
162   int nbleft  = quad->nbPts[3];
163
164   int nbhoriz  = Min(nbdown, nbup);
165   int nbvertic = Min(nbright, nbleft);
166
167   const TopoDS_Face& F = TopoDS::Face(aShape);
168   Handle(Geom_Surface) S = BRep_Tool::Surface(F);
169
170   // internal mesh nodes
171   int i, j, geomFaceID = meshDS->ShapeToIndex( F );
172   for (i = 1; i < nbhoriz - 1; i++) {
173     for (j = 1; j < nbvertic - 1; j++) {
174       int ij = j * nbhoriz + i;
175       double u = quad->uv_grid[ij].u;
176       double v = quad->uv_grid[ij].v;
177       gp_Pnt P = S->Value(u, v);
178       SMDS_MeshNode * node = meshDS->AddNode(P.X(), P.Y(), P.Z());
179       meshDS->SetNodeOnFace(node, geomFaceID, u, v);
180       quad->uv_grid[ij].node = node;
181     }
182   }
183
184   // mesh faces
185
186   //             [2]
187   //      --.--.--.--.--.--  nbvertic
188   //     |                 | ^
189   //     |                 | ^
190   // [3] |                 | ^ j  [1]
191   //     |                 | ^
192   //     |                 | ^
193   //      ---.----.----.---  0
194   //     0 > > > > > > > > nbhoriz
195   //              i
196   //             [0]
197
198   i = 0;
199   int ilow = 0;
200   int iup = nbhoriz - 1;
201   if (quad->isEdgeOut[3]) { ilow++; } else { if (quad->isEdgeOut[1]) iup--; }
202
203   int jlow = 0;
204   int jup = nbvertic - 1;
205   if (quad->isEdgeOut[0]) { jlow++; } else { if (quad->isEdgeOut[2]) jup--; }
206
207   // regular quadrangles
208   for (i = ilow; i < iup; i++) {
209     for (j = jlow; j < jup; j++) {
210       const SMDS_MeshNode *a, *b, *c, *d;
211       a = quad->uv_grid[j * nbhoriz + i].node;
212       b = quad->uv_grid[j * nbhoriz + i + 1].node;
213       c = quad->uv_grid[(j + 1) * nbhoriz + i + 1].node;
214       d = quad->uv_grid[(j + 1) * nbhoriz + i].node;
215       SMDS_MeshFace * face = meshDS->AddFace(a, b, c, d);
216       meshDS->SetMeshElementOnShape(face, geomFaceID);
217     }
218   }
219
220   UVPtStruct *uv_e0 = quad->uv_edges[0];
221   UVPtStruct *uv_e1 = quad->uv_edges[1];
222   UVPtStruct *uv_e2 = quad->uv_edges[2];
223   UVPtStruct *uv_e3 = quad->uv_edges[3];
224
225   double eps = Precision::Confusion();
226
227   // Boundary quadrangles
228
229   if (quad->isEdgeOut[0]) {
230     // Down edge is out
231     // 
232     // |___|___|___|___|___|___|
233     // |   |   |   |   |   |   |
234     // |___|___|___|___|___|___|
235     // |   |   |   |   |   |   |
236     // |___|___|___|___|___|___| __ first row of the regular grid
237     // .  .  .  .  .  .  .  .  . __ down edge nodes
238     // 
239     // >->->->->->->->->->->->-> -- direction of processing
240
241     int g = 0; // number of last processed node in the regular grid
242
243     // number of last node of the down edge to be processed
244     int stop = nbdown - 1;
245     // if right edge is out, we will stop at a node, previous to the last one
246     if (quad->isEdgeOut[1]) stop--;
247
248     // for each node of the down edge find nearest node
249     // in the first row of the regular grid and link them
250     for (i = 0; i < stop; i++) {
251       const SMDS_MeshNode *a, *b, *c, *d;
252       a = uv_e0[i].node;
253       b = uv_e0[i + 1].node;
254       gp_Pnt pb (b->X(), b->Y(), b->Z());
255
256       // find node c in the regular grid, which will be linked with node b
257       int near = g;
258       if (i == stop - 1) {
259         // right bound reached, link with the rightmost node
260         near = iup;
261         c = quad->uv_grid[nbhoriz + iup].node;
262       } else {
263         // find in the grid node c, nearest to the b
264         double mind = RealLast();
265         for (int k = g; k <= iup; k++) {
266
267           const SMDS_MeshNode *nk;
268           if (k < ilow) // this can be, if left edge is out
269             nk = uv_e3[1].node; // get node from the left edge
270           else
271             nk = quad->uv_grid[nbhoriz + k].node; // get one of middle nodes
272
273           gp_Pnt pnk (nk->X(), nk->Y(), nk->Z());
274           double dist = pb.Distance(pnk);
275           if (dist < mind - eps) {
276             c = nk;
277             near = k;
278             mind = dist;
279           } else {
280             break;
281           }
282         }
283       }
284
285       if (near == g) { // make triangle
286         SMDS_MeshFace* face = meshDS->AddFace(a, b, c);
287         meshDS->SetMeshElementOnShape(face, geomFaceID);
288       } else { // make quadrangle
289         if (near - 1 < ilow)
290           d = uv_e3[1].node;
291         else
292           d = quad->uv_grid[nbhoriz + near - 1].node;
293         SMDS_MeshFace* face = meshDS->AddFace(a, b, c, d);
294         meshDS->SetMeshElementOnShape(face, geomFaceID);
295
296         // if node d is not at position g - make additional triangles
297         if (near - 1 > g) {
298           for (int k = near - 1; k > g; k--) {
299             c = quad->uv_grid[nbhoriz + k].node;
300             if (k - 1 < ilow)
301               d = uv_e3[1].node;
302             else
303               d = quad->uv_grid[nbhoriz + k - 1].node;
304             SMDS_MeshFace* face = meshDS->AddFace(a, c, d);
305             meshDS->SetMeshElementOnShape(face, geomFaceID);
306           }
307         }
308         g = near;
309       }
310     }
311   } else {
312     if (quad->isEdgeOut[2]) {
313       // Up edge is out
314       // 
315       // <-<-<-<-<-<-<-<-<-<-<-<-< -- direction of processing
316       // 
317       // .  .  .  .  .  .  .  .  . __ up edge nodes
318       //  ___ ___ ___ ___ ___ ___  __ first row of the regular grid
319       // |   |   |   |   |   |   |
320       // |___|___|___|___|___|___|
321       // |   |   |   |   |   |   |
322       // |___|___|___|___|___|___|
323       // |   |   |   |   |   |   |
324
325       int g = nbhoriz - 1; // last processed node in the regular grid
326
327       int stop = 0;
328       // if left edge is out, we will stop at a second node
329       if (quad->isEdgeOut[3]) stop++;
330
331       // for each node of the up edge find nearest node
332       // in the first row of the regular grid and link them
333       for (i = nbup - 1; i > stop; i--) {
334         const SMDS_MeshNode *a, *b, *c, *d;
335         a = uv_e2[i].node;
336         b = uv_e2[i - 1].node;
337         gp_Pnt pb (b->X(), b->Y(), b->Z());
338
339         // find node c in the grid, which will be linked with node b
340         int near = g;
341         if (i == stop + 1) { // left bound reached, link with the leftmost node
342           c = quad->uv_grid[nbhoriz*(nbvertic - 2) + ilow].node;
343           near = ilow;
344         } else {
345           // find node c in the grid, nearest to the b
346           double mind = RealLast();
347           for (int k = g; k >= ilow; k--) {
348             const SMDS_MeshNode *nk;
349             if (k > iup)
350               nk = uv_e1[nbright - 2].node;
351             else
352               nk = quad->uv_grid[nbhoriz*(nbvertic - 2) + k].node;
353             gp_Pnt pnk (nk->X(), nk->Y(), nk->Z());
354             double dist = pb.Distance(pnk);
355             if (dist < mind - eps) {
356               c = nk;
357               near = k;
358               mind = dist;
359             } else {
360               break;
361             }
362           }
363         }
364
365         if (near == g) { // make triangle
366           SMDS_MeshFace* face = meshDS->AddFace(a, b, c);
367           meshDS->SetMeshElementOnShape(face, geomFaceID);
368         } else { // make quadrangle
369           if (near + 1 > iup)
370             d = uv_e1[nbright - 2].node;
371           else
372             d = quad->uv_grid[nbhoriz*(nbvertic - 2) + near + 1].node;
373           SMDS_MeshFace* face = meshDS->AddFace(a, b, c, d);
374           meshDS->SetMeshElementOnShape(face, geomFaceID);
375
376           if (near + 1 < g) { // if d not is at g - make additional triangles
377             for (int k = near + 1; k < g; k++) {
378               c = quad->uv_grid[nbhoriz*(nbvertic - 2) + k].node;
379               if (k + 1 > iup)
380                 d = uv_e1[nbright - 2].node;
381               else
382                 d = quad->uv_grid[nbhoriz*(nbvertic - 2) + k + 1].node;
383               SMDS_MeshFace* face = meshDS->AddFace(a, c, d);
384               meshDS->SetMeshElementOnShape(face, geomFaceID);
385             }
386           }
387           g = near;
388         }
389       }
390     }
391   }
392
393   // right or left boundary quadrangles
394   if (quad->isEdgeOut[1]) {
395 //    MESSAGE("right edge is out");
396     int g = 0; // last processed node in the grid
397     int stop = nbright - 1;
398     if (quad->isEdgeOut[2]) stop--;
399     for (i = 0; i < stop; i++) {
400       const SMDS_MeshNode *a, *b, *c, *d;
401       a = uv_e1[i].node;
402       b = uv_e1[i + 1].node;
403       gp_Pnt pb (b->X(), b->Y(), b->Z());
404
405       // find node c in the grid, nearest to the b
406       int near = g;
407       if (i == stop - 1) { // up bondary reached
408         c = quad->uv_grid[nbhoriz*(jup + 1) - 2].node;
409         near = jup;
410       } else {
411         double mind = RealLast();
412         for (int k = g; k <= jup; k++) {
413           const SMDS_MeshNode *nk;
414           if (k < jlow)
415             nk = uv_e0[nbdown - 2].node;
416           else
417             nk = quad->uv_grid[nbhoriz*(k + 1) - 2].node;
418           gp_Pnt pnk (nk->X(), nk->Y(), nk->Z());
419           double dist = pb.Distance(pnk);
420           if (dist < mind - eps) {
421             c = nk;
422             near = k;
423             mind = dist;
424           } else {
425             break;
426           }
427         }
428       }
429
430       if (near == g) { // make triangle
431         SMDS_MeshFace* face = meshDS->AddFace(a, b, c);
432         meshDS->SetMeshElementOnShape(face, geomFaceID);
433       } else { // make quadrangle
434         if (near - 1 < jlow)
435           d = uv_e0[nbdown - 2].node;
436         else
437           d = quad->uv_grid[nbhoriz*near - 2].node;
438         SMDS_MeshFace* face = meshDS->AddFace(a, b, c, d);
439         meshDS->SetMeshElementOnShape(face, geomFaceID);
440
441         if (near - 1 > g) { // if d not is at g - make additional triangles
442           for (int k = near - 1; k > g; k--) {
443             c = quad->uv_grid[nbhoriz*(k + 1) - 2].node;
444             if (k - 1 < jlow)
445               d = uv_e0[nbdown - 2].node;
446             else
447               d = quad->uv_grid[nbhoriz*k - 2].node;
448             SMDS_MeshFace* face = meshDS->AddFace(a, c, d);
449             meshDS->SetMeshElementOnShape(face, geomFaceID);
450           }
451         }
452         g = near;
453       }
454     }
455   } else {
456     if (quad->isEdgeOut[3]) {
457 //      MESSAGE("left edge is out");
458       int g = nbvertic - 1; // last processed node in the grid
459       int stop = 0;
460       if (quad->isEdgeOut[0]) stop++;
461       for (i = nbleft - 1; i > stop; i--) {
462         const SMDS_MeshNode *a, *b, *c, *d;
463         a = uv_e3[i].node;
464         b = uv_e3[i - 1].node;
465         gp_Pnt pb (b->X(), b->Y(), b->Z());
466
467         // find node c in the grid, nearest to the b
468         int near = g;
469         if (i == stop + 1) { // down bondary reached
470           c = quad->uv_grid[nbhoriz*jlow + 1].node;
471           near = jlow;
472         } else {
473           double mind = RealLast();
474           for (int k = g; k >= jlow; k--) {
475             const SMDS_MeshNode *nk;
476             if (k > jup)
477               nk = uv_e2[1].node;
478             else
479               nk = quad->uv_grid[nbhoriz*k + 1].node;
480             gp_Pnt pnk (nk->X(), nk->Y(), nk->Z());
481             double dist = pb.Distance(pnk);
482             if (dist < mind - eps) {
483               c = nk;
484               near = k;
485               mind = dist;
486             } else {
487               break;
488             }
489           }
490         }
491
492         if (near == g) { // make triangle
493           SMDS_MeshFace* face = meshDS->AddFace(a, b, c);
494           meshDS->SetMeshElementOnShape(face, geomFaceID);
495         } else { // make quadrangle
496           if (near + 1 > jup)
497             d = uv_e2[1].node;
498           else
499             d = quad->uv_grid[nbhoriz*(near + 1) + 1].node;
500           SMDS_MeshFace* face = meshDS->AddFace(a, b, c, d);
501           meshDS->SetMeshElementOnShape(face, geomFaceID);
502
503           if (near + 1 < g) { // if d not is at g - make additional triangles
504             for (int k = near + 1; k < g; k++) {
505               c = quad->uv_grid[nbhoriz*k + 1].node;
506               if (k + 1 > jup)
507                 d = uv_e2[1].node;
508               else
509                 d = quad->uv_grid[nbhoriz*(k + 1) + 1].node;
510               SMDS_MeshFace* face = meshDS->AddFace(a, c, d);
511               meshDS->SetMeshElementOnShape(face, geomFaceID);
512             }
513           }
514           g = near;
515         }
516       }
517     }
518   }
519
520   QuadDelete(quad);
521   bool isOk = true;
522   return isOk;
523 }
524
525
526 //=============================================================================
527 /*!
528  *  
529  */
530 //=============================================================================
531
532 FaceQuadStruct* StdMeshers_Quadrangle_2D::CheckNbEdges(SMESH_Mesh & aMesh,
533                                                        const TopoDS_Shape & aShape)
534      throw(SALOME_Exception)
535 {
536   Unexpect aCatch(SalomeException);
537
538   const TopoDS_Face & F = TopoDS::Face(aShape);
539
540   // verify 1 wire only, with 4 edges
541
542   if (NumberOfWires(F) != 1) {
543     INFOS("only 1 wire by face (quadrangles)");
544     return 0;
545   }
546   const TopoDS_Wire& W = BRepTools::OuterWire(F);
547   BRepTools_WireExplorer wexp (W, F);
548
549   FaceQuadStruct* quad = new FaceQuadStruct;
550   for (int i = 0; i < 4; i++)
551     quad->uv_edges[i] = 0;
552   quad->uv_grid = 0;
553
554   int nbEdges = 0;
555   for (wexp.Init(W, F); wexp.More(); wexp.Next()) {
556     const TopoDS_Edge& E = wexp.Current();
557     int nb = aMesh.GetSubMesh(E)->GetSubMeshDS()->NbNodes();
558     if (nbEdges < 4) {
559       quad->edge[nbEdges] = E;
560       quad->nbPts[nbEdges] = nb + 2; // internal points + 2 extrema
561     }
562     nbEdges++;
563   }
564
565   if (nbEdges != 4) {
566     INFOS("face must have 4 edges /quadrangles");
567     QuadDelete(quad);
568     return 0;
569   }
570
571   return quad;
572 }
573
574
575 //=============================================================================
576 /*!
577  *  
578  */
579 //=============================================================================
580
581 FaceQuadStruct *StdMeshers_Quadrangle_2D::CheckAnd2Dcompute
582   (SMESH_Mesh & aMesh, const TopoDS_Shape & aShape) throw(SALOME_Exception)
583 {
584   Unexpect aCatch(SalomeException);
585
586   FaceQuadStruct *quad = CheckNbEdges(aMesh, aShape);
587
588   if(!quad) return 0;
589
590   // set normalized grid on unit square in parametric domain
591   SetNormalizedGrid(aMesh, aShape, quad);
592
593   return quad;
594 }
595
596 //=============================================================================
597 /*!
598  *  
599  */
600 //=============================================================================
601
602 void StdMeshers_Quadrangle_2D::QuadDelete (FaceQuadStruct * quad)
603 {
604   //MESSAGE("StdMeshers_Quadrangle_2D::QuadDelete");
605   if (quad)
606   {
607     for (int i = 0; i < 4; i++)
608     {
609       if (quad->uv_edges[i])
610         delete [] quad->uv_edges[i];
611       quad->edge[i].Nullify();
612     }
613     if (quad->uv_grid)
614       delete [] quad->uv_grid;
615     delete quad;
616   }
617 }
618
619 //=============================================================================
620 /*!
621  *  
622  */
623 //=============================================================================
624
625 void StdMeshers_Quadrangle_2D::SetNormalizedGrid (SMESH_Mesh & aMesh,
626                                                   const TopoDS_Shape& aShape,
627                                                   FaceQuadStruct* quad) throw (SALOME_Exception)
628 {
629   Unexpect aCatch(SalomeException);
630   // Algorithme décrit dans "Génération automatique de maillages"
631   // P.L. GEORGE, MASSON, Â§ 6.4.1 p. 84-85
632   // traitement dans le domaine paramétrique 2d u,v
633   // transport - projection sur le carré unité
634
635 //  MESSAGE("StdMeshers_Quadrangle_2D::SetNormalizedGrid");
636   const TopoDS_Face& F = TopoDS::Face(aShape);
637
638   // 1 --- find orientation of the 4 edges, by test on extrema
639
640   //      max             min                    0     x1     1
641   //     |<----north-2-------^                a3 -------------> a2
642   //     |                   |                   ^1          1^
643   //    west-3            east-1 =right          |            |
644   //     |                   |         ==>       |            |
645   //  y0 |                   | y1                |            |
646   //     |                   |                   |0          0|
647   //     v----south-0-------->                a0 -------------> a1
648   //      min             max                    0     x0     1
649   //             =down
650   //
651
652   Handle(Geom2d_Curve) c2d[4];
653   gp_Pnt2d pf[4];
654   gp_Pnt2d pl[4];
655   for (int i = 0; i < 4; i++)
656   {
657     c2d[i] = BRep_Tool::CurveOnSurface(quad->edge[i], F,
658                                        quad->first[i], quad->last[i]);
659     pf[i] = c2d[i]->Value(quad->first[i]);
660     pl[i] = c2d[i]->Value(quad->last[i]);
661     quad->isEdgeForward[i] = false;
662   }
663
664   double l0f1 = pl[0].SquareDistance(pf[1]);
665   double l0l1 = pl[0].SquareDistance(pl[1]);
666   double f0f1 = pf[0].SquareDistance(pf[1]);
667   double f0l1 = pf[0].SquareDistance(pl[1]);
668   if ( Min( l0f1, l0l1 ) < Min ( f0f1, f0l1 ))
669   {
670     quad->isEdgeForward[0] = true;
671   } else {
672     double tmp = quad->first[0];
673     quad->first[0] = quad->last[0];
674     quad->last[0] = tmp;
675     pf[0] = c2d[0]->Value(quad->first[0]);
676     pl[0] = c2d[0]->Value(quad->last[0]);
677   }
678   for (int i = 1; i < 4; i++)
679   {
680     l0l1 = pl[i - 1].SquareDistance(pl[i]);
681     l0f1 = pl[i - 1].SquareDistance(pf[i]);
682     quad->isEdgeForward[i] = ( l0f1 < l0l1 );
683     if (!quad->isEdgeForward[i])
684     {
685       double tmp = quad->first[i];
686       quad->first[i] = quad->last[i];
687       quad->last[i] = tmp;
688       pf[i] = c2d[i]->Value(quad->first[i]);
689       pl[i] = c2d[i]->Value(quad->last[i]);
690     }
691   }
692
693   // 2 --- load 2d edge points (u,v) with orientation and value on unit square
694
695   bool loadOk = true;
696   for (int i = 0; i < 2; i++)
697   {
698     quad->uv_edges[i] = LoadEdgePoints(aMesh, F, quad->edge[i],
699                                        quad->first[i], quad->last[i]);
700     if (!quad->uv_edges[i]) loadOk = false;
701   }
702
703   for (int i = 2; i < 4; i++)
704   {
705     quad->uv_edges[i] = LoadEdgePoints(aMesh, F, quad->edge[i],
706                                        quad->last[i], quad->first[i]);
707     if (!quad->uv_edges[i]) loadOk = false;
708   }
709
710   if (!loadOk)
711   {
712     INFOS("StdMeshers_Quadrangle_2D::SetNormalizedGrid - LoadEdgePoints failed");
713     QuadDelete( quad );
714     quad = 0;
715     return;
716   }
717   // 3 --- 2D normalized values on unit square [0..1][0..1]
718
719   int nbhoriz  = Min(quad->nbPts[0], quad->nbPts[2]);
720   int nbvertic = Min(quad->nbPts[1], quad->nbPts[3]);
721
722   quad->isEdgeOut[0] = (quad->nbPts[0] > quad->nbPts[2]);
723   quad->isEdgeOut[1] = (quad->nbPts[1] > quad->nbPts[3]);
724   quad->isEdgeOut[2] = (quad->nbPts[2] > quad->nbPts[0]);
725   quad->isEdgeOut[3] = (quad->nbPts[3] > quad->nbPts[1]);
726
727   quad->uv_grid = new UVPtStruct[nbvertic * nbhoriz];
728
729   UVPtStruct *uv_grid = quad->uv_grid;
730   UVPtStruct *uv_e0 = quad->uv_edges[0];
731   UVPtStruct *uv_e1 = quad->uv_edges[1];
732   UVPtStruct *uv_e2 = quad->uv_edges[2];
733   UVPtStruct *uv_e3 = quad->uv_edges[3];
734
735   // nodes Id on "in" edges
736   if (! quad->isEdgeOut[0]) {
737     int j = 0;
738     for (int i = 0; i < nbhoriz; i++) { // down
739       int ij = j * nbhoriz + i;
740       uv_grid[ij].node = uv_e0[i].node;
741     }
742   }
743   if (! quad->isEdgeOut[1]) {
744     int i = nbhoriz - 1;
745     for (int j = 0; j < nbvertic; j++) { // right
746       int ij = j * nbhoriz + i;
747       uv_grid[ij].node = uv_e1[j].node;
748     }
749   }
750   if (! quad->isEdgeOut[2]) {
751     int j = nbvertic - 1;
752     for (int i = 0; i < nbhoriz; i++) { // up
753       int ij = j * nbhoriz + i;
754       uv_grid[ij].node = uv_e2[i].node;
755     }
756   }
757   if (! quad->isEdgeOut[3]) {
758     int i = 0;
759     for (int j = 0; j < nbvertic; j++) { // left
760       int ij = j * nbhoriz + i;
761       uv_grid[ij].node = uv_e3[j].node;
762     }
763   }
764
765   // falsificate "out" edges
766   if (quad->isEdgeOut[0]) // down
767     uv_e0 = MakeEdgePoints
768       (aMesh, F, quad->edge[0], quad->first[0], quad->last[0], nbhoriz - 1);
769   else if (quad->isEdgeOut[2]) // up
770     uv_e2 = MakeEdgePoints
771       (aMesh, F, quad->edge[2], quad->last[2], quad->first[2], nbhoriz - 1);
772
773   if (quad->isEdgeOut[1]) // right
774     uv_e1 = MakeEdgePoints
775       (aMesh, F, quad->edge[1], quad->first[1], quad->last[1], nbvertic - 1);
776   else if (quad->isEdgeOut[3]) // left
777     uv_e3 = MakeEdgePoints
778       (aMesh, F, quad->edge[3], quad->last[3], quad->first[3], nbvertic - 1);
779
780   // normalized 2d values on grid
781   for (int i = 0; i < nbhoriz; i++)
782   {
783     for (int j = 0; j < nbvertic; j++)
784     {
785       int ij = j * nbhoriz + i;
786       // --- droite i cste : x = x0 + y(x1-x0)
787       double x0 = uv_e0[i].normParam;   // bas - sud
788       double x1 = uv_e2[i].normParam;   // haut - nord
789       // --- droite j cste : y = y0 + x(y1-y0)
790       double y0 = uv_e3[j].normParam;   // gauche-ouest
791       double y1 = uv_e1[j].normParam;   // droite - est
792       // --- intersection : x=x0+(y0+x(y1-y0))(x1-x0)
793       double x = (x0 + y0 * (x1 - x0)) / (1 - (y1 - y0) * (x1 - x0));
794       double y = y0 + x * (y1 - y0);
795       uv_grid[ij].x = x;
796       uv_grid[ij].y = y;
797       //MESSAGE("-xy-01 "<<x0<<" "<<x1<<" "<<y0<<" "<<y1);
798       //MESSAGE("-xy-norm "<<i<<" "<<j<<" "<<x<<" "<<y);
799     }
800   }
801
802   // 4 --- projection on 2d domain (u,v)
803   gp_Pnt2d a0 = pf[0];
804   gp_Pnt2d a1 = pf[1];
805   gp_Pnt2d a2 = pf[2];
806   gp_Pnt2d a3 = pf[3];
807
808   for (int i = 0; i < nbhoriz; i++)
809   {
810     for (int j = 0; j < nbvertic; j++)
811     {
812       int ij = j * nbhoriz + i;
813       double x = uv_grid[ij].x;
814       double y = uv_grid[ij].y;
815       double param_0 = uv_e0[0].param + x * (uv_e0[nbhoriz - 1].param - uv_e0[0].param); // sud
816       double param_2 = uv_e2[0].param + x * (uv_e2[nbhoriz - 1].param - uv_e2[0].param); // nord
817       double param_1 = uv_e1[0].param + y * (uv_e1[nbvertic - 1].param - uv_e1[0].param); // est
818       double param_3 = uv_e3[0].param + y * (uv_e3[nbvertic - 1].param - uv_e3[0].param); // ouest
819
820       //MESSAGE("params "<<param_0<<" "<<param_1<<" "<<param_2<<" "<<param_3);
821       gp_Pnt2d p0 = c2d[0]->Value(param_0);
822       gp_Pnt2d p1 = c2d[1]->Value(param_1);
823       gp_Pnt2d p2 = c2d[2]->Value(param_2);
824       gp_Pnt2d p3 = c2d[3]->Value(param_3);
825
826       double u = (1 - y) * p0.X() + x * p1.X() + y * p2.X() + (1 - x) * p3.X();
827       double v = (1 - y) * p0.Y() + x * p1.Y() + y * p2.Y() + (1 - x) * p3.Y();
828
829       u -= (1 - x) * (1 - y) * a0.X() + x * (1 - y) * a1.X() +
830         x * y * a2.X() + (1 - x) * y * a3.X();
831       v -= (1 - x) * (1 - y) * a0.Y() + x * (1 - y) * a1.Y() +
832         x * y * a2.Y() + (1 - x) * y * a3.Y();
833
834       uv_grid[ij].u = u;
835       uv_grid[ij].v = v;
836     }
837   }
838 }
839
840
841 //=======================================================================
842 //function : ShiftQuad
843 //purpose  : auxilary function for ComputeQuadPref
844 //=======================================================================
845 static void ShiftQuad(FaceQuadStruct* quad, const int num, bool WisF)
846 {
847   if(num>3) return;
848   int i;
849   for(i=1; i<=num; i++) {
850     int nbPts3 = quad->nbPts[0];
851     quad->nbPts[0] = quad->nbPts[1];
852     quad->nbPts[1] = quad->nbPts[2];
853     quad->nbPts[2] = quad->nbPts[3];
854     quad->nbPts[3] = nbPts3;
855     TopoDS_Edge edge3 = quad->edge[0];
856     quad->edge[0] = quad->edge[1];
857     quad->edge[1] = quad->edge[2];
858     quad->edge[2] = quad->edge[3];
859     quad->edge[3] = edge3;
860     double first3 = quad->first[0];
861     quad->first[0] = quad->first[1];
862     quad->first[1] = quad->first[2];
863     quad->first[2] = quad->first[3];
864     quad->first[3] = first3;
865     double last3 = quad->last[0];
866     quad->last[0] = quad->last[1];
867     quad->last[1] = quad->last[2];
868     quad->last[2] = quad->last[3];
869     quad->last[3] = last3;
870     bool isEdgeForward3 = quad->isEdgeForward[0];
871     quad->isEdgeForward[0] = quad->isEdgeForward[1];
872     quad->isEdgeForward[1] = quad->isEdgeForward[2];
873     quad->isEdgeForward[2] = quad->isEdgeForward[3];
874     quad->isEdgeForward[3] = isEdgeForward3;
875     bool isEdgeOut3 = quad->isEdgeOut[0];
876     quad->isEdgeOut[0] = quad->isEdgeOut[1];
877     quad->isEdgeOut[1] = quad->isEdgeOut[2];
878     quad->isEdgeOut[2] = quad->isEdgeOut[3];
879     quad->isEdgeOut[3] = isEdgeOut3;
880     UVPtStruct* uv_edges3 = quad->uv_edges[0];
881     quad->uv_edges[0] = quad->uv_edges[1];
882     quad->uv_edges[1] = quad->uv_edges[2];
883     quad->uv_edges[2] = quad->uv_edges[3];
884     quad->uv_edges[3] = uv_edges3;
885   }
886   if(!WisF) {
887     // replacement left and right edges
888     int nbPts3 = quad->nbPts[1];
889     quad->nbPts[1] = quad->nbPts[3];
890     quad->nbPts[3] = nbPts3;
891     TopoDS_Edge edge3 = quad->edge[1];
892     quad->edge[1] = quad->edge[3];
893     quad->edge[3] = edge3;
894     double first3 = quad->first[1];
895     quad->first[1] = quad->first[3];
896     quad->first[3] = first3;
897     double last3 = quad->last[1];
898     quad->last[1] = quad->last[2];
899     quad->last[3] = last3;
900     bool isEdgeForward3 = quad->isEdgeForward[1];
901     quad->isEdgeForward[1] = quad->isEdgeForward[3];
902     quad->isEdgeForward[3] = isEdgeForward3;
903     bool isEdgeOut3 = quad->isEdgeOut[1];
904     quad->isEdgeOut[1] = quad->isEdgeOut[3];
905     quad->isEdgeOut[3] = isEdgeOut3;
906     UVPtStruct* uv_edges3 = quad->uv_edges[1];
907     quad->uv_edges[1] = quad->uv_edges[3];
908     quad->uv_edges[3] = uv_edges3;
909   }
910 }
911
912
913 //=======================================================================
914 //function : CalcUV
915 //purpose  : auxilary function for ComputeQuadPref
916 //=======================================================================
917 static gp_XY CalcUV(double x0, double x1, double y0, double y1,
918                     FaceQuadStruct* quad,
919                     const gp_Pnt2d& a0, const gp_Pnt2d& a1,
920                     const gp_Pnt2d& a2, const gp_Pnt2d& a3,
921                     const Handle(Geom2d_Curve)& c2db,
922                     const Handle(Geom2d_Curve)& c2dr,
923                     const Handle(Geom2d_Curve)& c2dt,
924                     const Handle(Geom2d_Curve)& c2dl)
925 {
926   int nb = quad->nbPts[0];
927   int nr = quad->nbPts[1];
928   int nt = quad->nbPts[2];
929   int nl = quad->nbPts[3];
930
931   UVPtStruct* uv_eb = quad->uv_edges[0];
932   UVPtStruct* uv_er = quad->uv_edges[1];
933   UVPtStruct* uv_et = quad->uv_edges[2];
934   UVPtStruct* uv_el = quad->uv_edges[3];
935
936   double x = (x0 + y0 * (x1 - x0)) / (1 - (y1 - y0) * (x1 - x0));
937   double y = y0 + x * (y1 - y0);
938
939   double param_b = uv_eb[0].param + x * (uv_eb[nb-1].param - uv_eb[0].param);
940   double param_t = uv_et[0].param + x * (uv_et[nt-1].param - uv_et[0].param);
941   double param_r = uv_er[0].param + y * (uv_er[nr-1].param - uv_er[0].param);
942   double param_l = uv_el[0].param + y * (uv_el[nl-1].param - uv_el[0].param);
943
944   gp_Pnt2d p0 = c2db->Value(param_b);
945   gp_Pnt2d p1 = c2dr->Value(param_r);
946   gp_Pnt2d p2 = c2dt->Value(param_t);
947   gp_Pnt2d p3 = c2dl->Value(param_l);
948
949   double u = (1 - y) * p0.X() + x * p1.X() + y * p2.X() + (1 - x) * p3.X();
950   double v = (1 - y) * p0.Y() + x * p1.Y() + y * p2.Y() + (1 - x) * p3.Y();
951
952   u -= (1 - x) * (1 - y) * a0.X() + x * (1 - y) * a1.X() +
953     x * y * a2.X() + (1 - x) * y * a3.X();
954   v -= (1 - x) * (1 - y) * a0.Y() + x * (1 - y) * a1.Y() +
955     x * y * a2.Y() + (1 - x) * y * a3.Y();
956
957   //cout<<"x0="<<x0<<" x1="<<x1<<" y0="<<y0<<" y1="<<y1<<endl;
958   //cout<<"x="<<x<<" y="<<y<<endl;
959   //cout<<"param_b="<<param_b<<" param_t="<<param_t<<" param_r="<<param_r<<" param_l="<<param_l<<endl;
960   //cout<<"u="<<u<<" v="<<v<<endl;
961
962   return gp_XY(u,v);
963 }
964
965
966 //=======================================================================
967 //function : ComputeQuadPref
968 //purpose  : 
969 //=======================================================================
970 /*!
971  * Special function for creation only quandrangle faces
972  */
973 bool StdMeshers_Quadrangle_2D::ComputeQuadPref
974                           (SMESH_Mesh & aMesh,
975                            const TopoDS_Shape& aShape,
976                            FaceQuadStruct* quad) throw (SALOME_Exception)
977 {
978   Unexpect aCatch(SalomeException);
979
980   SMESHDS_Mesh * meshDS = aMesh.GetMeshDS();
981   const TopoDS_Face& F = TopoDS::Face(aShape);
982   Handle(Geom_Surface) S = BRep_Tool::Surface(F);
983   const TopoDS_Wire& W = BRepTools::OuterWire(F);
984   bool WisF = false;
985   if(W.Orientation()==TopAbs_FORWARD) 
986     WisF = true;
987   //if(WisF) cout<<"W is FORWARD"<<endl;
988   //else cout<<"W is REVERSED"<<endl;
989   bool FisF = (F.Orientation()==TopAbs_FORWARD);
990   if(!FisF) WisF = !WisF;
991   int i,j,geomFaceID = meshDS->ShapeToIndex( F );
992
993   int nb = quad->nbPts[0];
994   int nr = quad->nbPts[1];
995   int nt = quad->nbPts[2];
996   int nl = quad->nbPts[3];
997   int dh = abs(nb-nt);
998   int dv = abs(nr-nl);
999
1000   if( dh>=dv ) {
1001     if( nt>nb ) {
1002       // it is a base case => not shift quad but me be replacement is need
1003       ShiftQuad(quad,0,WisF);
1004     }
1005     else {
1006       // we have to shift quad on 2
1007       ShiftQuad(quad,2,WisF);
1008     }
1009   }
1010   else {
1011     if( nr>nl ) {
1012       // we have to shift quad on 3
1013       ShiftQuad(quad,3,WisF);
1014     }
1015     else {
1016       // we have to shift quad on 1
1017       ShiftQuad(quad,1,WisF);
1018     }
1019   }
1020
1021   nb = quad->nbPts[0];
1022   nr = quad->nbPts[1];
1023   nt = quad->nbPts[2];
1024   nl = quad->nbPts[3];
1025   dh = abs(nb-nt);
1026   dv = abs(nr-nl);
1027   int nbh  = Max(nb,nt);
1028   int nbv = Max(nr,nl);
1029   int addh = 0;
1030   int addv = 0;
1031
1032   // orientation of face and 3 main domain for future faces
1033   //       0   top    1
1034   //      1------------1
1035   //       |   |  |   |
1036   //       |   |  |   |
1037   //       | L |  | R |
1038   //  left |   |  |   | rigth
1039   //       |  /    \  |
1040   //       | /  C   \ |
1041   //       |/        \|
1042   //      0------------0
1043   //       0  bottom  1
1044
1045   if(dh>dv) {
1046     addv = (dh-dv)/2;
1047     nbv = nbv + addv;
1048   }
1049   else { // dv>=dh
1050     addh = (dv-dh)/2;
1051     nbh = nbh + addh;
1052   }
1053
1054   Handle(Geom2d_Curve) c2d[4];
1055   for(i=0; i<4; i++) {
1056     c2d[i] = BRep_Tool::CurveOnSurface(quad->edge[i], F,
1057                                        quad->first[i], quad->last[i]);
1058   }
1059
1060   bool loadOk = true;
1061   for(i=0; i<2; i++) {
1062     quad->uv_edges[i] = LoadEdgePoints2(aMesh, F, quad->edge[i], false);
1063     if(!quad->uv_edges[i]) loadOk = false;
1064   }
1065   for(i=2; i<4; i++) {
1066     quad->uv_edges[i] = LoadEdgePoints2(aMesh, F, quad->edge[i], true);
1067     if (!quad->uv_edges[i]) loadOk = false;
1068   }
1069   if (!loadOk) {
1070     INFOS("StdMeshers_Quadrangle_2D::ComputeQuadPref - LoadEdgePoints failed");
1071     QuadDelete( quad );
1072     quad = 0;
1073     return false;
1074   }
1075
1076   UVPtStruct* uv_eb = quad->uv_edges[0];
1077   UVPtStruct* uv_er = quad->uv_edges[1];
1078   UVPtStruct* uv_et = quad->uv_edges[2];
1079   UVPtStruct* uv_el = quad->uv_edges[3];
1080
1081   // arrays for normalized params
1082   //cout<<"Dump B:"<<endl;
1083   TColStd_SequenceOfReal npb, npr, npt, npl;
1084   for(i=0; i<nb; i++) {
1085     npb.Append(uv_eb[i].normParam);
1086     //cout<<"i="<<i<<" par="<<uv_eb[i].param<<" npar="<<uv_eb[i].normParam;
1087     //const SMDS_MeshNode* N = uv_eb[i].node;
1088     //cout<<" node("<<N->X()<<","<<N->Y()<<","<<N->Z()<<")"<<endl;
1089   }
1090   for(i=0; i<nr; i++) {
1091     npr.Append(uv_er[i].normParam);
1092   }
1093   for(i=0; i<nt; i++) {
1094     npt.Append(uv_et[i].normParam);
1095   }
1096   for(i=0; i<nl; i++) {
1097     npl.Append(uv_el[i].normParam);
1098   }
1099
1100   // we have to add few values of params to right and left
1101   // insert them after first param
1102   // insert to right
1103   int dr = nbv - nr;
1104   double dpr = (npr.Value(2) - npr.Value(1))/(dr+1);
1105   for(i=1; i<=dr; i++) {
1106     npr.InsertAfter(1,npr.Value(2)-dpr);
1107   }
1108   // insert to left
1109   int dl = nbv - nl;
1110   dpr = (npl.Value(2) - npl.Value(1))/(dl+1);
1111   for(i=1; i<=dl; i++) {
1112     npl.InsertAfter(1,npl.Value(2)-dpr);
1113   }
1114   //cout<<"npb:";
1115   //for(i=1; i<=npb.Length(); i++) {
1116   //  cout<<" "<<npb.Value(i);
1117   //}
1118   //cout<<endl;
1119   
1120   gp_Pnt2d a[4];
1121   c2d[0]->D0(uv_eb[0].param,a[0]);
1122   c2d[0]->D0(uv_eb[nb-1].param,a[1]);
1123   c2d[2]->D0(uv_et[nt-1].param,a[2]);
1124   c2d[2]->D0(uv_et[0].param,a[3]);
1125   //cout<<" a[0]("<<a[0].X()<<","<<a[0].Y()<<")"<<" a[1]("<<a[1].X()<<","<<a[1].Y()<<")"
1126   //    <<" a[2]("<<a[2].X()<<","<<a[2].Y()<<")"<<" a[3]("<<a[3].X()<<","<<a[3].Y()<<")"<<endl;
1127
1128   int nnn = Min(nr,nl);
1129   // auxilary sequence of XY for creation nodes
1130   // in the bottom part of central domain
1131   // it's length must be == nbv-nnn-1
1132   TColgp_SequenceOfXY UVL;
1133   TColgp_SequenceOfXY UVR;
1134
1135   // step1: create faces for left domain
1136   StdMeshers_Array2OfNode NodesL(1,dl+1,1,nl);
1137   // add left nodes
1138   for(j=1; j<=nl; j++) 
1139     NodesL.SetValue(1,j,uv_el[j-1].node);
1140   if(dl>0) {
1141     // add top nodes
1142     for(i=1; i<=dl; i++) 
1143       NodesL.SetValue(i+1,nl,uv_et[i].node);
1144     // create and add needed nodes
1145     TColgp_SequenceOfXY UVtmp;
1146     for(i=1; i<=dl; i++) {
1147       double x0 = npt.Value(i+1);
1148       double x1 = x0;
1149       // diagonal node
1150       double y0 = npl.Value(i+1);
1151       double y1 = npr.Value(i+1);
1152       gp_XY UV = CalcUV(x0, x1, y0, y1, quad, a[0], a[1], a[2], a[3],
1153                         c2d[0], c2d[1], c2d[2], c2d[3]);
1154       gp_Pnt P = S->Value(UV.X(),UV.Y());
1155       SMDS_MeshNode * N = meshDS->AddNode(P.X(), P.Y(), P.Z());
1156       meshDS->SetNodeOnFace(N, geomFaceID, UV.X(), UV.Y());
1157       NodesL.SetValue(i+1,1,N);
1158       if(UVL.Length()<nbv-nnn-1) UVL.Append(UV);
1159       // internal nodes
1160       for(j=2; j<nl; j++) {
1161         double y0 = npl.Value(dl+j);
1162         double y1 = npr.Value(dl+j);
1163         gp_XY UV = CalcUV(x0, x1, y0, y1, quad, a[0], a[1], a[2], a[3],
1164                           c2d[0], c2d[1], c2d[2], c2d[3]);
1165         gp_Pnt P = S->Value(UV.X(),UV.Y());
1166         SMDS_MeshNode* N = meshDS->AddNode(P.X(), P.Y(), P.Z());
1167         meshDS->SetNodeOnFace(N, geomFaceID, UV.X(), UV.Y());
1168         NodesL.SetValue(i+1,j,N);
1169         if( i==dl ) UVtmp.Append(UV);
1170       }
1171     }
1172     for(i=1; i<=UVtmp.Length() && UVL.Length()<nbv-nnn-1; i++) {
1173       UVL.Append(UVtmp.Value(i));
1174     }
1175     //cout<<"Dump NodesL:"<<endl;
1176     //for(i=1; i<=dl+1; i++) {
1177     //  cout<<"i="<<i;
1178     //  for(j=1; j<=nl; j++) {
1179     //    cout<<" ("<<NodesL.Value(i,j)->X()<<","<<NodesL.Value(i,j)->Y()<<","<<NodesL.Value(i,j)->Z()<<")";
1180     //  }
1181     //  cout<<endl;
1182     //}
1183     // create faces
1184     for(i=1; i<=dl; i++) {
1185       for(j=1; j<nl; j++) {
1186         if(WisF) {
1187           SMDS_MeshFace* F =
1188             meshDS->AddFace(NodesL.Value(i,j), NodesL.Value(i+1,j),
1189                             NodesL.Value(i+1,j+1), NodesL.Value(i,j+1));
1190           meshDS->SetMeshElementOnShape(F, geomFaceID);
1191         }
1192         else {
1193           SMDS_MeshFace* F =
1194             meshDS->AddFace(NodesL.Value(i,j), NodesL.Value(i,j+1),
1195                             NodesL.Value(i+1,j+1), NodesL.Value(i+1,j));
1196           meshDS->SetMeshElementOnShape(F, geomFaceID);
1197         }
1198       }
1199     }
1200   }
1201   else {
1202     // fill UVL using c2d
1203     for(i=1; i<npl.Length() && UVL.Length()<nbv-nnn-1; i++) {
1204       gp_Pnt2d p2d;
1205       c2d[3]->D0(uv_el[i].param,p2d);
1206       UVL.Append(p2d.XY());
1207     }
1208   }
1209
1210   // step2: create faces for right domain
1211   StdMeshers_Array2OfNode NodesR(1,dr+1,1,nr);
1212   // add right nodes
1213   for(j=1; j<=nr; j++) 
1214     NodesR.SetValue(1,j,uv_er[nr-j].node);
1215   if(dr>0) {
1216     // add top nodes
1217     for(i=1; i<=dr; i++) 
1218       NodesR.SetValue(i+1,1,uv_et[nt-1-i].node);
1219     // create and add needed nodes
1220     TColgp_SequenceOfXY UVtmp;
1221     for(i=1; i<=dr; i++) {
1222       double x0 = npt.Value(nt-i);
1223       double x1 = x0;
1224       // diagonal node
1225       double y0 = npl.Value(i+1);
1226       double y1 = npr.Value(i+1);
1227       gp_XY UV = CalcUV(x0, x1, y0, y1, quad, a[0], a[1], a[2], a[3],
1228                         c2d[0], c2d[1], c2d[2], c2d[3]);
1229       gp_Pnt P = S->Value(UV.X(),UV.Y());
1230       SMDS_MeshNode * N = meshDS->AddNode(P.X(), P.Y(), P.Z());
1231       meshDS->SetNodeOnFace(N, geomFaceID, UV.X(), UV.Y());
1232       NodesR.SetValue(i+1,nr,N);
1233       if(UVR.Length()<nbv-nnn-1) UVR.Append(UV);
1234       // internal nodes
1235       for(j=2; j<nr; j++) {
1236         double y0 = npl.Value(nbv-j+1);
1237         double y1 = npr.Value(nbv-j+1);
1238         gp_XY UV = CalcUV(x0, x1, y0, y1, quad, a[0], a[1], a[2], a[3],
1239                           c2d[0], c2d[1], c2d[2], c2d[3]);
1240         gp_Pnt P = S->Value(UV.X(),UV.Y());
1241         SMDS_MeshNode* N = meshDS->AddNode(P.X(), P.Y(), P.Z());
1242         meshDS->SetNodeOnFace(N, geomFaceID, UV.X(), UV.Y());
1243         NodesR.SetValue(i+1,j,N);
1244         if( i==dr ) UVtmp.Prepend(UV);
1245       }
1246     }
1247     for(i=1; i<=UVtmp.Length() && UVR.Length()<nbv-nnn-1; i++) {
1248       UVR.Append(UVtmp.Value(i));
1249     }
1250     // create faces
1251     for(i=1; i<=dr; i++) {
1252       for(j=1; j<nr; j++) {
1253         if(WisF) {
1254           SMDS_MeshFace* F =
1255             meshDS->AddFace(NodesR.Value(i,j), NodesR.Value(i+1,j),
1256                             NodesR.Value(i+1,j+1), NodesR.Value(i,j+1));
1257           meshDS->SetMeshElementOnShape(F, geomFaceID);
1258         }
1259         else {
1260           SMDS_MeshFace* F =
1261             meshDS->AddFace(NodesR.Value(i,j), NodesR.Value(i,j+1),
1262                             NodesR.Value(i+1,j+1), NodesR.Value(i+1,j));
1263           meshDS->SetMeshElementOnShape(F, geomFaceID);
1264         }
1265       }
1266     }
1267   }
1268   else {
1269     // fill UVR using c2d
1270     for(i=1; i<npr.Length() && UVR.Length()<nbv-nnn-1; i++) {
1271       gp_Pnt2d p2d;
1272       c2d[1]->D0(uv_er[i].param,p2d);
1273       UVR.Append(p2d.XY());
1274     }
1275   }
1276
1277   // step3: create faces for central domain
1278   StdMeshers_Array2OfNode NodesC(1,nb,1,nbv);
1279   // add first string using NodesL
1280   for(i=1; i<=dl+1; i++)
1281     NodesC.SetValue(1,i,NodesL(i,1));
1282   for(i=2; i<=nl; i++)
1283     NodesC.SetValue(1,dl+i,NodesL(dl+1,i));
1284   // add last string using NodesR
1285   for(i=1; i<=dr+1; i++)
1286     NodesC.SetValue(nb,i,NodesR(i,nr));
1287   for(i=1; i<nr; i++)
1288     NodesC.SetValue(nb,dr+i+1,NodesR(dr+1,nr-i));
1289   // add top nodes (last columns)
1290   for(i=dl+2; i<nbh-dr; i++) 
1291     NodesC.SetValue(i-dl,nbv,uv_et[i-1].node);
1292   // add bottom nodes (first columns)
1293   for(i=2; i<nb; i++) {
1294     NodesC.SetValue(i,1,uv_eb[i-1].node);
1295     gp_Pnt2d p2d;
1296     c2d[0]->D0(uv_eb[i-1].param,p2d);
1297   }
1298   // create and add needed nodes
1299   // add linear layers
1300   for(i=2; i<nb; i++) {
1301     double x0 = npt.Value(dl+i);
1302     double x1 = x0;
1303     for(j=1; j<nnn; j++) {
1304       double y0 = npl.Value(nbv-nnn+j);
1305       double y1 = npr.Value(nbv-nnn+j);
1306       gp_XY UV = CalcUV(x0, x1, y0, y1, quad, a[0], a[1], a[2], a[3],
1307                         c2d[0], c2d[1], c2d[2], c2d[3]);
1308       gp_Pnt P = S->Value(UV.X(),UV.Y());
1309       SMDS_MeshNode* N = meshDS->AddNode(P.X(), P.Y(), P.Z());
1310       meshDS->SetNodeOnFace(N, geomFaceID, UV.X(), UV.Y());
1311       NodesC.SetValue(i,nbv-nnn+j,N);
1312     }
1313   }
1314   // add diagonal layers
1315   //cout<<"UVL.Length()="<<UVL.Length()<<" UVR.Length()="<<UVR.Length()<<endl;
1316   //cout<<"Dump UVL:"<<endl;
1317   //for(i=1; i<=UVL.Length(); i++) {
1318   //  cout<<" ("<<UVL.Value(i).X()<<","<<UVL.Value(i).Y()<<")";
1319   //}
1320   //cout<<endl;
1321   for(i=1; i<nbv-nnn; i++) {
1322     double du = UVR.Value(i).X() - UVL.Value(i).X();
1323     double dv = UVR.Value(i).Y() - UVL.Value(i).Y();
1324     for(j=2; j<nb; j++) {
1325       double u = UVL.Value(i).X() + du*npb.Value(j);
1326       double v = UVL.Value(i).Y() + dv*npb.Value(j);
1327       gp_Pnt P = S->Value(u,v);
1328       SMDS_MeshNode* N = meshDS->AddNode(P.X(), P.Y(), P.Z());
1329       meshDS->SetNodeOnFace(N, geomFaceID, u, v);
1330       NodesC.SetValue(j,i+1,N);
1331     }
1332   }
1333   // create faces
1334   for(i=1; i<nb; i++) {
1335     for(j=1; j<nbv; j++) {
1336       if(WisF) {
1337         SMDS_MeshFace* F =
1338           meshDS->AddFace(NodesC.Value(i,j), NodesC.Value(i+1,j),
1339                           NodesC.Value(i+1,j+1), NodesC.Value(i,j+1));
1340         meshDS->SetMeshElementOnShape(F, geomFaceID);
1341       }
1342       else {
1343         SMDS_MeshFace* F =
1344           meshDS->AddFace(NodesC.Value(i,j), NodesC.Value(i,j+1),
1345                           NodesC.Value(i+1,j+1), NodesC.Value(i+1,j));
1346         meshDS->SetMeshElementOnShape(F, geomFaceID);
1347       }
1348     }
1349   }
1350
1351   QuadDelete(quad);
1352   bool isOk = true;
1353   return isOk;
1354 }
1355
1356
1357 //=============================================================================
1358 /*!
1359  *  LoadEdgePoints2
1360  */
1361 //=============================================================================
1362 UVPtStruct* StdMeshers_Quadrangle_2D::LoadEdgePoints2 (SMESH_Mesh & aMesh,
1363                                                        const TopoDS_Face& F,
1364                                                        const TopoDS_Edge& E,
1365                                                        bool IsReverse)
1366 {
1367   //MESSAGE("StdMeshers_Quadrangle_2D::LoadEdgePoints");
1368   // --- IDNodes of first and last Vertex
1369   TopoDS_Vertex VFirst, VLast;
1370   TopExp::Vertices(E, VFirst, VLast); // corresponds to f and l
1371
1372   ASSERT(!VFirst.IsNull());
1373   SMDS_NodeIteratorPtr lid = aMesh.GetSubMesh(VFirst)->GetSubMeshDS()->GetNodes();
1374   if (!lid->more()) {
1375     MESSAGE ( "NO NODE BUILT ON VERTEX" );
1376     return 0;
1377   }
1378   const SMDS_MeshNode* idFirst = lid->next();
1379
1380   ASSERT(!VLast.IsNull());
1381   lid = aMesh.GetSubMesh(VLast)->GetSubMeshDS()->GetNodes();
1382   if (!lid->more()) {
1383     MESSAGE ( "NO NODE BUILT ON VERTEX" );
1384     return 0;
1385   }
1386   const SMDS_MeshNode* idLast = lid->next();
1387
1388   // --- edge internal IDNodes (relies on good order storage, not checked)
1389
1390   map<double, const SMDS_MeshNode *> params;
1391   SMDS_NodeIteratorPtr ite = aMesh.GetSubMesh(E)->GetSubMeshDS()->GetNodes();
1392
1393   while(ite->more()) {
1394     const SMDS_MeshNode* node = ite->next();
1395     const SMDS_EdgePosition* epos =
1396       static_cast<const SMDS_EdgePosition*>(node->GetPosition().get());
1397     double param = epos->GetUParameter();
1398     params[param] = node;
1399   }
1400
1401   int nbPoints = aMesh.GetSubMesh(E)->GetSubMeshDS()->NbNodes();
1402   if (nbPoints != params.size()) {
1403     MESSAGE( "BAD NODE ON EDGE POSITIONS" );
1404     return 0;
1405   }
1406   UVPtStruct* uvslf = new UVPtStruct[nbPoints + 2];
1407
1408   double f, l;
1409   Handle(Geom2d_Curve) C2d = BRep_Tool::CurveOnSurface(E, F, f, l);
1410
1411   const TopoDS_Wire& W = BRepTools::OuterWire(F);
1412   bool FisF = (F.Orientation()==TopAbs_FORWARD);
1413   bool WisF = (W.Orientation()==TopAbs_FORWARD);
1414   bool isForward = (E.Orientation()==TopAbs_FORWARD);
1415   //if(isForward) cout<<"E is FORWARD"<<endl;
1416   //else cout<<"E is REVERSED"<<endl;
1417   if(!WisF) isForward = !isForward;
1418   if(!FisF) isForward = !isForward;
1419   //bool isForward = !(E.Orientation()==TopAbs_FORWARD);
1420   if(IsReverse) isForward = !isForward;
1421   double paramin = 0;
1422   double paramax = 0;
1423   if (isForward) {
1424     paramin = f;
1425     paramax = l;
1426     gp_Pnt2d p = C2d->Value(f); // first point = Vertex Forward
1427     uvslf[0].x = p.X();
1428     uvslf[0].y = p.Y();
1429     uvslf[0].param = f;
1430     uvslf[0].node = idFirst;
1431     //MESSAGE("__ f "<<f<<" "<<uvslf[0].x <<" "<<uvslf[0].y);
1432     map < double, const SMDS_MeshNode* >::iterator itp = params.begin();
1433     for (int i = 1; i <= nbPoints; i++) { // nbPoints internal
1434       double param = (*itp).first;
1435       gp_Pnt2d p = C2d->Value(param);
1436       uvslf[i].x = p.X();
1437       uvslf[i].y = p.Y();
1438       uvslf[i].param = param;
1439       uvslf[i].node = (*itp).second;
1440       //MESSAGE("__ "<<i<<" "<<param<<" "<<uvslf[i].x <<" "<<uvslf[i].y);
1441       itp++;
1442     }
1443     p = C2d->Value(l);          // last point = Vertex Reversed
1444     uvslf[nbPoints + 1].x = p.X();
1445     uvslf[nbPoints + 1].y = p.Y();
1446     uvslf[nbPoints + 1].param = l;
1447     uvslf[nbPoints + 1].node = idLast;
1448     //MESSAGE("__ l "<<l<<" "<<uvslf[nbPoints+1].x <<" "<<uvslf[nbPoints+1].y);
1449   }
1450   else {
1451     paramin = l;
1452     paramax = f;
1453     gp_Pnt2d p = C2d->Value(l); // first point = Vertex Reversed
1454     uvslf[0].x = p.X();
1455     uvslf[0].y = p.Y();
1456     uvslf[0].param = l;
1457     uvslf[0].node = idLast;
1458     //MESSAGE("__ l "<<l<<" "<<uvslf[0].x <<" "<<uvslf[0].y);
1459     map < double, const SMDS_MeshNode* >::reverse_iterator itp = params.rbegin();
1460     for (int j = nbPoints; j >= 1; j--) { // nbPoints internal
1461       double param = (*itp).first;
1462       int i = nbPoints + 1 - j;
1463       gp_Pnt2d p = C2d->Value(param);
1464       uvslf[i].x = p.X();
1465       uvslf[i].y = p.Y();
1466       uvslf[i].param = param;
1467       uvslf[i].node = (*itp).second;
1468       //MESSAGE("__ "<<i<<" "<<param<<" "<<uvslf[i].x <<" "<<uvslf[i].y);
1469       itp++;
1470     }
1471     p = C2d->Value(f);          // last point = Vertex Forward
1472     uvslf[nbPoints + 1].x = p.X();
1473     uvslf[nbPoints + 1].y = p.Y();
1474     uvslf[nbPoints + 1].param = f;
1475     uvslf[nbPoints + 1].node = idFirst;
1476     //MESSAGE("__ f "<<f<<" "<<uvslf[nbPoints+1].x <<" "<<uvslf[nbPoints+1].y);
1477   }
1478
1479   ASSERT(paramin != paramax);
1480   for (int i = 0; i < nbPoints + 2; i++) {
1481     uvslf[i].normParam = (uvslf[i].param - paramin) / (paramax - paramin);
1482   }
1483
1484   return uvslf;
1485 }
1486
1487
1488 //=============================================================================
1489 /*!
1490  *  LoadEdgePoints
1491  */
1492 //=============================================================================
1493 UVPtStruct* StdMeshers_Quadrangle_2D::LoadEdgePoints (SMESH_Mesh & aMesh,
1494                                                       const TopoDS_Face& F,
1495                                                       const TopoDS_Edge& E,
1496                                                       double first, double last)
1497 //                        bool isForward)
1498 {
1499   //MESSAGE("StdMeshers_Quadrangle_2D::LoadEdgePoints");
1500
1501   // --- IDNodes of first and last Vertex
1502
1503   TopoDS_Vertex VFirst, VLast;
1504   TopExp::Vertices(E, VFirst, VLast); // corresponds to f and l
1505
1506   ASSERT(!VFirst.IsNull());
1507   SMDS_NodeIteratorPtr lid = aMesh.GetSubMesh(VFirst)->GetSubMeshDS()->GetNodes();
1508   if (!lid->more())
1509   {
1510     MESSAGE ( "NO NODE BUILT ON VERTEX" );
1511     return 0;
1512   }
1513   const SMDS_MeshNode* idFirst = lid->next();
1514
1515   ASSERT(!VLast.IsNull());
1516   lid = aMesh.GetSubMesh(VLast)->GetSubMeshDS()->GetNodes();
1517   if (!lid->more())
1518   {
1519     MESSAGE ( "NO NODE BUILT ON VERTEX" );
1520     return 0;
1521   }
1522   const SMDS_MeshNode* idLast = lid->next();
1523
1524   // --- edge internal IDNodes (relies on good order storage, not checked)
1525
1526   map<double, const SMDS_MeshNode *> params;
1527   SMDS_NodeIteratorPtr ite = aMesh.GetSubMesh(E)->GetSubMeshDS()->GetNodes();
1528
1529   while(ite->more())
1530   {
1531     const SMDS_MeshNode* node = ite->next();
1532     const SMDS_EdgePosition* epos =
1533       static_cast<const SMDS_EdgePosition*>(node->GetPosition().get());
1534     double param = epos->GetUParameter();
1535     params[param] = node;
1536   }
1537
1538   int nbPoints = aMesh.GetSubMesh(E)->GetSubMeshDS()->NbNodes();
1539   if (nbPoints != params.size())
1540   {
1541     MESSAGE( "BAD NODE ON EDGE POSITIONS" );
1542     return 0;
1543   }
1544   UVPtStruct* uvslf = new UVPtStruct[nbPoints + 2];
1545
1546   double f, l;
1547   Handle(Geom2d_Curve) C2d = BRep_Tool::CurveOnSurface(E, F, f, l);
1548
1549   bool isForward = (((l - f) * (last - first)) > 0);
1550   double paramin = 0;
1551   double paramax = 0;
1552   if (isForward)
1553   {
1554     paramin = f;
1555     paramax = l;
1556     gp_Pnt2d p = C2d->Value(f); // first point = Vertex Forward
1557     uvslf[0].x = p.X();
1558     uvslf[0].y = p.Y();
1559     uvslf[0].param = f;
1560     uvslf[0].node = idFirst;
1561     //MESSAGE("__ f "<<f<<" "<<uvslf[0].x <<" "<<uvslf[0].y);
1562     map < double, const SMDS_MeshNode* >::iterator itp = params.begin();
1563     for (int i = 1; i <= nbPoints; i++) // nbPoints internal
1564     {
1565       double param = (*itp).first;
1566       gp_Pnt2d p = C2d->Value(param);
1567       uvslf[i].x = p.X();
1568       uvslf[i].y = p.Y();
1569       uvslf[i].param = param;
1570       uvslf[i].node = (*itp).second;
1571       //MESSAGE("__ "<<i<<" "<<param<<" "<<uvslf[i].x <<" "<<uvslf[i].y);
1572       itp++;
1573     }
1574     p = C2d->Value(l);          // last point = Vertex Reversed
1575     uvslf[nbPoints + 1].x = p.X();
1576     uvslf[nbPoints + 1].y = p.Y();
1577     uvslf[nbPoints + 1].param = l;
1578     uvslf[nbPoints + 1].node = idLast;
1579     //MESSAGE("__ l "<<l<<" "<<uvslf[nbPoints+1].x <<" "<<uvslf[nbPoints+1].y);
1580   } else
1581   {
1582     paramin = l;
1583     paramax = f;
1584     gp_Pnt2d p = C2d->Value(l); // first point = Vertex Reversed
1585     uvslf[0].x = p.X();
1586     uvslf[0].y = p.Y();
1587     uvslf[0].param = l;
1588     uvslf[0].node = idLast;
1589     //MESSAGE("__ l "<<l<<" "<<uvslf[0].x <<" "<<uvslf[0].y);
1590     map < double, const SMDS_MeshNode* >::reverse_iterator itp = params.rbegin();
1591
1592     for (int j = nbPoints; j >= 1; j--) // nbPoints internal
1593     {
1594       double param = (*itp).first;
1595       int i = nbPoints + 1 - j;
1596       gp_Pnt2d p = C2d->Value(param);
1597       uvslf[i].x = p.X();
1598       uvslf[i].y = p.Y();
1599       uvslf[i].param = param;
1600       uvslf[i].node = (*itp).second;
1601       //MESSAGE("__ "<<i<<" "<<param<<" "<<uvslf[i].x <<" "<<uvslf[i].y);
1602       itp++;
1603     }
1604     p = C2d->Value(f);          // last point = Vertex Forward
1605     uvslf[nbPoints + 1].x = p.X();
1606     uvslf[nbPoints + 1].y = p.Y();
1607     uvslf[nbPoints + 1].param = f;
1608     uvslf[nbPoints + 1].node = idFirst;
1609     //MESSAGE("__ f "<<f<<" "<<uvslf[nbPoints+1].x <<" "<<uvslf[nbPoints+1].y);
1610   }
1611
1612   ASSERT(paramin != paramax);
1613   for (int i = 0; i < nbPoints + 2; i++)
1614   {
1615     uvslf[i].normParam = (uvslf[i].param - paramin) / (paramax - paramin);
1616   }
1617
1618   return uvslf;
1619 }
1620
1621 //=============================================================================
1622 /*!
1623  *  MakeEdgePoints
1624  */
1625 //=============================================================================
1626 UVPtStruct* StdMeshers_Quadrangle_2D::MakeEdgePoints (SMESH_Mesh & aMesh,
1627                                                       const TopoDS_Face& F,
1628                                                       const TopoDS_Edge& E,
1629                                                       double first, double last,
1630                                                       int nb_segm)
1631 {
1632 //  MESSAGE("StdMeshers_Quadrangle_2D::MakeEdgePoints");
1633
1634   UVPtStruct* uvslf = new UVPtStruct[nb_segm + 1];
1635   list<double> params;
1636
1637   // --- edge internal points
1638   double fi, li;
1639   Handle(Geom_Curve) Curve = BRep_Tool::Curve(E, fi, li);
1640   if (!Curve.IsNull()) {
1641     try {
1642       GeomAdaptor_Curve C3d (Curve);
1643       double length = EdgeLength(E);
1644       double eltSize = length / nb_segm;
1645       GCPnts_UniformAbscissa Discret (C3d, eltSize, fi, li);
1646       if (!Discret.IsDone()) return false;
1647       int NbPoints = Discret.NbPoints();
1648       for (int i = 1; i <= NbPoints; i++) {
1649         double param = Discret.Parameter(i);
1650         params.push_back(param);
1651       }
1652     }
1653     catch (Standard_Failure) {
1654       return 0;
1655     }
1656   }
1657   else
1658   {
1659     // Edge is a degenerated Edge
1660     BRep_Tool::Range(E, fi, li);
1661     double du = (li - fi) / nb_segm;
1662     for (int i = 1; i <= nb_segm + 1; i++)
1663     {
1664       double param = fi + (i - 1) * du;
1665       params.push_back(param);
1666     }
1667   }
1668
1669   double f, l;
1670   Handle(Geom2d_Curve) C2d = BRep_Tool::CurveOnSurface(E, F, f, l);
1671   ASSERT(f != l);
1672
1673   bool isForward = (((l - f) * (last - first)) > 0);
1674   if (isForward) {
1675     list<double>::iterator itU = params.begin();
1676     for (int i = 0; i <= nb_segm; i++) // nbPoints internal
1677     {
1678       double param = *itU;
1679       gp_Pnt2d p = C2d->Value(param);
1680       uvslf[i].x = p.X();
1681       uvslf[i].y = p.Y();
1682       uvslf[i].param = param;
1683       uvslf[i].normParam = (param - f) / (l - f);
1684       itU++;
1685     }
1686   } else {
1687     list<double>::reverse_iterator itU = params.rbegin();
1688     for (int j = nb_segm; j >= 0; j--) // nbPoints internal
1689     {
1690       double param = *itU;
1691       int i = nb_segm - j;
1692       gp_Pnt2d p = C2d->Value(param);
1693       uvslf[i].x = p.X();
1694       uvslf[i].y = p.Y();
1695       uvslf[i].param = param;
1696       uvslf[i].normParam = (param - l) / (f - l);
1697       itU++;
1698     }
1699   }
1700
1701   return uvslf;
1702 }
1703
1704
1705 //=============================================================================
1706 /*!
1707  *  
1708  */
1709 //=============================================================================
1710
1711 ostream & StdMeshers_Quadrangle_2D::SaveTo(ostream & save)
1712 {
1713   return save;
1714 }
1715
1716 //=============================================================================
1717 /*!
1718  *  
1719  */
1720 //=============================================================================
1721
1722 istream & StdMeshers_Quadrangle_2D::LoadFrom(istream & load)
1723 {
1724   return load;
1725 }
1726
1727 //=============================================================================
1728 /*!
1729  *  
1730  */
1731 //=============================================================================
1732
1733 ostream & operator <<(ostream & save, StdMeshers_Quadrangle_2D & hyp)
1734 {
1735   return hyp.SaveTo( save );
1736 }
1737
1738 //=============================================================================
1739 /*!
1740  *  
1741  */
1742 //=============================================================================
1743
1744 istream & operator >>(istream & load, StdMeshers_Quadrangle_2D & hyp)
1745 {
1746   return hyp.LoadFrom( load );
1747 }