2 // C++ : Copiteur d'hexaedres
4 // Copyright (C) 2009-2013 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.
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 #include "HexCloner.hxx"
23 #include "HexMatrix.hxx"
25 #include "HexHexa.hxx"
26 #include "HexQuad.hxx"
27 #include "HexEdge.hxx"
28 #include "HexVertex.hxx"
30 #include "HexElements.hxx"
31 #include "HexVertexShape.hxx"
32 #include "HexEdgeShape.hxx"
33 #include "HexFaceShape.hxx"
37 void transfo_brep (string& brep, Matrix* matrice, string& trep);
38 void geom_dump_asso (Edge* edge);
39 static bool db = false;
41 // ============================================================= Constructeur
42 Cloner::Cloner (Matrix* mat)
46 // ============================================================== clonerVertex
47 Vertex* Cloner::clonerVertex (Vertex* orig)
52 Vertex* copie = clone_vertex [orig];
56 copie = new Vertex (orig);
57 matrice -> perform (copie);
58 clone_vertex [orig] = copie;
62 printf ( " --- Cloner::Asso (%s) -> asso (%s)\n", orig ->getName (),
67 // ============================================================== clonerEdge
68 Edge* Cloner::clonerEdge (Edge* orig)
73 Edge* copie = clone_edge [orig];
77 copie = new Edge (orig);
79 copie->e_vertex [V_AMONT] = clonerVertex (orig->e_vertex [V_AMONT]);
80 copie->e_vertex [V_AVAL] = clonerVertex (orig->e_vertex [V_AVAL]);
82 copie->majReferences ();
83 clone_edge [orig] = copie;
87 copie->printName (" est la copie de ");
88 orig ->printName ("\n");
91 /***********************
92 // const Shapes & new_asso = copie->getAssociations (); TODO New Shape
93 // int nbass = new_asso.size();
97 const Shapes & tab_asso = orig->getAssociations ();
98 nbass = tab_asso.size();
99 for (int nro=0 ; nro < nbass ; nro++)
101 Shape* shape = tab_asso [nro];
102 string brep = shape->getBrep();
104 transfo_brep (brep, matrice, trep);
105 Shape* tshape = new Shape (trep);
106 tshape->setBounds (shape->getStart(), shape->getEnd());
107 copie ->addAssociation (tshape);
110 printf ( " --- Cloner::Asso (%s) -> asso (%s)\n", orig ->getName (),
112 geom_dump_asso (orig );
113 geom_dump_asso (copie);
116 ***************************************************/
119 // ============================================================== clonerQuad
120 Quad* Cloner::clonerQuad (Quad* orig)
125 Quad* copie = clone_quad [orig];
129 copie = new Quad (orig);
131 for (int nro=0 ; nro<QUAD4 ; nro++)
132 copie->q_edge [nro] = clonerEdge (orig->q_edge [nro]);
134 for (int nro=0 ; nro<QUAD4 ; nro++)
135 copie->q_vertex [nro] = clonerVertex (orig->q_vertex [nro]);
137 copie->majReferences ();
138 clone_quad [orig] = copie;
139 /*******************************************************************
140 const Shapes & new_asso = copie->getAssociations ();
141 int nbass = new_asso.size();
145 const Shapes & tab_asso = orig->getAssociations ();
146 nbass = tab_asso.size();
147 for (int nro=0 ; nro < nbass ; nro++)
149 Shape* shape = tab_asso [nro];
150 string brep = shape->getBrep();
152 transfo_brep (brep, matrice, trep);
153 Shape* tshape = new Shape (trep);
154 copie ->addAssociation (tshape);
156 printf ( " --- Asso (%s) -> asso (%s)\n", orig ->getName (),
160 ***************************************************/
163 // ============================================================== clonerHexa
164 Hexa* Cloner::clonerHexa (Hexa* orig)
169 Hexa* copie = clone_hexa [orig];
173 copie = new Hexa (orig);
174 for (int nro=0 ; nro<HQ_MAXI ; nro++)
175 copie->h_quad [nro] = clonerQuad (orig->h_quad [nro]);
177 for (int nro=0 ; nro<HE_MAXI ; nro++)
178 copie->h_edge [nro] = clonerEdge (orig->h_edge [nro]);
180 for (int nro=0 ; nro<HV_MAXI ; nro++)
181 copie->h_vertex [nro] = clonerVertex (orig->h_vertex [nro]);
183 copie->majReferences ();
184 clone_hexa [orig] = copie;
187 // ============================================================== clonerElements
188 Elements* Cloner::clonerElements (Elements* orig)
190 Elements* copie = new Elements (orig);
193 double a11,a12,a13,a14, a21,a22,a23,a24, a31,a32,a33,a34;
194 matrice->getCoeff (a11,a12,a13,a14, a21,a22,a23,a24, a31,a32,a33,a34);
196 printf ( " --- Matrice = (%g, %g, %g) (%g) \n", a11,a12,a13,a14 );
197 printf ( " (%g, %g, %g) (%g) \n", a21,a22,a23,a24 );
198 printf ( " (%g, %g, %g) (%g) \n", a31,a32,a33,a34 );
201 int nombre = orig->countHexa ();
202 for (int nro=0 ; nro<nombre ; nro++)
204 Hexa* elt = orig->getHexa (nro);
205 Hexa* elt2 = clonerHexa (elt);
206 copie->setHexa (elt2, nro);
209 nombre = orig->countQuad ();
210 for (int nro=0 ; nro<nombre ; nro++)
212 Quad* elt = orig->getQuad (nro);
213 Quad* elt2 = clonerQuad (elt);
214 copie->setQuad (elt2, nro);
217 nombre = orig->countEdge ();
218 for (int nro=0 ; nro<nombre ; nro++)
220 Edge* elt = orig->getEdge (nro);
221 Edge* elt2 = clonerEdge (elt);
222 copie->setEdge (elt2, nro);
225 nombre = orig->countVertex ();
226 for (int nro=0 ; nro<nombre ; nro++)
228 Vertex* elt = orig->getVertex (nro);
229 Vertex* elt2 = clonerVertex (elt);
230 copie->setVertex (elt2, nro);