use Array instead of std::vector

This commit is contained in:
Christopher Lackner 2017-02-27 11:32:42 +01:00
parent 87669acfc6
commit 58555b96d9
4 changed files with 25 additions and 25 deletions

View File

@ -144,7 +144,7 @@ namespace netgen
string filename;
/// store splinesurfaces, such that added ones do not get deleted before geometry does
std::vector<shared_ptr<SplineSurface>> spline_surfaces;
Array<shared_ptr<SplineSurface>> spline_surfaces;
public:
CSGeometry ();
@ -320,7 +320,7 @@ namespace netgen
virtual const Refinement & GetRefinement () const;
void AddSplineSurface (shared_ptr<SplineSurface> ss) { spline_surfaces.push_back(ss); }
void AddSplineSurface (shared_ptr<SplineSurface> ss) { spline_surfaces.Append(ss); }
};

View File

@ -211,7 +211,7 @@ DLL_HEADER void ExportCSG(py::module &m)
.def("__init__", FunctionPointer ([](SplineSurface* instance, shared_ptr<SPSolid> base, py::list cuts)
{
auto primitive = dynamic_cast<OneSurfacePrimitive*> (base->GetSolid()->GetPrimitive());
auto acuts = make_shared<std::vector<shared_ptr<OneSurfacePrimitive>>>();
auto acuts = make_shared<Array<shared_ptr<OneSurfacePrimitive>>>();
for(int i = 0; i<py::len(cuts);i++)
{
py::extract<shared_ptr<SPSolid>> sps(cuts[i]);
@ -219,7 +219,7 @@ DLL_HEADER void ExportCSG(py::module &m)
throw NgException("Cut must be SurfacePrimitive in constructor of SplineSurface!");
auto sp = dynamic_cast<OneSurfacePrimitive*>(sps()->GetSolid()->GetPrimitive());
if(sp)
acuts->push_back(shared_ptr<OneSurfacePrimitive>(sp));
acuts->Append(shared_ptr<OneSurfacePrimitive>(sp));
else
throw NgException("Cut must be SurfacePrimitive in constructor of SplineSurface!");
}

View File

@ -6,14 +6,14 @@ namespace netgen
void SplineSurface :: AppendPoint(const Point<3> & p, const double reffac, const bool hpref)
{
auto pp = Point<3>(p);
geompoints.push_back(GeomPoint<3>(pp,reffac));
geompoints.back().hpref = hpref;
geompoints.Append(GeomPoint<3>(pp,reffac));
geompoints.Last().hpref = hpref;
}
void SplineSurface :: AppendSegment(shared_ptr<SplineSeg<3>> sp, string & bcname, double amaxh)
{
splines.push_back(sp);
bcnames.push_back(bcname);
splines.Append(sp);
bcnames.Append(bcname);
maxh.Append(amaxh);
}
@ -21,7 +21,7 @@ void SplineSurface :: AppendPoint(const Point<3> & p, const double reffac, const
{
double eps = 1e-5;
for(int i=0; i<splines.size(); i++)
for(int i=0; i<splines.Size(); i++)
{
auto pp1 = Point<3>(splines[i]->GetPoint(0));
Project(pp1);
@ -35,14 +35,14 @@ void SplineSurface :: AppendPoint(const Point<3> & p, const double reffac, const
return "default";
}
const shared_ptr<std::vector<shared_ptr<OneSurfacePrimitive>>> SplineSurface :: CreateCuttingSurfaces()
const shared_ptr<Array<shared_ptr<OneSurfacePrimitive>>> SplineSurface :: CreateCuttingSurfaces()
{
if(all_cuts)
return all_cuts;
auto cuttings = make_shared<std::vector<shared_ptr<OneSurfacePrimitive>>>();
auto cuttings = make_shared<Array<shared_ptr<OneSurfacePrimitive>>>();
for (auto cut : *cuts)
cuttings->push_back(cut);
for(int i = 0; i<splines.size(); i++)
cuttings->Append(cut);
for(int i = 0; i<splines.Size(); i++)
{
auto spline = splines[i];
auto lineseg = dynamic_cast<LineSeg<3>*>(spline.get());
@ -58,7 +58,7 @@ void SplineSurface :: AppendPoint(const Point<3> & p, const double reffac, const
{
plane->SetMaxH(maxh[i]);
}
cuttings->push_back(plane);
cuttings->Append(plane);
}
else
throw NgException("Spline type not implemented for SplineSurface!");

View File

@ -7,27 +7,27 @@ namespace netgen
class SplineSurface : public OneSurfacePrimitive
{
protected:
std::vector<GeomPoint<3>> geompoints;
std::vector<shared_ptr<SplineSeg<3>>> splines;
std::vector<string> bcnames;
Array<GeomPoint<3>> geompoints;
Array<shared_ptr<SplineSeg<3>>> splines;
Array<string> bcnames;
Array<double> maxh;
shared_ptr<OneSurfacePrimitive> baseprimitive;
shared_ptr<std::vector<shared_ptr<OneSurfacePrimitive>>> cuts;
shared_ptr<std::vector<shared_ptr<OneSurfacePrimitive>>> all_cuts;
shared_ptr<Array<shared_ptr<OneSurfacePrimitive>>> cuts;
shared_ptr<Array<shared_ptr<OneSurfacePrimitive>>> all_cuts;
public:
SplineSurface(shared_ptr<OneSurfacePrimitive> abaseprimitive, shared_ptr<std::vector<shared_ptr<OneSurfacePrimitive>>> acuts) :
SplineSurface(shared_ptr<OneSurfacePrimitive> abaseprimitive, shared_ptr<Array<shared_ptr<OneSurfacePrimitive>>> acuts) :
OneSurfacePrimitive(), baseprimitive(abaseprimitive), cuts(acuts)
{ ; }
virtual ~SplineSurface() { ; }
const auto & GetSplines() const { return splines; }
int GetNSplines() const { return splines.size(); }
const std::vector<GeomPoint<3>>& GetPoints() const { return geompoints; }
int GetNSplines() const { return splines.Size(); }
const Array<GeomPoint<3>>& GetPoints() const { return geompoints; }
string GetSplineType(const int i) const { return splines[i]->GetType(); }
SplineSeg<3> & GetSpline(const int i) { return *splines[i]; }
const SplineSeg<3> & GetSpline(const int i) const { return *splines[i]; }
int GetNP() const { return geompoints.size(); }
int GetNP() const { return geompoints.Size(); }
const GeomPoint<3> & GetPoint(int i) const { return geompoints[i]; }
string GetBCName(int i) const { return bcnames[i]; }
string GetBCNameOf(Point<3> p1, Point<3> p2) const;
@ -35,8 +35,8 @@ namespace netgen
DLL_HEADER void AppendPoint(const Point<3> & p, const double reffac = 1., const bool hpref=false);
void AppendSegment(shared_ptr<SplineSeg<3>> spline, string & bcname, double amaxh = -1);
const shared_ptr<std::vector<shared_ptr<OneSurfacePrimitive>>> CreateCuttingSurfaces();
const shared_ptr<std::vector<shared_ptr<OneSurfacePrimitive>>> GetCuts() const { return all_cuts; }
const shared_ptr<Array<shared_ptr<OneSurfacePrimitive>>> CreateCuttingSurfaces();
const shared_ptr<Array<shared_ptr<OneSurfacePrimitive>>> GetCuts() const { return all_cuts; }
const shared_ptr<OneSurfacePrimitive> GetBase() const { return baseprimitive; }
virtual void Project (Point<3> & p3d) const { baseprimitive->Project(p3d); }