/* * Copyright (C) 2003 Christian Zeller * Copyright (C) 2003 Christian Meyer * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "constraint.h" using namespace Ped; /* Constraint::Constraint() { } */ Constraint::Constraint(Alignment& start_align, Alignment& end_align, Geometry& start_range, Geometry& end_range, Sector min_size, Sector max_size) { constraint_ = ped_constraint_new (start_align.get_c_alignment(), end_align.get_c_alignment(), start_range.get_c_geometry(), end_range.get_c_geometry(), min_size, max_size); ped_constraint_init (constraint_, start_align.get_c_alignment(), end_align.get_c_alignment(), start_range.get_c_geometry(), end_range.get_c_geometry(), min_size, max_size); this->startrange = start_range; this->endrange = end_range; this->start_align = start_align; this->end_align = end_align; this->min_size = min_size; this->max_size = max_size; } /* Constraint::Constraint(Geometry& min, Geometry& max) { constraint_ = ped_constraint_new_from_min_max(min.get_c_geometry(), max.get_c_geometry()); this->start_range = start_range; this->end_range = end_range; this->start_align = start_align; this->end_align = end_align; this->min_size = min_size; this->max_size = max_size; } Constraint::Constraint(Geometry& minmax, bool isMin) { if (isMin) { constraint_ = ped_constraint_new_from_min(minmax.get_c_geometry()); } else { constraint_ = ped_constraint_new_from_max(minmax.get_c_geometry()); } } */ Constraint::~Constraint() { if (constraint_) { ped_constraint_done(constraint_); ped_constraint_destroy(constraint_); } } /* Constraint& Constraint::duplicate() { Constraint& constraint = * new Constraint(); constraint.set_c_constraint(ped_constraint_duplicate(constraint_)); return constraint; } */ Constraint& Constraint::intersect(Constraint& a) { /* Constraint& constraint = * new Constraint(); constraint.set_c_constraint(ped_constraint_intersect(constraint_, a.get_c_constraint())); return constraint; */ PedConstraint *constr = ped_constraint_intersect(constraint_, a.get_c_constraint()); Geometry &start_range = * new Geometry(a.start_range.device, constr->start_range->start, constr->start_range->length); Geometry &end_range = * new Geometry(a.end_range.device, constr->end_range->end, constr->end_range->length); Alignment &start_align = * new Alignment(constr->start_range->start, constr->start_range->length); // FIXME Alignment &end_align = * new Alignment(constr->end_range->end, constr->end_range->length); // FIXME return ( * new Constraint(start_align, end_align, start_range, end_range, min_size, max_size) ); } Geometry& Constraint::solve_max() { Geometry& geometry = * new Geometry(); geometry.set_c_geometry(ped_constraint_solve_max(constraint_)); return geometry; } Geometry& Constraint::solve_nearest(Geometry& geom) { Geometry& geometry = * new Geometry(); geometry.set_c_geometry(ped_constraint_solve_nearest(constraint_, geom.get_c_geometry())); return geometry; } bool Constraint::is_solution(Geometry& geom) { return ped_constraint_is_solution(constraint_, geom.get_c_geometry()); } /* vim: set tabstop=4 et shiftwidth=4: */