Salome HOME
Update copyrights 2014.
[modules/smesh.git] / src / StdMeshers_I / StdMeshers_Reversible1D_i.cxx
1 // Copyright (C) 2007-2014  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License, or (at your option) any later version.
10 //
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 // Lesser General Public License for more details.
15 //
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
19 //
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22
23 //  SMESH SMESH_I : idl implementation based on 'SMESH' unit's calsses
24 //  File   : StdMeshers_Reversible1D_i.cxx
25 //  Module : SMESH
26 //
27 #include "StdMeshers_Reversible1D_i.hxx"
28 #include "SMESH_PythonDump.hxx"
29
30 #include <Utils_CorbaException.hxx>
31 #include <utilities.h>
32
33 #include CORBA_SERVER_HEADER(SMESH_Hypothesis)
34
35 //================================================================================
36 /*!
37  * \brief Constructor
38  */
39 //================================================================================
40
41 StdMeshers_Reversible1D_i::StdMeshers_Reversible1D_i( SMESH_Hypothesis_i* reversible )
42   : myHyp( reversible )
43 {
44 }
45
46 //=============================================================================
47 /*!
48  *  StdMeshers_Reversible1D_i::SetReversedEdges
49  *
50  *  Set edges to reverse
51  */
52 //=============================================================================
53
54 void StdMeshers_Reversible1D_i::SetReversedEdges( const SMESH::long_array& theIds )
55 {
56   try {
57     std::vector<int> ids( theIds.length() );
58     CORBA::Long iEnd = theIds.length();
59     for ( CORBA::Long i = 0; i < iEnd; i++ )
60       ids[ i ] = theIds[ i ];
61
62     this->GetImpl()->SetReversedEdges( ids );
63   }
64   catch ( SALOME_Exception& S_ex ) {
65     THROW_SALOME_CORBA_EXCEPTION( S_ex.what(), SALOME::BAD_PARAM );
66   }
67
68   // Update Python script
69   SMESH::TPythonDump() << myHyp->_this() << ".SetReversedEdges( " << theIds << " )";
70 }
71
72 //=============================================================================
73 /*!
74  *  StdMeshers_Reversible1D_i::SetObjectEntry
75  *
76  *  Set the Entry for the Main Object
77  */
78 //=============================================================================
79
80 void StdMeshers_Reversible1D_i::SetObjectEntry( const char* theEntry )
81 {
82   string entry(theEntry); // actually needed as theEntry is spoiled by moment of dumping
83   try {
84     this->GetImpl()->SetObjectEntry( entry.c_str() );
85     // Update Python script
86     SMESH::TPythonDump() << myHyp->_this() << ".SetObjectEntry( \"" << entry.c_str() << "\" )";
87   }
88   catch ( SALOME_Exception& S_ex ) {
89     THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),SALOME::BAD_PARAM );
90   }
91 }
92
93 //=============================================================================
94 /*!
95  *  StdMeshers_Reversible1D_i::GetObjectEntry
96  *
97  *  Set the Entry for the Main Object
98  */
99 //=============================================================================
100
101 char* StdMeshers_Reversible1D_i::GetObjectEntry()
102 {
103   const char* entry;
104   try {
105     entry = this->GetImpl()->GetObjectEntry();
106   }
107   catch ( SALOME_Exception& S_ex ) {
108     THROW_SALOME_CORBA_EXCEPTION( S_ex.what(), SALOME::BAD_PARAM );
109   }
110   return CORBA::string_dup( entry );
111 }
112
113 //=============================================================================
114 /*!
115  *  StdMeshers_Reversible1D_i::GetReversedEdges
116  *
117  *  Get reversed edges
118  */
119 //=============================================================================
120
121 SMESH::long_array* StdMeshers_Reversible1D_i::GetReversedEdges()
122 {
123   SMESH::long_array_var anArray = new SMESH::long_array;
124   std::vector<int> ids = this->GetImpl()->GetReversedEdges();
125   anArray->length( ids.size() );
126   for ( CORBA::Long i = 0; i < ids.size(); i++)
127     anArray [ i ] = ids [ i ];
128
129   return anArray._retn();
130 }
131
132 //=============================================================================
133 /*!
134  *  StdMeshers_Reversible1D_i::GetImpl
135  *
136  *  Get implementation
137  */
138 //=============================================================================
139
140 ::StdMeshers_Reversible1D* StdMeshers_Reversible1D_i::GetImpl()
141 {
142   return ( ::StdMeshers_Reversible1D* )myHyp->GetImpl();
143 }