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

📄 link.cpp

📁 EDA PCB 电路设计工具源码 c/c++ for Linux, Windows, Mac, 2008.8 最新
💻 CPP
📖 第 1 页 / 共 2 页
字号:
/*! \file ../src/link.cpp    \author Probably Klaas Holwerda    Copyright: 2001-2004 (C) Probably Klaas Holwerda    Licence: wxWidgets Licence    RCS-ID: $Id: link.cpp,v 1.10 2005/06/17 22:54:37 kbluck Exp $*/#ifdef __GNUG__#pragma implementation #endif#include "../include/booleng.h"#include "../include/link.h"#include "../include/line.h"#include <math.h>#include <assert.h>#include "../include/node.h"#include "../include/graph.h"#include "../include/graphlst.h"int linkXYsorter(KBoolLink *, KBoolLink *);//// Default constructor//KBoolLink::KBoolLink(Bool_Engine* GC){   _GC=GC;	Reset();}//// This constructor makes this link a valid part of a graph//KBoolLink::KBoolLink(int graphnr, Node *begin, Node *end, Bool_Engine* GC){   _GC=GC;	Reset();	// Set the references of the node and of this link correct	begin->AddLink(this);	end->AddLink(this);	m_beginnode = begin;	m_endnode = end;	m_graphnum = graphnr;}//// This constructor makes this link a valid part of a graph//KBoolLink::KBoolLink(Node *begin, Node *end, Bool_Engine* GC){	_GC=GC;	Reset();	// Set the references of the node and of this link correct	begin->AddLink(this);	end->AddLink(this);	m_beginnode=begin;	m_endnode=end;	m_graphnum=0;}//// Destructor//KBoolLink::~KBoolLink(){	UnLink();}////	Checks whether the current algorithm has been on this link//bool KBoolLink::BeenHere(){   if (m_bin) return true;	return false;}void KBoolLink::TakeOverOperationFlags( KBoolLink* link ){   m_merge_L = link->m_merge_L;   m_a_substract_b_L = link->m_a_substract_b_L;   m_b_substract_a_L = link->m_b_substract_a_L;   m_intersect_L = link->m_intersect_L;   m_exor_L = link->m_exor_L;   m_merge_R = link->m_merge_R;   m_a_substract_b_R = link->m_a_substract_b_R;   m_b_substract_a_R = link->m_b_substract_a_R;   m_intersect_R = link->m_intersect_R;   m_exor_R = link->m_exor_R;}////	Returns the next link from the argument//KBoolLink*	KBoolLink::Forth(Node *node){	assert(node==m_beginnode || node==m_endnode);	return node->GetOtherLink(this);}//// Returns the Beginnode//Node *KBoolLink::GetBeginNode(){	return m_beginnode;}//// Returns the endnode//Node*	KBoolLink::GetEndNode(){	return m_endnode;}Node*	KBoolLink::GetLowNode(){	return ( ( m_beginnode->GetY() < m_endnode->GetY() ) ? m_beginnode : m_endnode );}Node*	KBoolLink::GetHighNode(){	return ( ( m_beginnode->GetY() > m_endnode->GetY() ) ? m_beginnode : m_endnode );}//// Returns the graphnumber//int KBoolLink::GetGraphNum(){	return m_graphnum;}bool KBoolLink::GetInc(){   return m_Inc;//   if (Inc) return true;//	return false;}void KBoolLink::SetInc(bool inc){     m_Inc = inc;//   Inc=0;//   if (inc) Inc=1;}bool KBoolLink::GetLeftA(){	return m_LeftA;}void KBoolLink::SetLeftA(bool la){	m_LeftA = la;}bool KBoolLink::GetLeftB(){	return m_LeftB;}void KBoolLink::SetLeftB(bool lb){	m_LeftB = lb;}bool KBoolLink::GetRightA(){	return m_RightA;}void KBoolLink::SetRightA(bool ra){	m_RightA = ra;}bool KBoolLink::GetRightB(){	return m_RightB;}void KBoolLink::SetRightB(bool rb){	m_RightB = rb;}////	This function is very popular by GP-faults// It returns the node different from a//Node* KBoolLink::GetOther(const Node *const a){	return ( (a != m_beginnode) ? m_beginnode : m_endnode);}////	Is this marked for given operation//bool KBoolLink::IsMarked(BOOL_OP operation){		switch (operation)		{			 case(BOOL_OR): 	 		return m_merge_L || m_merge_R;			 case(BOOL_AND):  		return m_intersect_L || m_intersect_R;			 case(BOOL_A_SUB_B):  return m_a_substract_b_L || m_a_substract_b_R;			 case(BOOL_B_SUB_A): 	return m_b_substract_a_L || m_b_substract_a_R;			 case(BOOL_EXOR):	 		return m_exor_L || m_exor_R;       default:             return false;		}}bool KBoolLink::IsMarkedLeft(BOOL_OP operation)          {		switch (operation)		{			 case(BOOL_OR):      return m_merge_L;			 case(BOOL_AND):     return m_intersect_L;			 case(BOOL_A_SUB_B): return m_a_substract_b_L;			 case(BOOL_B_SUB_A): return m_b_substract_a_L;			 case(BOOL_EXOR):    return m_exor_L;       default:            return false;		}}bool KBoolLink::IsMarkedRight(BOOL_OP operation){		switch (operation)		{			 case(BOOL_OR):      return m_merge_R;			 case(BOOL_AND):     return m_intersect_R;			 case(BOOL_A_SUB_B): return m_a_substract_b_R;			 case(BOOL_B_SUB_A): return m_b_substract_a_R;			 case(BOOL_EXOR):    return m_exor_R;       default:            return false;		}}////	Is this a hole for given operation// beginnode must be to the leftbool KBoolLink::IsHole(BOOL_OP operation){   bool topsideA,topsideB;	if (m_beginnode->GetX() < m_endnode->GetX()) //going to the right?   { 	topsideA = m_RightA; topsideB = m_RightB;  }   else   {  topsideA = m_LeftA; topsideB = m_LeftB; }   switch (operation)   {       case(BOOL_OR):      return ( !topsideB && !topsideA );       case(BOOL_AND):     return ( !topsideB || !topsideA );       case(BOOL_A_SUB_B): return ( topsideB || !topsideA );       case(BOOL_B_SUB_A): return ( topsideA || !topsideB );       case(BOOL_EXOR):    return !( (topsideB && !topsideA) || (!topsideB && topsideA) );       default:            return false;   }}//// Is this a part of a hole//bool KBoolLink::GetHole(){	return (m_hole);}void KBoolLink::SetHole(bool h){	m_hole = h;}////	Is this not marked at all//bool KBoolLink::IsUnused(){	return             !(m_merge_L || m_merge_R ||              m_a_substract_b_L || m_a_substract_b_R ||              m_b_substract_a_L || m_b_substract_a_R ||              m_intersect_L || m_intersect_R ||              m_exor_L || m_exor_R );}bool KBoolLink::IsZero(B_INT marge){	return (m_beginnode->Equal(m_endnode,marge)) ;}bool KBoolLink::ShorterThan(B_INT marge){	return (m_beginnode->ShorterThan(m_endnode,marge)) ;}////	Mark this link//void KBoolLink::Mark(){	m_mark = true;}#ifndef ABS#define ABS(a) (((a)<0) ? -(a) : (a))#endif//// This makes from the begin and endnode one node (argument begin_or_end_node)// The references to this link in the node will also be deleted// After doing that, link link can be deleted or be recycled.//void KBoolLink::MergeNodes(Node *const begin_or_end_node){//	assert(beginnode && endnode);//	assert ((begin_or_end_node == beginnode)||(begin_or_end_node == endnode));	m_beginnode->RemoveLink(this);	m_endnode->RemoveLink(this);	if (m_endnode != m_beginnode)	{	// only if beginnode and endnode are different nodes		begin_or_end_node->Merge(GetOther(begin_or_end_node));	}	m_endnode = NULL;	m_beginnode=NULL;}////	Return the position of the second link compared to this link// Result = IS_ON | IS_LEFT | IS_RIGHT// Here Left and Right is defined as being left or right from// the this link towards the center (common) node//LinkStatus KBoolLink::OutProduct(KBoolLink* const two,double accur){	Node*	center;	double distance;	if (two->GetBeginNode()->Equal(two->GetEndNode(), 1))

⌨️ 快捷键说明

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