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