Skip to content

Commit 6deb521

Browse files
authored
Merge pull request #393 from sbriseid/surf_vol_api
Surf vol api
2 parents c6ce2b9 + 1c34614 commit 6deb521

2 files changed

Lines changed: 79 additions & 7 deletions

File tree

gotools-core/include/GoTools/geometry/SplineSurface.h

Lines changed: 67 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -760,6 +760,16 @@ class GO_API SplineSurface : public ParamSurface
760760
const BsplineBasis& basis(int i) const
761761
{ return (i==0) ? basis_u_ : basis_v_; }
762762

763+
764+
/// Query the number of control points along the specified parameter direction
765+
/// \param pardir specify whether to return the number of coefs for the first
766+
/// parameter (0) or for the second parameter (1).
767+
/// \return the number of control points along the specified parameter direction
768+
int numCoefs(int pardir) const
769+
{
770+
return (pardir == 0) ? basis_u_.numCoefs() : basis_v_.numCoefs();
771+
}
772+
763773
/// Query the number of control points along the first parameter direction
764774
/// \return the number of control points along the first parameter direction
765775
int numCoefs_u() const
@@ -771,17 +781,28 @@ class GO_API SplineSurface : public ParamSurface
771781
{ return basis_v_.numCoefs(); }
772782

773783
/// Query the number of elements in the SplineSurface
784+
/// \return the number of 2D elements in the surface
774785
int numElem() const
775786
{
776787
return basis_u_.numElem()*basis_v_.numElem();
777788
}
778789

779790
/// Query the number of elements in one parameter direction of
780791
/// the SplineSurface
792+
/// \param pardir specify whether to return the order for the first
793+
/// parameter (0) or for the second parameter (1).
781794
int numElem(int pardir) const
782795
{
783-
return (pardir == 0) ? basis_u_.numElem() :
784-
basis_v_.numElem();
796+
return (pardir == 0) ? basis_u_.numElem() : basis_v_.numElem();
797+
}
798+
799+
/// Query the order of the BsplineBasis for the specified parameter
800+
/// \param pardir specify whether to return the order for the first
801+
/// parameter (0) or for the second parameter (1).
802+
/// \return the order of the BsplineBasis for the specified parameter direction
803+
int order(int pardir) const
804+
{
805+
return (pardir == 0) ? basis_u_.order() : basis_v_.order();
785806
}
786807

787808
/// Query the order of the BsplineBasis for the first parameter
@@ -909,6 +930,25 @@ class GO_API SplineSurface : public ParamSurface
909930
/// \param v2 new max. value of second parameter span
910931
virtual void setParameterDomain(double u1, double u2, double v1, double v2);
911932

933+
/// Insert a new knot in the knotvector of the given parameter direction
934+
/// \param pardir parameter direction in which to insert the knots
935+
/// (u=0, v=1)
936+
/// \param apar the parameter value at which a new knot will be inserted
937+
void insertKnot(int pardir, double apar)
938+
{
939+
(pardir == 0) ? insertKnot_u(apar) : insertKnot_v(apar);
940+
}
941+
942+
/// Insert new knots in the knotvector of the given parameter direction
943+
/// \param pardir parameter direction in which to insert the knots
944+
/// (u=0, v=1, w=2)
945+
/// \param new_knots a vector containing the parameter values of the
946+
/// new knots to insert.
947+
void insertKnot(int pardir, const std::vector<double>& new_knots)
948+
{
949+
(pardir == 0) ? insertKnot_u(new_knots) : insertKnot_v(new_knots);
950+
}
951+
912952
/// Insert a new knot in the knotvector of the first parameter
913953
/// \param apar the parameter value at which a new knot will be inserted
914954
void insertKnot_u(double apar);
@@ -927,6 +967,14 @@ class GO_API SplineSurface : public ParamSurface
927967
/// new knots to insert.
928968
void insertKnot_v(const std::vector<double>& new_knots);
929969

970+
/// Remove a knot from the knotvector of the given parameter direction.
971+
/// \param pardir the parameter direction (u=0, v=1)
972+
/// \param tpar the parameter value of the knot to be removed
973+
void removeKnot(int pardir, double tpar)
974+
{
975+
(pardir == 0) ? removeKnot_u(tpar) : removeKnot_v(tpar);
976+
}
977+
930978
/// Remove a knot from the knotvector of the first parameter.
931979
/// \param tpar the parameter value of the knot to be removed
932980
void removeKnot_u(double tpar);
@@ -935,6 +983,14 @@ class GO_API SplineSurface : public ParamSurface
935983
/// \param tpar the parameter value of the knot to be removed.
936984
void removeKnot_v(double tpar);
937985

986+
/// Inserts knots in the specified knot vector, such that all knots
987+
/// have multiplicity order
988+
/// \param pardir the parameter direction (u=0, v=1)
989+
void makeBernsteinKnots(int pardir)
990+
{
991+
(pardir == 0) ? makeBernsteinKnotsU() : makeBernsteinKnotsV();
992+
}
993+
938994
/// Inserts knots in the u knot vector, such that all knots
939995
/// have multiplicity order
940996
void makeBernsteinKnotsU();
@@ -946,6 +1002,15 @@ class GO_API SplineSurface : public ParamSurface
9461002
/// Ensure k-regularity of this surface in both parameter directions
9471003
void makeSurfaceKRegular();
9481004

1005+
/// Returns the number of knot intervals in the specified knot vector.
1006+
/// \param pardir parameter direction (u=0, v=1)
1007+
/// \return the number of knot intervals in the knotvector for the
1008+
/// specified parameter direction
1009+
int numberOfPatches(int pardir) const
1010+
{
1011+
return (pardir == 0) ? numberOfPatches_u() : numberOfPatches_v();
1012+
}
1013+
9491014
/// Returns the number of knot intervals in u knot vector.
9501015
/// \return the number of knot intervals in the knotvector for the first
9511016
/// parameter

trivariate/include/GoTools/trivariate/SplineVolume.h

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -476,6 +476,9 @@ class SplineVolume : public ParamVolume
476476
}
477477

478478
/// Query the number of control points along the specified parameter direction
479+
/// \param pardir specify whether to return the number of coefs for the first
480+
/// parameter (0), for the second parameter (1) or the third
481+
/// (2) parameter.
479482
/// \return the number of control points along the specified parameter direction
480483
int numCoefs(int pardir) const
481484
{
@@ -485,7 +488,7 @@ class SplineVolume : public ParamVolume
485488
}
486489

487490
/// Query the order of the BsplineBasis for the specified parameter
488-
/// \return the order of the BsplineBasis for the specified parameter
491+
/// \return the order of the BsplineBasis for the specified parameter direction
489492
int order(int pardir) const
490493
{
491494
if (pardir == 0) return basis_u_.order();
@@ -494,14 +497,18 @@ class SplineVolume : public ParamVolume
494497
}
495498

496499
/// Query the number of elements in the SplineVolume
500+
/// \return the number of 3D elements in the volume
497501
int numElem() const
498502
{
499503
return basis_u_.numElem()*basis_v_.numElem()*basis_w_.numElem();
500504
}
501505

502506
/// Query the number of elements in one parameter direction of
503507
// the SplineVolume
504-
/// pardir = 0: u-direction, pardir = 1: vdirection, pardir = 2: wdirection
508+
/// \param pardir specify whether to return the number of elements for the first
509+
/// parameter (0), for the second parameter (1) or the third
510+
/// (2) parameter.
511+
/// \return the number of elements for the specified parameter direction
505512
int numElem(int pardir) const
506513
{
507514
if (pardir == 0) return basis_u_.numElem();
@@ -628,17 +635,17 @@ class SplineVolume : public ParamVolume
628635
void insertKnot(int pardir, const std::vector<double>& new_knots);
629636

630637
/// Remove a knot from the knotvector of the given parameter direction.
631-
/// \param pardir the parameter direction (0, 1 or 2)
638+
/// \param pardir the parameter direction (u=0, v=1, w=2)
632639
/// \param tpar the parameter value of the knot to be removed
633640
void removeKnot(int pardir, double tpar);
634641

635642
/// Inserts knots in the specified knot vector, such that all knots
636643
/// have multiplicity order
637-
/// \param pardir the parameter direction (0, 1, or 2)
644+
/// \param pardir the parameter direction (u=0, v=1, w=2)
638645
void makeBernsteinKnots(int pardir);
639646

640647
/// Returns the number of knot intervals in the specified knot vector.
641-
/// \param pardir parameter direction
648+
/// \param pardir parameter direction (u=0, v=1, w=2)
642649
/// \return the number of knot intervals in the knotvector for the
643650
/// specified parameter direction
644651
int numberOfPatches(int pardir) const;

0 commit comments

Comments
 (0)