contour-combiners.h 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. #pragma once
  2. #include "Shape.h"
  3. #include "edge-selectors.h"
  4. namespace msdfgen {
  5. /// Simply selects the nearest contour.
  6. template <class EdgeSelector>
  7. class SimpleContourCombiner {
  8. public:
  9. typedef EdgeSelector EdgeSelectorType;
  10. typedef typename EdgeSelector::DistanceType DistanceType;
  11. explicit SimpleContourCombiner(const Shape &shape);
  12. void reset(const Point2 &p);
  13. EdgeSelector & edgeSelector(int i);
  14. DistanceType distance() const;
  15. private:
  16. EdgeSelector shapeEdgeSelector;
  17. };
  18. /// Selects the nearest contour that actually forms a border between filled and unfilled area.
  19. template <class EdgeSelector>
  20. class OverlappingContourCombiner {
  21. public:
  22. typedef EdgeSelector EdgeSelectorType;
  23. typedef typename EdgeSelector::DistanceType DistanceType;
  24. explicit OverlappingContourCombiner(const Shape &shape);
  25. void reset(const Point2 &p);
  26. EdgeSelector & edgeSelector(int i);
  27. DistanceType distance() const;
  28. private:
  29. Point2 p;
  30. std::vector<int> windings;
  31. std::vector<EdgeSelector> edgeSelectors;
  32. };
  33. }