2009-08-24 06:03:40 +06:00
|
|
|
#ifndef FILE_BASEGEOM
|
|
|
|
#define FILE_BASEGEOM
|
|
|
|
|
|
|
|
/**************************************************************************/
|
|
|
|
/* File: basegeom.hpp */
|
|
|
|
/* Author: Joachim Schoeberl */
|
|
|
|
/* Date: 23. Aug. 09 */
|
|
|
|
/**************************************************************************/
|
|
|
|
|
2011-03-03 01:50:39 +05:00
|
|
|
|
|
|
|
struct Tcl_Interp;
|
2011-01-11 01:18:01 +05:00
|
|
|
|
|
|
|
namespace netgen
|
|
|
|
{
|
2019-10-28 21:14:55 +05:00
|
|
|
class GeometryVertex
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
virtual ~GeometryVertex() {}
|
|
|
|
virtual Point<3> GetPoint() const = 0;
|
|
|
|
virtual size_t GetHash() const = 0;
|
|
|
|
};
|
|
|
|
|
2019-10-28 18:41:31 +05:00
|
|
|
class GeometryEdge
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
virtual ~GeometryEdge() {}
|
2019-10-28 21:14:55 +05:00
|
|
|
virtual const GeometryVertex& GetStartVertex() const = 0;
|
|
|
|
virtual const GeometryVertex& GetEndVertex() const = 0;
|
|
|
|
virtual double GetLength() const = 0;
|
|
|
|
virtual Point<3> GetPoint(double t) const = 0;
|
2019-10-28 23:58:35 +05:00
|
|
|
// Calculate parameter step respecting edges sag value
|
|
|
|
virtual double CalcStep(double t, double sag) const = 0;
|
2019-10-28 21:14:55 +05:00
|
|
|
virtual bool OrientedLikeGlobal() const = 0;
|
|
|
|
virtual size_t GetHash() const = 0;
|
2019-10-28 18:41:31 +05:00
|
|
|
};
|
|
|
|
|
|
|
|
class GeometryFace
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
virtual ~GeometryFace() {}
|
|
|
|
virtual size_t GetNBoundaries() const = 0;
|
2019-10-28 21:14:55 +05:00
|
|
|
virtual Array<unique_ptr<GeometryEdge>> GetBoundary(size_t index) const = 0;
|
|
|
|
virtual string GetName() const { return "default"; }
|
2019-10-28 18:41:31 +05:00
|
|
|
// Project point using geo info. Fast if point is close to
|
|
|
|
// parametrization in geo info.
|
|
|
|
virtual bool ProjectPointGI(Point<3>& p, PointGeomInfo& gi) const =0;
|
2019-10-28 23:58:35 +05:00
|
|
|
virtual Point<3> GetPoint(const PointGeomInfo& gi) const = 0;
|
2019-10-28 21:14:55 +05:00
|
|
|
virtual void CalcEdgePointGI(const GeometryEdge& edge,
|
|
|
|
double t,
|
|
|
|
EdgePointGeomInfo& egi) const = 0;
|
2019-10-28 18:41:31 +05:00
|
|
|
virtual Box<3> GetBoundingBox() const = 0;
|
2019-10-28 23:58:35 +05:00
|
|
|
|
|
|
|
// Get curvature in point from local coordinates in PointGeomInfo
|
|
|
|
virtual double GetCurvature(const PointGeomInfo& gi) const = 0;
|
|
|
|
|
|
|
|
virtual void RestrictH(Mesh& mesh, const MeshingParameters& mparam) const = 0;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
void RestrictHTrig(Mesh& mesh,
|
|
|
|
const PointGeomInfo& gi0,
|
|
|
|
const PointGeomInfo& gi1,
|
|
|
|
const PointGeomInfo& gi2,
|
|
|
|
const MeshingParameters& mparam,
|
|
|
|
int depth = 0, double h = 0.) const;
|
2019-10-28 18:41:31 +05:00
|
|
|
};
|
2009-08-24 06:03:40 +06:00
|
|
|
|
2011-03-04 02:42:20 +05:00
|
|
|
class DLL_HEADER NetgenGeometry
|
2011-03-03 01:50:39 +05:00
|
|
|
{
|
2019-10-03 16:52:59 +05:00
|
|
|
unique_ptr<Refinement> ref;
|
2019-10-24 16:17:00 +05:00
|
|
|
protected:
|
2019-10-28 21:14:55 +05:00
|
|
|
Array<unique_ptr<GeometryVertex>> vertices;
|
|
|
|
Array<unique_ptr<GeometryEdge>> edges;
|
2019-10-28 18:41:31 +05:00
|
|
|
Array<unique_ptr<GeometryFace>> faces;
|
2019-10-24 16:17:00 +05:00
|
|
|
Box<3> bounding_box;
|
2011-03-03 01:50:39 +05:00
|
|
|
public:
|
2019-10-03 16:52:59 +05:00
|
|
|
NetgenGeometry()
|
|
|
|
{
|
|
|
|
ref = make_unique<Refinement>(*this);
|
|
|
|
}
|
2011-03-03 01:50:39 +05:00
|
|
|
virtual ~NetgenGeometry () { ; }
|
2009-08-25 20:00:20 +06:00
|
|
|
|
2016-12-05 17:50:21 +05:00
|
|
|
virtual int GenerateMesh (shared_ptr<Mesh> & mesh, MeshingParameters & mparam);
|
2009-08-25 20:00:20 +06:00
|
|
|
|
2019-10-03 16:52:59 +05:00
|
|
|
virtual const Refinement & GetRefinement () const
|
|
|
|
{
|
|
|
|
return *ref;
|
|
|
|
}
|
2011-01-11 01:18:01 +05:00
|
|
|
|
2019-10-02 20:20:13 +05:00
|
|
|
virtual void DoArchive(Archive&)
|
2018-12-14 16:01:58 +05:00
|
|
|
{ throw NgException("DoArchive not implemented for " + Demangle(typeid(*this).name())); }
|
|
|
|
|
2019-10-02 20:20:13 +05:00
|
|
|
virtual Mesh::GEOM_TYPE GetGeomType() const { return Mesh::NO_GEOM; }
|
|
|
|
virtual void Analyse(Mesh& mesh,
|
2019-10-28 18:41:31 +05:00
|
|
|
const MeshingParameters& mparam) const;
|
|
|
|
virtual void FindEdges(Mesh& mesh, const MeshingParameters& mparam) const;
|
|
|
|
virtual void MeshSurface(Mesh& mesh, const MeshingParameters& mparam) const;
|
|
|
|
virtual void OptimizeSurface(Mesh& mesh, const MeshingParameters& mparam) const;
|
2019-10-02 23:29:18 +05:00
|
|
|
|
2019-10-02 20:20:13 +05:00
|
|
|
virtual void FinalizeMesh(Mesh& mesh) const {}
|
2019-10-02 23:29:18 +05:00
|
|
|
|
|
|
|
virtual void ProjectPoint (int surfind, Point<3> & p) const
|
|
|
|
{ }
|
|
|
|
virtual void ProjectPointEdge (int surfind, int surfind2, Point<3> & p) const { }
|
|
|
|
virtual void ProjectPointEdge (int surfind, int surfind2, Point<3> & p, EdgePointGeomInfo& gi) const
|
|
|
|
{ ProjectPointEdge(surfind, surfind2, p); }
|
|
|
|
|
|
|
|
virtual bool CalcPointGeomInfo(int surfind, PointGeomInfo& gi, const Point<3> & p3) const {return false;}
|
|
|
|
virtual bool ProjectPointGI (int surfind, Point<3> & p, PointGeomInfo & gi) const
|
|
|
|
{
|
2019-10-23 14:26:45 +05:00
|
|
|
throw Exception("ProjectPointGI not overloaded in class" + Demangle(typeid(*this).name()));
|
2019-10-02 23:29:18 +05:00
|
|
|
}
|
2019-10-23 14:26:45 +05:00
|
|
|
|
2019-10-02 23:29:18 +05:00
|
|
|
virtual Vec<3> GetNormal(int surfind, const Point<3> & p) const
|
|
|
|
{ return {0.,0.,1.}; }
|
|
|
|
virtual Vec<3> GetNormal(int surfind, const Point<3> & p, const PointGeomInfo & gi) const
|
|
|
|
{ return GetNormal(surfind, p); }
|
|
|
|
[[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,
|
|
|
|
int surfi,
|
|
|
|
const PointGeomInfo & gi1,
|
|
|
|
const PointGeomInfo & gi2,
|
|
|
|
Point<3> & newp,
|
|
|
|
PointGeomInfo & newgi) const
|
|
|
|
{
|
|
|
|
newp = p1 + secpoint * (p2-p1);
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual void PointBetweenEdge(const Point<3> & p1,
|
|
|
|
const Point<3> & p2, double secpoint,
|
|
|
|
int surfi1, int surfi2,
|
|
|
|
const EdgePointGeomInfo & ap1,
|
|
|
|
const EdgePointGeomInfo & ap2,
|
|
|
|
Point<3> & newp,
|
|
|
|
EdgePointGeomInfo & newgi) const
|
|
|
|
{
|
|
|
|
newp = p1+secpoint*(p2-p1);
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual Vec<3> GetTangent(const Point<3> & p, int surfi1,
|
|
|
|
int surfi2,
|
|
|
|
const EdgePointGeomInfo & egi) const
|
|
|
|
{ throw Exception("Call GetTangent of " + Demangle(typeid(*this).name())); }
|
2019-10-28 21:14:55 +05:00
|
|
|
|
|
|
|
virtual size_t GetEdgeIndex(const GeometryEdge& edge) const
|
|
|
|
{
|
|
|
|
for(auto i : Range(edges))
|
|
|
|
if(edge.GetHash() == edges[i]->GetHash())
|
|
|
|
return i;
|
|
|
|
throw Exception("Couldn't find edge index");
|
|
|
|
}
|
2011-03-03 01:50:39 +05:00
|
|
|
virtual void Save (string filename) const;
|
2011-08-29 16:09:11 +06:00
|
|
|
virtual void SaveToMeshFile (ostream & /* ost */) const { ; }
|
2011-03-03 01:50:39 +05:00
|
|
|
};
|
2009-08-24 06:03:40 +06:00
|
|
|
|
|
|
|
|
2010-03-23 17:52:07 +05:00
|
|
|
|
|
|
|
|
|
|
|
|
2011-03-04 02:42:20 +05:00
|
|
|
class DLL_HEADER GeometryRegister
|
2011-03-03 01:50:39 +05:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
virtual ~GeometryRegister();
|
|
|
|
virtual NetgenGeometry * Load (string filename) const = 0;
|
2011-08-29 16:09:11 +06:00
|
|
|
virtual NetgenGeometry * LoadFromMeshFile (istream & /* ist */) const { return NULL; }
|
|
|
|
virtual class VisualScene * GetVisualScene (const NetgenGeometry * /* geom */) const
|
2011-03-03 01:50:39 +05:00
|
|
|
{ return NULL; }
|
2011-08-29 16:09:11 +06:00
|
|
|
virtual void SetParameters (Tcl_Interp * /* interp */) { ; }
|
2011-03-03 01:50:39 +05:00
|
|
|
};
|
|
|
|
|
2019-07-09 13:39:16 +05:00
|
|
|
class DLL_HEADER GeometryRegisterArray : public NgArray<GeometryRegister*>
|
2013-02-06 18:55:20 +06:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
virtual ~GeometryRegisterArray()
|
|
|
|
{
|
|
|
|
for (int i = 0; i < Size(); i++)
|
|
|
|
delete (*this)[i];
|
|
|
|
}
|
2018-05-12 12:16:02 +05:00
|
|
|
|
|
|
|
virtual shared_ptr<NetgenGeometry> LoadFromMeshFile (istream & ist) const;
|
2013-02-06 18:55:20 +06:00
|
|
|
};
|
|
|
|
|
2019-07-09 13:39:16 +05:00
|
|
|
// extern DLL_HEADER NgArray<GeometryRegister*> geometryregister;
|
2013-02-06 18:55:20 +06:00
|
|
|
extern DLL_HEADER GeometryRegisterArray geometryregister;
|
2011-01-11 01:18:01 +05:00
|
|
|
}
|
|
|
|
|
2010-03-23 17:52:07 +05:00
|
|
|
|
|
|
|
|
2009-08-24 06:03:40 +06:00
|
|
|
#endif
|