Salome HOME
ENV: Windows porting.
[modules/kernel.git] / src / SALOMEDS / SALOMEDS_AttributeSequenceOfReal.cxx
1 //  File   : SALOMEDS_AttributeSequenceOfReal.cxx
2 //  Author : Sergey RUIN
3 //  Module : SALOME
4
5 #include "SALOMEDS_AttributeSequenceOfReal.hxx"
6
7 #include <TCollection_AsciiString.hxx>
8 #include <TCollection_ExtendedString.hxx>
9 #include <TColStd_HSequenceOfReal.hxx>
10
11 SALOMEDS_AttributeSequenceOfReal
12 ::SALOMEDS_AttributeSequenceOfReal(const Handle(SALOMEDSImpl_AttributeSequenceOfReal)& theAttr)
13 :SALOMEDS_GenericAttribute(theAttr)
14 {}
15
16 SALOMEDS_AttributeSequenceOfReal::SALOMEDS_AttributeSequenceOfReal(SALOMEDS::AttributeSequenceOfReal_ptr theAttr)
17 :SALOMEDS_GenericAttribute(theAttr)
18 {}
19
20 SALOMEDS_AttributeSequenceOfReal::~SALOMEDS_AttributeSequenceOfReal()
21 {}
22
23 void SALOMEDS_AttributeSequenceOfReal::Assign(const std::vector<double>& other)
24 {
25   int i, aLength = other.size();
26   if(_isLocal) {
27     Handle(TColStd_HSequenceOfReal) aSeq = new TColStd_HSequenceOfReal;
28     for(i = 0; i < aLength; i++) aSeq->Append(other[i]);
29     Handle(SALOMEDSImpl_AttributeSequenceOfReal)::DownCast(_local_impl)->Assign(aSeq);
30   }
31   else {
32     SALOMEDS::DoubleSeq_var aSeq = new SALOMEDS::DoubleSeq();
33     aSeq->length(aLength);
34     for(i = 0; i < aLength; i++) aSeq[i] = other[i];
35     SALOMEDS::AttributeSequenceOfReal::_narrow(_corba_impl)->Assign(aSeq);
36   }
37 }
38
39 std::vector<double> SALOMEDS_AttributeSequenceOfReal::CorbaSequence()
40 {
41   std::vector<double> aVector;
42   int i, aLength;
43   if(_isLocal) {
44     Handle(SALOMEDSImpl_AttributeSequenceOfReal) aSeqAttr;
45     aSeqAttr = Handle(SALOMEDSImpl_AttributeSequenceOfReal)::DownCast(_local_impl);
46     aLength = aSeqAttr->Length();
47     for(i = 1; i <=aLength; i++) aVector.push_back(aSeqAttr->Value(i));
48   }
49   else {
50     SALOMEDS::AttributeSequenceOfReal_var aSeqAttr = SALOMEDS::AttributeSequenceOfReal::_narrow(_corba_impl);
51     aLength = aSeqAttr->Length();
52     for(i = 1; i <=aLength; i++) aVector.push_back(aSeqAttr->Value(i));
53   }
54   return aVector;
55 }
56  
57 void SALOMEDS_AttributeSequenceOfReal::Add(double value)
58 {
59   if(_isLocal) Handle(SALOMEDSImpl_AttributeSequenceOfReal)::DownCast(_local_impl)->Add(value);
60   else SALOMEDS::AttributeSequenceOfReal::_narrow(_corba_impl)->Add(value);
61 }
62
63 void SALOMEDS_AttributeSequenceOfReal::Remove(int index)
64 {
65   if(_isLocal) Handle(SALOMEDSImpl_AttributeSequenceOfReal)::DownCast(_local_impl)->Remove(index);
66   else SALOMEDS::AttributeSequenceOfReal::_narrow(_corba_impl)->Remove(index);
67 }
68  
69 void SALOMEDS_AttributeSequenceOfReal::ChangeValue(int index, double value)
70 {
71   if(_isLocal) Handle(SALOMEDSImpl_AttributeSequenceOfReal)::DownCast(_local_impl)->ChangeValue(index, value);
72   else SALOMEDS::AttributeSequenceOfReal::_narrow(_corba_impl)->ChangeValue(index, value);
73 }
74  
75 double SALOMEDS_AttributeSequenceOfReal::Value(int index)
76 {
77   double aValue;
78   if(_isLocal) aValue = Handle(SALOMEDSImpl_AttributeSequenceOfReal)::DownCast(_local_impl)->Value(index);
79   else aValue = SALOMEDS::AttributeSequenceOfReal::_narrow(_corba_impl)->Value(index);
80   return aValue;
81 }
82  
83 int SALOMEDS_AttributeSequenceOfReal::Length()
84 {
85   int aValue;
86   if(_isLocal) aValue = Handle(SALOMEDSImpl_AttributeSequenceOfReal)::DownCast(_local_impl)-> Length();
87   else aValue = SALOMEDS::AttributeSequenceOfReal::_narrow(_corba_impl)-> Length();
88   return aValue;
89 }