Salome HOME
52566]: TC7.5.0: Empty group of Balls at Diameter Equal to filter
[modules/smesh.git] / src / StdMeshers_I / StdMeshers_FixedPoints1D_i.cxx
1 // Copyright (C) 2007-2014  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 calsses
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                                                         int                     theStudyId,
48                                                         ::SMESH_Gen*            theGenImpl )
49      : SALOME::GenericObj_i( thePOA ), 
50        SMESH_Hypothesis_i( thePOA )
51 {
52   MESSAGE( "StdMeshers_FixedPoints1D_i::StdMeshers_FixedPoints1D_i" );
53   myBaseImpl = new ::StdMeshers_FixedPoints1D(theGenImpl->GetANewId(),
54                                               theStudyId,
55                                               theGenImpl);
56 }
57
58 //=============================================================================
59 /*!
60  *  StdMeshers_FixedPoints1D_i::~StdMeshers_FixedPoints1D_i
61  *
62  *  Destructor
63  */
64 //=============================================================================
65
66 StdMeshers_FixedPoints1D_i::~StdMeshers_FixedPoints1D_i()
67 {
68   MESSAGE( "StdMeshers_FixedPoints1D_i::~StdMeshers_FixedPoints1D_i" );
69 }
70
71 //=============================================================================
72 /*!
73  *  StdMeshers_FixedPoints1D_i::SetNbSegments
74  */
75 //=============================================================================
76
77 void StdMeshers_FixedPoints1D_i::SetNbSegments(const SMESH::long_array& listNbSeg) 
78      throw ( SALOME::SALOME_Exception )
79 {
80   MESSAGE( "StdMeshers_FixedPoints1D_i::SetNbSegments" );
81   ASSERT( myBaseImpl );
82   try {
83     std::vector<int> nbsegs( listNbSeg.length() );
84     CORBA::Long iEnd = listNbSeg.length();
85     for ( CORBA::Long i = 0; i < iEnd; i++ )
86       nbsegs[ i ] = listNbSeg[ i ];
87     this->GetImpl()->SetNbSegments( nbsegs );
88   }
89   catch ( SALOME_Exception& S_ex ) {
90     THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
91                                   SALOME::BAD_PARAM );
92   }
93
94   // Update Python script
95   SMESH::TPythonDump() << _this() << ".SetNbSegments( " << listNbSeg << " )";
96 }
97
98 //=============================================================================
99 /*!
100  *  StdMeshers_FixedPoints1D_i::SetPoints
101  */
102 //=============================================================================
103
104 void StdMeshers_FixedPoints1D_i::SetPoints(const SMESH::double_array& listParams) 
105      throw ( SALOME::SALOME_Exception )
106 {
107   MESSAGE( "StdMeshers_FixedPoints1D_i::SetPoints" );
108   ASSERT( myBaseImpl );
109   try {
110     std::vector<double> params( listParams.length() );
111     CORBA::Long iEnd = listParams.length();
112     for ( CORBA::Long i = 0; i < iEnd; i++ )
113       params[ i ] = listParams[ i ];
114     this->GetImpl()->SetPoints( params );
115   }
116   catch ( SALOME_Exception& S_ex ) {
117     THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
118                                   SALOME::BAD_PARAM );
119   }
120
121   // Update Python script
122   SMESH::TPythonDump() << _this() << ".SetPoints( " << listParams << " )";
123 }
124
125 //=============================================================================
126 /*!
127  *  StdMeshers_FixedPoints1D_i::GetPoints
128  *
129  *  Get list of point's parameters
130  */
131 //=============================================================================
132
133 SMESH::double_array* StdMeshers_FixedPoints1D_i::GetPoints()
134 {
135   MESSAGE( "StdMeshers_FixedPoints1D_i::GetPoints" );
136   ASSERT( myBaseImpl );
137   SMESH::double_array_var anArray = new SMESH::double_array;
138   std::vector<double> params = this->GetImpl()->GetPoints();
139   anArray->length( params.size() );
140   for ( CORBA::Long i = 0; i < params.size(); i++)
141     anArray [ i ] = params [ i ];
142
143   return anArray._retn();
144 }
145
146 //=============================================================================
147 /*!
148  *  StdMeshers_FixedPoints1D_i::GetNbSegments
149  *
150  *  Get list of point's parameters
151  */
152 //=============================================================================
153
154 SMESH::long_array* StdMeshers_FixedPoints1D_i::GetNbSegments()
155 {
156   MESSAGE( "StdMeshers_FixedPoints1D_i::GetNbSegments" );
157   ASSERT( myBaseImpl );
158   SMESH::long_array_var anArray = new SMESH::long_array;
159   std::vector<int> nbsegs = this->GetImpl()->GetNbSegments();
160   anArray->length( nbsegs.size() );
161   for ( CORBA::Long i = 0; i < nbsegs.size(); i++)
162     anArray [ i ] = nbsegs [ i ];
163
164   return anArray._retn();
165 }
166
167 //=============================================================================
168 /*!
169  *  StdMeshers_FixedPoints1D_i::SetReversedEdges
170  *
171  *  Set edges to reverse
172  */
173 //=============================================================================
174
175 void StdMeshers_FixedPoints1D_i::SetReversedEdges( const SMESH::long_array& theIds )
176 {
177   ASSERT( myBaseImpl );
178   try {
179     std::vector<int> ids( theIds.length() );
180     CORBA::Long iEnd = theIds.length();
181     for ( CORBA::Long i = 0; i < iEnd; i++ )
182       ids[ i ] = theIds[ i ];
183
184     this->GetImpl()->SetReversedEdges( ids );
185   }
186   catch ( SALOME_Exception& S_ex ) {
187     THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
188                                   SALOME::BAD_PARAM );
189   }
190
191   // Update Python script
192   SMESH::TPythonDump() << _this() << ".SetReversedEdges( " << theIds << " )";
193 }
194
195 //=============================================================================
196 /*!
197  *  StdMeshers_FixedPoints1D_i::SetObjectEntry
198  *
199  *  Set the Entry for the Main Object
200  */
201 //=============================================================================
202
203 void StdMeshers_FixedPoints1D_i::SetObjectEntry( const char* theEntry )
204 {
205   ASSERT( myBaseImpl );
206   string entry(theEntry); // actually needed as theEntry is spoiled by moment of dumping
207   try {
208     this->GetImpl()->SetObjectEntry( entry.c_str() );
209     // Update Python script
210     SMESH::TPythonDump() << _this() << ".SetObjectEntry( \"" << entry.c_str() << "\" )";
211   }
212   catch ( SALOME_Exception& S_ex ) {
213     THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),SALOME::BAD_PARAM );
214   }
215 }
216
217 //=============================================================================
218 /*!
219  *  StdMeshers_FixedPoints1D_i::GetObjectEntry
220  *
221  *  Set the Entry for the Main Object
222  */
223 //=============================================================================
224
225 char* StdMeshers_FixedPoints1D_i::GetObjectEntry()
226 {
227   MESSAGE( "StdMeshers_FixedPoints1D_i::SetObjectEntry" );
228   ASSERT( myBaseImpl );
229   const char* entry;
230   try {
231     entry = this->GetImpl()->GetObjectEntry();
232   }
233   catch ( SALOME_Exception& S_ex ) {
234     THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
235                                   SALOME::BAD_PARAM );
236   }
237   return CORBA::string_dup( entry );
238 }
239
240 //=============================================================================
241 /*!
242  *  StdMeshers_FixedPoints1D_i::GetReversedEdges
243  *
244  *  Get reversed edges
245  */
246 //=============================================================================
247
248 SMESH::long_array* StdMeshers_FixedPoints1D_i::GetReversedEdges()
249 {
250   MESSAGE( "StdMeshers_FixedPoints1D_i::GetReversedEdges" );
251   ASSERT( myBaseImpl );
252   SMESH::long_array_var anArray = new SMESH::long_array;
253   std::vector<int> ids = this->GetImpl()->GetReversedEdges();
254   anArray->length( ids.size() );
255   for ( CORBA::Long i = 0; i < ids.size(); i++)
256     anArray [ i ] = ids [ i ];
257
258   return anArray._retn();
259 }
260
261 //=============================================================================
262 /*!
263  *  StdMeshers_FixedPoints1D_i::GetImpl
264  *
265  *  Get implementation
266  */
267 //=============================================================================
268
269 ::StdMeshers_FixedPoints1D* StdMeshers_FixedPoints1D_i::GetImpl()
270 {
271   MESSAGE( "StdMeshers_FixedPoints1D_i::GetImpl" );
272   return ( ::StdMeshers_FixedPoints1D* )myBaseImpl;
273 }
274
275 //================================================================================
276 /*!
277  * \brief Verify whether hypothesis supports given entity type 
278   * \param type - dimension (see SMESH::Dimension enumeration)
279   * \retval CORBA::Boolean - TRUE if dimension is supported, FALSE otherwise
280  * 
281  * Verify whether hypothesis supports given entity type (see SMESH::Dimension enumeration)
282  */
283 //================================================================================  
284 CORBA::Boolean StdMeshers_FixedPoints1D_i::IsDimSupported( SMESH::Dimension type )
285 {
286   return type == SMESH::DIM_1D;
287 }
288