mirror of
https://github.com/NGSolve/netgen.git
synced 2024-12-25 05:20:34 +05:00
Merge branch 'curvemanualmeshes' into 'master'
modify PointBetween for manually generated meshes See merge request jschoeberl/netgen!83
This commit is contained in:
commit
a985a7bfb1
@ -37,16 +37,53 @@ namespace netgen
|
|||||||
Point<3> & newp, EdgePointGeomInfo & newgi) const
|
Point<3> & newp, EdgePointGeomInfo & newgi) const
|
||||||
{
|
{
|
||||||
Point<2> p2d;
|
Point<2> p2d;
|
||||||
|
double newdist;
|
||||||
p2d = geometry.GetSplines().Get(ap1.edgenr) ->
|
auto spline = geometry.GetSplines().Get(ap1.edgenr);
|
||||||
GetPoint (((1-secpoint)*ap1.dist+secpoint*ap2.dist));
|
if( (ap1.dist == 0.0) && (ap2.dist == 0.0) )
|
||||||
|
{
|
||||||
|
// used for manually generated meshes
|
||||||
|
const SplineSeg3<2> * ss3;
|
||||||
|
const LineSeg<2> * ls;
|
||||||
|
auto ext = dynamic_cast<const SplineSegExt *>(spline);
|
||||||
|
if(ext)
|
||||||
|
{
|
||||||
|
ss3 = dynamic_cast<const SplineSeg3<2> *>(&ext->seg);
|
||||||
|
ls = dynamic_cast<const LineSeg<2> *>(&ext->seg);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ss3 = dynamic_cast<const SplineSeg3<2> *>(spline);
|
||||||
|
ls = dynamic_cast<const LineSeg<2> *>(spline);
|
||||||
|
}
|
||||||
|
Point<2> p12d(p1(0),p1(1)), p22d(p2(0),p2(1));
|
||||||
|
Point<2> p1_proj(0.0,0.0), p2_proj(0.0,0.0);
|
||||||
|
double t1_proj = 0.0;
|
||||||
|
double t2_proj = 0.0;
|
||||||
|
if(ss3)
|
||||||
|
{
|
||||||
|
ss3->Project(p12d,p1_proj,t1_proj);
|
||||||
|
ss3->Project(p22d,p2_proj,t2_proj);
|
||||||
|
}
|
||||||
|
else if(ls)
|
||||||
|
{
|
||||||
|
ls->Project(p12d,p1_proj,t1_proj);
|
||||||
|
ls->Project(p22d,p2_proj,t2_proj);
|
||||||
|
}
|
||||||
|
p2d = spline->GetPoint (((1-secpoint)*t1_proj+secpoint*t2_proj));
|
||||||
|
newdist = (1-secpoint)*t1_proj+secpoint*t2_proj;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
p2d = spline->GetPoint (((1-secpoint)*ap1.dist+secpoint*ap2.dist));
|
||||||
|
newdist = (1-secpoint)*ap1.dist+secpoint*ap2.dist;
|
||||||
|
}
|
||||||
|
|
||||||
// (*testout) << "refine 2d line, ap1.dist, ap2.dist = " << ap1.dist << ", " << ap2.dist << endl;
|
// (*testout) << "refine 2d line, ap1.dist, ap2.dist = " << ap1.dist << ", " << ap2.dist << endl;
|
||||||
// (*testout) << "p1, p2 = " << p1 << p2 << ", newp = " << p2d << endl;
|
// (*testout) << "p1, p2 = " << p1 << p2 << ", newp = " << p2d << endl;
|
||||||
|
|
||||||
newp = Point3d (p2d(0), p2d(1), 0);
|
newp = Point3d (p2d(0), p2d(1), 0);
|
||||||
newgi.edgenr = ap1.edgenr;
|
newgi.edgenr = ap1.edgenr;
|
||||||
newgi.dist = ((1-secpoint)*ap1.dist+secpoint*ap2.dist);
|
newgi.dist = newdist;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -320,12 +320,15 @@ DLL_HEADER void ExportNetgenMeshing(py::module &m)
|
|||||||
;
|
;
|
||||||
|
|
||||||
py::class_<Segment>(m, "Element1D")
|
py::class_<Segment>(m, "Element1D")
|
||||||
.def(py::init([](py::list vertices, py::list surfaces, int index)
|
.def(py::init([](py::list vertices, py::list surfaces, int index, int edgenr)
|
||||||
{
|
{
|
||||||
Segment * newel = new Segment();
|
Segment * newel = new Segment();
|
||||||
for (int i = 0; i < 2; i++)
|
for (int i = 0; i < 2; i++)
|
||||||
(*newel)[i] = py::extract<PointIndex>(vertices[i])();
|
(*newel)[i] = py::extract<PointIndex>(vertices[i])();
|
||||||
newel -> si = index;
|
newel -> si = index;
|
||||||
|
newel -> edgenr = edgenr;
|
||||||
|
newel -> epgeominfo[0].edgenr = edgenr;
|
||||||
|
newel -> epgeominfo[1].edgenr = edgenr;
|
||||||
// needed for codim2 in 3d
|
// needed for codim2 in 3d
|
||||||
newel -> edgenr = index;
|
newel -> edgenr = index;
|
||||||
if (len(surfaces))
|
if (len(surfaces))
|
||||||
@ -338,6 +341,7 @@ DLL_HEADER void ExportNetgenMeshing(py::module &m)
|
|||||||
py::arg("vertices"),
|
py::arg("vertices"),
|
||||||
py::arg("surfaces")=py::list(),
|
py::arg("surfaces")=py::list(),
|
||||||
py::arg("index")=1,
|
py::arg("index")=1,
|
||||||
|
py::arg("edgenr")=1,
|
||||||
"create segment element"
|
"create segment element"
|
||||||
)
|
)
|
||||||
.def("__repr__", &ToString<Segment>)
|
.def("__repr__", &ToString<Segment>)
|
||||||
|
Loading…
Reference in New Issue
Block a user