2 // C++ : Copiteur d'hexaedres
4 // Copyright (C) 2009-2012 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 "HexShape.hxx"
35 void transfo_brep (string& brep, Matrix* matrice, string& trep);
36 void geom_dump_asso (Edge* edge);
37 static bool db = false;
39 // ============================================================= Constructeur
40 Cloner::Cloner (Matrix* mat)
44 // ============================================================== clonerVertex
45 Vertex* Cloner::clonerVertex (Vertex* orig)
50 Vertex* copie = clone_vertex [orig];
54 copie = new Vertex (orig);
55 matrice -> perform (copie);
56 clone_vertex [orig] = copie;
58 Shape* tshape = copie->getAssociation ();
59 Shape* shape = orig ->getAssociation ();
60 if (tshape != NULL || shape == NULL)
63 string brep = shape->getBrep();
65 transfo_brep (brep, matrice, trep);
66 tshape = new Shape (trep);
67 copie ->setAssociation (tshape);
70 printf ( " --- Cloner::Asso (%s) -> asso (%s)\n", orig ->getName (),
75 // ============================================================== clonerEdge
76 Edge* Cloner::clonerEdge (Edge* orig)
81 Edge* copie = clone_edge [orig];
85 copie = new Edge (orig);
87 copie->e_vertex [V_AMONT] = clonerVertex (orig->e_vertex [V_AMONT]);
88 copie->e_vertex [V_AVAL] = clonerVertex (orig->e_vertex [V_AVAL]);
90 copie->majReferences ();
91 clone_edge [orig] = copie;
95 copie->printName (" est la copie de ");
96 orig ->printName ("\n");
99 const Shapes & new_asso = copie->getAssociations ();
100 int nbass = new_asso.size();
104 const Shapes & tab_asso = orig->getAssociations ();
105 nbass = tab_asso.size();
106 for (int nro=0 ; nro < nbass ; nro++)
108 Shape* shape = tab_asso [nro];
109 string brep = shape->getBrep();
111 transfo_brep (brep, matrice, trep);
112 Shape* tshape = new Shape (trep);
113 tshape->setBounds (shape->debut, shape->fin);
114 copie ->addAssociation (tshape);
117 printf ( " --- Cloner::Asso (%s) -> asso (%s)\n", orig ->getName (),
119 geom_dump_asso (orig );
120 geom_dump_asso (copie);
126 // ============================================================== clonerQuad
127 Quad* Cloner::clonerQuad (Quad* orig)
132 Quad* copie = clone_quad [orig];
136 copie = new Quad (orig);
138 for (int nro=0 ; nro<QUAD4 ; nro++)
139 copie->q_edge [nro] = clonerEdge (orig->q_edge [nro]);
141 for (int nro=0 ; nro<QUAD4 ; nro++)
142 copie->q_vertex [nro] = clonerVertex (orig->q_vertex [nro]);
144 copie->majReferences ();
145 clone_quad [orig] = copie;
147 const Shapes & new_asso = copie->getAssociations ();
148 int nbass = new_asso.size();
152 const Shapes & tab_asso = orig->getAssociations ();
153 nbass = tab_asso.size();
154 for (int nro=0 ; nro < nbass ; nro++)
156 Shape* shape = tab_asso [nro];
157 string brep = shape->getBrep();
159 transfo_brep (brep, matrice, trep);
160 Shape* tshape = new Shape (trep);
161 copie ->addAssociation (tshape);
163 printf ( " --- Asso (%s) -> asso (%s)\n", orig ->getName (),
169 // ============================================================== clonerHexa
170 Hexa* Cloner::clonerHexa (Hexa* orig)
175 Hexa* copie = clone_hexa [orig];
179 copie = new Hexa (orig);
180 for (int nro=0 ; nro<HQ_MAXI ; nro++)
181 copie->h_quad [nro] = clonerQuad (orig->h_quad [nro]);
183 for (int nro=0 ; nro<HE_MAXI ; nro++)
184 copie->h_edge [nro] = clonerEdge (orig->h_edge [nro]);
186 for (int nro=0 ; nro<HV_MAXI ; nro++)
187 copie->h_vertex [nro] = clonerVertex (orig->h_vertex [nro]);
189 copie->majReferences ();
190 clone_hexa [orig] = copie;
193 // ============================================================== clonerElements
194 Elements* Cloner::clonerElements (Elements* orig)
196 Elements* copie = new Elements (orig);
199 double a11,a12,a13,a14, a21,a22,a23,a24, a31,a32,a33,a34;
200 matrice->getCoeff (a11,a12,a13,a14, a21,a22,a23,a24, a31,a32,a33,a34);
202 printf ( " --- Matrice = (%g, %g, %g) (%g) \n", a11,a12,a13,a14 );
203 printf ( " (%g, %g, %g) (%g) \n", a21,a22,a23,a24 );
204 printf ( " (%g, %g, %g) (%g) \n", a31,a32,a33,a34 );
207 int nombre = orig->countHexa ();
208 for (int nro=0 ; nro<nombre ; nro++)
210 Hexa* elt = orig->getHexa (nro);
211 Hexa* elt2 = clonerHexa (elt);
212 copie->setHexa (elt2, nro);
215 nombre = orig->countQuad ();
216 for (int nro=0 ; nro<nombre ; nro++)
218 Quad* elt = orig->getQuad (nro);
219 Quad* elt2 = clonerQuad (elt);
220 copie->setQuad (elt2, nro);
223 nombre = orig->countEdge ();
224 for (int nro=0 ; nro<nombre ; nro++)
226 Edge* elt = orig->getEdge (nro);
227 Edge* elt2 = clonerEdge (elt);
228 copie->setEdge (elt2, nro);
231 nombre = orig->countVertex ();
232 for (int nro=0 ; nro<nombre ; nro++)
234 Vertex* elt = orig->getVertex (nro);
235 Vertex* elt2 = clonerVertex (elt);
236 copie->setVertex (elt2, nro);