From cdd695117fe1ffc5f663c48d33b36e5afabe8efb Mon Sep 17 00:00:00 2001 From: Rodrigo Faselli <162915171+RF47@users.noreply.github.com> Date: Fri, 20 Nov 2026 19:05:58 -0300 Subject: [PATCH] Fix cone seam pcurve selection in OCCT (#17720) Since the OCCT 8.0.1 update, some STEP files imported with cone faces missing. OCCT told the two seam pcurves of a cone apart with a 1e-7 threshold, which fails when the neighboring pcurves end slightly past the seam. The OCCT patch now picks the closer pcurve. The #16290 fix is kept. Also stops admesh from merging unrelated edges of open meshes from STEP and SVG import on ARM64. A mesh built in memory reaches the nearby check with a tolerance of 0, and dividing by it was undefined. The check now returns early, which is what x86-64 already did. --- ...epMesh-seam-pcurve-at-edge-parameter.patch | 28 -- .../0001-BRepMesh-seam-pcurve-selection.patch | 25 ++ deps/OCCT/OCCT.cmake | 8 +- deps_src/admesh/connect.cpp | 6 + tests/data/cone_band_seam_overshoot.step | 408 ++++++++++++++++++ tests/libslic3r/test_step.cpp | 27 ++ 6 files changed, 471 insertions(+), 31 deletions(-) delete mode 100644 deps/OCCT/0001-BRepMesh-seam-pcurve-at-edge-parameter.patch create mode 100644 deps/OCCT/0001-BRepMesh-seam-pcurve-selection.patch create mode 100644 tests/data/cone_band_seam_overshoot.step diff --git a/deps/OCCT/0001-BRepMesh-seam-pcurve-at-edge-parameter.patch b/deps/OCCT/0001-BRepMesh-seam-pcurve-at-edge-parameter.patch deleted file mode 100644 index 84c599a5f3..0000000000 --- a/deps/OCCT/0001-BRepMesh-seam-pcurve-at-edge-parameter.patch +++ /dev/null @@ -1,28 +0,0 @@ -diff --git a/src/ModelingAlgorithms/TKMesh/BRepMesh/BRepMesh_ModelPreProcessor.cxx b/src/ModelingAlgorithms/TKMesh/BRepMesh/BRepMesh_ModelPreProcessor.cxx -index 6f63781..9b1c08e 100644 ---- a/src/ModelingAlgorithms/TKMesh/BRepMesh/BRepMesh_ModelPreProcessor.cxx -+++ b/src/ModelingAlgorithms/TKMesh/BRepMesh/BRepMesh_ModelPreProcessor.cxx -@@ -210,10 +210,10 @@ private: - - // Define two pcurves of the seam-edge. - occ::handle aPC1, aPC2; -- double af, al; -+ double af, al, af1, al1; - - aE.Orientation(TopAbs_FORWARD); -- aPC1 = BRep_Tool::CurveOnSurface(aE, aF, af, al); -+ aPC1 = BRep_Tool::CurveOnSurface(aE, aF, af1, al1); - - aE.Orientation(TopAbs_REVERSED); - aPC2 = BRep_Tool::CurveOnSurface(aE, aF, af, al); -@@ -224,7 +224,9 @@ private: - } - - // Select the correct pcurve of the seam-edge. -- const gp_Pnt2d& aFPntOfPC1 = aPC1->Value(aPC1->FirstParameter()); -+ // Use the edge's first parameter. A Geom2d_Line's FirstParameter() is -Precision::Infinite(), -+ // where a direction of (2e-16, -1) from rounding error gives an X far outside the U range. -+ const gp_Pnt2d aFPntOfPC1 = aPC1->Value(af1); - - if (std::abs(aLPntOfIPC1.X() - aFPntOfPC1.X()) > Precision::Confusion()) - { diff --git a/deps/OCCT/0001-BRepMesh-seam-pcurve-selection.patch b/deps/OCCT/0001-BRepMesh-seam-pcurve-selection.patch new file mode 100644 index 0000000000..dc202d1827 --- /dev/null +++ b/deps/OCCT/0001-BRepMesh-seam-pcurve-selection.patch @@ -0,0 +1,25 @@ +diff --git a/src/ModelingAlgorithms/TKMesh/BRepMesh/BRepMesh_ModelPreProcessor.cxx b/src/ModelingAlgorithms/TKMesh/BRepMesh/BRepMesh_ModelPreProcessor.cxx +index 6f63781..97a20d3 100644 +--- a/src/ModelingAlgorithms/TKMesh/BRepMesh/BRepMesh_ModelPreProcessor.cxx ++++ b/src/ModelingAlgorithms/TKMesh/BRepMesh/BRepMesh_ModelPreProcessor.cxx +@@ -223,10 +223,16 @@ private: + return false; + } + +- // Select the correct pcurve of the seam-edge. +- const gp_Pnt2d& aFPntOfPC1 = aPC1->Value(aPC1->FirstParameter()); +- +- if (std::abs(aLPntOfIPC1.X() - aFPntOfPC1.X()) > Precision::Confusion()) ++ // Select the correct pcurve of the seam-edge: the one closer to the discrete pcurve. ++ // Both pcurves of a seam share the edge's range, so evaluate them at its start. A ++ // Geom2d_Line's FirstParameter() is -Precision::Infinite(), where a direction of (2e-16, -1) ++ // from rounding error gives an X far outside the U range. A Precision::Confusion() threshold ++ // fails too, because BRepMesh_ModelHealer has already moved the ends of the discrete pcurve ++ // onto those of the neighbouring edges, whose pcurves can end slightly past the seam. ++ const gp_Pnt2d aFPntOfPC1 = aPC1->Value(af); ++ const gp_Pnt2d aFPntOfPC2 = aPC2->Value(af); ++ ++ if (std::abs(aLPntOfIPC1.X() - aFPntOfPC1.X()) > std::abs(aLPntOfIPC1.X() - aFPntOfPC2.X())) + { + std::swap(aPC1, aPC2); + } diff --git a/deps/OCCT/OCCT.cmake b/deps/OCCT/OCCT.cmake index d41b3bd886..fed828ad54 100644 --- a/deps/OCCT/OCCT.cmake +++ b/deps/OCCT/OCCT.cmake @@ -48,12 +48,14 @@ endif () orcaslicer_add_cmake_project(OCCT URL https://github.com/Open-Cascade-SAS/OCCT/archive/refs/tags/V8_0_1.zip URL_HASH SHA256=7c033d917ee8f040c0512d289dcc5f02c148889d5bac17c3e25639accb44f0da - # Makes BRepMesh triangulate cone faces whose seam pcurve is slightly tilted - # (Open-Cascade-SAS/OCCT#572); remove the patch once an OCCT release includes the fix. + # 0001 makes BRepMesh pair each seam pcurve of a cone with the right side of the seam, which + # failed when the seam pcurve is slightly tilted (Open-Cascade-SAS/OCCT#572) or the adjacent + # pcurves end slightly past the seam. Either way the face meshed to a sliver or not at all. + # Remove the patch once an OCCT release includes the fix. # 0002 compiles one file without optimization under cl for ARM64, where MSVC 14.52 crashes # on it with an internal compiler error; remove it once the runner image ships a fixed MSVC. PATCH_COMMAND git apply ${OCCT_DIRECTORY_FLAG} --verbose --ignore-space-change --whitespace=fix - ${CMAKE_CURRENT_LIST_DIR}/0001-BRepMesh-seam-pcurve-at-edge-parameter.patch + ${CMAKE_CURRENT_LIST_DIR}/0001-BRepMesh-seam-pcurve-selection.patch ${CMAKE_CURRENT_LIST_DIR}/0002-BRepGraph-MSVC-ARM64-ICE-workaround.patch #DEPENDS dep_Boost CMAKE_ARGS diff --git a/deps_src/admesh/connect.cpp b/deps_src/admesh/connect.cpp index 30a199120d..d0a3f909b6 100644 --- a/deps_src/admesh/connect.cpp +++ b/deps_src/admesh/connect.cpp @@ -488,6 +488,12 @@ void stl_check_facets_nearby(stl_file *stl, float tolerance) // No need to check any further. All facets are connected. return; + // A mesh built in memory has no shortest edge, so the tolerance arrives as 0, and load_nearby() would divide by it. + // Converting the infinities and NaNs to int is undefined: x86-64 makes them all INT_MIN, so no edge was ever + // matched, while ARM64 saturates them by sign and merged unrelated edges. Keep the x86-64 result everywhere. + if (!(tolerance > 0.f)) + return; + HashTableEdges hash_table(stl->stats.number_of_facets); for (uint32_t i = 0; i < stl->stats.number_of_facets; ++ i) { //FIXME is the copy necessary? diff --git a/tests/data/cone_band_seam_overshoot.step b/tests/data/cone_band_seam_overshoot.step new file mode 100644 index 0000000000..e7b580aa2b --- /dev/null +++ b/tests/data/cone_band_seam_overshoot.step @@ -0,0 +1,408 @@ +ISO-10303-21; +HEADER; +FILE_DESCRIPTION(('Open CASCADE Model'),'2;1'); +FILE_NAME('Open CASCADE Shape Model','2026-11-19T16:06:59',('Author'),( + 'Open CASCADE'),'Open CASCADE STEP processor 8.0','Open CASCADE 8.0' + ,'Unknown'); +FILE_SCHEMA(('AUTOMOTIVE_DESIGN { 1 0 10303 214 1 1 1 1 }')); +ENDSEC; +DATA; +#1 = APPLICATION_PROTOCOL_DEFINITION('international standard', + 'automotive_design',2000,#2); +#2 = APPLICATION_CONTEXT( + 'core data for automotive mechanical design processes'); +#3 = SHAPE_DEFINITION_REPRESENTATION(#4,#10); +#4 = PRODUCT_DEFINITION_SHAPE('','',#5); +#5 = PRODUCT_DEFINITION('design','',#6,#9); +#6 = PRODUCT_DEFINITION_FORMATION('','',#7); +#7 = PRODUCT('Open CASCADE STEP translator 8.0 1', + 'Open CASCADE STEP translator 8.0 1','',(#8)); +#8 = PRODUCT_CONTEXT('',#2,'mechanical'); +#9 = PRODUCT_DEFINITION_CONTEXT('part definition',#2,'design'); +#10 = MANIFOLD_SURFACE_SHAPE_REPRESENTATION('',(#11,#15),#225); +#11 = AXIS2_PLACEMENT_3D('',#12,#13,#14); +#12 = CARTESIAN_POINT('',(0.,0.,0.)); +#13 = DIRECTION('',(0.,0.,1.)); +#14 = DIRECTION('',(1.,0.,-0.)); +#15 = SHELL_BASED_SURFACE_MODEL('',(#16)); +#16 = OPEN_SHELL('',(#17)); +#17 = ADVANCED_FACE('',(#18),#51,.T.); +#18 = FACE_BOUND('',#19,.T.); +#19 = EDGE_LOOP('',(#20,#61,#84,#118,#136,#171,#172,#209)); +#20 = ORIENTED_EDGE('',*,*,#21,.T.); +#21 = EDGE_CURVE('',#22,#24,#26,.T.); +#22 = VERTEX_POINT('',#23); +#23 = CARTESIAN_POINT('',(4.143759803741,-4.874444458849,69.872014613543 + )); +#24 = VERTEX_POINT('',#25); +#25 = CARTESIAN_POINT('',(-12.29864740029,-3.981026217535, + 68.506159421151)); +#26 = SURFACE_CURVE('',#27,(#50),.PCURVE_S1.); +#27 = B_SPLINE_CURVE_WITH_KNOTS('',3,(#28,#29,#30,#31,#32,#33,#34,#35, + #36,#37,#38,#39,#40,#41,#42,#43,#44,#45,#46,#47,#48,#49), + .UNSPECIFIED.,.F.,.F.,(4,3,3,3,3,3,3,4),(0.,0.37190743837, + 0.74381487674,1.11572231511,1.48762975348,1.983506337973, + 2.23144463022,2.529141946975),.UNSPECIFIED.); +#28 = CARTESIAN_POINT('',(4.143759803725,-4.874444458851,69.872014613543 + )); +#29 = CARTESIAN_POINT('',(4.029039479458,-6.099264561044,69.754781673223 + )); +#30 = CARTESIAN_POINT('',(3.635412845026,-7.295135950986,69.615587068332 + )); +#31 = CARTESIAN_POINT('',(3.000986439986,-8.345127490291,69.468007573028 + )); +#32 = CARTESIAN_POINT('',(2.366560034947,-9.395119029597,69.320428077723 + )); +#33 = CARTESIAN_POINT('',(1.491333859301,-10.29923071826,69.164463692005 + )); +#34 = CARTESIAN_POINT('',(0.462690190863,-10.96670470189,69.015728860463 + )); +#35 = CARTESIAN_POINT('',(-0.565953477574,-11.63417868553,68.86699402892 + )); +#36 = CARTESIAN_POINT('',(-1.748014638803,-12.06501496412, + 68.725488751553)); +#37 = CARTESIAN_POINT('',(-2.968374982818,-12.21880646908, + 68.604858207553)); +#38 = CARTESIAN_POINT('',(-4.188735326832,-12.37259797405, + 68.484227663552)); +#39 = CARTESIAN_POINT('',(-5.447394853632,-12.24934470538, + 68.384471852918)); +#40 = CARTESIAN_POINT('',(-6.616838482239,-11.85783039067,68.31602103766 + )); +#41 = CARTESIAN_POINT('',(-8.176096653714,-11.33581130439, + 68.224753283981)); +#42 = CARTESIAN_POINT('',(-9.576748783956,-10.33688369181, + 68.189138855415)); +#43 = CARTESIAN_POINT('',(-10.58137693017,-9.031652960205,68.21510243469 + )); +#44 = CARTESIAN_POINT('',(-11.08369100327,-8.379037594403, + 68.228084224327)); +#45 = CARTESIAN_POINT('',(-11.48699908037,-7.649846448845, + 68.256460515925)); +#46 = CARTESIAN_POINT('',(-11.77442415228,-6.878633185846, + 68.298690442896)); +#47 = CARTESIAN_POINT('',(-12.11953289646,-5.952644235287, + 68.349395543072)); +#48 = CARTESIAN_POINT('',(-12.29757783178,-4.966073709505,68.42007286513 + )); +#49 = CARTESIAN_POINT('',(-12.29864740029,-3.981026217535, + 68.506159421151)); +#50 = PCURVE('',#51,#56); +#51 = CONICAL_SURFACE('',#52,8.25,1.666512371394E-02); +#52 = AXIS2_PLACEMENT_3D('',#53,#54,#55); +#53 = CARTESIAN_POINT('',(-4.167416546478,-4.151558268342, + 70.452528145107)); +#54 = DIRECTION('',(8.715574274766E-02,8.682408883347E-02, + -0.992403876506)); +#55 = DIRECTION('',(0.996194698092,-7.596123493896E-03, + 8.682408883347E-02)); +#56 = DEFINITIONAL_REPRESENTATION('',(#57),#60); +#57 = B_SPLINE_CURVE_WITH_KNOTS('',1,(#58,#59),.UNSPECIFIED.,.F.,.F.,(2, + 2),(0.,2.529141946975),.PIECEWISE_BEZIER_KNOTS.); +#58 = CARTESIAN_POINT('',(6.376509579999,1.237706692175)); +#59 = CARTESIAN_POINT('',(9.424807694257,1.237705820714)); +#60 = ( GEOMETRIC_REPRESENTATION_CONTEXT(2) +PARAMETRIC_REPRESENTATION_CONTEXT() REPRESENTATION_CONTEXT('2D SPACE','' + ) ); +#61 = ORIENTED_EDGE('',*,*,#62,.T.); +#62 = EDGE_CURVE('',#24,#63,#65,.T.); +#63 = VERTEX_POINT('',#64); +#64 = CARTESIAN_POINT('',(-11.8668393524,-3.459571861966,62.542838503986 + )); +#65 = SEAM_CURVE('',#66,(#70,#77),.PCURVE_S1.); +#66 = LINE('',#67,#68); +#67 = CARTESIAN_POINT('',(-12.38602280573,-4.088890249517, + 69.736229412231)); +#68 = VECTOR('',#69,1.); +#69 = DIRECTION('',(7.054270086241E-02,8.69386169222E-02,-0.993712938551 + )); +#70 = PCURVE('',#51,#71); +#71 = DEFINITIONAL_REPRESENTATION('',(#72),#76); +#72 = LINE('',#73,#74); +#73 = CARTESIAN_POINT('',(9.424777960769,-3.3302065773E-15)); +#74 = VECTOR('',#75,1.); +#75 = DIRECTION('',(0.,1.)); +#76 = ( GEOMETRIC_REPRESENTATION_CONTEXT(2) +PARAMETRIC_REPRESENTATION_CONTEXT() REPRESENTATION_CONTEXT('2D SPACE','' + ) ); +#77 = PCURVE('',#51,#78); +#78 = DEFINITIONAL_REPRESENTATION('',(#79),#83); +#79 = LINE('',#80,#81); +#80 = CARTESIAN_POINT('',(3.14159265359,-3.3302065773E-15)); +#81 = VECTOR('',#82,1.); +#82 = DIRECTION('',(0.,1.)); +#83 = ( GEOMETRIC_REPRESENTATION_CONTEXT(2) +PARAMETRIC_REPRESENTATION_CONTEXT() REPRESENTATION_CONTEXT('2D SPACE','' + ) ); +#84 = ORIENTED_EDGE('',*,*,#85,.T.); +#85 = EDGE_CURVE('',#63,#86,#88,.T.); +#86 = VERTEX_POINT('',#87); +#87 = CARTESIAN_POINT('',(4.75702271724,-4.453754621641,63.91581382788) + ); +#88 = SURFACE_CURVE('',#89,(#112),.PCURVE_S1.); +#89 = B_SPLINE_CURVE_WITH_KNOTS('',3,(#90,#91,#92,#93,#94,#95,#96,#97, + #98,#99,#100,#101,#102,#103,#104,#105,#106,#107,#108,#109,#110,#111) + ,.UNSPECIFIED.,.F.,.F.,(4,3,3,3,3,3,3,4),(2.718902929729, + 3.010964145992,3.261821852983,3.763537266966,4.139823827454, + 4.516110387941,4.892396948428,5.268683508916),.UNSPECIFIED.); +#90 = CARTESIAN_POINT('',(-11.86683935239,-3.459571861965, + 62.542838503986)); +#91 = CARTESIAN_POINT('',(-11.86937709332,-4.426034233901, + 62.458061131061)); +#92 = CARTESIAN_POINT('',(-11.70896301475,-5.393774766903, + 62.387482827713)); +#93 = CARTESIAN_POINT('',(-11.38149547781,-6.306025299713,62.33643038214 + )); +#94 = CARTESIAN_POINT('',(-11.10022651481,-7.089577048867,62.29258033044 + )); +#95 = CARTESIAN_POINT('',(-10.69571445902,-7.832191248394, + 62.263135410637)); +#96 = CARTESIAN_POINT('',(-10.19237858665,-8.49827843209,62.249064726986 + )); +#97 = CARTESIAN_POINT('',(-9.185706841918,-9.83045279948,62.220923359685 + )); +#98 = CARTESIAN_POINT('',(-7.783739830833,-10.85651910354, + 62.254278936995)); +#99 = CARTESIAN_POINT('',(-6.211992111038,-11.40193452483, + 62.344596644395)); +#100 = CARTESIAN_POINT('',(-5.033181321192,-11.8109960908, + 62.412334924946)); +#101 = CARTESIAN_POINT('',(-3.758868882695,-11.9496915352, + 62.512114403672)); +#102 = CARTESIAN_POINT('',(-2.521619747312,-11.80753342024, + 62.633210379822)); +#103 = CARTESIAN_POINT('',(-1.284370611928,-11.66537530528, + 62.754306355971)); +#104 = CARTESIAN_POINT('',(-8.418477965762E-02,-11.24236363094, + 62.896718829545)); +#105 = CARTESIAN_POINT('',(0.964036704717,-10.57823477998,63.04688037961 + )); +#106 = CARTESIAN_POINT('',(2.012258189092,-9.91410592903,63.197041929676 + )); +#107 = CARTESIAN_POINT('',(2.908515325572,-9.008859901449, + 63.354952556234)); +#108 = CARTESIAN_POINT('',(3.562304174523,-7.953319785154, + 63.504717954247)); +#109 = CARTESIAN_POINT('',(4.216093023475,-6.897779668859,63.65448335226 + )); +#110 = CARTESIAN_POINT('',(4.627413584898,-5.691945463852, + 63.796103521729)); +#111 = CARTESIAN_POINT('',(4.757022717202,-4.453754621644, + 63.915813827868)); +#112 = PCURVE('',#51,#113); +#113 = DEFINITIONAL_REPRESENTATION('',(#114),#117); +#114 = B_SPLINE_CURVE_WITH_KNOTS('',1,(#115,#116),.UNSPECIFIED.,.F.,.F., + (2,2),(2.718902929729,5.268683508916),.PIECEWISE_BEZIER_KNOTS.); +#115 = CARTESIAN_POINT('',(9.424775367365,7.238497013832)); +#116 = CARTESIAN_POINT('',(6.387399122293,7.238638837649)); +#117 = ( GEOMETRIC_REPRESENTATION_CONTEXT(2) +PARAMETRIC_REPRESENTATION_CONTEXT() REPRESENTATION_CONTEXT('2D SPACE','' + ) ); +#118 = ORIENTED_EDGE('',*,*,#119,.T.); +#119 = EDGE_CURVE('',#86,#120,#122,.T.); +#120 = VERTEX_POINT('',#121); +#121 = CARTESIAN_POINT('',(4.763507424532,-4.389388517509, + 63.922014637813)); +#122 = SURFACE_CURVE('',#123,(#130),.PCURVE_S1.); +#123 = B_SPLINE_CURVE_WITH_KNOTS('',3,(#124,#125,#126,#127,#128,#129), + .UNSPECIFIED.,.F.,.F.,(4,2,4),(0.,3.249430989361E-03, + 6.498861978722E-03),.UNSPECIFIED.); +#124 = CARTESIAN_POINT('',(4.757022717206,-4.453754621644, + 63.915813827868)); +#125 = CARTESIAN_POINT('',(4.758145172852,-4.443031501464, + 63.916850556582)); +#126 = CARTESIAN_POINT('',(4.759246797592,-4.432306053903, + 63.917885659486)); +#127 = CARTESIAN_POINT('',(4.761408372809,-4.410850625235, + 63.919952601975)); +#128 = CARTESIAN_POINT('',(4.762468321249,-4.400120664336, + 63.920984439613)); +#129 = CARTESIAN_POINT('',(4.763507424532,-4.389388517509, + 63.922014637813)); +#130 = PCURVE('',#51,#131); +#131 = DEFINITIONAL_REPRESENTATION('',(#132),#135); +#132 = B_SPLINE_CURVE_WITH_KNOTS('',1,(#133,#134),.UNSPECIFIED.,.F.,.F., + (2,2),(0.,6.498861978722E-03),.PIECEWISE_BEZIER_KNOTS.); +#133 = CARTESIAN_POINT('',(6.387399122293,7.238638837649)); +#134 = CARTESIAN_POINT('',(6.379635251372,7.238638837649)); +#135 = ( GEOMETRIC_REPRESENTATION_CONTEXT(2) +PARAMETRIC_REPRESENTATION_CONTEXT() REPRESENTATION_CONTEXT('2D SPACE','' + ) ); +#136 = ORIENTED_EDGE('',*,*,#137,.T.); +#137 = EDGE_CURVE('',#120,#63,#138,.T.); +#138 = SURFACE_CURVE('',#139,(#165),.PCURVE_S1.); +#139 = B_SPLINE_CURVE_WITH_KNOTS('',3,(#140,#141,#142,#143,#144,#145, + #146,#147,#148,#149,#150,#151,#152,#153,#154,#155,#156,#157,#158, + #159,#160,#161,#162,#163,#164),.UNSPECIFIED.,.F.,.F.,(4,3,3,3,3,3,3, + 3,4),(0.,0.376379539117,0.752759078234,1.129138617351,1.505518156469 + ,1.881897695586,2.164182349923,2.258277234703,2.718902929729), + .UNSPECIFIED.); +#140 = CARTESIAN_POINT('',(4.763507424532,-4.389388517509, + 63.922014637813)); +#141 = CARTESIAN_POINT('',(4.883491920427,-3.150155374883, + 64.040970870365)); +#142 = CARTESIAN_POINT('',(4.720833010841,-1.881926911817, + 64.137641313649)); +#143 = CARTESIAN_POINT('',(4.29177713392,-0.709212197811,64.202559644177 + )); +#144 = CARTESIAN_POINT('',(3.862721257,0.463502516196,64.267477974704)); +#145 = CARTESIAN_POINT('',(3.167268412747,1.540703481143,64.300644192476 + )); +#146 = CARTESIAN_POINT('',(2.273495756837,2.415374288815,64.298674305201 + )); +#147 = CARTESIAN_POINT('',(1.379723100927,3.290045096488,64.296704417926 + )); +#148 = CARTESIAN_POINT('',(0.287630633361,3.962185746887,64.259598425604 + )); +#149 = CARTESIAN_POINT('',(-0.893605154041,4.365900727323,64.19117940922 + )); +#150 = CARTESIAN_POINT('',(-2.074840941442,4.769615707759, + 64.122760392836)); +#151 = CARTESIAN_POINT('',(-3.345220048677,4.904905018232, + 64.023028352389)); +#152 = CARTESIAN_POINT('',(-4.58171278018,4.758163349392,63.901597796786 + )); +#153 = CARTESIAN_POINT('',(-5.818205511682,4.611421680552, + 63.780167241183)); +#154 = CARTESIAN_POINT('',(-7.02081186745,4.1826490324,63.637038170423) + ); +#155 = CARTESIAN_POINT('',(-8.065522144736,3.514301141115, + 63.486815866392)); +#156 = CARTESIAN_POINT('',(-8.849054852701,3.013040222651,63.37414913837 + )); +#157 = CARTESIAN_POINT('',(-9.543771016519,2.377018229924, + 63.257492466632)); +#158 = CARTESIAN_POINT('',(-10.1208386321,1.644000024014,63.142681957346 + )); +#159 = CARTESIAN_POINT('',(-10.31319450396,1.399660622043, + 63.104411787584)); +#160 = CARTESIAN_POINT('',(-10.49247831491,1.144543863053, + 63.066346746984)); +#161 = CARTESIAN_POINT('',(-10.6555275489,0.880008227365,63.028883428364 + )); +#162 = CARTESIAN_POINT('',(-11.45370767211,-0.41498151978, + 62.845488048078)); +#163 = CARTESIAN_POINT('',(-11.86283793131,-1.935687816598, + 62.676512498712)); +#164 = CARTESIAN_POINT('',(-11.8668393524,-3.459571861966, + 62.542838503986)); +#165 = PCURVE('',#51,#166); +#166 = DEFINITIONAL_REPRESENTATION('',(#167),#170); +#167 = B_SPLINE_CURVE_WITH_KNOTS('',1,(#168,#169),.UNSPECIFIED.,.F.,.F., + (2,2),(0.,2.718902929729),.PIECEWISE_BEZIER_KNOTS.); +#168 = CARTESIAN_POINT('',(6.379635251372,7.238638837649)); +#169 = CARTESIAN_POINT('',(3.141590060185,7.238497013832)); +#170 = ( GEOMETRIC_REPRESENTATION_CONTEXT(2) +PARAMETRIC_REPRESENTATION_CONTEXT() REPRESENTATION_CONTEXT('2D SPACE','' + ) ); +#171 = ORIENTED_EDGE('',*,*,#62,.F.); +#172 = ORIENTED_EDGE('',*,*,#173,.T.); +#173 = EDGE_CURVE('',#24,#174,#176,.T.); +#174 = VERTEX_POINT('',#175); +#175 = CARTESIAN_POINT('',(4.149473588578,-4.810776140259,69.87808667055 + )); +#176 = SURFACE_CURVE('',#177,(#203),.PCURVE_S1.); +#177 = B_SPLINE_CURVE_WITH_KNOTS('',3,(#178,#179,#180,#181,#182,#183, + #184,#185,#186,#187,#188,#189,#190,#191,#192,#193,#194,#195,#196, + #197,#198,#199,#200,#201,#202),.UNSPECIFIED.,.F.,.F.,(4,3,3,3,3,3,3, + 3,4),(2.529141946975,2.603325106943,2.975097425779,3.346869744615, + 3.718642063451,4.090414382287,4.462186701123,4.833959019959, + 5.205731338795),.UNSPECIFIED.); +#178 = CARTESIAN_POINT('',(-12.29864740029,-3.981026217535, + 68.506159421151)); +#179 = CARTESIAN_POINT('',(-12.29891402281,-3.73547313371, + 68.527619116728)); +#180 = CARTESIAN_POINT('',(-12.28818326443,-3.490014692339, + 68.550036353563)); +#181 = CARTESIAN_POINT('',(-12.26630159044,-3.24561292317, + 68.573340448815)); +#182 = CARTESIAN_POINT('',(-12.15664057458,-2.020782213733, + 68.690129994234)); +#183 = CARTESIAN_POINT('',(-11.76691769672,-0.8224904536,68.829193515027 + )); +#184 = CARTESIAN_POINT('',(-11.13645348098,0.229933555183, + 68.976637853055)); +#185 = CARTESIAN_POINT('',(-10.50598926524,1.282357563966, + 69.124082191083)); +#186 = CARTESIAN_POINT('',(-9.634783711627,2.188913821399, + 69.279907346346)); +#187 = CARTESIAN_POINT('',(-8.608543800092,2.860523259039, + 69.428792878436)); +#188 = CARTESIAN_POINT('',(-7.582303888557,3.532132696679, + 69.577678410526)); +#189 = CARTESIAN_POINT('',(-6.401029619107,3.968795314526, + 69.719624319445)); +#190 = CARTESIAN_POINT('',(-5.181669553845,4.127115459444, + 69.840563220766)); +#191 = CARTESIAN_POINT('',(-3.962309488584,4.285435604362, + 69.961502122087)); +#192 = CARTESIAN_POINT('',(-2.70486362751,4.165413276351,70.06143401581) + ); +#193 = CARTESIAN_POINT('',(-1.533296826342,3.779222761759, + 70.130537066304)); +#194 = CARTESIAN_POINT('',(-0.361730025175,3.393032247166, + 70.199640116798)); +#195 = CARTESIAN_POINT('',(0.723957716087,2.740673545991,70.237914324062 + )); +#196 = CARTESIAN_POINT('',(1.616230879826,1.886055040854,70.241506870802 + )); +#197 = CARTESIAN_POINT('',(2.508504043565,1.031436535718,70.245099417541 + )); +#198 = CARTESIAN_POINT('',(3.207362629782,-2.544177338112E-02, + 70.214010303756)); +#199 = CARTESIAN_POINT('',(3.64390522245,-1.179558338951,70.151376605138 + )); +#200 = CARTESIAN_POINT('',(4.080447815118,-2.333674904522,70.08874290652 + )); +#201 = CARTESIAN_POINT('',(4.254674414237,-3.585029726563,69.99456462307 + )); +#202 = CARTESIAN_POINT('',(4.149473588575,-4.810776140259,69.87808667055 + )); +#203 = PCURVE('',#51,#204); +#204 = DEFINITIONAL_REPRESENTATION('',(#205),#208); +#205 = B_SPLINE_CURVE_WITH_KNOTS('',1,(#206,#207),.UNSPECIFIED.,.F.,.F., + (2,2),(2.529141946975,5.205731338795),.PIECEWISE_BEZIER_KNOTS.); +#206 = CARTESIAN_POINT('',(3.141622387077,1.237705820714)); +#207 = CARTESIAN_POINT('',(6.368745709079,1.237706692175)); +#208 = ( GEOMETRIC_REPRESENTATION_CONTEXT(2) +PARAMETRIC_REPRESENTATION_CONTEXT() REPRESENTATION_CONTEXT('2D SPACE','' + ) ); +#209 = ORIENTED_EDGE('',*,*,#210,.T.); +#210 = EDGE_CURVE('',#174,#22,#211,.T.); +#211 = SURFACE_CURVE('',#212,(#219),.PCURVE_S1.); +#212 = B_SPLINE_CURVE_WITH_KNOTS('',3,(#213,#214,#215,#216,#217,#218), + .UNSPECIFIED.,.F.,.F.,(4,2,4),(0.,3.21060559169E-03,6.42121118338E-03) + ,.UNSPECIFIED.); +#213 = CARTESIAN_POINT('',(4.149473588578,-4.810776140259,69.87808667055 + )); +#214 = CARTESIAN_POINT('',(4.148562516505,-4.821391487794,69.87707793503 + )); +#215 = CARTESIAN_POINT('',(4.147630827754,-4.832004899757, + 69.876067558235)); +#216 = CARTESIAN_POINT('',(4.145726227421,-4.853227732586, + 69.874043533514)); +#217 = CARTESIAN_POINT('',(4.144753317635,-4.863837133464, + 69.873029887494)); +#218 = CARTESIAN_POINT('',(4.143759803725,-4.874444458851, + 69.872014613543)); +#219 = PCURVE('',#51,#220); +#220 = DEFINITIONAL_REPRESENTATION('',(#221),#224); +#221 = B_SPLINE_CURVE_WITH_KNOTS('',1,(#222,#223),.UNSPECIFIED.,.F.,.F., + (2,2),(0.,6.42121118338E-03),.PIECEWISE_BEZIER_KNOTS.); +#222 = CARTESIAN_POINT('',(6.368745709079,1.237706692175)); +#223 = CARTESIAN_POINT('',(6.376509579999,1.237706692175)); +#224 = ( GEOMETRIC_REPRESENTATION_CONTEXT(2) +PARAMETRIC_REPRESENTATION_CONTEXT() REPRESENTATION_CONTEXT('2D SPACE','' + ) ); +#225 = ( GEOMETRIC_REPRESENTATION_CONTEXT(3) +GLOBAL_UNCERTAINTY_ASSIGNED_CONTEXT((#229)) GLOBAL_UNIT_ASSIGNED_CONTEXT +((#226,#227,#228)) REPRESENTATION_CONTEXT('Context #1', + '3D Context with UNIT and UNCERTAINTY') ); +#226 = ( LENGTH_UNIT() NAMED_UNIT(*) SI_UNIT(.MILLI.,.METRE.) ); +#227 = ( NAMED_UNIT(*) PLANE_ANGLE_UNIT() SI_UNIT($,.RADIAN.) ); +#228 = ( NAMED_UNIT(*) SI_UNIT($,.STERADIAN.) SOLID_ANGLE_UNIT() ); +#229 = UNCERTAINTY_MEASURE_WITH_UNIT(LENGTH_MEASURE(5.E-03),#226, + 'distance_accuracy_value','confusion accuracy'); +#230 = PRODUCT_RELATED_PRODUCT_CATEGORY('part',$,(#7)); +ENDSEC; +END-ISO-10303-21; diff --git a/tests/libslic3r/test_step.cpp b/tests/libslic3r/test_step.cpp index 45714e8cd5..e94019dbdb 100644 --- a/tests/libslic3r/test_step.cpp +++ b/tests/libslic3r/test_step.cpp @@ -35,6 +35,7 @@ #include #include #include +#include "admesh/stl.h" #include "libslic3r/BoundingBox.hpp" #include "libslic3r/Model.hpp" #include "libslic3r/Format/STEP.hpp" @@ -122,6 +123,32 @@ TEST_CASE("A cone with a slightly tilted seam imports as a closed mesh", "[Step] CHECK(its_num_open_edges(model.objects.front()->volumes.front()->mesh().its) == 0); } +// The fixture is one band of a tilted chimney exported from Fusion: a full turn of a cone of 313.77 mm², +// whose B-spline boundary pcurves end up to 3e-5 past the seam. Meshed wrongly, it becomes a flat disc of +// about 220 mm² over its top circle. +TEST_CASE("A cone band whose boundary ends past the seam meshes its whole surface", "[Step]") +{ + const std::string path = std::string(TEST_DATA_DIR) + PATH_SEPARATOR "cone_band_seam_overshoot.step"; + + Model model; + bool cancel = false; + Step step(path); + + REQUIRE(step.load() == Step::Step_Status::LOAD_SUCCESS); + REQUIRE(step.mesh(&model, cancel, false) == Step::Step_Status::MESH_SUCCESS); + + REQUIRE(model.objects.size() == 1); + REQUIRE(model.objects.front()->volumes.size() == 1); + const indexed_triangle_set &its = model.objects.front()->volumes.front()->mesh().its; + double area = 0.; + for (const stl_triangle_vertex_indices &face : its.indices) + area += 0.5 * (its.vertices[face[1]] - its.vertices[face[0]]) + .cast() + .cross((its.vertices[face[2]] - its.vertices[face[0]]).cast()) + .norm(); + CHECK_THAT(area, Catch::Matchers::WithinRel(313.77, 0.01)); +} + // The fixture holds two trimmed planes in a geometric set and no shells or solids, as some CAD exporters write // surface models, so OCCT reads it as a compound of loose faces. TEST_CASE("A surface model imports whether or not compounds are split", "[Step]")