X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FHEXABLOCK%2FHexEltBase.cxx;h=41a4aebe480fbfd8daa6010acf69828b532922fc;hb=f7c6169bde92dd9e0fe05f20f97156d47ee3b37b;hp=d77aa8bc0412609effdc16efb19b8890bff17bf9;hpb=8681e72f844274a0c2fc2cd64bbf2451bd8db77b;p=modules%2Fhexablock.git diff --git a/src/HEXABLOCK/HexEltBase.cxx b/src/HEXABLOCK/HexEltBase.cxx old mode 100755 new mode 100644 index d77aa8b..41a4aeb --- a/src/HEXABLOCK/HexEltBase.cxx +++ b/src/HEXABLOCK/HexEltBase.cxx @@ -1,12 +1,12 @@ -// C++ : Element de base +// C++ : Element de base -// Copyright (C) 2009-2012 CEA/DEN, EDF R&D +// Copyright (C) 2009-2022 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. +// 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 @@ -29,22 +29,30 @@ EltBase::EltBase (Document* doc, EnumElt type) { el_root = doc; el_type = type; - el_id = el_root->doc_nbr_elt [type]; + el_id = 0; el_next = NULL; - el_assoc = NULL; el_status = HOK; el_mark = 0; + is_associated = false; - el_root->doc_nbr_elt [type] ++; - el_root->doc_last_elt [type] -> el_next = this; - el_root->doc_last_elt [type] = this; + // EL_NONE, EL_VERTEX, EL_EDGE, EL_QUAD, EL_HEXA, EL_REMOVED + + if (el_root==NULL) + { + el_name = "NoValid"; + setError (); + return; + } + + el_id = el_root->doc_nbr_elt [el_type]; + el_root->doc_nbr_elt [el_type] ++; + el_root->doc_last_elt [el_type] -> el_next = this; + el_root->doc_last_elt [el_type] = this; el_root->setDeprecated (1); - // EL_NONE, EL_VERTEX, EL_EDGE, EL_QUAD, EL_HEXA, EL_REMOVED char buffer [16]; - sprintf (buffer, "%c%04d", ABR_TYPES[el_type], el_id); - el_name = buffer; + el_name = getName (buffer); } // =================================================== Destructeur EltBase::~EltBase () @@ -72,14 +80,15 @@ void EltBase::remove () return; el_root->setDeprecated (2); - el_type = EL_REMOVED; + el_type = EL_REMOVED; + el_status = HERR; int nbp = el_parent.size(); for (int nro=0 ; nroisHere()) - elt->remove (); - } + elt->remove (); + } } // =================================================== suppress void EltBase::suppress () @@ -88,73 +97,45 @@ void EltBase::suppress () return; el_root->setDeprecated (2); - el_type = EL_REMOVED; + el_type = EL_REMOVED; + el_status = HERR; } -// ========================================================= replaceAssociation -void EltBase::replaceAssociation (EltBase* orig) -{ - if ( orig == NULL || orig->el_assoc == NULL - || orig == this || orig->el_assoc == el_assoc) - return; - - if (el_assoc==NULL) - el_assoc = orig->el_assoc; - else - el_root->hputError (W_REPL_ASSOC, this, orig); -} -// ========================================================= copyAssociation -void EltBase::copyAssociation (EltBase* orig) -{ - if ( orig == NULL || orig->el_assoc == NULL - || orig == this || orig->el_assoc == el_assoc) - return; - - el_assoc = orig->el_assoc; - el_root->hputError (W_DISCO_ASSOC, orig); -} -// ========================================================= getName +// ========================================================= getName cpchar EltBase::getName () { return el_name.c_str() ; } -// ========================================================= getName +// ========================================================= getName char* EltBase::getName (pchar buffer) +{ + return makeName (el_type, el_id, buffer); +} +// ========================================================= makeName +char* EltBase::makeName (int type, int id, char* name) { // EL_NONE, EL_VERTEX, EL_EDGE, EL_QUAD, EL_HEXA, EL_REMOVED - sprintf (buffer, "%c%04d", ABR_TYPES[el_type], el_id); - return buffer; + sprintf (name, "%c%04d", ABR_TYPES[type], id); + return name; } -// ========================================================= printName + +// ========================================================= printName void EltBase::printName (cpchar sep) { char nom[12]; printf ("%s%s", getName(nom), sep); } -// ========================================================= setAssociation -void EltBase::setAssociation (Shape* forme) -{ - el_assoc = forme; - - if (el_root->debug (2)) - cout << " Vertex " << el_name << " : setAssociation" << endl; -} -// ========================================================= dumpRef +// ========================================================= dumpRef void EltBase::dumpRef () { - int nbp = el_parent.size(); + int nbp = el_parent.size(); bool prems = true; - if (nbp==0) - { - printf ("\n"); - } - - for (int nro=0 ; nroisHere ()) { - if (prems) + if (prems) printf ("\t isin "); prems = false; el_parent[nro]->printName(", "); @@ -163,6 +144,43 @@ void EltBase::dumpRef () printf ("\n"); } +// ========================================================= setId +void EltBase::setId (int ln) +{ + char buffer [16]; + bool defname = el_name == getName (buffer); + el_id = ln; + int maxid = std::max (el_root->doc_nbr_elt[el_type], ln+1); + + el_root->doc_nbr_elt[el_type] = maxid; + if (defname) + el_name = getName (buffer); +} +// ========================================================= makeVarName +char* EltBase::makeVarName (char* nom) +{ + static cpchar PREFIX [EL_MAXI] = {"undef", "ver", "edge", "quad", "hexa", + "vect", "grid", "cyl", "pipe", "group", + "law", "shape", "subsh", "prop", + "doc", "Xxxx" }; + sprintf (nom, "%s%d", PREFIX[el_type], el_id); + return nom; +} +// ========================================================= debug +bool EltBase::debug (int niv) +{ + return el_root != NULL && el_root->getLevel() > niv ; +} +// ========================================================= getNextName +std::string EltBase::getNextName () +{ + if (el_root != NULL) + return el_root->getNextName (el_type); + + char name [16]; + makeName (el_type, 0, name); + return std::string (name); +} END_NAMESPACE_HEXA