00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 # ifndef shape_cell3d_factory_hpp
00014 # define shape_cell3d_factory_hpp
00015
00016 # include <shape/algebraic_curve.hpp>
00017 # include <shape/algebraic_surface.hpp>
00018 # include <shape/bcell.hpp>
00019 # include <shape/bcell3d_algebraic_curve.hpp>
00020 # include <shape/bcell3d_algebraic_surface.hpp>
00021 # include <shape/bcell3d_list.hpp>
00022 # include <algorithm>
00023
00024 # define TMPL template<class C,class V>
00025 # define TMPL1 template<class V>
00026 # define Viewer viewer<axel,V>
00027
00028 # undef AlgebraicCurve
00029
00030 namespace mmx {
00031 namespace shape {
00032
00033 # define Cell3dFactory bcell3d_factory<C,V>
00034
00035 TMPL
00036 class bcell3d_factory {
00037 public:
00038 typedef typename SHAPE_OF(V) Shape;
00039 typedef REF_OF(V) Ref;
00040 typedef bounding_box<C,Ref> BoundingBox;
00041 typedef bcell3d<C,Ref> Cell;
00042 typedef algebraic_curve<C,Ref> AlgebraicCurve;
00043 typedef algebraic_surface<C,Ref> AlgebraicSurface;
00044
00045 typedef bcell3d_algebraic_surface<C,Ref> Cell3dAlgebraicSurface;
00046
00047 typedef bcell3d_list<C,Ref> Cell3dList;
00048
00049
00050 static Cell3dFactory * instance(void) {
00051 if(!m_instance)
00052 m_instance = new Cell3dFactory ;
00053
00054 return m_instance ;
00055 }
00056
00057 Cell * create(Shape * s,const BoundingBox& bx) {
00058 Cell * bcell = NULL ;
00059
00060 if(AlgebraicSurface* isurface = dynamic_cast<AlgebraicSurface *>(s)) {
00061 bcell = new Cell3dAlgebraicSurface(*isurface,bx);
00062 }
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072 return bcell ;
00073 }
00074
00075 Cell * create(const Seq<Shape*>& s, const BoundingBox& bx) {
00076 Cell * bcell = NULL ;
00077
00078 if(s.size()==1)
00079 return create(s[0],bx);
00080 else if(s.size()>1) {
00081 Cell3dList* l= new Cell3dList(bx);
00082 foreach(Shape* o, s)
00083 l->push_back(create(o,bx)) ;
00084 bcell = l;
00085 }
00086
00087 return bcell;
00088 }
00089
00090
00091 private:
00092 Cell3dFactory(void) {} ;
00093
00094 private:
00095 static Cell3dFactory * m_instance;
00096 } ;
00097
00098 TMPL Cell3dFactory* Cell3dFactory::m_instance = NULL;
00099
00100
00101
00102 } ;
00103 } ;
00104
00105 # undef TMPL
00106 # undef TMPL1
00107 # undef Viewer
00108 # endif
00109