mirror of
https://github.com/NGSolve/netgen.git
synced 2024-12-24 21:10:33 +05:00
Merge branch 'revolution_splinegeo_sharedptr' into 'master'
Revolution should keep shared_ptr to splinegeo2d See merge request jschoeberl/netgen!387
This commit is contained in:
commit
bc0b5d538c
@ -479,7 +479,7 @@ namespace netgen
|
|||||||
}
|
}
|
||||||
|
|
||||||
Primitive * nprim = new Revolution(p0,p1,
|
Primitive * nprim = new Revolution(p0,p1,
|
||||||
*(geom->GetSplineCurve2d(spline)));
|
geom->GetSplineCurve2d(spline));
|
||||||
|
|
||||||
geom->AddSurfaces (nprim);
|
geom->AddSurfaces (nprim);
|
||||||
return new Solid(nprim);
|
return new Solid(nprim);
|
||||||
|
@ -323,13 +323,13 @@ DLL_HEADER void ExportCSG(py::module &m)
|
|||||||
Solid * sol = new Solid (torus);
|
Solid * sol = new Solid (torus);
|
||||||
return make_shared<SPSolid> (sol);
|
return make_shared<SPSolid> (sol);
|
||||||
}));
|
}));
|
||||||
m.def ("Revolution", FunctionPointer([](Point<3> p1, Point<3> p2,
|
m.def ("Revolution", [](Point<3> p1, Point<3> p2,
|
||||||
const SplineGeometry<2> & spline)
|
shared_ptr<SplineGeometry<2>> spline)
|
||||||
{
|
{
|
||||||
Revolution * rev = new Revolution (p1, p2, spline);
|
Revolution * rev = new Revolution (p1, p2, spline);
|
||||||
Solid * sol = new Solid(rev);
|
Solid * sol = new Solid(rev);
|
||||||
return make_shared<SPSolid> (sol);
|
return make_shared<SPSolid> (sol);
|
||||||
}));
|
});
|
||||||
m.def ("Extrusion", [](shared_ptr<SplineGeometry<3>> path,
|
m.def ("Extrusion", [](shared_ptr<SplineGeometry<3>> path,
|
||||||
shared_ptr<SplineGeometry<2>> profile,
|
shared_ptr<SplineGeometry<2>> profile,
|
||||||
Vec<3> d)
|
Vec<3> d)
|
||||||
|
@ -640,10 +640,10 @@ namespace netgen
|
|||||||
|
|
||||||
Revolution :: Revolution(const Point<3> & p0_in,
|
Revolution :: Revolution(const Point<3> & p0_in,
|
||||||
const Point<3> & p1_in,
|
const Point<3> & p1_in,
|
||||||
const SplineGeometry<2> & spline_in) :
|
shared_ptr<SplineGeometry<2>> spline_in) :
|
||||||
p0(p0_in), p1(p1_in)
|
p0(p0_in), p1(p1_in), splinegeo(spline_in)
|
||||||
{
|
{
|
||||||
auto nsplines = spline_in.GetNSplines();
|
auto nsplines = spline_in->GetNSplines();
|
||||||
surfaceactive.SetSize(0);
|
surfaceactive.SetSize(0);
|
||||||
surfaceids.SetSize(0);
|
surfaceids.SetSize(0);
|
||||||
|
|
||||||
@ -651,39 +651,39 @@ namespace netgen
|
|||||||
|
|
||||||
v_axis.Normalize();
|
v_axis.Normalize();
|
||||||
|
|
||||||
if(spline_in.GetSpline(0).StartPI()(1) <= 0. &&
|
if(spline_in->GetSpline(0).StartPI()(1) <= 0. &&
|
||||||
spline_in.GetSpline(nsplines-1).EndPI()(1) <= 0.)
|
spline_in->GetSpline(nsplines-1).EndPI()(1) <= 0.)
|
||||||
type = 2;
|
type = 2;
|
||||||
else if (Dist(spline_in.GetSpline(0).StartPI(),
|
else if (Dist(spline_in->GetSpline(0).StartPI(),
|
||||||
spline_in.GetSpline(nsplines-1).EndPI()) < 1e-7)
|
spline_in->GetSpline(nsplines-1).EndPI()) < 1e-7)
|
||||||
type = 1;
|
type = 1;
|
||||||
else
|
else
|
||||||
cerr << "Surface of revolution cannot be constructed" << endl;
|
cerr << "Surface of revolution cannot be constructed" << endl;
|
||||||
|
|
||||||
for(int i=0; i<spline_in.GetNSplines(); i++)
|
for(int i=0; i<spline_in->GetNSplines(); i++)
|
||||||
{
|
{
|
||||||
RevolutionFace * face = new RevolutionFace(spline_in.GetSpline(i),
|
faces.Append(new RevolutionFace
|
||||||
p0,v_axis,
|
(spline_in->GetSpline(i),
|
||||||
type==2 && i==0,
|
p0,v_axis,
|
||||||
type==2 && i==spline_in.GetNSplines()-1);
|
type==2 && i==0,
|
||||||
faces.Append(face);
|
type==2 && i==spline_in->GetNSplines()-1));
|
||||||
surfaceactive.Append(1);
|
surfaceactive.Append(1);
|
||||||
surfaceids.Append(0);
|
surfaceids.Append(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
// checking
|
// checking
|
||||||
if (type == 2)
|
if (type == 2)
|
||||||
{
|
{
|
||||||
auto t0 = spline_in.GetSpline(0).GetTangent(0);
|
auto t0 = spline_in->GetSpline(0).GetTangent(0);
|
||||||
cout << "tstart (must be vertically): " << t0 << endl;
|
cout << "tstart (must be vertically): " << t0 << endl;
|
||||||
|
|
||||||
auto tn = spline_in.GetSpline(nsplines-1).GetTangent(1);
|
auto tn = spline_in->GetSpline(nsplines-1).GetTangent(1);
|
||||||
cout << "tend (must be vertically): " << tn << endl;
|
cout << "tend (must be vertically): " << tn << endl;
|
||||||
|
|
||||||
for (int i = 0; i < nsplines-1; i++)
|
for (int i = 0; i < nsplines-1; i++)
|
||||||
{
|
{
|
||||||
auto ta = spline_in.GetSpline(i).GetTangent(1);
|
auto ta = spline_in->GetSpline(i).GetTangent(1);
|
||||||
auto tb = spline_in.GetSpline(i+1).GetTangent(0);
|
auto tb = spline_in->GetSpline(i+1).GetTangent(0);
|
||||||
cout << "sin (must not be 0) = " << abs(ta(0)*tb(1)-ta(1)*tb(0)) / (Abs(ta)*Abs(tb));
|
cout << "sin (must not be 0) = " << abs(ta(0)*tb(1)-ta(1)*tb(0)) / (Abs(ta)*Abs(tb));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -114,14 +114,15 @@ namespace netgen
|
|||||||
int type;
|
int type;
|
||||||
|
|
||||||
|
|
||||||
NgArray<RevolutionFace*> faces;
|
Array<RevolutionFace*> faces;
|
||||||
|
shared_ptr<SplineGeometry<2>> splinegeo;
|
||||||
|
|
||||||
mutable int intersecting_face;
|
mutable int intersecting_face;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Revolution(const Point<3> & p0_in,
|
Revolution(const Point<3> & p0_in,
|
||||||
const Point<3> & p1_in,
|
const Point<3> & p1_in,
|
||||||
const SplineGeometry<2> & spline_in);
|
shared_ptr<SplineGeometry<2>> spline_in);
|
||||||
// default constructor for archive
|
// default constructor for archive
|
||||||
Revolution() {}
|
Revolution() {}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user