postprocessing.cpp 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615
  1. #include "Postprocessing.h"
  2. Postprocessing::Postprocessing()
  3. {
  4. }
  5. void Postprocessing::applyPostProcessing(SubGraph& gMaingraph )
  6. {
  7. // place empty clusters somewhere default
  8. BoostGraphWrapper bGraphWrapper;
  9. VertexDescriptor verAffected;
  10. VertexIterPair verIter;
  11. // XXX unused
  12. Q_UNUSED(verAffected);
  13. for(tie(verIter.first,verIter.second)=vertices(gMaingraph)
  14. ;verIter.first!=verIter.second;++verIter.first)
  15. {
  16. verAffected = *verIter.first;
  17. }
  18. int iMainTopY = 0;
  19. int iMainTopX = 0 ;
  20. iMainTopX = bGraphWrapper.getGraphLeftTopCoordX(gMaingraph);
  21. iMainTopY = bGraphWrapper.getGraphLeftTopCoordY(gMaingraph);
  22. // XXX unused
  23. Q_UNUSED(iMainTopX);
  24. Q_UNUSED(iMainTopY);
  25. QQueue<SubGraph*> qSubgraphs; // a queue of subgraphs
  26. qSubgraphs.enqueue(&gMaingraph );
  27. SubGraph* gSubgraph1 = NULL;
  28. while(qSubgraphs.isEmpty() == false) // Iterating subgraphs till they exist
  29. {
  30. gSubgraph1 = qSubgraphs.dequeue();
  31. ChildrenIterator iterChild , iterChildEnd;
  32. for(boost::tie(iterChild , iterChildEnd) = gSubgraph1->children();
  33. iterChild != iterChildEnd;iterChild++)
  34. {
  35. SubGraph* gChildGraph = &(*iterChild);
  36. if(boost::num_vertices(*gChildGraph) == 0)
  37. {
  38. bGraphWrapper.setGraphLeftTopCoordX(100,*gChildGraph);
  39. bGraphWrapper.setGraphLeftTopCoordY(100,*gChildGraph);
  40. bGraphWrapper.setGraphHeight(100,*gChildGraph);
  41. bGraphWrapper.setGraphWidth(100,*gChildGraph);
  42. }
  43. }
  44. }
  45. }
  46. void Postprocessing::applyPreProcessing(SubGraph& gMaingraph )
  47. {
  48. // add a dummy vertex to empty subgraph
  49. QQueue<SubGraph*> qSubgraphs; // a queue of subgraphs
  50. qSubgraphs.enqueue(&gMaingraph );
  51. SubGraph* gSubgraph1 = NULL;
  52. while(qSubgraphs.isEmpty() == false) // Iterating subgraphs till they exist
  53. {
  54. gSubgraph1 = qSubgraphs.dequeue();
  55. ChildrenIterator iterChild , iterChildEnd;
  56. for(boost::tie(iterChild , iterChildEnd) = gSubgraph1->children();
  57. iterChild != iterChildEnd;iterChild++)
  58. {
  59. SubGraph* gChildGraph = &(*iterChild);
  60. if(boost::num_vertices(*gChildGraph) == 0)
  61. {
  62. BoostGraphWrapper bGraphWrapper;
  63. // VertexDescriptor verDiscp = bGraphWrapper.addVertex(,*gChildGraph);
  64. VertexDescriptor verDiscp = boost::add_vertex(*gChildGraph);
  65. int igraphId = bGraphWrapper.getGraphClusterID(*gChildGraph);
  66. bGraphWrapper.setVertexClusterID(igraphId,verDiscp,*gChildGraph);
  67. bGraphWrapper.setVertexCenterCoordX(verDiscp,*gChildGraph,00 + 50);
  68. bGraphWrapper.setVertexCenterCoordY(verDiscp,*gChildGraph,00 + 50);
  69. bGraphWrapper.setVertexHeight(verDiscp,*gChildGraph,40);
  70. bGraphWrapper.setVertexWidth(verDiscp,*gChildGraph,40);
  71. bGraphWrapper.setVertexIsInvisible(verDiscp,*gChildGraph,true);
  72. Reingold rein;
  73. rein.setCompartMentProps(*gChildGraph,10);
  74. }
  75. }
  76. }
  77. }
  78. void Postprocessing::membershipFixer(SubGraph& gMaingraph)
  79. {
  80. // checks if membership of any subgraph is voilated
  81. QQueue<SubGraph*> qSubgraphs; // a queue of subgraphs
  82. qSubgraphs.enqueue(&gMaingraph );
  83. SubGraph* gSubgraph1 = NULL;
  84. while(qSubgraphs.isEmpty() == false) // Iterating subgraphs till they exist
  85. {
  86. gSubgraph1 = qSubgraphs.dequeue();
  87. ChildrenIterator iterChild , iterChildEnd;
  88. for(boost::tie(iterChild , iterChildEnd) = gSubgraph1->children();
  89. iterChild != iterChildEnd;iterChild++)
  90. {
  91. SubGraph* gChildGraph = &(*iterChild);
  92. qSubgraphs.enqueue(gChildGraph); // added later
  93. checkAndFixMembership(*gChildGraph);
  94. }
  95. }
  96. }
  97. void Postprocessing::checkClusterOverlap(SubGraph& gMaingraph )
  98. {
  99. // make it default **** Main method ****
  100. m_iRecursionIndex++; // increment recursion index
  101. bool bClusterOverlap = false;
  102. BoostGraphWrapper bGraphWrapper;
  103. QQueue<SubGraph*> qSubgraphs; // a queue of subgraphs
  104. qSubgraphs.enqueue(&gMaingraph );
  105. SubGraph* gSubgraph1 = NULL;
  106. while(qSubgraphs.isEmpty() == false) // Iterating subgraphs till they exist
  107. {
  108. gSubgraph1 = qSubgraphs.dequeue();
  109. ChildrenIterator iterChild , iterChildEnd;
  110. for(boost::tie(iterChild , iterChildEnd) = gSubgraph1->children();
  111. iterChild != iterChildEnd;iterChild++)
  112. {
  113. SubGraph* gChildGraph = &(*iterChild);
  114. ChildrenIterator iterChildInner , iterChildEndInner;
  115. for(boost::tie(iterChildInner , iterChildEndInner) = gSubgraph1->children();
  116. iterChildInner != iterChildEndInner;iterChildInner++)
  117. {
  118. SubGraph* gGraph = &(*iterChildInner);
  119. if(gChildGraph == gGraph)
  120. {
  121. continue;
  122. }
  123. double dVCenterX = bGraphWrapper.getGraphCenterCoordX(*gChildGraph);
  124. double dVCenterY = bGraphWrapper.getGraphCenterCoordY(*gChildGraph);
  125. double dVHeight = bGraphWrapper.getGraphHeight(*gChildGraph);
  126. double dVWidth = bGraphWrapper.getGraphWidth(*gChildGraph);
  127. double dVTopLeftX = bGraphWrapper.getGraphLeftTopCoordX(*gChildGraph);
  128. double dVTopLeftY = bGraphWrapper.getGraphLeftTopCoordY(*gChildGraph);
  129. double dUCenterX = bGraphWrapper.getGraphCenterCoordX(*gGraph);
  130. double dUCenterY = bGraphWrapper.getGraphCenterCoordY(*gGraph);
  131. double dUHeight = bGraphWrapper.getGraphHeight(*gGraph);
  132. double dUWidth = bGraphWrapper.getGraphWidth(*gGraph);
  133. double dUTopLeftX = bGraphWrapper.getGraphLeftTopCoordX(*gGraph);
  134. double dUTopLeftY = bGraphWrapper.getGraphLeftTopCoordY(*gGraph);
  135. // XXX unused
  136. Q_UNUSED(dVCenterX);
  137. Q_UNUSED(dVCenterY);
  138. Q_UNUSED(dUCenterX);
  139. Q_UNUSED(dUCenterY);
  140. Q_UNUSED(dVHeight);
  141. if((dUTopLeftX - CLUSTER_OVERLAP_BOUNDRY) <= (dVTopLeftX - CLUSTER_OVERLAP_BOUNDRY) &&
  142. (dUTopLeftX+ dUWidth+ CLUSTER_OVERLAP_BOUNDRY) > (dVTopLeftX- CLUSTER_OVERLAP_BOUNDRY))
  143. {
  144. if((dUTopLeftY- CLUSTER_OVERLAP_BOUNDRY < dVTopLeftY- CLUSTER_OVERLAP_BOUNDRY ) &&
  145. (dUTopLeftY + dUHeight+ CLUSTER_OVERLAP_BOUNDRY) >= (dVTopLeftY- CLUSTER_OVERLAP_BOUNDRY) )
  146. {
  147. // overlap case 1
  148. bClusterOverlap = true;
  149. }
  150. if((dVTopLeftY-CLUSTER_OVERLAP_BOUNDRY < dUTopLeftY-CLUSTER_OVERLAP_BOUNDRY ) &&
  151. (dVTopLeftY + dVHeight+ CLUSTER_OVERLAP_BOUNDRY) >= (dUTopLeftY-CLUSTER_OVERLAP_BOUNDRY) )
  152. {
  153. // overlap case 2
  154. bClusterOverlap = true;
  155. }
  156. }
  157. if((dVTopLeftX- CLUSTER_OVERLAP_BOUNDRY) <= (dUTopLeftX - CLUSTER_OVERLAP_BOUNDRY) &&
  158. (dVTopLeftX+ dVWidth + CLUSTER_OVERLAP_BOUNDRY) > (dUTopLeftX- CLUSTER_OVERLAP_BOUNDRY))
  159. {
  160. if((dVTopLeftY- CLUSTER_OVERLAP_BOUNDRY) < (dUTopLeftY - CLUSTER_OVERLAP_BOUNDRY) &&
  161. (dVTopLeftY + dVHeight+CLUSTER_OVERLAP_BOUNDRY) >= (dUTopLeftY- CLUSTER_OVERLAP_BOUNDRY) )
  162. {
  163. // overlap
  164. bClusterOverlap = true;
  165. }
  166. if((dUTopLeftY- CLUSTER_OVERLAP_BOUNDRY) < (dVTopLeftY - CLUSTER_OVERLAP_BOUNDRY) &&
  167. (dUTopLeftY + dUHeight+CLUSTER_OVERLAP_BOUNDRY) >= (dVTopLeftY- CLUSTER_OVERLAP_BOUNDRY) )
  168. {
  169. // overlap
  170. bClusterOverlap = true;
  171. }
  172. }
  173. if( bClusterOverlap)
  174. {
  175. bClusterOverlap = false;
  176. clusterOverlapRemoval(*gChildGraph,*gGraph);
  177. // remove overlap
  178. }
  179. }
  180. qSubgraphs.enqueue(gChildGraph);
  181. }
  182. }
  183. while(m_iRecursionIndex < CLUSTER_OVERLAP_REMOVAL_PASSES )
  184. {
  185. checkClusterOverlap(gMaingraph);
  186. }
  187. }
  188. void Postprocessing::clusterOverlapRemoval(SubGraph& gChildOne ,
  189. SubGraph& gChildSecond)
  190. {
  191. // default cluster overlap removal code
  192. BoostGraphWrapper bGraphWrapper;
  193. double dVCenterX = bGraphWrapper.getGraphCenterCoordX(gChildOne);
  194. double dVCenterY = bGraphWrapper.getGraphCenterCoordY(gChildOne);
  195. double dVHeight = bGraphWrapper.getGraphHeight(gChildOne);
  196. double dVWidth = bGraphWrapper.getGraphWidth(gChildOne);
  197. double dVTopLeftX = bGraphWrapper.getGraphLeftTopCoordX(gChildOne);
  198. double dVTopLeftY = bGraphWrapper.getGraphLeftTopCoordY(gChildOne);
  199. double dUCenterX = bGraphWrapper.getGraphCenterCoordX(gChildSecond);
  200. double dUCenterY = bGraphWrapper.getGraphCenterCoordY(gChildSecond);
  201. double dUHeight = bGraphWrapper.getGraphHeight(gChildSecond);
  202. double dUWidth = bGraphWrapper.getGraphWidth(gChildSecond);
  203. double dUTopLeftX = bGraphWrapper.getGraphLeftTopCoordX(gChildSecond);
  204. double dUTopLeftY = bGraphWrapper.getGraphLeftTopCoordY(gChildSecond);
  205. double dIntersectionHorizontal = 0.0;
  206. double dIntersectionVertical = 0.0 ;
  207. VertexDescriptor verAffected;
  208. VertexIterPair verIter;
  209. // XXX unused
  210. Q_UNUSED(dVCenterX);
  211. Q_UNUSED(dVCenterY);
  212. Q_UNUSED(dVHeight);
  213. Q_UNUSED(dUCenterX);
  214. Q_UNUSED(dUCenterY);
  215. Q_UNUSED(dUHeight);
  216. Q_UNUSED(dUWidth);
  217. Q_UNUSED(dIntersectionVertical);
  218. cout<<"\n \n Intersection Found";
  219. dIntersectionHorizontal = fabs(dUTopLeftX - (dVTopLeftX + dVWidth))*
  220. fabs(dUTopLeftX - (dVTopLeftX + dVWidth))
  221. + (fabs(dUTopLeftY - (dVTopLeftY + dVWidth)) *
  222. fabs(dUTopLeftY - (dVTopLeftY + dVWidth))) ; // change y coordinate
  223. dIntersectionHorizontal = sqrt(dIntersectionHorizontal);
  224. if(dVTopLeftX < dUTopLeftX)
  225. {
  226. cout<<"\n \n Intersection = "<<dIntersectionHorizontal;
  227. for(tie(verIter.first,verIter.second)=vertices(gChildOne)
  228. ;verIter.first!=verIter.second;++verIter.first)
  229. {
  230. verAffected = *verIter.first;
  231. int iCoordX = bGraphWrapper.getVertexCenterCoordX(verAffected,gChildOne);
  232. //iCoordX -= (dIntersectionHorizontal/2 + 150); //100*(-dYDisp/fabs(dYDisp));
  233. bGraphWrapper.setVertexCenterCoordX(verAffected,gChildOne,iCoordX);
  234. }
  235. for(tie(verIter.first,verIter.second)=vertices(gChildSecond)
  236. ;verIter.first!=verIter.second;++verIter.first)
  237. {
  238. verAffected = *verIter.first;
  239. int iCoordX = bGraphWrapper.getVertexCenterCoordX(verAffected,gChildSecond);
  240. iCoordX += (dIntersectionHorizontal/2 + 150); //100*(-dYDisp/fabs(dYDisp));
  241. bGraphWrapper.setVertexCenterCoordX(verAffected,gChildSecond,iCoordX);
  242. }
  243. }
  244. else
  245. {
  246. for(tie(verIter.first,verIter.second)=vertices(gChildOne)
  247. ;verIter.first!=verIter.second;++verIter.first)
  248. {
  249. verAffected = *verIter.first;
  250. int iCoordX = bGraphWrapper.getVertexCenterCoordX(verAffected,gChildOne);
  251. iCoordX += (dIntersectionHorizontal/2 + 150); //100*(-dYDisp/fabs(dYDisp));
  252. bGraphWrapper.setVertexCenterCoordX(verAffected,gChildOne,iCoordX);
  253. }
  254. for(tie(verIter.first,verIter.second)=vertices(gChildSecond)
  255. ;verIter.first!=verIter.second;++verIter.first)
  256. {
  257. verAffected = *verIter.first;
  258. int iCoordX = bGraphWrapper.getVertexCenterCoordX(verAffected,gChildSecond);
  259. // iCoordX -= (dIntersectionHorizontal/2 + 150); //100*(-dYDisp/fabs(dYDisp));
  260. bGraphWrapper.setVertexCenterCoordX(verAffected,gChildSecond,iCoordX);
  261. }
  262. }
  263. Reingold rein ;
  264. rein.SetClusterCompartmentPropsNew(gChildOne);
  265. rein.SetClusterCompartmentPropsNew(gChildSecond);
  266. }
  267. void Postprocessing::checkAndFixMembership(SubGraph& gSubgraph)
  268. {
  269. BoostGraphWrapper bGraphWrapper;
  270. VertexDescriptor verAffected;
  271. VertexIterPair verIter;
  272. int iSubGraphId = bGraphWrapper.getGraphClusterID(gSubgraph);
  273. SpringEmbedder *spl = new SpringEmbedder();
  274. QVector<int> vRestBound;
  275. QVector<SubGraph *> vClusters;
  276. spl->getRestrictedBounds(gSubgraph,vRestBound,vClusters);
  277. for(tie(verIter.first,verIter.second)=vertices(gSubgraph)
  278. ;verIter.first!= verIter.second;++verIter.first)
  279. {
  280. verAffected = *verIter.first;
  281. int iVertexId = bGraphWrapper.getVertexClusterID(verAffected,gSubgraph);
  282. if(iVertexId != iSubGraphId)
  283. {
  284. continue;
  285. }
  286. int iCoordX = bGraphWrapper.getVertexCenterCoordX(verAffected,gSubgraph);
  287. int iCoordY = bGraphWrapper.getVertexCenterCoordY(verAffected,gSubgraph);
  288. int iVertexLeftTopX = bGraphWrapper.getVertexLeftCoordX(verAffected,gSubgraph);
  289. int iVertexLeftTopY = bGraphWrapper.getVertexLeftCoordY(verAffected,gSubgraph);
  290. // XXX unused
  291. Q_UNUSED(iVertexLeftTopX);
  292. Q_UNUSED(iVertexLeftTopY);
  293. int iRestrictedAreas = vRestBound.size();
  294. if(iRestrictedAreas !=0)
  295. {
  296. iRestrictedAreas = iRestrictedAreas/6;
  297. }
  298. int iIndex = 0;
  299. for(int i = 0;i< iRestrictedAreas ; i++)
  300. {
  301. int iHeight = vRestBound.at(iIndex+2);
  302. int iWidth = vRestBound.at(iIndex+3);
  303. int iLeftTopX = vRestBound.at(iIndex+4);
  304. int iLeftTopY = vRestBound.at(iIndex+5);
  305. bool bVoilated = false;
  306. // orignally 50 instead of 80
  307. if(iCoordX >= iLeftTopX - 80 && iCoordX <= iLeftTopX+iWidth+80 )
  308. {
  309. if(iCoordY >= iLeftTopY- 80 && iCoordY <= iLeftTopY + iHeight + 80 )
  310. {
  311. bVoilated = true;
  312. }
  313. }
  314. if(bVoilated)
  315. {
  316. cout<<"\n\n ********* Voilated **************";
  317. int iDxLeft = 0 , iDyTop = 0, iDxRight =0 , iDyBottom = 0 ;
  318. iDxLeft = sqrt((iCoordX - iLeftTopX)*(iCoordX - iLeftTopX));
  319. iDxRight = sqrt((iCoordX - (iLeftTopX + iWidth))*
  320. (iCoordX - (iLeftTopX + iWidth)));
  321. iDyTop = sqrt((iCoordY - iLeftTopY)*(iCoordY - iLeftTopY));
  322. iDyBottom = sqrt((iCoordY - (iLeftTopY + iHeight))*
  323. (iCoordY - (iLeftTopY + iHeight)));
  324. // working formulae
  325. // if(abs(iDxLeft) > abs(iDxRight) )
  326. // {
  327. // iCoordX = iLeftTopX + iWidth + CORRECTED_DISTANCE +
  328. // std::rand()%CORRECTED_DISTANCE;
  329. // }
  330. // else
  331. // {
  332. // iCoordX = iLeftTopX - CORRECTED_DISTANCE -
  333. // std::rand()%CORRECTED_DISTANCE;
  334. // }
  335. // {
  336. // if(abs(iDyTop) > abs(iDyBottom) )
  337. // {
  338. // iCoordY = iLeftTopY + iHeight + CORRECTED_DISTANCE +
  339. // std::rand()%CORRECTED_DISTANCE;
  340. // }
  341. // else
  342. // {
  343. // iCoordY = iLeftTopY - CORRECTED_DISTANCE -
  344. // std::rand()%CORRECTED_DISTANCE;
  345. // }
  346. // }
  347. // trying new for time being
  348. int iSmallest = std::min(iDxLeft,std::min(iDxRight,std::min(iDyTop,iDyBottom)));
  349. if( iDxLeft == iSmallest)
  350. {
  351. iCoordX = iCoordX - iSmallest - CORRECTED_DISTANCE - std::rand()%CORRECTED_DISTANCE;
  352. }
  353. if(iDxRight == iSmallest)
  354. {
  355. iCoordX = iCoordX + iSmallest + CORRECTED_DISTANCE + std::rand()%CORRECTED_DISTANCE;
  356. }
  357. if(iDyBottom == iSmallest)
  358. {
  359. iCoordY = iCoordY + iSmallest + CORRECTED_DISTANCE + std::rand()%CORRECTED_DISTANCE;
  360. }
  361. if(iDyTop == iSmallest)
  362. {
  363. iCoordY = iCoordY - iSmallest - CORRECTED_DISTANCE - std::rand()%CORRECTED_DISTANCE;
  364. }
  365. bGraphWrapper.setVertexCenterCoordX(verAffected,gSubgraph,iCoordX);
  366. bGraphWrapper.setVertexCenterCoordY(verAffected,gSubgraph,iCoordY);
  367. }
  368. }
  369. }
  370. }
  371. void Postprocessing::overlapRemoval(SubGraph& gMaingraph )
  372. {
  373. // save vertices and x y cordinates ,
  374. // sort on x
  375. // look for min separation of width/2
  376. // if not min separation
  377. m_iVertexOverlapConter++;
  378. VertexDescriptor verAffected,verVisitor;
  379. VertexIterPair verIter,verIterEnd;
  380. BoostGraphWrapper bGraphWrapper;
  381. for(tie(verIter.first,verIter.second)=vertices(gMaingraph)
  382. ;verIter.first!=verIter.second;++verIter.first)
  383. {
  384. verAffected = *verIter.first;
  385. double X_Coord_V = bGraphWrapper.getVertexCenterCoordX(verAffected,gMaingraph);
  386. double Y_Coord_V = bGraphWrapper.getVertexCenterCoordY(verAffected,gMaingraph);
  387. for(tie(verIterEnd.first,verIterEnd.second)=vertices(gMaingraph);
  388. verIterEnd.first != verIterEnd.second;++verIterEnd.first)
  389. {
  390. verVisitor = *verIterEnd.first;
  391. double X_Coord_U = bGraphWrapper.getVertexCenterCoordX(verVisitor,gMaingraph);
  392. double Y_Coord_U = bGraphWrapper.getVertexCenterCoordY(verVisitor,gMaingraph);
  393. if(verAffected == verVisitor)
  394. {
  395. continue;
  396. }
  397. // Logic for vertex size here
  398. double d_Width_U = bGraphWrapper.getVertexWidth(verVisitor,gMaingraph);
  399. double d_Height_U = bGraphWrapper.getVertexHeight(verVisitor,gMaingraph);
  400. double d_Width_V = bGraphWrapper.getVertexWidth(verAffected,gMaingraph);
  401. double d_Height_V = bGraphWrapper.getVertexHeight(verAffected,gMaingraph );
  402. double dSizeU = std::max(d_Width_U,0.0);
  403. double dSizeV = std:: max(d_Width_V,0.0);
  404. double d_LeftTop_X_U = X_Coord_U - d_Width_U/2;
  405. double d_LeftTop_X_V = X_Coord_V - d_Width_V/2;
  406. double d_LeftTop_Y_U = Y_Coord_U - d_Height_U/2;
  407. double d_LeftTop_Y_V = Y_Coord_V - d_Height_U/2;
  408. // XXX unused
  409. Q_UNUSED(dSizeU);
  410. Q_UNUSED(dSizeV);
  411. double vx = X_Coord_V - X_Coord_U;
  412. double vy = Y_Coord_V - Y_Coord_U;
  413. double dDist = fabs((vx*vx + vy* vy));
  414. dDist = sqrt(dDist);
  415. cout<<"\nDistance at Overlap removal : "<<dDist;
  416. if( (d_LeftTop_X_V > d_LeftTop_X_U && d_LeftTop_X_V < d_LeftTop_X_U+ d_Width_U)||
  417. (d_LeftTop_X_V < d_LeftTop_X_U && d_LeftTop_X_V+ d_Width_V > d_LeftTop_X_U)) //dDist == 0 || dDist < 60)
  418. {
  419. // x intersept
  420. if((d_LeftTop_Y_V > d_LeftTop_Y_U && d_LeftTop_Y_U + d_Height_U > d_LeftTop_Y_V)
  421. || (d_LeftTop_Y_U > d_LeftTop_Y_V && d_LeftTop_Y_V + d_Height_V > d_LeftTop_Y_U) ) //(X_Coord_U - dSizeU/2 > X_Coord_V - dSizeV/2 ) // replace with overlap condition
  422. {
  423. if(Y_Coord_U < Y_Coord_V) // WORKING LOGIC
  424. {
  425. X_Coord_U = X_Coord_U + std::rand()%20+ CORRECTED_DISTANCE/2 +10 ; //+100;
  426. Y_Coord_U = Y_Coord_U + std::rand()%20- CORRECTED_DISTANCE/4 ;
  427. bGraphWrapper.setVertexCenterCoordX(verVisitor,gMaingraph,X_Coord_U);
  428. bGraphWrapper.setVertexCenterCoordY(verVisitor,gMaingraph,Y_Coord_U);
  429. }
  430. else
  431. {
  432. X_Coord_U = X_Coord_U + std::rand()%20+ CORRECTED_DISTANCE/2 +10 ; //+100;
  433. Y_Coord_U = Y_Coord_U + std::rand()%20+ CORRECTED_DISTANCE/4;
  434. bGraphWrapper.setVertexCenterCoordX(verVisitor,gMaingraph,X_Coord_U);
  435. bGraphWrapper.setVertexCenterCoordY(verVisitor,gMaingraph,Y_Coord_U);
  436. }
  437. // double dIntersectionHorizontal = 0;
  438. // if(d_LeftTop_X_U < d_LeftTop_X_V)
  439. // {
  440. // dIntersectionHorizontal = (d_LeftTop_X_V - (d_LeftTop_X_U + d_Width_U))
  441. // *(d_LeftTop_X_V - (d_LeftTop_X_U + d_Width_U));
  442. // dIntersectionHorizontal = sqrt(dIntersectionHorizontal);
  443. // X_Coord_U = X_Coord_U + std::rand()%30+ dIntersectionHorizontal;
  444. // bGraphWrapper.setVertexCenterCoordX(verVisitor,gMaingraph,X_Coord_U);
  445. // }
  446. // else
  447. // {
  448. // dIntersectionHorizontal = (d_LeftTop_X_U - (d_LeftTop_X_V + d_Width_V))
  449. // *(d_LeftTop_X_U - (d_LeftTop_X_V + d_Width_V));
  450. // dIntersectionHorizontal = sqrt(dIntersectionHorizontal);
  451. // X_Coord_V = X_Coord_V + std::rand()%30+ dIntersectionHorizontal;
  452. // bGraphWrapper.setVertexCenterCoordX(verVisitor,gMaingraph,X_Coord_V);
  453. // }
  454. }
  455. // else
  456. // {
  457. // if(Y_Coord_V < Y_Coord_U)
  458. // {
  459. // X_Coord_V = X_Coord_V + std::rand()%20+ CORRECTED_DISTANCE/2; //100;
  460. // Y_Coord_V = Y_Coord_V + std::rand()%20- CORRECTED_DISTANCE/4;
  461. // bGraphWrapper.setVertexCenterCoordX(verAffected,gMaingraph,X_Coord_V);
  462. // bGraphWrapper.setVertexCenterCoordY(verAffected,gMaingraph,Y_Coord_V);
  463. // }
  464. // else
  465. // {
  466. // X_Coord_V = X_Coord_V + std::rand()%20 + CORRECTED_DISTANCE/2; //100;
  467. // Y_Coord_V = Y_Coord_V + std::rand()%20 + CORRECTED_DISTANCE/4;
  468. // bGraphWrapper.setVertexCenterCoordX(verAffected,gMaingraph,X_Coord_V);
  469. // bGraphWrapper.setVertexCenterCoordY(verAffected,gMaingraph,Y_Coord_V);
  470. // }
  471. // }
  472. }
  473. }
  474. }
  475. if(m_iVertexOverlapConter < 25) //VERTEX_OVERLAP_REMOVAL_PASSES)
  476. {
  477. overlapRemoval(gMaingraph);
  478. }
  479. }