You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
158 lines
2.5 KiB
158 lines
2.5 KiB
#include <cstdio>
|
|
#include <iostream>
|
|
#include "edge.h"
|
|
#include "vtr.h"
|
|
#include "bc.h"
|
|
|
|
edge::edge(){
|
|
nd[0] = nd[1] = 0;
|
|
cnt = -1;
|
|
bType = 0;
|
|
globalCnt = 0;
|
|
IsPmcOnceSet = false;
|
|
IsPecOnceSet = false;
|
|
PecPmc = false;
|
|
e.reset();
|
|
h.reset();
|
|
}
|
|
|
|
void edge::setEdge(node *nd0, node *nd1){
|
|
nd[0] = nd0;
|
|
nd[1] = nd1;
|
|
if((*nd0) > (*nd1)){
|
|
nd[0] = nd1;
|
|
nd[1] = nd0;
|
|
}
|
|
}
|
|
|
|
int edge::operator > (const edge &right) const{
|
|
int i;
|
|
|
|
for (i = 0; i < 2; i ++) {
|
|
if ((*(nd[i])) > (*(right.nd[i])))
|
|
return 1;
|
|
if ((*(nd[i])) < (*(right.nd[i])))
|
|
return 0;
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
|
|
int edge::operator < (const edge &right) const{
|
|
int i;
|
|
|
|
for (i = 0; i < 2; i ++) {
|
|
if ((*(nd[i])) < (*(right.nd[i])))
|
|
return 1;
|
|
if ((*(nd[i])) > (*(right.nd[i])))
|
|
return 0;
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
|
|
int edge::operator == (const edge &right) const{
|
|
int i;
|
|
|
|
for (i = 0; i < 2; i ++) {
|
|
if (nd[i] != (right.nd[i]))
|
|
return 0;
|
|
}
|
|
|
|
return 1;
|
|
}
|
|
|
|
edge& edge::operator = (const edge &right){
|
|
nd[0] = right.nd[0];
|
|
nd[1] = right.nd[1];
|
|
|
|
bType = right.bType;
|
|
cnt = right.cnt;
|
|
}
|
|
|
|
int edge::getid(int n){
|
|
return (nd[n]->getid());
|
|
}
|
|
|
|
int edge::getcnt(){
|
|
return cnt;
|
|
}
|
|
|
|
void edge::setcnt(int nn){
|
|
cnt = nn;
|
|
}
|
|
|
|
void edge::print(){
|
|
cout << nd[0]->getid() << ", " << nd[1]->getid() << "bType " << bType << "Unknown Number " << cnt << endl;
|
|
}
|
|
|
|
void edge::setbType(int b_type){
|
|
if(b_type == pmcType){
|
|
IsPmcOnceSet = true; //add
|
|
bType = b_type;
|
|
}else if(b_type == pecType){
|
|
IsPecOnceSet = true; //add
|
|
bType = b_type;
|
|
}else{
|
|
bType = (b_type > bType) ? b_type : bType;
|
|
}
|
|
PecPmc = IsPmcOnceSet && IsPecOnceSet;
|
|
nd[0]->setbType(bType);
|
|
nd[1]->setbType(bType);
|
|
}
|
|
|
|
void edge::ReplacebType(int b_type){
|
|
if(b_type == pmcType){
|
|
IsPmcOnceSet = true; //add
|
|
bType = b_type;
|
|
}else if(b_type == pecType){
|
|
IsPecOnceSet = true; //add
|
|
bType = b_type;
|
|
}else{
|
|
bType = b_type;
|
|
}
|
|
PecPmc = IsPmcOnceSet && IsPecOnceSet;
|
|
nd[0]->setbType(bType);
|
|
nd[1]->setbType(bType);
|
|
}
|
|
|
|
node *edge::getNode(int n){
|
|
return nd[n];
|
|
}
|
|
|
|
fp_t edge::length(){
|
|
vtr lvtr;
|
|
|
|
lvtr = nd[1]->getCoord() - nd[0]->getCoord();
|
|
|
|
return lvtr.magnitude();
|
|
}
|
|
|
|
vtr edge::Center(){
|
|
vtr ctr;
|
|
|
|
ctr = nd[0]->getCoord() + nd[1]->getCoord();
|
|
ctr = ctr * 0.5;
|
|
|
|
return ctr;
|
|
}
|
|
|
|
void edge::AddToE(cVtr cv){
|
|
e = e + cv;
|
|
}
|
|
|
|
void edge::AddToH(cVtr cv){
|
|
h = h + cv;
|
|
}
|
|
|
|
cVtr edge::GetE(){
|
|
return e;
|
|
}
|
|
|
|
cVtr edge::GetH(){
|
|
return h;
|
|
}
|
|
|
|
void edge::resetEH(){
|
|
e.reset(); h.reset();
|
|
} |