Integration of OCCT 6.5.0 from SVN
[occt.git] / src / AppParCurves / AppParCurves_MultiPoint.cxx
1 //File AppParCurves_MultiPoint.cxx
2 //Lpa, le 3/12/91
3
4
5 #include <AppParCurves_MultiPoint.ixx>
6 #include <TColgp_HArray1OfPnt.hxx>
7 #include <TColgp_HArray1OfPnt2d.hxx>
8
9 #include <Standard_OutOfRange.hxx>
10
11 #define tabPoint   (*(Handle_TColgp_HArray1OfPnt*)&ttabPoint)
12 #define tabPoint2d (*(Handle_TColgp_HArray1OfPnt2d*)&ttabPoint2d)
13
14 AppParCurves_MultiPoint::AppParCurves_MultiPoint() {}
15
16
17 AppParCurves_MultiPoint::AppParCurves_MultiPoint (const Standard_Integer NbPoles, 
18                                                   const Standard_Integer NbPoles2d)
19 {
20   nbP = NbPoles;
21   nbP2d = NbPoles2d;
22   if (nbP != 0)  {
23     Handle(TColgp_HArray1OfPnt) tab3d = 
24       new TColgp_HArray1OfPnt(1, NbPoles);
25     ttabPoint = tab3d;
26   }
27   if (nbP2d != 0) {
28     Handle(TColgp_HArray1OfPnt2d) tab2d = 
29       new TColgp_HArray1OfPnt2d(1, NbPoles2d);
30     ttabPoint2d = tab2d;
31   }
32 }
33
34
35
36 AppParCurves_MultiPoint::AppParCurves_MultiPoint(const TColgp_Array1OfPnt& tabP)
37 {
38   nbP2d = 0;
39   nbP = tabP.Length();
40   Handle(TColgp_HArray1OfPnt) tab3d = 
41     new TColgp_HArray1OfPnt(1, nbP);
42   ttabPoint = tab3d;
43   Standard_Integer Lower = tabP.Lower();
44   TColgp_Array1OfPnt& P3d = tabPoint->ChangeArray1();
45   for (Standard_Integer i = 1; i <= tabP.Length(); i++) {
46     P3d.SetValue(i, tabP.Value(Lower+i-1));
47   }
48 }
49
50
51
52 AppParCurves_MultiPoint::AppParCurves_MultiPoint(const TColgp_Array1OfPnt2d& tabP2d)
53 {
54   nbP = 0;
55   nbP2d = tabP2d.Length();
56   Handle(TColgp_HArray1OfPnt2d) tab2d = 
57     new TColgp_HArray1OfPnt2d(1, nbP2d);
58   ttabPoint2d = tab2d;
59   Standard_Integer Lower = tabP2d.Lower();
60   TColgp_Array1OfPnt2d& P2d = tabPoint2d->ChangeArray1();
61   for (Standard_Integer i = 1; i <= nbP2d; i++) {
62     P2d.SetValue(i, tabP2d.Value(Lower+i-1));
63   }
64 }
65
66
67 AppParCurves_MultiPoint::AppParCurves_MultiPoint(const TColgp_Array1OfPnt&   tabP,
68                                                  const TColgp_Array1OfPnt2d& tabP2d)
69 {
70   nbP = tabP.Length();
71   nbP2d = tabP2d.Length();
72   Handle(TColgp_HArray1OfPnt) t3d = 
73     new TColgp_HArray1OfPnt(1, nbP);
74   ttabPoint = t3d;
75
76   Handle(TColgp_HArray1OfPnt2d) t2d = 
77     new TColgp_HArray1OfPnt2d(1, nbP2d);
78   ttabPoint2d = t2d;
79
80   TColgp_Array1OfPnt& P3d = tabPoint->ChangeArray1();
81   Standard_Integer i, Lower = tabP.Lower();
82   for (i = 1; i <= nbP; i++) {
83     P3d.SetValue(i, tabP.Value(Lower+i-1));
84   }
85   Lower = tabP2d.Lower();
86   TColgp_Array1OfPnt2d& P2d = tabPoint2d->ChangeArray1();
87   for (i = 1; i <= nbP2d; i++) {
88     P2d.SetValue(i, tabP2d.Value(Lower+i-1));
89   }
90 }
91
92 void AppParCurves_MultiPoint::Delete()
93 {}
94
95 void AppParCurves_MultiPoint::Transform(const Standard_Integer CuIndex,
96                                         const Standard_Real    x,
97                                         const Standard_Real    dx,
98                                         const Standard_Real    y,
99                                         const Standard_Real    dy,
100                                         const Standard_Real    z,
101                                         const Standard_Real    dz) 
102 {
103   if (Dimension(CuIndex) != 3) Standard_OutOfRange::Raise();
104
105   gp_Pnt P, newP;
106   P = Point(CuIndex);
107   newP.SetCoord(x + P.X()*dx, y + P.Y()*dy, z + P.Z()*dz);
108   tabPoint->SetValue(CuIndex, newP);
109 }
110
111
112 void AppParCurves_MultiPoint::Transform2d(const Standard_Integer CuIndex,
113                                           const Standard_Real    x,
114                                           const Standard_Real    dx,
115                                           const Standard_Real    y,
116                                           const Standard_Real    dy) 
117 {
118   if (Dimension(CuIndex) != 2) Standard_OutOfRange::Raise();
119
120   gp_Pnt2d P, newP;
121   P = Point2d(CuIndex);
122   newP.SetCoord(x + P.X()*dx, y + P.Y()*dy);
123   SetPoint2d(CuIndex, newP);
124 }
125
126
127
128
129
130 void AppParCurves_MultiPoint::SetPoint (const Standard_Integer Index, 
131                                         const gp_Pnt&          Point) {
132   Standard_OutOfRange_Raise_if((Index <= 0) || (Index > nbP), "");
133   tabPoint->SetValue(Index, Point);
134 }
135
136
137 const gp_Pnt& AppParCurves_MultiPoint::Point (const Standard_Integer Index) const 
138 {
139   Standard_OutOfRange_Raise_if((Index <= 0) || (Index > nbP), "");
140   return tabPoint->Value(Index);
141 }
142   
143
144
145 void AppParCurves_MultiPoint::SetPoint2d (const Standard_Integer Index, 
146                                           const gp_Pnt2d& Point)
147  {
148   Standard_OutOfRange_Raise_if((Index <= nbP) || (Index > nbP+nbP2d), "");
149   tabPoint2d->SetValue(Index-nbP, Point);
150 }
151
152
153 const gp_Pnt2d& AppParCurves_MultiPoint::Point2d (const Standard_Integer Index) const 
154 {
155   Standard_OutOfRange_Raise_if((Index <= nbP) || (Index > nbP+nbP2d), "");
156   return tabPoint2d->Value(Index-nbP);
157 }
158   
159
160
161
162
163 void AppParCurves_MultiPoint::Dump(Standard_OStream& o) const
164 {
165   o << "AppParCurves_MultiPoint dump:" << endl;
166   o << "It contains " << NbPoints() << " 3d points and " << NbPoints2d() <<" 2d points." << endl;
167   /*
168     if (Dimension(i) == 3) {
169       for (Standard_Integer j = 1; j <= tabPoint->Length(); j++) {
170         o << " Pole No. " << j << ": " << endl;
171         o << " Pole x = " << (tabPoint->Value(i)->Point(j)).X() << endl;
172         o << " Pole y = " << (tabPoint->Value(i)->Point(j)).Y() << endl;
173         o << " Pole z = " << (tabPoint->Value(i)->Point(j)).Z() << endl;
174       }
175     }
176     else {
177       for (Standard_Integer j = 1; j <= tabPoint->Length(); j++) {
178         o << " Pole No. " << j << ": " << endl;
179         o << " Pole x = " << (tabPoint->Value(i)->Point2d(j)).X() << endl;
180         o << " Pole y = " << (tabPoint->Value(i)->Point2d(j)).Y() << endl;
181       }
182 */
183 }