Exemplo n.º 1
0
void QSegmentWidget::clearSegment(int cyl, qreal startAngle, qreal stopAngle)
{
  Segment s(startAngle, stopAngle, QColor(Qt::black));
  SegmentList sl;
  sl.push_back(s);
  clearSegments(cyl, sl);
}
Exemplo n.º 2
0
void QSegmentWidget::DrawSegments(QPainter *painter,
  const SegmentList &s, qreal radius)
{
  for (SegmentList::const_iterator i = s.begin(); i != s.end(); i++) {
    painter->setRenderHint(QPainter::Antialiasing);
    painter->setRenderHint(QPainter::SmoothPixmapTransform);
    QBrush b(i->color);
    painter->setBrush(b);
    QBrush c(i->color.darker(200));
    painter->setPen(QPen(c, 0));
    int startAngle = qRound(i->first * 16.0);
    qreal dAngle = i->second - i->first;
    if (dAngle < 0.0)
      dAngle += 360.0;
    int spanAngle = qRound(dAngle * 16.0);
    QRectF r(-radius, -radius, radius * 2.0, radius * 2.0);
    if (spanAngle >= 360 * 16) {
//      qDebug() << QString("DrawSegments drawEllipse (%1, %2)").arg(-radius).arg(radius * 2.0);
      painter->drawEllipse(r);
    } else {
//      qDebug() << QString("DrawSegments drawPie (%1, %2, %3, %4)").arg(-radius).arg(radius * 2.0).arg(startAngle).arg(spanAngle);
      painter->drawPie(r, startAngle, spanAngle);
    }
  }
}
Exemplo n.º 3
0
void BoxShape::getExcludedIntervals(LayoutUnit logicalTop, LayoutUnit logicalHeight, SegmentList& result) const
{
    if (m_marginBounds.isEmpty())
        return;

    float y1 = logicalTop;
    float y2 = logicalTop + logicalHeight;
    const FloatRect& rect = m_marginBounds.rect();

    if (y2 <= rect.y() || y1 >= rect.maxY())
        return;

    if (!m_marginBounds.isRounded()) {
        result.append(LineSegment(m_marginBounds.rect().x(), m_marginBounds.rect().maxX()));
        return;
    }

    float x1 = rect.maxX();
    float x2 = rect.x();
    float minXIntercept;
    float maxXIntercept;

    if (m_marginBounds.xInterceptsAtY(y1, minXIntercept, maxXIntercept)) {
        x1 = std::min<float>(x1, minXIntercept);
        x2 = std::max<float>(x2, maxXIntercept);
    }

    if (m_marginBounds.xInterceptsAtY(y1, minXIntercept, maxXIntercept)) {
        x1 = std::min<float>(x1, minXIntercept);
        x2 = std::max<float>(x2, maxXIntercept);
    }

    ASSERT(x2 >= x1);
    result.append(LineSegment(x1, x2));
}
Exemplo n.º 4
0
void ShapeOutsideInfo::updateDeltasForContainingBlockLine(const RenderBlockFlow* containingBlock, const FloatingObject* floatingObject, LayoutUnit lineTop, LayoutUnit lineHeight)
{
    LayoutUnit shapeTop = containingBlock->logicalTopForFloat(floatingObject) + std::max(LayoutUnit(), containingBlock->marginBeforeForChild(*m_renderer));
    LayoutUnit lineTopInShapeCoordinates = lineTop - shapeTop + logicalTopOffset();

    if (shapeSizeDirty() || m_lineTop != lineTopInShapeCoordinates || m_lineHeight != lineHeight) {
        m_lineTop = lineTopInShapeCoordinates;
        m_shapeLineTop = lineTopInShapeCoordinates - logicalTopOffset();
        m_lineHeight = lineHeight;

        LayoutUnit floatMarginBoxWidth = containingBlock->logicalWidthForFloat(floatingObject);

        if (lineOverlapsShapeBounds()) {
            SegmentList segments = computeSegmentsForLine(lineTopInShapeCoordinates, lineHeight);
            if (segments.size()) {
                LayoutUnit rawLeftMarginBoxDelta = segments.first().logicalLeft + containingBlock->marginStartForChild(*m_renderer);
                m_leftMarginBoxDelta = clampTo<LayoutUnit>(rawLeftMarginBoxDelta, LayoutUnit(), floatMarginBoxWidth);

                LayoutUnit rawRightMarginBoxDelta = segments.last().logicalRight - containingBlock->logicalWidthForChild(*m_renderer) - containingBlock->marginEndForChild(*m_renderer);
                m_rightMarginBoxDelta = clampTo<LayoutUnit>(rawRightMarginBoxDelta, -floatMarginBoxWidth, LayoutUnit());
                return;
            }
        }

        // Lines that do not overlap the shape should act as if the float
        // wasn't there for layout purposes. So we set the deltas to remove the
        // entire width of the float. 
        // FIXME: The latest CSS Shapes spec says that in this case, the
        // content should interact with previously stacked floats on the line
        // as if this outermost float did not exist. Perhaps obviously, this
        // solution cannot do that, and will be revisted with bug 122576.
        m_leftMarginBoxDelta = floatMarginBoxWidth;
        m_rightMarginBoxDelta = -floatMarginBoxWidth;
    }
}
Exemplo n.º 5
0
void Tessellation::generateExtrusionContour()
{
	for( auto& pos : positions )
		extrusionContourVertices.push_back( pos );

	extrusionContourIndices = segments;

	SegmentList additionalSegments;

	Vector n;
	int originalSegments = extrusionContourIndices.size();
	for( auto& segment : extrusionContourIndices )
	{
		auto& a = positions[ segment.i1 ];
		auto& b = positions[ segment.i2 ];

		n.x = (float)(a.y - b.y);
		n.y = (float)(b.x - a.x);
		n = n.normalized();

		_assignNormal( n, segment, 0, additionalSegments );
		_assignNormal( n, segment, 1, additionalSegments );
	}

	//add the created segments to the extrusion segments
	extrusionContourIndices.insert( extrusionContourIndices.end(), additionalSegments.begin(), additionalSegments.end() );
}
Exemplo n.º 6
0
bool SegmentInformation::getSegmentNumberByTime(mtime_t time, uint64_t *ret) const
{
    SegmentList *segList;
    MediaSegmentTemplate *mediaTemplate;
    uint64_t timescale = 1;
    mtime_t duration = 0;

    if( (mediaTemplate = inheritSegmentTemplate()) )
    {
        timescale = mediaTemplate->inheritTimescale();
        duration = mediaTemplate->duration.Get();
    }
    else if ( (segList = inheritSegmentList()) )
    {
        timescale = segList->inheritTimescale();
        duration = segList->getDuration();
    }

    if(duration)
    {
        *ret = time / (CLOCK_FREQ * duration / timescale);
        return true;
    }

    return false;
}
Exemplo n.º 7
0
void BoxShape::getIncludedIntervals(LayoutUnit logicalTop, LayoutUnit logicalHeight, SegmentList& result) const
{
    const FloatRoundedRect& paddingBounds = shapePaddingBounds();
    if (paddingBounds.isEmpty())
        return;

    const FloatRect& rect = paddingBounds.rect();
    float y1 = logicalTop;
    float y2 = logicalTop + logicalHeight;

    if (y1 < rect.y() || y2 > rect.maxY())
        return;

    if (!paddingBounds.isRounded()) {
        result.append(LineSegment(rect.x(), rect.maxX()));
        return;
    }

    float x1 = rect.x();
    float x2 = rect.maxX();
    float minXIntercept;
    float maxXIntercept;

    if (paddingBounds.xInterceptsAtY(y1, minXIntercept, maxXIntercept)) {
        x1 = std::max<float>(x1, minXIntercept);
        x2 = std::min<float>(x2, maxXIntercept);
    }

    if (paddingBounds.xInterceptsAtY(y2, minXIntercept, maxXIntercept)) {
        x1 = std::max<float>(x1, minXIntercept);
        x2 = std::min<float>(x2, maxXIntercept);
    }

    result.append(LineSegment(x1, x2));
}
Exemplo n.º 8
0
void ShapeOutsideInfo::updateDeltasForContainingBlockLine(const RenderBlockFlow& containingBlock, const FloatingObject& floatingObject, LayoutUnit lineTop, LayoutUnit lineHeight)
{
    LayoutUnit borderBoxTop = containingBlock.logicalTopForFloat(&floatingObject) + containingBlock.marginBeforeForChild(&m_renderer);
    LayoutUnit borderBoxLineTop = lineTop - borderBoxTop;

    if (isShapeDirty() || m_borderBoxLineTop != borderBoxLineTop || m_lineHeight != lineHeight) {
        m_borderBoxLineTop = borderBoxLineTop;
        m_referenceBoxLineTop = borderBoxLineTop - logicalTopOffset();
        m_lineHeight = lineHeight;

        LayoutUnit floatMarginBoxWidth = containingBlock.logicalWidthForFloat(&floatingObject);

        if (lineOverlapsShapeBounds()) {
            SegmentList segments = computeSegmentsForLine(borderBoxLineTop, lineHeight);
            if (segments.size()) {
                LayoutUnit logicalLeftMargin = containingBlock.style()->isLeftToRightDirection() ? containingBlock.marginStartForChild(&m_renderer) : containingBlock.marginEndForChild(&m_renderer);
                LayoutUnit rawLeftMarginBoxDelta = segments.first().logicalLeft + logicalLeftMargin;
                m_leftMarginBoxDelta = clampToLayoutUnit(rawLeftMarginBoxDelta, LayoutUnit(), floatMarginBoxWidth);

                LayoutUnit logicalRightMargin = containingBlock.style()->isLeftToRightDirection() ? containingBlock.marginEndForChild(&m_renderer) : containingBlock.marginStartForChild(&m_renderer);
                LayoutUnit rawRightMarginBoxDelta = segments.last().logicalRight - containingBlock.logicalWidthForChild(&m_renderer) - logicalRightMargin;
                m_rightMarginBoxDelta = clampToLayoutUnit(rawRightMarginBoxDelta, -floatMarginBoxWidth, LayoutUnit());
                m_lineOverlapsShape = true;
                return;
            }
        }

        // Lines that do not overlap the shape should act as if the float
        // wasn't there for layout purposes. So we set the deltas to remove the
        // entire width of the float.
        m_leftMarginBoxDelta = floatMarginBoxWidth;
        m_rightMarginBoxDelta = -floatMarginBoxWidth;
        m_lineOverlapsShape = false;
    }
}
Exemplo n.º 9
0
mtime_t SegmentInformation::getPlaybackTimeBySegmentNumber(uint64_t number) const
{
    SegmentList *segList;
    MediaSegmentTemplate *mediaTemplate;
    mtime_t time = 0;
    if( (mediaTemplate = inheritSegmentTemplate()) )
    {
        uint64_t timescale = mediaTemplate->inheritTimescale();
        if(mediaTemplate->segmentTimeline.Get())
        {
            time = mediaTemplate->segmentTimeline.Get()->
                    getScaledPlaybackTimeByElementNumber(number);
        }
        else
        {
            time = number * mediaTemplate->duration.Get();
        }
        time = CLOCK_FREQ * time / timescale;
    }
    else if ( (segList = inheritSegmentList()) )
    {
        time = segList->getPlaybackTimeBySegmentNumber(number);
    }

    return time;
}
Exemplo n.º 10
0
FileInfo*
PieView::_FileAt(const BPoint& where)
{
	BRect b = Bounds();
	float cx = b.left + b.Width() / 2.0;
	float cy = b.top + b.Height() / 2.0;
	float dx = where.x - cx;
	float dy = where.y - cy;
	float dist = sqrt(dx*dx + dy*dy);

	int level;
	if (dist < kPieCenterSize)
		level = 0;
	else
		level = 1 + (int)((dist - kPieCenterSize) / kPieRingSize);

	float angle = rad2deg(atan(dy / dx));
	angle = ((dx < 0.0) ? 180.0 : (dy < 0.0) ? 0.0 : 360.0) - angle;

	if (fMouseOverInfo.find(level) == fMouseOverInfo.end()) {
		// No files in this level (ring) of the pie.
		return NULL;
	}

	SegmentList s = fMouseOverInfo[level];
	SegmentList::iterator i = s.begin();
	while (i != s.end() && (angle < (*i).begin || (*i).end < angle))
		i++;
	if (i == s.end()) {
		// Nothing at this angle.
		return NULL;
	}

	return (*i).info;
}
Exemplo n.º 11
0
QGraphicsScene * ClusteredArranger::arrange(SegmentList const & segments) const {
   QGraphicsScene * arrangement = new QGraphicsScene();

   QTime time;
   time.start();

   // determine background
   Segment * background = determineBackground(segments);
   SegmentList segmentsWOBack = removeBackground(segments, background);
   arrangement->setBackgroundBrush(QBrush(QColor(background->color().toQRgb())));
   segmentsWOBack.calculateFeatureVariances();

   // initialize layout
   //initializeLayout(segmentsWOBack, segmentsWOBack.featX(), segmentsWOBack.featY());
   initializeLayout(segmentsWOBack, xAxisBox->currentIndex(), yAxisBox->currentIndex());

   // find clusters
   time.restart();
   QList<SegmentList> clusters = meanShift(segmentsWOBack);
   qDebug("Segments clustered in %f seconds", time.restart()/1000.0);
   qDebug("  %d clusters found", clusters.size());

   // refine clusters
   //int counter = 0;
   foreach (SegmentList cluster, clusters) {
      if (clusterBox->currentIndex() == 0) {
         refineLayoutCircles(cluster);
      }
      else if (clusterBox->currentIndex() == 1) {
         refineLayoutPiles(cluster);
      }

      // debug output
      /*QGraphicsScene scene;
      scene.setBackgroundBrush(QBrush(QColor(255, 255, 255)));
      foreach(Segment * const segment, cluster) {
         scene.addItem(segment->toQGraphicsItem());
         // without the following line QPainter tends to crash
         scene.width();
      }
      ++counter;
      saveScene(&scene, QString("Test%1.png").arg(counter, 2));*/
   }

   // refine layout
   if (clusterBox->currentIndex() == 0) {
      refineLayoutByPlace(clusters);
   }
   else if (clusterBox->currentIndex() == 1) {
      refineLayoutBySize(clusters);
   }

   // convert the segments to QGraphicsItems and add to QGraphicsScene
   foreach(Segment const * const segment, segmentsWOBack) {
      arrangement->addItem(segment->toQGraphicsItem());
      // without the following line QPainter tends to crash
      arrangement->width();
   }
Exemplo n.º 12
0
size_t IsoffMainParser::parseSegmentList(Node * segListNode, SegmentInformation *info)
{
    size_t total = 0;
    if(segListNode)
    {
        std::vector<Node *> segments = DOMHelper::getElementByTagName(segListNode, "SegmentURL", false);
        SegmentList *list;
        if((list = new (std::nothrow) SegmentList(info)))
        {
            parseInitSegment(DOMHelper::getFirstChildElementByName(segListNode, "Initialization"), list, info);

            if(segListNode->hasAttribute("duration"))
                list->duration.Set(Integer<stime_t>(segListNode->getAttributeValue("duration")));

            if(segListNode->hasAttribute("timescale"))
                list->timescale.Set(Integer<uint64_t>(segListNode->getAttributeValue("timescale")));

            uint64_t nzStartTime = 0;
            std::vector<Node *>::const_iterator it;
            for(it = segments.begin(); it != segments.end(); ++it)
            {
                Node *segmentURL = *it;

                Segment *seg = new (std::nothrow) Segment(info);
                if(!seg)
                    continue;

                std::string mediaUrl = segmentURL->getAttributeValue("media");
                if(!mediaUrl.empty())
                    seg->setSourceUrl(mediaUrl);

                if(segmentURL->hasAttribute("mediaRange"))
                {
                    std::string range = segmentURL->getAttributeValue("mediaRange");
                    size_t pos = range.find("-");
                    seg->setByteRange(atoi(range.substr(0, pos).c_str()), atoi(range.substr(pos + 1, range.size()).c_str()));
                }

                if(list->duration.Get())
                {
                    seg->startTime.Set(nzStartTime);
                    seg->duration.Set(list->duration.Get());
                    nzStartTime += list->duration.Get();
                }

                seg->setSequenceNumber(total);

                list->addSegment(seg);
                total++;
            }

            info->setSegmentList(list);
        }
    }
    return total;
}
Exemplo n.º 13
0
SegmentList SegmentList::clone() const
      {
      SegmentList dl;
      Segment* s = _first;
      for (int i = 0; i < _size; ++i) {
            Segment* ns = s->clone();
            dl.push_back(ns);
            s = s->next();
            }
      dl.check();
      return dl;
      }
Exemplo n.º 14
0
void QSegmentWidget::addSegment(int cyl, qreal startAngle, qreal stopAngle, QColor color)
{
//  Segment s(startAngle, stopAngle, color);
    QSegmentWidget::Segment s;
    s.first = startAngle;
    s.second = stopAngle;
    s.color = color;

  SegmentList sl;
  sl.push_back(s);
  addSegments(cyl, sl);
}
Exemplo n.º 15
0
void drawInputSegments(){
    glClear(GL_COLOR_BUFFER_BIT);  
    glColor3f(0.0,0.0,0.0); 
    glPointSize(3.0);

    cout << segments.size() << endl;
    for (int i = 0; i < segments.size(); i++){
        glBegin(GL_LINES);
        glVertex2d(segments[i].p1[0], segments[i].p1[1]);
        glVertex2d(segments[i].p2[0], segments[i].p2[1]);
        glEnd();
        glFlush();
    }
}
Exemplo n.º 16
0
void getInputSegments(){
    segments.push_back(Line(20, 55, 60, 55)); 
    segments.push_back(Line(20, 5, 20, 55)); //TODO: real input
    segments.push_back(Line(60, 5, 20, 5)); 
    segments.push_back(Line(60, 55, 60, 5));
    //segments.push_back(Line(20, 5, 40, 63));
    
    planner = PathPlanner(segments);
    planner.populateTrajectory();
    StateTrajectory* traj = planner.getPathTrajectory();
    for (int i = 0; i < traj->size(); i++){
        cout << traj->at(i).toString() << endl;
    }
}
Exemplo n.º 17
0
SegmentList ShapeOutsideInfo::computeSegmentsForLine(LayoutUnit lineTop, LayoutUnit lineHeight) const
{
    ASSERT(lineHeight >= 0);
    SegmentList segments;

    computedShape().getExcludedIntervals((lineTop - logicalTopOffset()), std::min(lineHeight, shapeLogicalBottom() - lineTop), segments);

    for (size_t i = 0; i < segments.size(); i++) {
        segments[i].logicalLeft += logicalLeftOffset();
        segments[i].logicalRight += logicalLeftOffset();
    }

    return segments;
}
Exemplo n.º 18
0
size_t IsoffMainParser::parseSegmentBase(Node * segmentBaseNode, SegmentInformation *info)
{
    size_t list_count = 0;

    if(!segmentBaseNode)
        return 0;

    else if(segmentBaseNode->hasAttribute("indexRange"))
    {
        SegmentList *list = new SegmentList();
        Segment *seg;

        size_t start = 0, end = 0;
        if (std::sscanf(segmentBaseNode->getAttributeValue("indexRange").c_str(), "%zu-%zu", &start, &end) == 2)
        {
            IndexSegment *index = new DashIndexSegment(info);
            index->setByteRange(start, end);
            list->indexSegment.Set(index);
            /* index must be before data, so data starts at index end */
            seg = new Segment(info);
            seg->setByteRange(end + 1, 0);
        }
        else
        {
            seg = new Segment(info);
        }

        list_count++;
        list->addSegment(seg);
        info->setSegmentList(list);

        Node *initSeg = DOMHelper::getFirstChildElementByName(segmentBaseNode, "Initialization");
        if(initSeg)
        {
            SegmentBase *base = new SegmentBase();
            parseInitSegment(initSeg, base, info);
            info->setSegmentBase(base);
        }
    }
    else
    {
        SegmentBase *base = new SegmentBase();
        parseInitSegment(DOMHelper::getFirstChildElementByName(segmentBaseNode, "Initialization"), base, info);
        info->setSegmentBase(base);
    }

    return list_count;
}
Exemplo n.º 19
0
/// arc in radians
void TrackData::AddCurve (SegmentList& segments, float arc, float radius, float end_width_l, float end_width_r)
{
    arc = arc * PI/180.0f;
    float length = fabs(arc) * radius;
    int N = 1 + (int) floor(length/step);
    float s = length / (float) N;
    float d_width_l = (end_width_l - width_l) / (float) N;
    float d_width_r = (end_width_r - width_r) / (float) N;
    float d_angle = arc / (float) N;
    float start_angle = angle;
    float hpi = (float) (PI/2.0);
    for (int i=0; i<N; ++i) {
        mid.x += s*sin(angle);
        mid.y += s*cos(angle);
        Point left(mid.x + width_l*sin(angle - hpi),
                   mid.y + width_l*cos(angle - hpi),
                   mid.z);
        Point right(mid.x + width_r*sin(angle + hpi),
                    mid.y + width_r*cos(angle + hpi),
                    mid.z);
        segments.Add (Segment (left, right));
        angle += d_angle;
        width_l += d_width_l;
        width_r += d_width_r;
    }
    width_l = end_width_l;
    width_r = end_width_r;
    angle = start_angle + arc;
}
Exemplo n.º 20
0
void ExclusionRectangle::getExcludedIntervals(float logicalTop, float logicalBottom, SegmentList& result) const
{
    float y1 = minYForLogicalLine(logicalTop, logicalBottom);
    float y2 = maxYForLogicalLine(logicalTop, logicalBottom);

    if (y2 < m_y || y1 >= m_y + m_height)
        return;

    float x1 = m_x;
    float x2 = m_x + m_width;

    if (m_ry > 0) {
        if (y2 < m_y + m_ry) {
            float yi = y2 - m_y - m_ry;
            float xi = ellipseXIntercept(yi, m_rx, m_ry);
            x1 = m_x + m_rx - xi;
            x2 = m_x + m_width - m_rx + xi;
        } else if (y1 > m_y + m_height - m_ry) {
            float yi =  y1 - (m_y + m_height - m_ry);
            float xi = ellipseXIntercept(yi, m_rx, m_ry);
            x1 = m_x + m_rx - xi;
            x2 = m_x + m_width - m_rx + xi;
        }
    }

    result.append(LineSegment(x1, x2));
}
Exemplo n.º 21
0
void RectangleShape::getExcludedIntervals(LayoutUnit logicalTop, LayoutUnit logicalHeight, SegmentList& result) const
{
    const FloatRoundedRect& bounds = shapeMarginBounds();
    if (bounds.isEmpty())
        return;

    float y1 = logicalTop;
    float y2 = logicalTop + logicalHeight;

    if (y2 < bounds.y() || y1 >= bounds.maxY())
        return;

    float x1 = bounds.x();
    float x2 = bounds.maxX();

    if (bounds.ry() > 0) {
        if (y2 < bounds.y() + bounds.ry()) {
            float yi = y2 - bounds.y() - bounds.ry();
            float xi = ellipseXIntercept(yi, bounds.rx(), bounds.ry());
            x1 = bounds.x() + bounds.rx() - xi;
            x2 = bounds.maxX() - bounds.rx() + xi;
        } else if (y1 > bounds.maxY() - bounds.ry()) {
            float yi =  y1 - (bounds.maxY() - bounds.ry());
            float xi = ellipseXIntercept(yi, bounds.rx(), bounds.ry());
            x1 = bounds.x() + bounds.rx() - xi;
            x2 = bounds.maxX() - bounds.rx() + xi;
        }
    }

    result.append(LineSegment(x1, x2));
}
Exemplo n.º 22
0
void PolygonShape::getExcludedIntervals(LayoutUnit logicalTop, LayoutUnit logicalHeight, SegmentList& result) const
{
    const FloatPolygon& polygon = shapeMarginBounds();
    if (polygon.isEmpty())
        return;

    float y1 = logicalTop;
    float y2 = logicalTop + logicalHeight;

    FloatShapeIntervals y1XIntervals, y2XIntervals;
    computeXIntersections(polygon, y1, true, y1XIntervals);
    computeXIntersections(polygon, y2, false, y2XIntervals);

    FloatShapeIntervals mergedIntervals;
    FloatShapeInterval::uniteShapeIntervals(y1XIntervals, y2XIntervals, mergedIntervals);

    FloatShapeIntervals edgeIntervals;
    computeOverlappingEdgeXProjections(polygon, y1, y2, edgeIntervals);

    FloatShapeIntervals excludedIntervals;
    FloatShapeInterval::uniteShapeIntervals(mergedIntervals, edgeIntervals, excludedIntervals);

    for (unsigned i = 0; i < excludedIntervals.size(); ++i) {
        FloatShapeInterval interval = excludedIntervals[i];
        result.append(LineSegment(interval.x1(), interval.x2()));
    }
}
Exemplo n.º 23
0
void PolygonShape::getIncludedIntervals(LayoutUnit logicalTop, LayoutUnit logicalHeight, SegmentList& result) const
{
    const FloatPolygon& polygon = shapePaddingBounds();
    if (polygon.isEmpty())
        return;

    float y1 = logicalTop;
    float y2 = logicalTop + logicalHeight;

    FloatShapeIntervals y1XIntervals, y2XIntervals;
    computeXIntersections(polygon, y1, true, y1XIntervals);
    computeXIntersections(polygon, y2, false, y2XIntervals);

    FloatShapeIntervals commonIntervals;
    FloatShapeInterval::intersectShapeIntervals(y1XIntervals, y2XIntervals, commonIntervals);

    FloatShapeIntervals edgeIntervals;
    computeOverlappingEdgeXProjections(polygon, y1, y2, edgeIntervals);

    FloatShapeIntervals includedIntervals;
    FloatShapeInterval::subtractShapeIntervals(commonIntervals, edgeIntervals, includedIntervals);

    for (unsigned i = 0; i < includedIntervals.size(); ++i) {
        const FloatShapeInterval& interval = includedIntervals[i];
        result.append(LineSegment(interval.x1(), interval.x2()));
    }
}
Exemplo n.º 24
0
void PolygonShape::getExcludedIntervals(LayoutUnit logicalTop, LayoutUnit logicalHeight, SegmentList& result) const
{
    float y1 = logicalTop;
    float y2 = logicalTop + logicalHeight;

    if (m_polygon.isEmpty() || !m_polygon.boundingBox().overlapsYRange(y1 - shapeMargin(), y2 + shapeMargin()))
        return;

    Vector<const FloatPolygonEdge*> overlappingEdges;
    if (!m_polygon.overlappingEdges(y1 - shapeMargin(), y2 + shapeMargin(), overlappingEdges))
        return;

    FloatShapeInterval excludedInterval;
    for (unsigned i = 0; i < overlappingEdges.size(); i++) {
        const FloatPolygonEdge& edge = *(overlappingEdges[i]);
        if (!shapeMargin())
            excludedInterval.unite(OffsetPolygonEdge(edge, FloatSize()).clippedEdgeXRange(y1, y2));
        else {
            excludedInterval.unite(OffsetPolygonEdge(edge, outwardEdgeNormal(edge) * shapeMargin()).clippedEdgeXRange(y1, y2));
            excludedInterval.unite(OffsetPolygonEdge(edge, inwardEdgeNormal(edge) * shapeMargin()).clippedEdgeXRange(y1, y2));
            excludedInterval.unite(clippedCircleXRange(edge.vertex1(), shapeMargin(), y1, y2));
        }
    }

    if (!excludedInterval.isEmpty())
        result.append(LineSegment(excludedInterval.x1(), excludedInterval.x2()));
}
Exemplo n.º 25
0
void ExclusionPolygon::getIncludedIntervals(float logicalTop, float logicalHeight, SegmentList& result) const
{
    if (isEmpty())
        return;

    float y1 = minYForLogicalLine(logicalTop, logicalHeight);
    float y2 = maxYForLogicalLine(logicalTop, logicalHeight);

    Vector<ExclusionInterval> y1XIntervals, y2XIntervals;
    computeXIntersections(y1, true, y1XIntervals);
    computeXIntersections(y2, false, y2XIntervals);

    Vector<ExclusionInterval> commonIntervals;
    intersectExclusionIntervals(y1XIntervals, y2XIntervals, commonIntervals);

    Vector<ExclusionInterval> edgeIntervals;
    computeEdgeIntersections(y1, y2, edgeIntervals);

    Vector<ExclusionInterval> includedIntervals;
    subtractExclusionIntervals(commonIntervals, edgeIntervals, includedIntervals);

    for (unsigned i = 0; i < includedIntervals.size(); i++) {
        ExclusionInterval interval = includedIntervals[i];
        result.append(LineSegment(interval.x1, interval.x2));
    }
}
Exemplo n.º 26
0
void ExclusionPolygon::getExcludedIntervals(float logicalTop, float logicalHeight, SegmentList& result) const
{
    const FloatPolygon& polygon = shapeMarginBounds();
    if (polygon.isEmpty())
        return;

    float y1 = logicalTop;
    float y2 = y1 + logicalHeight;

    Vector<ExclusionInterval> y1XIntervals, y2XIntervals;
    computeXIntersections(polygon, y1, true, y1XIntervals);
    computeXIntersections(polygon, y2, false, y2XIntervals);

    Vector<ExclusionInterval> mergedIntervals;
    mergeExclusionIntervals(y1XIntervals, y2XIntervals, mergedIntervals);

    Vector<ExclusionInterval> edgeIntervals;
    computeOverlappingEdgeXProjections(polygon, y1, y2, edgeIntervals);

    Vector<ExclusionInterval> excludedIntervals;
    mergeExclusionIntervals(mergedIntervals, edgeIntervals, excludedIntervals);

    for (unsigned i = 0; i < excludedIntervals.size(); ++i) {
        ExclusionInterval interval = excludedIntervals[i];
        result.append(LineSegment(interval.x1, interval.x2));
    }
}
Exemplo n.º 27
0
void ExclusionPolygon::getIncludedIntervals(LayoutUnit logicalTop, LayoutUnit logicalHeight, SegmentList& result) const
{
    const FloatPolygon& polygon = shapePaddingBounds();
    if (polygon.isEmpty())
        return;

    float y1 = logicalTop;
    float y2 = logicalTop + logicalHeight;

    Vector<ExclusionInterval> y1XIntervals, y2XIntervals;
    computeXIntersections(polygon, y1, true, y1XIntervals);
    computeXIntersections(polygon, y2, false, y2XIntervals);

    Vector<ExclusionInterval> commonIntervals;
    intersectExclusionIntervals(y1XIntervals, y2XIntervals, commonIntervals);

    Vector<ExclusionInterval> edgeIntervals;
    computeOverlappingEdgeXProjections(polygon, y1, y2, edgeIntervals);

    Vector<ExclusionInterval> includedIntervals;
    subtractExclusionIntervals(commonIntervals, edgeIntervals, includedIntervals);

    for (unsigned i = 0; i < includedIntervals.size(); ++i) {
        ExclusionInterval interval = includedIntervals[i];
        result.append(LineSegment(interval.x1, interval.x2));
    }
}
Exemplo n.º 28
0
void Convex::FacetToSegmentsGorizon(FacetList *FL, SegmentList *SL)
{
    Facet       *pF;
    Segment     S;
    SegmentList SN;

    if ( FL->GetFirst(&pF) )
    {
        // з кожної грані створюємо три ребра
        do {
            S.Init(pF->A, pF->B);
            SN.Add(S);
            S.Init(pF->A, pF->C);
            SN.Add(S);
            S.Init(pF->C, pF->B);
            SN.Add(S);
        } while (FL->GetNext(&pF));
   
        // В список ребер горизонту включаємо лише зовнішні ребра видимої області
        while(!SN.IsEmpty())
        {
            SN.Remove(&S);
            if (SN.FindAndRemoveAll(S)==0)
            {
                SL->Add(S);

                #ifdef CONVEX_DEBUG
                    printf( "Add to horizon : ");
                    S.PrintPoints();
                #endif            
            };
        };
    
    };
}
bool SegmentInformation::getPlaybackTimeDurationBySegmentNumber(uint64_t number,
                                                                mtime_t *time, mtime_t *duration) const
{
    SegmentList *segList;
    MediaSegmentTemplate *mediaTemplate;

    if( (mediaTemplate = inheritSegmentTemplate()) )
    {
        const Timescale timescale = mediaTemplate->inheritTimescale();

        stime_t stime, sduration;
        if(mediaTemplate->segmentTimeline.Get())
        {
            mediaTemplate->segmentTimeline.Get()->
                getScaledPlaybackTimeDurationBySegmentNumber(number, &stime, &sduration);
        }
        else
        {
            stime = number * mediaTemplate->duration.Get();
            sduration = mediaTemplate->duration.Get();
        }
        *time = timescale.ToTime(stime);
        *duration = timescale.ToTime(sduration);
        return true;
    }
    else if ( (segList = inheritSegmentList()) )
    {
        return segList->getPlaybackTimeDurationBySegmentNumber(number, time, duration);
    }
    else
    {
        const Timescale timescale = inheritTimescale();
        const ISegment *segment = getSegment(SegmentInfoType::INFOTYPE_MEDIA, number);
        if( segment )
        {
            *time = timescale.ToTime(segment->startTime.Get());
            *duration = timescale.ToTime(segment->duration.Get());
            return true;
        }
    }

    return false;
}
Exemplo n.º 30
0
void BoxShape::getExcludedIntervals(LayoutUnit logicalTop, LayoutUnit logicalHeight, SegmentList& result) const
{
    const FloatRoundedRect& marginBounds = shapeMarginBounds();
    if (marginBounds.isEmpty() || !lineOverlapsShapeMarginBounds(logicalTop, logicalHeight))
        return;

    float y1 = logicalTop;
    float y2 = logicalTop + logicalHeight;
    const FloatRect& rect = marginBounds.rect();

    if (!marginBounds.isRounded()) {
        result.append(LineSegment(rect.x(), rect.maxX()));
        return;
    }

    float topCornerMaxY = std::max<float>(marginBounds.topLeftCorner().maxY(), marginBounds.topRightCorner().maxY());
    float bottomCornerMinY = std::min<float>(marginBounds.bottomLeftCorner().y(), marginBounds.bottomRightCorner().y());

    if (y1 <= topCornerMaxY && y2 >= bottomCornerMinY) {
        result.append(LineSegment(rect.x(), rect.maxX()));
        return;
    }

    float x1 = rect.maxX();
    float x2 = rect.x();
    float minXIntercept;
    float maxXIntercept;

    if (marginBounds.xInterceptsAtY(y1, minXIntercept, maxXIntercept)) {
        x1 = std::min<float>(x1, minXIntercept);
        x2 = std::max<float>(x2, maxXIntercept);
    }

    if (marginBounds.xInterceptsAtY(y2, minXIntercept, maxXIntercept)) {
        x1 = std::min<float>(x1, minXIntercept);
        x2 = std::max<float>(x2, maxXIntercept);
    }

    ASSERT(x2 >= x1);
    result.append(LineSegment(x1, x2));
}