0023024: Update headers of OCCT files
[occt.git] / src / AppParCurves / AppParCurves_MultiPoint.cxx
CommitLineData
b311480e 1// Copyright (c) 1995-1999 Matra Datavision
2// Copyright (c) 1999-2012 OPEN CASCADE SAS
3//
4// The content of this file is subject to the Open CASCADE Technology Public
5// License Version 6.5 (the "License"). You may not use the content of this file
6// except in compliance with the License. Please obtain a copy of the License
7// at http://www.opencascade.org and read it completely before using this file.
8//
9// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
10// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
11//
12// The Original Code and all software distributed under the License is
13// distributed on an "AS IS" basis, without warranty of any kind, and the
14// Initial Developer hereby disclaims all such warranties, including without
15// limitation, any warranties of merchantability, fitness for a particular
16// purpose or non-infringement. Please see the License for the specific terms
17// and conditions governing the rights and limitations under the License.
18
7fd59977 19
20
21#include <AppParCurves_MultiPoint.ixx>
22#include <TColgp_HArray1OfPnt.hxx>
23#include <TColgp_HArray1OfPnt2d.hxx>
24
25#include <Standard_OutOfRange.hxx>
26
27#define tabPoint (*(Handle_TColgp_HArray1OfPnt*)&ttabPoint)
28#define tabPoint2d (*(Handle_TColgp_HArray1OfPnt2d*)&ttabPoint2d)
29
30AppParCurves_MultiPoint::AppParCurves_MultiPoint() {}
31
32
33AppParCurves_MultiPoint::AppParCurves_MultiPoint (const Standard_Integer NbPoles,
34 const Standard_Integer NbPoles2d)
35{
36 nbP = NbPoles;
37 nbP2d = NbPoles2d;
38 if (nbP != 0) {
39 Handle(TColgp_HArray1OfPnt) tab3d =
40 new TColgp_HArray1OfPnt(1, NbPoles);
41 ttabPoint = tab3d;
42 }
43 if (nbP2d != 0) {
44 Handle(TColgp_HArray1OfPnt2d) tab2d =
45 new TColgp_HArray1OfPnt2d(1, NbPoles2d);
46 ttabPoint2d = tab2d;
47 }
48}
49
50
51
52AppParCurves_MultiPoint::AppParCurves_MultiPoint(const TColgp_Array1OfPnt& tabP)
53{
54 nbP2d = 0;
55 nbP = tabP.Length();
56 Handle(TColgp_HArray1OfPnt) tab3d =
57 new TColgp_HArray1OfPnt(1, nbP);
58 ttabPoint = tab3d;
59 Standard_Integer Lower = tabP.Lower();
60 TColgp_Array1OfPnt& P3d = tabPoint->ChangeArray1();
61 for (Standard_Integer i = 1; i <= tabP.Length(); i++) {
62 P3d.SetValue(i, tabP.Value(Lower+i-1));
63 }
64}
65
66
67
68AppParCurves_MultiPoint::AppParCurves_MultiPoint(const TColgp_Array1OfPnt2d& tabP2d)
69{
70 nbP = 0;
71 nbP2d = tabP2d.Length();
72 Handle(TColgp_HArray1OfPnt2d) tab2d =
73 new TColgp_HArray1OfPnt2d(1, nbP2d);
74 ttabPoint2d = tab2d;
75 Standard_Integer Lower = tabP2d.Lower();
76 TColgp_Array1OfPnt2d& P2d = tabPoint2d->ChangeArray1();
77 for (Standard_Integer i = 1; i <= nbP2d; i++) {
78 P2d.SetValue(i, tabP2d.Value(Lower+i-1));
79 }
80}
81
82
83AppParCurves_MultiPoint::AppParCurves_MultiPoint(const TColgp_Array1OfPnt& tabP,
84 const TColgp_Array1OfPnt2d& tabP2d)
85{
86 nbP = tabP.Length();
87 nbP2d = tabP2d.Length();
88 Handle(TColgp_HArray1OfPnt) t3d =
89 new TColgp_HArray1OfPnt(1, nbP);
90 ttabPoint = t3d;
91
92 Handle(TColgp_HArray1OfPnt2d) t2d =
93 new TColgp_HArray1OfPnt2d(1, nbP2d);
94 ttabPoint2d = t2d;
95
96 TColgp_Array1OfPnt& P3d = tabPoint->ChangeArray1();
97 Standard_Integer i, Lower = tabP.Lower();
98 for (i = 1; i <= nbP; i++) {
99 P3d.SetValue(i, tabP.Value(Lower+i-1));
100 }
101 Lower = tabP2d.Lower();
102 TColgp_Array1OfPnt2d& P2d = tabPoint2d->ChangeArray1();
103 for (i = 1; i <= nbP2d; i++) {
104 P2d.SetValue(i, tabP2d.Value(Lower+i-1));
105 }
106}
107
108void AppParCurves_MultiPoint::Delete()
109{}
110
111void AppParCurves_MultiPoint::Transform(const Standard_Integer CuIndex,
112 const Standard_Real x,
113 const Standard_Real dx,
114 const Standard_Real y,
115 const Standard_Real dy,
116 const Standard_Real z,
117 const Standard_Real dz)
118{
119 if (Dimension(CuIndex) != 3) Standard_OutOfRange::Raise();
120
121 gp_Pnt P, newP;
122 P = Point(CuIndex);
123 newP.SetCoord(x + P.X()*dx, y + P.Y()*dy, z + P.Z()*dz);
124 tabPoint->SetValue(CuIndex, newP);
125}
126
127
128void AppParCurves_MultiPoint::Transform2d(const Standard_Integer CuIndex,
129 const Standard_Real x,
130 const Standard_Real dx,
131 const Standard_Real y,
132 const Standard_Real dy)
133{
134 if (Dimension(CuIndex) != 2) Standard_OutOfRange::Raise();
135
136 gp_Pnt2d P, newP;
137 P = Point2d(CuIndex);
138 newP.SetCoord(x + P.X()*dx, y + P.Y()*dy);
139 SetPoint2d(CuIndex, newP);
140}
141
142
143
144
145
146void AppParCurves_MultiPoint::SetPoint (const Standard_Integer Index,
147 const gp_Pnt& Point) {
148 Standard_OutOfRange_Raise_if((Index <= 0) || (Index > nbP), "");
149 tabPoint->SetValue(Index, Point);
150}
151
152
153const gp_Pnt& AppParCurves_MultiPoint::Point (const Standard_Integer Index) const
154{
155 Standard_OutOfRange_Raise_if((Index <= 0) || (Index > nbP), "");
156 return tabPoint->Value(Index);
157}
158
159
160
161void AppParCurves_MultiPoint::SetPoint2d (const Standard_Integer Index,
162 const gp_Pnt2d& Point)
163 {
164 Standard_OutOfRange_Raise_if((Index <= nbP) || (Index > nbP+nbP2d), "");
165 tabPoint2d->SetValue(Index-nbP, Point);
166}
167
168
169const gp_Pnt2d& AppParCurves_MultiPoint::Point2d (const Standard_Integer Index) const
170{
171 Standard_OutOfRange_Raise_if((Index <= nbP) || (Index > nbP+nbP2d), "");
172 return tabPoint2d->Value(Index-nbP);
173}
174
175
176
177
178
179void AppParCurves_MultiPoint::Dump(Standard_OStream& o) const
180{
181 o << "AppParCurves_MultiPoint dump:" << endl;
182 o << "It contains " << NbPoints() << " 3d points and " << NbPoints2d() <<" 2d points." << endl;
183 /*
184 if (Dimension(i) == 3) {
185 for (Standard_Integer j = 1; j <= tabPoint->Length(); j++) {
186 o << " Pole No. " << j << ": " << endl;
187 o << " Pole x = " << (tabPoint->Value(i)->Point(j)).X() << endl;
188 o << " Pole y = " << (tabPoint->Value(i)->Point(j)).Y() << endl;
189 o << " Pole z = " << (tabPoint->Value(i)->Point(j)).Z() << endl;
190 }
191 }
192 else {
193 for (Standard_Integer j = 1; j <= tabPoint->Length(); j++) {
194 o << " Pole No. " << j << ": " << endl;
195 o << " Pole x = " << (tabPoint->Value(i)->Point2d(j)).X() << endl;
196 o << " Pole y = " << (tabPoint->Value(i)->Point2d(j)).Y() << endl;
197 }
198*/
199}