Integration of OCCT 6.5.0 from SVN
[occt.git] / src / IntPolyh / IntPolyh_SectionLine.cxx
CommitLineData
7fd59977 1// File: IntPolyh_SectionLine.cxx
2// Created: Tue Apr 6 11:05:39 1999
3// Author: Fabrice SERVANT
4// <fst@cleox.paris1.matra-dtv.fr>
5
6// modified by Edward AGAPOV (eap) Thu Feb 14 2002 (occ139)
7// Add Prepend(), replace array with sequence
8
9#include <IntPolyh_StartPoint.ixx>
10#include <IntPolyh_SectionLine.ixx>
11#include <stdio.h>
12
13//=======================================================================
14//function : IntPolyh_SectionLine
15//purpose :
16//=======================================================================
17
18IntPolyh_SectionLine::IntPolyh_SectionLine() /*: n(0),nbstartpoints(0),ptr(0)*/ { }
19
20//=======================================================================
21//function : IntPolyh_SectionLine
22//purpose :
23//=======================================================================
24
25IntPolyh_SectionLine::IntPolyh_SectionLine(const Standard_Integer N)/* : nbstartpoints(0)*/{
26 Init(N);
27}
28
29//=======================================================================
30//function : Init
31//purpose :
32//=======================================================================
33
34void IntPolyh_SectionLine::Init(const Standard_Integer /*N*/) {
35// ptr = (void*) (new IntPolyh_StartPoint [N]);
36// n=N;
37 if (!mySeqOfSPoints.Length()) IncrementNbStartPoints();
38}
39
40//=======================================================================
41//function : GetN
42//purpose :
43//=======================================================================
44
45Standard_Integer IntPolyh_SectionLine::GetN() const {
46 //return(n);
47 return mySeqOfSPoints.Length();
48}
49
50//=======================================================================
51//function : NbStartPoints
52//purpose :
53//=======================================================================
54
55Standard_Integer IntPolyh_SectionLine::NbStartPoints() const {
56// return(nbstartpoints);
57 return mySeqOfSPoints.Length() - 1;
58}
59
60//=======================================================================
61//function : IncrementNbStartPoints
62//purpose :
63//=======================================================================
64
65void IntPolyh_SectionLine::IncrementNbStartPoints() {
66// nbstartpoints++;
67 IntPolyh_StartPoint aSP;
68 mySeqOfSPoints.Append(aSP);
69}
70
71//=======================================================================
72//function : Value
73//purpose :
74//=======================================================================
75
76// # ifdef DEB
77// #define BORNES1
78// # endif
79const IntPolyh_StartPoint& IntPolyh_SectionLine::Value(const Standard_Integer Index) const {
80// IntPolyh_StartPoint *ptrstpoint = (IntPolyh_StartPoint *)ptr;
81// #if BORNES
82// if(Index<0 || Index>=n) {
83// cerr<<" Erreur1 "<<endl;
84// printf("Value() from IntPolyh_SectionLine.cxx : ERROR : value out of array\n");
85// }
86// #endif
87// return(ptrstpoint[Index]);
88 return mySeqOfSPoints(Index+1);
89}
90
91//=======================================================================
92//function : ChangeValue
93//purpose :
94//=======================================================================
95
96IntPolyh_StartPoint& IntPolyh_SectionLine::ChangeValue(const Standard_Integer Index) {
97// IntPolyh_StartPoint *ptrstpoint = (IntPolyh_StartPoint *)ptr;
98// #if BORNES
99// if(Index<0 || Index>=n) {
100// cerr<<" Erreur1 "<<endl;
101// printf("ChangeValue() from IntPolyh_SectionLine.cxx : ERROR : value out of array\n");
102// }
103// #endif
104// return(ptrstpoint[Index]);
105 return mySeqOfSPoints(Index+1);
106}
107
108//=======================================================================
109//function : Destroy
110//purpose :
111//=======================================================================
112
113void IntPolyh_SectionLine::Destroy() {
114// if(n) {
115// if(ptr) {
116// IntPolyh_StartPoint *ptrstpoint = (IntPolyh_StartPoint *)ptr;
117// delete [] ptrstpoint;
118// ptr=0;
119// n=0;
120// }
121// }
122}
123
124//=======================================================================
125//function : Copy
126//purpose :
127//=======================================================================
128
129IntPolyh_SectionLine & IntPolyh_SectionLine::Copy(const IntPolyh_SectionLine& Other) {
130// if(ptr==Other.ptr) return(*this);
131// Destroy();
132// n=Other.n;
133// ptr = (void *) (new IntPolyh_StartPoint[n]);
134// for(Standard_Integer i=0;i<=n;i++) {
135// (*this)[i]=Other[i];
136// }
137 mySeqOfSPoints = Other.mySeqOfSPoints;
138 return(*this);
139}
140
141//=======================================================================
142//function : Dump
143//purpose :
144//=======================================================================
145
146void IntPolyh_SectionLine::Dump() const{
147 printf("\n SectionLine 0-> %d",/*nbstartpoints*/NbStartPoints()-1);
148 for(Standard_Integer i=0;i<NbStartPoints();i++) {
149 //(*this)[i].Dump(i);
150 Value(i).Dump(i);
151// const IntPolyh_StartPoint& SP = Value(i);
152// cout << "point P" << i << " " << SP.X() << " " << SP.Y() << " " << SP.Z() << endl;
153 }
154 printf("\n");
155}
156
157//=======================================================================
158//function : Prepend
159//purpose :
160//=======================================================================
161
162void IntPolyh_SectionLine::Prepend(const IntPolyh_StartPoint& SP)
163{
164 mySeqOfSPoints.Prepend(SP);
165}
166
167
168