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 ),
51 StdMeshers_Reversible1D_i( this )
53 myBaseImpl = new ::StdMeshers_FixedPoints1D(theGenImpl->GetANewId(),
58 //=============================================================================
60 * StdMeshers_FixedPoints1D_i::~StdMeshers_FixedPoints1D_i
64 //=============================================================================
66 StdMeshers_FixedPoints1D_i::~StdMeshers_FixedPoints1D_i()
70 //=============================================================================
72 * StdMeshers_FixedPoints1D_i::SetNbSegments
74 //=============================================================================
76 void StdMeshers_FixedPoints1D_i::SetNbSegments(const SMESH::long_array& listNbSeg)
77 throw ( SALOME::SALOME_Exception )
81 std::vector<int> nbsegs( listNbSeg.length() );
82 CORBA::Long iEnd = listNbSeg.length();
83 for ( CORBA::Long i = 0; i < iEnd; i++ )
84 nbsegs[ i ] = listNbSeg[ i ];
85 this->GetImpl()->SetNbSegments( nbsegs );
87 catch ( SALOME_Exception& S_ex ) {
88 THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
92 // Update Python script
93 SMESH::TPythonDump() << _this() << ".SetNbSegments( " << listNbSeg << " )";
96 //=============================================================================
98 * StdMeshers_FixedPoints1D_i::SetPoints
100 //=============================================================================
102 void StdMeshers_FixedPoints1D_i::SetPoints(const SMESH::double_array& listParams)
103 throw ( SALOME::SALOME_Exception )
105 ASSERT( myBaseImpl );
107 std::vector<double> params( listParams.length() );
108 CORBA::Long iEnd = listParams.length();
109 for ( CORBA::Long i = 0; i < iEnd; i++ )
110 params[ i ] = listParams[ i ];
111 this->GetImpl()->SetPoints( params );
113 catch ( SALOME_Exception& S_ex ) {
114 THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
118 // Update Python script
119 SMESH::TPythonDump() << _this() << ".SetPoints( " << listParams << " )";
122 //=============================================================================
124 * StdMeshers_FixedPoints1D_i::GetPoints
126 * Get list of point's parameters
128 //=============================================================================
130 SMESH::double_array* StdMeshers_FixedPoints1D_i::GetPoints()
132 ASSERT( myBaseImpl );
133 SMESH::double_array_var anArray = new SMESH::double_array;
134 std::vector<double> params = this->GetImpl()->GetPoints();
135 anArray->length( params.size() );
136 for ( CORBA::ULong i = 0; i < params.size(); i++)
137 anArray [ i ] = params [ i ];
139 return anArray._retn();
142 //=============================================================================
144 * StdMeshers_FixedPoints1D_i::GetNbSegments
146 * Get list of point's parameters
148 //=============================================================================
150 SMESH::long_array* StdMeshers_FixedPoints1D_i::GetNbSegments()
152 ASSERT( myBaseImpl );
153 SMESH::long_array_var anArray = new SMESH::long_array;
154 std::vector<int> nbsegs = this->GetImpl()->GetNbSegments();
155 anArray->length( nbsegs.size() );
156 for ( CORBA::ULong i = 0; i < nbsegs.size(); i++)
157 anArray [ i ] = nbsegs [ i ];
159 return anArray._retn();
162 //=============================================================================
164 * StdMeshers_FixedPoints1D_i::GetImpl
168 //=============================================================================
170 ::StdMeshers_FixedPoints1D* StdMeshers_FixedPoints1D_i::GetImpl()
172 return ( ::StdMeshers_FixedPoints1D* )myBaseImpl;
175 //================================================================================
177 * \brief Verify whether hypothesis supports given entity type
178 * \param type - dimension (see SMESH::Dimension enumeration)
179 * \retval CORBA::Boolean - TRUE if dimension is supported, FALSE otherwise
181 * Verify whether hypothesis supports given entity type (see SMESH::Dimension enumeration)
183 //================================================================================
184 CORBA::Boolean StdMeshers_FixedPoints1D_i::IsDimSupported( SMESH::Dimension type )
186 return type == SMESH::DIM_1D;
189 //================================================================================
191 * \brief Return geometry this hypothesis depends on. Return false if there is no geometry parameter
193 //================================================================================
196 StdMeshers_FixedPoints1D_i::getObjectsDependOn( std::vector< std::string > & entryArray,
197 std::vector< int > & subIDArray ) const
199 return StdMeshers_Reversible1D_i::getObjectsDependOn( entryArray, subIDArray );
202 //================================================================================
204 * \brief Set new geometry instead of that returned by getObjectsDependOn()
206 //================================================================================
209 StdMeshers_FixedPoints1D_i::setObjectsDependOn( std::vector< std::string > & entryArray,
210 std::vector< int > & subIDArray )
212 return StdMeshers_Reversible1D_i::setObjectsDependOn( entryArray, subIDArray );