Skip to content

Commit

Permalink
rename make_offset to find
Browse files Browse the repository at this point in the history
  • Loading branch information
Pawel Herman committed Jan 15, 2018
1 parent 137d0d8 commit bd40322
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 33 deletions.
62 changes: 31 additions & 31 deletions lib/happah/Happah.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,16 @@ template<class Enumerator>
auto expand(Enumerator e);

template<typename T>
trix find(const Triples<T>& triples, const T& t);
trix find(const Triples<T>& triples, const T& value);

template<typename T>
quax find(const Quadruples<T>& quadruples, const T& t);
quax find(const Quadruples<T>& quadruples, const T& value);

template<typename T>
trit find(const Triples<T>& triples, hpindex t, const T& value);

template<typename T>
quat find(const Quadruples<T>& quadruples, hpindex q, const T& value);

inline hpreal length2(const Point3D& point);

Expand All @@ -134,12 +140,6 @@ Indices make_indices(const std::experimental::filesystem::path& indices);
template<class Value>
auto make_map(hpuint n);

template<typename T>
trit make_offset(const Triples<T>& triples, hpindex i, const T& t);

template<typename T>
quat make_offset(const Quadruples<T>& quadruples, hpindex i, const T& t);

//Convert a string representation in HPH format.
std::vector<hpreal> make_reals(const std::string& reals);

Expand Down Expand Up @@ -494,6 +494,27 @@ quax find(const Quadruples<T>& quadruples, const T& value) {
return { q, i };
}

template<typename T>
trit find(const Triples<T>& triples, hpindex t, const T& value) {
auto i = std::begin(triples) + 3 * t;

if(value == i[0]) return TRIT0;
if(value == i[1]) return TRIT1;
assert(value == i[2]);
return TRIT2;
}

template<typename T>
quat find(const Quadruples<T>& quadruples, hpindex q, const T& value) {
auto i = std::begin(quadruples) + (q << 2);

if(value == i[0]) return QUAT0;
if(value == i[1]) return QUAT1;
if(value == i[2]) return QUAT2;
assert(value == i[3]);
return QUAT3;
}

inline hpreal length2(const Point3D& point) { return glm::length2(point); }

template<class Enumerator>
Expand Down Expand Up @@ -529,27 +550,6 @@ auto make_map(hpuint n) {
return Map(n, getHash, isKeysEqual);
}

template<typename T>
trit make_offset(const Triples<T>& triples, hpindex t, const T& value) {
auto i = std::begin(triples) + 3 * t;

if(value == i[0]) return TRIT0;
if(value == i[1]) return TRIT1;
assert(value == i[2]);
return TRIT2;
}

template<typename T>
quat make_offset(const Quadruples<T>& quadruples, hpindex q, const T& value) {
auto i = std::begin(quadruples) + (q << 2);

if(value == i[0]) return QUAT0;
if(value == i[1]) return QUAT1;
if(value == i[2]) return QUAT2;
assert(value == i[3]);
return QUAT3;
}

inline Point3D mix(const Point3D& point, hpreal lambda) { return point * lambda; }

inline Point2D mix(const Point2D& p0, hpreal u, const Point2D& p1, hpreal v, const Point2D& p2, hpreal w) { return p0 * u + p1 * v + p2 * w; }
Expand Down Expand Up @@ -592,9 +592,9 @@ namespace Color {
static const hpcolor MAGENTA(1.0,0.0,1.0,1.0);
static const hpcolor RED(1.0,0.0,0.0,1.0);
static const hpcolor WHITE(1.0);
}
}//namespace Color

}
}//namespace happah

//TODO: automatic code styler
//TODO: deb/ppa package for happah install, -dev, -dev-eclipse, -dev-vim, plus documentation about use
Expand Down
4 changes: 2 additions & 2 deletions lib/happah/geometry/QuadMesh.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ class SpokesWalker {

auto q = m_neighbors(m_q, o[m_i]);

m_i = make_offset(m_neighbors, q, m_q);
m_i = find(m_neighbors, q, m_q);
m_q = q;
return *this;
}
Expand All @@ -124,7 +124,7 @@ class SpokesWalker {

auto q = m_neighbors(m_q, m_i);

m_i = o[make_offset(m_neighbors, q, m_q)];
m_i = o[find(m_neighbors, q, m_q)];
m_q = q;
return *this;
}
Expand Down

0 comments on commit bd40322

Please sign in to comment.