ShapeRaster.cpp revision 487300adfe55623187bc9af8e52022f2bfcd82b7
/*
* nlivarot
*
* Created by fred on Sat Jul 19 2003.
*
*/
#include "Shape.h"
#include "livarot/float-line.h"
#include "AlphaLigne.h"
#include "BitLigne.h"
#include "livarot/sweep-event-queue.h"
#include "livarot/sweep-tree-list.h"
#include "livarot/sweep-tree.h"
/*
* polygon rasterization: the sweepline algorithm in all its glory
* nothing unusual in this implementation, so nothing special to say
* the *Quick*() functions are not useful. forget about them
*/
{
curPt = 0;
pos = 0;
return;
}
MakeRasterData(true);
MakePointData(true);
MakeEdgeData(true);
}
}
SortPoints();
curPt = 0;
for (int i = 0; i < numberOfPoints(); i++) {
}
for (int i = 0;i < numberOfEdges(); i++) {
}
}
{
delete sTree;
delete sEvts;
MakePointData(false);
MakeEdgeData(false);
MakeRasterData(false);
}
{
curPt = 0;
pos = 0;
return;
}
MakeRasterData(true);
MakeQuickRasterData(true);
nbQRas = 0;
MakePointData(true);
MakeEdgeData(true);
curPt = 0;
for (int i=0;i<numberOfEdges();i++) {
}
SortPoints();
// SortPointsRounded();
}
void Shape::EndQuickRaster()
{
MakePointData(false);
MakeEdgeData(false);
MakeRasterData(false);
MakeQuickRasterData(false);
}
// 2 versions of the Scan() series to move the scanline to a given position withou actually computing coverages
{
if ( numberOfEdges() <= 1 ) {
return;
}
return;
}
enum Direction {
};
// points of the polygon are sorted top-down, so we take them in order, starting with the one at index curP,
// until we reach the wanted position to.
// don't forget to update curP and pos when we're done
{
// treat a new point: remove and add edges incident to it
int nbUp;
int nbDn;
int upNo;
int dnNo;
if ( d == DOWNWARDS ) {
if ( nbDn <= 0 ) {
upNo = -1;
}
upNo = -1;
}
} else {
if ( nbUp <= 0 ) {
dnNo = -1;
}
dnNo = -1;
}
}
// first remove edges coming from above or below, as appropriate
{
// we salvage the edge upNo to plug the edges we'll be addingat its place
// but the other edge don't have this chance
if ( node ) {
}
}
}
}
}
// if there is one edge going down and one edge coming from above, we don't Insert() the new edge,
// but replace the upNo edge by the new one (faster)
if ( dnNo >= 0 ) {
if ( upNo >= 0 ) {
} else {
// always DOWNWARDS
//if (d == UPWARDS) {
// node->startPoint = Other(nPt, dnNo);
//}
}
} else {
if ( upNo >= 0 ) {
// always UPWARDS
//if (d == UPWARDS) {
//}
}
}
// add the remaining edges
// si nbDn == 1 , alors dnNo a deja ete traite
if (d == UPWARDS) {
}
}
}
}
}
}
if ( curPt > 0 ) {
} else {
}
// the final touch: edges intersecting the sweepline must be update so that their intersection with
// said sweepline is correct.
while ( curS ) {
}
}
}
{
if ( numberOfEdges() <= 1 ) {
return;
}
return;
}
enum Direction {
};
{
int nbUp;
int nbDn;
int upNo;
int dnNo;
if ( nbDn <= 0 ) {
upNo = -1;
}
upNo = -1;
}
if ( nbUp > 0 ) {
{
}
}
}
}
// traitement du "upNo devient dnNo"
int ins_guess = -1;
if ( dnNo >= 0 ) {
if ( upNo >= 0 ) {
} else {
}
}
{
}
}
}
}
if ( curPt > 0 ) {
} else {
}
}
for (int i=0; i < nbQRas; i++) {
}
}
{
return -1;
}
if ( no >= 0 ) {
}
return no;
}
{
return -1;
}
if ( firstQRas < 0 ) {
return no;
}
int c = firstQRas;
}
if ( c < 0 || c >= nbQRas ) {
} else {
} else {
}
}
} else {
int c = guess;
if ( stTst == 0 ) {
} else {
}
} else if ( stTst > 0 ) {
}
if ( c < 0 || c >= nbQRas ) {
} else {
} else {
}
}
} else {
}
if ( c < 0 || c >= nbQRas ) {
} else {
} else {
}
}
}
}
return no;
}
{
return; // euuhHHH
}
}
}
}
}
if ( nbQRas > 0 ) {
}
}
}
}
}
}
void Shape::QuickRasterSwapEdge(int a, int b)
{
if ( a == b ) {
return;
}
return; // errrm
}
}
void Shape::QuickRasterSort()
{
if ( nbQRas <= 1 ) {
return;
}
while ( cb >= 0 ) {
if ( nI < 0 ) {
break;
}
if ( pI < 0 ) {
} else {
}
} else {
}
}
}
// direct scan to a given position. goes through the edge list to keep only the ones intersecting the target sweepline
// good for initial setup of scanline algo, bad for incremental changes
{
if ( numberOfEdges() <= 1 ) {
return;
}
return;
}
// we're moving downwards
// points of the polygon are sorted top-down, so we take them in order, starting with the one at index curP,
// until we reach the wanted position to.
// don't forget to update curP and pos when we're done
curPt++;
}
for (int i=0;i<numberOfEdges();i++) {
}
}
for (int i=0; i < numberOfEdges(); i++) {
// crosses sweepline
}
}
if ( curPt > 0 ) {
} else {
}
} else {
// same thing, but going up. so the sweepSens is inverted for the Find() function
curPt--;
}
for (int i = 0; i < numberOfEdges(); i++) {
}
}
for (int i=0;i<numberOfEdges();i++) {
// crosses sweepline
}
}
if ( curPt > 0 ) {
} else {
}
}
// the final touch: edges intersecting the sweepline must be update so that their intersection with
// said sweepline is correct.
while ( curS ) {
}
}
}
{
if ( numberOfEdges() <= 1 ) {
return;
}
return;
}
// we're moving downwards
// points of the polygon are sorted top-down, so we take them in order, starting with the one at index curP,
// until we reach the wanted position to.
// don't forget to update curP and pos when we're done
curPt++;
}
for (int i = 0; i < numberOfEdges(); i++) {
}
}
for (int i = 0; i < numberOfEdges(); i++) {
// crosses sweepline
}
}
if ( curPt > 0 ) {
} else {
}
} else {
// same thing, but going up. so the sweepSens is inverted for the Find() function
curPt--;
}
for (int i = 0; i < numberOfEdges(); i++) {
}
}
for (int i=0;i<numberOfEdges();i++) {
// crosses sweepline
}
}
if ( curPt > 0 ) {
} else {
}
}
for (int i = 0; i < nbQRas; i++) {
}
}
// scan and compute coverage, FloatLigne version coverage of the line is bult in 2 parts: first a
// set of rectangles of height the height of the line (here: "step") one rectangle for each portion
// of the sweepline that is in the polygon at the beginning of the scan. then a set ot trapezoids
// are added or removed to these rectangles, one trapezoid for each edge destroyed or edge crossing
// the entire line. think of it as a refinement of the coverage by rectangles
{
if ( numberOfEdges() <= 1 ) {
return;
}
return;
}
// first step: the rectangles since we read the sweepline left to right, we know the
// boundaries of the rectangles are appended in a list, hence the AppendBord(). we salvage
// the guess value for the trapezoids the edges will induce
while ( curS ) {
int lastGuess = -1;
} else {
}
}
}
// same thing as the usual Scan(), just with a hardcoded "indegree+outdegree=2" case, since
// it's the most common one
int nbUp;
int nbDn;
int upNo;
int dnNo;
} else {
}
if ( nbDn <= 0 ) {
upNo = -1;
}
upNo = -1;
}
if ( node ) {
// create trapezoid for the chunk of edge intersecting with the line
}
}
}
}
}
// traitement du "upNo devient dnNo"
if ( dnNo >= 0 ) {
if ( upNo >= 0 ) {
} else {
}
}
}
}
}
}
}
if ( curPt > 0 ) {
} else {
}
// update intersections with the sweepline, and add trapezoids for edges crossing the line
while ( curS ) {
}
}
}
void Shape::Scan(float &pos, int &curP, float to, FillRule directed, BitLigne *line, bool exact, float step)
{
if ( numberOfEdges() <= 1 ) {
return;
}
return;
}
int curW = 0;
float lastX = 0;
if ( directed == fill_oddEven ) {
while ( curS ) {
curW++;
curW &= 0x00000001;
if ( curW == 0 ) {
} else {
}
}
} else if ( directed == fill_positive ) {
// doesn't behave correctly; no way i know to do this without a ConvertToShape()
while ( curS ) {
curW++;
} else {
curW--;
}
}
}
} else if ( directed == fill_nonZero ) {
while ( curS ) {
curW++;
} else {
curW--;
}
}
}
}
}
int cb;
int nbUp;
int nbDn;
int upNo;
int dnNo;
} else {
}
if ( nbDn <= 0 ) {
upNo = -1;
}
upNo = -1;
}
if ( node ) {
}
}
}
}
}
// traitement du "upNo devient dnNo"
if ( dnNo >= 0 ) {
if ( upNo >= 0 ) {
} else {
}
}
}
}
}
}
}
if ( curPt > 0 ) {
} else {
}
while ( curS ) {
}
}
}
{
if ( numberOfEdges() <= 1 ) {
return;
}
return;
}
int nbUp;
int nbDn;
int upNo;
int dnNo;
} else {
}
if ( nbDn <= 0 ) {
upNo=-1;
}
upNo=-1;
}
if ( node ) {
}
}
}
}
}
// traitement du "upNo devient dnNo"
if ( dnNo >= 0 ) {
if ( upNo >= 0 ) {
} else {
}
}
}
}
}
}
}
if ( curPt > 0 ) {
} else {
}
while ( curS ) {
}
}
}
{
if ( numberOfEdges() <= 1 ) {
return;
}
return;
}
if ( nbQRas > 1 ) {
int curW = 0;
// float lastX = 0;
// float lastY = 0;
int lastGuess = -1;
int lastB = -1;
curW++;
} else {
curW--;
}
0.0);
if ( lastB >= 0 ) {
}
// lastX = swrData[cb].curX;
// lastY = swrData[cb].curY;
} else {
}
}
}
int nbUp;
int nbDn;
int upNo;
int dnNo;
} else {
}
if ( nbDn <= 0 ) {
upNo = -1;
}
upNo = -1;
}
}
}
}
}
// traitement du "upNo devient dnNo"
int ins_guess=-1;
if ( dnNo >= 0 ) {
if ( upNo >= 0 ) {
} else {
}
}
}
}
}
}
}
if ( curPt > 0 ) {
} else {
}
for (int i=0; i < nbQRas; i++) {
}
}
void Shape::QuickScan(float &pos, int &curP, float to, FillRule directed, BitLigne* line, float step)
{
if ( numberOfEdges() <= 1 ) {
return;
}
return;
}
if ( nbQRas > 1 ) {
int curW = 0;
float lastX = 0;
if ( directed == fill_oddEven ) {
curW++;
curW &= 1;
if ( curW == 0 ) {
} else {
}
}
} else if ( directed == fill_positive ) {
// doesn't behave correctly; no way i know to do this without a ConvertToShape()
curW++;
} else {
curW--;
}
}
}
} else if ( directed == fill_nonZero ) {
curW++;
} else {
curW--;
}
}
}
}
}
int nbUp;
int nbDn;
int upNo;
int dnNo;
} else {
}
if ( nbDn <= 0 ) {
upNo = -1;
}
upNo = -1;
}
}
}
}
}
// traitement du "upNo devient dnNo"
int ins_guess = -1;
if ( dnNo >= 0 ) {
if ( upNo >= 0 ) {
} else {
}
}
}
}
}
}
}
if ( curPt > 0 ) {
} else {
}
for (int i = 0; i < nbQRas; i++) {
}
}
{
if ( numberOfEdges() <= 1 ) {
return;
}
return;
}
int nbUp;
int nbDn;
int upNo;
int dnNo;
} else {
}
if ( nbDn <= 0 ) {
upNo = -1;
}
upNo = -1;
}
}
}
}
}
// traitement du "upNo devient dnNo"
int ins_guess = -1;
if ( dnNo >= 0 ) {
if ( upNo >= 0 ) {
} else {
}
}
}
}
}
}
}
if ( curPt > 0 ) {
} else {
}
for (int i = 0; i < nbQRas; i++) {
}
}
/*
* operations de bases pour la rasterization
*
*/
{
int cPt;
} else {
}
} else {
}
} else {
}
}
{
if ( exact ) {
} else {
}
} else {
}
} else {
}
}
/*
* specialisation par type de structure utilise
*/
{
}
} else {
}
}
}
{
}
} else {
}
}
}
{
}
} else {
}
}
}
{
}
} else {
}
}
}
{
0,
0,
}
} else {
0,
0,
}
}
}
{
0,
0,
}
} else {
0,
0,
}
}
}
/**
* \param P point index.
* \param numberUp Filled in with the number of edges coming into P from above.
* \param numberDown Filled in with the number of edges coming exiting P to go below.
* \param upEdge One of the numberUp edges, or -1.
* \param downEdge One of the numberDown edges, or -1.
*/
{
*numberUp = 0;
*numberDown = 0;
*upEdge = -1;
*downEdge = -1;
while ( i >= 0 && i < numberOfEdges() ) {
*upEdge = i;
(*numberUp)++;
}
*downEdge = i;
(*numberDown)++;
}
i = NextAt(P, i);
}
}
/**
* Version of Shape::_countUpDown optimised for the case when getPoint(P).totalDegree() == 2.
*/
void Shape::_countUpDownTotalDegree2(int P,
{
*numberUp = 0;
*numberDown = 0;
*upEdge = -1;
*downEdge = -1;
for (int i = 0; i < 2; i++) {
int const j = getPoint(P).incidentEdge[i];
*upEdge = j;
(*numberUp)++;
}
*downEdge = j;
(*numberDown)++;
}
}
}
void Shape::_updateIntersection(int e, int p)
{
}
/*
Local Variables:
mode:c++
c-file-style:"stroustrup"
c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
indent-tabs-mode:nil
fill-column:99
End:
*/
// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :