unique-ptr for TangentialSolid

This commit is contained in:
Joachim Schöberl 2020-10-16 09:44:11 +02:00
parent 4f4483794d
commit 4d2e4fea44
5 changed files with 37 additions and 31 deletions

View File

@ -970,7 +970,7 @@ namespace netgen
for (int i = 0; i < geometry.GetNTopLevelObjects(); i++)
{
Solid * locsol;
// Solid * locsol;
if (geometry.GetTopLevelObject(i)->GetLayer() != layer)
continue;
@ -978,7 +978,8 @@ namespace netgen
const Solid * sol = geometry.GetTopLevelObject(i)->GetSolid();
const Surface * surf = geometry.GetTopLevelObject(i)->GetSurface();
sol -> TangentialSolid (hp, locsol, locsurfind, size*ideps);
// sol -> TangentialSolid (hp, locsol, locsurfind, size*ideps);
auto locsol = sol -> TangentialSolid (hp, locsurfind, size*ideps);
//*testout << "hp = " << hp << endl;
//(*testout) << "locsol: " << endl;
@ -995,7 +996,8 @@ namespace netgen
ReducePrimitiveIterator rpi(boxp);
UnReducePrimitiveIterator urpi;
((Solid*)locsol) -> IterateSolid (rpi);
// ((Solid*)locsol) -> IterateSolid (rpi);
locsol -> IterateSolid (rpi);
locsol -> CalcSurfaceInverse ();
@ -1020,7 +1022,8 @@ namespace netgen
}
}
((Solid*)locsol) -> IterateSolid (urpi);
// ((Solid*)locsol) -> IterateSolid (urpi);
locsol -> IterateSolid (urpi);
if (debug)
@ -1259,7 +1262,7 @@ namespace netgen
m *= -1;
}
}
delete locsol;
// delete locsol;
}
@ -1780,7 +1783,7 @@ namespace netgen
int nsurf = geometry.GetNSurf();
int layer = 0;
Solid * tansol;
// Solid * tansol;
NgArray<int> tansurfind;
double size = geometry.MaxSize();
@ -1838,7 +1841,8 @@ namespace netgen
continue;
const Solid * sol = geometry.GetTopLevelObject(j)->GetSolid();
sol -> TangentialSolid (p1, tansol, tansurfind, ideps*size);
// sol -> TangentialSolid (p1, tansol, tansurfind, ideps*size);
auto tansol = sol -> TangentialSolid (p1, tansurfind, ideps*size);
layer = geometry.GetTopLevelObject(j)->GetLayer();
@ -1868,7 +1872,7 @@ namespace netgen
// seg.invs1 = surfaces[i] -> Inverse();
// seg.invs2 = ! (surfaces[i] -> Inverse());
}
delete tansol;
// delete tansol;
}
}

View File

@ -168,7 +168,7 @@ void SingularPoint :: FindPoints (class Mesh & mesh)
for (int k = 1; k <= 3; k++)
{
const Solid * solk(NULL);
Solid *tansol;
// Solid *tansol;
switch (k)
{
case 1: solk = sol1; break;
@ -176,7 +176,7 @@ void SingularPoint :: FindPoints (class Mesh & mesh)
case 3: solk = sol3; break;
}
solk -> TangentialSolid (p, tansol, surfk, 1e-3);
auto tansol = solk -> TangentialSolid (p, surfk, 1e-3);
(*testout) << "Tansol = " << *tansol << endl;
if (!tansol) continue;
@ -195,7 +195,7 @@ void SingularPoint :: FindPoints (class Mesh & mesh)
if (!surf.Contains (surfk[i]))
surf.Append (surfk[i]);
delete tansol;
// delete tansol;
}
if (surf.Size() < 3) continue;

View File

@ -638,13 +638,15 @@ namespace netgen
}
void Solid :: TangentialSolid (const Point<3> & p, Solid *& tansol, NgArray<int> & surfids, double eps) const
unique_ptr<Solid> Solid :: TangentialSolid (const Point<3> & p, NgArray<int> & surfids, double eps) const
{
int in, strin;
Solid * tansol = nullptr;
RecTangentialSolid (p, tansol, surfids, in, strin, eps);
surfids.SetSize (0);
if (tansol)
tansol -> GetTangentialSurfaceIndices (p, surfids, eps);
return unique_ptr<Solid> (tansol);
}

View File

@ -114,7 +114,7 @@ namespace netgen
/// compute localization in point p
void TangentialSolid (const Point<3> & p, Solid *& tansol, NgArray<int> & surfids, double eps) const;
unique_ptr<Solid> TangentialSolid (const Point<3> & p, NgArray<int> & surfids, double eps) const;
/// compute localization in point p tangential to vector t
void TangentialSolid2 (const Point<3> & p, const Vec<3> & t,

View File

@ -289,8 +289,8 @@ namespace netgen
for (int j = 0; j < pts.Size(); j++)
if (Dist (pts[j], box.Center()) < box.Diam()/2)
{
Solid * tansol;
sol -> TangentialSolid (pts[j], tansol, surfids, 1e-9*size);
// Solid * tansol;
auto tansol = sol -> TangentialSolid (pts[j], surfids, 1e-9*size);
if(!tansol)
continue;
@ -314,7 +314,7 @@ namespace netgen
if (AddPoint (pts[j], layer))
(*testout) << "cross point found, 1: " << pts[j] << endl;
}
delete tansol;
// delete tansol;
}
}
@ -333,8 +333,8 @@ namespace netgen
for (int j = 0; j < pts.Size(); j++)
if (Dist (pts[j], box.Center()) < box.Diam()/2)
{
Solid * tansol;
sol -> TangentialSolid (pts[j], tansol, surfids, 1e-9*size);
// Solid * tansol;
auto tansol = sol -> TangentialSolid (pts[j], surfids, 1e-9*size);
if(!tansol)
continue;
@ -358,7 +358,7 @@ namespace netgen
if (AddPoint (pts[j], layer))
(*testout) << "cross point found, 2: " << pts[j] << endl;
}
delete tansol;
// delete tansol;
}
}
@ -372,15 +372,15 @@ namespace netgen
for (int j = 0; j < pts.Size(); j++)
if (Dist (pts[j], box.Center()) < box.Diam()/2)
{
Solid * tansol;
sol -> TangentialSolid (pts[j], tansol, surfids, 1e-9*size);
// Solid * tansol;
auto tansol = sol -> TangentialSolid (pts[j], surfids, 1e-9*size);
if (tansol)
// sol -> IsIn (pts[j], 1e-6*size) && !sol->IsStrictIn (pts[j], 1e-6*size) )
{
if (AddPoint (pts[j], layer))
(*testout) << "extremal point found, 1: " << pts[j] << endl;
}
delete tansol;
// delete tansol;
}
}
}
@ -409,8 +409,8 @@ namespace netgen
for (int j = 0; j < pts.Size(); j++)
if (Dist (pts[j], box.Center()) < box.Diam()/2)
{
Solid * tansol;
sol -> TangentialSolid (pts[j], tansol, surfids, 1e-9*size);
// Solid * tansol;
auto tansol = sol -> TangentialSolid (pts[j], surfids, 1e-9*size);
if(!tansol)
continue;
@ -434,7 +434,7 @@ namespace netgen
if (AddPoint (pts[j], layer))
(*testout) << "cross point found, 1: " << pts[j] << endl;
}
delete tansol;
// delete tansol;
}
}
@ -449,15 +449,15 @@ namespace netgen
for (int j = 0; j < pts.Size(); j++)
if (Dist (pts[j], box.Center()) < box.Diam()/2)
{
Solid * tansol;
sol -> TangentialSolid (pts[j], tansol, surfids, 1e-9*size);
// Solid * tansol;
auto tansol = sol -> TangentialSolid (pts[j], surfids, 1e-9*size);
if (tansol)
// sol -> IsIn (pts[j], 1e-6*size) && !sol->IsStrictIn (pts[j], 1e-6*size) )
{
if (AddPoint (pts[j], layer))
(*testout) << "extremal point found, spheres: " << pts[j] << endl;
}
delete tansol;
// delete tansol;
}
}
@ -1829,8 +1829,8 @@ namespace netgen
continue;
Solid * locsol;
sol -> TangentialSolid (p, locsol, surfind, ideps*geomsize);
// Solid * locsol;
auto locsol = sol -> TangentialSolid (p, surfind, ideps*geomsize);
rep_surfind.SetSize (surfind.Size());
@ -2158,7 +2158,7 @@ namespace netgen
}
delete locsol;
// delete locsol;
}
}