1 /* C_Polyhedron class declaration.
2    Copyright (C) 2001-2010 Roberto Bagnara <bagnara@cs.unipr.it>
3    Copyright (C) 2010-2016 BUGSENG srl (http://bugseng.com)
4 
5 This file is part of the Parma Polyhedra Library (PPL).
6 
7 The PPL is free software; you can redistribute it and/or modify it
8 under the terms of the GNU General Public License as published by the
9 Free Software Foundation; either version 3 of the License, or (at your
10 option) any later version.
11 
12 The PPL is distributed in the hope that it will be useful, but WITHOUT
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
15 for more details.
16 
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software Foundation,
19 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1307, USA.
20 
21 For the most up-to-date information see the Parma Polyhedra Library
22 site: http://bugseng.com/products/ppl/ . */
23 
24 #ifndef PPL_C_Polyhedron_defs_hh
25 #define PPL_C_Polyhedron_defs_hh 1
26 
27 #include "C_Polyhedron_types.hh"
28 #include "NNC_Polyhedron_types.hh"
29 #include "Polyhedron_defs.hh"
30 #include "Grid_types.hh"
31 #include "BD_Shape_types.hh"
32 #include "Octagonal_Shape_types.hh"
33 
34 //! A closed convex polyhedron.
35 /*! \ingroup PPL_CXX_interface
36     An object of the class C_Polyhedron represents a
37     <EM>topologically closed</EM> convex polyhedron
38     in the vector space \f$\Rset^n\f$.
39 
40     When building a closed polyhedron starting from
41     a system of constraints, an exception is thrown if the system
42     contains a <EM>strict inequality</EM> constraint.
43     Similarly, an exception is thrown when building a closed polyhedron
44     starting from a system of generators containing a <EM>closure point</EM>.
45 
46     \note
47     Such an exception will be obtained even if the system of
48     constraints (resp., generators) actually defines
49     a topologically closed subset of the vector space, i.e.,
50     even if all the strict inequalities (resp., closure points)
51     in the system happen to be redundant with respect to the
52     system obtained by removing all the strict inequality constraints
53     (resp., all the closure points).
54     In contrast, when building a closed polyhedron starting from
55     an object of the class NNC_Polyhedron,
56     the precise topological closure test will be performed.
57 */
58 
59 class Parma_Polyhedra_Library::C_Polyhedron : public Polyhedron {
60 public:
61   //! Builds either the universe or the empty C polyhedron.
62   /*!
63     \param num_dimensions
64     The number of dimensions of the vector space enclosing the C polyhedron;
65 
66     \param kind
67     Specifies whether a universe or an empty C polyhedron should be built.
68 
69     \exception std::length_error
70     Thrown if \p num_dimensions exceeds the maximum allowed space dimension.
71 
72     Both parameters are optional:
73     by default, a 0-dimension space universe C polyhedron is built.
74   */
75   explicit C_Polyhedron(dimension_type num_dimensions = 0,
76                         Degenerate_Element kind = UNIVERSE);
77 
78   //! Builds a C polyhedron from a system of constraints.
79   /*!
80     The polyhedron inherits the space dimension of the constraint system.
81 
82     \param cs
83     The system of constraints defining the polyhedron.
84 
85     \exception std::invalid_argument
86     Thrown if the system of constraints contains strict inequalities.
87   */
88   explicit C_Polyhedron(const Constraint_System& cs);
89 
90   //! Builds a C polyhedron recycling a system of constraints.
91   /*!
92     The polyhedron inherits the space dimension of the constraint system.
93 
94     \param cs
95     The system of constraints defining the polyhedron.  It is not
96     declared <CODE>const</CODE> because its data-structures may be
97     recycled to build the polyhedron.
98 
99     \param dummy
100     A dummy tag to syntactically differentiate this one
101     from the other constructors.
102 
103     \exception std::invalid_argument
104     Thrown if the system of constraints contains strict inequalities.
105   */
106   C_Polyhedron(Constraint_System& cs, Recycle_Input dummy);
107 
108   //! Builds a C polyhedron from a system of generators.
109   /*!
110     The polyhedron inherits the space dimension of the generator system.
111 
112     \param gs
113     The system of generators defining the polyhedron.
114 
115     \exception std::invalid_argument
116     Thrown if the system of generators is not empty but has no points,
117     or if it contains closure points.
118   */
119   explicit C_Polyhedron(const Generator_System& gs);
120 
121   //! Builds a C polyhedron recycling a system of generators.
122   /*!
123     The polyhedron inherits the space dimension of the generator system.
124 
125     \param gs
126     The system of generators defining the polyhedron.  It is not
127     declared <CODE>const</CODE> because its data-structures may be
128     recycled to build the polyhedron.
129 
130     \param dummy
131     A dummy tag to syntactically differentiate this one
132     from the other constructors.
133 
134     \exception std::invalid_argument
135     Thrown if the system of generators is not empty but has no points,
136     or if it contains closure points.
137   */
138   C_Polyhedron(Generator_System& gs, Recycle_Input dummy);
139 
140   //! Builds a C polyhedron from a system of congruences.
141   /*!
142     The polyhedron inherits the space dimension of the congruence system.
143 
144     \param cgs
145     The system of congruences defining the polyhedron.
146   */
147   explicit C_Polyhedron(const Congruence_System& cgs);
148 
149   //! Builds a C polyhedron recycling a system of congruences.
150   /*!
151     The polyhedron inherits the space dimension of the congruence
152     system.
153 
154     \param cgs
155     The system of congruences defining the polyhedron.  It is not
156     declared <CODE>const</CODE> because its data-structures may be
157     recycled to build the polyhedron.
158 
159     \param dummy
160     A dummy tag to syntactically differentiate this one
161     from the other constructors.
162   */
163   C_Polyhedron(Congruence_System& cgs, Recycle_Input dummy);
164 
165   /*! \brief
166     Builds a C polyhedron representing the topological closure
167     of the NNC polyhedron \p y.
168 
169     \param y
170     The NNC polyhedron to be used;
171 
172     \param complexity
173     This argument is ignored.
174   */
175   explicit C_Polyhedron(const NNC_Polyhedron& y,
176                         Complexity_Class complexity = ANY_COMPLEXITY);
177 
178   //! Builds a C polyhedron out of a box.
179   /*!
180     The polyhedron inherits the space dimension of the box
181     and is the most precise that includes the box.
182     The algorithm used has polynomial complexity.
183 
184     \param box
185     The box representing the polyhedron to be approximated;
186 
187     \param complexity
188     This argument is ignored.
189 
190     \exception std::length_error
191     Thrown if the space dimension of \p box exceeds the maximum allowed
192     space dimension.
193   */
194   template <typename Interval>
195   explicit C_Polyhedron(const Box<Interval>& box,
196                         Complexity_Class complexity = ANY_COMPLEXITY);
197 
198   //! Builds a C polyhedron out of a BD shape.
199   /*!
200     The polyhedron inherits the space dimension of the BDS and is
201     the most precise that includes the BDS.
202 
203     \param bd
204     The BDS used to build the polyhedron.
205 
206     \param complexity
207     This argument is ignored as the algorithm used has
208     polynomial complexity.
209   */
210   template <typename U>
211   explicit C_Polyhedron(const BD_Shape<U>& bd,
212                         Complexity_Class complexity = ANY_COMPLEXITY);
213 
214   //! Builds a C polyhedron out of an octagonal shape.
215   /*!
216     The polyhedron inherits the space dimension of the octagonal shape
217     and is the most precise that includes the octagonal shape.
218 
219     \param os
220     The octagonal shape used to build the polyhedron.
221 
222     \param complexity
223     This argument is ignored as the algorithm used has
224     polynomial complexity.
225   */
226   template <typename U>
227   explicit C_Polyhedron(const Octagonal_Shape<U>& os,
228                         Complexity_Class complexity = ANY_COMPLEXITY);
229 
230   //! Builds a C polyhedron out of a grid.
231   /*!
232     The polyhedron inherits the space dimension of the grid
233     and is the most precise that includes the grid.
234 
235     \param grid
236     The grid used to build the polyhedron.
237 
238     \param complexity
239     This argument is ignored as the algorithm used has
240     polynomial complexity.
241   */
242   explicit C_Polyhedron(const Grid& grid,
243                         Complexity_Class complexity = ANY_COMPLEXITY);
244 
245   //! Ordinary copy constructor.
246   /*!
247     The complexity argument is ignored.
248   */
249   C_Polyhedron(const C_Polyhedron& y,
250                Complexity_Class complexity = ANY_COMPLEXITY);
251 
252   /*! \brief
253     The assignment operator.
254     (\p *this and \p y can be dimension-incompatible.)
255   */
256   C_Polyhedron& operator=(const C_Polyhedron& y);
257 
258   //! Assigns to \p *this the topological closure of the NNC polyhedron \p y.
259   C_Polyhedron& operator=(const NNC_Polyhedron& y);
260 
261   //! Destructor.
262   ~C_Polyhedron();
263 
264   /*! \brief
265     If the poly-hull of \p *this and \p y is exact it is assigned
266     to \p *this and <CODE>true</CODE> is returned,
267     otherwise <CODE>false</CODE> is returned.
268 
269     \exception std::invalid_argument
270     Thrown if \p *this and \p y are dimension-incompatible.
271   */
272   bool poly_hull_assign_if_exact(const C_Polyhedron& y);
273 
274   //! Same as poly_hull_assign_if_exact(y).
275   bool upper_bound_assign_if_exact(const C_Polyhedron& y);
276 
277   /*! \brief
278     Assigns to \p *this the smallest C polyhedron containing the
279     result of computing the
280     \ref Positive_Time_Elapse_Operator "positive time-elapse"
281     between \p *this and \p y.
282 
283     \exception std::invalid_argument
284     Thrown if \p *this and \p y are dimension-incompatible.
285   */
286   void positive_time_elapse_assign(const Polyhedron& y);
287 };
288 
289 #include "C_Polyhedron_inlines.hh"
290 
291 #endif // !defined(PPL_C_Polyhedron_defs_hh)
292