183{
185 typedef Helper::Point
Point;
191 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) } " ) {
192 std::vector<Point> V
193 = {
Point(0,0,0),
Point(-2,0,0),
Point(2,0,0),
Point(0,-2,0),
Point(0,2,0),
195 WHEN( "Computing its lattice polytope" ){
196 const auto P = Helper::computeLatticePolytope( V, false, true );
198 THEN( "The polytope is valid and has 8 non trivial facets plus 12 edge constraints" ) {
199 REQUIRE( P.nbHalfSpaces() - 6 == 20 );
200 }
201 THEN( "The polytope is Minkowski summable" ) {
203 }
204 THEN( "The polytope contains the input points" ) {
205 REQUIRE( P.isInside( V[ 0 ] ) );
206 REQUIRE( P.isInside( V[ 1 ] ) );
207 REQUIRE( P.isInside( V[ 2 ] ) );
208 REQUIRE( P.isInside( V[ 3 ] ) );
209 REQUIRE( P.isInside( V[ 4 ] ) );
210 REQUIRE( P.isInside( V[ 5 ] ) );
211 REQUIRE( P.isInside( V[ 6 ] ) );
212 }
213 THEN( "The polytope contains 25 points" ) {
215 }
216 THEN( "The interior of the polytope contains 7 points" ) {
217 REQUIRE( P.countInterior() == 7 );
218 }
219 THEN( "The boundary of the polytope contains 18 points" ) {
220 REQUIRE( P.countBoundary() == 18 );
221 }
222 }
223 WHEN( "Computing the boundary of its convex hull as a SurfaceMesh" ){
225 bool ok = Helper::computeConvexHullBoundary( smesh, V, false );
227 THEN( "The surface mesh is valid and has 6 vertices, 12 edges and 8 faces" ) {
232 }
233 THEN( "The surface mesh has the topology of a sphere" ) {
237 }
238 }
239 WHEN( "Computing the boundary of its convex hull as a lattice PolygonalSurface" ){
240 LatticePolySurf lpsurf;
241 bool ok = Helper::computeConvexHullBoundary( lpsurf, V, false );
243 THEN( "The polygonal surface is valid and has 6 vertices, 12 edges and 8 faces" ) {
245 REQUIRE( lpsurf.nbVertices() == 6 );
246 REQUIRE( lpsurf.nbEdges() == 12 );
247 REQUIRE( lpsurf.nbFaces() == 8 );
248 REQUIRE( lpsurf.nbArcs() == 24 );
249 }
250 THEN( "The polygonal surface has the topology of a sphere and no boundary" ) {
251 REQUIRE( lpsurf.Euler() == 2 );
252 REQUIRE( lpsurf.allBoundaryArcs().size() == 0 );
253 REQUIRE( lpsurf.allBoundaryVertices().size() == 0 );
254 }
255 }
256 WHEN( "Computing its convex hull as a ConvexCellComplex" ){
257 CvxCellComplex complex;
258 bool ok = Helper::computeConvexHullCellComplex( complex, V, false );
260 THEN( "The convex cell complex is valid and has 6 vertices, 8 faces and 1 finite cell" ) {
262 REQUIRE( complex.nbVertices() == 6 );
263 REQUIRE( complex.nbFaces() == 8 );
264 REQUIRE( complex.nbCells() == 1 );
265 }
266 }
267 WHEN( "Computing the vertices of its convex hull" ){
268 const auto X = Helper::computeConvexHullVertices( V, false );
270 THEN( "The polytope has 6 vertices" ) {
272 }
273 }
274 }
275 GIVEN(
"Given a cube with an additional outside vertex " ) {
276 std::vector<Point> V
277 = {
Point(-10,-10,-10),
Point(10,-10,-10),
Point(-10,10,-10),
Point(10,10,-10),
278 Point(-10,-10,10),
Point(10,-10,10),
Point(-10,10,10),
Point(10,10,10),
280 WHEN( "Computing its Delaunay cell complex" ){
281 CvxCellComplex complex;
282 bool ok = Helper::computeDelaunayCellComplex( complex, V, false );
284 THEN( "The complex has 2 cells, 10 faces, 9 vertices" ) {
286 REQUIRE( complex.nbCells() == 2 );
287 REQUIRE( complex.nbFaces() == 10 );
288 REQUIRE( complex.nbVertices() == 9 );
289 }
290 THEN( "The faces of cells are finite" ) {
291 bool ok_finite = true;
292 for ( CvxCellComplex::Size c = 0; c < complex.nbCells(); ++c ) {
293 const auto faces = complex.cellFaces( c );
294 for ( auto f : faces )
295 ok_finite = ok_finite && ! complex.isInfinite( complex.faceCell( f ) );
296 }
298 }
299 THEN( "The opposite of faces of cells are infinite except two" ) {
300 int nb_finite = 0;
301 for ( CvxCellComplex::Size c = 0; c < complex.nbCells(); ++c ) {
302 const auto faces = complex.cellFaces( c );
303 for ( auto f : faces ) {
304 const auto opp_f = complex.opposite( f );
305 nb_finite += complex.isInfinite( complex.faceCell( opp_f ) ) ? 0 : 1;
306 }
307 }
309 }
310 }
311 WHEN( "Computing the vertices of its convex hull" ){
312 const auto X = Helper::computeConvexHullVertices( V, false );
314 THEN( "The polytope has 9 vertices" ) {
316 }
317 }
318 }
319 GIVEN(
"Given a degenerated 1d polytope { (0,0,1), (3,-1,2), (9,-3,4), (-6,2,-1) } " ) {
320 std::vector<Point> V
321 = {
Point(0,0,1),
Point(3,-1,2),
Point(9,-3,4),
Point(-6,2,-1) };
322 WHEN( "Computing its lattice polytope" ){
323 const auto P = Helper::computeLatticePolytope( V, false, true );
325 THEN( "The polytope is valid and has 6 non trivial facets" ) {
326 REQUIRE( P.nbHalfSpaces() - 6 == 6 );
327 }
328 THEN( "The polytope contains 6 points" ) {
330 }
331 THEN( "The polytope contains no interior points" ) {
332 REQUIRE( P.countInterior() == 0 );
333 }
334 }
335 WHEN( "Computing the vertices of its convex hull" ){
336 auto X = Helper::computeConvexHullVertices( V, false );
337 std::sort( X.begin(), X.end() );
339 THEN( "The polytope is a segment defined by two points" ) {
343 }
344 }
345 }
346 GIVEN(
"Given a degenerated 1d simplex { (1,0,-1), Point(4,-1,-2), Point(10,-3,-4) } " ) {
347 std::vector<Point> V
349 WHEN( "Computing its lattice polytope" ){
350 const auto P = Helper::computeLatticePolytope( V, false, true );
352 THEN( "The polytope is valid and has 6 non trivial facets" ) {
353 REQUIRE( P.nbHalfSpaces() - 6 == 6 );
354 }
355 THEN( "The polytope contains 4 points" ) {
357 }
358 THEN( "The polytope contains no interior points" ) {
359 REQUIRE( P.countInterior() == 0 );
360 }
361 }
362 WHEN( "Computing the vertices of its convex hull" ){
363 auto X = Helper::computeConvexHullVertices( V, false );
364 std::sort( X.begin(), X.end() );
366 THEN( "The polytope is a segment defined by two points" ) {
370 }
371 }
372 }
373 GIVEN(
"Given a degenerated 2d polytope { (2,1,0), (1,0,1), (1,2,1), (0,1,2), (0,3,2) } " ) {
374 std::vector<Point> V
375 = {
Point(2,1,0),
Point(1,0,1),
Point(1,2,1),
Point(0,1,2),
Point(0,3,2) };
376 WHEN( "Computing its lattice polytope" ){
377 const auto P = Helper::computeLatticePolytope( V, false, true );
379 THEN( "The polytope is valid and has more than 6 non trivial facets" ) {
380 REQUIRE( P.nbHalfSpaces() - 6 == 6 );
381 }
382 THEN( "The polytope contains 7 points" ) {
384 }
385 THEN( "The polytope contains no interior points" ) {
386 REQUIRE( P.countInterior() == 0 );
387 }
388 }
389 WHEN( "Computing the vertices of its convex hull" ){
390 auto X = Helper::computeConvexHullVertices( V, false );
391 std::sort( X.begin(), X.end() );
393 THEN( "The polytope is a quad" ) {
399 }
400 }
401 }
402 GIVEN(
"Given a degenerated 2d simplex { (2,1,0), (1,0,1), (1,5,1), (0,3,2) } " ) {
403 std::vector<Point> V
404 = {
Point(2,1,0),
Point(1,0,1),
Point(1,5,1),
Point(0,3,2) };
405 WHEN( "Computing its lattice polytope" ){
406 const auto P = Helper::computeLatticePolytope( V, false, true );
408 THEN( "The polytope is valid and has more than 6 non trivial facets" ) {
409 REQUIRE( P.nbHalfSpaces() - 6 == 6 );
410 }
411 THEN( "The polytope contains 8 points" ) {
413 }
414 THEN( "The polytope contains no interior points" ) {
415 REQUIRE( P.countInterior() == 0 );
416 }
417 }
418 WHEN( "Computing the vertices of its convex hull" ){
419 auto X = Helper::computeConvexHullVertices( V, false );
420 std::sort( X.begin(), X.end() );
422 THEN( "The polytope is a quad" ) {
428 }
429 }
430 }
431}
Aim: Implements basic operations that will be used in Point and Vector classes.
Aim: Represents a polygon mesh, i.e. a 2-dimensional combinatorial surface whose faces are (topologic...
SurfaceMesh< RealPoint, RealVector > SMesh
Aim: Represents an embedded mesh as faces and a list of vertices. Vertices may be shared among faces ...
Edges computeManifoldBoundaryEdges() const
Edges computeNonManifoldEdges() const
PointVector< 3, double > RealPoint