📄 booleng.h
字号:
//! see SetCorrectionAber double GetCorrectionAber(); //! When doing a correction operation ( also known as process offset ) //! this defines the amount of correction. /* The correction algorithm can apply positive and negative offset to polygons. It takes into account closed in areas within a polygon, caused by overlapping/selfintersecting polygons. So holes form that way are corrected proberly, but the overlapping parts itself are left alone. An often used trick to present polygons with holes by linking to the outside boundary, is therefore also handled properly. The algoritm first does a boolean OR operation on the polygon, and seperates holes and outside contours. After this it creates a ring shapes on the above holes and outside contours. This ring shape is added or subtracted from the holes and outside contours. The result is the corrected polygon. If the correction factor is > 0, the outside contours will become larger, while the hole contours will become smaller. */ void SetCorrectionFactor(double aber); //! see SetCorrectionFactor double GetCorrectionFactor(); //! used within the smooth algorithm to define how much the smoothed curve may deviate //! from the original. void SetSmoothAber(double aber); //! see SetSmoothAber double GetSmoothAber(); //! segments of this size will be left alone in the smooth algorithm. void SetMaxlinemerge(double maxline); //! see SetMaxlinemerge double GetMaxlinemerge(); //! Polygon may be filled in different ways (alternate and winding rule). //! This here defines which method will be assumed within the algorithm. void SetWindingRule(bool rule); //! see SetWindingRule bool GetWindingRule(); //! the smallest accuracy used within the algorithm for comparing two real numbers. double GetAccur(); //! Used with in correction/offset algorithm. /* When the polygon contains sharp angles ( < 90 ), after a positive correction the extended parrallel constructed offset lines may leed to extreme offsets on the angles. The length of the crossing generated by the parrallel constructed offset lines towards the original point in the polygon is compared to the offset which needs to be applied. The Roundfactor then decides if this corner will be rounded. A Roundfactor of 1 means that the resulting offset will not be bigger then the correction factor set in the algorithm. Meaning even straight 90 degrees corners will be rounded. A Roundfactor of > sqrt(2) is where 90 corners will be left alone, and smaller corners will be rounded. */ void SetRoundfactor(double roundfac); //! see SetRoundfactor double GetRoundfactor();// the following are only be used within the algorithm,// since they are scaled with m_DGRID //! only used internal. void SetInternalMarge( B_INT marge ); //! only used internal. B_INT GetInternalMarge(); //! only used internal. double GetInternalCorrectionAber(); //! only used internal. double GetInternalCorrectionFactor(); //! only used internal. double GetInternalSmoothAber(); //! only used internal. B_INT GetInternalMaxlinemerge(); //! in this mode polygons add clockwise, or contours, /*! and polygons added counter clockwise or holes. */ void SetOrientationEntryMode( bool orientationEntryMode ) { m_orientationEntryMode = orientationEntryMode; } //! see SetOrientationEntryMode() bool GetOrientationEntryMode() { return m_orientationEntryMode; } //! if set true holes are linked into outer contours by double overlapping segments. /*! This mode is needed when the software using the boolean algorithm does not understand hole polygons. In that case a contour and its holes form one polygon. In cases where software understands the concept of holes, contours are clockwise oriented, while holes are anticlockwise oriented. The output of the boolean operations, is following those rules also. But even if extracting the polygons from the engine, each segment is marked such that holes and non holes and linksegments to holes can be recognized. */ void SetLinkHoles( bool doLinkHoles ) { m_doLinkHoles = doLinkHoles; } //! see SetLinkHoles() bool GetLinkHoles() { return m_doLinkHoles; } //!lof file will be created when set True void SetLog( bool OnOff ); //! used to write to log file void Write_Log(const char *); //! used to write to log file void Write_Log(const char *, const char *); //! used to write to log file void Write_Log(const char *, double); //! used to write to log file void Write_Log(const char *, B_INT); FILE* GetLogFile() { return m_logfile; } // methods used to add polygons to the eng using points //! Start adding a polygon to the engine /* The boolean operation work on two groups of polygons ( group A or B ), other algorithms are only using group A. You add polygons like this to the engine. // foreach point in a polygon ... if (booleng->StartPolygonAdd(GROUP_A)) { booleng->AddPoint(100,100); booleng->AddPoint(-100,100); booleng->AddPoint(-100,-100); booleng->AddPoint(100,-100); } booleng->EndPolygonAdd(); \param A_or_B defines if the new polygon will be of group A or B Holes or added by adding an inside polygons with opposite orientation compared to another polygon added. So the contour polygon ClockWise, then add counterclockwise polygons for holes, and visa versa. BUT only if m_orientationEntryMode is set true, else all polygons are redirected, and become individual areas without holes. Holes in such a case must be linked into the contour using two extra segments. */ bool StartPolygonAdd( GroupType A_or_B ); //! see StartPolygonAdd bool AddPoint(double x, double y); //! see StartPolygonAdd bool EndPolygonAdd(); // methods used to extract polygons from the eng by getting its points //! Use after StartPolygonGet() int GetNumPointsInPolygon() { return m_numPtsInPolygon ; } //! get resulting polygons at end of an operation /*! // foreach resultant polygon in the booleng ... while ( booleng->StartPolygonGet() ) { // foreach point in the polygon while ( booleng->PolygonHasMorePoints() ) { fprintf(stdout,"x = %f\t", booleng->GetPolygonXPoint()); fprintf(stdout,"y = %f\n", booleng->GetPolygonYPoint()); } booleng->EndPolygonGet(); } */ bool StartPolygonGet(); //! see StartPolygonGet /*! This iterates through the first graph in the graphlist. Setting the current Node properly by following the links in the graph through its nodes. */ bool PolygonHasMorePoints(); //! see StartPolygonGet double GetPolygonXPoint(); //! see StartPolygonGet double GetPolygonYPoint(); //! in the resulting polygons this tells if the current polygon segment is one //! used to link holes into the outer contour of the surrounding polygon bool GetHoleConnectionSegment(); //! in the resulting polygons this tells if the current polygon segment is part //! of a hole within a polygon. bool GetHoleSegment(); //! an other way to get the type of segment. kbEdgeType GetPolygonPointEdgeType(); //! see StartPolygonGet() /*! Removes a graph from the graphlist. Called after an extraction of an output polygon was done. */ void EndPolygonGet(); private: bool m_doLog; //! contains polygons in graph form GraphList* m_graphlist; double m_MARGE; B_INT m_GRID; double m_DGRID; double m_CORRECTIONABER; double m_CORRECTIONFACTOR; double m_SMOOTHABER; double m_MAXLINEMERGE; bool m_WINDINGRULE; double m_ACCUR; double m_ROUNDFACTOR; bool m_orientationEntryMode; bool m_doLinkHoles; //! used in the StartPolygonAdd, AddPt, EndPolygonAdd sequence Graph* m_GraphToAdd; //! used in the StartPolygonAdd, AddPt, EndPolygonAdd sequence Node* m_lastNodeToAdd; //! used in the StartPolygonAdd, AddPt, EndPolygonAdd sequence Node* m_firstNodeToAdd; //! the current group type ( group A or B ) GroupType m_groupType; //! used in extracting the points from the resultant polygons Graph* m_getGraph; //! used in extracting the points from the resultant polygons KBoolLink* m_getLink; //! used in extracting the points from the resultant polygons Node* m_getNode; //! used in extracting the points from the resultant polygons double m_PolygonXPoint; //! used in extracting the points from the resultant polygons double m_PolygonYPoint; //! used in extracting the points from the resultant polygons int m_numPtsInPolygon; //! used in extracting the points from the resultant polygons int m_numNodesVisited; FILE* m_logfile;public: //! use in Node to iterate links. TDLI<KBoolLink>* _linkiter; //! how many time run intersections fase. unsigned int m_intersectionruns;};#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -