Commit 062312ea authored by Dave Moxey's avatar Dave Moxey
Browse files

Merge branch 'feature/cadcurve_projection' into 'master'

cadcurve projection

small addition to allow points to be projected onto cad curves.

See merge request !697
parents 57f65371 f39c014c
......@@ -47,6 +47,7 @@ v4.4.0
- Add STL surface writer module (!668)
- New module for inserting an alternate high-order surface into the working
mesh (!669)
- Add curve projection routines to CAD system (!697)
- Improvements to mesh linearisation module (!659)
- Add support for Gmsh high-order output (!679)
- Move CAD classes to factory format (!676)
......
......@@ -153,7 +153,13 @@ public:
return m_mainVerts;
}
/*
* @brief locates a point in the parametric space
*/
virtual NekDouble loct(Array<OneD, NekDouble> xyz) = 0;
protected:
/// Length of edge
NekDouble m_length;
/// List of surfaces which this curve belongs to.
......
......@@ -71,7 +71,6 @@ NekDouble CADCurveOCE::tAtArcLength(NekDouble s)
NekDouble CADCurveOCE::Length(NekDouble ti, NekDouble tf)
{
Array<OneD, NekDouble> b = Bounds();
Handle(Geom_Curve) m_c = BRep_Tool::Curve(m_occEdge, b[0], b[1]);
Handle(Geom_Curve) NewCurve = new Geom_TrimmedCurve(m_c, ti, tf);
TopoDS_Edge NewEdge = BRepBuilderAPI_MakeEdge(NewCurve);
GProp_GProps System;
......@@ -79,6 +78,24 @@ NekDouble CADCurveOCE::Length(NekDouble ti, NekDouble tf)
return System.Mass() / 1000.0;
}
NekDouble CADCurveOCE::loct(Array<OneD, NekDouble> xyz)
{
NekDouble t = 0.0;
Array<OneD, NekDouble> b = Bounds();
gp_Pnt loc(xyz[0]*1000.0, xyz[1]*1000.0, xyz[2]*1000.0);
ShapeAnalysis_Curve sac;
gp_Pnt p;
sac.Project(m_c,loc,1e-8 ,p,t);
if(p.Distance(loc) > 1e-5)
{
cerr << "large loct distance" << endl;
}
return t;
}
Array<OneD, NekDouble> CADCurveOCE::P(NekDouble t)
{
Array<OneD, NekDouble> location(3);
......
......@@ -69,6 +69,7 @@ public:
virtual Array<OneD, NekDouble> D2(NekDouble t);
virtual NekDouble tAtArcLength(NekDouble s);
virtual Array<OneD, NekDouble> GetMinMax();
virtual NekDouble loct(Array<OneD, NekDouble> xyz);
void Initialise(int i, TopoDS_Shape in)
{
......@@ -76,6 +77,7 @@ public:
gp_Pnt ori(0.0, 0.0, 0.0);
transform.SetScale(ori, 1.0 / 1000.0);
TopLoc_Location mv(transform);
TopoDS_Shape cp = in;
in.Move(mv);
m_occEdge = TopoDS::Edge(in);
......@@ -85,6 +87,9 @@ public:
BRepGProp::LinearProperties(m_occEdge, System);
m_length = System.Mass();
Array<OneD, NekDouble> b = Bounds();
m_c = BRep_Tool::Curve(TopoDS::Edge(cp), b[0], b[1]);
m_id = i;
m_type = curve;
}
......@@ -94,6 +99,8 @@ private:
BRepAdaptor_Curve m_occCurve;
/// OpenCascade edge
TopoDS_Edge m_occEdge;
/// Alternate object used for reverse lookups
Handle(Geom_Curve) m_c;
};
}
......
......@@ -48,6 +48,7 @@
#include <BRepAdaptor_Curve.hxx>
#include <BRepAdaptor_Surface.hxx>
#include <GeomAPI_ProjectPointOnSurf.hxx>
#include <GeomAPI_ProjectPointOnCurve.hxx>
#include <GeomAbs_SurfaceType.hxx>
#include <BRepTools.hxx>
#include <BRep_Tool.hxx>
......@@ -67,6 +68,7 @@
#include <ShapeAnalysis_Wire.hxx>
#include <TopoDS_Wire.hxx>
#include <ShapeAnalysis_Surface.hxx>
#include <ShapeAnalysis_Curve.hxx>
#include <Standard_Macro.hxx>
#endif
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment