mirror of
https://github.com/NGSolve/netgen.git
synced 2024-11-11 16:49:16 +05:00
Merge branch 'point_info_csg2d' into 'master'
Point info csg2d See merge request jschoeberl/netgen!341
This commit is contained in:
commit
4b5054d9fd
@ -1171,8 +1171,10 @@ next_P: ;
|
||||
// add duplicate vertices to P and Q
|
||||
auto V_P = I_P->Insert(*I_P, I_P->lam);
|
||||
V_P->spline = I_P->spline;
|
||||
V_P->pinfo = I_P->pinfo;
|
||||
auto V_Q = I_Q->Insert(*I_Q, I_Q->lam);
|
||||
V_Q->spline = I_Q->spline;
|
||||
V_Q->pinfo = I_Q->pinfo;
|
||||
|
||||
// link vertices correctly
|
||||
if (sP*sQ > 0) { // same local orientation
|
||||
@ -1252,6 +1254,7 @@ void CreateResult(Solid2d & sp, Solid2d & sr, bool UNION)
|
||||
if ((status == EXIT) ^ UNION)
|
||||
{
|
||||
vnew.info = V->info;
|
||||
vnew.pinfo = V->pinfo;
|
||||
if(V->spline)
|
||||
vnew.spline = *V->spline;
|
||||
else
|
||||
@ -1270,6 +1273,7 @@ void CreateResult(Solid2d & sp, Solid2d & sr, bool UNION)
|
||||
else
|
||||
vnew.spline = nullopt;
|
||||
vnew.info = V->info;
|
||||
vnew.pinfo = V->pinfo;
|
||||
V->is_intersection = false; // mark visited vertices
|
||||
}
|
||||
if(V == I)
|
||||
@ -1580,7 +1584,7 @@ bool Loop :: IsInside( Point<2> r ) const
|
||||
}
|
||||
|
||||
|
||||
Solid2d :: Solid2d(const Array<std::variant<Point<2>, EdgeInfo>> & points, string name_, string bc)
|
||||
Solid2d :: Solid2d(const Array<std::variant<Point<2>, EdgeInfo, PointInfo>> & points, string name_, string bc)
|
||||
: name(name_)
|
||||
{
|
||||
Loop l;
|
||||
@ -1590,6 +1594,8 @@ Solid2d :: Solid2d(const Array<std::variant<Point<2>, EdgeInfo>> & points, strin
|
||||
l.Append(*point, true);
|
||||
if(auto edge_info = std::get_if<EdgeInfo>(&v))
|
||||
l.first->prev->info.Assign( *edge_info );
|
||||
if(auto point_info = std::get_if<PointInfo>(&v))
|
||||
l.first->prev->pinfo.Assign(*point_info);
|
||||
}
|
||||
|
||||
for(auto v : l.Vertices(ALL))
|
||||
@ -1849,17 +1855,20 @@ shared_ptr<netgen::SplineGeometry2d> CSG2d :: GenerateSplineGeometry()
|
||||
};
|
||||
|
||||
t_points.Start();
|
||||
auto insertPoint = [&](Point<2> p )
|
||||
auto insertPoint = [&](const Vertex& p )
|
||||
{
|
||||
int pi = getPoint(p);
|
||||
if(pi==-1)
|
||||
{
|
||||
// not found -> insert to tree
|
||||
netgen::GeomPoint<2> gp(p);
|
||||
gp.name = "default";
|
||||
geo->geompoints.Append(gp);
|
||||
pi = geo->geompoints.Size()-1;
|
||||
ptree.Insert(p,p,geo->geompoints.Size()-1);
|
||||
}
|
||||
geo->geompoints[pi].hmax = min2(geo->geompoints[pi].hmax, p.pinfo.maxh);
|
||||
if(p.pinfo.name != POINT_NAME_DEFAULT)
|
||||
geo->geompoints[pi].name = p.pinfo.name;
|
||||
};
|
||||
|
||||
for(auto & s : solids)
|
||||
|
@ -65,6 +65,7 @@ enum IteratorType
|
||||
};
|
||||
|
||||
inline constexpr const double MAXH_DEFAULT{1e99};
|
||||
inline const string POINT_NAME_DEFAULT{""};
|
||||
inline const string BC_DEFAULT{""};
|
||||
inline const string MAT_DEFAULT{""};
|
||||
|
||||
@ -93,6 +94,24 @@ struct EdgeInfo
|
||||
}
|
||||
};
|
||||
|
||||
struct PointInfo
|
||||
{
|
||||
double maxh = MAXH_DEFAULT;
|
||||
string name = POINT_NAME_DEFAULT;
|
||||
PointInfo() = default;
|
||||
PointInfo(const PointInfo& other) = default;
|
||||
PointInfo(double amaxh) : maxh(amaxh) {}
|
||||
PointInfo(string aname) : name(aname) {}
|
||||
PointInfo(double amaxh, string aname) : maxh(amaxh), name(aname) {}
|
||||
|
||||
void Assign(const PointInfo& other)
|
||||
{
|
||||
maxh = min(maxh, other.maxh);
|
||||
if(other.name != POINT_NAME_DEFAULT)
|
||||
name = other.name;
|
||||
}
|
||||
};
|
||||
|
||||
struct Vertex : Point<2>
|
||||
{
|
||||
Vertex (Point<2> p) : Point<2>(p) {}
|
||||
@ -100,6 +119,7 @@ struct Vertex : Point<2>
|
||||
{
|
||||
spline = v.spline;
|
||||
info = v.info;
|
||||
pinfo = v.pinfo;
|
||||
is_source = true;
|
||||
}
|
||||
|
||||
@ -117,6 +137,7 @@ struct Vertex : Point<2>
|
||||
// In case the edge this - next is curved, store the spline information here
|
||||
optional<Spline> spline = nullopt;
|
||||
EdgeInfo info;
|
||||
PointInfo pinfo;
|
||||
|
||||
DLL_HEADER Vertex * Insert(Point<2> p, double lam = -1.0);
|
||||
|
||||
@ -455,6 +476,7 @@ struct Loop
|
||||
{
|
||||
auto & vnew = Append( static_cast<Point<2>>(v), true );
|
||||
vnew.info = v.info;
|
||||
vnew.pinfo = v.pinfo;
|
||||
if(v.spline)
|
||||
vnew.spline = *v.spline;
|
||||
if(bbox)
|
||||
@ -628,7 +650,7 @@ struct Solid2d
|
||||
|
||||
Solid2d() = default;
|
||||
Solid2d(string name_) : name(name_) {}
|
||||
DLL_HEADER Solid2d(const Array<std::variant<Point<2>, EdgeInfo>> & points, string name_=MAT_DEFAULT, string bc_=BC_DEFAULT);
|
||||
DLL_HEADER Solid2d(const Array<std::variant<Point<2>, EdgeInfo, PointInfo>> & points, string name_=MAT_DEFAULT, string bc_=BC_DEFAULT);
|
||||
Solid2d(Solid2d && other) = default;
|
||||
Solid2d(const Solid2d & other) = default;
|
||||
|
||||
|
@ -399,7 +399,7 @@ DLL_HEADER void ExportGeom2d(py::module &m)
|
||||
|
||||
py::class_<Solid2d>(m, "Solid2d")
|
||||
.def(py::init<>())
|
||||
.def(py::init<Array<std::variant<Point<2>, EdgeInfo>>, std::string, std::string>(), py::arg("points"), py::arg("mat")=MAT_DEFAULT, py::arg("bc")=BC_DEFAULT)
|
||||
.def(py::init<Array<std::variant<Point<2>, EdgeInfo, PointInfo>>, std::string, std::string>(), py::arg("points"), py::arg("mat")=MAT_DEFAULT, py::arg("bc")=BC_DEFAULT)
|
||||
|
||||
.def(py::self+py::self)
|
||||
.def(py::self-py::self)
|
||||
@ -431,10 +431,10 @@ DLL_HEADER void ExportGeom2d(py::module &m)
|
||||
{
|
||||
using P = Point<2>;
|
||||
return { {
|
||||
p0, bottom ? *bottom : bc,
|
||||
P{p1[0],p0[1]}, right ? *right : bc,
|
||||
p1, top ? *top : bc,
|
||||
P{p0[0],p1[1]}, left ? *left : bc,
|
||||
p0, EdgeInfo{bottom ? *bottom : bc},
|
||||
P{p1[0],p0[1]}, EdgeInfo {right ? *right : bc},
|
||||
p1, EdgeInfo {top ? *top : bc},
|
||||
P{p0[0],p1[1]}, EdgeInfo {left ? *left : bc},
|
||||
}, mat};
|
||||
},
|
||||
"pmin"_a, "pmax"_a, "mat"_a=MAT_DEFAULT, "bc"_a=BC_DEFAULT,
|
||||
@ -475,6 +475,12 @@ DLL_HEADER void ExportGeom2d(py::module &m)
|
||||
.def(py::init<string>(), py::arg("bc"))
|
||||
.def(py::init<optional<Point<2>>, double, string>(), py::arg("control_point")=nullopt, py::arg("maxh")=MAXH_DEFAULT, py::arg("bc")=BC_DEFAULT)
|
||||
;
|
||||
py::class_<PointInfo>(m, "PointInfo")
|
||||
.def(py::init<>())
|
||||
.def(py::init<double>(), "maxh"_a)
|
||||
.def(py::init<string>(), "name"_a)
|
||||
.def(py::init<double, string>(), "maxh"_a, "name"_a)
|
||||
;
|
||||
}
|
||||
|
||||
PYBIND11_MODULE(libgeom2d, m) {
|
||||
|
@ -1,4 +1,4 @@
|
||||
from .libngpy._geom2d import SplineGeometry, Solid2d, CSG2d, Rectangle, Circle, EdgeInfo
|
||||
from .libngpy._geom2d import SplineGeometry, Solid2d, CSG2d, Rectangle, Circle, EdgeInfo, PointInfo
|
||||
from .meshing import meshsize
|
||||
|
||||
unit_square = SplineGeometry()
|
||||
|
Loading…
Reference in New Issue
Block a user