1 // Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE
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.
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.
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
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 // SMESH SMESH_I : idl implementation based on 'SMESH' unit's calsses
21 // File : StdMeshers_FixedPoints1D_i.cxx
22 // Author : Damien COQUERET, OCC
26 #include "StdMeshers_FixedPoints1D_i.hxx"
27 #include "SMESH_Gen_i.hxx"
28 #include "SMESH_Gen.hxx"
29 #include "SMESH_PythonDump.hxx"
31 #include "Utils_CorbaException.hxx"
32 #include "utilities.h"
34 #include <TCollection_AsciiString.hxx>
38 //=============================================================================
40 * StdMeshers_FixedPoints1D_i::StdMeshers_FixedPoints1D_i
44 //=============================================================================
46 StdMeshers_FixedPoints1D_i::StdMeshers_FixedPoints1D_i( PortableServer::POA_ptr thePOA,
48 ::SMESH_Gen* theGenImpl )
49 : SALOME::GenericObj_i( thePOA ),
50 SMESH_Hypothesis_i( thePOA )
52 MESSAGE( "StdMeshers_FixedPoints1D_i::StdMeshers_FixedPoints1D_i" );
53 myBaseImpl = new ::StdMeshers_FixedPoints1D(theGenImpl->GetANewId(),
58 //=============================================================================
60 * StdMeshers_FixedPoints1D_i::~StdMeshers_FixedPoints1D_i
64 //=============================================================================
66 StdMeshers_FixedPoints1D_i::~StdMeshers_FixedPoints1D_i()
68 MESSAGE( "StdMeshers_FixedPoints1D_i::~StdMeshers_FixedPoints1D_i" );
71 //=============================================================================
73 * StdMeshers_FixedPoints1D_i::SetNbSegments
75 //=============================================================================
77 void StdMeshers_FixedPoints1D_i::SetNbSegments(const SMESH::long_array& listNbSeg)
78 throw ( SALOME::SALOME_Exception )
80 MESSAGE( "StdMeshers_FixedPoints1D_i::SetNbSegments" );
83 std::vector<int> nbsegs( listNbSeg.length() );
84 CORBA::Long iEnd = listNbSeg.length();
85 for ( CORBA::Long i = 0; i < iEnd; i++ )
86 nbsegs[ i ] = listNbSeg[ i ];
87 this->GetImpl()->SetNbSegments( nbsegs );
89 catch ( SALOME_Exception& S_ex ) {
90 THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
94 // Update Python script
95 SMESH::TPythonDump() << _this() << ".SetNbSegments( " << listNbSeg << " )";
98 //=============================================================================
100 * StdMeshers_FixedPoints1D_i::SetPoints
102 //=============================================================================
104 void StdMeshers_FixedPoints1D_i::SetPoints(const SMESH::double_array& listParams)
105 throw ( SALOME::SALOME_Exception )
107 MESSAGE( "StdMeshers_FixedPoints1D_i::SetPoints" );
108 ASSERT( myBaseImpl );
110 std::vector<double> params( listParams.length() );
111 CORBA::Long iEnd = listParams.length();
112 for ( CORBA::Long i = 0; i < iEnd; i++ )
113 params[ i ] = listParams[ i ];
114 this->GetImpl()->SetPoints( params );
116 catch ( SALOME_Exception& S_ex ) {
117 THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
121 // Update Python script
122 SMESH::TPythonDump() << _this() << ".SetPoints( " << listParams << " )";
125 //=============================================================================
127 * StdMeshers_FixedPoints1D_i::GetPoints
129 * Get list of point's parameters
131 //=============================================================================
133 SMESH::double_array* StdMeshers_FixedPoints1D_i::GetPoints()
135 MESSAGE( "StdMeshers_FixedPoints1D_i::GetPoints" );
136 ASSERT( myBaseImpl );
137 SMESH::double_array_var anArray = new SMESH::double_array;
138 std::vector<double> params = this->GetImpl()->GetPoints();
139 anArray->length( params.size() );
140 for ( CORBA::Long i = 0; i < params.size(); i++)
141 anArray [ i ] = params [ i ];
143 return anArray._retn();
146 //=============================================================================
148 * StdMeshers_FixedPoints1D_i::GetNbSegments
150 * Get list of point's parameters
152 //=============================================================================
154 SMESH::long_array* StdMeshers_FixedPoints1D_i::GetNbSegments()
156 MESSAGE( "StdMeshers_FixedPoints1D_i::GetNbSegments" );
157 ASSERT( myBaseImpl );
158 SMESH::long_array_var anArray = new SMESH::long_array;
159 std::vector<int> nbsegs = this->GetImpl()->GetNbSegments();
160 anArray->length( nbsegs.size() );
161 for ( CORBA::Long i = 0; i < nbsegs.size(); i++)
162 anArray [ i ] = nbsegs [ i ];
164 return anArray._retn();
167 //=============================================================================
169 * StdMeshers_FixedPoints1D_i::SetReversedEdges
171 * Set edges to reverse
173 //=============================================================================
175 void StdMeshers_FixedPoints1D_i::SetReversedEdges( const SMESH::long_array& theIds )
177 ASSERT( myBaseImpl );
179 std::vector<int> ids( theIds.length() );
180 CORBA::Long iEnd = theIds.length();
181 for ( CORBA::Long i = 0; i < iEnd; i++ )
182 ids[ i ] = theIds[ i ];
184 this->GetImpl()->SetReversedEdges( ids );
186 catch ( SALOME_Exception& S_ex ) {
187 THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
191 // Update Python script
192 SMESH::TPythonDump() << _this() << ".SetReversedEdges( " << theIds << " )";
195 //=============================================================================
197 * StdMeshers_FixedPoints1D_i::SetObjectEntry
199 * Set the Entry for the Main Object
201 //=============================================================================
203 void StdMeshers_FixedPoints1D_i::SetObjectEntry( const char* theEntry )
205 ASSERT( myBaseImpl );
206 string entry(theEntry); // actually needed as theEntry is spoiled by moment of dumping
208 this->GetImpl()->SetObjectEntry( entry.c_str() );
209 // Update Python script
210 SMESH::TPythonDump() << _this() << ".SetObjectEntry( \"" << entry.c_str() << "\" )";
212 catch ( SALOME_Exception& S_ex ) {
213 THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),SALOME::BAD_PARAM );
217 //=============================================================================
219 * StdMeshers_FixedPoints1D_i::GetObjectEntry
221 * Set the Entry for the Main Object
223 //=============================================================================
225 char* StdMeshers_FixedPoints1D_i::GetObjectEntry()
227 MESSAGE( "StdMeshers_FixedPoints1D_i::SetObjectEntry" );
228 ASSERT( myBaseImpl );
231 entry = this->GetImpl()->GetObjectEntry();
233 catch ( SALOME_Exception& S_ex ) {
234 THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
237 return CORBA::string_dup( entry );
240 //=============================================================================
242 * StdMeshers_FixedPoints1D_i::GetReversedEdges
246 //=============================================================================
248 SMESH::long_array* StdMeshers_FixedPoints1D_i::GetReversedEdges()
250 MESSAGE( "StdMeshers_FixedPoints1D_i::GetReversedEdges" );
251 ASSERT( myBaseImpl );
252 SMESH::long_array_var anArray = new SMESH::long_array;
253 std::vector<int> ids = this->GetImpl()->GetReversedEdges();
254 anArray->length( ids.size() );
255 for ( CORBA::Long i = 0; i < ids.size(); i++)
256 anArray [ i ] = ids [ i ];
258 return anArray._retn();
261 //=============================================================================
263 * StdMeshers_FixedPoints1D_i::GetImpl
267 //=============================================================================
269 ::StdMeshers_FixedPoints1D* StdMeshers_FixedPoints1D_i::GetImpl()
271 MESSAGE( "StdMeshers_FixedPoints1D_i::GetImpl" );
272 return ( ::StdMeshers_FixedPoints1D* )myBaseImpl;
275 //================================================================================
277 * \brief Verify whether hypothesis supports given entity type
278 * \param type - dimension (see SMESH::Dimension enumeration)
279 * \retval CORBA::Boolean - TRUE if dimension is supported, FALSE otherwise
281 * Verify whether hypothesis supports given entity type (see SMESH::Dimension enumeration)
283 //================================================================================
284 CORBA::Boolean StdMeshers_FixedPoints1D_i::IsDimSupported( SMESH::Dimension type )
286 return type == SMESH::DIM_1D;