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