diff options
author | Marius Kintel <marius@kintel.net> | 2011-09-01 18:03:35 (GMT) |
---|---|---|
committer | Marius Kintel <marius@kintel.net> | 2011-09-01 18:03:35 (GMT) |
commit | c5758fbbfc13f3cf098bc74acdd1154bcab55cb7 (patch) | |
tree | e2e5f1e1b521a737bca7201c04807550ff3f21f9 /src/CGAL_Nef_polyhedron.cc | |
parent | 6041c34f0b458b3cb791a0e15b0f01bf3142981c (diff) |
bugfixes after refactoring
Diffstat (limited to 'src/CGAL_Nef_polyhedron.cc')
-rw-r--r-- | src/CGAL_Nef_polyhedron.cc | 65 |
1 files changed, 25 insertions, 40 deletions
diff --git a/src/CGAL_Nef_polyhedron.cc b/src/CGAL_Nef_polyhedron.cc index 09368da..0c8c627 100644 --- a/src/CGAL_Nef_polyhedron.cc +++ b/src/CGAL_Nef_polyhedron.cc @@ -5,49 +5,38 @@ CGAL_Nef_polyhedron& CGAL_Nef_polyhedron::operator+=(const CGAL_Nef_polyhedron &other) { - if (other.dim == 2) { - (*this->p2) += (*other.p2); - this->dim = 2; - } - if (other.dim == 3) { - (*this->p3) += (*other.p3); - this->dim = 3; - } + if (this->dim == 2) (*this->p2) += (*other.p2); + else if (this->dim == 3) (*this->p3) += (*other.p3); return *this; } CGAL_Nef_polyhedron& CGAL_Nef_polyhedron::operator*=(const CGAL_Nef_polyhedron &other) { - if (other.dim == 2) { - (*this->p2) *= (*other.p2); - this->dim = 2; - } - if (other.dim == 3) { - (*this->p3) *= (*other.p3); - this->dim = 3; - } + if (this->dim == 2) (*this->p2) *= (*other.p2); + else if (this->dim == 3) (*this->p3) *= (*other.p3); return *this; } CGAL_Nef_polyhedron& CGAL_Nef_polyhedron::operator-=(const CGAL_Nef_polyhedron &other) { - if (other.dim == 2) { - (*this->p2) -= (*other.p2); - this->dim = 2; - } - if (other.dim == 3) { - (*this->p3) -= (*other.p3); - this->dim = 3; - } + if (this->dim == 2) (*this->p2) -= (*other.p2); + else if (this->dim == 3) (*this->p3) -= (*other.p3); + return *this; +} + +extern CGAL_Nef_polyhedron2 minkowski2(const CGAL_Nef_polyhedron2 &a, const CGAL_Nef_polyhedron2 &b); + +CGAL_Nef_polyhedron &CGAL_Nef_polyhedron::minkowski(const CGAL_Nef_polyhedron &other) +{ + if (this->dim == 2) (*this->p2) = minkowski2(*this->p2, *other.p2); + else if (this->dim == 3) (*this->p3) = CGAL::minkowski_sum_3(*this->p3, *other.p3); return *this; } int CGAL_Nef_polyhedron::weight() const { - if (dim == 2) - return p2->explorer().number_of_vertices(); - if (dim == 3) - return p3->number_of_vertices(); + if (this->dim == 2) return this->p2->explorer().number_of_vertices(); + if (this->dim == 3) return this->p3->number_of_vertices(); return 0; } @@ -95,17 +84,13 @@ PolySet *CGAL_Nef_polyhedron::convertToPolyset() return ps; } -extern CGAL_Nef_polyhedron2 minkowski2(const CGAL_Nef_polyhedron2 &a, const CGAL_Nef_polyhedron2 &b); - -CGAL_Nef_polyhedron &CGAL_Nef_polyhedron::minkowski(const CGAL_Nef_polyhedron &other) +/*! + Deep copy +*/ +CGAL_Nef_polyhedron CGAL_Nef_polyhedron::copy() const { - if (other.dim == 2) { - (*this->p2) = minkowski2(*this->p2, *other.p2); - this->dim = 2; - } - if (other.dim == 3) { - (*this->p3) = CGAL::minkowski_sum_3(*this->p3, *other.p3); - this->dim = 3; - } - return *this; + CGAL_Nef_polyhedron copy = *this; + if (copy.p2) copy.p2 = new CGAL_Nef_polyhedron2(*copy.p2); + else if (copy.p3) copy.p3 = new CGAL_Nef_polyhedron3(*copy.p3); + return copy; } |