Salome HOME
d288638cabb128a89e07fc1e40dae1f75d7dbc33
[modules/hexablock.git] / src / HEXABLOCK / HexQuad.hxx
1
2 // class : Les Quadrangles
3
4 // Copyright (C) 2009-2023  CEA, EDF
5 //
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, or (at your option) any later version.
10 //
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.
15 //
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
19 //
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22 #ifndef __QUAD_H
23 #define __QUAD_H
24
25 #include "HexEdge.hxx"
26
27 BEGIN_NAMESPACE_HEXA
28
29 #ifndef SWIG
30 struct StrOrient
31 {
32    Vertex* v11;     // 1er sommet 1er quad
33    Vertex* v12;     // 2eme
34    Vertex* v21;     // 1er sommet 2eme quad
35    Vertex* v22;     // 2eme
36    int dir;         // direction element suivant
37
38 StrOrient ( Vertex* n11, Vertex* n12, Vertex* n21, Vertex* n22, int d=0)
39     : v11 (n11), v12 (n12), v21 (n21), v22 (n22), dir (d) {}
40
41 StrOrient ( StrOrient* s)
42     : v11 (s->v11), v12(s->v12), v21(s->v21), v22(s->v22), dir(s->dir){}
43
44 };
45 #endif
46
47 class HexaExport Quad : public EltBase
48 {
49 public:
50     virtual Edge*   getEdge   (int  nro);
51     virtual Vertex* getVertex (int  nro);
52
53     int   addAssociation (NewShape*  forme, int subid);
54     virtual void  clearAssociation  ();
55
56     void setColor  (double valeur);
57     Vertex* nearestVertex (Vertex* other);
58     double* getCenter     (double* center);
59
60     Quad (Vertex* va, Vertex* vb, Vertex* vc, Vertex* vd);
61
62 #ifndef SWIG
63 public:
64     Quad (Edge* ea, Edge* eb, Edge* ec, Edge* ed);
65     Quad (Quad* other);
66
67     virtual int countEdge   () { return QUAD4; }
68     virtual int countVertex () { return QUAD4; }
69
70     Hexa* getParent (int nro);
71
72     Edge* findEdge   (Vertex* v1, Vertex*v2);
73     Edge* commonEdge (Quad* other);
74     int   anaMerge (Vertex* v1, Vertex* v2, Vertex* tv[], Edge* te[]);
75
76     int   ordoVertex (Vertex* v1, Vertex* v2, Vertex* tv[]);
77     int   ordonner   (Vertex* v1, Vertex* v2, Vertex* tv[], Edge* ted[]);
78
79     int   inter     (Quad* other, int& nro);
80     Edge* inter     (Quad* other);
81     bool  definedBy (Vertex* v1, Vertex* v2);
82     bool  definedBy (Edge*   e1,  Edge*   e2);
83
84     int   indexVertex (Vertex* elt);
85     int   indexEdge   (Edge*   elt);
86
87     //int   accoupler (Quad* other, StrOrient* orient);
88     int   coupler (Quad* other, StrOrient* orient, Elements* table);
89
90     Edge*   getOpposEdge   (Edge* arete, int &sens);
91     Vertex* getOpposVertex (Vertex* sommet);
92     Hexa*   opposedHexa (Hexa* hexa);
93
94     virtual void majReferences();            // M.A.J relation "utilise par"
95     virtual void dump ();
96     virtual void dumpPlus ();
97     virtual void saveXml (XmlWriter* xml);
98     void setScalar (double valeur)              { setColor (valeur); }
99
100     void         replace (Quad* old);
101     virtual void replaceEdge   (Edge*   old, Edge*   nouveau);
102     virtual void replaceVertex (Vertex* old, Vertex* nouveau);
103
104     virtual void  setAssociation (Shape* forme) {}              // PERIME
105     virtual int   addAssociation (Shape* forme) {return HOK ; } // PERIME
106
107
108     // const Shapes& getAssociations ()        { return tab_shapes ; }
109
110
111     virtual void duplicate ();
112     Quad* getClone ()               {  return q_clone ; }
113
114     Edge* getOpposEdge     (Edge* arete);   // Version simplifiee
115     Edge* getPerpendicular (Edge* arete, Vertex* node);
116     int   getOrientation ()            { return q_orientation; }
117     int   setOrientation ();
118     void  setOrientation (int ori);
119     void  reorienter ();
120                                                       // Hexa5
121     int   addAssociation (FaceShape* forme);
122     int   countAssociation ()                     { return tab_assoc.size () ; }
123     FaceShape* getAssociation (int nro);
124
125     double  dist2         (double* point);
126
127 private:
128     friend class Cloner;
129     Quad* getBrother (StrOrient* orient);
130
131 private:
132     Edge*   q_edge   [QUAD4];
133     Vertex* q_vertex [QUAD4];
134     Quad*   q_clone;
135     int     q_orientation;
136
137     FaceShapes tab_assoc;
138 #endif
139 };
140 END_NAMESPACE_HEXA
141 #endif
142