171 GIVEN(
"Given an octahedron star { (0,0,0), (-2,0,0), (2,0,0), (0,-2,0), (0,2,0), (0,0,-2), (0,0,2) } " ) {
173 = {
Point(0,0,0),
Point(-2,0,0),
Point(2,0,0),
Point(0,-2,0),
Point(0,2,0),
175 WHEN(
"Computing its lattice polytope" ){
176 const auto P = Helper::computeLatticePolytope( V,
false,
true );
178 THEN(
"The polytope is valid and has 8 non trivial facets plus 12 edge constraints" ) {
179 REQUIRE( P.nbHalfSpaces() - 6 == 20 );
181 THEN(
"The polytope is Minkowski summable" ) {
184 THEN(
"The polytope contains the input points" ) {
185 REQUIRE( P.isInside( V[ 0 ] ) );
186 REQUIRE( P.isInside( V[ 1 ] ) );
187 REQUIRE( P.isInside( V[ 2 ] ) );
188 REQUIRE( P.isInside( V[ 3 ] ) );
189 REQUIRE( P.isInside( V[ 4 ] ) );
190 REQUIRE( P.isInside( V[ 5 ] ) );
191 REQUIRE( P.isInside( V[ 6 ] ) );
193 THEN(
"The polytope contains 25 points" ) {
196 THEN(
"The interior of the polytope contains 7 points" ) {
197 REQUIRE( P.countInterior() == 7 );
199 THEN(
"The boundary of the polytope contains 18 points" ) {
200 REQUIRE( P.countBoundary() == 18 );
203 WHEN(
"Computing the boundary of its convex hull as a SurfaceMesh" ){
205 bool ok = Helper::computeConvexHullBoundary( smesh, V,
false );
207 THEN(
"The surface mesh is valid and has 6 vertices, 12 edges and 8 faces" ) {
213 THEN(
"The surface mesh has the topology of a sphere" ) {
219 WHEN(
"Computing the boundary of its convex hull as a lattice PolygonalSurface" ){
220 LatticePolySurf lpsurf;
221 bool ok = Helper::computeConvexHullBoundary( lpsurf, V,
false );
223 THEN(
"The polygonal surface is valid and has 6 vertices, 12 edges and 8 faces" ) {
225 REQUIRE( lpsurf.nbVertices() == 6 );
226 REQUIRE( lpsurf.nbEdges() == 12 );
227 REQUIRE( lpsurf.nbFaces() == 8 );
228 REQUIRE( lpsurf.nbArcs() == 24 );
230 THEN(
"The polygonal surface has the topology of a sphere and no boundary" ) {
231 REQUIRE( lpsurf.Euler() == 2 );
232 REQUIRE( lpsurf.allBoundaryArcs().size() == 0 );
233 REQUIRE( lpsurf.allBoundaryVertices().size() == 0 );
236 WHEN(
"Computing its convex hull as a ConvexCellComplex" ){
237 CvxCellComplex complex;
238 bool ok = Helper::computeConvexHullCellComplex( complex, V,
false );
240 THEN(
"The convex cell complex is valid and has 6 vertices, 8 faces and 1 finite cell" ) {
242 REQUIRE( complex.nbVertices() == 6 );
243 REQUIRE( complex.nbFaces() == 8 );
244 REQUIRE( complex.nbCells() == 1 );
248 GIVEN(
"Given a cube with an additional outside vertex " ) {
250 = {
Point(-10,-10,-10),
Point(10,-10,-10),
Point(-10,10,-10),
Point(10,10,-10),
251 Point(-10,-10,10),
Point(10,-10,10),
Point(-10,10,10),
Point(10,10,10),
253 WHEN(
"Computing its Delaunay cell complex" ){
254 CvxCellComplex complex;
255 bool ok = Helper::computeDelaunayCellComplex( complex, V,
false );
257 THEN(
"The complex has 2 cells, 10 faces, 9 vertices" ) {
259 REQUIRE( complex.nbCells() == 2 );
260 REQUIRE( complex.nbFaces() == 10 );
261 REQUIRE( complex.nbVertices() == 9 );
263 THEN(
"The faces of cells are finite" ) {
264 bool ok_finite =
true;
265 for (
auto c = 0; c < complex.nbCells(); ++c ) {
266 const auto faces = complex.cellFaces( c );
267 for (
auto f : faces )
268 ok_finite = ok_finite && ! complex.isInfinite( complex.faceCell( f ) );
272 THEN(
"The opposite of faces of cells are infinite except two" ) {
274 for (
auto c = 0; c < complex.nbCells(); ++c ) {
275 const auto faces = complex.cellFaces( c );
276 for (
auto f : faces ) {
277 const auto opp_f = complex.opposite( f );
278 nb_finite += complex.isInfinite( complex.faceCell( opp_f ) ) ? 0 : 1;
285 GIVEN(
"Given a degenerated 1d polytope { (0,0,1), (3,-1,2), (9,-3,4), (-6,2,-1) } " ) {
287 = {
Point(0,0,1),
Point(3,-1,2),
Point(9,-3,4),
Point(-6,2,-1) };
288 WHEN(
"Computing its lattice polytope" ){
289 const auto P = Helper::computeLatticePolytope( V,
false,
true );
291 THEN(
"The polytope is valid and has 6 non trivial facets" ) {
292 REQUIRE( P.nbHalfSpaces() - 6 == 6 );
294 THEN(
"The polytope contains 6 points" ) {
297 THEN(
"The polytope contains no interior points" ) {
298 REQUIRE( P.countInterior() == 0 );
302 GIVEN(
"Given a degenerated 1d simplex { (1,0,-1), Point(4,-1,-2), Point(10,-3,-4) } " ) {
305 WHEN(
"Computing its lattice polytope" ){
306 const auto P = Helper::computeLatticePolytope( V,
false,
true );
308 THEN(
"The polytope is valid and has 6 non trivial facets" ) {
309 REQUIRE( P.nbHalfSpaces() - 6 == 6 );
311 THEN(
"The polytope contains 4 points" ) {
314 THEN(
"The polytope contains no interior points" ) {
315 REQUIRE( P.countInterior() == 0 );
319 GIVEN(
"Given a degenerated 2d polytope { (2,1,0), (1,0,1), (1,2,1), (0,1,2), (0,3,2) } " ) {
321 = {
Point(2,1,0),
Point(1,0,1),
Point(1,2,1),
Point(0,1,2),
Point(0,3,2) };
322 WHEN(
"Computing its lattice polytope" ){
323 const auto P = Helper::computeLatticePolytope( V,
false,
true );
325 THEN(
"The polytope is valid and has more than 6 non trivial facets" ) {
326 REQUIRE( P.nbHalfSpaces() - 6 == 6 );
328 THEN(
"The polytope contains 7 points" ) {
331 THEN(
"The polytope contains no interior points" ) {
332 REQUIRE( P.countInterior() == 0 );
336 GIVEN(
"Given a degenerated 2d simplex { (2,1,0), (1,0,1), (1,5,1), (0,3,2) } " ) {
338 = {
Point(2,1,0),
Point(1,0,1),
Point(1,5,1),
Point(0,3,2) };
339 WHEN(
"Computing its lattice polytope" ){
340 const auto P = Helper::computeLatticePolytope( V,
false,
true );
342 THEN(
"The polytope is valid and has more than 6 non trivial facets" ) {
343 REQUIRE( P.nbHalfSpaces() - 6 == 6 );
345 THEN(
"The polytope contains 8 points" ) {
348 THEN(
"The polytope contains no interior points" ) {
349 REQUIRE( P.countInterior() == 0 );