Programación en pseudocódigo
const int MAXPOLYV = 50
const int MAXH = 10;
Punto de estructura 2D
{float x , y;
};
typedef Vértice Point2D [max vert];
enum VerType = {Polígono, Intersección};
estructura typedef ClipListRec * ClipPtr
struct ClipListRec
{ int Vindex
ClipPtr siguiente
clase VerType;
Float t;
ClipPtr otherList
}
Estructura Polígono
{ int nVertex
int vert[MAXPOLYV ];
Lista ClipPtr;
}
Estructura polígono
{Polígono exterior;
int numHoles
Agujero poligonal [MAXH];
}
GenPolygon Sub, Clip
int ingresa a [MAXVERT], sale [max vert];
Vértice V;
int num vertex = 0; //Tamaño de la matriz vertical
int clip poly[max vert] //Recortar polígono
int num vertex = 0; p> p>
int punto de lectura();
CIN & gt; & gtinXCIN & gt; & gtinY
if(num vértice & lt;max vertical) p>
{ V[númVértice]. x = inX
V[númVértice]. y = inY
idNo = numVertex
num vértice++;
}
Otro
idNo =-1 ;
Devolver idNo
}
void readPolygon (GenPolygon p)
CIN & gt; & gtp . /p>
for(I = 0; i& ltp . exterior . nvertex; i++)
{ nuevoId = punto de lectura()
if(nuevoId & lt; 0; )
Error
Otro
{ insertAtRear (p.exterior.list, newId);
p exterior[ I . ]= newId;
}
}
//Ahora usa básicamente el mismo método para perforar agujeros
. . .
}
//Entonces el bucle del programa "principal" será (pseudocódigo)
while (!empty(enter))
{ nextInter = eliminar(entrada);
BUSCAR (SubjectPolygon, nextInter, ptr 1);
AddToOutputList(ptr 1-& gt;...)
punto de inicio = ptr 1->. . .
ptr 1 = PRT 1-> siguiente;
mientras(ptr 1->;...
. ! = punto de partida)
{ AddToOutputList(ptr 1->...);
if(ptr 1->;...==intersección)
ptr 1 = PRT 1->Otra lista->Siguiente;
Otro
ptr 1 = PRT 1->Siguiente;
}
FixListForOutput();
dibujar polígono();
EmptyOutputList();
}