]> SALOME platform Git repositories - modules/smesh.git/blob - src/StdMeshers_I/StdMeshers_i.cxx
Salome HOME
Exceptions oubliées
[modules/smesh.git] / src / StdMeshers_I / StdMeshers_i.cxx
1 // Copyright (C) 2007-2020  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
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
23 //  SMESH StdMeshers : implementation of SMESH idl descriptions
24 //  File   : StdMeshers_i.cxx
25 //  Author : Julia DOROVSKIKH
26 //  Module : SMESH
27 //
28 #include "SMESH_StdMeshers_I.hxx"
29
30 #include "SMESH_Gen_i.hxx"
31
32 #include "utilities.h"
33
34 #include "StdMeshers_Adaptive1D_i.hxx"
35 #include "StdMeshers_Arithmetic1D_i.hxx"
36 #include "StdMeshers_AutomaticLength_i.hxx"
37 #include "StdMeshers_BlockRenumber_i.hxx"
38 #include "StdMeshers_CartesianParameters3D_i.hxx"
39 #include "StdMeshers_Cartesian_3D_i.hxx"
40 #include "StdMeshers_CompositeSegment_1D_i.hxx"
41 #include "StdMeshers_Deflection1D_i.hxx"
42 #include "StdMeshers_FixedPoints1D_i.hxx"
43 #include "StdMeshers_Geometric1D_i.hxx"
44 #include "StdMeshers_Hexa_3D_i.hxx"
45 #include "StdMeshers_ImportSource1D_i.hxx"
46 #include "StdMeshers_ImportSource2D_i.hxx"
47 #include "StdMeshers_Import_1D2D_i.hxx"
48 #include "StdMeshers_Import_1D_i.hxx"
49 #include "StdMeshers_LayerDistribution2D_i.hxx"
50 #include "StdMeshers_LayerDistribution_i.hxx"
51 #include "StdMeshers_LengthFromEdges_i.hxx"
52 #include "StdMeshers_LocalLength_i.hxx"
53 #include "StdMeshers_MaxElementArea_i.hxx"
54 #include "StdMeshers_MaxElementVolume_i.hxx"
55 #include "StdMeshers_MaxLength_i.hxx"
56 #include "StdMeshers_NotConformAllowed_i.hxx"
57 #include "StdMeshers_NumberOfLayers2D_i.hxx"
58 #include "StdMeshers_NumberOfLayers_i.hxx"
59 #include "StdMeshers_NumberOfSegments_i.hxx"
60 #include "StdMeshers_PolygonPerFace_2D_i.hxx"
61 #include "StdMeshers_PolyhedronPerSolid_3D_i.hxx"
62 #include "StdMeshers_Prism_3D_i.hxx"
63 #include "StdMeshers_ProjectionSource1D_i.hxx"
64 #include "StdMeshers_ProjectionSource2D_i.hxx"
65 #include "StdMeshers_ProjectionSource3D_i.hxx"
66 #include "StdMeshers_Projection_1D_2D_3D_i.hxx"
67 #include "StdMeshers_Propagation_i.hxx"
68 #include "StdMeshers_QuadrangleParams_i.hxx"
69 #include "StdMeshers_QuadranglePreference_i.hxx"
70 #include "StdMeshers_Quadrangle_2D_i.hxx"
71 #include "StdMeshers_QuadraticMesh_i.hxx"
72 #include "StdMeshers_RadialQuadrangle_1D2D_i.hxx"
73 #include "StdMeshers_Regular_1D_i.hxx"
74 #include "StdMeshers_SegmentAroundVertex_0D_i.hxx"
75 #include "StdMeshers_SegmentLengthAroundVertex_i.hxx"
76 #include "StdMeshers_StartEndLength_i.hxx"
77 #include "StdMeshers_UseExisting_1D2D_i.hxx"
78 #include "StdMeshers_ViscousLayers2D_i.hxx"
79 #include "StdMeshers_ViscousLayers_i.hxx"
80 #ifdef ENABLE_MEFISTO
81  #include "StdMeshers_MEFISTO_2D_i.hxx"
82 #endif
83
84 namespace SMESH {
85   class ApplicableToAny
86   {
87   public:
88     static bool IsApplicable( const TopoDS_Shape &S, bool /*toCheckAll*/, int algoDim )
89     {
90       return GenericHypothesisCreator_i::IsShapeOfDim( S, algoDim );
91     }
92   };
93 }
94
95 template <class T, class TIsApplicable = SMESH::ApplicableToAny>
96 class StdHypothesisCreator_i : public HypothesisCreator_i< T >
97 {
98 public:
99   // as we have 'module StdMeshers' in SMESH_BasicHypothesis.idl
100   virtual std::string GetModuleName() { return "StdMeshers"; }
101   virtual bool IsApplicable( const TopoDS_Shape & S, bool toCheckAll, int algoDim )
102   {
103     return TIsApplicable::IsApplicable( S, toCheckAll, algoDim );
104   }
105 };
106
107 //=============================================================================
108 /*!
109  * \brief Creates StdMeshers_QuadrangleParams_i instead of
110  * StdMeshers_TrianglePreference_i and StdMeshers_QuadranglePreference_i
111  */
112 //=============================================================================
113
114 template <StdMeshers::QuadType TYPE>
115 class QuadrangleParamsCreator : public StdHypothesisCreator_i<StdMeshers_QuadrangleParams_i>
116 {
117 public:
118   virtual SMESH_Hypothesis_i* Create (PortableServer::POA_ptr thePOA,
119                                       ::SMESH_Gen*            theGenImpl)
120   {
121     StdMeshers_QuadrangleParams_i* h =
122       new StdMeshers_QuadrangleParams_i( thePOA, theGenImpl);
123     h->SetQuadType( TYPE );
124     return h;
125   }
126 };
127
128 //=============================================================================
129 /*!
130  *
131  */
132 //=============================================================================
133
134 extern "C"
135 {
136 STDMESHERS_I_EXPORT
137   GenericHypothesisCreator_i* GetHypothesisCreator (const char* aHypName)
138   {
139     GenericHypothesisCreator_i* aCreator = 0;
140
141     // Hypotheses
142     if      (strcmp(aHypName, "LocalLength") == 0)
143       aCreator = new StdHypothesisCreator_i<StdMeshers_LocalLength_i>;
144     else if (strcmp(aHypName, "MaxLength") == 0)
145       aCreator = new StdHypothesisCreator_i<StdMeshers_MaxLength_i>;
146     else if (strcmp(aHypName, "NumberOfSegments") == 0)
147       aCreator = new StdHypothesisCreator_i<StdMeshers_NumberOfSegments_i>;
148     else if (strcmp(aHypName, "LengthFromEdges") == 0)
149       aCreator = new StdHypothesisCreator_i<StdMeshers_LengthFromEdges_i>;
150     else if (strcmp(aHypName, "NotConformAllowed") == 0)
151       aCreator = new StdHypothesisCreator_i<StdMeshers_NotConformAllowed_i>;
152     else if (strcmp(aHypName, "Propagation") == 0)
153       aCreator = new StdHypothesisCreator_i<StdMeshers_Propagation_i>;
154     else if (strcmp(aHypName, "PropagOfDistribution") == 0)
155       aCreator = new StdHypothesisCreator_i<StdMeshers_PropagOfDistribution_i>;
156     else if (strcmp(aHypName, "MaxElementArea") == 0)
157       aCreator = new StdHypothesisCreator_i<StdMeshers_MaxElementArea_i>;
158     else if (strcmp(aHypName, "MaxElementVolume") == 0)
159       aCreator = new StdHypothesisCreator_i<StdMeshers_MaxElementVolume_i>;
160     else if (strcmp(aHypName, "StartEndLength") == 0)
161       aCreator = new StdHypothesisCreator_i<StdMeshers_StartEndLength_i>;
162     else if (strcmp(aHypName, "Deflection1D") == 0)
163       aCreator = new StdHypothesisCreator_i<StdMeshers_Deflection1D_i>;
164     else if (strcmp(aHypName, "Adaptive1D") == 0)
165       aCreator = new StdHypothesisCreator_i<StdMeshers_Adaptive1D_i>;
166     else if (strcmp(aHypName, "FixedPoints1D") == 0)
167       aCreator = new StdHypothesisCreator_i<StdMeshers_FixedPoints1D_i>;
168     else if (strcmp(aHypName, "Arithmetic1D") == 0)
169       aCreator = new StdHypothesisCreator_i<StdMeshers_Arithmetic1D_i>;
170     else if (strcmp(aHypName, "GeometricProgression") == 0)
171       aCreator = new StdHypothesisCreator_i<StdMeshers_Geometric1D_i>;
172     else if (strcmp(aHypName, "AutomaticLength") == 0)
173       aCreator = new StdHypothesisCreator_i<StdMeshers_AutomaticLength_i>;
174     else if (strcmp(aHypName, "QuadranglePreference") == 0)
175       // do not convert to StdMeshers_QuadrangleParams_i as it is used by NETGEN 2D
176       aCreator = new StdHypothesisCreator_i<StdMeshers_QuadranglePreference_i>;
177       //aCreator = new QuadrangleParamsCreator< StdMeshers::QUAD_QUADRANGLE_PREF >();
178     else if (strcmp(aHypName, "TrianglePreference") == 0)
179       //aCreator = new StdHypothesisCreator_i<StdMeshers_TrianglePreference_i>;
180       aCreator = new QuadrangleParamsCreator< StdMeshers::QUAD_TRIANGLE_PREF >();
181     else if (strcmp(aHypName, "QuadraticMesh") == 0)
182       aCreator = new StdHypothesisCreator_i<StdMeshers_QuadraticMesh_i>;
183     else if (strcmp(aHypName, "ProjectionSource3D") == 0)
184       aCreator = new StdHypothesisCreator_i<StdMeshers_ProjectionSource3D_i>;
185     else if (strcmp(aHypName, "ProjectionSource2D") == 0)
186       aCreator = new StdHypothesisCreator_i<StdMeshers_ProjectionSource2D_i>;
187     else if (strcmp(aHypName, "ProjectionSource1D") == 0)
188       aCreator = new StdHypothesisCreator_i<StdMeshers_ProjectionSource1D_i>;
189     else if (strcmp(aHypName, "NumberOfLayers") == 0)
190       aCreator = new StdHypothesisCreator_i<StdMeshers_NumberOfLayers_i>;
191     else if (strcmp(aHypName, "LayerDistribution") == 0)
192       aCreator = new StdHypothesisCreator_i<StdMeshers_LayerDistribution_i>;
193     else if (strcmp(aHypName, "NumberOfLayers2D") == 0)
194       aCreator = new StdHypothesisCreator_i<StdMeshers_NumberOfLayers2D_i>;
195     else if (strcmp(aHypName, "LayerDistribution2D") == 0)
196       aCreator = new StdHypothesisCreator_i<StdMeshers_LayerDistribution2D_i>;
197     else if (strcmp(aHypName, "SegmentLengthAroundVertex") == 0)
198       aCreator = new StdHypothesisCreator_i<StdMeshers_SegmentLengthAroundVertex_i>;
199     else if (strcmp(aHypName, "QuadrangleParams") == 0)
200       aCreator = new StdHypothesisCreator_i<StdMeshers_QuadrangleParams_i>;
201     else if (strcmp(aHypName, "ImportSource1D") == 0)
202       aCreator = new StdHypothesisCreator_i<StdMeshers_ImportSource1D_i>;
203     else if (strcmp(aHypName, "ImportSource2D") == 0)
204       aCreator = new StdHypothesisCreator_i<StdMeshers_ImportSource2D_i>;
205     else if (strcmp(aHypName, "ViscousLayers") == 0)
206       aCreator = new StdHypothesisCreator_i<StdMeshers_ViscousLayers_i>;
207     else if (strcmp(aHypName, "ViscousLayers2D") == 0)
208       aCreator = new StdHypothesisCreator_i<StdMeshers_ViscousLayers2D_i>;
209     else if (strcmp(aHypName, "CartesianParameters3D") == 0)
210       aCreator = new StdHypothesisCreator_i<StdMeshers_CartesianParameters3D_i>;
211     else if (strcmp(aHypName, "BlockRenumber") == 0)
212       aCreator = new StdHypothesisCreator_i<StdMeshers_BlockRenumber_i>;
213
214     // Algorithms
215     else if (strcmp(aHypName, "Regular_1D") == 0)
216       aCreator = new StdHypothesisCreator_i<StdMeshers_Regular_1D_i>;
217 #ifdef ENABLE_MEFISTO
218     else if (strcmp(aHypName, "MEFISTO_2D") == 0)
219       aCreator = new StdHypothesisCreator_i<StdMeshers_MEFISTO_2D_i>;
220 #endif
221     else if (strcmp(aHypName, "Quadrangle_2D") == 0)
222       aCreator = new StdHypothesisCreator_i<StdMeshers_Quadrangle_2D_i, StdMeshers_Quadrangle_2D_i>;
223     else if (strcmp(aHypName, "QuadFromMedialAxis_1D2D") == 0)
224       aCreator = new StdHypothesisCreator_i<StdMeshers_QuadFromMedialAxis_1D2D_i, StdMeshers_QuadFromMedialAxis_1D2D_i>;
225     else if (strcmp(aHypName, "Hexa_3D") == 0)
226       aCreator = new StdHypothesisCreator_i<StdMeshers_Hexa_3D_i, StdMeshers_Hexa_3D_i>;
227     else if (strcmp(aHypName, "Projection_1D") == 0)
228       aCreator = new StdHypothesisCreator_i<StdMeshers_Projection_1D_i>;
229     else if (strcmp(aHypName, "Projection_1D2D") == 0)
230       aCreator = new StdHypothesisCreator_i<StdMeshers_Projection_1D2D_i>;
231     else if (strcmp(aHypName, "Projection_2D") == 0)
232       aCreator = new StdHypothesisCreator_i<StdMeshers_Projection_2D_i>;
233     else if (strcmp(aHypName, "Projection_3D") == 0)
234       aCreator = new StdHypothesisCreator_i<StdMeshers_Projection_3D_i, StdMeshers_Projection_3D_i>;
235     else if (strcmp(aHypName, "Prism_3D") == 0)
236       aCreator = new StdHypothesisCreator_i<StdMeshers_Prism_3D_i, StdMeshers_Prism_3D_i>;
237     else if (strcmp(aHypName, "RadialPrism_3D") == 0)
238       aCreator = new StdHypothesisCreator_i<StdMeshers_RadialPrism_3D_i, StdMeshers_RadialPrism_3D_i>;
239     else if (strcmp(aHypName, "SegmentAroundVertex_0D") == 0)
240       aCreator = new StdHypothesisCreator_i<StdMeshers_SegmentAroundVertex_0D_i>;
241     else if (strcmp(aHypName, "CompositeSegment_1D") == 0)
242       aCreator = new StdHypothesisCreator_i<StdMeshers_CompositeSegment_1D_i>;
243     else if (strcmp(aHypName, "UseExisting_1D") == 0)
244       aCreator = new StdHypothesisCreator_i<StdMeshers_UseExisting_1D_i>;
245     else if (strcmp(aHypName, "UseExisting_2D") == 0)
246       aCreator = new StdHypothesisCreator_i<StdMeshers_UseExisting_2D_i>;
247     else if (strcmp(aHypName, "RadialQuadrangle_1D2D") == 0)
248       aCreator = new StdHypothesisCreator_i<StdMeshers_RadialQuadrangle_1D2D_i, StdMeshers_RadialQuadrangle_1D2D_i>;
249     else if (strcmp(aHypName, "Import_1D") == 0)
250       aCreator = new StdHypothesisCreator_i<StdMeshers_Import_1D_i>;
251     else if (strcmp(aHypName, "Import_1D2D") == 0)
252       aCreator = new StdHypothesisCreator_i<StdMeshers_Import_1D2D_i>;
253     else if (strcmp(aHypName, "Cartesian_3D") == 0)
254       aCreator = new StdHypothesisCreator_i<StdMeshers_Cartesian_3D_i>;
255     else if (strcmp(aHypName, "PolygonPerFace_2D") == 0)
256       aCreator = new StdHypothesisCreator_i<StdMeshers_PolygonPerFace_2D_i>;
257     else if (strcmp(aHypName, "PolyhedronPerSolid_3D") == 0)
258       aCreator = new StdHypothesisCreator_i<StdMeshers_PolyhedronPerSolid_3D_i>;
259
260     return aCreator;
261   }
262 }