netgen/libsrc/csg/splinesurface.cpp

68 lines
1.6 KiB
C++
Raw Normal View History

2016-10-04 22:30:57 +05:00
#include <csg.hpp>
namespace netgen
{
void SplineSurface :: AppendPoint(const Point<3> & p, const double reffac, const bool hpref)
{
2016-10-27 18:41:08 +05:00
auto pp = Point<3>(p);
geompoints.Append(GeomPoint<3>(pp,reffac));
2016-10-04 22:30:57 +05:00
geompoints.Last().hpref = hpref;
}
2016-10-27 18:41:08 +05:00
void SplineSurface :: AppendSegment(SplineSeg<3>* spline, string* bcname, double amaxh)
2016-10-04 22:30:57 +05:00
{
2016-10-27 18:41:08 +05:00
splines.Append(spline);
bcnames.Append(bcname);
maxh.Append(amaxh);
2016-10-04 22:30:57 +05:00
}
2016-10-05 22:48:18 +05:00
string* SplineSurface :: GetBCNameOf (Point<3> p1, Point<3> p2) const
{
2016-10-27 18:41:08 +05:00
double eps = 1e-5;
2016-10-05 22:48:18 +05:00
for(int i=0; i<splines.Size(); i++)
{
2016-10-27 18:41:08 +05:00
auto pp1 = Point<3>(splines[i]->GetPoint(0));
Project(pp1);
auto pp2 = Point<3>(splines[i]->GetPoint(1));
Project(pp2);
if (((pp1-p1).Length()<eps && (pp2-p2).Length() < eps) || ((pp1-p2).Length() < eps && (pp2-p1).Length() < eps))
2016-10-05 22:48:18 +05:00
{
return bcnames[i];
}
}
return new string("default");
}
2016-10-11 17:10:36 +05:00
2016-10-27 18:41:08 +05:00
Array<OneSurfacePrimitive*>* SplineSurface :: CreateCuttingSurfaces() const
2016-10-11 17:10:36 +05:00
{
2016-10-27 18:41:08 +05:00
auto cuttings = new Array<OneSurfacePrimitive*>();
for (auto cut : *cuts)
cuttings->Append(cut);
for(int i = 0; i<splines.Size(); i++)
2016-10-11 17:10:36 +05:00
{
2016-10-27 18:41:08 +05:00
auto spline = splines[i];
auto lineseg = dynamic_cast<LineSeg<3>*>(spline);
auto p1 = Point<3>(spline->GetPoint(0));
Project(p1);
auto p2 = Point<3>(spline->GetPoint(1));
Project(p2);
auto vec = Vec<3>(p2)-Vec<3>(p1);
auto plane = new Plane(p1,-Cross(vec,baseprimitive->GetNormalVector(p1)));
if(maxh[i]>0)
{
plane->SetMaxH(maxh[i]);
}
cuttings->Append(plane);
2016-10-11 17:10:36 +05:00
}
2016-10-27 18:41:08 +05:00
return cuttings;
2016-10-11 17:10:36 +05:00
}
void SplineSurface :: Print(ostream & str) const
{
str << "SplineSurface " << endl;
}
2016-10-04 22:30:57 +05:00
}