Salome HOME
Join modifications from branch OCC_development_for_3_2_0a2
[modules/smesh.git] / src / StdMeshers / StdMeshers_Helper.hxx
1 // File:      StdMeshers_Helper.hxx
2 // Created:   15.02.06 14:48:09
3 // Author:    Sergey KUUL
4 // Copyright: Open CASCADE 2006
5
6
7 #ifndef StdMeshers_Helper_HeaderFile
8 #define StdMeshers_Helper_HeaderFile
9
10 #include <SMESH_Mesh.hxx>
11 #include <TopoDS_Shape.hxx>
12 #include <SMDS_MeshNode.hxx>
13 #include <TopoDS_Face.hxx>
14 #include <gp_Pnt2d.hxx>
15
16 #include <map>
17
18 typedef pair<const SMDS_MeshNode*, const SMDS_MeshNode*> NLink;
19 typedef map<NLink, const SMDS_MeshNode*> NLinkNodeMap;
20 typedef map<NLink, const SMDS_MeshNode*>::iterator ItNLinkNode;
21
22 /*!
23  * \brief It helps meshers to add elements
24  *
25  * It allow meshers not to care about creation of medium nodes
26  * when filling a quadratic mesh. Helper does it itself.
27  * It defines degree of elements to create when IsQuadraticSubMesh()
28  * is called.
29  */
30
31 class StdMeshers_Helper 
32 {
33  public:
34   // ---------- PUBLIC METHODS ----------
35
36   /// Empty constructor
37   StdMeshers_Helper(SMESH_Mesh& theMesh)
38     { myMesh=(void *)&theMesh; myCreateQuadratic = false; }
39
40   SMESH_Mesh* GetMesh() const
41     { return (SMESH_Mesh*)myMesh; }
42     
43   /// Copy constructor
44   //Standard_EXPORT StdMeshers_Helper (const StdMeshers_Helper& theOther);
45
46   /// Destructor
47   //Standard_EXPORT virtual ~StdMeshers_Helper ();
48
49   /**
50    * Check submesh for given shape
51    * Check if all elements on this shape
52    * are quadratic, if yes => set true to myCreateQuadratic 
53    * (default value is false). Also fill myNLinkNodeMap
54    * Returns myCreateQuadratic
55    */
56   bool IsQuadraticSubMesh(const TopoDS_Shape& theShape);
57
58   /*!
59    * \brief Returns true if given node is medium
60     * \param n - node to check
61     * \param typeToCheck - type of elements containing the node to ask about node status
62     * \retval bool - check result
63    */
64   static bool IsMedium(const SMDS_MeshNode*      node,
65                        const SMDSAbs_ElementType typeToCheck = SMDSAbs_All);
66
67   /**
68    * Auxilary function for filling myNLinkNodeMap
69    */
70   void AddNLinkNode(const SMDS_MeshNode* n1,
71                     const SMDS_MeshNode* n2,
72                     const SMDS_MeshNode* n12);
73
74   /**
75    * Auxilary function for filling myNLinkNodeMap
76    */
77   void AddNLinkNodeMap(const NLinkNodeMap& aMap)
78     { myNLinkNodeMap.insert(aMap.begin(), aMap.end()); }
79
80   /**
81    * Returns myNLinkNodeMap
82    */
83   const NLinkNodeMap& GetNLinkNodeMap() { return myNLinkNodeMap; }
84
85   /*!
86    * \brief Return node UV on face
87     * \param F - the face
88     * \param n - the node
89     * \param n2 - a medium node will be placed between n and n2
90     * \retval gp_XY - resulting UV
91    * 
92    * Auxilary function called form GetMediumNode()
93    */
94   gp_XY GetNodeUV(const TopoDS_Face&   F,
95                   const SMDS_MeshNode* n,
96                   const SMDS_MeshNode* n2=0);
97
98   /**
99    * Special function for search or creation medium node
100    */
101   const SMDS_MeshNode* GetMediumNode(const SMDS_MeshNode* n1,
102                                      const SMDS_MeshNode* n2,
103                                      const bool force3d);
104   /**
105    * Special function for creation quadratic triangle
106    */
107   SMDS_MeshFace* AddFace(const SMDS_MeshNode* n1,
108                          const SMDS_MeshNode* n2,
109                          const SMDS_MeshNode* n3);
110
111   /**
112    * Special function for creation quadratic quadrangle
113    */
114   SMDS_MeshFace* AddFace(const SMDS_MeshNode* n1,
115                          const SMDS_MeshNode* n2,
116                          const SMDS_MeshNode* n3,
117                          const SMDS_MeshNode* n4);
118
119   /**
120    * Special function for creation quadratic tetraahedron
121    */
122   SMDS_MeshVolume* AddVolume(const SMDS_MeshNode* n1,
123                              const SMDS_MeshNode* n2,
124                              const SMDS_MeshNode* n3,
125                              const SMDS_MeshNode* n4);
126
127   /**
128    * Special function for creation quadratic pentahedron
129    */
130   SMDS_MeshVolume* AddVolume(const SMDS_MeshNode* n1,
131                              const SMDS_MeshNode* n2,
132                              const SMDS_MeshNode* n3,
133                              const SMDS_MeshNode* n4,
134                              const SMDS_MeshNode* n5,
135                              const SMDS_MeshNode* n6);
136
137   /**
138    * Special function for creation quadratic hexahedron
139    */
140   SMDS_MeshVolume* AddVolume(const SMDS_MeshNode* n1,
141                              const SMDS_MeshNode* n2,
142                              const SMDS_MeshNode* n3,
143                              const SMDS_MeshNode* n4,
144                              const SMDS_MeshNode* n5,
145                              const SMDS_MeshNode* n6,
146                              const SMDS_MeshNode* n7,
147                              const SMDS_MeshNode* n8);
148
149
150  protected:
151
152   /*!
153    * \brief Select UV on either of 2 pcurves of a seam edge, closest to the given UV
154     * \param uv1 - UV on the seam
155     * \param uv2 - UV within a face
156     * \retval gp_Pnt2d - selected UV
157    */
158   gp_Pnt2d GetUVOnSeam( const gp_Pnt2d& uv1, const gp_Pnt2d& uv2 ) const;
159
160  private:
161
162   void* myMesh;
163
164   int myShapeID;
165
166   // Key for creation quadratic faces
167   bool myCreateQuadratic;
168
169   // special map for using during creation quadratic faces
170   NLinkNodeMap myNLinkNodeMap;
171
172   std::set< int > mySeamShapeIds;
173   double          myPar1, myPar2; // bounds of a closed periodic surface
174   int             myParIndex;     // bounds' index (1-U, 2-V)
175
176 };
177
178
179 #endif