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

📄 link.cpp

📁 EDA PCB 电路设计工具源码 c/c++ for Linux, Windows, Mac, 2008.8 最新
💻 CPP
📖 第 1 页 / 共 2 页
字号:
		assert(!two);	if (GetBeginNode()->Equal(GetEndNode(), 1))		assert(!this);	KBoolLine* temp_line = new KBoolLine(this, _GC);	//the this link should connect to the other two link at at least one node	if (m_endnode == two->m_endnode || m_endnode == two->m_beginnode)		center = m_endnode;	else	{	center = m_beginnode;//		assert(center==two->endnode || center==two->beginnode);	}	//here something tricky	// the factor 10000.0 is needed to asure that the pointonline	// is more accurate in this case compared to the intersection for graphs	int uitp = temp_line->PointOnLine(two->GetOther(center), distance, accur);	delete temp_line;	/*double uitp=	(_x - first._x) * (third._y - _y) -					(_y - first._y) * (third._x - _x);	if (uitp>0) return IS_LEFT;	if (uitp<0) return IS_RIGHT;	return IS_ON;*/	//depending on direction of this link (going to or coming from centre)	if (center == m_endnode)	{	  if (uitp==LEFT_SIDE)			return IS_LEFT;	  if (uitp==RIGHT_SIDE)			return IS_RIGHT;	}	else  //center=beginnode	{	  if (uitp==LEFT_SIDE)			return IS_RIGHT;	  if (uitp==RIGHT_SIDE)			return IS_LEFT;	}	return IS_ON;}////	Return the position of the third link compared to this link and// the second link// Result = IS_ON | IS_LEFT | IS_RIGHT//LinkStatus KBoolLink::PointOnCorner(KBoolLink* const two, KBoolLink* const third){	LinkStatus	TwoToOne,		// Position of two to this line	ThirdToOne,    // Position of third to this line	ThirdToTwo,		// Position of third to two	Result;//m		Node*	center;//the this link should connect to the other two link at at least one node//m		if (endnode==two->endnode || endnode==two->beginnode)//m			center=endnode;//m		else//m		{	center=beginnode;//		assert(center==two->endnode || center==two->beginnode);//m	}//	assert(center==third->endnode || center==third->beginnode);	// Calculate the position of the links compared to eachother	TwoToOne	 = OutProduct(two,_GC->GetAccur());	ThirdToOne= OutProduct(third,_GC->GetAccur());	//center is used in outproduct to give de direction of two	// this is why the result should be swapped	ThirdToTwo=	two->OutProduct(third,_GC->GetAccur());	if (ThirdToTwo==IS_RIGHT)	  ThirdToTwo=IS_LEFT;	else if (ThirdToTwo==IS_LEFT)	  ThirdToTwo=IS_RIGHT;	// Select the result	switch(TwoToOne)	{		// Line 2 lies on  leftside of this line		case IS_LEFT : if ((ThirdToOne==IS_RIGHT) || (ThirdToTwo==IS_RIGHT))	return IS_RIGHT;							else if ((ThirdToOne==IS_LEFT) && (ThirdToTwo==IS_LEFT))	return IS_LEFT;							else	Result=IS_ON;	break;		// Line 2 lies on this line		case IS_ON	 :	if ((ThirdToOne==IS_RIGHT) && (ThirdToTwo==IS_RIGHT))		  return IS_RIGHT;							else if ((ThirdToOne==IS_LEFT) && (ThirdToTwo==IS_LEFT))   return IS_LEFT;					  //		else if ((ThirdToOne==IS_RIGHT) && (ThirdToTwo==IS_LEFT))   return IS_RIGHT;					  //		else if ((ThirdToOne==IS_LEFT) && (ThirdToTwo==IS_RIGHT))   return IS_LEFT;							else	Result=IS_ON;	break;		// Line 2 lies on right side of this line		case IS_RIGHT :if ((ThirdToOne==IS_RIGHT) && (ThirdToTwo==IS_RIGHT))	return IS_RIGHT;							else if ((ThirdToOne==IS_LEFT) || (ThirdToTwo==IS_LEFT)) return IS_LEFT;							else	Result=IS_ON;	break;    default: Result = IS_ON; assert( false );	}	return Result;}//// Remove the reference from this link to a_node//void KBoolLink::Remove(Node *a_node){	(m_beginnode == a_node) ? m_beginnode = NULL : m_endnode = NULL;}////	Replace oldnode by newnode and correct the references//void KBoolLink::Replace(Node *oldnode, Node *newnode){	   if (m_beginnode == oldnode)	{	m_beginnode->RemoveLink(this);	// remove the reference to this		newnode->AddLink(this);       // let newnode refer to this		m_beginnode = newnode;				// let this refer to newnode	}	else	{	//assert(endnode==oldnode);		m_endnode->RemoveLink(this);		newnode->AddLink(this);		m_endnode = newnode;	}}////	Reset all values//void KBoolLink::Reset(){	m_beginnode = 0;	m_endnode = 0;	Reset_flags();}////	Reset all flags//void KBoolLink::Reset_flags(){	m_bin	= false; 			// Marker for walking over the graph	m_hole  = false;			// Is this a part of hole ?	m_hole_top = false;	   // link that is toplink of hole?	m_group = GROUP_A;		// Does this belong to group A or B ( o.a. for boolean operations between graphs)	m_LeftA = false;     	// Is left in polygongroup A	m_RightA= false;     	// Is right in polygon group A	m_LeftB = false;     	// Is left in polygon group B	m_RightB= false;     	// Is right in polygongroup B	m_mark	= false;     	// General purose marker, internally unused   m_holelink=false;	m_merge_L = m_merge_R = false;			// Marker for Merge	m_a_substract_b_L = m_a_substract_b_R = false;	// Marker for substract	m_b_substract_a_L = m_b_substract_a_R = false;	// Marker for substract	m_intersect_L = m_intersect_R = false;		// Marker for intersect	m_exor_L	= m_exor_R= false;          // Marker for Exor}////	Refill this link by the arguments//void KBoolLink::Reset(Node *begin, Node *end,int graphnr){	// Remove all the previous references	UnLink();	Reset();	// Set the references of the node and of this link correct	begin->AddLink(this);	end->AddLink(this);	m_beginnode = begin;	m_endnode = end;	if (graphnr!=0)		 m_graphnum = graphnr;}void KBoolLink::Set(Node *begin, Node *end){	m_beginnode = begin;	m_endnode = end;}void KBoolLink::SetBeenHere(){	m_bin = true;}void KBoolLink::SetNotBeenHere(){	m_bin = false;}void KBoolLink::SetBeginNode(Node* new_node){	m_beginnode = new_node;}void KBoolLink::SetEndNode(Node* new_node){	m_endnode = new_node;}////	Sets the graphnumber to argument num//void KBoolLink::SetGraphNum( int num ){	m_graphnum=num;}GroupType KBoolLink::Group(){	return m_group;}//// Reset the groupflag to argument groep//void KBoolLink::SetGroup(GroupType groep){	m_group= groep;}////	Remove all references to this link and from this link//void KBoolLink::UnLink(){	if (m_beginnode)	{	m_beginnode->RemoveLink(this);		if (!m_beginnode->GetNumberOfLinks())	delete m_beginnode;	}	m_beginnode=NULL;	if (m_endnode)	{	m_endnode->RemoveLink(this);		if (!m_endnode->GetNumberOfLinks())	delete m_endnode;	}	m_endnode=NULL;}void KBoolLink::UnMark(){	m_mark = false;	m_bin = false;}void KBoolLink::SetMark(bool value){	m_mark = value;}////	general purpose mark checker//bool KBoolLink::IsMarked() { return m_mark; }void  KBoolLink::SetTopHole(bool value) {	m_hole_top = value; }bool KBoolLink::IsTopHole() {	return m_hole_top; }//// Calculates the merge/substact/exor/intersect flags//void	KBoolLink::SetLineTypes(){	m_merge_R     = 	m_a_substract_b_R = 	m_b_substract_a_R = 	m_intersect_R = 	m_exor_R      = 	m_merge_L     = 	m_a_substract_b_L = 	m_b_substract_a_L = 	m_intersect_L = 	m_exor_L      = false;   //if left side is in group A and B then it is for the merge	m_merge_L   = m_LeftA || m_LeftB;  												m_merge_R   = m_RightA || m_RightB;   //both in mean does not add to result.   if (m_merge_L && m_merge_R)      m_merge_L = m_merge_R = false;      m_a_substract_b_L = m_LeftA && !m_LeftB;     m_a_substract_b_R = m_RightA && !m_RightB;   //both in mean does not add to result.   if (m_a_substract_b_L && m_a_substract_b_R)      m_a_substract_b_L = m_a_substract_b_R = false;   m_b_substract_a_L = m_LeftB && !m_LeftA;     m_b_substract_a_R = m_RightB && !m_RightA;   //both in mean does not add to result.   if (m_b_substract_a_L && m_b_substract_a_R)      m_b_substract_a_L = m_b_substract_a_R = false;	m_intersect_L = m_LeftB && m_LeftA;	m_intersect_R = m_RightB && m_RightA;   //both in mean does not add to result.   if (m_intersect_L && m_intersect_R)      m_intersect_L = m_intersect_R = false;	m_exor_L = !( (m_LeftB && m_LeftA) || (!m_LeftB && !m_LeftA) );	m_exor_R = !( (m_RightB && m_RightA) || (!m_RightB && !m_RightA) );   //both in mean does not add to result.   if (m_exor_L && m_exor_R)      m_exor_L = m_exor_R = false;}//put in direction with a_node as beginnodevoid  KBoolLink::Redirect(Node* a_node){   if (a_node != m_beginnode)   {		// swap the begin- and endnode of the current link		Node* dummy = m_beginnode;		m_beginnode = m_endnode;		m_endnode = dummy;      bool swap = m_LeftA;	   m_LeftA = m_RightA;     		   m_RightA= swap;      swap = m_LeftB;	   m_LeftB = m_RightB;     		   m_RightB= swap;            swap = m_merge_L ;	   m_merge_L = m_merge_R; 	   m_merge_R = swap;       swap = m_a_substract_b_L;	   m_a_substract_b_L = m_a_substract_b_R; 	   m_a_substract_b_R = swap;       swap = m_b_substract_a_L;	   m_b_substract_a_L = m_b_substract_a_R; 	   m_b_substract_a_R = swap;       swap = m_intersect_L;	   m_intersect_L = m_intersect_R; 	   m_intersect_R = swap;       swap = m_exor_L;	   m_exor_L = m_exor_R; 	   m_exor_R = swap;    }}

⌨️ 快捷键说明

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