Nektar++
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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 // 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 surface.
33 //
34 ////////////////////////////////////////////////////////////////////////////////
35 
36 #ifndef NekMeshUtils_CADSYSTEM_CADSURF
37 #define NekMeshUtils_CADSYSTEM_CADSURF
38 
39 #include <boost/shared_ptr.hpp>
40 
43 
47 
48 namespace Nektar
49 {
50 namespace NekMeshUtils
51 {
52 
53 class CADCurve;
54 typedef boost::shared_ptr<CADCurve> CADCurveSharedPtr;
55 
56 /**
57  * @brief struct which descibes a collection of cad edges which for a
58  * loop on the cad surface
59  */
60 struct EdgeLoop
61 {
62  std::vector<CADCurveSharedPtr> edges;
63  std::vector<int> edgeo; //0 is forward 1 is backward
66 };
67 
68 /**
69  * @brief class for handleing a cad surface
70  */
71 
72 class CADSurf : public CADObj
73 {
74 public:
75  friend class MemoryManager<CADSurf>;
76 
77  /**
78  * @brief Default constructor.
79  */
80  CADSurf(int i, TopoDS_Shape in, std::vector<EdgeLoop> ein);
81 
82  ~CADSurf(){};
83 
84  /**
85  * @brief Get the IDs of the edges which bound the surface.
86  *
87  * The edges are organsised into two vectors, which are grouped into the
88  * continuous loops of the bounding edges, then the edges, which are a
89  * pair of integers. The first item is the edge ID and the second is an
90  * integer that indicates whether this edge is orientated forwards or
91  * backwards on this surface to form the loop.
92  */
93  std::vector<EdgeLoop> GetEdges()
94  {
95  return m_edges;
96  }
97 
98  /**
99  * @brief Get the limits of the parametric space for the surface.
100  *
101  * @return Array of 4 entries with parametric umin,umax,vmin,vmax.
102  */
104  {
106 
107  b[0] = m_occSurface.FirstUParameter();
108  b[1] = m_occSurface.LastUParameter();
109  b[2] = m_occSurface.FirstVParameter();
110  b[3] = m_occSurface.LastVParameter();
111 
112  return b;
113  }
114 
115  /**
116  * @brief Get the normal vector at parametric point u,v.
117  *
118  * @param uv Array of u and v parametric coords.
119  * @return Array of xyz components of normal vector.
120  */
122 
123  /**
124  * @brief Get the set of first derivatives at parametric point u,v
125  *
126  * @param uv Array of u and v parametric coords.
127  * @return Array of xyz copmonents of first derivatives.
128  */
130 
131  /**
132  * @brief Get the set of second derivatives at parametric point u,v
133  *
134  * @param uv array of u and v parametric coords
135  * @return array of xyz copmonents of second derivatives
136  */
138 
139  /**
140  * @brief Get the x,y,z at parametric point u,v.
141  *
142  * @param uv Array of u and v parametric coords.
143  * @return Array of xyz location.
144  */
146 
147  /**
148  * @brief Performs a reverse look up to find u,v and x,y,z.
149  *
150  * @param p Array of xyz location
151  * @return The parametric location of xyz on this surface
152  */
154 
155  /**
156  * @brief returns true if the surface is flat (2D)
157  */
158  bool IsPlane();
159 
160  /**
161  * @brief sets the flag to reverse the normal for this suface,
162  * this is determined in cadsystem and ensures all surface normals,
163  * point internaly
164  */
166  {
167  m_correctNormal = false;
168  }
169 
171  {
172  return !m_correctNormal;
173  }
174 
175  /**
176  * @brief surface needs to know if it is bounded by only two curves
177  */
178  void SetTwoC()
179  {
180  m_hasTwoCurves = true;
181  }
182 
183  /**
184  * @brief query two curves
185  */
186  bool GetTwoC(){return m_hasTwoCurves;}
187 
188  /**
189  * @brief does unconstrained locuv to project point from anywhere
190  */
192 
194 
195  /**
196  * @brief returns curvature at point uv
197  */
199 
200 private:
201 
202  /// Function which tests the the value of uv used is within the surface
203  void Test(Array<OneD, NekDouble> uv);
204  /// normal
206  /// flag to alert the mesh generation to a potential problem is both
207  /// curves have only two points in the mesh
209  /// OpenCascade object for surface.
210  BRepAdaptor_Surface m_occSurface;
211  /// Alternate OpenCascade object for surface. Used by reverse lookup.
212  Handle(Geom_Surface) m_s;
213  /// List of bounding edges in loops with orientation.
214  std::vector<EdgeLoop> m_edges;
215 };
216 
217 typedef boost::shared_ptr<CADSurf> CADSurfSharedPtr;
218 
219 }
220 }
221 
222 #endif
Array< OneD, NekDouble > D1(Array< OneD, NekDouble > uv)
Get the set of first derivatives at parametric point u,v.
Definition: CADSurf.cpp:282
Array< OneD, NekDouble > P(Array< OneD, NekDouble > uv)
Get the x,y,z at parametric point u,v.
Definition: CADSurf.cpp:236
Array< OneD, NekDouble > center
Definition: CADSurf.h:64
class for CAD curves.
Definition: CADObj.h:62
General purpose memory allocation routines with the ability to allocate from thread specific memory p...
bool m_hasTwoCurves
flag to alert the mesh generation to a potential problem is both curves have only two points in the m...
Definition: CADSurf.h:208
Array< OneD, NekDouble > locuv(Array< OneD, NekDouble > p)
Performs a reverse look up to find u,v and x,y,z.
Definition: CADSurf.cpp:64
STL namespace.
BRepAdaptor_Surface m_occSurface
OpenCascade object for surface.
Definition: CADSurf.h:210
struct which descibes a collection of cad edges which for a loop on the cad surface ...
Definition: CADSurf.h:60
std::vector< CADCurveSharedPtr > edges
Definition: CADSurf.h:62
Array< OneD, NekDouble > N(Array< OneD, NekDouble > uv)
Get the normal vector at parametric point u,v.
Definition: CADSurf.cpp:249
void SetReverseNomral()
sets the flag to reverse the normal for this suface, this is determined in cadsystem and ensures all ...
Definition: CADSurf.h:165
class for handleing a cad surface
Definition: CADSurf.h:72
NekDouble DistanceTo(Array< OneD, NekDouble > p)
does unconstrained locuv to project point from anywhere
Definition: CADSurf.cpp:185
double NekDouble
Handle(Geom_Surface) m_s
Alternate OpenCascade object for surface. Used by reverse lookup.
std::vector< EdgeLoop > m_edges
List of bounding edges in loops with orientation.
Definition: CADSurf.h:214
boost::shared_ptr< CADSurf > CADSurfSharedPtr
Definition: CADSurf.h:217
CADSurf(int i, TopoDS_Shape in, std::vector< EdgeLoop > ein)
Default constructor.
Definition: CADSurf.cpp:47
bool IsPlane()
returns true if the surface is flat (2D)
Definition: CADSurf.cpp:224
void ProjectTo(Array< OneD, NekDouble > &tp, Array< OneD, NekDouble > &uv)
Definition: CADSurf.cpp:202
void SetTwoC()
surface needs to know if it is bounded by only two curves
Definition: CADSurf.h:178
void Test(Array< OneD, NekDouble > uv)
Function which tests the the value of uv used is within the surface.
Definition: CADSurf.cpp:335
Array< OneD, NekDouble > GetBounds()
Get the limits of the parametric space for the surface.
Definition: CADSurf.h:103
bool GetTwoC()
query two curves
Definition: CADSurf.h:186
Array< OneD, NekDouble > D2(Array< OneD, NekDouble > uv)
Get the set of second derivatives at parametric point u,v.
Definition: CADSurf.cpp:304
NekDouble Curvature(Array< OneD, NekDouble > uv)
returns curvature at point uv
Definition: CADSurf.cpp:144
std::vector< EdgeLoop > GetEdges()
Get the IDs of the edges which bound the surface.
Definition: CADSurf.h:93
std::vector< int > edgeo
Definition: CADSurf.h:63
boost::shared_ptr< CADCurve > CADCurveSharedPtr
Definition: CADCurve.h:168