Salome HOME
Replace oe by ?
[modules/smesh.git] / src / StdMeshers_I / StdMeshers_QuadrangleParams_i.cxx
1 //  Copyright (C) 2007-2010  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 //  This library is free software; you can redistribute it and/or
4 //  modify it under the terms of the GNU Lesser General Public
5 //  License as published by the Free Software Foundation; either
6 //  version 2.1 of the License.
7 //
8 //  This library is distributed in the hope that it will be useful,
9 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
10 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 //  Lesser General Public License for more details.
12 //
13 //  You should have received a copy of the GNU Lesser General Public
14 //  License along with this library; if not, write to the Free Software
15 //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 //
17 //  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19 //  SMESH SMESH_I : idl implementation based on 'SMESH' unit's calsses
20 //  File   : StdMeshers_QuadrangleParams_i.cxx
21 //  Author : Sergey KUUL, OCC
22 //  Module : SMESH
23
24 #include "StdMeshers_QuadrangleParams_i.hxx"
25 #include "SMESH_Gen_i.hxx"
26 #include "SMESH_Gen.hxx"
27 #include "SMESH_PythonDump.hxx"
28
29 #include "Utils_CorbaException.hxx"
30 #include "utilities.h"
31
32 #include <TCollection_AsciiString.hxx>
33
34 using namespace std;
35
36 //=============================================================================
37 /*!
38  *  StdMeshers_QuadrangleParams_i::StdMeshers_QuadrangleParams_i
39  *
40  *  Constructor
41  */
42 //=============================================================================
43
44 StdMeshers_QuadrangleParams_i::StdMeshers_QuadrangleParams_i
45                                           (PortableServer::POA_ptr thePOA,
46                                            int                     theStudyId,
47                                            ::SMESH_Gen*            theGenImpl )
48      : SALOME::GenericObj_i( thePOA ), 
49        SMESH_Hypothesis_i( thePOA )
50 {
51   MESSAGE( "StdMeshers_QuadrangleParams_i::StdMeshers_QuadrangleParams_i" );
52   myBaseImpl = new ::StdMeshers_QuadrangleParams(theGenImpl->GetANewId(),
53                                                  theStudyId,
54                                                  theGenImpl);
55 }
56
57 //=============================================================================
58 /*!
59  *  StdMeshers_QuadrangleParams_i::~StdMeshers_QuadrangleParams_i
60  *
61  *  Destructor
62  */
63 //=============================================================================
64
65 StdMeshers_QuadrangleParams_i::~StdMeshers_QuadrangleParams_i()
66 {
67   MESSAGE( "StdMeshers_QuadrangleParams_i::~StdMeshers_QuadrangleParams_i" );
68 }
69
70 //=============================================================================
71 /*!
72  *  StdMeshers_QuadrangleParams_i::SetTriaVertex
73  *
74  *  Set base vertex for triangles
75  */
76 //=============================================================================
77
78 void StdMeshers_QuadrangleParams_i::SetTriaVertex(CORBA::Long vertID)
79 {
80   MESSAGE( "StdMeshers_QuadrangleParams_i::SetTriaVertex" );
81   ASSERT( myBaseImpl );
82   try {
83     this->GetImpl()->SetTriaVertex( vertID );
84   }
85   catch ( SALOME_Exception& S_ex ) {
86     THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
87                                   SALOME::BAD_PARAM );
88   }
89
90   // Update Python script
91   SMESH::TPythonDump() << _this() << ".SetTriaVertex( "
92       << vertID << " )";
93 }
94
95 //=============================================================================
96 /*!
97  *  StdMeshers_QuadrangleParams_i::GetTriaVertex
98  *
99  *  Get base vertex for triangles
100  */
101 //=============================================================================
102
103 CORBA::Long StdMeshers_QuadrangleParams_i::GetTriaVertex()
104 {
105   MESSAGE( "StdMeshers_QuadrangleParams_i::GetTriaVertex" );
106   ASSERT( myBaseImpl );
107   return this->GetImpl()->GetTriaVertex();
108 }
109
110 //=============================================================================
111 /*!
112  *  StdMeshers_QuadrangleParams_i::SetObjectEntry
113  *
114  *  Set the Entry for the Main Object
115  */
116 //=============================================================================
117
118 void StdMeshers_QuadrangleParams_i::SetObjectEntry( const char* entry )
119 {
120   MESSAGE( "StdMeshers_QuadrangleParams_i::SetObjectEntry" );
121   ASSERT( myBaseImpl );
122
123   try {
124     this->GetImpl()->SetObjectEntry( entry );
125     // Update Python script
126     //    SMESH::TPythonDump() << _this() << ".SetObjectEntry( '" << entry << "' )";
127   }
128   catch ( SALOME_Exception& S_ex ) {
129     THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
130                                   SALOME::BAD_PARAM );
131   }
132 }
133
134 //=============================================================================
135 /*!
136  *  StdMeshers_QuadrangleParams_i::GetObjectEntry
137  *
138  *  Set the Entry for the Main Object
139  */
140 //=============================================================================
141
142 char* StdMeshers_QuadrangleParams_i::GetObjectEntry()
143 {
144   MESSAGE( "StdMeshers_QuadrangleParams_i::SetObjectEntry" );
145   ASSERT( myBaseImpl );
146   const char* entry;
147   try {
148     entry = this->GetImpl()->GetObjectEntry();
149   }
150   catch ( SALOME_Exception& S_ex ) {
151     THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
152                                   SALOME::BAD_PARAM );
153   }
154   return CORBA::string_dup( entry );
155 }
156
157 //=============================================================================
158 /*!
159  *  StdMeshers_QuadrangleParams_i::SetQuadType
160  *
161  *  Set the type of quadrangulation
162  */
163 //=============================================================================
164 void StdMeshers_QuadrangleParams_i::SetQuadType(StdMeshers::QuadType type)
165 {
166   //static char* quadTypes[5] = {"StdMeshers.QUAD_STANDARD",
167   //                             "StdMeshers.QUAD_TRIANGLE_PREF",
168   //                             "StdMeshers.QUAD_QUADRANGLE_PREF",
169   //                             "StdMeshers.QUAD_QUADRANGLE_PREF_REVERSED",
170   //                             "StdMeshers.QUAD_REDUCED"};
171
172   MESSAGE("StdMeshers_QuadrangleParams_i::SetQuadType");
173   ASSERT(myBaseImpl);
174
175   if (int(type) >= int(StdMeshers::QUAD_NB_TYPES)) {
176     THROW_SALOME_CORBA_EXCEPTION("Bad type of quadrangulation", SALOME::BAD_PARAM);
177   }
178
179   try {
180     this->GetImpl()->SetQuadType(StdMeshers_QuadType(int(type)));
181   }
182   catch (SALOME_Exception& S_ex) {
183     THROW_SALOME_CORBA_EXCEPTION(S_ex.what(), SALOME::BAD_PARAM);
184   }
185
186   // Update Python script
187   const char* quadType;
188   switch (type) {
189   case StdMeshers::QUAD_STANDARD:
190     quadType = "StdMeshers.QUAD_STANDARD"; break;
191   case StdMeshers::QUAD_TRIANGLE_PREF:
192     quadType = "StdMeshers.QUAD_TRIANGLE_PREF"; break;
193   case StdMeshers::QUAD_QUADRANGLE_PREF:
194     quadType = "StdMeshers.QUAD_QUADRANGLE_PREF"; break;
195   case StdMeshers::QUAD_QUADRANGLE_PREF_REVERSED:
196     quadType = "StdMeshers.QUAD_QUADRANGLE_PREF_REVERSED"; break;
197   case StdMeshers::QUAD_REDUCED:
198     quadType = "StdMeshers.QUAD_REDUCED"; break;
199   default:
200     quadType = "UNKNOWN";
201   }
202   SMESH::TPythonDump() << _this() << ".SetQuadType( " << quadType << " )";
203   //SMESH::TPythonDump() << _this() << ".SetQuadType( " << quadTypes[int(type)] << " )";
204 }
205
206 //=============================================================================
207 /*!
208  *  StdMeshers_QuadrangleParams_i::GetQuadType
209  *
210  *  Get the type of quadrangulation
211  */
212 //=============================================================================
213 StdMeshers::QuadType StdMeshers_QuadrangleParams_i::GetQuadType()
214 {
215   MESSAGE("StdMeshers_QuadrangleParams_i::GetQuadType");
216   ASSERT(myBaseImpl);
217   return StdMeshers::QuadType(int(this->GetImpl()->GetQuadType()));
218 }
219
220 //=============================================================================
221 /*!
222  *  StdMeshers_QuadrangleParams_i::GetImpl
223  *
224  *  Get implementation
225  */
226 //=============================================================================
227
228 ::StdMeshers_QuadrangleParams* StdMeshers_QuadrangleParams_i::GetImpl()
229 {
230   MESSAGE( "StdMeshers_QuadrangleParams_i::GetImpl" );
231   return ( ::StdMeshers_QuadrangleParams* )myBaseImpl;
232 }
233
234 //================================================================================
235 /*!
236  * \brief Verify whether hypothesis supports given entity type 
237   * \param type - dimension (see SMESH::Dimension enumeration)
238   * \retval CORBA::Boolean - TRUE if dimension is supported, FALSE otherwise
239  * 
240  * Verify whether hypothesis supports given entity type (see SMESH::Dimension enumeration)
241  */
242 //================================================================================  
243 CORBA::Boolean StdMeshers_QuadrangleParams_i::IsDimSupported( SMESH::Dimension type )
244 {
245   return type == SMESH::DIM_2D;
246 }