2 // C++ : Element de base
4 // Copyright (C) 2009-2012 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.
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 "HexEltBase.hxx"
23 #include "HexDocument.hxx"
24 #include "HexDiagnostics.hxx"
27 // =================================================== Constructeur
28 EltBase::EltBase (Document* doc, EnumElt type)
32 el_id = el_root->doc_nbr_elt [type];
39 el_root->doc_nbr_elt [type] ++;
40 el_root->doc_last_elt [type] -> el_next = this;
41 el_root->doc_last_elt [type] = this;
42 el_root->setDeprecated (1);
44 // EL_NONE, EL_VERTEX, EL_EDGE, EL_QUAD, EL_HEXA, EL_REMOVED
46 sprintf (buffer, "%c%04d", ABR_TYPES[el_type], el_id);
49 // =================================================== Destructeur
52 // printf (" delete ");
55 // =================================================== Constructeur Bis
56 // Utilise uniquement dans le constructeur de Document
57 // Creation d'un premier element fictif pour accelerer les chainages
58 EltBase::EltBase (EnumElt type)
68 // =================================================== remove
69 void EltBase::remove ()
71 if (el_type == EL_REMOVED)
74 el_root->setDeprecated (2);
76 int nbp = el_parent.size();
77 for (int nro=0 ; nro<nbp ; nro++)
79 EltBase* elt = el_parent[nro];
80 if (elt != NULL && elt->isHere())
84 // =================================================== suppress
85 void EltBase::suppress ()
87 if (el_type == EL_REMOVED)
90 el_root->setDeprecated (2);
93 // ========================================================= replaceAssociation
94 void EltBase::replaceAssociation (EltBase* orig)
96 if ( orig == NULL || orig->el_assoc == NULL
97 || orig == this || orig->el_assoc == el_assoc)
101 el_assoc = orig->el_assoc;
103 el_root->hputError (W_REPL_ASSOC, this, orig);
105 // ========================================================= copyAssociation
106 void EltBase::copyAssociation (EltBase* orig)
108 if ( orig == NULL || orig->el_assoc == NULL
109 || orig == this || orig->el_assoc == el_assoc)
112 el_assoc = orig->el_assoc;
113 el_root->hputError (W_DISCO_ASSOC, orig);
115 // ========================================================= getName
116 cpchar EltBase::getName ()
118 return el_name.c_str() ;
120 // ========================================================= getName
121 char* EltBase::getName (pchar buffer)
123 // EL_NONE, EL_VERTEX, EL_EDGE, EL_QUAD, EL_HEXA, EL_REMOVED
124 sprintf (buffer, "%c%04d", ABR_TYPES[el_type], el_id);
127 // ========================================================= printName
128 void EltBase::printName (cpchar sep)
132 printf ("%s%s", getName(nom), sep);
134 // ========================================================= setAssociation
135 void EltBase::setAssociation (Shape* forme)
139 if (el_root->debug (2))
140 cout << " Vertex " << el_name << " : setAssociation" << endl;
142 // ========================================================= dumpRef
143 void EltBase::dumpRef ()
145 int nbp = el_parent.size();
153 for (int nro=0 ; nro<nbp ; nro++)
155 if (el_parent[nro]->isHere ())
160 el_parent[nro]->printName(", ");