geo GetNormal and ProjectPointEdge with geoinfo pointer

This commit is contained in:
Christopher Lackner 2019-11-04 11:27:01 +01:00
parent c1ede2a89f
commit 1b1c4700ad
14 changed files with 53 additions and 72 deletions

View File

@ -87,7 +87,7 @@ namespace netgen
}
void CSGeometry :: ProjectPointEdge(int surfind, INDEX surfind2,
Point<3> & p) const
Point<3> & p, EdgePointGeomInfo* /*unused*/) const
{
Point<3> hp = p;
ProjectToEdge (GetSurface(surfind),
@ -96,7 +96,8 @@ namespace netgen
}
Vec<3> CSGeometry :: GetNormal(int surfind, const Point<3> & p) const
Vec<3> CSGeometry :: GetNormal(int surfind, const Point<3> & p,
const PointGeomInfo* /*unused*/) const
{
Vec<3> hn;
GetSurface(surfind)->CalcGradient(p, hn);

View File

@ -190,8 +190,10 @@ namespace netgen
PointGeomInfo ProjectPoint(INDEX surfind, Point<3> & p) const override;
bool ProjectPointGI (int surfind, Point<3> & p, PointGeomInfo & gi) const override;
void ProjectPointEdge(INDEX surfind, INDEX surfind2, Point<3> & p) const override;
Vec<3> GetNormal(int surfind, const Point<3> & p) const override;
void ProjectPointEdge(INDEX surfind, INDEX surfind2, Point<3> & p,
EdgePointGeomInfo* gi = nullptr) const override;
Vec<3> GetNormal(int surfind, const Point<3> & p, const PointGeomInfo* gi = nullptr) const override;
void PointBetween(const Point<3> & p1, const Point<3> & p2,
double secpoint, int surfi,
const PointGeomInfo & gi1,

View File

@ -86,7 +86,7 @@ namespace netgen
}
Vec<3> SplineGeometry2d :: GetNormal(int surfi1, const Point<3> & p,
const PointGeomInfo & gi) const
const PointGeomInfo* gi) const
{
return Vec<3> (0,0,1);
}

View File

@ -182,7 +182,7 @@ namespace netgen
Vec<3> GetTangent (const Point<3> & p, int surfi1, int surfi2,
const EdgePointGeomInfo & ap1) const override;
Vec<3> GetNormal(int surfi1, const Point<3> & p,
const PointGeomInfo & gi) const override;
const PointGeomInfo* gi) const override;
const SplineSegExt & GetSpline (const int i) const
{

View File

@ -32,7 +32,7 @@ namespace netgen
virtual double CalcStep(double t, double sag) const = 0;
virtual bool OrientedLikeGlobal() const = 0;
virtual size_t GetHash() const = 0;
virtual void ProjectPoint(Point<3>& p, EdgePointGeomInfo& gi) const = 0;
virtual void ProjectPoint(Point<3>& p, EdgePointGeomInfo* gi) const = 0;
virtual void PointBetween(const Point<3>& p1,
const Point<3>& p2,
double secpoint,
@ -65,14 +65,8 @@ namespace netgen
virtual double GetCurvature(const PointGeomInfo& gi) const = 0;
virtual void RestrictH(Mesh& mesh, const MeshingParameters& mparam) const = 0;
virtual Vec<3> GetNormal(const Point<3>& p) const
{
return {0.,0.,1.};
}
virtual Vec<3> GetNormal(const Point<3>& p, const PointGeomInfo& gi) const
{
return GetNormal(p);
}
virtual Vec<3> GetNormal(const Point<3>& p, const PointGeomInfo* gi = nullptr) const = 0;
virtual void PointBetween(const Point<3>& p1,
const Point<3>& p2,
double secpoint,
@ -129,13 +123,9 @@ namespace netgen
return faces[surfind-1]->Project(p);
}
virtual void ProjectPointEdge (int surfind, int surfind2, Point<3> & p) const
{
throw Exception("In ProjectPointEdge of basegeometry");
}
virtual void ProjectPointEdge (int surfind, int surfind2, Point<3> & p, EdgePointGeomInfo& gi) const
virtual void ProjectPointEdge (int surfind, int surfind2, Point<3> & p, EdgePointGeomInfo* gi = nullptr) const
{
edges[gi.edgenr]->ProjectPoint(p, gi);
edges[gi->edgenr]->ProjectPoint(p, gi);
}
virtual bool CalcPointGeomInfo(int surfind, PointGeomInfo& gi, const Point<3> & p3) const
@ -147,15 +137,8 @@ namespace netgen
return faces[surfind-1]->ProjectPointGI(p, gi);
}
virtual Vec<3> GetNormal(int surfind, const Point<3> & p) const
{ return faces[surfind-1]->GetNormal(p); }
virtual Vec<3> GetNormal(int surfind, const Point<3> & p, const PointGeomInfo & gi) const
virtual Vec<3> GetNormal(int surfind, const Point<3> & p, const PointGeomInfo* gi = nullptr) const
{ return faces[surfind-1]->GetNormal(p, gi); }
[[deprecated]]
void GetNormal(int surfind, const Point<3> & p, Vec<3> & n) const
{
n = GetNormal(surfind, p);
}
virtual void PointBetween (const Point<3> & p1,
const Point<3> & p2, double secpoint,

View File

@ -839,8 +839,8 @@ namespace netgen
{
Point<3> pm = Center (p1, p2);
Vec<3> n1 = geo.GetNormal (surfnr[e], p1, gi0[e]);
Vec<3> n2 = geo.GetNormal (surfnr[e], p2, gi1[e]);
Vec<3> n1 = geo.GetNormal (surfnr[e], p1, &gi0[e]);
Vec<3> n2 = geo.GetNormal (surfnr[e], p2, &gi1[e]);
// p3 = pm + alpha1 n1 + alpha2 n2
@ -1084,7 +1084,7 @@ namespace netgen
v05 /= 1 + (w-1) * 0.5;
Point<3> p05 (v05), pp05(v05);
geo.ProjectPointEdge(edge_surfnr1[edgenr], edge_surfnr2[edgenr], pp05,
edge_gi0[edgenr]);
&edge_gi0[edgenr]);
double d = Dist (pp05, p05);
if (d < dold)

View File

@ -85,11 +85,11 @@ namespace netgen
nv1.Normalize();
nv2.Normalize();
auto nvp3 = geo.GetNormal (surfnr, mesh.Point(pi3), gi3);
auto nvp3 = geo.GetNormal (surfnr, mesh.Point(pi3), &gi3);
nvp3.Normalize();
auto nvp4 = geo.GetNormal (surfnr, mesh.Point(pi4), gi4);
auto nvp4 = geo.GetNormal (surfnr, mesh.Point(pi4), &gi4);
nvp4.Normalize();
@ -648,7 +648,7 @@ namespace netgen
{
const int faceindex = hel.GetIndex();
const int surfnr = mesh.GetFaceDescriptor (faceindex).SurfNr();
normals[pi] = geo.GetNormal (surfnr, mesh[pi], hel.GeomInfoPi(k+1));
normals[pi] = geo.GetNormal (surfnr, mesh[pi], &hel.GeomInfoPi(k+1));
break;
}
}

View File

@ -397,7 +397,7 @@ namespace netgen
// calc metric badness
double bad1 = 0, bad2 = 0;
// SelectSurfaceOfPoint (mesh.Point(pmap.Get(1)), pgi.Get(1));
auto n = geo.GetNormal(surfnr, mesh.Point(pmap.Get(1)), pgi.Elem(1));
auto n = geo.GetNormal(surfnr, mesh.Point(pmap.Get(1)), &pgi.Elem(1));
for (int j = 0; j < rule.oldels.Size(); j++)
bad1 += mesh[elmap[j]].CalcJacobianBadness (mesh.Points(), n);

View File

@ -142,8 +142,8 @@ namespace netgen
{
p1 = ap1;
p2 = ap2;
auto n1 = geo.GetNormal(gi1->trignum, p1, *gi1);
auto n2 = geo.GetNormal(gi2->trignum, p2, *gi2);
auto n1 = geo.GetNormal(gi1->trignum, p1, gi1);
auto n2 = geo.GetNormal(gi2->trignum, p2, gi2);
ez = 0.5 * (n1+n2);
ez.Normalize();
@ -158,7 +158,7 @@ namespace netgen
Point<2> & plainpoint, double h, int & zone)
{
auto& gi = geominfo.GetPGI(1);
auto n = geo.GetNormal(gi.trignum, locpoint, gi);
auto n = geo.GetNormal(gi.trignum, locpoint, &gi);
auto p1p = locpoint - p1;
plainpoint(0) = (p1p * ex) / h;
plainpoint(1) = (p1p * ey) / h;

View File

@ -218,7 +218,7 @@ namespace netgen
{
double badness = 0;
auto n = geo.GetNormal(ld.surfi, ld.sp1, ld.gi1);
auto n = geo.GetNormal(ld.surfi, ld.sp1, &ld.gi1);
Point<3> pp1 = ld.sp1 + x(0) * ld.t1 + x(1) * ld.t2;
for (int j = 0; j < ld.locelements.Size(); j++)
@ -359,7 +359,7 @@ namespace netgen
vgrad = 0;
double badness = 0;
auto n = geo.GetNormal(ld.surfi, ld.sp1, ld.gi1);
auto n = geo.GetNormal(ld.surfi, ld.sp1, &ld.gi1);
pp1 = ld.sp1 + x(0) * ld.t1 + x(1) * ld.t2;
// meshthis -> ProjectPoint (surfi, pp1);
@ -414,7 +414,7 @@ namespace netgen
vgrad = 0;
double badness = 0;
auto n = geo.GetNormal(ld.surfi, ld.sp1, ld.gi1);
auto n = geo.GetNormal(ld.surfi, ld.sp1, &ld.gi1);
pp1 = ld.sp1 + x(0) * ld.t1 + x(1) * ld.t2;
for (int j = 0; j < ld.locelements.Size(); j++)
@ -577,7 +577,7 @@ namespace netgen
vgrad = 0;
badness = 0;
auto n = geo.GetNormal(ld.surfi, ld.sp1, ld.gi1);
// auto n = geo.GetNormal(ld.surfi, ld.sp1, &ld.gi1);
pp1 = ld.sp1 + x(0) * ld.t1 + x(1) * ld.t2;
@ -933,7 +933,7 @@ namespace netgen
}
ld.normal = geo.GetNormal(ld.surfi, ld.sp1, ld.gi1);
ld.normal = geo.GetNormal(ld.surfi, ld.sp1, &ld.gi1);
ld.t1 = ld.normal.GetNormal ();
ld.t2 = Cross (ld.normal, ld.t1);

View File

@ -1072,7 +1072,7 @@ void STEP_GetEntityName(const TopoDS_Shape & theShape, STEPCAFControl_Reader * a
}
void OCCGeometry :: ProjectPointEdge(int surfind, INDEX surfind2,
Point<3> & p) const
Point<3> & p, EdgePointGeomInfo* gi) const
{
TopExp_Explorer exp0, exp1;
bool done = false;
@ -1154,26 +1154,25 @@ void STEP_GetEntityName(const TopoDS_Shape & theShape, STEPCAFControl_Reader * a
return true;
}
Vec<3> OCCGeometry :: GetNormal(int surfind, const Point<3> & p, const PointGeomInfo & geominfo) const
Vec<3> OCCGeometry :: GetNormal(int surfind, const Point<3> & p, const PointGeomInfo* geominfo) const
{
gp_Pnt pnt;
gp_Vec du, dv;
if(geominfo)
{
gp_Pnt pnt;
gp_Vec du, dv;
Handle(Geom_Surface) occface;
occface = BRep_Tool::Surface(TopoDS::Face(fmap(surfind)));
Handle(Geom_Surface) occface;
occface = BRep_Tool::Surface(TopoDS::Face(fmap(surfind)));
occface->D1(geominfo.u,geominfo.v,pnt,du,dv);
occface->D1(geominfo->u,geominfo->v,pnt,du,dv);
auto n = Cross (Vec<3>(du.X(), du.Y(), du.Z()),
Vec<3>(dv.X(), dv.Y(), dv.Z()));
n.Normalize();
auto n = Cross (Vec<3>(du.X(), du.Y(), du.Z()),
Vec<3>(dv.X(), dv.Y(), dv.Z()));
n.Normalize();
if (fmap(surfind).Orientation() == TopAbs_REVERSED) n *= -1;
return n;
}
Vec<3> OCCGeometry :: GetNormal(int surfind, const Point<3> & p) const
{
if (fmap(surfind).Orientation() == TopAbs_REVERSED) n *= -1;
return n;
}
Standard_Real u,v;
gp_Pnt pnt(p(0), p(1), p(2));

View File

@ -281,10 +281,10 @@ namespace netgen
void DoArchive(Archive& ar) override;
PointGeomInfo ProjectPoint(int surfind, Point<3> & p) const override;
void ProjectPointEdge (int surfind, int surfind2, Point<3> & p) const override;
void ProjectPointEdge (int surfind, int surfind2, Point<3> & p,
EdgePointGeomInfo* gi = nullptr) const override;
bool ProjectPointGI (int surfind, Point<3> & p, PointGeomInfo & gi) const override;
Vec<3> GetNormal(int surfind, const Point<3> & p) const override;
Vec<3> GetNormal(int surfind, const Point<3> & p, const PointGeomInfo & gi) const override;
Vec<3> GetNormal(int surfind, const Point<3> & p, const PointGeomInfo* gi) const override;
bool CalcPointGeomInfo(int surfind, PointGeomInfo& gi, const Point<3> & p3) const override;
void PointBetweenEdge(const Point<3> & p1, const Point<3> & p2, double secpoint,

View File

@ -100,14 +100,11 @@ int STLGeometry :: GenerateMesh (shared_ptr<Mesh> & mesh, MeshingParameters & mp
return STLMeshingDummy (this, mesh, mparam, stlpar);
}
Vec<3> STLGeometry :: GetNormal(INDEX surfind, const Point<3> & p) const
Vec<3> STLGeometry :: GetNormal(int surfind, const Point<3> & p, const PointGeomInfo* gi) const
{
throw Exception("STLGeometry::GetNormal without PointGeomInfo called");
}
Vec<3> STLGeometry :: GetNormal(int surfind, const Point<3> & p, const PointGeomInfo & gi) const
{
return GetChart(GetChartNr(gi.trignum)).GetNormal();
if(!gi)
throw Exception("STLGeometry::GetNormal without PointGeomInfo called");
return GetChart(GetChartNr(gi->trignum)).GetNormal();
}
bool STLGeometry :: CalcPointGeomInfo(int /*surfind*/, PointGeomInfo& gi, const Point<3> & p3) const

View File

@ -195,8 +195,7 @@ namespace netgen
bool CalcPointGeomInfo(int surfind, PointGeomInfo& gi, const Point<3> & p3) const override;
PointGeomInfo ProjectPoint(INDEX surfind, Point<3> & p) const override;
bool ProjectPointGI (int surfind, Point<3> & p, PointGeomInfo & gi) const override;
Vec<3> GetNormal(int surfind, const Point<3> & p) const override;
Vec<3> GetNormal(int surfind, const Point<3> & p, const PointGeomInfo & gi) const override;
Vec<3> GetNormal(int surfind, const Point<3> & p, const PointGeomInfo* gi = nullptr) const override;
void PointBetween(const Point<3> & p1, const Point<3> & p2,
double secpoint, int surfi,
const PointGeomInfo & gi1,