Nektar++
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator 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 namespace Nektar
47 {
48 namespace NekMeshUtils
49 {
50 
51 class CADVert;
52 typedef boost::shared_ptr<CADVert> CADVertSharedPtr;
53 class CADCurve;
54 typedef boost::shared_ptr<CADCurve> CADCurveSharedPtr;
55 class CADSurf;
56 typedef boost::shared_ptr<CADSurf> CADSurfSharedPtr;
57 struct EdgeLoop;
58 
59 /**
60  * @brief Base class for CAD interface system.
61  *
62  * A class which can load and interact with CAD for Nektar++ using OpenCascade.
63  * This class contains maps to subclasses surface and curves.
64  */
65 class CADSystem
66 {
67 public:
68  friend class MemoryManager<CADSystem>;
69 
70  /**
71  * @brief Default constructor.
72  */
73  CADSystem(const std::string &name) : m_name(name)
74  {
75  }
76 
77  /**
78  * @brief Return the name of the CAD system.
79  */
80  std::string GetName();
81 
82  /**
83  * @brief Initialises CAD and makes surface, curve and vertex maps.
84  *
85  * @return true if completed successfully
86  */
87  bool LoadCAD();
88 
89  /**
90  * @brief Reports basic properties to screen.
91  */
92  void Report();
93 
94  /**
95  * @brief Returns bounding box of the domain.
96  *
97  * Gets the bounding box of the domain by considering the start and end
98  * points of each curve in the geometry.
99  *
100  * @return Array with 6 entries: xmin, xmax, ymin, ymax, zmin and zmax.
101  */
103 
104  /**
105  * @brief Get the number of surfaces.
106  */
108  {
109  return m_surfs.size();
110  }
111 
112  /**
113  * @brief Get the number of curves.
114  */
116  {
117  return m_curves.size();
118  }
119 
120  /**
121  * @brief Gets a curve from the map.
122  */
123  CADCurveSharedPtr GetCurve(int i)
124  {
126  ASSERTL0(search != m_curves.end(), "curve does not exist");
127 
128  return search->second;
129  }
130 
131  /**
132  * @brief Gets a surface from the map.
133  */
134  CADSurfSharedPtr GetSurf(int i)
135  {
137  ASSERTL0(search != m_surfs.end(), "surface does not exist");
138 
139  return search->second;
140  }
141 
142  /**
143  * @brief Gets map of all vertices
144  */
145  std::map<int, CADVertSharedPtr> GetVerts()
146  {
147  return m_verts;
148  }
149 
150  /**
151  * @brief Gets number of vertices
152  */
154  {
155  return m_verts.size();
156  }
157 
158  /**
159  * @brief based on location in space, uses opencascade routines to
160  * determin if the point is within the domain. This routine is slow
161  * and should be used sparingly, it is smart enough to take and form
162  * of geometry
163  */
165 
166 private:
167  /// Function to add curve to CADSystem::m_verts.
168  void AddVert(int i, TopoDS_Shape in);
169  /// Function to add curve to CADSystem::m_curves.
170  void AddCurve(int i, TopoDS_Shape in, int fv, int lv);
171  /// Function to add surface to CADSystem::m_surfs.
172  void AddSurf(int i, TopoDS_Shape in, std::vector<EdgeLoop> ein);
173  /// Name of cad file to be opened, including file extension.
174  std::string m_name;
175  /// Map of curves
176  std::map<int, CADCurveSharedPtr> m_curves;
177  /// Map of surfaces
178  std::map<int, CADSurfSharedPtr> m_surfs;
179  /// Map of vertices
180  std::map<int, CADVertSharedPtr> m_verts;
181  /// OCC master object
182  TopoDS_Shape shape;
183 };
184 
185 typedef boost::shared_ptr<CADSystem> CADSystemSharedPtr;
186 }
187 }
188 
189 #endif
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:188
class for CAD curves.
Definition: CADCurve.h:61
TopoDS_Shape shape
OCC master object.
Definition: CADSystem.h:182
void AddVert(int i, TopoDS_Shape in)
Function to add curve to CADSystem::m_verts.
Definition: CADSystem.cpp:351
int GetNumVerts()
Gets number of vertices.
Definition: CADSystem.h:153
int GetNumCurve()
Get the number of curves.
Definition: CADSystem.h:115
General purpose memory allocation routines with the ability to allocate from thread specific memory p...
Base class for CAD interface system.
Definition: CADSystem.h:65
std::map< int, CADVertSharedPtr > GetVerts()
Gets map of all vertices.
Definition: CADSystem.h:145
int GetNumSurf()
Get the number of surfaces.
Definition: CADSystem.h:107
struct which descibes a collection of cad edges which for a loop on the cad surface ...
Definition: CADSurf.h:60
std::string m_name
Name of cad file to be opened, including file extension.
Definition: CADSystem.h:174
std::map< int, CADCurveSharedPtr > m_curves
Map of curves.
Definition: CADSystem.h:176
void Report()
Reports basic properties to screen.
Definition: CADSystem.cpp:57
std::map< int, CADVertSharedPtr > m_verts
Map of vertices.
Definition: CADSystem.h:180
class for handleing a cad surface
Definition: CADSurf.h:72
CADSystem(const std::string &name)
Default constructor.
Definition: CADSystem.h:73
void AddCurve(int i, TopoDS_Shape in, int fv, int lv)
Function to add curve to CADSystem::m_curves.
Definition: CADSystem.cpp:358
void AddSurf(int i, TopoDS_Shape in, std::vector< EdgeLoop > ein)
Function to add surface to CADSystem::m_surfs.
Definition: CADSystem.cpp:370
bool LoadCAD()
Initialises CAD and makes surface, curve and vertex maps.
Definition: CADSystem.cpp:93
CADCurveSharedPtr GetCurve(int i)
Gets a curve from the map.
Definition: CADSystem.h:123
class for CAD curves.
Definition: CADVert.h:59
boost::shared_ptr< CADSurf > CADSurfSharedPtr
Definition: CADSurf.h:217
StandardMatrixTag boost::call_traits< LhsDataType >::const_reference rhs typedef NekMatrix< LhsDataType, StandardMatrixTag >::iterator iterator
Array< OneD, NekDouble > GetBoundingBox()
Returns bounding box of the domain.
Definition: CADSystem.cpp:64
boost::shared_ptr< CADSystem > CADSystemSharedPtr
Definition: CADSystem.h:185
bool InsideShape(Array< OneD, NekDouble > loc)
based on location in space, uses opencascade routines to determin if the point is within the domain...
Definition: CADSystem.cpp:395
std::map< int, CADSurfSharedPtr > m_surfs
Map of surfaces.
Definition: CADSystem.h:178
std::string GetName()
Return the name of the CAD system.
Definition: CADSystem.cpp:52
boost::shared_ptr< CADVert > CADVertSharedPtr
Definition: CADSystem.h:51
CADSurfSharedPtr GetSurf(int i)
Gets a surface from the map.
Definition: CADSystem.h:134
boost::shared_ptr< CADCurve > CADCurveSharedPtr
Definition: CADCurve.h:168