2 // C++ : Reordonnancement des faces
4 // Copyright (C) 2009-2019 CEA/DEN, EDF R&D
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, or (at your option) any later version.
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
23 #include "HexDocument.hxx"
25 #include "HexVertex.hxx"
26 #include "HexEdge.hxx"
27 #include "HexQuad.hxx"
28 #include "HexHexa.hxx"
33 // ----------------------------------------------------------------------
41 void propagateOrientation (std::queue <OrientedQuad> &queue_quads, Quad* orig);
42 void makeSkin (Quad* orig);
44 // ========================================================= reorderFaces
45 // ==== Ordonner les faces externes
46 void Document::reorderQuads ()
51 for (elt = doc_first_elt[EL_QUAD]->next (); elt!=NULL; elt = elt->next())
52 if (elt!=NULL && elt->isHere())
54 Quad* quad = static_cast <Quad*> (elt);
55 if (quad->getNbrParents()==1) quad->setOrientation (Q_UNDEFINED);
56 else quad->setOrientation (Q_INSIDE);
59 for (elt = doc_first_elt[EL_HEXA]->next (); elt!=NULL; elt = elt->next())
60 if (elt!=NULL && elt->isHere())
62 Hexa* hexa = static_cast <Hexa*> (elt);
63 for (int nq=0; nq<HQ_MAXI ; nq++)
65 Quad* quad = hexa->getQuad (nq);
66 if (quad->getOrientation()==Q_UNDEFINED)
71 for (elt = doc_first_elt[EL_QUAD]->next (); elt!=NULL; elt = elt->next())
72 if (elt!=NULL && elt->isHere())
74 Quad* quad = static_cast <Quad*> (elt);
78 // ========================================================= makeSkin
79 void makeSkin (Quad* orig)
82 std::queue <OrientedQuad> queue_quads;
84 orig->setOrientation(); // Q_DIRECT=1, Q_INVERSE=2
85 propagateOrientation (queue_quads, orig);
87 while (NOT queue_quads.empty ())
89 triplet = queue_quads.front ();
91 int n1 = triplet.quad->indexVertex (triplet.v1);
92 int n2 = triplet.quad->indexVertex (triplet.v2);
94 if (n2 == (n1+1) MODULO QUAD4)
96 else if (n1 == (n2+1) MODULO QUAD4)
99 printf (" **************** Orientation face impossible\n");
101 triplet.quad->setOrientation (sens);
102 propagateOrientation (queue_quads, triplet.quad);
105 // ==================================================== propagateOrientation
106 void propagateOrientation (std::queue <OrientedQuad> &queue_quads, Quad* orig)
108 OrientedQuad triplet;
109 // Q_DIRECT : le sens des vertex est l'exterieur
110 int sens = orig->getOrientation(); // Q_DIRECT=1, Q_INVERSE=2
112 for (int ned=0; ned<QUAD4 ; ned++)
114 triplet.v1 = orig->getVertex ( ned );
115 triplet.v2 = orig->getVertex ((ned+1) MODULO QUAD4);
118 Vertex* v3 = triplet.v1;
119 triplet.v1 = triplet.v2;
122 Edge* edge = orig->getEdge (ned);
123 int nbp = edge->getNbrParents ();
124 for (int np=0; np<nbp ; np++)
126 triplet.quad = edge->getParent (np);
127 if (triplet.quad->getOrientation ()==Q_UNDEFINED)
129 triplet.quad->setOrientation (Q_WAITING);
130 queue_quads.push (triplet);