DGtal 1.3.0
Loading...
Searching...
No Matches
Functions
testBoundedLatticePolytopeCounter.cpp File Reference
#include <iostream>
#include <vector>
#include <algorithm>
#include "DGtal/base/Common.h"
#include "DGtal/kernel/SpaceND.h"
#include "DGtal/geometry/volumes/BoundedLatticePolytope.h"
#include "DGtal/geometry/volumes/BoundedLatticePolytopeCounter.h"
#include "DGtalCatch.h"

Go to the source code of this file.

Functions

 SCENARIO ("BoundedLatticePolytopeCounter< Z2 > unit tests", "[lattice_polytope][2d]")
 
 SCENARIO ("BoundedLatticePolytope< Z3 > unit tests", "[lattice_polytope][3d]")
 

Detailed Description

This program is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.

Author
Jacques-Olivier Lachaud (jacqu.nosp@m.es-o.nosp@m.livie.nosp@m.r.la.nosp@m.chaud.nosp@m.@uni.nosp@m.v-sav.nosp@m.oie..nosp@m.fr ) Laboratory of Mathematics (CNRS, UMR 5127), University of Savoie, France
Date
2019/01/04

Functions for testing class BoundedLatticePolytopeCounter.

This file is part of the DGtal library.

Definition in file testBoundedLatticePolytopeCounter.cpp.

Function Documentation

◆ SCENARIO() [1/2]

SCENARIO ( "BoundedLatticePolytope< Z3 > unit tests"  ,
""  [lattice_polytope][3d] 
)

Definition at line 85 of file testBoundedLatticePolytopeCounter.cpp.

86{
87 typedef SpaceND<3,int> Space;
88 typedef Space::Point Point;
89 typedef BoundedLatticePolytope< Space > Polytope;
91
92 GIVEN( "A closed arbitrary simplex P at (0,0,0), (6,3,0), (0,5,-10), (-6,4,8)" ) {
93 Point a( 0, 0, 0 );
94 Point b( 6, 3, 0 );
95 Point c( 0, 5, -10 );
96 Point d( -6, 4, 8 );
97 Polytope P { a, b, c, d };
98 int nbInside = P.count();
99 int nbInterior = P.countInterior();
100 Counter C( P );
101 int nb0 = C.countAlongAxis( 0 );
102 int nb1 = C.countAlongAxis( 1 );
103 int nb2 = C.countAlongAxis( 2 );
104 int nb0_int = C.countInteriorAlongAxis( 0 );
105 int nb1_int = C.countInteriorAlongAxis( 1 );
106 int nb2_int = C.countInteriorAlongAxis( 2 );
107 // std::cout << P << std::endl;
108 THEN( "Its longest axis is 2" )
109 {
110 REQUIRE( C.longestAxis() == 2 );
111 }
112 THEN( "We can count its points per point or per axis" )
113 {
114 REQUIRE( nbInside == nb0 );
115 REQUIRE( nbInside == nb1 );
116 REQUIRE( nbInside == nb2 );
117 }
118 THEN( "We can count its interior points per point or per axis" )
119 {
120 REQUIRE( nbInterior == nb0_int );
121 REQUIRE( nbInterior == nb1_int );
122 REQUIRE( nbInterior == nb2_int );
123 }
124 }
125}
Aim: Useful to compute quickly the lattice points within a polytope, i.e. a convex polyhedron.
Aim: Represents an nD lattice polytope, i.e. a convex polyhedron bounded with vertices with integer c...
MyPointD Point
Definition: testClone2.cpp:383
GIVEN("A cubical complex with random 3-cells")
REQUIRE(domain.isInside(aPoint))

References GIVEN(), and REQUIRE().

◆ SCENARIO() [2/2]

SCENARIO ( "BoundedLatticePolytopeCounter< Z2 > unit tests"  ,
""  [lattice_polytope][2d] 
)

Definition at line 49 of file testBoundedLatticePolytopeCounter.cpp.

50{
51 typedef SpaceND<2,int> Space;
52 typedef Space::Point Point;
53 typedef BoundedLatticePolytope< Space > Polytope;
55
56 GIVEN( "A triangle P at (0,3), (5,0), (15,7)" ) {
57 Point a( 0, 3 );
58 Point b( 8, 0 );
59 Point c( 15, 7 );
60 Polytope P { a, b, c };
61 int nbInside = P.count();
62 int nbInterior = P.countInterior();
63 Counter C( P );
64 int nb0 = C.countAlongAxis( 0 );
65 int nb1 = C.countAlongAxis( 1 );
66 int nb0_int = C.countInteriorAlongAxis( 0 );
67 int nb1_int = C.countInteriorAlongAxis( 1 );
68 THEN( "Its longest axis is 0" )
69 {
70 REQUIRE( C.longestAxis() == 0 );
71 }
72 THEN( "We can count its points per point or per axis" )
73 {
74 REQUIRE( nbInside == nb0 );
75 REQUIRE( nbInside == nb1 );
76 }
77 THEN( "We can count its interior points per point or per axis" )
78 {
79 REQUIRE( nbInterior == nb0_int );
80 REQUIRE( nbInterior == nb1_int );
81 }
82 }
83}

References GIVEN(), and REQUIRE().