00001 // Magic Software, Inc. 00002 // http://www.magic-software.com 00003 // Copyright (c) 2000-2003. All Rights Reserved 00004 // 00005 // Source code from Magic Software is supplied under the terms of a license 00006 // agreement and may not be copied or disclosed except in accordance with the 00007 // terms of that agreement. The various license agreements may be found at 00008 // the Magic Software web site. This file is subject to the license 00009 // 00010 // FREE SOURCE CODE 00011 // http://www.magic-software.com/License/free.pdf 00012 00013 #ifndef MGCINTR3DTETRTETR_H 00014 #define MGCINTR3DTETRTETR_H 00015 00016 #include "MgcTetrahedron.h" 00017 #include <vector> 00018 00019 namespace Mgc { 00020 00024 class TetrahedronConsumer { 00025 public: 00026 virtual ~TetrahedronConsumer(); 00027 00029 virtual void Add(const Tetrahedron& tet) =0; 00030 }; 00031 00032 00036 class TetrahedronVolumeConsumer : public TetrahedronConsumer { 00037 double volume; 00041 double tetVolume(const Vector3 &A,const Vector3 &B, 00042 const Vector3 &C,const Vector3 &D) 00043 { 00044 const static double oneSixth=1.0/6.0; 00045 return oneSixth*(B-A).Dot((D-A).Cross(C-A)); 00046 } 00047 public: 00048 TetrahedronVolumeConsumer() :volume(0.0) {} 00049 void Add(const Tetrahedron &kT2) { 00050 volume += fabs(tetVolume(kT2[0],kT2[1],kT2[2],kT2[3])); 00051 } 00052 operator double () {return volume;} 00053 }; 00054 00055 00056 MAGICFM void FindIntersection (const Tetrahedron& rkT0, 00057 const Tetrahedron& rkT1, TetrahedronConsumer &dest); 00058 00059 } // namespace Mgc 00060 00061 #endif 00062 00063 00064