Nektar++
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 NEKTAR_LIB_UTILITIES_CADSYSTEM_CADSYSTEM_H
37 #define NEKTAR_LIB_UTILITIES_CADSYSTEM_CADSYSTEM_H
38 
39 #include <boost/shared_ptr.hpp>
43 
44 #include <Standard_Macro.hxx>
45 
49 
50 namespace Nektar {
51 namespace LibUtilities {
52 
53 /**
54  * @brief Base class for CAD interface system.
55  *
56  * A class which can load and interact with CAD for Nektar++ using OpenCascade.
57  * This class contains maps to subclasses surface and curves.
58  */
59 class CADSystem
60 {
61  public:
62  friend class MemoryManager<CADSystem>;
63 
64  /**
65  * @brief Default constructor.
66  */
67  LIB_UTILITIES_EXPORT CADSystem(const std::string &name) : m_name(name)
68  {
69  }
70 
71  LIB_UTILITIES_EXPORT std::string GetName();
75 
76  /**
77  * @brief Return number of surfaces.
78  */
80  {
81  return m_surfs.size();
82  }
83 
84  /**
85  * @brief Return number of curves.
86  */
88  {
89  return m_curves.size();
90  }
91 
92  /**
93  * @brief Gets curve type from map.
94  */
96  {
98  search = m_curves.find(i);
99  ASSERTL0(search != m_curves.end(), "curve does not exist");
100 
101  return search->second;
102  }
103 
104  /**
105  * @brief Gets suface from map.
106  */
108  {
110  search = m_surfs.find(i);
111  ASSERTL0(search != m_surfs.end(), "surface does not exist");
112 
113  return search->second;
114  }
115 
116  /**
117  * @brief Return Euler-Poincare number.
118  */
120  {
121  return m_epc;
122  }
123 
124  private:
125  /// Private function to add curve to CADSystem::m_curves.
126  void AddCurve(int i, TopoDS_Shape in);
127  /// Private function to add surface to CADSystem::m_surfs.
128  void AddSurf(int i, TopoDS_Shape in,
129  std::vector<std::vector<std::pair<int,int> > > ein);
130  /// Name of cad file to be opened, including file extension.
131  std::string m_name;
132  /// Euler-Poincare number of the CAD.
133  int m_epc;
134  /// map of curves
135  std::map<int,CADCurveSharedPtr> m_curves;
136  /// map of surfaces
137  std::map<int,CADSurfSharedPtr> m_surfs;
138 };
139 
140 typedef boost::shared_ptr<CADSystem> CADSystemSharedPtr;
141 
142 }
143 }
144 
145 #endif
CADSurfSharedPtr GetSurf(int i)
Gets suface from map.
Definition: CADSystem.h:107
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:161
int GetEPC()
Return Euler-Poincare number.
Definition: CADSystem.h:119
CADSystem(const std::string &name)
Default constructor.
Definition: CADSystem.h:67
int GetNumSurf()
Return number of surfaces.
Definition: CADSystem.h:79
std::map< int, CADSurfSharedPtr > m_surfs
map of surfaces
Definition: CADSystem.h:137
General purpose memory allocation routines with the ability to allocate from thread specific memory p...
int GetNumCurve()
Return number of curves.
Definition: CADSystem.h:87
void AddCurve(int i, TopoDS_Shape in)
Private function to add curve to CADSystem::m_curves.
Definition: CADSystem.cpp:261
void Report()
Reports basic properties to screen.
Definition: CADSystem.cpp:61
boost::shared_ptr< CADCurve > CADCurveSharedPtr
Definition: CADCurve.h:92
Base class for CAD interface system.
Definition: CADSystem.h:59
bool LoadCAD()
Initialises CAD and makes surface and curve maps.
Definition: CADSystem.cpp:111
#define LIB_UTILITIES_EXPORT
const CADCurveSharedPtr GetCurve(int i)
Gets curve type from map.
Definition: CADSystem.h:95
StandardMatrixTag boost::call_traits< LhsDataType >::const_reference rhs typedef NekMatrix< LhsDataType, StandardMatrixTag >::iterator iterator
std::map< int, CADCurveSharedPtr > m_curves
map of curves
Definition: CADSystem.h:135
int m_epc
Euler-Poincare number of the CAD.
Definition: CADSystem.h:133
std::string GetName()
Return the name of the CAD system.
Definition: CADSystem.cpp:53
boost::shared_ptr< CADSurf > CADSurfSharedPtr
Definition: CADSurf.h:109
Array< OneD, NekDouble > GetBoundingBox()
Returns bounding box of the domain.
Definition: CADSystem.cpp:77
boost::shared_ptr< CADSystem > CADSystemSharedPtr
Definition: CADSystem.h:140
std::string m_name
Name of cad file to be opened, including file extension.
Definition: CADSystem.h:131
void AddSurf(int i, TopoDS_Shape in, std::vector< std::vector< std::pair< int, int > > > ein)
Private function to add surface to CADSystem::m_surfs.
Definition: CADSystem.cpp:268