00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #ifndef _COMPLEX_H_
00028 #define _COMPLEX_H_
00029
00030 #include <algorithm>
00031
00032 #include "Shape.h"
00033 #include "VertexBase.h"
00034
00035 class BBoxNode;
00036 class BBoxLeaf;
00037
00038 class Polytope;
00039 class Convex;
00040 class Transform;
00041 class BBox;
00042
00043 class Complex : public Shape {
00044 public:
00045 Complex() {}
00046 ~Complex();
00047
00048 ShapeType getType() const { return COMPLEX; }
00049 BBox bbox(const Transform& t) const;
00050
00051 const VertexBase& getBase() const { return base; }
00052 void setBase(const void *ptr, bool free = false) {
00053 base = ptr; free_base = free;
00054 }
00055 void changeBase(const void *ptr);
00056 void proceed() { prev_base = base; }
00057 void swapBase() { swap(base, prev_base); }
00058
00059 void finish(int n, const Polytope **p);
00060
00061 friend bool intersect(const Complex& a, const Convex& b,
00062 const Transform& a2w, const Transform& b2w,
00063 Vector& v);
00064
00065 friend bool intersect(const Complex& a, const Complex& b,
00066 const Transform& a2w, const Transform& b2w,
00067 Vector& v);
00068
00069 friend bool find_prim(const Complex& a, const Convex& b,
00070 const Transform& a2w, const Transform& b2w,
00071 Vector& v, ShapePtr& p);
00072
00073 friend bool find_prim(const Complex& a, const Complex& b,
00074 const Transform& a2w, const Transform& b2w,
00075 Vector& v, ShapePtr& pa, ShapePtr& pb);
00076
00077 friend bool common_point(const Complex& a, const Convex& b,
00078 const Transform& a2w, const Transform& b2w,
00079 Vector& v, Point& pa, Point& pb);
00080
00081 friend bool common_point(const Complex& a, const Complex& b,
00082 const Transform& a2w, const Transform& b2w,
00083 Vector& v, Point& pa, Point& pb);
00084
00085 private:
00086 VertexBase base;
00087 VertexBase prev_base;
00088 bool free_base;
00089 BBoxLeaf *leaves;
00090 BBoxNode *root;
00091 int count;
00092 };
00093
00094 #endif