2 // C++ : Copiteur d'hexaedres
4 // Copyright (C) 2009-2014 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
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 static bool db = false;
40 // ============================================================= Constructeur
41 Cloner::Cloner (Matrix* mat)
45 // ============================================================== clonerVertex
46 Vertex* Cloner::clonerVertex (Vertex* orig)
51 Vertex* copie = clone_vertex [orig];
55 copie = new Vertex (orig);
56 matrice -> perform (copie);
57 clone_vertex [orig] = copie;
61 printf ( " --- Cloner::Asso (%s) -> asso (%s)\n", orig ->getName (),
66 // ============================================================== clonerEdge
67 Edge* Cloner::clonerEdge (Edge* orig)
72 Edge* copie = clone_edge [orig];
76 copie = new Edge (orig);
78 copie->e_vertex [V_AMONT] = clonerVertex (orig->e_vertex [V_AMONT]);
79 copie->e_vertex [V_AVAL] = clonerVertex (orig->e_vertex [V_AVAL]);
81 copie->majReferences ();
82 clone_edge [orig] = copie;
86 copie->printName (" est la copie de ");
87 orig ->printName ("\n");
90 /***********************
91 // const Shapes & new_asso = copie->getAssociations (); TODO New Shape
92 // int nbass = new_asso.size();
96 const Shapes & tab_asso = orig->getAssociations ();
97 nbass = tab_asso.size();
98 for (int nro=0 ; nro < nbass ; nro++)
100 Shape* shape = tab_asso [nro];
101 string brep = shape->getBrep();
103 transfo_brep (brep, matrice, trep);
104 Shape* tshape = new Shape (trep);
105 tshape->setBounds (shape->getStart(), shape->getEnd());
106 copie ->addAssociation (tshape);
109 printf ( " --- Cloner::Asso (%s) -> asso (%s)\n", orig ->getName (),
111 // geom_dump_asso (orig );
112 // geom_dump_asso (copie);
115 ***************************************************/
118 // ============================================================== clonerQuad
119 Quad* Cloner::clonerQuad (Quad* orig)
124 Quad* copie = clone_quad [orig];
128 copie = new Quad (orig);
130 for (int nro=0 ; nro<QUAD4 ; nro++)
131 copie->q_edge [nro] = clonerEdge (orig->q_edge [nro]);
133 for (int nro=0 ; nro<QUAD4 ; nro++)
134 copie->q_vertex [nro] = clonerVertex (orig->q_vertex [nro]);
136 copie->majReferences ();
137 clone_quad [orig] = copie;
138 /*******************************************************************
139 const Shapes & new_asso = copie->getAssociations ();
140 int nbass = new_asso.size();
144 const Shapes & tab_asso = orig->getAssociations ();
145 nbass = tab_asso.size();
146 for (int nro=0 ; nro < nbass ; nro++)
148 Shape* shape = tab_asso [nro];
149 string brep = shape->getBrep();
151 transfo_brep (brep, matrice, trep);
152 Shape* tshape = new Shape (trep);
153 copie ->addAssociation (tshape);
155 printf ( " --- Asso (%s) -> asso (%s)\n", orig ->getName (),
159 ***************************************************/
162 // ============================================================== clonerHexa
163 Hexa* Cloner::clonerHexa (Hexa* orig)
168 Hexa* copie = clone_hexa [orig];
172 copie = new Hexa (orig);
173 for (int nro=0 ; nro<HQ_MAXI ; nro++)
174 copie->h_quad [nro] = clonerQuad (orig->h_quad [nro]);
176 for (int nro=0 ; nro<HE_MAXI ; nro++)
177 copie->h_edge [nro] = clonerEdge (orig->h_edge [nro]);
179 for (int nro=0 ; nro<HV_MAXI ; nro++)
180 copie->h_vertex [nro] = clonerVertex (orig->h_vertex [nro]);
182 copie->majReferences ();
183 clone_hexa [orig] = copie;
186 // ============================================================== clonerElements
187 Elements* Cloner::clonerElements (Elements* orig)
189 Elements* copie = new Elements (orig);
192 double a11,a12,a13,a14, a21,a22,a23,a24, a31,a32,a33,a34;
193 matrice->getCoeff (a11,a12,a13,a14, a21,a22,a23,a24, a31,a32,a33,a34);
195 printf ( " --- Matrice = (%g, %g, %g) (%g) \n", a11,a12,a13,a14 );
196 printf ( " (%g, %g, %g) (%g) \n", a21,a22,a23,a24 );
197 printf ( " (%g, %g, %g) (%g) \n", a31,a32,a33,a34 );
200 int nombre = orig->countHexa ();
201 for (int nro=0 ; nro<nombre ; nro++)
203 Hexa* elt = orig->getHexa (nro);
204 Hexa* elt2 = clonerHexa (elt);
205 copie->setHexa (elt2, nro);
208 nombre = orig->countQuad ();
209 for (int nro=0 ; nro<nombre ; nro++)
211 Quad* elt = orig->getQuad (nro);
212 Quad* elt2 = clonerQuad (elt);
213 copie->setQuad (elt2, nro);
216 nombre = orig->countEdge ();
217 for (int nro=0 ; nro<nombre ; nro++)
219 Edge* elt = orig->getEdge (nro);
220 Edge* elt2 = clonerEdge (elt);
221 copie->setEdge (elt2, nro);
224 nombre = orig->countVertex ();
225 for (int nro=0 ; nro<nombre ; nro++)
227 Vertex* elt = orig->getVertex (nro);
228 Vertex* elt2 = clonerVertex (elt);
229 copie->setVertex (elt2, nro);