mirror of
https://github.com/NGSolve/netgen.git
synced 2024-12-25 05:20:34 +05:00
python, shared ptr
This commit is contained in:
parent
3b5a612ddf
commit
4dda85ac90
@ -129,11 +129,11 @@ namespace netgen
|
|||||||
|
|
||||||
|
|
||||||
extern int CSGGenerateMesh (CSGeometry & geom,
|
extern int CSGGenerateMesh (CSGeometry & geom,
|
||||||
Mesh *& mesh, MeshingParameters & mparam,
|
shared_ptr<Mesh> & mesh, MeshingParameters & mparam,
|
||||||
int perfstepsstart, int perfstepsend);
|
int perfstepsstart, int perfstepsend);
|
||||||
|
|
||||||
|
|
||||||
int CSGeometry :: GenerateMesh (Mesh*& mesh, MeshingParameters & mparam,
|
int CSGeometry :: GenerateMesh (shared_ptr<Mesh> & mesh, MeshingParameters & mparam,
|
||||||
int perfstepsstart, int perfstepsend)
|
int perfstepsstart, int perfstepsend)
|
||||||
{
|
{
|
||||||
return CSGGenerateMesh (*this, mesh, mparam, perfstepsstart, perfstepsend);
|
return CSGGenerateMesh (*this, mesh, mparam, perfstepsstart, perfstepsend);
|
||||||
@ -182,7 +182,7 @@ namespace netgen
|
|||||||
|
|
||||||
void CSGeometry :: Save (string filename) const
|
void CSGeometry :: Save (string filename) const
|
||||||
{
|
{
|
||||||
fstream ost (filename.c_str());
|
ofstream ost (filename.c_str());
|
||||||
Save (ost);
|
Save (ost);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -313,7 +313,7 @@ namespace netgen
|
|||||||
|
|
||||||
Array<BCModification> bcmodifications;
|
Array<BCModification> bcmodifications;
|
||||||
|
|
||||||
virtual int GenerateMesh (Mesh*& mesh, MeshingParameters & mparam,
|
virtual int GenerateMesh (shared_ptr<Mesh> & mesh, MeshingParameters & mparam,
|
||||||
int perfstepsstart, int perfstepsend);
|
int perfstepsstart, int perfstepsend);
|
||||||
|
|
||||||
virtual const Refinement & GetRefinement () const;
|
virtual const Refinement & GetRefinement () const;
|
||||||
|
@ -653,7 +653,7 @@ namespace netgen
|
|||||||
|
|
||||||
|
|
||||||
int CSGGenerateMesh (CSGeometry & geom,
|
int CSGGenerateMesh (CSGeometry & geom,
|
||||||
Mesh *& mesh, MeshingParameters & mparam,
|
shared_ptr<Mesh> & mesh, MeshingParameters & mparam,
|
||||||
int perfstepsstart, int perfstepsend)
|
int perfstepsstart, int perfstepsend)
|
||||||
{
|
{
|
||||||
if (mesh && mesh->GetNSE() &&
|
if (mesh && mesh->GetNSE() &&
|
||||||
@ -668,7 +668,7 @@ namespace netgen
|
|||||||
if (mesh)
|
if (mesh)
|
||||||
mesh -> DeleteMesh();
|
mesh -> DeleteMesh();
|
||||||
else
|
else
|
||||||
mesh = new Mesh();
|
mesh = make_shared<Mesh>();
|
||||||
|
|
||||||
mesh->SetGlobalH (mparam.maxh);
|
mesh->SetGlobalH (mparam.maxh);
|
||||||
mesh->SetMinimalH (mparam.minh);
|
mesh->SetMinimalH (mparam.minh);
|
||||||
|
@ -46,7 +46,10 @@ public:
|
|||||||
enum optyp { TERM, SECTION, UNION, SUB };
|
enum optyp { TERM, SECTION, UNION, SUB };
|
||||||
|
|
||||||
SPSolid (Solid * as) : solid(as), owner(true), op(TERM) { ; }
|
SPSolid (Solid * as) : solid(as), owner(true), op(TERM) { ; }
|
||||||
|
~SPSolid ()
|
||||||
|
{
|
||||||
|
if (owner) delete solid;
|
||||||
|
}
|
||||||
SPSolid (optyp aop, shared_ptr<SPSolid> as1, shared_ptr<SPSolid> as2)
|
SPSolid (optyp aop, shared_ptr<SPSolid> as1, shared_ptr<SPSolid> as2)
|
||||||
: s1(as1), s2(as2), owner(true), op(aop)
|
: s1(as1), s2(as2), owner(true), op(aop)
|
||||||
{
|
{
|
||||||
@ -55,7 +58,7 @@ public:
|
|||||||
else if (aop == SECTION)
|
else if (aop == SECTION)
|
||||||
solid = new Solid (Solid::SECTION, s1->GetSolid(), s2->GetSolid());
|
solid = new Solid (Solid::SECTION, s1->GetSolid(), s2->GetSolid());
|
||||||
else if (aop == SUB)
|
else if (aop == SUB)
|
||||||
solid = new Solid (Solid::SUB, s1->GetSolid(), s2->GetSolid());
|
solid = new Solid (Solid::SUB, s1->GetSolid()); // , s2->GetSolid());
|
||||||
}
|
}
|
||||||
|
|
||||||
Solid * GetSolid() { return solid; }
|
Solid * GetSolid() { return solid; }
|
||||||
@ -106,7 +109,9 @@ void ExportCSG()
|
|||||||
;
|
;
|
||||||
|
|
||||||
bp::class_<Point<3>> ("Point3d", bp::init<double,double,double>())
|
bp::class_<Point<3>> ("Point3d", bp::init<double,double,double>())
|
||||||
|
.def(bp::self-bp::self)
|
||||||
.def(bp::self+Vec<3>())
|
.def(bp::self+Vec<3>())
|
||||||
|
.def(bp::self-Vec<3>())
|
||||||
;
|
;
|
||||||
|
|
||||||
bp::def ("Pnt", FunctionPointer( [] (double x, double y, double z) { return Point<3>(x,y,z); } ) );
|
bp::def ("Pnt", FunctionPointer( [] (double x, double y, double z) { return Point<3>(x,y,z); } ) );
|
||||||
@ -132,24 +137,30 @@ void ExportCSG()
|
|||||||
bp::class_<SPSolid, shared_ptr<SPSolid>, boost::noncopyable> ("Solid", bp::no_init)
|
bp::class_<SPSolid, shared_ptr<SPSolid>, boost::noncopyable> ("Solid", bp::no_init)
|
||||||
.def ("__add__", FunctionPointer( [] ( shared_ptr<SPSolid> self, shared_ptr<SPSolid> other ) { return make_shared<SPSolid> (SPSolid::UNION, self, other); } ) )
|
.def ("__add__", FunctionPointer( [] ( shared_ptr<SPSolid> self, shared_ptr<SPSolid> other ) { return make_shared<SPSolid> (SPSolid::UNION, self, other); } ) )
|
||||||
.def ("__mul__", FunctionPointer( [] ( shared_ptr<SPSolid> self, shared_ptr<SPSolid> other ) { return make_shared<SPSolid> (SPSolid::SECTION, self, other); } ) )
|
.def ("__mul__", FunctionPointer( [] ( shared_ptr<SPSolid> self, shared_ptr<SPSolid> other ) { return make_shared<SPSolid> (SPSolid::SECTION, self, other); } ) )
|
||||||
.def ("__sub__", FunctionPointer( [] ( shared_ptr<SPSolid> self, shared_ptr<SPSolid> other ) { return make_shared<SPSolid> (SPSolid::SUB, self, other); } ) )
|
.def ("__sub__", FunctionPointer( [] ( shared_ptr<SPSolid> self, shared_ptr<SPSolid> other )
|
||||||
|
{ return make_shared<SPSolid> (SPSolid::SECTION, self, make_shared<SPSolid> (SPSolid::SUB, other, nullptr)); } ) )
|
||||||
// .def ("__neg__", FunctionPointer( [] ( shared_ptr<SPSolid> self ) { return make_shared<SPSolid> (SPSolid::SUB, self); } ) ) COMPLEMENT?
|
// .def ("__neg__", FunctionPointer( [] ( shared_ptr<SPSolid> self ) { return make_shared<SPSolid> (SPSolid::SUB, self); } ) ) COMPLEMENT?
|
||||||
;
|
;
|
||||||
|
|
||||||
bp::def ("Sphere", FunctionPointer([](const Point<3> c, double r)
|
bp::def ("Sphere", FunctionPointer([](Point<3> c, double r)
|
||||||
{
|
{
|
||||||
Sphere * sp = new Sphere (c, r);
|
Sphere * sp = new Sphere (c, r);
|
||||||
Solid * sol = new Solid (sp);
|
Solid * sol = new Solid (sp);
|
||||||
return make_shared<SPSolid> (sol);
|
return make_shared<SPSolid> (sol);
|
||||||
}));
|
}));
|
||||||
bp::def ("Plane", FunctionPointer([](const Point<3> p, Vec<3> n)
|
bp::def ("Plane", FunctionPointer([](Point<3> p, Vec<3> n)
|
||||||
{
|
{
|
||||||
Plane * sp = new Plane (p,n);
|
Plane * sp = new Plane (p,n);
|
||||||
Solid * sol = new Solid (sp);
|
Solid * sol = new Solid (sp);
|
||||||
return make_shared<SPSolid> (sol);
|
return make_shared<SPSolid> (sol);
|
||||||
}));
|
}));
|
||||||
|
bp::def ("Cylinder", FunctionPointer([](Point<3> a, Point<3> b, double r)
|
||||||
bp::def ("OrthoBrick", FunctionPointer([](const Point<3> p1, Point<3> p2)
|
{
|
||||||
|
Cylinder * cyl = new Cylinder (a, b, r);
|
||||||
|
Solid * sol = new Solid (cyl);
|
||||||
|
return make_shared<SPSolid> (sol);
|
||||||
|
}));
|
||||||
|
bp::def ("OrthoBrick", FunctionPointer([](Point<3> p1, Point<3> p2)
|
||||||
{
|
{
|
||||||
OrthoBrick * brick = new OrthoBrick (p1,p2);
|
OrthoBrick * brick = new OrthoBrick (p1,p2);
|
||||||
Solid * sol = new Solid (brick);
|
Solid * sol = new Solid (brick);
|
||||||
@ -177,6 +188,11 @@ void ExportCSG()
|
|||||||
return geom;
|
return geom;
|
||||||
})))
|
})))
|
||||||
|
|
||||||
|
.def("Save", FunctionPointer([] (CSGeometry & self, string filename)
|
||||||
|
{
|
||||||
|
cout << "save geometry to file " << filename << endl;
|
||||||
|
self.Save (filename);
|
||||||
|
}))
|
||||||
.def("Add", FunctionPointer([] (CSGeometry & self, shared_ptr<SPSolid> solid)
|
.def("Add", FunctionPointer([] (CSGeometry & self, shared_ptr<SPSolid> solid)
|
||||||
{
|
{
|
||||||
solid->AddSurfaces (self);
|
solid->AddSurfaces (self);
|
||||||
@ -190,11 +206,11 @@ void ExportCSG()
|
|||||||
bp::def("GenerateMesh", FunctionPointer
|
bp::def("GenerateMesh", FunctionPointer
|
||||||
([](CSGeometry & geo, MeshingParameters & param)
|
([](CSGeometry & geo, MeshingParameters & param)
|
||||||
{
|
{
|
||||||
Mesh * dummy = NULL;
|
shared_ptr<Mesh> dummy;
|
||||||
cout << "Genrate Mesh, params = "; // << param << endl;
|
cout << "Genrate Mesh, params = "; // << param << endl;
|
||||||
geo.FindIdenticSurfaces(1e-8 * geo.MaxSize());
|
geo.FindIdenticSurfaces(1e-8 * geo.MaxSize());
|
||||||
geo.GenerateMesh (dummy, param, 0, 6);
|
geo.GenerateMesh (dummy, param, 0, 6);
|
||||||
return shared_ptr<Mesh> (dummy);
|
return dummy;
|
||||||
}));
|
}));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -22,10 +22,6 @@ namespace netgen
|
|||||||
extern Array<Box<3> > boxes;
|
extern Array<Box<3> > boxes;
|
||||||
|
|
||||||
|
|
||||||
extern Array<Point<3> > project1, project2;
|
|
||||||
|
|
||||||
|
|
||||||
// extern AutoPtr<CSGeometry> geometry;
|
|
||||||
|
|
||||||
|
|
||||||
VisualSceneGeometry :: VisualSceneGeometry ()
|
VisualSceneGeometry :: VisualSceneGeometry ()
|
||||||
|
@ -350,7 +350,7 @@ namespace netgen
|
|||||||
|
|
||||||
|
|
||||||
void MeshFromSpline2D (SplineGeometry2d & geometry,
|
void MeshFromSpline2D (SplineGeometry2d & geometry,
|
||||||
Mesh *& mesh,
|
shared_ptr<Mesh> & mesh,
|
||||||
MeshingParameters & mp)
|
MeshingParameters & mp)
|
||||||
{
|
{
|
||||||
PrintMessage (1, "Generate Mesh from spline geometry");
|
PrintMessage (1, "Generate Mesh from spline geometry");
|
||||||
@ -365,7 +365,7 @@ namespace netgen
|
|||||||
mp.maxh = h;
|
mp.maxh = h;
|
||||||
}
|
}
|
||||||
|
|
||||||
mesh = new Mesh;
|
mesh = make_shared<Mesh>();
|
||||||
mesh->SetDimension (2);
|
mesh->SetDimension (2);
|
||||||
|
|
||||||
Point3d pmin(bbox.PMin()(0), bbox.PMin()(1), -bbox.Diam());
|
Point3d pmin(bbox.PMin()(0), bbox.PMin()(1), -bbox.Diam());
|
||||||
|
@ -928,11 +928,11 @@ namespace netgen
|
|||||||
|
|
||||||
|
|
||||||
extern void MeshFromSpline2D (SplineGeometry2d & geometry,
|
extern void MeshFromSpline2D (SplineGeometry2d & geometry,
|
||||||
Mesh *& mesh,
|
shared_ptr<Mesh> & mesh,
|
||||||
MeshingParameters & mp);
|
MeshingParameters & mp);
|
||||||
|
|
||||||
|
|
||||||
int SplineGeometry2d :: GenerateMesh (Mesh*& mesh, MeshingParameters & mparam,
|
int SplineGeometry2d :: GenerateMesh (shared_ptr<Mesh> & mesh, MeshingParameters & mparam,
|
||||||
int perfstepsstart, int perfstepsend)
|
int perfstepsstart, int perfstepsend)
|
||||||
{
|
{
|
||||||
MeshFromSpline2D (*this, mesh, mparam);
|
MeshFromSpline2D (*this, mesh, mparam);
|
||||||
|
@ -151,7 +151,7 @@ namespace netgen
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
DLL_HEADER virtual int GenerateMesh (Mesh*& mesh, MeshingParameters & mparam,
|
DLL_HEADER virtual int GenerateMesh (shared_ptr<Mesh> & mesh, MeshingParameters & mparam,
|
||||||
int perfstepsstart, int perfstepsend);
|
int perfstepsstart, int perfstepsend);
|
||||||
|
|
||||||
void PartitionBoundary (MeshingParameters & mp, double h, Mesh & mesh2d);
|
void PartitionBoundary (MeshingParameters & mp, double h, Mesh & mesh2d);
|
||||||
|
@ -95,7 +95,7 @@ public:
|
|||||||
|
|
||||||
|
|
||||||
void MeshFromSpline2D (SplineGeometry2d & geometry,
|
void MeshFromSpline2D (SplineGeometry2d & geometry,
|
||||||
Mesh *& mesh,
|
shared_ptr<Mesh> & mesh,
|
||||||
MeshingParameters & mp);
|
MeshingParameters & mp);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -14,7 +14,7 @@ namespace netgen
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
int NetgenGeometry :: GenerateMesh (Mesh*& mesh, MeshingParameters & mparam,
|
int NetgenGeometry :: GenerateMesh (shared_ptr<Mesh> & mesh, MeshingParameters & mparam,
|
||||||
int perfstepsstart, int perfstepsend)
|
int perfstepsstart, int perfstepsend)
|
||||||
{
|
{
|
||||||
if (!mesh) return 1;
|
if (!mesh) return 1;
|
||||||
|
@ -18,7 +18,7 @@ namespace netgen
|
|||||||
public:
|
public:
|
||||||
virtual ~NetgenGeometry () { ; }
|
virtual ~NetgenGeometry () { ; }
|
||||||
|
|
||||||
virtual int GenerateMesh (Mesh*& mesh, MeshingParameters & mparam,
|
virtual int GenerateMesh (shared_ptr<Mesh> & mesh, MeshingParameters & mparam,
|
||||||
int perfstepsstart, int perfstepsend);
|
int perfstepsstart, int perfstepsend);
|
||||||
|
|
||||||
virtual const Refinement & GetRefinement () const;
|
virtual const Refinement & GetRefinement () const;
|
||||||
|
@ -85,12 +85,14 @@ void ExportNetgenMeshing()
|
|||||||
.add_property("nr", &PointIndex::operator int)
|
.add_property("nr", &PointIndex::operator int)
|
||||||
;
|
;
|
||||||
|
|
||||||
|
/*
|
||||||
bp::class_<Point<3>> ("Point")
|
bp::class_<Point<3>> ("Point")
|
||||||
.def(bp::init<double,double,double>())
|
.def(bp::init<double,double,double>())
|
||||||
;
|
;
|
||||||
|
*/
|
||||||
|
|
||||||
bp::class_<MeshPoint,bp::bases<Point<3>>>("MeshPoint")
|
bp::class_<MeshPoint /* ,bp::bases<Point<3>> */ >("MeshPoint")
|
||||||
.def(bp::init<Point<3>>())
|
// .def(bp::init<Point<3>>())
|
||||||
.add_property("p", FunctionPointer([](const MeshPoint & self)
|
.add_property("p", FunctionPointer([](const MeshPoint & self)
|
||||||
{
|
{
|
||||||
bp::list l;
|
bp::list l;
|
||||||
|
@ -91,7 +91,7 @@ void STLGeometry :: Save (string filename) const
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
int STLGeometry :: GenerateMesh (Mesh*& mesh, MeshingParameters & mparam,
|
int STLGeometry :: GenerateMesh (shared_ptr<Mesh> & mesh, MeshingParameters & mparam,
|
||||||
int perfstepsstart, int perfstepsend)
|
int perfstepsstart, int perfstepsend)
|
||||||
{
|
{
|
||||||
return STLMeshingDummy (this, mesh, mparam, perfstepsstart, perfstepsend);
|
return STLMeshingDummy (this, mesh, mparam, perfstepsstart, perfstepsend);
|
||||||
|
@ -452,7 +452,7 @@ namespace netgen
|
|||||||
friend class MeshingSTLSurface;
|
friend class MeshingSTLSurface;
|
||||||
|
|
||||||
|
|
||||||
virtual int GenerateMesh (Mesh*& mesh, MeshingParameters & mparam,
|
virtual int GenerateMesh (shared_ptr<Mesh> & mesh, MeshingParameters & mparam,
|
||||||
int perfstepsstart, int perfstepsend);
|
int perfstepsstart, int perfstepsend);
|
||||||
|
|
||||||
virtual const Refinement & GetRefinement () const;
|
virtual const Refinement & GetRefinement () const;
|
||||||
@ -463,7 +463,7 @@ namespace netgen
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
extern int STLMeshingDummy (STLGeometry* stlgeometry, Mesh*& mesh, MeshingParameters & mparam,
|
extern int STLMeshingDummy (STLGeometry* stlgeometry, shared_ptr<Mesh> & mesh, MeshingParameters & mparam,
|
||||||
int perfstepsstart, int perfstepsend);
|
int perfstepsstart, int perfstepsend);
|
||||||
|
|
||||||
|
|
||||||
|
@ -1329,7 +1329,7 @@ void STLGeometry :: RestrictHChartDistOneChart(int chartnum, Array<int>& acttrig
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int STLMeshingDummy (STLGeometry* stlgeometry, Mesh*& mesh, MeshingParameters & mparam,
|
int STLMeshingDummy (STLGeometry* stlgeometry, shared_ptr<Mesh> & mesh, MeshingParameters & mparam,
|
||||||
int perfstepsstart, int perfstepsend)
|
int perfstepsstart, int perfstepsend)
|
||||||
{
|
{
|
||||||
if (perfstepsstart > perfstepsend) return 0;
|
if (perfstepsstart > perfstepsend) return 0;
|
||||||
@ -1341,7 +1341,7 @@ int STLMeshingDummy (STLGeometry* stlgeometry, Mesh*& mesh, MeshingParameters &
|
|||||||
if (perfstepsstart <= MESHCONST_MESHEDGES)
|
if (perfstepsstart <= MESHCONST_MESHEDGES)
|
||||||
{
|
{
|
||||||
|
|
||||||
mesh = new Mesh();
|
mesh = make_shared<Mesh>();
|
||||||
mesh->geomtype = Mesh::GEOM_STL;
|
mesh->geomtype = Mesh::GEOM_STL;
|
||||||
|
|
||||||
mesh -> SetGlobalH (mparam.maxh);
|
mesh -> SetGlobalH (mparam.maxh);
|
||||||
|
Loading…
Reference in New Issue
Block a user