Nektar++
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | Private Attributes | Friends | List of all members
Nektar::NekMeshUtils::CADCurve Class Reference

class for CAD curves. More...

#include <CADCurve.h>

Inheritance diagram for Nektar::NekMeshUtils::CADCurve:
Inheritance graph
[legend]
Collaboration diagram for Nektar::NekMeshUtils::CADCurve:
Collaboration graph
[legend]

Public Member Functions

 CADCurve (int i, TopoDS_Shape in)
 Default constructor. More...
 
 ~CADCurve ()
 
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...
 
Array< OneD, NekDoubleD2 (NekDouble t)
 Gets the second derivatives at t. More...
 
NekDouble tAtArcLength (NekDouble s)
 Calculates the parametric coordinate and arclength location defined by s. More...
 
Array< OneD, NekDoubleGetMinMax ()
 Gets the start and end of the curve. More...
 
void SetAdjSurf (std::vector< CADSurfSharedPtr > i)
 set the ids of the surfaces either side of the curve More...
 
std::vector< CADSurfSharedPtrGetAdjSurf ()
 returns the ids of neigbouring surfaces More...
 
NekDouble GetTotLength ()
 returns lenght of the curve More...
 
void SetVert (std::vector< CADVertSharedPtr > &falVert)
 
std::vector< CADVertSharedPtrGetVertex ()
 get the ids of the vertices that are the ends of the curve, which are in the main cad list More...
 
- Public Member Functions inherited from Nektar::NekMeshUtils::CADObj
 CADObj ()
 Default constructor. More...
 
virtual ~CADObj ()
 
int GetId ()
 Return ID of the vertex. More...
 
cadType GetType ()
 

Private Attributes

BRepAdaptor_Curve m_occCurve
 OpenCascade object of the curve. More...
 
TopoDS_Edge m_occEdge
 OpenCascade edge. More...
 
NekDouble m_length
 Length of edge. More...
 
std::vector< CADSurfSharedPtrm_adjSurfs
 List of surfaces which this curve belongs to. More...
 
std::vector< CADVertSharedPtrm_mainVerts
 list of end vertices More...
 

Friends

class MemoryManager< CADCurve >
 

Additional Inherited Members

- Protected Attributes inherited from Nektar::NekMeshUtils::CADObj
int m_id
 ID of the vert. More...
 
cadType m_type
 type of the cad object More...
 

Detailed Description

class for CAD curves.

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

Definition at line 61 of file CADCurve.h.

Constructor & Destructor Documentation

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

Default constructor.

Definition at line 45 of file CADCurve.cpp.

References Nektar::NekMeshUtils::curve.

46 {
47  gp_Trsf transform;
48  gp_Pnt ori(0.0, 0.0, 0.0);
49  transform.SetScale(ori, 1.0 / 1000.0);
50  TopLoc_Location mv(transform);
51  in.Move(mv);
52 
53  m_occEdge = TopoDS::Edge(in);
54  m_occCurve = BRepAdaptor_Curve(m_occEdge);
55 
56  GProp_GProps System;
57  BRepGProp::LinearProperties(m_occEdge, System);
58  m_length = System.Mass();
59 
60  m_id = i;
61  m_type = curve;
62 }
int m_id
ID of the vert.
Definition: CADObj.h:91
NekDouble m_length
Length of edge.
Definition: CADCurve.h:161
TopoDS_Edge m_occEdge
OpenCascade edge.
Definition: CADCurve.h:159
cadType m_type
type of the cad object
Definition: CADObj.h:93
BRepAdaptor_Curve m_occCurve
OpenCascade object of the curve.
Definition: CADCurve.h:157
Nektar::NekMeshUtils::CADCurve::~CADCurve ( )
inline

Definition at line 71 of file CADCurve.h.

71 {};

Member Function Documentation

Array< OneD, NekDouble > Nektar::NekMeshUtils::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 130 of file CADCurve.cpp.

131 {
132  Array<OneD, NekDouble> t(2);
133  t[0] = m_occCurve.FirstParameter();
134  t[1] = m_occCurve.LastParameter();
135 
136  return t;
137 }
BRepAdaptor_Curve m_occCurve
OpenCascade object of the curve.
Definition: CADCurve.h:157
Array< OneD, NekDouble > Nektar::NekMeshUtils::CADCurve::D2 ( NekDouble  t)

Gets the second derivatives at t.

Definition at line 110 of file CADCurve.cpp.

111 {
112  Array<OneD, NekDouble> out(9);
113  gp_Pnt loc;
114  gp_Vec d1, d2;
115  m_occCurve.D2(t, loc, d1, d2);
116 
117  out[0] = loc.X();
118  out[1] = loc.Y();
119  out[2] = loc.Z();
120  out[3] = d1.X();
121  out[4] = d1.Y();
122  out[5] = d1.Z();
123  out[6] = d2.X();
124  out[7] = d2.Y();
125  out[8] = d2.Z();
126 
127  return out;
128 }
BRepAdaptor_Curve m_occCurve
OpenCascade object of the curve.
Definition: CADCurve.h:157
std::vector<CADSurfSharedPtr> Nektar::NekMeshUtils::CADCurve::GetAdjSurf ( )
inline

returns the ids of neigbouring surfaces

Definition at line 129 of file CADCurve.h.

References m_adjSurfs.

130  {
131  return m_adjSurfs;
132  }
std::vector< CADSurfSharedPtr > m_adjSurfs
List of surfaces which this curve belongs to.
Definition: CADCurve.h:163
Array< OneD, NekDouble > Nektar::NekMeshUtils::CADCurve::GetMinMax ( )

Gets the start and end of the curve.

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

Definition at line 139 of file CADCurve.cpp.

140 {
141  Array<OneD, NekDouble> locs(6);
142 
143  gp_Pnt start =
144  BRep_Tool::Pnt(TopExp::FirstVertex(m_occEdge, Standard_True));
145  gp_Pnt end = BRep_Tool::Pnt(TopExp::LastVertex(m_occEdge, Standard_True));
146 
147  locs[0] = start.X();
148  locs[1] = start.Y();
149  locs[2] = start.Z();
150  locs[3] = end.X();
151  locs[4] = end.Y();
152  locs[5] = end.Z();
153 
154  return locs;
155 }
TopoDS_Edge m_occEdge
OpenCascade edge.
Definition: CADCurve.h:159
NekDouble Nektar::NekMeshUtils::CADCurve::GetTotLength ( )
inline

returns lenght of the curve

Definition at line 135 of file CADCurve.h.

References m_length.

136  {
137  return m_length;
138  }
NekDouble m_length
Length of edge.
Definition: CADCurve.h:161
std::vector<CADVertSharedPtr> Nektar::NekMeshUtils::CADCurve::GetVertex ( )
inline

get the ids of the vertices that are the ends of the curve, which are in the main cad list

Definition at line 150 of file CADCurve.h.

References m_mainVerts.

151  {
152  return m_mainVerts;
153  }
std::vector< CADVertSharedPtr > m_mainVerts
list of end vertices
Definition: CADCurve.h:165
NekDouble Nektar::NekMeshUtils::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 87 of file CADCurve.cpp.

88 {
89  Array<OneD, NekDouble> b = Bounds();
90  Handle(Geom_Curve) m_c = BRep_Tool::Curve(m_occEdge, b[0], b[1]);
91  Handle(Geom_Curve) NewCurve = new Geom_TrimmedCurve(m_c, ti, tf);
92  TopoDS_Edge NewEdge = BRepBuilderAPI_MakeEdge(NewCurve);
93  GProp_GProps System;
94  BRepGProp::LinearProperties(NewEdge, System);
95  return System.Mass() / 1000.0;
96 }
TopoDS_Edge m_occEdge
OpenCascade edge.
Definition: CADCurve.h:159
Array< OneD, NekDouble > Bounds()
Returns the minimum and maximum parametric coords t of the curve.
Definition: CADCurve.cpp:130
Array< OneD, NekDouble > Nektar::NekMeshUtils::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 98 of file CADCurve.cpp.

99 {
100  Array<OneD, NekDouble> location(3);
101  gp_Pnt loc = m_occCurve.Value(t);
102 
103  location[0] = loc.X();
104  location[1] = loc.Y();
105  location[2] = loc.Z();
106 
107  return location;
108 }
BRepAdaptor_Curve m_occCurve
OpenCascade object of the curve.
Definition: CADCurve.h:157
void Nektar::NekMeshUtils::CADCurve::SetAdjSurf ( std::vector< CADSurfSharedPtr i)
inline

set the ids of the surfaces either side of the curve

Definition at line 123 of file CADCurve.h.

References m_adjSurfs.

124  {
125  m_adjSurfs = i;
126  }
std::vector< CADSurfSharedPtr > m_adjSurfs
List of surfaces which this curve belongs to.
Definition: CADCurve.h:163
void Nektar::NekMeshUtils::CADCurve::SetVert ( std::vector< CADVertSharedPtr > &  falVert)
inline

Definition at line 143 of file CADCurve.h.

References m_mainVerts.

144  {
145  m_mainVerts = falVert;
146  }
std::vector< CADVertSharedPtr > m_mainVerts
list of end vertices
Definition: CADCurve.h:165
NekDouble Nektar::NekMeshUtils::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 64 of file CADCurve.cpp.

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

Friends And Related Function Documentation

friend class MemoryManager< CADCurve >
friend

Definition at line 64 of file CADCurve.h.

Member Data Documentation

std::vector<CADSurfSharedPtr> Nektar::NekMeshUtils::CADCurve::m_adjSurfs
private

List of surfaces which this curve belongs to.

Definition at line 163 of file CADCurve.h.

Referenced by GetAdjSurf(), and SetAdjSurf().

NekDouble Nektar::NekMeshUtils::CADCurve::m_length
private

Length of edge.

Definition at line 161 of file CADCurve.h.

Referenced by GetTotLength().

std::vector<CADVertSharedPtr> Nektar::NekMeshUtils::CADCurve::m_mainVerts
private

list of end vertices

Definition at line 165 of file CADCurve.h.

Referenced by GetVertex(), and SetVert().

BRepAdaptor_Curve Nektar::NekMeshUtils::CADCurve::m_occCurve
private

OpenCascade object of the curve.

Definition at line 157 of file CADCurve.h.

TopoDS_Edge Nektar::NekMeshUtils::CADCurve::m_occEdge
private

OpenCascade edge.

Definition at line 159 of file CADCurve.h.