Nektar++
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
CADCurve.h
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////////////
2 //
3 // File: CADCurve.h
4 //
5 // For more information, please see: http://www.nektar.info/
6 //
7 // The MIT License
8 //
9 // Copyright (c) 2006 Division of Applied Mathematics, Brown University (USA),
10 // Department of Aeronautics, Imperial College London (UK), and Scientific
11 // Computing and Imaging Institute, University of Utah (USA).
12 //
13 // License for the specific language governing rights and limitations under
14 // Permission is hereby granted, free of charge, to any person obtaining a
15 // copy of this software and associated documentation files (the "Software"),
16 // to deal in the Software without restriction, including without limitation
17 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
18 // and/or sell copies of the Software, and to permit persons to whom the
19 // Software is furnished to do so, subject to the following conditions:
20 //
21 // The above copyright notice and this permission notice shall be included
22 // in all copies or substantial portions of the Software.
23 //
24 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
25 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
26 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
27 // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
28 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
29 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
30 // DEALINGS IN THE SOFTWARE.
31 //
32 // Description: CAD object curve.
33 //
34 ////////////////////////////////////////////////////////////////////////////////
35 
36 #ifndef NEKMESHUTILS_CADSYSTEM_CADCURVE
37 #define NEKMESHUTILS_CADSYSTEM_CADCURVE
38 
42 
43 namespace Nektar
44 {
45 namespace NekMeshUtils
46 {
47 
48 /**
49  * @brief base class for CAD curves.
50  *
51  */
52 class CADCurve : public CADObject
53 {
54 public:
55  friend class MemoryManager<CADCurve>;
56 
57  /**
58  * @brief Default constructor.
59  */
61  {
63  }
64 
66  {
67  }
68 
69  /**
70  * @brief Returns the minimum and maximum parametric coords t of the curve.
71  *
72  * @return Array of two entries, min and max parametric coordinate.
73  */
74  virtual Array<OneD, NekDouble> GetBounds() = 0;
75 
76  /**
77  * @brief Calculates the arclength between the two paremetric points \p ti
78  * and \p tf. \p ti must be less than \p tf.
79  *
80  * @param ti First parametric coordinate.
81  * @param tf Second parametric coordinate.
82  * @return Arc length between \p ti and \p tf.
83  */
84  virtual NekDouble Length(NekDouble ti, NekDouble tf) = 0;
85 
86  /**
87  * @brief Gets the location (x,y,z) in an array out of the curve at
88  * point \p t.
89  *
90  * @param t Parametric coordinate
91  * @return Array of x,y,z
92  */
93  virtual Array<OneD, NekDouble> P(NekDouble t) = 0;
94 
95  /**
96  * @brief Gets the second derivatives at t
97  */
98  virtual Array<OneD, NekDouble> D2(NekDouble t) = 0;
99 
100  virtual NekDouble Curvature(NekDouble t) = 0;
101 
102  /**
103  * @brief Calculates the parametric coordinate and arclength location
104  * defined by \p s.
105  *
106  * @param s Arclength location.
107  * @return Calculated parametric coordinate.
108  *
109  * @todo This really needs improving for accuracy.
110  */
111  virtual NekDouble tAtArcLength(NekDouble s) = 0;
112 
113  /**
114  * @brief Gets the start and end of the curve.
115  *
116  * @return Array with 6 entries of endpoints x1,y1,z1,x2,y2,z2.
117  */
118  virtual Array<OneD, NekDouble> GetMinMax() = 0;
119 
120  /**
121  * @brief set the ids of the surfaces either side of the curve
122  */
123  void SetAdjSurf(std::pair<CADSurfSharedPtr, CADOrientation::Orientation> i)
124  {
125  m_adjSurfs.push_back(i);
126  }
127 
128  /*
129  * @brief returns the ids of neigbouring surfaces
130  */
131  std::vector<std::pair<CADSurfSharedPtr, CADOrientation::Orientation> > GetAdjSurf()
132  {
133  return m_adjSurfs;
134  }
135 
136  /*
137  * @brief returns lenght of the curve
138  */
140  {
141  return m_length;
142  }
143 
144  /*
145  * @brief assign ids of end vertices in main cad
146  */
147  void SetVert(std::vector<CADVertSharedPtr> &falVert)
148  {
149  m_mainVerts = falVert;
150  }
151 
152  /*
153  * @brief get the vertices that are the ends of the curve,
154  * which are in the main cad list
155  */
156  std::vector<CADVertSharedPtr> GetVertex()
157  {
158  return m_mainVerts;
159  }
160 
161  /*
162  * @brief locates a point in the parametric space
163  */
164  virtual NekDouble loct(Array<OneD, NekDouble> xyz) = 0;
165 
167  {
168  for(int i = 0; i < m_adjSurfs.size(); i++)
169  {
170  if(m_adjSurfs[i].first->GetId() == surf)
171  {
172  return m_adjSurfs[i].second;
173  }
174  }
175 
176  ASSERTL0(false,"surf not in adjecency list");
178  }
179 
180  virtual Array<OneD, NekDouble> NormalWRT(NekDouble t, int surf)=0;
181  virtual Array<OneD, NekDouble> N(NekDouble t)=0;
182 
183 
184 protected:
185 
186  /// Length of edge
188  /// List of surfaces which this curve belongs to.
189  std::vector<std::pair<CADSurfSharedPtr, CADOrientation::Orientation> > m_adjSurfs;
190  /// list of end vertices
191  std::vector<CADVertSharedPtr> m_mainVerts;
192 };
193 
194 typedef boost::shared_ptr<CADCurve> CADCurveSharedPtr;
195 
197 
198 CADCurveFactory& GetCADCurveFactory();
199 
200 }
201 }
202 
203 #endif
virtual Array< OneD, NekDouble > NormalWRT(NekDouble t, int surf)=0
virtual NekDouble tAtArcLength(NekDouble s)=0
Calculates the parametric coordinate and arclength location defined by s.
CADCurveFactory & GetCADCurveFactory()
Definition: CADSystem.cpp:64
virtual Array< OneD, NekDouble > D2(NekDouble t)=0
Gets the second derivatives at t.
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:198
base class for CAD curves.
Definition: CADCurve.h:52
CADType::cadType m_type
type of the cad object
Definition: CADObject.h:107
std::vector< std::pair< CADSurfSharedPtr, CADOrientation::Orientation > > GetAdjSurf()
Definition: CADCurve.h:131
General purpose memory allocation routines with the ability to allocate from thread specific memory p...
virtual NekDouble loct(Array< OneD, NekDouble > xyz)=0
virtual Array< OneD, NekDouble > GetBounds()=0
Returns the minimum and maximum parametric coords t of the curve.
virtual NekDouble Curvature(NekDouble t)=0
virtual Array< OneD, NekDouble > N(NekDouble t)=0
std::vector< CADVertSharedPtr > m_mainVerts
list of end vertices
Definition: CADCurve.h:191
void SetVert(std::vector< CADVertSharedPtr > &falVert)
Definition: CADCurve.h:147
virtual NekDouble Length(NekDouble ti, NekDouble tf)=0
Calculates the arclength between the two paremetric points ti and tf. ti must be less than tf...
double NekDouble
NekDouble m_length
Length of edge.
Definition: CADCurve.h:187
CADOrientation::Orientation GetOrienationWRT(int surf)
Definition: CADCurve.h:166
std::vector< std::pair< CADSurfSharedPtr, CADOrientation::Orientation > > m_adjSurfs
List of surfaces which this curve belongs to.
Definition: CADCurve.h:189
virtual Array< OneD, NekDouble > P(NekDouble t)=0
Gets the location (x,y,z) in an array out of the curve at point t.
LibUtilities::NekFactory< std::string, CADCurve > CADCurveFactory
Definition: CADCurve.h:196
std::vector< CADVertSharedPtr > GetVertex()
Definition: CADCurve.h:156
void SetAdjSurf(std::pair< CADSurfSharedPtr, CADOrientation::Orientation > i)
set the ids of the surfaces either side of the curve
Definition: CADCurve.h:123
CADCurve()
Default constructor.
Definition: CADCurve.h:60
virtual Array< OneD, NekDouble > GetMinMax()=0
Gets the start and end of the curve.
boost::shared_ptr< CADCurve > CADCurveSharedPtr
Definition: CADCurve.h:194
Provides a generic Factory class.
Definition: NekFactory.hpp:116