From 7fe28e09e9476cb0c97e5af42d2f85b1b152c293 Mon Sep 17 00:00:00 2001 From: gjj Date: Wed, 16 Oct 2024 20:57:57 +0800 Subject: [PATCH] test --- algoim/organizer/default_halton_prime.inl | 82 ++ algoim/organizer/halton_algoim.hpp | 124 +++ algoim/organizer/loader.hpp | 38 +- algoim/organizer/organizer.hpp | 95 ++- algoim/organizer/quadratureMC.hpp | 0 algoim/quadrature_multipoly.hpp | 33 +- examples/example_loader.cpp | 869 +++++++++++++++++++++- examples/example_loader2.hpp | 48 +- 8 files changed, 1228 insertions(+), 61 deletions(-) create mode 100644 algoim/organizer/default_halton_prime.inl create mode 100644 algoim/organizer/halton_algoim.hpp create mode 100644 algoim/organizer/quadratureMC.hpp diff --git a/algoim/organizer/default_halton_prime.inl b/algoim/organizer/default_halton_prime.inl new file mode 100644 index 0000000..042e58f --- /dev/null +++ b/algoim/organizer/default_halton_prime.inl @@ -0,0 +1,82 @@ +2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, +131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, +269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, +421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521, 523, 541, 547, 557, 563, 569, 571, 577, +587, 593, 599, 601, 607, 613, 617, 619, 631, 641, 643, 647, 653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727, 733, 739, +743, 751, 757, 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829, 839, 853, 857, 859, 863, 877, 881, 883, 887, 907, 911, +919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997, 1009, 1013, 1019, 1021, 1031, 1033, 1039, 1049, 1051, 1061, +1063, 1069, 1087, 1091, 1093, 1097, 1103, 1109, 1117, 1123, 1129, 1151, 1153, 1163, 1171, 1181, 1187, 1193, 1201, 1213, +1217, 1223, 1229, 1231, 1237, 1249, 1259, 1277, 1279, 1283, 1289, 1291, 1297, 1301, 1303, 1307, 1319, 1321, 1327, 1361, +1367, 1373, 1381, 1399, 1409, 1423, 1427, 1429, 1433, 1439, 1447, 1451, 1453, 1459, 1471, 1481, 1483, 1487, 1489, 1493, +1499, 1511, 1523, 1531, 1543, 1549, 1553, 1559, 1567, 1571, 1579, 1583, 1597, 1601, 1607, 1609, 1613, 1619, 1621, 1627, +1637, 1657, 1663, 1667, 1669, 1693, 1697, 1699, 1709, 1721, 1723, 1733, 1741, 1747, 1753, 1759, 1777, 1783, 1787, 1789, +1801, 1811, 1823, 1831, 1847, 1861, 1867, 1871, 1873, 1877, 1879, 1889, 1901, 1907, 1913, 1931, 1933, 1949, 1951, 1973, +1979, 1987, 1993, 1997, 1999, 2003, 2011, 2017, 2027, 2029, 2039, 2053, 2063, 2069, 2081, 2083, 2087, 2089, 2099, 2111, +2113, 2129, 2131, 2137, 2141, 2143, 2153, 2161, 2179, 2203, 2207, 2213, 2221, 2237, 2239, 2243, 2251, 2267, 2269, 2273, +2281, 2287, 2293, 2297, 2309, 2311, 2333, 2339, 2341, 2347, 2351, 2357, 2371, 2377, 2381, 2383, 2389, 2393, 2399, 2411, +2417, 2423, 2437, 2441, 2447, 2459, 2467, 2473, 2477, 2503, 2521, 2531, 2539, 2543, 2549, 2551, 2557, 2579, 2591, 2593, +2609, 2617, 2621, 2633, 2647, 2657, 2659, 2663, 2671, 2677, 2683, 2687, 2689, 2693, 2699, 2707, 2711, 2713, 2719, 2729, +2731, 2741, 2749, 2753, 2767, 2777, 2789, 2791, 2797, 2801, 2803, 2819, 2833, 2837, 2843, 2851, 2857, 2861, 2879, 2887, +2897, 2903, 2909, 2917, 2927, 2939, 2953, 2957, 2963, 2969, 2971, 2999, 3001, 3011, 3019, 3023, 3037, 3041, 3049, 3061, +3067, 3079, 3083, 3089, 3109, 3119, 3121, 3137, 3163, 3167, 3169, 3181, 3187, 3191, 3203, 3209, 3217, 3221, 3229, 3251, +3253, 3257, 3259, 3271, 3299, 3301, 3307, 3313, 3319, 3323, 3329, 3331, 3343, 3347, 3359, 3361, 3371, 3373, 3389, 3391, +3407, 3413, 3433, 3449, 3457, 3461, 3463, 3467, 3469, 3491, 3499, 3511, 3517, 3527, 3529, 3533, 3539, 3541, 3547, 3557, +3559, 3571, 3581, 3583, 3593, 3607, 3613, 3617, 3623, 3631, 3637, 3643, 3659, 3671, 3673, 3677, 3691, 3697, 3701, 3709, +3719, 3727, 3733, 3739, 3761, 3767, 3769, 3779, 3793, 3797, 3803, 3821, 3823, 3833, 3847, 3851, 3853, 3863, 3877, 3881, +3889, 3907, 3911, 3917, 3919, 3923, 3929, 3931, 3943, 3947, 3967, 3989, 4001, 4003, 4007, 4013, 4019, 4021, 4027, 4049, +4051, 4057, 4073, 4079, 4091, 4093, 4099, 4111, 4127, 4129, 4133, 4139, 4153, 4157, 4159, 4177, 4201, 4211, 4217, 4219, +4229, 4231, 4241, 4243, 4253, 4259, 4261, 4271, 4273, 4283, 4289, 4297, 4327, 4337, 4339, 4349, 4357, 4363, 4373, 4391, +4397, 4409, 4421, 4423, 4441, 4447, 4451, 4457, 4463, 4481, 4483, 4493, 4507, 4513, 4517, 4519, 4523, 4547, 4549, 4561, +4567, 4583, 4591, 4597, 4603, 4621, 4637, 4639, 4643, 4649, 4651, 4657, 4663, 4673, 4679, 4691, 4703, 4721, 4723, 4729, +4733, 4751, 4759, 4783, 4787, 4789, 4793, 4799, 4801, 4813, 4817, 4831, 4861, 4871, 4877, 4889, 4903, 4909, 4919, 4931, +4933, 4937, 4943, 4951, 4957, 4967, 4969, 4973, 4987, 4993, 4999, 5003, 5009, 5011, 5021, 5023, 5039, 5051, 5059, 5077, +5081, 5087, 5099, 5101, 5107, 5113, 5119, 5147, 5153, 5167, 5171, 5179, 5189, 5197, 5209, 5227, 5231, 5233, 5237, 5261, +5273, 5279, 5281, 5297, 5303, 5309, 5323, 5333, 5347, 5351, 5381, 5387, 5393, 5399, 5407, 5413, 5417, 5419, 5431, 5437, +5441, 5443, 5449, 5471, 5477, 5479, 5483, 5501, 5503, 5507, 5519, 5521, 5527, 5531, 5557, 5563, 5569, 5573, 5581, 5591, +5623, 5639, 5641, 5647, 5651, 5653, 5657, 5659, 5669, 5683, 5689, 5693, 5701, 5711, 5717, 5737, 5741, 5743, 5749, 5779, +5783, 5791, 5801, 5807, 5813, 5821, 5827, 5839, 5843, 5849, 5851, 5857, 5861, 5867, 5869, 5879, 5881, 5897, 5903, 5923, +5927, 5939, 5953, 5981, 5987, 6007, 6011, 6029, 6037, 6043, 6047, 6053, 6067, 6073, 6079, 6089, 6091, 6101, 6113, 6121, +6131, 6133, 6143, 6151, 6163, 6173, 6197, 6199, 6203, 6211, 6217, 6221, 6229, 6247, 6257, 6263, 6269, 6271, 6277, 6287, +6299, 6301, 6311, 6317, 6323, 6329, 6337, 6343, 6353, 6359, 6361, 6367, 6373, 6379, 6389, 6397, 6421, 6427, 6449, 6451, +6469, 6473, 6481, 6491, 6521, 6529, 6547, 6551, 6553, 6563, 6569, 6571, 6577, 6581, 6599, 6607, 6619, 6637, 6653, 6659, +6661, 6673, 6679, 6689, 6691, 6701, 6703, 6709, 6719, 6733, 6737, 6761, 6763, 6779, 6781, 6791, 6793, 6803, 6823, 6827, +6829, 6833, 6841, 6857, 6863, 6869, 6871, 6883, 6899, 6907, 6911, 6917, 6947, 6949, 6959, 6961, 6967, 6971, 6977, 6983, +6991, 6997, 7001, 7013, 7019, 7027, 7039, 7043, 7057, 7069, 7079, 7103, 7109, 7121, 7127, 7129, 7151, 7159, 7177, 7187, +7193, 7207, 7211, 7213, 7219, 7229, 7237, 7243, 7247, 7253, 7283, 7297, 7307, 7309, 7321, 7331, 7333, 7349, 7351, 7369, +7393, 7411, 7417, 7433, 7451, 7457, 7459, 7477, 7481, 7487, 7489, 7499, 7507, 7517, 7523, 7529, 7537, 7541, 7547, 7549, +7559, 7561, 7573, 7577, 7583, 7589, 7591, 7603, 7607, 7621, 7639, 7643, 7649, 7669, 7673, 7681, 7687, 7691, 7699, 7703, +7717, 7723, 7727, 7741, 7753, 7757, 7759, 7789, 7793, 7817, 7823, 7829, 7841, 7853, 7867, 7873, 7877, 7879, 7883, 7901, +7907, 7919, 7927, 7933, 7937, 7949, 7951, 7963, 7993, 8009, 8011, 8017, 8039, 8053, 8059, 8069, 8081, 8087, 8089, 8093, +8101, 8111, 8117, 8123, 8147, 8161, 8167, 8171, 8179, 8191, 8209, 8219, 8221, 8231, 8233, 8237, 8243, 8263, 8269, 8273, +8287, 8291, 8293, 8297, 8311, 8317, 8329, 8353, 8363, 8369, 8377, 8387, 8389, 8419, 8423, 8429, 8431, 8443, 8447, 8461, +8467, 8501, 8513, 8521, 8527, 8537, 8539, 8543, 8563, 8573, 8581, 8597, 8599, 8609, 8623, 8627, 8629, 8641, 8647, 8663, +8669, 8677, 8681, 8689, 8693, 8699, 8707, 8713, 8719, 8731, 8737, 8741, 8747, 8753, 8761, 8779, 8783, 8803, 8807, 8819, +8821, 8831, 8837, 8839, 8849, 8861, 8863, 8867, 8887, 8893, 8923, 8929, 8933, 8941, 8951, 8963, 8969, 8971, 8999, 9001, +9007, 9011, 9013, 9029, 9041, 9043, 9049, 9059, 9067, 9091, 9103, 9109, 9127, 9133, 9137, 9151, 9157, 9161, 9173, 9181, +9187, 9199, 9203, 9209, 9221, 9227, 9239, 9241, 9257, 9277, 9281, 9283, 9293, 9311, 9319, 9323, 9337, 9341, 9343, 9349, +9371, 9377, 9391, 9397, 9403, 9413, 9419, 9421, 9431, 9433, 9437, 9439, 9461, 9463, 9467, 9473, 9479, 9491, 9497, 9511, +9521, 9533, 9539, 9547, 9551, 9587, 9601, 9613, 9619, 9623, 9629, 9631, 9643, 9649, 9661, 9677, 9679, 9689, 9697, 9719, +9721, 9733, 9739, 9743, 9749, 9767, 9769, 9781, 9787, 9791, 9803, 9811, 9817, 9829, 9833, 9839, 9851, 9857, 9859, 9871, +9883, 9887, 9901, 9907, 9923, 9929, 9931, 9941, 9949, 9967, 9973, 10007, 10009, 10037, 10039, 10061, 10067, 10069, 10079, +10091, 10093, 10099, 10103, 10111, 10133, 10139, 10141, 10151, 10159, 10163, 10169, 10177, 10181, 10193, 10211, 10223, +10243, 10247, 10253, 10259, 10267, 10271, 10273, 10289, 10301, 10303, 10313, 10321, 10331, 10333, 10337, 10343, 10357, +10369, 10391, 10399, 10427, 10429, 10433, 10453, 10457, 10459, 10463, 10477, 10487, 10499, 10501, 10513, 10529, 10531, +10559, 10567, 10589, 10597, 10601, 10607, 10613, 10627, 10631, 10639, 10651, 10657, 10663, 10667, 10687, 10691, 10709, +10711, 10723, 10729, 10733, 10739, 10753, 10771, 10781, 10789, 10799, 10831, 10837, 10847, 10853, 10859, 10861, 10867, +10883, 10889, 10891, 10903, 10909, 10937, 10939, 10949, 10957, 10973, 10979, 10987, 10993, 11003, 11027, 11047, 11057, +11059, 11069, 11071, 11083, 11087, 11093, 11113, 11117, 11119, 11131, 11149, 11159, 11161, 11171, 11173, 11177, 11197, +11213, 11239, 11243, 11251, 11257, 11261, 11273, 11279, 11287, 11299, 11311, 11317, 11321, 11329, 11351, 11353, 11369, +11383, 11393, 11399, 11411, 11423, 11437, 11443, 11447, 11467, 11471, 11483, 11489, 11491, 11497, 11503, 11519, 11527, +11549, 11551, 11579, 11587, 11593, 11597, 11617, 11621, 11633, 11657, 11677, 11681, 11689, 11699, 11701, 11717, 11719, +11731, 11743, 11777, 11779, 11783, 11789, 11801, 11807, 11813, 11821, 11827, 11831, 11833, 11839, 11863, 11867, 11887, +11897, 11903, 11909, 11923, 11927, 11933, 11939, 11941, 11953, 11959, 11969, 11971, 11981, 11987, 12007, 12011, 12037, +12041, 12043, 12049, 12071, 12073, 12097, 12101, 12107, 12109, 12113, 12119, 12143, 12149, 12157, 12161, 12163, 12197, +12203, 12211, 12227, 12239, 12241, 12251, 12253, 12263, 12269, 12277, 12281, 12289, 12301, 12323, 12329, 12343, 12347, +12373, 12377, 12379, 12391, 12401, 12409, 12413, 12421, 12433, 12437, 12451, 12457, 12473, 12479, 12487, 12491, 12497, +12503, 12511, 12517, 12527, 12539, 12541, 12547, 12553, 12569, 12577, 12583, 12589, 12601, 12611, 12613, 12619, 12637, +12641, 12647, 12653, 12659, 12671, 12689, 12697, 12703, 12713, 12721, 12739, 12743, 12757, 12763, 12781, 12791, 12799, +12809, 12821, 12823, 12829, 12841, 12853, 12889, 12893, 12899, 12907, 12911, 12917, 12919, 12923, 12941, 12953, 12959, +12967, 12973, 12979, 12983, 13001, 13003, 13007, 13009, 13033, 13037, 13043, 13049, 13063, 13093, 13099, 13103, 13109, +13121, 13127, 13147, 13151, 13159, 13163, 13171, 13177, 13183, 13187, 13217, 13219, 13229, 13241, 13249, 13259, 13267, +13291, 13297, 13309, 13313, 13327, 13331, 13337, 13339, 13367, 13381, 13397, 13399, 13411, 13417, 13421, 13441, 13451, +13457, 13463, 13469, 13477, 13487, 13499 \ No newline at end of file diff --git a/algoim/organizer/halton_algoim.hpp b/algoim/organizer/halton_algoim.hpp new file mode 100644 index 0000000..d0c68a6 --- /dev/null +++ b/algoim/organizer/halton_algoim.hpp @@ -0,0 +1,124 @@ +/** + * @file halton.hpp + * @author Wang Zhicheng (modified from John Burkardt's) + * @brief Halton sequence generator + * @attention + * 1. This code is modified from John Burkardt's code (https://people.sc.fsu.edu/~jburkardt/cpp_src/halton/halton.html) \n + * 2. The original code is under the MIT license. \n + * 3. The modified code is under the same license as the original code. \n + * 4. Reference: \n + * John Halton, \n + * On the efficiency of certain quasi-random sequences of points \n + * in evaluating multi-dimensional integrals, \n + * Numerische Mathematik, \n + * Volume 2, pages 84-90, 1960. \n \n + * Milton Abramowitz, Irene Stegun, \n + * Handbook of Mathematical Functions, \n + * US Department of Commerce, 1964, \n + * ISBN: 0-486-61272-4, \n + * LC: QA47.A34. \n \n + * Daniel Zwillinger, \n + * CRC Standard Mathematical Tables and Formulae, \n + * 30th Edition, \n + * CRC Press, 1996, pages 95-98. + */ +#pragma once + +#include +#include +#include + +#include "uvector.hpp" + +static constexpr size_t g_prime_max = 1600; +static constexpr int32_t g_npvec[g_prime_max]{ +#include "default_halton_prime.inl" +}; + +/** + * @brief PRIME returns any of the first PRIME_MAX prime numbers. + * @note + PRIME_MAX is 1600, and the largest prime stored is 13499. \n + Thanks to Bart Vandewoestyne for pointing out a typo, 18 February 2005. + * @param[in] n + * the index of the desired prime number. In general, is should be true that 0 <= N <= PRIME_MAX. \n + * N = -1 returns PRIME_MAX, the index of the largest prime available. \n + * N = 0 is legal, returning PRIME = 1. + * @return the N-th prime. If N is out of range, PRIME is returned as -1. + */ +static int32_t prime(size_t n) noexcept +{ + if (n > g_prime_max) std::cerr << "Fatal: PRIME - Unexpected input value of n = " << n << std::endl; + return g_npvec[std::max(n - 1, size_t{0})]; +} + +static constexpr int32_t prime_guaranteed(size_t n) noexcept { return g_npvec[n - 1]; } + +static constexpr int32_t* prime_guaranteed_ptr(size_t n) noexcept { return (int32_t*)&g_npvec[n - 1]; } + +/** + * @brief HALTON computes an element of a Halton sequence. + * @param[in] i the index of the element to compute (i >= 0). + * @param[in] m the spatial dimension. + * @return the element of the sequence with index I. + */ +template +auto halton(size_t i) noexcept +{ + // Map> r(&*d_first); + // Map> prime(prime_guaranteed_ptr(1)); + // Vector prime_inv_keep, prime_inv; + // Vector t = Vector::Constant(static_cast(i)); + // r.setZero(); + // for (auto i = 0; i < m; ++i) { + // prime_inv_keep[i] = 1.0 / prime_guaranteed(i + 1); + // prime_inv[i] = 1.0 / prime_guaranteed(i + 1); + // } + + algoim::uvector<_Tp, m> res{}; + algoim::uvector<_Tp, m> prime_inv_keep, prime_inv; + algoim::uvector t = static_cast(i); + for (auto i = 0; i < m; ++i) { + prime_inv_keep[i] = 1.0 / prime_guaranteed(i + 1); + prime_inv[i] = prime_inv_keep[i]; + } + + while (algoim::sum(t) > 0) { + for (auto i = 0; i < m; ++i) { + res[i] += prime_inv[i] * (t[i] % prime_guaranteed(i + 1)); + prime_inv[i] *= prime_inv_keep[i]; + t[i] = static_cast(t[i] * prime_inv_keep[i]); + } + } +} + +/** + * @brief HALTON_SEQUENCE computes elements in [i_first, i_last) of a Halton sequence. + * @param[in] i_first the indices of the first element of the sequence. (i_first >= 0). + * @param[in] i_last the indices of the last + 1 element of the sequence. (i_last >= 0). + * @param[in] m the spatial dimension. + * @return the elements of the sequence with indices [i_first, i_last). + */ +template +auto halton_sequence(size_t i_first, size_t i_last) noexcept +{ + const auto n = i_last - i_first; + + std::vector> res(n); + algoim::uvector<_Tp, m> prime_inv, prime_inv_keep; + algoim::uvector t{}; + for (auto i = 0; i < m; ++i) { prime_inv_keep[i] = 1.0 / prime_guaranteed(i + 1); } + for (auto i = 0; i < n; ++i) { + t = static_cast(i + i_first); + prime_inv = prime_inv_keep; + while (algoim::sum(t) > 0) { + for (auto j = 0; j < m; ++j) { + res[i][j] += prime_inv[j] * (t[j] % prime_guaranteed(j + 1)); + prime_inv[j] *= prime_inv_keep[j]; + t[j] = static_cast(t[j] * prime_inv_keep[j]); + } + } + } + + return res; +} \ No newline at end of file diff --git a/algoim/organizer/loader.hpp b/algoim/organizer/loader.hpp index d8d0e14..19a684a 100644 --- a/algoim/organizer/loader.hpp +++ b/algoim/organizer/loader.hpp @@ -262,7 +262,7 @@ public: if (pointNumber == 2) { return addExtrudeWithTwoPoint(points, bulges, extusion); } else { - return addEmpty(); + // return addEmpty(); } /* Get base polygonal column */ @@ -353,9 +353,9 @@ public: for (size_t i = 0; i < base.aabbs.size(); i++) { base.aabbs[i] = base.aabb; } this->m_allVisible.push_back(base); - auto result = this->getAreaAndVolume(this->m_allVisible.size() - 1); - this->m_allArea.push_back(result.first); - this->m_allVolume.push_back(result.second); + // auto result = this->getAreaAndVolume(this->m_allVisible.size() - 1); + // this->m_allArea.push_back(result.first); + // this->m_allVolume.push_back(result.second); return this->m_allVisible.size() - 1; } @@ -399,9 +399,9 @@ public: for (int i = 0; i < 3; i++) { cone.aabbs.push_back(cone.aabb); } this->m_allVisible.push_back(cone); - auto result = this->getAreaAndVolume(this->m_allVisible.size() - 1); - this->m_allArea.push_back(result.first); - this->m_allVolume.push_back(result.second); + // auto result = this->getAreaAndVolume(this->m_allVisible.size() - 1); + // this->m_allArea.push_back(result.first); + // this->m_allVolume.push_back(result.second); return this->m_allVisible.size() - 1; } @@ -429,9 +429,9 @@ public: for (int i = 0; i < 6; i++) { box.aabbs.push_back(box.aabb); } this->m_allVisible.push_back(box); - auto result = this->getAreaAndVolume(this->m_allVisible.size() - 1); - this->m_allArea.push_back(result.first); - this->m_allVolume.push_back(result.second); + // auto result = this->getAreaAndVolume(this->m_allVisible.size() - 1); + // this->m_allArea.push_back(result.first); + // this->m_allVolume.push_back(result.second); return this->m_allVisible.size() - 1; } @@ -473,9 +473,9 @@ public: for (int i = 0; i < 3; i++) { cylinder.aabbs.push_back(cylinder.aabb); } this->m_allVisible.push_back(cylinder); - auto result = this->getAreaAndVolume(this->m_allVisible.size() - 1); - this->m_allArea.push_back(result.first); - this->m_allVolume.push_back(result.second); + // auto result = this->getAreaAndVolume(this->m_allVisible.size() - 1); + // this->m_allArea.push_back(result.first); + // this->m_allVolume.push_back(result.second); return this->m_allVisible.size() - 1; } @@ -508,9 +508,9 @@ public: for (size_t i = 0; i < faces.size(); i++) { mesh.aabbs.push_back(mesh.aabb); } this->m_allVisible.push_back(mesh); - auto result = this->getAreaAndVolume(this->m_allVisible.size() - 1); - this->m_allArea.push_back(result.first); - this->m_allVolume.push_back(result.second); + // auto result = this->getAreaAndVolume(this->m_allVisible.size() - 1); + // this->m_allArea.push_back(result.first); + // this->m_allVolume.push_back(result.second); return this->m_allVisible.size() - 1; } @@ -962,9 +962,9 @@ protected: result = this->intersectNode(result, halfPlane2); this->m_allVisible.push_back(result); - auto result1 = this->getAreaAndVolume(this->m_allVisible.size() - 1); - this->m_allArea.push_back(result1.first); - this->m_allVolume.push_back(result1.second); + // auto result1 = this->getAreaAndVolume(this->m_allVisible.size() - 1); + // this->m_allArea.push_back(result1.first); + // this->m_allVolume.push_back(result1.second); return this->m_allVisible.size() - 1; } diff --git a/algoim/organizer/organizer.hpp b/algoim/organizer/organizer.hpp index 4cdcd1b..0aff8fd 100644 --- a/algoim/organizer/organizer.hpp +++ b/algoim/organizer/organizer.hpp @@ -344,7 +344,7 @@ void buildOcTreeV0(const Scene& scene, int bbb = 1; } const std::vector& polyIntersectIndices = node.polyIntersectIndices; - if (polyIntersectIndices.size() <= 4) { + if (polyIntersectIndices.size() <= 8) { leaves.emplace_back(node); return; } @@ -365,6 +365,11 @@ void buildOcTreeV0(const Scene& scene, return; } + if (depth >= 8) { + leaves.emplace_back(node); + return; + } + // std::array subNodes; std::vector subNodes(CHILD_NUM); // intermediateNodes.resize(lastIdx + 8); @@ -524,10 +529,6 @@ void basicTask(const std::vector>& primitives, in BasicTaskRes basicTask(const Scene& scene, const OcTreeNode& node, int q = 10) { if (node.polyIntersectIndices.size() == 0) { - if (node.blobTree.structure.back().inOut == NODE_IN_OUT_UNKNOWN) { - int aaa = 0; - int bbb = 0; - } assert(node.blobTree.structure.back().inOut != NODE_IN_OUT_UNKNOWN); if (node.blobTree.structure.back().inOut == NODE_IN) { return {node.aabb.volume(), 0}; @@ -541,6 +542,29 @@ BasicTaskRes basicTask(const Scene& scene, const OcTreeNode& node, int q = 10) auto range = node.aabb.size(); std::vector phis; // phis using subcell as [0,1]^3 std::vector*> phiStacks; + + uvector3i numSamples(50, 50, 50); + // if (false) { + if (node.polyIntersectIndices.size() > 0) { + // TODO: 蒙特卡洛 + std::cout << "Monte Carlo 1" << std::endl; + ; + uvector3f interval = range / (numSamples); + int inCnt = 0; + for (int i = 0; i < node.polyIntersectIndices.size(); i++) { + const auto& polyWithinScene = scene.minimalReps[node.polyIntersectIndices[i]].tensor; + phis.emplace_back(tensor3(nullptr, polyWithinScene.ext())); + phiStacks.emplace_back(algoim_spark_alloc_heap(real, phis.back())); + phis[i] = polyWithinScene; // copy, not deCasteljau + } + for (auto i = MultiLoop<3>(0, numSamples); ~i; ++i) { + uvector3f x = i() * interval + node.aabb.min + interval * 0.5; + if (keepQuadraturePoint(phis, node, x)) ++inCnt; + } + + for (auto& p : phiStacks) delete p; + return {node.aabb.volume() * inCnt / prod(numSamples), 0}; + } for (int i = 0; i < node.polyIntersectIndices.size(); i++) { const auto& polyWithinScene = scene.minimalReps[node.polyIntersectIndices[i]].tensor; phis.emplace_back(tensor3(nullptr, polyWithinScene.ext())); @@ -549,17 +573,57 @@ BasicTaskRes basicTask(const Scene& scene, const OcTreeNode& node, int q = 10) } // ImplicitPolyQuadrature<3> ipquad(scene.minimalReps, node.polyIntersectIndices); ImplicitPolyQuadrature<3> ipquad(phis); + int aaa = 1; #if STOP_WHEN_BLOCKED - if (stopCurrentQuadrature) { + // if (stopCurrentQuadrature + // || std::chrono::duration_cast(std::chrono::high_resolution_clock::now() - + // timerStart).count() + // > MAX_DURATION) { + if (stopCurrentQuadrature + || std::chrono::duration(std::chrono::high_resolution_clock::now() - timerStart).count() > MAX_DURATION) { + std::cout << "Monte Carlo 2" << std::endl; stopCurrentQuadrature = false; - std::cout << "blocked" << std::endl; - return {0, 0}; + // std::cout << "blocked" << std::endl; + // 注意这里tensor已经经过deCasteljau变换,所以采样点属于[0,1]^3 + uvector3i numSamples(20, 20, 20); + uvector3f interval = 1.f / (numSamples); + int inCnt = 0; + for (auto i = MultiLoop<3>(0, numSamples); ~i; ++i) { + uvector3f x = i() * interval + interval * 0.5; + if (keepQuadraturePoint(phis, node, x)) ++inCnt; + } + + for (auto& p : phiStacks) delete p; + return {node.aabb.volume() * inCnt / prod(numSamples), 0}; } #endif ipquad.integrate(AutoMixed, q, [&](const uvector& x, real w) { auto realX = x * range + node.aabb.min; // 这里realX应该是最原始空间下的点?不过因为算体积,所以不影响 if (keepQuadraturePoint(phis, node, x)) { volume += w * integrand(realX); } }); +#if STOP_WHEN_BLOCKED + // if (stopCurrentQuadrature + // || std::chrono::duration_cast(std::chrono::high_resolution_clock::now() - + // timerStart).count() + // > MAX_DURATION) { + if (stopCurrentQuadrature + || std::chrono::duration(std::chrono::high_resolution_clock::now() - timerStart).count() > MAX_DURATION) { + std::cout << "Monte Carlo 2" << std::endl; + stopCurrentQuadrature = false; + // std::cout << "blocked" << std::endl; + // 注意这里tensor已经经过deCasteljau变换,所以采样点属于[0,1]^3 + uvector3i numSamples(20, 20, 20); + uvector3f interval = 1.f / (numSamples); + int inCnt = 0; + for (auto i = MultiLoop<3>(0, numSamples); ~i; ++i) { + uvector3f x = i() * interval + interval * 0.5; + if (keepQuadraturePoint(phis, node, x)) ++inCnt; + } + + for (auto& p : phiStacks) delete p; + return {node.aabb.volume() * inCnt / prod(numSamples), 0}; + } +#endif for (auto& p : phiStacks) delete p; return {volume * node.aabb.volume(), surf}; @@ -662,8 +726,8 @@ void quadratureScene(const std::vector>& primitiv // // int originLeafIdx = blobTree.primitiveNodeIdx[i]; // // for (int j = 0; j < originLeafIdx; ++j) { // // if (blobTree.structure[j].isLeft && blobTree.structure[j].ancestor + j > originLeafIdx) { - // // blobTree.structure[j].ancestor += std::max(int(visiblePrimitiveReps[i].subBlobTree.structure.size()) - 1, - // 0); + // // blobTree.structure[j].ancestor += std::max(int(visiblePrimitiveReps[i].subBlobTree.structure.size()) - + // 1, 0); // // } // // } // // } @@ -673,7 +737,8 @@ void quadratureScene(const std::vector>& primitiv // int oldAncestor = blobTree.structure[i].ancestor; // for (int j = visiblePrimitiveReps.size() - 1; blobTree.primitiveNodeIdx[j] > i; --j) { // if (blobTree.structure[i].isLeft && oldAncestor + i > blobTree.primitiveNodeIdx[j]) { - // blobTree.structure[i].ancestor += std::max(int(visiblePrimitiveReps[j].subBlobTree.structure.size()) - 1, 0); + // blobTree.structure[i].ancestor += std::max(int(visiblePrimitiveReps[j].subBlobTree.structure.size()) - 1, + // 0); // } // } // } @@ -690,8 +755,9 @@ void quadratureScene(const std::vector>& primitiv // visiblePrimitiveReps[i].subBlobTree.structure.begin(), // visiblePrimitiveReps[i].subBlobTree.structure.end() - 1); - // realLeafIndices.reserve(realLeafIndices.size() + visiblePrimitiveReps[i].subBlobTree.primitiveNodeIdx.size()); - // for (auto primitiveIdx : visiblePrimitiveReps[i].subBlobTree.primitiveNodeIdx) { + // realLeafIndices.reserve(realLeafIndices.size() + + // visiblePrimitiveReps[i].subBlobTree.primitiveNodeIdx.size()); for (auto primitiveIdx : + // visiblePrimitiveReps[i].subBlobTree.primitiveNodeIdx) { // realLeafIndices.push_back(primitiveIdx + originLeafIdx); // } // minimalReps.reserve(minimalReps.size() + visiblePrimitiveReps[i].tensors.size()); @@ -702,7 +768,8 @@ void quadratureScene(const std::vector>& primitiv // } else { // blobTree.structure[originLeafIdx].isPrimitive = true; // realLeafIndices.push_back(originLeafIdx); - // minimalReps.emplace_back(MinimalPrimitiveRep{visiblePrimitiveReps[i].tensors[0], visiblePrimitiveReps[i].aabb}); + // minimalReps.emplace_back(MinimalPrimitiveRep{visiblePrimitiveReps[i].tensors[0], + // visiblePrimitiveReps[i].aabb}); // } // } // blobTree.primitiveNodeIdx = realLeafIndices; diff --git a/algoim/organizer/quadratureMC.hpp b/algoim/organizer/quadratureMC.hpp new file mode 100644 index 0000000..e69de29 diff --git a/algoim/quadrature_multipoly.hpp b/algoim/quadrature_multipoly.hpp index b2d00a1..04e6ced 100644 --- a/algoim/quadrature_multipoly.hpp +++ b/algoim/quadrature_multipoly.hpp @@ -374,6 +374,16 @@ void eliminate_axis(PolySet& phi, int k, PolySet& // For every phi(i) ... for (int i = 0; i < phi.count(); ++i) { +#if STOP_WHEN_BLOCKED + auto timerEnd = std::chrono::high_resolution_clock::now(); + std::chrono::duration duration = timerEnd - timerStart; + // auto duration = std::chrono::duration_cast(timerEnd - timerStart); + if (duration.count() > MAX_DURATION) { + stopCurrentQuadrature = true; + return; + } +#endif + const auto& p = phi.poly(i); const auto& mask = phi.mask(i); @@ -416,10 +426,11 @@ void eliminate_axis(PolySet& phi, int k, PolySet& #if STOP_WHEN_BLOCKED auto timerEnd = std::chrono::high_resolution_clock::now(); std::chrono::duration duration = timerEnd - timerStart; + // auto duration = std::chrono::duration_cast(timerEnd - timerStart); if (duration.count() > MAX_DURATION) { stopCurrentQuadrature = true; return; - } // 超过20s + } #endif const auto& p = phi.poly(i); const auto& pmask = phi.mask(i); @@ -680,7 +691,9 @@ struct ImplicitPolyQuadrature { // Assuming phi has been instantiated, determine elimination axis and build base void build(bool outer, bool auto_apply_TS) { +#if STOP_WHEN_BLOCKED if (stopCurrentQuadrature) { return; } +#endif type = outer ? OuterSingle : Inner; this->auto_apply_TS = auto_apply_TS; @@ -762,6 +775,15 @@ struct ImplicitPolyQuadrature { // Base integral invokes the following integrand auto integrand = [&](const uvector& xbase, real w) { +#if STOP_WHEN_BLOCKED + auto timerEnd = std::chrono::high_resolution_clock::now(); + std::chrono::duration duration = timerEnd - timerStart; + // auto duration = std::chrono::duration_cast(timerEnd - timerStart); + if (duration.count() > MAX_DURATION) { + stopCurrentQuadrature = true; + return; + } +#endif // Allocate node buffer of sufficient size and initialise with {0, 1} real* nodes; algoim_spark_alloc(real, &nodes, max_count); @@ -771,6 +793,15 @@ struct ImplicitPolyQuadrature { // For every phi(i) ... for (size_t i = 0; i < phi.count(); ++i) { +#if STOP_WHEN_BLOCKED + auto timerEnd = std::chrono::high_resolution_clock::now(); + std::chrono::duration duration = timerEnd - timerStart; + // auto duration = std::chrono::duration_cast(timerEnd - timerStart); + if (duration.count() > MAX_DURATION) { + stopCurrentQuadrature = true; + return; + } +#endif const auto& p = phi.poly(i); const auto& mask = phi.mask(i); int P = p.ext(k); diff --git a/examples/example_loader.cpp b/examples/example_loader.cpp index 8680ae0..5c8752e 100644 --- a/examples/example_loader.cpp +++ b/examples/example_loader.cpp @@ -481,7 +481,7 @@ void loaderTest1() std::cout << areaDifference << ", " << volumeDifference << std::endl; } -void loaderTest2() +void loaderTest2Simplified() { Loader loader; @@ -719,6 +719,867 @@ void loaderTest2() // loader.output(); } +void loaderTest2() +{ + Loader loader; + + std::vector points; + std::vector bulges; + Vector3D extusion; + Point3D topPoint, bottomPoint, basePoint, leftBottomPoint; + Direction3D direction; + + double offset, radius, radius1, radius2, length, width, height, areaDifference, volumeDifference; + + std::pair before, after; + + /* 1 */ + points.clear(); + bulges.clear(); + points.push_back(Point3D{-32450.000001122418, -3.8391231093737305e-07, 0.0000000000000000}); + points.push_back(Point3D{32449.999998877582, -3.8392495305561452e-07, 0.0000000000000000}); + bulges.push_back(0.99999999999999989); + bulges.push_back(0.99999999999999989); + extusion = Vector3D{0.0000000000000000, 0.0000000000000000, 3300.0000000000000}; + auto tag1 = loader.addExtrude(points, bulges, extusion); + + /* 2 */ + points.clear(); + bulges.clear(); + points.push_back(Point3D{-32450.000001122418, -3.8391231093737305e-07, 0.0000000000000000}); + points.push_back(Point3D{32449.999998877582, -3.8392495305561452e-07, 0.0000000000000000}); + points.push_back(Point3D{33538.999998877582, -3.8392534654100421e-07, 0.0000000000000000}); + points.push_back(Point3D{-33539.000001122418, -3.8391228016184551e-07, 0.0000000000000000}); + bulges.push_back(0.99999999999999989); + bulges.push_back(0.0000000000000000); + bulges.push_back(-0.99999999999999989); + bulges.push_back(0.0000000000000000); + extusion = Vector3D{0.0000000000000000, 0.0000000000000000, 3300.0000000000000}; + auto tag2 = loader.addExtrude(points, bulges, extusion); + + /* 3 */ + points.clear(); + bulges.clear(); + points.push_back(Point3D{-32450.000001122418, -3.8391231093737305e-07, 0.0000000000000000}); + points.push_back(Point3D{32449.999998877582, -3.8392495305561452e-07, 0.0000000000000000}); + points.push_back(Point3D{33538.999998877582, -3.8392534654100421e-07, 0.0000000000000000}); + points.push_back(Point3D{-33539.000001122418, -3.8391228016184551e-07, 0.0000000000000000}); + bulges.push_back(0.99999999999999989); + bulges.push_back(0.0000000000000000); + bulges.push_back(-0.99999999999999989); + bulges.push_back(0.0000000000000000); + extusion = Vector3D{0.0000000000000000, 0.0000000000000000, 3300.0000000000000}; + auto tag3 = loader.addExtrude(points, bulges, extusion); + + /* 4 */ + topPoint = Point3D{-1.1224183253943920e-06, -3.8391322798592142e-07, 0.0000000000000000}; + bottomPoint = Point3D{-1.1224183253943920e-06, -3.8391322798592142e-07, 3300.0000000000000000}; + radius1 = 32450.000000000000; + radius2 = 33539.000000000000; + auto tag4 = loader.addCone(topPoint, bottomPoint, radius1, radius2); + + /* 3и */ + direction = Direction3D{0, 0, 1}; + basePoint = Point3D{-1.1224183253943920e-06, -3.8391322798592142e-07, 0.0000000000000000}; + loader.split(tag3, basePoint, direction); + + /* 34 */ + loader.differentNode(tag3, tag4); + + /* 5 */ + points.clear(); + bulges.clear(); + points.push_back(Point3D{-32450.000001122418, -3.8391231093737305e-07, 0.0000000000000000}); + points.push_back(Point3D{32449.999998877582, -3.8392495305561452e-07, 0.0000000000000000}); + points.push_back(Point3D{33538.999998877582, -3.8392534654100421e-07, 0.0000000000000000}); + points.push_back(Point3D{-33539.000001122418, -3.8391228016184551e-07, 0.0000000000000000}); + bulges.push_back(0.99999999999999989); + bulges.push_back(0.0000000000000000); + bulges.push_back(-0.99999999999999989); + bulges.push_back(0.0000000000000000); + extusion = Vector3D{0.0000000000000000, 0.0000000000000000, 3300.0000000000000}; + auto tag5 = loader.addExtrude(points, bulges, extusion); + + /* 5и */ + direction = Direction3D{0, 0, 1}; + basePoint = Point3D{-1.1224183253943920e-06, -3.8391322798592142e-07, 3300.0000000000000000}; + loader.split(tag5, basePoint, direction); + + /* 35 */ + loader.unionNode(tag3, tag5); + + /* 6 */ + points.clear(); + bulges.clear(); + points.push_back(Point3D{-32450.000001122418, -3.8391231093737305e-07, 0.0000000000000000}); + points.push_back(Point3D{32449.999998877582, -3.8392495305561452e-07, 0.0000000000000000}); + points.push_back(Point3D{33538.999998877582, -3.8392534654100421e-07, 0.0000000000000000}); + points.push_back(Point3D{-33539.000001122418, -3.8391228016184551e-07, 0.0000000000000000}); + bulges.push_back(0.99999999999999989); + bulges.push_back(0.0000000000000000); + bulges.push_back(-0.99999999999999989); + bulges.push_back(0.0000000000000000); + extusion = Vector3D{0.0000000000000000, 0.0000000000000000, 3300.0000000000000}; + auto tag6 = loader.addExtrude(points, bulges, extusion); + + /* 6и */ + direction = Direction3D{0, 0, 1}; + basePoint = Point3D{-1.1224183253943920e-06, -3.8391322798592142e-07, 3300.0000000000000000}; + loader.split(tag6, basePoint, direction); + + /* 36 */ + loader.unionNode(tag3, tag6); + + /* 23 */ + loader.differentNode(tag2, tag3); + + /* 7 */ + points.clear(); + bulges.clear(); + points.push_back(Point3D{32449.999998877582, -3.8392495305561452e-07, 0.0000000000000000}); + points.push_back(Point3D{-32450.000001122418, -3.8391231093737305e-07, 0.0000000000000000}); + points.push_back(Point3D{-33539.000001122418, -3.8391191745198337e-07, 0.0000000000000000}); + points.push_back(Point3D{33538.999998877582, -3.8392498383114206e-07, 0.0000000000000000}); + bulges.push_back(0.99999999999999989); + bulges.push_back(0.0000000000000000); + bulges.push_back(-0.99999999999999989); + bulges.push_back(0.0000000000000000); + extusion = Vector3D{0.0000000000000000, 0.0000000000000000, 3300.0000000000000}; + auto tag7 = loader.addExtrude(points, bulges, extusion); + + /* 8 */ + points.clear(); + bulges.clear(); + points.push_back(Point3D{32449.999998877582, -3.8392495305561452e-07, 0.0000000000000000}); + points.push_back(Point3D{-32450.000001122418, -3.8391231093737305e-07, 0.0000000000000000}); + points.push_back(Point3D{-33539.000001122418, -3.8391191745198337e-07, 0.0000000000000000}); + points.push_back(Point3D{33538.999998877582, -3.8392498383114206e-07, 0.0000000000000000}); + bulges.push_back(0.99999999999999989); + bulges.push_back(0.0000000000000000); + bulges.push_back(-0.99999999999999989); + bulges.push_back(0.0000000000000000); + extusion = Vector3D{0.0000000000000000, 0.0000000000000000, 3300.0000000000000}; + auto tag8 = loader.addExtrude(points, bulges, extusion); + + /* 9 */ + topPoint = Point3D{-1.1224183253943920e-06, -3.8392403600706615e-07, 0.0000000000000000}; + bottomPoint = Point3D{-1.1224183253943920e-06, -3.8392403600706615e-07, 3300.0000000000000000}; + radius1 = 32450.000000000000; + radius2 = 33539.000000000000; + auto tag9 = loader.addCone(topPoint, bottomPoint, radius1, radius2); + + /* 8и */ + direction = Direction3D{0, 0, 1}; + basePoint = Point3D{-1.1224183253943920e-06, -3.8392403600706615e-07, 3300.0000000000000000}; + loader.split(tag8, basePoint, direction); + + /* 89 */ + loader.differentNode(tag8, tag9); + + /* 10 */ + points.clear(); + bulges.clear(); + points.push_back(Point3D{32449.999998877582, -3.8392495305561452e-07, 0.0000000000000000}); + points.push_back(Point3D{-32450.000001122418, -3.8391231093737305e-07, 0.0000000000000000}); + points.push_back(Point3D{-33539.000001122418, -3.8391191745198337e-07, 0.0000000000000000}); + points.push_back(Point3D{33538.999998877582, -3.8392498383114206e-07, 0.0000000000000000}); + bulges.push_back(0.99999999999999989); + bulges.push_back(0.0000000000000000); + bulges.push_back(-0.99999999999999989); + bulges.push_back(0.0000000000000000); + extusion = Vector3D{0.0000000000000000, 0.0000000000000000, 3300.0000000000000}; + auto tag10 = loader.addExtrude(points, bulges, extusion); + + /* 10и */ + direction = Direction3D{0, 0, 1}; + basePoint = Point3D{-1.1224183253943920e-06, -3.8392403600706615e-07, 3300.0000000000000000}; + loader.split(tag10, basePoint, direction); + + /* 810 */ + loader.unionNode(tag8, tag10); + + /* 11 */ + points.clear(); + bulges.clear(); + points.push_back(Point3D{32449.999998877582, -3.8392495305561452e-07, 0.0000000000000000}); + points.push_back(Point3D{-32450.000001122418, -3.8391231093737305e-07, 0.0000000000000000}); + points.push_back(Point3D{-33539.000001122418, -3.8391191745198337e-07, 0.0000000000000000}); + points.push_back(Point3D{33538.999998877582, -3.8392498383114206e-07, 0.0000000000000000}); + bulges.push_back(0.99999999999999989); + bulges.push_back(0.0000000000000000); + bulges.push_back(-0.99999999999999989); + bulges.push_back(0.0000000000000000); + extusion = Vector3D{0.0000000000000000, 0.0000000000000000, 3300.0000000000000}; + auto tag11 = loader.addExtrude(points, bulges, extusion); + + /* 11и */ + direction = Direction3D{0, 0, 1}; + basePoint = Point3D{-1.1224183253943920e-06, -3.8392403600706615e-07, 3300.0000000000000000}; + loader.split(tag11, basePoint, direction); + + /* 811 */ + loader.unionNode(tag8, tag11); + + /* 78 */ + loader.differentNode(tag7, tag8); + + /* 27 */ + loader.unionNode(tag2, tag7); + + /* 12 */ + loader.unionNode(tag1, tag2); + + /* 1 Zƫ -3600 */ + direction = Direction3D{0, 0, 1}; + offset = -3600; + loader.offset(tag1, direction, offset); + + /* 111 */ + points.clear(); + bulges.clear(); + points.push_back(Point3D{-32050.000001122418, -3.8396319723688066e-07, 0.0000000000000000}); + points.push_back(Point3D{32049.999998877582, -3.8387224776670337e-07, 0.0000000000000000}); + bulges.push_back(0.99999999999999989); + bulges.push_back(0.99999999999999989); + extusion = Vector3D{0.0000000000000000, 0.0000000000000000, 600.0000000000000}; + auto tag111 = loader.addExtrude(points, bulges, extusion); + + /* 0 */ + points.clear(); + bulges.clear(); + points.push_back(Point3D{-11798.670446418590, 5999.2409883221799, 0.0000000000000000}); + points.push_back(Point3D{11801.337366082498, 5999.2409883221590, 0.0000000000000000}); + bulges.push_back(0.99999999999999989); + bulges.push_back(0.99999999999999989); + extusion = Vector3D{0.0000000000000000, 0.0000000000000000, 600.0000000000000}; + auto tag0 = loader.addExtrude(points, bulges, extusion); + + /* 1110 */ + loader.differentNode(tag111, tag0); + + /* 111 Zƫ -3500 */ + direction = Direction3D{0, 0, 1}; + offset = -3500; + loader.offset(tag111, direction, offset); + + /* 1111н */ + /* TODO */ + + /* 12 */ + points.clear(); + bulges.clear(); + points.push_back(Point3D{676.33403607269543, 5999.2409883221790, 0.0000000000000000}); + points.push_back(Point3D{-673.66711640879771, 5999.2409883221790, 0.0000000000000000}); + bulges.push_back(0.99999999999999989); + bulges.push_back(0.99999999999999989); + extusion = Vector3D{0.0000000000000000, 0.0000000000000000, 600.0000000000000}; + auto tag12 = loader.addExtrude(points, bulges, extusion); + + /* 12 Zƫ -3500 */ + direction = Direction3D{0, 0, 1}; + offset = -3500; + loader.offset(tag12, direction, offset); + + /* 112н */ + /* TODO */ + + /* 11112 */ + loader.unionNode(tag111, tag12); + + /* 13 */ + points.clear(); + bulges.clear(); + points.push_back(Point3D{-2398.6665401680511, 5999.2409883221771, 0.0000000000000000}); + points.push_back(Point3D{2401.3334598319489, 5999.2409883221790, 0.0000000000000000}); + bulges.push_back(0.99999999999999989); + bulges.push_back(0.99999999999999989); + extusion = Vector3D{0.0000000000000000, 0.0000000000000000, 600.0000000000000}; + auto tag13 = loader.addExtrude(points, bulges, extusion); + + + /* 14 */ + points.clear(); + bulges.clear(); + points.push_back(Point3D{-673.66711640879771, 5999.2409883221790, 0.0000000000000000}); + points.push_back(Point3D{676.33403607269543, 5999.2409883221790, 0.0000000000000000}); + bulges.push_back(-0.99999999999999989); + bulges.push_back(-0.99999999999999989); + extusion = Vector3D{0.0000000000000000, 0.0000000000000000, 600.0000000000000}; + auto tag14 = loader.addExtrude(points, bulges, extusion); + + /* 1314 */ + loader.differentNode(tag13, tag14); + + /* 13 Zƫ -3500 */ + direction = Direction3D{0, 0, 1}; + offset = -3500; + loader.offset(tag13, direction, offset); + + /* 113н */ + /* TODO */ + + /* 11113 */ + loader.unionNode(tag111, tag13); + + // before = loader.getAreaAndVolume(tag1); + /* 1111 */ + loader.differentNode(tag1, tag111); + // after = loader.getAreaAndVolume(tag1); + + /* ȡ1 ǰ */ + // areaDifference = after.first - before.first; + // volumeDifference = after.second - before.second; + // std::cout << areaDifference << ", " << volumeDifference << std::endl; + + /* ۼ1 */ + auto subTag1 = loader.addEmpty(); + auto cycle = [&loader, subTag1](const Point3D& point) { + std::vector points; + std::vector bulges; + Vector3D extusion; + Direction3D direction; + double offset; + + /* ѭ1 */ + points.clear(); + bulges.clear(); + points.push_back(Point3D{-1000.0000000000000, 1000.0000000000001, 0.0000000000000000}); + points.push_back(Point3D{-1000.0000000000000, -1000.0000000000000, 0.0000000000000000}); + points.push_back(Point3D{1000.0000000000000, -1000.0000000000000, 0.0000000000000000}); + points.push_back(Point3D{1000.0000000000000, 1000.0000000000000, 0.0000000000000000}); + bulges.push_back(0.0000000000000000); + bulges.push_back(0.0000000000000000); + bulges.push_back(0.0000000000000000); + bulges.push_back(0.0000000000000000); + extusion = Vector3D{0.0000000000000000, 0.0000000000000000, 600.0000000000000}; + auto cycleTag1 = loader.addExtrude(points, bulges, extusion); + + /* ѭ1 ƫ+ X,Y,Zֵ */ + loader.offset(cycleTag1, Direction3D{point}, point.length()); + + /* ѭ2 */ + auto leftBottomPoint = Point3D{point.m_x - 1000, point.m_y - 1000, point.m_z + 0.0000000000005}; + double length = 2000.0000000000036; + double width = 2000.0000000000036; + double height = 600; + auto cycleTag2 = loader.addBox(leftBottomPoint, length, width, height); + + /* ѭ3 */ + points.clear(); + bulges.clear(); + points.push_back(Point3D{-32050.000001122418, -3.8396319723688066e-07, 0.0000000000000000}); + points.push_back(Point3D{32049.999998877582, -3.8387224776670337e-07, 0.0000000000000000}); + bulges.push_back(0.99999999999999989); + bulges.push_back(0.99999999999999989); + extusion = Vector3D{0.0000000000000000, 0.0000000000000000, 600.0000000000000}; + auto cycleTag3 = loader.addExtrude(points, bulges, extusion); + + /* ѭ3 Zƫ -2900 */ + direction = Direction3D{0, 0, 1}; + offset = -2900; + loader.offset(cycleTag3, direction, offset); + + /* ѭ32 */ + loader.intersectNode(cycleTag3, cycleTag2); + + /* ѭ13 */ + loader.intersectNode(cycleTag1, cycleTag3); + + /* ѭ11н */ + /* TODO */ + + /* ۼ1ѭ1 */ + loader.unionNode(subTag1, cycleTag1); + }; + + points.clear(); + points.push_back(Point3D{-21595.036456438422, -21609.173181957169, -2900.0000000000000}); + points.push_back(Point3D{-13505.711180076411, -13505.717935507526, -2900.0000000000000}); + points.push_back(Point3D{-2987.8729842756293, -18864.829751913778, -2900.0000000000000}); + points.push_back(Point3D{2987.9196792985895, -18864.830728476278, -2900.0000000000000}); + points.push_back(Point3D{13505.770265236089, -13505.722818320026, -2900.0000000000000}); + points.push_back(Point3D{17018.254640236089, -8671.2047519137759, -2900.0000000000000}); + points.push_back(Point3D{27220.281983986089, -13869.397623007526, -2900.0000000000000}); + points.push_back(Point3D{21602.139405861089, -21602.103677695028, -2900.0000000000000}); + points.push_back(Point3D{30173.926515236089, -4778.9669589450259, -2900.0000000000000}); + points.push_back(Point3D{18864.887452736089, -2987.8275546481514, -2900.0000000000000}); + points.push_back(Point3D{-18864.815672263911, -2987.8811435153389, -2900.0000000000000}); + points.push_back(Point3D{-30173.856687888911, -4779.0570468356509, -2900.0000000000000}); + points.push_back(Point3D{-13869.422117576411, -27220.218912070028, -2900.0000000000000}); + points.push_back(Point3D{-11781.052000388911, -23121.591958945028, -2900.0000000000000}); + points.push_back(Point3D{-8671.2131332014105, -17018.193521445028, -2900.0000000000000}); + points.push_back(Point3D{-27220.229734763911, -13869.391763632526, -2900.0000000000000}); + points.push_back(Point3D{-17018.194578513911, -8671.1974276950259, -2900.0000000000000}); + points.push_back(Point3D{-30173.856687888911, 4779.0965176174741, -2900.0000000000000}); + points.push_back(Point3D{-25630.485594138911, 4059.4959316799741, -2900.0000000000000}); + points.push_back(Point3D{-18864.815672263911, 2987.9134121487236, -2900.0000000000000}); + points.push_back(Point3D{-15863.798094138911, 8083.0535488674741, -2900.0000000000000}); + points.push_back(Point3D{-27220.216062888911, 13869.449056679974, -2900.0000000000000}); + points.push_back(Point3D{-21602.091062888911, 21602.130697304972, -2900.0000000000000}); + points.push_back(Point3D{-18349.393797263911, 18349.437337929972, -2900.0000000000000}); + points.push_back(Point3D{-13908.684812888911, 13908.728353554974, -2900.0000000000000}); + points.push_back(Point3D{-9584.8552230451605, 18811.339681679972, -2900.0000000000000}); + points.push_back(Point3D{-13869.425047263911, 27220.249837929972, -2900.0000000000000}); + points.push_back(Point3D{-4779.0493148420355, 30173.900228554972, -2900.0000000000000}); + points.push_back(Point3D{4779.0900894548395, 30173.904134804972, -2900.0000000000000}); + points.push_back(Point3D{13869.430421486089, 27220.275228554972, -2900.0000000000000}); + points.push_back(Point3D{9584.8806167985895, 18811.363119179972, -2900.0000000000000}); + points.push_back(Point3D{13908.739015236089, 13908.728353554974, -2900.0000000000000}); + points.push_back(Point3D{18349.453858986089, 18349.433431679972, -2900.0000000000000}); + points.push_back(Point3D{21602.147218361089, 21602.130697304972, -2900.0000000000000}); + points.push_back(Point3D{27220.268312111089, 13869.454916054974, -2900.0000000000000}); + points.push_back(Point3D{15863.852296486089, 8083.0574551174741, -2900.0000000000000}); + points.push_back(Point3D{18864.879640236089, 2987.9153652737236, -2900.0000000000000}); + points.push_back(Point3D{25630.543702736089, 4059.4900723049741, -2900.0000000000000}); + points.push_back(Point3D{30173.912843361089, 4779.0896816799741, -2900.0000000000000}); + points.push_back(Point3D{13869.432374611089, -27220.242349570028, -2900.0000000000000}); + points.push_back(Point3D{-4776.1108367703273, -30098.869302695028, -2900.0000000000000}); + points.push_back(Point3D{4779.0915542985895, -30098.869302695028, -2900.0000000000000}); + points.push_back(Point3D{-23121.594969138911, -11781.033365195026, -2900.0000000000000}); + points.push_back(Point3D{23121.637452736089, 11781.092611367474, -2900.0000000000000}); + points.push_back(Point3D{11781.053468361089, -23121.619302695028, -2900.0000000000000}); + points.push_back(Point3D{-23121.583250388911, 11781.089681679974, -2900.0000000000000}); + for (auto& point : points) { cycle(point); } + + // before = loader.getAreaAndVolume(tag1); + /* 1Ϳۼ1 */ + loader.differentNode(tag1, subTag1); + // after = loader.getAreaAndVolume(tag1); + + /* ȡ 1 ǰ */ + // areaDifference = after.first - before.first; + // volumeDifference = after.second - before.second; + // std::cout << areaDifference << ", " << volumeDifference << std::endl; + + /* 15Ent1.bool */ + bottomPoint = Point3D{0.0000, 0.0000, -3600.0000}; + radius = 32150.0; + direction = Direction3D{0, 0, 100}; + auto tag15 = loader.addCylinder(bottomPoint, radius, direction); + bottomPoint = Point3D{1.3330, 5999.2412, -3600.0000}; + radius = 11700.43125; + direction = Direction3D{0, 0, 100}; + auto tag15_1 = loader.addCylinder(bottomPoint, radius, direction); + loader.differentNode(tag15, tag15_1); + + /* 115 */ + loader.differentNode(tag1, tag15); + + /* 16 */ + points.clear(); + bulges.clear(); + points.push_back(Point3D{-2503.6291053659488, 5999.2409883221790, -3500.0000000000000}); + points.push_back(Point3D{2501.2960250298465, 5999.2409883221790, -3500.0000000000000}); + bulges.push_back(0.99999999999999989); + bulges.push_back(0.99999999999999989); + extusion = Vector3D{-0.0000000000000000, -0.0000000000000000, -100.00000000000000}; + auto tag16 = loader.addExtrude(points, bulges, extusion); + + /* 116 */ + loader.differentNode(tag1, tag16); + + /* 17 */ + points.clear(); + bulges.clear(); + points.push_back(Point3D{2079.8334638622341, 5999.2409883221844, 0.0000000000000000}); + points.push_back(Point3D{-2070.1665441983364, 5999.2409883221844, 0.0000000000000000}); + points.push_back(Point3D{-1320.1665441983364, 5999.2409883221844, 0.0000000000000000}); + points.push_back(Point3D{1329.8334638622341, 5999.2409883221844, 0.0000000000000000}); + bulges.push_back(0.99999999999999989); + bulges.push_back(0.0000000000000000); + bulges.push_back(-0.99999999999999989); + bulges.push_back(0.0000000000000000); + extusion = Vector3D{0.0000000000000000, 0.0000000000000000, 2750.0000000000000}; + auto tag17 = loader.addExtrude(points, bulges, extusion); + + /* 17 Zƫ -2900 */ + direction = Direction3D{0, 0, 1}; + offset = -2900; + loader.offset(tag17, direction, offset); + + /* 117 */ + loader.differentNode(tag1, tag17); + + /* 18 */ + points.clear(); + bulges.clear(); + points.push_back(Point3D{-2070.1665441983364, 5999.2409883221844, 0.0000000000000000}); + points.push_back(Point3D{2079.8334638622341, 5999.2409883221844, 0.0000000000000000}); + points.push_back(Point3D{1329.8334638622341, 5999.2409883221844, 0.0000000000000000}); + points.push_back(Point3D{-1320.1665441983364, 5999.2409883221844, 0.0000000000000000}); + bulges.push_back(0.99999999999999989); + bulges.push_back(0.0000000000000000); + bulges.push_back(-0.99999999999999989); + bulges.push_back(0.0000000000000000); + extusion = Vector3D{0.0000000000000000, 0.0000000000000000, 2750.0000000000000}; + auto tag18 = loader.addExtrude(points, bulges, extusion); + + /* 18 Zƫ -2900 */ + direction = Direction3D{0, 0, 1}; + offset = -2900; + loader.offset(tag18, direction, offset); + + /* 118 */ + loader.differentNode(tag1, tag18); + + /* 19 */ + points.clear(); + bulges.clear(); + points.push_back(Point3D{8760.4644464528919, -16861.795338417785, 0.0000000000000000}); + points.push_back(Point3D{5893.9646280986062, -18064.309214597473, 0.0000000000000000}); + points.push_back(Point3D{6248.1524494726591, -18208.769763083357, 0.0000000000000000}); + points.push_back(Point3D{8651.1159137951836, -17197.859075721935, 0.0000000000000000}); + bulges.push_back(-0.039803147455118697); + bulges.push_back(0.0000000000000000); + bulges.push_back(0.032943018176267741); + bulges.push_back(0.0000000000000000); + extusion = Vector3D{0.0000000000000000, 0.0000000000000000, 2850.0000000000000}; + auto tag19 = loader.addExtrude(points, bulges, extusion); + + /* 19 Zƫ -2900 */ + direction = Direction3D{0, 0, 1}; + offset = -2900; + loader.offset(tag19, direction, offset); + + /* 119 */ + loader.differentNode(tag1, tag19); + + /* 20 */ + points.clear(); + bulges.clear(); + points.push_back(Point3D{8472.1973651856952, -23124.378331468590, 0.0000000000000000}); + points.push_back(Point3D{11234.316117012168, -21717.002618593218, 0.0000000000000000}); + points.push_back(Point3D{10898.067054009927, -21607.748991111552, 0.0000000000000000}); + points.push_back(Point3D{8581.4512221945606, -22788.128674499021, 0.0000000000000000}); + bulges.push_back(0.0000000000000000); + bulges.push_back(0.0000000000000000); + bulges.push_back(0.0000000000000000); + bulges.push_back(0.0000000000000000); + extusion = Vector3D{0.0000000000000000, 0.0000000000000000, 2850.0000000000000}; + auto tag20 = loader.addExtrude(points, bulges, extusion); + + /* 20 Zƫ -2900 */ + direction = Direction3D{0, 0, 1}; + offset = -2900; + loader.offset(tag20, direction, offset); + + /* 120 */ + loader.differentNode(tag1, tag20); + + /* 21 */ + points.clear(); + bulges.clear(); + points.push_back(Point3D{11234.316117012169, -21717.002618593222, 0.0000000000000000}); + points.push_back(Point3D{8760.4644464528919, -16861.795338417785, 0.0000000000000000}); + points.push_back(Point3D{8651.1159137951836, -17197.859075721935, 0.0000000000000000}); + points.push_back(Point3D{10898.067054009929, -21607.748991111555, 0.0000000000000000}); + bulges.push_back(0.0000000000000000); + bulges.push_back(0.0000000000000000); + bulges.push_back(0.0000000000000000); + bulges.push_back(0.0000000000000000); + extusion = Vector3D{0.0000000000000000, 0.0000000000000000, 2850.0000000000000}; + auto tag21 = loader.addExtrude(points, bulges, extusion); + + /* 21 Zƫ -2900 */ + direction = Direction3D{0, 0, 1}; + offset = -2900; + loader.offset(tag21, direction, offset); + + /* 121 */ + loader.differentNode(tag1, tag21); + + /* 22 */ + points.clear(); + bulges.clear(); + points.push_back(Point3D{5893.9646280986062, -18064.309214597473, 0.0000000000000000}); + points.push_back(Point3D{8472.1973651856970, -23124.378331468593, 0.0000000000000000}); + points.push_back(Point3D{8581.4512221945624, -22788.128674499025, 0.0000000000000000}); + points.push_back(Point3D{6248.1524494726591, -18208.769763083357, 0.0000000000000000}); + bulges.push_back(0.0000000000000000); + bulges.push_back(0.0000000000000000); + bulges.push_back(0.0000000000000000); + bulges.push_back(0.0000000000000000); + extusion = Vector3D{0.0000000000000000, 0.0000000000000000, 2850.0000000000000}; + auto tag22 = loader.addExtrude(points, bulges, extusion); + + /* 22 Zƫ -2900 */ + direction = Direction3D{0, 0, 1}; + offset = -2900; + loader.offset(tag22, direction, offset); + + // before = loader.getAreaAndVolume(tag1); + /* 122 */ + loader.differentNode(tag1, tag22); + // after = loader.getAreaAndVolume(tag1); + + /* ȡ1 ǰ */ + // areaDifference = after.first - before.first; + // volumeDifference = after.second - before.second; + // std::cout << areaDifference << ", " << volumeDifference << std::endl; + + /* 23 */ + points.clear(); + bulges.clear(); + points.push_back(Point3D{7380.7150904719992, -20706.098050612181, 0.0000000000000000}); + points.push_back(Point3D{9920.1451018985645, -19412.300707257506, 0.0000000000000000}); + points.push_back(Point3D{9829.3529561354007, -19234.096368736471, 0.0000000000000000}); + points.push_back(Point3D{7289.9229447088355, -20527.893712091147, 0.0000000000000000}); + bulges.push_back(0.0000000000000000); + bulges.push_back(0.0000000000000000); + bulges.push_back(0.0000000000000000); + bulges.push_back(0.0000000000000000); + extusion = Vector3D{0.0000000000000000, 0.0000000000000000, 2850.0000000000000}; + auto tag23 = loader.addExtrude(points, bulges, extusion); + + /* 23 Zƫ -2900 */ + direction = Direction3D{0, 0, 1}; + offset = -2900; + loader.offset(tag23, direction, offset); + + // before = loader.getAreaAndVolume(tag1); + /* 123 */ + loader.differentNode(tag1, tag23); + // after = loader.getAreaAndVolume(tag1); + + /* ȡ1 ǰ */ + // areaDifference = after.first - before.first; + // volumeDifference = after.second - before.second; + // std::cout << areaDifference << ", " << volumeDifference << std::endl; + + /* Ϊһѭ͹̶鲻һһ */ + auto cycle1 = [&loader, tag1](const Point3D& point1, const Point3D point2) { + /* ѭ */ + const std::vector points = {point1, point2}; + std::vector bulges = {0.99999999999999989, 0.99999999999999989}; + Vector3D extusion = Vector3D{0.0000000000000000, 0.0000000000000000, 2850.0000000000000}; + auto cycleTag = loader.addExtrude(points, bulges, extusion); + + /* ѭ Zƫ -2900 */ + Direction3D direction = Direction3D{0, 0, 1}; + double offset = -2900; + loader.offset(cycleTag, direction, offset); + + /* 1ѭ岼 */ + loader.differentNode(tag1, cycleTag); + }; + + points.clear(); + bulges.clear(); + points.push_back(Point3D{25330.544191030145, 4059.4890957491152, 0.0000000000000000}); + points.push_back(Point3D{25930.544191030145, 4059.4890957491152, 0.0000000000000000}); + points.push_back(Point3D{2637.9248093705974, -18864.831701145784, 0.0000000000000000}); + points.push_back(Point3D{3337.9248093705974, -18864.831701145784, 0.0000000000000000}); + points.push_back(Point3D{-19214.815183982137, -2987.8808536118449, 0.0000000000000000}); + points.push_back(Point3D{-18514.815183982137, -2987.8808536118449, 0.0000000000000000}); + points.push_back(Point3D{13155.774659765651, -13505.730142548899, 0.0000000000000000}); + points.push_back(Point3D{13855.774659765651, -13505.730142548899, 0.0000000000000000}); + points.push_back(Point3D{-23421.584711222677, 11781.088222738428, 0.0000000000000000}); + points.push_back(Point3D{-22821.584711222677, 11781.088222738428, 0.0000000000000000}); + points.push_back(Point3D{-21952.083741631068, -21602.101728577210, 0.0000000000000000}); + points.push_back(Point3D{-21252.083741631068, -21602.101728577210, 0.0000000000000000}); + points.push_back(Point3D{-3337.8756971632247, -18864.831700995899, 0.0000000000000000}); + points.push_back(Point3D{-2637.8756971632247, -18864.831700995899, 0.0000000000000000}); + points.push_back(Point3D{22821.635010756669, 11781.088216097109, 0.0000000000000000}); + points.push_back(Point3D{23421.635010756669, 11781.088216097109, 0.0000000000000000}); + points.push_back(Point3D{8321.2448748154566, -17018.220376670986, 0.0000000000000000}); + points.push_back(Point3D{9021.2448748154566, -17018.220376670986, 0.0000000000000000}); + points.push_back(Point3D{-1871.5656374104437, -9922.6107521542435, 0.0000000000000000}); + points.push_back(Point3D{-1271.5656374104440, -9922.6107521542435, 0.0000000000000000}); + points.push_back(Point3D{26920.265871888550, 13869.448081589901, 0.0000000000000000}); + points.push_back(Point3D{27520.265871888550, 13869.448081589901, 0.0000000000000000}); + points.push_back(Point3D{29873.915284768678, 4779.0894375231728, 0.0000000000000000}); + points.push_back(Point3D{30473.915284768678, 4779.0894375231728, 0.0000000000000000}); + points.push_back(Point3D{1271.6142550302902, -9922.6210172974243, 0.0000000000000000}); + points.push_back(Point3D{1871.6142550302900, -9922.6210172974243, 0.0000000000000000}); + points.push_back(Point3D{7608.7448703002883, -7908.7010952570563, 0.0000000000000000}); + points.push_back(Point3D{8208.7448703002883, -7908.7010952570563, 0.0000000000000000}); + points.push_back(Point3D{11431.053468361089, -23121.619302695020, 0.0000000000000000}); + points.push_back(Point3D{12131.053468361089, -23121.619302695020, 0.0000000000000000}); + points.push_back(Point3D{21252.143796979217, -21602.113447324591, 0.0000000000000000}); + points.push_back(Point3D{21952.143796979217, -21602.113447324591, 0.0000000000000000}); + points.push_back(Point3D{26870.284425387275, -13869.400552711551, 0.0000000000000000}); + points.push_back(Point3D{27570.284425387275, -13869.400552711551, 0.0000000000000000}); + points.push_back(Point3D{16668.254151753965, -8671.2113439714158, 0.0000000000000000}); + points.push_back(Point3D{17368.254151753965, -8671.2113439714158, 0.0000000000000000}); + points.push_back(Point3D{21302.142824993702, 21602.129722254482, 0.0000000000000000}); + points.push_back(Point3D{21902.142824993702, 21602.129722254482, 0.0000000000000000}); + points.push_back(Point3D{18514.882078273164, -2987.8308623732737, 0.0000000000000000}); + points.push_back(Point3D{19214.882078273164, -2987.8308623732737, 0.0000000000000000}); + points.push_back(Point3D{-27570.225340223697, -13869.390298805301, 0.0000000000000000}); + points.push_back(Point3D{-26870.225340223697, -13869.390298805301, 0.0000000000000000}); + points.push_back(Point3D{15563.854737884307, 8083.0486660407769, 0.0000000000000000}); + points.push_back(Point3D{16163.854737884307, 8083.0486660407769, 0.0000000000000000}); + points.push_back(Point3D{29823.926027013978, -4778.9706820347201, 0.0000000000000000}); + points.push_back(Point3D{30523.926027013978, -4778.9706820347201, 0.0000000000000000}); + points.push_back(Point3D{-25930.485105855274, 4059.4890957491152, 0.0000000000000000}); + points.push_back(Point3D{-25330.485105855274, 4059.4890957491152, 0.0000000000000000}); + points.push_back(Point3D{-15906.105228972388, 2471.7791264631815, 0.0000000000000000}); + points.push_back(Point3D{-15306.105228972388, 2471.7791264631815, 0.0000000000000000}); + points.push_back(Point3D{-14208.685301157355, 13908.728353561615, 0.0000000000000000}); + points.push_back(Point3D{-13608.685301157355, 13908.728353561615, 0.0000000000000000}); + points.push_back(Point3D{15306.173097269726, 2471.7791347907769, 0.0000000000000000}); + points.push_back(Point3D{15906.173097269726, 2471.7791347907769, 0.0000000000000000}); + points.push_back(Point3D{-30523.856199605914, -4779.0607699771499, 0.0000000000000000}); + points.push_back(Point3D{-29823.856199605914, -4779.0607699771499, 0.0000000000000000}); + points.push_back(Point3D{13608.744379809476, 13908.728344973482, 0.0000000000000000}); + points.push_back(Point3D{14208.744379809476, 13908.728344973482, 0.0000000000000000}); + points.push_back(Point3D{-19164.815183980274, 2987.9090176032769, 0.0000000000000000}); + points.push_back(Point3D{-18564.815183980274, 2987.9090176032769, 0.0000000000000000}); + points.push_back(Point3D{18049.454334036331, 18349.429508093293, 0.0000000000000000}); + points.push_back(Point3D{18649.454334036331, 18349.429508093293, 0.0000000000000000}); + points.push_back(Point3D{18564.882081644726, 2987.9090176032769, 0.0000000000000000}); + points.push_back(Point3D{19164.882081644726, 2987.9090176032769, 0.0000000000000000}); + points.push_back(Point3D{-18649.394773816515, 18349.429525433647, 0.0000000000000000}); + points.push_back(Point3D{-18049.394773816515, 18349.429525433647, 0.0000000000000000}); + points.push_back(Point3D{-16163.795652730274, 8083.0486660407769, 0.0000000000000000}); + points.push_back(Point3D{-15563.795652730274, 8083.0486660407769, 0.0000000000000000}); + points.push_back(Point3D{-13089.545652741857, 6516.6287441791064, 0.0000000000000000}); + points.push_back(Point3D{-12489.545652741857, 6516.6287441791064, 0.0000000000000000}); + points.push_back(Point3D{-12432.865969395847, 1921.6695098721102, 0.0000000000000000}); + points.push_back(Point3D{-11832.865969395847, 1921.6695098721102, 0.0000000000000000}); + points.push_back(Point3D{11832.924069322587, 1921.6787872227869, 0.0000000000000000}); + points.push_back(Point3D{12432.924069322587, 1921.6787872227869, 0.0000000000000000}); + points.push_back(Point3D{-14219.424558988423, -27220.219888640844, 0.0000000000000000}); + points.push_back(Point3D{-13519.424558988423, -27220.219888640844, 0.0000000000000000}); + points.push_back(Point3D{-8208.6860335274250, -7908.7010897282598, 0.0000000000000000}); + points.push_back(Point3D{-7608.6860335274250, -7908.7010897282598, 0.0000000000000000}); + points.push_back(Point3D{11531.074457970564, 23121.638501036170, 0.0000000000000000}); + points.push_back(Point3D{12031.074457970564, 23121.638501036170, 0.0000000000000000}); + points.push_back(Point3D{-21902.083733627456, 21602.129728298649, 0.0000000000000000}); + points.push_back(Point3D{-21302.083733627456, 21602.129728298649, 0.0000000000000000}); + points.push_back(Point3D{-5079.0456527201459, 30173.900228539613, 0.0000000000000000}); + points.push_back(Point3D{-4479.0456527201459, 30173.900228539613, 0.0000000000000000}); + points.push_back(Point3D{-3223.9956954814261, 18461.557455070157, 0.0000000000000000}); + points.push_back(Point3D{-2623.9956954814261, 18461.557455070157, 0.0000000000000000}); + points.push_back(Point3D{2624.0444348900346, 18461.557454720794, 0.0000000000000000}); + points.push_back(Point3D{3224.0444348900346, 18461.557454720794, 0.0000000000000000}); + points.push_back(Point3D{-8405.0161077585071, 15906.991054460479, 0.0000000000000000}); + points.push_back(Point3D{-7805.0161077585071, 15906.991054460479, 0.0000000000000000}); + points.push_back(Point3D{4479.0942398422048, 30173.900228537284, 0.0000000000000000}); + points.push_back(Point3D{5079.0942398422048, 30173.900228537284, 0.0000000000000000}); + points.push_back(Point3D{-30473.855223292368, 4779.0894371719478, 0.0000000000000000}); + points.push_back(Point3D{-29873.855223292368, 4779.0894371719478, 0.0000000000000000}); + points.push_back(Point3D{-9834.8557113136048, 18811.339681665777, 0.0000000000000000}); + points.push_back(Point3D{-9334.8557113136048, 18811.339681665777, 0.0000000000000000}); + points.push_back(Point3D{13569.434806959180, 27220.270333465378, 0.0000000000000000}); + points.push_back(Point3D{14169.434806959180, 27220.270333465378, 0.0000000000000000}); + points.push_back(Point3D{13452.094479468651, -2178.0609130331286, 0.0000000000000000}); + points.push_back(Point3D{14052.094479468651, -2178.0609130331286, 0.0000000000000000}); + points.push_back(Point3D{7635.4943863257067, -4043.3108920587547, 0.0000000000000000}); + points.push_back(Point3D{8235.4943863257067, -4043.3108920587547, 0.0000000000000000}); + points.push_back(Point3D{-5030.7456039006938, -9284.6107577729126, 0.0000000000000000}); + points.push_back(Point3D{-4430.7456039006938, -9284.6107577729126, 0.0000000000000000}); + points.push_back(Point3D{9334.8840347801452, 18811.357259790777, 0.0000000000000000}); + points.push_back(Point3D{9834.8840347801452, 18811.357259790777, 0.0000000000000000}); + points.push_back(Point3D{-3675.6656478448422, 21628.976400436615, 0.0000000000000000}); + points.push_back(Point3D{-3175.6656478448422, 21628.976400436615, 0.0000000000000000}); + points.push_back(Point3D{3809.4943863322260, 25630.529134790777, 0.0000000000000000}); + points.push_back(Point3D{4309.4943863322260, 25630.529134790777, 0.0000000000000000}); + points.push_back(Point3D{4430.7846695982153, -9284.6210116034345, 0.0000000000000000}); + points.push_back(Point3D{5030.7846695982153, -9284.6210116034345, 0.0000000000000000}); + points.push_back(Point3D{-13855.715086132754, -13505.720376673606, 0.0000000000000000}); + points.push_back(Point3D{-13155.715086132754, -13505.720376673606, 0.0000000000000000}); + points.push_back(Point3D{-12131.054926622368, -23121.600743537347, 0.0000000000000000}); + points.push_back(Point3D{-11431.054926622368, -23121.600743537347, 0.0000000000000000}); + points.push_back(Point3D{-10578.765375099087, -1627.9909095301846, 0.0000000000000000}); + points.push_back(Point3D{-9978.7653750990867, -1627.9909095301846, 0.0000000000000000}); + points.push_back(Point3D{3175.7141128947260, 21628.976400436615, 0.0000000000000000}); + points.push_back(Point3D{3675.7141128947260, 21628.976400436615, 0.0000000000000000}); + points.push_back(Point3D{11239.354737904854, 11539.338705116606, 0.0000000000000000}); + points.push_back(Point3D{11839.354737904854, 11539.338705116606, 0.0000000000000000}); + points.push_back(Point3D{-17318.196043352364, -8671.2008456719195, 0.0000000000000000}); + points.push_back(Point3D{-16718.196043352364, -8671.2008456719195, 0.0000000000000000}); + points.push_back(Point3D{-14169.424558975501, 27220.248861367945, 0.0000000000000000}); + points.push_back(Point3D{-13569.424558975501, 27220.248861367945, 0.0000000000000000}); + points.push_back(Point3D{9978.8439957064693, -1627.9708957259863, 0.0000000000000000}); + points.push_back(Point3D{10578.843995706469, -1627.9708957259863, 0.0000000000000000}); + points.push_back(Point3D{13519.435304297367, -27220.250162088065, 0.0000000000000000}); + points.push_back(Point3D{14219.435304297367, -27220.250162088065, 0.0000000000000000}); + points.push_back(Point3D{-3550.8955367645249, -6380.2710360850760, 0.0000000000000000}); + points.push_back(Point3D{-2950.8955367645249, -6380.2710360850760, 0.0000000000000000}); + points.push_back(Point3D{10709.754156451614, -5609.7207374573773, 0.0000000000000000}); + points.push_back(Point3D{11309.754156451614, -5609.7207374573773, 0.0000000000000000}); + points.push_back(Point3D{12489.604245378461, 6516.6389926101110, 0.0000000000000000}); + points.push_back(Point3D{13089.604245378461, 6516.6389926101110, 0.0000000000000000}); + points.push_back(Point3D{-8235.4355452836026, -4043.3108920448431, 0.0000000000000000}); + points.push_back(Point3D{-7635.4355452836026, -4043.3108920448431, 0.0000000000000000}); + points.push_back(Point3D{2950.9448257543263, -6380.2808017734642, 0.0000000000000000}); + points.push_back(Point3D{3550.9448257543263, -6380.2808017734642, 0.0000000000000000}); + points.push_back(Point3D{-11309.696043347765, -5609.7207431293646, 0.0000000000000000}); + points.push_back(Point3D{-10709.696043347765, -5609.7207431293646, 0.0000000000000000}); + points.push_back(Point3D{-11839.285398820706, 11539.328939490792, 0.0000000000000000}); + points.push_back(Point3D{-11239.285398820706, 11539.328939490792, 0.0000000000000000}); + points.push_back(Point3D{-14052.005613667367, -2178.0908755634300, 0.0000000000000000}); + points.push_back(Point3D{-13452.005613667367, -2178.0908755634300, 0.0000000000000000}); + points.push_back(Point3D{-9021.2153273623553, -17018.201329904943, 0.0000000000000000}); + points.push_back(Point3D{-8321.2153273623553, -17018.201329904943, 0.0000000000000000}); + points.push_back(Point3D{-4309.4457381869433, 25630.529134784956, 0.0000000000000000}); + points.push_back(Point3D{-3809.4457381869433, 25630.529134784956, 0.0000000000000000}); + points.push_back(Point3D{-27520.215574607428, 13869.448080100890, 0.0000000000000000}); + points.push_back(Point3D{-26920.215574607428, 13869.448080100890, 0.0000000000000000}); + points.push_back(Point3D{-12031.065183990693, 23121.618978540777, 0.0000000000000000}); + points.push_back(Point3D{-11531.065183990693, 23121.618978540777, 0.0000000000000000}); + points.push_back(Point3D{7805.0446787483525, 15907.018391851525, 0.0000000000000000}); + points.push_back(Point3D{8405.0446787483525, 15907.018391851525, 0.0000000000000000}); + points.push_back(Point3D{4354.0942397164181, -30098.870279427545, 0.0000000000000000}); + points.push_back(Point3D{5204.0942397164044, -30098.870279427545, 0.0000000000000000}); + points.push_back(Point3D{-5204.0456527279457, -30098.870279264738, 0.0000000000000000}); + points.push_back(Point3D{-4354.0456527279594, -30098.870279264738, 0.0000000000000000}); + points.push_back(Point3D{-23421.612136159150, -11781.067532595984, 0.0000000000000000}); + points.push_back(Point3D{-22821.612136159150, -11781.067532595984, 0.0000000000000000}); + for (size_t i = 0; i < points.size(); i += 2) { cycle1(points[i], points[i + 1]); } + + /* Ϊһѭ͹̶鲻һһ */ + auto cycle2 = [&loader, tag1](const Point3D& point1, const Point3D point2, const Point3D point3, const Point3D point4) { + /* ѭ */ + const std::vector points = {point1, point2, point3, point4}; + std::vector bulges = {0.0000000000000000, 0.0000000000000000, 0.0000000000000000, 0.0000000000000000}; + Vector3D extusion = Vector3D{0.0000000000000000, 0.0000000000000000, 2850.0000000000000}; + auto cycleTag = loader.addExtrude(points, bulges, extusion); + + /* ѭ Zƫ -2900 */ + Direction3D direction = Direction3D{0, 0, 1}; + double offset = -2900; + loader.offset(cycleTag, direction, offset); + + /* 1ѭ岼 */ + loader.differentNode(tag1, cycleTag); + }; + + points.clear(); + bulges.clear(); + points.push_back(Point3D{-24963.009860716236, 7446.7650615308812, 0.0000000000000000}); + points.push_back(Point3D{-24459.052558350675, 7366.9792723925602, 0.0000000000000000}); + points.push_back(Point3D{-24388.685618648018, 7811.4435496937649, 0.0000000000000000}); + points.push_back(Point3D{-24833.149895949224, 7881.8104893964210, 0.0000000000000000}); + points.push_back(Point3D{24963.106150213611, 7446.7650615305229, 0.0000000000000000}); + points.push_back(Point3D{24459.148847848050, 7366.9792723922019, 0.0000000000000000}); + points.push_back(Point3D{24388.781908145393, 7811.4435496934066, 0.0000000000000000}); + points.push_back(Point3D{24833.246185446598, 7881.8104893960626, 0.0000000000000000}); + points.push_back(Point3D{6085.2898662776533, -18440.931060827090, 0.0000000000000000}); + points.push_back(Point3D{6530.7930936759531, -18213.935742862825, 0.0000000000000000}); + points.push_back(Point3D{6326.4973075081125, -17812.982838204356, 0.0000000000000000}); + points.push_back(Point3D{5880.9940801098128, -18039.978156168621, 0.0000000000000000}); + points.push_back(Point3D{9198.0021988374647, -24549.990396445304, 0.0000000000000000}); + points.push_back(Point3D{9643.5067429911614, -24322.997662776565, 0.0000000000000000}); + points.push_back(Point3D{9439.2132826892957, -23922.043573038238, 0.0000000000000000}); + points.push_back(Point3D{8993.7087385355990, -24149.036306706977, 0.0000000000000000}); + + // before = loader.getAreaAndVolume(tag1); + for (size_t i = 0; i < points.size(); i += 4) { cycle2(points[i], points[i + 1], points[i + 2], points[i + 3]); } + // after = loader.getAreaAndVolume(tag1); + + /* ȡ1 ǰ */ + // areaDifference = after.first - before.first; + // volumeDifference = after.second - before.second; + // std::cout << areaDifference << ", " << volumeDifference << std::endl; + + auto result = loader.getAreaAndVolume(tag1); + // std::cout << "result:" << result.first << ", " << result.second << std::endl; + + // loader.output(); +} + void loaderEntBool() { Loader loader; @@ -744,8 +1605,10 @@ void loaderEntBool() int main(int argc, char** argv) { - loaderEntBool(); + // loaderEntBool(); + // loaderTest2Simplified(); + // loaderTest2(); // loaderPolyTilted(); - // loaderPolyThickPlane(); + loaderPolyThickPlane(); return 0; } diff --git a/examples/example_loader2.hpp b/examples/example_loader2.hpp index 128655d..2bdd331 100644 --- a/examples/example_loader2.hpp +++ b/examples/example_loader2.hpp @@ -360,8 +360,8 @@ void loaderPolyTilted() } auto tag1 = loader.addMesh(points, indices, faces); - std::cout << "Des volume:" << std::endl; - loader.getAreaAndVolume(tag1); + // std::cout << "Des volume:" << std::endl; + // loader.getAreaAndVolume(tag1); auto tag2 = loader.addMesh( { @@ -376,8 +376,8 @@ void loaderPolyTilted() }, {0, 1, 2, 3, 0, 1, 5, 4, 1, 2, 6, 5, 2, 3, 7, 6, 3, 0, 4, 7, 4, 5, 6, 7}, {{0, 4}, {4, 4}, {8, 4}, {12, 4}, {16, 4}, {20, 4}}); - std::cout << "Src volume:" << std::endl; - loader.getAreaAndVolume(tag2); + // std::cout << "Src volume:" << std::endl; + // loader.getAreaAndVolume(tag2); loader.differentNode(tag1, tag2); loader.getAreaAndVolume(tag1); @@ -407,25 +407,25 @@ void loaderPolyThickPlane() std::cout << "Des volume:" << std::endl; loader.getAreaAndVolume(tag1); - auto tag2 = loader.addMesh( - { - {2629.99453728099, 8340.01156816906, 52180.00000000000}, - {2869.99453728099, 8340.01156816906, 52180.00000000000}, - {2869.99453728099, 8401.36916293070, 52180.00000000000}, - {2869.99453728099, 8580.01156816906, 52180.00000000000}, - {2629.99453728099, 8580.01156816906, 52180.00000000000}, - {2629.99453728099, 8340.02684557581, 52180.00000000000}, - {2629.99453728099, 8340.01156816906, 49030.00000000000}, - {2869.99453728099, 8340.01156816906, 49030.00000000000}, - {2869.99453728099, 8401.36916293070, 49030.00000000000}, - {2869.99453728099, 8580.01156816906, 49030.00000000000}, - {2629.99453728099, 8580.01156816906, 49030.00000000000} - }, - {0, 1, 2, 3, 4, 5, 6, 7, 1, 0, 7, 8, 9, 3, 2, 1, 9, 10, 4, 3, 10, 6, 0, 5, 4, 6, 10, 9, 8, 7}, - {{0, 6}, {6, 4}, {10, 6}, {16, 4}, {20, 5}, {25, 5}}); - std::cout << "Src volume:" << std::endl; - loader.getAreaAndVolume(tag2); + // auto tag2 = loader.addMesh( + // { + // {2629.99453728099, 8340.01156816906, 52180.00000000000}, + // {2869.99453728099, 8340.01156816906, 52180.00000000000}, + // {2869.99453728099, 8401.36916293070, 52180.00000000000}, + // {2869.99453728099, 8580.01156816906, 52180.00000000000}, + // {2629.99453728099, 8580.01156816906, 52180.00000000000}, + // {2629.99453728099, 8340.02684557581, 52180.00000000000}, + // {2629.99453728099, 8340.01156816906, 49030.00000000000}, + // {2869.99453728099, 8340.01156816906, 49030.00000000000}, + // {2869.99453728099, 8401.36916293070, 49030.00000000000}, + // {2869.99453728099, 8580.01156816906, 49030.00000000000}, + // {2629.99453728099, 8580.01156816906, 49030.00000000000} + // }, + // {0, 1, 2, 3, 4, 5, 6, 7, 1, 0, 7, 8, 9, 3, 2, 1, 9, 10, 4, 3, 10, 6, 0, 5, 4, 6, 10, 9, 8, 7}, + // {{0, 6}, {6, 4}, {10, 6}, {16, 4}, {20, 5}, {25, 5}}); + // std::cout << "Src volume:" << std::endl; + // loader.getAreaAndVolume(tag2); - loader.differentNode(tag1, tag2); - loader.getAreaAndVolume(tag1); + // loader.differentNode(tag1, tag2); + // loader.getAreaAndVolume(tag1); }