| |
| |
|
|
| |
| |
| #if !defined(TREGION_H) |
| #define TREGION_H |
| |
| #if _MSC_VER > 1000 |
| #pragma once |
| #endif |
| |
| #include "tgeometry.h" |
| |
| |
| #undef DVAPI |
| #undef DVVAR |
| #ifdef TVECTORIMAGE_EXPORTS |
| #define DVAPI DV_EXPORT_API |
| #define DVVAR DV_EXPORT_VAR |
| #else |
| #define DVAPI DV_IMPORT_API |
| #define DVVAR DV_IMPORT_VAR |
| #endif |
| |
| |
| |
| |
| class TStroke; |
| |
| class TRegion; |
| class TRegionProp; |
| |
| |
| |
| |
| class TRegionId |
| { |
| public: |
| int m_strokeId; |
| float m_midW; |
| bool m_direction; |
| |
| TRegionId(int strokeId, float midW, bool direction) |
| : m_strokeId(strokeId), m_midW(midW), m_direction(direction) |
| { |
| } |
| }; |
| |
| class TFilledRegionInf |
| { |
| public: |
| TRegionId m_regionId; |
| int m_styleId; |
| |
| TFilledRegionInf(int strokeId, float midW, bool direction, int styleId) |
| : m_regionId(strokeId, midW, direction), m_styleId(styleId) |
| { |
| } |
| |
| TFilledRegionInf(TRegionId regionId, int styleId) |
| : m_regionId(regionId), m_styleId(styleId) |
| { |
| } |
| }; |
| |
| |
| |
| class TGeneralEdge |
| { |
| public: |
| enum Type { |
| eNormal, |
| eAutoclose |
| }; |
| |
| Type m_type; |
| |
| TGeneralEdge(Type type) : m_type(type) {} |
| }; |
| |
| class TEdge : public TGeneralEdge |
| { |
| |
| public: |
| TStroke *m_s; |
| double m_w0, m_w1; |
| int m_index; |
| TRegion *m_r; |
| int m_styleId; |
| bool m_toBeDeleted; |
| |
| public: |
| TEdge() |
| : TGeneralEdge(eNormal), m_s(0), m_w0(-1), m_w1(-1), m_index(-1), m_r(0), m_styleId(0), m_toBeDeleted(false) |
| |
| { |
| } |
| |
| TEdge(TStroke *ref, UINT index, double w0, double w1, bool toBeDeletedWithStroke, int styleId) |
| : TGeneralEdge(eNormal), m_s(ref), m_w0(w0), m_w1(w1), m_index(index), m_r(0), m_styleId(styleId), m_toBeDeleted(toBeDeletedWithStroke) |
| |
| { |
| } |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| TEdge(const TEdge &e, bool toBeDeletedWithStroke) |
| : TGeneralEdge(eNormal), m_s(e.m_s), m_w0(e.m_w0), m_w1(e.m_w1), m_index(e.m_index), m_r(e.m_r), m_styleId(e.m_styleId), m_toBeDeleted(toBeDeletedWithStroke) |
| |
| { |
| } |
| |
| TEdge &operator=(const TEdge &e) |
| { |
| m_s = e.m_s; |
| m_w0 = e.m_w0; |
| m_w1 = e.m_w1; |
| m_index = e.m_index; |
| m_r = e.m_r; |
| m_styleId = e.m_styleId; |
| m_toBeDeleted = e.m_toBeDeleted; |
| |
| return *this; |
| } |
| TEdge(const TEdge &e) : TGeneralEdge(eNormal), m_s(e.m_s), m_w0(e.m_w0), m_w1(e.m_w1), m_index(e.m_index), m_r(e.m_r), m_styleId(e.m_styleId), m_toBeDeleted(e.m_toBeDeleted) {} |
| |
| bool operator<(const TEdge &e) const |
| { |
| return (e.m_s == m_s) ? ((e.m_w0 == m_w0) ? e.m_w1 < m_w1 : e.m_w0 < m_w0) : e.m_s < m_s; |
| } |
| |
| inline int getStyle() const { return m_styleId; } |
| inline void setStyle(int styleId) { m_styleId = styleId; } |
| |
| inline bool operator==(const TEdge &b) const |
| { |
| return m_s == b.m_s && ((m_w0 == b.m_w0 && m_w1 == b.m_w1) || (m_w0 == b.m_w1 && m_w1 == b.m_w0)); |
| } |
| |
| private: |
| TEdge(TStroke *ref); |
| }; |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| class DVAPI TRegion |
| { |
| class Imp; |
| Imp *m_imp; |
| |
| public: |
| TRegion(); |
| ~TRegion(); |
| |
| TRectD getBBox() const; |
| |
| bool contains(const TPointD &p) const; |
| bool contains(const TRegion &r) const; |
| bool contains(const TStroke &s, bool mayIntersect = false) const; |
| bool contains(const TEdge &e) const; |
| |
| |
| TRegion *findRegion(const TRegion &r) const; |
| TRegion *getSubregion(UINT index) const; |
| UINT getSubregionCount() const; |
| void deleteSubregion(UINT index); |
| void addSubregion(TRegion *region); |
| TEdge *getEdge(UINT index) const; |
| TEdge *getLastEdge() const; |
| UINT getEdgeCount() const; |
| void addEdge(TEdge *e, bool minimizeEdges); |
| TEdge *popFrontEdge(); |
| TEdge *popBackEdge(); |
| |
| void moveSubregionsTo(TRegion *r); |
| |
| int fill(const TPointD &p, int styleId); |
| |
| bool selectFill(const TRectD &selectArea, int styleId); |
| |
| |
| TRegion *getRegion(const TPointD &p); |
| |
| int getStyle() const; |
| |
| void setStyle(int styleId); |
| |
| void autoFill(int styleId, bool oddLevel); |
| |
| bool isSubRegionOf(const TRegion &r) const; |
| bool getInternalPoint(TPointD &p); |
| |
| TRegionProp *getProp(); |
| void setProp(TRegionProp *prop); |
| |
| TRegionId getId(); |
| |
| void invalidateProp(); |
| |
| void invalidateBBox(); |
| |
| void print(); |
| |
| |
| void computeScanlineIntersections(double y, vector<double> &intersections) const; |
| |
| int scanlineIntersectionsBefore(double x, double y, bool horiz) const; |
| int leftScanlineIntersections(double x, double y) const |
| { |
| return scanlineIntersectionsBefore(x, y, true); |
| } |
| |
| #ifdef _DEBUG |
| void checkRegion(); |
| #endif |
| }; |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| class DVAPI TRegionFeatureFormula |
| { |
| public: |
| virtual void update(const TPointD &p1, const TPointD &p2) = 0; |
| }; |
| |
| |
| |
| |
| |
| |
| void DVAPI computeRegionFeature(const TRegion &r, TRegionFeatureFormula &formula); |
| |
| #endif |
| |
| |
| |
| |