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

class for CAD curves. More...

#include <CADCurve.h>

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

Public Member Functions

 CADCurve (int i, TopoDS_Shape in)
 Default constructor. More...
 
Array< OneD, NekDoubleBounds ()
 Returns the minimum and maximum parametric coords t of the curve. More...
 
NekDouble Length (NekDouble ti, NekDouble tf)
 Calculates the arclength between the two paremetric points ti and tf. ti must be less than tf. More...
 
Array< OneD, NekDoubleP (NekDouble t)
 Gets the location (x,y,z) in an array out of the curve at point t. More...
 
NekDouble tAtArcLength (NekDouble s)
 Calculates the parametric coordinate and arclength location defined by s. More...
 
Array< OneD, NekDoubleGetMinMax ()
 Gets OpenCascade point objects for the start and end of the curve. More...
 
int GetID ()
 
void SetAdjSurf (std::vector< int > i)
 
std::vector< int > GetAdjSurf ()
 

Private Attributes

int m_ID
 ID of the curve. More...
 
BRepAdaptor_Curve m_occCurve
 OpenCascade object of the curve. More...
 
std::vector< int > m_adjSurfs
 List of surfaces which this curve belongs to. More...
 

Friends

class MemoryManager< CADCurve >
 

Detailed Description

class for CAD curves.

This class wraps the OpenCascade BRepAdaptor_Curve class for use with Nektar++.

Definition at line 56 of file CADCurve.h.

Constructor & Destructor Documentation

Nektar::LibUtilities::CADCurve::CADCurve ( int  i,
TopoDS_Shape  in 
)

Default constructor.

Definition at line 46 of file CADCurve.cpp.

References m_occCurve.

46  : m_ID(i)
47 {
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  in.Move(mv);
53  m_occCurve = BRepAdaptor_Curve(TopoDS::Edge(in));
54 }
int m_ID
ID of the curve.
Definition: CADCurve.h:85
BRepAdaptor_Curve m_occCurve
OpenCascade object of the curve.
Definition: CADCurve.h:87

Member Function Documentation

Array< OneD, NekDouble > Nektar::LibUtilities::CADCurve::Bounds ( )

Returns the minimum and maximum parametric coords t of the curve.

Returns
Array of two entries, min and max parametric coordinate.

Definition at line 142 of file CADCurve.cpp.

References m_occCurve.

143 {
144  Array<OneD, NekDouble> t(2);
145  t[0] = m_occCurve.FirstParameter();
146  t[1] = m_occCurve.LastParameter();
147 
148  return t;
149 }
BRepAdaptor_Curve m_occCurve
OpenCascade object of the curve.
Definition: CADCurve.h:87
std::vector<int> Nektar::LibUtilities::CADCurve::GetAdjSurf ( )
inline

Definition at line 78 of file CADCurve.h.

References m_adjSurfs.

79  {
80  return m_adjSurfs;
81  }
std::vector< int > m_adjSurfs
List of surfaces which this curve belongs to.
Definition: CADCurve.h:89
int Nektar::LibUtilities::CADCurve::GetID ( )
inline

Definition at line 68 of file CADCurve.h.

References m_ID.

69  {
70  return m_ID;
71  }
int m_ID
ID of the curve.
Definition: CADCurve.h:85
Array< OneD, NekDouble > Nektar::LibUtilities::CADCurve::GetMinMax ( )

Gets OpenCascade point objects for the start and end of the curve.

Returns
Array with 6 entries of endpoints x1,y1,z1,x2,y2,z2.

Definition at line 157 of file CADCurve.cpp.

References m_occCurve.

158 {
159  Array<OneD, NekDouble> locs(6);
160 
161  gp_Pnt start = m_occCurve.Value(m_occCurve.FirstParameter());
162  gp_Pnt end = m_occCurve.Value(m_occCurve.LastParameter());
163 
164  locs[0] = start.X();
165  locs[1] = start.Y();
166  locs[2] = start.Z();
167  locs[3] = end.X();
168  locs[4] = end.Y();
169  locs[5] = end.Z();
170 
171  return locs;
172 }
BRepAdaptor_Curve m_occCurve
OpenCascade object of the curve.
Definition: CADCurve.h:87
NekDouble Nektar::LibUtilities::CADCurve::Length ( NekDouble  ti,
NekDouble  tf 
)

Calculates the arclength between the two paremetric points ti and tf. ti must be less than tf.

Parameters
tiFirst parametric coordinate.
tfSecond parametric coordinate.
Returns
Arc length between ti and tf.

Definition at line 96 of file CADCurve.cpp.

References m_occCurve.

97 {
98  NekDouble len = 0;
99  NekDouble dt = (m_occCurve.LastParameter() -
100  m_occCurve.FirstParameter()) / (1000 - 1);
101  NekDouble t = ti;
102 
103  while(t + dt <= tf)
104  {
105  gp_Pnt P1,P2;
106  gp_Vec drdt1,drdt2;
107 
108  m_occCurve.D1(t,P1,drdt1);
109  t += dt;
110  m_occCurve.D1(t,P2,drdt2);
111 
112  len += (drdt1.Magnitude() + drdt2.Magnitude()) / 2.0 * dt;
113  }
114 
115  return len;
116 }
double NekDouble
BRepAdaptor_Curve m_occCurve
OpenCascade object of the curve.
Definition: CADCurve.h:87
Array< OneD, NekDouble > Nektar::LibUtilities::CADCurve::P ( NekDouble  t)

Gets the location (x,y,z) in an array out of the curve at point t.

Parameters
tParametric coordinate
Returns
Array of x,y,z

Definition at line 124 of file CADCurve.cpp.

References m_occCurve.

125 {
126  Array<OneD, NekDouble> location(3);
127  gp_Pnt loc = m_occCurve.Value(t);
128 
129  location[0] = loc.X();
130  location[1] = loc.Y();
131  location[2] = loc.Z();
132 
133  return location;
134 }
BRepAdaptor_Curve m_occCurve
OpenCascade object of the curve.
Definition: CADCurve.h:87
void Nektar::LibUtilities::CADCurve::SetAdjSurf ( std::vector< int >  i)
inline

Definition at line 73 of file CADCurve.h.

References m_adjSurfs.

74  {
75  m_adjSurfs = i;
76  }
std::vector< int > m_adjSurfs
List of surfaces which this curve belongs to.
Definition: CADCurve.h:89
NekDouble Nektar::LibUtilities::CADCurve::tAtArcLength ( NekDouble  s)

Calculates the parametric coordinate and arclength location defined by s.

Parameters
sArclength location.
Returns
Calculated parametric coordinate.
Todo:
This really needs improving for accuracy.

Definition at line 65 of file CADCurve.cpp.

References m_occCurve.

66 {
67  NekDouble dt = (m_occCurve.LastParameter() -
68  m_occCurve.FirstParameter()) / (5000);
69  NekDouble t = m_occCurve.FirstParameter();
70 
71  NekDouble len = 0.0;
72 
73  while(len <= s)
74  {
75  gp_Pnt P1,P2;
76  gp_Vec drdt1,drdt2;
77 
78  m_occCurve.D1(t,P1,drdt1);
79  t += dt;
80  m_occCurve.D1(t,P2,drdt2);
81 
82  len += (drdt1.Magnitude() + drdt2.Magnitude()) / 2.0 * dt;
83  }
84 
85  return t - dt;
86 }
double NekDouble
BRepAdaptor_Curve m_occCurve
OpenCascade object of the curve.
Definition: CADCurve.h:87

Friends And Related Function Documentation

friend class MemoryManager< CADCurve >
friend

Definition at line 59 of file CADCurve.h.

Member Data Documentation

std::vector<int> Nektar::LibUtilities::CADCurve::m_adjSurfs
private

List of surfaces which this curve belongs to.

Definition at line 89 of file CADCurve.h.

Referenced by GetAdjSurf(), and SetAdjSurf().

int Nektar::LibUtilities::CADCurve::m_ID
private

ID of the curve.

Definition at line 85 of file CADCurve.h.

Referenced by GetID().

BRepAdaptor_Curve Nektar::LibUtilities::CADCurve::m_occCurve
private

OpenCascade object of the curve.

Definition at line 87 of file CADCurve.h.

Referenced by Bounds(), CADCurve(), GetMinMax(), Length(), P(), and tAtArcLength().