Nektar++
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
CADSystem.h
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////////////
2 //
3 // File: CADSystem.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 methods.
33 //
34 ////////////////////////////////////////////////////////////////////////////////
35 
36 #ifndef NekMeshUtils_CADSYSTEM_CADSYSTEM
37 #define NekMeshUtils_CADSYSTEM_CADSYSTEM
38 
39 #include <boost/shared_ptr.hpp>
40 
43 
45 
46 #include "CADObject.h"
47 
48 namespace Nektar
49 {
50 namespace NekMeshUtils
51 {
52 
53 //forward declorators
54 class CADVert;
55 typedef boost::shared_ptr<CADVert> CADVertSharedPtr;
56 class CADCurve;
57 typedef boost::shared_ptr<CADCurve> CADCurveSharedPtr;
58 class CADSurf;
59 typedef boost::shared_ptr<CADSurf> CADSurfSharedPtr;
60 
61 
62 
63 /**
64  * @brief Base class for CAD interface system.
65  *
66  * A class which can load and interact with CAD for Nektar++.
67  * This class contains maps to subclasses surface and curves.
68  */
69 class CADSystem
70 {
71 public:
72  friend class MemoryManager<CADSystem>;
73 
74  /**
75  * @brief struct which descibes a collection of cad edges which are a
76  * loop on the cad surface
77  */
78  struct EdgeLoop
79  {
80  std::vector<CADCurveSharedPtr> edges;
81  std::vector<CADOrientation::Orientation> edgeo;
84  };
85 
86  typedef boost::shared_ptr<EdgeLoop> EdgeLoopSharedPtr;
87 
88  /**
89  * @brief Default constructor.
90  */
91  CADSystem(std::string name) : m_name(name)
92  {
93  m_2d = false;
94  }
95 
97  {
98  }
99 
100  /**
101  * @brief Return the name of the CAD system.
102  */
103  std::string GetName()
104  {
105  return m_name;
106  }
107 
108  void Set2D()
109  {
110  m_2d = true;
111  }
112 
113  bool Is2D()
114  {
115  return m_2d;
116  }
117 
118  void SetNACA(std::string i)
119  {
120  m_naca = i;
121  }
122 
123  /**
124  * @brief Initialises CAD and makes surface, curve and vertex maps.
125  *
126  * @return true if completed successfully
127  */
128  virtual bool LoadCAD() = 0;
129 
130  /**
131  * @brief Reports basic properties to screen.
132  */
133  void Report()
134  {
135  std::cout << std::endl << "CAD report:" << std::endl;
136  std::cout << "\tCAD has: " << m_curves.size() << " curves." << std::endl;
137  std::cout << "\tCAD has: " << m_surfs.size() << " surfaces." << std::endl;
138  }
139 
140  /**
141  * @brief Returns bounding box of the domain.
142  *
143  * Gets the bounding box of the domain by considering the start and end
144  * points of each curve in the geometry.
145  *
146  * @return Array with 6 entries: xmin, xmax, ymin, ymax, zmin and zmax.
147  */
149 
150  /**
151  * @brief Get the number of surfaces.
152  */
154  {
155  return m_surfs.size();
156  }
157 
158  /**
159  * @brief Get the number of curves.
160  */
162  {
163  return m_curves.size();
164  }
165 
166  /**
167  * @brief Gets a curve from the map.
168  */
169  CADCurveSharedPtr GetCurve(int i)
170  {
172  ASSERTL0(search != m_curves.end(), "curve does not exist");
173 
174  return search->second;
175  }
176 
177  /**
178  * @brief Gets a surface from the map.
179  */
180  CADSurfSharedPtr GetSurf(int i)
181  {
183  ASSERTL0(search != m_surfs.end(), "surface does not exist");
184 
185  return search->second;
186  }
187 
188  /**
189  * @brief Gets map of all vertices
190  */
191  std::map<int, CADVertSharedPtr> GetVerts()
192  {
193  return m_verts;
194  }
195 
196  /**
197  * @brief Gets number of vertices
198  */
200  {
201  return m_verts.size();
202  }
203 
204 protected:
205  /// Name of cad file
206  std::string m_name;
207  /// Map of curves
208  std::map<int, CADCurveSharedPtr> m_curves;
209  /// Map of surfaces
210  std::map<int, CADSurfSharedPtr> m_surfs;
211  /// Map of vertices
212  std::map<int, CADVertSharedPtr> m_verts;
213 
214  bool m_2d;
215  std::string m_naca;
216 };
217 
218 typedef boost::shared_ptr<CADSystem> CADSystemSharedPtr;
221 
223 
224 }
225 }
226 
227 #endif
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:198
LibUtilities::NekFactory< std::string, CADSystem, std::string > EngineFactory
Definition: CADSystem.h:220
base class for CAD curves.
Definition: CADCurve.h:52
int GetNumVerts()
Gets number of vertices.
Definition: CADSystem.h:199
int GetNumCurve()
Get the number of curves.
Definition: CADSystem.h:161
General purpose memory allocation routines with the ability to allocate from thread specific memory p...
Base class for CAD interface system.
Definition: CADSystem.h:69
std::map< int, CADVertSharedPtr > GetVerts()
Gets map of all vertices.
Definition: CADSystem.h:191
int GetNumSurf()
Get the number of surfaces.
Definition: CADSystem.h:153
std::vector< CADCurveSharedPtr > edges
Definition: CADSystem.h:80
std::string m_name
Name of cad file.
Definition: CADSystem.h:206
std::map< int, CADCurveSharedPtr > m_curves
Map of curves.
Definition: CADSystem.h:208
void Report()
Reports basic properties to screen.
Definition: CADSystem.h:133
std::map< int, CADVertSharedPtr > m_verts
Map of vertices.
Definition: CADSystem.h:212
CADSystem(std::string name)
Default constructor.
Definition: CADSystem.h:91
virtual Array< OneD, NekDouble > GetBoundingBox()=0
Returns bounding box of the domain.
base class for a cad surface
Definition: CADSurf.h:55
double NekDouble
virtual bool LoadCAD()=0
Initialises CAD and makes surface, curve and vertex maps.
std::vector< CADOrientation::Orientation > edgeo
Definition: CADSystem.h:81
CADCurveSharedPtr GetCurve(int i)
Gets a curve from the map.
Definition: CADSystem.h:169
base class for CAD verticies.
Definition: CADVert.h:56
boost::shared_ptr< CADSurf > CADSurfSharedPtr
Definition: CADSurf.h:172
StandardMatrixTag boost::call_traits< LhsDataType >::const_reference rhs typedef NekMatrix< LhsDataType, StandardMatrixTag >::iterator iterator
EngineFactory & GetEngineFactory()
Definition: CADSystem.cpp:48
boost::shared_ptr< CADSystem > CADSystemSharedPtr
Definition: CADSystem.h:218
void SetNACA(std::string i)
Definition: CADSystem.h:118
std::map< int, CADSurfSharedPtr > m_surfs
Map of surfaces.
Definition: CADSystem.h:210
Array< OneD, NekDouble > center
Definition: CADSystem.h:82
struct which descibes a collection of cad edges which are a loop on the cad surface ...
Definition: CADSystem.h:78
std::string GetName()
Return the name of the CAD system.
Definition: CADSystem.h:103
boost::shared_ptr< EdgeLoop > EdgeLoopSharedPtr
Definition: CADSystem.h:86
boost::shared_ptr< CADVert > CADVertSharedPtr
Definition: CADSystem.h:54
CADSurfSharedPtr GetSurf(int i)
Gets a surface from the map.
Definition: CADSystem.h:180
boost::shared_ptr< CADCurve > CADCurveSharedPtr
Definition: CADCurve.h:194
Provides a generic Factory class.
Definition: NekFactory.hpp:116