Salome HOME
Updated copyright comment
[modules/hexablock.git] / src / HEXABLOCK / HexCloner.cxx
old mode 100755 (executable)
new mode 100644 (file)
index e6fa6f1..7d211f1
@@ -1,6 +1,24 @@
 
-// C++ : Gestion des noeuds
-
+// C++ : Copiteur d'hexaedres
+
+// Copyright (C) 2009-2024  CEA, EDF
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
 #include "HexCloner.hxx"
 #include "HexMatrix.hxx"
 
 #include "HexVertex.hxx"
 
 #include "HexElements.hxx"
+#include "HexVertexShape.hxx"
+#include "HexEdgeShape.hxx"
+#include "HexFaceShape.hxx"
 
 BEGIN_NAMESPACE_HEXA
 
+void transfo_brep (std::string& brep, Matrix* matrice, std::string& trep);
+static bool db = false;
+
 // ============================================================= Constructeur
 Cloner::Cloner  (Matrix* mat)
 {
@@ -21,22 +45,28 @@ Cloner::Cloner  (Matrix* mat)
 // ============================================================== clonerVertex
 Vertex* Cloner::clonerVertex (Vertex* orig)
 {
-    if (orig == NULL)
-        return orig;
+   if (orig == NULL)
+       return orig;
 
-    Vertex* copie = clone_vertex [orig];
-    if (copie != NULL)
-        return copie;
+   Vertex* copie = clone_vertex [orig];
+   if (copie != NULL)
+       return copie;
+
+   copie = new Vertex (orig);
+   matrice -> perform (copie);
+   clone_vertex [orig] = copie;
 
-    copie = new Vertex (orig);
-    matrice -> perform (copie);
-    clone_vertex [orig] = copie;
-    return copie;
+   if (db)
+      {
+      printf ( " --- Cloner::Asso (%s) -> asso (%s)\n", orig ->getName  (),
+                                                        copie->getName ());
+      }
+   return copie;
 }
 // ============================================================== clonerEdge
 Edge* Cloner::clonerEdge (Edge* orig)
 {
-    if (orig == NULL)
+   if (orig == NULL)
         return orig;
 
    Edge* copie = clone_edge [orig];
@@ -57,6 +87,32 @@ Edge* Cloner::clonerEdge (Edge* orig)
       orig ->printName ("\n");
       }
 
+/***********************
+   // const  Shapes & new_asso = copie->getAssociations ();  TODO  New Shape
+   // int    nbass             = new_asso.size();
+   // if (nbass!=0)
+      // return copie;
+
+   const Shapes & tab_asso = orig->getAssociations ();
+   nbass             = tab_asso.size();
+   for (int nro=0 ; nro < nbass ; nro++)
+       {
+       Shape* shape = tab_asso [nro];
+       std::string brep  = shape->getBrep();
+       std::string trep;
+       transfo_brep (brep, matrice, trep);
+       Shape* tshape = new Shape (trep);
+       tshape->setBounds (shape->getStart(), shape->getEnd());
+       copie ->addAssociation (tshape);
+       if (db)
+          {
+          printf ( " --- Cloner::Asso (%s) -> asso (%s)\n", orig ->getName (),
+                                                            copie->getName ());
+          // geom_dump_asso (orig );
+          // geom_dump_asso (copie);
+          }
+       }
+***************************************************/
    return copie;
 }
 // ============================================================== clonerQuad
@@ -71,14 +127,36 @@ Quad* Cloner::clonerQuad (Quad* orig)
 
    copie = new Quad (orig);
 
-   for (int nro=0 ; nro<QUAD4 ; nro++) 
+   for (int nro=0 ; nro<QUAD4 ; nro++)
        copie->q_edge [nro] = clonerEdge (orig->q_edge [nro]);
 
-   for (int nro=0 ; nro<QUAD4 ; nro++) 
+   for (int nro=0 ; nro<QUAD4 ; nro++)
        copie->q_vertex [nro] = clonerVertex (orig->q_vertex [nro]);
 
    copie->majReferences ();
    clone_quad [orig] = copie;
+/*******************************************************************
+   const  Shapes & new_asso = copie->getAssociations ();
+   int    nbass             = new_asso.size();
+   if (nbass!=0)
+      return copie;
+
+   const Shapes & tab_asso = orig->getAssociations ();
+   nbass             = tab_asso.size();
+   for (int nro=0 ; nro < nbass ; nro++)
+       {
+       Shape* shape = tab_asso [nro];
+       std::string brep  = shape->getBrep();
+       std::string trep;
+       transfo_brep (brep, matrice, trep);
+       Shape* tshape = new Shape (trep);
+       copie ->addAssociation (tshape);
+       if (db)
+          printf ( " --- Asso (%s) -> asso (%s)\n", orig ->getName (),
+                                                    copie->getName ());
+       }
+
+***************************************************/
    return copie;
 }
 // ============================================================== clonerHexa
@@ -95,10 +173,10 @@ Hexa* Cloner::clonerHexa (Hexa* orig)
    for (int nro=0 ; nro<HQ_MAXI ; nro++)
        copie->h_quad [nro] = clonerQuad (orig->h_quad [nro]);
 
-   for (int nro=0 ; nro<HE_MAXI ; nro++) 
+   for (int nro=0 ; nro<HE_MAXI ; nro++)
        copie->h_edge [nro] = clonerEdge (orig->h_edge [nro]);
 
-   for (int nro=0 ; nro<HV_MAXI ; nro++) 
+   for (int nro=0 ; nro<HV_MAXI ; nro++)
        copie->h_vertex [nro] = clonerVertex (orig->h_vertex [nro]);
 
    copie->majReferences ();
@@ -109,6 +187,15 @@ Hexa* Cloner::clonerHexa (Hexa* orig)
 Elements* Cloner::clonerElements (Elements* orig)
 {
    Elements* copie = new Elements (orig);
+   if (db)
+      {
+      double             a11,a12,a13,a14, a21,a22,a23,a24, a31,a32,a33,a34;
+      matrice->getCoeff (a11,a12,a13,a14, a21,a22,a23,a24, a31,a32,a33,a34);
+      printf ( "\n");
+      printf ( " --- Matrice = (%g, %g, %g) (%g) \n", a11,a12,a13,a14 );
+      printf ( "               (%g, %g, %g) (%g) \n", a21,a22,a23,a24 );
+      printf ( "               (%g, %g, %g) (%g) \n", a31,a32,a33,a34 );
+      }
 
    int nombre = orig->countHexa ();
    for (int nro=0 ; nro<nombre ; nro++)