degate  0.1.2
Public Member Functions | Private Attributes
degate::LineSegment Class Reference

Line segment. More...

#include <LineSegmentExtraction.h>

Inheritance diagram for degate::LineSegment:
Inheritance graph
[legend]

List of all members.

Public Member Functions

 LineSegment (LinearPrimitive_shptr lp)
void merge (LineSegment_shptr seg)

Private Attributes

std::list< LinearPrimitive_shptrsegments

Detailed Description

Line segment.

Definition at line 54 of file LineSegmentExtraction.h.


Constructor & Destructor Documentation

Definition at line 58 of file LineSegmentExtraction.h.

                                          :
      LinearPrimitive(lp->get_from_x(), lp->get_from_y(), lp->get_to_x(), lp->get_to_y()) {
    }

Member Function Documentation

Definition at line 62 of file LineSegmentExtraction.h.

References degate::Point::get_distance(), degate::Line::get_p1(), degate::Line::get_p2(), degate::Line::set_p1(), and degate::Line::set_p2().

                                      {
      //std::cout << "merging lines:" << std::endl;
      //print();
      //seg->print();

      Point a1 = get_p1();
      Point a2 = get_p2();
      Point b1 = seg->get_p1();
      Point b2 = seg->get_p2();

      unsigned int a1b1 = a1.get_distance(b1);
      unsigned int a1b2 = a1.get_distance(b2);
      unsigned int a2b1 = a2.get_distance(b1);
      unsigned int a2b2 = a2.get_distance(b2);

      // +-----------------+       +--------------+
      // A1                A2      B1             B2

      if(a2b1 <= a1b1 && a2b1 <= a1b2 && a2b1 <= a2b2) {
        set_p1(a1);set_p2(b2);
      }

      // +-----------------+       +--------------+
      // A2                A1      B1             B2

      else if(a1b1 <= a1b2 && a1b1 <= a2b1 && a1b1 <= a2b2) {
        set_p1(a2); set_p2(b2);
      }

      // +-----------------+       +--------------+
      // A2                A1      B2             B1

      else if(a1b2 <= a1b1 && a1b2 <= a2b1 && a1b2 <= a2b2) {
        set_p1(a2);set_p2(b1);
      }

      // +-----------------+       +--------------+
      // A1                A2      B2             B1

      else if(a2b2 <= a1b1 && a2b2 <= a1b2 && a2b2 <= a2b1) {
        set_p1(a1);set_p2(b1);
      }

      //std::cout << "Result: " << std::endl;
      //print();

    }

Here is the call graph for this function:


Member Data Documentation

Definition at line 56 of file LineSegmentExtraction.h.


The documentation for this class was generated from the following file: