Exemple #1
0
 function add(Vertex &$nv)
 {
     $this->x_min = min($this->x_min, $nv->X());
     $this->x_max = max($this->x_max, $nv->X());
     $this->y_min = min($this->y_min, $nv->Y());
     $this->y_max = max($this->y_max, $nv->Y());
     if ($this->cnt == 0) {
         $this->first = $nv;
         // Save a reference to it in the polygon
         $this->first->setNext($nv);
         // Set its pointer to point to itself
         $this->first->setPrev($nv);
         // because it is the only vertex in the list
         $ps = $this->first->Nseg();
         // Get ref to the Next segment object
         $this->first->setPseg($ps);
         // and save it as Prev segment as well
     } else {
         // $p <-> $nv <-> $n
         //    $ps     $ns
         $n = $this->first;
         // Get a ref to the first vertex in the list
         $p = $n->Prev();
         // Get ref to previous vertex
         $n->setPrev($nv);
         // Add at end of list (just before first)
         $nv->setNext($n);
         // link the new Vertex to it
         $nv->setPrev($p);
         // link to the pervious EOL vertex
         $p->setNext($nv);
         // And finally link the previous EOL vertex
         // Segments
         $ns = $nv->Nseg();
         // Get ref to the new next segment
         $ps = $p->Nseg();
         // Get ref to the previous segment
         $n->setPseg($ns);
         // Set new previous seg for $this->first
         $nv->setPseg($ps);
         // Set previous seg of the new Vertex
     }
     $this->cnt++;
     // Increment the count of vertices
 }