Salome HOME
Update of CheckDone
[modules/smesh.git] / src / StdMeshers_I / StdMeshers_FixedPoints1D_i.cxx
1 // Copyright (C) 2007-2021  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
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.
7 //
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.
12 //
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
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19
20 //  SMESH SMESH_I : idl implementation based on 'SMESH' unit's classes
21 //  File   : StdMeshers_FixedPoints1D_i.cxx
22 //  Author : Damien COQUERET, OCC
23 //  Module : SMESH
24 //  $Header$
25 //
26 #include "StdMeshers_FixedPoints1D_i.hxx"
27 #include "SMESH_Gen_i.hxx"
28 #include "SMESH_Gen.hxx"
29 #include "SMESH_PythonDump.hxx"
30
31 #include "Utils_CorbaException.hxx"
32 #include "utilities.h"
33
34 #include <TCollection_AsciiString.hxx>
35
36 using namespace std;
37
38 //=============================================================================
39 /*!
40  *  StdMeshers_FixedPoints1D_i::StdMeshers_FixedPoints1D_i
41  *
42  *  Constructor
43  */
44 //=============================================================================
45
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 )
51 {
52   myBaseImpl = new ::StdMeshers_FixedPoints1D(theGenImpl->GetANewId(),
53                                               theGenImpl);
54 }
55
56 //=============================================================================
57 /*!
58  *  StdMeshers_FixedPoints1D_i::~StdMeshers_FixedPoints1D_i
59  *
60  *  Destructor
61  */
62 //=============================================================================
63
64 StdMeshers_FixedPoints1D_i::~StdMeshers_FixedPoints1D_i()
65 {
66 }
67
68 //=============================================================================
69 /*!
70  *  StdMeshers_FixedPoints1D_i::SetNbSegments
71  */
72 //=============================================================================
73
74 void StdMeshers_FixedPoints1D_i::SetNbSegments(const SMESH::smIdType_array& listNbSeg)
75
76 {
77   ASSERT( myBaseImpl );
78   try {
79     std::vector<smIdType> nbsegs( listNbSeg.length() );
80     CORBA::ULong iEnd = listNbSeg.length();
81     for ( CORBA::ULong i = 0; i < iEnd; i++ )
82       nbsegs[ i ] = listNbSeg[ i ];
83     this->GetImpl()->SetNbSegments( nbsegs );
84   }
85   catch ( SALOME_Exception& S_ex ) {
86     THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
87                                   SALOME::BAD_PARAM );
88   }
89
90   // Update Python script
91   SMESH::TPythonDump() << _this() << ".SetNbSegments( " << listNbSeg << " )";
92 }
93
94 //=============================================================================
95 /*!
96  *  StdMeshers_FixedPoints1D_i::SetPoints
97  */
98 //=============================================================================
99
100 void StdMeshers_FixedPoints1D_i::SetPoints(const SMESH::double_array& listParams) 
101      
102 {
103   ASSERT( myBaseImpl );
104   try {
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 );
110   }
111   catch ( SALOME_Exception& S_ex ) {
112     THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
113                                   SALOME::BAD_PARAM );
114   }
115
116   // Update Python script
117   SMESH::TPythonDump() << _this() << ".SetPoints( " << listParams << " )";
118 }
119
120 //=============================================================================
121 /*!
122  *  StdMeshers_FixedPoints1D_i::GetPoints
123  *
124  *  Get list of point's parameters
125  */
126 //=============================================================================
127
128 SMESH::double_array* StdMeshers_FixedPoints1D_i::GetPoints()
129 {
130   ASSERT( myBaseImpl );
131   SMESH::double_array_var anArray = new SMESH::double_array;
132   std::vector<double> params = this->GetImpl()->GetPoints();
133   anArray->length( static_cast<CORBA::ULong>( params.size() ));
134   for ( CORBA::ULong i = 0; i < params.size(); i++)
135     anArray [ i ] = params [ i ];
136
137   return anArray._retn();
138 }
139
140 //=============================================================================
141 /*!
142  *  StdMeshers_FixedPoints1D_i::GetNbSegments
143  *
144  *  Get list of point's parameters
145  */
146 //=============================================================================
147
148 SMESH::smIdType_array* StdMeshers_FixedPoints1D_i::GetNbSegments()
149 {
150   ASSERT( myBaseImpl );
151   SMESH::smIdType_array_var anArray = new SMESH::smIdType_array;
152   std::vector<smIdType> nbsegs = this->GetImpl()->GetNbSegments();
153   anArray->length( static_cast<CORBA::ULong>( nbsegs.size() ));
154   for ( CORBA::ULong i = 0; i < nbsegs.size(); i++)
155     anArray [ i ] = nbsegs [ i ];
156
157   return anArray._retn();
158 }
159
160 //=============================================================================
161 /*!
162  *  StdMeshers_FixedPoints1D_i::GetImpl
163  *
164  *  Get implementation
165  */
166 //=============================================================================
167
168 ::StdMeshers_FixedPoints1D* StdMeshers_FixedPoints1D_i::GetImpl()
169 {
170   return ( ::StdMeshers_FixedPoints1D* )myBaseImpl;
171 }
172
173 //================================================================================
174 /*!
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
178  * 
179  * Verify whether hypothesis supports given entity type (see SMESH::Dimension enumeration)
180  */
181 //================================================================================
182 CORBA::Boolean StdMeshers_FixedPoints1D_i::IsDimSupported( SMESH::Dimension type )
183 {
184   return type == SMESH::DIM_1D;
185 }
186
187 //================================================================================
188 /*!
189  * \brief Return geometry this hypothesis depends on. Return false if there is no geometry parameter
190  */
191 //================================================================================
192
193 bool
194 StdMeshers_FixedPoints1D_i::getObjectsDependOn( std::vector< std::string > & entryArray,
195                                                 std::vector< int >         & subIDArray ) const
196 {
197   return StdMeshers_Reversible1D_i::getObjectsDependOn( entryArray, subIDArray );
198 }
199
200 //================================================================================
201 /*!
202  * \brief Set new geometry instead of that returned by getObjectsDependOn()
203  */
204 //================================================================================
205
206 bool
207 StdMeshers_FixedPoints1D_i::setObjectsDependOn( std::vector< std::string > & entryArray,
208                                                 std::vector< int >         & subIDArray )
209 {
210   return StdMeshers_Reversible1D_i::setObjectsDependOn( entryArray, subIDArray );
211 }