@@ -1015,7 +1015,7 @@ void resolve_floating_polygons(
1015
1015
1016
1016
// NOTE: using max (i.e. < operator) lead to floating point precision issues on
1017
1017
// test 40. The only solution to which is exact arithmetic. However, since we still
1018
- // want MCUT to work even if the user only has fixed precision numbers.
1018
+ // want MCUT to work even if the user only has fixed precision numbers (outdated) .
1019
1019
// We pick edges based on this which are closest. No worries about colinear edges
1020
1020
// because they will be detected later and skipped!
1021
1021
auto fp_max_dist_predicate = [&](std::pair<int , int > edgePairA,
@@ -1079,14 +1079,16 @@ void resolve_floating_polygons(
1079
1079
it != polyVerts.cend ();
1080
1080
++it)
1081
1081
{
1082
-
1082
+ // TODO: call "collinear" with vec3_<double> not vec3. That is the only way to
1083
+ // get a reliable measure because with double everything is in the same space/units
1084
+ // (lengths areas etc).
1083
1085
bool are_collinear = collinear (segStart, segEnd, (*it), predResult);
1084
1086
// last ditch attempt to prevent the possibility of creating a partitioning
1085
1087
// edge that more-or-less passes through a vertex (of origin-face or the floatig poly itself)
1086
1088
// see: test41
1087
- const scalar_t epsilon = 1e-6 ;
1089
+ const double epsilon = 1e-6 ;
1088
1090
#if MCUT_WITH_ARBITRARY_PRECISION_NUMBERS
1089
- if (are_collinear || (!are_collinear && epsilon > absolute_value (predResult)))
1091
+ if (are_collinear || epsilon > scalar_t::dequantize ( absolute_value (predResult),multiplier ))
1090
1092
#else
1091
1093
if (are_collinear || (!are_collinear && epsilon > std::fabs (predResult)))
1092
1094
#endif
@@ -2213,6 +2215,20 @@ bool calculate_vertex_parameters(
2213
2215
2214
2216
pre_quantization_translation = to_positive_quadrant + offset_from_origin;
2215
2217
2218
+ //
2219
+ // update bboxes and coms
2220
+ //
2221
+ srcmesh_com = srcmesh_com + pre_quantization_translation;
2222
+ cutmesh_com = cutmesh_com + pre_quantization_translation;
2223
+ srcmesh_cutmesh_com = srcmesh_cutmesh_com + pre_quantization_translation;
2224
+ srcmesh_bboxmin = srcmesh_bboxmin + pre_quantization_translation;
2225
+ srcmesh_bboxmax = srcmesh_bboxmax + pre_quantization_translation;
2226
+ cutmesh_bboxmin = cutmesh_bboxmin + pre_quantization_translation;
2227
+ cutmesh_bboxmax = cutmesh_bboxmax + pre_quantization_translation;
2228
+ srcmesh_cutmesh_bboxmin = srcmesh_cutmesh_bboxmin + pre_quantization_translation;
2229
+ srcmesh_cutmesh_bboxmax = srcmesh_cutmesh_bboxmax + pre_quantization_translation;
2230
+
2231
+
2216
2232
double max_coord = std::numeric_limits<double >::lowest ();
2217
2233
double min_coord = std::numeric_limits<double >::max ();
2218
2234
@@ -2307,8 +2323,8 @@ extern "C" void preproc(std::shared_ptr<context_t> context_ptr,
2307
2323
numSrcMeshVertices,
2308
2324
numSrcMeshFaces,
2309
2325
multiplier,
2310
- vec3_< double >( 0.0 ) /* srcmesh_cutmesh_com*/ ,
2311
- vec3_< double >( 0.0 ) /* pre_quantization_translation*/ ))
2326
+ srcmesh_cutmesh_com,
2327
+ pre_quantization_translation))
2312
2328
{
2313
2329
throw std::invalid_argument (" invalid source-mesh arrays" );
2314
2330
}
@@ -2331,12 +2347,12 @@ extern "C" void preproc(std::shared_ptr<context_t> context_ptr,
2331
2347
2332
2348
kernel_input.src_mesh = source_hmesh;
2333
2349
2334
- kernel_input.verbose = false ;
2350
+ kernel_input.verbose = true ;
2335
2351
kernel_input.require_looped_cutpaths = false ;
2336
2352
2337
- kernel_input.verbose =
2338
- static_cast <bool >((context_ptr->get_flags () & MC_DEBUG) &&
2339
- (context_ptr->dbgCallbackBitfieldType & MC_DEBUG_SOURCE_KERNEL));
2353
+ // kernel_input.verbose =
2354
+ // static_cast<bool>((context_ptr->get_flags() & MC_DEBUG) &&
2355
+ // (context_ptr->dbgCallbackBitfieldType & MC_DEBUG_SOURCE_KERNEL));
2340
2356
kernel_input.require_looped_cutpaths =
2341
2357
static_cast <bool >(dispatchFlags & MC_DISPATCH_REQUIRE_THROUGH_CUTS);
2342
2358
kernel_input.populate_vertex_maps =
@@ -2620,8 +2636,8 @@ extern "C" void preproc(std::shared_ptr<context_t> context_ptr,
2620
2636
numCutMeshVertices,
2621
2637
numCutMeshFaces,
2622
2638
multiplier,
2623
- vec3_< double >( 0.0 ) /* srcmesh_cutmesh_com*/ ,
2624
- vec3_< double >( 0.0 ) /* pre_quantization_translation*/ ,
2639
+ srcmesh_cutmesh_com,
2640
+ pre_quantization_translation,
2625
2641
((cut_mesh_perturbation_count == 0 ) ? NULL : &perturbation)))
2626
2642
{
2627
2643
throw std::invalid_argument (" invalid cut-mesh arrays" );
@@ -3030,6 +3046,8 @@ extern "C" void preproc(std::shared_ptr<context_t> context_ptr,
3030
3046
3031
3047
#if MCUT_WITH_ARBITRARY_PRECISION_NUMBERS
3032
3048
asFragPtr->multiplier = multiplier;
3049
+ asFragPtr->srcmesh_cutmesh_com = srcmesh_cutmesh_com;
3050
+ asFragPtr->pre_quantization_translation = pre_quantization_translation;
3033
3051
#endif
3034
3052
3035
3053
context_ptr->connected_components .push_front (
@@ -3095,6 +3113,8 @@ extern "C" void preproc(std::shared_ptr<context_t> context_ptr,
3095
3113
3096
3114
#if MCUT_WITH_ARBITRARY_PRECISION_NUMBERS
3097
3115
asFragPtr->multiplier = multiplier;
3116
+ asFragPtr->srcmesh_cutmesh_com = srcmesh_cutmesh_com;
3117
+ asFragPtr->pre_quantization_translation = pre_quantization_translation;
3098
3118
#endif
3099
3119
3100
3120
context_ptr->connected_components .push_front (
@@ -3164,6 +3184,8 @@ extern "C" void preproc(std::shared_ptr<context_t> context_ptr,
3164
3184
3165
3185
#if MCUT_WITH_ARBITRARY_PRECISION_NUMBERS
3166
3186
asPatchPtr->multiplier = multiplier;
3187
+ asPatchPtr->srcmesh_cutmesh_com = srcmesh_cutmesh_com;
3188
+ asPatchPtr->pre_quantization_translation = pre_quantization_translation;
3167
3189
#endif
3168
3190
context_ptr->connected_components .push_front (
3169
3191
cc_ptr); // copy the connected component ptr into the context object
@@ -3229,6 +3251,8 @@ extern "C" void preproc(std::shared_ptr<context_t> context_ptr,
3229
3251
3230
3252
#if MCUT_WITH_ARBITRARY_PRECISION_NUMBERS
3231
3253
asPatchPtr->multiplier = multiplier;
3254
+ asPatchPtr->srcmesh_cutmesh_com = srcmesh_cutmesh_com;
3255
+ asPatchPtr->pre_quantization_translation = pre_quantization_translation;
3232
3256
#endif
3233
3257
3234
3258
context_ptr->connected_components .push_front (
@@ -3300,6 +3324,8 @@ extern "C" void preproc(std::shared_ptr<context_t> context_ptr,
3300
3324
3301
3325
#if MCUT_WITH_ARBITRARY_PRECISION_NUMBERS
3302
3326
asSrcMeshSeamPtr->multiplier = multiplier;
3327
+ asSrcMeshSeamPtr->srcmesh_cutmesh_com = srcmesh_cutmesh_com;
3328
+ asSrcMeshSeamPtr->pre_quantization_translation = pre_quantization_translation;
3303
3329
#endif
3304
3330
3305
3331
context_ptr->connected_components .push_front (
@@ -3365,6 +3391,8 @@ extern "C" void preproc(std::shared_ptr<context_t> context_ptr,
3365
3391
3366
3392
#if MCUT_WITH_ARBITRARY_PRECISION_NUMBERS
3367
3393
asCutMeshSeamPtr->multiplier = multiplier;
3394
+ asCutMeshSeamPtr->srcmesh_cutmesh_com = srcmesh_cutmesh_com;
3395
+ asCutMeshSeamPtr->pre_quantization_translation = pre_quantization_translation;
3368
3396
#endif
3369
3397
3370
3398
context_ptr->connected_components .push_front (
@@ -3498,6 +3526,8 @@ extern "C" void preproc(std::shared_ptr<context_t> context_ptr,
3498
3526
3499
3527
#if MCUT_WITH_ARBITRARY_PRECISION_NUMBERS
3500
3528
asCutMeshInputPtr->multiplier = multiplier;
3529
+ asCutMeshInputPtr->srcmesh_cutmesh_com = srcmesh_cutmesh_com;
3530
+ asCutMeshInputPtr->pre_quantization_translation = pre_quantization_translation;
3501
3531
#endif
3502
3532
3503
3533
context_ptr->connected_components .push_front (
@@ -3622,6 +3652,8 @@ extern "C" void preproc(std::shared_ptr<context_t> context_ptr,
3622
3652
3623
3653
#if MCUT_WITH_ARBITRARY_PRECISION_NUMBERS
3624
3654
asSrcMeshInputPtr->multiplier = multiplier;
3655
+ asSrcMeshInputPtr->srcmesh_cutmesh_com = srcmesh_cutmesh_com;
3656
+ asSrcMeshInputPtr->pre_quantization_translation = pre_quantization_translation;
3625
3657
#endif
3626
3658
3627
3659
context_ptr->connected_components .push_front (
0 commit comments