/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2007-2019 PCOpt/NTUA
Copyright (C) 2013-2019 FOSS GP
Copyright (C) 2019 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see .
\*---------------------------------------------------------------------------*/
#include "NURBSbasis.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
defineTypeNameAndDebug(NURBSbasis, 1);
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
void NURBSbasis::computeKnots()
{
// Sanity check
if (basisDegree_ >(nCPs_ - 1))
{
FatalErrorInFunction
<< "B - splines basis degree can be at most equal to the "
<< "number of control points minus 1"
<< exit(FatalError);
}
// First zero knots
for (label ik = 0; ik < basisDegree_ + 1; ik++)
{
knots_ = scalar(0);
}
// Intermediate knots
label firstCPIndex(basisDegree_ + 1);
label lastCPIndex(knots_.size() - basisDegree_ - 1);
label size(knots_.size() - 2*basisDegree_ - 2);
for (label ik = 0; ik < size; ik++)
{
knots_[ik + firstCPIndex] = scalar(ik + 1)/scalar(size + 1);
}
// Last unity knots
for (label ik = 0; ik < basisDegree_ + 1; ik++)
{
knots_[ik + lastCPIndex] = scalar(1);
}
DebugInfo
<< "Using knots " << knots_ << endl;
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
NURBSbasis::NURBSbasis
(
const label nCPs,
const label degree,
const scalarField& knots
)
:
nCPs_(nCPs),
basisDegree_(degree),
knots_(knots)
{}
NURBSbasis::NURBSbasis
(
const label nCPs,
const label degree
)
:
nCPs_(nCPs),
basisDegree_(degree),
knots_((nCPs_ + basisDegree_ + 1), Zero)
{
computeKnots();
}
NURBSbasis::NURBSbasis
(
const dictionary& dict
)
:
nCPs_(dict.get