154 GIVEN(
"A twisted simplex P at (0,0,0), (1,0,0), (0,1,0), (1,1,z)" ) {
159 Polytope P { a, b, c, d };
160 THEN(
"Its domain contains its vertices" ) {
161 REQUIRE( P.isDomainPointInside( a ) );
162 REQUIRE( P.isDomainPointInside( b ) );
163 REQUIRE( P.isDomainPointInside( c ) );
164 REQUIRE( P.isDomainPointInside( d ) );
166 THEN(
"Its vertices lie on its boundary" ) {
171 REQUIRE( ! P.isInterior( a ) );
172 REQUIRE( ! P.isInterior( b ) );
173 REQUIRE( ! P.isInterior( c ) );
174 REQUIRE( ! P.isInterior( d ) );
176 THEN(
"It satisfies #In(P) <= #Int(P) + #Bd(P)" ) {
178 auto nb_int = P.countInterior();
179 auto nb_bd = P.countBoundary();
183 REQUIRE( nb <= nb_int + nb_bd );
185 THEN(
"It contains only 4 integer points" ) {
191 GIVEN(
"A closed arbitrary simplex P at (0,0,0), (6,3,0), (0,5,10), (6,4,8)" ) {
196 Polytope P { a, b, c, d };
198 THEN(
"It satisfies #In(P) == #Int(P) + #Bd(P)" ) {
200 auto nb_int = P.countInterior();
201 auto nb_bd = P.countBoundary();
205 REQUIRE( nb == nb_int + nb_bd );
207 THEN(
"Its boundary points and interior points are its inside points (closed polytope)" ) {
208 std::vector<Point> inside;
209 std::vector<Point> interior;
210 std::vector<Point> boundary;
211 std::vector<Point> all;
212 P.getPoints( inside );
213 P.getInteriorPoints( interior );
214 P.getBoundaryPoints( boundary );
215 std::sort( inside.begin(), inside.end() );
216 std::sort( interior.begin(), interior.end() );
217 std::sort( boundary.begin(), boundary.end() );
221 std::set_union( interior.cbegin(), interior.cend(), boundary.cbegin(), boundary.cend(),
222 std::back_inserter( all ) );
223 REQUIRE( std::equal( inside.cbegin(), inside.cend(), all.cbegin() ) );
225 WHEN(
"Cut by some axis aligned half-space (1,0,0).x <= 3" ) {
228 THEN(
"It contains less points" ) {
233 auto Pnb = P.count();
234 auto Pnb_int = P.countInterior();
235 auto Pnb_bd = P.countBoundary();
239 auto Qnb = Q.count();
240 auto Qnb_int = Q.countInterior();
241 auto Qnb_bd = Q.countBoundary();
245 std::vector<Point> Qpts;
248 REQUIRE( Q.count() < P.count() );
252 GIVEN(
"A closed triangle P at (0,0,0), (6,3,0), (2,5,10)" ) {
256 Polytope P { a, b, c };
257 THEN(
"Its interior is empty #Int(P) == 0" ) {
258 auto nb_int = P.countInterior();
261 THEN(
"It satisfies #In(P) == #Int(P) + #Bd(P)" ) {
263 auto nb_int = P.countInterior();
264 auto nb_bd = P.countBoundary();
268 std::vector<Point> Ppts;
271 REQUIRE( nb == nb_int + nb_bd );
274 GIVEN(
"A closed triangle P with relatively prime coordinates (3,0,0), (0,4,0), (0,0,5)" ) {
278 Polytope P { a, b, c };
279 THEN(
"Its interior is empty #Int(P) == 0" ) {
280 auto nb_int = P.countInterior();
283 THEN(
"It satisfies #In(P) == #Int(P) + #Bd(P) == #Bd(P) == 3" ) {
285 auto nb_int = P.countInterior();
286 auto nb_bd = P.countBoundary();
290 std::vector<Point> Ppts;
294 REQUIRE( nb == nb_int + nb_bd );
297 GIVEN(
"A closed segment S at (0,0,0), (8,-4,2)" ) {
301 THEN(
"Its interior is empty #Int(P) == 0" ) {
302 auto nb_int = P.countInterior();
305 THEN(
"It satisfies #In(P) == #Int(P) + #Bd(P) == #Bd(P) == 3" ) {
307 auto nb_int = P.countInterior();
308 auto nb_bd = P.countBoundary();
312 std::vector<Point> Ppts;
316 REQUIRE( nb == nb_int + nb_bd );