2 // Class : Element de base des Vertex/Edge/Quad, etc...
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
26 #include "hexa_base.hxx"
27 #include "HexDocument.hxx"
30 #define HexDump(x) {printf(#x " = "); if (x) x->dump(); else printf("NULL\n");}
31 #define PrintName(x) if (x) x->printName(); else printf ("NULL, ")
32 #define PutName(x) { printf(#x " = "); if (x) x->printName("\n"); else printf("NULL\n"); }
34 #define GetClone(elt) ((elt)==NULL ? NULL : elt->getClone())
35 #define BadElement(elt) (elt)==NULL || (elt)->isBad()
36 #define ABR_TYPES "xveqhw????"
43 virtual Hexa* getHexa (int nro) { return NULL; }
44 virtual Quad* getQuad (int nro) { return NULL; }
45 virtual Edge* getEdge (int nro) { return NULL; }
46 virtual Vertex* getVertex (int nro) { return NULL; }
48 virtual int countHexa () { return 0; }
49 virtual int countQuad () { return 0; }
50 virtual int countEdge () { return 0; }
51 virtual int countVertex () { return 0; }
53 virtual void setError (int kod=HERR) { el_status = kod; }
54 virtual int getError () { return el_status; }
55 virtual bool isValid () { return el_status==HOK; }
56 virtual bool isBad () { return el_status!=HOK; }
58 virtual void setAssociation (Shape* forme);
59 virtual void clearAssociation () { el_assoc = NULL ; }
60 virtual void duplicate () {}
61 virtual Shape* getAssociation () { return el_assoc ; }
63 void copyAssociation (EltBase* orig);
64 void replaceAssociation (EltBase* orig);
67 virtual void replaceEdge (Edge* old, Edge* nouveau)
68 { printf ("rep-edge\n") ; }
69 virtual void replaceVertex (Vertex* old, Vertex* nouveau)
70 { printf ("rep-vertex\n") ; }
72 EltBase (Document* doc, EnumElt type=EL_NONE);
73 EltBase (EnumElt type=EL_NONE);
76 virtual void remove ();
77 virtual void suppress ();
79 virtual void saveXml (XmlWriter* xml) {}
80 virtual void majReferences () { }
82 EltBase* next () { return el_next; }
83 void setNext (EltBase* suivant) { el_next = suivant; }
84 int getId () { return el_id; }
85 void setId (int ln) { el_id = ln; }
86 Document* dad () { return el_root; }
87 EnumElt getType () { return el_type; }
88 bool isHere () { return el_type!=EL_REMOVED; }
89 bool isDeleted () { return el_type==EL_REMOVED; }
91 // On s'occupe des parents
93 void razReferences () { el_parent.clear() ; }
94 void addParent (EltBase* dad) { if (dad) el_parent.push_back(dad) ; }
95 int getNbrParents () { return el_parent.size() ; }
97 EltBase* getFather (int nro);
99 int getMark () { return el_mark; }
100 void setMark (int ln) { el_mark = ln ; }
101 char* getName (pchar nom);
102 void printName (cpchar sep=" ");
106 void setName (const string& nom) { el_name = nom ; }
107 void setName (cpchar nom) { el_name = nom ; }
109 bool debug (int niv=0) { return el_root->getLevel() > niv ; }
121 std::vector <EltBase*> el_parent;
123 // ========================================================= dump
124 inline void EltBase::dump ()
126 printf ("Elt%d Nro=%04d", el_type, el_id);
130 // ========================================================= getFather
131 inline EltBase* EltBase::getFather (int nro)
134 if (nro >= 0 && nro < (int) el_parent.size() && isHere()
135 && el_parent[nro]->isHere())
136 elt = el_parent[nro];
140 // ========================================================= hasParents
141 inline bool EltBase::hasParents ()
143 int nbp = el_parent.size();
144 for (int nro=0 ; nro<nbp ; nro++)
145 if (el_parent[nro]!=NULL && el_parent[nro]->isHere())
150 // ========================================================= clear_association
151 inline void clear_association (EltBase* elt)
153 if (elt != NULL && elt->isHere() && elt->isValid())
154 elt -> clearAssociation ();