X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FHEXABLOCK%2FHexEltBase.cxx;h=41a4aebe480fbfd8daa6010acf69828b532922fc;hb=f7c6169bde92dd9e0fe05f20f97156d47ee3b37b;hp=c5aa79eda739facb5b22aac5bcfb7fb2a543f8dd;hpb=3362101497b1bc0ded71b74c0806ac06c64d49d3;p=modules%2Fhexablock.git diff --git a/src/HEXABLOCK/HexEltBase.cxx b/src/HEXABLOCK/HexEltBase.cxx old mode 100755 new mode 100644 index c5aa79e..41a4aeb --- a/src/HEXABLOCK/HexEltBase.cxx +++ b/src/HEXABLOCK/HexEltBase.cxx @@ -1,8 +1,27 @@ -// C++ : Gestion des noeuds +// C++ : Element de base +// 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, 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 "HexEltBase.hxx" #include "HexDocument.hxx" +#include "HexDiagnostics.hxx" BEGIN_NAMESPACE_HEXA // =================================================== Constructeur @@ -10,17 +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); + + char buffer [16]; + el_name = getName (buffer); } // =================================================== Destructeur EltBase::~EltBase () @@ -48,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 () @@ -64,7 +97,90 @@ void EltBase::suppress () return; el_root->setDeprecated (2); - el_type = EL_REMOVED; + el_type = EL_REMOVED; + el_status = HERR; +} +// ========================================================= getName +cpchar EltBase::getName () +{ + return el_name.c_str() ; +} +// ========================================================= 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 (name, "%c%04d", ABR_TYPES[type], id); + return name; +} + +// ========================================================= printName +void EltBase::printName (cpchar sep) +{ + char nom[12]; + + printf ("%s%s", getName(nom), sep); +} +// ========================================================= dumpRef +void EltBase::dumpRef () +{ + int nbp = el_parent.size(); + bool prems = true; + + for (int nro=0 ; nroisHere ()) + { + if (prems) + printf ("\t isin "); + prems = false; + el_parent[nro]->printName(", "); + } + } + + 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