63 template <
typename InputType,
typename ComputeType>
95 inline std::vector<int>
const&
GetIndices()
const;
108 bool GetHull(std::vector<int>& hull)
const;
120 bool GetAdjacencies(
int i, std::array<int, 3>& adjacencies)
const;
205 std::array<std::array<int, 2>, 3>
mIndex;
209 template <
typename InputType,
typename ComputeType>
214 template <
typename InputType,
typename ComputeType>
228 mIndex = { { { 0, 1 }, { 1, 2 }, { 2, 0 } } };
231 template <
typename InputType,
typename ComputeType>
235 mEpsilon = std::max(epsilon, (InputType)0);
277 for (j = 0; j < 2; ++j)
298 std::set<ProcessedVertex> processed;
299 for (i = 0; i < 3; ++i)
308 auto iter = processed.find(v);
309 if (iter == processed.end())
328 std::map<std::shared_ptr<Triangle>,
int> permute;
330 permute[
nullptr] = i++;
333 permute[element.second] = i++;
346 std::shared_ptr<Triangle> tri = element.second;
347 for (j = 0; j < 3; ++j, ++i)
358 template <
typename InputType,
typename ComputeType>
inline 364 template <
typename InputType,
typename ComputeType>
inline 370 template <
typename InputType,
typename ComputeType>
inline 376 template <
typename InputType,
typename ComputeType>
inline 382 template <
typename InputType,
typename ComputeType>
inline 388 template <
typename InputType,
typename ComputeType>
inline 394 template <
typename InputType,
typename ComputeType>
inline 400 template <
typename InputType,
typename ComputeType>
inline 406 template <
typename InputType,
typename ComputeType>
inline 412 template <
typename InputType,
typename ComputeType>
inline 418 template <
typename InputType,
typename ComputeType>
inline 424 template <
typename InputType,
typename ComputeType>
inline 430 template <
typename InputType,
typename ComputeType>
448 hull.resize(2 * numEdges);
449 int current = 0, i = 0;
450 for (
auto adj : mAdjacencies)
454 int tri = i / 3, j = i % 3;
455 hull[current++] =
mIndices[3 * tri + j];
456 hull[current++] =
mIndices[3 * tri + ((j + 1) % 3)];
464 LogError(
"Unexpected. There must be at least one triangle.");
469 LogError(
"The dimension must be 2.");
474 template <
typename InputType,
typename ComputeType>
479 int numTriangles =
static_cast<int>(
mIndices.size() / 3);
480 if (0 <= i && i < numTriangles)
490 LogError(
"The dimension must be 2.");
495 template <
typename InputType,
typename ComputeType>
500 int numTriangles =
static_cast<int>(
mIndices.size() / 3);
501 if (0 <= i && i < numTriangles)
511 LogError(
"The dimension must be 2.");
516 template <
typename InputType,
typename ComputeType>
524 int numTriangles =
static_cast<int>(
mIndices.size() / 3);
525 info.
path.resize(numTriangles);
539 for (
int i = 0; i < numTriangles; ++i)
541 int ibase = 3 * triangle;
594 LogError(
"The dimension must be 2.");
599 template <
typename InputType,
typename ComputeType>
603 for (
int t = 0;
t < numTriangles; ++
t)
606 for (j = 0; j < 3; ++j)
613 auto adjTri = tri->T[j].lock();
640 LogError(
"Unexpected termination of GetContainingTriangle.");
644 template <
typename InputType,
typename ComputeType>
646 std::set<std::shared_ptr<Triangle>>& candidates, std::set<
EdgeKey<true>>& boundary)
650 while (candidates.size() > 0)
652 std::shared_ptr<Triangle> tri = *candidates.begin();
653 candidates.erase(candidates.begin());
655 for (
int j = 0; j < 3; ++j)
657 auto adj = tri->T[j].lock();
658 if (adj && candidates.find(adj) == candidates.end())
666 candidates.insert(adj);
671 if (!polygon.
Insert(tri->V[0], tri->V[1], tri->V[2]))
684 std::shared_ptr<Triangle> tri = element.second;
685 for (
int j = 0; j < 3; ++j)
687 if (!tri->T[j].lock())
696 template <
typename InputType,
typename ComputeType>
704 std::shared_ptr<Triangle> tri = tmap.begin()->second;
713 std::set<std::shared_ptr<Triangle>> candidates;
714 candidates.insert(tri);
719 std::set<EdgeKey<true>> boundary;
727 for (
auto const& key : boundary)
750 std::set<EdgeKey<true>> hull;
751 for (
auto const& element : tmap)
753 std::shared_ptr<Triangle>
t = element.second;
754 for (
int j = 0; j < 3; ++j)
767 std::set<std::shared_ptr<Triangle>> candidates;
768 std::set<EdgeKey<true>> visible;
769 for (
auto const& key : hull)
776 if (iter != emap.end() && iter->second->T[1].lock() ==
nullptr)
778 auto adj = iter->second->T[0].lock();
779 if (adj && candidates.find(adj) == candidates.end())
787 candidates.insert(adj);
799 LogError(
"Unexpected condition (ComputeType not exact?)");
807 std::set<EdgeKey<true>> boundary;
815 for (
auto const& key : boundary)
828 for (
auto const& key : visible)
840 template <
typename InputType,
typename ComputeType>
845 template <
typename InputType,
typename ComputeType>
854 template <
typename InputType,
typename ComputeType>
Vector2< InputType > vertex
bool GetAndRemoveInsertionPolygon(int i, std::set< std::shared_ptr< Triangle >> &candidates, std::set< EdgeKey< true >> &boundary)
EMap const & GetEdges() const
std::vector< int > const & GetAdjacencies() const
void Set(int numVertices, Vector2< Real > const *vertices)
int GetNumVertices() const
bool GetHull(std::vector< int > &hull) const
std::vector< int > const & GetDuplicates() const
ETManifoldMesh const & GetGraph() const
PrimalQuery2< ComputeType > mQuery
bool operator()(int numVertices, Vector2< InputType > const *vertices, InputType epsilon)
std::vector< int > mIndices
std::vector< int > mDuplicates
InputType GetEpsilon() const
bool operator<(ProcessedVertex const &v) const
int ToLine(int i, int v0, int v1) const
GLsizei GLenum const void * indices
#define LogError(message)
Line2< InputType > const & GetLine() const
virtual std::shared_ptr< Triangle > Insert(int v0, int v1, int v2)
int ToCircumcircle(int i, int v0, int v1, int v2) const
Vector2< InputType > const * GetVertices() const
Vector2< InputType > const * mVertices
int GetNumTriangles() const
TMap const & GetTriangles() const
int GetNumUniqueVertices() const
virtual bool Remove(int v0, int v1, int v2)
std::array< int, 3 > finalV
PrimalQuery2< ComputeType > const & GetQuery() const
std::vector< Vector2< ComputeType > > mComputeVertices
std::vector< int > mAdjacencies
int GetContainingTriangle(Vector2< InputType > const &p, SearchInfo &info) const
ETManifoldMesh::Triangle Triangle
std::array< std::array< int, 2 >, 3 > mIndex
std::vector< int > const & GetIndices() const
Vector2< Real > direction[2]