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"
32 // Fonctions utilisateur
35 const char* getName () { return doc_name.c_str() ; }
36 bool isSaved () { return doc_saved ; }
37 int setName (const char* name);
38 int save (const char* ficxml);
40 int getLevel () { return doc_db ; }
41 void setLevel (int niv);
43 Hexa* getHexa (int nro);
44 Quad* getQuad (int nro);
45 Edge* getEdge (int nro);
46 Vertex* getVertex (int nro);
48 int countHexa () { return countElement (EL_HEXA); }
49 int countQuad () { return countElement (EL_QUAD); }
50 int countEdge () { return countElement (EL_EDGE); }
51 int countVertex () { return countElement (EL_VERTEX); }
53 // Creation d'elements
54 Vertex* addVertex (double x=0.0, double y=0.0, double z=0.0);
55 Edge* addEdge (Vertex* va, Vertex* vb);
56 Edge* addEdge (Vertex* va, Vector* vec);
58 Quad* addQuadVertices (Vertex* v1, Vertex* v2, Vertex* v3, Vertex* v4);
59 Quad* addQuad (Edge* v1, Edge* v2, Edge* v3, Edge* v4);
61 Hexa* addHexaVertices (Vertex* v1, Vertex* v2, Vertex* v3, Vertex* v4,
62 Vertex* v5, Vertex* v6, Vertex* v7, Vertex* v8);
63 Hexa* addHexa (Quad* qa, Quad* qb, Quad* qc, Quad* qd, Quad* qe, Quad* qf);
65 Vector* addVector (double dx=0.0, double dy=0.0, double dz=0.0);
66 Vector* addVectorVertices (Vertex* va, Vertex* vb);
68 Elements* makeCartesian (Vertex* v, Vector* v1,
69 int px, int py, int pz, int mx=0, int my=0, int mz=0);
70 Elements* makeCartesian (Vertex* v, Vector* v1, Vector* v2, Vector* v3,
71 int px, int py, int pz, int mx=0, int my=0, int mz=0);
73 Elements* makeCylindrical (Vertex* c, Vector* b, Vector* h, double dr,
74 double da, double dl, int nr, int na, int nl, bool fill=false);
77 Elements* makeSpherical (Vertex* v, Vector* dv, int nb, double k=1) {return NULL;}
78 Elements* makeSpherical (Vertex* center, double rayon, int nb, double k=1);
80 Elements* prismQuad (Quad* start, Vector* dv, int nb);
81 Elements* prismQuads (Quads& start, Vector* dv, int nb);
82 Elements* prismQuadsVec (Quads& start, Vector* dv, RealVector& th, int k=0);
84 Elements* joinQuad (Quad* start, Quad* dest, Vertex* v1, Vertex* v2,
85 Vertex* v3, Vertex* v4, int nb);
86 Elements* joinQuads (Quads& start, Quad* dest, Vertex* v1, Vertex* v2,
87 Vertex* v3, Vertex* v4, int nb);
89 Cylinder* addCylinder (Vertex* b, Vector* d, double r, double h);
90 Elements* makeCylinder (Cylinder* cyl, Vector* vx, int nr, int na, int nl);
91 CrossElements* makeCylinders (Cylinder* cyl1, Cylinder* cyl2);
93 Pipe* addPipe (Vertex* b, Vector* d, double ri, double re, double h);
94 Elements* makePipe (Pipe* pip, Vector* vx, int nr, int na, int nl);
95 CrossElements* makePipes (Pipe* pipe1, Pipe* pipe2);
97 int removeHexa (Hexa* maille);
98 int removeQuad (Quad* maille);
99 int removeConnectedHexa (Hexa* maille);
100 int removeElements (Elements* bloc);
102 Vertex* findVertex (double vx, double vy, double vz);
103 Edge* findEdge (Vertex* va, Vertex* vb);
104 Quad* findQuad (Vertex* va, Vertex* vb);
105 Hexa* findHexa (Vertex* va, Vertex* vb);
107 Vertex* findVertex (int id);
109 int mergeVertices (Vertex* v1, Vertex* v2);
110 int mergeEdges (Edge* e1, Edge* e2, Vertex* v1, Vertex* v2);
111 int mergeQuads (Quad* q1, Quad* q2, Vertex* v1, Vertex* v2,
112 Vertex* v3, Vertex* v4);
113 int closeQuads (Quad* q1, Quad* q2);
115 Elements* makeTranslation (Elements* elts, Vector* trans);
116 Elements* makeScale (Elements* elts, Vertex* ver, double k);
117 Elements* makeRotation (Elements* elts, Vertex* ver, Vector* vec,
119 Elements* makeSymmetryPoint (Elements* elts, Vertex* ver);
120 Elements* makeSymmetryLine (Elements* elts, Vertex* ver, Vector* vec);
121 Elements* makeSymmetryPlane (Elements* elts, Vertex* ver, Vector* vec);
123 int performTranslation (Elements* elts, Vector* trans);
124 int performScale (Elements* elts, Vertex* ver, double k);
125 int performRotation (Elements* elts, Vertex* ver, Vector* vec, double angle);
126 int performSymmetryPoint (Elements* elts, Vertex* ver);
127 int performSymmetryLine (Elements* elts, Vertex* ver, Vector* vec);
128 int performSymmetryPlane (Elements* elts, Vertex* ver, Vector* vec);
130 void setTolerance (double tol) { doc_tolerance = std::max (tol, 0.0); }
131 double getTolerance () { return doc_tolerance; }
133 Elements* disconnectQuad (Hexa* maille, Quad* face);
134 Elements* disconnectEdge (Hexa* maille, Edge* arete);
135 Elements* disconnectVertex (Hexa* maille, Vertex* noeud);
136 Elements* disconnectEdges (Hexas& thexas, Edges& edges);
138 Elements* cut (Edge* edge, int nbcuts);
140 Group* addGroup (cpchar name, EnumGroup kind);
141 Group* getGroup (int nro) { return doc_group [nro]; }
142 Group* findGroup (cpchar name);
143 int removeGroup (Group* grp);
144 int countGroup () { return (int) doc_group.size(); }
146 // ---------------------------------------------------
148 Law* addLaw (const char* name, int nbnodes);
149 Law* addLaw (Law* law); // lo-add-lololo
150 int countLaw () { return nbr_laws ; }
151 Law* getLaw (int nro);
152 Law* findLaw (const char* name);
153 int removeLaw (Law* loi);
155 // ---------------------------------------------------
156 int countPropagation ();
157 Propagation* getPropagation (int nro);
158 Propagation* findPropagation (Edge* arete);
159 void dumpPropagation ();
161 int countVector () { return doc_vector.size(); }
162 int countCylinder () { return doc_cylinder.size(); }
163 int countPipe () { return doc_pipe.size(); }
165 Vector* getVector (int nro) { return doc_vector [nro]; }
166 Cylinder* getCylinder (int nro) { return doc_cylinder [nro]; }
167 Pipe* getPipe (int nro) { return doc_pipe [nro]; }
170 int associateOpenedLine (Edge* mstart, Edges& mline, Shape* gstart,
171 double pstart, Shapes& gline, double pend);
172 int associateClosedLine (Vertex* mfirst, Edge* mstart, Edges& mline,
173 Shape* gstart, double pstart, bool inv,
176 void setShape (Shape* forme) { doc_shape = forme ; }
177 Shape* getShape () { return doc_shape ; }
179 // --------------------------------------------------- Evols Hexa3
181 Document* copyDocument ();
183 int countUsedHexa ();
184 int countUsedQuad ();
185 int countUsedEdge ();
186 int countUsedVertex ();
188 Hexa* getUsedHexa (int nro);
189 Quad* getUsedQuad (int nro);
190 Edge* getUsedEdge (int nro);
191 Vertex* getUsedVertex (int nro);
193 Hexa* addHexa2Quads (Quad* q1, Quad* q2);
194 Hexa* addHexa3Quads (Quad* q1, Quad* q2, Quad* q3);
195 Hexa* addHexa4Quads (Quad* q1, Quad* q2, Quad* q3, Quad* q4);
196 Hexa* addHexa5Quads (Quad* q1, Quad* q2, Quad* q3, Quad* q4, Quad* q5);
198 Elements* revolutionQuads (Quads& start, Vertex* center, Vector* axis,
201 Elements* makeSphere (Vertex* center, Vector* vx, Vector* vz,
202 double radius, double radhole,
204 int nrad, int nang, int nhaut);
206 Elements* makePartSphere (Vertex* center, Vector* vx, Vector* vz,
207 double radius, double radhole,
208 Vertex* plorig, double angle,
209 int nrad, int nang, int nhaut);
211 Elements* makeRind (Vertex* center, Vector* vx, Vector* vz,
212 double radext, double radint, double radhole,
214 int nrad, int nang, int nhaut);
216 Elements* makePartRind (Vertex* center, Vector* vx, Vector* vz,
217 double radext, double radint, double radhole,
218 Vertex* plorig, double angle,
219 int nrad, int nang, int nhaut);
221 Elements* replace (Quads& pattern, Vertex* p1, Vertex* c1,
222 Vertex* p2, Vertex* c2, Vertex* p3, Vertex* c3);
224 Elements* makeCylindricals (Vertex* c, Vector* b, Vector* h,
225 RealVector& tdr, RealVector& tda, RealVector& tdh,
228 // --------------------------------------------------- Evols Hexa4'
230 void clearAssociation ();
232 typedef std::vector <Vertex*> Vertices;
233 void getAssoEdges (Edges& tabelt);
234 void getAssoVertices (Vertices& tabelt);
237 Document (cpchar name);
240 int loadXml (cpchar name);
241 int setXml (cpchar flux);
244 EltBase* getFirstEltBase (EnumElt type) { return doc_first_elt [type]; }
245 EltBase* getLastEltBase (EnumElt type) { return doc_last_elt [type]; }
246 void setDeprecated (int level=1);
249 void markAll (int marque, int type=-1);
250 int saveVtk (cpchar nomfic);
251 int saveVtk (cpchar radical, int &nro);
253 void putError (cpchar mess, cpchar info1=NULL, cpchar info2=NULL);
254 void nputError (cpchar mess, int info1, cpchar info2=NULL);
255 void hputError (cpchar mess, EltBase* e1, EltBase* e2=NULL);
257 void majReferences (); // M.A.J relation "utilise par"
258 void update () { if (maj_connection) majReferences (); }
259 bool debug (int niv=0) { return doc_db > niv ; }
261 void reorderFaces ();
262 void reorderQuads ();
268 int genXml (cpchar filename);
269 int parseXml (XmlTree& xml);
271 void replaceVertex (Vertex* v1, Vertex* v2);
272 void replaceEdge (Edge* e1, Edge* e2);
273 void replaceQuad (Quad* q1, Quad* q2);
275 int countElement (EnumElt type);
276 EltBase* getElement (EnumElt type, int nro);
278 void majPropagation ();
281 Elements* clonerElements (Elements* table, Matrix* matrice);
282 int associateCascade (Edges& mline, int msens[], Shape* gstart,
283 Shapes& gline, double pstart, double pend, bool clos,
285 int associateLine (Vertex* mfirst, Edge* mstart, Edges& mline,
286 Shape* gstart, double pstart, Shapes& gline, double pend,
289 // --------------------------------------------------- Evols Hexa3
290 Hexa* addHexaQuadsAB (AnaQuads& strquads);
291 Hexa* addHexaQuadsAC (AnaQuads& strquads);
292 Hexa* addHexaQuadsACE (AnaQuads& strquads);
293 Hexa* addHexaQuadsACD (AnaQuads& strquads);
294 Hexa* addHexaQuadsABCD (AnaQuads& strquads);
295 Hexa* addHexaQuadsACDE (AnaQuads& strquads);
297 Shape* parseShape (XmlTree* node);
299 EltBase* findElement (EnumElt type, int ident);
302 friend class EltBase;
312 std::string doc_name;
313 EltBase* doc_first_elt [EL_MAXI];
314 EltBase* doc_last_elt [EL_MAXI];
315 int doc_nbr_elt [EL_MAXI];
316 double doc_tolerance;
318 std::vector <Law*> doc_laws;
322 int nbr_propagations;
323 bool maj_propagation;
325 std::vector <Propagation*> doc_propagation;
326 std::vector <Group*> doc_group;
328 std::vector <Vector*> doc_vector;
329 std::vector <Cylinder*> doc_cylinder;
330 std::vector <Pipe*> doc_pipe;
333 // --------------------------------------------------- HexaBlock v3
337 std::vector <Hexa*> doc_used_hexas;
338 std::vector <Quad*> doc_used_quads;
339 std::vector <Edge*> doc_used_edges;
340 std::vector <Vertex*> doc_used_vertex;
347 // ========================================================= saveVtk (avec nro)
348 inline int Document::saveVtk (cpchar radical, int &nro)
351 sprintf (num, "%d", nro);
354 string filename = radical;
357 int ier = saveVtk (filename.c_str());
360 // ========================================================= setDeprecated
361 inline void Document::setDeprecated (int level)
365 // En cas de destruction : parents invalides
366 case 2 : maj_connection = true;
367 purge_elements = true;
368 // creation + destruction : propagations a revoir
369 case 1 : maj_propagation = true;
371 default: doc_modified = true;
372 count_modified = true;