Revision: 54526
http://brlcad.svn.sourceforge.net/brlcad/?rev=54526&view=rev
Author: indianlarry
Date: 2013-03-04 16:10:50 +0000 (Mon, 04 Mar 2013)
Log Message:
-----------
Added default constructor, AddOuterLoop() and GetPoints() functions for classes
CDT and SweepContext. Added parameters 'finalize(bool)' and 'num_points' to
Triangulate() function for class CDT and Sweep to be able to stop sweep at any
point for debugging. Also added 'num_points' parameter to SweepPoints()
function.
Modified Paths:
--------------
brlcad/trunk/src/other/poly2tri/poly2tri/sweep/cdt.cc
brlcad/trunk/src/other/poly2tri/poly2tri/sweep/cdt.h
brlcad/trunk/src/other/poly2tri/poly2tri/sweep/sweep.cc
brlcad/trunk/src/other/poly2tri/poly2tri/sweep/sweep.h
brlcad/trunk/src/other/poly2tri/poly2tri/sweep/sweep_context.cc
brlcad/trunk/src/other/poly2tri/poly2tri/sweep/sweep_context.h
Modified: brlcad/trunk/src/other/poly2tri/poly2tri/sweep/cdt.cc
===================================================================
--- brlcad/trunk/src/other/poly2tri/poly2tri/sweep/cdt.cc 2013-03-04
12:23:54 UTC (rev 54525)
+++ brlcad/trunk/src/other/poly2tri/poly2tri/sweep/cdt.cc 2013-03-04
16:10:50 UTC (rev 54526)
@@ -32,12 +32,22 @@
namespace p2t {
+CDT::CDT()
+{
+ sweep_context_ = new SweepContext();
+ sweep_ = new Sweep;
+}
+
CDT::CDT(std::vector<Point*> &polyline)
{
sweep_context_ = new SweepContext(polyline);
sweep_ = new Sweep;
}
+void CDT::AddOuterLoop(std::vector<Point*> &polyline)
+{
+ sweep_context_->AddOuterLoop(polyline);
+}
void CDT::AddHole(std::vector<Point*> &polyline)
{
sweep_context_->AddHole(polyline);
@@ -47,9 +57,13 @@
sweep_context_->AddPoint(point);
}
-void CDT::Triangulate()
+std::vector<Point*>& CDT::GetPoints() {
+ return sweep_context_->GetPoints();
+}
+
+void CDT::Triangulate(bool finalize, int num_points)
{
- sweep_->Triangulate(*sweep_context_);
+ sweep_->Triangulate(*sweep_context_, finalize, num_points);
}
std::vector<p2t::Triangle*>& CDT::GetTriangles()
Modified: brlcad/trunk/src/other/poly2tri/poly2tri/sweep/cdt.h
===================================================================
--- brlcad/trunk/src/other/poly2tri/poly2tri/sweep/cdt.h 2013-03-04
12:23:54 UTC (rev 54525)
+++ brlcad/trunk/src/other/poly2tri/poly2tri/sweep/cdt.h 2013-03-04
16:10:50 UTC (rev 54526)
@@ -53,12 +53,20 @@
*
* @param polyline
*/
+ CDT();
CDT(std::vector<Point*> &polyline);
/**
* Destructor - clean up memory
*/
~CDT();
+
+ /**
+ * Add outer loop
+ *
+ * @param polyline
+ */
+ void AddOuterLoop(std::vector<Point*> &polyline);
/**
* Add a hole
@@ -74,10 +82,12 @@
*/
void AddPoint(Point* point);
+ std::vector<Point*>& GetPoints();
+
/**
* Triangulate - do this AFTER you've added the polyline, holes, and Steiner
points
*/
- void Triangulate();
+ void Triangulate(bool finalize = true, int num_points = -1);
/**
* Get CDT triangles
Modified: brlcad/trunk/src/other/poly2tri/poly2tri/sweep/sweep.cc
===================================================================
--- brlcad/trunk/src/other/poly2tri/poly2tri/sweep/sweep.cc 2013-03-04
12:23:54 UTC (rev 54525)
+++ brlcad/trunk/src/other/poly2tri/poly2tri/sweep/sweep.cc 2013-03-04
16:10:50 UTC (rev 54526)
@@ -37,17 +37,19 @@
namespace p2t {
// Triangulate simple polygon with holes
-void Sweep::Triangulate(SweepContext& tcx)
+void Sweep::Triangulate(SweepContext& tcx, bool finalize, int num_points)
{
tcx.InitTriangulation();
tcx.CreateAdvancingFront(nodes_);
// Sweep points; build mesh
- SweepPoints(tcx);
+ SweepPoints(tcx,num_points);
// Clean up
- FinalizationPolygon(tcx);
+ if (finalize) {
+ FinalizationPolygon(tcx);
+ }
}
-void Sweep::SweepPoints(SweepContext& tcx)
+void Sweep::SweepPoints(SweepContext& tcx, int num_points)
{
for (size_t i = 1; i < tcx.point_count(); i++) {
Point& point = *tcx.GetPoint(i);
Modified: brlcad/trunk/src/other/poly2tri/poly2tri/sweep/sweep.h
===================================================================
--- brlcad/trunk/src/other/poly2tri/poly2tri/sweep/sweep.h 2013-03-04
12:23:54 UTC (rev 54525)
+++ brlcad/trunk/src/other/poly2tri/poly2tri/sweep/sweep.h 2013-03-04
16:10:50 UTC (rev 54526)
@@ -58,7 +58,7 @@
*
* @param tcx
*/
- void Triangulate(SweepContext& tcx);
+ void Triangulate(SweepContext& tcx, bool finalize = true, int num_points =
-1);
/**
* Destructor - clean up memory
@@ -72,7 +72,7 @@
*
* @param tcx
*/
- void SweepPoints(SweepContext& tcx);
+ void SweepPoints(SweepContext& tcx, int num_points = -1);
/**
* Find closes node to the left of the new point and
Modified: brlcad/trunk/src/other/poly2tri/poly2tri/sweep/sweep_context.cc
===================================================================
--- brlcad/trunk/src/other/poly2tri/poly2tri/sweep/sweep_context.cc
2013-03-04 12:23:54 UTC (rev 54525)
+++ brlcad/trunk/src/other/poly2tri/poly2tri/sweep/sweep_context.cc
2013-03-04 16:10:50 UTC (rev 54526)
@@ -34,11 +34,29 @@
namespace p2t {
+SweepContext::SweepContext()
+{
+ basin = Basin();
+ edge_event = EdgeEvent();
+}
+
SweepContext::SweepContext(std::vector<Point*> &polyline) : points_(polyline)
{
+
+ basin = Basin();
+ edge_event = EdgeEvent();
+
InitEdges(points_);
}
+void SweepContext::AddOuterLoop(std::vector<Point*> &polyline)
+{
+ InitEdges(polyline);
+ for(unsigned int i = 0; i < polyline.size(); i++) {
+ points_.push_back(polyline[i]);
+ }
+}
+
void SweepContext::AddHole(std::vector<Point*> &polyline)
{
InitEdges(polyline);
@@ -103,6 +121,11 @@
return points_[index];
}
+std::vector<Point*>& SweepContext::GetPoints()
+{
+ return points_;
+}
+
void SweepContext::AddToMap(Triangle* triangle)
{
map_.push_back(triangle);
Modified: brlcad/trunk/src/other/poly2tri/poly2tri/sweep/sweep_context.h
===================================================================
--- brlcad/trunk/src/other/poly2tri/poly2tri/sweep/sweep_context.h
2013-03-04 12:23:54 UTC (rev 54525)
+++ brlcad/trunk/src/other/poly2tri/poly2tri/sweep/sweep_context.h
2013-03-04 16:10:50 UTC (rev 54526)
@@ -52,6 +52,7 @@
public:
/// Constructor
+ SweepContext();
SweepContext(std::vector<Point*> &polyline);
/// Destructor
~SweepContext();
@@ -79,10 +80,11 @@
Point* GetPoint(size_t index);
-Point* GetPoints();
+std::vector<Point*>& GetPoints();
void RemoveFromMap(Triangle* triangle);
+void AddOuterLoop(std::vector<Point*> &polyline);
void AddHole(std::vector<Point*> &polyline);
void AddPoint(Point* point);
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_d2d_feb
_______________________________________________
BRL-CAD Source Commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/brlcad-commits