6
$\begingroup$

I have data like this:

DataVisualizationPlot = ListPointPlot3D[data]

enter image description here

And would like to obtain the representing surface like this:

surfacefunc = BSplineFunction[data, SplineClosed -> {True, True}, SplineDegree -> 3];
surface = BSplineSurface[data, SplineClosed -> {True, True}, SplineDegree -> 3];
Show[Graphics3D[surface], DataVisualizationPlot]

enter image description here

Now I would like to obtain a Region from surfacefunc or surface. How would I do this?

I tried:

ParametricRegion[{Indexed[surfacefunc[θ, φ], 1], Indexed[surfacefunc[θ, φ], 2], Indexed[surfacefunc[θ, φ], 3]}, {{θ, 0, 1}, {φ, 0, 1}}]

According to this this questions. But this fails (gives me back my input).

Here is the (downsampled) data I am using:

data = {{{20.7241, 2.6313, -0.958896}, {20.6579, 1.6232, 2.17988}, {19.6809, 
   0.809182, 4.93326}, {18.1495, 0.232267, 6.96528}, {16.0862, 
   0.25068, 8.23515}, {13.305, 0.122614, 8.10287}, {12.5783, -1.66508,
    5.51201}, {13.362, -1.56645, 2.79238}, {14.0258, 0.354933, 
   0.540142}, {13.7853, 2.23253, -1.90586}, {12.9562, 
   3.72589, -4.47214}, {13.9527, 3.58837, -6.95238}, {16.7421, 
   2.63516, -7.69454}, {18.7952, 2.79434, -6.0844}, {20.0849, 
   2.83319, -3.73606}, {20.7241, 2.6313, -0.958896}}, {{19.468, 
   6.31246, -2.02679}, {19.3781, 6.2076, 0.806302}, {18.6902, 5.76271,
    3.60029}, {17.531, 4.71474, 6.25544}, {15.8671, 3.81076, 
   8.06302}, {13.7203, 3.16293, 8.86713}, {11.0759, 2.37486, 
   8.15418}, {10.1418, 1.42822, 5.40309}, {12.3264, 0.516888, 
   3.05301}, {13.4832, 1.76188, 0.598635}, {13.4504, 
   3.59678, -1.8133}, {12.6405, 5.60668, -4.13329}, {13.6336, 
   6.58546, -5.89892}, {16.7385, 6.34902, -6.59126}, {18.689, 
   6.39298, -4.70006}, {19.468, 6.31246, -2.02679}}, {{17.0021, 
   10.4027, -2.69022}, {17.3318, 9.75113, 0.187506}, {16.3727, 
   9.33611, 2.96241}, {15.1913, 8.09968, 5.71207}, {13.5028, 6.82737, 
   7.74435}, {11.3616, 5.69612, 8.67034}, {9.30278, 4.11132, 
   8.25942}, {7.95726, 2.94108, 6.24303}, {8.88154, 2.46133, 
   3.38205}, {11.7948, 2.32406, 1.65432}, {12.6464, 
   3.87895, -0.797979}, {12.2489, 5.95015, -2.77211}, {11.9038, 
   7.7919, -4.04264}, {13.2866, 9.57274, -5.16344}, {15.2138, 
   10.6008, -4.75862}, {17.0021, 10.4027, -2.69022}}, {{14.1895, 
   13.1735, -2.40893}, {15.1891, 12.0797, 0.318843}, {14.0102, 
   11.4668, 3.04077}, {12.0694, 10.758, 5.24092}, {9.83536, 9.32558, 
   6.90425}, {7.91743, 7.28718, 7.68509}, {6.21514, 5.02538, 
   7.13403}, {5.12778, 3.59505, 4.86797}, {5.5905, 3.30795, 
   2.32939}, {8.45417, 3.90559, 0.410677}, {11.1106, 
   5.08825, -1.28437}, {10.7999, 7.10519, -2.83511}, {9.99013, 
   9.23944, -3.66546}, {10.9745, 12.2539, -3.79284}, {12.4215, 
   13.2876, -3.40139}, {14.1895, 13.1735, -2.40893}}, {{11.2012, 
   15.6801, -0.962747}, {12.7699, 14.0564, 0.727781}, {11.4534, 
   13.1432, 3.22443}, {9.00629, 12.161, 4.78537}, {6.51459, 10.6795, 
   5.50792}, {4.67103, 8.1836, 5.72466}, {3.79296, 5.65757, 
   5.4768}, {2.91137, 3.46482, 3.05997}, {3.18801, 3.48183, 
   0.119388}, {4.724, 4.4462, -1.59956}, {7.10721, 
   6.07631, -2.54694}, {8.57125, 8.24611, -3.48069}, {8.33168, 
   11.0158, -4.30245}, {7.92445, 14.0864, -3.69932}, {8.97529, 
   16.3203, -1.60139}, {11.2012, 15.6801, -0.962747}}, {{7.97877, 
   17.5406, 0.962748}, {9.64617, 15.933, 1.60139}, {8.23695, 13.906, 
   3.69932}, {5.37414, 12.7234, 4.30245}, {2.85572, 11.546, 
   3.48069}, {1.70864, 9.19318, 2.54694}, {1.48852, 6.3142, 
   1.59956}, {1.42135, 4.50182, -0.119387}, {1.54494, 
   4.25373, -3.05997}, {3.00312, 6.11359, -5.4768}, {4.7517, 
   8.13703, -5.72466}, {5.99141, 10.9815, -5.50792}, {6.02859, 
   13.8802, -4.78537}, {5.65562, 16.4905, -3.22443}, {5.78823, 
   18.0872, -0.727781}, {7.97877, 17.5406, 0.962748}}, {{4.31384, 
   18.8752, 2.40893}, {5.29669, 17.4011, 3.40139}, {5.12488, 15.6312, 
   3.79284}, {3.00652, 13.2714, 3.66546}, {0.75335, 12.9055, 
   2.83511}, {-1.14876, 12.1662, 1.28437}, {-0.844748, 
   9.27433, -0.410678}, {0.0695202, 6.49549, -2.3294}, {0.549512, 
   6.23831, -4.86797}, {1.24454, 7.89516, -7.13403}, {2.35217, 
   10.5003, -7.68509}, {3.15851, 13.1805, -6.90425}, {3.28199, 
   15.8314, -5.24092}, {2.92538, 17.8666, -3.04077}, {2.86678, 
   19.194, -0.318843}, {4.31384, 18.8752, 2.40893}}, {{0.507987, 
   19.9256, 2.69022}, {1.57368, 18.4759, 4.75862}, {1.64693, 16.2929, 
   5.16344}, {0.796068, 14.205, 4.04264}, {-0.971442, 13.5829, 
   2.77211}, {-2.96394, 12.8916, 0.797978}, {-3.88472, 
   11.3767, -1.65432}, {-2.30919, 8.9223, -3.38205}, {-1.43158, 
   8.36173, -6.24303}, {-1.09089, 10.1121, -8.25942}, {-0.747821, 
   12.6875, -8.67034}, {-0.838713, 15.1074, -7.74435}, {-0.58112, 
   17.2059, -5.71207}, {-0.101055, 18.8473, -2.96241}, {-0.22116, 
   19.8853, -0.187507}, {0.507987, 19.9256, 2.69022}}, {{-4.26724, 
   20.016, 2.02679}, {-3.808, 19.3816, 4.70006}, {-2.87086, 17.6705, 
   6.59126}, {-1.11363, 15.0998, 5.89892}, {-1.46473, 13.7503, 
   4.13329}, {-3.6103, 13.4468, 1.8133}, {-5.21576, 
   12.5577, -0.598634}, {-5.71556, 10.9334, -3.05301}, {-3.834, 
   9.49712, -5.40309}, {-3.48124, 10.7794, -8.15418}, {-4.12095, 
   13.4636, -8.86713}, {-4.63333, 15.6467, -8.06302}, {-4.68242, 
   17.5397, -6.25545}, {-4.35444, 19.0675, -3.6003}, {-4.31311, 
   19.8857, -0.806302}, {-4.26724, 20.016, 2.02679}}, {{-8.08329, 
   19.2633, 0.958896}, {-7.58884, 18.8106, 3.73606}, {-6.97763, 
   17.6743, 6.0844}, {-6.08895, 15.8167, 7.69454}, {-3.86874, 13.8776,
    6.95238}, {-3.25136, 13.0833, 4.47214}, {-4.95921, 13.0547, 
   1.90586}, {-6.70552, 12.3242, -0.540142}, {-8.03756, 
   10.7886, -2.79237}, {-7.73117, 10.0606, -5.51201}, {-6.54633, 
   11.5838, -8.10287}, {-7.82599, 14.0564, -8.23515}, {-8.8736, 
   15.8341, -6.96528}, {-9.13965, 17.4487, -4.93326}, {-8.9232, 
   18.7018, -2.17989}, {-8.08329, 19.2633, 0.958896}}, {{-12.6408, 
   16.632, -0.958896}, {-11.7347, 17.0786, 2.17988}, {-10.5412, 
   16.6395, 4.93326}, {-9.2759, 15.6018, 6.96528}, {-8.26018, 13.8057,
    8.23515}, {-6.75871, 11.4612, 8.10287}, {-4.84717, 11.7257, 
   5.51201}, {-5.32439, 12.355, 2.79238}, {-7.32028, 11.9692, 
   0.540142}, {-8.82606, 10.8221, -1.90586}, {-9.70479, 
   9.35742, -4.47214}, {-10.084, 10.2892, -6.95238}, {-10.6532, 
   13.1815, -7.69454}, {-11.8176, 14.8799, -6.0844}, {-12.4961, 
   15.9774, -3.73606}, {-12.6408, 16.632, -0.958896}}, {{-15.2007, 
   13.7035, -2.02679}, {-15.065, 13.6781, 0.806302}, {-14.3357, 
   13.3048, 3.60029}, {-12.8486, 12.8249, 6.25544}, {-11.2338, 
   11.8359, 8.06302}, {-9.5993, 10.3006, 8.86713}, {-7.59461, 8.40454,
    8.15418}, {-6.30775, 8.0689, 5.40309}, {-6.61084, 10.4165, 
   3.05301}, {-8.26742, 10.7958, 0.598635}, {-9.84011, 
   9.85001, -1.8133}, {-11.1758, 8.14366, -4.13329}, {-12.52, 
   8.51432, -5.89892}, {-13.8677, 11.3215, -6.59126}, {-14.881, 
   12.9886, -4.70006}, {-15.2007, 13.7035, -2.02679}}, {{-17.51, 
   9.52286, -2.69022}, {-17.1106, 10.1342, 0.187506}, {-16.2717, 
   9.51114, 2.96241}, {-14.6102, 9.10621, 5.71207}, {-12.6641, 
   8.28006, 7.74435}, {-10.6138, 6.99138, 8.67034}, {-8.2119, 6.00079,
    8.25942}, {-6.52568, 5.42065, 6.24303}, {-6.57235, 6.46097, 
   3.38205}, {-7.91012, 9.0526, 1.65432}, {-9.68247, 
   9.01263, -0.797979}, {-11.2774, 7.63274, -2.77211}, {-12.6999, 
   6.41306, -4.04264}, {-14.9335, 6.72018, -5.16344}, {-16.7875, 
   7.87511, -4.75862}, {-17.51, 9.52286, -2.69022}}, {{-18.5033, 
   5.7017, -2.40893}, {-18.0559, 7.11428, 0.318843}, {-16.9356, 
   6.39984, 3.04077}, {-15.3514, 5.07342, 5.24092}, {-12.9939, 
   3.85488, 6.90425}, {-10.2696, 3.2131, 7.68509}, {-7.45968, 2.86978,
    7.13403}, {-5.67729, 2.64327, 4.86797}, {-5.66002, 3.18754, 
   2.32939}, {-7.60943, 5.36873, 0.410677}, {-9.96187, 
   7.07796, -1.28437}, {-11.5532, 5.80035, -2.83511}, {-12.9967, 
   4.03199, -3.66546}, {-16.0994, 3.37731, -3.79284}, {-17.7182, 
   4.1135, -3.40139}, {-18.5033, 5.7017, -2.40893}}, {{-19.18, 
   1.86048, -0.962747}, {-18.5581, 4.03085, 0.727781}, {-17.109, 
   3.34736, 3.22443}, {-15.0349, 1.71918, 4.78537}, {-12.506, 
   0.302055, 5.50792}, {-9.42272, -0.0465748, 5.72466}, {-6.79608, 
   0.456018, 5.4768}, {-4.45631, 0.788911, 3.05997}, {-4.60936, 
   1.01998, 0.119388}, {-6.21252, 1.86801, -1.59956}, {-8.81584, 
   3.11687, -2.54694}, {-11.427, 3.29987, -3.48069}, {-13.7058, 
   1.70754, -4.30245}, {-16.1614, -0.180422, -3.69932}, {-18.6215, \
-0.387334, -1.60139}, {-19.18, 
   1.86048, -0.962747}}, {{-19.18, -1.86047, 0.962748}, {-18.6214, 
   0.387334, 1.60139}, {-16.1614, 0.180418, 
   3.69932}, {-13.7058, -1.70754, 4.30245}, {-11.427, -3.29987, 
   3.48069}, {-8.81584, -3.11687, 2.54694}, {-6.21252, -1.86801, 
   1.59956}, {-4.60936, -1.01998, -0.119387}, {-4.45631, -0.788912, \
-3.05997}, {-6.79608, -0.456018, -5.4768}, {-9.42272, 
   0.0465741, -5.72466}, {-12.506, -0.302058, -5.50792}, {-15.0349, \
-1.71918, -4.78537}, {-17.109, -3.34736, -3.22443}, {-18.5581, \
-4.03085, -0.727781}, {-19.18, -1.86047, 
   0.962748}}, {{-18.5033, -5.70169, 2.40893}, {-17.7182, -4.1135, 
   3.40139}, {-16.0994, -3.37731, 3.79284}, {-12.9967, -4.03199, 
   3.66546}, {-11.5532, -5.80035, 2.83511}, {-9.96187, -7.07796, 
   1.28437}, {-7.60943, -5.36874, -0.410678}, {-5.66002, -3.18754, \
-2.3294}, {-5.67729, -2.64327, -4.86797}, {-7.45968, -2.86978, \
-7.13403}, {-10.2696, -3.2131, -7.68509}, {-12.9939, -3.85488, \
-6.90425}, {-15.3514, -5.07343, -5.24092}, {-16.9356, -6.39984, \
-3.04077}, {-18.0559, -7.11429, -0.318843}, {-18.5033, -5.70169, 
   2.40893}}, {{-17.5101, -9.52286, 2.69022}, {-16.7875, -7.87511, 
   4.75862}, {-14.9335, -6.72018, 5.16344}, {-12.6999, -6.41306, 
   4.04264}, {-11.2774, -7.63274, 2.77211}, {-9.68247, -9.01263, 
   0.797978}, {-7.91012, -9.0526, -1.65432}, {-6.57235, -6.46097, \
-3.38205}, {-6.52568, -5.42065, -6.24303}, {-8.2119, -6.00079, \
-8.25942}, {-10.6138, -6.99138, -8.67034}, {-12.6641, -8.28006, \
-7.74435}, {-14.6102, -9.10621, -5.71207}, {-16.2717, -9.51114, \
-2.96241}, {-17.1106, -10.1342, -0.187507}, {-17.5101, -9.52286, 
   2.69022}}, {{-15.2007, -13.7035, 2.02679}, {-14.881, -12.9886, 
   4.70006}, {-13.8677, -11.3215, 6.59126}, {-12.52, -8.51431, 
   5.89892}, {-11.1758, -8.14367, 4.13329}, {-9.8401, -9.85, 
   1.8133}, {-8.26743, -10.7958, -0.598634}, {-6.61084, -10.4165, \
-3.05301}, {-6.30775, -8.0689, -5.40309}, {-7.59462, -8.40454, \
-8.15418}, {-9.5993, -10.3006, -8.86713}, {-11.2338, -11.8359, \
-8.06302}, {-12.8486, -12.8249, -6.25545}, {-14.3357, -13.3048, \
-3.6003}, {-15.065, -13.6781, -0.806302}, {-15.2007, -13.7035, 
   2.02679}}, {{-12.6408, -16.632, 0.958896}, {-12.4961, -15.9774, 
   3.73606}, {-11.8176, -14.8799, 6.0844}, {-10.6532, -13.1815, 
   7.69454}, {-10.084, -10.2892, 6.95238}, {-9.70479, -9.35741, 
   4.47214}, {-8.82606, -10.8221, 
   1.90586}, {-7.32028, -11.9692, -0.540142}, {-5.32439, -12.355, \
-2.79237}, {-4.84717, -11.7257, -5.51201}, {-6.75871, -11.4612, \
-8.10287}, {-8.26018, -13.8057, -8.23515}, {-9.2759, -15.6018, \
-6.96528}, {-10.5412, -16.6395, -4.93326}, {-11.7347, -17.0786, \
-2.17989}, {-12.6408, -16.632, 
   0.958896}}, {{-8.08329, -19.2633, -0.958896}, {-8.9232, -18.7018, 
   2.17988}, {-9.13965, -17.4487, 4.93326}, {-8.8736, -15.8341, 
   6.96528}, {-7.82599, -14.0564, 8.23515}, {-6.54633, -11.5838, 
   8.10287}, {-7.73117, -10.0606, 5.51201}, {-8.03756, -10.7886, 
   2.79238}, {-6.70552, -12.3242, 
   0.540142}, {-4.9592, -13.0546, -1.90586}, {-3.25137, -13.0833, \
-4.47214}, {-3.86874, -13.8776, -6.95238}, {-6.08895, -15.8167, \
-7.69454}, {-6.97763, -17.6743, -6.0844}, {-7.58884, -18.8106, \
-3.73606}, {-8.08329, -19.2633, -0.958896}}, {{-4.26724, -20.016, \
-2.02679}, {-4.31311, -19.8857, 0.806302}, {-4.35444, -19.0675, 
   3.60029}, {-4.68242, -17.5397, 6.25544}, {-4.63333, -15.6467, 
   8.06302}, {-4.12095, -13.4636, 8.86713}, {-3.48124, -10.7794, 
   8.15418}, {-3.834, -9.49712, 5.40309}, {-5.71556, -10.9334, 
   3.05301}, {-5.21576, -12.5577, 
   0.598635}, {-3.6103, -13.4468, -1.8133}, {-1.46473, -13.7503, \
-4.13329}, {-1.11363, -15.0998, -5.89892}, {-2.87086, -17.6705, \
-6.59126}, {-3.808, -19.3816, -4.70006}, {-4.26724, -20.016, \
-2.02679}}, {{0.50799, -19.9256, -2.69022}, {-0.221158, -19.8853, 
   0.187506}, {-0.101052, -18.8472, 2.96241}, {-0.581119, -17.2059, 
   5.71207}, {-0.83871, -15.1074, 7.74435}, {-0.74782, -12.6875, 
   8.67034}, {-1.09088, -10.1121, 8.25942}, {-1.43158, -8.36173, 
   6.24303}, {-2.30919, -8.9223, 3.38205}, {-3.88472, -11.3767, 
   1.65432}, {-2.96393, -12.8916, -0.797979}, {-0.971442, -13.5829, \
-2.77211}, {0.796072, -14.205, -4.04264}, {1.64693, -16.2929, \
-5.16344}, {1.57368, -18.4759, -4.75862}, {0.50799, -19.9256, \
-2.69022}}, {{4.31384, -18.8752, -2.40893}, {2.86678, -19.194, 
   0.318843}, {2.92538, -17.8666, 3.04077}, {3.28199, -15.8314, 
   5.24092}, {3.15851, -13.1805, 6.90425}, {2.35217, -10.5003, 
   7.68509}, {1.24454, -7.89516, 7.13403}, {0.549512, -6.23831, 
   4.86797}, {0.0695199, -6.49549, 2.32939}, {-0.844747, -9.27432, 
   0.410677}, {-1.14876, -12.1662, -1.28437}, {0.75335, -12.9055, \
-2.83511}, {3.00653, -13.2714, -3.66546}, {5.12488, -15.6312, \
-3.79284}, {5.29668, -17.4011, -3.40139}, {4.31384, -18.8752, \
-2.40893}}, {{7.97877, -17.5406, -0.962747}, {5.78823, -18.0872, 
   0.727781}, {5.65563, -16.4905, 3.22443}, {6.02859, -13.8802, 
   4.78537}, {5.99141, -10.9815, 5.50792}, {4.7517, -8.13703, 
   5.72466}, {3.00312, -6.11359, 5.4768}, {1.54494, -4.25373, 
   3.05997}, {1.42135, -4.50181, 
   0.119388}, {1.48852, -6.3142, -1.59956}, {1.70863, -9.19318, \
-2.54694}, {2.85572, -11.546, -3.48069}, {5.37414, -12.7234, \
-4.30245}, {8.23695, -13.906, -3.69932}, {9.64617, -15.933, \
-1.60139}, {7.97877, -17.5406, -0.962747}}, {{11.2012, -15.6801, 
   0.962748}, {8.97528, -16.3203, 1.60139}, {7.92446, -14.0864, 
   3.69932}, {8.33168, -11.0158, 4.30245}, {8.57125, -8.24611, 
   3.48069}, {7.10721, -6.07631, 2.54694}, {4.724, -4.44619, 
   1.59956}, {3.18801, -3.48183, -0.119387}, {2.91137, -3.46482, \
-3.05997}, {3.79296, -5.65757, -5.4768}, {4.67103, -8.1836, \
-5.72466}, {6.51459, -10.6795, -5.50792}, {9.00629, -12.161, \
-4.78537}, {11.4534, -13.1432, -3.22443}, {12.7699, -14.0564, \
-0.727781}, {11.2012, -15.6801, 0.962748}}, {{14.1895, -13.1735, 
   2.40893}, {12.4215, -13.2876, 3.40139}, {10.9745, -12.2539, 
   3.79284}, {9.99013, -9.23944, 3.66546}, {10.7999, -7.10519, 
   2.83511}, {11.1106, -5.08825, 
   1.28437}, {8.45418, -3.90559, -0.410678}, {5.59049, -3.30795, \
-2.3294}, {5.12778, -3.59505, -4.86797}, {6.21514, -5.02538, \
-7.13403}, {7.91742, -7.28718, -7.68509}, {9.83536, -9.32558, \
-6.90425}, {12.0694, -10.758, -5.24092}, {14.0102, -11.4667, \
-3.04077}, {15.1891, -12.0797, -0.318843}, {14.1895, -13.1735, 
   2.40893}}, {{17.0021, -10.4027, 2.69022}, {15.2138, -10.6008, 
   4.75862}, {13.2866, -9.57274, 5.16344}, {11.9038, -7.7919, 
   4.04264}, {12.2488, -5.95015, 2.77211}, {12.6464, -3.87895, 
   0.797978}, {11.7948, -2.32407, -1.65432}, {8.88154, -2.46133, \
-3.38205}, {7.95726, -2.94108, -6.24303}, {9.30279, -4.11132, \
-8.25942}, {11.3616, -5.69612, -8.67034}, {13.5028, -6.82737, \
-7.74435}, {15.1913, -8.09968, -5.71207}, {16.3727, -9.33611, \
-2.96241}, {17.3318, -9.75112, -0.187507}, {17.0021, -10.4027, 
   2.69022}}, {{19.468, -6.31246, 2.02679}, {18.689, -6.39297, 
   4.70006}, {16.7385, -6.34901, 6.59126}, {13.6336, -6.58546, 
   5.89892}, {12.6405, -5.60667, 4.13329}, {13.4504, -3.59678, 
   1.8133}, {13.4832, -1.76188, -0.598634}, {12.3264, -0.51689, \
-3.05301}, {10.1417, -1.42822, -5.40309}, {11.0759, -2.37486, \
-8.15418}, {13.7203, -3.16293, -8.86713}, {15.8671, -3.81076, \
-8.06302}, {17.531, -4.71474, -6.25545}, {18.6902, -5.7627, -3.6003}, \
{19.3781, -6.2076, -0.806302}, {19.468, -6.31246, 
   2.02679}}, {{20.7241, -2.6313, 0.958896}, {20.0849, -2.83319, 
   3.73606}, {18.7952, -2.79434, 6.0844}, {16.7421, -2.63517, 
   7.69454}, {13.9527, -3.58837, 6.95238}, {12.9562, -3.72589, 
   4.47214}, {13.7853, -2.23253, 
   1.90586}, {14.0258, -0.35493, -0.540142}, {13.3619, 
   1.56645, -2.79237}, {12.5783, 
   1.66508, -5.51201}, {13.305, -0.122616, -8.10287}, {16.0862, \
-0.250681, -8.23515}, {18.1495, -0.232265, -6.96528}, {19.6809, \
-0.809185, -4.93326}, {20.6579, -1.6232, -2.17989}, {20.7241, -2.6313,
    0.958896}}}

Edit:

The proposed Solution so far (thanks @cvgmt) is the following:

surfacefunc = BSplineFunction[coils, SplineClosed -> {True, True}, SplineDegree -> 3];
plot = ParametricPlot3D[surfacefunc[u, v], {u, 0, 1}, {v, 0, 1}, Boxed -> False, Axes -> False, PlotRange -> Automatic, PlotPoints -> 11];
reg = DiscretizeGraphics[plot , PlotRange -> Automatic];
FindMeshDefects[reg]

enter image description here

reg is a Region indeed, but the underlying mesh seems to be ill defined. Is there any way to fix this?

$\endgroup$
1
  • 1
    $\begingroup$ Michael E2's method is better than my approach if we replace DiscretizeGraphics to BoundaryDiscretizeGraphics $\endgroup$
    – cvgmt
    Commented Nov 24, 2020 at 23:01

3 Answers 3

6
$\begingroup$

Here are some modifications to ParametricPlot:

   Method -> {"BoundaryOffset" -> False}
   Mesh -> None
   PlotPoints -> {40, 20}
   MaxRecursion -> 1
   PlotRange -> All

The first one is important, since it allows the pairs of boundaries, u == 0, u == 1 and v == 0, v == 1, to match up. The Mesh option is important because it prevents the polygons being broken for the sake of a mesh line. The next two needed tweaking. Some settings resulted in meshes that had problems. Sometimes the problems were fixed with RepairMesh and sometimes not. The best chance of generating a defect-free mesh is MaxRecursion -> 0, since the recursive subdivision is not guaranteed to match up on opposite edges; usually RepairMesh fixes this problem. PlotRange -> All is safer than Automatic; I sometimes got small holes from the surface being clipped.

surfacefunc = 
  BSplineFunction[data, SplineClosed -> {True, True}, 
   SplineDegree -> 3];
plot = ParametricPlot3D[surfacefunc[u, v], {u, 0, 1}, {v, 0, 1}, 
   PlotRange -> All,
   PlotPoints -> {40, 20}, (* to get initial grid of approx. squares *)
   MaxRecursion -> 1,   (* works with 0, 1; 2 requires RepairMesh *)
   Method -> {"BoundaryOffset" -> False},
   Mesh -> None];
reg = DiscretizeGraphics[plot, PlotRange -> Automatic];
FindMeshDefects[reg]

enter image description here

$\endgroup$
2
  • 3
    $\begingroup$ Wonderful!!! It is perfect if we replace DiscretizeGraphics to BoundaryDiscretizeGraphics,since we can calculate the volume. $\endgroup$
    – cvgmt
    Commented Nov 24, 2020 at 22:52
  • $\begingroup$ Thank you a lot Michael, it works beautifully! $\endgroup$
    – Mr Puh
    Commented Nov 25, 2020 at 9:45
6
$\begingroup$

Edit

Or directly construct such BoundaryMeshRegion.

data

surfacefunc = 
  BSplineFunction[data, SplineClosed -> {True, True}, 
   SplineDegree -> 3];
ptss = Table[
   surfacefunc[u, v], {u, Subdivide[0, 1, 400]}, {v, 
    Subdivide[0, 1, 200]}];
{m, n, p} = Dimensions[ptss];
bm = BoundaryMeshRegion[
  Catenate[
   ptss], {Table[
    Polygon[{{#1[[1]], #2[[1]], #2[[2]]}, {#1[[2]], #1[[1]], \
#2[[2]]}}] & @@@ 
     Thread@{Partition[Range[1, n] + j*n, 2, 1], 
       Partition[Range[1, n] + (j + 1)*n, 2, 1]}, {j, 0, m - 2}]}]
bm // Volume

enter image description here

9687.98

Original

surfacefunc = 
  BSplineFunction[data, SplineClosed -> {True, True}, 
   SplineDegree -> 3];
reg = ParametricPlot3D[surfacefunc[u, v], {u, 0, 1}, {v, 0, 1}, 
   Boxed -> False, Axes -> False];
DiscretizeGraphics[reg]
$\endgroup$
5
  • $\begingroup$ If I Volume[DiscretizeGraphics[reg]] I get: Undefined.How to fix this? $\endgroup$ Commented Nov 24, 2020 at 10:16
  • 3
    $\begingroup$ @MariuszIwaniuk It's undefined because if you look at mesh = DiscretizeGraphics[reg]; FindMeshDefects[mesh] it has holes and is therefore not a solid object. You could also use SolidRegionQ[mesh] too and it returns False. Unfortunately RepairMesh is not clever enough to stitch the edges up so it becomes solid. It's a lot easier to export it to 3D software and fix it than performing this stitching within Mathematica. $\endgroup$
    – flinty
    Commented Nov 24, 2020 at 15:00
  • $\begingroup$ @cvgmt Thanks a lot for your answer. I visualized your answer in an edit. The underlying Mesh however seems to be having some problems.. Mostly it looks like the periodic closure isn't done correctly. Do you have any idea how one could fix this? $\endgroup$
    – Mr Puh
    Commented Nov 24, 2020 at 17:25
  • 2
    $\begingroup$ @MariuszIwaniuk reg a surface mesh and does not define a solid. I tried to convert a repaired mesh to a boundary region, but I got an error $\endgroup$
    – Michael E2
    Commented Nov 24, 2020 at 19:42
  • $\begingroup$ @cvgmt,@flinty, @Michael E2, thanks for the exact explanation. $\endgroup$ Commented Nov 25, 2020 at 9:31
3
$\begingroup$

The Indexed approach produces:

reg = ParametricRegion[
    {
    Indexed[surfacefunc[θ, φ], 1],
    Indexed[surfacefunc[θ, φ], 2],
    Indexed[surfacefunc[θ, φ], 3]
    },
    {{θ, 0, 1}, {φ, 0, 1}}
];
mesh = DiscretizeRegion[reg, PerformanceGoal->"Quality"];

FindMeshDefects[mesh]

enter image description here

$\endgroup$
1
  • $\begingroup$ With FindMeshDefects[RepairMesh@mesh] the mesh issues of this answer seem to be fixed! Nice. But.. why is there a macroscopic hole at the top right? $\endgroup$
    – Mr Puh
    Commented Nov 24, 2020 at 18:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.