make it so that CCW iter ranges are the reverse of CW iter ranges, i.e. they do not start with the same element anymore

This commit is contained in:
Max Lyon
2021-03-09 15:32:44 +01:00
parent f63c4a54bb
commit 9b85f7713e

View File

@@ -156,7 +156,21 @@ class GenericCirculator_ValueHandleFnsT {
inline static bool is_valid(const typename Mesh::HalfedgeHandle &heh, const int lap_counter) { inline static bool is_valid(const typename Mesh::HalfedgeHandle &heh, const int lap_counter) {
return ( heh.is_valid() && (lap_counter == 0 ) ); return ( heh.is_valid() && (lap_counter == 0 ) );
} }
inline static void init(const Mesh*, typename Mesh::HalfedgeHandle&, typename Mesh::HalfedgeHandle&, int&) {}; inline static void init(const Mesh* mesh, typename Mesh::HalfedgeHandle& heh, typename Mesh::HalfedgeHandle& start, int& lap_counter, bool adjust_for_ccw)
{
if (!CW) // TODO: constexpr if
{
if (adjust_for_ccw)
{
// increment current heh and start so that cw and ccw version dont start with the same element but ranges are actually reversed
int lc = lap_counter;
increment(mesh, heh, start, lap_counter);
start = heh;
lap_counter = lc;
}
}
}
inline static void increment(const Mesh *mesh, typename Mesh::HalfedgeHandle &heh, typename Mesh::HalfedgeHandle &start, int &lap_counter) { inline static void increment(const Mesh *mesh, typename Mesh::HalfedgeHandle &heh, typename Mesh::HalfedgeHandle &start, int &lap_counter) {
GenericCirculator_CenterEntityFnsT<Mesh, CenterEntityHandle, CW>::increment(mesh, heh, start, lap_counter); GenericCirculator_CenterEntityFnsT<Mesh, CenterEntityHandle, CW>::increment(mesh, heh, start, lap_counter);
} }
@@ -173,7 +187,19 @@ class GenericCirculator_ValueHandleFnsT<Mesh, CenterEntityHandle, typename Mesh:
inline static bool is_valid(const typename Mesh::HalfedgeHandle &heh, const int lap_counter) { inline static bool is_valid(const typename Mesh::HalfedgeHandle &heh, const int lap_counter) {
return ( heh.is_valid() && (lap_counter == 0)); return ( heh.is_valid() && (lap_counter == 0));
} }
inline static void init(const Mesh *mesh, typename Mesh::HalfedgeHandle &heh, typename Mesh::HalfedgeHandle &start, int &lap_counter) { inline static void init(const Mesh *mesh, typename Mesh::HalfedgeHandle &heh, typename Mesh::HalfedgeHandle &start, int &lap_counter, bool adjust_for_ccw)
{
if (!CW) // TODO: constexpr if
{
if (adjust_for_ccw)
{
// increment current heh and start so that cw and ccw version dont start with the same element but ranges are actually reversed
int lc = lap_counter;
increment(mesh, heh, start, lap_counter);
start = heh;
lap_counter = lc;
}
}
if (heh.is_valid() && !GenericCirculator_DereferenciabilityCheck::isDereferenciable(mesh, heh) && lap_counter == 0 ) if (heh.is_valid() && !GenericCirculator_DereferenciabilityCheck::isDereferenciable(mesh, heh) && lap_counter == 0 )
increment(mesh, heh, start, lap_counter); increment(mesh, heh, start, lap_counter);
}; };
@@ -279,12 +305,14 @@ class GenericCirculatorT : protected GenericCirculatorBaseT<typename GenericCirc
GenericCirculatorT(mesh_ref mesh, CenterEntityHandle start, bool end = false) : GenericCirculatorT(mesh_ref mesh, CenterEntityHandle start, bool end = false) :
GenericCirculatorBaseT<Mesh>(mesh, mesh.halfedge_handle(start), end) GenericCirculatorBaseT<Mesh>(mesh, mesh.halfedge_handle(start), end)
{ {
GenericCirculator_ValueHandleFns::init(this->mesh_, this->heh_, this->start_, this->lap_counter_); bool adjust_for_ccw = true;
GenericCirculator_ValueHandleFns::init(this->mesh_, this->heh_, this->start_, this->lap_counter_, adjust_for_ccw);
} }
GenericCirculatorT(mesh_ref mesh, typename Mesh::HalfedgeHandle heh, bool end = false) : GenericCirculatorT(mesh_ref mesh, typename Mesh::HalfedgeHandle heh, bool end = false) :
GenericCirculatorBaseT<Mesh>(mesh, heh, end) GenericCirculatorBaseT<Mesh>(mesh, heh, end)
{ {
GenericCirculator_ValueHandleFns::init(this->mesh_, this->heh_, this->start_, this->lap_counter_); bool adjust_for_ccw = false; // if iterator is initialized with specific heh, we want to start there
GenericCirculator_ValueHandleFns::init(this->mesh_, this->heh_, this->start_, this->lap_counter_, adjust_for_ccw);
} }
GenericCirculatorT(const GenericCirculatorT &rhs) : GenericCirculatorBaseT<Mesh>(rhs) {} GenericCirculatorT(const GenericCirculatorT &rhs) : GenericCirculatorBaseT<Mesh>(rhs) {}