Nektar++
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 // Permission is hereby granted, free of charge, to any person obtaining a
14 // copy of this software and associated documentation files (the "Software"),
15 // to deal in the Software without restriction, including without limitation
16 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
17 // and/or sell copies of the Software, and to permit persons to whom the
18 // Software is furnished to do so, subject to the following conditions:
19 //
20 // The above copyright notice and this permission notice shall be included
21 // in all copies or substantial portions of the Software.
22 //
23 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
24 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
25 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
26 // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
27 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
28 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
29 // DEALINGS IN THE SOFTWARE.
30 //
31 // Description: CAD object curve.
32 //
33 ////////////////////////////////////////////////////////////////////////////////
34 
35 #ifndef NEKMESHUTILS_CADSYSTEM_CADCURVE
36 #define NEKMESHUTILS_CADSYSTEM_CADCURVE
37 
40 
42 
43 namespace Nektar
44 {
45 namespace NekMeshUtils
46 {
47 
48 // forward declarations
49 class CADVert;
50 typedef std::shared_ptr<CADVert> CADVertSharedPtr;
51 class CADSurf;
52 typedef std::shared_ptr<CADSurf> CADSurfSharedPtr;
53 
54 /**
55  * @brief base class for CAD curves.
56  *
57  */
58 class CADCurve : public CADObject
59 {
60 public:
61  friend class MemoryManager<CADCurve>;
62 
63  /**
64  * @brief Default constructor.
65  */
67  {
69  }
70 
71  virtual ~CADCurve()
72  {
73  }
74 
75  /**
76  * @brief Returns the minimum and maximum parametric coords t of the curve.
77  *
78  * @return Array of two entries, min and max parametric coordinate.
79  */
80  virtual Array<OneD, NekDouble> GetBounds() = 0;
81 
82  /**
83  * @brief Returns the minimum and maximum parametric coords t of the curve.
84  */
85  virtual void GetBounds(NekDouble &tmin, NekDouble &tmax) = 0;
86 
87  /**
88  * @brief Calculates the arclength between the two paremetric points \p ti
89  * and \p tf. \p ti must be less than \p tf.
90  *
91  * @param ti First parametric coordinate.
92  * @param tf Second parametric coordinate.
93  * @return Arc length between \p ti and \p tf.
94  */
95  virtual NekDouble Length(NekDouble ti, NekDouble tf) = 0;
96 
97  /**
98  * @brief Gets the location (x,y,z) in an array out of the curve at
99  * point \p t.
100  *
101  * @param t Parametric coordinate
102  * @return Array of x,y,z
103  */
104  virtual Array<OneD, NekDouble> P(NekDouble t) = 0;
105 
106  /**
107  * @brief Gets the location (x,y,z) in an array out of the curve at
108  * point \p t.
109  *
110  * @param t Parametric coordinate
111  */
112  virtual void P(NekDouble t, NekDouble &x, NekDouble &y, NekDouble &z) = 0;
113 
114  /**
115  * @brief Gets the second derivatives at t
116  */
117  virtual Array<OneD, NekDouble> D2(NekDouble t) = 0;
118 
119  /**
120  * @brief Calculates the radius of curvature of the curve at point t
121  */
122  virtual NekDouble Curvature(NekDouble t) = 0;
123 
124  /**
125  * @brief Calculates the parametric coordinate and arclength location
126  * defined by \p s.
127  *
128  * @param s Arclength location.
129  * @return Calculated parametric coordinate.
130  *
131  * @todo This really needs improving for accuracy.
132  */
133  virtual NekDouble tAtArcLength(NekDouble s) = 0;
134 
135  /**
136  * @brief Gets the start and end of the curve.
137  *
138  * @return Array with 6 entries of endpoints x1,y1,z1,x2,y2,z2.
139  */
140  virtual Array<OneD, NekDouble> GetMinMax() = 0;
141 
142  /**
143  * @brief set the ids of the surfaces either side of the curve
144  */
145  void SetAdjSurf(std::pair<CADSurfSharedPtr, CADOrientation::Orientation> i)
146  {
147  m_adjSurfs.push_back(i);
148  }
149 
150  /*
151  * @brief returns the ids of surfaces bound by this curve as well as their
152  * Orientation with respect to the loop of curves
153  */
154  std::vector<std::pair<CADSurfSharedPtr, CADOrientation::Orientation>>
156  {
157  return m_adjSurfs;
158  }
159 
160  /*
161  * @brief returns lenght of the curve
162  */
164  {
165  return m_length;
166  }
167 
168  /*
169  * @brief assign ids of end vertices in main cad
170  */
171  void SetVert(std::vector<CADVertSharedPtr> &falVert)
172  {
173  m_mainVerts = falVert;
174  }
175 
176  /*
177  * @brief get the vertices that are the ends of the curve,
178  * which are in the main cad list
179  */
180  std::vector<CADVertSharedPtr> GetVertex()
181  {
182  return m_mainVerts;
183  }
184 
185  /*
186  * @brief locates a point in the parametric space. returns the
187  * distance to the point and passes t by reference and updates it
188  */
189  virtual NekDouble loct(Array<OneD, NekDouble> xyz, NekDouble &t) = 0;
190 
191  /**
192  * @brief Returns the orientation of the curve with respect to a given
193  * surface by id surf
194  */
196 
197  /**
198  * @brief Returns the normal to the curve which is orientate with respect
199  * to the surface surf
200  */
202 
203  /**
204  * @brief Returns the normal to a curve, it will always point in the concave
205  * direction
206  */
207  virtual Array<OneD, NekDouble> N(NekDouble t) = 0;
208 
209 protected:
210  /// Length of edge
212  /// List of surfaces which this curve belongs to.
213  std::vector<std::pair<CADSurfSharedPtr, CADOrientation::Orientation>>
215  /// list of end vertices
216  std::vector<CADVertSharedPtr> m_mainVerts;
217 };
218 
219 typedef std::shared_ptr<CADCurve> CADCurveSharedPtr;
220 
222 
223 CADCurveFactory &GetCADCurveFactory();
224 }
225 }
226 
227 #endif
virtual NekDouble tAtArcLength(NekDouble s)=0
Calculates the parametric coordinate and arclength location defined by s.
CADCurveFactory & GetCADCurveFactory()
Definition: CADSystem.cpp:59
virtual Array< OneD, NekDouble > D2(NekDouble t)=0
Gets the second derivatives at t.
std::shared_ptr< CADSurf > CADSurfSharedPtr
Definition: CADCurve.h:51
base class for CAD curves.
Definition: CADCurve.h:58
CADType::cadType m_type
type of the cad object
Definition: CADObject.h:126
std::vector< std::pair< CADSurfSharedPtr, CADOrientation::Orientation > > GetAdjSurf()
Definition: CADCurve.h:155
General purpose memory allocation routines with the ability to allocate from thread specific memory p...
std::shared_ptr< CADVert > CADVertSharedPtr
Definition: CADCurve.h:49
Array< OneD, NekDouble > NormalWRT(NekDouble t, int surf)
Returns the normal to the curve which is orientate with respect to the surface surf.
Definition: CADCurve.cpp:47
virtual Array< OneD, NekDouble > GetBounds()=0
Returns the minimum and maximum parametric coords t of the curve.
virtual NekDouble Curvature(NekDouble t)=0
Calculates the radius of curvature of the curve at point t.
virtual Array< OneD, NekDouble > N(NekDouble t)=0
Returns the normal to a curve, it will always point in the concave direction.
std::vector< CADVertSharedPtr > m_mainVerts
list of end vertices
Definition: CADCurve.h:216
void SetVert(std::vector< CADVertSharedPtr > &falVert)
Definition: CADCurve.h:171
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...
std::shared_ptr< CADCurve > CADCurveSharedPtr
Definition: CADCurve.h:219
base class for a cad surface
Definition: CADSurf.h:71
double NekDouble
base class for CAD verticies.
Definition: CADVert.h:60
NekDouble m_length
Length of edge.
Definition: CADCurve.h:211
CADOrientation::Orientation GetOrienationWRT(int surf)
Returns the orientation of the curve with respect to a given surface by id surf.
Definition: CADCurve.cpp:87
std::vector< std::pair< CADSurfSharedPtr, CADOrientation::Orientation > > m_adjSurfs
List of surfaces which this curve belongs to.
Definition: CADCurve.h:214
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:221
std::vector< CADVertSharedPtr > GetVertex()
Definition: CADCurve.h:180
void SetAdjSurf(std::pair< CADSurfSharedPtr, CADOrientation::Orientation > i)
set the ids of the surfaces either side of the curve
Definition: CADCurve.h:145
CADCurve()
Default constructor.
Definition: CADCurve.h:66
virtual NekDouble loct(Array< OneD, NekDouble > xyz, NekDouble &t)=0
virtual Array< OneD, NekDouble > GetMinMax()=0
Gets the start and end of the curve.
Provides a generic Factory class.
Definition: NekFactory.hpp:103