35 template <
typename InputType,
typename ComputeType>
50 inline std::vector<std::array<int, 3>>
const&
GetTriangles()
const;
62 inline std::vector<bool>
const&
GetIsInside()
const;
63 inline bool IsInside(
int triIndex)
const;
64 inline bool IsOutside(
int triIndex)
const;
82 bool operator()(Polygon
const& outer, Polygon
const& inner);
88 bool operator()(Polygon
const& outer, std::vector<Polygon>
const& inners);
101 std::vector<std::shared_ptr<Tree>>
child;
106 bool operator()(std::shared_ptr<Tree>
const& tree);
117 std::shared_ptr<Tree>
const& tree,
118 std::map<std::shared_ptr<Tree>,
int>
const&
offsets);
121 std::map<std::shared_ptr<Tree>,
int>&
offsets)
const;
123 void PackPoints(std::shared_ptr<Tree>
const& tree,
126 bool InsertEdges(std::shared_ptr<Tree>
const& tree);
128 void LookupIndex(std::shared_ptr<Tree>
const& tree,
int&
v,
129 std::map<std::shared_ptr<Tree>,
int>
const&
offsets)
const;
133 std::map<std::shared_ptr<Tree>,
int>
const&
offsets)
const;
150 template <
typename InputType,
typename ComputeType>
167 template <
typename InputType,
typename ComputeType>
184 template <
typename InputType,
typename ComputeType>
inline 190 template <
typename InputType,
typename ComputeType>
inline 196 template <
typename InputType,
typename ComputeType>
inline 202 template <
typename InputType,
typename ComputeType>
inline 208 template <
typename InputType,
typename ComputeType>
inline 211 if (0 <= triIndex && triIndex < static_cast<int>(
mIsInside.size()))
221 template <
typename InputType,
typename ComputeType>
inline 224 if (0 <= triIndex && triIndex < static_cast<int>(
mIsInside.size()))
234 template <
typename InputType,
typename ComputeType>
239 std::shared_ptr<Tree> tree = std::make_shared<Tree>();
243 tree->polygon[i] = i;
251 template <
typename InputType,
typename ComputeType>
256 std::shared_ptr<Tree> tree = std::make_shared<Tree>();
257 tree->polygon = polygon;
264 template <
typename InputType,
typename ComputeType>
269 std::shared_ptr<Tree> otree = std::make_shared<Tree>();
270 otree->polygon = outer;
271 otree->child.resize(1);
273 std::shared_ptr<Tree> itree = std::make_shared<Tree>();
274 itree->polygon = inner;
275 otree->child[0] = itree;
282 template <
typename InputType,
typename ComputeType>
287 std::shared_ptr<Tree> otree = std::make_shared<Tree>();
288 otree->polygon = outer;
289 otree->child.resize(inners.size());
291 std::vector<std::shared_ptr<Tree>> itree(inners.size());
292 for (
size_t i = 0; i < inners.size(); ++i)
294 itree[i] = std::make_shared<Tree>();
295 itree[i]->polygon = inners[i];
296 otree->child[i] = itree[i];
304 template <
typename InputType,
typename ComputeType>
309 std::map<std::shared_ptr<Tree>,
int>
offsets;
311 std::vector<Vector2<InputType>>
points(numPoints);
317 for (
int t = 0;
t < numTriangles; ++
t)
320 for (
int j = 0; j < 3; ++j)
341 template <
typename InputType,
typename ComputeType>
344 std::map<std::shared_ptr<Tree>,
int>
const&
offsets)
354 ComputeType half =
static_cast<ComputeType
>(0.5);
355 ComputeType fourth =
static_cast<ComputeType
>(0.25);
357 auto const* ctPoints =
query.GetVertices();
361 for (
int t = 0;
t < numTriangles; ++
t)
366 auto ctInside = fourth * ctPoints[
v0] + half * ctPoints[
v1] + fourth *ctPoints[
v2];
373 template <
typename InputType,
typename ComputeType>
375 std::shared_ptr<Tree>
const& tree, std::map<std::shared_ptr<Tree>,
int>&
offsets)
const 378 std::queue<std::shared_ptr<Tree>> treeQueue;
379 treeQueue.push(tree);
380 while (treeQueue.size() > 0)
382 std::shared_ptr<Tree> outer = treeQueue.front();
384 offsets.insert(std::make_pair(outer, numPoints));
385 numPoints +=
static_cast<int>(outer->polygon.size());
387 int numChildren =
static_cast<int>(outer->child.size());
388 for (
int c = 0;
c < numChildren; ++
c)
390 std::shared_ptr<Tree> inner = outer->child[
c];
391 offsets.insert(std::make_pair(inner, numPoints));
392 numPoints +=
static_cast<int>(inner->polygon.size());
394 int numGrandChildren =
static_cast<int>(inner->child.size());
395 for (
int g = 0;
g < numGrandChildren; ++
g)
397 treeQueue.push(inner->child[
g]);
404 template <
typename InputType,
typename ComputeType>
409 std::queue<std::shared_ptr<Tree>> treeQueue;
410 treeQueue.push(tree);
411 while (treeQueue.size() > 0)
413 std::shared_ptr<Tree> outer = treeQueue.front();
415 int const numOuterIndices =
static_cast<int>(outer->polygon.size());
416 int const* outerIndices = outer->polygon.data();
417 for (
int i = 0; i < numOuterIndices; ++i)
422 int numChildren =
static_cast<int>(outer->child.size());
423 for (
int c = 0;
c < numChildren; ++
c)
425 std::shared_ptr<Tree> inner = outer->child[
c];
426 int const numInnerIndices =
static_cast<int>(inner->polygon.size());
427 int const* innerIndices = inner->polygon.data();
428 for (
int i = 0; i < numInnerIndices; ++i)
433 int numGrandChildren =
static_cast<int>(inner->child.size());
434 for (
int g = 0;
g < numGrandChildren; ++
g)
436 treeQueue.push(inner->child[
g]);
442 template <
typename InputType,
typename ComputeType>
446 std::array<int, 2> edge;
447 std::vector<int> ignoreOutEdge;
448 std::queue<std::shared_ptr<Tree>> treeQueue;
449 treeQueue.push(tree);
450 while (treeQueue.size() > 0)
452 std::shared_ptr<Tree> outer = treeQueue.front();
454 int numOuter =
static_cast<int>(outer->polygon.size());
455 for (
int i0 = numOuter - 1, i1 = 0; i1 < numOuter; i0 = i1++)
457 edge[0] = numPoints + i0;
458 edge[1] = numPoints + i1;
464 numPoints += numOuter;
466 int numChildren =
static_cast<int>(outer->child.size());
467 for (
int c = 0;
c < numChildren; ++
c)
469 std::shared_ptr<Tree> inner = outer->child[
c];
470 int numInner =
static_cast<int>(inner->polygon.size());
471 for (
int i0 = numInner - 1, i1 = 0; i1 < numInner; i0 = i1++)
473 edge[0] = numPoints + i0;
474 edge[1] = numPoints + i1;
480 numPoints += numInner;
482 int numGrandChildren =
static_cast<int>(inner->child.size());
483 for (
int g = 0;
g < numGrandChildren; ++
g)
485 treeQueue.push(inner->child[
g]);
492 template <
typename InputType,
typename ComputeType>
494 int&
v, std::map<std::shared_ptr<Tree>,
int>
const&
offsets)
const 496 std::queue<std::shared_ptr<Tree>> treeQueue;
497 treeQueue.push(tree);
498 while (treeQueue.size() > 0)
500 std::shared_ptr<Tree> outer = treeQueue.front();
502 int const numOuterIndices =
static_cast<int>(outer->polygon.size());
503 int const* outerIndices = outer->polygon.data();
505 if (v < offset + numOuterIndices)
507 v = outerIndices[v -
offset];
511 int numChildren =
static_cast<int>(outer->child.size());
512 for (
int c = 0;
c < numChildren; ++
c)
514 std::shared_ptr<Tree> inner = outer->child[
c];
515 int const numInnerIndices =
static_cast<int>(inner->polygon.size());
516 int const* innerIndices = inner->polygon.data();
517 offset =
offsets.find(inner)->second;
518 if (v < offset + numInnerIndices)
520 v = innerIndices[v -
offset];
524 int numGrandChildren =
static_cast<int>(inner->child.size());
525 for (
int g = 0;
g < numGrandChildren; ++
g)
527 treeQueue.push(inner->child[
g]);
533 template <
typename InputType,
typename ComputeType>
536 std::map<std::shared_ptr<Tree>,
int>
const&
offsets)
const 538 std::queue<std::shared_ptr<Tree>> treeQueue;
539 treeQueue.push(tree);
540 while (treeQueue.size() > 0)
542 std::shared_ptr<Tree> outer = treeQueue.front();
544 int const numOuterIndices =
static_cast<int>(outer->polygon.size());
549 int numChildren =
static_cast<int>(outer->child.size());
551 for (c = 0; c < numChildren; ++
c)
553 std::shared_ptr<Tree> inner = outer->child[
c];
554 int const numInnerIndices =
static_cast<int>(inner->polygon.size());
555 offset =
offsets.find(inner)->second;
559 int numGrandChildren =
static_cast<int>(inner->child.size());
560 for (
int g = 0;
g < numGrandChildren; ++
g)
562 treeQueue.push(inner->child[
g]);
567 if (c == numChildren)
void LookupIndex(std::shared_ptr< Tree > const &tree, int &v, std::map< std::shared_ptr< Tree >, int > const &offsets) const
std::vector< std::array< int, 3 > > mOutsideTriangles
std::vector< int > Polygon
std::vector< std::array< int, 3 > > const & GetOutsideTriangles() const
void PackPoints(std::shared_ptr< Tree > const &tree, std::vector< Vector2< InputType >> &points)
bool IsOutside(int triIndex) const
std::vector< std::array< int, 3 > > const & GetTriangles() const
std::vector< bool > mIsInside
std::vector< std::shared_ptr< Tree > > child
GLuint GLsizei const GLuint const GLintptr * offsets
int GetNumPointsAndOffsets(std::shared_ptr< Tree > const &tree, std::map< std::shared_ptr< Tree >, int > &offsets) const
bool Contains(Vector2< Real > const &p) const
GLfixed GLfixed GLint GLint GLfixed points
ConstrainedDelaunay2< InputType, ComputeType > mConstrainedDelaunay
bool InsertEdges(std::shared_ptr< Tree > const &tree)
GLsizei GLenum const void * indices
typedef int(WINAPI *PFNWGLRELEASEPBUFFERDCARBPROC)(HPBUFFERARB hPbuffer
#define LogError(message)
TriangulateCDT(int numPoints, Vector2< InputType > const *points)
std::vector< std::array< int, 3 > > mTriangles
bool TriangulatePacked(int numPoints, Vector2< InputType > const *points, std::shared_ptr< Tree > const &tree, std::map< std::shared_ptr< Tree >, int > const &offsets)
std::vector< std::array< int, 3 > > mAllTriangles
bool IsInside(int triIndex) const
GLfloat GLfloat GLfloat v2
std::vector< bool > const & GetIsInside() const
std::vector< std::array< int, 3 > > const & GetAllTriangles() const
Vector2< InputType > const * mPoints