1 // Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
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.
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.
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
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 // SMESH SMESH_I : idl implementation based on 'SMESH' unit's calsses
23 // File : StdMeshers_FixedPoints1D_i.cxx
24 // Author : Damien COQUERET, OCC
28 #include "StdMeshers_FixedPoints1D_i.hxx"
29 #include "SMESH_Gen_i.hxx"
30 #include "SMESH_Gen.hxx"
31 #include "SMESH_PythonDump.hxx"
33 #include "Utils_CorbaException.hxx"
34 #include "utilities.h"
36 #include <TCollection_AsciiString.hxx>
40 //=============================================================================
42 * StdMeshers_FixedPoints1D_i::StdMeshers_FixedPoints1D_i
46 //=============================================================================
48 StdMeshers_FixedPoints1D_i::StdMeshers_FixedPoints1D_i( PortableServer::POA_ptr thePOA,
50 ::SMESH_Gen* theGenImpl )
51 : SALOME::GenericObj_i( thePOA ),
52 SMESH_Hypothesis_i( thePOA )
54 MESSAGE( "StdMeshers_FixedPoints1D_i::StdMeshers_FixedPoints1D_i" );
55 myBaseImpl = new ::StdMeshers_FixedPoints1D(theGenImpl->GetANewId(),
60 //=============================================================================
62 * StdMeshers_FixedPoints1D_i::~StdMeshers_FixedPoints1D_i
66 //=============================================================================
68 StdMeshers_FixedPoints1D_i::~StdMeshers_FixedPoints1D_i()
70 MESSAGE( "StdMeshers_FixedPoints1D_i::~StdMeshers_FixedPoints1D_i" );
73 //=============================================================================
75 * StdMeshers_FixedPoints1D_i::SetNbSegments
77 //=============================================================================
79 void StdMeshers_FixedPoints1D_i::SetNbSegments(const SMESH::long_array& listNbSeg)
80 throw ( SALOME::SALOME_Exception )
82 MESSAGE( "StdMeshers_FixedPoints1D_i::SetNbSegments" );
85 std::vector<int> nbsegs( listNbSeg.length() );
86 CORBA::Long iEnd = listNbSeg.length();
87 for ( CORBA::Long i = 0; i < iEnd; i++ )
88 nbsegs[ i ] = listNbSeg[ i ];
89 this->GetImpl()->SetNbSegments( nbsegs );
91 catch ( SALOME_Exception& S_ex ) {
92 THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
96 // Update Python script
97 SMESH::TPythonDump() << _this() << ".SetNbSegments( " << listNbSeg << " )";
100 //=============================================================================
102 * StdMeshers_FixedPoints1D_i::SetPoints
104 //=============================================================================
106 void StdMeshers_FixedPoints1D_i::SetPoints(const SMESH::double_array& listParams)
107 throw ( SALOME::SALOME_Exception )
109 MESSAGE( "StdMeshers_FixedPoints1D_i::SetPoints" );
110 ASSERT( myBaseImpl );
112 std::vector<double> params( listParams.length() );
113 CORBA::Long iEnd = listParams.length();
114 for ( CORBA::Long i = 0; i < iEnd; i++ )
115 params[ i ] = listParams[ i ];
116 this->GetImpl()->SetPoints( params );
118 catch ( SALOME_Exception& S_ex ) {
119 THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
123 // Update Python script
124 SMESH::TPythonDump() << _this() << ".SetPoints( " << listParams << " )";
127 //=============================================================================
129 * StdMeshers_FixedPoints1D_i::GetPoints
131 * Get list of point's parameters
133 //=============================================================================
135 SMESH::double_array* StdMeshers_FixedPoints1D_i::GetPoints()
137 MESSAGE( "StdMeshers_FixedPoints1D_i::GetPoints" );
138 ASSERT( myBaseImpl );
139 SMESH::double_array_var anArray = new SMESH::double_array;
140 std::vector<double> params = this->GetImpl()->GetPoints();
141 anArray->length( params.size() );
142 for ( CORBA::Long i = 0; i < params.size(); i++)
143 anArray [ i ] = params [ i ];
145 return anArray._retn();
148 //=============================================================================
150 * StdMeshers_FixedPoints1D_i::GetNbSegments
152 * Get list of point's parameters
154 //=============================================================================
156 SMESH::long_array* StdMeshers_FixedPoints1D_i::GetNbSegments()
158 MESSAGE( "StdMeshers_FixedPoints1D_i::GetNbSegments" );
159 ASSERT( myBaseImpl );
160 SMESH::long_array_var anArray = new SMESH::long_array;
161 std::vector<int> nbsegs = this->GetImpl()->GetNbSegments();
162 anArray->length( nbsegs.size() );
163 for ( CORBA::Long i = 0; i < nbsegs.size(); i++)
164 anArray [ i ] = nbsegs [ i ];
166 return anArray._retn();
169 //=============================================================================
171 * StdMeshers_FixedPoints1D_i::SetReversedEdges
173 * Set edges to reverse
175 //=============================================================================
177 void StdMeshers_FixedPoints1D_i::SetReversedEdges( const SMESH::long_array& theIds )
179 ASSERT( myBaseImpl );
181 std::vector<int> ids( theIds.length() );
182 CORBA::Long iEnd = theIds.length();
183 for ( CORBA::Long i = 0; i < iEnd; i++ )
184 ids[ i ] = theIds[ i ];
186 this->GetImpl()->SetReversedEdges( ids );
188 catch ( SALOME_Exception& S_ex ) {
189 THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
193 // Update Python script
194 SMESH::TPythonDump() << _this() << ".SetReversedEdges( " << theIds << " )";
197 //=============================================================================
199 * StdMeshers_FixedPoints1D_i::SetObjectEntry
201 * Set the Entry for the Main Object
203 //=============================================================================
205 void StdMeshers_FixedPoints1D_i::SetObjectEntry( const char* theEntry )
207 ASSERT( myBaseImpl );
208 string entry(theEntry); // actually needed as theEntry is spoiled by moment of dumping
210 this->GetImpl()->SetObjectEntry( entry.c_str() );
211 // Update Python script
212 SMESH::TPythonDump() << _this() << ".SetObjectEntry( \"" << entry.c_str() << "\" )";
214 catch ( SALOME_Exception& S_ex ) {
215 THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),SALOME::BAD_PARAM );
219 //=============================================================================
221 * StdMeshers_FixedPoints1D_i::GetObjectEntry
223 * Set the Entry for the Main Object
225 //=============================================================================
227 char* StdMeshers_FixedPoints1D_i::GetObjectEntry()
229 MESSAGE( "StdMeshers_FixedPoints1D_i::SetObjectEntry" );
230 ASSERT( myBaseImpl );
233 entry = this->GetImpl()->GetObjectEntry();
235 catch ( SALOME_Exception& S_ex ) {
236 THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
239 return CORBA::string_dup( entry );
242 //=============================================================================
244 * StdMeshers_FixedPoints1D_i::GetReversedEdges
248 //=============================================================================
250 SMESH::long_array* StdMeshers_FixedPoints1D_i::GetReversedEdges()
252 MESSAGE( "StdMeshers_FixedPoints1D_i::GetReversedEdges" );
253 ASSERT( myBaseImpl );
254 SMESH::long_array_var anArray = new SMESH::long_array;
255 std::vector<int> ids = this->GetImpl()->GetReversedEdges();
256 anArray->length( ids.size() );
257 for ( CORBA::Long i = 0; i < ids.size(); i++)
258 anArray [ i ] = ids [ i ];
260 return anArray._retn();
263 //=============================================================================
265 * StdMeshers_FixedPoints1D_i::GetImpl
269 //=============================================================================
271 ::StdMeshers_FixedPoints1D* StdMeshers_FixedPoints1D_i::GetImpl()
273 MESSAGE( "StdMeshers_FixedPoints1D_i::GetImpl" );
274 return ( ::StdMeshers_FixedPoints1D* )myBaseImpl;
277 //================================================================================
279 * \brief Verify whether hypothesis supports given entity type
280 * \param type - dimension (see SMESH::Dimension enumeration)
281 * \retval CORBA::Boolean - TRUE if dimension is supported, FALSE otherwise
283 * Verify whether hypothesis supports given entity type (see SMESH::Dimension enumeration)
285 //================================================================================
286 CORBA::Boolean StdMeshers_FixedPoints1D_i::IsDimSupported( SMESH::Dimension type )
288 return type == SMESH::DIM_1D;