1 // Copyright (C) 2007-2016 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, or (at your option) any later version.
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 classes
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,
47 ::SMESH_Gen* theGenImpl )
48 : SALOME::GenericObj_i( thePOA ),
49 SMESH_Hypothesis_i( thePOA )
51 myBaseImpl = new ::StdMeshers_FixedPoints1D(theGenImpl->GetANewId(),
55 //=============================================================================
57 * StdMeshers_FixedPoints1D_i::~StdMeshers_FixedPoints1D_i
61 //=============================================================================
63 StdMeshers_FixedPoints1D_i::~StdMeshers_FixedPoints1D_i()
67 //=============================================================================
69 * StdMeshers_FixedPoints1D_i::SetNbSegments
71 //=============================================================================
73 void StdMeshers_FixedPoints1D_i::SetNbSegments(const SMESH::long_array& listNbSeg)
74 throw ( SALOME::SALOME_Exception )
78 std::vector<int> nbsegs( listNbSeg.length() );
79 CORBA::Long iEnd = listNbSeg.length();
80 for ( CORBA::Long i = 0; i < iEnd; i++ )
81 nbsegs[ i ] = listNbSeg[ i ];
82 this->GetImpl()->SetNbSegments( nbsegs );
84 catch ( SALOME_Exception& S_ex ) {
85 THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
89 // Update Python script
90 SMESH::TPythonDump() << _this() << ".SetNbSegments( " << listNbSeg << " )";
93 //=============================================================================
95 * StdMeshers_FixedPoints1D_i::SetPoints
97 //=============================================================================
99 void StdMeshers_FixedPoints1D_i::SetPoints(const SMESH::double_array& listParams)
100 throw ( SALOME::SALOME_Exception )
102 ASSERT( myBaseImpl );
104 std::vector<double> params( listParams.length() );
105 CORBA::Long iEnd = listParams.length();
106 for ( CORBA::Long i = 0; i < iEnd; i++ )
107 params[ i ] = listParams[ i ];
108 this->GetImpl()->SetPoints( params );
110 catch ( SALOME_Exception& S_ex ) {
111 THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
115 // Update Python script
116 SMESH::TPythonDump() << _this() << ".SetPoints( " << listParams << " )";
119 //=============================================================================
121 * StdMeshers_FixedPoints1D_i::GetPoints
123 * Get list of point's parameters
125 //=============================================================================
127 SMESH::double_array* StdMeshers_FixedPoints1D_i::GetPoints()
129 ASSERT( myBaseImpl );
130 SMESH::double_array_var anArray = new SMESH::double_array;
131 std::vector<double> params = this->GetImpl()->GetPoints();
132 anArray->length( params.size() );
133 for ( CORBA::ULong i = 0; i < params.size(); i++)
134 anArray [ i ] = params [ i ];
136 return anArray._retn();
139 //=============================================================================
141 * StdMeshers_FixedPoints1D_i::GetNbSegments
143 * Get list of point's parameters
145 //=============================================================================
147 SMESH::long_array* StdMeshers_FixedPoints1D_i::GetNbSegments()
149 ASSERT( myBaseImpl );
150 SMESH::long_array_var anArray = new SMESH::long_array;
151 std::vector<int> nbsegs = this->GetImpl()->GetNbSegments();
152 anArray->length( nbsegs.size() );
153 for ( CORBA::ULong i = 0; i < nbsegs.size(); i++)
154 anArray [ i ] = nbsegs [ i ];
156 return anArray._retn();
159 //=============================================================================
161 * StdMeshers_FixedPoints1D_i::SetReversedEdges
163 * Set edges to reverse
165 //=============================================================================
167 void StdMeshers_FixedPoints1D_i::SetReversedEdges( const SMESH::long_array& theIds )
169 ASSERT( myBaseImpl );
171 std::vector<int> ids( theIds.length() );
172 CORBA::Long iEnd = theIds.length();
173 for ( CORBA::Long i = 0; i < iEnd; i++ )
174 ids[ i ] = theIds[ i ];
176 this->GetImpl()->SetReversedEdges( ids );
178 catch ( SALOME_Exception& S_ex ) {
179 THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
183 // Update Python script
184 SMESH::TPythonDump() << _this() << ".SetReversedEdges( " << theIds << " )";
187 //=============================================================================
189 * StdMeshers_FixedPoints1D_i::SetObjectEntry
191 * Set the Entry for the Main Object
193 //=============================================================================
195 void StdMeshers_FixedPoints1D_i::SetObjectEntry( const char* theEntry )
197 ASSERT( myBaseImpl );
198 string entry(theEntry); // actually needed as theEntry is spoiled by moment of dumping
200 this->GetImpl()->SetObjectEntry( entry.c_str() );
201 // Update Python script
202 SMESH::TPythonDump() << _this() << ".SetObjectEntry( \"" << entry.c_str() << "\" )";
204 catch ( SALOME_Exception& S_ex ) {
205 THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),SALOME::BAD_PARAM );
209 //=============================================================================
211 * StdMeshers_FixedPoints1D_i::GetObjectEntry
213 * Set the Entry for the Main Object
215 //=============================================================================
217 char* StdMeshers_FixedPoints1D_i::GetObjectEntry()
219 ASSERT( myBaseImpl );
222 entry = this->GetImpl()->GetObjectEntry();
224 catch ( SALOME_Exception& S_ex ) {
225 THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
228 return CORBA::string_dup( entry );
231 //=============================================================================
233 * StdMeshers_FixedPoints1D_i::GetReversedEdges
237 //=============================================================================
239 SMESH::long_array* StdMeshers_FixedPoints1D_i::GetReversedEdges()
241 ASSERT( myBaseImpl );
242 SMESH::long_array_var anArray = new SMESH::long_array;
243 std::vector<int> ids = this->GetImpl()->GetReversedEdges();
244 anArray->length( ids.size() );
245 for ( CORBA::ULong i = 0; i < ids.size(); i++)
246 anArray [ i ] = ids [ i ];
248 return anArray._retn();
251 //=============================================================================
253 * StdMeshers_FixedPoints1D_i::GetImpl
257 //=============================================================================
259 ::StdMeshers_FixedPoints1D* StdMeshers_FixedPoints1D_i::GetImpl()
261 return ( ::StdMeshers_FixedPoints1D* )myBaseImpl;
264 //================================================================================
266 * \brief Verify whether hypothesis supports given entity type
267 * \param type - dimension (see SMESH::Dimension enumeration)
268 * \retval CORBA::Boolean - TRUE if dimension is supported, FALSE otherwise
270 * Verify whether hypothesis supports given entity type (see SMESH::Dimension enumeration)
272 //================================================================================
273 CORBA::Boolean StdMeshers_FixedPoints1D_i::IsDimSupported( SMESH::Dimension type )
275 return type == SMESH::DIM_1D;