00001 #include "Hexahedron_3.h"
00002
00003 #include <CGAL/predicates_on_points_3.h>
00004
00005
00006
00013 Hexahedron_3::Hexahedron_3( CGAL::Point_3<R> vertices[8] )
00014 {
00015 for( int i = 0; i < 8; ++i )
00016 vert[i] = vertices[i];
00017
00018 verify();
00019 }
00020
00021
00022 Hexahedron_3::Hexahedron_3( CGAL::Point_3<R> v0,
00023 CGAL::Point_3<R> v1,
00024 CGAL::Point_3<R> v2,
00025 CGAL::Point_3<R> v3,
00026 CGAL::Point_3<R> v4,
00027 CGAL::Point_3<R> v5,
00028 CGAL::Point_3<R> v6,
00029 CGAL::Point_3<R> v7 )
00030 {
00031 vert[0] = v0;
00032 vert[1] = v1;
00033 vert[2] = v2;
00034 vert[3] = v3;
00035 vert[4] = v4;
00036 vert[5] = v5;
00037 vert[6] = v6;
00038 vert[7] = v7;
00039
00040 verify();
00041 }
00042
00043
00044 typedef Hexahedron_3::R R;
00045
00046
00047 CGAL::Plane_3<R>
00048 Hexahedron_3::plane_0164() const
00049 {
00050 return CGAL::Plane_3<R>( vert[0],vert[1],vert[6] );
00051 }
00052
00053 CGAL::Plane_3<R>
00054 Hexahedron_3::plane_1276() const
00055 {
00056 return CGAL::Plane_3<R>( vert[1],vert[2],vert[7] );
00057 }
00058
00059
00060 CGAL::Plane_3<R>
00061 Hexahedron_3::plane_2357() const
00062 {
00063 return CGAL::Plane_3<R>( vert[2],vert[3],vert[5] );
00064 }
00065
00066
00067 CGAL::Plane_3<R>
00068 Hexahedron_3::plane_0453() const
00069 {
00070 return CGAL::Plane_3<R>( vert[0],vert[4],vert[5] );
00071 }
00072
00073
00074 CGAL::Plane_3<R>
00075 Hexahedron_3::plane_4675() const
00076 {
00077 return CGAL::Plane_3<R>( vert[4],vert[6],vert[7] );
00078 }
00079
00080
00081 CGAL::Plane_3<R>
00082 Hexahedron_3::plane_0321() const
00083 {
00084 return CGAL::Plane_3<R>( vert[0],vert[3],vert[2] );
00085 }
00086
00087
00090 CGAL::Plane_3<R>
00091 Hexahedron_3::plane(int i) const
00092 {
00093 CGAL_assertion( 0 <= i );
00094 CGAL_assertion( i < 6 );
00095
00096 switch(i) {
00097 case 0: return plane_0164();
00098 case 1: return plane_1276();
00099 case 2: return plane_2357();
00100 case 3: return plane_0453();
00101 case 4: return plane_4675();
00102 case 5: return plane_0321();
00103 }
00104
00105 return plane_0321();
00106 }
00107
00108
00109
00110
00111
00112
00113
00117 void
00118 Hexahedron_3::verify_facet(int i, int j, int k, int l)
00119 {
00120 CGAL_exactness_assertion
00121 ( CGAL::NEGATIVE == CGAL::coplanar_orientation(vert[i],
00122 vert[k],
00123 vert[j],
00124 vert[l]) );
00125 CGAL_exactness_assertion
00126 ( CGAL::NEGATIVE == CGAL::coplanar_orientation(vert[j],
00127 vert[l],
00128 vert[i],
00129 vert[k]) );
00130 }
00131
00132
00133 void
00134 Hexahedron_3::verify()
00135 {
00136 verify_facet(0,1,6,4);
00137 verify_facet(1,2,7,6);
00138 verify_facet(2,3,5,7);
00139 verify_facet(0,4,5,3);
00140 verify_facet(4,6,7,5);
00141 verify_facet(0,3,2,1);
00142
00143 CGAL_exactness_assertion
00144 ( CGAL::NEGATIVE == CGAL::orientation(vert[0],
00145 vert[1],
00146 vert[6],
00147 vert[2]) );
00148 }
00149