X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FHEXABLOCK%2FHexDocument.cxx;h=b7ce32e6e5cbd04108b25c5dbd1738f008e1f98c;hb=76a04c833d6dbc5affe2455f372fb625050f5746;hp=ee4514e33bae99feed65d40afe772fc53fdf9569;hpb=8681e72f844274a0c2fc2cd64bbf2451bd8db77b;p=modules%2Fhexablock.git diff --git a/src/HEXABLOCK/HexDocument.cxx b/src/HEXABLOCK/HexDocument.cxx old mode 100755 new mode 100644 index ee4514e..b7ce32e --- a/src/HEXABLOCK/HexDocument.cxx +++ b/src/HEXABLOCK/HexDocument.cxx @@ -1,24 +1,24 @@ // C++ : La clase principale de Hexa -// Copyright (C) 2009-2012 CEA/DEN, EDF R&D +// Copyright (C) 2009-2019 CEA/DEN, EDF R&D // -// 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. +// 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. +// 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 +// 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 // -// See http://www.salome-platform.org/ -// or email : webmaster.salome@opencascade.com #include "HexDocument.hxx" @@ -29,11 +29,8 @@ #include "HexHexa.hxx" #include "HexElements.hxx" -#include "HexCrossElements.hxx" #include "HexVector.hxx" -#include "HexCylinder.hxx" -#include "HexPipe.hxx" #include "HexMatrix.hxx" #include "HexCloner.hxx" #include "HexPropagation.hxx" @@ -43,35 +40,55 @@ #include "HexXmlTree.hxx" #include "HexGlobale.hxx" #include "HexGroup.hxx" +#include "Hex.hxx" +#include "HexNewShape.hxx" + +void test_six (Hex::Document* docu, int option); BEGIN_NAMESPACE_HEXA +int Document::doc_number = 0; + // ======================================================== Constructeur -Document::Document (cpchar name) +Document::Document (cpchar name, Hex* dad) { - glob = Globale::getInstance (); + el_name = name; + hex_parent = dad; + glob = Globale::getInstance (); + el_root = this; doc_db = 0; nbr_errors = 0; doc_modified = true; doc_saved = false; - doc_name = name; doc_tolerance = 1e-6; nbr_laws = 0; nbr_propagations = 0; maj_propagation = true; doc_xml = NULL; - doc_shape = NULL; - defaultLaw = addLaw ("DefaultLaw", 0); - nbr_used_hexas = nbr_used_quads = nbr_used_edges = nbr_used_vertex = 0; for (EnumElt type = EL_NONE ; type < EL_MAXI ; type=(EnumElt) (type+1)) { - doc_first_elt [type] = doc_last_elt [type] = new EltBase (); + doc_first_elt [type] = doc_last_elt [type] = new EltBase (); doc_nbr_elt [type] = 0; } + + if (doc_number == 0) + strcpy (doc_ident, "doc"); + else + sprintf (doc_ident, "doc%02d", doc_number); + doc_number++; + + DumpLock; + defaultLaw = addLaw ("DefaultLaw", 0); + DumpRestore; + + maj_connection = false; + purge_elements = false; + holes_elements = false; + addCloud (); } // ======================================================== Destructeur Document::~Document () @@ -82,7 +99,7 @@ Document::~Document () { // printf ("____________________________ Type=%d\n", type); EltBase* next = NULL; - for (EltBase* elt=doc_first_elt [type] ; elt != NULL ; elt=next) + for (EltBase* elt=doc_first_elt [type] ; elt != NULL ; elt=next) { next = elt->next(); delete elt; @@ -92,220 +109,197 @@ Document::~Document () // ======================================================== addVector Vector* Document::addVector (double dx, double dy, double dz) { - Vector* pv = new Vector (this, dx, dy, dz); + DumpStart ("addVector", dx << dy << dz); + Vector* pv = new Vector (this, dx, dy, dz); doc_vector.push_back (pv); + + DumpReturn (pv); return pv; } // ======================================================== addVectorVertices Vector* Document::addVectorVertices (Vertex* va, Vertex* vb) { + DumpStart ("addVectorVertices", va << vb); + Vector* pv = addVector (vb->getX () - va->getX (), vb->getY () - va->getY (), vb->getZ () - va->getZ ()); + + DumpReturn (pv); return pv; } // ======================================================== addVertex Vertex* Document::addVertex (double x, double y, double z) { + DumpStart ("addVertex", x << y << z); + Vertex* pv = new Vertex (this, x, y, z); + DumpReturn (pv); return pv; } // ======================================================== addEdge Edge* Document::addEdge (Vertex* va, Vertex* vb) { - if (va==NULL || vb==NULL) + DumpStart ("addEdge", va << vb ); + + if (va==NULL || vb==NULL) return NULL; Edge* arete = new Edge (va, vb); + DumpReturn (arete); return arete; } -// ======================================================== addEdge (bis) -Edge* Document::addEdge (Vertex* va, Vector* vec) +// ======================================================== addEdgeVector +Edge* Document::addEdgeVector (Vertex* va, Vector* vec) { - Vertex* vb = addVertex (va->getX () + vec->getDx(), - va->getY () + vec->getDy(), + DumpStart ("addEdgeVector", va << vec ); + + Vertex* vb = addVertex (va->getX () + vec->getDx(), + va->getY () + vec->getDy(), va->getZ () + vec->getDz()); Edge* arete = addEdge (va, vb); + DumpReturn (arete); return arete; } // ======================================================== addQuadVertices Quad* Document::addQuadVertices (Vertex* va, Vertex* vb, Vertex* vc, Vertex* vd) { + DumpStart ("addQuadVertices", va << vb << vc << vd ); + Quad* face = new Quad (va, vb, vc, vd); + DumpReturn (face); return face; } // ======================================================== addQuad Quad* Document::addQuad (Edge* ea, Edge* eb, Edge* ec, Edge* ed) { + DumpStart ("addQuad", ea << eb << ec << ed ); + Quad* face = new Quad (ea, eb, ec, ed); + DumpReturn (face); return face; } // ======================================================== addHexaVertices Hexa* Document::addHexaVertices (Vertex* va, Vertex* vb, Vertex* vc, Vertex* vd, Vertex* ve, Vertex* vf, Vertex* vg, Vertex* vh) { + DumpStart ("addHexaVertices", va << vb << vc << vd << ve << vf << vg << vh); + Hexa* pave = new Hexa (va, vb, vc, vd, ve, vf, vg, vh); + DumpReturn (pave); return pave; } // ======================================================== addHexa -Hexa* Document::addHexa (Quad* qa, Quad* qb, Quad* qc, Quad* qd, Quad* qe, +Hexa* Document::addHexa (Quad* qa, Quad* qb, Quad* qc, Quad* qd, Quad* qe, Quad* qf) { + DumpStart ("addHexa", qa << qb << qc << qd << qe << qf ); + Hexa* pave = new Hexa (qa, qb, qc, qd, qe, qf); + DumpReturn (pave); return pave; } -// ======================================================== addCylinder -Cylinder* Document::addCylinder (Vertex* b, Vector* d, double r, double h) -{ - Cylinder* cyl = new Cylinder (b, d, r, h); - doc_cylinder.push_back (cyl); - return cyl; -} -// ======================================================== addPipe -Pipe* Document::addPipe (Vertex* b, Vector* d, double ri, double re, double h) -{ - Pipe* tuyau = new Pipe (b, d, ri, re, h); - doc_pipe.push_back (tuyau); - return tuyau; -} -// ======================================================== makeCartesian -Elements* Document::makeCartesian (Vertex* v, Vector* dir, - int px, int py, int pz, int mx, int my, int mz) -{ - Vector* v1 = new Vector (this, dir->getDx(), 0, 0); - Vector* v2 = new Vector (this, 0, dir->getDy(), 0); - Vector* v3 = new Vector (this, 0,0, dir->getDz()); - Elements* grille = new Elements (this); - grille->makeCartesianGrid (v, v1, v2, v3, px, py, pz, mx, my, mz); - return grille; -} -// ======================================================== makeCartesian -Elements* Document::makeCartesian (Vertex* v, Vector* v1, Vector* v2, - Vector* v3, int px, int py, int pz, int mx, int my, int mz) -{ - Elements* grille = new Elements (this); - grille->makeCartesianGrid (v, v1, v2, v3, px, py, pz, mx, my, mz); - return grille; -} -// ======================================================== makeSpherical -Elements* Document::makeSpherical (Vertex* c, double rayon, int nb, double k) -{ - Elements* grille = new Elements (this); - grille->makeSphericalGrid (c, rayon, nb, k); - return grille; -} -// ======================================================== makeCylindrical -Elements* Document::makeCylindrical (Vertex* c, Vector* b, Vector* h, - double dr, double da, double dl, int nr, int na, int nl, bool fill) -{ - Elements* grille = new Elements (this); - grille->makeCylindricalGrid (c, b, h, dr, da, dl, nr, na, nl, fill); - return grille; -} -// ======================================================== makeSphere -Elements* Document::makeSphere (Vertex* center, Vector* vx, Vector* vz, - double radius, double radhole, Vertex* plorig, - int nrad, int nang, int nhaut) -{ - Elements* grille = new Elements (this); - double radint = (radhole + radius)*DEMI; - grille->makeRind (GR_HEMISPHERIC, center, vx, vz, radius, radint, radhole, - plorig, 360.0, nrad, nang, nhaut); - return grille; -} -// ======================================================== makePartSphere -Elements* Document::makePartSphere (Vertex* center, Vector* vx, Vector* vz, - double radius, double radhole, - Vertex* plorig, double angle, - int nrad, int nang, int nhaut) -{ - Elements* grille = new Elements (this); - double radint = (radhole + radius)*DEMI; - grille->makeRind (GR_PART_SPHERIC, center, vx, vz, radius, radint, radhole, - plorig, angle, nrad, nang, nhaut); - return grille; -} -// ======================================================== makeRind -Elements* Document::makeRind (Vertex* center, Vector* vx, Vector* vz, - double radext, double radint, double radhole, - Vertex* plorig, int nrad, int nang, int nhaut) -{ - Elements* grille = new Elements (this); - grille->makeRind (GR_RIND, center, vx, vz, radext, radint, radhole, - plorig, 360.0, nrad, nang, nhaut); - return grille; -} -// ======================================================== makePartRind -Elements* Document::makePartRind (Vertex* center, Vector* vx, Vector* vz, - double radext, double radint, double radhole, - Vertex* plorig, double angle, - int nrad, int nang, int nhaut) -{ - Elements* grille = new Elements (this); - grille->makeRind (GR_PART_RIND, center, vx, vz, radext, radint, radhole, - plorig, angle, nrad, nang, nhaut); - return grille; -} // ======================================================== findVertex Vertex* Document::findVertex (double vx, double vy, double vz) { + DumpStart ("findVertex", vx << vy << vz); + Vertex* found = NULL; + double xmin = vx - doc_tolerance; double xmax = vx + doc_tolerance; double ymin = vy - doc_tolerance; double ymax = vy + doc_tolerance; double zmin = vz - doc_tolerance; double zmax = vz + doc_tolerance; - - for (EltBase* elt = doc_first_elt[EL_VERTEX]->next (); elt!=NULL; + + for (EltBase* elt = doc_first_elt[EL_VERTEX]->next (); + elt!= NULL && found == NULL ; elt = elt->next()) { if (elt->isHere()) - { - Vertex* node = static_cast (elt); - if (node->isin (xmin, xmax, ymin, ymax, zmin, zmax)) - return node; + { + Vertex* candidat = static_cast (elt); + if (candidat->isin (xmin, xmax, ymin, ymax, zmin, zmax)) + found = candidat; } } - return NULL; + + DumpReturn (found); + return found; } // ======================================================== findEdge Edge* Document::findEdge (Vertex* v1, Vertex* v2) { - for (EltBase* elt = doc_first_elt[EL_EDGE]->next (); elt!=NULL; + DumpStart ("findEdge", v1 << v2); + Edge* found = NULL; + + for (EltBase* elt = doc_first_elt[EL_EDGE]->next (); + elt!= NULL && found == NULL ; elt = elt->next()) { - Edge* candidat = static_cast (elt); + Edge* candidat = static_cast (elt); if (candidat->definedBy (v1, v2)) - return candidat; + found = candidat; } - return NULL; + + DumpReturn (found); + return found; } // ======================================================== findQuad Quad* Document::findQuad (Vertex* v1, Vertex* v2) { - for (EltBase* elt = doc_first_elt[EL_QUAD]->next (); elt!=NULL; + DumpStart ("findQuad", v1 << v2); + Quad* found = NULL; + + for (EltBase* elt = doc_first_elt[EL_QUAD]->next (); + elt!= NULL && found == NULL ; elt = elt->next()) { - Quad* candidat = static_cast (elt); + Quad* candidat = static_cast (elt); if (candidat->definedBy (v1, v2)) - return candidat; + found = candidat; } - return NULL; + + DumpReturn (found); + return found; +} +// ======================================================== findQuad +Quad* Document::findQuad (Edge* e1, Edge* e2) +{ + DumpStart ("findQuad", e1 << e2); + Quad* found = NULL; + + for (EltBase* elt = doc_first_elt[EL_QUAD]->next (); + elt!= NULL && found == NULL ; + elt = elt->next()) + { + Quad* candidat = static_cast (elt); + if (candidat->definedBy (e1, e2)) + found = candidat; + } + + DumpReturn (found); + return found; } // ======================================================== findHexa Hexa* Document::findHexa (Vertex* v1, Vertex* v2) { - for (EltBase* elt = doc_first_elt[EL_HEXA]->next (); elt!=NULL; + DumpStart ("findHexa", v1 << v2); + Hexa* found = NULL; + + for (EltBase* elt = doc_first_elt[EL_HEXA]->next (); + elt!= NULL && found == NULL ; elt = elt->next()) { - Hexa* candidat = static_cast (elt); + Hexa* candidat = static_cast (elt); if (candidat->definedBy (v1, v2)) - return candidat; + found = candidat; } - return NULL; -} + DumpReturn (found); + return found; +} // ======================================================== findElement EltBase* Document::findElement (EnumElt type, int ident) { @@ -320,7 +314,7 @@ EltBase* Document::findElement (EnumElt type, int ident) // ======================================================== findVertex Vertex* Document::findVertex (int ident) { - Vertex* node = static_cast (findElement (EL_VERTEX, ident)); + Vertex* node = static_cast (findElement (EL_VERTEX, ident)); return node; } @@ -334,29 +328,34 @@ int index_tv (Vertex* table[], Vertex* elt) return NOTHING; } // ======================================================== mergeQuads -int Document::mergeQuads (Quad* dest, Quad* orig, Vertex* v1, Vertex* v2, +int Document::mergeQuads (Quad* dest, Quad* orig, Vertex* v1, Vertex* v2, Vertex* v3, Vertex* v4) { + DumpStart ("mergeQuads", dest << orig << v1 << v2 << v3 << v4); + update (); if (dest==orig) { printf (" *** Quads identiques dans mergeQuads\n"); + DumpEnd; return HERR; } else if (dest==NULL || dest->isDeleted()) { printf (" *** Quad nro 1 incorrect dans mergeQuads \n"); + DumpEnd; return HERR; } else if (orig==NULL || orig->isDeleted() ) { printf (" *** Quad nro 2 incorrect dans mergeQuads \n"); + DumpEnd; return HERR; } int nbcomm = 0; - for (int nro=0 ; nroindexVertex (dest->getVertex(nro)); if (norig != NOTHING) @@ -370,7 +369,7 @@ int Document::mergeQuads (Quad* dest, Quad* orig, Vertex* v1, Vertex* v2, printf (" (%s,", dest->getName (nom)); printf (" %s)\n", orig->getName (nom)); } - printf (" +++ quad1[%d] = quad2[%d] = %s\n", nro, norig, + printf (" +++ quad1[%d] = quad2[%d] = %s\n", nro, norig, uv->getName (nom)); } } @@ -379,20 +378,23 @@ int Document::mergeQuads (Quad* dest, Quad* orig, Vertex* v1, Vertex* v2, { printf (" +++ Les vertex passes en arguments sont ignores\n"); int ier = closeQuads (dest, orig); + DumpEnd; return ier; } else if (nbcomm != 0) { printf (" *** _____________________ mergeQuads refuse: \n"); printf (" il y a %d sommet(s) sont commun(s)\n", nbcomm); + DumpEnd; return HERR; } - if ( v1 ==NULL || v1 ->isDeleted() || v2 ==NULL || v2 ->isDeleted() - || v3 ==NULL || v3 ->isDeleted() || v4 ==NULL || v4 ->isDeleted()) + if ( v1 ==NULL || v1 ->isDeleted() || v2 ==NULL || v2 ->isDeleted() + || v3 ==NULL || v3 ->isDeleted() || v4 ==NULL || v4 ->isDeleted()) { printf (" *** _____________________ mergeQuads refuse: \n"); printf (" un sommet est incorrect\n"); + DumpEnd; return HERR; } @@ -413,8 +415,16 @@ int Document::mergeQuads (Quad* dest, Quad* orig, Vertex* v1, Vertex* v2, int ier1 = dest->ordoVertex (v1, v3, tv1); int ier2 = orig->ordoVertex (v2, v4, tv2); - if (ier1 != HOK) return ier1; - else if (ier2 != HOK) return ier2; + if (ier1 != HOK) + { + DumpEnd; + return ier1; + } + else if (ier2 != HOK) + { + DumpEnd; + return ier2; + } for (int nro=0 ; nrofindEdge (tv2[na], tv2[nb]); if (te2[nro]==NULL) + { + DumpEnd; return HERR; + } } if (debug()) @@ -453,53 +469,61 @@ int Document::mergeQuads (Quad* dest, Quad* orig, Vertex* v1, Vertex* v2, } replaceQuad (orig, dest); - for (int nro=0 ; nrogetName(nom)); + DumpEnd; return HERR; } else if (dest==NULL || dest->isDeleted()) { printf (" *** Quad nro 1 incorrect dans closeQuads \n"); + DumpEnd; return HERR; } else if (orig==NULL || orig->isDeleted() ) { printf (" *** Quad nro 2 incorrect dans closeQuads \n"); + DumpEnd; return HERR; } Edge* edc = NULL; - for (int nro=0 ; nroindexEdge (dest->getEdge(nro)); if (norig != NOTHING) { - if (edc != NULL) + if (edc != NULL) { printf (" *** Plus d'une arete commune dans closeQuads"); printf (" (%s,", dest->getName (nom)); printf (" %s)\n", orig->getName (nom)); + DumpEnd; return HERR; } edc = dest->getEdge (nro); - printf (" +++ quad1[%d] = quad2[%d] = %s\n", nro, norig, + printf (" +++ quad1[%d] = quad2[%d] = %s\n", nro, norig, edc->getName (nom)); } } @@ -512,8 +536,16 @@ int Document::closeQuads (Quad* dest, Quad* orig) int ier1 = dest->ordoVertex (va, vb, tv1); int ier2 = orig->ordoVertex (va, vb, tv2); - if (ier1 != HOK) return ier1; - else if (ier2 != HOK) return ier2; + if (ier1 != HOK) + { + DumpEnd; + return ier1; + } + else if (ier2 != HOK) + { + DumpEnd; + return ier2; + } for (int nro=0 ; nrofindEdge (tv2[na], tv2[nb]); if (te2[nro]==NULL) + { + DumpEnd; return HERR; + } } if (debug()) @@ -552,59 +590,185 @@ int Document::closeQuads (Quad* dest, Quad* orig) } replaceQuad (orig, dest); - for (int nro=0 ; nroisDeleted() || e2==NULL || e2->isDeleted()) + DumpStart ("mergeEdges", e1 << e2 << v1 << v2); + + if (e1==NULL || e1->isDeleted() || e2==NULL || e2->isDeleted()) + { + DumpEnd; return HERR; + } - for (int nro=0 ; nroindex (e2->getVertex(nro))!= NOTHING) + { + DumpEnd; return HERR+nro+1; + } Vertex *tv1 [V_TWO], *tv2 [V_TWO]; int ier1 = e1->anaMerge (v1, tv1); int ier2 = e2->anaMerge (v2, tv2); - if (ier1 != HOK) return ier1; - else if (ier2 != HOK) return ier2; + if (ier1 != HOK) + { + DumpEnd; + return ier1; + } + else if (ier2 != HOK) + { + DumpEnd; + return ier2; + } replaceEdge (e2, e1); - for (int nro=0 ; nroisDeleted() - || v2==NULL || v2->isDeleted()) - return HERR; + DumpStart ("mergeVertices", vpar << vold); - replaceVertex (v2, v1); + int ier = HOK; + if (BadElement (vpar)) + { + Mess << "First vertex is not valid"; + ier = HERR; + } + else if (BadElement (vold)) + { + Mess << "Second vertex is not valid"; + ier = HERR; + } + else if (vpar==vold) + { + Mess << "Vertices are identical"; + ier = HERR; + } + else if (EltIsValid (findEdge (vpar, vold))) + { + Mess << "Theese vertices are connected by an edge"; + ier = HERR; + } + if (ier != HOK) + { + DumpEnd; + return ier; + } + + std::map rep_quad; + std::map rep_edge; + std::map rep_vertex; + + std::map :: iterator itq; + std::map :: iterator ited; + std::map :: iterator itv; + + rep_vertex [vold] = vpar; + int nbparv = vold->getNbrParents (); + + for (int ned=0 ; nedgetParent (ned); + if (edold->isHere()) + { + Vertex* vopp = edold->opposedVertex (vold); + Edge* edpar = findEdge (vpar, vopp); + if (edpar != NULL) + rep_edge [edold] = edpar; + } + } + + Quad *qold=NULL, *qpar=NULL; + + for (ited=rep_edge.begin(); ited!=rep_edge.end() ; ++ited) + { + Edge* edold = ited->first; + Edge* edpar = ited->second; + int nbpared = edold->getNbrParents (); + for (int nq=0 ; nqgetParent (nq); + if (qold->isHere()) + { + for (int ned=0 ; nedgetEdge(ned); + Edge* edge = qold->getEdge (ned); + if (edge != edold) + { + qpar = findQuad (edpar, edge); + if (qpar != NULL) + rep_quad [qold] = qpar; + } + } + } + } + } + + std::cout << " +++ Intersection : veq = " << rep_vertex.size() + << " " << rep_edge.size() << " " << rep_quad.size() + << std::endl; + + for (itq=rep_quad.begin(); itq!=rep_quad.end() ; ++itq) + { + qold = itq->first; + qpar = itq->second; + Vertex *tv1[QUAD4], *tv2[QUAD4]; + Edge *te1[QUAD4], *te2[QUAD4]; + Edge* einter = qpar->inter (qold); + if (einter!=NULL) + { + Vertex* va = einter->getVertex (V_AMONT); + Vertex* vb = einter->getVertex (V_AVAL); + qpar->ordonner (va, vb, tv1, te1); + qold->ordonner (va, vb, tv2, te2); + for (int nro=0 ; nrofirst, ited->second); + + for (itv=rep_vertex.begin(); itv!=rep_vertex.end() ; ++itv) + replaceVertex (itv->first, itv->second); + maj_connection = false; + DumpEnd; return HOK; } // ======================================================== replaceVertex void Document::replaceVertex (Vertex* old, Vertex* par) { - if (old==par) - return; + if (BadElement(old) || BadElement(par) || old==par) + return ; - par->replaceAssociation (old); + // par->replaceAssociation (old); TODO for (int type=EL_EDGE ; type <= EL_HEXA ; type++) { @@ -618,10 +782,10 @@ void Document::replaceVertex (Vertex* old, Vertex* par) // ======================================================== replaceEdge void Document::replaceEdge (Edge* old, Edge* par) { - if (old==par) + if (BadElement(old) || BadElement(par) || old==par) return; - par->replaceAssociation (old); + // par->replaceAssociation (old); TODO for (int type=EL_QUAD ; type <= EL_HEXA ; type++) { @@ -630,15 +794,16 @@ void Document::replaceEdge (Edge* old, Edge* par) if (elt->isHere ()) elt->replaceEdge (old, par); } + old->suppress (); } // ======================================================== replaceQuad -void Document::replaceQuad (Quad* old, Quad* par) +int Document::replaceQuad (Quad* old, Quad* par) { - if (old==par) - return; + if (BadElement(old) || BadElement(par) || old==par) + return HERR; - par->replaceAssociation (old); + // par->replaceAssociation (old); TODO for (EltBase* elt = doc_first_elt[EL_HEXA]->next (); elt!=NULL; elt = elt->next()) @@ -648,82 +813,11 @@ void Document::replaceQuad (Quad* old, Quad* par) cell->replaceQuad (old, par); } old->suppress (); -} -// ======================================================== prismQuad -Elements* Document::prismQuad (Quad* start, Vector* dir, int nb) -{ - Quads tstart; - tstart.push_back (start); - - update (); - Elements* prisme = prismQuads (tstart, dir, nb); - return prisme; -} -// ======================================================== prismQuads -Elements* Document::prismQuads (Quads& tstart, Vector* dir, int nb) -{ - Elements* prisme = new Elements (this); - if (nb<=0) return prisme; - - prisme->prismQuads (tstart, dir, nb); - return prisme; -} -// ======================================================== prismQuadsVec -Elements* Document::prismQuadsVec (Quads& tstart, Vector* dir, RealVector& tlen, - int crit) -{ - Elements* prisme = new Elements (this); - if (tlen.size()<=0) return prisme; - - prisme->prismQuadsVec (tstart, dir, tlen, crit); - return prisme; -} -// ======================================================== joinQuads -Elements* Document::joinQuads (Quads& start, Quad* dest, Vertex* v1, - Vertex* v2, Vertex* v3, Vertex* v4, int nb) -{ - update (); - Elements* joint = new Elements (this); - if (nb<=0) return joint; - - int ier = joint->joinQuads (start, nb, v1, v2, v3, v4, dest); - if (ier !=HOK) - printf ("\n ****\n **** Error in joinQuad(s)\n ****\n"); - return joint; -} -// ======================================================== joinQuad -Elements* Document::joinQuad (Quad* start, Quad* dest, Vertex* v1, - Vertex* v2, Vertex* v3, Vertex* v4, int nb) -{ - Quads tstart; - tstart.push_back (start); - - Elements* joint = joinQuads (tstart, dest, v1, v2, v3, v4, nb); - return joint; -} -// ========================================================== getHexa -Hexa* Document::getHexa (int nro) -{ - return static_cast (getElement (EL_HEXA, nro)); -} -// ========================================================== getQuad -Quad* Document::getQuad (int nro) -{ - return static_cast (getElement (EL_QUAD, nro)); -} -// ========================================================== getEdge -Edge* Document::getEdge (int nro) -{ - return static_cast (getElement (EL_EDGE, nro)); -} -// ========================================================== getVertex -Vertex* Document::getVertex (int nro) -{ - return static_cast (getElement (EL_VERTEX, nro)); + return HOK; } // ========================================================== countElement int Document::countElement (EnumElt type) -{ +{ int compteur = 0; for (EltBase* elt = doc_first_elt[type]->next (); elt!=NULL; elt = elt->next()) @@ -733,8 +827,8 @@ int Document::countElement (EnumElt type) return compteur; } // ========================================================== getElement -EltBase* Document::getElement (EnumElt type, int nro) -{ +EltBase* Document::getElement (EnumElt type, int nro) +{ int compteur = 0; for (EltBase* elt = doc_first_elt[type]->next (); elt!=NULL; elt = elt->next()) @@ -750,60 +844,78 @@ EltBase* Document::getElement (EnumElt type, int nro) } // ========================================================= addLaw Law* Document::addLaw (const char* name, int nbnodes) -{ - Law* loi = new Law (name, nbnodes); - return addLaw (loi); +{ + DumpStart ("addLaw", name << nbnodes); + Law* loi = new Law (this, name, nbnodes); + addLaw (loi); + DumpReturn (loi); + return loi; } // ========================================================= addLaw Law* Document::addLaw (Law* loi) -{ +{ doc_laws.push_back (loi); nbr_laws ++; return loi; } -// ========================================================= GetLaw +// ========================================================= getLaw Law* Document::getLaw (int nro) -{ - if (nro <0 || nro>= nbr_laws) - return NULL; +{ + DumpStart ("getLaw", nro); + Law* loi = NULL; - return doc_laws [nro]; + if (nro >= 0 && nro < nbr_laws) + loi = doc_laws [nro]; + + DumpReturn (loi); + return loi; } -// ========================================================= FindLaw +// ========================================================= findLaw Law* Document::findLaw (const char* name) -{ +{ + DumpStart ("findLaw", name); + std::string nom = name; - for (int nro=0 ; nrogetName() == nom) - return doc_laws [nro]; + loi = doc_laws [nro]; - return NULL; + DumpReturn (loi); + return loi; } // ========================================================= removeLaw int Document::removeLaw (Law* loi) -{ +{ + DumpStart ("removeLaw", loi); + for (int nro=1 ; nrogetLaw() == loi ) - doc_propagation [nl]->setLaw(defaultLaw); - } + if ( doc_propagation [nl]->getLaw() == loi ) + doc_propagation [nl]->setLaw(defaultLaw); + } + + // delete doc_laws [nro]; + doc_laws [nro]->suppress (); + doc_laws.erase (doc_laws.begin()+nro); + nbr_laws = doc_laws.size(); - delete doc_laws [nro]; - doc_laws.erase (doc_laws.begin()+nro); - nbr_laws= doc_laws.size(); - return HOK; - } + DumpReturn (HOK); + return HOK; + } + DumpReturn (HERR); return HERR; } // ========================================================= majPropagation void Document::majPropagation () -{ +{ + DumpLock; majReferences (); update (); // if (purge_elements) @@ -811,7 +923,9 @@ void Document::majPropagation () for (int nro=0 ; nrosuppress(); + ; } doc_propagation.clear (); @@ -839,15 +953,17 @@ void Document::majPropagation () Edge* arete = cell->getEdge(ne); if (arete->getPropag()<0) { - Propagation* prop = new Propagation (); + Propagation* prop = new Propagation (this); doc_propagation.push_back (prop); arete->propager (prop, nbr_propagations); nbr_propagations ++; - prop->majLaw(); + prop->majLaw(); } } } } + maj_propagation = false; + DumpRestore; } // ======================================================== countPropagation int Document::countPropagation () @@ -860,202 +976,198 @@ int Document::countPropagation () // ======================================================== getPropagation Propagation* Document::getPropagation (int nro) { + DumpStart ("getPropagation", nro); + if (maj_propagation) majPropagation (); - if (nro < 0 || nro >= nbr_propagations) - return NULL; + Propagation* prop = NULL; + if (nro >= 0 && nro < nbr_propagations) + prop = doc_propagation [nro]; - return doc_propagation [nro]; + DumpReturn (prop); + return prop; } // ======================================================== findPropagation Propagation* Document::findPropagation (Edge* arete) { - if (arete==NULL) - return NULL; + DumpStart ("findPropagation", arete); - if (maj_propagation) - majPropagation (); + Propagation* prop = NULL; + if (arete!=NULL) + { + if (maj_propagation) + majPropagation (); + prop = getPropagation (arete->getPropag ()); + } - return getPropagation (arete->getPropag ()); + DumpReturn (prop); + return prop; } // ======================================================== disconnectQuad Elements* Document::disconnectQuad (Hexa* cell, Quad* element) { - if (cell==NULL || element==NULL) - return NULL; + DumpStart ("disconnectQuad", cell << element); - update (); - Elements* crees = cell->disconnectQuad (element); + Elements* grid = new Elements (this); + grid->checkDisco (cell, element); - if (crees!=NULL) - majReferences (); + if (grid->isValid()) + { + update (); + cell->disconnectQuad (element, grid); + majReferences (); + } - return crees; + DumpReturn (grid); + return grid; } // ======================================================== disconnectEdge Elements* Document::disconnectEdge (Hexa* cell, Edge* element) { - if (cell==NULL || element==NULL) - return NULL; + DumpStart ("disconnectEdge", cell << element); - update (); - Elements* crees = cell->disconnectEdge (element); + Elements* grid = new Elements (this); + grid->checkDisco (cell, element); + + if (grid->isValid()) + { + update (); + cell->disconnectEdge (element, grid); + majReferences (); + } - if (crees!=NULL) - majReferences (); - return crees; + DumpReturn (grid); + return grid; } // ======================================================== disconnectVertex Elements* Document::disconnectVertex (Hexa* cell, Vertex* element) { - if (cell==NULL || element==NULL) - return NULL; - - update (); - Elements* crees = cell->disconnectVertex (element); + DumpStart ("disconnectVertex", cell << element); - if (crees!=NULL) - majReferences (); - return crees; -} -// ======================================================== cut -Elements* Document::cut (Edge* edge, int nbcuts) -{ - Elements* t_hexas = new Elements (this); + Elements* grid = new Elements (this); + grid->checkDisco (cell, element); - if (edge==NULL || nbcuts<=0) - return t_hexas; - - Propagation* prop = findPropagation (edge); - const Edges& t_edges = prop->getEdges (); - - t_hexas->cutHexas (t_edges, nbcuts); + if (grid->isValid()) + { + update (); + cell->disconnectVertex (element, grid); + majReferences (); + } - majPropagation (); - return t_hexas; + DumpReturn (grid); + return grid; } -// ======================================================== addGroup -Group* Document::addGroup (cpchar name, EnumGroup kind) -{ - Group* grp = new Group (name, kind); - doc_group.push_back (grp); - return grp; -} -// ======================================================== findGroup -Group* Document::findGroup (cpchar name) +// ======================================================== setName +int Document::setName (cpchar prefix) { - int nbre = doc_group.size(); - - for (int ng=0 ; nggetName(), name)) - return doc_group [ng]; + DumpStart ("setName", prefix); - return NULL; -} -// ======================================================== removeGroup -int Document::removeGroup (Group* grp) -{ - int nbre = doc_group.size(); - for (int ng=0 ; ngmakeName (prefix, name); + el_name = name; } - // Pas trouve dans la liste. On detruit quand meme - delete grp; - return HERR; -}// ======================================================== makeCylinder -Elements* Document::makeCylinder (Cylinder* cyl, Vector* base, int nr, int na, - int nl) -{ - Elements* grille = new Elements (this); - grille->makeCylinder (cyl, base, nr, na, nl); - return grille; -} -// ======================================================== makeCylinders -CrossElements* Document::makeCylinders (Cylinder* cyl1, Cylinder* cyl2) -{ - CrossElements* grille = new CrossElements (this, GR_BICYL); - grille->crossCylinders (cyl1, cyl2, true); - return grille; -} -// ======================================================== makePipe -Elements* Document::makePipe (Pipe* pipe, Vector* bx, int nr, int na, int nl) -{ - Elements* grille = new Elements (this); - grille->makePipe (pipe, bx, nr, na, nr); - return grille; + DumpReturn (ier); + return ier ; } -// ======================================================== makePipes -CrossElements* Document::makePipes (Pipe* pipe1, Pipe* pipe2) -{ - CrossElements* grille = new CrossElements (this, GR_BIPIPE); - grille->crossCylinders (pipe1, pipe2, false); - return grille; -} -// ======================================================== setName -int Document::setName (const char* name) -{ - doc_name = name ; - return HOK ; -} - // ======================================================== setLevel #ifdef NO_CASCADE -#define _TEST_BIC +#define _TEST_BICYL #endif -class BiCylinder; - -BiCylinder* test_bicylinder (Document* docu, int option); -void set_debug_asso (bool boule); - void Document::setLevel (int niv) { + DumpStart ("setLevel", niv); + if (niv == 747) - clearAssociation (); + checkAssociations (); + else if (niv == 748) + { + int nbshapes = countShape (); + for (int nsh=0 ; nsh < nbshapes ; nsh++) + { + doc_tab_shape[nsh]->saveBrep(); + } + } else if (niv == 777) set_special_option (true); else if (niv == 778) set_special_option (false); -#ifdef _TEST_BICYL - else if (niv >=90 && niv <=99) - test_bicylinder (this, niv-90); -#endif + + else if (niv >=100 && niv <=200) + test_six (this, niv); else { doc_db = niv; - set_debug_asso (niv>0); } + + DumpEnd; } -// ======================================================== getAssoVertices -void Document::getAssoVertices (Vertices& tabelt) +// ======================================================== makeVarName +char* Document::makeVarName (char* name) { - tabelt.clear (); - for (EltBase* elt = doc_first_elt[EL_VERTEX]->next (); elt!=NULL; - elt = elt->next()) - if (elt->isHere() && elt->getAssociation()!=NULL) - tabelt.push_back (static_cast (elt)); + strcpy (name, doc_ident); + return doc_ident ; } -// ======================================================== getAssoEdges -void Document::getAssoEdges (Edges& tabelt) +// ======================================================== isEmpty +bool Document::isEmpty () { - tabelt.clear (); - for (EltBase* elt = doc_first_elt[EL_EDGE]->next (); elt!=NULL; - elt = elt->next()) - if (elt->isHere()) - { - Edge* edge = static_cast (elt); - int nbass = edge->getAssociations().size(); - if (nbass>0) - tabelt.push_back (edge); - } + int nombre = countVertex () + countVector (); + return nombre <= 0 && countLaw () <= 1; +} +// ======================================================== getNextName +cpchar Document::getNextName (EnumElt type, std::string& buff) +{ + char name [8]; + EltBase::makeName (type, doc_nbr_elt [type], name); + + buff = name; + return buff.c_str(); +} + +// ======================================================== getNextName +std::string Document::getNextName (EnumElt type) +{ + char name [8]; + EltBase::makeName (type, doc_nbr_elt [type], name); + + return std::string(name); +} + +// ======================================================== lockDump +void Document::lockDump () +{ + glob->dump.lock (); +} +// ======================================================== restoreDump +void Document::restoreDump () +{ + glob->dump.restore (DumpActif); +} +// ======================================================== getGroup +Group* Document::getGroup (int nro) +{ + int size = doc_group.size(); + if (nro>=0 && nro=0 && nro