Salome HOME
Merge from V6_3_BR 06/06/2011
[modules/smesh.git] / src / StdMeshers_I / StdMeshers_QuadrangleParams_i.cxx
1 // Copyright (C) 2007-2011  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 //  File   : StdMeshers_QuadrangleParams_i.cxx
20 //  Author : Sergey KUUL, OCC
21 //  Module : SMESH
22
23 #include "StdMeshers_QuadrangleParams_i.hxx"
24 #include "SMESH_Gen_i.hxx"
25 #include "SMESH_Gen.hxx"
26 #include "SMESH_PythonDump.hxx"
27
28 #include "Utils_CorbaException.hxx"
29 #include "utilities.h"
30
31 #include <TCollection_AsciiString.hxx>
32
33 using namespace std;
34
35 //=============================================================================
36 /*!
37  *  StdMeshers_QuadrangleParams_i::StdMeshers_QuadrangleParams_i
38  *
39  *  Constructor
40  */
41 //=============================================================================
42
43 StdMeshers_QuadrangleParams_i::StdMeshers_QuadrangleParams_i
44                                           (PortableServer::POA_ptr thePOA,
45                                            int                     theStudyId,
46                                            ::SMESH_Gen*            theGenImpl )
47      : SALOME::GenericObj_i( thePOA ), 
48        SMESH_Hypothesis_i( thePOA )
49 {
50   MESSAGE( "StdMeshers_QuadrangleParams_i::StdMeshers_QuadrangleParams_i" );
51   myBaseImpl = new ::StdMeshers_QuadrangleParams(theGenImpl->GetANewId(),
52                                                  theStudyId,
53                                                  theGenImpl);
54 }
55
56 //=============================================================================
57 /*!
58  *  StdMeshers_QuadrangleParams_i::~StdMeshers_QuadrangleParams_i
59  *
60  *  Destructor
61  */
62 //=============================================================================
63
64 StdMeshers_QuadrangleParams_i::~StdMeshers_QuadrangleParams_i()
65 {
66   MESSAGE( "StdMeshers_QuadrangleParams_i::~StdMeshers_QuadrangleParams_i" );
67 }
68
69 //=============================================================================
70 /*!
71  *  StdMeshers_QuadrangleParams_i::SetTriaVertex
72  *
73  *  Set base vertex for triangles
74  */
75 //=============================================================================
76
77 void StdMeshers_QuadrangleParams_i::SetTriaVertex(CORBA::Long vertID)
78 {
79   MESSAGE( "StdMeshers_QuadrangleParams_i::SetTriaVertex" );
80   ASSERT( myBaseImpl );
81   try {
82     this->GetImpl()->SetTriaVertex( vertID );
83   }
84   catch ( SALOME_Exception& S_ex ) {
85     THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
86                                   SALOME::BAD_PARAM );
87   }
88
89   // Update Python script
90   SMESH::TPythonDump() << _this() << ".SetTriaVertex( "
91       << vertID << " )";
92 }
93
94 //=============================================================================
95 /*!
96  *  StdMeshers_QuadrangleParams_i::GetTriaVertex
97  *
98  *  Get base vertex for triangles
99  */
100 //=============================================================================
101
102 CORBA::Long StdMeshers_QuadrangleParams_i::GetTriaVertex()
103 {
104   MESSAGE( "StdMeshers_QuadrangleParams_i::GetTriaVertex" );
105   ASSERT( myBaseImpl );
106   return this->GetImpl()->GetTriaVertex();
107 }
108
109 //=============================================================================
110 /*!
111  *  StdMeshers_QuadrangleParams_i::SetObjectEntry
112  *
113  *  Set the Entry for the Main Object
114  */
115 //=============================================================================
116
117 void StdMeshers_QuadrangleParams_i::SetObjectEntry( const char* entry )
118 {
119   MESSAGE( "StdMeshers_QuadrangleParams_i::SetObjectEntry" );
120   ASSERT( myBaseImpl );
121
122   try {
123     this->GetImpl()->SetObjectEntry( entry );
124     // Update Python script
125     //    SMESH::TPythonDump() << _this() << ".SetObjectEntry( '" << entry << "' )";
126   }
127   catch ( SALOME_Exception& S_ex ) {
128     THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
129                                   SALOME::BAD_PARAM );
130   }
131 }
132
133 //=============================================================================
134 /*!
135  *  StdMeshers_QuadrangleParams_i::GetObjectEntry
136  *
137  *  Set the Entry for the Main Object
138  */
139 //=============================================================================
140
141 char* StdMeshers_QuadrangleParams_i::GetObjectEntry()
142 {
143   MESSAGE( "StdMeshers_QuadrangleParams_i::SetObjectEntry" );
144   ASSERT( myBaseImpl );
145   const char* entry;
146   try {
147     entry = this->GetImpl()->GetObjectEntry();
148   }
149   catch ( SALOME_Exception& S_ex ) {
150     THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
151                                   SALOME::BAD_PARAM );
152   }
153   return CORBA::string_dup( entry );
154 }
155
156 //=============================================================================
157 /*!
158  *  StdMeshers_QuadrangleParams_i::SetQuadType
159  *
160  *  Set the type of quadrangulation
161  */
162 //=============================================================================
163 void StdMeshers_QuadrangleParams_i::SetQuadType(StdMeshers::QuadType type)
164 {
165   //static char* quadTypes[5] = {"StdMeshers.QUAD_STANDARD",
166   //                             "StdMeshers.QUAD_TRIANGLE_PREF",
167   //                             "StdMeshers.QUAD_QUADRANGLE_PREF",
168   //                             "StdMeshers.QUAD_QUADRANGLE_PREF_REVERSED",
169   //                             "StdMeshers.QUAD_REDUCED"};
170
171   MESSAGE("StdMeshers_QuadrangleParams_i::SetQuadType");
172   ASSERT(myBaseImpl);
173
174   if (int(type) >= int(StdMeshers::QUAD_NB_TYPES)) {
175     THROW_SALOME_CORBA_EXCEPTION("Bad type of quadrangulation", SALOME::BAD_PARAM);
176   }
177
178   try {
179     this->GetImpl()->SetQuadType(StdMeshers_QuadType(int(type)));
180   }
181   catch (SALOME_Exception& S_ex) {
182     THROW_SALOME_CORBA_EXCEPTION(S_ex.what(), SALOME::BAD_PARAM);
183   }
184
185   // Update Python script
186   const char* quadType;
187   switch (type) {
188   case StdMeshers::QUAD_STANDARD:
189     quadType = "StdMeshers.QUAD_STANDARD"; break;
190   case StdMeshers::QUAD_TRIANGLE_PREF:
191     quadType = "StdMeshers.QUAD_TRIANGLE_PREF"; break;
192   case StdMeshers::QUAD_QUADRANGLE_PREF:
193     quadType = "StdMeshers.QUAD_QUADRANGLE_PREF"; break;
194   case StdMeshers::QUAD_QUADRANGLE_PREF_REVERSED:
195     quadType = "StdMeshers.QUAD_QUADRANGLE_PREF_REVERSED"; break;
196   case StdMeshers::QUAD_REDUCED:
197     quadType = "StdMeshers.QUAD_REDUCED"; break;
198   default:
199     quadType = "UNKNOWN";
200   }
201   SMESH::TPythonDump() << _this() << ".SetQuadType( " << quadType << " )";
202   //SMESH::TPythonDump() << _this() << ".SetQuadType( " << quadTypes[int(type)] << " )";
203 }
204
205 //=============================================================================
206 /*!
207  *  StdMeshers_QuadrangleParams_i::GetQuadType
208  *
209  *  Get the type of quadrangulation
210  */
211 //=============================================================================
212 StdMeshers::QuadType StdMeshers_QuadrangleParams_i::GetQuadType()
213 {
214   MESSAGE("StdMeshers_QuadrangleParams_i::GetQuadType");
215   ASSERT(myBaseImpl);
216   return StdMeshers::QuadType(int(this->GetImpl()->GetQuadType()));
217 }
218
219 //=============================================================================
220 /*!
221  *  StdMeshers_QuadrangleParams_i::GetImpl
222  *
223  *  Get implementation
224  */
225 //=============================================================================
226
227 ::StdMeshers_QuadrangleParams* StdMeshers_QuadrangleParams_i::GetImpl()
228 {
229   MESSAGE( "StdMeshers_QuadrangleParams_i::GetImpl" );
230   return ( ::StdMeshers_QuadrangleParams* )myBaseImpl;
231 }
232
233 //================================================================================
234 /*!
235  * \brief Verify whether hypothesis supports given entity type 
236   * \param type - dimension (see SMESH::Dimension enumeration)
237   * \retval CORBA::Boolean - TRUE if dimension is supported, FALSE otherwise
238  * 
239  * Verify whether hypothesis supports given entity type (see SMESH::Dimension enumeration)
240  */
241 //================================================================================  
242 CORBA::Boolean StdMeshers_QuadrangleParams_i::IsDimSupported( SMESH::Dimension type )
243 {
244   return type == SMESH::DIM_2D;
245 }