TexGen
Interpolation.h
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#pragma once
21#include "SlaveNode.h"
22
23namespace TexGen
24{
25 using namespace std;
26
28
33 {
34 public:
35 CInterpolation(bool bPeriodic, bool bForceInPlaneTangent, bool bForceMasterNodeTangent);
36 CInterpolation(TiXmlElement &Element);
37 virtual ~CInterpolation(void);
38
40
44 virtual CInterpolation* Copy() const = 0;
45
47 virtual string GetType() const = 0;
48
50 static CObjectContainer<CInterpolation> CreateInterpolation(TiXmlElement &Element);
51
53 virtual void PopulateTiXmlElement(TiXmlElement &Element, OUTPUT_TYPE OutputType) const;
54
56 vector<CSlaveNode> GetSlaveNodes(const vector<CNode> &MasterNodes, int iNumPoints, bool bEquiSpaced = true) const;
57
60 virtual void Initialise(const vector<CNode> &MasterNodes) const {};
61
63
70 virtual CSlaveNode GetNode(const vector<CNode> &MasterNodes, int iIndex, double t) const = 0;
71
73
79 CSlaveNode GetNode(const vector<CNode> &MasterNodes, double t) const;
80
81 // /// Get the length of the centreline by spliting up the interpolation function with straight lines
82 // double GetLength(vector<CNode> &MasterNodes);
83
84 // Accessor methods
85 void SetPeriodic(bool bPeriodic) { m_bPeriodic = bPeriodic; }
86 void SetForceInPlaneTangent(bool bForceInPlaneTangent) { m_bForceInPlaneTangent = bForceInPlaneTangent; }
87 bool GetPeriodic() const { return m_bPeriodic; }
88 bool GetForceInPlaneTangent() const { return m_bForceInPlaneTangent; }
89
90 protected:
92 void CreateSlaveNodes(vector<CSlaveNode> &SlaveNodes, const vector<CNode> &MasterNodes, int iNumPoints) const;
93
95 bool CreateEquiSpacedSlaveNodes(vector<CSlaveNode> &SlaveNodes, const vector<CNode> &MasterNodes, int iNumPoints) const;
96
97 static void InterpolateUp(const CNode &Node1, const CNode &Node2, CSlaveNode &SlaveNode, double t);
98 static void InterpolateAngle(const CNode &Node1, const CNode &Node2, CSlaveNode &SlaveNode, double t);
99
102 void CalculateNodeCoordinateSystem(const vector<CNode> &MasterNodes, vector<XYZ> &Tangents) const;
103
105 vector<CSlaveNode> CalcSlaveNodePositions( const vector<CNode> &MasterNodes, vector<double> &LValues, vector<double> &TValues, double dL, int iNumNodes, int iNumPoints ) const;
106
108 bool m_bForceInPlaneTangent; // Forces both slave and master nodes to have in-plane tangents
109 bool m_bForceMasterNodeTangent; // Forces master nodes to have in-plane tangents
110 };
111
112}; // namespace TexGen
#define CLASS_DECLSPEC
Definition: Misc.h:35
Abstract base class for describing the yarn path interpolations.
Definition: Interpolation.h:33
virtual string GetType() const =0
Derived class should return the class name.
virtual void Initialise(const vector< CNode > &MasterNodes) const
Definition: Interpolation.h:60
virtual CInterpolation * Copy() const =0
This is a function to allow copying of derived classes correctly.
virtual CSlaveNode GetNode(const vector< CNode > &MasterNodes, int iIndex, double t) const =0
Get a node from parametric function. Initialise should be called first.
void SetPeriodic(bool bPeriodic)
Definition: Interpolation.h:85
void SetForceInPlaneTangent(bool bForceInPlaneTangent)
Definition: Interpolation.h:86
bool GetForceInPlaneTangent() const
Definition: Interpolation.h:88
bool GetPeriodic() const
Definition: Interpolation.h:87
Represents a point on the centreline of a yarn.
Definition: Node.h:28
Object container to help handle memory management issues.
A derivation of the CNode class which contains data specific to slave nodes such as sections.
Definition: SlaveNode.h:30
Namespace containing a series of customised math operations not found in the standard c++ library.
OUTPUT_TYPE
Definition: Misc.h:105