contrib/gel/vsol/vsol_curve_3d.cxx
Go to the documentation of this file.
00001 #include "vsol_curve_3d.h"
00002 #include "vsol_point_3d.h"
00003 
00004 //------------------------------------------------------------------------
00005 // Helper function to determine if curve endpoints are equal (in any order).
00006 // Useful for curve equality tests.
00007 //
00008 bool vsol_curve_3d::endpoints_equal(const vsol_curve_3d &other) const
00009 {
00010   vsol_point_3d_sptr p01 = this->p0(), p11 = this->p1();
00011   vsol_point_3d_sptr p02 = other.p0(), p12 = other.p1();
00012   bool c1_has_endpoints = p01&&p11;
00013   bool c2_has_endpoints = p02&&p12;
00014   if ((c1_has_endpoints&&!c2_has_endpoints)
00015      ||(!c1_has_endpoints&&c2_has_endpoints))
00016     return false;
00017   else if (c1_has_endpoints&&c2_has_endpoints)
00018     return *p01 ==*p02 && *p11==*p12;
00019   else if (!p01&&!p11&&!p02&&!p12) // no endpoints at all
00020     return true;
00021   else if (p01&&!p11&&p02&&!p12)
00022     return *p01==*p02;
00023   else if (p01&&!p11&&!p02&&p12)
00024     return *p01==*p12;
00025   else if (!p01&&p11&&p02&&!p12)
00026     return *p11==*p02;
00027   else if (!p01&&p11&&!p02&&p12)
00028     return *p11==*p12;
00029   else
00030     return false;
00031 }