project point without geominfo returns new geominfo

This commit is contained in:
Christopher Lackner 2019-10-31 17:08:29 +01:00
parent 1e3ed047db
commit 6c012675aa
9 changed files with 20 additions and 13 deletions

View File

@ -72,11 +72,12 @@ namespace netgen
Clean(); Clean();
} }
void CSGeometry :: ProjectPoint(int surfind, Point<3> & p) const PointGeomInfo CSGeometry :: ProjectPoint(int surfind, Point<3> & p) const
{ {
Point<3> hp = p; Point<3> hp = p;
GetSurface(surfind)->Project (hp); GetSurface(surfind)->Project (hp);
p = hp; p = hp;
return PointGeomInfo();
} }
bool CSGeometry :: ProjectPointGI(int surfind, Point<3> & p, PointGeomInfo & gi) const bool CSGeometry :: ProjectPointGI(int surfind, Point<3> & p, PointGeomInfo & gi) const

View File

@ -188,7 +188,7 @@ namespace netgen
virtual void SaveToMeshFile (ostream & ost) const override; virtual void SaveToMeshFile (ostream & ost) const override;
void ProjectPoint(INDEX surfind, Point<3> & p) const override; PointGeomInfo ProjectPoint(INDEX surfind, Point<3> & p) const override;
bool ProjectPointGI (int surfind, Point<3> & p, PointGeomInfo & gi) const override; bool ProjectPointGI (int surfind, Point<3> & p, PointGeomInfo & gi) const override;
void ProjectPointEdge(INDEX surfind, INDEX surfind2, Point<3> & p) const override; void ProjectPointEdge(INDEX surfind, INDEX surfind2, Point<3> & p) const override;
Vec<3> GetNormal(int surfind, const Point<3> & p) const override; Vec<3> GetNormal(int surfind, const Point<3> & p) const override;

View File

@ -95,6 +95,9 @@ namespace netgen
mesh.SetLocalH(bounding_box.PMin(), bounding_box.PMax(), mesh.SetLocalH(bounding_box.PMin(), bounding_box.PMax(),
mparam.grading); mparam.grading);
// only set meshsize for edges longer than this
double mincurvelength = 1e-3 * bounding_box.Diam();
if(mparam.uselocalh) if(mparam.uselocalh)
{ {
double eps = 1e-12 * bounding_box.Diam(); double eps = 1e-12 * bounding_box.Diam();
@ -108,7 +111,7 @@ namespace netgen
const auto & edge = edges[i]; const auto & edge = edges[i];
auto length = edge->GetLength(); auto length = edge->GetLength();
// skip very short edges // skip very short edges
if(length < eps) if(length < mincurvelength)
continue; continue;
static constexpr int npts = 20; static constexpr int npts = 20;
// restrict mesh size based on edge length // restrict mesh size based on edge length

View File

@ -50,7 +50,7 @@ namespace netgen
virtual size_t GetNBoundaries() const = 0; virtual size_t GetNBoundaries() const = 0;
virtual Array<unique_ptr<GeometryEdge>> GetBoundary(size_t index) const = 0; virtual Array<unique_ptr<GeometryEdge>> GetBoundary(size_t index) const = 0;
virtual string GetName() const { return "default"; } virtual string GetName() const { return "default"; }
virtual void Project(Point<3>& p) const = 0; virtual PointGeomInfo Project(Point<3>& p) const = 0;
// Project point using geo info. Fast if point is close to // Project point using geo info. Fast if point is close to
// parametrization in geo info. // parametrization in geo info.
virtual bool ProjectPointGI(Point<3>& p, PointGeomInfo& gi) const =0; virtual bool ProjectPointGI(Point<3>& p, PointGeomInfo& gi) const =0;
@ -124,9 +124,9 @@ namespace netgen
virtual void FinalizeMesh(Mesh& mesh) const {} virtual void FinalizeMesh(Mesh& mesh) const {}
virtual void ProjectPoint (int surfind, Point<3> & p) const virtual PointGeomInfo ProjectPoint (int surfind, Point<3> & p) const
{ {
faces[surfind-1]->Project(p); return faces[surfind-1]->Project(p);
} }
virtual void ProjectPointEdge (int surfind, int surfind2, Point<3> & p) const virtual void ProjectPointEdge (int surfind, int surfind2, Point<3> & p) const

View File

@ -176,7 +176,7 @@ namespace netgen
{ {
locpoint = p1 + (h*plainpoint(0)) * ex + (h* plainpoint(1)) * ey; locpoint = p1 + (h*plainpoint(0)) * ex + (h* plainpoint(1)) * ey;
if (!geo.ProjectPointGI(gi.trignum, locpoint, gi)) if (!geo.ProjectPointGI(gi.trignum, locpoint, gi))
geo.ProjectPoint(gi.trignum, locpoint); gi = geo.ProjectPoint(gi.trignum, locpoint);
return 0; return 0;
} }

View File

@ -1034,7 +1034,7 @@ void STEP_GetEntityName(const TopoDS_Shape & theShape, STEPCAFControl_Reader * a
SetCenter(); SetCenter();
} }
void OCCGeometry :: ProjectPoint(int surfi, Point<3> & p) const PointGeomInfo OCCGeometry :: ProjectPoint(int surfi, Point<3> & p) const
{ {
static int cnt = 0; static int cnt = 0;
if (++cnt % 1000 == 0) cout << "Project cnt = " << cnt << endl; if (++cnt % 1000 == 0) cout << "Project cnt = " << cnt << endl;
@ -1048,9 +1048,12 @@ void STEP_GetEntityName(const TopoDS_Shape & theShape, STEPCAFControl_Reader * a
suval.Coord( u, v); suval.Coord( u, v);
pnt = thesurf->Value( u, v ); pnt = thesurf->Value( u, v );
PointGeomInfo gi;
gi.trignum = surfi;
gi.u = u;
gi.v = v;
p = Point<3> (pnt.X(), pnt.Y(), pnt.Z()); p = Point<3> (pnt.X(), pnt.Y(), pnt.Z());
return gi;
} }
bool OCCGeometry :: ProjectPointGI(int surfind, Point<3>& p, PointGeomInfo& gi) const bool OCCGeometry :: ProjectPointGI(int surfind, Point<3>& p, PointGeomInfo& gi) const

View File

@ -280,7 +280,7 @@ namespace netgen
void DoArchive(Archive& ar) override; void DoArchive(Archive& ar) override;
void ProjectPoint(int surfind, Point<3> & p) const 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) const override;
bool ProjectPointGI (int surfind, Point<3> & p, PointGeomInfo & gi) 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 override;

View File

@ -144,7 +144,7 @@ bool STLGeometry :: ProjectPointGI (int surfind, Point<3> & p, PointGeomInfo & g
return true; return true;
} }
void STLGeometry :: ProjectPoint (INDEX surfind, Point<3> & p) const PointGeomInfo STLGeometry :: ProjectPoint (INDEX surfind, Point<3> & p) const
{ {
throw Exception("ProjectPoint without PointGeomInfo not implemented"); throw Exception("ProjectPoint without PointGeomInfo not implemented");
} }

View File

@ -193,7 +193,7 @@ namespace netgen
virtual void Save (string filename) const override; virtual void Save (string filename) const override;
bool CalcPointGeomInfo(int surfind, PointGeomInfo& gi, const Point<3> & p3) const override; bool CalcPointGeomInfo(int surfind, PointGeomInfo& gi, const Point<3> & p3) const override;
void ProjectPoint(INDEX surfind, Point<3> & p) const override; PointGeomInfo ProjectPoint(INDEX surfind, Point<3> & p) const override;
bool ProjectPointGI (int surfind, Point<3> & p, PointGeomInfo & gi) 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 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;