Atoms Crowd  7.0.0
LocomotionHelper.h
1 #pragma once
2 // ===========================================================================
3 // Copyright (c) 2015 Toolchefs Ltd. All rights reserved.
4 //
5 // Use of this software is subject to the terms of the Toolchefs license
6 // agreement provided at the time of installation or download, or which
7 // otherwise accompanies this software in either electronic or hard copy form.
8 // ===========================================================================
9 
10 #include <Atoms/Globals.h>
11 #include <AtomsUtils/AtomsMath.h>
12 #include <AtomsUtils/Triangle.h>
13 #include <AtomsUtils/Edge.h>
14 #include <algorithm>
15 #include <vector>
16 #include <map>
17 #include <set>
18 
19 
20 namespace Atoms
21 {
22  enum LocomotionSort
23  {
24  kGreater = 0,
25  kLess
26  };
27 
28  class ATOMS_EXPORT LocomotionBoundaries
29  {
30  public:
31  AtomsMath::Vector2f min;
32  AtomsMath::Vector2f max;
33  AtomsMath::Vector2f gridSize;
34  };
35 
36  class ATOMS_EXPORT LocomotionDelaunay {
37 
38  public:
39  std::vector<AtomsUtils::Triangle2> triangles;
40 
41  LocomotionBoundaries boundaries;
42 
43  LocomotionDelaunay() { triangles.clear(); }
44  };
45 
47 
52  ATOMS_EXPORT std::vector<AtomsUtils::Triangle2> locomotionTriangulation(const std::vector<AtomsMath::Vector2f> & points, const LocomotionSort xSort = LocomotionSort::kLess, const LocomotionSort ySort = LocomotionSort::kLess, const float eps = 1e-4);
53 
54  ATOMS_EXPORT bool findTriangleFromPointForLocomotion(const AtomsMath::Vector2f& point, const std::vector<AtomsUtils::Triangle2>& triangles, AtomsMath::Vector3f& barycentricCoords, AtomsUtils::Triangle2& outTriangle, const std::set<int>& skipTriangles);
55 
56 }
Definition: LocomotionHelper.h:29
Definition: LocomotionHelper.h:36
Triangle 2D class.
Definition: Triangle.h:87
Atoms namespace.
Definition: Agent.h:29
ATOMS_EXPORT std::vector< AtomsUtils::Triangle2 > locomotionTriangulation(const std::vector< AtomsMath::Vector2f > &points, const LocomotionSort xSort=LocomotionSort::kLess, const LocomotionSort ySort=LocomotionSort::kLess, const float eps=1e-4)
Implements Bowyer-Watson algorithm to generate a Delaunay triangulation for the given positions.