/**
     * Create all initial line segments. We can be certain there are no zero-length
     * lines as these are screened earlier.
     */
    void createInitialLineSegments(LineSegmentBlockTreeNode &rootNode)
    {
        for(Line *line : lines)
        {
            Sector *frontSec = line->frontSectorPtr();
            Sector *backSec  = line->backSectorPtr();

            // Handle the "one-way window" effect.
            if(!backSec && line->_bspWindowSector)
            {
                backSec = line->_bspWindowSector;
            }

            LineSegment *seg = makeLineSegment(line->from(), line->to(),
                                               frontSec, backSec, &line->front());

            if(seg->front().hasSector())
            {
                linkLineSegmentInBlockTree(rootNode, seg->front());
            }
            if(seg->back().hasSector())
            {
                linkLineSegmentInBlockTree(rootNode, seg->back());
            }

            edgeTipSet(line->from()) << EdgeTip(seg->front());
            edgeTipSet(line->to())   << EdgeTip(seg->back());
        }
    }
    /**
     * @return The new line segment (front is from @a start to @a end).
     */
    LineSegment *makeLineSegment(Vertex &start, Vertex &end, Sector *frontSec,
        Sector *backSec, LineSide *frontSide, Line *partitionLine = nullptr)
    {
        LineSegment *newSeg = new LineSegment(start, end);
        lineSegments << newSeg;

        LineSegmentSide &front = newSeg->front();
        front.setMapSide(frontSide);
        front.setPartitionMapLine(partitionLine);
        front.setSector(frontSec);

        LineSegmentSide &back = newSeg->back();
        back.setMapSide(frontSide? &frontSide->back() : nullptr);
        back.setPartitionMapLine(partitionLine);
        back.setSector(backSec);

        return newSeg;
    }