2 // Class : EltBase de base des Vertex/Edge/Quad, etc...
7 #include "hexa_base.hxx"
8 #include "HexDocument.hxx"
11 #define HexDump(x) {printf(#x " = "); if (x) x->dump(); else printf("NULL\n");}
12 #define PrintName(x) if (x) x->printName(); else printf ("NULL, ")
13 #define PutName(x) { printf(#x " = "); if (x) x->printName("\n"); else printf("NULL\n"); }
20 virtual Hexa* getHexa (int nro) { return NULL; }
21 virtual Quad* getQuad (int nro) { return NULL; }
22 virtual Edge* getEdge (int nro) { return NULL; }
23 virtual Vertex* getVertex (int nro) { return NULL; }
25 virtual int countHexa () { return 0; }
26 virtual int countQuad () { return 0; }
27 virtual int countEdge () { return 0; }
28 virtual int countVertex () { return 0; }
30 virtual int getError () { return el_status; }
31 virtual bool isValid () { return el_status==HOK; }
33 virtual void setAssociation (Shape* forme) { el_assoc = forme ; }
34 virtual void removeAssociation () { el_assoc = NULL ; }
35 virtual Shape* getAssociation () { return el_assoc ; }
38 // virtual void replaceHexa (Hexa* old, Hexa* nouveau) {}
39 // virtual void replaceQuad (Quad* old, Quad* nouveau) {}
40 virtual void replaceEdge (Edge* old, Edge* nouveau)
41 { printf ("rep-edge\n") ; }
42 virtual void replaceVertex (Vertex* old, Vertex* nouveau)
43 { printf ("rep-vertex\n") ; }
45 EltBase (Document* doc, EnumElt type=EL_NONE);
46 EltBase (EnumElt type=EL_NONE);
49 virtual void remove ();
50 virtual void suppress ();
52 virtual void saveXml (XmlWriter& xml) {}
53 virtual void majReferences () { }
55 EltBase* next () { return el_next; }
56 void setNext (EltBase* suivant) { el_next = suivant; }
57 int getId () { return el_id; }
58 void setId (int ln) { el_id = ln; }
59 Document* dad () { return el_root; }
60 EnumElt getType () { return el_type; }
61 bool isHere () { return el_type!=EL_REMOVED; }
62 bool isDeleted () { return el_type==EL_REMOVED; }
64 // On s'occupe des parents
66 void razReferences () { el_parent.clear() ; }
67 void addParent (EltBase* dad) { if (dad) el_parent.push_back(dad) ; }
68 int getNbrParents () { return el_parent.size() ; }
70 EltBase* getFather (int nro);
72 int getMark () { return el_mark; }
73 void setMark (int ln) { el_mark = ln ; }
74 char* getName (pchar nom);
75 void printName (cpchar sep=" ");
78 bool debug (int niv=0) { return el_root->getLevel() > niv ; }
89 std::vector <EltBase*> el_parent;
91 // ========================================================= getName
92 inline char* EltBase::getName (pchar nom)
94 // EL_NONE, EL_VERTEX, EL_EDGE, EL_QUAD, EL_HEXA, EL_REMOVED
95 cpchar nm_type = "xveqh????";
97 sprintf (nom, "%c%04d", nm_type[el_type], el_id);
100 // ========================================================= printName
101 inline void EltBase::printName (cpchar sep)
105 printf ("%s%s", getName(nom), sep);
107 // ========================================================= dump
108 inline void EltBase::dump ()
110 printf ("Elt%d Nro=%04d", el_type, el_id);
113 // ========================================================= dumpRef
114 inline void EltBase::dumpRef ()
116 int nbp = el_parent.size();
121 for (int nro=0 ; nro<nbp ; nro++)
122 el_parent[nro]->printName(", ");
126 // ========================================================= getFather
127 inline EltBase* EltBase::getFather (int nro)
130 if (nro >= 0 && nro < (int) el_parent.size() && isHere()
131 && el_parent[nro]->isHere())
132 elt = el_parent[nro];
136 // ========================================================= getFather
137 inline bool EltBase::hasParents ()
139 int nbp = el_parent.size();
140 for (int nro=0 ; nro<nbp ; nro++)
141 if (el_parent[nro]!=NULL && el_parent[nro]->isHere())