mirror of
https://github.com/NGSolve/netgen.git
synced 2024-12-25 05:20:34 +05:00
csg splinecurves -> shared_ptr
This commit is contained in:
parent
2d9e32ba70
commit
7c6296f153
@ -176,9 +176,8 @@ namespace netgen
|
|||||||
|
|
||||||
solids.DeleteAll ();
|
solids.DeleteAll ();
|
||||||
|
|
||||||
for (int i = 0; i < splinecurves2d.Size(); i++)
|
|
||||||
delete splinecurves2d[i];
|
|
||||||
splinecurves2d.DeleteAll();
|
splinecurves2d.DeleteAll();
|
||||||
|
splinecurves3d.DeleteAll();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
for (int i = 0; i < surfaces.Size(); i++)
|
for (int i = 0; i < surfaces.Size(); i++)
|
||||||
@ -712,24 +711,24 @@ namespace netgen
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
void CSGeometry :: SetSplineCurve (const char * name, SplineGeometry<2> * spl)
|
void CSGeometry :: SetSplineCurve (const char * name, shared_ptr<SplineGeometry<2>> spl)
|
||||||
{
|
{
|
||||||
splinecurves2d.Set(name,spl);
|
splinecurves2d.Set(name,spl);
|
||||||
}
|
}
|
||||||
void CSGeometry :: SetSplineCurve (const char * name, SplineGeometry<3> * spl)
|
void CSGeometry :: SetSplineCurve (const char * name, shared_ptr<SplineGeometry<3>> spl)
|
||||||
{
|
{
|
||||||
splinecurves3d.Set(name,spl);
|
splinecurves3d.Set(name,spl);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const SplineGeometry<2> * CSGeometry :: GetSplineCurve2d (const string & name) const
|
shared_ptr<SplineGeometry<2>> CSGeometry :: GetSplineCurve2d (const string & name) const
|
||||||
{
|
{
|
||||||
if (splinecurves2d.Used(name))
|
if (splinecurves2d.Used(name))
|
||||||
return splinecurves2d[name];
|
return splinecurves2d[name];
|
||||||
else
|
else
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
const SplineGeometry<3> * CSGeometry :: GetSplineCurve3d (const string & name) const
|
shared_ptr<SplineGeometry<3>> CSGeometry :: GetSplineCurve3d (const string & name) const
|
||||||
{
|
{
|
||||||
if (splinecurves3d.Used(name))
|
if (splinecurves3d.Used(name))
|
||||||
return splinecurves3d[name];
|
return splinecurves3d[name];
|
||||||
|
@ -115,9 +115,9 @@ namespace netgen
|
|||||||
SymbolTable<Solid*> solids;
|
SymbolTable<Solid*> solids;
|
||||||
|
|
||||||
/// all 2d splinecurves
|
/// all 2d splinecurves
|
||||||
SymbolTable< SplineGeometry<2>* > splinecurves2d;
|
SymbolTable<shared_ptr<SplineGeometry<2>>> splinecurves2d;
|
||||||
/// all 3d splinecurves
|
/// all 3d splinecurves
|
||||||
SymbolTable< SplineGeometry<3>* > splinecurves3d;
|
SymbolTable<shared_ptr<SplineGeometry<3>>> splinecurves3d;
|
||||||
|
|
||||||
/// all top level objects: solids and surfaces
|
/// all top level objects: solids and surfaces
|
||||||
NgArray<TopLevelObject*> toplevelobjects;
|
NgArray<TopLevelObject*> toplevelobjects;
|
||||||
@ -232,10 +232,10 @@ namespace netgen
|
|||||||
const SymbolTable<Solid*> & GetSolids () const { return solids; }
|
const SymbolTable<Solid*> & GetSolids () const { return solids; }
|
||||||
|
|
||||||
|
|
||||||
void SetSplineCurve (const char * name, SplineGeometry<2> * spl);
|
void SetSplineCurve (const char * name, shared_ptr<SplineGeometry<2>> spl);
|
||||||
void SetSplineCurve (const char * name, SplineGeometry<3> * spl);
|
void SetSplineCurve (const char * name, shared_ptr<SplineGeometry<3>> spl);
|
||||||
const SplineGeometry<2> * GetSplineCurve2d (const string & name) const;
|
shared_ptr<SplineGeometry<2>> GetSplineCurve2d (const string & name) const;
|
||||||
const SplineGeometry<3> * GetSplineCurve3d (const string & name) const;
|
shared_ptr<SplineGeometry<3>> GetSplineCurve3d (const string & name) const;
|
||||||
|
|
||||||
void DoArchive(Archive& archive) override;
|
void DoArchive(Archive& archive) override;
|
||||||
|
|
||||||
|
@ -511,8 +511,8 @@ namespace netgen
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
Primitive * nprim = new Extrusion(*(geom->GetSplineCurve3d(epath)),
|
Primitive * nprim = new Extrusion(geom->GetSplineCurve3d(epath),
|
||||||
*(geom->GetSplineCurve2d(profile)),
|
geom->GetSplineCurve2d(profile),
|
||||||
z_dir);
|
z_dir);
|
||||||
geom->AddSurfaces (nprim);
|
geom->AddSurfaces (nprim);
|
||||||
return new Solid(nprim);
|
return new Solid(nprim);
|
||||||
@ -1186,7 +1186,7 @@ namespace netgen
|
|||||||
ParseChar (scan, '=');
|
ParseChar (scan, '=');
|
||||||
ParseChar (scan, '(');
|
ParseChar (scan, '(');
|
||||||
|
|
||||||
SplineGeometry<2> * newspline = new SplineGeometry<2>;
|
auto newspline = make_shared<SplineGeometry<2>>();
|
||||||
// newspline->CSGLoad(scan);
|
// newspline->CSGLoad(scan);
|
||||||
LoadSpline (*newspline, scan);
|
LoadSpline (*newspline, scan);
|
||||||
|
|
||||||
@ -1212,7 +1212,7 @@ namespace netgen
|
|||||||
ParseChar (scan, '=');
|
ParseChar (scan, '=');
|
||||||
ParseChar (scan, '(');
|
ParseChar (scan, '(');
|
||||||
|
|
||||||
SplineGeometry<3> * newspline = new SplineGeometry<3>;
|
auto newspline = make_shared<SplineGeometry<3>>();
|
||||||
// newspline->CSGLoad(scan);
|
// newspline->CSGLoad(scan);
|
||||||
LoadSpline (*newspline, scan);
|
LoadSpline (*newspline, scan);
|
||||||
|
|
||||||
|
@ -658,18 +658,18 @@ namespace netgen
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Extrusion :: Extrusion(const SplineGeometry<3> & path_in,
|
Extrusion :: Extrusion(shared_ptr<SplineGeometry<3>> path_in,
|
||||||
const SplineGeometry<2> & profile_in,
|
shared_ptr<SplineGeometry<2>> profile_in,
|
||||||
const Vec<3> & z_dir) :
|
const Vec<3> & z_dir) :
|
||||||
path(&path_in), profile(&profile_in), z_direction(z_dir)
|
path(path_in), profile(profile_in), z_direction(z_dir)
|
||||||
{
|
{
|
||||||
surfaceactive.SetSize(0);
|
surfaceactive.SetSize(0);
|
||||||
surfaceids.SetSize(0);
|
surfaceids.SetSize(0);
|
||||||
|
|
||||||
for(int j=0; j<profile->GetNSplines(); j++)
|
for(int j=0; j<profile->GetNSplines(); j++)
|
||||||
{
|
{
|
||||||
ExtrusionFace * face = new ExtrusionFace(&((*profile).GetSpline(j)),
|
ExtrusionFace * face = new ExtrusionFace(&(profile->GetSpline(j)),
|
||||||
path,
|
path.get(),
|
||||||
z_direction);
|
z_direction);
|
||||||
faces.Append(face);
|
faces.Append(face);
|
||||||
surfaceactive.Append(true);
|
surfaceactive.Append(true);
|
||||||
|
@ -121,8 +121,8 @@ namespace netgen
|
|||||||
class Extrusion : public Primitive
|
class Extrusion : public Primitive
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
const SplineGeometry<3>* path;
|
shared_ptr<SplineGeometry<3>> path;
|
||||||
const SplineGeometry<2>* profile; // closed, clockwise oriented curve
|
shared_ptr<SplineGeometry<2>> profile; // closed, clockwise oriented curve
|
||||||
|
|
||||||
Vec<3> z_direction;
|
Vec<3> z_direction;
|
||||||
|
|
||||||
@ -131,8 +131,8 @@ namespace netgen
|
|||||||
mutable int latestfacenum;
|
mutable int latestfacenum;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Extrusion(const SplineGeometry<3> & path_in,
|
Extrusion(shared_ptr<SplineGeometry<3>> path_in,
|
||||||
const SplineGeometry<2> & profile_in,
|
shared_ptr<SplineGeometry<2>> profile_in,
|
||||||
const Vec<3> & z_dir);
|
const Vec<3> & z_dir);
|
||||||
// default constructor for archive
|
// default constructor for archive
|
||||||
Extrusion() {}
|
Extrusion() {}
|
||||||
|
@ -170,7 +170,8 @@ namespace netgen
|
|||||||
|
|
||||||
DLL_HEADER void ExportCSG(py::module &m)
|
DLL_HEADER void ExportCSG(py::module &m)
|
||||||
{
|
{
|
||||||
py::class_<SplineGeometry<2>> (m, "SplineCurve2d")
|
py::class_<SplineGeometry<2>, shared_ptr<SplineGeometry<2>>>
|
||||||
|
(m, "SplineCurve2d")
|
||||||
.def(py::init<>())
|
.def(py::init<>())
|
||||||
.def ("AddPoint", FunctionPointer
|
.def ("AddPoint", FunctionPointer
|
||||||
([] (SplineGeometry<2> & self, double x, double y)
|
([] (SplineGeometry<2> & self, double x, double y)
|
||||||
@ -329,8 +330,8 @@ DLL_HEADER void ExportCSG(py::module &m)
|
|||||||
Solid * sol = new Solid(rev);
|
Solid * sol = new Solid(rev);
|
||||||
return make_shared<SPSolid> (sol);
|
return make_shared<SPSolid> (sol);
|
||||||
}));
|
}));
|
||||||
m.def ("Extrusion", FunctionPointer([](const SplineGeometry<3> & path,
|
m.def ("Extrusion", FunctionPointer([](shared_ptr<SplineGeometry<3>> path,
|
||||||
const SplineGeometry<2> & profile,
|
shared_ptr<SplineGeometry<2>> profile,
|
||||||
Vec<3> n)
|
Vec<3> n)
|
||||||
{
|
{
|
||||||
Extrusion * extr = new Extrusion (path,profile,n);
|
Extrusion * extr = new Extrusion (path,profile,n);
|
||||||
|
Loading…
Reference in New Issue
Block a user