1 // { dg-do compile { target powerpc*-*-* ia64-*-* i?86-*-* x86_64-*-* } }
2 // { dg-options "-O3 -fselective-scheduling2" }
3 // { dg-additional-options "-Wno-return-type" }
4 
5 namespace std {
6 
7 typedef long unsigned int size_t;
8 
9 template<typename _Tp> class new_allocator { public: typedef size_t size_type; typedef _Tp* pointer; };
10 template<typename _Tp> class allocator: public new_allocator<_Tp> { public: typedef size_t size_type; template<typename _Tp1> struct rebind { typedef allocator<_Tp1> other; }; };
11 
12 class back_insert_iterator { };
back_inserter(_Container & __x)13 template<typename _Container> back_insert_iterator back_inserter(_Container& __x) { return back_insert_iterator(); };
14 
15 class vector { };
16 
17 struct _List_node_base { };
18 struct _List_node : public _List_node_base { };
_List_iterator_List_iterator19 template<typename _Tp> struct _List_iterator { typedef _List_iterator<_Tp> _Self; typedef _Tp& reference; explicit _List_iterator(_List_node_base* __x) : _M_node(__x) { } reference operator*() const { } _Self& operator++() { } bool operator!=(const _Self& __x) const { return _M_node != __x._M_node; } _List_node_base* _M_node; };
20 template<typename _Tp, typename _Alloc> class _List_base { protected: typedef typename _Alloc::template rebind<_List_node >::other _Node_alloc_type; struct _List_impl : public _Node_alloc_type { _List_node_base _M_node; }; _List_impl _M_impl; };
end()21 template<typename _Tp, typename _Alloc = std::allocator<_Tp> > class list : protected _List_base<_Tp, _Alloc> { public: typedef _Tp value_type; typedef _List_iterator<_Tp> iterator; iterator begin() { } iterator end() { return iterator(&this->_M_impl._M_node); } };
22 
beginarray23 namespace tr1 { template<typename _Tp, size_t _Nm> struct array { typedef _Tp value_type; typedef const value_type& const_reference; typedef const value_type* const_iterator; typedef size_t size_type; value_type _M_instance[_Nm ? _Nm : 1]; const_iterator begin() const { return const_iterator(&_M_instance[0]); } const_reference operator[](size_type __n) const { return _M_instance[__n]; } }; }
24 }
25 
26 namespace X {
27 
28 class Object { };
29 struct Has_qrt { };
30 template <typename F> struct qrt_or_not { typedef const typename F::result_type & type; };
31 template <typename Functor, typename P1 = void> struct Qualified_result_of : qrt_or_not<Functor> { };
32 
33 using std::tr1::array;
34 
35 template <class R_> class Point_2 : public R_::Kernel_base::Point_2 {
36 public:
37   typedef typename R_::Kernel_base::Point_2 RPoint_2;
38   typedef RPoint_2 Rep;
rep()39   const Rep& rep() const { }
40 };
41 
42 template <class R_> class Vector_2 : public R_::Kernel_base::Vector_2 {
43 public:
44   typedef typename R_::Kernel_base::Vector_2 RVector_2;
45   typedef RVector_2 Rep;
rep()46   const Rep& rep() const { return *this; }
47   typedef R_ R;
x()48   typename Qualified_result_of<typename R::Compute_x_2,Vector_2>::type x() const { return R().compute_x_2_object()(*this); }
y()49   typename Qualified_result_of<typename R::Compute_y_2,Vector_2>::type y() const { return R().compute_y_2_object()(*this); }
cartesian(int i)50   typename Qualified_result_of<typename R::Compute_y_2,Vector_2>::type cartesian(int i) const { return (i==0) ? x() : y(); }
hx()51   typename Qualified_result_of<typename R::Compute_hx_2,Vector_2>::type hx() const { return R().compute_hx_2_object()(*this); }
hy()52   typename Qualified_result_of<typename R::Compute_hy_2,Vector_2>::type hy() const { return R().compute_hy_2_object()(*this); }
hw()53   typename Qualified_result_of<typename R::Compute_hw_2,Vector_2>::type hw() const { return R().compute_hw_2_object()(*this); }
homogeneous(int i)54   typename Qualified_result_of<typename R::Compute_hx_2,Vector_2>::type homogeneous(int i) const { return (i==0) ? hx() : (i==1)? hy() : hw(); }
55 };
56 
57 template <class R_> class Segment_2 : public R_::Kernel_base::Segment_2 { };
58 template <class R_> class Iso_rectangle_2 : public R_::Kernel_base::Iso_rectangle_2 { };
59 
constant()60 template <typename T, int i > const T& constant() { static const T t(i); return t; }
Ptr()61 template <class T, class Alloc = std::allocator<T > > class Handle_for { struct RefCounted { T t; }; typedef typename Alloc::template rebind<RefCounted>::other Allocator; typedef typename Allocator::pointer pointer; pointer ptr_; public: typedef T element_type; const T * Ptr() const { return &(ptr_->t); } };
get(const Handle_for<T,Allocator> & h)62 template <class T, class Allocator> const T& get(const Handle_for<T, Allocator> &h) { return *(h.Ptr()); }
63 
64 template <class R_> class PointC2 {
65 public:
66   typedef typename R_::Vector_2 Vector_2; Vector_2 base;
cartesian_begin()67   typedef typename Vector_2::Cartesian_const_iterator Cartesian_const_iterator; Cartesian_const_iterator cartesian_begin() const { return base.cartesian_begin(); }
68 };
69 
70 template <class R_> class VectorC2 {
71 public:
72   typedef typename R_::FT FT;
73   typedef array<FT, 2> Rep;
74   typedef typename R_::template Handle<Rep>::type Base;
75   Base base;
76   typedef typename Rep::const_iterator Cartesian_const_iterator;
x()77   const FT & x() const { return X::get(base)[0]; }
y()78   const FT & y() const { return X::get(base)[1]; }
hx()79   const FT & hx() const { return x(); }
hy()80   const FT & hy() const { return y(); }
hw()81   const FT & hw() const { return constant<FT, 1>(); }
cartesian_begin()82   Cartesian_const_iterator cartesian_begin() const { return X::get(base).begin(); }
83 };
84 
85 template <class R_> class SegmentC2 { };
86 template <class R_> class Iso_rectangleC2 { };
87 
88 namespace internal {
89   template <class K> class Segment_2_Iso_rectangle_2_pair {
90     public:
91       enum Intersection_results { NO_INTERSECTION };
92       Segment_2_Iso_rectangle_2_pair(typename K::Segment_2 const *seg, typename K::Iso_rectangle_2 const *rect) ;
93       Intersection_results intersection_type() const;
94       mutable Intersection_results _result;
95       typename K::Point_2 _ref_point;
96       typename K::Vector_2 _dir;
97       typename K::Point_2 _isomin;
98       typename K::Point_2 _isomax;
99       mutable typename K::FT _min, _max;
100   };
intersection(const typename K::Segment_2 & seg,const typename K::Iso_rectangle_2 & iso,const K &)101   template <class K> Object intersection( const typename K::Segment_2 &seg, const typename K::Iso_rectangle_2 &iso, const K&) {
102     typedef Segment_2_Iso_rectangle_2_pair<K> is_t; is_t ispair(&seg, &iso); switch (ispair.intersection_type()) { }
103     return Object();
104   }
intersection_type()105   template <class K> typename Segment_2_Iso_rectangle_2_pair<K>::Intersection_results Segment_2_Iso_rectangle_2_pair<K>::intersection_type() const {
106     typedef typename K::RT RT;
107     typedef typename K::FT FT;
108     typename K::Construct_cartesian_const_iterator_2 construct_cccit;
109     typename K::Cartesian_const_iterator_2 ref_point_it = construct_cccit(_ref_point);
110     typename K::Cartesian_const_iterator_2 end = construct_cccit(_ref_point, 0);
111     typename K::Cartesian_const_iterator_2 isomin_it = construct_cccit(_isomin);
112     typename K::Cartesian_const_iterator_2 isomax_it = construct_cccit(_isomax);
113     for (unsigned int i=0; ref_point_it != end; ++i, ++ref_point_it, ++isomin_it, ++isomax_it) {
114       if (_dir.homogeneous(i) == RT(0)) {
115         if ( *(ref_point_it) <*(isomin_it) ) {
116           _result = NO_INTERSECTION;
117         }
118         if ( *(ref_point_it) > *(isomax_it)) {
119           _result = NO_INTERSECTION;
120         }
121       } else {
122         FT newmin, newmax;
123         if (_dir.homogeneous(i) > RT(0)) {
124           newmin = ( *(isomin_it) - (*ref_point_it)) / _dir.cartesian(i);
125           newmax = ( *(isomax_it) - (*ref_point_it)) / _dir.cartesian(i);
126         } else {
127           newmin = ( (*isomax_it) - (*ref_point_it)) / _dir.cartesian(i);
128           newmax = ( (*isomin_it) - (*ref_point_it)) / _dir.cartesian(i);
129         }
130         if (newmin > _min) _min = newmin;
131         if (newmax <_max) _max = newmax;
132         if (_max <_min) { return _result; }
133       }
134     }
135   }
136 }
137 
intersection(const Segment_2<K> & seg,const Iso_rectangle_2<K> & iso)138 template <class K> Object intersection(const Segment_2<K> &seg, const Iso_rectangle_2<K> &iso) { typedef typename K::Intersect_2 Intersect; return Intersect()(seg, iso); }
139 
140 namespace CommonKernelFunctors {
141   template <typename K> class Construct_cartesian_const_iterator_2 {
142     typedef typename K::Point_2 Point_2;
143     typedef typename K::Cartesian_const_iterator_2 Cartesian_const_iterator_2;
144 public:
145     typedef Cartesian_const_iterator_2 result_type;
operator()146     Cartesian_const_iterator_2 operator()( const Point_2& p) const { return p.rep().cartesian_begin(); }
operator()147     Cartesian_const_iterator_2 operator()( const Point_2& p, int) const { }
148   };
149   template <typename K> class Intersect_2 {
150     typedef typename K::Object_2 Object_2;
151   public:
152     typedef Object_2 result_type;
operator()153     template <class T1, class T2> Object_2 operator()(const T1& t1, const T2& t2) const { return internal::intersection(t1, t2, K()); }
154   };
155 }
156 
157 namespace CartesianKernelFunctors {
158   using namespace CommonKernelFunctors;
159   template <typename K> class Compute_x_2 : Has_qrt {
160     typedef typename K::FT FT;
161     typedef typename K::Vector_2 Vector_2;
162   public:
163     typedef FT result_type;
operator()164     const result_type & operator()(const Vector_2& v) const { return v.rep().x(); }
165   };
166   template <typename K> class Compute_y_2 : Has_qrt {
167     typedef typename K::FT FT;
168     typedef typename K::Vector_2 Vector_2;
169   public:
170     typedef FT result_type;
operator()171     const result_type & operator()(const Vector_2& v) const { return v.rep().y(); }
172   };
173   template <typename K> class Compute_hx_2 : public Has_qrt {
174     typedef typename K::FT FT;
175     typedef typename K::Vector_2 Vector_2;
176   public:
177     typedef FT result_type;
operator()178     const result_type & operator()(const Vector_2& v) const { return v.rep().hx(); }
179   };
180   template <typename K> class Compute_hy_2 : public Has_qrt {
181     typedef typename K::FT FT;
182     typedef typename K::Vector_2 Vector_2;
183   public:
184     typedef FT result_type;
operator()185     const result_type & operator()(const Vector_2& v) const { return v.rep().hy(); }
186   };
187   template <typename K> class Compute_hw_2 : public Has_qrt {
188     typedef typename K::FT FT;
189     typedef typename K::Vector_2 Vector_2;
190   public:
191     typedef FT result_type;
operator()192     const result_type & operator()(const Vector_2& v) const { return v.rep().hw(); }
193   };
194 }
195 
196 template <typename K_, typename FT_> struct Cartesian_base {
197   typedef K_ Kernel;
198   typedef X::Object Object_2;
199   typedef PointC2<Kernel> Point_2;
200   typedef VectorC2<Kernel> Vector_2;
201   typedef SegmentC2<Kernel> Segment_2;
202   typedef Iso_rectangleC2<Kernel> Iso_rectangle_2;
203   typedef typename array<FT_, 2>::const_iterator Cartesian_const_iterator_2;
204 };
205 
206 template <typename K_base, typename Kernel_ > struct Type_equality_wrapper : public K_base {
207   typedef K_base Kernel_base;
208   typedef X::Point_2<Kernel_> Point_2;
209   typedef X::Vector_2<Kernel_> Vector_2;
210   typedef X::Segment_2<Kernel_> Segment_2;
211   typedef X::Iso_rectangle_2<Kernel_> Iso_rectangle_2;
212 };
213 
214 template <typename FT_, typename Kernel_ > struct Cartesian_base_ref_count : public Cartesian_base<Kernel_, FT_ > {
215   typedef FT_ RT;
216   typedef FT_ FT;
217   template <typename T > struct Handle { typedef Handle_for<T> type; };
218   typedef Kernel_ K;
219   typedef CartesianKernelFunctors::Compute_x_2<K> Compute_x_2;
compute_x_2_objectCartesian_base_ref_count220   Compute_x_2 compute_x_2_object() const { }
221   typedef CartesianKernelFunctors::Compute_y_2<K> Compute_y_2;
compute_y_2_objectCartesian_base_ref_count222   Compute_y_2 compute_y_2_object() const { }
223   typedef CartesianKernelFunctors::Compute_hx_2<K> Compute_hx_2;
compute_hx_2_objectCartesian_base_ref_count224   Compute_hx_2 compute_hx_2_object() const { }
225   typedef CartesianKernelFunctors::Compute_hy_2<K> Compute_hy_2;
compute_hy_2_objectCartesian_base_ref_count226   Compute_hy_2 compute_hy_2_object() const { }
227   typedef CartesianKernelFunctors::Compute_hw_2<K> Compute_hw_2;
compute_hw_2_objectCartesian_base_ref_count228   Compute_hw_2 compute_hw_2_object() const { }
229   typedef CartesianKernelFunctors::Construct_cartesian_const_iterator_2<K> Construct_cartesian_const_iterator_2;
230   typedef CartesianKernelFunctors::Intersect_2<K> Intersect_2;
231 };
232 
233 template <typename FT_ > struct Cartesian : public Type_equality_wrapper<Cartesian_base_ref_count<FT_, Cartesian<FT_> >, Cartesian<FT_> > { };
234 
235 template <class Kernel> class Ipelet_base {
236 public:
237   typedef typename X::Point_2<Kernel> Point_2;
238   typedef typename Kernel::Segment_2 Segment_2;
239   typedef typename Kernel::Iso_rectangle_2 Iso_rectangle_2;
240 
read_active_objects()241   Iso_rectangle_2 read_active_objects () const { }
242   struct Voronoi_from_tri{ std::list<Segment_2> seg_list; };
243 
cast_into_seg(const T & obj,const Iso_rectangle_2 & bbox,output_iterator out_it)244   template <class T,class output_iterator> bool cast_into_seg(const T& obj,const Iso_rectangle_2& bbox,output_iterator out_it) const{ X::intersection(obj,bbox); }
cast_into_seg(const iterator first,const iterator end,const Iso_rectangle_2 & bbox,output_iterator out_it)245   template<class iterator,class output_iterator> void cast_into_seg(const iterator first,const iterator end, const Iso_rectangle_2& bbox, output_iterator out_it) const { for (iterator it=first; it!=end; ++it) cast_into_seg(*it,bbox,out_it); }
draw_dual_(Voronoi_from_tri & v_recup,const Iso_rectangle_2 & bbox)246   void draw_dual_(Voronoi_from_tri& v_recup,const Iso_rectangle_2& bbox) const { std::vector seg_cont; cast_into_seg(v_recup.seg_list.begin(),v_recup.seg_list.end(),bbox,std::back_inserter(seg_cont)); }
draw_dual_in_ipe(const Iso_rectangle_2 & bbox)247   void draw_dual_in_ipe(const Iso_rectangle_2& bbox) const { Voronoi_from_tri v_recup; draw_dual_(v_recup,bbox); }
248 };
249 
250 typedef X::Cartesian<double> Kernel;
251 
252 class diagrammeIpelet : public X::Ipelet_base<Kernel> { void protected_run(); };
protected_run()253 void diagrammeIpelet::protected_run() { Iso_rectangle_2 bbox = read_active_objects( ); draw_dual_in_ipe(bbox); }
254 
255 }
256