Shape.cpp revision d1096878fbd996664e5a90dfe4e03b81a999d783
2beebed98b4fc7f018fb224a1e4a3ab6103a4c0bCraig McDonnell * Created by fred on Thu Jun 12 2003.
2beebed98b4fc7f018fb224a1e4a3ab6103a4c0bCraig McDonnell * Shape instances handling.
f877f6ca2428244a6d0954a1dbef471577b32c60Diego Colantoni * never (i repeat: never) modify edges and points links; use Connect() and Disconnect() instead
caa9e77dc369fea8df9ae2c598d3c83b7214c1cfDiego Colantoni * the graph is stored as a set of points and edges, with edges in a doubly-linked list for each point.
415243fbc81341293a852ff6aa14e9608d08685cCraig McDonnell printf("sh=%p nbPt=%i nbAr=%i\n",this, _pts.size(), _aretes.size()); // localizing ok
91f0e3cb60de3eba8cbb70c7e36cc0df22d71f5bRobert Wapshott for (unsigned int i=0; i<_pts.size(); i++) {
91f0e3cb60de3eba8cbb70c7e36cc0df22d71f5bRobert Wapshott printf("pt %i : x=(%f %f) dI=%i dO=%i\n",i, _pts[i].x[0], _pts[i].x[1], _pts[i].dI, _pts[i].dO); // localizing ok
415243fbc81341293a852ff6aa14e9608d08685cCraig McDonnell for (unsigned int i=0; i<_aretes.size(); i++) {
415243fbc81341293a852ff6aa14e9608d08685cCraig McDonnell printf("ar %i : dx=(%f %f) st=%i en=%i\n",i, _aretes[i].dx[0], _aretes[i].dx[1], _aretes[i].st, _aretes[i].en); // localizing ok
415243fbc81341293a852ff6aa14e9608d08685cCraig McDonnell * Allocates space for point cache or clears the cache
415243fbc81341293a852ff6aa14e9608d08685cCraig McDonnell \param nVal Allocate a cache (true) or clear it (false)
78c07714ec1113f7f21c75b818f2bf6a7021618aDiego Colantoni /* no need to clean point data - keep it cached*/
if (_has_quick_raster_data == false)
_has_quick_raster_data = true;
_has_quick_raster_data = false;
if (nVal)
if (_has_sweep_src_data == false)
_has_sweep_src_data = true;
if (_has_sweep_src_data)
_has_sweep_src_data = false;
if (nVal)
if (_has_sweep_dest_data == false)
_has_sweep_dest_data = true;
if (_has_sweep_dest_data)
_has_sweep_dest_data = false;
if (nVal)
if (_has_back_data == false)
_has_back_data = true;
if (_has_back_data)
_has_back_data = false;
if (nVal)
if (_has_voronoi_data == false)
_has_voronoi_data = true;
if (_has_voronoi_data)
_has_voronoi_data = false;
Reset (0, 0);
MakePointData (false);
MakeEdgeData (false);
MakeSweepSrcData (false);
MakeSweepDestData (false);
MakeRasterData (false);
MakeQuickRasterData (false);
MakeBackData (false);
delete sTree;
delete sEvts;
_has_points_data = false;
_point_data_initialised = false;
_has_edges_data = false;
_has_sweep_src_data = false;
_has_sweep_dest_data = false;
_has_raster_data = false;
_has_quick_raster_data = false;
_has_back_data = false;
_has_voronoi_data = false;
_bbox_up_to_date = false;
if (_has_points_data)
if (_has_voronoi_data)
if (_has_edges_data)
if (_has_sweep_dest_data)
if (_has_sweep_src_data)
if (_has_back_data)
if (_has_voronoi_data)
_need_points_sorting = false;
_need_edges_sorting = false;
_point_data_initialised = false;
_bbox_up_to_date = false;
if (_has_points_data)
if (_has_voronoi_data)
dg_point p;
if (_has_points_data)
if (_has_voronoi_data)
_need_points_sorting = true;
if (p < 0 || p >= numberOfPoints())
_need_points_sorting = true;
int cb;
int cb;
while (cb >= 0)
while (cb >= 0)
while (cb >= 0)
if (_has_points_data)
if (_has_voronoi_data)
SwapPoints (a, b);
SwapPoints (b, c);
_need_points_sorting = false;
if (hasPoints())
SwapPoints (s, e);
int test = 0;
test = 0;
if (test == 0)
ppos--;
ppos--;
if (test > 0)
le++;
int test = 0;
test = 0;
if (test == 0)
plast++;
plast++;
if (test < 0)
ri--;
le++;
ri--;
ppos--;
plast--;
ppos--;
plast--;
ppos++;
plast++;
ppos++;
plast++;
if (getPoint(s).x[1] > getPoint(e).x[1] || (getPoint(s).x[1] == getPoint(e).x[1] && getPoint(s).x[0] > getPoint(e).x[0])
SwapPoints (s, e);
int test = 0;
test = 0;
if (test == 0)
ppos--;
ppos--;
if (test > 0)
le++;
int test = 0;
test = 0;
if (test == 0)
plast++;
plast++;
if (test < 0)
ri--;
le++;
ri--;
ppos--;
plast--;
ppos--;
plast--;
ppos++;
plast++;
ppos++;
plast++;
SwapPoints (s, e);
int test = 0;
test = 0;
if (test == 0)
ppos--;
ppos--;
if (test > 0)
le++;
int test = 0;
test = 0;
if (test == 0)
plast++;
plast++;
if (test < 0)
ri--;
le++;
ri--;
ppos--;
plast--;
ppos--;
plast--;
ppos++;
plast++;
ppos++;
plast++;
if (_has_edges_data)
if (_has_sweep_src_data)
if (_has_sweep_dest_data)
if (_has_raster_data)
if (_has_back_data)
if (_has_voronoi_data)
dg_arete a;
if (_has_edges_data)
if (_has_sweep_src_data)
if (_has_back_data)
if (_has_voronoi_data)
_need_edges_sorting = true;
while (cb >= 0)
if (_has_edges_data)
if (_has_sweep_src_data)
if (_has_sweep_dest_data)
if (_has_raster_data)
if (_has_back_data)
if (_has_voronoi_data)
dg_arete a;
if (_has_edges_data)
if (_has_sweep_src_data)
if (_has_back_data)
if (_has_voronoi_data)
_need_edges_sorting = true;
if (e < 0 || e >= numberOfEdges())
DisconnectStart (e);
DisconnectEnd (e);
_need_edges_sorting = true;
if (_has_edges_data)
if (_has_sweep_src_data)
if (_has_sweep_dest_data)
if (_has_raster_data)
if (_has_back_data)
if (_has_voronoi_data)
SwapEdges (a, b);
SwapEdges (b, c);
if (_need_edges_sorting == false) {
_need_edges_sorting = false;
for (int p = 0; p < numberOfPoints(); p++)
int cb;
int nb = 0;
while (cb >= 0)
int n = nb++;
for (int i = 0; i < nb; i++)
int tstAX = 0;
int tstAY = 0;
int tstBX = 0;
int tstBY = 0;
if (ax[0] > 0)
if (ax[0] < 0)
if (bx[0] > 0)
if (bx[0] < 0)
if (tstAX < 0)
if (tstAY < 0)
else if (tstAY == 0)
else if (tstAY > 0)
else if (tstAX == 0)
if (tstAY < 0)
quadA = 0;
else if (tstAY == 0)
else if (tstAY > 0)
else if (tstAX > 0)
if (tstAY < 0)
else if (tstAY == 0)
else if (tstAY > 0)
if (tstBX < 0)
if (tstBY < 0)
else if (tstBY == 0)
else if (tstBY > 0)
else if (tstBX == 0)
if (tstBY < 0)
quadB = 0;
else if (tstBY == 0)
else if (tstBY > 0)
else if (tstBX > 0)
if (tstBY < 0)
else if (tstBY == 0)
else if (tstBY > 0)
int tstSi = 0;
if ( tstSi == 0 ) {
return tstSi;
if (test == 0)
ppos--;
ppos--;
if (test > 0)
le++;
if (test == 0)
plast++;
plast++;
if (test < 0)
ri--;
le++;
ri--;
ppos--;
plast--;
ppos--;
plast--;
ppos++;
plast++;
ppos++;
plast++;
DisconnectStart (b);
DisconnectEnd (b);
int swap;
if (_has_edges_data)
if (_has_sweep_dest_data)
if (_has_back_data)
if (_has_voronoi_data)
if (_bbox_up_to_date)
if (hasPoints() == false)
_bbox_up_to_date = true;
bool not_set=true;
for (int i = 0; i < numberOfPoints(); i++)
if ( not_set ) {
not_set=false;
_bbox_up_to_date = true;
for (int i = 0; i < numberOfEdges(); i++)
if (cote == 0) continue;
if (cote < 0) {
int const N = numberOfPoints();
_point_data_initialised = true;
int const N = numberOfEdges();
for (int i = 0; i < s->numberOfPoints(); i++) {
if ( s->hasPoints() == false) {
for (int i = 0; i < s->numberOfPoints(); i++) {
for (int i = 0; i < s->numberOfEdges(); i++) {
if ( s->hasPoints() == false ) {
/* TODO: Efficiency: In one test case (scribbling with the freehand tool to create a small number of long
for (int i = 0; i < s->numberOfPoints(); i++) {
for (int i = 0; i < s->numberOfEdges(); i++) {