xmsgrid  1.0
XmGeometry.cpp
Go to the documentation of this file.
1 //------------------------------------------------------------------------------
6 //------------------------------------------------------------------------------
7 
8 //----- Included files ---------------------------------------------------------
9 
10 // 1. Precompiled header
11 
12 // 2. My own header
14 
15 // 3. Standard library headers
16 #include <set>
17 
18 // 4. External library headers
19 #include <boost/container/flat_set.hpp>
20 
21 // 5. Shared code headers
22 #include <xmscore/misc/XmConst.h>
23 #include <xmscore/misc/XmLog.h>
24 
25 // 6. Non-shared code headers
26 #include <xmsgrid/geometry/geoms.h>
27 #include <xmsgrid/ugrid/XmUGrid.h>
29 
30 //----- Forward declarations ---------------------------------------------------
31 
32 //----- External globals -------------------------------------------------------
33 
34 //----- Namespace declaration --------------------------------------------------
35 
37 namespace xms
38 {
39 //----- Constants / Enumerations -----------------------------------------------
40 
41 //----- Classes / Structs ------------------------------------------------------
42 
43 //----- Internal functions -----------------------------------------------------
44 
45 //----- Class / Function definitions -------------------------------------------
46 
47 //------------------------------------------------------------------------------
53 //------------------------------------------------------------------------------
54 // TODO: Deprecated. Remove in major version change.
55 VecPt3d ConvexHull(const std::vector<Pt3<double>>& a_points)
56 {
57  VecPt3d hull;
58  gmGetConvexHull(a_points, hull, false);
59  return hull;
60 } // ConvexHull
61 //------------------------------------------------------------------------------
68 //------------------------------------------------------------------------------
69 // TODO: Deprecated. Remove in major version change.
70 VecInt ConvexHullWithIndices(const std::vector<int>& a_points, std::shared_ptr<XmUGrid> a_ugrid)
71 {
72  VecPt3d points3d(a_points.size());
73  for (int i = 0; i < a_points.size(); ++i)
74  {
75  points3d.push_back(a_ugrid->GetPointLocation(a_points[i]));
76  }
77  VecPt3d convexHull = ConvexHull(points3d);
78  VecInt returnPoints(convexHull.size());
79  for (int i(0); i < convexHull.size(); i++)
80  {
81  for (int j(0); i < points3d.size(); j++)
82  {
83  if (convexHull[i] == points3d[j])
84  {
85  returnPoints.push_back(a_points[j]);
86  break;
87  }
88  }
89  }
90  return returnPoints;
91 } // ConvexHullWithIndices
92 //------------------------------------------------------------------------------
97 //------------------------------------------------------------------------------
98 // TODO: Deprecated. Remove in major version change.
99 bool DoLineSegmentsCross(const std::pair<Pt3<double>, Pt3<double>>& a_segment1,
100  const std::pair<Pt3<double>, Pt3<double>>& a_segment2)
101 {
102  return gmLinesCross(a_segment1.first, a_segment1.second, a_segment2.first, a_segment2.second);
103  ;
104 } // DoLineSegmentsCross
105 
106 //------------------------------------------------------------------------------
113 //------------------------------------------------------------------------------
114 // TODO: Deprecated. Remove in major version change.
115 bool DoLineSegmentsCross(const Pt3<double>& a_segment1Point1,
116  const Pt3<double>& a_segment1Point2,
117  const Pt3<double>& a_segment2Point1,
118  const Pt3<double>& a_segment2Point2)
119 {
120  return gmLinesCross(a_segment1Point1, a_segment1Point2, a_segment2Point1, a_segment2Point2);
121 } // DoLineSegmentsCross
122 
123 } // namespace xms
124 
125 #ifdef CXX_TEST
126 //------------------------------------------------------------------------------
127 // Unit Tests
128 //------------------------------------------------------------------------------
129 using namespace xms;
130 //#include <xmsgrid/ugrid/detail/XmGeometry.t.h>
131 
132 #endif
Contains the XmUGrid Class and supporting data types.
std::vector< int > VecInt
Contains IO functions as well as several utility functions for XmUGrid.
bool DoLineSegmentsCross(const std::pair< Pt3< double >, Pt3< double >> &a_segment1, const std::pair< Pt3< double >, Pt3< double >> &a_segment2)
Determine whether 2 line segments intersect (Deprecated).
Definition: XmGeometry.cpp:99
void gmGetConvexHull(const VecPt3d &a_pts, VecPt3d &a_hull, bool a_includeOn)
Calculate convex hull using Monotone chain aka Andrew&#39;s algorithm.
Definition: geoms.cpp:2211
Code to calculate the convex hull of a set of points in two dimensions.
VecInt ConvexHullWithIndices(const std::vector< int > &a_points, std::shared_ptr< XmUGrid > a_ugrid)
Returns the convex hull of a set of points (Deprecated).
Definition: XmGeometry.cpp:70
Functions dealing with geometry.
XMS Namespace.
Definition: geoms.cpp:34
bool gmLinesCross(const Pt3d &a_segment1Point1, const Pt3d &a_segment1Point2, const Pt3d &a_segment2Point1, const Pt3d &a_segment2Point2)
Determine whether 2 line segments cross. The segments may touch at the end points.
Definition: geoms.cpp:1013
VecPt3d ConvexHull(const std::vector< Pt3< double >> &a_points)
Returns the convex hull of a set of points (Deprecated).
Definition: XmGeometry.cpp:55
std::vector< Pt3d > VecPt3d