1 // Copyright (C) 2007-2020 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 ),
50 StdMeshers_Reversible1D_i( this )
52 myBaseImpl = new ::StdMeshers_FixedPoints1D(theGenImpl->GetANewId(),
56 //=============================================================================
58 * StdMeshers_FixedPoints1D_i::~StdMeshers_FixedPoints1D_i
62 //=============================================================================
64 StdMeshers_FixedPoints1D_i::~StdMeshers_FixedPoints1D_i()
68 //=============================================================================
70 * StdMeshers_FixedPoints1D_i::SetNbSegments
72 //=============================================================================
74 void StdMeshers_FixedPoints1D_i::SetNbSegments(const SMESH::long_array& listNbSeg)
75 throw ( SALOME::SALOME_Exception )
79 std::vector<int> nbsegs( listNbSeg.length() );
80 CORBA::Long iEnd = listNbSeg.length();
81 for ( CORBA::Long i = 0; i < iEnd; i++ )
82 nbsegs[ i ] = listNbSeg[ i ];
83 this->GetImpl()->SetNbSegments( nbsegs );
85 catch ( SALOME_Exception& S_ex ) {
86 THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
90 // Update Python script
91 SMESH::TPythonDump() << _this() << ".SetNbSegments( " << listNbSeg << " )";
94 //=============================================================================
96 * StdMeshers_FixedPoints1D_i::SetPoints
98 //=============================================================================
100 void StdMeshers_FixedPoints1D_i::SetPoints(const SMESH::double_array& listParams)
101 throw ( SALOME::SALOME_Exception )
103 ASSERT( myBaseImpl );
105 std::vector<double> params( listParams.length() );
106 CORBA::Long iEnd = listParams.length();
107 for ( CORBA::Long i = 0; i < iEnd; i++ )
108 params[ i ] = listParams[ i ];
109 this->GetImpl()->SetPoints( params );
111 catch ( SALOME_Exception& S_ex ) {
112 THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
116 // Update Python script
117 SMESH::TPythonDump() << _this() << ".SetPoints( " << listParams << " )";
120 //=============================================================================
122 * StdMeshers_FixedPoints1D_i::GetPoints
124 * Get list of point's parameters
126 //=============================================================================
128 SMESH::double_array* StdMeshers_FixedPoints1D_i::GetPoints()
130 ASSERT( myBaseImpl );
131 SMESH::double_array_var anArray = new SMESH::double_array;
132 std::vector<double> params = this->GetImpl()->GetPoints();
133 anArray->length( params.size() );
134 for ( CORBA::ULong i = 0; i < params.size(); i++)
135 anArray [ i ] = params [ i ];
137 return anArray._retn();
140 //=============================================================================
142 * StdMeshers_FixedPoints1D_i::GetNbSegments
144 * Get list of point's parameters
146 //=============================================================================
148 SMESH::long_array* StdMeshers_FixedPoints1D_i::GetNbSegments()
150 ASSERT( myBaseImpl );
151 SMESH::long_array_var anArray = new SMESH::long_array;
152 std::vector<int> nbsegs = this->GetImpl()->GetNbSegments();
153 anArray->length( nbsegs.size() );
154 for ( CORBA::ULong i = 0; i < nbsegs.size(); i++)
155 anArray [ i ] = nbsegs [ i ];
157 return anArray._retn();
160 //=============================================================================
162 * StdMeshers_FixedPoints1D_i::GetImpl
166 //=============================================================================
168 ::StdMeshers_FixedPoints1D* StdMeshers_FixedPoints1D_i::GetImpl()
170 return ( ::StdMeshers_FixedPoints1D* )myBaseImpl;
173 //================================================================================
175 * \brief Verify whether hypothesis supports given entity type
176 * \param type - dimension (see SMESH::Dimension enumeration)
177 * \retval CORBA::Boolean - TRUE if dimension is supported, FALSE otherwise
179 * Verify whether hypothesis supports given entity type (see SMESH::Dimension enumeration)
181 //================================================================================
182 CORBA::Boolean StdMeshers_FixedPoints1D_i::IsDimSupported( SMESH::Dimension type )
184 return type == SMESH::DIM_1D;
187 //================================================================================
189 * \brief Return geometry this hypothesis depends on. Return false if there is no geometry parameter
191 //================================================================================
194 StdMeshers_FixedPoints1D_i::getObjectsDependOn( std::vector< std::string > & entryArray,
195 std::vector< int > & subIDArray ) const
197 return StdMeshers_Reversible1D_i::getObjectsDependOn( entryArray, subIDArray );
200 //================================================================================
202 * \brief Set new geometry instead of that returned by getObjectsDependOn()
204 //================================================================================
207 StdMeshers_FixedPoints1D_i::setObjectsDependOn( std::vector< std::string > & entryArray,
208 std::vector< int > & subIDArray )
210 return StdMeshers_Reversible1D_i::setObjectsDependOn( entryArray, subIDArray );