⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 booleng.h

📁 EDA PCB 电路设计工具源码 c/c++ for Linux, Windows, Mac, 2008.8 最新
💻 H
📖 第 1 页 / 共 2 页
字号:
/*! \file kbool/include/kbool/booleng.h    \author Probably Klaas Holwerda    Copyright: 2001-2004 (C) Probably Klaas Holwerda    Licence: wxWidgets Licence    RCS-ID: $Id: booleng.h,v 1.3 2005/06/11 19:25:12 frm Exp $*/#ifndef BOOLENG_H#define BOOLENG_H#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)#pragma interface#endif#include <stdio.h>#include <limits.h>#ifdef A2DKBOOLMAKINGDLL#define A2DKBOOLDLLEXP WXEXPORT#define A2DKBOOLDLLEXP_DATA(type) WXEXPORT type#define A2DKBOOLDLLEXP_CTORFN#if 0   // Kicad does dot use wxWidgets lib when building the kbool library        // but uses wxWidgets. So WXUSINGDLL has no meaning here, but could be defined in makefiles        // but must not be used when building kbool#elif defined(WXUSINGDLL)#define A2DKBOOLDLLEXP WXIMPORT#define A2DKBOOLDLLEXP_DATA(type) WXIMPORT type#define A2DKBOOLDLLEXP_CTORFN#endif#else // not making nor using DLL#define A2DKBOOLDLLEXP#define A2DKBOOLDLLEXP_DATA(type) type#define A2DKBOOLDLLEXP_CTORFN#endif#define KBOOL_VERSION "1.8"#define KBOOL_DEBUG 0#define KBOOL_LOG 0#define KBOOL_INT64 1class KBoolLink;#define LINELENGTH 200#ifdef  MAXDOUBLE#undef  MAXDOUBLE#endif#define MAXDOUBLE 1.7976931348623158e+308#ifdef KBOOL_INT64#if defined(__UNIX__) || defined(__GNUG__)typedef long long B_INT;		   // 8 bytes integer//#define MAXB_INT LONG_LONG_MAX//#define MINB_INT LONG_LONG_MIN	// 8 bytes integer#ifndef MAXB_INT const B_INT MAXB_INT = (0x7fffffffffffffffLL);             // 8 bytes integer#endif#ifndef MINB_INT const B_INT MINB_INT = (0x8000000000000000LL);#endif#else //defined(__UNIX__) || defined(__GNUG__)typedef __int64 B_INT;		   // 8 bytes integer#undef MAXB_INT #undef MINB_INT const B_INT MAXB_INT = (0x7fffffffffffffff);             // 8 bytes integerconst B_INT MINB_INT = (0x8000000000000000);#endif //defined(__UNIX__) || defined(__GNUG__)#else //KBOOL_INT64 #if defined(__UNIX__) || defined(__GNUG__)typedef long B_INT;		   // 4 bytes integerconst B_INT MAXB_INT = (0x7fffffffL);             // 4 bytes integerconst B_INT MINB_INT = (0x80000000L);#elsetypedef long B_INT;		   // 4 bytes integerconst B_INT MAXB_INT = (0x7fffffff);             // 4 bytes integerconst B_INT MINB_INT = (0x80000000);#endif#endif //KBOOL_INT64 B_INT babs(B_INT);#ifdef  M_PI#undef  M_PI#endif#define M_PI		(3.1415926535897932384626433832795028841972)#ifdef  M_PI_2#undef  M_PI_2#endif#define M_PI_2      1.57079632679489661923#ifdef  M_PI_4#undef  M_PI_4#endif#define M_PI_4      0.785398163397448309616#ifndef NULL#define NULL 0#endifB_INT bmin(B_INT const value1, B_INT const value2);B_INT bmax(B_INT const value1, B_INT const value2);B_INT bmin(B_INT value1, B_INT value2);B_INT bmax(B_INT value1, B_INT value2);#include <string.h>//! errors in the boolean algorithm will be thrown using this classclass A2DKBOOLDLLEXP Bool_Engine_Error{	public:		Bool_Engine_Error(const char* message, const char* header=0, int degree = 9, int fatal = 0);		Bool_Engine_Error(const Bool_Engine_Error& a);		~Bool_Engine_Error();		char*	GetErrorMessage();		char* GetHeaderMessage();		int	GetErrorDegree();		int	GetFatal();	protected:		char*	_message;		char*	_header;		int 	_degree;		int 	_fatal;};#define KBOOL_LOGFILE "kbool.log"enum kbEdgeType {    KB_OUTSIDE_EDGE, /*!< edge of the outside contour of a polygon */   KB_INSIDE_EDGE,  /*!< edge of the inside hole a polygon */   KB_FALSE_EDGE    /*!< edge to connect holes into polygons */} ;enum GroupType {    GROUP_A, /*!< to set Group A for polygons */   GROUP_B  /*!< to set Group A for polygons */};enum BOOL_OP {    BOOL_NON, /*!< No operation */   BOOL_OR, /*!< boolean OR operation */   BOOL_AND, /*!< boolean AND operation */   BOOL_EXOR, /*!< boolean EX_OR operation */   BOOL_A_SUB_B, /*!< boolean Group A - Group B operation */   BOOL_B_SUB_A, /*!< boolean Group B - Group A operation */   BOOL_CORRECTION, /*!< polygon correction/offset operation */   BOOL_SMOOTHEN, /*!< smooth operation */   BOOL_MAKERING /*!< create a ring on all polygons */};class GraphList;class Graph;class KBoolLink;class Node;template<class Type> class TDLI;//! boolean engine to perform operation on two sets of polygons./*	First the engine needs to be filled with polygons.	The first operand in the operation is called group A polygons, the second group B.	The boolean operation ( BOOL_OR, BOOL_AND, BOOL_EXOR, BOOL_A_SUB_B, BOOL_B_SUB_A )	are based on the two sets of polygons in group A and B.	The other operation on group A only.    At the end of the operation the resulting polygons can be extracted.*/class A2DKBOOLDLLEXP Bool_Engine {  public:   //! constructor       Bool_Engine();   //! destructor      virtual ~Bool_Engine();   const char* GetVersion() { return KBOOL_VERSION; }	//! reports progress of algorithm.   virtual void SetState( const char* = 0 );	//! called at an internal error.	virtual void error(const char *text, const char *title);	//! called at an internal generated possible error.   virtual void info(const char *text, const char *title);   bool Do_Operation(BOOL_OP operation);   //! distance within which points and lines will be snapped towards lines and other points   /*         The algorithm takes into account gaps and inaccuracies caused by rounding to integer coordinates         in the original data.         Imagine two rectangles one with a side ( 0,0 ) ( 2.0, 17.0 )          and the other has a side ( 0,0 ) ( 1.0, 8.5 )         If for some reason those coordinates where round to ( 0,0 ) ( 2, 17 ) ( 0,0 ) ( 1, 9 ),         there will be clearly a gap or overlap that was not intended.         Even without rounding this effect takes place since there is always a minimum significant bit         also when using doubles.         If the user used as minimum accuracy 0.001, you need to choose Marge > 0.001         The boolean engine scales up the input data with GetDGrid() * GetGrid() and rounds the result to         integer, So (assuming GRID = 100 DGRID = 1000)  a vertex of 123.001 in the user data will         become 12300100 internal.         At the end of the algorithm the internal vertexes are scaled down again with GetDGrid() * GetGrid(),         so 12300103 becomes 123.00103 eventually.         So indeed the minimum accuracy might increase, you are free to round again if needed.   */   void SetMarge(double marge);   double GetMarge();   //! input points are scaled up with GetDGrid() * GetGrid()   /*		Grid makes sure that the integer data used within the algorithm has room for extra intersections		smaller than the smallest number within the input data.		The input data scaled up with DGrid is related to the accuracy the user has in his input data.        Another scaling with Grid is applied on top of it to create space in the integer number for 		even smaller numbers.    */   void SetGrid(B_INT grid);  		//! See SetGrid   B_INT GetGrid();   //! input points are scaled up with GetDGrid() * GetGrid()   /*      The input data scaled up with DGrid is related to the accuracy the user has in his input data.      User data with a minimum accuracy of 0.001, means set the DGrid to 1000.      The input data may contain data with a minimum accuracy much smaller, but by setting the DGrid      everything smaller than 1/DGrid is rounded.      DGRID is only meant to make fractional parts of input data which can be      doubles, part of the integers used in vertexes within the boolean algorithm.      And therefore DGRID bigger than 1 is not usefull, you would only loose accuracy.      Within the algorithm all input data is multiplied with DGRID, and the result      is rounded to an integer.    */   void SetDGrid(double dgrid);	//! See SetDGrid   double GetDGrid();   //! When doing a correction operation ( also known as process offset )	//! this defines the detail in the rounded corners.	/*		Depending on the round factor the corners of the polygon may be rounding within the correction		algorithm. The detail within this rounded corner is set here.		It defines the deviation the generated segments in arc like polygon may have towards the ideal		rounded corner using a perfect arc.    */   void SetCorrectionAber(double aber);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -