00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036 #include "G4BSplineCurve.hh"
00037 #include "G4ControlPoints.hh"
00038 #include "G4KnotVector.hh"
00039
00040 G4BSplineCurve::G4BSplineCurve()
00041 : degree(0), controlPointsList(0), knots(0), weightsData(0)
00042 {
00043 }
00044
00045 void G4BSplineCurve::Init(G4int degree0, G4Point3DVector* controlPointsList0,
00046 std::vector<G4double>* knots0,
00047 std::vector<G4double>* weightsData0)
00048 {
00049 degree= degree0;
00050
00051 G4int nbpoints = controlPointsList0->size();
00052 controlPointsList = new G4Point3DVector(nbpoints,G4Point3D(0,0,0));
00053
00054 G4int a;
00055 for(a = 0; a < nbpoints; a++)
00056 {
00057 (*controlPointsList)[a] = (*controlPointsList0)[a];
00058 }
00059
00060 G4int nbknots = knots0->size();
00061 knots = new std::vector<G4double>(nbknots,0.);
00062 for(a = 0; a < nbknots; a++)
00063 {
00064 (*knots)[a] = (*knots0)[a];
00065 }
00066
00067 G4int nbweights = weightsData0->size();
00068 weightsData = new std::vector<G4double>(nbweights,0.);
00069 for(a = 0; a < nbweights; a++)
00070 {
00071 (*weightsData)[a] = (*weightsData0)[a];
00072 }
00073
00074 SetBounds((*knots)[0], (*knots)[knots->size()-1]);
00075 }
00076
00077
00078 G4BSplineCurve::~G4BSplineCurve()
00079 {
00080 delete [] controlPointsList;
00081 delete [] knots;
00082 delete [] weightsData;
00083 }
00084
00085
00086 G4BSplineCurve::G4BSplineCurve(const G4BSplineCurve& right)
00087 : G4Curve()
00088 {
00089 delete [] controlPointsList;
00090 delete [] knots;
00091 delete [] weightsData;
00092 Init(right.degree, right.controlPointsList,
00093 right.knots, right.weightsData);
00094 bBox = right.bBox;
00095 start = right.start;
00096 end = right.end;
00097 pStart = right.pStart;
00098 pEnd = right.pEnd;
00099 pRange = right.pRange;
00100 bounded = right.bounded;
00101 sameSense = right.sameSense;
00102 }
00103
00104 G4BSplineCurve& G4BSplineCurve::operator=(const G4BSplineCurve& right)
00105 {
00106 if (&right == this) { return *this; }
00107 delete [] controlPointsList;
00108 delete [] knots;
00109 delete [] weightsData;
00110 Init(right.degree, right.controlPointsList,
00111 right.knots, right.weightsData);
00112 bBox = right.bBox;
00113 start = right.start;
00114 end = right.end;
00115 pStart = right.pStart;
00116 pEnd = right.pEnd;
00117 pRange = right.pRange;
00118 bounded = right.bounded;
00119 sameSense = right.sameSense;
00120
00121 return *this;
00122 }
00123
00124
00125
00126 G4double G4BSplineCurve::GetPMax() const
00127 {
00128 return 0.0;
00129 }
00130
00131 G4Point3D G4BSplineCurve::GetPoint(G4double) const
00132 {
00133 return G4Point3D(0, 0, 0);
00134 }
00135
00136 G4double G4BSplineCurve::GetPPoint(const G4Point3D&) const
00137 {
00138 return 0.0;
00139 }
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150 G4int G4BSplineCurve::IntersectRay2D(const G4Ray&)
00151 {
00152
00153 G4Exception("G4BSplineCurve::IntersectRay2D()", "GeomSolids0001",
00154 FatalException, "Sorry, not yet implemented.");
00155 return 0;
00156 }
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167
00168
00169
00170
00171
00172
00173
00174
00175
00176 G4Curve* G4BSplineCurve::Project(const G4Transform3D& tr)
00177 {
00178
00179
00180
00181 G4int n = controlPointsList->size();
00182 G4Point3DVector* newControlPointsList = new G4Point3DVector(n);
00183
00184 for (G4int i=0; i<n; i++)
00185 {
00186 G4Point3D& p= (*newControlPointsList)[i];
00187 p= tr*(*controlPointsList)[i];
00188 p.setZ(0);
00189 }
00190
00191 std::vector<G4double>* newKnots= new std::vector<G4double>(*knots);
00192 std::vector<G4double>* newWeightsData=
00193 weightsData ? new std::vector<G4double>(*weightsData)
00194 : new std::vector<G4double>(0);
00195
00196 G4BSplineCurve* r= new G4BSplineCurve;
00197 r->Init(degree, newControlPointsList, newKnots, newWeightsData);
00198
00199 delete newControlPointsList;
00200 delete newKnots;
00201 delete newWeightsData;
00202
00203 if (IsBounded())
00204 {
00205 r->SetBounds(GetPStart(), GetPEnd());
00206 }
00207 return r;
00208 }
00209
00210
00211
00212
00213
00214
00215
00216
00217
00218
00219
00220
00221
00222
00223
00224
00225
00226
00227
00228
00229
00230
00231
00232
00233
00234
00235
00236
00237
00238
00239
00240
00241
00242
00243
00244
00245
00246
00247
00248
00249
00250
00251
00252
00253
00254
00255
00256
00257
00258
00259
00260
00261
00262
00263
00264
00265
00266
00267
00268
00269
00270
00271
00272
00273
00274
00275
00276
00277
00278
00279
00280
00281
00282
00283
00284
00285
00286
00287
00288
00289
00290
00291
00292
00293
00294 void G4BSplineCurve::InitBounded()
00295 {
00296
00297 G4int pointCount = controlPointsList->size();
00298 bBox.Init( (*controlPointsList)[0] );
00299 for (G4int i=1; i<pointCount; i++)
00300 {
00301 bBox.Extend( (*controlPointsList)[i] );
00302 }
00303 }
00304
00305
00306
00307
00308
00309
00310
00311
00312
00313
00314
00315
00316
00317
00318
00319
00320
00321
00322
00323
00324
00325
00326
00327
00328
00329
00330
00331
00332
00333
00334
00335 G4bool G4BSplineCurve::Tangent(G4CurvePoint&, G4Vector3D&)
00336 {
00337 G4Exception("G4BSplineCurve::Tangent()", "GeomSolids0001",
00338 FatalException, "Sorry, not implemented !");
00339 return false;
00340 }
00341