31 #if defined(CellGeometry_RECURSES)
32 #error Recursive header files inclusion detected in CellGeometry.h
33 #else // defined(CellGeometry_RECURSES)
35 #define CellGeometry_RECURSES
37 #if !defined CellGeometry_h
39 #define CellGeometry_h
47 #include <unordered_set>
48 #include "DGtal/base/Common.h"
49 #include "DGtal/kernel/UnorderedSetByBlock.h"
50 #include "DGtal/kernel/PointHashFunctions.h"
51 #include "DGtal/topology/CCellularGridSpaceND.h"
52 #include "DGtal/topology/KhalimskySpaceND.h"
53 #include "DGtal/topology/KhalimskyCellHashFunctions.h"
54 #include "DGtal/geometry/volumes/BoundedLatticePolytope.h"
55 #include "DGtal/geometry/volumes/BoundedRationalPolytope.h"
73 template <
typename TKSpace >
87 #ifdef WITH_BIGINTEGER
134 bool verbose =
false );
153 bool verbose =
false );
163 template <
typename Po
intIterator>
168 template <
typename Po
intelIterator>
373 template <
typename RandomIterator>
375 bool includes( RandomIterator it2, RandomIterator itE2,
376 RandomIterator it1, RandomIterator itE1 );
389 template <
typename TKSpace>
403 template <
typename TKSpace,
int i,
int N>
418 template <
typename Po
intelIterator>
420 std::unordered_set<typename KSpace::Cell>
422 PointelIterator itB, PointelIterator itE )
424 std::unordered_set<typename KSpace::Cell> cells;
426 for (
auto it = itB; it != itE; ++it )
429 for (
auto it = itB; it != itE; ++it )
433 for (
auto&& f : cofaces )
434 if (
K.
uDim( f ) == i ) cells.insert( f );
445 template <
typename Po
intIterator>
447 std::unordered_set<typename KSpace::Cell>
449 PointIterator itB, PointIterator itE )
451 std::unordered_set<typename KSpace::Cell> cells;
453 for (
auto it = itB; it != itE; ++it )
456 for (
auto it = itB; it != itE; ++it )
460 for (
auto&& f : cofaces )
461 if (
K.
uDim( f ) == i ) cells.insert( f );
472 template <
typename Po
intIterator>
477 PointIterator itB, PointIterator itE )
482 for (
auto it = itB; it != itE; ++it )
485 for (
auto it = itB; it != itE; ++it )
489 for (
auto&& f : cofaces )
500 template <
typename TKSpace>
514 template <
typename Po
intelIterator>
516 std::unordered_set<typename KSpace::Cell>
518 PointelIterator itB, PointelIterator itE )
520 std::unordered_set<typename KSpace::Cell> cells;
521 for (
auto it = itB; it != itE; ++it )
524 cells.insert(
K.
uIncident( pointel, 0,
true ) );
525 cells.insert(
K.
uIncident( pointel, 0,
false ) );
526 cells.insert(
K.
uIncident( pointel, 1,
true ) );
527 cells.insert(
K.
uIncident( pointel, 1,
false ) );
537 template <
typename Po
intIterator>
539 std::unordered_set<typename KSpace::Cell>
541 PointIterator itB, PointIterator itE )
543 std::unordered_set<typename KSpace::Cell> cells;
544 for (
auto it = itB; it != itE; ++it )
547 cells.insert(
K.
uIncident( pointel, 0,
true ) );
548 cells.insert(
K.
uIncident( pointel, 0,
false ) );
549 cells.insert(
K.
uIncident( pointel, 1,
true ) );
550 cells.insert(
K.
uIncident( pointel, 1,
false ) );
560 template <
typename Po
intIterator>
565 PointIterator itB, PointIterator itE )
569 for (
auto it = itB; it != itE; ++it )
572 kpoints.emplace( kp[ 0 ] , kp[ 1 ] - 1 );
573 kpoints.emplace( kp[ 0 ] - 1, kp[ 1 ] );
574 kpoints.emplace( kp[ 0 ] + 1, kp[ 1 ] );
575 kpoints.emplace( kp[ 0 ] , kp[ 1 ] + 1 );
584 template <
typename TKSpace>
598 template <
typename Po
intelIterator>
600 std::unordered_set<typename KSpace::Cell>
602 PointelIterator itB, PointelIterator itE )
604 std::unordered_set<typename KSpace::Cell> cells;
605 for (
auto it = itB; it != itE; ++it )
608 cells.insert(
K.
uIncident( pointel, 0,
true ) );
609 cells.insert(
K.
uIncident( pointel, 0,
false ) );
610 cells.insert(
K.
uIncident( pointel, 1,
true ) );
611 cells.insert(
K.
uIncident( pointel, 1,
false ) );
612 cells.insert(
K.
uIncident( pointel, 2,
true ) );
613 cells.insert(
K.
uIncident( pointel, 2,
false ) );
624 template <
typename Po
intIterator>
626 std::unordered_set<typename KSpace::Cell>
628 PointIterator itB, PointIterator itE )
630 std::cout <<
"<1,3> specialization" << std::endl;
631 std::unordered_set<typename KSpace::Cell> cells;
632 for (
auto it = itB; it != itE; ++it )
635 cells.insert(
K.
uIncident( pointel, 0,
true ) );
636 cells.insert(
K.
uIncident( pointel, 0,
false ) );
637 cells.insert(
K.
uIncident( pointel, 1,
true ) );
638 cells.insert(
K.
uIncident( pointel, 1,
false ) );
639 cells.insert(
K.
uIncident( pointel, 2,
true ) );
640 cells.insert(
K.
uIncident( pointel, 2,
false ) );
650 template <
typename Po
intIterator>
655 PointIterator itB, PointIterator itE )
659 for (
auto it = itB; it != itE; ++it )
662 kpoints.emplace( kp[ 0 ] - 1, kp[ 1 ] , kp[ 2 ] );
663 kpoints.emplace( kp[ 0 ] + 1, kp[ 1 ] , kp[ 2 ] );
664 kpoints.emplace( kp[ 0 ] , kp[ 1 ] - 1, kp[ 2 ] );
665 kpoints.emplace( kp[ 0 ] , kp[ 1 ] + 1, kp[ 2 ] );
666 kpoints.emplace( kp[ 0 ] , kp[ 1 ] , kp[ 2 ] - 1 );
667 kpoints.emplace( kp[ 0 ] , kp[ 1 ] , kp[ 2 ] + 1 );
676 template <
typename TKSpace>
690 template <
typename Po
intelIterator>
692 std::unordered_set<typename KSpace::Cell>
694 PointelIterator itB, PointelIterator itE )
696 std::unordered_set<typename KSpace::Cell> cells;
697 for (
auto it = itB; it != itE; ++it )
700 auto linelxp =
K.
uIncident( pointel, 0,
true );
701 auto linelxm =
K.
uIncident( pointel, 0,
false );
702 cells.insert(
K.
uIncident( linelxp, 1,
true ) );
703 cells.insert(
K.
uIncident( linelxp, 1,
false ) );
704 cells.insert(
K.
uIncident( linelxm, 1,
true ) );
705 cells.insert(
K.
uIncident( linelxm, 1,
false ) );
716 template <
typename Po
intIterator>
718 std::unordered_set<typename KSpace::Cell>
720 PointIterator itB, PointIterator itE )
722 std::cout <<
"<2,2> specialization" << std::endl;
723 std::unordered_set<typename KSpace::Cell> cells;
724 for (
auto it = itB; it != itE; ++it )
727 auto linelxp =
K.
uIncident( pointel, 0,
true );
728 auto linelxm =
K.
uIncident( pointel, 0,
false );
729 cells.insert(
K.
uIncident( linelxp, 1,
true ) );
730 cells.insert(
K.
uIncident( linelxp, 1,
false ) );
731 cells.insert(
K.
uIncident( linelxm, 1,
true ) );
732 cells.insert(
K.
uIncident( linelxm, 1,
false ) );
742 template <
typename Po
intIterator>
747 PointIterator itB, PointIterator itE )
751 for (
auto it = itB; it != itE; ++it )
754 kpoints.emplace( kp[ 0 ] - 1, kp[ 1 ] - 1 );
755 kpoints.emplace( kp[ 0 ] + 1, kp[ 1 ] - 1 );
756 kpoints.emplace( kp[ 0 ] - 1, kp[ 1 ] + 1 );
757 kpoints.emplace( kp[ 0 ] + 1, kp[ 1 ] + 1 );
766 template <
typename TKSpace>
780 template <
typename Po
intelIterator>
782 std::unordered_set<typename KSpace::Cell>
784 PointelIterator itB, PointelIterator itE )
786 std::unordered_set<typename KSpace::Cell> cells;
787 for (
auto it = itB; it != itE; ++it )
790 auto linelxp =
K.
uIncident( pointel, 0,
true );
791 auto linelxm =
K.
uIncident( pointel, 0,
false );
792 auto linelyp =
K.
uIncident( pointel, 1,
true );
793 auto linelym =
K.
uIncident( pointel, 1,
false );
794 cells.insert(
K.
uIncident( linelxp, 1,
true ) );
795 cells.insert(
K.
uIncident( linelxp, 1,
false ) );
796 cells.insert(
K.
uIncident( linelxp, 2,
true ) );
797 cells.insert(
K.
uIncident( linelxp, 2,
false ) );
798 cells.insert(
K.
uIncident( linelxm, 1,
true ) );
799 cells.insert(
K.
uIncident( linelxm, 1,
false ) );
800 cells.insert(
K.
uIncident( linelxm, 2,
true ) );
801 cells.insert(
K.
uIncident( linelxm, 2,
false ) );
802 cells.insert(
K.
uIncident( linelyp, 2,
true ) );
803 cells.insert(
K.
uIncident( linelyp, 2,
false ) );
804 cells.insert(
K.
uIncident( linelym, 2,
true ) );
805 cells.insert(
K.
uIncident( linelym, 2,
false ) );
816 template <
typename Po
intIterator>
818 std::unordered_set<typename KSpace::Cell>
820 PointIterator itB, PointIterator itE )
822 std::cout <<
"<2,3> specialization" << std::endl;
823 std::unordered_set<typename KSpace::Cell> cells;
824 for (
auto it = itB; it != itE; ++it )
827 auto linelxp =
K.
uIncident( pointel, 0,
true );
828 auto linelxm =
K.
uIncident( pointel, 0,
false );
829 auto linelyp =
K.
uIncident( pointel, 1,
true );
830 auto linelym =
K.
uIncident( pointel, 1,
false );
831 cells.insert(
K.
uIncident( linelxp, 1,
true ) );
832 cells.insert(
K.
uIncident( linelxp, 1,
false ) );
833 cells.insert(
K.
uIncident( linelxp, 2,
true ) );
834 cells.insert(
K.
uIncident( linelxp, 2,
false ) );
835 cells.insert(
K.
uIncident( linelxm, 1,
true ) );
836 cells.insert(
K.
uIncident( linelxm, 1,
false ) );
837 cells.insert(
K.
uIncident( linelxm, 2,
true ) );
838 cells.insert(
K.
uIncident( linelxm, 2,
false ) );
839 cells.insert(
K.
uIncident( linelyp, 2,
true ) );
840 cells.insert(
K.
uIncident( linelyp, 2,
false ) );
841 cells.insert(
K.
uIncident( linelym, 2,
true ) );
842 cells.insert(
K.
uIncident( linelym, 2,
false ) );
852 template <
typename Po
intIterator>
857 PointIterator itB, PointIterator itE )
861 for (
auto it = itB; it != itE; ++it )
864 kpoints.emplace( kp[ 0 ] - 1, kp[ 1 ] - 1, kp[ 2 ] );
865 kpoints.emplace( kp[ 0 ] + 1, kp[ 1 ] - 1, kp[ 2 ] );
866 kpoints.emplace( kp[ 0 ] - 1, kp[ 1 ] + 1, kp[ 2 ] );
867 kpoints.emplace( kp[ 0 ] + 1, kp[ 1 ] + 1, kp[ 2 ] );
868 kpoints.emplace( kp[ 0 ] - 1, kp[ 1 ] , kp[ 2 ] - 1 );
869 kpoints.emplace( kp[ 0 ] + 1, kp[ 1 ] , kp[ 2 ] - 1 );
870 kpoints.emplace( kp[ 0 ] - 1, kp[ 1 ] , kp[ 2 ] + 1 );
871 kpoints.emplace( kp[ 0 ] + 1, kp[ 1 ] , kp[ 2 ] + 1 );
872 kpoints.emplace( kp[ 0 ] , kp[ 1 ] - 1, kp[ 2 ] - 1 );
873 kpoints.emplace( kp[ 0 ] , kp[ 1 ] + 1, kp[ 2 ] - 1 );
874 kpoints.emplace( kp[ 0 ] , kp[ 1 ] - 1, kp[ 2 ] + 1 );
875 kpoints.emplace( kp[ 0 ] , kp[ 1 ] + 1, kp[ 2 ] + 1 );
884 template <
typename TKSpace>
898 template <
typename Po
intelIterator>
900 std::unordered_set<typename KSpace::Cell>
902 PointelIterator itB, PointelIterator itE )
904 std::unordered_set<typename KSpace::Cell> cells;
905 for (
auto it = itB; it != itE; ++it )
908 auto linelxp =
K.
uIncident( pointel, 0,
true );
909 auto linelxm =
K.
uIncident( pointel, 0,
false );
910 auto surfxpyp =
K.
uIncident( linelxp, 1,
true );
911 auto surfxpym =
K.
uIncident( linelxp, 1,
false );
912 auto surfxmyp =
K.
uIncident( linelxm, 1,
true );
913 auto surfxmym =
K.
uIncident( linelxm, 1,
false );
914 cells.insert(
K.
uIncident( surfxpyp, 2,
true ) );
915 cells.insert(
K.
uIncident( surfxpyp, 2,
false ) );
916 cells.insert(
K.
uIncident( surfxpym, 2,
true ) );
917 cells.insert(
K.
uIncident( surfxpym, 2,
false ) );
918 cells.insert(
K.
uIncident( surfxmyp, 2,
true ) );
919 cells.insert(
K.
uIncident( surfxmyp, 2,
false ) );
920 cells.insert(
K.
uIncident( surfxmym, 2,
true ) );
921 cells.insert(
K.
uIncident( surfxmym, 2,
false ) );
932 template <
typename Po
intIterator>
934 std::unordered_set<typename KSpace::Cell>
936 PointIterator itB, PointIterator itE )
938 std::unordered_set<typename KSpace::Cell> cells;
939 for (
auto it = itB; it != itE; ++it )
942 auto linelxp =
K.
uIncident( pointel, 0,
true );
943 auto linelxm =
K.
uIncident( pointel, 0,
false );
944 auto surfxpyp =
K.
uIncident( linelxp, 1,
true );
945 auto surfxpym =
K.
uIncident( linelxp, 1,
false );
946 auto surfxmyp =
K.
uIncident( linelxm, 1,
true );
947 auto surfxmym =
K.
uIncident( linelxm, 1,
false );
948 cells.insert(
K.
uIncident( surfxpyp, 2,
true ) );
949 cells.insert(
K.
uIncident( surfxpyp, 2,
false ) );
950 cells.insert(
K.
uIncident( surfxpym, 2,
true ) );
951 cells.insert(
K.
uIncident( surfxpym, 2,
false ) );
952 cells.insert(
K.
uIncident( surfxmyp, 2,
true ) );
953 cells.insert(
K.
uIncident( surfxmyp, 2,
false ) );
954 cells.insert(
K.
uIncident( surfxmym, 2,
true ) );
955 cells.insert(
K.
uIncident( surfxmym, 2,
false ) );
965 template <
typename Po
intIterator>
970 PointIterator itB, PointIterator itE )
974 for (
auto it = itB; it != itE; ++it )
977 kpoints.emplace( kp[ 0 ] - 1, kp[ 1 ] - 1, kp[ 2 ] - 1 );
978 kpoints.emplace( kp[ 0 ] + 1, kp[ 1 ] - 1, kp[ 2 ] - 1 );
979 kpoints.emplace( kp[ 0 ] - 1, kp[ 1 ] + 1, kp[ 2 ] - 1 );
980 kpoints.emplace( kp[ 0 ] + 1, kp[ 1 ] + 1, kp[ 2 ] - 1 );
981 kpoints.emplace( kp[ 0 ] - 1, kp[ 1 ] - 1, kp[ 2 ] + 1 );
982 kpoints.emplace( kp[ 0 ] + 1, kp[ 1 ] - 1, kp[ 2 ] + 1 );
983 kpoints.emplace( kp[ 0 ] - 1, kp[ 1 ] + 1, kp[ 2 ] + 1 );
984 kpoints.emplace( kp[ 0 ] + 1, kp[ 1 ] + 1, kp[ 2 ] + 1 );
997 #include "CellGeometry.ih"
1002 #endif // !defined CellGeometry_h
1004 #undef CellGeometry_RECURSES
1005 #endif // else defined(CellGeometry_RECURSES)