netgen/libsrc/csg/meshsurf.cpp

206 lines
5.0 KiB
C++
Raw Normal View History

2009-01-13 04:40:13 +05:00
#include <mystdlib.h>
#include <csg.hpp>
#include <meshing.hpp>
namespace netgen
{
/*
Meshing2Surfaces :: Meshing2Surfaces (const Surface & asurface)
: surface(asurface)
{
;
}
*/
Meshing2Surfaces :: Meshing2Surfaces (const Surface & asurf,
2011-07-25 14:40:23 +06:00
const MeshingParameters & mp,
2009-01-13 04:40:13 +05:00
const Box<3> & abb)
2014-08-30 06:15:59 +06:00
: Meshing2(mp, abb), surface(asurf), mparam (mp)
2009-01-13 04:40:13 +05:00
{
;
}
void Meshing2Surfaces :: DefineTransformation (const Point<3> & p1, const Point<3> & p2,
2009-01-13 04:40:13 +05:00
const PointGeomInfo * geominfo1,
const PointGeomInfo * geominfo2)
{
((Surface&)surface).DefineTangentialPlane (p1, p2);
}
void Meshing2Surfaces :: TransformToPlain (const Point<3> & locpoint,
2009-01-13 04:40:13 +05:00
const MultiPointGeomInfo & geominfo,
Point<2> & planepoint,
2009-01-13 04:40:13 +05:00
double h, int & zone)
{
surface.ToPlane (locpoint, planepoint, h, zone);
2009-01-13 04:40:13 +05:00
}
int Meshing2Surfaces :: TransformFromPlain (const Point<2> & planepoint,
Point<3> & locpoint,
PointGeomInfo & gi,
double h)
2009-01-13 04:40:13 +05:00
{
surface.FromPlane (planepoint, locpoint, h);
2009-01-13 04:40:13 +05:00
gi.trignum = 1;
return 0;
}
double Meshing2Surfaces :: CalcLocalH (const Point<3> & p, double gh) const
2009-01-13 04:40:13 +05:00
{
2014-08-30 06:15:59 +06:00
return surface.LocH (p, 3, 1, mparam, gh);
2009-01-13 04:40:13 +05:00
/*
double loch = mesh.lochfunc->GetH(p);
if (gh < loch) loch = gh;
return loch;
*/
}
MeshOptimize2dSurfaces :: MeshOptimize2dSurfaces (const CSGeometry & ageometry)
: MeshOptimize2d(), geometry(ageometry)
{
;
}
void MeshOptimize2dSurfaces :: ProjectPoint (INDEX surfind, Point<3> & p) const
{
Point<3> hp = p;
geometry.GetSurface(surfind)->Project (hp);
p = hp;
}
void MeshOptimize2dSurfaces :: ProjectPoint2 (INDEX surfind, INDEX surfind2,
Point<3> & p) const
{
Point<3> hp = p;
ProjectToEdge ( geometry.GetSurface(surfind),
geometry.GetSurface(surfind2), hp);
p = hp;
}
void MeshOptimize2dSurfaces ::
GetNormalVector(INDEX surfind, const Point<3> & p, Vec<3> & n) const
{
Vec<3> hn = n;
geometry.GetSurface(surfind)->CalcGradient (p, hn);
hn.Normalize();
n = hn;
/*
if (geometry.GetSurface(surfind)->Inverse())
n *= -1;
*/
}
RefinementSurfaces :: RefinementSurfaces (const CSGeometry & ageometry)
: Refinement(), geometry(ageometry)
{
if(geometry.GetNSurf() == 0)
*testout << endl
2018-01-08 20:45:53 +05:00
<< "WARNING: Initializing 2D refinement with 0-surface geometry" << endl
2009-01-13 04:40:13 +05:00
<< "==========================================================" << endl
<< endl << endl;
}
RefinementSurfaces :: ~RefinementSurfaces ()
{
;
}
void RefinementSurfaces ::
PointBetween (const Point<3> & p1, const Point<3> & p2, double secpoint,
int surfi,
const PointGeomInfo & gi1,
const PointGeomInfo & gi2,
2011-01-11 01:18:01 +05:00
Point<3> & newp, PointGeomInfo & newgi) const
2009-01-13 04:40:13 +05:00
{
Point<3> hnewp;
hnewp = p1+secpoint*(p2-p1);
if (surfi != -1)
{
geometry.GetSurface (surfi) -> Project (hnewp);
newgi.trignum = 1;
}
newp = hnewp;
}
void RefinementSurfaces ::
PointBetween (const Point<3> & p1, const Point<3> & p2, double secpoint,
int surfi1, int surfi2,
const EdgePointGeomInfo & ap1,
const EdgePointGeomInfo & ap2,
2011-01-11 01:18:01 +05:00
Point<3> & newp, EdgePointGeomInfo & newgi) const
2009-01-13 04:40:13 +05:00
{
Point<3> hnewp = p1+secpoint*(p2-p1);
//(*testout) << "hnewp " << hnewp << " s1 " << surfi1 << " s2 " << surfi2 << endl;
if (surfi1 != -1 && surfi2 != -1 && surfi1 != surfi2)
{
netgen::ProjectToEdge (geometry.GetSurface(surfi1),
geometry.GetSurface(surfi2),
hnewp);
// (*testout) << "Pointbetween, newp = " << hnewp << endl
// << ", err = " << sqrt (sqr (hnewp(0))+ sqr(hnewp(1)) + sqr (hnewp(2))) - 1 << endl;
newgi.edgenr = 1;
//(*testout) << "hnewp (a1) " << hnewp << endl;
}
else if (surfi1 != -1)
{
geometry.GetSurface (surfi1) -> Project (hnewp);
//(*testout) << "hnewp (a2) " << hnewp << endl;
}
newp = hnewp;
};
Vec<3> RefinementSurfaces :: GetTangent (const Point<3> & p, int surfi1, int surfi2,
const EdgePointGeomInfo & ap1) const
{
Vec<3> n1 = geometry.GetSurface (surfi1)->GetNormalVector (p);
Vec<3> n2 = geometry.GetSurface (surfi2)->GetNormalVector (p);
Vec<3> tau = Cross (n1, n2).Normalize();
return tau;
}
Vec<3> RefinementSurfaces :: GetNormal (const Point<3> & p, int surfi1,
const PointGeomInfo & gi) const
{
return geometry.GetSurface (surfi1)->GetNormalVector (p);
}
2011-01-11 01:18:01 +05:00
void RefinementSurfaces :: ProjectToSurface (Point<3> & p, int surfi) const
2009-01-13 04:40:13 +05:00
{
if (surfi != -1)
geometry.GetSurface (surfi) -> Project (p);
};
void RefinementSurfaces :: ProjectToEdge (Point<3> & p, int surfi1, int surfi2, const EdgePointGeomInfo & egi) const
{
netgen::ProjectToEdge (geometry.GetSurface(surfi1),
geometry.GetSurface(surfi2),
p);
}
}