TexGen
ReedData.cpp
Go to the documentation of this file.
1/*=============================================================================
2TexGen: Geometric textile modeller.
3Copyright (C) 2006 Martin Sherburn
4
5This program is free software; you can redistribute it and/or
6modify it under the terms of the GNU General Public License
7as published by the Free Software Foundation; either version 2
8of the License, or (at your option) any later version.
9
10This program is distributed in the hope that it will be useful,
11but WITHOUT ANY WARRANTY; without even the implied warranty of
12MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13GNU General Public License for more details.
14
15You should have received a copy of the GNU General Public License
16along with this program; if not, write to the Free Software
17Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18=============================================================================*/
19
20#include "PrecompiledHeaders.h"
21#include "ReedData.h"
22
23using namespace TexGen;
24
25CReedData::CReedData()
26{
27}
28
30{
31}
32
33double CReedData::GetClosestReedThickness(double dThickness)
34{
35 vector<double> ReedSizes(ReedThickness, ReedThickness + NUM_REED_SIZES);
36 vector<double>::iterator after = lower_bound( ReedSizes.begin(), ReedSizes.end(), dThickness );
37
38 if ( after == ReedSizes.begin() )
39 return *after;
40
41 if ( after == ReedSizes.end() )
42 return( *(after - 1 ) );
43
44 return (*after - dThickness) < ( dThickness - *(after-1) ) ? *after : *(after - 1);
45}
#define NUM_REED_SIZES
Definition: ReedData.h:26
virtual ~CReedData(void)
Definition: ReedData.cpp:29
double GetClosestReedThickness(double dThickness)
Definition: ReedData.cpp:33
Namespace containing a series of customised math operations not found in the standard c++ library.
static double ReedThickness[NUM_REED_SIZES]
Definition: ReedData.h:27