mirror of
https://github.com/NGSolve/netgen.git
synced 2024-12-25 05:20:34 +05:00
csg2d interface
This commit is contained in:
parent
8b14f399c1
commit
6199c7f66b
@ -1703,11 +1703,14 @@ Solid2d & Solid2d :: Move( Vec<2> v )
|
|||||||
return Transform( [v](Point<2> p) -> Point<2> { return p+v; } );
|
return Transform( [v](Point<2> p) -> Point<2> { return p+v; } );
|
||||||
}
|
}
|
||||||
|
|
||||||
Solid2d & Solid2d :: Scale( double sx, double sy )
|
Solid2d & Solid2d :: Scale( double s )
|
||||||
{
|
{
|
||||||
if(sy==0.0)
|
return Transform( [s](Point<2> p) -> Point<2> { return{p[0]*s, p[1]*s}; } );
|
||||||
sy=sx;
|
}
|
||||||
return Transform( [sx,sy](Point<2> p) -> Point<2> { return{p[0]*sx, p[1]*sy}; } );
|
|
||||||
|
Solid2d & Solid2d :: Scale( Vec<2> s )
|
||||||
|
{
|
||||||
|
return Transform( [s](Point<2> p) -> Point<2> { return{p[0]*s[0], p[1]*s[1]}; } );
|
||||||
}
|
}
|
||||||
|
|
||||||
Solid2d & Solid2d :: RotateRad( double ang, Point<2> center )
|
Solid2d & Solid2d :: RotateRad( double ang, Point<2> center )
|
||||||
@ -1720,8 +1723,8 @@ Solid2d & Solid2d :: RotateRad( double ang, Point<2> center )
|
|||||||
p -= c;
|
p -= c;
|
||||||
double x = p[0];
|
double x = p[0];
|
||||||
double y = p[1];
|
double y = p[1];
|
||||||
p[0] = cosa*x+sina*y;
|
p[0] = cosa*x-sina*y;
|
||||||
p[1] = -sina*x+cosa*y;
|
p[1] = sina*x+cosa*y;
|
||||||
p += c;
|
p += c;
|
||||||
return p;
|
return p;
|
||||||
} );
|
} );
|
||||||
|
@ -678,11 +678,12 @@ struct Solid2d
|
|||||||
}
|
}
|
||||||
|
|
||||||
Solid2d & Move( Vec<2> v );
|
Solid2d & Move( Vec<2> v );
|
||||||
Solid2d & Scale( double sx, double sy=0.0 );
|
Solid2d & Scale( double s );
|
||||||
|
Solid2d & Scale( Vec<2> s );
|
||||||
Solid2d & RotateRad( double ang, Point<2> center = {0,0} );
|
Solid2d & RotateRad( double ang, Point<2> center = {0,0} );
|
||||||
Solid2d & RotateDeg( double ang, Point<2> center = {0,0} )
|
Solid2d & RotateDeg( double ang, Point<2> center = {0,0} )
|
||||||
{
|
{
|
||||||
return RotateRad( ang/180.*M_PI );
|
return RotateRad( ang/180.*M_PI, center );
|
||||||
}
|
}
|
||||||
|
|
||||||
Solid2d & BC(string bc)
|
Solid2d & BC(string bc)
|
||||||
|
@ -414,16 +414,9 @@ DLL_HEADER void ExportGeom2d(py::module &m)
|
|||||||
|
|
||||||
.def("Copy", [](Solid2d & self) -> Solid2d { return self; })
|
.def("Copy", [](Solid2d & self) -> Solid2d { return self; })
|
||||||
.def("Move", &Solid2d::Move)
|
.def("Move", &Solid2d::Move)
|
||||||
.def("Scale", &Solid2d::Scale)
|
.def("Scale", static_cast<Solid2d& (Solid2d::*)(double)>(&Solid2d::Scale))
|
||||||
.def("Rotate", [](Solid2d & self, optional<double> rad, optional<double> deg, Point<2> center )
|
.def("Scale", static_cast<Solid2d& (Solid2d::*)(Vec<2>)>(&Solid2d::Scale))
|
||||||
{
|
.def("Rotate", &Solid2d::RotateDeg, py::arg("angle"), py::arg("center")=Point<2>{0,0})
|
||||||
if(rad)
|
|
||||||
self.RotateRad(*rad, center);
|
|
||||||
if(deg)
|
|
||||||
self.RotateDeg(*deg, center);
|
|
||||||
return self;
|
|
||||||
}, py::arg("rad")=nullopt, py::arg("deg")=nullopt, py::arg("center")=Point<2>{0,0})
|
|
||||||
|
|
||||||
;
|
;
|
||||||
|
|
||||||
|
|
||||||
|
@ -211,6 +211,10 @@ DLL_HEADER void ExportNetgenMeshing(py::module &m)
|
|||||||
|
|
||||||
py::class_<Vec<2>> (m, "Vec2d")
|
py::class_<Vec<2>> (m, "Vec2d")
|
||||||
.def(py::init<double,double>())
|
.def(py::init<double,double>())
|
||||||
|
.def(py::init( [] (std::pair<double,double> xy)
|
||||||
|
{
|
||||||
|
return Vec<2>{xy.first, xy.second};
|
||||||
|
}))
|
||||||
.def ("__str__", &ToString<Vec<3>>)
|
.def ("__str__", &ToString<Vec<3>>)
|
||||||
.def(py::self==py::self)
|
.def(py::self==py::self)
|
||||||
.def(py::self+py::self)
|
.def(py::self+py::self)
|
||||||
@ -223,6 +227,8 @@ DLL_HEADER void ExportNetgenMeshing(py::module &m)
|
|||||||
.def("__len__", [](Vec<2>& /*unused*/) { return 2; })
|
.def("__len__", [](Vec<2>& /*unused*/) { return 2; })
|
||||||
;
|
;
|
||||||
|
|
||||||
|
py::implicitly_convertible<py::tuple, Vec<2>>();
|
||||||
|
|
||||||
py::class_<Vec<3>> (m, "Vec3d")
|
py::class_<Vec<3>> (m, "Vec3d")
|
||||||
.def(py::init<double,double,double>())
|
.def(py::init<double,double,double>())
|
||||||
.def(py::init([](py::tuple v)
|
.def(py::init([](py::tuple v)
|
||||||
|
Loading…
Reference in New Issue
Block a user