Revision: 54517
          http://brlcad.svn.sourceforge.net/brlcad/?rev=54517&view=rev
Author:   indianlarry
Date:     2013-03-01 18:58:00 +0000 (Fri, 01 Mar 2013)
Log Message:
-----------
Added FindInternalTriangle() function with supporting details to more reliably 
find an initial triangle within the trimming constrained edges.

Modified Paths:
--------------
    brlcad/trunk/src/other/poly2tri/poly2tri/common/shapes.cc
    brlcad/trunk/src/other/poly2tri/poly2tri/common/shapes.h
    brlcad/trunk/src/other/poly2tri/poly2tri/sweep/sweep.cc
    brlcad/trunk/src/other/poly2tri/poly2tri/sweep/sweep.h

Modified: brlcad/trunk/src/other/poly2tri/poly2tri/common/shapes.cc
===================================================================
--- brlcad/trunk/src/other/poly2tri/poly2tri/common/shapes.cc   2013-03-01 
18:06:27 UTC (rev 54516)
+++ brlcad/trunk/src/other/poly2tri/poly2tri/common/shapes.cc   2013-03-01 
18:58:00 UTC (rev 54517)
@@ -40,6 +40,7 @@
   constrained_edge[0] = constrained_edge[1] = constrained_edge[2] = false;
   delaunay_edge[0] = delaunay_edge[1] = delaunay_edge[2] = false;
   interior_ = false;
+  checked_ = false;
 }
 
 // Update neighbor pointers

Modified: brlcad/trunk/src/other/poly2tri/poly2tri/common/shapes.h
===================================================================
--- brlcad/trunk/src/other/poly2tri/poly2tri/common/shapes.h    2013-03-01 
18:06:27 UTC (rev 54516)
+++ brlcad/trunk/src/other/poly2tri/poly2tri/common/shapes.h    2013-03-01 
18:58:00 UTC (rev 54517)
@@ -202,6 +202,9 @@
 inline bool IsInterior();
 inline void IsInterior(bool b);
 
+inline bool IsChecked();
+inline void IsChecked(bool b);
+
 void DebugPrint();
 
 private:
@@ -213,6 +216,8 @@
 
 /// Has this triangle been marked as an interior triangle?
 bool interior_;
+/// Has this triangle been checked as an interior triangle?
+bool checked_;
 };
 
 inline bool cmp(const Point* a, const Point* b)
@@ -317,6 +322,16 @@
   interior_ = b;
 }
 
+inline bool Triangle::IsChecked()
+{
+  return checked_;
 }
 
+inline void Triangle::IsChecked(bool b)
+{
+       checked_ = b;
+}
+
+}
+
 #endif
\ No newline at end of file

Modified: brlcad/trunk/src/other/poly2tri/poly2tri/sweep/sweep.cc
===================================================================
--- brlcad/trunk/src/other/poly2tri/poly2tri/sweep/sweep.cc     2013-03-01 
18:06:27 UTC (rev 54516)
+++ brlcad/trunk/src/other/poly2tri/poly2tri/sweep/sweep.cc     2013-03-01 
18:58:00 UTC (rev 54517)
@@ -57,15 +57,37 @@
     }
   }
 }
+Triangle* Sweep::FindInternalTriangle(Triangle* ext_tri)
+{
+       Triangle* t = NULL;
 
+       if (ext_tri != NULL) {
+               if (ext_tri->constrained_edge[0]) {
+                       return ext_tri->GetNeighbor(0);
+               } else if (ext_tri->constrained_edge[1]) {
+                       return ext_tri->GetNeighbor(1);
+               } else if (ext_tri->constrained_edge[2]) {
+                       return ext_tri->GetNeighbor(2);
+               } else {
+                       ext_tri->IsChecked(true);
+                       for(int i=0; i<3; i++) {
+                               Triangle* n = ext_tri->GetNeighbor(i);
+                               if ((n != NULL) && (!n->IsChecked())) {
+                                       t = FindInternalTriangle(n);
+                                       if (t != NULL)
+                                               break;
+                               }
+                       }
+               }
+       }
+       return t;
+}
 void Sweep::FinalizationPolygon(SweepContext& tcx)
 {
   // Get an Internal triangle to start with
   Triangle* t = tcx.front()->head()->next->triangle;
   Point* p = tcx.front()->head()->next->point;
-  while (!t->GetConstrainedEdgeCW(*p)) {
-    t = t->NeighborCCW(*p);
-  }
+  t = FindInternalTriangle(tcx.af_tail_->triangle);
 
   // Collect interior triangles constrained by edges
   tcx.MeshClean(*t);

Modified: brlcad/trunk/src/other/poly2tri/poly2tri/sweep/sweep.h
===================================================================
--- brlcad/trunk/src/other/poly2tri/poly2tri/sweep/sweep.h      2013-03-01 
18:06:27 UTC (rev 54516)
+++ brlcad/trunk/src/other/poly2tri/poly2tri/sweep/sweep.h      2013-03-01 
18:58:00 UTC (rev 54517)
@@ -274,6 +274,8 @@
      */
   void FlipScanEdgeEvent(SweepContext& tcx, Point& ep, Point& eq, Triangle& 
flip_triangle, Triangle& t, Point& p);
 
+  Triangle* FindInternalTriangle(Triangle* ext_tri);
+
   void FinalizationPolygon(SweepContext& tcx);
 
   std::vector<Node*> nodes_;

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

Reply via email to