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 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 myBaseImpl = new ::StdMeshers_FixedPoints1D(theGenImpl->GetANewId(),
57 //=============================================================================
59 * StdMeshers_FixedPoints1D_i::~StdMeshers_FixedPoints1D_i
63 //=============================================================================
65 StdMeshers_FixedPoints1D_i::~StdMeshers_FixedPoints1D_i()
69 //=============================================================================
71 * StdMeshers_FixedPoints1D_i::SetNbSegments
73 //=============================================================================
75 void StdMeshers_FixedPoints1D_i::SetNbSegments(const SMESH::long_array& listNbSeg)
76 throw ( SALOME::SALOME_Exception )
80 std::vector<int> nbsegs( listNbSeg.length() );
81 CORBA::Long iEnd = listNbSeg.length();
82 for ( CORBA::Long i = 0; i < iEnd; i++ )
83 nbsegs[ i ] = listNbSeg[ i ];
84 this->GetImpl()->SetNbSegments( nbsegs );
86 catch ( SALOME_Exception& S_ex ) {
87 THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
91 // Update Python script
92 SMESH::TPythonDump() << _this() << ".SetNbSegments( " << listNbSeg << " )";
95 //=============================================================================
97 * StdMeshers_FixedPoints1D_i::SetPoints
99 //=============================================================================
101 void StdMeshers_FixedPoints1D_i::SetPoints(const SMESH::double_array& listParams)
102 throw ( SALOME::SALOME_Exception )
104 ASSERT( myBaseImpl );
106 std::vector<double> params( listParams.length() );
107 CORBA::Long iEnd = listParams.length();
108 for ( CORBA::Long i = 0; i < iEnd; i++ )
109 params[ i ] = listParams[ i ];
110 this->GetImpl()->SetPoints( params );
112 catch ( SALOME_Exception& S_ex ) {
113 THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
117 // Update Python script
118 SMESH::TPythonDump() << _this() << ".SetPoints( " << listParams << " )";
121 //=============================================================================
123 * StdMeshers_FixedPoints1D_i::GetPoints
125 * Get list of point's parameters
127 //=============================================================================
129 SMESH::double_array* StdMeshers_FixedPoints1D_i::GetPoints()
131 ASSERT( myBaseImpl );
132 SMESH::double_array_var anArray = new SMESH::double_array;
133 std::vector<double> params = this->GetImpl()->GetPoints();
134 anArray->length( params.size() );
135 for ( CORBA::ULong i = 0; i < params.size(); i++)
136 anArray [ i ] = params [ i ];
138 return anArray._retn();
141 //=============================================================================
143 * StdMeshers_FixedPoints1D_i::GetNbSegments
145 * Get list of point's parameters
147 //=============================================================================
149 SMESH::long_array* StdMeshers_FixedPoints1D_i::GetNbSegments()
151 ASSERT( myBaseImpl );
152 SMESH::long_array_var anArray = new SMESH::long_array;
153 std::vector<int> nbsegs = this->GetImpl()->GetNbSegments();
154 anArray->length( nbsegs.size() );
155 for ( CORBA::ULong i = 0; i < nbsegs.size(); i++)
156 anArray [ i ] = nbsegs [ i ];
158 return anArray._retn();
161 //=============================================================================
163 * StdMeshers_FixedPoints1D_i::SetReversedEdges
165 * Set edges to reverse
167 //=============================================================================
169 void StdMeshers_FixedPoints1D_i::SetReversedEdges( const SMESH::long_array& theIds )
171 ASSERT( myBaseImpl );
173 std::vector<int> ids( theIds.length() );
174 CORBA::Long iEnd = theIds.length();
175 for ( CORBA::Long i = 0; i < iEnd; i++ )
176 ids[ i ] = theIds[ i ];
178 this->GetImpl()->SetReversedEdges( ids );
180 catch ( SALOME_Exception& S_ex ) {
181 THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
185 // Update Python script
186 SMESH::TPythonDump() << _this() << ".SetReversedEdges( " << theIds << " )";
189 //=============================================================================
191 * StdMeshers_FixedPoints1D_i::SetObjectEntry
193 * Set the Entry for the Main Object
195 //=============================================================================
197 void StdMeshers_FixedPoints1D_i::SetObjectEntry( const char* theEntry )
199 ASSERT( myBaseImpl );
200 string entry(theEntry); // actually needed as theEntry is spoiled by moment of dumping
202 this->GetImpl()->SetObjectEntry( entry.c_str() );
203 // Update Python script
204 SMESH::TPythonDump() << _this() << ".SetObjectEntry( \"" << entry.c_str() << "\" )";
206 catch ( SALOME_Exception& S_ex ) {
207 THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),SALOME::BAD_PARAM );
211 //=============================================================================
213 * StdMeshers_FixedPoints1D_i::GetObjectEntry
215 * Set the Entry for the Main Object
217 //=============================================================================
219 char* StdMeshers_FixedPoints1D_i::GetObjectEntry()
221 ASSERT( myBaseImpl );
224 entry = this->GetImpl()->GetObjectEntry();
226 catch ( SALOME_Exception& S_ex ) {
227 THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
230 return CORBA::string_dup( entry );
233 //=============================================================================
235 * StdMeshers_FixedPoints1D_i::GetReversedEdges
239 //=============================================================================
241 SMESH::long_array* StdMeshers_FixedPoints1D_i::GetReversedEdges()
243 ASSERT( myBaseImpl );
244 SMESH::long_array_var anArray = new SMESH::long_array;
245 std::vector<int> ids = this->GetImpl()->GetReversedEdges();
246 anArray->length( ids.size() );
247 for ( CORBA::ULong i = 0; i < ids.size(); i++)
248 anArray [ i ] = ids [ i ];
250 return anArray._retn();
253 //=============================================================================
255 * StdMeshers_FixedPoints1D_i::GetImpl
259 //=============================================================================
261 ::StdMeshers_FixedPoints1D* StdMeshers_FixedPoints1D_i::GetImpl()
263 return ( ::StdMeshers_FixedPoints1D* )myBaseImpl;
266 //================================================================================
268 * \brief Verify whether hypothesis supports given entity type
269 * \param type - dimension (see SMESH::Dimension enumeration)
270 * \retval CORBA::Boolean - TRUE if dimension is supported, FALSE otherwise
272 * Verify whether hypothesis supports given entity type (see SMESH::Dimension enumeration)
274 //================================================================================
275 CORBA::Boolean StdMeshers_FixedPoints1D_i::IsDimSupported( SMESH::Dimension type )
277 return type == SMESH::DIM_1D;