Skip to content

Commit

Permalink
add getcorners and getnumberofpatches methods
Browse files Browse the repository at this point in the history
  • Loading branch information
Pawel Herman committed Mar 21, 2016
1 parent 69d47b5 commit 63478e3
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 10 deletions.
5 changes: 5 additions & 0 deletions lib/happah/geometries/SurfaceHEZ.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,13 @@ class SurfaceHEZ : public Geometry3D<Space> {

template<hpuint t_i0, hpuint t_i1, hpuint t_i2>
const Point& getControlPoint() const { return (*m_controlPoints)[SurfaceUtilsBEZ::get_index<t_degree, t_i0, t_i1, t_i2>::value]; }

const Point& getControlPoint(hpuint i0, hpuint i1, hpuint i2) const { return (*m_controlPoints)[SurfaceUtilsBEZ::template getIndex<t_degree>(i0, i1, i2)]; }

std::tuple<const Point&, const Point&, const Point&> getCorners() const { return std::make_tuple(std::cref(m_controlPoints[0]), std::cref(m_controlPoints[t_degree]), std::cref(m_controlPoints.back())); }

std::tuple<const Point3D&, const Point3D&, const Point3D&> getParameterTriangle() const { return std::make_tuple(std::cref(m_p0), std::cref(m_p1), std::cref(m_p2)); }

Point getPoint(const Point3D& p) const {
//TODO: can this be done more efficiently?

Expand Down
25 changes: 15 additions & 10 deletions lib/happah/geometries/SurfaceSplineHEZ.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ class SurfaceSplineHEZ : public Surface<Space> {

const ControlPoints& getControlPoints() const { return m_controlPoints; }

hpuint getNumberOfPatches() const {
static auto nControlPoints = SurfaceUtilsBEZ::get_number_of_control_points<t_degree>::value;
return m_controlPointIndices.size() / nControlPoints;
}

const Indices& getParameterPointIndices() const { return m_parameterPointIndices; }

const ParameterPoints& getParameterPoints() const { return m_parameterPoints; }
Expand All @@ -42,14 +47,23 @@ class SurfaceSplineHEZ : public Surface<Space> {
static auto nControlPoints = SurfaceUtilsBEZ::get_number_of_control_points<t_degree>::value;
std::vector<Point> controlPoints;
auto c = deindex(m_controlPoints, m_controlPointIndices);
for(auto i = c.cbegin() + p * nControlPoints, end = i + nControlPoints; i != end; ++i) controlPoints.push_back(*i);
for(auto i = c.cbegin() + p * nControlPoints, end = i + nControlPoints; i != end; ++i) controlPoints.push_back(*i);//TODO: use vector input iterator constructor?
auto r = deindex(m_parameterPoints, m_parameterPointIndices).cbegin() + 3 * p;
auto p0 = *r;
auto p1 = *(++r);
auto p2 = *(++r);
return {p0, p1, p2, controlPoints};
}

//NOTE: Replace sth patch with a linear piece whose corners are p0, p1, and p2. Be aware the shared control points along the edge are also moved.
void linearize(hpuint s, const Point& p0, const Point& p1, const Point& p2) {
auto c = m_controlPointIndices.begin() + s * SurfaceUtilsBEZ::get_number_of_control_points<t_degree>::value;
SurfaceUtilsBEZ::sample(t_degree + 1, [&] (hpreal u, hpreal v, hpreal w) {
m_controlPoints[*c] = u * p0 + v * p1 + w * p2;
++c;
});
}

SurfaceSplineBEZ<Space, t_degree> restrict(const Plane& plane, hpreal epsilon = EPSILON) const {
std::vector<Point2D> parameterPoints;
parameterPoints.reserve(m_parameterPoints.size());
Expand Down Expand Up @@ -183,15 +197,6 @@ class SurfaceSplineHEZ : public Surface<Space> {
}
}

//NOTE: Replace sth piece with a linear piece whose corners are p0, p1, and p2. Be aware the shared control points along the edge are also moved.
void linearize(hpuint s, const Point& p0, const Point& p1, const Point& p2) {
auto c = m_controlPointIndices.begin() + s * SurfaceUtilsBEZ::get_number_of_control_points<t_degree>::value;
SurfaceUtilsBEZ::sample(t_degree + 1, [&] (hpreal u, hpreal v, hpreal w) {
m_controlPoints[*c] = u * p0 + v * p1 + w * p2;
++c;
});
}

void operator+=(const SurfaceSplineHEZ<Space, t_degree>& surface) {
//TODO: surface must have the same parameter space
//TODO: maybe compare indices using simd?
Expand Down

0 comments on commit 63478e3

Please sign in to comment.