コード例 #1
0
ファイル: Polygon.php プロジェクト: babkinandreyhm/polygon
 function add(Vertex $nv)
 {
     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
 }