Nektar++
CADSurf.h
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////////////
2 //
3 // File: CADSurf.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 surface.
32 //
33 ////////////////////////////////////////////////////////////////////////////////
34 
35 #ifndef NekMeshUtils_CADSYSTEM_CADSURF
36 #define NekMeshUtils_CADSYSTEM_CADSURF
37 
40 
42 
43 namespace Nektar
44 {
45 namespace NekMeshUtils
46 {
47 
48 class CADCurve;
49 typedef std::shared_ptr<CADCurve> CADCurveSharedPtr;
50 class CADSurf;
51 typedef std::shared_ptr<CADSurf> CADSurfSharedPtr;
52 
53 /**
54  * @brief struct which descibes a collection of cad edges which are a
55  * loop on the cad surface
56  */
57 struct EdgeLoop
58 {
59  std::vector<CADCurveSharedPtr> edges;
60  std::vector<CADOrientation::Orientation> edgeo;
63 };
64 
65 typedef std::shared_ptr<EdgeLoop> EdgeLoopSharedPtr;
66 
67 /**
68  * @brief base class for a cad surface
69  */
70 
71 class CADSurf : public CADObject
72 {
73 public:
74  friend class MemoryManager<CADSurf>;
75 
76  /**
77  * @brief Default constructor.
78  */
80  {
81  m_type = CADType::eSurf;
82  m_orientation = CADOrientation::eForwards;
83  }
84 
85  virtual ~CADSurf()
86  {
87  }
88 
89  /**
90  * @brief Static function which orientates the edge loop on a surface
91  */
92  static void OrientateEdges(CADSurfSharedPtr surf,
93  std::vector<EdgeLoopSharedPtr> &ein);
94 
95  /**
96  * @brief Get the loop structures which bound the cad surface
97  */
98  std::vector<EdgeLoopSharedPtr> GetEdges()
99  {
100  return m_edges;
101  }
102 
103  /**
104  * @brief Set the edge loop
105  */
106  void SetEdges(std::vector<EdgeLoopSharedPtr> ein)
107  {
108  m_edges = ein;
109  }
110 
111  /**
112  * @brief Get the limits of the parametric space for the surface.
113  *
114  * @return Array of 4 entries with parametric umin,umax,vmin,vmax.
115  */
116  virtual Array<OneD, NekDouble> GetBounds() = 0;
117 
118  /**
119  * @brief Get the limits of the parametric space for the surface.
120  */
121  virtual void GetBounds(NekDouble &umin, NekDouble &umax, NekDouble &vmin,
122  NekDouble &vmax) = 0;
123 
124  /**
125  * @brief Get the normal vector at parametric point u,v.
126  *
127  * @param uv Array of u and v parametric coords.
128  * @return Array of xyz components of normal vector.
129  */
131 
132  /**
133  * @brief Get the set of first derivatives at parametric point u,v
134  *
135  * @param uv Array of u and v parametric coords.
136  * @return Array of xyz copmonents of first derivatives.
137  */
139 
140  /**
141  * @brief Get the set of second derivatives at parametric point u,v
142  *
143  * @param uv array of u and v parametric coords
144  * @return array of xyz copmonents of second derivatives
145  */
147 
148  /**
149  * @brief Get the x,y,z at parametric point u,v.
150  *
151  * @param uv Array of u and v parametric coords.
152  * @return Array of x,y,z location.
153  */
155 
156  /**
157  * @brief Get the x,y,z at parametric point u,v.
158  *
159  * @param uv Array of u and v parametric coords.
160  */
161  virtual void P(Array<OneD, NekDouble> uv, NekDouble &x, NekDouble &y,
162  NekDouble &z) = 0;
163 
164  /**
165  * @brief Performs a reverse look up to find u,v and x,y,z.
166  * if xyz is off the surface it will return the closest point
167  *
168  * @param p Array of xyz location
169  * @return The parametric location of xyz on this surface
170  */
172  NekDouble &dist) = 0;
173 
174  /**
175  * @brief overload function of locuv ommiting the dist parameter
176  * in this case if the projection is greater than a certain distance
177  * it will produce a warning. To do large distance projection use the other
178  * locuv method
179  */
181 
182  /**
183  * @brief Returns the bounding box of the surface
184  */
185  virtual Array<OneD, NekDouble> BoundingBox() = 0;
186 
187  /**
188  * @brief returns curvature at point uv
189  */
190  virtual NekDouble Curvature(Array<OneD, NekDouble> uv) = 0;
191 
192  /**
193  * @brief Is the surface defined by a planar surface (i.e not nurbs and is
194  * flat)
195  */
196  virtual bool IsPlanar() = 0;
197 
198  /**
199  * @brief query reversed normal
200  */
202  {
203  return m_orientation;
204  }
205 
206 protected:
207  /// List of bounding edges in loops with orientation.
208  std::vector<EdgeLoopSharedPtr> m_edges;
209 
210  /// Function which tests the the value of uv used is within the surface
211  virtual void Test(Array<OneD, NekDouble> uv) = 0;
212 };
213 
214 typedef std::shared_ptr<CADSurf> CADSurfSharedPtr;
215 
217 
218 CADSurfFactory &GetCADSurfFactory();
219 } // namespace NekMeshUtils
220 } // namespace Nektar
221 
222 #endif
std::shared_ptr< CADSurf > CADSurfSharedPtr
Definition: CADCurve.h:51
Array< OneD, NekDouble > center
Definition: CADSurf.h:61
std::shared_ptr< EdgeLoop > EdgeLoopSharedPtr
Definition: CADSurf.h:65
General purpose memory allocation routines with the ability to allocate from thread specific memory p...
CADOrientation::Orientation Orientation()
query reversed normal
Definition: CADSurf.h:201
std::vector< EdgeLoopSharedPtr > m_edges
List of bounding edges in loops with orientation.
Definition: CADSurf.h:208
struct which descibes a collection of cad edges which are a loop on the cad surface ...
Definition: CADSurf.h:57
std::vector< CADOrientation::Orientation > edgeo
Definition: CADSurf.h:60
std::vector< CADCurveSharedPtr > edges
Definition: CADSurf.h:59
void SetEdges(std::vector< EdgeLoopSharedPtr > ein)
Set the edge loop.
Definition: CADSurf.h:106
CADSurfFactory & GetCADSurfFactory()
Definition: CADSystem.cpp:65
void P(NekDouble t, NekDouble &x, NekDouble &y, NekDouble &z)
std::shared_ptr< CADCurve > CADCurveSharedPtr
Definition: CADCurve.h:219
base class for a cad surface
Definition: CADSurf.h:71
double NekDouble
CADSurf()
Default constructor.
Definition: CADSurf.h:79
std::vector< EdgeLoopSharedPtr > GetEdges()
Get the loop structures which bound the cad surface.
Definition: CADSurf.h:98
LibUtilities::NekFactory< std::string, CADSurf > CADSurfFactory
Definition: CADSurf.h:216
Provides a generic Factory class.
Definition: NekFactory.hpp:103