bool Optimize::LineSegmentsCollide(const Point& p1, const Point& p2, const Point& q1, const Point& q2) { OpenMesh::Vec3d p_center((p1 + p2)/2), q_center((q1+q2)/2); if ((p_center - q_center).norm() < ((p1-p2).norm() + (q1 - q2).norm())/2 + pOp->r) return true; else return false; }
int test_1_shape_ ( Main_Form *b ) { QTextStream std_out ( stdout ); QTextStream std_in ( stdin ); QTransform transform ( 1, 0, 0, 0, -1, 0, 0, 0, 1 ); transform.scale ( 0.5, 0.5 ); QGraphicsView* grView = b->graphicsView; grView->setAlignment ( 0 ); //Qt::AlignLeft | Qt::AlignTop grView->setTransform ( transform ); QGraphicsScene *grScene = new QGraphicsScene; grView->setScene ( grScene ); grView->setTransform ( transform ); grView->setRenderHints ( QPainter::Antialiasing | QPainter::TextAntialiasing | QPainter::SmoothPixmapTransform | QPainter::HighQualityAntialiasing ); int i = 1000; forma_l * a = new forma_l; forma *form = a->get_m_forma(); QList<shapes*>* sh_list = form->get_m_shapes(); sh_list->clear(); shape_e* she_0 = new shape_e(); sh_list->append ( she_0 ); shape_7* sh7_0 = new shape_7 ( 450 ); sh_list->append ( sh7_0 ); shape_56* sh56_0 = new shape_56 ( true ); sh_list->append ( sh56_0 ); shape_b* shb_0 = new shape_b ( 220, -30, -120, -1 ); sh_list->append ( shb_0 ); shape_* sh_0 = new shape_; sh_0->set_length ( 14 ); sh_0->set_sixtant ( 0 ); sh_list->append ( sh_0 ); shape_34* sh34_0 = new shape_34; sh34_0->set_scale_up ( true ); sh34_0->set_scale_factor ( 4 ); sh_list->append ( sh34_0 ); shape_12* sh12_0 = new shape_12 ( false ); sh_list->append ( sh12_0 ); shape_* sh_1 = new shape_; sh_1->set_length ( 14 ); sh_1->set_sixtant ( 4 ); sh_list->append ( sh_1 ); shape_12* sh12_1 = new shape_12 ( true ); sh_list->append ( sh12_1 ); shape_89* sh89_0 = new shape_89; sh89_0->set_xy ( 0, 20, 20 ); sh89_0->append ( -20, 20 ); sh89_0->append ( -20, -20 ); sh89_0->append ( 20, -20 ); sh_list->append ( sh89_0 ); shape_56* sh56_1 = new shape_56 ( false ); sh_list->append ( sh56_1 ); shape_a* sha_0 = new shape_a; sha_0->set_radius ( 120 ); sha_0->set_start ( 0 ); sha_0->set_number ( -1 ); sh_list->append ( sha_0 ); shape_cd* shcd_0 = new shape_cd; shcd_0->set_xy_c ( 0, 20, 20, 127 ); shcd_0->append ( -20, 20, 127 ); shcd_0->append ( -20, -20, 127 ); shcd_0->append ( 20, -20, 127 ); sh_list->append ( shcd_0 ); draw_vars dr; stack st; a->draw ( dr, st, *grScene ); { draw_point p_center ( 0.0, 0.0 ); draw_point p_radius ( 3.5, 3.5 ); grScene->addEllipse ( p_center.x - p_radius.x / 2., p_center.y - p_radius.y / 2., p_radius.x, p_radius.y, QPen ( Qt::red ) ); } std_out << a->out() << endl; forma_l *bb = new forma_l; *bb = *a; std_out << endl; std_out << endl; std_out << bb->out() << endl; delete bb; }