Nektar++
Loading...
Searching...
No Matches
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 NEKTAR_SPATIALDOMAINS_CADSYSTEM_CADCURVE
36#define NEKTAR_SPATIALDOMAINS_CADSYSTEM_CADCURVE
37
38#include <array>
39
41
43
45{
46
47// forward declarations
48class CADVert;
49typedef std::shared_ptr<CADVert> CADVertSharedPtr;
50class CADSurf;
51typedef std::shared_ptr<CADSurf> CADSurfSharedPtr;
52
53/**
54 * @brief base class for CAD curves.
55 *
56 */
57class CADCurve : public CADObject
58{
59public:
60 friend class MemoryManager<CADCurve>;
61
62 /**
63 * @brief Default constructor.
64 */
66 {
68 }
69
70 ~CADCurve() override
71 {
72 }
73
74 /**
75 * @brief Returns the minimum and maximum parametric coords t of the curve.
76 *
77 * @return Array of two entries, min and max parametric coordinate.
78 */
79 SPATIAL_DOMAINS_EXPORT virtual std::array<NekDouble, 2> GetBounds() = 0;
80
81 /**
82 * @brief Returns the minimum and maximum parametric coords t of the curve.
83 */
85 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 */
96 NekDouble tf) = 0;
97
98 /**
99 * @brief Gets the location (x,y,z) in an array out of the curve at
100 * point \p t.
101 *
102 * @param t Parametric coordinate
103 * @return Array of x,y,z
104 */
105 SPATIAL_DOMAINS_EXPORT virtual std::array<NekDouble, 3> P(NekDouble t) = 0;
106
107 /**
108 * @brief Gets the location (x,y,z) in an array out of the curve at
109 * point \p t.
110 *
111 * @param t Parametric coordinate
112 */
114 NekDouble &y, NekDouble &z) = 0;
115
116 /**
117 * @brief Gets the second derivatives at t
118 */
119 SPATIAL_DOMAINS_EXPORT virtual std::array<NekDouble, 9> D2(NekDouble t) = 0;
120
121 /**
122 * @brief Calculates the radius of curvature of the curve at point t
123 */
125
126 /**
127 * @brief Calculates the parametric coordinate and arclength location
128 * defined by \p s.
129 *
130 * @param s Arclength location.
131 * @return Calculated parametric coordinate.
132 *
133 * @todo This really needs improving for accuracy.
134 */
136
137 /**
138 * @brief Gets the start and end of the curve.
139 *
140 * @return Array with 6 entries of endpoints x1,y1,z1,x2,y2,z2.
141 */
142 SPATIAL_DOMAINS_EXPORT virtual std::array<NekDouble, 6> GetMinMax() = 0;
143
144 /**
145 * @brief set the ids of the surfaces either side of the curve
146 */
147 void SetAdjSurf(std::pair<CADSurfSharedPtr, CADOrientation::Orientation> i)
148 {
149 m_adjSurfs.push_back(i);
150 }
151
152 /**
153 * @brief returns the ids of surfaces bound by this curve as well as their
154 * Orientation with respect to the loop of curves
155 */
156 std::vector<std::pair<std::weak_ptr<CADSurf>, CADOrientation::Orientation>>
158 {
159 return m_adjSurfs;
160 }
161
162 /**
163 * @brief returns lenght of the curve
164 */
166 {
167 return m_length;
168 }
169
170 /**
171 * @brief assign ids of end vertices in main cad
172 */
173 void SetVert(std::vector<CADVertSharedPtr> &falVert)
174 {
175 m_mainVerts = falVert;
176 }
177
178 /**
179 * @brief get the vertices that are the ends of the curve,
180 * which are in the main cad list
181 */
182 std::vector<CADVertSharedPtr> GetVertex()
183 {
184 return m_mainVerts;
185 }
186
187 /**
188 * @brief locates a point in the parametric space. returns the
189 * distance to the point and passes t by reference and updates it
190 */
191 SPATIAL_DOMAINS_EXPORT virtual NekDouble loct(std::array<NekDouble, 3> xyz,
192 NekDouble &t) = 0;
193
194 /**
195 * @brief locates a point in the parametric space. returns the
196 * distance to the point and passes t by reference and updates it
197 * This is in the parametric bounds of the Curve and is important for
198 * periodic surfaces (Circles)
199 */
200 SPATIAL_DOMAINS_EXPORT virtual NekDouble loct(std::array<NekDouble, 3> xyz,
201 NekDouble &t, NekDouble cf,
202 NekDouble cl) = 0;
203
204 /**
205 * @brief Locates a point @p xyz in the parametric space. returns the
206 * distance to the point.
207 */
209 std::array<NekDouble, 3> &xyz) = 0;
210
211 /**
212 * @brief Returns the orientation of the curve with respect to a given
213 * surface by id surf
214 */
216 int surf);
217
218 /**
219 * @brief Returns the normal to the curve which is orientate with respect
220 * to the surface surf
221 */
222 SPATIAL_DOMAINS_EXPORT std::array<NekDouble, 3> NormalWRT(NekDouble t,
223 int surf);
224
225 /**
226 * @brief Returns the normal to a curve, it will always point in the concave
227 * direction
228 */
229 SPATIAL_DOMAINS_EXPORT virtual std::array<NekDouble, 3> N(NekDouble t) = 0;
230
231 /**
232 * @brief Returns the bounding box of a curve enlarged by 5e-3mm * scale
233 */
234 SPATIAL_DOMAINS_EXPORT virtual std::array<NekDouble, 6> BoundingBox(
235 NekDouble scale) = 0;
236
237protected:
238 /// Length of edge
240 /// List of surfaces which this curve belongs to.
241 std::vector<std::pair<std::weak_ptr<CADSurf>, CADOrientation::Orientation>>
243 /// list of end vertices
244 std::vector<CADVertSharedPtr> m_mainVerts;
245};
246
247typedef std::shared_ptr<CADCurve> CADCurveSharedPtr;
248
250
252} // namespace Nektar::SpatialDomains
253
254#endif
#define SPATIAL_DOMAINS_EXPORT
General purpose memory allocation routines with the ability to allocate from thread specific memory p...
base class for CAD curves.
Definition CADCurve.h:58
virtual std::array< NekDouble, 6 > BoundingBox(NekDouble scale)=0
Returns the bounding box of a curve enlarged by 5e-3mm * scale.
virtual NekDouble tAtArcLength(NekDouble s)=0
Calculates the parametric coordinate and arclength location defined by s.
virtual NekDouble Curvature(NekDouble t)=0
Calculates the radius of curvature of the curve at point t.
virtual std::array< NekDouble, 3 > N(NekDouble t)=0
Returns the normal to a curve, it will always point in the concave direction.
void SetVert(std::vector< CADVertSharedPtr > &falVert)
assign ids of end vertices in main cad
Definition CADCurve.h:173
std::vector< CADVertSharedPtr > m_mainVerts
list of end vertices
Definition CADCurve.h:244
CADCurve()
Default constructor.
Definition CADCurve.h:65
NekDouble GetTotLength()
returns lenght of the curve
Definition CADCurve.h:165
std::array< NekDouble, 3 > NormalWRT(NekDouble t, int surf)
Returns the normal to the curve which is orientate with respect to the surface surf.
Definition CADCurve.cpp:44
virtual void GetBounds(NekDouble &tmin, NekDouble &tmax)=0
Returns the minimum and maximum parametric coords t of the curve.
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.
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< CADVertSharedPtr > GetVertex()
get the vertices that are the ends of the curve, which are in the main cad list
Definition CADCurve.h:182
NekDouble m_length
Length of edge.
Definition CADCurve.h:239
virtual void P(NekDouble t, NekDouble &x, NekDouble &y, NekDouble &z)=0
Gets the location (x,y,z) in an array out of the curve at point t.
virtual NekDouble GetMinDistance(std::array< NekDouble, 3 > &xyz)=0
Locates a point xyz in the parametric space. returns the distance to the point.
virtual std::array< NekDouble, 2 > GetBounds()=0
Returns the minimum and maximum parametric coords t of the curve.
std::vector< std::pair< std::weak_ptr< CADSurf >, CADOrientation::Orientation > > GetAdjSurf()
returns the ids of surfaces bound by this curve as well as their Orientation with respect to the loop...
Definition CADCurve.h:157
std::vector< std::pair< std::weak_ptr< CADSurf >, CADOrientation::Orientation > > m_adjSurfs
List of surfaces which this curve belongs to.
Definition CADCurve.h:242
virtual std::array< NekDouble, 9 > D2(NekDouble t)=0
Gets the second derivatives at t.
virtual std::array< NekDouble, 6 > GetMinMax()=0
Gets the start and end of the curve.
virtual std::array< NekDouble, 3 > P(NekDouble t)=0
Gets the location (x,y,z) in an array out of the curve at point t.
virtual NekDouble loct(std::array< NekDouble, 3 > xyz, NekDouble &t, NekDouble cf, NekDouble cl)=0
locates a point in the parametric space. returns the distance to the point and passes t by reference ...
virtual NekDouble loct(std::array< NekDouble, 3 > xyz, NekDouble &t)=0
locates a point in the parametric space. returns the distance to the point and passes t by reference ...
void SetAdjSurf(std::pair< CADSurfSharedPtr, CADOrientation::Orientation > i)
set the ids of the surfaces either side of the curve
Definition CADCurve.h:147
CADType::cadType m_type
type of the cad object
Definition CADObject.h:148
base class for a cad surface
Definition CADSurf.h:70
std::shared_ptr< CADCurve > CADCurveSharedPtr
Definition CADCurve.h:247
std::shared_ptr< CADVert > CADVertSharedPtr
Definition CADCurve.h:49
LibUtilities::NekFactory< std::string, CADCurve > CADCurveFactory
Definition CADCurve.h:249
std::shared_ptr< CADSurf > CADSurfSharedPtr
Definition CADCurve.h:51
CADCurveFactory & GetCADCurveFactory()
Definition CADSystem.cpp:54