MarchingCubes.h 80 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254
  1. // David Eberly, Geometric Tools, Redmond WA 98052
  2. // Copyright (c) 1998-2020
  3. // Distributed under the Boost Software License, Version 1.0.
  4. // https://www.boost.org/LICENSE_1_0.txt
  5. // https://www.geometrictools.com/License/Boost/LICENSE_1_0.txt
  6. // Version: 4.0.2019.08.13
  7. #pragma once
  8. #include <array>
  9. #include <string>
  10. // Create the lookup table for the Marching Cubes algorithm that is used to
  11. // extract a triangular mesh that represents a level surface of a 3D image
  12. // sampled on a regular lattice. The assumption is that no data sample is
  13. // zero, which allows us to have a table with 256 entries: 2 signs per
  14. // sample, 8 samples per volume element (voxel). Each entry corresponds to
  15. // the pattern of 8 signs at the corners of a voxel. The signs are stored as
  16. // bits (b7,b6,b5,b4,b3,b2,b1,b0). The bit assignments to voxel corners is
  17. // b0 = (x,y,z), b1 = (x+1,y,z), b2 = (x,y+1,z), b3 = (x+1,y+1,z)
  18. // b4 = (x,y,z+1), b5 = (x+1,y,z+1), b6 = (x,y+1,z+1), b7 = (x+1,y+1,z+1)
  19. // If a bit is zero, then the voxel value at the corresponding corner is
  20. // positive; otherwise, the bit is one and the value is negative. The
  21. // triangles are counterclockwise ordered according to an observer viewing
  22. // the triangle from the negative side of the level surface.
  23. // INTERNAL USE ONLY. This is used for convenience in creating the
  24. // Configuration table. TODO: Expand the macro manually for the table
  25. // creation.
  26. #define GTE_MC_ENTRY(name) CT_##name, &MarchingCubes::name
  27. namespace WwiseGTE
  28. {
  29. class MarchingCubes
  30. {
  31. public:
  32. // Construction and destruction.
  33. virtual ~MarchingCubes() = default;
  34. MarchingCubes()
  35. {
  36. // Create the lookup table.
  37. for (mEntry = 0; mEntry < 256; ++mEntry)
  38. {
  39. (this->*ConfigurationTable()[mEntry].F)(ConfigurationTable()[mEntry].index);
  40. }
  41. }
  42. enum
  43. {
  44. MAX_VERTICES = 12,
  45. MAX_TRIANGLES = 5,
  46. };
  47. struct Topology
  48. {
  49. // All members are set to zeros.
  50. Topology()
  51. :
  52. numVertices(0),
  53. numTriangles(0)
  54. {
  55. std::fill(vpair.begin(), vpair.end(), std::array<int, 2>{ 0, 0 });
  56. std::fill(itriple.begin(), itriple.end(), std::array<int, 3>{ 0, 0, 0 });
  57. }
  58. int numVertices;
  59. int numTriangles;
  60. std::array<std::array<int, 2>, MAX_VERTICES> vpair;
  61. std::array<std::array<int, 3>, MAX_TRIANGLES> itriple;
  62. };
  63. // The entry must be in {0..255}.
  64. inline Topology const& GetTable(int entry) const
  65. {
  66. return TopologyTable()[entry];
  67. }
  68. // The table has 256 entries, each 41 integers, stored as
  69. // table[256][41]. The return value is a pointer to the table via
  70. // &table[0][0].
  71. inline int const* GetTable() const
  72. {
  73. return reinterpret_cast<int const*>(TopologyTable().data());
  74. }
  75. // The pre-built topology table that is generated by the constructor.
  76. // This is for reference in case you want to have a GPU-based
  77. // implementation where you load the table as a GPU resource.
  78. static std::array<std::array<int, 41>, 256> const& GetPrebuiltTable()
  79. {
  80. static std::array<std::array<int, 41>, 256> topologyTable =
  81. { {
  82. { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
  83. { 3, 1, 0, 1, 0, 4, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }
  338. }};
  339. return topologyTable;
  340. }
  341. // Get the configuration type for the voxel, which is one of the
  342. // string names of the 'void Bits* (int[8])' functions.
  343. static std::string GetConfigurationType(int entry)
  344. {
  345. if (0 <= entry && entry < 256)
  346. {
  347. return ConfigurationString()[ConfigurationTable()[entry].type];
  348. }
  349. return "";
  350. }
  351. protected:
  352. // Support for lookup construction and access.
  353. // mTable[i][0] = numVertices
  354. // mTable[i][1] = numTriangles
  355. // mTable[i][2..25] = pairs of corner indices (maximum of 12 pairs)
  356. // mTable[i][26..40] = triples of indices (maximum of 5 triples)
  357. static std::array<Topology, 256>& TopologyTable()
  358. {
  359. static std::array<Topology, 256> topologyTable;
  360. return topologyTable;
  361. }
  362. // The constructor iterates mEntry from 0 to 255 and calls configuration
  363. // functions, each calling SetTable(...). The mEntry value is the table
  364. // index to be used.
  365. int mEntry;
  366. void SetTable(int numV, int const* vpair, int numT, int const* itriple)
  367. {
  368. // The item is already zeroed in the constructor.
  369. Topology& topology = TopologyTable()[mEntry];
  370. topology.numVertices = numV;
  371. topology.numTriangles = numT;
  372. // Store vertex pairs with minimum index occurring first.
  373. for (int i = 0; i < numV; ++i, vpair += 2)
  374. {
  375. topology.vpair[i][0] = std::min(vpair[0], vpair[1]);
  376. topology.vpair[i][1] = std::max(vpair[0], vpair[1]);
  377. }
  378. // Store triangle triples as is.
  379. for (int i = 0; i < numT; ++i, itriple += 3)
  380. {
  381. topology.itriple[i] = { itriple[0], itriple[1], itriple[2] };
  382. }
  383. }
  384. // The precomputed information about the 256 configurations for voxels.
  385. void Bits0(int[8])
  386. {
  387. SetTable(0, nullptr, 0, nullptr);
  388. }
  389. void Bits1(int index[8])
  390. {
  391. int const numV = 3;
  392. int vpair[2 * numV] =
  393. {
  394. index[1], index[0],
  395. index[4], index[0],
  396. index[2], index[0]
  397. };
  398. int const numT = 1;
  399. int itriple[3 * numT] =
  400. {
  401. 0, 1, 2
  402. };
  403. SetTable(numV, vpair, numT, itriple);
  404. }
  405. void Bits7(int index[8])
  406. {
  407. int const numV = 3;
  408. int vpair[2 * numV] =
  409. {
  410. index[1], index[0],
  411. index[4], index[0],
  412. index[2], index[0]
  413. };
  414. int const numT = 1;
  415. int itriple[3 * numT] =
  416. {
  417. 0, 2, 1
  418. };
  419. SetTable(numV, vpair, numT, itriple);
  420. }
  421. void Bits2Edge(int index[8])
  422. {
  423. int const numV = 4;
  424. int vpair[2 * numV] =
  425. {
  426. index[4], index[0],
  427. index[2], index[0],
  428. index[3], index[1],
  429. index[5], index[1]
  430. };
  431. int const numT = 2;
  432. int itriple[3 * numT] =
  433. {
  434. 0, 1, 2,
  435. 0, 2, 3
  436. };
  437. SetTable(numV, vpair, numT, itriple);
  438. }
  439. void Bits6Edge(int index[8])
  440. {
  441. int const numV = 4;
  442. int vpair[2 * numV] =
  443. {
  444. index[4], index[0],
  445. index[2], index[0],
  446. index[3], index[1],
  447. index[5], index[1]
  448. };
  449. int const numT = 2;
  450. int itriple[3 * numT] =
  451. {
  452. 0, 2, 1,
  453. 0, 3, 2
  454. };
  455. SetTable(numV, vpair, numT, itriple);
  456. }
  457. void Bits2FaceDiag(int index[8])
  458. {
  459. int const numV = 6;
  460. int vpair[2 * numV] =
  461. {
  462. index[1], index[0],
  463. index[4], index[0],
  464. index[2], index[0],
  465. index[2], index[3],
  466. index[7], index[3],
  467. index[1], index[3]
  468. };
  469. int const numT = 2;
  470. int itriple[3 * numT] =
  471. {
  472. 0, 1, 2,
  473. 3, 4, 5
  474. };
  475. SetTable(numV, vpair, numT, itriple);
  476. }
  477. void Bits6FaceDiag(int index[8])
  478. {
  479. int const numV = 6;
  480. int vpair[2 * numV] =
  481. {
  482. index[1], index[0],
  483. index[4], index[0],
  484. index[2], index[0],
  485. index[2], index[3],
  486. index[7], index[3],
  487. index[1], index[3]
  488. };
  489. // Not the reverse ordering from Bit2FaceDiag due to ambiguous face
  490. // handling.
  491. int const numT = 4;
  492. int itriple[3 * numT] =
  493. {
  494. 1, 0, 5,
  495. 1, 5, 4,
  496. 1, 4, 3,
  497. 1, 3, 2
  498. };
  499. SetTable(numV, vpair, numT, itriple);
  500. }
  501. void Bits2BoxDiag(int index[8])
  502. {
  503. int const numV = 6;
  504. int vpair[2 * numV] =
  505. {
  506. index[1], index[0],
  507. index[4], index[0],
  508. index[2], index[0],
  509. index[3], index[7],
  510. index[6], index[7],
  511. index[5], index[7]
  512. };
  513. int const numT = 2;
  514. int itriple[3 * numT] =
  515. {
  516. 0, 1, 2,
  517. 3, 4, 5
  518. };
  519. SetTable(numV, vpair, numT, itriple);
  520. }
  521. void Bits6BoxDiag(int index[8])
  522. {
  523. int const numV = 6;
  524. int vpair[2 * numV] =
  525. {
  526. index[1], index[0],
  527. index[4], index[0],
  528. index[2], index[0],
  529. index[3], index[7],
  530. index[6], index[7],
  531. index[5], index[7]
  532. };
  533. int const numT = 2;
  534. int itriple[3 * numT] =
  535. {
  536. 0, 2, 1,
  537. 3, 5, 4
  538. };
  539. SetTable(numV, vpair, numT, itriple);
  540. }
  541. void Bits3SameFace(int index[8])
  542. {
  543. int const numV = 5;
  544. int vpair[2 * numV] =
  545. {
  546. index[4], index[0],
  547. index[2], index[6],
  548. index[2], index[3],
  549. index[1], index[3],
  550. index[1], index[5]
  551. };
  552. int const numT = 3;
  553. int itriple[3 * numT] =
  554. {
  555. 0, 1, 2,
  556. 0, 2, 3,
  557. 0, 3, 4
  558. };
  559. SetTable(numV, vpair, numT, itriple);
  560. }
  561. void Bits5SameFace(int index[8])
  562. {
  563. int const numV = 5;
  564. int vpair[2 * numV] =
  565. {
  566. index[4], index[0],
  567. index[2], index[6],
  568. index[2], index[3],
  569. index[1], index[3],
  570. index[1], index[5]
  571. };
  572. int const numT = 3;
  573. int itriple[3 * numT] =
  574. {
  575. 0, 2, 1,
  576. 0, 3, 2,
  577. 0, 4, 3
  578. };
  579. SetTable(numV, vpair, numT, itriple);
  580. }
  581. void Bits3EdgeFaceDiag(int index[8])
  582. {
  583. int const numV = 7;
  584. int vpair[2 * numV] =
  585. {
  586. index[0], index[1],
  587. index[4], index[5],
  588. index[4], index[6],
  589. index[0], index[2],
  590. index[2], index[3],
  591. index[3], index[7],
  592. index[1], index[3]
  593. };
  594. int const numT = 3;
  595. int itriple[3 * numT] =
  596. {
  597. 0, 1, 2,
  598. 0, 2, 3,
  599. 4, 5, 6
  600. };
  601. SetTable(numV, vpair, numT, itriple);
  602. }
  603. void Bits5EdgeFaceDiag(int index[8])
  604. {
  605. int const numV = 7;
  606. int vpair[2 * numV] =
  607. {
  608. index[0], index[1],
  609. index[4], index[5],
  610. index[4], index[6],
  611. index[0], index[2],
  612. index[2], index[3],
  613. index[3], index[7],
  614. index[1], index[3]
  615. };
  616. // Not the reverse ordering from Bit3EdgeFaceDiag due to ambiguous face
  617. // handling.
  618. int const numT = 5;
  619. int itriple[3 * numT] =
  620. {
  621. 5, 0, 6,
  622. 5, 1, 0,
  623. 5, 2, 1,
  624. 5, 3, 2,
  625. 5, 4, 3
  626. };
  627. SetTable(numV, vpair, numT, itriple);
  628. }
  629. void Bits3FaceDiagFaceDiag(int index[8])
  630. {
  631. int const numV = 9;
  632. int vpair[2 * numV] =
  633. {
  634. index[0], index[1],
  635. index[0], index[4],
  636. index[0], index[2],
  637. index[2], index[3],
  638. index[3], index[7],
  639. index[1], index[3],
  640. index[1], index[5],
  641. index[5], index[7],
  642. index[4], index[5]
  643. };
  644. int const numT = 3;
  645. int itriple[3 * numT] =
  646. {
  647. 0, 1, 2,
  648. 3, 4, 5,
  649. 6, 7, 8
  650. };
  651. SetTable(numV, vpair, numT, itriple);
  652. }
  653. void Bits5FaceDiagFaceDiag(int index[8])
  654. {
  655. int const numV = 9;
  656. int vpair[2 * numV] =
  657. {
  658. index[0], index[1],
  659. index[0], index[4],
  660. index[0], index[2],
  661. index[2], index[3],
  662. index[3], index[7],
  663. index[1], index[3],
  664. index[1], index[5],
  665. index[5], index[7],
  666. index[4], index[5]
  667. };
  668. // Not the reverse ordering from Bit3FaceDiagFaceDiag due to ambiguous face
  669. // handling.
  670. int const numT = 5;
  671. int itriple[3 * numT] =
  672. {
  673. 1, 3, 2,
  674. 1, 4, 3,
  675. 1, 7, 4,
  676. 1, 8, 7,
  677. 0, 5, 6
  678. };
  679. SetTable(numV, vpair, numT, itriple);
  680. }
  681. void Bits4SameFace(int index[8])
  682. {
  683. int const numV = 4;
  684. int vpair[2 * numV] =
  685. {
  686. index[0], index[4],
  687. index[2], index[6],
  688. index[3], index[7],
  689. index[1], index[5]
  690. };
  691. int const numT = 2;
  692. int itriple[3 * numT] =
  693. {
  694. 0, 1, 2,
  695. 0, 2, 3
  696. };
  697. SetTable(numV, vpair, numT, itriple);
  698. }
  699. void Bits4FaceEdge(int index[8])
  700. {
  701. int const numV = 6;
  702. int vpair[2 * numV] =
  703. {
  704. index[4], index[5],
  705. index[4], index[6],
  706. index[2], index[6],
  707. index[2], index[3],
  708. index[1], index[3],
  709. index[1], index[5]
  710. };
  711. int const numT = 4;
  712. int itriple[3 * numT] =
  713. {
  714. 0, 1, 2,
  715. 0, 2, 3,
  716. 0, 3, 4,
  717. 0, 4, 5
  718. };
  719. SetTable(numV, vpair, numT, itriple);
  720. }
  721. void Bits4FaceFaceDiagL(int index[8])
  722. {
  723. int const numV = 6;
  724. int vpair[2 * numV] =
  725. {
  726. index[4], index[5],
  727. index[0], index[4],
  728. index[2], index[6],
  729. index[2], index[3],
  730. index[1], index[3],
  731. index[5], index[7]
  732. };
  733. int const numT = 4;
  734. int itriple[3 * numT] =
  735. {
  736. 0, 1, 2,
  737. 0, 2, 3,
  738. 0, 3, 4,
  739. 0, 4, 5
  740. };
  741. SetTable(numV, vpair, numT, itriple);
  742. }
  743. void Bits4FaceFaceDiagR(int index[8])
  744. {
  745. int const numV = 6;
  746. int vpair[2 * numV] =
  747. {
  748. index[4], index[6],
  749. index[6], index[7],
  750. index[2], index[3],
  751. index[1], index[3],
  752. index[1], index[5],
  753. index[0], index[4]
  754. };
  755. int const numT = 4;
  756. int itriple[3 * numT] =
  757. {
  758. 0, 1, 2,
  759. 0, 2, 3,
  760. 0, 3, 4,
  761. 0, 4, 5
  762. };
  763. SetTable(numV, vpair, numT, itriple);
  764. }
  765. void Bits4FaceBoxDiag(int index[8])
  766. {
  767. int const numV = 8;
  768. int vpair[2 * numV] =
  769. {
  770. index[0], index[4],
  771. index[2], index[6],
  772. index[2], index[3],
  773. index[1], index[3],
  774. index[1], index[5],
  775. index[6], index[7],
  776. index[5], index[7],
  777. index[3], index[7]
  778. };
  779. int const numT = 4;
  780. int itriple[3 * numT] =
  781. {
  782. 0, 1, 2,
  783. 0, 2, 3,
  784. 0, 3, 4,
  785. 5, 6, 7
  786. };
  787. SetTable(numV, vpair, numT, itriple);
  788. }
  789. void Bits4EdgeEdgePara(int index[8])
  790. {
  791. int const numV = 8;
  792. int vpair[2 * numV] =
  793. {
  794. index[0], index[4],
  795. index[0], index[2],
  796. index[1], index[3],
  797. index[1], index[5],
  798. index[2], index[6],
  799. index[4], index[6],
  800. index[5], index[7],
  801. index[3], index[7]
  802. };
  803. int const numT = 4;
  804. int itriple[3 * numT] =
  805. {
  806. 0, 1, 2,
  807. 0, 2, 3,
  808. 4, 5, 6,
  809. 4, 6, 7
  810. };
  811. SetTable(numV, vpair, numT, itriple);
  812. }
  813. void Bits4EdgeEdgePerp(int index[8])
  814. {
  815. int const numV = 12;
  816. int vpair[2 * numV] =
  817. {
  818. index[0], index[1],
  819. index[0], index[4],
  820. index[0], index[2],
  821. index[2], index[6],
  822. index[4], index[6],
  823. index[6], index[7],
  824. index[2], index[3],
  825. index[3], index[7],
  826. index[1], index[3],
  827. index[1], index[5],
  828. index[5], index[7],
  829. index[4], index[5]
  830. };
  831. int const numT = 4;
  832. int itriple[3 * numT] =
  833. {
  834. 0, 1, 2,
  835. 3, 4, 5,
  836. 6, 7, 8,
  837. 9, 10, 11
  838. };
  839. SetTable(numV, vpair, numT, itriple);
  840. }
  841. enum ConfigurationType
  842. {
  843. CT_Bits0,
  844. CT_Bits1,
  845. CT_Bits7,
  846. CT_Bits2Edge,
  847. CT_Bits6Edge,
  848. CT_Bits2FaceDiag,
  849. CT_Bits6FaceDiag,
  850. CT_Bits2BoxDiag,
  851. CT_Bits6BoxDiag,
  852. CT_Bits3SameFace,
  853. CT_Bits5SameFace,
  854. CT_Bits3EdgeFaceDiag,
  855. CT_Bits5EdgeFaceDiag,
  856. CT_Bits3FaceDiagFaceDiag,
  857. CT_Bits5FaceDiagFaceDiag,
  858. CT_Bits4SameFace,
  859. CT_Bits4FaceEdge,
  860. CT_Bits4FaceFaceDiagL,
  861. CT_Bits4FaceFaceDiagR,
  862. CT_Bits4FaceBoxDiag,
  863. CT_Bits4EdgeEdgePara,
  864. CT_Bits4EdgeEdgePerp,
  865. CT_NUM_TYPES
  866. };
  867. typedef void (MarchingCubes::*Function)(int[8]);
  868. struct Configuration
  869. {
  870. ConfigurationType type;
  871. Function F;
  872. int index[8];
  873. };
  874. static std::array<Configuration, 256>& ConfigurationTable()
  875. {
  876. static std::array<Configuration, 256> configuration =
  877. { {
  878. /*00000000*/{ GTE_MC_ENTRY(Bits0), 0, 1, 2, 3, 4, 5, 6, 7 },
  879. /*00000001*/{ GTE_MC_ENTRY(Bits1), 0, 1, 2, 3, 4, 5, 6, 7 },
  880. /*00000010*/{ GTE_MC_ENTRY(Bits1), 1, 3, 0, 2, 5, 7, 4, 6 },
  881. /*00000011*/{ GTE_MC_ENTRY(Bits2Edge), 0, 1, 2, 3, 4, 5, 6, 7 },
  882. /*00000100*/{ GTE_MC_ENTRY(Bits1), 2, 0, 3, 1, 6, 4, 7, 5 },
  883. /*00000101*/{ GTE_MC_ENTRY(Bits2Edge), 2, 0, 3, 1, 6, 4, 7, 5 },
  884. /*00000110*/{ GTE_MC_ENTRY(Bits2FaceDiag), 1, 3, 0, 2, 5, 7, 4, 6 },
  885. /*00000111*/{ GTE_MC_ENTRY(Bits3SameFace), 0, 1, 2, 3, 4, 5, 6, 7 },
  886. /*00001000*/{ GTE_MC_ENTRY(Bits1), 3, 2, 1, 0, 7, 6, 5, 4 },
  887. /*00001001*/{ GTE_MC_ENTRY(Bits2FaceDiag), 0, 1, 2, 3, 4, 5, 6, 7 },
  888. /*00001010*/{ GTE_MC_ENTRY(Bits2Edge), 1, 3, 0, 2, 5, 7, 4, 6 },
  889. /*00001011*/{ GTE_MC_ENTRY(Bits3SameFace), 1, 3, 0, 2, 5, 7, 4, 6 },
  890. /*00001100*/{ GTE_MC_ENTRY(Bits2Edge), 3, 2, 1, 0, 7, 6, 5, 4 },
  891. /*00001101*/{ GTE_MC_ENTRY(Bits3SameFace), 2, 0, 3, 1, 6, 4, 7, 5 },
  892. /*00001110*/{ GTE_MC_ENTRY(Bits3SameFace), 3, 2, 1, 0, 7, 6, 5, 4 },
  893. /*00001111*/{ GTE_MC_ENTRY(Bits4SameFace), 0, 1, 2, 3, 4, 5, 6, 7 },
  894. /*00010000*/{ GTE_MC_ENTRY(Bits1), 4, 5, 0, 1, 6, 7, 2, 3 },
  895. /*00010001*/{ GTE_MC_ENTRY(Bits2Edge), 4, 0, 6, 2, 5, 1, 7, 3 },
  896. /*00010010*/{ GTE_MC_ENTRY(Bits2FaceDiag), 1, 0, 5, 4, 3, 2, 7, 6 },
  897. /*00010011*/{ GTE_MC_ENTRY(Bits3SameFace), 0, 4, 1, 5, 2, 6, 3, 7 },
  898. /*00010100*/{ GTE_MC_ENTRY(Bits2FaceDiag), 4, 0, 6, 2, 5, 1, 7, 3 },
  899. /*00010101*/{ GTE_MC_ENTRY(Bits3SameFace), 0, 2, 4, 6, 1, 3, 5, 7 },
  900. /*00010110*/{ GTE_MC_ENTRY(Bits3FaceDiagFaceDiag), 2, 0, 3, 1, 6, 4, 7, 5 },
  901. /*00010111*/{ GTE_MC_ENTRY(Bits4FaceEdge), 0, 1, 2, 3, 4, 5, 6, 7 },
  902. /*00011000*/{ GTE_MC_ENTRY(Bits2BoxDiag), 3, 2, 1, 0, 7, 6, 5, 4 },
  903. /*00011001*/{ GTE_MC_ENTRY(Bits3EdgeFaceDiag), 0, 1, 2, 3, 4, 5, 6, 7 },
  904. /*00011010*/{ GTE_MC_ENTRY(Bits3EdgeFaceDiag), 1, 0, 5, 4, 3, 2, 7, 6 },
  905. /*00011011*/{ GTE_MC_ENTRY(Bits4FaceFaceDiagR), 1, 3, 0, 2, 5, 7, 4, 6 },
  906. /*00011100*/{ GTE_MC_ENTRY(Bits3EdgeFaceDiag), 2, 6, 0, 4, 3, 7, 1, 5 },
  907. /*00011101*/{ GTE_MC_ENTRY(Bits4FaceFaceDiagL), 2, 0, 3, 1, 6, 4, 7, 5 },
  908. /*00011110*/{ GTE_MC_ENTRY(Bits4FaceBoxDiag), 3, 2, 1, 0, 7, 6, 5, 4 },
  909. /*00011111*/{ GTE_MC_ENTRY(Bits5SameFace), 7, 5, 6, 4, 3, 1, 2, 0 },
  910. /*00100000*/{ GTE_MC_ENTRY(Bits1), 5, 7, 1, 3, 4, 6, 0, 2 },
  911. /*00100001*/{ GTE_MC_ENTRY(Bits2FaceDiag), 0, 4, 1, 5, 2, 6, 3, 7 },
  912. /*00100010*/{ GTE_MC_ENTRY(Bits2Edge), 5, 1, 4, 0, 7, 3, 6, 2 },
  913. /*00100011*/{ GTE_MC_ENTRY(Bits3SameFace), 1, 0, 5, 4, 3, 2, 7, 6 },
  914. /*00100100*/{ GTE_MC_ENTRY(Bits2BoxDiag), 2, 0, 3, 1, 6, 4, 7, 5 },
  915. /*00100101*/{ GTE_MC_ENTRY(Bits3EdgeFaceDiag), 0, 4, 1, 5, 2, 6, 3, 7 },
  916. /*00100110*/{ GTE_MC_ENTRY(Bits3EdgeFaceDiag), 1, 3, 0, 2, 5, 7, 4, 6 },
  917. /*00100111*/{ GTE_MC_ENTRY(Bits4FaceFaceDiagL), 0, 1, 2, 3, 4, 5, 6, 7 },
  918. /*00101000*/{ GTE_MC_ENTRY(Bits2FaceDiag), 5, 7, 1, 3, 4, 6, 0, 2 },
  919. /*00101001*/{ GTE_MC_ENTRY(Bits3FaceDiagFaceDiag), 0, 1, 2, 3, 4, 5, 6, 7 },
  920. /*00101010*/{ GTE_MC_ENTRY(Bits3SameFace), 1, 5, 3, 7, 0, 4, 2, 6 },
  921. /*00101011*/{ GTE_MC_ENTRY(Bits4FaceEdge), 1, 3, 0, 2, 5, 7, 4, 6 },
  922. /*00101100*/{ GTE_MC_ENTRY(Bits3EdgeFaceDiag), 3, 1, 7, 5, 2, 0, 6, 4 },
  923. /*00101101*/{ GTE_MC_ENTRY(Bits4FaceBoxDiag), 2, 0, 3, 1, 6, 4, 7, 5 },
  924. /*00101110*/{ GTE_MC_ENTRY(Bits4FaceFaceDiagR), 3, 2, 1, 0, 7, 6, 5, 4 },
  925. /*00101111*/{ GTE_MC_ENTRY(Bits5SameFace), 6, 7, 4, 5, 2, 3, 0, 1 },
  926. /*00110000*/{ GTE_MC_ENTRY(Bits2Edge), 4, 5, 0, 1, 6, 7, 2, 3 },
  927. /*00110001*/{ GTE_MC_ENTRY(Bits3SameFace), 4, 5, 0, 1, 6, 7, 2, 3 },
  928. /*00110010*/{ GTE_MC_ENTRY(Bits3SameFace), 5, 1, 4, 0, 7, 3, 6, 2 },
  929. /*00110011*/{ GTE_MC_ENTRY(Bits4SameFace), 0, 4, 1, 5, 2, 6, 3, 7 },
  930. /*00110100*/{ GTE_MC_ENTRY(Bits3EdgeFaceDiag), 4, 0, 6, 2, 5, 1, 7, 3 },
  931. /*00110101*/{ GTE_MC_ENTRY(Bits4FaceFaceDiagR), 0, 2, 4, 6, 1, 3, 5, 7 },
  932. /*00110110*/{ GTE_MC_ENTRY(Bits4FaceBoxDiag), 5, 1, 4, 0, 7, 3, 6, 2 },
  933. /*00110111*/{ GTE_MC_ENTRY(Bits5SameFace), 7, 6, 3, 2, 5, 4, 1, 0 },
  934. /*00111000*/{ GTE_MC_ENTRY(Bits3EdgeFaceDiag), 5, 7, 1, 3, 4, 6, 0, 2 },
  935. /*00111001*/{ GTE_MC_ENTRY(Bits4FaceBoxDiag), 4, 5, 0, 1, 6, 7, 2, 3 },
  936. /*00111010*/{ GTE_MC_ENTRY(Bits4FaceFaceDiagL), 5, 1, 4, 0, 7, 3, 6, 2 },
  937. /*00111011*/{ GTE_MC_ENTRY(Bits5SameFace), 6, 2, 7, 3, 4, 0, 5, 1 },
  938. /*00111100*/{ GTE_MC_ENTRY(Bits4EdgeEdgePara), 3, 2, 1, 0, 7, 6, 5, 4 },
  939. /*00111101*/{ GTE_MC_ENTRY(Bits5EdgeFaceDiag), 7, 3, 5, 1, 6, 2, 4, 0 },
  940. /*00111110*/{ GTE_MC_ENTRY(Bits5EdgeFaceDiag), 6, 4, 2, 0, 7, 5, 3, 1 },
  941. /*00111111*/{ GTE_MC_ENTRY(Bits6Edge), 6, 7, 4, 5, 2, 3, 0, 1 },
  942. /*01000000*/{ GTE_MC_ENTRY(Bits1), 6, 7, 4, 5, 2, 3, 0, 1 },
  943. /*01000001*/{ GTE_MC_ENTRY(Bits2FaceDiag), 0, 2, 4, 6, 1, 3, 5, 7 },
  944. /*01000010*/{ GTE_MC_ENTRY(Bits2BoxDiag), 1, 3, 0, 2, 5, 7, 4, 6 },
  945. /*01000011*/{ GTE_MC_ENTRY(Bits3EdgeFaceDiag), 0, 2, 4, 6, 1, 3, 5, 7 },
  946. /*01000100*/{ GTE_MC_ENTRY(Bits2Edge), 6, 2, 7, 3, 4, 0, 5, 1 },
  947. /*01000101*/{ GTE_MC_ENTRY(Bits3SameFace), 2, 6, 0, 4, 3, 7, 1, 5 },
  948. /*01000110*/{ GTE_MC_ENTRY(Bits3EdgeFaceDiag), 2, 0, 3, 1, 6, 4, 7, 5 },
  949. /*01000111*/{ GTE_MC_ENTRY(Bits4FaceFaceDiagR), 0, 1, 2, 3, 4, 5, 6, 7 },
  950. /*01001000*/{ GTE_MC_ENTRY(Bits2FaceDiag), 3, 7, 2, 6, 1, 5, 0, 4 },
  951. /*01001001*/{ GTE_MC_ENTRY(Bits3FaceDiagFaceDiag), 3, 2, 1, 0, 7, 6, 5, 4 },
  952. /*01001010*/{ GTE_MC_ENTRY(Bits3EdgeFaceDiag), 3, 7, 2, 6, 1, 5, 0, 4 },
  953. /*01001011*/{ GTE_MC_ENTRY(Bits4FaceBoxDiag), 1, 3, 0, 2, 5, 7, 4, 6 },
  954. /*01001100*/{ GTE_MC_ENTRY(Bits3SameFace), 2, 3, 6, 7, 0, 1, 4, 5 },
  955. /*01001101*/{ GTE_MC_ENTRY(Bits4FaceEdge), 2, 0, 3, 1, 6, 4, 7, 5 },
  956. /*01001110*/{ GTE_MC_ENTRY(Bits4FaceFaceDiagL), 3, 2, 1, 0, 7, 6, 5, 4 },
  957. /*01001111*/{ GTE_MC_ENTRY(Bits5SameFace), 5, 4, 7, 6, 1, 0, 3, 2 },
  958. /*01010000*/{ GTE_MC_ENTRY(Bits2Edge), 6, 4, 2, 0, 7, 5, 3, 1 },
  959. /*01010001*/{ GTE_MC_ENTRY(Bits3SameFace), 4, 0, 6, 2, 5, 1, 7, 3 },
  960. /*01010010*/{ GTE_MC_ENTRY(Bits3EdgeFaceDiag), 4, 5, 0, 1, 6, 7, 2, 3 },
  961. /*01010011*/{ GTE_MC_ENTRY(Bits4FaceFaceDiagL), 0, 4, 1, 5, 2, 6, 3, 7 },
  962. /*01010100*/{ GTE_MC_ENTRY(Bits3SameFace), 6, 4, 2, 0, 7, 5, 3, 1 },
  963. /*01010101*/{ GTE_MC_ENTRY(Bits4SameFace), 0, 2, 4, 6, 1, 3, 5, 7 },
  964. /*01010110*/{ GTE_MC_ENTRY(Bits4FaceBoxDiag), 6, 4, 2, 0, 7, 5, 3, 1 },
  965. /*01010111*/{ GTE_MC_ENTRY(Bits5SameFace), 7, 3, 5, 1, 6, 2, 4, 0 },
  966. /*01011000*/{ GTE_MC_ENTRY(Bits3EdgeFaceDiag), 6, 2, 7, 3, 4, 0, 5, 1 },
  967. /*01011001*/{ GTE_MC_ENTRY(Bits4FaceBoxDiag), 4, 0, 6, 2, 5, 1, 7, 3 },
  968. /*01011010*/{ GTE_MC_ENTRY(Bits4EdgeEdgePara), 1, 3, 0, 2, 5, 7, 4, 6 },
  969. /*01011011*/{ GTE_MC_ENTRY(Bits5EdgeFaceDiag), 7, 6, 3, 2, 5, 4, 1, 0 },
  970. /*01011100*/{ GTE_MC_ENTRY(Bits4FaceFaceDiagR), 6, 4, 2, 0, 7, 5, 3, 1 },
  971. /*01011101*/{ GTE_MC_ENTRY(Bits5SameFace), 5, 7, 1, 3, 4, 6, 0, 2 },
  972. /*01011110*/{ GTE_MC_ENTRY(Bits5EdgeFaceDiag), 5, 1, 4, 0, 7, 3, 6, 2 },
  973. /*01011111*/{ GTE_MC_ENTRY(Bits6Edge), 5, 7, 1, 3, 4, 6, 0, 2 },
  974. /*01100000*/{ GTE_MC_ENTRY(Bits2FaceDiag), 5, 4, 7, 6, 1, 0, 3, 2 },
  975. /*01100001*/{ GTE_MC_ENTRY(Bits3FaceDiagFaceDiag), 5, 4, 7, 6, 1, 0, 3, 2 },
  976. /*01100010*/{ GTE_MC_ENTRY(Bits3EdgeFaceDiag), 5, 4, 7, 6, 1, 0, 3, 2 },
  977. /*01100011*/{ GTE_MC_ENTRY(Bits4FaceBoxDiag), 1, 0, 5, 4, 3, 2, 7, 6 },
  978. /*01100100*/{ GTE_MC_ENTRY(Bits3EdgeFaceDiag), 6, 7, 4, 5, 2, 3, 0, 1 },
  979. /*01100101*/{ GTE_MC_ENTRY(Bits4FaceBoxDiag), 2, 6, 0, 4, 3, 7, 1, 5 },
  980. /*01100110*/{ GTE_MC_ENTRY(Bits4EdgeEdgePara), 6, 2, 7, 3, 4, 0, 5, 1 },
  981. /*01100111*/{ GTE_MC_ENTRY(Bits5EdgeFaceDiag), 7, 5, 6, 4, 3, 1, 2, 0 },
  982. /*01101000*/{ GTE_MC_ENTRY(Bits3FaceDiagFaceDiag), 6, 7, 4, 5, 2, 3, 0, 1 },
  983. /*01101001*/{ GTE_MC_ENTRY(Bits4EdgeEdgePerp), 0, 1, 2, 3, 4, 5, 6, 7 },
  984. /*01101010*/{ GTE_MC_ENTRY(Bits4FaceBoxDiag), 1, 5, 3, 7, 0, 4, 2, 6 },
  985. /*01101011*/{ GTE_MC_ENTRY(Bits5FaceDiagFaceDiag), 4, 6, 5, 7, 0, 2, 1, 3 },
  986. /*01101100*/{ GTE_MC_ENTRY(Bits4FaceBoxDiag), 2, 3, 6, 7, 0, 1, 4, 5 },
  987. /*01101101*/{ GTE_MC_ENTRY(Bits5FaceDiagFaceDiag), 7, 5, 6, 4, 3, 1, 2, 0 },
  988. /*01101110*/{ GTE_MC_ENTRY(Bits5EdgeFaceDiag), 4, 6, 5, 7, 0, 2, 1, 3 },
  989. /*01101111*/{ GTE_MC_ENTRY(Bits6FaceDiag), 7, 5, 6, 4, 3, 1, 2, 0 },
  990. /*01110000*/{ GTE_MC_ENTRY(Bits3SameFace), 4, 6, 5, 7, 0, 2, 1, 3 },
  991. /*01110001*/{ GTE_MC_ENTRY(Bits4FaceEdge), 4, 6, 5, 7, 0, 2, 1, 3 },
  992. /*01110010*/{ GTE_MC_ENTRY(Bits4FaceFaceDiagR), 5, 1, 4, 0, 7, 3, 6, 2 },
  993. /*01110011*/{ GTE_MC_ENTRY(Bits5SameFace), 3, 7, 2, 6, 1, 5, 0, 4 },
  994. /*01110100*/{ GTE_MC_ENTRY(Bits4FaceFaceDiagL), 4, 6, 5, 7, 0, 2, 1, 3 },
  995. /*01110101*/{ GTE_MC_ENTRY(Bits5SameFace), 3, 1, 7, 5, 2, 0, 6, 4 },
  996. /*01110110*/{ GTE_MC_ENTRY(Bits5EdgeFaceDiag), 3, 2, 1, 0, 7, 6, 5, 4 },
  997. /*01110111*/{ GTE_MC_ENTRY(Bits6Edge), 3, 7, 2, 6, 1, 5, 0, 4 },
  998. /*01111000*/{ GTE_MC_ENTRY(Bits4FaceBoxDiag), 4, 6, 5, 7, 0, 2, 1, 3 },
  999. /*01111001*/{ GTE_MC_ENTRY(Bits5FaceDiagFaceDiag), 1, 3, 0, 2, 5, 7, 4, 6 },
  1000. /*01111010*/{ GTE_MC_ENTRY(Bits5EdgeFaceDiag), 2, 3, 6, 7, 0, 1, 4, 5 },
  1001. /*01111011*/{ GTE_MC_ENTRY(Bits6FaceDiag), 2, 3, 6, 7, 0, 1, 4, 5 },
  1002. /*01111100*/{ GTE_MC_ENTRY(Bits5EdgeFaceDiag), 1, 5, 3, 7, 0, 4, 2, 6 },
  1003. /*01111101*/{ GTE_MC_ENTRY(Bits6FaceDiag), 1, 5, 3, 7, 0, 4, 2, 6 },
  1004. /*01111110*/{ GTE_MC_ENTRY(Bits6BoxDiag), 0, 1, 2, 3, 4, 5, 6, 7 },
  1005. /*01111111*/{ GTE_MC_ENTRY(Bits7), 7, 3, 5, 1, 6, 2, 4, 0 },
  1006. /*10000000*/{ GTE_MC_ENTRY(Bits1), 7, 3, 5, 1, 6, 2, 4, 0 },
  1007. /*10000001*/{ GTE_MC_ENTRY(Bits2BoxDiag), 0, 1, 2, 3, 4, 5, 6, 7 },
  1008. /*10000010*/{ GTE_MC_ENTRY(Bits2FaceDiag), 1, 5, 3, 7, 0, 4, 2, 6 },
  1009. /*10000011*/{ GTE_MC_ENTRY(Bits3EdgeFaceDiag), 1, 5, 3, 7, 0, 4, 2, 6 },
  1010. /*10000100*/{ GTE_MC_ENTRY(Bits2FaceDiag), 2, 3, 6, 7, 0, 1, 4, 5 },
  1011. /*10000101*/{ GTE_MC_ENTRY(Bits3EdgeFaceDiag), 2, 3, 6, 7, 0, 1, 4, 5 },
  1012. /*10000110*/{ GTE_MC_ENTRY(Bits3FaceDiagFaceDiag), 1, 3, 0, 2, 5, 7, 4, 6 },
  1013. /*10000111*/{ GTE_MC_ENTRY(Bits4FaceBoxDiag), 0, 1, 2, 3, 4, 5, 6, 7 },
  1014. /*10001000*/{ GTE_MC_ENTRY(Bits2Edge), 3, 7, 2, 6, 1, 5, 0, 4 },
  1015. /*10001001*/{ GTE_MC_ENTRY(Bits3EdgeFaceDiag), 3, 2, 1, 0, 7, 6, 5, 4 },
  1016. /*10001010*/{ GTE_MC_ENTRY(Bits3SameFace), 3, 1, 7, 5, 2, 0, 6, 4 },
  1017. /*10001011*/{ GTE_MC_ENTRY(Bits4FaceFaceDiagL), 1, 3, 0, 2, 5, 7, 4, 6 },
  1018. /*10001100*/{ GTE_MC_ENTRY(Bits3SameFace), 3, 7, 2, 6, 1, 5, 0, 4 },
  1019. /*10001101*/{ GTE_MC_ENTRY(Bits4FaceFaceDiagR), 2, 0, 3, 1, 6, 4, 7, 5 },
  1020. /*10001110*/{ GTE_MC_ENTRY(Bits4FaceEdge), 3, 2, 1, 0, 7, 6, 5, 4 },
  1021. /*10001111*/{ GTE_MC_ENTRY(Bits5SameFace), 4, 6, 5, 7, 0, 2, 1, 3 },
  1022. /*10010000*/{ GTE_MC_ENTRY(Bits2FaceDiag), 7, 5, 6, 4, 3, 1, 2, 0 },
  1023. /*10010001*/{ GTE_MC_ENTRY(Bits3EdgeFaceDiag), 4, 6, 5, 7, 0, 2, 1, 3 },
  1024. /*10010010*/{ GTE_MC_ENTRY(Bits3FaceDiagFaceDiag), 7, 5, 6, 4, 3, 1, 2, 0 },
  1025. /*10010011*/{ GTE_MC_ENTRY(Bits4FaceBoxDiag), 0, 4, 1, 5, 2, 6, 3, 7 },
  1026. /*10010100*/{ GTE_MC_ENTRY(Bits3FaceDiagFaceDiag), 4, 6, 5, 7, 0, 2, 1, 3 },
  1027. /*10010101*/{ GTE_MC_ENTRY(Bits4FaceBoxDiag), 0, 2, 4, 6, 1, 3, 5, 7 },
  1028. /*10010110*/{ GTE_MC_ENTRY(Bits4EdgeEdgePerp), 1, 3, 0, 2, 5, 7, 4, 6 },
  1029. /*10010111*/{ GTE_MC_ENTRY(Bits5FaceDiagFaceDiag), 6, 7, 4, 5, 2, 3, 0, 1 },
  1030. /*10011000*/{ GTE_MC_ENTRY(Bits3EdgeFaceDiag), 7, 5, 6, 4, 3, 1, 2, 0 },
  1031. /*10011001*/{ GTE_MC_ENTRY(Bits4EdgeEdgePara), 4, 0, 6, 2, 5, 1, 7, 3 },
  1032. /*10011010*/{ GTE_MC_ENTRY(Bits4FaceBoxDiag), 3, 1, 7, 5, 2, 0, 6, 4 },
  1033. /*10011011*/{ GTE_MC_ENTRY(Bits5EdgeFaceDiag), 6, 7, 4, 5, 2, 3, 0, 1 },
  1034. /*10011100*/{ GTE_MC_ENTRY(Bits4FaceBoxDiag), 3, 7, 2, 6, 1, 5, 0, 4 },
  1035. /*10011101*/{ GTE_MC_ENTRY(Bits5EdgeFaceDiag), 5, 4, 7, 6, 1, 0, 3, 2 },
  1036. /*10011110*/{ GTE_MC_ENTRY(Bits5FaceDiagFaceDiag), 5, 4, 7, 6, 1, 0, 3, 2 },
  1037. /*10011111*/{ GTE_MC_ENTRY(Bits6FaceDiag), 5, 4, 7, 6, 1, 0, 3, 2 },
  1038. /*10100000*/{ GTE_MC_ENTRY(Bits2Edge), 5, 7, 1, 3, 4, 6, 0, 2 },
  1039. /*10100001*/{ GTE_MC_ENTRY(Bits3EdgeFaceDiag), 5, 1, 4, 0, 7, 3, 6, 2 },
  1040. /*10100010*/{ GTE_MC_ENTRY(Bits3SameFace), 5, 7, 1, 3, 4, 6, 0, 2 },
  1041. /*10100011*/{ GTE_MC_ENTRY(Bits4FaceFaceDiagR), 1, 0, 5, 4, 3, 2, 7, 6 },
  1042. /*10100100*/{ GTE_MC_ENTRY(Bits3EdgeFaceDiag), 7, 6, 3, 2, 5, 4, 1, 0 },
  1043. /*10100101*/{ GTE_MC_ENTRY(Bits4EdgeEdgePara), 2, 0, 3, 1, 6, 4, 7, 5 },
  1044. /*10100110*/{ GTE_MC_ENTRY(Bits4FaceBoxDiag), 5, 7, 1, 3, 4, 6, 0, 2 },
  1045. /*10100111*/{ GTE_MC_ENTRY(Bits5EdgeFaceDiag), 6, 2, 7, 3, 4, 0, 5, 1 },
  1046. /*10101000*/{ GTE_MC_ENTRY(Bits3SameFace), 7, 3, 5, 1, 6, 2, 4, 0 },
  1047. /*10101001*/{ GTE_MC_ENTRY(Bits4FaceBoxDiag), 7, 3, 5, 1, 6, 2, 4, 0 },
  1048. /*10101010*/{ GTE_MC_ENTRY(Bits4SameFace), 1, 5, 3, 7, 0, 4, 2, 6 },
  1049. /*10101011*/{ GTE_MC_ENTRY(Bits5SameFace), 6, 4, 2, 0, 7, 5, 3, 1 },
  1050. /*10101100*/{ GTE_MC_ENTRY(Bits4FaceFaceDiagL), 3, 7, 2, 6, 1, 5, 0, 4 },
  1051. /*10101101*/{ GTE_MC_ENTRY(Bits5EdgeFaceDiag), 4, 5, 0, 1, 6, 7, 2, 3 },
  1052. /*10101110*/{ GTE_MC_ENTRY(Bits5SameFace), 4, 0, 6, 2, 5, 1, 7, 3 },
  1053. /*10101111*/{ GTE_MC_ENTRY(Bits6Edge), 6, 4, 2, 0, 7, 5, 3, 1 },
  1054. /*10110000*/{ GTE_MC_ENTRY(Bits3SameFace), 5, 4, 7, 6, 1, 0, 3, 2 },
  1055. /*10110001*/{ GTE_MC_ENTRY(Bits4FaceFaceDiagL), 4, 5, 0, 1, 6, 7, 2, 3 },
  1056. /*10110010*/{ GTE_MC_ENTRY(Bits4FaceEdge), 5, 1, 4, 0, 7, 3, 6, 2 },
  1057. /*10110011*/{ GTE_MC_ENTRY(Bits5SameFace), 2, 3, 6, 7, 0, 1, 4, 5 },
  1058. /*10110100*/{ GTE_MC_ENTRY(Bits4FaceBoxDiag), 5, 4, 7, 6, 1, 0, 3, 2 },
  1059. /*10110101*/{ GTE_MC_ENTRY(Bits5EdgeFaceDiag), 3, 7, 2, 6, 1, 5, 0, 4 },
  1060. /*10110110*/{ GTE_MC_ENTRY(Bits5FaceDiagFaceDiag), 3, 2, 1, 0, 7, 6, 5, 4 },
  1061. /*10110111*/{ GTE_MC_ENTRY(Bits6FaceDiag), 3, 7, 2, 6, 1, 5, 0, 4 },
  1062. /*10111000*/{ GTE_MC_ENTRY(Bits4FaceFaceDiagR), 7, 3, 5, 1, 6, 2, 4, 0 },
  1063. /*10111001*/{ GTE_MC_ENTRY(Bits5EdgeFaceDiag), 2, 0, 3, 1, 6, 4, 7, 5 },
  1064. /*10111010*/{ GTE_MC_ENTRY(Bits5SameFace), 2, 6, 0, 4, 3, 7, 1, 5 },
  1065. /*10111011*/{ GTE_MC_ENTRY(Bits6Edge), 6, 2, 7, 3, 4, 0, 5, 1 },
  1066. /*10111100*/{ GTE_MC_ENTRY(Bits5EdgeFaceDiag), 0, 2, 4, 6, 1, 3, 5, 7 },
  1067. /*10111101*/{ GTE_MC_ENTRY(Bits6BoxDiag), 1, 3, 0, 2, 5, 7, 4, 6 },
  1068. /*10111110*/{ GTE_MC_ENTRY(Bits6FaceDiag), 0, 2, 4, 6, 1, 3, 5, 7 },
  1069. /*10111111*/{ GTE_MC_ENTRY(Bits7), 6, 7, 4, 5, 2, 3, 0, 1 },
  1070. /*11000000*/{ GTE_MC_ENTRY(Bits2Edge), 6, 7, 4, 5, 2, 3, 0, 1 },
  1071. /*11000001*/{ GTE_MC_ENTRY(Bits3EdgeFaceDiag), 6, 4, 2, 0, 7, 5, 3, 1 },
  1072. /*11000010*/{ GTE_MC_ENTRY(Bits3EdgeFaceDiag), 7, 3, 5, 1, 6, 2, 4, 0 },
  1073. /*11000011*/{ GTE_MC_ENTRY(Bits4EdgeEdgePara), 0, 1, 2, 3, 4, 5, 6, 7 },
  1074. /*11000100*/{ GTE_MC_ENTRY(Bits3SameFace), 6, 2, 7, 3, 4, 0, 5, 1 },
  1075. /*11000101*/{ GTE_MC_ENTRY(Bits4FaceFaceDiagL), 2, 6, 0, 4, 3, 7, 1, 5 },
  1076. /*11000110*/{ GTE_MC_ENTRY(Bits4FaceBoxDiag), 6, 2, 7, 3, 4, 0, 5, 1 },
  1077. /*11000111*/{ GTE_MC_ENTRY(Bits5EdgeFaceDiag), 5, 7, 1, 3, 4, 6, 0, 2 },
  1078. /*11001000*/{ GTE_MC_ENTRY(Bits3SameFace), 7, 6, 3, 2, 5, 4, 1, 0 },
  1079. /*11001001*/{ GTE_MC_ENTRY(Bits4FaceBoxDiag), 7, 6, 3, 2, 5, 4, 1, 0 },
  1080. /*11001010*/{ GTE_MC_ENTRY(Bits4FaceFaceDiagR), 7, 6, 3, 2, 5, 4, 1, 0 },
  1081. /*11001011*/{ GTE_MC_ENTRY(Bits5EdgeFaceDiag), 4, 0, 6, 2, 5, 1, 7, 3 },
  1082. /*11001100*/{ GTE_MC_ENTRY(Bits4SameFace), 2, 3, 6, 7, 0, 1, 4, 5 },
  1083. /*11001101*/{ GTE_MC_ENTRY(Bits5SameFace), 5, 1, 4, 0, 7, 3, 6, 2 },
  1084. /*11001110*/{ GTE_MC_ENTRY(Bits5SameFace), 4, 5, 0, 1, 6, 7, 2, 3 },
  1085. /*11001111*/{ GTE_MC_ENTRY(Bits6Edge), 4, 5, 0, 1, 6, 7, 2, 3 },
  1086. /*11010000*/{ GTE_MC_ENTRY(Bits3SameFace), 6, 7, 4, 5, 2, 3, 0, 1 },
  1087. /*11010001*/{ GTE_MC_ENTRY(Bits4FaceFaceDiagR), 4, 0, 6, 2, 5, 1, 7, 3 },
  1088. /*11010010*/{ GTE_MC_ENTRY(Bits4FaceBoxDiag), 6, 7, 4, 5, 2, 3, 0, 1 },
  1089. /*11010011*/{ GTE_MC_ENTRY(Bits5EdgeFaceDiag), 3, 1, 7, 5, 2, 0, 6, 4 },
  1090. /*11010100*/{ GTE_MC_ENTRY(Bits4FaceEdge), 6, 4, 2, 0, 7, 5, 3, 1 },
  1091. /*11010101*/{ GTE_MC_ENTRY(Bits5SameFace), 1, 5, 3, 7, 0, 4, 2, 6 },
  1092. /*11010110*/{ GTE_MC_ENTRY(Bits5FaceDiagFaceDiag), 0, 1, 2, 3, 4, 5, 6, 7 },
  1093. /*11010111*/{ GTE_MC_ENTRY(Bits6FaceDiag), 5, 7, 1, 3, 4, 6, 0, 2 },
  1094. /*11011000*/{ GTE_MC_ENTRY(Bits4FaceFaceDiagL), 6, 7, 4, 5, 2, 3, 0, 1 },
  1095. /*11011001*/{ GTE_MC_ENTRY(Bits5EdgeFaceDiag), 1, 3, 0, 2, 5, 7, 4, 6 },
  1096. /*11011010*/{ GTE_MC_ENTRY(Bits5EdgeFaceDiag), 0, 4, 1, 5, 2, 6, 3, 7 },
  1097. /*11011011*/{ GTE_MC_ENTRY(Bits6BoxDiag), 2, 0, 3, 1, 6, 4, 7, 5 },
  1098. /*11011100*/{ GTE_MC_ENTRY(Bits5SameFace), 1, 0, 5, 4, 3, 2, 7, 6 },
  1099. /*11011101*/{ GTE_MC_ENTRY(Bits6Edge), 5, 1, 4, 0, 7, 3, 6, 2 },
  1100. /*11011110*/{ GTE_MC_ENTRY(Bits6FaceDiag), 0, 4, 1, 5, 2, 6, 3, 7 },
  1101. /*11011111*/{ GTE_MC_ENTRY(Bits7), 5, 7, 1, 3, 4, 6, 0, 2 },
  1102. /*11100000*/{ GTE_MC_ENTRY(Bits3SameFace), 7, 5, 6, 4, 3, 1, 2, 0 },
  1103. /*11100001*/{ GTE_MC_ENTRY(Bits4FaceBoxDiag), 7, 5, 6, 4, 3, 1, 2, 0 },
  1104. /*11100010*/{ GTE_MC_ENTRY(Bits4FaceFaceDiagL), 7, 5, 6, 4, 3, 1, 2, 0 },
  1105. /*11100011*/{ GTE_MC_ENTRY(Bits5EdgeFaceDiag), 2, 6, 0, 4, 3, 7, 1, 5 },
  1106. /*11100100*/{ GTE_MC_ENTRY(Bits4FaceFaceDiagR), 7, 5, 6, 4, 3, 1, 2, 0 },
  1107. /*11100101*/{ GTE_MC_ENTRY(Bits5EdgeFaceDiag), 1, 0, 5, 4, 3, 2, 7, 6 },
  1108. /*11100110*/{ GTE_MC_ENTRY(Bits5EdgeFaceDiag), 0, 1, 2, 3, 4, 5, 6, 7 },
  1109. /*11100111*/{ GTE_MC_ENTRY(Bits6BoxDiag), 3, 2, 1, 0, 7, 6, 5, 4 },
  1110. /*11101000*/{ GTE_MC_ENTRY(Bits4FaceEdge), 7, 5, 6, 4, 3, 1, 2, 0 },
  1111. /*11101001*/{ GTE_MC_ENTRY(Bits5FaceDiagFaceDiag), 2, 0, 3, 1, 6, 4, 7, 5 },
  1112. /*11101010*/{ GTE_MC_ENTRY(Bits5SameFace), 0, 2, 4, 6, 1, 3, 5, 7 },
  1113. /*11101011*/{ GTE_MC_ENTRY(Bits6FaceDiag), 4, 0, 6, 2, 5, 1, 7, 3 },
  1114. /*11101100*/{ GTE_MC_ENTRY(Bits5SameFace), 0, 4, 1, 5, 2, 6, 3, 7 },
  1115. /*11101101*/{ GTE_MC_ENTRY(Bits6FaceDiag), 1, 0, 5, 4, 3, 2, 7, 6 },
  1116. /*11101110*/{ GTE_MC_ENTRY(Bits6Edge), 4, 0, 6, 2, 5, 1, 7, 3 },
  1117. /*11101111*/{ GTE_MC_ENTRY(Bits7), 4, 5, 0, 1, 6, 7, 2, 3 },
  1118. /*11110000*/{ GTE_MC_ENTRY(Bits4SameFace), 4, 6, 5, 7, 0, 2, 1, 3 },
  1119. /*11110001*/{ GTE_MC_ENTRY(Bits5SameFace), 3, 2, 1, 0, 7, 6, 5, 4 },
  1120. /*11110010*/{ GTE_MC_ENTRY(Bits5SameFace), 2, 0, 3, 1, 6, 4, 7, 5 },
  1121. /*11110011*/{ GTE_MC_ENTRY(Bits6Edge), 3, 2, 1, 0, 7, 6, 5, 4 },
  1122. /*11110100*/{ GTE_MC_ENTRY(Bits5SameFace), 1, 3, 0, 2, 5, 7, 4, 6 },
  1123. /*11110101*/{ GTE_MC_ENTRY(Bits6Edge), 1, 3, 0, 2, 5, 7, 4, 6 },
  1124. /*11110110*/{ GTE_MC_ENTRY(Bits6FaceDiag), 0, 1, 2, 3, 4, 5, 6, 7 },
  1125. /*11110111*/{ GTE_MC_ENTRY(Bits7), 3, 2, 1, 0, 7, 6, 5, 4 },
  1126. /*11111000*/{ GTE_MC_ENTRY(Bits5SameFace), 0, 1, 2, 3, 4, 5, 6, 7 },
  1127. /*11111001*/{ GTE_MC_ENTRY(Bits6FaceDiag), 1, 3, 0, 2, 5, 7, 4, 6 },
  1128. /*11111010*/{ GTE_MC_ENTRY(Bits6Edge), 2, 0, 3, 1, 6, 4, 7, 5 },
  1129. /*11111011*/{ GTE_MC_ENTRY(Bits7), 2, 0, 3, 1, 6, 4, 7, 5 },
  1130. /*11111100*/{ GTE_MC_ENTRY(Bits6Edge), 0, 1, 2, 3, 4, 5, 6, 7 },
  1131. /*11111101*/{ GTE_MC_ENTRY(Bits7), 1, 3, 0, 2, 5, 7, 4, 6 },
  1132. /*11111110*/{ GTE_MC_ENTRY(Bits7), 0, 1, 2, 3, 4, 5, 6, 7 },
  1133. /*11111111*/{ GTE_MC_ENTRY(Bits0), 0, 1, 2, 3, 4, 5, 6, 7 }
  1134. }};
  1135. return configuration;
  1136. }
  1137. static std::array<std::string, CT_NUM_TYPES>& ConfigurationString()
  1138. {
  1139. static std::array<std::string, CT_NUM_TYPES> configurationString =
  1140. {
  1141. "Bits0",
  1142. "Bits1",
  1143. "Bits7",
  1144. "Bits2Edge",
  1145. "Bits6Edge",
  1146. "Bits2FaceDiag",
  1147. "Bits6FaceDiag",
  1148. "Bits2BoxDiag",
  1149. "Bits6BoxDiag",
  1150. "Bits3SameFace",
  1151. "Bits5SameFace",
  1152. "Bits3EdgeFaceDiag",
  1153. "Bits5EdgeFaceDiag",
  1154. "Bits3FaceDiagFaceDiag",
  1155. "Bits5FaceDiagFaceDiag",
  1156. "Bits4SameFace",
  1157. "Bits4FaceEdge",
  1158. "Bits4FaceFaceDiagL",
  1159. "Bits4FaceFaceDiagR",
  1160. "Bits4FaceBoxDiag",
  1161. "Bits4EdgeEdgePara",
  1162. "Bits4EdgeEdgePerp"
  1163. };
  1164. return configurationString;
  1165. }
  1166. };
  1167. }