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

#include <CADCurveOCE.h>

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

Public Member Functions

 CADCurveOCE ()
 
 ~CADCurveOCE ()
 
virtual Array< OneD, NekDoubleGetBounds ()
 Returns the minimum and maximum parametric coords t of the curve. More...
 
virtual NekDouble Length (NekDouble ti, NekDouble tf)
 Calculates the arclength between the two paremetric points ti and tf. ti must be less than tf. More...
 
virtual Array< OneD, NekDoubleP (NekDouble t)
 Gets the location (x,y,z) in an array out of the curve at point t. More...
 
virtual Array< OneD, NekDoubleD2 (NekDouble t)
 Gets the second derivatives at t. More...
 
virtual NekDouble tAtArcLength (NekDouble s)
 Calculates the parametric coordinate and arclength location defined by s. More...
 
virtual Array< OneD, NekDoubleGetMinMax ()
 Gets the start and end of the curve. More...
 
virtual NekDouble loct (Array< OneD, NekDouble > xyz)
 
virtual NekDouble Curvature (NekDouble t)
 
virtual Array< OneD, NekDoubleNormalWRT (NekDouble t, int surf)
 
virtual Array< OneD, NekDoubleN (NekDouble t)
 
void Initialise (int i, TopoDS_Shape in)
 
- Public Member Functions inherited from Nektar::NekMeshUtils::CADCurve
 CADCurve ()
 Default constructor. More...
 
 ~CADCurve ()
 
void SetAdjSurf (std::pair< CADSurfSharedPtr, CADOrientation::Orientation > i)
 set the ids of the surfaces either side of the curve More...
 
std::vector< std::pair
< CADSurfSharedPtr,
CADOrientation::Orientation > > 
GetAdjSurf ()
 
NekDouble GetTotLength ()
 
void SetVert (std::vector< CADVertSharedPtr > &falVert)
 
std::vector< CADVertSharedPtrGetVertex ()
 
CADOrientation::Orientation GetOrienationWRT (int surf)
 
- Public Member Functions inherited from Nektar::NekMeshUtils::CADObject
 CADObject ()
 Default constructor. More...
 
virtual ~CADObject ()
 
int GetId ()
 Return ID of the vertex. More...
 
CADType::cadType GetType ()
 
virtual CADOrientation::Orientation Orientation ()
 

Static Public Member Functions

static CADCurveSharedPtr create ()
 

Static Public Attributes

static std::string key
 

Private Member Functions

 Handle (Geom_Curve) m_c
 Alternate object used for reverse lookups. More...
 

Private Attributes

BRepAdaptor_Curve m_occCurve
 OpenCascade object of the curve. More...
 
TopoDS_Edge m_occEdge
 OpenCascade edge. More...
 

Additional Inherited Members

- Protected Attributes inherited from Nektar::NekMeshUtils::CADCurve
NekDouble m_length
 Length of edge. More...
 
std::vector< std::pair
< CADSurfSharedPtr,
CADOrientation::Orientation > > 
m_adjSurfs
 List of surfaces which this curve belongs to. More...
 
std::vector< CADVertSharedPtrm_mainVerts
 list of end vertices More...
 
- Protected Attributes inherited from Nektar::NekMeshUtils::CADObject
int m_id
 ID of the vert. More...
 
CADType::cadType m_type
 type of the cad object More...
 
CADOrientation::Orientation m_orientation
 orientation of the CADObject More...
 

Detailed Description

Definition at line 47 of file CADCurveOCE.h.

Constructor & Destructor Documentation

Nektar::NekMeshUtils::CADCurveOCE::CADCurveOCE ( )
inline

Definition at line 58 of file CADCurveOCE.h.

59  {
60  }
Nektar::NekMeshUtils::CADCurveOCE::~CADCurveOCE ( )
inline

Definition at line 62 of file CADCurveOCE.h.

63  {
64  }

Member Function Documentation

static CADCurveSharedPtr Nektar::NekMeshUtils::CADCurveOCE::create ( )
inlinestatic

Definition at line 51 of file CADCurveOCE.h.

References Nektar::MemoryManager< DataType >::AllocateSharedPtr().

52  {
54  }
static boost::shared_ptr< DataType > AllocateSharedPtr()
Allocate a shared pointer from the memory pool.
NekDouble Nektar::NekMeshUtils::CADCurveOCE::Curvature ( NekDouble  t)
virtual

Implements Nektar::NekMeshUtils::CADCurve.

Definition at line 191 of file CADCurveOCE.cpp.

192 {
193  GeomLProp_CLProps d(m_c,2,1e-8);
194  d.SetParameter(t);
195 
196  return d.Curvature() * 1000.0;
197 }
Array< OneD, NekDouble > Nektar::NekMeshUtils::CADCurveOCE::D2 ( NekDouble  t)
virtual

Gets the second derivatives at t.

Implements Nektar::NekMeshUtils::CADCurve.

Definition at line 111 of file CADCurveOCE.cpp.

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

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

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

Implements Nektar::NekMeshUtils::CADCurve.

Definition at line 199 of file CADCurveOCE.cpp.

Referenced by Initialise().

200 {
201  Array<OneD, NekDouble> t(2);
202  t[0] = m_occCurve.FirstParameter();
203  t[1] = m_occCurve.LastParameter();
204 
205  return t;
206 }
BRepAdaptor_Curve m_occCurve
OpenCascade object of the curve.
Definition: CADCurveOCE.h:101
Array< OneD, NekDouble > Nektar::NekMeshUtils::CADCurveOCE::GetMinMax ( )
virtual

Gets the start and end of the curve.

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

Implements Nektar::NekMeshUtils::CADCurve.

Definition at line 208 of file CADCurveOCE.cpp.

209 {
210  Array<OneD, NekDouble> locs(6);
211 
212  gp_Pnt start =
213  BRep_Tool::Pnt(TopExp::FirstVertex(m_occEdge, Standard_True));
214  gp_Pnt end = BRep_Tool::Pnt(TopExp::LastVertex(m_occEdge, Standard_True));
215 
216  locs[0] = start.X();
217  locs[1] = start.Y();
218  locs[2] = start.Z();
219  locs[3] = end.X();
220  locs[4] = end.Y();
221  locs[5] = end.Z();
222 
223  return locs;
224 }
TopoDS_Edge m_occEdge
OpenCascade edge.
Definition: CADCurveOCE.h:103
Nektar::NekMeshUtils::CADCurveOCE::Handle ( Geom_Curve  )
private

Alternate object used for reverse lookups.

void Nektar::NekMeshUtils::CADCurveOCE::Initialise ( int  i,
TopoDS_Shape  in 
)
inline

Definition at line 77 of file CADCurveOCE.h.

References GetBounds(), Nektar::NekMeshUtils::CADObject::m_id, Nektar::NekMeshUtils::CADCurve::m_length, m_occCurve, and m_occEdge.

78  {
79  gp_Trsf transform;
80  gp_Pnt ori(0.0, 0.0, 0.0);
81  transform.SetScale(ori, 1.0 / 1000.0);
82  TopLoc_Location mv(transform);
83  TopoDS_Shape cp = in;
84  in.Move(mv);
85 
86  m_occEdge = TopoDS::Edge(in);
87  m_occCurve = BRepAdaptor_Curve(m_occEdge);
88 
89  GProp_GProps System;
90  BRepGProp::LinearProperties(m_occEdge, System);
91  m_length = System.Mass();
92 
93  Array<OneD, NekDouble> b = GetBounds();
94  m_c = BRep_Tool::Curve(TopoDS::Edge(cp), b[0], b[1]);
95 
96  m_id = i;
97  }
BRepAdaptor_Curve m_occCurve
OpenCascade object of the curve.
Definition: CADCurveOCE.h:101
virtual Array< OneD, NekDouble > GetBounds()
Returns the minimum and maximum parametric coords t of the curve.
int m_id
ID of the vert.
Definition: CADObject.h:105
TopoDS_Edge m_occEdge
OpenCascade edge.
Definition: CADCurveOCE.h:103
NekDouble m_length
Length of edge.
Definition: CADCurve.h:187
NekDouble Nektar::NekMeshUtils::CADCurveOCE::Length ( NekDouble  ti,
NekDouble  tf 
)
virtual

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.

Implements Nektar::NekMeshUtils::CADCurve.

Definition at line 71 of file CADCurveOCE.cpp.

72 {
73  Array<OneD, NekDouble> b = GetBounds();
74  Handle(Geom_Curve) NewCurve = new Geom_TrimmedCurve(m_c, ti, tf);
75  TopoDS_Edge NewEdge = BRepBuilderAPI_MakeEdge(NewCurve);
76  GProp_GProps System;
77  BRepGProp::LinearProperties(NewEdge, System);
78  return System.Mass() / 1000.0;
79 }
Handle(Geom_Curve) m_c
Alternate object used for reverse lookups.
virtual Array< OneD, NekDouble > GetBounds()
Returns the minimum and maximum parametric coords t of the curve.
NekDouble Nektar::NekMeshUtils::CADCurveOCE::loct ( Array< OneD, NekDouble xyz)
virtual

Implements Nektar::NekMeshUtils::CADCurve.

Definition at line 81 of file CADCurveOCE.cpp.

References CellMLToNektar.cellml_metadata::p.

82 {
83  NekDouble t = 0.0;
84  Array<OneD, NekDouble> b = GetBounds();
85 
86  gp_Pnt loc(xyz[0]*1000.0, xyz[1]*1000.0, xyz[2]*1000.0);
87 
88  ShapeAnalysis_Curve sac;
89  gp_Pnt p;
90  sac.Project(m_c,loc,1e-8 ,p,t);
91 
92  if(p.Distance(loc) > 1e-5)
93  {
94  cerr << "large loct distance" << endl;
95  }
96  return t;
97 }
virtual Array< OneD, NekDouble > GetBounds()
Returns the minimum and maximum parametric coords t of the curve.
double NekDouble
Array< OneD, NekDouble > Nektar::NekMeshUtils::CADCurveOCE::N ( NekDouble  t)
virtual

Implements Nektar::NekMeshUtils::CADCurve.

Definition at line 168 of file CADCurveOCE.cpp.

169 {
170  GeomLProp_CLProps d(m_c,2,1e-8);
171  d.SetParameter(t+1e-8);
172 
173  gp_Vec d2 = d.D2();
174  if(d2.Magnitude() < 1e-8)
175  {
176  //no normal, stright line
177  return Array<OneD, NekDouble>(3,0.0);
178  }
179 
180  gp_Dir n;
181  d.Normal(n);
182 
183  Array<OneD, NekDouble> N(3);
184  N[0] = n.X();
185  N[1] = n.Y();
186  N[2] = n.Z();
187 
188  return N;
189 }
virtual Array< OneD, NekDouble > N(NekDouble t)
Array< OneD, NekDouble > Nektar::NekMeshUtils::CADCurveOCE::NormalWRT ( NekDouble  t,
int  surf 
)
virtual

Implements Nektar::NekMeshUtils::CADCurve.

Definition at line 131 of file CADCurveOCE.cpp.

References ASSERTL0, Nektar::StdRegions::eBackwards, class_topology::P, and CellMLToNektar.cellml_metadata::p.

132 {
133  Array<OneD, NekDouble> p = P(t);
134  pair<CADSurfSharedPtr, CADOrientation::Orientation> surface;
135  ASSERTL0(m_adjSurfs.size() == 1, "This will only work in 2D for one surface at the moment");
136  surface = m_adjSurfs[0];
137 
138  Array<OneD, NekDouble> uv = surface.first->locuv(p);
139  Array<OneD, NekDouble> d1 = surface.first->D1(uv);
140 
141  NekDouble t1 = t - 1e-8;
142  NekDouble t2 = t + 1e-8;
143 
144  if(surface.second == CADOrientation::eBackwards)
145  {
146  swap(t1, t2);
147  }
148 
149  Array<OneD, NekDouble> uv1 = surface.first->locuv(P(t1));
150  Array<OneD, NekDouble> uv2 = surface.first->locuv(P(t2));
151 
152  NekDouble du = uv2[1] - uv1[1];
153  NekDouble dv = -1.0*(uv2[0] - uv1[0]);
154 
155  Array<OneD, NekDouble> N(3,0.0);
156  N[0] = (d1[3] * du + d1[6] * dv) / 2.0;
157  N[1] = (d1[4] * du + d1[7] * dv) / 2.0;
158  N[2] = (d1[5] * du + d1[8] * dv) / 2.0;
159 
160  NekDouble mag = sqrt(N[0]*N[0] + N[1]*N[1] + N[2]*N[2]);
161  N[0] /= mag;
162  N[1] /= mag;
163  N[2] /= mag;
164 
165  return N;
166 }
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:198
virtual Array< OneD, NekDouble > P(NekDouble t)
Gets the location (x,y,z) in an array out of the curve at point t.
Definition: CADCurveOCE.cpp:99
virtual Array< OneD, NekDouble > N(NekDouble t)
double NekDouble
std::vector< std::pair< CADSurfSharedPtr, CADOrientation::Orientation > > m_adjSurfs
List of surfaces which this curve belongs to.
Definition: CADCurve.h:189
Array< OneD, NekDouble > Nektar::NekMeshUtils::CADCurveOCE::P ( NekDouble  t)
virtual

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

Implements Nektar::NekMeshUtils::CADCurve.

Definition at line 99 of file CADCurveOCE.cpp.

100 {
101  Array<OneD, NekDouble> location(3);
102  gp_Pnt loc = m_occCurve.Value(t);
103 
104  location[0] = loc.X();
105  location[1] = loc.Y();
106  location[2] = loc.Z();
107 
108  return location;
109 }
BRepAdaptor_Curve m_occCurve
OpenCascade object of the curve.
Definition: CADCurveOCE.h:101
NekDouble Nektar::NekMeshUtils::CADCurveOCE::tAtArcLength ( NekDouble  s)
virtual

Calculates the parametric coordinate and arclength location defined by s.

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

Implements Nektar::NekMeshUtils::CADCurve.

Definition at line 48 of file CADCurveOCE.cpp.

49 {
50  NekDouble dt =
51  (m_occCurve.LastParameter() - m_occCurve.FirstParameter()) / (1000);
52  NekDouble t = m_occCurve.FirstParameter();
53 
54  NekDouble len = 0.0;
55 
56  while (len <= s)
57  {
58  gp_Pnt P1, P2;
59  gp_Vec drdt1, drdt2;
60 
61  m_occCurve.D1(t, P1, drdt1);
62  t += dt;
63  m_occCurve.D1(t, P2, drdt2);
64 
65  len += (drdt1.Magnitude() + drdt2.Magnitude()) / 2.0 * dt;
66  }
67 
68  return t - dt;
69 }
BRepAdaptor_Curve m_occCurve
OpenCascade object of the curve.
Definition: CADCurveOCE.h:101
double NekDouble

Member Data Documentation

std::string Nektar::NekMeshUtils::CADCurveOCE::key
static
Initial value:

Definition at line 56 of file CADCurveOCE.h.

BRepAdaptor_Curve Nektar::NekMeshUtils::CADCurveOCE::m_occCurve
private

OpenCascade object of the curve.

Definition at line 101 of file CADCurveOCE.h.

Referenced by Initialise().

TopoDS_Edge Nektar::NekMeshUtils::CADCurveOCE::m_occEdge
private

OpenCascade edge.

Definition at line 103 of file CADCurveOCE.h.

Referenced by Initialise().