Nektar++
Public Member Functions | Private Member Functions | Private Attributes | Friends | List of all members
Nektar::LibUtilities::CADSurf Class Reference

#include <CADSurf.h>

Collaboration diagram for Nektar::LibUtilities::CADSurf:
Collaboration graph
[legend]

Public Member Functions

 CADSurf (int i, TopoDS_Shape in, std::vector< std::vector< std::pair< int, int > > > ein)
 Default constructor. More...
 
std::vector< std::vector< std::pair< int, int > > > GetEdges ()
 Get the IDs of the edges which bound the surface. More...
 
Array< OneD, NekDoubleGetBounds ()
 Get the limits of the parametric space for the surface. More...
 
Array< OneD, NekDoubleN (Array< OneD, NekDouble > uv)
 Get the normal vector at parametric point u,v. More...
 
Array< OneD, NekDoubleD1 (Array< OneD, NekDouble > uv)
 Get the set of first derivatives at parametric point u,v. More...
 
Array< OneD, NekDoubleD2 (Array< OneD, NekDouble > uv)
 Get the set of second derivatives at parametric point u,v. More...
 
Array< OneD, NekDoubleP (Array< OneD, NekDouble > uv)
 Get the x,y,z at parametric point u,v. More...
 
Array< OneD, NekDoublelocuv (Array< OneD, NekDouble > p)
 Performs a reverse look up to find u,v and x,y,z. More...
 

Private Member Functions

 Handle (Geom_Surface) m_s
 Alternate OpenCascade object for surface. Used by reverse lookup. More...
 

Private Attributes

int m_ID
 ID of surface. More...
 
BRepAdaptor_Surface m_occSurface
 OpenCascade object for surface. More...
 
std::vector< std::vector< std::pair< int, int > > > m_edges
 List of bounding edges in loops with orientation. More...
 

Friends

class MemoryManager< CADSurf >
 

Detailed Description

Definition at line 50 of file CADSurf.h.

Constructor & Destructor Documentation

Nektar::LibUtilities::CADSurf::CADSurf ( int  i,
TopoDS_Shape  in,
std::vector< std::vector< std::pair< int, int > > >  ein 
)

Default constructor.

Definition at line 43 of file CADSurf.cpp.

References m_occSurface.

44  : m_ID(i), m_edges(ein)
45 {
46  // this bit of code changes the units of the cad from mm opencascade
47  // defualt to m
48  gp_Trsf transform;
49  gp_Pnt ori(0.0, 0.0, 0.0);
50  transform.SetScale(ori, 1.0 / 1000.0);
51  TopLoc_Location mv(transform);
52  m_s = BRep_Tool::Surface(TopoDS::Face(in));
53  in.Move(mv);
54  m_occSurface = BRepAdaptor_Surface(TopoDS::Face(in));
55 }
BRepAdaptor_Surface m_occSurface
OpenCascade object for surface.
Definition: CADSurf.h:102
int m_ID
ID of surface.
Definition: CADSurf.h:100
std::vector< std::vector< std::pair< int, int > > > m_edges
List of bounding edges in loops with orientation.
Definition: CADSurf.h:106

Member Function Documentation

Array< OneD, NekDouble > Nektar::LibUtilities::CADSurf::D1 ( Array< OneD, NekDouble uv)

Get the set of first derivatives at parametric point u,v.

Parameters
uvArray of u and v parametric coords.
Returns
Array of xyz copmonents of first derivatives.

Definition at line 151 of file CADSurf.cpp.

References m_occSurface.

152 {
153  Array<OneD, NekDouble> r(9);
154  gp_Pnt Loc;
155  gp_Vec D1U, D1V;
156  m_occSurface.D1(uv[0], uv[1], Loc, D1U, D1V);
157 
158  r[0] = Loc.X(); //x
159  r[1] = Loc.Y(); //y
160  r[2] = Loc.Z(); //z
161  r[3] = D1U.X(); //dx/du
162  r[4] = D1U.Y(); //dy/du
163  r[5] = D1U.Z(); //dz/du
164  r[6] = D1V.X(); //dx/dv
165  r[7] = D1V.Y(); //dy/dv
166  r[8] = D1V.Z(); //dz/dv
167 
168  return r;
169 }
BRepAdaptor_Surface m_occSurface
OpenCascade object for surface.
Definition: CADSurf.h:102
Array< OneD, NekDouble > Nektar::LibUtilities::CADSurf::D2 ( Array< OneD, NekDouble uv)

Get the set of second derivatives at parametric point u,v.

Parameters
uvarray of u and v parametric coords
Returns
array of xyz copmonents of second derivatives

Definition at line 178 of file CADSurf.cpp.

References m_occSurface.

179 {
180  Array<OneD, NekDouble> r(18);
181  gp_Pnt Loc;
182  gp_Vec D1U, D1V, D2U, D2V, D2UV;
183  m_occSurface.D2(uv[0], uv[1], Loc, D1U, D1V, D2U, D2V, D2UV);
184 
185  r[0] = Loc.X(); //x
186  r[1] = Loc.Y(); //y
187  r[2] = Loc.Z(); //z
188  r[3] = D1U.X(); //dx/dx
189  r[4] = D1U.Y(); //dy/dy
190  r[5] = D1U.Z(); //dz/dz
191  r[6] = D1V.X(); //dx/dx
192  r[7] = D1V.Y(); //dy/dy
193  r[8] = D1V.Z(); //dz/dz
194  r[9] = D2U.X(); //d2x/du2
195  r[10] = D2U.Y(); //d2y/du2
196  r[11] = D2U.Z(); //d2z/du2
197  r[12] = D2V.X(); //d2x/dv2
198  r[13] = D2V.Y(); //d2y/dv2
199  r[14] = D2V.Z(); //d2z/dv2
200  r[15] = D2UV.X(); //d2x/dudv
201  r[16] = D2UV.Y(); //d2y/dudv
202  r[17] = D2UV.Z(); //d2z/dudv
203 
204  return r;
205 }
BRepAdaptor_Surface m_occSurface
OpenCascade object for surface.
Definition: CADSurf.h:102
Array<OneD, NekDouble> Nektar::LibUtilities::CADSurf::GetBounds ( )
inline

Get the limits of the parametric space for the surface.

Returns
Array of 4 entries with parametric umin,umax,vmin,vmax.

Definition at line 80 of file CADSurf.h.

References m_occSurface.

81  {
82  Array<OneD,NekDouble> b(4);
83 
84  b[0] = m_occSurface.FirstUParameter();
85  b[1] = m_occSurface.LastUParameter();
86  b[2] = m_occSurface.FirstVParameter();
87  b[3] = m_occSurface.LastVParameter();
88 
89  return b;
90  }
BRepAdaptor_Surface m_occSurface
OpenCascade object for surface.
Definition: CADSurf.h:102
std::vector<std::vector<std::pair<int,int> > > Nektar::LibUtilities::CADSurf::GetEdges ( )
inline

Get the IDs of the edges which bound the surface.

The edges are organsised into two vectors, which are grouped into the continuous loops of the bounding edges, then the edges, which are a pair of integers. The first item is the edge ID and the second is an integer that indicates whether this edge is orientated forwards or backwards on this surface to form the loop.

Definition at line 70 of file CADSurf.h.

References m_edges.

71  {
72  return m_edges;
73  }
std::vector< std::vector< std::pair< int, int > > > m_edges
List of bounding edges in loops with orientation.
Definition: CADSurf.h:106
Nektar::LibUtilities::CADSurf::Handle ( Geom_Surface  )
private

Alternate OpenCascade object for surface. Used by reverse lookup.

Array< OneD, NekDouble > Nektar::LibUtilities::CADSurf::locuv ( Array< OneD, NekDouble p)

Performs a reverse look up to find u,v and x,y,z.

Parameters
pArray of xyz location
Returns
The parametric location of xyz on this surface
Todo:
create a check so that if the calculated uv is out of bounds

Definition at line 63 of file CADSurf.cpp.

References ASSERTL0, ASSERTL1, Nektar::NekConstants::GeomTol, and m_occSurface.

64 {
65  //has to transfer back to mm
66  gp_Pnt loc(p[0] * 1000.0, p[1] * 1000.0, p[2] * 1000.0);
67 
68  GeomAPI_ProjectPointOnSurf projection(loc, m_s,
69  m_occSurface.FirstUParameter(),
70  m_occSurface.LastUParameter(),
71  m_occSurface.FirstVParameter(),
72  m_occSurface.LastVParameter(),
73  Extrema_ExtAlgo_Tree);
74 
75  ASSERTL0(projection.NbPoints() > 0, "locuv failed");
76 
77  Quantity_Parameter ui;
78  Quantity_Parameter vi;
79 
80  projection.Parameters(1,ui,vi);
81 
82  /// @todo create a check so that if the calculated uv is out of bounds
83 
84  Array<OneD, NekDouble> uvr(2);
85  uvr[0] = ui;
86  uvr[1] = vi;
87 
88  ASSERTL1(projection.Distance(1) < NekConstants::GeomTol,
89  "large locuv distance");
90 
91  return uvr;
92 }
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:161
BRepAdaptor_Surface m_occSurface
OpenCascade object for surface.
Definition: CADSurf.h:102
#define ASSERTL1(condition, msg)
Assert Level 1 – Debugging which is used whether in FULLDEBUG or DEBUG compilation mode...
Definition: ErrorUtil.hpp:191
static const NekDouble GeomTol
Array< OneD, NekDouble > Nektar::LibUtilities::CADSurf::N ( Array< OneD, NekDouble uv)

Get the normal vector at parametric point u,v.

Parameters
uvArray of u and v parametric coords.
Returns
Array of xyz components of normal vector.

Definition at line 118 of file CADSurf.cpp.

References m_occSurface.

119 {
120  Array<OneD, NekDouble> normal(3);
121  gp_Pnt Loc;
122  gp_Vec D1U, D1V;
123  m_occSurface.D1(uv[0], uv[1], Loc, D1U, D1V);
124  gp_Vec n = D1U.Crossed(D1V);
125 
126  if (n.X() == 0 && n.Y() == 0 && n.Z() == 0)
127  {
128  // Return bad normal
129  normal[0] = 0.0;
130  normal[1] = 0.0;
131  normal[2] = 0.0;
132  }
133  else
134  {
135  n.Normalize();
136  normal[0] = n.X();
137  normal[1] = n.Y();
138  normal[2] = n.Z();
139  }
140 
141  return normal;
142 }
BRepAdaptor_Surface m_occSurface
OpenCascade object for surface.
Definition: CADSurf.h:102
Array< OneD, NekDouble > Nektar::LibUtilities::CADSurf::P ( Array< OneD, NekDouble uv)

Get the x,y,z at parametric point u,v.

Parameters
uvArray of u and v parametric coords.
Returns
Array of xyz location.
Todo:
create bound checking

Definition at line 100 of file CADSurf.cpp.

References m_occSurface.

101 {
102  /// @todo create bound checking
103  Array<OneD, NekDouble> location(3);
104  gp_Pnt loc;
105  loc = m_occSurface.Value(uv[0], uv[1]);
106  location[0] = loc.X();
107  location[1] = loc.Y();
108  location[2] = loc.Z();
109  return location;
110 }
BRepAdaptor_Surface m_occSurface
OpenCascade object for surface.
Definition: CADSurf.h:102

Friends And Related Function Documentation

friend class MemoryManager< CADSurf >
friend

Definition at line 53 of file CADSurf.h.

Member Data Documentation

std::vector<std::vector<std::pair<int,int> > > Nektar::LibUtilities::CADSurf::m_edges
private

List of bounding edges in loops with orientation.

Definition at line 106 of file CADSurf.h.

Referenced by GetEdges().

int Nektar::LibUtilities::CADSurf::m_ID
private

ID of surface.

Definition at line 100 of file CADSurf.h.

BRepAdaptor_Surface Nektar::LibUtilities::CADSurf::m_occSurface
private

OpenCascade object for surface.

Definition at line 102 of file CADSurf.h.

Referenced by CADSurf(), D1(), D2(), GetBounds(), locuv(), N(), and P().