]> SALOME platform Git repositories - modules/kernel.git/blob - src/SALOMEDS/SALOMEDS_AttributeSequenceOfReal.cxx
Salome HOME
faffcaa29b3f67c0605b75774fd20f3464cf8c91
[modules/kernel.git] / src / SALOMEDS / SALOMEDS_AttributeSequenceOfReal.cxx
1 // Copyright (C) 2005  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
2 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
3 // 
4 // This library is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU Lesser General Public
6 // License as published by the Free Software Foundation; either 
7 // version 2.1 of the License.
8 // 
9 // This library is distributed in the hope that it will be useful 
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of 
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
12 // Lesser General Public License for more details.
13 //
14 // You should have received a copy of the GNU Lesser General Public  
15 // License along with this library; if not, write to the Free Software 
16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
17 //
18 // See http://www.salome-platform.org/
19 //
20 //  File   : SALOMEDS_AttributeSequenceOfReal.cxx
21 //  Author : Sergey RUIN
22 //  Module : SALOME
23
24 #include "SALOMEDS_AttributeSequenceOfReal.hxx"
25
26 #include <TCollection_AsciiString.hxx>
27 #include <TCollection_ExtendedString.hxx>
28 #include <TColStd_HSequenceOfReal.hxx>
29
30 SALOMEDS_AttributeSequenceOfReal
31 ::SALOMEDS_AttributeSequenceOfReal(const Handle(SALOMEDSImpl_AttributeSequenceOfReal)& theAttr)
32 :SALOMEDS_GenericAttribute(theAttr)
33 {}
34
35 SALOMEDS_AttributeSequenceOfReal::SALOMEDS_AttributeSequenceOfReal(SALOMEDS::AttributeSequenceOfReal_ptr theAttr)
36 :SALOMEDS_GenericAttribute(theAttr)
37 {}
38
39 SALOMEDS_AttributeSequenceOfReal::~SALOMEDS_AttributeSequenceOfReal()
40 {}
41
42 void SALOMEDS_AttributeSequenceOfReal::Assign(const std::vector<double>& other)
43 {
44   int i, aLength = other.size();
45   if(_isLocal) {
46     Handle(TColStd_HSequenceOfReal) aSeq = new TColStd_HSequenceOfReal;
47     for(i = 0; i < aLength; i++) aSeq->Append(other[i]);
48     Handle(SALOMEDSImpl_AttributeSequenceOfReal)::DownCast(_local_impl)->Assign(aSeq);
49   }
50   else {
51     SALOMEDS::DoubleSeq_var aSeq = new SALOMEDS::DoubleSeq();
52     aSeq->length(aLength);
53     for(i = 0; i < aLength; i++) aSeq[i] = other[i];
54     SALOMEDS::AttributeSequenceOfReal::_narrow(_corba_impl)->Assign(aSeq);
55   }
56 }
57
58 std::vector<double> SALOMEDS_AttributeSequenceOfReal::CorbaSequence()
59 {
60   std::vector<double> aVector;
61   int i, aLength;
62   if(_isLocal) {
63     Handle(SALOMEDSImpl_AttributeSequenceOfReal) aSeqAttr;
64     aSeqAttr = Handle(SALOMEDSImpl_AttributeSequenceOfReal)::DownCast(_local_impl);
65     aLength = aSeqAttr->Length();
66     for(i = 1; i <=aLength; i++) aVector.push_back(aSeqAttr->Value(i));
67   }
68   else {
69     SALOMEDS::AttributeSequenceOfReal_var aSeqAttr = SALOMEDS::AttributeSequenceOfReal::_narrow(_corba_impl);
70     aLength = aSeqAttr->Length();
71     for(i = 1; i <=aLength; i++) aVector.push_back(aSeqAttr->Value(i));
72   }
73   return aVector;
74 }
75  
76 void SALOMEDS_AttributeSequenceOfReal::Add(double value)
77 {
78   if(_isLocal) Handle(SALOMEDSImpl_AttributeSequenceOfReal)::DownCast(_local_impl)->Add(value);
79   else SALOMEDS::AttributeSequenceOfReal::_narrow(_corba_impl)->Add(value);
80 }
81
82 void SALOMEDS_AttributeSequenceOfReal::Remove(int index)
83 {
84   if(_isLocal) Handle(SALOMEDSImpl_AttributeSequenceOfReal)::DownCast(_local_impl)->Remove(index);
85   else SALOMEDS::AttributeSequenceOfReal::_narrow(_corba_impl)->Remove(index);
86 }
87  
88 void SALOMEDS_AttributeSequenceOfReal::ChangeValue(int index, double value)
89 {
90   if(_isLocal) Handle(SALOMEDSImpl_AttributeSequenceOfReal)::DownCast(_local_impl)->ChangeValue(index, value);
91   else SALOMEDS::AttributeSequenceOfReal::_narrow(_corba_impl)->ChangeValue(index, value);
92 }
93  
94 double SALOMEDS_AttributeSequenceOfReal::Value(int index)
95 {
96   double aValue;
97   if(_isLocal) aValue = Handle(SALOMEDSImpl_AttributeSequenceOfReal)::DownCast(_local_impl)->Value(index);
98   else aValue = SALOMEDS::AttributeSequenceOfReal::_narrow(_corba_impl)->Value(index);
99   return aValue;
100 }
101  
102 int SALOMEDS_AttributeSequenceOfReal::Length()
103 {
104   int aValue;
105   if(_isLocal) aValue = Handle(SALOMEDSImpl_AttributeSequenceOfReal)::DownCast(_local_impl)-> Length();
106   else aValue = SALOMEDS::AttributeSequenceOfReal::_narrow(_corba_impl)-> Length();
107   return aValue;
108 }