94 , m_trisAdjToPts(a_trisAdjToPts)
103 TrTriangulatorPoints::~TrTriangulatorPoints()
136 return (
int)
m_pts.size();
151 m_observer->BeginOperationString(
"Triangulating Points");
179 double area = trArea(
m_pts[a_id1 - 1],
m_pts[a_id2 - 1],
m_pts[a_id3 - 1]);
185 m_tris.push_back(a_id1 - 1);
186 m_tris.push_back(a_id2 - 1);
187 m_tris.push_back(a_id3 - 1);
191 int triIdx = ((int)
m_tris.size() / 3) - 1;
192 (*m_trisAdjToPts)[a_id1 - 1].push_back(triIdx);
193 (*m_trisAdjToPts)[a_id2 - 1].push_back(triIdx);
194 (*m_trisAdjToPts)[a_id3 - 1].push_back(triIdx);
198 double prog = std::min(
m_tris.size() / (double)(
m_pts.size() * 2), 1.0);
211 for (
const auto& p :
m_pts)
212 gmAddToExtents(p, ptMin, ptMax);
213 m_areaTol = gmComputeXyTol(ptMin, ptMax);
258 VecPt3d pts = {{0, 0, 0}, {10, 0, 0}, {20, 0, 0}, {5, 10, 0}, {15, 10, 0}};
262 trTriangulateIt(client);
264 TS_ASSERT_EQUALS(tris.size(), 9);
265 TS_ASSERT_EQUALS(tris[0], 3);
266 TS_ASSERT_EQUALS(tris[1], 0);
267 TS_ASSERT_EQUALS(tris[2], 1);
268 TS_ASSERT_EQUALS(tris[3], 1);
269 TS_ASSERT_EQUALS(tris[4], 2);
270 TS_ASSERT_EQUALS(tris[5], 4);
271 TS_ASSERT_EQUALS(tris[6], 1);
272 TS_ASSERT_EQUALS(tris[7], 4);
273 TS_ASSERT_EQUALS(tris[8], 3);
275 TS_ASSERT_EQUALS(trisAdjToPts.size(), pts.size());
276 TS_ASSERT_EQUALS((
VecInt{0}), trisAdjToPts[0]);
277 TS_ASSERT_EQUALS((
VecInt{0, 1, 2}), trisAdjToPts[1]);
278 TS_ASSERT_EQUALS((
VecInt{1}), trisAdjToPts[2]);
279 TS_ASSERT_EQUALS((
VecInt{0, 2}), trisAdjToPts[3]);
280 TS_ASSERT_EQUALS((
VecInt{1, 2}), trisAdjToPts[4]);
Code that creates a Delauney triangulation from points.
virtual int GetID() const override
Return the current point index (0-based).
double m_areaTol
tolerance for area to be greater than 0.0
Functions dealing with triangles.
virtual void ReceiveTriangle(int a_id1, int a_id2, int a_id3) override
Receive a triangle consisting of the 3 points.
virtual void PrepareToReceiveTriangles() override
Called just before triangles are created.
void stShrinkCapacity(std::vector< T > &v)
VecInt2d * m_trisAdjToPts
Triangles adjacent to points.
TrTriangulatorPoints(const VecPt3d &a_pts, VecInt &a_tris, VecInt2d *a_trisAdjToPts=nullptr)
Triangulate Pt3ds returning triangles in a single 1D vector.
int m_idx
Current point index.
std::vector< int > VecInt
virtual Pt3d GetLocation() const override
Get location of current point.
const VecPt3d & m_pts
The points.
virtual void FinalizeTriangulation() override
Called after all triangles have been received.
void UpdateAreaTolerance()
calculates the area tolerance
Functions dealing with geometry.
virtual void SetObserver(BSHP< Observer > a_)
Set the observer to use for feedback while processing.
std::vector< Pt3d > VecPt3d
void test1()
tests triangulating points
VecInt & m_tris
The triangles as 0-based indices into m_pts.
virtual int GetNPoints() const override
Return the number of points to be triangulated.
virtual void IncrementPoint() override
Increment the current point index by 1.
std::vector< VecInt > VecInt2d
Class to triangulate simple points.
BSHP< Observer > m_observer
Observer.