From 5eba9aff4ff818be1a8c57fd9a85c67969066283 Mon Sep 17 00:00:00 2001 From: Pasukhin Dmitry Date: Sun, 9 Aug 2026 22:10:30 +0100 Subject: [PATCH] Tests - Migrate DRAW tests to Gtests (#1448) Migrate some DRAW tests which do not use external CAD files and which do not use visualisation/image dump. Some tests were modified, but the original idea was preserved --- .../TKCAF/GTests/FILES.cmake | 1 + .../TKCAF/GTests/TDataXtd_Attribute_Test.cxx | 184 + .../TKCAF/GTests/TNaming_NamedShape_Test.cxx | 568 +++ .../TKCAF/GTests/TNaming_Tool_Test.cxx | 1513 +++++++ .../TKLCAF/GTests/FILES.cmake | 6 + .../GTests/TDF_AttributeIterator_Test.cxx | 31 + .../TKLCAF/GTests/TDF_Copy_Test.cxx | 110 + .../TKLCAF/GTests/TDataStd_Attribute_Test.cxx | 836 ++++ .../GTests/TDataStd_Expression_Test.cxx | 107 + .../TKLCAF/GTests/TDataStd_List_Test.cxx | 165 + .../TKLCAF/GTests/TDataStd_TreeNode_Test.cxx | 510 +++ .../GTests/TDocStd_Application_Test.cxx | 43 + .../GTests/TDocStd_Transaction_Test.cxx | 889 ++++ .../TKLCAF/GTests/TDocStd_XLink_Test.cxx | 389 ++ .../TKTObj/GTests/TObj_Model_Test.cxx | 218 + .../TKVCAF/GTests/FILES.cmake | 1 + .../GTests/TPrsStd_AISPresentation_Test.cxx | 37 + .../TKXml/GTests/FILES.cmake | 3 + .../TKXml/GTests/TDocStd_Progress_Test.cxx | 424 ++ .../TKXml/GTests/TDocStd_Storage_Test.cxx | 3846 +++++++++++++++++ .../TKXml/GTests/XmlOcaf_Storage_Test.cxx | 2356 ++++++++++ .../GTests/DE_Wrapper_Configuration_Test.cxx | 636 +++ src/DataExchange/TKDE/GTests/FILES.cmake | 1 + .../DEBREP/DEBREP_ConfigurationNode.cxx | 7 + .../DEBREP/DEBREP_ConfigurationNode.hxx | 4 + .../TKDECascade/DEBREP/DEBREP_Provider.cxx | 282 ++ .../TKDECascade/DEBREP/DEBREP_Provider.hxx | 64 + .../GTests/DEBREP_Provider_Test.cxx | 213 + .../TKDECascade/GTests/FILES.cmake | 1 + .../DEGLTF/DEGLTF_ConfigurationNode.cxx | 7 + .../DEGLTF/DEGLTF_ConfigurationNode.hxx | 4 + .../TKDEGLTF/DEGLTF/DEGLTF_Provider.cxx | 94 + .../TKDEGLTF/DEGLTF/DEGLTF_Provider.hxx | 26 + .../TKDEGLTF/GTests/DEGLTF_Provider_Test.cxx | 426 ++ src/DataExchange/TKDEGLTF/GTests/FILES.cmake | 1 + .../TKDEGLTF/RWGltf/RWGltf_CafReader.cxx | 8 +- .../TKDEGLTF/RWGltf/RWGltf_CafReader.hxx | 4 + .../TKDEGLTF/RWGltf/RWGltf_GltfJsonParser.cxx | 105 +- .../TKDEGLTF/RWGltf/RWGltf_GltfJsonParser.hxx | 4 + .../TKDESTEP/DESTEP/DESTEP_Provider.cxx | 28 +- .../TKDESTEP/GTests/DESTEP_Provider_Test.cxx | 590 ++- src/DataExchange/TKDESTEP/GTests/FILES.cmake | 1 + .../TKDESTEP/GTests/GDT_STEP_Storage_Test.cxx | 1206 ++++++ .../STEPCAFControl/STEPCAFControl_Reader.cxx | 9 + .../STEPCAFControl/STEPCAFControl_Reader.hxx | 9 + .../GTests/DEMesh_ShapeWriteStl_Test.cxx | 493 +++ .../TKDESTL/GTests/DESTL_Provider_Test.cxx | 154 +- src/DataExchange/TKDESTL/GTests/FILES.cmake | 1 + .../TKDEVRML/GTests/DEVRML_Provider_Test.cxx | 262 +- src/DataExchange/TKXCAF/GTests/FILES.cmake | 2 + .../TKXCAF/GTests/XCAFDoc_GDT_Test.cxx | 359 ++ .../TKXCAF/GTests/XCAFDoc_NotesTool_Test.cxx | 404 ++ src/DataExchange/TKXmlXCAF/GTests/FILES.cmake | 1 + .../TKXmlXCAF/GTests/XmlXCAF_Storage_Test.cxx | 604 +++ .../TKDCAF/GTests/DNaming_Driver_Test.cxx | 433 ++ src/Draw/TKDCAF/GTests/FILES.cmake | 6 + .../TKMath/GTests/BVH_DistanceField_Test.cxx | 133 + .../TKMath/GTests/BVH_PairDistance_Test.cxx | 240 + .../TKMath/GTests/BVH_ShapeSelect_Test.cxx | 244 ++ .../TKMath/GTests/CSLib_Test.cxx | 59 +- .../TKMath/GTests/FILES.cmake | 3 + .../TKernel/GTests/OSD_Path_Test.cxx | 46 +- .../TKernel/GTests/Quantity_Color_Test.cxx | 204 + .../TKernel/GTests/UnitsAPI_Test.cxx | 73 + .../TKBO/GTests/BOPAlgo_BOP_Test.cxx | 219 +- .../TKBO/GTests/BOPAlgo_CellsBuilder_Test.cxx | 185 + .../TKBO/GTests/BOPAlgo_MakePeriodic_Test.cxx | 998 +++++ .../TKBO/GTests/BOPAlgo_OpenSolid_Test.cxx | 473 ++ .../TKBO/GTests/BRepAlgoAPI_Common_Test.cxx | 27 +- .../TKBO/GTests/BRepAlgoAPI_Cut_Test.cxx | 59 + .../TKBO/GTests/BRepAlgoAPI_Simplify_Test.cxx | 135 + .../TKBO/GTests/BRepAlgoAPI_Splitter_Test.cxx | 354 ++ .../TKBO/GTests/BRepTools_History_Test.cxx | 359 ++ .../TKBO/GTests/FILES.cmake | 6 + .../TKBO/GTests/IntTools_FaceFace_Test.cxx | 112 + .../GTests/BRepAlgoAPI_Section_Test.cxx | 133 + .../GTests/Expr_GeneralExpression_Test.cxx | 17 + .../TKGeomAlgo/GTests/FILES.cmake | 5 + .../GTests/GccAna_Circ2d3Tan_Test.cxx | 343 ++ .../Geom2dAPI_ExtremaCurveCurve_Test.cxx | 49 + .../GTests/Geom2dAPI_InterCurveCurve_Test.cxx | 129 + .../GTests/Geom2dGcc_Circ2d2TanRad_Test.cxx | 183 + .../GTests/Geom2dGcc_Circ2d3Tan_Test.cxx | 117 +- .../GeomAPI_ExtremaCurveSurface_Test.cxx | 172 + .../GeomAPI_ExtremaSurfaceSurface_Test.cxx | 48 + .../TKGeomAlgo/GTests/GeomAPI_IntCS_Test.cxx | 148 + .../TKGeomAlgo/GTests/GeomAPI_IntSS_Test.cxx | 119 + .../GeomAPI_ProjectPointOnSurf_Test.cxx | 60 + .../GTests/GeomFill_BSplineCurves_Test.cxx | 92 + .../GeomPlate_BuildPlateSurface_Test.cxx | 187 +- .../Geom2dGcc/Geom2dGcc_Circ2dTanCenGeo.cxx | 15 +- .../GTests/BRepMesh_IncrementalMesh_Test.cxx | 228 +- .../BRepOffsetAPI_MakePipeShell_Test.cxx | 56 + .../GTests/BRepPrimAPI_MakeRevol_Test.cxx | 120 + .../TKPrim/GTests/FILES.cmake | 1 + .../GTests/ShapeFix_Shape_Test.cxx | 67 + .../ShapeUpgrade_UnifySameDomain_Test.cxx | 160 +- .../TKTopAlgo/GTests/BRepBndLib_Test.cxx | 234 + .../GTests/BRepBuilderAPI_Copy_Test.cxx | 61 + .../GTests/BRepBuilderAPI_MakeShell_Test.cxx | 50 + .../BRepExtrema_ShapeProximity_Test.cxx | 568 +++ .../TKTopAlgo/GTests/FILES.cmake | 3 + .../GTests/BRepAdaptor_CompCurve_Test.cxx | 61 + .../TKBRep/GTests/BRepTools_ReShape_Test.cxx | 40 + .../TKBRep/GTests/BRepTools_Test.cxx | 945 ++++ .../GTests/Geom2dAPI_InterCurveCurve_Test.cxx | 44 + .../TKG2d/GTests/Geom2d_OffsetCurve_Test.cxx | 26 +- .../GTests/GeomAPI_ExtremaCurveCurve_Test.cxx | 613 +++ .../TKGeomBase/GTests/FILES.cmake | 2 + .../GCPnts_QuasiUniformDeflection_Test.cxx | 98 + .../TKGeomBase/GTests/GeomProjLib_Test.cxx | 95 + .../GTests/IntAna_IntQuadQuad_Test.cxx | 50 + tests/boolean/history/A1 | 178 - tests/boolean/history/A2 | 178 - tests/boolean/history/A3 | 185 - tests/boolean/history/A4 | 40 - tests/boolean/history/A5 | 185 - tests/boolean/history/A6 | 194 - tests/boolean/history/A8 | 51 - tests/boolean/history/A9 | 41 - tests/boolean/mkconnected/A1 | 61 - tests/boolean/mkconnected/A2 | 90 - tests/boolean/mkconnected/A5 | 63 - tests/boolean/opensolid/A1 | 41 - tests/boolean/opensolid/A2 | 45 - tests/boolean/opensolid/A3 | 44 - tests/boolean/opensolid/A4 | 60 - tests/boolean/opensolid/A5 | 32 - tests/boolean/opensolid/A6 | 34 - tests/boolean/opensolid/A7 | 59 - tests/boolean/opensolid/A8 | 33 - tests/boolean/opensolid/A9 | 56 - tests/boolean/periodicity/A1 | 15 - tests/boolean/periodicity/A2 | 80 - tests/boolean/periodicity/A3 | 14 - tests/boolean/periodicity/A4 | 13 - tests/boolean/periodicity/A5 | 39 - tests/boolean/periodicity/A6 | 62 - tests/boolean/simplify/A1 | 24 - tests/boolean/simplify/A2 | 33 - tests/boolean/splitter/A1 | 24 - tests/boolean/splitter/A2 | 26 - tests/boolean/splitter/A3 | 25 - tests/boolean/splitter/A4 | 46 - tests/boolean/splitter/A6 | 36 - tests/boolean/splitter/B1 | 24 - tests/boolean/splitter/B2 | 26 - tests/boolean/splitter/B3 | 25 - tests/boolean/splitter/B4 | 46 - tests/boolean/splitter/B6 | 36 - tests/bugs/caf/buc60790 | 15 - tests/bugs/caf/buc60813 | 30 - tests/bugs/caf/buc60831 | 50 - tests/bugs/caf/buc60844 | 39 - tests/bugs/caf/buc60847 | 18 - tests/bugs/caf/buc60862 | 21 - tests/bugs/caf/buc60910 | 19 - tests/bugs/caf/bug158 | 12 - tests/bugs/caf/bug159 | 28 - tests/bugs/caf/bug170_3 | 33 - tests/bugs/caf/bug1722 | 98 - tests/bugs/caf/bug21231 | 91 - tests/bugs/caf/bug22976 | 25 - tests/bugs/caf/bug23306 | 22 - tests/bugs/caf/bug23465 | 119 - tests/bugs/caf/bug23799 | 25 - tests/bugs/caf/bug23912 | 24 - tests/bugs/caf/bug24164_1 | 54 - tests/bugs/caf/bug24164_2 | 70 - tests/bugs/caf/bug24263 | 27 - tests/bugs/caf/bug24263_2 | 12 - tests/bugs/caf/bug24645 | 45 - tests/bugs/caf/bug24852 | 14 - tests/bugs/caf/bug24869 | 66 - tests/bugs/caf/bug24925 | 38 - tests/bugs/caf/bug25112 | 27 - tests/bugs/caf/bug25153 | 16 - tests/bugs/caf/bug25317 | 35 - tests/bugs/caf/bug25394_1 | 129 - tests/bugs/caf/bug25394_2 | 129 - tests/bugs/caf/bug25394_3 | 129 - tests/bugs/caf/bug25536 | 37 - tests/bugs/caf/bug25537 | 28 - tests/bugs/caf/bug26061 | 47 - tests/bugs/caf/bug261 | 31 - tests/bugs/caf/bug26155 | 37 - tests/bugs/caf/bug26229_1 | 44 - tests/bugs/caf/bug26229_2 | 44 - tests/bugs/caf/bug26428 | 15 - tests/bugs/caf/bug267_1 | 10 - tests/bugs/caf/bug27187 | 24 - tests/bugs/caf/bug28425 | 58 - tests/bugs/caf/bug28428 | 18 - tests/bugs/caf/bug29142 | 51 - tests/bugs/caf/bug2932_1 | 74 - tests/bugs/caf/bug2932_10 | 73 - tests/bugs/caf/bug2932_11 | 70 - tests/bugs/caf/bug2932_12 | 94 - tests/bugs/caf/bug2932_13 | 76 - tests/bugs/caf/bug2932_14 | 73 - tests/bugs/caf/bug2932_15 | 69 - tests/bugs/caf/bug2932_16 | 73 - tests/bugs/caf/bug2932_17 | 71 - tests/bugs/caf/bug2932_18 | 115 - tests/bugs/caf/bug2932_19 | 73 - tests/bugs/caf/bug2932_2 | 72 - tests/bugs/caf/bug2932_20 | 70 - tests/bugs/caf/bug2932_21 | 71 - tests/bugs/caf/bug2932_22 | 73 - tests/bugs/caf/bug2932_24 | 72 - tests/bugs/caf/bug2932_3 | 75 - tests/bugs/caf/bug2932_4 | 69 - tests/bugs/caf/bug2932_5 | 91 - tests/bugs/caf/bug2932_6 | 71 - tests/bugs/caf/bug2932_7 | 70 - tests/bugs/caf/bug2932_8 | 116 - tests/bugs/caf/bug2932_9 | 69 - tests/bugs/caf/bug29669 | 41 - tests/bugs/caf/bug29901 | 46 - tests/bugs/caf/bug31323 | 36 - tests/bugs/caf/bug31785 | 10 - tests/bugs/caf/bug31839_1 | 141 - tests/bugs/caf/bug31839_2 | 55 - tests/bugs/caf/bug31918_1 | 100 - tests/bugs/caf/bug31920 | 22 - tests/bugs/caf/bug387 | 23 - tests/bugs/caf/bug425 | 54 - tests/bugs/caf/bug644 | 30 - tests/bugs/caf/bug9746 | 174 - tests/bugs/demo/bug14673_4 | 28 - tests/bugs/demo/bug23130 | 66 - tests/bugs/demo/bug25344_4 | 28 - tests/bugs/demo/bug25445 | 18 - tests/bugs/fclasses/bug11568_1 | 19 - tests/bugs/fclasses/bug11568_2 | 18 - tests/bugs/fclasses/bug11568_3 | 18 - tests/bugs/fclasses/bug11568_4 | 18 - tests/bugs/fclasses/bug23403 | 12 - tests/bugs/fclasses/bug23852 | 69 - tests/bugs/fclasses/bug24897 | 11 - tests/bugs/fclasses/bug24931 | 20 - tests/bugs/fclasses/bug25635_1 | 21 - tests/bugs/fclasses/bug25635_2 | 47 - tests/bugs/fclasses/bug26922 | 38 - tests/bugs/fclasses/bug28478 | 27 - tests/bugs/fclasses/bug30800 | 14 - tests/bugs/fclasses/bug31092 | 36 - tests/bugs/fclasses/bug31381 | 15 - tests/bugs/fclasses/bug710 | 18 - tests/bugs/fclasses/bug9848_1 | 24 - tests/bugs/fclasses/bug9848_2 | 25 - tests/bugs/filling/bug13904 | 33 - tests/bugs/filling/bug27775 | 25 - tests/bugs/heal/bug24881 | 17 - tests/bugs/heal/bug25014 | 10 - tests/bugs/heal/bug29382_3 | 24 - tests/bugs/heal/bug29544_2 | 27 - tests/bugs/heal/bug30927 | 15 - tests/bugs/mesh/bug30234 | 15 - tests/bugs/mesh/bug31125 | 7 - tests/bugs/mesh/bug32692_3 | 14 - tests/bugs/modalg_5/bug21564 | 61 - tests/bugs/modalg_5/bug23855 | 21 - tests/bugs/modalg_5/bug23932_1 | 27 - tests/bugs/modalg_5/bug23932_2 | 27 - tests/bugs/modalg_5/bug23954 | 21 - tests/bugs/modalg_5/bug24029 | 33 - tests/bugs/modalg_5/bug24033 | 60 - tests/bugs/modalg_5/bug24213 | 17 - tests/bugs/modalg_5/bug24328 | 23 - tests/bugs/modalg_5/bug24404 | 83 - tests/bugs/modalg_5/bug24492 | 19 - tests/bugs/modalg_5/bug24706 | 19 - tests/bugs/modalg_5/bug25242 | 15 - tests/bugs/modalg_5/bug25368_1 | 29 - tests/bugs/modalg_5/bug25368_2 | 41 - tests/bugs/modalg_5/bug25477_1 | 16 - tests/bugs/modalg_5/bug25578 | 12 - tests/bugs/modalg_5/bug25591 | 18 - tests/bugs/modalg_7/bug29939 | 215 - tests/bugs/modalg_7/bug30269 | 104 - tests/bugs/modalg_7/bug30829 | 20 - tests/bugs/modalg_7/optimal_bndbox_exception | 93 - tests/bugs/modalg_8/bug33165 | 41 - tests/bugs/moddata_1/bug20616 | 34 - tests/bugs/moddata_2/bug6503 | 27 - tests/bugs/moddata_3/bug23575 | 18 - tests/bugs/moddata_3/bug23939 | 28 - tests/bugs/moddata_3/bug24138 | 53 - tests/bugs/moddata_3/bug24375 | 32 - tests/bugs/moddata_3/bug27356 | 18 - tests/bugs/moddata_3/bug27467 | 28 - tests/bugs/moddata_3/bug29662 | 19 - tests/bugs/moddata_3/bug29723 | 29 - tests/bugs/moddata_3/bug30422 | 56 - tests/bugs/moddata_3/bug31136_5 | 69 - tests/bugs/moddata_3/bug31661_1 | 26 - tests/bugs/moddata_3/bug31661_2 | 26 - tests/bugs/moddata_3/bug31946 | 49 - tests/bugs/moddata_3/bug33828 | 35 - tests/bugs/step/bug23203 | 60 - tests/bugs/step/bug25694 | 20 - tests/bugs/step/bug25989 | 39 - tests/bugs/step/bug27070 | 8 - tests/bugs/step/bug27313 | 31 - tests/bugs/step/bug28024 | 47 - tests/bugs/step/bug28454_1 | 117 - tests/bugs/step/bug30189_2 | 38 - tests/bugs/step/bug30189_3 | 56 - tests/bugs/step/bug30694 | 54 - tests/bugs/step/bug31670_1 | 117 - tests/bugs/step/bug31923 | 57 - tests/bugs/step/bug32310 | 28 - tests/bugs/step/bug32817_1 | 13 - tests/bugs/step/bug32817_2 | 13 - tests/bugs/step/bug32817_3 | 13 - tests/bugs/step/bug33815 | 30 - tests/bugs/step/bug_ocp1949_2 | 48 - tests/bugs/stlvrml/bug25279 | 32 - tests/bugs/stlvrml/bug25740 | 43 - tests/bugs/stlvrml/bug26338 | 29 - tests/bugs/stlvrml/bug30389 | 19 - tests/bugs/xde/bug13175 | 15 - tests/bugs/xde/bug1540 | 25 - tests/bugs/xde/bug1669 | 107 - tests/bugs/xde/bug22728 | 22 - tests/bugs/xde/bug25357 | 28 - tests/bugs/xde/bug25910 | 16 - tests/bugs/xde/bug27722 | 47 - tests/bugs/xde/bug29338 | 45 - tests/bugs/xde/bug30409 | 14 - tests/bugs/xde/bug31382 | 81 - tests/bugs/xde/bug31851 | 19 - tests/bugs/xde/bug533 | 16 - tests/bugs/xde/bug7141 | 21 - tests/caf/basic/A1 | 38 - tests/caf/basic/A2 | 37 - tests/caf/basic/A3 | 43 - tests/caf/basic/A4 | 50 - tests/caf/basic/A5 | 52 - tests/caf/basic/A6 | 58 - tests/caf/basic/A7 | 58 - tests/caf/basic/B1 | 38 - tests/caf/basic/B2 | 37 - tests/caf/basic/B3 | 43 - tests/caf/basic/B4 | 50 - tests/caf/basic/B5 | 52 - tests/caf/basic/B6 | 58 - tests/caf/basic/B7 | 57 - tests/caf/basic/B8 | 41 - tests/caf/basic/C1 | 67 - tests/caf/basic/C2 | 68 - tests/caf/basic/C3 | 74 - tests/caf/basic/C4 | 79 - tests/caf/basic/C5 | 88 - tests/caf/basic/C6 | 89 - tests/caf/basic/D1 | 66 - tests/caf/basic/D2 | 69 - tests/caf/basic/D3 | 74 - tests/caf/basic/D4 | 66 - tests/caf/basic/D5 | 80 - tests/caf/basic/D6 | 89 - tests/caf/basic/D7 | 90 - tests/caf/basic/E1 | 39 - tests/caf/basic/E2 | 38 - tests/caf/basic/E3 | 44 - tests/caf/basic/E4 | 50 - tests/caf/basic/E5 | 52 - tests/caf/basic/E6 | 58 - tests/caf/basic/E7 | 57 - tests/caf/basic/F1 | 39 - tests/caf/basic/F2 | 38 - tests/caf/basic/F3 | 44 - tests/caf/basic/F4 | 81 - tests/caf/basic/F5 | 70 - tests/caf/basic/G1 | 65 - tests/caf/basic/G2 | 67 - tests/caf/basic/G3 | 74 - tests/caf/basic/H1 | 89 - tests/caf/basic/H2 | 87 - tests/caf/basic/H3 | 90 - tests/caf/basic/I1 | 85 - tests/caf/basic/I2 | 90 - tests/caf/basic/I3 | 93 - tests/caf/basic/J1 | 39 - tests/caf/basic/J2 | 38 - tests/caf/basic/J3 | 49 - tests/caf/basic/J4 | 55 - tests/caf/basic/J5 | 52 - tests/caf/basic/J6 | 70 - tests/caf/basic/K1 | 60 - tests/caf/basic/K2 | 65 - tests/caf/basic/K3 | 69 - tests/caf/basic/L1 | 49 - tests/caf/basic/L2 | 48 - tests/caf/basic/L3 | 57 - tests/caf/basic/M1 | 71 - tests/caf/basic/M2 | 74 - tests/caf/basic/M3 | 77 - tests/caf/basic/M4 | 132 - tests/caf/basic/M5 | 80 - tests/caf/basic/M6 | 89 - tests/caf/basic/M7 | 90 - tests/caf/basic/N1 | 70 - tests/caf/basic/N2 | 70 - tests/caf/basic/N4 | 50 - tests/caf/basic/N5 | 52 - tests/caf/basic/N6 | 58 - tests/caf/basic/N7 | 57 - tests/caf/basic/O5 | 80 - tests/caf/basic/O6 | 89 - tests/caf/basic/O7 | 90 - tests/caf/basic/P5 | 80 - tests/caf/basic/P6 | 89 - tests/caf/basic/P7 | 90 - tests/caf/basic/Q5 | 80 - tests/caf/basic/Q6 | 89 - tests/caf/basic/Q7 | 90 - tests/caf/basic/R5 | 74 - tests/caf/basic/R6 | 82 - tests/caf/basic/R7 | 83 - tests/caf/basic/S5 | 74 - tests/caf/basic/S6 | 82 - tests/caf/basic/S7 | 83 - tests/caf/basic/T5 | 74 - tests/caf/basic/T6 | 82 - tests/caf/basic/T7 | 83 - tests/caf/basic/U5 | 74 - tests/caf/basic/U6 | 82 - tests/caf/basic/U7 | 83 - tests/caf/basic/V5 | 74 - tests/caf/basic/V6 | 83 - tests/caf/basic/V7 | 84 - tests/caf/basic/Y1 | 78 - tests/caf/basic/Y2 | 78 - tests/caf/bugs/A1 | 58 - tests/caf/bugs/A2 | 58 - tests/caf/bugs/A3 | 79 - tests/caf/bugs/A4 | 79 - tests/caf/bugs/A5 | 59 - tests/caf/bugs/A6 | 58 - tests/caf/bugs/A7 | 89 - tests/caf/bugs/A8 | 104 - tests/caf/bugs/A9 | 107 - tests/caf/bugs/B1 | 64 - tests/caf/bugs/B2 | 85 - tests/caf/bugs/B3 | 83 - tests/caf/bugs/B4 | 72 - tests/caf/bugs/B5 | 89 - tests/caf/bugs/B7 | 97 - tests/caf/bugs/B8 | 65 - tests/caf/bugs/B9 | 58 - tests/caf/bugs/C1 | 61 - tests/caf/bugs/C2 | 82 - tests/caf/bugs/D1 | 236 - tests/caf/bugs/E1 | 40 - tests/caf/driver/A2 | 95 - tests/caf/driver/A9 | 120 - tests/caf/driver/B2 | 69 - tests/caf/driver/B3 | 124 - tests/caf/nam/A1 | 100 - tests/caf/nam/A2 | 129 - tests/caf/nam/A3 | 147 - tests/caf/nam/A4 | 53 - tests/caf/nam/A5 | 98 - tests/caf/named_shape/A1 | 66 - tests/caf/named_shape/B1 | 66 - tests/caf/named_shape/C1 | 76 - tests/caf/named_shape/D1 | 70 - tests/caf/named_shape/D2 | 70 - tests/caf/named_shape/D3 | 70 - tests/caf/named_shape/D4 | 130 - tests/caf/named_shape/E2 | 113 - tests/caf/named_shape/E9 | 143 - tests/caf/named_shape/F2 | 92 - tests/caf/named_shape/F3 | 152 - tests/caf/named_shape/F8 | 93 - tests/caf/named_shape/F9 | 93 - tests/caf/progress/A1 | 35 - tests/caf/progress/A2 | 39 - tests/caf/progress/B1 | 35 - tests/caf/progress/B2 | 37 - tests/caf/progress/C1 | 41 - tests/caf/progress/C2 | 43 - tests/caf/tree/A1 | 43 - tests/caf/tree/A2 | 41 - tests/caf/tree/A3 | 50 - tests/caf/tree/B1 | 38 - tests/caf/tree/B2 | 42 - tests/caf/tree/B3 | 43 - tests/caf/tree/C1 | 41 - tests/caf/tree/C2 | 47 - tests/caf/tree/D1 | 72 - tests/caf/tree/D2 | 85 - tests/caf/tree/E1 | 74 - tests/caf/tree/E2 | 86 - tests/caf/tree/F1 | 75 - tests/caf/tree/F2 | 87 - tests/caf/tree/G1 | 75 - tests/caf/tree/G2 | 87 - tests/caf/tree/H1 | 76 - tests/caf/tree/H2 | 85 - tests/caf/tree/I1 | 101 - tests/caf/tree/I2 | 110 - tests/caf/tree/I3 | 101 - tests/caf/tree/I4 | 125 - tests/caf/tree/J1 | 100 - tests/caf/tree/J2 | 100 - tests/caf/tree/K1 | 109 - tests/caf/tree/K2 | 109 - tests/caf/tree/L1 | 124 - tests/caf/tree/L2 | 140 - tests/caf/tree/M1 | 133 - tests/caf/tree/M2 | 132 - tests/caf/xlink/A1 | 78 - tests/caf/xlink/A2 | 78 - tests/caf/xlink/B1 | 78 - tests/caf/xlink/B2 | 83 - tests/caf/xlink/B3 | 91 - tests/caf/xlink/B4 | 78 - tests/caf/xlink/B5 | 83 - tests/caf/xlink/C1 | 89 - tests/caf/xlink/D1 | 89 - tests/caf/xlink/D2 | 138 - tests/cr/approx/A1 | 12 - tests/cr/approx/A2 | 15 - tests/cr/approx/A3 | 15 - tests/cr/approx/A4 | 16 - tests/cr/base/A1 | 13 - tests/cr/base/A2 | 12 - tests/cr/base/A3 | 13 - tests/cr/base/A4 | 15 - tests/cr/base/A5 | 15 - tests/cr/base/A6 | 15 - tests/cr/base/B1 | 15 - tests/cr/base/B10 | 18 - tests/cr/base/B2 | 14 - tests/cr/base/B3 | 13 - tests/cr/base/B4 | 12 - tests/cr/base/B5 | 25 - tests/cr/base/B6 | 25 - tests/cr/base/B7 | 25 - tests/cr/base/B8 | 25 - tests/cr/base/B9 | 40 - tests/de_mesh/gltf_read/boxinterleaved | 45 - tests/de_mesh/gltf_read/cubeemb | 53 - tests/de_mesh/shape_write_stl/B1 | 36 - tests/de_mesh/step_read/B1 | 16 - tests/de_mesh/step_write/B1 | 9 - tests/de_mesh/step_write/B2 | 13 - tests/de_mesh/step_write/C1 | 10 - tests/de_mesh/step_write/C2 | 11 - tests/de_mesh/stl_read/D1 | 91 - tests/de_wrapper/brep/A1 | 16 - tests/de_wrapper/brep/A2 | 22 - tests/de_wrapper/brep/A3 | 20 - tests/de_wrapper/brep/A4 | 16 - tests/de_wrapper/configuration/A1 | 15 - tests/de_wrapper/configuration/A2 | 15 - tests/de_wrapper/configuration/A3 | 269 -- tests/de_wrapper/configuration/A4 | 204 - tests/de_wrapper/configuration/A5 | 13 - tests/de_wrapper/stl/A1 | 16 - tests/de_wrapper/stl/A2 | 24 - tests/de_wrapper/stl/A3 | 20 - tests/de_wrapper/stl/A4 | 16 - tests/de_wrapper/vrml/A1 | 21 - tests/de_wrapper/vrml/A2 | 21 - tests/de_wrapper/vrml/A3 | 16 - tests/de_wrapper/vrml/A4 | 16 - tests/demo/draw/binpersist_1 | 25 - tests/gdt/dimensions/A1 | 14 - tests/gdt/dimensions/A2 | 16 - tests/gdt/dimensions/A3 | 15 - tests/gdt/dimensions/A4 | 20 - tests/gdt/dimensions/A5 | 24 - tests/gdt/dimensions/A6 | 22 - tests/gdt/dimensions/A7 | 33 - tests/gdt/dimensions/A8 | 38 - tests/gdt/dimensions/A9 | 35 - tests/gdt/notes/A1 | 5 - tests/gdt/notes/A2 | 13 - tests/gdt/notes/A3 | 9 - tests/gdt/notes/A4 | 16 - tests/gdt/notes/A5 | 16 - tests/gdt/notes/B1 | 25 - tests/gdt/notes/B2 | 22 - tests/gdt/notes/B3 | 25 - tests/gdt/notes/B4 | 22 - tests/gdt/notes/B5 | 15 - tests/gdt/notes/B6 | 18 - tests/gdt/notes/B7 | 21 - tests/gdt/notes/C1 | 24 - tests/gdt/notes/C2 | 28 - tests/gdt/notes/C3 | 28 - tests/gdt/notes/C4 | 27 - tests/gdt/notes/C5 | 29 - tests/gdt/notes/C6 | 29 - tests/gdt/notes/C7 | 31 - tests/gdt/notes/C8 | 33 - tests/gdt/notes/C9 | 33 - tests/gdt/notes/D1 | 51 - tests/gdt/tolerances/A1 | 35 - tests/gdt/tolerances/A2 | 28 - .../geometry/circ2d3Tan/CircleCircleCircle_11 | 13 - .../geometry/circ2d3Tan/CircleCirclePoint_11 | 7 - .../geometry/circ2d3Tan/CircleCirclePoint_12 | 8 - .../geometry/circ2d3Tan/CircleCirclePoint_14 | 8 - tests/geometry/circ2d3Tan/CircleLinLin_11 | 9 - tests/geometry/circ2d3Tan/CirclePointPoint_11 | 7 - tests/geometry/circ2d3Tan/CirclePointPoint_12 | 6 - tests/geometry/circ2d3Tan/CirclePointPoint_13 | 7 - tests/geometry/circ2d3Tan/CirclePointPoint_14 | 6 - tests/geometry/circ2d3Tan/CirclePointPoint_15 | 7 - tests/geometry/circ2d3Tan/CirclePointPoint_21 | 7 - tests/geometry/circ2d3Tan/CirclePointPoint_22 | 7 - tests/geometry/circ2d3Tan/CirclePointPoint_24 | 6 - tests/geometry/circ2d3Tan/CirclePointPoint_31 | 6 - tests/geometry/circ2d3Tan/LinLinLin_11 | 9 - tests/geometry/circ2d3Tan/LinLinPoint_11 | 7 - tests/geometry/circ2d3Tan/LinPointPoint_11 | 7 - tests/geometry/circ2d3Tan/PointPointPoint_11 | 6 - tests/lowalgos/2dgcc/buc60607_1 | 12 - tests/lowalgos/2dgcc/buc60607_2 | 8 - tests/lowalgos/2dgcc/buc60607_3 | 8 - tests/lowalgos/2dgcc/buc60607_4 | 8 - tests/lowalgos/2dgcc/buc60618 | 21 - tests/lowalgos/2dgcc/buc60622_1 | 14 - tests/lowalgos/2dgcc/buc60622_2 | 17 - tests/lowalgos/2dgcc/buc60622_3 | 19 - tests/lowalgos/2dgcc/buc60941 | 20 - tests/lowalgos/2dgcc/bug29694 | 18 - tests/lowalgos/2dinter/bug23706_4 | 37 - tests/lowalgos/2dinter/bug23706_5 | 34 - tests/lowalgos/2dinter/bug29162 | 22 - tests/lowalgos/bnd/bug30292 | 68 - tests/lowalgos/bvh/bug30655_1 | 58 - tests/lowalgos/bvh/bug30655_2 | 16 - tests/lowalgos/bvh/bug30655_3 | 21 - tests/lowalgos/bvh/bug30655_4 | 13 - tests/lowalgos/extcc/bug29712_10 | 33 - tests/lowalgos/extcc/bug29712_11 | 33 - tests/lowalgos/extcc/bug29712_12 | 33 - tests/lowalgos/extcc/bug29712_13 | 35 - tests/lowalgos/extcc/bug29712_14 | 24 - tests/lowalgos/extcc/bug29712_15 | 24 - tests/lowalgos/extcc/bug29712_16 | 45 - tests/lowalgos/extcc/bug29712_17 | 24 - tests/lowalgos/extcc/bug29712_18 | 24 - tests/lowalgos/extcc/bug29712_19 | 24 - tests/lowalgos/extcc/bug29712_2 | 19 - tests/lowalgos/extcc/bug29712_20 | 24 - tests/lowalgos/extcc/bug29712_21 | 35 - tests/lowalgos/extcc/bug29712_22 | 33 - tests/lowalgos/extcc/bug29712_23 | 24 - tests/lowalgos/extcc/bug29712_24 | 34 - tests/lowalgos/extcc/bug29712_25 | 35 - tests/lowalgos/extcc/bug29712_26 | 24 - tests/lowalgos/extcc/bug29712_27 | 24 - tests/lowalgos/extcc/bug29712_28 | 40 - tests/lowalgos/extcc/bug29712_29 | 34 - tests/lowalgos/extcc/bug29712_3 | 35 - tests/lowalgos/extcc/bug29712_30 | 24 - tests/lowalgos/extcc/bug29712_31 | 24 - tests/lowalgos/extcc/bug29712_32 | 35 - tests/lowalgos/extcc/bug29712_33 | 24 - tests/lowalgos/extcc/bug29712_36 | 24 - tests/lowalgos/extcc/bug29712_37 | 37 - tests/lowalgos/extcc/bug29712_38 | 25 - tests/lowalgos/extcc/bug29712_39 | 19 - tests/lowalgos/extcc/bug29712_4 | 21 - tests/lowalgos/extcc/bug29712_40 | 19 - tests/lowalgos/extcc/bug29712_41 | 19 - tests/lowalgos/extcc/bug29712_42 | 25 - tests/lowalgos/extcc/bug29712_43 | 25 - tests/lowalgos/extcc/bug29712_5 | 34 - tests/lowalgos/extcc/bug29712_6 | 18 - tests/lowalgos/extcc/bug29712_7 | 19 - tests/lowalgos/extcc/bug29712_8 | 19 - tests/lowalgos/extcc/bug29712_9 | 20 - tests/lowalgos/extcs/bug29426_1 | 18 - tests/lowalgos/extcs/bug29426_2 | 17 - tests/lowalgos/extcs/circ_sph_inter | 127 - tests/lowalgos/extcs/circ_sph_nointer | 160 - tests/lowalgos/extcs/circ_sph_parallel | 82 - tests/lowalgos/extcs/circ_sph_touch | 93 - tests/lowalgos/extss/bug29712_44 | 20 - tests/lowalgos/intcs/bug26979 | 39 - tests/lowalgos/intss/bug23644 | 20 - tests/lowalgos/intss/bug24313 | 14 - tests/lowalgos/intss/bug24418_2 | 26 - tests/lowalgos/intss/bug25782_2 | 51 - tests/lowalgos/intss/bug32850 | 19 - tests/lowalgos/intss/bug33244 | 48 - tests/lowalgos/progress/A1 | 33 - tests/lowalgos/progress/A2 | 30 - tests/lowalgos/progress/A3 | 40 - tests/lowalgos/progress/A4 | 27 - tests/lowalgos/proximity/A1 | 24 - tests/lowalgos/proximity/A2 | 26 - tests/lowalgos/proximity/A3 | 28 - tests/lowalgos/proximity/A4 | 26 - tests/lowalgos/proximity/A5 | 31 - tests/lowalgos/proximity/B1 | 28 - tests/lowalgos/proximity/B2 | 28 - tests/lowalgos/proximity/B3 | 28 - tests/lowalgos/proximity/B4 | 28 - tests/lowalgos/proximity/B5 | 27 - tests/lowalgos/proximity/C1 | 29 - tests/lowalgos/proximity/C2 | 29 - tests/lowalgos/proximity/C3 | 28 - tests/lowalgos/proximity/C4 | 28 - tests/lowalgos/proximity/D1 | 28 - tests/lowalgos/proximity/D2 | 26 - tests/lowalgos/proximity/D3 | 33 - tests/lowalgos/proximity/D4 | 29 - tests/lowalgos/proximity/E1 | 30 - tests/lowalgos/proximity/E2 | 27 - tests/perf/de/bug29830_3 | 27 - tests/pipe/bugs/bug24909_2 | 25 - tests/v3d/colors/begin | 7 - tests/v3d/colors/de2000 | 60 - tests/v3d/colors/de2000_sharma | 70 - tests/v3d/colors/rgb2lab | 39 - tests/v3d/colors/rgb2lch | 40 - tests/v3d/colors/stability | 18 - tests/xml/data/ocaf/A1 | 24 - tests/xml/data/ocaf/A2 | 25 - tests/xml/data/ocaf/A3 | 45 - tests/xml/data/ocaf/A4 | 45 - tests/xml/data/ocaf/A5 | 26 - tests/xml/data/ocaf/A6 | 26 - tests/xml/data/ocaf/A7 | 49 - tests/xml/data/ocaf/A8 | 53 - tests/xml/data/ocaf/A9 | 61 - tests/xml/data/ocaf/B1 | 31 - tests/xml/data/ocaf/B2 | 44 - tests/xml/data/ocaf/B3 | 52 - tests/xml/data/ocaf/B4 | 55 - tests/xml/data/ocaf/B5 | 61 - tests/xml/data/ocaf/B7 | 79 - tests/xml/data/ocaf/B8 | 35 - tests/xml/data/ocaf/B9 | 26 - tests/xml/data/ocaf/C1 | 45 - tests/xml/data/ocaf/C2 | 67 - tests/xml/data/ocaf/C3 | 42 - tests/xml/data/ocaf/C4 | 36 - tests/xml/data/ocaf/C5 | 62 - tests/xml/data/ocaf/C6 | 37 - tests/xml/data/ocaf/C7 | 32 - tests/xml/data/ocaf/C8 | 46 - tests/xml/data/ocaf/C9 | 38 - tests/xml/data/ocaf/D1 | 41 - tests/xml/data/ocaf/D2 | 57 - tests/xml/data/ocaf/D3 | 46 - tests/xml/data/ocaf/D4 | 46 - tests/xml/data/ocaf/D5 | 47 - tests/xml/data/ocaf/D6 | 41 - tests/xml/data/xcaf/A1 | 33 - tests/xml/data/xcaf/A4 | 26 - tests/xml/data/xcaf/A5 | 25 - tests/xml/data/xcaf/A6 | 41 - tests/xml/data/xcaf/A7 | 29 - tests/xml/data/xcaf/A8 | 30 - tests/xml/data/xcaf/A9 | 33 - 765 files changed, 27824 insertions(+), 32055 deletions(-) create mode 100644 src/ApplicationFramework/TKCAF/GTests/TDataXtd_Attribute_Test.cxx create mode 100644 src/ApplicationFramework/TKLCAF/GTests/TDF_Copy_Test.cxx create mode 100644 src/ApplicationFramework/TKLCAF/GTests/TDataStd_Expression_Test.cxx create mode 100644 src/ApplicationFramework/TKLCAF/GTests/TDataStd_List_Test.cxx create mode 100644 src/ApplicationFramework/TKLCAF/GTests/TDocStd_Application_Test.cxx create mode 100644 src/ApplicationFramework/TKLCAF/GTests/TDocStd_Transaction_Test.cxx create mode 100644 src/ApplicationFramework/TKLCAF/GTests/TDocStd_XLink_Test.cxx create mode 100644 src/ApplicationFramework/TKVCAF/GTests/TPrsStd_AISPresentation_Test.cxx create mode 100644 src/ApplicationFramework/TKXml/GTests/TDocStd_Progress_Test.cxx create mode 100644 src/ApplicationFramework/TKXml/GTests/TDocStd_Storage_Test.cxx create mode 100644 src/ApplicationFramework/TKXml/GTests/XmlOcaf_Storage_Test.cxx create mode 100644 src/DataExchange/TKDE/GTests/DE_Wrapper_Configuration_Test.cxx create mode 100644 src/DataExchange/TKDECascade/GTests/DEBREP_Provider_Test.cxx create mode 100644 src/DataExchange/TKDEGLTF/GTests/DEGLTF_Provider_Test.cxx create mode 100644 src/DataExchange/TKDESTEP/GTests/GDT_STEP_Storage_Test.cxx create mode 100644 src/DataExchange/TKDESTL/GTests/DEMesh_ShapeWriteStl_Test.cxx create mode 100644 src/DataExchange/TKXCAF/GTests/XCAFDoc_GDT_Test.cxx create mode 100644 src/DataExchange/TKXCAF/GTests/XCAFDoc_NotesTool_Test.cxx create mode 100644 src/DataExchange/TKXmlXCAF/GTests/XmlXCAF_Storage_Test.cxx create mode 100644 src/Draw/TKDCAF/GTests/DNaming_Driver_Test.cxx create mode 100644 src/Draw/TKDCAF/GTests/FILES.cmake create mode 100644 src/FoundationClasses/TKMath/GTests/BVH_DistanceField_Test.cxx create mode 100644 src/FoundationClasses/TKMath/GTests/BVH_PairDistance_Test.cxx create mode 100644 src/FoundationClasses/TKMath/GTests/BVH_ShapeSelect_Test.cxx create mode 100644 src/ModelingAlgorithms/TKBO/GTests/BOPAlgo_CellsBuilder_Test.cxx create mode 100644 src/ModelingAlgorithms/TKBO/GTests/BOPAlgo_MakePeriodic_Test.cxx create mode 100644 src/ModelingAlgorithms/TKBO/GTests/BOPAlgo_OpenSolid_Test.cxx create mode 100644 src/ModelingAlgorithms/TKBO/GTests/BRepAlgoAPI_Simplify_Test.cxx create mode 100644 src/ModelingAlgorithms/TKBO/GTests/BRepAlgoAPI_Splitter_Test.cxx create mode 100644 src/ModelingAlgorithms/TKBO/GTests/BRepTools_History_Test.cxx create mode 100644 src/ModelingAlgorithms/TKGeomAlgo/GTests/GccAna_Circ2d3Tan_Test.cxx create mode 100644 src/ModelingAlgorithms/TKGeomAlgo/GTests/Geom2dAPI_ExtremaCurveCurve_Test.cxx create mode 100644 src/ModelingAlgorithms/TKGeomAlgo/GTests/GeomAPI_ExtremaCurveSurface_Test.cxx create mode 100644 src/ModelingAlgorithms/TKGeomAlgo/GTests/GeomAPI_ExtremaSurfaceSurface_Test.cxx create mode 100644 src/ModelingAlgorithms/TKGeomAlgo/GTests/GeomAPI_IntCS_Test.cxx create mode 100644 src/ModelingAlgorithms/TKPrim/GTests/BRepPrimAPI_MakeRevol_Test.cxx create mode 100644 src/ModelingAlgorithms/TKTopAlgo/GTests/BRepBndLib_Test.cxx create mode 100644 src/ModelingAlgorithms/TKTopAlgo/GTests/BRepBuilderAPI_MakeShell_Test.cxx create mode 100644 src/ModelingAlgorithms/TKTopAlgo/GTests/BRepExtrema_ShapeProximity_Test.cxx create mode 100644 src/ModelingData/TKGeomBase/GTests/GCPnts_QuasiUniformDeflection_Test.cxx create mode 100644 src/ModelingData/TKGeomBase/GTests/GeomProjLib_Test.cxx delete mode 100644 tests/boolean/history/A1 delete mode 100644 tests/boolean/history/A2 delete mode 100644 tests/boolean/history/A3 delete mode 100644 tests/boolean/history/A4 delete mode 100644 tests/boolean/history/A5 delete mode 100644 tests/boolean/history/A6 delete mode 100644 tests/boolean/history/A8 delete mode 100644 tests/boolean/history/A9 delete mode 100644 tests/boolean/mkconnected/A1 delete mode 100644 tests/boolean/mkconnected/A2 delete mode 100644 tests/boolean/mkconnected/A5 delete mode 100644 tests/boolean/opensolid/A1 delete mode 100644 tests/boolean/opensolid/A2 delete mode 100644 tests/boolean/opensolid/A3 delete mode 100644 tests/boolean/opensolid/A4 delete mode 100644 tests/boolean/opensolid/A5 delete mode 100644 tests/boolean/opensolid/A6 delete mode 100644 tests/boolean/opensolid/A7 delete mode 100644 tests/boolean/opensolid/A8 delete mode 100644 tests/boolean/opensolid/A9 delete mode 100644 tests/boolean/periodicity/A1 delete mode 100644 tests/boolean/periodicity/A2 delete mode 100644 tests/boolean/periodicity/A3 delete mode 100644 tests/boolean/periodicity/A4 delete mode 100644 tests/boolean/periodicity/A5 delete mode 100644 tests/boolean/periodicity/A6 delete mode 100644 tests/boolean/simplify/A1 delete mode 100644 tests/boolean/simplify/A2 delete mode 100644 tests/boolean/splitter/A1 delete mode 100644 tests/boolean/splitter/A2 delete mode 100644 tests/boolean/splitter/A3 delete mode 100644 tests/boolean/splitter/A4 delete mode 100644 tests/boolean/splitter/A6 delete mode 100644 tests/boolean/splitter/B1 delete mode 100644 tests/boolean/splitter/B2 delete mode 100644 tests/boolean/splitter/B3 delete mode 100644 tests/boolean/splitter/B4 delete mode 100644 tests/boolean/splitter/B6 delete mode 100755 tests/bugs/caf/buc60790 delete mode 100755 tests/bugs/caf/buc60813 delete mode 100755 tests/bugs/caf/buc60831 delete mode 100755 tests/bugs/caf/buc60844 delete mode 100755 tests/bugs/caf/buc60847 delete mode 100755 tests/bugs/caf/buc60862 delete mode 100755 tests/bugs/caf/buc60910 delete mode 100755 tests/bugs/caf/bug158 delete mode 100644 tests/bugs/caf/bug159 delete mode 100755 tests/bugs/caf/bug170_3 delete mode 100644 tests/bugs/caf/bug1722 delete mode 100755 tests/bugs/caf/bug21231 delete mode 100755 tests/bugs/caf/bug22976 delete mode 100755 tests/bugs/caf/bug23306 delete mode 100644 tests/bugs/caf/bug23465 delete mode 100755 tests/bugs/caf/bug23799 delete mode 100644 tests/bugs/caf/bug23912 delete mode 100644 tests/bugs/caf/bug24164_1 delete mode 100644 tests/bugs/caf/bug24164_2 delete mode 100644 tests/bugs/caf/bug24263 delete mode 100644 tests/bugs/caf/bug24263_2 delete mode 100644 tests/bugs/caf/bug24645 delete mode 100755 tests/bugs/caf/bug24852 delete mode 100644 tests/bugs/caf/bug24869 delete mode 100644 tests/bugs/caf/bug24925 delete mode 100644 tests/bugs/caf/bug25112 delete mode 100644 tests/bugs/caf/bug25153 delete mode 100755 tests/bugs/caf/bug25317 delete mode 100755 tests/bugs/caf/bug25394_1 delete mode 100755 tests/bugs/caf/bug25394_2 delete mode 100755 tests/bugs/caf/bug25394_3 delete mode 100644 tests/bugs/caf/bug25536 delete mode 100644 tests/bugs/caf/bug25537 delete mode 100644 tests/bugs/caf/bug26061 delete mode 100755 tests/bugs/caf/bug261 delete mode 100644 tests/bugs/caf/bug26155 delete mode 100644 tests/bugs/caf/bug26229_1 delete mode 100644 tests/bugs/caf/bug26229_2 delete mode 100644 tests/bugs/caf/bug26428 delete mode 100644 tests/bugs/caf/bug267_1 delete mode 100644 tests/bugs/caf/bug27187 delete mode 100644 tests/bugs/caf/bug28425 delete mode 100644 tests/bugs/caf/bug28428 delete mode 100644 tests/bugs/caf/bug29142 delete mode 100755 tests/bugs/caf/bug2932_1 delete mode 100644 tests/bugs/caf/bug2932_10 delete mode 100644 tests/bugs/caf/bug2932_11 delete mode 100644 tests/bugs/caf/bug2932_12 delete mode 100644 tests/bugs/caf/bug2932_13 delete mode 100644 tests/bugs/caf/bug2932_14 delete mode 100644 tests/bugs/caf/bug2932_15 delete mode 100644 tests/bugs/caf/bug2932_16 delete mode 100644 tests/bugs/caf/bug2932_17 delete mode 100644 tests/bugs/caf/bug2932_18 delete mode 100644 tests/bugs/caf/bug2932_19 delete mode 100755 tests/bugs/caf/bug2932_2 delete mode 100644 tests/bugs/caf/bug2932_20 delete mode 100644 tests/bugs/caf/bug2932_21 delete mode 100644 tests/bugs/caf/bug2932_22 delete mode 100644 tests/bugs/caf/bug2932_24 delete mode 100644 tests/bugs/caf/bug2932_3 delete mode 100644 tests/bugs/caf/bug2932_4 delete mode 100644 tests/bugs/caf/bug2932_5 delete mode 100644 tests/bugs/caf/bug2932_6 delete mode 100644 tests/bugs/caf/bug2932_7 delete mode 100644 tests/bugs/caf/bug2932_8 delete mode 100644 tests/bugs/caf/bug2932_9 delete mode 100644 tests/bugs/caf/bug29669 delete mode 100644 tests/bugs/caf/bug29901 delete mode 100644 tests/bugs/caf/bug31323 delete mode 100644 tests/bugs/caf/bug31785 delete mode 100644 tests/bugs/caf/bug31839_1 delete mode 100644 tests/bugs/caf/bug31839_2 delete mode 100644 tests/bugs/caf/bug31918_1 delete mode 100644 tests/bugs/caf/bug31920 delete mode 100755 tests/bugs/caf/bug387 delete mode 100755 tests/bugs/caf/bug425 delete mode 100644 tests/bugs/caf/bug644 delete mode 100755 tests/bugs/caf/bug9746 delete mode 100644 tests/bugs/demo/bug14673_4 delete mode 100755 tests/bugs/demo/bug23130 delete mode 100644 tests/bugs/demo/bug25344_4 delete mode 100644 tests/bugs/demo/bug25445 delete mode 100755 tests/bugs/fclasses/bug11568_1 delete mode 100755 tests/bugs/fclasses/bug11568_2 delete mode 100644 tests/bugs/fclasses/bug11568_3 delete mode 100644 tests/bugs/fclasses/bug11568_4 delete mode 100755 tests/bugs/fclasses/bug23403 delete mode 100755 tests/bugs/fclasses/bug23852 delete mode 100755 tests/bugs/fclasses/bug24897 delete mode 100644 tests/bugs/fclasses/bug24931 delete mode 100755 tests/bugs/fclasses/bug25635_1 delete mode 100755 tests/bugs/fclasses/bug25635_2 delete mode 100755 tests/bugs/fclasses/bug26922 delete mode 100644 tests/bugs/fclasses/bug28478 delete mode 100644 tests/bugs/fclasses/bug30800 delete mode 100644 tests/bugs/fclasses/bug31092 delete mode 100644 tests/bugs/fclasses/bug31381 delete mode 100755 tests/bugs/fclasses/bug710 delete mode 100755 tests/bugs/fclasses/bug9848_1 delete mode 100755 tests/bugs/fclasses/bug9848_2 delete mode 100644 tests/bugs/filling/bug13904 delete mode 100644 tests/bugs/filling/bug27775 delete mode 100644 tests/bugs/heal/bug24881 delete mode 100755 tests/bugs/heal/bug25014 delete mode 100644 tests/bugs/heal/bug29382_3 delete mode 100644 tests/bugs/heal/bug29544_2 delete mode 100644 tests/bugs/heal/bug30927 delete mode 100644 tests/bugs/mesh/bug30234 delete mode 100644 tests/bugs/mesh/bug31125 delete mode 100644 tests/bugs/mesh/bug32692_3 delete mode 100644 tests/bugs/modalg_5/bug21564 delete mode 100644 tests/bugs/modalg_5/bug23855 delete mode 100644 tests/bugs/modalg_5/bug23932_1 delete mode 100644 tests/bugs/modalg_5/bug23932_2 delete mode 100644 tests/bugs/modalg_5/bug23954 delete mode 100644 tests/bugs/modalg_5/bug24029 delete mode 100755 tests/bugs/modalg_5/bug24033 delete mode 100644 tests/bugs/modalg_5/bug24213 delete mode 100644 tests/bugs/modalg_5/bug24328 delete mode 100644 tests/bugs/modalg_5/bug24404 delete mode 100644 tests/bugs/modalg_5/bug24492 delete mode 100755 tests/bugs/modalg_5/bug24706 delete mode 100644 tests/bugs/modalg_5/bug25242 delete mode 100644 tests/bugs/modalg_5/bug25368_1 delete mode 100644 tests/bugs/modalg_5/bug25368_2 delete mode 100644 tests/bugs/modalg_5/bug25477_1 delete mode 100644 tests/bugs/modalg_5/bug25578 delete mode 100644 tests/bugs/modalg_5/bug25591 delete mode 100644 tests/bugs/modalg_7/bug29939 delete mode 100644 tests/bugs/modalg_7/bug30269 delete mode 100644 tests/bugs/modalg_7/bug30829 delete mode 100644 tests/bugs/modalg_7/optimal_bndbox_exception delete mode 100644 tests/bugs/modalg_8/bug33165 delete mode 100755 tests/bugs/moddata_1/bug20616 delete mode 100755 tests/bugs/moddata_2/bug6503 delete mode 100644 tests/bugs/moddata_3/bug23575 delete mode 100644 tests/bugs/moddata_3/bug23939 delete mode 100755 tests/bugs/moddata_3/bug24138 delete mode 100644 tests/bugs/moddata_3/bug24375 delete mode 100644 tests/bugs/moddata_3/bug27356 delete mode 100644 tests/bugs/moddata_3/bug27467 delete mode 100644 tests/bugs/moddata_3/bug29662 delete mode 100644 tests/bugs/moddata_3/bug29723 delete mode 100644 tests/bugs/moddata_3/bug30422 delete mode 100644 tests/bugs/moddata_3/bug31136_5 delete mode 100644 tests/bugs/moddata_3/bug31661_1 delete mode 100644 tests/bugs/moddata_3/bug31661_2 delete mode 100644 tests/bugs/moddata_3/bug31946 delete mode 100644 tests/bugs/moddata_3/bug33828 delete mode 100755 tests/bugs/step/bug23203 delete mode 100644 tests/bugs/step/bug25694 delete mode 100644 tests/bugs/step/bug25989 delete mode 100644 tests/bugs/step/bug27070 delete mode 100644 tests/bugs/step/bug27313 delete mode 100644 tests/bugs/step/bug28024 delete mode 100644 tests/bugs/step/bug28454_1 delete mode 100644 tests/bugs/step/bug30189_2 delete mode 100644 tests/bugs/step/bug30189_3 delete mode 100644 tests/bugs/step/bug30694 delete mode 100644 tests/bugs/step/bug31670_1 delete mode 100644 tests/bugs/step/bug31923 delete mode 100644 tests/bugs/step/bug32310 delete mode 100644 tests/bugs/step/bug32817_1 delete mode 100644 tests/bugs/step/bug32817_2 delete mode 100644 tests/bugs/step/bug32817_3 delete mode 100644 tests/bugs/step/bug33815 delete mode 100644 tests/bugs/step/bug_ocp1949_2 delete mode 100755 tests/bugs/stlvrml/bug25279 delete mode 100644 tests/bugs/stlvrml/bug25740 delete mode 100644 tests/bugs/stlvrml/bug26338 delete mode 100644 tests/bugs/stlvrml/bug30389 delete mode 100644 tests/bugs/xde/bug13175 delete mode 100755 tests/bugs/xde/bug1540 delete mode 100755 tests/bugs/xde/bug1669 delete mode 100755 tests/bugs/xde/bug22728 delete mode 100644 tests/bugs/xde/bug25357 delete mode 100644 tests/bugs/xde/bug25910 delete mode 100644 tests/bugs/xde/bug27722 delete mode 100644 tests/bugs/xde/bug29338 delete mode 100644 tests/bugs/xde/bug30409 delete mode 100644 tests/bugs/xde/bug31382 delete mode 100644 tests/bugs/xde/bug31851 delete mode 100755 tests/bugs/xde/bug533 delete mode 100755 tests/bugs/xde/bug7141 delete mode 100755 tests/caf/basic/A1 delete mode 100755 tests/caf/basic/A2 delete mode 100755 tests/caf/basic/A3 delete mode 100644 tests/caf/basic/A4 delete mode 100644 tests/caf/basic/A5 delete mode 100644 tests/caf/basic/A6 delete mode 100644 tests/caf/basic/A7 delete mode 100755 tests/caf/basic/B1 delete mode 100755 tests/caf/basic/B2 delete mode 100755 tests/caf/basic/B3 delete mode 100644 tests/caf/basic/B4 delete mode 100755 tests/caf/basic/B5 delete mode 100644 tests/caf/basic/B6 delete mode 100644 tests/caf/basic/B7 delete mode 100644 tests/caf/basic/B8 delete mode 100755 tests/caf/basic/C1 delete mode 100755 tests/caf/basic/C2 delete mode 100755 tests/caf/basic/C3 delete mode 100644 tests/caf/basic/C4 delete mode 100644 tests/caf/basic/C5 delete mode 100644 tests/caf/basic/C6 delete mode 100755 tests/caf/basic/D1 delete mode 100755 tests/caf/basic/D2 delete mode 100755 tests/caf/basic/D3 delete mode 100644 tests/caf/basic/D4 delete mode 100644 tests/caf/basic/D5 delete mode 100644 tests/caf/basic/D6 delete mode 100644 tests/caf/basic/D7 delete mode 100755 tests/caf/basic/E1 delete mode 100755 tests/caf/basic/E2 delete mode 100755 tests/caf/basic/E3 delete mode 100644 tests/caf/basic/E4 delete mode 100644 tests/caf/basic/E5 delete mode 100644 tests/caf/basic/E6 delete mode 100644 tests/caf/basic/E7 delete mode 100755 tests/caf/basic/F1 delete mode 100755 tests/caf/basic/F2 delete mode 100755 tests/caf/basic/F3 delete mode 100644 tests/caf/basic/F4 delete mode 100644 tests/caf/basic/F5 delete mode 100755 tests/caf/basic/G1 delete mode 100755 tests/caf/basic/G2 delete mode 100755 tests/caf/basic/G3 delete mode 100755 tests/caf/basic/H1 delete mode 100755 tests/caf/basic/H2 delete mode 100755 tests/caf/basic/H3 delete mode 100755 tests/caf/basic/I1 delete mode 100755 tests/caf/basic/I2 delete mode 100755 tests/caf/basic/I3 delete mode 100755 tests/caf/basic/J1 delete mode 100755 tests/caf/basic/J2 delete mode 100755 tests/caf/basic/J3 delete mode 100755 tests/caf/basic/J4 delete mode 100755 tests/caf/basic/J5 delete mode 100755 tests/caf/basic/J6 delete mode 100755 tests/caf/basic/K1 delete mode 100755 tests/caf/basic/K2 delete mode 100755 tests/caf/basic/K3 delete mode 100755 tests/caf/basic/L1 delete mode 100755 tests/caf/basic/L2 delete mode 100755 tests/caf/basic/L3 delete mode 100755 tests/caf/basic/M1 delete mode 100755 tests/caf/basic/M2 delete mode 100755 tests/caf/basic/M3 delete mode 100755 tests/caf/basic/M4 delete mode 100644 tests/caf/basic/M5 delete mode 100644 tests/caf/basic/M6 delete mode 100644 tests/caf/basic/M7 delete mode 100644 tests/caf/basic/N1 delete mode 100644 tests/caf/basic/N2 delete mode 100644 tests/caf/basic/N4 delete mode 100644 tests/caf/basic/N5 delete mode 100644 tests/caf/basic/N6 delete mode 100644 tests/caf/basic/N7 delete mode 100644 tests/caf/basic/O5 delete mode 100644 tests/caf/basic/O6 delete mode 100644 tests/caf/basic/O7 delete mode 100644 tests/caf/basic/P5 delete mode 100644 tests/caf/basic/P6 delete mode 100644 tests/caf/basic/P7 delete mode 100644 tests/caf/basic/Q5 delete mode 100644 tests/caf/basic/Q6 delete mode 100644 tests/caf/basic/Q7 delete mode 100644 tests/caf/basic/R5 delete mode 100644 tests/caf/basic/R6 delete mode 100644 tests/caf/basic/R7 delete mode 100644 tests/caf/basic/S5 delete mode 100644 tests/caf/basic/S6 delete mode 100644 tests/caf/basic/S7 delete mode 100644 tests/caf/basic/T5 delete mode 100644 tests/caf/basic/T6 delete mode 100644 tests/caf/basic/T7 delete mode 100644 tests/caf/basic/U5 delete mode 100644 tests/caf/basic/U6 delete mode 100644 tests/caf/basic/U7 delete mode 100644 tests/caf/basic/V5 delete mode 100644 tests/caf/basic/V6 delete mode 100644 tests/caf/basic/V7 delete mode 100644 tests/caf/basic/Y1 delete mode 100644 tests/caf/basic/Y2 delete mode 100755 tests/caf/bugs/A1 delete mode 100755 tests/caf/bugs/A2 delete mode 100755 tests/caf/bugs/A3 delete mode 100755 tests/caf/bugs/A4 delete mode 100755 tests/caf/bugs/A5 delete mode 100755 tests/caf/bugs/A6 delete mode 100755 tests/caf/bugs/A7 delete mode 100755 tests/caf/bugs/A8 delete mode 100755 tests/caf/bugs/A9 delete mode 100755 tests/caf/bugs/B1 delete mode 100755 tests/caf/bugs/B2 delete mode 100755 tests/caf/bugs/B3 delete mode 100755 tests/caf/bugs/B4 delete mode 100755 tests/caf/bugs/B5 delete mode 100755 tests/caf/bugs/B7 delete mode 100755 tests/caf/bugs/B8 delete mode 100755 tests/caf/bugs/B9 delete mode 100755 tests/caf/bugs/C1 delete mode 100755 tests/caf/bugs/C2 delete mode 100755 tests/caf/bugs/D1 delete mode 100644 tests/caf/bugs/E1 delete mode 100755 tests/caf/driver/A2 delete mode 100755 tests/caf/driver/A9 delete mode 100755 tests/caf/driver/B2 delete mode 100755 tests/caf/driver/B3 delete mode 100644 tests/caf/nam/A1 delete mode 100644 tests/caf/nam/A2 delete mode 100644 tests/caf/nam/A3 delete mode 100644 tests/caf/nam/A4 delete mode 100644 tests/caf/nam/A5 delete mode 100755 tests/caf/named_shape/A1 delete mode 100755 tests/caf/named_shape/B1 delete mode 100755 tests/caf/named_shape/C1 delete mode 100755 tests/caf/named_shape/D1 delete mode 100755 tests/caf/named_shape/D2 delete mode 100755 tests/caf/named_shape/D3 delete mode 100644 tests/caf/named_shape/D4 delete mode 100755 tests/caf/named_shape/E2 delete mode 100755 tests/caf/named_shape/E9 delete mode 100755 tests/caf/named_shape/F2 delete mode 100755 tests/caf/named_shape/F3 delete mode 100755 tests/caf/named_shape/F8 delete mode 100755 tests/caf/named_shape/F9 delete mode 100644 tests/caf/progress/A1 delete mode 100644 tests/caf/progress/A2 delete mode 100644 tests/caf/progress/B1 delete mode 100644 tests/caf/progress/B2 delete mode 100644 tests/caf/progress/C1 delete mode 100644 tests/caf/progress/C2 delete mode 100755 tests/caf/tree/A1 delete mode 100755 tests/caf/tree/A2 delete mode 100755 tests/caf/tree/A3 delete mode 100755 tests/caf/tree/B1 delete mode 100755 tests/caf/tree/B2 delete mode 100755 tests/caf/tree/B3 delete mode 100755 tests/caf/tree/C1 delete mode 100755 tests/caf/tree/C2 delete mode 100755 tests/caf/tree/D1 delete mode 100755 tests/caf/tree/D2 delete mode 100755 tests/caf/tree/E1 delete mode 100755 tests/caf/tree/E2 delete mode 100755 tests/caf/tree/F1 delete mode 100755 tests/caf/tree/F2 delete mode 100755 tests/caf/tree/G1 delete mode 100755 tests/caf/tree/G2 delete mode 100755 tests/caf/tree/H1 delete mode 100755 tests/caf/tree/H2 delete mode 100755 tests/caf/tree/I1 delete mode 100755 tests/caf/tree/I2 delete mode 100755 tests/caf/tree/I3 delete mode 100755 tests/caf/tree/I4 delete mode 100755 tests/caf/tree/J1 delete mode 100755 tests/caf/tree/J2 delete mode 100755 tests/caf/tree/K1 delete mode 100755 tests/caf/tree/K2 delete mode 100755 tests/caf/tree/L1 delete mode 100755 tests/caf/tree/L2 delete mode 100755 tests/caf/tree/M1 delete mode 100755 tests/caf/tree/M2 delete mode 100755 tests/caf/xlink/A1 delete mode 100755 tests/caf/xlink/A2 delete mode 100755 tests/caf/xlink/B1 delete mode 100755 tests/caf/xlink/B2 delete mode 100755 tests/caf/xlink/B3 delete mode 100755 tests/caf/xlink/B4 delete mode 100755 tests/caf/xlink/B5 delete mode 100755 tests/caf/xlink/C1 delete mode 100755 tests/caf/xlink/D1 delete mode 100755 tests/caf/xlink/D2 delete mode 100644 tests/cr/approx/A1 delete mode 100644 tests/cr/approx/A2 delete mode 100644 tests/cr/approx/A3 delete mode 100644 tests/cr/approx/A4 delete mode 100644 tests/cr/base/A1 delete mode 100644 tests/cr/base/A2 delete mode 100644 tests/cr/base/A3 delete mode 100644 tests/cr/base/A4 delete mode 100644 tests/cr/base/A5 delete mode 100644 tests/cr/base/A6 delete mode 100644 tests/cr/base/B1 delete mode 100644 tests/cr/base/B10 delete mode 100644 tests/cr/base/B2 delete mode 100644 tests/cr/base/B3 delete mode 100644 tests/cr/base/B4 delete mode 100644 tests/cr/base/B5 delete mode 100644 tests/cr/base/B6 delete mode 100644 tests/cr/base/B7 delete mode 100644 tests/cr/base/B8 delete mode 100644 tests/cr/base/B9 delete mode 100644 tests/de_mesh/gltf_read/boxinterleaved delete mode 100644 tests/de_mesh/gltf_read/cubeemb delete mode 100644 tests/de_mesh/shape_write_stl/B1 delete mode 100644 tests/de_mesh/step_read/B1 delete mode 100644 tests/de_mesh/step_write/B1 delete mode 100644 tests/de_mesh/step_write/B2 delete mode 100644 tests/de_mesh/step_write/C1 delete mode 100644 tests/de_mesh/step_write/C2 delete mode 100644 tests/de_mesh/stl_read/D1 delete mode 100644 tests/de_wrapper/brep/A1 delete mode 100644 tests/de_wrapper/brep/A2 delete mode 100644 tests/de_wrapper/brep/A3 delete mode 100644 tests/de_wrapper/brep/A4 delete mode 100644 tests/de_wrapper/configuration/A1 delete mode 100644 tests/de_wrapper/configuration/A2 delete mode 100644 tests/de_wrapper/configuration/A3 delete mode 100644 tests/de_wrapper/configuration/A4 delete mode 100644 tests/de_wrapper/configuration/A5 delete mode 100644 tests/de_wrapper/stl/A1 delete mode 100644 tests/de_wrapper/stl/A2 delete mode 100644 tests/de_wrapper/stl/A3 delete mode 100644 tests/de_wrapper/stl/A4 delete mode 100644 tests/de_wrapper/vrml/A1 delete mode 100644 tests/de_wrapper/vrml/A2 delete mode 100644 tests/de_wrapper/vrml/A3 delete mode 100644 tests/de_wrapper/vrml/A4 delete mode 100644 tests/demo/draw/binpersist_1 delete mode 100644 tests/gdt/dimensions/A1 delete mode 100644 tests/gdt/dimensions/A2 delete mode 100644 tests/gdt/dimensions/A3 delete mode 100644 tests/gdt/dimensions/A4 delete mode 100644 tests/gdt/dimensions/A5 delete mode 100644 tests/gdt/dimensions/A6 delete mode 100644 tests/gdt/dimensions/A7 delete mode 100644 tests/gdt/dimensions/A8 delete mode 100644 tests/gdt/dimensions/A9 delete mode 100644 tests/gdt/notes/A1 delete mode 100644 tests/gdt/notes/A2 delete mode 100644 tests/gdt/notes/A3 delete mode 100644 tests/gdt/notes/A4 delete mode 100644 tests/gdt/notes/A5 delete mode 100644 tests/gdt/notes/B1 delete mode 100644 tests/gdt/notes/B2 delete mode 100644 tests/gdt/notes/B3 delete mode 100644 tests/gdt/notes/B4 delete mode 100644 tests/gdt/notes/B5 delete mode 100644 tests/gdt/notes/B6 delete mode 100644 tests/gdt/notes/B7 delete mode 100644 tests/gdt/notes/C1 delete mode 100644 tests/gdt/notes/C2 delete mode 100644 tests/gdt/notes/C3 delete mode 100644 tests/gdt/notes/C4 delete mode 100644 tests/gdt/notes/C5 delete mode 100644 tests/gdt/notes/C6 delete mode 100644 tests/gdt/notes/C7 delete mode 100644 tests/gdt/notes/C8 delete mode 100644 tests/gdt/notes/C9 delete mode 100644 tests/gdt/notes/D1 delete mode 100644 tests/gdt/tolerances/A1 delete mode 100644 tests/gdt/tolerances/A2 delete mode 100644 tests/geometry/circ2d3Tan/CircleCircleCircle_11 delete mode 100644 tests/geometry/circ2d3Tan/CircleCirclePoint_11 delete mode 100644 tests/geometry/circ2d3Tan/CircleCirclePoint_12 delete mode 100644 tests/geometry/circ2d3Tan/CircleCirclePoint_14 delete mode 100644 tests/geometry/circ2d3Tan/CircleLinLin_11 delete mode 100644 tests/geometry/circ2d3Tan/CirclePointPoint_11 delete mode 100644 tests/geometry/circ2d3Tan/CirclePointPoint_12 delete mode 100644 tests/geometry/circ2d3Tan/CirclePointPoint_13 delete mode 100644 tests/geometry/circ2d3Tan/CirclePointPoint_14 delete mode 100644 tests/geometry/circ2d3Tan/CirclePointPoint_15 delete mode 100644 tests/geometry/circ2d3Tan/CirclePointPoint_21 delete mode 100644 tests/geometry/circ2d3Tan/CirclePointPoint_22 delete mode 100644 tests/geometry/circ2d3Tan/CirclePointPoint_24 delete mode 100644 tests/geometry/circ2d3Tan/CirclePointPoint_31 delete mode 100644 tests/geometry/circ2d3Tan/LinLinLin_11 delete mode 100644 tests/geometry/circ2d3Tan/LinLinPoint_11 delete mode 100644 tests/geometry/circ2d3Tan/LinPointPoint_11 delete mode 100644 tests/geometry/circ2d3Tan/PointPointPoint_11 delete mode 100644 tests/lowalgos/2dgcc/buc60607_1 delete mode 100644 tests/lowalgos/2dgcc/buc60607_2 delete mode 100644 tests/lowalgos/2dgcc/buc60607_3 delete mode 100644 tests/lowalgos/2dgcc/buc60607_4 delete mode 100644 tests/lowalgos/2dgcc/buc60618 delete mode 100644 tests/lowalgos/2dgcc/buc60622_1 delete mode 100644 tests/lowalgos/2dgcc/buc60622_2 delete mode 100644 tests/lowalgos/2dgcc/buc60622_3 delete mode 100644 tests/lowalgos/2dgcc/buc60941 delete mode 100644 tests/lowalgos/2dgcc/bug29694 delete mode 100644 tests/lowalgos/2dinter/bug23706_4 delete mode 100644 tests/lowalgos/2dinter/bug23706_5 delete mode 100644 tests/lowalgos/2dinter/bug29162 delete mode 100644 tests/lowalgos/bnd/bug30292 delete mode 100644 tests/lowalgos/bvh/bug30655_1 delete mode 100644 tests/lowalgos/bvh/bug30655_2 delete mode 100644 tests/lowalgos/bvh/bug30655_3 delete mode 100644 tests/lowalgos/bvh/bug30655_4 delete mode 100644 tests/lowalgos/extcc/bug29712_10 delete mode 100644 tests/lowalgos/extcc/bug29712_11 delete mode 100644 tests/lowalgos/extcc/bug29712_12 delete mode 100644 tests/lowalgos/extcc/bug29712_13 delete mode 100644 tests/lowalgos/extcc/bug29712_14 delete mode 100644 tests/lowalgos/extcc/bug29712_15 delete mode 100644 tests/lowalgos/extcc/bug29712_16 delete mode 100644 tests/lowalgos/extcc/bug29712_17 delete mode 100644 tests/lowalgos/extcc/bug29712_18 delete mode 100644 tests/lowalgos/extcc/bug29712_19 delete mode 100644 tests/lowalgos/extcc/bug29712_2 delete mode 100644 tests/lowalgos/extcc/bug29712_20 delete mode 100644 tests/lowalgos/extcc/bug29712_21 delete mode 100644 tests/lowalgos/extcc/bug29712_22 delete mode 100644 tests/lowalgos/extcc/bug29712_23 delete mode 100644 tests/lowalgos/extcc/bug29712_24 delete mode 100644 tests/lowalgos/extcc/bug29712_25 delete mode 100644 tests/lowalgos/extcc/bug29712_26 delete mode 100644 tests/lowalgos/extcc/bug29712_27 delete mode 100644 tests/lowalgos/extcc/bug29712_28 delete mode 100644 tests/lowalgos/extcc/bug29712_29 delete mode 100644 tests/lowalgos/extcc/bug29712_3 delete mode 100644 tests/lowalgos/extcc/bug29712_30 delete mode 100644 tests/lowalgos/extcc/bug29712_31 delete mode 100644 tests/lowalgos/extcc/bug29712_32 delete mode 100644 tests/lowalgos/extcc/bug29712_33 delete mode 100644 tests/lowalgos/extcc/bug29712_36 delete mode 100644 tests/lowalgos/extcc/bug29712_37 delete mode 100644 tests/lowalgos/extcc/bug29712_38 delete mode 100644 tests/lowalgos/extcc/bug29712_39 delete mode 100644 tests/lowalgos/extcc/bug29712_4 delete mode 100644 tests/lowalgos/extcc/bug29712_40 delete mode 100644 tests/lowalgos/extcc/bug29712_41 delete mode 100644 tests/lowalgos/extcc/bug29712_42 delete mode 100644 tests/lowalgos/extcc/bug29712_43 delete mode 100644 tests/lowalgos/extcc/bug29712_5 delete mode 100644 tests/lowalgos/extcc/bug29712_6 delete mode 100644 tests/lowalgos/extcc/bug29712_7 delete mode 100644 tests/lowalgos/extcc/bug29712_8 delete mode 100644 tests/lowalgos/extcc/bug29712_9 delete mode 100644 tests/lowalgos/extcs/bug29426_1 delete mode 100644 tests/lowalgos/extcs/bug29426_2 delete mode 100644 tests/lowalgos/extcs/circ_sph_inter delete mode 100644 tests/lowalgos/extcs/circ_sph_nointer delete mode 100644 tests/lowalgos/extcs/circ_sph_parallel delete mode 100644 tests/lowalgos/extcs/circ_sph_touch delete mode 100644 tests/lowalgos/extss/bug29712_44 delete mode 100644 tests/lowalgos/intcs/bug26979 delete mode 100644 tests/lowalgos/intss/bug23644 delete mode 100644 tests/lowalgos/intss/bug24313 delete mode 100644 tests/lowalgos/intss/bug24418_2 delete mode 100644 tests/lowalgos/intss/bug25782_2 delete mode 100644 tests/lowalgos/intss/bug32850 delete mode 100644 tests/lowalgos/intss/bug33244 delete mode 100644 tests/lowalgos/progress/A1 delete mode 100644 tests/lowalgos/progress/A2 delete mode 100644 tests/lowalgos/progress/A3 delete mode 100644 tests/lowalgos/progress/A4 delete mode 100644 tests/lowalgos/proximity/A1 delete mode 100644 tests/lowalgos/proximity/A2 delete mode 100644 tests/lowalgos/proximity/A3 delete mode 100644 tests/lowalgos/proximity/A4 delete mode 100644 tests/lowalgos/proximity/A5 delete mode 100644 tests/lowalgos/proximity/B1 delete mode 100644 tests/lowalgos/proximity/B2 delete mode 100644 tests/lowalgos/proximity/B3 delete mode 100644 tests/lowalgos/proximity/B4 delete mode 100644 tests/lowalgos/proximity/B5 delete mode 100644 tests/lowalgos/proximity/C1 delete mode 100644 tests/lowalgos/proximity/C2 delete mode 100644 tests/lowalgos/proximity/C3 delete mode 100644 tests/lowalgos/proximity/C4 delete mode 100644 tests/lowalgos/proximity/D1 delete mode 100644 tests/lowalgos/proximity/D2 delete mode 100644 tests/lowalgos/proximity/D3 delete mode 100644 tests/lowalgos/proximity/D4 delete mode 100644 tests/lowalgos/proximity/E1 delete mode 100644 tests/lowalgos/proximity/E2 delete mode 100644 tests/perf/de/bug29830_3 delete mode 100755 tests/pipe/bugs/bug24909_2 delete mode 100644 tests/v3d/colors/begin delete mode 100644 tests/v3d/colors/de2000 delete mode 100644 tests/v3d/colors/de2000_sharma delete mode 100644 tests/v3d/colors/rgb2lab delete mode 100644 tests/v3d/colors/rgb2lch delete mode 100644 tests/v3d/colors/stability delete mode 100644 tests/xml/data/ocaf/A1 delete mode 100644 tests/xml/data/ocaf/A2 delete mode 100644 tests/xml/data/ocaf/A3 delete mode 100644 tests/xml/data/ocaf/A4 delete mode 100644 tests/xml/data/ocaf/A5 delete mode 100644 tests/xml/data/ocaf/A6 delete mode 100644 tests/xml/data/ocaf/A7 delete mode 100644 tests/xml/data/ocaf/A8 delete mode 100644 tests/xml/data/ocaf/A9 delete mode 100644 tests/xml/data/ocaf/B1 delete mode 100644 tests/xml/data/ocaf/B2 delete mode 100644 tests/xml/data/ocaf/B3 delete mode 100644 tests/xml/data/ocaf/B4 delete mode 100644 tests/xml/data/ocaf/B5 delete mode 100644 tests/xml/data/ocaf/B7 delete mode 100644 tests/xml/data/ocaf/B8 delete mode 100644 tests/xml/data/ocaf/B9 delete mode 100644 tests/xml/data/ocaf/C1 delete mode 100644 tests/xml/data/ocaf/C2 delete mode 100644 tests/xml/data/ocaf/C3 delete mode 100644 tests/xml/data/ocaf/C4 delete mode 100644 tests/xml/data/ocaf/C5 delete mode 100644 tests/xml/data/ocaf/C6 delete mode 100644 tests/xml/data/ocaf/C7 delete mode 100644 tests/xml/data/ocaf/C8 delete mode 100644 tests/xml/data/ocaf/C9 delete mode 100644 tests/xml/data/ocaf/D1 delete mode 100644 tests/xml/data/ocaf/D2 delete mode 100644 tests/xml/data/ocaf/D3 delete mode 100644 tests/xml/data/ocaf/D4 delete mode 100644 tests/xml/data/ocaf/D5 delete mode 100644 tests/xml/data/ocaf/D6 delete mode 100644 tests/xml/data/xcaf/A1 delete mode 100644 tests/xml/data/xcaf/A4 delete mode 100644 tests/xml/data/xcaf/A5 delete mode 100644 tests/xml/data/xcaf/A6 delete mode 100644 tests/xml/data/xcaf/A7 delete mode 100644 tests/xml/data/xcaf/A8 delete mode 100644 tests/xml/data/xcaf/A9 diff --git a/src/ApplicationFramework/TKCAF/GTests/FILES.cmake b/src/ApplicationFramework/TKCAF/GTests/FILES.cmake index 98862c31c6..5c05ac6a42 100644 --- a/src/ApplicationFramework/TKCAF/GTests/FILES.cmake +++ b/src/ApplicationFramework/TKCAF/GTests/FILES.cmake @@ -2,6 +2,7 @@ set(OCCT_TKCAF_GTests_FILES_LOCATION "${CMAKE_CURRENT_LIST_DIR}") set(OCCT_TKCAF_GTests_FILES + TDataXtd_Attribute_Test.cxx TNaming_NamedShape_Test.cxx TNaming_Tool_Test.cxx ) diff --git a/src/ApplicationFramework/TKCAF/GTests/TDataXtd_Attribute_Test.cxx b/src/ApplicationFramework/TKCAF/GTests/TDataXtd_Attribute_Test.cxx new file mode 100644 index 0000000000..1d1215c943 --- /dev/null +++ b/src/ApplicationFramework/TKCAF/GTests/TDataXtd_Attribute_Test.cxx @@ -0,0 +1,184 @@ +// Copyright (c) 2026 OPEN CASCADE SAS +// +// This file is part of Open CASCADE Technology software library. +// +// This library is free software; you can redistribute it and/or modify it under +// the terms of the GNU Lesser General Public License version 2.1 as published +// by the Free Software Foundation, with special exception defined in the file +// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT +// distribution for complete text of the license and disclaimer of any warranty. +// +// Alternatively, this file may be used under the terms of Open CASCADE +// commercial license or contractual agreement. + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace +{ +static occ::handle NewDocument() +{ + occ::handle aDocument = new TDocStd_Document("BinOcaf"); + aDocument->SetUndoLimit(10); + return aDocument; +} + +static TDF_Label NewGeometryLabel(const occ::handle& theDocument) +{ + return theDocument->Main().FindChild(2, true); +} + +static void ExpectPoint(const gp_Pnt& theActual, const gp_Pnt& theExpected) +{ + EXPECT_TRUE(theActual.IsEqual(theExpected, 1.0e-12)); +} + +static void ExpectAxis(const gp_Ax1& theActual, const gp_Ax1& theExpected) +{ + EXPECT_TRUE(theActual.IsCoaxial(theExpected, 1.0e-12, 1.0e-12)); +} + +static void ExpectPlane(const gp_Pln& theActual, const gp_Pln& theExpected) +{ + double anActualA = 0.0; + double anActualB = 0.0; + double anActualC = 0.0; + double anActualD = 0.0; + double anExpectedA = 0.0; + double anExpectedB = 0.0; + double anExpectedC = 0.0; + double anExpectedD = 0.0; + theActual.Coefficients(anActualA, anActualB, anActualC, anActualD); + theExpected.Coefficients(anExpectedA, anExpectedB, anExpectedC, anExpectedD); + EXPECT_NEAR(anActualA, anExpectedA, 1.0e-12); + EXPECT_NEAR(anActualB, anExpectedB, 1.0e-12); + EXPECT_NEAR(anActualC, anExpectedC, 1.0e-12); + EXPECT_NEAR(anActualD, anExpectedD, 1.0e-12); +} +} // namespace + +// caf/basic/G1: point geometry is stored as a construction shape. +TEST(TDataXtd_Attribute_Test, CafBasic_G1_PointSetGet) +{ + occ::handle aDoc = NewDocument(); + const TDF_Label aLabel = NewGeometryLabel(aDoc); + const gp_Pnt anExpected(10.0, 20.0, 30.0); + ASSERT_FALSE(TDataXtd_Point::Set(aLabel, anExpected).IsNull()); + + gp_Pnt anActual; + ASSERT_TRUE(TDataXtd_Geometry::Point(aLabel, anActual)); + ExpectPoint(anActual, anExpected); +} + +// caf/basic/G2: setting a new point replaces the construction geometry. +TEST(TDataXtd_Attribute_Test, CafBasic_G2_PointUndo) +{ + occ::handle aDoc = NewDocument(); + const TDF_Label aLabel = NewGeometryLabel(aDoc); + const gp_Pnt anExpected(10.0, 20.0, 30.0); + const gp_Pnt aReplacement(-10.0, -20.0, -30.0); + TDataXtd_Point::Set(aLabel, anExpected); + aDoc->NewCommand(); + TDataXtd_Point::Set(aLabel, aReplacement); + aDoc->NewCommand(); + aDoc->Undo(); + + gp_Pnt anActual; + ASSERT_TRUE(TDataXtd_Geometry::Point(aLabel, anActual)); + ExpectPoint(anActual, anExpected); +} + +// caf/basic/H1: axis construction geometry is retrievable from its label. +TEST(TDataXtd_Attribute_Test, CafBasic_H1_AxisSetGet) +{ + occ::handle aDoc = NewDocument(); + const TDF_Label aLabel = NewGeometryLabel(aDoc); + const gp_Lin anExpected(gp_Pnt(10.0, 20.0, 30.0), gp_Dir(100.0, 200.0, 300.0)); + ASSERT_FALSE(TDataXtd_Axis::Set(aLabel, anExpected).IsNull()); + + gp_Ax1 anActual; + ASSERT_TRUE(TDataXtd_Geometry::Axis(aLabel, anActual)); + ExpectAxis(anActual, anExpected.Position()); +} + +TEST(TDataXtd_Attribute_Test, CafBasic_H2_AxisUndo) +{ + occ::handle aDoc = NewDocument(); + const TDF_Label aLabel = NewGeometryLabel(aDoc); + const gp_Lin anExpected(gp_Pnt(10.0, 20.0, 30.0), gp_Dir(100.0, 200.0, 300.0)); + const gp_Lin aReplacement(gp_Pnt(-10.0, -20.0, -30.0), gp_Dir(-100.0, 200.0, 300.0)); + TDataXtd_Axis::Set(aLabel, anExpected); + aDoc->NewCommand(); + TDataXtd_Axis::Set(aLabel, aReplacement); + aDoc->NewCommand(); + aDoc->Undo(); + + gp_Ax1 anActual; + ASSERT_TRUE(TDataXtd_Geometry::Axis(aLabel, anActual)); + ExpectAxis(anActual, anExpected.Position()); +} + +// caf/basic/I1-I2: plane construction geometry is retrievable and undoable. +TEST(TDataXtd_Attribute_Test, CafBasic_I1_PlaneSetGet) +{ + occ::handle aDoc = NewDocument(); + const TDF_Label aLabel = NewGeometryLabel(aDoc); + const gp_Pln anExpected(gp_Pnt(10.0, 20.0, 30.0), gp_Dir(-1.0, 0.0, 0.0)); + ASSERT_FALSE(TDataXtd_Plane::Set(aLabel, anExpected).IsNull()); + + gp_Pln anActual; + ASSERT_TRUE(TDataXtd_Geometry::Plane(aLabel, anActual)); + ExpectPlane(anActual, anExpected); +} + +TEST(TDataXtd_Attribute_Test, CafBasic_I2_PlaneUndo) +{ + occ::handle aDoc = NewDocument(); + const TDF_Label aLabel = NewGeometryLabel(aDoc); + const gp_Pln anExpected(gp_Pnt(10.0, 20.0, 30.0), gp_Dir(-1.0, 0.0, 0.0)); + const gp_Pln aReplacement(gp_Pnt(-10.0, -20.0, -30.0), gp_Dir(0.0, -1.0, 0.0)); + TDataXtd_Plane::Set(aLabel, anExpected); + aDoc->NewCommand(); + TDataXtd_Plane::Set(aLabel, aReplacement); + aDoc->NewCommand(); + aDoc->Undo(); + + gp_Pln anActual; + ASSERT_TRUE(TDataXtd_Geometry::Plane(aLabel, anActual)); + ExpectPlane(anActual, anExpected); +} + +// caf/named_shape/B1: NewShape stores and restores an associated shape. +TEST(TDataXtd_Attribute_Test, CafNamedShape_B1_NewShapeUndoRedo) +{ + occ::handle aDoc = NewDocument(); + TDF_Label aLabel = NewGeometryLabel(aDoc); + const TopoDS_Shape aBox = BRepPrimAPI_MakeBox(100.0, 200.0, 300.0).Shape(); + + aDoc->NewCommand(); + ASSERT_FALSE(TDataXtd_Shape::Set(aLabel, aBox).IsNull()); + aDoc->NewCommand(); + aDoc->Undo(); + occ::handle anAttribute; + aLabel = aDoc->Main().FindChild(2, false); + EXPECT_FALSE(TDataXtd_Shape::Find(aLabel, anAttribute)); + + aDoc->Redo(); + aLabel = aDoc->Main().FindChild(2, false); + ASSERT_TRUE(TDataXtd_Shape::Find(aLabel, anAttribute)); + EXPECT_TRUE(TDataXtd_Shape::Get(aLabel).IsSame(aBox)); + aDoc->ClearUndos(); + aDoc->ClearRedos(); +} diff --git a/src/ApplicationFramework/TKCAF/GTests/TNaming_NamedShape_Test.cxx b/src/ApplicationFramework/TKCAF/GTests/TNaming_NamedShape_Test.cxx index e109a79a15..cee86ff08c 100644 --- a/src/ApplicationFramework/TKCAF/GTests/TNaming_NamedShape_Test.cxx +++ b/src/ApplicationFramework/TKCAF/GTests/TNaming_NamedShape_Test.cxx @@ -12,6 +12,9 @@ // commercial license or contractual agreement. #include +#include +#include +#include #include #include #include @@ -21,7 +24,13 @@ #include #include #include +#include +#include +#include +#include +#include #include +#include #include @@ -46,6 +55,295 @@ protected: TDF_Label myLabel; }; +namespace +{ +static TopoDS_Shape ShapeAt(const TopoDS_Shape& theShape, + const TopAbs_ShapeEnum theType, + const int theIndex) +{ + NCollection_Map aSeenShapes; + aSeenShapes.Add(theShape); + int anIndex = 0; + for (TopExp_Explorer anExplorer(theShape, theType); anExplorer.More(); anExplorer.Next()) + { + if (!aSeenShapes.Add(anExplorer.Current())) + { + continue; + } + if (++anIndex == theIndex) + { + return anExplorer.Current(); + } + } + return TopoDS_Shape(); +} + +static void BuildPrimitive(const TDF_Label& theLabel, + const TopoDS_Shape* theShapes, + const int theNbShapes) +{ + TNaming_Builder aBuilder(theLabel); + for (int anIndex = 0; anIndex < theNbShapes; ++anIndex) + { + aBuilder.Generated(theShapes[anIndex]); + } +} + +static void BuildGenerated(const TDF_Label& theLabel, + const TopoDS_Shape* theOldShapes, + const TopoDS_Shape* theNewShapes, + const int theNbShapes) +{ + TNaming_Builder aBuilder(theLabel); + for (int anIndex = 0; anIndex < theNbShapes; ++anIndex) + { + aBuilder.Generated(theOldShapes[anIndex], theNewShapes[anIndex]); + } +} + +static void BuildModified(const TDF_Label& theLabel, + const TopoDS_Shape* theOldShapes, + const TopoDS_Shape* theNewShapes, + const int theNbShapes) +{ + TNaming_Builder aBuilder(theLabel); + for (int anIndex = 0; anIndex < theNbShapes; ++anIndex) + { + aBuilder.Modify(theOldShapes[anIndex], theNewShapes[anIndex]); + } +} + +static void BuildDeleted(const TDF_Label& theLabel, + const TopoDS_Shape* theOldShapes, + const int theNbShapes) +{ + TNaming_Builder aBuilder(theLabel); + for (int anIndex = 0; anIndex < theNbShapes; ++anIndex) + { + aBuilder.Delete(theOldShapes[anIndex]); + } +} + +static void BuildSelected(const TDF_Label& theLabel, + const TopoDS_Shape* theShapes, + const int theNbShapes) +{ + TNaming_Builder aBuilder(theLabel); + for (int anIndex = 0; anIndex < theNbShapes; ++anIndex) + { + aBuilder.Select(theShapes[anIndex], theShapes[anIndex]); + } +} + +static int CountNewShapes(const TDF_Label& theLabel) +{ + occ::handle aNamedShape; + if (!theLabel.FindAttribute(TNaming_NamedShape::GetID(), aNamedShape)) + { + return 0; + } + + int aCount = 0; + for (TNaming_Iterator anIterator(aNamedShape); anIterator.More(); anIterator.Next()) + { + if (!anIterator.NewShape().IsNull()) + { + ++aCount; + } + } + return aCount; +} + +static int CountOldShapes(const TDF_Label& theLabel) +{ + occ::handle aNamedShape; + if (!theLabel.FindAttribute(TNaming_NamedShape::GetID(), aNamedShape)) + { + return 0; + } + + int aCount = 0; + for (TNaming_Iterator anIterator(aNamedShape); anIterator.More(); anIterator.Next()) + { + if (!anIterator.OldShape().IsNull()) + { + ++aCount; + } + } + return aCount; +} + +static int CountAllNewShapes(const TopoDS_Shape& theShape, const TDF_Label& theAccess) +{ + int aCount = 0; + for (TNaming_NewShapeIterator anIterator(theShape, theAccess); anIterator.More(); + anIterator.Next()) + { + if (!anIterator.Shape().IsNull()) + { + ++aCount; + aCount += CountAllNewShapes(anIterator.Shape(), theAccess); + } + } + return aCount; +} + +static int CountAllOldShapes(const TopoDS_Shape& theShape, const TDF_Label& theAccess) +{ + occ::handle aNamedShape = TNaming_Tool::NamedShape(theShape, theAccess); + if (aNamedShape.IsNull()) + { + return 0; + } + + int aCount = 0; + for (TNaming_Iterator anIterator(aNamedShape); anIterator.More(); anIterator.Next()) + { + if (!anIterator.OldShape().IsNull() && !anIterator.NewShape().IsNull() + && anIterator.NewShape().IsSame(theShape)) + { + ++aCount; + aCount += CountAllOldShapes(anIterator.OldShape(), theAccess); + } + } + return aCount; +} + +static int CountAllNewShapesAtLabel(const TDF_Label& theLabel, const TDF_Label& theAccess) +{ + occ::handle aNamedShape; + if (!theLabel.FindAttribute(TNaming_NamedShape::GetID(), aNamedShape)) + { + return 0; + } + + int aCount = 0; + for (TNaming_Iterator anIterator(aNamedShape); anIterator.More(); anIterator.Next()) + { + if (!anIterator.NewShape().IsNull()) + { + aCount += CountAllNewShapes(anIterator.NewShape(), theAccess); + } + } + return aCount; +} + +static int CountAllOldShapesAtLabel(const TDF_Label& theLabel, const TDF_Label& theAccess) +{ + occ::handle aNamedShape; + if (!theLabel.FindAttribute(TNaming_NamedShape::GetID(), aNamedShape)) + { + return 0; + } + + int aCount = 0; + for (TNaming_Iterator anIterator(aNamedShape); anIterator.More(); anIterator.Next()) + { + if (!anIterator.NewShape().IsNull()) + { + aCount += CountAllOldShapes(anIterator.NewShape(), theAccess); + } + } + return aCount; +} + +static void CollectAllNewShapes(const TopoDS_Shape& theShape, + const TDF_Label& theAccess, + NCollection_List& theShapes) +{ + for (TNaming_NewShapeIterator anIterator(theShape, theAccess); anIterator.More(); + anIterator.Next()) + { + if (!anIterator.Shape().IsNull()) + { + theShapes.Append(anIterator.Shape()); + CollectAllNewShapes(anIterator.Shape(), theAccess, theShapes); + } + } +} + +static void CollectAllOldShapes(const TopoDS_Shape& theShape, + const TDF_Label& theAccess, + NCollection_List& theShapes) +{ + occ::handle aNamedShape = TNaming_Tool::NamedShape(theShape, theAccess); + if (aNamedShape.IsNull()) + { + return; + } + + for (TNaming_Iterator anIterator(aNamedShape); anIterator.More(); anIterator.Next()) + { + if (!anIterator.OldShape().IsNull() && !anIterator.NewShape().IsNull() + && anIterator.NewShape().IsSame(theShape)) + { + theShapes.Append(anIterator.OldShape()); + CollectAllOldShapes(anIterator.OldShape(), theAccess, theShapes); + } + } +} + +static void CollectAllNewShapesAtLabel(const TDF_Label& theLabel, + const TDF_Label& theAccess, + NCollection_List& theShapes) +{ + occ::handle aNamedShape; + if (!theLabel.FindAttribute(TNaming_NamedShape::GetID(), aNamedShape)) + { + return; + } + + for (TNaming_Iterator anIterator(aNamedShape); anIterator.More(); anIterator.Next()) + { + if (!anIterator.NewShape().IsNull()) + { + CollectAllNewShapes(anIterator.NewShape(), theAccess, theShapes); + } + } +} + +static void CollectAllOldShapesAtLabel(const TDF_Label& theLabel, + const TDF_Label& theAccess, + NCollection_List& theShapes) +{ + occ::handle aNamedShape; + if (!theLabel.FindAttribute(TNaming_NamedShape::GetID(), aNamedShape)) + { + return; + } + + for (TNaming_Iterator anIterator(aNamedShape); anIterator.More(); anIterator.Next()) + { + if (!anIterator.NewShape().IsNull()) + { + CollectAllOldShapes(anIterator.NewShape(), theAccess, theShapes); + } + } +} + +static int CountSameShapes(const TopoDS_Shape& theShape, const TDF_Label& theAccess) +{ + int aCount = 0; + for (TNaming_SameShapeIterator anIterator(theShape, theAccess); anIterator.More(); + anIterator.Next()) + { + if (!anIterator.Label().IsNull()) + { + ++aCount; + } + } + return aCount; +} + +static int CountSameShapesInDrawResult(const TopoDS_Shape& theShape, const TDF_Label& theAccess) +{ + const int aCount = CountSameShapes(theShape, theAccess); + // GetSameShapes concatenates its first two labels without a separator; Tcl's + // llength consequently reports one fewer item whenever two or more labels exist. + return aCount > 1 ? aCount - 1 : aCount; +} +} // namespace + // ===================== TNaming_Builder tests ===================== TEST_F(TNaming_NamedShapeTest, Generated_Primitive) @@ -406,3 +704,273 @@ TEST_F(TNaming_NamedShapeTest, UndoRedo_RestoresNamedShape) EXPECT_FALSE(aNSAfterRedo->IsEmpty()); EXPECT_TRUE(aNSAfterRedo->Get().IsSame(aBox)); } + +// caf/named_shape/A1: SetShape is restored by redo after an undo. +TEST(TNaming_NamedShape_Test, CafNamedShape_A1_SetShapeUndoRedo) +{ + occ::handle aDoc = new TDocStd_Document("BinOcaf"); + aDoc->SetUndoLimit(10); + TDF_Label aLabel = aDoc->Main().FindChild(2, true); + const TopoDS_Shape aBox = BRepPrimAPI_MakeBox(100.0, 200.0, 300.0).Shape(); + + aDoc->NewCommand(); + TNaming_Builder aBuilder(aLabel); + aBuilder.Generated(aBox); + aDoc->NewCommand(); + aDoc->Undo(); + + TDF_Label aAfterUndo = aDoc->Main().FindChild(2, false); + if (!aAfterUndo.IsNull()) + { + occ::handle aShapeAfterUndo; + EXPECT_FALSE(aAfterUndo.FindAttribute(TNaming_NamedShape::GetID(), aShapeAfterUndo)); + } + + aDoc->Redo(); + aLabel = aDoc->Main().FindChild(2, true); + ASSERT_FALSE(aLabel.IsNull()); + occ::handle aNamedShape; + ASSERT_TRUE(aLabel.FindAttribute(TNaming_NamedShape::GetID(), aNamedShape)); + EXPECT_TRUE(aNamedShape->Get().IsSame(aBox)); + aDoc->ClearUndos(); + aDoc->ClearRedos(); +} + +// caf/nam/A2: the complete TNaming iterator graph preserves direct, recursive, +// and same-shape relationships from the DRAW case. +TEST(TNaming_NamedShape_Test, CafNamedShape_A2_IteratorGraph) +{ + occ::handle aDocument = new TDocStd_Document("BinOcaf"); + const TDF_Label aTestLabel = aDocument->Main().FindChild(1, true); + const TDF_Label anAccessLabel = aDocument->GetData()->Root(); + + const TopoDS_Shape aBox = BRepPrimAPI_MakeBox(100.0, 200.0, 300.0).Shape(); + const TopoDS_Shape aBox2 = BRepPrimAPI_MakeBox(200.0, 300.0, 400.0).Shape(); + const TopoDS_Shape aBox3 = BRepPrimAPI_MakeBox(300.0, 400.0, 500.0).Shape(); + const TopoDS_Shape aBox4 = + BRepPrimAPI_MakeBox(gp_Pnt(100.0, 100.0, 100.0), gp_Pnt(300.0, 400.0, 500.0)).Shape(); + + TopoDS_Shape anEdges[12]; + TopoDS_Shape aBox2Faces[6]; + TopoDS_Shape aBox3Faces[6]; + TopoDS_Shape aBox4Faces[6]; + for (int anIndex = 1; anIndex <= 12; ++anIndex) + { + anEdges[anIndex - 1] = ShapeAt(aBox, TopAbs_EDGE, anIndex); + ASSERT_FALSE(anEdges[anIndex - 1].IsNull()); + } + for (int anIndex = 1; anIndex <= 6; ++anIndex) + { + aBox2Faces[anIndex - 1] = ShapeAt(aBox2, TopAbs_FACE, anIndex); + aBox3Faces[anIndex - 1] = ShapeAt(aBox3, TopAbs_FACE, anIndex); + aBox4Faces[anIndex - 1] = ShapeAt(aBox4, TopAbs_FACE, anIndex); + ASSERT_FALSE(aBox2Faces[anIndex - 1].IsNull()); + ASSERT_FALSE(aBox3Faces[anIndex - 1].IsNull()); + ASSERT_FALSE(aBox4Faces[anIndex - 1].IsNull()); + } + + const TDF_Label aLabel1 = aTestLabel.FindChild(1, true); + const TDF_Label aLabel11 = aLabel1.FindChild(1, true); + const TDF_Label aLabel12 = aLabel1.FindChild(2, true); + const TDF_Label aLabel2 = aTestLabel.FindChild(2, true); + const TDF_Label aLabel21 = aLabel2.FindChild(1, true); + const TDF_Label aLabel22 = aLabel2.FindChild(2, true); + const TDF_Label aLabel3 = aTestLabel.FindChild(3, true); + const TDF_Label aLabel31 = aLabel3.FindChild(1, true); + const TDF_Label aLabel32 = aLabel3.FindChild(2, true); + const TDF_Label aLabel41 = aTestLabel.FindChild(4, true).FindChild(1, true); + const TDF_Label aLabel5 = aTestLabel.FindChild(5, true); + const TDF_Label aLabel51 = aLabel5.FindChild(1, true); + const TDF_Label aLabel6 = aTestLabel.FindChild(6, true); + const TDF_Label aLabel61 = aLabel6.FindChild(1, true); + + BuildPrimitive(aLabel1, &aBox, 1); + BuildPrimitive(aLabel11, anEdges, 1); + BuildPrimitive(aLabel11, anEdges, 3); + BuildPrimitive(aLabel12, anEdges + 3, 3); + + const TopoDS_Shape aGenerated2Old[] = {aBox}; + const TopoDS_Shape aGenerated2New[] = {aBox2}; + BuildGenerated(aLabel2, aGenerated2Old, aGenerated2New, 1); + + const TopoDS_Shape aGenerated21FirstOld[] = {anEdges[0]}; + const TopoDS_Shape aGenerated21FirstNew[] = {aBox2Faces[0]}; + BuildGenerated(aLabel21, aGenerated21FirstOld, aGenerated21FirstNew, 1); + + const TopoDS_Shape aGenerated22Old[] = {anEdges[1], anEdges[1], anEdges[2]}; + const TopoDS_Shape aGenerated22New[] = {aBox2Faces[1], aBox2Faces[2], aBox2Faces[3]}; + BuildGenerated(aLabel22, aGenerated22Old, aGenerated22New, 3); + + const TopoDS_Shape aGenerated21Old[] = {anEdges[2], anEdges[2], anEdges[3]}; + const TopoDS_Shape aGenerated21New[] = {aBox2Faces[0], aBox2Faces[2], aBox2Faces[3]}; + BuildGenerated(aLabel21, aGenerated21Old, aGenerated21New, 3); + + const TopoDS_Shape aModified3Old[] = {aBox2}; + const TopoDS_Shape aModified3New[] = {aBox3}; + BuildModified(aLabel3, aModified3Old, aModified3New, 1); + + const TopoDS_Shape aModified31FirstOld[] = {aBox2Faces[0]}; + const TopoDS_Shape aModified31FirstNew[] = {aBox3Faces[0]}; + BuildModified(aLabel31, aModified31FirstOld, aModified31FirstNew, 1); + + const TopoDS_Shape aModified32Old[] = {aBox2Faces[4], aBox2Faces[1], aBox2Faces[2]}; + const TopoDS_Shape aModified32New[] = {aBox3Faces[1], aBox3Faces[2], aBox3Faces[3]}; + BuildModified(aLabel32, aModified32Old, aModified32New, 3); + + const TopoDS_Shape aModified31Old[] = {aBox2Faces[2], anEdges[2], aBox2Faces[3]}; + const TopoDS_Shape aModified31New[] = {aBox3Faces[0], aBox3Faces[2], aBox3Faces[3]}; + BuildModified(aLabel31, aModified31Old, aModified31New, 3); + + const TopoDS_Shape aDeleted41FirstOld[] = {aBox3Faces[0]}; + BuildDeleted(aLabel41, aDeleted41FirstOld, 1); + const TopoDS_Shape aDeleted41Old[] = {aBox3Faces[0], aBox3Faces[3]}; + BuildDeleted(aLabel41, aDeleted41Old, 2); + + const TopoDS_Shape aModified5Old[] = {aBox3}; + const TopoDS_Shape aModified5New[] = {aBox4}; + BuildModified(aLabel5, aModified5Old, aModified5New, 1); + + const TopoDS_Shape aModified51Old[] = {aBox3Faces[1], aBox3Faces[2]}; + const TopoDS_Shape aModified51New[] = {aBox4Faces[1], aBox4Faces[2]}; + BuildModified(aLabel51, aModified51Old, aModified51New, 2); + + const TopoDS_Shape aSelected6[] = {aBox4}; + BuildSelected(aLabel6, aSelected6, 1); + const TopoDS_Shape aSelected61[] = {aBox4Faces[1], aBox2Faces[4]}; + BuildSelected(aLabel61, aSelected61, 2); + + NCollection_Array1 aLabels(1, 14); + aLabels.SetValue(1, aLabel1); + aLabels.SetValue(2, aLabel11); + aLabels.SetValue(3, aLabel12); + aLabels.SetValue(4, aLabel2); + aLabels.SetValue(5, aLabel21); + aLabels.SetValue(6, aLabel22); + aLabels.SetValue(7, aLabel3); + aLabels.SetValue(8, aLabel31); + aLabels.SetValue(9, aLabel32); + aLabels.SetValue(10, aLabel41); + aLabels.SetValue(11, aLabel5); + aLabels.SetValue(12, aLabel51); + aLabels.SetValue(13, aLabel6); + aLabels.SetValue(14, aLabel61); + + const TNaming_Evolution anExpectedEvolution[] = {TNaming_PRIMITIVE, + TNaming_PRIMITIVE, + TNaming_PRIMITIVE, + TNaming_GENERATED, + TNaming_GENERATED, + TNaming_GENERATED, + TNaming_MODIFY, + TNaming_MODIFY, + TNaming_MODIFY, + TNaming_DELETE, + TNaming_MODIFY, + TNaming_MODIFY, + TNaming_SELECTED, + TNaming_SELECTED}; + const int anExpectedNew[] = {1, 3, 3, 1, 3, 3, 1, 3, 3, 0, 1, 2, 1, 2}; + const int anExpectedOld[] = {0, 0, 0, 1, 3, 3, 1, 3, 3, 2, 1, 2, 1, 2}; + const int anExpectedAllNew[] = {3, 14, 2, 2, 3, 5, 1, 1, 2, 0, 0, 0, 0, 2}; + const int anExpectedAllOld[] = {0, 0, 0, 1, 3, 3, 2, 6, 5, 0, 3, 5, 3, 2}; + for (int anIndex = 1; anIndex <= aLabels.Upper(); ++anIndex) + { + occ::handle aNamedShape; + ASSERT_TRUE(aLabels.Value(anIndex).FindAttribute(TNaming_NamedShape::GetID(), aNamedShape)); + EXPECT_EQ(aNamedShape->Evolution(), anExpectedEvolution[anIndex - 1]); + EXPECT_EQ(CountNewShapes(aLabels.Value(anIndex)), anExpectedNew[anIndex - 1]); + EXPECT_EQ(CountOldShapes(aLabels.Value(anIndex)), anExpectedOld[anIndex - 1]); + EXPECT_EQ(CountAllNewShapesAtLabel(aLabels.Value(anIndex), anAccessLabel), + anExpectedAllNew[anIndex - 1]); + EXPECT_EQ(CountAllOldShapesAtLabel(aLabels.Value(anIndex), anAccessLabel), + anExpectedAllOld[anIndex - 1]); + } + + NCollection_List anIteratorShapes; + CollectAllNewShapesAtLabel(aLabel11, anAccessLabel, anIteratorShapes); + NCollection_List anOldIteratorShapes; + CollectAllOldShapesAtLabel(aLabel31, anAccessLabel, anOldIteratorShapes); + EXPECT_EQ(anIteratorShapes.Extent(), 14); + EXPECT_EQ(anOldIteratorShapes.Extent(), 6); + NCollection_Array1 aCollectedOldShapes(1, 6); + int anOldIndex = 1; + for (NCollection_List::Iterator anIterator(anOldIteratorShapes); anIterator.More(); + anIterator.Next()) + { + aCollectedOldShapes.SetValue(anOldIndex++, anIterator.Value()); + } + const int anOldShapeOrder[] = {5, 6, 1, 2, 3, 4}; + NCollection_Array1 anOrderedOldShapes(1, 6); + for (int anIndex = 1; anIndex <= 6; ++anIndex) + { + anOrderedOldShapes.SetValue(anIndex, aCollectedOldShapes.Value(anOldShapeOrder[anIndex - 1])); + } + NCollection_Array1 aShapes(1, 21); + aShapes.SetValue(1, aBox); + int anShapeIndex = 2; + for (NCollection_List::Iterator anIterator(anIteratorShapes); anIterator.More(); + anIterator.Next()) + { + ASSERT_LE(anShapeIndex, 15); + aShapes.SetValue(anShapeIndex++, anIterator.Value()); + } + for (NCollection_Array1::Iterator anIterator(anOrderedOldShapes); anIterator.More(); + anIterator.Next()) + { + ASSERT_LE(anShapeIndex, 21); + aShapes.SetValue(anShapeIndex++, anIterator.Value()); + } + ASSERT_EQ(anShapeIndex, 22); + + const int anExpectedSame[] = {1, 2, 2, 1, 3, 2, 1, 2, 1, 1, 2, 1, 3, 2, 1, 3, 4, 3, 4, 1, 2}; + const int anExpectedSameLabels[] = {2, 3, 3, 1, 4, 3, 2, 3, 1, 2, 3, + 1, 4, 3, 2, 4, 5, 4, 5, 2, 3}; + for (int anIndex = 1; anIndex <= aShapes.Upper(); ++anIndex) + { + EXPECT_EQ(CountSameShapes(aShapes.Value(anIndex), anAccessLabel), + anExpectedSameLabels[anIndex - 1]); + EXPECT_EQ(CountSameShapesInDrawResult(aShapes.Value(anIndex), anAccessLabel), + anExpectedSame[anIndex - 1]); + } + + const int anExpectedSamePairs[][2] = {{20, 10}, + {19, 17}, + {18, 16}, + {18, 13}, + {18, 5}, + {16, 13}, + {16, 5}, + {15, 7}, + {14, 6}, + {14, 3}, + {13, 5}, + {12, 9}, + {11, 8}, + {6, 3}}; + for (const int (&aPair)[2] : anExpectedSamePairs) + { + EXPECT_TRUE(aShapes.Value(aPair[0]).IsSame(aShapes.Value(aPair[1]))); + } + for (int anFirst = 1; anFirst <= aShapes.Upper(); ++anFirst) + { + for (int anSecond = 1; anSecond < anFirst; ++anSecond) + { + if (!aShapes.Value(anFirst).IsSame(aShapes.Value(anSecond))) + { + continue; + } + + bool isExpectedPair = false; + for (const int (&aPair)[2] : anExpectedSamePairs) + { + if ((aPair[0] == anFirst && aPair[1] == anSecond) + || (aPair[0] == anSecond && aPair[1] == anFirst)) + { + isExpectedPair = true; + break; + } + } + EXPECT_TRUE(isExpectedPair); + } + } +} diff --git a/src/ApplicationFramework/TKCAF/GTests/TNaming_Tool_Test.cxx b/src/ApplicationFramework/TKCAF/GTests/TNaming_Tool_Test.cxx index 3de148b0f6..a30f22a102 100644 --- a/src/ApplicationFramework/TKCAF/GTests/TNaming_Tool_Test.cxx +++ b/src/ApplicationFramework/TKCAF/GTests/TNaming_Tool_Test.cxx @@ -13,14 +13,67 @@ #include +#include +#include +#include +#include +#include +#include +#include #include +#include #include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include +#include +#include #include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include +#include +#include #include +#include +#include +#include #include +#include +#include +#include +#include +#include #include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include @@ -50,6 +103,470 @@ protected: TDF_Label myRoot; }; +namespace +{ +static TopoDS_Shape FirstSubShape(const TopoDS_Shape& theShape, const TopAbs_ShapeEnum theType) +{ + TopExp_Explorer anExplorer(theShape, theType); + return anExplorer.More() ? anExplorer.Current() : TopoDS_Shape(); +} + +static occ::handle NewNamingDocument() +{ + return new TDocStd_Document("BinOcaf"); +} + +static occ::handle AddNamingObject( + const occ::handle& theDocument) +{ + occ::handle aRootNode = TDataStd_TreeNode::Set(theDocument->Main()); + const TDF_Label aLabel = TDF_TagSource::NewChild(theDocument->Main()); + occ::handle anObject = TDataStd_UAttribute::Set(aLabel, GEOMOBJECT_GUID); + occ::handle aNode = TDataStd_TreeNode::Set(aLabel); + aRootNode->Append(aNode); + return anObject; +} + +static occ::handle AddNamingFunction( + const occ::handle& theObject, + const Standard_GUID& theDriverGuid) +{ + const TDF_Label aFunctionLabel = TDF_TagSource::NewChild(theObject->Label()); + occ::handle aFunction = + TFunction_Function::Set(aFunctionLabel, theDriverGuid); + occ::handle aFunctionNode = TDataStd_TreeNode::Set(aFunctionLabel); + occ::handle anObjectNode; + theObject->Label().FindAttribute(TDataStd_TreeNode::GetDefaultTreeID(), anObjectNode); + anObjectNode->Append(aFunctionNode); + + const TDF_Label anArgumentsLabel = TDF_TagSource::NewChild(aFunctionLabel); + occ::handle anArgumentsNode = TDataStd_TreeNode::Set(anArgumentsLabel); + aFunctionNode->Append(anArgumentsNode); + + const TDF_Label aResultLabel = TDF_TagSource::NewChild(aFunctionLabel); + occ::handle aResultNode = TDataStd_TreeNode::Set(aResultLabel); + aFunctionNode->Append(aResultNode); + TDF_Reference::Set(theObject->Label(), aResultLabel); + return aFunction; +} + +static int ExecuteNamingFunction(const occ::handle& theFunction, + const occ::handle& theDriver) +{ + occ::handle aLogbook = TFunction_Logbook::Set(theFunction->Label()); + aLogbook->Clear(); + theDriver->Init(theFunction->Label()); + return theDriver->Execute(aLogbook); +} + +static TopoDS_Shape NamingFunctionShape(const occ::handle& theFunction) +{ + const occ::handle aNamedShape = DNaming::GetFunctionResult(theFunction); + return aNamedShape.IsNull() ? TopoDS_Shape() : TNaming_Tool::GetShape(aNamedShape); +} + +static void RegisterNamingDrivers() +{ + occ::handle aTable = TFunction_DriverTable::Get(); + aTable->AddDriver(BOX_GUID, new DNaming_BoxDriver()); + aTable->AddDriver(SPH_GUID, new DNaming_SphereDriver()); + aTable->AddDriver(CUT_GUID, new DNaming_BooleanOperationDriver()); + aTable->AddDriver(FUSE_GUID, new DNaming_BooleanOperationDriver()); + aTable->AddDriver(PTXYZ_GUID, new DNaming_TransformationDriver()); + aTable->AddDriver(PTALINE_GUID, new DNaming_TransformationDriver()); + aTable->AddDriver(PRRLINE_GUID, new DNaming_TransformationDriver()); + aTable->AddDriver(PMIRR_GUID, new DNaming_TransformationDriver()); + aTable->AddDriver(FILLT_GUID, new DNaming_FilletDriver()); +} + +static occ::handle MakeNamingBox( + const occ::handle& theObject, + const double theDX, + const double theDY, + const double theDZ) +{ + occ::handle aFunction = AddNamingFunction(theObject, BOX_GUID); + DNaming::GetReal(aFunction, BOX_DX)->Set(theDX); + DNaming::GetReal(aFunction, BOX_DY)->Set(theDY); + DNaming::GetReal(aFunction, BOX_DZ)->Set(theDZ); + EXPECT_EQ(ExecuteNamingFunction(aFunction, new DNaming_BoxDriver()), 0); + return aFunction; +} + +static occ::handle MakeNamingTranslation( + const occ::handle& theObject, + const double theDX, + const double theDY, + const double theDZ) +{ + occ::handle aFunction = AddNamingFunction(theObject, PTXYZ_GUID); + DNaming::GetReal(aFunction, PTRANSF_DX)->Set(theDX); + DNaming::GetReal(aFunction, PTRANSF_DY)->Set(theDY); + DNaming::GetReal(aFunction, PTRANSF_DZ)->Set(theDZ); + EXPECT_EQ(ExecuteNamingFunction(aFunction, new DNaming_TransformationDriver()), 0); + return aFunction; +} + +static occ::handle MakeNamingAlongLine( + const occ::handle& theObject, + const occ::handle& theLine, + const double theOffset) +{ + occ::handle aFunction = AddNamingFunction(theObject, PTALINE_GUID); + DNaming::SetObjectArg(aFunction, PTRANSF_LINE, theLine); + DNaming::GetReal(aFunction, PTRANSF_OFF)->Set(theOffset); + EXPECT_EQ(ExecuteNamingFunction(aFunction, new DNaming_TransformationDriver()), 0); + return aFunction; +} + +static occ::handle MakeNamingRotation( + const occ::handle& theObject, + const occ::handle& theLine, + const double theAngle) +{ + occ::handle aFunction = AddNamingFunction(theObject, PRRLINE_GUID); + DNaming::SetObjectArg(aFunction, PTRANSF_LINE, theLine); + DNaming::GetReal(aFunction, PTRANSF_ANG)->Set(theAngle); + EXPECT_EQ(ExecuteNamingFunction(aFunction, new DNaming_TransformationDriver()), 0); + return aFunction; +} + +static occ::handle MakeNamingMirror( + const occ::handle& theObject, + const occ::handle& thePlane) +{ + occ::handle aFunction = AddNamingFunction(theObject, PMIRR_GUID); + DNaming::SetObjectArg(aFunction, PTRANSF_PLANE, thePlane); + EXPECT_EQ(ExecuteNamingFunction(aFunction, new DNaming_TransformationDriver()), 0); + return aFunction; +} + +static occ::handle MakeNamingFillet( + const occ::handle& theObject, + const occ::handle& thePath) +{ + occ::handle aFunction = AddNamingFunction(theObject, FILLT_GUID); + DNaming::GetReal(aFunction, FILLET_RADIUS)->Set(25.0); + DNaming::GetInteger(aFunction, FILLET_SURFTYPE)->Set(0); + DNaming::SetObjectArg(aFunction, FILLET_PATH, thePath); + EXPECT_EQ(ExecuteNamingFunction(aFunction, new DNaming_FilletDriver()), 0); + return aFunction; +} + +static TopoDS_Shape NamingSubShape(const TopoDS_Shape& theShape, + const TopAbs_ShapeEnum theType, + const int theIndex) +{ + NCollection_Map aShapeMap; + aShapeMap.Add(theShape); + int anIndex = 0; + for (TopExp_Explorer anExplorer(theShape, theType); anExplorer.More(); anExplorer.Next()) + { + if (aShapeMap.Add(anExplorer.Current()) && ++anIndex == theIndex) + { + return anExplorer.Current(); + } + } + return TopoDS_Shape(); +} + +static int CollectNamingSubShapes(const TopoDS_Shape& theShape, + const TopAbs_ShapeEnum theType, + TopoDS_Shape* theShapes, + const int theCapacity) +{ + NCollection_Map aShapeMap; + aShapeMap.Add(theShape); + int aCount = 0; + for (TopExp_Explorer anExplorer(theShape, theType); anExplorer.More(); anExplorer.Next()) + { + if (aShapeMap.Add(anExplorer.Current())) + { + if (aCount < theCapacity) + { + theShapes[aCount] = anExplorer.Current(); + } + ++aCount; + } + } + return aCount; +} + +static gp_Pnt NamingVertexAverage(const TopoDS_Shape& theShape) +{ + double aX = 0.0; + double aY = 0.0; + double aZ = 0.0; + int aCount = 0; + for (TopExp_Explorer anExplorer(theShape, TopAbs_VERTEX); anExplorer.More(); anExplorer.Next()) + { + const gp_Pnt aPoint = BRep_Tool::Pnt(TopoDS::Vertex(anExplorer.Current())); + aX += aPoint.X(); + aY += aPoint.Y(); + aZ += aPoint.Z(); + ++aCount; + } + return aCount == 0 ? gp_Pnt() : gp_Pnt(aX / aCount, aY / aCount, aZ / aCount); +} + +static int NamingFaceCount(const TopoDS_Shape& theShape) +{ + TopoDS_Shape aFaces[32]; + return CollectNamingSubShapes(theShape, TopAbs_FACE, aFaces, 32); +} + +static bool NamingNear(const double theValue, const double theExpected) +{ + return std::abs(theValue - theExpected) <= 1.0e-7; +} + +static void AddNamingPrimitives(const TDF_Label& theLabel, + const TopoDS_Shape* theShapes, + const int theCount) +{ + TNaming_Builder aBuilder(theLabel); + for (int anIndex = 0; anIndex < theCount; ++anIndex) + { + aBuilder.Generated(theShapes[anIndex]); + } +} + +static void AddNamingGenerated(const TDF_Label& theLabel, + const TopoDS_Shape* theOldShapes, + const TopoDS_Shape* theNewShapes, + const int theCount) +{ + TNaming_Builder aBuilder(theLabel); + for (int anIndex = 0; anIndex < theCount; ++anIndex) + { + aBuilder.Generated(theOldShapes[anIndex], theNewShapes[anIndex]); + } +} + +static void AddNamingModified(const TDF_Label& theLabel, + const TopoDS_Shape* theOldShapes, + const TopoDS_Shape* theNewShapes, + const int theCount) +{ + TNaming_Builder aBuilder(theLabel); + for (int anIndex = 0; anIndex < theCount; ++anIndex) + { + aBuilder.Modify(theOldShapes[anIndex], theNewShapes[anIndex]); + } +} + +static void AddNamingDeleted(const TDF_Label& theLabel, + const TopoDS_Shape* theShapes, + const int theCount) +{ + TNaming_Builder aBuilder(theLabel); + for (int anIndex = 0; anIndex < theCount; ++anIndex) + { + aBuilder.Delete(theShapes[anIndex]); + } +} + +static void AddNamingSelected(const TDF_Label& theLabel, + const TopoDS_Shape* theShapes, + const TopoDS_Shape* theContexts, + const int theCount) +{ + TNaming_Builder aBuilder(theLabel); + for (int anIndex = 0; anIndex < theCount; ++anIndex) + { + aBuilder.Select(theShapes[anIndex], theContexts[anIndex]); + } +} + +static void ExpectNamingAttribute(const TDF_Label& theLabel) +{ + occ::handle aNamedShape; + ASSERT_TRUE(theLabel.FindAttribute(TNaming_NamedShape::GetID(), aNamedShape)); + EXPECT_FALSE(aNamedShape.IsNull()); +} + +static void ExpectNamingLabel(const TopoDS_Shape& theShape, + const TDF_Label& theExpectedLabel, + const TDF_Label& theAccessLabel) +{ + const occ::handle aNamedShape = + TNaming_Tool::NamedShape(theShape, theAccessLabel); + ASSERT_FALSE(aNamedShape.IsNull()); + EXPECT_TRUE(aNamedShape->Label().IsEqual(theExpectedLabel)); +} + +static void ExpectNamingCurrentShape(const TDF_Label& theLabel, + const TopoDS_Shape& theExpectedShape) +{ + occ::handle aNamedShape; + ASSERT_TRUE(theLabel.FindAttribute(TNaming_NamedShape::GetID(), aNamedShape)); + TCollection_AsciiString aLabelEntry; + TDF_Tool::Entry(theLabel, aLabelEntry); + EXPECT_TRUE(TNaming_Tool::CurrentShape(aNamedShape).IsSame(theExpectedShape)) + << "CurrentShape mismatch at " << aLabelEntry.ToCString(); +} + +static void ExpectNamingGetShape(const TDF_Label& theLabel, const TopoDS_Shape& theExpectedShape) +{ + occ::handle aNamedShape; + ASSERT_TRUE(theLabel.FindAttribute(TNaming_NamedShape::GetID(), aNamedShape)); + TCollection_AsciiString aLabelEntry; + TDF_Tool::Entry(theLabel, aLabelEntry); + EXPECT_TRUE(TNaming_Tool::GetShape(aNamedShape).IsSame(theExpectedShape)) + << "GetShape mismatch at " << aLabelEntry.ToCString(); +} + +static void ExpectNamingShape(const TDF_Label& theLabel, const TopoDS_Shape& theExpectedShape) +{ + ExpectNamingCurrentShape(theLabel, theExpectedShape); + ExpectNamingGetShape(theLabel, theExpectedShape); +} + +static void ExpectNamingCompoundFaces(const TDF_Label& theLabel, + const int theCurrentCount, + const int theShapeCount) +{ + occ::handle aNamedShape; + ASSERT_TRUE(theLabel.FindAttribute(TNaming_NamedShape::GetID(), aNamedShape)); + EXPECT_EQ(NamingFaceCount(TNaming_Tool::CurrentShape(aNamedShape)), theCurrentCount); + EXPECT_EQ(NamingFaceCount(TNaming_Tool::GetShape(aNamedShape)), theShapeCount); +} + +static void CollectNamingShapes(const TopoDS_Shape& theShape, + NCollection_List& theShapes) +{ + theShapes.Append(theShape); + for (TopoDS_Iterator anIterator(theShape, true, true); anIterator.More(); anIterator.Next()) + { + CollectNamingShapes(anIterator.Value(), theShapes); + } +} + +static void FillSelectionValidMap(const TDF_Label& theLabel, + NCollection_Map& theValidMap); + +static occ::handle AddNamingSelection( + const occ::handle& theDocument, + const occ::handle& theContextObject, + const TopoDS_Shape& theSelection, + const bool theKeepOrientation, + occ::handle& theSelectionObject) +{ + const occ::handle anObject = AddNamingObject(theDocument); + theSelectionObject = anObject; + occ::handle anObjectNode; + anObject->Label().FindAttribute(TDataStd_TreeNode::GetDefaultTreeID(), anObjectNode); + anObjectNode->Remove(); + occ::handle aContextNode; + theContextObject->Label().FindAttribute(TDataStd_TreeNode::GetDefaultTreeID(), aContextNode); + aContextNode->Append(anObjectNode); + + const occ::handle aFunction = AddNamingFunction(anObject, ATTCH_GUID); + const TDF_Label aResultLabel = aFunction->Label().FindChild(FUNCTION_RESULT_LABEL, true); + TDF_Reference::Set(anObject->Label(), aResultLabel); + + const occ::handle aContextNS = DNaming::GetObjectValue(theContextObject); + if (aContextNS.IsNull() || aContextNS->IsEmpty()) + { + return aFunction; + } + + TNaming_Selector aSelector(aResultLabel); + if (!aSelector.Select(theSelection, aContextNS->Get(), false, theKeepOrientation)) + { + return aFunction; + } + TDF_Reference::Set(aFunction->Label().FindChild(FUNCTION_ARGUMENTS_LABEL).FindChild(ATTACH_ARG), + aContextNS->Label().Father()); + return aFunction; +} + +static TopoDS_Shape SolveNamingFunctionSelection(const occ::handle& theFunction) +{ + const TDF_Label aResultLabel = theFunction->Label().FindChild(FUNCTION_RESULT_LABEL, true); + NCollection_Map aValidLabels; + FillSelectionValidMap(aResultLabel, aValidLabels); + TDF_ChildIterator anIterator(theFunction->Label().Root(), true); + for (; anIterator.More(); anIterator.Next()) + { + occ::handle aNamedShape; + if (anIterator.Value().FindAttribute(TNaming_NamedShape::GetID(), aNamedShape)) + { + aValidLabels.Add(anIterator.Value()); + } + } + occ::handle aLogbook = TFunction_Logbook::Set(theFunction->Label()); + aLogbook->Clear(); + aLogbook->SetValid(aValidLabels); + occ::handle aDriver = new DNaming_SelectionDriver(); + aDriver->Init(theFunction->Label()); + if (aDriver->Execute(aLogbook) != 0) + { + return TopoDS_Shape(); + } + return TNaming_Tool::CurrentShape(DNaming::GetFunctionResult(theFunction)); +} + +static void FillSelectionValidMap(const TDF_Label& theLabel, + NCollection_Map& theValidMap) +{ + NCollection_Map> anExternalAttributes; + TDF_ChildIterator anIterator(theLabel, true); + for (; anIterator.More(); anIterator.Next()) + { + const TDF_Label& aChildLabel = anIterator.Value(); + TDF_Tool::OutReferences(aChildLabel, anExternalAttributes); + for (NCollection_Map>::Iterator anAttributeIterator( + anExternalAttributes); + anAttributeIterator.More(); + anAttributeIterator.Next()) + { + const occ::handle& anAttribute = anAttributeIterator.Key(); + if (anAttribute->Label().IsDifferent(aChildLabel) + && !anAttribute->Label().IsDescendant(theLabel)) + { + theValidMap.Add(anAttribute->Label()); + occ::handle aNamedShape; + anAttribute->Label().FindAttribute(TNaming_NamedShape::GetID(), aNamedShape); + if (!aNamedShape.IsNull()) + { + TNaming_NamingTool::BuildDescendants(aNamedShape, theValidMap); + } + } + } + } +} + +static TopoDS_Shape SolveSelectionAfterModification(const TopoDS_Shape& theInitial, + const TopoDS_Shape& theModified) +{ + occ::handle aData = new TDF_Data(); + const TDF_Label aRoot = aData->Root(); + const TDF_Label aContextLabel = aRoot.FindChild(1); + const TDF_Label aSelectionLabel = aRoot.FindChild(2); + + DNaming::LoadImportedShape(aContextLabel, theInitial); + + const TopoDS_Shape aSelected = FirstSubShape(theInitial, TopAbs_FACE); + TNaming_Selector aSelector(aSelectionLabel); + if (aSelected.IsNull() || !aSelector.Select(aSelected, theInitial, true)) + { + return TopoDS_Shape(); + } + + TNaming_Builder aModificationBuilder(aContextLabel); + aModificationBuilder.Modify(theInitial, theModified); + + NCollection_Map aValidLabels; + FillSelectionValidMap(aSelectionLabel, aValidLabels); + if (!aSelector.Solve(aValidLabels)) + { + return TopoDS_Shape(); + } + return TNaming_Tool::GetShape(aSelector.NamedShape()); +} +} // namespace + // Test TNaming_Tool::GetShape with primitive evolution TEST_F(TNaming_ToolTest, GetShape_Primitive) { @@ -417,3 +934,999 @@ TEST_F(TNaming_ToolTest, NamedShape_MissingUsedShapes) // Should return null NamedShape when UsedShapes is missing EXPECT_TRUE(aNS.IsNull()); } + +// caf/named_shape/D1: SelectGeometry resolves every box edge. +TEST(TNaming_Tool_Test, CafNamedShape_D1_SelectGeometryEdges) +{ + occ::handle aData = new TDF_Data(); + const TDF_Label aRoot = aData->Root(); + const TDF_Label aContextLabel = aRoot.FindChild(1); + const TopoDS_Shape aBox = BRepPrimAPI_MakeBox(100.0, 200.0, 300.0).Shape(); + DNaming::LoadImportedShape(aContextLabel, aBox); + + int anIndex = 0; + NCollection_Map aShapeMap; + aShapeMap.Add(aBox); + for (TopExp_Explorer anExplorer(aBox, TopAbs_EDGE); anExplorer.More(); anExplorer.Next()) + { + if (!aShapeMap.Add(anExplorer.Current())) + { + continue; + } + const TDF_Label aSelectionLabel = aRoot.FindChild(1001 + anIndex++); + TNaming_Selector aSelector(aSelectionLabel); + ASSERT_TRUE(aSelector.Select(anExplorer.Current(), aBox, true)); + NCollection_Map aValidLabels; + FillSelectionValidMap(aSelectionLabel, aValidLabels); + ASSERT_TRUE(aSelector.Solve(aValidLabels)); + EXPECT_TRUE(TNaming_Tool::GetShape(aSelector.NamedShape()).IsSame(anExplorer.Current())); + } + EXPECT_EQ(anIndex, 12); +} + +// caf/named_shape/D2: SelectGeometry resolves every box face. +TEST(TNaming_Tool_Test, CafNamedShape_D2_SelectGeometryFaces) +{ + occ::handle aData = new TDF_Data(); + const TDF_Label aRoot = aData->Root(); + const TDF_Label aContextLabel = aRoot.FindChild(1); + const TopoDS_Shape aBox = BRepPrimAPI_MakeBox(100.0, 200.0, 300.0).Shape(); + DNaming::LoadImportedShape(aContextLabel, aBox); + + int anIndex = 0; + NCollection_Map aShapeMap; + aShapeMap.Add(aBox); + for (TopExp_Explorer anExplorer(aBox, TopAbs_FACE); anExplorer.More(); anExplorer.Next()) + { + if (!aShapeMap.Add(anExplorer.Current())) + { + continue; + } + const TDF_Label aSelectionLabel = aRoot.FindChild(2001 + anIndex++); + TNaming_Selector aSelector(aSelectionLabel); + ASSERT_TRUE(aSelector.Select(anExplorer.Current(), aBox, true)); + NCollection_Map aValidLabels; + FillSelectionValidMap(aSelectionLabel, aValidLabels); + ASSERT_TRUE(aSelector.Solve(aValidLabels)); + EXPECT_TRUE(TNaming_Tool::GetShape(aSelector.NamedShape()).IsSame(anExplorer.Current())); + } + EXPECT_EQ(anIndex, 6); +} + +// caf/named_shape/D3: SelectGeometry resolves every box vertex. +TEST(TNaming_Tool_Test, CafNamedShape_D3_SelectGeometryVertices) +{ + occ::handle aData = new TDF_Data(); + const TDF_Label aRoot = aData->Root(); + const TDF_Label aContextLabel = aRoot.FindChild(1); + const TopoDS_Shape aBox = BRepPrimAPI_MakeBox(100.0, 200.0, 300.0).Shape(); + DNaming::LoadImportedShape(aContextLabel, aBox); + + int anIndex = 0; + NCollection_Map aShapeMap; + aShapeMap.Add(aBox); + for (TopExp_Explorer anExplorer(aBox, TopAbs_VERTEX); anExplorer.More(); anExplorer.Next()) + { + if (!aShapeMap.Add(anExplorer.Current())) + { + continue; + } + const TDF_Label aSelectionLabel = aRoot.FindChild(3001 + anIndex++); + TNaming_Selector aSelector(aSelectionLabel); + ASSERT_TRUE(aSelector.Select(anExplorer.Current(), aBox, true)); + NCollection_Map aValidLabels; + FillSelectionValidMap(aSelectionLabel, aValidLabels); + ASSERT_TRUE(aSelector.Solve(aValidLabels)); + EXPECT_TRUE(TNaming_Tool::GetShape(aSelector.NamedShape()).IsSame(anExplorer.Current())); + } + EXPECT_EQ(anIndex, 8); +} + +// caf/named_shape/D4: current shape follows a Boolean modification history. +TEST(TNaming_Tool_Test, CafNamedShape_D4_CurrentShapeAfterBoolean) +{ + const TopoDS_Shape aBox = BRepPrimAPI_MakeBox(190.0, 890.0, 290.0).Shape(); + const TopoDS_Shape aTool = + BRepPrimAPI_MakeBox(gp_Pnt(-100.0, 400.0, -130.0), 390.0, 190.0, 490.0).Shape(); + const TopoDS_Shape aCut = BRepAlgoAPI_Fuse(aBox, aTool).Shape(); + + occ::handle aData = new TDF_Data(); + const TDF_Label aLabel = aData->Root().FindChild(1); + TNaming_Builder aBuilder(aLabel); + aBuilder.Generated(aBox); + TNaming_Builder aModification(aLabel); + aModification.Modify(aBox, aCut); + + occ::handle aNamedShape; + ASSERT_TRUE(aLabel.FindAttribute(TNaming_NamedShape::GetID(), aNamedShape)); + EXPECT_TRUE(TNaming_Tool::CurrentShape(aNamedShape).IsSame(aCut)); +} + +// caf/named_shape/E2: selection follows the complete transformation/fillet chain. +TEST(TNaming_Tool_Test, CafNamedShape_E2_SelectionAfterTransformations) +{ + RegisterNamingDrivers(); + const occ::handle aDocument = NewNamingDocument(); + const occ::handle aBoxObject = AddNamingObject(aDocument); + const occ::handle aBoxFunction = + MakeNamingBox(aBoxObject, 190.0, 290.0, 390.0); + const occ::handle aTranslate1 = + MakeNamingTranslation(aBoxObject, 150.0, 40.0, 90.0); + + const TopoDS_Shape aBox2 = NamingFunctionShape(aTranslate1); + const TopoDS_Shape aLineShape = + NamingSubShape(NamingSubShape(aBox2, TopAbs_FACE, 1), TopAbs_EDGE, 1); + ASSERT_FALSE(aLineShape.IsNull()); + occ::handle aLineObject; + const occ::handle aLineSelection = + AddNamingSelection(aDocument, aBoxObject, aLineShape, true, aLineObject); + const occ::handle aAlongLine = + MakeNamingAlongLine(aBoxObject, aLineObject, 210.0); + + const TopoDS_Shape aBox3 = NamingFunctionShape(aAlongLine); + const TopoDS_Shape aRotationLine = + NamingSubShape(NamingSubShape(aBox3, TopAbs_FACE, 1), TopAbs_EDGE, 3); + occ::handle aRotationLineObject; + const occ::handle aRotationLineSelection = + AddNamingSelection(aDocument, aBoxObject, aRotationLine, true, aRotationLineObject); + const occ::handle aRotate = + MakeNamingRotation(aBoxObject, aRotationLineObject, 120.0); + + const TopoDS_Shape aBox4 = NamingFunctionShape(aRotate); + const TopoDS_Shape aMirrorFace = NamingSubShape(aBox4, TopAbs_FACE, 3); + ASSERT_FALSE(aMirrorFace.IsNull()); + occ::handle aPlaneObject; + const occ::handle aPlaneSelection = + AddNamingSelection(aDocument, aBoxObject, aMirrorFace, true, aPlaneObject); + const occ::handle aMirror = MakeNamingMirror(aBoxObject, aPlaneObject); + + const TopoDS_Shape aBox5 = NamingFunctionShape(aMirror); + const TopoDS_Shape aFilletPath = + NamingSubShape(NamingSubShape(aBox5, TopAbs_FACE, 1), TopAbs_EDGE, 3); + ASSERT_FALSE(aFilletPath.IsNull()); + occ::handle aPathObject; + const occ::handle aPathSelection = + AddNamingSelection(aDocument, aBoxObject, aFilletPath, true, aPathObject); + const occ::handle aFillet = MakeNamingFillet(aBoxObject, aPathObject); + ASSERT_FALSE(NamingFunctionShape(aFillet).IsNull()); + + NCollection_List> aSelectionFunctions; + NCollection_List aSelectionShapes; + NCollection_List aCollectedShapes; + CollectNamingShapes(NamingFunctionShape(aFillet), aCollectedShapes); + ASSERT_FALSE(aCollectedShapes.IsEmpty()); + aCollectedShapes.RemoveFirst(); + for (NCollection_List::Iterator anIterator(aCollectedShapes); anIterator.More(); + anIterator.Next()) + { + if (anIterator.Value().ShapeType() == TopAbs_EDGE + && BRep_Tool::Degenerated(TopoDS::Edge(anIterator.Value()))) + { + continue; + } + occ::handle aSelectionObject; + aSelectionFunctions.Append( + AddNamingSelection(aDocument, aBoxObject, anIterator.Value(), true, aSelectionObject)); + aSelectionShapes.Append(anIterator.Value()); + } + + DNaming::GetReal(aBoxFunction, BOX_DX)->Set(290.0); + ASSERT_EQ(ExecuteNamingFunction(aBoxFunction, new DNaming_BoxDriver()), 0); + ASSERT_EQ(ExecuteNamingFunction(aTranslate1, new DNaming_TransformationDriver()), 0); + ASSERT_FALSE(SolveNamingFunctionSelection(aLineSelection).IsNull()); + ASSERT_EQ(ExecuteNamingFunction(aAlongLine, new DNaming_TransformationDriver()), 0); + ASSERT_FALSE(SolveNamingFunctionSelection(aRotationLineSelection).IsNull()); + ASSERT_EQ(ExecuteNamingFunction(aRotate, new DNaming_TransformationDriver()), 0); + ASSERT_FALSE(SolveNamingFunctionSelection(aPlaneSelection).IsNull()); + ASSERT_EQ(ExecuteNamingFunction(aMirror, new DNaming_TransformationDriver()), 0); + ASSERT_FALSE(SolveNamingFunctionSelection(aPathSelection).IsNull()); + ASSERT_EQ(ExecuteNamingFunction(aFillet, new DNaming_FilletDriver()), 0); + + NCollection_List>::Iterator aFunctionIterator( + aSelectionFunctions); + NCollection_List::Iterator aShapeIterator(aSelectionShapes); + for (; aFunctionIterator.More() && aShapeIterator.More(); + aFunctionIterator.Next(), aShapeIterator.Next()) + { + const TopoDS_Shape aSelected = SolveNamingFunctionSelection(aFunctionIterator.Value()); + ASSERT_FALSE(aSelected.IsNull()); + EXPECT_EQ(aSelected.ShapeType(), aShapeIterator.Value().ShapeType()); + } +} + +TEST(TNaming_Tool_Test, CafNamedShape_F2_FusedSelectionAfterRecompute) +{ + const TopoDS_Shape aFirst = BRepPrimAPI_MakeBox(130.0, 140.0, 150.0).Shape(); + const TopoDS_Shape aSecond = + BRepPrimAPI_MakeBox(gp_Pnt(80.0, 20.0, 20.0), 80.0, 100.0, 120.0).Shape(); + const TopoDS_Shape aFused = BRepAlgoAPI_Fuse(aFirst, aSecond).Shape(); + const TopoDS_Shape aChangedSecond = + BRepPrimAPI_MakeBox(gp_Pnt(80.0, 20.0, 20.0), 80.0, 100.0, 140.0).Shape(); + const TopoDS_Shape aChangedFused = BRepAlgoAPI_Fuse(aFirst, aChangedSecond).Shape(); + const TopoDS_Shape aSelected = SolveSelectionAfterModification(aFused, aChangedFused); + ASSERT_FALSE(aSelected.IsNull()); + EXPECT_EQ(aSelected.ShapeType(), TopAbs_FACE); +} + +TEST(TNaming_Tool_Test, CafNamedShape_F3_CutSelectionAfterRecompute) +{ + const TopoDS_Shape aFirst = BRepPrimAPI_MakeBox(130.0, 140.0, 150.0).Shape(); + const TopoDS_Shape aSecond = + BRepPrimAPI_MakeBox(gp_Pnt(20.0, 20.0, 20.0), 30.0, 30.0, 30.0).Shape(); + const TopoDS_Shape aCut = BRepAlgoAPI_Cut(aFirst, aSecond).Shape(); + const TopoDS_Shape aChangedSecond = + BRepPrimAPI_MakeBox(gp_Pnt(30.0, 20.0, 20.0), 30.0, 30.0, 30.0).Shape(); + const TopoDS_Shape aChangedCut = BRepAlgoAPI_Cut(aFirst, aChangedSecond).Shape(); + const TopoDS_Shape aSelected = SolveSelectionAfterModification(aCut, aChangedCut); + ASSERT_FALSE(aSelected.IsNull()); + EXPECT_EQ(aSelected.ShapeType(), TopAbs_FACE); +} + +TEST(TNaming_Tool_Test, CafNamedShape_E9_SelectionAfterMultipleFusions) +{ + const TopoDS_Shape aBox = BRepPrimAPI_MakeBox(130.0, 140.0, 150.0).Shape(); + const TopoDS_Shape aSphere1 = BRepPrimAPI_MakeSphere(gp_Pnt(20.0, 20.0, 20.0), 25.0).Shape(); + const TopoDS_Shape aSphere2 = BRepPrimAPI_MakeSphere(gp_Pnt(70.0, 70.0, 70.0), 25.0).Shape(); + const TopoDS_Shape aFused = + BRepAlgoAPI_Fuse(BRepAlgoAPI_Fuse(aBox, aSphere1).Shape(), aSphere2).Shape(); + const TopoDS_Shape aChangedSphere = + BRepPrimAPI_MakeSphere(gp_Pnt(70.0, 70.0, 80.0), 25.0).Shape(); + const TopoDS_Shape aChangedFused = + BRepAlgoAPI_Fuse(BRepAlgoAPI_Fuse(aBox, aSphere1).Shape(), aChangedSphere).Shape(); + const TopoDS_Shape aSelected = SolveSelectionAfterModification(aFused, aChangedFused); + ASSERT_FALSE(aSelected.IsNull()); + EXPECT_EQ(aSelected.ShapeType(), TopAbs_FACE); +} + +TEST(TNaming_Tool_Test, CafNamedShape_F8_SelectShapeAfterFusion) +{ + const TopoDS_Shape aBox1 = BRepPrimAPI_MakeBox(100.0, 200.0, 350.0).Shape(); + const TopoDS_Shape aBox2 = + BRepPrimAPI_MakeBox(gp_Pnt(80.0, 80.0, 20.0), 330.0, 330.0, 90.0).Shape(); + const TopoDS_Shape aBox3 = + BRepPrimAPI_MakeBox(gp_Pnt(40.0, 40.0, 40.0), 60.0, 450.0, 150.0).Shape(); + const TopoDS_Shape aFused = + BRepAlgoAPI_Fuse(BRepAlgoAPI_Fuse(aBox1, aBox2).Shape(), aBox3).Shape(); + const TopoDS_Shape aChangedBox2 = + BRepPrimAPI_MakeBox(gp_Pnt(80.0, 80.0, 20.0), 330.0, 330.0, 120.0).Shape(); + const TopoDS_Shape aChangedFused = + BRepAlgoAPI_Fuse(BRepAlgoAPI_Fuse(aBox1, aChangedBox2).Shape(), aBox3).Shape(); + const TopoDS_Shape aSelected = SolveSelectionAfterModification(aFused, aChangedFused); + ASSERT_FALSE(aSelected.IsNull()); + EXPECT_EQ(aSelected.ShapeType(), TopAbs_FACE); +} + +TEST(TNaming_Tool_Test, CafNamedShape_F9_AttachedSelectionAfterFusion) +{ + const TopoDS_Shape aBox1 = BRepPrimAPI_MakeBox(100.0, 200.0, 350.0).Shape(); + const TopoDS_Shape aBox2 = + BRepPrimAPI_MakeBox(gp_Pnt(80.0, 80.0, 20.0), 330.0, 330.0, 90.0).Shape(); + const TopoDS_Shape aBox3 = + BRepPrimAPI_MakeBox(gp_Pnt(40.0, 40.0, 40.0), 60.0, 450.0, 150.0).Shape(); + const TopoDS_Shape aFused = + BRepAlgoAPI_Fuse(BRepAlgoAPI_Fuse(aBox1, aBox2).Shape(), aBox3).Shape(); + const TopoDS_Shape aChangedBox2 = + BRepPrimAPI_MakeBox(gp_Pnt(80.0, 80.0, 20.0), 330.0, 330.0, 125.0).Shape(); + const TopoDS_Shape aChangedFused = + BRepAlgoAPI_Fuse(BRepAlgoAPI_Fuse(aBox1, aChangedBox2).Shape(), aBox3).Shape(); + const TopoDS_Shape aSelected = SolveSelectionAfterModification(aFused, aChangedFused); + ASSERT_FALSE(aSelected.IsNull()); + EXPECT_EQ(aSelected.ShapeType(), TopAbs_FACE); +} + +// caf/nam/A1: TNaming_Builder accepts primitive, generated, modified, deleted, +// replacement, and selected evolutions without DRAW command wrappers. +TEST(TNaming_Tool_Test, CafNamedShape_A1_BuilderEvolutions) +{ + occ::handle aData = new TDF_Data(); + const TDF_Label aRoot = aData->Root(); + const TDF_Label aTestLabel = aRoot.FindChild(1, true); + + const TDF_Label aLabel1 = aTestLabel.FindChild(1, true); + const TDF_Label aLabel11 = aLabel1.FindChild(1, true); + const TDF_Label aLabel12 = aLabel1.FindChild(2, true); + const TDF_Label aLabel2 = aTestLabel.FindChild(2, true); + const TDF_Label aLabel21 = aLabel2.FindChild(1, true); + const TDF_Label aLabel22 = aLabel2.FindChild(2, true); + const TDF_Label aLabel3 = aTestLabel.FindChild(3, true); + const TDF_Label aLabel31 = aLabel3.FindChild(1, true); + const TDF_Label aLabel32 = aLabel3.FindChild(2, true); + const TDF_Label aLabel4 = aTestLabel.FindChild(4, true); + const TDF_Label aLabel41 = aLabel4.FindChild(1, true); + const TDF_Label aLabel5 = aTestLabel.FindChild(5, true); + const TDF_Label aLabel51 = aLabel5.FindChild(1, true); + const TDF_Label aLabel6 = aTestLabel.FindChild(6, true); + const TDF_Label aLabel61 = aLabel6.FindChild(1, true); + + const TopoDS_Shape aBox = BRepPrimAPI_MakeBox(100.0, 200.0, 300.0).Shape(); + const TopoDS_Shape aBox2 = BRepPrimAPI_MakeBox(200.0, 300.0, 400.0).Shape(); + const TopoDS_Shape aBox3 = BRepPrimAPI_MakeBox(300.0, 400.0, 500.0).Shape(); + const TopoDS_Shape aBox4 = BRepPrimAPI_MakeBox(300.0, 400.0, 500.0).Shape(); + TopoDS_Shape aBoxEdges[16]; + TopoDS_Shape aBox2Faces[8]; + TopoDS_Shape aBox3Faces[8]; + TopoDS_Shape aBox4Faces[8]; + ASSERT_EQ(CollectNamingSubShapes(aBox, TopAbs_EDGE, aBoxEdges, 16), 12); + ASSERT_EQ(CollectNamingSubShapes(aBox2, TopAbs_FACE, aBox2Faces, 8), 6); + ASSERT_EQ(CollectNamingSubShapes(aBox3, TopAbs_FACE, aBox3Faces, 8), 6); + ASSERT_EQ(CollectNamingSubShapes(aBox4, TopAbs_FACE, aBox4Faces, 8), 6); + + AddNamingPrimitives(aLabel1, &aBox, 1); + AddNamingPrimitives(aLabel11, &aBoxEdges[0], 1); + AddNamingPrimitives(aLabel11, aBoxEdges, 3); + AddNamingPrimitives(aLabel12, &aBoxEdges[3], 3); + + const TopoDS_Shape aGeneratedOld1[] = {aBox}; + const TopoDS_Shape aGeneratedNew1[] = {aBox2}; + AddNamingGenerated(aLabel2, aGeneratedOld1, aGeneratedNew1, 1); + const TopoDS_Shape aGeneratedOld21[] = {aBoxEdges[0]}; + const TopoDS_Shape aGeneratedNew21[] = {aBox2Faces[0]}; + AddNamingGenerated(aLabel21, aGeneratedOld21, aGeneratedNew21, 1); + const TopoDS_Shape aGeneratedOld22[] = {aBoxEdges[1], aBoxEdges[1], aBoxEdges[2]}; + const TopoDS_Shape aGeneratedNew22[] = {aBox2Faces[1], aBox2Faces[2], aBox2Faces[3]}; + AddNamingGenerated(aLabel22, aGeneratedOld22, aGeneratedNew22, 3); + const TopoDS_Shape aGeneratedOld21Second[] = {aBoxEdges[2], aBoxEdges[2], aBoxEdges[3]}; + const TopoDS_Shape aGeneratedNew21Second[] = {aBox2Faces[0], aBox2Faces[2], aBox2Faces[3]}; + AddNamingGenerated(aLabel21, aGeneratedOld21Second, aGeneratedNew21Second, 3); + + const TopoDS_Shape aModifiedOld3[] = {aBox2}; + const TopoDS_Shape aModifiedNew3[] = {aBox3}; + AddNamingModified(aLabel3, aModifiedOld3, aModifiedNew3, 1); + const TopoDS_Shape aModifiedOld31[] = {aBox2Faces[0]}; + const TopoDS_Shape aModifiedNew31[] = {aBox3Faces[0]}; + AddNamingModified(aLabel31, aModifiedOld31, aModifiedNew31, 1); + const TopoDS_Shape aModifiedOld32[] = {aBox2Faces[4], aBox2Faces[1], aBox2Faces[2]}; + const TopoDS_Shape aModifiedNew32[] = {aBox3Faces[1], aBox3Faces[2], aBox3Faces[3]}; + AddNamingModified(aLabel32, aModifiedOld32, aModifiedNew32, 3); + const TopoDS_Shape aModifiedOld31Second[] = {aBox2Faces[2], aBoxEdges[2], aBox2Faces[3]}; + const TopoDS_Shape aModifiedNew31Second[] = {aBox3Faces[0], aBox3Faces[2], aBox3Faces[3]}; + AddNamingModified(aLabel31, aModifiedOld31Second, aModifiedNew31Second, 3); + + AddNamingDeleted(aLabel41, &aBox3Faces[0], 1); + const TopoDS_Shape aDeletedFaces[] = {aBox3Faces[0], aBox3Faces[3]}; + AddNamingDeleted(aLabel41, aDeletedFaces, 2); + + const TopoDS_Shape aModifiedOld5[] = {aBox3}; + const TopoDS_Shape aModifiedNew5[] = {aBox4}; + AddNamingModified(aLabel5, aModifiedOld5, aModifiedNew5, 1); + const TopoDS_Shape aModifiedOld51[] = {aBox3Faces[1], aBox3Faces[2]}; + const TopoDS_Shape aModifiedNew51[] = {aBox4Faces[1], aBox4Faces[2]}; + AddNamingModified(aLabel51, aModifiedOld51, aModifiedNew51, 2); + + const TopoDS_Shape aSelectedOld6[] = {aBox4}; + const TopoDS_Shape aSelectedNew6[] = {aBox4}; + AddNamingSelected(aLabel6, aSelectedOld6, aSelectedNew6, 1); + const TopoDS_Shape aSelectedOld61[] = {aBox4Faces[1], + aBox4Faces[1], + aBox2Faces[4], + aBox2Faces[4]}; + const TopoDS_Shape aSelectedNew61[] = {aBox4Faces[1], + aBox4Faces[1], + aBox2Faces[4], + aBox2Faces[4]}; + AddNamingSelected(aLabel61, aSelectedOld61, aSelectedNew61, 4); + + const TDF_Label aLabels[] = {aLabel1, + aLabel11, + aLabel12, + aLabel2, + aLabel21, + aLabel22, + aLabel3, + aLabel31, + aLabel32, + aLabel41, + aLabel5, + aLabel51, + aLabel6, + aLabel61}; + for (const TDF_Label& aLabel : aLabels) + { + ExpectNamingAttribute(aLabel); + } + ExpectNamingShape(aLabel1, aBox); + ExpectNamingGetShape(aLabel2, aBox2); + ExpectNamingGetShape(aLabel3, aBox3); + ExpectNamingShape(aLabel5, aBox4); + ExpectNamingShape(aLabel6, aBox4); +} + +// caf/nam/A5: SelectShape command flows resolve geometry and reject an +// insufficient valid-label map when solving an intersection selection. +TEST(TNaming_Tool_Test, CafNamedShape_A5_SelectorCommandFlow) +{ + occ::handle aData = new TDF_Data(); + const TDF_Label aRoot = aData->Root(); + const TDF_Label aTestLabel = aRoot.FindChild(1, true); + const TDF_Label aFaceLabel = aTestLabel.FindChild(1, true); + const TDF_Label anEdgeLabel = aFaceLabel.FindChild(1, true); + + const gp_Pnt aP1(0.0, 0.0, 0.0); + const gp_Pnt aP2(0.0, 100.0, 0.0); + const gp_Pnt aP3(100.0, 0.0, 0.0); + const TopoDS_Vertex aVertex1 = BRepBuilderAPI_MakeVertex(aP1).Vertex(); + const TopoDS_Vertex aVertex2 = BRepBuilderAPI_MakeVertex(aP2).Vertex(); + const TopoDS_Vertex aVertex3 = BRepBuilderAPI_MakeVertex(aP3).Vertex(); + const occ::handle aLine1 = new Geom_Line(aP1, gp_Dir(0.0, 1.0, 0.0)); + const occ::handle aLine2 = new Geom_Line(aP2, gp_Dir(1.0, -1.0, 0.0)); + const occ::handle aLine3 = new Geom_Line(aP3, gp_Dir(-1.0, 0.0, 0.0)); + const TopoDS_Edge aEdge1 = BRepBuilderAPI_MakeEdge(aLine1, aVertex1, aVertex2).Edge(); + const TopoDS_Edge aEdge2 = BRepBuilderAPI_MakeEdge(aLine2, aVertex2, aVertex3).Edge(); + const TopoDS_Edge aEdge3 = BRepBuilderAPI_MakeEdge(aLine3, aVertex3, aVertex1).Edge(); + BRepBuilderAPI_MakeWire aWireBuilder; + aWireBuilder.Add(aEdge1); + aWireBuilder.Add(aEdge2); + aWireBuilder.Add(aEdge3); + ASSERT_TRUE(aWireBuilder.IsDone()); + const TopoDS_Face aFace = + BRepBuilderAPI_MakeFace(gp_Pln(gp_Pnt(0.0, 0.0, 0.0), gp_Dir(0.0, 0.0, 1.0)), + aWireBuilder.Wire()) + .Face(); + const TopoDS_Shape aBox = BRepPrimAPI_MakeBox(100.0, 100.0, 100.0).Shape(); + const TopoDS_Shape aFirstFaceVertex = NamingSubShape(aFace, TopAbs_VERTEX, 1); + const TopoDS_Shape aFirstBoxEdge = NamingSubShape(aBox, TopAbs_EDGE, 1); + const TopoDS_Shape aFirstBoxVertex = NamingSubShape(aBox, TopAbs_VERTEX, 1); + ASSERT_FALSE(aFirstFaceVertex.IsNull()); + ASSERT_FALSE(aFirstBoxEdge.IsNull()); + ASSERT_FALSE(aFirstBoxVertex.IsNull()); + AddNamingPrimitives(aFaceLabel, &aFace, 1); + AddNamingPrimitives(aFaceLabel.FindChild(1, true), &aEdge1, 1); + AddNamingPrimitives(aFaceLabel.FindChild(2, true), &aEdge2, 1); + AddNamingPrimitives(aFaceLabel.FindChild(3, true), &aEdge3, 1); + AddNamingPrimitives(anEdgeLabel, &aEdge1, 1); + + const TDF_Label aSelectionRoot = aTestLabel.FindChild(10, true); + TNaming_Selector aSelector1(aSelectionRoot.FindChild(1, true)); + TNaming_Selector aSelector2(aSelectionRoot.FindChild(2, true)); + TNaming_Selector aSelector3(aSelectionRoot.FindChild(3, true)); + TNaming_Selector aSelector4(aSelectionRoot.FindChild(4, true)); + TNaming_Selector aSelector5(aSelectionRoot.FindChild(5, true)); + TNaming_Selector aSelector6(aSelectionRoot.FindChild(6, true)); + ASSERT_TRUE(aSelector1.Select(aFace, false)); + ASSERT_TRUE(aSelector2.Select(aEdge1, aFace, false)); + ASSERT_TRUE(aSelector3.Select(aEdge2, false)); + ASSERT_TRUE(aSelector4.Select(aFirstFaceVertex, aFace, false)); + ASSERT_TRUE(aSelector5.Select(aFirstBoxEdge, aBox, false)); + ASSERT_TRUE(aSelector6.Select(aFirstBoxVertex, aBox, false)); + EXPECT_TRUE(TNaming_Tool::GetShape(aSelector1.NamedShape()).IsSame(aFace)); + EXPECT_TRUE(TNaming_Tool::GetShape(aSelector2.NamedShape()).IsSame(aEdge1)); + EXPECT_TRUE(TNaming_Tool::GetShape(aSelector3.NamedShape()).IsSame(aEdge2)); + EXPECT_TRUE(TNaming_Tool::GetShape(aSelector4.NamedShape()).IsSame(aFirstFaceVertex)); + EXPECT_TRUE(TNaming_Tool::GetShape(aSelector5.NamedShape()).IsSame(aFirstBoxEdge)); + EXPECT_TRUE(TNaming_Tool::GetShape(aSelector6.NamedShape()).IsSame(aFirstBoxVertex)); + + NCollection_Map aValidLabels; + aValidLabels.Add(anEdgeLabel); + EXPECT_FALSE(aSelector4.Solve(aValidLabels)); +} + +// caf/nam/A3: NamedShape, CurrentShape, GetShape, and selector resolution on +// a triangle prism cut preserve the complete DRAW naming graph. +TEST(TNaming_Tool_Test, CafNamedShape_A3_NamingToolGraph) +{ + occ::handle aData = new TDF_Data(); + const TDF_Label aRoot = aData->Root(); + const TDF_Label aTestLabel = aRoot.FindChild(1, true); + + const TDF_Label aLabel1 = aTestLabel.FindChild(1, true); + const TDF_Label aLabel11 = aLabel1.FindChild(1, true); + const TDF_Label aLabel12 = aLabel1.FindChild(2, true); + const TDF_Label aLabel13 = aLabel1.FindChild(3, true); + const TDF_Label aLabel2 = aTestLabel.FindChild(2, true); + const TDF_Label aLabel21 = aLabel2.FindChild(1, true); + const TDF_Label aLabel3 = aTestLabel.FindChild(3, true); + const TDF_Label aLabel4 = aTestLabel.FindChild(4, true); + const TDF_Label aLabel41 = aLabel4.FindChild(1, true); + const TDF_Label aLabel42 = aLabel4.FindChild(2, true); + + const gp_Pnt aP1(0.0, 0.0, 0.0); + const gp_Pnt aP2(0.0, 100.0, 0.0); + const gp_Pnt aP3(100.0, 0.0, 0.0); + const TopoDS_Vertex aVertex1 = BRepBuilderAPI_MakeVertex(aP1).Vertex(); + const TopoDS_Vertex aVertex2 = BRepBuilderAPI_MakeVertex(aP2).Vertex(); + const TopoDS_Vertex aVertex3 = BRepBuilderAPI_MakeVertex(aP3).Vertex(); + const occ::handle aLine1 = new Geom_Line(aP1, gp_Dir(0.0, 1.0, 0.0)); + const occ::handle aLine2 = new Geom_Line(aP2, gp_Dir(1.0, -1.0, 0.0)); + const occ::handle aLine3 = new Geom_Line(aP3, gp_Dir(-1.0, 0.0, 0.0)); + const TopoDS_Edge aEdge1 = BRepBuilderAPI_MakeEdge(aLine1, aVertex1, aVertex2).Edge(); + const TopoDS_Edge aEdge2 = BRepBuilderAPI_MakeEdge(aLine2, aVertex2, aVertex3).Edge(); + const TopoDS_Edge aEdge3 = BRepBuilderAPI_MakeEdge(aLine3, aVertex3, aVertex1).Edge(); + BRepBuilderAPI_MakeWire aWireBuilder; + aWireBuilder.Add(aEdge1); + aWireBuilder.Add(aEdge2); + aWireBuilder.Add(aEdge3); + ASSERT_TRUE(aWireBuilder.IsDone()); + const TopoDS_Face aFace = + BRepBuilderAPI_MakeFace(gp_Pln(gp_Pnt(0.0, 0.0, 0.0), gp_Dir(0.0, 0.0, 1.0)), + aWireBuilder.Wire()) + .Face(); + + AddNamingPrimitives(aLabel1, &aFace, 1); + const TopoDS_Shape aTriangleEdges[] = {aEdge1, aEdge2, aEdge3}; + AddNamingPrimitives(aLabel11, &aEdge1, 1); + AddNamingPrimitives(aLabel12, &aEdge2, 1); + AddNamingPrimitives(aLabel13, &aEdge3, 1); + + const TopoDS_Shape aPrism = BRepPrimAPI_MakePrism(aFace, gp_Vec(0.0, 0.0, 100.0), false).Shape(); + TopoDS_Shape aPrismFaces[6]; + const int aPrismFaceCount = CollectNamingSubShapes(aPrism, TopAbs_FACE, aPrismFaces, 6); + ASSERT_EQ(aPrismFaceCount, 5); + AddNamingPrimitives(aLabel2, &aPrism, 1); + + TopoDS_Shape aGeneratedOld[8]; + TopoDS_Shape aGeneratedNew[8]; + int aGeneratedCount = 0; + int aPrimitiveLabel = 2; + for (int aFaceIndex = 0; aFaceIndex < aPrismFaceCount; ++aFaceIndex) + { + TopoDS_Shape anEdges[8]; + const int anEdgeCount = + CollectNamingSubShapes(aPrismFaces[aFaceIndex], TopAbs_EDGE, anEdges, 8); + if (anEdgeCount == 4) + { + for (int anOldIndex = 0; anOldIndex < 3; ++anOldIndex) + { + for (int aNewIndex = 0; aNewIndex < 3; ++aNewIndex) + { + if (aTriangleEdges[anOldIndex].IsSame(anEdges[aNewIndex])) + { + if (aGeneratedCount < 8) + { + aGeneratedOld[aGeneratedCount] = aTriangleEdges[anOldIndex]; + aGeneratedNew[aGeneratedCount] = aPrismFaces[aFaceIndex]; + ++aGeneratedCount; + } + } + } + } + } + else + { + const TDF_Label aPrimitiveChild = aLabel2.FindChild(aPrimitiveLabel++, true); + AddNamingPrimitives(aPrimitiveChild, &aPrismFaces[aFaceIndex], 1); + } + } + ASSERT_EQ(aGeneratedCount, 3); + AddNamingGenerated(aLabel21, aGeneratedOld, aGeneratedNew, aGeneratedCount); + + const TopoDS_Shape aBox = BRepPrimAPI_MakeBox(gp_Pnt(0.0, 0.0, 20.0), 100.0, 100.0, 20.0).Shape(); + TopoDS_Shape aBoxFaces[6]; + ASSERT_EQ(CollectNamingSubShapes(aBox, TopAbs_FACE, aBoxFaces, 6), 6); + AddNamingPrimitives(aLabel3, &aBox, 1); + for (int aFaceIndex = 0; aFaceIndex < 6; ++aFaceIndex) + { + AddNamingPrimitives(aLabel3.FindChild(aFaceIndex + 1, true), &aBoxFaces[aFaceIndex], 1); + } + + const TopoDS_Shape aCut = BRepAlgoAPI_Cut(aPrism, aBox).Shape(); + ASSERT_FALSE(aCut.IsNull()); + TopoDS_Shape aCutFaces[16]; + const int aCutFaceCount = CollectNamingSubShapes(aCut, TopAbs_FACE, aCutFaces, 16); + ASSERT_EQ(aCutFaceCount, 10); + AddNamingModified(aLabel4, &aPrism, &aCut, 1); + + TopoDS_Shape aPX; + TopoDS_Shape aPY; + TopoDS_Shape aPXY; + for (int aFaceIndex = 0; aFaceIndex < aPrismFaceCount; ++aFaceIndex) + { + const gp_Pnt aCenter = NamingVertexAverage(aPrismFaces[aFaceIndex]); + if (NamingNear(aCenter.X(), 50.0)) + { + if (NamingNear(aCenter.Y(), 50.0)) + { + aPXY = aPrismFaces[aFaceIndex]; + } + else + { + aPX = aPrismFaces[aFaceIndex]; + } + } + else if (NamingNear(aCenter.Y(), 50.0)) + { + aPY = aPrismFaces[aFaceIndex]; + } + } + ASSERT_FALSE(aPX.IsNull()); + ASSERT_FALSE(aPY.IsNull()); + ASSERT_FALSE(aPXY.IsNull()); + + TopoDS_Shape aCutGeneratedOld[16]; + TopoDS_Shape aCutGeneratedNew[16]; + int aCutGeneratedCount = 0; + TopoDS_Shape aCutModifiedOld[8]; + TopoDS_Shape aCutModifiedNew[8]; + int aCutModifiedCount = 0; + for (int aFaceIndex = 0; aFaceIndex < aCutFaceCount; ++aFaceIndex) + { + const gp_Pnt aCenter = NamingVertexAverage(aCutFaces[aFaceIndex]); + if (NamingNear(aCenter.X(), 50.0)) + { + const TopoDS_Shape& anOldShape = NamingNear(aCenter.Y(), 50.0) ? aPXY : aPX; + aCutGeneratedOld[aCutGeneratedCount] = anOldShape; + aCutGeneratedNew[aCutGeneratedCount++] = aCutFaces[aFaceIndex]; + } + else if (NamingNear(aCenter.Y(), 50.0)) + { + aCutGeneratedOld[aCutGeneratedCount] = aPY; + aCutGeneratedNew[aCutGeneratedCount++] = aCutFaces[aFaceIndex]; + } + else if (NamingNear(aCenter.Z(), 20.0)) + { + aCutModifiedOld[aCutModifiedCount] = aBoxFaces[4]; + aCutModifiedNew[aCutModifiedCount++] = aCutFaces[aFaceIndex]; + } + else if (NamingNear(aCenter.Z(), 40.0)) + { + aCutModifiedOld[aCutModifiedCount] = aBoxFaces[5]; + aCutModifiedNew[aCutModifiedCount++] = aCutFaces[aFaceIndex]; + } + } + ASSERT_EQ(aCutGeneratedCount, 6); + ASSERT_EQ(aCutModifiedCount, 2); + + TopoDS_Shape aReversedGeneratedOld[16]; + TopoDS_Shape aReversedGeneratedNew[16]; + for (int anIndex = 0; anIndex < aCutGeneratedCount; ++anIndex) + { + aReversedGeneratedOld[anIndex] = aCutGeneratedOld[aCutGeneratedCount - anIndex - 1]; + aReversedGeneratedNew[anIndex] = aCutGeneratedNew[aCutGeneratedCount - anIndex - 1]; + } + AddNamingModified(aLabel41, aReversedGeneratedOld, aReversedGeneratedNew, aCutGeneratedCount); + + TopoDS_Shape aGenerated42Old[8]; + TopoDS_Shape aGenerated42New[8]; + for (int anIndex = 0; anIndex < aCutModifiedCount; ++anIndex) + { + aGenerated42Old[anIndex] = aCutModifiedOld[aCutModifiedCount - anIndex - 1]; + aGenerated42New[anIndex] = aCutModifiedNew[aCutModifiedCount - anIndex - 1]; + } + aGenerated42Old[aCutModifiedCount] = aBoxFaces[0]; + aGenerated42New[aCutModifiedCount] = aBoxFaces[0]; + AddNamingGenerated(aLabel42, aGenerated42Old, aGenerated42New, aCutModifiedCount + 1); + + ExpectNamingLabel(aEdge1, aLabel11, aRoot); + ExpectNamingLabel(aEdge2, aLabel12, aRoot); + ExpectNamingLabel(aEdge3, aLabel13, aRoot); + ExpectNamingLabel(aPrism, aLabel2, aRoot); + ExpectNamingLabel(aPrismFaces[0], aLabel21, aRoot); + ExpectNamingLabel(aPrismFaces[1], aLabel21, aRoot); + ExpectNamingLabel(aPrismFaces[2], aLabel21, aRoot); + ExpectNamingLabel(aPrismFaces[4], aLabel2.FindChild(3, true), aRoot); + ExpectNamingLabel(aBox, aLabel3, aRoot); + for (int aFaceIndex = 0; aFaceIndex < 6; ++aFaceIndex) + { + ExpectNamingLabel(aBoxFaces[aFaceIndex], aLabel3.FindChild(aFaceIndex + 1, true), aRoot); + } + ExpectNamingLabel(aCut, aLabel4, aRoot); + const TDF_Label aLabel23 = aLabel2.FindChild(3, true); + for (int aFaceIndex = 0; aFaceIndex < aCutFaceCount; ++aFaceIndex) + { + const gp_Pnt aCenter = NamingVertexAverage(aCutFaces[aFaceIndex]); + if (aCutFaces[aFaceIndex].IsSame(aPrismFaces[3])) + { + ExpectNamingLabel(aCutFaces[aFaceIndex], aLabel1, aRoot); + } + else if (aCutFaces[aFaceIndex].IsSame(aPrismFaces[4])) + { + ExpectNamingLabel(aCutFaces[aFaceIndex], aLabel23, aRoot); + } + else if (NamingNear(aCenter.X(), 50.0) || NamingNear(aCenter.Y(), 50.0)) + { + ExpectNamingLabel(aCutFaces[aFaceIndex], aLabel41, aRoot); + } + else if (NamingNear(aCenter.Z(), 20.0) || NamingNear(aCenter.Z(), 40.0)) + { + ExpectNamingLabel(aCutFaces[aFaceIndex], aLabel42, aRoot); + } + else + { + ADD_FAILURE() << "Unclassified cut face in A3 naming graph"; + } + } + + ExpectNamingShape(aLabel1, aFace); + ExpectNamingShape(aLabel11, aEdge1); + ExpectNamingShape(aLabel12, aEdge2); + ExpectNamingShape(aLabel13, aEdge3); + ExpectNamingCurrentShape(aLabel2, aCut); + ExpectNamingGetShape(aLabel2, aPrism); + ExpectNamingShape(aLabel2.FindChild(2, true), aPrismFaces[3]); + ExpectNamingShape(aLabel2.FindChild(3, true), aPrismFaces[4]); + ExpectNamingShape(aLabel3, aBox); + for (int aFaceIndex = 0; aFaceIndex < 6; ++aFaceIndex) + { + ExpectNamingShape(aLabel3.FindChild(aFaceIndex + 1, true), aBoxFaces[aFaceIndex]); + } + ExpectNamingShape(aLabel4, aCut); + ExpectNamingCompoundFaces(aLabel21, 6, 3); + ExpectNamingCompoundFaces(aLabel41, 6, 6); + ExpectNamingCompoundFaces(aLabel42, 2, 2); + + const TDF_Label aSelectionRoot = aTestLabel.FindChild(10, true); + TNaming_Selector aSelector1(aSelectionRoot.FindChild(1, true)); + TNaming_Selector aSelector2(aSelectionRoot.FindChild(2, true)); + TNaming_Selector aSelector3(aSelectionRoot.FindChild(3, true)); + TNaming_Selector aSelector4(aSelectionRoot.FindChild(4, true)); + TNaming_Selector aSelector5(aSelectionRoot.FindChild(5, true)); + TNaming_Selector aSelector6(aSelectionRoot.FindChild(6, true)); + const TopoDS_Shape aFirstFaceVertex = NamingSubShape(aFace, TopAbs_VERTEX, 1); + const TopoDS_Shape aFirstBoxEdge = NamingSubShape(aBox, TopAbs_EDGE, 1); + const TopoDS_Shape aFirstBoxVertex = NamingSubShape(aBox, TopAbs_VERTEX, 1); + ASSERT_TRUE(aSelector1.Select(aFace, false)); + ASSERT_TRUE(aSelector2.Select(aEdge1, aFace, false)); + ASSERT_TRUE(aSelector3.Select(aEdge2, false)); + ASSERT_TRUE(aSelector4.Select(aFirstFaceVertex, aFace, false)); + ASSERT_TRUE(aSelector5.Select(aFirstBoxEdge, aBox, false)); + ASSERT_TRUE(aSelector6.Select(aFirstBoxVertex, aBox, false)); + EXPECT_TRUE(TNaming_Tool::GetShape(aSelector1.NamedShape()).IsSame(aFace)); + EXPECT_TRUE(TNaming_Tool::GetShape(aSelector2.NamedShape()).IsSame(aEdge1)); + EXPECT_TRUE(TNaming_Tool::GetShape(aSelector3.NamedShape()).IsSame(aEdge2)); + EXPECT_TRUE(TNaming_Tool::GetShape(aSelector4.NamedShape()).IsSame(aFirstFaceVertex)); + EXPECT_TRUE(TNaming_Tool::GetShape(aSelector5.NamedShape()).IsSame(aFirstBoxEdge)); + EXPECT_TRUE(TNaming_Tool::GetShape(aSelector6.NamedShape()).IsSame(aFirstBoxVertex)); + + NCollection_Map aValidLabels; + aValidLabels.Add(aLabel11); + EXPECT_FALSE(aSelector4.Solve(aValidLabels)); +} + +// caf/bugs/buc60847: a generated box is available through TNaming_Naming. +TEST_F(TNaming_ToolTest, Buc_CafBug_60847_GeneratedBoxNaming) +{ + const TDF_Label aLabel = myRoot.FindChild(2, true); + const TopoDS_Shape aBox = MakeBox(10.0, 20.0, 30.0); + TNaming_Builder aBuilder(aLabel); + aBuilder.Generated(aBox); + + const occ::handle aNamedShape = TNaming_Naming::Name(aLabel, aBox, aBox); + ASSERT_FALSE(aNamedShape.IsNull()); + EXPECT_FALSE(aNamedShape->IsEmpty()); + EXPECT_TRUE(TNaming_Tool::GetShape(aNamedShape).IsSame(aBox)); +} + +// caf/bugs/buc60862: a generated edge follows the same naming path as a box. +TEST_F(TNaming_ToolTest, Buc_CafBug_60862_GeneratedEdgeNaming) +{ + const TDF_Label aLabel = myRoot.FindChild(2, true); + const TopoDS_Shape anEdge = + BRepBuilderAPI_MakeEdge(gp_Pnt(10.0, 20.0, 0.0), gp_Pnt(20.0, 10.0, 0.0)).Shape(); + ASSERT_FALSE(anEdge.IsNull()); + TNaming_Builder aBuilder(aLabel); + aBuilder.Generated(anEdge); + + const occ::handle aNamedShape = TNaming_Naming::Name(aLabel, anEdge, anEdge); + ASSERT_FALSE(aNamedShape.IsNull()); + EXPECT_FALSE(aNamedShape->IsEmpty()); + EXPECT_TRUE(TNaming_Tool::GetShape(aNamedShape).IsSame(anEdge)); +} + +// caf/bugs/bug23799: copying a selection remains safe after its imported +// source label has forgotten its own attributes. +TEST_F(TNaming_ToolTest, CafBug_23799_CopySelectionAfterSourceForget) +{ + const TopoDS_Shape aSphere = BRepPrimAPI_MakeSphere(100.0).Shape(); + ASSERT_FALSE(aSphere.IsNull()); + + const TDF_Label aSourceLabel = myRoot.FindChild(1, true); + DNaming::LoadImportedShape(aSourceLabel, aSphere); + + TopExp_Explorer aFaceExplorer(aSphere, TopAbs_FACE); + ASSERT_TRUE(aFaceExplorer.More()); + const TopoDS_Shape aFace = aFaceExplorer.Current(); + + const TDF_Label aSelectionLabel = myRoot.FindChild(2, true); + TNaming_Selector aSelector(aSelectionLabel); + ASSERT_TRUE(aSelector.Select(aFace, true)); + aSourceLabel.ForgetAllAttributes(); + + const TDF_Label aCopyLabel = myRoot.FindChild(3, true); + TDF_CopyLabel aCopier; + aCopier.Load(aSelectionLabel, aCopyLabel); + aCopier.Perform(); + EXPECT_TRUE(aCopier.IsDone()); +} + +// bugs/caf/bug25153: retrieving selection arguments remains safe after the +// imported source label has forgotten its attributes. +TEST(TNaming_Tool_Test, CafBug_25153_ArgumentsAfterSourceForget) +{ + occ::handle aData = new TDF_Data(); + const TDF_Label aRoot = aData->Root(); + const TDF_Label aSourceLabel = aRoot.FindChild(1, true); + const TDF_Label aSelectionLabel = aRoot.FindChild(2, true); + const TopoDS_Face aFace = + BRepBuilderAPI_MakeFace(gp_Pln(gp_Pnt(0.0, 0.0, 0.0), gp_Dir(0.0, 0.0, 1.0)), + -100.0, + 100.0, + -100.0, + 100.0) + .Face(); + DNaming::LoadImportedShape(aSourceLabel, aFace); + + TNaming_Selector aSelector(aSelectionLabel); + ASSERT_TRUE(aSelector.Select(aFace, false)); + aSourceLabel.ForgetAllAttributes(); + + NCollection_Map> anArguments; + EXPECT_NO_THROW(aSelector.Arguments(anArguments)); +} + +// bugs/caf/bug26061: selecting a translated mirrored face does not throw and +// resolves to the current shape of the modified named-shape history. +TEST(TNaming_Tool_Test, CafBug_26061_TranslatedMirroredSelection) +{ + occ::handle aData = new TDF_Data(); + const TDF_Label aRoot = aData->Root(); + const TopoDS_Face aFace = + BRepBuilderAPI_MakeFace(gp_Pln(gp_Pnt(0.0, 0.0, 0.0), gp_Dir(0.0, 0.0, 1.0)), + -10.0, + 10.0, + -10.0, + 10.0) + .Face(); + + gp_Trsf aMirror; + aMirror.SetMirror(gp_Ax2(gp_Pnt(0.0, 0.0, 10.0), gp_Dir(0.0, 0.0, 1.0))); + const TopoDS_Shape aMirroredFace = BRepBuilderAPI_Transform(aFace, aMirror).Shape(); + gp_Trsf aTranslation; + aTranslation.SetTranslation(gp_Vec(0.0, 0.0, -5.0)); + const TopoDS_Shape aTranslatedFace = BRepBuilderAPI_Transform(aFace, aTranslation).Shape(); + const TopoDS_Shape aTranslatedMirroredFace = + BRepBuilderAPI_Transform(aMirroredFace, aTranslation).Shape(); + + TNaming_Builder aPrimitiveBuilder(aRoot.FindChild(900, true)); + aPrimitiveBuilder.Generated(aFace); + TNaming_Builder aMirrorBuilder(aRoot.FindChild(901, true)); + aMirrorBuilder.Generated(aFace, aMirroredFace); + TNaming_Builder aTranslationBuilder(aRoot.FindChild(902, true)); + aTranslationBuilder.Modify(aFace, aTranslatedFace); + TNaming_Builder aMirroredTranslationBuilder(aRoot.FindChild(903, true)); + aMirroredTranslationBuilder.Modify(aMirroredFace, aTranslatedMirroredFace); + + occ::handle aModifiedShape; + ASSERT_TRUE( + aRoot.FindChild(903, true).FindAttribute(TNaming_NamedShape::GetID(), aModifiedShape)); + const TopoDS_Shape aCurrentShape = TNaming_Tool::GetShape(aModifiedShape); + ASSERT_FALSE(aCurrentShape.IsNull()); + + TNaming_Selector aSelector(aRoot.FindChild(904, true)); + ASSERT_TRUE(aSelector.Select(aCurrentShape, false)); + occ::handle aSelection = aSelector.NamedShape(); + ASSERT_FALSE(aSelection.IsNull()); + EXPECT_TRUE(TNaming_Tool::GetShape(aSelection).IsSame(aTranslatedMirroredFace)); +} + +// bugs/caf/bug26428: both named-shape iterators can be constructed when the +// named shape contains only a generated (new) shape. +TEST(TNaming_Tool_Test, CafBug_26428_NewAndOldShapeIterators) +{ + occ::handle aData = new TDF_Data(); + const TDF_Label aLabel = aData->Root().FindChild(1, true); + const TopoDS_Shape aBox = BRepPrimAPI_MakeBox(10.0, 20.0, 30.0).Shape(); + TNaming_Builder aBuilder(aLabel); + aBuilder.Generated(aBox); + + TNaming_Iterator aNameIterator(aLabel); + TNaming_NewShapeIterator aNewIterator(aNameIterator); + TNaming_OldShapeIterator anOldIterator(aNameIterator); + EXPECT_NO_THROW({ + (void)aNewIterator.More(); + (void)anOldIterator.More(); + }); + + occ::handle aNamedShape; + ASSERT_TRUE(aLabel.FindAttribute(TNaming_NamedShape::GetID(), aNamedShape)); + EXPECT_TRUE(TNaming_Tool::GetShape(aNamedShape).IsSame(aBox)); +} + +// bugs/caf/bug24263: TNaming_CopyShape copies a solid and its faces while +// preserving the orientation carried by each source shape. +TEST(TNaming_Tool_Test, CafBug_24263_CopyShapePreservesOrientation) +{ + const TopoDS_Shape aBox = BRepPrimAPI_MakeBox(100.0, 100.0, 100.0).Shape(); + TNaming_Translator aTranslator; + aTranslator.Add(aBox); + + int aNbFaces = 0; + int aNbReversedFaces = 0; + for (TopExp_Explorer anExplorer(aBox, TopAbs_FACE); anExplorer.More(); anExplorer.Next()) + { + aTranslator.Add(anExplorer.Current()); + ++aNbFaces; + aNbReversedFaces += anExplorer.Current().Orientation() == TopAbs_REVERSED ? 1 : 0; + } + ASSERT_EQ(aNbFaces, 6); + ASSERT_GT(aNbReversedFaces, 0); + + aTranslator.Perform(); + ASSERT_TRUE(aTranslator.IsDone()); + const TopoDS_Shape aCopiedBox = aTranslator.Copied(aBox); + ASSERT_FALSE(aCopiedBox.IsNull()); + EXPECT_EQ(aCopiedBox.Orientation(), TopAbs_FORWARD); + + int aCopiedFaceCount = 0; + int aCopiedReversedFaceCount = 0; + for (TopExp_Explorer anExplorer(aBox, TopAbs_FACE); anExplorer.More(); anExplorer.Next()) + { + const TopoDS_Shape aCopiedFace = aTranslator.Copied(anExplorer.Current()); + ASSERT_FALSE(aCopiedFace.IsNull()); + EXPECT_EQ(aCopiedFace.Orientation(), anExplorer.Current().Orientation()); + ++aCopiedFaceCount; + aCopiedReversedFaceCount += aCopiedFace.Orientation() == TopAbs_REVERSED ? 1 : 0; + } + EXPECT_EQ(aCopiedFaceCount, aNbFaces); + EXPECT_EQ(aCopiedReversedFaceCount, aNbReversedFaces); +} + +// bugs/caf/bug26155: the order of a modified compound must remain stable +// when the same naming sequence is evaluated repeatedly. +TEST(TNaming_Tool_Test, CafBug_26155_ModificationOrderStable) +{ + const occ::handle aDocument = NewNamingDocument(); + ASSERT_FALSE(aDocument.IsNull()); + + const double aTolerance = 0.1; + double aReferenceX = 0.0; + bool hasReference = false; + for (int anIndex = 1; anIndex <= 50; ++anIndex) + { + TCollection_AsciiString aPrimitiveEntry(anIndex); + aPrimitiveEntry += ":1:1"; + TDF_Label aPrimitiveLabel; + TDF_Tool::Label(aDocument->GetData(), aPrimitiveEntry, aPrimitiveLabel, true); + ASSERT_FALSE(aPrimitiveLabel.IsNull()); + + const TopoDS_Shape aBox = BRepPrimAPI_MakeBox(10.0, 10.0, 10.0).Shape(); + TNaming_Builder aPrimitiveBuilder(aPrimitiveLabel); + aPrimitiveBuilder.Generated(aBox); + + const TopoDS_Shape aFirstHalf = + BRepPrimAPI_MakeBox(gp_Pnt(0.0, 0.0, 0.0), gp_Pnt(5.0, 10.0, 10.0)).Shape(); + const TopoDS_Shape aSecondHalf = + BRepPrimAPI_MakeBox(gp_Pnt(5.0, 0.0, 0.0), gp_Pnt(10.0, 10.0, 10.0)).Shape(); + + TCollection_AsciiString aFirstModificationEntry = aPrimitiveEntry; + aFirstModificationEntry += ":1"; + TDF_Label aFirstModificationLabel; + TDF_Tool::Label(aDocument->GetData(), aFirstModificationEntry, aFirstModificationLabel, true); + TNaming_Builder aFirstModificationBuilder(aFirstModificationLabel); + aFirstModificationBuilder.Modify(aBox, aFirstHalf); + + TCollection_AsciiString aSecondModificationEntry = aPrimitiveEntry; + aSecondModificationEntry += ":2"; + TDF_Label aSecondModificationLabel; + TDF_Tool::Label(aDocument->GetData(), aSecondModificationEntry, aSecondModificationLabel, true); + TNaming_Builder aSecondModificationBuilder(aSecondModificationLabel); + aSecondModificationBuilder.Modify(aBox, aSecondHalf); + + occ::handle aNamedShape; + ASSERT_TRUE(aPrimitiveLabel.FindAttribute(TNaming_NamedShape::GetID(), aNamedShape)); + const TopoDS_Shape aCurrentShape = TNaming_Tool::CurrentShape(aNamedShape); + ASSERT_FALSE(aCurrentShape.IsNull()); + + TopoDS_Shape aFirstSolid; + for (TopoDS_Iterator anIterator(aCurrentShape); anIterator.More(); anIterator.Next()) + { + if (anIterator.Value().ShapeType() == TopAbs_SOLID) + { + aFirstSolid = anIterator.Value(); + break; + } + } + ASSERT_FALSE(aFirstSolid.IsNull()); + + GProp_GProps aProperties; + BRepGProp::VolumeProperties(aFirstSolid, aProperties); + const double aCurrentX = aProperties.CentreOfMass().X(); + if (!hasReference) + { + aReferenceX = aCurrentX; + hasReference = true; + } + else + { + EXPECT_LE(std::abs(aCurrentX - aReferenceX), aTolerance); + } + } +} diff --git a/src/ApplicationFramework/TKLCAF/GTests/FILES.cmake b/src/ApplicationFramework/TKLCAF/GTests/FILES.cmake index dc8c6669e4..cc1f23a708 100644 --- a/src/ApplicationFramework/TKLCAF/GTests/FILES.cmake +++ b/src/ApplicationFramework/TKLCAF/GTests/FILES.cmake @@ -3,8 +3,14 @@ set(OCCT_TKLCAF_GTests_FILES_LOCATION "${CMAKE_CURRENT_LIST_DIR}") set(OCCT_TKLCAF_GTests_FILES TDataStd_Attribute_Test.cxx + TDataStd_Expression_Test.cxx + TDataStd_List_Test.cxx TDataStd_TreeNode_Test.cxx TDF_AttributeIterator_Test.cxx + TDF_Copy_Test.cxx + TDocStd_Application_Test.cxx + TDocStd_Transaction_Test.cxx + TDocStd_XLink_Test.cxx TNaming_Builder_Test.cxx TNaming_Name_Test.cxx ) diff --git a/src/ApplicationFramework/TKLCAF/GTests/TDF_AttributeIterator_Test.cxx b/src/ApplicationFramework/TKLCAF/GTests/TDF_AttributeIterator_Test.cxx index 67dd72a3b5..0422810656 100644 --- a/src/ApplicationFramework/TKLCAF/GTests/TDF_AttributeIterator_Test.cxx +++ b/src/ApplicationFramework/TKLCAF/GTests/TDF_AttributeIterator_Test.cxx @@ -58,3 +58,34 @@ TEST(TDF_AttributeIterator_Test, OCC24755_AttributeInsertionOrder) anIter.Next(); EXPECT_FALSE(anIter.More()) << "Iterator should have no more attributes"; } + +// caf/basic/B8: attribute order survives an undo/redo round trip. +TEST(TDF_AttributeIterator_Test, CafBasic_B8_AttributeOrderAfterUndoRedo) +{ + occ::handle aDoc = new TDocStd_Document("BinOcaf"); + const TDF_Label aLabel = aDoc->Main().FindChild(1, true); + aDoc->NewCommand(); + TDataStd_Integer::Set(aLabel, 123); + TDataStd_Real::Set(aLabel, 123.321); + aDoc->NewCommand(); + + TDF_AttributeIterator anIterator(aLabel); + ASSERT_TRUE(anIterator.More()); + EXPECT_TRUE(anIterator.Value()->IsKind(STANDARD_TYPE(TDataStd_Integer))); + anIterator.Next(); + ASSERT_TRUE(anIterator.More()); + EXPECT_TRUE(anIterator.Value()->IsKind(STANDARD_TYPE(TDataStd_Real))); + anIterator.Next(); + EXPECT_FALSE(anIterator.More()); + + aDoc->Undo(); + aDoc->Redo(); + anIterator.Initialize(aLabel); + ASSERT_TRUE(anIterator.More()); + EXPECT_TRUE(anIterator.Value()->IsKind(STANDARD_TYPE(TDataStd_Integer))); + anIterator.Next(); + ASSERT_TRUE(anIterator.More()); + EXPECT_TRUE(anIterator.Value()->IsKind(STANDARD_TYPE(TDataStd_Real))); + anIterator.Next(); + EXPECT_FALSE(anIterator.More()); +} diff --git a/src/ApplicationFramework/TKLCAF/GTests/TDF_Copy_Test.cxx b/src/ApplicationFramework/TKLCAF/GTests/TDF_Copy_Test.cxx new file mode 100644 index 0000000000..c669b9f781 --- /dev/null +++ b/src/ApplicationFramework/TKLCAF/GTests/TDF_Copy_Test.cxx @@ -0,0 +1,110 @@ +// Copyright (c) 2026 OPEN CASCADE SAS +// +// This file is part of Open CASCADE Technology software library. +// +// This library is free software; you can redistribute it and/or modify it under +// the terms of the GNU Lesser General Public License version 2.1 as published +// by the Free Software Foundation, with special exception defined in the file +// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT +// distribution for complete text of the license and disclaimer of any warranty. +// +// Alternatively, this file may be used under the terms of Open CASCADE +// commercial license or contractual agreement. + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace +{ +static occ::handle NewCopyDocument() +{ + return new TDocStd_Document("BinOcaf"); +} + +static TDF_Label RootChild(const occ::handle& theDocument, const int theTag) +{ + return theDocument->Main().Root().FindChild(theTag, true); +} + +static void ExpectCopiedLabel(const TDF_Label& theLabel, + const TCollection_ExtendedString& theExpectedName, + const double theExpectedReal) +{ + occ::handle aName; + if (!theLabel.FindAttribute(TDataStd_Name::GetID(), aName)) + { + ADD_FAILURE() << "Name attribute is missing"; + return; + } + EXPECT_TRUE(aName->Get().IsEqual(theExpectedName)); + occ::handle aReal; + if (!theLabel.FindAttribute(TDataStd_Real::GetID(), aReal)) + { + ADD_FAILURE() << "Real attribute is missing"; + return; + } + EXPECT_DOUBLE_EQ(aReal->Get(), theExpectedReal); +} +} // namespace + +// caf/bugs/buc60813: TDF_CopyLabel can copy a label repeatedly without losing +// the copied name or real attribute. +TEST(TDF_Copy_Test, Buc_CafBug_60813_CopyLabelTwice) +{ + occ::handle aDocument = NewCopyDocument(); + aDocument->SetUndoLimit(100); + aDocument->NewCommand(); + + const TDF_Label aSource = aDocument->Main(); + const TDF_Label aTarget1 = RootChild(aDocument, 2); + const TDF_Label aTarget2 = RootChild(aDocument, 3); + TDataStd_Name::Set(aSource, TCollection_ExtendedString("SourceLabel")); + TDataStd_Real::Set(aSource, 3.1415); + + TDF_CopyLabel aFirstCopy; + aFirstCopy.Load(aSource, aTarget1); + aFirstCopy.Perform(); + ASSERT_TRUE(aFirstCopy.IsDone()); + ExpectCopiedLabel(aTarget1, TCollection_ExtendedString("SourceLabel"), 3.1415); + + TDF_CopyLabel aSecondCopy; + aSecondCopy.Load(aTarget1, aTarget2); + aSecondCopy.Perform(); + ASSERT_TRUE(aSecondCopy.IsDone()); + ExpectCopiedLabel(aTarget2, TCollection_ExtendedString("SourceLabel"), 3.1415); +} + +// caf/bugs/bug22976: CopyDF copies the content of a label, not only the label +// itself. +TEST(TDF_Copy_Test, CafBug_22976_CopyDataFrameworkLabel) +{ + occ::handle aDocument = NewCopyDocument(); + aDocument->SetUndoLimit(100); + aDocument->NewCommand(); + + const TDF_Label aSource = aDocument->Main(); + const TDF_Label aTarget = RootChild(aDocument, 2); + TDataStd_Real::Set(aSource, 1.2345); + + occ::handle aDataSet = new TDF_DataSet(); + aDataSet->AddLabel(aSource); + TDF_ClosureTool::Closure(aDataSet); + + occ::handle aRelocation = new TDF_RelocationTable(); + aRelocation->SetRelocation(aSource, aTarget); + TDF_CopyTool::Copy(aDataSet, aRelocation); + + occ::handle aCopiedReal; + ASSERT_TRUE(aTarget.FindAttribute(TDataStd_Real::GetID(), aCopiedReal)); + EXPECT_DOUBLE_EQ(aCopiedReal->Get(), 1.2345); +} diff --git a/src/ApplicationFramework/TKLCAF/GTests/TDataStd_Attribute_Test.cxx b/src/ApplicationFramework/TKLCAF/GTests/TDataStd_Attribute_Test.cxx index eb8dbe0360..baa15e7763 100644 --- a/src/ApplicationFramework/TKLCAF/GTests/TDataStd_Attribute_Test.cxx +++ b/src/ApplicationFramework/TKLCAF/GTests/TDataStd_Attribute_Test.cxx @@ -15,6 +15,7 @@ #include #include #include +#include #include #include #include @@ -26,13 +27,62 @@ #include #include #include +#include +#include +#include #include #include +#include #include +#include +#include #include +#include +#include +#include #include +namespace +{ +static occ::handle NewDocument() +{ + occ::handle aDocument = new TDocStd_Document("BinOcaf"); + aDocument->SetUndoLimit(10); + return aDocument; +} + +static TDF_Label NewAttributeLabel(const occ::handle& theDocument) +{ + return theDocument->Main().FindChild(2, true); +} + +static void ExpectRealArray(const occ::handle& theArray, + const double theFirst, + const double theSecond) +{ + ASSERT_FALSE(theArray.IsNull()); + EXPECT_EQ(theArray->Lower(), 1); + EXPECT_EQ(theArray->Upper(), 2); + EXPECT_EQ(theArray->Length(), 2); + EXPECT_DOUBLE_EQ(theArray->Value(1), theFirst); + EXPECT_DOUBLE_EQ(theArray->Value(2), theSecond); +} + +static void ExpectIntegerArray(const occ::handle& theArray, + const int theFirst, + const int theSecond) +{ + ASSERT_FALSE(theArray.IsNull()); + EXPECT_EQ(theArray->Lower(), 1); + EXPECT_EQ(theArray->Upper(), 2); + EXPECT_EQ(theArray->Length(), 2); + EXPECT_EQ(theArray->Value(1), theFirst); + EXPECT_EQ(theArray->Value(2), theSecond); +} + +} // namespace + TEST(TDataStd_Attribute_Test, OCC29371_AttributeGUIDsNotNull) { // Create document and label @@ -107,3 +157,789 @@ TEST(TDataStd_Attribute_Test, OCC29371_AttributeGUIDsNotNull) anApp->Close(aDoc); } + +// caf/basic/A1: setting and retrieving the default integer attribute. +TEST(TDataStd_Attribute_Test, CafBasic_A1_IntegerSetGet) +{ + occ::handle aDoc = NewDocument(); + const TDF_Label aLabel = NewAttributeLabel(aDoc); + occ::handle anInteger = TDataStd_Integer::Set(aLabel, 100); + + ASSERT_FALSE(anInteger.IsNull()); + EXPECT_EQ(anInteger->Get(), 100); +} + +// caf/basic/A2: undoing a replacement restores the previous integer value. +TEST(TDataStd_Attribute_Test, CafBasic_A2_IntegerUndo) +{ + occ::handle aDoc = NewDocument(); + TDF_Label aLabel = NewAttributeLabel(aDoc); + TDataStd_Integer::Set(aLabel, 100); + aDoc->NewCommand(); + TDataStd_Integer::Set(aLabel, 200); + aDoc->NewCommand(); + aDoc->Undo(); + + occ::handle anInteger; + ASSERT_TRUE(aLabel.FindAttribute(TDataStd_Integer::GetID(), anInteger)); + EXPECT_EQ(anInteger->Get(), 100); +} + +// caf/basic/A4-A5: two user GUIDs identify independent integer attributes. +TEST(TDataStd_Attribute_Test, CafBasic_A4_IntegerUserGuids) +{ + occ::handle aDoc = NewDocument(); + const TDF_Label aLabel = NewAttributeLabel(aDoc); + const Standard_GUID aGuid1("12e94541-6dbc-11d4-b9c8-0060b0ee281b"); + const Standard_GUID aGuid2("12e94542-6dbc-11d4-b9c8-0060b0ee281b"); + TDataStd_Integer::Set(aLabel, aGuid1, 100); + TDataStd_Integer::Set(aLabel, aGuid2, 200); + + occ::handle anInteger1; + occ::handle anInteger2; + ASSERT_TRUE(aLabel.FindAttribute(aGuid1, anInteger1)); + ASSERT_TRUE(aLabel.FindAttribute(aGuid2, anInteger2)); + EXPECT_EQ(anInteger1->Get(), 100); + EXPECT_EQ(anInteger2->Get(), 200); +} + +TEST(TDataStd_Attribute_Test, CafBasic_A5_IntegerUserGuidUndo) +{ + occ::handle aDoc = NewDocument(); + const TDF_Label aLabel = NewAttributeLabel(aDoc); + const Standard_GUID aGuid1("12e94541-6dbc-11d4-b9c8-0060b0ee281b"); + const Standard_GUID aGuid2("12e94542-6dbc-11d4-b9c8-0060b0ee281b"); + TDataStd_Integer::Set(aLabel, aGuid1, 100); + TDataStd_Integer::Set(aLabel, aGuid2, 200); + aDoc->NewCommand(); + TDataStd_Integer::Set(aLabel, aGuid1, 199); + TDataStd_Integer::Set(aLabel, aGuid2, 299); + aDoc->NewCommand(); + aDoc->Undo(); + + occ::handle anInteger1; + occ::handle anInteger2; + ASSERT_TRUE(aLabel.FindAttribute(aGuid1, anInteger1)); + ASSERT_TRUE(aLabel.FindAttribute(aGuid2, anInteger2)); + EXPECT_EQ(anInteger1->Get(), 100); + EXPECT_EQ(anInteger2->Get(), 200); +} + +// caf/basic/B1-B2: scalar real values support replacement and undo. +TEST(TDataStd_Attribute_Test, CafBasic_B1_RealSetGet) +{ + occ::handle aDoc = NewDocument(); + const TDF_Label aLabel = NewAttributeLabel(aDoc); + occ::handle aReal = TDataStd_Real::Set(aLabel, 100.0); + + ASSERT_FALSE(aReal.IsNull()); + EXPECT_DOUBLE_EQ(aReal->Get(), 100.0); +} + +TEST(TDataStd_Attribute_Test, CafBasic_B2_RealUndo) +{ + occ::handle aDoc = NewDocument(); + const TDF_Label aLabel = NewAttributeLabel(aDoc); + TDataStd_Real::Set(aLabel, 100.0); + aDoc->NewCommand(); + TDataStd_Real::Set(aLabel, 200.0); + aDoc->NewCommand(); + aDoc->Undo(); + + occ::handle aReal; + ASSERT_TRUE(aLabel.FindAttribute(TDataStd_Real::GetID(), aReal)); + EXPECT_DOUBLE_EQ(aReal->Get(), 100.0); +} + +TEST(TDataStd_Attribute_Test, CafBasic_B4_RealUserGuids) +{ + occ::handle aDoc = NewDocument(); + const TDF_Label aLabel = NewAttributeLabel(aDoc); + const Standard_GUID aGuid1("12e94551-6dbc-11d4-b9c8-0060b0ee281b"); + const Standard_GUID aGuid2("12e94552-6dbc-11d4-b9c8-0060b0ee281b"); + TDataStd_Real::Set(aLabel, aGuid1, 100.11); + TDataStd_Real::Set(aLabel, aGuid2, 200.11); + + occ::handle aReal1; + occ::handle aReal2; + ASSERT_TRUE(aLabel.FindAttribute(aGuid1, aReal1)); + ASSERT_TRUE(aLabel.FindAttribute(aGuid2, aReal2)); + EXPECT_DOUBLE_EQ(aReal1->Get(), 100.11); + EXPECT_DOUBLE_EQ(aReal2->Get(), 200.11); +} + +TEST(TDataStd_Attribute_Test, CafBasic_B5_RealUserGuidUndo) +{ + occ::handle aDoc = NewDocument(); + const TDF_Label aLabel = NewAttributeLabel(aDoc); + const Standard_GUID aGuid1("12e94551-6dbc-11d4-b9c8-0060b0ee281b"); + const Standard_GUID aGuid2("12e94552-6dbc-11d4-b9c8-0060b0ee281b"); + TDataStd_Real::Set(aLabel, aGuid1, 100.11); + TDataStd_Real::Set(aLabel, aGuid2, 200.11); + aDoc->NewCommand(); + TDataStd_Real::Set(aLabel, aGuid1, 199.11); + TDataStd_Real::Set(aLabel, aGuid2, 299.11); + aDoc->NewCommand(); + aDoc->Undo(); + + occ::handle aReal1; + occ::handle aReal2; + ASSERT_TRUE(aLabel.FindAttribute(aGuid1, aReal1)); + ASSERT_TRUE(aLabel.FindAttribute(aGuid2, aReal2)); + EXPECT_DOUBLE_EQ(aReal1->Get(), 100.11); + EXPECT_DOUBLE_EQ(aReal2->Get(), 200.11); +} + +// caf/basic/C1-C2: real arrays retain bounds, values, and undo state. +TEST(TDataStd_Attribute_Test, CafBasic_C1_RealArraySetGet) +{ + occ::handle aDoc = NewDocument(); + const TDF_Label aLabel = NewAttributeLabel(aDoc); + occ::handle anArray = TDataStd_RealArray::Set(aLabel, 1, 2); + anArray->SetValue(1, 3.0); + anArray->SetValue(2, 4.0); + + ExpectRealArray(anArray, 3.0, 4.0); +} + +TEST(TDataStd_Attribute_Test, CafBasic_C2_RealArrayUndo) +{ + occ::handle aDoc = NewDocument(); + const TDF_Label aLabel = NewAttributeLabel(aDoc); + occ::handle anArray = TDataStd_RealArray::Set(aLabel, 1, 2); + anArray->SetValue(1, 3.0); + anArray->SetValue(2, 4.0); + aDoc->NewCommand(); + anArray->SetValue(1, 33.0); + anArray->SetValue(2, 44.0); + aDoc->NewCommand(); + aDoc->Undo(); + + ExpectRealArray(anArray, 3.0, 4.0); +} + +TEST(TDataStd_Attribute_Test, CafBasic_C4_RealArrayUserGuid) +{ + occ::handle aDoc = NewDocument(); + const TDF_Label aLabel = NewAttributeLabel(aDoc); + const Standard_GUID aGuid("12e94511-6dbc-11d4-b9c8-0060b0ee281b"); + occ::handle anArray = TDataStd_RealArray::Set(aLabel, 1, 2); + anArray->SetValue(1, 3.0); + anArray->SetValue(2, 4.0); + occ::handle aGuidArray = TDataStd_RealArray::Set(aLabel, aGuid, 1, 2); + aGuidArray->SetValue(1, 3.0); + aGuidArray->SetValue(2, 4.0); + + ExpectRealArray(anArray, 3.0, 4.0); + ExpectRealArray(aGuidArray, 3.0, 4.0); + EXPECT_EQ(aGuidArray->ID(), aGuid); +} + +// caf/basic/D1-D2: integer arrays mirror real-array behavior. +TEST(TDataStd_Attribute_Test, CafBasic_D1_IntegerArraySetGet) +{ + occ::handle aDoc = NewDocument(); + const TDF_Label aLabel = NewAttributeLabel(aDoc); + occ::handle anArray = TDataStd_IntegerArray::Set(aLabel, 1, 2); + anArray->SetValue(1, 3); + anArray->SetValue(2, 4); + + ExpectIntegerArray(anArray, 3, 4); +} + +TEST(TDataStd_Attribute_Test, CafBasic_D2_IntegerArrayUndo) +{ + occ::handle aDoc = NewDocument(); + const TDF_Label aLabel = NewAttributeLabel(aDoc); + occ::handle anArray = TDataStd_IntegerArray::Set(aLabel, 1, 2); + anArray->SetValue(1, 3); + anArray->SetValue(2, 4); + aDoc->NewCommand(); + anArray->SetValue(1, 33); + anArray->SetValue(2, 44); + aDoc->NewCommand(); + aDoc->Undo(); + + ExpectIntegerArray(anArray, 3, 4); +} + +TEST(TDataStd_Attribute_Test, CafBasic_D4_IntegerArrayDefaultGuid) +{ + occ::handle aDoc = NewDocument(); + const TDF_Label aLabel = NewAttributeLabel(aDoc); + occ::handle anArray = TDataStd_IntegerArray::Set(aLabel, 1, 2); + anArray->SetValue(1, 3); + anArray->SetValue(2, 4); + + EXPECT_EQ(anArray->ID(), TDataStd_IntegerArray::GetID()); + ExpectIntegerArray(anArray, 3, 4); +} + +TEST(TDataStd_Attribute_Test, CafBasic_D5_IntegerArrayUserGuid) +{ + occ::handle aDoc = NewDocument(); + const TDF_Label aLabel = NewAttributeLabel(aDoc); + const Standard_GUID aGuid("12e94511-6dbc-11d4-b9c8-0060b0ee281b"); + occ::handle anArray = TDataStd_IntegerArray::Set(aLabel, 1, 2); + anArray->SetValue(1, 3); + anArray->SetValue(2, 4); + occ::handle aGuidArray = TDataStd_IntegerArray::Set(aLabel, aGuid, 1, 2); + aGuidArray->SetValue(1, 3); + aGuidArray->SetValue(2, 4); + + ExpectIntegerArray(anArray, 3, 4); + ExpectIntegerArray(aGuidArray, 3, 4); + EXPECT_EQ(aGuidArray->ID(), aGuid); +} + +// caf/basic/E1-E2: names support setting and undoing a replacement. +TEST(TDataStd_Attribute_Test, CafBasic_E1_NameSetGet) +{ + occ::handle aDoc = NewDocument(); + const TDF_Label aLabel = NewAttributeLabel(aDoc); + occ::handle aName = + TDataStd_Name::Set(aLabel, TCollection_ExtendedString("New Attribute")); + + ASSERT_FALSE(aName.IsNull()); + EXPECT_TRUE(aName->Get().IsEqual(TCollection_ExtendedString("New Attribute"))); +} + +TEST(TDataStd_Attribute_Test, CafBasic_E2_NameUndo) +{ + occ::handle aDoc = NewDocument(); + const TDF_Label aLabel = NewAttributeLabel(aDoc); + occ::handle aName = + TDataStd_Name::Set(aLabel, TCollection_ExtendedString("New Attribute")); + aDoc->NewCommand(); + aName->Set(TCollection_ExtendedString("Old Attribute")); + aDoc->NewCommand(); + aDoc->Undo(); + + EXPECT_TRUE(aName->Get().IsEqual(TCollection_ExtendedString("New Attribute"))); +} + +TEST(TDataStd_Attribute_Test, CafBasic_E4_NameUserGuids) +{ + occ::handle aDoc = NewDocument(); + const TDF_Label aLabel = NewAttributeLabel(aDoc); + const Standard_GUID aGuid1("12e94561-6dbc-11d4-b9c8-0060b0ee281b"); + const Standard_GUID aGuid2("12e94562-6dbc-11d4-b9c8-0060b0ee281b"); + occ::handle aName1 = + TDataStd_Name::Set(aLabel, aGuid1, TCollection_ExtendedString("New Attribute1")); + occ::handle aName2 = + TDataStd_Name::Set(aLabel, aGuid2, TCollection_ExtendedString("New Attribute2")); + + ASSERT_FALSE(aName1.IsNull()); + ASSERT_FALSE(aName2.IsNull()); + EXPECT_TRUE(aName1->Get().IsEqual(TCollection_ExtendedString("New Attribute1"))); + EXPECT_TRUE(aName2->Get().IsEqual(TCollection_ExtendedString("New Attribute2"))); +} + +TEST(TDataStd_Attribute_Test, CafBasic_E5_NameUserGuidUndo) +{ + occ::handle aDoc = NewDocument(); + const TDF_Label aLabel = NewAttributeLabel(aDoc); + const Standard_GUID aGuid1("12e94561-6dbc-11d4-b9c8-0060b0ee281b"); + const Standard_GUID aGuid2("12e94562-6dbc-11d4-b9c8-0060b0ee281b"); + occ::handle aName1 = + TDataStd_Name::Set(aLabel, aGuid1, TCollection_ExtendedString("New Attribute1")); + occ::handle aName2 = + TDataStd_Name::Set(aLabel, aGuid2, TCollection_ExtendedString("New Attribute2")); + aDoc->NewCommand(); + aName1->Set(TCollection_ExtendedString("Modified Attribute1")); + aName2->Set(TCollection_ExtendedString("Modified Attribute2")); + aDoc->NewCommand(); + aDoc->Undo(); + + EXPECT_TRUE(aName1->Get().IsEqual(TCollection_ExtendedString("New Attribute1"))); + EXPECT_TRUE(aName2->Get().IsEqual(TCollection_ExtendedString("New Attribute2"))); +} + +// caf/basic/F1-F2: comments use the same generic extended-string behavior. +TEST(TDataStd_Attribute_Test, CafBasic_F1_CommentSetGet) +{ + occ::handle aDoc = NewDocument(); + const TDF_Label aLabel = NewAttributeLabel(aDoc); + occ::handle aComment = + TDataStd_Comment::Set(aLabel, TCollection_ExtendedString("New Attribute")); + + ASSERT_FALSE(aComment.IsNull()); + EXPECT_TRUE(aComment->Get().IsEqual(TCollection_ExtendedString("New Attribute"))); +} + +TEST(TDataStd_Attribute_Test, CafBasic_F2_CommentUndo) +{ + occ::handle aDoc = NewDocument(); + const TDF_Label aLabel = NewAttributeLabel(aDoc); + occ::handle aComment = + TDataStd_Comment::Set(aLabel, TCollection_ExtendedString("New Attribute")); + aDoc->NewCommand(); + aComment->Set(TCollection_ExtendedString("Old Attribute")); + aDoc->NewCommand(); + aDoc->Undo(); + + EXPECT_TRUE(aComment->Get().IsEqual(TCollection_ExtendedString("New Attribute"))); +} + +// caf/basic/J1-J5: UAttributes are identified by their local GUID. +TEST(TDataStd_Attribute_Test, CafBasic_J1_UAttributeSetGet) +{ + occ::handle aDoc = NewDocument(); + const TDF_Label aLabel = NewAttributeLabel(aDoc); + const Standard_GUID aGuid("c73bd075-22ee-11d2-acde-080009dc4422"); + occ::handle anAttribute = TDataStd_UAttribute::Set(aLabel, aGuid); + + ASSERT_FALSE(anAttribute.IsNull()); + EXPECT_EQ(anAttribute->ID(), aGuid); +} + +TEST(TDataStd_Attribute_Test, CafBasic_J2_UAttributeUndo) +{ + occ::handle aDoc = NewDocument(); + const TDF_Label aLabel = NewAttributeLabel(aDoc); + const Standard_GUID aGuid1("c73bd075-22ee-11d2-acde-080009dc4422"); + const Standard_GUID aGuid2("425a8e02-8934-11d2-b3f0-0060b0f1d69e"); + TDataStd_UAttribute::Set(aLabel, aGuid1); + aDoc->NewCommand(); + aLabel.ForgetAttribute(aGuid1); + TDataStd_UAttribute::Set(aLabel, aGuid2); + aDoc->NewCommand(); + aDoc->Undo(); + + occ::handle anAttribute; + ASSERT_TRUE(aLabel.FindAttribute(aGuid1, anAttribute)); + EXPECT_EQ(anAttribute->ID(), aGuid1); +} + +TEST(TDataStd_Attribute_Test, CafBasic_J4_UAttributeMultipleGuids) +{ + occ::handle aDoc = NewDocument(); + const TDF_Label aLabel = NewAttributeLabel(aDoc); + const Standard_GUID aGuid1("c73bd075-22ee-11d2-acde-080009dc4422"); + const Standard_GUID aGuid2("c73bd076-22ee-11d2-acde-080009dc4422"); + TDataStd_UAttribute::Set(aLabel, aGuid1); + TDataStd_UAttribute::Set(aLabel, aGuid2); + + EXPECT_TRUE(aLabel.IsAttribute(aGuid1)); + EXPECT_TRUE(aLabel.IsAttribute(aGuid2)); +} + +TEST(TDataStd_Attribute_Test, CafBasic_J5_UAttributeCopy) +{ + occ::handle aDoc = NewDocument(); + const TDF_Label aSourceLabel = NewAttributeLabel(aDoc); + const TDF_Label aTargetLabel = aDoc->Main().FindChild(3, true); + const Standard_GUID aGuid1("c73bd075-22ee-11d2-acde-080009dc4422"); + const Standard_GUID aGuid2("c73bd076-22ee-11d2-acde-080009dc4422"); + TDataStd_UAttribute::Set(aSourceLabel, aGuid1); + TDataStd_UAttribute::Set(aSourceLabel, aGuid2); + + occ::handle aSource1; + occ::handle aSource2; + ASSERT_TRUE(aSourceLabel.FindAttribute(aGuid1, aSource1)); + ASSERT_TRUE(aSourceLabel.FindAttribute(aGuid2, aSource2)); + aTargetLabel.AddAttribute(aSource1->NewEmpty()); + aTargetLabel.AddAttribute(aSource2->NewEmpty()); + EXPECT_TRUE(aTargetLabel.IsAttribute(aGuid1)); + EXPECT_TRUE(aTargetLabel.IsAttribute(aGuid2)); +} + +// caf/basic/L1-L2: references store and restore target labels. +TEST(TDataStd_Attribute_Test, CafBasic_L1_ReferenceSetGet) +{ + occ::handle aDoc = NewDocument(); + const TDF_Label aTarget = aDoc->Main().FindChild(3, true); + const TDF_Label aReferenceLabel = aDoc->Main().FindChild(5, true); + occ::handle aReference = TDF_Reference::Set(aReferenceLabel, aTarget); + + ASSERT_FALSE(aReference.IsNull()); + EXPECT_EQ(aReference->Get(), aTarget); +} + +TEST(TDataStd_Attribute_Test, CafBasic_L2_ReferenceUndo) +{ + occ::handle aDoc = NewDocument(); + const TDF_Label aTarget1 = aDoc->Main().FindChild(3, true); + const TDF_Label aTarget2 = aDoc->Main().FindChild(4, true); + const TDF_Label aReferenceLabel = aDoc->Main().FindChild(5, true); + occ::handle aReference = TDF_Reference::Set(aReferenceLabel, aTarget1); + aDoc->NewCommand(); + aReference->Set(aTarget2); + aDoc->NewCommand(); + aDoc->Undo(); + + EXPECT_EQ(aReference->Get(), aTarget1); +} + +// caf/basic/M5: extension-string arrays support a second user-defined GUID. +TEST(TDataStd_Attribute_Test, CafBasic_M5_ExtStringArrayUserGuid) +{ + occ::handle aDoc = NewDocument(); + const TDF_Label aLabel = NewAttributeLabel(aDoc); + const Standard_GUID aGuid("12e94515-6dbc-11d4-b9c8-0060b0ee281b"); + occ::handle anArray = TDataStd_ExtStringArray::Set(aLabel, 1, 2); + anArray->SetValue(1, TCollection_ExtendedString("aaaaa")); + anArray->SetValue(2, TCollection_ExtendedString("bbbbbbb")); + occ::handle aGuidArray = + TDataStd_ExtStringArray::Set(aLabel, aGuid, 1, 2); + aGuidArray->SetValue(1, TCollection_ExtendedString("aaaaa")); + aGuidArray->SetValue(2, TCollection_ExtendedString("bbbbbbb")); + + ASSERT_EQ(anArray->Length(), 2); + ASSERT_EQ(aGuidArray->Length(), 2); + EXPECT_TRUE(anArray->Value(1).IsEqual(aGuidArray->Value(1))); + EXPECT_TRUE(anArray->Value(2).IsEqual(aGuidArray->Value(2))); + EXPECT_EQ(aGuidArray->ID(), aGuid); +} + +// caf/basic/K1: a named shape survives ForgetAll/Undo/Redo/Undo. +TEST(TDataStd_Attribute_Test, CafBasic_K1_ShapeUndo) +{ + occ::handle aDoc = NewDocument(); + TDF_Label aLabel = NewAttributeLabel(aDoc); + const TopoDS_Shape aBox = BRepPrimAPI_MakeBox(100.0, 200.0, 300.0).Shape(); + TDataXtd_Shape::Set(aLabel, aBox); + + aDoc->NewCommand(); + aLabel.ForgetAllAttributes(); + aDoc->NewCommand(); + aDoc->Undo(); + aDoc->Redo(); + aDoc->Undo(); + + occ::handle anAttribute; + aLabel = aDoc->Main().FindChild(2, false); + if (aLabel.IsNull()) + { + ADD_FAILURE() << "Shape label was not restored after undo"; + return; + } + ASSERT_TRUE(TDataXtd_Shape::Find(aLabel, anAttribute)); + EXPECT_TRUE(TDataXtd_Shape::Get(aLabel).IsSame(aBox)); + aDoc->ClearUndos(); + aDoc->ClearRedos(); +} + +// caf/basic/K2: undoing a replacement restores the first named shape. +TEST(TDataStd_Attribute_Test, CafBasic_K2_ShapeReplacementUndo) +{ + occ::handle aDoc = NewDocument(); + TDF_Label aLabel = NewAttributeLabel(aDoc); + const TopoDS_Shape aBox1 = BRepPrimAPI_MakeBox(100.0, 200.0, 300.0).Shape(); + const TopoDS_Shape aBox2 = + BRepPrimAPI_MakeBox(gp_Pnt(-10.0, -20.0, -30.0), 100.0, 200.0, 300.0).Shape(); + TDataXtd_Shape::Set(aLabel, aBox1); + aDoc->NewCommand(); + TDataXtd_Shape::Set(aLabel, aBox2); + aDoc->NewCommand(); + aDoc->Undo(); + + aLabel = aDoc->Main().FindChild(2, false); + if (aLabel.IsNull()) + { + ADD_FAILURE() << "Shape label was not restored after undo"; + return; + } + occ::handle anAttribute; + ASSERT_TRUE(TDataXtd_Shape::Find(aLabel, anAttribute)); + EXPECT_TRUE(TDataXtd_Shape::Get(aLabel).IsSame(aBox1)); + aDoc->ClearUndos(); + aDoc->ClearRedos(); +} + +// caf/basic/M1-M2: extension-string arrays preserve values and undo changes. +TEST(TDataStd_Attribute_Test, CafBasic_M1_ExtStringArrayUndo) +{ + occ::handle aDoc = NewDocument(); + const TDF_Label aLabel = NewAttributeLabel(aDoc); + occ::handle anArray = TDataStd_ExtStringArray::Set(aLabel, 1, 2); + anArray->SetValue(1, TCollection_ExtendedString("TDataStd")); + anArray->SetValue(2, TCollection_ExtendedString("ExtStringArray")); + aDoc->NewCommand(); + aLabel.ForgetAllAttributes(); + aDoc->NewCommand(); + aDoc->Undo(); + aDoc->Redo(); + aDoc->Undo(); + + ASSERT_EQ(anArray->Length(), 2); + EXPECT_TRUE(anArray->Value(1).IsEqual(TCollection_ExtendedString("TDataStd"))); + EXPECT_TRUE(anArray->Value(2).IsEqual(TCollection_ExtendedString("ExtStringArray"))); +} + +TEST(TDataStd_Attribute_Test, CafBasic_M2_ExtStringArrayReplacementUndo) +{ + occ::handle aDoc = NewDocument(); + const TDF_Label aLabel = NewAttributeLabel(aDoc); + occ::handle anArray = TDataStd_ExtStringArray::Set(aLabel, 1, 2); + anArray->SetValue(1, TCollection_ExtendedString("TDataStd")); + anArray->SetValue(2, TCollection_ExtendedString("ExtStringArray")); + aDoc->NewCommand(); + anArray->SetValue(1, TCollection_ExtendedString("NEW TDataStd")); + anArray->SetValue(2, TCollection_ExtendedString("NEW ExtStringArray")); + aDoc->NewCommand(); + aDoc->Undo(); + + EXPECT_TRUE(anArray->Value(1).IsEqual(TCollection_ExtendedString("TDataStd"))); + EXPECT_TRUE(anArray->Value(2).IsEqual(TCollection_ExtendedString("ExtStringArray"))); +} + +// caf/basic/N4-N5: user-defined ASCII-string attributes are independent and undoable. +TEST(TDataStd_Attribute_Test, CafBasic_N4_AsciiStringUserGuids) +{ + occ::handle aDoc = NewDocument(); + const TDF_Label aLabel = NewAttributeLabel(aDoc); + const Standard_GUID aGuid1("12e94571-6dbc-11d4-b9c8-0060b0ee281b"); + const Standard_GUID aGuid2("12e94572-6dbc-11d4-b9c8-0060b0ee281b"); + TDataStd_AsciiString::Set(aLabel, aGuid1, TCollection_AsciiString("New Attribute1")); + TDataStd_AsciiString::Set(aLabel, aGuid2, TCollection_AsciiString("New Attribute2")); + + aDoc->NewCommand(); + aLabel.ForgetAllAttributes(); + aDoc->NewCommand(); + aDoc->Undo(); + aDoc->Redo(); + aDoc->Undo(); + + occ::handle anAttribute1; + occ::handle anAttribute2; + ASSERT_TRUE(aLabel.FindAttribute(aGuid1, anAttribute1)); + ASSERT_TRUE(aLabel.FindAttribute(aGuid2, anAttribute2)); + EXPECT_EQ(anAttribute1->Get(), TCollection_AsciiString("New Attribute1")); + EXPECT_EQ(anAttribute2->Get(), TCollection_AsciiString("New Attribute2")); +} + +TEST(TDataStd_Attribute_Test, CafBasic_N5_AsciiStringReplacementUndo) +{ + occ::handle aDoc = NewDocument(); + const TDF_Label aLabel = NewAttributeLabel(aDoc); + const Standard_GUID aGuid1("12e94571-6dbc-11d4-b9c8-0060b0ee281b"); + const Standard_GUID aGuid2("12e94572-6dbc-11d4-b9c8-0060b0ee281b"); + TDataStd_AsciiString::Set(aLabel, aGuid1, TCollection_AsciiString("Attribute_1")); + TDataStd_AsciiString::Set(aLabel, aGuid2, TCollection_AsciiString("Attribute_2")); + aDoc->NewCommand(); + TDataStd_AsciiString::Set(aLabel, aGuid1, TCollection_AsciiString("Modified_1")); + TDataStd_AsciiString::Set(aLabel, aGuid2, TCollection_AsciiString("Modified_2")); + aDoc->NewCommand(); + aDoc->Undo(); + + occ::handle anAttribute1; + occ::handle anAttribute2; + ASSERT_TRUE(aLabel.FindAttribute(aGuid1, anAttribute1)); + ASSERT_TRUE(aLabel.FindAttribute(aGuid2, anAttribute2)); + EXPECT_EQ(anAttribute1->Get(), TCollection_AsciiString("Attribute_1")); + EXPECT_EQ(anAttribute2->Get(), TCollection_AsciiString("Attribute_2")); +} + +// caf/basic/O5-P5: array attributes can be restored under a second GUID. +TEST(TDataStd_Attribute_Test, CafBasic_O5_BooleanArrayUserGuid) +{ + occ::handle aDoc = NewDocument(); + const TDF_Label aLabel = NewAttributeLabel(aDoc); + const Standard_GUID aGuid("12e94516-6dbc-11d4-b9c8-0060b0ee281b"); + occ::handle aDefault = TDataStd_BooleanArray::Set(aLabel, 1, 2); + occ::handle aCustom = TDataStd_BooleanArray::Set(aLabel, aGuid, 1, 2); + aDefault->SetValue(1, false); + aDefault->SetValue(2, true); + aCustom->SetValue(1, false); + aCustom->SetValue(2, true); + + aDoc->NewCommand(); + aLabel.ForgetAllAttributes(); + aDoc->NewCommand(); + aDoc->Undo(); + aDoc->Redo(); + aDoc->Undo(); + + EXPECT_EQ(aDefault->Length(), 2); + EXPECT_EQ(aCustom->Length(), 2); + EXPECT_EQ(aDefault->Value(1), aCustom->Value(1)); + EXPECT_EQ(aDefault->Value(2), aCustom->Value(2)); +} + +TEST(TDataStd_Attribute_Test, CafBasic_P5_ByteArrayUserGuid) +{ + occ::handle aDoc = NewDocument(); + const TDF_Label aLabel = NewAttributeLabel(aDoc); + const Standard_GUID aGuid("12e94517-6dbc-11d4-b9c8-0060b0ee281b"); + occ::handle aDefault = TDataStd_ByteArray::Set(aLabel, 1, 2); + occ::handle aCustom = TDataStd_ByteArray::Set(aLabel, aGuid, 1, 2); + aDefault->SetValue(1, 10); + aDefault->SetValue(2, 12); + aCustom->SetValue(1, 10); + aCustom->SetValue(2, 12); + + aDoc->NewCommand(); + aLabel.ForgetAllAttributes(); + aDoc->NewCommand(); + aDoc->Undo(); + aDoc->Redo(); + aDoc->Undo(); + + EXPECT_EQ(aDefault->Value(1), aCustom->Value(1)); + EXPECT_EQ(aDefault->Value(2), aCustom->Value(2)); +} + +TEST(TDataStd_Attribute_Test, CafBasic_Q5_ReferenceArrayUserGuid) +{ + occ::handle aDoc = NewDocument(); + const TDF_Label aLabel = NewAttributeLabel(aDoc); + const Standard_GUID aGuid("12e94518-6dbc-11d4-b9c8-0060b0ee281b"); + const TDF_Label aTarget1 = aDoc->Main().FindChild(3, true); + const TDF_Label aTarget2 = aDoc->Main().FindChild(4, true); + occ::handle aDefault = TDataStd_ReferenceArray::Set(aLabel, 1, 2); + occ::handle aCustom = TDataStd_ReferenceArray::Set(aLabel, aGuid, 1, 2); + aDefault->SetValue(1, aTarget1); + aDefault->SetValue(2, aTarget2); + aCustom->SetValue(1, aTarget1); + aCustom->SetValue(2, aTarget2); + + aDoc->NewCommand(); + aLabel.ForgetAllAttributes(); + aDoc->NewCommand(); + aDoc->Undo(); + aDoc->Redo(); + aDoc->Undo(); + + EXPECT_EQ(aDefault->Value(1), aCustom->Value(1)); + EXPECT_EQ(aDefault->Value(2), aCustom->Value(2)); +} + +// caf/basic/R5-V5: list attributes preserve values for default and custom GUIDs. +TEST(TDataStd_Attribute_Test, CafBasic_R5_RealListUserGuid) +{ + occ::handle aDoc = NewDocument(); + const TDF_Label aLabel = NewAttributeLabel(aDoc); + const Standard_GUID aGuid("12e94521-6dbc-11d4-b9c8-0060b0ee281b"); + occ::handle aDefault = TDataStd_RealList::Set(aLabel); + occ::handle aCustom = TDataStd_RealList::Set(aLabel, aGuid); + aDefault->Append(3.0); + aDefault->Append(4.0); + aCustom->Append(3.0); + aCustom->Append(4.0); + + aDoc->NewCommand(); + aLabel.ForgetAllAttributes(); + aDoc->NewCommand(); + aDoc->Undo(); + aDoc->Redo(); + aDoc->Undo(); + + EXPECT_EQ(aDefault->Extent(), aCustom->Extent()); + EXPECT_DOUBLE_EQ(aDefault->First(), aCustom->First()); + EXPECT_DOUBLE_EQ(aDefault->Last(), aCustom->Last()); +} + +TEST(TDataStd_Attribute_Test, CafBasic_S5_IntegerListUserGuid) +{ + occ::handle aDoc = NewDocument(); + const TDF_Label aLabel = NewAttributeLabel(aDoc); + const Standard_GUID aGuid("12e94531-6dbc-11d4-b9c8-0060b0ee281b"); + occ::handle aDefault = TDataStd_IntegerList::Set(aLabel); + occ::handle aCustom = TDataStd_IntegerList::Set(aLabel, aGuid); + aDefault->Append(33); + aDefault->Append(44); + aCustom->Append(33); + aCustom->Append(44); + + aDoc->NewCommand(); + aLabel.ForgetAllAttributes(); + aDoc->NewCommand(); + aDoc->Undo(); + aDoc->Redo(); + aDoc->Undo(); + + EXPECT_EQ(aDefault->Extent(), aCustom->Extent()); + EXPECT_EQ(aDefault->First(), aCustom->First()); + EXPECT_EQ(aDefault->Last(), aCustom->Last()); +} + +TEST(TDataStd_Attribute_Test, CafBasic_T5_ExtStringListUserGuid) +{ + occ::handle aDoc = NewDocument(); + const TDF_Label aLabel = NewAttributeLabel(aDoc); + const Standard_GUID aGuid("12e94541-6dbc-11d4-b9c8-0060b0ee281b"); + occ::handle aDefault = TDataStd_ExtStringList::Set(aLabel); + occ::handle aCustom = TDataStd_ExtStringList::Set(aLabel, aGuid); + aDefault->Append(TCollection_ExtendedString("aaaaa")); + aDefault->Append(TCollection_ExtendedString("bbbbbb")); + aCustom->Append(TCollection_ExtendedString("aaaaa")); + aCustom->Append(TCollection_ExtendedString("bbbbbb")); + + aDoc->NewCommand(); + aLabel.ForgetAllAttributes(); + aDoc->NewCommand(); + aDoc->Undo(); + aDoc->Redo(); + aDoc->Undo(); + + EXPECT_EQ(aDefault->Extent(), aCustom->Extent()); + EXPECT_TRUE(aDefault->First().IsEqual(aCustom->First())); + EXPECT_TRUE(aDefault->Last().IsEqual(aCustom->Last())); +} + +TEST(TDataStd_Attribute_Test, CafBasic_U5_BooleanListUserGuid) +{ + occ::handle aDoc = NewDocument(); + const TDF_Label aLabel = NewAttributeLabel(aDoc); + const Standard_GUID aGuid("12e94551-6dbc-11d4-b9c8-0060b0ee281b"); + occ::handle aDefault = TDataStd_BooleanList::Set(aLabel); + occ::handle aCustom = TDataStd_BooleanList::Set(aLabel, aGuid); + aDefault->Append(false); + aDefault->Append(true); + aCustom->Append(false); + aCustom->Append(true); + + aDoc->NewCommand(); + aLabel.ForgetAllAttributes(); + aDoc->NewCommand(); + aDoc->Undo(); + aDoc->Redo(); + aDoc->Undo(); + + EXPECT_EQ(aDefault->Extent(), aCustom->Extent()); + EXPECT_EQ(aDefault->First(), aCustom->First()); + EXPECT_EQ(aDefault->Last(), aCustom->Last()); +} + +TEST(TDataStd_Attribute_Test, CafBasic_V5_ReferenceListUserGuid) +{ + occ::handle aDoc = NewDocument(); + const TDF_Label aLabel = NewAttributeLabel(aDoc); + const Standard_GUID aGuid("12e94561-6dbc-11d4-b9c8-0060b0ee281b"); + const TDF_Label aTarget1 = aDoc->Main().FindChild(3, true); + const TDF_Label aTarget2 = aDoc->Main().FindChild(4, true); + occ::handle aDefault = TDataStd_ReferenceList::Set(aLabel); + occ::handle aCustom = TDataStd_ReferenceList::Set(aLabel, aGuid); + aDefault->Append(aTarget1); + aDefault->Append(aTarget2); + aCustom->Append(aTarget1); + aCustom->Append(aTarget2); + + aDoc->NewCommand(); + aLabel.ForgetAllAttributes(); + aDoc->NewCommand(); + aDoc->Undo(); + aDoc->Redo(); + aDoc->Undo(); + + EXPECT_EQ(aDefault->Extent(), aCustom->Extent()); + EXPECT_EQ(aDefault->First(), aCustom->First()); + EXPECT_EQ(aDefault->Last(), aCustom->Last()); +} + +// caf/bugs/E1: forgetting and replacing an integer must remain undoable. +TEST(TDataStd_Attribute_Test, CafBug_E1_UndoAfterForgetAndReplace) +{ + occ::handle aDoc = NewDocument(); + const TDF_Label aLabel = aDoc->Main().FindChild(1, true); + TDataStd_Integer::Set(aLabel, 1); + TDataStd_Real::Set(aLabel, 1.5); + + aDoc->NewCommand(); + aLabel.ForgetAttribute(TDataStd_Integer::GetID()); + TDataStd_Integer::Set(aLabel, 3); + aDoc->NewCommand(); + + EXPECT_NO_THROW(aDoc->Undo()); +} diff --git a/src/ApplicationFramework/TKLCAF/GTests/TDataStd_Expression_Test.cxx b/src/ApplicationFramework/TKLCAF/GTests/TDataStd_Expression_Test.cxx new file mode 100644 index 0000000000..d266ba8731 --- /dev/null +++ b/src/ApplicationFramework/TKLCAF/GTests/TDataStd_Expression_Test.cxx @@ -0,0 +1,107 @@ +// Copyright (c) 2026 OPEN CASCADE SAS +// +// This file is part of Open CASCADE Technology software library. +// +// This library is free software; you can redistribute it and/or modify it under +// the terms of the GNU Lesser General Public License version 2.1 as published +// by the Free Software Foundation, with special exception defined in the file +// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT +// distribution for complete text of the license and disclaimer of any warranty. +// +// Alternatively, this file may be used under the terms of Open CASCADE +// commercial license or contractual agreement. + +#include + +#include +#include +#include +#include +#include +#include +#include + +namespace +{ +static occ::handle NewExpressionDocument() +{ + return new TDocStd_Document("BinOcaf"); +} + +static occ::handle SetVariable(const TDF_Label& theLabel, + const TCollection_AsciiString& theUnit) +{ + occ::handle aVariable = TDataStd_Variable::Set(theLabel); + aVariable->Constant(false); + aVariable->Unit(theUnit); + return aVariable; +} + +static occ::handle SetRelation(const TDF_Label& theLabel, + const TCollection_ExtendedString& theExpression, + const occ::handle& theVariable) +{ + occ::handle aRelation = TDataStd_Relation::Set(theLabel); + aRelation->SetRelation(theExpression); + aRelation->GetVariables().Append(theVariable); + return aRelation; +} +} // namespace + +// caf/bugs/bug387: undoing a relation change restores the previous expression. +TEST(TDataStd_Expression_Test, CafBug_387_RelationUndo) +{ + occ::handle aDocument = NewExpressionDocument(); + aDocument->SetUndoLimit(10); + const TDF_Label aLabel = aDocument->Main(); + + aDocument->NewCommand(); + occ::handle aVariable = SetVariable(aLabel, TCollection_AsciiString("a")); + occ::handle aRelation = + SetRelation(aLabel, TCollection_ExtendedString("a=10"), aVariable); + TDataStd_Real::Set(aLabel, 10.0); + + aDocument->NewCommand(); + aRelation->SetRelation(TCollection_ExtendedString("a=20")); + TDataStd_Real::Set(aLabel, 20.0); + + aDocument->NewCommand(); + ASSERT_TRUE(aDocument->Undo()); + + occ::handle aRestoredRelation; + ASSERT_TRUE(aLabel.FindAttribute(TDataStd_Relation::GetID(), aRestoredRelation)); + EXPECT_TRUE(aRestoredRelation->GetRelation().IsEqual(TCollection_ExtendedString("a=10"))); + occ::handle aRestoredReal; + ASSERT_TRUE(aLabel.FindAttribute(TDataStd_Real::GetID(), aRestoredReal)); + EXPECT_DOUBLE_EQ(aRestoredReal->Get(), 10.0); +} + +// caf/bugs/bug644: repeated undo/redo of a relation leaves the original +// expression and its variable reference intact. +TEST(TDataStd_Expression_Test, CafBug_644_RelationUndoRedo) +{ + occ::handle aDocument = NewExpressionDocument(); + aDocument->SetUndoLimit(10); + const TDF_Label aVariableLabel = aDocument->Main(); + const TDF_Label aRelationLabel = aDocument->Main().Root().FindChild(2, true); + + aDocument->NewCommand(); + occ::handle aVariable = + SetVariable(aVariableLabel, TCollection_AsciiString("mm")); + occ::handle aRelation = + SetRelation(aRelationLabel, TCollection_ExtendedString("x=10"), aVariable); + + aDocument->NewCommand(); + aRelation->SetRelation(TCollection_ExtendedString("x=20")); + + aDocument->NewCommand(); + ASSERT_TRUE(aDocument->Undo()); + ASSERT_TRUE(aDocument->Redo()); + ASSERT_TRUE(aDocument->Undo()); + + occ::handle aRestoredRelation; + ASSERT_TRUE(aRelationLabel.FindAttribute(TDataStd_Relation::GetID(), aRestoredRelation)); + EXPECT_TRUE(aRestoredRelation->GetRelation().IsEqual(TCollection_ExtendedString("x=10"))); + ASSERT_EQ(aRestoredRelation->GetVariables().Extent(), 1); + EXPECT_EQ(aRestoredRelation->GetVariables().First()->Label(), aVariableLabel); +} diff --git a/src/ApplicationFramework/TKLCAF/GTests/TDataStd_List_Test.cxx b/src/ApplicationFramework/TKLCAF/GTests/TDataStd_List_Test.cxx new file mode 100644 index 0000000000..3fe785ec12 --- /dev/null +++ b/src/ApplicationFramework/TKLCAF/GTests/TDataStd_List_Test.cxx @@ -0,0 +1,165 @@ +// Copyright (c) 2026 OPEN CASCADE SAS +// +// This file is part of Open CASCADE Technology software library. +// +// This library is free software; you can redistribute it and/or modify it under +// the terms of the GNU Lesser General Public License version 2.1 as published +// by the Free Software Foundation, with special exception defined in the file +// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT +// distribution for complete text of the license and disclaimer of any warranty. +// +// Alternatively, this file may be used under the terms of Open CASCADE +// commercial license or contractual agreement. + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +TEST(TDataStd_List_Test, CafBug_23465_ListInsertRemove) +{ + occ::handle aDocument = new TDocStd_Document("XmlOcaf"); + const TDF_Label aLabel1 = aDocument->Main().FindChild(1, true); + const TDF_Label aLabel2 = aDocument->Main().FindChild(2, true); + const TDF_Label aLabel3 = aDocument->Main().FindChild(3, true); + const TDF_Label aLabel4 = aDocument->Main().FindChild(4, true); + const TDF_Label aLabel5 = aDocument->Main().FindChild(5, true); + + occ::handle aBooleanList = TDataStd_BooleanList::Set(aLabel1); + aBooleanList->Append(false); + aBooleanList->Append(false); + aBooleanList->Append(true); + aBooleanList->Append(false); + + occ::handle anIntegerList = TDataStd_IntegerList::Set(aLabel2); + anIntegerList->Append(0); + anIntegerList->Append(0); + anIntegerList->Append(1); + anIntegerList->Append(0); + + occ::handle aRealList = TDataStd_RealList::Set(aLabel3); + aRealList->Append(0.0); + aRealList->Append(0.0); + aRealList->Append(1.0); + aRealList->Append(0.0); + + occ::handle anExtStringList = TDataStd_ExtStringList::Set(aLabel4); + anExtStringList->Append(TCollection_ExtendedString("0")); + anExtStringList->Append(TCollection_ExtendedString("0")); + anExtStringList->Append(TCollection_ExtendedString("1")); + anExtStringList->Append(TCollection_ExtendedString("0")); + + occ::handle aReferenceList = TDataStd_ReferenceList::Set(aLabel5); + aReferenceList->Append(aLabel1); + aReferenceList->Append(aLabel2); + aReferenceList->Append(aLabel4); + + ASSERT_TRUE(aBooleanList->InsertBefore(3, true)); + ASSERT_TRUE(anIntegerList->InsertBeforeByIndex(3, 1)); + ASSERT_TRUE(aRealList->InsertBeforeByIndex(3, 1.0)); + ASSERT_TRUE(anExtStringList->InsertBefore(3, TCollection_ExtendedString("1"))); + ASSERT_TRUE(aReferenceList->InsertBefore(3, aLabel3)); + + ASSERT_TRUE(aBooleanList->InsertAfter(4, true)); + ASSERT_TRUE(anIntegerList->InsertAfterByIndex(4, 1)); + ASSERT_TRUE(aRealList->InsertAfterByIndex(4, 1.0)); + ASSERT_TRUE(anExtStringList->InsertAfter(4, TCollection_ExtendedString("1"))); + ASSERT_TRUE(aReferenceList->InsertAfter(4, aLabel5)); + + ASSERT_TRUE(aBooleanList->Remove(6)); + ASSERT_TRUE(anIntegerList->RemoveByIndex(6)); + ASSERT_TRUE(aRealList->RemoveByIndex(6)); + ASSERT_TRUE(anExtStringList->Remove(6)); + ASSERT_TRUE(aReferenceList->Remove(1)); + + ASSERT_EQ(aBooleanList->Extent(), 5); + const uint8_t anExpectedBooleanValues[5] = {0, 0, 1, 1, 1}; + int anIndex = 0; + for (NCollection_List::Iterator anIterator(aBooleanList->List()); anIterator.More(); + anIterator.Next(), ++anIndex) + { + ASSERT_LT(anIndex, 5); + EXPECT_EQ(anIterator.Value(), anExpectedBooleanValues[anIndex]); + } + EXPECT_EQ(anIndex, 5); + + ASSERT_EQ(anIntegerList->Extent(), 5); + const int anExpectedIntegerValues[5] = {0, 0, 1, 1, 1}; + anIndex = 0; + for (NCollection_List::Iterator anIterator(anIntegerList->List()); anIterator.More(); + anIterator.Next(), ++anIndex) + { + ASSERT_LT(anIndex, 5); + EXPECT_EQ(anIterator.Value(), anExpectedIntegerValues[anIndex]); + } + EXPECT_EQ(anIndex, 5); + + ASSERT_EQ(aRealList->Extent(), 5); + anIndex = 0; + for (NCollection_List::Iterator anIterator(aRealList->List()); anIterator.More(); + anIterator.Next(), ++anIndex) + { + ASSERT_LT(anIndex, 5); + EXPECT_DOUBLE_EQ(anIterator.Value(), double(anExpectedIntegerValues[anIndex])); + } + EXPECT_EQ(anIndex, 5); + + ASSERT_EQ(anExtStringList->Extent(), 5); + const TCollection_ExtendedString anExpectedStringValues[5] = {TCollection_ExtendedString("0"), + TCollection_ExtendedString("0"), + TCollection_ExtendedString("1"), + TCollection_ExtendedString("1"), + TCollection_ExtendedString("1")}; + anIndex = 0; + for (NCollection_List::Iterator anIterator(anExtStringList->List()); + anIterator.More(); + anIterator.Next(), ++anIndex) + { + ASSERT_LT(anIndex, 5); + EXPECT_TRUE(anIterator.Value().IsEqual(anExpectedStringValues[anIndex])); + } + EXPECT_EQ(anIndex, 5); + + ASSERT_EQ(aReferenceList->Extent(), 4); + const TDF_Label anExpectedReferenceValues[4] = {aLabel2, aLabel3, aLabel4, aLabel5}; + anIndex = 0; + for (NCollection_List::Iterator anIterator(aReferenceList->List()); anIterator.More(); + anIterator.Next(), ++anIndex) + { + ASSERT_LT(anIndex, 4); + EXPECT_EQ(anIterator.Value(), anExpectedReferenceValues[anIndex]); + } + EXPECT_EQ(anIndex, 4); +} + +// caf/bugs/bug23912: an extended-string array keeps each assigned value at its +// own index. +TEST(TDataStd_List_Test, CafBug_23912_ExtStringArrayValues) +{ + occ::handle aDocument = new TDocStd_Document("BinOcaf"); + occ::handle anArray = + TDataStd_ExtStringArray::Set(aDocument->Main(), 1, 5); + ASSERT_FALSE(anArray.IsNull()); + + const TCollection_ExtendedString anExpectedValues[5] = {TCollection_ExtendedString("A"), + TCollection_ExtendedString("B"), + TCollection_ExtendedString("C"), + TCollection_ExtendedString("D"), + TCollection_ExtendedString("E")}; + for (int anIndex = 1; anIndex <= 5; ++anIndex) + { + anArray->SetValue(anIndex, anExpectedValues[anIndex - 1]); + } + for (int anIndex = 1; anIndex <= 5; ++anIndex) + { + EXPECT_TRUE(anArray->Value(anIndex).IsEqual(anExpectedValues[anIndex - 1])); + } +} diff --git a/src/ApplicationFramework/TKLCAF/GTests/TDataStd_TreeNode_Test.cxx b/src/ApplicationFramework/TKLCAF/GTests/TDataStd_TreeNode_Test.cxx index 34370d2eb4..2ab488e035 100644 --- a/src/ApplicationFramework/TKLCAF/GTests/TDataStd_TreeNode_Test.cxx +++ b/src/ApplicationFramework/TKLCAF/GTests/TDataStd_TreeNode_Test.cxx @@ -13,9 +13,126 @@ #include +#include +#include +#include +#include #include #include #include +#include +#include + +namespace +{ +struct TreeData +{ + occ::handle myData; + occ::handle myRoot; + occ::handle myChild1; + occ::handle myChild2; + occ::handle myChild3; + occ::handle myChild4; + occ::handle myChild5; + occ::handle myChild6; + occ::handle myChild7; + occ::handle myChild8; + occ::handle myChild9; + occ::handle myChild10; +}; + +static TDF_Label MakeLabel(const occ::handle& theData, const int theTag) +{ + return theData->Root().FindChild(theTag, true); +} + +static TreeData MakeFlatTree() +{ + TreeData aTree; + aTree.myData = new TDF_Data(); + aTree.myRoot = TDataStd_TreeNode::Set(MakeLabel(aTree.myData, 2)); + aTree.myChild1 = TDataStd_TreeNode::Set(MakeLabel(aTree.myData, 3)); + aTree.myChild2 = TDataStd_TreeNode::Set(MakeLabel(aTree.myData, 4)); + aTree.myChild3 = TDataStd_TreeNode::Set(MakeLabel(aTree.myData, 5)); + aTree.myChild4 = TDataStd_TreeNode::Set(MakeLabel(aTree.myData, 6)); + aTree.myChild5 = TDataStd_TreeNode::Set(MakeLabel(aTree.myData, 7)); + aTree.myChild6 = TDataStd_TreeNode::Set(MakeLabel(aTree.myData, 8)); + aTree.myChild7 = TDataStd_TreeNode::Set(MakeLabel(aTree.myData, 9)); + aTree.myChild8 = TDataStd_TreeNode::Set(MakeLabel(aTree.myData, 10)); + aTree.myChild9 = TDataStd_TreeNode::Set(MakeLabel(aTree.myData, 11)); + aTree.myChild10 = TDataStd_TreeNode::Set(MakeLabel(aTree.myData, 12)); + return aTree; +} + +static TreeData MakeNestedTree() +{ + TreeData aTree = MakeFlatTree(); + EXPECT_TRUE(aTree.myRoot->Append(aTree.myChild1)); + EXPECT_TRUE(aTree.myRoot->Append(aTree.myChild2)); + EXPECT_TRUE(aTree.myChild1->Append(aTree.myChild3)); + EXPECT_TRUE(aTree.myChild1->Append(aTree.myChild4)); + EXPECT_TRUE(aTree.myChild1->Append(aTree.myChild5)); + EXPECT_TRUE(aTree.myChild2->Append(aTree.myChild6)); + EXPECT_TRUE(aTree.myChild2->Append(aTree.myChild7)); + return aTree; +} + +static void ExpectTreeOrder(const occ::handle& theRoot, + const bool theAllLevels, + const NCollection_Array1>& theExpected) +{ + TDataStd_ChildNodeIterator anIterator(theRoot, theAllLevels); + int anIndex = theExpected.Lower(); + for (; anIterator.More() && anIndex <= theExpected.Upper(); anIterator.Next(), ++anIndex) + { + EXPECT_EQ(anIterator.Value()->Label(), theExpected(anIndex)->Label()); + } + EXPECT_EQ(anIndex, theExpected.Upper() + 1); + EXPECT_FALSE(anIterator.More()); +} + +static NCollection_Array1> ExpectedNodes( + const occ::handle& theNode1, + const occ::handle& theNode2) +{ + NCollection_Array1> anExpected(1, 2); + anExpected.SetValue(1, theNode1); + anExpected.SetValue(2, theNode2); + return anExpected; +} + +static NCollection_Array1> ExpectedNodes( + const occ::handle& theNode1, + const occ::handle& theNode2, + const occ::handle& theNode3) +{ + NCollection_Array1> anExpected(1, 3); + anExpected.SetValue(1, theNode1); + anExpected.SetValue(2, theNode2); + anExpected.SetValue(3, theNode3); + return anExpected; +} + +static NCollection_Array1> ExpectedNodes( + const occ::handle& theNode1, + const occ::handle& theNode2, + const occ::handle& theNode3, + const occ::handle& theNode4, + const occ::handle& theNode5, + const occ::handle& theNode6, + const occ::handle& theNode7) +{ + NCollection_Array1> anExpected(1, 7); + anExpected.SetValue(1, theNode1); + anExpected.SetValue(2, theNode2); + anExpected.SetValue(3, theNode3); + anExpected.SetValue(4, theNode4); + anExpected.SetValue(5, theNode5); + anExpected.SetValue(6, theNode6); + anExpected.SetValue(7, theNode7); + return anExpected; +} +} // namespace // Test BUC60817: TDataStd_TreeNode descendant relationship TEST(TDataStd_TreeNode_Test, BUC60817_DescendantRelationship) @@ -40,3 +157,396 @@ TEST(TDataStd_TreeNode_Test, BUC60817_DescendantRelationship) // Verify that TN1 is NOT a descendant of TN2 EXPECT_FALSE(aTN1->IsDescendant(aTN2)) << "TN1 should not be a descendant of TN2"; } + +// caf/bugs/bug24645: undoing the removal of intermediate children does not leave +// a stale last-child pointer on the tree node. +TEST(TDataStd_TreeNode_Test, CafBug_24645_UndoDetachedChildren) +{ + occ::handle aDocument = new TDocStd_Document("BinOcaf"); + aDocument->SetUndoLimit(1000); + + const TDF_Label aRootLabel = aDocument->Main().FindChild(1, true); + occ::handle aRoot = TDataStd_TreeNode::Set(aRootLabel); + NCollection_Array1> aChildren(1, 5); + aDocument->NewCommand(); + for (int anIndex = 1; anIndex <= aChildren.Upper(); ++anIndex) + { + aChildren.SetValue(anIndex, TDataStd_TreeNode::Set(aRootLabel.FindChild(anIndex, true))); + ASSERT_TRUE(aRoot->Append(aChildren(anIndex))); + aDocument->NewCommand(); + } + + ASSERT_TRUE(aChildren(3)->Remove()); + ASSERT_TRUE(aChildren(4)->Remove()); + aDocument->NewCommand(); + + ASSERT_TRUE(aDocument->Undo()); + EXPECT_FALSE(aRoot->HasLast()); +} + +// caf/tree/A1: TDF_TagSource::NewChild keeps the child label addressable. +TEST(TDataStd_TreeNode_Test, CafTree_A1_TagSourceNewChild) +{ + occ::handle aData = new TDF_Data(); + const TDF_Label aParent = MakeLabel(aData, 2); + const TDF_Label aChild = TDF_TagSource::NewChild(aParent); + occ::handle aName = + TDataStd_Name::Set(aChild, TCollection_ExtendedString("Label11")); + + ASSERT_FALSE(aName.IsNull()); + EXPECT_EQ(aChild.Father(), aParent); + EXPECT_TRUE(aName->Get().IsEqual(TCollection_ExtendedString("Label11"))); +} + +// caf/tree/A2: explicit tag allocation and child creation use the same source. +TEST(TDataStd_TreeNode_Test, CafTree_A2_TagSourceNewTag) +{ + occ::handle aData = new TDF_Data(); + const TDF_Label aParent1 = MakeLabel(aData, 2); + const TDF_Label aParent2 = MakeLabel(aData, 3); + occ::handle aTagger1 = TDF_TagSource::Set(aParent1); + occ::handle aTagger2 = TDF_TagSource::Set(aParent2); + + const TDF_Label aChild1 = TDF_TagSource::NewChild(aParent1); + aTagger2->NewTag(); + aTagger2->NewTag(); + aTagger2->NewTag(); + const TDF_Label aChild2 = TDF_TagSource::NewChild(aParent2); + + EXPECT_EQ(aChild1.Tag(), 1); + EXPECT_EQ(aChild2.Tag(), 4); +} + +// caf/tree/B1: TDataStd_Directory::New creates a directory on the label. +TEST(TDataStd_TreeNode_Test, CafTree_B1_NewDirectory) +{ + occ::handle aData = new TDF_Data(); + const TDF_Label aLabel = MakeLabel(aData, 2); + occ::handle aDirectory = TDataStd_Directory::New(aLabel); + occ::handle aName = + TDataStd_Name::Set(aLabel, TCollection_ExtendedString("Label1")); + + ASSERT_FALSE(aDirectory.IsNull()); + ASSERT_FALSE(aName.IsNull()); + EXPECT_EQ(aDirectory->Label(), aLabel); + EXPECT_TRUE(aName->Get().IsEqual(TCollection_ExtendedString("Label1"))); +} + +// caf/tree/B2: adding a directory allocates a child label and directory. +TEST(TDataStd_TreeNode_Test, CafTree_B2_AddDirectory) +{ + occ::handle aData = new TDF_Data(); + const TDF_Label aParent = MakeLabel(aData, 2); + occ::handle aDirectory = TDataStd_Directory::New(aParent); + occ::handle aSubDirectory = TDataStd_Directory::AddDirectory(aDirectory); + occ::handle aName = + TDataStd_Name::Set(aSubDirectory->Label(), TCollection_ExtendedString("SubDirectory1")); + + ASSERT_FALSE(aSubDirectory.IsNull()); + ASSERT_FALSE(aName.IsNull()); + EXPECT_EQ(aSubDirectory->Label().Father(), aParent); + EXPECT_TRUE(aName->Get().IsEqual(TCollection_ExtendedString("SubDirectory1"))); +} + +// caf/tree/C1: a node is its own root when it has no father. +TEST(TDataStd_TreeNode_Test, CafTree_C1_RootNode) +{ + TreeData aTree = MakeFlatTree(); + EXPECT_EQ(aTree.myRoot->Root()->Label(), aTree.myRoot->Label()); + EXPECT_TRUE(aTree.myRoot->IsRoot()); +} + +// caf/tree/D1-D2: AppendNode preserves insertion order. +TEST(TDataStd_TreeNode_Test, CafTree_D1_AppendNodeCount) +{ + TreeData aTree = MakeFlatTree(); + ASSERT_TRUE(aTree.myRoot->Append(aTree.myChild1)); + ASSERT_TRUE(aTree.myRoot->Append(aTree.myChild2)); + ASSERT_TRUE(aTree.myRoot->Append(aTree.myChild3)); + + EXPECT_EQ(aTree.myRoot->NbChildren(false), 3); +} + +TEST(TDataStd_TreeNode_Test, CafTree_D2_AppendNodeOrder) +{ + TreeData aTree = MakeFlatTree(); + ASSERT_TRUE(aTree.myRoot->Append(aTree.myChild1)); + ASSERT_TRUE(aTree.myRoot->Append(aTree.myChild2)); + ASSERT_TRUE(aTree.myRoot->Append(aTree.myChild3)); + + ExpectTreeOrder(aTree.myRoot, + true, + ExpectedNodes(aTree.myChild1, aTree.myChild2, aTree.myChild3)); +} + +// caf/tree/E1-E2: PrependNode inserts each new node before the old first child. +TEST(TDataStd_TreeNode_Test, CafTree_E1_PrependNodeCount) +{ + TreeData aTree = MakeFlatTree(); + ASSERT_TRUE(aTree.myRoot->Append(aTree.myChild1)); + ASSERT_TRUE(aTree.myRoot->Prepend(aTree.myChild2)); + ASSERT_TRUE(aTree.myRoot->Prepend(aTree.myChild3)); + + EXPECT_EQ(aTree.myRoot->NbChildren(false), 3); +} + +TEST(TDataStd_TreeNode_Test, CafTree_E2_PrependNodeOrder) +{ + TreeData aTree = MakeFlatTree(); + ASSERT_TRUE(aTree.myRoot->Append(aTree.myChild1)); + ASSERT_TRUE(aTree.myRoot->Prepend(aTree.myChild2)); + ASSERT_TRUE(aTree.myRoot->Prepend(aTree.myChild3)); + + ExpectTreeOrder(aTree.myRoot, + true, + ExpectedNodes(aTree.myChild3, aTree.myChild2, aTree.myChild1)); +} + +// caf/tree/F1-F2: InsertNodeBefore places a node immediately before its target. +TEST(TDataStd_TreeNode_Test, CafTree_F1_InsertNodeBeforeCount) +{ + TreeData aTree = MakeFlatTree(); + ASSERT_TRUE(aTree.myRoot->Append(aTree.myChild1)); + ASSERT_TRUE(aTree.myRoot->Append(aTree.myChild2)); + ASSERT_TRUE(aTree.myChild2->InsertBefore(aTree.myChild3)); + + EXPECT_EQ(aTree.myRoot->NbChildren(false), 3); +} + +TEST(TDataStd_TreeNode_Test, CafTree_F2_InsertNodeBeforeOrder) +{ + TreeData aTree = MakeFlatTree(); + ASSERT_TRUE(aTree.myRoot->Append(aTree.myChild1)); + ASSERT_TRUE(aTree.myRoot->Append(aTree.myChild2)); + ASSERT_TRUE(aTree.myChild2->InsertBefore(aTree.myChild3)); + + ExpectTreeOrder(aTree.myRoot, + true, + ExpectedNodes(aTree.myChild1, aTree.myChild3, aTree.myChild2)); +} + +// caf/tree/G1-G2: InsertNodeAfter places a node immediately after its target. +TEST(TDataStd_TreeNode_Test, CafTree_G1_InsertNodeAfterCount) +{ + TreeData aTree = MakeFlatTree(); + ASSERT_TRUE(aTree.myRoot->Append(aTree.myChild1)); + ASSERT_TRUE(aTree.myRoot->Append(aTree.myChild2)); + ASSERT_TRUE(aTree.myChild1->InsertAfter(aTree.myChild3)); + + EXPECT_EQ(aTree.myRoot->NbChildren(false), 3); +} + +TEST(TDataStd_TreeNode_Test, CafTree_G2_InsertNodeAfterOrder) +{ + TreeData aTree = MakeFlatTree(); + ASSERT_TRUE(aTree.myRoot->Append(aTree.myChild1)); + ASSERT_TRUE(aTree.myRoot->Append(aTree.myChild2)); + ASSERT_TRUE(aTree.myChild1->InsertAfter(aTree.myChild3)); + + ExpectTreeOrder(aTree.myRoot, + true, + ExpectedNodes(aTree.myChild1, aTree.myChild3, aTree.myChild2)); +} + +// caf/tree/H1-H2: Remove detaches a node without changing its siblings. +TEST(TDataStd_TreeNode_Test, CafTree_H1_DetachNodeCount) +{ + TreeData aTree = MakeFlatTree(); + ASSERT_TRUE(aTree.myRoot->Append(aTree.myChild1)); + ASSERT_TRUE(aTree.myRoot->Append(aTree.myChild2)); + ASSERT_TRUE(aTree.myRoot->Append(aTree.myChild3)); + ASSERT_TRUE(aTree.myChild2->Remove()); + + EXPECT_EQ(aTree.myRoot->NbChildren(false), 2); + EXPECT_TRUE(aTree.myChild2->Father().IsNull()); +} + +TEST(TDataStd_TreeNode_Test, CafTree_H2_DetachNodeOrder) +{ + TreeData aTree = MakeFlatTree(); + ASSERT_TRUE(aTree.myRoot->Append(aTree.myChild1)); + ASSERT_TRUE(aTree.myRoot->Append(aTree.myChild2)); + ASSERT_TRUE(aTree.myRoot->Append(aTree.myChild3)); + ASSERT_TRUE(aTree.myChild2->Remove()); + + ExpectTreeOrder(aTree.myRoot, true, ExpectedNodes(aTree.myChild1, aTree.myChild3)); +} + +// caf/tree/I1-I4: ChildNodeIterator supports both direct and recursive walks. +TEST(TDataStd_TreeNode_Test, CafTree_I1_ChildNodeIterateDirectCount) +{ + TreeData aTree = MakeNestedTree(); + EXPECT_EQ(aTree.myRoot->NbChildren(false), 2); + ExpectTreeOrder(aTree.myRoot, false, ExpectedNodes(aTree.myChild1, aTree.myChild2)); +} + +TEST(TDataStd_TreeNode_Test, CafTree_I2_ChildNodeIterateDirectOrder) +{ + TreeData aTree = MakeNestedTree(); + ExpectTreeOrder(aTree.myRoot, false, ExpectedNodes(aTree.myChild1, aTree.myChild2)); +} + +TEST(TDataStd_TreeNode_Test, CafTree_I3_ChildNodeIterateAllLevelsCount) +{ + TreeData aTree = MakeNestedTree(); + EXPECT_EQ(aTree.myRoot->NbChildren(true), 7); + ExpectTreeOrder(aTree.myRoot, + true, + ExpectedNodes(aTree.myChild1, + aTree.myChild3, + aTree.myChild4, + aTree.myChild5, + aTree.myChild2, + aTree.myChild6, + aTree.myChild7)); +} + +TEST(TDataStd_TreeNode_Test, CafTree_I4_ChildNodeIterateAllLevelsOrder) +{ + TreeData aTree = MakeNestedTree(); + ExpectTreeOrder(aTree.myRoot, + true, + ExpectedNodes(aTree.myChild1, + aTree.myChild3, + aTree.myChild4, + aTree.myChild5, + aTree.myChild2, + aTree.myChild6, + aTree.myChild7)); +} + +TEST(TDataStd_TreeNode_Test, CafTree_J1_ChildNodeIteratorMoreAllLevels) +{ + TreeData aTree = MakeNestedTree(); + TDataStd_ChildNodeIterator anIterator(aTree.myRoot, true); + EXPECT_TRUE(anIterator.More()); +} + +TEST(TDataStd_TreeNode_Test, CafTree_J2_ChildNodeIteratorMoreDirect) +{ + TreeData aTree = MakeNestedTree(); + TDataStd_ChildNodeIterator anIterator(aTree.myRoot, false); + EXPECT_TRUE(anIterator.More()); +} + +TEST(TDataStd_TreeNode_Test, CafTree_K1_ChildNodeIteratorNextAllLevels) +{ + TreeData aTree = MakeNestedTree(); + TDataStd_ChildNodeIterator anIterator(aTree.myRoot, true); + int aChildCount = 0; + while (anIterator.More()) + { + anIterator.Next(); + ++aChildCount; + } + EXPECT_EQ(aChildCount, 7); +} + +TEST(TDataStd_TreeNode_Test, CafTree_K2_ChildNodeIteratorNextDirect) +{ + TreeData aTree = MakeNestedTree(); + TDataStd_ChildNodeIterator anIterator(aTree.myRoot, false); + int aChildCount = 0; + while (anIterator.More()) + { + anIterator.Next(); + ++aChildCount; + } + EXPECT_EQ(aChildCount, 2); +} + +TEST(TDataStd_TreeNode_Test, CafTree_L1_ChildNodeIteratorValueDirect) +{ + TreeData aTree = MakeNestedTree(); + ExpectTreeOrder(aTree.myRoot, false, ExpectedNodes(aTree.myChild1, aTree.myChild2)); +} + +TEST(TDataStd_TreeNode_Test, CafTree_L2_ChildNodeIteratorValueAllLevels) +{ + TreeData aTree = MakeNestedTree(); + ExpectTreeOrder(aTree.myRoot, + true, + ExpectedNodes(aTree.myChild1, + aTree.myChild3, + aTree.myChild4, + aTree.myChild5, + aTree.myChild2, + aTree.myChild6, + aTree.myChild7)); +} + +TEST(TDataStd_TreeNode_Test, CafTree_M1_ChildNodeIteratorNextBrotherAllLevels) +{ + TreeData aTree = MakeNestedTree(); + ASSERT_TRUE(aTree.myChild4->Append(aTree.myChild8)); + ASSERT_TRUE(aTree.myChild4->Append(aTree.myChild9)); + TDataStd_ChildNodeIterator anIterator(aTree.myRoot, true); + anIterator.Next(); + anIterator.Next(); + anIterator.Next(); + anIterator.NextBrother(); + EXPECT_EQ(anIterator.Value()->Label(), aTree.myChild9->Label()); + anIterator.NextBrother(); + EXPECT_EQ(anIterator.Value()->Label(), aTree.myChild5->Label()); + anIterator.NextBrother(); + EXPECT_EQ(anIterator.Value()->Label(), aTree.myChild2->Label()); +} + +TEST(TDataStd_TreeNode_Test, CafTree_M2_ChildNodeIteratorNextBrotherDirect) +{ + TreeData aTree = MakeNestedTree(); + ASSERT_TRUE(aTree.myChild4->Append(aTree.myChild8)); + ASSERT_TRUE(aTree.myChild4->Append(aTree.myChild9)); + ASSERT_TRUE(aTree.myRoot->Append(aTree.myChild10)); + TDataStd_ChildNodeIterator anIterator(aTree.myRoot, false); + anIterator.NextBrother(); + EXPECT_EQ(anIterator.Value()->Label(), aTree.myChild2->Label()); + anIterator.NextBrother(); + EXPECT_EQ(anIterator.Value()->Label(), aTree.myChild10->Label()); +} + +// caf/bugs/buc60844: forgetting a tree node inside a command is reversible. +TEST(TDataStd_TreeNode_Test, Buc_CafBug_60844_ForgetAllUndo) +{ + occ::handle aDocument = new TDocStd_Document("BinOcaf"); + aDocument->SetUndoLimit(100); + aDocument->NewCommand(); + + const TDF_Label aLabel1 = aDocument->Main(); + const TDF_Label aLabel2 = aDocument->Main().Root().FindChild(2, true); + const TDF_Label aLabel21 = aLabel2.FindChild(1, true); + const TDF_Label aLabel211 = aLabel21.FindChild(1, true); + const TDF_Label aLabel212 = aLabel21.FindChild(2, true); + const TDF_Label aLabel3 = aDocument->Main().Root().FindChild(3, true); + + occ::handle aNode1 = TDataStd_TreeNode::Set(aLabel1); + occ::handle aNode2 = TDataStd_TreeNode::Set(aLabel2); + occ::handle aNode21 = TDataStd_TreeNode::Set(aLabel21); + occ::handle aNode211 = TDataStd_TreeNode::Set(aLabel211); + occ::handle aNode212 = TDataStd_TreeNode::Set(aLabel212); + occ::handle aNode3 = TDataStd_TreeNode::Set(aLabel3); + + ASSERT_TRUE(aNode1->InsertAfter(aNode2)); + ASSERT_TRUE(aNode2->InsertAfter(aNode3)); + ASSERT_TRUE(aNode2->Append(aNode21)); + ASSERT_TRUE(aNode21->Append(aNode211)); + ASSERT_TRUE(aNode211->InsertAfter(aNode212)); + EXPECT_EQ(aNode2->NbChildren(), 1); + EXPECT_EQ(aNode21->NbChildren(), 2); + EXPECT_EQ(aNode21->Root()->Label(), aNode2->Label()); + + aDocument->NewCommand(); + aLabel21.ForgetAllAttributes(); + EXPECT_FALSE(TDataStd_TreeNode::Find(aLabel21, aNode21)); + + aDocument->NewCommand(); + ASSERT_TRUE(aDocument->Undo()); + + occ::handle aRestored21; + ASSERT_TRUE(TDataStd_TreeNode::Find(aLabel21, aRestored21)); + EXPECT_EQ(aRestored21->Father()->Label(), aLabel2); + EXPECT_EQ(aRestored21->NbChildren(), 2); + EXPECT_EQ(aRestored21->First()->Label(), aLabel211); + EXPECT_EQ(aRestored21->Last()->Label(), aLabel212); + EXPECT_EQ(aRestored21->Root()->Label(), aLabel2); +} diff --git a/src/ApplicationFramework/TKLCAF/GTests/TDocStd_Application_Test.cxx b/src/ApplicationFramework/TKLCAF/GTests/TDocStd_Application_Test.cxx new file mode 100644 index 0000000000..af8aa6d4ab --- /dev/null +++ b/src/ApplicationFramework/TKLCAF/GTests/TDocStd_Application_Test.cxx @@ -0,0 +1,43 @@ +// Copyright (c) 2026 OPEN CASCADE SAS +// +// This file is part of Open CASCADE Technology software library. +// +// This library is free software; you can redistribute it and/or modify it under +// the terms of the GNU Lesser General Public License version 2.1 as published +// by the Free Software Foundation, with special exception defined in the file +// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT +// distribution for complete text of the license and disclaimer of any warranty. +// +// Alternatively, this file may be used under the terms of Open CASCADE +// commercial license or contractual agreement. + +#include +#include +#include +#include + +#include + +// bugs/caf/bug159: closing an OCAF document clears its owner link and releases +// the application's reference to the document. +TEST(TDocStd_Application_Test, CafBug_159_OwnerClearedOnClose) +{ + const occ::handle anApplication = new TDocStd_Application(); + BinDrivers::DefineFormat(anApplication); + + occ::handle aDocument; + anApplication->NewDocument("BinOcaf", aDocument); + ASSERT_FALSE(aDocument.IsNull()); + + const int aReferenceCountBeforeClose = aDocument->GetRefCount(); + occ::handle anOwner; + ASSERT_TRUE(aDocument->Main().Root().FindAttribute(TDocStd_Owner::GetID(), anOwner)); + occ::handle anOwnedDocument = anOwner->GetDocument(); + ASSERT_FALSE(anOwnedDocument.IsNull()); + EXPECT_EQ(anOwnedDocument.get(), aDocument.get()); + anOwnedDocument.Nullify(); + + EXPECT_NO_THROW(anApplication->Close(aDocument)); + EXPECT_TRUE(anOwner->GetDocument().IsNull()); + EXPECT_GE(aReferenceCountBeforeClose - aDocument->GetRefCount(), 1); +} diff --git a/src/ApplicationFramework/TKLCAF/GTests/TDocStd_Transaction_Test.cxx b/src/ApplicationFramework/TKLCAF/GTests/TDocStd_Transaction_Test.cxx new file mode 100644 index 0000000000..ef12340746 --- /dev/null +++ b/src/ApplicationFramework/TKLCAF/GTests/TDocStd_Transaction_Test.cxx @@ -0,0 +1,889 @@ +// Copyright (c) 2026 OPEN CASCADE SAS +// +// This file is part of Open CASCADE Technology software library. +// +// This library is free software; you can redistribute it and/or modify it under +// the terms of the GNU Lesser General Public License version 2.1 as published +// by the Free Software Foundation, with special exception defined in the file +// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT +// distribution for complete text of the license and disclaimer of any warranty. +// +// Alternatively, this file may be used under the terms of Open CASCADE +// commercial license or contractual agreement. + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace +{ +static occ::handle NewTransactionDocument() +{ + return new TDocStd_Document("BinOcaf"); +} + +static occ::handle NewApplicationTransactionDocument( + occ::handle& theApplication) +{ + theApplication = new TDocStd_Application(); + BinDrivers::DefineFormat(theApplication); + occ::handle aDocument; + theApplication->NewDocument("BinOcaf", aDocument); + return aDocument; +} + +static TDF_Label RootChild(const occ::handle& theDocument, const int theTag) +{ + return theDocument->Main().Root().FindChild(theTag, true); +} + +static bool HasModifiedLabels(const occ::handle& theDocument) +{ + occ::handle aModified; + if (!theDocument->Main().Root().FindAttribute(TDocStd_Modified::GetID(), aModified)) + { + return false; + } + return !aModified->IsEmpty(); +} + +static double RealValue(const TDF_Label& theLabel) +{ + occ::handle aReal; + if (!theLabel.FindAttribute(TDataStd_Real::GetID(), aReal)) + { + ADD_FAILURE() << "Real attribute is missing"; + return 0.0; + } + return aReal->Get(); +} + +static void ExpectLastDeltaIs(const occ::handle& theDocument, + const char* theAttributeName) +{ + ASSERT_FALSE(theDocument->GetUndos().IsEmpty()); + const occ::handle& aDelta = theDocument->GetUndos().Last(); + ASSERT_FALSE(aDelta->AttributeDeltas().IsEmpty()); + EXPECT_STREQ(aDelta->AttributeDeltas().Last()->Attribute()->DynamicType()->Name(), + theAttributeName); +} + +static void ExpectLastDeltaIsReal(const occ::handle& theDocument) +{ + ExpectLastDeltaIs(theDocument, "TDataStd_Real"); +} + +static bool DeltaHasAttribute(const occ::handle& theDelta, const char* theAttributeName) +{ + for (NCollection_List>::Iterator anIterator( + theDelta->AttributeDeltas()); + anIterator.More(); + anIterator.Next()) + { + if (TCollection_AsciiString(anIterator.Value()->Attribute()->DynamicType()->Name()) + .IsEqual(theAttributeName)) + { + return true; + } + } + return false; +} + +static void ExpectLastDeltaHas(const occ::handle& theDocument, + const char* theFirstAttributeName, + const char* theSecondAttributeName) +{ + ASSERT_FALSE(theDocument->GetUndos().IsEmpty()); + const occ::handle& aDelta = theDocument->GetUndos().Last(); + EXPECT_TRUE(DeltaHasAttribute(aDelta, theFirstAttributeName)); + EXPECT_TRUE(DeltaHasAttribute(aDelta, theSecondAttributeName)); +} +} // namespace + +// caf/bugs/buc60790: the most recent redo keeps the name of the second undone delta. +TEST(TDocStd_Transaction_Test, Buc_CafBug_60790_TreeNodeDeltaNames) +{ + occ::handle aDocument = NewTransactionDocument(); + aDocument->SetUndoLimit(100); + + aDocument->NewCommand(); + ASSERT_FALSE(TDataStd_TreeNode::Set(RootChild(aDocument, 2)).IsNull()); + aDocument->NewCommand(); + ASSERT_FALSE(TDataStd_TreeNode::Set(RootChild(aDocument, 3)).IsNull()); + aDocument->NewCommand(); + ASSERT_FALSE(TDataStd_TreeNode::Set(RootChild(aDocument, 4)).IsNull()); + aDocument->NewCommand(); + + ASSERT_EQ(aDocument->GetAvailableUndos(), 3); + const TCollection_ExtendedString aNames[3] = {TCollection_ExtendedString("n1"), + TCollection_ExtendedString("n2"), + TCollection_ExtendedString("n3")}; + int anIndex = 0; + for (NCollection_List>::Iterator anIterator(aDocument->GetUndos()); + anIterator.More(); + anIterator.Next(), ++anIndex) + { + ASSERT_LT(anIndex, 3); + anIterator.Value()->SetName(aNames[anIndex]); + } + ASSERT_EQ(anIndex, 3); + + ASSERT_TRUE(aDocument->Undo()); + ASSERT_TRUE(aDocument->Undo()); + ASSERT_EQ(aDocument->GetAvailableUndos(), 1); + ASSERT_EQ(aDocument->GetAvailableRedos(), 2); + ASSERT_FALSE(aDocument->GetRedos().IsEmpty()); + EXPECT_TRUE(aDocument->GetRedos().First()->Name().IsEqual(TCollection_ExtendedString("n2"))); +} + +// caf/bugs/buc60831: modified labels are restored when the command adding them is undone. +TEST(TDocStd_Transaction_Test, Buc_CafBug_60831_ModifiedAttributeUndo) +{ + occ::handle aDocument = NewTransactionDocument(); + aDocument->SetUndoLimit(100); + + aDocument->NewCommand(); + const TDF_Label aLabel = RootChild(aDocument, 3); + EXPECT_FALSE(HasModifiedLabels(aDocument)); + + aDocument->NewCommand(); + EXPECT_TRUE(TDocStd_Modified::Add(aLabel)); + EXPECT_TRUE(HasModifiedLabels(aDocument)); + + aDocument->NewCommand(); + ASSERT_TRUE(aDocument->Undo()); + EXPECT_FALSE(HasModifiedLabels(aDocument)); +} + +// caf/bugs/bug1722: a multi-document transaction manager commits and restores the +// second value while preserving the value set before the managed transaction. +TEST(TDocStd_Transaction_Test, CafBug_1722_MultiTransactionManagerUndoRedo) +{ + occ::handle aDocument = NewTransactionDocument(); + occ::handle aManager = new TDocStd_MultiTransactionManager(); + aDocument->SetUndoLimit(4); + aManager->SetUndoLimit(4); + aManager->AddDocument(aDocument); + + const TDF_Label aLabel = aDocument->Main().FindChild(1, true); + TDataStd_Real::Set(aLabel, 1.1); + EXPECT_DOUBLE_EQ(RealValue(aLabel), 1.1); + + aManager->OpenCommand(); + TDataStd_Real::Set(aLabel, 2.1); + EXPECT_DOUBLE_EQ(RealValue(aLabel), 2.1); + EXPECT_TRUE(aManager->GetAvailableUndos().IsEmpty()); + + ASSERT_TRUE(aManager->CommitCommand(TCollection_ExtendedString("Transaction1"))); + ASSERT_EQ(aManager->GetAvailableUndos().Length(), 1); + EXPECT_TRUE(aManager->GetAvailableUndos().First()->GetName().IsEqual( + TCollection_ExtendedString("Transaction1"))); + + aManager->Undo(); + EXPECT_DOUBLE_EQ(RealValue(aLabel), 1.1); + ASSERT_EQ(aManager->GetAvailableRedos().Length(), 1); + + aManager->Redo(); + EXPECT_DOUBLE_EQ(RealValue(aLabel), 2.1); + EXPECT_TRUE(aManager->GetAvailableRedos().IsEmpty()); +} + +// caf/bugs/bug25112: undoing a packed-map modification restores both removal +// and addition performed by one command. +TEST(TDocStd_Transaction_Test, CafBug_25112_IntPackedMapUndo) +{ + occ::handle aDocument = NewTransactionDocument(); + aDocument->SetUndoLimit(10); + const TDF_Label aLabel = aDocument->Main(); + + occ::handle aMap = TDataStd_IntPackedMap::Set(aLabel); + ASSERT_FALSE(aMap.IsNull()); + ASSERT_TRUE(aMap->Add(319)); + + aDocument->OpenCommand(); + ASSERT_TRUE(aMap->Add(344)); + ASSERT_TRUE(aMap->Remove(319)); + ASSERT_TRUE(aDocument->CommitCommand()); + + ASSERT_TRUE(aDocument->Undo()); + occ::handle aRestoredMap; + ASSERT_TRUE(aLabel.FindAttribute(TDataStd_IntPackedMap::GetID(), aRestoredMap)); + EXPECT_TRUE(aRestoredMap->Contains(319)); + EXPECT_FALSE(aRestoredMap->Contains(344)); +} + +// caf/bugs/bug29142: undo and redo of a forget-plus-replace command keep the +// integer attribute valid rather than leaving a missing attribute behind. +TEST(TDocStd_Transaction_Test, CafBug_29142_ForgetAndReplaceIntegerUndoRedo) +{ + occ::handle aDocument = NewTransactionDocument(); + aDocument->SetUndoLimit(100); + const TDF_Label aLabel = aDocument->Main().FindChild(1, true); + + aDocument->NewCommand(); + TDataStd_Integer::Set(aLabel, 111); + aDocument->NewCommand(); + TDataStd_Real::Set(aLabel, 0.234); + aDocument->NewCommand(); + ASSERT_TRUE(aLabel.ForgetAttribute(TDataStd_Integer::GetID())); + TDataStd_Integer::Set(aLabel, 222); + aDocument->NewCommand(); + + ASSERT_TRUE(aDocument->Undo()); + occ::handle aInteger; + ASSERT_TRUE(aLabel.FindAttribute(TDataStd_Integer::GetID(), aInteger)); + EXPECT_EQ(aInteger->Get(), 111); + occ::handle aReal; + ASSERT_TRUE(aLabel.FindAttribute(TDataStd_Real::GetID(), aReal)); + EXPECT_DOUBLE_EQ(aReal->Get(), 0.234); + + ASSERT_TRUE(aDocument->Redo()); + ASSERT_TRUE(aLabel.FindAttribute(TDataStd_Integer::GetID(), aInteger)); + EXPECT_EQ(aInteger->Get(), 222); +} + +// caf/bugs/bug31920: enabling entry indexing does not change the value +// retrieved from a label. +TEST(TDocStd_Transaction_Test, CafBug_31920_AccessLabelByEntry) +{ + occ::handle aDocument = NewTransactionDocument(); + const TDF_Label aLabel = aDocument->Main().Root().FindChild(2, true); + TDataStd_Integer::Set(aLabel, 5); + + occ::handle aValue; + ASSERT_TRUE(aLabel.FindAttribute(TDataStd_Integer::GetID(), aValue)); + EXPECT_EQ(aValue->Get(), 5); + + aDocument->GetData()->SetAccessByEntries(true); + TDF_Label aFoundLabel; + ASSERT_TRUE(aDocument->GetData()->GetLabel(TCollection_AsciiString("0:2"), aFoundLabel)); + EXPECT_EQ(aFoundLabel, aLabel); + ASSERT_TRUE(aFoundLabel.FindAttribute(TDataStd_Integer::GetID(), aValue)); + EXPECT_EQ(aValue->Get(), 5); +} + +// caf/bugs/bug2932_9: repeating an unchanged integer attribute must not hide +// the real attribute modification in the committed transaction delta. +TEST(TDocStd_Transaction_Test, CafBug_2932_9_UnchangedIntegerKeepsRealDelta) +{ + occ::handle aDocument = NewTransactionDocument(); + aDocument->SetUndoLimit(100); + const TDF_Label aLabel = RootChild(aDocument, 2); + + aDocument->NewCommand(); + TDataStd_Integer::Set(aLabel, 100); + TDataStd_Real::Set(aLabel, 300.0); + aDocument->NewCommand(); + + TDataStd_Integer::Set(aLabel, 100); + TDataStd_Real::Set(aLabel, 400.0); + aDocument->NewCommand(); + + ExpectLastDeltaIsReal(aDocument); +} + +// caf/bugs/bug2932_11: an unchanged name attribute must not become the +// reported modified attribute when a real value changes. +TEST(TDocStd_Transaction_Test, CafBug_2932_11_UnchangedNameKeepsRealDelta) +{ + occ::handle aDocument = NewTransactionDocument(); + aDocument->SetUndoLimit(100); + const TDF_Label aLabel = RootChild(aDocument, 2); + + aDocument->NewCommand(); + TDataStd_Name::Set(aLabel, TCollection_ExtendedString("New Name")); + TDataStd_Real::Set(aLabel, 300.0); + aDocument->NewCommand(); + + TDataStd_Name::Set(aLabel, TCollection_ExtendedString("New Name")); + TDataStd_Real::Set(aLabel, 400.0); + aDocument->NewCommand(); + + ExpectLastDeltaIsReal(aDocument); +} + +// caf/bugs/bug2932_1: unchanged integer-array values must not replace the +// real attribute modification in the transaction delta. +TEST(TDocStd_Transaction_Test, CafBug_2932_1_UnchangedIntegerArrayKeepsRealDelta) +{ + occ::handle aDocument = NewTransactionDocument(); + aDocument->SetUndoLimit(100); + const TDF_Label aLabel = RootChild(aDocument, 2); + + aDocument->NewCommand(); + occ::handle anArray = TDataStd_IntegerArray::Set(aLabel, 1, 2, false); + anArray->SetValue(1, 3); + anArray->SetValue(2, 4); + TDataStd_Real::Set(aLabel, 300.0); + aDocument->NewCommand(); + + anArray = TDataStd_IntegerArray::Set(aLabel, 1, 2, false); + anArray->SetValue(1, 3); + anArray->SetValue(2, 4); + TDataStd_Real::Set(aLabel, 400.0); + aDocument->NewCommand(); + + ExpectLastDeltaIsReal(aDocument); +} + +// caf/bugs/bug2932_16: the same delta rule applies to real arrays. +TEST(TDocStd_Transaction_Test, CafBug_2932_16_UnchangedRealArrayKeepsRealDelta) +{ + occ::handle aDocument = NewTransactionDocument(); + aDocument->SetUndoLimit(100); + const TDF_Label aLabel = RootChild(aDocument, 2); + + aDocument->NewCommand(); + occ::handle anArray = TDataStd_RealArray::Set(aLabel, 1, 2, false); + anArray->SetValue(1, 3.0); + anArray->SetValue(2, 4.0); + TDataStd_Real::Set(aLabel, 300.0); + aDocument->NewCommand(); + + anArray = TDataStd_RealArray::Set(aLabel, 1, 2, false); + anArray->SetValue(1, 3.0); + anArray->SetValue(2, 4.0); + TDataStd_Real::Set(aLabel, 400.0); + aDocument->NewCommand(); + + ExpectLastDeltaIsReal(aDocument); +} + +// bugs/caf/bug261: clearing redo history after two undo operations leaves no +// redo command available while preserving the remaining undo history. +TEST(TDocStd_Transaction_Test, CafBug_261_ClearRedosAfterUndo) +{ + occ::handle aDocument = NewTransactionDocument(); + aDocument->SetUndoLimit(10); + const TDF_Label aLabel = aDocument->Main(); + + aDocument->NewCommand(); + TDataStd_Real::Set(aLabel, 10.0); + aDocument->NewCommand(); + TDataStd_Real::Set(aLabel, 20.0); + aDocument->NewCommand(); + TDataStd_Real::Set(aLabel, 30.0); + aDocument->NewCommand(); + TDataStd_Real::Set(aLabel, 40.0); + + ASSERT_TRUE(aDocument->Undo()); + ASSERT_TRUE(aDocument->Undo()); + EXPECT_EQ(aDocument->GetAvailableUndos(), 1); + EXPECT_EQ(aDocument->GetAvailableRedos(), 2); + + aDocument->ClearRedos(); + EXPECT_EQ(aDocument->GetAvailableUndos(), 1); + EXPECT_EQ(aDocument->GetAvailableRedos(), 0); +} + +// bugs/caf/bug2932_2: repeating an unchanged real-array attribute must not +// replace the real attribute modification in the transaction delta. +TEST(TDocStd_Transaction_Test, CafBug_2932_2_UnchangedRealArrayKeepsRealDelta) +{ + occ::handle aDocument = NewTransactionDocument(); + aDocument->SetUndoLimit(100); + const TDF_Label aLabel = RootChild(aDocument, 2); + + aDocument->NewCommand(); + occ::handle anArray = TDataStd_RealArray::Set(aLabel, 1, 2, false); + anArray->SetValue(1, 3.0); + anArray->SetValue(2, 4.0); + TDataStd_Real::Set(aLabel, 300.0); + aDocument->NewCommand(); + + anArray = TDataStd_RealArray::Set(aLabel, 1, 2, false); + anArray->SetValue(1, 3.0); + anArray->SetValue(2, 4.0); + TDataStd_Real::Set(aLabel, 400.0); + aDocument->NewCommand(); + + ExpectLastDeltaIsReal(aDocument); +} + +// bugs/caf/bug2932_3: repeating an unchanged axis attribute must not replace +// the real attribute modification in the transaction delta. +TEST(TDocStd_Transaction_Test, CafBug_2932_3_UnchangedAxisKeepsRealDelta) +{ + occ::handle anApplication = new TDocStd_Application(); + BinDrivers::DefineFormat(anApplication); + occ::handle aDocument; + anApplication->NewDocument("BinOcaf", aDocument); + ASSERT_FALSE(aDocument.IsNull()); + aDocument->SetUndoLimit(100); + const TDF_Label aLabel = RootChild(aDocument, 2); + const gp_Lin anAxis(gp_Pnt(10.0, 20.0, 30.0), gp_Dir(100.0, 200.0, 300.0)); + + aDocument->NewCommand(); + TDataXtd_Axis::Set(aLabel, anAxis); + TDataStd_Real::Set(aLabel, 300.0); + aDocument->NewCommand(); + + TDataXtd_Axis::Set(aLabel, anAxis); + TDataStd_Real::Set(aLabel, 400.0); + aDocument->NewCommand(); + + ExpectLastDeltaIsReal(aDocument); +} + +// bugs/caf/bug2932_4: repeating an unchanged comment attribute must not +// replace the real attribute modification in the transaction delta. +TEST(TDocStd_Transaction_Test, CafBug_2932_4_UnchangedCommentKeepsRealDelta) +{ + occ::handle aDocument = NewTransactionDocument(); + aDocument->SetUndoLimit(100); + const TDF_Label aLabel = RootChild(aDocument, 2); + const TCollection_ExtendedString aComment("New Comment"); + + aDocument->NewCommand(); + TDataStd_Comment::Set(aLabel, aComment); + TDataStd_Real::Set(aLabel, 300.0); + aDocument->NewCommand(); + + TDataStd_Comment::Set(aLabel, aComment); + TDataStd_Real::Set(aLabel, 400.0); + aDocument->NewCommand(); + + ExpectLastDeltaIsReal(aDocument); +} + +// bugs/caf/bug2932_10: repeating an unchanged integer-array attribute must +// not replace the real attribute modification in the transaction delta. +TEST(TDocStd_Transaction_Test, CafBug_2932_10_UnchangedIntegerArrayKeepsRealDelta) +{ + occ::handle aDocument = NewTransactionDocument(); + aDocument->SetUndoLimit(100); + const TDF_Label aLabel = RootChild(aDocument, 2); + + aDocument->NewCommand(); + occ::handle anArray = TDataStd_IntegerArray::Set(aLabel, 1, 2, false); + anArray->SetValue(1, 3); + anArray->SetValue(2, 4); + TDataStd_Real::Set(aLabel, 300.0); + aDocument->NewCommand(); + + anArray = TDataStd_IntegerArray::Set(aLabel, 1, 2, false); + anArray->SetValue(1, 3); + anArray->SetValue(2, 4); + TDataStd_Real::Set(aLabel, 400.0); + aDocument->NewCommand(); + + ExpectLastDeltaIsReal(aDocument); +} + +// bugs/caf/bug2932_6: an unchanged current attribute must not replace the +// real attribute modification in the transaction delta. +TEST(TDocStd_Transaction_Test, CafBug_2932_6_UnchangedCurrentKeepsRealDelta) +{ + occ::handle aDocument = NewTransactionDocument(); + aDocument->SetUndoLimit(100); + const TDF_Label aLabel = RootChild(aDocument, 2); + + aDocument->NewCommand(); + TDataStd_Current::Set(aLabel); + TDataStd_Real::Set(aLabel, 300.0); + aDocument->NewCommand(); + + TDataStd_Current::Set(aLabel); + TDataStd_Real::Set(aLabel, 400.0); + aDocument->NewCommand(); + + ExpectLastDeltaIsReal(aDocument); +} + +// bugs/caf/bug2932_7: an unchanged expression must not replace the real +// attribute modification in the transaction delta. +TEST(TDocStd_Transaction_Test, CafBug_2932_7_UnchangedExpressionKeepsRealDelta) +{ + occ::handle aDocument = NewTransactionDocument(); + aDocument->SetUndoLimit(100); + const TDF_Label aLabel = RootChild(aDocument, 2); + const TCollection_ExtendedString anExpression("New Expression"); + + aDocument->NewCommand(); + TDataStd_Expression::Set(aLabel)->SetExpression(anExpression); + TDataStd_Real::Set(aLabel, 300.0); + aDocument->NewCommand(); + + TDataStd_Expression::Set(aLabel)->SetExpression(anExpression); + TDataStd_Real::Set(aLabel, 400.0); + aDocument->NewCommand(); + + ExpectLastDeltaIsReal(aDocument); +} + +// bugs/caf/bug2932_15: changing an integer while repeating an unchanged real +// must report the integer attribute as the last delta. +TEST(TDocStd_Transaction_Test, CafBug_2932_15_UnchangedRealKeepsIntegerDelta) +{ + occ::handle aDocument = NewTransactionDocument(); + aDocument->SetUndoLimit(100); + const TDF_Label aLabel = RootChild(aDocument, 2); + + aDocument->NewCommand(); + TDataStd_Real::Set(aLabel, 100.0); + TDataStd_Integer::Set(aLabel, 300); + aDocument->NewCommand(); + + TDataStd_Real::Set(aLabel, 100.0); + TDataStd_Integer::Set(aLabel, 400); + aDocument->NewCommand(); + + ExpectLastDeltaIs(aDocument, "TDataStd_Integer"); +} + +// bugs/caf/bug2932_17: an unchanged relation must not replace the real +// attribute modification in the transaction delta. +TEST(TDocStd_Transaction_Test, CafBug_2932_17_UnchangedRelationKeepsRealDelta) +{ + occ::handle aDocument = NewTransactionDocument(); + aDocument->SetUndoLimit(100); + const TDF_Label aLabel = RootChild(aDocument, 2); + const TCollection_ExtendedString aRelation("New Relation"); + + aDocument->NewCommand(); + TDataStd_Relation::Set(aLabel)->SetRelation(aRelation); + TDataStd_Real::Set(aLabel, 300.0); + aDocument->NewCommand(); + + TDataStd_Relation::Set(aLabel)->SetRelation(aRelation); + TDataStd_Real::Set(aLabel, 400.0); + aDocument->NewCommand(); + + ExpectLastDeltaIsReal(aDocument); +} + +// bugs/caf/bug2932_19: an unchanged variable must not replace the real +// attribute modification in the transaction delta. +TEST(TDocStd_Transaction_Test, CafBug_2932_19_UnchangedVariableKeepsRealDelta) +{ + occ::handle aDocument = NewTransactionDocument(); + aDocument->SetUndoLimit(100); + const TDF_Label aLabel = RootChild(aDocument, 2); + + aDocument->NewCommand(); + occ::handle aVariable = TDataStd_Variable::Set(aLabel); + aVariable->Unit(TCollection_AsciiString("kg/m3")); + aVariable->Constant(true); + TDataStd_Real::Set(aLabel, 300.0); + aDocument->NewCommand(); + + aVariable = TDataStd_Variable::Set(aLabel); + aVariable->Unit(TCollection_AsciiString("kg/m3")); + aVariable->Constant(true); + TDataStd_Real::Set(aLabel, 400.0); + aDocument->NewCommand(); + + ExpectLastDeltaIsReal(aDocument); +} + +// bugs/caf/bug2932_20: an unchanged label reference must not replace the real +// attribute modification in the transaction delta. +TEST(TDocStd_Transaction_Test, CafBug_2932_20_UnchangedReferenceKeepsRealDelta) +{ + occ::handle aDocument = NewTransactionDocument(); + aDocument->SetUndoLimit(100); + const TDF_Label aLabel = RootChild(aDocument, 2); + const TDF_Label aReference = RootChild(aDocument, 3); + + aDocument->NewCommand(); + TDF_Reference::Set(aLabel, aReference); + TDataStd_Real::Set(aLabel, 300.0); + aDocument->NewCommand(); + + TDF_Reference::Set(aLabel, aReference); + TDataStd_Real::Set(aLabel, 400.0); + aDocument->NewCommand(); + + ExpectLastDeltaIsReal(aDocument); +} + +// bugs/caf/bug2932_21: an unchanged tag source must not replace the real +// attribute modification in the transaction delta. +TEST(TDocStd_Transaction_Test, CafBug_2932_21_UnchangedTagSourceKeepsRealDelta) +{ + occ::handle aDocument = NewTransactionDocument(); + aDocument->SetUndoLimit(100); + const TDF_Label aLabel = RootChild(aDocument, 2); + + aDocument->NewCommand(); + TDF_TagSource::Set(aLabel)->Set(5); + TDataStd_Real::Set(aLabel, 300.0); + aDocument->NewCommand(); + + TDF_TagSource::Set(aLabel)->Set(5); + TDataStd_Real::Set(aLabel, 400.0); + aDocument->NewCommand(); + + ExpectLastDeltaIsReal(aDocument); +} + +// bugs/caf/bug2932_22: an unchanged function attribute must not replace the +// real attribute modification in the transaction delta. +TEST(TDocStd_Transaction_Test, CafBug_2932_22_UnchangedFunctionKeepsRealDelta) +{ + occ::handle aDocument = NewTransactionDocument(); + aDocument->SetUndoLimit(100); + const TDF_Label aLabel = RootChild(aDocument, 2); + const Standard_GUID aDriverGuid("5b35ca00-5b78-11d1-8940-080009dc3333"); + + aDocument->NewCommand(); + occ::handle aFunction = TFunction_Function::Set(aLabel, aDriverGuid); + aFunction->SetFailure(13); + TDataStd_Real::Set(aLabel, 300.0); + aDocument->NewCommand(); + + aFunction = TFunction_Function::Set(aLabel, aDriverGuid); + aFunction->SetFailure(13); + TDataStd_Real::Set(aLabel, 400.0); + aDocument->NewCommand(); + + ExpectLastDeltaIsReal(aDocument); +} + +// bugs/caf/bug2932_24: an unchanged position must not replace the real +// attribute modification in the transaction delta. +TEST(TDocStd_Transaction_Test, CafBug_2932_24_UnchangedPositionKeepsRealDelta) +{ + occ::handle aDocument = NewTransactionDocument(); + aDocument->SetUndoLimit(100); + const TDF_Label aLabel = RootChild(aDocument, 2); + const gp_Pnt aPosition(123.456, 789.012, 345.678); + + aDocument->NewCommand(); + TDataXtd_Position::Set(aLabel, aPosition); + TDataStd_Real::Set(aLabel, 300.0); + aDocument->NewCommand(); + + TDataXtd_Position::Set(aLabel, aPosition); + TDataStd_Real::Set(aLabel, 400.0); + aDocument->NewCommand(); + + ExpectLastDeltaIsReal(aDocument); +} + +// bugs/caf/bug2932_8: repeating unchanged construction geometry keeps both the +// named-shape and real attribute deltas in the transaction. +TEST(TDocStd_Transaction_Test, CafBug_2932_8_UnchangedGeometryKeepsBothDeltas) +{ + occ::handle anApplication; + occ::handle aDocument = NewApplicationTransactionDocument(anApplication); + ASSERT_FALSE(aDocument.IsNull()); + aDocument->SetUndoLimit(100); + const TDF_Label aLabel = RootChild(aDocument, 2); + const TopoDS_Shape aBox = + BRepPrimAPI_MakeBox(gp_Pnt(10.0, 20.0, 30.0), 100.0, 200.0, 300.0).Shape(); + + aDocument->NewCommand(); + TNaming_Builder(aLabel).Generated(aBox); + TDataXtd_Geometry::Set(aLabel)->SetType(TDataXtd_POINT); + TDataStd_Real::Set(aLabel, 300.0); + aDocument->NewCommand(); + + TNaming_Builder(aLabel).Generated(aBox); + TDataXtd_Geometry::Set(aLabel)->SetType(TDataXtd_POINT); + TDataStd_Real::Set(aLabel, 400.0); + aDocument->NewCommand(); + + ExpectLastDeltaHas(aDocument, "TDataStd_Real", "TNaming_NamedShape"); +} + +// bugs/caf/bug2932_13: an unchanged plane construction attribute must not +// replace the real attribute modification in the transaction delta. +TEST(TDocStd_Transaction_Test, CafBug_2932_13_UnchangedPlaneKeepsRealDelta) +{ + occ::handle anApplication; + occ::handle aDocument = NewApplicationTransactionDocument(anApplication); + ASSERT_FALSE(aDocument.IsNull()); + aDocument->SetUndoLimit(100); + const TDF_Label aLabel = RootChild(aDocument, 2); + const gp_Pln aPlane(gp_Pnt(10.0, 20.0, 30.0), gp_Dir(-1.0, 0.0, 0.0)); + + aDocument->NewCommand(); + TDataXtd_Plane::Set(aLabel, aPlane); + TDataStd_Real::Set(aLabel, 300.0); + aDocument->NewCommand(); + + TDataXtd_Plane::Set(aLabel, aPlane); + TDataStd_Real::Set(aLabel, 400.0); + aDocument->NewCommand(); + + ExpectLastDeltaIsReal(aDocument); +} + +// bugs/caf/bug2932_14: an unchanged point construction attribute must not +// replace the real attribute modification in the transaction delta. +TEST(TDocStd_Transaction_Test, CafBug_2932_14_UnchangedPointKeepsRealDelta) +{ + occ::handle anApplication; + occ::handle aDocument = NewApplicationTransactionDocument(anApplication); + ASSERT_FALSE(aDocument.IsNull()); + aDocument->SetUndoLimit(100); + const TDF_Label aLabel = RootChild(aDocument, 2); + const gp_Pnt aPoint(10.0, 20.0, 30.0); + + aDocument->NewCommand(); + TDataXtd_Point::Set(aLabel, aPoint); + TDataStd_Real::Set(aLabel, 300.0); + aDocument->NewCommand(); + + TDataXtd_Point::Set(aLabel, aPoint); + TDataStd_Real::Set(aLabel, 400.0); + aDocument->NewCommand(); + + ExpectLastDeltaIsReal(aDocument); +} + +// bugs/caf/bug2932_18: repeating an unchanged named shape keeps both the +// named-shape and real attribute deltas in the transaction. +TEST(TDocStd_Transaction_Test, CafBug_2932_18_UnchangedShapeKeepsBothDeltas) +{ + occ::handle anApplication; + occ::handle aDocument = NewApplicationTransactionDocument(anApplication); + ASSERT_FALSE(aDocument.IsNull()); + aDocument->SetUndoLimit(100); + const TDF_Label aLabel = RootChild(aDocument, 2); + const TopoDS_Shape aBox = + BRepPrimAPI_MakeBox(gp_Pnt(10.0, 20.0, 30.0), 100.0, 200.0, 300.0).Shape(); + + aDocument->NewCommand(); + TNaming_Builder(aLabel).Generated(aBox); + TDataStd_Real::Set(aLabel, 300.0); + aDocument->NewCommand(); + + TNaming_Builder(aLabel).Generated(aBox); + TDataStd_Real::Set(aLabel, 400.0); + aDocument->NewCommand(); + + ExpectLastDeltaHas(aDocument, "TDataStd_Real", "TNaming_NamedShape"); +} + +// bugs/caf/bug2932_5: unchanged constraint metadata must not replace the real +// attribute modification in the transaction delta. +TEST(TDocStd_Transaction_Test, CafBug_2932_5_UnchangedConstraintKeepsRealDelta) +{ + occ::handle anApplication; + occ::handle aDocument = NewApplicationTransactionDocument(anApplication); + ASSERT_FALSE(aDocument.IsNull()); + aDocument->SetUndoLimit(100); + const TDF_Label aLabel = RootChild(aDocument, 2); + const TDF_Label aShapeLabel = RootChild(aDocument, 3); + const TDF_Label anIntLabel = RootChild(aDocument, 4); + const TopoDS_Shape aBox = + BRepPrimAPI_MakeBox(gp_Pnt(10.0, 20.0, 30.0), 100.0, 200.0, 300.0).Shape(); + + aDocument->NewCommand(); + TNaming_Builder(aShapeLabel).Generated(aBox); + TDataStd_Integer::Set(anIntLabel, 10); + occ::handle aNamedShape; + ASSERT_TRUE(aShapeLabel.FindAttribute(TNaming_NamedShape::GetID(), aNamedShape)); + occ::handle aConstraint = TDataXtd_Constraint::Set(aLabel); + aConstraint->SetType(TDataXtd_TANGENT); + aConstraint->SetGeometry(1, aNamedShape); + aConstraint->SetPlane(aNamedShape); + TDataStd_Real::Set(aLabel, 300.0); + aDocument->NewCommand(); + + aConstraint = TDataXtd_Constraint::Set(aLabel); + aConstraint->SetType(TDataXtd_TANGENT); + aConstraint->SetGeometry(1, aNamedShape); + aConstraint->SetPlane(aNamedShape); + TDataStd_Real::Set(aLabel, 400.0); + aDocument->NewCommand(); + + EXPECT_EQ(aConstraint->GetType(), TDataXtd_TANGENT); + EXPECT_EQ(aConstraint->NbGeometries(), 1); + EXPECT_FALSE(aConstraint->GetPlane().IsNull()); + ExpectLastDeltaIsReal(aDocument); +} + +// bugs/caf/bug2932_12: unchanged pattern metadata must not replace the real +// attribute modification in the transaction delta. +TEST(TDocStd_Transaction_Test, CafBug_2932_12_UnchangedPatternKeepsRealDelta) +{ + occ::handle anApplication; + occ::handle aDocument = NewApplicationTransactionDocument(anApplication); + ASSERT_FALSE(aDocument.IsNull()); + aDocument->SetUndoLimit(100); + const TDF_Label aLabel = RootChild(aDocument, 2); + const TDF_Label aShapeLabel = RootChild(aDocument, 3); + const TDF_Label aRealLabel = RootChild(aDocument, 4); + const TDF_Label anIntLabel = RootChild(aDocument, 5); + const TopoDS_Shape aBox = + BRepPrimAPI_MakeBox(gp_Pnt(10.0, 20.0, 30.0), 100.0, 200.0, 300.0).Shape(); + + aDocument->NewCommand(); + TNaming_Builder(aShapeLabel).Generated(aBox); + TDataStd_Real::Set(aRealLabel, 123.456789); + TDataStd_Integer::Set(anIntLabel, 123456789); + + occ::handle aNamedShape; + ASSERT_TRUE(aShapeLabel.FindAttribute(TNaming_NamedShape::GetID(), aNamedShape)); + occ::handle aPatternValue; + ASSERT_TRUE(aRealLabel.FindAttribute(TDataStd_Real::GetID(), aPatternValue)); + occ::handle aPatternInstances; + ASSERT_TRUE(anIntLabel.FindAttribute(TDataStd_Integer::GetID(), aPatternInstances)); + + occ::handle aPattern = TDataXtd_PatternStd::Set(aLabel); + aPattern->Signature(1); + aPattern->Axis1(aNamedShape); + aPattern->Value1(aPatternValue); + aPattern->NbInstances1(aPatternInstances); + TDataStd_Real::Set(aLabel, 300.0); + aDocument->NewCommand(); + + aPattern = TDataXtd_PatternStd::Set(aLabel); + aPattern->Signature(1); + aPattern->Axis1(aNamedShape); + aPattern->Value1(aPatternValue); + aPattern->NbInstances1(aPatternInstances); + TDataStd_Real::Set(aLabel, 400.0); + aDocument->NewCommand(); + + EXPECT_EQ(aPattern->Signature(), 1); + ASSERT_FALSE(aPattern->Axis1().IsNull()); + EXPECT_TRUE(aPattern->Axis1()->Get().IsEqual(aBox)); + ASSERT_FALSE(aPattern->Value1().IsNull()); + EXPECT_DOUBLE_EQ(aPattern->Value1()->Get(), 123.456789); + ASSERT_FALSE(aPattern->NbInstances1().IsNull()); + EXPECT_EQ(aPattern->NbInstances1()->Get(), 123456789); + ExpectLastDeltaIsReal(aDocument); +} diff --git a/src/ApplicationFramework/TKLCAF/GTests/TDocStd_XLink_Test.cxx b/src/ApplicationFramework/TKLCAF/GTests/TDocStd_XLink_Test.cxx new file mode 100644 index 0000000000..f24715c136 --- /dev/null +++ b/src/ApplicationFramework/TKLCAF/GTests/TDocStd_XLink_Test.cxx @@ -0,0 +1,389 @@ +// Copyright (c) 2026 OPEN CASCADE SAS +// +// This file is part of Open CASCADE Technology software library. +// +// This library is free software; you can redistribute it and/or modify it under +// the terms of the GNU Lesser General Public License version 2.1 as published +// by the Free Software Foundation, with special exception defined in the file +// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT +// distribution for complete text of the license and disclaimer of any warranty. +// +// Alternatively, this file may be used under the terms of Open CASCADE +// commercial license or contractual agreement. + +#include + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace +{ +static occ::handle NewDocument() +{ + static occ::handle anApplication = new TDocStd_Application(); + occ::handle aDocument; + anApplication->NewDocument("BinOcaf", aDocument); + return aDocument; +} + +static TDF_Label NewLabel(const occ::handle& theDocument, const int theTag) +{ + return theDocument->Main().FindChild(theTag, true); +} + +static TopoDS_Shape MakeBox(const double theDx, const double theDy, const double theDz) +{ + return BRepPrimAPI_MakeBox(theDx, theDy, theDz).Shape(); +} + +static TopoDS_Shape MakeSphere(const double theRadius) +{ + return BRepPrimAPI_MakeSphere(theRadius).Shape(); +} + +static void SetShape(const TDF_Label& theLabel, const TopoDS_Shape& theShape) +{ + TNaming_Builder aBuilder(theLabel); + aBuilder.Generated(theShape); +} + +static occ::handle FindNamedShape(const TDF_Label& theLabel) +{ + occ::handle aNamedShape; + if (!theLabel.FindAttribute(TNaming_NamedShape::GetID(), aNamedShape)) + { + return occ::handle(); + } + return aNamedShape; +} + +static TopoDS_Shape ShapeOf(const TDF_Label& theLabel) +{ + const occ::handle aNamedShape = FindNamedShape(theLabel); + return aNamedShape.IsNull() ? TopoDS_Shape() : TNaming_Tool::GetShape(aNamedShape); +} + +static bool SameBounds(const TopoDS_Shape& theFirst, const TopoDS_Shape& theSecond) +{ + if (theFirst.IsNull() || theSecond.IsNull()) + { + return theFirst.IsNull() && theSecond.IsNull(); + } + + Bnd_Box aFirstBox; + Bnd_Box aSecondBox; + BRepBndLib::Add(theFirst, aFirstBox); + BRepBndLib::Add(theSecond, aSecondBox); + + double aFirstXMin = 0.0; + double aFirstYMin = 0.0; + double aFirstZMin = 0.0; + double aFirstXMax = 0.0; + double aFirstYMax = 0.0; + double aFirstZMax = 0.0; + double aSecondXMin = 0.0; + double aSecondYMin = 0.0; + double aSecondZMin = 0.0; + double aSecondXMax = 0.0; + double aSecondYMax = 0.0; + double aSecondZMax = 0.0; + aFirstBox.Get(aFirstXMin, aFirstYMin, aFirstZMin, aFirstXMax, aFirstYMax, aFirstZMax); + aSecondBox.Get(aSecondXMin, aSecondYMin, aSecondZMin, aSecondXMax, aSecondYMax, aSecondZMax); + + return std::fabs(aFirstXMin - aSecondXMin) <= 1.0e-12 + && std::fabs(aFirstYMin - aSecondYMin) <= 1.0e-12 + && std::fabs(aFirstZMin - aSecondZMin) <= 1.0e-12 + && std::fabs(aFirstXMax - aSecondXMax) <= 1.0e-12 + && std::fabs(aFirstYMax - aSecondYMax) <= 1.0e-12 + && std::fabs(aFirstZMax - aSecondZMax) <= 1.0e-12; +} + +static void EnableUndo(const occ::handle& theDocument) +{ + theDocument->SetUndoLimit(100); +} + +static void CommitAndUndoRedo(const occ::handle& theDocument) +{ + theDocument->NewCommand(); + ASSERT_TRUE(theDocument->Undo()); + ASSERT_TRUE(theDocument->Redo()); +} + +static void ExpectLinked(const TDF_Label& theTarget, const TDF_Label& theSource) +{ + occ::handle aXLink; + ASSERT_TRUE(theTarget.FindAttribute(TDocStd_XLink::GetID(), aXLink)); + EXPECT_FALSE(aXLink->LabelEntry().IsEmpty()); + + occ::handle aReference; + ASSERT_TRUE(theTarget.FindAttribute(TDF_Reference::GetID(), aReference)); + EXPECT_TRUE(aReference->Get() == theSource); +} +} // namespace + +// caf/xlink/A1: copy a named shape without a link inside one document. +TEST(TDocStd_XLink_Test, CafXLink_A1_CopySameDocument) +{ + occ::handle aDocument = NewDocument(); + EnableUndo(aDocument); + const TDF_Label aSource = NewLabel(aDocument, 2); + const TDF_Label aTarget = NewLabel(aDocument, 3); + const TopoDS_Shape aBox = MakeBox(100.0, 200.0, 300.0); + SetShape(aSource, aBox); + + aDocument->NewCommand(); + TDocStd_XLinkTool aTool; + aTool.Copy(aTarget, aSource); + ASSERT_TRUE(aTool.IsDone()); + CommitAndUndoRedo(aDocument); + + const TopoDS_Shape aCopiedBox = ShapeOf(aTarget); + ASSERT_FALSE(aCopiedBox.IsNull()); + EXPECT_TRUE(SameBounds(aBox, aCopiedBox)); +} + +// caf/xlink/A2: copy a self-contained named shape between documents. +TEST(TDocStd_XLink_Test, CafXLink_A2_CopyOtherDocument) +{ + occ::handle aSourceDocument = NewDocument(); + occ::handle aTargetDocument = NewDocument(); + EnableUndo(aTargetDocument); + const TDF_Label aSource = NewLabel(aSourceDocument, 2); + const TDF_Label aTarget = NewLabel(aTargetDocument, 3); + const TopoDS_Shape aBox = MakeBox(100.0, 200.0, 300.0); + SetShape(aSource, aBox); + + aTargetDocument->NewCommand(); + TDocStd_XLinkTool aTool; + aTool.Copy(aTarget, aSource); + ASSERT_TRUE(aTool.IsDone()); + CommitAndUndoRedo(aTargetDocument); + + const TopoDS_Shape aCopiedBox = ShapeOf(aTarget); + ASSERT_FALSE(aCopiedBox.IsNull()); + EXPECT_TRUE(SameBounds(aBox, aCopiedBox)); +} + +// caf/xlink/B1: create a link inside one document and preserve it through undo/redo. +TEST(TDocStd_XLink_Test, CafXLink_B1_CopyWithLinkSameDocument) +{ + occ::handle aDocument = NewDocument(); + EnableUndo(aDocument); + const TDF_Label aSource = NewLabel(aDocument, 2); + const TDF_Label aTarget = NewLabel(aDocument, 3); + const TopoDS_Shape aBox = MakeBox(100.0, 200.0, 300.0); + SetShape(aSource, aBox); + + aDocument->NewCommand(); + TDocStd_XLinkTool aTool; + aTool.CopyWithLink(aTarget, aSource); + ASSERT_TRUE(aTool.IsDone()); + CommitAndUndoRedo(aDocument); + + ExpectLinked(aTarget, aSource); + EXPECT_TRUE(SameBounds(aBox, ShapeOf(aTarget))); +} + +// caf/xlink/B2: a link follows source history through source undo/redo. +TEST(TDocStd_XLink_Test, CafXLink_B2_SourceUndoRedo) +{ + occ::handle aDocument = NewDocument(); + EnableUndo(aDocument); + const TDF_Label aSource = NewLabel(aDocument, 2); + const TDF_Label aTarget = NewLabel(aDocument, 3); + const TopoDS_Shape aBox = MakeBox(100.0, 200.0, 300.0); + SetShape(aSource, aBox); + + aDocument->NewCommand(); + TDocStd_XLinkTool aTool; + aTool.CopyWithLink(aTarget, aSource); + ASSERT_TRUE(aTool.IsDone()); + aDocument->NewCommand(); + + SetShape(aSource, MakeSphere(60.0)); + aDocument->NewCommand(); + ASSERT_TRUE(aDocument->Undo()); + ASSERT_TRUE(aDocument->Redo()); + + aTool.UpdateLink(aTarget); + ASSERT_TRUE(aTool.IsDone()); + + ExpectLinked(aTarget, aSource); + EXPECT_FALSE(SameBounds(aBox, ShapeOf(aTarget))); +} + +// caf/xlink/B4: create a link between two documents and preserve the copied shape. +TEST(TDocStd_XLink_Test, CafXLink_B4_CopyWithLinkOtherDocument) +{ + occ::handle aSourceDocument = NewDocument(); + occ::handle aTargetDocument = NewDocument(); + EnableUndo(aTargetDocument); + const TDF_Label aSource = NewLabel(aSourceDocument, 2); + const TDF_Label aTarget = NewLabel(aTargetDocument, 3); + const TopoDS_Shape aBox = MakeBox(100.0, 200.0, 300.0); + SetShape(aSource, aBox); + + aTargetDocument->NewCommand(); + TDocStd_XLinkTool aTool; + aTool.CopyWithLink(aTarget, aSource); + ASSERT_TRUE(aTool.IsDone()); + CommitAndUndoRedo(aTargetDocument); + + ExpectLinked(aTarget, aSource); + EXPECT_TRUE(SameBounds(aBox, ShapeOf(aTarget))); +} + +// caf/xlink/B5: the target remains a valid external link after source history changes. +TEST(TDocStd_XLink_Test, CafXLink_B5_SourceHistoryOtherDocument) +{ + occ::handle aSourceDocument = NewDocument(); + occ::handle aTargetDocument = NewDocument(); + EnableUndo(aSourceDocument); + EnableUndo(aTargetDocument); + const TDF_Label aSource = NewLabel(aSourceDocument, 2); + const TDF_Label aTarget = NewLabel(aTargetDocument, 3); + const TopoDS_Shape aBox = MakeBox(100.0, 200.0, 300.0); + SetShape(aSource, aBox); + + aTargetDocument->NewCommand(); + TDocStd_XLinkTool aTool; + aTool.CopyWithLink(aTarget, aSource); + ASSERT_TRUE(aTool.IsDone()); + aTargetDocument->NewCommand(); + + aSourceDocument->NewCommand(); + SetShape(aSource, MakeSphere(70.0)); + aSourceDocument->NewCommand(); + ASSERT_TRUE(aSourceDocument->Undo()); + ASSERT_TRUE(aSourceDocument->Redo()); + + aTool.UpdateLink(aTarget); + ASSERT_TRUE(aTool.IsDone()); + + ExpectLinked(aTarget, aSource); + EXPECT_FALSE(SameBounds(aBox, ShapeOf(aTarget))); +} + +// caf/xlink/C1: updating references keeps the explicitly changed target shape. +TEST(TDocStd_XLink_Test, CafXLink_C1_UpdateReferences) +{ + occ::handle aDocument = NewDocument(); + EnableUndo(aDocument); + const TDF_Label aSource = NewLabel(aDocument, 2); + const TDF_Label aTarget = NewLabel(aDocument, 3); + const TopoDS_Shape aBox = MakeBox(100.0, 200.0, 300.0); + SetShape(aSource, aBox); + + aDocument->NewCommand(); + TDocStd_XLinkTool aTool; + aTool.CopyWithLink(aTarget, aSource); + ASSERT_TRUE(aTool.IsDone()); + aDocument->NewCommand(); + + aDocument->NewCommand(); + SetShape(aTarget, MakeSphere(70.0)); + occ::handle aXLink; + ASSERT_TRUE(aTarget.FindAttribute(TDocStd_XLink::GetID(), aXLink)); + aDocument->UpdateReferences(aXLink->DocumentEntry()); + aDocument->NewCommand(); + ASSERT_TRUE(aDocument->Undo()); + ASSERT_TRUE(aDocument->Redo()); + + ExpectLinked(aTarget, aSource); + EXPECT_FALSE(SameBounds(aBox, ShapeOf(aTarget))); +} + +// caf/xlink/D1: explicitly update a link after changing its source document. +TEST(TDocStd_XLink_Test, CafXLink_D1_UpdateOtherDocument) +{ + occ::handle aSourceDocument = NewDocument(); + occ::handle aTargetDocument = NewDocument(); + EnableUndo(aSourceDocument); + EnableUndo(aTargetDocument); + const TDF_Label aSource = NewLabel(aSourceDocument, 2); + const TDF_Label aTarget = NewLabel(aTargetDocument, 3); + const TopoDS_Shape aBox = MakeBox(100.0, 200.0, 300.0); + SetShape(aSource, aBox); + + aTargetDocument->NewCommand(); + TDocStd_XLinkTool aTool; + aTool.CopyWithLink(aTarget, aSource); + ASSERT_TRUE(aTool.IsDone()); + aTargetDocument->NewCommand(); + + aSourceDocument->NewCommand(); + SetShape(aSource, MakeSphere(70.0)); + aSourceDocument->NewCommand(); + + aTargetDocument->NewCommand(); + aTool.UpdateLink(aTarget); + ASSERT_TRUE(aTool.IsDone()); + aTargetDocument->NewCommand(); + ASSERT_TRUE(aTargetDocument->Undo()); + ASSERT_TRUE(aTargetDocument->Redo()); + + ExpectLinked(aTarget, aSource); + EXPECT_FALSE(SameBounds(aBox, ShapeOf(aTarget))); +} + +// caf/xlink/D2: update two cross-document links independently. +TEST(TDocStd_XLink_Test, CafXLink_D2_UpdateAllOtherDocumentLinks) +{ + occ::handle aSourceDocument = NewDocument(); + occ::handle aTargetDocument = NewDocument(); + EnableUndo(aSourceDocument); + EnableUndo(aTargetDocument); + const TDF_Label aSource1 = NewLabel(aSourceDocument, 2); + const TDF_Label aSource2 = NewLabel(aSourceDocument, 22); + const TDF_Label aTarget1 = NewLabel(aTargetDocument, 3); + const TDF_Label aTarget2 = NewLabel(aTargetDocument, 32); + const TopoDS_Shape aBox1 = MakeBox(100.0, 200.0, 300.0); + const TopoDS_Shape aBox2 = MakeBox(2100.0, 2200.0, 2300.0); + SetShape(aSource1, aBox1); + SetShape(aSource2, aBox2); + + aTargetDocument->NewCommand(); + TDocStd_XLinkTool aTool; + aTool.CopyWithLink(aTarget1, aSource1); + ASSERT_TRUE(aTool.IsDone()); + aTool.CopyWithLink(aTarget2, aSource2); + ASSERT_TRUE(aTool.IsDone()); + aTargetDocument->NewCommand(); + + aSourceDocument->NewCommand(); + SetShape(aSource1, MakeSphere(70.0)); + SetShape(aSource2, MakeSphere(270.0)); + aSourceDocument->NewCommand(); + + aTargetDocument->NewCommand(); + aTool.UpdateLink(aTarget1); + ASSERT_TRUE(aTool.IsDone()); + aTool.UpdateLink(aTarget2); + ASSERT_TRUE(aTool.IsDone()); + aTargetDocument->NewCommand(); + ASSERT_TRUE(aTargetDocument->Undo()); + ASSERT_TRUE(aTargetDocument->Redo()); + + ExpectLinked(aTarget1, aSource1); + ExpectLinked(aTarget2, aSource2); + const TopoDS_Shape aUpdated1 = ShapeOf(aTarget1); + const TopoDS_Shape aUpdated2 = ShapeOf(aTarget2); + EXPECT_FALSE(SameBounds(aBox1, aUpdated1)); + EXPECT_FALSE(SameBounds(aBox2, aUpdated2)); + EXPECT_FALSE(SameBounds(aUpdated1, aUpdated2)); +} diff --git a/src/ApplicationFramework/TKTObj/GTests/TObj_Model_Test.cxx b/src/ApplicationFramework/TKTObj/GTests/TObj_Model_Test.cxx index 8902656345..6c7845a24b 100644 --- a/src/ApplicationFramework/TKTObj/GTests/TObj_Model_Test.cxx +++ b/src/ApplicationFramework/TKTObj/GTests/TObj_Model_Test.cxx @@ -12,7 +12,10 @@ // commercial license or contractual agreement. #include +#include +#include #include +#include #include #include #include @@ -20,9 +23,13 @@ #include #include #include +#include #include +#include #include +#include + #include // Minimal concrete subclass of TObj_Model for testing purposes. @@ -43,16 +50,73 @@ IMPLEMENT_STANDARD_RTTIEXT(TObj_TestModel, TObj_Model) // TObj_Object has a protected constructor. class TObj_TestObject : public TObj_Object { +protected: + enum DataTag + { + DataTag_First = TObj_Object::DataTag_Last, + DataTag_IntVal, + DataTag_RealArr, + DataTag_Last = DataTag_First + 100 + }; + + enum RefTag + { + RefTag_First = TObj_Object::RefTag_Last, + RefTag_Other, + RefTag_Last = RefTag_First + 100 + }; + + enum ChildTag + { + ChildTag_First = TObj_Object::ChildTag_Last, + ChildTag_Child, + ChildTag_Last = ChildTag_First + 100 + }; + public: TObj_TestObject(const TDF_Label& theLabel, const bool theSetName = true) : TObj_Object(theLabel, theSetName) { } + void SetInt(const int theValue) { setInteger(theValue, DataTag_IntVal); } + + int GetInt() const { return getInteger(DataTag_IntVal); } + + void SetRealArr(const occ::handle>& theArray) + { + setArray(theArray, DataTag_RealArr); + } + + occ::handle> GetRealArr() const + { + return getRealArray(0, DataTag_RealArr); + } + + void SetRef(const occ::handle& theObject) { setReference(theObject, RefTag_Other); } + + occ::handle GetRef() const { return getReference(RefTag_Other); } + + occ::handle AddChild() + { + return new TObj_TestObject(getChildLabel(ChildTag_Child).NewChild()); + } + +protected: + DECLARE_TOBJOCAF_PERSISTENCE(TObj_TestObject, TObj_Object) + DEFINE_STANDARD_RTTIEXT(TObj_TestObject, TObj_Object) }; IMPLEMENT_STANDARD_RTTIEXT(TObj_TestObject, TObj_Object) +IMPLEMENT_TOBJOCAF_PERSISTENCE(TObj_TestObject) + +static occ::handle FindTestObject(const occ::handle& theModel, + const char* theName) +{ + occ::handle aName = new TCollection_HExtendedString(theName); + return occ::down_cast(theModel->FindObject(aName, theModel->GetDictionary())); +} // Test fixture that creates and initializes a TObj_Model. class TObj_ModelTest : public testing::Test @@ -228,6 +292,107 @@ TEST_F(TObj_ModelTest, Messenger_SetAndGet) EXPECT_EQ(aMsgr.get(), myModel->Messenger().get()); } +// bugs/caf/bug29901: TObj save and restore preserve an integer through streams. +TEST_F(TObj_ModelTest, CafBug_29901_StreamInteger) +{ + BinTObjDrivers::DefineFormat(myModel->GetApplication()); + myModel->OpenCommand(); + occ::handle anObject = + new TObj_TestObject(myModel->GetMainPartition()->NewLabel()); + ASSERT_TRUE(anObject->SetName("obj1")); + anObject->SetInt(29901); + myModel->CommitCommand(); + + std::ostringstream aStream; + ASSERT_TRUE(myModel->SaveAs(aStream)); + ASSERT_FALSE(aStream.str().empty()); + ASSERT_TRUE(myModel->Close()); + + std::istringstream aInput(aStream.str()); + occ::handle aRestored = new TObj_TestModel(); + ASSERT_TRUE(aRestored->Load(aInput)); + occ::handle aRestoredObject = FindTestObject(aRestored, "obj1"); + ASSERT_FALSE(aRestoredObject.IsNull()); + EXPECT_EQ(aRestoredObject->GetInt(), 29901); + EXPECT_TRUE(aRestored->Close()); +} + +// bugs/caf/bug21231: TObj stream storage preserves names, hierarchy, references, +// an integer value, and an array of real values. +TEST_F(TObj_ModelTest, CafBug_21231_StreamObjectGraph) +{ + BinTObjDrivers::DefineFormat(myModel->GetApplication()); + myModel->OpenCommand(); + occ::handle anObject1 = + new TObj_TestObject(myModel->GetMainPartition()->NewLabel()); + occ::handle anObject2 = + new TObj_TestObject(myModel->GetMainPartition()->NewLabel()); + occ::handle anObject3 = + new TObj_TestObject(myModel->GetMainPartition()->NewLabel()); + ASSERT_TRUE(anObject1->SetName("obj1")); + ASSERT_TRUE(anObject2->SetName("obj2")); + ASSERT_TRUE(anObject3->SetName("obj3")); + + occ::handle aChild11 = anObject1->AddChild(); + occ::handle aChild21 = anObject2->AddChild(); + occ::handle aChild22 = anObject2->AddChild(); + ASSERT_TRUE(aChild11->SetName("ch11")); + ASSERT_TRUE(aChild21->SetName("ch21")); + ASSERT_TRUE(aChild22->SetName("ch22")); + + anObject1->SetRef(anObject2); + anObject1->SetInt(533); + occ::handle> aValues = new NCollection_HArray1(1, 3); + aValues->SetValue(1, 3.14); + aValues->SetValue(2, 2.78); + aValues->SetValue(3, 0.123); + anObject2->SetRealArr(aValues); + myModel->CommitCommand(); + + std::ostringstream aStream; + ASSERT_TRUE(myModel->SaveAs(aStream)); + ASSERT_FALSE(aStream.str().empty()); + ASSERT_TRUE(myModel->Close()); + + std::istringstream aInput(aStream.str()); + occ::handle aRestored = new TObj_TestModel(); + ASSERT_TRUE(aRestored->Load(aInput)); + occ::handle aRestoredObject1 = FindTestObject(aRestored, "obj1"); + occ::handle aRestoredObject2 = FindTestObject(aRestored, "obj2"); + ASSERT_FALSE(aRestoredObject1.IsNull()); + ASSERT_FALSE(aRestoredObject2.IsNull()); + + occ::handle anIterator = aRestoredObject2->GetChildren(); + ASSERT_FALSE(anIterator.IsNull()); + ASSERT_TRUE(anIterator->More()); + TCollection_AsciiString aFirstChildName; + ASSERT_TRUE(anIterator->Value()->GetName(aFirstChildName)); + anIterator->Next(); + ASSERT_TRUE(anIterator->More()); + TCollection_AsciiString aSecondChildName; + ASSERT_TRUE(anIterator->Value()->GetName(aSecondChildName)); + anIterator->Next(); + EXPECT_FALSE(anIterator->More()); + EXPECT_TRUE((aFirstChildName == "ch21" && aSecondChildName == "ch22") + || (aFirstChildName == "ch22" && aSecondChildName == "ch21")); + + occ::handle aRestoredReference = aRestoredObject1->GetRef(); + ASSERT_FALSE(aRestoredReference.IsNull()); + TCollection_AsciiString aReferenceName; + ASSERT_TRUE(aRestoredReference->GetName(aReferenceName)); + EXPECT_EQ(aReferenceName, "obj2"); + EXPECT_EQ(aRestoredObject1->GetInt(), 533); + + occ::handle> aRestoredValues = aRestoredObject2->GetRealArr(); + ASSERT_FALSE(aRestoredValues.IsNull()); + ASSERT_EQ(aRestoredValues->Length(), 3); + EXPECT_DOUBLE_EQ(aRestoredValues->Value(1), 3.14); + EXPECT_DOUBLE_EQ(aRestoredValues->Value(2), 2.78); + EXPECT_DOUBLE_EQ(aRestoredValues->Value(3), 0.123); + EXPECT_FALSE(FindTestObject(aRestored, "obj3").IsNull()); + EXPECT_TRUE(aRestored->Close()); +} + // Tests for TObj_Object functionality within a model context. class TObj_ObjectTest : public testing::Test { @@ -458,6 +623,59 @@ TEST_F(TObj_ObjectTest, ModelIteration_AfterAddingObjects) EXPECT_EQ(3, aCount); } +// caf/bugs/bug31323: typed child iteration remains recursive through all +// object levels. +TEST_F(TObj_ObjectTest, CafBug_31323_RecursiveTypedChildren) +{ + myModel->OpenCommand(); + occ::handle anObject = createObject(); + occ::handle aSub1 = anObject->AddChild(); + occ::handle aSub2 = anObject->AddChild(); + occ::handle aSub11 = aSub1->AddChild(); + occ::handle aSub12 = aSub1->AddChild(); + occ::handle aSub13 = aSub1->AddChild(); + occ::handle aSub121 = aSub12->AddChild(); + ASSERT_TRUE(anObject->SetName("obj")); + ASSERT_TRUE(aSub1->SetName("sub1")); + ASSERT_TRUE(aSub2->SetName("sub2")); + ASSERT_TRUE(aSub11->SetName("sub11")); + ASSERT_TRUE(aSub12->SetName("sub12")); + ASSERT_TRUE(aSub13->SetName("sub13")); + ASSERT_TRUE(aSub121->SetName("sub121")); + myModel->CommitCommand(); + + occ::handle aFlatIterator = anObject->GetChildren(); + ASSERT_FALSE(aFlatIterator.IsNull()); + NCollection_IndexedMap aFlatNames; + for (; aFlatIterator->More(); aFlatIterator->Next()) + { + TCollection_AsciiString aName; + ASSERT_TRUE(aFlatIterator->Value()->GetName(aName)); + aFlatNames.Add(aName); + } + ASSERT_EQ(aFlatNames.Extent(), 2); + EXPECT_TRUE(aFlatNames.Contains(TCollection_AsciiString("sub1"))); + EXPECT_TRUE(aFlatNames.Contains(TCollection_AsciiString("sub2"))); + + occ::handle anIterator = + new TObj_OcafObjectIterator(anObject->GetChildLabel(), nullptr, true, true); + ASSERT_FALSE(anIterator.IsNull()); + NCollection_IndexedMap anAllNames; + for (; anIterator->More(); anIterator->Next()) + { + TCollection_AsciiString aName; + ASSERT_TRUE(anIterator->Value()->GetName(aName)); + anAllNames.Add(aName); + } + ASSERT_EQ(anAllNames.Extent(), 6); + EXPECT_TRUE(anAllNames.Contains(TCollection_AsciiString("sub1"))); + EXPECT_TRUE(anAllNames.Contains(TCollection_AsciiString("sub2"))); + EXPECT_TRUE(anAllNames.Contains(TCollection_AsciiString("sub11"))); + EXPECT_TRUE(anAllNames.Contains(TCollection_AsciiString("sub12"))); + EXPECT_TRUE(anAllNames.Contains(TCollection_AsciiString("sub13"))); + EXPECT_TRUE(anAllNames.Contains(TCollection_AsciiString("sub121"))); +} + TEST_F(TObj_ObjectTest, GetTypeFlags_DefaultVisible) { myModel->OpenCommand(); diff --git a/src/ApplicationFramework/TKVCAF/GTests/FILES.cmake b/src/ApplicationFramework/TKVCAF/GTests/FILES.cmake index 22d93b30b4..a8011cda1e 100644 --- a/src/ApplicationFramework/TKVCAF/GTests/FILES.cmake +++ b/src/ApplicationFramework/TKVCAF/GTests/FILES.cmake @@ -2,4 +2,5 @@ set(OCCT_TKVCAF_GTests_FILES_LOCATION "${CMAKE_CURRENT_LIST_DIR}") set(OCCT_TKVCAF_GTests_FILES + TPrsStd_AISPresentation_Test.cxx ) diff --git a/src/ApplicationFramework/TKVCAF/GTests/TPrsStd_AISPresentation_Test.cxx b/src/ApplicationFramework/TKVCAF/GTests/TPrsStd_AISPresentation_Test.cxx new file mode 100644 index 0000000000..2a27c462f9 --- /dev/null +++ b/src/ApplicationFramework/TKVCAF/GTests/TPrsStd_AISPresentation_Test.cxx @@ -0,0 +1,37 @@ +// Copyright (c) 2026 OPEN CASCADE SAS +// +// This file is part of Open CASCADE Technology software library. +// +// This library is free software; you can redistribute it and/or modify it under +// the terms of the GNU Lesser General Public License version 2.1 as published +// by the Free Software Foundation, with special exception defined in the file +// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT +// distribution for complete text of the license and disclaimer of any warranty. +// +// Alternatively, this file may be used under the terms of Open CASCADE +// commercial license or contractual agreement. + +#include +#include +#include + +#include + +// Migrated from tests/bugs/caf/buc60910. +// The DRAW case checks presentation mode state only; it does not create a +// viewer or otherwise exercise visualization output. +TEST(TPrsStd_AISPresentationTest, CafBug_60910_ModeState) +{ + const occ::handle aDocument = new TDocStd_Document("BinOcaf"); + const TDF_Label aLabel = aDocument->Main().FindChild(2, true); + const occ::handle aPresentation = + TPrsStd_AISPresentation::Set(aLabel, TDataXtd_Constraint::GetID()); + ASSERT_FALSE(aPresentation.IsNull()); + + EXPECT_FALSE(aPresentation->HasOwnMode()); + aPresentation->SetMode(3); + EXPECT_EQ(aPresentation->Mode(), 3); + EXPECT_TRUE(aPresentation->HasOwnMode()); + aPresentation->UnsetMode(); + EXPECT_FALSE(aPresentation->HasOwnMode()); +} diff --git a/src/ApplicationFramework/TKXml/GTests/FILES.cmake b/src/ApplicationFramework/TKXml/GTests/FILES.cmake index 22b8dcce33..6689c6662e 100644 --- a/src/ApplicationFramework/TKXml/GTests/FILES.cmake +++ b/src/ApplicationFramework/TKXml/GTests/FILES.cmake @@ -2,4 +2,7 @@ set(OCCT_TKXml_GTests_FILES_LOCATION "${CMAKE_CURRENT_LIST_DIR}") set(OCCT_TKXml_GTests_FILES + TDocStd_Progress_Test.cxx + TDocStd_Storage_Test.cxx + XmlOcaf_Storage_Test.cxx ) diff --git a/src/ApplicationFramework/TKXml/GTests/TDocStd_Progress_Test.cxx b/src/ApplicationFramework/TKXml/GTests/TDocStd_Progress_Test.cxx new file mode 100644 index 0000000000..6e36fc7ade --- /dev/null +++ b/src/ApplicationFramework/TKXml/GTests/TDocStd_Progress_Test.cxx @@ -0,0 +1,424 @@ +// Copyright (c) 2026 OPEN CASCADE SAS +// +// This file is part of Open CASCADE Technology software library. +// +// This library is free software; you can redistribute it and/or modify it under +// the terms of the GNU Lesser General Public License version 2.1 as published +// by the Free Software Foundation, with special exception defined in the file +// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT +// distribution for complete text of the license and disclaimer of any warranty. +// +// Alternatively, this file may be used under the terms of Open CASCADE +// commercial license or contractual agreement. + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include + +namespace +{ +class ProgressObserver : public Message_ProgressIndicator +{ +public: + const NCollection_Sequence& Messages() const { return myMessages; } + +protected: + void Show(const Message_ProgressScope& theScope, const bool) override + { + TCollection_AsciiString aMessage("Progress: "); + aMessage += static_cast(100.0 * GetPosition() + 0.5); + aMessage += "%"; + const Message_ProgressScope* aScope = &theScope; + while (aScope != nullptr) + { + if (aScope->Name() != nullptr) + { + aMessage += " "; + aMessage += aScope->Name(); + } + aScope = aScope->Parent(); + } + myMessages.Append(aMessage); + } + +private: + NCollection_Sequence myMessages; +}; + +// Keep the text formatting used by Draw_ProgressIndicator for tests which +// validate the complete nested-scope output. +class DrawTextProgressObserver : public Message_ProgressIndicator +{ +public: + const NCollection_Sequence& Messages() const { return myMessages; } + +protected: + void Show(const Message_ProgressScope& theScope, const bool) override + { + TCollection_AsciiString aMessage("Progress: "); + aMessage += static_cast(100.0 * GetPosition() + 0.5); + aMessage += "%"; + + NCollection_List aScopes; + for (const Message_ProgressScope* aScope = &theScope; aScope != nullptr; + aScope = aScope->Parent()) + { + aScopes.Prepend(aScope); + } + for (NCollection_List::Iterator anIterator(aScopes); + anIterator.More(); + anIterator.Next()) + { + const Message_ProgressScope* aScope = anIterator.Value(); + if (aScope->Name() == nullptr) + { + continue; + } + + aMessage += " "; + aMessage += aScope->Name(); + aMessage += ": "; + if (aScope->IsInfinite()) + { + if (Precision::IsInfinite(aScope->Value())) + { + aMessage += "finished"; + } + else + { + aMessage += static_cast(aScope->Value() + 0.5); + } + } + else + { + aMessage += static_cast(aScope->Value() + 0.5); + aMessage += " / "; + aMessage += static_cast(aScope->MaxValue() + 0.5); + } + } + myMessages.Append(aMessage); + } + +private: + NCollection_Sequence myMessages; +}; + +static occ::handle NewApplication() +{ + occ::handle anApplication = new TDocStd_Application(); + XmlDrivers::DefineFormat(anApplication); + BinDrivers::DefineFormat(anApplication); + return anApplication; +} + +static occ::handle NewDocument( + const occ::handle& theApplication, + const char* theFormat) +{ + occ::handle aDocument; + theApplication->NewDocument(theFormat, aDocument); + EXPECT_FALSE(aDocument.IsNull()); + return aDocument; +} + +static TCollection_ExtendedString MakeTemporaryFile(OSD_Directory& theDirectory, + OSD_Path& thePath, + const char* theName, + const char* theExtension) +{ + theDirectory.Path(thePath); + thePath.SetName(theName); + thePath.SetExtension(theExtension); + TCollection_AsciiString aSystemName; + thePath.SystemName(aSystemName); + return TCollection_ExtendedString(aSystemName, true); +} + +static void SetBox(const TDF_Label& theLabel) +{ + TNaming_Builder aBuilder(theLabel); + aBuilder.Generated(BRepPrimAPI_MakeBox(1.0, 1.0, 1.0).Shape()); +} + +static bool HasMessage(const ProgressObserver& theObserver, const char* theText) +{ + for (NCollection_Sequence::Iterator anIterator(theObserver.Messages()); + anIterator.More(); + anIterator.Next()) + { + if (anIterator.Value().Search(theText) != -1) + { + return true; + } + } + return false; +} + +static void ExpectMessages(const ProgressObserver& theObserver, + const char* const theExpectedMessages[], + const int theNbExpectedMessages) +{ + ASSERT_GT(theObserver.Messages().Length(), 0); + EXPECT_TRUE(HasMessage(theObserver, "0%")); + EXPECT_TRUE(HasMessage(theObserver, "100%")); + for (int anIndex = 0; anIndex < theNbExpectedMessages; ++anIndex) + { + EXPECT_TRUE(HasMessage(theObserver, theExpectedMessages[anIndex])) + << theExpectedMessages[anIndex]; + } +} + +static void RunSaveAsProgress(const char* theFormat, + const char* theName, + const char* const theExpectedMessages[], + const int theNbExpectedMessages) +{ + occ::handle anApplication = NewApplication(); + occ::handle aDocument = NewDocument(anApplication, theFormat); + ASSERT_FALSE(aDocument.IsNull()); + SetBox(aDocument->Main().FindChild(1, true)); + + OSD_Directory aDirectory = OSD_Directory::BuildTemporary(); + OSD_Path aPath; + const TCollection_ExtendedString aFileName = + MakeTemporaryFile(aDirectory, + aPath, + theName, + strcmp(theFormat, "BinOcaf") == 0 ? ".cbf" : ".xml"); + occ::handle aProgress = new ProgressObserver(); + EXPECT_EQ( + anApplication->SaveAs(aDocument, aFileName, Message_ProgressIndicator::Start(aProgress)), + PCDM_SS_OK); + OSD_File aFile(aPath); + EXPECT_TRUE(aFile.Exists()); + ExpectMessages(*aProgress, theExpectedMessages, theNbExpectedMessages); + anApplication->Close(aDocument); + if (aFile.Exists()) + { + aFile.Remove(); + } +} + +static void RunOpenProgress(const char* theFormat, + const char* theName, + const char* const theExpectedMessages[], + const int theNbExpectedMessages) +{ + occ::handle anApplication = NewApplication(); + occ::handle aDocument = NewDocument(anApplication, theFormat); + ASSERT_FALSE(aDocument.IsNull()); + SetBox(aDocument->Main().FindChild(1, true)); + + OSD_Directory aDirectory = OSD_Directory::BuildTemporary(); + OSD_Path aPath; + const TCollection_ExtendedString aFileName = + MakeTemporaryFile(aDirectory, + aPath, + theName, + strcmp(theFormat, "BinOcaf") == 0 ? ".cbf" : ".xml"); + EXPECT_EQ(anApplication->SaveAs(aDocument, aFileName), PCDM_SS_OK); + anApplication->Close(aDocument); + + occ::handle aProgress = new ProgressObserver(); + occ::handle aRestored; + EXPECT_EQ(anApplication->Open(aFileName, aRestored, Message_ProgressIndicator::Start(aProgress)), + PCDM_RS_OK); + ASSERT_FALSE(aRestored.IsNull()); + ExpectMessages(*aProgress, theExpectedMessages, theNbExpectedMessages); + anApplication->Close(aRestored); + OSD_File aFile(aPath); + if (aFile.Exists()) + { + aFile.Remove(); + } +} + +static void RunSaveProgress(const char* theFormat, + const char* theName, + const char* const theExpectedMessages[], + const int theNbExpectedMessages) +{ + occ::handle anApplication = NewApplication(); + occ::handle aDocument = NewDocument(anApplication, theFormat); + ASSERT_FALSE(aDocument.IsNull()); + SetBox(aDocument->Main().FindChild(1, true)); + + OSD_Directory aDirectory = OSD_Directory::BuildTemporary(); + OSD_Path aPath; + const TCollection_ExtendedString aFileName = + MakeTemporaryFile(aDirectory, + aPath, + theName, + strcmp(theFormat, "BinOcaf") == 0 ? ".cbf" : ".xml"); + EXPECT_EQ(anApplication->SaveAs(aDocument, aFileName), PCDM_SS_OK); + anApplication->Close(aDocument); + + occ::handle aOpened; + EXPECT_EQ(anApplication->Open(aFileName, aOpened), PCDM_RS_OK); + ASSERT_FALSE(aOpened.IsNull()); + SetBox(aOpened->Main().FindChild(2, true)); + aOpened->NewCommand(); + + occ::handle aProgress = new ProgressObserver(); + EXPECT_EQ(anApplication->Save(aOpened, Message_ProgressIndicator::Start(aProgress)), PCDM_SS_OK); + ExpectMessages(*aProgress, theExpectedMessages, theNbExpectedMessages); + anApplication->Close(aOpened); + OSD_File aFile(aPath); + if (aFile.Exists()) + { + aFile.Remove(); + } +} + +static void RunNestedProgress(const bool theIsInfinite, + const char* const theExpectedMessages[], + const int theNbExpectedMessages) +{ + occ::handle aProgress = new DrawTextProgressObserver(); + { + Message_ProgressScope anOuter(aProgress->Start(), "Outer", 3); + for (int anOuterIndex = 0; anOuterIndex < 3 && anOuter.More(); ++anOuterIndex) + { + Message_ProgressScope anInner(anOuter.Next(), "Inner", 2, theIsInfinite); + for (int anInnerIndex = 0; anInnerIndex < (theIsInfinite ? 4 : 2) && anInner.More(); + ++anInnerIndex, anInner.Next()) + { + } + } + } + + ASSERT_EQ(aProgress->Messages().Length(), theNbExpectedMessages); + for (int anIndex = 1; anIndex <= theNbExpectedMessages; ++anIndex) + { + EXPECT_STREQ(theExpectedMessages[anIndex - 1], aProgress->Messages()(anIndex).ToCString()) + << "Unexpected progress message at index " << anIndex; + } +} +} // namespace + +// caf/progress/A1: binary SaveAs progress reports the document and subtree stages. +TEST(TDocStd_Progress_Test, CafProgress_A1_BinarySaveAs) +{ + const char* const anExpected[] = {"Writing document", "Writing sub tree"}; + RunSaveAsProgress("BinOcaf", "draw_progress_binary_save_as", anExpected, 2); +} + +// caf/progress/A2: XML SaveAs progress reports the storage stages. +TEST(TDocStd_Progress_Test, CafProgress_A2_XmlSaveAs) +{ + const char* const anExpected[] = {"Writing sub-tree", + "Writing shape section", + "Writing", + "Geometry", + "2D Curves", + "3D Curves", + "Polygons On Triangulation", + "Surfaces", + "3D Polygons", + "Triangulations", + "Shapes"}; + RunSaveAsProgress("XmlOcaf", "draw_progress_xml_save_as", anExpected, 11); +} + +// caf/progress/B1: binary Open progress reports the document and subtree stages. +TEST(TDocStd_Progress_Test, CafProgress_B1_BinaryOpen) +{ + const char* const anExpected[] = {"Reading data", "Reading sub tree"}; + RunOpenProgress("BinOcaf", "draw_progress_binary_open", anExpected, 2); +} + +// caf/progress/B2: XML Open progress reports the retrieval stages. +TEST(TDocStd_Progress_Test, CafProgress_B2_XmlOpen) +{ + const char* const anExpected[] = {"Reading document", + "Reading", + "3D Curves", + "2D Curves", + "3D Polygons", + "Polygons On Triangulation", + "Shapes", + "Triangulations", + "Surfaces", + "Reading sub-tree"}; + RunOpenProgress("XmlOcaf", "draw_progress_xml_open", anExpected, 10); +} + +// caf/progress/C1: binary Save progress reports the document and subtree stages. +TEST(TDocStd_Progress_Test, CafProgress_C1_BinarySave) +{ + const char* const anExpected[] = {"Writing document", "Writing sub tree"}; + RunSaveProgress("BinOcaf", "draw_progress_binary_save", anExpected, 2); +} + +// caf/progress/C2: XML Save progress reports the storage stages. +TEST(TDocStd_Progress_Test, CafProgress_C2_XmlSave) +{ + const char* const anExpected[] = {"Writing sub-tree", + "Writing shape section", + "Polygons On Triangulation", + "3D Polygons", + "Locations", + "Writing", + "Geometry", + "2D Curves", + "Triangulations", + "3D Curves", + "Surfaces", + "Shapes"}; + RunSaveProgress("XmlOcaf", "draw_progress_xml_save", anExpected, 12); +} + +// fclasses/bug28478: nested finite scopes retain both scope names and values. +TEST(TDocStd_Progress_Test, FClassesBug_28478_NestedFiniteScopes) +{ + const char* const anExpected[] = {"Progress: 0%", + "Progress: 17% Outer: 1 / 3 Inner: 1 / 2", + "Progress: 33% Outer: 1 / 3 Inner: 2 / 2", + "Progress: 50% Outer: 2 / 3 Inner: 1 / 2", + "Progress: 67% Outer: 2 / 3 Inner: 2 / 2", + "Progress: 83% Outer: 3 / 3 Inner: 1 / 2", + "Progress: 100% Outer: 3 / 3 Inner: 2 / 2"}; + RunNestedProgress(false, anExpected, 7); +} + +// fclasses/bug31092: an infinite nested scope reports its terminal value as finished. +TEST(TDocStd_Progress_Test, FClassesBug_31092_NestedInfiniteScopes) +{ + const char* const anExpected[] = {"Progress: 0%", + "Progress: 11% Outer: 1 / 3 Inner: 1", + "Progress: 17% Outer: 1 / 3 Inner: 2", + "Progress: 20% Outer: 1 / 3 Inner: 3", + "Progress: 22% Outer: 1 / 3 Inner: 4", + "Progress: 33% Outer: 1 / 3 Inner: finished", + "Progress: 44% Outer: 2 / 3 Inner: 1", + "Progress: 50% Outer: 2 / 3 Inner: 2", + "Progress: 53% Outer: 2 / 3 Inner: 3", + "Progress: 56% Outer: 2 / 3 Inner: 4", + "Progress: 67% Outer: 2 / 3 Inner: finished", + "Progress: 78% Outer: 3 / 3 Inner: 1", + "Progress: 83% Outer: 3 / 3 Inner: 2", + "Progress: 87% Outer: 3 / 3 Inner: 3", + "Progress: 89% Outer: 3 / 3 Inner: 4", + "Progress: 100% Outer: 3 / 3 Inner: finished"}; + RunNestedProgress(true, anExpected, 16); +} diff --git a/src/ApplicationFramework/TKXml/GTests/TDocStd_Storage_Test.cxx b/src/ApplicationFramework/TKXml/GTests/TDocStd_Storage_Test.cxx new file mode 100644 index 0000000000..b422725aaf --- /dev/null +++ b/src/ApplicationFramework/TKXml/GTests/TDocStd_Storage_Test.cxx @@ -0,0 +1,3846 @@ +// Copyright (c) 2026 OPEN CASCADE SAS +// +// This file is part of Open CASCADE Technology software library. +// +// This library is free software; you can redistribute it and/or modify it under +// the terms of the GNU Lesser General Public License version 2.1 as published +// by the Free Software Foundation, with special exception defined in the file +// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT +// distribution for complete text of the license and disclaimer of any warranty. +// +// Alternatively, this file may be used under the terms of Open CASCADE +// commercial license or contractual agreement. + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#include + +namespace +{ +static occ::handle NewApplication() +{ + occ::handle anApplication = new TDocStd_Application(); + XmlDrivers::DefineFormat(anApplication); + BinDrivers::DefineFormat(anApplication); + BinLDrivers::DefineFormat(anApplication); + return anApplication; +} + +static occ::handle NewDocument( + const occ::handle& theApplication, + const char* theFormat) +{ + occ::handle aDocument; + theApplication->NewDocument(theFormat, aDocument); + EXPECT_FALSE(aDocument.IsNull()); + if (!aDocument.IsNull()) + { + aDocument->SetUndoLimit(100); + } + return aDocument; +} + +static occ::handle SaveAndOpenStream( + const occ::handle& theApplication, + const occ::handle& theDocument); + +static occ::handle SaveAndOpen( + const occ::handle& theApplication, + const occ::handle& theDocument, + const char* theFormat, + const char* theTestName, + const bool theUseStream = false) +{ + if (theUseStream) + { + return SaveAndOpenStream(theApplication, theDocument); + } + + OSD_Directory aDirectory = OSD_Directory::BuildTemporary(); + OSD_Path aPath; + aDirectory.Path(aPath); + aPath.SetName(theTestName); + aPath.SetExtension(strcmp(theFormat, "BinOcaf") == 0 ? ".cbf" : ".xml"); + + TCollection_AsciiString aSystemName; + aPath.SystemName(aSystemName); + const TCollection_ExtendedString aFileName(aSystemName, true); + + theDocument->NewCommand(); + EXPECT_EQ(theApplication->SaveAs(theDocument, aFileName), PCDM_SS_OK); + OSD_File aFile(aPath); + EXPECT_TRUE(aFile.Exists()); + + theApplication->Close(theDocument); + occ::handle aRestored; + EXPECT_EQ(theApplication->Open(aFileName, aRestored), PCDM_RS_OK); + EXPECT_FALSE(aRestored.IsNull()); + + if (aFile.Exists()) + { + aFile.Remove(); + } + return aRestored; +} + +static occ::handle SaveAndOpenStream( + const occ::handle& theApplication, + const occ::handle& theDocument) +{ + std::stringstream aStream; + theDocument->NewCommand(); + EXPECT_EQ(theApplication->SaveAs(theDocument, aStream), PCDM_SS_OK); + EXPECT_FALSE(aStream.str().empty()); + + theApplication->Close(theDocument); + aStream.seekg(0); + occ::handle aRestored; + EXPECT_EQ(theApplication->Open(aStream, aRestored), PCDM_RS_OK); + EXPECT_FALSE(aRestored.IsNull()); + return aRestored; +} + +static void SaveDocumentStream(const occ::handle& theApplication, + const occ::handle& theDocument, + std::stringstream& theStream) +{ + EXPECT_EQ(theApplication->SaveAs(theDocument, theStream), PCDM_SS_OK); + EXPECT_FALSE(theStream.str().empty()); +} + +static occ::handle OpenDocumentStream( + const occ::handle& theApplication, + std::stringstream& theStream) +{ + theStream.clear(); + theStream.seekg(0); + occ::handle aRestored; + EXPECT_EQ(theApplication->Open(theStream, aRestored), PCDM_RS_OK); + EXPECT_FALSE(aRestored.IsNull()); + return aRestored; +} + +static PCDM_ReaderStatus OpenDocumentStream(const occ::handle& theApplication, + std::stringstream& theStream, + occ::handle& theDocument, + const occ::handle& theFilter) +{ + theStream.clear(); + theStream.seekg(0); + return theApplication->Open(theStream, theDocument, theFilter); +} + +static void RunBinaryEmptyLists() +{ + occ::handle anApplication = NewApplication(); + occ::handle aDocument = NewDocument(anApplication, "BinOcaf"); + ASSERT_FALSE(aDocument.IsNull()); + + const TDF_Label aRoot = aDocument->GetData()->Root(); + ASSERT_FALSE(TDataStd_BooleanList::Set(aRoot.FindChild(1, true).FindChild(1, true)).IsNull()); + ASSERT_FALSE(TDataStd_IntegerList::Set(aRoot.FindChild(1, true).FindChild(2, true)).IsNull()); + ASSERT_FALSE(TDataStd_RealList::Set(aRoot.FindChild(1, true).FindChild(3, true)).IsNull()); + ASSERT_FALSE(TDataStd_ExtStringList::Set(aRoot.FindChild(1, true).FindChild(4, true)).IsNull()); + ASSERT_FALSE(TDataStd_ReferenceList::Set(aRoot.FindChild(1, true).FindChild(5, true)).IsNull()); + + occ::handle aRestored = SaveAndOpenStream(anApplication, aDocument); + ASSERT_FALSE(aRestored.IsNull()); + const TDF_Label aRestoredRoot = aRestored->GetData()->Root().FindChild(1, false); + ASSERT_FALSE(aRestoredRoot.IsNull()); + + occ::handle aBooleanList; + ASSERT_TRUE( + aRestoredRoot.FindChild(1, false).FindAttribute(TDataStd_BooleanList::GetID(), aBooleanList)); + EXPECT_TRUE(aBooleanList->IsEmpty()); + EXPECT_EQ(aBooleanList->Extent(), 0); + + occ::handle anIntegerList; + ASSERT_TRUE( + aRestoredRoot.FindChild(2, false).FindAttribute(TDataStd_IntegerList::GetID(), anIntegerList)); + EXPECT_TRUE(anIntegerList->IsEmpty()); + EXPECT_EQ(anIntegerList->Extent(), 0); + + occ::handle aRealList; + ASSERT_TRUE( + aRestoredRoot.FindChild(3, false).FindAttribute(TDataStd_RealList::GetID(), aRealList)); + EXPECT_TRUE(aRealList->IsEmpty()); + EXPECT_EQ(aRealList->Extent(), 0); + + occ::handle anExtStringList; + ASSERT_TRUE(aRestoredRoot.FindChild(4, false).FindAttribute(TDataStd_ExtStringList::GetID(), + anExtStringList)); + EXPECT_TRUE(anExtStringList->IsEmpty()); + EXPECT_EQ(anExtStringList->Extent(), 0); + + occ::handle aReferenceList; + ASSERT_TRUE(aRestoredRoot.FindChild(5, false).FindAttribute(TDataStd_ReferenceList::GetID(), + aReferenceList)); + EXPECT_TRUE(aReferenceList->IsEmpty()); + EXPECT_EQ(aReferenceList->Extent(), 0); +} + +// bugs/caf/bug25394_1: empty standard lists survive binary OCAF streams. +TEST(TDocStd_Storage_Test, Cbf_CafBug_25394_1_EmptyLists) +{ + RunBinaryEmptyLists(); +} + +// bugs/caf/bug25394_2: empty standard lists survive binary OCAF streams. +TEST(TDocStd_Storage_Test, Cbf_CafBug_25394_2_EmptyLists) +{ + RunBinaryEmptyLists(); +} + +class XbfStreamLoader : public OSD_Thread +{ +public: + XbfStreamLoader(const occ::handle& theApplication, + const std::string& theData) + : OSD_Thread(PerformThread), + myApplication(theApplication), + myData(theData), + myStatus(PCDM_RS_DriverFailure) + { + } + + PCDM_ReaderStatus Status() const { return myStatus; } + + const occ::handle& Document() const { return myDocument; } + +private: + void Perform() + { + std::istringstream aStream(myData); + myStatus = myApplication->Open(aStream, myDocument); + } + + static void* PerformThread(void* theData) + { + XbfStreamLoader* aLoader = static_cast(theData); + OSD::SetThreadLocalSignal(OSD_SignalMode_Set, false); + try + { + aLoader->Perform(); + } + catch (const Standard_Failure&) + { + // Keep the failure status and report it from the joining test thread. + } + return nullptr; + } + +private: + occ::handle myApplication; + std::string myData; + occ::handle myDocument; + PCDM_ReaderStatus myStatus; +}; + +// bugs/caf/bug31785: an XBF document can be opened from a background thread. +TEST(TDocStd_Storage_Test, CafBug_31785_BackgroundXbfStreamOpen) +{ + occ::handle anApplication = new TDocStd_Application(); + BinXCAFDrivers::DefineFormat(anApplication); + occ::handle aDocument = NewDocument(anApplication, "BinXCAF"); + ASSERT_FALSE(aDocument.IsNull()); + + std::stringstream aStream; + const PCDM_StoreStatus aStoreStatus = anApplication->SaveAs(aDocument, aStream); + ASSERT_TRUE(aStoreStatus == PCDM_SS_OK || aStoreStatus == PCDM_SS_No_Obj); + const std::string aData = aStream.str(); + ASSERT_FALSE(aData.empty()); + anApplication->Close(aDocument); + + XbfStreamLoader aLoader(anApplication, aData); + ASSERT_TRUE(aLoader.Run(&aLoader)); + ASSERT_TRUE(aLoader.Wait()); + // The original DRAW case saves an empty document and ignores the resulting read status. + // The stream is consequently rejected as incomplete, but opening it in the worker must not + // crash the application. + EXPECT_EQ(aLoader.Status(), PCDM_RS_UnrecognizedFileFormat); + EXPECT_FALSE(aLoader.Document().IsNull()); +} + +// bugs/caf/bug26229_1: binary OCAF SaveAs/Open stream APIs preserve attributes. +TEST(TDocStd_Storage_Test, Cbf_CafBug_26229_1_StreamInteger) +{ + occ::handle anApplication = NewApplication(); + occ::handle aDocument = NewDocument(anApplication, "BinOcaf"); + ASSERT_FALSE(aDocument.IsNull()); + + const TDF_Label aLabel = aDocument->GetData()->Root().FindChild(2, true); + ASSERT_FALSE(TDataStd_Integer::Set(aLabel, 100).IsNull()); + + occ::handle aRestored = SaveAndOpenStream(anApplication, aDocument); + ASSERT_FALSE(aRestored.IsNull()); + const TDF_Label aRestoredLabel = aRestored->GetData()->Root().FindChild(2, false); + occ::handle anInteger; + ASSERT_TRUE(aRestoredLabel.FindAttribute(TDataStd_Integer::GetID(), anInteger)); + EXPECT_EQ(anInteger->Get(), 100); +} + +// bugs/caf/bug23306: an extended-string array is read from binary OCAF without warnings. +TEST(TDocStd_Storage_Test, Cbf_CafBug_23306_ExtStringArray) +{ + occ::handle anApplication = NewApplication(); + occ::handle aDocument = NewDocument(anApplication, "BinOcaf"); + ASSERT_FALSE(aDocument.IsNull()); + + const TDF_Label aLabel = aDocument->GetData()->Root().FindChild(1, true).FindChild(1, true); + occ::handle anArray = TDataStd_ExtStringArray::Set(aLabel, 1, 3); + ASSERT_FALSE(anArray.IsNull()); + anArray->SetValue(1, TCollection_ExtendedString("String1")); + anArray->SetValue(2, TCollection_ExtendedString("String2")); + anArray->SetValue(3, TCollection_ExtendedString("String3")); + + occ::handle aRestored = SaveAndOpenStream(anApplication, aDocument); + ASSERT_FALSE(aRestored.IsNull()); + occ::handle aRestoredArray; + ASSERT_TRUE(aRestored->GetData()->Root().FindChild(1, false).FindChild(1, false).FindAttribute( + TDataStd_ExtStringArray::GetID(), + aRestoredArray)); + ASSERT_FALSE(aRestoredArray.IsNull()); + ASSERT_EQ(aRestoredArray->Lower(), 1); + ASSERT_EQ(aRestoredArray->Upper(), 3); + EXPECT_TRUE(aRestoredArray->Value(1).IsEqual(TCollection_ExtendedString("String1"))); + EXPECT_TRUE(aRestoredArray->Value(2).IsEqual(TCollection_ExtendedString("String2"))); + EXPECT_TRUE(aRestoredArray->Value(3).IsEqual(TCollection_ExtendedString("String3"))); +} + +// bugs/caf/bug425: an empty TDataStd_Name survives binary OCAF streams. +TEST(TDocStd_Storage_Test, Cbf_CafBug_425_EmptyName) +{ + occ::handle anApplication = NewApplication(); + occ::handle aDocument = NewDocument(anApplication, "BinOcaf"); + ASSERT_FALSE(aDocument.IsNull()); + + const TDF_Label aLabel = aDocument->GetData()->Root().FindChild(2, true); + ASSERT_FALSE(TDataStd_Name::Set(aLabel, TCollection_ExtendedString()).IsNull()); + + occ::handle aRestored = SaveAndOpenStream(anApplication, aDocument); + ASSERT_FALSE(aRestored.IsNull()); + occ::handle aRestoredName; + ASSERT_TRUE(aRestored->GetData()->Root().FindChild(2, false).FindAttribute(TDataStd_Name::GetID(), + aRestoredName)); + ASSERT_FALSE(aRestoredName.IsNull()); + EXPECT_TRUE(aRestoredName->Get().IsEmpty()); +} + +// bugs/caf/bug28428: a NamedShape with no stored nodes survives binary OCAF streams. +TEST(TDocStd_Storage_Test, Cbf_CafBug_28428_EmptyNamedShape) +{ + occ::handle anApplication = NewApplication(); + occ::handle aDocument = NewDocument(anApplication, "BinOcaf"); + ASSERT_FALSE(aDocument.IsNull()); + + const TDF_Label aLabel = aDocument->GetData()->Root().FindChild(1, true); + TNaming_Builder aBuilder(aLabel); + occ::handle aNamedShape; + ASSERT_TRUE(aLabel.FindAttribute(TNaming_NamedShape::GetID(), aNamedShape)); + + occ::handle aRestored = SaveAndOpenStream(anApplication, aDocument); + ASSERT_FALSE(aRestored.IsNull()); + occ::handle aRestoredNamedShape; + const TDF_Label aRestoredLabel = aRestored->GetData()->Root().FindChild(1, false); + ASSERT_TRUE(aRestoredLabel.FindAttribute(TNaming_NamedShape::GetID(), aRestoredNamedShape)); + TNaming_Iterator anIterator(aRestoredNamedShape); + EXPECT_FALSE(anIterator.More()); +} + +static void SetShape(const TDF_Label& theLabel, const TopoDS_Shape& theShape) +{ + TNaming_Builder aBuilder(theLabel); + aBuilder.Generated(theShape); +} + +static occ::handle AddNamingObject( + const occ::handle& theDocument) +{ + occ::handle aRootNode = TDataStd_TreeNode::Set(theDocument->Main()); + const TDF_Label anObjectLabel = TDF_TagSource::NewChild(theDocument->Main()); + occ::handle anObject = + TDataStd_UAttribute::Set(anObjectLabel, GEOMOBJECT_GUID); + occ::handle anObjectNode = TDataStd_TreeNode::Set(anObjectLabel); + if (aRootNode.IsNull() || anObject.IsNull() || anObjectNode.IsNull() + || !aRootNode->Append(anObjectNode)) + { + ADD_FAILURE() << "Failed to create the naming object"; + return occ::handle(); + } + return anObject; +} + +static occ::handle AddNamingFunction( + const occ::handle& theObject, + const Standard_GUID& theDriverGuid) +{ + const TDF_Label aFunctionLabel = TDF_TagSource::NewChild(theObject->Label()); + occ::handle aFunction = + TFunction_Function::Set(aFunctionLabel, theDriverGuid); + occ::handle aFunctionNode = TDataStd_TreeNode::Set(aFunctionLabel); + occ::handle anObjectNode; + if (aFunction.IsNull() || aFunctionNode.IsNull() + || !theObject->Label().FindAttribute(TDataStd_TreeNode::GetDefaultTreeID(), anObjectNode) + || anObjectNode.IsNull() || !anObjectNode->Append(aFunctionNode)) + { + ADD_FAILURE() << "Failed to create the naming function"; + return occ::handle(); + } + + const TDF_Label anArgumentsLabel = TDF_TagSource::NewChild(aFunctionLabel); + const TDF_Label aResultLabel = TDF_TagSource::NewChild(aFunctionLabel); + occ::handle anArgumentsNode = TDataStd_TreeNode::Set(anArgumentsLabel); + occ::handle aResultNode = TDataStd_TreeNode::Set(aResultLabel); + if (anArgumentsNode.IsNull() || aResultNode.IsNull() || !aFunctionNode->Append(anArgumentsNode) + || !aFunctionNode->Append(aResultNode) + || TDF_Reference::Set(theObject->Label(), aResultLabel).IsNull()) + { + ADD_FAILURE() << "Failed to initialize the naming function labels"; + return occ::handle(); + } + return aFunction; +} + +static int ExecuteNamingFunction(const occ::handle& theFunction, + const occ::handle& theDriver) +{ + occ::handle aLogbook = TFunction_Logbook::Set(theFunction->Label()); + aLogbook->Clear(); + theDriver->Init(theFunction->Label()); + return theDriver->Execute(aLogbook); +} + +static TopoDS_Shape NamingFunctionShape(const occ::handle& theFunction) +{ + const occ::handle aNamedShape = DNaming::GetFunctionResult(theFunction); + return aNamedShape.IsNull() ? TopoDS_Shape() : TNaming_Tool::GetShape(aNamedShape); +} + +static TopoDS_Shape ShapeOf(const TDF_Label& theLabel) +{ + occ::handle aNamedShape; + if (!theLabel.FindAttribute(TNaming_NamedShape::GetID(), aNamedShape)) + { + return TopoDS_Shape(); + } + return TNaming_Tool::GetShape(aNamedShape); +} + +static void ExpectBoxBounds(const TopoDS_Shape& theShape, + const double theXMin, + const double theYMin, + const double theZMin, + const double theXMax, + const double theYMax, + const double theZMax) +{ + ASSERT_FALSE(theShape.IsNull()); + Bnd_Box aBounds; + BRepBndLib::Add(theShape, aBounds); + double aXMin = 0.0; + double aYMin = 0.0; + double aZMin = 0.0; + double aXMax = 0.0; + double aYMax = 0.0; + double aZMax = 0.0; + aBounds.Get(aXMin, aYMin, aZMin, aXMax, aYMax, aZMax); + EXPECT_NEAR(aXMin, theXMin, 1.0e-6); + EXPECT_NEAR(aYMin, theYMin, 1.0e-6); + EXPECT_NEAR(aZMin, theZMin, 1.0e-6); + EXPECT_NEAR(aXMax, theXMax, 1.0e-6); + EXPECT_NEAR(aYMax, theYMax, 1.0e-6); + EXPECT_NEAR(aZMax, theZMax, 1.0e-6); +} + +static void ExpectLinked(const TDF_Label& theTarget, const TDF_Label& theSource) +{ + occ::handle aLink; + ASSERT_TRUE(theTarget.FindAttribute(TDocStd_XLink::GetID(), aLink)); + EXPECT_FALSE(aLink->LabelEntry().IsEmpty()); + + occ::handle aReference; + ASSERT_TRUE(theTarget.FindAttribute(TDF_Reference::GetID(), aReference)); + EXPECT_TRUE(aReference->Get() == theSource); +} + +static TDF_Label LabelByEntry(const occ::handle& theDocument, + const TCollection_AsciiString& theEntry) +{ + TDF_Label aLabel; + TDF_Tool::Label(theDocument->GetData(), theEntry, aLabel); + return aLabel; +} + +static int CollectUniqueSubShapes(const TopoDS_Shape& theShape, + const TopAbs_ShapeEnum theType, + TopoDS_Shape* theSubShapes, + const int theCapacity) +{ + NCollection_Map aShapeMap; + aShapeMap.Add(theShape); + int aCount = 0; + for (TopExp_Explorer anExplorer(theShape, theType); anExplorer.More(); anExplorer.Next()) + { + if (aShapeMap.Add(anExplorer.Current())) + { + if (aCount < theCapacity) + { + theSubShapes[aCount] = anExplorer.Current(); + } + ++aCount; + } + } + return aCount; +} + +static void SelectImportedShape(const TDF_Label& theSelectionLabel, + const TopoDS_Shape& theSelection, + const TopoDS_Shape& theContext) +{ + TNaming_Selector aSelector(theSelectionLabel); + ASSERT_TRUE(aSelector.Select(theSelection, theContext, false)); + EXPECT_TRUE(TNaming_Tool::GetShape(aSelector.NamedShape()).IsSame(theSelection)); +} + +static void ExpectNamingSelection(const TDF_Label& theSelectionLabel, + const TNaming_NameType theExpectedType, + const TopAbs_ShapeEnum theExpectedShapeType, + const TDF_Label* theExpectedArguments, + const int theExpectedArgumentCount) +{ + occ::handle aNaming; + ASSERT_TRUE(theSelectionLabel.FindAttribute(TNaming_Naming::GetID(), aNaming)); + const TNaming_Name& aName = aNaming->GetName(); + EXPECT_EQ(aName.Type(), theExpectedType); + EXPECT_EQ(aName.ShapeType(), theExpectedShapeType); + EXPECT_EQ(aName.Arguments().Extent(), theExpectedArgumentCount); + + // The DRAW DumpSelection output for this case is TODO and its textual + // argument order is not a stable naming invariant. Check the complete set + // of referenced labels instead. + for (int anExpectedIndex = 0; anExpectedIndex < theExpectedArgumentCount; ++anExpectedIndex) + { + bool hasArgument = false; + for (NCollection_List>::Iterator anIterator(aName.Arguments()); + anIterator.More(); + anIterator.Next()) + { + if (!anIterator.Value().IsNull() + && anIterator.Value()->Label().IsEqual(theExpectedArguments[anExpectedIndex])) + { + hasArgument = true; + break; + } + } + EXPECT_TRUE(hasArgument); + } +} + +static void RunB7(const char* theFormat, const bool theUseStream = false) +{ + occ::handle anApplication = NewApplication(); + occ::handle aDocument = NewDocument(anApplication, theFormat); + ASSERT_FALSE(aDocument.IsNull()); + + const TDF_Label aSource = aDocument->Main().FindChild(2, true); + const TDF_Label aTarget = aDocument->Main().FindChild(3, true); + ASSERT_FALSE(TDataStd_Name::Set(aSource, "SLabel").IsNull()); + ASSERT_FALSE(TDataStd_Name::Set(aTarget, "TLabel1").IsNull()); + const TopoDS_Shape aBox = + BRepPrimAPI_MakeBox(gp_Pnt(10.0, 20.0, 30.0), gp_Pnt(110.0, 220.0, 330.0)).Shape(); + SetShape(aSource, aBox); + + aDocument->NewCommand(); + TDocStd_XLinkTool aTool; + aTool.CopyWithLink(aTarget, aSource); + ASSERT_TRUE(aTool.IsDone()); + + occ::handle aRestored = + SaveAndOpen(anApplication, aDocument, theFormat, "draw_ocaf_copy_with_link", theUseStream); + ASSERT_FALSE(aRestored.IsNull()); + const TDF_Label aRestoredSource = aRestored->Main().FindChild(2, false); + const TDF_Label aRestoredTarget = aRestored->Main().FindChild(3, false); + ASSERT_FALSE(aRestoredSource.IsNull()); + ASSERT_FALSE(aRestoredTarget.IsNull()); + ExpectLinked(aRestoredTarget, aRestoredSource); + ExpectBoxBounds(ShapeOf(aRestoredTarget), 10.0, 20.0, 30.0, 110.0, 220.0, 330.0); +} + +static void RunC2(const char* theFormat) +{ + occ::handle anApplication = NewApplication(); + occ::handle aDocument = NewDocument(anApplication, theFormat); + ASSERT_FALSE(aDocument.IsNull()); + const TDF_Label aShapeLabel = aDocument->Main().FindChild(2, true); + const TopoDS_Shape aBox = + BRepPrimAPI_MakeBox(gp_Pnt(10.0, 20.0, 30.0), gp_Pnt(110.0, 220.0, 330.0)).Shape(); + SetShape(aShapeLabel, aBox); + occ::handle aNamedShape; + ASSERT_TRUE(aShapeLabel.FindAttribute(TNaming_NamedShape::GetID(), aNamedShape)); + + const TDF_Label aRealLabel = aDocument->Main().FindChild(1, true).FindChild(1, true); + const TDF_Label aConstraintLabel = aDocument->Main().FindChild(3, true); + occ::handle aReal = TDataStd_Real::Set(aRealLabel, 123.456789); + ASSERT_FALSE(aReal.IsNull()); + occ::handle aConstraint = TDataXtd_Constraint::Set(aConstraintLabel); + aConstraint->SetType(TDataXtd_TANGENT); + aConstraint->SetGeometry(1, aNamedShape); + aConstraint->SetPlane(aNamedShape); + aConstraint->SetValue(aReal); + + occ::handle aRestored = + SaveAndOpen(anApplication, aDocument, theFormat, "draw_ocaf_constraint"); + ASSERT_FALSE(aRestored.IsNull()); + const TDF_Label aRestoredConstraintLabel = aRestored->Main().FindChild(3, false); + ASSERT_FALSE(aRestoredConstraintLabel.IsNull()); + occ::handle aRestoredConstraint; + ASSERT_TRUE( + aRestoredConstraintLabel.FindAttribute(TDataXtd_Constraint::GetID(), aRestoredConstraint)); + EXPECT_EQ(aRestoredConstraint->GetType(), TDataXtd_TANGENT); + ASSERT_EQ(aRestoredConstraint->NbGeometries(), 1); + ASSERT_FALSE(aRestoredConstraint->GetGeometry(1).IsNull()); + ASSERT_FALSE(aRestoredConstraint->GetPlane().IsNull()); + ExpectBoxBounds(TNaming_Tool::GetShape(aRestoredConstraint->GetGeometry(1)), + 10.0, + 20.0, + 30.0, + 110.0, + 220.0, + 330.0); + ASSERT_FALSE(aRestoredConstraint->GetValue().IsNull()); + EXPECT_DOUBLE_EQ(aRestoredConstraint->GetValue()->Get(), 123.456789); +} + +static void RunC3(const char* theFormat) +{ + occ::handle anApplication = NewApplication(); + occ::handle aDocument = NewDocument(anApplication, theFormat); + ASSERT_FALSE(aDocument.IsNull()); + const TDF_Label aLabel = aDocument->Main().FindChild(2, true); + const TopoDS_Shape aBox = BRepPrimAPI_MakeBox(10.0, 20.0, 30.0).Shape(); + SetShape(aLabel, aBox); + occ::handle aGeometry = TDataXtd_Geometry::Set(aLabel); + ASSERT_FALSE(aGeometry.IsNull()); + aGeometry->SetType(TDataXtd_POINT); + + occ::handle aRestored = + SaveAndOpen(anApplication, aDocument, theFormat, "draw_ocaf_geometry_type"); + ASSERT_FALSE(aRestored.IsNull()); + const TDF_Label aRestoredLabel = aRestored->Main().FindChild(2, false); + ASSERT_FALSE(aRestoredLabel.IsNull()); + occ::handle aRestoredGeometry; + ASSERT_TRUE(aRestoredLabel.FindAttribute(TDataXtd_Geometry::GetID(), aRestoredGeometry)); + EXPECT_EQ(aRestoredGeometry->GetType(), TDataXtd_POINT); +} + +static void RunC4(const char* theFormat) +{ + occ::handle anApplication = NewApplication(); + occ::handle aDocument = NewDocument(anApplication, theFormat); + ASSERT_FALSE(aDocument.IsNull()); + const TopoDS_Shape aBox = BRepPrimAPI_MakeBox(10.0, 20.0, 777.0).Shape(); + const TDF_Label aShapeLabel = aDocument->Main().FindChild(1, true); + SetShape(aShapeLabel, aBox); + const TDF_Label aSelectionLabel = aShapeLabel.FindChild(1, true); + TNaming_Selector aSelector(aSelectionLabel); + ASSERT_TRUE(aSelector.Select(aBox)); + + occ::handle aRestored = + SaveAndOpen(anApplication, aDocument, theFormat, "draw_ocaf_selection"); + ASSERT_FALSE(aRestored.IsNull()); + const TDF_Label aRestoredSelection = aRestored->Main().FindChild(1, false).FindChild(1, false); + ASSERT_FALSE(aRestoredSelection.IsNull()); + occ::handle aNaming; + ASSERT_TRUE(aRestoredSelection.FindAttribute(TNaming_Naming::GetID(), aNaming)); + ExpectBoxBounds(ShapeOf(aRestoredSelection), 0.0, 0.0, 0.0, 10.0, 20.0, 777.0); +} + +static void RunC5(const char* theFormat) +{ + occ::handle anApplication = NewApplication(); + occ::handle aDocument = NewDocument(anApplication, theFormat); + ASSERT_FALSE(aDocument.IsNull()); + const TDF_Label aShapeLabel = aDocument->Main().FindChild(2, true); + const TDF_Label aRealLabel = aDocument->Main().FindChild(3, true); + const TDF_Label anIntegerLabel = aDocument->Main().FindChild(4, true); + const TDF_Label aPatternLabel = aDocument->Main().FindChild(1, true).FindChild(1, true); + SetShape(aShapeLabel, BRepPrimAPI_MakeBox(10.0, 20.0, 30.0).Shape()); + occ::handle aNamedShape; + ASSERT_TRUE(aShapeLabel.FindAttribute(TNaming_NamedShape::GetID(), aNamedShape)); + occ::handle aReal = TDataStd_Real::Set(aRealLabel, 45.0); + occ::handle anInteger = TDataStd_Integer::Set(anIntegerLabel, 7); + ASSERT_FALSE(aReal.IsNull()); + ASSERT_FALSE(anInteger.IsNull()); + occ::handle aPattern = TDataXtd_PatternStd::Set(aPatternLabel); + aPattern->Signature(1); + aPattern->Axis1(aNamedShape); + aPattern->Value1(aReal); + aPattern->NbInstances1(anInteger); + + occ::handle aRestored = + SaveAndOpen(anApplication, aDocument, theFormat, "draw_ocaf_pattern"); + ASSERT_FALSE(aRestored.IsNull()); + const TDF_Label aRestoredPatternLabel = aRestored->Main().FindChild(1, false).FindChild(1, false); + ASSERT_FALSE(aRestoredPatternLabel.IsNull()); + occ::handle aRestoredPattern; + ASSERT_TRUE(aRestoredPatternLabel.FindAttribute(TDataXtd_Pattern::GetID(), aRestoredPattern)); + EXPECT_EQ(aRestoredPattern->Signature(), 1); + ASSERT_FALSE(aRestoredPattern->Axis1().IsNull()); + ExpectBoxBounds(TNaming_Tool::GetShape(aRestoredPattern->Axis1()), + 0.0, + 0.0, + 0.0, + 10.0, + 20.0, + 30.0); + ASSERT_FALSE(aRestoredPattern->Value1().IsNull()); + ASSERT_FALSE(aRestoredPattern->NbInstances1().IsNull()); + EXPECT_DOUBLE_EQ(aRestoredPattern->Value1()->Get(), 45.0); + EXPECT_EQ(aRestoredPattern->NbInstances1()->Get(), 7); +} + +static void RunC7(const char* theFormat) +{ + occ::handle anApplication = NewApplication(); + occ::handle aDocument = NewDocument(anApplication, theFormat); + ASSERT_FALSE(aDocument.IsNull()); + const TDF_Label aLabel = aDocument->Main().FindChild(1, true).FindChild(1, true); + const gp_Pnt anExpected(123.456, 789.012, 345.678); + TDataXtd_Position::Set(aLabel, anExpected); + + occ::handle aRestored = + SaveAndOpen(anApplication, aDocument, theFormat, "draw_ocaf_position"); + ASSERT_FALSE(aRestored.IsNull()); + const TDF_Label aRestoredLabel = aRestored->Main().FindChild(1, false).FindChild(1, false); + ASSERT_FALSE(aRestoredLabel.IsNull()); + gp_Pnt anActual; + ASSERT_TRUE(TDataXtd_Position::Get(aRestoredLabel, anActual)); + EXPECT_TRUE(anActual.IsEqual(anExpected, 1.0e-12)); +} + +static void RunD2(const char* theFormat) +{ + occ::handle anApplication = NewApplication(); + occ::handle aDocument = NewDocument(anApplication, theFormat); + ASSERT_FALSE(aDocument.IsNull()); + const int aTags[][6] = {{3}, + {2076534922, 524398634, 912349856}, + {3, 9283, 12, 1, 9843, 46793}, + {4, 81245034, 321, 1, 1, 1}, + {5, 8, 4, 2, 213, 3242}, + {2, 15, 123, 31214, 452398, 421}, + {2, 2, 1, 1, 1, 3}, + {2, 9}}; + const int aTagLengths[] = {1, 3, 6, 6, 6, 6, 6, 2}; + NCollection_Array1 aLabels(1, 8); + NCollection_Array1 anEntries(1, 8); + for (int anIndex = 1; anIndex <= 8; ++anIndex) + { + TDF_Label aLabel = aDocument->Main(); + for (int aTagIndex = 0; aTagIndex < aTagLengths[anIndex - 1]; ++aTagIndex) + { + aLabel = aLabel.FindChild(aTags[anIndex - 1][aTagIndex], true); + } + aLabels.SetValue(anIndex, aLabel); + TDF_Tool::Entry(aLabel, anEntries.ChangeValue(anIndex)); + } + + for (int anIndex = 1; anIndex <= 8; ++anIndex) + { + TDataStd_Integer::Set(aLabels.Value(anIndex), anIndex); + TDF_Reference::Set(aLabels.Value(anIndex), aLabels.Value(anIndex == 1 ? 8 : anIndex - 1)); + } + + occ::handle aRestored = + SaveAndOpen(anApplication, aDocument, theFormat, "draw_ocaf_reference_chain_alias"); + ASSERT_FALSE(aRestored.IsNull()); + for (int anIndex = 1; anIndex <= 8; ++anIndex) + { + const TDF_Label aRestoredLabel = LabelByEntry(aRestored, anEntries.Value(anIndex)); + ASSERT_FALSE(aRestoredLabel.IsNull()); + occ::handle aReference; + ASSERT_TRUE(aRestoredLabel.FindAttribute(TDF_Reference::GetID(), aReference)); + const int anExpectedIndex = anIndex == 1 ? 8 : anIndex - 1; + EXPECT_TRUE(aReference->Get() == LabelByEntry(aRestored, anEntries.Value(anExpectedIndex))); + occ::handle anInteger; + ASSERT_TRUE(aReference->Get().FindAttribute(TDataStd_Integer::GetID(), anInteger)); + EXPECT_EQ(anInteger->Get(), anExpectedIndex); + } +} + +static void RunD3(const char* theFormat) +{ + occ::handle anApplication = NewApplication(); + occ::handle aDocument = NewDocument(anApplication, theFormat); + ASSERT_FALSE(aDocument.IsNull()); + const TDF_Label aVariableLabel1 = + aDocument->GetData()->Root().FindChild(1, true).FindChild(1, true); + const TDF_Label aVariableLabel2 = + aDocument->GetData()->Root().FindChild(1, true).FindChild(2, true); + const TDF_Label aVariableLabel3 = + aDocument->GetData()->Root().FindChild(1, true).FindChild(3, true); + const TDF_Label aRelationLabel = + aDocument->GetData()->Root().FindChild(1, true).FindChild(13, true); + occ::handle aVariable1 = TDataStd_Variable::Set(aVariableLabel1); + occ::handle aVariable2 = TDataStd_Variable::Set(aVariableLabel2); + occ::handle aVariable3 = TDataStd_Variable::Set(aVariableLabel3); + aVariable1->Unit("N"); + aVariable2->Unit("kg"); + aVariable3->Unit("m/s2"); + aVariable1->Constant(true); + aVariable2->Constant(false); + aVariable3->Constant(false); + occ::handle aRelation = TDataStd_Relation::Set(aRelationLabel); + aRelation->SetRelation(TCollection_ExtendedString("f = m*a")); + aRelation->GetVariables().Append(aVariable1); + aRelation->GetVariables().Append(aVariable2); + aRelation->GetVariables().Append(aVariable3); + + TCollection_AsciiString aRelationEntry; + TDF_Tool::Entry(aRelationLabel, aRelationEntry); + TCollection_AsciiString aVariableEntry1; + TCollection_AsciiString aVariableEntry2; + TCollection_AsciiString aVariableEntry3; + TDF_Tool::Entry(aVariableLabel1, aVariableEntry1); + TDF_Tool::Entry(aVariableLabel2, aVariableEntry2); + TDF_Tool::Entry(aVariableLabel3, aVariableEntry3); + + occ::handle aRestored = + SaveAndOpen(anApplication, aDocument, theFormat, "draw_ocaf_relation_alias"); + ASSERT_FALSE(aRestored.IsNull()); + const TDF_Label aRestoredRelationLabel = LabelByEntry(aRestored, aRelationEntry); + occ::handle aRestoredRelation; + ASSERT_TRUE(aRestoredRelationLabel.FindAttribute(TDataStd_Relation::GetID(), aRestoredRelation)); + EXPECT_EQ(aRestoredRelation->GetRelation(), TCollection_ExtendedString("f = m*a")); + const TCollection_AsciiString anExpectedEntries[] = {aVariableEntry1, + aVariableEntry2, + aVariableEntry3}; + int anIndex = 0; + for (NCollection_List>::Iterator anIterator( + aRestoredRelation->GetVariables()); + anIterator.More(); + anIterator.Next(), ++anIndex) + { + ASSERT_LT(anIndex, 3); + TCollection_AsciiString anActualEntry; + TDF_Tool::Entry(anIterator.Value()->Label(), anActualEntry); + EXPECT_STREQ(anActualEntry.ToCString(), anExpectedEntries[anIndex].ToCString()); + } + EXPECT_EQ(anIndex, 3); + + const TDF_Label aRestoredVariable1 = LabelByEntry(aRestored, aVariableEntry1); + const TDF_Label aRestoredVariable2 = LabelByEntry(aRestored, aVariableEntry2); + const TDF_Label aRestoredVariable3 = LabelByEntry(aRestored, aVariableEntry3); + occ::handle aRestoredVariable; + ASSERT_TRUE(aRestoredVariable1.FindAttribute(TDataStd_Variable::GetID(), aRestoredVariable)); + EXPECT_TRUE(aRestoredVariable->IsConstant()); + EXPECT_EQ(aRestoredVariable->Unit(), TCollection_AsciiString("N")); + ASSERT_TRUE(aRestoredVariable2.FindAttribute(TDataStd_Variable::GetID(), aRestoredVariable)); + EXPECT_FALSE(aRestoredVariable->IsConstant()); + EXPECT_EQ(aRestoredVariable->Unit(), TCollection_AsciiString("kg")); + ASSERT_TRUE(aRestoredVariable3.FindAttribute(TDataStd_Variable::GetID(), aRestoredVariable)); + EXPECT_FALSE(aRestoredVariable->IsConstant()); + EXPECT_EQ(aRestoredVariable->Unit(), TCollection_AsciiString("m/s2")); +} + +static TDF_Label AttributeLabel(const occ::handle& theDocument) +{ + return theDocument->Main().FindChild(2, true); +} + +static void RunA1(const char* theFormat, const bool theUseStream = false) +{ + occ::handle anApplication = NewApplication(); + occ::handle aDocument = NewDocument(anApplication, theFormat); + ASSERT_FALSE(aDocument.IsNull()); + ASSERT_FALSE(TDataStd_Integer::Set(AttributeLabel(aDocument), 100).IsNull()); + + occ::handle aRestored = + SaveAndOpen(anApplication, aDocument, theFormat, "draw_ocaf_integer_bin", theUseStream); + ASSERT_FALSE(aRestored.IsNull()); + occ::handle anInteger; + ASSERT_TRUE(AttributeLabel(aRestored).FindAttribute(TDataStd_Integer::GetID(), anInteger)); + EXPECT_EQ(anInteger->Get(), 100); +} + +static void RunA2(const char* theFormat, const bool theUseStream = false) +{ + occ::handle anApplication = NewApplication(); + occ::handle aDocument = NewDocument(anApplication, theFormat); + ASSERT_FALSE(aDocument.IsNull()); + ASSERT_FALSE(TDataStd_Real::Set(AttributeLabel(aDocument), 100.0).IsNull()); + + occ::handle aRestored = + SaveAndOpen(anApplication, aDocument, theFormat, "draw_ocaf_real_bin", theUseStream); + ASSERT_FALSE(aRestored.IsNull()); + occ::handle aReal; + ASSERT_TRUE(AttributeLabel(aRestored).FindAttribute(TDataStd_Real::GetID(), aReal)); + EXPECT_DOUBLE_EQ(aReal->Get(), 100.0); +} + +static void RunA3(const char* theFormat, const bool theUseStream = false) +{ + occ::handle anApplication = NewApplication(); + occ::handle aDocument = NewDocument(anApplication, theFormat); + ASSERT_FALSE(aDocument.IsNull()); + occ::handle anArray = + TDataStd_RealArray::Set(AttributeLabel(aDocument), 1, 2); + ASSERT_FALSE(anArray.IsNull()); + anArray->SetValue(1, 3.0); + anArray->SetValue(2, 4.0); + + occ::handle aRestored = + SaveAndOpen(anApplication, aDocument, theFormat, "draw_ocaf_real_array_bin", theUseStream); + ASSERT_FALSE(aRestored.IsNull()); + occ::handle aRestoredArray; + ASSERT_TRUE(AttributeLabel(aRestored).FindAttribute(TDataStd_RealArray::GetID(), aRestoredArray)); + EXPECT_EQ(aRestoredArray->Lower(), 1); + EXPECT_EQ(aRestoredArray->Upper(), 2); + EXPECT_DOUBLE_EQ(aRestoredArray->Value(1), 3.0); + EXPECT_DOUBLE_EQ(aRestoredArray->Value(2), 4.0); +} + +static void RunA4(const char* theFormat, const bool theUseStream = false) +{ + occ::handle anApplication = NewApplication(); + occ::handle aDocument = NewDocument(anApplication, theFormat); + ASSERT_FALSE(aDocument.IsNull()); + occ::handle anArray = + TDataStd_IntegerArray::Set(AttributeLabel(aDocument), 1, 2); + ASSERT_FALSE(anArray.IsNull()); + anArray->SetValue(1, 3); + anArray->SetValue(2, 4); + + occ::handle aRestored = + SaveAndOpen(anApplication, aDocument, theFormat, "draw_ocaf_integer_array_bin", theUseStream); + ASSERT_FALSE(aRestored.IsNull()); + occ::handle aRestoredArray; + ASSERT_TRUE( + AttributeLabel(aRestored).FindAttribute(TDataStd_IntegerArray::GetID(), aRestoredArray)); + EXPECT_EQ(aRestoredArray->Lower(), 1); + EXPECT_EQ(aRestoredArray->Upper(), 2); + EXPECT_EQ(aRestoredArray->Value(1), 3); + EXPECT_EQ(aRestoredArray->Value(2), 4); +} + +static void RunA5(const char* theFormat, const bool theUseStream = false) +{ + occ::handle anApplication = NewApplication(); + occ::handle aDocument = NewDocument(anApplication, theFormat); + ASSERT_FALSE(aDocument.IsNull()); + const TCollection_ExtendedString anExpected("New Attribute"); + ASSERT_FALSE(TDataStd_Name::Set(AttributeLabel(aDocument), anExpected).IsNull()); + + occ::handle aRestored = + SaveAndOpen(anApplication, aDocument, theFormat, "draw_ocaf_name_bin", theUseStream); + ASSERT_FALSE(aRestored.IsNull()); + occ::handle aName; + ASSERT_TRUE(AttributeLabel(aRestored).FindAttribute(TDataStd_Name::GetID(), aName)); + EXPECT_EQ(aName->Get(), anExpected); +} + +static void RunA6(const char* theFormat, const bool theUseStream = false) +{ + occ::handle anApplication = NewApplication(); + occ::handle aDocument = NewDocument(anApplication, theFormat); + ASSERT_FALSE(aDocument.IsNull()); + const TCollection_ExtendedString anExpected("New Attribute"); + ASSERT_FALSE(TDataStd_Comment::Set(AttributeLabel(aDocument), anExpected).IsNull()); + + occ::handle aRestored = + SaveAndOpen(anApplication, aDocument, theFormat, "draw_ocaf_comment_bin", theUseStream); + ASSERT_FALSE(aRestored.IsNull()); + occ::handle aComment; + ASSERT_TRUE(AttributeLabel(aRestored).FindAttribute(TDataStd_Comment::GetID(), aComment)); + EXPECT_EQ(aComment->Get(), anExpected); +} + +static void RunA7(const char* theFormat, const bool theUseStream = false) +{ + occ::handle anApplication = NewApplication(); + occ::handle aDocument = NewDocument(anApplication, theFormat); + ASSERT_FALSE(aDocument.IsNull()); + const gp_Pnt anExpected(10.0, 20.0, 30.0); + ASSERT_FALSE(TDataXtd_Point::Set(AttributeLabel(aDocument), anExpected).IsNull()); + + occ::handle aRestored = + SaveAndOpen(anApplication, aDocument, theFormat, "draw_ocaf_point_bin", theUseStream); + ASSERT_FALSE(aRestored.IsNull()); + gp_Pnt aPoint; + ASSERT_TRUE(TDataXtd_Geometry::Point(AttributeLabel(aRestored), aPoint)); + EXPECT_TRUE(aPoint.IsEqual(anExpected, Precision::Confusion())); +} + +static void RunA8(const char* theFormat, const bool theUseStream = false) +{ + occ::handle anApplication = NewApplication(); + occ::handle aDocument = NewDocument(anApplication, theFormat); + ASSERT_FALSE(aDocument.IsNull()); + const gp_Lin anExpected(gp_Pnt(10.0, 20.0, 30.0), gp_Dir(100.0, 200.0, 300.0)); + ASSERT_FALSE(TDataXtd_Axis::Set(AttributeLabel(aDocument), anExpected).IsNull()); + + occ::handle aRestored = + SaveAndOpen(anApplication, aDocument, theFormat, "draw_ocaf_axis_bin", theUseStream); + ASSERT_FALSE(aRestored.IsNull()); + gp_Lin aLine; + ASSERT_TRUE(TDataXtd_Geometry::Line(AttributeLabel(aRestored), aLine)); + EXPECT_TRUE(aLine.Location().IsEqual(anExpected.Location(), Precision::Confusion())); + EXPECT_TRUE(aLine.Direction().IsEqual(anExpected.Direction(), Precision::Confusion())); +} + +static void RunA9(const char* theFormat, const bool theUseStream = false) +{ + occ::handle anApplication = NewApplication(); + occ::handle aDocument = NewDocument(anApplication, theFormat); + ASSERT_FALSE(aDocument.IsNull()); + const gp_Pln anExpected(gp_Pnt(10.0, 20.0, 30.0), gp_Dir(-1.0, 0.0, 0.0)); + ASSERT_FALSE(TDataXtd_Plane::Set(AttributeLabel(aDocument), anExpected).IsNull()); + + occ::handle aRestored = + SaveAndOpen(anApplication, aDocument, theFormat, "draw_ocaf_plane_bin", theUseStream); + ASSERT_FALSE(aRestored.IsNull()); + gp_Pln aPlane; + ASSERT_TRUE(TDataXtd_Geometry::Plane(AttributeLabel(aRestored), aPlane)); + EXPECT_TRUE(aPlane.Location().IsEqual(anExpected.Location(), Precision::Confusion())); + EXPECT_TRUE( + aPlane.Axis().Direction().IsEqual(anExpected.Axis().Direction(), Precision::Confusion())); +} + +static void RunB1(const char* theFormat, const bool theUseStream = false) +{ + occ::handle anApplication = NewApplication(); + occ::handle aDocument = NewDocument(anApplication, theFormat); + ASSERT_FALSE(aDocument.IsNull()); + const Standard_GUID aGuid("c73bd075-22ee-11d2-acde-080009dc4422"); + ASSERT_FALSE(TDataStd_UAttribute::Set(AttributeLabel(aDocument), aGuid).IsNull()); + + occ::handle aRestored = + SaveAndOpen(anApplication, aDocument, theFormat, "draw_ocaf_user_attribute_bin", theUseStream); + ASSERT_FALSE(aRestored.IsNull()); + occ::handle anAttribute; + ASSERT_TRUE(AttributeLabel(aRestored).FindAttribute(aGuid, anAttribute)); + EXPECT_EQ(anAttribute->ID(), aGuid); +} + +static void RunB2(const char* theFormat, const bool theUseStream = false) +{ + occ::handle anApplication = NewApplication(); + occ::handle aDocument = NewDocument(anApplication, theFormat); + ASSERT_FALSE(aDocument.IsNull()); + const Standard_GUID aGuid1("c73bd075-22ee-11d2-acde-080009dc4422"); + const Standard_GUID aGuid2("c73bd076-22ee-11d2-acde-080009dc4422"); + const TDF_Label aLabel = AttributeLabel(aDocument); + ASSERT_FALSE(TDataStd_UAttribute::Set(aLabel, aGuid1).IsNull()); + ASSERT_FALSE(TDataStd_UAttribute::Set(aLabel, aGuid2).IsNull()); + + occ::handle aRestored = SaveAndOpen(anApplication, + aDocument, + theFormat, + "draw_ocaf_two_user_attributes_bin", + theUseStream); + ASSERT_FALSE(aRestored.IsNull()); + occ::handle anAttribute1; + occ::handle anAttribute2; + ASSERT_TRUE(AttributeLabel(aRestored).FindAttribute(aGuid1, anAttribute1)); + ASSERT_TRUE(AttributeLabel(aRestored).FindAttribute(aGuid2, anAttribute2)); + EXPECT_NE(anAttribute1->ID(), anAttribute2->ID()); +} + +static void RunB3(const char* theFormat, const bool theUseStream = false) +{ + occ::handle anApplication = NewApplication(); + occ::handle aDocument = NewDocument(anApplication, theFormat); + ASSERT_FALSE(aDocument.IsNull()); + SetShape(AttributeLabel(aDocument), + BRepPrimAPI_MakeBox(gp_Pnt(10.0, 20.0, 30.0), gp_Pnt(110.0, 220.0, 330.0))); + + occ::handle aRestored = + SaveAndOpen(anApplication, aDocument, theFormat, "draw_ocaf_named_shape_bin", theUseStream); + ASSERT_FALSE(aRestored.IsNull()); + ExpectBoxBounds(ShapeOf(AttributeLabel(aRestored)), 10.0, 20.0, 30.0, 110.0, 220.0, 330.0); +} + +static void RunB5(const char* theFormat, const bool theUseStream = false) +{ + occ::handle anApplication = NewApplication(); + occ::handle aDocument = NewDocument(anApplication, theFormat); + ASSERT_FALSE(aDocument.IsNull()); + aDocument->NewCommand(); + SetShape(AttributeLabel(aDocument), + BRepPrimAPI_MakeBox(gp_Pnt(10.0, 20.0, 30.0), gp_Pnt(110.0, 220.0, 330.0))); + + occ::handle aRestored = SaveAndOpen(anApplication, + aDocument, + theFormat, + "draw_ocaf_named_shape_transaction_bin", + theUseStream); + ASSERT_FALSE(aRestored.IsNull()); + ExpectBoxBounds(ShapeOf(AttributeLabel(aRestored)), 10.0, 20.0, 30.0, 110.0, 220.0, 330.0); +} + +static void RunB8(const char* theFormat, const bool theUseStream = false) +{ + occ::handle anApplication = NewApplication(); + occ::handle aDocument = NewDocument(anApplication, theFormat); + ASSERT_FALSE(aDocument.IsNull()); + const TDF_Label aLabel = AttributeLabel(aDocument); + ASSERT_FALSE(TDataStd_Name::Set(aLabel, TCollection_ExtendedString("Label1")).IsNull()); + const TDF_Label aChild = TDF_TagSource::NewChild(aLabel); + ASSERT_FALSE(TDataStd_Name::Set(aChild, TCollection_ExtendedString("Label11")).IsNull()); + + occ::handle aRestored = + SaveAndOpen(anApplication, aDocument, theFormat, "draw_ocaf_tag_source_bin", theUseStream); + ASSERT_FALSE(aRestored.IsNull()); + occ::handle aTagSource; + ASSERT_TRUE(AttributeLabel(aRestored).FindAttribute(TDF_TagSource::GetID(), aTagSource)); + EXPECT_EQ(aTagSource->NewTag(), 2); + const TDF_Label aRestoredChild = AttributeLabel(aRestored).FindChild(1, false); + ASSERT_FALSE(aRestoredChild.IsNull()); + occ::handle aChildName; + ASSERT_TRUE(aRestoredChild.FindAttribute(TDataStd_Name::GetID(), aChildName)); + EXPECT_EQ(aChildName->Get(), TCollection_ExtendedString("Label11")); +} + +static void RunB9(const char* theFormat, const bool theUseStream = false) +{ + occ::handle anApplication = NewApplication(); + occ::handle aDocument = NewDocument(anApplication, theFormat); + ASSERT_FALSE(aDocument.IsNull()); + const TDF_Label aLabel = AttributeLabel(aDocument); + ASSERT_FALSE(TDataStd_Directory::New(aLabel).IsNull()); + ASSERT_FALSE(TDataStd_Name::Set(aLabel, TCollection_ExtendedString("Label1")).IsNull()); + + occ::handle aRestored = + SaveAndOpen(anApplication, aDocument, theFormat, "draw_ocaf_directory_bin", theUseStream); + ASSERT_FALSE(aRestored.IsNull()); + occ::handle aRestoredDirectory; + ASSERT_TRUE(TDataStd_Directory::Find(AttributeLabel(aRestored), aRestoredDirectory)); + occ::handle aName; + ASSERT_TRUE(AttributeLabel(aRestored).FindAttribute(TDataStd_Name::GetID(), aName)); + EXPECT_EQ(aName->Get(), TCollection_ExtendedString("Label1")); +} + +static void RunCafBugC1Stream() +{ + occ::handle anApplication = NewApplication(); + occ::handle aDocument = NewDocument(anApplication, "BinOcaf"); + ASSERT_FALSE(aDocument.IsNull()); + + const TDF_Label aLabel = AttributeLabel(aDocument); + ASSERT_FALSE(TDataStd_Name::Set(aLabel, TCollection_ExtendedString("Label_1")).IsNull()); + ASSERT_FALSE(TDataStd_TreeNode::Set(aLabel).IsNull()); + + occ::handle aRestored = SaveAndOpenStream(anApplication, aDocument); + ASSERT_FALSE(aRestored.IsNull()); + const TDF_Label aRestoredLabel = aRestored->Main().FindChild(2, false); + ASSERT_FALSE(aRestoredLabel.IsNull()); + occ::handle aRestoredNode; + ASSERT_TRUE(TDataStd_TreeNode::Find(aRestoredLabel, aRestoredNode)); + ASSERT_FALSE(aRestoredNode.IsNull()); + EXPECT_TRUE(aRestoredNode->IsRoot()); + ASSERT_FALSE(aRestoredNode->Root().IsNull()); + EXPECT_TRUE(aRestoredNode->Root()->Label() == aRestoredLabel); + occ::handle aRestoredName; + ASSERT_TRUE(aRestoredLabel.FindAttribute(TDataStd_Name::GetID(), aRestoredName)); + EXPECT_EQ(aRestoredName->Get(), TCollection_ExtendedString("Label_1")); +} + +static void RunCafBugC2Stream() +{ + occ::handle anApplication = NewApplication(); + occ::handle aDocument = NewDocument(anApplication, "BinOcaf"); + ASSERT_FALSE(aDocument.IsNull()); + + const TDF_Label aLabel = AttributeLabel(aDocument); + occ::handle anArray = TDataStd_ExtStringArray::Set(aLabel, 1, 2); + ASSERT_FALSE(anArray.IsNull()); + anArray->SetValue(1, TCollection_ExtendedString("TDataStd")); + anArray->SetValue(2, TCollection_ExtendedString("ExtStringArray")); + + occ::handle aRestored = SaveAndOpenStream(anApplication, aDocument); + ASSERT_FALSE(aRestored.IsNull()); + occ::handle aRestoredArray; + ASSERT_TRUE( + AttributeLabel(aRestored).FindAttribute(TDataStd_ExtStringArray::GetID(), aRestoredArray)); + ASSERT_FALSE(aRestoredArray.IsNull()); + EXPECT_EQ(aRestoredArray->Lower(), 1); + EXPECT_EQ(aRestoredArray->Upper(), 2); + EXPECT_EQ(aRestoredArray->Value(1), TCollection_ExtendedString("TDataStd")); + EXPECT_EQ(aRestoredArray->Value(2), TCollection_ExtendedString("ExtStringArray")); +} + +static void RestoreAfterForget(const occ::handle& theDocument, + const TDF_Label& theLabel) +{ + theDocument->NewCommand(); + theLabel.ForgetAllAttributes(); + theDocument->NewCommand(); + ASSERT_TRUE(theDocument->Undo()); + ASSERT_TRUE(theDocument->Redo()); + ASSERT_TRUE(theDocument->Undo()); +} + +static void ExpectCafExtendedArray(const occ::handle& theArray, + const TCollection_ExtendedString& theFirst, + const TCollection_ExtendedString& theSecond) +{ + ASSERT_FALSE(theArray.IsNull()); + EXPECT_EQ(theArray->Lower(), 1); + EXPECT_EQ(theArray->Upper(), 2); + EXPECT_EQ(theArray->Length(), 2); + EXPECT_EQ(theArray->Value(1), theFirst); + EXPECT_EQ(theArray->Value(2), theSecond); +} + +static void ExpectCafBooleanArray(const occ::handle& theArray, + const bool theFirst, + const bool theSecond) +{ + ASSERT_FALSE(theArray.IsNull()); + EXPECT_EQ(theArray->Lower(), 1); + EXPECT_EQ(theArray->Upper(), 2); + EXPECT_EQ(theArray->Length(), 2); + EXPECT_EQ(theArray->Value(1), theFirst); + EXPECT_EQ(theArray->Value(2), theSecond); +} + +static void ExpectCafByteArray(const occ::handle& theArray, + const int theFirst, + const int theSecond) +{ + ASSERT_FALSE(theArray.IsNull()); + EXPECT_EQ(theArray->Lower(), 1); + EXPECT_EQ(theArray->Upper(), 2); + EXPECT_EQ(theArray->Length(), 2); + EXPECT_EQ(static_cast(theArray->Value(1)), theFirst); + EXPECT_EQ(static_cast(theArray->Value(2)), theSecond); +} + +static void RunCafBasicM3Stream() +{ + occ::handle anApplication = NewApplication(); + occ::handle aDocument = NewDocument(anApplication, "BinOcaf"); + ASSERT_FALSE(aDocument.IsNull()); + const TDF_Label aLabel = AttributeLabel(aDocument); + occ::handle anArray = TDataStd_ExtStringArray::Set(aLabel, 1, 2); + ASSERT_FALSE(anArray.IsNull()); + anArray->SetValue(1, TCollection_ExtendedString("TDataStd")); + anArray->SetValue(2, TCollection_ExtendedString("ExtStringArray")); + + occ::handle aRestored = SaveAndOpenStream(anApplication, aDocument); + ASSERT_FALSE(aRestored.IsNull()); + occ::handle aRestoredArray; + ASSERT_TRUE( + AttributeLabel(aRestored).FindAttribute(TDataStd_ExtStringArray::GetID(), aRestoredArray)); + ExpectCafExtendedArray(aRestoredArray, + TCollection_ExtendedString("TDataStd"), + TCollection_ExtendedString("ExtStringArray")); +} + +static void RunCafBasicM6Stream() +{ + occ::handle anApplication = NewApplication(); + occ::handle aDocument = NewDocument(anApplication, "BinOcaf"); + ASSERT_FALSE(aDocument.IsNull()); + const TDF_Label aLabel = AttributeLabel(aDocument); + const Standard_GUID aGuid("12e94515-6dbc-11d4-b9c8-0060b0ee281b"); + occ::handle anArray = TDataStd_ExtStringArray::Set(aLabel, 1, 2); + occ::handle aGuidArray = + TDataStd_ExtStringArray::Set(aLabel, aGuid, 1, 2); + ASSERT_FALSE(anArray.IsNull()); + ASSERT_FALSE(aGuidArray.IsNull()); + anArray->SetValue(1, TCollection_ExtendedString("xxxxxxxx")); + anArray->SetValue(2, TCollection_ExtendedString("yyyyyyy")); + aGuidArray->SetValue(1, TCollection_ExtendedString("xxxxxxxx")); + aGuidArray->SetValue(2, TCollection_ExtendedString("yyyyyyy")); + RestoreAfterForget(aDocument, aLabel); + + occ::handle aRestored = SaveAndOpenStream(anApplication, aDocument); + ASSERT_FALSE(aRestored.IsNull()); + occ::handle aRestoredArray; + occ::handle aRestoredGuidArray; + ASSERT_TRUE( + AttributeLabel(aRestored).FindAttribute(TDataStd_ExtStringArray::GetID(), aRestoredArray)); + ASSERT_TRUE(AttributeLabel(aRestored).FindAttribute(aGuid, aRestoredGuidArray)); + ExpectCafExtendedArray(aRestoredArray, + TCollection_ExtendedString("xxxxxxxx"), + TCollection_ExtendedString("yyyyyyy")); + ExpectCafExtendedArray(aRestoredGuidArray, + TCollection_ExtendedString("xxxxxxxx"), + TCollection_ExtendedString("yyyyyyy")); +} + +static void RunCafBasicN6Stream() +{ + occ::handle anApplication = NewApplication(); + occ::handle aDocument = NewDocument(anApplication, "BinOcaf"); + ASSERT_FALSE(aDocument.IsNull()); + const TDF_Label aLabel = AttributeLabel(aDocument); + const Standard_GUID aGuid1("12e94571-6dbc-11d4-b9c8-0060b0ee281b"); + const Standard_GUID aGuid2("12e94572-6dbc-11d4-b9c8-0060b0ee281b"); + ASSERT_FALSE(TDataStd_AsciiString::Set(aLabel, aGuid1, "New Attribute_1").IsNull()); + ASSERT_FALSE(TDataStd_AsciiString::Set(aLabel, aGuid2, "New Attribute_2").IsNull()); + + occ::handle aRestored = SaveAndOpenStream(anApplication, aDocument); + ASSERT_FALSE(aRestored.IsNull()); + occ::handle anAttribute1; + occ::handle anAttribute2; + ASSERT_TRUE(AttributeLabel(aRestored).FindAttribute(aGuid1, anAttribute1)); + ASSERT_TRUE(AttributeLabel(aRestored).FindAttribute(aGuid2, anAttribute2)); + EXPECT_EQ(anAttribute1->Get(), TCollection_AsciiString("New Attribute_1")); + EXPECT_EQ(anAttribute2->Get(), TCollection_AsciiString("New Attribute_2")); +} + +static void RunCafBasicN7Stream() +{ + occ::handle anApplication = NewApplication(); + occ::handle aDocument = NewDocument(anApplication, "BinOcaf"); + ASSERT_FALSE(aDocument.IsNull()); + const TDF_Label aLabel = AttributeLabel(aDocument); + const Standard_GUID aGuid("12e94572-6dbc-11d4-b9c8-0060b0ee281b"); + ASSERT_FALSE(TDataStd_AsciiString::Set(aLabel, "New Attribute_1").IsNull()); + ASSERT_FALSE(TDataStd_AsciiString::Set(aLabel, aGuid, "New Attribute_2").IsNull()); + + occ::handle aRestored = SaveAndOpenStream(anApplication, aDocument); + ASSERT_FALSE(aRestored.IsNull()); + occ::handle aDefaultAttribute; + occ::handle aGuidAttribute; + ASSERT_TRUE( + AttributeLabel(aRestored).FindAttribute(TDataStd_AsciiString::GetID(), aDefaultAttribute)); + ASSERT_TRUE(AttributeLabel(aRestored).FindAttribute(aGuid, aGuidAttribute)); + EXPECT_EQ(aDefaultAttribute->Get(), TCollection_AsciiString("New Attribute_1")); + EXPECT_EQ(aGuidAttribute->Get(), TCollection_AsciiString("New Attribute_2")); +} + +static void RunCafBasicO6Stream() +{ + occ::handle anApplication = NewApplication(); + occ::handle aDocument = NewDocument(anApplication, "BinOcaf"); + ASSERT_FALSE(aDocument.IsNull()); + const TDF_Label aLabel = AttributeLabel(aDocument); + const Standard_GUID aGuid("12e94516-6dbc-11d4-b9c8-0060b0ee281b"); + occ::handle anArray = TDataStd_BooleanArray::Set(aLabel, 1, 2); + occ::handle aGuidArray = TDataStd_BooleanArray::Set(aLabel, aGuid, 1, 2); + ASSERT_FALSE(anArray.IsNull()); + ASSERT_FALSE(aGuidArray.IsNull()); + anArray->SetValue(1, false); + anArray->SetValue(2, true); + aGuidArray->SetValue(1, false); + aGuidArray->SetValue(2, true); + RestoreAfterForget(aDocument, aLabel); + + occ::handle aRestored = SaveAndOpenStream(anApplication, aDocument); + ASSERT_FALSE(aRestored.IsNull()); + occ::handle aRestoredArray; + occ::handle aRestoredGuidArray; + ASSERT_TRUE( + AttributeLabel(aRestored).FindAttribute(TDataStd_BooleanArray::GetID(), aRestoredArray)); + ASSERT_TRUE(AttributeLabel(aRestored).FindAttribute(aGuid, aRestoredGuidArray)); + ExpectCafBooleanArray(aRestoredArray, false, true); + ExpectCafBooleanArray(aRestoredGuidArray, false, true); +} + +static void RunCafBasicP6Stream() +{ + occ::handle anApplication = NewApplication(); + occ::handle aDocument = NewDocument(anApplication, "BinOcaf"); + ASSERT_FALSE(aDocument.IsNull()); + const TDF_Label aLabel = AttributeLabel(aDocument); + const Standard_GUID aGuid("12e94517-6dbc-11d4-b9c8-0060b0ee281b"); + occ::handle anArray = TDataStd_ByteArray::Set(aLabel, 1, 2); + occ::handle aGuidArray = TDataStd_ByteArray::Set(aLabel, aGuid, 1, 2); + ASSERT_FALSE(anArray.IsNull()); + ASSERT_FALSE(aGuidArray.IsNull()); + anArray->SetValue(1, 10); + anArray->SetValue(2, 12); + aGuidArray->SetValue(1, 10); + aGuidArray->SetValue(2, 12); + RestoreAfterForget(aDocument, aLabel); + + occ::handle aRestored = SaveAndOpenStream(anApplication, aDocument); + ASSERT_FALSE(aRestored.IsNull()); + occ::handle aRestoredArray; + occ::handle aRestoredGuidArray; + ASSERT_TRUE(AttributeLabel(aRestored).FindAttribute(TDataStd_ByteArray::GetID(), aRestoredArray)); + ASSERT_TRUE(AttributeLabel(aRestored).FindAttribute(aGuid, aRestoredGuidArray)); + ExpectCafByteArray(aRestoredArray, 10, 12); + ExpectCafByteArray(aRestoredGuidArray, 10, 12); +} + +static void RunCafBasicQ6Stream() +{ + occ::handle anApplication = NewApplication(); + occ::handle aDocument = NewDocument(anApplication, "BinOcaf"); + ASSERT_FALSE(aDocument.IsNull()); + const TDF_Label aLabel = AttributeLabel(aDocument); + const TDF_Label aTarget1 = aDocument->Main().FindChild(3, true); + const TDF_Label aTarget2 = aDocument->Main().FindChild(4, true); + const Standard_GUID aGuid("12e94518-6dbc-11d4-b9c8-0060b0ee281b"); + occ::handle anArray = TDataStd_ReferenceArray::Set(aLabel, 1, 2); + occ::handle aGuidArray = + TDataStd_ReferenceArray::Set(aLabel, aGuid, 1, 2); + ASSERT_FALSE(anArray.IsNull()); + ASSERT_FALSE(aGuidArray.IsNull()); + anArray->SetValue(1, aTarget1); + anArray->SetValue(2, aTarget2); + aGuidArray->SetValue(1, aTarget1); + aGuidArray->SetValue(2, aTarget2); + RestoreAfterForget(aDocument, aLabel); + + occ::handle aRestored = SaveAndOpenStream(anApplication, aDocument); + ASSERT_FALSE(aRestored.IsNull()); + const TDF_Label aRestoredLabel = AttributeLabel(aRestored); + const TDF_Label aRestoredTarget1 = aRestored->Main().FindChild(3, false); + const TDF_Label aRestoredTarget2 = aRestored->Main().FindChild(4, false); + ASSERT_FALSE(aRestoredTarget1.IsNull()); + ASSERT_FALSE(aRestoredTarget2.IsNull()); + occ::handle aRestoredArray; + occ::handle aRestoredGuidArray; + ASSERT_TRUE(aRestoredLabel.FindAttribute(TDataStd_ReferenceArray::GetID(), aRestoredArray)); + ASSERT_TRUE(aRestoredLabel.FindAttribute(aGuid, aRestoredGuidArray)); + EXPECT_EQ(aRestoredArray->Lower(), 1); + EXPECT_EQ(aRestoredArray->Upper(), 2); + EXPECT_EQ(aRestoredArray->Value(1), aRestoredTarget1); + EXPECT_EQ(aRestoredArray->Value(2), aRestoredTarget2); + EXPECT_EQ(aRestoredGuidArray->Value(1), aRestoredTarget1); + EXPECT_EQ(aRestoredGuidArray->Value(2), aRestoredTarget2); +} + +static void RunCafBasicR6Stream() +{ + occ::handle anApplication = NewApplication(); + occ::handle aDocument = NewDocument(anApplication, "BinOcaf"); + ASSERT_FALSE(aDocument.IsNull()); + const TDF_Label aLabel = AttributeLabel(aDocument); + const Standard_GUID aGuid("12e94521-6dbc-11d4-b9c8-0060b0ee281b"); + occ::handle aList = TDataStd_RealList::Set(aLabel); + occ::handle aGuidList = TDataStd_RealList::Set(aLabel, aGuid); + ASSERT_FALSE(aList.IsNull()); + ASSERT_FALSE(aGuidList.IsNull()); + aList->Append(3.0); + aList->Append(4.0); + aGuidList->Append(3.0); + aGuidList->Append(4.0); + RestoreAfterForget(aDocument, aLabel); + + occ::handle aRestored = SaveAndOpenStream(anApplication, aDocument); + ASSERT_FALSE(aRestored.IsNull()); + occ::handle aRestoredList; + occ::handle aRestoredGuidList; + ASSERT_TRUE(AttributeLabel(aRestored).FindAttribute(TDataStd_RealList::GetID(), aRestoredList)); + ASSERT_TRUE(AttributeLabel(aRestored).FindAttribute(aGuid, aRestoredGuidList)); + EXPECT_EQ(aRestoredList->Extent(), 2); + EXPECT_DOUBLE_EQ(aRestoredList->First(), 3.0); + EXPECT_DOUBLE_EQ(aRestoredList->Last(), 4.0); + EXPECT_EQ(aRestoredGuidList->Extent(), 2); + EXPECT_DOUBLE_EQ(aRestoredGuidList->First(), 3.0); + EXPECT_DOUBLE_EQ(aRestoredGuidList->Last(), 4.0); +} + +static void RunCafBasicS6Stream() +{ + occ::handle anApplication = NewApplication(); + occ::handle aDocument = NewDocument(anApplication, "BinOcaf"); + ASSERT_FALSE(aDocument.IsNull()); + const TDF_Label aLabel = AttributeLabel(aDocument); + const Standard_GUID aGuid("12e94531-6dbc-11d4-b9c8-0060b0ee281b"); + occ::handle aList = TDataStd_IntegerList::Set(aLabel); + occ::handle aGuidList = TDataStd_IntegerList::Set(aLabel, aGuid); + ASSERT_FALSE(aList.IsNull()); + ASSERT_FALSE(aGuidList.IsNull()); + aList->Append(33); + aList->Append(44); + aGuidList->Append(33); + aGuidList->Append(44); + RestoreAfterForget(aDocument, aLabel); + + occ::handle aRestored = SaveAndOpenStream(anApplication, aDocument); + ASSERT_FALSE(aRestored.IsNull()); + occ::handle aRestoredList; + occ::handle aRestoredGuidList; + ASSERT_TRUE( + AttributeLabel(aRestored).FindAttribute(TDataStd_IntegerList::GetID(), aRestoredList)); + ASSERT_TRUE(AttributeLabel(aRestored).FindAttribute(aGuid, aRestoredGuidList)); + EXPECT_EQ(aRestoredList->Extent(), 2); + EXPECT_EQ(aRestoredList->First(), 33); + EXPECT_EQ(aRestoredList->Last(), 44); + EXPECT_EQ(aRestoredGuidList->Extent(), 2); + EXPECT_EQ(aRestoredGuidList->First(), 33); + EXPECT_EQ(aRestoredGuidList->Last(), 44); +} + +static void RunCafBasicT6Stream() +{ + occ::handle anApplication = NewApplication(); + occ::handle aDocument = NewDocument(anApplication, "BinOcaf"); + ASSERT_FALSE(aDocument.IsNull()); + const TDF_Label aLabel = AttributeLabel(aDocument); + const Standard_GUID aGuid("12e94541-6dbc-11d4-b9c8-0060b0ee281b"); + occ::handle aList = TDataStd_ExtStringList::Set(aLabel); + occ::handle aGuidList = TDataStd_ExtStringList::Set(aLabel, aGuid); + ASSERT_FALSE(aList.IsNull()); + ASSERT_FALSE(aGuidList.IsNull()); + aList->Append(TCollection_ExtendedString("xxxx")); + aList->Append(TCollection_ExtendedString("yyyyy")); + aGuidList->Append(TCollection_ExtendedString("xxxx")); + aGuidList->Append(TCollection_ExtendedString("yyyyy")); + RestoreAfterForget(aDocument, aLabel); + + occ::handle aRestored = SaveAndOpenStream(anApplication, aDocument); + ASSERT_FALSE(aRestored.IsNull()); + occ::handle aRestoredList; + occ::handle aRestoredGuidList; + ASSERT_TRUE( + AttributeLabel(aRestored).FindAttribute(TDataStd_ExtStringList::GetID(), aRestoredList)); + ASSERT_TRUE(AttributeLabel(aRestored).FindAttribute(aGuid, aRestoredGuidList)); + EXPECT_EQ(aRestoredList->Extent(), 2); + EXPECT_EQ(aRestoredList->First(), TCollection_ExtendedString("xxxx")); + EXPECT_EQ(aRestoredList->Last(), TCollection_ExtendedString("yyyyy")); + EXPECT_EQ(aRestoredGuidList->Extent(), 2); + EXPECT_EQ(aRestoredGuidList->First(), TCollection_ExtendedString("xxxx")); + EXPECT_EQ(aRestoredGuidList->Last(), TCollection_ExtendedString("yyyyy")); +} + +static void RunCafBasicU6Stream() +{ + occ::handle anApplication = NewApplication(); + occ::handle aDocument = NewDocument(anApplication, "BinOcaf"); + ASSERT_FALSE(aDocument.IsNull()); + const TDF_Label aLabel = AttributeLabel(aDocument); + const Standard_GUID aGuid("12e94551-6dbc-11d4-b9c8-0060b0ee281b"); + occ::handle aList = TDataStd_BooleanList::Set(aLabel); + occ::handle aGuidList = TDataStd_BooleanList::Set(aLabel, aGuid); + ASSERT_FALSE(aList.IsNull()); + ASSERT_FALSE(aGuidList.IsNull()); + aList->Append(false); + aList->Append(true); + aGuidList->Append(false); + aGuidList->Append(true); + RestoreAfterForget(aDocument, aLabel); + + occ::handle aRestored = SaveAndOpenStream(anApplication, aDocument); + ASSERT_FALSE(aRestored.IsNull()); + occ::handle aRestoredList; + occ::handle aRestoredGuidList; + ASSERT_TRUE( + AttributeLabel(aRestored).FindAttribute(TDataStd_BooleanList::GetID(), aRestoredList)); + ASSERT_TRUE(AttributeLabel(aRestored).FindAttribute(aGuid, aRestoredGuidList)); + EXPECT_EQ(aRestoredList->Extent(), 2); + EXPECT_EQ(aRestoredList->First(), false); + EXPECT_EQ(aRestoredList->Last(), true); + EXPECT_EQ(aRestoredGuidList->Extent(), 2); + EXPECT_EQ(aRestoredGuidList->First(), false); + EXPECT_EQ(aRestoredGuidList->Last(), true); +} + +static void RunCafBasicV6Stream() +{ + occ::handle anApplication = NewApplication(); + occ::handle aDocument = NewDocument(anApplication, "BinOcaf"); + ASSERT_FALSE(aDocument.IsNull()); + const TDF_Label aLabel = AttributeLabel(aDocument); + const TDF_Label aTarget1 = aDocument->Main().FindChild(3, true); + const TDF_Label aTarget2 = aDocument->Main().FindChild(4, true); + const Standard_GUID aGuid("12e94561-6dbc-11d4-b9c8-0060b0ee281b"); + occ::handle aList = TDataStd_ReferenceList::Set(aLabel); + occ::handle aGuidList = TDataStd_ReferenceList::Set(aLabel, aGuid); + ASSERT_FALSE(aList.IsNull()); + ASSERT_FALSE(aGuidList.IsNull()); + aList->Append(aTarget1); + aList->Append(aTarget2); + aGuidList->Append(aTarget1); + aGuidList->Append(aTarget2); + RestoreAfterForget(aDocument, aLabel); + + occ::handle aRestored = SaveAndOpenStream(anApplication, aDocument); + ASSERT_FALSE(aRestored.IsNull()); + const TDF_Label aRestoredTarget1 = aRestored->Main().FindChild(3, false); + const TDF_Label aRestoredTarget2 = aRestored->Main().FindChild(4, false); + ASSERT_FALSE(aRestoredTarget1.IsNull()); + ASSERT_FALSE(aRestoredTarget2.IsNull()); + occ::handle aRestoredList; + occ::handle aRestoredGuidList; + ASSERT_TRUE( + AttributeLabel(aRestored).FindAttribute(TDataStd_ReferenceList::GetID(), aRestoredList)); + ASSERT_TRUE(AttributeLabel(aRestored).FindAttribute(aGuid, aRestoredGuidList)); + EXPECT_EQ(aRestoredList->Extent(), 2); + EXPECT_EQ(aRestoredList->First(), aRestoredTarget1); + EXPECT_EQ(aRestoredList->Last(), aRestoredTarget2); + EXPECT_EQ(aRestoredGuidList->Extent(), 2); + EXPECT_EQ(aRestoredGuidList->First(), aRestoredTarget1); + EXPECT_EQ(aRestoredGuidList->Last(), aRestoredTarget2); +} + +static occ::handle MakeCafTriangulation(const bool theDense) +{ + if (!theDense) + { + NCollection_Array1 aNodes(1, 4); + aNodes.SetValue(1, gp_Pnt(0.0, 0.0, 0.0)); + aNodes.SetValue(2, gp_Pnt(10.0, 0.0, 0.0)); + aNodes.SetValue(3, gp_Pnt(10.0, 10.0, 0.0)); + aNodes.SetValue(4, gp_Pnt(0.0, 10.0, 0.0)); + NCollection_Array1 aTriangles(1, 2); + aTriangles.SetValue(1, Poly_Triangle(1, 2, 3)); + aTriangles.SetValue(2, Poly_Triangle(1, 3, 4)); + occ::handle aResult = new Poly_Triangulation(aNodes, aTriangles); + aResult->Deflection(10.0); + return aResult; + } + + NCollection_Array1 aNodes(1, 5); + aNodes.SetValue(1, gp_Pnt(0.0, 0.0, 0.0)); + aNodes.SetValue(2, gp_Pnt(10.0, 0.0, 0.0)); + aNodes.SetValue(3, gp_Pnt(10.0, 10.0, 0.0)); + aNodes.SetValue(4, gp_Pnt(0.0, 10.0, 0.0)); + aNodes.SetValue(5, gp_Pnt(5.0, 5.0, 0.0)); + NCollection_Array1 aTriangles(1, 4); + aTriangles.SetValue(1, Poly_Triangle(1, 2, 5)); + aTriangles.SetValue(2, Poly_Triangle(2, 3, 5)); + aTriangles.SetValue(3, Poly_Triangle(3, 4, 5)); + aTriangles.SetValue(4, Poly_Triangle(4, 1, 5)); + occ::handle aResult = new Poly_Triangulation(aNodes, aTriangles); + aResult->Deflection(1.0); + return aResult; +} + +static void ExpectCafTriangulation(const TDF_Label& theLabel, + const occ::handle& theExpected) +{ + occ::handle anAttribute; + ASSERT_TRUE(theLabel.FindAttribute(TDataXtd_Triangulation::GetID(), anAttribute)); + ASSERT_FALSE(anAttribute.IsNull()); + ASSERT_FALSE(anAttribute->Get().IsNull()); + EXPECT_DOUBLE_EQ(anAttribute->Deflection(), theExpected->Deflection()); + EXPECT_EQ(anAttribute->NbNodes(), theExpected->NbNodes()); + EXPECT_EQ(anAttribute->NbTriangles(), theExpected->NbTriangles()); + EXPECT_EQ(anAttribute->HasUVNodes(), theExpected->HasUVNodes()); + EXPECT_EQ(anAttribute->HasNormals(), theExpected->HasNormals()); + for (int anIndex = 1; anIndex <= theExpected->NbNodes(); ++anIndex) + { + EXPECT_TRUE( + anAttribute->Node(anIndex).IsEqual(theExpected->Node(anIndex), Precision::Confusion())); + } + for (int anIndex = 1; anIndex <= theExpected->NbTriangles(); ++anIndex) + { + int anExpectedNode1 = 0; + int anExpectedNode2 = 0; + int anExpectedNode3 = 0; + int anActualNode1 = 0; + int anActualNode2 = 0; + int anActualNode3 = 0; + theExpected->Triangle(anIndex).Get(anExpectedNode1, anExpectedNode2, anExpectedNode3); + anAttribute->Triangle(anIndex).Get(anActualNode1, anActualNode2, anActualNode3); + EXPECT_EQ(anActualNode1, anExpectedNode1); + EXPECT_EQ(anActualNode2, anExpectedNode2); + EXPECT_EQ(anActualNode3, anExpectedNode3); + } +} + +static void RunCafBasicN1Stream() +{ + occ::handle anApplication = NewApplication(); + occ::handle aDocument = NewDocument(anApplication, "BinOcaf"); + ASSERT_FALSE(aDocument.IsNull()); + const TDF_Label aLabel = aDocument->Main().FindChild(1, true); + const occ::handle aFirstMesh = MakeCafTriangulation(false); + const occ::handle aSecondMesh = MakeCafTriangulation(true); + + aDocument->NewCommand(); + ASSERT_FALSE(TDataXtd_Triangulation::Set(aLabel, aFirstMesh).IsNull()); + aDocument->CommitCommand(); + std::stringstream aFirstStream; + SaveDocumentStream(anApplication, aDocument, aFirstStream); + + aDocument->NewCommand(); + ASSERT_FALSE(TDataXtd_Triangulation::Set(aLabel, aSecondMesh).IsNull()); + aDocument->CommitCommand(); + std::stringstream aSecondStream; + SaveDocumentStream(anApplication, aDocument, aSecondStream); + + ASSERT_TRUE(aDocument->Undo()); + ExpectCafTriangulation(aLabel, aFirstMesh); + ASSERT_TRUE(aDocument->Redo()); + ExpectCafTriangulation(aLabel, aSecondMesh); + + anApplication->Close(aDocument); + occ::handle aRestoredFirst = OpenDocumentStream(anApplication, aFirstStream); + occ::handle aRestoredSecond = OpenDocumentStream(anApplication, aSecondStream); + ASSERT_FALSE(aRestoredFirst.IsNull()); + ASSERT_FALSE(aRestoredSecond.IsNull()); + ExpectCafTriangulation(aRestoredFirst->Main().FindChild(1, false), aFirstMesh); + ExpectCafTriangulation(aRestoredSecond->Main().FindChild(1, false), aSecondMesh); +} + +static void RunCafBug24164_2Stream() +{ + occ::handle anApplication = NewApplication(); + occ::handle aDocument = NewDocument(anApplication, "BinOcaf"); + ASSERT_FALSE(aDocument.IsNull()); + const TDF_Label aRoot = aDocument->Main().FindChild(1, true); + const TDF_Label aLabel1 = aRoot.FindChild(1, true); + const TDF_Label aLabel2 = aRoot.FindChild(2, true); + const TDF_Label aLabel3 = aRoot.FindChild(3, true); + const TDF_Label aLabel4 = aRoot.FindChild(4, true); + const TDF_Label aLabel5 = aRoot.FindChild(5, true); + const TDF_Label aLabel6 = aRoot.FindChild(6, true); + + occ::handle anArray1 = TDataStd_ReferenceArray::Set(aLabel1, 1, 2); + occ::handle anArray2 = TDataStd_ReferenceArray::Set(aLabel2, 1, 2); + occ::handle anArray3 = TDataStd_ReferenceArray::Set(aLabel3, 1, 1); + occ::handle anArray4 = TDataStd_ReferenceArray::Set(aLabel4, 1, 2); + occ::handle anArray5 = TDataStd_ReferenceArray::Set(aLabel5, 1, 1); + occ::handle anArray6 = TDataStd_ReferenceArray::Set(aLabel6, 1, 2); + ASSERT_FALSE(anArray1.IsNull()); + ASSERT_FALSE(anArray2.IsNull()); + ASSERT_FALSE(anArray3.IsNull()); + ASSERT_FALSE(anArray4.IsNull()); + ASSERT_FALSE(anArray5.IsNull()); + ASSERT_FALSE(anArray6.IsNull()); + anArray1->SetValue(1, aLabel2); + anArray1->SetValue(2, aLabel1); + anArray2->SetValue(1, aLabel3); + anArray2->SetValue(2, aLabel4); + anArray3->SetValue(1, aLabel1); + anArray4->SetValue(1, aLabel5); + anArray4->SetValue(2, aLabel1); + anArray5->SetValue(1, aLabel6); + anArray6->SetValue(1, aLabel3); + anArray6->SetValue(2, aLabel4); + + aDocument->NewCommand(); + occ::handle aRestored = SaveAndOpenStream(anApplication, aDocument); + ASSERT_FALSE(aRestored.IsNull()); + const TDF_Label aRestoredRoot = aRestored->Main().FindChild(1, false); + ASSERT_FALSE(aRestoredRoot.IsNull()); + const TDF_Label aRestoredLabel1 = aRestoredRoot.FindChild(1, false); + const TDF_Label aRestoredLabel2 = aRestoredRoot.FindChild(2, false); + const TDF_Label aRestoredLabel3 = aRestoredRoot.FindChild(3, false); + const TDF_Label aRestoredLabel4 = aRestoredRoot.FindChild(4, false); + const TDF_Label aRestoredLabel5 = aRestoredRoot.FindChild(5, false); + const TDF_Label aRestoredLabel6 = aRestoredRoot.FindChild(6, false); + ASSERT_FALSE(aRestoredLabel1.IsNull()); + ASSERT_FALSE(aRestoredLabel2.IsNull()); + ASSERT_FALSE(aRestoredLabel3.IsNull()); + ASSERT_FALSE(aRestoredLabel4.IsNull()); + ASSERT_FALSE(aRestoredLabel5.IsNull()); + ASSERT_FALSE(aRestoredLabel6.IsNull()); + + occ::handle aRestoredArray; + ASSERT_TRUE(aRestoredLabel1.FindAttribute(TDataStd_ReferenceArray::GetID(), aRestoredArray)); + EXPECT_EQ(aRestoredArray->Lower(), 1); + EXPECT_EQ(aRestoredArray->Upper(), 2); + EXPECT_EQ(aRestoredArray->Value(1), aRestoredLabel2); + EXPECT_EQ(aRestoredArray->Value(2), aRestoredLabel1); + ASSERT_TRUE(aRestoredLabel2.FindAttribute(TDataStd_ReferenceArray::GetID(), aRestoredArray)); + EXPECT_EQ(aRestoredArray->Value(1), aRestoredLabel3); + EXPECT_EQ(aRestoredArray->Value(2), aRestoredLabel4); + ASSERT_TRUE(aRestoredLabel3.FindAttribute(TDataStd_ReferenceArray::GetID(), aRestoredArray)); + EXPECT_EQ(aRestoredArray->Upper(), 1); + EXPECT_EQ(aRestoredArray->Value(1), aRestoredLabel1); + ASSERT_TRUE(aRestoredLabel4.FindAttribute(TDataStd_ReferenceArray::GetID(), aRestoredArray)); + EXPECT_EQ(aRestoredArray->Value(1), aRestoredLabel5); + EXPECT_EQ(aRestoredArray->Value(2), aRestoredLabel1); + ASSERT_TRUE(aRestoredLabel5.FindAttribute(TDataStd_ReferenceArray::GetID(), aRestoredArray)); + EXPECT_EQ(aRestoredArray->Upper(), 1); + EXPECT_EQ(aRestoredArray->Value(1), aRestoredLabel6); + ASSERT_TRUE(aRestoredLabel6.FindAttribute(TDataStd_ReferenceArray::GetID(), aRestoredArray)); + EXPECT_EQ(aRestoredArray->Value(1), aRestoredLabel3); + EXPECT_EQ(aRestoredArray->Value(2), aRestoredLabel4); +} + +static void RunCafBug24164_1Stream() +{ + occ::handle anApplication = NewApplication(); + occ::handle aDocument = NewDocument(anApplication, "BinOcaf"); + ASSERT_FALSE(aDocument.IsNull()); + + occ::handle aDriverTable = TFunction_DriverTable::Get(); + aDriverTable->AddDriver(BOX_GUID, new DNaming_BoxDriver()); + + const occ::handle anObject = AddNamingObject(aDocument); + ASSERT_FALSE(anObject.IsNull()); + const occ::handle aFunction = AddNamingFunction(anObject, BOX_GUID); + ASSERT_FALSE(aFunction.IsNull()); + DNaming::GetReal(aFunction, BOX_DX)->Set(190.0); + DNaming::GetReal(aFunction, BOX_DY)->Set(290.0); + DNaming::GetReal(aFunction, BOX_DZ)->Set(390.0); + ASSERT_EQ(ExecuteNamingFunction(aFunction, new DNaming_BoxDriver()), 0); + ExpectBoxBounds(NamingFunctionShape(aFunction), 0.0, 0.0, 0.0, 190.0, 290.0, 390.0); + + TCollection_AsciiString aFunctionEntry; + TDF_Tool::Entry(aFunction->Label(), aFunctionEntry); + std::stringstream aStream; + SaveDocumentStream(anApplication, aDocument, aStream); + + EXPECT_NO_THROW(anApplication->Close(aDocument)); + occ::handle aRestored = OpenDocumentStream(anApplication, aStream); + ASSERT_FALSE(aRestored.IsNull()); + + const TDF_Label aRestoredFunctionLabel = LabelByEntry(aRestored, aFunctionEntry); + ASSERT_FALSE(aRestoredFunctionLabel.IsNull()); + occ::handle aRestoredFunction; + ASSERT_TRUE(aRestoredFunctionLabel.FindAttribute(TFunction_Function::GetID(), aRestoredFunction)); + EXPECT_EQ(aRestoredFunction->GetDriverGUID(), BOX_GUID); + EXPECT_EQ(aRestoredFunction->GetFailure(), DONE); + ExpectBoxBounds(NamingFunctionShape(aRestoredFunction), 0.0, 0.0, 0.0, 190.0, 290.0, 390.0); + + const TDF_Label aRestoredResultLabel = + aRestoredFunctionLabel.FindChild(FUNCTION_RESULT_LABEL, false); + ASSERT_FALSE(aRestoredResultLabel.IsNull()); + EXPECT_EQ(TopExp_Explorer(NamingFunctionShape(aRestoredFunction), TopAbs_FACE).More(), true); + EXPECT_NO_THROW(anApplication->Close(aRestored)); +} + +static void RunC1(const char* theFormat) +{ + occ::handle anApplication = NewApplication(); + occ::handle aDocument = NewDocument(anApplication, theFormat); + ASSERT_FALSE(aDocument.IsNull()); + const TDF_Label aRootLabel = AttributeLabel(aDocument); + ASSERT_FALSE(TDataStd_Name::Set(aRootLabel, TCollection_ExtendedString("Label_1")).IsNull()); + occ::handle aRootNode = TDataStd_TreeNode::Set(aRootLabel); + const TDF_Label aChildLabel1 = aDocument->Main().FindChild(7, true); + const TDF_Label aChildLabel2 = aDocument->Main().FindChild(8, true); + const TDF_Label aChildLabel3 = aDocument->Main().FindChild(9, true); + occ::handle aChildNode1 = TDataStd_TreeNode::Set(aChildLabel1); + occ::handle aChildNode2 = TDataStd_TreeNode::Set(aChildLabel2); + occ::handle aChildNode3 = TDataStd_TreeNode::Set(aChildLabel3); + ASSERT_TRUE(aRootNode->Append(aChildNode1)); + ASSERT_TRUE(aRootNode->Append(aChildNode2)); + ASSERT_TRUE(aRootNode->Append(aChildNode3)); + + occ::handle aRestored = + SaveAndOpen(anApplication, aDocument, theFormat, "draw_ocaf_tree_nodes_bin"); + ASSERT_FALSE(aRestored.IsNull()); + occ::handle aRestoredRoot = TDataStd_TreeNode::Set(AttributeLabel(aRestored)); + ASSERT_FALSE(aRestoredRoot.IsNull()); + EXPECT_EQ(aRestoredRoot->NbChildren(false), 3); + const int aExpectedTags[] = {7, 8, 9}; + TDataStd_ChildNodeIterator anIterator(aRestoredRoot, false); + for (int anIndex = 0; anIterator.More() && anIndex < 3; anIterator.Next(), ++anIndex) + { + EXPECT_EQ(anIterator.Value()->Label().Tag(), aExpectedTags[anIndex]); + } + EXPECT_FALSE(anIterator.More()); +} + +static void RunC6(const char* theFormat) +{ + occ::handle anApplication = NewApplication(); + occ::handle aDocument = NewDocument(anApplication, theFormat); + ASSERT_FALSE(aDocument.IsNull()); + const Standard_GUID aDriverGuid("5b35ca00-5b78-11d1-8940-080009dc3333"); + const TDF_Label aLabel = aDocument->GetData()->Root().FindChild(1, true).FindChild(1, true); + occ::handle aFunction = TFunction_Function::Set(aLabel, aDriverGuid); + ASSERT_FALSE(aFunction.IsNull()); + aFunction->SetFailure(13); + TCollection_AsciiString aLabelEntry; + TDF_Tool::Entry(aLabel, aLabelEntry); + + occ::handle aRestored = + SaveAndOpen(anApplication, aDocument, theFormat, "draw_ocaf_function_bin"); + ASSERT_FALSE(aRestored.IsNull()); + const TDF_Label aRestoredLabel = LabelByEntry(aRestored, aLabelEntry); + occ::handle aRestoredFunction; + ASSERT_TRUE(aRestoredLabel.FindAttribute(TFunction_Function::GetID(), aRestoredFunction)); + EXPECT_EQ(aRestoredFunction->GetDriverGUID(), aDriverGuid); + EXPECT_EQ(aRestoredFunction->GetFailure(), 13); +} + +static void RunD1(const char* theFormat) +{ + occ::handle anApplication = NewApplication(); + occ::handle aDocument = NewDocument(anApplication, theFormat); + ASSERT_FALSE(aDocument.IsNull()); + const char* const aNames[] = {"Tu sais je n'ai jamais t aussi hereux que ce matin-l", + "\"Tu sais je n'ai jamais t aussi hereux que ce matin-l\"", + "", + "Tu m'as dit \"J'ai rendez-vous dans un sous-sol avec des fous", + "\"Tu m'as dit \"J'ai rendez-vous dans un sous-sol avec des fous\"", + "Il dans ce monde triste"}; + for (int anIndex = 0; anIndex < 6; ++anIndex) + { + const TDF_Label aLabel = aDocument->Main().FindChild(11 + anIndex, true); + ASSERT_FALSE(TDataStd_Name::Set(aLabel, TCollection_ExtendedString(aNames[anIndex])).IsNull()); + } + + occ::handle aRestored = + SaveAndOpen(anApplication, aDocument, theFormat, "draw_ocaf_special_names_bin"); + ASSERT_FALSE(aRestored.IsNull()); + for (int anIndex = 0; anIndex < 6; ++anIndex) + { + const TDF_Label aLabel = aRestored->Main().FindChild(11 + anIndex, false); + occ::handle aName; + ASSERT_TRUE(aLabel.FindAttribute(TDataStd_Name::GetID(), aName)); + EXPECT_EQ(aName->Get(), TCollection_ExtendedString(aNames[anIndex])); + } +} + +static void RunD4(const char* theFormat) +{ + occ::handle anApplication = NewApplication(); + occ::handle aDocument = NewDocument(anApplication, theFormat); + ASSERT_FALSE(aDocument.IsNull()); + occ::handle anArray = + TDataStd_IntegerArray::Set(AttributeLabel(aDocument), 1, 1); + ASSERT_FALSE(anArray.IsNull()); + anArray->SetValue(1, 3); + + occ::handle aRestored = + SaveAndOpen(anApplication, aDocument, theFormat, "draw_ocaf_single_integer_array_bin"); + ASSERT_FALSE(aRestored.IsNull()); + occ::handle aRestoredArray; + ASSERT_TRUE( + AttributeLabel(aRestored).FindAttribute(TDataStd_IntegerArray::GetID(), aRestoredArray)); + EXPECT_EQ(aRestoredArray->Lower(), 1); + EXPECT_EQ(aRestoredArray->Upper(), 1); + EXPECT_EQ(aRestoredArray->Value(1), 3); +} + +static void RunD5(const char* theFormat) +{ + occ::handle anApplication = NewApplication(); + occ::handle aDocument = NewDocument(anApplication, theFormat); + ASSERT_FALSE(aDocument.IsNull()); + occ::handle anArray = + TDataStd_RealArray::Set(AttributeLabel(aDocument), 1, 1); + ASSERT_FALSE(anArray.IsNull()); + anArray->SetValue(1, 3.0); + + occ::handle aRestored = + SaveAndOpen(anApplication, aDocument, theFormat, "draw_ocaf_single_real_array_bin"); + ASSERT_FALSE(aRestored.IsNull()); + occ::handle aRestoredArray; + ASSERT_TRUE(AttributeLabel(aRestored).FindAttribute(TDataStd_RealArray::GetID(), aRestoredArray)); + EXPECT_EQ(aRestoredArray->Lower(), 1); + EXPECT_EQ(aRestoredArray->Upper(), 1); + EXPECT_DOUBLE_EQ(aRestoredArray->Value(1), 3.0); +} + +static void RunD6(const char* theFormat) +{ + occ::handle anApplication = NewApplication(); + occ::handle aDocument = NewDocument(anApplication, theFormat); + ASSERT_FALSE(aDocument.IsNull()); + ASSERT_FALSE( + TDataStd_Name::Set(AttributeLabel(aDocument), TCollection_ExtendedString("00")).IsNull()); + + occ::handle aRestored = + SaveAndOpen(anApplication, aDocument, theFormat, "draw_ocaf_leading_zero_name_bin"); + ASSERT_FALSE(aRestored.IsNull()); + occ::handle aName; + ASSERT_TRUE(AttributeLabel(aRestored).FindAttribute(TDataStd_Name::GetID(), aName)); + EXPECT_EQ(aName->Get(), TCollection_ExtendedString("00")); +} + +static void RunBasicIntegerUserGUID(const char* theFormat) +{ + occ::handle anApplication = NewApplication(); + occ::handle aDocument = NewDocument(anApplication, theFormat); + ASSERT_FALSE(aDocument.IsNull()); + const TDF_Label aLabel = AttributeLabel(aDocument); + const Standard_GUID aGuid1("12e94541-6dbc-11d4-b9c8-0060b0ee281b"); + const Standard_GUID aGuid2("12e94542-6dbc-11d4-b9c8-0060b0ee281b"); + ASSERT_FALSE(TDataStd_Integer::Set(aLabel, aGuid1, 100).IsNull()); + ASSERT_FALSE(TDataStd_Integer::Set(aLabel, aGuid2, 200).IsNull()); + + occ::handle aRestored = + SaveAndOpen(anApplication, aDocument, theFormat, "draw_caf_basic_integer_user_guids"); + ASSERT_FALSE(aRestored.IsNull()); + const TDF_Label aRestoredLabel = aRestored->Main().FindChild(2, false); + ASSERT_FALSE(aRestoredLabel.IsNull()); + occ::handle anInteger1; + occ::handle anInteger2; + ASSERT_TRUE(aRestoredLabel.FindAttribute(aGuid1, anInteger1)); + ASSERT_TRUE(aRestoredLabel.FindAttribute(aGuid2, anInteger2)); + EXPECT_EQ(anInteger1->Get(), 100); + EXPECT_EQ(anInteger2->Get(), 200); +} + +static void RunBasicIntegerDefaultAndUserGUID(const char* theFormat) +{ + occ::handle anApplication = NewApplication(); + occ::handle aDocument = NewDocument(anApplication, theFormat); + ASSERT_FALSE(aDocument.IsNull()); + const TDF_Label aLabel = AttributeLabel(aDocument); + const Standard_GUID aGuid("12e94541-6dbc-11d4-b9c8-0060b0ee281b"); + ASSERT_FALSE(TDataStd_Integer::Set(aLabel, 100).IsNull()); + ASSERT_FALSE(TDataStd_Integer::Set(aLabel, aGuid, 200).IsNull()); + + occ::handle aRestored = + SaveAndOpen(anApplication, aDocument, theFormat, "draw_caf_basic_integer_default_and_guid"); + ASSERT_FALSE(aRestored.IsNull()); + const TDF_Label aRestoredLabel = aRestored->Main().FindChild(2, false); + ASSERT_FALSE(aRestoredLabel.IsNull()); + occ::handle anInteger; + occ::handle aGuidInteger; + ASSERT_TRUE(aRestoredLabel.FindAttribute(TDataStd_Integer::GetID(), anInteger)); + ASSERT_TRUE(aRestoredLabel.FindAttribute(aGuid, aGuidInteger)); + EXPECT_EQ(anInteger->Get(), 100); + EXPECT_EQ(aGuidInteger->Get(), 200); +} + +static void RunBug28425(const char* theFormat) +{ + occ::handle anApplication = NewApplication(); + occ::handle aDocument = NewDocument(anApplication, theFormat); + ASSERT_FALSE(aDocument.IsNull()); + + const TDF_Label aLabel = aDocument->Main().FindChild(1, true); + TNaming_Builder aBuilder(aLabel); + aBuilder.Generated(BRepBuilderAPI_MakeVertex(gp_Pnt(1.0, 2.0, 3.0)).Shape()); + aBuilder.Generated(BRepPrimAPI_MakeBox(10.0, 20.0, 30.0).Shape()); + + occ::handle aNamedShape; + ASSERT_TRUE(aLabel.FindAttribute(TNaming_NamedShape::GetID(), aNamedShape)); + TNaming_Iterator anIterator(aNamedShape); + ASSERT_TRUE(anIterator.More()); + EXPECT_EQ(anIterator.NewShape().ShapeType(), TopAbs_SOLID); + + occ::handle aRestored = SaveAndOpenStream(anApplication, aDocument); + ASSERT_FALSE(aRestored.IsNull()); + const TDF_Label aRestoredLabel = aRestored->Main().FindChild(1, false); + ASSERT_FALSE(aRestoredLabel.IsNull()); + ASSERT_TRUE(aRestoredLabel.FindAttribute(TNaming_NamedShape::GetID(), aNamedShape)); + TNaming_Iterator aRestoredIterator(aNamedShape); + ASSERT_TRUE(aRestoredIterator.More()); + EXPECT_EQ(aRestoredIterator.NewShape().ShapeType(), TopAbs_SOLID); +} + +static void RunBug29669(const char* theFormat) +{ + occ::handle anApplication = NewApplication(); + occ::handle aDocument = NewDocument(anApplication, theFormat); + ASSERT_FALSE(aDocument.IsNull()); + + const TDF_Label aLabel = aDocument->Main().FindChild(1, true); + const Standard_GUID aGuid1("12e94541-6dbc-11d4-b9c8-0060b0ee281b"); + const Standard_GUID aGuid2("12e94541-6dbc-11d4-b9c8-0060b0ee281d"); + ASSERT_FALSE(TDataStd_Integer::Set(aLabel, aGuid1, 123).IsNull()); + ASSERT_FALSE(TDataStd_Integer::Set(aLabel, 100).IsNull()); + ASSERT_FALSE(TDataStd_Integer::Set(aLabel, aGuid2, 321).IsNull()); + + occ::handle aRestored = SaveAndOpenStream(anApplication, aDocument); + ASSERT_FALSE(aRestored.IsNull()); + const TDF_Label aRestoredLabel = aRestored->Main().FindChild(1, false); + ASSERT_FALSE(aRestoredLabel.IsNull()); + + occ::handle anInteger1; + occ::handle anInteger2; + ASSERT_TRUE(aRestoredLabel.FindAttribute(aGuid1, anInteger1)); + ASSERT_TRUE(aRestoredLabel.FindAttribute(aGuid2, anInteger2)); + EXPECT_EQ(anInteger1->Get(), 123); + EXPECT_EQ(anInteger2->Get(), 321); +} + +static void RunBasicRealUserGUID(const char* theFormat) +{ + occ::handle anApplication = NewApplication(); + occ::handle aDocument = NewDocument(anApplication, theFormat); + ASSERT_FALSE(aDocument.IsNull()); + const TDF_Label aLabel = AttributeLabel(aDocument); + const Standard_GUID aGuid1("12e94551-6dbc-11d4-b9c8-0060b0ee281b"); + const Standard_GUID aGuid2("12e94552-6dbc-11d4-b9c8-0060b0ee281b"); + ASSERT_FALSE(TDataStd_Real::Set(aLabel, aGuid1, 100.11).IsNull()); + ASSERT_FALSE(TDataStd_Real::Set(aLabel, aGuid2, 200.11).IsNull()); + + occ::handle aRestored = + SaveAndOpen(anApplication, aDocument, theFormat, "draw_caf_basic_real_user_guids"); + ASSERT_FALSE(aRestored.IsNull()); + const TDF_Label aRestoredLabel = aRestored->Main().FindChild(2, false); + ASSERT_FALSE(aRestoredLabel.IsNull()); + occ::handle aReal1; + occ::handle aReal2; + ASSERT_TRUE(aRestoredLabel.FindAttribute(aGuid1, aReal1)); + ASSERT_TRUE(aRestoredLabel.FindAttribute(aGuid2, aReal2)); + EXPECT_DOUBLE_EQ(aReal1->Get(), 100.11); + EXPECT_DOUBLE_EQ(aReal2->Get(), 200.11); +} + +static void RunBasicRealDefaultAndUserGUID(const char* theFormat) +{ + occ::handle anApplication = NewApplication(); + occ::handle aDocument = NewDocument(anApplication, theFormat); + ASSERT_FALSE(aDocument.IsNull()); + const TDF_Label aLabel = AttributeLabel(aDocument); + const Standard_GUID aGuid("12e94552-6dbc-11d4-b9c8-0060b0ee281b"); + ASSERT_FALSE(TDataStd_Real::Set(aLabel, 100.11).IsNull()); + ASSERT_FALSE(TDataStd_Real::Set(aLabel, aGuid, 200.11).IsNull()); + + occ::handle aRestored = + SaveAndOpen(anApplication, aDocument, theFormat, "draw_caf_basic_real_default_and_guid"); + ASSERT_FALSE(aRestored.IsNull()); + const TDF_Label aRestoredLabel = aRestored->Main().FindChild(2, false); + ASSERT_FALSE(aRestoredLabel.IsNull()); + occ::handle aReal; + occ::handle aGuidReal; + ASSERT_TRUE(aRestoredLabel.FindAttribute(TDataStd_Real::GetID(), aReal)); + ASSERT_TRUE(aRestoredLabel.FindAttribute(aGuid, aGuidReal)); + EXPECT_DOUBLE_EQ(aReal->Get(), 100.11); + EXPECT_DOUBLE_EQ(aGuidReal->Get(), 200.11); +} + +static void RestoreAttributesAfterUndo(const occ::handle& theDocument, + const TDF_Label& theLabel) +{ + theDocument->NewCommand(); + theLabel.ForgetAllAttributes(); + theDocument->NewCommand(); + ASSERT_TRUE(theDocument->Undo()); + ASSERT_TRUE(theDocument->Redo()); + ASSERT_TRUE(theDocument->Undo()); +} + +static void RunBasicRealArrayDefaultAndUserGUID(const char* theFormat) +{ + occ::handle anApplication = NewApplication(); + occ::handle aDocument = NewDocument(anApplication, theFormat); + ASSERT_FALSE(aDocument.IsNull()); + const TDF_Label aLabel = AttributeLabel(aDocument); + const Standard_GUID aGuid("12e94511-6dbc-11d4-b9c8-0060b0ee281b"); + aDocument->NewCommand(); + occ::handle anArray = TDataStd_RealArray::Set(aLabel, 1, 2); + occ::handle aGuidArray = TDataStd_RealArray::Set(aLabel, aGuid, 1, 2); + ASSERT_FALSE(anArray.IsNull()); + ASSERT_FALSE(aGuidArray.IsNull()); + anArray->SetValue(1, 3.0); + anArray->SetValue(2, 4.0); + aGuidArray->SetValue(1, 3.0); + aGuidArray->SetValue(2, 4.0); + RestoreAttributesAfterUndo(aDocument, aLabel); + + occ::handle aRestored = + SaveAndOpen(anApplication, aDocument, theFormat, "draw_caf_basic_real_array_user_guid"); + ASSERT_FALSE(aRestored.IsNull()); + const TDF_Label aRestoredLabel = aRestored->Main().FindChild(2, false); + ASSERT_FALSE(aRestoredLabel.IsNull()); + occ::handle aRestoredArray; + occ::handle aRestoredGuidArray; + ASSERT_TRUE(aRestoredLabel.FindAttribute(TDataStd_RealArray::GetID(), aRestoredArray)); + ASSERT_TRUE(aRestoredLabel.FindAttribute(aGuid, aRestoredGuidArray)); + EXPECT_EQ(aRestoredArray->Lower(), 1); + EXPECT_EQ(aRestoredArray->Upper(), 2); + EXPECT_DOUBLE_EQ(aRestoredArray->Value(1), 3.0); + EXPECT_DOUBLE_EQ(aRestoredArray->Value(2), 4.0); + EXPECT_EQ(aRestoredGuidArray->Lower(), 1); + EXPECT_EQ(aRestoredGuidArray->Upper(), 2); + EXPECT_DOUBLE_EQ(aRestoredGuidArray->Value(1), 3.0); + EXPECT_DOUBLE_EQ(aRestoredGuidArray->Value(2), 4.0); + EXPECT_EQ(aRestoredGuidArray->ID(), aGuid); +} + +static void RunBasicIntegerArrayDefaultAndUserGUID(const char* theFormat) +{ + occ::handle anApplication = NewApplication(); + occ::handle aDocument = NewDocument(anApplication, theFormat); + ASSERT_FALSE(aDocument.IsNull()); + const TDF_Label aLabel = AttributeLabel(aDocument); + const Standard_GUID aGuid("12e94511-6dbc-11d4-b9c8-0060b0ee281b"); + aDocument->NewCommand(); + occ::handle anArray = TDataStd_IntegerArray::Set(aLabel, 1, 2); + occ::handle aGuidArray = TDataStd_IntegerArray::Set(aLabel, aGuid, 1, 2); + ASSERT_FALSE(anArray.IsNull()); + ASSERT_FALSE(aGuidArray.IsNull()); + anArray->SetValue(1, 3); + anArray->SetValue(2, 4); + aGuidArray->SetValue(1, 3); + aGuidArray->SetValue(2, 4); + RestoreAttributesAfterUndo(aDocument, aLabel); + + occ::handle aRestored = + SaveAndOpen(anApplication, aDocument, theFormat, "draw_caf_basic_integer_array_user_guid"); + ASSERT_FALSE(aRestored.IsNull()); + const TDF_Label aRestoredLabel = aRestored->Main().FindChild(2, false); + ASSERT_FALSE(aRestoredLabel.IsNull()); + occ::handle aRestoredArray; + occ::handle aRestoredGuidArray; + ASSERT_TRUE(aRestoredLabel.FindAttribute(TDataStd_IntegerArray::GetID(), aRestoredArray)); + ASSERT_TRUE(aRestoredLabel.FindAttribute(aGuid, aRestoredGuidArray)); + EXPECT_EQ(aRestoredArray->Lower(), 1); + EXPECT_EQ(aRestoredArray->Upper(), 2); + EXPECT_EQ(aRestoredArray->Value(1), 3); + EXPECT_EQ(aRestoredArray->Value(2), 4); + EXPECT_EQ(aRestoredGuidArray->Lower(), 1); + EXPECT_EQ(aRestoredGuidArray->Upper(), 2); + EXPECT_EQ(aRestoredGuidArray->Value(1), 3); + EXPECT_EQ(aRestoredGuidArray->Value(2), 4); + EXPECT_EQ(aRestoredGuidArray->ID(), aGuid); +} + +static void RunBasicNameDefaultAndUserGUID(const char* theFormat) +{ + occ::handle anApplication = NewApplication(); + occ::handle aDocument = NewDocument(anApplication, theFormat); + ASSERT_FALSE(aDocument.IsNull()); + const TDF_Label aLabel = AttributeLabel(aDocument); + const Standard_GUID aGuid1("12e94561-6dbc-11d4-b9c8-0060b0ee281b"); + const Standard_GUID aGuid2("12e94562-6dbc-11d4-b9c8-0060b0ee281b"); + ASSERT_FALSE( + TDataStd_Name::Set(aLabel, aGuid1, TCollection_ExtendedString("New Attribute_1")).IsNull()); + ASSERT_FALSE( + TDataStd_Name::Set(aLabel, aGuid2, TCollection_ExtendedString("New Attribute_2")).IsNull()); + + occ::handle aRestored = + SaveAndOpen(anApplication, aDocument, theFormat, "draw_caf_basic_name_user_guids"); + ASSERT_FALSE(aRestored.IsNull()); + const TDF_Label aRestoredLabel = aRestored->Main().FindChild(2, false); + ASSERT_FALSE(aRestoredLabel.IsNull()); + occ::handle aName1; + occ::handle aName2; + ASSERT_TRUE(aRestoredLabel.FindAttribute(aGuid1, aName1)); + ASSERT_TRUE(aRestoredLabel.FindAttribute(aGuid2, aName2)); + EXPECT_EQ(aName1->Get(), TCollection_ExtendedString("New Attribute_1")); + EXPECT_EQ(aName2->Get(), TCollection_ExtendedString("New Attribute_2")); +} + +static void RunBasicNameDefaultAndUserGUIDPair(const char* theFormat) +{ + occ::handle anApplication = NewApplication(); + occ::handle aDocument = NewDocument(anApplication, theFormat); + ASSERT_FALSE(aDocument.IsNull()); + const TDF_Label aLabel = AttributeLabel(aDocument); + const Standard_GUID aGuid("12e94562-6dbc-11d4-b9c8-0060b0ee281b"); + ASSERT_FALSE(TDataStd_Name::Set(aLabel, TCollection_ExtendedString("New Attribute_1")).IsNull()); + ASSERT_FALSE( + TDataStd_Name::Set(aLabel, aGuid, TCollection_ExtendedString("New Attribute_2")).IsNull()); + + occ::handle aRestored = + SaveAndOpen(anApplication, aDocument, theFormat, "draw_caf_basic_name_default_and_guid"); + ASSERT_FALSE(aRestored.IsNull()); + const TDF_Label aRestoredLabel = aRestored->Main().FindChild(2, false); + ASSERT_FALSE(aRestoredLabel.IsNull()); + occ::handle aName; + occ::handle aGuidName; + ASSERT_TRUE(aRestoredLabel.FindAttribute(TDataStd_Name::GetID(), aName)); + ASSERT_TRUE(aRestoredLabel.FindAttribute(aGuid, aGuidName)); + EXPECT_EQ(aName->Get(), TCollection_ExtendedString("New Attribute_1")); + EXPECT_EQ(aGuidName->Get(), TCollection_ExtendedString("New Attribute_2")); +} + +static void AddEmptyAttribute(const TDF_Label& theLabel, const char* theTypeName) +{ + if (strcmp(theTypeName, "TDataStd_Tick") == 0) + { + theLabel.AddAttribute(new TDataStd_Tick()); + } + else if (strcmp(theTypeName, "TDataStd_Directory") == 0) + { + theLabel.AddAttribute(new TDataStd_Directory()); + } + else if (strcmp(theTypeName, "TDataStd_NoteBook") == 0) + { + theLabel.AddAttribute(new TDataStd_NoteBook()); + } + else if (strcmp(theTypeName, "TDataXtd_Axis") == 0) + { + theLabel.AddAttribute(new TDataXtd_Axis()); + } + else if (strcmp(theTypeName, "TDataXtd_Placement") == 0) + { + theLabel.AddAttribute(new TDataXtd_Placement()); + } + else if (strcmp(theTypeName, "TDataXtd_Plane") == 0) + { + theLabel.AddAttribute(new TDataXtd_Plane()); + } + else if (strcmp(theTypeName, "TDataXtd_Point") == 0) + { + theLabel.AddAttribute(new TDataXtd_Point()); + } + else if (strcmp(theTypeName, "TDataXtd_Shape") == 0) + { + theLabel.AddAttribute(new TDataXtd_Shape()); + } + else + { + ASSERT_TRUE(false); + } +} + +static int NumberOfAttributes(const TDF_Label& theLabel) +{ + int aCount = 0; + TDF_AttributeIterator anIterator(theLabel); + for (; anIterator.More(); anIterator.Next()) + { + ++aCount; + } + return aCount; +} + +static bool HasAttributeType(const TDF_Label& theLabel, const occ::handle& theType) +{ + for (TDF_AttributeIterator anIterator(theLabel); anIterator.More(); anIterator.Next()) + { + if (anIterator.Value()->IsKind(theType)) + { + return true; + } + } + return false; +} + +static void RunBasicEmptyAttributes(const char* theFormat) +{ + occ::handle anApplication = NewApplication(); + occ::handle aDocument = NewDocument(anApplication, theFormat); + ASSERT_FALSE(aDocument.IsNull()); + const TDF_Label aLabel = AttributeLabel(aDocument); + aDocument->NewCommand(); + AddEmptyAttribute(aLabel, "TDataStd_Tick"); + AddEmptyAttribute(aLabel, "TDataStd_Directory"); + AddEmptyAttribute(aLabel, "TDataStd_NoteBook"); + AddEmptyAttribute(aLabel, "TDataXtd_Axis"); + AddEmptyAttribute(aLabel, "TDataXtd_Placement"); + AddEmptyAttribute(aLabel, "TDataXtd_Plane"); + AddEmptyAttribute(aLabel, "TDataXtd_Point"); + AddEmptyAttribute(aLabel, "TDataXtd_Shape"); + ASSERT_TRUE(aDocument->CommitCommand()); + EXPECT_EQ(NumberOfAttributes(aLabel), 8); + EXPECT_TRUE(HasAttributeType(aLabel, STANDARD_TYPE(TDataStd_Tick))); + EXPECT_TRUE(HasAttributeType(aLabel, STANDARD_TYPE(TDataStd_Directory))); + EXPECT_TRUE(HasAttributeType(aLabel, STANDARD_TYPE(TDataStd_NoteBook))); + EXPECT_TRUE(HasAttributeType(aLabel, STANDARD_TYPE(TDataXtd_Axis))); + EXPECT_TRUE(HasAttributeType(aLabel, STANDARD_TYPE(TDataXtd_Placement))); + EXPECT_TRUE(HasAttributeType(aLabel, STANDARD_TYPE(TDataXtd_Plane))); + EXPECT_TRUE(HasAttributeType(aLabel, STANDARD_TYPE(TDataXtd_Point))); + EXPECT_TRUE(HasAttributeType(aLabel, STANDARD_TYPE(TDataXtd_Shape))); + + aDocument->NewCommand(); + ASSERT_TRUE(aLabel.ForgetAttribute(TDataXtd_Point::GetID())); + ASSERT_TRUE(aDocument->CommitCommand()); + EXPECT_EQ(NumberOfAttributes(aLabel), 7); + ASSERT_TRUE(aDocument->Undo()); + ASSERT_TRUE(aDocument->Undo()); + EXPECT_EQ(NumberOfAttributes(aLabel), 0); + ASSERT_TRUE(aDocument->Redo()); + EXPECT_EQ(NumberOfAttributes(aLabel), 8); + + occ::handle aRestored = + SaveAndOpen(anApplication, aDocument, theFormat, "draw_caf_basic_empty_attributes"); + ASSERT_FALSE(aRestored.IsNull()); + const TDF_Label aRestoredLabel = aRestored->Main().FindChild(2, false); + ASSERT_FALSE(aRestoredLabel.IsNull()); + EXPECT_EQ(NumberOfAttributes(aRestoredLabel), 8); + EXPECT_TRUE(HasAttributeType(aRestoredLabel, STANDARD_TYPE(TDataStd_Tick))); + EXPECT_TRUE(HasAttributeType(aRestoredLabel, STANDARD_TYPE(TDataStd_Directory))); + EXPECT_TRUE(HasAttributeType(aRestoredLabel, STANDARD_TYPE(TDataStd_NoteBook))); + EXPECT_TRUE(HasAttributeType(aRestoredLabel, STANDARD_TYPE(TDataXtd_Axis))); + EXPECT_TRUE(HasAttributeType(aRestoredLabel, STANDARD_TYPE(TDataXtd_Placement))); + EXPECT_TRUE(HasAttributeType(aRestoredLabel, STANDARD_TYPE(TDataXtd_Plane))); + EXPECT_TRUE(HasAttributeType(aRestoredLabel, STANDARD_TYPE(TDataXtd_Point))); + EXPECT_TRUE(HasAttributeType(aRestoredLabel, STANDARD_TYPE(TDataXtd_Shape))); +} + +static void RunBasicReference(const char* theFormat, const bool theUseStream = false) +{ + occ::handle anApplication = NewApplication(); + occ::handle aDocument = NewDocument(anApplication, theFormat); + ASSERT_FALSE(aDocument.IsNull()); + const TDF_Label aLabel1 = aDocument->Main().FindChild(2, true); + const TDF_Label aLabel2 = aDocument->Main().FindChild(3, true); + const TDF_Label aLabel3 = aDocument->Main().FindChild(4, true); + const TDF_Label aLabel4 = aDocument->Main().FindChild(5, true); + ASSERT_FALSE(TDataStd_Integer::Set(aLabel1, 100).IsNull()); + ASSERT_FALSE(TDataStd_Integer::Set(aLabel2, 200).IsNull()); + ASSERT_FALSE(TDataStd_Integer::Set(aLabel3, 300).IsNull()); + ASSERT_FALSE(TDF_Reference::Set(aLabel4, aLabel2).IsNull()); + + occ::handle aRestored = + SaveAndOpen(anApplication, aDocument, theFormat, "draw_caf_basic_reference", theUseStream); + ASSERT_FALSE(aRestored.IsNull()); + const TDF_Label aRestoredLabel2 = aRestored->Main().FindChild(3, false); + const TDF_Label aRestoredLabel4 = aRestored->Main().FindChild(5, false); + ASSERT_FALSE(aRestoredLabel2.IsNull()); + ASSERT_FALSE(aRestoredLabel4.IsNull()); + occ::handle aReference; + ASSERT_TRUE(aRestoredLabel4.FindAttribute(TDF_Reference::GetID(), aReference)); + ASSERT_TRUE(aReference->Get() == aRestoredLabel2); + occ::handle anInteger; + ASSERT_TRUE(aRestoredLabel2.FindAttribute(TDataStd_Integer::GetID(), anInteger)); + EXPECT_EQ(anInteger->Get(), 200); +} + +static TDF_Label FindOrCreatePath(const occ::handle& theDocument, + const int* theTags, + const int theNbTags) +{ + TDF_Label aLabel = theDocument->Main(); + for (int anIndex = 0; anIndex < theNbTags; ++anIndex) + { + aLabel = aLabel.FindChild(theTags[anIndex], true); + } + return aLabel; +} + +static void RunB4(const char* theFormat) +{ + occ::handle anApplication = NewApplication(); + occ::handle aDocument = NewDocument(anApplication, theFormat); + ASSERT_FALSE(aDocument.IsNull()); + const int aTags1[] = {3}; + const int aTags2[] = {2076534922, 524398634, 912349856}; + const int aTags3[] = {3, 9283, 12, 1, 9843, 46793, 321}; + const int aTags4[] = {4, 81245034, 321, 1, 1, 1, 345, 8542, 1, 90, 6453}; + const int aTags5[] = {5, 8, 4, 2, 213, 3242, 123456789, 987654321}; + const int aTags6[] = {2, 15, 123, 31214, 452398, 421, 3, 2, 1, 3, 1, 2, 9, 10, 2, 1, 1, 4}; + const int aTags7[] = {2, 2, 1, 1, 1, 3, 1, 2, 1, 34, 1, 2, 4, 1, 5, + 4, 1, 9, 3, 1, 2, 1, 8, 2, 3, 1, 9, 5, 2, 7}; + const int aTags8[] = {2, 9}; + const int* const aTags[] = {aTags1, aTags2, aTags3, aTags4, aTags5, aTags6, aTags7, aTags8}; + const int aTagLengths[] = {1, 3, 7, 11, 8, 18, 30, 2}; + NCollection_Array1 aLabels(1, 8); + NCollection_Array1 aEntries(1, 8); + for (int anIndex = 1; anIndex <= 8; ++anIndex) + { + aLabels.SetValue(anIndex, + FindOrCreatePath(aDocument, aTags[anIndex - 1], aTagLengths[anIndex - 1])); + TDF_Tool::Entry(aLabels.Value(anIndex), aEntries.ChangeValue(anIndex)); + } + + TDataStd_Integer::Set(aLabels.Value(8), 0); + for (int anIndex = 1; anIndex <= 8; ++anIndex) + { + TDataStd_Integer::Set(aLabels.Value(anIndex), anIndex); + TDF_Reference::Set(aLabels.Value(anIndex), aLabels.Value(anIndex == 1 ? 8 : anIndex - 1)); + } + + occ::handle aRestored = + SaveAndOpen(anApplication, aDocument, theFormat, "draw_ocaf_reference_chain_b4_bin"); + ASSERT_FALSE(aRestored.IsNull()); + for (int anIndex = 1; anIndex <= 8; ++anIndex) + { + const TDF_Label aRestoredLabel = LabelByEntry(aRestored, aEntries.Value(anIndex)); + ASSERT_FALSE(aRestoredLabel.IsNull()); + occ::handle aReference; + ASSERT_TRUE(aRestoredLabel.FindAttribute(TDF_Reference::GetID(), aReference)); + const int anExpectedIndex = anIndex == 1 ? 8 : anIndex - 1; + EXPECT_TRUE(aReference->Get() == LabelByEntry(aRestored, aEntries.Value(anExpectedIndex))); + occ::handle anInteger; + ASSERT_TRUE(aReference->Get().FindAttribute(TDataStd_Integer::GetID(), anInteger)); + EXPECT_EQ(anInteger->Get(), anExpectedIndex); + } +} + +static void RunC8(const char* theFormat) +{ + occ::handle anApplication = NewApplication(); + occ::handle aDocument = NewDocument(anApplication, theFormat); + ASSERT_FALSE(aDocument.IsNull()); + const TDF_Label aVariableLabel1 = + aDocument->GetData()->Root().FindChild(1, true).FindChild(1, true); + const TDF_Label aVariableLabel2 = + aDocument->GetData()->Root().FindChild(1, true).FindChild(2, true); + const TDF_Label aVariableLabel3 = + aDocument->GetData()->Root().FindChild(1, true).FindChild(3, true); + const TDF_Label aRelationLabel = + aDocument->GetData()->Root().FindChild(1, true).FindChild(13, true); + occ::handle aVariable1 = TDataStd_Variable::Set(aVariableLabel1); + occ::handle aVariable2 = TDataStd_Variable::Set(aVariableLabel2); + occ::handle aVariable3 = TDataStd_Variable::Set(aVariableLabel3); + aVariable1->Unit("N"); + aVariable2->Unit("kg"); + aVariable3->Unit("m/s2"); + aVariable1->Constant(true); + aVariable2->Constant(false); + aVariable3->Constant(false); + occ::handle aRelation = TDataStd_Relation::Set(aRelationLabel); + aRelation->SetRelation(TCollection_ExtendedString("f = m*a")); + aRelation->GetVariables().Append(aVariable1); + aRelation->GetVariables().Append(aVariable2); + aRelation->GetVariables().Append(aVariable3); + + TCollection_AsciiString aRelationEntry; + TDF_Tool::Entry(aRelationLabel, aRelationEntry); + const TCollection_AsciiString anExpectedEntries[] = {TCollection_AsciiString("0:1:1"), + TCollection_AsciiString("0:1:2"), + TCollection_AsciiString("0:1:3")}; + + occ::handle aRestored = + SaveAndOpen(anApplication, aDocument, theFormat, "draw_ocaf_relation_c8_bin"); + ASSERT_FALSE(aRestored.IsNull()); + const TDF_Label aRestoredRelationLabel = LabelByEntry(aRestored, aRelationEntry); + occ::handle aRestoredRelation; + ASSERT_TRUE(aRestoredRelationLabel.FindAttribute(TDataStd_Relation::GetID(), aRestoredRelation)); + EXPECT_EQ(aRestoredRelation->GetRelation(), TCollection_ExtendedString("f = m*a")); + int anIndex = 0; + for (NCollection_List>::Iterator anIterator( + aRestoredRelation->GetVariables()); + anIterator.More(); + anIterator.Next(), ++anIndex) + { + ASSERT_LT(anIndex, 3); + TCollection_AsciiString anActualEntry; + TDF_Tool::Entry(anIterator.Value()->Label(), anActualEntry); + EXPECT_EQ(anActualEntry, anExpectedEntries[anIndex]); + } + EXPECT_EQ(anIndex, 3); + + const TDF_Label aRestoredVariableLabel1 = LabelByEntry(aRestored, "0:1:1"); + const TDF_Label aRestoredVariableLabel2 = LabelByEntry(aRestored, "0:1:2"); + const TDF_Label aRestoredVariableLabel3 = LabelByEntry(aRestored, "0:1:3"); + occ::handle aRestoredVariable; + ASSERT_TRUE(aRestoredVariableLabel1.FindAttribute(TDataStd_Variable::GetID(), aRestoredVariable)); + EXPECT_TRUE(aRestoredVariable->IsConstant()); + EXPECT_EQ(aRestoredVariable->Unit(), TCollection_AsciiString("N")); + ASSERT_TRUE(aRestoredVariableLabel2.FindAttribute(TDataStd_Variable::GetID(), aRestoredVariable)); + EXPECT_FALSE(aRestoredVariable->IsConstant()); + EXPECT_EQ(aRestoredVariable->Unit(), TCollection_AsciiString("kg")); + ASSERT_TRUE(aRestoredVariableLabel3.FindAttribute(TDataStd_Variable::GetID(), aRestoredVariable)); + EXPECT_FALSE(aRestoredVariable->IsConstant()); + EXPECT_EQ(aRestoredVariable->Unit(), TCollection_AsciiString("m/s2")); +} + +static void RunC9(const char* theFormat) +{ + occ::handle anApplication = NewApplication(); + occ::handle aDocument = NewDocument(anApplication, theFormat); + ASSERT_FALSE(aDocument.IsNull()); + const TDF_Label aLabel = aDocument->GetData()->Root().FindChild(1, true).FindChild(1, true); + occ::handle aVariable = TDataStd_Variable::Set(aLabel); + ASSERT_FALSE(aVariable.IsNull()); + aVariable->Constant(true); + aVariable->Unit("kg/m3"); + + occ::handle aRestored = + SaveAndOpen(anApplication, aDocument, theFormat, "draw_ocaf_variable_c9_bin"); + ASSERT_FALSE(aRestored.IsNull()); + const TDF_Label aRestoredLabel = LabelByEntry(aRestored, "0:1:1"); + occ::handle aRestoredVariable; + ASSERT_TRUE(aRestoredLabel.FindAttribute(TDataStd_Variable::GetID(), aRestoredVariable)); + EXPECT_TRUE(aRestoredVariable->IsConstant()); + EXPECT_EQ(aRestoredVariable->Unit(), TCollection_AsciiString("kg/m3")); +} + +static void RunCafBug31839_1Stream() +{ + occ::handle anApplication = NewApplication(); + occ::handle aDocument = NewDocument(anApplication, "BinOcaf"); + ASSERT_FALSE(aDocument.IsNull()); + + const TDF_Label aObjectsLabel = aDocument->Main(); + aDocument->NewCommand(); + for (int anObjectIndex = 1; anObjectIndex <= 100; ++anObjectIndex) + { + const TDF_Label anObjectLabel = aObjectsLabel.FindChild(anObjectIndex, true); + for (int aSubLabelIndex = 1; aSubLabelIndex <= 10; ++aSubLabelIndex) + { + const TDF_Label aSubLabel = anObjectLabel.FindChild(aSubLabelIndex, true); + ASSERT_FALSE(TDataStd_Integer::Set(aSubLabel, 10).IsNull()); + ASSERT_FALSE(TDataStd_Real::Set(aSubLabel, 12.3).IsNull()); + } + } + aDocument->CommitCommand(); + + std::stringstream aStream; + SaveDocumentStream(anApplication, aDocument, aStream); + anApplication->Close(aDocument); + + occ::handle aFullDocument = OpenDocumentStream(anApplication, aStream); + ASSERT_FALSE(aFullDocument.IsNull()); + const TDF_Label aFullLabel = LabelByEntry(aFullDocument, "0:1:1:1"); + ASSERT_FALSE(aFullLabel.IsNull()); + occ::handle anInteger; + occ::handle aReal; + ASSERT_TRUE(aFullLabel.FindAttribute(TDataStd_Integer::GetID(), anInteger)); + ASSERT_TRUE(aFullLabel.FindAttribute(TDataStd_Real::GetID(), aReal)); + EXPECT_EQ(anInteger->Get(), 10); + EXPECT_DOUBLE_EQ(aReal->Get(), 12.3); + anApplication->Close(aFullDocument); + + occ::handle aSkipInteger = new PCDM_ReaderFilter; + aSkipInteger->AddSkipped("TDataStd_Integer"); + occ::handle aPartialDocument; + ASSERT_EQ(OpenDocumentStream(anApplication, aStream, aPartialDocument, aSkipInteger), PCDM_RS_OK); + ASSERT_FALSE(aPartialDocument.IsNull()); + const TDF_Label aFirstSubLabel = LabelByEntry(aPartialDocument, "0:1:1:1"); + ASSERT_FALSE(aFirstSubLabel.IsNull()); + anInteger.Nullify(); + aReal.Nullify(); + EXPECT_FALSE(aFirstSubLabel.FindAttribute(TDataStd_Integer::GetID(), anInteger)); + ASSERT_TRUE(aFirstSubLabel.FindAttribute(TDataStd_Real::GetID(), aReal)); + EXPECT_DOUBLE_EQ(aReal->Get(), 12.3); + + occ::handle aReadOneInteger = + new PCDM_ReaderFilter(PCDM_ReaderFilter::AppendMode_Protect); + aReadOneInteger->AddPath("0:1:1:1"); + ASSERT_EQ(OpenDocumentStream(anApplication, aStream, aPartialDocument, aReadOneInteger), + PCDM_RS_OK); + anInteger.Nullify(); + aReal.Nullify(); + ASSERT_TRUE(aFirstSubLabel.FindAttribute(TDataStd_Integer::GetID(), anInteger)); + ASSERT_TRUE(aFirstSubLabel.FindAttribute(TDataStd_Real::GetID(), aReal)); + EXPECT_EQ(anInteger->Get(), 10); + EXPECT_DOUBLE_EQ(aReal->Get(), 12.3); + + const TDF_Label aTenthSubLabel = LabelByEntry(aPartialDocument, "0:1:1:10"); + ASSERT_FALSE(aTenthSubLabel.IsNull()); + anInteger.Nullify(); + aReal.Nullify(); + EXPECT_FALSE(aTenthSubLabel.FindAttribute(TDataStd_Integer::GetID(), anInteger)); + ASSERT_TRUE(aTenthSubLabel.FindAttribute(TDataStd_Real::GetID(), aReal)); + EXPECT_DOUBLE_EQ(aReal->Get(), 12.3); + + occ::handle aReadFirstObject = + new PCDM_ReaderFilter(PCDM_ReaderFilter::AppendMode_Protect); + aReadFirstObject->AddPath("0:1:1"); + ASSERT_EQ(OpenDocumentStream(anApplication, aStream, aPartialDocument, aReadFirstObject), + PCDM_RS_OK); + anInteger.Nullify(); + ASSERT_TRUE(aTenthSubLabel.FindAttribute(TDataStd_Integer::GetID(), anInteger)); + EXPECT_EQ(anInteger->Get(), 10); + const TDF_Label aSecondObjectSubLabel = LabelByEntry(aPartialDocument, "0:1:2:5"); + ASSERT_FALSE(aSecondObjectSubLabel.IsNull()); + anInteger.Nullify(); + aReal.Nullify(); + EXPECT_FALSE(aSecondObjectSubLabel.FindAttribute(TDataStd_Integer::GetID(), anInteger)); + ASSERT_TRUE(aSecondObjectSubLabel.FindAttribute(TDataStd_Real::GetID(), aReal)); + EXPECT_DOUBLE_EQ(aReal->Get(), 12.3); + + const TDF_Label aChangedIntegerLabel = LabelByEntry(aPartialDocument, "0:1:1:5"); + const TDF_Label aChangedRealLabel = LabelByEntry(aPartialDocument, "0:1:1:7"); + ASSERT_FALSE(TDataStd_Integer::Set(aChangedIntegerLabel, 21).IsNull()); + ASSERT_FALSE(TDataStd_Real::Set(aChangedRealLabel, 32.1).IsNull()); + + occ::handle anOverwrite = + new PCDM_ReaderFilter(PCDM_ReaderFilter::AppendMode_Overwrite); + anOverwrite->AddPath("0:1:1"); + ASSERT_EQ(OpenDocumentStream(anApplication, aStream, aPartialDocument, anOverwrite), PCDM_RS_OK); + ASSERT_TRUE(aChangedIntegerLabel.FindAttribute(TDataStd_Integer::GetID(), anInteger)); + ASSERT_TRUE(aChangedRealLabel.FindAttribute(TDataStd_Real::GetID(), aReal)); + EXPECT_EQ(anInteger->Get(), 10); + EXPECT_DOUBLE_EQ(aReal->Get(), 12.3); + + ASSERT_FALSE(TDataStd_Integer::Set(aChangedIntegerLabel, 21).IsNull()); + ASSERT_FALSE(TDataStd_Real::Set(aChangedRealLabel, 32.1).IsNull()); + occ::handle anAppend = + new PCDM_ReaderFilter(PCDM_ReaderFilter::AppendMode_Protect); + anAppend->AddPath("0:1:1"); + ASSERT_EQ(OpenDocumentStream(anApplication, aStream, aPartialDocument, anAppend), PCDM_RS_OK); + ASSERT_TRUE(aChangedIntegerLabel.FindAttribute(TDataStd_Integer::GetID(), anInteger)); + ASSERT_TRUE(aChangedRealLabel.FindAttribute(TDataStd_Real::GetID(), aReal)); + EXPECT_EQ(anInteger->Get(), 21); + EXPECT_DOUBLE_EQ(aReal->Get(), 32.1); + anApplication->Close(aPartialDocument); +} + +static void RunCafBug31839_2Stream() +{ + occ::handle anApplication = NewApplication(); + occ::handle aDocument = NewDocument(anApplication, "BinOcaf"); + ASSERT_FALSE(aDocument.IsNull()); + + const TopoDS_Shape aBox = BRepPrimAPI_MakeBox(1.0, 2.0, 3.0).Shape(); + NCollection_Array1 aFaces(1, 6); + int aFaceIndex = 1; + for (TopExp_Explorer anExplorer(aBox, TopAbs_FACE); anExplorer.More(); anExplorer.Next()) + { + ASSERT_LE(aFaceIndex, 6); + aFaces.SetValue(aFaceIndex++, anExplorer.Current()); + } + ASSERT_EQ(aFaceIndex, 7); + + const TDF_Label aBoxLabel = aDocument->Main(); + aDocument->NewCommand(); + SetShape(aBoxLabel, aBox); + for (int anIndex = 1; anIndex <= 6; ++anIndex) + { + SetShape(aBoxLabel.FindChild(anIndex, true), aFaces.Value(anIndex)); + } + aDocument->CommitCommand(); + + std::stringstream aStream; + SaveDocumentStream(anApplication, aDocument, aStream); + anApplication->Close(aDocument); + + occ::handle aSkipShapes = new PCDM_ReaderFilter; + aSkipShapes->AddSkipped("TNaming_NamedShape"); + occ::handle aRestored; + const PCDM_ReaderStatus aSkipStatus = + OpenDocumentStream(anApplication, aStream, aRestored, aSkipShapes); + // BinOcaf reports a generic driver failure when the filter rejects every attribute; + // DRAW ignores this status and validates the resulting document contents instead. + EXPECT_TRUE(aSkipStatus == PCDM_RS_OK || aSkipStatus == PCDM_RS_DriverFailure); + ASSERT_FALSE(aRestored.IsNull()); + const TDF_Label aSkippedBoxLabel = LabelByEntry(aRestored, "0:1"); + const TDF_Label aSkippedFace1 = LabelByEntry(aRestored, "0:1:1"); + if (!aSkippedBoxLabel.IsNull()) + { + EXPECT_TRUE(ShapeOf(aSkippedBoxLabel).IsNull()); + } + if (!aSkippedFace1.IsNull()) + { + EXPECT_TRUE(ShapeOf(aSkippedFace1).IsNull()); + } + + occ::handle aReadFirstFace = + new PCDM_ReaderFilter(PCDM_ReaderFilter::AppendMode_Protect); + aReadFirstFace->AddPath("0:1:1"); + ASSERT_EQ(OpenDocumentStream(anApplication, aStream, aRestored, aReadFirstFace), PCDM_RS_OK); + const TDF_Label aRestoredBoxLabel = LabelByEntry(aRestored, "0:1"); + const TDF_Label aRestoredFace1 = LabelByEntry(aRestored, "0:1:1"); + ASSERT_FALSE(aRestoredBoxLabel.IsNull()); + ASSERT_FALSE(aRestoredFace1.IsNull()); + EXPECT_TRUE(ShapeOf(aRestoredBoxLabel).IsNull()); + const TopoDS_Shape aRestoredFace = ShapeOf(aRestoredFace1); + ASSERT_FALSE(aRestoredFace.IsNull()); + EXPECT_TRUE(ShapeOf(LabelByEntry(aRestored, "0:1:2")).IsNull()); + + occ::handle anOverwriteShapes = + new PCDM_ReaderFilter(PCDM_ReaderFilter::AppendMode_Overwrite); + ASSERT_EQ(OpenDocumentStream(anApplication, aStream, aRestored, anOverwriteShapes), PCDM_RS_OK); + const TopoDS_Shape aRestoredBox = ShapeOf(aRestoredBoxLabel); + const TopoDS_Shape aRestoredFace1AfterOverwrite = ShapeOf(aRestoredFace1); + ASSERT_FALSE(aRestoredBox.IsNull()); + ASSERT_FALSE(aRestoredFace1AfterOverwrite.IsNull()); + ExpectBoxBounds(aRestoredBox, 0.0, 0.0, 0.0, 1.0, 2.0, 3.0); + + bool hasSharedFace = false; + for (TopExp_Explorer aBoxExplorer(aRestoredBox, TopAbs_FACE); aBoxExplorer.More(); + aBoxExplorer.Next()) + { + for (TopExp_Explorer aFaceExplorer(aRestoredFace1AfterOverwrite, TopAbs_FACE); + aFaceExplorer.More(); + aFaceExplorer.Next()) + { + if (aBoxExplorer.Current().IsSame(aFaceExplorer.Current())) + { + hasSharedFace = true; + } + } + } + EXPECT_TRUE(hasSharedFace); + anApplication->Close(aRestored); +} + +static void ExpectCafBug31918IntegerArray(const TDF_Label& theLabel) +{ + occ::handle anArray; + ASSERT_TRUE(theLabel.FindAttribute(TDataStd_IntegerArray::GetID(), anArray)); + ASSERT_FALSE(anArray.IsNull()); + EXPECT_EQ(anArray->Lower(), 0); + EXPECT_EQ(anArray->Upper(), 1000); + EXPECT_EQ(anArray->Length(), 1001); + EXPECT_EQ(anArray->Value(0), 100); + EXPECT_EQ(anArray->Value(500), 600); + EXPECT_EQ(anArray->Value(1000), 1100); +} + +static void RunCafBug31918_1Stream() +{ + occ::handle anApplication = NewApplication(); + occ::handle aDocument = NewDocument(anApplication, "BinLOcaf"); + ASSERT_FALSE(aDocument.IsNull()); + + NCollection_Array1 aValues(0, 1000); + for (int anIndex = 0; anIndex <= 1000; ++anIndex) + { + aValues.SetValue(anIndex, 100 + anIndex); + } + + aDocument->NewCommand(); + for (int aLabelIndex = 1; aLabelIndex <= 4; ++aLabelIndex) + { + for (int aSubLabelIndex = 1; aSubLabelIndex <= 100; ++aSubLabelIndex) + { + const TDF_Label aLabel = + aDocument->GetData()->Root().FindChild(aLabelIndex, true).FindChild(aSubLabelIndex, true); + occ::handle anArray = + TDataStd_IntegerArray::Set(aLabel, aValues.Lower(), aValues.Upper()); + ASSERT_FALSE(anArray.IsNull()); + for (int anIndex = aValues.Lower(); anIndex <= aValues.Upper(); ++anIndex) + { + anArray->SetValue(anIndex, aValues.Value(anIndex)); + } + ASSERT_FALSE(TDataStd_Real::Set(aLabel, 0.1).IsNull()); + } + } + aDocument->CommitCommand(); + + std::stringstream aStream; + SaveDocumentStream(anApplication, aDocument, aStream); + anApplication->Close(aDocument); + + auto ExpectOpen = [&](const occ::handle& theFilter) { + occ::handle anOpened; + EXPECT_EQ(OpenDocumentStream(anApplication, aStream, anOpened, theFilter), PCDM_RS_OK); + EXPECT_FALSE(anOpened.IsNull()); + if (!anOpened.IsNull()) + { + anApplication->Close(anOpened); + } + }; + + ExpectOpen(occ::handle()); + occ::handle aQuarterFilter = new PCDM_ReaderFilter; + aQuarterFilter->AddPath("0:2"); + ExpectOpen(aQuarterFilter); + occ::handle aFourQuarterFilter = new PCDM_ReaderFilter; + aFourQuarterFilter->AddPath("0:1"); + aFourQuarterFilter->AddPath("0:2"); + aFourQuarterFilter->AddPath("0:3"); + aFourQuarterFilter->AddPath("0:4"); + ExpectOpen(aFourQuarterFilter); + + occ::handle aNoArrayDocument; + occ::handle aNoArrayFilter = new PCDM_ReaderFilter; + aNoArrayFilter->AddSkipped("TDataStd_IntegerArray"); + aNoArrayFilter->AddPath("0:2"); + ASSERT_EQ(OpenDocumentStream(anApplication, aStream, aNoArrayDocument, aNoArrayFilter), + PCDM_RS_OK); + ASSERT_FALSE(aNoArrayDocument.IsNull()); + + const TDF_Label aQuarterLabel = LabelByEntry(aNoArrayDocument, "0:2:13"); + ASSERT_FALSE(aQuarterLabel.IsNull()); + occ::handle aReal; + occ::handle anIntegerArray; + ASSERT_TRUE(aQuarterLabel.FindAttribute(TDataStd_Real::GetID(), aReal)); + EXPECT_DOUBLE_EQ(aReal->Get(), 0.1); + EXPECT_FALSE(aQuarterLabel.FindAttribute(TDataStd_IntegerArray::GetID(), anIntegerArray)); + + const TDF_Label aFirstTreeLabel = LabelByEntry(aNoArrayDocument, "0:1:1:13"); + const TDF_Label aThirdTreeLabel = LabelByEntry(aNoArrayDocument, "0:1:3:14"); + const TDF_Label aFourthTreeLabel = LabelByEntry(aNoArrayDocument, "0:1:4:1"); + if (!aFirstTreeLabel.IsNull()) + { + EXPECT_FALSE(aFirstTreeLabel.FindAttribute(TDataStd_Real::GetID(), aReal)); + } + if (!aThirdTreeLabel.IsNull()) + { + EXPECT_FALSE(aThirdTreeLabel.FindAttribute(TDataStd_Real::GetID(), aReal)); + } + if (!aFourthTreeLabel.IsNull()) + { + EXPECT_FALSE(aFourthTreeLabel.FindAttribute(TDataStd_Real::GetID(), aReal)); + } + + occ::handle anAppendArrays = + new PCDM_ReaderFilter(PCDM_ReaderFilter::AppendMode_Protect); + anAppendArrays->AddRead("TDataStd_IntegerArray"); + anAppendArrays->AddPath("0:2"); + anAppendArrays->AddPath("0:3"); + ASSERT_EQ(OpenDocumentStream(anApplication, aStream, aNoArrayDocument, anAppendArrays), + PCDM_RS_OK); + ASSERT_TRUE(aQuarterLabel.FindAttribute(TDataStd_Real::GetID(), aReal)); + EXPECT_DOUBLE_EQ(aReal->Get(), 0.1); + ExpectCafBug31918IntegerArray(aQuarterLabel); + const TDF_Label aThirdQuarterLabel = LabelByEntry(aNoArrayDocument, "0:3:1"); + ASSERT_FALSE(aThirdQuarterLabel.IsNull()); + ExpectCafBug31918IntegerArray(aThirdQuarterLabel); + + anIntegerArray.Nullify(); + if (!aFirstTreeLabel.IsNull()) + { + EXPECT_FALSE(aFirstTreeLabel.FindAttribute(TDataStd_IntegerArray::GetID(), anIntegerArray)); + } + if (!aFourthTreeLabel.IsNull()) + { + EXPECT_FALSE(aFourthTreeLabel.FindAttribute(TDataStd_IntegerArray::GetID(), anIntegerArray)); + } + anApplication->Close(aNoArrayDocument); +} + +static void RunCafBasicY1Stream() +{ + occ::handle anApplication = NewApplication(); + occ::handle aDocument = NewDocument(anApplication, "BinOcaf"); + ASSERT_FALSE(aDocument.IsNull()); + + const TDF_Label aParent = aDocument->Main(); + aParent.FindChild(1, true); + const TDF_Label aValueLabel = aParent.FindChild(2, true); + aParent.FindChild(3, true); + ASSERT_FALSE(TDataStd_Integer::Set(aValueLabel, 321).IsNull()); + ASSERT_FALSE(TDataStd_Real::Set(aValueLabel, 871.33).IsNull()); + + aDocument->SetEmptyLabelsSavingMode(true); + std::stringstream aStreamWithEmptyLabels; + SaveDocumentStream(anApplication, aDocument, aStreamWithEmptyLabels); + + aDocument->SetEmptyLabelsSavingMode(false); + std::stringstream aStreamWithoutEmptyLabels; + SaveDocumentStream(anApplication, aDocument, aStreamWithoutEmptyLabels); + anApplication->Close(aDocument); + + occ::handle aRestoredWithEmptyLabels = + OpenDocumentStream(anApplication, aStreamWithEmptyLabels); + occ::handle aRestoredWithoutEmptyLabels = + OpenDocumentStream(anApplication, aStreamWithoutEmptyLabels); + ASSERT_FALSE(aRestoredWithEmptyLabels.IsNull()); + ASSERT_FALSE(aRestoredWithoutEmptyLabels.IsNull()); + + const TDF_Label aParentWithEmptyLabels = aRestoredWithEmptyLabels->Main(); + const TDF_Label aParentWithoutEmptyLabels = aRestoredWithoutEmptyLabels->Main(); + EXPECT_EQ(aParentWithEmptyLabels.NbChildren(), 3); + EXPECT_EQ(aParentWithoutEmptyLabels.NbChildren(), 1); + + occ::handle anInteger; + occ::handle aReal; + const TDF_Label aRestoredValueWithEmptyLabels = aParentWithEmptyLabels.FindChild(2, false); + ASSERT_TRUE(aRestoredValueWithEmptyLabels.FindAttribute(TDataStd_Integer::GetID(), anInteger)); + ASSERT_TRUE(aRestoredValueWithEmptyLabels.FindAttribute(TDataStd_Real::GetID(), aReal)); + EXPECT_EQ(anInteger->Get(), 321); + EXPECT_DOUBLE_EQ(aReal->Get(), 871.33); + + const TDF_Label aRestoredValueWithoutEmptyLabels = aParentWithoutEmptyLabels.FindChild(2, false); + ASSERT_TRUE(aRestoredValueWithoutEmptyLabels.FindAttribute(TDataStd_Integer::GetID(), anInteger)); + ASSERT_TRUE(aRestoredValueWithoutEmptyLabels.FindAttribute(TDataStd_Real::GetID(), aReal)); + EXPECT_EQ(anInteger->Get(), 321); + EXPECT_DOUBLE_EQ(aReal->Get(), 871.33); + + anApplication->Close(aRestoredWithEmptyLabels); + anApplication->Close(aRestoredWithoutEmptyLabels); +} + +// bugs/caf/bug9746: BinOcaf stream persistence keeps multi-level naming +// selections, including the integer-array naming driver regression. +static void RunCafBug9746Stream() +{ + occ::handle anApplication = NewApplication(); + occ::handle aDocument = NewDocument(anApplication, "BinOcaf"); + ASSERT_FALSE(aDocument.IsNull()); + + gp_Trsf aBoxTranslation; + aBoxTranslation.SetTranslation(gp_Vec(35.0, 1.0, 1.0)); + const TopoDS_Shape aBox = + BRepPrimAPI_MakeBox(130.0, 111.0, 145.0).Shape().Moved(TopLoc_Location(aBoxTranslation)); + const TopoDS_Shape aCylinderBase = + BRepPrimAPI_MakeCylinder(50.0, 120.0, 230.0 * M_PI / 180.0).Shape(); + gp_Trsf aCylinderTranslation; + aCylinderTranslation.SetTranslation(gp_Vec(1.0, 1.0, 75.0)); + const TopoDS_Shape aCylinder = aCylinderBase.Moved(TopLoc_Location(aCylinderTranslation)); + ASSERT_EQ(aBox.ShapeType(), TopAbs_SOLID); + ASSERT_EQ(aCylinder.ShapeType(), TopAbs_SOLID); + + TopoDS_Shape aBoxFaces[8]; + TopoDS_Shape aBoxEdges[24]; + TopoDS_Shape aBoxVertices[16]; + ASSERT_EQ(CollectUniqueSubShapes(aBox, TopAbs_FACE, aBoxFaces, 8), 6); + ASSERT_EQ(CollectUniqueSubShapes(aBox, TopAbs_EDGE, aBoxEdges, 24), 12); + ASSERT_EQ(CollectUniqueSubShapes(aBox, TopAbs_VERTEX, aBoxVertices, 16), 8); + + TopoDS_Shape aCylinderFaces[8]; + TopoDS_Shape aCylinderVertices[16]; + const int aCylinderFaceCount = CollectUniqueSubShapes(aCylinder, TopAbs_FACE, aCylinderFaces, 8); + const int aCylinderVertexCount = + CollectUniqueSubShapes(aCylinder, TopAbs_VERTEX, aCylinderVertices, 16); + ASSERT_GE(aCylinderFaceCount, 3); + ASSERT_GE(aCylinderVertexCount, 3); + + const TDF_Label aRoot = aDocument->GetData()->Root(); + const TDF_Label aBoxLabel = aRoot.FindChild(2, true); + const TDF_Label aCylinderLabel = aRoot.FindChild(3, true); + DNaming::LoadImportedShape(aBoxLabel, aBox); + DNaming::LoadImportedShape(aCylinderLabel, aCylinder); + ASSERT_FALSE(TDataStd_Name::Set(aBoxLabel, TCollection_ExtendedString("Box1", true)).IsNull()); + ASSERT_FALSE( + TDataStd_Name::Set(aCylinderLabel, TCollection_ExtendedString("Cylinder", true)).IsNull()); + + const TDF_Label aBoxSelectionRoot = aRoot.FindChild(4, true); + for (int aFaceIndex = 0; aFaceIndex < 6; ++aFaceIndex) + { + SelectImportedShape(aBoxSelectionRoot.FindChild(aFaceIndex + 1, true), + aBoxFaces[aFaceIndex], + aBox); + } + SelectImportedShape(aBoxSelectionRoot.FindChild(10, true), aBoxEdges[0], aBox); + SelectImportedShape(aBoxSelectionRoot.FindChild(11, true), aBoxEdges[2], aBox); + SelectImportedShape(aBoxSelectionRoot.FindChild(21, true), aBoxVertices[2], aBox); + SelectImportedShape(aBoxSelectionRoot.FindChild(22, true), aBoxVertices[4], aBox); + + const TDF_Label aCylinderSelectionRoot = aRoot.FindChild(5, true); + SelectImportedShape(aCylinderSelectionRoot.FindChild(1, true), aCylinderFaces[0], aCylinder); + SelectImportedShape(aCylinderSelectionRoot.FindChild(2, true), aCylinderFaces[1], aCylinder); + SelectImportedShape(aCylinderSelectionRoot.FindChild(10, true), aCylinderVertices[0], aCylinder); + SelectImportedShape(aCylinderSelectionRoot.FindChild(11, true), aCylinderVertices[1], aCylinder); + SelectImportedShape(aCylinderSelectionRoot.FindChild(12, true), aCylinderVertices[2], aCylinder); + + std::stringstream aStream; + SaveDocumentStream(anApplication, aDocument, aStream); + anApplication->Close(aDocument); + occ::handle aRestored = OpenDocumentStream(anApplication, aStream); + ASSERT_FALSE(aRestored.IsNull()); + + const TDF_Label aRestoredRoot = aRestored->GetData()->Root(); + const TDF_Label aRestoredBoxLabel = aRestoredRoot.FindChild(2, false); + const TDF_Label aRestoredCylinderLabel = aRestoredRoot.FindChild(3, false); + ASSERT_FALSE(aRestoredBoxLabel.IsNull()); + ASSERT_FALSE(aRestoredCylinderLabel.IsNull()); + const TopoDS_Shape aRestoredBox = ShapeOf(aRestoredBoxLabel); + const TopoDS_Shape aRestoredCylinder = ShapeOf(aRestoredCylinderLabel); + ASSERT_FALSE(aRestoredBox.IsNull()); + ASSERT_FALSE(aRestoredCylinder.IsNull()); + ExpectBoxBounds(aRestoredBox, 35.0, 1.0, 1.0, 165.0, 112.0, 146.0); + + TopoDS_Shape aRestoredBoxFaces[8]; + TopoDS_Shape aRestoredBoxEdges[24]; + TopoDS_Shape aRestoredBoxVertices[16]; + ASSERT_EQ(CollectUniqueSubShapes(aRestoredBox, TopAbs_FACE, aRestoredBoxFaces, 8), 6); + ASSERT_EQ(CollectUniqueSubShapes(aRestoredBox, TopAbs_EDGE, aRestoredBoxEdges, 24), 12); + ASSERT_EQ(CollectUniqueSubShapes(aRestoredBox, TopAbs_VERTEX, aRestoredBoxVertices, 16), 8); + + TopoDS_Shape aRestoredCylinderFaces[8]; + TopoDS_Shape aRestoredCylinderVertices[16]; + ASSERT_EQ(CollectUniqueSubShapes(aRestoredCylinder, TopAbs_FACE, aRestoredCylinderFaces, 8), + aCylinderFaceCount); + ASSERT_EQ(CollectUniqueSubShapes(aRestoredCylinder, TopAbs_VERTEX, aRestoredCylinderVertices, 16), + aCylinderVertexCount); + + const TDF_Label aRestoredBoxSelectionRoot = aRestoredRoot.FindChild(4, false); + const TDF_Label aRestoredCylinderSelectionRoot = aRestoredRoot.FindChild(5, false); + ASSERT_FALSE(aRestoredBoxSelectionRoot.IsNull()); + ASSERT_FALSE(aRestoredCylinderSelectionRoot.IsNull()); + for (int aFaceIndex = 0; aFaceIndex < 6; ++aFaceIndex) + { + EXPECT_TRUE(ShapeOf(aRestoredBoxSelectionRoot.FindChild(aFaceIndex + 1, false)) + .IsSame(aRestoredBoxFaces[aFaceIndex])); + } + EXPECT_TRUE(ShapeOf(aRestoredBoxSelectionRoot.FindChild(10, false)).IsSame(aRestoredBoxEdges[0])); + EXPECT_TRUE(ShapeOf(aRestoredBoxSelectionRoot.FindChild(11, false)).IsSame(aRestoredBoxEdges[2])); + EXPECT_TRUE( + ShapeOf(aRestoredBoxSelectionRoot.FindChild(21, false)).IsSame(aRestoredBoxVertices[2])); + EXPECT_TRUE( + ShapeOf(aRestoredBoxSelectionRoot.FindChild(22, false)).IsSame(aRestoredBoxVertices[4])); + EXPECT_TRUE( + ShapeOf(aRestoredCylinderSelectionRoot.FindChild(1, false)).IsSame(aRestoredCylinderFaces[0])); + EXPECT_TRUE( + ShapeOf(aRestoredCylinderSelectionRoot.FindChild(2, false)).IsSame(aRestoredCylinderFaces[1])); + EXPECT_TRUE(ShapeOf(aRestoredCylinderSelectionRoot.FindChild(10, false)) + .IsSame(aRestoredCylinderVertices[0])); + EXPECT_TRUE(ShapeOf(aRestoredCylinderSelectionRoot.FindChild(11, false)) + .IsSame(aRestoredCylinderVertices[1])); + EXPECT_TRUE(ShapeOf(aRestoredCylinderSelectionRoot.FindChild(12, false)) + .IsSame(aRestoredCylinderVertices[2])); + + const TDF_Label aCylSelection10 = aRestoredCylinderSelectionRoot.FindChild(10, false); + const TDF_Label aCylSelection11 = aRestoredCylinderSelectionRoot.FindChild(11, false); + const TDF_Label aCylSelection12 = aRestoredCylinderSelectionRoot.FindChild(12, false); + const TDF_Label aCylSelection10Child = aCylSelection10.FindChild(1, false); + const TDF_Label aCylSelection11Child = aCylSelection11.FindChild(1, false); + const TDF_Label aCylSelection12Child = aCylSelection12.FindChild(1, false); + ASSERT_FALSE(aCylSelection10Child.IsNull()); + ASSERT_FALSE(aCylSelection11Child.IsNull()); + ASSERT_FALSE(aCylSelection12Child.IsNull()); + + const TDF_Label aCylinderChild1 = aRestoredCylinderLabel.FindChild(1, false); + const TDF_Label aCylinderChild2 = aRestoredCylinderLabel.FindChild(2, false); + const TDF_Label aCylinderChild3 = aRestoredCylinderLabel.FindChild(3, false); + const TDF_Label aCylinderChild5 = aRestoredCylinderLabel.FindChild(5, false); + ASSERT_FALSE(aCylinderChild1.IsNull()); + ASSERT_FALSE(aCylinderChild2.IsNull()); + ASSERT_FALSE(aCylinderChild3.IsNull()); + ASSERT_FALSE(aCylinderChild5.IsNull()); + const TDF_Label aIntersectionArguments[] = {aCylinderChild5, aCylinderChild1, aCylinderChild2}; + const TDF_Label aVertexArguments[] = {aCylinderChild3, aCylinderChild5, aCylinderChild1}; + ExpectNamingSelection(aCylSelection10, TNaming_IDENTITY, TopAbs_VERTEX, &aCylSelection10Child, 1); + ExpectNamingSelection(aCylSelection10Child, + TNaming_INTERSECTION, + TopAbs_VERTEX, + aIntersectionArguments, + 3); + ExpectNamingSelection(aCylSelection11, TNaming_IDENTITY, TopAbs_VERTEX, &aCylSelection11Child, 1); + ExpectNamingSelection(aCylSelection12, TNaming_IDENTITY, TopAbs_VERTEX, &aCylSelection12Child, 1); + ExpectNamingSelection(aCylSelection12Child, + TNaming_INTERSECTION, + TopAbs_VERTEX, + aVertexArguments, + 3); + + anApplication->Close(aRestored); +} +} // namespace + +// xml/data/ocaf/B7: a linked named shape survives XML and binary OCAF storage. +TEST(TDocStd_Storage_Test, Xml_B7_CopyWithLink) +{ + RunB7("XmlOcaf"); +} + +TEST(TDocStd_Storage_Test, Cbf_B7_CopyWithLink) +{ + RunB7("BinOcaf"); +} + +// xml/data/ocaf/C2: a constraint and its shape/value references survive storage. +TEST(TDocStd_Storage_Test, Xml_C2_Constraint) +{ + RunC2("XmlOcaf"); +} + +TEST(TDocStd_Storage_Test, Cbf_C2_Constraint) +{ + RunC2("BinOcaf"); +} + +// xml/data/ocaf/C3: the TDataXtd_Geometry type survives storage. +TEST(TDocStd_Storage_Test, Xml_C3_GeometryType) +{ + RunC3("XmlOcaf"); +} + +TEST(TDocStd_Storage_Test, Cbf_C3_GeometryType) +{ + RunC3("BinOcaf"); +} + +// xml/data/ocaf/C4: a selected shape and its naming survive storage. +TEST(TDocStd_Storage_Test, Xml_C4_Selection) +{ + RunC4("XmlOcaf"); +} + +TEST(TDocStd_Storage_Test, Cbf_C4_Selection) +{ + RunC4("BinOcaf"); +} + +// xml/data/ocaf/C5: pattern references and scalar parameters survive storage. +TEST(TDocStd_Storage_Test, Xml_C5_Pattern) +{ + RunC5("XmlOcaf"); +} + +TEST(TDocStd_Storage_Test, Cbf_C5_Pattern) +{ + RunC5("BinOcaf"); +} + +// xml/data/ocaf/C7: a position survives storage. +TEST(TDocStd_Storage_Test, Xml_C7_Position) +{ + RunC7("XmlOcaf"); +} + +TEST(TDocStd_Storage_Test, Cbf_C7_Position) +{ + RunC7("BinOcaf"); +} + +// xml/data/ocaf/D2: references to labels with large tags survive storage. +TEST(TDocStd_Storage_Test, Xml_D2_ReferenceChain) +{ + RunD2("XmlOcaf"); +} + +TEST(TDocStd_Storage_Test, Cbf_D2_ReferenceChain) +{ + RunD2("BinOcaf"); +} + +// xml/data/ocaf/D3: relation variables, units, and flags survive storage. +TEST(TDocStd_Storage_Test, Xml_D3_Relation) +{ + RunD3("XmlOcaf"); +} + +TEST(TDocStd_Storage_Test, Cbf_D3_Relation) +{ + RunD3("BinOcaf"); +} + +// xml/data/ocaf/A1-A9: binary OCAF preserves scalar, array, and geometry attributes. +TEST(TDocStd_Storage_Test, Cbf_A1_Integer) +{ + RunA1("BinOcaf"); +} + +TEST(TDocStd_Storage_Test, Cbf_A2_Real) +{ + RunA2("BinOcaf"); +} + +TEST(TDocStd_Storage_Test, Cbf_A3_RealArray) +{ + RunA3("BinOcaf"); +} + +TEST(TDocStd_Storage_Test, Cbf_A4_IntegerArray) +{ + RunA4("BinOcaf"); +} + +TEST(TDocStd_Storage_Test, Cbf_A5_Name) +{ + RunA5("BinOcaf"); +} + +TEST(TDocStd_Storage_Test, Cbf_A6_Comment) +{ + RunA6("BinOcaf"); +} + +TEST(TDocStd_Storage_Test, Cbf_A7_Point) +{ + RunA7("BinOcaf"); +} + +TEST(TDocStd_Storage_Test, Cbf_A8_Axis) +{ + RunA8("BinOcaf"); +} + +TEST(TDocStd_Storage_Test, Cbf_A9_Plane) +{ + RunA9("BinOcaf"); +} + +// xml/data/ocaf/B1-B5, B8-B9: binary OCAF preserves user, shape, tree, +// and directory attributes. +TEST(TDocStd_Storage_Test, Cbf_B1_UserAttribute) +{ + RunB1("BinOcaf"); +} + +TEST(TDocStd_Storage_Test, Cbf_B2_TwoUserAttributes) +{ + RunB2("BinOcaf"); +} + +TEST(TDocStd_Storage_Test, Cbf_B3_NamedShape) +{ + RunB3("BinOcaf"); +} + +TEST(TDocStd_Storage_Test, Cbf_B4_ReferenceChain) +{ + RunB4("BinOcaf"); +} + +TEST(TDocStd_Storage_Test, Cbf_B5_NamedShapeAfterTransaction) +{ + RunB5("BinOcaf"); +} + +TEST(TDocStd_Storage_Test, Cbf_B8_TagSource) +{ + RunB8("BinOcaf"); +} + +TEST(TDocStd_Storage_Test, Cbf_B9_Directory) +{ + RunB9("BinOcaf"); +} + +// xml/data/ocaf/C1, C6, C8-C9: binary OCAF preserves tree and function data, +// relations, and variables. +TEST(TDocStd_Storage_Test, Cbf_C1_TreeNodeChildren) +{ + RunC1("BinOcaf"); +} + +TEST(TDocStd_Storage_Test, Cbf_C6_Function) +{ + RunC6("BinOcaf"); +} + +TEST(TDocStd_Storage_Test, Cbf_C8_Relation) +{ + RunC8("BinOcaf"); +} + +TEST(TDocStd_Storage_Test, Cbf_C9_Variable) +{ + RunC9("BinOcaf"); +} + +// xml/data/ocaf/D1, D4-D6: binary OCAF preserves names and one-element arrays. +TEST(TDocStd_Storage_Test, Cbf_D1_SpecialNames) +{ + RunD1("BinOcaf"); +} + +TEST(TDocStd_Storage_Test, Cbf_D4_SingleIntegerArray) +{ + RunD4("BinOcaf"); +} + +TEST(TDocStd_Storage_Test, Cbf_D5_SingleRealArray) +{ + RunD5("BinOcaf"); +} + +TEST(TDocStd_Storage_Test, Cbf_D6_LeadingZeroName) +{ + RunD6("BinOcaf"); +} + +// caf/basic/A3: a default TDataStd_Integer survives binary OCAF storage. +TEST(TDocStd_Storage_Test, Cbf_CafBasic_A3_Integer) +{ + RunA1("BinOcaf"); +} + +// caf/basic/A6: two user-GUID TDataStd_Integer attributes survive storage. +TEST(TDocStd_Storage_Test, Cbf_CafBasic_A6_IntegerUserGUIDs) +{ + RunBasicIntegerUserGUID("BinOcaf"); +} + +// caf/basic/A7: a default and a user-GUID integer coexist after storage. +TEST(TDocStd_Storage_Test, Cbf_CafBasic_A7_IntegerDefaultAndGUID) +{ + RunBasicIntegerDefaultAndUserGUID("BinOcaf"); +} + +// caf/basic/B3: a default TDataStd_Real survives binary OCAF storage. +TEST(TDocStd_Storage_Test, Cbf_CafBasic_B3_Real) +{ + RunA2("BinOcaf"); +} + +// caf/basic/B6: two user-GUID TDataStd_Real attributes survive storage. +TEST(TDocStd_Storage_Test, Cbf_CafBasic_B6_RealUserGUIDs) +{ + RunBasicRealUserGUID("BinOcaf"); +} + +// caf/basic/B7: a default and a user-GUID real coexist after storage. +TEST(TDocStd_Storage_Test, Cbf_CafBasic_B7_RealDefaultAndGUID) +{ + RunBasicRealDefaultAndUserGUID("BinOcaf"); +} + +// caf/basic/C3: a default real array survives binary OCAF storage. +TEST(TDocStd_Storage_Test, Cbf_CafBasic_C3_RealArray) +{ + RunA3("BinOcaf"); +} + +// caf/basic/C5: default and user-GUID real arrays survive undo/redo and storage. +TEST(TDocStd_Storage_Test, Cbf_CafBasic_C5_RealArrayDefaultAndGUID) +{ + RunBasicRealArrayDefaultAndUserGUID("BinOcaf"); +} + +// caf/basic/D3: a default integer array survives binary OCAF storage. +TEST(TDocStd_Storage_Test, Cbf_CafBasic_D3_IntegerArray) +{ + RunA4("BinOcaf"); +} + +// caf/basic/D6: default and user-GUID integer arrays survive undo/redo and storage. +TEST(TDocStd_Storage_Test, Cbf_CafBasic_D6_IntegerArrayDefaultAndGUID) +{ + RunBasicIntegerArrayDefaultAndUserGUID("BinOcaf"); +} + +// caf/basic/E3: a default TDataStd_Name survives binary OCAF storage. +TEST(TDocStd_Storage_Test, Cbf_CafBasic_E3_Name) +{ + RunA5("BinOcaf"); +} + +// caf/basic/E6: two user-GUID TDataStd_Name attributes survive storage. +TEST(TDocStd_Storage_Test, Cbf_CafBasic_E6_NameUserGUIDs) +{ + RunBasicNameDefaultAndUserGUID("BinOcaf"); +} + +// caf/basic/E7: a default and a user-GUID name coexist after storage. +TEST(TDocStd_Storage_Test, Cbf_CafBasic_E7_NameDefaultAndGUID) +{ + RunBasicNameDefaultAndUserGUIDPair("BinOcaf"); +} + +TEST(TDocStd_Storage_Test, Xml_CafBug_28425_NamedShapeOrder) +{ + RunBug28425("XmlOcaf"); +} + +TEST(TDocStd_Storage_Test, Cbf_CafBug_28425_NamedShapeOrder) +{ + RunBug28425("BinOcaf"); +} + +TEST(TDocStd_Storage_Test, Xml_CafBug_29669_UserIntegerIds) +{ + RunBug29669("XmlOcaf"); +} + +TEST(TDocStd_Storage_Test, Cbf_CafBug_29669_UserIntegerIds) +{ + RunBug29669("BinOcaf"); +} + +// caf/basic/F3: a default TDataStd_Comment survives binary OCAF storage. +TEST(TDocStd_Storage_Test, Cbf_CafBasic_F3_Comment) +{ + RunA6("BinOcaf"); +} + +// caf/basic/F4: empty attributes preserve deletion, undo/redo, and storage state. +TEST(TDocStd_Storage_Test, Cbf_CafBasic_F4_EmptyAttributes) +{ + RunBasicEmptyAttributes("BinOcaf"); +} + +// caf/basic/G3: a TDataXtd_Point survives binary OCAF storage. +TEST(TDocStd_Storage_Test, Cbf_CafBasic_G3_Point) +{ + RunA7("BinOcaf"); +} + +// caf/basic/H3: a TDataXtd_Axis survives binary OCAF storage. +TEST(TDocStd_Storage_Test, Cbf_CafBasic_H3_Axis) +{ + RunA8("BinOcaf"); +} + +// caf/basic/I3: a TDataXtd_Plane survives binary OCAF storage. +TEST(TDocStd_Storage_Test, Cbf_CafBasic_I3_Plane) +{ + RunA9("BinOcaf"); +} + +// caf/basic/J3: a TDataStd_UAttribute survives binary OCAF storage. +TEST(TDocStd_Storage_Test, Cbf_CafBasic_J3_UserAttribute) +{ + RunB1("BinOcaf"); +} + +// caf/basic/J6: two TDataStd_UAttribute identifiers survive storage. +TEST(TDocStd_Storage_Test, Cbf_CafBasic_J6_TwoUserAttributes) +{ + RunB2("BinOcaf"); +} + +// caf/basic/K3: a named box shape survives binary OCAF storage. +TEST(TDocStd_Storage_Test, Cbf_CafBasic_K3_Shape) +{ + RunB3("BinOcaf"); +} + +// caf/basic/L3: a TDF_Reference resolves to the referenced label after storage. +TEST(TDocStd_Storage_Test, Cbf_CafBasic_L3_Reference) +{ + RunBasicReference("BinOcaf"); +} + +// caf/bugs/A1: a binary OCAF stream preserves TDataStd_Integer. +TEST(TDocStd_Storage_Test, Cbf_CafBugs_A1_IntegerStream) +{ + RunA1("BinOcaf", true); +} + +// caf/bugs/A2: a binary OCAF stream preserves TDataStd_Real. +TEST(TDocStd_Storage_Test, Cbf_CafBugs_A2_RealStream) +{ + RunA2("BinOcaf", true); +} + +// caf/bugs/A3: a binary OCAF stream preserves TDataStd_RealArray bounds and values. +TEST(TDocStd_Storage_Test, Cbf_CafBugs_A3_RealArrayStream) +{ + RunA3("BinOcaf", true); +} + +// caf/bugs/A4: a binary OCAF stream preserves TDataStd_IntegerArray bounds and values. +TEST(TDocStd_Storage_Test, Cbf_CafBugs_A4_IntegerArrayStream) +{ + RunA4("BinOcaf", true); +} + +// caf/bugs/A5: a binary OCAF stream preserves TDataStd_Name. +TEST(TDocStd_Storage_Test, Cbf_CafBugs_A5_NameStream) +{ + RunA5("BinOcaf", true); +} + +// caf/bugs/A6: a binary OCAF stream preserves TDataStd_Comment. +TEST(TDocStd_Storage_Test, Cbf_CafBugs_A6_CommentStream) +{ + RunA6("BinOcaf", true); +} + +// caf/bugs/A7: a binary OCAF stream preserves TDataXtd_Point geometry. +TEST(TDocStd_Storage_Test, Cbf_CafBugs_A7_PointStream) +{ + RunA7("BinOcaf", true); +} + +// caf/bugs/A8: a binary OCAF stream preserves TDataXtd_Axis geometry. +TEST(TDocStd_Storage_Test, Cbf_CafBugs_A8_AxisStream) +{ + RunA8("BinOcaf", true); +} + +// caf/bugs/A9: a binary OCAF stream preserves TDataXtd_Plane geometry. +TEST(TDocStd_Storage_Test, Cbf_CafBugs_A9_PlaneStream) +{ + RunA9("BinOcaf", true); +} + +// caf/bugs/B1: a binary OCAF stream preserves one TDataStd_UAttribute identifier. +TEST(TDocStd_Storage_Test, Cbf_CafBugs_B1_UserAttributeStream) +{ + RunB1("BinOcaf", true); +} + +// caf/bugs/B2: a binary OCAF stream preserves two distinct UAttribute identifiers. +TEST(TDocStd_Storage_Test, Cbf_CafBugs_B2_TwoUserAttributesStream) +{ + RunB2("BinOcaf", true); +} + +// caf/bugs/B3: a binary OCAF stream preserves a named shape and its bounds. +TEST(TDocStd_Storage_Test, Cbf_CafBugs_B3_NamedShapeStream) +{ + RunB3("BinOcaf", true); +} + +// caf/bugs/B4: a binary OCAF stream preserves a TDF_Reference target. +TEST(TDocStd_Storage_Test, Cbf_CafBugs_B4_ReferenceStream) +{ + RunBasicReference("BinOcaf", true); +} + +// caf/bugs/B5: a binary OCAF stream preserves a named shape after a transaction. +TEST(TDocStd_Storage_Test, Cbf_CafBugs_B5_NamedShapeAfterTransactionStream) +{ + RunB5("BinOcaf", true); +} + +// caf/bugs/B7: a binary OCAF stream preserves a same-document CopyWithLink result. +TEST(TDocStd_Storage_Test, Cbf_CafBugs_B7_CopyWithLinkStream) +{ + RunB7("BinOcaf", true); +} + +// caf/bugs/B8: a binary OCAF stream preserves a TDF_TagSource child label and name. +TEST(TDocStd_Storage_Test, Cbf_CafBugs_B8_TagSourceStream) +{ + RunB8("BinOcaf", true); +} + +// caf/bugs/B9: a binary OCAF stream preserves a TDataStd_Directory and its name. +TEST(TDocStd_Storage_Test, Cbf_CafBugs_B9_DirectoryStream) +{ + RunB9("BinOcaf", true); +} + +// caf/bugs/C1: a binary OCAF stream preserves a root TDataStd_TreeNode. +TEST(TDocStd_Storage_Test, Cbf_CafBugs_C1_TreeNodeRootStream) +{ + RunCafBugC1Stream(); +} + +// caf/bugs/C2: a binary OCAF stream preserves TDataStd_ExtStringArray values. +TEST(TDocStd_Storage_Test, Cbf_CafBugs_C2_ExtStringArrayStream) +{ + RunCafBugC2Stream(); +} + +// caf/basic/M3: a binary OCAF stream preserves a default extended-string array. +TEST(TDocStd_Storage_Test, Cbf_CafBasic_M3_ExtStringArrayStream) +{ + RunCafBasicM3Stream(); +} + +// caf/basic/M6: binary OCAF preserves default and user-GUID extended-string arrays after undo. +TEST(TDocStd_Storage_Test, Cbf_CafBasic_M6_ExtStringArrayStream) +{ + RunCafBasicM6Stream(); +} + +// caf/basic/N6: a binary OCAF stream preserves two user-GUID ASCII-string attributes. +TEST(TDocStd_Storage_Test, Cbf_CafBasic_N6_AsciiStringStream) +{ + RunCafBasicN6Stream(); +} + +// caf/basic/N7: a binary OCAF stream preserves default and user-GUID ASCII strings. +TEST(TDocStd_Storage_Test, Cbf_CafBasic_N7_AsciiStringStream) +{ + RunCafBasicN7Stream(); +} + +// caf/basic/O6: binary OCAF preserves default and user-GUID boolean arrays after undo. +TEST(TDocStd_Storage_Test, Cbf_CafBasic_O6_BooleanArrayStream) +{ + RunCafBasicO6Stream(); +} + +// caf/basic/P6: binary OCAF preserves default and user-GUID byte arrays after undo. +TEST(TDocStd_Storage_Test, Cbf_CafBasic_P6_ByteArrayStream) +{ + RunCafBasicP6Stream(); +} + +// caf/basic/Q6: binary OCAF preserves default and user-GUID reference arrays after undo. +TEST(TDocStd_Storage_Test, Cbf_CafBasic_Q6_ReferenceArrayStream) +{ + RunCafBasicQ6Stream(); +} + +// caf/basic/R6: binary OCAF preserves default and user-GUID real lists after undo. +TEST(TDocStd_Storage_Test, Cbf_CafBasic_R6_RealListStream) +{ + RunCafBasicR6Stream(); +} + +// caf/basic/S6: binary OCAF preserves default and user-GUID integer lists after undo. +TEST(TDocStd_Storage_Test, Cbf_CafBasic_S6_IntegerListStream) +{ + RunCafBasicS6Stream(); +} + +// caf/basic/T6: binary OCAF preserves default and user-GUID extended-string lists after undo. +TEST(TDocStd_Storage_Test, Cbf_CafBasic_T6_ExtStringListStream) +{ + RunCafBasicT6Stream(); +} + +// caf/basic/U6: binary OCAF preserves default and user-GUID boolean lists after undo. +TEST(TDocStd_Storage_Test, Cbf_CafBasic_U6_BooleanListStream) +{ + RunCafBasicU6Stream(); +} + +// caf/basic/V6: binary OCAF preserves default and user-GUID reference lists after undo. +TEST(TDocStd_Storage_Test, Cbf_CafBasic_V6_ReferenceListStream) +{ + RunCafBasicV6Stream(); +} + +// caf/tree/A3: a binary OCAF stream preserves a TDF_TagSource child name. +TEST(TDocStd_Storage_Test, Cbf_CafTree_A3_TagSourceStream) +{ + RunB8("BinOcaf", true); +} + +// caf/tree/B3: a binary OCAF stream preserves a TDataStd_Directory name. +TEST(TDocStd_Storage_Test, Cbf_CafTree_B3_DirectoryStream) +{ + RunB9("BinOcaf", true); +} + +// caf/tree/C2: a binary OCAF stream preserves a root TDataStd_TreeNode label. +TEST(TDocStd_Storage_Test, Cbf_CafTree_C2_TreeNodeRootStream) +{ + RunCafBugC1Stream(); +} + +// caf/named_shape/C1: a binary OCAF stream preserves a named shape after transactions. +TEST(TDocStd_Storage_Test, Cbf_CafNamedShape_C1_Stream) +{ + RunB5("BinOcaf", true); +} + +// caf/xlink/B3: a binary OCAF stream preserves a same-document CopyWithLink shape. +TEST(TDocStd_Storage_Test, Cbf_CafXLink_B3_CopyWithLinkStream) +{ + RunB7("BinOcaf", true); +} + +// caf/basic/N1: binary OCAF streams preserve two triangulation snapshots and undo/redo state. +TEST(TDocStd_Storage_Test, Cbf_CafBasic_N1_TriangulationStream) +{ + RunCafBasicN1Stream(); +} + +// bugs/caf/bug24164_2: a binary OCAF stream preserves a six-label reference-array graph. +TEST(TDocStd_Storage_Test, Cbf_CafBug_24164_2_ReferenceArraysStream) +{ + RunCafBug24164_2Stream(); +} + +// bugs/caf/bug24164_1: a binary OCAF stream preserves a computed naming function. +TEST(TDocStd_Storage_Test, Cbf_CafBug_24164_1_FunctionStream) +{ + RunCafBug24164_1Stream(); +} + +// bugs/caf/bug158: saving an empty BinOcaf document reports a valid empty-store status. +TEST(TDocStd_Storage_Test, Cbf_CafBug_158_EmptyDocumentStreamSave) +{ + occ::handle anApplication = NewApplication(); + occ::handle aDocument = NewDocument(anApplication, "BinOcaf"); + ASSERT_FALSE(aDocument.IsNull()); + + std::stringstream aStream; + const PCDM_StoreStatus aStatus = anApplication->SaveAs(aDocument, aStream); + EXPECT_TRUE(aStatus == PCDM_SS_OK || aStatus == PCDM_SS_No_Obj); + EXPECT_NO_THROW(anApplication->Close(aDocument)); +} + +// bugs/caf/bug267_1: an empty BinOcaf document can be stored through the +// stream API and produces the same valid empty-store status as DRAW SaveAs. +TEST(TDocStd_Storage_Test, Cbf_CafBug_267_1_EmptyDocumentStreamSave) +{ + occ::handle anApplication = NewApplication(); + occ::handle aDocument = NewDocument(anApplication, "BinOcaf"); + ASSERT_FALSE(aDocument.IsNull()); + + std::stringstream aStream; + const PCDM_StoreStatus aStatus = anApplication->SaveAs(aDocument, aStream); + EXPECT_TRUE(aStatus == PCDM_SS_OK || aStatus == PCDM_SS_No_Obj); + EXPECT_FALSE(aStream.str().empty()); + EXPECT_NO_THROW(anApplication->Close(aDocument)); +} + +// bugs/caf/bug9746: naming selections and their integer-array arguments survive +// a BinOcaf stream round trip. +TEST(TDocStd_Storage_Test, Cbf_CafBug_9746_NamingSelectionsStream) +{ + RunCafBug9746Stream(); +} + +// bugs/caf/bug31839_1: BinOcaf stream filters support skipped attributes and append modes. +TEST(TDocStd_Storage_Test, Cbf_CafBug_31839_1_PartialStream) +{ + RunCafBug31839_1Stream(); +} + +// bugs/caf/bug31839_2: BinOcaf stream filters preserve shared topology in append/overwrite modes. +TEST(TDocStd_Storage_Test, Cbf_CafBug_31839_2_PartialShapeStream) +{ + RunCafBug31839_2Stream(); +} + +// bugs/caf/bug31918_1: BinLOcaf streams support fast subtree and attribute-filtered loading. +TEST(TDocStd_Storage_Test, Cbfl_CafBug_31918_1_PartialStream) +{ + RunCafBug31918_1Stream(); +} + +// caf/basic/Y1: BinOcaf streams preserve the document's empty-label saving mode. +TEST(TDocStd_Storage_Test, Cbf_CafBasic_Y1_SaveEmptyLabelsStream) +{ + RunCafBasicY1Stream(); +} + +// bugs/moddata_3/bug31136_5: StoreTriangulation updates the BinXCAF and +// BinOcaf storage-driver triangulation/normal switches consistently. The DRAW +// command is only a driver-setting command, so no document or file is needed. +TEST(TDocStd_Storage_Test, Cbf_CafBug_31136_5_StorageDriverOptions) +{ + occ::handle anApplication = new TDocStd_Application(); + BinDrivers::DefineFormat(anApplication); + BinXCAFDrivers::DefineFormat(anApplication); + + const occ::handle aXcafDriver = + occ::down_cast(anApplication->WriterFromFormat("BinXCAF")); + const occ::handle anOcafDriver = + occ::down_cast(anApplication->WriterFromFormat("BinOcaf")); + ASSERT_FALSE(aXcafDriver.IsNull()); + ASSERT_FALSE(anOcafDriver.IsNull()); + + aXcafDriver->SetWithTriangles(anApplication->MessageDriver(), true); + anOcafDriver->SetWithTriangles(anApplication->MessageDriver(), true); + aXcafDriver->SetWithNormals(anApplication->MessageDriver(), true); + anOcafDriver->SetWithNormals(anApplication->MessageDriver(), true); + EXPECT_TRUE(aXcafDriver->IsWithTriangles()); + EXPECT_TRUE(anOcafDriver->IsWithTriangles()); + EXPECT_TRUE(aXcafDriver->IsWithNormals()); + EXPECT_TRUE(anOcafDriver->IsWithNormals()); + + aXcafDriver->SetWithNormals(anApplication->MessageDriver(), false); + anOcafDriver->SetWithNormals(anApplication->MessageDriver(), false); + EXPECT_FALSE(aXcafDriver->IsWithNormals()); + EXPECT_FALSE(anOcafDriver->IsWithNormals()); + + aXcafDriver->SetWithTriangles(anApplication->MessageDriver(), false); + anOcafDriver->SetWithTriangles(anApplication->MessageDriver(), false); + EXPECT_FALSE(aXcafDriver->IsWithTriangles()); + EXPECT_FALSE(anOcafDriver->IsWithTriangles()); +} diff --git a/src/ApplicationFramework/TKXml/GTests/XmlOcaf_Storage_Test.cxx b/src/ApplicationFramework/TKXml/GTests/XmlOcaf_Storage_Test.cxx new file mode 100644 index 0000000000..da0984c970 --- /dev/null +++ b/src/ApplicationFramework/TKXml/GTests/XmlOcaf_Storage_Test.cxx @@ -0,0 +1,2356 @@ +// Copyright (c) 2026 OPEN CASCADE SAS +// +// This file is part of Open CASCADE Technology software library. +// +// This library is free software; you can redistribute it and/or modify it under +// the terms of the GNU Lesser General Public License version 2.1 as published +// by the Free Software Foundation, with special exception defined in the file +// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT +// distribution for complete text of the license and disclaimer of any warranty. +// +// Alternatively, this file may be used under the terms of Open CASCADE +// commercial license or contractual agreement. + +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +#include +#include +#include + +namespace +{ +static occ::handle NewApplication() +{ + occ::handle anApplication = new TDocStd_Application(); + XmlDrivers::DefineFormat(anApplication); + return anApplication; +} + +static const char* THE_QATEST_DOC_FORMAT = "My Proprietary Format"; + +// The DRAW regression deliberately uses an application with an explicitly +// empty resource file to verify that the XML format can still be selected. +class CustomXmlApplication : public TDocStd_Application +{ +public: + CustomXmlApplication() + { + myResources = new Resource_Manager(""); + myResources->SetResource("xml.FileFormat", THE_QATEST_DOC_FORMAT); + myResources->SetResource("My Proprietary Format.Description", "Test XML Document"); + myResources->SetResource("My Proprietary Format.FileExtension", "xml"); + } + + occ::handle ReaderFromFormat(const TCollection_ExtendedString&) override + { + return new XmlDrivers_DocumentRetrievalDriver(); + } + + occ::handle WriterFromFormat(const TCollection_ExtendedString&) override + { + return new XmlDrivers_DocumentStorageDriver("Test"); + } + + const char* ResourcesName() override { return ""; } +}; + +static TDF_Label AttributeLabel(const occ::handle& theDocument) +{ + return theDocument->GetData()->Root().FindChild(2, true); +} + +static TCollection_ExtendedString MakeTemporaryFile(OSD_Directory& theDirectory, + const char* theName, + OSD_Path& thePath) +{ + theDirectory.Path(thePath); + thePath.SetName(theName); + thePath.SetExtension(".xml"); + + TCollection_AsciiString aSystemName; + thePath.SystemName(aSystemName); + return TCollection_ExtendedString(aSystemName, true); +} + +static occ::handle SaveAndOpen( + const occ::handle& theApplication, + const occ::handle& theDocument, + const TCollection_ExtendedString& theFileName, + const OSD_Path& theFilePath) +{ + EXPECT_EQ(theApplication->SaveAs(theDocument, theFileName), PCDM_SS_OK); + + OSD_File aFile(theFilePath); + EXPECT_TRUE(aFile.Exists()); + + theApplication->Close(theDocument); + + occ::handle aRestoredDocument; + EXPECT_EQ(theApplication->Open(theFileName, aRestoredDocument), PCDM_RS_OK); + EXPECT_FALSE(aRestoredDocument.IsNull()); + + if (aFile.Exists()) + { + aFile.Remove(); + } + return aRestoredDocument; +} + +static occ::handle NewDocument( + const occ::handle& theApplication) +{ + occ::handle aDocument; + theApplication->NewDocument("XmlOcaf", aDocument); + EXPECT_FALSE(aDocument.IsNull()); + if (!aDocument.IsNull()) + { + aDocument->SetUndoLimit(100); + } + return aDocument; +} + +static occ::handle SaveNewDocument( + const occ::handle& theApplication, + const occ::handle& theDocument, + const char* theName, + OSD_Directory& theDirectory, + OSD_Path& thePath) +{ + const TCollection_ExtendedString aFileName = MakeTemporaryFile(theDirectory, theName, thePath); + theDocument->NewCommand(); + return SaveAndOpen(theApplication, theDocument, aFileName, thePath); +} + +static occ::handle SaveAndOpenStream( + const occ::handle& theApplication, + const occ::handle& theDocument) +{ + std::stringstream aStream; + theDocument->NewCommand(); + EXPECT_EQ(theApplication->SaveAs(theDocument, aStream), PCDM_SS_OK); + EXPECT_FALSE(aStream.str().empty()); + + theApplication->Close(theDocument); + aStream.seekg(0); + occ::handle aRestoredDocument; + EXPECT_EQ(theApplication->Open(aStream, aRestoredDocument), PCDM_RS_OK); + EXPECT_FALSE(aRestoredDocument.IsNull()); + return aRestoredDocument; +} + +static void SetShape(const TDF_Label& theLabel, const TopoDS_Shape& theShape) +{ + TNaming_Builder aBuilder(theLabel); + aBuilder.Generated(theShape); +} + +static TopoDS_Shape ShapeOf(const TDF_Label& theLabel) +{ + occ::handle aNamedShape; + if (!theLabel.FindAttribute(TNaming_NamedShape::GetID(), aNamedShape)) + { + return TopoDS_Shape(); + } + return TNaming_Tool::GetShape(aNamedShape); +} + +static TopoDS_Shape MakeLargeTestShape(int& theShapeNb) +{ + TopoDS_Compound aCompound; + BRep_Builder aBuilder; + aBuilder.MakeCompound(aCompound); + + occ::handle aNurbsModification = + new BRepTools_NurbsConvertModification; + TopoDS_Shape aReferenceShape = BRepPrimAPI_MakeCylinder(50.0, 100.0).Solid(); + BRepTools_Modifier aModifier(aReferenceShape, aNurbsModification); + if (aModifier.IsDone()) + { + aReferenceShape = aModifier.ModifiedShape(aReferenceShape); + } + + int aSiblingNb = 0; + for (; theShapeNb > 0; --theShapeNb) + { + TopoDS_Shape aShape; + if (++aSiblingNb <= 100) + { + aShape = BRepBuilderAPI_Copy(aReferenceShape, true).Shape(); + } + else + { + aShape = MakeLargeTestShape(theShapeNb); + } + aBuilder.Add(aCompound, aShape); + } + return aCompound; +} + +static void ExpectBoxBounds(const TopoDS_Shape& theShape, + const double theXMin, + const double theYMin, + const double theZMin, + const double theXMax, + const double theYMax, + const double theZMax) +{ + ASSERT_FALSE(theShape.IsNull()); + Bnd_Box aBounds; + BRepBndLib::Add(theShape, aBounds); + double aXMin = 0.0; + double aYMin = 0.0; + double aZMin = 0.0; + double aXMax = 0.0; + double aYMax = 0.0; + double aZMax = 0.0; + aBounds.Get(aXMin, aYMin, aZMin, aXMax, aYMax, aZMax); + EXPECT_NEAR(aXMin, theXMin, 1.0e-6); + EXPECT_NEAR(aYMin, theYMin, 1.0e-6); + EXPECT_NEAR(aZMin, theZMin, 1.0e-6); + EXPECT_NEAR(aXMax, theXMax, 1.0e-6); + EXPECT_NEAR(aYMax, theYMax, 1.0e-6); + EXPECT_NEAR(aZMax, theZMax, 1.0e-6); +} + +static TDF_Label FindOrCreatePath(const occ::handle& theDocument, + const int* theTags, + const int theNbTags) +{ + TDF_Label aLabel = theDocument->GetData()->Root(); + for (int anIndex = 0; anIndex < theNbTags; ++anIndex) + { + aLabel = aLabel.FindChild(theTags[anIndex], true); + } + return aLabel; +} + +static void RestoreAttributesAfterUndo(const occ::handle& theDocument, + const TDF_Label& theLabel) +{ + theDocument->NewCommand(); + theLabel.ForgetAllAttributes(); + theDocument->NewCommand(); + EXPECT_TRUE(theDocument->Undo()); + EXPECT_TRUE(theDocument->Redo()); + EXPECT_TRUE(theDocument->Undo()); +} + +static void AddEmptyAttribute(const TDF_Label& theLabel, const char* theTypeName) +{ + occ::handle anAttribute = TDF_DerivedAttribute::Attribute(theTypeName); + ASSERT_FALSE(anAttribute.IsNull()); + if (!anAttribute.IsNull()) + { + theLabel.AddAttribute(anAttribute); + } +} + +static bool HasAttributeType(const TDF_Label& theLabel, const occ::handle& theType) +{ + for (TDF_AttributeIterator anIterator(theLabel); anIterator.More(); anIterator.Next()) + { + if (anIterator.Value()->IsKind(theType)) + { + return true; + } + } + return false; +} + +static void ExpectBooleanArray(const occ::handle& theArray, + const bool theFirst, + const bool theSecond) +{ + ASSERT_FALSE(theArray.IsNull()); + EXPECT_EQ(theArray->Lower(), 1); + EXPECT_EQ(theArray->Upper(), 2); + EXPECT_EQ(theArray->Length(), 2); + EXPECT_EQ(theArray->Value(1), theFirst); + EXPECT_EQ(theArray->Value(2), theSecond); +} + +static void ExpectRealArray(const occ::handle& theArray, + const double theFirst, + const double theSecond) +{ + ASSERT_FALSE(theArray.IsNull()); + EXPECT_EQ(theArray->Lower(), 1); + EXPECT_EQ(theArray->Upper(), 2); + EXPECT_EQ(theArray->Length(), 2); + EXPECT_DOUBLE_EQ(theArray->Value(1), theFirst); + EXPECT_DOUBLE_EQ(theArray->Value(2), theSecond); +} + +static void ExpectIntegerArray(const occ::handle& theArray, + const int theFirst, + const int theSecond) +{ + ASSERT_FALSE(theArray.IsNull()); + EXPECT_EQ(theArray->Lower(), 1); + EXPECT_EQ(theArray->Upper(), 2); + EXPECT_EQ(theArray->Length(), 2); + EXPECT_EQ(theArray->Value(1), theFirst); + EXPECT_EQ(theArray->Value(2), theSecond); +} + +static void ExpectByteArray(const occ::handle& theArray, + const int theFirst, + const int theSecond) +{ + ASSERT_FALSE(theArray.IsNull()); + EXPECT_EQ(theArray->Lower(), 1); + EXPECT_EQ(theArray->Upper(), 2); + EXPECT_EQ(theArray->Length(), 2); + EXPECT_EQ(static_cast(theArray->Value(1)), theFirst); + EXPECT_EQ(static_cast(theArray->Value(2)), theSecond); +} + +static void ExpectExtendedArray(const occ::handle& theArray, + const int theLower, + const int theUpper, + const int theFirstIndex, + const TCollection_ExtendedString& theFirst, + const TCollection_ExtendedString& theSecond) +{ + ASSERT_FALSE(theArray.IsNull()); + EXPECT_EQ(theArray->Lower(), theLower); + EXPECT_EQ(theArray->Upper(), theUpper); + EXPECT_EQ(theArray->Length(), theUpper - theLower + 1); + EXPECT_EQ(theArray->Value(theFirstIndex), theFirst); + EXPECT_EQ(theArray->Value(theFirstIndex + 1), theSecond); +} + +static void ExpectBooleanList(const occ::handle& theList, + const bool theFirst, + const bool theSecond) +{ + ASSERT_FALSE(theList.IsNull()); + EXPECT_EQ(theList->Extent(), 2); + EXPECT_EQ(theList->First(), theFirst); + EXPECT_EQ(theList->Last(), theSecond); +} + +static void ExpectExtendedList(const occ::handle& theList, + const TCollection_ExtendedString& theFirst, + const TCollection_ExtendedString& theSecond) +{ + ASSERT_FALSE(theList.IsNull()); + EXPECT_EQ(theList->Extent(), 2); + EXPECT_EQ(theList->First(), theFirst); + EXPECT_EQ(theList->Last(), theSecond); +} + +static void ExpectIntegerList(const occ::handle& theList, + const int theFirst, + const int theSecond) +{ + ASSERT_FALSE(theList.IsNull()); + EXPECT_EQ(theList->Extent(), 2); + EXPECT_EQ(theList->First(), theFirst); + EXPECT_EQ(theList->Last(), theSecond); +} + +static void ExpectRealList(const occ::handle& theList, + const double theFirst, + const double theSecond) +{ + ASSERT_FALSE(theList.IsNull()); + EXPECT_EQ(theList->Extent(), 2); + EXPECT_DOUBLE_EQ(theList->First(), theFirst); + EXPECT_DOUBLE_EQ(theList->Last(), theSecond); +} + +static TCollection_AsciiString LabelEntry(const TDF_Label& theLabel) +{ + TCollection_AsciiString anEntry; + TDF_Tool::Entry(theLabel, anEntry); + return anEntry; +} + +static TDF_Label LabelByEntry(const occ::handle& theDocument, + const char* theEntry) +{ + TDF_Label aLabel; + TDF_Tool::Label(theDocument->GetData(), TCollection_AsciiString(theEntry), aLabel); + return aLabel; +} + +static void ExpectReferenceArray(const occ::handle& theArray, + const TCollection_AsciiString& theFirst, + const TCollection_AsciiString& theSecond) +{ + ASSERT_FALSE(theArray.IsNull()); + EXPECT_EQ(theArray->Lower(), 1); + EXPECT_EQ(theArray->Upper(), 2); + EXPECT_EQ(theArray->Length(), 2); + EXPECT_EQ(LabelEntry(theArray->Value(1)), theFirst); + EXPECT_EQ(LabelEntry(theArray->Value(2)), theSecond); +} + +static void ExpectReferenceList(const occ::handle& theList, + const TCollection_AsciiString& theFirst, + const TCollection_AsciiString& theSecond) +{ + ASSERT_FALSE(theList.IsNull()); + EXPECT_EQ(theList->Extent(), 2); + EXPECT_EQ(LabelEntry(theList->First()), theFirst); + EXPECT_EQ(LabelEntry(theList->Last()), theSecond); +} + +static occ::handle MakeTestTriangulation(const bool theDense) +{ + if (!theDense) + { + NCollection_Array1 aNodes(1, 4); + aNodes.SetValue(1, gp_Pnt(0.0, 0.0, 0.0)); + aNodes.SetValue(2, gp_Pnt(10.0, 0.0, 0.0)); + aNodes.SetValue(3, gp_Pnt(10.0, 10.0, 0.0)); + aNodes.SetValue(4, gp_Pnt(0.0, 10.0, 0.0)); + NCollection_Array1 aTriangles(1, 2); + aTriangles.SetValue(1, Poly_Triangle(1, 2, 3)); + aTriangles.SetValue(2, Poly_Triangle(1, 3, 4)); + occ::handle aResult = new Poly_Triangulation(aNodes, aTriangles); + aResult->Deflection(10.0); + return aResult; + } + + NCollection_Array1 aNodes(1, 5); + aNodes.SetValue(1, gp_Pnt(0.0, 0.0, 0.0)); + aNodes.SetValue(2, gp_Pnt(10.0, 0.0, 0.0)); + aNodes.SetValue(3, gp_Pnt(10.0, 10.0, 0.0)); + aNodes.SetValue(4, gp_Pnt(0.0, 10.0, 0.0)); + aNodes.SetValue(5, gp_Pnt(5.0, 5.0, 0.0)); + NCollection_Array1 aTriangles(1, 4); + aTriangles.SetValue(1, Poly_Triangle(1, 2, 5)); + aTriangles.SetValue(2, Poly_Triangle(2, 3, 5)); + aTriangles.SetValue(3, Poly_Triangle(3, 4, 5)); + aTriangles.SetValue(4, Poly_Triangle(4, 1, 5)); + occ::handle aResult = new Poly_Triangulation(aNodes, aTriangles); + aResult->Deflection(1.0); + return aResult; +} + +static void ExpectTriangulation(const TDF_Label& theLabel, + const occ::handle& theExpected) +{ + occ::handle anAttribute; + ASSERT_TRUE(theLabel.FindAttribute(TDataXtd_Triangulation::GetID(), anAttribute)); + ASSERT_FALSE(anAttribute.IsNull()); + ASSERT_FALSE(anAttribute->Get().IsNull()); + EXPECT_DOUBLE_EQ(anAttribute->Deflection(), theExpected->Deflection()); + EXPECT_EQ(anAttribute->NbNodes(), theExpected->NbNodes()); + EXPECT_EQ(anAttribute->NbTriangles(), theExpected->NbTriangles()); + EXPECT_EQ(anAttribute->HasUVNodes(), theExpected->HasUVNodes()); + EXPECT_EQ(anAttribute->HasNormals(), theExpected->HasNormals()); + for (int anIndex = 1; anIndex <= theExpected->NbNodes(); ++anIndex) + { + EXPECT_TRUE( + anAttribute->Node(anIndex).IsEqual(theExpected->Node(anIndex), Precision::Confusion())); + } + for (int anIndex = 1; anIndex <= theExpected->NbTriangles(); ++anIndex) + { + int anExpectedNode1 = 0; + int anExpectedNode2 = 0; + int anExpectedNode3 = 0; + int anActualNode1 = 0; + int anActualNode2 = 0; + int anActualNode3 = 0; + theExpected->Triangle(anIndex).Get(anExpectedNode1, anExpectedNode2, anExpectedNode3); + anAttribute->Triangle(anIndex).Get(anActualNode1, anActualNode2, anActualNode3); + EXPECT_EQ(anActualNode1, anExpectedNode1); + EXPECT_EQ(anActualNode2, anExpectedNode2); + EXPECT_EQ(anActualNode3, anExpectedNode3); + } +} +} // namespace + +// xml/data/ocaf/A1: TDataStd_Integer survives XML storage and retrieval. +TEST(XmlOcaf_Storage_Test, A1_Integer) +{ + occ::handle anApplication = NewApplication(); + occ::handle aDocument = NewDocument(anApplication); + ASSERT_FALSE(aDocument.IsNull()); + const TDF_Label aLabel = AttributeLabel(aDocument); + ASSERT_FALSE(TDataStd_Integer::Set(aLabel, 100).IsNull()); + + OSD_Directory aDirectory = OSD_Directory::BuildTemporary(); + OSD_Path aPath; + occ::handle aRestored = + SaveNewDocument(anApplication, aDocument, "draw_ocaf_integer", aDirectory, aPath); + ASSERT_FALSE(aRestored.IsNull()); + + occ::handle anInteger; + ASSERT_TRUE(AttributeLabel(aRestored).FindAttribute(TDataStd_Integer::GetID(), anInteger)); + EXPECT_EQ(anInteger->Get(), 100); +} + +// xml/data/ocaf/A2: TDataStd_Real survives XML storage and retrieval. +TEST(XmlOcaf_Storage_Test, A2_Real) +{ + occ::handle anApplication = NewApplication(); + occ::handle aDocument = NewDocument(anApplication); + ASSERT_FALSE(aDocument.IsNull()); + const TDF_Label aLabel = AttributeLabel(aDocument); + ASSERT_FALSE(TDataStd_Real::Set(aLabel, 100.0).IsNull()); + + OSD_Directory aDirectory = OSD_Directory::BuildTemporary(); + OSD_Path aPath; + occ::handle aRestored = + SaveNewDocument(anApplication, aDocument, "draw_ocaf_real", aDirectory, aPath); + ASSERT_FALSE(aRestored.IsNull()); + + occ::handle aReal; + ASSERT_TRUE(AttributeLabel(aRestored).FindAttribute(TDataStd_Real::GetID(), aReal)); + EXPECT_DOUBLE_EQ(aReal->Get(), 100.0); +} + +// xml/data/ocaf/A3: a two-value TDataStd_RealArray keeps its bounds and values. +TEST(XmlOcaf_Storage_Test, A3_RealArray) +{ + occ::handle anApplication = NewApplication(); + occ::handle aDocument = NewDocument(anApplication); + ASSERT_FALSE(aDocument.IsNull()); + const TDF_Label aLabel = AttributeLabel(aDocument); + occ::handle anArray = TDataStd_RealArray::Set(aLabel, 1, 2); + ASSERT_FALSE(anArray.IsNull()); + anArray->SetValue(1, 3.0); + anArray->SetValue(2, 4.0); + + OSD_Directory aDirectory = OSD_Directory::BuildTemporary(); + OSD_Path aPath; + occ::handle aRestored = + SaveNewDocument(anApplication, aDocument, "draw_ocaf_real_array", aDirectory, aPath); + ASSERT_FALSE(aRestored.IsNull()); + + occ::handle aRestoredArray; + ASSERT_TRUE(AttributeLabel(aRestored).FindAttribute(TDataStd_RealArray::GetID(), aRestoredArray)); + EXPECT_EQ(aRestoredArray->Lower(), 1); + EXPECT_EQ(aRestoredArray->Upper(), 2); + EXPECT_DOUBLE_EQ(aRestoredArray->Value(1), 3.0); + EXPECT_DOUBLE_EQ(aRestoredArray->Value(2), 4.0); +} + +// xml/data/ocaf/A4: a two-value TDataStd_IntegerArray keeps its bounds and values. +TEST(XmlOcaf_Storage_Test, A4_IntegerArray) +{ + occ::handle anApplication = NewApplication(); + occ::handle aDocument = NewDocument(anApplication); + ASSERT_FALSE(aDocument.IsNull()); + const TDF_Label aLabel = AttributeLabel(aDocument); + occ::handle anArray = TDataStd_IntegerArray::Set(aLabel, 1, 2); + ASSERT_FALSE(anArray.IsNull()); + anArray->SetValue(1, 3); + anArray->SetValue(2, 4); + + OSD_Directory aDirectory = OSD_Directory::BuildTemporary(); + OSD_Path aPath; + occ::handle aRestored = + SaveNewDocument(anApplication, aDocument, "draw_ocaf_integer_array", aDirectory, aPath); + ASSERT_FALSE(aRestored.IsNull()); + + occ::handle aRestoredArray; + ASSERT_TRUE( + AttributeLabel(aRestored).FindAttribute(TDataStd_IntegerArray::GetID(), aRestoredArray)); + EXPECT_EQ(aRestoredArray->Lower(), 1); + EXPECT_EQ(aRestoredArray->Upper(), 2); + EXPECT_EQ(aRestoredArray->Value(1), 3); + EXPECT_EQ(aRestoredArray->Value(2), 4); +} + +// xml/data/ocaf/A5: a TDataStd_Name survives XML storage and retrieval. +TEST(XmlOcaf_Storage_Test, A5_Name) +{ + occ::handle anApplication = NewApplication(); + occ::handle aDocument = NewDocument(anApplication); + ASSERT_FALSE(aDocument.IsNull()); + const TCollection_ExtendedString anExpected("New Attribute"); + ASSERT_FALSE(TDataStd_Name::Set(AttributeLabel(aDocument), anExpected).IsNull()); + + OSD_Directory aDirectory = OSD_Directory::BuildTemporary(); + OSD_Path aPath; + occ::handle aRestored = + SaveNewDocument(anApplication, aDocument, "draw_ocaf_name", aDirectory, aPath); + ASSERT_FALSE(aRestored.IsNull()); + + occ::handle aName; + ASSERT_TRUE(AttributeLabel(aRestored).FindAttribute(TDataStd_Name::GetID(), aName)); + EXPECT_EQ(aName->Get(), anExpected); +} + +// bugs/demo/bug14673_4: XML storage preserves names in several Unicode scripts. +TEST(XmlOcaf_Storage_Test, DemoBug_14673_4_UnicodeNames) +{ + occ::handle anApplication = NewApplication(); + occ::handle aDocument = NewDocument(anApplication); + ASSERT_FALSE(aDocument.IsNull()); + + const char* aNames[] = {"test", + "l'\xC3\xA9preuve", + "\xD0\xBE\xD0\xBF\xD1\x8B\xD1\x82", + "\xED\x85\x8C\xEC\x8A\xA4\xED\x8A\xB8", + "gr\xC3\xB6\xC3\x9Ften \xE5\xB8\x82"}; + for (int anIndex = 0; anIndex < 5; ++anIndex) + { + const TDF_Label aLabel = aDocument->GetData()->Root().FindChild(anIndex + 1, true); + ASSERT_FALSE( + TDataStd_Name::Set(aLabel, TCollection_ExtendedString(aNames[anIndex], true)).IsNull()); + } + + occ::handle aRestored = SaveAndOpenStream(anApplication, aDocument); + ASSERT_FALSE(aRestored.IsNull()); + for (int anIndex = 0; anIndex < 5; ++anIndex) + { + occ::handle aName; + const TDF_Label aLabel = aRestored->GetData()->Root().FindChild(anIndex + 1, true); + ASSERT_TRUE(aLabel.FindAttribute(TDataStd_Name::GetID(), aName)); + EXPECT_EQ(aName->Get(), TCollection_ExtendedString(aNames[anIndex], true)); + } +} + +// xml/data/ocaf/A6: a TDataStd_Comment survives XML storage and retrieval. +TEST(XmlOcaf_Storage_Test, A6_Comment) +{ + occ::handle anApplication = NewApplication(); + occ::handle aDocument = NewDocument(anApplication); + ASSERT_FALSE(aDocument.IsNull()); + const TCollection_ExtendedString anExpected("New Attribute"); + ASSERT_FALSE(TDataStd_Comment::Set(AttributeLabel(aDocument), anExpected).IsNull()); + + OSD_Directory aDirectory = OSD_Directory::BuildTemporary(); + OSD_Path aPath; + occ::handle aRestored = + SaveNewDocument(anApplication, aDocument, "draw_ocaf_comment", aDirectory, aPath); + ASSERT_FALSE(aRestored.IsNull()); + + occ::handle aComment; + ASSERT_TRUE(AttributeLabel(aRestored).FindAttribute(TDataStd_Comment::GetID(), aComment)); + EXPECT_EQ(aComment->Get(), anExpected); +} + +// xml/data/ocaf/A7: a TDataXtd_Point survives XML storage and retrieval. +TEST(XmlOcaf_Storage_Test, A7_Point) +{ + occ::handle anApplication = NewApplication(); + occ::handle aDocument = NewDocument(anApplication); + ASSERT_FALSE(aDocument.IsNull()); + const gp_Pnt anExpected(10.0, 20.0, 30.0); + ASSERT_FALSE(TDataXtd_Point::Set(AttributeLabel(aDocument), anExpected).IsNull()); + + OSD_Directory aDirectory = OSD_Directory::BuildTemporary(); + OSD_Path aPath; + occ::handle aRestored = + SaveNewDocument(anApplication, aDocument, "draw_ocaf_point", aDirectory, aPath); + ASSERT_FALSE(aRestored.IsNull()); + + gp_Pnt aPoint; + ASSERT_TRUE(TDataXtd_Geometry::Point(AttributeLabel(aRestored), aPoint)); + EXPECT_TRUE(aPoint.IsEqual(anExpected, Precision::Confusion())); +} + +// xml/data/ocaf/A8: a TDataXtd_Axis survives XML storage and retrieval. +TEST(XmlOcaf_Storage_Test, A8_Axis) +{ + occ::handle anApplication = NewApplication(); + occ::handle aDocument = NewDocument(anApplication); + ASSERT_FALSE(aDocument.IsNull()); + const gp_Lin anExpected(gp_Pnt(10.0, 20.0, 30.0), gp_Dir(100.0, 200.0, 300.0)); + ASSERT_FALSE(TDataXtd_Axis::Set(AttributeLabel(aDocument), anExpected).IsNull()); + + OSD_Directory aDirectory = OSD_Directory::BuildTemporary(); + OSD_Path aPath; + occ::handle aRestored = + SaveNewDocument(anApplication, aDocument, "draw_ocaf_axis", aDirectory, aPath); + ASSERT_FALSE(aRestored.IsNull()); + + gp_Lin aLine; + ASSERT_TRUE(TDataXtd_Geometry::Line(AttributeLabel(aRestored), aLine)); + EXPECT_TRUE(aLine.Location().IsEqual(anExpected.Location(), Precision::Confusion())); + EXPECT_TRUE(aLine.Direction().IsEqual(anExpected.Direction(), Precision::Confusion())); +} + +// xml/data/ocaf/A9: a TDataXtd_Plane survives XML storage and retrieval. +TEST(XmlOcaf_Storage_Test, A9_Plane) +{ + occ::handle anApplication = NewApplication(); + occ::handle aDocument = NewDocument(anApplication); + ASSERT_FALSE(aDocument.IsNull()); + const gp_Pln anExpected(gp_Pnt(10.0, 20.0, 30.0), gp_Dir(-1.0, 0.0, 0.0)); + ASSERT_FALSE(TDataXtd_Plane::Set(AttributeLabel(aDocument), anExpected).IsNull()); + + OSD_Directory aDirectory = OSD_Directory::BuildTemporary(); + OSD_Path aPath; + occ::handle aRestored = + SaveNewDocument(anApplication, aDocument, "draw_ocaf_plane", aDirectory, aPath); + ASSERT_FALSE(aRestored.IsNull()); + + gp_Pln aPlane; + ASSERT_TRUE(TDataXtd_Geometry::Plane(AttributeLabel(aRestored), aPlane)); + EXPECT_TRUE(aPlane.Location().IsEqual(anExpected.Location(), Precision::Confusion())); + EXPECT_TRUE( + aPlane.Axis().Direction().IsEqual(anExpected.Axis().Direction(), Precision::Confusion())); +} + +// xml/data/ocaf/B1: a user attribute survives XML storage and retrieval. +TEST(XmlOcaf_Storage_Test, B1_UserAttribute) +{ + occ::handle anApplication = NewApplication(); + occ::handle aDocument = NewDocument(anApplication); + ASSERT_FALSE(aDocument.IsNull()); + const Standard_GUID aGuid("c73bd075-22ee-11d2-acde-080009dc4422"); + ASSERT_FALSE(TDataStd_UAttribute::Set(AttributeLabel(aDocument), aGuid).IsNull()); + + OSD_Directory aDirectory = OSD_Directory::BuildTemporary(); + OSD_Path aPath; + occ::handle aRestored = + SaveNewDocument(anApplication, aDocument, "draw_ocaf_user_attribute", aDirectory, aPath); + ASSERT_FALSE(aRestored.IsNull()); + + occ::handle anAttribute; + ASSERT_TRUE(AttributeLabel(aRestored).FindAttribute(aGuid, anAttribute)); + EXPECT_EQ(anAttribute->ID(), aGuid); +} + +// xml/data/ocaf/B2: two user attributes with different GUIDs remain independent. +TEST(XmlOcaf_Storage_Test, B2_TwoUserAttributes) +{ + occ::handle anApplication = NewApplication(); + occ::handle aDocument = NewDocument(anApplication); + ASSERT_FALSE(aDocument.IsNull()); + const Standard_GUID aGuid1("c73bd075-22ee-11d2-acde-080009dc4422"); + const Standard_GUID aGuid2("c73bd076-22ee-11d2-acde-080009dc4422"); + const TDF_Label aLabel = AttributeLabel(aDocument); + ASSERT_FALSE(TDataStd_UAttribute::Set(aLabel, aGuid1).IsNull()); + ASSERT_FALSE(TDataStd_UAttribute::Set(aLabel, aGuid2).IsNull()); + + OSD_Directory aDirectory = OSD_Directory::BuildTemporary(); + OSD_Path aPath; + occ::handle aRestored = + SaveNewDocument(anApplication, aDocument, "draw_ocaf_two_user_attributes", aDirectory, aPath); + ASSERT_FALSE(aRestored.IsNull()); + + occ::handle anAttribute1; + occ::handle anAttribute2; + ASSERT_TRUE(AttributeLabel(aRestored).FindAttribute(aGuid1, anAttribute1)); + ASSERT_TRUE(AttributeLabel(aRestored).FindAttribute(aGuid2, anAttribute2)); + EXPECT_NE(anAttribute1->ID(), anAttribute2->ID()); +} + +// xml/data/ocaf/B3: a TNaming_NamedShape box survives XML storage and retrieval. +TEST(XmlOcaf_Storage_Test, B3_NamedShape) +{ + occ::handle anApplication = NewApplication(); + occ::handle aDocument = NewDocument(anApplication); + ASSERT_FALSE(aDocument.IsNull()); + const TDF_Label aLabel = AttributeLabel(aDocument); + SetShape(aLabel, BRepPrimAPI_MakeBox(gp_Pnt(10.0, 20.0, 30.0), gp_Pnt(110.0, 220.0, 330.0))); + + OSD_Directory aDirectory = OSD_Directory::BuildTemporary(); + OSD_Path aPath; + occ::handle aRestored = + SaveNewDocument(anApplication, aDocument, "draw_ocaf_named_shape", aDirectory, aPath); + ASSERT_FALSE(aRestored.IsNull()); + ExpectBoxBounds(ShapeOf(AttributeLabel(aRestored)), 10.0, 20.0, 30.0, 110.0, 220.0, 330.0); +} + +// xml/data/ocaf/B4: a chain of label references and referenced integer values survives storage. +TEST(XmlOcaf_Storage_Test, B4_ReferenceChain) +{ + occ::handle anApplication = NewApplication(); + occ::handle aDocument = NewDocument(anApplication); + ASSERT_FALSE(aDocument.IsNull()); + + const int aTags[][6] = {{3}, + {2076534922, 524398634, 912349856}, + {3, 9283, 12, 1, 9843, 46793}, + {4, 81245034, 321, 1, 1, 1}, + {5, 8, 4, 2, 213, 3242}, + {2, 15, 123, 31214, 452398, 421}, + {2, 2, 1, 1, 1, 3}, + {2, 9}}; + const int aTagLengths[] = {1, 3, 6, 6, 6, 6, 6, 2}; + NCollection_Array1 aLabels(1, 8); + NCollection_Array1 aEntries(1, 8); + for (int anIndex = 1; anIndex <= 8; ++anIndex) + { + aLabels.SetValue(anIndex, + FindOrCreatePath(aDocument, aTags[anIndex - 1], aTagLengths[anIndex - 1])); + TDF_Tool::Entry(aLabels.Value(anIndex), aEntries.ChangeValue(anIndex)); + } + + TDataStd_Integer::Set(aLabels.Value(8), 0); + for (int anIndex = 1; anIndex <= 8; ++anIndex) + { + TDataStd_Integer::Set(aLabels.Value(anIndex), anIndex); + TDF_Reference::Set(aLabels.Value(anIndex), aLabels.Value(anIndex == 1 ? 8 : anIndex - 1)); + } + + OSD_Directory aDirectory = OSD_Directory::BuildTemporary(); + OSD_Path aPath; + occ::handle aRestored = + SaveNewDocument(anApplication, aDocument, "draw_ocaf_reference_chain", aDirectory, aPath); + ASSERT_FALSE(aRestored.IsNull()); + + for (int anIndex = 1; anIndex <= 8; ++anIndex) + { + TDF_Label aRestoredLabel; + TDF_Tool::Label(aRestored->GetData(), aEntries.Value(anIndex), aRestoredLabel); + occ::handle aReference; + ASSERT_TRUE(aRestoredLabel.FindAttribute(TDF_Reference::GetID(), aReference)); + const int anExpectedIndex = anIndex == 1 ? 8 : anIndex - 1; + TCollection_AsciiString anActualEntry; + TDF_Tool::Entry(aReference->Get(), anActualEntry); + EXPECT_STREQ(anActualEntry.ToCString(), aEntries.Value(anExpectedIndex).ToCString()); + + occ::handle anInteger; + ASSERT_TRUE(aReference->Get().FindAttribute(TDataStd_Integer::GetID(), anInteger)); + EXPECT_EQ(anInteger->Get(), anExpectedIndex); + } +} + +// xml/data/ocaf/B5: a named shape created in a later transaction survives storage. +TEST(XmlOcaf_Storage_Test, B5_NamedShapeAfterTransaction) +{ + occ::handle anApplication = NewApplication(); + occ::handle aDocument = NewDocument(anApplication); + ASSERT_FALSE(aDocument.IsNull()); + const TDF_Label aLabel = AttributeLabel(aDocument); + aDocument->NewCommand(); + SetShape(aLabel, BRepPrimAPI_MakeBox(gp_Pnt(10.0, 20.0, 30.0), gp_Pnt(110.0, 220.0, 330.0))); + + OSD_Directory aDirectory = OSD_Directory::BuildTemporary(); + OSD_Path aPath; + occ::handle aRestored = SaveNewDocument(anApplication, + aDocument, + "draw_ocaf_named_shape_transaction", + aDirectory, + aPath); + ASSERT_FALSE(aRestored.IsNull()); + ExpectBoxBounds(ShapeOf(AttributeLabel(aRestored)), 10.0, 20.0, 30.0, 110.0, 220.0, 330.0); +} + +// xml/data/ocaf/B8: the label tag source continues after its child labels are restored. +TEST(XmlOcaf_Storage_Test, B8_TagSource) +{ + occ::handle anApplication = NewApplication(); + occ::handle aDocument = NewDocument(anApplication); + ASSERT_FALSE(aDocument.IsNull()); + const TDF_Label aLabel = AttributeLabel(aDocument); + ASSERT_FALSE(TDataStd_Name::Set(aLabel, TCollection_ExtendedString("Label1")).IsNull()); + const TDF_Label aChild = TDF_TagSource::NewChild(aLabel); + ASSERT_FALSE(TDataStd_Name::Set(aChild, TCollection_ExtendedString("Label11")).IsNull()); + + OSD_Directory aDirectory = OSD_Directory::BuildTemporary(); + OSD_Path aPath; + occ::handle aRestored = + SaveNewDocument(anApplication, aDocument, "draw_ocaf_tag_source", aDirectory, aPath); + ASSERT_FALSE(aRestored.IsNull()); + + occ::handle aTagSource; + ASSERT_TRUE(AttributeLabel(aRestored).FindAttribute(TDF_TagSource::GetID(), aTagSource)); + EXPECT_EQ(aTagSource->NewTag(), 2); +} + +// xml/data/ocaf/B9: a directory label and its name survive XML storage. +TEST(XmlOcaf_Storage_Test, B9_Directory) +{ + occ::handle anApplication = NewApplication(); + occ::handle aDocument = NewDocument(anApplication); + ASSERT_FALSE(aDocument.IsNull()); + const TDF_Label aLabel = AttributeLabel(aDocument); + ASSERT_FALSE(TDataStd_Directory::New(aLabel).IsNull()); + ASSERT_FALSE(TDataStd_Name::Set(aLabel, TCollection_ExtendedString("Label1")).IsNull()); + + OSD_Directory aDirectory = OSD_Directory::BuildTemporary(); + OSD_Path aPath; + occ::handle aRestored = + SaveNewDocument(anApplication, aDocument, "draw_ocaf_directory", aDirectory, aPath); + ASSERT_FALSE(aRestored.IsNull()); + + occ::handle aRestoredDirectory; + ASSERT_TRUE(TDataStd_Directory::Find(AttributeLabel(aRestored), aRestoredDirectory)); + occ::handle aName; + ASSERT_TRUE(AttributeLabel(aRestored).FindAttribute(TDataStd_Name::GetID(), aName)); + EXPECT_EQ(aName->Get(), TCollection_ExtendedString("Label1")); +} + +// xml/data/ocaf/C1: child TDataStd_TreeNode order survives XML storage. +TEST(XmlOcaf_Storage_Test, C1_TreeNodeChildren) +{ + occ::handle anApplication = NewApplication(); + occ::handle aDocument = NewDocument(anApplication); + ASSERT_FALSE(aDocument.IsNull()); + const TDF_Label aRootLabel = AttributeLabel(aDocument); + ASSERT_FALSE(TDataStd_Name::Set(aRootLabel, TCollection_ExtendedString("Label_1")).IsNull()); + occ::handle aRootNode = TDataStd_TreeNode::Set(aRootLabel); + const TDF_Label aChildLabel1 = aDocument->GetData()->Root().FindChild(7, true); + const TDF_Label aChildLabel2 = aDocument->GetData()->Root().FindChild(8, true); + const TDF_Label aChildLabel3 = aDocument->GetData()->Root().FindChild(9, true); + occ::handle aChildNode1 = TDataStd_TreeNode::Set(aChildLabel1); + occ::handle aChildNode2 = TDataStd_TreeNode::Set(aChildLabel2); + occ::handle aChildNode3 = TDataStd_TreeNode::Set(aChildLabel3); + ASSERT_TRUE(aRootNode->Append(aChildNode1)); + ASSERT_TRUE(aRootNode->Append(aChildNode2)); + ASSERT_TRUE(aRootNode->Append(aChildNode3)); + + OSD_Directory aDirectory = OSD_Directory::BuildTemporary(); + OSD_Path aPath; + occ::handle aRestored = + SaveNewDocument(anApplication, aDocument, "draw_ocaf_tree_nodes", aDirectory, aPath); + ASSERT_FALSE(aRestored.IsNull()); + + occ::handle aRestoredRoot = TDataStd_TreeNode::Set(AttributeLabel(aRestored)); + ASSERT_FALSE(aRestoredRoot.IsNull()); + EXPECT_EQ(aRestoredRoot->NbChildren(false), 3); + const int aExpectedTags[] = {7, 8, 9}; + TDataStd_ChildNodeIterator anIterator(aRestoredRoot, false); + for (int anIndex = 0; anIterator.More() && anIndex < 3; anIterator.Next(), ++anIndex) + { + EXPECT_EQ(anIterator.Value()->Label().Tag(), aExpectedTags[anIndex]); + } + EXPECT_FALSE(anIterator.More()); +} + +// xml/data/ocaf/C8: a relation preserves its expression and variable references. +TEST(XmlOcaf_Storage_Test, C8_Relation) +{ + occ::handle anApplication = NewApplication(); + occ::handle aDocument = NewDocument(anApplication); + ASSERT_FALSE(aDocument.IsNull()); + const TDF_Label aVariableLabel1 = aDocument->GetData()->Root().FindChild(1, true); + const TDF_Label aVariableLabel2 = aVariableLabel1.FindChild(2, true); + const TDF_Label aVariableLabel3 = aVariableLabel1.FindChild(3, true); + const TDF_Label aRelationLabel = aVariableLabel1.FindChild(13, true); + occ::handle aVariable1 = TDataStd_Variable::Set(aVariableLabel1); + occ::handle aVariable2 = TDataStd_Variable::Set(aVariableLabel2); + occ::handle aVariable3 = TDataStd_Variable::Set(aVariableLabel3); + aVariable1->Unit("N"); + aVariable2->Unit("kg"); + aVariable3->Unit("m/s2"); + aVariable1->Constant(true); + aVariable2->Constant(false); + aVariable3->Constant(false); + occ::handle aRelation = TDataStd_Relation::Set(aRelationLabel); + aRelation->SetRelation(TCollection_ExtendedString("f = m*a")); + aRelation->GetVariables().Append(aVariable1); + aRelation->GetVariables().Append(aVariable2); + aRelation->GetVariables().Append(aVariable3); + + TCollection_AsciiString aRelationEntry; + TDF_Tool::Entry(aRelationLabel, aRelationEntry); + NCollection_Array1 aVariableEntries(1, 3); + TDF_Tool::Entry(aVariableLabel1, aVariableEntries.ChangeValue(1)); + TDF_Tool::Entry(aVariableLabel2, aVariableEntries.ChangeValue(2)); + TDF_Tool::Entry(aVariableLabel3, aVariableEntries.ChangeValue(3)); + + OSD_Directory aDirectory = OSD_Directory::BuildTemporary(); + OSD_Path aPath; + occ::handle aRestored = + SaveNewDocument(anApplication, aDocument, "draw_ocaf_relation", aDirectory, aPath); + ASSERT_FALSE(aRestored.IsNull()); + + TDF_Label aRestoredRelationLabel; + TDF_Tool::Label(aRestored->GetData(), aRelationEntry, aRestoredRelationLabel); + occ::handle aRestoredRelation; + ASSERT_TRUE(aRestoredRelationLabel.FindAttribute(TDataStd_Relation::GetID(), aRestoredRelation)); + EXPECT_EQ(aRestoredRelation->GetRelation(), TCollection_ExtendedString("f = m*a")); + + int anIndex = 1; + NCollection_List>::Iterator anIterator; + for (anIterator.Initialize(aRestoredRelation->GetVariables()); anIterator.More(); + anIterator.Next(), ++anIndex) + { + ASSERT_LE(anIndex, 3); + TCollection_AsciiString anActualEntry; + TDF_Tool::Entry(anIterator.Value()->Label(), anActualEntry); + EXPECT_STREQ(anActualEntry.ToCString(), aVariableEntries.Value(anIndex).ToCString()); + } + EXPECT_EQ(anIndex, 4); +} + +// xml/data/ocaf/C9: a variable preserves its constant flag and unit. +TEST(XmlOcaf_Storage_Test, C9_Variable) +{ + occ::handle anApplication = NewApplication(); + occ::handle aDocument = NewDocument(anApplication); + ASSERT_FALSE(aDocument.IsNull()); + const TDF_Label aLabel = aDocument->GetData()->Root().FindChild(1, true).FindChild(1, true); + occ::handle aVariable = TDataStd_Variable::Set(aLabel); + ASSERT_FALSE(aVariable.IsNull()); + aVariable->Constant(true); + aVariable->Unit("kg/m3"); + + OSD_Directory aDirectory = OSD_Directory::BuildTemporary(); + OSD_Path aPath; + occ::handle aRestored = + SaveNewDocument(anApplication, aDocument, "draw_ocaf_variable", aDirectory, aPath); + ASSERT_FALSE(aRestored.IsNull()); + + TDF_Label aRestoredLabel; + TDF_Tool::Label(aRestored->GetData(), "0:1:1", aRestoredLabel); + occ::handle aRestoredVariable; + ASSERT_TRUE(aRestoredLabel.FindAttribute(TDataStd_Variable::GetID(), aRestoredVariable)); + EXPECT_TRUE(aRestoredVariable->IsConstant()); + EXPECT_EQ(aRestoredVariable->Unit(), TCollection_AsciiString("kg/m3")); +} + +// xml/data/ocaf/C6: a TFunction_Function driver GUID and failure index survive storage. +TEST(XmlOcaf_Storage_Test, C6_Function) +{ + occ::handle anApplication = NewApplication(); + occ::handle aDocument = NewDocument(anApplication); + ASSERT_FALSE(aDocument.IsNull()); + const Standard_GUID aDriverGuid("5b35ca00-5b78-11d1-8940-080009dc3333"); + const TDF_Label aLabel = aDocument->GetData()->Root().FindChild(1, true).FindChild(1, true); + occ::handle aFunction = TFunction_Function::Set(aLabel, aDriverGuid); + ASSERT_FALSE(aFunction.IsNull()); + aFunction->SetFailure(13); + + TCollection_AsciiString aLabelEntry; + TDF_Tool::Entry(aLabel, aLabelEntry); + OSD_Directory aDirectory = OSD_Directory::BuildTemporary(); + OSD_Path aPath; + occ::handle aRestored = + SaveNewDocument(anApplication, aDocument, "draw_ocaf_function", aDirectory, aPath); + ASSERT_FALSE(aRestored.IsNull()); + + TDF_Label aRestoredLabel; + TDF_Tool::Label(aRestored->GetData(), aLabelEntry, aRestoredLabel); + occ::handle aRestoredFunction; + ASSERT_TRUE(aRestoredLabel.FindAttribute(TFunction_Function::GetID(), aRestoredFunction)); + EXPECT_EQ(aRestoredFunction->GetDriverGUID(), aDriverGuid); + EXPECT_EQ(aRestoredFunction->GetFailure(), 13); +} + +// xml/data/ocaf/D1: XML preserves names containing quotes and angle brackets. +TEST(XmlOcaf_Storage_Test, D1_SpecialNames) +{ + occ::handle anApplication = NewApplication(); + occ::handle aDocument = NewDocument(anApplication); + ASSERT_FALSE(aDocument.IsNull()); + const char* const aNames[] = {"Tu sais je n'ai jamais t aussi hereux que ce matin-l", + "\"Tu sais je n'ai jamais t aussi hereux que ce matin-l\"", + "", + "Tu m'as dit \"J'ai rendez-vous dans un sous-sol avec des fous", + "\"Tu m'as dit \"J'ai rendez-vous dans un sous-sol avec des fous\"", + "Il dans ce monde triste"}; + for (int anIndex = 0; anIndex < 6; ++anIndex) + { + const TDF_Label aLabel = aDocument->GetData()->Root().FindChild(11 + anIndex, true); + ASSERT_FALSE(TDataStd_Name::Set(aLabel, TCollection_ExtendedString(aNames[anIndex])).IsNull()); + } + + OSD_Directory aDirectory = OSD_Directory::BuildTemporary(); + OSD_Path aPath; + occ::handle aRestored = + SaveNewDocument(anApplication, aDocument, "draw_ocaf_special_names", aDirectory, aPath); + ASSERT_FALSE(aRestored.IsNull()); + for (int anIndex = 0; anIndex < 6; ++anIndex) + { + const TDF_Label aLabel = aRestored->GetData()->Root().FindChild(11 + anIndex, true); + occ::handle aName; + ASSERT_TRUE(aLabel.FindAttribute(TDataStd_Name::GetID(), aName)); + EXPECT_EQ(aName->Get(), TCollection_ExtendedString(aNames[anIndex])); + } +} + +// xml/data/ocaf/D4: a one-element integer array survives XML storage. +TEST(XmlOcaf_Storage_Test, D4_SingleIntegerArray) +{ + occ::handle anApplication = NewApplication(); + occ::handle aDocument = NewDocument(anApplication); + ASSERT_FALSE(aDocument.IsNull()); + occ::handle anArray = + TDataStd_IntegerArray::Set(AttributeLabel(aDocument), 1, 1); + ASSERT_FALSE(anArray.IsNull()); + anArray->SetValue(1, 3); + + OSD_Directory aDirectory = OSD_Directory::BuildTemporary(); + OSD_Path aPath; + occ::handle aRestored = + SaveNewDocument(anApplication, aDocument, "draw_ocaf_single_integer_array", aDirectory, aPath); + ASSERT_FALSE(aRestored.IsNull()); + occ::handle aRestoredArray; + ASSERT_TRUE( + AttributeLabel(aRestored).FindAttribute(TDataStd_IntegerArray::GetID(), aRestoredArray)); + EXPECT_EQ(aRestoredArray->Lower(), 1); + EXPECT_EQ(aRestoredArray->Upper(), 1); + EXPECT_EQ(aRestoredArray->Value(1), 3); +} + +// xml/data/ocaf/D5: a one-element real array survives XML storage. +TEST(XmlOcaf_Storage_Test, D5_SingleRealArray) +{ + occ::handle anApplication = NewApplication(); + occ::handle aDocument = NewDocument(anApplication); + ASSERT_FALSE(aDocument.IsNull()); + occ::handle anArray = + TDataStd_RealArray::Set(AttributeLabel(aDocument), 1, 1); + ASSERT_FALSE(anArray.IsNull()); + anArray->SetValue(1, 3.0); + + OSD_Directory aDirectory = OSD_Directory::BuildTemporary(); + OSD_Path aPath; + occ::handle aRestored = + SaveNewDocument(anApplication, aDocument, "draw_ocaf_single_real_array", aDirectory, aPath); + ASSERT_FALSE(aRestored.IsNull()); + occ::handle aRestoredArray; + ASSERT_TRUE(AttributeLabel(aRestored).FindAttribute(TDataStd_RealArray::GetID(), aRestoredArray)); + EXPECT_EQ(aRestoredArray->Lower(), 1); + EXPECT_EQ(aRestoredArray->Upper(), 1); + EXPECT_DOUBLE_EQ(aRestoredArray->Value(1), 3.0); +} + +// xml/data/ocaf/D6: the OCC16497 leading-zero name regression remains fixed. +TEST(XmlOcaf_Storage_Test, D6_LeadingZeroName) +{ + occ::handle anApplication = NewApplication(); + occ::handle aDocument = NewDocument(anApplication); + ASSERT_FALSE(aDocument.IsNull()); + ASSERT_FALSE( + TDataStd_Name::Set(AttributeLabel(aDocument), TCollection_ExtendedString("00")).IsNull()); + + OSD_Directory aDirectory = OSD_Directory::BuildTemporary(); + OSD_Path aPath; + occ::handle aRestored = + SaveNewDocument(anApplication, aDocument, "draw_ocaf_leading_zero_name", aDirectory, aPath); + ASSERT_FALSE(aRestored.IsNull()); + occ::handle aName; + ASSERT_TRUE(AttributeLabel(aRestored).FindAttribute(TDataStd_Name::GetID(), aName)); + EXPECT_EQ(aName->Get(), TCollection_ExtendedString("00")); +} + +// caf/basic/C6: XML preserves default and user-GUID real arrays after undo/redo. +TEST(XmlOcaf_Storage_Test, CafBasic_C6_RealArrayPersistence) +{ + occ::handle anApplication = NewApplication(); + occ::handle aDocument = NewDocument(anApplication); + const TDF_Label aLabel = AttributeLabel(aDocument); + const Standard_GUID aGuid("12e94511-6dbc-11d4-b9c8-0060b0ee281b"); + aDocument->NewCommand(); + occ::handle anArray = TDataStd_RealArray::Set(aLabel, 1, 2); + occ::handle aGuidArray = TDataStd_RealArray::Set(aLabel, aGuid, 1, 2); + anArray->SetValue(1, 3.0); + anArray->SetValue(2, 4.0); + aGuidArray->SetValue(1, 3.0); + aGuidArray->SetValue(2, 4.0); + RestoreAttributesAfterUndo(aDocument, aLabel); + + OSD_Directory aDirectory = OSD_Directory::BuildTemporary(); + OSD_Path aPath; + occ::handle aRestored = + SaveNewDocument(anApplication, aDocument, "draw_caf_real_array", aDirectory, aPath); + ASSERT_FALSE(aRestored.IsNull()); + occ::handle aRestoredArray; + occ::handle aRestoredGuidArray; + ASSERT_TRUE(AttributeLabel(aRestored).FindAttribute(TDataStd_RealArray::GetID(), aRestoredArray)); + ASSERT_TRUE(AttributeLabel(aRestored).FindAttribute(aGuid, aRestoredGuidArray)); + ExpectRealArray(aRestoredArray, 3.0, 4.0); + ExpectRealArray(aRestoredGuidArray, 3.0, 4.0); + EXPECT_EQ(aRestoredGuidArray->ID(), aGuid); +} + +// caf/basic/D7: XML preserves default and user-GUID integer arrays after undo/redo. +TEST(XmlOcaf_Storage_Test, CafBasic_D7_IntegerArrayPersistence) +{ + occ::handle anApplication = NewApplication(); + occ::handle aDocument = NewDocument(anApplication); + const TDF_Label aLabel = AttributeLabel(aDocument); + const Standard_GUID aGuid("12e94511-6dbc-11d4-b9c8-0060b0ee281b"); + aDocument->NewCommand(); + occ::handle anArray = TDataStd_IntegerArray::Set(aLabel, 1, 2); + occ::handle aGuidArray = TDataStd_IntegerArray::Set(aLabel, aGuid, 1, 2); + anArray->SetValue(1, 3); + anArray->SetValue(2, 4); + aGuidArray->SetValue(1, 3); + aGuidArray->SetValue(2, 4); + RestoreAttributesAfterUndo(aDocument, aLabel); + + OSD_Directory aDirectory = OSD_Directory::BuildTemporary(); + OSD_Path aPath; + occ::handle aRestored = + SaveNewDocument(anApplication, aDocument, "draw_caf_integer_array", aDirectory, aPath); + ASSERT_FALSE(aRestored.IsNull()); + occ::handle aRestoredArray; + occ::handle aRestoredGuidArray; + ASSERT_TRUE( + AttributeLabel(aRestored).FindAttribute(TDataStd_IntegerArray::GetID(), aRestoredArray)); + ASSERT_TRUE(AttributeLabel(aRestored).FindAttribute(aGuid, aRestoredGuidArray)); + ExpectIntegerArray(aRestoredArray, 3, 4); + ExpectIntegerArray(aRestoredGuidArray, 3, 4); + EXPECT_EQ(aRestoredGuidArray->ID(), aGuid); +} + +// caf/basic/M7: XML preserves default and user-GUID extended-string arrays. +TEST(XmlOcaf_Storage_Test, CafBasic_M7_ExtendedStringArrayPersistence) +{ + occ::handle anApplication = NewApplication(); + occ::handle aDocument = NewDocument(anApplication); + const TDF_Label aLabel = AttributeLabel(aDocument); + const Standard_GUID aGuid("12e94515-6dbc-11d4-b9c8-0060b0ee281b"); + aDocument->NewCommand(); + occ::handle anArray = TDataStd_ExtStringArray::Set(aLabel, 1, 2); + occ::handle aGuidArray = + TDataStd_ExtStringArray::Set(aLabel, aGuid, 1, 2); + anArray->SetValue(1, TCollection_ExtendedString("xxxxx")); + anArray->SetValue(2, TCollection_ExtendedString("zzzzzzz")); + aGuidArray->SetValue(1, TCollection_ExtendedString("xxxxx")); + aGuidArray->SetValue(2, TCollection_ExtendedString("zzzzzzz")); + RestoreAttributesAfterUndo(aDocument, aLabel); + + OSD_Directory aDirectory = OSD_Directory::BuildTemporary(); + OSD_Path aPath; + occ::handle aRestored = + SaveNewDocument(anApplication, aDocument, "draw_caf_extended_string_array", aDirectory, aPath); + ASSERT_FALSE(aRestored.IsNull()); + occ::handle aRestoredArray; + occ::handle aRestoredGuidArray; + ASSERT_TRUE( + AttributeLabel(aRestored).FindAttribute(TDataStd_ExtStringArray::GetID(), aRestoredArray)); + ASSERT_TRUE(AttributeLabel(aRestored).FindAttribute(aGuid, aRestoredGuidArray)); + ExpectExtendedArray(aRestoredArray, + 1, + 2, + 1, + TCollection_ExtendedString("xxxxx"), + TCollection_ExtendedString("zzzzzzz")); + ExpectExtendedArray(aRestoredGuidArray, + 1, + 2, + 1, + TCollection_ExtendedString("xxxxx"), + TCollection_ExtendedString("zzzzzzz")); +} + +// caf/basic/O7: XML preserves default and user-GUID boolean arrays. +TEST(XmlOcaf_Storage_Test, CafBasic_O7_BooleanArrayPersistence) +{ + occ::handle anApplication = NewApplication(); + occ::handle aDocument = NewDocument(anApplication); + const TDF_Label aLabel = AttributeLabel(aDocument); + const Standard_GUID aGuid("12e94516-6dbc-11d4-b9c8-0060b0ee281b"); + aDocument->NewCommand(); + occ::handle anArray = TDataStd_BooleanArray::Set(aLabel, 1, 2); + occ::handle aGuidArray = TDataStd_BooleanArray::Set(aLabel, aGuid, 1, 2); + anArray->SetValue(1, false); + anArray->SetValue(2, true); + aGuidArray->SetValue(1, false); + aGuidArray->SetValue(2, true); + RestoreAttributesAfterUndo(aDocument, aLabel); + + OSD_Directory aDirectory = OSD_Directory::BuildTemporary(); + OSD_Path aPath; + occ::handle aRestored = + SaveNewDocument(anApplication, aDocument, "draw_caf_boolean_array", aDirectory, aPath); + ASSERT_FALSE(aRestored.IsNull()); + occ::handle aRestoredArray; + occ::handle aRestoredGuidArray; + ASSERT_TRUE( + AttributeLabel(aRestored).FindAttribute(TDataStd_BooleanArray::GetID(), aRestoredArray)); + ASSERT_TRUE(AttributeLabel(aRestored).FindAttribute(aGuid, aRestoredGuidArray)); + ExpectBooleanArray(aRestoredArray, false, true); + ExpectBooleanArray(aRestoredGuidArray, false, true); +} + +// caf/basic/P7: XML preserves default and user-GUID byte arrays. +TEST(XmlOcaf_Storage_Test, CafBasic_P7_ByteArrayPersistence) +{ + occ::handle anApplication = NewApplication(); + occ::handle aDocument = NewDocument(anApplication); + const TDF_Label aLabel = AttributeLabel(aDocument); + const Standard_GUID aGuid("12e94517-6dbc-11d4-b9c8-0060b0ee281b"); + aDocument->NewCommand(); + occ::handle anArray = TDataStd_ByteArray::Set(aLabel, 1, 2); + occ::handle aGuidArray = TDataStd_ByteArray::Set(aLabel, aGuid, 1, 2); + anArray->SetValue(1, 10); + anArray->SetValue(2, 12); + aGuidArray->SetValue(1, 10); + aGuidArray->SetValue(2, 12); + RestoreAttributesAfterUndo(aDocument, aLabel); + + OSD_Directory aDirectory = OSD_Directory::BuildTemporary(); + OSD_Path aPath; + occ::handle aRestored = + SaveNewDocument(anApplication, aDocument, "draw_caf_byte_array", aDirectory, aPath); + ASSERT_FALSE(aRestored.IsNull()); + occ::handle aRestoredArray; + occ::handle aRestoredGuidArray; + ASSERT_TRUE(AttributeLabel(aRestored).FindAttribute(TDataStd_ByteArray::GetID(), aRestoredArray)); + ASSERT_TRUE(AttributeLabel(aRestored).FindAttribute(aGuid, aRestoredGuidArray)); + ExpectByteArray(aRestoredArray, 10, 12); + ExpectByteArray(aRestoredGuidArray, 10, 12); +} + +// caf/basic/Q7: XML preserves default and user-GUID reference arrays. +TEST(XmlOcaf_Storage_Test, CafBasic_Q7_ReferenceArrayPersistence) +{ + occ::handle anApplication = NewApplication(); + occ::handle aDocument = NewDocument(anApplication); + const TDF_Label aLabel = AttributeLabel(aDocument); + const TDF_Label aReference1 = aDocument->GetData()->Root().FindChild(3, true); + const TDF_Label aReference2 = aDocument->GetData()->Root().FindChild(4, true); + const TCollection_AsciiString anEntry1 = LabelEntry(aReference1); + const TCollection_AsciiString anEntry2 = LabelEntry(aReference2); + const Standard_GUID aGuid("12e94518-6dbc-11d4-b9c8-0060b0ee281b"); + aDocument->NewCommand(); + occ::handle anArray = TDataStd_ReferenceArray::Set(aLabel, 1, 2); + occ::handle aGuidArray = + TDataStd_ReferenceArray::Set(aLabel, aGuid, 1, 2); + anArray->SetValue(1, aReference1); + anArray->SetValue(2, aReference2); + aGuidArray->SetValue(1, aReference1); + aGuidArray->SetValue(2, aReference2); + RestoreAttributesAfterUndo(aDocument, aLabel); + + OSD_Directory aDirectory = OSD_Directory::BuildTemporary(); + OSD_Path aPath; + occ::handle aRestored = + SaveNewDocument(anApplication, aDocument, "draw_caf_reference_array", aDirectory, aPath); + ASSERT_FALSE(aRestored.IsNull()); + occ::handle aRestoredArray; + occ::handle aRestoredGuidArray; + ASSERT_TRUE( + AttributeLabel(aRestored).FindAttribute(TDataStd_ReferenceArray::GetID(), aRestoredArray)); + ASSERT_TRUE(AttributeLabel(aRestored).FindAttribute(aGuid, aRestoredGuidArray)); + ExpectReferenceArray(aRestoredArray, anEntry1, anEntry2); + ExpectReferenceArray(aRestoredGuidArray, anEntry1, anEntry2); +} + +// caf/basic/R7: XML preserves default and user-GUID real lists. +TEST(XmlOcaf_Storage_Test, CafBasic_R7_RealListPersistence) +{ + occ::handle anApplication = NewApplication(); + occ::handle aDocument = NewDocument(anApplication); + const TDF_Label aLabel = AttributeLabel(aDocument); + const Standard_GUID aGuid("12e94521-6dbc-11d4-b9c8-0060b0ee281b"); + aDocument->NewCommand(); + occ::handle aList = TDataStd_RealList::Set(aLabel); + occ::handle aGuidList = TDataStd_RealList::Set(aLabel, aGuid); + aList->Append(3.0); + aList->Append(4.0); + aGuidList->Append(3.0); + aGuidList->Append(4.0); + RestoreAttributesAfterUndo(aDocument, aLabel); + + OSD_Directory aDirectory = OSD_Directory::BuildTemporary(); + OSD_Path aPath; + occ::handle aRestored = + SaveNewDocument(anApplication, aDocument, "draw_caf_real_list", aDirectory, aPath); + ASSERT_FALSE(aRestored.IsNull()); + occ::handle aRestoredList; + occ::handle aRestoredGuidList; + ASSERT_TRUE(AttributeLabel(aRestored).FindAttribute(TDataStd_RealList::GetID(), aRestoredList)); + ASSERT_TRUE(AttributeLabel(aRestored).FindAttribute(aGuid, aRestoredGuidList)); + ExpectRealList(aRestoredList, 3.0, 4.0); + ExpectRealList(aRestoredGuidList, 3.0, 4.0); +} + +// caf/basic/S7: XML preserves default and user-GUID integer lists. +TEST(XmlOcaf_Storage_Test, CafBasic_S7_IntegerListPersistence) +{ + occ::handle anApplication = NewApplication(); + occ::handle aDocument = NewDocument(anApplication); + const TDF_Label aLabel = AttributeLabel(aDocument); + const Standard_GUID aGuid("12e94531-6dbc-11d4-b9c8-0060b0ee281b"); + aDocument->NewCommand(); + occ::handle aList = TDataStd_IntegerList::Set(aLabel); + occ::handle aGuidList = TDataStd_IntegerList::Set(aLabel, aGuid); + aList->Append(33); + aList->Append(44); + aGuidList->Append(33); + aGuidList->Append(44); + RestoreAttributesAfterUndo(aDocument, aLabel); + + OSD_Directory aDirectory = OSD_Directory::BuildTemporary(); + OSD_Path aPath; + occ::handle aRestored = + SaveNewDocument(anApplication, aDocument, "draw_caf_integer_list", aDirectory, aPath); + ASSERT_FALSE(aRestored.IsNull()); + occ::handle aRestoredList; + occ::handle aRestoredGuidList; + ASSERT_TRUE( + AttributeLabel(aRestored).FindAttribute(TDataStd_IntegerList::GetID(), aRestoredList)); + ASSERT_TRUE(AttributeLabel(aRestored).FindAttribute(aGuid, aRestoredGuidList)); + ExpectIntegerList(aRestoredList, 33, 44); + ExpectIntegerList(aRestoredGuidList, 33, 44); +} + +// caf/basic/T7: XML preserves default and user-GUID extended-string lists. +TEST(XmlOcaf_Storage_Test, CafBasic_T7_ExtendedStringListPersistence) +{ + occ::handle anApplication = NewApplication(); + occ::handle aDocument = NewDocument(anApplication); + const TDF_Label aLabel = AttributeLabel(aDocument); + const Standard_GUID aGuid("12e94541-6dbc-11d4-b9c8-0060b0ee281b"); + aDocument->NewCommand(); + occ::handle aList = TDataStd_ExtStringList::Set(aLabel); + occ::handle aGuidList = TDataStd_ExtStringList::Set(aLabel, aGuid); + aList->Append(TCollection_ExtendedString("xxxx")); + aList->Append(TCollection_ExtendedString("yyyyy")); + aGuidList->Append(TCollection_ExtendedString("xxxx")); + aGuidList->Append(TCollection_ExtendedString("yyyyy")); + RestoreAttributesAfterUndo(aDocument, aLabel); + + OSD_Directory aDirectory = OSD_Directory::BuildTemporary(); + OSD_Path aPath; + occ::handle aRestored = + SaveNewDocument(anApplication, aDocument, "draw_caf_extended_string_list", aDirectory, aPath); + ASSERT_FALSE(aRestored.IsNull()); + occ::handle aRestoredList; + occ::handle aRestoredGuidList; + ASSERT_TRUE( + AttributeLabel(aRestored).FindAttribute(TDataStd_ExtStringList::GetID(), aRestoredList)); + ASSERT_TRUE(AttributeLabel(aRestored).FindAttribute(aGuid, aRestoredGuidList)); + ExpectExtendedList(aRestoredList, + TCollection_ExtendedString("xxxx"), + TCollection_ExtendedString("yyyyy")); + ExpectExtendedList(aRestoredGuidList, + TCollection_ExtendedString("xxxx"), + TCollection_ExtendedString("yyyyy")); +} + +// caf/basic/U7: XML preserves default and user-GUID boolean lists. +TEST(XmlOcaf_Storage_Test, CafBasic_U7_BooleanListPersistence) +{ + occ::handle anApplication = NewApplication(); + occ::handle aDocument = NewDocument(anApplication); + const TDF_Label aLabel = AttributeLabel(aDocument); + const Standard_GUID aGuid("12e94551-6dbc-11d4-b9c8-0060b0ee281b"); + aDocument->NewCommand(); + occ::handle aList = TDataStd_BooleanList::Set(aLabel); + occ::handle aGuidList = TDataStd_BooleanList::Set(aLabel, aGuid); + aList->Append(false); + aList->Append(true); + aGuidList->Append(false); + aGuidList->Append(true); + RestoreAttributesAfterUndo(aDocument, aLabel); + + OSD_Directory aDirectory = OSD_Directory::BuildTemporary(); + OSD_Path aPath; + occ::handle aRestored = + SaveNewDocument(anApplication, aDocument, "draw_caf_boolean_list", aDirectory, aPath); + ASSERT_FALSE(aRestored.IsNull()); + occ::handle aRestoredList; + occ::handle aRestoredGuidList; + ASSERT_TRUE( + AttributeLabel(aRestored).FindAttribute(TDataStd_BooleanList::GetID(), aRestoredList)); + ASSERT_TRUE(AttributeLabel(aRestored).FindAttribute(aGuid, aRestoredGuidList)); + ExpectBooleanList(aRestoredList, false, true); + ExpectBooleanList(aRestoredGuidList, false, true); +} + +// caf/basic/V7: XML preserves default and user-GUID reference lists. +TEST(XmlOcaf_Storage_Test, CafBasic_V7_ReferenceListPersistence) +{ + occ::handle anApplication = NewApplication(); + occ::handle aDocument = NewDocument(anApplication); + const TDF_Label aLabel = AttributeLabel(aDocument); + const TDF_Label aReference1 = aDocument->GetData()->Root().FindChild(3, true); + const TDF_Label aReference2 = aDocument->GetData()->Root().FindChild(4, true); + const TCollection_AsciiString anEntry1 = LabelEntry(aReference1); + const TCollection_AsciiString anEntry2 = LabelEntry(aReference2); + const Standard_GUID aGuid("12e94561-6dbc-11d4-b9c8-0060b0ee281b"); + aDocument->NewCommand(); + occ::handle aList = TDataStd_ReferenceList::Set(aLabel); + occ::handle aGuidList = TDataStd_ReferenceList::Set(aLabel, aGuid); + aList->Append(aReference1); + aList->Append(aReference2); + aGuidList->Append(aReference1); + aGuidList->Append(aReference2); + RestoreAttributesAfterUndo(aDocument, aLabel); + + OSD_Directory aDirectory = OSD_Directory::BuildTemporary(); + OSD_Path aPath; + occ::handle aRestored = + SaveNewDocument(anApplication, aDocument, "draw_caf_reference_list", aDirectory, aPath); + ASSERT_FALSE(aRestored.IsNull()); + occ::handle aRestoredList; + occ::handle aRestoredGuidList; + ASSERT_TRUE( + AttributeLabel(aRestored).FindAttribute(TDataStd_ReferenceList::GetID(), aRestoredList)); + ASSERT_TRUE(AttributeLabel(aRestored).FindAttribute(aGuid, aRestoredGuidList)); + ExpectReferenceList(aRestoredList, anEntry1, anEntry2); + ExpectReferenceList(aRestoredGuidList, anEntry1, anEntry2); +} + +// caf/basic/M4: XML preserves separators, empty strings, and empty arrays. +TEST(XmlOcaf_Storage_Test, CafBasic_M4_ExtendedStringArrayEdgeCases) +{ + occ::handle anApplication = NewApplication(); + occ::handle aDocument = NewDocument(anApplication); + const TDF_Label aLabel1 = aDocument->GetData()->Root().FindChild(1, true); + const TDF_Label aLabel2 = aDocument->GetData()->Root().FindChild(2, true); + const TDF_Label aLabel3 = aDocument->GetData()->Root().FindChild(3, true); + const TCollection_ExtendedString anEmpty; + occ::handle anArray1 = TDataStd_ExtStringArray::Set(aLabel1, 0, 6); + const char* const aValues[] = {"Hello 1", "Hello_2", "Hello*3", "Hello-4", "Hello5", ""}; + for (int anIndex = 1; anIndex <= 6; ++anIndex) + { + anArray1->SetValue(anIndex, TCollection_ExtendedString(aValues[anIndex - 1])); + } + occ::handle anArray2 = TDataStd_ExtStringArray::Set(aLabel2, 0, 3); + anArray2->SetValue(0, anEmpty); + anArray2->SetValue(1, TCollection_ExtendedString("H")); + anArray2->SetValue(2, anEmpty); + anArray2->SetValue(3, anEmpty); + occ::handle anArray3 = TDataStd_ExtStringArray::Set(aLabel3, 0, 0); + anArray3->SetValue(0, anEmpty); + occ::handle aNode1 = TDataStd_TreeNode::Set(aLabel1); + occ::handle aNode2 = TDataStd_TreeNode::Set(aLabel2); + occ::handle aNode3 = TDataStd_TreeNode::Set(aLabel3); + ASSERT_TRUE(aNode1->Append(aNode2)); + ASSERT_TRUE(aNode1->Append(aNode3)); + + OSD_Directory aDirectory = OSD_Directory::BuildTemporary(); + OSD_Path aPath; + occ::handle aRestored = + SaveNewDocument(anApplication, aDocument, "draw_caf_extended_array_edges", aDirectory, aPath); + ASSERT_FALSE(aRestored.IsNull()); + const TDF_Label aRestoredLabel1 = aRestored->GetData()->Root().FindChild(1, false); + const TDF_Label aRestoredLabel2 = aRestored->GetData()->Root().FindChild(2, false); + const TDF_Label aRestoredLabel3 = aRestored->GetData()->Root().FindChild(3, false); + occ::handle aRestoredArray1; + occ::handle aRestoredArray2; + occ::handle aRestoredArray3; + ASSERT_TRUE(aRestoredLabel1.FindAttribute(TDataStd_ExtStringArray::GetID(), aRestoredArray1)); + ASSERT_TRUE(aRestoredLabel2.FindAttribute(TDataStd_ExtStringArray::GetID(), aRestoredArray2)); + ASSERT_TRUE(aRestoredLabel3.FindAttribute(TDataStd_ExtStringArray::GetID(), aRestoredArray3)); + EXPECT_EQ(aRestoredArray1->Lower(), 0); + EXPECT_EQ(aRestoredArray1->Upper(), 6); + for (int anIndex = 1; anIndex <= 6; ++anIndex) + { + EXPECT_EQ(aRestoredArray1->Value(anIndex), TCollection_ExtendedString(aValues[anIndex - 1])); + } + EXPECT_EQ(aRestoredArray2->Lower(), 0); + EXPECT_EQ(aRestoredArray2->Upper(), 3); + EXPECT_EQ(aRestoredArray2->Value(0), anEmpty); + EXPECT_EQ(aRestoredArray2->Value(1), TCollection_ExtendedString("H")); + EXPECT_EQ(aRestoredArray2->Value(2), anEmpty); + EXPECT_EQ(aRestoredArray2->Value(3), anEmpty); + EXPECT_EQ(aRestoredArray3->Lower(), 0); + EXPECT_EQ(aRestoredArray3->Upper(), 0); + EXPECT_EQ(aRestoredArray3->Value(0), anEmpty); +} + +// caf/basic/F5: all registered empty attributes survive XML storage. +TEST(XmlOcaf_Storage_Test, CafBasic_F5_EmptyAttributes) +{ + occ::handle anApplication = NewApplication(); + occ::handle aDocument = NewDocument(anApplication); + const TDF_Label aLabel = AttributeLabel(aDocument); + aDocument->NewCommand(); + AddEmptyAttribute(aLabel, "TDataXtd_Axis"); + AddEmptyAttribute(aLabel, "TDataXtd_Placement"); + AddEmptyAttribute(aLabel, "TDataXtd_Plane"); + AddEmptyAttribute(aLabel, "TDataXtd_Point"); + AddEmptyAttribute(aLabel, "TDataXtd_Shape"); + AddEmptyAttribute(aLabel, "TDataStd_Tick"); + AddEmptyAttribute(aLabel, "TDataStd_Directory"); + AddEmptyAttribute(aLabel, "TDataStd_NoteBook"); + aDocument->CommitCommand(); + + auto NbAttributes = [](const TDF_Label& theLabel) { + int aCount = 0; + TDF_AttributeIterator anIterator(theLabel); + for (; anIterator.More(); anIterator.Next()) + { + ++aCount; + } + return aCount; + }; + EXPECT_EQ(NbAttributes(aLabel), 8); + EXPECT_TRUE(HasAttributeType(aLabel, STANDARD_TYPE(TDataXtd_Axis))); + EXPECT_TRUE(HasAttributeType(aLabel, STANDARD_TYPE(TDataXtd_Placement))); + EXPECT_TRUE(HasAttributeType(aLabel, STANDARD_TYPE(TDataXtd_Plane))); + EXPECT_TRUE(HasAttributeType(aLabel, STANDARD_TYPE(TDataXtd_Point))); + EXPECT_TRUE(HasAttributeType(aLabel, STANDARD_TYPE(TDataXtd_Shape))); + EXPECT_TRUE(HasAttributeType(aLabel, STANDARD_TYPE(TDataStd_Tick))); + EXPECT_TRUE(HasAttributeType(aLabel, STANDARD_TYPE(TDataStd_Directory))); + EXPECT_TRUE(HasAttributeType(aLabel, STANDARD_TYPE(TDataStd_NoteBook))); + ASSERT_TRUE(aDocument->Undo()); + EXPECT_EQ(NbAttributes(aLabel), 0); + ASSERT_TRUE(aDocument->Redo()); + EXPECT_EQ(NbAttributes(aLabel), 8); + + OSD_Directory aDirectory = OSD_Directory::BuildTemporary(); + OSD_Path aPath; + occ::handle aRestored = + SaveNewDocument(anApplication, aDocument, "draw_caf_empty_attributes", aDirectory, aPath); + ASSERT_FALSE(aRestored.IsNull()); + EXPECT_EQ(NbAttributes(AttributeLabel(aRestored)), 8); + EXPECT_TRUE(HasAttributeType(AttributeLabel(aRestored), STANDARD_TYPE(TDataXtd_Axis))); + EXPECT_TRUE(HasAttributeType(AttributeLabel(aRestored), STANDARD_TYPE(TDataXtd_Placement))); + EXPECT_TRUE(HasAttributeType(AttributeLabel(aRestored), STANDARD_TYPE(TDataXtd_Plane))); + EXPECT_TRUE(HasAttributeType(AttributeLabel(aRestored), STANDARD_TYPE(TDataXtd_Point))); + EXPECT_TRUE(HasAttributeType(AttributeLabel(aRestored), STANDARD_TYPE(TDataXtd_Shape))); + EXPECT_TRUE(HasAttributeType(AttributeLabel(aRestored), STANDARD_TYPE(TDataStd_Tick))); + EXPECT_TRUE(HasAttributeType(AttributeLabel(aRestored), STANDARD_TYPE(TDataStd_Directory))); + EXPECT_TRUE(HasAttributeType(AttributeLabel(aRestored), STANDARD_TYPE(TDataStd_NoteBook))); +} + +// caf/basic/Y2: XML save-empty-label mode preserves empty children selectively. +TEST(XmlOcaf_Storage_Test, CafBasic_Y2_SaveEmptyLabels) +{ + occ::handle anApplication = NewApplication(); + occ::handle aDocument = NewDocument(anApplication); + const TDF_Label aParent = aDocument->GetData()->Root().FindChild(1, true); + aParent.FindChild(1, true); + const TDF_Label aValueLabel = aParent.FindChild(2, true); + aParent.FindChild(3, true); + TDataStd_Integer::Set(aValueLabel, 321); + TDataStd_Real::Set(aValueLabel, 871.33); + + OSD_Directory aDirectory = OSD_Directory::BuildTemporary(); + OSD_Path aPathWithEmpty; + aDirectory.Path(aPathWithEmpty); + aPathWithEmpty.SetName("draw_caf_empty_labels"); + aPathWithEmpty.SetExtension(".xml"); + TCollection_AsciiString aSystemNameWithEmpty; + aPathWithEmpty.SystemName(aSystemNameWithEmpty); + const TCollection_ExtendedString aFileWithEmpty(aSystemNameWithEmpty, true); + aDocument->SetEmptyLabelsSavingMode(true); + ASSERT_EQ(anApplication->SaveAs(aDocument, aFileWithEmpty), PCDM_SS_OK); + + OSD_Path aPathWithoutEmpty; + aDirectory.Path(aPathWithoutEmpty); + aPathWithoutEmpty.SetName("draw_caf_nonempty_labels"); + aPathWithoutEmpty.SetExtension(".xml"); + TCollection_AsciiString aSystemNameWithoutEmpty; + aPathWithoutEmpty.SystemName(aSystemNameWithoutEmpty); + const TCollection_ExtendedString aFileWithoutEmpty(aSystemNameWithoutEmpty, true); + aDocument->SetEmptyLabelsSavingMode(false); + ASSERT_EQ(anApplication->SaveAs(aDocument, aFileWithoutEmpty), PCDM_SS_OK); + anApplication->Close(aDocument); + + occ::handle aRestoredWithEmpty; + occ::handle aRestoredWithoutEmpty; + ASSERT_EQ(anApplication->Open(aFileWithEmpty, aRestoredWithEmpty), PCDM_RS_OK); + ASSERT_EQ(anApplication->Open(aFileWithoutEmpty, aRestoredWithoutEmpty), PCDM_RS_OK); + ASSERT_FALSE(aRestoredWithEmpty.IsNull()); + ASSERT_FALSE(aRestoredWithoutEmpty.IsNull()); + EXPECT_EQ(aRestoredWithEmpty->GetData()->Root().FindChild(1, false).NbChildren(), 3); + EXPECT_EQ(aRestoredWithoutEmpty->GetData()->Root().FindChild(1, false).NbChildren(), 1); + + OSD_File aFile1(aPathWithEmpty); + OSD_File aFile2(aPathWithoutEmpty); + if (aFile1.Exists()) + { + aFile1.Remove(); + } + if (aFile2.Exists()) + { + aFile2.Remove(); + } +} + +// caf/basic/N2: triangulation attributes preserve payload, transactions, and XML storage. +TEST(XmlOcaf_Storage_Test, CafBasic_N2_TriangulationStorage) +{ + occ::handle anApplication = NewApplication(); + occ::handle aDocument = NewDocument(anApplication); + ASSERT_FALSE(aDocument.IsNull()); + const TDF_Label aLabel = aDocument->GetData()->Root().FindChild(1, true); + const occ::handle aFirstMesh = MakeTestTriangulation(false); + const occ::handle aSecondMesh = MakeTestTriangulation(true); + + aDocument->NewCommand(); + ASSERT_FALSE(TDataXtd_Triangulation::Set(aLabel, aFirstMesh).IsNull()); + aDocument->CommitCommand(); + + OSD_Directory aDirectory = OSD_Directory::BuildTemporary(); + OSD_Path aPath1; + OSD_Path aPath2; + const TCollection_ExtendedString aFileName1 = + MakeTemporaryFile(aDirectory, "draw_caf_triangulation_first", aPath1); + const TCollection_ExtendedString aFileName2 = + MakeTemporaryFile(aDirectory, "draw_caf_triangulation_second", aPath2); + ASSERT_EQ(anApplication->SaveAs(aDocument, aFileName1), PCDM_SS_OK); + OSD_File aFile1(aPath1); + ASSERT_TRUE(aFile1.Exists()); + + aDocument->NewCommand(); + ASSERT_FALSE(TDataXtd_Triangulation::Set(aLabel, aSecondMesh).IsNull()); + aDocument->CommitCommand(); + ASSERT_EQ(anApplication->SaveAs(aDocument, aFileName2), PCDM_SS_OK); + OSD_File aFile2(aPath2); + ASSERT_TRUE(aFile2.Exists()); + + ASSERT_TRUE(aDocument->Undo()); + ExpectTriangulation(aLabel, aFirstMesh); + ASSERT_TRUE(aDocument->Redo()); + ExpectTriangulation(aLabel, aSecondMesh); + + anApplication->Close(aDocument); + occ::handle aRestoredFirst; + occ::handle aRestoredSecond; + ASSERT_EQ(anApplication->Open(aFileName1, aRestoredFirst), PCDM_RS_OK); + ASSERT_EQ(anApplication->Open(aFileName2, aRestoredSecond), PCDM_RS_OK); + ASSERT_FALSE(aRestoredFirst.IsNull()); + ASSERT_FALSE(aRestoredSecond.IsNull()); + ExpectTriangulation(aRestoredFirst->GetData()->Root().FindChild(1, false), aFirstMesh); + ExpectTriangulation(aRestoredSecond->GetData()->Root().FindChild(1, false), aSecondMesh); + anApplication->Close(aRestoredFirst); + anApplication->Close(aRestoredSecond); + + if (aFile1.Exists()) + { + aFile1.Remove(); + } + if (aFile2.Exists()) + { + aFile2.Remove(); + } +} + +// caf/bugs/D1: XML preserves a mixed set of large and collection attributes. +TEST(XmlOcaf_Storage_Test, CafBug_D1_MixedAttributeStorage) +{ + occ::handle anApplication = NewApplication(); + occ::handle aDocument = NewDocument(anApplication); + ASSERT_FALSE(aDocument.IsNull()); + const TDF_Label aLabel = aDocument->GetData()->Root().FindChild(1, true); + + occ::handle aByteArray = TDataStd_ByteArray::Set(aLabel, 1, 10); + ASSERT_FALSE(aByteArray.IsNull()); + for (int anIndex = 1; anIndex <= 10; ++anIndex) + { + aByteArray->SetValue(anIndex, static_cast(anIndex)); + } + + occ::handle aRootNode = TDataStd_TreeNode::Set(aLabel); + ASSERT_FALSE(aRootNode.IsNull()); + for (int anIndex = 1; anIndex <= 8; ++anIndex) + { + const TDF_Label aChildLabel = aLabel.FindChild(anIndex, true); + occ::handle aChildNode = TDataStd_TreeNode::Set(aChildLabel); + ASSERT_FALSE(aChildNode.IsNull()); + ASSERT_TRUE(aRootNode->Append(aChildNode)); + } + + occ::handle anIntegerArray = TDataStd_IntegerArray::Set(aLabel, 1, 5); + ASSERT_FALSE(anIntegerArray.IsNull()); + const int anIntegerValues[] = {111, 222, 333, 444, 555}; + for (int anIndex = 1; anIndex <= 5; ++anIndex) + { + anIntegerArray->SetValue(anIndex, anIntegerValues[anIndex - 1]); + } + + occ::handle aRealArray = TDataStd_RealArray::Set(aLabel, 1, 5); + ASSERT_FALSE(aRealArray.IsNull()); + const double aRealValues[] = {1.12345678987654321, 2.2, 3.3, 4.4, 5.5}; + for (int anIndex = 1; anIndex <= 5; ++anIndex) + { + aRealArray->SetValue(anIndex, aRealValues[anIndex - 1]); + } + + occ::handle aPackedMap = TDataStd_IntPackedMap::Set(aLabel); + ASSERT_FALSE(aPackedMap.IsNull()); + const int aPackedValues[] = {1, 10, 100, 1000, 10000}; + for (const int aValue : aPackedValues) + { + ASSERT_TRUE(aPackedMap->Add(aValue)); + } + + occ::handle aBooleanArray = TDataStd_BooleanArray::Set(aLabel, 1, 5); + ASSERT_FALSE(aBooleanArray.IsNull()); + const bool aBooleanValues[] = {false, false, false, true, true}; + for (int anIndex = 1; anIndex <= 5; ++anIndex) + { + aBooleanArray->SetValue(anIndex, aBooleanValues[anIndex - 1]); + } + + occ::handle anIntegerList = TDataStd_IntegerList::Set(aLabel); + ASSERT_FALSE(anIntegerList.IsNull()); + for (int aValue = 1971; aValue <= 1975; ++aValue) + { + anIntegerList->Append(aValue); + } + + occ::handle aBooleanList = TDataStd_BooleanList::Set(aLabel); + ASSERT_FALSE(aBooleanList.IsNull()); + const bool aBooleanListValues[] = {true, false, false, false, true}; + for (const bool aValue : aBooleanListValues) + { + aBooleanList->Append(aValue); + } + + occ::handle aRealList = TDataStd_RealList::Set(aLabel); + ASSERT_FALSE(aRealList.IsNull()); + const double aRealListValues[] = {0.98765432123456789e+21, + 0.98765432123456789e+22, + 0.98765432123456789e+23}; + for (const double aValue : aRealListValues) + { + aRealList->Append(aValue); + } + + OSD_Directory aDirectory = OSD_Directory::BuildTemporary(); + OSD_Path aPath; + occ::handle aRestored = + SaveNewDocument(anApplication, aDocument, "draw_caf_bug23850", aDirectory, aPath); + ASSERT_FALSE(aRestored.IsNull()); + const TDF_Label aRestoredLabel = aRestored->GetData()->Root().FindChild(1, false); + + occ::handle aRestoredByteArray; + ASSERT_TRUE(aRestoredLabel.FindAttribute(TDataStd_ByteArray::GetID(), aRestoredByteArray)); + ASSERT_EQ(aRestoredByteArray->Length(), 10); + for (int anIndex = 1; anIndex <= 10; ++anIndex) + { + EXPECT_EQ(static_cast(aRestoredByteArray->Value(anIndex)), anIndex); + } + + occ::handle aRestoredRootNode = TDataStd_TreeNode::Set(aRestoredLabel); + ASSERT_FALSE(aRestoredRootNode.IsNull()); + EXPECT_EQ(aRestoredRootNode->NbChildren(false), 8); + TDataStd_ChildNodeIterator aNodeIterator(aRestoredRootNode, false); + for (int anIndex = 1; aNodeIterator.More() && anIndex <= 8; aNodeIterator.Next(), ++anIndex) + { + EXPECT_EQ(aNodeIterator.Value()->Label().Tag(), anIndex); + } + EXPECT_FALSE(aNodeIterator.More()); + + occ::handle aRestoredIntegerArray; + ASSERT_TRUE(aRestoredLabel.FindAttribute(TDataStd_IntegerArray::GetID(), aRestoredIntegerArray)); + for (int anIndex = 1; anIndex <= 5; ++anIndex) + { + EXPECT_EQ(aRestoredIntegerArray->Value(anIndex), anIntegerValues[anIndex - 1]); + } + + occ::handle aRestoredRealArray; + ASSERT_TRUE(aRestoredLabel.FindAttribute(TDataStd_RealArray::GetID(), aRestoredRealArray)); + for (int anIndex = 1; anIndex <= 5; ++anIndex) + { + EXPECT_DOUBLE_EQ(aRestoredRealArray->Value(anIndex), aRealValues[anIndex - 1]); + } + + occ::handle aRestoredPackedMap; + ASSERT_TRUE(aRestoredLabel.FindAttribute(TDataStd_IntPackedMap::GetID(), aRestoredPackedMap)); + EXPECT_EQ(aRestoredPackedMap->Extent(), 5); + for (const int aValue : aPackedValues) + { + EXPECT_TRUE(aRestoredPackedMap->Contains(aValue)); + } + + occ::handle aRestoredBooleanArray; + ASSERT_TRUE(aRestoredLabel.FindAttribute(TDataStd_BooleanArray::GetID(), aRestoredBooleanArray)); + for (int anIndex = 1; anIndex <= 5; ++anIndex) + { + EXPECT_EQ(aRestoredBooleanArray->Value(anIndex), aBooleanValues[anIndex - 1]); + } + + occ::handle aRestoredIntegerList; + ASSERT_TRUE(aRestoredLabel.FindAttribute(TDataStd_IntegerList::GetID(), aRestoredIntegerList)); + int anIntegerIndex = 0; + for (NCollection_List::Iterator anIterator(aRestoredIntegerList->List()); anIterator.More(); + anIterator.Next(), ++anIntegerIndex) + { + ASSERT_LT(anIntegerIndex, 5); + EXPECT_EQ(anIterator.Value(), 1971 + anIntegerIndex); + } + EXPECT_EQ(anIntegerIndex, 5); + + occ::handle aRestoredBooleanList; + ASSERT_TRUE(aRestoredLabel.FindAttribute(TDataStd_BooleanList::GetID(), aRestoredBooleanList)); + int aBooleanIndex = 0; + for (NCollection_List::Iterator anIterator(aRestoredBooleanList->List()); + anIterator.More(); + anIterator.Next(), ++aBooleanIndex) + { + ASSERT_LT(aBooleanIndex, 5); + EXPECT_EQ(anIterator.Value(), aBooleanListValues[aBooleanIndex]); + } + EXPECT_EQ(aBooleanIndex, 5); + + occ::handle aRestoredRealList; + ASSERT_TRUE(aRestoredLabel.FindAttribute(TDataStd_RealList::GetID(), aRestoredRealList)); + int aRealIndex = 0; + for (NCollection_List::Iterator anIterator(aRestoredRealList->List()); anIterator.More(); + anIterator.Next(), ++aRealIndex) + { + ASSERT_LT(aRealIndex, 3); + EXPECT_DOUBLE_EQ(anIterator.Value(), aRealListValues[aRealIndex]); + } + EXPECT_EQ(aRealIndex, 3); +} + +// bugs/caf/bug170_3: XML storage preserves punctuation and UTF-8 in comments. +TEST(XmlOcaf_Storage_Test, CafBug_170_3_CommentCharacters) +{ + occ::handle anApplication = NewApplication(); + occ::handle aDocument = NewDocument(anApplication); + ASSERT_FALSE(aDocument.IsNull()); + + const TCollection_ExtendedString anExpected( + "~!@#$%^&*():;'{}|?/.>,<~!@#$%^&*():;'{}|?/.>,<#$%#$%$%^&*():;'{}|$%^&*(@#$%^&*():;'{}|" + "\xEF\xBF\xBD" + "/", + true); + const TDF_Label aLabel = AttributeLabel(aDocument); + ASSERT_FALSE(TDataStd_Comment::Set(aLabel, anExpected).IsNull()); + + occ::handle aRestored = SaveAndOpenStream(anApplication, aDocument); + ASSERT_FALSE(aRestored.IsNull()); + occ::handle aComment; + ASSERT_TRUE(AttributeLabel(aRestored).FindAttribute(TDataStd_Comment::GetID(), aComment)); + EXPECT_EQ(aComment->Get(), anExpected); +} + +// bugs/caf/bug25317: a large real array survives XML stream storage. +TEST(XmlOcaf_Storage_Test, CafBug_25317_LargeRealArray) +{ + occ::handle anApplication = NewApplication(); + occ::handle aDocument = NewDocument(anApplication); + ASSERT_FALSE(aDocument.IsNull()); + + const int aSize = 50000; + const TDF_Label aLabel = aDocument->GetData()->Root().FindChild(1, true); + occ::handle anArray = TDataStd_RealArray::Set(aLabel, 1, aSize); + ASSERT_FALSE(anArray.IsNull()); + for (int anIndex = 1; anIndex <= aSize; ++anIndex) + { + anArray->SetValue(anIndex, 1.234); + } + + occ::handle aRestored = SaveAndOpenStream(anApplication, aDocument); + ASSERT_FALSE(aRestored.IsNull()); + occ::handle aRestoredArray; + ASSERT_TRUE( + LabelByEntry(aRestored, "0:1").FindAttribute(TDataStd_RealArray::GetID(), aRestoredArray)); + ASSERT_FALSE(aRestoredArray.IsNull()); + EXPECT_EQ(aRestoredArray->Lower(), 1); + EXPECT_EQ(aRestoredArray->Upper(), aSize); + EXPECT_EQ(aRestoredArray->Length(), aSize); + for (int anIndex = 1; anIndex <= aSize; ++anIndex) + { + EXPECT_DOUBLE_EQ(aRestoredArray->Value(anIndex), 1.234); + } +} + +// bugs/caf/bug25394_3: empty standard list attributes survive XML storage. +TEST(XmlOcaf_Storage_Test, CafBug_25394_3_EmptyLists) +{ + occ::handle anApplication = NewApplication(); + occ::handle aDocument = NewDocument(anApplication); + ASSERT_FALSE(aDocument.IsNull()); + + const TDF_Label aRoot = aDocument->GetData()->Root(); + ASSERT_FALSE(TDataStd_BooleanList::Set(aRoot.FindChild(1, true).FindChild(1, true)).IsNull()); + ASSERT_FALSE(TDataStd_IntegerList::Set(aRoot.FindChild(1, true).FindChild(2, true)).IsNull()); + ASSERT_FALSE(TDataStd_RealList::Set(aRoot.FindChild(1, true).FindChild(3, true)).IsNull()); + ASSERT_FALSE(TDataStd_ExtStringList::Set(aRoot.FindChild(1, true).FindChild(4, true)).IsNull()); + ASSERT_FALSE(TDataStd_ReferenceList::Set(aRoot.FindChild(1, true).FindChild(5, true)).IsNull()); + + occ::handle aRestored = SaveAndOpenStream(anApplication, aDocument); + ASSERT_FALSE(aRestored.IsNull()); + const TDF_Label aRestoredRoot = aRestored->GetData()->Root().FindChild(1, false); + ASSERT_FALSE(aRestoredRoot.IsNull()); + + occ::handle aBooleanList; + ASSERT_TRUE( + aRestoredRoot.FindChild(1, false).FindAttribute(TDataStd_BooleanList::GetID(), aBooleanList)); + EXPECT_TRUE(aBooleanList->IsEmpty()); + EXPECT_EQ(aBooleanList->Extent(), 0); + + occ::handle anIntegerList; + ASSERT_TRUE( + aRestoredRoot.FindChild(2, false).FindAttribute(TDataStd_IntegerList::GetID(), anIntegerList)); + EXPECT_TRUE(anIntegerList->IsEmpty()); + EXPECT_EQ(anIntegerList->Extent(), 0); + + occ::handle aRealList; + ASSERT_TRUE( + aRestoredRoot.FindChild(3, false).FindAttribute(TDataStd_RealList::GetID(), aRealList)); + EXPECT_TRUE(aRealList->IsEmpty()); + EXPECT_EQ(aRealList->Extent(), 0); + + occ::handle anExtStringList; + ASSERT_TRUE(aRestoredRoot.FindChild(4, false).FindAttribute(TDataStd_ExtStringList::GetID(), + anExtStringList)); + EXPECT_TRUE(anExtStringList->IsEmpty()); + EXPECT_EQ(anExtStringList->Extent(), 0); + + occ::handle aReferenceList; + ASSERT_TRUE(aRestoredRoot.FindChild(5, false).FindAttribute(TDataStd_ReferenceList::GetID(), + aReferenceList)); + EXPECT_TRUE(aReferenceList->IsEmpty()); + EXPECT_EQ(aReferenceList->Extent(), 0); +} + +// bugs/caf/bug25536: XML storage preserves the less common geometry types. +TEST(XmlOcaf_Storage_Test, CafBug_25536_GeometryTypes) +{ + occ::handle anApplication = NewApplication(); + occ::handle aDocument = NewDocument(anApplication); + ASSERT_FALSE(aDocument.IsNull()); + + const TDF_Label aRoot = aDocument->GetData()->Root().FindChild(2, true); + occ::handle aSpline = TDataXtd_Geometry::Set(aRoot.FindChild(1, true)); + occ::handle aPlane = TDataXtd_Geometry::Set(aRoot.FindChild(2, true)); + occ::handle aCylinder = TDataXtd_Geometry::Set(aRoot.FindChild(3, true)); + ASSERT_FALSE(aSpline.IsNull()); + ASSERT_FALSE(aPlane.IsNull()); + ASSERT_FALSE(aCylinder.IsNull()); + aSpline->SetType(TDataXtd_SPLINE); + aPlane->SetType(TDataXtd_PLANE); + aCylinder->SetType(TDataXtd_CYLINDER); + + occ::handle aRestored = SaveAndOpenStream(anApplication, aDocument); + ASSERT_FALSE(aRestored.IsNull()); + const TDF_Label aRestoredRoot = aRestored->GetData()->Root().FindChild(2, false); + ASSERT_FALSE(aRestoredRoot.IsNull()); + occ::handle aRestoredSpline; + occ::handle aRestoredPlane; + occ::handle aRestoredCylinder; + ASSERT_TRUE( + aRestoredRoot.FindChild(1, false).FindAttribute(TDataXtd_Geometry::GetID(), aRestoredSpline)); + ASSERT_TRUE( + aRestoredRoot.FindChild(2, false).FindAttribute(TDataXtd_Geometry::GetID(), aRestoredPlane)); + ASSERT_TRUE( + aRestoredRoot.FindChild(3, false).FindAttribute(TDataXtd_Geometry::GetID(), aRestoredCylinder)); + EXPECT_EQ(aRestoredSpline->GetType(), TDataXtd_SPLINE); + EXPECT_EQ(aRestoredPlane->GetType(), TDataXtd_PLANE); + EXPECT_EQ(aRestoredCylinder->GetType(), TDataXtd_CYLINDER); +} + +// bugs/caf/bug26229_2: XML OCAF SaveAs/Open stream APIs preserve attributes. +TEST(XmlOcaf_Storage_Test, CafBug_26229_2_StreamInteger) +{ + occ::handle anApplication = NewApplication(); + occ::handle aDocument = NewDocument(anApplication); + ASSERT_FALSE(aDocument.IsNull()); + const TDF_Label aLabel = aDocument->GetData()->Root().FindChild(2, true); + ASSERT_FALSE(TDataStd_Integer::Set(aLabel, 100).IsNull()); + + occ::handle aRestored = SaveAndOpenStream(anApplication, aDocument); + ASSERT_FALSE(aRestored.IsNull()); + occ::handle anInteger; + ASSERT_TRUE(LabelByEntry(aRestored, "0:2").FindAttribute(TDataStd_Integer::GetID(), anInteger)); + EXPECT_EQ(anInteger->Get(), 100); +} + +// bugs/caf/bug27187: XML storage preserves references to labels containing a zero tag. +TEST(XmlOcaf_Storage_Test, CafBug_27187_ReferenceToZeroTag) +{ + occ::handle anApplication = NewApplication(); + occ::handle aDocument = NewDocument(anApplication); + ASSERT_FALSE(aDocument.IsNull()); + + const char* aDeepEntry = "0:1:4:9999:0:1:4:2001:4:2001:4:1:4:1001:4:1001"; + const TDF_Label aTarget = aDocument->GetData()->Root().FindChild(1, true); + const int aTags[] = {1, 4, 9999, 0, 1, 4, 2001, 4, 2001, 4, 1, 4, 1001, 4, 1001}; + const TDF_Label aDeepLabel = FindOrCreatePath(aDocument, aTags, 15); + ASSERT_FALSE(aDeepLabel.IsNull()); + ASSERT_FALSE(TDF_Reference::Set(aTarget, aDeepLabel).IsNull()); + + occ::handle aRestored = SaveAndOpenStream(anApplication, aDocument); + ASSERT_FALSE(aRestored.IsNull()); + const TDF_Label aRestoredTarget = LabelByEntry(aRestored, "0:1"); + const TDF_Label aRestoredDeepLabel = LabelByEntry(aRestored, aDeepEntry); + ASSERT_FALSE(aRestoredTarget.IsNull()); + ASSERT_FALSE(aRestoredDeepLabel.IsNull()); + occ::handle aReference; + ASSERT_TRUE(aRestoredTarget.FindAttribute(TDF_Reference::GetID(), aReference)); + ASSERT_FALSE(aReference->Get().IsNull()); + EXPECT_TRUE(aReference->Get() == aRestoredDeepLabel); + EXPECT_EQ(LabelEntry(aReference->Get()), TCollection_AsciiString(aDeepEntry)); +} + +// bugs/caf/bug24852: storing an empty XML OCAF document to a stream does not +// crash the application. +TEST(XmlOcaf_Storage_Test, CafBug_24852_EmptyDocumentStreamStorage) +{ + occ::handle anApplication = NewApplication(); + occ::handle aDocument = NewDocument(anApplication); + ASSERT_FALSE(aDocument.IsNull()); + + std::stringstream aStream; + PCDM_StoreStatus aStoreStatus = PCDM_SS_Failure; + EXPECT_NO_THROW(aStoreStatus = anApplication->SaveAs(aDocument, aStream)); + EXPECT_EQ(aStoreStatus, PCDM_SS_No_Obj); + EXPECT_TRUE(aStream.str().empty()); +} + +// bugs/xde/bug533: XML OCAF storage to a caller-owned stream completes for an +// empty document without raising an exception. +TEST(XmlOcaf_Storage_Test, XdeBug_533_EmptyDocumentStreamStorage) +{ + occ::handle anApplication = NewApplication(); + occ::handle aDocument = NewDocument(anApplication); + ASSERT_FALSE(aDocument.IsNull()); + + std::stringstream aStream; + PCDM_StoreStatus aStoreStatus = PCDM_SS_Failure; + EXPECT_NO_THROW(aStoreStatus = anApplication->SaveAs(aDocument, aStream)); + EXPECT_EQ(aStoreStatus, PCDM_SS_No_Obj); + EXPECT_TRUE(aStream.str().empty()); +} + +// bugs/fclasses/bug24925: XML storage works with a custom format and an empty +// resource manager when both save and load use streams. +TEST(XmlOcaf_Storage_Test, FClassesBug_24925_CustomFormatStream) +{ + occ::handle anApplication = new CustomXmlApplication(); + occ::handle aDocument; + anApplication->NewDocument(THE_QATEST_DOC_FORMAT, aDocument); + ASSERT_FALSE(aDocument.IsNull()); + ASSERT_FALSE(TDataStd_Integer::Set(aDocument->Main(), 0).IsNull()); + ASSERT_FALSE(TDataStd_Name::Set(aDocument->Main(), "QABugs_19.cxx").IsNull()); + + std::stringstream aStream; + ASSERT_EQ(anApplication->SaveAs(aDocument, aStream), PCDM_SS_OK); + const std::string aContent = aStream.str(); + ASSERT_FALSE(aContent.empty()); + EXPECT_NE(aContent.find("My Proprietary Format"), std::string::npos); + + anApplication->Close(aDocument); + aStream.seekg(0); + occ::handle aRestored; + ASSERT_EQ(anApplication->Open(aStream, aRestored), PCDM_RS_OK); + ASSERT_FALSE(aRestored.IsNull()); + + occ::handle anInteger; + ASSERT_TRUE(aRestored->Main().FindAttribute(TDataStd_Integer::GetID(), anInteger)); + EXPECT_EQ(anInteger->Get(), 0); + occ::handle aName; + ASSERT_TRUE(aRestored->Main().FindAttribute(TDataStd_Name::GetID(), aName)); + EXPECT_EQ(aName->Get(), TCollection_ExtendedString("QABugs_19.cxx")); +} + +// bugs/fclasses/bug24931: XML storage can serialize the original 10,000-shape +// stress document through a stream and restore its named shape. +TEST(XmlOcaf_Storage_Test, FClassesBug_24931_LargeShapeStream) +{ + occ::handle anApplication = NewApplication(); + occ::handle aDocument = NewDocument(anApplication); + ASSERT_FALSE(aDocument.IsNull()); + ASSERT_FALSE(TDataStd_Integer::Set(aDocument->Main(), 0).IsNull()); + ASSERT_FALSE(TDataStd_Name::Set(aDocument->Main(), "QABugs_19.cxx").IsNull()); + + int aShapeCount = 10000; + const TopoDS_Shape aShape = MakeLargeTestShape(aShapeCount); + SetShape(aDocument->Main(), aShape); + + std::stringstream aStream; + ASSERT_EQ(anApplication->SaveAs(aDocument, aStream), PCDM_SS_OK); + ASSERT_FALSE(aStream.str().empty()); + + anApplication->Close(aDocument); + aStream.seekg(0); + occ::handle aRestored; + ASSERT_EQ(anApplication->Open(aStream, aRestored), PCDM_RS_OK); + ASSERT_FALSE(aRestored.IsNull()); + + occ::handle anInteger; + ASSERT_TRUE(aRestored->Main().FindAttribute(TDataStd_Integer::GetID(), anInteger)); + EXPECT_EQ(anInteger->Get(), 0); + occ::handle aName; + ASSERT_TRUE(aRestored->Main().FindAttribute(TDataStd_Name::GetID(), aName)); + EXPECT_EQ(aName->Get(), TCollection_ExtendedString("QABugs_19.cxx")); + + Bnd_Box aSourceBounds; + BRepBndLib::Add(aShape, aSourceBounds); + double aSourceXMin = 0.0; + double aSourceYMin = 0.0; + double aSourceZMin = 0.0; + double aSourceXMax = 0.0; + double aSourceYMax = 0.0; + double aSourceZMax = 0.0; + aSourceBounds.Get(aSourceXMin, aSourceYMin, aSourceZMin, aSourceXMax, aSourceYMax, aSourceZMax); + + Bnd_Box aRestoredBounds; + BRepBndLib::Add(ShapeOf(aRestored->Main()), aRestoredBounds); + double aRestoredXMin = 0.0; + double aRestoredYMin = 0.0; + double aRestoredZMin = 0.0; + double aRestoredXMax = 0.0; + double aRestoredYMax = 0.0; + double aRestoredZMax = 0.0; + aRestoredBounds + .Get(aRestoredXMin, aRestoredYMin, aRestoredZMin, aRestoredXMax, aRestoredYMax, aRestoredZMax); + EXPECT_NEAR(aRestoredXMin, aSourceXMin, 1.0e-6); + EXPECT_NEAR(aRestoredYMin, aSourceYMin, 1.0e-6); + EXPECT_NEAR(aRestoredZMin, aSourceZMin, 1.0e-6); + EXPECT_NEAR(aRestoredXMax, aSourceXMax, 1.0e-6); + EXPECT_NEAR(aRestoredYMax, aSourceYMax, 1.0e-6); + EXPECT_NEAR(aRestoredZMax, aSourceZMax, 1.0e-6); +} + +// bugs/caf/bug1919: XML stream retrieval must keep real values independent of +// the numeric locale. The DRAW source is explicitly TODO OCC12345: the +// localized comma input is currently read as 123 instead of 123.456. Keep the +// port disabled until the underlying locale handling is fixed. +TEST(XmlOcaf_Storage_Test, DISABLED_CafBug_1919_LocaleRoundTrip) +{ + occ::handle anApplication = NewApplication(); + occ::handle aDocument = NewDocument(anApplication); + ASSERT_FALSE(aDocument.IsNull()); + + const TDF_Label anEnglishLabel = aDocument->GetData()->Root().FindChild(10, true); + const TDF_Label anItalianLabel = aDocument->GetData()->Root().FindChild(20, true); + const TCollection_AsciiString anOldLocale((const char*)setlocale(LC_ALL, nullptr)); + aDocument->NewCommand(); + + setlocale(LC_ALL, ""); + const char* anEnglishLocale = setlocale(LC_NUMERIC, "en_US"); + const bool hasEnglishLocale = + anEnglishLocale != nullptr && std::strcmp(anEnglishLocale, "en_US") == 0; + const char* anItalianLocale = setlocale(LC_NUMERIC, "it"); + const bool hasItalianLocale = + anItalianLocale != nullptr && std::strcmp(anItalianLocale, "it") == 0; + if (!hasEnglishLocale || !hasItalianLocale) + { + setlocale(LC_ALL, anOldLocale.ToCString()); + GTEST_SKIP() << "Required DRAW locales en_US and it are unavailable"; + } + + setlocale(LC_ALL, ""); + const char* anEnglishLocaleAfterReset = setlocale(LC_NUMERIC, "en_US"); + const bool isEnglishLocaleAfterReset = + anEnglishLocaleAfterReset != nullptr && std::strcmp(anEnglishLocaleAfterReset, "en_US") == 0; + const TCollection_AsciiString anEnglishInput("123.456"); + const bool isEnglishInput = anEnglishInput.IsRealValue(); + const double anEnglishValue = anEnglishInput.RealValue(); + occ::handle anEnglishReal = TDataStd_Real::Set(anEnglishLabel, anEnglishValue); + + setlocale(LC_ALL, ""); + setlocale(LC_NUMERIC, "it"); + const TCollection_AsciiString anItalianInput("123,456"); + const bool isItalianInput = anItalianInput.IsRealValue(); + const double anItalianValue = anItalianInput.RealValue(); + occ::handle anItalianReal = TDataStd_Real::Set(anItalianLabel, anItalianValue); + + const bool hasCurrentEnglish = !anEnglishReal.IsNull(); + const bool hasCurrentItalian = !anItalianReal.IsNull(); + const double aCurrentEnglishValue = hasCurrentEnglish ? anEnglishReal->Get() : 0.0; + const double aCurrentItalianValue = hasCurrentItalian ? anItalianReal->Get() : 0.0; + + std::stringstream aStream; + const PCDM_StoreStatus aStoreStatus = anApplication->SaveAs(aDocument, aStream); + const bool hasSerializedData = !aStream.str().empty(); + anApplication->Close(aDocument); + + setlocale(LC_ALL, ""); + const char* anEnglishLocaleBeforeRead = setlocale(LC_NUMERIC, "en_US"); + const bool isEnglishLocaleBeforeRead = + anEnglishLocaleBeforeRead != nullptr && std::strcmp(anEnglishLocaleBeforeRead, "en_US") == 0; + aStream.seekg(0); + occ::handle aRestored; + const PCDM_ReaderStatus aReadStatus = anApplication->Open(aStream, aRestored); + + double aRestoredEnglishValue = 0.0; + double aRestoredItalianValue = 0.0; + bool hasRestoredEnglish = false; + bool hasRestoredItalian = false; + if (!aRestored.IsNull()) + { + occ::handle anEnglishReal; + occ::handle anItalianReal; + hasRestoredEnglish = + aRestored->GetData()->Root().FindChild(10, false).FindAttribute(TDataStd_Real::GetID(), + anEnglishReal); + hasRestoredItalian = + aRestored->GetData()->Root().FindChild(20, false).FindAttribute(TDataStd_Real::GetID(), + anItalianReal); + if (hasRestoredEnglish) + { + aRestoredEnglishValue = anEnglishReal->Get(); + } + if (hasRestoredItalian) + { + aRestoredItalianValue = anItalianReal->Get(); + } + } + setlocale(LC_ALL, anOldLocale.ToCString()); + + EXPECT_TRUE(isEnglishInput); + EXPECT_TRUE(isItalianInput); + EXPECT_TRUE(isEnglishLocaleAfterReset); + EXPECT_TRUE(hasCurrentEnglish); + EXPECT_TRUE(hasCurrentItalian); + EXPECT_DOUBLE_EQ(anEnglishValue, 123.456); + EXPECT_DOUBLE_EQ(anItalianValue, 123.456); + EXPECT_DOUBLE_EQ(aCurrentEnglishValue, 123.456); + EXPECT_DOUBLE_EQ(aCurrentItalianValue, 123.456); + EXPECT_EQ(aStoreStatus, PCDM_SS_OK); + EXPECT_TRUE(hasSerializedData); + EXPECT_TRUE(isEnglishLocaleBeforeRead); + EXPECT_EQ(aReadStatus, PCDM_RS_OK); + EXPECT_TRUE(hasRestoredEnglish); + EXPECT_TRUE(hasRestoredItalian); + EXPECT_DOUBLE_EQ(aRestoredEnglishValue, 123.456); + EXPECT_DOUBLE_EQ(aRestoredItalianValue, 123.456); +} diff --git a/src/DataExchange/TKDE/GTests/DE_Wrapper_Configuration_Test.cxx b/src/DataExchange/TKDE/GTests/DE_Wrapper_Configuration_Test.cxx new file mode 100644 index 0000000000..3b0f19a7a6 --- /dev/null +++ b/src/DataExchange/TKDE/GTests/DE_Wrapper_Configuration_Test.cxx @@ -0,0 +1,636 @@ +// Copyright (c) 2026 OPEN CASCADE SAS +// +// This file is part of Open CASCADE Technology software library. +// +// This library is free software; you can redistribute it and/or modify it under +// the terms of the GNU Lesser General Public License version 2.1 as published +// by the Free Software Foundation, with special exception defined in the file +// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT +// distribution for complete text of the license and disclaimer of any warranty. +// +// Alternatively, this file may be used under the terms of Open CASCADE +// commercial license or contractual agreement. + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace +{ +static occ::handle NewWrapper() +{ + occ::handle aWrapper = new DE_Wrapper(); + EXPECT_TRUE(aWrapper->Bind(new DEVRML_ConfigurationNode())); + EXPECT_TRUE(aWrapper->Bind(new DEIGES_ConfigurationNode())); + EXPECT_TRUE(aWrapper->Bind(new DEOBJ_ConfigurationNode())); + EXPECT_TRUE(aWrapper->Bind(new DEGLTF_ConfigurationNode())); + EXPECT_TRUE(aWrapper->Bind(new DEPLY_ConfigurationNode())); + EXPECT_TRUE(aWrapper->Bind(new DEXCAF_ConfigurationNode())); + EXPECT_TRUE(aWrapper->Bind(new DESTEP_ConfigurationNode())); + EXPECT_TRUE(aWrapper->Bind(new DESTL_ConfigurationNode())); + EXPECT_TRUE(aWrapper->Bind(new DEBREP_ConfigurationNode())); + return aWrapper; +} + +static bool SameConfiguration(const TCollection_AsciiString& theFirst, + const TCollection_AsciiString& theSecond) +{ + occ::handle aFirstContext = new DE_ConfigurationContext(); + occ::handle aSecondContext = new DE_ConfigurationContext(); + if (!aFirstContext->Load(theFirst) || !aSecondContext->Load(theSecond)) + { + return false; + } + + const NCollection_DataMap& aFirstMap = + aFirstContext->GetInternalMap(); + const NCollection_DataMap& aSecondMap = + aSecondContext->GetInternalMap(); + if (aFirstMap.Extent() != aSecondMap.Extent()) + { + return false; + } + + for (NCollection_DataMap::Iterator anIterator( + aFirstMap); + anIterator.More(); + anIterator.Next()) + { + TCollection_AsciiString aValue; + if (!aSecondMap.Find(anIterator.Key(), aValue) || !aValue.IsEqual(anIterator.Value())) + { + return false; + } + } + return true; +} + +static TCollection_AsciiString ChangeProviderValues(const TCollection_AsciiString& theConfiguration, + const char* theValue) +{ + TCollection_AsciiString aResult; + TCollection_AsciiString aLine; + for (int anIndex = 1; anIndex <= theConfiguration.Length(); ++anIndex) + { + const char aCharacter = theConfiguration.Value(anIndex); + if (aCharacter != '\n') + { + aLine += aCharacter; + } + + if (aCharacter == '\n' || anIndex == theConfiguration.Length()) + { + TCollection_AsciiString aTrimmedLine(aLine); + aTrimmedLine.LeftAdjust(); + if (aTrimmedLine.StartsWith("provider.")) + { + const int aColon = aLine.Location(1, ':', 1, aLine.Length()); + if (aColon > 0) + { + aResult += aLine.SubString(1, aColon); + aResult += " "; + aResult += theValue; + aResult += " \t\n"; + } + } + else if (aTrimmedLine.StartsWith("global.")) + { + aResult += aLine; + aResult += "\n"; + } + aLine.Clear(); + } + } + return aResult; +} + +static const char* InitialConfiguration() +{ + return R"OCCT_A3( +global.priority.VRML : OCC +global.priority.IGES : OCC +global.priority.OBJ : OCC +global.priority.GLTF : OCC +global.priority.PLY : OCC +global.priority.XCAF : OCC +global.priority.STEP : OCC +global.priority.STL : OCC +global.priority.BREP : OCC +global.general.length.unit : 1 +global.general.system.unit : 1 +provider.VRML.OCC.read.file.unit : 1 +provider.VRML.OCC.read.file.coordinate.system : 1 +provider.VRML.OCC.read.system.coordinate.system : 0 +provider.VRML.OCC.read.fill.incomplete : 1 +provider.VRML.OCC.writer.version : 2 +provider.VRML.OCC.write.representation.type : 1 +provider.IGES.OCC.read.iges.bspline.continuity : 1 +provider.IGES.OCC.read.precision.mode : 0 +provider.IGES.OCC.read.precision.val : 0.0001 +provider.IGES.OCC.read.maxprecision.mode : 0 +provider.IGES.OCC.read.maxprecision.val : 1 +provider.IGES.OCC.read.stdsameparameter.mode : 0 +provider.IGES.OCC.read.surfacecurve.mode : 0 +provider.IGES.OCC.read.encoderegularity.angle : 0.572958 +provider.IGES.OCC.read.bspline.approxd1.mode : 0 +provider.IGES.OCC.read.fau_lty.entities : 0 +provider.IGES.OCC.read.onlyvisible : 0 +provider.IGES.OCC.read.color : 1 +provider.IGES.OCC.read.name : 1 +provider.IGES.OCC.read.layer : 1 +provider.IGES.OCC.write.brep.mode : 0 +provider.IGES.OCC.write.convertsurface.mode : 0 +provider.IGES.OCC.write.header.author : +provider.IGES.OCC.write.header.company : +provider.IGES.OCC.write.header.product : +provider.IGES.OCC.write.header.receiver : +provider.IGES.OCC.write.precision.mode : 0 +provider.IGES.OCC.write.precision.val : 0.0001 +provider.IGES.OCC.write.plane.mode : 0 +provider.IGES.OCC.write.offset : 0 +provider.IGES.OCC.write.color : 1 +provider.IGES.OCC.write.name : 1 +provider.IGES.OCC.write.layer : 1 +provider.IGES.OCC.healing.tolerance3d : 1e-06 +provider.IGES.OCC.healing.max.tolerance3d : 1 +provider.IGES.OCC.healing.min.tolerance3d : 1e-07 +provider.IGES.OCC.healing.free.shell : -1 +provider.IGES.OCC.healing.free.face : -1 +provider.IGES.OCC.healing.free.wire : -1 +provider.IGES.OCC.healing.same.parameter : -1 +provider.IGES.OCC.healing.solid : -1 +provider.IGES.OCC.healing.shell.orientation : -1 +provider.IGES.OCC.healing.create.open.solid : 1 +provider.IGES.OCC.healing.shell : -1 +provider.IGES.OCC.healing.face.orientation : -1 +provider.IGES.OCC.healing.face : -1 +provider.IGES.OCC.healing.wire : -1 +provider.IGES.OCC.healing.orientation : -1 +provider.IGES.OCC.healing.add.natural.bound : -1 +provider.IGES.OCC.healing.missing.seam : -1 +provider.IGES.OCC.healing.small.area.wire : -1 +provider.IGES.OCC.healing.remove.small.area.face : -1 +provider.IGES.OCC.healing.intersecting.wires : -1 +provider.IGES.OCC.healing.loop.wires : -1 +provider.IGES.OCC.healing.split.face : -1 +provider.IGES.OCC.healing.auto.correct.precision : 1 +provider.IGES.OCC.healing.modify.topology : 0 +provider.IGES.OCC.healing.modify.geometry : 1 +provider.IGES.OCC.healing.closed.wire : 1 +provider.IGES.OCC.healing.preference.pcurve : 1 +provider.IGES.OCC.healing.reorder.edges : -1 +provider.IGES.OCC.healing.remove.small.edges : -1 +provider.IGES.OCC.healing.connected.edges : -1 +provider.IGES.OCC.healing.edge.curves : -1 +provider.IGES.OCC.healing.add.degenerated.edges : -1 +provider.IGES.OCC.healing.add.lacking.edges : -1 +provider.IGES.OCC.healing.selfintersection : -1 +provider.IGES.OCC.healing.remove.loop : -1 +provider.IGES.OCC.healing.reversed2d : -1 +provider.IGES.OCC.healing.remove.pcurve : -1 +provider.IGES.OCC.healing.remove.curve3d : -1 +provider.IGES.OCC.healing.add.pcurve : -1 +provider.IGES.OCC.healing.add.curve3d : -1 +provider.IGES.OCC.healing.correct.order.in.seam : -1 +provider.IGES.OCC.healing.shifted : -1 +provider.IGES.OCC.healing.edge.same.parameter : 0 +provider.IGES.OCC.healing.notched.edges : -1 +provider.IGES.OCC.healing.tail : -1 +provider.IGES.OCC.healing.max.tail.angle : -1 +provider.IGES.OCC.healing.max.tail.width : -1 +provider.IGES.OCC.healing.selfintersecting.edge : -1 +provider.IGES.OCC.healing.intersecting.edges : -1 +provider.IGES.OCC.healing.nonadjacent.intersecting.edges : -1 +provider.IGES.OCC.healing.vertex.position : 0 +provider.IGES.OCC.healing.vertex.tolerance : -1 +provider.OBJ.OCC.file.length.unit : 1 +provider.OBJ.OCC.system.cs : 0 +provider.OBJ.OCC.file.cs : 1 +provider.OBJ.OCC.read.single.precision : 0 +provider.OBJ.OCC.read.create.shapes : 0 +provider.OBJ.OCC.read.root.prefix : +provider.OBJ.OCC.read.fill.doc : 1 +provider.OBJ.OCC.read.fill.incomplete : 1 +provider.OBJ.OCC.read.memory.limit.mib : -1 +provider.OBJ.OCC.write.comment : +provider.OBJ.OCC.write.author : +provider.GLTF.OCC.file.length.unit : 1 +provider.GLTF.OCC.system.cs : 0 +provider.GLTF.OCC.file.cs : 1 +provider.GLTF.OCC.read.single.precision : 1 +provider.GLTF.OCC.read.create.shapes : 0 +provider.GLTF.OCC.read.root.prefix : +provider.GLTF.OCC.read.fill.doc : 1 +provider.GLTF.OCC.read.fill.incomplete : 1 +provider.GLTF.OCC.read.memory.limit.mib : -1 +provider.GLTF.OCC.read.parallel : 0 +provider.GLTF.OCC.read.skip.empty.nodes : 1 +provider.GLTF.OCC.read.load.all.scenes : 0 +provider.GLTF.OCC.read.use.mesh.name.as.fallback : 1 +provider.GLTF.OCC.read.skip.late.data.loading : 0 +provider.GLTF.OCC.read.keep.late.data : 1 +provider.GLTF.OCC.read.print.debug.message : 0 +provider.GLTF.OCC.read.apply.scale : 1 +provider.GLTF.OCC.write.comment : +provider.GLTF.OCC.write.author : +provider.GLTF.OCC.write.trsf.format : 0 +provider.GLTF.OCC.write.node.name.format : 3 +provider.GLTF.OCC.write.mesh.name.format : 1 +provider.GLTF.OCC.write.forced.uv.export : 0 +provider.GLTF.OCC.write.embed.textures.in.glb : 1 +provider.GLTF.OCC.write.merge.faces : 0 +provider.GLTF.OCC.write.split.indices16 : 0 +provider.PLY.OCC.file.length.unit : 1 +provider.PLY.OCC.system.cs : 0 +provider.PLY.OCC.file.cs : 1 +provider.PLY.OCC.write.normals : 1 +provider.PLY.OCC.write.colors : 1 +provider.PLY.OCC.write.tex.coords : 0 +provider.PLY.OCC.write.part.id : 1 +provider.PLY.OCC.write.face.id : 0 +provider.PLY.OCC.write.comment : +provider.PLY.OCC.write.author : +provider.XCAF.OCC.read.append.mode : 0 +provider.XCAF.OCC.read.skip.values : +provider.XCAF.OCC.read.values : +provider.STEP.OCC.read.iges.bspline.continuity : 1 +provider.STEP.OCC.read.precision.mode : 0 +provider.STEP.OCC.read.precision.val : 0.0001 +provider.STEP.OCC.read.maxprecision.mode : 0 +provider.STEP.OCC.read.maxprecision.val : 1 +provider.STEP.OCC.read.stdsameparameter.mode : 0 +provider.STEP.OCC.read.surfacecurve.mode : 0 +provider.STEP.OCC.read.encoderegularity.angle : 0.572958 +provider.STEP.OCC.angleunit.mode : 0 +provider.STEP.OCC.read.product.mode : 1 +provider.STEP.OCC.read.product.context : 1 +provider.STEP.OCC.read.shape.repr : 1 +provider.STEP.OCC.read.tessellated : 1 +provider.STEP.OCC.read.assembly.level : 1 +provider.STEP.OCC.read.shape.relationship : 1 +provider.STEP.OCC.read.shape.aspect : 1 +provider.STEP.OCC.read.constructivegeom.relationship : 0 +provider.STEP.OCC.read.stepcaf.subshapes.name : 0 +provider.STEP.OCC.read.codepage : 4 +provider.STEP.OCC.read.nonmanifold : 0 +provider.STEP.OCC.read.ideas : 0 +provider.STEP.OCC.read.all.shapes : 0 +provider.STEP.OCC.read.root.transformation : 1 +provider.STEP.OCC.read.color : 1 +provider.STEP.OCC.read.name : 1 +provider.STEP.OCC.read.layer : 1 +provider.STEP.OCC.read.props : 1 +provider.STEP.OCC.read.metadata : 1 +provider.STEP.OCC.read.productmetadata : 0 +provider.STEP.OCC.write.precision.mode : 0 +provider.STEP.OCC.write.precision.val : 0.0001 +provider.STEP.OCC.write.assembly : 2 +provider.STEP.OCC.write.schema : 4 +provider.STEP.OCC.write.tessellated : 2 +provider.STEP.OCC.write.product.name : +provider.STEP.OCC.write.surfacecurve.mode : 1 +provider.STEP.OCC.write.unit : 2 +provider.STEP.OCC.write.vertex.mode : 0 +provider.STEP.OCC.write.stepcaf.subshapes.name : 0 +provider.STEP.OCC.write.color : 1 +provider.STEP.OCC.write.nonmanifold : 0 +provider.STEP.OCC.write.name : 1 +provider.STEP.OCC.write.layer : 1 +provider.STEP.OCC.write.material : 1 +provider.STEP.OCC.write.vismaterial : 0 +provider.STEP.OCC.write.metadata : 1 +provider.STEP.OCC.write.props : 1 +provider.STEP.OCC.write.model.type : 0 +provider.STEP.OCC.write.cleanduplicates : 0 +provider.STEP.OCC.write.scaling.trsf : 1 +provider.STEP.OCC.healing.tolerance3d : 1e-06 +provider.STEP.OCC.healing.max.tolerance3d : 1 +provider.STEP.OCC.healing.min.tolerance3d : 1e-07 +provider.STEP.OCC.healing.free.shell : -1 +provider.STEP.OCC.healing.free.face : -1 +provider.STEP.OCC.healing.free.wire : -1 +provider.STEP.OCC.healing.same.parameter : -1 +provider.STEP.OCC.healing.solid : -1 +provider.STEP.OCC.healing.shell.orientation : -1 +provider.STEP.OCC.healing.create.open.solid : 0 +provider.STEP.OCC.healing.shell : -1 +provider.STEP.OCC.healing.face.orientation : -1 +provider.STEP.OCC.healing.face : -1 +provider.STEP.OCC.healing.wire : -1 +provider.STEP.OCC.healing.orientation : -1 +provider.STEP.OCC.healing.add.natural.bound : -1 +provider.STEP.OCC.healing.missing.seam : -1 +provider.STEP.OCC.healing.small.area.wire : -1 +provider.STEP.OCC.healing.remove.small.area.face : -1 +provider.STEP.OCC.healing.intersecting.wires : -1 +provider.STEP.OCC.healing.loop.wires : -1 +provider.STEP.OCC.healing.split.face : -1 +provider.STEP.OCC.healing.auto.correct.precision : 1 +provider.STEP.OCC.healing.modify.topology : 0 +provider.STEP.OCC.healing.modify.geometry : 1 +provider.STEP.OCC.healing.closed.wire : 1 +provider.STEP.OCC.healing.preference.pcurve : 1 +provider.STEP.OCC.healing.reorder.edges : -1 +provider.STEP.OCC.healing.remove.small.edges : -1 +provider.STEP.OCC.healing.connected.edges : -1 +provider.STEP.OCC.healing.edge.curves : -1 +provider.STEP.OCC.healing.add.degenerated.edges : -1 +provider.STEP.OCC.healing.add.lacking.edges : -1 +provider.STEP.OCC.healing.selfintersection : -1 +provider.STEP.OCC.healing.remove.loop : -1 +provider.STEP.OCC.healing.reversed2d : -1 +provider.STEP.OCC.healing.remove.pcurve : -1 +provider.STEP.OCC.healing.remove.curve3d : -1 +provider.STEP.OCC.healing.add.pcurve : -1 +provider.STEP.OCC.healing.add.curve3d : -1 +provider.STEP.OCC.healing.correct.order.in.seam : -1 +provider.STEP.OCC.healing.shifted : -1 +provider.STEP.OCC.healing.edge.same.parameter : 0 +provider.STEP.OCC.healing.notched.edges : -1 +provider.STEP.OCC.healing.tail : 0 +provider.STEP.OCC.healing.max.tail.angle : 0 +provider.STEP.OCC.healing.max.tail.width : -1 +provider.STEP.OCC.healing.selfintersecting.edge : -1 +provider.STEP.OCC.healing.intersecting.edges : -1 +provider.STEP.OCC.healing.nonadjacent.intersecting.edges : -1 +provider.STEP.OCC.healing.vertex.position : 0 +provider.STEP.OCC.healing.vertex.tolerance : -1 +provider.STL.OCC.read.merge.angle : 90 +provider.STL.OCC.read.brep : 0 +provider.STL.OCC.write.ascii : 1 +provider.BREP.OCC.write.binary : 1 +provider.BREP.OCC.write.version.binary : 4 +provider.BREP.OCC.write.version.ascii : 3 +provider.BREP.OCC.write.triangles : 1 +provider.BREP.OCC.write.normals : 1 + +)OCCT_A3"; +} + +static const char* TwoFormatsConfiguration() +{ + return R"OCCT_A4( +global.priority.VRML : OCC +global.priority.IGES : OCC +global.priority.OBJ : OCC +global.priority.GLTF : OCC +global.priority.PLY : OCC +global.priority.XCAF : OCC +global.priority.STEP : OCC +global.priority.STL : OCC +global.priority.BREP : OCC +global.general.length.unit : 1 +global.general.system.unit : 1 +provider.IGES.OCC.read.iges.bspline.continuity : 1 +provider.IGES.OCC.read.precision.mode : 0 +provider.IGES.OCC.read.precision.val : 0.0001 +provider.IGES.OCC.read.maxprecision.mode : 0 +provider.IGES.OCC.read.maxprecision.val : 1 +provider.IGES.OCC.read.stdsameparameter.mode : 0 +provider.IGES.OCC.read.surfacecurve.mode : 0 +provider.IGES.OCC.read.encoderegularity.angle : 0.572958 +provider.IGES.OCC.read.bspline.approxd1.mode : 0 +provider.IGES.OCC.read.fau_lty.entities : 0 +provider.IGES.OCC.read.onlyvisible : 0 +provider.IGES.OCC.read.color : 1 +provider.IGES.OCC.read.name : 1 +provider.IGES.OCC.read.layer : 1 +provider.IGES.OCC.write.brep.mode : 0 +provider.IGES.OCC.write.convertsurface.mode : 0 +provider.IGES.OCC.write.header.author : +provider.IGES.OCC.write.header.company : +provider.IGES.OCC.write.header.product : +provider.IGES.OCC.write.header.receiver : +provider.IGES.OCC.write.precision.mode : 0 +provider.IGES.OCC.write.precision.val : 0.0001 +provider.IGES.OCC.write.plane.mode : 0 +provider.IGES.OCC.write.offset : 0 +provider.IGES.OCC.write.color : 1 +provider.IGES.OCC.write.name : 1 +provider.IGES.OCC.write.layer : 1 +provider.IGES.OCC.healing.tolerance3d : 1e-06 +provider.IGES.OCC.healing.max.tolerance3d : 1 +provider.IGES.OCC.healing.min.tolerance3d : 1e-07 +provider.IGES.OCC.healing.free.shell : -1 +provider.IGES.OCC.healing.free.face : -1 +provider.IGES.OCC.healing.free.wire : -1 +provider.IGES.OCC.healing.same.parameter : -1 +provider.IGES.OCC.healing.solid : -1 +provider.IGES.OCC.healing.shell.orientation : -1 +provider.IGES.OCC.healing.create.open.solid : 1 +provider.IGES.OCC.healing.shell : -1 +provider.IGES.OCC.healing.face.orientation : -1 +provider.IGES.OCC.healing.face : -1 +provider.IGES.OCC.healing.wire : -1 +provider.IGES.OCC.healing.orientation : -1 +provider.IGES.OCC.healing.add.natural.bound : -1 +provider.IGES.OCC.healing.missing.seam : -1 +provider.IGES.OCC.healing.small.area.wire : -1 +provider.IGES.OCC.healing.remove.small.area.face : -1 +provider.IGES.OCC.healing.intersecting.wires : -1 +provider.IGES.OCC.healing.loop.wires : -1 +provider.IGES.OCC.healing.split.face : -1 +provider.IGES.OCC.healing.auto.correct.precision : 1 +provider.IGES.OCC.healing.modify.topology : 0 +provider.IGES.OCC.healing.modify.geometry : 1 +provider.IGES.OCC.healing.closed.wire : 1 +provider.IGES.OCC.healing.preference.pcurve : 1 +provider.IGES.OCC.healing.reorder.edges : -1 +provider.IGES.OCC.healing.remove.small.edges : -1 +provider.IGES.OCC.healing.connected.edges : -1 +provider.IGES.OCC.healing.edge.curves : -1 +provider.IGES.OCC.healing.add.degenerated.edges : -1 +provider.IGES.OCC.healing.add.lacking.edges : -1 +provider.IGES.OCC.healing.selfintersection : -1 +provider.IGES.OCC.healing.remove.loop : -1 +provider.IGES.OCC.healing.reversed2d : -1 +provider.IGES.OCC.healing.remove.pcurve : -1 +provider.IGES.OCC.healing.remove.curve3d : -1 +provider.IGES.OCC.healing.add.pcurve : -1 +provider.IGES.OCC.healing.add.curve3d : -1 +provider.IGES.OCC.healing.correct.order.in.seam : -1 +provider.IGES.OCC.healing.shifted : -1 +provider.IGES.OCC.healing.edge.same.parameter : 0 +provider.IGES.OCC.healing.notched.edges : -1 +provider.IGES.OCC.healing.tail : -1 +provider.IGES.OCC.healing.max.tail.angle : -1 +provider.IGES.OCC.healing.max.tail.width : -1 +provider.IGES.OCC.healing.selfintersecting.edge : -1 +provider.IGES.OCC.healing.intersecting.edges : -1 +provider.IGES.OCC.healing.nonadjacent.intersecting.edges : -1 +provider.IGES.OCC.healing.vertex.position : 0 +provider.IGES.OCC.healing.vertex.tolerance : -1 +provider.STEP.OCC.read.iges.bspline.continuity : 1 +provider.STEP.OCC.read.precision.mode : 0 +provider.STEP.OCC.read.precision.val : 0.0001 +provider.STEP.OCC.read.maxprecision.mode : 0 +provider.STEP.OCC.read.maxprecision.val : 1 +provider.STEP.OCC.read.stdsameparameter.mode : 0 +provider.STEP.OCC.read.surfacecurve.mode : 0 +provider.STEP.OCC.read.encoderegularity.angle : 0.572958 +provider.STEP.OCC.angleunit.mode : 0 +provider.STEP.OCC.read.product.mode : 1 +provider.STEP.OCC.read.product.context : 1 +provider.STEP.OCC.read.shape.repr : 1 +provider.STEP.OCC.read.tessellated : 1 +provider.STEP.OCC.read.assembly.level : 1 +provider.STEP.OCC.read.shape.relationship : 1 +provider.STEP.OCC.read.shape.aspect : 1 +provider.STEP.OCC.read.constructivegeom.relationship : 0 +provider.STEP.OCC.read.stepcaf.subshapes.name : 0 +provider.STEP.OCC.read.codepage : 4 +provider.STEP.OCC.read.nonmanifold : 0 +provider.STEP.OCC.read.ideas : 0 +provider.STEP.OCC.read.all.shapes : 0 +provider.STEP.OCC.read.root.transformation : 1 +provider.STEP.OCC.read.color : 1 +provider.STEP.OCC.read.name : 1 +provider.STEP.OCC.read.layer : 1 +provider.STEP.OCC.read.props : 1 +provider.STEP.OCC.read.metadata : 1 +provider.STEP.OCC.read.productmetadata : 0 +provider.STEP.OCC.write.precision.mode : 0 +provider.STEP.OCC.write.precision.val : 0.0001 +provider.STEP.OCC.write.assembly : 2 +provider.STEP.OCC.write.schema : 4 +provider.STEP.OCC.write.tessellated : 2 +provider.STEP.OCC.write.product.name : +provider.STEP.OCC.write.surfacecurve.mode : 1 +provider.STEP.OCC.write.unit : 2 +provider.STEP.OCC.write.vertex.mode : 0 +provider.STEP.OCC.write.stepcaf.subshapes.name : 0 +provider.STEP.OCC.write.color : 1 +provider.STEP.OCC.write.nonmanifold : 0 +provider.STEP.OCC.write.name : 1 +provider.STEP.OCC.write.layer : 1 +provider.STEP.OCC.write.props : 1 +provider.STEP.OCC.write.material : 1 +provider.STEP.OCC.write.vismaterial : 0 +provider.STEP.OCC.write.metadata : 1 +provider.STEP.OCC.write.model.type : 0 +provider.STEP.OCC.write.cleanduplicates : 0 +provider.STEP.OCC.write.scaling.trsf : 1 +provider.STEP.OCC.healing.tolerance3d : 1e-06 +provider.STEP.OCC.healing.max.tolerance3d : 1 +provider.STEP.OCC.healing.min.tolerance3d : 1e-07 +provider.STEP.OCC.healing.free.shell : -1 +provider.STEP.OCC.healing.free.face : -1 +provider.STEP.OCC.healing.free.wire : -1 +provider.STEP.OCC.healing.same.parameter : -1 +provider.STEP.OCC.healing.solid : -1 +provider.STEP.OCC.healing.shell.orientation : -1 +provider.STEP.OCC.healing.create.open.solid : 0 +provider.STEP.OCC.healing.shell : -1 +provider.STEP.OCC.healing.face.orientation : -1 +provider.STEP.OCC.healing.face : -1 +provider.STEP.OCC.healing.wire : -1 +provider.STEP.OCC.healing.orientation : -1 +provider.STEP.OCC.healing.add.natural.bound : -1 +provider.STEP.OCC.healing.missing.seam : -1 +provider.STEP.OCC.healing.small.area.wire : -1 +provider.STEP.OCC.healing.remove.small.area.face : -1 +provider.STEP.OCC.healing.intersecting.wires : -1 +provider.STEP.OCC.healing.loop.wires : -1 +provider.STEP.OCC.healing.split.face : -1 +provider.STEP.OCC.healing.auto.correct.precision : 1 +provider.STEP.OCC.healing.modify.topology : 0 +provider.STEP.OCC.healing.modify.geometry : 1 +provider.STEP.OCC.healing.closed.wire : 1 +provider.STEP.OCC.healing.preference.pcurve : 1 +provider.STEP.OCC.healing.reorder.edges : -1 +provider.STEP.OCC.healing.remove.small.edges : -1 +provider.STEP.OCC.healing.connected.edges : -1 +provider.STEP.OCC.healing.edge.curves : -1 +provider.STEP.OCC.healing.add.degenerated.edges : -1 +provider.STEP.OCC.healing.add.lacking.edges : -1 +provider.STEP.OCC.healing.selfintersection : -1 +provider.STEP.OCC.healing.remove.loop : -1 +provider.STEP.OCC.healing.reversed2d : -1 +provider.STEP.OCC.healing.remove.pcurve : -1 +provider.STEP.OCC.healing.remove.curve3d : -1 +provider.STEP.OCC.healing.add.pcurve : -1 +provider.STEP.OCC.healing.add.curve3d : -1 +provider.STEP.OCC.healing.correct.order.in.seam : -1 +provider.STEP.OCC.healing.shifted : -1 +provider.STEP.OCC.healing.edge.same.parameter : 0 +provider.STEP.OCC.healing.notched.edges : -1 +provider.STEP.OCC.healing.tail : 0 +provider.STEP.OCC.healing.max.tail.angle : 0 +provider.STEP.OCC.healing.max.tail.width : -1 +provider.STEP.OCC.healing.selfintersecting.edge : -1 +provider.STEP.OCC.healing.intersecting.edges : -1 +provider.STEP.OCC.healing.nonadjacent.intersecting.edges : -1 +provider.STEP.OCC.healing.vertex.position : 0 +provider.STEP.OCC.healing.vertex.tolerance : -1 +)OCCT_A4"; +} + +static void ExpectConfiguration(const TCollection_AsciiString& theActual, + const TCollection_AsciiString& theExpected) +{ + EXPECT_TRUE(SameConfiguration(theExpected, theActual)); +} +} // namespace + +// de_wrapper/configuration/A1: provider values can be changed to one and saved stably. +TEST(DE_Wrapper_Configuration_Test, DeWrapperConfiguration_A1_ChangeToOne) +{ + occ::handle aWrapper = NewWrapper(); + const TCollection_AsciiString anOldConfiguration = aWrapper->Save(); + const TCollection_AsciiString aChangedConfiguration = + ChangeProviderValues(anOldConfiguration, "1"); + ASSERT_TRUE(aWrapper->Load(aChangedConfiguration)); + ExpectConfiguration(aChangedConfiguration, aWrapper->Save()); +} + +// de_wrapper/configuration/A2: provider values can be changed to zero and saved stably. +TEST(DE_Wrapper_Configuration_Test, DeWrapperConfiguration_A2_ChangeToZero) +{ + occ::handle aWrapper = NewWrapper(); + const TCollection_AsciiString anOldConfiguration = aWrapper->Save(); + const TCollection_AsciiString aChangedConfiguration = + ChangeProviderValues(anOldConfiguration, "0"); + ASSERT_TRUE(aWrapper->Load(aChangedConfiguration)); + ExpectConfiguration(aChangedConfiguration, aWrapper->Save()); +} + +// de_wrapper/configuration/A3: the initial configuration has the expected resource values. +TEST(DE_Wrapper_Configuration_Test, DeWrapperConfiguration_A3_InitialConfiguration) +{ + occ::handle aWrapper = NewWrapper(); + ExpectConfiguration(aWrapper->Save(), TCollection_AsciiString(InitialConfiguration())); +} + +// de_wrapper/configuration/A4: filtering the saved configuration to STEP and IGES is stable. +TEST(DE_Wrapper_Configuration_Test, DeWrapperConfiguration_A4_TwoFormats) +{ + occ::handle aWrapper = NewWrapper(); + NCollection_List aFormats; + aFormats.Append("STEP"); + aFormats.Append("IGES"); + ExpectConfiguration(aWrapper->Save(true, aFormats), + TCollection_AsciiString(TwoFormatsConfiguration())); +} + +// de_wrapper/configuration/A5: loading an empty configuration preserves defaults. +TEST(DE_Wrapper_Configuration_Test, DeWrapperConfiguration_A5_EmptyLoad) +{ + occ::handle aWrapper = NewWrapper(); + const TCollection_AsciiString anOldConfiguration = aWrapper->Save(); + ASSERT_TRUE(aWrapper->Load("")); + ExpectConfiguration(aWrapper->Save(), anOldConfiguration); +} diff --git a/src/DataExchange/TKDE/GTests/FILES.cmake b/src/DataExchange/TKDE/GTests/FILES.cmake index b67b61223c..212177c3b6 100644 --- a/src/DataExchange/TKDE/GTests/FILES.cmake +++ b/src/DataExchange/TKDE/GTests/FILES.cmake @@ -2,4 +2,5 @@ set(OCCT_TKDE_GTests_FILES_LOCATION "${CMAKE_CURRENT_LIST_DIR}") set(OCCT_TKDE_GTests_FILES + DE_Wrapper_Configuration_Test.cxx ) diff --git a/src/DataExchange/TKDECascade/DEBREP/DEBREP_ConfigurationNode.cxx b/src/DataExchange/TKDECascade/DEBREP/DEBREP_ConfigurationNode.cxx index 66a7a97b5a..4708fb1ce7 100644 --- a/src/DataExchange/TKDECascade/DEBREP/DEBREP_ConfigurationNode.cxx +++ b/src/DataExchange/TKDECascade/DEBREP/DEBREP_ConfigurationNode.cxx @@ -147,6 +147,13 @@ bool DEBREP_ConfigurationNode::IsExportSupported() const //================================================================================================= +bool DEBREP_ConfigurationNode::IsStreamSupported() const +{ + return true; +} + +//================================================================================================= + TCollection_AsciiString DEBREP_ConfigurationNode::GetFormat() const { return TCollection_AsciiString("BREP"); diff --git a/src/DataExchange/TKDECascade/DEBREP/DEBREP_ConfigurationNode.hxx b/src/DataExchange/TKDECascade/DEBREP/DEBREP_ConfigurationNode.hxx index fe7c2fee70..a39e4bf483 100644 --- a/src/DataExchange/TKDECascade/DEBREP/DEBREP_ConfigurationNode.hxx +++ b/src/DataExchange/TKDECascade/DEBREP/DEBREP_ConfigurationNode.hxx @@ -66,6 +66,10 @@ public: //! @return true if export is supported Standard_EXPORT bool IsExportSupported() const override; + //! Checks the stream support + //! @return true if streams are supported + Standard_EXPORT bool IsStreamSupported() const override; + //! Gets CAD format name of associated provider //! @return provider CAD format Standard_EXPORT TCollection_AsciiString GetFormat() const override; diff --git a/src/DataExchange/TKDECascade/DEBREP/DEBREP_Provider.cxx b/src/DataExchange/TKDECascade/DEBREP/DEBREP_Provider.cxx index cb6324bf7c..d32bdf828c 100644 --- a/src/DataExchange/TKDECascade/DEBREP/DEBREP_Provider.cxx +++ b/src/DataExchange/TKDECascade/DEBREP/DEBREP_Provider.cxx @@ -16,6 +16,7 @@ #include #include #include +#include #include #include #include @@ -23,8 +24,79 @@ #include #include +#include +#include + IMPLEMENT_STANDARD_RTTIEXT(DEBREP_Provider, DE_Provider) +namespace +{ +static occ::handle ValidateConfigurationNode( + const occ::handle& theNode, + const TCollection_AsciiString& theContext) +{ + if (!DE_ValidationUtils::ValidateConfigurationNode(theNode, + STANDARD_TYPE(DEBREP_ConfigurationNode), + theContext)) + { + return occ::handle(); + } + return occ::down_cast(theNode); +} + +static bool IsAsciiBRepStream(Standard_IStream& theStream) +{ + // A stream passed through DE_Wrapper has already been probed for content. + // Start the actual format probe from the beginning as the provider consumes + // the complete stream during the following read. + theStream.clear(); + theStream.seekg(0); + if (theStream.fail()) + { + return false; + } + + char aHeader[19] = {}; + theStream.read(aHeader, sizeof(aHeader)); + const bool isAscii = theStream.gcount() == sizeof(aHeader) + && ((aHeader[0] == '\n' && aHeader[1] == 'C') + || ::strncmp(aHeader, "DBRep_DrawableShape", sizeof(aHeader)) == 0); + theStream.clear(); + theStream.seekg(0); + return isAscii; +} + +static TopoDS_Shape ShapeFromDocument(const occ::handle& theDocument) +{ + if (theDocument.IsNull()) + { + return TopoDS_Shape(); + } + + occ::handle aShapeTool = XCAFDoc_DocumentTool::ShapeTool(theDocument->Main()); + NCollection_Sequence aLabels; + aShapeTool->GetFreeShapes(aLabels); + if (aLabels.IsEmpty()) + { + return TopoDS_Shape(); + } + + if (aLabels.Length() == 1) + { + return aShapeTool->GetShape(aLabels.First()); + } + + TopoDS_Compound aCompound; + BRep_Builder aBuilder; + aBuilder.MakeCompound(aCompound); + for (int anIndex = 1; anIndex <= aLabels.Length(); ++anIndex) + { + aBuilder.Add(aCompound, aShapeTool->GetShape(aLabels.Value(anIndex))); + } + return aCompound; +} +} // namespace + //================================================================================================= DEBREP_Provider::DEBREP_Provider() = default; @@ -284,6 +356,216 @@ bool DEBREP_Provider::Write(const TCollection_AsciiString& thePath, //================================================================================================= +bool DEBREP_Provider::Read(ReadStreamList& theStreams, + TopoDS_Shape& theShape, + const Message_ProgressRange& theProgress) +{ + const TCollection_AsciiString aContext = "reading stream"; + if (!DE_ValidationUtils::ValidateReadStreamList(theStreams, aContext)) + { + return false; + } + + const TCollection_AsciiString& aFirstKey = theStreams.First().Path; + const TCollection_AsciiString aFullContext = aContext + " " + aFirstKey; + if (ValidateConfigurationNode(GetNode(), aFullContext).IsNull()) + { + return false; + } + + Standard_IStream& aStream = theStreams.First().Stream; + const bool isAscii = IsAsciiBRepStream(aStream); + if (aStream.fail()) + { + Message::SendFail() << "Error in the DEBREP_Provider during " << aFullContext + << ": Cannot seek input stream"; + return false; + } + + if (isAscii) + { + BRepTools::Read(theShape, aStream, BRep_Builder(), theProgress); + } + else + { + BinTools::Read(theShape, aStream, theProgress); + } + const bool isDone = !theShape.IsNull() && !aStream.fail(); + if (!isDone) + { + Message::SendFail() << "Error in the DEBREP_Provider during " << aFullContext + << ": Cannot read from the stream"; + } + return isDone; +} + +//================================================================================================= + +bool DEBREP_Provider::Write(WriteStreamList& theStreams, + const TopoDS_Shape& theShape, + const Message_ProgressRange& theProgress) +{ + const TCollection_AsciiString aContext = "writing stream"; + if (!DE_ValidationUtils::ValidateWriteStreamList(theStreams, aContext)) + { + return false; + } + + const TCollection_AsciiString& aFirstKey = theStreams.First().Path; + const TCollection_AsciiString aFullContext = aContext + " " + aFirstKey; + occ::handle aNode = ValidateConfigurationNode(GetNode(), aFullContext); + if (aNode.IsNull()) + { + return false; + } + + Standard_OStream& aStream = theStreams.First().Stream; + bool isDone = false; + if (aNode->InternalParameters.WriteBinary) + { + if (aNode->InternalParameters.WriteVersionBin + < static_cast(BinTools_FormatVersion_LOWER) + || aNode->InternalParameters.WriteVersionBin + > static_cast(BinTools_FormatVersion_UPPER)) + { + Message::SendFail() << "Error in the DEBREP_Provider during " << aFullContext + << ": Unknown binary format version"; + return false; + } + if (aNode->InternalParameters.WriteNormals + && aNode->InternalParameters.WriteVersionBin < BinTools_FormatVersion_VERSION_4) + { + Message::SendFail() << "Error in the DEBREP_Provider during " << aFullContext + << ": Vertex normals require binary format version 4 or later"; + return false; + } + BinTools::Write(theShape, + aStream, + aNode->InternalParameters.WriteTriangles, + aNode->InternalParameters.WriteNormals, + aNode->InternalParameters.WriteVersionBin, + theProgress); + isDone = !aStream.fail(); + } + else + { + if (aNode->InternalParameters.WriteVersionAscii + < static_cast(TopTools_FormatVersion_LOWER) + || aNode->InternalParameters.WriteVersionAscii + > static_cast(TopTools_FormatVersion_UPPER)) + { + Message::SendFail() << "Error in the DEBREP_Provider during " << aFullContext + << ": Unknown ASCII format version"; + return false; + } + if (aNode->InternalParameters.WriteNormals + && aNode->InternalParameters.WriteVersionAscii < TopTools_FormatVersion_VERSION_3) + { + Message::SendFail() << "Error in the DEBREP_Provider during " << aFullContext + << ": Vertex normals require ascii format version 3 or later"; + return false; + } + BRepTools::Write(theShape, + aStream, + aNode->InternalParameters.WriteTriangles, + aNode->InternalParameters.WriteNormals, + aNode->InternalParameters.WriteVersionAscii, + theProgress); + isDone = !aStream.fail(); + } + if (!isDone) + { + Message::SendFail() << "Error in the DEBREP_Provider during " << aFullContext + << ": Cannot write to the stream"; + } + return isDone; +} + +//================================================================================================= + +bool DEBREP_Provider::Read(ReadStreamList& theStreams, + const occ::handle& theDocument, + const Message_ProgressRange& theProgress) +{ + const TCollection_AsciiString aContext = "reading stream"; + if (!DE_ValidationUtils::ValidateDocument(theDocument, aContext)) + { + return false; + } + + TopoDS_Shape aShape; + if (!Read(theStreams, aShape, theProgress)) + { + return false; + } + + XCAFDoc_DocumentTool::ShapeTool(theDocument->Main())->AddShape(aShape); + return true; +} + +//================================================================================================= + +bool DEBREP_Provider::Write(WriteStreamList& theStreams, + const occ::handle& theDocument, + const Message_ProgressRange& theProgress) +{ + if (theDocument.IsNull()) + { + return false; + } + + const TopoDS_Shape aShape = ShapeFromDocument(theDocument); + if (aShape.IsNull()) + { + Message::SendFail() << "Error in the DEBREP_Provider during writing stream" + << ": Document contains no shapes"; + return false; + } + return Write(theStreams, aShape, theProgress); +} + +//================================================================================================= + +bool DEBREP_Provider::Read(ReadStreamList& theStreams, + const occ::handle& theDocument, + occ::handle&, + const Message_ProgressRange& theProgress) +{ + return Read(theStreams, theDocument, theProgress); +} + +//================================================================================================= + +bool DEBREP_Provider::Write(WriteStreamList& theStreams, + const occ::handle& theDocument, + occ::handle&, + const Message_ProgressRange& theProgress) +{ + return Write(theStreams, theDocument, theProgress); +} + +//================================================================================================= + +bool DEBREP_Provider::Read(ReadStreamList& theStreams, + TopoDS_Shape& theShape, + occ::handle&, + const Message_ProgressRange& theProgress) +{ + return Read(theStreams, theShape, theProgress); +} + +//================================================================================================= + +bool DEBREP_Provider::Write(WriteStreamList& theStreams, + const TopoDS_Shape& theShape, + occ::handle&, + const Message_ProgressRange& theProgress) +{ + return Write(theStreams, theShape, theProgress); +} + +//================================================================================================= + TCollection_AsciiString DEBREP_Provider::GetFormat() const { return TCollection_AsciiString("BREP"); diff --git a/src/DataExchange/TKDECascade/DEBREP/DEBREP_Provider.hxx b/src/DataExchange/TKDECascade/DEBREP/DEBREP_Provider.hxx index d20360a84c..f54ab77945 100644 --- a/src/DataExchange/TKDECascade/DEBREP/DEBREP_Provider.hxx +++ b/src/DataExchange/TKDECascade/DEBREP/DEBREP_Provider.hxx @@ -128,6 +128,70 @@ public: const TopoDS_Shape& theShape, const Message_ProgressRange& theProgress = Message_ProgressRange()) override; + //! Reads a CAD stream, according internal configuration + //! @param[in] theStreams streams to read from + //! @param[out] theShape shape to save result + //! @param[in] theProgress progress indicator + //! @return true if Read operation has ended correctly + Standard_EXPORT bool Read( + ReadStreamList& theStreams, + TopoDS_Shape& theShape, + const Message_ProgressRange& theProgress = Message_ProgressRange()) override; + + //! Writes a CAD stream, according internal configuration + //! @param[in] theStreams streams to write to + //! @param[in] theShape shape to export + //! @param[in] theProgress progress indicator + //! @return true if Write operation has ended correctly + Standard_EXPORT bool Write( + WriteStreamList& theStreams, + const TopoDS_Shape& theShape, + const Message_ProgressRange& theProgress = Message_ProgressRange()) override; + + //! Reads a CAD stream into a document, according internal configuration + //! @param[in] theStreams streams to read from + //! @param[out] theDocument document to save result + //! @param[in] theProgress progress indicator + //! @return true if Read operation has ended correctly + Standard_EXPORT bool Read( + ReadStreamList& theStreams, + const occ::handle& theDocument, + const Message_ProgressRange& theProgress = Message_ProgressRange()) override; + + //! Writes a CAD document to a stream, according internal configuration + //! @param[in] theStreams streams to write to + //! @param[in] theDocument document to export + //! @param[in] theProgress progress indicator + //! @return true if Write operation has ended correctly + Standard_EXPORT bool Write( + WriteStreamList& theStreams, + const occ::handle& theDocument, + const Message_ProgressRange& theProgress = Message_ProgressRange()) override; + + Standard_EXPORT bool Read( + ReadStreamList& theStreams, + const occ::handle& theDocument, + occ::handle& theWS, + const Message_ProgressRange& theProgress = Message_ProgressRange()) override; + + Standard_EXPORT bool Write( + WriteStreamList& theStreams, + const occ::handle& theDocument, + occ::handle& theWS, + const Message_ProgressRange& theProgress = Message_ProgressRange()) override; + + Standard_EXPORT bool Read( + ReadStreamList& theStreams, + TopoDS_Shape& theShape, + occ::handle& theWS, + const Message_ProgressRange& theProgress = Message_ProgressRange()) override; + + Standard_EXPORT bool Write( + WriteStreamList& theStreams, + const TopoDS_Shape& theShape, + occ::handle& theWS, + const Message_ProgressRange& theProgress = Message_ProgressRange()) override; + public: //! Gets CAD format name of associated provider //! @return provider CAD format diff --git a/src/DataExchange/TKDECascade/GTests/DEBREP_Provider_Test.cxx b/src/DataExchange/TKDECascade/GTests/DEBREP_Provider_Test.cxx new file mode 100644 index 0000000000..a97df82b38 --- /dev/null +++ b/src/DataExchange/TKDECascade/GTests/DEBREP_Provider_Test.cxx @@ -0,0 +1,213 @@ +// Copyright (c) 2026 OPEN CASCADE SAS +// +// This file is part of Open CASCADE Technology software library. +// +// This library is free software; you can redistribute it and/or modify it under +// the terms of the GNU Lesser General Public License version 2.1 as published +// by the Free Software Foundation, with special exception defined in the file +// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT +// distribution for complete text of the license and disclaimer of any warranty. +// +// Alternatively, this file may be used under the terms of Open CASCADE +// commercial license or contractual agreement. + +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +#include + +namespace +{ +static TopoDS_Shape MakeSourceShape() +{ + return BRepPrimAPI_MakeBox(10.0, 20.0, 30.0).Shape(); +} + +static std::string MakeAsciiBRep(const TopoDS_Shape& theShape) +{ + std::ostringstream aStream; + BRepTools::Write(theShape, aStream); + EXPECT_TRUE(aStream.good()); + EXPECT_FALSE(aStream.str().empty()); + return aStream.str(); +} + +static int CountSubShapes(const TopoDS_Shape& theShape, const TopAbs_ShapeEnum theType) +{ + int aCount = 0; + for (TopExp_Explorer anExplorer(theShape, theType); anExplorer.More(); anExplorer.Next()) + { + ++aCount; + } + return aCount; +} + +static void ExpectSameShape(const TopoDS_Shape& theExpected, const TopoDS_Shape& theActual) +{ + ASSERT_FALSE(theExpected.IsNull()); + ASSERT_FALSE(theActual.IsNull()); + EXPECT_EQ(theActual.ShapeType(), theExpected.ShapeType()); + EXPECT_EQ(CountSubShapes(theActual, TopAbs_SOLID), CountSubShapes(theExpected, TopAbs_SOLID)); + EXPECT_EQ(CountSubShapes(theActual, TopAbs_SHELL), CountSubShapes(theExpected, TopAbs_SHELL)); + EXPECT_EQ(CountSubShapes(theActual, TopAbs_FACE), CountSubShapes(theExpected, TopAbs_FACE)); + EXPECT_EQ(CountSubShapes(theActual, TopAbs_WIRE), CountSubShapes(theExpected, TopAbs_WIRE)); + EXPECT_EQ(CountSubShapes(theActual, TopAbs_EDGE), CountSubShapes(theExpected, TopAbs_EDGE)); + EXPECT_EQ(CountSubShapes(theActual, TopAbs_VERTEX), CountSubShapes(theExpected, TopAbs_VERTEX)); + + GProp_GProps anExpectedProps; + GProp_GProps anActualProps; + BRepGProp::VolumeProperties(theExpected, anExpectedProps); + BRepGProp::VolumeProperties(theActual, anActualProps); + EXPECT_NEAR(anActualProps.Mass(), anExpectedProps.Mass(), 1.0e-7); +} + +static void BindWrapper(DE_Wrapper& theWrapper) +{ + EXPECT_TRUE(theWrapper.Bind(new DEBREP_ConfigurationNode())); +} +} // namespace + +// de_wrapper/brep/A1: direct BRep write followed by wrapper stream read. +TEST(DEBREP_Provider_Test, DEWrapper_Brep_A1_ShapeRoundTrip) +{ + const TopoDS_Shape aFirstShape = MakeSourceShape(); + const std::string aContent = MakeAsciiBRep(aFirstShape); + + std::istringstream aInput(aContent); + DE_Provider::ReadStreamList aReadStreams; + aReadStreams.Append(DE_Provider::ReadStreamNode("source.brep", aInput)); + + DE_Wrapper aWrapper; + BindWrapper(aWrapper); + TopoDS_Shape aSecondShape; + ASSERT_TRUE(aWrapper.Read(aReadStreams, aSecondShape)); + ExpectSameShape(aFirstShape, aSecondShape); +} + +// de_wrapper/brep/A2: wrapper document write followed by direct BRep read. +TEST(DEBREP_Provider_Test, DEWrapper_Brep_A2_DocumentWrite) +{ + const TopoDS_Shape aFirstShape = MakeSourceShape(); + occ::handle anApplication = new TDocStd_Application(); + occ::handle aDocument; + anApplication->NewDocument("BinXCAF", aDocument); + ASSERT_FALSE(aDocument.IsNull()); + XCAFDoc_DocumentTool::ShapeTool(aDocument->Main())->AddShape(aFirstShape); + + std::ostringstream aOutput; + DE_Provider::WriteStreamList aWriteStreams; + aWriteStreams.Append(DE_Provider::WriteStreamNode("document.brep", aOutput)); + + DE_Wrapper aWrapper; + BindWrapper(aWrapper); + ASSERT_TRUE(aWrapper.Write(aWriteStreams, aDocument)); + ASSERT_FALSE(aOutput.str().empty()); + + std::istringstream aInput(aOutput.str()); + DE_Provider::ReadStreamList aReadStreams; + aReadStreams.Append(DE_Provider::ReadStreamNode("document.brep", aInput)); + occ::handle aProvider = new DEBREP_Provider(new DEBREP_ConfigurationNode()); + TopoDS_Shape aSecondShape; + ASSERT_TRUE(aProvider->Read(aReadStreams, aSecondShape)); + ExpectSameShape(aFirstShape, aSecondShape); +} + +// de_wrapper/brep/A3: wrapper shape write followed by wrapper document read. +TEST(DEBREP_Provider_Test, DEWrapper_Brep_A3_DocumentRead) +{ + const TopoDS_Shape aFirstShape = MakeSourceShape(); + std::ostringstream aOutput; + DE_Provider::WriteStreamList aWriteStreams; + aWriteStreams.Append(DE_Provider::WriteStreamNode("shape.brep", aOutput)); + + DE_Wrapper aWrapper; + BindWrapper(aWrapper); + ASSERT_TRUE(aWrapper.Write(aWriteStreams, aFirstShape)); + ASSERT_FALSE(aOutput.str().empty()); + + std::istringstream aInput(aOutput.str()); + DE_Provider::ReadStreamList aReadStreams; + aReadStreams.Append(DE_Provider::ReadStreamNode("shape.brep", aInput)); + occ::handle anApplication = new TDocStd_Application(); + occ::handle aDocument; + anApplication->NewDocument("BinXCAF", aDocument); + ASSERT_TRUE(aWrapper.Read(aReadStreams, aDocument)); + + NCollection_Sequence aLabels; + XCAFDoc_DocumentTool::ShapeTool(aDocument->Main())->GetFreeShapes(aLabels); + ASSERT_EQ(aLabels.Length(), 1); + ExpectSameShape(aFirstShape, + XCAFDoc_DocumentTool::ShapeTool(aDocument->Main())->GetShape(aLabels.First())); +} + +// de_wrapper/brep/A4: wrapper shape stream read/write/read round trip. +TEST(DEBREP_Provider_Test, DEWrapper_Brep_A4_ShapeRoundTrip) +{ + const TopoDS_Shape aFirstShape = MakeSourceShape(); + const std::string aContent = MakeAsciiBRep(aFirstShape); + DE_Wrapper aWrapper; + BindWrapper(aWrapper); + + std::istringstream aFirstInput(aContent); + DE_Provider::ReadStreamList aFirstReadStreams; + aFirstReadStreams.Append(DE_Provider::ReadStreamNode("source.brep", aFirstInput)); + TopoDS_Shape aReadShape; + ASSERT_TRUE(aWrapper.Read(aFirstReadStreams, aReadShape)); + + std::ostringstream aOutput; + DE_Provider::WriteStreamList aWriteStreams; + aWriteStreams.Append(DE_Provider::WriteStreamNode("roundtrip.brep", aOutput)); + ASSERT_TRUE(aWrapper.Write(aWriteStreams, aReadShape)); + + std::istringstream aSecondInput(aOutput.str()); + DE_Provider::ReadStreamList aSecondReadStreams; + aSecondReadStreams.Append(DE_Provider::ReadStreamNode("roundtrip.brep", aSecondInput)); + TopoDS_Shape aSecondShape; + ASSERT_TRUE(aWrapper.Read(aSecondReadStreams, aSecondShape)); + ExpectSameShape(aFirstShape, aSecondShape); +} + +TEST(DEBREP_Provider_Test, StreamWriteRejectsNormalsForOldVersions) +{ + const TopoDS_Shape aShape = MakeSourceShape(); + + { + occ::handle aNode = new DEBREP_ConfigurationNode(); + aNode->InternalParameters.WriteVersionBin = BinTools_FormatVersion_VERSION_3; + occ::handle aProvider = new DEBREP_Provider(aNode); + std::ostringstream aOutput; + DE_Provider::WriteStreamList aStreams; + aStreams.Append(DE_Provider::WriteStreamNode("old-version.brep", aOutput)); + EXPECT_FALSE(aProvider->Write(aStreams, aShape)); + } + + { + occ::handle aNode = new DEBREP_ConfigurationNode(); + aNode->InternalParameters.WriteBinary = false; + aNode->InternalParameters.WriteVersionAscii = TopTools_FormatVersion_VERSION_2; + occ::handle aProvider = new DEBREP_Provider(aNode); + std::ostringstream aOutput; + DE_Provider::WriteStreamList aStreams; + aStreams.Append(DE_Provider::WriteStreamNode("old-version.brep", aOutput)); + EXPECT_FALSE(aProvider->Write(aStreams, aShape)); + } +} diff --git a/src/DataExchange/TKDECascade/GTests/FILES.cmake b/src/DataExchange/TKDECascade/GTests/FILES.cmake index 49cd9243a3..6f1e4534b4 100644 --- a/src/DataExchange/TKDECascade/GTests/FILES.cmake +++ b/src/DataExchange/TKDECascade/GTests/FILES.cmake @@ -2,4 +2,5 @@ set(OCCT_TKDECascade_GTests_FILES_LOCATION "${CMAKE_CURRENT_LIST_DIR}") set(OCCT_TKDECascade_GTests_FILES + DEBREP_Provider_Test.cxx ) diff --git a/src/DataExchange/TKDEGLTF/DEGLTF/DEGLTF_ConfigurationNode.cxx b/src/DataExchange/TKDEGLTF/DEGLTF/DEGLTF_ConfigurationNode.cxx index 0fca61f6ee..5db596eb19 100644 --- a/src/DataExchange/TKDEGLTF/DEGLTF/DEGLTF_ConfigurationNode.cxx +++ b/src/DataExchange/TKDEGLTF/DEGLTF/DEGLTF_ConfigurationNode.cxx @@ -365,6 +365,13 @@ bool DEGLTF_ConfigurationNode::IsExportSupported() const //================================================================================================= +bool DEGLTF_ConfigurationNode::IsStreamSupported() const +{ + return true; +} + +//================================================================================================= + TCollection_AsciiString DEGLTF_ConfigurationNode::GetFormat() const { return TCollection_AsciiString("GLTF"); diff --git a/src/DataExchange/TKDEGLTF/DEGLTF/DEGLTF_ConfigurationNode.hxx b/src/DataExchange/TKDEGLTF/DEGLTF/DEGLTF_ConfigurationNode.hxx index fee52effa8..d36fb9d91d 100644 --- a/src/DataExchange/TKDEGLTF/DEGLTF/DEGLTF_ConfigurationNode.hxx +++ b/src/DataExchange/TKDEGLTF/DEGLTF/DEGLTF_ConfigurationNode.hxx @@ -66,6 +66,10 @@ public: //! @return true if export is supported Standard_EXPORT bool IsExportSupported() const override; + //! Checks the stream support + //! @return true if streams are supported + Standard_EXPORT bool IsStreamSupported() const override; + //! Gets CAD format name of associated provider //! @return provider CAD format Standard_EXPORT TCollection_AsciiString GetFormat() const override; diff --git a/src/DataExchange/TKDEGLTF/DEGLTF/DEGLTF_Provider.cxx b/src/DataExchange/TKDEGLTF/DEGLTF/DEGLTF_Provider.cxx index eee53fce30..5543ec52e2 100644 --- a/src/DataExchange/TKDEGLTF/DEGLTF/DEGLTF_Provider.cxx +++ b/src/DataExchange/TKDEGLTF/DEGLTF/DEGLTF_Provider.cxx @@ -238,6 +238,100 @@ bool DEGLTF_Provider::Write(const TCollection_AsciiString& thePath, //================================================================================================= +bool DEGLTF_Provider::Read(ReadStreamList& theStreams, + const occ::handle& theDocument, + occ::handle& theWS, + const Message_ProgressRange& theProgress) +{ + (void)theWS; + return Read(theStreams, theDocument, theProgress); +} + +//================================================================================================= + +bool DEGLTF_Provider::Read(ReadStreamList& theStreams, + TopoDS_Shape& theShape, + occ::handle& theWS, + const Message_ProgressRange& theProgress) +{ + (void)theWS; + return Read(theStreams, theShape, theProgress); +} + +//================================================================================================= + +bool DEGLTF_Provider::Read(ReadStreamList& theStreams, + const occ::handle& theDocument, + const Message_ProgressRange& theProgress) +{ + const TCollection_AsciiString aContext = "reading stream"; + if (!DE_ValidationUtils::ValidateReadStreamList(theStreams, aContext)) + { + return false; + } + + const TCollection_AsciiString& aFirstKey = theStreams.First().Path; + const TCollection_AsciiString aFullContext = aContext + " " + aFirstKey; + if (!DE_ValidationUtils::ValidateDocument(theDocument, aFullContext) + || !DE_ValidationUtils::ValidateConfigurationNode(GetNode(), + STANDARD_TYPE(DEGLTF_ConfigurationNode), + aFullContext)) + { + return false; + } + + occ::handle aNode = occ::down_cast(GetNode()); + RWGltf_CafReader aReader; + aReader.SetStreamInput(true); + aReader.SetDocument(theDocument); + SetReaderParameters(aReader, aNode); + XCAFDoc_DocumentTool::SetLengthUnit(theDocument, + aNode->GlobalParameters.LengthUnit, + UnitsMethods_LengthUnit_Millimeter); + if (!aReader.Perform(theStreams.First().Stream, theProgress, aFirstKey)) + { + Message::SendFail() << "Error in the DEGLTF_Provider during reading stream " << aFirstKey; + return false; + } + return true; +} + +//================================================================================================= + +bool DEGLTF_Provider::Read(ReadStreamList& theStreams, + TopoDS_Shape& theShape, + const Message_ProgressRange& theProgress) +{ + const TCollection_AsciiString aContext = "reading stream"; + if (!DE_ValidationUtils::ValidateReadStreamList(theStreams, aContext)) + { + return false; + } + + const TCollection_AsciiString& aFirstKey = theStreams.First().Path; + const TCollection_AsciiString aFullContext = aContext + " " + aFirstKey; + if (!DE_ValidationUtils::ValidateConfigurationNode(GetNode(), + STANDARD_TYPE(DEGLTF_ConfigurationNode), + aFullContext)) + { + return false; + } + + occ::handle aNode = occ::down_cast(GetNode()); + RWGltf_CafReader aReader; + aReader.SetStreamInput(true); + SetReaderParameters(aReader, aNode); + if (!aReader.Perform(theStreams.First().Stream, theProgress, aFirstKey)) + { + Message::SendFail() << "Error in the DEGLTF_Provider during reading stream " << aFirstKey; + return false; + } + theShape = aReader.SingleShape(); + return !theShape.IsNull(); +} + +//================================================================================================= + TCollection_AsciiString DEGLTF_Provider::GetFormat() const { return TCollection_AsciiString("GLTF"); diff --git a/src/DataExchange/TKDEGLTF/DEGLTF/DEGLTF_Provider.hxx b/src/DataExchange/TKDEGLTF/DEGLTF/DEGLTF_Provider.hxx index acfcb11fbc..c07cfd52f9 100644 --- a/src/DataExchange/TKDEGLTF/DEGLTF/DEGLTF_Provider.hxx +++ b/src/DataExchange/TKDEGLTF/DEGLTF/DEGLTF_Provider.hxx @@ -130,6 +130,32 @@ public: const TopoDS_Shape& theShape, const Message_ProgressRange& theProgress = Message_ProgressRange()) override; + //! Reads streams according to internal configuration. + Standard_EXPORT bool Read( + ReadStreamList& theStreams, + const occ::handle& theDocument, + occ::handle& theWS, + const Message_ProgressRange& theProgress = Message_ProgressRange()) override; + + //! Reads streams according to internal configuration. + Standard_EXPORT bool Read( + ReadStreamList& theStreams, + TopoDS_Shape& theShape, + occ::handle& theWS, + const Message_ProgressRange& theProgress = Message_ProgressRange()) override; + + //! Reads streams according to internal configuration. + Standard_EXPORT bool Read( + ReadStreamList& theStreams, + const occ::handle& theDocument, + const Message_ProgressRange& theProgress = Message_ProgressRange()) override; + + //! Reads streams according to internal configuration. + Standard_EXPORT bool Read( + ReadStreamList& theStreams, + TopoDS_Shape& theShape, + const Message_ProgressRange& theProgress = Message_ProgressRange()) override; + public: //! Gets CAD format name of associated provider //! @return provider CAD format diff --git a/src/DataExchange/TKDEGLTF/GTests/DEGLTF_Provider_Test.cxx b/src/DataExchange/TKDEGLTF/GTests/DEGLTF_Provider_Test.cxx new file mode 100644 index 0000000000..81d42b6eb1 --- /dev/null +++ b/src/DataExchange/TKDEGLTF/GTests/DEGLTF_Provider_Test.cxx @@ -0,0 +1,426 @@ +// Copyright (c) 2026 OPEN CASCADE SAS +// +// This file is part of Open CASCADE Technology software library. +// +// This library is free software; you can redistribute it and/or modify it under +// the terms of the GNU Lesser General Public License version 2.1 as published +// by the Free Software Foundation, with special exception defined in the file +// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT +// distribution for complete text of the license and disclaimer of any warranty. +// +// Alternatively, this file may be used under the terms of Open CASCADE +// commercial license or contractual agreement. + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#include +#include +#include +#include + +#include + +namespace +{ +static int CountShapeElements(const TopoDS_Shape& theShape, const TopAbs_ShapeEnum theType) +{ + int aCount = 0; + for (TopExp_Explorer anExplorer(theShape, theType); anExplorer.More(); anExplorer.Next()) + { + ++aCount; + } + return aCount; +} + +static int CountTriangulationTriangles(const TopoDS_Shape& theShape) +{ + int aCount = 0; + for (TopExp_Explorer anExplorer(theShape, TopAbs_FACE); anExplorer.More(); anExplorer.Next()) + { + TopLoc_Location aLocation; + const occ::handle aTriangulation = + BRep_Tool::Triangulation(TopoDS::Face(anExplorer.Current()), aLocation); + if (!aTriangulation.IsNull()) + { + aCount += aTriangulation->NbTriangles(); + } + } + return aCount; +} + +static int CountTriangulationNodes(const TopoDS_Shape& theShape) +{ + int aCount = 0; + for (TopExp_Explorer anExplorer(theShape, TopAbs_FACE); anExplorer.More(); anExplorer.Next()) + { + TopLoc_Location aLocation; + const occ::handle aTriangulation = + BRep_Tool::Triangulation(TopoDS::Face(anExplorer.Current()), aLocation); + if (!aTriangulation.IsNull()) + { + aCount += aTriangulation->NbNodes(); + } + } + return aCount; +} + +static void WriteFloat(NCollection_Buffer& theBuffer, const size_t theOffset, const float theValue) +{ + std::memcpy(theBuffer.ChangeData() + theOffset, &theValue, sizeof(theValue)); +} + +static void WriteUint32(NCollection_Buffer& theBuffer, + const size_t theOffset, + const uint32_t theValue) +{ + std::memcpy(theBuffer.ChangeData() + theOffset, &theValue, sizeof(theValue)); +} + +static void WriteMeshData(NCollection_Buffer& theBuffer, + const size_t thePositionOffset, + const size_t theNormalOffset, + const size_t theTexCoordOffset, + const size_t theIndexOffset, + const bool theIsInterleaved) +{ + for (int anIndex = 0; anIndex < 24; ++anIndex) + { + const float aX = (anIndex & 1) != 0 ? 1.0f : -1.0f; + const float aY = (anIndex & 2) != 0 ? 1.0f : -1.0f; + const float aZ = (anIndex & 4) != 0 ? 1.0f : -1.0f; + const size_t aPosition = + thePositionOffset + (theIsInterleaved ? size_t(anIndex) * 24 : size_t(anIndex) * 12); + const size_t aNormal = + theIsInterleaved ? aPosition + 12 : theNormalOffset + size_t(anIndex) * 12; + WriteFloat(theBuffer, aPosition, aX); + WriteFloat(theBuffer, aPosition + 4, aY); + WriteFloat(theBuffer, aPosition + 8, aZ); + WriteFloat(theBuffer, aNormal, 0.0f); + WriteFloat(theBuffer, aNormal + 4, 0.0f); + WriteFloat(theBuffer, aNormal + 8, 1.0f); + + if (!theIsInterleaved) + { + const size_t aTexCoord = theTexCoordOffset + size_t(anIndex) * 8; + WriteFloat(theBuffer, aTexCoord, anIndex % 2 == 0 ? 0.0f : 1.0f); + WriteFloat(theBuffer, aTexCoord + 4, anIndex % 4 < 2 ? 0.0f : 1.0f); + } + } + + for (int anIndex = 0; anIndex < 36; ++anIndex) + { + const uint16_t aVertex = static_cast(anIndex % 24); + std::memcpy(theBuffer.ChangeData() + theIndexOffset + size_t(anIndex) * sizeof(aVertex), + &aVertex, + sizeof(aVertex)); + } +} + +static occ::handle MakeEmbeddedTextureBuffer() +{ + // A valid 1x1 PNG kept in the same buffer as the mesh data. + static const uint8_t anImage[] = { + 0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a, 0x00, 0x00, 0x00, 0x0d, 0x49, 0x48, + 0x44, 0x52, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x08, 0x04, 0x00, 0x00, + 0x00, 0xb5, 0x1c, 0x0c, 0x02, 0x00, 0x00, 0x00, 0x0b, 0x49, 0x44, 0x41, 0x54, 0x78, + 0xda, 0x63, 0x64, 0x00, 0x01, 0x00, 0x00, 0x05, 0x00, 0x01, 0x0d, 0x0a, 0x2d, 0xb4, + 0x00, 0x00, 0x00, 0x00, 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82}; + const size_t anImageOffset = 840; + occ::handle aBuffer = + new NCollection_Buffer(NCollection_BaseAllocator::CommonBaseAllocator(), + anImageOffset + sizeof(anImage)); + WriteMeshData(*aBuffer, 0, 288, 576, 768, false); + std::memcpy(aBuffer->ChangeData() + anImageOffset, anImage, sizeof(anImage)); + return aBuffer; +} + +static TCollection_AsciiString MakeEmbeddedTextureJson(const NCollection_Buffer& theBuffer, + const bool theWithDataUri) +{ + const size_t anImageOffset = 840; + + TCollection_AsciiString aJson = + R"({"asset":{"version":"2.0"},"scene":0,"scenes":[{"nodes":[0]}],)" + R"("nodes":[{"mesh":0,"name":"Cube"}],)" + R"("materials":[{"name":"Material","pbrMetallicRoughness":{"baseColorTexture":{"index":0,"texCoord":0}}}],)" + R"("meshes":[{"name":"Cube","primitives":[{"attributes":{"POSITION":0,"NORMAL":1,"TEXCOORD_0":2},"indices":3,"material":0}]}],)" + R"("textures":[{"source":0}],"images":[{"bufferView":4,"mimeType":"image/png","name":"Embedded"}],)" + R"("accessors":[{"bufferView":0,"componentType":5126,"count":24,"type":"VEC3"},)" + R"({"bufferView":1,"componentType":5126,"count":24,"type":"VEC3"},)" + R"({"bufferView":2,"componentType":5126,"count":24,"type":"VEC2"},)" + R"({"bufferView":3,"componentType":5123,"count":36,"type":"SCALAR"}],)" + R"("bufferViews":[{"buffer":0,"byteLength":288,"byteOffset":0},)" + R"({"buffer":0,"byteLength":288,"byteOffset":288},)" + R"({"buffer":0,"byteLength":192,"byteOffset":576},)" + R"({"buffer":0,"byteLength":72,"byteOffset":768},)" + R"({"buffer":0,"byteLength":)"; + aJson += static_cast(theBuffer.Size() - anImageOffset); + aJson += R"(,"byteOffset":)"; + aJson += static_cast(anImageOffset); + aJson += R"(}],"buffers":[{"byteLength":)"; + aJson += static_cast(theBuffer.Size()); + if (theWithDataUri) + { + aJson += R"(,"uri":"data:application/octet-stream;base64,)"; + aJson += FSD_Base64::Encode(theBuffer.Data(), theBuffer.Size()); + aJson += "\""; + } + aJson += R"(}]})"; + return aJson; +} + +static TCollection_AsciiString MakeEmbeddedTextureGltf() +{ + const occ::handle aBuffer = MakeEmbeddedTextureBuffer(); + return MakeEmbeddedTextureJson(*aBuffer, true); +} + +static TCollection_AsciiString MakeInterleavedJson(const bool theWithDataUri) +{ + NCollection_Buffer aBuffer(NCollection_BaseAllocator::CommonBaseAllocator(), 648); + WriteMeshData(aBuffer, 0, 0, 0, 576, true); + + TCollection_AsciiString aJson = + R"({"asset":{"version":"2.0"},"scene":0,"scenes":[{"nodes":[0]}],)" + R"("nodes":[{"children":[1]},{"mesh":0,"name":"Mesh"}],)" + R"("meshes":[{"primitives":[{"attributes":{"NORMAL":1,"POSITION":2},"indices":0,"mode":4}]}],)" + R"("accessors":[{"bufferView":0,"byteOffset":0,"componentType":5123,"count":36,"type":"SCALAR"},)" + R"({"bufferView":1,"byteOffset":0,"componentType":5126,"count":24,"type":"VEC3"},)" + R"({"bufferView":1,"byteOffset":12,"componentType":5126,"count":24,"type":"VEC3"}],)" + R"("bufferViews":[{"buffer":0,"byteOffset":576,"byteLength":72,"target":34963},)" + R"({"buffer":0,"byteOffset":0,"byteLength":576,"byteStride":24,"target":34962}],)" + R"("buffers":[{"byteLength":648)"; + if (theWithDataUri) + { + aJson += R"(,"uri":"data:application/octet-stream;base64,)"; + aJson += FSD_Base64::Encode(aBuffer.Data(), aBuffer.Size()); + aJson += R"("}]})"; + } + else + { + aJson += R"(}]})"; + } + return aJson; +} + +static TCollection_AsciiString MakeInterleavedGltf() +{ + return MakeInterleavedJson(true); +} + +static occ::handle MakeGlb(const TCollection_AsciiString& theJson, + const NCollection_Buffer& theBinary) +{ + const size_t aJsonLength = static_cast(theJson.Length()); + const size_t aJsonPaddedLength = (aJsonLength + 3) & ~size_t(3); + const size_t aJsonChunkOffset = 12; + const size_t aBinaryChunkOffset = aJsonChunkOffset + 8 + aJsonPaddedLength; + const size_t aBinaryOffset = aBinaryChunkOffset + 8; + const size_t aTotalLength = aBinaryOffset + theBinary.Size(); + occ::handle aBuffer = + new NCollection_Buffer(NCollection_BaseAllocator::CommonBaseAllocator(), aTotalLength); + + WriteUint32(*aBuffer, 0, 0x46546c67); // glTF + WriteUint32(*aBuffer, 4, 2); + WriteUint32(*aBuffer, 8, static_cast(aTotalLength)); + WriteUint32(*aBuffer, aJsonChunkOffset, static_cast(aJsonPaddedLength)); + WriteUint32(*aBuffer, aJsonChunkOffset + 4, 0x4e4f534a); // JSON + std::memcpy(aBuffer->ChangeData() + aJsonChunkOffset + 8, theJson.ToCString(), aJsonLength); + std::memset(aBuffer->ChangeData() + aJsonChunkOffset + 8 + aJsonLength, + ' ', + aJsonPaddedLength - aJsonLength); + WriteUint32(*aBuffer, aBinaryChunkOffset, static_cast(theBinary.Size())); + WriteUint32(*aBuffer, aBinaryChunkOffset + 4, 0x004e4942); // BIN\0 + std::memcpy(aBuffer->ChangeData() + aBinaryOffset, theBinary.Data(), theBinary.Size()); + return aBuffer; +} + +static occ::handle MakeInterleavedGlb() +{ + occ::handle aBinary = + new NCollection_Buffer(NCollection_BaseAllocator::CommonBaseAllocator(), 648); + WriteMeshData(*aBinary, 0, 0, 0, 576, true); + return MakeGlb(MakeInterleavedJson(false), *aBinary); +} + +static occ::handle MakeEmbeddedTextureGlb() +{ + const occ::handle aBinary = MakeEmbeddedTextureBuffer(); + return MakeGlb(MakeEmbeddedTextureJson(*aBinary, false), *aBinary); +} + +static TCollection_AsciiString MakePointGltf() +{ + NCollection_Buffer aBuffer(NCollection_BaseAllocator::CommonBaseAllocator(), 12); + WriteFloat(aBuffer, 0, 1.0f); + WriteFloat(aBuffer, 4, 2.0f); + WriteFloat(aBuffer, 8, 3.0f); + + TCollection_AsciiString aJson = + R"({"asset":{"version":"2.0"},"scene":0,"scenes":[{"nodes":[0]}],)" + R"("nodes":[{"mesh":0}],"meshes":[{"primitives":[{"attributes":{"POSITION":0},"mode":0}]}],)" + R"("accessors":[{"bufferView":0,"componentType":5126,"count":1,"type":"VEC3"}],)" + R"("bufferViews":[{"buffer":0,"byteLength":12}],"buffers":[{"byteLength":12,"uri":"data:application/octet-stream;base64,)"; + aJson += FSD_Base64::Encode(aBuffer.Data(), aBuffer.Size()); + aJson += R"("}]})"; + return aJson; +} + +static occ::handle NewDocument() +{ + occ::handle anApplication = new TDocStd_Application(); + occ::handle aDocument; + anApplication->NewDocument("BinXCAF", aDocument); + return aDocument; +} +} // namespace + +// bugs/de_mesh/gltf_read/cubeemb: embedded texture data in a base64 bufferView is accepted from a +// caller-owned stream and the imported mesh keeps its material assignment. +TEST(DEGLTF_Bug_Test, MeshBug_31312_StreamEmbeddedTexture) +{ + occ::handle aProvider = new DEGLTF_Provider(new DEGLTF_ConfigurationNode()); + std::istringstream anInput(MakeEmbeddedTextureGltf().ToCString()); + DE_Provider::ReadStreamList aStreams; + aStreams.Append(DE_Provider::ReadStreamNode("cube.gltf", anInput)); + occ::handle aDocument = NewDocument(); + + ASSERT_TRUE(aProvider->Read(aStreams, aDocument)); + occ::handle aShapeTool = XCAFDoc_DocumentTool::ShapeTool(aDocument->Main()); + NCollection_Sequence aLabels; + aShapeTool->GetFreeShapes(aLabels); + ASSERT_EQ(aLabels.Length(), 1); + + const TopoDS_Shape aShape = aShapeTool->GetShape(aLabels.First()); + ASSERT_FALSE(aShape.IsNull()); + EXPECT_EQ(CountShapeElements(aShape, TopAbs_FACE), 1); + EXPECT_EQ(CountShapeElements(aShape, TopAbs_COMPOUND), 0); + EXPECT_EQ(CountTriangulationTriangles(aShape), 12); + EXPECT_EQ(CountTriangulationNodes(aShape), 24); + + occ::handle aMaterialTool = + XCAFDoc_DocumentTool::VisMaterialTool(aDocument->Main()); + NCollection_Sequence aMaterialLabels; + aMaterialTool->GetMaterials(aMaterialLabels); + ASSERT_EQ(aMaterialLabels.Length(), 1); + occ::handle aMaterial = aMaterialTool->GetMaterial(aMaterialLabels.First()); + ASSERT_FALSE(aMaterial.IsNull()); + EXPECT_FALSE(aMaterial->PbrMaterial().BaseColorTexture.IsNull()); +} + +TEST(DEGLTF_Bug_Test, DEWrapper_StreamRead) +{ + DE_Wrapper aWrapper; + ASSERT_TRUE(aWrapper.Bind(new DEGLTF_ConfigurationNode())); + + std::istringstream anInput(MakeInterleavedGltf().ToCString()); + DE_Provider::ReadStreamList aStreams; + aStreams.Append(DE_Provider::ReadStreamNode("interleaved.gltf", anInput)); + TopoDS_Shape aShape; + + ASSERT_TRUE(aWrapper.Read(aStreams, aShape)); + EXPECT_FALSE(aShape.IsNull()); + EXPECT_EQ(CountShapeElements(aShape, TopAbs_FACE), 1); +} + +TEST(DEGLTF_Bug_Test, MeshStreamPoints) +{ + occ::handle aProvider = new DEGLTF_Provider(new DEGLTF_ConfigurationNode()); + std::istringstream anInput(MakePointGltf().ToCString()); + DE_Provider::ReadStreamList aStreams; + aStreams.Append(DE_Provider::ReadStreamNode("points.gltf", anInput)); + TopoDS_Shape aShape; + + ASSERT_TRUE(aProvider->Read(aStreams, aShape)); + EXPECT_EQ(CountShapeElements(aShape, TopAbs_VERTEX), 1); +} + +TEST(DEGLTF_Bug_Test, MeshBug_31312_GlbStreamEmbeddedTexture) +{ + occ::handle aProvider = new DEGLTF_Provider(new DEGLTF_ConfigurationNode()); + occ::handle aGlb = MakeEmbeddedTextureGlb(); + Standard_ArrayStreamBuffer aStreamBuffer(reinterpret_cast(aGlb->Data()), + aGlb->Size()); + std::istream anInput(&aStreamBuffer); + DE_Provider::ReadStreamList aStreams; + aStreams.Append(DE_Provider::ReadStreamNode("cube.glb", anInput)); + occ::handle aDocument = NewDocument(); + + ASSERT_TRUE(aProvider->Read(aStreams, aDocument)); + occ::handle aMaterialTool = + XCAFDoc_DocumentTool::VisMaterialTool(aDocument->Main()); + NCollection_Sequence aMaterialLabels; + aMaterialTool->GetMaterials(aMaterialLabels); + ASSERT_EQ(aMaterialLabels.Length(), 1); + occ::handle aMaterial = aMaterialTool->GetMaterial(aMaterialLabels.First()); + ASSERT_FALSE(aMaterial.IsNull()); + ASSERT_FALSE(aMaterial->PbrMaterial().BaseColorTexture.IsNull()); + EXPECT_TRUE(aMaterial->PbrMaterial().BaseColorTexture->FilePath().IsEmpty()); + EXPECT_EQ(aMaterial->PbrMaterial().BaseColorTexture->FileOffset(), -1); + EXPECT_NE(aMaterial->PbrMaterial().BaseColorTexture->TextureId().Search("texturebuf://"), -1); +} + +// bugs/de_mesh/gltf_read/boxinterleaved: byteStride is applied to interleaved vertex attributes +// when the glTF document is read from a stream. +TEST(DEGLTF_Bug_Test, MeshBug_31332_StreamInterleavedBuffer) +{ + occ::handle aProvider = new DEGLTF_Provider(new DEGLTF_ConfigurationNode()); + std::istringstream anInput(MakeInterleavedGltf().ToCString()); + DE_Provider::ReadStreamList aStreams; + aStreams.Append(DE_Provider::ReadStreamNode("interleaved.gltf", anInput)); + TopoDS_Shape aShape; + + ASSERT_TRUE(aProvider->Read(aStreams, aShape)); + EXPECT_FALSE(aShape.IsNull()); + EXPECT_EQ(CountShapeElements(aShape, TopAbs_FACE), 1); + EXPECT_EQ(CountShapeElements(aShape, TopAbs_COMPOUND), 1); + EXPECT_EQ(CountTriangulationTriangles(aShape), 12); + EXPECT_EQ(CountTriangulationNodes(aShape), 24); +} + +// The same interleaved regression is also checked in binary glTF to validate seeking within a +// caller-owned stream for the BIN chunk. +TEST(DEGLTF_Bug_Test, MeshBug_31332_GlbStreamInterleavedBuffer) +{ + occ::handle aProvider = new DEGLTF_Provider(new DEGLTF_ConfigurationNode()); + occ::handle aGlb = MakeInterleavedGlb(); + ASSERT_EQ(aGlb->Data()[0], uint8_t('g')); + ASSERT_EQ(aGlb->Data()[1], uint8_t('l')); + ASSERT_EQ(aGlb->Data()[2], uint8_t('T')); + ASSERT_EQ(aGlb->Data()[3], uint8_t('F')); + Standard_ArrayStreamBuffer aStreamBuffer(reinterpret_cast(aGlb->Data()), + aGlb->Size()); + std::istream anInput(&aStreamBuffer); + DE_Provider::ReadStreamList aStreams; + aStreams.Append(DE_Provider::ReadStreamNode("interleaved.glb", anInput)); + TopoDS_Shape aShape; + + ASSERT_TRUE(aProvider->Read(aStreams, aShape)); + EXPECT_FALSE(aShape.IsNull()); + EXPECT_EQ(CountShapeElements(aShape, TopAbs_FACE), 1); + EXPECT_EQ(CountShapeElements(aShape, TopAbs_COMPOUND), 1); + EXPECT_EQ(CountTriangulationTriangles(aShape), 12); + EXPECT_EQ(CountTriangulationNodes(aShape), 24); +} diff --git a/src/DataExchange/TKDEGLTF/GTests/FILES.cmake b/src/DataExchange/TKDEGLTF/GTests/FILES.cmake index 12612060f1..e6bbe57a09 100644 --- a/src/DataExchange/TKDEGLTF/GTests/FILES.cmake +++ b/src/DataExchange/TKDEGLTF/GTests/FILES.cmake @@ -2,4 +2,5 @@ set(OCCT_TKDEGLTF_GTests_FILES_LOCATION "${CMAKE_CURRENT_LIST_DIR}") set(OCCT_TKDEGLTF_GTests_FILES + DEGLTF_Provider_Test.cxx ) diff --git a/src/DataExchange/TKDEGLTF/RWGltf/RWGltf_CafReader.cxx b/src/DataExchange/TKDEGLTF/RWGltf/RWGltf_CafReader.cxx index cd5a5deaa5..8b10e78d4a 100644 --- a/src/DataExchange/TKDEGLTF/RWGltf/RWGltf_CafReader.cxx +++ b/src/DataExchange/TKDEGLTF/RWGltf/RWGltf_CafReader.cxx @@ -177,7 +177,8 @@ RWGltf_CafReader::RWGltf_CafReader() myToSkipLateDataLoading(false), myToKeepLateData(true), myToPrintDebugMessages(false), - myToApplyScale(true) + myToApplyScale(true), + myIsStreamInput(false) { myCoordSysConverter.SetInputLengthUnit(1.0); // glTF defines model in meters myCoordSysConverter.SetInputCoordinateSystem(RWMesh_CoordinateSystem_glTF); @@ -298,6 +299,11 @@ bool RWGltf_CafReader::performMesh(std::istream& theStream, aDoc.SetSkipEmptyNodes(myToSkipEmptyNodes); aDoc.SetLoadAllScenes(myToLoadAllScenes); aDoc.SetMeshNameAsFallback(myUseMeshNameAsFallback); + if (myIsStreamInput) + { + std::shared_ptr aSharedStream(&theStream, [](std::istream*) {}); + aDoc.SetStream(aSharedStream); + } if (!theToProbe) { aDoc.SetAttributeMap(myAttribMap); diff --git a/src/DataExchange/TKDEGLTF/RWGltf/RWGltf_CafReader.hxx b/src/DataExchange/TKDEGLTF/RWGltf/RWGltf_CafReader.hxx index 3d7f1ed32c..ac62486051 100644 --- a/src/DataExchange/TKDEGLTF/RWGltf/RWGltf_CafReader.hxx +++ b/src/DataExchange/TKDEGLTF/RWGltf/RWGltf_CafReader.hxx @@ -53,6 +53,9 @@ public: //! (default) scene will be loaded. void SetLoadAllScenes(bool theToLoadAll) { myToLoadAllScenes = theToLoadAll; } + //! Mark the input as a caller-owned stream so binary buffers can be cached in memory. + void SetStreamInput(bool theIsStream) { myIsStreamInput = theIsStream; } + //! Set flag to use Mesh name in case if Node name is empty, TRUE by default. bool ToUseMeshNameAsFallback() { return myUseMeshNameAsFallback; } @@ -139,6 +142,7 @@ protected: // clang-format on bool myToPrintDebugMessages; //!< flag to print additional debug information bool myToApplyScale; //!< flag to apply non-uniform scaling + bool myIsStreamInput; //!< input is a caller-owned stream NCollection_DataMap* myShapeScaleMap; //!< map of shapes with non-uniform scalings }; diff --git a/src/DataExchange/TKDEGLTF/RWGltf/RWGltf_GltfJsonParser.cxx b/src/DataExchange/TKDEGLTF/RWGltf/RWGltf_GltfJsonParser.cxx index b27d1fd19e..f552585a3a 100644 --- a/src/DataExchange/TKDEGLTF/RWGltf/RWGltf_GltfJsonParser.cxx +++ b/src/DataExchange/TKDEGLTF/RWGltf/RWGltf_GltfJsonParser.cxx @@ -27,6 +27,7 @@ #include #include #include +#include #include #include #include @@ -35,6 +36,8 @@ #include #include +#include +#include #ifdef HAVE_RAPIDJSON namespace @@ -687,6 +690,42 @@ void RWGltf_GltfJsonParser::SetFilePath(const TCollection_AsciiString& theFilePa #ifdef HAVE_RAPIDJSON //================================================================================================= +bool RWGltf_GltfJsonParser::loadStreamBuffer() +{ + if (!myStreamBuffer.IsNull()) + { + return true; + } + if (myStream == nullptr || myBinBodyLen <= 0 + || static_cast(myBinBodyLen) + > static_cast(std::numeric_limits::max())) + { + reportGltfError("Binary buffer has invalid length."); + return false; + } + + myStreamBuffer = new NCollection_Buffer(NCollection_BaseAllocator::CommonBaseAllocator(), + static_cast(myBinBodyLen)); + myStream->clear(); + myStream->seekg(myBinBodyOffset, std::ios_base::beg); + if (myStream->fail()) + { + myStreamBuffer.Nullify(); + reportGltfError("Binary buffer cannot be positioned in stream."); + return false; + } + myStream->read(reinterpret_cast(myStreamBuffer->ChangeData()), myBinBodyLen); + if (!myStream->good()) + { + myStreamBuffer.Nullify(); + reportGltfError("Binary buffer cannot be read from stream."); + return false; + } + return true; +} + +//================================================================================================= + bool RWGltf_GltfJsonParser::gltfParseRoots() { // find glTF root elements for smooth navigation @@ -1350,6 +1389,27 @@ bool RWGltf_GltfJsonParser::gltfParseTexturInGlbBuffer( return false; } + if (myStream != nullptr) + { + if (!loadStreamBuffer()) + { + return false; + } + if (aBuffView.ByteOffset > myBinBodyLen + || aBuffView.ByteLength > myBinBodyLen - aBuffView.ByteOffset) + { + reportGltfError("BufferView '" + theBufferViewId + "' exceeds binary buffer length."); + return false; + } + + occ::handle aSubBuffer = + new RWGltf_SubBuffer(myStreamBuffer, + static_cast(aBuffView.ByteOffset), + static_cast(aBuffView.ByteLength)); + theTexture = new Image_Texture(aSubBuffer, myFilePath + "@" + theBufferViewId); + return true; + } + const int64_t anOffset = myBinBodyOffset + aBuffView.ByteOffset; theTexture = new Image_Texture(myFilePath, anOffset, aBuffView.ByteLength); return true; @@ -2298,9 +2358,21 @@ bool RWGltf_GltfJsonParser::gltfParseBuffer( RWGltf_GltfPrimArrayData& aData = theMeshData->AddPrimArrayData(theType); aData.Accessor = theAccessor; aData.Accessor.ByteStride = aByteStride; - aData.StreamOffset = anOffset; aData.StreamLength = theView.ByteLength; aData.StreamUri = myFilePath; + if (myStream != nullptr) + { + if (!loadStreamBuffer()) + { + return false; + } + aData.StreamData = myStreamBuffer; + aData.StreamOffset = theView.ByteOffset + theAccessor.ByteOffset; + } + else + { + aData.StreamOffset = anOffset; + } return true; } @@ -2519,19 +2591,32 @@ bool RWGltf_GltfJsonParser::fillMeshData( occ::handle aReader = new RWGltf_TriangulationReader(); aReader->SetCoordinateSystemConverter(myCSTrsf); - std::shared_ptr aNewStream; + + if (!aData.StreamData.IsNull()) + { + Standard_ArrayStreamBuffer aStreamBuffer((const char*)aData.StreamData->Data(), + aData.StreamData->Size()); + std::istream aStream(&aStreamBuffer); + aStream.seekg((std::streamoff)aData.StreamOffset, std::ios_base::beg); + if (!aReader->ReadStream(theMeshData, theMeshData, aStream, aData.Accessor, aData.Type)) + { + return false; + } + continue; + } + if (myStream != nullptr) { - aNewStream = myStream; - aNewStream->seekg(aData.StreamOffset); - } - else - { - aNewStream = aFileSystem->OpenIStream(aData.StreamUri, - std::ios::in | std::ios::binary, - aData.StreamOffset); + reportGltfError("Buffer '" + aData.StreamUri + + "' cannot be loaded from caller-owned stream."); + return false; } + std::shared_ptr aNewStream; + aNewStream = aFileSystem->OpenIStream(aData.StreamUri, + std::ios::in | std::ios::binary, + aData.StreamOffset); + if (aNewStream == nullptr) { reportGltfError("Buffer '" + aData.StreamUri + "' isn't defined."); diff --git a/src/DataExchange/TKDEGLTF/RWGltf/RWGltf_GltfJsonParser.hxx b/src/DataExchange/TKDEGLTF/RWGltf/RWGltf_GltfJsonParser.hxx index 5b536035ee..b2a7bea124 100644 --- a/src/DataExchange/TKDEGLTF/RWGltf/RWGltf_GltfJsonParser.hxx +++ b/src/DataExchange/TKDEGLTF/RWGltf/RWGltf_GltfJsonParser.hxx @@ -472,6 +472,9 @@ private: Standard_EXPORT bool fillMeshData( const occ::handle& theMeshData) const; + //! Load the binary body of a caller-owned GLB stream into memory. + Standard_EXPORT bool loadStreamBuffer(); + #endif protected: //! Print message about invalid glTF syntax. @@ -503,6 +506,7 @@ protected: NCollection_DataMap myProbedFiles; NCollection_DataMap> myDecodedBuffers; + occ::handle myStreamBuffer; NCollection_DynamicArray myFaceList; //!< face list for loading triangulation TCollection_AsciiString myFilePath; //!< file path diff --git a/src/DataExchange/TKDESTEP/DESTEP/DESTEP_Provider.cxx b/src/DataExchange/TKDESTEP/DESTEP/DESTEP_Provider.cxx index e5eff0e65d..f976a15d68 100644 --- a/src/DataExchange/TKDESTEP/DESTEP/DESTEP_Provider.cxx +++ b/src/DataExchange/TKDESTEP/DESTEP/DESTEP_Provider.cxx @@ -50,14 +50,12 @@ bool validateNode(const occ::handle& theNode, //! be initialized) //! @param[in] theDocument Target document for length unit setup (optional) //! @param[in] theLengthUnit Length unit for document setup (used only if theDocument is provided) -//! @param[in] theShapeFixParams Shape fix parameters (optional, uses default if not provided) -//! @note Sets up colors, names, layers, properties, metadata, and shape fix parameters +//! @note Sets up colors, names, layers, properties, and metadata void configureSTEPCAFReader(STEPCAFControl_Reader& theReader, const DESTEP_Parameters& theParams, occ::handle& theWS, const occ::handle& theDocument, - double theLengthUnit, - const DE_ShapeFixParameters& theShapeFixParams) + double theLengthUnit) { theReader.Init(theWS); @@ -68,8 +66,6 @@ void configureSTEPCAFReader(STEPCAFControl_Reader& theReader, theReader.SetMetaMode(theParams.ReadMetadata); theReader.SetProductMetaMode(theParams.ReadProductMetadata); - theReader.SetShapeFixParameters(theShapeFixParams); - XCAFDoc_DocumentTool::SetLengthUnit(theDocument, theLengthUnit, UnitsMethods_LengthUnit_Millimeter); @@ -173,8 +169,7 @@ bool DESTEP_Provider::Read(const TCollection_AsciiString& thePath, aNode->InternalParameters, theWS, theDocument, - aNode->GlobalParameters.LengthUnit, - aNode->ShapeFixParameters); + aNode->GlobalParameters.LengthUnit); IFSelect_ReturnStatus aReadStat = IFSelect_RetVoid; DESTEP_Parameters aParams = aNode->InternalParameters; @@ -187,6 +182,8 @@ bool DESTEP_Provider::Read(const TCollection_AsciiString& thePath, return false; } + aReader.SetShapeFixParameters(aNode->ShapeFixParameters); + if (!aReader.Transfer(theDocument, theProgress)) { Message::SendFail() << "Error in the DESTEP_Provider during reading the file " << thePath @@ -294,7 +291,6 @@ bool DESTEP_Provider::Read(const TCollection_AsciiString& thePath, personizeWS(theWS); STEPControl_Reader aReader; aReader.SetWS(theWS); - aReader.SetShapeFixParameters(aNode->ShapeFixParameters); IFSelect_ReturnStatus aReadstat = IFSelect_RetVoid; DESTEP_Parameters aParams = aNode->InternalParameters; aReadstat = aReader.ReadFile(thePath.ToCString(), aParams); @@ -305,6 +301,7 @@ bool DESTEP_Provider::Read(const TCollection_AsciiString& thePath, << "\t: abandon, no model loaded"; return false; } + aReader.SetShapeFixParameters(aNode->ShapeFixParameters); aModel->SetLocalLengthUnit(aNode->GlobalParameters.LengthUnit); if (aReader.TransferRoots(theProgress) <= 0) { @@ -430,16 +427,18 @@ bool DESTEP_Provider::Read(ReadStreamList& theStreams, aNode->InternalParameters, theWS, theDocument, - aNode->GlobalParameters.LengthUnit, - aNode->ShapeFixParameters); + aNode->GlobalParameters.LengthUnit); - bool isOk = aReader.ReadStream(aFirstKey.ToCString(), aStream); + bool isOk = aReader.ReadStream(aFirstKey.ToCString(), aNode->InternalParameters, aStream) + == IFSelect_RetDone; if (!isOk) { Message::SendFail() << "Error: DESTEP_Provider failed to read stream " << aFirstKey; return false; } + aReader.SetShapeFixParameters(aNode->ShapeFixParameters); + return aReader.Transfer(theDocument, theProgress); } @@ -550,15 +549,16 @@ bool DESTEP_Provider::Read(ReadStreamList& theStreams, // Use STEPControl_Reader for shape operations from streams STEPControl_Reader aReader; aReader.SetWS(theWS); - aReader.SetShapeFixParameters(aNode->ShapeFixParameters); // Read from stream using the reader's internal model - IFSelect_ReturnStatus aReadStat = aReader.ReadStream(aFirstKey.ToCString(), aStream); + IFSelect_ReturnStatus aReadStat = + aReader.ReadStream(aFirstKey.ToCString(), aNode->InternalParameters, aStream); if (aReadStat != IFSelect_RetDone) { Message::SendFail() << "Error: DESTEP_Provider failed to read from stream " << aFirstKey; return false; } + aReader.SetShapeFixParameters(aNode->ShapeFixParameters); occ::handle aModel = aReader.StepModel(); aModel->SetLocalLengthUnit(aNode->GlobalParameters.LengthUnit); diff --git a/src/DataExchange/TKDESTEP/GTests/DESTEP_Provider_Test.cxx b/src/DataExchange/TKDESTEP/GTests/DESTEP_Provider_Test.cxx index 343c243625..dc9bb076c5 100644 --- a/src/DataExchange/TKDESTEP/GTests/DESTEP_Provider_Test.cxx +++ b/src/DataExchange/TKDESTEP/GTests/DESTEP_Provider_Test.cxx @@ -15,21 +15,118 @@ #include #include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include +#include #include #include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include +#include +#include #include #include +#include #include +#include #include #include +#include #include #include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include +#include #include +namespace +{ +struct TriangulationStats +{ + int myFaces = 0; + int myNodes = 0; + int myTriangles = 0; +}; + +TriangulationStats getTriangulationStats(const TopoDS_Shape& theShape) +{ + TriangulationStats aStats; + for (TopExp_Explorer anExplorer(theShape, TopAbs_FACE); anExplorer.More(); anExplorer.Next()) + { + ++aStats.myFaces; + TopLoc_Location aLocation; + const occ::handle aTriangulation = + BRep_Tool::Triangulation(TopoDS::Face(anExplorer.Current()), aLocation); + if (!aTriangulation.IsNull()) + { + aStats.myNodes += aTriangulation->NbNodes(); + aStats.myTriangles += aTriangulation->NbTriangles(); + } + } + return aStats; +} + +bool writeReadTessellatedStep(const TopoDS_Shape& theSource, + const DESTEP_Parameters::RWMode_Tessellated theWriteMode, + const DESTEP_Parameters::RWMode_Tessellated theReadMode, + TopoDS_Shape& theResult, + std::string& theContent) +{ + occ::handle aWriteNode = new DESTEP_ConfigurationNode(); + aWriteNode->InternalParameters.WriteSchema = DESTEP_Parameters::WriteMode_StepSchema_AP242DIS; + aWriteNode->InternalParameters.WriteTessellated = theWriteMode; + occ::handle aWriteProvider = new DESTEP_Provider(aWriteNode); + + std::ostringstream aWriteStream; + DE_Provider::WriteStreamList aWriteStreams; + aWriteStreams.Append(DE_Provider::WriteStreamNode("tessellated.step", aWriteStream)); + if (!aWriteProvider->Write(aWriteStreams, theSource)) + { + return false; + } + theContent = aWriteStream.str(); + + occ::handle aReadNode = new DESTEP_ConfigurationNode(); + aReadNode->InternalParameters.ReadTessellated = theReadMode; + occ::handle aReadProvider = new DESTEP_Provider(aReadNode); + + std::istringstream aReadStream(theContent); + DE_Provider::ReadStreamList aReadStreams; + aReadStreams.Append(DE_Provider::ReadStreamNode("tessellated.step", aReadStream)); + return aReadProvider->Read(aReadStreams, theResult); +} +} // namespace + class DESTEP_ProviderTest : public ::testing::Test { protected: @@ -126,6 +223,417 @@ TEST_F(DESTEP_ProviderTest, StreamShapeWriteRead) } } +// Migrated from tests/de_mesh/step_write/B1. The DRAW suite writes and reads +// a meshed box with AP242 tessellation enabled. +TEST_F(DESTEP_ProviderTest, MeshStep_B1_MeshedBox) +{ + const TopoDS_Shape aSource = BRepPrimAPI_MakeBox(1., 1., 1.).Shape(); + BRepMesh_IncrementalMesh aMesh(aSource, 0.1); + (void)aMesh; + + const TriangulationStats aSourceStats = getTriangulationStats(aSource); + EXPECT_EQ(aSourceStats.myFaces, 6); + EXPECT_EQ(aSourceStats.myNodes, 24); + EXPECT_EQ(aSourceStats.myTriangles, 12); + + TopoDS_Shape aResult; + std::string aContent; + ASSERT_TRUE(writeReadTessellatedStep(aSource, + DESTEP_Parameters::RWMode_Tessellated_On, + DESTEP_Parameters::RWMode_Tessellated_On, + aResult, + aContent)); + ASSERT_TRUE(IsValidSTEPContent(aContent)); + + const TriangulationStats aResultStats = getTriangulationStats(aResult); + EXPECT_EQ(aResultStats.myFaces, 6); + EXPECT_EQ(aResultStats.myNodes, 24); + EXPECT_EQ(aResultStats.myTriangles, 12); +} + +// Migrated from tests/de_mesh/step_write/B2. +TEST_F(DESTEP_ProviderTest, MeshStep_B2_MeshedBoxWithVoid) +{ + const TopoDS_Shape anOuterBox = BRepPrimAPI_MakeBox(gp_Pnt(-5., -5., -5.), 10., 10., 10.).Shape(); + const TopoDS_Shape anInnerBox = BRepPrimAPI_MakeBox(gp_Pnt(-3., -3., -3.), 6., 6., 6.).Shape(); + const TopoDS_Shape aSource = BRepAlgoAPI_Cut(anOuterBox, anInnerBox).Shape(); + ASSERT_FALSE(aSource.IsNull()); + BRepMesh_IncrementalMesh aMesh(aSource, 0.1); + (void)aMesh; + + const TriangulationStats aSourceStats = getTriangulationStats(aSource); + EXPECT_EQ(aSourceStats.myFaces, 12); + EXPECT_EQ(aSourceStats.myNodes, 48); + EXPECT_EQ(aSourceStats.myTriangles, 24); + + TopoDS_Shape aResult; + std::string aContent; + ASSERT_TRUE(writeReadTessellatedStep(aSource, + DESTEP_Parameters::RWMode_Tessellated_On, + DESTEP_Parameters::RWMode_Tessellated_On, + aResult, + aContent)); + ASSERT_TRUE(IsValidSTEPContent(aContent)); + + const TriangulationStats aResultStats = getTriangulationStats(aResult); + EXPECT_EQ(aResultStats.myFaces, 12); + EXPECT_EQ(aResultStats.myNodes, 48); + EXPECT_EQ(aResultStats.myTriangles, 24); +} + +// Migrated from tests/de_mesh/step_write/C1. tclean -geom removes the BRep +// surfaces and curves but keeps the polygonal representation for STEP export. +TEST_F(DESTEP_ProviderTest, MeshStep_C1_MeshWithoutBRepGeometry) +{ + const TopoDS_Shape aSource = BRepPrimAPI_MakeBox(1., 1., 1.).Shape(); + BRepMesh_IncrementalMesh aMesh(aSource, 0.1); + (void)aMesh; + BRepTools::CleanGeometry(aSource); + + const TriangulationStats aSourceStats = getTriangulationStats(aSource); + EXPECT_EQ(aSourceStats.myFaces, 6); + EXPECT_EQ(aSourceStats.myNodes, 24); + EXPECT_EQ(aSourceStats.myTriangles, 12); + + TopoDS_Shape aResult; + std::string aContent; + ASSERT_TRUE(writeReadTessellatedStep(aSource, + DESTEP_Parameters::RWMode_Tessellated_On, + DESTEP_Parameters::RWMode_Tessellated_On, + aResult, + aContent)); + ASSERT_TRUE(IsValidSTEPContent(aContent)); + + const TriangulationStats aResultStats = getTriangulationStats(aResult); + EXPECT_EQ(aResultStats.myFaces, 6); + EXPECT_EQ(aResultStats.myNodes, 24); + EXPECT_EQ(aResultStats.myTriangles, 12); +} + +// Migrated from tests/de_mesh/step_write/C2. OnNoBRep writes the tessellated +// representation without the analytic BRep representation. +TEST_F(DESTEP_ProviderTest, MeshStep_C2_TessellatedWithoutBRep) +{ + const TopoDS_Shape aSource = BRepPrimAPI_MakeBox(1., 1., 1.).Shape(); + BRepMesh_IncrementalMesh aMesh(aSource, 0.1); + (void)aMesh; + + const TriangulationStats aSourceStats = getTriangulationStats(aSource); + EXPECT_EQ(aSourceStats.myFaces, 6); + EXPECT_EQ(aSourceStats.myNodes, 24); + EXPECT_EQ(aSourceStats.myTriangles, 12); + + TopoDS_Shape aResult; + std::string aContent; + ASSERT_TRUE(writeReadTessellatedStep(aSource, + DESTEP_Parameters::RWMode_Tessellated_OnNoBRep, + DESTEP_Parameters::RWMode_Tessellated_On, + aResult, + aContent)); + ASSERT_TRUE(IsValidSTEPContent(aContent)); + + const TriangulationStats aResultStats = getTriangulationStats(aResult); + EXPECT_EQ(aResultStats.myFaces, 6); + EXPECT_EQ(aResultStats.myNodes, 0); + EXPECT_EQ(aResultStats.myTriangles, 0); +} + +// Migrated from tests/de_mesh/step_read/B1. The read-side OnNoBRep mode +// intentionally restores only the tessellated representation. +TEST_F(DESTEP_ProviderTest, MeshStep_Read_B1_TessellatedWithoutBRep) +{ + const TopoDS_Shape aSource = BRepPrimAPI_MakeBox(gp_Pnt(-5., -5., -5.), 10., 10., 10.).Shape(); + BRepMesh_IncrementalMesh aMesh(aSource, 0.1); + (void)aMesh; + + const TriangulationStats aSourceStats = getTriangulationStats(aSource); + EXPECT_EQ(aSourceStats.myFaces, 6); + EXPECT_EQ(aSourceStats.myNodes, 24); + EXPECT_EQ(aSourceStats.myTriangles, 12); + + TopoDS_Shape aResult; + std::string aContent; + ASSERT_TRUE(writeReadTessellatedStep(aSource, + DESTEP_Parameters::RWMode_Tessellated_On, + DESTEP_Parameters::RWMode_Tessellated_OnNoBRep, + aResult, + aContent)); + ASSERT_TRUE(IsValidSTEPContent(aContent)); + + const TriangulationStats aResultStats = getTriangulationStats(aResult); + EXPECT_EQ(aResultStats.myFaces, 6); + EXPECT_EQ(aResultStats.myNodes, 0); + EXPECT_EQ(aResultStats.myTriangles, 0); +} + +// bugs/step/bug25989: a self-generated BOP result keeps its volume through a +// STEP round-trip. The DRAW file used stepwrite/writeall/stepread; this test +// uses the stream API of DESTEP_Provider for the same shape transfer. +TEST_F(DESTEP_ProviderTest, StepBug_25989_FusedShapeVolumeRoundTrip) +{ + const TopoDS_Shape aBox = BRepPrimAPI_MakeBox(10.0, 10.0, 10.0).Shape(); + const TopoDS_Shape aCylinder = BRepPrimAPI_MakeCylinder(2.0, 10.0).Shape(); + const TopoDS_Shape aSphere = BRepPrimAPI_MakeSphere(5.0).Shape(); + const TopoDS_Shape aTorus = BRepPrimAPI_MakeTorus(10.0, 2.0).Shape(); + + NCollection_List aPaveArguments; + aPaveArguments.Append(aBox); + aPaveArguments.Append(aCylinder); + aPaveArguments.Append(aSphere); + aPaveArguments.Append(aTorus); + + BOPAlgo_PaveFiller aPaveFiller; + aPaveFiller.SetArguments(aPaveArguments); + aPaveFiller.SetRunParallel(false); + aPaveFiller.Perform(); + ASSERT_FALSE(aPaveFiller.HasErrors()); + + NCollection_List aObjects; + aObjects.Append(aBox); + NCollection_List aTools; + aTools.Append(aCylinder); + aTools.Append(aSphere); + aTools.Append(aTorus); + + BOPAlgo_BOP aFusion; + aFusion.SetArguments(aObjects); + aFusion.SetTools(aTools); + aFusion.SetOperation(BOPAlgo_FUSE); + aFusion.SetRunParallel(false); + aFusion.PerformWithFiller(aPaveFiller); + ASSERT_FALSE(aFusion.HasErrors()); + const TopoDS_Shape aFusionShape = aFusion.Shape(); + ASSERT_FALSE(aFusionShape.IsNull()); + ASSERT_TRUE(BRepCheck_Analyzer(aFusionShape).IsValid()); + + BOPAlgo_CheckerSI aSourceChecker; + NCollection_List aSourceCheckArguments; + aSourceCheckArguments.Append(aFusionShape); + aSourceChecker.SetArguments(aSourceCheckArguments); + aSourceChecker.SetLevelOfCheck(9); + aSourceChecker.SetRunParallel(false); + aSourceChecker.Perform(); + ASSERT_FALSE(aSourceChecker.HasErrors()); + + GProp_GProps aSourceVolume; + BRepGProp::VolumeProperties(aFusionShape, aSourceVolume); + + std::ostringstream aWriteStream; + DE_Provider::WriteStreamList aWriteStreams; + aWriteStreams.Append(DE_Provider::WriteStreamNode("bug25989.step", aWriteStream)); + ASSERT_TRUE(myProvider->Write(aWriteStreams, aFusionShape)); + ASSERT_FALSE(aWriteStream.str().empty()); + + std::istringstream aReadStream(aWriteStream.str()); + DE_Provider::ReadStreamList aReadStreams; + aReadStreams.Append(DE_Provider::ReadStreamNode("bug25989.step", aReadStream)); + TopoDS_Shape aRestoredShape; + ASSERT_TRUE(myProvider->Read(aReadStreams, aRestoredShape)); + ASSERT_FALSE(aRestoredShape.IsNull()); + ASSERT_TRUE(BRepCheck_Analyzer(aRestoredShape).IsValid()); + + BOPAlgo_CheckerSI aRestoredChecker; + NCollection_List aRestoredCheckArguments; + aRestoredCheckArguments.Append(aRestoredShape); + aRestoredChecker.SetArguments(aRestoredCheckArguments); + aRestoredChecker.SetLevelOfCheck(9); + aRestoredChecker.SetRunParallel(false); + aRestoredChecker.Perform(); + ASSERT_FALSE(aRestoredChecker.HasErrors()); + + GProp_GProps aRestoredVolume; + BRepGProp::VolumeProperties(aRestoredShape, aRestoredVolume); + const double aVolumeTolerance = 1.0e-6 * std::max(1.0, std::abs(aSourceVolume.Mass())); + EXPECT_NEAR(aRestoredVolume.Mass(), aSourceVolume.Mass(), aVolumeTolerance); +} + +// bugs/step/bug25694: the default STEP schema is AP214IS. +TEST_F(DESTEP_ProviderTest, StepBug_25694_DefaultSchemaIsAP214IS) +{ + std::ostringstream anOStream; + DE_Provider::WriteStreamList aWriteStreams; + aWriteStreams.Append(DE_Provider::WriteStreamNode("bug25694.step", anOStream)); + ASSERT_TRUE(myProvider->Write(aWriteStreams, myBox)); + + const std::string aStepContent = anOStream.str(); + ASSERT_TRUE(IsValidSTEPContent(aStepContent)); + EXPECT_NE(aStepContent.find("AUTOMOTIVE_DESIGN { 1 0 10303 214 1 1 1 1 }"), std::string::npos); +} + +// bugs/step/bug27070: writing a null shape reports a translation failure. +TEST_F(DESTEP_ProviderTest, StepBug_27070_NullShapeWriteFails) +{ + std::ostringstream anOStream; + DE_Provider::WriteStreamList aWriteStreams; + aWriteStreams.Append(DE_Provider::WriteStreamNode("bug27070.step", anOStream)); + TopoDS_Shape aNullShape; + EXPECT_FALSE(myProvider->Write(aWriteStreams, aNullShape)); +} + +// bugs/step/bug28024: STEP stream import honors the disabled orientation fix +// and preserves the negative orientation of the input triangular face. +TEST_F(DESTEP_ProviderTest, StepBug_28024_DisabledOrientationFix) +{ + const TopoDS_Vertex aV1 = BRepBuilderAPI_MakeVertex(gp_Pnt(0.0, 0.0, 0.0)).Vertex(); + const TopoDS_Vertex aV2 = BRepBuilderAPI_MakeVertex(gp_Pnt(1.0, 0.0, 0.0)).Vertex(); + const TopoDS_Vertex aV3 = BRepBuilderAPI_MakeVertex(gp_Pnt(0.0, 1.0, 0.0)).Vertex(); + const TopoDS_Edge anE1 = BRepBuilderAPI_MakeEdge(aV2, aV1).Edge(); + const TopoDS_Edge anE2 = BRepBuilderAPI_MakeEdge(aV3, aV2).Edge(); + const TopoDS_Edge anE3 = BRepBuilderAPI_MakeEdge(aV1, aV3).Edge(); + + BRepBuilderAPI_MakeWire aWireBuilder; + aWireBuilder.Add(anE1); + aWireBuilder.Add(anE3); + aWireBuilder.Add(anE2); + ASSERT_TRUE(aWireBuilder.IsDone()); + + BRepBuilderAPI_MakeFace aFaceBuilder(gp_Pln(gp_Pnt(0.0, 0.0, 0.0), gp_Dir(0.0, 0.0, 1.0)), + aWireBuilder.Wire(), + false); + ASSERT_TRUE(aFaceBuilder.IsDone()); + const TopoDS_Face aFace = aFaceBuilder.Face(); + + GProp_GProps aSourceProperties; + BRepGProp::SurfaceProperties(aFace, aSourceProperties); + EXPECT_NEAR(aSourceProperties.Mass(), -0.5, 1.0e-6); + + occ::handle aWriteNode = new DESTEP_ConfigurationNode(); + occ::handle aWriteProvider = new DESTEP_Provider(aWriteNode); + std::ostringstream aWriteStream; + DE_Provider::WriteStreamList aWriteStreams; + aWriteStreams.Append(DE_Provider::WriteStreamNode("bug28024.stp", aWriteStream)); + ASSERT_TRUE(aWriteProvider->Write(aWriteStreams, aFace)); + ASSERT_FALSE(aWriteStream.str().empty()); + + occ::handle aReadNode = new DESTEP_ConfigurationNode(); + aReadNode->ShapeFixParameters.FixOrientationMode = DE_ShapeFixParameters::FixMode::NotFix; + occ::handle aReadProvider = new DESTEP_Provider(aReadNode); + + std::istringstream aReadStream(aWriteStream.str()); + DE_Provider::ReadStreamList aReadStreams; + aReadStreams.Append(DE_Provider::ReadStreamNode("bug28024.stp", aReadStream)); + TopoDS_Shape aRestoredShape; + ASSERT_TRUE(aReadProvider->Read(aReadStreams, aRestoredShape)); + TopExp_Explorer aFaceExplorer(aRestoredShape, TopAbs_FACE); + ASSERT_TRUE(aFaceExplorer.More()); + GProp_GProps aRestoredProperties; + BRepGProp::SurfaceProperties(TopoDS::Face(aFaceExplorer.Current()), aRestoredProperties); + EXPECT_NEAR(aRestoredProperties.Mass(), -0.5, 1.0e-6); +} + +// bugs/step/bug23203: STEP stream import preserves the ellipse basis curve of +// a revolved surface, including its local X and Y directions. +TEST_F(DESTEP_ProviderTest, StepBug_23203_EllipseRevolutionAxes) +{ + const gp_Ax2 anEllipseAxis(gp_Pnt(0.0, 0.0, 0.0), gp_Dir(0.0, -1.0, 0.0), gp_Dir(1.0, 0.0, -1.0)); + const occ::handle anEllipse = new Geom_Ellipse(anEllipseAxis, 10.0, 5.0); + const occ::handle aSurface = + new Geom_SurfaceOfRevolution(anEllipse, gp_Ax1(gp_Pnt(0.0, 0.0, 0.0), gp_Dir(0.0, 0.0, 1.0))); + BRepBuilderAPI_MakeFace aFaceBuilder(aSurface, 0.0, 3.0, 0.0, 1.0, Precision::Confusion()); + ASSERT_TRUE(aFaceBuilder.IsDone()); + const TopoDS_Face aFace = aFaceBuilder.Face(); + + std::ostringstream aWriteStream; + DE_Provider::WriteStreamList aWriteStreams; + aWriteStreams.Append(DE_Provider::WriteStreamNode("bug23203.step", aWriteStream)); + ASSERT_TRUE(myProvider->Write(aWriteStreams, aFace)); + ASSERT_FALSE(aWriteStream.str().empty()); + + std::istringstream aReadStream(aWriteStream.str()); + DE_Provider::ReadStreamList aReadStreams; + aReadStreams.Append(DE_Provider::ReadStreamNode("bug23203.step", aReadStream)); + TopoDS_Shape aRestoredShape; + ASSERT_TRUE(myProvider->Read(aReadStreams, aRestoredShape)); + ASSERT_FALSE(aRestoredShape.IsNull()); + + TopExp_Explorer aFaceExplorer(aRestoredShape, TopAbs_FACE); + ASSERT_TRUE(aFaceExplorer.More()); + const TopoDS_Face aRestoredFace = TopoDS::Face(aFaceExplorer.Current()); + const occ::handle aRestoredSurface = BRep_Tool::Surface(aRestoredFace); + const occ::handle aRestoredRevolution = + occ::down_cast(aRestoredSurface); + ASSERT_FALSE(aRestoredRevolution.IsNull()); + const occ::handle aRestoredEllipse = + occ::down_cast(aRestoredRevolution->BasisCurve()); + ASSERT_FALSE(aRestoredEllipse.IsNull()); + + const gp_Dir anExpectedX = anEllipse->XAxis().Direction(); + const gp_Dir anExpectedY = anEllipse->YAxis().Direction(); + const gp_Dir anActualX = aRestoredEllipse->XAxis().Direction(); + const gp_Dir anActualY = aRestoredEllipse->YAxis().Direction(); + EXPECT_NEAR(anActualX.X(), anExpectedX.X(), 1.0e-6); + EXPECT_NEAR(anActualX.Y(), anExpectedX.Y(), 1.0e-6); + EXPECT_NEAR(anActualX.Z(), anExpectedX.Z(), 1.0e-6); + EXPECT_NEAR(anActualY.X(), anExpectedY.X(), 1.0e-6); + EXPECT_NEAR(anActualY.Y(), anExpectedY.Y(), 1.0e-6); + EXPECT_NEAR(anActualY.Z(), anExpectedY.Z(), 1.0e-6); +} + +// bugs/xde/bug27722: STEP round-trip of an ellipse revolved around the Y axis +// retains the original DRAW TODO diagnostics. +TEST_F(DESTEP_ProviderTest, XdeBug_27722_EllipseRevolutionTopology) +{ + const occ::handle anEllipse = + new Geom_Ellipse(gp_Ax2(gp_Pnt(0.0, 0.0, 0.0), gp_Dir(0.0, 0.0, 1.0)), 20.0, 10.0); + const TopoDS_Edge anEdge = BRepBuilderAPI_MakeEdge(anEllipse, 0.0, 0.5 * M_PI).Edge(); + const TopoDS_Shape aSource = + BRepPrimAPI_MakeRevol(anEdge, gp_Ax1(gp_Pnt(0.0, 0.0, 0.0), gp_Dir(0.0, 1.0, 0.0)), 2.0 * M_PI) + .Shape(); + ASSERT_FALSE(aSource.IsNull()); + ASSERT_TRUE(BRepCheck_Analyzer(aSource).IsValid()); + + std::ostringstream aWriteStream; + DE_Provider::WriteStreamList aWriteStreams; + aWriteStreams.Append(DE_Provider::WriteStreamNode("bug27722.step", aWriteStream)); + ASSERT_TRUE(myProvider->Write(aWriteStreams, aSource)); + ASSERT_FALSE(aWriteStream.str().empty()); + + std::istringstream aReadStream(aWriteStream.str()); + DE_Provider::ReadStreamList aReadStreams; + aReadStreams.Append(DE_Provider::ReadStreamNode("bug27722.step", aReadStream)); + TopoDS_Shape aRestored; + ASSERT_TRUE(myProvider->Read(aReadStreams, aRestored)); + ASSERT_FALSE(aRestored.IsNull()); + // The original DRAW test is marked TODO because STEP restoration still + // produces a faulty shape for this case. Keep that known result explicit. + const bool isRestoredValid = BRepCheck_Analyzer(aRestored).IsValid(); + RecordProperty("restored_shape_valid", isRestoredValid ? "true" : "false"); + + NCollection_Array1 aTypes(1, 9); + aTypes.SetValue(1, TopAbs_VERTEX); + aTypes.SetValue(2, TopAbs_EDGE); + aTypes.SetValue(3, TopAbs_WIRE); + aTypes.SetValue(4, TopAbs_FACE); + aTypes.SetValue(5, TopAbs_SHELL); + aTypes.SetValue(6, TopAbs_SOLID); + aTypes.SetValue(7, TopAbs_COMPSOLID); + aTypes.SetValue(8, TopAbs_COMPOUND); + aTypes.SetValue(9, TopAbs_SHAPE); + NCollection_Array1 aTypeNames(1, 9); + aTypeNames.SetValue(1, "vertices"); + aTypeNames.SetValue(2, "edges"); + aTypeNames.SetValue(3, "wires"); + aTypeNames.SetValue(4, "faces"); + aTypeNames.SetValue(5, "shells"); + aTypeNames.SetValue(6, "solids"); + aTypeNames.SetValue(7, "compsolids"); + aTypeNames.SetValue(8, "compounds"); + aTypeNames.SetValue(9, "shapes"); + bool hasTopologyDifference = false; + for (int anIndex = 1; anIndex <= 9; ++anIndex) + { + const TopAbs_ShapeEnum aType = aTypes.Value(anIndex); + const int aSourceCount = CountShapeElements(aSource, aType); + const int aRestoredCount = CountShapeElements(aRestored, aType); + hasTopologyDifference = hasTopologyDifference || aSourceCount != aRestoredCount; + RecordProperty((std::string("source_") + aTypeNames.Value(anIndex)).c_str(), aSourceCount); + RecordProperty((std::string("restored_") + aTypeNames.Value(anIndex)).c_str(), aRestoredCount); + } + EXPECT_FALSE(isRestoredValid); + EXPECT_TRUE(hasTopologyDifference); + EXPECT_GT(CountShapeElements(aRestored, TopAbs_FACE), 0); +} + // Test stream-based document write and read operations TEST_F(DESTEP_ProviderTest, StreamDocumentWriteRead) { @@ -168,6 +676,33 @@ TEST_F(DESTEP_ProviderTest, StreamDocumentWriteRead) } } +// Migrated from tests/bugs/xde/bug1540. Writing an XCAF document containing +// an invisible layer must succeed without touching the filesystem. +TEST_F(DESTEP_ProviderTest, XdeBug_1540_WriteDocumentWithInvisibleLayer) +{ + occ::handle aShapeTool = XCAFDoc_DocumentTool::ShapeTool(myDocument->Main()); + const TDF_Label aShapeLabel = aShapeTool->AddShape(BRepPrimAPI_MakeBox(10., 10., 10.).Shape()); + ASSERT_FALSE(aShapeLabel.IsNull()); + + occ::handle aLayerTool = XCAFDoc_DocumentTool::LayerTool(myDocument->Main()); + const TDF_Label aLayerLabel = aLayerTool->AddLayer(TCollection_ExtendedString("invis")); + ASSERT_FALSE(aLayerLabel.IsNull()); + aLayerTool->SetLayer(aShapeLabel, aLayerLabel); + aLayerTool->SetVisibility(aLayerLabel, false); + EXPECT_TRUE(aLayerTool->IsSet(aShapeLabel, aLayerLabel)); + EXPECT_FALSE(aLayerTool->IsVisible(aLayerLabel)); + + std::ostringstream aStream; + DE_Provider::WriteStreamList aWriteStreams; + aWriteStreams.Append(DE_Provider::WriteStreamNode("bug1540.step", aStream)); + ASSERT_TRUE(myProvider->Write(aWriteStreams, myDocument)); + + const std::string aContent = aStream.str(); + EXPECT_TRUE(IsValidSTEPContent(aContent)); + EXPECT_NE(aContent.find("invis"), std::string::npos); + EXPECT_NE(aContent.find("INVISIBILITY"), std::string::npos); +} + // Test DE_Wrapper integration for STEP operations TEST_F(DESTEP_ProviderTest, DE_WrapperIntegration) { @@ -326,13 +861,19 @@ TEST_F(DESTEP_ProviderTest, DE_WrapperFileExtensions) EXPECT_TRUE(aWrapper.Bind(aNode)); // Test different STEP extensions - std::vector aExtensions = {"test.step", "test.STEP", "test.stp", "test.STP"}; + NCollection_Array1 aExtensions(1, 4); + aExtensions.SetValue(1, "test.step"); + aExtensions.SetValue(2, "test.STEP"); + aExtensions.SetValue(3, "test.stp"); + aExtensions.SetValue(4, "test.STP"); - for (const auto& anExt : aExtensions) + for (NCollection_Array1::Iterator anIterator(aExtensions); anIterator.More(); + anIterator.Next()) { + const char* anExt = anIterator.Value(); std::ostringstream anOStream; DE_Provider::WriteStreamList aWriteStreams; - aWriteStreams.Append(DE_Provider::WriteStreamNode(anExt.c_str(), anOStream)); + aWriteStreams.Append(DE_Provider::WriteStreamNode(anExt, anOStream)); EXPECT_TRUE(aWrapper.Write(aWriteStreams, myBox)) << "Failed to write with extension: " << anExt; @@ -344,7 +885,7 @@ TEST_F(DESTEP_ProviderTest, DE_WrapperFileExtensions) // Test read back std::istringstream anIStream(aContent); DE_Provider::ReadStreamList aReadStreams; - aReadStreams.Append(DE_Provider::ReadStreamNode(anExt.c_str(), anIStream)); + aReadStreams.Append(DE_Provider::ReadStreamNode(anExt, anIStream)); TopoDS_Shape aReadShape; EXPECT_TRUE(aWrapper.Read(aReadStreams, aReadShape)) @@ -475,4 +1016,43 @@ TEST_F(DESTEP_ProviderTest, DocumentWorkSessionIntegration) NCollection_Sequence aLabels; aNewShapeTool->GetShapes(aLabels); EXPECT_GT(aLabels.Length(), 0); -} \ No newline at end of file +} + +// perf/de/bug29830_3: writing a large XCAF compound must complete and the +// document must be safely destructible afterwards. The DRAW test used a +// temporary STEP file; the stream keeps the same transfer and lifetime path +// without depending on the filesystem. +TEST_F(DESTEP_ProviderTest, StepBug_29830_LargeCompoundWriteAndDestruction) +{ + const int aShapeCount = 1000; + const TopoDS_Shape aBox = BRepPrimAPI_MakeBox(1.0, 1.0, 1.0).Shape(); + + std::ostringstream aWriteStream; + { + BRep_Builder aBuilder; + TopoDS_Compound aCompound; + aBuilder.MakeCompound(aCompound); + for (int anIndex = 0; anIndex < aShapeCount; ++anIndex) + { + aBuilder.Add(aCompound, aBox); + } + + occ::handle anApp = new TDocStd_Application(); + occ::handle aDocument; + anApp->NewDocument("BinXCAF", aDocument); + ASSERT_FALSE(aDocument.IsNull()); + + occ::handle aShapeTool = XCAFDoc_DocumentTool::ShapeTool(aDocument->Main()); + ASSERT_FALSE(aShapeTool.IsNull()); + const TDF_Label aShapeLabel = aShapeTool->AddShape(aCompound); + ASSERT_FALSE(aShapeLabel.IsNull()); + + DE_Provider::WriteStreamList aWriteStreams; + aWriteStreams.Append(DE_Provider::WriteStreamNode("bug29830.step", aWriteStream)); + ASSERT_TRUE(myProvider->Write(aWriteStreams, aDocument)); + } + + const std::string aStepContent = aWriteStream.str(); + ASSERT_TRUE(IsValidSTEPContent(aStepContent)); + EXPECT_GT(aStepContent.size(), static_cast(aShapeCount)); +} diff --git a/src/DataExchange/TKDESTEP/GTests/FILES.cmake b/src/DataExchange/TKDESTEP/GTests/FILES.cmake index 4f31aa4e06..5d0d411a28 100644 --- a/src/DataExchange/TKDESTEP/GTests/FILES.cmake +++ b/src/DataExchange/TKDESTEP/GTests/FILES.cmake @@ -3,6 +3,7 @@ set(OCCT_TKDESTEP_GTests_FILES_LOCATION "${CMAKE_CURRENT_LIST_DIR}") set(OCCT_TKDESTEP_GTests_FILES DESTEP_Provider_Test.cxx + GDT_STEP_Storage_Test.cxx STEPConstruct_RenderingProperties_Test.cxx StepData_StepWriter_Test.cxx StepTidy_BaseTestFixture.pxx diff --git a/src/DataExchange/TKDESTEP/GTests/GDT_STEP_Storage_Test.cxx b/src/DataExchange/TKDESTEP/GTests/GDT_STEP_Storage_Test.cxx new file mode 100644 index 0000000000..ab4659d152 --- /dev/null +++ b/src/DataExchange/TKDESTEP/GTests/GDT_STEP_Storage_Test.cxx @@ -0,0 +1,1206 @@ +// Copyright (c) 2026 OPEN CASCADE SAS +// +// This file is part of Open CASCADE Technology software library. +// +// This library is free software; you can redistribute it and/or modify it under +// the terms of the GNU Lesser General Public License version 2.1 as published +// by the Free Software Foundation, with special exception defined in the file +// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT +// distribution for complete text of the license and disclaimer of any warranty. +// +// Alternatively, this file may be used under the terms of Open CASCADE +// commercial license or contractual agreement. + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include + +namespace +{ +static occ::handle NewDocument(occ::handle& theApplication) +{ + occ::handle aDocument; + theApplication->NewDocument("BinXCAF", aDocument); + EXPECT_FALSE(aDocument.IsNull()); + return aDocument; +} + +static TDF_Label AddBoxAndDimension(const occ::handle& theDocument) +{ + occ::handle aShapeTool = XCAFDoc_DocumentTool::ShapeTool(theDocument->Main()); + const TDF_Label aShapeLabel = aShapeTool->AddShape(BRepPrimAPI_MakeBox(10.0, 10.0, 10.0).Shape()); + occ::handle aDimTolTool = + XCAFDoc_DocumentTool::DimTolTool(theDocument->Main()); + const TDF_Label aDimensionLabel = aDimTolTool->AddDimension(); + aDimTolTool->SetDimension(aShapeLabel, aDimensionLabel); + return aDimensionLabel; +} + +static occ::handle DimensionObject( + const TDF_Label& theDimensionLabel) +{ + occ::handle aDimension; + if (!theDimensionLabel.FindAttribute(XCAFDoc_Dimension::GetID(), aDimension)) + { + return nullptr; + } + return aDimension->GetObject(); +} + +static occ::handle RestoreDimension( + const occ::handle& theDocument) +{ + occ::handle aDimTolTool = + XCAFDoc_DocumentTool::DimTolTool(theDocument->Main()); + NCollection_Sequence aDimensionLabels; + aDimTolTool->GetDimensionLabels(aDimensionLabels); + if (aDimensionLabels.IsEmpty()) + { + return nullptr; + } + return DimensionObject(aDimensionLabels.First()); +} + +static occ::handle RoundTrip(const occ::handle& theDocument, + const bool theWriteNonmanifold = false) +{ + occ::handle aNode = new DESTEP_ConfigurationNode(); + aNode->InternalParameters.WriteSchema = DESTEP_Parameters::WriteMode_StepSchema_AP242DIS; + aNode->InternalParameters.WriteNonmanifold = theWriteNonmanifold; + DESTEP_Provider aProvider(aNode); + + std::stringstream aStream; + DE_Provider::WriteStreamList aWriteStreams; + aWriteStreams.Append(DE_Provider::WriteStreamNode("gdt.step", aStream)); + if (!aProvider.Write(aWriteStreams, theDocument)) + { + ADD_FAILURE() << "DESTEP_Provider failed to write the GD&T stream"; + return nullptr; + } + + EXPECT_FALSE(aStream.str().empty()); + aStream.seekg(0); + DE_Provider::ReadStreamList aReadStreams; + aReadStreams.Append(DE_Provider::ReadStreamNode("gdt.step", aStream)); + + occ::handle anApplication = new TDocStd_Application(); + occ::handle aRestored = NewDocument(anApplication); + if (!aProvider.Read(aReadStreams, aRestored)) + { + ADD_FAILURE() << "DESTEP_Provider failed to read the GD&T stream"; + return nullptr; + } + return aRestored; +} + +static void ExpectPoint(const gp_Pnt& theActual, const gp_Pnt& theExpected) +{ + EXPECT_DOUBLE_EQ(theActual.X(), theExpected.X()); + EXPECT_DOUBLE_EQ(theActual.Y(), theExpected.Y()); + EXPECT_DOUBLE_EQ(theActual.Z(), theExpected.Z()); +} + +static void ExpectDirection(const gp_Dir& theActual, const gp_Dir& theExpected) +{ + EXPECT_DOUBLE_EQ(theActual.X(), theExpected.X()); + EXPECT_DOUBLE_EQ(theActual.Y(), theExpected.Y()); + EXPECT_DOUBLE_EQ(theActual.Z(), theExpected.Z()); +} + +static bool WriteStepStream(const occ::handle& theDocument, + std::stringstream& theStream) +{ + occ::handle aNode = new DESTEP_ConfigurationNode(); + aNode->InternalParameters.WriteSchema = DESTEP_Parameters::WriteMode_StepSchema_AP242DIS; + DESTEP_Provider aProvider(aNode); + DE_Provider::WriteStreamList aWriteStreams; + aWriteStreams.Append(DE_Provider::WriteStreamNode("draw_step.stream", theStream)); + return aProvider.Write(aWriteStreams, theDocument); +} + +static TopoDS_Compound MakeLocatedBoxAssembly(const int theCount) +{ + BRep_Builder aBuilder; + TopoDS_Compound aCompound; + aBuilder.MakeCompound(aCompound); + const TopoDS_Shape aBox = BRepPrimAPI_MakeBox(1.0, 2.0, 3.0).Shape(); + for (int anIndex = 0; anIndex < theCount; ++anIndex) + { + for (int aSubIndex = 0; aSubIndex < theCount; ++aSubIndex) + { + gp_Trsf aTrsf; + aTrsf.SetTranslation(gp_Vec(5.0 * anIndex, 0.5 * aSubIndex, 0.0)); + aBuilder.Add(aCompound, aBox.Located(TopLoc_Location(aTrsf))); + } + } + return aCompound; +} + +static occ::handle RoundTripWithSTEPCAF( + const occ::handle& theDocument) +{ + DESTEP_Parameters aParameters; + aParameters.WriteSchema = DESTEP_Parameters::WriteMode_StepSchema_AP242DIS; + STEPCAFControl_Writer aWriter; + EXPECT_TRUE(aWriter.Transfer(theDocument, aParameters)); + std::stringstream aStream; + EXPECT_EQ(aWriter.WriteStream(aStream), IFSelect_RetDone); + EXPECT_FALSE(aStream.str().empty()); + + aStream.seekg(0); + STEPCAFControl_Reader aReader; + EXPECT_EQ(aReader.ReadStream("stepcaf_vertex.step", aStream), IFSelect_RetDone); + occ::handle aRestoredApplication = new TDocStd_Application(); + occ::handle aRestoredDocument; + aRestoredApplication->NewDocument("BinXCAF", aRestoredDocument); + EXPECT_TRUE(aReader.Transfer(aRestoredDocument)); + return aRestoredDocument; +} + +static TDF_Label FindShapeByName(const NCollection_Sequence& theLabels, + const char* theName) +{ + for (NCollection_Sequence::Iterator anIterator(theLabels); anIterator.More(); + anIterator.Next()) + { + occ::handle aName; + if (anIterator.Value().FindAttribute(TDataStd_Name::GetID(), aName) + && aName->Get() == TCollection_ExtendedString(theName)) + { + return anIterator.Value(); + } + } + return TDF_Label(); +} + +static TDF_Label FindLabelByName(const TDF_Label& theLabel, + const TCollection_ExtendedString& theName) +{ + occ::handle aLabelName; + if (theLabel.FindAttribute(TDataStd_Name::GetID(), aLabelName) && aLabelName->Get() == theName) + { + return theLabel; + } + + for (TDF_ChildIterator anIterator(theLabel); anIterator.More(); anIterator.Next()) + { + const TDF_Label aFoundLabel = FindLabelByName(anIterator.Value(), theName); + if (!aFoundLabel.IsNull()) + { + return aFoundLabel; + } + } + return TDF_Label(); +} + +static TCollection_ExtendedString FindFirstLabelName(const TDF_Label& theLabel) +{ + occ::handle aLabelName; + if (theLabel.FindAttribute(TDataStd_Name::GetID(), aLabelName)) + { + return aLabelName->Get(); + } + + for (TDF_ChildIterator anIterator(theLabel); anIterator.More(); anIterator.Next()) + { + const TCollection_ExtendedString aName = FindFirstLabelName(anIterator.Value()); + if (!aName.IsEmpty()) + { + return aName; + } + } + return TCollection_ExtendedString(); +} + +static TCollection_ExtendedString FindFirstSubShapeName( + const occ::handle& theDocument) +{ + occ::handle aShapeTool = XCAFDoc_DocumentTool::ShapeTool(theDocument->Main()); + NCollection_Sequence aShapeLabels; + aShapeTool->GetShapes(aShapeLabels); + for (NCollection_Sequence::Iterator aShapeIterator(aShapeLabels); + aShapeIterator.More(); + aShapeIterator.Next()) + { + NCollection_Sequence aSubShapeLabels; + aShapeTool->GetSubShapes(aShapeIterator.Value(), aSubShapeLabels); + for (NCollection_Sequence::Iterator aSubShapeIterator(aSubShapeLabels); + aSubShapeIterator.More(); + aSubShapeIterator.Next()) + { + const TCollection_ExtendedString aName = FindFirstLabelName(aSubShapeIterator.Value()); + if (!aName.IsEmpty()) + { + return aName; + } + } + } + return TCollection_ExtendedString(); +} + +static TCollection_AsciiString MakeStepNameTemplate() +{ + occ::handle anApplication = new TDocStd_Application(); + occ::handle aDocument = NewDocument(anApplication); + if (aDocument.IsNull()) + { + return TCollection_AsciiString(); + } + + const TopoDS_Shape aBox = BRepPrimAPI_MakeBox(1.0, 2.0, 3.0).Shape(); + occ::handle aShapeTool = XCAFDoc_DocumentTool::ShapeTool(aDocument->Main()); + const TDF_Label aShapeLabel = aShapeTool->AddShape(aBox, false); + if (aShapeLabel.IsNull()) + { + return TCollection_AsciiString(); + } + + TopExp_Explorer aFaceExplorer(aBox, TopAbs_FACE); + if (!aFaceExplorer.More()) + { + return TCollection_AsciiString(); + } + const TDF_Label aSubShapeLabel = aShapeTool->AddSubShape(aShapeLabel, aFaceExplorer.Current()); + if (aSubShapeLabel.IsNull() + || TDataStd_Name::Set(aSubShapeLabel, TCollection_ExtendedString("@tmp_name@", true)) + .IsNull()) + { + return TCollection_AsciiString(); + } + + occ::handle aNode = new DESTEP_ConfigurationNode(); + aNode->InternalParameters.WriteSchema = DESTEP_Parameters::WriteMode_StepSchema_AP242DIS; + aNode->InternalParameters.WriteName = true; + aNode->InternalParameters.WriteSubshapeNames = true; + DESTEP_Provider aProvider(aNode); + std::stringstream aStream; + DE_Provider::WriteStreamList aWriteStreams; + aWriteStreams.Append(DE_Provider::WriteStreamNode("codepage_template.step", aStream)); + if (!aProvider.Write(aWriteStreams, aDocument)) + { + return TCollection_AsciiString(); + } + + return TCollection_AsciiString(aStream.str().c_str()); +} + +static TCollection_AsciiString EncodeStepName(const TCollection_ExtendedString& theName, + const Resource_FormatType theFormat) +{ + if (theFormat >= Resource_FormatType_CP1250 && theFormat <= Resource_FormatType_CP850) + { + TCollection_AsciiString aResult; + for (int aCharIndex = 1; aCharIndex <= theName.Length(); ++aCharIndex) + { + const char16_t aChar = theName.Value(aCharIndex); + if (aChar <= 0x7F) + { + aResult.AssignCat(static_cast(aChar)); + continue; + } + + char aCharBuffer[4]; + Standard_PCharacter aCharBufferPtr = aCharBuffer; + const TCollection_ExtendedString aSingleChar(1, aChar); + if (!Resource_Unicode::ConvertUnicodeToFormat(theFormat, aSingleChar, aCharBufferPtr, 2)) + { + return TCollection_AsciiString(); + } + aResult.AssignCat(aCharBuffer); + } + return aResult; + } + + char aBuffer[512]; + Standard_PCharacter aBufferPtr = aBuffer; + const int aBufferSize = + theFormat == Resource_FormatType_UTF8 ? theName.LengthOfCString() + 1 : sizeof(aBuffer); + if (!Resource_Unicode::ConvertUnicodeToFormat(theFormat, theName, aBufferPtr, aBufferSize)) + { + return TCollection_AsciiString(); + } + return TCollection_AsciiString(aBuffer); +} + +static TCollection_AsciiString ReplaceStepName(const TCollection_AsciiString& theTemplate, + const TCollection_ExtendedString& theName, + const Resource_FormatType theFormat) +{ + const TCollection_AsciiString aPlaceholder("@tmp_name@"); + const int aPosition = theTemplate.Search(aPlaceholder); + const TCollection_AsciiString anEncodedName = EncodeStepName(theName, theFormat); + if (aPosition < 1 || anEncodedName.IsEmpty()) + { + return TCollection_AsciiString(); + } + + TCollection_AsciiString aResult; + if (aPosition > 1) + { + aResult.AssignCat(theTemplate.SubString(1, aPosition - 1)); + } + aResult.AssignCat(anEncodedName); + const int aSuffixPosition = aPosition + aPlaceholder.Length(); + if (aSuffixPosition <= theTemplate.Length()) + { + aResult.AssignCat(theTemplate.SubString(aSuffixPosition, theTemplate.Length())); + } + return aResult; +} + +static TCollection_ExtendedString ReadStepName(const TCollection_AsciiString& thePayload, + const Resource_FormatType theFormat) +{ + occ::handle aNode = new DESTEP_ConfigurationNode(); + aNode->InternalParameters.ReadCodePage = theFormat; + aNode->InternalParameters.ReadName = true; + aNode->InternalParameters.ReadSubshapeNames = true; + DESTEP_Provider aProvider(aNode); + + std::stringstream aStream(std::ios::in | std::ios::out | std::ios::binary); + aStream.write(thePayload.ToCString(), thePayload.Length()); + aStream.seekg(0); + DE_Provider::ReadStreamList aReadStreams; + aReadStreams.Append(DE_Provider::ReadStreamNode("codepage_test.step", aStream)); + + occ::handle anApplication = new TDocStd_Application(); + occ::handle aDocument = NewDocument(anApplication); + if (aDocument.IsNull() || !aProvider.Read(aReadStreams, aDocument)) + { + return TCollection_ExtendedString(); + } + return FindFirstSubShapeName(aDocument); +} + +static void ExpectStepCodePageName(const TCollection_AsciiString& theTemplate, + const TCollection_ExtendedString& theExpectedName, + const Resource_FormatType theFormat) +{ + const TCollection_AsciiString aUtf8Payload = + ReplaceStepName(theTemplate, theExpectedName, Resource_FormatType_UTF8); + const TCollection_AsciiString aTargetPayload = + ReplaceStepName(theTemplate, theExpectedName, theFormat); + ASSERT_FALSE(aUtf8Payload.IsEmpty()); + ASSERT_FALSE(aTargetPayload.IsEmpty()); + + EXPECT_EQ(ReadStepName(aUtf8Payload, Resource_FormatType_UTF8), theExpectedName); + EXPECT_EQ(ReadStepName(aTargetPayload, theFormat), theExpectedName); + EXPECT_NE(ReadStepName(aTargetPayload, Resource_FormatType_UTF8), theExpectedName); +} + +static TopoDS_Shape TranslateShape(const TopoDS_Shape& theShape, + const double theX, + const double theY, + const double theZ) +{ + gp_Trsf aTrsf; + aTrsf.SetTranslation(gp_Vec(theX, theY, theZ)); + return BRepBuilderAPI_Transform(theShape, aTrsf).Shape(); +} + +static TopoDS_Shape FindFirstVertex(const TDF_Label& theLabel) +{ + const TopoDS_Shape aShape = XCAFDoc_ShapeTool::GetShape(theLabel); + if (!aShape.IsNull()) + { + if (aShape.ShapeType() == TopAbs_VERTEX) + { + return aShape; + } + + TopExp_Explorer anExplorer(aShape, TopAbs_VERTEX); + if (anExplorer.More()) + { + return anExplorer.Current(); + } + } + + for (TDF_ChildIterator anIterator(theLabel); anIterator.More(); anIterator.Next()) + { + const TopoDS_Shape aVertex = FindFirstVertex(anIterator.Value()); + if (!aVertex.IsNull()) + { + return aVertex; + } + } + return TopoDS_Shape(); +} + +static double ShapeDiagonal(const TopoDS_Shape& theShape) +{ + Bnd_Box aBox; + BRepBndLib::Add(theShape, aBox); + return aBox.CornerMin().Distance(aBox.CornerMax()); +} +} // namespace + +// gdt/dimensions/A7: STEP AP242 preserves dimension descriptions. +TEST(GDT_STEP_Storage_Test, A7_DimensionDescriptions) +{ + occ::handle anApplication = new TDocStd_Application(); + occ::handle aDocument = NewDocument(anApplication); + ASSERT_FALSE(aDocument.IsNull()); + const TDF_Label aDimensionLabel = AddBoxAndDimension(aDocument); + occ::handle aDimension; + ASSERT_TRUE(aDimensionLabel.FindAttribute(XCAFDoc_Dimension::GetID(), aDimension)); + occ::handle anObject = aDimension->GetObject(); + anObject->SetType(XCAFDimTolObjects_DimensionType_Size_CurveLength); + anObject->SetValue(10.0); + anObject->AddDescription(new TCollection_HAsciiString("description1"), + new TCollection_HAsciiString()); + anObject->AddDescription(new TCollection_HAsciiString("description2"), + new TCollection_HAsciiString("name2")); + aDimension->SetObject(anObject); + + occ::handle aRestored = RoundTrip(aDocument); + ASSERT_FALSE(aRestored.IsNull()); + occ::handle aRestoredObject = RestoreDimension(aRestored); + ASSERT_FALSE(aRestoredObject.IsNull()); + EXPECT_EQ(aRestoredObject->GetType(), XCAFDimTolObjects_DimensionType_Size_CurveLength); + EXPECT_DOUBLE_EQ(aRestoredObject->GetValue(), 10.0); + ASSERT_EQ(aRestoredObject->NbDescriptions(), 2); + EXPECT_STREQ(aRestoredObject->GetDescription(0)->ToCString(), "description1"); + EXPECT_STREQ(aRestoredObject->GetDescriptionName(0)->ToCString(), ""); + EXPECT_STREQ(aRestoredObject->GetDescription(1)->ToCString(), "description2"); + EXPECT_STREQ(aRestoredObject->GetDescriptionName(1)->ToCString(), "name2"); +} + +// gdt/dimensions/A8: STEP AP242 preserves the dimension annotation plane. +TEST(GDT_STEP_Storage_Test, A8_DimensionAnnotationPlane) +{ + occ::handle anApplication = new TDocStd_Application(); + occ::handle aDocument = NewDocument(anApplication); + ASSERT_FALSE(aDocument.IsNull()); + const TDF_Label aDimensionLabel = AddBoxAndDimension(aDocument); + occ::handle aDimension; + ASSERT_TRUE(aDimensionLabel.FindAttribute(XCAFDoc_Dimension::GetID(), aDimension)); + occ::handle anObject = aDimension->GetObject(); + anObject->SetType(XCAFDimTolObjects_DimensionType_Size_CurveLength); + anObject->SetValue(10.0); + const gp_Pnt aPoint(-5.0, 0.0, 7.0); + const gp_Dir aNormal(-1.0, 0.0, 0.0); + const gp_Dir anXDirection(0.0, 1.0, 0.0); + anObject->SetPlane(gp_Ax2(aPoint, aNormal, anXDirection)); + anObject->SetPointTextAttach(aPoint); + anObject->SetPresentation( + BRepBuilderAPI_MakeEdge(gp_Pnt(-5.0, 0.0, 0.0), gp_Pnt(-5.0, 0.0, 10.0)), + new TCollection_HAsciiString("presentation")); + aDimension->SetObject(anObject); + + occ::handle aRestored = RoundTrip(aDocument); + ASSERT_FALSE(aRestored.IsNull()); + occ::handle aRestoredObject = RestoreDimension(aRestored); + ASSERT_FALSE(aRestoredObject.IsNull()); + EXPECT_DOUBLE_EQ(aRestoredObject->GetValue(), 10.0); + ASSERT_TRUE(aRestoredObject->HasPlane()); + ExpectPoint(aRestoredObject->GetPlane().Location(), aPoint); + ExpectDirection(aRestoredObject->GetPlane().Direction(), aNormal); + ExpectDirection(aRestoredObject->GetPlane().XDirection(), anXDirection); + ASSERT_TRUE(aRestoredObject->HasTextPoint()); + ExpectPoint(aRestoredObject->GetPointTextAttach(), aPoint); +} + +// gdt/dimensions/A9: STEP AP242 preserves both dimension connection points. +TEST(GDT_STEP_Storage_Test, A9_DimensionConnectionPoints) +{ + occ::handle anApplication = new TDocStd_Application(); + occ::handle aDocument = NewDocument(anApplication); + ASSERT_FALSE(aDocument.IsNull()); + const TDF_Label aDimensionLabel = AddBoxAndDimension(aDocument); + occ::handle aDimension; + ASSERT_TRUE(aDimensionLabel.FindAttribute(XCAFDoc_Dimension::GetID(), aDimension)); + occ::handle anObject = aDimension->GetObject(); + anObject->SetType(XCAFDimTolObjects_DimensionType_Location_LinearDistance); + anObject->SetValue(10.0); + const gp_Pnt aPoint1(1.0, 0.0, 0.0); + const gp_Pnt aPoint2(9.0, 0.0, 0.0); + anObject->SetPoint(aPoint1); + anObject->SetPoint2(aPoint2); + aDimension->SetObject(anObject); + + occ::handle aRestored = RoundTrip(aDocument); + ASSERT_FALSE(aRestored.IsNull()); + occ::handle aRestoredObject = RestoreDimension(aRestored); + ASSERT_FALSE(aRestoredObject.IsNull()); + EXPECT_DOUBLE_EQ(aRestoredObject->GetValue(), 10.0); + ASSERT_TRUE(aRestoredObject->HasPoint()); + ASSERT_TRUE(aRestoredObject->HasPoint2()); + ExpectPoint(aRestoredObject->GetPoint(), aPoint1); + ExpectPoint(aRestoredObject->GetPoint2(), aPoint2); +} + +static TCollection_ExtendedString StepSpecialName() +{ + return TCollection_ExtendedString("a'''\\b\n\t\\c\\\\\\\\"); +} + +static TCollection_ExtendedString RestoredFirstShapeName( + const occ::handle& theDocument) +{ + occ::handle aShapeTool = XCAFDoc_DocumentTool::ShapeTool(theDocument->Main()); + NCollection_Sequence aShapeLabels; + aShapeTool->GetShapes(aShapeLabels); + if (aShapeLabels.IsEmpty()) + { + return TCollection_ExtendedString(); + } + + occ::handle aName; + if (!aShapeLabels.First().FindAttribute(TDataStd_Name::GetID(), aName)) + { + return TCollection_ExtendedString(); + } + return aName->Get(); +} + +// bugs/step/bug32310: STEP stream export/import preserves names containing +// quotes, backslashes, newlines, and tabs. +TEST(GDT_STEP_Storage_Test, StepBug_32310_SpecialName) +{ + occ::handle anApplication = new TDocStd_Application(); + occ::handle aDocument = NewDocument(anApplication); + ASSERT_FALSE(aDocument.IsNull()); + occ::handle aShapeTool = XCAFDoc_DocumentTool::ShapeTool(aDocument->Main()); + const TDF_Label aShapeLabel = aShapeTool->AddShape(BRepPrimAPI_MakeBox(1.0, 1.0, 1.0).Shape()); + ASSERT_FALSE(aShapeLabel.IsNull()); + const TCollection_ExtendedString anExpected = StepSpecialName(); + ASSERT_FALSE(TDataStd_Name::Set(aShapeLabel, anExpected).IsNull()); + + occ::handle aRestored = RoundTrip(aDocument); + ASSERT_FALSE(aRestored.IsNull()); + EXPECT_EQ(RestoredFirstShapeName(aRestored), anExpected); +} + +// bugs/step/bug28454_1: STEP names encoded in ISO-8859-N are decoded using the selected code page. +TEST(GDT_STEP_Storage_Test, StepBug_28454_1_ISO8859Names) +{ + const TCollection_AsciiString aTemplate = MakeStepNameTemplate(); + ASSERT_FALSE(aTemplate.IsEmpty()); + + NCollection_Array1 aFormats(1, 9); + aFormats.SetValue(1, Resource_FormatType_iso8859_1); + aFormats.SetValue(2, Resource_FormatType_iso8859_2); + aFormats.SetValue(3, Resource_FormatType_iso8859_3); + aFormats.SetValue(4, Resource_FormatType_iso8859_4); + aFormats.SetValue(5, Resource_FormatType_iso8859_5); + aFormats.SetValue(6, Resource_FormatType_iso8859_6); + aFormats.SetValue(7, Resource_FormatType_iso8859_7); + aFormats.SetValue(8, Resource_FormatType_iso8859_8); + aFormats.SetValue(9, Resource_FormatType_iso8859_9); + + NCollection_Array1 aNames(1, 9); + aNames.SetValue(1, TCollection_ExtendedString(u"Test Prob\u00EDh\u00E1")); + aNames.SetValue(2, TCollection_ExtendedString(u"Test Prob\u00EDh\u00E1")); + aNames.SetValue(3, TCollection_ExtendedString(u"Test \u00D6l\u00E7ek")); + aNames.SetValue(4, TCollection_ExtendedString(u"Test m\u0113\u0123iniet")); + aNames.SetValue(5, TCollection_ExtendedString(u"Test \u0422\u0435\u0441\u0442")); + aNames.SetValue(6, TCollection_ExtendedString(u"Test \u0627\u062e\u062a\u0628\u0627\u0631")); + aNames.SetValue(7, TCollection_ExtendedString(u"Test \u03B4\u03C0\u03A8\u03AE")); + aNames.SetValue(8, TCollection_ExtendedString(u"Test \u00B1\u05E4\u05DE\u05DC\u05E9")); + aNames.SetValue(9, TCollection_ExtendedString(u"Test \u011F\u015F\u011E\u015E\u00C6")); + + for (int anIndex = aFormats.Lower(); anIndex <= aFormats.Upper(); ++anIndex) + { + SCOPED_TRACE(anIndex); + ExpectStepCodePageName(aTemplate, aNames.Value(anIndex), aFormats.Value(anIndex)); + } +} + +// bugs/step/bug30694: STEP names encoded in GB2312 are decoded using the GB code page. +TEST(GDT_STEP_Storage_Test, StepBug_30694_GB2312Name) +{ + const TCollection_AsciiString aTemplate = MakeStepNameTemplate(); + ASSERT_FALSE(aTemplate.IsEmpty()); + ExpectStepCodePageName(aTemplate, + TCollection_ExtendedString(u"\u56FD\u6807"), + Resource_FormatType_GB); +} + +// bugs/step/bug31670_1: STEP names encoded in CP1250..CP1258 are decoded using the selected page. +TEST(GDT_STEP_Storage_Test, StepBug_31670_1_CP125xNames) +{ + const TCollection_AsciiString aTemplate = MakeStepNameTemplate(); + ASSERT_FALSE(aTemplate.IsEmpty()); + + NCollection_Array1 aFormats(1, 9); + NCollection_Array1 aNames(1, 9); + for (int anIndex = 1; anIndex <= 9; ++anIndex) + { + aFormats.SetValue(anIndex, + static_cast(Resource_FormatType_CP1250 + anIndex - 1)); + } + aNames.SetValue(1, TCollection_ExtendedString(u"Test Prob\u00EDh\u00E1")); + aNames.SetValue(2, TCollection_ExtendedString(u"Test \u0422\u0435\u0441\u0442")); + aNames.SetValue(3, TCollection_ExtendedString(u"Test Prob\u00EDh\u00E1")); + aNames.SetValue(4, TCollection_ExtendedString(u"Test \u0394\u03BF\u03BA\u03B9\u03BC\u03AE")); + aNames.SetValue(5, TCollection_ExtendedString(u"Test \u00D6l\u00E7ek")); + aNames.SetValue(6, + TCollection_ExtendedString(u"Test \u05DE\u05B4\u05D1\u05B0\u05D7\u05B8\u05DF")); + aNames.SetValue(7, TCollection_ExtendedString(u"Test \u0627\u062E\u062A\u0628\u0627\u0631")); + aNames.SetValue(8, TCollection_ExtendedString(u"Test P\u0101rbaude")); + // CP1258 represents U+1EC7 as U+00EA followed by combining dot below. + aNames.SetValue(9, TCollection_ExtendedString(u"Test Th\u00ED nghi\u00EA\u0323m")); + + for (int anIndex = aFormats.Lower(); anIndex <= aFormats.Upper(); ++anIndex) + { + SCOPED_TRACE(anIndex); + ExpectStepCodePageName(aTemplate, aNames.Value(anIndex), aFormats.Value(anIndex)); + } +} + +// bugs/step/bug31923: STEP names encoded in DOS CP850 are decoded using the selected page. +TEST(GDT_STEP_Storage_Test, StepBug_31923_CP850Name) +{ + const TCollection_AsciiString aTemplate = MakeStepNameTemplate(); + ASSERT_FALSE(aTemplate.IsEmpty()); + ExpectStepCodePageName( + aTemplate, + TCollection_ExtendedString(u"\u00DCberpr\u00FCfung de codifica\u00E7\u00E3o"), + Resource_FormatType_CP850); +} + +// bugs/xde/bug22728: STEP export can write the result to a caller-owned stream. +TEST(GDT_STEP_Storage_Test, XdeBug_22728_WriteStream) +{ + occ::handle anApplication = new TDocStd_Application(); + occ::handle aDocument = NewDocument(anApplication); + ASSERT_FALSE(aDocument.IsNull()); + occ::handle aShapeTool = XCAFDoc_DocumentTool::ShapeTool(aDocument->Main()); + ASSERT_FALSE(aShapeTool->AddShape(BRepPrimAPI_MakeBox(10.0, 10.0, 10.0).Shape()).IsNull()); + + std::stringstream aStream; + ASSERT_TRUE(WriteStepStream(aDocument, aStream)); + const std::string aContent = aStream.str(); + EXPECT_FALSE(aContent.empty()); + EXPECT_NE(aContent.find("ISO-10303-21;"), std::string::npos); + EXPECT_NE(aContent.find("MANIFOLD_SOLID_BREP"), std::string::npos); +} + +// bugs/step/bug33815: non-manifold STEP export retains the same special name. +TEST(GDT_STEP_Storage_Test, StepBug_33815_NonmanifoldSpecialName) +{ + occ::handle anApplication = new TDocStd_Application(); + occ::handle aDocument = NewDocument(anApplication); + ASSERT_FALSE(aDocument.IsNull()); + occ::handle aShapeTool = XCAFDoc_DocumentTool::ShapeTool(aDocument->Main()); + const TDF_Label aShapeLabel = aShapeTool->AddShape(BRepPrimAPI_MakeBox(1.0, 1.0, 1.0).Shape()); + ASSERT_FALSE(aShapeLabel.IsNull()); + const TCollection_ExtendedString anExpected = StepSpecialName(); + ASSERT_FALSE(TDataStd_Name::Set(aShapeLabel, anExpected).IsNull()); + + occ::handle aRestored = RoundTrip(aDocument, true); + ASSERT_FALSE(aRestored.IsNull()); + EXPECT_EQ(RestoredFirstShapeName(aRestored), anExpected); +} + +static void ExpectStepEdgeExport(const TopoDS_Shape& theEdge) +{ + occ::handle anApplication = new TDocStd_Application(); + occ::handle aDocument = NewDocument(anApplication); + ASSERT_FALSE(aDocument.IsNull()); + occ::handle aShapeTool = XCAFDoc_DocumentTool::ShapeTool(aDocument->Main()); + ASSERT_FALSE(aShapeTool->AddShape(theEdge).IsNull()); + + occ::handle aNode = new DESTEP_ConfigurationNode(); + aNode->InternalParameters.WriteSchema = DESTEP_Parameters::WriteMode_StepSchema_AP242DIS; + DESTEP_Provider aProvider(aNode); + std::stringstream aStream; + DE_Provider::WriteStreamList aWriteStreams; + aWriteStreams.Append(DE_Provider::WriteStreamNode("untrimmed_edge.step", aStream)); + EXPECT_TRUE(aProvider.Write(aWriteStreams, aDocument)); + EXPECT_FALSE(aStream.str().empty()); + EXPECT_NE(aStream.str().find("LINE"), std::string::npos); +} + +// bugs/step/bug32817_1: STEP export accepts an untrimmed line edge. +TEST(GDT_STEP_Storage_Test, StepBug_32817_1_UntrimmedLine) +{ + const gp_Lin aLine(gp_Pnt(0.0, 0.0, 0.0), gp_Dir(0.0, 1.0, 0.0)); + const TopoDS_Shape anEdge = BRepBuilderAPI_MakeEdge(aLine).Edge(); + ASSERT_FALSE(anEdge.IsNull()); + ExpectStepEdgeExport(anEdge); +} + +// bugs/step/bug32817_2: STEP export accepts a line edge with a huge end value. +TEST(GDT_STEP_Storage_Test, StepBug_32817_2_HugeEndParameter) +{ + const gp_Lin aLine(gp_Pnt(0.0, 0.0, 0.0), gp_Dir(0.0, 1.0, 0.0)); + const TopoDS_Shape anEdge = BRepBuilderAPI_MakeEdge(aLine, 10.0, 2.0e100).Edge(); + ASSERT_FALSE(anEdge.IsNull()); + ExpectStepEdgeExport(anEdge); +} + +// bugs/step/bug32817_3: STEP export accepts a line edge with a huge negative start value. +TEST(GDT_STEP_Storage_Test, StepBug_32817_3_HugeStartParameter) +{ + const gp_Lin aLine(gp_Pnt(0.0, 0.0, 0.0), gp_Dir(1.0, 1.0, 0.0)); + const TopoDS_Shape anEdge = BRepBuilderAPI_MakeEdge(aLine, -2.0e100, 10.0).Edge(); + ASSERT_FALSE(anEdge.IsNull()); + ExpectStepEdgeExport(anEdge); +} + +// bugs/xde/bug25910: STEP writing accepts a material with zero density. +TEST(GDT_STEP_Storage_Test, XdeBug_25910_ZeroDensityMaterial) +{ + occ::handle anApplication = new TDocStd_Application(); + occ::handle aDocument = NewDocument(anApplication); + ASSERT_FALSE(aDocument.IsNull()); + + occ::handle aShapeTool = XCAFDoc_DocumentTool::ShapeTool(aDocument->Main()); + const TDF_Label aShapeLabel = aShapeTool->AddShape(BRepPrimAPI_MakeBox(10.0, 10.0, 10.0).Shape()); + ASSERT_FALSE(aShapeLabel.IsNull()); + occ::handle aMaterialTool = + XCAFDoc_DocumentTool::MaterialTool(aDocument->Main()); + aMaterialTool->SetMaterial(aShapeLabel, + new TCollection_HAsciiString("Vacuum"), + new TCollection_HAsciiString(), + 0.0, + new TCollection_HAsciiString("density measure"), + new TCollection_HAsciiString("POSITIVE_RATIO_MEASURE")); + + occ::handle aNode = new DESTEP_ConfigurationNode(); + aNode->InternalParameters.WriteSchema = DESTEP_Parameters::WriteMode_StepSchema_AP242DIS; + DESTEP_Provider aProvider(aNode); + std::stringstream aStream; + DE_Provider::WriteStreamList aWriteStreams; + aWriteStreams.Append(DE_Provider::WriteStreamNode("zero_density.step", aStream)); + EXPECT_TRUE(aProvider.Write(aWriteStreams, aDocument)); + EXPECT_FALSE(aStream.str().empty()); +} + +// bugs/step/bug27313: STEP writing accepts a PMI document with a datum and +// angularity tolerance. +TEST(GDT_STEP_Storage_Test, StepBug_27313_PmiExport) +{ + occ::handle anApplication = new TDocStd_Application(); + occ::handle aDocument = NewDocument(anApplication); + ASSERT_FALSE(aDocument.IsNull()); + + occ::handle aShapeTool = XCAFDoc_DocumentTool::ShapeTool(aDocument->Main()); + const TDF_Label aShapeLabel = aShapeTool->AddShape(BRepPrimAPI_MakeBox(10.0, 10.0, 10.0).Shape()); + ASSERT_FALSE(aShapeLabel.IsNull()); + occ::handle aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(aDocument->Main()); + const TDF_Label aToleranceLabel = aDimTolTool->AddGeomTolerance(); + aDimTolTool->SetGeomTolerance(aShapeLabel, aToleranceLabel); + const TDF_Label aDatumLabel = aDimTolTool->AddDatum(); + NCollection_Sequence aShapeLabels; + aShapeLabels.Append(aShapeLabel); + aDimTolTool->SetDatum(aShapeLabels, aDatumLabel); + + occ::handle aDatum; + ASSERT_TRUE(aDatumLabel.FindAttribute(XCAFDoc_Datum::GetID(), aDatum)); + occ::handle aDatumObject = aDatum->GetObject(); + aDatumObject->SetName(new TCollection_HAsciiString("A")); + aDatumObject->SetPosition(1); + aDatumObject->AddModifier(XCAFDimTolObjects_DatumSingleModif_DistanceVariable); + aDatum->SetObject(aDatumObject); + aDimTolTool->SetDatumToGeomTol(aDatumLabel, aToleranceLabel); + + occ::handle aTolerance; + ASSERT_TRUE(aToleranceLabel.FindAttribute(XCAFDoc_GeomTolerance::GetID(), aTolerance)); + occ::handle aToleranceObject = aTolerance->GetObject(); + aToleranceObject->SetValue(0.5); + aToleranceObject->SetType(XCAFDimTolObjects_GeomToleranceType_Angularity); + aToleranceObject->SetTypeOfValue(XCAFDimTolObjects_GeomToleranceTypeValue_Diameter); + aTolerance->SetObject(aToleranceObject); + + std::stringstream aStream; + EXPECT_TRUE(WriteStepStream(aDocument, aStream)); + EXPECT_FALSE(aStream.str().empty()); +} + +// bugs/modalg_8/bug33165: STEP preserves names of assembly instances. +TEST(GDT_STEP_Storage_Test, ModalgBug_33165_AssemblyInstanceNames) +{ + occ::handle anApplication = new TDocStd_Application(); + occ::handle aDocument = NewDocument(anApplication); + ASSERT_FALSE(aDocument.IsNull()); + + const TopoDS_Shape aFirstBox = BRepPrimAPI_MakeBox(1.0, 1.0, 1.0).Shape(); + gp_Trsf aTranslation; + aTranslation.SetTranslation(gp_Vec(1.0, 1.0, 1.0)); + const TopoDS_Shape aSecondBox = BRepBuilderAPI_Transform(aFirstBox, aTranslation).Shape(); + BRep_Builder aBuilder; + TopoDS_Compound aCompound; + aBuilder.MakeCompound(aCompound); + aBuilder.Add(aCompound, aFirstBox); + aBuilder.Add(aCompound, aSecondBox); + + occ::handle aShapeTool = XCAFDoc_DocumentTool::ShapeTool(aDocument->Main()); + const TDF_Label anAssembly = aShapeTool->AddShape(aCompound, true); + ASSERT_FALSE(anAssembly.IsNull()); + NCollection_Sequence aComponents; + ASSERT_TRUE(aShapeTool->GetComponents(anAssembly, aComponents)); + ASSERT_EQ(aComponents.Length(), 2); + ASSERT_FALSE(TDataStd_Name::Set(aComponents.Value(1), "name1").IsNull()); + ASSERT_FALSE(TDataStd_Name::Set(aComponents.Value(2), "name2").IsNull()); + + occ::handle aRestored = RoundTrip(aDocument); + ASSERT_FALSE(aRestored.IsNull()); + occ::handle aRestoredShapeTool = + XCAFDoc_DocumentTool::ShapeTool(aRestored->Main()); + NCollection_Sequence aRestoredAssemblies; + aRestoredShapeTool->GetFreeShapes(aRestoredAssemblies); + ASSERT_EQ(aRestoredAssemblies.Length(), 1); + NCollection_Sequence aRestoredComponents; + ASSERT_TRUE(aRestoredShapeTool->GetComponents(aRestoredAssemblies.First(), aRestoredComponents)); + ASSERT_EQ(aRestoredComponents.Length(), 2); + + occ::handle aName1; + occ::handle aName2; + ASSERT_TRUE(aRestoredComponents.Value(1).FindAttribute(TDataStd_Name::GetID(), aName1)); + ASSERT_TRUE(aRestoredComponents.Value(2).FindAttribute(TDataStd_Name::GetID(), aName2)); + EXPECT_EQ(aName1->Get(), TCollection_ExtendedString("name1")); + EXPECT_EQ(aName2->Get(), TCollection_ExtendedString("name2")); +} + +// bugs/xde/bug7141: STEP export handles a large assembly of located instances +// when the output is written to a caller-owned stream. +TEST(GDT_STEP_Storage_Test, XdeBug_7141_LargeAssemblyExport) +{ + occ::handle anApplication = new TDocStd_Application(); + occ::handle aDocument = NewDocument(anApplication); + ASSERT_FALSE(aDocument.IsNull()); + + const TopoDS_Compound aCompound = MakeLocatedBoxAssembly(20); + occ::handle aShapeTool = XCAFDoc_DocumentTool::ShapeTool(aDocument->Main()); + const TDF_Label anAssembly = aShapeTool->AddShape(aCompound, true); + ASSERT_FALSE(anAssembly.IsNull()); + NCollection_Sequence aComponents; + ASSERT_TRUE(aShapeTool->GetComponents(anAssembly, aComponents)); + ASSERT_EQ(aComponents.Length(), 400); + + occ::handle aNode = new DESTEP_ConfigurationNode(); + aNode->InternalParameters.WriteSchema = DESTEP_Parameters::WriteMode_StepSchema_AP242DIS; + aNode->InternalParameters.WriteAssembly = DESTEP_Parameters::WriteMode_Assembly_On; + DESTEP_Provider aProvider(aNode); + std::stringstream aStream; + DE_Provider::WriteStreamList aWriteStreams; + aWriteStreams.Append(DE_Provider::WriteStreamNode("bug7141.step", aStream)); + ASSERT_TRUE(aProvider.Write(aWriteStreams, aDocument)); + + const std::string aContent = aStream.str(); + EXPECT_FALSE(aContent.empty()); + EXPECT_NE(aContent.find("ISO-10303-21;"), std::string::npos); + EXPECT_NE(aContent.find("NEXT_ASSEMBLY_USAGE_OCCURRENCE"), std::string::npos); + EXPECT_NE(aContent.find("MANIFOLD_SOLID_BREP"), std::string::npos); +} + +// bugs/step/bug30189_2: STEP preserves the top-level assembly structure and sharing. +TEST(GDT_STEP_Storage_Test, StepBug_30189_2_LocatedRootStructure) +{ + occ::handle anApplication = new TDocStd_Application(); + occ::handle aDocument = NewDocument(anApplication); + ASSERT_FALSE(aDocument.IsNull()); + + const TopoDS_Shape aBox = BRepPrimAPI_MakeBox(1.0, 1.0, 1.0).Shape(); + const TopoDS_Shape aSecondBox = + BRepPrimAPI_MakeBox(gp_Pnt(2.0, 0.0, 0.0), gp_Pnt(3.0, 1.0, 1.0)).Shape(); + const TopoDS_Shape aThirdBox = + BRepPrimAPI_MakeBox(gp_Pnt(4.0, 0.0, 0.0), gp_Pnt(5.0, 1.0, 1.0)).Shape(); + + BRep_Builder aBuilder; + TopoDS_Compound aCompound; + aBuilder.MakeCompound(aCompound); + aBuilder.Add(aCompound, aBox); + aBuilder.Add(aCompound, aSecondBox); + const TopoDS_Shape aLocatedCompound = TranslateShape(aCompound, 0.0, 2.0, 0.0); + + TopoDS_Compound aRootCompound; + aBuilder.MakeCompound(aRootCompound); + aBuilder.Add(aRootCompound, aThirdBox); + aBuilder.Add(aRootCompound, aCompound); + + occ::handle aShapeTool = XCAFDoc_DocumentTool::ShapeTool(aDocument->Main()); + ASSERT_FALSE(aShapeTool->AddShape(aRootCompound).IsNull()); + ASSERT_FALSE(aShapeTool->AddShape(aLocatedCompound).IsNull()); + + NCollection_Sequence aShapes; + aShapeTool->GetShapes(aShapes); + ASSERT_EQ(aShapes.Length(), 6); + NCollection_Sequence aUsers; + EXPECT_EQ(XCAFDoc_ShapeTool::GetUsers(aShapes.Value(3), aUsers), 2); + + occ::handle aRestored = RoundTrip(aDocument); + ASSERT_FALSE(aRestored.IsNull()); + occ::handle aRestoredShapeTool = + XCAFDoc_DocumentTool::ShapeTool(aRestored->Main()); + NCollection_Sequence aRestoredShapes; + aRestoredShapeTool->GetShapes(aRestoredShapes); + ASSERT_EQ(aRestoredShapes.Length(), 6); + NCollection_Sequence aRestoredUsers; + EXPECT_EQ(XCAFDoc_ShapeTool::GetUsers(aRestoredShapes.Value(3), aRestoredUsers), 2); + EXPECT_EQ(XCAFDoc_ShapeTool::NbComponents(aRestoredShapes.Value(6)), 1); +} + +// bugs/xde/bug1669: STEP preserves names throughout a nested assembly. +TEST(GDT_STEP_Storage_Test, XdeBug_1669_NestedAssemblyNames) +{ + occ::handle anApplication = new TDocStd_Application(); + occ::handle aDocument = NewDocument(anApplication); + ASSERT_FALSE(aDocument.IsNull()); + + const TopoDS_Shape aBox1 = + TranslateShape(BRepPrimAPI_MakeBox(10.0, 10.0, 10.0).Shape(), 10.0, 0.0, 0.0); + const TopoDS_Shape aBox2 = + TranslateShape(BRepPrimAPI_MakeBox(20.0, 10.0, 10.0).Shape(), 20.0, 0.0, 0.0); + + BRep_Builder aBuilder; + TopoDS_Compound aBlock; + aBuilder.MakeCompound(aBlock); + aBuilder.Add(aBlock, aBox1); + aBuilder.Add(aBlock, aBox2); + + const TopoDS_Shape aNextBlock = TranslateShape(aBlock, 30.0, 0.0, 0.0); + + TopoDS_Compound aRow; + aBuilder.MakeCompound(aRow); + aBuilder.Add(aRow, aBlock); + aBuilder.Add(aRow, aNextBlock); + + const TopoDS_Shape aHalfBrick = TranslateShape(aRow, -10.0, 0.0, 10.0); + const TopoDS_Shape aBrick = TranslateShape(aRow, 0.0, 0.0, 20.0); + + TopoDS_Compound aWall; + aBuilder.MakeCompound(aWall); + aBuilder.Add(aWall, aRow); + aBuilder.Add(aWall, aHalfBrick); + aBuilder.Add(aWall, aBrick); + + occ::handle aShapeTool = XCAFDoc_DocumentTool::ShapeTool(aDocument->Main()); + const TDF_Label aWallLabel = aShapeTool->AddShape(aWall, true); + ASSERT_FALSE(aWallLabel.IsNull()); + + NCollection_Sequence aShapes; + aShapeTool->GetShapes(aShapes); + ASSERT_EQ(aShapes.Length(), 5); + EXPECT_FALSE(TDataStd_Name::Set(aShapes.Value(1), "Wall").IsNull()); + EXPECT_FALSE(TDataStd_Name::Set(aShapes.Value(2), "Block-Array").IsNull()); + EXPECT_FALSE(TDataStd_Name::Set(aShapes.Value(3), "Block").IsNull()); + EXPECT_FALSE(TDataStd_Name::Set(aShapes.Value(4), "Half-Brick").IsNull()); + EXPECT_FALSE(TDataStd_Name::Set(aShapes.Value(5), "Brick").IsNull()); + + NCollection_Sequence aComponents; + ASSERT_TRUE(aShapeTool->GetComponents(aShapes.Value(1), aComponents)); + ASSERT_EQ(aComponents.Length(), 3); + EXPECT_FALSE(TDataStd_Name::Set(aComponents.Value(1), "base-array").IsNull()); + EXPECT_FALSE(TDataStd_Name::Set(aComponents.Value(2), "next-array").IsNull()); + EXPECT_FALSE(TDataStd_Name::Set(aComponents.Value(3), "top-array").IsNull()); + + aComponents.Clear(); + ASSERT_TRUE(aShapeTool->GetComponents(aShapes.Value(2), aComponents)); + ASSERT_EQ(aComponents.Length(), 2); + EXPECT_FALSE(TDataStd_Name::Set(aComponents.Value(1), "left-block").IsNull()); + EXPECT_FALSE(TDataStd_Name::Set(aComponents.Value(2), "right-block").IsNull()); + + aComponents.Clear(); + ASSERT_TRUE(aShapeTool->GetComponents(aShapes.Value(3), aComponents)); + ASSERT_EQ(aComponents.Length(), 2); + EXPECT_FALSE(TDataStd_Name::Set(aComponents.Value(1), "half-brick").IsNull()); + EXPECT_FALSE(TDataStd_Name::Set(aComponents.Value(2), "brick").IsNull()); + + occ::handle aRestored = RoundTrip(aDocument); + ASSERT_FALSE(aRestored.IsNull()); + const TDF_Label aRestoredRoot = aRestored->Main(); + EXPECT_FALSE(FindLabelByName(aRestoredRoot, "Wall").IsNull()); + EXPECT_FALSE(FindLabelByName(aRestoredRoot, "Block-Array").IsNull()); + EXPECT_FALSE(FindLabelByName(aRestoredRoot, "Block").IsNull()); + EXPECT_FALSE(FindLabelByName(aRestoredRoot, "Half-Brick").IsNull()); + EXPECT_FALSE(FindLabelByName(aRestoredRoot, "Brick").IsNull()); + EXPECT_FALSE(FindLabelByName(aRestoredRoot, "base-array").IsNull()); + EXPECT_FALSE(FindLabelByName(aRestoredRoot, "next-array").IsNull()); + EXPECT_FALSE(FindLabelByName(aRestoredRoot, "top-array").IsNull()); + EXPECT_FALSE(FindLabelByName(aRestoredRoot, "left-block").IsNull()); + EXPECT_FALSE(FindLabelByName(aRestoredRoot, "right-block").IsNull()); + EXPECT_FALSE(FindLabelByName(aRestoredRoot, "half-brick").IsNull()); + EXPECT_FALSE(FindLabelByName(aRestoredRoot, "brick").IsNull()); +} + +// bugs/step/bug_ocp1949_2: STEP tessellated export applies the document unit scaling. +TEST(GDT_STEP_Storage_Test, StepBug_Ocp1949_2_TessellatedScaling) +{ + const TopoDS_Shape aBox = BRepPrimAPI_MakeBox(1.0, 1.0, 1.0).Shape(); + BRepMesh_IncrementalMesh aMesh(aBox, 1.0); + ASSERT_TRUE(aMesh.IsDone()); + + occ::handle anApplication = new TDocStd_Application(); + occ::handle aDocument = NewDocument(anApplication); + ASSERT_FALSE(aDocument.IsNull()); + XCAFDoc_DocumentTool::SetLengthUnit(aDocument, 1.0); + occ::handle aShapeTool = XCAFDoc_DocumentTool::ShapeTool(aDocument->Main()); + ASSERT_FALSE(aShapeTool->AddShape(aBox).IsNull()); + + occ::handle aNode = new DESTEP_ConfigurationNode(); + aNode->InternalParameters.WriteSchema = DESTEP_Parameters::WriteMode_StepSchema_AP242DIS; + aNode->InternalParameters.WriteTessellated = DESTEP_Parameters::RWMode_Tessellated_On; + DESTEP_Provider aProvider(aNode); + + std::stringstream aStream; + DE_Provider::WriteStreamList aWriteStreams; + aWriteStreams.Append(DE_Provider::WriteStreamNode("ocp1949_2.step", aStream)); + ASSERT_TRUE(aProvider.Write(aWriteStreams, aDocument)); + ASSERT_FALSE(aStream.str().empty()); + EXPECT_NE(aStream.str().find("TESSELLATED_SHAPE_REPRESENTATION"), std::string::npos); + + aStream.seekg(0); + occ::handle aRestoredApplication = new TDocStd_Application(); + occ::handle aRestoredDocument = NewDocument(aRestoredApplication); + ASSERT_FALSE(aRestoredDocument.IsNull()); + DE_Provider::ReadStreamList aReadStreams; + aReadStreams.Append(DE_Provider::ReadStreamNode("ocp1949_2.step", aStream)); + ASSERT_TRUE(aProvider.Read(aReadStreams, aRestoredDocument)); + + occ::handle aRestoredShapeTool = + XCAFDoc_DocumentTool::ShapeTool(aRestoredDocument->Main()); + const TopoDS_Shape aRestoredShape = aRestoredShapeTool->GetOneShape(); + ASSERT_FALSE(aRestoredShape.IsNull()); + EXPECT_NEAR(ShapeDiagonal(aBox) * 1000.0, ShapeDiagonal(aRestoredShape), 0.1); +} + +// bugs/step/bug30189_3: STEP preserves names and sharing of located roots. +TEST(GDT_STEP_Storage_Test, StepBug_30189_3_LocatedRootSharing) +{ + occ::handle anApplication = new TDocStd_Application(); + occ::handle aDocument = NewDocument(anApplication); + ASSERT_FALSE(aDocument.IsNull()); + + const TopoDS_Shape aBaseBox = BRepPrimAPI_MakeBox(1.0, 1.0, 1.0).Shape(); + gp_Trsf aTranslation; + occ::handle aShapeTool = XCAFDoc_DocumentTool::ShapeTool(aDocument->Main()); + const TDF_Label aBaseLabel = aShapeTool->AddShape(aBaseBox); + ASSERT_FALSE(aBaseLabel.IsNull()); + + aTranslation.SetTranslation(gp_Vec(2.0, 0.0, 0.0)); + const TDF_Label aReference1 = + aShapeTool->AddShape(BRepBuilderAPI_Transform(aBaseBox, aTranslation).Shape()); + aTranslation.SetTranslation(gp_Vec(0.0, 2.0, 0.0)); + const TDF_Label aReference2 = + aShapeTool->AddShape(BRepBuilderAPI_Transform(aBaseBox, aTranslation).Shape()); + aTranslation.SetTranslation(gp_Vec(0.0, 0.0, 2.0)); + const TDF_Label aReference3 = + aShapeTool->AddShape(BRepBuilderAPI_Transform(aBaseBox, aTranslation).Shape()); + ASSERT_FALSE(aReference1.IsNull()); + ASSERT_FALSE(aReference2.IsNull()); + ASSERT_FALSE(aReference3.IsNull()); + ASSERT_FALSE(TDataStd_Name::Set(aBaseLabel, "box").IsNull()); + ASSERT_FALSE(TDataStd_Name::Set(aReference1, "ref1_box").IsNull()); + ASSERT_FALSE(TDataStd_Name::Set(aReference2, "ref2_box").IsNull()); + ASSERT_FALSE(TDataStd_Name::Set(aReference3, "ref3_box").IsNull()); + + NCollection_Sequence aShapes; + aShapeTool->GetShapes(aShapes); + ASSERT_EQ(aShapes.Length(), 4); + NCollection_Sequence aUsers; + EXPECT_EQ(XCAFDoc_ShapeTool::GetUsers(aBaseLabel, aUsers), 3); + + occ::handle aRestored = RoundTrip(aDocument); + ASSERT_FALSE(aRestored.IsNull()); + occ::handle aRestoredShapeTool = + XCAFDoc_DocumentTool::ShapeTool(aRestored->Main()); + NCollection_Sequence aRestoredShapes; + aRestoredShapeTool->GetShapes(aRestoredShapes); + ASSERT_EQ(aRestoredShapes.Length(), 4); + + const TDF_Label aRestoredBase = FindShapeByName(aRestoredShapes, "box"); + ASSERT_FALSE(aRestoredBase.IsNull()); + ASSERT_FALSE(FindShapeByName(aRestoredShapes, "ref1_box").IsNull()); + ASSERT_FALSE(FindShapeByName(aRestoredShapes, "ref2_box").IsNull()); + ASSERT_FALSE(FindShapeByName(aRestoredShapes, "ref3_box").IsNull()); + NCollection_Sequence aRestoredUsers; + EXPECT_EQ(XCAFDoc_ShapeTool::GetUsers(aRestoredBase, aRestoredUsers), 3); +} + +// bugs/xde/bug13175: STEP preserves a document containing a single vertex. +TEST(GDT_STEP_Storage_Test, XdeBug_13175_SingleVertex) +{ + occ::handle anApplication = new TDocStd_Application(); + occ::handle aDocument = NewDocument(anApplication); + ASSERT_FALSE(aDocument.IsNull()); + occ::handle aShapeTool = XCAFDoc_DocumentTool::ShapeTool(aDocument->Main()); + const TDF_Label aVertexLabel = aShapeTool->NewShape(); + aShapeTool->SetShape(aVertexLabel, BRepBuilderAPI_MakeVertex(gp_Pnt(10.0, 10.0, 10.0)).Shape()); + + occ::handle aRestored = RoundTripWithSTEPCAF(aDocument); + ASSERT_FALSE(aRestored.IsNull()); + occ::handle aRestoredShapeTool = + XCAFDoc_DocumentTool::ShapeTool(aRestored->Main()); + NCollection_Sequence aShapes; + aRestoredShapeTool->GetShapes(aShapes); + ASSERT_EQ(aShapes.Length(), 1); + const TopoDS_Shape aVertex = FindFirstVertex(aShapes.First()); + ASSERT_EQ(aVertex.ShapeType(), TopAbs_VERTEX); + const gp_Pnt aPoint = BRep_Tool::Pnt(TopoDS::Vertex(aVertex)); + EXPECT_DOUBLE_EQ(aPoint.X(), 10.0); + EXPECT_DOUBLE_EQ(aPoint.Y(), 10.0); + EXPECT_DOUBLE_EQ(aPoint.Z(), 10.0); +} + +// bugs/xde/bug31851: STEP preserves Unicode shape names. +TEST(GDT_STEP_Storage_Test, XdeBug_31851_UnicodeShapeName) +{ + occ::handle anApplication = new TDocStd_Application(); + occ::handle aDocument = NewDocument(anApplication); + ASSERT_FALSE(aDocument.IsNull()); + occ::handle aShapeTool = XCAFDoc_DocumentTool::ShapeTool(aDocument->Main()); + const TDF_Label aShapeLabel = aShapeTool->AddShape(BRepPrimAPI_MakeBox(10.0, 10.0, 10.0).Shape()); + ASSERT_FALSE(aShapeLabel.IsNull()); + const TCollection_ExtendedString anExpected(u"\u30DC\u30C3\u30AF\u30B9"); + ASSERT_FALSE(TDataStd_Name::Set(aShapeLabel, anExpected).IsNull()); + + occ::handle aRestored = RoundTrip(aDocument); + ASSERT_FALSE(aRestored.IsNull()); + EXPECT_EQ(RestoredFirstShapeName(aRestored), anExpected); +} diff --git a/src/DataExchange/TKDESTEP/STEPCAFControl/STEPCAFControl_Reader.cxx b/src/DataExchange/TKDESTEP/STEPCAFControl/STEPCAFControl_Reader.cxx index 1262ea954f..4108adeb9d 100644 --- a/src/DataExchange/TKDESTEP/STEPCAFControl/STEPCAFControl_Reader.cxx +++ b/src/DataExchange/TKDESTEP/STEPCAFControl/STEPCAFControl_Reader.cxx @@ -365,6 +365,15 @@ IFSelect_ReturnStatus STEPCAFControl_Reader::ReadStream(const char* const theNam //================================================================================================= +IFSelect_ReturnStatus STEPCAFControl_Reader::ReadStream(const char* const theName, + const DESTEP_Parameters& theParams, + std::istream& theIStream) +{ + return myReader.ReadStream(theName, theParams, theIStream); +} + +//================================================================================================= + int STEPCAFControl_Reader::NbRootsForTransfer() { return myReader.NbRootsForTransfer(); diff --git a/src/DataExchange/TKDESTEP/STEPCAFControl/STEPCAFControl_Reader.hxx b/src/DataExchange/TKDESTEP/STEPCAFControl/STEPCAFControl_Reader.hxx index 7cfdecdcef..25510a594e 100644 --- a/src/DataExchange/TKDESTEP/STEPCAFControl/STEPCAFControl_Reader.hxx +++ b/src/DataExchange/TKDESTEP/STEPCAFControl/STEPCAFControl_Reader.hxx @@ -107,6 +107,15 @@ public: Standard_EXPORT IFSelect_ReturnStatus ReadStream(const char* const theName, std::istream& theIStream); + //! Loads a file from stream with specified parameters and returns the read status. + //! @param[in] theName auxiliary stream name + //! @param[in] theParams default configuration parameters + //! @param[in] theIStream stream to read from + //! @return read status + Standard_EXPORT IFSelect_ReturnStatus ReadStream(const char* const theName, + const DESTEP_Parameters& theParams, + std::istream& theIStream); + //! Returns number of roots recognized for transfer //! Shortcut for Reader().NbRootsForTransfer() Standard_EXPORT int NbRootsForTransfer(); diff --git a/src/DataExchange/TKDESTL/GTests/DEMesh_ShapeWriteStl_Test.cxx b/src/DataExchange/TKDESTL/GTests/DEMesh_ShapeWriteStl_Test.cxx new file mode 100644 index 0000000000..2b6a0132be --- /dev/null +++ b/src/DataExchange/TKDESTL/GTests/DEMesh_ShapeWriteStl_Test.cxx @@ -0,0 +1,493 @@ +// Copyright (c) 2026 OPEN CASCADE SAS +// +// This file is part of Open CASCADE Technology software library. +// +// This library is free software; you can redistribute it and/or modify it under +// the terms of the GNU Lesser General Public License version 2.1 as published +// by the Free Software Foundation, with special exception defined in the file +// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT +// distribution for complete text of the license and disclaimer of any warranty. +// +// Alternatively, this file may be used under the terms of Open CASCADE +// commercial license or contractual agreement. + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include + +namespace +{ +class ProgressObserver : public Message_ProgressIndicator +{ +public: + const NCollection_Sequence& Messages() const { return myMessages; } + +protected: + void Show(const Message_ProgressScope& theScope, const bool) override + { + TCollection_AsciiString aMessage("Progress: "); + aMessage += static_cast(100.0 * GetPosition() + 0.5); + aMessage += "%"; + if (theScope.Name() != nullptr) + { + aMessage += " "; + aMessage += theScope.Name(); + aMessage += ": "; + aMessage += static_cast(theScope.Value() + 0.5); + aMessage += " / "; + aMessage += static_cast(theScope.MaxValue() + 0.5); + } + myMessages.Append(aMessage); + } + +private: + NCollection_Sequence myMessages; +}; + +static TopoDS_Shape MakeRegularTriangulatedFace() +{ + const int aNbU = 100; + const int aNbV = 100; + TopoDS_Face aFace = BRepBuilderAPI_MakeFace(gp_Pln(), 0.0, 100.0, 0.0, 100.0).Face(); + occ::handle aTriangulation = + new Poly_Triangulation((aNbU + 1) * (aNbV + 1), 2 * aNbU * aNbV, false); + for (int iU = 0; iU <= aNbU; ++iU) + { + for (int iV = 0; iV <= aNbV; ++iV) + { + const int aNode = 1 + iU * (aNbV + 1) + iV; + aTriangulation->SetNode(aNode, gp_Pnt(iU, iV, 0.0)); + } + } + int aTriangle = 1; + for (int iU = 0; iU < aNbU; ++iU) + { + for (int iV = 0; iV < aNbV; ++iV) + { + const int aBase = 1 + iU * (aNbV + 1) + iV; + aTriangulation->SetTriangle(aTriangle++, Poly_Triangle(aBase, aBase + aNbV + 2, aBase + 1)); + aTriangulation->SetTriangle(aTriangle++, + Poly_Triangle(aBase, aBase + aNbV + 1, aBase + aNbV + 2)); + } + } + BRep_Builder aBuilder; + aBuilder.UpdateFace(aFace, aTriangulation); + return aFace; +} + +static TCollection_AsciiString MakeTemporaryStlFile(OSD_Directory& theDirectory, OSD_Path& thePath) +{ + theDirectory.Path(thePath); + thePath.SetName("draw_shape_write_stl"); + thePath.SetExtension(".stl"); + + TCollection_AsciiString aSystemName; + thePath.SystemName(aSystemName); + return aSystemName; +} + +static int CountFaces(const TopoDS_Shape& theShape) +{ + int aNbFaces = 0; + for (TopExp_Explorer anExplorer(theShape, TopAbs_FACE); anExplorer.More(); anExplorer.Next()) + { + ++aNbFaces; + } + return aNbFaces; +} + +static int CountTriangles(const TopoDS_Shape& theShape) +{ + int aNbTriangles = 0; + for (TopExp_Explorer anExplorer(theShape, TopAbs_FACE); anExplorer.More(); anExplorer.Next()) + { + TopLoc_Location aLocation; + occ::handle aTriangulation = + BRep_Tool::Triangulation(TopoDS::Face(anExplorer.Current()), aLocation); + if (!aTriangulation.IsNull()) + { + aNbTriangles += aTriangulation->NbTriangles(); + } + } + return aNbTriangles; +} + +static TCollection_AsciiString MakeTemporaryStlFile(OSD_Directory& theDirectory, + const char* const theName, + OSD_Path& thePath) +{ + theDirectory.Path(thePath); + thePath.SetName(theName); + thePath.SetExtension(".stl"); + + TCollection_AsciiString aSystemName; + thePath.SystemName(aSystemName); + return aSystemName; +} + +static void WriteTemporaryFile(const OSD_Path& thePath, const void* theBuffer, const int theLength) +{ + OSD_File aFile(thePath); + aFile.Build(OSD_WriteOnly, OSD_Protection()); + if (theLength > 0) + { + aFile.Write(const_cast(theBuffer), theLength); + } + aFile.Close(); +} + +static void WriteTemporaryFile(const OSD_Path& thePath, const TCollection_AsciiString& theBuffer) +{ + WriteTemporaryFile(thePath, (void*)theBuffer.ToCString(), theBuffer.Length()); +} + +static void WriteBinaryStl(const OSD_Path& thePath, const bool theHasFacet) +{ + unsigned char aBuffer[134] = {}; + std::memcpy(aBuffer, "stl ", 4); + if (theHasFacet) + { + aBuffer[80] = 1; + + const float aNormal[3] = {0.0f, 0.0f, 1.0f}; + const float aVertex1[3] = {0.0f, 0.0f, 0.0f}; + const float aVertex2[3] = {1.0f, 0.0f, 0.0f}; + const float aVertex3[3] = {0.0f, 1.0f, 0.0f}; + std::memcpy(aBuffer + 84, aNormal, sizeof(aNormal)); + std::memcpy(aBuffer + 96, aVertex1, sizeof(aVertex1)); + std::memcpy(aBuffer + 108, aVertex2, sizeof(aVertex2)); + std::memcpy(aBuffer + 120, aVertex3, sizeof(aVertex3)); + } + WriteTemporaryFile(thePath, aBuffer, theHasFacet ? 134 : 84); +} + +static bool ReadStl(const TCollection_AsciiString& theFileName, TopoDS_Shape& theShape) +{ + StlAPI_Reader aReader; + return aReader.Read(theShape, theFileName.ToCString()); +} + +static TopoDS_Shape RoundTripStl(const TopoDS_Shape& theShape, const bool theAsciiMode = false) +{ + std::stringstream aStream; + StlAPI_Writer aWriter; + aWriter.ASCIIMode() = theAsciiMode; + if (!aWriter.Write(theShape, aStream)) + { + return TopoDS_Shape(); + } + + aStream.seekg(0); + TopoDS_Shape aRestoredShape; + StlAPI_Reader aReader; + if (!aReader.Read(aRestoredShape, aStream)) + { + return TopoDS_Shape(); + } + return aRestoredShape; +} + +static TopoDS_Shape RoundTripStlMesh(const TopoDS_Shape& theShape) +{ + std::stringstream aStream; + StlAPI_Writer aWriter; + aWriter.ASCIIMode() = false; + if (!aWriter.Write(theShape, aStream)) + { + return TopoDS_Shape(); + } + + aStream.seekg(0); + occ::handle aMesh = RWStl::ReadStream(aStream); + if (aMesh.IsNull()) + { + return TopoDS_Shape(); + } + + BRep_Builder aBuilder; + TopoDS_Face aFace; + aBuilder.MakeFace(aFace); + aBuilder.UpdateFace(aFace, aMesh); + return aFace; +} +} // namespace + +// de_mesh/shape_write_stl/B1: the DRAW writestl path reports progress and +// produces a readable STL file from a generated triangulated shape. +TEST(DEMesh_ShapeWriteStl_Test, B1_WriteProgressAndReadBack) +{ + const TopoDS_Shape aShape = MakeRegularTriangulatedFace(); + ASSERT_FALSE(aShape.IsNull()); + + OSD_Directory aDirectory = OSD_Directory::BuildTemporary(); + OSD_Path aPath; + const TCollection_AsciiString aFileName = MakeTemporaryStlFile(aDirectory, aPath); + occ::handle aProgress = new ProgressObserver(); + StlAPI_Writer aWriter; + aWriter.ASCIIMode() = false; + + EXPECT_TRUE(aWriter.Write(aShape, aFileName.ToCString(), aProgress->Start())); + const char* const anExpected[] = { + "Progress: 0%", + "Progress: 5% Triangles: 1000 / 20000", + "Progress: 10% Triangles: 2000 / 20000", + "Progress: 15% Triangles: 3000 / 20000", + "Progress: 20% Triangles: 4000 / 20000", + "Progress: 25% Triangles: 5000 / 20000", + "Progress: 30% Triangles: 6000 / 20000", + "Progress: 35% Triangles: 7000 / 20000", + "Progress: 40% Triangles: 8000 / 20000", + "Progress: 45% Triangles: 9000 / 20000", + "Progress: 50% Triangles: 10000 / 20000", + "Progress: 55% Triangles: 11000 / 20000", + "Progress: 60% Triangles: 12000 / 20000", + "Progress: 65% Triangles: 13000 / 20000", + "Progress: 70% Triangles: 14000 / 20000", + "Progress: 75% Triangles: 15000 / 20000", + "Progress: 80% Triangles: 16000 / 20000", + "Progress: 85% Triangles: 17000 / 20000", + "Progress: 90% Triangles: 18000 / 20000", + "Progress: 95% Triangles: 19000 / 20000", + "Progress: 100% Triangles: 20000 / 20000", + }; + ASSERT_EQ(aProgress->Messages().Length(), + static_cast(sizeof(anExpected) / sizeof(*anExpected))); + for (int anIndex = 1; anIndex <= aProgress->Messages().Length(); ++anIndex) + { + EXPECT_STREQ(aProgress->Messages().Value(anIndex).ToCString(), anExpected[anIndex - 1]); + } + EXPECT_DOUBLE_EQ(aProgress->GetPosition(), 1.0); + + OSD_File aFile(aPath); + ASSERT_TRUE(aFile.Exists()); + + TopoDS_Shape aRestored; + StlAPI_Reader aReader; + EXPECT_TRUE(aReader.Read(aRestored, aFileName.ToCString())); + EXPECT_FALSE(aRestored.IsNull()); + EXPECT_GT(CountFaces(aRestored), 0); + + aFile.Remove(); +} + +// de_mesh/stl_read/D1: the DRAW reader accepts ASCII STL with both line endings, +// a missing final EOL, and a binary STL, while rejecting empty files. +TEST(DEMesh_StlRead_Test, D1_ReadAsciiAndBinaryBoundaryCases) +{ + const TCollection_AsciiString aMinimalAsciiStl("solid\n" + "facet normal 0 0 1\n" + "outer loop\n" + "vertex 0 0 0\n" + "vertex 1 0 0\n" + "vertex 0 1 0\n" + "endloop\n" + "endfacet\n" + "endsolid"); + + OSD_Directory aDirectory = OSD_Directory::BuildTemporary(); + + OSD_Path aDosPath; + const TCollection_AsciiString aDosName = + MakeTemporaryStlFile(aDirectory, "draw_stl_one_ascii_dos", aDosPath); + const TCollection_AsciiString aDosAscii("solid\r\n" + "facet normal 0 0 1\r\n" + "outer loop\r\n" + "vertex 0 0 0\r\n" + "vertex 1 0 0\r\n" + "vertex 0 1 0\r\n" + "endloop\r\n" + "endfacet\r\n" + "endsolid\r\n"); + WriteTemporaryFile(aDosPath, aDosAscii); + TopoDS_Shape aDosShape; + ASSERT_TRUE(ReadStl(aDosName, aDosShape)); + EXPECT_EQ(CountFaces(aDosShape), 1); + + OSD_Path aUnixPath; + const TCollection_AsciiString aUnixName = + MakeTemporaryStlFile(aDirectory, "draw_stl_one_ascii_unix", aUnixPath); + WriteTemporaryFile(aUnixPath, aMinimalAsciiStl + "\n"); + TopoDS_Shape aUnixShape; + ASSERT_TRUE(ReadStl(aUnixName, aUnixShape)); + EXPECT_EQ(CountFaces(aUnixShape), 1); + + OSD_Path aNoEolPath; + const TCollection_AsciiString aNoEolName = + MakeTemporaryStlFile(aDirectory, "draw_stl_one_ascii_noeol", aNoEolPath); + WriteTemporaryFile(aNoEolPath, aMinimalAsciiStl); + TopoDS_Shape aNoEolShape; + ASSERT_TRUE(ReadStl(aNoEolName, aNoEolShape)); + EXPECT_EQ(CountFaces(aNoEolShape), 1); + + const TCollection_AsciiString aZeroAsciiStl("solid \nendsolid"); + OSD_Path aZeroAsciiPath; + const TCollection_AsciiString aZeroAsciiName = + MakeTemporaryStlFile(aDirectory, "draw_stl_zero_ascii", aZeroAsciiPath); + WriteTemporaryFile(aZeroAsciiPath, aZeroAsciiStl); + TopoDS_Shape aZeroAsciiShape; + EXPECT_FALSE(ReadStl(aZeroAsciiName, aZeroAsciiShape)); + EXPECT_TRUE(aZeroAsciiShape.IsNull()); + + OSD_Path aBinaryPath; + const TCollection_AsciiString aBinaryName = + MakeTemporaryStlFile(aDirectory, "draw_stl_one_binary", aBinaryPath); + WriteBinaryStl(aBinaryPath, true); + TopoDS_Shape aBinaryShape; + ASSERT_TRUE(ReadStl(aBinaryName, aBinaryShape)); + EXPECT_EQ(CountFaces(aBinaryShape), 1); + + OSD_Path aZeroBinaryPath; + const TCollection_AsciiString aZeroBinaryName = + MakeTemporaryStlFile(aDirectory, "draw_stl_zero_binary", aZeroBinaryPath); + WriteBinaryStl(aZeroBinaryPath, false); + TopoDS_Shape aZeroBinaryShape; + EXPECT_FALSE(ReadStl(aZeroBinaryName, aZeroBinaryShape)); + EXPECT_TRUE(aZeroBinaryShape.IsNull()); + + OSD_Path aEmptyPath; + const TCollection_AsciiString aEmptyName = + MakeTemporaryStlFile(aDirectory, "draw_stl_empty", aEmptyPath); + const char* anEmptyBuffer = ""; + WriteTemporaryFile(aEmptyPath, anEmptyBuffer, 0); + TopoDS_Shape anEmptyShape; + EXPECT_FALSE(ReadStl(aEmptyName, anEmptyShape)); + EXPECT_TRUE(anEmptyShape.IsNull()); + + OSD_File aFile(aDosPath); + aFile.Remove(); + OSD_File(aUnixPath).Remove(); + OSD_File(aNoEolPath).Remove(); + OSD_File(aZeroAsciiPath).Remove(); + OSD_File(aBinaryPath).Remove(); + OSD_File(aZeroBinaryPath).Remove(); + OSD_File(aEmptyPath).Remove(); +} + +// bugs/modalg_7/bug30829: STL round-trips remain usable by shape proximity. +TEST(DEMesh_ShapeWriteStl_Test, ModalgBug_30829_ProximityAfterStlRoundTrip) +{ + const TopoDS_Shape aBox = BRepPrimAPI_MakeBox(10.0, 10.0, 10.0).Shape(); + const TopoDS_Shape aCylinder = BRepPrimAPI_MakeCylinder(5.0, 10.0).Shape(); + BRepMesh_IncrementalMesh aBoxMesher(aBox, 0.1); + BRepMesh_IncrementalMesh aCylinderMesher(aCylinder, 0.1); + + const TopoDS_Shape aRestoredBox = RoundTripStlMesh(aBox); + const TopoDS_Shape aRestoredCylinder = RoundTripStlMesh(aCylinder); + ASSERT_FALSE(aRestoredBox.IsNull()); + ASSERT_FALSE(aRestoredCylinder.IsNull()); + + BRepExtrema_ShapeProximity aProximity(0.0); + ASSERT_TRUE(aProximity.LoadShape1(aRestoredBox)); + ASSERT_TRUE(aProximity.LoadShape2(aRestoredCylinder)); + aProximity.Perform(); + ASSERT_TRUE(aProximity.IsDone()); + EXPECT_GT(aProximity.ElementSet1()->Size(), 0); + EXPECT_GT(aProximity.ElementSet2()->Size(), 0); +} + +// bugs/stlvrml/bug26338: binary STL preserves the locations of compound parts. +TEST(DEMesh_ShapeWriteStl_Test, StlBug_26338_CompoundLocations) +{ + const TopoDS_Shape aFirstBox = BRepPrimAPI_MakeBox(5.0, 5.0, 5.0).Shape(); + gp_Trsf aTranslation; + aTranslation.SetTranslation(gp_Vec(10.0, 10.0, 10.0)); + const TopoDS_Shape aSecondBox = BRepBuilderAPI_Transform(aFirstBox, aTranslation).Shape(); + + BRep_Builder aBuilder; + TopoDS_Compound aCompound; + aBuilder.MakeCompound(aCompound); + aBuilder.Add(aCompound, aFirstBox); + aBuilder.Add(aCompound, aSecondBox); + BRepMesh_IncrementalMesh aMesher(aCompound, 1.0); + + const TopoDS_Shape aRestored = RoundTripStl(aCompound); + ASSERT_FALSE(aRestored.IsNull()); + Bnd_Box aBounds; + BRepBndLib::Add(aRestored, aBounds); + double aXMin = 0.0; + double aYMin = 0.0; + double aZMin = 0.0; + double aXMax = 0.0; + double aYMax = 0.0; + double aZMax = 0.0; + aBounds.Get(aXMin, aYMin, aZMin, aXMax, aYMax, aZMax); + EXPECT_NEAR(aXMin, 0.0, 1.0e-6); + EXPECT_NEAR(aYMin, 0.0, 1.0e-6); + EXPECT_NEAR(aZMin, 0.0, 1.0e-6); + EXPECT_NEAR(aXMax, 15.0, 1.0e-6); + EXPECT_NEAR(aYMax, 15.0, 1.0e-6); + EXPECT_NEAR(aZMax, 15.0, 1.0e-6); +} + +// bugs/stlvrml/bug30389: STL writing skips an untriangulated face and keeps the +// ten triangles generated for the five meshed faces. +TEST(DEMesh_ShapeWriteStl_Test, StlBug_30389_MissingFaceTriangulation) +{ + const TopoDS_Shape aBox = BRepPrimAPI_MakeBox(1.0, 1.0, 1.0).Shape(); + BRep_Builder aBuilder; + TopoDS_Compound aMeshedFaces; + aBuilder.MakeCompound(aMeshedFaces); + int aFaceIndex = 0; + for (TopExp_Explorer anExplorer(aBox, TopAbs_FACE); anExplorer.More() && aFaceIndex < 5; + anExplorer.Next(), ++aFaceIndex) + { + aBuilder.Add(aMeshedFaces, anExplorer.Current()); + } + ASSERT_EQ(aFaceIndex, 5); + BRepMesh_IncrementalMesh aMesher(aMeshedFaces, 0.1); + + const TopoDS_Shape aRestored = RoundTripStl(aBox); + ASSERT_FALSE(aRestored.IsNull()); + EXPECT_EQ(CountFaces(aRestored), 10); +} + +// bugs/xde/bug25357: STL writing does not remesh an already triangulated torus. +TEST(DEMesh_ShapeWriteStl_Test, XdeBug_25357_PreserveTriangulation) +{ + const TopoDS_Shape aTorus = BRepPrimAPI_MakeTorus(10.0, 8.0).Shape(); + BRepMesh_IncrementalMesh aMesher(aTorus, 0.5); + const int aTrianglesBefore = CountTriangles(aTorus); + ASSERT_GT(aTrianglesBefore, 0); + + std::stringstream aStream; + StlAPI_Writer aWriter; + aWriter.ASCIIMode() = false; + EXPECT_TRUE(aWriter.Write(aTorus, aStream)); + EXPECT_FALSE(aStream.str().empty()); + EXPECT_EQ(CountTriangles(aTorus), aTrianglesBefore); +} diff --git a/src/DataExchange/TKDESTL/GTests/DESTL_Provider_Test.cxx b/src/DataExchange/TKDESTL/GTests/DESTL_Provider_Test.cxx index 6b8da31929..29b0aed95c 100644 --- a/src/DataExchange/TKDESTL/GTests/DESTL_Provider_Test.cxx +++ b/src/DataExchange/TKDESTL/GTests/DESTL_Provider_Test.cxx @@ -20,6 +20,7 @@ #include #include #include +#include #include #include #include @@ -31,14 +32,35 @@ #include #include #include +#include #include #include #include #include #include +#include #include +namespace +{ +static int CountTriangles(const TopoDS_Shape& theShape) +{ + int aCount = 0; + for (TopExp_Explorer anExplorer(theShape, TopAbs_FACE); anExplorer.More(); anExplorer.Next()) + { + TopLoc_Location aLocation; + const occ::handle aTriangulation = + BRep_Tool::Triangulation(TopoDS::Face(anExplorer.Current()), aLocation); + if (!aTriangulation.IsNull()) + { + aCount += aTriangulation->NbTriangles(); + } + } + return aCount; +} +} // namespace + class DESTL_ProviderTest : public ::testing::Test { protected: @@ -251,6 +273,114 @@ TEST_F(DESTL_ProviderTest, DE_WrapperIntegration) } } +// de_wrapper/stl/A1: direct STL write followed by wrapper stream read. +TEST_F(DESTL_ProviderTest, DEWrapper_Stl_A1_ShapeRoundTrip) +{ + std::ostringstream aOutput; + DE_Provider::WriteStreamList aWriteStreams; + aWriteStreams.Append(DE_Provider::WriteStreamNode("source.stl", aOutput)); + ASSERT_TRUE(myProvider->Write(aWriteStreams, myTriangularFace)); + + std::istringstream aInput(aOutput.str()); + DE_Provider::ReadStreamList aReadStreams; + aReadStreams.Append(DE_Provider::ReadStreamNode("source.stl", aInput)); + DE_Wrapper aWrapper; + ASSERT_TRUE(aWrapper.Bind(new DESTL_ConfigurationNode())); + + TopoDS_Shape aReadShape; + ASSERT_TRUE(aWrapper.Read(aReadStreams, aReadShape)); + EXPECT_EQ(CountShapeElements(aReadShape, TopAbs_FACE), 1); + EXPECT_EQ(CountTriangles(aReadShape), 2); +} + +// de_wrapper/stl/A2: wrapper document write followed by direct STL read. +TEST_F(DESTL_ProviderTest, DEWrapper_Stl_A2_DocumentWrite) +{ + occ::handle anApplication = new TDocStd_Application(); + occ::handle aDocument; + anApplication->NewDocument("BinXCAF", aDocument); + ASSERT_FALSE(aDocument.IsNull()); + XCAFDoc_DocumentTool::ShapeTool(aDocument->Main())->AddShape(myTriangularFace); + + occ::handle aNode = new DESTL_ConfigurationNode(); + aNode->InternalParameters.WriteAscii = true; + DE_Wrapper aWrapper; + ASSERT_TRUE(aWrapper.Bind(aNode)); + + std::ostringstream aOutput; + DE_Provider::WriteStreamList aWriteStreams; + aWriteStreams.Append(DE_Provider::WriteStreamNode("document.stl", aOutput)); + ASSERT_TRUE(aWrapper.Write(aWriteStreams, aDocument)); + ASSERT_FALSE(aOutput.str().empty()); + + std::istringstream aInput(aOutput.str()); + DE_Provider::ReadStreamList aReadStreams; + aReadStreams.Append(DE_Provider::ReadStreamNode("document.stl", aInput)); + occ::handle aProvider = new DESTL_Provider(new DESTL_ConfigurationNode()); + TopoDS_Shape aReadShape; + ASSERT_TRUE(aProvider->Read(aReadStreams, aReadShape)); + EXPECT_EQ(CountShapeElements(aReadShape, TopAbs_FACE), 1); +} + +// de_wrapper/stl/A3: wrapper shape write followed by wrapper document read. +TEST_F(DESTL_ProviderTest, DEWrapper_Stl_A3_DocumentRead) +{ + occ::handle aNode = new DESTL_ConfigurationNode(); + aNode->InternalParameters.WriteAscii = true; + DE_Wrapper aWrapper; + ASSERT_TRUE(aWrapper.Bind(aNode)); + + std::ostringstream aOutput; + DE_Provider::WriteStreamList aWriteStreams; + aWriteStreams.Append(DE_Provider::WriteStreamNode("shape.stl", aOutput)); + ASSERT_TRUE(aWrapper.Write(aWriteStreams, myTriangularFace)); + + std::istringstream aInput(aOutput.str()); + DE_Provider::ReadStreamList aReadStreams; + aReadStreams.Append(DE_Provider::ReadStreamNode("shape.stl", aInput)); + occ::handle anApplication = new TDocStd_Application(); + occ::handle aDocument; + anApplication->NewDocument("BinXCAF", aDocument); + ASSERT_TRUE(aWrapper.Read(aReadStreams, aDocument)); + + NCollection_Sequence aLabels; + XCAFDoc_DocumentTool::ShapeTool(aDocument->Main())->GetFreeShapes(aLabels); + ASSERT_EQ(aLabels.Length(), 1); + EXPECT_GT(CountShapeElements( + XCAFDoc_DocumentTool::ShapeTool(aDocument->Main())->GetShape(aLabels.First()), + TopAbs_FACE), + 0); +} + +// de_wrapper/stl/A4: wrapper shape stream read/write/read round trip. +TEST_F(DESTL_ProviderTest, DEWrapper_Stl_A4_ShapeRoundTrip) +{ + std::ostringstream aSourceOutput; + DE_Provider::WriteStreamList aSourceWriteStreams; + aSourceWriteStreams.Append(DE_Provider::WriteStreamNode("source.stl", aSourceOutput)); + ASSERT_TRUE(myProvider->Write(aSourceWriteStreams, myTriangularFace)); + + DE_Wrapper aWrapper; + ASSERT_TRUE(aWrapper.Bind(new DESTL_ConfigurationNode())); + std::istringstream aSourceInput(aSourceOutput.str()); + DE_Provider::ReadStreamList aSourceReadStreams; + aSourceReadStreams.Append(DE_Provider::ReadStreamNode("source.stl", aSourceInput)); + TopoDS_Shape aReadShape; + ASSERT_TRUE(aWrapper.Read(aSourceReadStreams, aReadShape)); + + std::ostringstream aRoundTripOutput; + DE_Provider::WriteStreamList aRoundTripWriteStreams; + aRoundTripWriteStreams.Append(DE_Provider::WriteStreamNode("roundtrip.stl", aRoundTripOutput)); + ASSERT_TRUE(aWrapper.Write(aRoundTripWriteStreams, aReadShape)); + + std::istringstream aRoundTripInput(aRoundTripOutput.str()); + DE_Provider::ReadStreamList aRoundTripReadStreams; + aRoundTripReadStreams.Append(DE_Provider::ReadStreamNode("roundtrip.stl", aRoundTripInput)); + TopoDS_Shape aRoundTripShape; + ASSERT_TRUE(aWrapper.Read(aRoundTripReadStreams, aRoundTripShape)); + EXPECT_GT(CountShapeElements(aRoundTripShape, TopAbs_FACE), 0); +} + // Test error conditions and edge cases with null document validation TEST_F(DESTL_ProviderTest, ErrorHandling) { @@ -416,29 +546,33 @@ TEST_F(DESTL_ProviderTest, DE_WrapperFileExtensions) EXPECT_TRUE(aWrapper.Bind(aNode)); // Test different STL extensions - std::vector aExtensions = {"test.stl", "test.STL", "mesh.stl"}; + NCollection_Array1 aExtensions(1, 3); + aExtensions.SetValue(1, "test.stl"); + aExtensions.SetValue(2, "test.STL"); + aExtensions.SetValue(3, "mesh.stl"); - for (const auto& anExt : aExtensions) + for (int anIndex = aExtensions.Lower(); anIndex <= aExtensions.Upper(); ++anIndex) { - std::ostringstream anOStream; - DE_Provider::WriteStreamList aWriteStreams; - aWriteStreams.Append(DE_Provider::WriteStreamNode(anExt.c_str(), anOStream)); + const TCollection_AsciiString& anExt = aExtensions.Value(anIndex); + std::ostringstream anOStream; + DE_Provider::WriteStreamList aWriteStreams; + aWriteStreams.Append(DE_Provider::WriteStreamNode(anExt, anOStream)); EXPECT_TRUE(aWrapper.Write(aWriteStreams, myTriangularFace)) - << "Failed to write with extension: " << anExt; + << "Failed to write with extension: " << anExt.ToCString(); std::string aContent = anOStream.str(); - EXPECT_FALSE(aContent.empty()) << "Empty content for extension: " << anExt; + EXPECT_FALSE(aContent.empty()) << "Empty content for extension: " << anExt.ToCString(); // Test read back std::istringstream anIStream(aContent); DE_Provider::ReadStreamList aReadStreams; - aReadStreams.Append(DE_Provider::ReadStreamNode(anExt.c_str(), anIStream)); + aReadStreams.Append(DE_Provider::ReadStreamNode(anExt, anIStream)); TopoDS_Shape aReadShape; EXPECT_TRUE(aWrapper.Read(aReadStreams, aReadShape)) - << "Failed to read with extension: " << anExt; - EXPECT_FALSE(aReadShape.IsNull()) << "Null shape read with extension: " << anExt; + << "Failed to read with extension: " << anExt.ToCString(); + EXPECT_FALSE(aReadShape.IsNull()) << "Null shape read with extension: " << anExt.ToCString(); } } diff --git a/src/DataExchange/TKDESTL/GTests/FILES.cmake b/src/DataExchange/TKDESTL/GTests/FILES.cmake index e88079fa28..0109426265 100644 --- a/src/DataExchange/TKDESTL/GTests/FILES.cmake +++ b/src/DataExchange/TKDESTL/GTests/FILES.cmake @@ -2,5 +2,6 @@ set(OCCT_TKDESTL_GTests_FILES_LOCATION "${CMAKE_CURRENT_LIST_DIR}") set(OCCT_TKDESTL_GTests_FILES + DEMesh_ShapeWriteStl_Test.cxx DESTL_Provider_Test.cxx ) diff --git a/src/DataExchange/TKDEVRML/GTests/DEVRML_Provider_Test.cxx b/src/DataExchange/TKDEVRML/GTests/DEVRML_Provider_Test.cxx index 60e1064dea..87bc45dcae 100644 --- a/src/DataExchange/TKDEVRML/GTests/DEVRML_Provider_Test.cxx +++ b/src/DataExchange/TKDEVRML/GTests/DEVRML_Provider_Test.cxx @@ -14,13 +14,17 @@ #include #include #include +#include #include #include +#include #include +#include #include #include #include +#include #include #include #include @@ -29,6 +33,7 @@ #include #include #include +#include #include #include #include @@ -37,8 +42,54 @@ #include #include +#include +#include #include +namespace +{ +static int CountTriangulationTriangles(const TopoDS_Shape& theShape) +{ + int aNbTriangles = 0; + for (TopExp_Explorer anExplorer(theShape, TopAbs_FACE); anExplorer.More(); anExplorer.Next()) + { + TopLoc_Location aLocation; + const occ::handle aTriangulation = + BRep_Tool::Triangulation(TopoDS::Face(anExplorer.Current()), aLocation); + if (!aTriangulation.IsNull()) + { + aNbTriangles += aTriangulation->NbTriangles(); + } + } + return aNbTriangles; +} + +static int CountTriangulationNodes(const TopoDS_Shape& theShape) +{ + int aNbNodes = 0; + for (TopExp_Explorer anExplorer(theShape, TopAbs_FACE); anExplorer.More(); anExplorer.Next()) + { + TopLoc_Location aLocation; + const occ::handle aTriangulation = + BRep_Tool::Triangulation(TopoDS::Face(anExplorer.Current()), aLocation); + if (!aTriangulation.IsNull()) + { + aNbNodes += aTriangulation->NbNodes(); + } + } + return aNbNodes; +} + +static bool ReadVrmlShape(const std::string& theContent, TopoDS_Shape& theShape) +{ + occ::handle aProvider = new DEVRML_Provider(new DEVRML_ConfigurationNode()); + std::istringstream anInput(theContent); + DE_Provider::ReadStreamList aStreams; + aStreams.Append(DE_Provider::ReadStreamNode("bug.vrml", anInput)); + return aProvider->Read(aStreams, theShape); +} +} // namespace + class DEVRML_ProviderTest : public ::testing::Test { protected: @@ -444,6 +495,115 @@ TEST_F(DEVRML_ProviderTest, DE_WrapperDocumentOperations) } } +// de_wrapper/vrml/A1: wrapper document write followed by wrapper shape read. +TEST_F(DEVRML_ProviderTest, DEWrapper_Vrml_A1_DocumentWrite) +{ + DE_Wrapper aWrapper; + occ::handle aNode = new DEVRML_ConfigurationNode(); + aNode->InternalParameters.WriteRepresentationType = + DEVRML_ConfigurationNode::WriteMode_RepresentationType_Both; + ASSERT_TRUE(aWrapper.Bind(aNode)); + + occ::handle aShapeTool = XCAFDoc_DocumentTool::ShapeTool(myDocument->Main()); + ASSERT_FALSE(aShapeTool->AddShape(myTriangularFace).IsNull()); + + std::ostringstream aOutput; + DE_Provider::WriteStreamList aWriteStreams; + aWriteStreams.Append(DE_Provider::WriteStreamNode("document.vrml", aOutput)); + ASSERT_TRUE(aWrapper.Write(aWriteStreams, myDocument)); + + std::istringstream aInput(aOutput.str()); + DE_Provider::ReadStreamList aReadStreams; + aReadStreams.Append(DE_Provider::ReadStreamNode("document.vrml", aInput)); + TopoDS_Shape aReadShape; + ASSERT_TRUE(aWrapper.Read(aReadStreams, aReadShape)); + EXPECT_GT(CountShapeElements(aReadShape, TopAbs_FACE), 0); +} + +// de_wrapper/vrml/A2: wrapper shaded document write followed by shape read. +TEST_F(DEVRML_ProviderTest, DEWrapper_Vrml_A2_ShadedDocumentWrite) +{ + DE_Wrapper aWrapper; + occ::handle aNode = new DEVRML_ConfigurationNode(); + aNode->InternalParameters.WriteRepresentationType = + DEVRML_ConfigurationNode::WriteMode_RepresentationType_Shaded; + ASSERT_TRUE(aWrapper.Bind(aNode)); + + occ::handle aShapeTool = XCAFDoc_DocumentTool::ShapeTool(myDocument->Main()); + ASSERT_FALSE(aShapeTool->AddShape(myTriangularFace).IsNull()); + + std::ostringstream aOutput; + DE_Provider::WriteStreamList aWriteStreams; + aWriteStreams.Append(DE_Provider::WriteStreamNode("document.wrl", aOutput)); + ASSERT_TRUE(aWrapper.Write(aWriteStreams, myDocument)); + + std::istringstream aInput(aOutput.str()); + DE_Provider::ReadStreamList aReadStreams; + aReadStreams.Append(DE_Provider::ReadStreamNode("document.wrl", aInput)); + TopoDS_Shape aReadShape; + ASSERT_TRUE(aWrapper.Read(aReadStreams, aReadShape)); + EXPECT_GT(CountShapeElements(aReadShape, TopAbs_FACE), 0); +} + +// de_wrapper/vrml/A3: wrapper shaded shape write followed by wrapper shape read. +TEST_F(DEVRML_ProviderTest, DEWrapper_Vrml_A3_ShadedShapeRoundTrip) +{ + DE_Wrapper aWrapper; + occ::handle aNode = new DEVRML_ConfigurationNode(); + aNode->InternalParameters.WriteRepresentationType = + DEVRML_ConfigurationNode::WriteMode_RepresentationType_Shaded; + ASSERT_TRUE(aWrapper.Bind(aNode)); + + std::ostringstream aOutput; + DE_Provider::WriteStreamList aWriteStreams; + aWriteStreams.Append(DE_Provider::WriteStreamNode("shape.wrl", aOutput)); + ASSERT_TRUE(aWrapper.Write(aWriteStreams, myTriangularFace)); + + std::istringstream aInput(aOutput.str()); + DE_Provider::ReadStreamList aReadStreams; + aReadStreams.Append(DE_Provider::ReadStreamNode("shape.wrl", aInput)); + TopoDS_Shape aReadShape; + ASSERT_TRUE(aWrapper.Read(aReadStreams, aReadShape)); + EXPECT_GT(CountShapeElements(aReadShape, TopAbs_FACE), 0); +} + +// de_wrapper/vrml/A4: wrapper shape stream read/write/read round trip. +TEST_F(DEVRML_ProviderTest, DEWrapper_Vrml_A4_ShapeRoundTrip) +{ + occ::handle aNode = new DEVRML_ConfigurationNode(); + aNode->InternalParameters.WriteRepresentationType = + DEVRML_ConfigurationNode::WriteMode_RepresentationType_Shaded; + DEVRML_Provider aProvider(aNode); + + std::ostringstream aSourceOutput; + DE_Provider::WriteStreamList aSourceWriteStreams; + aSourceWriteStreams.Append(DE_Provider::WriteStreamNode("source.wrl", aSourceOutput)); + ASSERT_TRUE(aProvider.Write(aSourceWriteStreams, myTriangularFace)); + + DE_Wrapper aWrapper; + occ::handle aWrapperNode = new DEVRML_ConfigurationNode(); + aWrapperNode->InternalParameters.WriteRepresentationType = + DEVRML_ConfigurationNode::WriteMode_RepresentationType_Both; + ASSERT_TRUE(aWrapper.Bind(aWrapperNode)); + std::istringstream aSourceInput(aSourceOutput.str()); + DE_Provider::ReadStreamList aSourceReadStreams; + aSourceReadStreams.Append(DE_Provider::ReadStreamNode("source.wrl", aSourceInput)); + TopoDS_Shape aReadShape; + ASSERT_TRUE(aWrapper.Read(aSourceReadStreams, aReadShape)); + + std::ostringstream aRoundTripOutput; + DE_Provider::WriteStreamList aRoundTripWriteStreams; + aRoundTripWriteStreams.Append(DE_Provider::WriteStreamNode("roundtrip.wrl", aRoundTripOutput)); + ASSERT_TRUE(aWrapper.Write(aRoundTripWriteStreams, aReadShape)); + + std::istringstream aRoundTripInput(aRoundTripOutput.str()); + DE_Provider::ReadStreamList aRoundTripReadStreams; + aRoundTripReadStreams.Append(DE_Provider::ReadStreamNode("roundtrip.wrl", aRoundTripInput)); + TopoDS_Shape aRoundTripShape; + ASSERT_TRUE(aWrapper.Read(aRoundTripReadStreams, aRoundTripShape)); + EXPECT_GT(CountShapeElements(aRoundTripShape, TopAbs_FACE), 0); +} + // Test error conditions and edge cases TEST_F(DEVRML_ProviderTest, ErrorHandling) { @@ -517,4 +677,104 @@ TEST_F(DEVRML_ProviderTest, ConfigurationModes) // Test that provider format and vendor are correct EXPECT_STREQ("VRML", myProvider->GetFormat().ToCString()); EXPECT_STREQ("OCC", myProvider->GetVendor().ToCString()); -} \ No newline at end of file +} + +// bugs/stlvrml/bug25279: a VRML written from an OCCT triangulation can be read +// back through the stream provider without changing the source triangulation. +TEST(DEVRML_Bug_Test, StlVrmlBug_25279_StreamRoundTrip) +{ + const double aPi = 3.14159265358979323846; + const TopoDS_Shape aTorus = + BRepPrimAPI_MakeTorus(10.0, 8.0, 0.0, 90.0 * aPi / 180.0, 270.0 * aPi / 180.0).Shape(); + BRepMesh_IncrementalMesh aMesher(aTorus, 0.1); + const int aTrianglesBefore = CountTriangulationTriangles(aTorus); + ASSERT_GT(aTrianglesBefore, 0); + + VrmlAPI_Writer aWriter; + aWriter.SetRepresentation(VrmlAPI_BothRepresentation); + std::ostringstream aOutput; + ASSERT_TRUE(aWriter.Write(aTorus, aOutput, 2)); + const std::string aContent = aOutput.str(); + ASSERT_FALSE(aContent.empty()); + EXPECT_NE(aContent.find("#VRML"), std::string::npos); + EXPECT_EQ(CountTriangulationTriangles(aTorus), aTrianglesBefore); + + TopoDS_Shape aRestored; + ASSERT_TRUE(ReadVrmlShape(aContent, aRestored)); + EXPECT_FALSE(aRestored.IsNull()); + EXPECT_GT(CountTriangulationTriangles(aRestored), 0); +} + +// bugs/stlvrml/bug25740: VRML edge output terminates its indexed line list +// correctly and does not append an extra point index. +TEST(DEVRML_Bug_Test, StlVrmlBug_25740_EdgeIndexTermination) +{ + const double aPi = 3.14159265358979323846; + const TopoDS_Shape aTorus = + BRepPrimAPI_MakeTorus(10.0, 8.0, 0.0, 90.0 * aPi / 180.0, 120.0 * aPi / 180.0).Shape(); + BRepMesh_IncrementalMesh aMesher(aTorus, 0.1); + + TopoDS_Shape aThirdEdge; + int anEdgeIndex = 0; + for (TopExp_Explorer anExplorer(aTorus, TopAbs_EDGE); anExplorer.More(); anExplorer.Next()) + { + ++anEdgeIndex; + if (anEdgeIndex == 3) + { + aThirdEdge = anExplorer.Current(); + break; + } + } + ASSERT_FALSE(aThirdEdge.IsNull()); + + VrmlAPI_Writer aWriter; + aWriter.SetRepresentation(VrmlAPI_WireFrameRepresentation); + std::ostringstream aOutput; + ASSERT_TRUE(aWriter.Write(aThirdEdge, aOutput, 2)); + const std::string aContent = aOutput.str(); + ASSERT_FALSE(aContent.empty()); + EXPECT_NE(aContent.find("#VRML"), std::string::npos); + const std::regex anExpectedIndices( + R"(coordIndex\s*\[\s*0\s*,\s*1\s*,\s*2\s*,\s*3\s*,\s*4\s*,\s*5\s*,\s*6\s*,\s*7\s*,\s*8\s*,\s*9\s*,\s*10\s*,\s*11\s*,\s*12\s*,\s*13\s*,\s*14\s*,\s*15\s*,\s*-1\s*,?\s*\])"); + EXPECT_TRUE(std::regex_search(aContent, anExpectedIndices)); +} + +// bugs/xde/bug30409: exporting a triangulated XDE face to VRML does not throw +// and the stream can be read with the original triangle and node counts. +TEST_F(DEVRML_ProviderTest, XdeBug_30409_StreamFaceExport) +{ + occ::handle aShapeTool = XCAFDoc_DocumentTool::ShapeTool(myDocument->Main()); + ASSERT_FALSE(aShapeTool->AddShape(myTriangularFace).IsNull()); + + VrmlAPI_Writer aWriter; + aWriter.SetRepresentation(VrmlAPI_ShadedRepresentation); + std::ostringstream aOutput; + ASSERT_TRUE(aWriter.WriteDoc(myDocument, aOutput, 1.0)); + const std::string aContent = aOutput.str(); + ASSERT_FALSE(aContent.empty()); + EXPECT_NE(aContent.find("#VRML"), std::string::npos); + + TopoDS_Shape aRestored; + ASSERT_TRUE(ReadVrmlShape(aContent, aRestored)); + EXPECT_EQ(CountTriangulationTriangles(aRestored), 2); + EXPECT_EQ(CountTriangulationNodes(aRestored), 4); +} + +// bugs/fclasses/bug26922: writing a densely meshed sphere to a VRML stream remains within the +// performance budget used by the original DRAW test. +TEST(DEVRML_Bug_Test, FClassesBug_26922_StreamWritePerformance) +{ + const TopoDS_Shape aSphere = BRepPrimAPI_MakeSphere(50.0).Shape(); + BRepMesh_IncrementalMesh aMesher(aSphere, 0.01); + + VrmlAPI_Writer aWriter; + aWriter.SetRepresentation(VrmlAPI_WireFrameRepresentation); + std::ostringstream aOutput; + OSD_Timer aTimer; + aTimer.Start(); + ASSERT_TRUE(aWriter.Write(aSphere, aOutput, 2)); + aTimer.Stop(); + + EXPECT_FALSE(aOutput.str().empty()); + EXPECT_LT(aTimer.ElapsedTime(), 0.5); +} diff --git a/src/DataExchange/TKXCAF/GTests/FILES.cmake b/src/DataExchange/TKXCAF/GTests/FILES.cmake index 0597af7f42..bce21340d4 100644 --- a/src/DataExchange/TKXCAF/GTests/FILES.cmake +++ b/src/DataExchange/TKXCAF/GTests/FILES.cmake @@ -2,5 +2,7 @@ set(OCCT_TKXCAF_GTests_FILES_LOCATION "${CMAKE_CURRENT_LIST_DIR}") set(OCCT_TKXCAF_GTests_FILES + XCAFDoc_GDT_Test.cxx + XCAFDoc_NotesTool_Test.cxx XCAFDoc_Test.cxx ) diff --git a/src/DataExchange/TKXCAF/GTests/XCAFDoc_GDT_Test.cxx b/src/DataExchange/TKXCAF/GTests/XCAFDoc_GDT_Test.cxx new file mode 100644 index 0000000000..2d73993c2f --- /dev/null +++ b/src/DataExchange/TKXCAF/GTests/XCAFDoc_GDT_Test.cxx @@ -0,0 +1,359 @@ +// Copyright (c) 2026 OPEN CASCADE SAS +// +// This file is part of Open CASCADE Technology software library. +// +// This library is free software; you can redistribute it and/or modify it under +// the terms of the GNU Lesser General Public License version 2.1 as published +// by the Free Software Foundation, with special exception defined in the file +// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT +// distribution for complete text of the license and disclaimer of any warranty. +// +// Alternatively, this file may be used under the terms of Open CASCADE +// commercial license or contractual agreement. + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace +{ +struct GdtContext +{ + occ::handle Application; + occ::handle Document; + occ::handle ShapeTool; + occ::handle DimTolTool; + TDF_Label Shape1; + TDF_Label Shape2; +}; + +static GdtContext NewContext() +{ + GdtContext aContext; + aContext.Application = new TDocStd_Application(); + aContext.Application->NewDocument("BinXCAF", aContext.Document); + aContext.ShapeTool = XCAFDoc_DocumentTool::ShapeTool(aContext.Document->Main()); + aContext.DimTolTool = XCAFDoc_DocumentTool::DimTolTool(aContext.Document->Main()); + aContext.Shape1 = aContext.ShapeTool->AddShape(BRepPrimAPI_MakeBox(10.0, 10.0, 10.0).Shape()); + aContext.Shape2 = aContext.ShapeTool->AddShape(BRepPrimAPI_MakeBox(20.0, 20.0, 20.0).Shape()); + return aContext; +} + +static TDF_Label AddDimension(GdtContext& theContext, const bool theHasSecondShape) +{ + const TDF_Label aDimension = theContext.DimTolTool->AddDimension(); + if (theHasSecondShape) + { + theContext.DimTolTool->SetDimension(theContext.Shape1, theContext.Shape2, aDimension); + } + else + { + theContext.DimTolTool->SetDimension(theContext.Shape1, aDimension); + } + EXPECT_TRUE(theContext.DimTolTool->IsDimension(aDimension)); + return aDimension; +} + +static occ::handle DimensionObject(const TDF_Label& theLabel) +{ + occ::handle anAttribute; + EXPECT_TRUE(theLabel.FindAttribute(XCAFDoc_Dimension::GetID(), anAttribute)); + return anAttribute->GetObject(); +} + +static TDF_Label AddGeomTolerance(GdtContext& theContext) +{ + const TDF_Label aTolerance = theContext.DimTolTool->AddGeomTolerance(); + theContext.DimTolTool->SetGeomTolerance(theContext.Shape1, aTolerance); + EXPECT_TRUE(theContext.DimTolTool->IsGeomTolerance(aTolerance)); + return aTolerance; +} + +static occ::handle GeomToleranceObject( + const TDF_Label& theLabel) +{ + occ::handle anAttribute; + EXPECT_TRUE(theLabel.FindAttribute(XCAFDoc_GeomTolerance::GetID(), anAttribute)); + return anAttribute->GetObject(); +} + +static TDF_Label AddDatum(GdtContext& theContext, + const TDF_Label& theTolerance, + const char* theName, + const int thePosition, + const bool theAddDistanceModifier) +{ + const TDF_Label aDatum = theContext.DimTolTool->AddDatum(); + NCollection_Sequence aShapeLabels; + aShapeLabels.Append(theContext.Shape1); + theContext.DimTolTool->SetDatum(aShapeLabels, aDatum); + + occ::handle anAttribute; + EXPECT_TRUE(aDatum.FindAttribute(XCAFDoc_Datum::GetID(), anAttribute)); + occ::handle anObject = anAttribute->GetObject(); + anObject->SetName(new TCollection_HAsciiString(theName)); + anObject->SetPosition(thePosition); + if (theAddDistanceModifier) + { + anObject->AddModifier(XCAFDimTolObjects_DatumSingleModif_DistanceVariable); + } + anAttribute->SetObject(anObject); + theContext.DimTolTool->SetDatumToGeomTol(aDatum, theTolerance); + return aDatum; +} + +static occ::handle DatumObject(const TDF_Label& theLabel) +{ + occ::handle anAttribute; + EXPECT_TRUE(theLabel.FindAttribute(XCAFDoc_Datum::GetID(), anAttribute)); + return anAttribute->GetObject(); +} + +static NCollection_Sequence DatumReferences(const TDF_Label& theTolerance, + const GdtContext& theContext) +{ + NCollection_Sequence aDatums; + EXPECT_TRUE(theContext.DimTolTool->GetDatumOfTolerLabels(theTolerance, aDatums)); + return aDatums; +} +} // namespace + +// gdt/dimensions/A1: a curve-length dimension stores its type and value. +TEST(XCAFDoc_GDT_Test, GdtDimensions_A1_CurveLength) +{ + GdtContext aContext = NewContext(); + const TDF_Label aDimension = AddDimension(aContext, false); + occ::handle anObject = DimensionObject(aDimension); + anObject->SetType(XCAFDimTolObjects_DimensionType_Size_CurveLength); + anObject->SetValue(1.5); + XCAFDoc_Dimension::Set(aDimension)->SetObject(anObject); + + anObject = DimensionObject(aDimension); + EXPECT_EQ(anObject->GetType(), XCAFDimTolObjects_DimensionType_Size_CurveLength); + EXPECT_DOUBLE_EQ(anObject->GetValue(), 1.5); +} + +// gdt/dimensions/A2: a diameter dimension stores its maximum qualifier. +TEST(XCAFDoc_GDT_Test, GdtDimensions_A2_DiameterQualifier) +{ + GdtContext aContext = NewContext(); + const TDF_Label aDimension = AddDimension(aContext, false); + occ::handle anObject = DimensionObject(aDimension); + anObject->SetType(XCAFDimTolObjects_DimensionType_Size_Diameter); + anObject->SetValue(2.5); + anObject->SetQualifier(XCAFDimTolObjects_DimensionQualifier_Max); + XCAFDoc_Dimension::Set(aDimension)->SetObject(anObject); + + anObject = DimensionObject(aDimension); + EXPECT_EQ(anObject->GetType(), XCAFDimTolObjects_DimensionType_Size_Diameter); + EXPECT_DOUBLE_EQ(anObject->GetValue(), 2.5); + EXPECT_TRUE(anObject->HasQualifier()); + EXPECT_EQ(anObject->GetQualifier(), XCAFDimTolObjects_DimensionQualifier_Max); +} + +// gdt/dimensions/A3: a dimension may store a lower and upper range. +TEST(XCAFDoc_GDT_Test, GdtDimensions_A3_Range) +{ + GdtContext aContext = NewContext(); + const TDF_Label aDimension = AddDimension(aContext, false); + occ::handle anObject = DimensionObject(aDimension); + anObject->SetType(XCAFDimTolObjects_DimensionType_Size_CurveLength); + anObject->SetLowerBound(1.5); + anObject->SetUpperBound(2.5); + XCAFDoc_Dimension::Set(aDimension)->SetObject(anObject); + + anObject = DimensionObject(aDimension); + EXPECT_EQ(anObject->GetType(), XCAFDimTolObjects_DimensionType_Size_CurveLength); + EXPECT_TRUE(anObject->IsDimWithRange()); + EXPECT_DOUBLE_EQ(anObject->GetLowerBound(), 1.5); + EXPECT_DOUBLE_EQ(anObject->GetUpperBound(), 2.5); +} + +// gdt/dimensions/A4: class-of-tolerance, decimal places, and modifiers are persisted. +TEST(XCAFDoc_GDT_Test, GdtDimensions_A4_ClassAndModifiers) +{ + GdtContext aContext = NewContext(); + const TDF_Label aDimension = AddDimension(aContext, false); + occ::handle anObject = DimensionObject(aDimension); + anObject->SetType(XCAFDimTolObjects_DimensionType_Size_Diameter); + anObject->SetValue(2.5); + anObject->SetClassOfTolerance(true, + XCAFDimTolObjects_DimensionFormVariance_F, + XCAFDimTolObjects_DimensionGrade_IT6); + anObject->SetNbOfDecimalPlaces(3, 3); + anObject->AddModifier(XCAFDimTolObjects_DimensionModif_AverageSize); + anObject->AddModifier(XCAFDimTolObjects_DimensionModif_ControlledRadius); + XCAFDoc_Dimension::Set(aDimension)->SetObject(anObject); + + anObject = DimensionObject(aDimension); + bool aHole = false; + XCAFDimTolObjects_DimensionFormVariance aForm = XCAFDimTolObjects_DimensionFormVariance_None; + XCAFDimTolObjects_DimensionGrade aGrade = XCAFDimTolObjects_DimensionGrade_IT01; + EXPECT_TRUE(anObject->GetClassOfTolerance(aHole, aForm, aGrade)); + EXPECT_TRUE(aHole); + EXPECT_EQ(aForm, XCAFDimTolObjects_DimensionFormVariance_F); + EXPECT_EQ(aGrade, XCAFDimTolObjects_DimensionGrade_IT6); + + int aLeft = 0; + int aRight = 0; + anObject->GetNbOfDecimalPlaces(aLeft, aRight); + EXPECT_EQ(aLeft, 3); + EXPECT_EQ(aRight, 3); + + const NCollection_Sequence aModifiers = + anObject->GetModifiers(); + ASSERT_EQ(aModifiers.Length(), 2); + EXPECT_EQ(aModifiers.Value(1), XCAFDimTolObjects_DimensionModif_AverageSize); + EXPECT_EQ(aModifiers.Value(2), XCAFDimTolObjects_DimensionModif_ControlledRadius); +} + +// gdt/dimensions/A5: a linear-location dimension stores two points and plus/minus tolerances. +TEST(XCAFDoc_GDT_Test, GdtDimensions_A5_LinearDistance) +{ + GdtContext aContext = NewContext(); + const TDF_Label aDimension = AddDimension(aContext, true); + occ::handle anObject = DimensionObject(aDimension); + anObject->SetType(XCAFDimTolObjects_DimensionType_Location_LinearDistance); + anObject->SetValue(6.0); + ASSERT_TRUE(anObject->SetLowerTolValue(-0.001)); + ASSERT_TRUE(anObject->SetUpperTolValue(0.002)); + anObject->SetPoint(gp_Pnt(10.0, 10.0, 10.0)); + anObject->SetPoint2(gp_Pnt(20.0, 20.0, 20.0)); + XCAFDoc_Dimension::Set(aDimension)->SetObject(anObject); + + anObject = DimensionObject(aDimension); + EXPECT_EQ(anObject->GetType(), XCAFDimTolObjects_DimensionType_Location_LinearDistance); + EXPECT_DOUBLE_EQ(anObject->GetValue(), 6.0); + EXPECT_TRUE(anObject->IsDimWithPlusMinusTolerance()); + EXPECT_DOUBLE_EQ(anObject->GetLowerTolValue(), -0.001); + EXPECT_DOUBLE_EQ(anObject->GetUpperTolValue(), 0.002); + EXPECT_TRUE(anObject->HasPoint()); + EXPECT_TRUE(anObject->HasPoint2()); + EXPECT_TRUE(anObject->GetPoint().IsEqual(gp_Pnt(10.0, 10.0, 10.0), 0.0)); + EXPECT_TRUE(anObject->GetPoint2().IsEqual(gp_Pnt(20.0, 20.0, 20.0), 0.0)); +} + +// gdt/dimensions/A6: an oriented dimension stores direction and plus/minus tolerances. +TEST(XCAFDoc_GDT_Test, GdtDimensions_A6_Oriented) +{ + GdtContext aContext = NewContext(); + const TDF_Label aDimension = AddDimension(aContext, true); + occ::handle anObject = DimensionObject(aDimension); + anObject->SetType(XCAFDimTolObjects_DimensionType_Location_Oriented); + anObject->SetValue(6.0); + ASSERT_TRUE(anObject->SetLowerTolValue(-0.001)); + ASSERT_TRUE(anObject->SetUpperTolValue(0.002)); + ASSERT_TRUE(anObject->SetDirection(gp_Dir(1.0, 1.0, 0.0))); + XCAFDoc_Dimension::Set(aDimension)->SetObject(anObject); + + anObject = DimensionObject(aDimension); + gp_Dir aDirection; + EXPECT_EQ(anObject->GetType(), XCAFDimTolObjects_DimensionType_Location_Oriented); + EXPECT_DOUBLE_EQ(anObject->GetValue(), 6.0); + EXPECT_TRUE(anObject->IsDimWithPlusMinusTolerance()); + EXPECT_DOUBLE_EQ(anObject->GetLowerTolValue(), -0.001); + EXPECT_DOUBLE_EQ(anObject->GetUpperTolValue(), 0.002); + ASSERT_TRUE(anObject->GetDirection(aDirection)); + EXPECT_NEAR(aDirection.X(), 0.7071067811865476, 1.0e-15); + EXPECT_NEAR(aDirection.Y(), 0.7071067811865476, 1.0e-15); + EXPECT_DOUBLE_EQ(aDirection.Z(), 0.0); +} + +// gdt/tolerances/A1: a tolerance stores datum, type, material, zone, and modifiers. +TEST(XCAFDoc_GDT_Test, GdtTolerances_A1_FullDefinition) +{ + GdtContext aContext = NewContext(); + const TDF_Label aTolerance = AddGeomTolerance(aContext); + const TDF_Label aDatum = AddDatum(aContext, aTolerance, "A", 1, true); + + occ::handle anObject = GeomToleranceObject(aTolerance); + anObject->SetValue(0.5); + anObject->SetType(XCAFDimTolObjects_GeomToleranceType_Angularity); + anObject->SetTypeOfValue(XCAFDimTolObjects_GeomToleranceTypeValue_Diameter); + anObject->SetMaterialRequirementModifier(XCAFDimTolObjects_GeomToleranceMatReqModif_M); + anObject->SetZoneModifier(XCAFDimTolObjects_GeomToleranceZoneModif_Projected); + anObject->SetValueOfZoneModifier(1.0); + anObject->AddModifier(XCAFDimTolObjects_GeomToleranceModif_Major_Diameter); + anObject->AddModifier(XCAFDimTolObjects_GeomToleranceModif_Common_Zone); + anObject->SetMaxValueModifier(1.5); + XCAFDoc_GeomTolerance::Set(aTolerance)->SetObject(anObject); + + anObject = GeomToleranceObject(aTolerance); + EXPECT_DOUBLE_EQ(anObject->GetValue(), 0.5); + EXPECT_EQ(anObject->GetType(), XCAFDimTolObjects_GeomToleranceType_Angularity); + EXPECT_EQ(anObject->GetTypeOfValue(), XCAFDimTolObjects_GeomToleranceTypeValue_Diameter); + EXPECT_EQ(anObject->GetMaterialRequirementModifier(), + XCAFDimTolObjects_GeomToleranceMatReqModif_M); + EXPECT_EQ(anObject->GetZoneModifier(), XCAFDimTolObjects_GeomToleranceZoneModif_Projected); + EXPECT_DOUBLE_EQ(anObject->GetValueOfZoneModifier(), 1.0); + EXPECT_DOUBLE_EQ(anObject->GetMaxValueModifier(), 1.5); + const NCollection_Sequence aModifiers = + anObject->GetModifiers(); + ASSERT_EQ(aModifiers.Length(), 2); + EXPECT_EQ(aModifiers.Value(1), XCAFDimTolObjects_GeomToleranceModif_Major_Diameter); + EXPECT_EQ(aModifiers.Value(2), XCAFDimTolObjects_GeomToleranceModif_Common_Zone); + + const NCollection_Sequence aDatums = DatumReferences(aTolerance, aContext); + ASSERT_EQ(aDatums.Length(), 1); + EXPECT_EQ(aDatums.Value(1), aDatum); + const occ::handle aDatumObject = DatumObject(aDatum); + ASSERT_FALSE(aDatumObject.IsNull()); + EXPECT_STREQ(aDatumObject->GetName()->ToCString(), "A"); + EXPECT_EQ(aDatumObject->GetPosition(), 1); + const NCollection_Sequence aDatumModifiers = + aDatumObject->GetModifiers(); + ASSERT_EQ(aDatumModifiers.Length(), 1); + EXPECT_EQ(aDatumModifiers.Value(1), XCAFDimTolObjects_DatumSingleModif_DistanceVariable); +} + +// gdt/tolerances/A2: two datums can reference one geometric tolerance. +TEST(XCAFDoc_GDT_Test, GdtTolerances_A2_TwoDatums) +{ + GdtContext aContext = NewContext(); + const TDF_Label aTolerance = AddGeomTolerance(aContext); + const TDF_Label aDatumA = AddDatum(aContext, aTolerance, "A", 1, true); + const TDF_Label aDatumB = AddDatum(aContext, aTolerance, "B", 2, false); + + occ::handle anObject = GeomToleranceObject(aTolerance); + anObject->SetValue(0.5); + XCAFDoc_GeomTolerance::Set(aTolerance)->SetObject(anObject); + + anObject = GeomToleranceObject(aTolerance); + EXPECT_DOUBLE_EQ(anObject->GetValue(), 0.5); + const NCollection_Sequence aDatums = DatumReferences(aTolerance, aContext); + ASSERT_EQ(aDatums.Length(), 2); + EXPECT_EQ(aDatums.Value(1), aDatumA); + EXPECT_EQ(aDatums.Value(2), aDatumB); + + const occ::handle aDatumObjectA = DatumObject(aDatumA); + const occ::handle aDatumObjectB = DatumObject(aDatumB); + EXPECT_STREQ(aDatumObjectA->GetName()->ToCString(), "A"); + EXPECT_EQ(aDatumObjectA->GetPosition(), 1); + EXPECT_STREQ(aDatumObjectB->GetName()->ToCString(), "B"); + EXPECT_EQ(aDatumObjectB->GetPosition(), 2); + EXPECT_EQ(aDatumObjectA->GetModifiers().Length(), 1); + EXPECT_EQ(aDatumObjectB->GetModifiers().Length(), 0); +} diff --git a/src/DataExchange/TKXCAF/GTests/XCAFDoc_NotesTool_Test.cxx b/src/DataExchange/TKXCAF/GTests/XCAFDoc_NotesTool_Test.cxx new file mode 100644 index 0000000000..cb50843dd4 --- /dev/null +++ b/src/DataExchange/TKXCAF/GTests/XCAFDoc_NotesTool_Test.cxx @@ -0,0 +1,404 @@ +// Copyright (c) 2026 OPEN CASCADE SAS +// +// This file is part of Open CASCADE Technology software library. +// +// This library is free software; you can redistribute it and/or modify it under +// the terms of the GNU Lesser General Public License version 2.1 as published +// by the Free Software Foundation, with special exception defined in the file +// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT +// distribution for complete text of the license and disclaimer of any warranty. +// +// Alternatively, this file may be used under the terms of Open CASCADE +// commercial license or contractual agreement. + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +namespace +{ +struct NotesContext +{ + occ::handle Application; + occ::handle Document; + occ::handle Tool; + TDF_Label Item1; + TDF_Label Item2; + Standard_GUID AttributeGuid; +}; + +static NotesContext NewContext() +{ + NotesContext aContext; + aContext.Application = new TDocStd_Application(); + aContext.Application->NewDocument("BinXCAF", aContext.Document); + occ::handle aShapeTool = + XCAFDoc_DocumentTool::ShapeTool(aContext.Document->Main()); + aContext.Item1 = aShapeTool->AddShape(BRepPrimAPI_MakeBox(1.0, 1.0, 1.0).Shape()); + aContext.Item2 = aShapeTool->AddShape(BRepPrimAPI_MakeBox(2.0, 2.0, 2.0).Shape()); + aContext.Tool = XCAFDoc_DocumentTool::NotesTool(aContext.Document->Main()); + aContext.AttributeGuid = Standard_GUID("27927843-72A0-41ef-901D-621FAB01C27A"); + TDataStd_Integer::Set(aContext.Item1, aContext.AttributeGuid, 1965); + return aContext; +} + +static occ::handle Comment(const NotesContext& theContext, const char* theText) +{ + return theContext.Tool->CreateComment(TCollection_ExtendedString("The user"), + TCollection_ExtendedString("2026-08-07T00:00:00"), + TCollection_ExtendedString(theText)); +} + +static occ::handle Balloon(const NotesContext& theContext, const char* theText) +{ + return theContext.Tool->CreateBalloon(TCollection_ExtendedString("The user"), + TCollection_ExtendedString("2026-08-07T00:00:00"), + TCollection_ExtendedString(theText)); +} + +static occ::handle BinaryNote(const NotesContext& theContext) +{ + occ::handle> aData = new NCollection_HArray1(1, 26); + for (int anIndex = 1; anIndex <= 26; ++anIndex) + { + aData->SetValue(anIndex, static_cast('a' + anIndex - 1)); + } + return theContext.Tool->CreateBinData(TCollection_ExtendedString("The user"), + TCollection_ExtendedString("2026-08-07T00:00:00"), + TCollection_ExtendedString("Binary data"), + TCollection_AsciiString("application/octet-stream"), + aData); +} + +static TDF_Label NoteLabel(const occ::handle& theNote) +{ + return theNote.IsNull() ? TDF_Label() : theNote->Label(); +} + +static XCAFDoc_AssemblyItemId ItemId(const TDF_Label& theItem) +{ + TCollection_AsciiString anEntry; + TDF_Tool::Entry(theItem, anEntry); + return XCAFDoc_AssemblyItemId(anEntry); +} + +static void AddBase(const NotesContext& theContext, + const occ::handle& theNote, + const TDF_Label& theItem) +{ + ASSERT_FALSE(theNote.IsNull()); + ASSERT_FALSE(theContext.Tool->AddNote(NoteLabel(theNote), theItem).IsNull()); +} + +static void AddAttribute(const NotesContext& theContext, + const occ::handle& theNote, + const TDF_Label& theItem) +{ + ASSERT_FALSE(theNote.IsNull()); + ASSERT_FALSE( + theContext.Tool->AddNoteToAttr(NoteLabel(theNote), theItem, theContext.AttributeGuid).IsNull()); +} + +static void AddSubshape(const NotesContext& theContext, + const occ::handle& theNote, + const TDF_Label& theItem) +{ + ASSERT_FALSE(theNote.IsNull()); + ASSERT_FALSE(theContext.Tool->AddNoteToSubshape(NoteLabel(theNote), theItem, 1).IsNull()); +} + +static void ExpectCounts(const NotesContext& theContext, + const int theAnnotations, + const int theNotes, + const int theOrphans) +{ + EXPECT_EQ(theContext.Tool->NbAnnotatedItems(), theAnnotations); + EXPECT_EQ(theContext.Tool->NbNotes(), theNotes); + EXPECT_EQ(theContext.Tool->NbOrphanNotes(), theOrphans); +} +} // namespace + +// gdt/notes/A1: an empty notes tool has no annotations or notes. +TEST(XCAFDoc_NotesTool_Test, GdtNotes_A1_Empty) +{ + const NotesContext aContext = NewContext(); + ExpectCounts(aContext, 0, 0, 0); +} + +// gdt/notes/A2: comment and balloon notes are initially orphan notes. +TEST(XCAFDoc_NotesTool_Test, GdtNotes_A2_CreateOrphans) +{ + const NotesContext aContext = NewContext(); + ASSERT_FALSE(Comment(aContext, "Hello, World!").IsNull()); + ASSERT_FALSE(Balloon(aContext, "Hello, Everyone!").IsNull()); + ExpectCounts(aContext, 0, 2, 2); +} + +// gdt/notes/A3: binary notes are stored in the notes hive as orphan notes. +TEST(XCAFDoc_NotesTool_Test, GdtNotes_A3_CreateBinary) +{ + const NotesContext aContext = NewContext(); + ASSERT_FALSE(BinaryNote(aContext).IsNull()); + ExpectCounts(aContext, 0, 1, 1); +} + +// gdt/notes/A4: deleting one note leaves the other orphan note intact. +TEST(XCAFDoc_NotesTool_Test, GdtNotes_A4_DeleteOne) +{ + const NotesContext aContext = NewContext(); + const occ::handle aComment = Comment(aContext, "Hello, World!"); + ASSERT_FALSE(aComment.IsNull()); + ASSERT_FALSE(Balloon(aContext, "Hello, Everyone!").IsNull()); + EXPECT_TRUE(aContext.Tool->DeleteNote(aComment->Label())); + ExpectCounts(aContext, 0, 1, 1); +} + +// gdt/notes/A5: deleting all notes clears the notes hive. +TEST(XCAFDoc_NotesTool_Test, GdtNotes_A5_DeleteAll) +{ + const NotesContext aContext = NewContext(); + ASSERT_FALSE(Comment(aContext, "Hello, World!").IsNull()); + ASSERT_FALSE(Balloon(aContext, "Hello, Everyone!").IsNull()); + EXPECT_EQ(aContext.Tool->DeleteAllNotes(), 2); + ExpectCounts(aContext, 0, 0, 0); +} + +// gdt/notes/B1: one note may annotate two items. +TEST(XCAFDoc_NotesTool_Test, GdtNotes_B1_TwoItemsOneNote) +{ + const NotesContext aContext = NewContext(); + const occ::handle aNote = Comment(aContext, "Hello, World!"); + AddBase(aContext, aNote, aContext.Item1); + AddBase(aContext, aNote, aContext.Item2); + ExpectCounts(aContext, 2, 1, 0); +} + +// gdt/notes/B2: two notes may annotate two different items. +TEST(XCAFDoc_NotesTool_Test, GdtNotes_B2_TwoItemsTwoNotes) +{ + const NotesContext aContext = NewContext(); + const occ::handle aNote1 = Comment(aContext, "Hello, World!"); + const occ::handle aNote2 = Comment(aContext, "Hello, Everyone!"); + AddBase(aContext, aNote1, aContext.Item1); + AddBase(aContext, aNote2, aContext.Item2); + ExpectCounts(aContext, 2, 2, 0); +} + +// gdt/notes/B3: deleting orphan notes removes only the unreferenced note. +TEST(XCAFDoc_NotesTool_Test, GdtNotes_B3_DeleteOrphan) +{ + const NotesContext aContext = NewContext(); + const occ::handle aNote1 = Comment(aContext, "Hello, World!"); + const occ::handle aNote2 = Comment(aContext, "Hello, Everyone!"); + AddBase(aContext, aNote1, aContext.Item1); + AddBase(aContext, aNote1, aContext.Item2); + EXPECT_EQ(aContext.Tool->DeleteOrphanNotes(), 1); + ExpectCounts(aContext, 2, 1, 0); +} + +// gdt/notes/B4: two notes on one item share one annotated-item label. +TEST(XCAFDoc_NotesTool_Test, GdtNotes_B4_TwoNotesOneItem) +{ + const NotesContext aContext = NewContext(); + const occ::handle aNote1 = Comment(aContext, "Hello, World!"); + const occ::handle aNote2 = Comment(aContext, "Hello, Everyone!"); + AddBase(aContext, aNote1, aContext.Item1); + AddBase(aContext, aNote2, aContext.Item1); + ExpectCounts(aContext, 1, 2, 0); +} + +// gdt/notes/B5-B7: base, attribute, and subshape annotations are distinct references. +TEST(XCAFDoc_NotesTool_Test, GdtNotes_B5_AttributeAnnotation) +{ + const NotesContext aContext = NewContext(); + const occ::handle aNote = Comment(aContext, "Hello, World!"); + AddAttribute(aContext, aNote, aContext.Item1); + ExpectCounts(aContext, 1, 1, 0); + EXPECT_FALSE( + aContext.Tool->FindAnnotatedItemAttr(aContext.Item1, aContext.AttributeGuid).IsNull()); +} + +TEST(XCAFDoc_NotesTool_Test, GdtNotes_B6_BaseAndAttribute) +{ + const NotesContext aContext = NewContext(); + const occ::handle aNote = Comment(aContext, "Hello, World!"); + AddBase(aContext, aNote, aContext.Item1); + AddAttribute(aContext, aNote, aContext.Item1); + ExpectCounts(aContext, 2, 1, 0); +} + +TEST(XCAFDoc_NotesTool_Test, GdtNotes_B7_BaseAttributeAndSubshape) +{ + const NotesContext aContext = NewContext(); + const occ::handle aNote = Comment(aContext, "Hello, World!"); + AddBase(aContext, aNote, aContext.Item1); + AddAttribute(aContext, aNote, aContext.Item1); + AddSubshape(aContext, aNote, aContext.Item1); + ExpectCounts(aContext, 3, 1, 0); +} + +// gdt/notes/C1-C2: deleting notes removes their annotations as well. +TEST(XCAFDoc_NotesTool_Test, GdtNotes_C1_DeleteLinkedNote) +{ + const NotesContext aContext = NewContext(); + const occ::handle aNote = Comment(aContext, "Hello, World!"); + AddBase(aContext, aNote, aContext.Item1); + AddBase(aContext, aNote, aContext.Item2); + EXPECT_TRUE(aContext.Tool->DeleteNote(aNote->Label())); + ExpectCounts(aContext, 0, 0, 0); +} + +TEST(XCAFDoc_NotesTool_Test, GdtNotes_C2_DeleteOneLinkedNote) +{ + const NotesContext aContext = NewContext(); + const occ::handle aNote1 = Comment(aContext, "Hello, World!"); + const occ::handle aNote2 = Comment(aContext, "Hello, World!"); + AddBase(aContext, aNote1, aContext.Item1); + AddBase(aContext, aNote2, aContext.Item2); + EXPECT_TRUE(aContext.Tool->DeleteNote(aNote1->Label())); + ExpectCounts(aContext, 1, 1, 0); +} + +// gdt/notes/C3-C4: removing selected links preserves unrelated links. +TEST(XCAFDoc_NotesTool_Test, GdtNotes_C3_RemoveBaseAnnotation) +{ + const NotesContext aContext = NewContext(); + const occ::handle aNote1 = Comment(aContext, "Hello, World!"); + const occ::handle aNote2 = Comment(aContext, "Hello, World!"); + AddBase(aContext, aNote1, aContext.Item1); + AddBase(aContext, aNote2, aContext.Item2); + EXPECT_TRUE(aContext.Tool->RemoveNote(aNote1->Label(), aContext.Item1)); + ExpectCounts(aContext, 1, 2, 1); +} + +TEST(XCAFDoc_NotesTool_Test, GdtNotes_C4_RemoveExtraAnnotations) +{ + const NotesContext aContext = NewContext(); + const occ::handle aNote = Comment(aContext, "Hello, World!"); + AddBase(aContext, aNote, aContext.Item1); + AddAttribute(aContext, aNote, aContext.Item1); + AddSubshape(aContext, aNote, aContext.Item1); + EXPECT_TRUE( + aContext.Tool->RemoveAttrNote(aNote->Label(), aContext.Item1, aContext.AttributeGuid)); + EXPECT_TRUE(aContext.Tool->RemoveSubshapeNote(aNote->Label(), aContext.Item1, 1)); + ExpectCounts(aContext, 1, 1, 0); +} + +// gdt/notes/C5-C6: remove all notes of one extra-reference kind. +TEST(XCAFDoc_NotesTool_Test, GdtNotes_C5_RemoveAllAttributeAnnotations) +{ + const NotesContext aContext = NewContext(); + const occ::handle aNote1 = Comment(aContext, "Hello, World!"); + const occ::handle aNote2 = Comment(aContext, "Hello, Everyone!"); + AddBase(aContext, aNote1, aContext.Item1); + AddAttribute(aContext, aNote1, aContext.Item1); + AddAttribute(aContext, aNote2, aContext.Item1); + AddSubshape(aContext, aNote1, aContext.Item1); + EXPECT_TRUE(aContext.Tool->RemoveAllAttrNotes(aContext.Item1, aContext.AttributeGuid)); + ExpectCounts(aContext, 2, 2, 1); +} + +TEST(XCAFDoc_NotesTool_Test, GdtNotes_C6_RemoveAllSubshapeAnnotations) +{ + const NotesContext aContext = NewContext(); + const occ::handle aNote1 = Comment(aContext, "Hello, World!"); + const occ::handle aNote2 = Comment(aContext, "Hello, Everyone!"); + AddBase(aContext, aNote1, aContext.Item1); + AddAttribute(aContext, aNote1, aContext.Item1); + AddSubshape(aContext, aNote1, aContext.Item1); + AddSubshape(aContext, aNote2, aContext.Item1); + EXPECT_TRUE(aContext.Tool->RemoveAllSubshapeNotes(ItemId(aContext.Item1), 1)); + ExpectCounts(aContext, 2, 2, 1); +} + +// gdt/notes/C7-C9: remove all annotations, optionally deleting orphans. +TEST(XCAFDoc_NotesTool_Test, GdtNotes_C7_RemoveBaseAnnotations) +{ + const NotesContext aContext = NewContext(); + const occ::handle aNote1 = Comment(aContext, "Hello, World!"); + const occ::handle aNote2 = Comment(aContext, "Hello, Everyone!"); + AddBase(aContext, aNote1, aContext.Item1); + AddBase(aContext, aNote2, aContext.Item1); + AddAttribute(aContext, aNote1, aContext.Item1); + AddAttribute(aContext, aNote2, aContext.Item1); + AddSubshape(aContext, aNote1, aContext.Item1); + AddSubshape(aContext, aNote2, aContext.Item1); + EXPECT_TRUE(aContext.Tool->RemoveAllNotes(aContext.Item1)); + ExpectCounts(aContext, 2, 2, 0); +} + +TEST(XCAFDoc_NotesTool_Test, GdtNotes_C8_RemoveAllAnnotations) +{ + const NotesContext aContext = NewContext(); + const occ::handle aNote1 = Comment(aContext, "Hello, World!"); + const occ::handle aNote2 = Comment(aContext, "Hello, Everyone!"); + AddBase(aContext, aNote1, aContext.Item1); + AddBase(aContext, aNote2, aContext.Item1); + AddAttribute(aContext, aNote1, aContext.Item1); + AddAttribute(aContext, aNote2, aContext.Item1); + AddSubshape(aContext, aNote1, aContext.Item1); + AddSubshape(aContext, aNote2, aContext.Item1); + EXPECT_TRUE(aContext.Tool->RemoveAllNotes(aContext.Item1)); + EXPECT_TRUE(aContext.Tool->RemoveAllAttrNotes(aContext.Item1, aContext.AttributeGuid)); + EXPECT_TRUE(aContext.Tool->RemoveAllSubshapeNotes(ItemId(aContext.Item1), 1)); + ExpectCounts(aContext, 0, 2, 2); +} + +TEST(XCAFDoc_NotesTool_Test, GdtNotes_C9_RemoveAllAndDeleteOrphans) +{ + const NotesContext aContext = NewContext(); + const occ::handle aNote1 = Comment(aContext, "Hello, World!"); + const occ::handle aNote2 = Comment(aContext, "Hello, Everyone!"); + AddBase(aContext, aNote1, aContext.Item1); + AddBase(aContext, aNote2, aContext.Item1); + AddAttribute(aContext, aNote1, aContext.Item1); + AddAttribute(aContext, aNote2, aContext.Item1); + AddSubshape(aContext, aNote1, aContext.Item1); + AddSubshape(aContext, aNote2, aContext.Item1); + EXPECT_TRUE(aContext.Tool->RemoveAllNotes(aContext.Item1, true)); + EXPECT_TRUE(aContext.Tool->RemoveAllAttrNotes(aContext.Item1, aContext.AttributeGuid, true)); + EXPECT_TRUE(aContext.Tool->RemoveAllSubshapeNotes(ItemId(aContext.Item1), 1, true)); + ExpectCounts(aContext, 0, 0, 0); +} + +// gdt/notes/D1: repeated annotations of the same kind reuse the same item label. +TEST(XCAFDoc_NotesTool_Test, GdtNotes_D1_ReuseAnnotatedItemLabels) +{ + const NotesContext aContext = NewContext(); + const occ::handle aNote1 = Comment(aContext, "Hello, World!"); + const occ::handle aNote2 = Comment(aContext, "Hello, Everyone!"); + AddBase(aContext, aNote1, aContext.Item1); + const TDF_Label aBaseLabel = aContext.Tool->FindAnnotatedItem(aContext.Item1); + AddBase(aContext, aNote2, aContext.Item1); + EXPECT_TRUE(aBaseLabel.IsEqual(aContext.Tool->FindAnnotatedItem(aContext.Item1))); + + AddAttribute(aContext, aNote1, aContext.Item1); + const TDF_Label anAttributeLabel = + aContext.Tool->FindAnnotatedItemAttr(aContext.Item1, aContext.AttributeGuid); + AddAttribute(aContext, aNote2, aContext.Item1); + EXPECT_TRUE(anAttributeLabel.IsEqual( + aContext.Tool->FindAnnotatedItemAttr(aContext.Item1, aContext.AttributeGuid))); + + AddSubshape(aContext, aNote1, aContext.Item1); + const TDF_Label aSubshapeLabel = aContext.Tool->FindAnnotatedItemSubshape(aContext.Item1, 1); + AddSubshape(aContext, aNote2, aContext.Item1); + EXPECT_TRUE(aSubshapeLabel.IsEqual(aContext.Tool->FindAnnotatedItemSubshape(aContext.Item1, 1))); + ExpectCounts(aContext, 3, 2, 0); +} diff --git a/src/DataExchange/TKXmlXCAF/GTests/FILES.cmake b/src/DataExchange/TKXmlXCAF/GTests/FILES.cmake index 718cec28a3..4feb63d00e 100644 --- a/src/DataExchange/TKXmlXCAF/GTests/FILES.cmake +++ b/src/DataExchange/TKXmlXCAF/GTests/FILES.cmake @@ -2,4 +2,5 @@ set(OCCT_TKXmlXCAF_GTests_FILES_LOCATION "${CMAKE_CURRENT_LIST_DIR}") set(OCCT_TKXmlXCAF_GTests_FILES + XmlXCAF_Storage_Test.cxx ) diff --git a/src/DataExchange/TKXmlXCAF/GTests/XmlXCAF_Storage_Test.cxx b/src/DataExchange/TKXmlXCAF/GTests/XmlXCAF_Storage_Test.cxx new file mode 100644 index 0000000000..5abd2c34fe --- /dev/null +++ b/src/DataExchange/TKXmlXCAF/GTests/XmlXCAF_Storage_Test.cxx @@ -0,0 +1,604 @@ +// Copyright (c) 2026 OPEN CASCADE SAS +// +// This file is part of Open CASCADE Technology software library. +// +// This library is free software; you can redistribute it and/or modify it under +// the terms of the GNU Lesser General Public License version 2.1 as published +// by the Free Software Foundation, with special exception defined in the file +// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT +// distribution for complete text of the license and disclaimer of any warranty. +// +// Alternatively, this file may be used under the terms of Open CASCADE +// commercial license or contractual agreement. + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +namespace +{ +enum class StorageFormat +{ + Xml, + Xbf +}; + +static occ::handle NewApplication(const StorageFormat theFormat) +{ + occ::handle anApplication = new TDocStd_Application(); + if (theFormat == StorageFormat::Xml) + { + XmlXCAFDrivers::DefineFormat(anApplication); + } + else + { + BinXCAFDrivers::DefineFormat(anApplication); + } + return anApplication; +} + +static const char* FormatName(const StorageFormat theFormat) +{ + return theFormat == StorageFormat::Xml ? "XmlXCAF" : "BinXCAF"; +} + +static const char* FileExtension(const StorageFormat theFormat) +{ + return theFormat == StorageFormat::Xml ? "xml" : "xbf"; +} + +static TCollection_ExtendedString MakeTemporaryFile(OSD_Directory& theDirectory, + const char* theName, + const StorageFormat theFormat, + OSD_Path& thePath) +{ + theDirectory.Path(thePath); + thePath.SetName(theName); + thePath.SetExtension(TCollection_AsciiString(".") + FileExtension(theFormat)); + + TCollection_AsciiString aSystemName; + thePath.SystemName(aSystemName); + return TCollection_ExtendedString(aSystemName, true); +} + +static TDF_Label Label_0_1_1_1(const occ::handle& theDocument) +{ + TDF_Label aLabel = theDocument->Main(); + aLabel = aLabel.FindChild(1, true); + aLabel = aLabel.FindChild(1, true); + return aLabel.FindChild(1, true); +} + +static occ::handle SaveAndOpen( + const occ::handle& theApplication, + const occ::handle& theDocument, + const TCollection_ExtendedString& theFileName, + const OSD_Path& theFilePath) +{ + EXPECT_EQ(theApplication->SaveAs(theDocument, theFileName), PCDM_SS_OK); + + OSD_File aFile(theFilePath); + EXPECT_TRUE(aFile.Exists()); + + theApplication->Close(theDocument); + + occ::handle aRestoredDocument; + EXPECT_EQ(theApplication->Open(theFileName, aRestoredDocument), PCDM_RS_OK); + EXPECT_FALSE(aRestoredDocument.IsNull()); + + if (aFile.Exists()) + { + aFile.Remove(); + } + return aRestoredDocument; +} + +static occ::handle SaveAndOpenStream( + const occ::handle& theApplication, + const occ::handle& theDocument) +{ + std::stringstream aStream; + theDocument->NewCommand(); + EXPECT_EQ(theApplication->SaveAs(theDocument, aStream), PCDM_SS_OK); + EXPECT_FALSE(aStream.str().empty()); + + theApplication->Close(theDocument); + aStream.seekg(0); + occ::handle aRestoredDocument; + EXPECT_EQ(theApplication->Open(aStream, aRestoredDocument), PCDM_RS_OK); + EXPECT_FALSE(aRestoredDocument.IsNull()); + return aRestoredDocument; +} + +static occ::handle NewDocument( + const StorageFormat theFormat, + const occ::handle& theApplication) +{ + occ::handle aDocument; + theApplication->NewDocument(FormatName(theFormat), aDocument); + EXPECT_FALSE(aDocument.IsNull()); + return aDocument; +} + +static void TestArea(const StorageFormat theFormat) +{ + OSD_Directory aDirectory = OSD_Directory::BuildTemporary(); + OSD_Path aFilePath; + const TCollection_ExtendedString aFileName = + MakeTemporaryFile(aDirectory, "draw_xcaf_area", theFormat, aFilePath); + occ::handle anApplication = NewApplication(theFormat); + occ::handle aDocument = NewDocument(theFormat, anApplication); + const TDF_Label aLabel = Label_0_1_1_1(aDocument); + const double aExpected = 13.777; + + ASSERT_FALSE(aDocument.IsNull()); + ASSERT_FALSE(XCAFDoc_Area::Set(aLabel, aExpected).IsNull()); + aDocument->NewCommand(); + + occ::handle aRestored = + SaveAndOpen(anApplication, aDocument, aFileName, aFilePath); + ASSERT_FALSE(aRestored.IsNull()); + + double aValue = 0.0; + ASSERT_TRUE(XCAFDoc_Area::Get(Label_0_1_1_1(aRestored), aValue)); + EXPECT_DOUBLE_EQ(aValue, aExpected); +} + +static void TestColor(const StorageFormat theFormat) +{ + OSD_Directory aDirectory = OSD_Directory::BuildTemporary(); + OSD_Path aFilePath; + const TCollection_ExtendedString aFileName = + MakeTemporaryFile(aDirectory, "draw_xcaf_color", theFormat, aFilePath); + occ::handle anApplication = NewApplication(theFormat); + occ::handle aDocument = NewDocument(theFormat, anApplication); + const Quantity_ColorRGBA anExpected(0.3f, 0.3f, 0.3f, 1.0f); + occ::handle aColorTool = XCAFDoc_DocumentTool::ColorTool(aDocument->Main()); + const TDF_Label aLabel = aColorTool->AddColor(anExpected); + + ASSERT_FALSE(aDocument.IsNull()); + ASSERT_FALSE(aLabel.IsNull()); + Quantity_ColorRGBA aBefore; + ASSERT_TRUE(XCAFDoc_ColorTool::GetColor(aLabel, aBefore)); + aDocument->NewCommand(); + + TCollection_AsciiString aColorEntry; + TDF_Tool::Entry(aLabel, aColorEntry); + + occ::handle aRestored = + SaveAndOpen(anApplication, aDocument, aFileName, aFilePath); + ASSERT_FALSE(aRestored.IsNull()); + + TDF_Label aRestoredLabel; + Quantity_ColorRGBA aValue; + TDF_Tool::Label(aRestored->GetData(), aColorEntry, aRestoredLabel); + ASSERT_TRUE(XCAFDoc_ColorTool::GetColor(aRestoredLabel, aValue)); + // XML stores the color through its canonical named-color representation; + // compare the same semantic value used by DRAW's XGetColor command. + EXPECT_EQ(aValue.GetRGB().Name(), aBefore.GetRGB().Name()); + EXPECT_FLOAT_EQ(aValue.Alpha(), aBefore.Alpha()); +} + +static void TestCentroid(const StorageFormat theFormat) +{ + OSD_Directory aDirectory = OSD_Directory::BuildTemporary(); + OSD_Path aFilePath; + const TCollection_ExtendedString aFileName = + MakeTemporaryFile(aDirectory, "draw_xcaf_centroid", theFormat, aFilePath); + occ::handle anApplication = NewApplication(theFormat); + occ::handle aDocument = NewDocument(theFormat, anApplication); + const TDF_Label aLabel = Label_0_1_1_1(aDocument); + const gp_Pnt anExpected(12.34, 56.78, 90.12); + + ASSERT_FALSE(aDocument.IsNull()); + ASSERT_FALSE(XCAFDoc_Centroid::Set(aLabel, anExpected).IsNull()); + aDocument->NewCommand(); + + occ::handle aRestored = + SaveAndOpen(anApplication, aDocument, aFileName, aFilePath); + ASSERT_FALSE(aRestored.IsNull()); + + gp_Pnt aValue; + ASSERT_TRUE(XCAFDoc_Centroid::Get(Label_0_1_1_1(aRestored), aValue)); + EXPECT_TRUE(aValue.IsEqual(anExpected, Precision::Confusion())); +} + +static void TestName(const StorageFormat theFormat) +{ + OSD_Directory aDirectory = OSD_Directory::BuildTemporary(); + OSD_Path aFilePath; + const TCollection_ExtendedString aFileName = + MakeTemporaryFile(aDirectory, "draw_xcaf_name", theFormat, aFilePath); + occ::handle anApplication = NewApplication(theFormat); + occ::handle aDocument = NewDocument(theFormat, anApplication); + const TDF_Label aLabel = Label_0_1_1_1(aDocument); + const TCollection_ExtendedString anExpected("00"); + + ASSERT_FALSE(aDocument.IsNull()); + ASSERT_FALSE(TDataStd_Name::Set(aLabel, anExpected).IsNull()); + aDocument->NewCommand(); + + occ::handle aRestored = + SaveAndOpen(anApplication, aDocument, aFileName, aFilePath); + ASSERT_FALSE(aRestored.IsNull()); + + occ::handle aName; + ASSERT_TRUE(Label_0_1_1_1(aRestored).FindAttribute(TDataStd_Name::GetID(), aName)); + EXPECT_EQ(aName->Get(), anExpected); +} + +static void TestLayers(const StorageFormat theFormat) +{ + OSD_Directory aDirectory = OSD_Directory::BuildTemporary(); + OSD_Path aFilePath; + const TCollection_ExtendedString aFileName = + MakeTemporaryFile(aDirectory, "draw_xcaf_layers", theFormat, aFilePath); + occ::handle anApplication = NewApplication(theFormat); + occ::handle aDocument = NewDocument(theFormat, anApplication); + occ::handle aShapeTool = XCAFDoc_DocumentTool::ShapeTool(aDocument->Main()); + occ::handle aLayerTool = XCAFDoc_DocumentTool::LayerTool(aDocument->Main()); + const TDF_Label aShapeLabel = aShapeTool->AddShape(BRepPrimAPI_MakeBox(10.0, 20.0, 30.0).Shape()); + const TDF_Label aLayerLabel = aLayerTool->AddLayer(TCollection_ExtendedString("Layer_1")); + + ASSERT_FALSE(aDocument.IsNull()); + ASSERT_FALSE(aShapeLabel.IsNull()); + ASSERT_FALSE(aLayerLabel.IsNull()); + aLayerTool->SetLayer(aShapeLabel, aLayerLabel); + aDocument->NewCommand(); + + TCollection_AsciiString aShapeEntry; + TCollection_AsciiString aLayerEntry; + TDF_Tool::Entry(aShapeLabel, aShapeEntry); + TDF_Tool::Entry(aLayerLabel, aLayerEntry); + + occ::handle aRestored = + SaveAndOpen(anApplication, aDocument, aFileName, aFilePath); + ASSERT_FALSE(aRestored.IsNull()); + + TDF_Label aRestoredShape; + TDF_Label aRestoredLayer; + TDF_Tool::Label(aRestored->GetData(), aShapeEntry, aRestoredShape); + TDF_Tool::Label(aRestored->GetData(), aLayerEntry, aRestoredLayer); + ASSERT_FALSE(aRestoredShape.IsNull()); + ASSERT_FALSE(aRestoredLayer.IsNull()); + + occ::handle aRestoredLayerTool = + XCAFDoc_DocumentTool::LayerTool(aRestored->Main()); + NCollection_Sequence aLayers; + ASSERT_TRUE(aRestoredLayerTool->GetLayers(aRestoredShape, aLayers)); + ASSERT_EQ(aLayers.Length(), 1); + EXPECT_EQ(aLayers.Value(1), aRestoredLayer); + + TCollection_ExtendedString aLayerName; + ASSERT_TRUE(aRestoredLayerTool->GetLayer(aLayers.Value(1), aLayerName)); + EXPECT_EQ(aLayerName, TCollection_ExtendedString("Layer_1")); +} + +static void TestLocation(const StorageFormat theFormat) +{ + OSD_Directory aDirectory = OSD_Directory::BuildTemporary(); + OSD_Path aFilePath; + const TCollection_ExtendedString aFileName = + MakeTemporaryFile(aDirectory, "draw_xcaf_location", theFormat, aFilePath); + occ::handle anApplication = NewApplication(theFormat); + occ::handle aDocument = NewDocument(theFormat, anApplication); + occ::handle aShapeTool = XCAFDoc_DocumentTool::ShapeTool(aDocument->Main()); + const TDF_Label anAssembly = aShapeTool->NewShape(); + const TDF_Label aBaseShape = aShapeTool->AddShape(BRepPrimAPI_MakeBox(10.0, 20.0, 30.0).Shape()); + gp_Trsf aTransformation; + aTransformation.SetTranslation(gp_Vec(333.0, 777.0, 13.0)); + const TopLoc_Location anExpectedLocation(aTransformation); + const TDF_Label aComponent = aShapeTool->AddComponent(anAssembly, aBaseShape, anExpectedLocation); + + ASSERT_FALSE(aDocument.IsNull()); + ASSERT_FALSE(anAssembly.IsNull()); + ASSERT_FALSE(aComponent.IsNull()); + aDocument->NewCommand(); + + TCollection_AsciiString anAssemblyEntry; + TCollection_AsciiString aComponentEntry; + TDF_Tool::Entry(anAssembly, anAssemblyEntry); + TDF_Tool::Entry(aComponent, aComponentEntry); + + occ::handle aRestored = + SaveAndOpen(anApplication, aDocument, aFileName, aFilePath); + ASSERT_FALSE(aRestored.IsNull()); + + TDF_Label aRestoredAssembly; + TDF_Label aRestoredComponent; + TDF_Tool::Label(aRestored->GetData(), anAssemblyEntry, aRestoredAssembly); + TDF_Tool::Label(aRestored->GetData(), aComponentEntry, aRestoredComponent); + ASSERT_FALSE(aRestoredAssembly.IsNull()); + ASSERT_FALSE(aRestoredComponent.IsNull()); + const gp_Trsf aRestoredTransformation = + XCAFDoc_ShapeTool::GetLocation(aRestoredComponent).Transformation(); + const gp_Trsf anExpectedTransformation = anExpectedLocation.Transformation(); + for (int aRow = 1; aRow <= 3; ++aRow) + { + for (int aColumn = 1; aColumn <= 4; ++aColumn) + { + EXPECT_DOUBLE_EQ(aRestoredTransformation.Value(aRow, aColumn), + anExpectedTransformation.Value(aRow, aColumn)); + } + } +} + +static void TestVolume(const StorageFormat theFormat) +{ + OSD_Directory aDirectory = OSD_Directory::BuildTemporary(); + OSD_Path aFilePath; + const TCollection_ExtendedString aFileName = + MakeTemporaryFile(aDirectory, "draw_xcaf_volume", theFormat, aFilePath); + occ::handle anApplication = NewApplication(theFormat); + occ::handle aDocument = NewDocument(theFormat, anApplication); + const TDF_Label aLabel = Label_0_1_1_1(aDocument); + const double anExpected = 13.777; + + ASSERT_FALSE(aDocument.IsNull()); + ASSERT_FALSE(XCAFDoc_Volume::Set(aLabel, anExpected).IsNull()); + aDocument->NewCommand(); + + occ::handle aRestored = + SaveAndOpen(anApplication, aDocument, aFileName, aFilePath); + ASSERT_FALSE(aRestored.IsNull()); + + double aValue = 0.0; + ASSERT_TRUE(XCAFDoc_Volume::Get(Label_0_1_1_1(aRestored), aValue)); + EXPECT_DOUBLE_EQ(aValue, anExpected); +} + +static void TestLengthUnit(const StorageFormat theFormat, const double theExpectedMeterScale) +{ + occ::handle anApplication = NewApplication(theFormat); + occ::handle aDocument = NewDocument(theFormat, anApplication); + ASSERT_FALSE(aDocument.IsNull()); + + occ::handle aShapeTool = XCAFDoc_DocumentTool::ShapeTool(aDocument->Main()); + ASSERT_FALSE(aShapeTool->AddShape(BRepPrimAPI_MakeBox(10.0, 20.0, 30.0).Shape()).IsNull()); + XCAFDoc_DocumentTool::SetLengthUnit(aDocument, theExpectedMeterScale); + + occ::handle aRestored = SaveAndOpenStream(anApplication, aDocument); + ASSERT_FALSE(aRestored.IsNull()); + double aRestoredMeterScale = 0.0; + ASSERT_TRUE(XCAFDoc_DocumentTool::GetLengthUnit(aRestored, aRestoredMeterScale)); + EXPECT_NEAR(aRestoredMeterScale, theExpectedMeterScale, 1.0e-2); +} + +static void TestGlobalLengthUnit(const StorageFormat theFormat, + const int theCascadeUnit, + const double theExpectedMeterScale) +{ + UnitsMethods::SetCasCadeLengthUnit(theCascadeUnit); + occ::handle anApplication = NewApplication(theFormat); + occ::handle aDocument = NewDocument(theFormat, anApplication); + ASSERT_FALSE(aDocument.IsNull()); + + occ::handle aShapeTool = XCAFDoc_DocumentTool::ShapeTool(aDocument->Main()); + ASSERT_FALSE(aShapeTool->AddShape(BRepPrimAPI_MakeBox(1.0, 1.0, 1.0).Shape()).IsNull()); + XCAFDoc_DocumentTool::SetLengthUnit( + aDocument, + UnitsMethods::GetCasCadeLengthUnit(UnitsMethods_LengthUnit_Meter)); + + occ::handle aRestored = SaveAndOpenStream(anApplication, aDocument); + UnitsMethods::SetCasCadeLengthUnit(2); + ASSERT_FALSE(aRestored.IsNull()); + double aRestoredMeterScale = 0.0; + ASSERT_TRUE(XCAFDoc_DocumentTool::GetLengthUnit(aRestored, aRestoredMeterScale)); + EXPECT_NEAR(aRestoredMeterScale, theExpectedMeterScale, 1.0e-2); +} + +static void TestAffectedPlane() +{ + occ::handle anApplication = NewApplication(StorageFormat::Xbf); + occ::handle aDocument = NewDocument(StorageFormat::Xbf, anApplication); + ASSERT_FALSE(aDocument.IsNull()); + + occ::handle aShapeTool = XCAFDoc_DocumentTool::ShapeTool(aDocument->Main()); + occ::handle aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(aDocument->Main()); + const TDF_Label aShapeLabel = aShapeTool->AddShape(BRepPrimAPI_MakeBox(1.0, 1.0, 1.0).Shape()); + const TDF_Label aToleranceLabel = aDimTolTool->AddGeomTolerance(); + aDimTolTool->SetGeomTolerance(aShapeLabel, aToleranceLabel); + + const gp_Pln aExpectedPlane(gp_Pnt(1.0, 2.0, 3.0), gp_Dir(0.0, 1.0, 0.0)); + occ::handle aTolerance; + ASSERT_TRUE(aToleranceLabel.FindAttribute(XCAFDoc_GeomTolerance::GetID(), aTolerance)); + occ::handle anObject = aTolerance->GetObject(); + anObject->SetAffectedPlane(aExpectedPlane, + XCAFDimTolObjects_ToleranceZoneAffectedPlane_Orientation); + aTolerance->SetObject(anObject); + + occ::handle aRestored = SaveAndOpenStream(anApplication, aDocument); + ASSERT_FALSE(aRestored.IsNull()); + occ::handle aRestoredDimTolTool = + XCAFDoc_DocumentTool::DimTolTool(aRestored->Main()); + NCollection_Sequence aTolerances; + aRestoredDimTolTool->GetGeomToleranceLabels(aTolerances); + ASSERT_EQ(aTolerances.Length(), 1); + + occ::handle aRestoredTolerance; + ASSERT_TRUE( + aTolerances.Value(1).FindAttribute(XCAFDoc_GeomTolerance::GetID(), aRestoredTolerance)); + const occ::handle aRestoredObject = + aRestoredTolerance->GetObject(); + ASSERT_TRUE(aRestoredObject->HasAffectedPlane()); + EXPECT_EQ(aRestoredObject->GetAffectedPlaneType(), + XCAFDimTolObjects_ToleranceZoneAffectedPlane_Orientation); + const gp_Pln& aRestoredPlane = aRestoredObject->GetAffectedPlane(); + EXPECT_TRUE(aRestoredPlane.Location().IsEqual(aExpectedPlane.Location(), Precision::Confusion())); + EXPECT_TRUE(aRestoredPlane.Axis().Direction().IsEqual(aExpectedPlane.Axis().Direction(), + Precision::Confusion())); +} + +} // namespace + +// xml/data/xcaf/A1: XCAFDoc_Area survives XML and XBF document storage. +TEST(XmlXCAF_Storage_Test, Xml_A1_Area) +{ + TestArea(StorageFormat::Xml); +} + +TEST(XmlXCAF_Storage_Test, Xbf_A1_Area) +{ + TestArea(StorageFormat::Xbf); +} + +// xml/data/xcaf/A4: the color table keeps the exact RGB/RGBA value. +TEST(XmlXCAF_Storage_Test, Xml_A4_Color) +{ + TestColor(StorageFormat::Xml); +} + +TEST(XmlXCAF_Storage_Test, Xbf_A4_Color) +{ + TestColor(StorageFormat::Xbf); +} + +// xml/data/xcaf/A5: XCAFDoc_Centroid survives document storage. +TEST(XmlXCAF_Storage_Test, Xml_A5_Centroid) +{ + TestCentroid(StorageFormat::Xml); +} + +TEST(XmlXCAF_Storage_Test, Xbf_A5_Centroid) +{ + TestCentroid(StorageFormat::Xbf); +} + +// xml/data/xcaf/A6: leading zeroes in a TDataStd_Name are preserved. +TEST(XmlXCAF_Storage_Test, Xml_A6_NameLeadingZeroes) +{ + TestName(StorageFormat::Xml); +} + +TEST(XmlXCAF_Storage_Test, Xbf_A6_NameLeadingZeroes) +{ + TestName(StorageFormat::Xbf); +} + +// xml/data/xcaf/A7: shape-to-layer graph links survive document storage. +TEST(XmlXCAF_Storage_Test, Xml_A7_LayerLink) +{ + TestLayers(StorageFormat::Xml); +} + +TEST(XmlXCAF_Storage_Test, Xbf_A7_LayerLink) +{ + TestLayers(StorageFormat::Xbf); +} + +// xml/data/xcaf/A8: a located component keeps its XCAFDoc_Location. +TEST(XmlXCAF_Storage_Test, Xml_A8_ComponentLocation) +{ + TestLocation(StorageFormat::Xml); +} + +TEST(XmlXCAF_Storage_Test, Xbf_A8_ComponentLocation) +{ + TestLocation(StorageFormat::Xbf); +} + +// xml/data/xcaf/A9: XCAFDoc_Volume survives document storage. +TEST(XmlXCAF_Storage_Test, Xml_A9_Volume) +{ + TestVolume(StorageFormat::Xml); +} + +TEST(XmlXCAF_Storage_Test, Xbf_A9_Volume) +{ + TestVolume(StorageFormat::Xbf); +} + +TEST(XmlXCAF_Storage_Test, Xml_CafBug_31382_InchUnit) +{ + TestLengthUnit(StorageFormat::Xml, 0.0254); +} + +TEST(XmlXCAF_Storage_Test, Xbf_CafBug_31382_MeterUnit) +{ + TestLengthUnit(StorageFormat::Xbf, 1.0); +} + +TEST(XmlXCAF_Storage_Test, Xml_CafBug_31382_GlobalMileUnit) +{ + TestGlobalLengthUnit(StorageFormat::Xml, 5, 1609.344); +} + +TEST(XmlXCAF_Storage_Test, Xbf_CafBug_31382_GlobalKilometerUnit) +{ + TestGlobalLengthUnit(StorageFormat::Xbf, 7, 1000.0); +} + +TEST(XmlXCAF_Storage_Test, Xbf_CafBug_29338_AffectedPlane) +{ + TestAffectedPlane(); +} + +// bugs/caf/bug25537: XML-XCAF storage handles many long decimal position and +// centroid attributes without an exception or value corruption. +TEST(XmlXCAF_Storage_Test, CafBug_25537_LongPositionAndCentroid) +{ + occ::handle anApplication = NewApplication(StorageFormat::Xml); + occ::handle aDocument = NewDocument(StorageFormat::Xml, anApplication); + ASSERT_FALSE(aDocument.IsNull()); + const double aBigNumber = -0.0000000000123456789123456789; + const gp_Pnt anExpected(aBigNumber, aBigNumber, aBigNumber); + const TDF_Label aRoot = aDocument->GetData()->Root(); + + for (int anIndex = 1; anIndex < 100; ++anIndex) + { + TDataXtd_Position::Set(aRoot.FindChild(1, true).FindChild(anIndex, true), anExpected); + ASSERT_FALSE( + XCAFDoc_Centroid::Set(aRoot.FindChild(2, true).FindChild(anIndex, true), anExpected) + .IsNull()); + } + + occ::handle aRestored = SaveAndOpenStream(anApplication, aDocument); + ASSERT_FALSE(aRestored.IsNull()); + const TDF_Label aRestoredRoot = aRestored->GetData()->Root(); + for (int anIndex = 1; anIndex < 100; ++anIndex) + { + gp_Pnt aPosition; + ASSERT_TRUE(TDataXtd_Position::Get(aRestoredRoot.FindChild(1, false).FindChild(anIndex, false), + aPosition)); + EXPECT_TRUE(aPosition.IsEqual(anExpected, Precision::Confusion())); + + gp_Pnt aCentroid; + ASSERT_TRUE(XCAFDoc_Centroid::Get(aRestoredRoot.FindChild(2, false).FindChild(anIndex, false), + aCentroid)); + EXPECT_TRUE(aCentroid.IsEqual(anExpected, Precision::Confusion())); + } +} diff --git a/src/Draw/TKDCAF/GTests/DNaming_Driver_Test.cxx b/src/Draw/TKDCAF/GTests/DNaming_Driver_Test.cxx new file mode 100644 index 0000000000..6de7fa1af0 --- /dev/null +++ b/src/Draw/TKDCAF/GTests/DNaming_Driver_Test.cxx @@ -0,0 +1,433 @@ +// Copyright (c) 2026 OPEN CASCADE SAS +// +// This file is part of Open CASCADE Technology software library. +// +// This library is free software; you can redistribute it and/or modify it under +// the terms of the GNU Lesser General Public License version 2.1 as published +// by the Free Software Foundation, with special exception defined in the file +// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT +// distribution for complete text of the license and disclaimer of any warranty. +// +// Alternatively, this file may be used under the terms of Open CASCADE +// commercial license or contractual agreement. + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace +{ +static occ::handle NewDocument() +{ + return new TDocStd_Document("BinOcaf"); +} + +static occ::handle AddObject(const occ::handle& theDocument) +{ + occ::handle aRootNode = TDataStd_TreeNode::Set(theDocument->Main()); + const TDF_Label aLabel = TDF_TagSource::NewChild(theDocument->Main()); + occ::handle anObject = TDataStd_UAttribute::Set(aLabel, GEOMOBJECT_GUID); + occ::handle aNode = TDataStd_TreeNode::Set(aLabel); + aRootNode->Append(aNode); + return anObject; +} + +static void SetObjectShape(const occ::handle& theObject, + const TopoDS_Shape& theShape) +{ + const TDF_Label aShapeLabel = TDF_TagSource::NewChild(theObject->Label()); + TNaming_Builder aBuilder(aShapeLabel); + aBuilder.Generated(theShape); + TDF_Reference::Set(theObject->Label(), aShapeLabel); +} + +static occ::handle AddFunction( + const occ::handle& theObject, + const Standard_GUID& theDriverGuid) +{ + const TDF_Label aFunctionLabel = TDF_TagSource::NewChild(theObject->Label()); + occ::handle aFunction = + TFunction_Function::Set(aFunctionLabel, theDriverGuid); + occ::handle aFunctionNode = TDataStd_TreeNode::Set(aFunctionLabel); + occ::handle anObjectNode; + theObject->Label().FindAttribute(TDataStd_TreeNode::GetDefaultTreeID(), anObjectNode); + anObjectNode->Append(aFunctionNode); + + const TDF_Label anArgumentsLabel = TDF_TagSource::NewChild(aFunctionLabel); + occ::handle anArgumentsNode = TDataStd_TreeNode::Set(anArgumentsLabel); + if (!aFunctionNode.IsNull()) + { + aFunctionNode->Append(anArgumentsNode); + } + + const TDF_Label aResultLabel = TDF_TagSource::NewChild(aFunctionLabel); + occ::handle aResultNode = TDataStd_TreeNode::Set(aResultLabel); + if (!aFunctionNode.IsNull()) + { + aFunctionNode->Append(aResultNode); + } + + TDF_Reference::Set(theObject->Label(), aResultLabel); + return aFunction; +} + +static int ExecuteFunction(const occ::handle& theDocument, + const occ::handle& theFunction, + const occ::handle& theDriver) +{ + (void)theDocument; + occ::handle aLogbook = TFunction_Logbook::Set(theFunction->Label()); + aLogbook->Clear(); + theDriver->Init(theFunction->Label()); + return theDriver->Execute(aLogbook); +} + +static TopoDS_Shape FunctionShape(const occ::handle& theFunction) +{ + const occ::handle aNamedShape = DNaming::GetFunctionResult(theFunction); + return aNamedShape.IsNull() ? TopoDS_Shape() : TNaming_Tool::GetShape(aNamedShape); +} + +static occ::handle MakePointObject( + const occ::handle& theDocument, + const gp_Pnt& thePoint) +{ + occ::handle anObject = AddObject(theDocument); + SetObjectShape(anObject, BRepBuilderAPI_MakeVertex(thePoint).Vertex()); + return anObject; +} + +static occ::handle MakeBoxFunction( + const occ::handle& theDocument, + const occ::handle& theObject, + const double theDx, + const double theDy, + const double theDz) +{ + occ::handle aFunction = AddFunction(theObject, BOX_GUID); + DNaming::GetReal(aFunction, BOX_DX)->Set(theDx); + DNaming::GetReal(aFunction, BOX_DY)->Set(theDy); + DNaming::GetReal(aFunction, BOX_DZ)->Set(theDz); + EXPECT_EQ(ExecuteFunction(theDocument, aFunction, new DNaming_BoxDriver()), 0); + return aFunction; +} + +static occ::handle MakeSphereFunction( + const occ::handle& theDocument, + const occ::handle& theObject, + const occ::handle& theCenter, + const double theRadius) +{ + occ::handle aFunction = AddFunction(theObject, SPH_GUID); + DNaming::SetObjectArg(aFunction, SPHERE_CENTER, theCenter); + DNaming::GetReal(aFunction, SPHERE_RADIUS)->Set(theRadius); + EXPECT_EQ(ExecuteFunction(theDocument, aFunction, new DNaming_SphereDriver()), 0); + return aFunction; +} + +static occ::handle AddFuseFunction( + const occ::handle& theDocument, + const occ::handle& theObject, + const occ::handle& theTool) +{ + occ::handle aFunction = AddFunction(theObject, FUSE_GUID); + DNaming::SetObjectArg(aFunction, BOOL_TOOL, theTool); + EXPECT_EQ(ExecuteFunction(theDocument, aFunction, new DNaming_BooleanOperationDriver()), 0); + return aFunction; +} + +static occ::handle AddCutFunction( + const occ::handle& theDocument, + const occ::handle& theObject, + const occ::handle& theTool) +{ + occ::handle aFunction = AddFunction(theObject, CUT_GUID); + DNaming::SetObjectArg(aFunction, BOOL_TOOL, theTool); + EXPECT_EQ(ExecuteFunction(theDocument, aFunction, new DNaming_BooleanOperationDriver()), 0); + return aFunction; +} + +static occ::handle AddSectionFunction( + const occ::handle& theDocument, + const occ::handle& theObject, + const occ::handle& theTool) +{ + occ::handle aFunction = AddFunction(theObject, SECTION_GUID); + DNaming::SetObjectArg(aFunction, BOOL_TOOL, theTool); + EXPECT_EQ(ExecuteFunction(theDocument, aFunction, new DNaming_BooleanOperationDriver()), 0); + return aFunction; +} + +static occ::handle AddTranslationFunction( + const occ::handle& theDocument, + const occ::handle& theObject, + const double theDx, + const double theDy, + const double theDz) +{ + occ::handle aFunction = AddFunction(theObject, PTXYZ_GUID); + DNaming::GetReal(aFunction, PTRANSF_DX)->Set(theDx); + DNaming::GetReal(aFunction, PTRANSF_DY)->Set(theDy); + DNaming::GetReal(aFunction, PTRANSF_DZ)->Set(theDz); + EXPECT_EQ(ExecuteFunction(theDocument, aFunction, new DNaming_TransformationDriver()), 0); + return aFunction; +} + +static void AddDriversToTable() +{ + occ::handle aTable = TFunction_DriverTable::Get(); + aTable->AddDriver(BOX_GUID, new DNaming_BoxDriver()); + aTable->AddDriver(SPH_GUID, new DNaming_SphereDriver()); + aTable->AddDriver(CUT_GUID, new DNaming_BooleanOperationDriver()); + aTable->AddDriver(FUSE_GUID, new DNaming_BooleanOperationDriver()); + aTable->AddDriver(PTXYZ_GUID, new DNaming_TransformationDriver()); + aTable->AddDriver(PTALINE_GUID, new DNaming_TransformationDriver()); + aTable->AddDriver(PRRLINE_GUID, new DNaming_TransformationDriver()); + aTable->AddDriver(PMIRR_GUID, new DNaming_TransformationDriver()); + aTable->AddDriver(FILLT_GUID, new DNaming_FilletDriver()); +} +} // namespace + +// caf/driver/A2: recompute a box through the transformation and fillet driver chain. +TEST(DNaming_Driver_Test, CafDriver_A2_TransformationChain) +{ + AddDriversToTable(); + occ::handle aDocument = NewDocument(); + occ::handle aBoxObject = AddObject(aDocument); + occ::handle aBoxFunction = + MakeBoxFunction(aDocument, aBoxObject, 190.0, 290.0, 390.0); + ASSERT_FALSE(FunctionShape(aBoxFunction).IsNull()); + + occ::handle aTranslate = + AddTranslationFunction(aDocument, aBoxObject, 150.0, 40.0, 90.0); + ASSERT_FALSE(FunctionShape(aTranslate).IsNull()); + + occ::handle aLineObject = AddObject(aDocument); + SetObjectShape( + aLineObject, + BRepBuilderAPI_MakeEdge(gp_Lin(gp_Pnt(0.0, 0.0, 0.0), gp_Dir(0.0, 0.0, 1.0))).Edge()); + occ::handle aAlongLine = AddFunction(aBoxObject, PTALINE_GUID); + DNaming::SetObjectArg(aAlongLine, PTRANSF_LINE, aLineObject); + DNaming::GetReal(aAlongLine, PTRANSF_OFF)->Set(210.0); + ASSERT_EQ(ExecuteFunction(aDocument, aAlongLine, new DNaming_TransformationDriver()), 0); + + occ::handle aRotate = AddFunction(aBoxObject, PRRLINE_GUID); + DNaming::SetObjectArg(aRotate, PTRANSF_LINE, aLineObject); + DNaming::GetReal(aRotate, PTRANSF_ANG)->Set(120.0); + ASSERT_EQ(ExecuteFunction(aDocument, aRotate, new DNaming_TransformationDriver()), 0); + + occ::handle aPlaneObject = AddObject(aDocument); + SetObjectShape(aPlaneObject, + BRepBuilderAPI_MakeFace(gp_Pln(gp_Pnt(0.0, 0.0, 0.0), gp_Dir(0.0, 0.0, 1.0)), + -100.0, + 100.0, + -100.0, + 100.0) + .Face()); + occ::handle aMirror = AddFunction(aBoxObject, PMIRR_GUID); + DNaming::SetObjectArg(aMirror, PTRANSF_PLANE, aPlaneObject); + ASSERT_EQ(ExecuteFunction(aDocument, aMirror, new DNaming_TransformationDriver()), 0); + + TopExp_Explorer anEdgeExplorer(FunctionShape(aMirror), TopAbs_EDGE); + ASSERT_TRUE(anEdgeExplorer.More()); + occ::handle aPathObject = AddObject(aDocument); + SetObjectShape(aPathObject, anEdgeExplorer.Current()); + occ::handle aFillet = AddFunction(aBoxObject, FILLT_GUID); + DNaming::GetReal(aFillet, FILLET_RADIUS)->Set(25.0); + DNaming::GetInteger(aFillet, FILLET_SURFTYPE)->Set(0); + DNaming::SetObjectArg(aFillet, FILLET_PATH, aPathObject); + ASSERT_EQ(ExecuteFunction(aDocument, aFillet, new DNaming_FilletDriver()), 0); + EXPECT_FALSE(FunctionShape(aFillet).IsNull()); +} + +// bugs/caf/bug24869: the section driver preserves the DRAW naming counts for +// the generated section edges and modified source faces. +TEST(DNaming_Driver_Test, CafBug_24869_SectionNamingCounts) +{ + AddDriversToTable(); + const occ::handle aDocument = NewDocument(); + + const occ::handle aFirstObject = AddObject(aDocument); + MakeBoxFunction(aDocument, aFirstObject, 100.0, 200.0, 300.0); + + const occ::handle aSecondObject = AddObject(aDocument); + MakeBoxFunction(aDocument, aSecondObject, 150.0, 200.0, 300.0); + AddTranslationFunction(aDocument, aSecondObject, 30.0, 40.0, 50.0); + + const occ::handle aSection = + AddSectionFunction(aDocument, aFirstObject, aSecondObject); + ASSERT_FALSE(aSection.IsNull()); + const TopoDS_Shape aSectionShape = FunctionShape(aSection); + ASSERT_FALSE(aSectionShape.IsNull()); + + const TDF_Label aSectionNamingLabel = + aSection->Label().FindChild(FUNCTION_RESULT_LABEL).FindChild(1); + int aNbNewShapes = 0; + int aNbOldShapes = 0; + for (TNaming_Iterator anIterator(aSectionNamingLabel); anIterator.More(); anIterator.Next()) + { + aNbNewShapes += anIterator.NewShape().IsNull() ? 0 : 1; + aNbOldShapes += anIterator.OldShape().IsNull() ? 0 : 1; + } + EXPECT_EQ(aNbNewShapes, 18); + EXPECT_EQ(aNbOldShapes, 18); +} + +// caf/driver/A9: create spheres, fuse them with a box, and recompute after a box edit. +TEST(DNaming_Driver_Test, CafDriver_A9_SpheresAndFuses) +{ + AddDriversToTable(); + occ::handle aDocument = NewDocument(); + occ::handle aBoxObject = AddObject(aDocument); + occ::handle aBoxFunction = + MakeBoxFunction(aDocument, aBoxObject, 130.0, 140.0, 150.0); + occ::handle aCenterObject = + MakePointObject(aDocument, gp_Pnt(0.0, 0.0, 0.0)); + + occ::handle aSphereObject1 = AddObject(aDocument); + occ::handle aSphereObject2 = AddObject(aDocument); + occ::handle aSphere1 = + MakeSphereFunction(aDocument, aSphereObject1, aCenterObject, 25.0); + occ::handle aSphere2 = + MakeSphereFunction(aDocument, aSphereObject2, aCenterObject, 25.0); + ASSERT_FALSE(FunctionShape(aSphere1).IsNull()); + ASSERT_FALSE(FunctionShape(aSphere2).IsNull()); + + occ::handle aFuse1 = AddFuseFunction(aDocument, aBoxObject, aSphereObject1); + occ::handle aFuse2 = AddFuseFunction(aDocument, aBoxObject, aSphereObject2); + ASSERT_FALSE(FunctionShape(aFuse1).IsNull()); + ASSERT_FALSE(FunctionShape(aFuse2).IsNull()); + + DNaming::GetReal(aBoxFunction, BOX_DX)->Set(210.0); + DNaming::GetReal(aBoxFunction, BOX_DZ)->Set(270.0); + ASSERT_EQ(ExecuteFunction(aDocument, aBoxFunction, new DNaming_BoxDriver()), 0); + ASSERT_EQ(ExecuteFunction(aDocument, aSphere1, new DNaming_SphereDriver()), 0); + ASSERT_EQ(ExecuteFunction(aDocument, aSphere2, new DNaming_SphereDriver()), 0); + ASSERT_EQ(ExecuteFunction(aDocument, aFuse1, new DNaming_BooleanOperationDriver()), 0); + ASSERT_EQ(ExecuteFunction(aDocument, aFuse2, new DNaming_BooleanOperationDriver()), 0); + EXPECT_FALSE(FunctionShape(aFuse2).IsNull()); +} + +// caf/driver/B2: recompute two translated spheres and their fuse after editing the box driver. +TEST(DNaming_Driver_Test, CafDriver_B2_RecomputeFuse) +{ + AddDriversToTable(); + occ::handle aDocument = NewDocument(); + occ::handle aBoxObject = AddObject(aDocument); + occ::handle aBoxFunction = + MakeBoxFunction(aDocument, aBoxObject, 130.0, 140.0, 150.0); + occ::handle aCenterObject = + MakePointObject(aDocument, gp_Pnt(0.0, 0.0, 0.0)); + occ::handle aSphereObject1 = AddObject(aDocument); + occ::handle aSphereObject2 = AddObject(aDocument); + occ::handle aSphere1 = + MakeSphereFunction(aDocument, aSphereObject1, aCenterObject, 250.0); + occ::handle aSphere2 = + MakeSphereFunction(aDocument, aSphereObject2, aCenterObject, 30.0); + occ::handle aTranslate = + AddTranslationFunction(aDocument, aSphereObject2, 0.0, -253.0, 0.0); + occ::handle aFuse = + AddFuseFunction(aDocument, aSphereObject1, aSphereObject2); + ASSERT_FALSE(FunctionShape(aTranslate).IsNull()); + ASSERT_FALSE(FunctionShape(aFuse).IsNull()); + + DNaming::GetReal(aBoxFunction, BOX_DZ)->Set(270.0); + ASSERT_EQ(ExecuteFunction(aDocument, aBoxFunction, new DNaming_BoxDriver()), 0); + ASSERT_EQ(ExecuteFunction(aDocument, aSphere1, new DNaming_SphereDriver()), 0); + ASSERT_EQ(ExecuteFunction(aDocument, aSphere2, new DNaming_SphereDriver()), 0); + ASSERT_EQ(ExecuteFunction(aDocument, aTranslate, new DNaming_TransformationDriver()), 0); + ASSERT_EQ(ExecuteFunction(aDocument, aFuse, new DNaming_BooleanOperationDriver()), 0); + EXPECT_FALSE(FunctionShape(aFuse).IsNull()); +} + +// caf/driver/B3: cut several translated spheres from a common sphere and recompute. +TEST(DNaming_Driver_Test, CafDriver_B3_RecomputeCuts) +{ + AddDriversToTable(); + occ::handle aDocument = NewDocument(); + occ::handle aBoxObject = AddObject(aDocument); + occ::handle aBoxFunction = + MakeBoxFunction(aDocument, aBoxObject, 130.0, 140.0, 150.0); + occ::handle aCenterObject = + MakePointObject(aDocument, gp_Pnt(0.0, 0.0, 0.0)); + occ::handle aMainSphereObject = AddObject(aDocument); + occ::handle aMainSphere = + MakeSphereFunction(aDocument, aMainSphereObject, aCenterObject, 250.0); + + occ::handle aToolObject1 = AddObject(aDocument); + occ::handle aToolObject2 = AddObject(aDocument); + occ::handle aToolObject3 = AddObject(aDocument); + occ::handle aToolObject4 = AddObject(aDocument); + occ::handle aTool1 = + MakeSphereFunction(aDocument, aToolObject1, aCenterObject, 30.0); + occ::handle aTool2 = + MakeSphereFunction(aDocument, aToolObject2, aCenterObject, 30.0); + occ::handle aTool3 = + MakeSphereFunction(aDocument, aToolObject3, aCenterObject, 30.0); + occ::handle aTool4 = + MakeSphereFunction(aDocument, aToolObject4, aCenterObject, 30.0); + AddTranslationFunction(aDocument, aToolObject1, 0.0, -251.0, 0.0); + AddTranslationFunction(aDocument, aToolObject2, 0.0, 251.0, 0.0); + AddTranslationFunction(aDocument, aToolObject3, -251.0, 0.0, 0.0); + AddTranslationFunction(aDocument, aToolObject4, 251.0, -40.0, 0.0); + occ::handle aCut1 = + AddCutFunction(aDocument, aMainSphereObject, aToolObject1); + occ::handle aCut2 = + AddCutFunction(aDocument, aMainSphereObject, aToolObject2); + occ::handle aCut3 = + AddCutFunction(aDocument, aMainSphereObject, aToolObject3); + occ::handle aCut4 = + AddCutFunction(aDocument, aMainSphereObject, aToolObject4); + (void)aMainSphere; + (void)aTool1; + (void)aTool2; + (void)aTool3; + (void)aTool4; + ASSERT_FALSE(FunctionShape(aCut4).IsNull()); + + DNaming::GetReal(aBoxFunction, BOX_DZ)->Set(270.0); + ASSERT_EQ(ExecuteFunction(aDocument, aBoxFunction, new DNaming_BoxDriver()), 0); + ASSERT_EQ(ExecuteFunction(aDocument, aCut1, new DNaming_BooleanOperationDriver()), 0); + ASSERT_EQ(ExecuteFunction(aDocument, aCut2, new DNaming_BooleanOperationDriver()), 0); + ASSERT_EQ(ExecuteFunction(aDocument, aCut3, new DNaming_BooleanOperationDriver()), 0); + ASSERT_EQ(ExecuteFunction(aDocument, aCut4, new DNaming_BooleanOperationDriver()), 0); + EXPECT_FALSE(FunctionShape(aCut4).IsNull()); +} diff --git a/src/Draw/TKDCAF/GTests/FILES.cmake b/src/Draw/TKDCAF/GTests/FILES.cmake new file mode 100644 index 0000000000..d6841e5420 --- /dev/null +++ b/src/Draw/TKDCAF/GTests/FILES.cmake @@ -0,0 +1,6 @@ +# Test source files for TKDCAF +set(OCCT_TKDCAF_GTests_FILES_LOCATION "${CMAKE_CURRENT_LIST_DIR}") + +set(OCCT_TKDCAF_GTests_FILES + DNaming_Driver_Test.cxx +) diff --git a/src/FoundationClasses/TKMath/GTests/BVH_DistanceField_Test.cxx b/src/FoundationClasses/TKMath/GTests/BVH_DistanceField_Test.cxx new file mode 100644 index 0000000000..da64123c11 --- /dev/null +++ b/src/FoundationClasses/TKMath/GTests/BVH_DistanceField_Test.cxx @@ -0,0 +1,133 @@ +// Copyright (c) 2026 OPEN CASCADE SAS +// +// This file is part of Open CASCADE Technology software library. +// +// This library is free software; you can redistribute it and/or modify it under +// the terms of the GNU Lesser General Public License version 2.1 as published +// by the Free Software Foundation, with special exception defined in the file +// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT +// distribution for complete text of the license and disclaimer of any warranty. +// +// Alternatively, this file may be used under the terms of Open CASCADE +// commercial license or contractual agreement. + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +namespace +{ +class ShapeTriangulation : public BVH_Triangulation +{ +public: + bool Build(const TopoDS_Face& theFace) + { + TopLoc_Location aLocation; + const Handle(Poly_Triangulation)& aTriangulation = BRep_Tool::Triangulation(theFace, aLocation); + if (aTriangulation.IsNull()) + { + return false; + } + + for (int aTriangleIndex = 1; aTriangleIndex <= aTriangulation->NbTriangles(); ++aTriangleIndex) + { + int aNode1 = 0; + int aNode2 = 0; + int aNode3 = 0; + aTriangulation->Triangle(aTriangleIndex).Get(aNode1, aNode2, aNode3); + const gp_Pnt aPoint1 = aTriangulation->Node(aNode1).Transformed(aLocation.Transformation()); + const gp_Pnt aPoint2 = aTriangulation->Node(aNode2).Transformed(aLocation.Transformation()); + const gp_Pnt aPoint3 = aTriangulation->Node(aNode3).Transformed(aLocation.Transformation()); + + const int aFirstVertex = static_cast(Vertices.Size()); + Vertices.Append(BVH_Vec3d(aPoint1.X(), aPoint1.Y(), aPoint1.Z())); + Vertices.Append(BVH_Vec3d(aPoint2.X(), aPoint2.Y(), aPoint2.Z())); + Vertices.Append(BVH_Vec3d(aPoint3.X(), aPoint3.Y(), aPoint3.Z())); + Elements.Append(BVH_Vec4i(aFirstVertex, aFirstVertex + 1, aFirstVertex + 2, aTriangleIndex)); + } + + MarkDirty(); + BVH(); + return Size() > 0; + } +}; + +class ShapeGeometry : public BVH_Geometry +{ +public: + bool Build(const TopoDS_Shape& theShape) + { + NCollection_IndexedMap aFaces; + TopExp::MapShapes(theShape, TopAbs_FACE, aFaces); + for (int aFaceIndex = 1; aFaceIndex <= aFaces.Extent(); ++aFaceIndex) + { + const opencascade::handle aTriangulation = new ShapeTriangulation(); + if (!aTriangulation->Build(TopoDS::Face(aFaces(aFaceIndex)))) + { + return false; + } + myObjects.Append(aTriangulation); + } + + MarkDirty(); + BVH(); + return myObjects.Size() > 0; + } +}; +} // namespace + +// Migrated from tests/lowalgos/bvh/bug30655_4. The DRAW command only checked +// that the distance field could be built; the additional checks make its +// output contract explicit without relying on printed voxel data. +TEST(BVH_DistanceFieldTest, Bug30655_BoxDistanceField) +{ + const TopoDS_Shape aBox = BRepPrimAPI_MakeBox(10., 10., 10.).Shape(); + BRepMesh_IncrementalMesh aMesh(aBox, 0.1); + (void)aMesh; + + ShapeGeometry aGeometry; + ASSERT_TRUE(aGeometry.Build(aBox)); + + BVH_DistanceField aDistanceField(2, true); + ASSERT_TRUE(aDistanceField.Build(aGeometry)); + EXPECT_EQ(aDistanceField.DimensionX(), 2); + EXPECT_EQ(aDistanceField.DimensionY(), 2); + EXPECT_EQ(aDistanceField.DimensionZ(), 2); + EXPECT_NE(aDistanceField.VoxelSize().x(), 0.); + EXPECT_NE(aDistanceField.VoxelSize().y(), 0.); + EXPECT_NE(aDistanceField.VoxelSize().z(), 0.); + + bool hasInsideVoxel = false; + bool hasOutsideVoxel = false; + for (int aZ = 0; aZ < aDistanceField.DimensionZ(); ++aZ) + { + for (int aY = 0; aY < aDistanceField.DimensionY(); ++aY) + { + for (int aX = 0; aX < aDistanceField.DimensionX(); ++aX) + { + const double aVoxel = aDistanceField.Voxel(aX, aY, aZ); + EXPECT_TRUE(std::isfinite(aVoxel)); + hasInsideVoxel = hasInsideVoxel || aVoxel < 0.; + hasOutsideVoxel = hasOutsideVoxel || aVoxel > 0.; + } + } + } + EXPECT_TRUE(hasInsideVoxel); + EXPECT_TRUE(hasOutsideVoxel); +} diff --git a/src/FoundationClasses/TKMath/GTests/BVH_PairDistance_Test.cxx b/src/FoundationClasses/TKMath/GTests/BVH_PairDistance_Test.cxx new file mode 100644 index 0000000000..84f559e9cd --- /dev/null +++ b/src/FoundationClasses/TKMath/GTests/BVH_PairDistance_Test.cxx @@ -0,0 +1,240 @@ +// Copyright (c) 2026 OPEN CASCADE SAS +// +// This file is part of Open CASCADE Technology software library. +// +// This library is free software; you can redistribute it and/or modify it under +// the terms of the GNU Lesser General Public License version 2.1 as published +// by the Free Software Foundation, with special exception defined in the file +// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT +// distribution for complete text of the license and disclaimer of any warranty. +// +// Alternatively, this file may be used under the terms of Open CASCADE +// commercial license or contractual agreement. + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +namespace +{ +struct Triangle +{ + BVH_Vec3d myNode1; + BVH_Vec3d myNode2; + BVH_Vec3d myNode3; +}; + +typedef BVH_BoxSet TriangleBoxSet; + +double triangleTriangleSqDistance(const BVH_Vec3d& theNode11, + const BVH_Vec3d& theNode12, + const BVH_Vec3d& theNode13, + const BVH_Vec3d& theNode21, + const BVH_Vec3d& theNode22, + const BVH_Vec3d& theNode23) +{ + double aMinDistance = std::numeric_limits::max(); + const BVH_Vec3d aNodes[2][3] = {{theNode11, theNode12, theNode13}, + {theNode21, theNode22, theNode23}}; + + // This is the same bounded edge sampling used by QABVH_PairDistance. + const int aNbSegments = 100; + for (int aTriangleIndex = 0; aTriangleIndex < 2; ++aTriangleIndex) + { + for (int aPointIndex = 0; aPointIndex < 3; ++aPointIndex) + { + const double aDistance = + BVH_Tools::PointTriangleSquareDistance(aNodes[aTriangleIndex][aPointIndex], + aNodes[(aTriangleIndex + 1) % 2][0], + aNodes[(aTriangleIndex + 1) % 2][1], + aNodes[(aTriangleIndex + 1) % 2][2]); + if (aDistance < aMinDistance) + { + aMinDistance = aDistance; + if (aMinDistance == 0.) + { + return aMinDistance; + } + } + } + + const BVH_Vec3d aEdgeStarts[3] = {aNodes[aTriangleIndex][0], + aNodes[aTriangleIndex][1], + aNodes[aTriangleIndex][2]}; + const BVH_Vec3d aEdgeEnds[3] = {aNodes[aTriangleIndex][1], + aNodes[aTriangleIndex][2], + aNodes[aTriangleIndex][0]}; + for (int anEdgeIndex = 0; anEdgeIndex < 3; ++anEdgeIndex) + { + const BVH_Vec3d aFirstPoint = aEdgeStarts[anEdgeIndex]; + const BVH_Vec3d aLastPoint = aEdgeEnds[anEdgeIndex]; + BVH_Vec3d anEdge = aLastPoint - aFirstPoint; + const double aLength = anEdge.Modulus(); + if (aLength < Precision::Confusion()) + { + continue; + } + anEdge /= aLength; + + const double aDelta = aLength / aNbSegments; + for (int aPointIndex = 1; aPointIndex < aNbSegments; ++aPointIndex) + { + const BVH_Vec3d aPoint = aFirstPoint + anEdge.Multiplied(aPointIndex * aDelta); + const double aDistance = + BVH_Tools::PointTriangleSquareDistance(aPoint, + aNodes[(aTriangleIndex + 1) % 2][0], + aNodes[(aTriangleIndex + 1) % 2][1], + aNodes[(aTriangleIndex + 1) % 2][2]); + if (aDistance < aMinDistance) + { + aMinDistance = aDistance; + if (aMinDistance == 0.) + { + return aMinDistance; + } + } + } + } + } + return aMinDistance; +} + +opencascade::handle makeTriangleBoxSet(const TopoDS_Shape& theShape) +{ + const opencascade::handle> aBuilder = + new BVH_LinearBuilder(); + const opencascade::handle aSet = new TriangleBoxSet(aBuilder); + + NCollection_IndexedMap aFaces; + TopExp::MapShapes(theShape, TopAbs_FACE, aFaces); + for (int aFaceIndex = 1; aFaceIndex <= aFaces.Extent(); ++aFaceIndex) + { + TopLoc_Location aLocation; + const Handle(Poly_Triangulation)& aTriangulation = + BRep_Tool::Triangulation(TopoDS::Face(aFaces(aFaceIndex)), aLocation); + if (aTriangulation.IsNull()) + { + return opencascade::handle(); + } + + for (int aTriangleIndex = 1; aTriangleIndex <= aTriangulation->NbTriangles(); ++aTriangleIndex) + { + int aNode1 = 0; + int aNode2 = 0; + int aNode3 = 0; + aTriangulation->Triangle(aTriangleIndex).Get(aNode1, aNode2, aNode3); + const gp_Pnt aPoint1 = aTriangulation->Node(aNode1).Transformed(aLocation.Transformation()); + const gp_Pnt aPoint2 = aTriangulation->Node(aNode2).Transformed(aLocation.Transformation()); + const gp_Pnt aPoint3 = aTriangulation->Node(aNode3).Transformed(aLocation.Transformation()); + + Triangle aTriangle; + aTriangle.myNode1 = BVH_Vec3d(aPoint1.X(), aPoint1.Y(), aPoint1.Z()); + aTriangle.myNode2 = BVH_Vec3d(aPoint2.X(), aPoint2.Y(), aPoint2.Z()); + aTriangle.myNode3 = BVH_Vec3d(aPoint3.X(), aPoint3.Y(), aPoint3.Z()); + BVH_Box aBox; + aBox.Add(aTriangle.myNode1); + aBox.Add(aTriangle.myNode2); + aBox.Add(aTriangle.myNode3); + aSet->Add(aTriangle, aBox); + } + } + if (aSet->Size() == 0) + { + return opencascade::handle(); + } + aSet->Build(); + return aSet; +} + +class MeshMeshDistance : public BVH_PairDistance +{ +public: + bool Accept(const int theIndex1, const int theIndex2) override + { + const Triangle& aTriangle1 = myBVHSet1->Element(theIndex1); + const Triangle& aTriangle2 = myBVHSet2->Element(theIndex2); + const double aDistance = triangleTriangleSqDistance(aTriangle1.myNode1, + aTriangle1.myNode2, + aTriangle1.myNode3, + aTriangle2.myNode1, + aTriangle2.myNode2, + aTriangle2.myNode3); + if (aDistance < myDistance) + { + myDistance = aDistance; + return true; + } + return false; + } +}; + +void meshShape(const TopoDS_Shape& theShape, const double theDeflection) +{ + BRepMesh_IncrementalMesh aMesh(theShape, theDeflection); + (void)aMesh; +} +} // namespace + +// Migrated from tests/lowalgos/bvh/bug30655_2. +TEST(BVH_PairDistanceTest, Bug30655_BoxDistance) +{ + const TopoDS_Shape aBox1 = BRepPrimAPI_MakeBox(10., 10., 10.).Shape(); + const TopoDS_Shape aBox2 = BRepPrimAPI_MakeBox(gp_Pnt(20., 0., 0.), 10., 10., 10.).Shape(); + meshShape(aBox1, 0.1); + meshShape(aBox2, 0.1); + + const opencascade::handle aSet1 = makeTriangleBoxSet(aBox1); + const opencascade::handle aSet2 = makeTriangleBoxSet(aBox2); + ASSERT_FALSE(aSet1.IsNull()); + ASSERT_FALSE(aSet2.IsNull()); + + MeshMeshDistance aDistance; + aDistance.SetBVHSets(aSet1.operator->(), aSet2.operator->()); + const double aDistanceValue = std::sqrt(aDistance.ComputeDistance()); + ASSERT_TRUE(aDistance.IsDone()); + EXPECT_NEAR(aDistanceValue, 10., 1.e-2); + EXPECT_NEAR(std::sqrt(aDistance.Distance()), 10., 1.e-2); +} + +// Migrated from tests/lowalgos/bvh/bug30655_3. +TEST(BVH_PairDistanceTest, Bug30655_SphereDistance) +{ + const TopoDS_Shape aSphere1 = BRepPrimAPI_MakeSphere(100.).Shape(); + const TopoDS_Shape aSphere2 = BRepPrimAPI_MakeSphere(gp_Pnt(150., 150., 150.), 110.).Shape(); + meshShape(aSphere1, 0.01); + meshShape(aSphere2, 0.01); + + const opencascade::handle aSet1 = makeTriangleBoxSet(aSphere1); + const opencascade::handle aSet2 = makeTriangleBoxSet(aSphere2); + ASSERT_FALSE(aSet1.IsNull()); + ASSERT_FALSE(aSet2.IsNull()); + + MeshMeshDistance aDistance; + aDistance.SetBVHSets(aSet1.operator->(), aSet2.operator->()); + const double aDistanceValue = std::sqrt(aDistance.ComputeDistance()); + ASSERT_TRUE(aDistance.IsDone()); + + const double anAnalyticDistance = std::sqrt(3. * 150. * 150.) - 210.; + EXPECT_NEAR(aDistanceValue, anAnalyticDistance, 1.e-2); + EXPECT_NEAR(std::sqrt(aDistance.Distance()), anAnalyticDistance, 1.e-2); +} diff --git a/src/FoundationClasses/TKMath/GTests/BVH_ShapeSelect_Test.cxx b/src/FoundationClasses/TKMath/GTests/BVH_ShapeSelect_Test.cxx new file mode 100644 index 0000000000..99dc6dc95d --- /dev/null +++ b/src/FoundationClasses/TKMath/GTests/BVH_ShapeSelect_Test.cxx @@ -0,0 +1,244 @@ +// Copyright (c) 2026 OPEN CASCADE SAS +// +// This file is part of Open CASCADE Technology software library. +// +// This library is free software; you can redistribute it and/or modify it under +// the terms of the GNU Lesser General Public License version 2.1 as published +// by the Free Software Foundation, with special exception defined in the file +// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT +// distribution for complete text of the license and disclaimer of any warranty. +// +// Alternatively, this file may be used under the terms of Open CASCADE +// commercial license or contractual agreement. + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +namespace +{ +typedef BVH_BoxSet ShapeBoxSet; + +occ::handle makeShapeBoxSet(const TopoDS_Shape& theShape) +{ + const occ::handle> aBuilder = new BVH_LinearBuilder(); + const occ::handle aSet = new ShapeBoxSet(aBuilder); + + NCollection_IndexedMap aShapes; + TopExp::MapShapes(theShape, TopAbs_VERTEX, aShapes); + TopExp::MapShapes(theShape, TopAbs_EDGE, aShapes); + TopExp::MapShapes(theShape, TopAbs_FACE, aShapes); + for (int anIndex = 1; anIndex <= aShapes.Extent(); ++anIndex) + { + Bnd_Box aBox; + BRepBndLib::Add(aShapes(anIndex), aBox); + aSet->Add(aShapes(anIndex), Bnd_Tools::Bnd2BVH(aBox)); + } + aSet->Build(); + return aSet; +} + +class ShapeSelector : public BVH_Traverse +{ +public: + void SetSelectionBox(const TopoDS_Shape& theShape) + { + Bnd_Box aBox; + BRepBndLib::Add(theShape, aBox); + myBox = Bnd_Tools::Bnd2BVH(aBox); + } + + bool RejectNode(const BVH_Vec3d& theMin, + const BVH_Vec3d& theMax, + bool& theIsInside) const override + { + bool hasOverlap = false; + theIsInside = myBox.Contains(theMin, theMax, hasOverlap); + return !hasOverlap; + } + + bool AcceptMetric(const bool& theIsInside) const override { return theIsInside; } + + bool Accept(const int theIndex, const bool& theIsInside) override + { + if (theIsInside || !myBox.IsOut(myBVHSet->Box(theIndex))) + { + ++myAccepted; + return true; + } + return false; + } + + int Accepted() const { return myAccepted; } + +private: + BVH_Box myBox; + int myAccepted = 0; +}; + +class ShapeSelectorVoid : public BVH_Traverse +{ +public: + void SetSelectionBox(const TopoDS_Shape& theShape) + { + Bnd_Box aBox; + BRepBndLib::Add(theShape, aBox); + myBox = Bnd_Tools::Bnd2BVH(aBox); + } + + void SetShapeBoxSet(const ShapeBoxSet* theSet) { mySet = theSet; } + + bool RejectNode(const BVH_Vec3d& theMin, + const BVH_Vec3d& theMax, + bool& theIsInside) const override + { + bool hasOverlap = false; + theIsInside = myBox.Contains(theMin, theMax, hasOverlap); + return !hasOverlap; + } + + bool AcceptMetric(const bool& theIsInside) const override { return theIsInside; } + + bool Accept(const int theIndex, const bool& theIsInside) override + { + if (theIsInside || !myBox.IsOut(mySet->Box(theIndex))) + { + ++myAccepted; + return true; + } + return false; + } + + int Accepted() const { return myAccepted; } + +private: + const ShapeBoxSet* mySet = nullptr; + BVH_Box myBox; + int myAccepted = 0; +}; + +class PairSelector : public BVH_PairTraverse +{ +public: + bool RejectNode(const BVH_Vec3d& theMin1, + const BVH_Vec3d& theMax1, + const BVH_Vec3d& theMin2, + const BVH_Vec3d& theMax2, + bool& theMetric) const override + { + const BVH_Box aBox(theMin1, theMax1); + theMetric = !aBox.IsOut(theMin2, theMax2); + return !theMetric; + } + + bool Accept(const int theIndex1, const int theIndex2) override + { + if (!myBVHSet1->Box(theIndex1).IsOut(myBVHSet2->Box(theIndex2))) + { + ++myAccepted; + return true; + } + return false; + } + + int Accepted() const { return myAccepted; } + +private: + int myAccepted = 0; +}; + +class PairSelectorVoid : public BVH_PairTraverse +{ +public: + void SetShapeBoxSets(const ShapeBoxSet* theSet1, const ShapeBoxSet* theSet2) + { + mySet1 = theSet1; + mySet2 = theSet2; + } + + bool RejectNode(const BVH_Vec3d& theMin1, + const BVH_Vec3d& theMax1, + const BVH_Vec3d& theMin2, + const BVH_Vec3d& theMax2, + bool& theMetric) const override + { + const BVH_Box aBox(theMin1, theMax1); + theMetric = !aBox.IsOut(theMin2, theMax2); + return !theMetric; + } + + bool Accept(const int theIndex1, const int theIndex2) override + { + if (!mySet1->Box(theIndex1).IsOut(mySet2->Box(theIndex2))) + { + ++myAccepted; + return true; + } + return false; + } + + int Accepted() const { return myAccepted; } + +private: + const ShapeBoxSet* mySet1 = nullptr; + const ShapeBoxSet* mySet2 = nullptr; + int myAccepted = 0; +}; +} // namespace + +// Migrated from tests/lowalgos/bvh/bug30655_1. A box has 8 vertices, 12 +// edges, and 6 faces; selecting a vertex/edge/face must therefore find 7/11/17 +// interfering sub-shape boxes, respectively. +TEST(BVH_ShapeSelectTest, Bug30655_ShapeSelectionTypedAndVoid) +{ + const TopoDS_Shape aBox = BRepPrimAPI_MakeBox(10., 10., 10.).Shape(); + const occ::handle aSet = makeShapeBoxSet(aBox); + + const TopAbs_ShapeEnum aTypes[] = {TopAbs_VERTEX, TopAbs_EDGE, TopAbs_FACE}; + const int anExpected[] = {7, 11, 17}; + for (int aTypeIndex = 0; aTypeIndex < 3; ++aTypeIndex) + { + NCollection_IndexedMap aShapes; + TopExp::MapShapes(aBox, aTypes[aTypeIndex], aShapes); + for (int aShapeIndex = 1; aShapeIndex <= aShapes.Extent(); ++aShapeIndex) + { + ShapeSelector aSelector; + aSelector.SetSelectionBox(aShapes(aShapeIndex)); + aSelector.SetBVHSet(aSet.operator->()); + EXPECT_EQ(aSelector.Select(), anExpected[aTypeIndex]); + EXPECT_EQ(aSelector.Accepted(), anExpected[aTypeIndex]); + + ShapeSelectorVoid aVoidSelector; + aVoidSelector.SetSelectionBox(aShapes(aShapeIndex)); + aVoidSelector.SetShapeBoxSet(aSet.operator->()); + EXPECT_EQ(aVoidSelector.Select(aSet->BVH()), anExpected[aTypeIndex]); + EXPECT_EQ(aVoidSelector.Accepted(), anExpected[aTypeIndex]); + } + EXPECT_EQ(aShapes.Extent(), aTypeIndex == 0 ? 8 : aTypeIndex == 1 ? 12 : 6); + } +} + +TEST(BVH_ShapeSelectTest, Bug30655_PairSelectionTypedAndVoid) +{ + const TopoDS_Shape aBox = BRepPrimAPI_MakeBox(10., 10., 10.).Shape(); + const occ::handle aSet = makeShapeBoxSet(aBox); + + PairSelector aSelector; + aSelector.SetBVHSets(aSet.operator->(), aSet.operator->()); + EXPECT_EQ(aSelector.Select(), 290); + EXPECT_EQ(aSelector.Accepted(), 290); + + PairSelectorVoid aVoidSelector; + aVoidSelector.SetShapeBoxSets(aSet.operator->(), aSet.operator->()); + EXPECT_EQ(aVoidSelector.Select(aSet->BVH(), aSet->BVH()), 290); + EXPECT_EQ(aVoidSelector.Accepted(), 290); +} diff --git a/src/FoundationClasses/TKMath/GTests/CSLib_Test.cxx b/src/FoundationClasses/TKMath/GTests/CSLib_Test.cxx index 893d2717ca..9ebe0f7bac 100644 --- a/src/FoundationClasses/TKMath/GTests/CSLib_Test.cxx +++ b/src/FoundationClasses/TKMath/GTests/CSLib_Test.cxx @@ -412,10 +412,9 @@ TEST_F(CSLibClass2dTest, LazyGridMatchesExactPathForConcaveDiagonalPolygon) } } -TEST_F(CSLibClass2dTest, LazyGridConcurrentBuildOverlapIsThreadSafe) +TEST_F(CSLibClass2dTest, LazyGridConcurrentActivationQueriesAreThreadSafe) { - // The large polygon keeps the designated build query active while synchronized - // readers exercise the exact fallback. Run this test under TSAN for race detection. + // Release concurrent queries together at the lazy-grid activation threshold. constexpr int THE_POINT_COUNT = 32768; NCollection_Array1 aPnts(1, THE_POINT_COUNT); for (int anIdx = 0; anIdx < THE_POINT_COUNT; ++anIdx) @@ -431,40 +430,20 @@ TEST_F(CSLibClass2dTest, LazyGridConcurrentBuildOverlapIsThreadSafe) ASSERT_EQ(aClassifier.SiDans(gp_Pnt2d(0.5, 0.5)), CSLib_Class2d::Result_Inside); } - std::atomic hasFailure{false}; - std::atomic canStart{false}; - std::atomic hasBuildQueryStarted{false}; - std::atomic hasBuildQueryFinished{false}; - std::atomic anOverlapQueryCount{0}; - std::atomic aReadyCount{0}; - std::thread aBuildThread([&]() { - while (!canStart.load(std::memory_order_acquire)) - { - std::this_thread::yield(); - } - hasBuildQueryStarted.store(true, std::memory_order_release); - if (aClassifier.SiDans(gp_Pnt2d(0.5, 0.5)) != CSLib_Class2d::Result_Inside) - { - hasFailure.store(true, std::memory_order_relaxed); - } - hasBuildQueryFinished.store(true, std::memory_order_release); - }); - - std::array aReaderThreads; - for (size_t aThreadIdx = 0; aThreadIdx < aReaderThreads.size(); ++aThreadIdx) + std::atomic hasFailure{false}; + std::atomic canStart{false}; + std::atomic aReadyCount{0}; + std::array aQueryThreads; + for (size_t aThreadIdx = 0; aThreadIdx < aQueryThreads.size(); ++aThreadIdx) { - aReaderThreads[aThreadIdx] = std::thread([&]() { + aQueryThreads[aThreadIdx] = std::thread([&]() { aReadyCount.fetch_add(1, std::memory_order_release); - while (!hasBuildQueryStarted.load(std::memory_order_acquire)) + while (!canStart.load(std::memory_order_acquire)) { std::this_thread::yield(); } for (size_t aQueryIdx = 0; aQueryIdx < 8; ++aQueryIdx) { - if (!hasBuildQueryFinished.load(std::memory_order_acquire)) - { - anOverlapQueryCount.fetch_add(1, std::memory_order_relaxed); - } const bool isInside = (aQueryIdx & 1u) == 0u; const gp_Pnt2d aPoint = isInside ? gp_Pnt2d(0.5, 0.5) : gp_Pnt2d(0.99, 0.99); const CSLib_Class2d::Result anExpected = @@ -477,30 +456,18 @@ TEST_F(CSLibClass2dTest, LazyGridConcurrentBuildOverlapIsThreadSafe) } }); } - while (aReadyCount.load(std::memory_order_acquire) != aReaderThreads.size()) + while (aReadyCount.load(std::memory_order_acquire) != aQueryThreads.size()) { std::this_thread::yield(); } canStart.store(true, std::memory_order_release); - while (!hasBuildQueryStarted.load(std::memory_order_acquire)) - { - std::this_thread::yield(); - } - if (!hasBuildQueryFinished.load(std::memory_order_acquire)) - { - anOverlapQueryCount.fetch_add(1, std::memory_order_relaxed); - if (aClassifier.SiDans(gp_Pnt2d(0.99, 0.99)) != CSLib_Class2d::Result_Outside) - { - hasFailure.store(true, std::memory_order_relaxed); - } - } - aBuildThread.join(); - for (std::thread& aThread : aReaderThreads) + for (std::thread& aThread : aQueryThreads) { aThread.join(); } EXPECT_FALSE(hasFailure.load(std::memory_order_relaxed)); - EXPECT_GT(anOverlapQueryCount.load(std::memory_order_relaxed), 0u); + EXPECT_EQ(aClassifier.SiDans(gp_Pnt2d(0.5, 0.5)), CSLib_Class2d::Result_Inside); + EXPECT_EQ(aClassifier.SiDans(gp_Pnt2d(0.99, 0.99)), CSLib_Class2d::Result_Outside); } TEST_F(CSLibClass2dTest, SiDansHandlesNegativeNonFiniteAndExtremeInputs) diff --git a/src/FoundationClasses/TKMath/GTests/FILES.cmake b/src/FoundationClasses/TKMath/GTests/FILES.cmake index c0c5f76406..ef70394d23 100644 --- a/src/FoundationClasses/TKMath/GTests/FILES.cmake +++ b/src/FoundationClasses/TKMath/GTests/FILES.cmake @@ -18,9 +18,12 @@ set(OCCT_TKMath_GTests_FILES BVH_Box_Test.cxx BVH_BuildQueue_Test.cxx BVH_LinearBuilder_Test.cxx + BVH_DistanceField_Test.cxx + BVH_PairDistance_Test.cxx BVH_QuickSorter_Test.cxx BVH_RadixSorter_Test.cxx BVH_Ray_Test.cxx + BVH_ShapeSelect_Test.cxx BVH_SpatialMedianBuilder_Test.cxx BVH_SweepPlaneBuilder_Test.cxx BVH_Tools_Test.cxx diff --git a/src/FoundationClasses/TKernel/GTests/OSD_Path_Test.cxx b/src/FoundationClasses/TKernel/GTests/OSD_Path_Test.cxx index 985e964465..2a5bc26533 100644 --- a/src/FoundationClasses/TKernel/GTests/OSD_Path_Test.cxx +++ b/src/FoundationClasses/TKernel/GTests/OSD_Path_Test.cxx @@ -12,6 +12,7 @@ // commercial license or contractual agreement. #include +#include #include #include @@ -53,6 +54,29 @@ TEST_F(OSD_PathTest, UncPaths) EXPECT_FALSE(OSD_Path::IsUnixPath("\\\\share\\file.pdf")); } +// fclasses/bugs/bug23852: UNC paths must retain their server/share trek and +// split the file name and extension consistently on every host. +TEST_F(OSD_PathTest, FClassesBug_23852_UncPathComponents) +{ +#if defined(_WIN32) || defined(__WIN32__) + OSD_Path aPath("\\\\Server\\Shared\\Folder\\File.Extension"); +#else + OSD_Path aPath("//Server/Shared/Folder/File.Extension"); +#endif + + EXPECT_STREQ("||Server|Shared|Folder|", aPath.Trek().ToCString()); + EXPECT_STREQ("File", aPath.Name().ToCString()); + EXPECT_STREQ(".Extension", aPath.Extension().ToCString()); + +#if defined(_WIN32) || defined(__WIN32__) + // DRAW also covers the slash-separated spelling on Windows. + OSD_Path aSlashPath("//Server/Shared/Folder/File.Extension"); + EXPECT_STREQ("||Server|Shared|Folder|", aSlashPath.Trek().ToCString()); + EXPECT_STREQ("File", aSlashPath.Name().ToCString()); + EXPECT_STREQ(".Extension", aSlashPath.Extension().ToCString()); +#endif +} + TEST_F(OSD_PathTest, NtExtendedPaths) { // Test NT Extended paths @@ -276,6 +300,26 @@ TEST_F(OSD_PathTest, OCC309_CurrentDirectoryAndUpTrek) EXPECT_LT(aSystemName2.Length(), aSystemName1.Length()); } +TEST_F(OSD_PathTest, FClassesBuc_60944_DotDotPathSystemName) +{ + // fclasses/buc60944: portable conversion must preserve a relative dot-dot path. + const TCollection_AsciiString anInput("../../.."); + OSD_Path aPath(anInput); + TCollection_AsciiString aSystemName; + aPath.SystemName(aSystemName); + EXPECT_EQ(aSystemName, anInput); +} + +// fclasses/bugs/bug710: checking an OSD file with an empty path must not raise. +TEST(OSD_FileTest, FClassesBug_710_EmptyFilePathDoesNotThrow) +{ + const TCollection_AsciiString anEmptyPath; + EXPECT_NO_THROW({ + OSD_File aFile(anEmptyPath); + (void)aFile.Exists(); + }); +} + //================================================================================================= // Validation Tests -//================================================================================================= \ No newline at end of file +//================================================================================================= diff --git a/src/FoundationClasses/TKernel/GTests/Quantity_Color_Test.cxx b/src/FoundationClasses/TKernel/GTests/Quantity_Color_Test.cxx index 18759cc099..f6e09200c5 100644 --- a/src/FoundationClasses/TKernel/GTests/Quantity_Color_Test.cxx +++ b/src/FoundationClasses/TKernel/GTests/Quantity_Color_Test.cxx @@ -289,3 +289,207 @@ TEST_F(Quantity_ColorTest, EdgeCases) Quantity_Color aColor2(0.50001, 0.50001, 0.50001, Quantity_TOC_RGB); EXPECT_TRUE(aColor1.IsEqual(aColor2)); // Should be equal within epsilon } + +namespace +{ +struct ColorConversionSample +{ + double myR; + double myG; + double myB; + double myC1; + double myC2; + double myC3; +}; + +struct LabDifferenceSample +{ + double myL1; + double myA1; + double myB1; + double myL2; + double myA2; + double myB2; + double myExpected; + double myTolerance; +}; + +void expectColorValues(const ColorConversionSample& theSample, + const Quantity_TypeOfColor theType, + const double theTolerance) +{ + Quantity_Color aColor(theSample.myR, theSample.myG, theSample.myB, Quantity_TOC_RGB); + double aC1, aC2, aC3; + aColor.Values(aC1, aC2, aC3, theType); + EXPECT_NEAR(aC1, theSample.myC1, theTolerance); + EXPECT_NEAR(aC2, theSample.myC2, theTolerance); + EXPECT_NEAR(aC3, theSample.myC3, theTolerance); +} + +void expectLabDifference(const LabDifferenceSample& theSample) +{ + const Quantity_Color aColor1(theSample.myL1, theSample.myA1, theSample.myB1, Quantity_TOC_CIELab); + const Quantity_Color aColor2(theSample.myL2, theSample.myA2, theSample.myB2, Quantity_TOC_CIELab); + EXPECT_NEAR(aColor1.DeltaE2000(aColor2), theSample.myExpected, theSample.myTolerance); +} +} // namespace + +// Migrated from tests/v3d/colors/rgb2lab. The DRAW command uses RGB as +// linear RGB, which is the native Quantity_Color representation. +TEST_F(Quantity_ColorTest, Draw_RGBToLabReferenceSamples) +{ + static const ColorConversionSample aSamples[] = { + {0., 0., 0., 0., 0., 0.}, + {1., 1., 1., 100., 0., 0.}, + {0.5, 0.5, 0.5, 76.0693, 0., 0.}, + {1., 0., 0., 53.2408, 80.0925, 67.2032}, + {0., 1., 0., 87.7347, -86.1827, 83.1793}, + {0., 0., 1., 32.2970, 79.1875, -107.8602}, + {0., 1., 1., 91.1132, -48.0875, -14.1312}, + {1., 1., 0., 97.1393, -21.5537, 94.4780}, + {1., 0., 1., 60.3242, 98.2343, -60.8249}, + {0.1, 0., 0., 16.1387, 37.1756, 25.0600}, + {0.3, 0., 0., 30.3521, 53.6166, 44.0349}, + {0.5, 0., 0., 38.9565, 63.5695, 53.3392}, + {0.7, 0., 0., 45.4792, 71.1144, 59.6700}, + {0.9, 0., 0., 50.8512, 77.3285, 64.8840}, + {0.3, 0.5, 0.9, 75.2228, 0.7560, -31.8425}, + }; + + for (const ColorConversionSample& aSample : aSamples) + { + expectColorValues(aSample, Quantity_TOC_CIELab, 1.e-4); + } +} + +// Migrated from tests/v3d/colors/rgb2lch. +TEST_F(Quantity_ColorTest, Draw_RGBToLchReferenceSamples) +{ + static const ColorConversionSample aSamples[] = { + {0., 0., 0., 0., 0., 0.}, + {1., 1., 1., 100., 0., 0.}, + {0.5, 0.5, 0.5, 76.0693, 0., 0.}, + {1., 0., 0., 53.2408, 104.5518, 39.9990}, + {0., 1., 0., 87.7347, 119.7759, 136.0160}, + {0., 0., 1., 32.2970, 133.8076, 306.2849}, + {0., 1., 1., 91.1132, 50.1209, 196.3762}, + {1., 1., 0., 97.1393, 96.9054, 102.8512}, + {1., 0., 1., 60.3242, 115.5407, 328.2350}, + {0.1, 0., 0., 16.1387, 44.8334, 33.9838}, + {0.3, 0., 0., 30.3521, 69.3816, 39.3960}, + {0.5, 0., 0., 38.9565, 82.9828, 39.9990}, + {0.7, 0., 0., 45.4792, 92.8320, 39.9990}, + {0.9, 0., 0., 50.8512, 100.9436, 39.9990}, + {0.3, 0.5, 0.9, 75.2228, 31.8514, 271.3601}, + }; + + for (const ColorConversionSample& aSample : aSamples) + { + expectColorValues(aSample, Quantity_TOC_CIELch, 1.e-4); + } +} + +// Migrated from tests/v3d/colors/stability. Use deterministic samples so +// failures are reproducible while retaining both conversion round trips. +TEST_F(Quantity_ColorTest, Draw_ColorSpaceRoundTripStability) +{ + for (int anIndex = 1; anIndex < 1000; ++anIndex) + { + const double aR = std::fmod(anIndex * 0.6180339887498949, 1.0); + const double aG = std::fmod(anIndex * 0.4142135623730950, 1.0); + const double aB = std::fmod(anIndex * 0.7320508075688773, 1.0); + + Quantity_Color aColor(aR, aG, aB, Quantity_TOC_RGB); + double aL, anA, aLabB; + aColor.Values(aL, anA, aLabB, Quantity_TOC_CIELab); + + Quantity_Color aFromLab; + aFromLab.SetValues(aL, anA, aLabB, Quantity_TOC_CIELab); + EXPECT_NEAR(aFromLab.Red(), aR, 1.e-4); + EXPECT_NEAR(aFromLab.Green(), aG, 1.e-4); + EXPECT_NEAR(aFromLab.Blue(), aB, 1.e-4); + + double aC, aH; + aColor.Values(aL, aC, aH, Quantity_TOC_CIELch); + Quantity_Color aFromLch; + aFromLch.SetValues(aL, aC, aH, Quantity_TOC_CIELch); + EXPECT_NEAR(aFromLch.Red(), aR, 1.e-4); + EXPECT_NEAR(aFromLch.Green(), aG, 1.e-4); + EXPECT_NEAR(aFromLch.Blue(), aB, 1.e-4); + } +} + +// Migrated from tests/v3d/colors/de2000. Constructing the colors from Lab +// follows the same gamut-adjusting conversion as vcolorconvert -from lab. +TEST_F(Quantity_ColorTest, Draw_CIEDE2000ReferenceSamples) +{ + static const LabDifferenceSample aSamples[] = { + {0., 0., 0., 50., 0., 0., 36.519268, 1.e-4}, + {50., 0., 0., 100., 0., 0., 36.519268, 1.e-4}, + {0., 0., 0., 100., 0., 0., 100., 1.e-4}, + {20., 10., 10., 80., 10., 10., 60., 1.e-4}, + {50., 0., 0., 50., 0., 50., 23.529412, 1.e-4}, + {50., 60., 60., 50., 60., 0., 28.016927, 1.e-4}, + {30., 30., 40., 30., 30., -60., 44.606253, 1.e-4}, + {30., 50.00, 40., 20., -10., -8., 39.105394, 1.e-3}, + {30., 50.01, 40., 20., -10., -8., 43.53247, 1.e-3}, + {20., 30.00, 30.01, 60., -10., -10., 49.416742, 0.05}, + {20., 30.01, 30.00, 60., -10., -10., 52.448227, 0.05}, + {73.4450, 34.9839, -24.6753, 87.6216, -18.4863, 57.8838, 62.402500, 1.e-4}, + {93.6166, -27.3677, 29.3893, 46.9191, 12.3400, -27.5948, 54.640034, 1.e-4}, + {53.9062, 61.0929, -51.7583, 65.5157, 26.3376, -37.0512, 15.679046, 1.e-4}, + {83.6996, 9.3358, -24.5571, 93.2268, -3.8589, 3.5217, 23.158692, 1.e-4}, + {64.8053, -27.3177, -8.9602, 65.8225, 37.3192, -38.1465, 34.670514, 1.e-4}, + {94.7633, -19.7915, 69.2787, 90.9238, -16.7535, 4.1936, 26.093024, 1.e-4}, + {85.4699, 5.6078, -11.1083, 67.9455, -28.4536, 7.8808, 31.115070, 1.e-4}, + {83.5473, -15.7170, 8.3546, 81.3193, -37.2851, 57.7090, 19.696753, 1.e-4}, + {75.7406, -12.0785, -12.3505, 80.0810, -54.8591, 52.1739, 35.834099, 1.e-4}, + {62.8209, 32.1209, 16.9113, 82.1106, 25.0843, -7.9416, 21.178519, 1.e-4}, + }; + + for (const LabDifferenceSample& aSample : aSamples) + { + expectLabDifference(aSample); + } +} + +// Migrated from tests/v3d/colors/de2000_sharma. This is the published +// supplementary data set from Sharma, Wu, and Dalal, excluding only the +// six out-of-gamut samples intentionally excluded by the DRAW test. +TEST_F(Quantity_ColorTest, Draw_CIEDE2000SharmaReferenceSamples) +{ + static const LabDifferenceSample aSamples[] = { + {50., 0., 0., 50., -1., 2., 2.3669, 1.e-3}, + {50., -1., 2., 50., 0., 0., 2.3669, 1.e-3}, + {50., 2.490, -0.001, 50., -2.490, 0.0009, 7.1792, 1.e-3}, + {50., 2.490, -0.001, 50., -2.490, 0.0010, 7.1792, 0.05}, + {50., 2.490, -0.001, 50., -2.490, 0.0011, 7.2195, 1.e-3}, + {50., 2.490, -0.001, 50., -2.490, 0.0012, 7.2195, 1.e-3}, + {50., -0.001, 2.490, 50., 0.0009, -2.490, 4.8045, 1.e-3}, + {50., -0.001, 2.490, 50., 0.0010, -2.490, 4.8045, 1.e-3}, + {50., -0.001, 2.490, 50., 0.0011, -2.490, 4.7461, 0.06}, + {50., 2.5, 0., 50., 0., -2.5, 4.3065, 1.e-3}, + {50., 2.5, 0., 73., 25., -18., 27.1492, 1.e-3}, + {50., 2.5, 0., 61., -5., 29., 22.8977, 1.e-3}, + {50., 2.5, 0., 56., -27., -3., 31.9030, 1.e-3}, + {50., 2.5, 0., 58., 24., 15., 19.4535, 1.e-3}, + {50., 2.5, 0., 50., 3.1736, 0.5854, 1., 1.e-3}, + {50., 2.5, 0., 50., 3.2972, 0., 1., 1.e-3}, + {50., 2.5, 0., 50., 1.8634, 0.5757, 1., 1.e-3}, + {50., 2.5, 0., 50., 3.2592, 0.3350, 1., 1.e-3}, + {60.2574, -34.0099, 36.2677, 60.4626, -34.1751, 39.4387, 1.2644, 1.e-3}, + {63.0109, -31.0961, -5.8663, 62.8187, -29.7946, -4.0864, 1.2630, 1.e-3}, + {61.2901, 3.7196, -5.3901, 61.4292, 2.2480, -4.9620, 1.8731, 1.e-3}, + {22.7233, 20.0904, -46.6940, 23.0331, 14.9730, -42.5619, 2.0373, 1.e-3}, + {36.4612, 47.8580, 18.3852, 36.2715, 50.5065, 21.2231, 1.4146, 1.e-3}, + {90.8027, -2.0831, 1.4410, 91.1528, -1.6435, 0.0447, 1.4441, 1.e-3}, + {90.9257, -0.5406, -0.9208, 88.6381, -0.8985, -0.7239, 1.5381, 1.e-3}, + {6.7747, -0.2908, -2.4247, 5.8714, -0.0985, -2.2286, 0.6377, 1.e-3}, + {2.0776, 0.0795, -1.1350, 0.9033, -0.0636, -0.5514, 0.9082, 1.e-3}, + }; + + for (const LabDifferenceSample& aSample : aSamples) + { + expectLabDifference(aSample); + } +} diff --git a/src/FoundationClasses/TKernel/GTests/UnitsAPI_Test.cxx b/src/FoundationClasses/TKernel/GTests/UnitsAPI_Test.cxx index f1af7cb92a..2ca62d0fd8 100644 --- a/src/FoundationClasses/TKernel/GTests/UnitsAPI_Test.cxx +++ b/src/FoundationClasses/TKernel/GTests/UnitsAPI_Test.cxx @@ -12,6 +12,8 @@ // commercial license or contractual agreement. #include +#include +#include #include @@ -37,3 +39,74 @@ TEST(UnitsAPI_Test, AnyToAny_UnknownUnit) EXPECT_DOUBLE_EQ(1.0, aResult1); EXPECT_DOUBLE_EQ(1.0, aResult2); } + +// fclasses/bugs/bug23497: composite units must be accepted by the SI converter. +TEST(UnitsAPI_Test, DISABLED_FClassesBug_23497_CompositeUnit) +{ + double aResult = 0.0; + EXPECT_NO_THROW(aResult = UnitsAPI::AnyToSI(1.0, "sq.km")); + EXPECT_DOUBLE_EQ(1.0e6, aResult); +} + +// fclasses/bugs/bug30800: Poise is 0.1 Pa*s and 0.001 kg/(cm*s). +TEST(UnitsAPI_Test, FClassesBug_30800_PoiseConversion) +{ + EXPECT_NEAR(UnitsAPI::AnyToSI(1.0, "Po"), 0.1, 1.0e-12); + EXPECT_NEAR(UnitsAPI::AnyToAny(1.0, "Po", "kg/cm/s"), 0.001, 1.0e-12); +} + +TEST(UnitsAPI_Test, FClassesBug_11568_2_MinuteAlias) +{ + // fclasses/bug11568_2: the legacy "mn" minute symbol converts to 60 seconds. + EXPECT_DOUBLE_EQ(UnitsAPI::AnyToSI(1.0, "mn"), 60.0); +} + +TEST(UnitsAPI_Test, FClassesBug_11568_4_MinuteSymbol) +{ + // fclasses/bug11568_4: the standard "min" minute symbol converts to 60 seconds. + EXPECT_DOUBLE_EQ(UnitsAPI::AnyToSI(1.0, "min"), 60.0); +} + +// fclasses/bugs/bug11568_1: the legacy minute alias must be parsed as "min". +TEST(UnitsAPI_Test, FClassesBug_11568_1_MinuteAliasParsing) +{ + UnitsAPI::SetLocalSystem(); + Units_UnitSentence aSentence("mn"); + ASSERT_TRUE(aSentence.IsDone()); + + const occ::handle aToken = aSentence.Evaluate(); + ASSERT_FALSE(aToken.IsNull()); + EXPECT_STREQ("min", aToken->Word().ToCString()); +} + +// fclasses/bugs/bug11568_3: the standard minute symbol must parse unchanged. +TEST(UnitsAPI_Test, FClassesBug_11568_3_MinuteSymbolParsing) +{ + UnitsAPI::SetLocalSystem(); + Units_UnitSentence aSentence("min"); + ASSERT_TRUE(aSentence.IsDone()); + + const occ::handle aToken = aSentence.Evaluate(); + ASSERT_FALSE(aToken.IsNull()); + EXPECT_STREQ("min", aToken->Word().ToCString()); +} + +// fclasses/bugs/bug9848_1: an unknown unit name must reject the sentence. +TEST(UnitsAPI_Test, FClassesBug_9848_1_InvalidUnitSentence) +{ + UnitsAPI::SetLocalSystem(); + Units_UnitSentence aSentence("tonne/(mm*s**2)"); + EXPECT_FALSE(aSentence.IsDone()); +} + +// fclasses/bugs/bug9848_2: a valid composite unit must produce the DRAW token word. +TEST(UnitsAPI_Test, FClassesBug_9848_2_ValidCompositeUnitSentence) +{ + UnitsAPI::SetLocalSystem(); + Units_UnitSentence aSentence("ton/(m*s**2)"); + ASSERT_TRUE(aSentence.IsDone()); + + const occ::handle aToken = aSentence.Evaluate(); + ASSERT_FALSE(aToken.IsNull()); + EXPECT_STREQ("(ton)/((m)*((s)**(2)))", aToken->Word().ToCString()); +} diff --git a/src/ModelingAlgorithms/TKBO/GTests/BOPAlgo_BOP_Test.cxx b/src/ModelingAlgorithms/TKBO/GTests/BOPAlgo_BOP_Test.cxx index a20861d210..bc851348c6 100644 --- a/src/ModelingAlgorithms/TKBO/GTests/BOPAlgo_BOP_Test.cxx +++ b/src/ModelingAlgorithms/TKBO/GTests/BOPAlgo_BOP_Test.cxx @@ -13,8 +13,22 @@ #include "BOPTest_Utilities.pxx" +#include +#include +#include +#include #include +#include +#include +#include +#include +#include #include +#include +#include +#include +#include +#include //================================================================================================= // Direct BOP Operations Tests (equivalent to bcut, bfuse, bcommon, btuc commands) @@ -24,6 +38,209 @@ class BOPAlgo_DirectOperationsTest : public BOPAlgo_TestBase { }; +static void ConfigureArgumentAnalyzer(BOPAlgo_ArgumentAnalyzer& theAnalyzer) +{ + theAnalyzer.ArgumentTypeMode() = true; + theAnalyzer.SelfInterMode() = true; + theAnalyzer.SmallEdgeMode() = true; + theAnalyzer.RebuildFaceMode() = true; + theAnalyzer.ContinuityMode() = true; + theAnalyzer.CurveOnSurfaceMode() = true; +} + +static int CountUniqueBOPSubShapes(const TopoDS_Shape& theShape, const TopAbs_ShapeEnum theType) +{ + NCollection_IndexedMap aShapes; + TopExp::MapShapes(theShape, theType, aShapes); + return aShapes.Extent(); +} + +static TopoDS_Shape MakeGridShell() +{ + BRepBuilderAPI_Sewing aSewing; + const gp_Pln aPlane(gp_Pnt(0.0, 0.0, 0.0), gp_Dir(0.0, 0.0, 1.0)); + for (int anX = 0; anX < 3; ++anX) + { + for (int anY = 0; anY < 3; ++anY) + { + aSewing.Add(BRepBuilderAPI_MakeFace(aPlane, + static_cast(anX), + static_cast(anX + 1), + static_cast(anY), + static_cast(anY + 1))); + } + } + aSewing.Perform(); + return aSewing.SewedShape(); +} + +static int CountCheckerInterferences(const TopoDS_Shape& theShape, const int theLevel) +{ + NCollection_List anArguments; + anArguments.Append(theShape); + + BOPAlgo_CheckerSI aChecker; + aChecker.SetArguments(anArguments); + aChecker.SetLevelOfCheck(theLevel); + aChecker.Perform(); + EXPECT_FALSE(aChecker.HasErrors()); + + const BOPDS_DS& aData = *aChecker.PDS(); + const NCollection_Map& aPairs = aData.Interferences(); + int aCount = 0; + for (NCollection_Map::Iterator anIterator(aPairs); anIterator.More(); + anIterator.Next()) + { + int anIndex1 = -1; + int anIndex2 = -1; + anIterator.Value().Indices(anIndex1, anIndex2); + if (!aData.IsNewShape(anIndex1) && !aData.IsNewShape(anIndex2)) + { + ++aCount; + } + } + return aCount; +} + +// Migrated from tests/bugs/modalg_5/bug24029. The bopcheck level controls +// which interference families are considered for two overlapping boxes. +TEST(BOPAlgo_CheckerSITest, ModalgBug_24029_CheckLevelControlsInterferences) +{ + const TopoDS_Shape aBox1 = BOPTest_Utilities::CreateBox(gp_Pnt(0, 0, 0), 10.0, 10.0, 10.0); + const TopoDS_Shape aBox2 = BOPTest_Utilities::CreateBox(gp_Pnt(5, 5, 5), 10.0, 10.0, 10.0); + + const TopoDS_Shape aCompound = [&]() { + BRep_Builder aBuilder; + TopoDS_Compound aResult; + aBuilder.MakeCompound(aResult); + aBuilder.Add(aResult, aBox1); + aBuilder.Add(aResult, aBox2); + return aResult; + }(); + + const int aLevel3Count = CountCheckerInterferences(aCompound, 3); + const int aLevel4Count = CountCheckerInterferences(aCompound, 4); + const int aLevel9Count = CountCheckerInterferences(aCompound, 9); + EXPECT_EQ(aLevel3Count, 0); + EXPECT_GT(aLevel4Count, 0); + EXPECT_GE(aLevel9Count, aLevel4Count); +} + +// Migrated from tests/bugs/modalg_5/bug24213. The standard sphere must be +// accepted as a valid single Boolean-operation argument. +TEST(BOPAlgo_ArgumentAnalyzerTest, ModalgBug_24213_SphereIsValidBOPArgument) +{ + BOPAlgo_ArgumentAnalyzer anAnalyzer; + anAnalyzer.SetShape1(BOPTest_Utilities::CreateSphere(gp_Pnt(0, 0, 0), 10.0)); + ConfigureArgumentAnalyzer(anAnalyzer); + anAnalyzer.Perform(); + + EXPECT_FALSE(anAnalyzer.HasFaulty()); + EXPECT_TRUE(anAnalyzer.GetCheckResult().IsEmpty()); +} + +// Migrated from tests/bugs/modalg_5/bug24492. A compound containing a solid +// and an isolated vertex must be reported as a faulty BOP argument. +TEST(BOPAlgo_ArgumentAnalyzerTest, ModalgBug_24492_MixedDimensionalCompoundIsFaulty) +{ + const TopoDS_Shape aBox = BOPTest_Utilities::CreateBox(gp_Pnt(0, 0, 0), 10.0, 10.0, 10.0); + const TopoDS_Shape aVertex = BRepBuilderAPI_MakeVertex(gp_Pnt(3.0, 3.0, 3.0)); + + BRep_Builder aBuilder; + TopoDS_Compound aCompound; + aBuilder.MakeCompound(aCompound); + aBuilder.Add(aCompound, aBox); + aBuilder.Add(aCompound, aVertex); + + BOPAlgo_ArgumentAnalyzer anAnalyzer; + anAnalyzer.SetShape1(aCompound); + ConfigureArgumentAnalyzer(anAnalyzer); + anAnalyzer.Perform(); + + ASSERT_TRUE(anAnalyzer.HasFaulty()); + const NCollection_List& aResults = anAnalyzer.GetCheckResult(); + ASSERT_EQ(aResults.Extent(), 1); + EXPECT_EQ(aResults.First().GetCheckStatus(), BOPAlgo_SelfIntersect); +} + +// Migrated from tests/bugs/modalg_5/bug25477_1. A fuzzy fuse must bridge the +// small gap between the two boxes and produce one solid with the DRAW counts. +TEST(BOPAlgo_BOPTest, ModalgBug_25477_FuzzyFuseBridgesSmallGap) +{ + const TopoDS_Shape aBox1 = BOPTest_Utilities::CreateBox(gp_Pnt(0.0, 0.0, 0.0), 10.0, 10.0, 10.0); + const TopoDS_Shape aBox2 = + BOPTest_Utilities::CreateBox(gp_Pnt(10.00001, 0.0, 0.0), 10.0, 10.0, 10.0); + + BOPAlgo_BOP aFuse; + aFuse.AddArgument(aBox1); + aFuse.AddTool(aBox2); + aFuse.SetOperation(BOPAlgo_FUSE); + aFuse.SetFuzzyValue(0.00002); + aFuse.SetRunParallel(false); + aFuse.SetNonDestructive(false); + aFuse.Perform(); + + ASSERT_FALSE(aFuse.HasErrors()); + const TopoDS_Shape aResult = aFuse.Shape(); + ASSERT_FALSE(aResult.IsNull()); + EXPECT_EQ(aResult.ShapeType(), TopAbs_COMPOUND); + EXPECT_EQ(CountUniqueBOPSubShapes(aResult, TopAbs_VERTEX), 12); + EXPECT_EQ(CountUniqueBOPSubShapes(aResult, TopAbs_EDGE), 20); + EXPECT_EQ(CountUniqueBOPSubShapes(aResult, TopAbs_WIRE), 10); + EXPECT_EQ(CountUniqueBOPSubShapes(aResult, TopAbs_FACE), 10); + EXPECT_EQ(CountUniqueBOPSubShapes(aResult, TopAbs_SHELL), 1); + EXPECT_EQ(CountUniqueBOPSubShapes(aResult, TopAbs_SOLID), 1); + EXPECT_EQ(CountUniqueBOPSubShapes(aResult, TopAbs_COMPOUND), 1); + EXPECT_EQ(CountUniqueBOPSubShapes(aResult, TopAbs_COMPSOLID), 0); + // Fuzzy classification slightly changes the bridge volume; it must remain + // close to the sum of the two box volumes. + EXPECT_NEAR(BOPTest_Utilities::GetVolume(aResult), 2000.0, 0.001); +} + +// Migrated from tests/bugs/modalg_5/bug24033. A common of a sewn planar +// shell and a box must preserve usable, non-INTERNAL orientations. +TEST(BOPAlgo_BOPTest, ModalgBug_24033_CommonResultOrientations) +{ + const TopoDS_Shape aShell = MakeGridShell(); + const TopoDS_Shape aBox = BOPTest_Utilities::CreateBox(gp_Pnt(-1.0, 1.0, -1.0), 2.0, 1.0, 2.0); + ASSERT_FALSE(aShell.IsNull()); + + BOPAlgo_BOP aCommon; + aCommon.AddArgument(aShell); + aCommon.AddTool(aBox); + aCommon.SetOperation(BOPAlgo_COMMON); + aCommon.SetRunParallel(false); + aCommon.SetNonDestructive(false); + aCommon.Perform(); + + ASSERT_FALSE(aCommon.HasErrors()); + const TopoDS_Shape aResult = aCommon.Shape(); + ASSERT_FALSE(aResult.IsNull()); + EXPECT_TRUE(BRepCheck_Analyzer(aResult).IsValid()); + + const NCollection_IndexedMap aFaces = [&]() { + NCollection_IndexedMap aMap; + TopExp::MapShapes(aResult, TopAbs_FACE, aMap); + return aMap; + }(); + const NCollection_IndexedMap anEdges = [&]() { + NCollection_IndexedMap aMap; + TopExp::MapShapes(aResult, TopAbs_EDGE, aMap); + return aMap; + }(); + const NCollection_IndexedMap aVertices = [&]() { + NCollection_IndexedMap aMap; + TopExp::MapShapes(aResult, TopAbs_VERTEX, aMap); + return aMap; + }(); + ASSERT_GT(aFaces.Extent(), 0); + ASSERT_GT(anEdges.Extent(), 0); + ASSERT_GT(aVertices.Extent(), 0); + EXPECT_NE(TopoDS::Face(aFaces(1)).Orientation(), TopAbs_INTERNAL); + EXPECT_NE(TopoDS::Edge(anEdges(1)).Orientation(), TopAbs_INTERNAL); + EXPECT_NE(TopoDS::Vertex(aVertices(1)).Orientation(), TopAbs_INTERNAL); +} + // Test direct cut operation: bcut result sphere box TEST_F(BOPAlgo_DirectOperationsTest, DirectCut_SphereMinusBox) { @@ -279,4 +496,4 @@ TEST_F(BOPAlgo_DegenerateToolTest, Common_SolidAndHalfspace_Unaffected) const TopoDS_Shape aRes = PerformDirectBOP(aBox, aHalfSpace, BOPAlgo_COMMON); ASSERT_FALSE(aRes.IsNull()); EXPECT_GT(BOPTest_Utilities::GetVolume(aRes), 1.0); -} \ No newline at end of file +} diff --git a/src/ModelingAlgorithms/TKBO/GTests/BOPAlgo_CellsBuilder_Test.cxx b/src/ModelingAlgorithms/TKBO/GTests/BOPAlgo_CellsBuilder_Test.cxx new file mode 100644 index 0000000000..08ca6fc634 --- /dev/null +++ b/src/ModelingAlgorithms/TKBO/GTests/BOPAlgo_CellsBuilder_Test.cxx @@ -0,0 +1,185 @@ +// Copyright (c) 2026 OPEN CASCADE SAS +// +// This file is part of Open CASCADE Technology software library. +// +// This library is free software; you can redistribute it and/or modify it under +// the terms of the GNU Lesser General Public License version 2.1 as published +// by the Free Software Foundation, with special exception defined in the file +// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT +// distribution for complete text of the license and disclaimer of any warranty. +// +// Alternatively, this file may be used under the terms of Open CASCADE +// commercial license or contractual agreement. + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace +{ +static int CountShapes(const NCollection_List& theShapes, + const TopAbs_ShapeEnum theType) +{ + NCollection_IndexedMap aMap; + for (NCollection_List::Iterator anIterator(theShapes); anIterator.More(); + anIterator.Next()) + { + TopExp::MapShapes(anIterator.Value(), aMap); + } + int aCount = 0; + for (int anIndex = 1; anIndex <= aMap.Extent(); ++anIndex) + { + if (aMap(anIndex).ShapeType() == theType) + { + ++aCount; + } + } + return aCount; +} + +static TopoDS_Face MakeCircleFace(const gp_Pnt& theCenter, const double theRadius) +{ + const TopoDS_Edge anEdge = + BRepBuilderAPI_MakeEdge(gp_Circ(gp_Ax2(theCenter, gp::DZ()), theRadius)).Edge(); + return BRepBuilderAPI_MakeFace(BRepBuilderAPI_MakeWire(anEdge).Wire()).Face(); +} + +static void ExpectModified(const BOPAlgo_CellsBuilder& theBuilder, + const TopoDS_Shape& theShape, + const TopAbs_ShapeEnum theType, + const int theCount) +{ + BOPAlgo_CellsBuilder& aBuilder = const_cast(theBuilder); + EXPECT_EQ(CountShapes(aBuilder.Modified(theShape), theType), theCount); +} + +static void AddToResult(BOPAlgo_CellsBuilder& theBuilder, + const TopoDS_Shape& theTake1, + const TopoDS_Shape& theTake2, + const TopoDS_Shape& theAvoid, + const int theMaterial) +{ + NCollection_List aTake; + aTake.Append(theTake1); + if (!theTake2.IsNull()) + { + aTake.Append(theTake2); + } + NCollection_List anAvoid; + if (!theAvoid.IsNull()) + { + anAvoid.Append(theAvoid); + } + theBuilder.AddToResult(aTake, anAvoid, theMaterial, false); +} +} // namespace + +// Equivalent to tests/boolean/history/A5. +TEST(BOPAlgo_CellsBuilderTest, A5_CircleCellsHistory) +{ + const TopoDS_Shape aFace1 = MakeCircleFace(gp_Pnt(0.0, 0.0, 0.0), 10.0); + const TopoDS_Shape aFace2 = MakeCircleFace(gp_Pnt(10.0, 0.0, 0.0), 10.0); + const TopoDS_Shape aFace3 = MakeCircleFace(gp_Pnt(10.0, 10.0, 0.0), 10.0); + + NCollection_List anArguments; + anArguments.Append(aFace1); + anArguments.Append(aFace2); + anArguments.Append(aFace3); + BOPAlgo_CellsBuilder aBuilder; + aBuilder.SetArguments(anArguments); + aBuilder.SetRunParallel(false); + aBuilder.Perform(); + ASSERT_FALSE(aBuilder.HasErrors()); + + AddToResult(aBuilder, aFace1, TopoDS_Shape(), TopoDS_Shape(), 1); + ExpectModified(aBuilder, aFace1, TopAbs_FACE, 4); + ExpectModified(aBuilder, aFace2, TopAbs_FACE, 2); + ExpectModified(aBuilder, aFace3, TopAbs_FACE, 2); + aBuilder.RemoveInternalBoundaries(); + ExpectModified(aBuilder, aFace1, TopAbs_FACE, 1); + ExpectModified(aBuilder, aFace2, TopAbs_FACE, 1); + ExpectModified(aBuilder, aFace3, TopAbs_FACE, 1); + + aBuilder.RemoveAllFromResult(); + AddToResult(aBuilder, aFace1, TopoDS_Shape(), aFace3, 1); + AddToResult(aBuilder, aFace2, TopoDS_Shape(), aFace3, 1); + ExpectModified(aBuilder, aFace1, TopAbs_FACE, 2); + ExpectModified(aBuilder, aFace2, TopAbs_FACE, 2); + EXPECT_TRUE(aBuilder.IsDeleted(aFace3)); + aBuilder.RemoveInternalBoundaries(); + ExpectModified(aBuilder, aFace1, TopAbs_FACE, 1); + ExpectModified(aBuilder, aFace2, TopAbs_FACE, 1); + + aBuilder.RemoveAllFromResult(); + AddToResult(aBuilder, aFace1, TopoDS_Shape(), TopoDS_Shape(), 1); + AddToResult(aBuilder, aFace2, TopoDS_Shape(), aFace1, 2); + AddToResult(aBuilder, aFace3, TopoDS_Shape(), aFace1, 2); + ExpectModified(aBuilder, aFace1, TopAbs_FACE, 4); + ExpectModified(aBuilder, aFace2, TopAbs_FACE, 4); + ExpectModified(aBuilder, aFace3, TopAbs_FACE, 4); + aBuilder.RemoveInternalBoundaries(); + ExpectModified(aBuilder, aFace1, TopAbs_FACE, 1); + ExpectModified(aBuilder, aFace2, TopAbs_FACE, 2); + ExpectModified(aBuilder, aFace3, TopAbs_FACE, 2); +} + +// Equivalent to tests/boolean/history/A6. +TEST(BOPAlgo_CellsBuilderTest, A6_BoxCellsHistory) +{ + const TopoDS_Shape aBox1 = BRepPrimAPI_MakeBox(10.0, 10.0, 10.0).Shape(); + const TopoDS_Shape aBox2 = BRepPrimAPI_MakeBox(gp_Pnt(5.0, 0.0, 0.0), 10.0, 10.0, 10.0).Shape(); + const TopoDS_Shape aBox3 = BRepPrimAPI_MakeBox(gp_Pnt(2.5, 0.0, 5.0), 10.0, 10.0, 10.0).Shape(); + + NCollection_List anArguments; + anArguments.Append(aBox1); + anArguments.Append(aBox2); + anArguments.Append(aBox3); + BOPAlgo_CellsBuilder aBuilder; + aBuilder.SetArguments(anArguments); + aBuilder.SetRunParallel(false); + aBuilder.Perform(); + ASSERT_FALSE(aBuilder.HasErrors()); + + AddToResult(aBuilder, aBox1, TopoDS_Shape(), TopoDS_Shape(), 1); + ExpectModified(aBuilder, aBox1, TopAbs_SOLID, 4); + ExpectModified(aBuilder, aBox2, TopAbs_SOLID, 2); + ExpectModified(aBuilder, aBox3, TopAbs_SOLID, 2); + aBuilder.RemoveInternalBoundaries(); + ExpectModified(aBuilder, aBox1, TopAbs_SOLID, 1); + ExpectModified(aBuilder, aBox2, TopAbs_SOLID, 1); + ExpectModified(aBuilder, aBox3, TopAbs_SOLID, 1); + + aBuilder.RemoveAllFromResult(); + AddToResult(aBuilder, aBox1, TopoDS_Shape(), aBox3, 1); + AddToResult(aBuilder, aBox2, TopoDS_Shape(), aBox3, 1); + ExpectModified(aBuilder, aBox1, TopAbs_SOLID, 2); + ExpectModified(aBuilder, aBox2, TopAbs_SOLID, 2); + EXPECT_TRUE(aBuilder.IsDeleted(aBox3)); + aBuilder.RemoveInternalBoundaries(); + ExpectModified(aBuilder, aBox1, TopAbs_SOLID, 1); + ExpectModified(aBuilder, aBox2, TopAbs_SOLID, 1); + + aBuilder.RemoveAllFromResult(); + AddToResult(aBuilder, aBox1, TopoDS_Shape(), TopoDS_Shape(), 1); + AddToResult(aBuilder, aBox2, TopoDS_Shape(), aBox1, 2); + AddToResult(aBuilder, aBox3, TopoDS_Shape(), aBox1, 2); + ExpectModified(aBuilder, aBox1, TopAbs_SOLID, 4); + ExpectModified(aBuilder, aBox2, TopAbs_SOLID, 4); + ExpectModified(aBuilder, aBox3, TopAbs_SOLID, 4); + aBuilder.RemoveInternalBoundaries(); + ExpectModified(aBuilder, aBox1, TopAbs_SOLID, 1); + ExpectModified(aBuilder, aBox2, TopAbs_SOLID, 2); + ExpectModified(aBuilder, aBox3, TopAbs_SOLID, 2); +} diff --git a/src/ModelingAlgorithms/TKBO/GTests/BOPAlgo_MakePeriodic_Test.cxx b/src/ModelingAlgorithms/TKBO/GTests/BOPAlgo_MakePeriodic_Test.cxx new file mode 100644 index 0000000000..cc63b97d24 --- /dev/null +++ b/src/ModelingAlgorithms/TKBO/GTests/BOPAlgo_MakePeriodic_Test.cxx @@ -0,0 +1,998 @@ +// Copyright (c) 2026 OPEN CASCADE SAS +// +// This file is part of Open CASCADE Technology software library. +// +// This library is free software; you can redistribute it and/or modify it under +// the terms of the GNU Lesser General Public License version 2.1 as published +// by the Free Software Foundation, with special exception defined in the file +// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT +// distribution for complete text of the license and disclaimer of any warranty. +// +// Alternatively, this file may be used under the terms of Open CASCADE +// commercial license or contractual agreement. + +#include "BOPTest_Utilities.pxx" + +#include +#include + +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace +{ +int CountShapes(const TopoDS_Shape& theShape, const TopAbs_ShapeEnum theType) +{ + NCollection_IndexedMap aMap; + TopExp::MapShapes(theShape, aMap); + + int aCount = 0; + for (int anIndex = 1; anIndex <= aMap.Extent(); ++anIndex) + { + if (aMap(anIndex).ShapeType() == theType) + { + ++aCount; + } + } + return aCount; +} + +int CountShapes(const NCollection_List& theShapes, const TopAbs_ShapeEnum theType) +{ + NCollection_IndexedMap aMap; + for (NCollection_List::Iterator anIterator(theShapes); anIterator.More(); + anIterator.Next()) + { + TopExp::MapShapes(anIterator.Value(), aMap); + } + + int aCount = 0; + for (int anIndex = 1; anIndex <= aMap.Extent(); ++anIndex) + { + if (aMap(anIndex).ShapeType() == theType) + { + ++aCount; + } + } + return aCount; +} + +TopoDS_Compound MakeCompound(const NCollection_List& theShapes) +{ + BRep_Builder aBuilder; + TopoDS_Compound aCompound; + aBuilder.MakeCompound(aCompound); + for (NCollection_List::Iterator anIterator(theShapes); anIterator.More(); + anIterator.Next()) + { + aBuilder.Add(aCompound, anIterator.Value()); + } + return aCompound; +} + +void ExpectShapeCounts(const TopoDS_Shape& theShape, + const int theVertices, + const int theEdges, + const int theWires, + const int theFaces, + const int theShells, + const int theSolids) +{ + EXPECT_FALSE(theShape.IsNull()); + if (theShape.IsNull()) + { + return; + } + EXPECT_TRUE(BRepCheck_Analyzer(theShape, true, false, false).IsValid()); + EXPECT_EQ(CountShapes(theShape, TopAbs_VERTEX), theVertices); + EXPECT_EQ(CountShapes(theShape, TopAbs_EDGE), theEdges); + EXPECT_EQ(CountShapes(theShape, TopAbs_WIRE), theWires); + EXPECT_EQ(CountShapes(theShape, TopAbs_FACE), theFaces); + EXPECT_EQ(CountShapes(theShape, TopAbs_SHELL), theShells); + EXPECT_EQ(CountShapes(theShape, TopAbs_SOLID), theSolids); +} + +void ExpectWireFaceShellSolidCounts(const TopoDS_Shape& theShape, + const int theWires, + const int theFaces, + const int theShells, + const int theSolids) +{ + EXPECT_FALSE(theShape.IsNull()); + if (theShape.IsNull()) + { + return; + } + EXPECT_TRUE(BRepCheck_Analyzer(theShape, true, false, false).IsValid()); + EXPECT_EQ(CountShapes(theShape, TopAbs_WIRE), theWires); + EXPECT_EQ(CountShapes(theShape, TopAbs_FACE), theFaces); + EXPECT_EQ(CountShapes(theShape, TopAbs_SHELL), theShells); + EXPECT_EQ(CountShapes(theShape, TopAbs_SOLID), theSolids); +} + +void ExpectValidShape(const TopoDS_Shape& theShape) +{ + EXPECT_FALSE(theShape.IsNull()); + if (!theShape.IsNull()) + { + EXPECT_TRUE(BRepCheck_Analyzer(theShape, true, false, false).IsValid()); + } +} + +void ExpectMaterials(const NCollection_List& theActual, + const TopoDS_Shape& theExpected1, + const TopoDS_Shape& theExpected2 = TopoDS_Shape()) +{ + const int anExpectedExtent = theExpected2.IsNull() ? 1 : 2; + EXPECT_EQ(theActual.Extent(), anExpectedExtent); + for (NCollection_List::Iterator anIterator(theActual); anIterator.More(); + anIterator.Next()) + { + const bool isExpected = anIterator.Value().IsSame(theExpected1) + || (!theExpected2.IsNull() && anIterator.Value().IsSame(theExpected2)); + EXPECT_TRUE(isExpected); + } +} + +void ExpectEqualProperties(const TopoDS_Shape& theFirst, + const TopoDS_Shape& theSecond, + const bool theSkipShared) +{ + GProp_GProps aFirstProperties; + GProp_GProps aSecondProperties; + BRepGProp::LinearProperties(theFirst, aFirstProperties, theSkipShared); + BRepGProp::LinearProperties(theSecond, aSecondProperties, theSkipShared); + EXPECT_NEAR(aFirstProperties.Mass(), + aSecondProperties.Mass(), + 1.0e-6 * std::max(1.0, std::abs(aSecondProperties.Mass()))); + + aFirstProperties = GProp_GProps(); + aSecondProperties = GProp_GProps(); + BRepGProp::SurfaceProperties(theFirst, aFirstProperties, 1.0, theSkipShared); + BRepGProp::SurfaceProperties(theSecond, aSecondProperties, 1.0, theSkipShared); + EXPECT_NEAR(aFirstProperties.Mass(), + aSecondProperties.Mass(), + 1.0e-6 * std::max(1.0, std::abs(aSecondProperties.Mass()))); + + aFirstProperties = GProp_GProps(); + aSecondProperties = GProp_GProps(); + BRepGProp::VolumeProperties(theFirst, aFirstProperties, 1.0, false, theSkipShared); + BRepGProp::VolumeProperties(theSecond, aSecondProperties, 1.0, false, theSkipShared); + EXPECT_NEAR(aFirstProperties.Mass(), + aSecondProperties.Mass(), + 1.0e-6 * std::max(1.0, std::abs(aSecondProperties.Mass()))); +} + +NCollection_List GetFaces(const TopoDS_Shape& theShape); + +void ExpectModifiedMaterials(BOPAlgo_MakeConnected& theConnected, + const NCollection_List& theModified, + const TopoDS_Shape& thePositive1, + const TopoDS_Shape& thePositive2, + const TopoDS_Shape& theNegative1, + const TopoDS_Shape& theNegative2 = TopoDS_Shape()) +{ + const TopoDS_Shape aModifiedShape = MakeCompound(theModified); + const NCollection_List aModifiedFaces = GetFaces(aModifiedShape); + ASSERT_FALSE(aModifiedFaces.IsEmpty()); + + bool hasPositiveMaterials = false; + bool hasNegativeMaterials = false; + for (NCollection_List::Iterator anIterator(aModifiedFaces); anIterator.More(); + anIterator.Next()) + { + const NCollection_List& aPositive = + theConnected.MaterialsOnPositiveSide(anIterator.Value()); + const NCollection_List& aNegative = + theConnected.MaterialsOnNegativeSide(anIterator.Value()); + if (!aPositive.IsEmpty()) + { + hasPositiveMaterials = true; + ExpectMaterials(aPositive, thePositive1, thePositive2); + } + if (!aNegative.IsEmpty()) + { + hasNegativeMaterials = true; + ExpectMaterials(aNegative, theNegative1, theNegative2); + } + } + + EXPECT_TRUE(hasPositiveMaterials); + EXPECT_EQ(hasNegativeMaterials, !theNegative1.IsNull()); +} + +TopoDS_Shape MakePeriodicityProfile() +{ + BRepBuilderAPI_MakePolygon aPolygon; + aPolygon.Add(gp_Pnt(0.0, 0.0, 0.0)); + aPolygon.Add(gp_Pnt(10.0, 0.0, 0.0)); + aPolygon.Add(gp_Pnt(10.0, 0.0, 10.0)); + aPolygon.Add(gp_Pnt(5.0, 0.0, 10.0)); + aPolygon.Add(gp_Pnt(5.0, 0.0, 5.0)); + aPolygon.Add(gp_Pnt(0.0, 0.0, 5.0)); + aPolygon.Close(); + + const TopoDS_Face aFace = BRepBuilderAPI_MakeFace(aPolygon.Wire()); + return BRepPrimAPI_MakePrism(aFace, gp_Vec(0.0, 5.0, 0.0)).Shape(); +} + +NCollection_List GetFaces(const TopoDS_Shape& theShape) +{ + NCollection_List aFaces; + NCollection_Map aMap; + aMap.Add(theShape); + for (TopExp_Explorer anExplorer(theShape, TopAbs_FACE); anExplorer.More(); anExplorer.Next()) + { + if (aMap.Add(anExplorer.Current())) + { + aFaces.Append(TopoDS::Face(anExplorer.Current())); + } + } + return aFaces; +} + +NCollection_List GetEdges(const TopoDS_Shape& theShape) +{ + NCollection_List anEdges; + NCollection_Map aMap; + aMap.Add(theShape); + for (TopExp_Explorer anExplorer(theShape, TopAbs_EDGE); anExplorer.More(); anExplorer.Next()) + { + if (aMap.Add(anExplorer.Current())) + { + anEdges.Append(TopoDS::Edge(anExplorer.Current())); + } + } + return anEdges; +} + +TopoDS_Face GetFace(const TopoDS_Shape& theShape, const int theIndex) +{ + int anIndex = 0; + for (TopExp_Explorer anExplorer(theShape, TopAbs_FACE); anExplorer.More(); anExplorer.Next()) + { + if (anIndex++ == theIndex) + { + return TopoDS::Face(anExplorer.Current()); + } + } + return TopoDS_Face(); +} + +occ::handle BasisCurve(const TopoDS_Edge& theEdge) +{ + double aFirst = 0.0; + double aLast = 0.0; + occ::handle aCurve = BRep_Tool::Curve(theEdge, aFirst, aLast); + while (!aCurve.IsNull()) + { + const occ::handle aTrimmed = occ::down_cast(aCurve); + if (aTrimmed.IsNull()) + { + break; + } + aCurve = aTrimmed->BasisCurve(); + } + return aCurve; +} + +const char* CurveTypeName(const TopoDS_Edge& theEdge) +{ + const occ::handle aCurve = BasisCurve(theEdge); + return aCurve.IsNull() ? nullptr : aCurve->DynamicType()->Name(); +} + +bool IsBSplineCurve(const TopoDS_Edge& theEdge) +{ + return !occ::down_cast(BasisCurve(theEdge)).IsNull(); +} + +occ::handle BasisSurface(const TopoDS_Face& theFace) +{ + occ::handle aSurface = BRep_Tool::Surface(theFace); + while (!aSurface.IsNull()) + { + const occ::handle aTrimmed = + occ::down_cast(aSurface); + if (aTrimmed.IsNull()) + { + break; + } + aSurface = aTrimmed->BasisSurface(); + } + return aSurface; +} + +const char* SurfaceTypeName(const TopoDS_Face& theFace) +{ + const occ::handle aSurface = BasisSurface(theFace); + return aSurface.IsNull() ? nullptr : aSurface->DynamicType()->Name(); +} + +bool IsBSplineSurface(const TopoDS_Face& theFace) +{ + return !occ::down_cast(BasisSurface(theFace)).IsNull(); +} + +occ::handle MakeVolume(BOPAlgo_MakerVolume& theMaker, + const TopoDS_Shape& theModifiedShape, + const NCollection_List& theFaces) +{ + NCollection_List anArguments; + anArguments.Append(theModifiedShape); + for (NCollection_List::Iterator anIterator(theFaces); anIterator.More(); + anIterator.Next()) + { + anArguments.Append(anIterator.Value()); + } + + theMaker.SetArguments(anArguments); + theMaker.SetToFillHistory(true); + theMaker.SetFuzzyValue(Precision::Confusion()); + theMaker.SetNonDestructive(false); + theMaker.SetIntersect(true); + theMaker.SetRunParallel(false); + theMaker.Perform(); + return new BRepTools_History(anArguments, theMaker); +} + +void MakeBoxPeriodic(BOPAlgo_MakePeriodic& theMaker, + const TopoDS_Shape& theShape, + const double theXPeriod, + const double theYPeriod, + const double theZPeriod, + const bool theIsInputTrimmedX = true, + const bool theIsInputTrimmedY = true, + const bool theIsInputTrimmedZ = true, + const double theXFirst = 0.0, + const double theYFirst = 0.0, + const double theZFirst = 0.0, + const bool theSetTrimmed = true) +{ + theMaker.SetShape(theShape); + theMaker.MakeXPeriodic(true, theXPeriod); + theMaker.MakeYPeriodic(true, theYPeriod); + theMaker.MakeZPeriodic(true, theZPeriod); + if (theSetTrimmed) + { + theMaker.SetTrimmed(0, theIsInputTrimmedX, theXFirst); + theMaker.SetTrimmed(1, theIsInputTrimmedY, theYFirst); + theMaker.SetTrimmed(2, theIsInputTrimmedZ, theZFirst); + } + theMaker.SetRunParallel(false); + theMaker.Perform(); +} + +BOPAlgo_MakePeriodic::PeriodicityParams MakeXYZPeriodicity(const double theXPeriod, + const double theYPeriod, + const double theZPeriod) +{ + BOPAlgo_MakePeriodic::PeriodicityParams aParams; + aParams.myPeriodic[0] = true; + aParams.myPeriodic[1] = true; + aParams.myPeriodic[2] = true; + aParams.myPeriod[0] = theXPeriod; + aParams.myPeriod[1] = theYPeriod; + aParams.myPeriod[2] = theZPeriod; + return aParams; +} + +void PerformConnected(BOPAlgo_MakeConnected& theConnected, + const NCollection_List& theArguments) +{ + theConnected.SetArguments(theArguments); + theConnected.SetRunParallel(false); + theConnected.Perform(); +} +} // namespace + +// Equivalent to tests/boolean/periodicity/A1. +TEST(BOPAlgo_MakePeriodicTest, A1_BoxWithTrimmedPeriodicity_RepeatsWithExpectedTopology) +{ + const TopoDS_Shape aBox = BRepPrimAPI_MakeBox(10.0, 10.0, 10.0).Shape(); + + BOPAlgo_MakePeriodic aMaker; + MakeBoxPeriodic(aMaker, aBox, 5.0, 8.0, 12.0, false, false, false, 2.0, 1.0, -1.0); + + ASSERT_FALSE(aMaker.HasErrors()); + const TopoDS_Shape& aPeriodicShape = aMaker.Shape(); + ASSERT_FALSE(aPeriodicShape.IsNull()); + ExpectShapeCounts(aPeriodicShape, 8, 12, 6, 6, 1, 1); + EXPECT_NEAR(BOPTest_Utilities::GetSurfaceArea(aPeriodicShape), 340.0, Precision::Confusion()); + EXPECT_NEAR(BOPTest_Utilities::GetVolume(aPeriodicShape), 400.0, Precision::Confusion()); + + aMaker.XRepeat(5); + aMaker.YRepeat(5); + aMaker.ZRepeat(5); + const TopoDS_Shape& aRepeatedShape = aMaker.RepeatedShape(); + ASSERT_FALSE(aRepeatedShape.IsNull()); + ExpectShapeCounts(aRepeatedShape, 588, 1302, 936, 936, 216, 216); + EXPECT_NEAR(BOPTest_Utilities::GetSurfaceArea(aRepeatedShape), 73440.0, Precision::Confusion()); + EXPECT_NEAR(BOPTest_Utilities::GetVolume(aRepeatedShape), 86400.0, Precision::Confusion()); +} + +// Equivalent to tests/boolean/periodicity/A2. +TEST(BOPAlgo_MakePeriodicTest, A2_ProfilePeriodicity_HistoryAndRepetitionAreConsistent) +{ + const TopoDS_Shape aShape = MakePeriodicityProfile(); + + BOPAlgo_MakePeriodic aMaker; + aMaker.SetShape(aShape); + aMaker.MakeXPeriodic(true, 10.0); + aMaker.MakeZPeriodic(true, 10.0); + aMaker.MakeYPeriodic(true, 5.0); + aMaker.SetRunParallel(false); + aMaker.Perform(); + + ASSERT_FALSE(aMaker.HasErrors()); + const TopoDS_Shape& aPeriodicShape = aMaker.Shape(); + ASSERT_FALSE(aPeriodicShape.IsNull()); + ExpectShapeCounts(aPeriodicShape, 16, 24, 10, 10, 1, 1); + EXPECT_NEAR(BOPTest_Utilities::GetSurfaceArea(aPeriodicShape), 350.0, Precision::Confusion()); + EXPECT_NEAR(BOPTest_Utilities::GetVolume(aPeriodicShape), 375.0, Precision::Confusion()); + ASSERT_FALSE(aMaker.History().IsNull()); + + const BRepTools_History& aHistory = *aMaker.History(); + const NCollection_List aFaces = GetFaces(aShape); + ASSERT_GE(aFaces.Extent(), 3); + + for (int anIndex = 0; anIndex < 2; ++anIndex) + { + const TopoDS_Face aFace = GetFace(aShape, anIndex); + ASSERT_FALSE(aFace.IsNull()); + const NCollection_List& aModified = aHistory.Modified(aFace); + EXPECT_EQ(CountShapes(aModified, TopAbs_VERTEX), 6); + EXPECT_EQ(CountShapes(aModified, TopAbs_EDGE), 7); + EXPECT_EQ(CountShapes(aModified, TopAbs_WIRE), 2); + EXPECT_EQ(CountShapes(aModified, TopAbs_FACE), 2); + + const TopoDS_Shape aModifiedShape = MakeCompound(aModified); + const NCollection_List aModifiedFaces = GetFaces(aModifiedShape); + ASSERT_EQ(aModifiedFaces.Extent(), 2); + NCollection_List aTwins; + for (NCollection_List::Iterator anIterator(aModifiedFaces); anIterator.More(); + anIterator.Next()) + { + const NCollection_List& aFaceTwins = aMaker.GetTwins(anIterator.Value()); + for (NCollection_List::Iterator aTwinIterator(aFaceTwins); aTwinIterator.More(); + aTwinIterator.Next()) + { + aTwins.Append(aTwinIterator.Value()); + } + } + EXPECT_EQ(CountShapes(aTwins, TopAbs_FACE), 1); + } + + aMaker.XRepeat(1); + aMaker.YRepeat(2); + const TopoDS_Shape& aRepeatedShape = aMaker.RepeatedShape(); + ASSERT_FALSE(aRepeatedShape.IsNull()); + ExpectShapeCounts(aRepeatedShape, 56, 102, 53, 53, 6, 6); + EXPECT_NEAR(BOPTest_Utilities::GetSurfaceArea(aRepeatedShape), 2100.0, Precision::Confusion()); + EXPECT_NEAR(BOPTest_Utilities::GetVolume(aRepeatedShape), 2250.0, Precision::Confusion()); + + const TopoDS_Face aBottomFace = GetFace(aShape, 0); + const TopoDS_Face aTopFace = GetFace(aShape, 2); + ASSERT_FALSE(aBottomFace.IsNull()); + ASSERT_FALSE(aTopFace.IsNull()); + const NCollection_List& aBottomGenerated = aHistory.Generated(aBottomFace); + EXPECT_EQ(CountShapes(aBottomGenerated, TopAbs_VERTEX), 20); + EXPECT_EQ(CountShapes(aBottomGenerated, TopAbs_EDGE), 31); + EXPECT_EQ(CountShapes(aBottomGenerated, TopAbs_WIRE), 12); + EXPECT_EQ(CountShapes(aBottomGenerated, TopAbs_FACE), 12); + const TopoDS_Shape aBottomGeneratedShape = MakeCompound(aBottomGenerated); + EXPECT_NEAR(BOPTest_Utilities::GetSurfaceArea(aBottomGeneratedShape), + 300.0, + Precision::Confusion()); + ExpectValidShape(aBottomGeneratedShape); + + const NCollection_List& aTopGenerated = aHistory.Generated(aTopFace); + EXPECT_EQ(CountShapes(aTopGenerated, TopAbs_VERTEX), 16); + EXPECT_EQ(CountShapes(aTopGenerated, TopAbs_EDGE), 20); + EXPECT_EQ(CountShapes(aTopGenerated, TopAbs_WIRE), 6); + EXPECT_EQ(CountShapes(aTopGenerated, TopAbs_FACE), 6); + const TopoDS_Shape aTopGeneratedShape = MakeCompound(aTopGenerated); + EXPECT_NEAR(BOPTest_Utilities::GetSurfaceArea(aTopGeneratedShape), 150.0, Precision::Confusion()); + ExpectValidShape(aTopGeneratedShape); + + for (NCollection_List::Iterator anIterator(aTopGenerated); anIterator.More(); + anIterator.Next()) + { + const NCollection_List& aTwins = aMaker.GetTwins(anIterator.Value()); + EXPECT_EQ(CountShapes(aTwins, TopAbs_WIRE), 11); + EXPECT_EQ(CountShapes(aTwins, TopAbs_FACE), 11); + const TopoDS_Shape aTwinsShape = MakeCompound(aTwins); + EXPECT_NEAR(BOPTest_Utilities::GetSurfaceArea(aTwinsShape), 275.0, Precision::Confusion()); + ExpectValidShape(aTwinsShape); + } + + aMaker.ClearRepetitions(); + EXPECT_TRUE(aHistory.Generated(aBottomFace).IsEmpty()); +} + +// Equivalent to tests/boolean/periodicity/A3. +TEST(BOPAlgo_MakePeriodicTest, A3_PeriodicCylinderCut_RepeatedCutHasExpectedTopology) +{ + const TopoDS_Shape aBox = BOPTest_Utilities::CreateBox(gp_Pnt(0.0, 0.0, 0.0), 100.0, 100.0, 1.0); + const TopoDS_Shape aCylinder = + BOPTest_Utilities::Translate(BOPTest_Utilities::CreateCylinder(2.0, 2.0), 2.5, 2.5, 0.0); + + BOPAlgo_MakePeriodic aMaker; + aMaker.SetShape(aCylinder); + aMaker.MakeXPeriodic(true, 5.0); + aMaker.MakeYPeriodic(true, 5.0); + aMaker.SetXTrimmed(false, 0.0); + aMaker.SetYTrimmed(false, 0.0); + aMaker.SetRunParallel(false); + aMaker.Perform(); + ASSERT_FALSE(aMaker.HasErrors()); + aMaker.XRepeat(19); + aMaker.YRepeat(19); + + BRepAlgoAPI_Cut aCut(aBox, aMaker.RepeatedShape()); + ASSERT_TRUE(aCut.IsDone()); + const TopoDS_Shape& aResult = aCut.Shape(); + ASSERT_FALSE(aResult.IsNull()); + ExpectShapeCounts(aResult, 808, 1212, 1206, 406, 1, 1); + EXPECT_NEAR(BOPTest_Utilities::GetSurfaceArea(aResult), 15373.5, 15373.5 * 0.01); + EXPECT_NEAR(BOPTest_Utilities::GetVolume(aResult), 4973.45, 4973.45 * 0.01); +} + +// Equivalent to tests/boolean/periodicity/A4. +TEST(BOPAlgo_MakePeriodicTest, A4_PeriodicCutResult_RepeatsInBothDirections) +{ + const TopoDS_Shape aBox = BOPTest_Utilities::CreateBox(gp_Pnt(0.0, 0.0, 0.0), 5.0, 5.0, 1.0); + const TopoDS_Shape aCylinder = + BOPTest_Utilities::Translate(BOPTest_Utilities::CreateCylinder(2.0, 2.0), 2.5, 2.5, 0.0); + BRepAlgoAPI_Cut aCut(aBox, aCylinder); + ASSERT_TRUE(aCut.IsDone()); + + BOPAlgo_MakePeriodic aMaker; + aMaker.SetShape(aCut.Shape()); + aMaker.MakeXPeriodic(true, 5.0); + aMaker.MakeYPeriodic(true, 5.0); + aMaker.SetRunParallel(false); + aMaker.Perform(); + ASSERT_FALSE(aMaker.HasErrors()); + aMaker.XRepeat(-9); + aMaker.XRepeat(1); + aMaker.YRepeat(-9); + aMaker.YRepeat(1); + + const TopoDS_Shape& aResult = aMaker.RepeatedShape(); + ASSERT_FALSE(aResult.IsNull()); + ExpectShapeCounts(aResult, 1682, 3321, 2840, 2040, 400, 400); + EXPECT_NEAR(BOPTest_Utilities::GetSurfaceArea(aResult), 22973.5, 22973.5 * 0.01); + EXPECT_NEAR(BOPTest_Utilities::GetVolume(aResult), 4973.45, 4973.45 * 0.01); +} + +// Equivalent to tests/boolean/periodicity/A5. +TEST(BOPAlgo_MakePeriodicTest, A5_NurbsEdges_PeriodicTwinsPreserveCurveType) +{ + const TopoDS_Shape aBox = BRepPrimAPI_MakeBox(10.0, 10.0, 10.0).Shape(); + const NCollection_List aFaces = GetFaces(aBox); + const NCollection_List anEdges = GetEdges(aBox); + + for (NCollection_List::Iterator anEdgeIterator(anEdges); anEdgeIterator.More(); + anEdgeIterator.Next()) + { + const TopoDS_Edge& anEdge = anEdgeIterator.Value(); + BRepBuilderAPI_NurbsConvert aConverter; + aConverter.Perform(anEdge); + ASSERT_TRUE(aConverter.IsDone()); + const TopoDS_Shape aNurbsEdge = aConverter.Shape(); + ASSERT_FALSE(aNurbsEdge.IsNull()); + + BOPAlgo_MakerVolume aVolume; + const occ::handle aVolumeHistory = MakeVolume(aVolume, aNurbsEdge, aFaces); + ASSERT_FALSE(aVolume.HasErrors()); + const TopoDS_Shape& aSolid = aVolume.Shape(); + ASSERT_FALSE(aSolid.IsNull()); + ExpectValidShape(aSolid); + + const NCollection_List& aModified = aVolumeHistory->Modified(aNurbsEdge); + ASSERT_EQ(CountShapes(aModified, TopAbs_EDGE), 1); + const TopoDS_Edge aModifiedEdge = TopoDS::Edge(aModified.First()); + EXPECT_TRUE(IsBSplineCurve(aModifiedEdge)); + + BOPAlgo_MakePeriodic aMaker; + aMaker.Clear(); + MakeBoxPeriodic(aMaker, aSolid, 10.0, 10.0, 10.0, true, true, true, 0.0, 0.0, 0.0, false); + ASSERT_FALSE(aMaker.HasErrors()); + ASSERT_FALSE(aMaker.History().IsNull()); + + const NCollection_List& aPeriodicModified = + aMaker.History()->Modified(aModifiedEdge); + ASSERT_EQ(CountShapes(aPeriodicModified, TopAbs_EDGE), 1); + const TopoDS_Edge aPeriodicModifiedEdge = TopoDS::Edge(aPeriodicModified.First()); + const char* aPeriodicCurveType = CurveTypeName(aPeriodicModifiedEdge); + ASSERT_NE(aPeriodicCurveType, nullptr); + + const NCollection_List& aTwins = aMaker.GetTwins(aPeriodicModifiedEdge); + EXPECT_EQ(CountShapes(aTwins, TopAbs_EDGE), 2); + for (NCollection_List::Iterator anIterator(aTwins); anIterator.More(); + anIterator.Next()) + { + const char* aTwinCurveType = CurveTypeName(TopoDS::Edge(anIterator.Value())); + ASSERT_NE(aTwinCurveType, nullptr); + EXPECT_STREQ(aTwinCurveType, aPeriodicCurveType); + } + } +} + +// Equivalent to tests/boolean/periodicity/A6. +TEST(BOPAlgo_MakePeriodicTest, A6_NurbsFaces_PeriodicTwinsPreserveGeometryTypes) +{ + const TopoDS_Shape aBox = BRepPrimAPI_MakeBox(10.0, 10.0, 10.0).Shape(); + const NCollection_List aFaces = GetFaces(aBox); + + for (NCollection_List::Iterator aFaceIterator(aFaces); aFaceIterator.More(); + aFaceIterator.Next()) + { + const TopoDS_Face& aFace = aFaceIterator.Value(); + BRepBuilderAPI_NurbsConvert aConverter; + aConverter.Perform(aFace); + ASSERT_TRUE(aConverter.IsDone()); + const TopoDS_Shape aNurbsFace = aConverter.Shape(); + ASSERT_FALSE(aNurbsFace.IsNull()); + + BOPAlgo_MakerVolume aVolume; + const occ::handle aVolumeHistory = MakeVolume(aVolume, aNurbsFace, aFaces); + ASSERT_FALSE(aVolume.HasErrors()); + const TopoDS_Shape& aSolid = aVolume.Shape(); + ASSERT_FALSE(aSolid.IsNull()); + ExpectValidShape(aSolid); + + const NCollection_List& aModified = aVolumeHistory->Modified(aNurbsFace); + ASSERT_EQ(CountShapes(aModified, TopAbs_FACE), 1); + const TopoDS_Face aModifiedFace = TopoDS::Face(aModified.First()); + EXPECT_TRUE(IsBSplineSurface(aModifiedFace)); + + BOPAlgo_MakePeriodic aMaker; + MakeBoxPeriodic(aMaker, aSolid, 10.0, 10.0, 10.0, true, true, true, 0.0, 0.0, 0.0, false); + ASSERT_FALSE(aMaker.HasErrors()); + ASSERT_FALSE(aMaker.History().IsNull()); + + const NCollection_List& aPeriodicModified = + aMaker.History()->Modified(aModifiedFace); + ASSERT_EQ(CountShapes(aPeriodicModified, TopAbs_FACE), 1); + const TopoDS_Face aPeriodicModifiedFace = TopoDS::Face(aPeriodicModified.First()); + const char* aPeriodicSurfaceType = SurfaceTypeName(aPeriodicModifiedFace); + ASSERT_NE(aPeriodicSurfaceType, nullptr); + + const NCollection_List& aFaceTwins = aMaker.GetTwins(aPeriodicModifiedFace); + EXPECT_EQ(CountShapes(aFaceTwins, TopAbs_FACE), 1); + for (NCollection_List::Iterator anIterator(aFaceTwins); anIterator.More(); + anIterator.Next()) + { + const char* aTwinSurfaceType = SurfaceTypeName(TopoDS::Face(anIterator.Value())); + ASSERT_NE(aTwinSurfaceType, nullptr); + EXPECT_STREQ(aTwinSurfaceType, aPeriodicSurfaceType); + } + + const NCollection_List aModifiedEdges = GetEdges(aPeriodicModifiedFace); + for (NCollection_List::Iterator anEdgeIterator(aModifiedEdges); + anEdgeIterator.More(); + anEdgeIterator.Next()) + { + const TopoDS_Edge& aModifiedEdge = anEdgeIterator.Value(); + const char* aModifiedCurveType = CurveTypeName(aModifiedEdge); + ASSERT_NE(aModifiedCurveType, nullptr); + const NCollection_List& anEdgeTwins = aMaker.GetTwins(aModifiedEdge); + EXPECT_EQ(CountShapes(anEdgeTwins, TopAbs_EDGE), 2); + for (NCollection_List::Iterator anIterator(anEdgeTwins); anIterator.More(); + anIterator.Next()) + { + const char* aTwinCurveType = CurveTypeName(TopoDS::Edge(anIterator.Value())); + ASSERT_NE(aTwinCurveType, nullptr); + EXPECT_STREQ(aTwinCurveType, aModifiedCurveType); + } + } + } +} + +// Equivalent to tests/boolean/mkconnected/A1. +TEST(BOPAlgo_MakePeriodicTest, MakeConnected_A1_PeriodicConnectedSolids) +{ + const TopoDS_Shape aProfile = MakePeriodicityProfile(); + const TopoDS_Shape aBox1 = aProfile; + const TopoDS_Shape aBox2 = BRepPrimAPI_MakeBox(gp_Pnt(0.0, 0.0, 5.0), 5.0, 5.0, 5.0).Shape(); + const TopoDS_Shape aBox3 = BRepPrimAPI_MakeBox(gp_Pnt(0.0, 5.0, 0.0), 10.0, 5.0, 10.0).Shape(); + + NCollection_List anArguments; + anArguments.Append(aBox3); + anArguments.Append(aBox1); + anArguments.Append(aBox2); + BOPAlgo_MakeConnected aConnected; + PerformConnected(aConnected, anArguments); + ASSERT_FALSE(aConnected.HasErrors()); + ExpectShapeCounts(aConnected.Shape(), 18, 31, 17, 17, 3, 3); + EXPECT_NEAR(BOPTest_Utilities::GetSurfaceArea(aConnected.Shape()), 900.0, Precision::Confusion()); + EXPECT_NEAR(BOPTest_Utilities::GetVolume(aConnected.Shape()), 1000.0, Precision::Confusion()); + ASSERT_FALSE(aConnected.History().IsNull()); + EXPECT_EQ(CountShapes(aConnected.GetModified(aBox3), TopAbs_FACE), 7); + + aConnected.MakePeriodic(MakeXYZPeriodicity(10.0, 10.0, 10.0)); + ASSERT_FALSE(aConnected.PeriodicityTool().HasErrors()); + ExpectShapeCounts(aConnected.PeriodicShape(), 26, 42, 20, 20, 3, 3); + EXPECT_EQ(CountShapes(aConnected.GetModified(aBox1), TopAbs_FACE), 10); + EXPECT_EQ(CountShapes(aConnected.GetModified(aBox2), TopAbs_VERTEX), + CountShapes(aBox2, TopAbs_VERTEX)); + EXPECT_EQ(CountShapes(aConnected.GetModified(aBox3), TopAbs_FACE), 8); + + const TopoDS_Face aMaterialFace = GetFace(aBox3, 2); + ASSERT_FALSE(aMaterialFace.IsNull()); + const TopoDS_Shape aModifiedMaterialShape = MakeCompound(aConnected.GetModified(aMaterialFace)); + const NCollection_List aModifiedMaterialFaces = GetFaces(aModifiedMaterialShape); + ASSERT_FALSE(aModifiedMaterialFaces.IsEmpty()); + NCollection_List aPositiveMaterials; + NCollection_List aNegativeMaterials; + for (NCollection_List::Iterator anIterator(aModifiedMaterialFaces); + anIterator.More(); + anIterator.Next()) + { + const NCollection_List& aPositive = + aConnected.MaterialsOnPositiveSide(anIterator.Value()); + for (NCollection_List::Iterator aMaterialIterator(aPositive); + aMaterialIterator.More(); + aMaterialIterator.Next()) + { + aPositiveMaterials.Append(aMaterialIterator.Value()); + } + + const NCollection_List& aNegative = + aConnected.MaterialsOnNegativeSide(anIterator.Value()); + for (NCollection_List::Iterator aMaterialIterator(aNegative); + aMaterialIterator.More(); + aMaterialIterator.Next()) + { + aNegativeMaterials.Append(aMaterialIterator.Value()); + } + } + ASSERT_FALSE(aPositiveMaterials.IsEmpty()); + ASSERT_FALSE(aNegativeMaterials.IsEmpty()); + NCollection_List anExpectedPositiveMaterials; + anExpectedPositiveMaterials.Append(aBox1); + anExpectedPositiveMaterials.Append(aBox2); + NCollection_List anExpectedNegativeMaterials; + anExpectedNegativeMaterials.Append(aBox3); + ExpectEqualProperties(MakeCompound(aPositiveMaterials), + MakeCompound(anExpectedPositiveMaterials), + true); + ExpectEqualProperties(MakeCompound(aNegativeMaterials), + MakeCompound(anExpectedNegativeMaterials), + true); +} + +// Equivalent to tests/boolean/mkconnected/A2. +TEST(BOPAlgo_MakePeriodicTest, MakeConnected_A2_PeriodicAndRepeatedConnectedSolids) +{ + BRepBuilderAPI_MakePolygon aPolygon; + aPolygon.Add(gp_Pnt(3.0, 0.0, 6.0)); + aPolygon.Add(gp_Pnt(3.0, 3.0, 6.0)); + aPolygon.Add(gp_Pnt(0.0, 3.0, 6.0)); + aPolygon.Add(gp_Pnt(0.0, 4.0, 6.0)); + aPolygon.Add(gp_Pnt(4.0, 4.0, 6.0)); + aPolygon.Add(gp_Pnt(4.0, 0.0, 6.0)); + aPolygon.Close(); + const TopoDS_Shape aPrism = + BRepPrimAPI_MakePrism(BRepBuilderAPI_MakeFace(aPolygon.Wire()).Face(), gp_Vec(0.0, 0.0, 4.0)) + .Shape(); + + const TopoDS_Shape aBox1 = BRepPrimAPI_MakeBox(10.0, 10.0, 5.0).Shape(); + const TopoDS_Shape aBox2 = BRepPrimAPI_MakeBox(gp_Pnt(0.0, 0.0, 5.0), 10.0, 10.0, 1.0).Shape(); + const TopoDS_Shape aBox3 = BRepPrimAPI_MakeBox(gp_Pnt(0.0, 0.0, 6.0), 3.0, 3.0, 4.0).Shape(); + NCollection_List anArguments; + anArguments.Append(aBox1); + anArguments.Append(aBox2); + anArguments.Append(aBox3); + anArguments.Append(aPrism); + const TopoDS_Shape aBox5 = BRepPrimAPI_MakeBox(gp_Pnt(0.0, 9.0, 6.0), 4.0, 1.0, 4.0).Shape(); + const TopoDS_Shape aBox6 = BRepPrimAPI_MakeBox(gp_Pnt(9.0, 9.0, 6.0), 1.0, 1.0, 4.0).Shape(); + const TopoDS_Shape aBox7 = BRepPrimAPI_MakeBox(gp_Pnt(9.0, 0.0, 6.0), 1.0, 3.0, 4.0).Shape(); + anArguments.Append(aBox5); + anArguments.Append(aBox6); + anArguments.Append(aBox7); + + BOPAlgo_MakeConnected aConnected; + PerformConnected(aConnected, anArguments); + ASSERT_FALSE(aConnected.HasErrors()); + ExpectShapeCounts(aConnected.Shape(), 46, 79, 41, 41, 7, 7); + EXPECT_NEAR(BOPTest_Utilities::GetSurfaceArea(aConnected.Shape()), 888.0, Precision::Confusion()); + EXPECT_NEAR(BOPTest_Utilities::GetVolume(aConnected.Shape()), 696.0, Precision::Confusion()); + + BOPAlgo_MakePeriodic::PeriodicityParams aParams; + aParams.myPeriodic[0] = true; + aParams.myPeriodic[1] = true; + aParams.myPeriod[0] = 10.0; + aParams.myPeriod[1] = 10.0; + aConnected.MakePeriodic(aParams); + ASSERT_FALSE(aConnected.PeriodicityTool().HasErrors()); + ExpectShapeCounts(aConnected.PeriodicShape(), 49, 83, 42, 42, 7, 7); + EXPECT_NEAR(BOPTest_Utilities::GetSurfaceArea(aConnected.PeriodicShape()), + 888.0, + Precision::Confusion()); + EXPECT_NEAR(BOPTest_Utilities::GetVolume(aConnected.PeriodicShape()), + 696.0, + Precision::Confusion()); + + const TopoDS_Face aMaterialFace = GetFace(aBox6, 3); + ASSERT_FALSE(aMaterialFace.IsNull()); + ExpectModifiedMaterials(aConnected, + aConnected.GetModified(aMaterialFace), + aBox6, + TopoDS_Shape(), + TopoDS_Shape()); + + ASSERT_FALSE(aConnected.History().IsNull()); + const TopoDS_Shape aModifiedBox5 = MakeCompound(aConnected.GetModified(aBox5)); + ExpectShapeCounts(aModifiedBox5, 10, 15, 7, 7, 1, 1); + EXPECT_NEAR(BOPTest_Utilities::GetSurfaceArea(aModifiedBox5), 48.0, Precision::Confusion()); + EXPECT_NEAR(BOPTest_Utilities::GetVolume(aModifiedBox5), 16.0, Precision::Confusion()); + + aConnected.RepeatShape(0, -1); + aConnected.RepeatShape(0, 1); + aConnected.RepeatShape(1, -1); + aConnected.RepeatShape(1, 1); + ExpectShapeCounts(aConnected.PeriodicShape(), 496, 947, 564, 564, 112, 112); + EXPECT_NEAR(BOPTest_Utilities::GetSurfaceArea(aConnected.PeriodicShape()), + 14208.0, + Precision::Confusion()); + EXPECT_NEAR(BOPTest_Utilities::GetVolume(aConnected.PeriodicShape()), + 11136.0, + Precision::Confusion()); + ExpectModifiedMaterials(aConnected, + aConnected.GetModified(aMaterialFace), + aBox6, + TopoDS_Shape(), + aBox7); + + aParams.Clear(); + aParams.myPeriodic[0] = true; + aParams.myPeriodic[1] = true; + aParams.myPeriod[0] = 12.0; + aParams.myPeriod[1] = 12.0; + aParams.myIsTrimmed[0] = false; + aParams.myIsTrimmed[1] = false; + aParams.myPeriodFirst[0] = -1.0; + aParams.myPeriodFirst[1] = -1.0; + aConnected.MakePeriodic(aParams); + ASSERT_FALSE(aConnected.PeriodicityTool().HasErrors()); + ExpectShapeCounts(aConnected.PeriodicShape(), 46, 79, 41, 41, 7, 7); + ExpectEqualProperties(aConnected.Shape(), aConnected.PeriodicShape(), true); + aConnected.RepeatShape(0, -1); + aConnected.RepeatShape(0, 1); + aConnected.RepeatShape(1, -1); + aConnected.RepeatShape(1, 1); + ExpectShapeCounts(aConnected.PeriodicShape(), 736, 1264, 656, 656, 112, 112); + EXPECT_NEAR(BOPTest_Utilities::GetSurfaceArea(aConnected.PeriodicShape()), + 14208.0, + Precision::Confusion()); + EXPECT_NEAR(BOPTest_Utilities::GetVolume(aConnected.PeriodicShape()), + 11136.0, + Precision::Confusion()); + ExpectModifiedMaterials(aConnected, + aConnected.GetModified(aMaterialFace), + aBox6, + TopoDS_Shape(), + TopoDS_Shape()); +} + +// Equivalent to tests/boolean/mkconnected/A5. +TEST(BOPAlgo_MakePeriodicTest, MakeConnected_A5_PeriodicRepetitionCanBeCleared) +{ + const TopoDS_Shape aBox1 = BRepPrimAPI_MakeBox(5.0, 5.0, 10.0).Shape(); + const TopoDS_Shape aBox2 = BRepPrimAPI_MakeBox(gp_Pnt(5.0, 0.0, 0.0), 5.0, 5.0, 5.0).Shape(); + const TopoDS_Shape aBox3 = BRepPrimAPI_MakeBox(gp_Pnt(0.0, 5.0, 0.0), 5.0, 5.0, 5.0).Shape(); + NCollection_List anArguments; + anArguments.Append(aBox1); + anArguments.Append(aBox2); + anArguments.Append(aBox3); + + BOPAlgo_MakeConnected aConnected; + PerformConnected(aConnected, anArguments); + ASSERT_FALSE(aConnected.HasErrors()); + ExpectValidShape(aConnected.Shape()); + EXPECT_EQ(CountShapes(aConnected.Shape(), TopAbs_WIRE), 18); + EXPECT_EQ(CountShapes(aConnected.Shape(), TopAbs_FACE), 18); + EXPECT_EQ(CountShapes(aConnected.Shape(), TopAbs_SHELL), 3); + EXPECT_EQ(CountShapes(aConnected.Shape(), TopAbs_SOLID), 3); + + const TopoDS_Face aMaterialFace = GetFace(aBox2, 1); + ASSERT_FALSE(aMaterialFace.IsNull()); + + BOPAlgo_MakePeriodic::PeriodicityParams aParams; + aParams.myPeriodic[0] = true; + aParams.myPeriodic[1] = true; + aParams.myPeriod[0] = 10.0; + aParams.myPeriod[1] = 10.0; + aConnected.MakePeriodic(aParams); + ASSERT_FALSE(aConnected.PeriodicityTool().HasErrors()); + ExpectValidShape(aConnected.PeriodicShape()); + EXPECT_EQ(CountShapes(aConnected.PeriodicShape(), TopAbs_WIRE), 20); + EXPECT_EQ(CountShapes(aConnected.PeriodicShape(), TopAbs_FACE), 20); + EXPECT_EQ(CountShapes(aConnected.PeriodicShape(), TopAbs_SHELL), 3); + EXPECT_EQ(CountShapes(aConnected.PeriodicShape(), TopAbs_SOLID), 3); + + const NCollection_List& aModifiedMaterial = aConnected.GetModified(aMaterialFace); + const TopoDS_Shape aModifiedMaterialShape = MakeCompound(aModifiedMaterial); + const NCollection_List aModifiedMaterialFaces = GetFaces(aModifiedMaterialShape); + ASSERT_FALSE(aModifiedMaterialFaces.IsEmpty()); + const TopoDS_Face& aModifiedFace = aModifiedMaterialFaces.First(); + ExpectMaterials(aConnected.MaterialsOnPositiveSide(aModifiedFace), aBox2); + const NCollection_List& aFaceTwins = + aConnected.PeriodicityTool().GetTwins(aModifiedFace); + NCollection_List aNegativeMaterials; + for (NCollection_List::Iterator anIterator(aFaceTwins); anIterator.More(); + anIterator.Next()) + { + const NCollection_List& aMaterials = + aConnected.MaterialsOnNegativeSide(anIterator.Value()); + for (NCollection_List::Iterator aMaterialIterator(aMaterials); + aMaterialIterator.More(); + aMaterialIterator.Next()) + { + aNegativeMaterials.Append(aMaterialIterator.Value()); + } + } + ExpectMaterials(aNegativeMaterials, aBox1); + + aConnected.RepeatShape(0, 1); + aConnected.RepeatShape(1, 1); + ExpectValidShape(aConnected.PeriodicShape()); + EXPECT_EQ(CountShapes(aConnected.PeriodicShape(), TopAbs_WIRE), 76); + EXPECT_EQ(CountShapes(aConnected.PeriodicShape(), TopAbs_FACE), 76); + EXPECT_EQ(CountShapes(aConnected.PeriodicShape(), TopAbs_SHELL), 12); + EXPECT_EQ(CountShapes(aConnected.PeriodicShape(), TopAbs_SOLID), 12); + ASSERT_FALSE(aConnected.History().IsNull()); + EXPECT_EQ(CountShapes(aConnected.History()->Generated(aMaterialFace), TopAbs_FACE), 4); + aConnected.ClearRepetitions(); + ExpectWireFaceShellSolidCounts(aConnected.PeriodicShape(), 20, 20, 3, 3); + + const NCollection_List aClearedModifiedFaces = + GetFaces(MakeCompound(aConnected.GetModified(aMaterialFace))); + ASSERT_FALSE(aClearedModifiedFaces.IsEmpty()); + ExpectMaterials(aConnected.MaterialsOnPositiveSide(aClearedModifiedFaces.First()), aBox2); + + aConnected.RepeatShape(1, 1); + ExpectValidShape(aConnected.PeriodicShape()); + EXPECT_EQ(CountShapes(aConnected.PeriodicShape(), TopAbs_WIRE), 39); + EXPECT_EQ(CountShapes(aConnected.PeriodicShape(), TopAbs_FACE), 39); + EXPECT_EQ(CountShapes(aConnected.PeriodicShape(), TopAbs_SHELL), 6); + EXPECT_EQ(CountShapes(aConnected.PeriodicShape(), TopAbs_SOLID), 6); + const NCollection_List aFinalModifiedFaces = + GetFaces(MakeCompound(aConnected.GetModified(aMaterialFace))); + ASSERT_FALSE(aFinalModifiedFaces.IsEmpty()); + const NCollection_List& aFinalTwins = + aConnected.PeriodicityTool().GetTwins(aFinalModifiedFaces.First()); + EXPECT_EQ(CountShapes(aFinalTwins, TopAbs_FACE), 3); +} diff --git a/src/ModelingAlgorithms/TKBO/GTests/BOPAlgo_OpenSolid_Test.cxx b/src/ModelingAlgorithms/TKBO/GTests/BOPAlgo_OpenSolid_Test.cxx new file mode 100644 index 0000000000..7cf0091e93 --- /dev/null +++ b/src/ModelingAlgorithms/TKBO/GTests/BOPAlgo_OpenSolid_Test.cxx @@ -0,0 +1,473 @@ +// Copyright (c) 2026 OPEN CASCADE SAS +// +// This file is part of Open CASCADE Technology software library. +// +// This library is free software; you can redistribute it and/or modify it under +// the terms of the GNU Lesser General Public License version 2.1 as published +// by the Free Software Foundation, with special exception defined in the file +// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT +// distribution for complete text of the license and disclaimer of any warranty. +// +// Alternatively, this file may be used under the terms of Open CASCADE +// commercial license or contractual agreement. + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace +{ +struct ShapeExpectation +{ + int myVertices; + int myEdges; + int myWires; + int myFaces; + int myShells; + int mySolids; + double mySurface; + double myVolume; +}; + +static int CountShapes(const TopoDS_Shape& theShape, const TopAbs_ShapeEnum theType) +{ + NCollection_IndexedMap aMap; + TopExp::MapShapes(theShape, aMap); + int aCount = 0; + for (int anIndex = 1; anIndex <= aMap.Extent(); ++anIndex) + { + if (aMap(anIndex).ShapeType() == theType) + { + ++aCount; + } + } + return aCount; +} + +static void ExpectNoSelfInterference(const TopoDS_Shape& theShape) +{ + if (theShape.IsNull()) + { + return; + } + + NCollection_List anArguments; + anArguments.Append(theShape); + BOPAlgo_CheckerSI aChecker; + aChecker.SetArguments(anArguments); + aChecker.SetLevelOfCheck(9); + aChecker.SetFuzzyValue(Precision::Confusion()); + aChecker.SetRunParallel(false); + aChecker.Perform(); + EXPECT_FALSE(aChecker.HasErrors()); +} + +static void ExpectShape(const TopoDS_Shape& theShape, const ShapeExpectation& theExpected) +{ + // Open-solid results are intentionally not closed. DRAW checkshape reports + // BRepCheck_NotClosed for these results, while bopcheck is the actual + // self-interference validation used by the test. + ExpectNoSelfInterference(theShape); + EXPECT_EQ(CountShapes(theShape, TopAbs_VERTEX), theExpected.myVertices); + EXPECT_EQ(CountShapes(theShape, TopAbs_EDGE), theExpected.myEdges); + EXPECT_EQ(CountShapes(theShape, TopAbs_WIRE), theExpected.myWires); + EXPECT_EQ(CountShapes(theShape, TopAbs_FACE), theExpected.myFaces); + EXPECT_EQ(CountShapes(theShape, TopAbs_SHELL), theExpected.myShells); + EXPECT_EQ(CountShapes(theShape, TopAbs_SOLID), theExpected.mySolids); + + GProp_GProps aSurfaceProperties; + BRepGProp::SurfaceProperties(theShape, aSurfaceProperties); + EXPECT_NEAR(aSurfaceProperties.Mass(), theExpected.mySurface, 1.0e-6); + if (theExpected.myVolume >= 0.0) + { + GProp_GProps aVolumeProperties; + BRepGProp::VolumeProperties(theShape, aVolumeProperties); + EXPECT_NEAR(aVolumeProperties.Mass(), theExpected.myVolume, 1.0e-6); + } +} + +static TopoDS_Solid MakeOpenSolid(const TopoDS_Shape& theSolid, + const int theFirstFace, + const int theLastFace, + const TopoDS_Face& theExtraFace = TopoDS_Face()) +{ + BRep_Builder aBuilder; + TopoDS_Shell aShell; + aBuilder.MakeShell(aShell); + int anIndex = 0; + for (TopExp_Explorer anExplorer(theSolid, TopAbs_FACE); anExplorer.More(); anExplorer.Next()) + { + if (anIndex >= theFirstFace && anIndex <= theLastFace) + { + aBuilder.Add(aShell, anExplorer.Current()); + } + ++anIndex; + } + + TopoDS_Solid aResult; + aBuilder.MakeSolid(aResult); + aBuilder.Add(aResult, aShell); + if (!theExtraFace.IsNull()) + { + TopoDS_Shell anInternalShell; + aBuilder.MakeShell(anInternalShell); + aBuilder.Add(anInternalShell, theExtraFace); + aBuilder.Add(aResult, anInternalShell); + } + return aResult; +} + +static void CheckBOP(const NCollection_List& theObjects, + const NCollection_List& theTools, + const BOPAlgo_Operation theOperation, + const ShapeExpectation& theExpected) +{ + BOPAlgo_BOP anAlgorithm; + for (NCollection_List::Iterator anIterator(theObjects); anIterator.More(); + anIterator.Next()) + { + anAlgorithm.AddArgument(anIterator.Value()); + } + for (NCollection_List::Iterator anIterator(theTools); anIterator.More(); + anIterator.Next()) + { + anAlgorithm.AddTool(anIterator.Value()); + } + anAlgorithm.SetOperation(theOperation); + anAlgorithm.SetRunParallel(false); + anAlgorithm.Perform(); + ASSERT_FALSE(anAlgorithm.HasErrors()); + ExpectShape(anAlgorithm.Shape(), theExpected); +} + +static void CheckBOPWithFiller(const NCollection_List& theObjects, + const NCollection_List& theTools, + const BOPAlgo_Operation theOperation, + const ShapeExpectation& theExpected) +{ + NCollection_List anArguments = theObjects; + for (NCollection_List::Iterator anIterator(theTools); anIterator.More(); + anIterator.Next()) + { + anArguments.Append(anIterator.Value()); + } + + BOPAlgo_PaveFiller aFiller; + aFiller.SetArguments(anArguments); + aFiller.SetFuzzyValue(Precision::Confusion()); + aFiller.SetRunParallel(false); + aFiller.SetNonDestructive(false); + aFiller.Perform(); + ASSERT_FALSE(aFiller.HasErrors()); + + BOPAlgo_BOP anAlgorithm; + for (NCollection_List::Iterator anIterator(theObjects); anIterator.More(); + anIterator.Next()) + { + anAlgorithm.AddArgument(anIterator.Value()); + } + for (NCollection_List::Iterator anIterator(theTools); anIterator.More(); + anIterator.Next()) + { + anAlgorithm.AddTool(anIterator.Value()); + } + anAlgorithm.SetOperation(theOperation); + anAlgorithm.SetRunParallel(false); + anAlgorithm.SetCheckInverted(true); + anAlgorithm.PerformWithFiller(aFiller); + ASSERT_FALSE(anAlgorithm.HasErrors()); + ExpectShape(anAlgorithm.Shape(), theExpected); +} + +static void CheckBuildBOP(const NCollection_List& theArguments, + const NCollection_List& theObjects, + const NCollection_List& theTools, + const BOPAlgo_Operation theOperation, + const ShapeExpectation& theExpected, + const char* theLabel) +{ + SCOPED_TRACE(theLabel); + BOPAlgo_PaveFiller aFiller; + aFiller.SetArguments(theArguments); + aFiller.SetFuzzyValue(Precision::Confusion()); + aFiller.SetRunParallel(false); + aFiller.SetNonDestructive(false); + aFiller.Perform(); + ASSERT_FALSE(aFiller.HasErrors()); + + BOPAlgo_Builder aBuilder; + for (NCollection_List::Iterator anIterator(theArguments); anIterator.More(); + anIterator.Next()) + { + aBuilder.AddArgument(anIterator.Value()); + } + aBuilder.SetRunParallel(false); + aBuilder.SetCheckInverted(true); + aBuilder.PerformWithFiller(aFiller); + ASSERT_FALSE(aBuilder.HasErrors()); + + aBuilder.BuildBOP(theObjects, theTools, theOperation, Message_ProgressRange()); + ASSERT_FALSE(aBuilder.HasErrors()); + ExpectShape(aBuilder.Shape(), theExpected); +} + +static void CheckTwoShapeBOP(const TopoDS_Shape& theObject, + const TopoDS_Shape& theTool, + const ShapeExpectation& theCommon, + const ShapeExpectation& theFuse, + const ShapeExpectation& theCut, + const ShapeExpectation& theTuc) +{ + NCollection_List anObject; + anObject.Append(theObject); + NCollection_List aTool; + aTool.Append(theTool); + CheckBOP(anObject, aTool, BOPAlgo_COMMON, theCommon); + CheckBOP(anObject, aTool, BOPAlgo_FUSE, theFuse); + CheckBOP(anObject, aTool, BOPAlgo_CUT, theCut); + CheckBOP(aTool, anObject, BOPAlgo_CUT, theTuc); +} + +static TopoDS_Shape MakeOpenBox(const gp_Pnt& theOrigin, + const double theDx, + const double theDy, + const double theDz, + const int theFirstFace = 0, + const int theLastFace = 4) +{ + return MakeOpenSolid(BRepPrimAPI_MakeBox(theOrigin, theDx, theDy, theDz).Shape(), + theFirstFace, + theLastFace); +} + +static TopoDS_Face MakeInternalFace(const double theX) +{ + BRepBuilderAPI_MakePolygon aPolygon; + aPolygon.Add(gp_Pnt(theX, 1.0, 1.0)); + aPolygon.Add(gp_Pnt(theX, 9.0, 1.0)); + aPolygon.Add(gp_Pnt(theX, 9.0, 9.0)); + aPolygon.Add(gp_Pnt(theX, 1.0, 9.0)); + aPolygon.Close(); + TopoDS_Face aFace = BRepBuilderAPI_MakeFace(aPolygon.Wire()).Face(); + aFace.Orientation(TopAbs_INTERNAL); + return aFace; +} + +static ShapeExpectation OpenResult(const int theVertices, + const int theEdges, + const int theWires, + const int theFaces, + const int theShells, + const int theSolids, + const double theSurface) +{ + return {theVertices, theEdges, theWires, theFaces, theShells, theSolids, theSurface, -1.0}; +} +} // namespace + +// Equivalent to tests/boolean/opensolid/A1. +TEST(BOPAlgo_OpenSolidTest, A1_TwoOpenBoxes) +{ + const TopoDS_Shape aBox1 = MakeOpenBox(gp_Pnt(0.0, 0.0, 0.0), 10.0, 10.0, 10.0); + const TopoDS_Shape aBox2 = MakeOpenBox(gp_Pnt(5.0, 0.0, 0.0), 10.0, 10.0, 10.0); + CheckTwoShapeBOP(aBox1, + aBox2, + OpenResult(8, 12, 5, 5, 1, 1, 350.0), + OpenResult(16, 26, 11, 11, 1, 1, 650.0), + OpenResult(8, 12, 5, 5, 1, 1, 350.0), + OpenResult(8, 12, 5, 5, 1, 1, 350.0)); +} + +// Equivalent to tests/boolean/opensolid/A2. +TEST(BOPAlgo_OpenSolidTest, A2_OpenBoxesWithPartialIntersection) +{ + const TopoDS_Shape aBox1 = MakeOpenBox(gp_Pnt(0.0, 0.0, 0.0), 10.0, 10.0, 10.0); + const TopoDS_Shape aBox2 = MakeOpenBox(gp_Pnt(2.5, 0.0, 0.0), 5.0, 10.0, 5.0); + CheckTwoShapeBOP(aBox1, + aBox2, + OpenResult(8, 12, 5, 5, 1, 1, 200.0), + OpenResult(16, 24, 9, 9, 1, 1, 500.0), + OpenResult(16, 24, 8, 8, 1, 1, 500.0), + OpenResult(0, 0, 0, 0, 0, 0, 0.0)); +} + +// Equivalent to tests/boolean/opensolid/A3. +TEST(BOPAlgo_OpenSolidTest, A3_OpenBoxesWithDifferentOrientation) +{ + const TopoDS_Shape aBox1 = MakeOpenBox(gp_Pnt(-15.0, 0.0, 0.0), 20.0, 5.0, 5.0, 1, 5); + const TopoDS_Shape aBox2 = MakeOpenBox(gp_Pnt(0.0, 0.0, 0.0), 5.0, 5.0, 20.0); + CheckTwoShapeBOP(aBox1, + aBox2, + OpenResult(8, 12, 6, 6, 1, 1, 150.0), + OpenResult(16, 28, 12, 12, 1, 1, 700.0), + OpenResult(8, 12, 5, 5, 1, 1, 325.0), + OpenResult(8, 12, 5, 5, 1, 1, 325.0)); +} + +// Equivalent to tests/boolean/opensolid/A4. +TEST(BOPAlgo_OpenSolidTest, A4_MultiObjectOpenSolidOperations) +{ + const TopoDS_Shape aBox1 = BRepPrimAPI_MakeBox(40.0, 10.0, 10.0).Shape(); + const TopoDS_Shape aBox2 = BRepPrimAPI_MakeBox(gp_Pnt(0.0, 0.0, 30.0), 40.0, 10.0, 10.0).Shape(); + const TopoDS_Shape aBox3 = BRepPrimAPI_MakeBox(10.0, 10.0, 40.0).Shape(); + const TopoDS_Shape aBox4 = BRepPrimAPI_MakeBox(gp_Pnt(30.0, 0.0, 0.0), 10.0, 10.0, 40.0).Shape(); + const ShapeExpectation aFuse = {32, 64, 32, 32, 1, 1, 4800.0, 12000.0}; + const ShapeExpectation aCut = {16, 24, 12, 12, 2, 2, 2000.0, 4000.0}; + const ShapeExpectation aSingleCut = {8, 12, 6, 6, 1, 1, 1000.0, 2000.0}; + const ShapeExpectation aCommon = {32, 48, 24, 24, 4, 4, 2400.0, 4000.0}; + const ShapeExpectation aSingleCommon = {16, 24, 12, 12, 2, 2, 1200.0, 2000.0}; + + NCollection_List anAll; + anAll.Append(aBox1); + anAll.Append(aBox2); + anAll.Append(aBox3); + anAll.Append(aBox4); + + NCollection_List anObjects; + anObjects.Append(aBox1); + anObjects.Append(aBox2); + NCollection_List aTools; + aTools.Append(aBox3); + aTools.Append(aBox4); + NCollection_List anAllTools; + anAllTools.Append(aBox2); + anAllTools.Append(aBox3); + anAllTools.Append(aBox4); + CheckBuildBOP(anAll, anAll, NCollection_List(), BOPAlgo_FUSE, aFuse, "all fuse"); + CheckBuildBOP(anAll, anObjects, aTools, BOPAlgo_FUSE, aFuse, "objects/tools fuse"); + CheckBuildBOP(anAll, anObjects, aTools, BOPAlgo_CUT, aCut, "objects/tools cut"); + CheckBuildBOP(anAll, aTools, anObjects, BOPAlgo_CUT, aCut, "tools/objects cut"); + CheckBuildBOP(anAll, anObjects, aTools, BOPAlgo_COMMON, aCommon, "objects/tools common"); + + NCollection_List aSingleObject; + aSingleObject.Append(aBox1); + NCollection_List aSecondObject; + aSecondObject.Append(aBox2); + CheckBuildBOP(anAll, aSingleObject, anAllTools, BOPAlgo_FUSE, aFuse, "single object/tools fuse"); + CheckBuildBOP(anAll, aSingleObject, aTools, BOPAlgo_CUT, aSingleCut, "single object/tools cut"); + CheckBuildBOP(anAll, aSecondObject, aTools, BOPAlgo_CUT, aSingleCut, "second object/tools cut"); + CheckBuildBOP(anAll, + aSingleObject, + aTools, + BOPAlgo_COMMON, + aSingleCommon, + "first object/tools common"); + CheckBuildBOP(anAll, + aSecondObject, + aTools, + BOPAlgo_COMMON, + aSingleCommon, + "second object/tools common"); +} + +// Equivalent to tests/boolean/opensolid/A5. +TEST(BOPAlgo_OpenSolidTest, A5_InvertedToolOpenSolidOperations) +{ + const TopoDS_Shape aBox1 = BRepPrimAPI_MakeBox(10.0, 2.0, 2.0).Shape(); + const TopoDS_Shape aBox2 = BRepPrimAPI_MakeBox(gp_Pnt(2.0, 0.5, -3.0), 1.0, 1.0, 8.0).Shape(); + TopoDS_Shape aBox3 = BRepPrimAPI_MakeBox(gp_Pnt(7.0, 0.5, -3.0), 1.0, 1.0, 8.0).Shape(); + aBox3.Reverse(); + NCollection_List aTools; + aTools.Append(aBox2); + aTools.Append(aBox3); + NCollection_List anObject; + anObject.Append(aBox1); + CheckBOP(anObject, aTools, BOPAlgo_COMMON, {24, 36, 20, 16, 2, 2, 110.0, 38.0}); + CheckBOP(anObject, aTools, BOPAlgo_FUSE, {16, 24, 12, 12, 2, 2, 28.0, -6.0}); + CheckBOP(anObject, aTools, BOPAlgo_CUT, {8, 12, 6, 6, 1, 1, 10.0, 2.0}); + CheckBOP(aTools, anObject, BOPAlgo_CUT, {40, 60, 32, 28, 3, 3, 164.0, -46.0}); +} + +// Equivalent to tests/boolean/opensolid/A6. +TEST(BOPAlgo_OpenSolidTest, A6_NestedOpenSolidOperations) +{ + const TopoDS_Shape aBox1 = BRepPrimAPI_MakeBox(10.0, 2.0, 2.0).Shape(); + const TopoDS_Shape aBox2 = BRepPrimAPI_MakeBox(gp_Pnt(5.0, 0.0, 0.0), 5.0, 5.0, 5.0).Shape(); + const TopoDS_Shape aBox3 = BRepPrimAPI_MakeBox(gp_Pnt(6.0, 0.0, 0.0), 1.0, 1.0, 1.0).Shape(); + NCollection_List aTools; + aTools.Append(aBox2); + aTools.Append(aBox3); + NCollection_List anObject; + anObject.Append(aBox1); + CheckBOP(anObject, aTools, BOPAlgo_COMMON, {16, 25, 12, 12, 2, 2, 56.0, 20.0}); + CheckBOP(anObject, aTools, BOPAlgo_FUSE, {24, 38, 16, 16, 1, 1, 190.0, 145.0}); + CheckBOP(anObject, aTools, BOPAlgo_CUT, {8, 12, 6, 6, 1, 1, 48.0, 20.0}); + CheckBOP(aTools, anObject, BOPAlgo_CUT, {12, 18, 8, 8, 1, 1, 142.0, 105.0}); +} + +// Equivalent to tests/boolean/opensolid/A7. +TEST(BOPAlgo_OpenSolidTest, A7_ThreeOpenSolidOperations) +{ + const TopoDS_Shape aBox1 = BRepPrimAPI_MakeBox(10.0, 10.0, 10.0).Shape(); + const TopoDS_Shape aBox2 = BRepPrimAPI_MakeBox(gp_Pnt(1.0, 1.0, 1.0), 8.0, 8.0, 8.0).Shape(); + const TopoDS_Shape aBox3 = BRepPrimAPI_MakeBox(gp_Pnt(-2.0, 3.0, 3.0), 14.0, 4.0, 4.0).Shape(); + NCollection_List anObjects; + anObjects.Append(aBox1); + anObjects.Append(aBox2); + anObjects.Append(aBox3); + NCollection_List aOne; + aOne.Append(aBox3); + NCollection_List aTwo; + aTwo.Append(aBox1); + aTwo.Append(aBox2); + CheckBOP(aOne, aTwo, BOPAlgo_COMMON, {16, 28, 16, 16, 3, 3, 256.0, 160.0}); + CheckBOP(aOne, aTwo, BOPAlgo_FUSE, {24, 36, 18, 16, 1, 1, 664.0, 1064.0}); + CheckBOP(aOne, aTwo, BOPAlgo_CUT, {16, 24, 12, 12, 2, 2, 128.0, 64.0}); + CheckBOP(aTwo, aOne, BOPAlgo_CUT, {32, 52, 28, 24, 2, 2, 1432.0, 840.0}); + (void)anObjects; +} + +// Equivalent to tests/boolean/opensolid/A8. +TEST(BOPAlgo_OpenSolidTest, A8_OverlappingOpenSolidOperations) +{ + const TopoDS_Shape aBox1 = BRepPrimAPI_MakeBox(10.0, 10.0, 10.0).Shape(); + const TopoDS_Shape aBox2 = BRepPrimAPI_MakeBox(gp_Pnt(-2.0, -2.0, 2.0), 7.0, 14.0, 6.0).Shape(); + const TopoDS_Shape aBox3 = BRepPrimAPI_MakeBox(gp_Pnt(5.0, -2.0, 2.0), 7.0, 14.0, 6.0).Shape(); + NCollection_List aTools; + aTools.Append(aBox3); + aTools.Append(aBox2); + NCollection_List anObject; + anObject.Append(aBox1); + CheckBOP(anObject, aTools, BOPAlgo_COMMON, {12, 20, 11, 11, 2, 2, 560.0, 600.0}); + CheckBOP(anObject, aTools, BOPAlgo_FUSE, {32, 50, 20, 20, 1, 1, 888.0, 1576.0}); + CheckBOP(anObject, aTools, BOPAlgo_CUT, {20, 30, 14, 14, 2, 2, 560.0, 400.0}); + CheckBOP(aTools, anObject, BOPAlgo_CUT, {24, 40, 18, 18, 2, 2, 816.0, 576.0}); +} + +// Equivalent to tests/boolean/opensolid/A9. +TEST(BOPAlgo_OpenSolidTest, A9_OpenSolidWithInternalShell) +{ + const TopoDS_Shape aBox1 = BRepPrimAPI_MakeBox(10.0, 10.0, 10.0).Shape(); + const TopoDS_Shape aBox2 = BRepPrimAPI_MakeBox(gp_Pnt(5.0, 0.0, 0.0), 10.0, 10.0, 10.0).Shape(); + const TopoDS_Shape aOpen1 = MakeOpenSolid(aBox1, 0, 4, MakeInternalFace(1.0)); + const TopoDS_Shape aOpen2 = MakeOpenSolid(aBox2, 0, 4, MakeInternalFace(14.0)); + NCollection_List anObject; + anObject.Append(aOpen1); + NCollection_List aTool; + aTool.Append(aOpen2); + CheckBOPWithFiller(anObject, aTool, BOPAlgo_COMMON, OpenResult(8, 12, 5, 5, 1, 1, 350.0)); + CheckBOPWithFiller(anObject, aTool, BOPAlgo_FUSE, OpenResult(16, 26, 11, 11, 1, 1, 650.0)); + CheckBOPWithFiller(anObject, aTool, BOPAlgo_CUT, OpenResult(12, 16, 6, 6, 2, 1, 414.0)); + CheckBOPWithFiller(aTool, anObject, BOPAlgo_CUT, OpenResult(12, 16, 6, 6, 2, 1, 414.0)); +} diff --git a/src/ModelingAlgorithms/TKBO/GTests/BRepAlgoAPI_Common_Test.cxx b/src/ModelingAlgorithms/TKBO/GTests/BRepAlgoAPI_Common_Test.cxx index 72ad4202ff..0ff88a4797 100644 --- a/src/ModelingAlgorithms/TKBO/GTests/BRepAlgoAPI_Common_Test.cxx +++ b/src/ModelingAlgorithms/TKBO/GTests/BRepAlgoAPI_Common_Test.cxx @@ -30,4 +30,29 @@ TEST_F(BOPCommonSimpleTest, IdenticalBoxes_A1) const TopoDS_Shape aResult = PerformCommon(aBox1, aBox2); ValidateResult(aResult, 6.0); -} \ No newline at end of file +} + +// Migrated from tests/bugs/modalg_5/bug23855. The common of two coincident +// spheres must preserve the complete solid, not produce a partial shell. +TEST_F(BOPCommonSimpleTest, OCC23855_CoincidentSpheresPreserveSolid) +{ + const TopoDS_Shape aSphere1 = BRepPrimAPI_MakeSphere(10.0).Shape(); + const TopoDS_Shape aSphere2 = BRepPrimAPI_MakeSphere(10.0).Shape(); + const TopoDS_Shape aResult = PerformCommon(aSphere1, aSphere2); + ASSERT_FALSE(aResult.IsNull()); + + int aNbSolids = 0; + int aNbFaces = 0; + for (TopExp_Explorer anExplorer(aResult, TopAbs_SOLID); anExplorer.More(); anExplorer.Next()) + { + ++aNbSolids; + } + for (TopExp_Explorer anExplorer(aResult, TopAbs_FACE); anExplorer.More(); anExplorer.Next()) + { + ++aNbFaces; + } + EXPECT_EQ(aNbSolids, 1); + EXPECT_EQ(aNbFaces, 1); + EXPECT_NEAR(BOPTest_Utilities::GetSurfaceArea(aResult), 4.0 * M_PI * 100.0, 1.e-6); + EXPECT_NEAR(BOPTest_Utilities::GetVolume(aResult), 4.0 * M_PI * 1000.0 / 3.0, 1.e-6); +} diff --git a/src/ModelingAlgorithms/TKBO/GTests/BRepAlgoAPI_Cut_Test.cxx b/src/ModelingAlgorithms/TKBO/GTests/BRepAlgoAPI_Cut_Test.cxx index 33f7754233..6267e281e3 100644 --- a/src/ModelingAlgorithms/TKBO/GTests/BRepAlgoAPI_Cut_Test.cxx +++ b/src/ModelingAlgorithms/TKBO/GTests/BRepAlgoAPI_Cut_Test.cxx @@ -14,6 +14,10 @@ #include "BOPTest_Utilities.pxx" #include +#include +#include +#include +#include #include #include #include @@ -48,6 +52,13 @@ static int countSubShapes(const TopoDS_Shape& theShape, const TopAbs_ShapeEnum t return aCount; } +static int countUniqueSubShapes(const TopoDS_Shape& theShape, const TopAbs_ShapeEnum theType) +{ + NCollection_IndexedMap aShapes; + TopExp::MapShapes(theShape, theType, aShapes); + return aShapes.Extent(); +} + // Test bcut_simple/A1: psphere s 1; box b 1 1 1; bcut result s b; checkprops result -s 13.3518 TEST_F(BCutSimpleTest, SphereMinusBox_A1) { @@ -58,6 +69,54 @@ TEST_F(BCutSimpleTest, SphereMinusBox_A1) ValidateResult(aResult, 13.3518); } +// Migrated from tests/bugs/modalg_5/bug24706. A Boolean cut must retain the +// Closed flag on the shell of the resulting box-with-spherical-cut solid. +TEST_F(BCutSimpleTest, ModalgBug_24706_CutResultShellIsClosed) +{ + const TopoDS_Shape aBox = BOPTest_Utilities::CreateBox(gp_Pnt(0, 0, 0), 10.0, 10.0, 10.0); + const TopoDS_Shape aSphere = BOPTest_Utilities::CreateSphere(gp_Pnt(0, 0, 0), 2.0); + + BRepAlgoAPI_Cut aCut(aBox, aSphere); + aCut.Build(); + ASSERT_TRUE(aCut.IsDone()); + const TopoDS_Shape aResult = aCut.Shape(); + ASSERT_FALSE(aResult.IsNull()); + EXPECT_TRUE(BRepCheck_Analyzer(aResult).IsValid()); + EXPECT_EQ(countSubShapes(aResult, TopAbs_SOLID), 1); + EXPECT_EQ(countSubShapes(aResult, TopAbs_SHELL), 1); + + TopExp_Explorer anExplorer(aResult, TopAbs_SHELL); + ASSERT_TRUE(anExplorer.More()); + EXPECT_TRUE(TopoDS::Shell(anExplorer.Current()).Closed()); +} + +// Migrated from tests/bugs/modalg_5/bug25242. Cutting one disjoint member +// from a fused compound must leave the other box with the DRAW topology. +TEST_F(BCutSimpleTest, ModalgBug_25242_CutFusedDisjointBoxesKeepsTopology) +{ + const TopoDS_Shape aBoxA = BOPTest_Utilities::CreateBox(gp_Pnt(0, 0, 0), 10.0, 10.0, 10.0); + const TopoDS_Shape aBoxB = BOPTest_Utilities::CreateBox(gp_Pnt(20, 0, 0), 10.0, 10.0, 10.0); + + BRepAlgoAPI_Fuse aFuse(aBoxA, aBoxB); + aFuse.Build(); + ASSERT_TRUE(aFuse.IsDone()); + + BRepAlgoAPI_Cut aCut(aFuse.Shape(), aBoxA); + aCut.Build(); + ASSERT_TRUE(aCut.IsDone()); + const TopoDS_Shape aResult = aCut.Shape(); + ASSERT_FALSE(aResult.IsNull()); + + EXPECT_EQ(aResult.ShapeType(), TopAbs_COMPOUND); + EXPECT_EQ(countUniqueSubShapes(aResult, TopAbs_VERTEX), 8); + EXPECT_EQ(countUniqueSubShapes(aResult, TopAbs_EDGE), 12); + EXPECT_EQ(countUniqueSubShapes(aResult, TopAbs_WIRE), 6); + EXPECT_EQ(countUniqueSubShapes(aResult, TopAbs_FACE), 6); + EXPECT_EQ(countUniqueSubShapes(aResult, TopAbs_SHELL), 1); + EXPECT_EQ(countUniqueSubShapes(aResult, TopAbs_SOLID), 1); + EXPECT_NEAR(BOPTest_Utilities::GetVolume(aResult), 1000.0, Precision::Confusion()); +} + // Test bcut_simple/A2: rotated sphere - box TEST_F(BCutSimpleTest, RotatedSphereMinusBox_A2) { diff --git a/src/ModelingAlgorithms/TKBO/GTests/BRepAlgoAPI_Simplify_Test.cxx b/src/ModelingAlgorithms/TKBO/GTests/BRepAlgoAPI_Simplify_Test.cxx new file mode 100644 index 0000000000..3f3e3c9c86 --- /dev/null +++ b/src/ModelingAlgorithms/TKBO/GTests/BRepAlgoAPI_Simplify_Test.cxx @@ -0,0 +1,135 @@ +// Copyright (c) 2026 OPEN CASCADE SAS +// +// This file is part of Open CASCADE Technology software library. +// +// This library is free software; you can redistribute it and/or modify it under +// the terms of the GNU Lesser General Public License version 2.1 as published +// by the Free Software Foundation, with special exception defined in the file +// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT +// distribution for complete text of the license and disclaimer of any warranty. +// +// Alternatively, this file may be used under the terms of Open CASCADE +// commercial license or contractual agreement. + +#include "BOPTest_Utilities.pxx" + +#include +#include +#include +#include +#include +#include + +#include +#include + +namespace +{ +int CountShapes(const TopoDS_Shape& theShape, const TopAbs_ShapeEnum theType) +{ + NCollection_IndexedMap aMap; + TopExp::MapShapes(theShape, aMap); + + int aCount = 0; + for (int anIndex = 1; anIndex <= aMap.Extent(); ++anIndex) + { + if (aMap(anIndex).ShapeType() == theType) + { + ++aCount; + } + } + return aCount; +} + +TopoDS_Face MakePlaneFace(const gp_Pln& thePlane, + const double theFirstU, + const double theLastU, + const double theFirstV, + const double theLastV) +{ + return BRepBuilderAPI_MakeFace(thePlane, theFirstU, theLastU, theFirstV, theLastV).Face(); +} + +TopoDS_Shape MakeThreeFaceShell() +{ + const gp_Pln aPlane(gp_Pnt(0.0, 0.0, 0.0), gp::DZ()); + BRepBuilderAPI_Sewing aSewing; + aSewing.Add(MakePlaneFace(aPlane, -10.0, 10.0, -10.0, 10.0)); + aSewing.Add(MakePlaneFace(aPlane, 10.0, 30.0, -10.0, 10.0)); + aSewing.Add(MakePlaneFace(aPlane, 30.0, 50.0, -10.0, 10.0)); + aSewing.Perform(); + return aSewing.SewedShape(); +} + +double GetLength(const TopoDS_Shape& theShape) +{ + GProp_GProps aProperties; + BRepGProp::LinearProperties(theShape, aProperties); + return aProperties.Mass(); +} +} // namespace + +// Equivalent to tests/boolean/simplify/A1. +TEST(BRepAlgoAPI_SimplifyTest, A1_FuseCoplanarBoxes_SimplifiesFaces) +{ + const TopoDS_Shape aBox1 = BRepPrimAPI_MakeBox(10.0, 10.0, 15.0).Shape(); + const TopoDS_Shape aBox2 = BRepPrimAPI_MakeBox(gp_Pnt(3.0, 7.0, 0.0), 10.0, 10.0, 15.0).Shape(); + + BRepAlgoAPI_Fuse aFuse; + NCollection_List anArguments; + anArguments.Append(aBox1); + aFuse.SetArguments(anArguments); + NCollection_List aTools; + aTools.Append(aBox2); + aFuse.SetTools(aTools); + aFuse.SetRunParallel(false); + aFuse.Build(); + + ASSERT_FALSE(aFuse.HasErrors()); + const TopoDS_Shape& aResult = aFuse.Shape(); + ASSERT_FALSE(aResult.IsNull()); + EXPECT_TRUE(BRepCheck_Analyzer(aResult).IsValid()); + EXPECT_EQ(CountShapes(aResult, TopAbs_VERTEX), 20); + EXPECT_EQ(CountShapes(aResult, TopAbs_EDGE), 32); + EXPECT_EQ(CountShapes(aResult, TopAbs_WIRE), 14); + EXPECT_EQ(CountShapes(aResult, TopAbs_FACE), 14); + + aFuse.SimplifyResult(true, true); + EXPECT_TRUE(BRepCheck_Analyzer(aResult).IsValid()); + EXPECT_EQ(CountShapes(aResult, TopAbs_VERTEX), 16); + EXPECT_EQ(CountShapes(aResult, TopAbs_EDGE), 24); + EXPECT_EQ(CountShapes(aResult, TopAbs_WIRE), 10); + EXPECT_EQ(CountShapes(aResult, TopAbs_FACE), 10); +} + +// Equivalent to tests/boolean/simplify/A2. +TEST(BRepAlgoAPI_SimplifyTest, A2_SectionThroughSewnShell_SimplifiesEdges) +{ + const TopoDS_Shape aShell = MakeThreeFaceShell(); + const gp_Pln aCuttingPlane(gp_Pnt(0.0, 5.0, 0.0), gp::DY()); + const TopoDS_Shape aCuttingFace = MakePlaneFace(aCuttingPlane, -100.0, 100.0, -100.0, 100.0); + + BRepAlgoAPI_Section aSection; + NCollection_List anArguments; + anArguments.Append(aShell); + aSection.SetArguments(anArguments); + NCollection_List aTools; + aTools.Append(aCuttingFace); + aSection.SetTools(aTools); + aSection.SetRunParallel(false); + aSection.Build(); + + ASSERT_FALSE(aSection.HasErrors()); + const TopoDS_Shape& aResult = aSection.Shape(); + ASSERT_FALSE(aResult.IsNull()); + EXPECT_TRUE(BRepCheck_Analyzer(aResult).IsValid()); + EXPECT_EQ(CountShapes(aResult, TopAbs_VERTEX), 4); + EXPECT_EQ(CountShapes(aResult, TopAbs_EDGE), 3); + EXPECT_NEAR(GetLength(aResult), 60.0, Precision::Confusion()); + + aSection.SimplifyResult(true, true); + EXPECT_TRUE(BRepCheck_Analyzer(aResult).IsValid()); + EXPECT_EQ(CountShapes(aResult, TopAbs_VERTEX), 2); + EXPECT_EQ(CountShapes(aResult, TopAbs_EDGE), 1); + EXPECT_NEAR(GetLength(aResult), 60.0, Precision::Confusion()); +} diff --git a/src/ModelingAlgorithms/TKBO/GTests/BRepAlgoAPI_Splitter_Test.cxx b/src/ModelingAlgorithms/TKBO/GTests/BRepAlgoAPI_Splitter_Test.cxx new file mode 100644 index 0000000000..2ef57512da --- /dev/null +++ b/src/ModelingAlgorithms/TKBO/GTests/BRepAlgoAPI_Splitter_Test.cxx @@ -0,0 +1,354 @@ +// Copyright (c) 2026 OPEN CASCADE SAS +// +// This file is part of Open CASCADE Technology software library. +// +// This library is free software; you can redistribute it and/or modify it under +// the terms of the GNU Lesser General Public License version 2.1 as published +// by the Free Software Foundation, with special exception defined in the file +// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT +// distribution for complete text of the license and disclaimer of any warranty. +// +// Alternatively, this file may be used under the terms of Open CASCADE +// commercial license or contractual agreement. + +#include "BOPTest_Utilities.pxx" + +#include + +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include +#include +#include + +namespace +{ +int CountShapes(const TopoDS_Shape& theShape, const TopAbs_ShapeEnum theType) +{ + NCollection_IndexedMap aMap; + TopExp::MapShapes(theShape, aMap); + + int aCount = 0; + for (int anIndex = 1; anIndex <= aMap.Extent(); ++anIndex) + { + if (aMap(anIndex).ShapeType() == theType) + { + ++aCount; + } + } + return aCount; +} + +void ExpectShapeCount(const TopoDS_Shape& theShape, + const TopAbs_ShapeEnum theType, + const int theExpected) +{ + if (!theShape.IsNull()) + { + EXPECT_TRUE(BRepCheck_Analyzer(theShape).IsValid()); + } + EXPECT_EQ(CountShapes(theShape, theType), theExpected); +} + +TopoDS_Face MakePlaneFace(const double theFirstU, + const double theLastU, + const double theFirstV, + const double theLastV, + const double theZ = 0.0) +{ + const gp_Pln aPlane(gp_Pnt(0.0, 0.0, theZ), gp::DZ()); + return BRepBuilderAPI_MakeFace(aPlane, theFirstU, theLastU, theFirstV, theLastV).Face(); +} + +TopoDS_Face MakeCylinderFace() +{ + const occ::handle aSurface = + new Geom_CylindricalSurface(gp::XOY(), 10.0); + return BRepBuilderAPI_MakeFace(aSurface, + 0.0, + 2.0 * 3.14159265358979323846, + -20.0, + 20.0, + Precision::Confusion()) + .Face(); +} + +TopoDS_Compound MakeCylinderIsoEdges() +{ + BRep_Builder aBuilder; + TopoDS_Compound anEdges; + aBuilder.MakeCompound(anEdges); + const occ::handle aSurface = + new Geom_CylindricalSurface(gp::XOY(), 10.0); + + const double aPi = 3.14159265358979323846; + const int aNbUEdges = 10; + for (int anIndex = 0; anIndex <= aNbUEdges; ++anIndex) + { + const double anAngle = 2.0 * aPi * double(anIndex) / double(aNbUEdges); + const occ::handle aCurve = aSurface->UIso(anAngle); + aBuilder.Add(anEdges, BRepBuilderAPI_MakeEdge(aCurve, -25.0, 25.0).Edge()); + } + + const int aNbVEdges = 10; + for (int anIndex = 0; anIndex <= aNbVEdges; ++anIndex) + { + const double aZ = -20.0 + 40.0 * double(anIndex) / double(aNbVEdges); + const occ::handle aCurve = aSurface->VIso(aZ); + aBuilder.Add(anEdges, BRepBuilderAPI_MakeEdge(aCurve).Edge()); + } + return anEdges; +} + +TopoDS_Compound MakeCylinderGrid() +{ + BRep_Builder aBuilder; + TopoDS_Compound aCylinders; + aBuilder.MakeCompound(aCylinders); + for (int anX = 0; anX <= 100; anX += 5) + { + for (int anY = 0; anY <= 100; anY += 5) + { + const gp_Ax2 anAxis(gp_Pnt(double(anX), double(anY), -5.0), gp::DZ()); + aBuilder.Add(aCylinders, BRepPrimAPI_MakeCylinder(anAxis, 1.0, 11.0).Shape()); + } + } + return aCylinders; +} + +TopoDS_Shape SplitWithBOPAlgo(const TopoDS_Shape& theObject, const TopoDS_Shape& theTool) +{ + BOPAlgo_Splitter aSplitter; + aSplitter.AddArgument(theObject); + aSplitter.AddTool(theTool); + aSplitter.SetRunParallel(false); + aSplitter.Perform(); + EXPECT_FALSE(aSplitter.HasErrors()); + return aSplitter.Shape(); +} + +TopoDS_Shape SplitWithBRepAlgoAPI(const TopoDS_Shape& theObject, const TopoDS_Shape& theTool) +{ + BRepAlgoAPI_Splitter aSplitter; + NCollection_List anArguments; + anArguments.Append(theObject); + aSplitter.SetArguments(anArguments); + + NCollection_List aTools; + aTools.Append(theTool); + aSplitter.SetTools(aTools); + aSplitter.SetRunParallel(false); + aSplitter.Build(); + EXPECT_FALSE(aSplitter.HasErrors()); + return aSplitter.Shape(); +} + +TopoDS_Shape SplitCylinderFaceWithBOPAlgo(const TopoDS_Shape& theObject, + const TopoDS_Shape& theTools) +{ + BOPAlgo_Splitter aSplitter; + aSplitter.AddArgument(theObject); + for (TopoDS_Iterator anIterator(theTools); anIterator.More(); anIterator.Next()) + { + aSplitter.AddTool(anIterator.Value()); + } + aSplitter.SetRunParallel(false); + aSplitter.Perform(); + EXPECT_FALSE(aSplitter.HasErrors()); + return aSplitter.Shape(); +} + +TopoDS_Shape SplitCylinderFaceWithBRepAlgoAPI(const TopoDS_Shape& theObject, + const TopoDS_Shape& theTools) +{ + BRepAlgoAPI_Splitter aSplitter; + NCollection_List anArguments; + anArguments.Append(theObject); + aSplitter.SetArguments(anArguments); + NCollection_List aTools; + for (TopoDS_Iterator anIterator(theTools); anIterator.More(); anIterator.Next()) + { + aTools.Append(anIterator.Value()); + } + aSplitter.SetTools(aTools); + aSplitter.SetRunParallel(false); + aSplitter.Build(); + EXPECT_FALSE(aSplitter.HasErrors()); + return aSplitter.Shape(); +} +} // namespace + +// Equivalent to tests/boolean/splitter/A1. +TEST(BRepAlgoAPI_SplitterTest, A1_BoxSplitByCrossingBoxes_ProducesNineSolids) +{ + const TopoDS_Shape aBox = BRepPrimAPI_MakeBox(10.0, 10.0, 10.0).Shape(); + const TopoDS_Shape aToolX = BRepPrimAPI_MakeBox(gp_Pnt(4.0, -2.0, -2.0), 2.0, 14.0, 14.0).Shape(); + const TopoDS_Shape aToolY = BRepPrimAPI_MakeBox(gp_Pnt(-2.0, 4.0, -2.0), 14.0, 2.0, 14.0).Shape(); + + BOPAlgo_Splitter aSplitter; + aSplitter.AddArgument(aBox); + aSplitter.AddTool(aToolX); + aSplitter.AddTool(aToolY); + aSplitter.SetRunParallel(false); + aSplitter.Perform(); + + ASSERT_FALSE(aSplitter.HasErrors()); + const TopoDS_Shape& aResult = aSplitter.Shape(); + ASSERT_FALSE(aResult.IsNull()); + ExpectShapeCount(aResult, TopAbs_SOLID, 9); + EXPECT_NEAR(BOPTest_Utilities::GetVolume(aResult), 1000.0, Precision::Confusion()); +} + +// Equivalent to tests/boolean/splitter/A2. +TEST(BRepAlgoAPI_SplitterTest, A2_BoxSplitBySolidAndFace_ProducesFourSolids) +{ + const TopoDS_Shape aBox = BRepPrimAPI_MakeBox(10.0, 10.0, 10.0).Shape(); + const TopoDS_Shape aToolBox = + BRepPrimAPI_MakeBox(gp_Pnt(5.0, 0.0, 0.0), 10.0, 10.0, 10.0).Shape(); + const TopoDS_Shape aToolFace = MakePlaneFace(-20.0, 20.0, -20.0, 20.0, 5.0); + + BOPAlgo_Splitter aSplitter; + aSplitter.AddArgument(aBox); + aSplitter.AddTool(aToolBox); + aSplitter.AddTool(aToolFace); + aSplitter.SetRunParallel(false); + aSplitter.Perform(); + ASSERT_FALSE(aSplitter.HasErrors()); + + const TopoDS_Shape& aSplitResult = aSplitter.Shape(); + ASSERT_FALSE(aSplitResult.IsNull()); + ExpectShapeCount(aSplitResult, TopAbs_SOLID, 4); + EXPECT_NEAR(BOPTest_Utilities::GetVolume(aSplitResult), 1000.0, Precision::Confusion()); +} + +// Equivalent to tests/boolean/splitter/A3. +TEST(BRepAlgoAPI_SplitterTest, A3_PlaneSplitBySphere_ProducesTwoFaces) +{ + const TopoDS_Shape aFace = MakePlaneFace(-20.0, 20.0, -20.0, 20.0); + const TopoDS_Shape aSphere = BRepPrimAPI_MakeSphere(5.0).Shape(); + const TopoDS_Shape aResult = SplitWithBOPAlgo(aFace, aSphere); + + ASSERT_FALSE(aResult.IsNull()); + ExpectShapeCount(aResult, TopAbs_FACE, 2); + EXPECT_NEAR(BOPTest_Utilities::GetSurfaceArea(aResult), 1600.0, Precision::Confusion()); +} + +// Equivalent to tests/boolean/splitter/B1. +TEST(BRepAlgoAPI_SplitterTest, B1_ApiBoxSplitByCrossingBoxes_ProducesNineSolids) +{ + const TopoDS_Shape aBox = BRepPrimAPI_MakeBox(10.0, 10.0, 10.0).Shape(); + const TopoDS_Shape aToolX = BRepPrimAPI_MakeBox(gp_Pnt(4.0, -2.0, -2.0), 2.0, 14.0, 14.0).Shape(); + const TopoDS_Shape aToolY = BRepPrimAPI_MakeBox(gp_Pnt(-2.0, 4.0, -2.0), 14.0, 2.0, 14.0).Shape(); + + BRepAlgoAPI_Splitter aSplitter; + NCollection_List anArguments; + anArguments.Append(aBox); + aSplitter.SetArguments(anArguments); + NCollection_List aTools; + aTools.Append(aToolX); + aTools.Append(aToolY); + aSplitter.SetTools(aTools); + aSplitter.SetRunParallel(false); + aSplitter.Build(); + + ASSERT_FALSE(aSplitter.HasErrors()); + const TopoDS_Shape& aResult = aSplitter.Shape(); + ASSERT_FALSE(aResult.IsNull()); + ExpectShapeCount(aResult, TopAbs_SOLID, 9); + EXPECT_NEAR(BOPTest_Utilities::GetVolume(aResult), 1000.0, Precision::Confusion()); +} + +// Equivalent to tests/boolean/splitter/B2. +TEST(BRepAlgoAPI_SplitterTest, B2_ApiBoxSplitBySolidAndFace_ProducesFourSolids) +{ + const TopoDS_Shape aBox = BRepPrimAPI_MakeBox(10.0, 10.0, 10.0).Shape(); + const TopoDS_Shape aToolBox = + BRepPrimAPI_MakeBox(gp_Pnt(5.0, 0.0, 0.0), 10.0, 10.0, 10.0).Shape(); + const TopoDS_Shape aToolFace = MakePlaneFace(-20.0, 20.0, -20.0, 20.0, 5.0); + + BRepAlgoAPI_Splitter aSplitter; + NCollection_List anArguments; + anArguments.Append(aBox); + aSplitter.SetArguments(anArguments); + NCollection_List aTools; + aTools.Append(aToolBox); + aTools.Append(aToolFace); + aSplitter.SetTools(aTools); + aSplitter.SetRunParallel(false); + aSplitter.Build(); + ASSERT_FALSE(aSplitter.HasErrors()); + + const TopoDS_Shape& aSplitResult = aSplitter.Shape(); + ASSERT_FALSE(aSplitResult.IsNull()); + ExpectShapeCount(aSplitResult, TopAbs_SOLID, 4); + EXPECT_NEAR(BOPTest_Utilities::GetVolume(aSplitResult), 1000.0, Precision::Confusion()); +} + +// Equivalent to tests/boolean/splitter/B3. +TEST(BRepAlgoAPI_SplitterTest, B3_ApiPlaneSplitBySphere_ProducesTwoFaces) +{ + const TopoDS_Shape aFace = MakePlaneFace(-20.0, 20.0, -20.0, 20.0); + const TopoDS_Shape aSphere = BRepPrimAPI_MakeSphere(5.0).Shape(); + const TopoDS_Shape aResult = SplitWithBRepAlgoAPI(aFace, aSphere); + + ASSERT_FALSE(aResult.IsNull()); + ExpectShapeCount(aResult, TopAbs_FACE, 2); + EXPECT_NEAR(BOPTest_Utilities::GetSurfaceArea(aResult), 1600.0, Precision::Confusion()); +} + +// Equivalent to tests/boolean/splitter/A4. +TEST(BRepAlgoAPI_SplitterTest, A4_CylinderFaceSplitByIsoEdges_ProducesHundredFaces) +{ + const TopoDS_Shape aFace = MakeCylinderFace(); + const TopoDS_Shape anEdges = MakeCylinderIsoEdges(); + const TopoDS_Shape aResult = SplitCylinderFaceWithBOPAlgo(aFace, anEdges); + + ASSERT_FALSE(aResult.IsNull()); + ExpectShapeCount(aResult, TopAbs_FACE, 100); + EXPECT_NEAR(BOPTest_Utilities::GetSurfaceArea(aResult), 2513.27, 0.01); +} + +// Equivalent to tests/boolean/splitter/B4. +TEST(BRepAlgoAPI_SplitterTest, B4_ApiCylinderFaceSplitByIsoEdges_ProducesHundredFaces) +{ + const TopoDS_Shape aFace = MakeCylinderFace(); + const TopoDS_Shape anEdges = MakeCylinderIsoEdges(); + const TopoDS_Shape aResult = SplitCylinderFaceWithBRepAlgoAPI(aFace, anEdges); + + ASSERT_FALSE(aResult.IsNull()); + ExpectShapeCount(aResult, TopAbs_FACE, 100); + EXPECT_NEAR(BOPTest_Utilities::GetSurfaceArea(aResult), 2513.27, 0.01); +} + +// Equivalent to tests/boolean/splitter/A6. +TEST(BRepAlgoAPI_SplitterTest, A6_PlateSplitByCylinderGrid_ProducesFourHundredFortyTwoSolids) +{ + const TopoDS_Shape aPlate = BRepPrimAPI_MakeBox(100.0, 100.0, 1.0).Shape(); + const TopoDS_Shape aCylinders = MakeCylinderGrid(); + const TopoDS_Shape aResult = SplitWithBOPAlgo(aPlate, aCylinders); + + ASSERT_FALSE(aResult.IsNull()); + ExpectShapeCount(aResult, TopAbs_SOLID, 442); + EXPECT_NEAR(BOPTest_Utilities::GetVolume(aResult), 10000.0, Precision::Confusion()); +} + +// Equivalent to tests/boolean/splitter/B6. +TEST(BRepAlgoAPI_SplitterTest, B6_ApiPlateSplitByCylinderGrid_ProducesFourHundredFortyTwoSolids) +{ + const TopoDS_Shape aPlate = BRepPrimAPI_MakeBox(100.0, 100.0, 1.0).Shape(); + const TopoDS_Shape aCylinders = MakeCylinderGrid(); + const TopoDS_Shape aResult = SplitWithBRepAlgoAPI(aPlate, aCylinders); + + ASSERT_FALSE(aResult.IsNull()); + ExpectShapeCount(aResult, TopAbs_SOLID, 442); + EXPECT_NEAR(BOPTest_Utilities::GetVolume(aResult), 10000.0, Precision::Confusion()); +} diff --git a/src/ModelingAlgorithms/TKBO/GTests/BRepTools_History_Test.cxx b/src/ModelingAlgorithms/TKBO/GTests/BRepTools_History_Test.cxx new file mode 100644 index 0000000000..72a9f51103 --- /dev/null +++ b/src/ModelingAlgorithms/TKBO/GTests/BRepTools_History_Test.cxx @@ -0,0 +1,359 @@ +// Copyright (c) 2026 OPEN CASCADE SAS +// +// This file is part of Open CASCADE Technology software library. +// +// This library is free software; you can redistribute it and/or modify it under +// the terms of the GNU Lesser General Public License version 2.1 as published +// by the Free Software Foundation, with special exception defined in the file +// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT +// distribution for complete text of the license and disclaimer of any warranty. +// +// Alternatively, this file may be used under the terms of Open CASCADE +// commercial license or contractual agreement. + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace +{ +static int CountShapes(const NCollection_List& theShapes, + const TopAbs_ShapeEnum theType) +{ + NCollection_IndexedMap aMap; + for (NCollection_List::Iterator anIterator(theShapes); anIterator.More(); + anIterator.Next()) + { + TopExp::MapShapes(anIterator.Value(), aMap); + } + + int aCount = 0; + for (int anIndex = 1; anIndex <= aMap.Extent(); ++anIndex) + { + if (aMap(anIndex).ShapeType() == theType) + { + ++aCount; + } + } + return aCount; +} + +static void ExpectHistory(const BRepTools_History& theHistory, + const TopoDS_Shape& theShape, + const bool theDeleted, + const TopAbs_ShapeEnum theModifiedType, + const int theModifiedCount, + const TopAbs_ShapeEnum theGeneratedType, + const int theGeneratedCount) +{ + EXPECT_EQ(theHistory.IsRemoved(theShape), theDeleted); + EXPECT_EQ(CountShapes(theHistory.Modified(theShape), theModifiedType), theModifiedCount); + EXPECT_EQ(CountShapes(theHistory.Generated(theShape), theGeneratedType), theGeneratedCount); +} + +static TopoDS_Edge MakeCircleEdge(const gp_Pnt& theCenter, const double theRadius) +{ + return BRepBuilderAPI_MakeEdge(gp_Circ(gp_Ax2(theCenter, gp::DZ()), theRadius)).Edge(); +} + +static TopoDS_Face MakeRectangleFace(const double theFirstX, + const double theLastX, + const double theFirstY, + const double theLastY) +{ + return BRepBuilderAPI_MakeFace(gp_Pln(gp_Pnt(0.0, 0.0, 0.0), gp::DZ()), + theFirstX, + theLastX, + theFirstY, + theLastY) + .Face(); +} + +static TopoDS_Face MakePolygonFace() +{ + BRepBuilderAPI_MakePolygon aPolygon; + aPolygon.Add(gp_Pnt(-5.0, 0.0, -5.0)); + aPolygon.Add(gp_Pnt(-5.0, 0.0, 10.0)); + aPolygon.Add(gp_Pnt(5.0, 0.0, 10.0)); + aPolygon.Add(gp_Pnt(5.0, 0.0, -5.0)); + aPolygon.Add(gp_Pnt(2.0, 0.0, -5.0)); + aPolygon.Add(gp_Pnt(2.0, 0.0, 5.0)); + aPolygon.Add(gp_Pnt(-2.0, 0.0, 5.0)); + aPolygon.Add(gp_Pnt(-2.0, 0.0, -5.0)); + aPolygon.Close(); + return BRepBuilderAPI_MakeFace(aPolygon.Wire()).Face(); +} + +static TopoDS_Shape MakeExpandedFace(const TopoDS_Face& theFace) +{ + double aFirstU = 0.0; + double aLastU = 0.0; + double aFirstV = 0.0; + double aLastV = 0.0; + const occ::handle aSurface = BRep_Tool::Surface(theFace); + BRepTools::UVBounds(theFace, aFirstU, aLastU, aFirstV, aLastV); + return BRepBuilderAPI_MakeFace(aSurface, + aFirstU - 100.0, + aLastU + 100.0, + aFirstV - 100.0, + aLastV + 100.0, + Precision::Confusion()) + .Face(); +} + +static void ExpectBooleanHistory(const TopoDS_Shape& theFirst, + const TopoDS_Shape& theSecond, + const BOPAlgo_Operation theOperation, + const bool theFirstDeleted, + const int theFirstModified, + const int theFirstGenerated, + const bool theSecondDeleted, + const int theSecondModified, + const int theSecondGenerated) +{ + BOPAlgo_BOP* anBOP = nullptr; + BOPAlgo_BOP aBOP; + BOPAlgo_Section aSection; + BOPAlgo_Builder* anAlgorithm = nullptr; + switch (theOperation) + { + case BOPAlgo_COMMON: + anBOP = &aBOP; + break; + case BOPAlgo_FUSE: + anBOP = &aBOP; + break; + case BOPAlgo_CUT: + anBOP = &aBOP; + break; + case BOPAlgo_SECTION: + anAlgorithm = &aSection; + break; + default: + ADD_FAILURE() << "Unsupported history operation"; + return; + } + + NCollection_List anArguments; + anArguments.Append(theFirst); + anArguments.Append(theSecond); + + BOPAlgo_PaveFiller aFiller; + aFiller.SetArguments(anArguments); + aFiller.SetFuzzyValue(0.0); + aFiller.SetRunParallel(false); + aFiller.SetNonDestructive(false); + aFiller.Perform(); + ASSERT_FALSE(aFiller.HasErrors()); + + const NCollection_List& aFillerArguments = aFiller.Arguments(); + if (anBOP != nullptr) + { + anBOP->AddArgument(aFillerArguments.First()); + anBOP->AddTool(aFillerArguments.Last()); + anBOP->SetOperation(theOperation); + anAlgorithm = anBOP; + } + else + { + anAlgorithm->AddArgument(aFillerArguments.First()); + anAlgorithm->AddArgument(aFillerArguments.Last()); + } + anAlgorithm->SetRunParallel(false); + anAlgorithm->SetToFillHistory(true); + anAlgorithm->PerformWithFiller(aFiller); + if (anAlgorithm->HasErrors()) + { + Standard_SStream anErrors; + anAlgorithm->DumpErrors(anErrors); + ADD_FAILURE() << anErrors.str(); + return; + } + + const occ::handle aHistory = anAlgorithm->History(); + ASSERT_FALSE(aHistory.IsNull()); + + const TopAbs_ShapeEnum aFirstGeneratedType = + theFirst.ShapeType() == TopAbs_FACE ? TopAbs_EDGE : TopAbs_VERTEX; + const TopAbs_ShapeEnum aSecondGeneratedType = + theSecond.ShapeType() == TopAbs_FACE ? TopAbs_EDGE : TopAbs_VERTEX; + ExpectHistory(*aHistory, + theFirst, + theFirstDeleted, + theFirst.ShapeType(), + theFirstModified, + aFirstGeneratedType, + theFirstGenerated); + ExpectHistory(*aHistory, + theSecond, + theSecondDeleted, + theSecond.ShapeType(), + theSecondModified, + aSecondGeneratedType, + theSecondGenerated); +} +} // namespace + +// Equivalent to tests/boolean/history/A1. +TEST(BRepTools_HistoryTest, A1_IntersectingCircleEdges) +{ + const TopoDS_Shape anEdge1 = MakeCircleEdge(gp_Pnt(0.0, 0.0, 0.0), 10.0); + const TopoDS_Shape anEdge2 = MakeCircleEdge(gp_Pnt(10.0, 0.0, 0.0), 10.0); + + ExpectBooleanHistory(anEdge1, anEdge2, BOPAlgo_COMMON, true, 0, 0, true, 0, 0); + ExpectBooleanHistory(anEdge1, anEdge2, BOPAlgo_FUSE, false, 3, 2, false, 3, 2); + ExpectBooleanHistory(anEdge1, anEdge2, BOPAlgo_CUT, false, 3, 2, true, 0, 2); + ExpectBooleanHistory(anEdge2, anEdge1, BOPAlgo_CUT, false, 3, 2, true, 0, 2); + ExpectBooleanHistory(anEdge1, anEdge2, BOPAlgo_SECTION, true, 0, 2, true, 0, 2); +} + +// Equivalent to tests/boolean/history/A2. +TEST(BRepTools_HistoryTest, A2_IntersectingPlanarFaces) +{ + const TopoDS_Shape aFace1 = MakeRectangleFace(-10.0, 10.0, -10.0, 10.0); + const TopoDS_Shape aFace2 = MakePolygonFace(); + + ExpectBooleanHistory(aFace1, aFace2, BOPAlgo_COMMON, true, 0, 0, true, 0, 0); + ExpectBooleanHistory(aFace1, aFace2, BOPAlgo_FUSE, false, 1, 2, false, 3, 2); + ExpectBooleanHistory(aFace1, aFace2, BOPAlgo_CUT, false, 1, 2, true, 0, 2); + ExpectBooleanHistory(aFace2, aFace1, BOPAlgo_CUT, false, 3, 2, true, 0, 2); + ExpectBooleanHistory(aFace1, aFace2, BOPAlgo_SECTION, true, 0, 2, true, 0, 2); +} + +// Equivalent to tests/boolean/history/A3. +TEST(BRepTools_HistoryTest, A3_OverlappingPlanarFaces) +{ + const TopoDS_Shape aFace1 = MakeRectangleFace(-10.0, 10.0, -10.0, 10.0); + const TopoDS_Shape aFace2 = MakeRectangleFace(0.0, 20.0, -10.0, 10.0); + + ExpectBooleanHistory(aFace1, aFace2, BOPAlgo_COMMON, false, 1, 0, false, 1, 0); + ExpectBooleanHistory(aFace1, aFace2, BOPAlgo_FUSE, false, 2, 0, false, 2, 0); + ExpectBooleanHistory(aFace1, aFace2, BOPAlgo_CUT, false, 1, 0, true, 0, 0); + ExpectBooleanHistory(aFace2, aFace1, BOPAlgo_CUT, false, 1, 0, true, 0, 0); + ExpectBooleanHistory(aFace1, aFace2, BOPAlgo_SECTION, true, 0, 0, true, 0, 0); +} + +// Equivalent to tests/boolean/history/A4. +TEST(BRepTools_HistoryTest, A4_GeneralFuseEdgeAndFace) +{ + const TopoDS_Shape aFace = MakeRectangleFace(0.0, 10.0, 0.0, 10.0); + const TopoDS_Shape anEdge = + BRepBuilderAPI_MakeEdge(gp_Pnt(5.0, 5.0, -5.0), gp_Pnt(5.0, 5.0, 5.0)).Edge(); + + BOPAlgo_Builder aBuilder; + aBuilder.AddArgument(aFace); + aBuilder.AddArgument(anEdge); + aBuilder.SetRunParallel(false); + aBuilder.Perform(); + ASSERT_FALSE(aBuilder.HasErrors()); + EXPECT_FALSE(aBuilder.IsDeleted(aFace)); + EXPECT_FALSE(aBuilder.IsDeleted(anEdge)); + EXPECT_EQ(CountShapes(aBuilder.Modified(aFace), TopAbs_FACE), 1); + EXPECT_EQ(CountShapes(aBuilder.Modified(anEdge), TopAbs_EDGE), 2); + EXPECT_EQ(CountShapes(aBuilder.Generated(aFace), TopAbs_VERTEX), 1); + EXPECT_EQ(CountShapes(aBuilder.Generated(anEdge), TopAbs_VERTEX), 1); +} + +// Equivalent to tests/boolean/history/A8. +TEST(BRepTools_HistoryTest, A8_FuseAndSimplifyHistory) +{ + const TopoDS_Shape aBox1 = BRepPrimAPI_MakeBox(10.0, 10.0, 10.0).Shape(); + const TopoDS_Shape aBox2 = BRepPrimAPI_MakeBox(gp_Pnt(5.0, 0.0, 0.0), 10.0, 10.0, 10.0).Shape(); + BRepAlgoAPI_Fuse aFuse(aBox1, aBox2); + aFuse.SetRunParallel(false); + aFuse.Build(); + ASSERT_FALSE(aFuse.HasErrors()); + + int anIndex = 0; + for (TopExp_Explorer anExplorer(aBox1, TopAbs_FACE); anExplorer.More(); anExplorer.Next()) + { + if (anIndex++ < 2) + { + continue; + } + const NCollection_List& aModified = aFuse.Modified(anExplorer.Current()); + EXPECT_EQ(CountShapes(aModified, TopAbs_FACE), 2); + } + + aFuse.SimplifyResult(true, true); + anIndex = 0; + for (TopExp_Explorer anExplorer(aBox1, TopAbs_FACE); anExplorer.More(); anExplorer.Next()) + { + if (anIndex++ < 2) + { + continue; + } + const NCollection_List& aModified = aFuse.Modified(anExplorer.Current()); + EXPECT_EQ(CountShapes(aModified, TopAbs_FACE), 1); + if (!aModified.IsEmpty()) + { + GProp_GProps aProperties; + BRepGProp::SurfaceProperties(aModified.First(), aProperties); + EXPECT_NEAR(aProperties.Mass(), 150.0, Precision::Confusion()); + } + } +} + +// Equivalent to tests/boolean/history/A9. +TEST(BRepTools_HistoryTest, A9_SectionExpandedBoxFacesHistory) +{ + const TopoDS_Shape aBox = BRepPrimAPI_MakeBox(10.0, 10.0, 10.0).Shape(); + NCollection_List anInputFaces; + for (TopExp_Explorer anExplorer(aBox, TopAbs_FACE); anExplorer.More(); anExplorer.Next()) + { + const TopoDS_Shape anExpandedFace = MakeExpandedFace(TopoDS::Face(anExplorer.Current())); + anInputFaces.Append(anExpandedFace); + } + + BOPAlgo_PaveFiller aFiller; + aFiller.SetArguments(anInputFaces); + aFiller.SetFuzzyValue(0.0); + aFiller.SetRunParallel(false); + aFiller.SetNonDestructive(false); + aFiller.Perform(); + ASSERT_FALSE(aFiller.HasErrors()); + + BOPAlgo_Section aSection; + for (NCollection_List::Iterator anIterator(aFiller.Arguments()); anIterator.More(); + anIterator.Next()) + { + aSection.AddArgument(anIterator.Value()); + } + aSection.SetToFillHistory(true); + aSection.SetRunParallel(false); + aSection.PerformWithFiller(aFiller); + ASSERT_FALSE(aSection.HasErrors()); + ASSERT_FALSE(aSection.Shape().IsNull()); + const occ::handle aHistory = aSection.History(); + ASSERT_FALSE(aHistory.IsNull()); + for (NCollection_List::Iterator anIterator(anInputFaces); anIterator.More(); + anIterator.Next()) + { + EXPECT_TRUE(aHistory->IsRemoved(anIterator.Value())); + EXPECT_EQ(CountShapes(aHistory->Modified(anIterator.Value()), TopAbs_FACE), 0); + EXPECT_EQ(CountShapes(aHistory->Generated(anIterator.Value()), TopAbs_EDGE), 12); + } +} diff --git a/src/ModelingAlgorithms/TKBO/GTests/FILES.cmake b/src/ModelingAlgorithms/TKBO/GTests/FILES.cmake index e78fe1d017..3ebeddf9ca 100644 --- a/src/ModelingAlgorithms/TKBO/GTests/FILES.cmake +++ b/src/ModelingAlgorithms/TKBO/GTests/FILES.cmake @@ -2,12 +2,18 @@ set(OCCT_TKBO_GTests_FILES_LOCATION "${CMAKE_CURRENT_LIST_DIR}") set(OCCT_TKBO_GTests_FILES + BOPAlgo_CellsBuilder_Test.cxx + BOPAlgo_OpenSolid_Test.cxx + BRepTools_History_Test.cxx BRepAlgoAPI_BuilderAlgo_Test.cxx BRepAlgoAPI_Cut_Test.cxx BRepAlgoAPI_Cut_Test_1.cxx BRepAlgoAPI_Fuse_Test.cxx BRepAlgoAPI_Common_Test.cxx BOPAlgo_BOP_Test.cxx + BOPAlgo_MakePeriodic_Test.cxx BOPAlgo_PaveFiller_Test.cxx + BRepAlgoAPI_Splitter_Test.cxx + BRepAlgoAPI_Simplify_Test.cxx IntTools_FaceFace_Test.cxx ) diff --git a/src/ModelingAlgorithms/TKBO/GTests/IntTools_FaceFace_Test.cxx b/src/ModelingAlgorithms/TKBO/GTests/IntTools_FaceFace_Test.cxx index 4489a5806c..741543d8e4 100644 --- a/src/ModelingAlgorithms/TKBO/GTests/IntTools_FaceFace_Test.cxx +++ b/src/ModelingAlgorithms/TKBO/GTests/IntTools_FaceFace_Test.cxx @@ -22,10 +22,12 @@ #include #include #include +#include #include #include #include #include +#include #include #include #include @@ -422,3 +424,113 @@ TEST_F(IntTools_FaceFaceTest, OCC24005_PlaneCylinderIntersection) EXPECT_GE(aCurves.Length() + anInters.Points().Length(), 1) << "Expected at least one intersection result (curve or point)"; } + +//! Migrated from tests/lowalgos/intss/bug32850. Keep the original +//! IntTools_FaceFace path used by DRAW's bopcurves command: four intersection +//! curves must be prepared with a reached tolerance no greater than 1.e-12. +TEST_F(IntTools_FaceFaceTest, OCC32850_TrimmedCylindersKeepFourCurves) +{ + const gp_Ax3 anAxes1(gp_Pnt(25.8071575178163, 0.0, -373.974517822281), + gp_Dir(0.0, 1.0, 0.0), + gp_Dir(-1.73024882663956e-06, 0.0, 0.999999999998503)); + const gp_Ax3 anAxes2(gp_Pnt(0.0, 1974.19284248218, -373.974517822281), + gp_Dir(1.0, 0.0, 0.0), + gp_Dir(0.0, 1.73024882663956e-06, 0.999999999998503)); + const occ::handle aCylinder1 = + new Geom_CylindricalSurface(anAxes1, 408.974517822893); + const occ::handle aCylinder2 = + new Geom_CylindricalSurface(anAxes2, 408.974517822893); + + BRepBuilderAPI_MakeFace aFaceBuilder1(aCylinder1, + 0.0, + 0.0225015452057227, + -146.010003766057, + 2146.01000376606, + 1.e-7); + BRepBuilderAPI_MakeFace aFaceBuilder2(aCylinder2, + 0.0, + 0.0225015452057227, + -146.010003766057, + 946.010003766057, + 1.e-7); + ASSERT_TRUE(aFaceBuilder1.IsDone()); + ASSERT_TRUE(aFaceBuilder2.IsDone()); + + IntTools_FaceFace anInters; + anInters.SetParameters(true, false, false, 1.e-7); + anInters.Perform(aFaceBuilder1.Face(), aFaceBuilder2.Face()); + ASSERT_TRUE(anInters.IsDone()); + + anInters.PrepareLines3D(false); + const NCollection_Sequence& aCurves = anInters.Lines(); + ASSERT_EQ(aCurves.Length(), 4); + + double aMaximumTolerance = 0.0; + for (int anIndex = 1; anIndex <= aCurves.Length(); ++anIndex) + { + const IntTools_Curve& aCurve = aCurves(anIndex); + ASSERT_FALSE(aCurve.Curve().IsNull()); + aMaximumTolerance = std::max(aMaximumTolerance, aCurve.Tolerance()); + } + EXPECT_LE(aMaximumTolerance, 1.e-12); +} + +//! Migrated from tests/lowalgos/intss/bug24313. A face based on a linear +//! extrusion of a circle must be accepted by the face-face intersector when +//! paired with a plane face. +TEST_F(IntTools_FaceFaceTest, OCC24313_ExtrusionAndPlaneIntersection) +{ + const occ::handle aCircle = + new Geom_Circle(gp_Ax2(gp_Pnt(0.0, 0.0, 0.0), gp_Dir(0.0, 0.0, 1.0), gp_Dir(1.0, 0.0, 0.0)), + 100.0); + const occ::handle anExtrusion = + new Geom_SurfaceOfLinearExtrusion(aCircle, gp_Dir(0.0, 0.0, 1.0)); + const occ::handle aPlane = + new Geom_Plane(gp_Pln(gp_Pnt(0.0, 0.0, 0.0), gp_Dir(1.0, 0.0, 0.0))); + + BRep_Builder aBuilder; + TopoDS_Face anExtrusionFace; + TopoDS_Face aPlaneFace; + aBuilder.MakeFace(anExtrusionFace, anExtrusion, Precision::Confusion()); + aBuilder.MakeFace(aPlaneFace, aPlane, Precision::Confusion()); + ASSERT_FALSE(anExtrusionFace.IsNull()); + ASSERT_FALSE(aPlaneFace.IsNull()); + + IntTools_FaceFace anInters; + anInters.SetParameters(true, false, false, Precision::Confusion()); + ASSERT_NO_THROW(anInters.Perform(anExtrusionFace, aPlaneFace)); + ASSERT_TRUE(anInters.IsDone()); + anInters.PrepareLines3D(false); + EXPECT_GT(anInters.Lines().Length() + anInters.Points().Length(), 0); +} + +//! Migrated from tests/lowalgos/intss/bug23644. Coaxial conical lateral +//! faces have no regular 3D intersection curve; the face-face algorithm must +//! complete without escaping an exception. +TEST_F(IntTools_FaceFaceTest, OCC23644_CoaxialConesNoRegularCurve) +{ + BRepPrimAPI_MakeCone aConeMaker1(10.0, 0.0, 20.0); + BRepPrimAPI_MakeCone aConeMaker2(20.0, 0.0, 20.0); + const TopoDS_Shape& aSolid1 = aConeMaker1.Shape(); + const TopoDS_Shape& aSolid2 = aConeMaker2.Shape(); + ASSERT_FALSE(aSolid1.IsNull()); + ASSERT_FALSE(aSolid2.IsNull()); + + TopExp_Explorer anFaceExplorer1(aSolid1, TopAbs_FACE); + TopExp_Explorer anFaceExplorer2(aSolid2, TopAbs_FACE); + ASSERT_TRUE(anFaceExplorer1.More()); + ASSERT_TRUE(anFaceExplorer2.More()); + const TopoDS_Face aFace1 = TopoDS::Face(anFaceExplorer1.Current()); + const TopoDS_Face aFace2 = TopoDS::Face(anFaceExplorer2.Current()); + ASSERT_FALSE(aFace1.IsNull()); + ASSERT_FALSE(aFace2.IsNull()); + + IntTools_FaceFace anInters; + anInters.SetParameters(true, false, false, 1.e-7); + ASSERT_NO_THROW(anInters.Perform(aFace1, aFace2)); + ASSERT_TRUE(anInters.IsDone()); + anInters.PrepareLines3D(false); + EXPECT_EQ(anInters.Lines().Length(), 0); + ASSERT_EQ(anInters.Points().Length(), 1); + EXPECT_TRUE(anInters.Points()(1).P1().Pnt().IsEqual(gp_Pnt(0.0, 0.0, 20.0), 1.e-7)); +} diff --git a/src/ModelingAlgorithms/TKBool/GTests/BRepAlgoAPI_Section_Test.cxx b/src/ModelingAlgorithms/TKBool/GTests/BRepAlgoAPI_Section_Test.cxx index 7315c3674a..22889d467e 100644 --- a/src/ModelingAlgorithms/TKBool/GTests/BRepAlgoAPI_Section_Test.cxx +++ b/src/ModelingAlgorithms/TKBool/GTests/BRepAlgoAPI_Section_Test.cxx @@ -14,11 +14,70 @@ #include #include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include #include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include #include +namespace +{ +static TopoDS_Face MakeHalfCylinderFace(const gp_Ax3& theAxis, + const double theRadius, + const double theFirstU, + const double theLastU) +{ + const occ::handle aCylinder = + new Geom_CylindricalSurface(theAxis, theRadius); + const occ::handle aTrimmedCylinder = + new Geom_RectangularTrimmedSurface(aCylinder, theFirstU, theLastU, true); + return BRepBuilderAPI_MakeFace(aTrimmedCylinder, Precision::Confusion()).Face(); +} + +static void CheckCylinderSection(const gp_Ax3& theFirstAxis, + const double theFirstRadius, + const gp_Ax3& theSecondAxis, + const double theSecondRadius, + const double theExpectedLength) +{ + const double aPi = 3.14159265358979323846; + const TopoDS_Face aFirstFace = MakeHalfCylinderFace(theFirstAxis, theFirstRadius, 0.0, aPi); + const TopoDS_Face aSecondFace = MakeHalfCylinderFace(theSecondAxis, theSecondRadius, 0.0, aPi); + ASSERT_FALSE(aFirstFace.IsNull()); + ASSERT_FALSE(aSecondFace.IsNull()); + + BRepAlgoAPI_Section aSection(aFirstFace, aSecondFace); + aSection.Build(); + ASSERT_TRUE(aSection.IsDone()); + const TopoDS_Shape aResult = aSection.Shape(); + ASSERT_FALSE(aResult.IsNull()); + EXPECT_TRUE(BRepCheck_Analyzer(aResult).IsValid()); + + GProp_GProps aProperties; + BRepGProp::LinearProperties(aResult, aProperties); + EXPECT_NEAR(aProperties.Mass(), theExpectedLength, 0.001); +} +} // namespace + // Test OCCN2: BRepAlgoAPI_Section of a cylinder intersecting a sphere. // Migrated from QABugs_17.cxx OCCN2 TEST(BRepAlgoAPI_SectionTest, OCCN2_CylinderSphereSectionIsDone) @@ -33,3 +92,77 @@ TEST(BRepAlgoAPI_SectionTest, OCCN2_CylinderSphereSectionIsDone) EXPECT_TRUE(aSection.IsDone()); EXPECT_FALSE(aSection.Shape().IsNull()); } + +// Migrated from tests/bugs/modalg_5/bug21564. Intersections with a converted +// trimmed plane must stay two-pole curves, both with and without approximation. +TEST(BRepAlgoAPI_SectionTest, OCC21564_PlaneIntersectionKeepsTwoPoles) +{ + const occ::handle aHorizontalPlane = new Geom_Plane(gp::XOY()); + const occ::handle aTrimmedPlane = + new Geom_RectangularTrimmedSurface(aHorizontalPlane, -10.0, 10.0, -10.0, 10.0); + const occ::handle aBSplinePlane = + GeomConvert::SurfaceToBSplineSurface(aTrimmedPlane); + ASSERT_FALSE(aBSplinePlane.IsNull()); + + BRepBuilderAPI_MakeFace aHorizontalFaceBuilder(aBSplinePlane, Precision::Confusion()); + ASSERT_TRUE(aHorizontalFaceBuilder.IsDone()); + + const gp_Pln aVerticalPlane(gp_Pnt(0.0, 0.0, 0.0), gp_Dir(1.0, 0.0, 0.0)); + BRepBuilderAPI_MakeFace aVerticalFaceBuilder(aVerticalPlane, -10.0, 10.0, -10.0, 10.0); + ASSERT_TRUE(aVerticalFaceBuilder.IsDone()); + + const auto checkTwoPoleSection = [&](const bool theApproximation) { + BRepAlgoAPI_Section aSection(aHorizontalFaceBuilder.Face(), aVerticalFaceBuilder.Face(), false); + aSection.Approximation(theApproximation); + aSection.Build(); + ASSERT_TRUE(aSection.IsDone()); + + int aNbEdges = 0; + for (TopExp_Explorer anExplorer(aSection.Shape(), TopAbs_EDGE); anExplorer.More(); + anExplorer.Next()) + { + double aFirst = 0.0; + double aLast = 0.0; + const occ::handle aCurve = + BRep_Tool::Curve(TopoDS::Edge(anExplorer.Current()), aFirst, aLast); + const occ::handle aBSpline = occ::down_cast(aCurve); + ASSERT_FALSE(aBSpline.IsNull()); + EXPECT_EQ(aBSpline->NbPoles(), 2); + ++aNbEdges; + } + EXPECT_EQ(aNbEdges, 1); + }; + + checkTwoPoleSection(false); + checkTwoPoleSection(true); +} + +// Migrated from tests/bugs/modalg_5/bug23932_1. Intersecting two trimmed +// cylinders must complete without Standard_NoSuchObject and preserve length. +TEST(BRepAlgoAPI_SectionTest, ModalgBug_23932_SectionBetweenTrimmedCylinders1) +{ + CheckCylinderSection(gp_Ax3(gp_Pnt(538.57646417050069, 347.77316708315834, 183.375), + gp_Dir(0.0, -1.0, 0.0), + gp_Dir(1.0, 0.0, 0.0)), + 44.194173824159222, + gp_Ax3(gp_Pnt(859.00000000000011, 463.75990629028450, 80.865093709715211), + gp_Dir(-1.0, 0.0, 0.0), + gp_Dir(0.0, -1.0, 0.0)), + 186.78835506149036, + 326.401); +} + +// Migrated from tests/bugs/modalg_5/bug23932_2. The nearby cylinder radii +// exercise the second historical section configuration. +TEST(BRepAlgoAPI_SectionTest, ModalgBug_23932_SectionBetweenTrimmedCylinders2) +{ + CheckCylinderSection(gp_Ax3(gp_Pnt(538.57646417050069, 347.77316708315834, 183.375), + gp_Dir(0.0, -1.0, 0.0), + gp_Dir(1.0, 0.0, 0.0)), + 44.819173824159222, + gp_Ax3(gp_Pnt(859.00000000000011, 463.75990629028450, 80.865093709715211), + gp_Dir(-1.0, 0.0, 0.0), + gp_Dir(0.0, -1.0, 0.0)), + 187.41335506149036, + 330.903); +} diff --git a/src/ModelingAlgorithms/TKExpress/GTests/Expr_GeneralExpression_Test.cxx b/src/ModelingAlgorithms/TKExpress/GTests/Expr_GeneralExpression_Test.cxx index 3bd3878e8d..de8a827c41 100644 --- a/src/ModelingAlgorithms/TKExpress/GTests/Expr_GeneralExpression_Test.cxx +++ b/src/ModelingAlgorithms/TKExpress/GTests/Expr_GeneralExpression_Test.cxx @@ -89,3 +89,20 @@ TEST(Expr_GeneralExpression_Test, OCC22611_ParseNumericLiteral) EXPECT_FALSE(aExpr.IsNull()) << "Expression should not be null on iteration " << i; } } + +// fclasses/bugs/bug23403: a lexical-error input must not escape the expression +// parser as an exception. +TEST(Expr_GeneralExpression_Test, FClassesBug_23403_TabInputDoesNotThrow) +{ + occ::handle aGenerator = ExprIntrp_GenExp::Create(); + EXPECT_NO_THROW(aGenerator->Process(TCollection_AsciiString("\t"))); +} + +// fclasses/bugs/bug24897: a long invalid expression must also be rejected +// without an exception or uncontrolled exit. +TEST(Expr_GeneralExpression_Test, FClassesBug_24897_InvalidInputDoesNotThrow) +{ + occ::handle aGenerator = ExprIntrp_GenExp::Create(); + EXPECT_NO_THROW(aGenerator->Process( + TCollection_AsciiString("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"))); +} diff --git a/src/ModelingAlgorithms/TKGeomAlgo/GTests/FILES.cmake b/src/ModelingAlgorithms/TKGeomAlgo/GTests/FILES.cmake index 16f0045996..32aaca64ae 100644 --- a/src/ModelingAlgorithms/TKGeomAlgo/GTests/FILES.cmake +++ b/src/ModelingAlgorithms/TKGeomAlgo/GTests/FILES.cmake @@ -3,6 +3,7 @@ set(OCCT_TKGeomAlgo_GTests_FILES_LOCATION "${CMAKE_CURRENT_LIST_DIR}") set(OCCT_TKGeomAlgo_GTests_FILES Geom2dAPI_InterCurveCurve_Test.cxx + Geom2dAPI_ExtremaCurveCurve_Test.cxx Geom2dAPI_Interpolate_Test.cxx Geom2dAPI_PointsToBSpline_Test.cxx GeomFill_BSplineCurves_Test.cxx @@ -13,6 +14,7 @@ set(OCCT_TKGeomAlgo_GTests_FILES GeomAPI_PointsToBSpline_Test.cxx Geom2dGcc_Circ2d2TanRad_Test.cxx Geom2dGcc_Circ2d3Tan_Test.cxx + GccAna_Circ2d3Tan_Test.cxx Geom2dGcc_Lin2d2Tan_Test.cxx GeomFill_CorrectedFrenet_Test.cxx GeomFill_Gordon_Test.cxx @@ -31,6 +33,9 @@ set(OCCT_TKGeomAlgo_GTests_FILES IntSurf_LineOn2S_Test.cxx IntSurf_Quadric_Test.cxx GeomAPI_IntSS_Test.cxx + GeomAPI_IntCS_Test.cxx + GeomAPI_ExtremaCurveSurface_Test.cxx + GeomAPI_ExtremaSurfaceSurface_Test.cxx GeomAPI_ProjectPointOnSurf_Test.cxx Geom2dConvert_BSplineCurveToBezierCurve_Test.cxx TopTrans_SurfaceTransition_Test.cxx diff --git a/src/ModelingAlgorithms/TKGeomAlgo/GTests/GccAna_Circ2d3Tan_Test.cxx b/src/ModelingAlgorithms/TKGeomAlgo/GTests/GccAna_Circ2d3Tan_Test.cxx new file mode 100644 index 0000000000..b56cdac5b4 --- /dev/null +++ b/src/ModelingAlgorithms/TKGeomAlgo/GTests/GccAna_Circ2d3Tan_Test.cxx @@ -0,0 +1,343 @@ +// Copyright (c) 2026 OPEN CASCADE SAS +// +// This file is part of Open CASCADE Technology software library. +// +// This library is free software; you can redistribute it and/or modify it under +// the terms of the GNU Lesser General Public License version 2.1 as published +// by the Free Software Foundation, with special exception defined in the file +// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT +// distribution for complete text of the license and disclaimer of any warranty. +// +// Alternatively, this file may be used under the terms of Open CASCADE +// commercial license or contractual agreement. + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +namespace +{ +gp_Circ2d makeCircle(const double theX, const double theY, const double theRadius) +{ + return gp_Circ2d(gp_Ax2d(gp_Pnt2d(theX, theY), gp_Dir2d(1.0, 0.0)), theRadius); +} + +GccEnt_QualifiedCirc makeQualifiedCircle(const double theX, + const double theY, + const double theRadius) +{ + return GccEnt_QualifiedCirc(makeCircle(theX, theY, theRadius), GccEnt_unqualified); +} + +GccEnt_QualifiedLin makeQualifiedLine(const double theX, + const double theY, + const double theDX, + const double theDY) +{ + return GccEnt_QualifiedLin(gp_Lin2d(gp_Pnt2d(theX, theY), gp_Dir2d(theDX, theDY)), + GccEnt_unqualified); +} + +double circleLength(const gp_Circ2d& theCircle) +{ + const occ::handle aCurve = new Geom2d_Circle(theCircle); + Geom2dAdaptor_Curve anAdaptor(aCurve); + return GCPnts_AbscissaPoint::Length(anAdaptor); +} + +NCollection_Array1 makeExpectedLengths(const double* theValues, const int theLength) +{ + NCollection_Array1 anExpected(1, theLength); + for (int anIndex = 1; anIndex <= theLength; ++anIndex) + { + anExpected.SetValue(anIndex, theValues[anIndex - 1]); + } + return anExpected; +} + +void verifySolutionLengths(GccAna_Circ2d3Tan& theSolver, + const NCollection_Array1& theExpected) +{ + ASSERT_TRUE(theSolver.IsDone()); + ASSERT_GE(theSolver.NbSolutions(), theExpected.Length()); + + for (int anIndex = 1; anIndex <= theExpected.Length(); ++anIndex) + { + const double anExpectedLength = theExpected.Value(anIndex); + const double aTolerance = 1.e-7 * (anExpectedLength > 1.0 ? anExpectedLength : 1.0); + const gp_Circ2d aSolution = theSolver.ThisSolution(anIndex); + EXPECT_GT(aSolution.Radius(), 0.0); + EXPECT_NEAR(circleLength(aSolution), anExpectedLength, aTolerance) + << "Unexpected circumference for solution " << anIndex; + } +} + +void verifySolverDoesNotFail(GccAna_Circ2d3Tan& theSolver) +{ + ASSERT_TRUE(theSolver.IsDone()); + for (int anIndex = 1; anIndex <= theSolver.NbSolutions(); ++anIndex) + { + EXPECT_GT(theSolver.ThisSolution(anIndex).Radius(), 0.0) + << "Invalid zero-radius solution " << anIndex; + } +} +} // namespace + +// Migrated from tests/geometry/circ2d3Tan/CircleCircleCircle_11. +TEST(GccAna_Circ2d3TanTest, CircleCircleCircle_11) +{ + const GccEnt_QualifiedCirc aCircle1 = makeQualifiedCircle(0.0, 0.0, 50.0); + const GccEnt_QualifiedCirc aCircle2 = makeQualifiedCircle(20.0, 0.0, 10.0); + const GccEnt_QualifiedCirc aCircle3 = makeQualifiedCircle(0.0, 20.0, 10.0); + GccAna_Circ2d3Tan aSolver(aCircle1, aCircle2, aCircle3, Precision::Confusion()); + + const double anExpectedValues[] = {168.36566348025758, + 244.52937099154383, + 131.42863607625242, + 182.73062928272694, + 182.7306292827268, + 131.42863607625236, + 94.936311385359318, + 178.56704904481091}; + const NCollection_Array1 anExpected = makeExpectedLengths(anExpectedValues, 8); + verifySolutionLengths(aSolver, anExpected); +} + +// Migrated from tests/geometry/circ2d3Tan/CircleCirclePoint_11. +TEST(GccAna_Circ2d3TanTest, CircleCirclePoint_11) +{ + const GccEnt_QualifiedCirc aCircle1 = makeQualifiedCircle(0.0, 0.0, 10.0); + const GccEnt_QualifiedCirc aCircle2 = makeQualifiedCircle(30.0, 0.0, 20.0); + GccAna_Circ2d3Tan aSolver(aCircle1, aCircle2, gp_Pnt2d(10.0, 10.0), Precision::Confusion()); + + const double anExpectedValues[] = {13.802267767659149, 80.445511840034683}; + const NCollection_Array1 anExpected = makeExpectedLengths(anExpectedValues, 2); + verifySolutionLengths(aSolver, anExpected); +} + +// Migrated from tests/geometry/circ2d3Tan/CircleCirclePoint_12. +TEST(GccAna_Circ2d3TanTest, CircleCirclePoint_12) +{ + const GccEnt_QualifiedCirc aCircle1 = makeQualifiedCircle(0.0, 0.0, 10.0); + const GccEnt_QualifiedCirc aCircle2 = makeQualifiedCircle(30.0, 0.0, 20.0); + GccAna_Circ2d3Tan aSolver(aCircle1, aCircle2, gp_Pnt2d(7.0, 30.0), Precision::Confusion()); + + const double anExpectedValues[] = {951.90257403770727, 66.177052461460107, 190.20396243259333}; + const NCollection_Array1 anExpected = makeExpectedLengths(anExpectedValues, 3); + verifySolutionLengths(aSolver, anExpected); +} + +// Migrated from tests/geometry/circ2d3Tan/CircleLinLin_11. +TEST(GccAna_Circ2d3TanTest, CircleLinLin_11) +{ + const GccEnt_QualifiedCirc aCircle = makeQualifiedCircle(0.0, 120.0, 20.0); + const GccEnt_QualifiedLin aLine1 = makeQualifiedLine(0.0, 0.0, 10.0, 20.0); + const GccEnt_QualifiedLin aLine2 = makeQualifiedLine(0.0, 0.0, 10.0, -40.0); + GccAna_Circ2d3Tan aSolver(aCircle, aLine1, aLine2, Precision::Confusion()); + + const double anExpectedValues[] = {461.86006847878718, + 163.75801021417183, + 321.80336707682847, + 235.02950419226329}; + const NCollection_Array1 anExpected = makeExpectedLengths(anExpectedValues, 4); + verifySolutionLengths(aSolver, anExpected); +} + +// Migrated from tests/geometry/circ2d3Tan/CirclePointPoint_11. +TEST(GccAna_Circ2d3TanTest, CirclePointPoint_11) +{ + const GccEnt_QualifiedCirc aCircle = makeQualifiedCircle(0.0, 0.0, 10.0); + GccAna_Circ2d3Tan aSolver(aCircle, + gp_Pnt2d(20.0, 0.0), + gp_Pnt2d(15.0, 5.0), + Precision::Confusion()); + + const double anExpectedValues[] = {157.07963267948966, 31.415926535897931}; + const NCollection_Array1 anExpected = makeExpectedLengths(anExpectedValues, 2); + verifySolutionLengths(aSolver, anExpected); +} + +// Migrated from tests/geometry/circ2d3Tan/CirclePointPoint_21. +TEST(GccAna_Circ2d3TanTest, CirclePointPoint_21) +{ + const GccEnt_QualifiedCirc aCircle = makeQualifiedCircle(0.0, 0.0, 10.0); + GccAna_Circ2d3Tan aSolver(aCircle, + gp_Pnt2d(5.0, 0.0), + gp_Pnt2d(0.0, 5.0), + Precision::Confusion()); + + const double anExpectedValues[] = {45.424379479936995, 26.383452602115419}; + const NCollection_Array1 anExpected = makeExpectedLengths(anExpectedValues, 2); + verifySolutionLengths(aSolver, anExpected); +} + +// Migrated from tests/geometry/circ2d3Tan/LinLinLin_11. +TEST(GccAna_Circ2d3TanTest, LinLinLin_11) +{ + const GccEnt_QualifiedLin aLine1 = makeQualifiedLine(0.0, 0.0, 10.0, 20.0); + const GccEnt_QualifiedLin aLine2 = makeQualifiedLine(0.0, 0.0, 10.0, -40.0); + const GccEnt_QualifiedLin aLine3 = makeQualifiedLine(160.0, 0.0, -40.0, 10.0); + GccAna_Circ2d3Tan aSolver(aLine1, aLine2, aLine3, Precision::Confusion()); + + const double anExpectedValues[] = {213.09795279419643, + 284.90187851033369, + 131.38343888467227, + 63.235238531994284}; + const NCollection_Array1 anExpected = makeExpectedLengths(anExpectedValues, 4); + verifySolutionLengths(aSolver, anExpected); +} + +// Migrated from tests/geometry/circ2d3Tan/LinLinPoint_11. +TEST(GccAna_Circ2d3TanTest, LinLinPoint_11) +{ + const GccEnt_QualifiedLin aLine1 = makeQualifiedLine(0.0, 0.0, 10.0, 20.0); + const GccEnt_QualifiedLin aLine2 = makeQualifiedLine(0.0, 0.0, 10.0, -40.0); + GccAna_Circ2d3Tan aSolver(aLine1, aLine2, gp_Pnt2d(10.0, 80.0), Precision::Confusion()); + + const double anExpectedValues[] = {269.03484941268533, 130.52381207643296}; + const NCollection_Array1 anExpected = makeExpectedLengths(anExpectedValues, 2); + verifySolutionLengths(aSolver, anExpected); +} + +// Migrated from tests/geometry/circ2d3Tan/LinPointPoint_11. +TEST(GccAna_Circ2d3TanTest, LinPointPoint_11) +{ + const GccEnt_QualifiedLin aLine = makeQualifiedLine(0.0, 0.0, 10.0, 20.0); + GccAna_Circ2d3Tan aSolver(aLine, + gp_Pnt2d(10.0, 10.0), + gp_Pnt2d(100.0, 10.0), + Precision::Confusion()); + + const double anExpectedValues[] = {419.71016104587477, 282.77131205819785}; + const NCollection_Array1 anExpected = makeExpectedLengths(anExpectedValues, 2); + verifySolutionLengths(aSolver, anExpected); +} + +// Migrated from tests/geometry/circ2d3Tan/CircleCirclePoint_14. +TEST(GccAna_Circ2d3TanTest, CircleCirclePoint_14) +{ + const GccEnt_QualifiedCirc aCircle1 = makeQualifiedCircle(0.0, 0.0, 10.0); + const GccEnt_QualifiedCirc aCircle2 = makeQualifiedCircle(30.0, 0.0, 20.0); + GccAna_Circ2d3Tan aSolver(aCircle1, aCircle2, gp_Pnt2d(30.0, -20.0), Precision::Confusion()); + + const double anExpectedValues[] = {125.6637061435916, 376.99111854338514, 376.99111854338514}; + const NCollection_Array1 anExpected = makeExpectedLengths(anExpectedValues, 3); + verifySolutionLengths(aSolver, anExpected); +} + +// Migrated from tests/geometry/circ2d3Tan/CirclePointPoint_12. +TEST(GccAna_Circ2d3TanTest, CirclePointPoint_12) +{ + const GccEnt_QualifiedCirc aCircle = makeQualifiedCircle(0.0, 0.0, 10.0); + GccAna_Circ2d3Tan aSolver(aCircle, + gp_Pnt2d(20.0, 0.0), + gp_Pnt2d(10.0, 0.0), + Precision::Confusion()); + verifySolverDoesNotFail(aSolver); +} + +// Migrated from tests/geometry/circ2d3Tan/CirclePointPoint_13. +TEST(GccAna_Circ2d3TanTest, CirclePointPoint_13) +{ + const GccEnt_QualifiedCirc aCircle = makeQualifiedCircle(0.0, 0.0, 10.0); + GccAna_Circ2d3Tan aSolver(aCircle, + gp_Pnt2d(20.0, 0.0), + gp_Pnt2d(0.0, 10.0), + Precision::Confusion()); + + const double anExpectedValues[] = {157.07963267948978, 157.07963267948978}; + const NCollection_Array1 anExpected = makeExpectedLengths(anExpectedValues, 2); + verifySolutionLengths(aSolver, anExpected); +} + +// Migrated from tests/geometry/circ2d3Tan/CirclePointPoint_14. +TEST(GccAna_Circ2d3TanTest, CirclePointPoint_14) +{ + const GccEnt_QualifiedCirc aCircle = makeQualifiedCircle(0.0, 0.0, 10.0); + GccAna_Circ2d3Tan aSolver(aCircle, + gp_Pnt2d(20.0, 0.0), + gp_Pnt2d(5.0, 5.0), + Precision::Confusion()); + verifySolverDoesNotFail(aSolver); +} + +// Migrated from tests/geometry/circ2d3Tan/CirclePointPoint_15. +TEST(GccAna_Circ2d3TanTest, CirclePointPoint_15) +{ + const GccEnt_QualifiedCirc aCircle = makeQualifiedCircle(0.0, 0.0, 10.0); + GccAna_Circ2d3Tan aSolver(aCircle, + gp_Pnt2d(20.0, 0.0), + gp_Pnt2d(-20.0, 0.0), + Precision::Confusion()); + + const double anExpectedValues[] = {157.07963267948966, 157.07963267948966}; + const NCollection_Array1 anExpected = makeExpectedLengths(anExpectedValues, 2); + verifySolutionLengths(aSolver, anExpected); +} + +// Migrated from tests/geometry/circ2d3Tan/CirclePointPoint_22. +TEST(GccAna_Circ2d3TanTest, CirclePointPoint_22) +{ + const GccEnt_QualifiedCirc aCircle = makeQualifiedCircle(0.0, 0.0, 10.0); + GccAna_Circ2d3Tan aSolver(aCircle, + gp_Pnt2d(5.0, 0.0), + gp_Pnt2d(0.0, 0.0), + Precision::Confusion()); + + const double anExpectedValues[] = {31.415926535897931, 31.415926535897931}; + const NCollection_Array1 anExpected = makeExpectedLengths(anExpectedValues, 2); + verifySolutionLengths(aSolver, anExpected); +} + +// Migrated from tests/geometry/circ2d3Tan/CirclePointPoint_24. +TEST(GccAna_Circ2d3TanTest, CirclePointPoint_24) +{ + const GccEnt_QualifiedCirc aCircle = makeQualifiedCircle(0.0, 0.0, 10.0); + GccAna_Circ2d3Tan aSolver(aCircle, + gp_Pnt2d(5.0, 0.0), + gp_Pnt2d(0.0, 10.0), + Precision::Confusion()); + + const double anExpectedValues[] = {39.269908169872416}; + const NCollection_Array1 anExpected = makeExpectedLengths(anExpectedValues, 1); + verifySolutionLengths(aSolver, anExpected); +} + +// Migrated from tests/geometry/circ2d3Tan/CirclePointPoint_31. +TEST(GccAna_Circ2d3TanTest, CirclePointPoint_31) +{ + const GccEnt_QualifiedCirc aCircle = makeQualifiedCircle(0.0, 0.0, 10.0); + GccAna_Circ2d3Tan aSolver(aCircle, + gp_Pnt2d(10.0, 0.0), + gp_Pnt2d(0.0, 10.0), + Precision::Confusion()); + + const double anExpectedValues[] = {62.831853071795862}; + const NCollection_Array1 anExpected = makeExpectedLengths(anExpectedValues, 1); + verifySolutionLengths(aSolver, anExpected); +} + +// Migrated from tests/geometry/circ2d3Tan/PointPointPoint_11. +TEST(GccAna_Circ2d3TanTest, PointPointPoint_11) +{ + GccAna_Circ2d3Tan aSolver(gp_Pnt2d(0.0, 50.0), + gp_Pnt2d(30.0, 20.0), + gp_Pnt2d(150.0, 150.0), + Precision::Confusion()); + + const double anExpectedValues[] = {566.81157580298293}; + const NCollection_Array1 anExpected = makeExpectedLengths(anExpectedValues, 1); + verifySolutionLengths(aSolver, anExpected); +} diff --git a/src/ModelingAlgorithms/TKGeomAlgo/GTests/Geom2dAPI_ExtremaCurveCurve_Test.cxx b/src/ModelingAlgorithms/TKGeomAlgo/GTests/Geom2dAPI_ExtremaCurveCurve_Test.cxx new file mode 100644 index 0000000000..68038e8915 --- /dev/null +++ b/src/ModelingAlgorithms/TKGeomAlgo/GTests/Geom2dAPI_ExtremaCurveCurve_Test.cxx @@ -0,0 +1,49 @@ +// Copyright (c) 2026 OPEN CASCADE SAS +// +// This file is part of Open CASCADE Technology software library. +// +// This library is free software; you can redistribute it and/or modify it under +// the terms of the GNU Lesser General Public License version 2.1 as published +// by the Free Software Foundation, with special exception defined in the file +// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT +// distribution for complete text of the license and disclaimer of any warranty. +// +// Alternatively, this file may be used under the terms of Open CASCADE +// commercial license or contractual agreement. + +#include + +#include +#include +#include +#include +#include +#include + +// Migrated from tests/bugs/moddata_3/bug27467. Two bounded, intersecting lines +// must yield one zero-distance extrema solution. +TEST(Geom2dAPI_ExtremaCurveCurveTest, ModDataBug_27467_IntersectingTrimmedLines) +{ + const occ::handle aLine1 = + new Geom2d_Line(gp_Lin2d(gp_Pnt2d(0.0, 0.0), gp_Dir2d(0.0, -1.0))); + const occ::handle aLine2 = + new Geom2d_Line(gp_Lin2d(gp_Pnt2d(1.0, -9.5), gp_Dir2d(-1.0, 0.0))); + const occ::handle aTrimmedLine1 = new Geom2d_TrimmedCurve(aLine1, 0.0, 23.0); + const occ::handle aTrimmedLine2 = new Geom2d_TrimmedCurve(aLine2, 0.0, 2.0); + + Geom2dAPI_ExtremaCurveCurve anExtrema(aTrimmedLine1, + aTrimmedLine2, + aTrimmedLine1->FirstParameter(), + aTrimmedLine1->LastParameter(), + aTrimmedLine2->FirstParameter(), + aTrimmedLine2->LastParameter()); + ASSERT_EQ(anExtrema.NbExtrema(), 1); + + gp_Pnt2d aPoint1, aPoint2; + anExtrema.Points(1, aPoint1, aPoint2); + EXPECT_NEAR(anExtrema.Distance(1), 0.0, 1.0e-9); + EXPECT_NEAR(aPoint1.X(), 0.0, 1.0e-9); + EXPECT_NEAR(aPoint1.Y(), -9.5, 1.0e-9); + EXPECT_NEAR(aPoint2.X(), 0.0, 1.0e-9); + EXPECT_NEAR(aPoint2.Y(), -9.5, 1.0e-9); +} diff --git a/src/ModelingAlgorithms/TKGeomAlgo/GTests/Geom2dAPI_InterCurveCurve_Test.cxx b/src/ModelingAlgorithms/TKGeomAlgo/GTests/Geom2dAPI_InterCurveCurve_Test.cxx index aadc84290d..6466bced93 100644 --- a/src/ModelingAlgorithms/TKGeomAlgo/GTests/Geom2dAPI_InterCurveCurve_Test.cxx +++ b/src/ModelingAlgorithms/TKGeomAlgo/GTests/Geom2dAPI_InterCurveCurve_Test.cxx @@ -12,7 +12,11 @@ // commercial license or contractual agreement. #include +#include #include +#include +#include +#include #include #include #include @@ -24,6 +28,70 @@ #include +namespace +{ +occ::handle createOCC23706Curve1() +{ + NCollection_Array1 aPoles(1, 6); + aPoles(1) = gp_Pnt2d(2.0, 0.0); + aPoles(2) = gp_Pnt2d(3.0, -1.0); + aPoles(3) = gp_Pnt2d(5.0, 5.0); + aPoles(4) = gp_Pnt2d(5.0, 5.0); + aPoles(5) = gp_Pnt2d(6.0, 8.0); + aPoles(6) = gp_Pnt2d(4.0, 7.0); + + NCollection_Array1 aKnots(1, 5); + aKnots(1) = 0.0; + aKnots(2) = 0.2; + aKnots(3) = 0.3; + aKnots(4) = 0.4; + aKnots(5) = 0.5; + + NCollection_Array1 aMultiplicities(1, 5); + aMultiplicities(1) = 3; + aMultiplicities(2) = 1; + aMultiplicities(3) = 1; + aMultiplicities(4) = 1; + aMultiplicities(5) = 3; + + NCollection_Array1 aWeights(1, 6); + for (int anIndex = aWeights.Lower(); anIndex <= aWeights.Upper(); ++anIndex) + { + aWeights(anIndex) = 1.0; + } + return new Geom2d_BSplineCurve(aPoles, aWeights, aKnots, aMultiplicities, 2); +} + +occ::handle createOCC23706Curve2(const bool thePerturbed) +{ + NCollection_Array1 aPoles(1, 5); + aPoles(1) = gp_Pnt2d(6.0, 3.0); + aPoles(2) = gp_Pnt2d(thePerturbed ? 5.001 : 5.0, thePerturbed ? 5.01 : 5.0); + aPoles(3) = aPoles(2); + aPoles(4) = gp_Pnt2d(3.0, 9.0); + aPoles(5) = gp_Pnt2d(2.0, 11.0); + + NCollection_Array1 aKnots(1, 4); + aKnots(1) = 1.0; + aKnots(2) = 2.0; + aKnots(3) = 3.0; + aKnots(4) = 5.0; + + NCollection_Array1 aMultiplicities(1, 4); + aMultiplicities(1) = 3; + aMultiplicities(2) = 1; + aMultiplicities(3) = 1; + aMultiplicities(4) = 3; + + NCollection_Array1 aWeights(1, 5); + for (int anIndex = aWeights.Lower(); anIndex <= aWeights.Upper(); ++anIndex) + { + aWeights(anIndex) = 1.0; + } + return new Geom2d_BSplineCurve(aPoles, aWeights, aKnots, aMultiplicities, 2); +} +} // namespace + TEST(Geom2dAPI_InterCurveCurve_Test, OCC29289_EllipseIntersectionNewtonRoot) { // Create two ellipses @@ -104,3 +172,64 @@ TEST(Geom2dAPI_InterCurveCurve_Test, Init_NullHandle_RaisesException) EXPECT_THROW(anInter.Init(aNullCurve, 1.0e-7), Standard_NullObject); #endif } + +// Migrated from tests/lowalgos/2dinter/bug23706_4. Preserve the rounded +// four-decimal coordinate checks used by the DRAW regression. +TEST(Geom2dAPI_InterCurveCurve_Test, OCC23706_4_BSplineIntersectionCoordinates) +{ + const occ::handle aCurve1 = createOCC23706Curve1(); + const occ::handle aCurve2 = createOCC23706Curve2(true); + Geom2dAPI_InterCurveCurve anIntersector(aCurve1, aCurve2, 0.001); + + ASSERT_EQ(anIntersector.NbPoints(), 2); + const gp_Pnt2d aPoint1 = anIntersector.Point(1); + const gp_Pnt2d aPoint2 = anIntersector.Point(2); + EXPECT_NEAR(aPoint1.X(), 5.0024, 1.e-4); + EXPECT_NEAR(aPoint1.Y(), 5.0072, 1.e-4); + EXPECT_NEAR(aPoint2.X(), 4.0024, 1.e-4); + EXPECT_NEAR(aPoint2.Y(), 7.0012, 1.e-4); +} + +// Migrated from tests/lowalgos/2dinter/bug23706_5. The original script used +// integer truncation for the second point, so retain that intent with ranges. +TEST(Geom2dAPI_InterCurveCurve_Test, OCC23706_5_BSplineIntersectionCoordinates) +{ + const occ::handle aCurve1 = createOCC23706Curve1(); + const occ::handle aCurve2 = createOCC23706Curve2(false); + Geom2dAPI_InterCurveCurve anIntersector(aCurve1, aCurve2, 0.001); + + ASSERT_EQ(anIntersector.NbPoints(), 2); + const gp_Pnt2d aPoint1 = anIntersector.Point(1); + const gp_Pnt2d aPoint2 = anIntersector.Point(2); + EXPECT_NEAR(aPoint1.X(), 5.0, 1.e-7); + EXPECT_NEAR(aPoint1.Y(), 5.0, 1.e-7); + EXPECT_GE(aPoint2.X(), 4.0); + EXPECT_LT(aPoint2.X(), 5.0); + EXPECT_GE(aPoint2.Y(), 7.0); + EXPECT_LT(aPoint2.Y(), 8.0); +} + +// Migrated from tests/lowalgos/2dinter/bug29162. The DRAW command uses its +// default 1.e-3 intersection tolerance. +TEST(Geom2dAPI_InterCurveCurve_Test, OCC29162_TrimmedEllipseLineIntersection) +{ + const occ::handle anEllipse = + new Geom2d_Ellipse(gp_Ax22d(gp_Pnt2d(-610.348096534595, -710.720096056787), + gp_Dir2d(0.999999902285153, 0.000442074298181498)), + 15.0066332711999, + 0.291884102212871); + const occ::handle aTrimmedEllipse = + new Geom2d_TrimmedCurve(anEllipse, 3.09462291909258, 9.37780822627216); + + const occ::handle aLine = + new Geom2d_Line(gp_Pnt2d(-625.34430362036, -680.713463264921), + gp_Dir2d(-0.000252749178714602, -0.999999968058926)); + const occ::handle aTrimmedLine = + new Geom2d_TrimmedCurve(aLine, 0.0, 30.0132665523925); + + Geom2dAPI_InterCurveCurve anIntersector(aTrimmedEllipse, aTrimmedLine, 0.001); + ASSERT_EQ(anIntersector.NbPoints(), 1); + const gp_Pnt2d aPoint = anIntersector.Point(1); + EXPECT_NEAR(aPoint.X(), -625.35188801291508, 1.e-7); + EXPECT_NEAR(aPoint.Y(), -710.72104765746838, 1.e-7); +} diff --git a/src/ModelingAlgorithms/TKGeomAlgo/GTests/Geom2dGcc_Circ2d2TanRad_Test.cxx b/src/ModelingAlgorithms/TKGeomAlgo/GTests/Geom2dGcc_Circ2d2TanRad_Test.cxx index de6cfbd3a7..2d46881bc7 100644 --- a/src/ModelingAlgorithms/TKGeomAlgo/GTests/Geom2dGcc_Circ2d2TanRad_Test.cxx +++ b/src/ModelingAlgorithms/TKGeomAlgo/GTests/Geom2dGcc_Circ2d2TanRad_Test.cxx @@ -16,13 +16,31 @@ #include #include #include +#include +#include #include #include +#include +#include +#include #include #include #include #include #include +#include + +#include + +namespace +{ +double circleLength(const gp_Circ2d& theCircle) +{ + const occ::handle aCurve = new Geom2d_Circle(theCircle); + Geom2dAdaptor_Curve anAdaptor(aCurve); + return GCPnts_AbscissaPoint::Length(anAdaptor); +} +} // namespace // Test BUC60897: Geom2dGcc_Circ2d2TanRad finds circles tangent to a line and // a Bezier curve. Verifies that each tangency point lies at the circle radius @@ -79,3 +97,168 @@ TEST(Geom2dGcc_Circ2d2TanRadTest, BUC60897_TangentToLineAndBezier) << "Solution " << i << ": tangency2 distance error " << aDelta2 << "% exceeds 1%"; } } + +// Migrated from tests/lowalgos/2dgcc/buc60607_1. Keep the two solution +// lengths produced by a point/line fixed-radius construction. +TEST(Geom2dGcc_Circ2d2TanRadTest, BUC60607_1_PointLineFixedRadius) +{ + const occ::handle aLine = + new Geom2d_Line(gp_Pnt2d(0.0, 500.0), gp_Dir2d(2000.0, 500.0)); + Geom2dAdaptor_Curve anAdaptor(aLine); + Geom2dGcc_QualifiedCurve aQualifiedLine = Geom2dGcc::Unqualified(anAdaptor); + + Geom2dGcc_Circ2d2TanRad aSolver(aQualifiedLine, + new Geom2d_CartesianPoint(gp_Pnt2d(1600.0, 300.0)), + 400.0, + Precision::Confusion()); + ASSERT_TRUE(aSolver.IsDone()); + ASSERT_EQ(aSolver.NbSolutions(), 2); + + for (int anIndex = 1; anIndex <= aSolver.NbSolutions(); ++anIndex) + { + EXPECT_NEAR(circleLength(aSolver.ThisSolution(anIndex)), + 2513.2741228718346, + 2513.2741228718346 * 1.e-8); + } +} + +// Migrated from tests/lowalgos/2dgcc/buc60607_2. The DRAW case did not +// print a result, but the construction is a valid no-solution configuration. +TEST(Geom2dGcc_Circ2d2TanRadTest, BUC60607_2_PointLineFixedRadiusNoSolution) +{ + const occ::handle aLine = + new Geom2d_Line(gp_Pnt2d(0.0, 500.0), gp_Dir2d(2000.0, 500.0)); + Geom2dAdaptor_Curve anAdaptor(aLine); + Geom2dGcc_QualifiedCurve aQualifiedLine = Geom2dGcc::Unqualified(anAdaptor); + + Geom2dGcc_Circ2d2TanRad aSolver(aQualifiedLine, + new Geom2d_CartesianPoint(gp_Pnt2d(1600.0, 300.0)), + 200.0, + Precision::Confusion()); + ASSERT_TRUE(aSolver.IsDone()); + EXPECT_EQ(aSolver.NbSolutions(), 0); +} + +// Migrated from tests/lowalgos/2dgcc/buc60607_3. Preserve the exact DRAW +// line definition (the last two values are its direction, not an endpoint). +TEST(Geom2dGcc_Circ2d2TanRadTest, BUC60607_3_PointLineFixedRadiusNoSolution) +{ + const occ::handle aLine = + new Geom2d_Line(gp_Pnt2d(3000.0, 1700.0), gp_Dir2d(1000.0, 1550.0)); + Geom2dAdaptor_Curve anAdaptor(aLine); + Geom2dGcc_QualifiedCurve aQualifiedLine = Geom2dGcc::Unqualified(anAdaptor); + + Geom2dGcc_Circ2d2TanRad aSolver(aQualifiedLine, + new Geom2d_CartesianPoint(gp_Pnt2d(1400.0, 1400.0)), + 300.0, + Precision::Confusion()); + ASSERT_TRUE(aSolver.IsDone()); + EXPECT_EQ(aSolver.NbSolutions(), 0); +} + +// Migrated from tests/lowalgos/2dgcc/buc60607_4. This is the same geometry +// as BUC60607_3 with the smaller requested radius. +TEST(Geom2dGcc_Circ2d2TanRadTest, BUC60607_4_PointLineFixedRadiusNoSolution) +{ + const occ::handle aLine = + new Geom2d_Line(gp_Pnt2d(3000.0, 1700.0), gp_Dir2d(1000.0, 1550.0)); + Geom2dAdaptor_Curve anAdaptor(aLine); + Geom2dGcc_QualifiedCurve aQualifiedLine = Geom2dGcc::Unqualified(anAdaptor); + + Geom2dGcc_Circ2d2TanRad aSolver(aQualifiedLine, + new Geom2d_CartesianPoint(gp_Pnt2d(1400.0, 1400.0)), + 150.0, + Precision::Confusion()); + ASSERT_TRUE(aSolver.IsDone()); + EXPECT_EQ(aSolver.NbSolutions(), 0); +} + +// Migrated from tests/lowalgos/2dgcc/buc60941. The DRAW regression is about +// the two-curve constructor not raising while processing a BSpline curve. +TEST(Geom2dGcc_Circ2d2TanRadTest, BUC60941_TwoCurveFixedRadiusDoesNotThrow) +{ + const occ::handle aCircle = new Geom2d_Circle( + gp_Circ2d(gp_Ax2d(gp_Pnt2d(1.79356127430613, -11.9148900515605), gp_Dir2d(1.0, 0.0)), + 12.0491272292007)); + + NCollection_Array1 aPoles(1, 6); + aPoles(1) = gp_Pnt2d(0.0, 0.0); + aPoles(2) = gp_Pnt2d(-2.14533906935467, 4.92056269221697); + aPoles(3) = gp_Pnt2d(-0.537398638327716, 10.0937503357781); + aPoles(4) = gp_Pnt2d(10.3564232507092, 8.73929826869582); + aPoles(5) = gp_Pnt2d(16.6366922939454, 3.11858911810943); + aPoles(6) = gp_Pnt2d(16.39, -0.262); + + NCollection_Array1 aKnots(1, 4); + aKnots(1) = 0.0; + aKnots(2) = 8.6971225126475; + aKnots(3) = 16.903955884905; + aKnots(4) = 28.0087167558108; + + NCollection_Array1 aMultiplicities(1, 4); + aMultiplicities(1) = 4; + aMultiplicities(2) = 1; + aMultiplicities(3) = 1; + aMultiplicities(4) = 4; + + NCollection_Array1 aWeights(1, 6); + for (int anIndex = aWeights.Lower(); anIndex <= aWeights.Upper(); ++anIndex) + { + aWeights(anIndex) = 1.0; + } + const occ::handle aBSpline = + new Geom2d_BSplineCurve(aPoles, aWeights, aKnots, aMultiplicities, 3); + + Geom2dAdaptor_Curve anAdaptor1(aCircle); + Geom2dAdaptor_Curve anAdaptor2(aBSpline); + Geom2dGcc_QualifiedCurve aQualifiedCircle = Geom2dGcc::Unqualified(anAdaptor1); + Geom2dGcc_QualifiedCurve aQualifiedBSpline = Geom2dGcc::Unqualified(anAdaptor2); + + bool anIsDone = false; + int aNbSolutions = -1; + EXPECT_NO_THROW({ + Geom2dGcc_Circ2d2TanRad aSolver(aQualifiedCircle, + aQualifiedBSpline, + 2.0, + Precision::Confusion()); + anIsDone = aSolver.IsDone(); + if (anIsDone) + { + aNbSolutions = aSolver.NbSolutions(); + } + }); + EXPECT_TRUE(anIsDone); + EXPECT_GE(aNbSolutions, 0); +} + +// Migrated from tests/lowalgos/2dgcc/bug29694. This keeps the center and +// radius checks from the DRAW script while using the algorithm API directly. +TEST(Geom2dGcc_Circ2d2TanRadTest, Bug29694_CurvePointCenter) +{ + NCollection_Array1 aPoles(1, 2); + aPoles(1) = gp_Pnt2d(-10.0, -5.0); + aPoles(2) = gp_Pnt2d(10.0, -5.0); + + NCollection_Array1 aKnots(1, 2); + aKnots(1) = 0.0; + aKnots(2) = 1.0; + + NCollection_Array1 aMultiplicities(1, 2); + aMultiplicities(1) = 2; + aMultiplicities(2) = 2; + const occ::handle aSegment = + new Geom2d_BSplineCurve(aPoles, aKnots, aMultiplicities, 1); + + Geom2dAdaptor_Curve anAdaptor(aSegment); + Geom2dGcc_QualifiedCurve aQualifiedSegment = Geom2dGcc::Unqualified(anAdaptor); + Geom2dGcc_Circ2dTanCen aSolver(aQualifiedSegment, + new Geom2d_CartesianPoint(gp_Pnt2d(1.0, 1.0)), + Precision::Confusion()); + + ASSERT_TRUE(aSolver.IsDone()); + ASSERT_EQ(aSolver.NbSolutions(), 1); + const gp_Circ2d aSolution = aSolver.ThisSolution(1); + EXPECT_NEAR(aSolution.Location().X(), 1.0, 1.e-7); + EXPECT_NEAR(aSolution.Location().Y(), 1.0, 1.e-7); + EXPECT_NEAR(aSolution.Radius(), 6.0, 1.e-7); +} diff --git a/src/ModelingAlgorithms/TKGeomAlgo/GTests/Geom2dGcc_Circ2d3Tan_Test.cxx b/src/ModelingAlgorithms/TKGeomAlgo/GTests/Geom2dGcc_Circ2d3Tan_Test.cxx index eb50581f60..9887553d4c 100644 --- a/src/ModelingAlgorithms/TKGeomAlgo/GTests/Geom2dGcc_Circ2d3Tan_Test.cxx +++ b/src/ModelingAlgorithms/TKGeomAlgo/GTests/Geom2dGcc_Circ2d3Tan_Test.cxx @@ -14,6 +14,7 @@ #include #include #include +#include #include #include #include @@ -21,9 +22,21 @@ #include #include #include +#include #include +namespace +{ +double circleLength(const gp_Circ2d& theCircle) +{ + const occ::handle aCurve = new Geom2d_Circle(theCircle); + Geom2dAdaptor_Curve anAdaptor(aCurve); + return GCPnts_AbscissaPoint::Length(anAdaptor); +} + +} // namespace + // Test fixture for Geom2dGcc_Circ2d3Tan testing class Geom2dGcc_Circ2d3TanTest : public ::testing::Test { @@ -154,6 +167,94 @@ TEST_F(Geom2dGcc_Circ2d3TanTest, BUC60622_RegressionCase) } } +// Migrated from tests/lowalgos/2dgcc/buc60622_1. The original DRAW case +// checked that this degenerate configuration can be passed to cirtang without +// raising an exception. +TEST_F(Geom2dGcc_Circ2d3TanTest, BUC60622_1_DegenerateThreeCircleCase) +{ + const Geom2dGcc_QualifiedCurve aQual1 = createQualifiedCircle(2900.0, 800.0, 500.0); + const Geom2dGcc_QualifiedCurve aQual2 = createQualifiedCircle(2900.0, 900.0, 400.0); + const Geom2dGcc_QualifiedCurve aQual3 = createQualifiedCircle(2900.0, 1000.0, 300.0); + + EXPECT_NO_THROW({ Geom2dGcc_Circ2d3Tan aSolver(aQual1, aQual2, aQual3, myTolerance, 0, 0, 0); }); +} + +// Migrated from tests/lowalgos/2dgcc/buc60622_2. Keep the three explicit +// solution-length checks in addition to the general regression validation. +TEST_F(Geom2dGcc_Circ2d3TanTest, BUC60622_2_AllKnownSolutionLengths) +{ + const Geom2dGcc_QualifiedCurve aQual1 = createQualifiedCircle(500.0, 1800.0, 500.0); + const Geom2dGcc_QualifiedCurve aQual2 = createQualifiedCircle(500.0, 1900.0, 400.0); + const Geom2dGcc_QualifiedCurve aQual3 = createQualifiedCircle(700.0, 1900.0, 200.0); + Geom2dGcc_Circ2d3Tan aSolver(aQual1, aQual2, aQual3, myTolerance, 0, 0, 0); + + ASSERT_TRUE(aSolver.IsDone()); + ASSERT_EQ(aSolver.NbSolutions(), 3); + + const double anExpectedLengths[] = {2513.2741228703289, 837.75804095727631, 279.2526803190928}; + for (int anIndex = 1; anIndex <= aSolver.NbSolutions(); ++anIndex) + { + EXPECT_NEAR(circleLength(aSolver.ThisSolution(anIndex)), + anExpectedLengths[anIndex - 1], + anExpectedLengths[anIndex - 1] * 1.e-8); + } +} + +// Migrated from tests/lowalgos/2dgcc/buc60622_3. The original DRAW test +// checks the lengths of all five returned tangent circles. +TEST_F(Geom2dGcc_Circ2d3TanTest, BUC60622_3_AllTangentCircleLengths) +{ + const Geom2dGcc_QualifiedCurve aQual1 = createQualifiedCircle(625.0, 3000.0, 125.0); + const Geom2dGcc_QualifiedCurve aQual2 = createQualifiedCircle(375.0, 3000.0, 125.0); + const Geom2dGcc_QualifiedCurve aQual3 = createQualifiedCircle(500.0, 3000.0, 250.0); + Geom2dGcc_Circ2d3Tan aSolver(aQual1, aQual2, aQual3, myTolerance, 0, 0, 0); + + ASSERT_TRUE(aSolver.IsDone()); + ASSERT_EQ(aSolver.NbSolutions(), 5); + + const double anExpectedLengths[] = {1570.7963267948965, + 785.39816339744868, + 785.39816339744823, + 523.59877559829806, + 523.59877559829806}; + for (int anIndex = 1; anIndex <= aSolver.NbSolutions(); ++anIndex) + { + const gp_Circ2d aSolution = aSolver.ThisSolution(anIndex); + EXPECT_NEAR(circleLength(aSolution), + anExpectedLengths[anIndex - 1], + anExpectedLengths[anIndex - 1] * 1.e-8); + } +} + +// Migrated from tests/lowalgos/2dgcc/buc60618. This preserves the eight +// solution-length checks that guard the solver's solution filtering. +TEST_F(Geom2dGcc_Circ2d3TanTest, BUC60618_FilteringKeepsAllSolutions) +{ + const Geom2dGcc_QualifiedCurve aQual1 = createQualifiedCircle(0.0, 0.0, 100.0); + const Geom2dGcc_QualifiedCurve aQual2 = createQualifiedCircle(500.0, -400.0, 300.0); + const Geom2dGcc_QualifiedCurve aQual3 = createQualifiedCircle(300.0, 200.0, 200.0); + Geom2dGcc_Circ2d3Tan aSolver(aQual1, aQual2, aQual3, myTolerance, 0, 0, 0); + + ASSERT_TRUE(aSolver.IsDone()); + ASSERT_EQ(aSolver.NbSolutions(), 8); + + const double anExpectedLengths[] = {3568.9587306060739, + 9964.7111736227271, + 2082.9371204466097, + 32696.069757517998, + 1681.9298517645602, + 3097.3731840080009, + 1545.2428620020787, + 772.26646380656518}; + for (int anIndex = 1; anIndex <= aSolver.NbSolutions(); ++anIndex) + { + const gp_Circ2d aSolution = aSolver.ThisSolution(anIndex); + EXPECT_NEAR(circleLength(aSolution), + anExpectedLengths[anIndex - 1], + anExpectedLengths[anIndex - 1] * 1.e-8); + } +} + // Test with different tolerance values to demonstrate the filtering issue TEST_F(Geom2dGcc_Circ2d3TanTest, ToleranceImpact_Analysis) { @@ -163,17 +264,17 @@ TEST_F(Geom2dGcc_Circ2d3TanTest, ToleranceImpact_Analysis) Geom2dGcc_QualifiedCurve aQual3 = createQualifiedCircle(700.0, 1900.0, 200.0); // Test with different tolerance values to ensure stability - std::vector aTestTolerances = { - Precision::Confusion(), // Default ~1e-15 - 1e-12, // Slightly larger - 1e-10, // Moderate - 1e-8 // Large - }; + NCollection_Array1 aTestTolerances(1, 4); + aTestTolerances(1) = Precision::Confusion(); // Default ~1e-15 + aTestTolerances(2) = 1e-12; // Slightly larger + aTestTolerances(3) = 1e-10; // Moderate + aTestTolerances(4) = 1e-8; // Large int aDefaultSolCount = 0; - for (double aTol : aTestTolerances) + for (int anIndex = aTestTolerances.Lower(); anIndex <= aTestTolerances.Upper(); ++anIndex) { + const double aTol = aTestTolerances(anIndex); Geom2dGcc_Circ2d3Tan aSolver(aQual1, aQual2, aQual3, aTol, 0, 0, 0); EXPECT_TRUE(aSolver.IsDone()) << "Algorithm should succeed with tolerance " << aTol; @@ -376,4 +477,4 @@ TEST_F(Geom2dGcc_Circ2d3TanTest, TouchingCircles_DegenerateCase) verifySolutionValidity(aSol, i); verifyTangencyConstraints(aSol, aInputCirc1, aInputCirc2, aInputCirc3, i); } -} \ No newline at end of file +} diff --git a/src/ModelingAlgorithms/TKGeomAlgo/GTests/GeomAPI_ExtremaCurveSurface_Test.cxx b/src/ModelingAlgorithms/TKGeomAlgo/GTests/GeomAPI_ExtremaCurveSurface_Test.cxx new file mode 100644 index 0000000000..29d979683f --- /dev/null +++ b/src/ModelingAlgorithms/TKGeomAlgo/GTests/GeomAPI_ExtremaCurveSurface_Test.cxx @@ -0,0 +1,172 @@ +// Copyright (c) 2026 OPEN CASCADE SAS +// +// This file is part of Open CASCADE Technology software library. +// +// This library is free software; you can redistribute it and/or modify it under +// the terms of the GNU Lesser General Public License version 2.1 as published +// by the Free Software Foundation, with special exception defined in the file +// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT +// distribution for complete text of the license and disclaimer of any warranty. +// +// Alternatively, this file may be used under the terms of Open CASCADE +// commercial license or contractual agreement. + +#include + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace +{ +static occ::handle makeCircle(const gp_Pnt& theCenter, + const gp_Dir& theNormal, + const double theRadius) +{ + return new Geom_Circle(gp_Ax2(theCenter, theNormal), theRadius); +} + +static occ::handle makeSphere(const double theRadius) +{ + return new Geom_SphericalSurface(gp_Ax3(gp_Pnt(0.0, 0.0, 0.0), gp_Dir(0.0, 0.0, 1.0)), theRadius); +} + +static void expectCircleSphereExtrema(const gp_Pnt& theCenter, + const gp_Dir& theNormal, + const double theCircleRadius, + const double theExpectedDistance, + const bool theIsParallel) +{ + const occ::handle aCircle = makeCircle(theCenter, theNormal, theCircleRadius); + const occ::handle aSphere = makeSphere(10.0); + + double aCurveFirst = 0.0, aCurveLast = 0.0; + double aSurfaceUFirst = 0.0, aSurfaceULast = 0.0; + double aSurfaceVFirst = 0.0, aSurfaceVLast = 0.0; + aCurveFirst = aCircle->FirstParameter(); + aCurveLast = aCircle->LastParameter(); + aSphere->Bounds(aSurfaceUFirst, aSurfaceULast, aSurfaceVFirst, aSurfaceVLast); + + GeomAPI_ExtremaCurveSurface anExtrema(aCircle, + aSphere, + aCurveFirst, + aCurveLast, + aSurfaceUFirst, + aSurfaceULast, + aSurfaceVFirst, + aSurfaceVLast); + EXPECT_EQ(anExtrema.IsParallel(), theIsParallel); + if (!theIsParallel) + { + ASSERT_GT(anExtrema.NbExtrema(), 0); + } + EXPECT_NEAR(anExtrema.LowerDistance(), theExpectedDistance, 1.e-7); +} +} // namespace + +// Migrated from tests/lowalgos/extcs/circ_sph_parallel. A concentric circle +// and sphere form a parallel extrema configuration with a known minimum. +TEST(GeomAPI_ExtremaCurveSurfaceTest, CircSph_ParallelConcentric) +{ + expectCircleSphereExtrema(gp_Pnt(0.0, 0.0, 0.0), gp_Dir(0.0, 0.0, 1.0), 4.0, 6.0, true); +} + +// Migrated from tests/lowalgos/extcs/circ_sph_inter. A circle on the sphere +// is an intersection case and its minimum extrema distance is zero. +TEST(GeomAPI_ExtremaCurveSurfaceTest, CircSph_Intersection) +{ + expectCircleSphereExtrema(gp_Pnt(0.0, 0.0, 0.0), gp_Dir(0.0, 0.0, 1.0), 10.0, 0.0, true); +} + +// Migrated from tests/lowalgos/extcs/circ_sph_touch. The internally tangent +// circle must report a zero lower distance even though the circle is bounded. +TEST(GeomAPI_ExtremaCurveSurfaceTest, CircSph_Touch) +{ + expectCircleSphereExtrema(gp_Pnt(8.0, 0.0, 0.0), gp_Dir(0.0, 0.0, 1.0), 2.0, 0.0, false); +} + +// Migrated from tests/lowalgos/extcs/circ_sph_nointer. A circle outside the +// sphere has a positive minimum distance. +TEST(GeomAPI_ExtremaCurveSurfaceTest, CircSph_NoIntersection) +{ + expectCircleSphereExtrema(gp_Pnt(0.0, 0.0, 12.0), + gp_Dir(0.0, 0.0, 1.0), + 2.0, + std::sqrt(148.0) - 10.0, + true); +} + +// Migrated from tests/bugs/modalg_5/bug25368_1. Extrema between a trimmed +// line and a sphere must retain the intersection point on the curve. +TEST(GeomAPI_ExtremaCurveSurfaceTest, ModalgBug_25368_TrimmedLineSphere) +{ + const occ::handle aLine = + new Geom_TrimmedCurve(new Geom_Line(gp_Pnt(0.0, 0.0, 0.2), gp_Dir(1.0, 1.0, 0.0)), 0.0, 10.0); + const occ::handle aSphere = makeSphere(5.0); + + double aUFirst = 0.0, aULast = 0.0, aVFirst = 0.0, aVLast = 0.0; + aSphere->Bounds(aUFirst, aULast, aVFirst, aVLast); + GeomAPI_ExtremaCurveSurface anExtrema(aLine, + aSphere, + aLine->FirstParameter(), + aLine->LastParameter(), + aUFirst, + aULast, + aVFirst, + aVLast); + + ASSERT_EQ(anExtrema.NbExtrema(), 3); + gp_Pnt aCurvePoint, aSurfacePoint; + anExtrema.Points(1, aCurvePoint, aSurfacePoint); + const gp_Pnt anExpectedPoint(3.5327043465311383, 3.5327043465311383, 0.2); + EXPECT_TRUE(aCurvePoint.IsEqual(anExpectedPoint, 0.01)); + EXPECT_TRUE(aSurfacePoint.IsEqual(anExpectedPoint, 0.01)); + EXPECT_GT(anExtrema.Distance(2), 0.01); + EXPECT_GT(anExtrema.Distance(3), 0.01); +} + +// Migrated from tests/bugs/modalg_5/bug25368_2. The rotated sphere and +// infinite line have two extrema, both of which are intersection points. +TEST(GeomAPI_ExtremaCurveSurfaceTest, ModalgBug_25368_RotatedSphereLine) +{ + const occ::handle aSphere = makeSphere(4.5); + gp_Trsf aRotation; + aRotation.SetRotation(gp_Ax1(gp_Pnt(0.0, 0.5, 1.0), gp_Dir(1.0, 1.0, 0.5)), 34.9 * M_PI / 180.0); + aSphere->Transform(aRotation); + + const occ::handle aLine = + new Geom_Line(gp_Pnt(-0.79, 0.88, 1.22), gp_Dir(0.579, 1.765, 0.576)); + double aUFirst = 0.0, aULast = 0.0, aVFirst = 0.0, aVLast = 0.0; + aSphere->Bounds(aUFirst, aULast, aVFirst, aVLast); + GeomAPI_ExtremaCurveSurface anExtrema(aLine, + aSphere, + aLine->FirstParameter(), + aLine->LastParameter(), + aUFirst, + aULast, + aVFirst, + aVLast); + + ASSERT_EQ(anExtrema.NbExtrema(), 4); + const gp_Pnt anExpectedPoint1(-2.2838350838816694, -3.6737459810900646, -0.2660950057268425); + const gp_Pnt anExpectedPoint2(0.29086178559218934, 4.1748550113475211, 2.2952614654595873); + gp_Pnt aCurvePoint, aSurfacePoint; + anExtrema.Points(1, aCurvePoint, aSurfacePoint); + EXPECT_TRUE(aCurvePoint.IsEqual(anExpectedPoint1, 0.01)); + EXPECT_TRUE(aSurfacePoint.IsEqual(anExpectedPoint1, 0.01)); + anExtrema.Points(2, aCurvePoint, aSurfacePoint); + EXPECT_TRUE(aCurvePoint.IsEqual(anExpectedPoint2, 0.01)); + EXPECT_TRUE(aSurfacePoint.IsEqual(anExpectedPoint2, 0.01)); + EXPECT_GT(anExtrema.Distance(3), 0.01); + EXPECT_GT(anExtrema.Distance(4), 0.01); +} diff --git a/src/ModelingAlgorithms/TKGeomAlgo/GTests/GeomAPI_ExtremaSurfaceSurface_Test.cxx b/src/ModelingAlgorithms/TKGeomAlgo/GTests/GeomAPI_ExtremaSurfaceSurface_Test.cxx new file mode 100644 index 0000000000..dc4c534cd0 --- /dev/null +++ b/src/ModelingAlgorithms/TKGeomAlgo/GTests/GeomAPI_ExtremaSurfaceSurface_Test.cxx @@ -0,0 +1,48 @@ +// Copyright (c) 2026 OPEN CASCADE SAS +// +// This file is part of Open CASCADE Technology software library. +// +// This library is free software; you can redistribute it and/or modify it under +// the terms of the GNU Lesser General Public License version 2.1 as published +// by the Free Software Foundation, with special exception defined in the file +// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT +// distribution for complete text of the license and disclaimer of any warranty. +// +// Alternatively, this file may be used under the terms of Open CASCADE +// commercial license or contractual agreement. + +#include + +#include +#include +#include +#include +#include + +// Migrated from tests/lowalgos/extss/bug29712_44. The DRAW script contains a +// same-object typo in both extrema calls; its expected distance of 10.0 clearly +// describes the two parallel planes created immediately above, so this test +// preserves the intended regression check. +TEST(GeomAPI_ExtremaSurfaceSurfaceTest, OCC29712_44_ParallelPlanes) +{ + const occ::handle aPlane1 = + new Geom_Plane(gp_Pln(gp_Pnt(0.0, 0.0, 0.0), gp_Dir(0.0, 0.0, 1.0))); + const occ::handle aPlane2 = + new Geom_Plane(gp_Pln(gp_Pnt(0.0, 0.0, 10.0), gp_Dir(0.0, 0.0, 1.0))); + + GeomAPI_ExtremaSurfaceSurface anExtrema(aPlane1, aPlane2); + ASSERT_TRUE(anExtrema.Extrema().IsParallel()); + EXPECT_NEAR(anExtrema.LowerDistance(), 10.0, 1.e-7); +} + +// Extra validation for the source typo: a plane compared with itself must have +// zero lower distance, rather than the distance between s1 and s2. +TEST(GeomAPI_ExtremaSurfaceSurfaceTest, OCC29712_44_SelfComparisonHasZeroDistance) +{ + const occ::handle aPlane = + new Geom_Plane(gp_Pln(gp_Pnt(0.0, 0.0, 0.0), gp_Dir(0.0, 0.0, 1.0))); + + GeomAPI_ExtremaSurfaceSurface anExtrema(aPlane, aPlane); + ASSERT_TRUE(anExtrema.Extrema().IsParallel()); + EXPECT_NEAR(anExtrema.LowerDistance(), 0.0, 1.e-7); +} diff --git a/src/ModelingAlgorithms/TKGeomAlgo/GTests/GeomAPI_IntCS_Test.cxx b/src/ModelingAlgorithms/TKGeomAlgo/GTests/GeomAPI_IntCS_Test.cxx new file mode 100644 index 0000000000..bda2764399 --- /dev/null +++ b/src/ModelingAlgorithms/TKGeomAlgo/GTests/GeomAPI_IntCS_Test.cxx @@ -0,0 +1,148 @@ +// Copyright (c) 2026 OPEN CASCADE SAS +// +// This file is part of Open CASCADE Technology software library. +// +// This library is free software; you can redistribute it and/or modify it under +// the terms of the GNU Lesser General Public License version 2.1 as published +// by the Free Software Foundation, with special exception defined in the file +// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT +// distribution for complete text of the license and disclaimer of any warranty. +// +// Alternatively, this file may be used under the terms of Open CASCADE +// commercial license or contractual agreement. + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace +{ +static occ::handle makeOCC26979Curve() +{ + const occ::handle aParabola = + new Geom_Parabola(gp_Ax2(gp_Pnt(-5.0, -1.0, 0.25), gp_Dir(0.0, 0.0, 1.0)), 0.25); + return new Geom_TrimmedCurve(aParabola, 0.0, 1000.0); +} + +static void expectOCC26979Intersection(const occ::handle& theSurface) +{ + GeomAPI_IntCS anIntersection(makeOCC26979Curve(), theSurface); + ASSERT_TRUE(anIntersection.IsDone()); + EXPECT_GT(anIntersection.NbPoints() + anIntersection.NbSegments(), 0); +} + +static occ::handle makeOCC26979BezierSurface() +{ + NCollection_Array2 aPoles(1, 3, 1, 3); + aPoles(1, 1) = gp_Pnt(-4.0, 0.0, -1.0); + aPoles(2, 1) = gp_Pnt(-4.0, 1.0, 0.0); + aPoles(3, 1) = gp_Pnt(-4.0, 0.0, 1.0); + aPoles(1, 2) = gp_Pnt(-3.0, 1.0, -1.0); + aPoles(2, 2) = gp_Pnt(-3.0, 2.0, 0.0); + aPoles(3, 2) = gp_Pnt(-3.0, 1.0, 1.0); + aPoles(1, 3) = gp_Pnt(-2.0, 0.0, -1.0); + aPoles(2, 3) = gp_Pnt(-2.0, 1.0, 0.0); + aPoles(3, 3) = gp_Pnt(-2.0, 0.0, 1.0); + return new Geom_BezierSurface(aPoles); +} + +static occ::handle makeOCC26979BSplineSurface() +{ + NCollection_Array1 aUKnots(1, 5), aVKnots(1, 5); + NCollection_Array1 aUMultiplicities(1, 5), aVMultiplicities(1, 5); + for (int anIndex = 1; anIndex <= 5; ++anIndex) + { + aUKnots(anIndex) = anIndex - 1; + aVKnots(anIndex) = anIndex - 1; + aUMultiplicities(anIndex) = 1; + aVMultiplicities(anIndex) = 1; + } + + NCollection_Array2 aPoles(1, 3, 1, 3); + aPoles(1, 1) = gp_Pnt(-3.0, 0.5, -1.0); + aPoles(2, 1) = gp_Pnt(-2.0, 0.5, 0.0); + aPoles(3, 1) = gp_Pnt(-3.0, 0.5, 1.0); + aPoles(1, 2) = gp_Pnt(-2.0, 1.5, -1.0); + aPoles(2, 2) = gp_Pnt(-1.0, 1.5, 0.0); + aPoles(3, 2) = gp_Pnt(-2.0, 1.5, 1.0); + aPoles(1, 3) = gp_Pnt(-3.0, 2.5, -1.0); + aPoles(2, 3) = gp_Pnt(-2.0, 2.5, 0.0); + aPoles(3, 3) = gp_Pnt(-3.0, 2.5, 1.0); + + NCollection_Array2 aWeights(1, 3, 1, 3); + for (int aU = 1; aU <= 3; ++aU) + { + for (int aV = 1; aV <= 3; ++aV) + { + aWeights(aU, aV) = 1.0; + } + } + return new Geom_BSplineSurface(aPoles, + aWeights, + aUKnots, + aVKnots, + aUMultiplicities, + aVMultiplicities, + 1, + 1); +} + +static occ::handle makeOCC26979RevolutionSurface() +{ + const occ::handle aCircle = + new Geom_Circle(gp_Ax2(gp_Pnt(0.0, 0.0, 0.0), gp_Dir(0.0, -1.0, 0.0), gp_Dir(1.0, 0.0, 0.0)), + 3.0); + const occ::handle aTrimmedCircle = + new Geom_TrimmedCurve(aCircle, -M_PI / 2.0, M_PI / 2.0); + return new Geom_SurfaceOfRevolution(aTrimmedCircle, + gp_Ax1(gp_Pnt(0.0, 0.0, 0.0), gp_Dir(0.0, 0.0, 1.0))); +} +} // namespace + +// Migrated from tests/lowalgos/intcs/bug26979. +TEST(GeomAPI_IntCSTest, OCC26979_ParabolaBezierSurface) +{ + expectOCC26979Intersection(makeOCC26979BezierSurface()); +} + +// Migrated from tests/lowalgos/intcs/bug26979. +TEST(GeomAPI_IntCSTest, OCC26979_ParabolaBSplineSurface) +{ + expectOCC26979Intersection(makeOCC26979BSplineSurface()); +} + +// Migrated from tests/lowalgos/intcs/bug26979. +TEST(GeomAPI_IntCSTest, OCC26979_ParabolaTorus) +{ + expectOCC26979Intersection( + new Geom_ToroidalSurface(gp_Ax3(gp_Pnt(0.0, 0.0, 0.0), gp_Dir(0.0, 0.0, 1.0)), 3.0, 1.0)); +} + +// Migrated from tests/lowalgos/intcs/bug26979. +TEST(GeomAPI_IntCSTest, OCC26979_ParabolaLinearExtrusion) +{ + const occ::handle aCircle = + new Geom_Circle(gp_Ax2(gp_Pnt(0.0, 0.0, 0.0), gp_Dir(0.0, 0.0, 1.0)), 4.0); + expectOCC26979Intersection(new Geom_SurfaceOfLinearExtrusion(aCircle, gp_Dir(0.0, 0.0, 1.0))); +} + +// Migrated from tests/lowalgos/intcs/bug26979. +TEST(GeomAPI_IntCSTest, OCC26979_ParabolaRevolution) +{ + expectOCC26979Intersection(makeOCC26979RevolutionSurface()); +} diff --git a/src/ModelingAlgorithms/TKGeomAlgo/GTests/GeomAPI_IntSS_Test.cxx b/src/ModelingAlgorithms/TKGeomAlgo/GTests/GeomAPI_IntSS_Test.cxx index 417703fe14..52234bbf91 100644 --- a/src/ModelingAlgorithms/TKGeomAlgo/GTests/GeomAPI_IntSS_Test.cxx +++ b/src/ModelingAlgorithms/TKGeomAlgo/GTests/GeomAPI_IntSS_Test.cxx @@ -17,9 +17,13 @@ #include #include #include +#include +#include #include #include +#include #include +#include #include #include #include @@ -28,6 +32,8 @@ #include #include +#include + //! OCC26675: BSplineSurface intersect SurfaceOfLinearExtrusion //! Verifies that GeomAPI_IntSS finds exactly one intersection curve with a valid (non-degenerate) //! parameter range. The surface data is generated inline to avoid file I/O @@ -3631,3 +3637,116 @@ TEST(GeomAPI_IntSSTest, OCC23972_TwoConesIntersection) ASSERT_GT(aU2 - aU1, 1.0e-20) << "Degenerate parameter range for curve " << anIdx; } } + +// Migrated from tests/lowalgos/intss/bug25782_2. The DRAW test expects the +// intersection of two parallel cylinders to be two exact straight lines and +// checks both lines against both source surfaces. +TEST(GeomAPI_IntSSTest, OCC25782_2_ParallelCylindersProduceTwoLines) +{ + const gp_Dir anAxisDirection(12.0, 35.0, 47.0); + const occ::handle aCylinder1 = + new Geom_CylindricalSurface(gp_Ax3(gp_Pnt(0.0, 0.0, 0.0), anAxisDirection), 5.0); + const occ::handle aCylinder2 = + new Geom_CylindricalSurface(gp_Ax3(gp_Pnt(3.0, 2.0, 8.0), anAxisDirection), 4.0); + + GeomAPI_IntSS anIntersection(aCylinder1, aCylinder2, 1.e-7); + ASSERT_TRUE(anIntersection.IsDone()); + ASSERT_EQ(anIntersection.NbLines(), 2); + + const double aParameters[] = {0.0, 50.0, 100.0}; + for (int anIndex = 1; anIndex <= anIntersection.NbLines(); ++anIndex) + { + const occ::handle& aCurve = anIntersection.Line(anIndex); + const occ::handle aLine = occ::down_cast(aCurve); + ASSERT_FALSE(aLine.IsNull()) << "Intersection " << anIndex << " is not a line"; + + for (const double aParameter : aParameters) + { + const gp_Pnt aPoint = aLine->Value(aParameter); + GeomAPI_ProjectPointOnSurf aProjection1(aPoint, aCylinder1, 1.e-7); + GeomAPI_ProjectPointOnSurf aProjection2(aPoint, aCylinder2, 1.e-7); + ASSERT_TRUE(aProjection1.IsDone()); + ASSERT_TRUE(aProjection2.IsDone()); + ASSERT_GT(aProjection1.NbPoints(), 0); + ASSERT_GT(aProjection2.NbPoints(), 0); + EXPECT_LE(aProjection1.LowerDistance(), 1.e-7); + EXPECT_LE(aProjection2.LowerDistance(), 1.e-7); + } + } +} + +// Migrated from tests/lowalgos/intss/bug33244. Preserve the exact cone +// parameters because the original issue was a duplicate intersection curve. +TEST(GeomAPI_IntSSTest, OCC33244_TwoConesDoNotDuplicateCurves) +{ + const occ::handle aCone1 = new Geom_ConicalSurface( + gp_Ax3(gp_Pnt(-1.11630646267172, -4.54487349779333, 13.2493435203532), + gp_Dir(-1.05794851588922e-07, -1.39278337794573e-08, 0.999999999999994)), + 0.785398163360967, + 0.560000000061149); + const occ::handle aCone2 = new Geom_ConicalSurface( + gp_Ax3(gp_Pnt(-2.08647872350287e-07, -5.78732475509323, 13.2493436211), + gp_Dir(-1.05794850062242e-07, -1.39278350756825e-08, 0.999999999999994)), + 0.785398163396248, + 0.785398163396248); + + GeomAPI_IntSS anIntersection; + ASSERT_NO_THROW(anIntersection.Perform(aCone1, aCone2, Precision::Confusion())); + ASSERT_TRUE(anIntersection.IsDone()); + ASSERT_EQ(anIntersection.NbLines(), 2); + for (int anIndex = 1; anIndex <= anIntersection.NbLines(); ++anIndex) + { + const occ::handle& aCurve = anIntersection.Line(anIndex); + ASSERT_FALSE(aCurve.IsNull()); + EXPECT_GT(aCurve->LastParameter() - aCurve->FirstParameter(), 0.0); + } +} + +// Migrated from tests/lowalgos/intss/bug24418_2. The original DRAW case +// samples the first intersection curve and verifies its distance to both +// trimmed analytical surfaces. +TEST(GeomAPI_IntSSTest, OCC24418_2_AnalyticalSurfaceIntersection) +{ + const double aPi = 3.1415926535897932384626433832795; + const occ::handle aTorus = + new Geom_ToroidalSurface(gp_Ax3(gp_Pnt(0.0, 0.0, 0.0), gp_Dir(0.0, 0.0, 1.0)), 25.0, 24.0); + const occ::handle aCone = + new Geom_ConicalSurface(gp_Ax3(gp_Pnt(20.0, 20.0, 10.0), gp_Dir(0.0, 0.0, 1.0)), + std::atan2(2.0, 40.0), + 10.0); + + const occ::handle aTorusTrimmed = + new Geom_RectangularTrimmedSurface(aTorus, 0.0, 0.5 * aPi, true, true); + const occ::handle aConeTrimmed = + new Geom_RectangularTrimmedSurface(aCone, 0.0, 40.049968789001575, false, true); + + GeomAPI_IntSS anIntersection; + ASSERT_NO_THROW(anIntersection.Perform(aTorusTrimmed, aConeTrimmed, Precision::Confusion())); + ASSERT_TRUE(anIntersection.IsDone()); + ASSERT_GT(anIntersection.NbLines(), 0); + + const occ::handle& aCurve = anIntersection.Line(1); + ASSERT_FALSE(aCurve.IsNull()); + const double aFirstParameter = aCurve->FirstParameter(); + const double aLastParameter = aCurve->LastParameter(); + ASSERT_GT(aLastParameter, aFirstParameter); + + for (int anIndex = 0; anIndex < 10; ++anIndex) + { + double aParameter = aFirstParameter + (aLastParameter - aFirstParameter) * anIndex / 9.0; + gp_Pnt aPoint; + aCurve->D0(aParameter, aPoint); + + GeomAPI_ProjectPointOnSurf aTorusProjection(aPoint, aTorusTrimmed, 1.0e-7); + ASSERT_TRUE(aTorusProjection.IsDone()) << "Torus projection failed at sample " << anIndex; + ASSERT_GT(aTorusProjection.NbPoints(), 0); + EXPECT_LE(aTorusProjection.LowerDistance(), 2.0e-7) + << "Intersection curve is off the torus at sample " << anIndex; + + GeomAPI_ProjectPointOnSurf aConeProjection(aPoint, aConeTrimmed, 1.0e-7); + ASSERT_TRUE(aConeProjection.IsDone()) << "Cone projection failed at sample " << anIndex; + ASSERT_GT(aConeProjection.NbPoints(), 0); + EXPECT_LE(aConeProjection.LowerDistance(), 2.0e-7) + << "Intersection curve is off the cone at sample " << anIndex; + } +} diff --git a/src/ModelingAlgorithms/TKGeomAlgo/GTests/GeomAPI_ProjectPointOnSurf_Test.cxx b/src/ModelingAlgorithms/TKGeomAlgo/GTests/GeomAPI_ProjectPointOnSurf_Test.cxx index bacbc968e4..4862f52b87 100644 --- a/src/ModelingAlgorithms/TKGeomAlgo/GTests/GeomAPI_ProjectPointOnSurf_Test.cxx +++ b/src/ModelingAlgorithms/TKGeomAlgo/GTests/GeomAPI_ProjectPointOnSurf_Test.cxx @@ -13,11 +13,25 @@ #include +#include +#include +#include +#include +#include #include #include #include +#include +#include +#include +#include +#include +#include #include +#include +#include #include +#include #include //================================================================================================= @@ -41,3 +55,49 @@ TEST(GeomAPI_ProjectPointOnSurfTest, Bug867_InitWithTightBoundsNoException) // The original bug (OCC867) was that Init()+Perform() threw an exception. // Whether a projection exists within the given UV bounds is not the concern here. } + +// Migrated from tests/bugs/moddata_3/bug24138. Projecting a point onto the +// lateral face generated by an elliptical wire must return stable UV and XYZ. +TEST(GeomAPI_ProjectPointOnSurfTest, OCC24138_ProjectPointOnEllipticalPrismFace) +{ + const occ::handle anEllipse = + new Geom_Ellipse(gp_Ax2(gp_Pnt(0.0, 0.0, 0.0), gp_Dir(0.0, 0.0, 1.0)), 10.0, 5.0); + const TopoDS_Edge anEdge = BRepBuilderAPI_MakeEdge(anEllipse).Edge(); + const TopoDS_Wire aWire = BRepBuilderAPI_MakeWire(anEdge).Wire(); + const TopoDS_Shape aPrism = BRepPrimAPI_MakePrism(aWire, gp_Vec(2.0, 0.0, 30.0)).Shape(); + + TopExp_Explorer aFaceExplorer(aPrism, TopAbs_FACE); + ASSERT_TRUE(aFaceExplorer.More()); + const TopoDS_Face aFace = TopoDS::Face(aFaceExplorer.Current()); + + TopLoc_Location aLocation; + const occ::handle aSurface = BRep_Tool::Surface(aFace, aLocation); + ASSERT_FALSE(aSurface.IsNull()); + + const gp_Pnt aPoint(0.753071156928785, 4.98580193823337, 0.0); + double aUMin = 0.0; + double aUMax = 0.0; + double aVMin = 0.0; + double aVMax = 0.0; + aSurface->Bounds(aUMin, aUMax, aVMin, aVMax); + + GeomAPI_ProjectPointOnSurf aProjector; + aProjector.Init(aSurface, aUMin, aUMax, aVMin, aVMax); + aProjector.SetExtremaAlgo(Extrema_ExtAlgo_Grad); + aProjector.SetExtremaFlag(Extrema_ExtFlag_MINMAX); + aProjector.Perform(aPoint); + + ASSERT_TRUE(aProjector.IsDone()); + ASSERT_GT(aProjector.NbPoints(), 0); + + double aU = 0.0; + double aV = 0.0; + aProjector.LowerDistanceParameters(aU, aV); + const gp_Pnt aProjectedPoint = aProjector.NearestPoint(); + EXPECT_NEAR(aProjector.LowerDistance(), 9.16061678111512e-10, 1.0e-7); + EXPECT_NEAR(aU, 1.4954178490327235, 1.0e-7); + EXPECT_NEAR(aV, 0.0, 1.0e-7); + EXPECT_NEAR(aProjectedPoint.X(), 0.75307115689421944, 1.0e-7); + EXPECT_NEAR(aProjectedPoint.Y(), 4.9858019383179632, 1.0e-7); + EXPECT_NEAR(aProjectedPoint.Z(), 0.0, 1.0e-7); +} diff --git a/src/ModelingAlgorithms/TKGeomAlgo/GTests/GeomFill_BSplineCurves_Test.cxx b/src/ModelingAlgorithms/TKGeomAlgo/GTests/GeomFill_BSplineCurves_Test.cxx index 5e683c2d22..5ce6859042 100644 --- a/src/ModelingAlgorithms/TKGeomAlgo/GTests/GeomFill_BSplineCurves_Test.cxx +++ b/src/ModelingAlgorithms/TKGeomAlgo/GTests/GeomFill_BSplineCurves_Test.cxx @@ -20,9 +20,14 @@ #include #include #include +#include +#include #include #include +#include #include +#include +#include #include #include #include @@ -30,6 +35,7 @@ #include #include #include +#include #include #include #include @@ -126,6 +132,29 @@ double surfaceArea(const TopoDS_Shape& theShape) return aProps.Mass(); } +occ::handle makeTwoPoleCurve(const gp_Pnt& theFirst, + const gp_Pnt& theLast, + const double theLastKnot) +{ + NCollection_Array1 aPoles(1, 2); + aPoles(1) = theFirst; + aPoles(2) = theLast; + + NCollection_Array1 aWeights(1, 2); + aWeights(1) = 1.0; + aWeights(2) = 1.0; + + NCollection_Array1 aKnots(1, 2); + aKnots(1) = 0.0; + aKnots(2) = theLastKnot; + + NCollection_Array1 aMultiplicities(1, 2); + aMultiplicities(1) = 2; + aMultiplicities(2) = 2; + + return new Geom_BSplineCurve(aPoles, aWeights, aKnots, aMultiplicities, 1, false); +} + } // namespace TEST(GeomFill_BSplineCurvesTest, OCC28131_FillSurfaceFromBezierAndInterpolatedCurves) @@ -177,3 +206,66 @@ TEST(GeomFill_BSplineCurvesTest, OCC28131_StandardOffsetOfFilledFace) // checkprops -s 1693.76 EXPECT_NEAR(surfaceArea(aResult), 1693.76, 1693.76 * 0.01); } + +// Migrated from tests/bugs/filling/bug13904. Keep the DRAW command's +// approximation path: SectionGenerator -> AppSurf -> BSpline surface. +TEST(GeomFill_BSplineCurvesTest, OCC13904_AppSurfBetweenCircleAndEllipse) +{ + const occ::handle aCircle = + new Geom_Circle(gp_Ax2(gp_Pnt(0.0, 100.0, 100.0), gp_Dir(0.0, 1.0, 1.0)), 50.0); + const occ::handle anEllipse = + new Geom_Ellipse(gp_Ax2(gp_Pnt(0.0, 0.0, 0.0), gp_Dir(0.0, 1.0, 1.0)), 100.0, 50.0); + + GeomFill_SectionGenerator aSection; + aSection.AddCurve(aCircle); + aSection.AddCurve(anEllipse); + aSection.Perform(Precision::PConfusion()); + + occ::handle aLine = new GeomFill_Line(2); + GeomFill_AppSurf anApproximation(3, 8, Precision::Confusion(), Precision::PConfusion(), 0); + ASSERT_NO_THROW(anApproximation.Perform(aLine, aSection)); + ASSERT_TRUE(anApproximation.IsDone()); + + int aUDegree = 0; + int aVDegree = 0; + int aNbUPoles = 0; + int aNbVPoles = 0; + int aNbUKnots = 0; + int aNbVKnots = 0; + anApproximation.SurfShape(aUDegree, aVDegree, aNbUPoles, aNbVPoles, aNbUKnots, aNbVKnots); + EXPECT_GE(aUDegree, 3); + EXPECT_GE(aVDegree, 1); + EXPECT_GT(aNbUPoles, 0); + EXPECT_GT(aNbVPoles, 0); + EXPECT_GT(aNbUKnots, 0); + EXPECT_GT(aNbVKnots, 0); + + const occ::handle aSurface = + new Geom_BSplineSurface(anApproximation.SurfPoles(), + anApproximation.SurfWeights(), + anApproximation.SurfUKnots(), + anApproximation.SurfVKnots(), + anApproximation.SurfUMults(), + anApproximation.SurfVMults(), + anApproximation.UDegree(), + anApproximation.VDegree()); + EXPECT_FALSE(aSurface.IsNull()); +} + +// Migrated from tests/bugs/filling/bug27775. The source curves intentionally +// have only two poles; GeomFill_BSplineCurves must reject this invalid input. +TEST(GeomFill_BSplineCurvesTest, OCC27704_InvalidTwoPoleCurvesRaiseConstructionError) +{ + const gp_Pnt aP1(-24033.3957701043, -6337.90755953146, -16577.8188547128); + const gp_Pnt aP2(-23933.3957701044, -6337.90755953146, -16577.8362547128); + const gp_Pnt aP3(-24033.3957701043, -6371.01755953146, -16577.8188547128); + const gp_Pnt aP4(-23933.3957701044, -6371.01755953146, -16577.8362547128); + + const occ::handle aCurve1 = makeTwoPoleCurve(aP1, aP2, 100.000001513789); + const occ::handle aCurve2 = makeTwoPoleCurve(aP2, aP1, 100.000001513789); + const occ::handle aCurve3 = makeTwoPoleCurve(aP3, aP1, 33.1099999999979); + const occ::handle aCurve4 = makeTwoPoleCurve(aP3, aP4, 100.000001513789); + + EXPECT_THROW(GeomFill_BSplineCurves(aCurve1, aCurve2, aCurve3, aCurve4, GeomFill_CoonsStyle), + Standard_ConstructionError); +} diff --git a/src/ModelingAlgorithms/TKGeomAlgo/GTests/GeomPlate_BuildPlateSurface_Test.cxx b/src/ModelingAlgorithms/TKGeomAlgo/GTests/GeomPlate_BuildPlateSurface_Test.cxx index 9d3d5fcbf6..647f444d97 100644 --- a/src/ModelingAlgorithms/TKGeomAlgo/GTests/GeomPlate_BuildPlateSurface_Test.cxx +++ b/src/ModelingAlgorithms/TKGeomAlgo/GTests/GeomPlate_BuildPlateSurface_Test.cxx @@ -12,13 +12,100 @@ // commercial license or contractual agreement. #include +#include #include -#include +#include +#include +#include #include +#include +#include +#include +#include +#include #include #include +#include + +namespace +{ +class ProgressObserver : public Message_ProgressIndicator +{ +public: + const NCollection_Sequence& Messages() const { return myMessages; } + +protected: + void Show(const Message_ProgressScope& theScope, const bool) override + { + TCollection_AsciiString aMessage; + aMessage += static_cast(100. * GetPosition() + 0.5); + aMessage += "%"; + for (const Message_ProgressScope* aScope = &theScope; aScope != nullptr; + aScope = aScope->Parent()) + { + if (aScope->Name() != nullptr) + { + aMessage += " "; + aMessage += aScope->Name(); + } + } + myMessages.Append(aMessage); + } + +private: + NCollection_Sequence myMessages; +}; + +bool hasProgressText(const ProgressObserver& theObserver, const char* theText) +{ + for (NCollection_Sequence::Iterator anIterator(theObserver.Messages()); + anIterator.More(); + anIterator.Next()) + { + if (anIterator.Value().Search(theText) != -1) + { + return true; + } + } + return false; +} + +occ::handle createBezierCurve(const gp_Pnt& theP1, + const gp_Pnt& theP2, + const gp_Pnt& theP3) +{ + NCollection_Array1 aPoles(1, 3); + aPoles(1) = theP1; + aPoles(2) = theP2; + aPoles(3) = theP3; + return new Geom_BezierCurve(aPoles); +} + +TopoDS_Edge createBezierEdge(const gp_Pnt& theP1, const gp_Pnt& theP2, const gp_Pnt& theP3) +{ + return BRepBuilderAPI_MakeEdge(createBezierCurve(theP1, theP2, theP3)).Edge(); +} + +void addCurveConstraint(GeomPlate_BuildPlateSurface& theBuilder, const TopoDS_Edge& theEdge) +{ + occ::handle aCurve = new BRepAdaptor_Curve(theEdge); + const occ::handle& aCurveAdaptor = aCurve; + theBuilder.Add(new GeomPlate_CurveConstraint(aCurveAdaptor, 0)); +} + +void expectPlateProgress(const ProgressObserver& theObserver) +{ + EXPECT_GT(theObserver.Messages().Length(), 0); + EXPECT_TRUE(hasProgressText(theObserver, "0%")); + EXPECT_TRUE(hasProgressText(theObserver, "100%")); + EXPECT_TRUE(hasProgressText(theObserver, "Calculating the surface filled")); + EXPECT_TRUE(hasProgressText(theObserver, "Plate_Plate::SolveTI1()")); + EXPECT_TRUE(hasProgressText(theObserver, "math_Gauss LU_Decompose")); +} +} // namespace + TEST(GeomPlate_BuildPlateSurface, OCC525_PerformWithoutConstraints) { GeomPlate_BuildPlateSurface aBuilder; @@ -52,3 +139,101 @@ TEST(GeomPlate_BuildPlateSurface, Perform_ClearsStaleResult) EXPECT_TRUE(aBuilder.IsDone()); EXPECT_TRUE(aBuilder.Surface().IsNull()) << "Surface must be null after Init() + empty Perform()"; } + +// Migrated from tests/lowalgos/progress/A1. Validate the progress scopes +// emitted by the same GeomPlate operation rather than testing DRAW output. +TEST(GeomPlate_BuildPlateSurface, Progress_A1_FourBezierEdgesWithPlane) +{ + GeomPlate_BuildPlateSurface aBuilder(3, 15, 2); + aBuilder.LoadInitSurface(new Geom_Plane(gp_Pln(gp_Pnt(0., 0., 0.), gp_Dir(0., 0., 1.)))); + + const TopoDS_Edge anEdge1 = + createBezierEdge(gp_Pnt(0., 0., 0.), gp_Pnt(1., 0., 1.), gp_Pnt(2., 0., 0.)); + const TopoDS_Edge anEdge2 = + createBezierEdge(gp_Pnt(0., 2., 0.), gp_Pnt(1., 2., 1.), gp_Pnt(2., 2., 0.)); + const TopoDS_Edge anEdge3 = + createBezierEdge(gp_Pnt(0., 0., 0.), gp_Pnt(0., 1., 1.), gp_Pnt(0., 2., 0.)); + const TopoDS_Edge anEdge4 = + createBezierEdge(gp_Pnt(2., 0., 0.), gp_Pnt(2., 1., 1.), gp_Pnt(2., 2., 0.)); + addCurveConstraint(aBuilder, anEdge1); + addCurveConstraint(aBuilder, anEdge2); + addCurveConstraint(aBuilder, anEdge3); + addCurveConstraint(aBuilder, anEdge4); + + occ::handle aProgress = new ProgressObserver(); + aBuilder.Perform(Message_ProgressIndicator::Start(aProgress)); + + EXPECT_TRUE(aBuilder.IsDone()); + EXPECT_FALSE(aBuilder.Surface().IsNull()); + expectPlateProgress(*aProgress); +} + +// Migrated from tests/lowalgos/progress/A2. +TEST(GeomPlate_BuildPlateSurface, Progress_A2_FourBezierEdgesWithoutPlane) +{ + GeomPlate_BuildPlateSurface aBuilder(3, 15, 2); + addCurveConstraint(aBuilder, + createBezierEdge(gp_Pnt(0., 0., 0.), gp_Pnt(1., 0., 1.), gp_Pnt(2., 0., 0.))); + addCurveConstraint(aBuilder, + createBezierEdge(gp_Pnt(0., 2., 0.), gp_Pnt(1., 2., 1.), gp_Pnt(2., 2., 0.))); + addCurveConstraint(aBuilder, + createBezierEdge(gp_Pnt(0., 0., 0.), gp_Pnt(0., 1., 2.), gp_Pnt(0., 2., 0.))); + addCurveConstraint(aBuilder, + createBezierEdge(gp_Pnt(2., 0., 0.), gp_Pnt(2., 1., 2.), gp_Pnt(2., 2., 0.))); + + occ::handle aProgress = new ProgressObserver(); + aBuilder.Perform(Message_ProgressIndicator::Start(aProgress)); + + EXPECT_TRUE(aBuilder.IsDone()); + EXPECT_FALSE(aBuilder.Surface().IsNull()); + expectPlateProgress(*aProgress); +} + +// Migrated from tests/lowalgos/progress/A3. +TEST(GeomPlate_BuildPlateSurface, Progress_A3_LargePointContour) +{ + GeomPlate_BuildPlateSurface aBuilder(3, 15, 2); + for (int anIndex = 0; anIndex < 300; ++anIndex) + { + aBuilder.Add(new GeomPlate_PointConstraint(gp_Pnt(anIndex, 0., 0.), 0)); + } + for (int anIndex = 1; anIndex < 300; ++anIndex) + { + aBuilder.Add(new GeomPlate_PointConstraint(gp_Pnt(0., anIndex, 0.), 0)); + } + for (int anIndex = 0; anIndex < 300; ++anIndex) + { + aBuilder.Add(new GeomPlate_PointConstraint(gp_Pnt(300., anIndex, 0.), 0)); + } + for (int anIndex = 0; anIndex <= 300; ++anIndex) + { + aBuilder.Add(new GeomPlate_PointConstraint(gp_Pnt(anIndex, 300., 0.), 0)); + } + + occ::handle aProgress = new ProgressObserver(); + aBuilder.Perform(Message_ProgressIndicator::Start(aProgress)); + + EXPECT_TRUE(aBuilder.IsDone()); + EXPECT_FALSE(aBuilder.Surface().IsNull()); + expectPlateProgress(*aProgress); +} + +// Migrated from tests/lowalgos/progress/A4. +TEST(GeomPlate_BuildPlateSurface, Progress_A4_OneHundredPointContour) +{ + GeomPlate_BuildPlateSurface aBuilder(3, 15, 2); + for (int anIndex = 0; anIndex < 100; ++anIndex) + { + const double aParameter = 2. * M_PI * anIndex / 100.; + aBuilder.Add(new GeomPlate_PointConstraint( + gp_Pnt(std::sin(aParameter), std::cos(aParameter), std::abs(1. - 2. * anIndex / 100.)), + 0)); + } + + occ::handle aProgress = new ProgressObserver(); + aBuilder.Perform(Message_ProgressIndicator::Start(aProgress)); + + EXPECT_TRUE(aBuilder.IsDone()); + EXPECT_FALSE(aBuilder.Surface().IsNull()); + expectPlateProgress(*aProgress); +} diff --git a/src/ModelingAlgorithms/TKGeomAlgo/Geom2dGcc/Geom2dGcc_Circ2dTanCenGeo.cxx b/src/ModelingAlgorithms/TKGeomAlgo/Geom2dGcc/Geom2dGcc_Circ2dTanCenGeo.cxx index ba6939935c..464f27b9b7 100644 --- a/src/ModelingAlgorithms/TKGeomAlgo/Geom2dGcc/Geom2dGcc_Circ2dTanCenGeo.cxx +++ b/src/ModelingAlgorithms/TKGeomAlgo/Geom2dGcc/Geom2dGcc_Circ2dTanCenGeo.cxx @@ -55,6 +55,8 @@ Geom2dGcc_Circ2dTanCenGeo::Geom2dGcc_Circ2dTanCenGeo(const Geom2dGcc_QCurve& Qua NCollection_Array1 theParam(1, 2); theDist2(1) = RealLast(); theDist2(2) = 0.; + Index(1) = 0; + Index(2) = 0; int i = 1; int nbsol = 0; gp_Dir2d dirx(gp_Dir2d::D::X); @@ -76,18 +78,21 @@ Geom2dGcc_Circ2dTanCenGeo::Geom2dGcc_Circ2dTanCenGeo(const Geom2dGcc_QCurve& Qua } while (i <= nbext) { - thePar = distmin.Point(i).Parameter(); - if (distmin.SquareDistance(i) < theDist2(1)) + thePar = distmin.Point(i).Parameter(); + const double aSquareDistance = distmin.SquareDistance(i); + if (Index(1) == 0 || aSquareDistance < theDist2(1)) { - theDist2(1) = distmin.SquareDistance(i); + theDist2(1) = aSquareDistance; theParam(1) = thePar; pTan(1) = distmin.Point(i).Value(); + Index(1) = i; } - if (distmin.SquareDistance(i) > theDist2(2)) + if (Index(2) == 0 || aSquareDistance > theDist2(2)) { - theDist2(2) = distmin.SquareDistance(i); + theDist2(2) = aSquareDistance; theParam(2) = thePar; pTan(2) = distmin.Point(i).Value(); + Index(2) = i; } i++; } diff --git a/src/ModelingAlgorithms/TKMesh/GTests/BRepMesh_IncrementalMesh_Test.cxx b/src/ModelingAlgorithms/TKMesh/GTests/BRepMesh_IncrementalMesh_Test.cxx index ba587d429b..5b67c6dc8a 100644 --- a/src/ModelingAlgorithms/TKMesh/GTests/BRepMesh_IncrementalMesh_Test.cxx +++ b/src/ModelingAlgorithms/TKMesh/GTests/BRepMesh_IncrementalMesh_Test.cxx @@ -21,11 +21,17 @@ #include #include #include +#include #include +#include #include #include +#include +#include #include +#include #include +#include #include #include #include @@ -41,6 +47,7 @@ #include #include #include +#include #include #include #include @@ -53,35 +60,36 @@ TEST(BRepMesh_IncrementalMeshTest, OCC26407_PlanarPolygonMeshStatus) { // Hardcoded octagon-like polygon lying in the Z=88.5 plane - std::vector aPnts = { - gp_Pnt(587.90000000000009094947, 40.6758179230516248026106, 88.5), - gp_Pnt(807.824182076948432040808, 260.599999999999965893949, 88.5), - gp_Pnt(644.174182076948454778176, 424.249999999999943156581, 88.5000000000000142108547), - gp_Pnt(629.978025792618950617907, 424.25, 88.5), - gp_Pnt(793.628025792618700506864, 260.599999999999852207111, 88.5), - gp_Pnt(587.900000000000204636308, 54.8719742073813492311274, 88.5), - gp_Pnt(218.521974207381418864315, 424.250000000000056843419, 88.5), - gp_Pnt(204.325817923051886282337, 424.249999999999943156581, 88.5)}; + NCollection_Array1 aPnts(1, 8); + aPnts(1) = gp_Pnt(587.90000000000009094947, 40.6758179230516248026106, 88.5); + aPnts(2) = gp_Pnt(807.824182076948432040808, 260.599999999999965893949, 88.5); + aPnts(3) = + gp_Pnt(644.174182076948454778176, 424.249999999999943156581, 88.5000000000000142108547); + aPnts(4) = gp_Pnt(629.978025792618950617907, 424.25, 88.5); + aPnts(5) = gp_Pnt(793.628025792618700506864, 260.599999999999852207111, 88.5); + aPnts(6) = gp_Pnt(587.900000000000204636308, 54.8719742073813492311274, 88.5); + aPnts(7) = gp_Pnt(218.521974207381418864315, 424.250000000000056843419, 88.5); + aPnts(8) = gp_Pnt(204.325817923051886282337, 424.249999999999943156581, 88.5); - std::vector aVertices; - aVertices.reserve(aPnts.size()); - for (const gp_Pnt& aPnt : aPnts) + NCollection_Array1 aVertices(1, aPnts.Length()); + for (int anIndex = aPnts.Lower(); anIndex <= aPnts.Upper(); ++anIndex) { - aVertices.push_back(BRepBuilderAPI_MakeVertex(aPnt)); + aVertices(anIndex) = BRepBuilderAPI_MakeVertex(aPnts(anIndex)); } BRepBuilderAPI_MakeWire aWireBuilder; - for (size_t i = 0; i < aVertices.size(); ++i) + for (int anIndex = aVertices.Lower(); anIndex <= aVertices.Upper(); ++anIndex) { - const TopoDS_Vertex& aV = aVertices[i]; - const TopoDS_Vertex& aW = aVertices[(i + 1) % aVertices.size()]; + const TopoDS_Vertex& aV = aVertices(anIndex); + const int aNextIndex = anIndex == aVertices.Upper() ? aVertices.Lower() : anIndex + 1; + const TopoDS_Vertex& aW = aVertices(aNextIndex); aWireBuilder.Add(BRepBuilderAPI_MakeEdge(aV, aW)); } ASSERT_TRUE(aWireBuilder.IsDone()) << "Wire construction failed"; - const gp_Pnt& aV0 = aPnts[0]; - const gp_Pnt& aV1 = aPnts[1]; - const gp_Pnt& aV2 = aPnts[aPnts.size() - 1]; + const gp_Pnt& aV0 = aPnts(1); + const gp_Pnt& aV1 = aPnts(2); + const gp_Pnt& aV2 = aPnts(aPnts.Upper()); const gp_Vec aFaceNormal = gp_Vec(aV0, aV1).Crossed(gp_Vec(aV0, aV2)); const TopoDS_Face aFace = BRepBuilderAPI_MakeFace(gp_Pln(aV0, aFaceNormal), aWireBuilder.Wire()); @@ -271,3 +279,185 @@ TEST(BRepMesh_IncrementalMeshTest, ClosedCylinder_SeamPolygonsReferenceValidMesh EXPECT_GT(aSeamEdges, 0); } + +// Migrated from tests/bugs/mesh/bug32692_3. An unbounded cylindrical face +// must be handled without a crash and must report the expected mesh status. +TEST(BRepMesh_IncrementalMeshTest, OCC32692_UnboundedCylinderFaceReportsFailure) +{ + const occ::handle aCylinder = + new Geom_CylindricalSurface(gp::XOY(), 10.0); + BRepBuilderAPI_MakeFace aFaceBuilder(aCylinder, Precision::Confusion()); + ASSERT_TRUE(aFaceBuilder.IsDone()); + const TopoDS_Face aFace = aFaceBuilder.Face(); + + BRepMesh_IncrementalMesh aMesher(aFace, 0.01, false, 0.5, true); + EXPECT_TRUE(aMesher.IsDone()); + EXPECT_EQ(aMesher.GetStatusFlags(), IMeshData_OpenWire | IMeshData_Failure | IMeshData_Outdated); + + int aNbFaces = 0; + for (TopExp_Explorer anExplorer(aFace, TopAbs_FACE); anExplorer.More(); anExplorer.Next()) + { + ++aNbFaces; + } + EXPECT_EQ(aNbFaces, 1); + + TopLoc_Location aLocation; + const occ::handle aTriangulation = BRep_Tool::Triangulation(aFace, aLocation); + int aNbNodes = 0; + int aNbTriangles = 0; + if (!aTriangulation.IsNull()) + { + aNbNodes = aTriangulation->NbNodes(); + aNbTriangles = aTriangulation->NbTriangles(); + } + EXPECT_EQ(aNbNodes, 0); + EXPECT_EQ(aNbTriangles, 0); +} + +// Migrated from tests/bugs/demo/bug25445. The DRAW test verifies that the +// angular deflection is forwarded to BRepMesh by comparing the two meshes. +TEST(BRepMesh_IncrementalMeshTest, OCC25445_AngularDeflectionChangesMesh) +{ + struct MeshCounts + { + int NbNodes; + int NbTriangles; + }; + + const auto countMeshElements = [](const TopoDS_Shape& theShape, const double theAngleDegrees) { + IMeshTools_Parameters aParameters; + aParameters.Deflection = 0.01; + aParameters.Angle = theAngleDegrees * M_PI / 180.0; + + BRepMesh_IncrementalMesh aMesher(theShape, aParameters); + EXPECT_TRUE(aMesher.IsDone()); + + int aNbNodes = 0; + int aNbTriangles = 0; + for (TopExp_Explorer anExplorer(theShape, TopAbs_FACE); anExplorer.More(); anExplorer.Next()) + { + TopLoc_Location aLocation; + const occ::handle aTriangulation = + BRep_Tool::Triangulation(TopoDS::Face(anExplorer.Current()), aLocation); + EXPECT_FALSE(aTriangulation.IsNull()); + if (!aTriangulation.IsNull()) + { + aNbNodes += aTriangulation->NbNodes(); + aNbTriangles += aTriangulation->NbTriangles(); + } + } + return MeshCounts{aNbNodes, aNbTriangles}; + }; + + const TopoDS_Shape aCoarseAngleShape = BRepPrimAPI_MakeCone(100.0, 10.0, 100.0).Shape(); + const TopoDS_Shape aFineAngleShape = BRepPrimAPI_MakeCone(100.0, 10.0, 100.0).Shape(); + + const MeshCounts aCoarseMesh = countMeshElements(aCoarseAngleShape, 10.0); + const MeshCounts aFineMesh = countMeshElements(aFineAngleShape, 1.0); + + EXPECT_NE(aCoarseMesh.NbNodes, aFineMesh.NbNodes); + EXPECT_NE(aCoarseMesh.NbTriangles, aFineMesh.NbTriangles); +} + +// Migrated from tests/bugs/mesh/bug30234. A zero-radius free edge is a +// legitimate degenerate input and must not acquire a face triangulation. +TEST(BRepMesh_IncrementalMeshTest, OCC30234_ZeroLengthFreeEdgeHasNoTriangles) +{ + const occ::handle aCircle = new Geom_Circle(gp_Ax2(gp::Origin(), gp::DZ()), 0.0); + BRepBuilderAPI_MakeEdge aEdgeBuilder(aCircle); + ASSERT_TRUE(aEdgeBuilder.IsDone()); + + IMeshTools_Parameters aParameters; + aParameters.Deflection = 0.005; + aParameters.Relative = true; + BRepMesh_IncrementalMesh aMesher(aEdgeBuilder.Edge(), aParameters); + EXPECT_TRUE(aMesher.IsDone()); + + int aNbNodes = 0; + int aNbTriangles = 0; + for (TopExp_Explorer anExplorer(aEdgeBuilder.Edge(), TopAbs_FACE); anExplorer.More(); + anExplorer.Next()) + { + TopLoc_Location aLocation; + const occ::handle aTriangulation = + BRep_Tool::Triangulation(TopoDS::Face(anExplorer.Current()), aLocation); + ASSERT_FALSE(aTriangulation.IsNull()); + aNbNodes += aTriangulation->NbNodes(); + aNbTriangles += aTriangulation->NbTriangles(); + } + EXPECT_EQ(aNbNodes, 0); + EXPECT_EQ(aNbTriangles, 0); +} + +// Migrated from tests/bugs/mesh/bug31125. Meshing an empty compound is a +// no-op and must complete without dereferencing a missing face. +TEST(BRepMesh_IncrementalMeshTest, OCC31125_EmptyCompoundDoesNotCrash) +{ + BRep_Builder aBuilder; + TopoDS_Compound anEmptyCompound; + aBuilder.MakeCompound(anEmptyCompound); + + IMeshTools_Parameters aParameters; + aParameters.Deflection = 1.0; + EXPECT_NO_THROW(BRepMesh_IncrementalMesh(anEmptyCompound, aParameters)); +} + +// Migrated from tests/bugs/mesh/bug31461. A second pass with +// AllowQualityDecrease must replace the fine sphere mesh with the requested +// coarser one. +TEST(BRepMesh_IncrementalMeshTest, OCC31461_AllowQualityDecreaseRebuildsMesh) +{ + const TopoDS_Shape aSphere = BRepPrimAPI_MakeSphere(10.0).Shape(); + + struct MeshCounts + { + int NbNodes; + int NbTriangles; + }; + + const auto countMeshElements = [](const TopoDS_Shape& theShape) { + int aNbNodes = 0; + int aNbTriangles = 0; + for (TopExp_Explorer anExplorer(theShape, TopAbs_FACE); anExplorer.More(); anExplorer.Next()) + { + TopLoc_Location aLocation; + const occ::handle aTriangulation = + BRep_Tool::Triangulation(TopoDS::Face(anExplorer.Current()), aLocation); + EXPECT_FALSE(aTriangulation.IsNull()); + if (!aTriangulation.IsNull()) + { + aNbNodes += aTriangulation->NbNodes(); + aNbTriangles += aTriangulation->NbTriangles(); + } + } + return MeshCounts{aNbNodes, aNbTriangles}; + }; + + IMeshTools_Parameters aFineParameters; + aFineParameters.Deflection = 0.01; + BRepMesh_IncrementalMesh aFineMesher(aSphere, aFineParameters); + ASSERT_TRUE(aFineMesher.IsDone()); + const MeshCounts aFineMesh = countMeshElements(aSphere); + EXPECT_EQ(aFineMesh.NbNodes, 5106); + EXPECT_EQ(aFineMesh.NbTriangles, 10108); + + IMeshTools_Parameters aCoarseParameters; + aCoarseParameters.Deflection = 0.1; + aCoarseParameters.AllowQualityDecrease = true; + BRepMesh_IncrementalMesh aCoarseMesher(aSphere, aCoarseParameters); + ASSERT_TRUE(aCoarseMesher.IsDone()); + const MeshCounts aCoarseMesh = countMeshElements(aSphere); + EXPECT_LT(aCoarseMesh.NbNodes, aFineMesh.NbNodes); + EXPECT_LT(aCoarseMesh.NbTriangles, aFineMesh.NbTriangles); + + BRepTools::CleanGeometry(aSphere); + IMeshTools_Parameters aFineAfterCleanParameters; + aFineAfterCleanParameters.Deflection = 0.01; + BRepMesh_IncrementalMesh aFineAfterCleanMesher(aSphere, aFineAfterCleanParameters); + ASSERT_TRUE(aFineAfterCleanMesher.IsDone()); + + BRepTools::Clean(aSphere); + const MeshCounts aAfterCleanMesh = countMeshElements(aSphere); + EXPECT_EQ(aAfterCleanMesh.NbNodes, aCoarseMesh.NbNodes); + EXPECT_EQ(aAfterCleanMesh.NbTriangles, aCoarseMesh.NbTriangles); +} diff --git a/src/ModelingAlgorithms/TKOffset/GTests/BRepOffsetAPI_MakePipeShell_Test.cxx b/src/ModelingAlgorithms/TKOffset/GTests/BRepOffsetAPI_MakePipeShell_Test.cxx index 2fdad8c9a8..746f6c5ad2 100644 --- a/src/ModelingAlgorithms/TKOffset/GTests/BRepOffsetAPI_MakePipeShell_Test.cxx +++ b/src/ModelingAlgorithms/TKOffset/GTests/BRepOffsetAPI_MakePipeShell_Test.cxx @@ -18,6 +18,7 @@ #include #include #include +#include #include #include #include @@ -30,8 +31,11 @@ #include #include #include +#include +#include #include #include +#include #include #include #include @@ -264,3 +268,55 @@ TEST(BRepOffsetAPI_MakePipeShellTest, Bug332_BentTubeWithScalingLaw) EXPECT_GE(countMatching(aExpLen4), 1) << "No wire found with circumference pi*(dia2+2*wall) = " << aExpLen4; } + +// pipe/bugs/bug24909_2: the original DRAW test is an explicit TODO because +// buildsweep throws "Not Done" for this closed-spine configuration. +TEST(BRepOffsetAPI_MakePipeShellTest, Bug24909_2_ClosedCircularSpine) +{ + // The source DRAW test is explicitly incomplete: this configuration may fail with + // NotDone or be accepted by the sweep implementation depending on the platform. + const gp_Circ aCircle(gp_Ax2(gp_Pnt(0.0, 0.0, 0.0), gp_Dir(0.0, 0.0, 1.0)), 40.0); + const TopoDS_Wire aBaseWire = BRepBuilderAPI_MakeWire(BRepBuilderAPI_MakeEdge(aCircle)).Wire(); + + gp_Trsf aRotate; + aRotate.SetRotation(gp_Ax1(gp_Pnt(0.0, 0.0, 0.0), gp_Dir(0.0, 1.0, 0.0)), M_PI / 2.0); + const TopoDS_Wire aRotatedWire = + TopoDS::Wire(BRepBuilderAPI_Transform(aBaseWire, aRotate, false).Shape()); + + gp_Trsf aTranslateUp; + aTranslateUp.SetTranslation(gp_Vec(0.0, 0.0, 75.0)); + const TopoDS_Wire aSketch = + TopoDS::Wire(BRepBuilderAPI_Transform(aRotatedWire, aTranslateUp, false).Shape()); + + gp_Trsf aTranslateDown; + aTranslateDown.SetTranslation(gp_Vec(0.0, 0.0, -75.0)); + const TopoDS_Wire aSketch001 = + TopoDS::Wire(BRepBuilderAPI_Transform(aRotatedWire, aTranslateDown, false).Shape()); + + gp_Trsf aTranslateSpine; + aTranslateSpine.SetTranslation(gp_Vec(50.0, 0.0, 0.0)); + const TopoDS_Wire aSketch002 = + TopoDS::Wire(BRepBuilderAPI_Transform(aBaseWire, aTranslateSpine, false).Shape()); + + BRepOffsetAPI_MakePipeShell aSweep(aSketch002); + aSweep.SetMode(false); // setsweep -CF + aSweep.Add(aSketch001); + aSweep.Add(aSketch); + + try + { + aSweep.Build(); + } + catch (const Standard_Failure&) + { + GTEST_SKIP() << "The historical closed-spine sweep still reports NotDone."; + } + + if (!aSweep.IsDone()) + { + GTEST_SKIP() << "The closed-spine sweep did not complete on this platform."; + } + + EXPECT_EQ(aSweep.GetStatus(), BRepBuilderAPI_PipeDone); + EXPECT_FALSE(aSweep.Shape().IsNull()); +} diff --git a/src/ModelingAlgorithms/TKPrim/GTests/BRepPrimAPI_MakeRevol_Test.cxx b/src/ModelingAlgorithms/TKPrim/GTests/BRepPrimAPI_MakeRevol_Test.cxx new file mode 100644 index 0000000000..bbfa52ac2a --- /dev/null +++ b/src/ModelingAlgorithms/TKPrim/GTests/BRepPrimAPI_MakeRevol_Test.cxx @@ -0,0 +1,120 @@ +// Copyright (c) 2026 OPEN CASCADE SAS +// +// This file is part of Open CASCADE Technology software library. +// +// This library is free software; you can redistribute it and/or modify it under +// the terms of the GNU Lesser General Public License version 2.1 as published +// by the Free Software Foundation, with special exception defined in the file +// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT +// distribution for complete text of the license and disclaimer of any warranty. +// +// Alternatively, this file may be used under the terms of Open CASCADE +// commercial license or contractual agreement. + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +namespace +{ + +void CheckToroidalRevolution(const gp_Dir& theXDirection, const double theRadius) +{ + const gp_Ax2 anCircleAxis(gp_Pnt(0.0, 100.00001, 0.0), gp_Dir(1.0, 0.0, 0.0), theXDirection); + occ::handle aCircle = new Geom_Circle(anCircleAxis, theRadius); + + BRepBuilderAPI_MakeEdge aMakeEdge(aCircle); + ASSERT_TRUE(aMakeEdge.IsDone()); + + const gp_Ax1 aRevolutionAxis(gp_Pnt(0.0, 0.0, 0.0), gp_Dir(0.0, 0.0, 1.0)); + BRepPrimAPI_MakeRevol aMakeRevol(aMakeEdge.Edge(), aRevolutionAxis, M_PI / 2.0); + ASSERT_TRUE(aMakeRevol.IsDone()); + + const TopoDS_Shape aResult = aMakeRevol.Shape(); + ASSERT_FALSE(aResult.IsNull()); + EXPECT_TRUE(BRepCheck_Analyzer(aResult).IsValid()); + + TopExp_Explorer anExplorer(aResult, TopAbs_FACE); + ASSERT_TRUE(anExplorer.More()); + const TopoDS_Face& aFace = TopoDS::Face(anExplorer.Current()); + occ::handle aSurface = BRep_Tool::Surface(aFace); + ASSERT_FALSE(aSurface.IsNull()); + EXPECT_TRUE(aSurface->IsKind(STANDARD_TYPE(Geom_ToroidalSurface))); + EXPECT_FALSE(aSurface->IsKind(STANDARD_TYPE(Geom_SurfaceOfRevolution))); +} + +} // namespace + +// Migrated from tests/bugs/modalg_5/bug23954. Revolving circles in the four +// orientations used by DRAW must preserve their toroidal surface type. +TEST(BRepPrimAPI_MakeRevolTest, ModalgBug_23954_CircleRevolutionsKeepToroidalSurface) +{ + CheckToroidalRevolution(gp_Dir(0.0, 1.0, 0.0), 100.0); + CheckToroidalRevolution(gp_Dir(0.0, 0.0, 1.0), 100.0); + CheckToroidalRevolution(gp_Dir(0.0, -1.0, 0.0), 100.0); + CheckToroidalRevolution(gp_Dir(0.0, 0.0, 1.0), 10.0); +} + +// Migrated from tests/bugs/modalg_5/bug24328. Revolving the two-edge wire +// must produce a shape accepted by the Boolean-operation validity checker. +TEST(BRepPrimAPI_MakeRevolTest, ModalgBug_24328_RevolvedWireIsValid) +{ + const TopoDS_Vertex aVertex1 = BRepBuilderAPI_MakeVertex(gp_Pnt(23.5, 11.123, 0.0)); + const TopoDS_Vertex aVertex2 = BRepBuilderAPI_MakeVertex(gp_Pnt(22.0, 11.1409, 0.0)); + const TopoDS_Vertex aVertex3 = BRepBuilderAPI_MakeVertex(gp_Pnt(20.5, 11.1807, 0.0)); + const TopoDS_Edge anEdge1 = BRepBuilderAPI_MakeEdge(aVertex1, aVertex2); + const TopoDS_Edge anEdge2 = BRepBuilderAPI_MakeEdge(aVertex2, aVertex3); + const TopoDS_Wire aWire = BRepBuilderAPI_MakeWire(anEdge1, anEdge2); + + BRepPrimAPI_MakeRevol aMakeRevol(aWire, + gp_Ax1(gp_Pnt(0.0, 0.0, 0.0), gp_Dir(1.0, 0.0, 0.0)), + 2.0 * M_PI); + ASSERT_TRUE(aMakeRevol.IsDone()); + const TopoDS_Shape aResult = aMakeRevol.Shape(); + ASSERT_FALSE(aResult.IsNull()); + EXPECT_TRUE(BRepCheck_Analyzer(aResult).IsValid()); +} + +// Migrated from tests/bugs/modalg_5/bug25578. Revolving the partial-sphere +// face around both axes must complete without a singularity crash. +TEST(BRepPrimAPI_MakeRevolTest, ModalgBug_25578_PartialSphereRevolutions) +{ + BRepPrimAPI_MakeSphere aMakeSphere(5.0, 0.0, M_PI / 2.0, M_PI / 2.0); + const TopoDS_Shape aSphere = aMakeSphere.Shape(); + ASSERT_TRUE(aMakeSphere.IsDone()); + + TopExp_Explorer aFaceExplorer(aSphere, TopAbs_FACE); + ASSERT_TRUE(aFaceExplorer.More()); + const TopoDS_Face aFace = TopoDS::Face(aFaceExplorer.Current()); + + const gp_Ax1 anAxisZ(gp_Pnt(0.0, 0.0, 0.0), gp_Dir(0.0, 0.0, 1.0)); + BRepPrimAPI_MakeRevol aRevolZ(aFace, anAxisZ, 2.0 * M_PI); + ASSERT_TRUE(aRevolZ.IsDone()); + ASSERT_FALSE(aRevolZ.Shape().IsNull()); + + const gp_Ax1 anAxisX(gp_Pnt(0.0, 0.0, 0.0), gp_Dir(1.0, 0.0, 0.0)); + BRepPrimAPI_MakeRevol aRevolX(aFace, anAxisX, M_PI / 2.0); + ASSERT_TRUE(aRevolX.IsDone()); + ASSERT_FALSE(aRevolX.Shape().IsNull()); +} diff --git a/src/ModelingAlgorithms/TKPrim/GTests/FILES.cmake b/src/ModelingAlgorithms/TKPrim/GTests/FILES.cmake index e9c2c2fdc9..a8fdc4fa55 100644 --- a/src/ModelingAlgorithms/TKPrim/GTests/FILES.cmake +++ b/src/ModelingAlgorithms/TKPrim/GTests/FILES.cmake @@ -6,6 +6,7 @@ set(OCCT_TKPrim_GTests_FILES BRepPrimAPI_MakeCone_Test.cxx BRepPrimAPI_MakeCylinder_Test.cxx BRepPrimAPI_MakePrism_Test.cxx + BRepPrimAPI_MakeRevol_Test.cxx BRepPrimAPI_MakeSphere_Test.cxx BRepPrimAPI_MakeTorus_Test.cxx BRepPrimAPI_MakeWedge_Test.cxx diff --git a/src/ModelingAlgorithms/TKShHealing/GTests/ShapeFix_Shape_Test.cxx b/src/ModelingAlgorithms/TKShHealing/GTests/ShapeFix_Shape_Test.cxx index 42a6e3ecd4..1e9ab5aa3f 100644 --- a/src/ModelingAlgorithms/TKShHealing/GTests/ShapeFix_Shape_Test.cxx +++ b/src/ModelingAlgorithms/TKShHealing/GTests/ShapeFix_Shape_Test.cxx @@ -13,6 +13,7 @@ #include #include +#include #include #include #include @@ -21,9 +22,18 @@ #include #include #include +#include +#include +#include #include +#include +#include +#include #include +#include #include +#include +#include #include @@ -123,3 +133,60 @@ TEST(ShapeFix_ShapeTest, HealPrismFromSelfIntersectingFace) BRepCheck_Analyzer anAnalyzer(aFixer->Shape()); EXPECT_TRUE(anAnalyzer.IsValid()); } + +// Migrated from tests/bugs/heal/bug24881. A valid box must pass the same +// reorder/gap-fixing sequence used by the DRAW OCC24881 command without +// reporting a failure status for either 3D or 2D gaps. +TEST(ShapeFix_ShapeTest, OCC24881_ValidBoxHasNoWireGapFailures) +{ + const TopoDS_Shape aBox = BRepPrimAPI_MakeBox(100.0, 200.0, 300.0).Shape(); + ASSERT_FALSE(aBox.IsNull()); + + occ::handle aWireFix = new ShapeFix_Wire; + int aNbWires = 0; + for (TopExp_Explorer aFaceExplorer(aBox, TopAbs_FACE); aFaceExplorer.More(); aFaceExplorer.Next()) + { + const TopoDS_Face aFace = TopoDS::Face(aFaceExplorer.Current()); + for (TopoDS_Iterator aWireIterator(aFace); aWireIterator.More(); aWireIterator.Next()) + { + const TopoDS_Wire aWire = TopoDS::Wire(aWireIterator.Value()); + aWireFix->Load(aWire); + aWireFix->SetFace(aFace); + EXPECT_NO_THROW(aWireFix->FixReorder()); + + bool aFixed3d = false; + EXPECT_NO_THROW(aFixed3d = aWireFix->FixGaps3d()); + EXPECT_FALSE(aWireFix->StatusGaps3d(ShapeExtend_FAIL)); + + bool aFixed2d = false; + EXPECT_NO_THROW(aFixed2d = aWireFix->FixGaps2d()); + EXPECT_FALSE(aWireFix->StatusGaps2d(ShapeExtend_FAIL)); + (void)aFixed3d; + (void)aFixed2d; + ++aNbWires; + } + } + + EXPECT_EQ(aNbWires, 6); +} + +// Migrated from tests/bugs/heal/bug25014. The DRAW stwire +r path must be +// safe even when the input wire contains no edges. +TEST(ShapeFix_ShapeTest, OCC25014_EmptyWireReorderDoesNotThrow) +{ + BRep_Builder aBuilder; + TopoDS_Wire anEmptyWire; + aBuilder.MakeWire(anEmptyWire); + + occ::handle aWireData = new ShapeExtend_WireData; + occ::handle anAnalyzer = new ShapeAnalysis_Wire; + anAnalyzer->Load(aWireData); + + ShapeFix_Wire aFixer; + aFixer.Init(anAnalyzer); + ShapeAnalysis_WireOrder anOrder(true, BRepBuilderAPI::Precision()); + EXPECT_NO_THROW(anAnalyzer->CheckOrder(anOrder)); + EXPECT_NO_THROW(aFixer.FixReorder(anOrder)); + EXPECT_EQ(anOrder.NbEdges(), 0); + EXPECT_EQ(anEmptyWire.ShapeType(), TopAbs_WIRE); +} diff --git a/src/ModelingAlgorithms/TKShHealing/GTests/ShapeUpgrade_UnifySameDomain_Test.cxx b/src/ModelingAlgorithms/TKShHealing/GTests/ShapeUpgrade_UnifySameDomain_Test.cxx index 58894d2756..1b38583ff2 100644 --- a/src/ModelingAlgorithms/TKShHealing/GTests/ShapeUpgrade_UnifySameDomain_Test.cxx +++ b/src/ModelingAlgorithms/TKShHealing/GTests/ShapeUpgrade_UnifySameDomain_Test.cxx @@ -13,23 +13,39 @@ #include +#include #include +#include +#include #include +#include +#include #include #include +#include #include #include #include +#include +#include #include +#include #include #include #include #include #include +#include #include +#include +#include +#include #include #include +#include #include +#include +#include #include #include #include @@ -38,6 +54,7 @@ #include #include +#include //================================================================================================= // ShapeUpgrade_UnifySameDomain Tests @@ -259,15 +276,24 @@ static bool addPlanarFacePair(BRep_Builder& theBuilder, TopoDS_Shell& theShell) return true; } +static int countSubShapes(const TopoDS_Shape& theShape, const TopAbs_ShapeEnum theType) +{ + NCollection_IndexedMap aMap; + for (TopExp_Explorer anExp(theShape, theType); anExp.More(); anExp.Next()) + { + TopoDS_Shape aSubShape = anExp.Current(); + // Match DRAW's default nbshapes command, which ignores locations. + aSubShape.Location(TopLoc_Location()); + aMap.Add(aSubShape); + } + return aMap.Extent(); +} + static int countFaces(const TopoDS_Shape& theShape) { - int aFaceCount = 0; - for (TopExp_Explorer anExp(theShape, TopAbs_FACE); anExp.More(); anExp.Next()) - { - ++aFaceCount; - } - return aFaceCount; + return countSubShapes(theShape, TopAbs_FACE); } + } // namespace // Test for issue #925: Infinite loop when processing internal edges. @@ -589,3 +615,125 @@ TEST(ShapeUpgrade_UnifySameDomainTest, MissingSourcePCurveDuringTransformation) ASSERT_FALSE(aResult.IsNull()); EXPECT_EQ(countFaces(aResult), 2); } + +// Migrated from tests/bugs/heal/bug29382_3. Preserve all DRAW validations: +// valid result, exact topology counts, and the maximum tolerance bound. +TEST(ShapeUpgrade_UnifySameDomainTest, OCC29382_CommonShapeHasStableTopology) +{ + NCollection_Array1 aPoles(1, 5); + aPoles(1) = gp_Pnt(0.0, 0.0, 0.0); + aPoles(2) = gp_Pnt(1.0, 0.0, 0.0); + aPoles(3) = gp_Pnt(2.0, 2.0, 0.0); + aPoles(4) = gp_Pnt(0.0, 0.5, 0.0); + aPoles(5) = gp_Pnt(0.0, 0.0, 0.0); + const occ::handle aBezier = new Geom_BezierCurve(aPoles); + + BRepBuilderAPI_MakeEdge aEdgeBuilder(aBezier); + ASSERT_TRUE(aEdgeBuilder.IsDone()); + BRepBuilderAPI_MakeWire aWireBuilder(aEdgeBuilder.Edge()); + ASSERT_TRUE(aWireBuilder.IsDone()); + BRepBuilderAPI_MakeFace aFaceBuilder(aWireBuilder.Wire(), false); + ASSERT_TRUE(aFaceBuilder.IsDone()); + BRepPrimAPI_MakePrism aPrismBuilder(aFaceBuilder.Face(), gp_Vec(0.0, 0.0, 1.0)); + ASSERT_TRUE(aPrismBuilder.IsDone()); + + BRepPrimAPI_MakeBox aBoxBuilder(gp_Pnt(-0.3, -0.2, 0.0), 1.0, 0.4, 1.0); + aBoxBuilder.Build(); + ASSERT_TRUE(aBoxBuilder.IsDone()); + BRepAlgoAPI_Common aCommon(aPrismBuilder.Shape(), aBoxBuilder.Shape()); + aCommon.Build(); + ASSERT_TRUE(aCommon.IsDone()); + ASSERT_FALSE(aCommon.Shape().IsNull()); + + ShapeUpgrade_UnifySameDomain aUnifier(aCommon.Shape(), true, true, true); + aUnifier.Build(); + const TopoDS_Shape& aResult = aUnifier.Shape(); + ASSERT_FALSE(aResult.IsNull()); + EXPECT_TRUE(BRepCheck_Analyzer(aResult).IsValid()); + + EXPECT_EQ(countSubShapes(aResult, TopAbs_SOLID), 1); + EXPECT_EQ(countSubShapes(aResult, TopAbs_SHELL), 1); + EXPECT_EQ(countSubShapes(aResult, TopAbs_FACE), 5); + EXPECT_EQ(countSubShapes(aResult, TopAbs_WIRE), 5); + EXPECT_EQ(countSubShapes(aResult, TopAbs_EDGE), 9); + EXPECT_EQ(countSubShapes(aResult, TopAbs_VERTEX), 5); + + double aMaxTolerance = 0.0; + for (TopExp_Explorer anExp(aResult, TopAbs_VERTEX); anExp.More(); anExp.Next()) + { + aMaxTolerance = std::max(aMaxTolerance, BRep_Tool::Tolerance(TopoDS::Vertex(anExp.Current()))); + } + for (TopExp_Explorer anExp(aResult, TopAbs_EDGE); anExp.More(); anExp.Next()) + { + aMaxTolerance = std::max(aMaxTolerance, BRep_Tool::Tolerance(TopoDS::Edge(anExp.Current()))); + } + for (TopExp_Explorer anExp(aResult, TopAbs_FACE); anExp.More(); anExp.Next()) + { + aMaxTolerance = std::max(aMaxTolerance, BRep_Tool::Tolerance(TopoDS::Face(anExp.Current()))); + } + EXPECT_LE(aMaxTolerance, 6.e-6); +} + +// Migrated from tests/bugs/heal/bug30927. Unification must retain the Closed +// flag of every wire produced by the fuse. +TEST(ShapeUpgrade_UnifySameDomainTest, OCC30927_FusedSolidKeepsClosedWires) +{ + BRepPrimAPI_MakeBox aBox1Builder(10.0, 10.0, 10.0); + BRepPrimAPI_MakeBox aBox2Builder(gp_Pnt(5.0, 0.0, -5.0), 10.0, 10.0, 20.0); + aBox1Builder.Build(); + aBox2Builder.Build(); + ASSERT_TRUE(aBox1Builder.IsDone()); + ASSERT_TRUE(aBox2Builder.IsDone()); + + BRepAlgoAPI_Fuse aFuse(aBox1Builder.Shape(), aBox2Builder.Shape()); + aFuse.Build(); + ASSERT_TRUE(aFuse.IsDone()); + ASSERT_FALSE(aFuse.Shape().IsNull()); + + ShapeUpgrade_UnifySameDomain aUnifier(aFuse.Shape()); + aUnifier.Build(); + const TopoDS_Shape& aResult = aUnifier.Shape(); + ASSERT_FALSE(aResult.IsNull()); + + int aNbWires = 0; + for (TopExp_Explorer anExp(aResult, TopAbs_WIRE); anExp.More(); anExp.Next()) + { + EXPECT_TRUE(TopoDS::Wire(anExp.Current()).Closed()); + ++aNbWires; + } + EXPECT_GT(aNbWires, 0); +} + +// Migrated from tests/bugs/heal/bug29544_2. Two collinear edge pieces split +// by a nearby vertex must be merged back into one ten-unit edge. +TEST(ShapeUpgrade_UnifySameDomainTest, OCC29544_NearbyLinearSplitIsUnified) +{ + const occ::handle aLine = new Geom_Line(gp_Pnt(0.0, 0.0, 0.0), gp_Dir(1.0, 0.0, 0.0)); + BRepBuilderAPI_MakeEdge aEdgeBuilder(aLine, 0.0, 10.0); + ASSERT_TRUE(aEdgeBuilder.IsDone()); + const TopoDS_Edge aReferenceEdge = aEdgeBuilder.Edge(); + + const TopoDS_Vertex aSplitVertex = BRepBuilderAPI_MakeVertex(gp_Pnt(5.0, 2.0e-7, 0.0)); + ASSERT_FALSE(aSplitVertex.IsNull()); + + BOPAlgo_Splitter aSplitter; + aSplitter.AddArgument(aReferenceEdge); + aSplitter.AddTool(aSplitVertex); + aSplitter.SetRunParallel(false); + aSplitter.Perform(); + ASSERT_FALSE(aSplitter.HasErrors()); + const TopoDS_Shape aSplitShape = aSplitter.Shape(); + ASSERT_FALSE(aSplitShape.IsNull()); + + ShapeUpgrade_UnifySameDomain aUnifier(aSplitShape); + aUnifier.Build(); + const TopoDS_Shape& aResult = aUnifier.Shape(); + ASSERT_FALSE(aResult.IsNull()); + EXPECT_TRUE(BRepCheck_Analyzer(aResult).IsValid()); + EXPECT_EQ(countSubShapes(aResult, TopAbs_VERTEX), 2); + EXPECT_EQ(countSubShapes(aResult, TopAbs_EDGE), 1); + + GProp_GProps aProperties; + BRepGProp::LinearProperties(aResult, aProperties); + EXPECT_NEAR(aProperties.Mass(), 10.0, Precision::Confusion()); +} diff --git a/src/ModelingAlgorithms/TKTopAlgo/GTests/BRepBndLib_Test.cxx b/src/ModelingAlgorithms/TKTopAlgo/GTests/BRepBndLib_Test.cxx new file mode 100644 index 0000000000..431460a33c --- /dev/null +++ b/src/ModelingAlgorithms/TKTopAlgo/GTests/BRepBndLib_Test.cxx @@ -0,0 +1,234 @@ +// Copyright (c) 2026 OPEN CASCADE SAS +// +// This file is part of Open CASCADE Technology software library. +// +// This library is free software; you can redistribute it and/or modify it under +// the terms of the GNU Lesser General Public License version 2.1 as published +// by the Free Software Foundation, with special exception defined in the file +// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT +// distribution for complete text of the license and disclaimer of any warranty. +// +// Alternatively, this file may be used under the terms of Open CASCADE +// commercial license or contractual agreement. + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace +{ +void expectSameBounds(const Bnd_Box& theFirst, const Bnd_Box& theSecond) +{ + const Bnd_Box::Limits aFirst = theFirst.Get(); + const Bnd_Box::Limits aSecond = theSecond.Get(); + EXPECT_DOUBLE_EQ(aFirst.Xmin, aSecond.Xmin); + EXPECT_DOUBLE_EQ(aFirst.Xmax, aSecond.Xmax); + EXPECT_DOUBLE_EQ(aFirst.Ymin, aSecond.Ymin); + EXPECT_DOUBLE_EQ(aFirst.Ymax, aSecond.Ymax); + EXPECT_DOUBLE_EQ(aFirst.Zmin, aSecond.Zmin); + EXPECT_DOUBLE_EQ(aFirst.Zmax, aSecond.Zmax); +} + +void expectBounds(const Bnd_Box& theBox, + const double theXMin, + const double theYMin, + const double theZMin, + const double theXMax, + const double theYMax, + const double theZMax) +{ + const Bnd_Box::Limits aLimits = theBox.Get(); + EXPECT_NEAR(aLimits.Xmin, theXMin, 1.e-12); + EXPECT_NEAR(aLimits.Ymin, theYMin, 1.e-12); + EXPECT_NEAR(aLimits.Zmin, theZMin, 1.e-12); + EXPECT_NEAR(aLimits.Xmax, theXMax, 1.e-12); + EXPECT_NEAR(aLimits.Ymax, theYMax, 1.e-12); + EXPECT_NEAR(aLimits.Zmax, theZMax, 1.e-12); +} + +TopoDS_Edge makeCircleEdge() +{ + const occ::handle aCircle = + new Geom_Circle(gp_Ax2(gp_Pnt(0.0, 0.0, 0.0), gp_Dir(0.0, 0.0, 1.0)), 1.0); + return BRepBuilderAPI_MakeEdge(aCircle).Edge(); +} + +TopoDS_Edge makePolygon3dEdge() +{ + NCollection_Array1 aNodes(1, 5); + aNodes(1) = gp_Pnt(1.0, 0.0, 0.0); + aNodes(2) = gp_Pnt(0.0, 1.0, 0.0); + aNodes(3) = gp_Pnt(-1.0, 0.0, 0.0); + aNodes(4) = gp_Pnt(0.0, -1.0, 0.0); + aNodes(5) = gp_Pnt(1.0, 0.0, 0.0); + + const occ::handle aPolygon = new Poly_Polygon3D(aNodes); + TopoDS_Edge anEdge; + BRep_Builder aBuilder; + aBuilder.MakeEdge(anEdge, aPolygon); + return anEdge; +} + +TopoDS_Edge thirdCylinderEdge(const TopoDS_Shape& theCylinder) +{ + TopExp_Explorer anExplorer(theCylinder, TopAbs_EDGE); + anExplorer.Next(); + anExplorer.Next(); + return TopoDS::Edge(anExplorer.Current()); +} +} // namespace + +// Migrated from tests/lowalgos/bnd/bug30292. A geometric edge without a +// discrete representation must have the same bounds with and without mesh use. +TEST(BRepBndLibTest, OCC30292_GeometricEdgeWithoutDiscreteRepresentation) +{ + const TopoDS_Edge aCircleEdge = makeCircleEdge(); + + Bnd_Box aWithTriangulation; + Bnd_Box aWithoutTriangulation; + BRepBndLib::Add(aCircleEdge, aWithTriangulation, true); + BRepBndLib::Add(aCircleEdge, aWithoutTriangulation, false); + expectSameBounds(aWithTriangulation, aWithoutTriangulation); +} + +// The polygon path and the exact-geometry path intentionally produce different +// boxes for a meshed circular edge; both are checked against DRAW's references. +TEST(BRepBndLibTest, OCC30292_MeshedGeometricEdgeUsesRequestedRepresentation) +{ + const TopoDS_Edge aCircleEdge = makeCircleEdge(); + BRepMesh_IncrementalMesh aMesher(aCircleEdge, 0.1); + ASSERT_TRUE(aMesher.IsDone()); + + Bnd_Box aWithTriangulation; + Bnd_Box aWithoutTriangulation; + BRepBndLib::Add(aCircleEdge, aWithTriangulation, true); + BRepBndLib::Add(aCircleEdge, aWithoutTriangulation, false); + + expectBounds(aWithTriangulation, + -1.1000001, + -1.0927089740980542, + -0.1000001, + 1.1000001, + 1.092708974098054, + 0.1000001); + expectBounds(aWithoutTriangulation, -1.0000001, -1.0000001, -1.e-7, 1.0000001, 1.0000001, 1.e-7); +} + +TEST(BRepBndLibTest, OCC30292_MeshedCylinderEdgeUsesPolygon3d) +{ + const TopoDS_Shape aCylinder = BRepPrimAPI_MakeCylinder(1.0, 1.0).Shape(); + const TopoDS_Edge aCylinderEdge = thirdCylinderEdge(aCylinder); + BRepMesh_IncrementalMesh aMesher(aCylinder, 0.1); + ASSERT_TRUE(aMesher.IsDone()); + + Bnd_Box aWithTriangulation; + Bnd_Box aWithoutTriangulation; + BRepBndLib::Add(aCylinderEdge, aWithTriangulation, true); + BRepBndLib::Add(aCylinderEdge, aWithoutTriangulation, false); + + expectBounds(aWithTriangulation, + -1.1000001, + -1.0927089740980542, + -0.1000001, + 1.1000001, + 1.092708974098054, + 0.1000001); + expectBounds(aWithoutTriangulation, -1.0000001, -1.0000001, -1.e-7, 1.0000001, 1.0000001, 1.e-7); +} + +// A polygon-only edge has no geometric curve, so the representation flag must +// not change its bounds. +TEST(BRepBndLibTest, OCC30292_Polygon3dEdgeIgnoresRepresentationFlag) +{ + const TopoDS_Edge aPolygonEdge = makePolygon3dEdge(); + + Bnd_Box aWithTriangulation; + Bnd_Box aWithoutTriangulation; + BRepBndLib::Add(aPolygonEdge, aWithTriangulation, true); + BRepBndLib::Add(aPolygonEdge, aWithoutTriangulation, false); + expectSameBounds(aWithTriangulation, aWithoutTriangulation); +} + +// Migrated from tests/bugs/moddata_3/bug23575. A planar BSpline edge must not +// acquire a non-zero extent in the direction orthogonal to its plane. +TEST(BRepBndLibTest, OCC23575_PlanarBSplineEdgeBounds) +{ + NCollection_Array1 aPoles(1, 4); + aPoles(1) = gp_Pnt(0.0, 0.0, 0.0); + aPoles(2) = gp_Pnt(0.0, 1.0, 0.0); + aPoles(3) = gp_Pnt(1.0, 1.0, 0.0); + aPoles(4) = gp_Pnt(1.0, 0.0, 0.0); + + NCollection_Array1 aWeights(1, 4); + aWeights.Init(1.0); + + NCollection_Array1 aKnots(1, 2); + aKnots(1) = 0.0; + aKnots(2) = 1.0; + + NCollection_Array1 aMultiplicities(1, 2); + aMultiplicities(1) = 4; + aMultiplicities(2) = 4; + + const occ::handle aCurve = + new Geom_BSplineCurve(aPoles, aWeights, aKnots, aMultiplicities, 3, false); + const TopoDS_Edge anEdge = BRepBuilderAPI_MakeEdge(aCurve).Edge(); + + Bnd_Box aBox; + BRepBndLib::Add(anEdge, aBox); + ASSERT_FALSE(aBox.IsVoid()); + + const Bnd_Box::Limits aLimits = aBox.Get(); + // Keep the 0.1 tolerance from DRAW's checkreal commands: the curve does not + // interpolate all of its control points (its actual Ymax is about 0.90023). + constexpr double aTolerance = 0.1; + EXPECT_NEAR(aLimits.Xmin, 0.0, aTolerance); + EXPECT_NEAR(aLimits.Ymin, 0.0, aTolerance); + EXPECT_NEAR(aLimits.Zmin, 0.0, aTolerance); + EXPECT_NEAR(aLimits.Xmax, 1.0, aTolerance); + EXPECT_NEAR(aLimits.Ymax, 1.0, aTolerance); + EXPECT_NEAR(aLimits.Zmax, 0.0, aTolerance); + EXPECT_LE(aLimits.Zmax - aLimits.Zmin, 1.e-6); +} + +// Migrated from tests/bugs/moddata_2/bug6503. An infinite planar face must +// remain open in X and Y while retaining only its finite surface tolerance in Z. +TEST(BRepBndLibTest, OCC6503_InfinitePlaneBounds) +{ + const TopoDS_Face aFace = + BRepBuilderAPI_MakeFace(gp_Pln(gp_Pnt(0.0, 0.0, 0.0), gp_Dir(0.0, 0.0, 1.0))).Face(); + ASSERT_FALSE(aFace.IsNull()); + + Bnd_Box aBox; + BRepBndLib::Add(aFace, aBox); + ASSERT_FALSE(aBox.IsVoid()); + + const Bnd_Box::Limits aLimits = aBox.Get(); + const double anOpenBound = Precision::Infinite() / 2.0; + EXPECT_EQ(aLimits.Xmin, -anOpenBound); + EXPECT_EQ(aLimits.Xmax, anOpenBound); + EXPECT_EQ(aLimits.Ymin, -anOpenBound); + EXPECT_EQ(aLimits.Ymax, anOpenBound); + EXPECT_NEAR(aLimits.Zmin, -1.e-7, 1.e-12); + EXPECT_NEAR(aLimits.Zmax, 1.e-7, 1.e-12); +} diff --git a/src/ModelingAlgorithms/TKTopAlgo/GTests/BRepBuilderAPI_Copy_Test.cxx b/src/ModelingAlgorithms/TKTopAlgo/GTests/BRepBuilderAPI_Copy_Test.cxx index b4e6f6c455..90cb98aa73 100644 --- a/src/ModelingAlgorithms/TKTopAlgo/GTests/BRepBuilderAPI_Copy_Test.cxx +++ b/src/ModelingAlgorithms/TKTopAlgo/GTests/BRepBuilderAPI_Copy_Test.cxx @@ -12,10 +12,15 @@ // commercial license or contractual agreement. #include +#include #include #include #include +#include +#include #include +#include +#include #include #include #include @@ -104,3 +109,59 @@ TEST(BRepBuilderAPI_CopyTest, CopyGeomFalse) BRepCheck_Analyzer anAnalyzer(aCopy); EXPECT_TRUE(anAnalyzer.IsValid()) << "Shallow copy should produce a valid shape"; } + +// caf/nam/A4: CopyShape creates distinct subfaces with matching centers and +// retains the source location when the source is copied after translation. +TEST(BRepBuilderAPI_CopyTest, CafNamedShape_A4_CopyAndTranslate) +{ + const TopoDS_Shape aBox = BRepPrimAPI_MakeBox(12.0, 13.0, 14.0).Shape(); + BRepBuilderAPI_Copy aCopyBuilder(aBox); + const TopoDS_Shape aCopy = aCopyBuilder.Shape(); + ASSERT_FALSE(aCopy.IsNull()); + + int anOriginalFaceCount = 0; + int aCopiedFaceCount = 0; + for (TopExp_Explorer anExplorer(aBox, TopAbs_FACE); anExplorer.More(); anExplorer.Next()) + { + ++anOriginalFaceCount; + GProp_GProps anOriginalProperties; + BRepGProp::SurfaceProperties(anExplorer.Current(), anOriginalProperties); + const gp_Pnt anOriginalCenter = anOriginalProperties.CentreOfMass(); + int aMatchingFaces = 0; + for (TopExp_Explorer aCopyExplorer(aCopy, TopAbs_FACE); aCopyExplorer.More(); + aCopyExplorer.Next()) + { + GProp_GProps aCopyProperties; + BRepGProp::SurfaceProperties(aCopyExplorer.Current(), aCopyProperties); + if (aCopyProperties.CentreOfMass().IsEqual(anOriginalCenter, Precision::Confusion())) + { + ++aMatchingFaces; + EXPECT_FALSE(aCopyExplorer.Current().IsSame(anExplorer.Current())); + } + } + EXPECT_EQ(aMatchingFaces, 1); + } + for (TopExp_Explorer anExplorer(aCopy, TopAbs_FACE); anExplorer.More(); anExplorer.Next()) + { + ++aCopiedFaceCount; + } + EXPECT_EQ(anOriginalFaceCount, 6); + EXPECT_EQ(aCopiedFaceCount, anOriginalFaceCount); + + gp_Trsf aTranslation; + aTranslation.SetTranslation(gp_Vec(50.0, 40.0, 30.0)); + const TopoDS_Shape aTranslatedBox = BRepBuilderAPI_Transform(aBox, aTranslation).Shape(); + BRepBuilderAPI_Copy aTranslatedCopyBuilder(aTranslatedBox); + const TopoDS_Shape aTranslatedCopy = aTranslatedCopyBuilder.Shape(); + ASSERT_FALSE(aTranslatedCopy.IsNull()); + + GProp_GProps aTranslatedProperties; + GProp_GProps aTranslatedCopyProperties; + BRepGProp::VolumeProperties(aTranslatedBox, aTranslatedProperties); + BRepGProp::VolumeProperties(aTranslatedCopy, aTranslatedCopyProperties); + EXPECT_TRUE(aTranslatedProperties.CentreOfMass().IsEqual(aTranslatedCopyProperties.CentreOfMass(), + Precision::Confusion())); + EXPECT_TRUE( + aTranslatedProperties.CentreOfMass().IsEqual(gp_Pnt(56.0, 46.5, 37.0), Precision::Confusion())); + EXPECT_TRUE(BRepCheck_Analyzer(aTranslatedCopy).IsValid()); +} diff --git a/src/ModelingAlgorithms/TKTopAlgo/GTests/BRepBuilderAPI_MakeShell_Test.cxx b/src/ModelingAlgorithms/TKTopAlgo/GTests/BRepBuilderAPI_MakeShell_Test.cxx new file mode 100644 index 0000000000..f1415b5b54 --- /dev/null +++ b/src/ModelingAlgorithms/TKTopAlgo/GTests/BRepBuilderAPI_MakeShell_Test.cxx @@ -0,0 +1,50 @@ +// Copyright (c) 2026 OPEN CASCADE SAS +// +// This file is part of Open CASCADE Technology software library. +// +// This library is free software; you can redistribute it and/or modify it under +// the terms of the GNU Lesser General Public License version 2.1 as published +// by the Free Software Foundation, with special exception defined in the file +// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT +// distribution for complete text of the license and disclaimer of any warranty. +// +// Alternatively, this file may be used under the terms of Open CASCADE +// commercial license or contractual agreement. + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +// Migrated from tests/bugs/modalg_5/bug25591. The second unique edge of a +// sphere shell created from a surface must not acquire a spurious 3D curve. +TEST(BRepBuilderAPI_MakeShellTest, ModalgBug_25591_SphereSeamHasNo3dCurve) +{ + const occ::handle aSphere = + new Geom_SphericalSurface(gp_Ax3(gp_Pnt(0.0, 0.0, 0.0), gp_Dir(0.0, 0.0, 1.0)), 100.0); + BRepBuilderAPI_MakeShell aMaker(aSphere, false); + ASSERT_TRUE(aMaker.IsDone()); + + const TopoDS_Shell aShell = aMaker.Shell(); + ASSERT_FALSE(aShell.IsNull()); + + NCollection_IndexedMap anEdges; + TopExp::MapShapes(aShell, TopAbs_EDGE, anEdges); + ASSERT_GE(anEdges.Extent(), 2); + + TopLoc_Location aLocation; + double aFirst = 0.0, aLast = 0.0; + const occ::handle aCurve = + BRep_Tool::Curve(TopoDS::Edge(anEdges(2)), aLocation, aFirst, aLast); + EXPECT_TRUE(aCurve.IsNull()); +} diff --git a/src/ModelingAlgorithms/TKTopAlgo/GTests/BRepExtrema_ShapeProximity_Test.cxx b/src/ModelingAlgorithms/TKTopAlgo/GTests/BRepExtrema_ShapeProximity_Test.cxx new file mode 100644 index 0000000000..2b4332c36e --- /dev/null +++ b/src/ModelingAlgorithms/TKTopAlgo/GTests/BRepExtrema_ShapeProximity_Test.cxx @@ -0,0 +1,568 @@ +// Copyright (c) 2026 OPEN CASCADE SAS +// +// This file is part of Open CASCADE Technology software library. +// +// This library is free software; you can redistribute it and/or modify it under +// the terms of the GNU Lesser General Public License version 2.1 as published +// by the Free Software Foundation, with special exception defined in the file +// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT +// distribution for complete text of the license and disclaimer of any warranty. +// +// Alternatively, this file may be used under the terms of Open CASCADE +// commercial license or contractual agreement. + +#include + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace +{ +using ProximityStatus = BRepExtrema_ProximityDistTool::ProxPnt_Status; + +void expectProximityValue(const TopoDS_Shape& theShape1, + const TopoDS_Shape& theShape2, + const double theExpectedValue, + const double theTolerance, + const ProximityStatus theExpectedStatus1, + const ProximityStatus theExpectedStatus2, + const double theMeshDeflection, + const bool theCheckStatuses = true) +{ + BRepMesh_IncrementalMesh aMesh1(theShape1, theMeshDeflection); + BRepMesh_IncrementalMesh aMesh2(theShape2, theMeshDeflection); + ASSERT_TRUE(aMesh1.IsDone()); + ASSERT_TRUE(aMesh2.IsDone()); + + BRepExtrema_ShapeProximity aProximity(Precision::Infinite()); + ASSERT_TRUE(aProximity.LoadShape1(theShape1)); + ASSERT_TRUE(aProximity.LoadShape2(theShape2)); + aProximity.Perform(); + + ASSERT_TRUE(aProximity.IsDone()); + EXPECT_NEAR(aProximity.Proximity(), theExpectedValue, theTolerance); + if (theCheckStatuses) + { + EXPECT_EQ(aProximity.ProxPntStatus1(), theExpectedStatus1); + EXPECT_EQ(aProximity.ProxPntStatus2(), theExpectedStatus2); + } + EXPECT_FALSE( + aProximity.ProximityPoint1().IsEqual(aProximity.ProximityPoint2(), Precision::Confusion())); +} + +TopoDS_Edge makeCircularArc(const gp_Pnt& theCenter, + const gp_Dir& theNormal, + const double theRadius, + const double theFirstParameter, + const double theLastParameter) +{ + const gp_Circ aCircle(gp_Ax2(theCenter, theNormal), theRadius); + return BRepBuilderAPI_MakeEdge(aCircle, theFirstParameter, theLastParameter).Edge(); +} + +TopoDS_Edge makeTrimmedCircularArc(const gp_Pnt& theCenter, + const gp_Dir& theNormal, + const double theRadius, + const double theFirstParameter, + const double theLastParameter) +{ + const occ::handle aCircle = + new Geom_Circle(gp_Circ(gp_Ax2(theCenter, theNormal), theRadius)); + const occ::handle aTrimmedCircle = + new Geom_TrimmedCurve(aCircle, theFirstParameter, theLastParameter); + return BRepBuilderAPI_MakeEdge(aTrimmedCircle).Edge(); +} + +TopoDS_Edge makeFullCircularEdge(const gp_Pnt& theCenter, + const gp_Dir& theNormal, + const double theRadius) +{ + const occ::handle aCircle = + new Geom_Circle(gp_Circ(gp_Ax2(theCenter, theNormal), theRadius)); + return BRepBuilderAPI_MakeEdge(aCircle).Edge(); +} + +TopoDS_Face makePlanePatch(const gp_Pnt& theLocation, + const gp_Dir& theNormal, + const double theUMin, + const double theUMax, + const double theVMin, + const double theVMax) +{ + return BRepBuilderAPI_MakeFace(gp_Pln(theLocation, theNormal), theUMin, theUMax, theVMin, theVMax) + .Face(); +} + +TopoDS_Face makeCylinderPatch(const gp_Pnt& theLocation, + const gp_Dir& theDirection, + const double theRadius, + const double theFirstU, + const double theLastU, + const double theFirstV, + const double theLastV) +{ + const occ::handle aCylinder = + new Geom_CylindricalSurface(gp_Ax3(theLocation, theDirection), theRadius); + const occ::handle aTrimmedCylinder = + new Geom_RectangularTrimmedSurface(aCylinder, theFirstU, theLastU, theFirstV, theLastV); + return BRepBuilderAPI_MakeFace(aTrimmedCylinder, Precision::Confusion()).Face(); +} + +TopoDS_Face makeSpherePatch(const gp_Pnt& theCenter, const double theFirstU, const double theLastU) +{ + const occ::handle aSphere = + new Geom_SphericalSurface(gp_Ax3(theCenter, gp_Dir(0.0, 0.0, 1.0)), 1.0); + const occ::handle aTrimmedSphere = + new Geom_RectangularTrimmedSurface(aSphere, theFirstU, theLastU, -0.5 * M_PI, 0.5 * M_PI); + return BRepBuilderAPI_MakeFace(aTrimmedSphere, Precision::Confusion()).Face(); +} + +TopoDS_Face makeSphereFace(const gp_Pnt& theCenter) +{ + const occ::handle aSphere = + new Geom_SphericalSurface(gp_Ax3(theCenter, gp_Dir(0.0, 0.0, 1.0)), 1.0); + return BRepBuilderAPI_MakeFace(aSphere, Precision::Confusion()).Face(); +} + +TopoDS_Face makePolygonFace() +{ + BRepBuilderAPI_MakePolygon aPolygon; + aPolygon.Add(gp_Pnt(-1.0, -1.0, 1.0)); + aPolygon.Add(gp_Pnt(-1.0, 1.0, 1.0)); + aPolygon.Add(gp_Pnt(1.0, 1.0, 2.0)); + aPolygon.Add(gp_Pnt(1.0, -1.0, 2.0)); + aPolygon.Close(); + return BRepBuilderAPI_MakeFace(aPolygon.Wire(), true).Face(); +} + +TopoDS_Shape makeSplitSphere(const gp_Pnt& theCenter) +{ + BRep_Builder aBuilder; + TopoDS_Compound aCompound; + aBuilder.MakeCompound(aCompound); + aBuilder.Add(aCompound, makeSpherePatch(theCenter, 0.0, 0.5 * M_PI)); + aBuilder.Add(aCompound, makeSpherePatch(theCenter, 0.5 * M_PI, M_PI)); + return aCompound; +} + +TopoDS_Edge makeBezierEdge(const NCollection_Array1& thePoles) +{ + const occ::handle aCurve = new Geom_BezierCurve(thePoles); + return BRepBuilderAPI_MakeEdge(aCurve).Edge(); +} +} // namespace + +// Migrated from tests/lowalgos/proximity/A1. Two opposite semicircular edges +// have a proximity value equal to the diameter and interior proximity points. +TEST(BRepExtrema_ShapeProximityTest, LowAlgo_A1_OppositeCircularArcs) +{ + const TopoDS_Edge anEdge1 = + makeCircularArc(gp_Pnt(0.0, 0.0, 0.0), gp_Dir(1.0, 0.0, 0.0), 5.0, 0.5 * M_PI, M_PI); + const TopoDS_Edge anEdge2 = + makeCircularArc(gp_Pnt(0.0, 0.0, 0.0), gp_Dir(1.0, 0.0, 0.0), 5.0, -0.5 * M_PI, 0.0); + expectProximityValue(anEdge1, + anEdge2, + 10.0, + 1.e-3, + ProximityStatus::ProxPnt_Status_MIDDLE, + ProximityStatus::ProxPnt_Status_MIDDLE, + 1.e-3); +} + +// Migrated from tests/lowalgos/proximity/B1. Parallel square faces are closest +// at their boundary triangulation nodes. +TEST(BRepExtrema_ShapeProximityTest, LowAlgo_B1_ParallelPlanePatches) +{ + const TopoDS_Face aFace1 = + makePlanePatch(gp_Pnt(0.0, 0.0, 0.0), gp_Dir(0.0, 0.0, 1.0), -1.0, 1.0, -1.0, 1.0); + const TopoDS_Face aFace2 = + makePlanePatch(gp_Pnt(0.0, 0.0, 1.0), gp_Dir(0.0, 0.0, 1.0), -1.0, 1.0, -1.0, 1.0); + expectProximityValue(aFace1, + aFace2, + 1.0, + 1.e-3, + ProximityStatus::ProxPnt_Status_BORDER, + ProximityStatus::ProxPnt_Status_BORDER, + 0.1); +} + +// Migrated from tests/lowalgos/proximity/C1. A plane and a short coaxial +// cylinder exercise the mixed middle/border status classification. +TEST(BRepExtrema_ShapeProximityTest, LowAlgo_C1_PlaneAndCylinder) +{ + const TopoDS_Face aPlane = + makePlanePatch(gp_Pnt(0.0, 0.0, 0.0), gp_Dir(0.0, 0.0, 1.0), -1.0, 1.0, -1.0, 1.0); + const TopoDS_Face aCylinder = + makeCylinderPatch(gp_Pnt(0.0, 0.0, 0.0), gp_Dir(0.0, 1.0, 0.0), 0.1, 0.0, 2.0 * M_PI, 0.0, 1.0); + expectProximityValue(aPlane, + aCylinder, + 0.1, + 1.e-3, + ProximityStatus::ProxPnt_Status_MIDDLE, + ProximityStatus::ProxPnt_Status_BORDER, + 1.e-3); +} + +// Migrated from tests/lowalgos/proximity/D1. Two opposing half-spheres have a +// four-unit minimal enclosing-layer thickness. +TEST(BRepExtrema_ShapeProximityTest, LowAlgo_D1_OpposingSpherePatches) +{ + const TopoDS_Face aSphere1 = makeSpherePatch(gp_Pnt(0.0, 1.0, 0.0), 0.0, M_PI); + const TopoDS_Face aSphere2 = makeSpherePatch(gp_Pnt(0.0, -1.0, 0.0), -M_PI, 0.0); + expectProximityValue(aSphere1, + aSphere2, + 4.0, + 1.e-2, + ProximityStatus::ProxPnt_Status_MIDDLE, + ProximityStatus::ProxPnt_Status_MIDDLE, + 1.e-3); +} + +TEST(BRepExtrema_ShapeProximityTest, LowAlgo_A2_PerpendicularFullCircles) +{ + const TopoDS_Edge anEdge1 = + makeFullCircularEdge(gp_Pnt(0.0, 0.0, 0.0), gp_Dir(1.0, 0.0, 0.0), 1.0); + const TopoDS_Edge anEdge2 = + makeFullCircularEdge(gp_Pnt(0.0, 0.0, 0.0), gp_Dir(0.0, 1.0, 0.0), 1.0); + expectProximityValue(anEdge1, + anEdge2, + 2.0, + 1.e-3, + ProximityStatus::ProxPnt_Status_MIDDLE, + ProximityStatus::ProxPnt_Status_MIDDLE, + 1.e-3); +} + +TEST(BRepExtrema_ShapeProximityTest, LowAlgo_A3_OffsetSemicircles) +{ + const TopoDS_Edge anEdge1 = + makeTrimmedCircularArc(gp_Pnt(0.0, -1.0, 0.0), gp_Dir(1.0, 0.0, 0.0), 1.0, -M_PI, 0.0); + const TopoDS_Edge anEdge2 = + makeTrimmedCircularArc(gp_Pnt(0.0, 1.0, 0.0), gp_Dir(1.0, 0.0, 0.0), 1.0, 0.0, M_PI); + expectProximityValue(anEdge1, + anEdge2, + std::sqrt(5.0) - 1.0, + 1.e-3, + ProximityStatus::ProxPnt_Status_MIDDLE, + ProximityStatus::ProxPnt_Status_BORDER, + 1.e-3, + false); + // DRAW only assigned the two expected status names; it did not compare + // them. The current refinement path reports UNKNOWN for these edge points, + // so retain the validated distance and distinct-point checks above without + // turning unasserted DRAW metadata into a new failure. +} + +TEST(BRepExtrema_ShapeProximityTest, LowAlgo_A4_CoplanarCirclesWithDifferentAxes) +{ + const TopoDS_Edge anEdge1 = + makeFullCircularEdge(gp_Pnt(0.0, 0.0, 0.0), gp_Dir(1.0, 0.0, 0.0), 1.0); + const TopoDS_Edge anEdge2 = + makeFullCircularEdge(gp_Pnt(0.0, 0.0, 0.0), gp_Dir(-1.0, 0.5, 0.0), 1.0); + expectProximityValue(anEdge1, + anEdge2, + 2.0, + 1.e-3, + ProximityStatus::ProxPnt_Status_MIDDLE, + ProximityStatus::ProxPnt_Status_MIDDLE, + 1.e-3, + false); + // As in A3, the DRAW variables named expected statuses but never checked + // them; the numeric proximity and distinct-point invariants are meaningful. +} + +// Migrated from tests/lowalgos/proximity/A5. Use the same first-vertex +// distance that the DRAW script computes as an independent numeric reference. +TEST(BRepExtrema_ShapeProximityTest, LowAlgo_A5_TrimmedCircularEdges) +{ + const occ::handle aCircle1 = + new Geom_Circle(gp_Circ(gp_Ax2(gp_Pnt(0.0, 0.0, 0.0), gp_Dir(1.0, 0.0, 0.0)), 1.0)); + const occ::handle aTrimmedCircle1 = + new Geom_TrimmedCurve(aCircle1, -0.5 * M_PI, 0.5 * M_PI); + const TopoDS_Edge anEdge1 = BRepBuilderAPI_MakeEdge(aTrimmedCircle1).Edge(); + + const occ::handle aCircle2 = + new Geom_Circle(gp_Circ(gp_Ax2(gp_Pnt(0.0, 0.0, 0.0), gp_Dir(1.0, 0.5, 0.0)), 1.0)); + const occ::handle aTrimmedCircle2 = new Geom_TrimmedCurve(aCircle2, 0.0, M_PI); + const TopoDS_Edge anEdge2 = BRepBuilderAPI_MakeEdge(aTrimmedCircle2).Edge(); + + TopoDS_Vertex anEdge1First; + TopoDS_Vertex anEdge1Last; + TopoDS_Vertex anEdge2First; + TopoDS_Vertex anEdge2Last; + TopExp::Vertices(anEdge1, anEdge1First, anEdge1Last); + TopExp::Vertices(anEdge2, anEdge2First, anEdge2Last); + ASSERT_FALSE(anEdge1First.IsNull()); + ASSERT_FALSE(anEdge2First.IsNull()); + + BRepExtrema_DistShapeShape aReferenceDistance(anEdge1First, anEdge2First); + ASSERT_TRUE(aReferenceDistance.IsDone()); + ASSERT_GT(aReferenceDistance.Value(), 0.0); + + // The DRAW status variables are not compared in this case; retain the + // independent vertex-distance reference and the proximity point checks. + expectProximityValue(anEdge1, + anEdge2, + aReferenceDistance.Value(), + 2.e-3, + ProximityStatus::ProxPnt_Status_MIDDLE, + ProximityStatus::ProxPnt_Status_BORDER, + 1.e-3, + false); +} + +TEST(BRepExtrema_ShapeProximityTest, LowAlgo_B2_OrthogonalPlanePatches) +{ + const TopoDS_Face aFace1 = + makePlanePatch(gp_Pnt(0.0, 0.0, 0.0), gp_Dir(0.0, 0.0, 1.0), -1.0, 1.0, -1.0, 1.0); + const TopoDS_Face aFace2 = + makePlanePatch(gp_Pnt(0.0, 0.0, 1.0), gp_Dir(-1.0, 0.0, 0.0), -1.0, 1.0, -1.0, 1.0); + expectProximityValue(aFace1, + aFace2, + 1.0, + 1.e-3, + ProximityStatus::ProxPnt_Status_BORDER, + ProximityStatus::ProxPnt_Status_BORDER, + 0.1); +} + +TEST(BRepExtrema_ShapeProximityTest, LowAlgo_B3_IntersectingPlanePatches) +{ + const TopoDS_Face aFace1 = + makePlanePatch(gp_Pnt(0.0, 0.0, 0.0), gp_Dir(0.0, 0.0, 1.0), -1.0, 1.0, -1.0, 1.0); + const TopoDS_Face aFace2 = + makePlanePatch(gp_Pnt(0.0, 0.0, 0.0), gp_Dir(-1.0, 0.0, 0.0), -1.0, 1.0, -1.0, 1.0); + expectProximityValue(aFace1, + aFace2, + 1.0, + 1.e-3, + ProximityStatus::ProxPnt_Status_BORDER, + ProximityStatus::ProxPnt_Status_BORDER, + 0.1); +} + +TEST(BRepExtrema_ShapeProximityTest, LowAlgo_B4_OffsetIntersectingPlanePatches) +{ + const TopoDS_Face aFace1 = + makePlanePatch(gp_Pnt(0.0, 0.0, 0.0), gp_Dir(0.0, 0.0, 1.0), -1.0, 1.0, -1.0, 1.0); + const TopoDS_Face aFace2 = + makePlanePatch(gp_Pnt(0.0, 0.0, 0.5), gp_Dir(-1.0, 0.0, 0.0), -1.0, 1.0, -1.0, 1.0); + expectProximityValue(aFace1, + aFace2, + 1.0, + 1.e-3, + ProximityStatus::ProxPnt_Status_BORDER, + ProximityStatus::ProxPnt_Status_BORDER, + 0.1); +} + +TEST(BRepExtrema_ShapeProximityTest, LowAlgo_B5_SlopedPolygonPatch) +{ + const TopoDS_Face aFace1 = + makePlanePatch(gp_Pnt(0.0, 0.0, 0.0), gp_Dir(0.0, 0.0, 1.0), -1.0, 1.0, -1.0, 1.0); + const TopoDS_Face aFace2 = makePolygonFace(); + expectProximityValue(aFace1, + aFace2, + 0.8 * std::sqrt(5.0), + 1.e-3, + ProximityStatus::ProxPnt_Status_BORDER, + ProximityStatus::ProxPnt_Status_BORDER, + 1.e-3); +} + +TEST(BRepExtrema_ShapeProximityTest, LowAlgo_C2_ObliqueCylinderAndPlane) +{ + const TopoDS_Face aPlane = + makePlanePatch(gp_Pnt(0.0, 0.0, 0.0), gp_Dir(0.0, 0.0, 1.0), -2.0, 2.0, -2.0, 2.0); + const TopoDS_Face aCylinder = makeCylinderPatch(gp_Pnt(0.0, 0.0, 1.0), + gp_Dir(0.0, std::sqrt(0.5), std::sqrt(0.5)), + 0.1, + 0.0, + 2.0 * M_PI, + 0.0, + 1.0); + expectProximityValue(aPlane, + aCylinder, + 1.0 + 1.1 * std::sqrt(0.5), + 1.e-3, + ProximityStatus::ProxPnt_Status_MIDDLE, + ProximityStatus::ProxPnt_Status_BORDER, + 1.e-3); +} + +TEST(BRepExtrema_ShapeProximityTest, LowAlgo_C3_ParallelCylinderPatches) +{ + const TopoDS_Face aCylinder1 = + makeCylinderPatch(gp_Pnt(0.0, 0.0, 1.0), gp_Dir(1.0, 0.0, 0.0), 0.1, 0.0, 2.0 * M_PI, 0.0, 1.0); + const TopoDS_Face aCylinder2 = + makeCylinderPatch(gp_Pnt(0.0, 0.0, 0.0), gp_Dir(1.0, 0.0, 0.0), 0.1, 0.0, 2.0 * M_PI, 0.0, 1.0); + expectProximityValue(aCylinder1, + aCylinder2, + 1.0, + 1.e-3, + ProximityStatus::ProxPnt_Status_BORDER, + ProximityStatus::ProxPnt_Status_BORDER, + 1.e-3); +} + +TEST(BRepExtrema_ShapeProximityTest, LowAlgo_C4_TrimmedParallelCylinderPatches) +{ + const TopoDS_Face aCylinder1 = makeCylinderPatch(gp_Pnt(0.0, 0.0, 1.0), + gp_Dir(1.0, 0.0, 0.0), + 0.1, + -0.5 * M_PI, + 0.5 * M_PI, + 0.0, + 1.0); + const TopoDS_Face aCylinder2 = makeCylinderPatch(gp_Pnt(0.0, 0.0, 0.0), + gp_Dir(1.0, 0.0, 0.0), + 0.1, + 0.5 * M_PI, + -0.5 * M_PI, + 0.0, + 1.0); + expectProximityValue(aCylinder1, + aCylinder2, + 1.2, + 1.e-3, + ProximityStatus::ProxPnt_Status_BORDER, + ProximityStatus::ProxPnt_Status_BORDER, + 1.e-5); +} + +TEST(BRepExtrema_ShapeProximityTest, LowAlgo_D2_FullOpposingSpheres) +{ + const TopoDS_Face aSphere1 = makeSphereFace(gp_Pnt(0.0, 1.0, 0.0)); + const TopoDS_Face aSphere2 = makeSphereFace(gp_Pnt(0.0, -1.0, 0.0)); + expectProximityValue(aSphere1, + aSphere2, + 4.0, + 1.e-2, + ProximityStatus::ProxPnt_Status_MIDDLE, + ProximityStatus::ProxPnt_Status_MIDDLE, + 1.e-3); +} + +TEST(BRepExtrema_ShapeProximityTest, LowAlgo_D3_SplitSphereAndPlane) +{ + const TopoDS_Shape aSphere = makeSplitSphere(gp_Pnt(0.0, 1.0, 0.0)); + const TopoDS_Face aPlane = + makePlanePatch(gp_Pnt(0.0, 0.0, 0.0), gp_Dir(0.0, 1.0, 0.0), -2.0, 2.0, -2.0, 2.0); + expectProximityValue(aSphere, + aPlane, + 2.0, + 1.e-2, + ProximityStatus::ProxPnt_Status_BORDER, + ProximityStatus::ProxPnt_Status_MIDDLE, + 1.e-3); +} + +TEST(BRepExtrema_ShapeProximityTest, LowAlgo_D4_TrimmedSphereAndPlane) +{ + const TopoDS_Face aSphere = makeSpherePatch(gp_Pnt(0.0, 1.0, 0.0), 0.0, M_PI); + const TopoDS_Face aPlane = + makePlanePatch(gp_Pnt(0.0, 0.0, 0.0), gp_Dir(0.0, 1.0, 0.0), -1.0, 1.0, -1.0, 1.0); + expectProximityValue(aSphere, + aPlane, + 2.0, + 1.e-2, + ProximityStatus::ProxPnt_Status_MIDDLE, + ProximityStatus::ProxPnt_Status_MIDDLE, + 1.e-3); +} + +// Migrated from tests/lowalgos/proximity/E1. The DRAW case derives the +// expected proximity from the second endpoint of each Bezier edge. +TEST(BRepExtrema_ShapeProximityTest, LowAlgo_E1_BezierEdgesEndpointReference) +{ + NCollection_Array1 aPoles1(1, 7); + aPoles1(1) = gp_Pnt(10.0, 84.0, 0.0); + aPoles1(2) = gp_Pnt(54.0, 96.0, 0.0); + aPoles1(3) = gp_Pnt(145.0, 146.0, 0.0); + aPoles1(4) = gp_Pnt(167.0, 167.0, 0.0); + aPoles1(5) = gp_Pnt(185.0, 212.0, 0.0); + aPoles1(6) = gp_Pnt(187.0, 234.0, 0.0); + aPoles1(7) = gp_Pnt(176.0, 302.0, 0.0); + + NCollection_Array1 aPoles2(1, 8); + aPoles2(1) = gp_Pnt(120.0, 72.0, 0.0); + aPoles2(2) = gp_Pnt(170.0, 87.0, 0.0); + aPoles2(3) = gp_Pnt(227.0, 118.0, 0.0); + aPoles2(4) = gp_Pnt(238.0, 126.0, 0.0); + aPoles2(5) = gp_Pnt(243.0, 157.0, 0.0); + aPoles2(6) = gp_Pnt(203.0, 216.0, 0.0); + aPoles2(7) = gp_Pnt(134.0, 281.0, 0.0); + aPoles2(8) = gp_Pnt(94.0, 324.0, 0.0); + + const TopoDS_Edge anEdge1 = makeBezierEdge(aPoles1); + const TopoDS_Edge anEdge2 = makeBezierEdge(aPoles2); + const gp_Pnt aPnt1 = BRep_Tool::Pnt(TopExp::LastVertex(anEdge1, true)); + const gp_Pnt aPnt2 = BRep_Tool::Pnt(TopExp::LastVertex(anEdge2, true)); + expectProximityValue(anEdge1, + anEdge2, + aPnt1.Distance(aPnt2), + 1.e-3, + ProximityStatus::ProxPnt_Status_BORDER, + ProximityStatus::ProxPnt_Status_BORDER, + 1.e-3); +} + +// Migrated from tests/lowalgos/proximity/E2. This case checks a finite +// middle-point proximity for two different-degree Bezier curves. +TEST(BRepExtrema_ShapeProximityTest, LowAlgo_E2_DifferentDegreeBezierEdges) +{ + NCollection_Array1 aPoles1(1, 6); + aPoles1(1) = gp_Pnt(54.0, 96.0, 0.0); + aPoles1(2) = gp_Pnt(145.0, 146.0, 0.0); + aPoles1(3) = gp_Pnt(167.0, 167.0, 0.0); + aPoles1(4) = gp_Pnt(185.0, 212.0, 0.0); + aPoles1(5) = gp_Pnt(187.0, 234.0, 0.0); + aPoles1(6) = gp_Pnt(176.0, 302.0, 0.0); + + NCollection_Array1 aPoles2(1, 7); + aPoles2(1) = gp_Pnt(120.0, 72.0, 0.0); + aPoles2(2) = gp_Pnt(170.0, 87.0, 0.0); + aPoles2(3) = gp_Pnt(227.0, 118.0, 0.0); + aPoles2(4) = gp_Pnt(238.0, 126.0, 0.0); + aPoles2(5) = gp_Pnt(243.0, 157.0, 0.0); + aPoles2(6) = gp_Pnt(203.0, 216.0, 0.0); + aPoles2(7) = gp_Pnt(134.0, 281.0, 0.0); + + const TopoDS_Edge anEdge1 = makeBezierEdge(aPoles1); + const TopoDS_Edge anEdge2 = makeBezierEdge(aPoles2); + expectProximityValue(anEdge1, + anEdge2, + 76.34, + 1.e-3, + ProximityStatus::ProxPnt_Status_MIDDLE, + ProximityStatus::ProxPnt_Status_MIDDLE, + 1.e-3); +} diff --git a/src/ModelingAlgorithms/TKTopAlgo/GTests/FILES.cmake b/src/ModelingAlgorithms/TKTopAlgo/GTests/FILES.cmake index 09fd1dc39f..61f8e4c257 100644 --- a/src/ModelingAlgorithms/TKTopAlgo/GTests/FILES.cmake +++ b/src/ModelingAlgorithms/TKTopAlgo/GTests/FILES.cmake @@ -5,12 +5,15 @@ set(OCCT_TKTopAlgo_GTests_FILES BRepBuilderAPI_Copy_Test.cxx BRepBuilderAPI_MakeEdge_Test.cxx BRepBuilderAPI_MakeFace_Test.cxx + BRepBuilderAPI_MakeShell_Test.cxx BRepBuilderAPI_MakeWire_Test.cxx BRepBuilderAPI_Transform_Test.cxx BRepCheck_Face_Test.cxx BRepClass3d_SolidClassifier_Test.cxx BRepClass_FaceExplorer_Test.cxx BRepExtrema_DistShapeShape_Test.cxx + BRepExtrema_ShapeProximity_Test.cxx + BRepBndLib_Test.cxx BRepGProp_Test.cxx BRepLib_MakeWire_Test.cxx BRepOffsetAPI_ThruSections_Test.cxx diff --git a/src/ModelingData/TKBRep/GTests/BRepAdaptor_CompCurve_Test.cxx b/src/ModelingData/TKBRep/GTests/BRepAdaptor_CompCurve_Test.cxx index 2d6cc3a2d4..b773b4820a 100644 --- a/src/ModelingData/TKBRep/GTests/BRepAdaptor_CompCurve_Test.cxx +++ b/src/ModelingData/TKBRep/GTests/BRepAdaptor_CompCurve_Test.cxx @@ -15,8 +15,11 @@ #include #include +#include #include +#include #include +#include #include #include #include @@ -189,3 +192,61 @@ TEST(BRepAdaptor_CompCurve_Test, OCC30869_ReversedEdgeBoundaryPoints) EXPECT_NEAR(aVLast.Y(), aRefV2.Y(), aTol) << "Last tangent Y"; EXPECT_NEAR(aVLast.Z(), aRefV2.Z(), aTol) << "Last tangent Z"; } + +namespace +{ +TopoDS_Wire makeOCC30422Wire(const bool theReverseInsertionOrder) +{ + const TopoDS_Vertex aV1 = BRepBuilderAPI_MakeVertex(gp_Pnt(0.0, 0.0, 0.0)); + const TopoDS_Vertex aV2 = BRepBuilderAPI_MakeVertex(gp_Pnt(1.0, 0.0, 0.0)); + const TopoDS_Vertex aV3 = BRepBuilderAPI_MakeVertex(gp_Pnt(2.0, 0.0, 0.0)); + const TopoDS_Vertex aV4 = BRepBuilderAPI_MakeVertex(gp_Pnt(3.0, 0.0, 0.0)); + const TopoDS_Vertex aV5 = BRepBuilderAPI_MakeVertex(gp_Pnt(4.0, 0.0, 0.0)); + + const TopoDS_Edge anE1 = BRepBuilderAPI_MakeEdge(aV1, aV2); + const TopoDS_Edge anE2 = BRepBuilderAPI_MakeEdge(aV2, aV3); + const TopoDS_Edge anE3 = BRepBuilderAPI_MakeEdge(aV3, aV4); + const TopoDS_Edge anE4 = BRepBuilderAPI_MakeEdge(aV5, aV4); + + BRep_Builder aBuilder; + TopoDS_Wire aWire; + aBuilder.MakeWire(aWire); + if (theReverseInsertionOrder) + { + aBuilder.Add(aWire, anE1); + aBuilder.Add(aWire, anE4); + aBuilder.Add(aWire, anE3); + aBuilder.Add(aWire, anE2); + } + else + { + aBuilder.Add(aWire, anE1); + aBuilder.Add(aWire, anE2); + aBuilder.Add(aWire, anE3); + aBuilder.Add(aWire, anE4); + } + return aWire; +} + +void expectOCC30422WireExplorer(const TopoDS_Wire& theWire) +{ + BRepTools_WireExplorer anExplorer(theWire); + int aNbEdges = 0; + for (; anExplorer.More(); anExplorer.Next()) + { + EXPECT_FALSE(anExplorer.Current().IsNull()); + ++aNbEdges; + } + // DRAW validates the third WEDGE_* object; the fourth edge is deliberately + // not guaranteed to be reachable for this malformed insertion sequence. + EXPECT_GE(aNbEdges, 3); +} +} // namespace + +// Migrated from tests/bugs/moddata_3/bug30422. Wire exploration must remain +// deterministic for both the connected and reordered compound insertion paths. +TEST(BRepAdaptor_CompCurve_Test, OCC30422_WireExplorerReorderedEdges) +{ + expectOCC30422WireExplorer(makeOCC30422Wire(false)); + expectOCC30422WireExplorer(makeOCC30422Wire(true)); +} diff --git a/src/ModelingData/TKBRep/GTests/BRepTools_ReShape_Test.cxx b/src/ModelingData/TKBRep/GTests/BRepTools_ReShape_Test.cxx index 7466f97707..a8b6c33c2d 100644 --- a/src/ModelingData/TKBRep/GTests/BRepTools_ReShape_Test.cxx +++ b/src/ModelingData/TKBRep/GTests/BRepTools_ReShape_Test.cxx @@ -14,6 +14,7 @@ #include #include #include +#include #include #include #include @@ -21,6 +22,7 @@ #include #include #include +#include #include #include @@ -364,3 +366,41 @@ TEST(BRepTools_ReShapeTest, ValueLeaf_ConsidersLocationMode) EXPECT_TRUE(aReShape.ValueLeaf(aA).IsSame(aB)); } + +// Migrated from tests/bugs/moddata_3/bug29662. Replacing a compound up to the +// compound level must preserve the solids from the untouched branch and add +// the replacement branch as one solid. +TEST(BRepTools_ReShapeTest, ModDataBug_29662_ReplaceCompound) +{ + const TopoDS_Shape aBox1 = BRepPrimAPI_MakeBox(10.0, 10.0, 10.0).Shape(); + const TopoDS_Shape aBox2 = BRepPrimAPI_MakeBox(gp_Pnt(10.0, 0.0, 0.0), 10.0, 10.0, 10.0).Shape(); + const TopoDS_Shape aBox3 = BRepPrimAPI_MakeBox(gp_Pnt(0.0, 0.0, 10.0), 10.0, 10.0, 10.0).Shape(); + const TopoDS_Shape aBox4 = BRepPrimAPI_MakeBox(gp_Pnt(10.0, 0.0, 10.0), 10.0, 10.0, 10.0).Shape(); + const TopoDS_Shape aBox5 = BRepPrimAPI_MakeBox(gp_Pnt(20.0, 0.0, 0.0), 10.0, 10.0, 10.0).Shape(); + + BRep_Builder aBuilder; + TopoDS_Compound aC1, aC2, aC, aC3; + aBuilder.MakeCompound(aC1); + aBuilder.Add(aC1, aBox1); + aBuilder.Add(aC1, aBox2); + aBuilder.MakeCompound(aC2); + aBuilder.Add(aC2, aBox3); + aBuilder.Add(aC2, aBox4); + aBuilder.MakeCompound(aC); + aBuilder.Add(aC, aC1); + aBuilder.Add(aC, aC2); + aBuilder.MakeCompound(aC3); + aBuilder.Add(aC3, aBox5); + + BRepTools_ReShape aReShape; + aReShape.Replace(aC2, aC3); + const TopoDS_Shape aResult = aReShape.Apply(aC, TopAbs_COMPOUND); + ASSERT_FALSE(aResult.IsNull()); + + int aNbSolids = 0; + for (TopExp_Explorer anExplorer(aResult, TopAbs_SOLID); anExplorer.More(); anExplorer.Next()) + { + ++aNbSolids; + } + EXPECT_EQ(aNbSolids, 3); +} diff --git a/src/ModelingData/TKBRep/GTests/BRepTools_Test.cxx b/src/ModelingData/TKBRep/GTests/BRepTools_Test.cxx index 09ed351fcc..2bb2249582 100644 --- a/src/ModelingData/TKBRep/GTests/BRepTools_Test.cxx +++ b/src/ModelingData/TKBRep/GTests/BRepTools_Test.cxx @@ -12,16 +12,55 @@ // commercial license or contractual agreement. #include +#include +#include +#include +#include +#include +#include +#include #include +#include #include #include +#include +#include +#include +#include +#include +#include #include +#include #include +#include +#include #include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include +#include #include #include #include @@ -51,6 +90,468 @@ bool ReadFromBuffer(const std::string& theData, TopoDS_Shape& theShape) return !theShape.IsNull(); } +const char* Bug30269BrepData() +{ + return R"OCCT(DBRep_DrawableShape + +CASCADE Topology V1, (c) Matra-Datavision +Locations 0 +Curve2ds 0 +Curves 2 +1 8111.3 2939 9014.2 0.23 5.2e-07 0.97 +1 9996.2 2940 8568.4 -0.229 3.64e-07 -0.97 +Polygon3D 0 +PolygonOnTriangulations 0 +Surfaces 2 +1 9056.7 2940 8807.3 1.29e-07 -1 5e-07 -1.26e-29 -5.03e-07 -1 1 1.288e-07 -6.48e-14 +1 10000 1519 8584.45 -0.97 -8.47e-08 0.23 0.23 0 0.97 -8.24e-08 1 1.95e-08 +Triangulations 0 + +TShapes 10 +Ve +1e-07 +8111.30 2940 9014.2 +0 0 + +0101101 +* +Ve +1e-07 +9996.21 2940 8568.4 +0 0 + +0101101 +* +Ed + 2.22e-16 0 0 0 +0 + +0101000 ++10 0 -9 0 * +Ve +1e-07 +8115 2940 9030 +0 0 + +0101101 +* +Ed + 1e-07 0 0 0 +1 1 0 0 16.5 +0 + +0101000 ++10 0 -7 0 * +Ve +1e-07 +10000 2940 8584.5 +0 0 + +0101101 +* +Ed + 2.22e-16 0 0 0 +0 + +0101000 ++7 0 -5 0 * +Ed + 1e-07 0 0 0 +1 2 0 -16.5 0 +4 C0 1 0 2 0 +0 + +0101000 ++5 0 -9 0 * +Wi + +0101000 +-8 0 +6 0 +4 0 +3 0 * +Fa +0 1e-07 1 0 + +0101000 +-2 0 * + +-1 4 +)OCCT"; +} + +const char* Bug29939BrepData() +{ + return R"OCCT(DBRep_DrawableShape + +CASCADE Topology V1, (c) Matra-Datavision +Locations 6 +1 +-6.93889390391e-18 1 0 -266.829932547 + -1 -6.93889390391e-18 0 0 + 0 0 1 8.881784197e-16 +1 + 1 -1.23204712323214e-17 3.48118418796994e-18 -357.513195371 +1.23204706275e-17 0.999999999999985 1.73740064720997e-07 5.87091965856e-15 +-3.48118632852936e-18 -1.73740064720997e-07 0.999999999999985 1.00245277978e-14 +1 + 1 -3.49249707682408e-17 -1.73723591341045e-16 613.47435459 +3.30382668395332e-18 0.983888906493258 -0.178780926498047 -24.4029550353 +1.77168632948486e-16 0.178780926498047 0.983888906493258 17.0096765133 +1 +-0.891601662261103 -0.296724731883325 0.34205395676999 289.371401338 +0.321472550183128 -0.946772534430101 0.0166483490940992 -855.09721987 +0.318907314641721 0.12480465350928 0.939532821741973 -233.868191989 +2 1 1 2 1 3 1 4 1 0 +2 4 -1 3 -1 2 -1 1 -1 0 +Curve2ds 8 +1 3.1415926535885261 -3.1415926537565504 -9.6123430370698398e-15 1 +1 2.6415926535897927 3.1415926535897829 1 3.227912221389625e-15 +1 -3.641592653589794 3.1415926535899144 1 -2.1627771834064215e-14 +1 -3.641592653589794 3.1415926535897447 1 8.2694421717546571e-15 +1 -3.641592653589794 3.1415926535897984 1 -2.5444437451706449e-15 +1 -3.6415926535891083 3.1415926535895933 1 4.5496352846831891e-14 +1 0 -3.1415926537565433 0 1 +1 -3.6415926535884808 1.5707963267948022 1 1.8093822187836176e-14 +Curves 9 +2 84.858320332900007 -63 155.33211345500001 -0.87758256189037243 0 0.4794255386042035 -0.4794255386042035 0 -0.87758256189037243 -0 -1 0 2 +2 -5.6843418860799994e-14 -63 4.2632564145599997e-14 -0 1 0 0 0 1 1 0 -0 175 +7 0 0 4 5 2 9.51279659315 -64.469009257300002 174.74125643599999 10.8275887261 -63.750060296000001 174.66968003599999 12.261430838000001 -63.2501700292 174.57846249100001 13.7577343107 -62.999999975000001 174.464825784 15.252255180300001 -63 174.33407214900001 + 0 5 8.4865807349600004 5 +2 -5.6843418860799994e-14 -63 4.2632564145599997e-14 -0 1 0 0 0 1 1 0 -0 175 +2 -5.6843418860799994e-14 -63 4.2632564145599997e-14 -0 1 0 0 0 1 1 0 -0 175 +2 -5.6843418860799994e-14 -63 4.2632564145599997e-14 -0 1 0 0 0 1 1 0 -0 175 +2 -5.6843418860799994e-14 -63 4.2632564145599997e-14 -0 1 0 0 0 1 1 0 -0 175 +2 -84.858320332900007 -63 -155.33211345500001 0.87758256189037243 -0 -0.4794255386042035 0.4794255386042035 0 0.87758256189037243 0 -1 0 2 +2 -4.2632564145599997e-14 -61 -2.8421709430399997e-14 0 1 0 0 -0 1 1 0 -0 177 +Polygon3D 0 +PolygonOnTriangulations 0 +Surfaces 1 +5 -5.6843418860799994e-14 -63 4.2632564145599997e-14 -0 1 0 -0.4794255386042035 0 -0.87758256189037243 -0.87758256189037243 -0 0.4794255386042035 177 2 +Triangulations 0 + +TShapes 20 +Ve +1.00005e-07 +446.609600903292 -747.182655462685 -128.403390746598 +0 0 + +0101101 +* +Ve +1e-07 +447.487711636221 -749.041771994926 -130.345710818059 +0 0 + +0101101 +* +Ed + 1e-07 1 1 0 +1 1 0 4.71238898051187 6.28318530717959 +2 1 1 0 4.71238898051187 6.28318530717959 +0 + +0101000 ++20 6 -19 6 * +Ve +0.000801323308506101 +439.731321696259 -808.930183254921 -91.6608968795304 +0 0 + +0101101 +* +Ed + 1e-07 1 1 0 +1 2 0 0.0872664625995157 0.499999999999316 +2 2 1 0 0.0872664625995157 0.499999999999316 +0 + +0101000 ++17 6 -19 6 * +Ve +9.50082811303135e-06 +439.731308365217 -808.930245083447 -91.6608718249203 +0 0 + +0101101 +* +Ed + 1e-07 1 1 0 +1 3 0 8.48648424147889 8.48658045180264 +0 + +0101000 ++15 6 -17 6 * +Ve +0.000801323588114315 +400.97481659698 -922.047565623353 -85.9891266596981 +0 0 + +0101101 +* +Ed + 1e-07 1 1 0 +1 4 0 5.672320068985 6.37045138103039 +2 3 1 0 5.672320068985 6.37045138103039 +0 + +0101000 ++13 6 -15 6 * +Ve +0.000801323173512029 +346.92570979233 -1004.00637567207 -154.481647187039 +0 0 + +0101101 +* +Ed + 1e-07 1 1 0 +1 5 0 4.974188368183 5.672320068985 +2 4 1 0 4.974188368183 5.672320068985 +0 + +0101000 ++11 6 -13 6 * +Ve +0.000801323604481778 +302.874179046209 -1016.45717530592 -265.090046896853 +0 0 + +0101101 +* +Ed + 1e-07 1 1 0 +1 6 0 4.27605666738522 4.974188368183 +2 5 1 0 4.27605666738522 4.974188368183 +0 + +0101000 ++9 6 -11 6 * +Ve +1e-07 +289.096508106169 -961.871772388525 -358.63416338841 +0 0 + +0101101 +* +Ed + 1e-07 1 1 0 +1 7 0 3.64159265358911 4.27605666738522 +2 6 1 0 3.64159265358911 4.27605666738522 +0 + +0101000 ++7 6 -9 6 * +Ve +1.00005e-07 +286.408212189964 -962.444998719012 -359.300854202584 +0 0 + +0101101 +* +Ed + 1e-07 1 1 0 +1 8 0 4.71238898038469 6.28318530717959 +2 7 1 0 4.71238898038469 6.28318530717959 +0 + +0101000 ++5 6 -7 6 * +Ed + 1.00005e-07 1 1 0 +1 9 0 3.64159265358848 6.78318530718743 +2 8 1 0 3.64159265358848 6.78318530718743 +0 + +0101000 ++5 6 -20 6 * +Wi + +0101100 ++18 0 -16 0 -14 0 -12 0 -10 0 -8 0 -6 0 -4 0 +3 0 * +Fa +0 1e-07 1 0 + +1101000 ++2 0 * + +-1 5 +0 +)OCCT"; +} + +TopoDS_Shape RoundTripShape(const TopoDS_Shape& theShape, + const bool theBinary, + const bool theWithTriangles, + const int theVersion) +{ + std::stringstream aStream; + if (theBinary) + { + BinTools::Write(theShape, + aStream, + theWithTriangles, + false, + static_cast(theVersion)); + } + else + { + BRepTools::Write(theShape, + aStream, + theWithTriangles, + false, + static_cast(theVersion)); + } + EXPECT_TRUE(aStream.good()); + EXPECT_FALSE(aStream.str().empty()); + + aStream.seekg(0); + TopoDS_Shape aRestoredShape; + if (theBinary) + { + BinTools::Read(aRestoredShape, aStream); + } + else + { + BRepTools::Read(aRestoredShape, aStream, BRep_Builder()); + } + EXPECT_FALSE(aRestoredShape.IsNull()); + return aRestoredShape; +} + +int NbTriangles(const TopoDS_Shape& theShape) +{ + int aNbTriangles = 0; + for (TopExp_Explorer anExplorer(theShape, TopAbs_FACE); anExplorer.More(); anExplorer.Next()) + { + TopLoc_Location aLocation; + const occ::handle aTriangulation = + BRep_Tool::Triangulation(TopoDS::Face(anExplorer.Current()), aLocation); + if (!aTriangulation.IsNull()) + { + aNbTriangles += aTriangulation->NbTriangles(); + } + } + return aNbTriangles; +} + +int NbSubShapes(const TopoDS_Shape& theShape, const TopAbs_ShapeEnum theType) +{ + int aNbShapes = 0; + for (TopExp_Explorer anExplorer(theShape, theType); anExplorer.More(); anExplorer.Next()) + { + ++aNbShapes; + } + return aNbShapes; +} + +void ExpectEquivalentShape(const TopoDS_Shape& theExpected, + const TopoDS_Shape& theActual, + const int theExpectedTriangles) +{ + ASSERT_FALSE(theExpected.IsNull()); + ASSERT_FALSE(theActual.IsNull()); + EXPECT_EQ(theActual.ShapeType(), theExpected.ShapeType()); + EXPECT_EQ(NbSubShapes(theActual, TopAbs_SOLID), NbSubShapes(theExpected, TopAbs_SOLID)); + EXPECT_EQ(NbSubShapes(theActual, TopAbs_SHELL), NbSubShapes(theExpected, TopAbs_SHELL)); + EXPECT_EQ(NbSubShapes(theActual, TopAbs_FACE), NbSubShapes(theExpected, TopAbs_FACE)); + EXPECT_EQ(NbSubShapes(theActual, TopAbs_EDGE), NbSubShapes(theExpected, TopAbs_EDGE)); + EXPECT_EQ(NbSubShapes(theActual, TopAbs_VERTEX), NbSubShapes(theExpected, TopAbs_VERTEX)); + EXPECT_EQ(NbTriangles(theActual), theExpectedTriangles); + + GProp_GProps anExpectedVolume; + GProp_GProps anActualVolume; + BRepGProp::VolumeProperties(theExpected, anExpectedVolume); + BRepGProp::VolumeProperties(theActual, anActualVolume); + EXPECT_NEAR(anActualVolume.Mass(), anExpectedVolume.Mass(), 1.0e-7); + + GProp_GProps anExpectedSurface; + GProp_GProps anActualSurface; + BRepGProp::SurfaceProperties(theExpected, anExpectedSurface); + BRepGProp::SurfaceProperties(theActual, anActualSurface); + EXPECT_NEAR(anActualSurface.Mass(), anExpectedSurface.Mass(), 1.0e-7); +} + +TopoDS_Shape MakeEmptyShape(const TopAbs_ShapeEnum theType) +{ + BRep_Builder aBuilder; + switch (theType) + { + case TopAbs_VERTEX: { + TopoDS_Vertex aShape; + aBuilder.MakeVertex(aShape); + return aShape; + } + case TopAbs_EDGE: { + TopoDS_Edge aShape; + aBuilder.MakeEdge(aShape); + return aShape; + } + case TopAbs_WIRE: { + TopoDS_Wire aShape; + aBuilder.MakeWire(aShape); + return aShape; + } + case TopAbs_FACE: { + TopoDS_Face aShape; + aBuilder.MakeFace(aShape); + return aShape; + } + case TopAbs_SHELL: { + TopoDS_Shell aShape; + aBuilder.MakeShell(aShape); + return aShape; + } + case TopAbs_SOLID: { + TopoDS_Solid aShape; + aBuilder.MakeSolid(aShape); + return aShape; + } + case TopAbs_COMPSOLID: { + TopoDS_CompSolid aShape; + aBuilder.MakeCompSolid(aShape); + return aShape; + } + case TopAbs_COMPOUND: { + TopoDS_Compound aShape; + aBuilder.MakeCompound(aShape); + return aShape; + } + default: + return TopoDS_Shape(); + } +} + +TopoDS_Face UniqueFace(const TopoDS_Shape& theShape, const int theIndex) +{ + NCollection_IndexedMap aFaces; + TopExp::MapShapes(theShape, TopAbs_FACE, aFaces); + return theIndex > 0 && theIndex <= aFaces.Extent() ? TopoDS::Face(aFaces(theIndex)) + : TopoDS_Face(); +} + +TopoDS_Face MakeCircleFace(const gp_Pnt& theCenter, const gp_Dir& theNormal, const double theRadius) +{ + const occ::handle aCircle = new Geom_Circle(gp_Ax2(theCenter, theNormal), theRadius); + const TopoDS_Edge aEdge = BRepBuilderAPI_MakeEdge(aCircle).Edge(); + const TopoDS_Wire anWire = BRepBuilderAPI_MakeWire(aEdge).Wire(); + return BRepBuilderAPI_MakeFace(anWire).Face(); +} + +TopoDS_Face CutAndSelectFirstFace(const TopoDS_Face& theFace, const TopoDS_Face& theTool) +{ + BRepAlgoAPI_Cut aCut(theFace, theTool); + aCut.Build(); + return aCut.IsDone() ? UniqueFace(aCut.Shape(), 1) : TopoDS_Face(); +} + +void ExpectBoxUvBounds(const TopoDS_Face& theFace) +{ + double aUMin = 0.0, aUMax = 0.0, aVMin = 0.0, aVMax = 0.0; + BRepTools::UVBounds(theFace, aUMin, aUMax, aVMin, aVMax); + EXPECT_NEAR(aUMin, 0.0, 1.e-10); + EXPECT_NEAR(aUMax, 1500.0, 1.e-10); + EXPECT_NEAR(aVMin, 0.0, 1.e-10); + EXPECT_NEAR(aVMax, 1500.0, 1.e-10); +} + } // namespace // Parallel BRep reading must produce shapes with identical volume properties. @@ -140,3 +641,447 @@ TEST(BRepTools_Test, ParallelRead_RepeatedRuns) } } } + +// bugs/moddata_3/bug29723: all supported BRep format versions preserve NURBS geometry. +TEST(BRepTools_Test, ModDataBug_29723_FormatVersions) +{ + const TopoDS_Shape aBox = BRepPrimAPI_MakeBox(10.0, 20.0, 30.0).Shape(); + BRepBuilderAPI_NurbsConvert aConverter(aBox); + const TopoDS_Shape aNurbsBox = aConverter.Shape(); + ASSERT_FALSE(aNurbsBox.IsNull()); + + const TopoDS_Shape anAsciiVersion1 = + RoundTripShape(aNurbsBox, false, true, TopTools_FormatVersion_VERSION_1); + const TopoDS_Shape anAsciiVersion2 = + RoundTripShape(aNurbsBox, false, true, TopTools_FormatVersion_VERSION_2); + const TopoDS_Shape aBinaryVersion1 = + RoundTripShape(aNurbsBox, true, true, BinTools_FormatVersion_VERSION_1); + const TopoDS_Shape aBinaryVersion2 = + RoundTripShape(aNurbsBox, true, true, BinTools_FormatVersion_VERSION_2); + const TopoDS_Shape aBinaryVersion3 = + RoundTripShape(aNurbsBox, true, true, BinTools_FormatVersion_VERSION_3); + + ExpectEquivalentShape(aNurbsBox, anAsciiVersion1, 0); + ExpectEquivalentShape(aNurbsBox, anAsciiVersion2, 0); + ExpectEquivalentShape(aNurbsBox, aBinaryVersion1, 0); + ExpectEquivalentShape(aNurbsBox, aBinaryVersion2, 0); + ExpectEquivalentShape(aNurbsBox, aBinaryVersion3, 0); +} + +// bugs/moddata_3/bug31946: BRep ASCII/binary writers honor triangle options. +TEST(BRepTools_Test, ModDataBug_31946_TriangleOptions) +{ + const TopoDS_Shape aBox = BRepPrimAPI_MakeBox(10.0, 20.0, 30.0).Shape(); + BRepMesh_IncrementalMesh aMesher(aBox, 0.1); + ASSERT_EQ(NbTriangles(aBox), 12); + + const TopoDS_Shape anAsciiWithTriangles = + RoundTripShape(aBox, false, true, TopTools_FormatVersion_CURRENT); + const TopoDS_Shape anAsciiWithoutTriangles = + RoundTripShape(aBox, false, false, TopTools_FormatVersion_CURRENT); + const TopoDS_Shape aBinaryWithTriangles = + RoundTripShape(aBox, true, true, BinTools_FormatVersion_CURRENT); + const TopoDS_Shape aBinaryWithoutTriangles = + RoundTripShape(aBox, true, false, BinTools_FormatVersion_CURRENT); + + ExpectEquivalentShape(aBox, anAsciiWithTriangles, 12); + ExpectEquivalentShape(aBox, anAsciiWithoutTriangles, 0); + ExpectEquivalentShape(aBox, aBinaryWithTriangles, 12); + ExpectEquivalentShape(aBox, aBinaryWithoutTriangles, 0); +} + +// bugs/demo/bug25344_4: a BRep shape remains valid after stream save/restore. +TEST(BRepTools_Test, DemoBug_25344_4_SaveRestoreShapeType) +{ + const TopoDS_Shape aSource = BRepPrimAPI_MakeBox(1.0, 1.0, 1.0).Shape(); + const TopoDS_Shape aRestored = + RoundTripShape(aSource, false, true, TopTools_FormatVersion_VERSION_2); + ASSERT_FALSE(aRestored.IsNull()); + EXPECT_EQ(aRestored.ShapeType(), aSource.ShapeType()); + EXPECT_EQ(NbSubShapes(aRestored, TopAbs_SOLID), 1); + EXPECT_EQ(NbSubShapes(aRestored, TopAbs_FACE), 6); +} + +// demo/draw/binpersist_1: a generated box survives binary BRep stream storage with its +// bounding box, topology, validity, and global properties intact. +TEST(BRepTools_Test, DemoBinPersist_1_BinaryStreamRoundTrip) +{ + const TopoDS_Shape aSource = + BRepPrimAPI_MakeBox(gp_Pnt(10.0, 20.0, 30.0), 100.0, 200.0, 300.0).Shape(); + ASSERT_FALSE(aSource.IsNull()); + + std::stringstream aStream; + BinTools::Write(aSource, aStream, true, false, BinTools_FormatVersion_CURRENT); + ASSERT_TRUE(aStream.good()); + ASSERT_FALSE(aStream.str().empty()); + + aStream.seekg(0); + TopoDS_Shape aRestored; + BinTools::Read(aRestored, aStream); + ASSERT_FALSE(aRestored.IsNull()); + + Bnd_Box aSourceBounds; + Bnd_Box aRestoredBounds; + BRepBndLib::Add(aSource, aSourceBounds); + BRepBndLib::Add(aRestored, aRestoredBounds); + const Bnd_Box::Limits anExpected = aSourceBounds.Get(); + const Bnd_Box::Limits anActual = aRestoredBounds.Get(); + EXPECT_NEAR(anActual.Xmin, anExpected.Xmin, 1.0e-9); + EXPECT_NEAR(anActual.Ymin, anExpected.Ymin, 1.0e-9); + EXPECT_NEAR(anActual.Zmin, anExpected.Zmin, 1.0e-9); + EXPECT_NEAR(anActual.Xmax, anExpected.Xmax, 1.0e-9); + EXPECT_NEAR(anActual.Ymax, anExpected.Ymax, 1.0e-9); + EXPECT_NEAR(anActual.Zmax, anExpected.Zmax, 1.0e-9); + + EXPECT_TRUE(BRepCheck_Analyzer(aRestored).IsValid()); + EXPECT_EQ(NbSubShapes(aRestored, TopAbs_SOLID), NbSubShapes(aSource, TopAbs_SOLID)); + EXPECT_EQ(NbSubShapes(aRestored, TopAbs_SHELL), NbSubShapes(aSource, TopAbs_SHELL)); + EXPECT_EQ(NbSubShapes(aRestored, TopAbs_FACE), NbSubShapes(aSource, TopAbs_FACE)); + EXPECT_EQ(NbSubShapes(aRestored, TopAbs_EDGE), NbSubShapes(aSource, TopAbs_EDGE)); + EXPECT_EQ(NbSubShapes(aRestored, TopAbs_VERTEX), NbSubShapes(aSource, TopAbs_VERTEX)); + + GProp_GProps aSourceLinear; + GProp_GProps aRestoredLinear; + BRepGProp::LinearProperties(aSource, aSourceLinear); + BRepGProp::LinearProperties(aRestored, aRestoredLinear); + EXPECT_NEAR(aRestoredLinear.Mass(), aSourceLinear.Mass(), 1.0e-7); + EXPECT_DOUBLE_EQ(aSourceLinear.Mass(), 4800.0); + + GProp_GProps aSourceSurface; + GProp_GProps aRestoredSurface; + BRepGProp::SurfaceProperties(aSource, aSourceSurface); + BRepGProp::SurfaceProperties(aRestored, aRestoredSurface); + EXPECT_NEAR(aRestoredSurface.Mass(), aSourceSurface.Mass(), 1.0e-7); + EXPECT_DOUBLE_EQ(aSourceSurface.Mass(), 220000.0); + + GProp_GProps aSourceVolume; + GProp_GProps aRestoredVolume; + BRepGProp::VolumeProperties(aSource, aSourceVolume); + BRepGProp::VolumeProperties(aRestored, aRestoredVolume); + EXPECT_NEAR(aRestoredVolume.Mass(), aSourceVolume.Mass(), 1.0e-7); + EXPECT_DOUBLE_EQ(aSourceVolume.Mass(), 6000000.0); +} + +// bugs/moddata_1/bug20616: every empty BRep topology type survives DRAW-style storage. +TEST(BRepTools_Test, ModDataBug_20616_EmptyShapeSaveRestore) +{ + NCollection_Array1 aTypes(1, 8); + aTypes(1) = TopAbs_VERTEX; + aTypes(2) = TopAbs_EDGE; + aTypes(3) = TopAbs_WIRE; + aTypes(4) = TopAbs_FACE; + aTypes(5) = TopAbs_SHELL; + aTypes(6) = TopAbs_SOLID; + aTypes(7) = TopAbs_COMPSOLID; + aTypes(8) = TopAbs_COMPOUND; + + for (NCollection_Array1::Iterator anIterator(aTypes); anIterator.More(); + anIterator.Next()) + { + const TopoDS_Shape aSource = MakeEmptyShape(anIterator.Value()); + ASSERT_FALSE(aSource.IsNull()); + + std::stringstream aStream; + BRepTools::Write(aSource, aStream); + ASSERT_TRUE(aStream.good()); + ASSERT_FALSE(aStream.str().empty()); + + aStream.seekg(0); + TopoDS_Shape aRestored; + BRep_Builder aBuilder; + BRepTools::Read(aRestored, aStream, aBuilder); + ASSERT_FALSE(aRestored.IsNull()); + EXPECT_EQ(aRestored.ShapeType(), anIterator.Value()); + } +} + +// bugs/modalg_7/optimal_bndbox_exception: an embedded BRep shape is safe for AddOptimal. +TEST(BRepTools_Test, ModalgBug_32236_OptimalBoundingBox) +{ + const char* aShapeData = R"BREP(CASCADE Topology V1, (c) Matra-Datavision +Locations 0 +Curve2ds 4 +1 -1.3333333333333335 0 0 1 +1 0 -1.6666666666666667 1 0 +1 1.6666666666666665 0 0 1 +1 0 1.3333333333333333 1 0 +Curves 0 +Polygon3D 0 +PolygonOnTriangulations 0 +Surfaces 1 +9 0 0 0 0 3 3 4 4 2 2 0 3 1.9999999999999998 0 1.6666666666666665 1.9999999999999998 0 0.3333333333333332 1.9999999999999996 0 -0.99999999999999989 2 +0 2.9999999999999991 0.66666666666666718 0 1.6666666666666659 0.66666666666666741 0 0.3333333333333332 0.66666666666666663 0 -0.99999999999999956 0.66666666666666663 +0 3.0000000000000009 -0.66666666666666718 0 1.6666666666666676 -0.66666666666666752 0 0.33333333333333331 -0.66666666666666652 0 -1.0000000000000002 -0.66666666666666685 +0 3.0000000000000004 -2 0 1.6666666666666667 -2 0 0.33333333333333326 -1.9999999999999996 0 -1 -2 + +-1.3333333333333335 4 +2.6666666666666665 4 + +-2.666666666666667 4 +1.3333333333333333 4 + +Triangulations 0 + +TShapes 8 +Ve +4.000004 +0 -1 -1 +0 0 + +0101101 +* +Ed + 4.000004 1 1 1 +2 1 1 0 -1.66666666666667 1.33333333333333 +0 + +0101000 ++8 0 -8 0 * +Ed + 4.000004 1 1 1 +2 2 1 0 -1.33333333333333 1.66666666666667 +0 + +0101000 ++8 0 -8 0 * +Ed + 4.000004 1 1 1 +2 3 1 0 -1.66666666666667 1.33333333333333 +0 + +0101000 ++8 0 -8 0 * +Ed + 4.000004 1 1 1 +2 4 1 0 -1.33333333333333 1.66666666666667 +0 + +0101000 ++8 0 -8 0 * +Wi + +0101100 +-7 0 +6 0 +5 0 -4 0 * +Fa +0 1e-07 1 0 + +0101000 ++3 0 * +Sh + +1101000 ++2 0 * + ++1 0 +)BREP"; + + std::istringstream aStream(aShapeData); + BRep_Builder aBuilder; + TopoDS_Shape aShape; + BRepTools::Read(aShape, aStream, aBuilder); + ASSERT_FALSE(aShape.IsNull()); + + Bnd_Box aBox; + EXPECT_NO_THROW(BRepBndLib::AddOptimal(aShape, aBox, true, false)); + EXPECT_FALSE(aBox.IsVoid()); +} + +// bugs/modalg_7/bug30269: a BRep face with missing 2D curves must not crash +// the ordinary, optimal, or oriented bounding-box calculations. +TEST(BRepTools_Test, ModalgBug_30269_MissingCurve2dBounding) +{ + TopoDS_Shape aShape; + ASSERT_TRUE(ReadFromBuffer(Bug30269BrepData(), aShape)); + + Bnd_Box aRegularBox; + Bnd_Box anOptimalBox; + Bnd_OBB anOrientedBox; + EXPECT_NO_THROW(BRepBndLib::Add(aShape, aRegularBox)); + EXPECT_NO_THROW(BRepBndLib::AddOptimal(aShape, anOptimalBox)); + EXPECT_NO_THROW(BRepBndLib::AddOBB(aShape, anOrientedBox)); + EXPECT_FALSE(aRegularBox.IsVoid()); + EXPECT_FALSE(anOptimalBox.IsVoid()); + EXPECT_FALSE(anOrientedBox.IsVoid()); +} + +// bugs/modalg_7/bug29939: global properties must tolerate the same missing +// Curve2d records without raising Standard_NullObject. +TEST(BRepTools_Test, ModalgBug_29939_MissingCurve2dProperties) +{ + TopoDS_Shape aShape; + ASSERT_TRUE(ReadFromBuffer(Bug29939BrepData(), aShape)); + + GProp_GProps aSurfaceProperties; + GProp_GProps aVolumeProperties; + EXPECT_NO_THROW(BRepGProp::SurfaceProperties(aShape, aSurfaceProperties)); + EXPECT_NO_THROW(BRepGProp::VolumeProperties(aShape, aVolumeProperties)); + EXPECT_TRUE(std::isfinite(aSurfaceProperties.Mass())); + EXPECT_TRUE(std::isfinite(aVolumeProperties.Mass())); +} + +namespace +{ +static void ExpectSamePrincipalProperties(const GProp_GProps& theExact, + const GProp_GProps& theTriangulated) +{ + EXPECT_NEAR(theExact.Mass(), theTriangulated.Mass(), 1.0e-7); + + GProp_PrincipalProps anExactPrincipal = theExact.PrincipalProperties(); + GProp_PrincipalProps aTriangulatedPrincipal = theTriangulated.PrincipalProperties(); + double anExactIx = 0.0; + double anExactIy = 0.0; + double anExactIz = 0.0; + double aTriangulatedIx = 0.0; + double aTriangulatedIy = 0.0; + double aTriangulatedIz = 0.0; + anExactPrincipal.Moments(anExactIx, anExactIy, anExactIz); + aTriangulatedPrincipal.Moments(aTriangulatedIx, aTriangulatedIy, aTriangulatedIz); + EXPECT_NEAR(anExactIx, aTriangulatedIx, 1.0e-7); + EXPECT_NEAR(anExactIy, aTriangulatedIy, 1.0e-7); + EXPECT_NEAR(anExactIz, aTriangulatedIz, 1.0e-7); +} + +static void CompareExactAndTriangulatedProperties(const TopoDS_Shape& theShape, + const int thePropertyType) +{ + GProp_GProps anExactProperties; + GProp_GProps aTriangulatedProperties; + switch (thePropertyType) + { + case 0: + BRepGProp::LinearProperties(theShape, anExactProperties, false, false); + BRepGProp::LinearProperties(theShape, aTriangulatedProperties, false, true); + break; + case 1: + BRepGProp::SurfaceProperties(theShape, anExactProperties, false, false); + BRepGProp::SurfaceProperties(theShape, aTriangulatedProperties, false, true); + break; + default: + BRepGProp::VolumeProperties(theShape, anExactProperties, false, false, false); + BRepGProp::VolumeProperties(theShape, aTriangulatedProperties, false, false, true); + break; + } + ExpectSamePrincipalProperties(anExactProperties, aTriangulatedProperties); +} +} // namespace + +// bugs/modalg_7/bug29734: global properties computed from planar face +// triangulations must agree with the exact-geometry calculations. +TEST(BRepTools_Test, ModalgBug_29734_ExactAndTriangulatedProperties) +{ + const TopoDS_Shape aFirstBox = BRepPrimAPI_MakeBox(1.0, 2.0, 3.0).Shape(); + const TopoDS_Shape aSecondBox = BRepPrimAPI_MakeBox(3.0, 2.0, 1.0).Shape(); + + gp_Trsf aTranslation; + aTranslation.SetTranslation(gp_Vec(0.5, 0.5, 0.5)); + const TopoDS_Shape aTranslatedBox = BRepBuilderAPI_Transform(aSecondBox, aTranslation).Shape(); + + gp_Trsf aRotation; + aRotation.SetRotation(gp_Ax1(gp_Pnt(0.0, 0.0, 0.0), gp_Dir(1.0, 1.0, 1.0)), M_PI / 6.0); + const TopoDS_Shape aRotatedBox = BRepBuilderAPI_Transform(aTranslatedBox, aRotation).Shape(); + const TopoDS_Shape aFusedShape = BRepAlgoAPI_Fuse(aFirstBox, aRotatedBox).Shape(); + ASSERT_FALSE(aFusedShape.IsNull()); + + BRepMesh_IncrementalMesh aMesh(aFusedShape, 0.01); + ASSERT_TRUE(aMesh.IsDone()); + EXPECT_TRUE(BRepCheck_Analyzer(aFusedShape).IsValid()); + + CompareExactAndTriangulatedProperties(aFusedShape, 0); + CompareExactAndTriangulatedProperties(aFusedShape, 1); + CompareExactAndTriangulatedProperties(aFusedShape, 2); +} + +// bugs/demo/bug23130: maxtolerance reports all box subshape counts and their +// default tolerances consistently on every supported platform. +TEST(BRepTools_Test, DemoBug_23130_BoxMaxTolerance) +{ + const TopoDS_Shape aBox = BRepPrimAPI_MakeBox(100.0, 100.0, 100.0).Shape(); + const TopAbs_ShapeEnum aTypes[] = {TopAbs_FACE, TopAbs_EDGE, TopAbs_VERTEX}; + const int anExpectedCounts[] = {6, 12, 8}; + + for (int aTypeIndex = 0; aTypeIndex < 3; ++aTypeIndex) + { + NCollection_Map aShapeMap; + double aMinTolerance = 1.0e100; + double aMaxTolerance = -1.0; + for (TopExp_Explorer anExplorer(aBox, aTypes[aTypeIndex]); anExplorer.More(); anExplorer.Next()) + { + double aTolerance = 0.0; + switch (aTypes[aTypeIndex]) + { + case TopAbs_FACE: + aTolerance = BRep_Tool::Tolerance(TopoDS::Face(anExplorer.Current())); + break; + case TopAbs_EDGE: + aTolerance = BRep_Tool::Tolerance(TopoDS::Edge(anExplorer.Current())); + break; + case TopAbs_VERTEX: + aTolerance = BRep_Tool::Tolerance(TopoDS::Vertex(anExplorer.Current())); + break; + default: + break; + } + aShapeMap.Add(anExplorer.Current()); + aMinTolerance = (std::min)(aMinTolerance, aTolerance); + aMaxTolerance = (std::max)(aMaxTolerance, aTolerance); + } + + EXPECT_EQ(aShapeMap.Extent(), anExpectedCounts[aTypeIndex]); + EXPECT_NEAR(aMinTolerance, 1.0e-7, 1.0e-7); + EXPECT_NEAR(aMaxTolerance, 1.0e-7, 1.0e-7); + } +} + +// Migrated from tests/bugs/moddata_3/bug27356. Clean() must remove a free +// edge's 3D polygon while leaving the topological edge itself usable. +TEST(BRepTools_Test, ModDataBug_27356_CleanRemovesFreeEdgePolygon3d) +{ + const TopoDS_Edge anEdge = + BRepBuilderAPI_MakeEdge(gp_Pnt(0.0, 0.0, 0.0), gp_Pnt(1.0, 0.0, 0.0)).Edge(); + ASSERT_FALSE(anEdge.IsNull()); + + BRepMesh_IncrementalMesh aMesher(anEdge, 0.01); + ASSERT_TRUE(aMesher.IsDone()); + + TopLoc_Location aLocation; + ASSERT_FALSE(BRep_Tool::Polygon3D(anEdge, aLocation).IsNull()); + + BRepTools::Clean(anEdge); + + EXPECT_TRUE(BRep_Tool::Polygon3D(anEdge, aLocation).IsNull()); +} + +// Migrated from tests/bugs/modalg_5/bug24404. UV bounds of the selected box +// face must remain its full parametric limits after the successive cuts. +TEST(BRepTools_Test, ModalgBug_24404_BoxFaceUVBounds) +{ + const TopoDS_Shape aBox = BRepPrimAPI_MakeBox(1500.0, 1500.0, 1500.0).Shape(); + TopoDS_Face aFace = UniqueFace(aBox, 4); + ASSERT_FALSE(aFace.IsNull()); + ExpectBoxUvBounds(aFace); + + const gp_Dir aNormal(0.0, 1.0, 0.0); + aFace = CutAndSelectFirstFace( + aFace, + MakeCircleFace(gp_Pnt(1361.60462531413, 1500.0, 275.105307765905), aNormal, 182.781239888725)); + ASSERT_FALSE(aFace.IsNull()); + ExpectBoxUvBounds(aFace); + + aFace = CutAndSelectFirstFace( + aFace, + MakeCircleFace(gp_Pnt(398.623694869499, 1500.0, 5.77182937332096), aNormal, 181.948898616306)); + ASSERT_FALSE(aFace.IsNull()); + ExpectBoxUvBounds(aFace); + + aFace = CutAndSelectFirstFace( + aFace, + MakeCircleFace(gp_Pnt(66.2457890511211, 1500.0, 832.500519113239), aNormal, 176.393473166564)); + ASSERT_FALSE(aFace.IsNull()); + ExpectBoxUvBounds(aFace); + + aFace = CutAndSelectFirstFace( + aFace, + MakeCircleFace(gp_Pnt(1177.73545803307, 1500.0, 1406.03245550006), aNormal, 150.768085993996)); + ASSERT_FALSE(aFace.IsNull()); + ExpectBoxUvBounds(aFace); +} diff --git a/src/ModelingData/TKG2d/GTests/Geom2dAPI_InterCurveCurve_Test.cxx b/src/ModelingData/TKG2d/GTests/Geom2dAPI_InterCurveCurve_Test.cxx index 3213bf1a87..8d3326b9df 100644 --- a/src/ModelingData/TKG2d/GTests/Geom2dAPI_InterCurveCurve_Test.cxx +++ b/src/ModelingData/TKG2d/GTests/Geom2dAPI_InterCurveCurve_Test.cxx @@ -12,12 +12,16 @@ // commercial license or contractual agreement. #include +#include #include +#include #include #include #include #include +#include #include +#include #include #include @@ -73,3 +77,43 @@ TEST(Geom2dAPI_InterCurveCurve_Test, OCC24889_IntersectionParameterWithinLimits) double aDist2 = aP1.SquareDistance(aP2); EXPECT_LT(aDist2, 1.0e-14) << "Points on both curves at intersection parameters should coincide"; } + +TEST(Geom2dAPI_InterCurveCurve_Test, FClassesBug_25635_1_TangentEllipses) +{ + // fclasses/bug25635_1: extrema between two tangent ellipses includes the zero-distance result. + occ::handle anEllipse1 = + new Geom2d_Ellipse(gp_Elips2d(gp_Ax2d(gp_Pnt2d(0.0, 0.0), gp_Dir2d(1.0, 0.0)), 2.0, 1.0)); + occ::handle anEllipse2 = + new Geom2d_Ellipse(gp_Elips2d(gp_Ax2d(gp_Pnt2d(4.0, 0.0), gp_Dir2d(1.0, 0.0)), 2.0, 1.0)); + + Geom2dAPI_ExtremaCurveCurve anExtrema(anEllipse1, + anEllipse2, + anEllipse1->FirstParameter(), + anEllipse1->LastParameter(), + anEllipse2->FirstParameter(), + anEllipse2->LastParameter()); + ASSERT_GT(anExtrema.NbExtrema(), 0); + EXPECT_NEAR(anExtrema.Distance(1), 0.0, 7.0e-5); +} + +TEST(Geom2dAPI_InterCurveCurve_Test, FClassesBug_25635_2_TangentCircles) +{ + // fclasses/bug25635_2: all four extrema are reported and ext_2 is the tangent point. + occ::handle aCircle1 = + new Geom2d_Circle(gp_Ax22d(gp_Pnt2d(0.0, 0.0), gp_Dir2d(1.0, 0.0), gp_Dir2d(0.0, 1.0)), 2.0); + occ::handle aCircle2 = + new Geom2d_Circle(gp_Ax22d(gp_Pnt2d(4.0, 0.0), gp_Dir2d(1.0, 0.0), gp_Dir2d(0.0, 1.0)), 2.0); + + Geom2dAPI_ExtremaCurveCurve anExtrema(aCircle1, + aCircle2, + aCircle1->FirstParameter(), + aCircle1->LastParameter(), + aCircle2->FirstParameter(), + aCircle2->LastParameter()); + ASSERT_GE(anExtrema.NbExtrema(), 4); + EXPECT_LE(anExtrema.Distance(2), Precision::PConfusion()); + + gp_Pnt2d aPoint1, aPoint2; + anExtrema.Points(2, aPoint1, aPoint2); + EXPECT_TRUE(aPoint1.IsEqual(aPoint2, Precision::PConfusion())); +} diff --git a/src/ModelingData/TKG2d/GTests/Geom2d_OffsetCurve_Test.cxx b/src/ModelingData/TKG2d/GTests/Geom2d_OffsetCurve_Test.cxx index 7bd135d778..8efd3429e3 100644 --- a/src/ModelingData/TKG2d/GTests/Geom2d_OffsetCurve_Test.cxx +++ b/src/ModelingData/TKG2d/GTests/Geom2d_OffsetCurve_Test.cxx @@ -13,8 +13,13 @@ #include +#include +#include +#include #include #include +#include +#include #include #include #include @@ -102,4 +107,23 @@ TEST_F(Geom2d_OffsetCurve_Test, CopyIndependence) // Verify the copied curve is not affected EXPECT_DOUBLE_EQ(aCopiedCurve->Offset(), anOrigOffset); EXPECT_NE(aCopiedCurve->Offset(), myOriginalCurve->Offset()); -} \ No newline at end of file +} + +TEST(Geom2d_OffsetCurve_AdditionalTest, FClassesBug_31381_RationalBSplineApproximation) +{ + // fclasses/bug31381: approximating an offset of a rational BSpline circle keeps its length. + occ::handle aCircle = + new Geom2d_Circle(gp_Circ2d(gp_Ax2d(gp_Pnt2d(0.0, 0.0), gp_Dir2d(1.0, 0.0)), 1.0)); + occ::handle aConvertedCircle = Geom2dConvert::CurveToBSplineCurve(aCircle); + ASSERT_FALSE(aConvertedCircle.IsNull()); + + occ::handle anOffsetCurve = new Geom2d_OffsetCurve(aConvertedCircle, -0.5); + Geom2dConvert_ApproxCurve anApproximation(anOffsetCurve, 1.0e-4, GeomAbs_C2, 25, 5); + ASSERT_TRUE(anApproximation.HasResult()); + occ::handle anApproximatedCurve = anApproximation.Curve(); + ASSERT_FALSE(anApproximatedCurve.IsNull()); + + Geom2dAdaptor_Curve anAdaptor(anApproximatedCurve); + const double aLength = GCPnts_AbscissaPoint::Length(anAdaptor); + EXPECT_NEAR(aLength, 3.1415850499856011, 1.0e-6); +} diff --git a/src/ModelingData/TKG3d/GTests/GeomAPI_ExtremaCurveCurve_Test.cxx b/src/ModelingData/TKG3d/GTests/GeomAPI_ExtremaCurveCurve_Test.cxx index d404a743ff..b3dca7bcfe 100644 --- a/src/ModelingData/TKG3d/GTests/GeomAPI_ExtremaCurveCurve_Test.cxx +++ b/src/ModelingData/TKG3d/GTests/GeomAPI_ExtremaCurveCurve_Test.cxx @@ -14,10 +14,16 @@ #include #include +#include +#include #include +#include #include #include #include +#include +#include +#include #include #include #include @@ -318,3 +324,610 @@ TEST(GeomAPI_ExtremaCurveCurve_Test, OCC862_ExtremaBSplineAndLine) } } } + +// Migrated from tests/lowalgos/extcc/bug26269_1. The finite trimming is +// essential: the corresponding infinite lines have infinitely many extrema. +TEST(GeomAPI_ExtremaCurveCurve_Test, OCC26269_1_TrimmedParallelLines) +{ + const occ::handle aLine1 = new Geom_Line(gp_Pnt(0.0, 0.0, 0.0), gp_Dir(1.0, 0.0, 0.0)); + const occ::handle aLine2 = new Geom_Line(gp_Pnt(2.0, 2.0, 0.0), gp_Dir(1.0, 0.0, 0.0)); + const occ::handle aTrimmed1 = new Geom_TrimmedCurve(aLine1, 0.0, 1.0); + const occ::handle aTrimmed2 = new Geom_TrimmedCurve(aLine2, 0.0, 1.0); + + GeomAPI_ExtremaCurveCurve anExtrema(aTrimmed1, aTrimmed2); + ASSERT_FALSE(anExtrema.Extrema().IsParallel()); + ASSERT_EQ(anExtrema.NbExtrema(), 1); + EXPECT_NEAR(anExtrema.Distance(1), std::sqrt(5.0), 1.e-12); +} + +// Migrated from tests/lowalgos/extcc/bug26269_2. Restrict the two concentric +// circles to disjoint arcs and verify that the finite extrema are computed. +TEST(GeomAPI_ExtremaCurveCurve_Test, OCC26269_2_TrimmedConcentricArcs) +{ + const occ::handle aCircle1 = + new Geom_Circle(gp_Ax2(gp_Pnt(0.0, 0.0, 0.0), gp_Dir(0.0, 0.0, 1.0)), 10.0); + const occ::handle aCircle2 = + new Geom_Circle(gp_Ax2(gp_Pnt(0.0, 0.0, 0.0), gp_Dir(0.0, 0.0, 1.0)), 5.0); + const occ::handle aTrimmed1 = new Geom_TrimmedCurve(aCircle1, 0.0, 1.0); + const occ::handle aTrimmed2 = new Geom_TrimmedCurve(aCircle2, 3.0, 4.0); + + GeomAPI_ExtremaCurveCurve anExtrema(aTrimmed1, aTrimmed2); + ASSERT_FALSE(anExtrema.Extrema().IsParallel()); + ASSERT_EQ(anExtrema.NbExtrema(), 1); + EXPECT_GT(anExtrema.Distance(1), 0.0); +} + +namespace +{ +void checkOCC29426CircleSphere(const double theCircleCenterY, + const double theCircleCenterZ, + const double theSphereRadius) +{ + const occ::handle aCircle = + new Geom_Circle(gp_Ax2(gp_Pnt(0.0, theCircleCenterY, theCircleCenterZ), + gp_Dir(-3.67401855705945e-17, -0.943656647634893, 0.330926172090505), + gp_Dir(-2.2723161366922e-16, 0.330926172090505, 0.943656647634893)), + 1.30000000000039); + const occ::handle aSphere = new Geom_SphericalSurface( + gp_Ax3(gp_Pnt(0.0, 2.425, 0.0), gp_Dir(0.0, 1.0, 0.0), gp_Dir(1.0, 0.0, 0.0)), + theSphereRadius); + + GeomAPI_ExtremaCurveSurface anExtrema(aCircle, aSphere); + ASSERT_TRUE(anExtrema.Extrema().IsDone()); + + if (anExtrema.NbExtrema() > 0) + { + double aMinimumDistance = anExtrema.Distance(1); + for (int anIndex = 2; anIndex <= anExtrema.NbExtrema(); ++anIndex) + { + const double aDistance = anExtrema.Distance(anIndex); + aMinimumDistance = aDistance < aMinimumDistance ? aDistance : aMinimumDistance; + } + EXPECT_NEAR(aMinimumDistance, 0.0, 1.e-10); + } +} + +static occ::handle makeLinearBSpline(const gp_Pnt& thePoint1, + const gp_Pnt& thePoint2) +{ + NCollection_Array1 aPoles(1, 2); + aPoles(1) = thePoint1; + aPoles(2) = thePoint2; + + NCollection_Array1 aKnots(1, 2); + aKnots(1) = 0.0; + aKnots(2) = 1.0; + + NCollection_Array1 aMultiplicities(1, 2); + aMultiplicities(1) = 2; + aMultiplicities(2) = 2; + return new Geom_BSplineCurve(aPoles, aKnots, aMultiplicities, 1); +} + +static void checkOCC29712ConcentricCircles(const double theFirstCircleLastParameter, + const double theSecondCircleFirstParameter, + const double theSecondCircleLastParameter) +{ + const occ::handle aCircle1 = + new Geom_Circle(gp_Ax2(gp_Pnt(0.0, 0.0, 0.0), gp_Dir(0.0, 0.0, 1.0)), 100.0); + const occ::handle aCircle2 = + new Geom_Circle(gp_Ax2(gp_Pnt(0.0, 0.0, 0.0), gp_Dir(0.0, 0.0, 1.0)), 50.0); + const occ::handle aTrimmed1 = + new Geom_TrimmedCurve(aCircle1, 0.0, theFirstCircleLastParameter); + const occ::handle aTrimmed2 = + new Geom_TrimmedCurve(aCircle2, theSecondCircleFirstParameter, theSecondCircleLastParameter); + + GeomAPI_ExtremaCurveCurve anExtrema12(aTrimmed1, aTrimmed2); + ASSERT_TRUE(anExtrema12.Extrema().IsParallel()); + EXPECT_NEAR(anExtrema12.LowerDistance(), 50.0, 1.e-7); + + GeomAPI_ExtremaCurveCurve anExtrema21(aTrimmed2, aTrimmed1); + ASSERT_TRUE(anExtrema21.Extrema().IsParallel()); + EXPECT_NEAR(anExtrema21.LowerDistance(), 50.0, 1.e-7); +} + +static void checkParallelExtrema(const occ::handle& theCurve1, + const occ::handle& theCurve2, + const double theExpectedDistance) +{ + GeomAPI_ExtremaCurveCurve anExtrema12(theCurve1, theCurve2); + ASSERT_TRUE(anExtrema12.Extrema().IsParallel()); + EXPECT_NEAR(anExtrema12.LowerDistance(), theExpectedDistance, 1.e-8); + + GeomAPI_ExtremaCurveCurve anExtrema21(theCurve2, theCurve1); + ASSERT_TRUE(anExtrema21.Extrema().IsParallel()); + EXPECT_NEAR(anExtrema21.LowerDistance(), theExpectedDistance, 1.e-8); +} + +static void checkOneFiniteExtremum(const occ::handle& theCurve1, + const occ::handle& theCurve2, + const double theExpectedDistance) +{ + GeomAPI_ExtremaCurveCurve anExtrema12(theCurve1, theCurve2); + ASSERT_FALSE(anExtrema12.Extrema().IsParallel()); + ASSERT_EQ(anExtrema12.NbExtrema(), 1); + EXPECT_NEAR(anExtrema12.Distance(1), theExpectedDistance, 2.e-8); + + GeomAPI_ExtremaCurveCurve anExtrema21(theCurve2, theCurve1); + ASSERT_FALSE(anExtrema21.Extrema().IsParallel()); + ASSERT_EQ(anExtrema21.NbExtrema(), 1); + EXPECT_NEAR(anExtrema21.Distance(1), theExpectedDistance, 2.e-8); +} + +static occ::handle makeOCC29712TrimmedCircle(const double theRadius, + const double theFirstParameter, + const double theLastParameter) +{ + const occ::handle aCircle = + new Geom_Circle(gp_Ax2(gp_Pnt(0.0, 0.0, 0.0), gp_Dir(0.0, 0.0, 1.0)), theRadius); + return new Geom_TrimmedCurve(aCircle, theFirstParameter, theLastParameter); +} + +static occ::handle makeOCC29712MirroredTrimmedCircle(const double theRadius, + const double theFirstParameter, + const double theLastParameter) +{ + const occ::handle aCircle = + new Geom_Circle(gp_Ax2(gp_Pnt(0.0, 0.0, 0.0), gp_Dir(0.0, 0.0, 1.0)), theRadius); + gp_Trsf aMirror; + aMirror.SetMirror(gp_Ax1(gp_Pnt(0.0, 0.0, 0.0), gp_Dir(1.0, 0.0, 0.0))); + aCircle->Transform(aMirror); + return new Geom_TrimmedCurve(aCircle, theFirstParameter, theLastParameter); +} + +static void checkFiniteConcentricExtremum(const double theSecondCircleFirstParameter, + const double theSecondCircleLastParameter) +{ + const occ::handle aCurve1 = makeOCC29712TrimmedCircle(100.0, 0.0, 3.0); + const occ::handle aCurve2 = + makeOCC29712TrimmedCircle(50.0, theSecondCircleFirstParameter, theSecondCircleLastParameter); + + GeomAPI_ExtremaCurveCurve anExtrema12(aCurve1, aCurve2); + ASSERT_FALSE(anExtrema12.Extrema().IsParallel()); + ASSERT_EQ(anExtrema12.NbExtrema(), 1); + EXPECT_NEAR(anExtrema12.Distance(1), 50.0, 1.e-7); + + GeomAPI_ExtremaCurveCurve anExtrema21(aCurve2, aCurve1); + ASSERT_FALSE(anExtrema21.Extrema().IsParallel()); + ASSERT_EQ(anExtrema21.NbExtrema(), 1); + EXPECT_NEAR(anExtrema21.Distance(1), 50.0, 1.e-7); +} + +static void checkFiniteConcentricExtremumExists(const double theSecondCircleFirstParameter, + const double theSecondCircleLastParameter) +{ + const occ::handle aCurve1 = makeOCC29712TrimmedCircle(100.0, 0.0, 3.0); + const occ::handle aCurve2 = + makeOCC29712TrimmedCircle(50.0, theSecondCircleFirstParameter, theSecondCircleLastParameter); + + GeomAPI_ExtremaCurveCurve anExtrema12(aCurve1, aCurve2); + ASSERT_FALSE(anExtrema12.Extrema().IsParallel()); + EXPECT_GT(anExtrema12.NbExtrema(), 0); + + GeomAPI_ExtremaCurveCurve anExtrema21(aCurve2, aCurve1); + ASSERT_FALSE(anExtrema21.Extrema().IsParallel()); + EXPECT_GT(anExtrema21.NbExtrema(), 0); +} +} // namespace + +// Migrated from tests/lowalgos/extcs/bug29426_1. The source DRAW test +// accepts an explicit intersection-point report as well as a zero extremum. +TEST(GeomAPI_ExtremaCurveCurve_Test, OCC29426_1_CircleSphereMinimumDistance) +{ + checkOCC29426CircleSphere(11.6635040382361, -3.23970209548358, 9.876); +} + +// Migrated from tests/lowalgos/extcs/bug29426_2. +TEST(GeomAPI_ExtremaCurveCurve_Test, OCC29426_2_CircleSphereMinimumDistance) +{ + checkOCC29426CircleSphere(11.5073628633636, -3.18494573739955, 9.712); +} + +// Migrated from tests/lowalgos/extcc/bug29712_2. Bounded parallel B-splines +// must be treated as finite curves rather than as an infinite parallel pair. +TEST(GeomAPI_ExtremaCurveCurve_Test, OCC29712_2_BoundedParallelBSplines) +{ + const occ::handle aCurve1 = + makeLinearBSpline(gp_Pnt(0.0, 0.0, 0.0), gp_Pnt(1.0, 0.0, 0.0)); + const occ::handle aCurve2 = + makeLinearBSpline(gp_Pnt(3.0, 4.0, 0.0), gp_Pnt(4.0, 4.0, 0.0)); + + GeomAPI_ExtremaCurveCurve anExtrema(aCurve1, aCurve2); + ASSERT_FALSE(anExtrema.Extrema().IsParallel()); + ASSERT_EQ(anExtrema.NbExtrema(), 1); + EXPECT_NEAR(anExtrema.Distance(1), std::sqrt(20.0), 2.e-8); +} + +// Migrated from tests/lowalgos/extcc/bug29712_10. Keep both argument orders +// covered because the original regression checked both extrema orientations. +TEST(GeomAPI_ExtremaCurveCurve_Test, OCC29712_10_BoundedParallelLines) +{ + const occ::handle aLine1 = new Geom_Line(gp_Pnt(1.0, 0.0, 0.0), gp_Dir(0.0, 0.0, 1.0)); + const occ::handle aLine2 = new Geom_Line(gp_Pnt(5.0, 0.0, 0.0), gp_Dir(0.0, 0.0, 1.0)); + const occ::handle aTrimmed1 = new Geom_TrimmedCurve(aLine1, -1.0e100, 5.0); + const occ::handle aTrimmed2 = new Geom_TrimmedCurve(aLine2, 5.0, 20.0); + + GeomAPI_ExtremaCurveCurve anExtrema12(aTrimmed1, aTrimmed2); + ASSERT_FALSE(anExtrema12.Extrema().IsParallel()); + ASSERT_EQ(anExtrema12.NbExtrema(), 1); + EXPECT_NEAR(anExtrema12.Distance(1), 4.0, 2.e-8); + + GeomAPI_ExtremaCurveCurve anExtrema21(aTrimmed2, aTrimmed1); + ASSERT_FALSE(anExtrema21.Extrema().IsParallel()); + ASSERT_EQ(anExtrema21.NbExtrema(), 1); + EXPECT_NEAR(anExtrema21.Distance(1), 4.0, 2.e-8); +} + +// Migrated from tests/lowalgos/extcc/bug29712_20. +TEST(GeomAPI_ExtremaCurveCurve_Test, OCC29712_20_ConcentricTrimmedCircles) +{ + checkOCC29712ConcentricCircles(3.0, -3.3, -1.3); +} + +// Migrated from tests/lowalgos/extcc/bug29712_30. +TEST(GeomAPI_ExtremaCurveCurve_Test, OCC29712_30_ConcentricTrimmedCircles) +{ + checkOCC29712ConcentricCircles(3.0, 4.3, 6.3); +} + +// Migrated from tests/lowalgos/extcc/bug29712_40. A short segment on the +// axis of a circle is still reported as an infinite-extrema configuration. +TEST(GeomAPI_ExtremaCurveCurve_Test, OCC29712_40_CircleAndAxisSegment) +{ + const occ::handle aCircle = + new Geom_Circle(gp_Ax2(gp_Pnt(0.0, 0.0, 0.0), gp_Dir(0.0, 0.0, 1.0)), 5.0); + const occ::handle aLine = new Geom_Line(gp_Pnt(0.0, 0.0, 0.0), gp_Dir(0.0, 0.0, 1.0)); + const occ::handle aSegment = new Geom_TrimmedCurve(aLine, -1.0, -5.e-8); + + GeomAPI_ExtremaCurveCurve anExtrema12(aCircle, aSegment); + ASSERT_TRUE(anExtrema12.Extrema().IsParallel()); + EXPECT_NEAR(anExtrema12.LowerDistance(), 5.0, 1.e-7); + + GeomAPI_ExtremaCurveCurve anExtrema21(aSegment, aCircle); + ASSERT_TRUE(anExtrema21.Extrema().IsParallel()); + EXPECT_NEAR(anExtrema21.LowerDistance(), 5.0, 1.e-7); +} + +// Migrated from tests/lowalgos/extcc/bug29712_43. The reversed tiny line +// segment has no extrema in either argument order. +TEST(GeomAPI_ExtremaCurveCurve_Test, OCC29712_43_CircleAndDegenerateSegment) +{ + const occ::handle aCircle = + new Geom_Circle(gp_Ax2(gp_Pnt(0.0, 0.0, 0.0), gp_Dir(0.0, 0.0, 1.0)), 5.0); + const occ::handle aLine = new Geom_Line(gp_Pnt(0.0, 0.0, 0.0), gp_Dir(0.0, 0.0, 1.0)); + const occ::handle aSegment = new Geom_TrimmedCurve(aLine, -1.5e-7, -1.0); + + GeomAPI_ExtremaCurveCurve anExtrema12(aCircle, aSegment); + EXPECT_FALSE(anExtrema12.Extrema().IsParallel()); + EXPECT_EQ(anExtrema12.NbExtrema(), 0); + + GeomAPI_ExtremaCurveCurve anExtrema21(aSegment, aCircle); + EXPECT_FALSE(anExtrema21.Extrema().IsParallel()); + EXPECT_EQ(anExtrema21.NbExtrema(), 0); +} + +// Migrated from tests/lowalgos/extcc/bug29712_3. +TEST(GeomAPI_ExtremaCurveCurve_Test, OCC29712_3_BoundedParallelSegments) +{ + const occ::handle aCurve1 = + new Geom_TrimmedCurve(new Geom_Line(gp_Pnt(0.0, 0.0, 0.0), gp_Dir(1.0, 0.0, 0.0)), 0.0, 1.0); + const occ::handle aCurve2 = + new Geom_TrimmedCurve(new Geom_Line(gp_Pnt(3.0, 4.0, 0.0), gp_Dir(1.0, 0.0, 0.0)), 0.0, 1.0); + checkOneFiniteExtremum(aCurve1, aCurve2, std::sqrt(20.0)); +} + +// Migrated from tests/lowalgos/extcc/bug29712_4. +TEST(GeomAPI_ExtremaCurveCurve_Test, OCC29712_4_ParallelTrimmedLines) +{ + const occ::handle aCurve1 = + new Geom_TrimmedCurve(new Geom_Line(gp_Pnt(0.0, 0.0, 0.0), gp_Dir(1.0, 0.0, 0.0)), 0.0, 1.0); + const occ::handle aCurve2 = + new Geom_TrimmedCurve(new Geom_Line(gp_Pnt(0.0, 4.0, 0.0), gp_Dir(1.0, 0.0, 0.0)), 0.0, 1.0); + checkParallelExtrema(aCurve1, aCurve2, 4.0); +} + +// Migrated from tests/lowalgos/extcc/bug29712_5. The source checks that both +// orientations still produce a finite result for separated trimmed lines. +TEST(GeomAPI_ExtremaCurveCurve_Test, OCC29712_5_SeparatedTrimmedLines) +{ + const occ::handle aCurve1 = + new Geom_TrimmedCurve(new Geom_Line(gp_Pnt(1.0, 0.0, 0.0), gp_Dir(0.0, 0.0, 1.0)), + -1.0e100, + 5.0); + const occ::handle aCurve2 = + new Geom_TrimmedCurve(new Geom_Line(gp_Pnt(5.0, 0.0, 0.0), gp_Dir(0.0, 0.0, 1.0)), 10.0, 20.0); + + GeomAPI_ExtremaCurveCurve anExtrema12(aCurve1, aCurve2); + ASSERT_FALSE(anExtrema12.Extrema().IsParallel()); + EXPECT_EQ(anExtrema12.NbExtrema(), 1); + GeomAPI_ExtremaCurveCurve anExtrema21(aCurve2, aCurve1); + ASSERT_FALSE(anExtrema21.Extrema().IsParallel()); + EXPECT_EQ(anExtrema21.NbExtrema(), 1); +} + +// Migrated from tests/lowalgos/extcc/bug29712_6. +TEST(GeomAPI_ExtremaCurveCurve_Test, OCC29712_6_ParallelLines) +{ + const occ::handle aCurve1 = + new Geom_Line(gp_Pnt(1.0, 2.0, 3.0), gp_Dir(0.0, 1.0, 0.0)); + const occ::handle aCurve2 = + new Geom_Line(gp_Pnt(10.0, 9.0, 8.0), gp_Dir(0.0, 1.0, 0.0)); + checkParallelExtrema(aCurve1, aCurve2, std::sqrt(106.0)); +} + +// Migrated from tests/lowalgos/extcc/bug29712_7. +TEST(GeomAPI_ExtremaCurveCurve_Test, OCC29712_7_ParallelTrimmedLine) +{ + const occ::handle aCurve1 = + new Geom_Line(gp_Pnt(1.0, 2.0, 3.0), gp_Dir(0.0, 1.0, 0.0)); + const occ::handle aCurve2 = + new Geom_TrimmedCurve(new Geom_Line(gp_Pnt(10.0, 9.0, 8.0), gp_Dir(0.0, 1.0, 0.0)), -1.0, 2.0); + checkParallelExtrema(aCurve1, aCurve2, std::sqrt(106.0)); +} + +// Migrated from tests/lowalgos/extcc/bug29712_8. +TEST(GeomAPI_ExtremaCurveCurve_Test, OCC29712_8_ParallelTrimmedFirstLine) +{ + const occ::handle aCurve1 = + new Geom_TrimmedCurve(new Geom_Line(gp_Pnt(1.0, 2.0, 3.0), gp_Dir(0.0, 1.0, 0.0)), + -100.0, + 200.0); + const occ::handle aCurve2 = + new Geom_Line(gp_Pnt(10.0, 9.0, 8.0), gp_Dir(0.0, 1.0, 0.0)); + checkParallelExtrema(aCurve1, aCurve2, std::sqrt(106.0)); +} + +// Migrated from tests/lowalgos/extcc/bug29712_9. +TEST(GeomAPI_ExtremaCurveCurve_Test, OCC29712_9_OppositeDirectionLines) +{ + const occ::handle aCurve1 = + new Geom_TrimmedCurve(new Geom_Line(gp_Pnt(1.0, 0.0, 0.0), gp_Dir(0.0, 0.0, -1.0)), -5.0, 2.0); + const occ::handle aCurve2 = + new Geom_TrimmedCurve(new Geom_Line(gp_Pnt(5.0, 0.0, 0.0), gp_Dir(0.0, 0.0, 1.0)), + -1.0e100, + 9.9e-8); + checkParallelExtrema(aCurve1, aCurve2, 4.0); +} + +// Migrated from tests/lowalgos/extcc/bug29712_11. +TEST(GeomAPI_ExtremaCurveCurve_Test, OCC29712_11_SeparatedOppositeLines) +{ + const occ::handle aCurve1 = + new Geom_TrimmedCurve(new Geom_Line(gp_Pnt(1.0, 0.0, 0.0), gp_Dir(0.0, 0.0, 1.0)), 0.0, 3.0); + const occ::handle aCurve2 = + new Geom_TrimmedCurve(new Geom_Line(gp_Pnt(5.0, 0.0, 0.0), gp_Dir(0.0, 0.0, -1.0)), + -9.9e-8, + 1.0e100); + checkOneFiniteExtremum(aCurve1, aCurve2, 4.0); +} + +// Migrated from tests/lowalgos/extcc/bug29712_12. +TEST(GeomAPI_ExtremaCurveCurve_Test, OCC29712_12_OppositeTrimmedSegments) +{ + const occ::handle aCurve1 = + new Geom_TrimmedCurve(new Geom_Line(gp_Pnt(0.0, 0.0, 0.0), gp_Dir(1.0, 0.0, 0.0)), 0.0, 1.0); + const occ::handle aCurve2 = + new Geom_TrimmedCurve(new Geom_Line(gp_Pnt(0.0, 4.0, 0.0), gp_Dir(-1.0, 0.0, 0.0)), -2.0, -1.0); + checkOneFiniteExtremum(aCurve1, aCurve2, 4.0); +} + +// Migrated from tests/lowalgos/extcc/bug29712_13. +TEST(GeomAPI_ExtremaCurveCurve_Test, OCC29712_13_SeparatedConcentricArcs) +{ + checkFiniteConcentricExtremumExists(4.0, 6.0); +} + +// Migrated from tests/lowalgos/extcc/bug29712_14. +TEST(GeomAPI_ExtremaCurveCurve_Test, OCC29712_14_ParallelConcentricArcs) +{ + checkOCC29712ConcentricCircles(3.0, -8.1, -6.1); +} + +// Migrated from tests/lowalgos/extcc/bug29712_15. +TEST(GeomAPI_ExtremaCurveCurve_Test, OCC29712_15_ParallelConcentricArcs) +{ + checkOCC29712ConcentricCircles(3.0, -1.9, 0.1); +} + +// Migrated from tests/lowalgos/extcc/bug29712_16. The common radial arc +// produces a finite minimum and must not be reported as infinitely parallel. +TEST(GeomAPI_ExtremaCurveCurve_Test, OCC29712_16_FiniteConcentricMinimum) +{ + checkFiniteConcentricExtremum(-2.0, 0.0); +} + +// Migrated from tests/lowalgos/extcc/bug29712_17. +TEST(GeomAPI_ExtremaCurveCurve_Test, OCC29712_17_ParallelConcentricArcs) +{ + checkOCC29712ConcentricCircles(3.0, -3.6, -1.6); +} + +// Migrated from tests/lowalgos/extcc/bug29712_18. +TEST(GeomAPI_ExtremaCurveCurve_Test, OCC29712_18_ParallelConcentricArcs) +{ + checkOCC29712ConcentricCircles(3.0, -3.5, -1.5); +} + +// Migrated from tests/lowalgos/extcc/bug29712_19. +TEST(GeomAPI_ExtremaCurveCurve_Test, OCC29712_19_ParallelConcentricArcs) +{ + checkOCC29712ConcentricCircles(3.0, -3.4, -1.4); +} + +// Migrated from tests/lowalgos/extcc/bug29712_21. +TEST(GeomAPI_ExtremaCurveCurve_Test, OCC29712_21_SeparatedConcentricArcs) +{ + checkFiniteConcentricExtremumExists(-3.2, -1.2); +} + +// Migrated from tests/lowalgos/extcc/bug29712_22. +TEST(GeomAPI_ExtremaCurveCurve_Test, OCC29712_22_SeparatedConcentricArcs) +{ + checkFiniteConcentricExtremumExists(-3.1, -1.1); +} + +// Migrated from tests/lowalgos/extcc/bug29712_23. +TEST(GeomAPI_ExtremaCurveCurve_Test, OCC29712_23_ParallelConcentricArcs) +{ + checkOCC29712ConcentricCircles(3.0, -9.6, -7.6); +} + +// Migrated from tests/lowalgos/extcc/bug29712_24. +TEST(GeomAPI_ExtremaCurveCurve_Test, OCC29712_24_SeparatedConcentricArcs) +{ + checkFiniteConcentricExtremumExists(-9.5, -7.5); +} + +// Migrated from tests/lowalgos/extcc/bug29712_25. +TEST(GeomAPI_ExtremaCurveCurve_Test, OCC29712_25_SeparatedConcentricArcs) +{ + checkFiniteConcentricExtremumExists(-8.3, -6.3); +} + +// Migrated from tests/lowalgos/extcc/bug29712_26. +TEST(GeomAPI_ExtremaCurveCurve_Test, OCC29712_26_ParallelConcentricArcs) +{ + checkOCC29712ConcentricCircles(3.0, -8.2, -6.2); +} + +// Migrated from tests/lowalgos/extcc/bug29712_27. +TEST(GeomAPI_ExtremaCurveCurve_Test, OCC29712_27_ParallelConcentricArcs) +{ + checkOCC29712ConcentricCircles(3.0, 0.0, 2.0); +} + +// Migrated from tests/lowalgos/extcc/bug29712_28. The crossing arc pair +// must return one finite extremum rather than an infinite solution set. +TEST(GeomAPI_ExtremaCurveCurve_Test, OCC29712_28_FiniteConcentricMinimum) +{ + checkFiniteConcentricExtremum(3.0, 5.0); +} + +// Migrated from tests/lowalgos/extcc/bug29712_29. +TEST(GeomAPI_ExtremaCurveCurve_Test, OCC29712_29_SeparatedConcentricArcs) +{ + checkFiniteConcentricExtremumExists(3.1, 5.1); +} + +// Migrated from tests/lowalgos/extcc/bug29712_31. +TEST(GeomAPI_ExtremaCurveCurve_Test, OCC29712_31_ParallelConcentricArcs) +{ + checkOCC29712ConcentricCircles(M_PI, -9.5, -7.5); +} + +// Migrated from tests/lowalgos/extcc/bug29712_32. +TEST(GeomAPI_ExtremaCurveCurve_Test, OCC29712_32_SeparatedConcentricArcs) +{ + checkFiniteConcentricExtremumExists(-9.4, -7.4); +} + +// Migrated from tests/lowalgos/extcc/bug29712_33. +TEST(GeomAPI_ExtremaCurveCurve_Test, OCC29712_33_ParallelConcentricArcs) +{ + checkOCC29712ConcentricCircles(M_PI, 0.0, 2.0); +} + +// Migrated from tests/lowalgos/extcc/bug29712_34. The bounded concentric +// arcs intentionally exercise the asymmetric extrema enumeration order. +TEST(GeomAPI_ExtremaCurveCurve_Test, OCC29712_34_AsymmetricConcentricArcs) +{ + const occ::handle aCurve1 = makeOCC29712TrimmedCircle(100.0, 0.0, M_PI); + const occ::handle aCurve2 = makeOCC29712TrimmedCircle(50.0, -2.0, 0.0); + + GeomAPI_ExtremaCurveCurve anExtrema12(aCurve1, aCurve2); + ASSERT_FALSE(anExtrema12.Extrema().IsParallel()); + ASSERT_EQ(anExtrema12.NbExtrema(), 2); + const double aDistance121 = anExtrema12.Distance(1); + const double aDistance122 = anExtrema12.Distance(2); + EXPECT_NEAR(std::min(aDistance121, aDistance122), 50.0, 1.e-7); + EXPECT_NEAR(std::max(aDistance121, aDistance122), 150.0, 1.e-7); + + GeomAPI_ExtremaCurveCurve anExtrema21(aCurve2, aCurve1); + ASSERT_FALSE(anExtrema21.Extrema().IsParallel()); + ASSERT_EQ(anExtrema21.NbExtrema(), 1); + EXPECT_NEAR(anExtrema21.Distance(1), 50.0, 1.e-7); +} + +// Migrated from tests/lowalgos/extcc/bug29712_35. Both argument orders +// produce the two finite radial extrema for these opposite half-arcs. +TEST(GeomAPI_ExtremaCurveCurve_Test, OCC29712_35_OppositeConcentricArcs) +{ + const occ::handle aCurve1 = makeOCC29712TrimmedCircle(100.0, 0.0, M_PI); + const occ::handle aCurve2 = makeOCC29712TrimmedCircle(50.0, M_PI, 2.0 * M_PI); + + GeomAPI_ExtremaCurveCurve anExtrema12(aCurve1, aCurve2); + ASSERT_FALSE(anExtrema12.Extrema().IsParallel()); + ASSERT_EQ(anExtrema12.NbExtrema(), 2); + const double aDistance121 = anExtrema12.Distance(1); + const double aDistance122 = anExtrema12.Distance(2); + EXPECT_NEAR(std::min(aDistance121, aDistance122), 50.0, 1.e-7); + EXPECT_NEAR(std::max(aDistance121, aDistance122), 150.0, 1.e-7); + + GeomAPI_ExtremaCurveCurve anExtrema21(aCurve2, aCurve1); + ASSERT_FALSE(anExtrema21.Extrema().IsParallel()); + ASSERT_EQ(anExtrema21.NbExtrema(), 2); + const double aDistance211 = anExtrema21.Distance(1); + const double aDistance212 = anExtrema21.Distance(2); + EXPECT_NEAR(std::min(aDistance211, aDistance212), 50.0, 1.e-7); + EXPECT_NEAR(std::max(aDistance211, aDistance212), 150.0, 1.e-7); +} + +// Migrated from tests/lowalgos/extcc/bug29712_36. +TEST(GeomAPI_ExtremaCurveCurve_Test, OCC29712_36_ParallelFullCircleAndArc) +{ + checkOCC29712ConcentricCircles(2.0 * M_PI, -12.0, -10.0); +} + +// Migrated from tests/lowalgos/extcc/bug29712_37. +TEST(GeomAPI_ExtremaCurveCurve_Test, OCC29712_37_SeparatedConcentricArcs) +{ + const occ::handle aCurve1 = makeOCC29712MirroredTrimmedCircle(100.0, 3.0, 6.5); + const occ::handle aCurve2 = makeOCC29712TrimmedCircle(50.0, 4.0, 6.0); + GeomAPI_ExtremaCurveCurve anExtrema12(aCurve1, aCurve2); + ASSERT_FALSE(anExtrema12.Extrema().IsParallel()); + EXPECT_GT(anExtrema12.NbExtrema(), 0); + GeomAPI_ExtremaCurveCurve anExtrema21(aCurve2, aCurve1); + ASSERT_FALSE(anExtrema21.Extrema().IsParallel()); + EXPECT_GT(anExtrema21.NbExtrema(), 0); +} + +// Migrated from tests/lowalgos/extcc/bug29712_38. +TEST(GeomAPI_ExtremaCurveCurve_Test, OCC29712_38_ParallelConcentricArcs) +{ + const occ::handle aCurve1 = makeOCC29712MirroredTrimmedCircle(100.0, 0.0, 4.0); + const occ::handle aCurve2 = makeOCC29712TrimmedCircle(50.0, 4.0, 6.0); + checkParallelExtrema(aCurve1, aCurve2, 50.0); +} + +// Migrated from tests/lowalgos/extcc/bug29712_39. +TEST(GeomAPI_ExtremaCurveCurve_Test, OCC29712_39_CircleAndAxisSegment) +{ + const occ::handle aCircle = makeOCC29712TrimmedCircle(5.0, 0.0, 2.0 * M_PI); + const occ::handle aSegment = + new Geom_TrimmedCurve(new Geom_Line(gp_Pnt(0.0, 0.0, 0.0), gp_Dir(0.0, 0.0, 1.0)), -1.0, 1.0); + checkParallelExtrema(aCircle, aSegment, 5.0); +} + +// Migrated from tests/lowalgos/extcc/bug29712_41. +TEST(GeomAPI_ExtremaCurveCurve_Test, OCC29712_41_CircleAndNearAxisSegment) +{ + const occ::handle aCircle = makeOCC29712TrimmedCircle(5.0, 0.0, 2.0 * M_PI); + const occ::handle aSegment = + new Geom_TrimmedCurve(new Geom_Line(gp_Pnt(0.0, 0.0, 0.0), gp_Dir(0.0, 0.0, 1.0)), 3.e-8, 1.0); + checkParallelExtrema(aCircle, aSegment, 5.0); +} + +// Migrated from tests/lowalgos/extcc/bug29712_42. +TEST(GeomAPI_ExtremaCurveCurve_Test, OCC29712_42_CircleAndTooNearAxisSegment) +{ + const occ::handle aCircle = makeOCC29712TrimmedCircle(5.0, 0.0, 2.0 * M_PI); + const occ::handle aSegment = + new Geom_TrimmedCurve(new Geom_Line(gp_Pnt(0.0, 0.0, 0.0), gp_Dir(0.0, 0.0, 1.0)), 2.e-7, 1.0); + + GeomAPI_ExtremaCurveCurve anExtrema12(aCircle, aSegment); + EXPECT_FALSE(anExtrema12.Extrema().IsParallel()); + EXPECT_EQ(anExtrema12.NbExtrema(), 0); + GeomAPI_ExtremaCurveCurve anExtrema21(aSegment, aCircle); + EXPECT_FALSE(anExtrema21.Extrema().IsParallel()); + EXPECT_EQ(anExtrema21.NbExtrema(), 0); +} diff --git a/src/ModelingData/TKGeomBase/GTests/FILES.cmake b/src/ModelingData/TKGeomBase/GTests/FILES.cmake index 4984b0ba5a..49cc7fa01a 100644 --- a/src/ModelingData/TKGeomBase/GTests/FILES.cmake +++ b/src/ModelingData/TKGeomBase/GTests/FILES.cmake @@ -37,6 +37,8 @@ set(OCCT_TKGeomBase_GTests_FILES GC_MakeParabola2d_Test.cxx GC_MakeSegment2d_Test.cxx GCPnts_AbscissaPoint_Test.cxx + GCPnts_QuasiUniformDeflection_Test.cxx + GeomProjLib_Test.cxx GeomConvert_CompCurveToBSplineCurve_Test.cxx Geom2dConvert_CompCurveToBSplineCurve_Test.cxx GeomConvert_Test.cxx diff --git a/src/ModelingData/TKGeomBase/GTests/GCPnts_QuasiUniformDeflection_Test.cxx b/src/ModelingData/TKGeomBase/GTests/GCPnts_QuasiUniformDeflection_Test.cxx new file mode 100644 index 0000000000..8d13649f6a --- /dev/null +++ b/src/ModelingData/TKGeomBase/GTests/GCPnts_QuasiUniformDeflection_Test.cxx @@ -0,0 +1,98 @@ +// Copyright (c) 2026 OPEN CASCADE SAS +// +// This file is part of Open CASCADE Technology software library. +// +// This library is free software; you can redistribute it and/or modify it under +// the terms of the GNU Lesser General Public License version 2.1 as published +// by the Free Software Foundation, with special exception defined in the file +// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT +// distribution for complete text of the license and disclaimer of any warranty. +// +// Alternatively, this file may be used under the terms of Open CASCADE +// commercial license or contractual agreement. + +#include + +#include +#include +#include +#include +#include + +namespace +{ +occ::handle makeOCC33828Curve() +{ + NCollection_Array1 aKnots(1, 7); + aKnots(1) = 0.0; + aKnots(2) = 0.17; + aKnots(3) = 0.33; + aKnots(4) = 0.5; + aKnots(5) = 0.67; + aKnots(6) = 0.83; + aKnots(7) = 1.0; + + NCollection_Array1 aMultiplicities(1, 7); + aMultiplicities(1) = 4; + aMultiplicities(2) = 2; + aMultiplicities(3) = 2; + aMultiplicities(4) = 2; + aMultiplicities(5) = 2; + aMultiplicities(6) = 2; + aMultiplicities(7) = 4; + + const double aPoleCoordinates[14][3] = {{0.163, 0.233, 0.0}, + {0.158, 0.204, 0.0}, + {0.139, 0.180, 0.0}, + {0.086, 0.159, 0.0}, + {0.055, 0.163, 0.0}, + {0.009, 0.196, 0.0}, + {-0.004, 0.225, 0.0}, + {0.002, 0.281, 0.0}, + {0.019, 0.307, 0.0}, + {0.070, 0.332, 0.0}, + {0.101, 0.331, 0.0}, + {0.149, 0.301, 0.0}, + {0.164, 0.274, 0.0}, + {0.163, 0.246, 0.0}}; + + NCollection_Array1 aPoles(1, 14); + for (int anIndex = 0; anIndex < 14; ++anIndex) + { + aPoles(anIndex + 1) = gp_Pnt(aPoleCoordinates[anIndex][0], + aPoleCoordinates[anIndex][1], + aPoleCoordinates[anIndex][2]); + } + + return new Geom_BSplineCurve(aPoles, aKnots, aMultiplicities, 3); +} + +void checkOCC33828Deflection(const GeomAdaptor_Curve& theCurve, + const double theDeflection, + const int theExpectedNbPoints) +{ + const GCPnts_QuasiUniformDeflection anAlgo(theCurve, theDeflection); + ASSERT_TRUE(anAlgo.IsDone()); + EXPECT_EQ(anAlgo.NbPoints(), theExpectedNbPoints); + EXPECT_LE(anAlgo.Deflection(), theDeflection); +} +} // namespace + +// Migrated from tests/bugs/moddata_3/bug33828. Small changes in requested +// deflection must produce the stable point counts recorded by the DRAW test. +TEST(GCPnts_QuasiUniformDeflectionTest, ModDataBug_33828_StablePointCounts) +{ + const occ::handle aCurve = makeOCC33828Curve(); + const GeomAdaptor_Curve anAdaptor(aCurve); + + checkOCC33828Deflection(anAdaptor, 0.5, 2); + checkOCC33828Deflection(anAdaptor, 0.1, 3); + checkOCC33828Deflection(anAdaptor, 0.05, 5); + checkOCC33828Deflection(anAdaptor, 0.025, 5); + checkOCC33828Deflection(anAdaptor, 0.007, 9); + checkOCC33828Deflection(anAdaptor, 0.005, 17); + checkOCC33828Deflection(anAdaptor, 0.0005, 33); + checkOCC33828Deflection(anAdaptor, 0.0003, 65); + checkOCC33828Deflection(anAdaptor, 0.0002, 65); + checkOCC33828Deflection(anAdaptor, 0.0001, 73); +} diff --git a/src/ModelingData/TKGeomBase/GTests/GeomProjLib_Test.cxx b/src/ModelingData/TKGeomBase/GTests/GeomProjLib_Test.cxx new file mode 100644 index 0000000000..b7a464f232 --- /dev/null +++ b/src/ModelingData/TKGeomBase/GTests/GeomProjLib_Test.cxx @@ -0,0 +1,95 @@ +// Copyright (c) 2026 OPEN CASCADE SAS +// +// This file is part of Open CASCADE Technology software library. +// +// This library is free software; you can redistribute it and/or modify it under +// the terms of the GNU Lesser General Public License version 2.1 as published +// by the Free Software Foundation, with special exception defined in the file +// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT +// distribution for complete text of the license and disclaimer of any warranty. +// +// Alternatively, this file may be used under the terms of Open CASCADE +// commercial license or contractual agreement. + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace +{ +occ::handle makeOCC31661Plane() +{ + return new Geom_Plane(gp_Pln(gp_Pnt(0.0, 0.0, 0.0), gp_Dir(0.0, 0.0, 1.0))); +} + +gp_Ax2 makeOCC31661CurveAxis() +{ + return gp_Ax2(gp_Pnt(0.0, 0.0, 0.0), gp_Dir(1.0, 1.0, 1.0), gp_Dir(2.0, 0.0, -2.0)); +} +} // namespace + +// Migrated from tests/bugs/moddata_3/bug31661_1. Projection of a parabola onto +// the XY plane must preserve its conic type and the trimmed parameter range. +TEST(GeomProjLibTest, OCC31661_1_ProjectParabolaOnPlane) +{ + const occ::handle aParabola = new Geom_Parabola(makeOCC31661CurveAxis(), 10.0); + const occ::handle aPlane = makeOCC31661Plane(); + + const occ::handle aProjected = + GeomProjLib::ProjectOnPlane(aParabola, aPlane, gp_Dir(0.0, 0.0, 1.0), false); + ASSERT_FALSE(aProjected.IsNull()); + EXPECT_STREQ(aProjected->DynamicType()->Name(), "Geom_Parabola"); + + const occ::handle aTrimmed = new Geom_TrimmedCurve(aParabola, -100.0, 100.0); + const occ::handle aProjectedTrimmed = + GeomProjLib::ProjectOnPlane(aTrimmed, aPlane, gp_Dir(0.0, 0.0, 1.0), false); + ASSERT_FALSE(aProjectedTrimmed.IsNull()); + EXPECT_STREQ(aProjectedTrimmed->DynamicType()->Name(), "Geom_TrimmedCurve"); + + const GeomAdaptor_Curve anAdaptor(aProjectedTrimmed); + EXPECT_NEAR(GCPnts_AbscissaPoint::Length(anAdaptor, Precision::Confusion()), + 408.40363195229503, + 2.0e-5); + // The parameter checks retain DRAW's references; the wider bound reflects + // the relative numerical tolerance used by its checkreal command. + EXPECT_NEAR(aProjectedTrimmed->FirstParameter(), -91.077748943768597, 2.0e-6); + EXPECT_NEAR(aProjectedTrimmed->LastParameter(), 72.221567418462357, 2.0e-6); +} + +// Migrated from tests/bugs/moddata_3/bug31661_2. Projection of a hyperbola +// must not crash and must retain the hyperbolic conic type after trimming. +TEST(GeomProjLibTest, OCC31661_2_ProjectHyperbolaOnPlane) +{ + const occ::handle aHyperbola = + new Geom_Hyperbola(makeOCC31661CurveAxis(), 10.0, 10.0); + const occ::handle aPlane = makeOCC31661Plane(); + + const occ::handle aProjected = + GeomProjLib::ProjectOnPlane(aHyperbola, aPlane, gp_Dir(0.0, 0.0, 1.0), false); + ASSERT_FALSE(aProjected.IsNull()); + EXPECT_STREQ(aProjected->DynamicType()->Name(), "Geom_Hyperbola"); + + const occ::handle aTrimmed = new Geom_TrimmedCurve(aHyperbola, -5.0, 5.0); + const occ::handle aProjectedTrimmed = + GeomProjLib::ProjectOnPlane(aTrimmed, aPlane, gp_Dir(0.0, 0.0, 1.0), false); + ASSERT_FALSE(aProjectedTrimmed.IsNull()); + EXPECT_STREQ(aProjectedTrimmed->DynamicType()->Name(), "Geom_TrimmedCurve"); + + const GeomAdaptor_Curve anAdaptor(aProjectedTrimmed); + EXPECT_NEAR(GCPnts_AbscissaPoint::Length(anAdaptor, Precision::Confusion()), + 1664.3732976598988, + 2.0e-5); + EXPECT_NEAR(aProjectedTrimmed->FirstParameter(), -5.23179933356147, 1.0e-7); + EXPECT_NEAR(aProjectedTrimmed->LastParameter(), 4.76820064934972, 1.0e-7); +} diff --git a/src/ModelingData/TKGeomBase/GTests/IntAna_IntQuadQuad_Test.cxx b/src/ModelingData/TKGeomBase/GTests/IntAna_IntQuadQuad_Test.cxx index 6ed2a9dc59..197ed51e95 100644 --- a/src/ModelingData/TKGeomBase/GTests/IntAna_IntQuadQuad_Test.cxx +++ b/src/ModelingData/TKGeomBase/GTests/IntAna_IntQuadQuad_Test.cxx @@ -12,6 +12,7 @@ // commercial license or contractual agreement. #include +#include #include #include #include @@ -19,7 +20,11 @@ #include #include #include +#include +#include +#include #include +#include #include @@ -271,3 +276,48 @@ TEST_F(IntAna_IntQuadQuad_Test, CylinderCylinderSkewExternallyTangent_HasPoint) EXPECT_NEAR(gp_Lin(aCyl1.Axis()).Distance(aP), aR1, 1.0e-7); EXPECT_NEAR(gp_Lin(aCyl2.Axis()).Distance(aP), aR2, 1.0e-7); } + +// Migrated from tests/bugs/moddata_3/bug23939. Internally tangent circles +// intersect at the X-axis point and both analytical parameters must be zero. +TEST(IntAna2d_AnaIntersectionTest, ModDataBug_23939_TangentCircleParameters) +{ + const gp_Ax2d anXAxis(gp_Pnt2d(0.0, 0.0), gp_Dir2d(1.0, 0.0)); + const gp_Circ2d aCircle1(anXAxis, 10.0); + const gp_Circ2d aCircle2(gp_Ax2d(gp_Pnt2d(7.0, 0.0), gp_Dir2d(1.0, 0.0)), 3.0); + + IntAna2d_AnaIntersection anIntersection(aCircle1, aCircle2); + ASSERT_TRUE(anIntersection.IsDone()); + ASSERT_EQ(anIntersection.NbPoints(), 1); + const IntAna2d_IntPoint& anIntersectionPoint = anIntersection.Point(1); + EXPECT_NEAR(anIntersectionPoint.ParamOnFirst(), 0.0, 1.0e-15); + EXPECT_NEAR(anIntersectionPoint.ParamOnSecond(), 0.0, 1.0e-15); + EXPECT_NEAR(anIntersectionPoint.Value().X(), 10.0, 1.0e-12); + EXPECT_NEAR(anIntersectionPoint.Value().Y(), 0.0, 1.0e-12); + + IntAna2d_AnaIntersection aReversedIntersection(aCircle2, aCircle1); + ASSERT_TRUE(aReversedIntersection.IsDone()); + ASSERT_EQ(aReversedIntersection.NbPoints(), 1); + const IntAna2d_IntPoint& aReversedPoint = aReversedIntersection.Point(1); + EXPECT_NEAR(aReversedPoint.ParamOnFirst(), 0.0, 1.0e-15); + EXPECT_NEAR(aReversedPoint.ParamOnSecond(), 0.0, 1.0e-15); +} + +// Migrated from tests/bugs/moddata_3/bug24375. Nearly coincident equal circles +// must retain the two diametrically opposite analytical intersection points. +TEST(IntAna2d_AnaIntersectionTest, ModDataBug_24375_NearlyCoincidentCircleParameters) +{ + const gp_Circ2d aCircle1(gp_Ax2d(gp_Pnt2d(10.0, 0.0), gp_Dir2d(1.0, 0.0)), 100.0); + const gp_Circ2d aCircle2(gp_Ax2d(gp_Pnt2d(10.00000000000001, 0.0), gp_Dir2d(1.0, 0.0)), 100.0); + + IntAna2d_AnaIntersection anIntersection(aCircle1, aCircle2); + ASSERT_TRUE(anIntersection.IsDone()); + ASSERT_EQ(anIntersection.NbPoints(), 2); + + const double anExpectedParameters[2] = {M_PI / 2.0, 3.0 * M_PI / 2.0}; + for (int anIndex = 1; anIndex <= 2; ++anIndex) + { + const IntAna2d_IntPoint& anIntersectionPoint = anIntersection.Point(anIndex); + EXPECT_NEAR(anIntersectionPoint.ParamOnFirst(), anExpectedParameters[anIndex - 1], 1.0e-7); + EXPECT_NEAR(anIntersectionPoint.ParamOnSecond(), anExpectedParameters[anIndex - 1], 1.0e-7); + } +} diff --git a/tests/boolean/history/A1 b/tests/boolean/history/A1 deleted file mode 100644 index 2bc5eb229c..0000000000 --- a/tests/boolean/history/A1 +++ /dev/null @@ -1,178 +0,0 @@ -puts "Check History of Boolean operations" - -puts "Case with intersecting circles (two intersection points)" - -circle c1 0 0 0 10 -mkedge e1 c1 - -circle c2 10 0 0 10 -mkedge e2 c2 - -bclearobjects -bcleartools -baddobjects e1 -baddtools e2 -bfillds - -puts "Common operation" -bbop rcom 0 - -# get history of the operation -savehistory com_hist - -# check that both e1 and e2 have been deleted -if {[string trim [isdeleted com_hist e1]] != "Deleted."} { - puts "Error: Incorrect information about Deleted shapes" -} - -if {[string trim [isdeleted com_hist e2]] != "Deleted."} { - puts "Error: Incorrect information about Deleted shapes" -} - -# check that none of the e1 and e2 have been Modified -if {[string trim [modified rm com_hist e1]] != "The shape has not been modified."} { - puts "Error: Incorrect information about Modified shapes" -} - -if {[string trim [modified rm com_hist e2]] != "The shape has not been modified."} { - puts "Error: Incorrect information about Modified shapes" -} - -# check that none of the e1 and e2 have Generated shapes -if {[string trim [generated rg com_hist e1]] != "No shapes were generated from the shape."} { - puts "Error: Incorrect information about Generated shapes" -} - -if {[string trim [generated rg com_hist e2]] != "No shapes were generated from the shape."} { - puts "Error: Incorrect information about Generated shapes" -} - - -puts "Fuse operation" -bbop rfuse 1 - -# get history of the operation -savehistory fuse_hist - -# check that both e1 and e2 have not been deleted -if {[string trim [isdeleted fuse_hist e1]] != "Not deleted."} { - puts "Error: Incorrect information about Deleted shapes" -} - -if {[string trim [isdeleted fuse_hist e2]] != "Not deleted."} { - puts "Error: Incorrect information about Deleted shapes" -} - -# check that both e1 and e2 have been Modified -modified rm fuse_hist e1 -checknbshapes rm -edge 3 -m "Information about modification of e1" - -modified rm fuse_hist e2 -checknbshapes rm -edge 3 -m "Information about modification of e2" - -# check that both e1 and e2 have Generated vertices -generated rg fuse_hist e1 -checknbshapes rg -vertex 2 -m "Information about shapes Generated from e1" - -generated rg fuse_hist e2 -checknbshapes rg -vertex 2 -m "Information about shapes Generated from e2" - - -puts "CUT operation" -bbop rcut 2 - -# get history of the operation -savehistory cut_hist - -# check that e1 has not been deleted -if {[string trim [isdeleted cut_hist e1]] != "Not deleted."} { - puts "Error: Incorrect information about Deleted shapes" -} - -# check that e2 has been deleted -if {[string trim [isdeleted cut_hist e2]] != "Deleted."} { - puts "Error: Incorrect information about Deleted shapes" -} - -# check that e1 has been modified -modified rm cut_hist e1 -checknbshapes rm -edge 3 -m "Information about modification of e1" - -# check that e2 has not been modified -if {[string trim [modified rm cut_hist e2]] != "The shape has not been modified."} { - puts "Error: Incorrect information about Modified shapes" -} - -# check that both e1 and e2 have Generated vertices -generated rg cut_hist e1 -checknbshapes rg -vertex 2 -m "Information about shapes Generated from e1" - -generated rg cut_hist e2 -checknbshapes rg -vertex 2 -m "Information about shapes Generated from e2" - - -puts "TUC operation" -bbop rtuc 3 - -# get history of the operation -savehistory tuc_hist - -# check that e1 has been deleted -if {[string trim [isdeleted tuc_hist e1]] != "Deleted."} { - puts "Error: Incorrect information about Deleted shapes" -} - -# check that e2 has not been deleted -if {[string trim [isdeleted tuc_hist e2]] != "Not deleted."} { - puts "Error: Incorrect information about Deleted shapes" -} - -# check that e1 has not been modified -if {[string trim [modified rm tuc_hist e1]] != "The shape has not been modified."} { - puts "Error: Incorrect information about Modified shapes" -} - -# check that e2 has been modified -modified rm tuc_hist e2 -checknbshapes rm -edge 3 -m "Information about modification of e1" - - -# check that both e1 and e2 have Generated vertices -generated rg tuc_hist e1 -checknbshapes rg -vertex 2 -m "Information about shapes Generated from e1" - -generated rg tuc_hist e2 -checknbshapes rg -vertex 2 -m "Information about shapes Generated from e2" - - - -puts "SECTION operation" -bbop rsec 4 - -# get history of the operation -savehistory sec_hist - -# check that both e1 and e2 have been deleted -if {[string trim [isdeleted sec_hist e1]] != "Deleted."} { - puts "Error: Incorrect information about Deleted shapes" -} - -if {[string trim [isdeleted sec_hist e2]] != "Deleted."} { - puts "Error: Incorrect information about Deleted shapes" -} - -# check that none of the e1 and e2 have been Modified -if {[string trim [modified rm sec_hist e1]] != "The shape has not been modified."} { - puts "Error: Incorrect information about Modified shapes" -} - -if {[string trim [modified rm sec_hist e2]] != "The shape has not been modified."} { - puts "Error: Incorrect information about Modified shapes" -} - -# check that both e1 and e2 have Generated vertices -generated rg sec_hist e1 -checknbshapes rg -vertex 2 -m "Information about shapes Generated from e1" - -generated rg sec_hist e2 -checknbshapes rg -vertex 2 -m "Information about shapes Generated from e2" diff --git a/tests/boolean/history/A2 b/tests/boolean/history/A2 deleted file mode 100644 index 97880bb5ed..0000000000 --- a/tests/boolean/history/A2 +++ /dev/null @@ -1,178 +0,0 @@ -puts "Check History of Boolean operations" - -puts "Case with intersecting planes (two intersection edges)" - -plane p 0 0 0 0 0 1 -mkface f1 p -10 10 -10 10 - -polyline p -5 0 -5 -5 0 10 5 0 10 5 0 -5 2 0 -5 2 0 5 -2 0 5 -2 0 -5 -5 0 -5 -mkplane f2 p - -bclearobjects -bcleartools -baddobjects f1 -baddtools f2 -bfillds - -puts "Common operation" -bbop rcom 0 - -# get history of the operation -savehistory com_hist - -# check that both f1 and f2 have been deleted -if {[string trim [isdeleted com_hist f1]] != "Deleted."} { - puts "Error: Incorrect information about Deleted shapes" -} - -if {[string trim [isdeleted com_hist f2]] != "Deleted."} { - puts "Error: Incorrect information about Deleted shapes" -} - -# check that none of the f1 and f2 have been Modified -if {[string trim [modified rm com_hist f1]] != "The shape has not been modified."} { - puts "Error: Incorrect information about Modified shapes" -} - -if {[string trim [modified rm com_hist f2]] != "The shape has not been modified."} { - puts "Error: Incorrect information about Modified shapes" -} - -# check that none of the f1 and f2 have Generated shapes -if {[string trim [generated rg com_hist f1]] != "No shapes were generated from the shape."} { - puts "Error: Incorrect information about Generated shapes" -} - -if {[string trim [generated rg com_hist f2]] != "No shapes were generated from the shape."} { - puts "Error: Incorrect information about Generated shapes" -} - - -puts "Fuse operation" -bbop rfuse 1 - -# get history of the operation -savehistory fuse_hist - -# check that both f1 and f2 have not been deleted -if {[string trim [isdeleted fuse_hist f1]] != "Not deleted."} { - puts "Error: Incorrect information about Deleted shapes" -} - -if {[string trim [isdeleted fuse_hist f2]] != "Not deleted."} { - puts "Error: Incorrect information about Deleted shapes" -} - -# check that both f1 and f2 have been Modified -modified rm fuse_hist f1 -checknbshapes rm -face 1 -m "Information about modification of f1" - -modified rm fuse_hist f2 -checknbshapes rm -face 3 -m "Information about modification of f2" - -# check that both f1 and f2 have Generated edges -generated rg fuse_hist f1 -checknbshapes rg -edge 2 -m "Information about shapes Generated from f1" - -generated rg fuse_hist f1 -checknbshapes rg -edge 2 -m "Information about shapes Generated from f2" - - -puts "CUT operation" -bbop rcut 2 - -# get history of the operation -savehistory cut_hist - -# check that f1 has not been deleted -if {[string trim [isdeleted cut_hist f1]] != "Not deleted."} { - puts "Error: Incorrect information about Deleted shapes" -} - -# check that f2 has been deleted -if {[string trim [isdeleted cut_hist f2]] != "Deleted."} { - puts "Error: Incorrect information about Deleted shapes" -} - -# check that f1 has been modified -modified rm cut_hist f1 -checknbshapes rm -face 1 -m "Information about modification of f1" - -# check that f2 has not been modified -if {[string trim [modified rm cut_hist f2]] != "The shape has not been modified."} { - puts "Error: Incorrect information about Modified shapes" -} - -# check that both f1 and f2 have Generated edges -generated rg cut_hist f1 -checknbshapes rg -edge 2 -m "Information about shapes Generated from f1" - -generated rg cut_hist f2 -checknbshapes rg -edge 2 -m "Information about shapes Generated from f2" - - -puts "TUC operation" -bbop rtuc 3 - -# get history of the operation -savehistory tuc_hist - -# check that f1 has been deleted -if {[string trim [isdeleted tuc_hist f1]] != "Deleted."} { - puts "Error: Incorrect information about Deleted shapes" -} - -# check that f2 has not been deleted -if {[string trim [isdeleted tuc_hist f2]] != "Not deleted."} { - puts "Error: Incorrect information about Deleted shapes" -} - -# check that f1 has not been modified -if {[string trim [modified rm tuc_hist f1]] != "The shape has not been modified."} { - puts "Error: Incorrect information about Modified shapes" -} - -# check that f2 has been modified -modified rm tuc_hist f2 -checknbshapes rm -face 3 -m "Information about modification of f1" - - -# check that both f1 and f2 have Generated vertices -generated rg tuc_hist f1 -checknbshapes rg -edge 2 -m "Information about shapes Generated from f1" - -generated rg tuc_hist f2 -checknbshapes rg -edge 2 -m "Information about shapes Generated from f2" - - - -puts "SECTION operation" -bbop rsec 4 - -# get history of the operation -savehistory sec_hist - -# check that both f1 and f2 have been deleted -if {[string trim [isdeleted sec_hist f1]] != "Deleted."} { - puts "Error: Incorrect information about Deleted shapes" -} - -if {[string trim [isdeleted sec_hist f2]] != "Deleted."} { - puts "Error: Incorrect information about Deleted shapes" -} - -# check that none of the f1 and f2 have been Modified -if {[string trim [modified rm sec_hist f1]] != "The shape has not been modified."} { - puts "Error: Incorrect information about Modified shapes" -} - -if {[string trim [modified rm sec_hist f2]] != "The shape has not been modified."} { - puts "Error: Incorrect information about Modified shapes" -} - -# check that both f1 and f2 have Generated vertices -generated rg sec_hist f1 -checknbshapes rg -edge 2 -m "Information about shapes Generated from f1" - -generated rg sec_hist f2 -checknbshapes rg -edge 2 -m "Information about shapes Generated from f2" diff --git a/tests/boolean/history/A3 b/tests/boolean/history/A3 deleted file mode 100644 index 94c1f85518..0000000000 --- a/tests/boolean/history/A3 +++ /dev/null @@ -1,185 +0,0 @@ -puts "Check History of Boolean operations" - -puts "Case with overlapping planar faces" - -plane p 0 0 0 0 0 1 -mkface f1 p -10 10 -10 10 -mkface f2 p 0 20 -10 10 - -bclearobjects -bcleartools -baddobjects f1 -baddtools f2 -bfillds - -puts "Common operation" -bbop rcom 0 - -# get history of the operation -savehistory com_hist - -# check that both f1 and f2 have not been deleted -if {[string trim [isdeleted com_hist f1]] != "Not deleted."} { - puts "Error: Incorrect information about Deleted shapes" -} - -if {[string trim [isdeleted com_hist f2]] != "Not deleted."} { - puts "Error: Incorrect information about Deleted shapes" -} - -# check that both f1 and f2 have been Modified into the same face -modified rm1 com_hist f1 -checknbshapes rm1 -face 1 -m "Information about modification of f1" - -modified rm2 com_hist f2 -checknbshapes rm2 -face 1 -m "Information about modification of f2" - -compound rm1 rm2 cm -checknbshapes cm -face 1 -m "Information about modification of f1 and f2" - - -# check that none of the f1 and f2 have Generated shapes -if {[string trim [generated rg com_hist f1]] != "No shapes were generated from the shape."} { - puts "Error: Incorrect information about Generated shapes" -} - -if {[string trim [generated rg com_hist f2]] != "No shapes were generated from the shape."} { - puts "Error: Incorrect information about Generated shapes" -} - - -puts "Fuse operation" -bbop rfuse 1 - -# get history of the operation -savehistory fuse_hist - -# check that both f1 and f2 have not been deleted -if {[string trim [isdeleted fuse_hist f1]] != "Not deleted."} { - puts "Error: Incorrect information about Deleted shapes" -} - -if {[string trim [isdeleted fuse_hist f2]] != "Not deleted."} { - puts "Error: Incorrect information about Deleted shapes" -} - -# check that both f1 and f2 have been Modified -modified rm fuse_hist f1 -checknbshapes rm -face 2 -m "Information about modification of f1" - -modified rm fuse_hist f2 -checknbshapes rm -face 2 -m "Information about modification of f2" - -# check that none of the f1 and f2 have Generated shapes -if {[string trim [generated rg fuse_hist f1]] != "No shapes were generated from the shape."} { - puts "Error: Incorrect information about Generated shapes" -} - -if {[string trim [generated rg fuse_hist f2]] != "No shapes were generated from the shape."} { - puts "Error: Incorrect information about Generated shapes" -} - - -puts "CUT operation" -bbop rcut 2 - -# get history of the operation -savehistory cut_hist - -# check that f1 has not been deleted -if {[string trim [isdeleted cut_hist f1]] != "Not deleted."} { - puts "Error: Incorrect information about Deleted shapes" -} - -# check that f2 has been deleted -if {[string trim [isdeleted cut_hist f2]] != "Deleted."} { - puts "Error: Incorrect information about Deleted shapes" -} - -# check that f1 has been modified -modified rm cut_hist f1 -checknbshapes rm -face 1 -m "Information about modification of f1" - -# check that f2 has not been modified -if {[string trim [modified rm cut_hist f2]] != "The shape has not been modified."} { - puts "Error: Incorrect information about Modified shapes" -} - -# check that none of the f1 and f2 have Generated shapes -if {[string trim [generated rg cut_hist f1]] != "No shapes were generated from the shape."} { - puts "Error: Incorrect information about Generated shapes" -} - -if {[string trim [generated rg cut_hist f2]] != "No shapes were generated from the shape."} { - puts "Error: Incorrect information about Generated shapes" -} - - -puts "TUC operation" -bbop rtuc 3 - -# get history of the operation -savehistory tuc_hist - -# check that f1 has been deleted -if {[string trim [isdeleted tuc_hist f1]] != "Deleted."} { - puts "Error: Incorrect information about Deleted shapes" -} - -# check that f2 has not been deleted -if {[string trim [isdeleted tuc_hist f2]] != "Not deleted."} { - puts "Error: Incorrect information about Deleted shapes" -} - -# check that f1 has not been modified -if {[string trim [modified rm tuc_hist f1]] != "The shape has not been modified."} { - puts "Error: Incorrect information about Modified shapes" -} - -# check that f2 has been modified -modified rm tuc_hist f2 -checknbshapes rm -face 1 -m "Information about modification of f1" - -# check that none of the f1 and f2 have Generated shapes -if {[string trim [generated rg tuc_hist f1]] != "No shapes were generated from the shape."} { - puts "Error: Incorrect information about Generated shapes" -} - -if {[string trim [generated rg tuc_hist f2]] != "No shapes were generated from the shape."} { - puts "Error: Incorrect information about Generated shapes" -} - - - -puts "SECTION operation" -bbop rsec 4 - -# get history of the operation -savehistory sec_hist - -# check that both f1 and f2 have been deleted -if {[string trim [isdeleted sec_hist f1]] != "Deleted."} { - puts "Error: Incorrect information about Deleted shapes" -} - -if {[string trim [isdeleted sec_hist f2]] != "Deleted."} { - puts "Error: Incorrect information about Deleted shapes" -} - -# check that none of the f1 and f2 have been Modified -if {[string trim [modified rm sec_hist f1]] != "The shape has not been modified."} { - puts "Error: Incorrect information about Modified shapes" -} - -if {[string trim [modified rm sec_hist f2]] != "The shape has not been modified."} { - puts "Error: Incorrect information about Modified shapes" -} - -# check that none of the f1 and f2 have Generated shapes -if {[string trim [generated rg sec_hist f1]] != "No shapes were generated from the shape."} { - puts "Error: Incorrect information about Generated shapes" -} - -if {[string trim [generated rg sec_hist f2]] != "No shapes were generated from the shape."} { - puts "Error: Incorrect information about Generated shapes" -} diff --git a/tests/boolean/history/A4 b/tests/boolean/history/A4 deleted file mode 100644 index 81d950405b..0000000000 --- a/tests/boolean/history/A4 +++ /dev/null @@ -1,40 +0,0 @@ -puts "Check History of General Fuse" - -puts "Case with an edge intersecting a face" - -polyline fw 0 0 0 10 0 0 10 10 0 0 10 0 0 0 0 -mkplane fs fw - -vertex ev1 5 5 5 -vertex ev2 5 5 -5 -edge es ev1 ev2 - -bclearobjects -bcleartools -baddobjects fs -baddtools es -bfillds -bbuild r - -# get history of the operation -savehistory gf_hist - -modified fs_m gf_hist fs -checknbshapes fs_m -face 1 -m "Information about Modification of fs" - -modified es_m gf_hist es -checknbshapes es_m -edge 2 -m "Information about Modification of es" - -generated fs_g gf_hist fs -checknbshapes fs_g -vertex 1 -m "Information about shapes Generated from fs" - -generated es_g gf_hist es -checknbshapes es_g -vertex 1 -m "Information about shapes Generated from es" - - -# In General Fuse operation there should be no Deleted elements -foreach s [join [list es fs [explode es v] [explode fs e] [explode fs v]]] { - if {[string trim [isdeleted gf_hist $s]] != "Not deleted."} { - puts "Error: Incorrect information about Deleted shapes" - } -} diff --git a/tests/boolean/history/A5 b/tests/boolean/history/A5 deleted file mode 100644 index d92fc0e4d3..0000000000 --- a/tests/boolean/history/A5 +++ /dev/null @@ -1,185 +0,0 @@ -puts "Check History of Cells Builder" - -puts "Case with overlapping planar faces" - -circle c1 0 0 0 10 -circle c2 10 0 0 10 -circle c3 10 10 0 10 - -mkedge e1 c1 -mkedge e2 c2 -mkedge e3 c3 - -wire w1 e1 -wire w2 e2 -wire w3 e3 - -mkplane f1 w1 -mkplane f2 w2 -mkplane f3 w3 - -bclearobjects -bcleartools -baddobjects f1 f2 f3 -bfillds - -bcbuild rx - -bcremoveall - -# no history at this point - -# add to result all parts of f1 with material 1 -bcadd result f1 1 -m 1 - -# get history of the operation -savehistory cells_hist - -# check modification of f1 -modified rm1 cells_hist f1 -checknbshapes rm1 -face 4 -m "Information about modification of f1" - -# check modification of f2 -modified rm2 cells_hist f2 -checknbshapes rm2 -face 2 -m "Information about modification of f2" - -# check modification of f3 -modified rm3 cells_hist f3 -checknbshapes rm3 -face 2 -m "Information about modification of f3" - -# make one face from result -bcremoveint result - -# update cells history -savehistory cells_hist - -# check modification of f1 -modified rm1u cells_hist f1 -checknbshapes rm1u -face 1 -m "Information about modification of f1" - -# check modification of f2 -modified rm2u cells_hist f2 -checknbshapes rm2u -face 1 -m "Information about modification of f2" - -# check modification of f3 -modified rm3u cells_hist f3 -checknbshapes rm3u -face 1 -m "Information about modification of f3" - -compound rm1u rm2u rm3u cfu -checknbshapes cfu -face 1 -m "Information about modification of f1, f2 and f3" - - -bcremoveall -# no history at this point - -# add to result all parts of f1 and f2 not contained in f3 with material 1 -bcadd result f1 1 f3 0 -m 1 -bcadd result f2 1 f3 0 -m 1 - -# update cells history -savehistory cells_hist - -# check modification of f1 -modified rm1 cells_hist f1 -checknbshapes rm1 -face 2 -m "Information about modification of f1" - -# check modification of f2 -modified rm2 cells_hist f2 -checknbshapes rm2 -face 2 -m "Information about modification of f2" - -# check modification of f3 -if {[string trim [modified rm3 cells_hist f3]] != "The shape has not been modified."} { - puts "Error: Incorrect information about Modification of f3" -} - -# check deletion of f1 -if {[string trim [isdeleted cells_hist f1]] != "Not deleted."} { - puts "Error: Incorrect information about Deletion of f1" -} - -# check deletion of f2 -if {[string trim [isdeleted cells_hist f2]] != "Not deleted."} { - puts "Error: Incorrect information about Deletion of f2" -} - -# check deletion of f3 -if {[string trim [isdeleted cells_hist f3]] != "Deleted."} { - puts "Error: Incorrect information about Deletion of f3" -} - -# make one face from result -bcremoveint result - -# update cells history -savehistory cells_hist - -# check modification of f1 -modified rm1 cells_hist f1 -checknbshapes rm1 -face 1 -m "Information about modification of f1" - -# check modification of f2 -modified rm2 cells_hist f2 -checknbshapes rm2 -face 1 -m "Information about modification of f2" - -# check modification of f3 -if {[string trim [modified rm3 cells_hist f3]] != "The shape has not been modified."} { - puts "Error: Incorrect information about Modification of f3" -} - -# check deletion of f1 -if {[string trim [isdeleted cells_hist f1]] != "Not deleted."} { - puts "Error: Incorrect information about Deletion of f1" -} - -# check deletion of f2 -if {[string trim [isdeleted cells_hist f2]] != "Not deleted."} { - puts "Error: Incorrect information about Deletion of f2" -} - -# check deletion of f3 -if {[string trim [isdeleted cells_hist f3]] != "Deleted."} { - puts "Error: Incorrect information about Deletion of f3" -} - - -bcremoveall - -# add to result parts of f1 with material 1, and all other parts with material 2 -bcadd result f1 1 -m 1 -bcadd result f2 1 f1 0 -m 2 -bcadd result f3 1 f1 0 -m 2 - -# update cells history -savehistory cells_hist - -# at this point all splits of faces are contained in the result -# check modification of f1 -modified rm1 cells_hist f1 -checknbshapes rm1 -face 4 -m "Information about modification of f1" - -# check modification of f2 -modified rm2 cells_hist f2 -checknbshapes rm2 -face 4 -m "Information about modification of f2" - -# check modification of f3 -modified rm3 cells_hist f3 -checknbshapes rm3 -face 4 -m "Information about modification of f3" - -# unify faces with same material -bcremoveint result - -# update cells history -savehistory cells_hist - -# check modification of f1 -modified rm1u cells_hist f1 -checknbshapes rm1u -face 1 -m "Information about modification of f1" - -# check modification of f2 -modified rm2u cells_hist f2 -checknbshapes rm2u -face 2 -m "Information about modification of f2" - -# check modification of f3 -modified rm3u cells_hist f3 -checknbshapes rm3u -face 2 -m "Information about modification of f3" - diff --git a/tests/boolean/history/A6 b/tests/boolean/history/A6 deleted file mode 100644 index 2d46c5074b..0000000000 --- a/tests/boolean/history/A6 +++ /dev/null @@ -1,194 +0,0 @@ -puts "Check History of Cells Builder" - -puts "Case with three boxes" - -box b1 10 10 10 -box b2 5 0 0 10 10 10 -box b3 2.5 0 5 10 10 10 - -bclearobjects -bcleartools -baddobjects b1 b2 b3 -bfillds - -bcbuild rx - -bcremoveall -# no history at this point - -# add all parts into result -bcaddall result - -# get history -savehistory cells_hist - -# find all section edges using Generated history information -compound ge -foreach s {b1 b2 b3} { - foreach f [explode $s f] { - if {[string trim [generated g cells_hist $f]] == ""} { - add g ge - } - } -} - -checknbshapes ge -edge 4 -m "Information about Generated shapes" - - -bcremoveall -# no history at this point - -# add to result all parts of b1 with material 1 -bcadd result b1 1 -m 1 - -# update history -savehistory cells_hist - -# check modification of b1 -modified rm1 cells_hist b1 -checknbshapes rm1 -solid 4 -m "Information about modification of b1" - -# check modification of b2 -modified rm2 cells_hist b2 -checknbshapes rm2 -solid 2 -m "Information about modification of b2" - -# check modification of b3 -modified rm3 cells_hist b3 -checknbshapes rm3 -solid 2 -m "Information about modification of b3" - -# make one face from result -bcremoveint result - -# update history -savehistory cells_hist - -# check modification of b1 -modified rm1u cells_hist b1 -checknbshapes rm1u -solid 1 -m "Information about modification of b1" - -# check modification of b2 -modified rm2u cells_hist b2 -checknbshapes rm2u -solid 1 -m "Information about modification of b2" - -# check modification of b3 -modified rm3u cells_hist b3 -checknbshapes rm3u -solid 1 -m "Information about modification of b3" - -compound rm1u rm2u rm3u cfu -checknbshapes cfu -solid 1 -m "Information about modification of b1, b2 and b3" - - -bcremoveall -# no history at this point - -# add to result all parts of b1 and b2 not contained in b3 with material 1 -bcadd result b1 1 b3 0 -m 1 -bcadd result b2 1 b3 0 -m 1 - -# update history -savehistory cells_hist - -# check modification of b1 -modified rm1 cells_hist b1 -checknbshapes rm1 -solid 2 -m "Information about modification of b1" - -# check modification of b2 -modified rm2 cells_hist b2 -checknbshapes rm2 -solid 2 -m "Information about modification of b2" - -# check modification of b3 -if {[string trim [modified rm3 cells_hist b3]] != "The shape has not been modified."} { - puts "Error: Incorrect information about Modification of b3" -} - -# check deletion of b1 -if {[string trim [isdeleted cells_hist b1]] != "Not deleted."} { - puts "Error: Incorrect information about Deletion of b1" -} - -# check deletion of b2 -if {[string trim [isdeleted cells_hist b2]] != "Not deleted."} { - puts "Error: Incorrect information about Deletion of b2" -} - -# check deletion of b3 -if {[string trim [isdeleted cells_hist b3]] != "Deleted."} { - puts "Error: Incorrect information about Deletion of b3" -} - -# make one face from result -bcremoveint result - -# update history -savehistory cells_hist - -# check modification of b1 -modified rm1 cells_hist b1 -checknbshapes rm1 -solid 1 -m "Information about modification of b1" - -# check modification of b2 -modified rm2 cells_hist b2 -checknbshapes rm2 -solid 1 -m "Information about modification of b2" - -# check modification of b3 -if {[string trim [modified rm3 cells_hist b3]] != "The shape has not been modified."} { - puts "Error: Incorrect information about Modification of b3" -} - -# check deletion of b1 -if {[string trim [isdeleted cells_hist b1]] != "Not deleted."} { - puts "Error: Incorrect information about Deletion of b1" -} - -# check deletion of b2 -if {[string trim [isdeleted cells_hist b2]] != "Not deleted."} { - puts "Error: Incorrect information about Deletion of b2" -} - -# check deletion of b3 -if {[string trim [isdeleted cells_hist b3]] != "Deleted."} { - puts "Error: Incorrect information about Deletion of b3" -} - - -bcremoveall - -# add to result parts of b1 with material 1, and all other parts with material 2 -bcadd result b1 1 -m 1 -bcadd result b2 1 b1 0 -m 2 -bcadd result b3 1 b1 0 -m 2 - -# update history -savehistory cells_hist - -# at this point all splits of faces are contained in the result -# check modification of b1 -modified rm1 cells_hist b1 -checknbshapes rm1 -solid 4 -m "Information about modification of b1" - -# check modification of b2 -modified rm2 cells_hist b2 -checknbshapes rm2 -solid 4 -m "Information about modification of b2" - -# check modification of b3 -modified rm3 cells_hist b3 -checknbshapes rm3 -solid 4 -m "Information about modification of b3" - -# unify faces with same material -bcremoveint result - -# update history -savehistory cells_hist - -# check modification of b1 -modified rm1u cells_hist b1 -checknbshapes rm1u -solid 1 -m "Information about modification of b1" - -# check modification of b2 -modified rm2u cells_hist b2 -checknbshapes rm2u -solid 2 -m "Information about modification of b2" - -# check modification of b3 -modified rm3u cells_hist b3 -checknbshapes rm3u -solid 2 -m "Information about modification of b3" - diff --git a/tests/boolean/history/A8 b/tests/boolean/history/A8 deleted file mode 100644 index f8d6b36cdc..0000000000 --- a/tests/boolean/history/A8 +++ /dev/null @@ -1,51 +0,0 @@ -box b1 10 10 10 -box b2 5 0 0 10 10 10 - -# fuse boxes -bfuse r b1 b2 - -# save Fuse history -savehistory fuse_hist - -# simplify result -unifysamedom ru r - -# save USD history -savehistory usd_hist - - -# check modifications of the faces of the boxes in two histories -explode b1 f -explode b2 f - -foreach i {3 4 5 6} { - if {[regexp "The shape has not been modified." [modified m1 fuse_hist b1_$i]]} { - puts "Error: Incorrect history of Fuse"; - continue; - } - checknbshapes m1 -face 2 - - if {[regexp "The shape has not been modified." [modified m2 fuse_hist b2_$i]]} { - puts "Error: Incorrect history of Fuse"; - continue; - } - checknbshapes m2 -face 2 - - # each face of the m1 and m2 should have been modified into the same face during USD - - compound usd_face - - foreach f [join [list [explode m1 f] [explode m2 f] ] ] { - if {[regexp "The shape has not been modified." [modified u usd_hist $f]]} { - puts "Error: Incorrect history of USD"; - continue; - } - checknbshapes u -vertex 4 -edge 4 -wire 1 -face 1 - checkprops u -s 150 - add u usd_face - } - - checknbshapes usd_face -face 1 - checkprops u -s 150 -skip - -} diff --git a/tests/boolean/history/A9 b/tests/boolean/history/A9 deleted file mode 100644 index 95afd2fa91..0000000000 --- a/tests/boolean/history/A9 +++ /dev/null @@ -1,41 +0,0 @@ -# History of section operation - -# extract faces of the box, enlarge them and intersect -box b 10 10 10 - -compound faces - -foreach f [explode b f] { - mksurface s $f - mkface fn s -100 100 -100 100 - add fn faces -} - -# perform intersection -bclearobjects -bcleartools -baddcompound faces -bfillds -# enable history collection -setfillhistory 1 -bbop result 4 - -savehistory history - -# check that all faces have been deleted, have not been modified -# and each face has generated edges - -foreach f [explode faces] { - if {![regexp "Deleted" [isdeleted history $f]]} { - puts "Error: Incorrect information about deleted shapes" - } - - if {![regexp "The shape has not been modified" [modified modif history $f]]} { - puts "Error: Incorrect information about modified shapes" - } - - if {[regexp "No shapes were generated from the shape" [generated gen history $f]]} { - puts "Error: Incorrect information about generated shapes" - } - checknbshapes gen -edge 12 -} diff --git a/tests/boolean/mkconnected/A1 b/tests/boolean/mkconnected/A1 deleted file mode 100644 index 023133d645..0000000000 --- a/tests/boolean/mkconnected/A1 +++ /dev/null @@ -1,61 +0,0 @@ -polyline p 0 0 0 10 0 0 10 0 10 5 0 10 5 0 5 0 0 5 0 0 0 -mkplane f p -prism b1 f 0 5 0 -box b2 0 0 5 5 5 5 -box b3 0 5 0 10 5 10 - -# make the shapes connected -makeconnected c b3 b1 b2 - -checkshape c -checknbshapes c -vertex 18 -edge 31 -wire 17 -face 17 -shell 3 -solid 3 -t -checkprops c -s 900 -v 1000 - -savehistory h - -modified m3 h b3 -checknbshapes m3 -face 7 -t - -# make the shape periodic -cmakeperiodic cp -x 10 -y 10 -z 10 -checknbshapes cp -vertex 26 -edge 42 -wire 20 -face 20 -shell 3 -solid 3 -t - -savehistory h - -modified m1 h b1 -checknbshapes m1 -face 10 -t - -modified m2 h b2 -checknbshapes m2 -ref [nbshapes b2] -t - -modified m3 h b3 -checknbshapes m3 -face 8 -t - - -# check material associations -explode b3 f - -# the face b3_3 is REVERSED -# materials on negative side should be only b3 -# materials on positive side should be b1 and b2 - -modified mf h b3_3 - -compound pos -compound neg - -foreach f [explode mf f] { - if {![regexp "No materials on this side" [cmaterialson p + $f]]} { - add p pos - } - if {![regexp "No materials on this side" [cmaterialson n - $f]]} { - add n neg - } -} - -# check that neg contains b3 only -checkprops neg -equal b3 -skip - -# check that pos contains both -compound b1 b2 comp -checkprops pos -equal comp -skip diff --git a/tests/boolean/mkconnected/A2 b/tests/boolean/mkconnected/A2 deleted file mode 100644 index 3e53724dad..0000000000 --- a/tests/boolean/mkconnected/A2 +++ /dev/null @@ -1,90 +0,0 @@ -box b1 10 10 5 -box b2 0 0 5 10 10 1 -box b3 0 0 6 3 3 4 -polyline p 3 0 6 3 3 6 0 3 6 0 4 6 4 4 6 4 0 6 3 0 6 -mkplane f p -prism b4 f 0 0 4 -box b5 0 9 6 4 1 4 -box b6 9 9 6 1 1 4 -box b7 9 0 6 1 3 4 - -# make the solids connected -makeconnected c b1 b2 b3 b4 b5 b6 b7 - -checkshape c -checknbshapes c -vertex 46 -edge 79 -wire 41 -face 41 -shell 7 -solid 7 -t -checkprops c -s 888 -v 696 - -savehistory h - -explode b6 f -modified f h b6_4 - -cmaterialson pos + f -if {![regexp "equal shapes" [compare pos b6]]} { - puts "Error: incorrect material associations" -} - -if {![regexp "No materials on this side." [cmaterialson neg - f]]} { - puts "Error: incorrect material associations" -} - -# make the connected shape periodic -cmakeperiodic cp -x 10 -y 10 -checkshape cp -checknbshapes cp -vertex 49 -edge 83 -wire 42 -face 42 -shell 7 -solid 7 -t -checkprops cp -s 888 -v 696 - -# get modifications of the fifth solid -savehistory h - -modified m5 h b5 -checknbshapes m5 -vertex 10 -edge 15 -wire 7 -face 7 -shell 1 -solid 1 -t -checkprops m5 -s 48 -v 16 - - -# repeat shape -crepeatshape res1 -x -1 -y -1 -x 1 -y 1 - -checknbshapes res1 -vertex 496 -edge 947 -wire 564 -face 564 -shell 112 -solid 112 -t -checkprops res1 -s 14208 -v 11136 - - -savehistory h -modified f h b6_4 - -cmaterialson pos + f -cmaterialson neg - f - -if {![regexp "equal shapes" [compare pos b6]]} { - puts "Error: incorrect material associations" -} - -if {![regexp "equal shapes" [compare neg b7]]} { - puts "Error: incorrect material associations" -} - - -# make the connected shape periodic with period grater than the unit cell -cmakeperiodic cp -x 12 -trim -1 -y 12 -trim -1 - -checknbshapes cp -ref [nbshapes c] -t -checkprops cp -equal c - -crepeatshape res2 -x -1 -y -1 -x 1 -y 1 - -checknbshapes res2 -vertex 736 -edge 1264 -wire 656 -face 656 -shell 112 -solid 112 -t -checkprops res2 -s 14208 -v 11136 - -savehistory h - -modified f h b6_4 - -cmaterialson pos + f -if {![regexp "equal shapes" [compare pos b6]]} { - puts "Error: incorrect material associations" -} - -if {![regexp "No materials on this side." [cmaterialson neg - f]]} { - puts "Error: incorrect material associations" -} diff --git a/tests/boolean/mkconnected/A5 b/tests/boolean/mkconnected/A5 deleted file mode 100644 index ab9abb2c5a..0000000000 --- a/tests/boolean/mkconnected/A5 +++ /dev/null @@ -1,63 +0,0 @@ -box b1 5 5 10 -box b2 5 0 0 5 5 5 -box b3 0 5 0 5 5 5 - -makeconnected r b1 b2 b3 -checknbshapes r -wire 18 -face 18 -shell 3 -solid 3 -t - -cmakeperiodic rp -x 10 -y 10 -checknbshapes rp -wire 20 -face 20 -shell 3 -solid 3 -t - -savehistory h - -explode b2 f -modified m2 h b2_2 -cperiodictwins m2_twin m2 - -cmaterialson m2_pos + m2 -cmaterialson m2_neg - m2_twin - -if {![regexp "same shapes" [compare m2_pos b2]]} { - puts "Error: incorrect material associations" -} - -if {![regexp "same shapes" [compare m2_neg b1]]} { - puts "Error: incorrect material associations" -} - - -crepeatshape r -x 1 -y 1 -checknbshapes r -wire 76 -face 76 -shell 12 -solid 12 -t - -savehistory h -generated g2 h b2_2 -checknbshapes g2 -face 4 -t - -cclearrepetitions r -checknbshapes r -wire 20 -face 20 -shell 3 -solid 3 -t - -savehistory h - -modified m2 h b2_2 -cperiodictwins m2_twin m2 - -cmaterialson m2_pos + m2 -cmaterialson m2_neg - m2_twin - -if {![regexp "same shapes" [compare m2_pos b2]]} { - puts "Error: incorrect material associations" -} - -if {![regexp "same shapes" [compare m2_neg b1]]} { - puts "Error: incorrect material associations" -} - -crepeatshape r -y 1 -checknbshapes r -wire 39 -face 39 -shell 6 -solid 6 -t - -savehistory h - -modified m2 h b2_2 -cperiodictwins m2_twin m2 - -checknbshapes m2_twin -face 3 -t diff --git a/tests/boolean/opensolid/A1 b/tests/boolean/opensolid/A1 deleted file mode 100644 index 95dda57b87..0000000000 --- a/tests/boolean/opensolid/A1 +++ /dev/null @@ -1,41 +0,0 @@ -puts "REQUIRED All: Faulty shapes in variables faulty_1 to faulty_2" - -box b1 10 10 10 -box b2 5 0 0 10 10 10 - -shape s1 So -shape s2 So -shape sh1 Sh -shape sh2 Sh - -foreach f [lrange [explode b1 f] 0 4] { add $f sh1 } -foreach f [lrange [explode b2 f] 0 4] { add $f sh2 } - -add sh1 s1 -add sh2 s2 - -bclearobjects -bcleartools -baddobjects s1 -baddtools s2 -bfillds - -bbop r0 0 -bbop r1 1 -bbop r2 2 -bbop r3 3 - -foreach r {r0 r1 r2 r3} { - checkshape $r - if {![regexp "OK" [bopcheck $r]]} { - puts "Error: shape is self-interfered" - } -} - -checknbshapes r1 -vertex 16 -edge 26 -wire 11 -face 11 -shell 1 -solid 1 -checkprops r1 -s 650 - -foreach r {r0 r2 r3} { - checknbshapes $r -vertex 8 -edge 12 -wire 5 -face 5 -shell 1 -solid 1 - checkprops $r -s 350 -} diff --git a/tests/boolean/opensolid/A2 b/tests/boolean/opensolid/A2 deleted file mode 100644 index 18d86f0a3b..0000000000 --- a/tests/boolean/opensolid/A2 +++ /dev/null @@ -1,45 +0,0 @@ -puts "REQUIRED All: Faulty shapes in variables faulty_1 to faulty_2" - -box b1 10 10 10 -box b2 2.5 0 0 5 10 5 - -shape s1 So -shape s2 So -shape sh1 Sh -shape sh2 Sh - -foreach f [lrange [explode b1 f] 0 4] { add $f sh1 } -foreach f [lrange [explode b2 f] 0 4] { add $f sh2 } - -add sh1 s1 -add sh2 s2 - -bclearobjects -bcleartools -baddobjects s1 -baddtools s2 -bfillds - -bbop r0 0 -bbop r1 1 -bbop r2 2 -bbop r3 3 - -foreach r {r0 r1 r2 r3} { - checkshape $r - if {![regexp "OK" [bopcheck $r]]} { - puts "Error: shape is self-interfered" - } -} - -checknbshapes r0 -vertex 8 -edge 12 -wire 5 -face 5 -shell 1 -solid 1 -checkprops r0 -s 200 - -checknbshapes r1 -vertex 16 -edge 24 -wire 9 -face 9 -shell 1 -solid 1 -checkprops r1 -s 500 - -checknbshapes r2 -vertex 16 -edge 24 -wire 8 -face 8 -shell 1 -solid 1 -checkprops r2 -s 500 - -checknbshapes r3 -vertex 0 -edge 0 -wire 0 -face 0 -shell 0 -solid 0 -checkprops r3 -s empty diff --git a/tests/boolean/opensolid/A3 b/tests/boolean/opensolid/A3 deleted file mode 100644 index db57478dbd..0000000000 --- a/tests/boolean/opensolid/A3 +++ /dev/null @@ -1,44 +0,0 @@ -puts "REQUIRED All: Faulty shapes in variables faulty_1 to faulty_2" - -box b1 -15 0 0 20 5 5 -box b2 5 5 20 - -shape s1 So -shape s2 So -shape sh1 Sh -shape sh2 Sh - -foreach f [lrange [explode b1 f] 1 5] { add $f sh1 } -foreach f [lrange [explode b2 f] 0 4] { add $f sh2 } - -add sh1 s1 -add sh2 s2 - -bclearobjects -bcleartools -baddobjects s1 -baddtools s2 -bfillds - -bbop r0 0 -bbop r1 1 -bbop r2 2 -bbop r3 3 - -foreach r {r0 r1 r2 r3} { - checkshape $r - if {![regexp "OK" [bopcheck $r]]} { - puts "Error: shape is self-interfered" - } -} - -checknbshapes r0 -vertex 8 -edge 12 -wire 6 -face 6 -shell 1 -solid 1 -checkprops r0 -s 150 - -checknbshapes r1 -vertex 16 -edge 28 -wire 12 -face 12 -shell 1 -solid 1 -checkprops r1 -s 700 - -foreach r {r2 r3} { - checknbshapes $r -vertex 8 -edge 12 -wire 5 -face 5 -shell 1 -solid 1 - checkprops $r -s 325 -} diff --git a/tests/boolean/opensolid/A4 b/tests/boolean/opensolid/A4 deleted file mode 100644 index 66721efa43..0000000000 --- a/tests/boolean/opensolid/A4 +++ /dev/null @@ -1,60 +0,0 @@ -box b1 40 10 10 -box b2 0 0 30 40 10 10 -box b3 10 10 40 -box b4 30 0 0 10 10 40 - -bclearobjects -bcleartools -baddobjects b1 b2 b3 b4 -bfillds -bbuild r - -# fuse of all -buildbop r1 -o b1 b2 b3 b4 -op fuse -buildbop r2 -o b1 b2 b3 -t b4 -op fuse -buildbop r3 -o b1 b2 -t b3 b4 -op fuse -buildbop r4 -o b1 -t b2 b3 b4 -op fuse -buildbop r5 -t b1 b2 b3 b4 -op fuse - -foreach r {r1 r2 r3 r4 r5} { - checkshape $r - checknbshapes $r -vertex 32 -edge 64 -wire 32 -face 32 -shell 1 -solid 1 - checkprops $r -s 4800 -v 12000 -} - -# Cut -buildbop r1 -o b1 b2 -t b3 b4 -op cut -buildbop r2 -o b1 b2 -t b3 b4 -op tuc - -foreach r {r1 r2} { - checkshape $r - checknbshapes $r -vertex 16 -edge 24 -wire 12 -face 12 -shell 2 -solid 2 - checkprops $r -s 2000 -v 4000 -} - -buildbop r1 -o b1 -t b3 b4 -op cut -buildbop r2 -o b2 -t b3 b4 -op cut - -foreach r {r1 r2} { - checkshape $r - checknbshapes $r -vertex 8 -edge 12 -wire 6 -face 6 -shell 1 -solid 1 - checkprops $r -s 1000 -v 2000 -} - -# Common -buildbop r1 -o b1 b2 -t b3 b4 -op common -checkshape r1 -checknbshapes r1 -vertex 32 -edge 48 -wire 24 -face 24 -shell 4 -solid 4 -checkprops r1 -s 2400 -v 4000 - -buildbop r1 -o b1 -t b3 b4 -op common -buildbop r2 -o b2 -t b3 b4 -op common - -checkshape r1 -checkshape r2 - -foreach r {r1 r2} { - checkshape $r - checknbshapes $r -vertex 16 -edge 24 -wire 12 -face 12 -shell 2 -solid 2 - checkprops $r -s 1200 -v 2000 -} diff --git a/tests/boolean/opensolid/A5 b/tests/boolean/opensolid/A5 deleted file mode 100644 index 721baf5a58..0000000000 --- a/tests/boolean/opensolid/A5 +++ /dev/null @@ -1,32 +0,0 @@ -box b1 10 2 2 -box b2 2 0.5 -3 1 1 8 -box b3 7 0.5 -3 1 1 8 -invert b3 - -bclearobjects -bcleartools -baddobjects b1 -baddtools b2 b3 -bfillds -bbuild r - -buildbop r0 -o b1 -t b2 b3 -op common -buildbop r1 -o b1 -t b2 b3 -op fuse -buildbop r2 -o b1 -t b2 b3 -op cut -buildbop r3 -o b1 -t b2 b3 -op tuc - -checkshape r0 -checkprops r0 -s 110 -v 38 -checknbshapes r0 -vertex 24 -edge 36 -wire 20 -face 16 -shell 2 -solid 2 - -checkshape r1 -checkprops r1 -s 28 -v -6 -checknbshapes r1 -vertex 16 -edge 24 -wire 12 -face 12 -shell 2 -solid 2 - -checkshape r2 -checkprops r2 -s 10 -v 2 -checknbshapes r2 -vertex 8 -edge 12 -wire 6 -face 6 -shell 1 -solid 1 - -checkshape r3 -checkprops r3 -s 164 -v -46 -checknbshapes r3 -vertex 40 -edge 60 -wire 32 -face 28 -shell 3 -solid 3 diff --git a/tests/boolean/opensolid/A6 b/tests/boolean/opensolid/A6 deleted file mode 100644 index 9bd8d89846..0000000000 --- a/tests/boolean/opensolid/A6 +++ /dev/null @@ -1,34 +0,0 @@ -box b1 10 2 2 -box b2 5 0 0 5 5 5 -box b3 6 0 0 1 1 1 - -bclearobjects -bcleartools -baddobjects b1 -baddtools b2 b3 -bfillds -bbuild r - -buildbop r0 -o b1 -t b2 b3 -op common -buildbop r1 -o b1 -t b2 b3 -op fuse -buildbop r2 -o b1 -t b2 b3 -op cut -buildbop r3 -o b1 -t b2 b3 -op tuc - -foreach r {r0 r1 r2 r3} { - checkshape $r - if {![regexp "OK" [bopcheck $r]]} { - puts "Error: shape is self-interfered" - } -} - -checkprops r0 -s 56 -v 20 -checknbshapes r0 -vertex 16 -edge 25 -wire 12 -face 12 -shell 2 -solid 2 - -checkprops r1 -s 190 -v 145 -checknbshapes r1 -vertex 24 -edge 38 -wire 16 -face 16 -shell 1 -solid 1 - -checkprops r2 -s 48 -v 20 -checknbshapes r2 -vertex 8 -edge 12 -wire 6 -face 6 -shell 1 -solid 1 - -checkprops r3 -s 142 -v 105 -checknbshapes r3 -vertex 12 -edge 18 -wire 8 -face 8 -shell 1 -solid 1 diff --git a/tests/boolean/opensolid/A7 b/tests/boolean/opensolid/A7 deleted file mode 100644 index 860026d762..0000000000 --- a/tests/boolean/opensolid/A7 +++ /dev/null @@ -1,59 +0,0 @@ -box b1 10 10 10 -box b2 1 1 1 8 8 8 -box b3 -2 3 3 14 4 4 - -bclearobjects -bcleartools -baddobjects b1 b2 b3 -bfillds -bbuild r - -buildbop r0 -o b3 -t b1 b2 -op common -buildbop r1 -o b3 -t b1 b2 -op fuse -buildbop r2 -o b3 -t b1 b2 -op cut -buildbop r3 -o b3 -t b1 b2 -op tuc - -foreach r {r0 r1 r2 r3} { - checkshape $r - if {![regexp "OK" [bopcheck $r]]} { - puts "Error: shape is self-interfered" - } -} - -checkprops r0 -s 256 -v 160 -checknbshapes r0 -vertex 16 -edge 28 -wire 16 -face 16 -shell 3 -solid 3 - -checkprops r1 -s 664 -v 1064 -checknbshapes r1 -vertex 24 -edge 36 -wire 18 -face 16 -shell 1 -solid 1 - -checkprops r2 -s 128 -v 64 -checknbshapes r2 -vertex 16 -edge 24 -wire 12 -face 12 -shell 2 -solid 2 - -checkprops r3 -s 1432 -v 840 -checknbshapes r3 -vertex 32 -edge 52 -wire 28 -face 24 -shell 2 -solid 2 - - - -buildbop r0 -o b2 -t b1 b3 -op common -buildbop r1 -o b2 -t b1 b3 -op fuse -buildbop r2 -o b2 -t b1 b3 -op cut -buildbop r3 -o b2 -t b1 b3 -op tuc - -foreach r {r0 r1 r2 r3} { - checkshape $r - if {![regexp "OK" [bopcheck $r]]} { - puts "Error: shape is self-interfered" - } -} - -checkprops r0 -s 640 -v 512 -checknbshapes r0 -vertex 16 -edge 24 -wire 14 -face 12 -shell 2 -solid 2 - -checkprops r1 -s 664 -v 1064 -checknbshapes r1 -vertex 24 -edge 36 -wire 18 -face 16 -shell 1 -solid 1 - -checkprops r2 -s empty -v empty -checknbshapes r2 -vertex 0 -edge 0 -wire 0 -face 0 -shell 0 -solid 0 - -checkprops r3 -s 1176 -v 552 -checknbshapes r3 -vertex 40 -edge 64 -wire 38 -face 34 -shell 5 -solid 5 diff --git a/tests/boolean/opensolid/A8 b/tests/boolean/opensolid/A8 deleted file mode 100644 index 6d9a1cc18c..0000000000 --- a/tests/boolean/opensolid/A8 +++ /dev/null @@ -1,33 +0,0 @@ -box b1 10 10 10 -box b2 -2 -2 2 7 14 6 -box b3 5 -2 2 7 14 6 -bclearobjects -bcleartools -baddobjects b1 -baddtools b2 b3 -bfillds -bbuild r - -buildbop r0 -o b1 -t b3 b2 -op common -buildbop r1 -o b1 -t b3 b2 -op fuse -buildbop r2 -o b1 -t b3 b2 -op cut -buildbop r3 -o b1 -t b3 b2 -op tuc - -foreach r {r0 r1 r2 r3} { - checkshape $r - if {![regexp "OK" [bopcheck $r]]} { - puts "Error: shape is self-interfered" - } -} - -checkprops r0 -s 560 -v 600 -checknbshapes r0 -vertex 12 -edge 20 -wire 11 -face 11 -shell 2 -solid 2 - -checkprops r1 -s 888 -v 1576 -checknbshapes r1 -vertex 32 -edge 50 -wire 20 -face 20 -shell 1 -solid 1 - -checkprops r2 -s 560 -v 400 -checknbshapes r2 -vertex 20 -edge 30 -wire 14 -face 14 -shell 2 -solid 2 - -checkprops r3 -s 816 -v 576 -checknbshapes r3 -vertex 24 -edge 40 -wire 18 -face 18 -shell 2 -solid 2 diff --git a/tests/boolean/opensolid/A9 b/tests/boolean/opensolid/A9 deleted file mode 100644 index e58196b4b7..0000000000 --- a/tests/boolean/opensolid/A9 +++ /dev/null @@ -1,56 +0,0 @@ -puts "REQUIRED All: Faulty shapes in variables faulty_1 to faulty_2" - -box b1 10 10 10 -box b2 5 0 0 10 10 10 - -shape s1 So -shape s2 So -shape sh1 Sh -shape sh2 Sh - -foreach f [lrange [explode b1 f] 0 4] { add $f sh1 } -foreach f [lrange [explode b2 f] 0 4] { add $f sh2 } - -add sh1 s1 -add sh2 s2 - -polyline p 1 1 1 1 9 1 1 9 9 1 1 9 1 1 1 -mkplane f p -orientation f I -shape shell_int1 Sh -add f shell_int1 -add shell_int1 s1 - -copy shell_int1 shell_int2 -ttranslate shell_int2 13 0 0 -add shell_int2 s2 - -bclearobjects -bcleartools -baddobjects s1 -baddtools s2 -bfillds - -bbop r0 0 -bbop r1 1 -bbop r2 2 -bbop r3 3 - -foreach r {r0 r1 r2 r3} { - checkshape $r - if {![regexp "OK" [bopcheck $r]]} { - puts "Error: shape is self-interfered" - } -} - -checknbshapes r0 -vertex 8 -edge 12 -wire 5 -face 5 -shell 1 -solid 1 -checkprops r0 -s 350 - -checknbshapes r1 -vertex 16 -edge 26 -wire 11 -face 11 -shell 1 -solid 1 -checkprops r1 -s 650 - -# results of CUT operations should contain an extra shell -foreach r {r2 r3} { - checknbshapes $r -vertex 12 -edge 16 -wire 6 -face 6 -shell 2 -solid 1 - checkprops $r -s 414 -} \ No newline at end of file diff --git a/tests/boolean/periodicity/A1 b/tests/boolean/periodicity/A1 deleted file mode 100644 index d23cc93aba..0000000000 --- a/tests/boolean/periodicity/A1 +++ /dev/null @@ -1,15 +0,0 @@ -box b 10 10 10 - -# make the box periodic -makeperiodic bp b -x 5 -trim 2 -y 8 -trim 1 -z 12 -trim -1 - -checkshape bp -checknbshapes bp -vertex 8 -edge 12 -wire 6 -face 6 -shell 1 -solid 1 -t -checkprops bp -s 340 -v 400 - -# repeat the shape -repeatshape result -x 5 -y 5 -z 5 - -checkshape result -checknbshapes result -vertex 588 -edge 1302 -wire 936 -face 936 -shell 216 -solid 216 -t -checkprops result -s 73440 -v 86400 diff --git a/tests/boolean/periodicity/A2 b/tests/boolean/periodicity/A2 deleted file mode 100644 index bfca7bfefb..0000000000 --- a/tests/boolean/periodicity/A2 +++ /dev/null @@ -1,80 +0,0 @@ -polyline p 0 0 0 10 0 0 10 0 10 5 0 10 5 0 5 0 0 5 0 0 0 -mkplane f p -prism s f 0 5 0 - -# make the shape periodic -makeperiodic sp s -x 10 -z 10 -y 5 - -checkshape sp -checknbshapes sp -vertex 16 -edge 24 -wire 10 -face 10 -shell 1 -solid 1 -t -checkprops sp -s 350 -v 375 - -# get history of the operation -savehistory h - -# check modification of the bottom and side faces -explode s f -modified m h s_1 - -checknbshapes m -vertex 6 -edge 7 -wire 2 -face 2 -t -explode m f -periodictwins t1 m_1 -periodictwins t2 m_2 - -compound t1 t2 t -checknbshapes t -face 1 -t - - -explode s f -modified m h s_2 - -checknbshapes m -vertex 6 -edge 7 -wire 2 -face 2 -t -explode m f -periodictwins t1 m_1 -periodictwins t2 m_2 - -compound t1 t2 t -checknbshapes t -face 1 -t - - -# repeat the shape -repeatshape res -x 1 -y 2 - -checkshape res -checknbshapes res -vertex 56 -edge 102 -wire 53 -face 53 -shell 6 -solid 6 -t -checkprops res -s 2100 -v 2250 - - -# get repetition history -savehistory h - -# get generations of bottom face -generated g h s_1 - -checkshape g -checknbshapes g -vertex 20 -edge 31 -wire 12 -face 12 -t -checkprops g -s 300 - -# get generations of the top face -generated g h s_3 - -checkshape g -checknbshapes g -vertex 16 -edge 20 -wire 6 -face 6 -t -checkprops g -s 150 - -foreach f [explode g f] { - periodictwins t $f - checkshape t - checknbshapes t -wire 11 -face 11 -t - checkprops t -s 275 -} - -# clear repetitions -clearrepetitions - -savehistory h - -# now generated for bottom face should be empty -if {![regexp "No shapes were generated from the shape." [generated g1 h s_1]]} { - puts "Error: history is not cleared" -} diff --git a/tests/boolean/periodicity/A3 b/tests/boolean/periodicity/A3 deleted file mode 100644 index 142b43d88d..0000000000 --- a/tests/boolean/periodicity/A3 +++ /dev/null @@ -1,14 +0,0 @@ -box b 100 100 1 - -pcylinder c 2 2 -ttranslate c 2.5 2.5 0 - -makeperiodic p c -x 5 -trim 0 -y 5 -trim 0 - -repeatshape r -x 19 -y 19 - -bcut result b r - -checkshape result -checknbshapes result -vertex 808 -edge 1212 -wire 1206 -face 406 -shell 1 -solid 1 -t -checkprops result -s 15373.5 -v 4973.45 diff --git a/tests/boolean/periodicity/A4 b/tests/boolean/periodicity/A4 deleted file mode 100644 index 3826d39178..0000000000 --- a/tests/boolean/periodicity/A4 +++ /dev/null @@ -1,13 +0,0 @@ -box b 5 5 1 -pcylinder c 2 2 -ttranslate c 2.5 2.5 0 - -bcut p b c - -makeperiodic p p -x 5 -y 5 - -repeatshape result -x -9 -x 1 -y -9 -y 1 - -checkshape result -checknbshapes result -vertex 1682 -edge 3321 -wire 2840 -face 2040 -shell 400 -solid 400 -t -checkprops result -s 22973.5 -v 4973.45 diff --git a/tests/boolean/periodicity/A5 b/tests/boolean/periodicity/A5 deleted file mode 100644 index 581aa61ccf..0000000000 --- a/tests/boolean/periodicity/A5 +++ /dev/null @@ -1,39 +0,0 @@ -box b 10 10 10 -copy b bf -foreach e [explode b e] { - nurbsconvert ne $e - eval mkvolume s ne [explode bf f] - - savehistory mv_hist - modified m mv_hist ne - - mkcurve cur m - if {![regexp "BSplineCurve" [dump cur]]} { - puts "Error: Boolean Operation took the second face" - } - - # make the shape periodic in all directions - makeperiodic res s -x 10 -y 10 -z 10 - - savehistory h - modified me h m - - # get twins for the edge - periodictwins twins me - - checknbshapes twins -edge 2 -m "Periodic twins" -t - mkcurve c_me me - if {![regexp {Basis curve :\n([^ \n]*)} [dump c_me] full e_type]} { - puts "Error: Unable to get the type" - } - - foreach t [explode twins e] { - mkcurve c_$t $t - if {![regexp {Basis curve :\n([^ \n]*)} [dump c_$t] full t_type]} { - puts "Error: Unable to get the type" - } - if {$e_type != $t_type} { - puts "Error: Twins have different geometries" - } - } -} diff --git a/tests/boolean/periodicity/A6 b/tests/boolean/periodicity/A6 deleted file mode 100644 index 29f035b5f5..0000000000 --- a/tests/boolean/periodicity/A6 +++ /dev/null @@ -1,62 +0,0 @@ -box b 10 10 10 - -foreach bf [explode b f] { - # replace face with the nurbs one - nurbsconvert nf $bf - eval mkvolume s nf [explode b f] - - savehistory mv_hist - modified m mv_hist nf - - mksurface surf m - if {![regexp "BSplineSurface" [dump surf]]} { - puts "Error: Boolean Operation took the second face" - } - - # make the shape periodic in all directions - makeperiodic res s -x 10 -y 10 -z 10 - - savehistory h - modified mf h m - - mksurface s_mf mf - - # get twins for the face - periodictwins tf mf - - checknbshapes tf -face 1 -m "Periodic twins" -t - - mksurface s_tf tf - - if {![regexp {\*\n([^ \n]*)} [dump s_mf] full mf_type]} { - puts "Error: Unable to get the type" - } - if {![regexp {\*\n([^ \n]*)} [dump s_tf] full tf_type]} { - puts "Error: Unable to get the type" - } - - if {$mf_type != $tf_type} { - puts "Error: Twins have different geometries" - } - - # get twins for edges of the face - foreach e [explode mf e] { - periodictwins twins $e - checknbshapes twins -edge 2 -m "Periodic twins" -t - mkcurve c_$e $e - if {![regexp {Basis curve :\n([^ \n]*)} [dump c_$e] full e_type]} { - puts "Error: Unable to get the type" - } - - foreach t [explode twins e] { - mkcurve c_$t $t - if {![regexp {Basis curve :\n([^ \n]*)} [dump c_$t] full t_type]} { - puts "Error: Unable to get the type" - } - if {$e_type != $t_type} { - puts "Error: Twins have different geometries" - } - } - } -} - diff --git a/tests/boolean/simplify/A1 b/tests/boolean/simplify/A1 deleted file mode 100644 index c8cac627ed..0000000000 --- a/tests/boolean/simplify/A1 +++ /dev/null @@ -1,24 +0,0 @@ -# Fuse of two boxes - -boptions -default - -box b1 10 10 15 -box b2 3 7 0 10 10 15 -bclearobjects -bcleartools -baddobjects b1 -baddtools b2 -bfillds - -# build not simplified result -bapibop res 1 -checkshape res -checknbshapes res -vertex 20 -edge 32 -wire 14 -face 14 - -# set option to simplify result -bsimplify -f 1 -bapibop res_simple 1 -checkshape res_simple -checknbshapes res_simple -vertex 16 -edge 24 -wire 10 -face 10 - -boptions -default diff --git a/tests/boolean/simplify/A2 b/tests/boolean/simplify/A2 deleted file mode 100644 index 26cad6fd5a..0000000000 --- a/tests/boolean/simplify/A2 +++ /dev/null @@ -1,33 +0,0 @@ -# Section between shell and a plane - -boptions -default - -plane p 0 0 0 0 0 1 -mkface f1 p -10 10 -10 10 -mkface f2 p 10 30 -10 10 -mkface f3 p 30 50 -10 10 -sewing shell f1 f2 f3 - -plane p 0 5 0 0 1 0 -mkface f p -100 100 -100 100 - -bclearobjects -bcleartools -baddobjects shell -baddtools f -bfillds - -# build not simplified result -bapibop sec 4 -checkshape sec -checknbshapes sec -vertex 4 -edge 3 -checkprops sec -l 60 - -# set option to simplify result -bsimplify -e 1 -bapibop sec_simple 4 -checkshape sec_simple -checknbshapes sec_simple -vertex 2 -edge 1 -checkprops sec_simple -l 60 - -boptions -default diff --git a/tests/boolean/splitter/A1 b/tests/boolean/splitter/A1 deleted file mode 100644 index 73bb2ecd2f..0000000000 --- a/tests/boolean/splitter/A1 +++ /dev/null @@ -1,24 +0,0 @@ -puts "============" -puts "OCC26874" -puts "============" -puts "" -####################################################################### -# Implementation of the Partition operator in OCCT -####################################################################### - -# split box by two other boxes - -box b1 10 10 10 -box b2 4 -2 -2 2 14 14 -box b3 -2 4 -2 14 2 14 - -bclearobjects -bcleartools -baddobjects b1 -baddtools b2 b3 -bfillds -bsplit result - -checkshape result -checknbshapes result -solid 9 -checkprops result -v 1000 diff --git a/tests/boolean/splitter/A2 b/tests/boolean/splitter/A2 deleted file mode 100644 index 5ddeb0e7a8..0000000000 --- a/tests/boolean/splitter/A2 +++ /dev/null @@ -1,26 +0,0 @@ -puts "============" -puts "OCC26874" -puts "============" -puts "" -####################################################################### -# Implementation of the Partition operator in OCCT -####################################################################### - -# split box by other solid and face - -box b1 10 10 10 - -box b2 5 0 0 10 10 10 -plane p 0 0 5 0 0 1 -mkface f p -20 20 -20 20 - -bclearobjects -bcleartools -baddobjects b1 -baddtools b2 f -bfillds -bsplit result - -checkshape result -checknbshapes result -solid 4 -checkprops result -v 1000 diff --git a/tests/boolean/splitter/A3 b/tests/boolean/splitter/A3 deleted file mode 100644 index 3dccb86f66..0000000000 --- a/tests/boolean/splitter/A3 +++ /dev/null @@ -1,25 +0,0 @@ -puts "============" -puts "OCC26874" -puts "============" -puts "" -####################################################################### -# Implementation of the Partition operator in OCCT -####################################################################### - -# split face by a sphere - -plane p 0 0 0 0 0 1 -mkface f p -20 20 -20 20 - -psphere s 5 - -bclearobjects -bcleartools -baddobjects f -baddtools s -bfillds -bsplit result - -checkshape result -checknbshapes result -face 2 -checkprops result -s 1600 \ No newline at end of file diff --git a/tests/boolean/splitter/A4 b/tests/boolean/splitter/A4 deleted file mode 100644 index 7060c0a28b..0000000000 --- a/tests/boolean/splitter/A4 +++ /dev/null @@ -1,46 +0,0 @@ -puts "============" -puts "OCC26874" -puts "============" -puts "" -####################################################################### -# Implementation of the Partition operator in OCCT -####################################################################### - -# split face by set of edges - -cylinder cyl 0 0 0 0 0 1 10 -set height 20 -mkface f cyl 0 2*pi -$height $height - -bclearobjects -bcleartools -baddobjects f - -# create tool edges -compound edges - -set nb_uedges 10 -set pi2 [dval 2*pi] -set ustep [expr $pi2/$nb_uedges] -for {set i 0} {$i <= $pi2} {set i [expr $i + $ustep]} { - uiso c cyl $i - mkedge e c -25 25 - add e edges -} - -set nb_vedges 10 -set vstep [expr 2*$height/$nb_vedges] -for {set i -20} {$i <= 20} {set i [expr $i + $vstep]} { - viso c cyl $i - mkedge e c - add e edges -} - -baddctools edges - -bfillds -bsplit result - -checkshape result -checknbshapes result -face 100 -checkprops result -s 2513.27 \ No newline at end of file diff --git a/tests/boolean/splitter/A6 b/tests/boolean/splitter/A6 deleted file mode 100644 index 6c57158763..0000000000 --- a/tests/boolean/splitter/A6 +++ /dev/null @@ -1,36 +0,0 @@ -puts "============" -puts "OCC26874" -puts "============" -puts "" -####################################################################### -# Implementation of the Partition operator in OCCT -####################################################################### - -# split plate by set of cylinders - -box plate 100 100 1 - -bclearobjects -bcleartools -baddobjects plate - -pcylinder p 1 11 - -compound cylinders - -for {set i 0} {$i < 101} {incr i 5} { - for {set j 0} {$j < 101} {incr j 5} { - copy p p1; - ttranslate p1 $i $j -5; - add p1 cylinders - } -} - -baddtools cylinders - -bfillds -bsplit result - -checkshape result -checknbshapes result -solid 442 -checkprops result -v 10000 \ No newline at end of file diff --git a/tests/boolean/splitter/B1 b/tests/boolean/splitter/B1 deleted file mode 100644 index dd0dc3475d..0000000000 --- a/tests/boolean/splitter/B1 +++ /dev/null @@ -1,24 +0,0 @@ -puts "============" -puts "OCC26874" -puts "============" -puts "" -####################################################################### -# Implementation of the Partition operator in OCCT -####################################################################### - -# split box by two other boxes - -box b1 10 10 10 -box b2 4 -2 -2 2 14 14 -box b3 -2 4 -2 14 2 14 - -bclearobjects -bcleartools -baddobjects b1 -baddtools b2 b3 -bfillds -bapisplit result - -checkshape result -checknbshapes result -solid 9 -checkprops result -v 1000 diff --git a/tests/boolean/splitter/B2 b/tests/boolean/splitter/B2 deleted file mode 100644 index b1ccd9a191..0000000000 --- a/tests/boolean/splitter/B2 +++ /dev/null @@ -1,26 +0,0 @@ -puts "============" -puts "OCC26874" -puts "============" -puts "" -####################################################################### -# Implementation of the Partition operator in OCCT -####################################################################### - -# split box by other solid and face - -box b1 10 10 10 - -box b2 5 0 0 10 10 10 -plane p 0 0 5 0 0 1 -mkface f p -20 20 -20 20 - -bclearobjects -bcleartools -baddobjects b1 -baddtools b2 f -bfillds -bapisplit result - -checkshape result -checknbshapes result -solid 4 -checkprops result -v 1000 diff --git a/tests/boolean/splitter/B3 b/tests/boolean/splitter/B3 deleted file mode 100644 index d07ab4c250..0000000000 --- a/tests/boolean/splitter/B3 +++ /dev/null @@ -1,25 +0,0 @@ -puts "============" -puts "OCC26874" -puts "============" -puts "" -####################################################################### -# Implementation of the Partition operator in OCCT -####################################################################### - -# split face by a sphere - -plane p 0 0 0 0 0 1 -mkface f p -20 20 -20 20 - -psphere s 5 - -bclearobjects -bcleartools -baddobjects f -baddtools s -bfillds -bapisplit result - -checkshape result -checknbshapes result -face 2 -checkprops result -s 1600 \ No newline at end of file diff --git a/tests/boolean/splitter/B4 b/tests/boolean/splitter/B4 deleted file mode 100644 index f6b3e1687d..0000000000 --- a/tests/boolean/splitter/B4 +++ /dev/null @@ -1,46 +0,0 @@ -puts "============" -puts "OCC26874" -puts "============" -puts "" -####################################################################### -# Implementation of the Partition operator in OCCT -####################################################################### - -# split face by set of edges - -cylinder cyl 0 0 0 0 0 1 10 -set height 20 -mkface f cyl 0 2*pi -$height $height - -bclearobjects -bcleartools -baddobjects f - -# create tool edges -compound edges - -set nb_uedges 10 -set pi2 [dval 2*pi] -set ustep [expr $pi2/$nb_uedges] -for {set i 0} {$i <= $pi2} {set i [expr $i + $ustep]} { - uiso c cyl $i - mkedge e c -25 25 - add e edges -} - -set nb_vedges 10 -set vstep [expr 2*$height/$nb_vedges] -for {set i -20} {$i <= 20} {set i [expr $i + $vstep]} { - viso c cyl $i - mkedge e c - add e edges -} - -baddctools edges - -bfillds -bapisplit result - -checkshape result -checknbshapes result -face 100 -checkprops result -s 2513.27 \ No newline at end of file diff --git a/tests/boolean/splitter/B6 b/tests/boolean/splitter/B6 deleted file mode 100644 index ef98821924..0000000000 --- a/tests/boolean/splitter/B6 +++ /dev/null @@ -1,36 +0,0 @@ -puts "============" -puts "OCC26874" -puts "============" -puts "" -####################################################################### -# Implementation of the Partition operator in OCCT -####################################################################### - -# split plate by set of cylinders - -box plate 100 100 1 - -bclearobjects -bcleartools -baddobjects plate - -pcylinder p 1 11 - -compound cylinders - -for {set i 0} {$i < 101} {incr i 5} { - for {set j 0} {$j < 101} {incr j 5} { - copy p p1; - ttranslate p1 $i $j -5; - add p1 cylinders - } -} - -baddtools cylinders - -bfillds -bapisplit result - -checkshape result -checknbshapes result -solid 442 -checkprops result -v 10000 \ No newline at end of file diff --git a/tests/bugs/caf/buc60790 b/tests/bugs/caf/buc60790 deleted file mode 100755 index 6dac2e4a12..0000000000 --- a/tests/bugs/caf/buc60790 +++ /dev/null @@ -1,15 +0,0 @@ -puts "===========" -puts "BUC60790" -puts "BUC60836" -puts "===========" - -pload QAcommands - -NewDocument D BinOcaf -UndoLimit D 100 - -set ResultError [BUC60836 D] -if {${ResultError} != 0 } { - puts "BUC60790: Error = $ResultError" -} - diff --git a/tests/bugs/caf/buc60813 b/tests/bugs/caf/buc60813 deleted file mode 100755 index 4871ce41ff..0000000000 --- a/tests/bugs/caf/buc60813 +++ /dev/null @@ -1,30 +0,0 @@ -puts "===========" -puts "BUC60813" -puts "===========" - -NewDocument D BinOcaf -UndoLimit D 100 - -NewCommand D - -Label D 0:1 - -SetName D 0:1 SourceLabel -SetReal D 0:1 3.1415 - -set Result [CopyLabel D 0:1 0:2] -if { ${Result} == 0} { - puts "BUC60813: Error 1" -} else { - set Name [GetName D 0:2] - if { [string length ${Name}] == 0 } { - puts "BUC60813: Error 2" - } else { - set Result [CopyLabel D 0:2 0:3] - if { ${Result} == 0 } { - puts "BUC60813: Error 3" - } else { - puts "BUC60813: OK" - } - } -} diff --git a/tests/bugs/caf/buc60831 b/tests/bugs/caf/buc60831 deleted file mode 100755 index b05fe956e0..0000000000 --- a/tests/bugs/caf/buc60831 +++ /dev/null @@ -1,50 +0,0 @@ -puts "===========" -puts "BUC60831" -puts "===========" - -pload QAcommands - -NewDocument D BinOcaf -UndoLimit D 100 - -NewCommand D - -set L 0:3 -Label D $L - -set Status 0 - -set Result [BUC60831_1 D] -if { ${Result} != 0 } { - puts "BUC60831: Error 1" - set Status 1 -} - -NewCommand D - -set Result [BUC60831_2 D $L] -if { ${Result} != 0 } { - puts "BUC60831: Error 2" - set Status 1 -} - -set Result [BUC60831_1 D] -if { ${Result} != 1 } { - puts "BUC60831: Error 3" - set Status 1 -} - -NewCommand D - -Undo D - -set Result [BUC60831_1 D] -if { ${Result} != 0 } { - puts "BUC60831: Error 4" - set Status 1 -} - -if { ${Status} != 0} then { - puts "BUC60831: Error" -} - diff --git a/tests/bugs/caf/buc60844 b/tests/bugs/caf/buc60844 deleted file mode 100755 index 9ef64e412f..0000000000 --- a/tests/bugs/caf/buc60844 +++ /dev/null @@ -1,39 +0,0 @@ -puts "===========" -puts "BUC60844" -puts "BUC60845" -puts "===========" - -NewDocument D BinOcaf -UndoLimit D 100 - -NewCommand D -Label D 0:2 -Label D 0:2:1 -Label D 0:2:1:1 -Label D 0:2:1:2 -Label D 0:3 - -SetNode D 0:1 -SetNode D 0:2 -SetNode D 0:2:1 -SetNode D 0:2:1:1 -SetNode D 0:2:1:2 -SetNode D 0:3 - -InsertNodeAfter D 0:1 0:2 -InsertNodeAfter D 0:2 0:3 - -AppendNode D 0:2 0:2:1 - -AppendNode D 0:2:1 0:2:1:1 -InsertNodeAfter D 0:2:1:1 0:2:1:2 - -NewCommand D - -ForgetAll D 0:2:1 - -NewCommand D - -Undo D - - diff --git a/tests/bugs/caf/buc60847 b/tests/bugs/caf/buc60847 deleted file mode 100755 index 15509edf18..0000000000 --- a/tests/bugs/caf/buc60847 +++ /dev/null @@ -1,18 +0,0 @@ -puts "===========" -puts "BUC60847" -puts "===========" - -pload QAcommands - -NewDocument D BinOcaf -UndoLimit D 100 - -NewCommand D - -box Shape 10 20 30 - -set ResultError [BUC60847 D Shape] -if { ${ResultError} != 0 } { - puts "BUC60847: Error = $ResultError" -} - diff --git a/tests/bugs/caf/buc60862 b/tests/bugs/caf/buc60862 deleted file mode 100755 index 84c0b07c8e..0000000000 --- a/tests/bugs/caf/buc60862 +++ /dev/null @@ -1,21 +0,0 @@ -puts "===========" -puts "BUC60862" -puts "===========" - -pload QAcommands - -NewDocument D BinOcaf -UndoLimit D 100 - -NewCommand D - -vertex V1 10 20 0 -vertex V2 20 10 0 - -catch {edge Shape ${V1} ${V2}} -catch {set ResultError [BUC60862 D $Shape]} - -if { ${ResultError} != 0 } { - puts "BUC60862: Error = $ResultError" -} - diff --git a/tests/bugs/caf/buc60910 b/tests/bugs/caf/buc60910 deleted file mode 100755 index 75b7d033b4..0000000000 --- a/tests/bugs/caf/buc60910 +++ /dev/null @@ -1,19 +0,0 @@ -puts "===========" -puts "BUC60910" -puts "===========" - -pload QAcommands - -NewDocument D BinOcaf -UndoLimit D 100 - -NewCommand D - -set ResultError [BUC60910 D] -if { ${ResultError} != 0 } { - puts "Error : 1" -} - -NewCommand D - - diff --git a/tests/bugs/caf/bug158 b/tests/bugs/caf/bug158 deleted file mode 100755 index 8959479d14..0000000000 --- a/tests/bugs/caf/bug158 +++ /dev/null @@ -1,12 +0,0 @@ -puts "==============" -puts "OCC158" -puts "==============" - -NewDocument D BinOcaf - -set aTmpFile ${imagedir}/${casename}.cbf -if { [catch {set res [SaveAs D ${aTmpFile}] }] != 0 } { - puts "OCC158: Error" -} - -file delete -force $aTmpFile diff --git a/tests/bugs/caf/bug159 b/tests/bugs/caf/bug159 deleted file mode 100644 index 074b437f3a..0000000000 --- a/tests/bugs/caf/bug159 +++ /dev/null @@ -1,28 +0,0 @@ -puts "===========" -puts "OCC159" -puts "===========" - -pload QAcommands - -NewDocument D BinOcaf - -set log [OCC159 D] - -set list [split ${log}] -set ll [llength ${list}] - -if { ${ll} < 13} then { - puts "OCC159: Error" -} else { - set DocRefCount1 [lindex ${list} 2] - set DocOwner1 [lindex ${list} 5] - set DocOwner2 [lindex ${list} 8] - set DocRefCount2 [lindex ${list} 11] - set deltaRefCount [expr ${DocRefCount1} - ${DocRefCount2}] - if { ${DocOwner2} == "NULL" && ${deltaRefCount} >= 1 } then { - puts "OCC159: OK" - } else { - puts "OCC159: Error" - } -} - diff --git a/tests/bugs/caf/bug170_3 b/tests/bugs/caf/bug170_3 deleted file mode 100755 index d0a9bc14f4..0000000000 --- a/tests/bugs/caf/bug170_3 +++ /dev/null @@ -1,33 +0,0 @@ -puts "========================" -puts "OCC170" -puts "(case 3)" -puts "========================" - -set docName ${casename} -set newDocName ${casename}_2 -set str1 "~!@#$%^&*():;'{}\|?/.>,<~!@#$%^&*():;'{}\|?/.>,<#$%#$%$%^&*():;'{}\|$%^&*(@#$%^&*():;'{}\|¦/" - -NewDocument $docName XmlOcaf -Label $docName 0:2 -SetComment $docName 0:2 $str1 - -file delete ${imagedir}/${docName}.xml -file delete ${imagedir}/${newDocName}.xml - -if [ catch {SaveAs $docName ${imagedir}/${docName}.xml} ] { - puts "Error : (SaveAs)" -} else { - puts "OK : (SaveAs)" -} - -file copy ${imagedir}/${docName}.xml ${imagedir}/${newDocName}.xml - -Open ${imagedir}/${newDocName}.xml $newDocName - -# Retrieve string from document and compare it with initial value -set str2 [GetComment $newDocName 0:2] -if {$str1 == $str2} {puts "OCC170 OK"} else { - puts "str1=${str1}" - puts "str2=${str2}" - puts "OCC170 Error" -} diff --git a/tests/bugs/caf/bug1722 b/tests/bugs/caf/bug1722 deleted file mode 100644 index 06887ddfe8..0000000000 --- a/tests/bugs/caf/bug1722 +++ /dev/null @@ -1,98 +0,0 @@ -puts "================" -puts "OCC1722" -puts "================" -puts "" -####################################################################################### -# Wrong behaviour of the method CommitCommand of class TDocStd_MultiTransactionManager -####################################################################################### - -proc OCC1722_Check_real_attribute {IsGood doc label good_real case} { - global ${doc} - # Check real attribute - set percent_max 0.1 - if [catch { set real [GetReal ${doc} ${label}] } message] { - set IsGood 0 - puts "OCC1722 Error (case ${case})" - } else { - set real_percent [expr abs(${real} - ${good_real}) / double(${good_real}) * 100.] - if {${real_percent} > ${percent_max}} { - puts "good_real = ${good_real}" - puts "real = ${real}" - puts "real_percent = ${real_percent}" - puts "OCC1722 Error (case ${case}-2)" - } - } - return ${IsGood} -} - - -set IsGood 1 -set Case 0 -set aLabel 0:1:1 -set aReal1 1.1 -set aReal2 2.1 - - -NewDocument doc1 -mtmCreate 4 - -mtmAdd doc1 - -SetReal doc1 ${aLabel} ${aReal1} -set IsGood [OCC1722_Check_real_attribute ${IsGood} ${doc1} ${aLabel} ${aReal1} [incr Case]] - -OpenCommand doc1 -SetReal doc1 ${aLabel} ${aReal2} -set IsGood [OCC1722_Check_real_attribute ${IsGood} ${doc1} ${aLabel} ${aReal2} [incr Case]] - -set list [mtmDump] -################################################################################ -# *** Dump of MTM *** -# There is one document ( "3095112" ) in the manager -# Nested transaction mode is off -# -# -# *** End *** -################################################################################ -set index1 [lsearch -exact ${list} "Undo:"] - -# Check dump -set case [incr Case] -if { ${index1} != -1 } { - set IsGood 0 - puts "OCC1722 Error (case ${case})" -} - -mtmCommit Transaction1 - -set list [mtmDump] -################################################################################ -# *** Dump of MTM *** -# There is one document ( "3095112" ) in the manager -# Nested transaction mode is off -# -# Undo: Transaction1 - 1 documents ( "3095112" ) < Last action -# -# *** End *** -################################################################################ -set index2 [lsearch -exact ${list} "Undo:"] - -# Check dump -set case [incr Case] -if { ${index2} == -1 } { - set IsGood 0 - puts "OCC1722 Error (case ${case})" -} - -Undo doc1 -set IsGood [OCC1722_Check_real_attribute ${IsGood} ${doc1} ${aLabel} ${aReal1} [incr Case]] - -Redo doc1 -set IsGood [OCC1722_Check_real_attribute ${IsGood} ${doc1} ${aLabel} ${aReal2} [incr Case]] - - -if { ${IsGood} == 1 } { - puts "OCC1722 OK" -} else { - puts "OCC1722 Error" -} diff --git a/tests/bugs/caf/bug21231 b/tests/bugs/caf/bug21231 deleted file mode 100755 index fa8dcc0e33..0000000000 --- a/tests/bugs/caf/bug21231 +++ /dev/null @@ -1,91 +0,0 @@ -puts "============" -puts "OCC21231" -puts "============" -puts "" -####################################################################### -####################################################################### - -set BugNumber OCC21231 -set status 0 - -pload TOBJ - -# Create a new document -TObjNew TD1 - -TObjAddObj TD1 obj1 -TObjAddObj TD1 obj2 -TObjAddObj TD1 obj3 - -set parent "obj1 obj2 obj2" -set children "ch11 ch21 ch22" -for { set i 0} {$i <= 2} {incr i} { - set p [lindex $parent $i] - set ch [lindex $children $i] - TObjAddChild TD1 $p $ch -} - -TObjSetRef TD1 obj1 obj2 - -TObjSetVal TD1 obj1 533 -TObjSetVal TD1 obj2 -r 3 3.14 2.78 0.123 - -# Save the document -set aFile $imagedir/${test_image}-[file tail [info script]].cbf -catch {[file delete ${aFile}]} -catch {TObjSave TD1 ${aFile}} -if { ![file exists ${aFile}] } { - set status 1 - puts "There is not ${aFile} file; TObjSave command: Error" - puts "${BugNumber}: ERROR" -} else { - puts "Save the document to ${aFile} file" -} - -TObjClose TD1 -unset TD1 - -# Restore the document -if [catch { TObjLoad TD2 ${aFile} } catch_result] { - puts "${BugNumber}: ERROR" -} - -# check children of obj2 -set retChh [TObjGetChildren TD2 obj2] -for { set i 1 } { $i <= 2} {incr i} { - set chh [lindex $retChh [expr $i - 1]] - set oldCh [lindex $children $i] - if { $chh != $oldCh } { - set status 1 - puts "${BugNumber}: check children of obj2; ERROR (case 1)" - } -} - -# check reference from obj1 -set retRef [TObjGetRef TD2 obj1] -if { $retRef != "obj2" } { - set status 1 - puts "${BugNumber}: check reference from obj1; ERROR (case 2)" -} - -# check stored single integer value -set retInt [TObjGetVal TD2 obj1 -i] -if { $retInt != 533 } { - set status 1 - puts "${BugNumber}: check stored single integer value; ERROR (case 3)" -} - -# check stored array of doubles -set retDbl [TObjGetVal TD2 obj2 -r] -set nbVal [llength $retDbl] -if { $nbVal != 3 } { - set status 1 - puts "${BugNumber}: check stored array of doubles; ERROR (case 4)" -} - -if { ${status} != 0 } { - puts "Faulty ${BugNumber}" -} else { - puts "OK ${BugNumber}" -} - diff --git a/tests/bugs/caf/bug22976 b/tests/bugs/caf/bug22976 deleted file mode 100755 index 8717c6151d..0000000000 --- a/tests/bugs/caf/bug22976 +++ /dev/null @@ -1,25 +0,0 @@ -puts "===========" -puts "OCC22976" -puts "===========" -###################################################### -# A draw-command CopyDF fails to copy content of a label -###################################################### - -set BugNumber OCC22976 - -# Create a new document and set UndoLimit -NewDocument D -UndoLimit D 100 - -# Open a transaction -NewCommand D - -SetReal D 0:1 1.2345 -CopyDF D 0:1 0:2 -catch { GetReal D 0:2 } catch_result - -if { $catch_result == 1.2344999999999999 } { - puts "OK ${BugNumber}" -} else { - puts "Faulty ${BugNumber}" -} diff --git a/tests/bugs/caf/bug23306 b/tests/bugs/caf/bug23306 deleted file mode 100755 index f627bf0d2e..0000000000 --- a/tests/bugs/caf/bug23306 +++ /dev/null @@ -1,22 +0,0 @@ -puts "============" -puts "OCC23306: F a i l u r e s reading some attributes of BinOcaf document" -puts "============" -puts "" - -set BugNumber OCC23306 - -NewDocument D1 BinOcaf -SetExtStringArray D1 0:1:1 0 1 3 String1 String2 String3 - -set aTmpFile ${imagedir}/${casename}.cbf -SaveAs D1 $aTmpFile -Close D1 -set warn [Open $aTmpFile D2] -set info [lsearch $warn "warning:"] -file delete -force ${aTmpFile} - -if { $info == -1 } { - puts "OK ${BugNumber}" -} else { - puts "Faulty ${BugNumber}" -} diff --git a/tests/bugs/caf/bug23465 b/tests/bugs/caf/bug23465 deleted file mode 100644 index 63c99e3a87..0000000000 --- a/tests/bugs/caf/bug23465 +++ /dev/null @@ -1,119 +0,0 @@ -# =================== OCAF ====================== -# Standard attributes of List containers (xml format) -# -# Testing purpose: test of InsertBefore / InsertAfter / Remove -# of TDataStd_BooleanList, TDataStd_IntegerList -# TDataStd_RealList, TDataStd_ExtStringList, -# TDataStd_ReferenceList attributes -# -# =============================================== -# Test case: -# 1. create BooleanList attribute with empty list -# 2. create IntegerList attribute with empty list -# 3. create RealList attribute with empty list -# 4. create ExtStringList attribute with empty list -# 5. create ReferenceList attribute with empty list -# 6. insert before a value -# 7. insert after a value -# 8. remove a value -# 9. check the values -# =============================================== - -NewDocument D XmlOcaf -# 1. create BooleanList attribute -set Lab1 [Label D 0:1:1] -SetBooleanList D $Lab1 0 0 1 0 -set info1 [GetBooleanList D $Lab1] -# output => "0 0 1 0" - -# 2. create IntegerList attribute -set Lab2 [Label D 0:1:2] -SetIntegerList D $Lab2 0 0 1 0 -set info2 [GetIntegerList D $Lab2] -# output => "0 0 1 0" - -# 3. create RealList attribute -set Lab3 [Label D 0:1:3] -SetRealList D $Lab3 0 0 1 0 -set info3 [GetRealList D $Lab3] -# output => "0 0 1 0" - -# 4. create ExtStringList attribute -set Lab4 [Label D 0:1:4] -SetExtStringList D $Lab4 0 0 1 0 -set info4 [GetExtStringList D $Lab4] -# output => "0 0 1 0" - -# 5. create ReferenceList attribute -set Lab5 [Label D 0:1:5] -SetReferenceList D $Lab5 $Lab1 $Lab2 $Lab4 -set info5 [GetReferenceList D $Lab5] -# output => "0:1:1 0:1:2 0:1:4" - -# 6. insert before a value -InsertBeforeBooleanList D $Lab1 3 1 -InsertBeforeIntegerList D $Lab2 3 1 -InsertBeforeRealList D $Lab3 3 1 -InsertBeforeExtStringList D $Lab4 3 1 -InsertBeforeReferenceList D $Lab5 3 0:1:3 -# output => "0 0 1 1 0" -# output => "0:1:1 0:1:2 0:1:3 0:1:4" - -# 7. insert after a value -InsertAfterBooleanList D $Lab1 4 1 -InsertAfterIntegerList D $Lab2 4 1 -InsertAfterRealList D $Lab3 4 1 -InsertAfterExtStringList D $Lab4 4 1 -InsertAfterReferenceList D $Lab5 4 0:1:5 -# output => "0 0 1 1 1 0" -# output => "0:1:1 0:1:2 0:1:3 0:1:4 0:1:5" - -# 8. remove a value -RemoveBooleanList D $Lab1 6 -RemoveIntegerList D $Lab2 6 -RemoveRealList D $Lab3 6 -RemoveExtStringList D $Lab4 6 -RemoveReferenceList D $Lab5 1 -# output => "0 0 1 1 1" -# output => "0:1:2 0:1:3 0:1:4 0:1:5" - -# 8. Check the values -set info6 [GetBooleanList D $Lab1] -set info7 [GetIntegerList D $Lab2] -set info8 [GetRealList D $Lab3] -set info9 [GetExtStringList D $Lab4] -set info10 [GetReferenceList D $Lab5] -# output => "0 0 1 1 1" -# output => "0:1:2 0:1:3 0:1:4 0:1:5" - -Close D - -if { [regexp {0 0 1 1 1} ${info6}] } { - puts "OK: inserted and removed values for BooleanList attribute are good" -} else { - puts "Error: inserted and removed values for BooleanList attribute are bad" -} - -if { [regexp {0 0 1 1 1} ${info7}] } { - puts "OK: inserted and removed values for IntegerList attribute are good" -} else { - puts "Error: inserted and removed values for IntegerList attribute are bad" -} - -if { [regexp {0 0 1 1 1} ${info8}] } { - puts "OK: inserted and removed values for RealList attribute are good" -} else { - puts "Error: inserted and removed values for RealList attribute are bad" -} - -if { [regexp {0 0 1 1 1} ${info9}] } { - puts "OK: inserted and removed values for ExtStringList attribute are good" -} else { - puts "Error: inserted and removed values for ExtStringList attribute are bad" -} - -if { [regexp {0:1:2 0:1:3 0:1:4 0:1:5} ${info10}] } { - puts "OK: inserted and removed values for ReferenceList attribute are good" -} else { - puts "Error: inserted and removed values for ReferenceList attribute are bad" -} diff --git a/tests/bugs/caf/bug23799 b/tests/bugs/caf/bug23799 deleted file mode 100755 index 4da857ea6d..0000000000 --- a/tests/bugs/caf/bug23799 +++ /dev/null @@ -1,25 +0,0 @@ -puts "============" -puts "OCC23799" -puts "============" -puts "" -####################################################################### -# Crash on copying a label -####################################################################### - -set BugNumber OCC23799 - -# Create a new document -NewDocument D - -psphere s 100 -explode s f - -ImportShape D 0:1 s -SelectShape D 0:2 s_1 s -ForgetAll D 0:1 - -if { [catch [CopyLabel D 0:2 0:3] ] != 0 } { - puts "${BugNumber}: Error copy label" -} else { - puts "${BugNumber}: OK" -} diff --git a/tests/bugs/caf/bug23912 b/tests/bugs/caf/bug23912 deleted file mode 100644 index 6509a8230c..0000000000 --- a/tests/bugs/caf/bug23912 +++ /dev/null @@ -1,24 +0,0 @@ -puts "============" -puts "OCC23912" -puts "============" -puts "" -################################################################################################################### -# TDataStd_ExtStringArray::Value() returns a copy of TCollection_ExtededString, but it might return a reference -################################################################################################################### - -NewDocument D -SetExtStringArray D 0:1 0 1 5 "A" "B" "C" "D" "E" -set info [GetExtStringArray D 0:1] - -if { [regexp "A B C D E" $info] != 1 } { - puts "Error : function returns wrong value" -} else { - puts "OK : function works properly" -} - - - - - - - diff --git a/tests/bugs/caf/bug24164_1 b/tests/bugs/caf/bug24164_1 deleted file mode 100644 index 4df67dc8a7..0000000000 --- a/tests/bugs/caf/bug24164_1 +++ /dev/null @@ -1,54 +0,0 @@ -pload OCAF - -if { [info exists imagedir] == 0 } { - set imagedir . -} -set BugNumber OCC24164 - -#1 open new document -NewDocument D BinOcaf -UndoLimit D 10 0 0 -InitLogBook D -AddDriver D Box - -#2 build box -NewCommand D -set B2 [AddObject D] -set F2 [AddFunction D $B2 Box] -BoxDX D $B2 190 -BoxDY D $B2 290 -BoxDZ D $B2 390 -ComputeFun D $F2 -GetShape D $F2:2 Box2 -NewCommand D - -#3 save shape in the document -set aTmpFile ${imagedir}/${casename}.cbf -SaveAs D $aTmpFile - -#4 close document -set catch_status 0 -if { [catch {Close D} catch_result] } { - set catch_status 1 -} -if { ${catch_status} != 0 } { - puts "Faulty ${BugNumber}" -} else { - puts "OK ${BugNumber}" -} - -#5 reopen just saved document with the same name -Open $aTmpFile D -file delete -force $aTmpFile -set catch_status 0 - -#6 close the document -if { [catch {Close D} catch_result] } { - set catch_status 1 -} - -if { ${catch_status} != 0 } { - puts "Faulty ${BugNumber}" -} else { - puts "OK ${BugNumber}" -} diff --git a/tests/bugs/caf/bug24164_2 b/tests/bugs/caf/bug24164_2 deleted file mode 100644 index 055643e553..0000000000 --- a/tests/bugs/caf/bug24164_2 +++ /dev/null @@ -1,70 +0,0 @@ -pload OCAF - -set BugNumber OCC24164 -if { [info exists imagedir] == 0 } { - set imagedir . -} - -#1 open new document -NewDocument D BinOcaf -UndoLimit D 10 0 0 - -#2 define set of labels -NewCommand D -set Lab1 [Label D 0:1:1] -set Lab2 [Label D 0:1:2] -set Lab3 [Label D 0:1:3] -set Lab4 [Label D 0:1:4] -set Lab5 [Label D 0:1:5] -set Lab6 [Label D 0:1:6] - -#3 set references -SetRefArray D $Lab1 1 2 $Lab2 $Lab1 -SetRefArray D $Lab2 1 2 $Lab3 $Lab4 -SetRefArray D $Lab3 1 1 $Lab1 - -#4 set additional references -NewCommand D -SetRefArray D $Lab4 1 2 $Lab5 $Lab1 -SetRefArray D $Lab5 1 1 $Lab6 -SetRefArray D $Lab6 1 2 $Lab3 $Lab4 - -NewCommand D - -#5 check references -GetRefArray D $Lab1 -GetRefArray D $Lab2 -GetRefArray D $Lab3 -GetRefArray D $Lab4 -GetRefArray D $Lab5 -GetRefArray D $Lab6 - -#6 save the document -set aTmpFile ${imagedir}/${casename}.cbf -SaveAs D $aTmpFile - -#7 close the document -set catch_status 0 -if { [catch {Close D} catch_result] } { - set catch_status 1 -} -if { ${catch_status} != 0 } { - puts "Faulty ${BugNumber}" -} else { - puts "OK ${BugNumber}" -} - -#8 reopen just saved document with the same name -Open $aTmpFile D -file delete -force $aTmpFile - -#9 close the document -if { [catch {Close D} catch_result] } { - set catch_status 1 -} - -if { ${catch_status} != 0 } { - puts "Faulty ${BugNumber}" -} else { - puts "OK ${BugNumber}" -} diff --git a/tests/bugs/caf/bug24263 b/tests/bugs/caf/bug24263 deleted file mode 100644 index 88d98199d1..0000000000 --- a/tests/bugs/caf/bug24263 +++ /dev/null @@ -1,27 +0,0 @@ -puts "==========" -puts "OCC24263" -puts "==========" -puts "" -################################################### -# TNaming_CopyShape::CopyTool failure -################################################### - -box b 100 100 100 -explode b F -if { [regexp "Copy is Done" [CopyShape b b_1] ] != 1 } { - puts "Error : Copy is not done" -} else { - puts "OK : Copy is done" -} - -if { [regexp "SOLID FORWARD" [whatis b_c] ] != 1 } { - puts "Error : b_c is not a solid forward" -} else { - puts "OK : b_c is a solid forward" -} - -if { [regexp "FACE REVERSED" [whatis b_1_c] ] != 1 } { - puts "Error : b_1_c is not a face reversed" -} else { - puts "OK : b_1_c is a face reversed" -} diff --git a/tests/bugs/caf/bug24263_2 b/tests/bugs/caf/bug24263_2 deleted file mode 100644 index ec99d7c41d..0000000000 --- a/tests/bugs/caf/bug24263_2 +++ /dev/null @@ -1,12 +0,0 @@ -puts "==========" -puts "OCC24263" -puts "==========" -puts "" -################################################### -# TNaming_CopyShape::CopyTool failure -################################################### - -box b 100 100 100 -explode b F - -CopyTool b_1 b diff --git a/tests/bugs/caf/bug24645 b/tests/bugs/caf/bug24645 deleted file mode 100644 index c9035f658b..0000000000 --- a/tests/bugs/caf/bug24645 +++ /dev/null @@ -1,45 +0,0 @@ -puts "==========" -puts "OCC24645" -puts "==========" -puts "" -################################################### -# Pointer to the last is wrong for a tree node -################################################### - -NewDocument D -UndoLimit D 1000 - -NewCommand D -SetNode D 0:1 - -NewCommand D -AppendNode D 0:1 0:1:1 -NewCommand D -AppendNode D 0:1 0:1:2 -NewCommand D -AppendNode D 0:1 0:1:3 -NewCommand D -AppendNode D 0:1 0:1:4 - -NewCommand D -AppendNode D 0:1 0:1:5 - -if { [regexp "Last=0:1:5" [XDumpDF D] ] == 1 } { - puts "OK : Last node is good" -} else { - puts "Error : Last node is bad" -} -puts "" - -DetachNode D 0:1:3 -DetachNode D 0:1:4 - -NewCommand D -Undo D - -if { [regexp "Last" [XDumpDF D] ] != 1 } { - puts "OK : Last node is not defined" -} else { - puts "Error : Last node is bad" -} -puts "" diff --git a/tests/bugs/caf/bug24852 b/tests/bugs/caf/bug24852 deleted file mode 100755 index 984e85a88b..0000000000 --- a/tests/bugs/caf/bug24852 +++ /dev/null @@ -1,14 +0,0 @@ -puts "==========" -puts "OCC24852: C r a s h on storage of an Ocaf document in XML file format" -puts "==========" -puts "" - -NewDocument D XmlOcaf - -set aTmpFile ${imagedir}/${casename}.xml -if { [catch {set res [SaveAs D $aTmpFile]}] != 0 } { - puts "Error : Crash on storage of an Ocaf document in XML file format" -} else { - puts "OK : Storage of an Ocaf document in XML file format is good" -} -file delete -force $aTmpFile diff --git a/tests/bugs/caf/bug24869 b/tests/bugs/caf/bug24869 deleted file mode 100644 index 96209bdda6..0000000000 --- a/tests/bugs/caf/bug24869 +++ /dev/null @@ -1,66 +0,0 @@ -puts "==========" -puts "OCC24869" -puts "==========" -puts "" -################################################### -# OCAF testing framework extending -################################################### - -NewDocument D BinOcaf - -#1 - create box1 -NewCommand D -set B1 [AddObject D] -set F1 [AddFunction D $B1 Box] -BoxDX D $B1 100 -BoxDY D $B1 200 -BoxDZ D $B1 300 -InitLogBook D -AddDriver D Box Section PTxyz -ComputeFun D $F1 -GetShape D $F1:2 Box1 - -#1 - create box2 -NewCommand D -set B2 [AddObject D] -set F2 [AddFunction D $B2 Box] -BoxDX D $B2 150 -BoxDY D $B2 200 -BoxDZ D $B2 300 -ComputeFun D $F2 - -NewCommand D -set FTr2 [PTranslateDXYZ D $B2 30 40 50] -ComputeFun D $FTr2 -# get modified result -GetShape D $FTr2:2 Box2 - -#3 Make Section Box1 Box2 -NewCommand D -set CS [AddSection D $B1 $B2] -ComputeFun D $CS -erase -GetShape D $CS:2 S - -# Check result -NewCommand D -erase -ExploreShape D $CS:2:1 R - -# should be 12 edges and 6 vertices -set l1 [llength [directory R_*] ] - -# should be 18 faces -set l2 [llength [directory oldR_*] ] - -if { ${l1} == 18 } { - puts "OK: Good edge number" -} else { - puts "Error: Bad edge number" -} - -if { ${l2} == 18 } { - puts "OK: Good face number" -} else { - puts "Error: Bad face number" -} diff --git a/tests/bugs/caf/bug24925 b/tests/bugs/caf/bug24925 deleted file mode 100644 index fe7f7d1f80..0000000000 --- a/tests/bugs/caf/bug24925 +++ /dev/null @@ -1,38 +0,0 @@ -puts "===========" -puts "OCC24925 Enabling OCAF persistence without setting environment variables" -puts "===========" - -pload QAcommands - -set THE_PLUGIN "TKXml" -set THE_SAVE_DRIVER "03a56820-8269-11d5-aab2-0050044b1af1" -set THE_LOAD_DRIVER "03a56822-8269-11d5-aab2-0050044b1af1" - -set aFileName "$imagedir/${casename}_doc.xml" -if { [file exists "$aFileName"] == 1} { - file delete $aFileName -} - -# corrupt environment variable to Plugin file -set anEnvOld [dgetenv CSF_PluginDefaults] -dsetenv "CSF_PluginDefaults" -set anEnvNow [dgetenv CSF_PluginDefaults] -puts "Unset environment variable CSF_PluginDefaults (old='${anEnvOld}', new='${anEnvNow}')" - -OCC24925 "$aFileName" $THE_PLUGIN $THE_SAVE_DRIVER $THE_LOAD_DRIVER - -if { [file isfile "$aFileName"] == 1} { - set aFile [open "$aFileName" r] - set aFileData [read $aFile] - close $aFile - if { [string first "My Proprietary Format" "$aFileData"] == -1} { - puts "Error: XML file does not contain 'My Proprietary Format'!" - } - if { [string first "QABugs_19.cxx" "$aFileData"] == -1} { - puts "Error: XML file does not contain 'QABugs_19.cxx'!" - } -} else { - puts "Error: file is not created!" -} - -#dsetenv "CSF_PluginDefaults" "anEnvOld" diff --git a/tests/bugs/caf/bug25112 b/tests/bugs/caf/bug25112 deleted file mode 100644 index 4cbb294523..0000000000 --- a/tests/bugs/caf/bug25112 +++ /dev/null @@ -1,27 +0,0 @@ -puts "===========" -puts "OCC25112" -puts "===========" -puts "" -########################################################################### -# Undo of modification of the attribute TDataStd_IntPackedMap works wrong -########################################################################### - -NewDocument D -UndoLimit D 10 -SetIntPackedMap D 0:1 1 319 -puts "initial: [GetIntPackedMap D 0:1]" - -OpenCommand D -ChangeIntPackedMap_Add D 0:1 344 -ChangeIntPackedMap_Rem D 0:1 319 -CommitCommand D -puts "after changes: [GetIntPackedMap D 0:1]" - -Undo D - -set map [GetIntPackedMap D 0:1] -puts "after undo: $map" - -if {$map != "319"} { - puts "ERROR: OCC25112 is reproduced. Expected map content is 319" -} diff --git a/tests/bugs/caf/bug25153 b/tests/bugs/caf/bug25153 deleted file mode 100644 index 58c429af56..0000000000 --- a/tests/bugs/caf/bug25153 +++ /dev/null @@ -1,16 +0,0 @@ -puts "==========" -puts "OCC25123" -puts "==========" -puts "" -################################################### -# Retrieval of arguments of selection crashes the application -################################################### - -plane p 0 0 0 0 0 1 -mkface f p -100 100 -100 100 - -NewDocument D XmlOcaf -ImportShape D 0:1 f -SelectShape D 0:2 f -ForgetAll D 0:1 -ArgsSelection D 0:2 diff --git a/tests/bugs/caf/bug25317 b/tests/bugs/caf/bug25317 deleted file mode 100755 index 9d65c44bb9..0000000000 --- a/tests/bugs/caf/bug25317 +++ /dev/null @@ -1,35 +0,0 @@ -puts "================" -puts "OCC25317" -puts "================" -puts "" -################################################################################################### -# Failure on attempt to save an Ocaf document with a long double array attribute in a Xml file -################################################################################################### - -set i 1 -set nb 50000 - -set FileName $imagedir/${test_image}.xml -file delete ${FileName} -if [file exists ${FileName}] { - puts "Error: There is temporary ${FileName} file" -} - -#Allocate a large array. -NewDocument D XmlOcaf -SetRealArray D 0:1 0 1 $nb - -#Fill-in the large array. -repeat $nb { - SetRealArrayValue D 0:1 $i 1.234 - incr i 1 -} - -#Save the document in XML format. -SaveAs D ${FileName} - -if [file exists ${FileName}] { - puts "OK: There is ${FileName} file" -} else { - puts "Error: There is not ${FileName} file" -} diff --git a/tests/bugs/caf/bug25394_1 b/tests/bugs/caf/bug25394_1 deleted file mode 100755 index 81318cc489..0000000000 --- a/tests/bugs/caf/bug25394_1 +++ /dev/null @@ -1,129 +0,0 @@ -# =================== OCAF ====================== -# Standard attributes of List containers (std format) -# -# Testing purpose: test of set /get & save / restore -# of TDataStd_BooleanList, TDataStd_IntegerList -# TDataStd_RealList, TDataStd_ExtStringList, -# TDataStd_ReferenceList attributes -# -# =============================================== -# Test case: t1 (testing Set /Get attribute with empty list) -# 1. create BooleanList attribute with empty list -# 2. create IntegerList attribute with empty list -# 3. create RealList attribute with empty list -# 4. create ExtStringList attribute with empty list -# 5. create ReferenceList attribute with empty list -# 6. save the Document in external std file -# 7. reopen the Document -# 8. check the restored attributes at the specified labels -# =============================================== - -NewDocument D BinOcaf -# 1. create BooleanList attribute with empty list -set Lab1 [Label D 0:1:1] -SetBooleanList D $Lab1 -set info1 [GetBooleanList D $Lab1] -# output => "List is empty" - -# 2. create IntegerList attribute with empty list -set Lab2 [Label D 0:1:2] -SetIntegerList D $Lab2 -set info2 [GetIntegerList D $Lab2] -# output => "List is empty" - -# 3. create RealList attribute with empty list -set Lab3 [Label D 0:1:3] -SetRealList D $Lab3 -set info3 [GetRealList D $Lab3] -# output => "List is empty" - -# 4. create ExtStringList attribute with empty list -set Lab4 [Label D 0:1:4] -SetExtStringList D $Lab4 -set info4 [GetExtStringList D $Lab4] -# output => "List is empty" - -# 5. create ReferenceList attribute with empty list -set Lab5 [Label D 0:1:5] -SetReferenceList D $Lab5 -set info5 [GetReferenceList D $Lab5] -# output => "List is empty" - -# 6. save the Document in external file -set aTmpFile ${imagedir}/${casename}.cbf -SaveAs D $aTmpFile -Close D - -# 7. reopen the Document -Open $aTmpFile D -file delete -force $aTmpFile - -# 8. Check the restored attributes at the specified labels -set info8 [GetBooleanList D $Lab1] -# output => "List is empty" - -set info9 [GetIntegerList D $Lab2] -# output => "List is empty" - -set info10 [GetRealList D $Lab3] -# output => "List is empty" - -set info11 [GetExtStringList D $Lab4] -# output => "List is empty" - -set info12 [GetReferenceList D $Lab5] -# output => "List is empty" - -Close D - -if { [regexp {List is empty} ${info1}] } { - puts "OK: created BooleanList attribute is good" -} else { - puts "Error: created BooleanList attribute is bad" -} -if { [regexp {List is empty} ${info2}] } { - puts "OK: created IntegerList attribute is good" -} else { - puts "Error: created IntegerList attribute is bad" -} -if { [regexp {List is empty} ${info3}] } { - puts "OK: created RealList attribute is good" -} else { - puts "Error: created RealList attribute is bad" -} -if { [regexp {List is empty} ${info4}] } { - puts "OK: created ExtStringList attribute is good" -} else { - puts "Error: created ExtStringList attribute is bad" -} -if { [regexp {List is empty} ${info5}] } { - puts "OK: created ReferenceList attribute is good" -} else { - puts "Error: created ReferenceList attribute is bad" -} - -if { [regexp {List is empty} ${info8}] } { - puts "OK: restored BooleanList attribute is good" -} else { - puts "Error: restored BooleanList attribute is bad" -} -if { [regexp {List is empty} ${info9}] } { - puts "OK: restored IntegerList attribute is good" -} else { - puts "Error: restored IntegerList attribute is bad" -} -if { [regexp {List is empty} ${info10}] } { - puts "OK: restored RealList attribute is good" -} else { - puts "Error: restored RealList attribute is bad" -} -if { [regexp {List is empty} ${info11}] } { - puts "OK: restored ExtStringList attribute is good" -} else { - puts "Error: restored ExtStringList attribute is bad" -} -if { [regexp {List is empty} ${info12}] } { - puts "OK: restored ReferenceList attribute is good" -} else { - puts "Error: restored ReferenceList attribute is bad" -} diff --git a/tests/bugs/caf/bug25394_2 b/tests/bugs/caf/bug25394_2 deleted file mode 100755 index 9d1632a036..0000000000 --- a/tests/bugs/caf/bug25394_2 +++ /dev/null @@ -1,129 +0,0 @@ -# =================== OCAF ====================== -# Standard attributes of List containers (bin format) -# -# Testing purpose: test of set /get & save / restore -# of TDataStd_BooleanList, TDataStd_IntegerList -# TDataStd_RealList, TDataStd_ExtStringList, -# TDataStd_ReferenceList attributes -# -# =============================================== -# Test case: t2 (testing Set /Get attribute with empty list) -# 1. create BooleanList attribute with empty list -# 2. create IntegerList attribute with empty list -# 3. create RealList attribute with empty list -# 4. create ExtStringList attribute with empty list -# 5. create ReferenceList attribute with empty list -# 6. save the Document in external cbf file -# 7. reopen the Document -# 8. check the restored attributes at the specified labels -# =============================================== - -NewDocument D BinOcaf -# 1. create BooleanList attribute with empty list -set Lab1 [Label D 0:1:1] -SetBooleanList D $Lab1 -set info1 [GetBooleanList D $Lab1] -# output => "List is empty" - -# 2. create IntegerList attribute with empty list -set Lab2 [Label D 0:1:2] -SetIntegerList D $Lab2 -set info2 [GetIntegerList D $Lab2] -# output => "List is empty" - -# 3. create RealList attribute with empty list -set Lab3 [Label D 0:1:3] -SetRealList D $Lab3 -set info3 [GetRealList D $Lab3] -# output => "List is empty" - -# 4. create ExtStringList attribute with empty list -set Lab4 [Label D 0:1:4] -SetExtStringList D $Lab4 -set info4 [GetExtStringList D $Lab4] -# output => "List is empty" - -# 5. create ReferenceList attribute with empty list -set Lab5 [Label D 0:1:5] -SetReferenceList D $Lab5 -set info5 [GetReferenceList D $Lab5] -# output => "List is empty" - -# 6. save the Document in external file -set aTmpFile ${imagedir}/${casename}.cbf -SaveAs D $aTmpFile -Close D - -# 7. reopen the Document -Open $aTmpFile D -file delete -force $aTmpFile - -# 8. Check the restored attributes at the specified labels -set info8 [GetBooleanList D $Lab1] -# output => "List is empty" - -set info9 [GetIntegerList D $Lab2] -# output => "List is empty" - -set info10 [GetRealList D $Lab3] -# output => "List is empty" - -set info11 [GetExtStringList D $Lab4] -# output => "List is empty" - -set info12 [GetReferenceList D $Lab5] -# output => "List is empty" - -Close D - -if { [regexp {List is empty} ${info1}] } { - puts "OK: created BooleanList attribute is good" -} else { - puts "Error: created BooleanList attribute is bad" -} -if { [regexp {List is empty} ${info2}] } { - puts "OK: created IntegerList attribute is good" -} else { - puts "Error: created IntegerList attribute is bad" -} -if { [regexp {List is empty} ${info3}] } { - puts "OK: created RealList attribute is good" -} else { - puts "Error: created RealList attribute is bad" -} -if { [regexp {List is empty} ${info4}] } { - puts "OK: created ExtStringList attribute is good" -} else { - puts "Error: created ExtStringList attribute is bad" -} -if { [regexp {List is empty} ${info5}] } { - puts "OK: created ReferenceList attribute is good" -} else { - puts "Error: created ReferenceList attribute is bad" -} - -if { [regexp {List is empty} ${info8}] } { - puts "OK: restored BooleanList attribute is good" -} else { - puts "Error: restored BooleanList attribute is bad" -} -if { [regexp {List is empty} ${info9}] } { - puts "OK: restored IntegerList attribute is good" -} else { - puts "Error: restored IntegerList attribute is bad" -} -if { [regexp {List is empty} ${info10}] } { - puts "OK: restored RealList attribute is good" -} else { - puts "Error: restored RealList attribute is bad" -} -if { [regexp {List is empty} ${info11}] } { - puts "OK: restored ExtStringList attribute is good" -} else { - puts "Error: restored ExtStringList attribute is bad" -} -if { [regexp {List is empty} ${info12}] } { - puts "OK: restored ReferenceList attribute is good" -} else { - puts "Error: restored ReferenceList attribute is bad" -} diff --git a/tests/bugs/caf/bug25394_3 b/tests/bugs/caf/bug25394_3 deleted file mode 100755 index 74d7114eb7..0000000000 --- a/tests/bugs/caf/bug25394_3 +++ /dev/null @@ -1,129 +0,0 @@ -# =================== OCAF ====================== -# Standard attributes of List containers (xml format) -# -# Testing purpose: test of set /get & save / restore -# of TDataStd_BooleanList, TDataStd_IntegerList -# TDataStd_RealList, TDataStd_ExtStringList, -# TDataStd_ReferenceList attributes -# -# =============================================== -# Test case: t2 (testing Set /Get attribute with empty list) -# 1. create BooleanList attribute with empty list -# 2. create IntegerList attribute with empty list -# 3. create RealList attribute with empty list -# 4. create ExtStringList attribute with empty list -# 5. create ReferenceList attribute with empty list -# 6. save the Document in external xml file -# 7. reopen the Document -# 8. check the restored attributes at the specified labels -# =============================================== - -NewDocument D XmlOcaf -# 1. create BooleanList attribute with empty list -set Lab1 [Label D 0:1:1] -SetBooleanList D $Lab1 -set info1 [GetBooleanList D $Lab1] -# output => "List is empty" - -# 2. create IntegerList attribute with empty list -set Lab2 [Label D 0:1:2] -SetIntegerList D $Lab2 -set info2 [GetIntegerList D $Lab2] -# output => "List is empty" - -# 3. create RealList attribute with empty list -set Lab3 [Label D 0:1:3] -SetRealList D $Lab3 -set info3 [GetRealList D $Lab3] -# output => "List is empty" - -# 4. create ExtStringList attribute with empty list -set Lab4 [Label D 0:1:4] -SetExtStringList D $Lab4 -set info4 [GetExtStringList D $Lab4] -# output => "List is empty" - -# 5. create ReferenceList attribute with empty list -set Lab5 [Label D 0:1:5] -SetReferenceList D $Lab5 -set info5 [GetReferenceList D $Lab5] -# output => "List is empty" - -# 6. save the Document in external file -set aTmpFile ${imagedir}/${casename}.xml -SaveAs D $aTmpFile -Close D - -# 7. reopen the Document -Open $aTmpFile D -file delete -force $aTmpFile - -# 8. Check the restored attributes at the specified labels -set info8 [GetBooleanList D $Lab1] -# output => "List is empty" - -set info9 [GetIntegerList D $Lab2] -# output => "List is empty" - -set info10 [GetRealList D $Lab3] -# output => "List is empty" - -set info11 [GetExtStringList D $Lab4] -# output => "List is empty" - -set info12 [GetReferenceList D $Lab5] -# output => "List is empty" - -Close D - -if { [regexp {List is empty} ${info1}] } { - puts "OK: created BooleanList attribute is good" -} else { - puts "Error: created BooleanList attribute is bad" -} -if { [regexp {List is empty} ${info2}] } { - puts "OK: created IntegerList attribute is good" -} else { - puts "Error: created IntegerList attribute is bad" -} -if { [regexp {List is empty} ${info3}] } { - puts "OK: created RealList attribute is good" -} else { - puts "Error: created RealList attribute is bad" -} -if { [regexp {List is empty} ${info4}] } { - puts "OK: created ExtStringList attribute is good" -} else { - puts "Error: created ExtStringList attribute is bad" -} -if { [regexp {List is empty} ${info5}] } { - puts "OK: created ReferenceList attribute is good" -} else { - puts "Error: created ReferenceList attribute is bad" -} - -if { [regexp {List is empty} ${info8}] } { - puts "OK: restored BooleanList attribute is good" -} else { - puts "Error: restored BooleanList attribute is bad" -} -if { [regexp {List is empty} ${info9}] } { - puts "OK: restored IntegerList attribute is good" -} else { - puts "Error: restored IntegerList attribute is bad" -} -if { [regexp {List is empty} ${info10}] } { - puts "OK: restored RealList attribute is good" -} else { - puts "Error: restored RealList attribute is bad" -} -if { [regexp {List is empty} ${info11}] } { - puts "OK: restored ExtStringList attribute is good" -} else { - puts "Error: restored ExtStringList attribute is bad" -} -if { [regexp {List is empty} ${info12}] } { - puts "OK: restored ReferenceList attribute is good" -} else { - puts "Error: restored ReferenceList attribute is bad" -} diff --git a/tests/bugs/caf/bug25536 b/tests/bugs/caf/bug25536 deleted file mode 100644 index 830883b0c5..0000000000 --- a/tests/bugs/caf/bug25536 +++ /dev/null @@ -1,37 +0,0 @@ -puts "============" -puts "OCC25536: XmlMDataXtd_GeometryDriver doesn't support TDataXtd_SPLINE, TDataXtd_PLANE and TDataXtd_CYLINDER." -puts "============" -puts "" - -NewDocument Doc XmlOcaf - -# set attributes not supported by geometry driver before this issue fix -Label Doc 0:2:1 -SetGeometry Doc 0:2:1 spl -Label Doc 0:2:2 -SetGeometry Doc 0:2:2 pln -Label Doc 0:2:3 -SetGeometry Doc 0:2:3 cyl - -set aTmpFile ${imagedir}/${casename}.xml -SaveAs Doc ${aTmpFile} -Close Doc - -# check attributes are correctly restored -Open ${aTmpFile} Doc2 -file delete -force $aTmpFile - -set aType [GetGeometryType Doc2 0:2:1] -if {${aType} != "spl"} { - puts "Error: Restored Geometry Type '${aType}' is not stored 'spl'" -} -set aType [GetGeometryType Doc2 0:2:2] -if {${aType} != "pln"} { - puts "Error: Restored Geometry Type '${aType}' is not stored 'pln'" -} -set aType [GetGeometryType Doc2 0:2:3] -if {${aType} != "cyl"} { - puts "Error: Restored Geometry Type '${aType}' is not stored 'cyl'" -} - -Close Doc2 diff --git a/tests/bugs/caf/bug25537 b/tests/bugs/caf/bug25537 deleted file mode 100644 index 26a6d46d6f..0000000000 --- a/tests/bugs/caf/bug25537 +++ /dev/null @@ -1,28 +0,0 @@ -puts "============" -puts "OCC25537: XmlMPrsStd_PositionDriver::Paste runtime check c r a s h." -puts "============" -puts "" - -pload XDEDRAW - -NewDocument Doc XmlXCAF - -# number that takes 24 symbols in %.17g string -set aBigNum -0.0000000000123456789123456789 - -# Create TDataXtd_Position and XCAFDoc_Centroid attributes (same problem in writing XML) -# 100 labels to have a stable exception (memory corruption) -for {set i 1} {$i < 100} {incr i} { - set aLab1 0:1:$i - SetPosition Doc $aLab1 $aBigNum $aBigNum $aBigNum - set aLab2 0:2:$i - Label Doc $aLab2 - XSetCentroid Doc $aLab2 $aBigNum $aBigNum $aBigNum -} - -set aTmpFile ${imagedir}/${casename}.xml -SaveAs Doc ${aTmpFile} - -## ==> No exception -Close Doc -file delete -force $aTmpFile diff --git a/tests/bugs/caf/bug26061 b/tests/bugs/caf/bug26061 deleted file mode 100644 index 92852f8d46..0000000000 --- a/tests/bugs/caf/bug26061 +++ /dev/null @@ -1,47 +0,0 @@ -puts "============" -puts "OCC26061" -puts "============" -puts "" -####################################################################### -# TNaming_Selector crash in select method. -####################################################################### - -pload QAcommands - -NewDocument D BinOcaf - -## 1. Build Primitive face -plane pl 0 0 0 0 0 1 -mkface f0 pl -10 10 -10 10 -set Lab900 [Label D 0:1:900] -BuildNamedShape D $Lab900 P f0 - -## 2. Mirror f0 -tmirror f0 0 0 10 0 0 1 -renamevar f0 fmir -GetShape D $Lab900 f0 -set Lab901 [Label D 0:1:901] -BuildNamedShape D $Lab901 G f0 fmir - -## 3. Translate primitive face -ttranslate f0 0 0 -5 -renamevar f0 ftr5 -set Lab902 [Label D 0:1:902] -GetShape D $Lab900 f0 -BuildNamedShape D $Lab902 M f0 ftr5 - -## 4. Translate mirrored face -GetShape D $Lab901 fmir -renamevar fmir fmirtr -ttranslate fmirtr 0 0 -5 -GetShape D $Lab901 fmir -set Lab903 [Label D 0:1:903] -BuildNamedShape D $Lab903 M fmir fmirtr - -## 5. Select the face from step 4 (mirrored & translasted) -set Lab904 [Label D 0:1:904] -GetShape D $Lab903 fSel -SelectShape D $Lab904 fSel -## ==> No exception -GetShape D $Lab904 fRes -whatis fRes diff --git a/tests/bugs/caf/bug261 b/tests/bugs/caf/bug261 deleted file mode 100755 index 0b0bfc4a61..0000000000 --- a/tests/bugs/caf/bug261 +++ /dev/null @@ -1,31 +0,0 @@ -puts "===========" -puts "OCC261" -puts "===========" - -pload QAcommands - -NewDocument D BinOcaf -UndoLimit D 10 -NewCommand D -SetReal D 0:1 10 - -NewCommand D -SetReal D 0:1 20 - -NewCommand D -SetReal D 0:1 30 - -NewCommand D -SetReal D 0:1 40 - -Undo D -Undo D - -OCC261 D - -set Res [UndoLimit D] -if { [regexp " 0" $Res] != 1 } { - puts "OCC261: Error" -} - - diff --git a/tests/bugs/caf/bug26155 b/tests/bugs/caf/bug26155 deleted file mode 100644 index f79a4ca3f7..0000000000 --- a/tests/bugs/caf/bug26155 +++ /dev/null @@ -1,37 +0,0 @@ -puts "============" -puts "OCC26155" -puts "============" -puts "" -################################################################################### -# TNaming, CurrentShape: order of shapes in Modification compound is unpredictable. -################################################################################### - -pload QAcommands - -NewDocument D BinOcaf - -set x_ref 0.0 -set x_tol 0.1 -set result 1 - -for {set i 1} {$i <= 50} {incr i} { - set lab $i:1 - - box b 0 0 0 10 10 10 - box b_1 0 0 0 5 10 10 - box b_2 5 0 0 5 10 10 - - BuildNamedShape D [set lab]:1 PRIMITIVE b - BuildNamedShape D [set lab]:1:1 MODIFY b b_1 - BuildNamedShape D [set lab]:1:2 MODIFY b b_2 - CurrentShape D "[set lab]:1" r - explode r so - regexp {X += +([-0-9.+eE]+)} [vprops r_1 $x_tol] full x_1 - - if { $x_ref == 0 } { - set x_ref $x_1 - } elseif { [expr abs ($x_1 - $x_ref)] > $x_tol } { - puts "Error: order of components of modified shape compound is not permanent." - break - } -} diff --git a/tests/bugs/caf/bug26229_1 b/tests/bugs/caf/bug26229_1 deleted file mode 100644 index bc4fe584ee..0000000000 --- a/tests/bugs/caf/bug26229_1 +++ /dev/null @@ -1,44 +0,0 @@ -puts "================" -puts "OCC26229" -puts "================" -puts "" -################################################################################################### -# Add the possibility in OCAF to open/save a document from/to a stream object (BinOcaf format) -################################################################################################### - -pload OCAF - -NewDocument D BinOcaf - -# Add an attribute to a data framework -set aSetAttr1 100 -set aLabel 0:2 -SetInteger D ${aLabel} ${aSetAttr1} - -# Close/Open the transaction -NewCommand D - -# Save the document -set aFile ${imagedir}/${casename}.cbf -file delete ${aFile} -SaveAs D ${aFile} -stream -if { ![file exists ${aFile}] } { - puts "Error: there is not ${aFile} file; SaveAs command" - return -} - - -# Restore the document -Close D -Open ${aFile} DD -stream - -# Get a value of the attribute -set IsDone [catch {set aGetAttr3 [GetInteger DD ${aLabel}]} aResult] -if { ${IsDone} != 0 || - ${aSetAttr1}!=${aGetAttr3} } { - puts ${aResult} - puts "aSetAttr1=${aSetAttr1} aGetAttr3=${aGetAttr3}" - puts "Error: get a value of TDataStd_Integer attribute from Streamed restoring document" -} else { - puts "Get a value of TDataStd_Integer attribute from Streamed restoring document: OK" -} \ No newline at end of file diff --git a/tests/bugs/caf/bug26229_2 b/tests/bugs/caf/bug26229_2 deleted file mode 100644 index 50a0379203..0000000000 --- a/tests/bugs/caf/bug26229_2 +++ /dev/null @@ -1,44 +0,0 @@ -puts "================" -puts "OCC26229" -puts "================" -puts "" -################################################################################################### -# Add the possibility in OCAF to open/save a document from/to a stream object (XmlOcaf format) -################################################################################################### - -pload OCAF - -NewDocument D XmlOcaf - -# Add an attribute to a data framework -set aSetAttr1 100 -set aLabel 0:2 -SetInteger D ${aLabel} ${aSetAttr1} - -# Close/Open the transaction -NewCommand D - -# Save the document -set aFile ${imagedir}/${casename}.xml -file delete ${aFile} -SaveAs D ${aFile} -stream -if { ![file exists ${aFile}] } { - puts "Error: there is not ${aFile} file; SaveAs command" - return -} - - -# Restore the document -Close D -Open ${aFile} DD -stream - -# Get a value of the attribute -set IsDone [catch {set aGetAttr3 [GetInteger DD ${aLabel}]} aResult] -if { ${IsDone} != 0 || - ${aSetAttr1}!=${aGetAttr3} } { - puts ${aResult} - puts "aSetAttr1=${aSetAttr1} aGetAttr3=${aGetAttr3}" - puts "Error: get a value of TDataStd_Integer attribute from Streamed restoring document" -} else { - puts "Get a value of TDataStd_Integer attribute from Streamed restoring document: OK" -} \ No newline at end of file diff --git a/tests/bugs/caf/bug26428 b/tests/bugs/caf/bug26428 deleted file mode 100644 index 94cfb8c7cd..0000000000 --- a/tests/bugs/caf/bug26428 +++ /dev/null @@ -1,15 +0,0 @@ -puts "============" -puts "OCC26428" -puts "============" -puts "" -################################################################################### -# TNaming_Selector::Solve crash for empty named shape. -################################################################################### - -NewDocument D BinOcaf - -box b 10 20 30 - -CheckNSIter D 0:1 b 1 - -CheckNSIter D 0:1 b 0 diff --git a/tests/bugs/caf/bug267_1 b/tests/bugs/caf/bug267_1 deleted file mode 100644 index 0ab50ac161..0000000000 --- a/tests/bugs/caf/bug267_1 +++ /dev/null @@ -1,10 +0,0 @@ -puts "========" -puts "OCC267" -puts "========" - -NewDocument D BinOcaf - -###################################################################### - -SaveAs D ${imagedir}/${casename}.cbf -file delete -force ${imagedir}/${casename}.cbf diff --git a/tests/bugs/caf/bug27187 b/tests/bugs/caf/bug27187 deleted file mode 100644 index fcf59c0509..0000000000 --- a/tests/bugs/caf/bug27187 +++ /dev/null @@ -1,24 +0,0 @@ -puts "===========" -puts "OCC27187" -puts "===========" -puts "" -################################# -# XmlMFunction_ScopeDriver fail to read and write function label including 0 tag in label path. -################################# - -NewDocument Doc XmlOcaf -# label that contains "0" tag not only in "Root" -set Lab 0:1:4:9999:0:1:4:2001:4:2001:4:1:4:1001:4:1001 -Label Doc $Lab -SetReference Doc 0:1 $Lab - -set aFileName ${imagedir}/${casename}_doc.xml -SaveAs Doc ${aFileName} -Close Doc - -# check that the reference is correctly restored -Open ${aFileName} Doc -if {[GetReference Doc 0:1] != $Lab} { - puts "Error: restored Reference attribute value is bad '[GetReference Doc 0:1]'" -} -Close Doc diff --git a/tests/bugs/caf/bug28425 b/tests/bugs/caf/bug28425 deleted file mode 100644 index 8b8835bca4..0000000000 --- a/tests/bugs/caf/bug28425 +++ /dev/null @@ -1,58 +0,0 @@ -puts "===========" -puts "OCC28425" -puts "===========" -puts "" -############################################################ -# Open/save NamedShape changes order of shapes -############################################################ - -pload QAcommands -set aTestFileBin $imagedir/${casename}.cbf -set aTestFileXml $imagedir/${casename}.xml - -vertex v 1 2 3 -box b 10 20 30 - -# Test bin document -NewDocument D1 BinOcaf -BuildNamedShape D1 0:1 PRIMITIVE v b -GetNewShapes D1 0:1 s -set info [whatis s_1] -if { [regexp "SOLID" $info] != 1 } { - puts "Error: first shape should be solid" -} else { - puts "OK: order of shapes is correct" -} -SaveAs D1 ${aTestFileBin} -Close D1 -Open ${aTestFileBin} D2 -GetNewShapes D2 0:1 s -set info [whatis s_1] -if { [regexp "SOLID" $info] != 1 } { - puts "Error: first shape should be solid" -} else { - puts "OK: order of shapes is correct" -} -Close D2 - -# Test xml document -NewDocument D1 XmlOcaf -BuildNamedShape D1 0:1 PRIMITIVE v b -GetNewShapes D1 0:1 s -set info [whatis s_1] -if { [regexp "SOLID" $info] != 1 } { - puts "Error: first shape should be solid" -} else { - puts "OK: order of shapes is correct" -} -SaveAs D1 ${aTestFileXml} -Close D1 -Open ${aTestFileXml} D2 -GetNewShapes D2 0:1 s -set info [whatis s_1] -if { [regexp "SOLID" $info] != 1 } { - puts "Error: first shape should be solid" -} else { - puts "OK: order of shapes is correct" -} -Close D2 diff --git a/tests/bugs/caf/bug28428 b/tests/bugs/caf/bug28428 deleted file mode 100644 index bd7ca182c1..0000000000 --- a/tests/bugs/caf/bug28428 +++ /dev/null @@ -1,18 +0,0 @@ -puts "===========" -puts "OCC28428: BinMNaming_NamedShapeDriver f a i l s if there are no nodes in NamedShape" -puts "===========" -puts "" - -pload QAcommands - -NewDocument D1 BinOcaf -# Create TNaming_Builder on a label without putthing shapes -BuildNamedShape D1 0:1 P -set aTmpFile ${imagedir}/${casename}.cbf -SaveAs D1 $aTmpFile -Close D1 -# This produced a NamedShape driver failure with catching by general driver -# and output a failure message (caught by parse.rules) -Open $aTmpFile D2 -Close D2 -file delete -force $aTmpFile diff --git a/tests/bugs/caf/bug29142 b/tests/bugs/caf/bug29142 deleted file mode 100644 index 63cf323f2c..0000000000 --- a/tests/bugs/caf/bug29142 +++ /dev/null @@ -1,51 +0,0 @@ -puts "================" -puts "bug0029142" -puts "================" -puts "" - -###################################################### -# Checks bug of Undo mechanism -###################################################### -NewDocument D BinOcaf -UndoLimit D 100 -set Lab1 [Label D 0:1:1] - -#1. Set Integer attribute -NewCommand D -SetInteger D $Lab1 111 - -#2. Set Real attribute -NewCommand D -SetReal D $Lab1 0.234 - -#3. Forget Integer attribute -NewCommand D -ForgetAtt D $Lab1 2a96b606-ec8b-11d0-bee7-080009dc3333 - -#4. Set new Integer attribute -SetInteger D $Lab1 222 -#5. Undo -NewCommand D -set IsGoodUndo 1 -if [catch {Undo D}] { - puts "Error during Document Undo" - set IsGoodUndo 0 -} - -#6. Redo -set IsGoodRedo 1 -if [catch {Redo D}] { - puts "Error during Document Redo" - set IsGoodRedo 0 -} - - -#7. Check result -if {$IsGoodUndo == 1 & $IsGoodRedo == 1} { - puts "bug0029142: OK" -} else { - puts "bug0029142: ERROR" -} - -#8. Close document -Close D \ No newline at end of file diff --git a/tests/bugs/caf/bug2932_1 b/tests/bugs/caf/bug2932_1 deleted file mode 100755 index 13e7a76e5b..0000000000 --- a/tests/bugs/caf/bug2932_1 +++ /dev/null @@ -1,74 +0,0 @@ -puts "================" -puts "OCC2932" -puts "================" -puts "" -####################################################################################### -# Create Attribute Delta depending on actual change of the attribute -####################################################################################### -# Case 8 (TDataStd_IntegerArray) -####################################################################################### - -# Create a new document and set UndoLimit -NewDocument D BinOcaf -UndoLimit D 100 - -# Create a label and set attributes -NewCommand D -set Label 0:2 - -############################################ -set From 1 -set To 2 -set IntegerArray1 3 -set IntegerArray2 4 -############################################ - -set Real1 300. -set Real2 400. -set modified_attribute TDataStd_Real - -############################################ -# Set TDataStd_IntegerArray -SetIntArray D ${Label} ${From} ${To} ${IntegerArray1} ${IntegerArray2} 0 -############################################ - -SetReal D ${Label} ${Real1} -set list [DumpCommand D] - -# Open a transaction -NewCommand D -set list [DumpCommand D] - -############################################ -# Set old value for TDataStd_IntegerArray -SetIntArray D ${Label} ${From} ${To} ${IntegerArray1} ${IntegerArray2} 0 -############################################ - -# Set new value for TDataStd_Real -SetReal D ${Label} ${Real2} -set list [DumpCommand D] - -# Open a transaction -NewCommand D -set list [DumpCommand D] - -# Checking -set ll [llength ${list}] -set good_length 17 -puts "length = ${ll}" -puts "good_length = ${good_length}" - -if { ${ll} != ${good_length} } { - puts "OCC2932 Error (case 1)" -} else { - set name_attribute [lindex ${list} [expr ${good_length} - 1]] - puts "name_attribute = ${name_attribute}" - puts "modified_attribute = ${modified_attribute}" - if {[string compare ${name_attribute} ${modified_attribute}] == 0} { - puts "OCC2932 OK" - } else { - puts "OCC2932 Error (case 2)" - } -} - - diff --git a/tests/bugs/caf/bug2932_10 b/tests/bugs/caf/bug2932_10 deleted file mode 100644 index 2af067c797..0000000000 --- a/tests/bugs/caf/bug2932_10 +++ /dev/null @@ -1,73 +0,0 @@ -puts "================" -puts "OCC2932" -puts "================" -puts "" -####################################################################################### -# Create Attribute Delta depending on actual change of the attribute -####################################################################################### -# Case 8 (TDataStd_IntegerArray) -####################################################################################### - -# Create a new document and set UndoLimit -NewDocument D BinOcaf -UndoLimit D 100 - -# Create a label and set attributes -NewCommand D -set Label 0:2 - -############################################ -set From 1 -set To 2 -set IntegerArray1 3 -set IntegerArray2 4 -set isDelta 0 -############################################ - -set Real1 300. -set Real2 400. -set modified_attribute TDataStd_Real - -############################################ -# Set TDataStd_IntegerArray -SetIntArray D ${Label} ${isDelta} ${From} ${To} ${IntegerArray1} ${IntegerArray2} -############################################ - -SetReal D ${Label} ${Real1} -set list [DumpCommand D] - -# Open a transaction -NewCommand D -set list [DumpCommand D] - -############################################ -# Set old value for TDataStd_IntegerArray -SetIntArray D ${Label} ${isDelta} ${From} ${To} ${IntegerArray1} ${IntegerArray2} -############################################ - -# Set new value for TDataStd_Real -SetReal D ${Label} ${Real2} -set list [DumpCommand D] - -# Open a transaction -NewCommand D -set list [DumpCommand D] - -# Checking -set ll [llength ${list}] -set good_length 17 -puts "length = ${ll}" -puts "good_length = ${good_length}" - -if { ${ll} != ${good_length} } { - puts "OCC2932 Error (case 1)" -} else { - set name_attribute [lindex ${list} [expr ${good_length} - 1]] - puts "name_attribute = ${name_attribute}" - puts "modified_attribute = ${modified_attribute}" - if {[string compare ${name_attribute} ${modified_attribute}] == 0} { - puts "OCC2932 OK" - } else { - puts "OCC2932 Error (case 2)" - } -} diff --git a/tests/bugs/caf/bug2932_11 b/tests/bugs/caf/bug2932_11 deleted file mode 100644 index decd051c37..0000000000 --- a/tests/bugs/caf/bug2932_11 +++ /dev/null @@ -1,70 +0,0 @@ -puts "================" -puts "OCC2932" -puts "================" -puts "" -####################################################################################### -# Create Attribute Delta depending on actual change of the attribute -####################################################################################### -# Case 9 (TDataStd_Name) -####################################################################################### - -# Create a new document and set UndoLimit -NewDocument D BinOcaf -UndoLimit D 100 - -# Create a label and set attributes -NewCommand D -set Label 0:2 - -############################################ -set Name "New Name" -############################################ - -set Real1 300. -set Real2 400. -set modified_attribute TDataStd_Real - -############################################ -# Set TDataStd_Name -Label D ${Label} -SetName D ${Label} ${Name} -############################################ - -SetReal D ${Label} ${Real1} -set list [DumpCommand D] - -# Open a transaction -NewCommand D -set list [DumpCommand D] - -############################################ -# Set old value for TDataStd_Name -SetName D ${Label} ${Name} -############################################ - -# Set new value for TDataStd_Real -SetReal D ${Label} ${Real2} -set list [DumpCommand D] - -# Open a transaction -NewCommand D -set list [DumpCommand D] - -# Checking -set ll [llength ${list}] -set good_length 17 -puts "length = ${ll}" -puts "good_length = ${good_length}" - -if { ${ll} != ${good_length} } { - puts "OCC2932 Error (case 1)" -} else { - set name_attribute [lindex ${list} [expr ${good_length} - 1]] - puts "name_attribute = ${name_attribute}" - puts "modified_attribute = ${modified_attribute}" - if {[string compare ${name_attribute} ${modified_attribute}] == 0} { - puts "OCC2932 OK" - } else { - puts "OCC2932 Error (case 2)" - } -} diff --git a/tests/bugs/caf/bug2932_12 b/tests/bugs/caf/bug2932_12 deleted file mode 100644 index 42b50800ad..0000000000 --- a/tests/bugs/caf/bug2932_12 +++ /dev/null @@ -1,94 +0,0 @@ -puts "================" -puts "OCC2932" -puts "================" -puts "" -####################################################################################### -# Create Attribute Delta depending on actual change of the attribute -####################################################################################### -# Case 10 (TDataStd_PatternStd) -####################################################################################### - -# Create a new document and set UndoLimit -NewDocument D BinOcaf -UndoLimit D 100 - -# Create a label and set attributes -NewCommand D -set Label 0:2 - -############################################ -# Create a box -set X 10 -set Y 20 -set Z 30 -set DX 100 -set DY 200 -set DZ 300 -box Box ${X} ${Y} ${Z} ${DX} ${DY} ${DZ} - -# Set a shape to the label -set BoxLabel 0:3 -SetShape D ${BoxLabel} Box - -# Set a real attribute -set RealLabel 0:4 -set RealPattern 123.456789 -SetReal D ${RealLabel} ${RealPattern} - -# Set an integer attribute -set IntegerLabel 0:5 -set IntegerPattern 123456789 -SetInteger D ${IntegerLabel} ${IntegerPattern} - -# Set a signature -set signature 1 -############################################ - -set Real1 300. -set Real2 400. -set modified_attribute TDataStd_Real - -############################################ -# Set TDataStd_PatternStd -Label D ${Label} -SetPattern D ${Label} ${signature} ${BoxLabel} ${RealLabel} ${IntegerLabel} -############################################ - -SetReal D ${Label} ${Real1} -set list [DumpCommand D] - -# Open a transaction -NewCommand D -set list [DumpCommand D] - -############################################ -# Set old value for TDataStd_PatternStd -SetPattern D ${Label} ${signature} ${BoxLabel} ${RealLabel} ${IntegerLabel} -############################################ - -# Set new value for TDataStd_Real -SetReal D ${Label} ${Real2} -set list [DumpCommand D] - -# Open a transaction -NewCommand D -set list [DumpCommand D] - -# Checking -set ll [llength ${list}] -set good_length 17 -puts "length = ${ll}" -puts "good_length = ${good_length}" - -if { ${ll} != ${good_length} } { - puts "OCC2932 Error (case 1)" -} else { - set name_attribute [lindex ${list} [expr ${good_length} - 1]] - puts "name_attribute = ${name_attribute}" - puts "modified_attribute = ${modified_attribute}" - if {[string compare ${name_attribute} ${modified_attribute}] == 0} { - puts "OCC2932 OK" - } else { - puts "OCC2932 Error (case 2)" - } -} diff --git a/tests/bugs/caf/bug2932_13 b/tests/bugs/caf/bug2932_13 deleted file mode 100644 index b64b685665..0000000000 --- a/tests/bugs/caf/bug2932_13 +++ /dev/null @@ -1,76 +0,0 @@ -puts "================" -puts "OCC2932" -puts "================" -puts "" -####################################################################################### -# Create Attribute Delta depending on actual change of the attribute -####################################################################################### -# Case 11 (TDataStd_Plane) -####################################################################################### - -# Create a new document and set UndoLimit -NewDocument D BinOcaf -UndoLimit D 100 - -# Create a label and set attributes -NewCommand D -set Label 0:2 - -############################################ -# Create a plane -set X 10 -set Y 20 -set Z 30 -set DX -1 -set DY 0 -set DZ 0 -plane Plane ${X} ${Y} ${Z} ${DX} ${DY} ${DZ} -############################################ - -set Real1 300. -set Real2 400. -set modified_attribute TDataStd_Real - -############################################ -# Set TDataStd_Plane -SetPlane D ${Label} Plane -############################################ - -SetReal D ${Label} ${Real1} -set list [DumpCommand D] - -# Open a transaction -NewCommand D -set list [DumpCommand D] - -############################################ -# Set old value for TDataStd_Plane -SetPlane D ${Label} Plane -############################################ - -# Set new value for TDataStd_Real -SetReal D ${Label} ${Real2} -set list [DumpCommand D] - -# Open a transaction -NewCommand D -set list [DumpCommand D] - -# Checking -set ll [llength ${list}] -set good_length 17 -puts "length = ${ll}" -puts "good_length = ${good_length}" - -if { ${ll} != ${good_length} } { - puts "OCC2932 Error (case 1)" -} else { - set name_attribute [lindex ${list} [expr ${good_length} - 1]] - puts "name_attribute = ${name_attribute}" - puts "modified_attribute = ${modified_attribute}" - if {[string compare ${name_attribute} ${modified_attribute}] == 0} { - puts "OCC2932 OK" - } else { - puts "OCC2932 Error (case 2)" - } -} diff --git a/tests/bugs/caf/bug2932_14 b/tests/bugs/caf/bug2932_14 deleted file mode 100644 index a1efeaf684..0000000000 --- a/tests/bugs/caf/bug2932_14 +++ /dev/null @@ -1,73 +0,0 @@ -puts "================" -puts "OCC2932" -puts "================" -puts "" -####################################################################################### -# Create Attribute Delta depending on actual change of the attribute -####################################################################################### -# Case 12 (TDataStd_Point) -####################################################################################### - -# Create a new document and set UndoLimit -NewDocument D BinOcaf -UndoLimit D 100 - -# Create a label and set attributes -NewCommand D -set Label 0:2 - -############################################ -# Create a point -set X 10 -set Y 20 -set Z 30 -point Point ${X} ${Y} ${Z} -############################################ - -set Real1 300. -set Real2 400. -set modified_attribute TDataStd_Real - -############################################ -# Set TDataStd_Point -SetPoint D ${Label} Point -############################################ - -SetReal D ${Label} ${Real1} -set list [DumpCommand D] - -# Open a transaction -NewCommand D -set list [DumpCommand D] - -############################################ -# Set old value for TDataStd_Point -SetPoint D ${Label} Point -############################################ - -# Set new value for TDataStd_Real -SetReal D ${Label} ${Real2} -set list [DumpCommand D] - -# Open a transaction -NewCommand D -set list [DumpCommand D] - -# Checking -set ll [llength ${list}] -set good_length 17 -puts "length = ${ll}" -puts "good_length = ${good_length}" - -if { ${ll} != ${good_length} } { - puts "OCC2932 Error (case 1)" -} else { - set name_attribute [lindex ${list} [expr ${good_length} - 1]] - puts "name_attribute = ${name_attribute}" - puts "modified_attribute = ${modified_attribute}" - if {[string compare ${name_attribute} ${modified_attribute}] == 0} { - puts "OCC2932 OK" - } else { - puts "OCC2932 Error (case 2)" - } -} diff --git a/tests/bugs/caf/bug2932_15 b/tests/bugs/caf/bug2932_15 deleted file mode 100644 index 01b79f16c3..0000000000 --- a/tests/bugs/caf/bug2932_15 +++ /dev/null @@ -1,69 +0,0 @@ -puts "================" -puts "OCC2932" -puts "================" -puts "" -####################################################################################### -# Create Attribute Delta depending on actual change of the attribute -####################################################################################### -# Case 13 (TDataStd_Real) -####################################################################################### - -# Create a new document and set UndoLimit -NewDocument D BinOcaf -UndoLimit D 100 - -# Create a label and set attributes -NewCommand D -set Label 0:2 - -############################################ -set Real 100. -############################################ - -set Integer1 300 -set Integer2 400 -set modified_attribute TDataStd_Integer - -############################################ -# Set TDataStd_Real -SetReal D ${Label} ${Real} -############################################ - -SetInteger D ${Label} ${Integer1} -set list [DumpCommand D] - -# Open a transaction -NewCommand D -set list [DumpCommand D] - -############################################ -# Set old value for TDataStd_Real -SetReal D ${Label} ${Real} -############################################ - -# Set new value for TDataStd_Integer -SetInteger D ${Label} ${Integer2} -set list [DumpCommand D] - -# Open a transaction -NewCommand D -set list [DumpCommand D] - -# Checking -set ll [llength ${list}] -set good_length 17 -puts "length = ${ll}" -puts "good_length = ${good_length}" - -if { ${ll} != ${good_length} } { - puts "OCC2932 Error (case 1)" -} else { - set name_attribute [lindex ${list} [expr ${good_length} - 1]] - puts "name_attribute = ${name_attribute}" - puts "modified_attribute = ${modified_attribute}" - if {[string compare ${name_attribute} ${modified_attribute}] == 0} { - puts "OCC2932 OK" - } else { - puts "OCC2932 Error (case 2)" - } -} diff --git a/tests/bugs/caf/bug2932_16 b/tests/bugs/caf/bug2932_16 deleted file mode 100644 index 2a0abb62d8..0000000000 --- a/tests/bugs/caf/bug2932_16 +++ /dev/null @@ -1,73 +0,0 @@ -puts "================" -puts "OCC2932" -puts "================" -puts "" -####################################################################################### -# Create Attribute Delta depending on actual change of the attribute -####################################################################################### -# Case 14 (TDataStd_RealArray) -####################################################################################### - -# Create a new document and set UndoLimit -NewDocument D BinOcaf -UndoLimit D 100 - -# Create a label and set attributes -NewCommand D -set Label 0:2 - -############################################ -set From 1 -set To 2 -set RealArray1 3. -set RealArray2 4. -set isDelta 0 -############################################ - -set Real1 300. -set Real2 400. -set modified_attribute TDataStd_Real - -############################################ -# Set TDataStd_RealArray -SetRealArray D ${Label} ${isDelta} ${From} ${To} ${RealArray1} ${RealArray2} -############################################ - -SetReal D ${Label} ${Real1} -set list [DumpCommand D] - -# Open a transaction -NewCommand D -set list [DumpCommand D] - -############################################ -# Set old value for TDataStd_RealArray -SetRealArray D ${Label} ${isDelta} ${From} ${To} ${RealArray1} ${RealArray2} -############################################ - -# Set new value for TDataStd_Real -SetReal D ${Label} ${Real2} -set list [DumpCommand D] - -# Open a transaction -NewCommand D -set list [DumpCommand D] - -# Checking -set ll [llength ${list}] -set good_length 17 -puts "length = ${ll}" -puts "good_length = ${good_length}" - -if { ${ll} != ${good_length} } { - puts "OCC2932 Error (case 1)" -} else { - set name_attribute [lindex ${list} [expr ${good_length} - 1]] - puts "name_attribute = ${name_attribute}" - puts "modified_attribute = ${modified_attribute}" - if {[string compare ${name_attribute} ${modified_attribute}] == 0} { - puts "OCC2932 OK" - } else { - puts "OCC2932 Error (case 2)" - } -} diff --git a/tests/bugs/caf/bug2932_17 b/tests/bugs/caf/bug2932_17 deleted file mode 100644 index da1cd7c0aa..0000000000 --- a/tests/bugs/caf/bug2932_17 +++ /dev/null @@ -1,71 +0,0 @@ -puts "================" -puts "OCC2932" -puts "================" -puts "" -####################################################################################### -# Create Attribute Delta depending on actual change of the attribute -####################################################################################### -# Case 15 (TDataStd_Relation) -####################################################################################### - -pload QAcommands - -# Create a new document and set UndoLimit -NewDocument D BinOcaf -UndoLimit D 100 - -# Create a label and set attributes -NewCommand D -set Label 0:2 - -############################################ -set Relation "New Relation" -############################################ - -set Real1 300. -set Real2 400. -set modified_attribute TDataStd_Real - -############################################ -# Set TDataStd_Relation -OCC2932_SetRelation D ${Label} ${Relation} -############################################ - -SetReal D ${Label} ${Real1} -set list [DumpCommand D] - -# Open a transaction -NewCommand D -set list [DumpCommand D] - -############################################ -# Set old value for TDataStd_Relation -OCC2932_SetRelation D ${Label} ${Relation} -############################################ - -# Set new value for TDataStd_Real -SetReal D ${Label} ${Real2} -set list [DumpCommand D] - -# Open a transaction -NewCommand D -set list [DumpCommand D] - -# Checking -set ll [llength ${list}] -set good_length 17 -puts "length = ${ll}" -puts "good_length = ${good_length}" - -if { ${ll} != ${good_length} } { - puts "OCC2932 Error (case 1)" -} else { - set name_attribute [lindex ${list} [expr ${good_length} - 1]] - puts "name_attribute = ${name_attribute}" - puts "modified_attribute = ${modified_attribute}" - if {[string compare ${name_attribute} ${modified_attribute}] == 0} { - puts "OCC2932 OK" - } else { - puts "OCC2932 Error (case 2)" - } -} diff --git a/tests/bugs/caf/bug2932_18 b/tests/bugs/caf/bug2932_18 deleted file mode 100644 index 821b5cd0a7..0000000000 --- a/tests/bugs/caf/bug2932_18 +++ /dev/null @@ -1,115 +0,0 @@ -puts "================" -puts "OCC2932" -puts "================" -puts "" -####################################################################################### -# Create Attribute Delta depending on actual change of the attribute -####################################################################################### -# Case 16 (TDataStd_Shape) -####################################################################################### - -# Create a new document and set UndoLimit -NewDocument D BinOcaf -UndoLimit D 100 - -# Create a label and set attributes -NewCommand D -set Label 0:2 - -############################################ -# Create a box -set X 10 -set Y 20 -set Z 30 -set DX 100 -set DY 200 -set DZ 300 -box Box ${X} ${Y} ${Z} ${DX} ${DY} ${DZ} -############################################ - -set Real1 300. -set Real2 400. -set modified_attribute TDataStd_Real - -############################################ -# Set TDataStd_Shape -SetShape D ${Label} Box -############################################ - -SetReal D ${Label} ${Real1} -set list [DumpCommand D] - -# Open a transaction -NewCommand D -set list [DumpCommand D] - -############################################ -# Set old value for TDataStd_Shape -SetShape D ${Label} Box -############################################ - -# Set new value for TDataStd_Real -SetReal D ${Label} ${Real2} -set list [DumpCommand D] - -# Open a transaction -NewCommand D -set list [DumpCommand D] - -# Checking -if { 1 == 2 } { -set ll [llength ${list}] -set good_length 17 -puts "length = ${ll}" -puts "good_length = ${good_length}" - -if { ${ll} != ${good_length} } { - puts "OCC2932 Error (case 1)" -} else { - set name_attribute [lindex ${list} [expr ${good_length} - 1]] - puts "name_attribute = ${name_attribute}" - puts "modified_attribute = ${modified_attribute}" - if {[string compare ${name_attribute} ${modified_attribute}] == 0} { - puts "OCC2932 OK" - } else { - puts "OCC2932 Error (case 2)" - } -} -} - -# NEW VERSION!!!!! -set ll [llength ${list}] -set good_length 20 -puts "length = ${ll}" -puts "good_length = ${good_length}" - -if { ${ll} != ${good_length} } { - puts "OCC2932 Error (case 1)" -} else { - set name_attribute1 [lindex ${list} [expr ${good_length} - 1]] - set name_attribute2 [lindex ${list} [expr ${good_length} - 4]] - set modified_attribute2 TNaming_NamedShape - puts "name_attribute1 = ${name_attribute1}" - puts "name_attribute2 = ${name_attribute2}" - puts "modified_attribute = ${modified_attribute}" - puts "modified_attribute2 = ${modified_attribute2}" - - set Is_TDataStd_Real 0 - set Is_TNaming_NamedShape 0 - if {[string compare ${name_attribute1} ${modified_attribute}] == 0 || - [string compare ${name_attribute2} ${modified_attribute}] == 0 } { - set Is_TDataStd_Real 1 - } - if {[string compare ${name_attribute1} ${modified_attribute2}] == 0 || - [string compare ${name_attribute2} ${modified_attribute2}] == 0 } { - set Is_TNaming_NamedShape 1 - } - - - if { ${Is_TDataStd_Real} == 1 && ${Is_TNaming_NamedShape} == 1 } { - puts "OCC2932 OK" - } else { - puts "OCC2932 Error (case 2)" - } - -} diff --git a/tests/bugs/caf/bug2932_19 b/tests/bugs/caf/bug2932_19 deleted file mode 100644 index 20d7983837..0000000000 --- a/tests/bugs/caf/bug2932_19 +++ /dev/null @@ -1,73 +0,0 @@ -puts "================" -puts "OCC2932" -puts "================" -puts "" -####################################################################################### -# Create Attribute Delta depending on actual change of the attribute -####################################################################################### -# Case 18 (TDataStd_Variable) -####################################################################################### - -# Create a new document and set UndoLimit -NewDocument D BinOcaf -UndoLimit D 100 - -# Create a label and set attributes -NewCommand D -set Label 0:2 - -############################################ -# Set isConstant -set isConstant 1 - -# Set a units -set units "kg/m3" -############################################ - -set Real1 300. -set Real2 400. -set modified_attribute TDataStd_Real - -############################################ -# Set TDataStd_Variable -SetVariable D ${Label} ${isConstant} ${units} -############################################ - -SetReal D ${Label} ${Real1} -set list [DumpCommand D] - -# Open a transaction -NewCommand D -set list [DumpCommand D] - -############################################ -# Set old value for TDataStd_Variable -SetVariable D ${Label} ${isConstant} ${units} -############################################ - -# Set new value for TDataStd_Real -SetReal D ${Label} ${Real2} -set list [DumpCommand D] - -# Open a transaction -NewCommand D -set list [DumpCommand D] - -# Checking -set ll [llength ${list}] -set good_length 17 -puts "length = ${ll}" -puts "good_length = ${good_length}" - -if { ${ll} != ${good_length} } { - puts "OCC2932 Error (case 1)" -} else { - set name_attribute [lindex ${list} [expr ${good_length} - 1]] - puts "name_attribute = ${name_attribute}" - puts "modified_attribute = ${modified_attribute}" - if {[string compare ${name_attribute} ${modified_attribute}] == 0} { - puts "OCC2932 OK" - } else { - puts "OCC2932 Error (case 2)" - } -} diff --git a/tests/bugs/caf/bug2932_2 b/tests/bugs/caf/bug2932_2 deleted file mode 100755 index 10d89a8923..0000000000 --- a/tests/bugs/caf/bug2932_2 +++ /dev/null @@ -1,72 +0,0 @@ -puts "================" -puts "OCC2932" -puts "================" -puts "" -####################################################################################### -# Create Attribute Delta depending on actual change of the attribute -####################################################################################### -# Case 14 (TDataStd_RealArray) -####################################################################################### - -# Create a new document and set UndoLimit -NewDocument D BinOcaf -UndoLimit D 100 - -# Create a label and set attributes -NewCommand D -set Label 0:2 - -############################################ -set From 1 -set To 2 -set RealArray1 3. -set RealArray2 4. -############################################ - -set Real1 300. -set Real2 400. -set modified_attribute TDataStd_Real - -############################################ -# Set TDataStd_RealArray -SetRealArray D ${Label} 0 ${From} ${To} ${RealArray1} ${RealArray2} -############################################ - -SetReal D ${Label} ${Real1} -set list [DumpCommand D] - -# Open a transaction -NewCommand D -set list [DumpCommand D] - -############################################ -# Set old value for TDataStd_RealArray -SetRealArray D ${Label} 0 ${From} ${To} ${RealArray1} ${RealArray2} -############################################ - -# Set new value for TDataStd_Real -SetReal D ${Label} ${Real2} -set list [DumpCommand D] - -# Open a transaction -NewCommand D -set list [DumpCommand D] - -# Checking -set ll [llength ${list}] -set good_length 17 -puts "length = ${ll}" -puts "good_length = ${good_length}" - -if { ${ll} != ${good_length} } { - puts "OCC2932 Error (case 1)" -} else { - set name_attribute [lindex ${list} [expr ${good_length} - 1]] - puts "name_attribute = ${name_attribute}" - puts "modified_attribute = ${modified_attribute}" - if {[string compare ${name_attribute} ${modified_attribute}] == 0} { - puts "OCC2932 OK" - } else { - puts "OCC2932 Error (case 2)" - } -} diff --git a/tests/bugs/caf/bug2932_20 b/tests/bugs/caf/bug2932_20 deleted file mode 100644 index 413719ebea..0000000000 --- a/tests/bugs/caf/bug2932_20 +++ /dev/null @@ -1,70 +0,0 @@ -puts "================" -puts "OCC2932" -puts "================" -puts "" -####################################################################################### -# Create Attribute Delta depending on actual change of the attribute -####################################################################################### -# Case 19 (TDF_Reference) -####################################################################################### - -# Create a new document and set UndoLimit -NewDocument D BinOcaf -UndoLimit D 100 - -# Create a label and set attributes -NewCommand D -set Label 0:2 - -############################################ -set Reference 0:3 -############################################ - -set Real1 300. -set Real2 400. -set modified_attribute TDataStd_Real - -############################################ -# Set TDF_Reference -Label D ${Reference} -SetReference D ${Label} ${Reference} -############################################ - -SetReal D ${Label} ${Real1} -set list [DumpCommand D] - -# Open a transaction -NewCommand D -set list [DumpCommand D] - -############################################ -# Set old value for TDF_Reference -SetReference D ${Label} ${Reference} -############################################ - -# Set new value for TDataStd_Real -SetReal D ${Label} ${Real2} -set list [DumpCommand D] - -# Open a transaction -NewCommand D -set list [DumpCommand D] - -# Checking -set ll [llength ${list}] -set good_length 17 -puts "length = ${ll}" -puts "good_length = ${good_length}" - -if { ${ll} != ${good_length} } { - puts "OCC2932 Error (case 1)" -} else { - set name_attribute [lindex ${list} [expr ${good_length} - 1]] - puts "name_attribute = ${name_attribute}" - puts "modified_attribute = ${modified_attribute}" - if {[string compare ${name_attribute} ${modified_attribute}] == 0} { - puts "OCC2932 OK" - } else { - puts "OCC2932 Error (case 2)" - } -} diff --git a/tests/bugs/caf/bug2932_21 b/tests/bugs/caf/bug2932_21 deleted file mode 100644 index 7a1e53c11c..0000000000 --- a/tests/bugs/caf/bug2932_21 +++ /dev/null @@ -1,71 +0,0 @@ -puts "================" -puts "OCC2932" -puts "================" -puts "" -####################################################################################### -# Create Attribute Delta depending on actual change of the attribute -####################################################################################### -# Case 20 (TDF_TagSource) -####################################################################################### - -pload QAcommands - -# Create a new document and set UndoLimit -NewDocument D BinOcaf -UndoLimit D 100 - -# Create a label and set attributes -NewCommand D -set Label 0:2 - -############################################ -set Tag 5 -############################################ - -set Real1 300. -set Real2 400. -set modified_attribute TDataStd_Real - -############################################ -# Set TDF_TagSource -OCC2932_SetTag D ${Label} ${Tag} -############################################ - -SetReal D ${Label} ${Real1} -set list [DumpCommand D] - -# Open a transaction -NewCommand D -set list [DumpCommand D] - -############################################ -# Set old value for TDF_TagSource -OCC2932_SetTag D ${Label} ${Tag} -############################################ - -# Set new value for TDataStd_Real -SetReal D ${Label} ${Real2} -set list [DumpCommand D] - -# Open a transaction -NewCommand D -set list [DumpCommand D] - -# Checking -set ll [llength ${list}] -set good_length 17 -puts "length = ${ll}" -puts "good_length = ${good_length}" - -if { ${ll} != ${good_length} } { - puts "OCC2932 Error (case 1)" -} else { - set name_attribute [lindex ${list} [expr ${good_length} - 1]] - puts "name_attribute = ${name_attribute}" - puts "modified_attribute = ${modified_attribute}" - if {[string compare ${name_attribute} ${modified_attribute}] == 0} { - puts "OCC2932 OK" - } else { - puts "OCC2932 Error (case 2)" - } -} diff --git a/tests/bugs/caf/bug2932_22 b/tests/bugs/caf/bug2932_22 deleted file mode 100644 index 89c005fa8c..0000000000 --- a/tests/bugs/caf/bug2932_22 +++ /dev/null @@ -1,73 +0,0 @@ -puts "================" -puts "OCC2932" -puts "================" -puts "" -####################################################################################### -# Create Attribute Delta depending on actual change of the attribute -####################################################################################### -# Case 21 (TFunction_Function) -####################################################################################### - -# Create a new document and set UndoLimit -NewDocument D BinOcaf -UndoLimit D 100 - -# Create a label and set attributes -NewCommand D -set Label 0:2 - -############################################ -# Set a driver guid -set driverGuid "5b35ca00-5b78-11d1-8940-080009dc3333" - -# Set a failure -set failureNb 13 -############################################ - -set Real1 300. -set Real2 400. -set modified_attribute TDataStd_Real - -############################################ -# Set TFunction_Function -SetFunction D ${Label} ${driverGuid} ${failureNb} -############################################ - -SetReal D ${Label} ${Real1} -set list [DumpCommand D] - -# Open a transaction -NewCommand D -set list [DumpCommand D] - -############################################ -# Set old value for TFunction_Function -SetFunction D ${Label} ${driverGuid} ${failureNb} -############################################ - -# Set new value for TDataStd_Real -SetReal D ${Label} ${Real2} -set list [DumpCommand D] - -# Open a transaction -NewCommand D -set list [DumpCommand D] - -# Checking -set ll [llength ${list}] -set good_length 17 -puts "length = ${ll}" -puts "good_length = ${good_length}" - -if { ${ll} != ${good_length} } { - puts "OCC2932 Error (case 1)" -} else { - set name_attribute [lindex ${list} [expr ${good_length} - 1]] - puts "name_attribute = ${name_attribute}" - puts "modified_attribute = ${modified_attribute}" - if {[string compare ${name_attribute} ${modified_attribute}] == 0} { - puts "OCC2932 OK" - } else { - puts "OCC2932 Error (case 2)" - } -} diff --git a/tests/bugs/caf/bug2932_24 b/tests/bugs/caf/bug2932_24 deleted file mode 100644 index 3d829dd242..0000000000 --- a/tests/bugs/caf/bug2932_24 +++ /dev/null @@ -1,72 +0,0 @@ -puts "================" -puts "OCC2932" -puts "================" -puts "" -####################################################################################### -# Create Attribute Delta depending on actual change of the attribute -####################################################################################### -# Case 23 (TPrsStd_Position) -####################################################################################### - -# Create a new document and set UndoLimit -NewDocument D BinOcaf -UndoLimit D 100 - -# Create a label and set attributes -NewCommand D -set Label 0:2 - -############################################ -# Set a coordinates -set X 123.456 -set Y 789.012 -set Z 345.678 -############################################ - -set Real1 300. -set Real2 400. -set modified_attribute TDataStd_Real - -############################################ -# Set TPrsStd_Position -SetPosition D ${Label} ${X} ${Y} ${Z} -############################################ - -SetReal D ${Label} ${Real1} -set list [DumpCommand D] - -# Open a transaction -NewCommand D -set list [DumpCommand D] - -############################################ -# Set old value for TPrsStd_Position -SetPosition D ${Label} ${X} ${Y} ${Z} -############################################ - -# Set new value for TDataStd_Real -SetReal D ${Label} ${Real2} -set list [DumpCommand D] - -# Open a transaction -NewCommand D -set list [DumpCommand D] - -# Checking -set ll [llength ${list}] -set good_length 17 -puts "length = ${ll}" -puts "good_length = ${good_length}" - -if { ${ll} != ${good_length} } { - puts "OCC2932 Error (case 1)" -} else { - set name_attribute [lindex ${list} [expr ${good_length} - 1]] - puts "name_attribute = ${name_attribute}" - puts "modified_attribute = ${modified_attribute}" - if {[string compare ${name_attribute} ${modified_attribute}] == 0} { - puts "OCC2932 OK" - } else { - puts "OCC2932 Error (case 2)" - } -} diff --git a/tests/bugs/caf/bug2932_3 b/tests/bugs/caf/bug2932_3 deleted file mode 100644 index 5426af492c..0000000000 --- a/tests/bugs/caf/bug2932_3 +++ /dev/null @@ -1,75 +0,0 @@ -puts "================" -puts "OCC2932" -puts "================" -puts "" -####################################################################################### -# Create Attribute Delta depending on actual change of the attribute -####################################################################################### -# Case 1 (TDataStd_Axis) -####################################################################################### - -# Create a new document and set UndoLimit -NewDocument D BinOcaf -UndoLimit D 100 - -# Create a label and set attributes -NewCommand D -set Label 0:2 - -############################################ -set X 10 -set Y 20 -set Z 30 -set DX 100 -set DY 200 -set DZ 300 -line Line ${X} ${Y} ${Z} ${DX} ${DY} ${DZ} -############################################ - -set Real1 300. -set Real2 400. -set modified_attribute TDataStd_Real - -############################################ -# Set TDataStd_Axis -SetAxis D ${Label} Line -############################################ - -SetReal D ${Label} ${Real1} -set list [DumpCommand D] - -# Open a transaction -NewCommand D -set list [DumpCommand D] - -############################################ -# Set old value for TDataStd_Axis -SetAxis D ${Label} Line -############################################ - -# Set new value for TDataStd_Real -SetReal D ${Label} ${Real2} -set list [DumpCommand D] - -# Open a transaction -NewCommand D -set list [DumpCommand D] - -# Checking -set ll [llength ${list}] -set good_length 17 -puts "length = ${ll}" -puts "good_length = ${good_length}" - -if { ${ll} != ${good_length} } { - puts "OCC2932 Error (case 1)" -} else { - set name_attribute [lindex ${list} [expr ${good_length} - 1]] - puts "name_attribute = ${name_attribute}" - puts "modified_attribute = ${modified_attribute}" - if {[string compare ${name_attribute} ${modified_attribute}] == 0} { - puts "OCC2932 OK" - } else { - puts "OCC2932 Error (case 2)" - } -} diff --git a/tests/bugs/caf/bug2932_4 b/tests/bugs/caf/bug2932_4 deleted file mode 100644 index 29637202a2..0000000000 --- a/tests/bugs/caf/bug2932_4 +++ /dev/null @@ -1,69 +0,0 @@ -puts "================" -puts "OCC2932" -puts "================" -puts "" -####################################################################################### -# Create Attribute Delta depending on actual change of the attribute -####################################################################################### -# Case 2 (TDataStd_Comment) -####################################################################################### - -# Create a new document and set UndoLimit -NewDocument D BinOcaf -UndoLimit D 100 - -# Create a label and set attributes -NewCommand D -set Label 0:2 - -############################################ -set Comment "New Comment" -############################################ - -set Real1 300. -set Real2 400. -set modified_attribute TDataStd_Real - -############################################ -# Set TDataStd_Comment -SetComment D ${Label} ${Comment} -############################################ - -SetReal D ${Label} ${Real1} -set list [DumpCommand D] - -# Open a transaction -NewCommand D -set list [DumpCommand D] - -############################################ -# Set old value for TDataStd_Comment -SetComment D ${Label} ${Comment} -############################################ - -# Set new value for TDataStd_Real -SetReal D ${Label} ${Real2} -set list [DumpCommand D] - -# Open a transaction -NewCommand D -set list [DumpCommand D] - -# Checking -set ll [llength ${list}] -set good_length 17 -puts "length = ${ll}" -puts "good_length = ${good_length}" - -if { ${ll} != ${good_length} } { - puts "OCC2932 Error (case 1)" -} else { - set name_attribute [lindex ${list} [expr ${good_length} - 1]] - puts "name_attribute = ${name_attribute}" - puts "modified_attribute = ${modified_attribute}" - if {[string compare ${name_attribute} ${modified_attribute}] == 0} { - puts "OCC2932 OK" - } else { - puts "OCC2932 Error (case 2)" - } -} diff --git a/tests/bugs/caf/bug2932_5 b/tests/bugs/caf/bug2932_5 deleted file mode 100644 index ca9d8e1c3a..0000000000 --- a/tests/bugs/caf/bug2932_5 +++ /dev/null @@ -1,91 +0,0 @@ -puts "================" -puts "OCC2932" -puts "================" -puts "" -####################################################################################### -# Create Attribute Delta depending on actual change of the attribute -####################################################################################### -# Case 3 (TDataStd_Constraint) -####################################################################################### - -# Create a new document and set UndoLimit -NewDocument D BinOcaf -UndoLimit D 100 - -# Create a label and set attributes -NewCommand D -set Label 0:2 - -############################################ -# Create a box -set X 10 -set Y 20 -set Z 30 -set DX 100 -set DY 200 -set DZ 300 -box Box ${X} ${Y} ${Z} ${DX} ${DY} ${DZ} - -# Set a shape to the label -set BoxLabel 0:3 -SetShape D ${BoxLabel} Box - -# Set integer attribute -set Integer 10 -set IntegerLabel 0:4 -SetInteger D ${IntegerLabel} ${Integer} - -############################################ - -set Real1 300. -set Real2 400. -set modified_attribute TDataStd_Real - -############################################ -# Set TDataStd_Constraint -Label D ${Label} -SetConstraint D ${Label} "tan" ${BoxLabel} -SetConstraint D ${Label} "plane" ${BoxLabel} -SetConstraint D ${Label} "value" ${IntegerLabel} -############################################ - -SetReal D ${Label} ${Real1} -set list [DumpCommand D] - -# Open a transaction -NewCommand D -set list [DumpCommand D] - -############################################ -# Set old value for TDataStd_Constraint -SetConstraint D ${Label} "tan" ${BoxLabel} -SetConstraint D ${Label} "plane" ${BoxLabel} -SetConstraint D ${Label} "value" ${IntegerLabel} -############################################ - -# Set new value for TDataStd_Real -SetReal D ${Label} ${Real2} -set list [DumpCommand D] - -# Open a transaction -NewCommand D -set list [DumpCommand D] - -# Checking -set ll [llength ${list}] -set good_length 17 -puts "length = ${ll}" -puts "good_length = ${good_length}" - -if { ${ll} != ${good_length} } { - puts "OCC2932 Error (case 1)" -} else { - set name_attribute [lindex ${list} [expr ${good_length} - 1]] - puts "name_attribute = ${name_attribute}" - puts "modified_attribute = ${modified_attribute}" - if {[string compare ${name_attribute} ${modified_attribute}] == 0} { - puts "OCC2932 OK" - } else { - puts "OCC2932 Error (case 2)" - } -} diff --git a/tests/bugs/caf/bug2932_6 b/tests/bugs/caf/bug2932_6 deleted file mode 100644 index d446fced8c..0000000000 --- a/tests/bugs/caf/bug2932_6 +++ /dev/null @@ -1,71 +0,0 @@ -puts "================" -puts "OCC2932" -puts "================" -puts "" -####################################################################################### -# Create Attribute Delta depending on actual change of the attribute -####################################################################################### -# Case 4 (TDataStd_Current) -####################################################################################### - -pload QAcommands - -# Create a new document and set UndoLimit -NewDocument D BinOcaf -UndoLimit D 100 - -# Create a label and set attributes -NewCommand D -set Label 0:2 - -############################################ -# -############################################ - -set Real1 300. -set Real2 400. -set modified_attribute TDataStd_Real - -############################################ -# Set TDataStd_Current -OCC2932_SetCurrent D ${Label} -############################################ - -SetReal D ${Label} ${Real1} -set list [DumpCommand D] - -# Open a transaction -NewCommand D -set list [DumpCommand D] - -############################################ -# Set old value for TDataStd_Current -OCC2932_SetCurrent D ${Label} -############################################ - -# Set new value for TDataStd_Real -SetReal D ${Label} ${Real2} -set list [DumpCommand D] - -# Open a transaction -NewCommand D -set list [DumpCommand D] - -# Checking -set ll [llength ${list}] -set good_length 17 -puts "length = ${ll}" -puts "good_length = ${good_length}" - -if { ${ll} != ${good_length} } { - puts "OCC2932 Error (case 1)" -} else { - set name_attribute [lindex ${list} [expr ${good_length} - 1]] - puts "name_attribute = ${name_attribute}" - puts "modified_attribute = ${modified_attribute}" - if {[string compare ${name_attribute} ${modified_attribute}] == 0} { - puts "OCC2932 OK" - } else { - puts "OCC2932 Error (case 2)" - } -} diff --git a/tests/bugs/caf/bug2932_7 b/tests/bugs/caf/bug2932_7 deleted file mode 100644 index e8d2af4d66..0000000000 --- a/tests/bugs/caf/bug2932_7 +++ /dev/null @@ -1,70 +0,0 @@ -puts "================" -puts "OCC2932" -puts "================" -puts "" -####################################################################################### -# Create Attribute Delta depending on actual change of the attribute -####################################################################################### -# Case 5 (TDataStd_Expression) -####################################################################################### - -pload QAcommands - -# Create a new document and set UndoLimit -NewDocument D BinOcaf -UndoLimit D 100 - -# Create a label and set attributes -NewCommand D -set Label 0:2 - -############################################ -set Expression "New Expression" -############################################ - -set Real1 300. -set Real2 400. -set modified_attribute TDataStd_Real - -############################################ -OCC2932_SetExpression D ${Label} ${Expression} -############################################ - -SetReal D ${Label} ${Real1} -set list [DumpCommand D] - -# Open a transaction -NewCommand D -set list [DumpCommand D] - -############################################ -# Set old value for TDataStd_Expression -OCC2932_SetExpression D ${Label} ${Expression} -############################################ - -# Set new value for TDataStd_Real -SetReal D ${Label} ${Real2} -set list [DumpCommand D] - -# Open a transaction -NewCommand D -set list [DumpCommand D] - -# Checking -set ll [llength ${list}] -set good_length 17 -puts "length = ${ll}" -puts "good_length = ${good_length}" - -if { ${ll} != ${good_length} } { - puts "OCC2932 Error (case 1)" -} else { - set name_attribute [lindex ${list} [expr ${good_length} - 1]] - puts "name_attribute = ${name_attribute}" - puts "modified_attribute = ${modified_attribute}" - if {[string compare ${name_attribute} ${modified_attribute}] == 0} { - puts "OCC2932 OK" - } else { - puts "OCC2932 Error (case 2)" - } -} diff --git a/tests/bugs/caf/bug2932_8 b/tests/bugs/caf/bug2932_8 deleted file mode 100644 index 50ed06341f..0000000000 --- a/tests/bugs/caf/bug2932_8 +++ /dev/null @@ -1,116 +0,0 @@ -puts "================" -puts "OCC2932" -puts "================" -puts "" -####################################################################################### -# Create Attribute Delta depending on actual change of the attribute -####################################################################################### -# Case 6 (TDataStd_Geometry) -####################################################################################### - -# Create a new document and set UndoLimit -NewDocument D BinOcaf -UndoLimit D 100 - -# Create a label and set attributes -NewCommand D -set Label 0:2 - -############################################ -# Create a box -set X 10 -set Y 20 -set Z 30 -set DX 100 -set DY 200 -set DZ 300 -box Box ${X} ${Y} ${Z} ${DX} ${DY} ${DZ} -############################################ - -set Real1 300. -set Real2 400. -set modified_attribute TDataStd_Real - -############################################ -# Set TDataStd_Geometry -Label D ${Label} -SetGeometry D ${Label} "pnt" ${Box} -############################################ - -SetReal D ${Label} ${Real1} -set list [DumpCommand D] - -# Open a transaction -NewCommand D -set list [DumpCommand D] - -############################################ -# Set old value for TDataStd_Geometry -SetGeometry D ${Label} "pnt" ${Box} -############################################ - -# Set new value for TDataStd_Real -SetReal D ${Label} ${Real2} -set list [DumpCommand D] - -# Open a transaction -NewCommand D -set list [DumpCommand D] - -# Checking -if { 1 == 2 } { -set ll [llength ${list}] -set good_length 17 -puts "length = ${ll}" -puts "good_length = ${good_length}" - -if { ${ll} != ${good_length} } { - puts "OCC2932 Error (case 1)" -} else { - set name_attribute [lindex ${list} [expr ${good_length} - 1]] - puts "name_attribute = ${name_attribute}" - puts "modified_attribute = ${modified_attribute}" - if {[string compare ${name_attribute} ${modified_attribute}] == 0} { - puts "OCC2932 OK" - } else { - puts "OCC2932 Error (case 2)" - } -} -} - -# NEW VERSION!!!!! -set ll [llength ${list}] -set good_length 20 -puts "length = ${ll}" -puts "good_length = ${good_length}" - -if { ${ll} != ${good_length} } { - puts "OCC2932 Error (case 1)" -} else { - set name_attribute1 [lindex ${list} [expr ${good_length} - 1]] - set name_attribute2 [lindex ${list} [expr ${good_length} - 4]] - set modified_attribute2 TNaming_NamedShape - puts "name_attribute1 = ${name_attribute1}" - puts "name_attribute2 = ${name_attribute2}" - puts "modified_attribute = ${modified_attribute}" - puts "modified_attribute2 = ${modified_attribute2}" - - set Is_TDataStd_Real 0 - set Is_TNaming_NamedShape 0 - if {[string compare ${name_attribute1} ${modified_attribute}] == 0 || - [string compare ${name_attribute2} ${modified_attribute}] == 0 } { - set Is_TDataStd_Real 1 - } - if {[string compare ${name_attribute1} ${modified_attribute2}] == 0 || - [string compare ${name_attribute2} ${modified_attribute2}] == 0 } { - set Is_TNaming_NamedShape 1 - } - - - if { ${Is_TDataStd_Real} == 1 && ${Is_TNaming_NamedShape} == 1 } { - puts "OCC2932 OK" - } else { - puts "OCC2932 Error (case 2)" - } - -} diff --git a/tests/bugs/caf/bug2932_9 b/tests/bugs/caf/bug2932_9 deleted file mode 100644 index 7b391945c5..0000000000 --- a/tests/bugs/caf/bug2932_9 +++ /dev/null @@ -1,69 +0,0 @@ -puts "================" -puts "OCC2932" -puts "================" -puts "" -####################################################################################### -# Create Attribute Delta depending on actual change of the attribute -####################################################################################### -# Case 7 (TDataStd_Integer) -####################################################################################### - -# Create a new document and set UndoLimit -NewDocument D BinOcaf -UndoLimit D 100 - -# Create a label and set attributes -NewCommand D -set Label 0:2 - -############################################ -set Integer 100 -############################################ - -set Real1 300. -set Real2 400. -set modified_attribute TDataStd_Real - -############################################ -# Set TDataStd_Integer -SetInteger D ${Label} ${Integer} -############################################ - -SetReal D ${Label} ${Real1} -set list [DumpCommand D] - -# Open a transaction -NewCommand D -set list [DumpCommand D] - -############################################ -# Set old value for TDataStd_Integer -SetInteger D ${Label} ${Integer} -############################################ - -# Set new value for TDataStd_Real -SetReal D ${Label} ${Real2} -set list [DumpCommand D] - -# Open a transaction -NewCommand D -set list [DumpCommand D] - -# Checking -set ll [llength ${list}] -set good_length 17 -puts "length = ${ll}" -puts "good_length = ${good_length}" - -if { ${ll} != ${good_length} } { - puts "OCC2932 Error (case 1)" -} else { - set name_attribute [lindex ${list} [expr ${good_length} - 1]] - puts "name_attribute = ${name_attribute}" - puts "modified_attribute = ${modified_attribute}" - if {[string compare ${name_attribute} ${modified_attribute}] == 0} { - puts "OCC2932 OK" - } else { - puts "OCC2932 Error (case 2)" - } -} diff --git a/tests/bugs/caf/bug29669 b/tests/bugs/caf/bug29669 deleted file mode 100644 index be0c470b4f..0000000000 --- a/tests/bugs/caf/bug29669 +++ /dev/null @@ -1,41 +0,0 @@ -puts " =================================================================== " -puts " 0029669: Crash on opening a document with same Ocaf attributes with different IDs" -puts " =================================================================== " -puts "" - -set aLabel 0:1 - -set aVal1 123 -set aVal2 321 - -set aGuid1 "12e94541-6dbc-11d4-b9c8-0060b0ee281b" -set aGuid2 "12e94541-6dbc-11d4-b9c8-0060b0ee281d" - -foreach format {{XmlOcaf xml} {BinOcaf cbf}} { - - NewDocument D [lindex $format 0] - - SetInteger D $aLabel $aVal1 $aGuid1 - SetInteger D $aLabel 100 - SetInteger D $aLabel $aVal2 $aGuid2 - - set aFile ${imagedir}/${casename}.[lindex $format 1] - SaveAs D $aFile - Close D - - if { ! [file exists $aFile] } { - puts "Error: cannot find file $aFile, document not saved" - } - - Open $aFile D - set val1 [GetInteger D $aLabel $aGuid1] - set val2 [GetInteger D $aLabel $aGuid2] - if { $val1 != $aVal1 } { - puts "Error: found $val1 while expected $aVal1" - } - if { $val2 != $aVal2 } { - puts "Error: found $val2 while expected $aVal2" - } - Close D -} - diff --git a/tests/bugs/caf/bug29901 b/tests/bugs/caf/bug29901 deleted file mode 100644 index 8018945c3a..0000000000 --- a/tests/bugs/caf/bug29901 +++ /dev/null @@ -1,46 +0,0 @@ -puts "============" -puts "0029901: Support save to and restore from Stream interface in TObj package" -puts "============" - -set status 0 -set BugNumber 29901 -pload TOBJ - -# Create a new document -TObjNew TD1 -TObjAddObj TD1 obj1 -TObjSetVal TD1 obj1 ${BugNumber} - -# Save the document -set aFile $imagedir/${test_image}-[file tail [info script]].cbf -catch {[file delete ${aFile}]} -catch {TObjSave TD1 ${aFile} -stream} -if { ![file exists ${aFile}] } { - set status 1 - puts "There is not ${aFile} file; TObjSave command: Error" - puts "bug${BugNumber}: ERROR" -} else { - puts "Save the document to ${aFile} file" -} - -TObjClose TD1 -unset TD1 - -# Restore the document -if [catch { TObjLoad TD2 ${aFile} -stream} catch_result] { - puts "bug${BugNumber}: ERROR" -} - -# check stored single integer value -set retInt [TObjGetVal TD2 obj1 -i] -if { $retInt != ${BugNumber} } { - set status 1 - puts "bug${BugNumber}: check stored single integer value; ERROR" -} - -if { ${status} != 0 } { - puts "Faulty bug${BugNumber}" -} else { - puts "OK bug${BugNumber}" -} - diff --git a/tests/bugs/caf/bug31323 b/tests/bugs/caf/bug31323 deleted file mode 100644 index 091552ce58..0000000000 --- a/tests/bugs/caf/bug31323 +++ /dev/null @@ -1,36 +0,0 @@ -puts "============" -puts "0031323: OCAF, TObj - TObj_OcafObjectIterator does not go recursively to children if type argument is used" -puts "============" -puts "" - -pload TOBJ QAcommands - -# create document with object and 3 levels of sub-objects -TObjNew TD1 -TObjAddObj TD1 obj -TObjAddChild TD1 obj sub1 -TObjAddChild TD1 obj sub2 -TObjAddChild TD1 sub1 sub11 -TObjAddChild TD1 sub1 sub12 -TObjAddChild TD1 sub1 sub13 -TObjAddChild TD1 sub12 sub121 - -# Check iteration without sub-children -set flat_list [TObjGetChildren TD1 obj] -if {[llength $flat_list] != 2} { - puts "Error : there must be two elements for the childrens only iteration, but got '$flat_list'" -} else { - if {[lsort $flat_list] != "sub1 sub2"} { - puts "Error : not all elements found in the flat list iteration. Must be 'sub1 sub2', but got '$flat_list'" - } -} - -# Check iteration with all sub-children -set all_subs [TObjGetChildren TD1 obj -all] -if {[llength $all_subs] != 6} { - puts "Error : there must be six elements for the all levels of childrens iteration, but got '$all_subs'" -} else { - if {[lsort $all_subs] != "sub1 sub11 sub12 sub121 sub13 sub2"} { - puts "Error : not all elements found in the flat list iteration. Must be 'sub1 sub11 sub12 sub121 sub13 sub2', but got '$all_subs'" - } -} diff --git a/tests/bugs/caf/bug31785 b/tests/bugs/caf/bug31785 deleted file mode 100644 index e4c64b5109..0000000000 --- a/tests/bugs/caf/bug31785 +++ /dev/null @@ -1,10 +0,0 @@ -puts "===========" -puts "0031785: \[REGRESSION\] Application Framework - application crashes on reading XBF document in background thread" -puts "===========" - -pload XDE QAcommands -XNewDoc D -XSave D ${imagedir}/bug31785.xbf -Close D - -OCC31785 ${imagedir}/bug31785.xbf diff --git a/tests/bugs/caf/bug31839_1 b/tests/bugs/caf/bug31839_1 deleted file mode 100644 index b72372ba09..0000000000 --- a/tests/bugs/caf/bug31839_1 +++ /dev/null @@ -1,141 +0,0 @@ -puts "===========" -puts "0031839: Application Framework - Add ability to partially load OCAF document" -puts "===========" - -# This test checks partial opening of the document with integer and real attributes -# and then partial appending (reading into the same document). - -NewDocument D0 BinOcaf -UndoLimit D0 10 - -# number of labels of objects in the document -set labs 100 -# number of sub-labels of each object -set sublabs 10 - -NewCommand D0 - -# store at each object-label sub-labels with two attributes at each -set creation_time [lindex [time { - for {set i 1} {$i <= $labs} {incr i} { - set lab [Label D0 0:1:${i}] - SetName D0 ${lab} Object$i - for {set ii 1} {$ii <= $sublabs} {incr ii} { - set sublab [Label D0 ${lab}:$ii] - SetInteger D0 ${sublab} 10 - SetReal D0 ${sublab} 12.3 - } - } -}] 0] - -set commit_time [lindex [time { - CommitCommand D0 -}] 0] - - -puts "Tree creation time $creation_time mcs" -puts "Creation commit time $commit_time mcs" - -set docname ${imagedir}/doc_${casename}.cbf -SaveAs D0 ${docname} -Close D0 - -set open_time [lindex [time { - Open ${docname} D1 -}] 0] - -puts "Full document open time $open_time mcs" - -set attributes [Attributes D1 0:1:1:1] -if {[lsearch $attributes TDataStd_Real] < 0 || [lsearch $attributes TDataStd_Integer] < 0} { - puts "Error: full document is opened incorrectly" -} - -Close D1 - -set open_noint_time [lindex [time { - Open ${docname} D2 -skipTDataStd_Integer -}] 0] - -puts "Document without integers open time $open_noint_time mcs" - -set attributes [Attributes D2 0:1:1:1] -if {[lsearch $attributes TDataStd_Real] < 0 || [lsearch $attributes TDataStd_Integer] >= 0} { - puts "Error: document open without integers contains wrong attributes" -} - -set open_oneint_time [lindex [time { - Open ${docname} D2 -append -read0:1:1:1 -}] 0] - -puts "Read of one integer time $open_oneint_time mcs" - -set attributes [Attributes D2 0:1:1:1] -if {[lsearch $attributes TDataStd_Real] < 0 || [lsearch $attributes TDataStd_Integer] < 0} { - puts "Error: document open with one integer contains wrong attributes" -} - -set attributes [Attributes D2 0:1:1:10] -if {[lsearch $attributes TDataStd_Real] < 0 || [lsearch $attributes TDataStd_Integer] >= 0} { - puts "Error: document open with one integer contains wrong attributes at label 10" -} - -set open_nineint_time [lindex [time { - Open ${docname} D2 -append -read0:1:1 -}] 0] -puts "Read of nine integer time $open_nineint_time mcs" - -set attributes [Attributes D2 0:1:1:10] -if {[lsearch $attributes TDataStd_Real] < 0 || [lsearch $attributes TDataStd_Integer] < 0} { - puts "Error: document open with nine integer contains wrong attributes at label 10" -} - -set attributes [Attributes D2 0:1:1:5] -if {[lsearch $attributes TDataStd_Real] < 0 || [lsearch $attributes TDataStd_Integer] < 0} { - puts "Error: document open with nine integer contains wrong attributes at label 5" -} - -set attributes [Attributes D2 0:1:2:5] -if {[lsearch $attributes TDataStd_Real] < 0 || [lsearch $attributes TDataStd_Integer] >= 0} { - puts "Error: document open with nine integer contains wrong attributes at the second object" -} - -SetInteger D2 0:1:1:5 21 -SetReal D2 0:1:1:7 32.1 - -set open_overwrite_time [lindex [time { - Open ${docname} D2 -overwrite -read0:1:1 -}] 0] -puts "Overwrite of ten integers time $open_overwrite_time mcs" - - -set value [GetInteger D2 0:1:1:5] -if {$value != 10} { - puts "Error: integer is overwritten incorrectly" -} - -set value [GetReal D2 0:1:1:7] -if {$value != 12.3} { - puts "Error: real is overwritten incorrectly" -} - -SetInteger D2 0:1:1:5 21 -SetReal D2 0:1:1:7 32.1 - -set open_append_time [lindex [time { - Open ${docname} D2 -append -read0:1:1 -}] 0] -puts "Append of ten integers time $open_overwrite_time mcs" - - -set value [GetInteger D2 0:1:1:5] -if {$value != 21} { - puts "Error: integer is overwritten by append" -} - -set value [GetReal D2 0:1:1:7] -if {$value != 32.1} { - puts "Error: real is overwritten by append" -} - -Close D2 diff --git a/tests/bugs/caf/bug31839_2 b/tests/bugs/caf/bug31839_2 deleted file mode 100644 index d72cdb1af1..0000000000 --- a/tests/bugs/caf/bug31839_2 +++ /dev/null @@ -1,55 +0,0 @@ -puts "===========" -puts "0031839: Application Framework - Add ability to partially load OCAF document" -puts "===========" - -# This test checks partial opening of the document shapes, append and overwrite modes -# for them checking that after overwrite the shapes keep shared topology. - -NewDocument D0 BinOcaf -UndoLimit D0 10 - -NewCommand D0 - -box b 1 2 3 -explode b F - -SetShape D0 0:1 b -for {set i 1} {$i <= 6} {incr i} { - set lab [Label D0 0:1:${i}] - SetShape D0 ${lab} b_${i} -} - -CommitCommand D0 - -set docname ${imagedir}/doc_${casename}.cbf -SaveAs D0 ${docname} -Close D0 - -# open document with shapes skipped -Open ${docname} D1 -skipTNaming_NamedShape -if {![catch {GetShape D1 0:1 b1}]} { - puts "Error: found box at the label 0:1, but it should not be there" -} -if {![catch {GetShape D1 0:1:1 f0}]} { - puts "Error: found face at the label 0:1:1, but it should not be there" -} - -# append one face -Open ${docname} D1 -append -read0:1:1 - -if {[catch {GetShape D1 0:1:1 f1}]} { - puts "Error: Can not find face at the label 0:1:1" -} -if {![catch {GetShape D1 0:1:2 f2}]} { - puts "Error: found face at the label 0:1:2, but it should not be there" -} - -# append others, rewrite the first face -Open ${docname} D1 -overwrite -GetShape D1 0:1 box -GetShape D1 0:1:1 f11 - -set same [CheckSame box f11 F] -if {$same == ""} { - puts "Error: shapes loaded in append mode do not share subshapes (so, face at 0:1:1 was not replaced)" -} diff --git a/tests/bugs/caf/bug31918_1 b/tests/bugs/caf/bug31918_1 deleted file mode 100644 index d2f59ce574..0000000000 --- a/tests/bugs/caf/bug31918_1 +++ /dev/null @@ -1,100 +0,0 @@ -puts "===========" -puts "0031918: Application Framework - New binary format for fast reading part of OCAF document" -puts "===========" - -set docname ${imagedir}/doc_${casename}.cbfl - -NewDocument D0 BinLOcaf -UndoLimit D0 10 - -NewCommand D0 - -# set an array 1000 values from 100 to 1099 -set values "100 " -for {set i 101} {$i < 1100} {incr i} {set values "$values $i"} - -# set 100 arrays to sub-labels of 0:1 0:2 0:3 and 0:4 -for {set lab 1} {$lab <= 4} {incr lab} { - for {set sublab 1} {$sublab <= 100} {incr sublab} { - set command "SetIntArray D0 0:$lab:$sublab 0 1 1000 $values" - eval $command - SetReal D0 0:$lab:$sublab 0.1 - } -} - -CommitCommand D0 - -SaveAs D0 ${docname} -Close D0 - -# Computes the elapsed time of open and close document with a given arguments (as text). -# It launches 10 iteration, 10 actions in each. Returns time of average time of the minimum-time iteration. -proc action_time args { - global docname - set min_time 1000000 - for {set iter 0} {$iter < 10} {incr iter} { - set iter_time [lindex [time { - Open ${docname} D {*}$args - Close D - } 10] 0] - puts "Iteration time $iter_time mcs" - if {$iter_time < $min_time} { - set min_time $iter_time - } - } - - return $min_time -} - -set whole_time [action_time] -puts "Whole document open time $whole_time mcs" - -set quarter_time [action_time -read0:2] -puts "Quarter of document open time $quarter_time mcs" - -# Check that open of quarter of the document is significantly faster than open of whole. -if { [expr $quarter_time * 1.5] > $whole_time } { - puts "Error : loading of quarter of the document content too slow relatively to the whole document load" -} - -set four_quarters_time [action_time -read0:1 -read0:2 -read0:3 -read0:4] -puts "Four quarters of document open time $four_quarters_time mcs" - -# Check that open of four quarters of the document is not too much slower than opening of the whole document. -if { [expr $four_quarters_time * 0.9] > $whole_time } { - puts "Error : loading of four quarters of the document content too slow relatively to the whole document load" -} - -set no_arrays_time [lindex [time { - Open ${docname} D4 -skipTDataStd_IntegerArray -read0:2 -}] 0] -puts "Quarter of document without arrays open time $no_arrays_time mcs" - -set attrs [Attributes D4 0:2:13] -if {"${attrs}" != "TDataStd_Real "} { - puts "Error : loading of document skipping arrays contains invalid attributes list '${attrs}'" -} - -if {![catch {Attributes D4 0:1:1:13}] || ![catch {Attributes D4 0:1:3:14}] || ![catch {Attributes D4 0:1:4:1}]} { - puts "Error : loading of document skipping arrays and sub-trees contains invalid attributes list" -} - -# check for appending arrays to the document from the file -set append_arrays_time [lindex [time { - Open ${docname} D4 -append -readTDataStd_IntegerArray -read0:2 -read0:3 -}] 0] -puts "Half of document arrays open time $append_arrays_time mcs" - -set attrs [Attributes D4 0:2:13] -if {"${attrs}" != "TDataStd_Real TDataStd_IntegerArray "} { - puts "Error : loading of document reading arrays separately contains invalid attributes list '${attrs}'" -} -set attrs [Attributes D4 0:3:1] -if {"${attrs}" != "TDataStd_IntegerArray "} { - puts "Error : loading of document reading arrays separately contains invalid attributes list on subtree 3 '${attrs}'" -} -if {![catch {Attributes D4 0:1:1:13}] || ![catch {Attributes D4 0:1:4:1}]} { - puts "Error : loading of document reading arrays separately contains invalid attributes list on 1 and 4 subtrees" -} - -Close D4 diff --git a/tests/bugs/caf/bug31920 b/tests/bugs/caf/bug31920 deleted file mode 100644 index 9d5a19cfff..0000000000 --- a/tests/bugs/caf/bug31920 +++ /dev/null @@ -1,22 +0,0 @@ -puts "===========" -puts "0031920: Application Framework - speed up methods of getting label by entry and vice versa" -puts "===========" - -NewDocument D -set entry 0:2 -set value 5 -SetInteger D $entry 5 -set checkvalue1 [GetInteger D $entry] -if { $value != $checkvalue1 } { - puts "Set a value of TDataStd_Integer attribute: Error" - return -} - -SetAccessByEntry D 1 -set checkvalue2 [GetInteger D $entry] -if { $value != $checkvalue2 } { - puts "Fast access to label by entry: Error" - return -} - -puts "Fast access to label by entry: OK" diff --git a/tests/bugs/caf/bug387 b/tests/bugs/caf/bug387 deleted file mode 100755 index 3cc7f5bc65..0000000000 --- a/tests/bugs/caf/bug387 +++ /dev/null @@ -1,23 +0,0 @@ -puts "===========" -puts "OCC387" -puts "SAM1452" -puts "===========" - -NewDocument D BinOcaf -UndoLimit D 10 -NewCommand D -SetVariable D 0:1 0 a -SetRelation D 0:1 a=10 0:1 -SetReal D 0:1 10 - -NewCommand D -SetRelation D 0:1 a=20 0:1 -SetReal D 0:1 20 -NewCommand D -Undo D -set Res [DumpRelation D 0:1] - -if { [regexp "a=20" $Res] == 1 } { - puts "OCC387: Error " -} - diff --git a/tests/bugs/caf/bug425 b/tests/bugs/caf/bug425 deleted file mode 100755 index 3cfbd8f2d1..0000000000 --- a/tests/bugs/caf/bug425 +++ /dev/null @@ -1,54 +0,0 @@ -puts "===========" -puts "OCC425" -puts "OCC414" -puts "===========" -###################################################### -# Exception on attempt to save a document that contains empty TDataStd_Name -###################################################### -# Crash on NT during document saving (SAM1344-#2153) -###################################################### - -set IsGood 1 - -NewDocument D BinOcaf -UndoLimit D 10 - -# Add an attribute to a data framework -set aSetAttr1 "" -set aLabel 0:2 -Label D ${aLabel} -SetName D ${aLabel} ${aSetAttr1} - -# Close/Open the transaction -NewCommand D - -# Save the document -set aFile ${imagedir}/${casename}.cbf -SaveAs D ${aFile} -if { ![file exists ${aFile}] } { - puts "There is not ${aFile} file; SaveAs command: Error" - set IsGood 0 -} - -# Restore the document -Close D -Open ${aFile} DD -file delete -force ${aFile} - -# Get a value of the attribute -set aGetAttr3 "" -set IsDone [catch {set aGetAttr3 [GetName DD ${aLabel}]} aResult] -if { ${IsDone} != 0 } { - puts "OCC425: Error" - set IsGood 0 -} -if { ${aSetAttr1}!=${aGetAttr3} } { - puts "aSetAttr1=${aSetAttr1} aGetAttr3=${aGetAttr3}" - puts "Get a value of TDataStd_Name attribute from restoring document: Error" - set IsGood 0 -} - -if { ${IsGood} != 1 } { - puts "OCC425: Error" -} - diff --git a/tests/bugs/caf/bug644 b/tests/bugs/caf/bug644 deleted file mode 100644 index 8e0a901943..0000000000 --- a/tests/bugs/caf/bug644 +++ /dev/null @@ -1,30 +0,0 @@ -puts "=================" -puts "OCC644" -puts "SAM1513" -puts "=================" -puts "" - -NewDocument D -UndoLimit D 10 - -NewCommand D -SetVariable D 0:1 0 mm -SetRelation D 0:2 x=10 0:1 - -NewCommand D -SetRelation D 0:2 x=20 0:1 - -NewCommand D -Undo D -Redo D -Undo D - -set RelationList [DumpRelation D 0:2] - -if {[llength ${RelationList}] <= 10} { - puts "OCC644: OK" -} else { - puts "OCC644: ERROR" -} - - diff --git a/tests/bugs/caf/bug9746 b/tests/bugs/caf/bug9746 deleted file mode 100755 index ab0679529e..0000000000 --- a/tests/bugs/caf/bug9746 +++ /dev/null @@ -1,174 +0,0 @@ -puts "TODO OCC12345 ALL: Dump1 : Faulty" -puts "TODO OCC12345 ALL: Dump2 : Faulty" -puts "TODO OCC12345 ALL: Dump3 : Faulty" -puts "TODO OCC12345 ALL: Dump4 : Faulty" -puts "TODO OCC12345 ALL: Dump5 : Faulty" -puts "TODO OCC12345 ALL: Dump6 : Faulty" -puts "TODO OCC12345 ALL: Faulty OCC9746" - -puts "============" -puts "OCC9746" -puts "============" -puts "" -####################################################################### -# Incorrect writing of integer array in BinMNaming_NamingDriver::Paste -####################################################################### - -set BugNumber OCC9746 - -# Create a new document -NewDocument D BinOcaf - -box b 130 111 145 -ttranslate b 35 1 1 -pcylinder cyl 50 120 230 -ttranslate cyl 1 1 75 - -set aLab1 [ImportShape D 0:2 b Box1] -set aLab2 [ImportShape D 0:3 cyl Cylinder] - -GetShape D $aLab1 S -explode S F -set BoxNamLab [Label D 0:4] -SelectShape D $BoxNamLab:1 S_1 S -SelectShape D $BoxNamLab:2 S_2 S -SelectShape D $BoxNamLab:3 S_3 S -SelectShape D $BoxNamLab:4 S_4 S -SelectShape D $BoxNamLab:5 S_5 S -SelectShape D $BoxNamLab:6 S_6 S - -GetShape D $aLab2 C -explode C F -set CylNamLab [Label D 0:5] -SelectShape D $CylNamLab:1 C_1 C -SelectShape D $CylNamLab:2 C_2 C - -explode S E -SelectShape D $BoxNamLab:10 S_1 S -SelectShape D $BoxNamLab:11 S_3 S - -explode S V -SelectShape D $BoxNamLab:21 S_3 S -SelectShape D $BoxNamLab:22 S_5 S - -explode C V -SelectShape D $CylNamLab:10 C_1 C -SelectShape D $CylNamLab:11 C_2 C -SelectShape D $CylNamLab:12 C_3 C - -# Save the document -set aFile ${imagedir}/${casename}.cbf -SaveAs D ${aFile} -if { ![file exists ${aFile}] } { - puts "There is not ${aFile} file; SaveAs command: Error" - puts "${BugNumber}: ERROR (case 1)" -} - -Close D - -# Restore the document -catch {Open ${aFile} DDoc} -file delete -force ${aFile} - -# -set BoxNamLab [Label DDoc 0:4] -set CylNamLab [Label DDoc 0:5] - -# one Naming argument -Attachment DDoc $BoxNamLab:1 -Attachment DDoc $BoxNamLab:2 -Attachment DDoc $BoxNamLab:3 -Attachment DDoc $BoxNamLab:4 -Attachment DDoc $BoxNamLab:5 -Attachment DDoc $BoxNamLab:6 - -# two Naming arguments -Attachment DDoc $BoxNamLab:10 -Attachment DDoc $BoxNamLab:11 -GetShape DDoc $BoxNamLab:10 -GetShape DDoc $BoxNamLab:11 - -# three naming arguments -Attachment DDoc $BoxNamLab:21 -Attachment DDoc $BoxNamLab:22 -GetShape DDoc $BoxNamLab:21 -GetShape DDoc $BoxNamLab:22 - -# one naming argument -Attachment DDoc $CylNamLab:1 -Attachment DDoc $CylNamLab:2 -GetShape DDoc $CylNamLab:1 -GetShape DDoc $CylNamLab:2 - -# three naming arguments -Attachment DDoc $CylNamLab:10 -GetShape DDoc $CylNamLab:10 -set Dump1 [DumpSelection DDoc $CylNamLab:10] -set Dump2 [DumpSelection DDoc $CylNamLab:10:1] - -Attachment DDoc $CylNamLab:11 -GetShape DDoc $CylNamLab:11 -set Dump3 [DumpSelection DDoc $CylNamLab:11] -set Dump4 [DumpSelection DDoc $CylNamLab:10:1] - -Attachment DDoc $CylNamLab:12 -GetShape DDoc $CylNamLab:12 -set Dump5 [DumpSelection DDoc $CylNamLab:12] -set Dump6 [DumpSelection DDoc $CylNamLab:12:1] - -# -set Good_Dump1 "IDENTITY VERTEX 0:5:10:1 Stop 0:5:10:1\n" -set Good_Dump2 "INTERSECTION VERTEX 0:3:5 0:3:1 0:3:2 Stop 0:3:2\n" -set Good_Dump3 "IDENTITY VERTEX 0:5:11:1 Stop 0:5:11:1\n" -set Good_Dump4 "INTERSECTION VERTEX 0:3:5 0:3:1 0:3:2 Stop 0:3:2\n" -set Good_Dump5 "IDENTITY VERTEX 0:5:12:1 Stop 0:5:12:1\n" -set Good_Dump6 "INTERSECTION VERTEX 0:3:3 0:3:5 0:3:1 Stop 0:3:1\n" -# - -# Checking -set status 0 -puts "" -if { ${Dump1} != ${Good_Dump1} } { - set status 1 - puts "Dump1 : Faulty" -} else { - puts "Dump1 : OK" -} -if { ${Dump2} != ${Good_Dump2} } { - set status 1 - puts "Dump2 : Faulty" -} else { - puts "Dump2 : OK" -} -if { ${Dump3} != ${Good_Dump3} } { - set status 1 - puts "Dump3 : Faulty" -} else { - puts "Dump3 : OK" -} -if { ${Dump4} != ${Good_Dump4} } { - set status 1 - puts "Dump4 : Faulty" -} else { - puts "Dump4 : OK" -} -if { ${Dump5} != ${Good_Dump5} } { - set status 1 - puts "Dump5 : Faulty" -} else { - puts "Dump5 : OK" -} -if { ${Dump6} != ${Good_Dump6} } { - set status 1 - puts "Dump6 : Faulty" -} else { - puts "Dump6 : OK" -} - -# Resume -puts "" -if { ${status} != 0 } { - puts "Faulty ${BugNumber}" -} else { - puts "OK ${BugNumber}" -} diff --git a/tests/bugs/demo/bug14673_4 b/tests/bugs/demo/bug14673_4 deleted file mode 100644 index 54987074f4..0000000000 --- a/tests/bugs/demo/bug14673_4 +++ /dev/null @@ -1,28 +0,0 @@ -puts "# ============================================================" -puts "# 0014673: Provide true support for Unicode symbols" -puts "# ============================================================" -puts "" -puts "# Check that non-Ascii text strings can be saved and restored in OCAF" - -puts "# Prepare OCAF document with text strings in different languages" -set strings [list "test" "l'épreuve" "опыт" "테스트" "größten 市"] - -pload OCAF -NewDocument D XmlOcaf -set i 0 -foreach str $strings { - SetName D 0:[incr i] $str -} - -puts "# Save it and load back, then check the strings" -SaveAs D $imagedir/${casename}.xml -Close D -Open $imagedir/${casename}.xml D - -set i 0 -foreach str $strings { - set res [GetName D 0:[incr i]] - if { $res != $str } { - puts "Error: string $str was restored as $res" - } -} diff --git a/tests/bugs/demo/bug23130 b/tests/bugs/demo/bug23130 deleted file mode 100755 index 5c5a3f5b68..0000000000 --- a/tests/bugs/demo/bug23130 +++ /dev/null @@ -1,66 +0,0 @@ -puts "============" -puts "OCC23130" -puts "============" -puts "" -########################################################################### -# command "maxtolerance" doesn't work on Windows -########################################################################### - -box b 100 100 100 - -set info [maxtolerance b] - -regexp {nbFaces:+([-0-9.+eE]+)} $info full nbF -regexp {nbEdges:+([-0-9.+eE]+)} $info full nbE -regexp {nbVtx:+([-0-9.+eE]+)} $info full nbV - -regexp {Face +: +Min +([-0-9.+eE]+) +Max +([-0-9.+eE]+) } $info full minF maxF -regexp {Edge +: +Min +([-0-9.+eE]+) +Max +([-0-9.+eE]+) } $info full minE maxE -regexp {Vertex +: +Min +([-0-9.+eE]+) +Max +([-0-9.+eE]+) } $info full minV maxV - -puts "nbF=${nbF}" -puts "nbE=${nbE}" -puts "nbV=${nbV}" - -puts "minF=${minF}" -puts "maxF=${maxF}" - -puts "minE=${minE}" -puts "maxE=${maxE}" - -puts "minV=${minV}" -puts "maxV=${maxV}" - -if { ${nbF} != 6} { - puts "Error: bad value of nbFaces" -} -# -if { ${nbE} != 12} { - puts "Error: bad value of nbEdges" -} -# -if { ${nbV} != 8} { - puts "Error: bad value of nbVtx" -} - -set goodTol 1.00000e-07 -set tol 1.00000e-07 - -if { [expr (abs (${minF} - ${goodTol}) )] > ${tol} } { - puts "Error: bad value of minF" -} -if { [expr (abs (${maxF} - ${goodTol}) )] > ${tol} } { - puts "Error: bad value of maxF" -} -if { [expr (abs (${minE} - ${goodTol}) )] > ${tol} } { - puts "Error: bad value of minE" -} -if { [expr (abs (${maxE} - ${goodTol}) )] > ${tol} } { - puts "Error: bad value of maxE" -} -if { [expr (abs (${minV} - ${goodTol}) )] > ${tol} } { - puts "Error: bad value of minV" -} -if { [expr (abs (${maxV} - ${goodTol}) )] > ${tol} } { - puts "Error: bad value of maxV" -} diff --git a/tests/bugs/demo/bug25344_4 b/tests/bugs/demo/bug25344_4 deleted file mode 100644 index a3c9f3f82c..0000000000 --- a/tests/bugs/demo/bug25344_4 +++ /dev/null @@ -1,28 +0,0 @@ -puts "========" -puts "OCC25344" -puts "========" -puts "" -####################################################### -# Draw variables do not follow the scope of TCL level -####################################################### - -box a 1 1 1 - -set filename "box file.brep" - -if [catch {save a $filename}] { - puts "ERROR: save failure" -} else { - if ![file exists $filename] { - puts "ERROR: file \"$filename\" is not created" - } else { - if [catch {restore $filename b}] { - puts "ERROR: restore of file \"$filename\" is failure" - } else { - if {[dtyp a] != [dtyp b]} { - puts "ERROR: types of shape and its restored copy do not equal" - } - } - file delete $filename - } -} diff --git a/tests/bugs/demo/bug25445 b/tests/bugs/demo/bug25445 deleted file mode 100644 index a94072ef96..0000000000 --- a/tests/bugs/demo/bug25445 +++ /dev/null @@ -1,18 +0,0 @@ -puts "========" -puts "OCC25445" -puts "========" -puts "" -####################################################################### -# Draw command incmesh should support all parameters used in BRepMesh -####################################################################### - -pcone aCone 100 10 100 - -tclean aCone -incmesh aCone 0.01 -a 10. -regexp {([0-9]+) +triangles.*[^0-9]([0-9]+) +nodes} [trinfo aCone] full NbTrian_1 NbNodes_1 - -tclean aCone -incmesh aCone 0.01 -a 1. - -checktrinfo aCone -tri !${NbTrian_1} -nod !${NbNodes_1} diff --git a/tests/bugs/fclasses/bug11568_1 b/tests/bugs/fclasses/bug11568_1 deleted file mode 100755 index 914c94cbcb..0000000000 --- a/tests/bugs/fclasses/bug11568_1 +++ /dev/null @@ -1,19 +0,0 @@ -puts "============" -puts "OCC11568" -puts "============" -puts "" -####################################################################### -# UnitsAPI package uses incorrect symbol for minutes: mn instead of min -####################################################################### - -set BugNumber OCC11568 - -set UnitString "mn" -set result "Token word : min\n" - -if { [unitparsing ${UnitString}] == ${result} } { - puts "${BugNumber}: OK" -} else { - puts "${BugNumber}: Faulty" -} - diff --git a/tests/bugs/fclasses/bug11568_2 b/tests/bugs/fclasses/bug11568_2 deleted file mode 100755 index 544b1c6c03..0000000000 --- a/tests/bugs/fclasses/bug11568_2 +++ /dev/null @@ -1,18 +0,0 @@ -puts "============" -puts "OCC11568" -puts "============" -puts "" -####################################################################### -# UnitsAPI package uses incorrect symbol for minutes: mn instead of min -####################################################################### - -set BugNumber OCC11568 - -set UnitString "mn" -set result "result: 60\n" - -if { [unitconvtoSI 1 ${UnitString}] == ${result} } { - puts "${BugNumber}: OK" -} else { - puts "${BugNumber}: Faulty" -} diff --git a/tests/bugs/fclasses/bug11568_3 b/tests/bugs/fclasses/bug11568_3 deleted file mode 100644 index 9ba5db60b8..0000000000 --- a/tests/bugs/fclasses/bug11568_3 +++ /dev/null @@ -1,18 +0,0 @@ -puts "============" -puts "OCC11568" -puts "============" -puts "" -####################################################################### -# UnitsAPI package uses incorrect symbol for minutes: mn instead of min -####################################################################### - -set BugNumber OCC11568 - -set UnitString "min" -set result "Token word : min\n" - -if { [unitparsing ${UnitString}] == ${result} } { - puts "${BugNumber}: OK" -} else { - puts "${BugNumber}: Faulty" -} diff --git a/tests/bugs/fclasses/bug11568_4 b/tests/bugs/fclasses/bug11568_4 deleted file mode 100644 index a5cda62d4d..0000000000 --- a/tests/bugs/fclasses/bug11568_4 +++ /dev/null @@ -1,18 +0,0 @@ -puts "============" -puts "OCC11568" -puts "============" -puts "" -####################################################################### -# UnitsAPI package uses incorrect symbol for minutes: mn instead of min -####################################################################### - -set BugNumber OCC11568 - -set UnitString "min" -set result "result: 60\n" - -if { [unitconvtoSI 1 ${UnitString}] == ${result} } { - puts "${BugNumber}: OK" -} else { - puts "${BugNumber}: Faulty" -} diff --git a/tests/bugs/fclasses/bug23403 b/tests/bugs/fclasses/bug23403 deleted file mode 100755 index ac4dbc2d76..0000000000 --- a/tests/bugs/fclasses/bug23403 +++ /dev/null @@ -1,12 +0,0 @@ -####################################################################### -# Crash when parsing an expression with lexical error -####################################################################### -pload QAcommands - -set result [CR23403 \t] -set ll [llength ${result}] - -puts "" -if { ${ll} != 0 } { - puts "Error : parsing is incorrect" -} \ No newline at end of file diff --git a/tests/bugs/fclasses/bug23852 b/tests/bugs/fclasses/bug23852 deleted file mode 100755 index 5318da4f1f..0000000000 --- a/tests/bugs/fclasses/bug23852 +++ /dev/null @@ -1,69 +0,0 @@ -puts "============" -puts "OCC23852" -puts "============" -puts "" -####################################################################### -# OSD_Path interprets unc paths incorrectly -####################################################################### - -pload OCAF - -set BugNumber OCC23852 - -if { [checkplatform -windows] } { - - # Windows, #1 - set OSD_Path "\\\\Server\\Shared\\Folder\\File.Extension" - puts "OSD_Path = ${OSD_Path}" - - set Log [OSDPath ${OSD_Path}] - # - if { [regexp "Trek +: +\\|\\|Server\\|Shared\\|Folder" ${Log}] != 1 } { - puts "${BugNumber}, Trek, #1: Error" - } - # - if { [regexp "Name +: +File" ${Log}] != 1 } { - puts "${BugNumber}, Name, #1: Error" - } - # - if { [regexp "Extension +: +.Extension" ${Log}] != 1 } { - puts "${BugNumber}, Extension, #1: Error" - } - - # Windows, #2 - set OSD_Path "//Server/Shared/Folder/File.Extension" - puts "OSD_Path = ${OSD_Path}" - - set Log [OSDPath ${OSD_Path}] - # - if { [regexp "Trek +: +||Server|Shared|Folder" ${Log}] != 1 } { - puts "${BugNumber}, Trek, #2: Error" - } - # - if { [regexp "Name +: +File" ${Log}] != 1 } { - puts "${BugNumber}, Name, #2: Error" - } - # - if { [regexp "Extension +: +.Extension" ${Log}] != 1 } { - puts "${BugNumber}, Extension, #2: Error" - } - -} else { - # Linux - set OSD_Path "//Server/Shared/Folder/File.Extension" - puts "OSD_Path = ${OSD_Path}" - - set Log [OSDPath ${OSD_Path}] - # - if { [regexp "Trek +: +||Server|Shared|Folder" ${Log}] != 1 } { - puts "${BugNumber}, Trek: Error" - } - # - if { [regexp "Name +: +File" ${Log}] != 1 } { - puts "${BugNumber}, Name: Error" - } - # - if { [regexp "Extension +: +.Extension" ${Log}] != 1 } { - puts "${BugNumber}, Extension: Error" - } -} diff --git a/tests/bugs/fclasses/bug24897 b/tests/bugs/fclasses/bug24897 deleted file mode 100755 index f0bf337bc8..0000000000 --- a/tests/bugs/fclasses/bug24897 +++ /dev/null @@ -1,11 +0,0 @@ -puts "============" -puts "OCC24897" -puts "============" -puts "" -####################################################################### -# Possibility of uncontrolled exit if scanner fails in ExprIntrp -####################################################################### - -pload QAcommands - -CR23403 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa diff --git a/tests/bugs/fclasses/bug24931 b/tests/bugs/fclasses/bug24931 deleted file mode 100644 index 7ccdf2d36c..0000000000 --- a/tests/bugs/fclasses/bug24931 +++ /dev/null @@ -1,20 +0,0 @@ -puts "==========" -puts "OCC24931" -puts "==========" -puts "" -#################################################### -# Stack overflow when writing large shapes to XML -#################################################### - -pload QAcommands - -set FilePath ${imagedir}/bug24931_testdocument.xml - -file delete -force ${FilePath} -set info [OCC24931 ${FilePath}] - -if { [regexp "OK" $info] != 1 } { - puts "Error: Stack is overflow" -} else { - puts "OK: Stack is good" -} \ No newline at end of file diff --git a/tests/bugs/fclasses/bug25635_1 b/tests/bugs/fclasses/bug25635_1 deleted file mode 100755 index 995282f026..0000000000 --- a/tests/bugs/fclasses/bug25635_1 +++ /dev/null @@ -1,21 +0,0 @@ -puts "============" -puts "OCC25635" -puts "============" -puts "" -###################################################### -# Wrong result of 2D-extrema between two ellipsis -###################################################### - -ellipse c1 0 0 2 1 -ellipse c2 4 0 2 1 - -set info [2dextrema c1 c2] - -set tol_abs 7.e-5 -set tol_rel 0.01 - -# Check result distance. -regexp "dist 1: +(\[-0-9.+eE\]+)" ${info} full dist_1 - -set expected_dist_1 0. -checkreal "Distance" ${dist_1} ${expected_dist_1} ${tol_abs} ${tol_rel} diff --git a/tests/bugs/fclasses/bug25635_2 b/tests/bugs/fclasses/bug25635_2 deleted file mode 100755 index ee048034cc..0000000000 --- a/tests/bugs/fclasses/bug25635_2 +++ /dev/null @@ -1,47 +0,0 @@ -puts "============" -puts "OCC25635" -puts "============" -puts "" -###################################################### -# Wrong result of 2D-extrema between two ellipsis -###################################################### - -circle c1 0 0 2 -circle c2 4 0 2 - -set info [2dextrema c1 c2] - -#-1 -if { [regexp "dist 1: +(\[-0-9.+eE\]+) +ext_1" ${info}] } { - puts "OK: Good ext_1" -} else { - puts "Error: Wrong ext_1" -} - -if { [regexp "dist 2: +(\[-0-9.+eE\]+) +ext_2" ${info}] } { - puts "OK: Good ext_2" -} else { - puts "Error: Wrong ext_2" -} - -if { [regexp "dist 3: +(\[-0-9.+eE\]+) +ext_3" ${info}] } { - puts "OK: Good ext_3" -} else { - puts "Error: Wrong ext_3" -} - -if { [regexp "dist 4: +(\[-0-9.+eE\]+) +ext_4" ${info}] } { - puts "OK: Good ext_4" -} else { - puts "Error: Wrong ext_4" -} - - -#-2 -set dump_list [dump ext_2] - -if { [regexp {Point 2d} ${dump_list}] } { - puts "OK: Good result of 2D-extrema between two circles" -} else { - puts "Error: Wrong result of 2D-extrema between two circles" -} diff --git a/tests/bugs/fclasses/bug26922 b/tests/bugs/fclasses/bug26922 deleted file mode 100755 index 362712f3da..0000000000 --- a/tests/bugs/fclasses/bug26922 +++ /dev/null @@ -1,38 +0,0 @@ -puts "============" -puts "OCC26922" -puts "============" -puts "" -############################### -## Huge performance issue writing data to the output stream -############################### - -pload XDE - -if { [regexp {Debug mode} [dversion]] } { - if { [regexp {Windows} [dversion]] } { - set max_time 0.5 - } else { - set max_time 0.5 - } -} else { - if { [regexp {Windows} [dversion]] } { - set max_time 0.5 - } else { - set max_time 0.5 - } -} - -psphere result 50. -incmesh result 0.01 -trinfo result - -set time_info [time {writevrml result ${imagedir}/bug26922.wrl 2 2}] -regexp {([-0-9.+eE]+)} ${time_info} full time_performance -set time_performance [expr {${time_performance} / 1e6}] -puts "Performance data writing into the file is ${time_performance} seconds" - -if { ${time_performance} > ${max_time} } { - puts "Elapsed time of data writing into the file is more than ${max_time} seconds - Faulty" -} else { - puts "Elapsed time of data writing into the file is less than ${max_time} seconds - OK" -} diff --git a/tests/bugs/fclasses/bug28478 b/tests/bugs/fclasses/bug28478 deleted file mode 100644 index 8fb3156b87..0000000000 --- a/tests/bugs/fclasses/bug28478 +++ /dev/null @@ -1,27 +0,0 @@ -puts "# ============" -puts "# 0028478: Scope Names Are Swallowed in Message_ProgressSentry Constructors" -puts "# ============" -puts "" -puts "# Test output of progress indicator in text mode" - -pload QAcommands - -XProgress +t - -set out [OCC28478 3 2] - -set expected { - {Progress: 0%} - {Progress: 17% Outer: 1 / 3 Inner: 1 / 2} - {Progress: 33% Outer: 1 / 3 Inner: 2 / 2} - {Progress: 50% Outer: 2 / 3 Inner: 1 / 2} - {Progress: 67% Outer: 2 / 3 Inner: 2 / 2} - {Progress: 83% Outer: 3 / 3 Inner: 1 / 2} - {Progress: 100% Outer: 3 / 3 Inner: 2 / 2} -} - -if { [string compare [string trim $out] [join $expected "\n"]] } { - puts "Error: output (see above) does not match expected one:" - puts "[join $expected "\n"]" - puts "" -} \ No newline at end of file diff --git a/tests/bugs/fclasses/bug30800 b/tests/bugs/fclasses/bug30800 deleted file mode 100644 index ec8253ff73..0000000000 --- a/tests/bugs/fclasses/bug30800 +++ /dev/null @@ -1,14 +0,0 @@ -puts "# ==========================================================================================" -puts "# 0030800: Foundation Classes, UnitsAPI - poise dynamic viscosity unit is not defined correctly" -puts "# ==========================================================================================" -puts "" - -puts "Check that 1 Poise is 0.1 Pa*s" -if { [regexp {result: ([0-9.e+-]+)} [unitconvtoSI 1. Po] res poise_si] } { - checkreal "Poise in SI (Pa*s)" $poise_si 0.1 1e-6 1e-6 -} else { - puts "Error: cannot convert Poise to SI" -} - -puts "Check that 1 Poise is 0.001 kg/cm/s" -checkreal "Poise in kg/cm/s" [unit 1. Po kg/cm/s] 0.001 1e-6 1e-6 diff --git a/tests/bugs/fclasses/bug31092 b/tests/bugs/fclasses/bug31092 deleted file mode 100644 index 89203d0d07..0000000000 --- a/tests/bugs/fclasses/bug31092 +++ /dev/null @@ -1,36 +0,0 @@ -puts "# ============" -puts "# 0031092: Foundation Classes - incorrect last output value for Infinite progress indicator" -puts "# ============" -puts "" -puts "# Test output of progress indicator in text mode (infinite scale)" - -pload QAcommands - -XProgress +t - -set out [OCC28478 3 2 -inf] - -set expected { - {Progress: 0%} - {Progress: 11% Outer: 1 / 3 Inner: 1} - {Progress: 17% Outer: 1 / 3 Inner: 2} - {Progress: 20% Outer: 1 / 3 Inner: 3} - {Progress: 22% Outer: 1 / 3 Inner: 4} - {Progress: 33% Outer: 1 / 3 Inner: finished} - {Progress: 44% Outer: 2 / 3 Inner: 1} - {Progress: 50% Outer: 2 / 3 Inner: 2} - {Progress: 53% Outer: 2 / 3 Inner: 3} - {Progress: 56% Outer: 2 / 3 Inner: 4} - {Progress: 67% Outer: 2 / 3 Inner: finished} - {Progress: 78% Outer: 3 / 3 Inner: 1} - {Progress: 83% Outer: 3 / 3 Inner: 2} - {Progress: 87% Outer: 3 / 3 Inner: 3} - {Progress: 89% Outer: 3 / 3 Inner: 4} - {Progress: 100% Outer: 3 / 3 Inner: finished} -} - -if { [string compare [string trim $out] [join $expected "\n"]] } { - puts "Error: output (see above) does not match expected one:" - puts "[join $expected "\n"]" - puts "" -} \ No newline at end of file diff --git a/tests/bugs/fclasses/bug31381 b/tests/bugs/fclasses/bug31381 deleted file mode 100644 index d108a8136e..0000000000 --- a/tests/bugs/fclasses/bug31381 +++ /dev/null @@ -1,15 +0,0 @@ -puts "# ============" -puts "# 0031381: Foundation Classes - wrong evaluations for rational BSpline curves using Adaptor curves " -puts "# ============" -puts "" -puts "Eliminate output of approxcurve command" -puts "REQUIRED ALL: Error " - -circle c 0 0 1 -puts "Get rational BSpline curve of degree 2" -convert c c -puts "Get offset curve to force calculation of D3 for base curve when algorithm needs D2 for offset" -offset oc c -.5 -puts "Approximate offset curve with continuity C2" -approxcurve ac oc 1.e-4 2 5 25 -checklength ac -l 3.1415850499856011 \ No newline at end of file diff --git a/tests/bugs/fclasses/bug710 b/tests/bugs/fclasses/bug710 deleted file mode 100755 index d2342f1299..0000000000 --- a/tests/bugs/fclasses/bug710 +++ /dev/null @@ -1,18 +0,0 @@ -puts "========" -puts "OCC710" -puts "========" -puts "" -######################################################## -## If the file pathname is empty, the Standard_Boolean OSD_FileNode::Exists() -## raises an exception -######################################################## - -pload QAcommands - -set Path "" - -if [catch {OCC710 ${Path} } result] { - puts "Faulty OCC710" -} else { - puts "OCC710 OK" -} diff --git a/tests/bugs/fclasses/bug9848_1 b/tests/bugs/fclasses/bug9848_1 deleted file mode 100755 index d092a45fa9..0000000000 --- a/tests/bugs/fclasses/bug9848_1 +++ /dev/null @@ -1,24 +0,0 @@ -puts "============" -puts "OCC9848" -puts "============" -puts "" -####################################################################### -# Specifying invalid name of unit produces exception.(for example tonne instead ton) -####################################################################### - -set BugNumber OCC9848 - -set UnitString "tonne/(mm*s**2)" - -set List "" -set result "" - -if [catch { set List [unitparsing ${UnitString}] } result] { - if { ${result} == "can not create a sentence\n"} { - puts "${BugNumber}: OK" - } else { - puts "${BugNumber}: Faulty (2)" - } -} else { - puts "${BugNumber}: Faulty (1)" -} diff --git a/tests/bugs/fclasses/bug9848_2 b/tests/bugs/fclasses/bug9848_2 deleted file mode 100755 index febb5563fa..0000000000 --- a/tests/bugs/fclasses/bug9848_2 +++ /dev/null @@ -1,25 +0,0 @@ -puts "============" -puts "OCC9848" -puts "============" -puts "" -####################################################################### -# Specifying invalid name of unit produces exception.(for example tonne instead ton) -####################################################################### - -set BugNumber OCC9848 - -set UnitString "ton/(m*s**2)" - -set List "" -set result "" -set GoodResult "Token word : (ton)/((m)*((s)**(2)))" - -if [catch { set List [unitparsing ${UnitString}] } result] { - puts "${BugNumber}: Faulty (1)" -} else { - if { ${List} == "${GoodResult}\n"} { - puts "${BugNumber}: OK" - } else { - puts "${BugNumber}: Faulty (2)" - } -} diff --git a/tests/bugs/filling/bug13904 b/tests/bugs/filling/bug13904 deleted file mode 100644 index 0438bc25a2..0000000000 --- a/tests/bugs/filling/bug13904 +++ /dev/null @@ -1,33 +0,0 @@ -puts "===========" -puts "OCC13904" -puts "===========" -###################################################### -# Exception during "filling" operation -###################################################### - -set BugNumber OCC13904 - -circle c 0 100 100 0 1 1 50 -ellipse el 0 0 0 0 1 1 100 50 - -set mistake 0 -if [catch { appsurf result c el } res] { - set mistake 1 - puts "Faulty ${BugNumber}: filling problem" -} else { - puts "Filling ${BugNumber} OK" - set What [whatis result] - if { [regexp "surface" $What] != 1 } { - set mistake 1 - } else { - set mistake 0 - } -} - -# Resume -puts "" -if { ${mistake} != 0 } { - puts "Faulty ${BugNumber}" -} else { - puts "OK ${BugNumber}" -} diff --git a/tests/bugs/filling/bug27775 b/tests/bugs/filling/bug27775 deleted file mode 100644 index 2fba34ca43..0000000000 --- a/tests/bugs/filling/bug27775 +++ /dev/null @@ -1,25 +0,0 @@ -puts "REQUIRED All: Standard_ConstructionError\: GeomFill_BSplineCurves\: invalid filling style" - -puts "========" -puts "OCC27704" -puts "========" -puts "" -################################################# -# Different behavior of GeomFill_BSplineCurves algorithm in DEBUG and RELEASE mode -################################################# - -#Indeed, the input data are invalid here: -#1. Algorithm requires B-Spline with 4+ poles. Source curves contains two pole only. -#2. Four curves must comprise closed region. But it is not here. -#Therefore, the normal behavior is to throw an exception. - -bsplinecurve c1 1 2 0 2 100.000001513789 2 -24033.3957701043 -6337.90755953146 -16577.8188547128 1 -23933.3957701044 -6337.90755953146 -16577.8362547128 1 -bsplinecurve c2 1 2 0 2 100.000001513789 2 -23933.3957701044 -6337.90755953146 -16577.8362547128 1 -24033.3957701043 -6337.90755953146 -16577.8188547128 1 -bsplinecurve c3 1 2 0 2 33.1099999999979 2 -24033.3957701043 -6371.01755953146 -16577.8188547128 1 -24033.3957701043 -6337.90755953146 -16577.8188547128 1 -bsplinecurve c4 1 2 0 2 100.000001513789 2 -24033.3957701043 -6371.01755953146 -16577.8188547128 1 -23933.3957701044 -6371.01755953146 -16577.8362547128 1 - -if {[catch {fillcurves res c1 c2 c3 c4 2}]} { - puts "OK: The incorrect input data were processed correctly!" -} else { - puts "Error: The output result must be invalid because the input data are wrong!" -} \ No newline at end of file diff --git a/tests/bugs/heal/bug24881 b/tests/bugs/heal/bug24881 deleted file mode 100644 index 772917adfb..0000000000 --- a/tests/bugs/heal/bug24881 +++ /dev/null @@ -1,17 +0,0 @@ -puts "========" -puts "OCC24881" -puts "========" -puts "" -################################################################## -# Wrong status returned by ShapeFix_Wire::FixGaps3d () operation -################################################################## - -pload QAcommands - -box b 100 200 300 - -set bug_info [OCC24881 b] - -if {[lindex $bug_info 0] != "Fix_FillGaps_NothingToDo"} { - puts "ERROR: OCC24881 is reproduced. Status is [lindex $bug_info 0]" -} diff --git a/tests/bugs/heal/bug25014 b/tests/bugs/heal/bug25014 deleted file mode 100755 index 492bc7ec23..0000000000 --- a/tests/bugs/heal/bug25014 +++ /dev/null @@ -1,10 +0,0 @@ -puts "============" -puts "OCC25014" -puts "============" -puts "" -####################################################################### -## ShapeAnalysis_WireOrder produces Standard_RangeError on empty wire (debug mode only) -####################################################################### - -shape w w -stwire w r +r diff --git a/tests/bugs/heal/bug29382_3 b/tests/bugs/heal/bug29382_3 deleted file mode 100644 index 6fcd5a6f57..0000000000 --- a/tests/bugs/heal/bug29382_3 +++ /dev/null @@ -1,24 +0,0 @@ -puts "================================================================================" -puts "OCC29382: ShapeUpgrade_UnifySameDomain algorithm incorrectly processes the shape" -puts "================================================================================" -puts "" - -beziercurve a 5 0 0 0 1 0 0 2 2 0 0 0.5 0 0 0 0 -mkedge a a -wire a a -mkplane a a -prism a a 0 0 1 -box b -0.3 -0.2 0 1 0.4 1 -bcommon shape a b - -unifysamedom result shape +b - -checkshape result - -checknbshapes result -solid 1 -shell 1 -face 5 -wire 5 -edge 9 -vertex 5 - -set tolres [checkmaxtol result] - -if { ${tolres} > 6.e-6} { - puts "Error: bad tolerance of result" -} diff --git a/tests/bugs/heal/bug29544_2 b/tests/bugs/heal/bug29544_2 deleted file mode 100644 index 52e203b4e2..0000000000 --- a/tests/bugs/heal/bug29544_2 +++ /dev/null @@ -1,27 +0,0 @@ -puts "========" -puts "OCC29544" -puts "========" -puts "" -################################################# -# Regression vs 7.2.0: ShapeUpgrade_UnifySameDomain fails to merge linear edges -################################################# - -# create edge -line l 0 0 0 1 0 0 -mkedge e l 0 10 - -# split edge by the vertex -vertex v 5 2.e-7 0 -bclearobjects -bcleartools -baddobjects e -baddtools v -bfillds -bsplit sp - -# unify the splits of the edge -unifysamedom result sp - -checkshape result -checkprops result -l 10 -checknbshapes result -vertex 2 -edge 1 diff --git a/tests/bugs/heal/bug30927 b/tests/bugs/heal/bug30927 deleted file mode 100644 index 898fa96a84..0000000000 --- a/tests/bugs/heal/bug30927 +++ /dev/null @@ -1,15 +0,0 @@ -puts "============================================================================" -puts "0030927: Modeling Algorithms - UnifySameDom looses the Closed flag for wires" -puts "============================================================================" -puts "" - -box b1 10 10 10 -box b2 5 0 -5 10 10 20 -bfuse s b1 b2 -unifysamedom result s - -foreach w [explode result w] { - if {![regexp "Closed" [whatis $w]]} { - puts "Error: Wire $w is not closed" - } -} diff --git a/tests/bugs/mesh/bug30234 b/tests/bugs/mesh/bug30234 deleted file mode 100644 index 54e4fdf30d..0000000000 --- a/tests/bugs/mesh/bug30234 +++ /dev/null @@ -1,15 +0,0 @@ -puts "=======" -puts "0030234: BRepMesh_IncrementalMesh fail to discretize some zero-length free edges" -puts "=======" -puts "" - -circle cc 0 0 0 0 - -dump cc - -mkedge result cc -checknbshapes result -edge 1 -vertex 1 - -incmesh result 0.005 -relative - -checktrinfo result -tri 0 -nod 0 diff --git a/tests/bugs/mesh/bug31125 b/tests/bugs/mesh/bug31125 deleted file mode 100644 index cbef730b1e..0000000000 --- a/tests/bugs/mesh/bug31125 +++ /dev/null @@ -1,7 +0,0 @@ -puts "=======" -puts "0031125: BRepMesh_IncrementalMesh crash in constructor for empty compound shape" -puts "=======" -puts "" - -compound result -incmesh result 1 diff --git a/tests/bugs/mesh/bug32692_3 b/tests/bugs/mesh/bug32692_3 deleted file mode 100644 index 50d9334f43..0000000000 --- a/tests/bugs/mesh/bug32692_3 +++ /dev/null @@ -1,14 +0,0 @@ -puts "=========" -puts "OCC32692: Crash when the input shape has some invalid topology" -puts "=========" -puts "" - -puts "REQUIRED ALL: Meshing statuses: OpenWire Failure Outdated" - -pload MODELING -cylinder c 0 0 0 10 -mkface f c - -incmesh f 0.01 -parallel - -checktrinfo f -nod 0 -tri 0 -face 1 diff --git a/tests/bugs/modalg_5/bug21564 b/tests/bugs/modalg_5/bug21564 deleted file mode 100644 index 4375e90da8..0000000000 --- a/tests/bugs/modalg_5/bug21564 +++ /dev/null @@ -1,61 +0,0 @@ -puts "================" -puts "OCC21564" -puts "================" -puts "" -####################################################################### -# Intersection of two planar faces produces curve with too many poles -####################################################################### - -puts "Construct horizontal plane, convert it to b-spline, and create a face on it" -plane p1 0 0 0 0 0 1 -trim p1t p1 -10 10 -10 10 -convert bs1 p1t -mkface f1 bs1 - -puts "Construct vertical plane and face on it" -plane p2 0 0 0 1 0 0 -mkface f2 p2 -10 10 -10 10 - -puts "\nBuild intersection of two faces" -bsection sec f1 f2 - -puts "Check number of points in resulting curve" -if { ! [regexp {([0-9]+) Poles} [dump sec] str nbp] } { - puts "Error: Could not check number of poles in resulting curve!" -} elseif { $nbp != 2 } { - puts "Error: Intersection curve has too many poles ($nbp while 2 is expected)" -} - -puts "\nBuild intersection with approximation of resulting curve" -bsection sec f1 f2 -a - -puts "Check number of points in resulting curve" -if { ! [regexp {([0-9]+) Poles} [dump sec] str nbp] } { - puts "Error: Could not check number of poles in resulting curve!" -} elseif { $nbp != 2 } { - puts "Error: Intersection curve has too many poles ($nbp while 2 is expected)" -} - -puts "\nNow trying with inclined plane" -plane p2 0 0 0 1 2 0 -mkface f2 p2 -15 15 -15 15 - -puts "\nBuild intersection of two faces" -bsection sec f1 f2 - -puts "Check number of points in resulting curve" -if { ! [regexp {([0-9]+) Poles} [dump sec] str nbp] } { - puts "Error: Could not check number of poles in resulting curve!" -} elseif { $nbp != 2 } { - puts "Error: Intersection curve has too many poles ($nbp while 2 is expected)" -} - -puts "\nBuild intersection with approximation of resulting curve" -bsection sec f1 f2 -a - -puts "Check number of points in resulting curve" -if { ! [regexp {([0-9]+) Poles} [dump sec] str nbp] } { - puts "Error: Could not check number of poles in resulting curve!" -} elseif { $nbp != 2 } { - puts "Error: Intersection curve has too many poles ($nbp while 2 is expected)" -} diff --git a/tests/bugs/modalg_5/bug23855 b/tests/bugs/modalg_5/bug23855 deleted file mode 100644 index 3d1524f25b..0000000000 --- a/tests/bugs/modalg_5/bug23855 +++ /dev/null @@ -1,21 +0,0 @@ -puts "=========" -puts "OCC23855" -puts "=========" -puts "" -########################################################### -# Old BOPs fail on Win7 64bit when using TBB -########################################################### - -psphere s1 10 -psphere s2 10 -bcommon result s1 s2 - -explode result so - -checkshape result - -checknbshapes result_1 -ref [nbshapes s1] -checknbshapes result_1 -ref [nbshapes s2] - -checkprops result_1 -equal s1 -checkprops result_1 -equal s2 \ No newline at end of file diff --git a/tests/bugs/modalg_5/bug23932_1 b/tests/bugs/modalg_5/bug23932_1 deleted file mode 100644 index 9930ae8517..0000000000 --- a/tests/bugs/modalg_5/bug23932_1 +++ /dev/null @@ -1,27 +0,0 @@ -puts "============" -puts "OCC23932" -puts "============" -puts "" -###################################################### -# Standard_NoSuchObject thrown computing section between two cylinders - new to 6.6.0 -###################################################### - -set PI 3.1415926535897932 - -#first face -cylinder s1 538.57646417050069, 347.77316708315834, 183.37500000000000 0 -1 0 1 0 0 44.194173824159222 -trimu s1t s1 0 $PI -mkface b1 s1t - -#second face -cylinder s2 859.00000000000011 463.75990629028450 80.865093709715211 -1 0 0 0 -1 0 186.78835506149036 -trimu s2t s2 0 $PI -mkface b2 s2t - -#section -bop b1 b2 -bopsection result - -checkprops result -l 326.401 -checkshape result -checksection result diff --git a/tests/bugs/modalg_5/bug23932_2 b/tests/bugs/modalg_5/bug23932_2 deleted file mode 100644 index 0d2c4b5dce..0000000000 --- a/tests/bugs/modalg_5/bug23932_2 +++ /dev/null @@ -1,27 +0,0 @@ -puts "============" -puts "OCC23932" -puts "============" -puts "" -###################################################### -# Standard_NoSuchObject thrown computing section between two cylinders - new to 6.6.0 -###################################################### - -set PI 3.1415926535897932 - -#first face -cylinder s1 538.57646417050069 347.77316708315834 183.37500000000000 0 -1 0 1 0 0 44.819173824159222 -trimu s1t s1 0 $PI -mkface b1 s1t - -#second face -cylinder s2 859.00000000000011 463.75990629028450 80.865093709715211 -1 0 0 0 -1 0 187.41335506149036 -trimu s2t s2 0 $PI -mkface b2 s2t - -#section -bop b1 b2 -bopsection result - -checkprops result -l 330.903 -checkshape result -checksection result diff --git a/tests/bugs/modalg_5/bug23954 b/tests/bugs/modalg_5/bug23954 deleted file mode 100644 index 1dc0cc10da..0000000000 --- a/tests/bugs/modalg_5/bug23954 +++ /dev/null @@ -1,21 +0,0 @@ -puts "============" -puts "OCC23954" -puts "============" -puts "" -########################################################## -# BRepPrimAPI_MakeRevol fails to recognize a torus case -########################################################## - -circle c_1 0 100.00001 0 1 0 0 0 1 0 100 -circle c_2 0 100.00001 0 1 0 0 0 0 1 100 -circle c_3 0 100.00001 0 1 0 0 0 -1 0 100 -circle c_4 0 100.00001 0 1 0 0 0 0 1 10 -for { set i 1 } { $i <= 4 } { incr i } { - mkedge e c_$i - revol r e 0 0 0 0 0 1 90 - mksurface s_$i r - set info [dump s_$i] - if { [regexp "SurfaceOfRevolution" $info] == 1 } { - puts "Error: result is not Toroidal surface" - } -} diff --git a/tests/bugs/modalg_5/bug24029 b/tests/bugs/modalg_5/bug24029 deleted file mode 100644 index 1a7ac90dbe..0000000000 --- a/tests/bugs/modalg_5/bug24029 +++ /dev/null @@ -1,33 +0,0 @@ -puts "============" -puts "OCC24029" -puts "============" -puts "" -############################################################################################ -# Add a flag to bopcheck command to provide possibility to disable Face/Face intersection -############################################################################################ - -box b1 10 10 10 -box b2 5 5 5 10 10 10 -compound b1 b2 c - -set info1 [bopcheck c] -set info2 [bopcheck c 4] -set info3 [bopcheck c 3] - -if { [regexp "x35" $info1] != 1 } { - puts "Error : bopcheck c works wrong" -} else { - puts "OK: bopcheck c works properly" -} - -if { [regexp "x13" $info2] != 1 || [regexp "x39" $info2] != 1 } { - puts "Error : bopcheck c 4 works wrong" -} else { - puts "OK: bopcheck c 4 works properly" -} - -if { [regexp "This shape seems to be OK" $info3] != 1 } { - puts "Error : bopcheck c 3 works wrong" -} else { - puts "OK: bopcheck c 3 works properly" -} diff --git a/tests/bugs/modalg_5/bug24033 b/tests/bugs/modalg_5/bug24033 deleted file mode 100755 index 5d0dbb4073..0000000000 --- a/tests/bugs/modalg_5/bug24033 +++ /dev/null @@ -1,60 +0,0 @@ -puts "========" -puts "CR24033" -puts "========" -puts "" -######################################### -## All the orientation as a result of BRepAlgoAPI_Common is set to INTERNAL -######################################### - -polyline f1 0 0 0 0 1 0 1 1 0 1 0 0 0 0 0 -mkplane f1 f1 -polyline f2 0 1 0 0 2 0 1 2 0 1 1 0 0 1 0 -mkplane f2 f2 -polyline f3 0 2 0 0 3 0 1 3 0 1 2 0 0 2 0 -mkplane f3 f3 - -polyline f4 1 0 0 1 1 0 2 1 0 2 0 0 1 0 0 -mkplane f4 f4 -polyline f5 1 1 0 1 2 0 2 2 0 2 1 0 1 1 0 -mkplane f5 f5 -polyline f6 1 2 0 1 3 0 2 3 0 2 2 0 1 2 0 -mkplane f6 f6 - -polyline f7 2 0 0 2 1 0 3 1 0 3 0 0 2 0 0 -mkplane f7 f7 -polyline f8 2 1 0 2 2 0 3 2 0 3 1 0 2 1 0 -mkplane f8 f8 -polyline f9 2 2 0 2 3 0 3 3 0 3 2 0 2 2 0 -mkplane f9 f9 - -sewing s f1 f2 f3 f4 f5 f6 f6 f7 f8 f9 - -box b -1 1 -1 2 1 2 - -bop s b -bopcommon r -explode r - -explode r_1 -set info_f [whatis r_1_1] -if { [regexp {INTERNAL} ${info_f}] } { - puts "Faulty : Wrong orientation of the face" -} else { - puts "Correct orientation of the face" -} - -explode r_1_1 e -set info_e [whatis r_1_1_1] -if { [regexp {INTERNAL} ${info_e}] } { - puts "Faulty : Wrong orientation of the edge" -} else { - puts "Correct orientation of the edge" -} - -explode r_1_1 v -set info_v [whatis r_1_1_1] -if { [regexp {INTERNAL} ${info_v}] } { - puts "Faulty : Wrong orientation of the vertex" -} else { - puts "Correct orientation of the vertex" -} diff --git a/tests/bugs/modalg_5/bug24213 b/tests/bugs/modalg_5/bug24213 deleted file mode 100644 index b80ed26838..0000000000 --- a/tests/bugs/modalg_5/bug24213 +++ /dev/null @@ -1,17 +0,0 @@ -puts "============" -puts "OCC24213" -puts "============" -puts "" -###################################################### -# bopargcheck complains on sphere -###################################################### - -psphere s 10 - -set info [bopargcheck s #F] - -if { [regexp "to be valid for BOP" ${info}] != 1 } { - puts "Error : complain of bopargcheck command is not correct" -} else { - puts "OK : bopargcheck command work properly" -} diff --git a/tests/bugs/modalg_5/bug24328 b/tests/bugs/modalg_5/bug24328 deleted file mode 100644 index 6a4504bdde..0000000000 --- a/tests/bugs/modalg_5/bug24328 +++ /dev/null @@ -1,23 +0,0 @@ -puts "================" -puts "OCC24328" -puts "================" -puts "" -####################################################################### -# Revolution of a wire generates two interfered faces -####################################################################### - -vertex v1 23.500000 11.123000 0 -vertex v2 22.000000 11.140900 0 -vertex v3 20.500000 11.180700 0 -edge e1 v1 v2 -edge e2 v2 v3 -wire w e1 e2 -revol r w 0 0 0 1 0 0 360 - -set info [bopcheck r] - -if { [regexp "This shape seems to be OK" ${info}] != 1 } { - puts "Error : Revolution works wrong" -} else { - puts "OK: Revolution works properly" -} diff --git a/tests/bugs/modalg_5/bug24404 b/tests/bugs/modalg_5/bug24404 deleted file mode 100644 index fb1899c149..0000000000 --- a/tests/bugs/modalg_5/bug24404 +++ /dev/null @@ -1,83 +0,0 @@ -puts "=========" -puts "OCC24404" -puts "=========" -puts "" -###################################################################### -# The function BRepTools::UVBounds gives wrong result for the face -###################################################################### - -# case 1 -box b1 1500 1500 1500 -explode b1 f -copy b1_4 b1 -don b1 -regexp {([-0-9.+eE]+)\n([-0-9.+eE]+)\n([-0-9.+eE]+)\n([-0-9.+eE]+)} [xbounds b1] dump x1 y1 x2 y2 -if { $x1 > 1.e-10 || $y1 != 1500 || $x2 > 1.e-10 || $y2 != 1500} { - puts "Error: Case1: Wrong boundaries of the face" -} else { - puts "OK: Case1: Correct boundaries of the face" -} - -# case 2 -circle c1 1361.60462531413 1500 275.105307765905 0 1 0 182.781239888725 -mkedge e c1 -wire w e -mkplane b2 w -bcut b1 b1 b2 -explode b1 f -copy b1_1 b1 -don b1 -regexp {([-0-9.+eE]+)\n([-0-9.+eE]+)\n([-0-9.+eE]+)\n([-0-9.+eE]+)} [xbounds b1] dump x1 y1 x2 y2 -if { $x1 > 1.e-10 || $y1 != 1500 || $x2 > 1.e-10 || $y2 != 1500} { - puts "Error: Case2: Wrong boundaries of the face" -} else { - puts "OK: Case2: Correct boundaries of the face" -} - -# case 3 -circle c2 398.623694869499 1500 5.77182937332096 0 1 0 181.948898616306 -mkedge e c2 -wire w e -mkplane b2 w -bcut b1 b1 b2 -explode b1 f -copy b1_1 b1 -don b1 -regexp {([-0-9.+eE]+)\n([-0-9.+eE]+)\n([-0-9.+eE]+)\n([-0-9.+eE]+)} [xbounds b1] dump x1 y1 x2 y2 -if { $x1 > 1.e-10 || $y1 != 1500 || $x2 > 1.e-10 || $y2 != 1500} { - puts "Error: Case3: Wrong boundaries of the face" -} else { - puts "OK: Case3: Correct boundaries of the face" -} - -# case 4 -circle c3 66.2457890511211 1500 832.500519113239 0 1 0 176.393473166564 -mkedge e c3 -wire w e -mkplane b2 w -bcut b1 b1 b2 -explode b1 f -copy b1_1 b1 -don b1 -regexp {([-0-9.+eE]+)\n([-0-9.+eE]+)\n([-0-9.+eE]+)\n([-0-9.+eE]+)} [xbounds b1] dump x1 y1 x2 y2 -if { $x1 > 1.e-10 || $y1 != 1500 || $x2 > 1.e-10 || $y2 != 1500} { - puts "Error: Case4: Wrong boundaries of the face" -} else { - puts "OK: Case4: Correct boundaries of the face" -} - -# case 5 -circle c4 1177.73545803307 1500 1406.03245550006 0 1 0 150.768085993996 -mkedge e c4 -wire w e -mkplane b2 w -bcut b1 b1 b2 -explode b1 f -copy b1_1 b1 -don b1 -regexp {([-0-9.+eE]+)\n([-0-9.+eE]+)\n([-0-9.+eE]+)\n([-0-9.+eE]+)} [xbounds b1] dump x1 y1 x2 y2 -if { $x1 > 1.e-10 || $y1 != 1500 || $x2 > 1.e-10 || $y2 != 1500} { - puts "Error: Case4: Wrong boundaries of the face" -} else { - puts "OK: Case4: Correct boundaries of the face" -} diff --git a/tests/bugs/modalg_5/bug24492 b/tests/bugs/modalg_5/bug24492 deleted file mode 100644 index 290f160ea8..0000000000 --- a/tests/bugs/modalg_5/bug24492 +++ /dev/null @@ -1,19 +0,0 @@ -puts "===========" -puts "OCC24492" -puts "===========" -puts "" -############################################################## -# The command bopargcheck produces wrong results for cases -############################################################## - -box x1 10 10 10 -vertex x2 3 3 3 -compound x1 x2 b1 - -set info [bopargcheck b1 #f] - -if { [regexp "Faulties for FIRST shape found : 1" $info] != 1 } { - puts "Error : command bopargcheck produces wrong result" -} else { - puts "OK : command bopargcheck produces correct result" -} diff --git a/tests/bugs/modalg_5/bug24706 b/tests/bugs/modalg_5/bug24706 deleted file mode 100755 index 66c2822c98..0000000000 --- a/tests/bugs/modalg_5/bug24706 +++ /dev/null @@ -1,19 +0,0 @@ -puts "========" -puts "CR24706" -puts "========" -puts "" -######################################### -## Solids produced by BOP do not have flag Closed set in shells -######################################### - -box b 10 10 10 -psphere s 2 -bcut r b s - -explode r sh -set info [whatis r_1] -if { [regexp {Closed} ${info}] } { - puts "OK : Flag CLOSED is set for closed shells created during perform of Boolean Operation" -} else { - puts "Faulty : Flag CLOSED is not set for closed shells created during perform of Boolean Operation" -} diff --git a/tests/bugs/modalg_5/bug25242 b/tests/bugs/modalg_5/bug25242 deleted file mode 100644 index 18fa3f3ae9..0000000000 --- a/tests/bugs/modalg_5/bug25242 +++ /dev/null @@ -1,15 +0,0 @@ -puts "================" -puts "OCC25242" -puts "================" -puts "" -################################# -# Wrong result of cut operation -################################# - -box a 0 0 0 10 10 10 -box b 20 0 0 10 10 10 - -bfuse r0 a b -bcut result r0 a - -checknbshapes result -vertex 8 -edge 12 -wire 6 -face 6 -shell 1 -solid 1 -compsolid 0 -compound 1 -shape 35 \ No newline at end of file diff --git a/tests/bugs/modalg_5/bug25368_1 b/tests/bugs/modalg_5/bug25368_1 deleted file mode 100644 index af3e75ab75..0000000000 --- a/tests/bugs/modalg_5/bug25368_1 +++ /dev/null @@ -1,29 +0,0 @@ -puts "==========" -puts "OCC25368" -puts "==========" -puts "" -################################################ -# BREPExtrma DistShapeShape gives wrong result for Sphere and Line -################################################ - -sphere s 0 0 0 5 -line l 0 0 0.2 1 1 0 -trim l l 0 10 - -set extrema_res [extrema l s] -set extrema_length [llength ${extrema_res} ] - -#Amount Check -if {${extrema_length} != 10 } { - puts "Error: Invalid extrema number in extrema output" -} -regexp {Extrema 1 is point : +([-0-9.+eE]+) +([-0-9.+eE]+) +([-0-9.+eE]+)} $extrema_res full x y z - -# Point check -set good_x 3.5327043465311383 -set good_y 3.5327043465311383 -set good_z 0.20 -checkreal "Intersection point x:" ${x} ${good_x} 0.01 0.01 -checkreal "Intersection point y:" ${y} ${good_y} 0.01 0.01 -checkreal "Intersection point z:" ${z} ${good_z} 0.01 0.01 - diff --git a/tests/bugs/modalg_5/bug25368_2 b/tests/bugs/modalg_5/bug25368_2 deleted file mode 100644 index 5daf8f99dd..0000000000 --- a/tests/bugs/modalg_5/bug25368_2 +++ /dev/null @@ -1,41 +0,0 @@ -puts "==========" -puts "OCC25368" -puts "==========" -puts "" -################################################ -# BREPExtrma DistShapeShape gives wrong result for Sphere and Line -################################################ - -sphere s 0 0 0 4.5 -rotate s 0 0.5 1 1 1 0.5 34.9 -line l -0.79 0.88 1.22 0.579 1.765 0.576 - -set extrema_res [extrema l s] -set extrema_length [llength ${extrema_res} ] - -# Amount check -if {${extrema_length} != 18 } { - puts "Error: expected only two lines as result of extrema!" -} - -# Distance check on ext_1 -set info [dump ext_1] -regexp {Extrema 1 is point : +([-0-9.+eE]+) +([-0-9.+eE]+) +([-0-9.+eE]+)} $extrema_res full x1 y1 z1 -# Point check -set good_x1 -2.2838350838816694 -set good_y1 -3.6737459810900646 -set good_z1 -0.2660950057268425 -checkreal "Intersection point x:" ${x1} ${good_x1} 0.01 0.01 -checkreal "Intersection point y:" ${y1} ${good_y1} 0.01 0.01 -checkreal "Intersection point z:" ${z1} ${good_z1} 0.01 0.01 - - -# Distance check on ext_2 -regexp {Extrema 2 is point : +([-0-9.+eE]+) +([-0-9.+eE]+) +([-0-9.+eE]+)} $extrema_res full x2 y2 z2 -# Point check -set good_x2 0.29086178559218934 -set good_y2 4.1748550113475211 -set good_z2 2.2952614654595873 -checkreal "Intersection point x:" ${x2} ${good_x2} 0.01 0.01 -checkreal "Intersection point y:" ${y2} ${good_y2} 0.01 0.01 -checkreal "Intersection point z:" ${z2} ${good_z2} 0.01 0.01 diff --git a/tests/bugs/modalg_5/bug25477_1 b/tests/bugs/modalg_5/bug25477_1 deleted file mode 100644 index 186fffe7cc..0000000000 --- a/tests/bugs/modalg_5/bug25477_1 +++ /dev/null @@ -1,16 +0,0 @@ -puts "========" -puts "OCC25477" -puts "========" -puts "" -############################################################################ -# Boolean Operations with additional tolerance - Fuzzy Boolean operations -############################################################################ - -box b1 10 10 10 -box b2 10.00001 0 0 10 10 10 - -bfuzzyvalue 0.00002 -bop b1 b2 -bopfuse result - -checknbshapes result -vertex 12 -edge 20 -wire 10 -face 10 -shell 1 -solid 1 -compsolid 0 -compound 1 -shape 55 \ No newline at end of file diff --git a/tests/bugs/modalg_5/bug25578 b/tests/bugs/modalg_5/bug25578 deleted file mode 100644 index 58c15e235b..0000000000 --- a/tests/bugs/modalg_5/bug25578 +++ /dev/null @@ -1,12 +0,0 @@ -puts "=========" -puts "OCC25578" -puts "=========" -puts "" -########################################################### -# SIGSEGV in BRepSweep_Rotation in case of singularities -########################################################### - -psphere Sphere 5 0 90 90 -explode Sphere F -revol rr Sphere_1 0 0 0 0 0 1 360 -revol rr Sphere_1 0 0 0 1 0 0 90 diff --git a/tests/bugs/modalg_5/bug25591 b/tests/bugs/modalg_5/bug25591 deleted file mode 100644 index b562eafb1f..0000000000 --- a/tests/bugs/modalg_5/bug25591 +++ /dev/null @@ -1,18 +0,0 @@ -puts "============" -puts "OCC25591" -puts "============" -puts "" -################################# -# Command mkshell produces wrong shell -################################# - -sphere surf 100 -mkshell sh surf 1 -explode sh e -catch {mkcurve csh_2 sh_2} - -if { [llength [dump csh_2]] > 0 } { - puts "Error: Command mkshell produces wrong shell" -} else { - puts "OK: Command mkshell produces good shell" -} diff --git a/tests/bugs/modalg_7/bug29939 b/tests/bugs/modalg_7/bug29939 deleted file mode 100644 index e66ccc2ff6..0000000000 --- a/tests/bugs/modalg_7/bug29939 +++ /dev/null @@ -1,215 +0,0 @@ -puts "========" -puts "0029939: Modeling Algorithms - add NULL check to BRepGProp_Face::Load()" -puts "========" -puts "" - -pload MODELING VISUALIZATION - -# sample Face with some Curve2ds missing -set aShapeData " -DBRep_DrawableShape - -CASCADE Topology V1, (c) Matra-Datavision -Locations 6 -1 --6.93889390391e-18 1 0 -266.829932547 - -1 -6.93889390391e-18 0 0 - 0 0 1 8.881784197e-16 -1 - 1 -1.23204712323214e-17 3.48118418796994e-18 -357.513195371 -1.23204706275e-17 0.999999999999985 1.73740064720997e-07 5.87091965856e-15 --3.48118632852936e-18 -1.73740064720997e-07 0.999999999999985 1.00245277978e-14 -1 - 1 -3.49249707682408e-17 -1.73723591341045e-16 613.47435459 -3.30382668395332e-18 0.983888906493258 -0.178780926498047 -24.4029550353 -1.77168632948486e-16 0.178780926498047 0.983888906493258 17.0096765133 -1 --0.891601662261103 -0.296724731883325 0.34205395676999 289.371401338 -0.321472550183128 -0.946772534430101 0.0166483490940992 -855.09721987 -0.318907314641721 0.12480465350928 0.939532821741973 -233.868191989 -2 1 1 2 1 3 1 4 1 0 -2 4 -1 3 -1 2 -1 1 -1 0 -Curve2ds 8 -1 3.1415926535885261 -3.1415926537565504 -9.6123430370698398e-15 1 -1 2.6415926535897927 3.1415926535897829 1 3.227912221389625e-15 -1 -3.641592653589794 3.1415926535899144 1 -2.1627771834064215e-14 -1 -3.641592653589794 3.1415926535897447 1 8.2694421717546571e-15 -1 -3.641592653589794 3.1415926535897984 1 -2.5444437451706449e-15 -1 -3.6415926535891083 3.1415926535895933 1 4.5496352846831891e-14 -1 0 -3.1415926537565433 0 1 -1 -3.6415926535884808 1.5707963267948022 1 1.8093822187836176e-14 -Curves 9 -2 84.858320332900007 -63 155.33211345500001 -0.87758256189037243 0 0.4794255386042035 -0.4794255386042035 0 -0.87758256189037243 -0 -1 0 2 -2 -5.6843418860799994e-14 -63 4.2632564145599997e-14 -0 1 0 0 0 1 1 0 -0 175 -7 0 0 4 5 2 9.51279659315 -64.469009257300002 174.74125643599999 10.8275887261 -63.750060296000001 174.66968003599999 12.261430838000001 -63.2501700292 174.57846249100001 13.7577343107 -62.999999975000001 174.464825784 15.252255180300001 -63 174.33407214900001 - 0 5 8.4865807349600004 5 -2 -5.6843418860799994e-14 -63 4.2632564145599997e-14 -0 1 0 0 0 1 1 0 -0 175 -2 -5.6843418860799994e-14 -63 4.2632564145599997e-14 -0 1 0 0 0 1 1 0 -0 175 -2 -5.6843418860799994e-14 -63 4.2632564145599997e-14 -0 1 0 0 0 1 1 0 -0 175 -2 -5.6843418860799994e-14 -63 4.2632564145599997e-14 -0 1 0 0 0 1 1 0 -0 175 -2 -84.858320332900007 -63 -155.33211345500001 0.87758256189037243 -0 -0.4794255386042035 0.4794255386042035 0 0.87758256189037243 0 -1 0 2 -2 -4.2632564145599997e-14 -61 -2.8421709430399997e-14 0 1 0 0 -0 1 1 0 -0 177 -Polygon3D 0 -PolygonOnTriangulations 0 -Surfaces 1 -5 -5.6843418860799994e-14 -63 4.2632564145599997e-14 -0 1 0 -0.4794255386042035 0 -0.87758256189037243 -0.87758256189037243 -0 0.4794255386042035 177 2 -Triangulations 0 - -TShapes 20 -Ve -1.00005e-07 -446.609600903292 -747.182655462685 -128.403390746598 -0 0 - -0101101 -* -Ve -1e-07 -447.487711636221 -749.041771994926 -130.345710818059 -0 0 - -0101101 -* -Ed - 1e-07 1 1 0 -1 1 0 4.71238898051187 6.28318530717959 -2 1 1 0 4.71238898051187 6.28318530717959 -0 - -0101000 -+20 6 -19 6 * -Ve -0.000801323308506101 -439.731321696259 -808.930183254921 -91.6608968795304 -0 0 - -0101101 -* -Ed - 1e-07 1 1 0 -1 2 0 0.0872664625995157 0.499999999999316 -2 2 1 0 0.0872664625995157 0.499999999999316 -0 - -0101000 -+17 6 -19 6 * -Ve -9.50082811303135e-06 -439.731308365217 -808.930245083447 -91.6608718249203 -0 0 - -0101101 -* -Ed - 1e-07 1 1 0 -1 3 0 8.48648424147889 8.48658045180264 -0 - -0101000 -+15 6 -17 6 * -Ve -0.000801323588114315 -400.97481659698 -922.047565623353 -85.9891266596981 -0 0 - -0101101 -* -Ed - 1e-07 1 1 0 -1 4 0 5.672320068985 6.37045138103039 -2 3 1 0 5.672320068985 6.37045138103039 -0 - -0101000 -+13 6 -15 6 * -Ve -0.000801323173512029 -346.92570979233 -1004.00637567207 -154.481647187039 -0 0 - -0101101 -* -Ed - 1e-07 1 1 0 -1 5 0 4.974188368183 5.672320068985 -2 4 1 0 4.974188368183 5.672320068985 -0 - -0101000 -+11 6 -13 6 * -Ve -0.000801323604481778 -302.874179046209 -1016.45717530592 -265.090046896853 -0 0 - -0101101 -* -Ed - 1e-07 1 1 0 -1 6 0 4.27605666738522 4.974188368183 -2 5 1 0 4.27605666738522 4.974188368183 -0 - -0101000 -+9 6 -11 6 * -Ve -1e-07 -289.096508106169 -961.871772388525 -358.63416338841 -0 0 - -0101101 -* -Ed - 1e-07 1 1 0 -1 7 0 3.64159265358911 4.27605666738522 -2 6 1 0 3.64159265358911 4.27605666738522 -0 - -0101000 -+7 6 -9 6 * -Ve -1.00005e-07 -286.408212189964 -962.444998719012 -359.300854202584 -0 0 - -0101101 -* -Ed - 1e-07 1 1 0 -1 8 0 4.71238898038469 6.28318530717959 -2 7 1 0 4.71238898038469 6.28318530717959 -0 - -0101000 -+5 6 -7 6 * -Ed - 1.00005e-07 1 1 0 -1 9 0 3.64159265358848 6.78318530718743 -2 8 1 0 3.64159265358848 6.78318530718743 -0 - -0101000 -+5 6 -20 6 * -Wi - -0101100 -+18 0 -16 0 -14 0 -12 0 -10 0 -8 0 -6 0 -4 0 +3 0 * -Fa -0 1e-07 1 0 - -1101000 -+2 0 * - --1 5 -0 - -" - -set aFile [open "$imagedir/${casename}.brep" wb] -puts $aFile $aShapeData -close $aFile -restore "$imagedir/${casename}.brep" f -file delete "$imagedir/${casename}.brep" - -sprops f -vprops f diff --git a/tests/bugs/modalg_7/bug30269 b/tests/bugs/modalg_7/bug30269 deleted file mode 100644 index 2a23c39d2f..0000000000 --- a/tests/bugs/modalg_7/bug30269 +++ /dev/null @@ -1,104 +0,0 @@ -puts "========" -puts "0030269: Modeling Algorithms - unhandled Standard_NullObject within BRepBndLib::Add()" -puts "========" -puts "" - -pload MODELING VISUALIZATION - -# sample Face with some Curve2ds missing -set aShapeData " -DBRep_DrawableShape - -CASCADE Topology V1, (c) Matra-Datavision -Locations 0 -Curve2ds 0 -Curves 2 -1 8111.3 2939 9014.2 0.23 5.2e-07 0.97 -1 9996.2 2940 8568.4 -0.229 3.64e-07 -0.97 -Polygon3D 0 -PolygonOnTriangulations 0 -Surfaces 2 -1 9056.7 2940 8807.3 1.29e-07 -1 5e-07 -1.26e-29 -5.03e-07 -1 1 1.288e-07 -6.48e-14 -1 10000 1519 8584.45 -0.97 -8.47e-08 0.23 0.23 0 0.97 -8.24e-08 1 1.95e-08 -Triangulations 0 - -TShapes 10 -Ve -1e-07 -8111.30 2940 9014.2 -0 0 - -0101101 -* -Ve -1e-07 -9996.21 2940 8568.4 -0 0 - -0101101 -* -Ed - 2.22e-16 0 0 0 -0 - -0101000 -+10 0 -9 0 * -Ve -1e-07 -8115 2940 9030 -0 0 - -0101101 -* -Ed - 1e-07 0 0 0 -1 1 0 0 16.5 -0 - -0101000 -+10 0 -7 0 * -Ve -1e-07 -10000 2940 8584.5 -0 0 - -0101101 -* -Ed - 2.22e-16 0 0 0 -0 - -0101000 -+7 0 -5 0 * -Ed - 1e-07 0 0 0 -1 2 0 -16.5 0 -4 C0 1 0 2 0 -0 - -0101000 -+5 0 -9 0 * -Wi - -0101000 --8 0 +6 0 +4 0 +3 0 * -Fa -0 1e-07 1 0 - -0101000 --2 0 * - --1 4 -" - -set aFile [open "$imagedir/${casename}.brep" wb] -puts $aFile $aShapeData -close $aFile -restore "$imagedir/${casename}.brep" f -file delete "$imagedir/${casename}.brep" - -bounding f -bounding f -optimal -bounding f -obb -sprops f -vprops f diff --git a/tests/bugs/modalg_7/bug30829 b/tests/bugs/modalg_7/bug30829 deleted file mode 100644 index 7724fb0b80..0000000000 --- a/tests/bugs/modalg_7/bug30829 +++ /dev/null @@ -1,20 +0,0 @@ -puts "========" -puts "0030829: BRepExtrema_ShapeProximity crashes with shape from STL/WRL" -puts "========" -puts "" - -pload XSDRAW STL - -box b 10 10 10 -pcylinder c 5 10 -incmesh b 0.1 -incmesh c 0.1 - -writestl b ${imagedir}/${test_image}_b.stl -writestl c ${imagedir}/${test_image}_c.stl -readstl b ${imagedir}/${test_image}_b.stl -readstl c ${imagedir}/${test_image}_c.stl -file delete ${imagedir}/${test_image}_b.stl -file delete ${imagedir}/${test_image}_c.stl - -proximity b c diff --git a/tests/bugs/modalg_7/optimal_bndbox_exception b/tests/bugs/modalg_7/optimal_bndbox_exception deleted file mode 100644 index 4126d3a869..0000000000 --- a/tests/bugs/modalg_7/optimal_bndbox_exception +++ /dev/null @@ -1,93 +0,0 @@ -puts "========" -puts "0032236: Modeling Algorithms - E x c e p t i o n on calculation optimal bounding box" -puts "========" -puts "" - -set aShapeData " -DBRep_DrawableShape - -CASCADE Topology V1, (c) Matra-Datavision -Locations 0 -Curve2ds 4 -1 -1.3333333333333335 0 0 1 -1 0 -1.6666666666666667 1 0 -1 1.6666666666666665 0 0 1 -1 0 1.3333333333333333 1 0 -Curves 0 -Polygon3D 0 -PolygonOnTriangulations 0 -Surfaces 1 -9 0 0 0 0 3 3 4 4 2 2 0 3 1.9999999999999998 0 1.6666666666666665 1.9999999999999998 0 0.3333333333333332 1.9999999999999996 0 -0.99999999999999989 2 -0 2.9999999999999991 0.66666666666666718 0 1.6666666666666659 0.66666666666666741 0 0.3333333333333332 0.66666666666666663 0 -0.99999999999999956 0.66666666666666663 -0 3.0000000000000009 -0.66666666666666718 0 1.6666666666666676 -0.66666666666666752 0 0.33333333333333331 -0.66666666666666652 0 -1.0000000000000002 -0.66666666666666685 -0 3.0000000000000004 -2 0 1.6666666666666667 -2 0 0.33333333333333326 -1.9999999999999996 0 -1 -2 - --1.3333333333333335 4 -2.6666666666666665 4 - --2.666666666666667 4 -1.3333333333333333 4 - -Triangulations 0 - -TShapes 8 -Ve -4.000004 -0 -1 -1 -0 0 - -0101101 -* -Ed - 4.000004 1 1 1 -2 1 1 0 -1.66666666666667 1.33333333333333 -0 - -0101000 -+8 0 -8 0 * -Ed - 4.000004 1 1 1 -2 2 1 0 -1.33333333333333 1.66666666666667 -0 - -0101000 -+8 0 -8 0 * -Ed - 4.000004 1 1 1 -2 3 1 0 -1.66666666666667 1.33333333333333 -0 - -0101000 -+8 0 -8 0 * -Ed - 4.000004 1 1 1 -2 4 1 0 -1.33333333333333 1.66666666666667 -0 - -0101000 -+8 0 -8 0 * -Wi - -0101100 --7 0 +6 0 +5 0 -4 0 * -Fa -0 1e-07 1 0 - -0101000 -+3 0 * -Sh - -1101000 -+2 0 * - -+1 0 -" - -set aFile [open "$imagedir/${casename}.brep" wb] -puts $aFile $aShapeData -close $aFile - -restore "$imagedir/${casename}.brep" aShape -bounding -optimal aShape - -file delete "$imagedir/${casename}.brep" diff --git a/tests/bugs/modalg_8/bug33165 b/tests/bugs/modalg_8/bug33165 deleted file mode 100644 index a736f52788..0000000000 --- a/tests/bugs/modalg_8/bug33165 +++ /dev/null @@ -1,41 +0,0 @@ -puts "====================================" -puts "0033165: Data exchange - Instance name is not saved during writing step file" -puts "====================================" -puts "" - -pload OCAF XDEDRAW STEP - -box b 1 1 1 -reset b -copy b b1 - -# set valid location with identity matrix -reset b1 - -ttranslate b 1 1 1 - -compound b1 b c -XNewDoc d -XAddShape d c 1 - -set label1 "0:1:1:1:1" -set label2 "0:1:1:1:2" -set name1 "name1" -set name2 "name2" - -SetName d $label1 $name1 -SetName d $label2 $name2 - -set file $imagedir/${test_image}.stp -WriteStep d $file -ReadStep d1 $file - -if { [GetName d1 $label1] != $name1 } { - puts "Error: The name is missed" -} - -if { [GetName d1 $label2] != $name2 } { - puts "Error: The name is missed" -} - -file delete -force ${file} \ No newline at end of file diff --git a/tests/bugs/moddata_1/bug20616 b/tests/bugs/moddata_1/bug20616 deleted file mode 100755 index 257fed4b09..0000000000 --- a/tests/bugs/moddata_1/bug20616 +++ /dev/null @@ -1,34 +0,0 @@ -puts "========================" -puts "OCC20616" -puts "========================" -puts "" -####################################################################### -# Failed to save/restore [locate_data_file empty] face -####################################################################### - -set BugNumber OCC20616 - -set mistake 0 -foreach t {V E W F Sh So CS C} { - puts "shape type $t" - shape test $t - if [catch {save test $imagedir/${test_image}.brep}] { - puts "Faulty ${BugNumber} save $t" - set mistake 1 - } else { - puts "OK ${BugNumber} save $t" - } - if [catch {restore $imagedir/${test_image}.brep test}] { - puts "Faulty ${BugNumber} restore $t" - set mistake 1 - } else { - puts "OK ${BugNumber} restore $t" - } -} - -if {${mistake} !=0} { - puts "Faulty ${BugNumber}" -} else { - puts "OK ${BugNumber}" -} - diff --git a/tests/bugs/moddata_2/bug6503 b/tests/bugs/moddata_2/bug6503 deleted file mode 100755 index 3901535d7c..0000000000 --- a/tests/bugs/moddata_2/bug6503 +++ /dev/null @@ -1,27 +0,0 @@ -puts "================" -puts "OCC6503" -puts "================" -puts "" -####################################################################################### -# Incorrect calculation of bounding box for infinite surfaces -####################################################################################### - -set BugNumber OCC6503 - -plane pl 0 0 0 0 0 1 -mkface f pl -set info_result [bounding f -save x1 y1 z1 x2 y2 z2] - -set good_x1 -1e+100 -set good_y1 -1e+100 -set good_z1 -9.9999999999999995e-08 -set good_x2 1e+100 -set good_y2 1e+100 -set good_z2 9.9999999999999995e-08 - -checkreal "x1" [dval x1] ${good_x1} 0 0.001 -checkreal "y1" [dval y1] ${good_y1} 0 0.001 -checkreal "z1" [dval z1] ${good_z1} 0 0.001 -checkreal "x2" [dval x2] ${good_x2} 0 0.001 -checkreal "y2" [dval y2] ${good_y2} 0 0.001 -checkreal "z2" [dval z2] ${good_z2} 0 0.001 diff --git a/tests/bugs/moddata_3/bug23575 b/tests/bugs/moddata_3/bug23575 deleted file mode 100644 index 8b1d08a15c..0000000000 --- a/tests/bugs/moddata_3/bug23575 +++ /dev/null @@ -1,18 +0,0 @@ -puts "========" -puts "OCC23575" -puts "========" -puts "" -################################################################################################## -# Bounding box for a planar edge has non-zero dimension in direction orthogonal to an edge plane -################################################################################################## - -bsplinecurve c 3 2 0 4 1 4 0 0 0 1 0 1 0 1 1 1 0 1 1 0 0 1 -mkedge e c -bounding e -save Xmin Ymin Zmin Xmax Ymax Zmax - -checkreal "Xmin" [dval Xmin] 0. 0.1 0. -checkreal "Ymin" [dval Ymin] 0. 0.1 0. -checkreal "Zmin" [dval Zmin] 0. 0.1 0. -checkreal "Xmax" [dval Xmax] 1. 0.1 0. -checkreal "Ymax" [dval Ymax] 1. 0.1 0. -checkreal "Zmax" [dval Zmax] 0. 0.1 0. diff --git a/tests/bugs/moddata_3/bug23939 b/tests/bugs/moddata_3/bug23939 deleted file mode 100644 index 7cc0a3bda7..0000000000 --- a/tests/bugs/moddata_3/bug23939 +++ /dev/null @@ -1,28 +0,0 @@ -puts "========================" -puts " CR23939 " -puts "========================" -puts "" -################################################################## -## Incorrect circle parameter in IntAna -################################################################## - -circle c1 0 0 10 -circle c2 7 0 3 - -set info1 [2dintanalytical c1 c2] -regexp {parameter on the fist: +([-0-9.+eE]+) parameter on the second: +([-0-9.+eE]+)} ${info1} full p1_1 p1_2 -if { ${p1_1} != 0 } { - puts "Bad first parameter p1_1=${p1_1}" -} -if { ${p1_2} != 0 } { - puts "Bad second parameter p1_2=${p1_2}" -} - -set info2 [2dintanalytical c2 c1] -regexp {parameter on the fist: +([-0-9.+eE]+) parameter on the second: +([-0-9.+eE]+)} ${info2} full p2_1 p2_2 -if { ${p2_1} != 0 } { - puts "Bad first parameter p2_1=${p2_1}" -} -if { ${p2_2} != 0 } { - puts "Bad second parameter p2_2=${p2_2}" -} diff --git a/tests/bugs/moddata_3/bug24138 b/tests/bugs/moddata_3/bug24138 deleted file mode 100755 index 18c0506e45..0000000000 --- a/tests/bugs/moddata_3/bug24138 +++ /dev/null @@ -1,53 +0,0 @@ -puts "================" -puts "OCC24138" -puts "================" -puts "" -####################################################################### -# Exception during projection of the point on the face -####################################################################### - -ellipse w 0 0 0 10 5 -mkedge w w -wire w w -mkplane w w -prism s w 2 0 30 -explode s f -copy s_1 f -point p 0.753071156928785 4.98580193823337 0 - -set proj_fp [projponf f p -t] -regexp {proj dist = ([-0-9.+eE]+)} ${proj_fp} full dist -regexp {uvproj = ([-0-9.+eE]+) ([-0-9.+eE]+)} ${proj_fp} full uproj vproj -regexp {pproj = ([-0-9.+eE]+) ([-0-9.+eE]+) ([-0-9.+eE]+)} ${proj_fp} full proj1 proj2 - -puts "dist=${dist}" -puts "uproj=${uproj}" -puts "vproj=${vproj}" -puts "proj1=${proj1}" -puts "proj2=${proj2}" - -set CMP_TOL [checkmaxtol f] - -puts "CMP_TOL=${CMP_TOL}" - -set good_dist 9.16061678111512e-10 -set good_uproj 1.4954178490327235 -set good_vproj -2.3095450102606156e-12 -set good_proj1 0.75307115689421944 -set good_proj2 4.9858019373179632 - -if { [expr abs(${dist} - ${good_dist}) ] > ${CMP_TOL} } { - puts "Error: invalid dist" -} -if { [expr abs(${uproj} - ${good_uproj}) ] > ${CMP_TOL} } { - puts "Error: invalid uproj" -} -if { [expr abs(${vproj} - ${good_vproj}) ] > ${CMP_TOL} } { - puts "Error: invalid vproj" -} -if { [expr abs(${proj1} - ${good_proj1}) ] > ${CMP_TOL} } { - puts "Error: invalid proj1" -} -if { [expr abs(${proj2} - ${good_proj2}) ] > ${CMP_TOL} } { - puts "Error: invalid proj2" -} diff --git a/tests/bugs/moddata_3/bug24375 b/tests/bugs/moddata_3/bug24375 deleted file mode 100644 index d4861f7ed2..0000000000 --- a/tests/bugs/moddata_3/bug24375 +++ /dev/null @@ -1,32 +0,0 @@ -puts "========================" -puts " CR24375 " -puts "========================" -puts "" -################################################################## -## Exception in IntAna on touching circles -################################################################## - -circle c1 10 0 100 -circle c2 10.00000000000001 0 100 - -set info1 [2dintanalytical c1 c2] - -set str1 "Intersection point 1 : +\(\[-0-9.+eE\]+\) +\(\[-0-9.+eE\]+\)\n" -set str2 "parameter on the fist: +\(\[-0-9.+eE\]+\) parameter on the second: +\(\[-0-9.+eE\]+\)\n" -set str3 "Intersection point 2 : +\(\[-0-9.+eE\]+\) +\(\[-0-9.+eE\]+\)\n" -set str4 "parameter on the fist: +\(\[-0-9.+eE\]+\) parameter on the second: +\(\[-0-9.+eE\]+\)\n" - -regexp "${str1}${str2}${str3}${str4}" ${info1} full ip1_1 ip1_2 p1_1 p1_2 ip2_1 ip2_2 p2_1 p2_2 - -set tol_abs_length 1.0e-07 -set tol_rel_length 0.01 - -set expected_p1_1 1.5707963267948966 -set expected_p1_2 1.5707963267948968 -set expected_p2_1 4.7123889803846897 -set expected_p2_2 4.7123889803846897 - -checkreal "Parameter p1_1" ${p1_1} ${expected_p1_1} ${tol_abs_length} ${tol_rel_length} -checkreal "Parameter p1_2" ${p1_2} ${expected_p1_2} ${tol_abs_length} ${tol_rel_length} -checkreal "Parameter p2_1" ${p2_1} ${expected_p2_1} ${tol_abs_length} ${tol_rel_length} -checkreal "Parameter p2_2" ${p2_2} ${expected_p2_2} ${tol_abs_length} ${tol_rel_length} diff --git a/tests/bugs/moddata_3/bug27356 b/tests/bugs/moddata_3/bug27356 deleted file mode 100644 index 72c3a6a1d0..0000000000 --- a/tests/bugs/moddata_3/bug27356 +++ /dev/null @@ -1,18 +0,0 @@ -puts "# =============================================================" -puts "# 0027356: BRepTools::Clean() does not clean free edges from Poly_Polygon3D" -puts "# =============================================================" -puts "" - -puts "Create simple straight edge and tessellate it" -vertex v1 0 0 0 -vertex v2 1 0 0 -edge e v1 v2 -incmesh e 0.01 - -puts "Clean triangulation and check that there are no Polygon3Ds remained" -tclean e -if { ! [regexp {Dump of ([0-9]+) Polygon3Ds} [dump e] res count] } { - puts "Error: Cannot find number of Polygon3Ds in output of trinfo command" -} elseif { $count != 0 } { - puts "Error: $count Polygon3Ds are found (zero expected)!" -} \ No newline at end of file diff --git a/tests/bugs/moddata_3/bug27467 b/tests/bugs/moddata_3/bug27467 deleted file mode 100644 index b6ccf7c908..0000000000 --- a/tests/bugs/moddata_3/bug27467 +++ /dev/null @@ -1,28 +0,0 @@ -puts "============" -puts "OCC27467" -puts "============" -puts "" -######################################################################### -# Modeling Algorithms - class Extrema_ExtCC2d does not find extremum between two intersecting lines -# Analytical solver can not work on 2 lines. -######################################################################### - -line l1 0 0 0 -1 -trim l1 l1 0 23 - -line l2 1 -9.5 -1 -0 -trim l2 l2 0 2 -set info [2dextrema l1 l2] - -# Number of solutions check. -# There should be only one solution - intersection point. -if {[llength $info] != 4} { - ERROR: Incorrect number of solutions. -} - -# Check distance. -regexp "dist 1: +(\[-0-9.+eE\]+)" $info full aDist -set absTol 1.0e-9 -set relTol 0.001 -set aDist_Exp 0.0 -checkreal "Distance value check" $aDist $aDist_Exp $absTol $relTol diff --git a/tests/bugs/moddata_3/bug29662 b/tests/bugs/moddata_3/bug29662 deleted file mode 100644 index 723e93b0d9..0000000000 --- a/tests/bugs/moddata_3/bug29662 +++ /dev/null @@ -1,19 +0,0 @@ -puts "===========" -puts "0029662" -puts "===========" -puts "" -######################################################## -# Allow replacement of Compounds via BRepTools_ReShape -######################################################## - -box b1 10 10 10 -box b2 10 0 0 10 10 10 -box b3 0 0 10 10 10 10 -box b4 10 0 10 10 10 10 -box b5 20 0 0 10 10 10 -compound b1 b2 c1 -compound b3 b4 c2 -compound c1 c2 c -compound b5 c3 -reshape res c -replace c2 c3 -until compound -checknbshapes res -solid 3 \ No newline at end of file diff --git a/tests/bugs/moddata_3/bug29723 b/tests/bugs/moddata_3/bug29723 deleted file mode 100644 index 748949e70a..0000000000 --- a/tests/bugs/moddata_3/bug29723 +++ /dev/null @@ -1,29 +0,0 @@ -puts "==========" -puts "0029723: Modeling Data - Get rid of second writing format (additional save of UV points)" -puts "==========" -puts "" - -pload MODELING VISUALIZATION - -box testBox 10 20 30 -nurbsconvert nurbsBox testBox - -writebrep nurbsBox "${imagedir}/${casename}_topBox1.brep" -version 1 -readbrep "${imagedir}/${casename}_topBox1.brep" topBox1 -checkprops topBox1 -equal nurbsBox - -writebrep nurbsBox "${imagedir}/${casename}_topBox2.brep" -version 2 -readbrep "${imagedir}/${casename}_topBox2.brep" topBox2 -checkprops topBox2 -equal nurbsBox - -writebrep nurbsBox "${imagedir}/${casename}_topBox3.bbrep" -version 1 -binary on -readbrep "${imagedir}/${casename}_topBox3.bbrep" topBox3 -checkprops topBox3 -equal nurbsBox - -writebrep nurbsBox "${imagedir}/${casename}_topBox4.bbrep" -version 2 -binary on -readbrep "${imagedir}/${casename}_topBox4.bbrep" topBox4 -checkprops topBox4 -equal nurbsBox - -writebrep nurbsBox "${imagedir}/${casename}_topBox5.bbrep" -version 3 -binary on -readbrep "${imagedir}/${casename}_topBox5.bbrep" topBox5 -checkprops topBox5 -equal nurbsBox diff --git a/tests/bugs/moddata_3/bug30422 b/tests/bugs/moddata_3/bug30422 deleted file mode 100644 index c897054a21..0000000000 --- a/tests/bugs/moddata_3/bug30422 +++ /dev/null @@ -1,56 +0,0 @@ -puts "=========" -puts "0030422: Modeling Data - Random behaviour of BRepAdaptor_CompCurve" -puts "=========" -puts "" - -vertex vf1 0 0 0 -vertex vf2 1 0 0 -vertex vf3 2 0 0 -vertex vf4 3 0 0 -vertex vf5 4 0 0 -## -edge ef1 vf1 vf2 -edge ef2 vf2 vf3 -edge ef3 vf3 vf4 -edge ef4 vf5 vf4 -## -shape wf w -add ef1 wf -add ef2 wf -add ef3 wf -add ef4 wf -## -wexplo wf -# -if {![isdraw WEDGE_3] } { - puts "Error: wire explorer failed" -} else { - unset WEDGE_1 - unset WEDGE_2 - unset WEDGE_3 -} -## -vertex vs5 4 0 0 -vertex vs2 1 0 0 -vertex vs3 2 0 0 -vertex vs4 3 0 0 -vertex vs1 0 0 0 -## -edge es1 vs1 vs2 -edge es2 vs2 vs3 -edge es3 vs3 vs4 -edge es4 vs5 vs4 -## -shape ws w -add es1 ws -add es4 ws -add es3 ws -add es2 ws -## -wexplo ws -# -if {![isdraw WEDGE_3] } { - puts "Error: wire explorer failed" -} - - diff --git a/tests/bugs/moddata_3/bug31136_5 b/tests/bugs/moddata_3/bug31136_5 deleted file mode 100644 index 8bb3c9d9b3..0000000000 --- a/tests/bugs/moddata_3/bug31136_5 +++ /dev/null @@ -1,69 +0,0 @@ -puts "==========" -puts "0031136: BinXCAF persistence loses normals from triangulation-only Faces" -puts "==========" -puts "" - -pload OCAF XDE - -StoreTriangulation 1 -normals -set res [StoreTriangulation -getnormals] -if { $res != 1 } { - puts "Error : normals not on" -} -StoreTriangulation 1 -normals 0 -set res [StoreTriangulation -getnormals] -if { $res != 0 } { - puts "Error : normals not off" -} -StoreTriangulation 1 -normals 1 -set res [StoreTriangulation -getnormals] -if { $res != 1 } { - puts "Error : normals not on" -} -StoreTriangulation 1 -nonormals -set res [StoreTriangulation -getnormals] -if { $res != 0 } { - puts "Error : normals not off" -} -StoreTriangulation 1 -nonormals 0 -set res [StoreTriangulation -getnormals] -if { $res != 1 } { - puts "Error : normals not on" -} -StoreTriangulation 1 -nonormals 1 -set res [StoreTriangulation -getnormals] -if { $res != 0 } { - puts "Error : normals not off" -} -StoreTriangulation -normals -set res [StoreTriangulation -getnormals] -if { $res != 1 } { - puts "Error : normals not on" -} -StoreTriangulation -normals 0 -set res [StoreTriangulation -getnormals] -if { $res != 0 } { - puts "Error : normals not off" -} -StoreTriangulation -normals 1 -set res [StoreTriangulation -getnormals] -if { $res != 1 } { - puts "Error : normals not on" -} -StoreTriangulation -nonormals -set res [StoreTriangulation -getnormals] -if { $res != 0 } { - puts "Error : normals not off" -} -StoreTriangulation -nonormals 0 -set res [StoreTriangulation -getnormals] -if { $res != 1 } { - puts "Error : normals not on" -} -StoreTriangulation -nonormals 1 -set res [StoreTriangulation -getnormals] -if { $res != 0 } { - puts "Error : normals not off" -} - -puts "OK" \ No newline at end of file diff --git a/tests/bugs/moddata_3/bug31661_1 b/tests/bugs/moddata_3/bug31661_1 deleted file mode 100644 index b30ef8fe2a..0000000000 --- a/tests/bugs/moddata_3/bug31661_1 +++ /dev/null @@ -1,26 +0,0 @@ -puts "" -puts "==========================================================================" -puts "OCC31661: Modeling Data - Algorithm crashes when projecting parabola or hyperbola to plane" -puts "==========================================================================" -puts "" - -parabola p 0 0 0 1 1 1 2 0 -2 10 -plane pln 0 0 0 0 0 1 -projonplane r p pln 0 - -if {![regexp {Parabola} [dump r]]} { - puts "ERROR: Projected curve is not a parabola" -} - -trim p p -100 100 -projonplane rp p pln 0 - -if {![regexp {Parabola} [dump rp]]} { - puts "ERROR: Projected curve is not a parabola" -} - -checklength rp -l 408.40363195229503 -bounds rp t1 t2 -checkreal t1 [dval t1] -91.077748943768597 1.e-7 1.e-7 -checkreal t2 [dval t2] 72.221567418462357 1.e-7 1.e-7 - diff --git a/tests/bugs/moddata_3/bug31661_2 b/tests/bugs/moddata_3/bug31661_2 deleted file mode 100644 index 0e601af77e..0000000000 --- a/tests/bugs/moddata_3/bug31661_2 +++ /dev/null @@ -1,26 +0,0 @@ -puts "" -puts "==========================================================================" -puts "OCC31661: Modeling Data - Algorithm crashes when projecting parabola or hyperbola to plane" -puts "==========================================================================" -puts "" - -hyperbola h 0 0 0 1 1 1 2 0 -2 10 10 -plane pln 0 0 0 0 0 1 -projonplane rh h pln 0 - -if {![regexp {Hyperbola} [dump rh]]} { - puts "ERROR: Projected curve is not a hyperbola" -} - -trim h h -5 5 -projonplane rh h pln 0 - -if {![regexp {Hyperbola} [dump rh]]} { - puts "ERROR: Projected curve is not a hyperbola" -} - -checklength rh -l 1664.3732976598988 -bounds rh t1 t2 -checkreal t1 [dval t1] -5.23179933356147 1.e-7 1.e-7 -checkreal t2 [dval t2] 4.76820064934972 1.e-7 1.e-7 - diff --git a/tests/bugs/moddata_3/bug31946 b/tests/bugs/moddata_3/bug31946 deleted file mode 100644 index 5803e5ea60..0000000000 --- a/tests/bugs/moddata_3/bug31946 +++ /dev/null @@ -1,49 +0,0 @@ -puts "==========" -puts "0031946: Modeling Data - replace version numbers with enumerations in TopTools and BinTools" -puts "==========" -puts "" - -pload MODELING VISUALIZATION - -box testBox 10 20 30 -incmesh testBox 0.1 - -writebrep testBox "${imagedir}/${casename}_topBox1.brep" -readbrep "${imagedir}/${casename}_topBox1.brep" topBox1 -trinfo topBox1 -checktrinfo topBox1 -tri 12 - -writebrep testBox "${imagedir}/${casename}_topBox2.brep" -noTriangles -readbrep "${imagedir}/${casename}_topBox2.brep" topBox2 -trinfo topBox2 -checktrinfo topBox2 -tri 0 - -writebrep testBox "${imagedir}/${casename}_topBox3.brep" -noTriangles on -binary off -readbrep "${imagedir}/${casename}_topBox3.brep" topBox3 -trinfo topBox3 -checktrinfo topBox3 -tri 0 - -writebrep testBox "${imagedir}/${casename}_topBox4.brep" -noTriangles off -binary off -readbrep "${imagedir}/${casename}_topBox4.brep" topBox4 -trinfo topBox4 -checktrinfo topBox4 -tri 12 - -writebrep testBox "${imagedir}/${casename}_binBox1.bbrep" -binary on -readbrep "${imagedir}/${casename}_binBox1.bbrep" binBox1 -trinfo binBox1 -checktrinfo binBox1 -tri 12 - -writebrep testBox "${imagedir}/${casename}_binBox2.bbrep" -noTriangles -binary on -readbrep "${imagedir}/${casename}_binBox2.bbrep" binBox2 -trinfo binBox2 -checktrinfo binBox2 -tri 0 - -writebrep testBox "${imagedir}/${casename}_binBox3.bbrep" -noTriangles on -binary on -readbrep "${imagedir}/${casename}_binBox3.bbrep" binBox3 -trinfo binBox3 -checktrinfo binBox3 -tri 0 - -writebrep testBox "${imagedir}/${casename}_binBox4.bbrep" -noTriangles off -binary on -readbrep "${imagedir}/${casename}_binBox4.bbrep" binBox4 -trinfo binBox4 -checktrinfo binBox4 -tri 12 diff --git a/tests/bugs/moddata_3/bug33828 b/tests/bugs/moddata_3/bug33828 deleted file mode 100644 index 9dbdf6a337..0000000000 --- a/tests/bugs/moddata_3/bug33828 +++ /dev/null @@ -1,35 +0,0 @@ -puts "===========================================================" -puts "0033828: Modeling Data - GCPnts_QuasiUniformDeflection" -puts "returns very different results under small change in deflection" -puts "===========================================================" - -proc check_crvpoints {cc deflection nb_expected} { - upvar ${cc} ${cc} - - set str1 "Nb points +: +(\[-0-9.+eE\]+)\n" - set str2 "Max defl: +(\[-0-9.+eE\]+) +(\[-0-9.+eE\]+) +(\[-0-9.+eE\]+) +(\[-0-9.+eE\]+)" - - set info [crvpoints r ${cc} ${deflection}] - regexp "${str1}${str2}" ${info} full Nb dmax ufmax ulmax i - - if { ${Nb} != ${nb_expected} } { - puts "Error : bad value of Nb points = ${Nb}, expected ${nb_expected}" - } - - if { ${dmax} > ${deflection} } { - puts "Error : bad value of maximum deflection = ${dmax}, expected < ${deflection}" - } -} - -bsplinecurve cu 3 7 0 4 0.17 2 0.33 2 0.5 2 0.67 2 0.83 2 1 4 0.163 0.233 0 1 0.158 0.204 0 1 0.139 0.180 0 1 0.086 0.159 0 1 0.055 0.163 0 1 0.009 0.196 0 1 -0.004 0.225 0 1 0.002 0.281 0 1 0.019 0.307 0 1 0.070 0.332 0 1 0.101 0.331 0 1 0.149 0.301 0 1 0.164 0.274 0 1 0.163 0.246 0 1 - -check_crvpoints cu .5 2 -check_crvpoints cu .1 3 -check_crvpoints cu .05 5 -check_crvpoints cu .025 5 -check_crvpoints cu .007 9 -check_crvpoints cu .005 17 -check_crvpoints cu .0005 33 -check_crvpoints cu .0003 65 -check_crvpoints cu .0002 65 -check_crvpoints cu .0001 73 diff --git a/tests/bugs/step/bug23203 b/tests/bugs/step/bug23203 deleted file mode 100755 index 07525ad5dd..0000000000 --- a/tests/bugs/step/bug23203 +++ /dev/null @@ -1,60 +0,0 @@ -puts "========================" -puts "OCC23203" -puts "========================" -puts "" -####################################################################### -# STEP import produces wrong surface of revolution on ellipse -####################################################################### - -ellipse e 0 0 0 0 -1 0 1 0 -1 10 5 -revsurf re e 0 0 0 0 0 1 -mkface f re 0 3 0 1 -newmodel - -set aFile ${imagedir}/bug23203.stp -file delete ${aFile} -if { [file exists ${aFile}] } { - puts "Error : There is old ${aFile} file." -} - -stepwrite 0 f ${aFile} -stepread ${aFile} res * -file delete ${aFile} - -explode res_1 f -mksurface ress1 res_1_1 -set log [dump ress1] - -if {[regexp {Trimmed +curve} ${log}]} { - puts "Error: bad basis curve" -} else { - puts "OK: good basis curve" -} - -regexp {XAxis :([-0-9.+eE]+), +([-0-9.+eE]+), +([-0-9.+eE]+)} ${log} full XAxis1 XAxis2 XAxis3 -regexp {YAxis :([-0-9.+eE]+), +([-0-9.+eE]+), +([-0-9.+eE]+)} ${log} full YAxis1 YAxis2 YAxis3 - -set good_XAxis1 0.707106781186548 -set good_XAxis2 0 -set good_XAxis3 -0.707106781186548 -set good_YAxis1 0.707106781186548 -set good_YAxis2 0 -set good_YAxis3 0.707106781186548 - -set Precision 1.e6 - -if {[expr abs(${XAxis1} - ${good_XAxis1})] > ${Precision} || - [expr abs(${XAxis2} - ${good_XAxis2})] > ${Precision} || - [expr abs(${XAxis3} - ${good_XAxis3})] > ${Precision}} { - puts "Error : bad XAxis" -} else { - puts "OK : good XAxis" -} - -if {[expr abs(${YAxis1} - ${good_YAxis1})] > ${Precision} || - [expr abs(${YAxis2} - ${good_YAxis2})] > ${Precision} || - [expr abs(${YAxis3} - ${good_YAxis3})] > ${Precision}} { - puts "Error : bad YAxis" -} else { - puts "OK : good YAxis" -} diff --git a/tests/bugs/step/bug25694 b/tests/bugs/step/bug25694 deleted file mode 100644 index 9cfd3ebdc7..0000000000 --- a/tests/bugs/step/bug25694 +++ /dev/null @@ -1,20 +0,0 @@ -puts "========" -puts "OCC25694" -puts "========" -puts "" -################################################### -# Change STEP exporter to use AP214 IS by default -################################################### - -box b 1 2 3 -stepwrite a b - -set bug_info [data g] - -set bug_info [string trim [string range $bug_info [string first "FILE_SCHEMA" $bug_info] [expr {[string length $bug_info] - 1}]]] -set bug_info [string trim [string range $bug_info 0 [string first ";" $bug_info]]] -set bug_info [string trim [string range $bug_info [expr {[string first "'" $bug_info] + 1}] [expr {[string last "'" $bug_info] - 1}]]] - -if {$bug_info != "AUTOMOTIVE_DESIGN { 1 0 10303 214 1 1 1 1 }"} { - puts "ERROR: OCC25694 is reproduced." -} diff --git a/tests/bugs/step/bug25989 b/tests/bugs/step/bug25989 deleted file mode 100644 index 4d4651ed1e..0000000000 --- a/tests/bugs/step/bug25989 +++ /dev/null @@ -1,39 +0,0 @@ -puts "========" -puts "OCC25989" -puts "========" -puts "" -################################################ -# toridial surface gets damaged in STEP export -################################################ - -set StepFileName ${imagedir}/${casename}_fusion-step1-out.step - -catch {exec rm ${StepFileName}} - -box Box 10 10 10 -pcylinder Cylinder 2 10 -psphere Sphere 5 -ptorus Torus 10 2 - -bclearobjects -bcleartools -baddobjects Box -baddtools Cylinder Sphere Torus -bfillds -bbop Fusion 1 - -checkshape Fusion -bopcheck Fusion - -set FusionVolume [lindex [string trim [vprops Fusion]] 2] - -stepwrite m Fusion -writeall $StepFileName - -stepread $StepFileName a * -renamevar a_1 result - -checkshape result -bopcheck result - -checkprops result -v $FusionVolume diff --git a/tests/bugs/step/bug27070 b/tests/bugs/step/bug27070 deleted file mode 100644 index 250204c301..0000000000 --- a/tests/bugs/step/bug27070 +++ /dev/null @@ -1,8 +0,0 @@ -puts "# =======================================================================" -puts "# 0027070: Segfault when transferring HLR-created shapes via STEPControl_Writer" -puts "# =======================================================================" -puts "" - -puts "Check that writing null shape does not produce access violation" -puts "REQUIRED ALL: Error: translation failed, status = 0" -stepwrite a a diff --git a/tests/bugs/step/bug27313 b/tests/bugs/step/bug27313 deleted file mode 100644 index 05177a8630..0000000000 --- a/tests/bugs/step/bug27313 +++ /dev/null @@ -1,31 +0,0 @@ -puts "========" -puts "OCC27313" -puts "========" -puts "" -########################################################################## -# Exception during WriteStep with PMI -########################################################################## - -pload OCAF - -box b 10 10 10 -explode b -explode b_1 -NewDocument D -XAddShape D b -XAddGeomTolerance D b_1_1 -XAddDatum D b_1_2 -#0:1:4:1 -#0:1:4:2 -XSetDatumName D 0:1:4:2 A -XAddDatumModifier D 0:1:4:2 10 -XSetDatumPosition D 0:1:4:2 1 -XSetDatum D 0:1:4:2 0:1:4:1 -XSetToleranceValue D 0:1:4:1 0.5 -XSetTypeOfTolerance D 0:1:4:1 1 -XSetTypeOfToleranceValue D 0:1:4:1 1 -param write.step.schema 5 -newmodel -WriteStep D $imagedir/${casename}_D.stp -param write.step.schema 4 -newmodel diff --git a/tests/bugs/step/bug28024 b/tests/bugs/step/bug28024 deleted file mode 100644 index 45df53c439..0000000000 --- a/tests/bugs/step/bug28024 +++ /dev/null @@ -1,47 +0,0 @@ -puts "============" -puts "OCC28024 Data Exchange, Configuration - revise XSTEPResource initialization" -puts "============" -puts "" -##################################################### -# Testing the mechanism for changing options of ShapeHealing -# from DRAW -##################################################### - -pload MODELING XDE - -if { [info exists imagedir] == 0 } { - set imagedir ../bug28024 - if {![file exists ${imagedir}]} { - file mkdir ${imagedir} - } -} -set step_file ${imagedir}/inv_triangle.stp - -# Make simple triangle with INNER wire -vertex v1 0 0 0 -vertex v2 1 0 0 -vertex v3 0 1 0 -edge e1 v2 v1 -edge e2 v3 v2 -edge e3 v1 v3 -wire w1 e1 e3 e2 -plane p1 -mkface f1 p1 w1 norient - -# Save to STEP -testwritestep ${step_file} f1 - -# Empty resource file name to take params from InterfaceStatic -param "read.step.resource.name" "\"\"" -# Turn off FixOrientation procedure -param "FromSTEP.FixShape.FixOrientationMode" 0 - -# Read from STEP without shape healing -stepread ${step_file} r * -explode r_1 f - -# The area of triangle must be negative -checkarea r_1_1 -0.5 1e-6 0.001 - -param "read.step.resource.name" "STEP" -param "FromSTEP.FixShape.FixOrientationMode" -1 diff --git a/tests/bugs/step/bug28454_1 b/tests/bugs/step/bug28454_1 deleted file mode 100644 index 45d78428d7..0000000000 --- a/tests/bugs/step/bug28454_1 +++ /dev/null @@ -1,117 +0,0 @@ -puts "================" -puts "0028454: Data Exchange - Names with Special Characters Cannot Be Read from STEP or IGES Files" -puts "Target encodings: ISO 8859-1, ISO 8859-2, ISO 8859-3, ISO 8859-4, ISO 8859-5, ISO 8859-6,, ISO 8859-7, ISO 8859-8" -puts "Test case:" -puts "1) Creates a temporary STEP file-template using WriteStep." -puts "2) Reads generated template and replaces @tmp_name@ entity in it with target language characters using Tcl." -puts "3) Generates 2 STEP files in UTF-8 and ISO 8859-(N) encodings (converted by Tcl)." -puts "4) Reads generated files using StepRead and validates entity name." -puts "================" -puts "" - -proc fileToString { thePath } { - set aFile [open "$thePath" r] - set aText [read $aFile [file size "$thePath"]] - close $aFile - return $aText -} - -proc fileFromString { thePath theContent theCodePage } { - set aFile [open "$thePath" w] - fconfigure $aFile -translation lf -encoding "$theCodePage" - puts $aFile $theContent - close $aFile -} - -proc fileCreateAndCompare { thePathFrom theUtfPathTo theCpPathTo theNameFrom theNameTo theCodePage } { - regsub -all -- $theNameFrom [fileToString "$thePathFrom"] "$theNameTo" aContent - set aPathTo $theCpPathTo${theCodePage}.stp - fileFromString "$theUtfPathTo" "$aContent" "utf-8" - fileFromString "$aPathTo" "$aContent" "$theCodePage" - - param read.step.codepage UTF8 - ReadStep U "$theUtfPathTo" - ReadStep A "$aPathTo" - param read.step.codepage "$theCodePage" - ReadStep ISO "$aPathTo" - - if { [GetName U 0:1:1:1] != "$theNameTo" } { puts "Error: unable to read UTF-8 STEP" } - if { [GetName ISO 0:1:1:1] != "$theNameTo" } { puts "Error: unable to read $theCodePage STEP" } - if { [GetName A 0:1:1:1] == "$theNameTo" } { puts "Error: broken test case" } - Close A U ISO -silent -} - -pload XDE OCAF MODELING VISUALIZATION -set aTmpNameTmpl "@tmp_name@" -set aTmpFileTmpl "${imagedir}/${casename}-tmp.stp" -set aTmpFileUtf8 "${imagedir}/${casename}-tmp-utf8.stp" -set aTmpFileISO8859N "${imagedir}/${casename}-tmp-" - -# "Test" (english multi-encoding) + "Test" (encoding in the target language) - -# multi-encoding -set anEngName [encoding convertfrom utf-8 "\x54\x65\x73\x74"] -# ISO 8859-1 -set iso8859_1 [encoding convertfrom utf-8 "\x50\x72\x6f\x62\xed\x68\xe1"] -# ISO 8859-2 -set iso8859_2 [encoding convertfrom utf-8 "\x50\x72\x6f\x62\xed\x68\xe1"] -# ISO 8859-3 -set iso8859_3 [encoding convertfrom utf-8 "\xd6\x6c\xe7\x65\x6b"] -# ISO 8859-4 -set iso8859_4 [encoding convertfrom utf-8 "\x6d\xc4\x93\xc4\xa3\x69\x6e\x69\x65\x74"] -# ISO 8859-5 -set iso8859_5 [encoding convertfrom utf-8 "\xD0\xa2\xD0\xB5\xD1\x81\xD1\x82"] -# ISO 8859-6 -set iso8859_6 [encoding convertfrom utf-8 "\xd8\xa7\xd8\xae\xd8\xaa\xd8\xa8\xd8\xa7\xd8\xb1"] -# ISO 8859-7 -set iso8859_7 [encoding convertfrom utf-8 "\xce\xb4\xcf\x80\xce\xa8\xce\xae"] -# ISO 8859-8 -set iso8859_8 [encoding convertfrom utf-8 "\xc2\xb1\xd7\xa4\xd7\x9e\xd7\x9c\xd7\xa9"] -# ISO 8859-9 -set iso8859_9 [encoding convertfrom utf-8 "\xc4\x9f\xc5\x9f\xc4\x9e\xc5\x9e\xc3\x86"] - -box b 1 2 3 -Close A T U CP -silent - -XNewDoc T -XAddShape T b 0 -XSetColor T b 1 0 0 -SetName T 0:1:1:1 "$aTmpNameTmpl" -GetName T 0:1:1:1 -WriteStep T "$aTmpFileTmpl" - -puts "ISO 8859-1" -set aName "$anEngName $iso8859_1" -fileCreateAndCompare "$aTmpFileTmpl" "$aTmpFileUtf8" "$aTmpFileISO8859N" "$aTmpNameTmpl" "$aName" "iso8859-1" - -puts "ISO 8859-2" -set aName "$anEngName $iso8859_2" -fileCreateAndCompare "$aTmpFileTmpl" "$aTmpFileUtf8" "$aTmpFileISO8859N" "$aTmpNameTmpl" "$aName" "iso8859-2" - -puts "ISO 8859-3" -set aName "$anEngName $iso8859_3" -fileCreateAndCompare "$aTmpFileTmpl" "$aTmpFileUtf8" "$aTmpFileISO8859N" "$aTmpNameTmpl" "$aName" "iso8859-3" - -puts "ISO 8859-4" -set aName "$anEngName $iso8859_4" -fileCreateAndCompare "$aTmpFileTmpl" "$aTmpFileUtf8" "$aTmpFileISO8859N" "$aTmpNameTmpl" "$aName" "iso8859-4" - -puts "ISO 8859-5" -set aName "$anEngName $iso8859_5" -fileCreateAndCompare "$aTmpFileTmpl" "$aTmpFileUtf8" "$aTmpFileISO8859N" "$aTmpNameTmpl" "$aName" "iso8859-5" - -puts "ISO 8859-6" -set aName "$anEngName $iso8859_6" -fileCreateAndCompare "$aTmpFileTmpl" "$aTmpFileUtf8" "$aTmpFileISO8859N" "$aTmpNameTmpl" "$aName" "iso8859-6" - -puts "ISO 8859-7" -set aName "$anEngName $iso8859_7" -fileCreateAndCompare "$aTmpFileTmpl" "$aTmpFileUtf8" "$aTmpFileISO8859N" "$aTmpNameTmpl" "$aName" "iso8859-7" - -puts "ISO 8859-8" -set aName "$anEngName $iso8859_8" -fileCreateAndCompare "$aTmpFileTmpl" "$aTmpFileUtf8" "$aTmpFileISO8859N" "$aTmpNameTmpl" "$aName" "iso8859-8" - -puts "ISO 8859-9" -set aName "$anEngName $iso8859_9" -fileCreateAndCompare "$aTmpFileTmpl" "$aTmpFileUtf8" "$aTmpFileISO8859N" "$aTmpNameTmpl" "$aName" "iso8859-9" \ No newline at end of file diff --git a/tests/bugs/step/bug30189_2 b/tests/bugs/step/bug30189_2 deleted file mode 100644 index c5598320e1..0000000000 --- a/tests/bugs/step/bug30189_2 +++ /dev/null @@ -1,38 +0,0 @@ -######################################## -# Wrong export to STEP of located root. -######################################## - -pload OCAF - -XNewDoc D -box b 1 1 1 -box bb 2 0 0 1 1 1 -box bbb 4 0 0 1 1 1 -compound b bb c -copy c cc -ttranslate cc 0 2 0 -compound bbb c s -XAddShape D s -XAddShape D cc -WriteStep D $imagedir/${casename}.stp -ReadStep DD $imagedir/${casename}.stp - -# Check structure -set top_level [XGetTopLevelShapes DD] -if {$top_level != "0:1:1:1 0:1:1:2 0:1:1:3 0:1:1:4 0:1:1:5 0:1:1:6 "} { - puts "Error: wrong structure of document." -} - -# Check sharing -set nb [XNbComponents DD 0:1:1:6] -if {$nb != "1"} { - puts "Error: wrong structure of document." -} -set nb [XGetUsers DD 0:1:1:3] -if {$nb != "2"} { - puts "Error: wrong structure of document." -} - -Close D -Close DD -file delete $imagedir/${casename}.stp diff --git a/tests/bugs/step/bug30189_3 b/tests/bugs/step/bug30189_3 deleted file mode 100644 index 903407e2ef..0000000000 --- a/tests/bugs/step/bug30189_3 +++ /dev/null @@ -1,56 +0,0 @@ -######################################## -# Wrong export to STEP of located root. -######################################## - -pload OCAF - -box b 1 1 1 -copy b bb -copy b bbb -ttranslate b 2 0 0 -ttranslate bb 0 2 0 -ttranslate bbb 0 0 2 -XNewDoc D -XAddShape D b -XAddShape D bb -XAddShape D bbb -SetName D 0:1:1:2 box -SetName D 0:1:1:1 ref1_box -SetName D 0:1:1:3 ref2_box -SetName D 0:1:1:4 ref3_box -WriteStep D $imagedir/${casename}.stp -ReadStep DD $imagedir/${casename}.stp - -# Check structure -set top_level [XGetTopLevelShapes DD] -if {$top_level != "0:1:1:1 0:1:1:2 0:1:1:3 0:1:1:4 "} { - puts "Error: wrong structure of document." -} - -# Check sharing -set nb [XGetUsers DD 0:1:1:2] -if {$nb != "3"} { - puts "Error: wrong structure of document." -} - -# Check names -set name [GetName DD 0:1:1:1] -if {$name != "ref1_box"} { - puts "Error: wrong name." -} -set name [GetName DD 0:1:1:2] -if {$name != "box"} { - puts "Error: wrong name." -} -set name [GetName DD 0:1:1:3] -if {$name != "ref2_box"} { - puts "Error: wrong name." -} -set name [GetName DD 0:1:1:4] -if {$name != "ref3_box"} { - puts "Error: wrong name." -} - -Close D -Close DD -file delete $imagedir/${casename}.stp diff --git a/tests/bugs/step/bug30694 b/tests/bugs/step/bug30694 deleted file mode 100644 index 01c5718c15..0000000000 --- a/tests/bugs/step/bug30694 +++ /dev/null @@ -1,54 +0,0 @@ -puts "================" -puts "0030694: Data Exchange - support non-standard GB2312-encoded STEP files" -puts "" -puts "Test case:" -puts "1) Creates a temporary STEP file-template using WriteStep." -puts "2) Reads generated template and replaces @tmp_name@ entity in it with Simplified Chinese characters using Tcl." -puts "3) Generates 2 STEP files in UTF-8 and GB2312 encodings (converted by Tcl)." -puts "4) Reads generated files using StepRead and validates entity name." -puts "================" -puts "" - -proc fileToString { thePath } { - set aFile [open "$thePath" r] - set aText [read $aFile [file size "$thePath"]] - close $aFile - return $aText -} - -proc fileFromString { thePath theContent theCodePage } { - set aFile [open "$thePath" w] - fconfigure $aFile -translation lf -encoding "$theCodePage" - puts $aFile $theContent - close $aFile -} - -pload XDE OCAF MODELING VISUALIZATION -set aTmpNameTmpl "@tmp_name@" -set aTmpFileTmpl "${imagedir}/${casename}-tmp.stp" -set aTmpFileUtf8 "${imagedir}/${casename}-tmp-utf8.stp" -set aTmpFileGb "${imagedir}/${casename}-tmp-gb.stp" -# 国标 -set aName [encoding convertfrom unicode "\xFD\x56\x07\x68"] -box b 1 2 3 -Close A T U G -silent -XNewDoc T -XAddShape T b 0 -XSetColor T b 1 0 0 -SetName T 0:1:1:1 "$aTmpNameTmpl" -GetName T 0:1:1:1 -WriteStep T "$aTmpFileTmpl" - -regsub -all -- $aTmpNameTmpl [fileToString "$aTmpFileTmpl"] "$aName" aContent -fileFromString "$aTmpFileUtf8" "$aContent" "utf-8" -fileFromString "$aTmpFileGb" "$aContent" "gb2312" - -param read.step.codepage UTF8 -ReadStep U "$aTmpFileUtf8" -ReadStep A "$aTmpFileGb" -param read.step.codepage GB -ReadStep G "$aTmpFileGb" - -if { [GetName U 0:1:1:1] != "$aName" } { puts "Error: unable to read UTF-8 STEP" } -if { [GetName G 0:1:1:1] != "$aName" } { puts "Error: unable to read gb2312 STEP" } -if { [GetName A 0:1:1:1] == "$aName" } { puts "Error: broken test case" } diff --git a/tests/bugs/step/bug31670_1 b/tests/bugs/step/bug31670_1 deleted file mode 100644 index 17e22ca452..0000000000 --- a/tests/bugs/step/bug31670_1 +++ /dev/null @@ -1,117 +0,0 @@ -puts "================" -puts "0031670: Data Exchange - cp1251 Cyrillic characters in STEP file" -puts "Target encodings: cp1250, cp1251, cp1252, cp1253, cp1254, cp1255, cp1256,, cp1257, cp1258" -puts "Test case:" -puts "1) Creates a temporary STEP file-template using WriteStep." -puts "2) Reads generated template and replaces @tmp_name@ entity in it with target language characters using Tcl." -puts "3) Generates 2 STEP files in UTF-8 and CP125(N) encodings (converted by Tcl)." -puts "4) Reads generated files using StepRead and validates entity name." -puts "================" -puts "" - -proc fileToString { thePath } { - set aFile [open "$thePath" r] - set aText [read $aFile [file size "$thePath"]] - close $aFile - return $aText -} - -proc fileFromString { thePath theContent theCodePage } { - set aFile [open "$thePath" w] - fconfigure $aFile -translation lf -encoding "$theCodePage" - puts $aFile $theContent - close $aFile -} - -proc fileCreateAndCompare { thePathFrom theUtfPathTo theCpPathTo theNameFrom theNameTo theCodePage } { - set aCodePage [string tolower "$theCodePage"] - regsub -all -- $theNameFrom [fileToString "$thePathFrom"] "$theNameTo" aContent - fileFromString "$theUtfPathTo" "$aContent" "utf-8" - fileFromString "$theCpPathTo" "$aContent" "$aCodePage" - - param read.step.codepage UTF8 - ReadStep U "$theUtfPathTo" - ReadStep A "$theCpPathTo" - param read.step.codepage "$theCodePage" - ReadStep CP "$theCpPathTo" - - if { [GetName U 0:1:1:1] != "$theNameTo" } { puts "Error: unable to read UTF-8 STEP" } - if { [GetName CP 0:1:1:1] != "$theNameTo" } { puts "Error: unable to read $theCodePage STEP" } - if { [GetName A 0:1:1:1] == "$theNameTo" } { puts "Error: broken test case" } - Close A U CP -silent -} - -pload XDE OCAF MODELING VISUALIZATION -set aTmpNameTmpl "@tmp_name@" -set aTmpFileTmpl "${imagedir}/${casename}-tmp.stp" -set aTmpFileUtf8 "${imagedir}/${casename}-tmp-utf8.stp" -set aTmpFileCP125N "${imagedir}/${casename}-tmp-CP125N.stp" - -# "Test" (english multi-encoding) + "Test" (encoding in the target language) - -# multi-encoding -set anEngName [encoding convertfrom utf-8 "\x54\x65\x73\x74"] -# cp1250 -set aLat1Name [encoding convertfrom utf-8 "\x50\x72\x6f\x62\xed\x68\xe1"] -# cp1251 -set aCyrName [encoding convertfrom utf-8 "\xD0\xa2\xD0\xB5\xD1\x81\xD1\x82"] -# cp1252 -set aLat2Name [encoding convertfrom utf-8 "\x50\x72\x6f\x62\xed\x68\xe1"] -# cp1253 -set aGreekName [encoding convertfrom utf-8 "\xce\x94\xce\xbf\xce\xba\xce\xb9\xce\xbc\xce\xae"] -# cp1254 -set aTurkName [encoding convertfrom utf-8 "\xd6\x6c\xe7\x65\x6b"] -# cp1255 -set aHebrName [encoding convertfrom utf-8 "\xd7\x9e\xd6\xb4\xd7\x91\xd6\xb0\xd7\x97\xd6\xb8\xd7\x9f"] -# cp1256 -set anArabName [encoding convertfrom utf-8 "\xd8\xa7\xd8\xae\xd8\xaa\xd8\xa8\xd8\xa7\xd8\xb1"] -# cp1257 -set aBaltName [encoding convertfrom utf-8 "\x50\xc4\x81\x72\x62\x61\x75\x64\x65"] -# cp1258 -set aViettName [encoding convertfrom utf-8 "\u0054\u0068\u00ed \u006e\u0067\u0068\u0069\u1ec7\u006d"] - -box b 1 2 3 -Close A T U CP -silent - -XNewDoc T -XAddShape T b 0 -XSetColor T b 1 0 0 -SetName T 0:1:1:1 "$aTmpNameTmpl" -GetName T 0:1:1:1 -WriteStep T "$aTmpFileTmpl" - -puts "Central European" -set aName "$anEngName $aLat1Name" -fileCreateAndCompare "$aTmpFileTmpl" "$aTmpFileUtf8" "$aTmpFileCP125N" "$aTmpNameTmpl" "$aName" "CP1250" - -puts "Cyrillic" -set aName "$anEngName $aCyrName" -fileCreateAndCompare "$aTmpFileTmpl" "$aTmpFileUtf8" "$aTmpFileCP125N" "$aTmpNameTmpl" "$aName" "CP1251" - -puts "Western European" -set aName "$anEngName $aLat2Name" -fileCreateAndCompare "$aTmpFileTmpl" "$aTmpFileUtf8" "$aTmpFileCP125N" "$aTmpNameTmpl" "$aName" "CP1252" - -puts "Greek" -set aName "$anEngName $aGreekName" -fileCreateAndCompare "$aTmpFileTmpl" "$aTmpFileUtf8" "$aTmpFileCP125N" "$aTmpNameTmpl" "$aName" "CP1253" - -puts "Turkish" -set aName "$anEngName $aTurkName" -fileCreateAndCompare "$aTmpFileTmpl" "$aTmpFileUtf8" "$aTmpFileCP125N" "$aTmpNameTmpl" "$aName" "CP1254" - -puts "Hebrew" -set aName "$anEngName $aHebrName" -fileCreateAndCompare "$aTmpFileTmpl" "$aTmpFileUtf8" "$aTmpFileCP125N" "$aTmpNameTmpl" "$aName" "CP1255" - -puts "Arabic" -set aName "$anEngName $anArabName" -fileCreateAndCompare "$aTmpFileTmpl" "$aTmpFileUtf8" "$aTmpFileCP125N" "$aTmpNameTmpl" "$aName" "CP1256" - -puts "Baltic" -set aName "$anEngName $aBaltName" -fileCreateAndCompare "$aTmpFileTmpl" "$aTmpFileUtf8" "$aTmpFileCP125N" "$aTmpNameTmpl" "$aName" "CP1257" - -puts "Vietnamese" -set aName "$anEngName $aViettName" -fileCreateAndCompare "$aTmpFileTmpl" "$aTmpFileUtf8" "$aTmpFileCP125N" "$aTmpNameTmpl" "$aName" "CP1258" \ No newline at end of file diff --git a/tests/bugs/step/bug31923 b/tests/bugs/step/bug31923 deleted file mode 100644 index edc3fa0a17..0000000000 --- a/tests/bugs/step/bug31923 +++ /dev/null @@ -1,57 +0,0 @@ -puts "================" -puts "0031923: DXF import - add support of code page DOS850" -puts "" -puts "Test case:" -puts "1) Creates a temporary STEP file-template using WriteStep." -puts "2) Reads generated template and replaces @tmp_name@ entity in it with Latin characters using Tcl." -puts "3) Generates 2 STEP files in UTF-8 and ISO850 encodings (converted by Tcl)." -puts "4) Reads generated files using StepRead and validates entity name." -puts "================" -puts "" - -proc fileToString { thePath } { - set aFile [open "$thePath" r] - set aText [read $aFile [file size "$thePath"]] - close $aFile - return $aText -} - -proc fileFromString { thePath theContent theCodePage } { - set aFile [open "$thePath" w] - fconfigure $aFile -translation lf -encoding "$theCodePage" - puts $aFile $theContent - close $aFile -} - -pload XDE OCAF MODELING VISUALIZATION -set aTmpNameTmpl "@tmp_name@" -set aTmpFileTmpl "${imagedir}/${casename}-tmp.stp" -set aTmpFileUtf8 "${imagedir}/${casename}-tmp-utf8.stp" -set aTmpFileCP850 "${imagedir}/${casename}-tmp-cp850.stp" -# Überprüfung de codificação -set aName [encoding convertfrom utf-8 "\xc3\x9c\x62\x65\x72\x70\x72\xc3\xbc\x66\x75\x6e\x67 \x64\x65 \x63\x6f\x64\x69\x66\x69\x63\x61\xc3\xa7\xc3\xa3\x6f"] - -Close A T U C -silent - -box b 1 2 3 -XNewDoc T -XAddShape T b 0 -XSetColor T b 1 0 0 -SetName T 0:1:1:1 "$aTmpNameTmpl" -GetName T 0:1:1:1 -WriteStep T "$aTmpFileTmpl" - -regsub -all -- $aTmpNameTmpl [fileToString "$aTmpFileTmpl"] "$aName" aContent -fileFromString "$aTmpFileUtf8" "$aContent" "utf-8" -fileFromString "$aTmpFileCP850" "$aContent" "cp850" - -param read.step.codepage UTF8 -ReadStep U "$aTmpFileUtf8" -ReadStep A "$aTmpFileCP850" -param read.step.codepage CP850 -ReadStep C "$aTmpFileCP850" - -puts "Original name is 'Überprüfung de codificação'" -if { [GetName U 0:1:1:1] != "$aName" } { puts "Error: unable to read UTF-8 STEP" } -if { [GetName C 0:1:1:1] != "$aName" } { puts "Error: unable to read CP850 STEP" } -if { [GetName A 0:1:1:1] == "$aName" } { puts "Error: broken test case" } diff --git a/tests/bugs/step/bug32310 b/tests/bugs/step/bug32310 deleted file mode 100644 index 083b5a36c1..0000000000 --- a/tests/bugs/step/bug32310 +++ /dev/null @@ -1,28 +0,0 @@ -puts "====================================" -puts "0032310: Data Exchange - Invalid STEP export/import of backslashes in names \[Regression since OCCT 7.5.0\]" -puts "====================================" -puts "" - -pload OCAF -Close D -silent - -XNewDoc D -box box 1 1 1 -XAddShape D box - -SetName D 0:1:1:1 "a'''\\b\n\t\\c\\\\\\\\" -set original_name [GetName D 0:1:1:1] - -WriteStep D "$imagedir/${casename}.stp" -Close D - -ReadStep D "$imagedir/${casename}.stp" -set imported_name [GetName D 0:1:1:1] - -file delete "$imagedir/${casename}.stp" - -if {$original_name != $imported_name} { - puts "Error: 'Incorrect exporting name: $original_name != $imported_name" -} - -Close D diff --git a/tests/bugs/step/bug32817_1 b/tests/bugs/step/bug32817_1 deleted file mode 100644 index 20c191ea8c..0000000000 --- a/tests/bugs/step/bug32817_1 +++ /dev/null @@ -1,13 +0,0 @@ -puts "================" -puts "0032817: Data Exchange - Step export - writing untrimmed Curve" -puts "================" - -pload XDE - -catch {Close D} -XNewDoc D -line l1 0 0 0 0 1 0 -mkedge e1 l1 -XAddShape D e1 -WriteStep D $imagedir/${casename}.stp -file delete $imagedir/${casename}.stp diff --git a/tests/bugs/step/bug32817_2 b/tests/bugs/step/bug32817_2 deleted file mode 100644 index 147f5c6ba1..0000000000 --- a/tests/bugs/step/bug32817_2 +++ /dev/null @@ -1,13 +0,0 @@ -puts "================" -puts "0032817: Data Exchange - Step export - writing untrimmed Curve" -puts "================" - -pload XDE - -catch {Close D} -XNewDoc D -line l1 0 0 0 0 1 0 -mkedge e1 l1 10 2e+100 -XAddShape D e1 -WriteStep D $imagedir/${casename}.stp -file delete $imagedir/${casename}.stp diff --git a/tests/bugs/step/bug32817_3 b/tests/bugs/step/bug32817_3 deleted file mode 100644 index 9c4df939f0..0000000000 --- a/tests/bugs/step/bug32817_3 +++ /dev/null @@ -1,13 +0,0 @@ -puts "================" -puts "0032817: Data Exchange - Step export - writing untrimmed Curve" -puts "================" - -pload XDE - -catch {Close D} -XNewDoc D -line l1 0 0 0 1 1 0 -mkedge e1 l1 -2e+100 10 -XAddShape D e1 -WriteStep D $imagedir/${casename}.stp -file delete $imagedir/${casename}.stp diff --git a/tests/bugs/step/bug33815 b/tests/bugs/step/bug33815 deleted file mode 100644 index cb71e00123..0000000000 --- a/tests/bugs/step/bug33815 +++ /dev/null @@ -1,30 +0,0 @@ -puts "====================================" -puts "0033815: Data Exchange, Step Export - No names in STEP file when writing in non-manifold mode" -puts "====================================" -puts "" - -pload OCAF -Close D -silent - -XNewDoc D -box box 1 1 1 -XAddShape D box - -param write.step.nonmanifold 1 - -SetName D 0:1:1:1 "a'''\\b\n\t\\c\\\\\\\\" -set original_name [GetName D 0:1:1:1] - -WriteStep D "$imagedir/${casename}.stp" -Close D - -ReadStep D "$imagedir/${casename}.stp" -set imported_name [GetName D 0:1:1:1] - -file delete "$imagedir/${casename}.stp" - -if {$original_name != $imported_name} { - puts "Error: 'Incorrect exporting name: $original_name != $imported_name" -} - -Close D diff --git a/tests/bugs/step/bug_ocp1949_2 b/tests/bugs/step/bug_ocp1949_2 deleted file mode 100644 index a7d2f749da..0000000000 --- a/tests/bugs/step/bug_ocp1949_2 +++ /dev/null @@ -1,48 +0,0 @@ -puts "================================================" -puts "OCP-1949: Apply a scaling transformation to STEP" -puts "================================================" -puts "" - -pload OCAF - -Close D1 -silent -Close D2 -silent - -# Create simple mesh -box b 1 1 1 -incmesh b 1 -writestl b "$imagedir/${casename}.stl" -readstl b "$imagedir/${casename}.stl" - -# Create document with meters as internal units -XNewDoc D1 -XSetLengthUnit D1 m -XAddShape D1 b - -# apply parameters for tessellation export -set conf " -provider.STEP.OCC.write.schema : 5 -provider.STEP.OCC.write.tessellated : 1 -" - -WriteFile D1 "$imagedir/${casename}.stp" -conf ${conf} -ReadFile D2 "$imagedir/${casename}.stp" - -XGetOneShape a1 D1 -XGetOneShape a2 D2 - -# check sizes -set m_diag [eval distpp [bounding a1]] -set mm_diag [eval distpp [bounding a2]] -set tol 0.1 - -if {([expr abs($m_diag * 1000 - $mm_diag)] > $tol)} { - puts "Error: wrong size of models." - } - -# cleaning -Close D1 -Close D2 -file delete "$imagedir/${casename}.stp" -file delete "$imagedir/${casename}.stl" - diff --git a/tests/bugs/stlvrml/bug25279 b/tests/bugs/stlvrml/bug25279 deleted file mode 100755 index 0edcd42d5a..0000000000 --- a/tests/bugs/stlvrml/bug25279 +++ /dev/null @@ -1,32 +0,0 @@ -puts "================" -puts "OCC25279" -puts "================" -puts "" -####################################################################################### -# OCCT fails to read VRML file created by OCCT -####################################################################################### - -set BugNumber OCC25279 - -set aFile ${imagedir}/${test_image}.vrml -file delete ${aFile} - -ptorus res 10 8 0 90 270 -incmesh res 0.1 - -set TrinfoBefore [trinfo res] - -set version 2 -set mode 2 - -writevrml res ${aFile} ${version} ${mode} - -checktrinfo res -ref "${TrinfoBefore}" - -set Log [loadvrml test ${aFile}] - -if { [string length $Log] != 0 } { - puts "Faulty ${BugNumber}" -} else { - puts "OK ${BugNumber}" -} diff --git a/tests/bugs/stlvrml/bug25740 b/tests/bugs/stlvrml/bug25740 deleted file mode 100644 index 5be4b83834..0000000000 --- a/tests/bugs/stlvrml/bug25740 +++ /dev/null @@ -1,43 +0,0 @@ -puts "================" -puts "OCC25740" -puts "================" -puts "" -####################################################################################### -# VrmlData_Scene::WriteArrIndex() writes extra point indices -####################################################################################### - -set BugNumber OCC25740 - -set aFile $imagedir/${test_image}.vrml - -ptorus p 10 8 0 90 120 -incmesh p 0.1 - -explode p e - -writevrml p_3 ${aFile} 2 2 - -set status 1 -if { ![file exists ${aFile}] } { - set status 0 -} - -# Check file size -set filesize [ file size ${aFile} ] -if { ${filesize} == 0 } { - set status 0 -} - -set fd0 [ open ${aFile} r ] -set filecontent [ read ${fd0} ] -close $fd0 - -if { ![regexp {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15, -1} ${filecontent} full] } { - set status 0 -} - -if {$status == 1} { - puts "OK ${BugNumber}" -} else { - puts "Faulty ${BugNumber}" -} diff --git a/tests/bugs/stlvrml/bug26338 b/tests/bugs/stlvrml/bug26338 deleted file mode 100644 index ff82376735..0000000000 --- a/tests/bugs/stlvrml/bug26338 +++ /dev/null @@ -1,29 +0,0 @@ -puts "========" -puts "0026338: STL export (especially binary) needs a lot of time if selected export path is not local" -puts "========" -puts "" - -pload MODELING XSDRAW - -# check that export to STL correctly takes into account shape locations -box b1 5 5 5 -box b2 5 5 5 -ttranslate b2 10 10 10 -compound b1 b2 comp -incmesh comp 1. - -# write to binary STL -writestl comp $imagedir/${casename}.stl 1 - -# load STL -readstl result $imagedir/${casename}.stl -brep - -# check that bounding box is -bounding result -save Xmin Ymin Zmin Xmax Ymax Zmax -nodraw - -checkreal "Xmin" [dval Xmin] 0.0 1e-5 0. -checkreal "Ymin" [dval Ymin] 0.0 1e-5 0. -checkreal "Zmin" [dval Zmin] 0.0 1e-5 0. -checkreal "Xmax" [dval Xmax] 15. 1e-5 0. -checkreal "Ymax" [dval Ymax] 15. 1e-5 0. -checkreal "Zmax" [dval Zmax] 15. 1e-5 0. diff --git a/tests/bugs/stlvrml/bug30389 b/tests/bugs/stlvrml/bug30389 deleted file mode 100644 index 383d8953fb..0000000000 --- a/tests/bugs/stlvrml/bug30389 +++ /dev/null @@ -1,19 +0,0 @@ -puts "========" -puts "0030389: Data Exchange - StlAPI_Writer does not check if the face has triangulation" -puts "========" -puts "" - -box b 1 1 1 - -# mesh only 5 faces of the box -eval compound [lrange [explode b f] 0 4] cf -incmesh cf 0.1 - -# save box into stl -writestl b $imagedir/${casename}.stl - -# read stl -readstl result $imagedir/${casename}.stl -brep - -# check that it contains only 10 triangles -checknbshapes result -face 10 diff --git a/tests/bugs/xde/bug13175 b/tests/bugs/xde/bug13175 deleted file mode 100644 index b1127f3838..0000000000 --- a/tests/bugs/xde/bug13175 +++ /dev/null @@ -1,15 +0,0 @@ -puts "============" -puts "0013175: XCAF document with one vertex is exported to an incorrect STEP file" -puts "============" -puts "" - -vertex v 10 10 10 -XNewDoc D1 -XAddShape D1 v -XGetShape r1 D1 0:1:1:1 -checknbshapes r1 -vertex 1 - -WriteStep D1 ${imagedir}/${casename}.step -ReadStep D2 ${imagedir}/${casename}.step -XGetShape r2 D2 0:1:1:1 -checknbshapes r2 -vertex 1 diff --git a/tests/bugs/xde/bug1540 b/tests/bugs/xde/bug1540 deleted file mode 100755 index 1e594bd26c..0000000000 --- a/tests/bugs/xde/bug1540 +++ /dev/null @@ -1,25 +0,0 @@ -puts "================" -puts "OCC1540" -puts "================" -puts "" -########################################################## -# exception while writing step file with invisible layer -########################################################## - -set BugNumber OCC1540 - -XNewDoc D -box b 10 10 10 -XAddShape D b 1 -XAddLayer D invis -XSetLayer D b invis -XSetVisibility D invis 0 - -set status [ catch { WriteStep D $imagedir/${test_image}.stp } ] - -if { $status == 0 } { - puts "OK ${BugNumber}" -} else { - puts "Faulty ${BugNumber}" -} - diff --git a/tests/bugs/xde/bug1669 b/tests/bugs/xde/bug1669 deleted file mode 100755 index 444d68cf16..0000000000 --- a/tests/bugs/xde/bug1669 +++ /dev/null @@ -1,107 +0,0 @@ -puts "================" -puts "OCC1669" -puts "================" -puts "" -################################################################# -# Wrong name mapping of the instances of assembly into STEP file. -################################################################# - -set BugNumber OCC1669 - -catch {pload OCAF} - -XNewDoc SA - -box b1 10 10 10 -box b2 20 10 10 -ttranslate b1 10 0 0 -ttranslate b2 20 0 0 -compound b1 b2 bl -copy bl nbl -ttranslate nbl 30 0 0 -compound bl nbl ryad -copy ryad hryad -ttranslate hryad -10 0 10 -copy ryad uryad -ttranslate uryad 0 0 20 -compound ryad hryad uryad stena - -XAddShape SA stena 1 - -SetName SA 0:1:1:1 Wall -SetName SA 0:1:1:2 Block-Array -SetName SA 0:1:1:3 Block -SetName SA 0:1:1:4 Half-Brick -SetName SA 0:1:1:5 Brick - -SetName SA 0:1:1:1:1 base-array -SetName SA 0:1:1:1:2 next-array -SetName SA 0:1:1:1:3 top-array - -SetName SA 0:1:1:2:1 left-block -SetName SA 0:1:1:2:2 right-block - -SetName SA 0:1:1:3:1 half-brick -SetName SA 0:1:1:3:2 brick - -catch { WriteStep SA $imagedir/${test_image}.stp } -catch { ReadStep D $imagedir/${test_image}.stp } - -puts "Info: Now compare two documents SA and D" -#DFBrowse SA -#DFBrowse D - -set NamesList1 {Wall Block-Array Block Half-Brick Brick} -set NamesList2 {base-array next-array top-array} -set NamesList3 {left-block right-block} -set NamesList4 {half-brick brick} - -set status 0 - -for {set i 1} {$i <= 5} {incr i} { - set name [ GetName D 0:1:1:$i ] - set ref_name [lindex $NamesList1 $i-1] - if { $name != $ref_name } { - set status 1 - break - } -} - -if { $status != 1 } { - for {set i 1} {$i <= 3} {incr i} { - set name [ GetName D 0:1:1:1:$i ] - set ref_name [lindex $NamesList2 $i-1] - if { $name != $ref_name } { - set status 1 - break - } - } -} - -if { $status != 1 } { - for {set i 1} {$i <= 2} {incr i} { - set name [ GetName D 0:1:1:2:$i ] - set ref_name [lindex $NamesList3 $i-1] - if { $name != $ref_name } { - set status 1 - break - } - } -} - -if { $status != 1 } { - for {set i 1} {$i <= 2} {incr i} { - set name [ GetName D 0:1:1:3:$i ] - set ref_name [lindex $NamesList4 $i-1] - if { $name != $ref_name } { - set status 1 - break - } - } -} - -if { $status != 0 } { - puts "Faulty ${BugNumber}" -} else { - puts "OK ${BugNumber}" -} diff --git a/tests/bugs/xde/bug22728 b/tests/bugs/xde/bug22728 deleted file mode 100755 index e37904bb75..0000000000 --- a/tests/bugs/xde/bug22728 +++ /dev/null @@ -1,22 +0,0 @@ -puts "================" -puts "OCC22728" -puts "================" -puts "" -####################################################################################### -# STEP export API does not provide possibility to control output stream -###################################################################################### - -set BugNumber OCC22728 - -box b 10 10 10 - -cd ${imagedir} - -set text [stepwrite a b test.step] - -if { [regexp "File test.step written" $text] != 1 } { - puts "Faulty ${BugNumber}" -} else { - puts "OK ${BugNumber}" -} - diff --git a/tests/bugs/xde/bug25357 b/tests/bugs/xde/bug25357 deleted file mode 100644 index 8f1348b5b6..0000000000 --- a/tests/bugs/xde/bug25357 +++ /dev/null @@ -1,28 +0,0 @@ -puts "==========" -puts "OCC25357" -puts "==========" -puts "" -####################################################################################### -# STL writer does not check the given shape for existing triangulation and remeshes -# shape using BRepMesh in force mode -####################################################################################### - -set aFile ${imagedir}/${test_image}.stl -file delete -force ${aFile} - -set anASCIImode 0 - -ptorus res 10 8 -incmesh res 0.5 - -set LogBefore [trinfo res] - -writestl res ${aFile} ${anASCIImode} - -checktrinfo res -ref "${LogBefore}" - -if { ![file exists ${aFile}] || [ file size ${aFile} ] == 0 } { - puts "Error: STL writer does not check given shape" -} else { - puts "OK: STL writer check given shape" -} diff --git a/tests/bugs/xde/bug25910 b/tests/bugs/xde/bug25910 deleted file mode 100644 index 2e03c9478a..0000000000 --- a/tests/bugs/xde/bug25910 +++ /dev/null @@ -1,16 +0,0 @@ -puts "========" -puts "OCC25910: The material with 0-density causes e r r o r s during writing STEP files" -puts "========" -puts "" - -pload OCAF - -NewDocument D -box b 10 10 10 -XSetMaterial D [XAddShape D b] Vacuum 0. - -set aTmpFile ${imagedir}/${casename}_tmp.stp -set bug_info [catch {WriteStep D $aTmpFile}] -file delete -force $aTmpFile - -if {$bug_info != 0} { puts "ERROR: OCC25910 is reproduced." } diff --git a/tests/bugs/xde/bug27722 b/tests/bugs/xde/bug27722 deleted file mode 100644 index f586f3f3c4..0000000000 --- a/tests/bugs/xde/bug27722 +++ /dev/null @@ -1,47 +0,0 @@ -puts "TODO OCC27722 ALL: Faulty shapes in variables faulty_1 to faulty_" -puts "TODO OCC27722 ALL: Error : is WRONG because number of " - -puts "========" -puts "OCC27722" -puts "========" -puts "" -###################################### -# STEP error for Ellipse revol shape -###################################### - -catch {exec rm ${imagedir}/bug27722.stp} - -ellipse ge 0 0 20 10 -mkedge te ge 0 pi/2.0 -revol re te 0 0 0 0 1 0 360 - -set i_Vertex 0 -set i_Edge 0 -set i_Wire 0 -set i_Face 0 -set i_Shell 0 -set i_Solid 0 -set i_CSolid 0 -set i_Compound 0 -set i_Shape 0 -set bug_info [string trim [checkshape re]] -if {$bug_info == "This shape seems to be valid"} { - set nb_info [string trim [nbshapes re]] - set i_Vertex [string trim [lindex $nb_info 7]] - set i_Edge [string trim [lindex $nb_info 10]] - set i_Wire [string trim [lindex $nb_info 13]] - set i_Face [string trim [lindex $nb_info 16]] - set i_Shell [string trim [lindex $nb_info 19]] - set i_Solid [string trim [lindex $nb_info 22]] - set i_CSolid [string trim [lindex $nb_info 25]] - set i_Compound [string trim [lindex $nb_info 28]] - set i_Shape [string trim [lindex $nb_info 31]] -} else { - puts "ERROR: Problem of test case functionality. Should be additionally investigated." -} - -stepwrite a re ${imagedir}/bug27722.stp - -stepread ${imagedir}/bug27722.stp sr * -checkshape sr_1 -checknbshapes sr_1 -vertex ${i_Vertex} -edge ${i_Edge} -wire ${i_Wire} -face ${i_Face} -shell ${i_Shell} -solid ${i_Solid} -compsolid ${i_CSolid} -compound ${i_Compound} -shape ${i_Shape} diff --git a/tests/bugs/xde/bug29338 b/tests/bugs/xde/bug29338 deleted file mode 100644 index 64f826e77b..0000000000 --- a/tests/bugs/xde/bug29338 +++ /dev/null @@ -1,45 +0,0 @@ -puts "==========" -puts "OCC29338: Add Planes for Tolerance zones in Geometric tolerances" -puts "==========" -puts "" - -pload ALL - -box b 1 1 1 -XNewDoc D -XAddShape D b -explode b f -XAddGeomTolerance D b_1 -plane p 1 2 3 0 1 0 -XSetGDTAffectedPlane D 0:1:4:1 p 2 -set aTmpFile ${imagedir}/${casename}.xbf -SaveAs D $aTmpFile -Close D -XOpen $aTmpFile DD -set type [XGetGDTAffectedPlane DD 0:1:4:1 plane] -if {[lindex $type 0] != "orientation"} { - puts "Error: wrong affected plane type" -} - -set res [dump plane] -set check [split $res {:, }] -if {[lindex $check 8] != 1} { - puts "Error: wrong affected plane" -} -if {[lindex $check 10] != 2} { - puts "Error: wrong affected plane" -} -if {[lindex $check 12] != 3} { - puts "Error: wrong affected plane" -} -if {[lindex $check 19] != 0} { - puts "Error: wrong affected plane" -} -if {[lindex $check 21] != 1} { - puts "Error: wrong affected plane" -} -if {[lindex $check 23] != 0} { - puts "Error: wrong affected plane" -} -Close DD -file delete -force $aTmpFile diff --git a/tests/bugs/xde/bug30409 b/tests/bugs/xde/bug30409 deleted file mode 100644 index b37120f095..0000000000 --- a/tests/bugs/xde/bug30409 +++ /dev/null @@ -1,14 +0,0 @@ -puts "================" -puts "0030409: Data Exchange - e x c e p t i o n during VRML file export" -puts "================" -puts "" - -pload XDE MODELING VISUALIZATION -box b 1 2 3 -incmesh b 1 -explode b F -XNewDoc D -XAddShape D b_1 0 -WriteVrml D $imagedir/${casename}.wrl -loadvrml w $imagedir/${casename}.wrl -checktrinfo w -tri 2 -nod 4 diff --git a/tests/bugs/xde/bug31382 b/tests/bugs/xde/bug31382 deleted file mode 100644 index ef9759e41b..0000000000 --- a/tests/bugs/xde/bug31382 +++ /dev/null @@ -1,81 +0,0 @@ -puts "# ==============================================================================" -puts "# 0031382: Data Exchange - BinXCAF should preserve length unit information" -puts "# ==============================================================================" - -pload OCAF - -box b 10 20 30 - -catch { Close D } -catch { Close D1 } -# check saving value of length unit -NewDocument D XmlXCAF -XAddShape D b 0 -XSetLengthUnit D in -XSave D ${imagedir}/${casename}.xml -XOpen ${imagedir}//${casename}.xml D1 -set LU [XGetLengthUnit D1] -if {$LU != "in"} { - puts "Error: Length unit is not coincided with given1" -} -Close D -Close D1 -NewDocument D BinXCAF -XAddShape D b 0 -XSetLengthUnit D m -XSave D ${imagedir}/${casename}.xbf -XOpen ${imagedir}//${casename}.xbf D1 -set LU [XGetLengthUnit D1] -if {$LU != "m"} { - puts "Error: Length unit is not coincided with given2" -} -Close D -Close D1 - -# if length unit is undefined in the document value from session -# must be set to document before saving it to xml -NewDocument D XmlXCAF -param xstep.cascade.unit 5 -XAddShape D b 0 -XSave D ${imagedir}/${casename}.xml -set LU [XGetLengthUnit D] -if {$LU == "mm"} { - puts "Error: Length unit is not coincided with given3" -} -XOpen ${imagedir}//${casename}.xml D1 -set LU [XGetLengthUnit D1] -if {$LU == "stat.mile"} { - puts "Length unit is coincided with given" -} else { - puts "Error: Length unit is not coincided with given4" -} -Close D -Close D1 - -# if length unit is undefined in the document value from session -# must be set to document before saving it to xbf -NewDocument D BinXCAF -param xstep.cascade.unit 7 -XAddShape D b 0 -XSave D ${imagedir}/${casename}.xbf -set LU [XGetLengthUnit D] -if {$LU == "km"} { - puts "Length unit is coincided with given" -} else { - puts "Error: Length unit is not coincided with given" -} -XOpen ${imagedir}//${casename}.xbf D1 -set LU [XGetLengthUnit D1] -if {$LU == "km"} { - puts "Length unit is coincided with given" -} else { - puts "Error: Length unit is not coincided with given" -} - -# return to default global unit -param xstep.cascade.unit 2 -file delete ${imagedir}//${casename}.xbf -file delete ${imagedir}//${casename}.xml - -Close D -Close D1 diff --git a/tests/bugs/xde/bug31851 b/tests/bugs/xde/bug31851 deleted file mode 100644 index 2c2bd582df..0000000000 --- a/tests/bugs/xde/bug31851 +++ /dev/null @@ -1,19 +0,0 @@ -puts "# ==============================================================================" -puts "# 0031851: Data Exchange, STEP - enable Unicode symbols in STEP export" -puts "# ==============================================================================" - -pload OCAF XDE MODELING - -puts "# Generate XDE document with a solid having name encoded in Japanese" -set name "\u30DC\u30C3\u30AF\u30B9" ;# "box" -box box 10 10 10 -NewDocument D XCAF -SetName D [XAddShape D box] $name - -WriteStep D $imagedir/${casename}.stp -ReadStep T $imagedir/${casename}.stp - -set result [GetName T 0:1:1:1] -if { $result != $name } { - puts "Error: name has been lost on conversion" -} diff --git a/tests/bugs/xde/bug533 b/tests/bugs/xde/bug533 deleted file mode 100755 index 443118d6c4..0000000000 --- a/tests/bugs/xde/bug533 +++ /dev/null @@ -1,16 +0,0 @@ -puts "=========" -puts "OCC533: XmlOcaf-Document is not stored in XDEDRAWEXE although stored in TCAF" -puts "=========" -puts "" - -set aTmpFile ${imagedir}/${casename}.xml - -set res 0 -catch { NewDocument A XmlOcaf } -if [catch {SaveAs A $aTmpFile}] { - puts "OCC533 FAULTY" -} else { - puts "OCC533 OK" -} - -file delete -force $aTmpFile diff --git a/tests/bugs/xde/bug7141 b/tests/bugs/xde/bug7141 deleted file mode 100755 index 4f42eb7b92..0000000000 --- a/tests/bugs/xde/bug7141 +++ /dev/null @@ -1,21 +0,0 @@ -puts "============" -puts "OCC7141" -puts "============" -puts "" -###################################################### -# STEP interface crashes exporting large assembly -###################################################### - -pload QAcommands - -set BugNumber OCC7141 -set aFile ${imagedir}/TestExportStructure.step -file delete -force ${aFile} - -set nCount 20 -if [catch { set List [OCC7141 ${nCount} ${aFile}] } result] { - puts "${BugNumber}: Faulty" -} else { - puts "${BugNumber}: OK" -} - diff --git a/tests/caf/basic/A1 b/tests/caf/basic/A1 deleted file mode 100755 index 4899cfe0fa..0000000000 --- a/tests/caf/basic/A1 +++ /dev/null @@ -1,38 +0,0 @@ -#INTERFACE CAF -# Basic attributes -# -# Testing attribute: TDataStd_Integer -# -# Testing command: SetInteger -# Testing command: GetInteger -# - -puts "caf001-A1" - -# Add an attribute to a data framework -set aSetAttr1 100 -set aLabel 0:2 -SetInteger D ${aLabel} ${aSetAttr1} - -# Close/Open the transaction -NewCommand D - -# Forget the attribute -ForgetAll D ${aLabel} - -# Close/Open the transaction -NewCommand D - -# Undo-Redo-Undo -Undo D -Redo D -Undo D - -# Get a value of the attribute -set aGetAttr1 [GetInteger D ${aLabel}] -if { ${aSetAttr1}!=${aGetAttr1} } { - puts "aSetAttr1=${aSetAttr1} aGetAttr1=${aGetAttr1}" - puts "Add TDataStd_Integer attribute: Error" - return -} -puts "Add TDataStd_Integer attribute: OK" diff --git a/tests/caf/basic/A2 b/tests/caf/basic/A2 deleted file mode 100755 index 73f21dd8b0..0000000000 --- a/tests/caf/basic/A2 +++ /dev/null @@ -1,37 +0,0 @@ -#INTERFACE CAF -# Basic attributes -# -# Testing attribute: TDataStd_Integer -# -# Testing command: SetInteger -# Testing command: GetInteger -# - -puts "caf001-A2" - -# Add an attribute to a data framework -set aSetAttr1 100 -set aLabel 0:2 -SetInteger D ${aLabel} ${aSetAttr1} - -# Close/Open the transaction -NewCommand D - -# Set a new value of the attribute -set aSetAttr2 200 -SetInteger D ${aLabel} ${aSetAttr2} - -# Close/Open the transaction -NewCommand D - -# Undo -Undo D - -# Get a value of the attribute -set aGetAttr2 [GetInteger D ${aLabel}] -if { ${aSetAttr1}!=${aGetAttr2} } { - puts "aSetAttr1=${aSetAttr1} aGetAttr2=${aGetAttr2}" - puts "Set a value of TDataStd_Integer attribute: Error" - return -} -puts "Set a value of TDataStd_Integer attribute: OK" diff --git a/tests/caf/basic/A3 b/tests/caf/basic/A3 deleted file mode 100755 index 737c0cb91f..0000000000 --- a/tests/caf/basic/A3 +++ /dev/null @@ -1,43 +0,0 @@ -#INTERFACE CAF -# Basic attributes -# -# Testing attribute: TDataStd_Integer -# -# Testing command: SetInteger -# Testing command: GetInteger -# - -puts "caf001-A3" - -# Add an attribute to a data framework -set aSetAttr1 100 -set aLabel 0:2 -SetInteger D ${aLabel} ${aSetAttr1} - -# Close/Open the transaction -NewCommand D - -# Save the document -set aFile ${imagedir}/caf001-A3.cbf -file delete ${aFile} -SaveAs D ${aFile} -if { ![file exists ${aFile}] } { - puts "There is not ${aFile} file; SaveAs command: Error" - return -} -#catch {exec chmod 777 ${aFile}} - -# Restore the document -Close D -Open ${aFile} DD - -# Get a value of the attribute -set IsDone [catch {set aGetAttr3 [GetInteger DD ${aLabel}]} aResult] -if { ${IsDone} != 0 || - ${aSetAttr1}!=${aGetAttr3} } { - puts ${aResult} - puts "aSetAttr1=${aSetAttr1} aGetAttr3=${aGetAttr3}" - puts "Get a value of TDataStd_Integer attribute from restoring document: Error" - return -} -puts "Get a value of TDataStd_Integer attribute from restoring document: OK" diff --git a/tests/caf/basic/A4 b/tests/caf/basic/A4 deleted file mode 100644 index 2179573e00..0000000000 --- a/tests/caf/basic/A4 +++ /dev/null @@ -1,50 +0,0 @@ -#INTERFACE CAF -# Basic attributes -# -# Testing attribute: User defined (additional GUID) TDataStd_Integer -# -# Testing command: SetInteger -# Testing command: GetInteger -# - -puts "caf001-A4" - -# Add an attribute to a data framework -set aSetAttr1 100 -set aSetAttr2 200 -set aGuid1 "12e94541-6dbc-11d4-b9c8-0060b0ee281b" -set aGuid2 "12e94542-6dbc-11d4-b9c8-0060b0ee281b" -set aLabel 0:2 -SetInteger D ${aLabel} ${aSetAttr1} ${aGuid1} -SetInteger D ${aLabel} ${aSetAttr2} ${aGuid2} - -# Close/Open the transaction -NewCommand D - -# Forget the attribute -ForgetAll D ${aLabel} - -# Close/Open the transaction -NewCommand D - -# Undo-Redo-Undo -Undo D -Redo D -Undo D - -# Get a value of the attribute -set aGetAttr1 [GetInteger D ${aLabel} ${aGuid1}] -if { ${aSetAttr1}!=${aGetAttr1} } { - puts "aSetAttr1=${aSetAttr1} aGetAttr1=${aGetAttr1}" - puts "Add TDataStd_Integer attribute: Error" - return -} - -set aGetAttr2 [GetInteger D ${aLabel} ${aGuid2}] -if { ${aSetAttr2}!=${aGetAttr2} } { - puts "aSetAttr2=${aSetAttr2} aGetAttr2=${aGetAttr2}" - puts "Add TDataStd_Integer attribute: Error" - return -} - -puts "Add user defined TDataStd_Integer attributes: OK" diff --git a/tests/caf/basic/A5 b/tests/caf/basic/A5 deleted file mode 100644 index 4a7738d106..0000000000 --- a/tests/caf/basic/A5 +++ /dev/null @@ -1,52 +0,0 @@ -#INTERFACE CAF -# Basic attributes -# -# Testing attribute: User defined (additional GUID) TDataStd_Integer -# -# Testing command: SetInteger -# Testing command: GetInteger -# - -puts "caf001-A5" - -# Add an attribute to a data framework -set aSetAttr1 100 -set aSetAttr2 200 -set aGuid1 "12e94541-6dbc-11d4-b9c8-0060b0ee281b" -set aGuid2 "12e94542-6dbc-11d4-b9c8-0060b0ee281b" -set aLabel 0:2 -SetInteger D ${aLabel} ${aSetAttr1} ${aGuid1} -SetInteger D ${aLabel} ${aSetAttr2} ${aGuid2} - -# Close/Open the transaction -NewCommand D - -# Set a new value of the attributes -set aSetAttr12 199 -SetInteger D ${aLabel} ${aSetAttr12} ${aGuid1} - -set aSetAttr22 299 -SetInteger D ${aLabel} ${aSetAttr12} ${aGuid2} - -# Close/Open the transaction -NewCommand D - -# Undo-Redo-Undo -Undo D - -# Get a value of the attribute -set aGetAttr1 [GetInteger D ${aLabel} ${aGuid1}] -if { ${aSetAttr1}!=${aGetAttr1} } { - puts "aSetAttr1=${aSetAttr1} aGetAttr1=${aGetAttr1}" - puts "Add TDataStd_Integer attribute: Error" - return -} - -set aGetAttr2 [GetInteger D ${aLabel} ${aGuid2}] -if { ${aSetAttr2}!=${aGetAttr2} } { - puts "aSetAttr2=${aSetAttr2} aGetAttr2=${aGetAttr2}" - puts "Add TDataStd_Integer attribute: Error" - return -} - -puts "Add user defined TDataStd_Integer attributes: OK" diff --git a/tests/caf/basic/A6 b/tests/caf/basic/A6 deleted file mode 100644 index 21288770d6..0000000000 --- a/tests/caf/basic/A6 +++ /dev/null @@ -1,58 +0,0 @@ -#INTERFACE CAF -# Basic attributes -# -# Testing attribute: User defined (additional GUID) TDataStd_Integer -# -# Testing command: SetInteger -# Testing command: GetInteger -# - -puts "caf001-A6" - -# Add an attribute to a data framework -set aSetAttr1 100 -set aSetAttr2 200 -set aGuid1 "12e94541-6dbc-11d4-b9c8-0060b0ee281b" -set aGuid2 "12e94542-6dbc-11d4-b9c8-0060b0ee281b" -set aLabel 0:2 -SetInteger D ${aLabel} ${aSetAttr1} ${aGuid1} -SetInteger D ${aLabel} ${aSetAttr2} ${aGuid2} - -# Close/Open the transaction -NewCommand D - -# Save the document -set aFile ${imagedir}/caf001-A6.cbf -file delete ${aFile} -SaveAs D ${aFile} -if { ![file exists ${aFile}] } { - puts "There is not ${aFile} file; SaveAs command: Error" - return -} -#catch {exec chmod 777 ${aFile}} - -# Restore the document -Close D -Open ${aFile} DD - -# Get a value of the attribute #1 -set IsDone [catch {set aGetAttr3 [GetInteger DD ${aLabel} ${aGuid1}]} aResult] -if { ${IsDone} != 0 || - ${aSetAttr1}!=${aGetAttr3} } { - puts ${aResult} - puts "aSetAttr1=${aSetAttr1} aGetAttr3=${aGetAttr3}" - puts "Get a value of the first TDataStd_Integer attribute from restoring document: Error" - return -} - -# Get a value of the attribute #2 -set IsDone [catch {set aGetAttr4 [GetInteger DD ${aLabel} ${aGuid2}]} aResult] -if { ${IsDone} != 0 || - ${aSetAttr2}!=${aGetAttr4} } { - puts ${aResult} - puts "aSetAttr2=${aSetAttr2} aGetAttr4=${aGetAttr4}" - puts "Get a value of the second TDataStd_Integer attribute from restoring document: Error" - return -} - -puts "Get a value of user defined TDataStd_Integer attributes from restoring document: OK" diff --git a/tests/caf/basic/A7 b/tests/caf/basic/A7 deleted file mode 100644 index e822254b37..0000000000 --- a/tests/caf/basic/A7 +++ /dev/null @@ -1,58 +0,0 @@ -#INTERFACE CAF -# Basic attributes -# -# Testing attribute: User defined (additional GUID) TDataStd_Integer -# -# Testing command: SetInteger -# Testing command: GetInteger -# - -puts "caf001-A6" - -# Add an attribute to a data framework -set aSetAttr1 100 -set aSetAttr2 200 -set aGuid1 "12e94541-6dbc-11d4-b9c8-0060b0ee281b" - -set aLabel 0:2 -SetInteger D ${aLabel} ${aSetAttr1} -SetInteger D ${aLabel} ${aSetAttr2} ${aGuid1} - -# Close/Open the transaction -NewCommand D - -# Save the document -set aFile ${imagedir}/caf001-A7.cbf -file delete ${aFile} -SaveAs D ${aFile} -if { ![file exists ${aFile}] } { - puts "There is not ${aFile} file; SaveAs command: Error" - return -} -#catch {exec chmod 777 ${aFile}} - -# Restore the document -Close D -Open ${aFile} DD - -# Get a value of the attribute #1 -set IsDone [catch {set aGetAttr3 [GetInteger DD ${aLabel}]} aResult] -if { ${IsDone} != 0 || - ${aSetAttr1}!=${aGetAttr3} } { - puts ${aResult} - puts "aSetAttr1=${aSetAttr1} aGetAttr3=${aGetAttr3}" - puts "Get a value of the first TDataStd_Integer attribute from restoring document: Error" - return -} - -# Get a value of the attribute #2 -set IsDone [catch {set aGetAttr4 [GetInteger DD ${aLabel} ${aGuid1}]} aResult] -if { ${IsDone} != 0 || - ${aSetAttr2}!=${aGetAttr4} } { - puts ${aResult} - puts "aSetAttr2=${aSetAttr2} aGetAttr4=${aGetAttr4}" - puts "Get a value of the second TDataStd_Integer attribute from restoring document: Error" - return -} - -puts "Get a value of user defined TDataStd_Integer attributes from restoring document: OK" diff --git a/tests/caf/basic/B1 b/tests/caf/basic/B1 deleted file mode 100755 index 51d0dd2f84..0000000000 --- a/tests/caf/basic/B1 +++ /dev/null @@ -1,38 +0,0 @@ -#INTERFACE CAF -# Basic attributes -# -# Testing attribute: TDataStd_Real -# -# Testing command: SetReal -# Testing command: GetReal -# - -puts "caf001-B1" - -# Add an attribute to a data framework -set aSetAttr1 100.0 -set aLabel 0:2 -SetReal D ${aLabel} ${aSetAttr1} - -# Close/Open the transaction -NewCommand D - -# Forget the attribute -ForgetAll D ${aLabel} - -# Close/Open the transaction -NewCommand D - -# Undo-Redo-Undo -Undo D -Redo D -Undo D - -# Get a value of the attribute -set aGetAttr1 [GetReal D ${aLabel}] -if { ${aSetAttr1}!=${aGetAttr1} } { - puts "aSetAttr1=${aSetAttr1} aGetAttr1=${aGetAttr1}" - puts "Add TDataStd_Real attribute: Error" - return -} -puts "Add TDataStd_Real attribute: OK" diff --git a/tests/caf/basic/B2 b/tests/caf/basic/B2 deleted file mode 100755 index 1896f30ce0..0000000000 --- a/tests/caf/basic/B2 +++ /dev/null @@ -1,37 +0,0 @@ -#INTERFACE CAF -# Basic attributes -# -# Testing attribute: TDataStd_Real -# -# Testing command: SetReal -# Testing command: GetReal -# - -puts "caf001-B2" - -# Add an attribute to a data framework -set aSetAttr1 100.0 -set aLabel 0:2 -SetReal D ${aLabel} ${aSetAttr1} - -# Close/Open the transaction -NewCommand D - -# Set a new value of the attribute -set aSetAttr2 200.0 -SetReal D ${aLabel} ${aSetAttr2} - -# Close/Open the transaction -NewCommand D - -# Undo -Undo D - -# Get a value of the attribute -set aGetAttr2 [GetReal D ${aLabel}] -if { ${aSetAttr1}!=${aGetAttr2} } { - puts "aSetAttr1=${aSetAttr1} aGetAttr2=${aGetAttr2}" - puts "Set a value of TDataStd_Real attribute: Error" - return -} -puts "Set a value of TDataStd_Real attribute: OK" diff --git a/tests/caf/basic/B3 b/tests/caf/basic/B3 deleted file mode 100755 index 35421dfa0e..0000000000 --- a/tests/caf/basic/B3 +++ /dev/null @@ -1,43 +0,0 @@ -#INTERFACE CAF -# Basic attributes -# -# Testing attribute: TDataStd_Real -# -# Testing command: SetReal -# Testing command: GetReal -# - -puts "caf001-B3" - -# Add an attribute to a data framework -set aSetAttr1 100.0 -set aLabel 0:2 -SetReal D ${aLabel} ${aSetAttr1} - -# Close/Open the transaction -NewCommand D - -# Save the document -set aFile ${imagedir}/caf001-B3.cbf -file delete ${aFile} -SaveAs D ${aFile} -if { ![file exists ${aFile}] } { - puts "There is not ${aFile} file; SaveAs command: Error" - return -} -#catch {exec chmod 777 ${aFile}} - -# Restore the document -Close D -Open ${aFile} DD - -# Get a value of the attribute -set IsDone [catch {set aGetAttr3 [GetReal DD ${aLabel}]} aResult] -if { ${IsDone} != 0 || - ${aSetAttr1}!=${aGetAttr3} } { - puts ${aResult} - puts "aSetAttr1=${aSetAttr1} aGetAttr3=${aGetAttr3}" - puts "Get a value of TDataStd_Real attribute from restoring document: Error" - return -} -puts "Get a value of TDataStd_Real attribute from restoring document: OK" diff --git a/tests/caf/basic/B4 b/tests/caf/basic/B4 deleted file mode 100644 index 5f003654a8..0000000000 --- a/tests/caf/basic/B4 +++ /dev/null @@ -1,50 +0,0 @@ -#INTERFACE CAF -# Basic attributes -# -# Testing attribute: User defined (additional GUID) TDataStd_Real -# -# Testing command: SetReal -# Testing command: GetReal -# - -puts "caf001-B4" - -# Add an attribute to a data framework -set aSetAttr1 100.11 -set aSetAttr2 200.11 -set aGuid1 "12e94551-6dbc-11d4-b9c8-0060b0ee281b" -set aGuid2 "12e94552-6dbc-11d4-b9c8-0060b0ee281b" -set aLabel 0:2 -SetReal D ${aLabel} ${aSetAttr1} ${aGuid1} -SetReal D ${aLabel} ${aSetAttr2} ${aGuid2} - -# Close/Open the transaction -NewCommand D - -# Forget the attribute -ForgetAll D ${aLabel} - -# Close/Open the transaction -NewCommand D - -# Undo-Redo-Undo -Undo D -Redo D -Undo D - -# Get a value of the attribute -set aGetAttr1 [GetReal D ${aLabel} ${aGuid1}] -if { ${aSetAttr1}!=${aGetAttr1} } { - puts "aSetAttr1=${aSetAttr1} aGetAttr1=${aGetAttr1}" - puts "Add TDataStd_Real attribute: Error" - return -} - -set aGetAttr2 [GetReal D ${aLabel} ${aGuid2}] -if { ${aSetAttr2}!=${aGetAttr2} } { - puts "aSetAttr2=${aSetAttr2} aGetAttr2=${aGetAttr2}" - puts "Add TDataStd_Real attribute: Error" - return -} - -puts "Add user defined TDataStd_Real attributes: OK" diff --git a/tests/caf/basic/B5 b/tests/caf/basic/B5 deleted file mode 100755 index 934132e52a..0000000000 --- a/tests/caf/basic/B5 +++ /dev/null @@ -1,52 +0,0 @@ -#INTERFACE CAF -# Basic attributes -# -# Testing attribute: User defined (additional GUID) TDataStd_Real -# -# Testing command: SetReal -# Testing command: GetReal -# - -puts "caf001-B5" - -# Add an attribute to a data framework -set aSetAttr1 100.11 -set aSetAttr2 200.11 -set aGuid1 "12e94551-6dbc-11d4-b9c8-0060b0ee281b" -set aGuid2 "12e94552-6dbc-11d4-b9c8-0060b0ee281b" -set aLabel 0:2 -SetReal D ${aLabel} ${aSetAttr1} ${aGuid1} -SetReal D ${aLabel} ${aSetAttr2} ${aGuid2} - -# Close/Open the transaction -NewCommand D - -# Set a new value of the attributes -set aSetAttr12 199.11 -SetReal D ${aLabel} ${aSetAttr12} ${aGuid1} - -set aSetAttr22 299.11 -SetReal D ${aLabel} ${aSetAttr12} ${aGuid2} - -# Close/Open the transaction -NewCommand D - -# Undo-Redo-Undo -Undo D - -# Get a value of the attribute -set aGetAttr1 [GetReal D ${aLabel} ${aGuid1}] -if { ${aSetAttr1}!=${aGetAttr1} } { - puts "aSetAttr1=${aSetAttr1} aGetAttr1=${aGetAttr1}" - puts "Add user defined TDataStd_Real attribute: Error" - return -} - -set aGetAttr2 [GetReal D ${aLabel} ${aGuid2}] -if { ${aSetAttr2}!=${aGetAttr2} } { - puts "aSetAttr2=${aSetAttr2} aGetAttr2=${aGetAttr2}" - puts "Add user defined TDataStd_Real attribute: Error" - return -} - -puts "Add user defined TDataStd_Real attributes: OK" diff --git a/tests/caf/basic/B6 b/tests/caf/basic/B6 deleted file mode 100644 index e85536deeb..0000000000 --- a/tests/caf/basic/B6 +++ /dev/null @@ -1,58 +0,0 @@ -#INTERFACE CAF -# Basic attributes -# -# Testing attribute: User defined (additional GUID) TDataStd_Real -# -# Testing command: SetReal -# Testing command: GetReal -# - -puts "caf001-B6" - -# Add an attribute to a data framework -set aSetAttr1 100.11 -set aSetAttr2 200.11 -set aGuid1 "12e94551-6dbc-11d4-b9c8-0060b0ee281b" -set aGuid2 "12e94552-6dbc-11d4-b9c8-0060b0ee281b" -set aLabel 0:2 -SetReal D ${aLabel} ${aSetAttr1} ${aGuid1} -SetReal D ${aLabel} ${aSetAttr2} ${aGuid2} - -# Close/Open the transaction -NewCommand D - -# Save the document -set aFile ${imagedir}/caf001-B6.cbf -file delete ${aFile} -SaveAs D ${aFile} -if { ![file exists ${aFile}] } { - puts "There is not ${aFile} file; SaveAs command: Error" - return -} -#catch {exec chmod 777 ${aFile}} - -# Restore the document -Close D -Open ${aFile} DD - -# Get a value of the attribute #1 -set IsDone [catch {set aGetAttr3 [GetReal DD ${aLabel} ${aGuid1}]} aResult] -if { ${IsDone} != 0 || - ${aSetAttr1}!=${aGetAttr3} } { - puts ${aResult} - puts "aSetAttr1=${aSetAttr1} aGetAttr3=${aGetAttr3}" - puts "Get a value of the first TDataStd_Real attribute from restoring document: Error" - return -} - -# Get a value of the attribute #2 -set IsDone [catch {set aGetAttr4 [GetReal DD ${aLabel} ${aGuid2}]} aResult] -if { ${IsDone} != 0 || - ${aSetAttr2}!=${aGetAttr4} } { - puts ${aResult} - puts "aSetAttr2=${aSetAttr2} aGetAttr4=${aGetAttr4}" - puts "Get a value of the second TDataStd_Real attribute from restoring document: Error" - return -} - -puts "Get a value of user defined TDataStd_Integer attributes from restoring document: OK" diff --git a/tests/caf/basic/B7 b/tests/caf/basic/B7 deleted file mode 100644 index 452c2bec21..0000000000 --- a/tests/caf/basic/B7 +++ /dev/null @@ -1,57 +0,0 @@ -#INTERFACE CAF -# Basic attributes -# -# Testing attribute: User defined (additional GUID) TDataStd_Real -# -# Testing command: SetReal -# Testing command: GetReal -# - -puts "caf001-B6" - -# Add an attribute to a data framework -set aSetAttr1 100.11 -set aSetAttr2 200.11 -set aGuid2 "12e94552-6dbc-11d4-b9c8-0060b0ee281b" -set aLabel 0:2 -SetReal D ${aLabel} ${aSetAttr1} -SetReal D ${aLabel} ${aSetAttr2} ${aGuid2} - -# Close/Open the transaction -NewCommand D - -# Save the document -set aFile ${imagedir}/caf001-B7.cbf -file delete ${aFile} -SaveAs D ${aFile} -if { ![file exists ${aFile}] } { - puts "There is not ${aFile} file; SaveAs command: Error" - return -} -#catch {exec chmod 777 ${aFile}} - -# Restore the document -Close D -Open ${aFile} DD - -# Get a value of the attribute #1 -set IsDone [catch {set aGetAttr3 [GetReal DD ${aLabel}]} aResult] -if { ${IsDone} != 0 || - ${aSetAttr1}!=${aGetAttr3} } { - puts ${aResult} - puts "aSetAttr1=${aSetAttr1} aGetAttr3=${aGetAttr3}" - puts "Get a value of the first TDataStd_Real attribute from restoring document: Error" - return -} - -# Get a value of the attribute #2 -set IsDone [catch {set aGetAttr4 [GetReal DD ${aLabel} ${aGuid2}]} aResult] -if { ${IsDone} != 0 || - ${aSetAttr2}!=${aGetAttr4} } { - puts ${aResult} - puts "aSetAttr2=${aSetAttr2} aGetAttr4=${aGetAttr4}" - puts "Get a value of the second TDataStd_Real attribute from restoring document: Error" - return -} - -puts "Get a value of user defined TDataStd_Integer attributes from restoring document: OK" diff --git a/tests/caf/basic/B8 b/tests/caf/basic/B8 deleted file mode 100644 index 8fecfd6b5f..0000000000 --- a/tests/caf/basic/B8 +++ /dev/null @@ -1,41 +0,0 @@ -#INTERFACE CAF -# Basic attributes -# -# Testing order of attributes on Undo/Redo -# -# Testing command: SetInteger -# Testing command: GetReal -# Testing command: Undo and Redo -# - -puts "caf001-B8" - -NewCommand D -SetInteger D 0:1 123 -SetReal D 0:1 123.321 -NewCommand D -CheckLabel D 0:1 - -set res1 [CheckLabel D 0:1] -set indexReal1 [lsearch ${res1} TDataStd_Real] -set indexInt1 [lsearch ${res1} TDataStd_Integer] -if { ${indexReal1} != 11} { - puts "Error: Wrong position 1 of TDataStd_Real attribute." -} -if { ${indexInt1} != 5} { - puts "Error: Wrong position 1 of TDataStd_Integer attribute." -} - -Undo D -Redo D -CheckLabel D 0:1 - -set res2 [CheckLabel D 0:1] -set indexReal2 [lsearch ${res2} TDataStd_Real] -set indexInt2 [lsearch ${res2} TDataStd_Integer] -if { ${indexReal1} != ${indexReal2}} { - puts "Error: Wrong position 2 of TDataStd_Real attribute." -} -if { ${indexInt1} != ${indexInt2}} { - puts "Error: Wrong position 2 of TDataStd_Integer attribute." -} diff --git a/tests/caf/basic/C1 b/tests/caf/basic/C1 deleted file mode 100755 index c65c3c2fa2..0000000000 --- a/tests/caf/basic/C1 +++ /dev/null @@ -1,67 +0,0 @@ -#INTERFACE CAF -# Basic attributes -# TDataStd_RealArray -# -# Testing attribute: TDataStd_RealArray -# -# Testing command: SetRealArray -# Testing command: GetRealArray -# - -puts "caf001-C1" -set QA_DUP 0 - -# Add an attribute to a data framework -set aFrom1 1 -set aTo1 2 -set aSetAttr11 3. -set aSetAttr12 4. -set aLabel 0:2 -set isDelta 0 -SetRealArray D ${aLabel} ${isDelta} ${aFrom1} ${aTo1} ${aSetAttr11} ${aSetAttr12} - -# Close/Open the transaction -NewCommand D - -# Forget the attribute -ForgetAll D ${aLabel} - -# Close/Open the transaction -NewCommand D - -# Undo-Redo-Undo -Undo D -Redo D -Undo D - -# Get a value of the attribute -set IsGood 1 -set aMessage1 "Add TDataStd_RealArray attribute: Error" -set aGetAttr1 [GetRealArray D ${aLabel}] -set aLen1 [llength ${aGetAttr1}] -if { ${aLen1} != [expr ${aTo1} - ${aFrom1} + 1] } { - set IsGood 0 - puts "aLen1=${aLen1}" - puts ${aMessage1} -### return -} -set aGetAttr21 [lindex ${aGetAttr1} 0] -if { ${aSetAttr11} != ${aGetAttr21} } { - set IsGood 0 - puts "aGetAttr21=${aGetAttr21}" - puts ${aMessage1} -### return -} -set aGetAttr22 [lindex ${aGetAttr1} 1] -if { ${aSetAttr12} != ${aGetAttr22} } { - set IsGood 0 - puts "aGetAttr22=${aGetAttr22}" - puts ${aMessage1} -### return -} - -if { ${IsGood} == 0} { - puts "Add TDataStd_RealArray attribute: Error" -} else { - puts "Add TDataStd_RealArray attribute: OK" -} diff --git a/tests/caf/basic/C2 b/tests/caf/basic/C2 deleted file mode 100755 index 31423f4ba2..0000000000 --- a/tests/caf/basic/C2 +++ /dev/null @@ -1,68 +0,0 @@ -#INTERFACE CAF -# Basic attributes -# -# Testing attribute: TDataStd_RealArray -# -# Testing command: SetRealArray -# Testing command: GetRealArray -# - -puts "caf001-C2" -set QA_DUP 0 - -# Add an attribute to a data framework -set aFrom1 1 -set aTo1 2 -set aSetAttr11 3. -set aSetAttr12 4. -set aLabel 0:2 -set isDelta 0 -SetRealArray D ${aLabel} ${isDelta} ${aFrom1} ${aTo1} ${aSetAttr11} ${aSetAttr12} - -# Close/Open the transaction -NewCommand D - -# Set a new value of the attribute -set aFrom2 1 -set aTo2 2 -set aSetAttr21 33. -set aSetAttr22 44. -SetRealArray D ${aLabel} ${isDelta} ${aFrom2} ${aTo2} ${aSetAttr21} ${aSetAttr22} - -# Close/Open the transaction -NewCommand D - -# Undo -Undo D - -# Get a value of the attribute -set IsGood 1 -set aMessage2 "Set a value of TDataStd_RealArray attribute: Error" -set aGetAttr2 [GetRealArray D ${aLabel}] -set aLen2 [llength ${aGetAttr2}] -if { ${aLen2} != [expr ${aTo1} - ${aFrom1} + 1] } { - set IsGood 0 - puts "aLen2=${aLen2}" - puts ${aMessage2} -### return -} -set aGetAttr31 [lindex ${aGetAttr2} 0] -if { ${aSetAttr11} != ${aGetAttr31} } { - set IsGood 0 - puts "aGetAttr31=${aGetAttr31}" - puts ${aMessage2} -### return -} -set aGetAttr32 [lindex ${aGetAttr2} 1] -if { ${aSetAttr12} != ${aGetAttr32} } { - set IsGood 0 - puts "aGetAttr32=${aGetAttr32}" - puts ${aMessage2} -### return -} - -if { ${IsGood} == 0} { - puts "Set a value of TDataStd_RealArray attribute: Error" -} else { - puts "Set a value of TDataStd_RealArray attribute: OK" -} diff --git a/tests/caf/basic/C3 b/tests/caf/basic/C3 deleted file mode 100755 index 781f6df0f3..0000000000 --- a/tests/caf/basic/C3 +++ /dev/null @@ -1,74 +0,0 @@ -#INTERFACE CAF -# Basic attributes -# -# Testing attribute: TDataStd_RealArray -# -# Testing command: SetRealArray -# Testing command: GetRealArray -# - -puts "caf001-C3" -set QA_DUP 0 - -# Add an attribute to a data framework -set aFrom1 1 -set aTo1 2 -set aSetAttr11 3. -set aSetAttr12 4. -set aLabel 0:2 -set isDelta 0 -SetRealArray D ${aLabel} ${isDelta} ${aFrom1} ${aTo1} ${aSetAttr11} ${aSetAttr12} - -# Close/Open the transaction -NewCommand D - -# Save the document -set aFile ${imagedir}/caf001-C3.cbf -file delete ${aFile} -SaveAs D ${aFile} -if { ![file exists ${aFile}] } { - puts "There is not ${aFile} file; SaveAs command: Error" - return -} -#catch {exec chmod 777 ${aFile}} - -# Restore the document -Close D -Open ${aFile} DD - -# Get a value of the attribute -set IsGood 1 -set aMessage3 "Get a value of TDataStd_RealArray attribute from restoring document: Error" -set IsDone [catch {set aGetAttr3 [GetRealArray DD ${aLabel}]} aResult] -if { ${IsDone} != 0 } { - set IsGood 0 - puts ${aMessage3} -### return -} -set aLen3 [llength ${aGetAttr3}] -if { ${aLen3} != [expr ${aTo1} - ${aFrom1} + 1] } { - set IsGood 0 - puts "aLen3=${aLen3}" - puts ${aMessage3} -### return -} -set aGetAttr41 [lindex ${aGetAttr3} 0] -if { ${aSetAttr11} != ${aGetAttr41} } { - set IsGood 0 - puts "aGetAttr41=${aGetAttr41}" - puts ${aMessage3} -### return -} -set aGetAttr42 [lindex ${aGetAttr3} 1] -if { ${aSetAttr12} != ${aGetAttr42} } { - set IsGood 0 - puts "aGetAttr42=${aGetAttr42}" - puts ${aMessage3} -### return -} - -if { ${IsGood} == 0} { - puts "Get a value of TDataStd_RealArray attribute: Error" -} else { - puts "Get a value of TDataStd_RealArray attribute: OK" -} diff --git a/tests/caf/basic/C4 b/tests/caf/basic/C4 deleted file mode 100644 index d8d2c4bd33..0000000000 --- a/tests/caf/basic/C4 +++ /dev/null @@ -1,79 +0,0 @@ -#INTERFACE CAF -# Basic attributes -# TDataStd_RealArray -# -# Testing attribute: User defined (additional GUID) TDataStd_RealArray -# -# Testing command: SetRealArray, GetRealArray -# - -puts "caf001-C4" -set QA_DUP 0 - -# Add an attribute to a data framework -set aFrom1 1 -set aTo1 2 -set aSetAttr11 3. -set aSetAttr12 4. -set aLabel 0:2 -set isDelta 0 -set aGuid1 "12e94511-6dbc-11d4-b9c8-0060b0ee281b" - -SetRealArray D ${aLabel} ${isDelta} ${aFrom1} ${aTo1} ${aSetAttr11} ${aSetAttr12} -SetRealArray D ${aLabel} ${isDelta} -g ${aGuid1} ${aFrom1} ${aTo1} ${aSetAttr11} ${aSetAttr12} - -# Close/Open the transaction -NewCommand D - -# Forget the attribute -ForgetAll D ${aLabel} - -# Close/Open the transaction -NewCommand D - -# Undo-Redo-Undo -Undo D -Redo D -Undo D - -# Get a value of the attribute -set IsGood 1 -set aMessage1 "Add TDataStd_RealArray attribute: Error" -set aGetAttr1 [GetRealArray D ${aLabel}] -set aLen1 [llength ${aGetAttr1}] -set aGetAttr2 [GetRealArray D ${aLabel} ${aGuid1}] -set aLen2 [llength ${aGetAttr2}] - -if { ${aLen1} != [expr ${aTo1} - ${aFrom1} + 1] } { - set IsGood 0 - puts "aLen1=${aLen1}" - puts ${aMessage1} -} -if { ${aLen2} != [expr ${aTo1} - ${aFrom1} + 1] } { - set IsGood 0 - puts "aLen2=${aLen2}" - puts ${aMessage1} -} - -set aGetAttr11 [lindex ${aGetAttr1} 0] -set aGetAttr21 [lindex ${aGetAttr2} 0] -if { ${aGetAttr11} != ${aGetAttr21} } { - set IsGood 0 - puts "aGetAttr11=${aGetAttr11}" - puts "aGetAttr21=${aGetAttr21}" - puts ${aMessage1} -} -set aGetAttr12 [lindex ${aGetAttr1} 1] -set aGetAttr22 [lindex ${aGetAttr2} 1] -if { ${aGetAttr12} != ${aGetAttr22} } { - set IsGood 0 - puts "aGetAttr12=${aGetAttr12}" - puts "aGetAttr22=${aGetAttr22}" - puts ${aMessage1} -} - -if { ${IsGood} == 0} { - puts "Add TDataStd_RealArray attribute: Error" -} else { - puts "Add TDataStd_RealArray attribute: OK" -} diff --git a/tests/caf/basic/C5 b/tests/caf/basic/C5 deleted file mode 100644 index 86dab81241..0000000000 --- a/tests/caf/basic/C5 +++ /dev/null @@ -1,88 +0,0 @@ -#INTERFACE CAF -# Basic attributes -# TDataStd_RealArray -# -# Testing attribute: User defined (additional GUID) TDataStd_RealArray -# -# Testing command: SetRealArray -# Testing command: GetRealArray -# - -puts "caf001-C5" -set QA_DUP 0 - -# Add an attributes to a data framework -set aFrom1 1 -set aTo1 2 -set aSetAttr11 3. -set aSetAttr12 4. -set aLabel 0:2 -set isDelta 0 -set aGuid1 "12e94511-6dbc-11d4-b9c8-0060b0ee281b" - -SetRealArray D ${aLabel} ${isDelta} ${aFrom1} ${aTo1} ${aSetAttr11} ${aSetAttr12} -SetRealArray D ${aLabel} ${isDelta} -g ${aGuid1} ${aFrom1} ${aTo1} ${aSetAttr11} ${aSetAttr12} - -# Close/Open the transaction -NewCommand D - -# Forget the attribute -ForgetAll D ${aLabel} - -# Close/Open the transaction -NewCommand D - -# Undo-Redo-Undo -Undo D -Redo D -Undo D - -# Save Document -set aFile ${imagedir}/caf001-C5.cbf -SaveAs D ${aFile}; -Close D - -#Open a document -Open ${aFile} D - -# Get a value of the attribute -set IsGood 1 -set aMessage1 "Add TDataStd_RealArray attribute: Error" -set aGetAttr1 [GetRealArray D ${aLabel}] -set aLen1 [llength ${aGetAttr1}] -set aGetAttr2 [GetRealArray D ${aLabel} ${aGuid1}] -set aLen2 [llength ${aGetAttr2}] - -if { ${aLen1} != [expr ${aTo1} - ${aFrom1} + 1] } { - set IsGood 0 - puts "aLen1=${aLen1}" - puts ${aMessage1} -} -if { ${aLen2} != [expr ${aTo1} - ${aFrom1} + 1] } { - set IsGood 0 - puts "aLen2=${aLen2}" - puts ${aMessage1} -} - -set aGetAttr11 [lindex ${aGetAttr1} 0] -set aGetAttr21 [lindex ${aGetAttr2} 0] -if { ${aGetAttr11} != ${aGetAttr21} } { - set IsGood 0 - puts "aGetAttr11=${aGetAttr11}" - puts "aGetAttr21=${aGetAttr21}" - puts ${aMessage1} -} -set aGetAttr12 [lindex ${aGetAttr1} 1] -set aGetAttr22 [lindex ${aGetAttr2} 1] -if { ${aGetAttr12} != ${aGetAttr22} } { - set IsGood 0 - puts "aGetAttr12=${aGetAttr12}" - puts "aGetAttr22=${aGetAttr22}" - puts ${aMessage1} -} - -if { ${IsGood} == 0} { - puts "Add TDataStd_RealArray attribute: Error" -} else { - puts "Add TDataStd_RealArray attribute: OK" -} diff --git a/tests/caf/basic/C6 b/tests/caf/basic/C6 deleted file mode 100644 index 99c5293ba9..0000000000 --- a/tests/caf/basic/C6 +++ /dev/null @@ -1,89 +0,0 @@ -#INTERFACE CAF -# Basic attributes -# TDataStd_RealArray -# -# Testing attribute: User defined (additional GUID) TDataStd_RealArray -# -# Testing command: SetRealArray -# Testing command: GetRealArray -# - -puts "caf001-C6" -set QA_DUP 0 - -# Add an attributes to a data framework -set aFrom1 1 -set aTo1 2 -set aSetAttr11 3. -set aSetAttr12 4. -set aLabel 0:2 -set isDelta 0 -set aGuid1 "12e94511-6dbc-11d4-b9c8-0060b0ee281b" - -SetRealArray D ${aLabel} ${isDelta} ${aFrom1} ${aTo1} ${aSetAttr11} ${aSetAttr12} -SetRealArray D ${aLabel} ${isDelta} -g ${aGuid1} ${aFrom1} ${aTo1} ${aSetAttr11} ${aSetAttr12} - -# Close/Open the transaction -NewCommand D - -# Forget the attribute -ForgetAll D ${aLabel} - -# Close/Open the transaction -NewCommand D - -# Undo-Redo-Undo -Undo D -Redo D -Undo D - -# Save Document -Format D XmlOcaf -set aFile ${imagedir}/caf001-C6.xml -SaveAs D ${aFile}; -Close D - -#Open a document -Open ${aFile} D - -# Get a value of the attribute -set IsGood 1 -set aMessage1 "Add TDataStd_RealArray attribute: Error" -set aGetAttr1 [GetRealArray D ${aLabel}] -set aLen1 [llength ${aGetAttr1}] -set aGetAttr2 [GetRealArray D ${aLabel} ${aGuid1}] -set aLen2 [llength ${aGetAttr2}] - -if { ${aLen1} != [expr ${aTo1} - ${aFrom1} + 1] } { - set IsGood 0 - puts "aLen1=${aLen1}" - puts ${aMessage1} -} -if { ${aLen2} != [expr ${aTo1} - ${aFrom1} + 1] } { - set IsGood 0 - puts "aLen2=${aLen2}" - puts ${aMessage1} -} - -set aGetAttr11 [lindex ${aGetAttr1} 0] -set aGetAttr21 [lindex ${aGetAttr2} 0] -if { ${aGetAttr11} != ${aGetAttr21} } { - set IsGood 0 - puts "aGetAttr11=${aGetAttr11}" - puts "aGetAttr21=${aGetAttr21}" - puts ${aMessage1} -} -set aGetAttr12 [lindex ${aGetAttr1} 1] -set aGetAttr22 [lindex ${aGetAttr2} 1] -if { ${aGetAttr12} != ${aGetAttr22} } { - set IsGood 0 - puts "aGetAttr12=${aGetAttr12}" - puts "aGetAttr22=${aGetAttr22}" - puts ${aMessage1} -} - -if { ${IsGood} == 0} { - puts "Add TDataStd_RealArray attribute: Error" -} else { - puts "Add TDataStd_RealArray attribute: OK" -} diff --git a/tests/caf/basic/D1 b/tests/caf/basic/D1 deleted file mode 100755 index c9adecd3d8..0000000000 --- a/tests/caf/basic/D1 +++ /dev/null @@ -1,66 +0,0 @@ -#INTERFACE CAF -# Basic attributes -# -# Testing attribute: TDataStd_IntegerArray -# -# Testing command: SetIntArray -# Testing command: GetIntArray -# - -puts "caf001-D1" -set QA_DUP 0 - -# Add an attribute to a data framework -set aFrom1 1 -set aTo1 2 -set aSetAttr11 3 -set aSetAttr12 4 -set aLabel 0:2 -set isDelta 0 -SetIntArray D ${aLabel} ${isDelta} ${aFrom1} ${aTo1} ${aSetAttr11} ${aSetAttr12} - -# Close/Open the transaction -NewCommand D - -# Forget the attribute -ForgetAll D ${aLabel} - -# Close/Open the transaction -NewCommand D - -# Undo-Redo-Undo -Undo D -Redo D -Undo D - -# Get a value of the attribute -set IsGood 1 -set aMessage1 "Add TDataStd_IntegerArray attribute: Error" -set aGetAttr1 [GetIntArray D ${aLabel}] -set aLen1 [llength ${aGetAttr1}] -if { ${aLen1} != [expr ${aTo1} - ${aFrom1} + 1] } { - set IsGood 0 - puts "aLen1=${aLen1}" - puts ${aMessage1} -### return -} -set aGetAttr21 [lindex ${aGetAttr1} 0] -if { ${aSetAttr11} != ${aGetAttr21} } { - set IsGood 0 - puts "aGetAttr21=${aGetAttr21}" - puts ${aMessage1} -### return -} -set aGetAttr22 [lindex ${aGetAttr1} 1] -if { ${aSetAttr12} != ${aGetAttr22} } { - set IsGood 0 - puts "aGetAttr22=${aGetAttr22}" - puts ${aMessage1} -### return -} - -if { ${IsGood} == 0} { - puts "Add TDataStd_IntegerArray attribute: Error" -} else { - puts "Add TDataStd_IntegerArray attribute: OK" -} diff --git a/tests/caf/basic/D2 b/tests/caf/basic/D2 deleted file mode 100755 index 6bce5ec02e..0000000000 --- a/tests/caf/basic/D2 +++ /dev/null @@ -1,69 +0,0 @@ -#INTERFACE CAF -# Basic attributes -# TDataStd_IntegerArray -# -# Testing attribute: TDataStd_IntegerArray -# -# Testing command: SetIntArray -# Testing command: GetIntArray -# - -puts "caf001-D2" -set QA_DUP 0 - -# Add an attribute to a data framework -set aFrom1 1 -set aTo1 2 -set aSetAttr11 3 -set aSetAttr12 4 -set aLabel 0:2 -set isDelta 0 -SetIntArray D ${aLabel} ${isDelta} ${aFrom1} ${aTo1} ${aSetAttr11} ${aSetAttr12} - -# Close/Open the transaction -NewCommand D - -# Set a new value of the attribute -set aFrom2 1 -set aTo2 2 -set aSetAttr21 33 -set aSetAttr22 44 -SetIntArray D ${aLabel} ${isDelta} ${aFrom2} ${aTo2} ${aSetAttr21} ${aSetAttr22} - -# Close/Open the transaction -NewCommand D - -# Undo -Undo D - -# Get a value of the attribute -set IsGood 1 -set aMessage2 "Set a value of TDataStd_IntegerArray attribute: Error" -set aGetAttr2 [GetIntArray D ${aLabel}] -set aLen2 [llength ${aGetAttr2}] -if { ${aLen2} != [expr ${aTo1} - ${aFrom1} + 1] } { - set IsGood 0 - puts "aLen2=${aLen2}" - puts ${aMessage2} -### return -} -set aGetAttr31 [lindex ${aGetAttr2} 0] -if { ${aSetAttr11} != ${aGetAttr31} } { - set IsGood 0 - puts "aGetAttr31=${aGetAttr31}" - puts ${aMessage2} -### return -} -set aGetAttr32 [lindex ${aGetAttr2} 1] -if { ${aSetAttr12} != ${aGetAttr32} } { - set IsGood 0 - puts "aGetAttr32=${aGetAttr32}" - puts ${aMessage2} -### return -} - -if { ${IsGood} == 0} { - puts "Set TDataStd_IntegerArray attribute: Error" -} else { - puts "Set TDataStd_IntegerArray attribute: OK" -} diff --git a/tests/caf/basic/D3 b/tests/caf/basic/D3 deleted file mode 100755 index 787b78071b..0000000000 --- a/tests/caf/basic/D3 +++ /dev/null @@ -1,74 +0,0 @@ -#INTERFACE CAF -# Basic attributes -# -# Testing attribute: TDataStd_IntegerArray -# -# Testing command: SetIntArray -# Testing command: GetIntArray -# - -puts "caf001-D3" -set QA_DUP 0 - -# Add an attribute to a data framework -set aFrom1 1 -set aTo1 2 -set aSetAttr11 3 -set aSetAttr12 4 -set aLabel 0:2 -set isDelta 0 -SetIntArray D ${aLabel} ${isDelta} ${aFrom1} ${aTo1} ${aSetAttr11} ${aSetAttr12} - -# Close/Open the transaction -NewCommand D - -# Save the document -set aFile ${imagedir}/caf001-D3.cbf -file delete ${aFile} -SaveAs D ${aFile} -if { ![file exists ${aFile}] } { - puts "There is not ${aFile} file; SaveAs command: Error" - return -} -#catch {exec chmod 777 ${aFile}} - -# Restore the document -Close D -Open ${aFile} DD - -# Get a value of the attribute -set IsGood 1 -set aMessage3 "Get a value of TDataStd_IntegerArray attribute from restoring document: Error" -set IsDone [catch {set aGetAttr3 [GetIntArray DD ${aLabel}]} aResult] -if { ${IsDone} != 0 } { - set IsGood 0 - puts ${aMessage3} -### return -} -set aLen3 [llength ${aGetAttr3}] -if { ${aLen3} != [expr ${aTo1} - ${aFrom1} + 1] } { - set IsGood 0 - puts "aLen3=${aLen3}" - puts ${aMessage3} -### return -} -set aGetAttr41 [lindex ${aGetAttr3} 0] -if { ${aSetAttr11} != ${aGetAttr41} } { - set IsGood 0 - puts "aGetAttr41=${aGetAttr41}" - puts ${aMessage3} -### return -} -set aGetAttr42 [lindex ${aGetAttr3} 1] -if { ${aSetAttr12} != ${aGetAttr42} } { - set IsGood 0 - puts "aGetAttr42=${aGetAttr42}" - puts ${aMessage3} -### return -} - -if { ${IsGood} == 0} { - puts "Get a value of TDataStd_IntegerArray attribute from restoring document: Error" -} else { - puts "Get a value of TDataStd_IntegerArray attribute from restoring document: OK" -} diff --git a/tests/caf/basic/D4 b/tests/caf/basic/D4 deleted file mode 100644 index 1f95e430fe..0000000000 --- a/tests/caf/basic/D4 +++ /dev/null @@ -1,66 +0,0 @@ -#INTERFACE CAF -# Basic attributes -# -# Testing attribute: TDataStd_IntegerArray -# -# Testing command: SetIntArray -# Testing command: GetIntArray -# - -puts "caf001-D1" -set QA_DUP 0 - -# Add an attribute to a data framework -set aFrom1 1 -set aTo1 2 -set aSetAttr11 3 -set aSetAttr12 4 -set aLabel 0:2 -set isDelta 0 -SetIntArray D ${aLabel} ${isDelta} ${aFrom1} ${aTo1} ${aSetAttr11} ${aSetAttr12} - -# Close/Open the transaction -NewCommand D - -# Forget the attribute -ForgetAll D ${aLabel} - -# Close/Open the transaction -NewCommand D - -# Undo-Redo-Undo -Undo D -Redo D -Undo D - -# Get a value of the attribute -set IsGood 1 -set aMessage1 "Add TDataStd_IntegerArray attribute: Error" -set aGetAttr1 [GetIntArray D ${aLabel}] -set aLen1 [llength ${aGetAttr1}] -if { ${aLen1} != [expr ${aTo1} - ${aFrom1} + 1] } { - set IsGood 0 - puts "aLen1=${aLen1}" - puts ${aMessage1} -### return -} -set aGetAttr21 [lindex ${aGetAttr1} 0] -if { ${aSetAttr11} != ${aGetAttr21} } { - set IsGood 0 - puts "aGetAttr21=${aGetAttr21}" - puts ${aMessage1} -### return -} -set aGetAttr22 [lindex ${aGetAttr1} 1] -if { ${aSetAttr12} != ${aGetAttr22} } { - set IsGood 0 - puts "aGetAttr22=${aGetAttr22}" - puts ${aMessage1} -### return -} - -if { ${IsGood} == 0} { - puts "Add TDataStd_IntegerArray attribute: Error" -} else { - puts "Add TDataStd_IntegerArray attribute: OK" -} diff --git a/tests/caf/basic/D5 b/tests/caf/basic/D5 deleted file mode 100644 index 17d843faa2..0000000000 --- a/tests/caf/basic/D5 +++ /dev/null @@ -1,80 +0,0 @@ -#INTERFACE CAF -# Basic attributes -# TDataStd_IntegerArray -# -# Testing attribute: User defined (additional GUID) TDataStd_IntegerArray -# -# Testing command: SetIntArray -# Testing command: GetIntArray -# - -puts "caf001-D5" -set QA_DUP 0 - -# Add an attribute to a data framework -set aFrom1 1 -set aTo1 2 -set aSetAttr11 3 -set aSetAttr12 4 -set aLabel 0:2 -set isDelta 0 -set aGuid1 "12e94511-6dbc-11d4-b9c8-0060b0ee281b" - -SetIntArray D ${aLabel} ${isDelta} ${aFrom1} ${aTo1} ${aSetAttr11} ${aSetAttr12} -SetIntArray D ${aLabel} ${isDelta} -g ${aGuid1} ${aFrom1} ${aTo1} ${aSetAttr11} ${aSetAttr12} - -# Close/Open the transaction -NewCommand D - -# Forget the attribute -ForgetAll D ${aLabel} - -# Close/Open the transaction -NewCommand D - -# Undo-Redo-Undo -Undo D -Redo D -Undo D - -# Get a value of the attribute -set IsGood 1 -set aMessage1 "Add TDataStd_IntegerArray attribute: Error" -set aGetAttr1 [GetIntArray D ${aLabel}] -set aLen1 [llength ${aGetAttr1}] -set aGetAttr2 [GetIntArray D ${aLabel} ${aGuid1}] -set aLen2 [llength ${aGetAttr2}] - -if { ${aLen1} != [expr ${aTo1} - ${aFrom1} + 1] } { - set IsGood 0 - puts "aLen1=${aLen1}" - puts ${aMessage1} -} -if { ${aLen2} != [expr ${aTo1} - ${aFrom1} + 1] } { - set IsGood 0 - puts "aLen2=${aLen2}" - puts ${aMessage1} -} - -set aGetAttr11 [lindex ${aGetAttr1} 0] -set aGetAttr21 [lindex ${aGetAttr2} 0] -if { ${aGetAttr11} != ${aGetAttr21} } { - set IsGood 0 - puts "aGetAttr11=${aGetAttr11}" - puts "aGetAttr21=${aGetAttr21}" - puts ${aMessage1} -} -set aGetAttr12 [lindex ${aGetAttr1} 1] -set aGetAttr22 [lindex ${aGetAttr2} 1] -if { ${aGetAttr12} != ${aGetAttr22} } { - set IsGood 0 - puts "aGetAttr12=${aGetAttr12}" - puts "aGetAttr22=${aGetAttr22}" - puts ${aMessage1} -} - -if { ${IsGood} == 0} { - puts "Add TDataStd_IntegerArray attribute: Error" -} else { - puts "Add TDataStd_IntegerArray attribute: OK" -} diff --git a/tests/caf/basic/D6 b/tests/caf/basic/D6 deleted file mode 100644 index 56e4b092a9..0000000000 --- a/tests/caf/basic/D6 +++ /dev/null @@ -1,89 +0,0 @@ -#INTERFACE CAF -# Basic attributes -# TDataStd_IntegerArray -# -# Testing attribute: User defined (additional GUID) TDataStd_IntegerArray -# -# Testing command: SetIntArray -# Testing command: GetIntArray -# - -puts "caf001-D6" -set QA_DUP 0 - -# Add an attribute to a data framework -set aFrom1 1 -set aTo1 2 -set aSetAttr11 3 -set aSetAttr12 4 -set aLabel 0:2 -set isDelta 0 -set aGuid1 "12e94511-6dbc-11d4-b9c8-0060b0ee281b" - -SetIntArray D ${aLabel} ${isDelta} ${aFrom1} ${aTo1} ${aSetAttr11} ${aSetAttr12} -SetIntArray D ${aLabel} ${isDelta} -g ${aGuid1} ${aFrom1} ${aTo1} ${aSetAttr11} ${aSetAttr12} - -# Close/Open the transaction -NewCommand D - -# Forget the attribute -ForgetAll D ${aLabel} - -# Close/Open the transaction -NewCommand D - -# Undo-Redo-Undo -Undo D -Redo D -Undo D - -# Save Document -set aFile ${imagedir}/caf001-D6.cbf -SaveAs D ${aFile} -Close D - -#Open a document -Open ${aFile} D - - -# Get a value of the attribute -set IsGood 1 -set aMessage1 "Add TDataStd_IntegerArray attribute: Error" -set aGetAttr1 [GetIntArray D ${aLabel}] -set aLen1 [llength ${aGetAttr1}] -set aGetAttr2 [GetIntArray D ${aLabel} ${aGuid1}] -set aLen2 [llength ${aGetAttr2}] - -if { ${aLen1} != [expr ${aTo1} - ${aFrom1} + 1] } { - set IsGood 0 - puts "aLen1=${aLen1}" - puts ${aMessage1} -} -if { ${aLen2} != [expr ${aTo1} - ${aFrom1} + 1] } { - set IsGood 0 - puts "aLen2=${aLen2}" - puts ${aMessage1} -} - -set aGetAttr11 [lindex ${aGetAttr1} 0] -set aGetAttr21 [lindex ${aGetAttr2} 0] -if { ${aGetAttr11} != ${aGetAttr21} } { - set IsGood 0 - puts "aGetAttr11=${aGetAttr11}" - puts "aGetAttr21=${aGetAttr21}" - puts ${aMessage1} -} -set aGetAttr12 [lindex ${aGetAttr1} 1] -set aGetAttr22 [lindex ${aGetAttr2} 1] -if { ${aGetAttr12} != ${aGetAttr22} } { - set IsGood 0 - puts "aGetAttr12=${aGetAttr12}" - puts "aGetAttr22=${aGetAttr22}" - puts ${aMessage1} -} - -if { ${IsGood} == 0} { - puts "Add TDataStd_IntegerArray attribute: Error" -} else { - puts "Add TDataStd_IntegerArray attribute: OK" -} diff --git a/tests/caf/basic/D7 b/tests/caf/basic/D7 deleted file mode 100644 index c15888f84f..0000000000 --- a/tests/caf/basic/D7 +++ /dev/null @@ -1,90 +0,0 @@ -#INTERFACE CAF -# Basic attributes -# TDataStd_RealArray -# -# Testing attribute: User defined (additional GUID) TDataStd_IntegerArray -# -# Testing command: SetIntArray -# Testing command: GetIntArray -# - -puts "caf001-D7" -set QA_DUP 0 - -# Add an attribute to a data framework -set aFrom1 1 -set aTo1 2 -set aSetAttr11 3 -set aSetAttr12 4 -set aLabel 0:2 -set isDelta 0 -set aGuid1 "12e94511-6dbc-11d4-b9c8-0060b0ee281b" - -SetIntArray D ${aLabel} ${isDelta} ${aFrom1} ${aTo1} ${aSetAttr11} ${aSetAttr12} -SetIntArray D ${aLabel} ${isDelta} -g ${aGuid1} ${aFrom1} ${aTo1} ${aSetAttr11} ${aSetAttr12} - -# Close/Open the transaction -NewCommand D - -# Forget the attribute -ForgetAll D ${aLabel} - -# Close/Open the transaction -NewCommand D - -# Undo-Redo-Undo -Undo D -Redo D -Undo D - -# Save Document -Format D XmlOcaf -set aFile ${imagedir}/caf001-D7.xml -SaveAs D ${aFile} -Close D - -#Open a document -Open ${aFile} D - - -# Get a value of the attribute -set IsGood 1 -set aMessage1 "Add TDataStd_IntegerArray attribute: Error" -set aGetAttr1 [GetIntArray D ${aLabel}] -set aLen1 [llength ${aGetAttr1}] -set aGetAttr2 [GetIntArray D ${aLabel} ${aGuid1}] -set aLen2 [llength ${aGetAttr2}] - -if { ${aLen1} != [expr ${aTo1} - ${aFrom1} + 1] } { - set IsGood 0 - puts "aLen1=${aLen1}" - puts ${aMessage1} -} -if { ${aLen2} != [expr ${aTo1} - ${aFrom1} + 1] } { - set IsGood 0 - puts "aLen2=${aLen2}" - puts ${aMessage1} -} - -set aGetAttr11 [lindex ${aGetAttr1} 0] -set aGetAttr21 [lindex ${aGetAttr2} 0] -if { ${aGetAttr11} != ${aGetAttr21} } { - set IsGood 0 - puts "aGetAttr11=${aGetAttr11}" - puts "aGetAttr21=${aGetAttr21}" - puts ${aMessage1} -} -set aGetAttr12 [lindex ${aGetAttr1} 1] -set aGetAttr22 [lindex ${aGetAttr2} 1] -if { ${aGetAttr12} != ${aGetAttr22} } { - set IsGood 0 - puts "aGetAttr12=${aGetAttr12}" - puts "aGetAttr22=${aGetAttr22}" - puts ${aMessage1} -} - -if { ${IsGood} == 0} { - puts "Add TDataStd_IntegerArray attribute: Error" -} else { - puts "Add TDataStd_IntegerArray attribute: OK" -} diff --git a/tests/caf/basic/E1 b/tests/caf/basic/E1 deleted file mode 100755 index a0645b35ab..0000000000 --- a/tests/caf/basic/E1 +++ /dev/null @@ -1,39 +0,0 @@ -#INTERFACE CAF -# Basic attributes -# -# Testing attribute: TDataStd_Name -# -# Testing command: SetName -# Testing command: GetName -# - -puts "caf001-E1" - -# Add an attribute to a data framework -set aSetAttr1 "New Attribute" -set aLabel 0:2 -Label D ${aLabel} -SetName D ${aLabel} ${aSetAttr1} - -# Close/Open the transaction -NewCommand D - -# Forget the attribute -ForgetAll D ${aLabel} - -# Close/Open the transaction -NewCommand D - -# Undo-Redo-Undo -Undo D -Redo D -Undo D - -# Get a value of the attribute -set aGetAttr1 [GetName D ${aLabel}] -if { ${aSetAttr1}!=${aGetAttr1} } { - puts "aSetAttr1=${aSetAttr1} aGetAttr1=${aGetAttr1}" - puts "Add TDataStd_Name attribute: Error" - return -} -puts "Add TDataStd_Name attribute: OK" diff --git a/tests/caf/basic/E2 b/tests/caf/basic/E2 deleted file mode 100755 index 7266e0d853..0000000000 --- a/tests/caf/basic/E2 +++ /dev/null @@ -1,38 +0,0 @@ -#INTERFACE CAF -# Basic attributes -# -# Testing attribute: TDataStd_Name -# -# Testing command: SetName -# Testing command: GetName -# - -puts "caf001-E2" - -# Add an attribute to a data framework -set aSetAttr1 "New Attribute" -set aLabel 0:2 -Label D ${aLabel} -SetName D ${aLabel} ${aSetAttr1} - -# Close/Open the transaction -NewCommand D - -# Set a new value of the attribute -set aSetAttr2 "Old Attribute" -SetName D ${aLabel} ${aSetAttr2} - -# Close/Open the transaction -NewCommand D - -# Undo -Undo D - -# Get a value of the attribute -set aGetAttr2 [GetName D ${aLabel}] -if { ${aSetAttr1}!=${aGetAttr2} } { - puts "aSetAttr1=${aSetAttr1} aGetAttr2=${aGetAttr2}" - puts "Set a value of TDataStd_Name attribute: Error" - return -} -puts "Set a value of TDataStd_Name attribute: OK" diff --git a/tests/caf/basic/E3 b/tests/caf/basic/E3 deleted file mode 100755 index c43ce2f6ce..0000000000 --- a/tests/caf/basic/E3 +++ /dev/null @@ -1,44 +0,0 @@ -#INTERFACE CAF -# Basic attributes -# -# Testing attribute: TDataStd_Name -# -# Testing command: SetName -# Testing command: GetName -# - -puts "caf001-E3" - -# Add an attribute to a data framework -set aSetAttr1 "New Attribute" -set aLabel 0:2 -Label D ${aLabel} -SetName D ${aLabel} ${aSetAttr1} - -# Close/Open the transaction -NewCommand D - -# Save the document -set aFile ${imagedir}/caf001-E3.cbf -file delete ${aFile} -SaveAs D ${aFile} -if { ![file exists ${aFile}] } { - puts "There is not ${aFile} file; SaveAs command: Error" - return -} -#catch {exec chmod 777 ${aFile}} - -# Restore the document -Close D -Open ${aFile} DD - -# Get a value of the attribute -set IsDone [catch {set aGetAttr3 [GetName DD ${aLabel}]} aResult] -if { ${IsDone} != 0 || - ${aSetAttr1}!=${aGetAttr3} } { - puts ${aResult} - puts "aSetAttr1=${aSetAttr1} aGetAttr3=${aGetAttr3}" - puts "Get a value of TDataStd_Name attribute from restoring document: Error" - return -} -puts "Get a value of TDataStd_Name attribute from restoring document: OK" diff --git a/tests/caf/basic/E4 b/tests/caf/basic/E4 deleted file mode 100644 index 29cd7adcf8..0000000000 --- a/tests/caf/basic/E4 +++ /dev/null @@ -1,50 +0,0 @@ -#INTERFACE CAF -# Basic attributes -# -# Testing attribute: User defined (additional GUID) TDataStd_Name -# -# Testing command: SetName -# Testing command: GetName -# - -puts "caf001-E4" - -# Add an attribute to a data framework -set aSetAttr1 "New Attribute1" -set aSetAttr2 "New Attribute2" -set aGuid1 "12e94561-6dbc-11d4-b9c8-0060b0ee281b" -set aGuid2 "12e94562-6dbc-11d4-b9c8-0060b0ee281b" -set aLabel 0:2 -SetName D ${aLabel} ${aSetAttr1} ${aGuid1} -SetName D ${aLabel} ${aSetAttr2} ${aGuid2} - -# Close/Open the transaction -NewCommand D - -# Forget the attribute -ForgetAll D ${aLabel} - -# Close/Open the transaction -NewCommand D - -# Undo-Redo-Undo -Undo D -Redo D -Undo D - -# Get a value of the attribute -set aGetAttr1 [GetName D ${aLabel} ${aGuid1}] -if { ${aSetAttr1}!=${aGetAttr1} } { - puts "aSetAttr1=${aSetAttr1} aGetAttr1=${aGetAttr1}" - puts "Add user defined TDataStd_Name attribute: Error" - return -} - -set aGetAttr2 [GetName D ${aLabel} ${aGuid2}] -if { ${aSetAttr2}!=${aGetAttr2} } { - puts "aSetAttr2=${aSetAttr2} aGetAttr2=${aGetAttr2}" - puts "Add user defined TDataStd_Name attribute: Error" - return -} - -puts "Add user defined TDataStd_Name attributes: OK" diff --git a/tests/caf/basic/E5 b/tests/caf/basic/E5 deleted file mode 100644 index 8be7ded210..0000000000 --- a/tests/caf/basic/E5 +++ /dev/null @@ -1,52 +0,0 @@ -#INTERFACE CAF -# Basic attributes -# -# Testing attribute: User defined (additional GUID) TDataStd_Name -# -# Testing command: SetName -# Testing command: GetName -# - -puts "caf001-E5" - -# Add an attribute to a data framework -set aSetAttr1 "New Attribute_1" -set aSetAttr2 "New Attribute_2" -set aGuid1 "12e94561-6dbc-11d4-b9c8-0060b0ee281b" -set aGuid2 "12e94562-6dbc-11d4-b9c8-0060b0ee281b" -set aLabel 0:2 -SetName D ${aLabel} ${aSetAttr1} ${aGuid1} -SetName D ${aLabel} ${aSetAttr2} ${aGuid2} - -# Close/Open the transaction -NewCommand D - -# Set a new value of the attributes -set aSetAttr12 "Modified Attribute_1" -SetName D ${aLabel} ${aSetAttr12} ${aGuid1} - -set aSetAttr22 "Modified Attribute_2" -SetName D ${aLabel} ${aSetAttr12} ${aGuid2} - -# Close/Open the transaction -NewCommand D - -# Undo-Redo-Undo -Undo D - -# Get a value of the attribute -set aGetAttr1 [GetName D ${aLabel} ${aGuid1}] -if { ${aSetAttr1}!=${aGetAttr1} } { - puts "aSetAttr1=${aSetAttr1} aGetAttr1=${aGetAttr1}" - puts "Add user defined TDataStd_Name attribute: Error" - return -} - -set aGetAttr2 [GetName D ${aLabel} ${aGuid2}] -if { ${aSetAttr2}!=${aGetAttr2} } { - puts "aSetAttr2=${aSetAttr2} aGetAttr2=${aGetAttr2}" - puts "Add user defined TDataStd_Name attribute: Error" - return -} - -puts "Add user defined TDataStd_Name attributes: OK" diff --git a/tests/caf/basic/E6 b/tests/caf/basic/E6 deleted file mode 100644 index b064c673a5..0000000000 --- a/tests/caf/basic/E6 +++ /dev/null @@ -1,58 +0,0 @@ -#INTERFACE CAF -# Basic attributes -# -# Testing attribute: User defined (additional GUID) TDataStd_Name -# -# Testing command: SetName -# Testing command: GetName -# - -puts "caf001-E6" - -# Add an attribute to a data framework -set aSetAttr1 "New Attribute_1" -set aSetAttr2 "New Attribute_2" -set aGuid1 "12e94561-6dbc-11d4-b9c8-0060b0ee281b" -set aGuid2 "12e94562-6dbc-11d4-b9c8-0060b0ee281b" -set aLabel 0:2 -SetName D ${aLabel} ${aSetAttr1} ${aGuid1} -SetName D ${aLabel} ${aSetAttr2} ${aGuid2} - -# Close/Open the transaction -NewCommand D - -# Save the document -set aFile ${imagedir}/caf001-E6.cbf -file delete ${aFile} -SaveAs D ${aFile} -if { ![file exists ${aFile}] } { - puts "There is not ${aFile} file; SaveAs command: Error" - return -} -#catch {exec chmod 777 ${aFile}} - -# Restore the document -Close D -Open ${aFile} DD - -# Get a value of the attribute #1 -set IsDone [catch {set aGetAttr3 [GetName DD ${aLabel} ${aGuid1}]} aResult] -if { ${IsDone} != 0 || - ${aSetAttr1}!=${aGetAttr3} } { - puts ${aResult} - puts "aSetAttr1=${aSetAttr1} aGetAttr3=${aGetAttr3}" - puts "Get a value of the first TDataStd_Name attribute from restoring document: Error" - return -} - -# Get a value of the attribute #2 -set IsDone [catch {set aGetAttr4 [GetName DD ${aLabel} ${aGuid2}]} aResult] -if { ${IsDone} != 0 || - ${aSetAttr2}!=${aGetAttr4} } { - puts ${aResult} - puts "aSetAttr2=${aSetAttr2} aGetAttr4=${aGetAttr4}" - puts "Get a value of the second TDataStd_Name attribute from restoring document: Error" - return -} - -puts "Get a value of user defined TDataStd_Name attributes from restoring document: OK" diff --git a/tests/caf/basic/E7 b/tests/caf/basic/E7 deleted file mode 100644 index 164840aaef..0000000000 --- a/tests/caf/basic/E7 +++ /dev/null @@ -1,57 +0,0 @@ -#INTERFACE CAF -# Basic attributes -# -# Testing attribute: User defined (additional GUID) TDataStd_Name -# -# Testing command: SetName -# Testing command: GetName -# - -puts "caf001-E6" - -# Add an attribute to a data framework -set aSetAttr1 "New Attribute_1" -set aSetAttr2 "New Attribute_2" -set aGuid2 "12e94562-6dbc-11d4-b9c8-0060b0ee281b" -set aLabel 0:2 -SetName D ${aLabel} ${aSetAttr1} -SetName D ${aLabel} ${aSetAttr2} ${aGuid2} - -# Close/Open the transaction -NewCommand D - -# Save the document -set aFile ${imagedir}/caf001-E7.cbf -file delete ${aFile} -SaveAs D ${aFile} -if { ![file exists ${aFile}] } { - puts "There is not ${aFile} file; SaveAs command: Error" - return -} -#catch {exec chmod 777 ${aFile}} - -# Restore the document -Close D -Open ${aFile} DD - -# Get a value of the attribute #1 -set IsDone [catch {set aGetAttr3 [GetName DD ${aLabel}]} aResult] -if { ${IsDone} != 0 || - ${aSetAttr1}!=${aGetAttr3} } { - puts ${aResult} - puts "aSetAttr1=${aSetAttr1} aGetAttr3=${aGetAttr3}" - puts "Get a value of the first TDataStd_Name attribute from restoring document: Error" - return -} - -# Get a value of the attribute #2 -set IsDone [catch {set aGetAttr4 [GetName DD ${aLabel} ${aGuid2}]} aResult] -if { ${IsDone} != 0 || - ${aSetAttr2}!=${aGetAttr4} } { - puts ${aResult} - puts "aSetAttr2=${aSetAttr2} aGetAttr4=${aGetAttr4}" - puts "Get a value of the second TDataStd_Name attribute from restoring document: Error" - return -} - -puts "Get a value of user defined TDataStd_Name attributes from restoring document: OK" diff --git a/tests/caf/basic/F1 b/tests/caf/basic/F1 deleted file mode 100755 index d397cef44e..0000000000 --- a/tests/caf/basic/F1 +++ /dev/null @@ -1,39 +0,0 @@ -#INTERFACE CAF -# Basic attributes -# -# Testing attribute: TDataStd_Comment -# -# Testing command: SetComment -# Testing command: GetComment -# - -puts "caf001-F1" - -# Add an attribute to a data framework -set aSetAttr1 "New Attribute" -set aLabel 0:2 -Label D ${aLabel} -SetComment D ${aLabel} ${aSetAttr1} - -# Close/Open the transaction -NewCommand D - -# Forget the attribute -ForgetAll D ${aLabel} - -# Close/Open the transaction -NewCommand D - -# Undo-Redo-Undo -Undo D -Redo D -Undo D - -# Get a value of the attribute -set aGetAttr1 [GetComment D ${aLabel}] -if { ${aSetAttr1}!=${aGetAttr1} } { - puts "aSetAttr1=${aSetAttr1} aGetAttr1=${aGetAttr1}" - puts "Add TDataStd_Comment attribute: Error" - return -} -puts "Add TDataStd_Comment attribute: OK" diff --git a/tests/caf/basic/F2 b/tests/caf/basic/F2 deleted file mode 100755 index a43d11a148..0000000000 --- a/tests/caf/basic/F2 +++ /dev/null @@ -1,38 +0,0 @@ -#INTERFACE CAF -# Basic attributes -# -# Testing attribute: TDataStd_Comment -# -# Testing command: SetComment -# Testing command: GetComment -# - -puts "caf001-F2" - -# Add an attribute to a data framework -set aSetAttr1 "New Attribute" -set aLabel 0:2 -Label D ${aLabel} -SetComment D ${aLabel} ${aSetAttr1} - -# Close/Open the transaction -NewCommand D - -# Set a new value of the attribute -set aSetAttr2 "Old Attribute" -SetComment D ${aLabel} ${aSetAttr2} - -# Close/Open the transaction -NewCommand D - -# Undo -Undo D - -# Get a value of the attribute -set aGetAttr2 [GetComment D ${aLabel}] -if { ${aSetAttr1}!=${aGetAttr2} } { - puts "aSetAttr1=${aSetAttr1} aGetAttr2=${aGetAttr2}" - puts "Set a value of TDataStd_Comment attribute: Error" - return -} -puts "Set a value of TDataStd_Comment attribute: OK" diff --git a/tests/caf/basic/F3 b/tests/caf/basic/F3 deleted file mode 100755 index 2193091697..0000000000 --- a/tests/caf/basic/F3 +++ /dev/null @@ -1,44 +0,0 @@ -#INTERFACE CAF -# Basic attributes -# -# Testing attribute: TDataStd_Comment -# -# Testing command: SetComment -# Testing command: GetComment -# - -puts "caf001-F3" - -# Add an attribute to a data framework -set aSetAttr1 "New Attribute" -set aLabel 0:2 -Label D ${aLabel} -SetComment D ${aLabel} ${aSetAttr1} - -# Close/Open the transaction -NewCommand D - -# Save the document -set aFile ${imagedir}/caf001-F3.cbf -file delete ${aFile} -SaveAs D ${aFile} -if { ![file exists ${aFile}] } { - puts "There is not ${aFile} file; SaveAs command: Error" - return -} -#catch {exec chmod 777 ${aFile}} - -# Restore the document -Close D -Open ${aFile} DD - -# Get a value of the attribute -set IsDone [catch {set aGetAttr3 [GetComment DD ${aLabel}]} aResult] -if { ${IsDone} != 0 || - ${aSetAttr1}!=${aGetAttr3} } { - puts ${aResult} - puts "aSetAttr1=${aSetAttr1} aGetAttr3=${aGetAttr3}" - puts "Get a value of TDataStd_Comment attribute from restoring document: Error" - return -} -puts "Get a value of TDataStd_Comment attribute from restoring document: OK" diff --git a/tests/caf/basic/F4 b/tests/caf/basic/F4 deleted file mode 100644 index 200cc657a8..0000000000 --- a/tests/caf/basic/F4 +++ /dev/null @@ -1,81 +0,0 @@ -#INTERFACE CAF -# Basic attributes -# -# Testing attributes: TDataStd_Tick TDataStd_Directory TDataStd_NoteBook TDataXtd_Axis TDataXtd_Placement TDataXtd_Plane TDataXtd_Point TDataXtd_Shape -# -# Testing command: SetEmptyAttribute -# BinOcaf format open/save with these attributes - -Label D 0:2 - -set IsGood 1 - -NewCommand D -SetEmptyAttribute D 0:2 TDataStd_Tick -SetEmptyAttribute D 0:2 TDataStd_Directory -SetEmptyAttribute D 0:2 TDataStd_NoteBook -SetEmptyAttribute D 0:2 TDataXtd_Axis -SetEmptyAttribute D 0:2 TDataXtd_Placement -SetEmptyAttribute D 0:2 TDataXtd_Plane -SetEmptyAttribute D 0:2 TDataXtd_Point -SetEmptyAttribute D 0:2 TDataXtd_Shape -CommitCommand D - -set aLen1 [llength [Attributes D 0:2]] -if { ${aLen1} != 8 } { - set IsGood 0 - puts "Not all attributes were added aLen1=${aLen1}" -} - -NewCommand D -# check forget attribute by its type -ForgetAtt D 0:2 TDataXtd_Point -CommitCommand D - -set aLen2 [llength [Attributes D 0:2]] -if { ${aLen2} != ${aLen1} - 1 } { - set IsGood 0 - puts "TDataXtd_Point was not removed from the label" -} - -Undo D -Undo D - -set aLen3 [llength [Attributes D 0:2]] -if { ${aLen3} != 0 } { - set IsGood 0 - puts "Not all attributes were removed on Undo aLen3=${aLen3}" -} - -Redo D - -set aLen4 [llength [Attributes D 0:2]] -if { ${aLen4} != 8 } { - set IsGood 0 - puts "Not all attributes were restored by Redo aLen4=${aLen4}" -} - -set aFile ${imagedir}/caf001-F4.cbf -file delete ${aFile} -SaveAs D ${aFile} -if { ![file exists ${aFile}] } { - puts "There is not ${aFile} file; SaveAs command: Error" - return -} -Close D - -Open ${aFile} DD - -Label DD 0:2 - -set aLen5 [llength [Attributes DD 0:2]] -if { ${aLen5} != 8 } { - set IsGood 0 - puts "Not all attributes were restored on Open aLen4=${aLen5}" -} - -if { ${IsGood} == 0} { - puts "Set empty attributes: Error" -} else { - puts "Set empty attributes: OK" -} diff --git a/tests/caf/basic/F5 b/tests/caf/basic/F5 deleted file mode 100644 index 5d4fc0332a..0000000000 --- a/tests/caf/basic/F5 +++ /dev/null @@ -1,70 +0,0 @@ -#INTERFACE CAF -# Basic attributes -# -# Testing attributes: TDataStd_Tick TDataStd_Directory TDataStd_NoteBook TDataXtd_Axis TDataXtd_Placement TDataXtd_Plane TDataXtd_Point TDataXtd_Shape -# -# Testing command: SetEmptyAttribute -# XmlOcaf format open/save with these attributes - -NewDocument DX XmlOcaf -UndoLimit DX 2 - -Label DX 0:2 - -set IsGood 1 - -NewCommand DX -SetEmptyAttribute DX 0:2 TDataXtd_Axis -SetEmptyAttribute DX 0:2 TDataXtd_Placement -SetEmptyAttribute DX 0:2 TDataXtd_Plane -SetEmptyAttribute DX 0:2 TDataXtd_Point -SetEmptyAttribute DX 0:2 TDataXtd_Shape -SetEmptyAttribute DX 0:2 TDataStd_Tick -SetEmptyAttribute DX 0:2 TDataStd_Directory -SetEmptyAttribute DX 0:2 TDataStd_NoteBook -CommitCommand DX - -set aLen1 [llength [Attributes DX 0:2]] -if { ${aLen1} != 8 } { - set IsGood 0 - puts "Not all attributes were added aLen1=${aLen1}" -} - -Undo DX - -set aLen2 [llength [Attributes DX 0:2]] -if { ${aLen2} != 0 } { - set IsGood 0 - puts "Not all attributes were removed on Undo aLen2=${aLen2}" -} - -Redo DX - -set aLen3 [llength [Attributes DX 0:2]] -if { ${aLen3} != 8 } { - set IsGood 0 - puts "Not all attributes were restored by Redo aLen3=${aLen3}" -} - -set aFile ${imagedir}/caf001-F5.xml -file delete ${aFile} -SaveAs DX ${aFile} -if { ![file exists ${aFile}] } { - puts "There is not ${aFile} file; SaveAs command: Error" - return -} -Close DX - -Open ${aFile} DDX - -set aLen4 [llength [Attributes DDX 0:2]] -if { ${aLen4} != 8 } { - set IsGood 0 - puts "Not all attributes were restored on Open aLen4=${aLen4}" -} - -if { ${IsGood} == 0} { - puts "Set empty attributes: Error" -} else { - puts "Set empty attributes: OK" -} diff --git a/tests/caf/basic/G1 b/tests/caf/basic/G1 deleted file mode 100755 index 730f2cf3e8..0000000000 --- a/tests/caf/basic/G1 +++ /dev/null @@ -1,65 +0,0 @@ -#INTERFACE CAF -# Basic attributes -# -# Testing attribute: TDataStd_Point -# -# Testing command: SetPoint -# Testing command: GetPoint -# - -puts "caf001-G1" - -set aTokList { :,} - -# Add an attribute to a data framework -set aSetX1 10 -set aSetY1 20 -set aSetZ1 30 -point aPoint1 ${aSetX1} ${aSetY1} ${aSetZ1} - -set aDumpPoint1 [dump aPoint1] - -# [llength ${aDumpPoint1}] = 10 -# Format of ${aDumpPoint1}: -# *********** Dump of aPoint1 ************* -# Point : 1.000000000000000e+01, 2.000000000000000e+01, 3.000000000000000e+01 - -set X_Point1 [lindex [split [lindex ${aDumpPoint1} 7] ${aTokList}] 0] -set Y_Point1 [lindex [split [lindex ${aDumpPoint1} 8] ${aTokList}] 0] -set Z_Point1 [lindex [split [lindex ${aDumpPoint1} 9] ${aTokList}] 0] - -set aLabel 0:2 -SetPoint D ${aLabel} aPoint1 - -# Close/Open the transaction -NewCommand D - -# Forget the attribute -ForgetAll D ${aLabel} - -# Close/Open the transaction -NewCommand D - -# Undo-Redo-Undo -Undo D -Redo D -Undo D - -# Get a value of the attribute -GetPoint D ${aLabel} aPoint2 - -set aDumpPoint2 [dump aPoint2] -set X_Point2 [lindex [split [lindex ${aDumpPoint2} 7] ${aTokList}] 0] -set Y_Point2 [lindex [split [lindex ${aDumpPoint2} 8] ${aTokList}] 0] -set Z_Point2 [lindex [split [lindex ${aDumpPoint2} 9] ${aTokList}] 0] - -if { ${X_Point1} != ${X_Point2} || - ${Y_Point1} != ${Y_Point2} || - ${Z_Point1} != ${Z_Point2} } { - puts "X_Point1=${X_Point1} X_Point2=${X_Point2}" - puts "Y_Point1=${Y_Point1} Y_Point2=${Y_Point2}" - puts "Z_Point1=${Z_Point1} Z_Point2=${Z_Point2}" - puts "Add Point attribute: Error" - return -} -puts "Add Point attribute: OK" diff --git a/tests/caf/basic/G2 b/tests/caf/basic/G2 deleted file mode 100755 index 01770418a3..0000000000 --- a/tests/caf/basic/G2 +++ /dev/null @@ -1,67 +0,0 @@ -#INTERFACE CAF -# Basic attributes -# -# Testing attribute: TDataStd_Point -# -# Testing command: SetPoint -# Testing command: GetPoint -# - -puts "caf001-G2" - -set aTokList { :,} - -# Add an attribute to a data framework -set aSetX1 10 -set aSetY1 20 -set aSetZ1 30 -point aPoint1 ${aSetX1} ${aSetY1} ${aSetZ1} - -set aDumpPoint1 [dump aPoint1] - -# [llength ${aDumpPoint1}] = 10 -# Format of ${aDumpPoint1}: -# *********** Dump of aPoint1 ************* -# Point : 1.000000000000000e+01, 2.000000000000000e+01, 3.000000000000000e+01 - -set X_Point1 [lindex [split [lindex ${aDumpPoint1} 7] ${aTokList}] 0] -set Y_Point1 [lindex [split [lindex ${aDumpPoint1} 8] ${aTokList}] 0] -set Z_Point1 [lindex [split [lindex ${aDumpPoint1} 9] ${aTokList}] 0] - -set aLabel 0:2 -SetPoint D ${aLabel} aPoint1 - -# Close/Open the transaction -NewCommand D - -# Set a new value of the attribute -set aSetX3 110 -set aSetY3 120 -set aSetZ3 130 -point aPoint3 ${aSetX3} ${aSetY3} ${aSetZ3} -SetPoint D ${aLabel} aPoint3 - -# Close/Open the transaction -NewCommand D - -# Undo -Undo D - -# Get a value of the attribute -GetPoint D ${aLabel} aPoint4 - -set aDumpPoint4 [dump aPoint4] -set X_Point4 [lindex [split [lindex ${aDumpPoint4} 7] ${aTokList}] 0] -set Y_Point4 [lindex [split [lindex ${aDumpPoint4} 8] ${aTokList}] 0] -set Z_Point4 [lindex [split [lindex ${aDumpPoint4} 9] ${aTokList}] 0] - -if { ${X_Point1} != ${X_Point4} || - ${Y_Point1} != ${Y_Point4} || - ${Z_Point1} != ${Z_Point4} } { - puts "X_Point1=${X_Point1} X_Point4=${X_Point4}" - puts "Y_Point1=${Y_Point1} Y_Point4=${Y_Point4}" - puts "Z_Point1=${Z_Point1} Z_Point4=${Z_Point4}" - puts "Set a value of TDataStd_Point attribute: Error" - return -} -puts "Set a value of TDataStd_Point attribute: OK" diff --git a/tests/caf/basic/G3 b/tests/caf/basic/G3 deleted file mode 100755 index cf10835ebf..0000000000 --- a/tests/caf/basic/G3 +++ /dev/null @@ -1,74 +0,0 @@ -#INTERFACE CAF -# Basic attributes -# -# Testing attribute: TDataStd_Point -# -# Testing command: SetPoint -# Testing command: GetPoint -# - -puts "caf001-G3" - -set aTokList { :,} - -# Add an attribute to a data framework -set aSetX1 10 -set aSetY1 20 -set aSetZ1 30 -point aPoint1 ${aSetX1} ${aSetY1} ${aSetZ1} - -set aDumpPoint1 [dump aPoint1] - -# [llength ${aDumpPoint1}] = 10 -# Format of ${aDumpPoint1}: -# *********** Dump of aPoint1 ************* -# Point : 1.000000000000000e+01, 2.000000000000000e+01, 3.000000000000000e+01 - -set X_Point1 [lindex [split [lindex ${aDumpPoint1} 7] ${aTokList}] 0] -set Y_Point1 [lindex [split [lindex ${aDumpPoint1} 8] ${aTokList}] 0] -set Z_Point1 [lindex [split [lindex ${aDumpPoint1} 9] ${aTokList}] 0] - -set aLabel 0:2 -SetPoint D ${aLabel} aPoint1 - -# Close/Open the transaction -NewCommand D - -# Save the document -set aFile ${imagedir}/caf001-G3.cbf -file delete ${aFile} -SaveAs D ${aFile} -if { ![file exists ${aFile}] } { - puts "There is no file ${aFile}; SaveAs command: Error" - return -} -#catch {exec chmod 777 ${aFile}} - -# Restore the document -Close D -Open ${aFile} DD - -# Get a value of the attribute -set IsDone [catch {set aGetAttr3 [GetPoint DD ${aLabel}]} aResult] -if { ${IsDone} != 0 } { - puts ${aResult} - puts "Get a value of TDataStd_Point attribute from restoring document: Error" - return -} -GetPoint DD ${aLabel} aPoint5 - -set aDumpPoint5 [dump aPoint5] -set X_Point5 [lindex [split [lindex ${aDumpPoint5} 7] ${aTokList}] 0] -set Y_Point5 [lindex [split [lindex ${aDumpPoint5} 8] ${aTokList}] 0] -set Z_Point5 [lindex [split [lindex ${aDumpPoint5} 9] ${aTokList}] 0] - -if { ${X_Point1} != ${X_Point5} || - ${Y_Point1} != ${Y_Point5} || - ${Z_Point1} != ${Z_Point5} } { - puts "X_Point1=${X_Point1} X_Point5=${X_Point5}" - puts "Y_Point1=${Y_Point1} Y_Point5=${Y_Point5}" - puts "Z_Point1=${Z_Point1} Z_Point5=${Z_Point5}" - puts "Get a value of TDataStd_Point attribute from restoring document: Error" - return -} -puts "Get a value of TDataStd_Point attribute from restoring document: OK" diff --git a/tests/caf/basic/H1 b/tests/caf/basic/H1 deleted file mode 100755 index af8b66fd94..0000000000 --- a/tests/caf/basic/H1 +++ /dev/null @@ -1,89 +0,0 @@ -#INTERFACE CAF -# Basic attributes -# -# Testing attribute: TDataStd_Axis -# -# Testing command: SetAxis -# Testing command: GetAxis -# - -puts "caf001-H1" - -set aTokList { :,} - -# Add an attribute to a data framework -set aSetX1 10 -set aSetY1 20 -set aSetZ1 30 -set aSetDX1 100 -set aSetDY1 200 -set aSetDZ1 300 -line aLine1 ${aSetX1} ${aSetY1} ${aSetZ1} ${aSetDX1} ${aSetDY1} ${aSetDZ1} - -set aDumpLine1 [dump aLine1] - -# [llength ${aDumpLine1}] = 14 -# Format of ${aDumpLine1}: -# *********** Dump of aLine1 ************* -# Line -# Origin :10, 20, 30 -# Axis :0.267261241912424, 0.534522483824849, 0.801783725737273 - -set anOriginX_Line1 [lindex [split [lindex ${aDumpLine1} 7] ${aTokList}] 1] -set anOriginY_Line1 [lindex [split [lindex ${aDumpLine1} 8] ${aTokList}] 0] -set anOriginZ_Line1 [lindex [split [lindex ${aDumpLine1} 9] ${aTokList}] 0] -set anAxisDX_Line1 [lindex [split [lindex ${aDumpLine1} 11] ${aTokList}] 1] -set anAxisDY_Line1 [lindex [split [lindex ${aDumpLine1} 12] ${aTokList}] 0] -set anAxisDZ_Line1 [lindex [split [lindex ${aDumpLine1} 13] ${aTokList}] 0] - -set aLabel 0:2 -SetAxis D ${aLabel} aLine1 - -# Close/Open the transaction -NewCommand D - -# Forget the attribute -ForgetAll D ${aLabel} - -# Close/Open the transaction -NewCommand D - -# Undo-Redo-Undo -Undo D -Redo D -Undo D - -# Get a value of the attribute -GetAxis D ${aLabel} anAxis1 - -# [llength ${aDumpAxis1}] = 14 -# Format of ${aDumpAxis1}: -# *********** Dump of anAxis1 ************* -# Line -# Origin :10, 20, 30 -# Axis :0.267261241912424, 0.534522483824849, 0.801783725737273 - -set aDumpAxis1 [dump anAxis1] -set anOriginX_Axis1 [lindex [split [lindex ${aDumpAxis1} 7] ${aTokList}] 1] -set anOriginY_Axis1 [lindex [split [lindex ${aDumpAxis1} 8] ${aTokList}] 0] -set anOriginZ_Axis1 [lindex [split [lindex ${aDumpAxis1} 9] ${aTokList}] 0] -set anAxisDX_Axis1 [lindex [split [lindex ${aDumpAxis1} 11] ${aTokList}] 1] -set anAxisDY_Axis1 [lindex [split [lindex ${aDumpAxis1} 12] ${aTokList}] 0] -set anAxisDZ_Axis1 [lindex [split [lindex ${aDumpAxis1} 13] ${aTokList}] 0] - -if { ${anOriginX_Line1} != ${anOriginX_Axis1} || - ${anOriginY_Line1} != ${anOriginY_Axis1} || - ${anOriginZ_Line1} != ${anOriginZ_Axis1} || - ${anAxisDX_Line1} != ${anAxisDX_Axis1} || - ${anAxisDY_Line1} != ${anAxisDY_Axis1} || - ${anAxisDZ_Line1} != ${anAxisDZ_Axis1} } { - puts "anOriginX_Line1=${anOriginX_Line1} anOriginX_Axis1=${anOriginX_Axis1}" - puts "anOriginY_Line1=${anOriginY_Line1} anOriginY_Axis1=${anOriginY_Axis1}" - puts "anOriginZ_Line1=${anOriginZ_Line1} anOriginZ_Axis1=${anOriginZ_Axis1}" - puts "anAxisDX_Line1=${anAxisDX_Line1} anAxisDX_Axis1=${anAxisDX_Axis1}" - puts "anAxisDY_Line1=${anAxisDY_Line1} anAxisDY_Axis1=${anAxisDY_Axis1}" - puts "anAxisDZ_Line1=${anAxisDZ_Line1} anAxisDZ_Axis1=${anAxisDZ_Axis1}" - puts "Add TDataStd_Axis attribute: Error" - return -} -puts "Add TDataStd_Axis attribute: OK" diff --git a/tests/caf/basic/H2 b/tests/caf/basic/H2 deleted file mode 100755 index c2798ce0cd..0000000000 --- a/tests/caf/basic/H2 +++ /dev/null @@ -1,87 +0,0 @@ -#INTERFACE CAF -# Basic attributes -# -# Testing attribute: TDataStd_Axis -# -# Testing command: SetAxis -# Testing command: GetAxis -# - -puts "caf001-H2" - -set aTokList { :,} - -# Add an attribute to a data framework -set aSetX1 10 -set aSetY1 20 -set aSetZ1 30 -set aSetDX1 100 -set aSetDY1 200 -set aSetDZ1 300 -line aLine1 ${aSetX1} ${aSetY1} ${aSetZ1} ${aSetDX1} ${aSetDY1} ${aSetDZ1} - -set aDumpLine1 [dump aLine1] - -# [llength ${aDumpLine1}] = 14 -# Format of ${aDumpLine1}: -# *********** Dump of aLine1 ************* -# Line -# Origin :10, 20, 30 -# Axis :0.267261241912424, 0.534522483824849, 0.801783725737273 - -set anOriginX_Line1 [lindex [split [lindex ${aDumpLine1} 7] ${aTokList}] 1] -set anOriginY_Line1 [lindex [split [lindex ${aDumpLine1} 8] ${aTokList}] 0] -set anOriginZ_Line1 [lindex [split [lindex ${aDumpLine1} 9] ${aTokList}] 0] -set anAxisDX_Line1 [lindex [split [lindex ${aDumpLine1} 11] ${aTokList}] 1] -set anAxisDY_Line1 [lindex [split [lindex ${aDumpLine1} 12] ${aTokList}] 0] -set anAxisDZ_Line1 [lindex [split [lindex ${aDumpLine1} 13] ${aTokList}] 0] - -set aLabel 0:2 -SetAxis D ${aLabel} aLine1 - -# Close/Open the transaction -NewCommand D - -# Set a new value of the attribute -set aSetX2 -10 -set aSetY2 -20 -set aSetZ2 -30 -set aSetDX2 -100 -set aSetDY2 200 -set aSetDZ2 300 -line aLine2 ${aSetX2} ${aSetY2} ${aSetZ2} ${aSetDX2} ${aSetDY2} ${aSetDZ2} -SetAxis D ${aLabel} aLine2 - -# Close/Open the transaction -NewCommand D - -# Undo -Undo D - -# Get a value of the attribute -GetAxis D ${aLabel} anAxis2 - -set aDumpAxis2 [dump anAxis2] -set anOriginX_Axis2 [lindex [split [lindex ${aDumpAxis2} 7] ${aTokList}] 1] -set anOriginY_Axis2 [lindex [split [lindex ${aDumpAxis2} 8] ${aTokList}] 0] -set anOriginZ_Axis2 [lindex [split [lindex ${aDumpAxis2} 9] ${aTokList}] 0] -set anAxisDX_Axis2 [lindex [split [lindex ${aDumpAxis2} 11] ${aTokList}] 1] -set anAxisDY_Axis2 [lindex [split [lindex ${aDumpAxis2} 12] ${aTokList}] 0] -set anAxisDZ_Axis2 [lindex [split [lindex ${aDumpAxis2} 13] ${aTokList}] 0] - -if { ${anOriginX_Line1} != ${anOriginX_Axis2} || - ${anOriginY_Line1} != ${anOriginY_Axis2} || - ${anOriginZ_Line1} != ${anOriginZ_Axis2} || - ${anAxisDX_Line1} != ${anAxisDX_Axis2} || - ${anAxisDY_Line1} != ${anAxisDY_Axis2} || - ${anAxisDZ_Line1} != ${anAxisDZ_Axis2} } { - puts "anOriginX_Line1=${anOriginX_Line1} anOriginX_Axis2=${anOriginX_Axis2}" - puts "anOriginY_Line1=${anOriginY_Line1} anOriginY_Axis2=${anOriginY_Axis2}" - puts "anOriginZ_Line1=${anOriginZ_Line1} anOriginZ_Axis2=${anOriginZ_Axis2}" - puts "anAxisDX_Line1=${anAxisDX_Line1} anAxisDX_Axis2=${anAxisDX_Axis2}" - puts "anAxisDY_Line1=${anAxisDY_Line1} anAxisDY_Axis2=${anAxisDY_Axis2}" - puts "anAxisDZ_Line1=${anAxisDZ_Line1} anAxisDZ_Axis2=${anAxisDZ_Axis2}" - puts "Set a value of TDataStd_Axis attribute: Error" - return -} -puts "Set a value of TDataStd_Axis attribute: OK" diff --git a/tests/caf/basic/H3 b/tests/caf/basic/H3 deleted file mode 100755 index 16e76f2762..0000000000 --- a/tests/caf/basic/H3 +++ /dev/null @@ -1,90 +0,0 @@ -#INTERFACE CAF -# Basic attributes -# -# Testing attribute: TDataStd_Axis -# -# Testing command: SetAxis -# Testing command: GetAxis -# - -puts "caf001-H3" - -set aTokList { :,} - -# Add an attribute to a data framework -set aSetX1 10 -set aSetY1 20 -set aSetZ1 30 -set aSetDX1 100 -set aSetDY1 200 -set aSetDZ1 300 -line aLine1 ${aSetX1} ${aSetY1} ${aSetZ1} ${aSetDX1} ${aSetDY1} ${aSetDZ1} - -set aDumpLine1 [dump aLine1] - -# [llength ${aDumpLine1}] = 14 -# Format of ${aDumpLine1}: -# *********** Dump of aLine1 ************* -# Line -# Origin :10, 20, 30 -# Axis :0.267261241912424, 0.534522483824849, 0.801783725737273 - -set anOriginX_Line1 [lindex [split [lindex ${aDumpLine1} 7] ${aTokList}] 1] -set anOriginY_Line1 [lindex [split [lindex ${aDumpLine1} 8] ${aTokList}] 0] -set anOriginZ_Line1 [lindex [split [lindex ${aDumpLine1} 9] ${aTokList}] 0] -set anAxisDX_Line1 [lindex [split [lindex ${aDumpLine1} 11] ${aTokList}] 1] -set anAxisDY_Line1 [lindex [split [lindex ${aDumpLine1} 12] ${aTokList}] 0] -set anAxisDZ_Line1 [lindex [split [lindex ${aDumpLine1} 13] ${aTokList}] 0] - -set aLabel 0:2 -SetAxis D ${aLabel} aLine1 - -# Close/Open the transaction -NewCommand D - -# Save the document -set aFile ${imagedir}/caf001-H3.cbf -file delete ${aFile} -SaveAs D ${aFile} -if { ![file exists ${aFile}] } { - puts "There is not ${aFile} file; SaveAs command: Error" - return -} -#catch {exec chmod 777 ${aFile}} - -# Restore the document -Close D -Open ${aFile} DD - -# Get a value of the attribute -set IsDone [catch {GetAxis DD ${aLabel} anAxis3} aResult] -if { ${IsDone} != 0 } { - puts ${aResult} - puts "Get a value of TDataStd_Axis attribute from restoring document: Error" - return -} - -set aDumpAxis3 [dump anAxis3] -set anOriginX_Axis3 [lindex [split [lindex ${aDumpAxis3} 7] ${aTokList}] 1] -set anOriginY_Axis3 [lindex [split [lindex ${aDumpAxis3} 8] ${aTokList}] 0] -set anOriginZ_Axis3 [lindex [split [lindex ${aDumpAxis3} 9] ${aTokList}] 0] -set anAxisDX_Axis3 [lindex [split [lindex ${aDumpAxis3} 11] ${aTokList}] 1] -set anAxisDY_Axis3 [lindex [split [lindex ${aDumpAxis3} 12] ${aTokList}] 0] -set anAxisDZ_Axis3 [lindex [split [lindex ${aDumpAxis3} 13] ${aTokList}] 0] - -if { ${anOriginX_Line1} != ${anOriginX_Axis3} || - ${anOriginY_Line1} != ${anOriginY_Axis3} || - ${anOriginZ_Line1} != ${anOriginZ_Axis3} || - ${anAxisDX_Line1} != ${anAxisDX_Axis3} || - ${anAxisDY_Line1} != ${anAxisDY_Axis3} || - ${anAxisDZ_Line1} != ${anAxisDZ_Axis3} } { - puts "anOriginX_Line1=${anOriginX_Line1} anOriginX_Axis3=${anOriginX_Axis3}" - puts "anOriginY_Line1=${anOriginY_Line1} anOriginY_Axis3=${anOriginY_Axis3}" - puts "anOriginZ_Line1=${anOriginZ_Line1} anOriginZ_Axis3=${anOriginZ_Axis3}" - puts "anAxisDX_Line1=${anAxisDX_Line1} anAxisDX_Axis3=${anAxisDX_Axis3}" - puts "anAxisDY_Line1=${anAxisDY_Line1} anAxisDY_Axis3=${anAxisDY_Axis3}" - puts "anAxisDZ_Line1=${anAxisDZ_Line1} anAxisDZ_Axis3=${anAxisDZ_Axis3}" - puts "Get a value of TDataStd_Axis attribute from restoring document: Error" - return -} -puts "Get a value of TDataStd_Axis attribute from restoring document: OK" diff --git a/tests/caf/basic/I1 b/tests/caf/basic/I1 deleted file mode 100755 index 81de56dcac..0000000000 --- a/tests/caf/basic/I1 +++ /dev/null @@ -1,85 +0,0 @@ -#INTERFACE CAF -# Basic attributes -# -# Testing attribute: TDataStd_Plane -# -# Testing command: SetPlane -# Testing command: GetPlane -# - -puts "caf001-I1" - -set aTokList { :,} - -# Add an attribute to a data framework -set aSetX1 10 -set aSetY1 20 -set aSetZ1 30 -set aSetDX1 -1 -set aSetDY1 0 -set aSetDZ1 0 - -plane aPlane1 ${aSetX1} ${aSetY1} ${aSetZ1} ${aSetDX1} ${aSetDY1} ${aSetDZ1} - -set aDumpPlane1 [dump aPlane1] - -# [llength ${aDumpPlane1}] = 22 -# Format of ${aDumpPlane1}: -# *********** Dump of aPlane1 ************* -# Plane -# Origin :10, 20, 30 -# Axis :-1, 0, 0 -# XAxis :-0, 0, -1 -# YAxis :-0, -1, 0 - -set anOriginX_Plane1 [lindex [split [lindex ${aDumpPlane1} 7] ${aTokList}] 1] -set anOriginY_Plane1 [lindex [split [lindex ${aDumpPlane1} 8] ${aTokList}] 0] -set anOriginZ_Plane1 [lindex [split [lindex ${aDumpPlane1} 9] ${aTokList}] 0] -set anAxisDX_Plane1 [lindex [split [lindex ${aDumpPlane1} 11] ${aTokList}] 1] -set anAxisDY_Plane1 [lindex [split [lindex ${aDumpPlane1} 12] ${aTokList}] 0] -set anAxisDZ_Plane1 [lindex [split [lindex ${aDumpPlane1} 13] ${aTokList}] 0] - -set aLabel 0:2 -SetPlane D ${aLabel} aPlane1 - -# Close/Open the transaction -NewCommand D - -# Forget the attribute -ForgetAll D ${aLabel} - -# Close/Open the transaction -NewCommand D - -# Undo-Redo-Undo -Undo D -Redo D -Undo D - -# Get a value of the attribute -GetPlane D ${aLabel} aPlane2 - -set aDumpPlane2 [dump aPlane2] -set anOriginX_Plane2 [lindex [split [lindex ${aDumpPlane2} 7] ${aTokList}] 1] -set anOriginY_Plane2 [lindex [split [lindex ${aDumpPlane2} 8] ${aTokList}] 0] -set anOriginZ_Plane2 [lindex [split [lindex ${aDumpPlane2} 9] ${aTokList}] 0] -set anAxisDX_Plane2 [lindex [split [lindex ${aDumpPlane2} 11] ${aTokList}] 1] -set anAxisDY_Plane2 [lindex [split [lindex ${aDumpPlane2} 12] ${aTokList}] 0] -set anAxisDZ_Plane2 [lindex [split [lindex ${aDumpPlane2} 13] ${aTokList}] 0] - -if { ${anOriginX_Plane1} != ${anOriginX_Plane2} || - ${anOriginY_Plane1} != ${anOriginY_Plane2} || - ${anOriginZ_Plane1} != ${anOriginZ_Plane2} || - ${anAxisDX_Plane1} != ${anAxisDX_Plane2} || - ${anAxisDY_Plane1} != ${anAxisDY_Plane2} || - ${anAxisDZ_Plane1} != ${anAxisDZ_Plane2} } { - puts "anOriginX_Plane1=${anOriginX_Plane1} anOriginX_Plane2=${anOriginX_Plane2}" - puts "anOriginY_Plane1=${anOriginY_Plane1} anOriginY_Plane2=${anOriginY_Plane2}" - puts "anOriginZ_Plane1=${anOriginZ_Plane1} anOriginZ_Plane2=${anOriginZ_Plane2}" - puts "anAxisDX_Plane1=${anAxisDX_Plane1} anAxisDX_Plane2=${anAxisDX_Plane2}" - puts "anAxisDY_Plane1=${anAxisDY_Plane1} anAxisDY_Plane2=${anAxisDY_Plane2}" - puts "anAxisDZ_Plane1=${anAxisDZ_Plane1} anAxisDZ_Plane2=${anAxisDZ_Plane2}" - puts "Add TDataStd_Plane attribute: Error" - return -} -puts "Add TDataStd_Plane attribute: OK" diff --git a/tests/caf/basic/I2 b/tests/caf/basic/I2 deleted file mode 100755 index e6b712330e..0000000000 --- a/tests/caf/basic/I2 +++ /dev/null @@ -1,90 +0,0 @@ -#INTERFACE CAF -# Basic attributes -# -# Testing attribute: TDataStd_Plane -# -# Testing command: SetPlane -# Testing command: GetPlane -# - -puts "caf001-I2" - -set aTokList { :,} - -# Add an attribute to a data framework -set aSetX1 10 -set aSetY1 20 -set aSetZ1 30 -set aSetDX1 -1 -set aSetDY1 0 -set aSetDZ1 0 - -plane aPlane1 ${aSetX1} ${aSetY1} ${aSetZ1} ${aSetDX1} ${aSetDY1} ${aSetDZ1} - -set aDumpPlane1 [dump aPlane1] - -# [llength ${aDumpPlane1}] = 22 -# Format of ${aDumpPlane1}: -# *********** Dump of aPlane1 ************* -# Plane -# Origin :10, 20, 30 -# Axis :-1, 0, 0 -# XAxis :-0, 0, -1 -# YAxis :-0, -1, 0 - -set anOriginX_Plane1 [lindex [split [lindex ${aDumpPlane1} 7] ${aTokList}] 1] -set anOriginY_Plane1 [lindex [split [lindex ${aDumpPlane1} 8] ${aTokList}] 0] -set anOriginZ_Plane1 [lindex [split [lindex ${aDumpPlane1} 9] ${aTokList}] 0] -set anAxisDX_Plane1 [lindex [split [lindex ${aDumpPlane1} 11] ${aTokList}] 1] -set anAxisDY_Plane1 [lindex [split [lindex ${aDumpPlane1} 12] ${aTokList}] 0] -set anAxisDZ_Plane1 [lindex [split [lindex ${aDumpPlane1} 13] ${aTokList}] 0] - -set aLabel 0:2 -SetPlane D ${aLabel} aPlane1 - -# Close/Open the transaction -NewCommand D - -# Set a new value of the attribute -set aSetX2 -10 -set aSetY2 -20 -set aSetZ2 -30 -set aSetDX2 0 -set aSetDY2 -1 -set aSetDZ2 0 -plane aPlane3 ${aSetX2} ${aSetY2} ${aSetZ2} ${aSetDX2} ${aSetDY2} ${aSetDZ2} -SetPlane D ${aLabel} aPlane3 - -# Close/Open the transaction -NewCommand D - -# Undo -Undo D - -# Get a value of the attribute -GetPlane D ${aLabel} aPlane4 - -set aDumpPlane4 [dump aPlane4] -set anOriginX_Plane4 [lindex [split [lindex ${aDumpPlane4} 7] ${aTokList}] 1] -set anOriginY_Plane4 [lindex [split [lindex ${aDumpPlane4} 8] ${aTokList}] 0] -set anOriginZ_Plane4 [lindex [split [lindex ${aDumpPlane4} 9] ${aTokList}] 0] -set anAxisDX_Plane4 [lindex [split [lindex ${aDumpPlane4} 11] ${aTokList}] 1] -set anAxisDY_Plane4 [lindex [split [lindex ${aDumpPlane4} 12] ${aTokList}] 0] -set anAxisDZ_Plane4 [lindex [split [lindex ${aDumpPlane4} 13] ${aTokList}] 0] - -if { ${anOriginX_Plane1} != ${anOriginX_Plane4} || - ${anOriginY_Plane1} != ${anOriginY_Plane4} || - ${anOriginZ_Plane1} != ${anOriginZ_Plane4} || - ${anAxisDX_Plane1} != ${anAxisDX_Plane4} || - ${anAxisDY_Plane1} != ${anAxisDY_Plane4} || - ${anAxisDZ_Plane1} != ${anAxisDZ_Plane4} } { - puts "anOriginX_Plane1=${anOriginX_Plane1} anOriginX_Plane4=${anOriginX_Plane4}" - puts "anOriginY_Plane1=${anOriginY_Plane1} anOriginY_Plane4=${anOriginY_Plane4}" - puts "anOriginZ_Plane1=${anOriginZ_Plane1} anOriginZ_Plane4=${anOriginZ_Plane4}" - puts "anAxisDX_Plane1=${anAxisDX_Plane1} anAxisDX_Plane4=${anAxisDX_Plane4}" - puts "anAxisDY_Plane1=${anAxisDY_Plane1} anAxisDY_Plane4=${anAxisDY_Plane4}" - puts "anAxisDZ_Plane1=${anAxisDZ_Plane1} anAxisDZ_Plane4=${anAxisDZ_Plane4}" - puts "Set a value of TDataStd_Plane attribute: Error" - return -} -puts "Set a value of TDataStd_Plane attribute: OK" diff --git a/tests/caf/basic/I3 b/tests/caf/basic/I3 deleted file mode 100755 index 71b77e121f..0000000000 --- a/tests/caf/basic/I3 +++ /dev/null @@ -1,93 +0,0 @@ -#INTERFACE CAF -# Basic attributes -# -# Testing attribute: TDataStd_Plane -# -# Testing command: SetPlane -# Testing command: GetPlane -# - -puts "caf001-I3" - -set aTokList { :,} - -# Add an attribute to a data framework -set aSetX1 10 -set aSetY1 20 -set aSetZ1 30 -set aSetDX1 -1 -set aSetDY1 0 -set aSetDZ1 0 - -plane aPlane1 ${aSetX1} ${aSetY1} ${aSetZ1} ${aSetDX1} ${aSetDY1} ${aSetDZ1} - -set aDumpPlane1 [dump aPlane1] - -# [llength ${aDumpPlane1}] = 22 -# Format of ${aDumpPlane1}: -# *********** Dump of aPlane1 ************* -# Plane -# Origin :10, 20, 30 -# Axis :-1, 0, 0 -# XAxis :-0, 0, -1 -# YAxis :-0, -1, 0 - -set anOriginX_Plane1 [lindex [split [lindex ${aDumpPlane1} 7] ${aTokList}] 1] -set anOriginY_Plane1 [lindex [split [lindex ${aDumpPlane1} 8] ${aTokList}] 0] -set anOriginZ_Plane1 [lindex [split [lindex ${aDumpPlane1} 9] ${aTokList}] 0] -set anAxisDX_Plane1 [lindex [split [lindex ${aDumpPlane1} 11] ${aTokList}] 1] -set anAxisDY_Plane1 [lindex [split [lindex ${aDumpPlane1} 12] ${aTokList}] 0] -set anAxisDZ_Plane1 [lindex [split [lindex ${aDumpPlane1} 13] ${aTokList}] 0] - -set aLabel 0:2 -SetPlane D ${aLabel} aPlane1 - -# Close/Open the transaction -NewCommand D - -# Save the document -set aFile ${imagedir}/caf001-I3.cbf -file delete ${aFile} -SaveAs D ${aFile} -if { ![file exists ${aFile}] } { - puts "There is not ${aFile} file; SaveAs command: Error" - return -} -#catch {exec chmod 777 ${aFile}} - -# Restore the document -Close D -Open ${aFile} DD - -# Get a value of the attribute -set IsDone [catch {GetPlane DD ${aLabel} aPlane5} aResult] -if { ${IsDone} != 0 } { - puts ${aResult} - puts "Get a value of TDataStd_Plane attribute from restoring document: Error" - return -} - -set aDumpPlane5 [dump aPlane5] -set anOriginX_Plane5 [lindex [split [lindex ${aDumpPlane5} 7] ${aTokList}] 1] -set anOriginY_Plane5 [lindex [split [lindex ${aDumpPlane5} 8] ${aTokList}] 0] -set anOriginZ_Plane5 [lindex [split [lindex ${aDumpPlane5} 9] ${aTokList}] 0] -set anAxisDX_Plane5 [lindex [split [lindex ${aDumpPlane5} 11] ${aTokList}] 1] -set anAxisDY_Plane5 [lindex [split [lindex ${aDumpPlane5} 12] ${aTokList}] 0] -set anAxisDZ_Plane5 [lindex [split [lindex ${aDumpPlane5} 13] ${aTokList}] 0] - -if { ${anOriginX_Plane1} != ${anOriginX_Plane5} || - ${anOriginY_Plane1} != ${anOriginY_Plane5} || - ${anOriginZ_Plane1} != ${anOriginZ_Plane5} || - ${anAxisDX_Plane1} != ${anAxisDX_Plane5} || - ${anAxisDY_Plane1} != ${anAxisDY_Plane5} || - ${anAxisDZ_Plane1} != ${anAxisDZ_Plane5} } { - puts "anOriginX_Plane1=${anOriginX_Plane1} anOriginX_Plane5=${anOriginX_Plane5}" - puts "anOriginY_Plane1=${anOriginY_Plane1} anOriginY_Plane5=${anOriginY_Plane5}" - puts "anOriginZ_Plane1=${anOriginZ_Plane1} anOriginZ_Plane5=${anOriginZ_Plane5}" - puts "anAxisDX_Plane1=${anAxisDX_Plane1} anAxisDX_Plane5=${anAxisDX_Plane5}" - puts "anAxisDY_Plane1=${anAxisDY_Plane1} anAxisDY_Plane5=${anAxisDY_Plane5}" - puts "anAxisDZ_Plane1=${anAxisDZ_Plane1} anAxisDZ_Plane5=${anAxisDZ_Plane5}" - puts "Get a value of TDataStd_Plane attribute from restoring document: Error" - return -} -puts "Get a value of TDataStd_Plane attribute from restoring document: OK" diff --git a/tests/caf/basic/J1 b/tests/caf/basic/J1 deleted file mode 100755 index a25dc4e6a5..0000000000 --- a/tests/caf/basic/J1 +++ /dev/null @@ -1,39 +0,0 @@ -#INTERFACE CAF -# Basic attributes -# -# Testing attribute: TDataStd_UAttribute -# -# Testing command: SetUAttribute -# Testing command: GetUAttribute -# - -puts "caf001-J1" - -# Add an attribute to a data framework -set aSetAttr1 "c73bd075-22ee-11d2-acde-080009dc4422" -set aLabel 0:2 -SetUAttribute D ${aLabel} ${aSetAttr1} - -# Close/Open the transaction -NewCommand D - -# Forget the attribute -ForgetAll D ${aLabel} - -# Close/Open the transaction -NewCommand D - -# Undo-Redo-Undo -Undo D -Redo D -Undo D - -# Get a value of the attribute -set aGetAttr1 [GetUAttribute D ${aLabel} ${aSetAttr1}] -if { ${aSetAttr1} != ${aGetAttr1} } { - puts "aSetAttr1=${aSetAttr1}" - puts "aGetAttr1=${aGetAttr1}" - puts "Add TDataStd_UAttribute attribute: Error" - return -} -puts "Add TDataStd_UAttribute attribute: OK" diff --git a/tests/caf/basic/J2 b/tests/caf/basic/J2 deleted file mode 100755 index 73f3f0ae11..0000000000 --- a/tests/caf/basic/J2 +++ /dev/null @@ -1,38 +0,0 @@ -#INTERFACE CAF -# Basic attributes -# -# Testing attribute: TDataStd_UAttribute -# -# Testing command: SetUAttribute -# Testing command: GetUAttribute -# - -puts "caf001-J2" - -# Add an attribute to a data framework -set aSetAttr1 "c73bd075-22ee-11d2-acde-080009dc4422" -set aLabel 0:2 -SetUAttribute D ${aLabel} ${aSetAttr1} - -# Close/Open the transaction -NewCommand D - -# Set a new value of the attribute -set aSetAttr2 "425a8e02-8934-11d2-b3f0-0060b0f1d69e" -SetUAttribute D ${aLabel} ${aSetAttr2} - -# Close/Open the transaction -NewCommand D - -# Undo -Undo D - -# Get a value of the attribute -set aGetAttr2 [GetUAttribute D ${aLabel} ${aSetAttr1}] -if { ${aSetAttr1}!=${aGetAttr2} } { - puts "aSetAttr1=${aSetAttr1}" - puts "aGetAttr2=${aGetAttr2}" - puts "Set a value of TDataStd_UAttribute attribute: Error" - return -} -puts "Set a value of TDataStd_UAttribute attribute: OK" diff --git a/tests/caf/basic/J3 b/tests/caf/basic/J3 deleted file mode 100755 index 9c6c9037f1..0000000000 --- a/tests/caf/basic/J3 +++ /dev/null @@ -1,49 +0,0 @@ -#INTERFACE CAF -# Basic attributes -# -# Testing attribute: TDataStd_UAttribute -# -# Testing command: SetUAttribute -# Testing command: GetUAttribute -# - -puts "caf001-J3" - -# Add an attribute to a data framework -set aSetAttr1 "c73bd075-22ee-11d2-acde-080009dc4422" -set aLabel 0:2 -SetUAttribute D ${aLabel} ${aSetAttr1} - -# Close/Open the transaction -NewCommand D - -# Save the document -set aFile ${imagedir}/caf001-J3.cbf -file delete ${aFile} -SaveAs D ${aFile} -if { ![file exists ${aFile}] } { - puts "There is not ${aFile} file; SaveAs command: Error" - return -} -#catch {exec chmod 777 ${aFile}} - -# Restore the document -Close D -Open ${aFile} DD - -# Get a value of the attribute -set IsDone [catch {GetUAttribute DD ${aLabel} ${aSetAttr1}} aResult] -if { ${IsDone} != 0 } { - puts ${aResult} - puts "Get a value of TDataStd_UAttribute attribute from restoring document: Error" - return -} -set aGetAttr3 [GetUAttribute DD ${aLabel} ${aSetAttr1}] - -if { ${aSetAttr1}!=${aGetAttr3} } { - puts "aSetAttr1=${aSetAttr1}" - puts "aGetAttr3=${aGetAttr3}" - puts "Get a value of TDataStd_UAttribute attribute from restoring document: Error" - return -} -puts "Get a value of TDataStd_UAttribute attribute from restoring document: OK" diff --git a/tests/caf/basic/J4 b/tests/caf/basic/J4 deleted file mode 100755 index 0667548cee..0000000000 --- a/tests/caf/basic/J4 +++ /dev/null @@ -1,55 +0,0 @@ -#INTERFACE CAF -# Basic attributes -# -# Testing attribute: TDataStd_UAttribute -# -# Testing command: SetUAttribute -# Testing command: GetUAttribute -# - -puts "caf001-J4" - -# Add an attribute to a data framework -set aSetAttr1 "c73bd075-22ee-11d2-acde-080009dc4422" -set aLabel 0:2 -SetUAttribute D ${aLabel} ${aSetAttr1} - -# Add new ID to a label -set aSetAttr2 "c73bd076-22ee-11d2-acde-080009dc4422" -SetUAttribute D ${aLabel} ${aSetAttr2} - -# Close/Open the transaction -NewCommand D - -# Forget the attribute -ForgetAll D ${aLabel} - -# Close/Open the transaction -NewCommand D - -# Undo-Redo-Undo -Undo D -Redo D -Undo D - -# Get a value of the attribute -set aGetAttr1 [GetUAttribute D ${aLabel} ${aSetAttr1}] -if { ${aSetAttr1} != ${aGetAttr1} } { - puts "First ID:" - puts "aSetAttr1=${aSetAttr1}" - puts "aGetAttr1=${aGetAttr1}" - puts "Add TDataStd_UAttribute attribute: Error" - return -} - -# Get a value of the attribute -set aGetAttr2 [GetUAttribute D ${aLabel} ${aSetAttr2}] -if { ${aSetAttr2} != ${aGetAttr2} } { - puts "Second ID:" - puts "aSetAttr2=${aSetAttr2}" - puts "aGetAttr2=${aGetAttr2}" - puts "Add TDataStd_UAttribute attribute: Error" - return -} - -puts "Add TDataStd_UAttribute attribute: OK" diff --git a/tests/caf/basic/J5 b/tests/caf/basic/J5 deleted file mode 100755 index 2792491142..0000000000 --- a/tests/caf/basic/J5 +++ /dev/null @@ -1,52 +0,0 @@ -#INTERFACE CAF -# Basic attributes -# -# Testing attribute: TDataStd_UAttribute -# -# Testing command: SetUAttribute -# Testing command: GetUAttribute -# Testing command: CopyLabel -# - -puts "caf001-J5" - -# Add an attribute to a data framework -set aSetAttr1 "c73bd075-22ee-11d2-acde-080009dc4422" -set aLabel 0:2 -SetUAttribute D ${aLabel} ${aSetAttr1} - -# Add new ID to a label -set aSetAttr2 "c73bd076-22ee-11d2-acde-080009dc4422" -SetUAttribute D ${aLabel} ${aSetAttr2} - -# Close/Open the transaction -NewCommand D - -# Copy aLabel to new label -set aTargetLabel 0:3 -CopyLabel D ${aLabel} ${aTargetLabel} - -# Close/Open the transaction -NewCommand D - -# Get a value of the attribute -set aGetAttr1 [GetUAttribute D ${aTargetLabel} ${aSetAttr1}] -if { ${aSetAttr1} != ${aGetAttr1} } { - puts "First ID:" - puts "aSetAttr1=${aSetAttr1}" - puts "aGetAttr1=${aGetAttr1}" - puts "Copy TDataStd_UAttribute attribute: Error" - return -} - -# Get a value of the attribute -set aGetAttr2 [GetUAttribute D ${aTargetLabel} ${aSetAttr2}] -if { ${aSetAttr2} != ${aGetAttr2} } { - puts "Second ID:" - puts "aSetAttr2=${aSetAttr2}" - puts "aGetAttr2=${aGetAttr2}" - puts "Copy TDataStd_UAttribute attribute: Error" - return -} - -puts "Copy TDataStd_UAttribute attribute: OK" diff --git a/tests/caf/basic/J6 b/tests/caf/basic/J6 deleted file mode 100755 index 3f9722ac42..0000000000 --- a/tests/caf/basic/J6 +++ /dev/null @@ -1,70 +0,0 @@ -#INTERFACE CAF -# Basic attributes -# -# Testing attribute: TDataStd_UAttribute -# -# Testing command: SetUAttribute -# Testing command: GetUAttribute -# - -puts "caf001-J6" - -# Add an attribute to a data framework -set aSetAttr1 "c73bd075-22ee-11d2-acde-080009dc4422" -set aLabel 0:2 -SetUAttribute D ${aLabel} ${aSetAttr1} -set aGetAttr1 [GetUAttribute D ${aLabel} ${aSetAttr1}] - -# Add new ID to a label -set aSetAttr2 "c73bd076-22ee-11d2-acde-080009dc4422" -SetUAttribute D ${aLabel} ${aSetAttr2} -set aGetAttr2 [GetUAttribute D ${aLabel} ${aSetAttr2}] - -# Close/Open the transaction -NewCommand D - -# Save the document -set aFile ${imagedir}/caf001-J6.cbf -file delete ${aFile} -SaveAs D ${aFile} -if { ![file exists ${aFile}] } { - puts "There is not ${aFile} file; SaveAs command: Error" - return -} -#catch {exec chmod 777 ${aFile}} - -# Restore the document -Close D -Open ${aFile} DD - -# Get a value of first ID -set IsDone [catch {GetUAttribute DD ${aLabel} ${aSetAttr1}} aResult] -if { ${IsDone} != 0 } { - puts ${aResult} - puts "Get a value of TDataStd_UAttribute attribute from restoring document: Error" - return -} -if { ${aSetAttr1}!=${aGetAttr1} } { - puts "First ID:" - puts "aSetAttr1=${aSetAttr1}" - puts "aGetAttr1=${aGetAttr1}" - puts "Get a value of TDataStd_UAttribute attribute from restoring document: Error" - return -} - -# Get a value of second ID -set IsDone [catch {GetUAttribute DD ${aLabel} ${aSetAttr2}} aResult] -if { ${IsDone} != 0 } { - puts ${aResult} - puts "Get a value of TDataStd_UAttribute attribute from restoring document: Error" - return -} -if { ${aSetAttr2}!=${aGetAttr2} } { - puts "Second ID:" - puts "aSetAttr2=${aSetAttr2}" - puts "aGetAttr2=${aGetAttr2}" - puts "Get a value of TDataStd_UAttribute attribute from restoring document: Error" - return -} - -puts "Get a value of TDataStd_UAttribute attribute from restoring document: OK" diff --git a/tests/caf/basic/K1 b/tests/caf/basic/K1 deleted file mode 100755 index 400f8f6a7f..0000000000 --- a/tests/caf/basic/K1 +++ /dev/null @@ -1,60 +0,0 @@ -#INTERFACE CAF -# Basic attributes -# -# Testing attribute: TDataStd_Shape -# -# Testing command: SetShape -# Testing command: GetShape -# - -puts "caf001-K1" - -# Add an attribute to a data framework -set aSetX1 10 -set aSetY1 20 -set aSetZ1 30 -set aSetDX1 100 -set aSetDY1 200 -set aSetDZ1 300 - -box aBox1 ${aSetX1} ${aSetY1} ${aSetZ1} ${aSetDX1} ${aSetDY1} ${aSetDZ1} -bounding aBox1 -save X1_Box1 Y1_Box1 Z1_Box1 X2_Box1 Y2_Box1 Z2_Box1 - -set aLabel 0:2 -SetShape D ${aLabel} aBox1 - -# Close/Open the transaction -NewCommand D - -# Forget the attribute -ForgetAll D ${aLabel} - -# Close/Open the transaction -NewCommand D - -# Undo-Redo-Undo -Undo D -Redo D -Undo D - -# Get a value of the attribute -GetShape D ${aLabel} aBox2 - -bounding aBox2 -save X1_Box2 Y1_Box2 Z1_Box2 X2_Box2 Y2_Box2 Z2_Box2 - -if { [dval X1_Box1] != [dval X1_Box2] || - [dval Y1_Box1] != [dval Y1_Box2] || - [dval Z1_Box1] != [dval Z1_Box2] || - [dval X2_Box1] != [dval X2_Box2] || - [dval Y2_Box1] != [dval Y2_Box2] || - [dval Z2_Box1] != [dval Z2_Box2] } { - puts "X1_Box1=[dval X1_Box1] X1_Box2=[dval X1_Box2]" - puts "Y1_Box1=[dval Y1_Box1] Y1_Box2=[dval Y1_Box2]" - puts "Z1_Box1=[dval Z1_Box1] Z1_Box2=[dval Z1_Box2]" - puts "X2_Box1=[dval X2_Box1] X2_Box2=[dval X2_Box2]" - puts "Y2_Box1=[dval Y2_Box1] Y2_Box2=[dval Y2_Box2]" - puts "Z2_Box1=[dval Z2_Box1] Z2_Box2=[dval Z2_Box2]" - puts "Add TDataStd_Shape attribute: Error" - return -} -puts "Add TDataStd_Shape attribute: OK" diff --git a/tests/caf/basic/K2 b/tests/caf/basic/K2 deleted file mode 100755 index 30dcaa6459..0000000000 --- a/tests/caf/basic/K2 +++ /dev/null @@ -1,65 +0,0 @@ -#INTERFACE CAF -# Basic attributes -# -# Testing attribute: TDataStd_Shape -# -# Testing command: SetShape -# Testing command: GetShape -# - -puts "caf001-K2" - -# Add an attribute to a data framework -set aSetX1 10 -set aSetY1 20 -set aSetZ1 30 -set aSetDX1 100 -set aSetDY1 200 -set aSetDZ1 300 - -box aBox1 ${aSetX1} ${aSetY1} ${aSetZ1} ${aSetDX1} ${aSetDY1} ${aSetDZ1} -bounding aBox1 -save X1_Box1 Y1_Box1 Z1_Box1 X2_Box1 Y2_Box1 Z2_Box1 - -set aLabel 0:2 -SetShape D ${aLabel} aBox1 - -# Close/Open the transaction -NewCommand D - -# Set a new value of the attribute -set aSetX2 -10 -set aSetY2 -20 -set aSetZ2 -30 -set aSetDX2 100 -set aSetDY2 200 -set aSetDZ2 300 -box aBox3 ${aSetX2} ${aSetY2} ${aSetZ2} ${aSetDX2} ${aSetDY2} ${aSetDZ2} - -SetShape D ${aLabel} aBox3 - -# Close/Open the transaction -NewCommand D - -# Undo -Undo D - -# Get a value of the attribute -GetShape D ${aLabel} aBox4 - -bounding aBox4 -save X1_Box4 Y1_Box4 Z1_Box4 X2_Box4 Y2_Box4 Z2_Box4 -if { [dval X1_Box1] != [dval X1_Box4] || - [dval Y1_Box1] != [dval Y1_Box4] || - [dval Z1_Box1] != [dval Z1_Box4] || - [dval X2_Box1] != [dval X2_Box4] || - [dval Y2_Box1] != [dval Y2_Box4] || - [dval Z2_Box1] != [dval Z2_Box4] } { - puts "X1_Box1=[dval X1_Box1] X1_Box4=[dval X1_Box4]" - puts "Y1_Box1=[dval Y1_Box1] Y1_Box4=[dval Y1_Box4]" - puts "Z1_Box1=[dval Z1_Box1] Z1_Box4=[dval Z1_Box4]" - puts "X2_Box1=[dval X2_Box1] X2_Box4=[dval X2_Box4]" - puts "Y2_Box1=[dval Y2_Box1] Y2_Box4=[dval Y2_Box4]" - puts "Z2_Box1=[dval Z2_Box1] Z2_Box4=[dval Z2_Box4]" - puts "Set a value of TDataStd_Shape attribute: Error" - return -} -puts "Set a value of TDataStd_Shape attribute: OK" diff --git a/tests/caf/basic/K3 b/tests/caf/basic/K3 deleted file mode 100755 index d0053a42df..0000000000 --- a/tests/caf/basic/K3 +++ /dev/null @@ -1,69 +0,0 @@ -#INTERFACE CAF -# Basic attributes -# -# Testing attribute: TDataStd_Shape -# -# Testing command: SetShape -# Testing command: GetShape -# - -puts "caf001-K3" - -# Add an attribute to a data framework -set aSetX1 10 -set aSetY1 20 -set aSetZ1 30 -set aSetDX1 100 -set aSetDY1 200 -set aSetDZ1 300 - -box aBox1 ${aSetX1} ${aSetY1} ${aSetZ1} ${aSetDX1} ${aSetDY1} ${aSetDZ1} - -bounding aBox1 -save X1_Box1 Y1_Box1 Z1_Box1 X2_Box1 Y2_Box1 Z2_Box1 - -set aLabel 0:2 -SetShape D ${aLabel} aBox1 - -# Close/Open the transaction -NewCommand D - -# Save the document -set aFile ${imagedir}/caf001-K3.cbf -file delete ${aFile} -SaveAs D ${aFile} -if { ![file exists ${aFile}] } { - puts "There is not ${aFile} file; SaveAs command: Error" - return -} -#catch {exec chmod 777 ${aFile}} - -# Restore the document -Close D -Open ${aFile} DD - -# Get a value of the attribute -set IsDone [catch {GetShape DD ${aLabel} aBox5} aResult] -if { ${IsDone} != 0 } { - puts ${aResult} - puts "Get a value of TDataStd_Shape attribute from restoring document: Error" - return -} - -bounding aBox5 -save X1_Box5 Y1_Box5 Z1_Box5 X2_Box5 Y2_Box5 Z2_Box5 - -if { [dval X1_Box1] != [dval X1_Box5] || - [dval Y1_Box1] != [dval Y1_Box5] || - [dval Z1_Box1] != [dval Z1_Box5] || - [dval X2_Box1] != [dval X2_Box5] || - [dval Y2_Box1] != [dval Y2_Box5] || - [dval Z2_Box1] != [dval Z2_Box5] } { - puts "X1_Box1=[dval X1_Box1] X1_Box5=[dval X1_Box5]" - puts "Y1_Box1=[dval Y1_Box1] Y1_Box5=[dval Y1_Box5]" - puts "Z1_Box1=[dval Z1_Box1] Z1_Box5=[dval Z1_Box5]" - puts "X2_Box1=[dval X2_Box1] X2_Box5=[dval X2_Box5]" - puts "Y2_Box1=[dval Y2_Box1] Y2_Box5=[dval Y2_Box5]" - puts "Z2_Box1=[dval Z2_Box1] Z2_Box5=[dval Z2_Box5]" - puts "Get a value of TDataStd_Shape attribute from restoring document: Error" - return -} -puts "Get a value of TDataStd_Shape attribute from restoring document: OK" diff --git a/tests/caf/basic/L1 b/tests/caf/basic/L1 deleted file mode 100755 index 63af975058..0000000000 --- a/tests/caf/basic/L1 +++ /dev/null @@ -1,49 +0,0 @@ -#INTERFACE CAF -# Basic attributes -# -# Testing attribute: TDF_Reference -# -# Testing command: SetReference -# Testing command: GetReference -# - -puts "caf001-L1" - -# Add an attribute to a data framework -set aSetAttr1 100 -set aSetAttr2 200 -set aSetAttr3 300 -set aLabel1 0:2 -set aLabel2 0:3 -set aLabel3 0:4 -set aLabel4 0:5 -SetInteger D ${aLabel1} ${aSetAttr1} -SetInteger D ${aLabel2} ${aSetAttr2} -SetInteger D ${aLabel3} ${aSetAttr3} - -set aReference1 ${aLabel2} -SetReference D ${aLabel4} ${aReference1} - -# Close/Open the transaction -NewCommand D - -# Forget the attribute -ForgetAll D ${aLabel4} - -# Close/Open the transaction -NewCommand D - -# Undo-Redo-Undo -Undo D -Redo D -Undo D - -# Get a value of the attribute -set aReference2 [GetReference D ${aLabel4}] - -if { ${aReference1} != ${aReference2} } { - puts "aReference1=${aReference1} aReference2=${aReference2}" - puts "Add TDF_Reference attribute: Error" - return -} -puts "Add TDF_Reference attribute: OK" diff --git a/tests/caf/basic/L2 b/tests/caf/basic/L2 deleted file mode 100755 index ebc4a1ce7b..0000000000 --- a/tests/caf/basic/L2 +++ /dev/null @@ -1,48 +0,0 @@ -#INTERFACE CAF -# Basic attributes -# -# Testing attribute: TDF_Reference -# -# Testing command: SetReference -# Testing command: GetReference -# - -puts "caf001-L2" - -# Add an attribute to a data framework -set aSetAttr1 100 -set aSetAttr2 200 -set aSetAttr3 300 -set aLabel1 0:2 -set aLabel2 0:3 -set aLabel3 0:4 -set aLabel4 0:5 -SetInteger D ${aLabel1} ${aSetAttr1} -SetInteger D ${aLabel2} ${aSetAttr2} -SetInteger D ${aLabel3} ${aSetAttr3} - -set aReference1 ${aLabel2} -SetReference D ${aLabel4} ${aReference1} - -# Close/Open the transaction -NewCommand D - -# Set a new value of the attribute -set aReference3 ${aLabel3} -SetReference D ${aLabel4} ${aReference3} - -# Close/Open the transaction -NewCommand D - -# Undo -Undo D - -# Get a value of the attribute -set aReference4 [GetReference D ${aLabel4}] - -if { ${aReference1} != ${aReference4} } { - puts "aReference1=${aReference1} aReference4=${aReference4}" - puts "Set a value of TDF_Reference attribute: Error" - return -} -puts "Set a value of TDF_Reference attribute: OK" diff --git a/tests/caf/basic/L3 b/tests/caf/basic/L3 deleted file mode 100755 index 11fe36c5a0..0000000000 --- a/tests/caf/basic/L3 +++ /dev/null @@ -1,57 +0,0 @@ -#INTERFACE CAF -# Basic attributes -# -# Testing attribute: TDF_Reference -# -# Testing command: SetReference -# Testing command: GetReference -# - -puts "caf001-L3" - -# Add an attribute to a data framework -set aSetAttr1 100 -set aSetAttr2 200 -set aSetAttr3 300 -set aLabel1 0:2 -set aLabel2 0:3 -set aLabel3 0:4 -set aLabel4 0:5 -SetInteger D ${aLabel1} ${aSetAttr1} -SetInteger D ${aLabel2} ${aSetAttr2} -SetInteger D ${aLabel3} ${aSetAttr3} - -set aReference1 ${aLabel2} -SetReference D ${aLabel4} ${aReference1} - -# Close/Open the transaction -NewCommand D - -# Save the document -set aFile ${imagedir}/caf001-L3.cbf -file delete ${aFile} -SaveAs D ${aFile} -if { ![file exists ${aFile}] } { - puts "There is not ${aFile} file; SaveAs command: Error" - return -} -#catch {exec chmod 777 ${aFile}} - -# Restore the document -Close D -Open ${aFile} DD - -# Get a value of the attribute -set IsDone [catch {set aReference5 [GetReference DD ${aLabel4}]} aResult] -if { ${IsDone} != 0 } { - puts ${aResult} - puts "Get a value of TDF_Reference attribute from restoring document: Error" - return -} - -if { ${aReference1} != ${aReference5} } { - puts "aReference1=${aReference1} aReference5=${aReference5}" - puts "Get a value of TDF_Reference attribute from restoring document: Error" - return -} -puts "Get a value of TDF_Reference attribute from restoring document: OK" diff --git a/tests/caf/basic/M1 b/tests/caf/basic/M1 deleted file mode 100755 index efe4b929d9..0000000000 --- a/tests/caf/basic/M1 +++ /dev/null @@ -1,71 +0,0 @@ -#INTERFACE CAF -puts "================" -puts "OCC6493" -puts "================" -puts "" -###################################################### -# No binary persistence for TDataStd_ExtStringArray attribute -###################################################### - -# Basic attributes -# -# Testing attribute: TDataStd_ExtStringArray -# -# Testing command: SetExtStringArray -# Testing command: GetExtStringArray -# - -puts "caf001-M1" -set QA_DUP 0 - -# Add an attribute to a data framework -set aFrom1 1 -set aTo1 2 -set aSetAttr11 "TDataStd" -set aSetAttr12 "ExtStringArray" -set aLabel 0:2 -set isDelta 0 -SetExtStringArray D ${aLabel} ${isDelta} ${aFrom1} ${aTo1} ${aSetAttr11} ${aSetAttr12} - -# Close/Open the transaction -NewCommand D - -# Forget the attribute -ForgetAll D ${aLabel} - -# Close/Open the transaction -NewCommand D - -# Undo-Redo-Undo -Undo D -Redo D -Undo D - -# Get a value of the attribute -set IsGood 1 -set aMessage1 "Add TDataStd_ExtStringArray attribute: Error" -set aGetAttr1 [GetExtStringArray D ${aLabel}] -set aLen1 [llength ${aGetAttr1}] -if { ${aLen1} != [expr ${aTo1} - ${aFrom1} + 1] } { - set IsGood 0 - puts "aLen1=${aLen1}" - puts ${aMessage1} -} -set aGetAttr21 [lindex ${aGetAttr1} 0] -if { ${aSetAttr11} != ${aGetAttr21} } { - set IsGood 0 - puts "aGetAttr21=${aGetAttr21}" - puts ${aMessage1} -} -set aGetAttr22 [lindex ${aGetAttr1} 1] -if { ${aSetAttr12} != ${aGetAttr22} } { - set IsGood 0 - puts "aGetAttr22=${aGetAttr22}" - puts ${aMessage1} -} - -if { ${IsGood} == 0} { - puts "OCC6493: Error" -} else { - puts "OCC6493: OK" -} diff --git a/tests/caf/basic/M2 b/tests/caf/basic/M2 deleted file mode 100755 index 9be120d196..0000000000 --- a/tests/caf/basic/M2 +++ /dev/null @@ -1,74 +0,0 @@ -#INTERFACE CAF -puts "================" -puts "OCC6493" -puts "================" -puts "" -###################################################### -# No binary persistence for TDataStd_ExtStringArray attribute -###################################################### - -# Basic attributes -# TDataStd_ExtStringArray -# -# Testing attribute: TDataStd_ExtStringArray -# -# Testing command: SetExtStringArray -# Testing command: GetExtStringArray -# - -puts "caf001-M2" -set QA_DUP 0 - -# Add an attribute to a data framework -set aFrom1 1 -set aTo1 2 -set aSetAttr11 "TDataStd" -set aSetAttr12 "ExtStringArray" -set aLabel 0:2 -set isDelta 0 -SetExtStringArray D ${aLabel} ${isDelta} ${aFrom1} ${aTo1} ${aSetAttr11} ${aSetAttr12} - -# Close/Open the transaction -NewCommand D - -# Set a new value of the attribute -set aFrom2 1 -set aTo2 2 -set aSetAttr21 "NEW TDataStd" -set aSetAttr22 "NEW ExtStringArray" -SetExtStringArray D ${aLabel} ${isDelta} ${aFrom2} ${aTo2} ${aSetAttr21} ${aSetAttr22} - -# Close/Open the transaction -NewCommand D - -# Undo -Undo D - -# Get a value of the attribute -set IsGood 1 -set aMessage2 "Set a value of TDataStd_ExtStringArray attribute: Error" -set aGetAttr2 [GetExtStringArray D ${aLabel}] -set aLen2 [llength ${aGetAttr2}] -if { ${aLen2} != [expr ${aTo1} - ${aFrom1} + 1] } { - set IsGood 0 - puts "aLen2=${aLen2}" - puts ${aMessage2} -} -set aGetAttr31 [lindex ${aGetAttr2} 0] -if { ${aSetAttr11} != ${aGetAttr31} } { - set IsGood 0 - puts "aGetAttr31=${aGetAttr31}" - puts ${aMessage2} -} -set aGetAttr32 [lindex ${aGetAttr2} 1] -if { ${aSetAttr12} != ${aGetAttr32} } { - set IsGood 0 - puts "aGetAttr32=${aGetAttr32}" - puts ${aMessage2} -} - -if { ${IsGood} == 0} { - puts "OCC6493: Error" -} else { - puts "OCC6493: OK" -} diff --git a/tests/caf/basic/M3 b/tests/caf/basic/M3 deleted file mode 100755 index 8c96fe813a..0000000000 --- a/tests/caf/basic/M3 +++ /dev/null @@ -1,77 +0,0 @@ -#INTERFACE CAF -puts "================" -puts "OCC6493" -puts "================" -puts "" -###################################################### -# No binary persistence for TDataStd_ExtStringArray attribute -###################################################### - -# Basic attributes -# -# Testing attribute: TDataStd_ExtStringArray -# -# Testing command: SetExtStringArray -# Testing command: GetExtStringArray -# - -puts "caf001-M3" -set QA_DUP 0 - -# Add an attribute to a data framework -set aFrom1 1 -set aTo1 2 -set aLabel 0:2 -set aSetAttr11 "TDataStd" -set aSetAttr12 "ExtStringArray" -set isDelta 0 -SetExtStringArray D ${aLabel} ${isDelta} ${aFrom1} ${aTo1} ${aSetAttr11} ${aSetAttr12} - -# Close/Open the transaction -NewCommand D - -# Save the document -set aFile ${imagedir}/caf001-M3.cbf -file delete ${aFile} -SaveAs D ${aFile} -if { ![file exists ${aFile}] } { - puts "There is not ${aFile} file; SaveAs command: Error" -} -#catch {exec chmod 777 ${aFile}} - -# Restore the document -Close D -Open ${aFile} DD - -# Get a value of the attribute -set IsGood 1 -set aMessage3 "Get a value of TDataStd_ExtStringArray attribute from restoring document: Error" -set IsDone [catch {set aGetAttr3 [GetExtStringArray DD ${aLabel}]} aResult] -if { ${IsDone} != 0 } { - set IsGood 0 - puts ${aMessage3} -} -set aLen3 [llength ${aGetAttr3}] -if { ${aLen3} != [expr ${aTo1} - ${aFrom1} + 1] } { - set IsGood 0 - puts "aLen3=${aLen3}" - puts ${aMessage3} -} -set aGetAttr41 [lindex ${aGetAttr3} 0] -if { ${aSetAttr11} != ${aGetAttr41} } { - set IsGood 0 - puts "aGetAttr41=${aGetAttr41}" - puts ${aMessage3} -} -set aGetAttr42 [lindex ${aGetAttr3} 1] -if { ${aSetAttr12} != ${aGetAttr42} } { - set IsGood 0 - puts "aGetAttr42=${aGetAttr42}" - puts ${aMessage3} -} - -if { ${IsGood} == 0} { - puts "OCC6493: Error" -} else { - puts "OCC6493: OK" -} diff --git a/tests/caf/basic/M4 b/tests/caf/basic/M4 deleted file mode 100755 index a31c599361..0000000000 --- a/tests/caf/basic/M4 +++ /dev/null @@ -1,132 +0,0 @@ -puts "================" -puts "OCC27192" -puts "================" -puts "" -###################################################### -# Improvement of storage of Ocaf document in XML file format -###################################################### - -NewDocument M4 XmlOcaf - -# Simple array with many separators inside. -SetExtStringArray M4 0:1 0 1 6 -set S1 "Hello 1" -SetExtStringArrayValue M4 0:1 1 ${S1} -set S2 "Hello_2" -SetExtStringArrayValue M4 0:1 2 ${S2} -set S3 "Hello*3" -SetExtStringArrayValue M4 0:1 3 ${S3} -set S4 "Hello-4" -SetExtStringArrayValue M4 0:1 4 ${S4} -set S5 "Hello5" -SetExtStringArrayValue M4 0:1 5 ${S5} -set Sempty "" -SetExtStringArrayValue M4 0:1 6 ${Sempty} -SetNode M4 0:1 - -#An array with empty strings. -SetExtStringArray M4 0:2 0 0 3 -SetExtStringArrayValue M4 0:2 0 ${Sempty} -set SH "H" -SetExtStringArrayValue M4 0:2 1 ${SH} -SetExtStringArrayValue M4 0:2 2 ${Sempty} -SetExtStringArrayValue M4 0:2 3 ${Sempty} -SetNode M4 0:2 -AppendNode M4 0:1 0:2 - -#An empty array. -SetExtStringArray M4 0:3 0 0 0 -SetNode M4 0:3 -AppendNode M4 0:1 0:3 - -#Save & Close. -set aFile ${imagedir}/OCC27192.xml -# -file delete ${aFile} -# -if { [file exists ${aFile}] } { - puts "There is ${aFile} old file" - puts "OCC27192: ERROR (old file)" -} -# -catch {SaveAs M4 ${aFile}} -if { ![file exists ${aFile}] } { - puts "There is not ${aFile} file; SaveAs command: Error" - puts "OCC27192: ERROR (Save failed)" -} -Close M4 - -#Open the document and check the values. -catch {Open ${aFile} MM4} - -set IsGood 1 - -#Check ExtStringArrays: -#0:1 -set V1 [GetExtStringArrayValue MM4 0:1 1] -if { ${V1} != ${S1} } { - set IsGood 0 - puts "${V1}!=${S1}" -} -set V2 [GetExtStringArrayValue MM4 0:1 2] -if { ${V2} != ${S2} } { - set IsGood 0 - puts "${V2}!=${S2}" -} -set V3 [GetExtStringArrayValue MM4 0:1 3] -if { ${V3} != ${S3} } { - set IsGood 0 - puts "${V3}!=${S3}" -} -set V4 [GetExtStringArrayValue MM4 0:1 4] -if { ${V4} != ${S4} } { - set IsGood 0 - puts "${V4}!=${S4}" -} -set V5 [GetExtStringArrayValue MM4 0:1 5] -if { ${V5} != ${S5} } { - set IsGood 0 - puts "${V5}!=${S5}" -} -set V6 [GetExtStringArrayValue MM4 0:1 6] -if { ${V6} != ${Sempty} } { - set IsGood 0 - puts "${V6}!=${Sempty}" -} - -#0:2 -set V7 [GetExtStringArrayValue MM4 0:2 0] -if { ${V7} != ${Sempty} } { - set IsGood 0 - puts "${V7}!=${Sempty}" -} -set V8 [GetExtStringArrayValue MM4 0:2 1] -if { ${V8} != ${SH} } { - set IsGood 0 - puts "${V8}!=${SH}" -} -set V9 [GetExtStringArrayValue MM4 0:2 2] -if { ${V9} != ${Sempty} } { - set IsGood 0 - puts "${V9}!=${Sempty}" -} -set V10 [GetExtStringArrayValue MM4 0:2 3] -if { ${V10} != ${Sempty} } { - set IsGood 0 - puts "${V10}!=${Sempty}" -} - -#0:3 -set V11 [GetExtStringArrayValue MM4 0:3 0] -if { ${V11} != ${Sempty} } { - set IsGood 0 - puts "${V11}!=${Sempty}" -} - -if { ${IsGood} == 0} { - puts "OCC27192: Error" -} else { - puts "OCC27192: OK" -} - -Close MM4 diff --git a/tests/caf/basic/M5 b/tests/caf/basic/M5 deleted file mode 100644 index d2c2836dfe..0000000000 --- a/tests/caf/basic/M5 +++ /dev/null @@ -1,80 +0,0 @@ -#INTERFACE CAF -# Basic attributes -# TDataStd_ExtStringArray -# -# Testing attribute: User defined (additional GUID) TDataStd_ExtStringArray -# -# Testing command: SetExtStringArray -# Testing command: GetExtStringArray -# - -puts "caf001-M5" -set QA_DUP 0 - -# Add an attribute to a data framework -set aFrom1 1 -set aTo1 2 -set aSetAttr11 aaaaa -set aSetAttr12 bbbbbbb -set aLabel 0:2 -set isDelta 0 -set aGuid1 "12e94515-6dbc-11d4-b9c8-0060b0ee281b" - -SetExtStringArray D ${aLabel} ${isDelta} ${aFrom1} ${aTo1} ${aSetAttr11} ${aSetAttr12} -SetExtStringArray D ${aLabel} ${isDelta} -g ${aGuid1} ${aFrom1} ${aTo1} ${aSetAttr11} ${aSetAttr12} - -# Close/Open the transaction -NewCommand D - -# Forget the attribute -ForgetAll D ${aLabel} - -# Close/Open the transaction -NewCommand D - -# Undo-Redo-Undo -Undo D -Redo D -Undo D - -# Get a value of the attribute -set IsGood 1 -set aMessage1 "Add TDataStd_ExtStringArray attribute: Error" -set aGetAttr1 [GetExtStringArray D ${aLabel}] -set aLen1 [llength ${aGetAttr1}] -set aGetAttr2 [GetExtStringArray D ${aLabel} ${aGuid1}] -set aLen2 [llength ${aGetAttr2}] - -if { ${aLen1} != [expr ${aTo1} - ${aFrom1} + 1] } { - set IsGood 0 - puts "aLen1=${aLen1}" - puts ${aMessage1} -} -if { ${aLen2} != [expr ${aTo1} - ${aFrom1} + 1] } { - set IsGood 0 - puts "aLen2=${aLen2}" - puts ${aMessage1} -} - -set aGetAttr11 [lindex ${aGetAttr1} 0] -set aGetAttr21 [lindex ${aGetAttr2} 0] -if { ${aGetAttr11} != ${aGetAttr21} } { - set IsGood 0 - puts "aGetAttr11=${aGetAttr11}" - puts "aGetAttr21=${aGetAttr21}" - puts ${aMessage1} -} -set aGetAttr12 [lindex ${aGetAttr1} 1] -set aGetAttr22 [lindex ${aGetAttr2} 1] -if { ${aGetAttr12} != ${aGetAttr22} } { - set IsGood 0 - puts "aGetAttr12=${aGetAttr12}" - puts "aGetAttr22=${aGetAttr22}" - puts ${aMessage1} -} - -if { ${IsGood} == 0} { - puts "Add TDataStd_ExtStringArray attribute: Error" -} else { - puts "Add TDataStd_ExtStringArray attribute: OK" -} diff --git a/tests/caf/basic/M6 b/tests/caf/basic/M6 deleted file mode 100644 index a4feb678cf..0000000000 --- a/tests/caf/basic/M6 +++ /dev/null @@ -1,89 +0,0 @@ -#INTERFACE CAF -# Basic attributes -# TDataStd_ExtStringArray -# -# Testing attribute: User defined (additional GUID) TDataStd_IntegerArray -# -# Testing command: SetExtStringArray -# Testing command: GetExtStringArray -# - -puts "caf001-M6" -set QA_DUP 0 - -# Add an attribute to a data framework -set aFrom1 1 -set aTo1 2 -set aSetAttr11 xxxxxxxx -set aSetAttr12 yyyyyyy -set aLabel 0:2 -set isDelta 0 -set aGuid1 "12e94515-6dbc-11d4-b9c8-0060b0ee281b" - -SetExtStringArray D ${aLabel} ${isDelta} ${aFrom1} ${aTo1} ${aSetAttr11} ${aSetAttr12} -SetExtStringArray D ${aLabel} ${isDelta} -g ${aGuid1} ${aFrom1} ${aTo1} ${aSetAttr11} ${aSetAttr12} - -# Close/Open the transaction -NewCommand D - -# Forget the attribute -ForgetAll D ${aLabel} - -# Close/Open the transaction -NewCommand D - -# Undo-Redo-Undo -Undo D -Redo D -Undo D - -# Save Document -set aFile ${imagedir}/caf001-M6.cbf -SaveAs D ${aFile} -Close D - -#Open a document -Open ${aFile} D - - -# Get a value of the attribute -set IsGood 1 -set aMessage1 "Add TDataStd_ExtStringArray attribute: Error" -set aGetAttr1 [GetExtStringArray D ${aLabel}] -set aLen1 [llength ${aGetAttr1}] -set aGetAttr2 [GetExtStringArray D ${aLabel} ${aGuid1}] -set aLen2 [llength ${aGetAttr2}] - -if { ${aLen1} != [expr ${aTo1} - ${aFrom1} + 1] } { - set IsGood 0 - puts "aLen1=${aLen1}" - puts ${aMessage1} -} -if { ${aLen2} != [expr ${aTo1} - ${aFrom1} + 1] } { - set IsGood 0 - puts "aLen2=${aLen2}" - puts ${aMessage1} -} - -set aGetAttr11 [lindex ${aGetAttr1} 0] -set aGetAttr21 [lindex ${aGetAttr2} 0] -if { ${aGetAttr11} != ${aGetAttr21} } { - set IsGood 0 - puts "aGetAttr11=${aGetAttr11}" - puts "aGetAttr21=${aGetAttr21}" - puts ${aMessage1} -} -set aGetAttr12 [lindex ${aGetAttr1} 1] -set aGetAttr22 [lindex ${aGetAttr2} 1] -if { ${aGetAttr12} != ${aGetAttr22} } { - set IsGood 0 - puts "aGetAttr12=${aGetAttr12}" - puts "aGetAttr22=${aGetAttr22}" - puts ${aMessage1} -} - -if { ${IsGood} == 0} { - puts "Add TDataStd_ExtStringArray attribute: Error" -} else { - puts "Add TDataStd_ExtStringArray attribute: OK" -} diff --git a/tests/caf/basic/M7 b/tests/caf/basic/M7 deleted file mode 100644 index 8ae4a998fa..0000000000 --- a/tests/caf/basic/M7 +++ /dev/null @@ -1,90 +0,0 @@ -#INTERFACE CAF -# Basic attributes -# TDataStd_ExtStringArray -# -# Testing attribute: User defined (additional GUID) TDataStd_ExtStringArray -# -# Testing command: SetExtStringArray -# Testing command: GetExtStringArray -# - -puts "caf001-M7" -set QA_DUP 0 - -# Add an attribute to a data framework -set aFrom1 1 -set aTo1 2 -set aSetAttr11 xxxxx -set aSetAttr12 zzzzzzz -set aLabel 0:2 -set isDelta 0 -set aGuid1 "12e94515-6dbc-11d4-b9c8-0060b0ee281b" - -SetExtStringArray D ${aLabel} ${isDelta} ${aFrom1} ${aTo1} ${aSetAttr11} ${aSetAttr12} -SetExtStringArray D ${aLabel} ${isDelta} -g ${aGuid1} ${aFrom1} ${aTo1} ${aSetAttr11} ${aSetAttr12} - -# Close/Open the transaction -NewCommand D - -# Forget the attribute -ForgetAll D ${aLabel} - -# Close/Open the transaction -NewCommand D - -# Undo-Redo-Undo -Undo D -Redo D -Undo D - -# Save Document -Format D XmlOcaf -set aFile ${imagedir}/caf001-M7.xml -SaveAs D ${aFile} -Close D - -#Open a document -Open ${aFile} D - - -# Get a value of the attribute -set IsGood 1 -set aMessage1 "Add TDataStd_ExtStringArray attribute: Error" -set aGetAttr1 [GetExtStringArray D ${aLabel}] -set aLen1 [llength ${aGetAttr1}] -set aGetAttr2 [GetExtStringArray D ${aLabel} ${aGuid1}] -set aLen2 [llength ${aGetAttr2}] - -if { ${aLen1} != [expr ${aTo1} - ${aFrom1} + 1] } { - set IsGood 0 - puts "aLen1=${aLen1}" - puts ${aMessage1} -} -if { ${aLen2} != [expr ${aTo1} - ${aFrom1} + 1] } { - set IsGood 0 - puts "aLen2=${aLen2}" - puts ${aMessage1} -} - -set aGetAttr11 [lindex ${aGetAttr1} 0] -set aGetAttr21 [lindex ${aGetAttr2} 0] -if { ${aGetAttr11} != ${aGetAttr21} } { - set IsGood 0 - puts "aGetAttr11=${aGetAttr11}" - puts "aGetAttr21=${aGetAttr21}" - puts ${aMessage1} -} -set aGetAttr12 [lindex ${aGetAttr1} 1] -set aGetAttr22 [lindex ${aGetAttr2} 1] -if { ${aGetAttr12} != ${aGetAttr22} } { - set IsGood 0 - puts "aGetAttr12=${aGetAttr12}" - puts "aGetAttr22=${aGetAttr22}" - puts ${aMessage1} -} - -if { ${IsGood} == 0} { - puts "Add TDataStd_ExtStringArray attribute: Error" -} else { - puts "Add TDataStd_ExtStringArray attribute: OK" -} diff --git a/tests/caf/basic/N1 b/tests/caf/basic/N1 deleted file mode 100644 index 3ab536f9bd..0000000000 --- a/tests/caf/basic/N1 +++ /dev/null @@ -1,70 +0,0 @@ -#INTERFACE CAF -# Basic attributes -# -# Testing attribute: TDataStd_Triangulation -# -# Testing command: SetTriangulation -# Testing command: DumpTriangulation -# - -puts "caf001-N1" -set FileName_1 $imagedir/caf001-N1_1.cbf -set FileName_2 $imagedir/caf001-N1_2.cbf - -# Make a box and produce triangulation -psphere s 10 -explode s f -incmesh s_1 10 -a 90 - -# Set triangulation from the box's face -Format D BinOcaf -SetTriangulation D 0:1 s_1 -CommitCommand D - -# Save document on disk. -# First transaction before Undo/Redo -SaveAs D $FileName_1 - -incmesh s_1 1 -a 15 - -OpenCommand D -SetTriangulation D 0:1 s_1 -CommitCommand D - -# Save document on disk. -# Second transaction before Undo/Redo -SaveAs D $FileName_2 - -# Test Undo/Redo. -Undo D - -# Print the mesh data after first transaction -set dump1_bfr [DumpTriangulation D 0:1] - -Redo D - -# Print the mesh data after second transaction -set dump2_bfr [DumpTriangulation D 0:1] - -Close D - -# Restore data after first and second transactions -Open $FileName_1 D_1 -Open $FileName_2 D_2 - -set dump1_aft [DumpTriangulation D_1 0:1] -set dump2_aft [DumpTriangulation D_2 0:1] - -Close D_1 -Close D_2 - -# Check data -if { ${dump1_bfr}!=${dump1_aft} } { - puts "TDataStd_Triangulation attribute: Error" - return -} -if { ${dump2_bfr}!=${dump2_aft} } { - puts "TDataStd_Triangulation attribute: Error" - return -} -puts "TDataStd_Triangulation attribute: OK" diff --git a/tests/caf/basic/N2 b/tests/caf/basic/N2 deleted file mode 100644 index 96c692c3f8..0000000000 --- a/tests/caf/basic/N2 +++ /dev/null @@ -1,70 +0,0 @@ -#INTERFACE CAF -# Basic attributes -# -# Testing attribute: TDataStd_Triangulation -# -# Testing command: SetTriangulation -# Testing command: DumpTriangulation -# - -puts "caf001-N2" -set FileName_1 $imagedir/caf001-N2_1.xml -set FileName_2 $imagedir/caf001-N2_2.xml - -# Make a box and produce triangulation -psphere s 10 -explode s f -incmesh s_1 10 -a 90 - -# Set triangulation from the box's face -Format D XmlOcaf -SetTriangulation D 0:1 s_1 -CommitCommand D - -# Save document on disk. -# First transaction before Undo/Redo -SaveAs D $FileName_1 - -incmesh s_1 1 -a 15 - -OpenCommand D -SetTriangulation D 0:1 s_1 -CommitCommand D - -# Save document on disk. -# Second transaction before Undo/Redo -SaveAs D $FileName_2 - -# Test Undo/Redo. -Undo D - -# Print the mesh data after first transaction -set dump1_bfr [DumpTriangulation D 0:1] - -Redo D - -# Print the mesh data after second transaction -set dump2_bfr [DumpTriangulation D 0:1] - -Close D - -# Restore data after first and second transactions -Open $FileName_1 D_1 -Open $FileName_2 D_2 - -set dump1_aft [DumpTriangulation D_1 0:1] -set dump2_aft [DumpTriangulation D_2 0:1] - -Close D_1 -Close D_2 - -# Check data -if { ${dump1_bfr}!=${dump1_aft} } { - puts "TDataStd_Triangulation attribute: Error" - return -} -if { ${dump2_bfr}!=${dump2_aft} } { - puts "TDataStd_Triangulation attribute: Error" - return -} -puts "TDataStd_Triangulation attribute: OK" diff --git a/tests/caf/basic/N4 b/tests/caf/basic/N4 deleted file mode 100644 index 5d65267162..0000000000 --- a/tests/caf/basic/N4 +++ /dev/null @@ -1,50 +0,0 @@ -#INTERFACE CAF -# Basic attributes -# -# Testing attribute: User defined (additional GUID) TDataStd_AsciiString -# -# Testing command: SetAsciiString -# Testing command: GetAsciiString -# - -puts "caf001-N4" - -# Add an attribute to a data framework -set aSetAttr1 "New Attribute1" -set aSetAttr2 "New Attribute2" -set aGuid1 "12e94571-6dbc-11d4-b9c8-0060b0ee281b" -set aGuid2 "12e94572-6dbc-11d4-b9c8-0060b0ee281b" -set aLabel 0:2 -SetAsciiString D ${aLabel} ${aSetAttr1} ${aGuid1} -SetAsciiString D ${aLabel} ${aSetAttr2} ${aGuid2} - -# Close/Open the transaction -NewCommand D - -# Forget the attribute -ForgetAll D ${aLabel} - -# Close/Open the transaction -NewCommand D - -# Undo-Redo-Undo -Undo D -Redo D -Undo D - -# Get a value of the attribute -set aGetAttr1 [GetAsciiString D ${aLabel} ${aGuid1}] -if { ${aSetAttr1}!=${aGetAttr1} } { - puts "aSetAttr1=${aSetAttr1} aGetAttr1=${aGetAttr1}" - puts "Add user defined TDataStd_AsciiString attribute: Error" - return -} - -set aGetAttr2 [GetAsciiString D ${aLabel} ${aGuid2}] -if { ${aSetAttr2}!=${aGetAttr2} } { - puts "aSetAttr2=${aSetAttr2} aGetAttr2=${aGetAttr2}" - puts "Add user defined TDataStd_AsciiString attribute: Error" - return -} - -puts "Add user defined TDataStd_AsciiString attributes: OK" diff --git a/tests/caf/basic/N5 b/tests/caf/basic/N5 deleted file mode 100644 index c1f4212b44..0000000000 --- a/tests/caf/basic/N5 +++ /dev/null @@ -1,52 +0,0 @@ -#INTERFACE CAF -# Basic attributes -# -# Testing attribute: User defined (additional GUID) TDataStd_AsciiString -# -# Testing command: SetAsciiString -# Testing command: GetAsciiString -# - -puts "caf001-N5" - -# Add an attribute to a data framework -set aSetAttr1 "New Attribute_1" -set aSetAttr2 "New Attribute_2" -set aGuid1 "12e94571-6dbc-11d4-b9c8-0060b0ee281b" -set aGuid2 "12e94572-6dbc-11d4-b9c8-0060b0ee281b" -set aLabel 0:2 -SetAsciiString D ${aLabel} ${aSetAttr1} ${aGuid1} -SetAsciiString D ${aLabel} ${aSetAttr2} ${aGuid2} - -# Close/Open the transaction -NewCommand D - -# Set a new value of the attributes -set aSetAttr12 "Modified Attribute_1" -SetAsciiString D ${aLabel} ${aSetAttr12} ${aGuid1} - -set aSetAttr22 "Modified Attribute_2" -SetAsciiString D ${aLabel} ${aSetAttr12} ${aGuid2} - -# Close/Open the transaction -NewCommand D - -# Undo-Redo-Undo -Undo D - -# Get a value of the attribute -set aGetAttr1 [GetAsciiString D ${aLabel} ${aGuid1}] -if { ${aSetAttr1}!=${aGetAttr1} } { - puts "aSetAttr1=${aSetAttr1} aGetAttr1=${aGetAttr1}" - puts "Add user defined TDataStd_AsciiString attribute: Error" - return -} - -set aGetAttr2 [GetAsciiString D ${aLabel} ${aGuid2}] -if { ${aSetAttr2}!=${aGetAttr2} } { - puts "aSetAttr2=${aSetAttr2} aGetAttr2=${aGetAttr2}" - puts "Add user defined TDataStd_AsciiString attribute: Error" - return -} - -puts "Add user defined TDataStd_AsciiString attributes: OK" diff --git a/tests/caf/basic/N6 b/tests/caf/basic/N6 deleted file mode 100644 index f26d50663c..0000000000 --- a/tests/caf/basic/N6 +++ /dev/null @@ -1,58 +0,0 @@ -#INTERFACE CAF -# Basic attributes -# -# Testing attribute: User defined (additional GUID) TDataStd_AsciiString -# -# Testing command: SetAsciiString -# Testing command: GetAsciiString -# - -puts "caf001-N6" - -# Add an attribute to a data framework -set aSetAttr1 "New Attribute_1" -set aSetAttr2 "New Attribute_2" -set aGuid1 "12e94571-6dbc-11d4-b9c8-0060b0ee281b" -set aGuid2 "12e94572-6dbc-11d4-b9c8-0060b0ee281b" -set aLabel 0:2 -SetAsciiString D ${aLabel} ${aSetAttr1} ${aGuid1} -SetAsciiString D ${aLabel} ${aSetAttr2} ${aGuid2} - -# Close/Open the transaction -NewCommand D - -# Save the document -set aFile ${imagedir}/caf001-N6.cbf -file delete ${aFile} -SaveAs D ${aFile} -if { ![file exists ${aFile}] } { - puts "There is not ${aFile} file; SaveAs command: Error" - return -} -#catch {exec chmod 777 ${aFile}} - -# Restore the document -Close D -Open ${aFile} DD - -# Get a value of the attribute #1 -set IsDone [catch {set aGetAttr3 [GetAsciiString DD ${aLabel} ${aGuid1}]} aResult] -if { ${IsDone} != 0 || - ${aSetAttr1}!=${aGetAttr3} } { - puts ${aResult} - puts "aSetAttr1=${aSetAttr1} aGetAttr3=${aGetAttr3}" - puts "Get a value of the first TDataStd_AsciiString attribute from restoring document: Error" - return -} - -# Get a value of the attribute #2 -set IsDone [catch {set aGetAttr4 [GetAsciiString DD ${aLabel} ${aGuid2}]} aResult] -if { ${IsDone} != 0 || - ${aSetAttr2}!=${aGetAttr4} } { - puts ${aResult} - puts "aSetAttr2=${aSetAttr2} aGetAttr4=${aGetAttr4}" - puts "Get a value of the second TDataStd_AsciiString attribute from restoring document: Error" - return -} - -puts "Get a value of user defined TDataStd_AsciiString attributes from restoring document: OK" diff --git a/tests/caf/basic/N7 b/tests/caf/basic/N7 deleted file mode 100644 index 65c43502ee..0000000000 --- a/tests/caf/basic/N7 +++ /dev/null @@ -1,57 +0,0 @@ -#INTERFACE CAF -# Basic attributes -# -# Testing attribute: User defined (additional GUID) TDataStd_AsciiString -# -# Testing command: SetAsciiString -# Testing command: GetAsciiString -# - -puts "caf001-N6" - -# Add an attribute to a data framework -set aSetAttr1 "New Attribute_1" -set aSetAttr2 "New Attribute_2" -set aGuid2 "12e94572-6dbc-11d4-b9c8-0060b0ee281b" -set aLabel 0:2 -SetAsciiString D ${aLabel} ${aSetAttr1} -SetAsciiString D ${aLabel} ${aSetAttr2} ${aGuid2} - -# Close/Open the transaction -NewCommand D - -# Save the document -set aFile ${imagedir}/caf001-N7.cbf -file delete ${aFile} -SaveAs D ${aFile} -if { ![file exists ${aFile}] } { - puts "There is not ${aFile} file; SaveAs command: Error" - return -} -#catch {exec chmod 777 ${aFile}} - -# Restore the document -Close D -Open ${aFile} DD - -# Get a value of the attribute #1 -set IsDone [catch {set aGetAttr3 [GetAsciiString DD ${aLabel}]} aResult] -if { ${IsDone} != 0 || - ${aSetAttr1}!=${aGetAttr3} } { - puts ${aResult} - puts "aSetAttr1=${aSetAttr1} aGetAttr3=${aGetAttr3}" - puts "Get a value of the first TDataStd_AsciiString attribute from restoring document: Error" - return -} - -# Get a value of the attribute #2 -set IsDone [catch {set aGetAttr4 [GetAsciiString DD ${aLabel} ${aGuid2}]} aResult] -if { ${IsDone} != 0 || - ${aSetAttr2}!=${aGetAttr4} } { - puts ${aResult} - puts "aSetAttr2=${aSetAttr2} aGetAttr4=${aGetAttr4}" - puts "Get a value of the second TDataStd_AsciiString attribute from restoring document: Error" - return -} - -puts "Get a value of user defined TDataStd_AsciiString attributes from restoring document: OK" diff --git a/tests/caf/basic/O5 b/tests/caf/basic/O5 deleted file mode 100644 index 0c56cfc180..0000000000 --- a/tests/caf/basic/O5 +++ /dev/null @@ -1,80 +0,0 @@ -#INTERFACE CAF -# Basic attributes -# TDataStd_BooleanArray -# -# Testing attribute: User defined (additional GUID) TDataStd_BooleanArray -# -# Testing command: SetBooleanArray -# Testing command: GetBooleanArray -# - -puts "caf001-O5" -set QA_DUP 0 - -# Add an attribute to a data framework -set aFrom1 1 -set aTo1 2 -set aSetAttr11 0 -set aSetAttr12 1 -set aLabel 0:2 - -set aGuid1 "12e94516-6dbc-11d4-b9c8-0060b0ee281b" - -SetBooleanArray D ${aLabel} ${aFrom1} ${aTo1} ${aSetAttr11} ${aSetAttr12} -SetBooleanArray D ${aLabel} -g ${aGuid1} ${aFrom1} ${aTo1} ${aSetAttr11} ${aSetAttr12} - -# Close/Open the transaction -NewCommand D - -# Forget the attribute -ForgetAll D ${aLabel} - -# Close/Open the transaction -NewCommand D - -# Undo-Redo-Undo -Undo D -Redo D -Undo D - -# Get a value of the attribute -set IsGood 1 -set aMessage1 "Add TDataStd_BooleanArray attribute: Error" -set aGetAttr1 [GetBooleanArray D ${aLabel}] -set aLen1 [llength ${aGetAttr1}] -set aGetAttr2 [GetBooleanArray D ${aLabel} ${aGuid1}] -set aLen2 [llength ${aGetAttr2}] - -if { ${aLen1} != [expr ${aTo1} - ${aFrom1} + 1] } { - set IsGood 0 - puts "aLen1=${aLen1}" - puts ${aMessage1} -} -if { ${aLen2} != [expr ${aTo1} - ${aFrom1} + 1] } { - set IsGood 0 - puts "aLen2=${aLen2}" - puts ${aMessage1} -} - -set aGetAttr11 [lindex ${aGetAttr1} 0] -set aGetAttr21 [lindex ${aGetAttr2} 0] -if { ${aGetAttr11} != ${aGetAttr21} } { - set IsGood 0 - puts "aGetAttr11=${aGetAttr11}" - puts "aGetAttr21=${aGetAttr21}" - puts ${aMessage1} -} -set aGetAttr12 [lindex ${aGetAttr1} 1] -set aGetAttr22 [lindex ${aGetAttr2} 1] -if { ${aGetAttr12} != ${aGetAttr22} } { - set IsGood 0 - puts "aGetAttr12=${aGetAttr12}" - puts "aGetAttr22=${aGetAttr22}" - puts ${aMessage1} -} - -if { ${IsGood} == 0} { - puts "Add TDataStd_BooleanArray attribute: Error" -} else { - puts "Add TDataStd_BooleanArray attribute: OK" -} diff --git a/tests/caf/basic/O6 b/tests/caf/basic/O6 deleted file mode 100644 index abbab0d70e..0000000000 --- a/tests/caf/basic/O6 +++ /dev/null @@ -1,89 +0,0 @@ -#INTERFACE CAF -# Basic attributes -# TDataStd_BooleanArray -# -# Testing attribute: User defined (additional GUID) TDataStd_BooleanArray -# -# Testing command: SetBooleanArray -# Testing command: GetBooleanArray -# - -puts "caf001-O6" -set QA_DUP 0 - -# Add an attribute to a data framework -set aFrom1 1 -set aTo1 2 -set aSetAttr11 0 -set aSetAttr12 1 -set aLabel 0:2 - -set aGuid1 "12e94516-6dbc-11d4-b9c8-0060b0ee281b" - -SetBooleanArray D ${aLabel} ${aFrom1} ${aTo1} ${aSetAttr11} ${aSetAttr12} -SetBooleanArray D ${aLabel} -g ${aGuid1} ${aFrom1} ${aTo1} ${aSetAttr11} ${aSetAttr12} - -# Close/Open the transaction -NewCommand D - -# Forget the attribute -ForgetAll D ${aLabel} - -# Close/Open the transaction -NewCommand D - -# Undo-Redo-Undo -Undo D -Redo D -Undo D - -# Save Document -set aFile ${imagedir}/caf001-O6.cbf -SaveAs D ${aFile} -Close D - -#Open a document -Open ${aFile} D - - -# Get a value of the attribute -set IsGood 1 -set aMessage1 "Add TDataStd_BooleanArray attribute: Error" -set aGetAttr1 [GetBooleanArray D ${aLabel}] -set aLen1 [llength ${aGetAttr1}] -set aGetAttr2 [GetBooleanArray D ${aLabel} ${aGuid1}] -set aLen2 [llength ${aGetAttr2}] - -if { ${aLen1} != [expr ${aTo1} - ${aFrom1} + 1] } { - set IsGood 0 - puts "aLen1=${aLen1}" - puts ${aMessage1} -} -if { ${aLen2} != [expr ${aTo1} - ${aFrom1} + 1] } { - set IsGood 0 - puts "aLen2=${aLen2}" - puts ${aMessage1} -} - -set aGetAttr11 [lindex ${aGetAttr1} 0] -set aGetAttr21 [lindex ${aGetAttr2} 0] -if { ${aGetAttr11} != ${aGetAttr21} } { - set IsGood 0 - puts "aGetAttr11=${aGetAttr11}" - puts "aGetAttr21=${aGetAttr21}" - puts ${aMessage1} -} -set aGetAttr12 [lindex ${aGetAttr1} 1] -set aGetAttr22 [lindex ${aGetAttr2} 1] -if { ${aGetAttr12} != ${aGetAttr22} } { - set IsGood 0 - puts "aGetAttr12=${aGetAttr12}" - puts "aGetAttr22=${aGetAttr22}" - puts ${aMessage1} -} - -if { ${IsGood} == 0} { - puts "Add TDataStd_BooleanArray attribute: Error" -} else { - puts "Add TDataStd_BooleanArray attribute: OK" -} diff --git a/tests/caf/basic/O7 b/tests/caf/basic/O7 deleted file mode 100644 index 9b5eb2bc9e..0000000000 --- a/tests/caf/basic/O7 +++ /dev/null @@ -1,90 +0,0 @@ -#INTERFACE CAF -# Basic attributes -# TDataStd_BooleanArray -# -# Testing attribute: User defined (additional GUID) TDataStd_BooleanArray -# -# Testing command: SetBooleanArray -# Testing command: GetBooleanArray -# - -puts "caf001-O7" -set QA_DUP 0 - -# Add an attribute to a data framework -set aFrom1 1 -set aTo1 2 -set aSetAttr11 0 -set aSetAttr12 1 -set aLabel 0:2 - -set aGuid1 "12e94516-6dbc-11d4-b9c8-0060b0ee281b" - -SetBooleanArray D ${aLabel} ${aFrom1} ${aTo1} ${aSetAttr11} ${aSetAttr12} -SetBooleanArray D ${aLabel} -g ${aGuid1} ${aFrom1} ${aTo1} ${aSetAttr11} ${aSetAttr12} - -# Close/Open the transaction -NewCommand D - -# Forget the attribute -ForgetAll D ${aLabel} - -# Close/Open the transaction -NewCommand D - -# Undo-Redo-Undo -Undo D -Redo D -Undo D - -# Save Document -Format D XmlOcaf -set aFile ${imagedir}/caf001-O7.xml -SaveAs D ${aFile} -Close D - -#Open a document -Open ${aFile} D - - -# Get a value of the attribute -set IsGood 1 -set aMessage1 "Add TDataStd_BooleanArray attribute: Error" -set aGetAttr1 [GetBooleanArray D ${aLabel}] -set aLen1 [llength ${aGetAttr1}] -set aGetAttr2 [GetBooleanArray D ${aLabel} ${aGuid1}] -set aLen2 [llength ${aGetAttr2}] - -if { ${aLen1} != [expr ${aTo1} - ${aFrom1} + 1] } { - set IsGood 0 - puts "aLen1=${aLen1}" - puts ${aMessage1} -} -if { ${aLen2} != [expr ${aTo1} - ${aFrom1} + 1] } { - set IsGood 0 - puts "aLen2=${aLen2}" - puts ${aMessage1} -} - -set aGetAttr11 [lindex ${aGetAttr1} 0] -set aGetAttr21 [lindex ${aGetAttr2} 0] -if { ${aGetAttr11} != ${aGetAttr21} } { - set IsGood 0 - puts "aGetAttr11=${aGetAttr11}" - puts "aGetAttr21=${aGetAttr21}" - puts ${aMessage1} -} -set aGetAttr12 [lindex ${aGetAttr1} 1] -set aGetAttr22 [lindex ${aGetAttr2} 1] -if { ${aGetAttr12} != ${aGetAttr22} } { - set IsGood 0 - puts "aGetAttr12=${aGetAttr12}" - puts "aGetAttr22=${aGetAttr22}" - puts ${aMessage1} -} - -if { ${IsGood} == 0} { - puts "Add TDataStd_BooleanArray attribute: Error" -} else { - puts "Add TDataStd_BooleanArray attribute: OK" -} diff --git a/tests/caf/basic/P5 b/tests/caf/basic/P5 deleted file mode 100644 index fca5e55d16..0000000000 --- a/tests/caf/basic/P5 +++ /dev/null @@ -1,80 +0,0 @@ -#INTERFACE CAF -# Basic attributes -# TDataStd_ByteArray -# -# Testing attribute: User defined (additional GUID) TDataStd_ByteArray -# -# Testing command: SetByteArray -# Testing command: GetByteArray -# - -puts "caf001-P5" -set QA_DUP 0 - -# Add an attribute to a data framework -set aFrom1 1 -set aTo1 2 -set aSetAttr11 10 -set aSetAttr12 12 -set aLabel 0:2 -set isDelta 0 -set aGuid1 "12e94517-6dbc-11d4-b9c8-0060b0ee281b" - -SetByteArray D ${aLabel} ${isDelta} ${aFrom1} ${aTo1} ${aSetAttr11} ${aSetAttr12} -SetByteArray D ${aLabel} ${isDelta} -g ${aGuid1} ${aFrom1} ${aTo1} ${aSetAttr11} ${aSetAttr12} - -# Close/Open the transaction -NewCommand D - -# Forget the attribute -ForgetAll D ${aLabel} - -# Close/Open the transaction -NewCommand D - -# Undo-Redo-Undo -Undo D -Redo D -Undo D - -# Get a value of the attribute -set IsGood 1 -set aMessage1 "Add TDataStd_ByteArray attribute: Error" -set aGetAttr1 [GetByteArray D ${aLabel}] -set aLen1 [llength ${aGetAttr1}] -set aGetAttr2 [GetByteArray D ${aLabel} ${aGuid1}] -set aLen2 [llength ${aGetAttr2}] - -if { ${aLen1} != [expr ${aTo1} - ${aFrom1} + 1] } { - set IsGood 0 - puts "aLen1=${aLen1}" - puts ${aMessage1} -} -if { ${aLen2} != [expr ${aTo1} - ${aFrom1} + 1] } { - set IsGood 0 - puts "aLen2=${aLen2}" - puts ${aMessage1} -} - -set aGetAttr11 [lindex ${aGetAttr1} 0] -set aGetAttr21 [lindex ${aGetAttr2} 0] -if { ${aGetAttr11} != ${aGetAttr21} } { - set IsGood 0 - puts "aGetAttr11=${aGetAttr11}" - puts "aGetAttr21=${aGetAttr21}" - puts ${aMessage1} -} -set aGetAttr12 [lindex ${aGetAttr1} 1] -set aGetAttr22 [lindex ${aGetAttr2} 1] -if { ${aGetAttr12} != ${aGetAttr22} } { - set IsGood 0 - puts "aGetAttr12=${aGetAttr12}" - puts "aGetAttr22=${aGetAttr22}" - puts ${aMessage1} -} - -if { ${IsGood} == 0} { - puts "Add TDataStd_ByteArray attribute: Error" -} else { - puts "Add TDataStd_ByteArray attribute: OK" -} diff --git a/tests/caf/basic/P6 b/tests/caf/basic/P6 deleted file mode 100644 index c7ba88f812..0000000000 --- a/tests/caf/basic/P6 +++ /dev/null @@ -1,89 +0,0 @@ -#INTERFACE CAF -# Basic attributes -# TDataStd_ByteArray -# -# Testing attribute: User defined (additional GUID) TDataStd_ByteArray -# -# Testing command: SetByteArray -# Testing command: GetByteArray -# - -puts "caf001-P6" -set QA_DUP 0 - -# Add an attribute to a data framework -set aFrom1 1 -set aTo1 2 -set aSetAttr11 10 -set aSetAttr12 12 -set aLabel 0:2 -set isDelta 0 -set aGuid1 "12e94517-6dbc-11d4-b9c8-0060b0ee281b" - -SetByteArray D ${aLabel} ${isDelta} ${aFrom1} ${aTo1} ${aSetAttr11} ${aSetAttr12} -SetByteArray D ${aLabel} ${isDelta} -g ${aGuid1} ${aFrom1} ${aTo1} ${aSetAttr11} ${aSetAttr12} - -# Close/Open the transaction -NewCommand D - -# Forget the attribute -ForgetAll D ${aLabel} - -# Close/Open the transaction -NewCommand D - -# Undo-Redo-Undo -Undo D -Redo D -Undo D - -# Save Document -set aFile ${imagedir}/caf001-P6.cbf -SaveAs D ${aFile} -Close D - -#Open a document -Open ${aFile} D - - -# Get a value of the attribute -set IsGood 1 -set aMessage1 "Add TDataStd_ByteArray attribute: Error" -set aGetAttr1 [GetByteArray D ${aLabel}] -set aLen1 [llength ${aGetAttr1}] -set aGetAttr2 [GetByteArray D ${aLabel} ${aGuid1}] -set aLen2 [llength ${aGetAttr2}] - -if { ${aLen1} != [expr ${aTo1} - ${aFrom1} + 1] } { - set IsGood 0 - puts "aLen1=${aLen1}" - puts ${aMessage1} -} -if { ${aLen2} != [expr ${aTo1} - ${aFrom1} + 1] } { - set IsGood 0 - puts "aLen2=${aLen2}" - puts ${aMessage1} -} - -set aGetAttr11 [lindex ${aGetAttr1} 0] -set aGetAttr21 [lindex ${aGetAttr2} 0] -if { ${aGetAttr11} != ${aGetAttr21} } { - set IsGood 0 - puts "aGetAttr11=${aGetAttr11}" - puts "aGetAttr21=${aGetAttr21}" - puts ${aMessage1} -} -set aGetAttr12 [lindex ${aGetAttr1} 1] -set aGetAttr22 [lindex ${aGetAttr2} 1] -if { ${aGetAttr12} != ${aGetAttr22} } { - set IsGood 0 - puts "aGetAttr12=${aGetAttr12}" - puts "aGetAttr22=${aGetAttr22}" - puts ${aMessage1} -} - -if { ${IsGood} == 0} { - puts "Add TDataStd_ByteArray attribute: Error" -} else { - puts "Add TDataStd_ByteArray attribute: OK" -} diff --git a/tests/caf/basic/P7 b/tests/caf/basic/P7 deleted file mode 100644 index dedbb2982a..0000000000 --- a/tests/caf/basic/P7 +++ /dev/null @@ -1,90 +0,0 @@ -#INTERFACE CAF -# Basic attributes -# TDataStd_ByteArray -# -# Testing attribute: User defined (additional GUID) TDataStd_ByteArray -# -# Testing command: SetByteArray -# Testing command: GetByteArray -# - -puts "caf001-P7" -set QA_DUP 0 - -# Add an attribute to a data framework -set aFrom1 1 -set aTo1 2 -set aSetAttr11 10 -set aSetAttr12 12 -set aLabel 0:2 -set isDelta 0 -set aGuid1 "12e94517-6dbc-11d4-b9c8-0060b0ee281b" - -SetByteArray D ${aLabel} ${isDelta} ${aFrom1} ${aTo1} ${aSetAttr11} ${aSetAttr12} -SetByteArray D ${aLabel} ${isDelta} -g ${aGuid1} ${aFrom1} ${aTo1} ${aSetAttr11} ${aSetAttr12} - -# Close/Open the transaction -NewCommand D - -# Forget the attribute -ForgetAll D ${aLabel} - -# Close/Open the transaction -NewCommand D - -# Undo-Redo-Undo -Undo D -Redo D -Undo D - -# Save Document -Format D XmlOcaf -set aFile ${imagedir}/caf001-P7.xml -SaveAs D ${aFile} -Close D - -#Open a document -Open ${aFile} D - - -# Get a value of the attribute -set IsGood 1 -set aMessage1 "Add TDataStd_ByteArray attribute: Error" -set aGetAttr1 [GetByteArray D ${aLabel}] -set aLen1 [llength ${aGetAttr1}] -set aGetAttr2 [GetByteArray D ${aLabel} ${aGuid1}] -set aLen2 [llength ${aGetAttr2}] - -if { ${aLen1} != [expr ${aTo1} - ${aFrom1} + 1] } { - set IsGood 0 - puts "aLen1=${aLen1}" - puts ${aMessage1} -} -if { ${aLen2} != [expr ${aTo1} - ${aFrom1} + 1] } { - set IsGood 0 - puts "aLen2=${aLen2}" - puts ${aMessage1} -} - -set aGetAttr11 [lindex ${aGetAttr1} 0] -set aGetAttr21 [lindex ${aGetAttr2} 0] -if { ${aGetAttr11} != ${aGetAttr21} } { - set IsGood 0 - puts "aGetAttr11=${aGetAttr11}" - puts "aGetAttr21=${aGetAttr21}" - puts ${aMessage1} -} -set aGetAttr12 [lindex ${aGetAttr1} 1] -set aGetAttr22 [lindex ${aGetAttr2} 1] -if { ${aGetAttr12} != ${aGetAttr22} } { - set IsGood 0 - puts "aGetAttr12=${aGetAttr12}" - puts "aGetAttr22=${aGetAttr22}" - puts ${aMessage1} -} - -if { ${IsGood} == 0} { - puts "Add TDataStd_ByteArray attribute: Error" -} else { - puts "Add TDataStd_ByteArray attribute: OK" -} diff --git a/tests/caf/basic/Q5 b/tests/caf/basic/Q5 deleted file mode 100644 index c22e7fcce2..0000000000 --- a/tests/caf/basic/Q5 +++ /dev/null @@ -1,80 +0,0 @@ -#INTERFACE CAF -# Basic attributes -# TDataStd_ReferenceArray -# -# Testing attribute: User defined (additional GUID) TDataStd_ReferenceArray -# -# Testing command: SetRefArray -# Testing command: GetRefArray -# - -puts "caf001-Q5" -set QA_DUP 0 - -# Add an attribute to a data framework -set aFrom1 1 -set aTo1 2 -set aSetAttr11 0:3 -set aSetAttr12 0:4 -set aLabel 0:2 - -set aGuid1 "12e94518-6dbc-11d4-b9c8-0060b0ee281b" - -SetRefArray D ${aLabel} ${aFrom1} ${aTo1} ${aSetAttr11} ${aSetAttr12} -SetRefArray D ${aLabel} -g ${aGuid1} ${aFrom1} ${aTo1} ${aSetAttr11} ${aSetAttr12} - -# Close/Open the transaction -NewCommand D - -# Forget the attribute -ForgetAll D ${aLabel} - -# Close/Open the transaction -NewCommand D - -# Undo-Redo-Undo -Undo D -Redo D -Undo D - -# Get a value of the attribute -set IsGood 1 -set aMessage1 "Add TDataStd_ReferenceArray attribute: Error" -set aGetAttr1 [GetRefArray D ${aLabel}] -set aLen1 [llength ${aGetAttr1}] -set aGetAttr2 [GetRefArray D ${aLabel} ${aGuid1}] -set aLen2 [llength ${aGetAttr2}] - -if { ${aLen1} != [expr ${aTo1} - ${aFrom1} + 1] } { - set IsGood 0 - puts "aLen1=${aLen1}" - puts ${aMessage1} -} -if { ${aLen2} != [expr ${aTo1} - ${aFrom1} + 1] } { - set IsGood 0 - puts "aLen2=${aLen2}" - puts ${aMessage1} -} - -set aGetAttr11 [lindex ${aGetAttr1} 0] -set aGetAttr21 [lindex ${aGetAttr2} 0] -if { ${aGetAttr11} != ${aGetAttr21} } { - set IsGood 0 - puts "aGetAttr11=${aGetAttr11}" - puts "aGetAttr21=${aGetAttr21}" - puts ${aMessage1} -} -set aGetAttr12 [lindex ${aGetAttr1} 1] -set aGetAttr22 [lindex ${aGetAttr2} 1] -if { ${aGetAttr12} != ${aGetAttr22} } { - set IsGood 0 - puts "aGetAttr12=${aGetAttr12}" - puts "aGetAttr22=${aGetAttr22}" - puts ${aMessage1} -} - -if { ${IsGood} == 0} { - puts "Add TDataStd_ReferenceArray attribute: Error" -} else { - puts "Add TDataStd_ReferenceArray attribute: OK" -} diff --git a/tests/caf/basic/Q6 b/tests/caf/basic/Q6 deleted file mode 100644 index 267d031aa4..0000000000 --- a/tests/caf/basic/Q6 +++ /dev/null @@ -1,89 +0,0 @@ -#INTERFACE CAF -# Basic attributes -# TDataStd_ReferenceArray -# -# Testing attribute: User defined (additional GUID) TDataStd_ReferenceArray -# -# Testing command: SetRefArray -# Testing command: GetRefArray -# - -puts "caf001-Q6" -set QA_DUP 0 - -# Add an attribute to a data framework -set aFrom1 1 -set aTo1 2 -set aSetAttr11 0:3 -set aSetAttr12 0:4 -set aLabel 0:2 - -set aGuid1 "12e94518-6dbc-11d4-b9c8-0060b0ee281b" - -SetRefArray D ${aLabel} ${aFrom1} ${aTo1} ${aSetAttr11} ${aSetAttr12} -SetRefArray D ${aLabel} -g ${aGuid1} ${aFrom1} ${aTo1} ${aSetAttr11} ${aSetAttr12} - -# Close/Open the transaction -NewCommand D - -# Forget the attribute -ForgetAll D ${aLabel} - -# Close/Open the transaction -NewCommand D - -# Undo-Redo-Undo -Undo D -Redo D -Undo D - -# Save Document -set aFile ${imagedir}/caf001-Q6.cbf -SaveAs D ${aFile} -Close D - -#Open a document -Open ${aFile} D - - -# Get a value of the attribute -set IsGood 1 -set aMessage1 "Add TDataStd_ReferenceArray attribute: Error" -set aGetAttr1 [GetRefArray D ${aLabel}] -set aLen1 [llength ${aGetAttr1}] -set aGetAttr2 [GetRefArray D ${aLabel} ${aGuid1}] -set aLen2 [llength ${aGetAttr2}] - -if { ${aLen1} != [expr ${aTo1} - ${aFrom1} + 1] } { - set IsGood 0 - puts "aLen1=${aLen1}" - puts ${aMessage1} -} -if { ${aLen2} != [expr ${aTo1} - ${aFrom1} + 1] } { - set IsGood 0 - puts "aLen2=${aLen2}" - puts ${aMessage1} -} - -set aGetAttr11 [lindex ${aGetAttr1} 0] -set aGetAttr21 [lindex ${aGetAttr2} 0] -if { ${aGetAttr11} != ${aGetAttr21} } { - set IsGood 0 - puts "aGetAttr11=${aGetAttr11}" - puts "aGetAttr21=${aGetAttr21}" - puts ${aMessage1} -} -set aGetAttr12 [lindex ${aGetAttr1} 1] -set aGetAttr22 [lindex ${aGetAttr2} 1] -if { ${aGetAttr12} != ${aGetAttr22} } { - set IsGood 0 - puts "aGetAttr12=${aGetAttr12}" - puts "aGetAttr22=${aGetAttr22}" - puts ${aMessage1} -} - -if { ${IsGood} == 0} { - puts "Add TDataStd_ReferenceArray attribute: Error" -} else { - puts "Add TDataStd_ReferenceArray attribute: OK" -} diff --git a/tests/caf/basic/Q7 b/tests/caf/basic/Q7 deleted file mode 100644 index 9cbaa8fb4d..0000000000 --- a/tests/caf/basic/Q7 +++ /dev/null @@ -1,90 +0,0 @@ -#INTERFACE CAF -# Basic attributes -# TDataStd_ReferenceArray -# -# Testing attribute: User defined (additional GUID) TDataStd_ReferenceArray -# -# Testing command: SetRefArray -# Testing command: GetRefArray -# - -puts "caf001-Q7" -set QA_DUP 0 - -# Add an attribute to a data framework -set aFrom1 1 -set aTo1 2 -set aSetAttr11 0:3 -set aSetAttr12 0:4 -set aLabel 0:2 - -set aGuid1 "12e94518-6dbc-11d4-b9c8-0060b0ee281b" - -SetRefArray D ${aLabel} ${aFrom1} ${aTo1} ${aSetAttr11} ${aSetAttr12} -SetRefArray D ${aLabel} -g ${aGuid1} ${aFrom1} ${aTo1} ${aSetAttr11} ${aSetAttr12} - -# Close/Open the transaction -NewCommand D - -# Forget the attribute -ForgetAll D ${aLabel} - -# Close/Open the transaction -NewCommand D - -# Undo-Redo-Undo -Undo D -Redo D -Undo D - -# Save Document -Format D XmlOcaf -set aFile ${imagedir}/caf001-Q7.xml -SaveAs D ${aFile} -Close D - -#Open a document -Open ${aFile} D - - -# Get a value of the attribute -set IsGood 1 -set aMessage1 "Add TDataStd_BooleanArray attribute: Error" -set aGetAttr1 [GetRefArray D ${aLabel}] -set aLen1 [llength ${aGetAttr1}] -set aGetAttr2 [GetRefArray D ${aLabel} ${aGuid1}] -set aLen2 [llength ${aGetAttr2}] - -if { ${aLen1} != [expr ${aTo1} - ${aFrom1} + 1] } { - set IsGood 0 - puts "aLen1=${aLen1}" - puts ${aMessage1} -} -if { ${aLen2} != [expr ${aTo1} - ${aFrom1} + 1] } { - set IsGood 0 - puts "aLen2=${aLen2}" - puts ${aMessage1} -} - -set aGetAttr11 [lindex ${aGetAttr1} 0] -set aGetAttr21 [lindex ${aGetAttr2} 0] -if { ${aGetAttr11} != ${aGetAttr21} } { - set IsGood 0 - puts "aGetAttr11=${aGetAttr11}" - puts "aGetAttr21=${aGetAttr21}" - puts ${aMessage1} -} -set aGetAttr12 [lindex ${aGetAttr1} 1] -set aGetAttr22 [lindex ${aGetAttr2} 1] -if { ${aGetAttr12} != ${aGetAttr22} } { - set IsGood 0 - puts "aGetAttr12=${aGetAttr12}" - puts "aGetAttr22=${aGetAttr22}" - puts ${aMessage1} -} - -if { ${IsGood} == 0} { - puts "Add TDataStd_ReferenceArray attribute: Error" -} else { - puts "Add TDataStd_ReferenceArray attribute: OK" -} diff --git a/tests/caf/basic/R5 b/tests/caf/basic/R5 deleted file mode 100644 index 9d366815c1..0000000000 --- a/tests/caf/basic/R5 +++ /dev/null @@ -1,74 +0,0 @@ -#INTERFACE CAF -# Basic attributes -# TDataStd_RealList -# -# Testing attribute: User defined (additional GUID) TDataStd_RealList -# -# Testing command: SetRealList -# Testing command: GetRealList -# - -puts "caf001-R5" -set QA_DUP 0 - -# Add an attribute to a data framework -set aSetAttr11 3. -set aSetAttr12 4. -set aLabel 0:2 - -set aGuid1 "12e94521-6dbc-11d4-b9c8-0060b0ee281b" - -SetRealList D ${aLabel} ${aSetAttr11} ${aSetAttr12} -SetRealList D ${aLabel} -g ${aGuid1} ${aSetAttr11} ${aSetAttr12} - -# Close/Open the transaction -NewCommand D - -# Forget the attribute -ForgetAll D ${aLabel} - -# Close/Open the transaction -NewCommand D - -# Undo-Redo-Undo -Undo D -Redo D -Undo D - -# Get a value of the attribute -set IsGood 1 -set aMessage1 "Add TDataStd_RealList attribute: Error" -set aGetAttr1 [GetRealList D ${aLabel}] -set aLen1 [llength ${aGetAttr1}] -set aGetAttr2 [GetRealList D ${aLabel} ${aGuid1}] -set aLen2 [llength ${aGetAttr2}] - -if { ${aLen1} != ${aLen2}} { - set IsGood 0 - puts "aLen1=${aLen1}" - puts "aLen2=${aLen2}" - puts ${aMessage1} -} - -set aGetAttr11 [lindex ${aGetAttr1} 0] -set aGetAttr21 [lindex ${aGetAttr2} 0] -if { ${aGetAttr11} != ${aGetAttr21} } { - set IsGood 0 - puts "aGetAttr11=${aGetAttr11}" - puts "aGetAttr21=${aGetAttr21}" - puts ${aMessage1} -} -set aGetAttr12 [lindex ${aGetAttr1} 1] -set aGetAttr22 [lindex ${aGetAttr2} 1] -if { ${aGetAttr12} != ${aGetAttr22} } { - set IsGood 0 - puts "aGetAttr12=${aGetAttr12}" - puts "aGetAttr22=${aGetAttr22}" - puts ${aMessage1} -} - -if { ${IsGood} == 0} { - puts "Add TDataStd_RealList attribute: Error" -} else { - puts "Add TDataStd_RealList attribute: OK" -} diff --git a/tests/caf/basic/R6 b/tests/caf/basic/R6 deleted file mode 100644 index e4beb6244a..0000000000 --- a/tests/caf/basic/R6 +++ /dev/null @@ -1,82 +0,0 @@ -#INTERFACE CAF -# Basic attributes -# TDataStd_RealList -# -# Testing attribute: User defined (additional GUID) TDataStd_RealList -# -# Testing command: SetRealList -# Testing command: GetRealList -# - -puts "caf001-R6" -set QA_DUP 0 - -# Add an attributes to a data framework -set aSetAttr11 3. -set aSetAttr12 4. -set aLabel 0:2 - -set aGuid1 "12e94521-6dbc-11d4-b9c8-0060b0ee281b" - -SetRealList D ${aLabel} ${aSetAttr11} ${aSetAttr12} -SetRealList D ${aLabel} -g ${aGuid1} ${aSetAttr11} ${aSetAttr12} - -# Close/Open the transaction -NewCommand D - -# Forget the attribute -ForgetAll D ${aLabel} - -# Close/Open the transaction -NewCommand D - -# Undo-Redo-Undo -Undo D -Redo D -Undo D - -# Save Document -set aFile ${imagedir}/caf001-R6.cbf -SaveAs D ${aFile}; -Close D - -#Open a document -Open ${aFile} D - -# Get a value of the attribute -set IsGood 1 -set aMessage1 "Add TDataStd_RealList attribute: Error" -set aGetAttr1 [GetRealList D ${aLabel}] -set aLen1 [llength ${aGetAttr1}] -set aGetAttr2 [GetRealList D ${aLabel} ${aGuid1}] -set aLen2 [llength ${aGetAttr2}] - -if { ${aLen1} != ${aLen2}} { - set IsGood 0 - puts "aLen1=${aLen1}" - puts "aLen2=${aLen2}" - puts ${aMessage1} -} - -set aGetAttr11 [lindex ${aGetAttr1} 0] -set aGetAttr21 [lindex ${aGetAttr2} 0] -if { ${aGetAttr11} != ${aGetAttr21} } { - set IsGood 0 - puts "aGetAttr11=${aGetAttr11}" - puts "aGetAttr21=${aGetAttr21}" - puts ${aMessage1} -} -set aGetAttr12 [lindex ${aGetAttr1} 1] -set aGetAttr22 [lindex ${aGetAttr2} 1] -if { ${aGetAttr12} != ${aGetAttr22} } { - set IsGood 0 - puts "aGetAttr12=${aGetAttr12}" - puts "aGetAttr22=${aGetAttr22}" - puts ${aMessage1} -} - -if { ${IsGood} == 0} { - puts "Add TDataStd_RealList attribute: Error" -} else { - puts "Add TDataStd_RealList attribute: OK" -} diff --git a/tests/caf/basic/R7 b/tests/caf/basic/R7 deleted file mode 100644 index f315282004..0000000000 --- a/tests/caf/basic/R7 +++ /dev/null @@ -1,83 +0,0 @@ -#INTERFACE CAF -# Basic attributes -# TDataStd_RealList -# -# Testing attribute: User defined (additional GUID) TDataStd_RealList -# -# Testing command: SetRealList -# Testing command: GetRealList -# - -puts "caf001-R7" -set QA_DUP 0 - -# Add an attributes to a data framework -set aSetAttr11 3. -set aSetAttr12 4. -set aLabel 0:2 - -set aGuid1 "12e94521-6dbc-11d4-b9c8-0060b0ee281b" - -SetRealList D ${aLabel} ${aSetAttr11} ${aSetAttr12} -SetRealList D ${aLabel} -g ${aGuid1} ${aSetAttr11} ${aSetAttr12} - -# Close/Open the transaction -NewCommand D - -# Forget the attribute -ForgetAll D ${aLabel} - -# Close/Open the transaction -NewCommand D - -# Undo-Redo-Undo -Undo D -Redo D -Undo D - -# Save Document -Format D XmlOcaf -set aFile ${imagedir}/caf001-R7.xml -SaveAs D ${aFile}; -Close D - -#Open a document -Open ${aFile} D - -# Get a value of the attribute -set IsGood 1 -set aMessage1 "Add TDataStd_RealList attribute: Error" -set aGetAttr1 [GetRealList D ${aLabel}] -set aLen1 [llength ${aGetAttr1}] -set aGetAttr2 [GetRealList D ${aLabel} ${aGuid1}] -set aLen2 [llength ${aGetAttr2}] - -if { ${aLen1} != ${aLen2}} { - set IsGood 0 - puts "aLen1=${aLen1}" - puts "aLen2=${aLen2}" - puts ${aMessage1} -} - -set aGetAttr11 [lindex ${aGetAttr1} 0] -set aGetAttr21 [lindex ${aGetAttr2} 0] -if { ${aGetAttr11} != ${aGetAttr21} } { - set IsGood 0 - puts "aGetAttr11=${aGetAttr11}" - puts "aGetAttr21=${aGetAttr21}" - puts ${aMessage1} -} -set aGetAttr12 [lindex ${aGetAttr1} 1] -set aGetAttr22 [lindex ${aGetAttr2} 1] -if { ${aGetAttr12} != ${aGetAttr22} } { - set IsGood 0 - puts "aGetAttr12=${aGetAttr12}" - puts "aGetAttr22=${aGetAttr22}" - puts ${aMessage1} -} - -if { ${IsGood} == 0} { - puts "Add TDataStd_RealList attribute: Error" -} else { - puts "Add TDataStd_RealList attribute: OK" -} diff --git a/tests/caf/basic/S5 b/tests/caf/basic/S5 deleted file mode 100644 index e8cafe43b7..0000000000 --- a/tests/caf/basic/S5 +++ /dev/null @@ -1,74 +0,0 @@ -#INTERFACE CAF -# Basic attributes -# TDataStd_IntegerList -# -# Testing attribute: User defined (additional GUID) TDataStd_IntegerList -# -# Testing command: SetIntegerList -# Testing command: GetIntegerList -# - -puts "caf001-S5" -set QA_DUP 0 - -# Add an attribute to a data framework -set aSetAttr11 33 -set aSetAttr12 44 -set aLabel 0:2 - -set aGuid1 "12e94531-6dbc-11d4-b9c8-0060b0ee281b" - -SetIntegerList D ${aLabel} ${aSetAttr11} ${aSetAttr12} -SetIntegerList D ${aLabel} -g ${aGuid1} ${aSetAttr11} ${aSetAttr12} - -# Close/Open the transaction -NewCommand D - -# Forget the attribute -ForgetAll D ${aLabel} - -# Close/Open the transaction -NewCommand D - -# Undo-Redo-Undo -Undo D -Redo D -Undo D - -# Get a value of the attribute -set IsGood 1 -set aMessage1 "Add TDataStd_IntegerList attribute: Error" -set aGetAttr1 [GetIntegerList D ${aLabel}] -set aLen1 [llength ${aGetAttr1}] -set aGetAttr2 [GetIntegerList D ${aLabel} ${aGuid1}] -set aLen2 [llength ${aGetAttr2}] - -if { ${aLen1} != ${aLen2}} { - set IsGood 0 - puts "aLen1=${aLen1}" - puts "aLen2=${aLen2}" - puts ${aMessage1} -} - -set aGetAttr11 [lindex ${aGetAttr1} 0] -set aGetAttr21 [lindex ${aGetAttr2} 0] -if { ${aGetAttr11} != ${aGetAttr21} } { - set IsGood 0 - puts "aGetAttr11=${aGetAttr11}" - puts "aGetAttr21=${aGetAttr21}" - puts ${aMessage1} -} -set aGetAttr12 [lindex ${aGetAttr1} 1] -set aGetAttr22 [lindex ${aGetAttr2} 1] -if { ${aGetAttr12} != ${aGetAttr22} } { - set IsGood 0 - puts "aGetAttr12=${aGetAttr12}" - puts "aGetAttr22=${aGetAttr22}" - puts ${aMessage1} -} - -if { ${IsGood} == 0} { - puts "Add TDataStd_IntegerList attribute: Error" -} else { - puts "Add TDataStd_IntegerList attribute: OK" -} diff --git a/tests/caf/basic/S6 b/tests/caf/basic/S6 deleted file mode 100644 index 42d68a998d..0000000000 --- a/tests/caf/basic/S6 +++ /dev/null @@ -1,82 +0,0 @@ -#INTERFACE CAF -# Basic attributes -# TDataStd_IntegerList -# -# Testing attribute: User defined (additional GUID) TDataStd_IntegerList -# -# Testing command: SetIntegerList -# Testing command: GetIntegerList -# - -puts "caf001-S6" -set QA_DUP 0 - -# Add an attributes to a data framework -set aSetAttr11 33 -set aSetAttr12 44 -set aLabel 0:2 - -set aGuid1 "12e94531-6dbc-11d4-b9c8-0060b0ee281b" - -SetIntegerList D ${aLabel} ${aSetAttr11} ${aSetAttr12} -SetIntegerList D ${aLabel} -g ${aGuid1} ${aSetAttr11} ${aSetAttr12} - -# Close/Open the transaction -NewCommand D - -# Forget the attribute -ForgetAll D ${aLabel} - -# Close/Open the transaction -NewCommand D - -# Undo-Redo-Undo -Undo D -Redo D -Undo D - -# Save Document -set aFile ${imagedir}/caf001-S6.cbf -SaveAs D ${aFile}; -Close D - -#Open a document -Open ${aFile} D - -# Get a value of the attribute -set IsGood 1 -set aMessage1 "Add TDataStd_IntegerList attribute: Error" -set aGetAttr1 [GetIntegerList D ${aLabel}] -set aLen1 [llength ${aGetAttr1}] -set aGetAttr2 [GetIntegerList D ${aLabel} ${aGuid1}] -set aLen2 [llength ${aGetAttr2}] - -if { ${aLen1} != ${aLen2}} { - set IsGood 0 - puts "aLen1=${aLen1}" - puts "aLen2=${aLen2}" - puts ${aMessage1} -} - -set aGetAttr11 [lindex ${aGetAttr1} 0] -set aGetAttr21 [lindex ${aGetAttr2} 0] -if { ${aGetAttr11} != ${aGetAttr21} } { - set IsGood 0 - puts "aGetAttr11=${aGetAttr11}" - puts "aGetAttr21=${aGetAttr21}" - puts ${aMessage1} -} -set aGetAttr12 [lindex ${aGetAttr1} 1] -set aGetAttr22 [lindex ${aGetAttr2} 1] -if { ${aGetAttr12} != ${aGetAttr22} } { - set IsGood 0 - puts "aGetAttr12=${aGetAttr12}" - puts "aGetAttr22=${aGetAttr22}" - puts ${aMessage1} -} - -if { ${IsGood} == 0} { - puts "Add TDataStd_IntegerList attribute: Error" -} else { - puts "Add TDataStd_IntegerList attribute: OK" -} diff --git a/tests/caf/basic/S7 b/tests/caf/basic/S7 deleted file mode 100644 index 63887e90ad..0000000000 --- a/tests/caf/basic/S7 +++ /dev/null @@ -1,83 +0,0 @@ -#INTERFACE CAF -# Basic attributes -# TDataStd_IntegerList -# -# Testing attribute: User defined (additional GUID) TDataStd_IntegerList -# -# Testing command: SetIntegerList -# Testing command: GetIntegerList -# - -puts "caf001-S7" -set QA_DUP 0 - -# Add an attributes to a data framework -set aSetAttr11 33 -set aSetAttr12 44 -set aLabel 0:2 - -set aGuid1 "12e94531-6dbc-11d4-b9c8-0060b0ee281b" - -SetIntegerList D ${aLabel} ${aSetAttr11} ${aSetAttr12} -SetIntegerList D ${aLabel} -g ${aGuid1} ${aSetAttr11} ${aSetAttr12} - -# Close/Open the transaction -NewCommand D - -# Forget the attribute -ForgetAll D ${aLabel} - -# Close/Open the transaction -NewCommand D - -# Undo-Redo-Undo -Undo D -Redo D -Undo D - -# Save Document -Format D XmlOcaf -set aFile ${imagedir}/caf001-S7.xml -SaveAs D ${aFile}; -Close D - -#Open a document -Open ${aFile} D - -# Get a value of the attribute -set IsGood 1 -set aMessage1 "Add TDataStd_IntegerList attribute: Error" -set aGetAttr1 [GetIntegerList D ${aLabel}] -set aLen1 [llength ${aGetAttr1}] -set aGetAttr2 [GetIntegerList D ${aLabel} ${aGuid1}] -set aLen2 [llength ${aGetAttr2}] - -if { ${aLen1} != ${aLen2}} { - set IsGood 0 - puts "aLen1=${aLen1}" - puts "aLen2=${aLen2}" - puts ${aMessage1} -} - -set aGetAttr11 [lindex ${aGetAttr1} 0] -set aGetAttr21 [lindex ${aGetAttr2} 0] -if { ${aGetAttr11} != ${aGetAttr21} } { - set IsGood 0 - puts "aGetAttr11=${aGetAttr11}" - puts "aGetAttr21=${aGetAttr21}" - puts ${aMessage1} -} -set aGetAttr12 [lindex ${aGetAttr1} 1] -set aGetAttr22 [lindex ${aGetAttr2} 1] -if { ${aGetAttr12} != ${aGetAttr22} } { - set IsGood 0 - puts "aGetAttr12=${aGetAttr12}" - puts "aGetAttr22=${aGetAttr22}" - puts ${aMessage1} -} - -if { ${IsGood} == 0} { - puts "Add TDataStd_IntegerList attribute: Error" -} else { - puts "Add TDataStd_IntegerList attribute: OK" -} diff --git a/tests/caf/basic/T5 b/tests/caf/basic/T5 deleted file mode 100644 index b590243806..0000000000 --- a/tests/caf/basic/T5 +++ /dev/null @@ -1,74 +0,0 @@ -#INTERFACE CAF -# Basic attributes -# TDataStd_ExtStringList -# -# Testing attribute: User defined (additional GUID) TDataStd_ExtStringList -# -# Testing command: SetExtStringList -# Testing command: GetExtStringList -# - -puts "caf001-T5" -set QA_DUP 0 - -# Add an attribute to a data framework -set aSetAttr11 aaaaa -set aSetAttr12 bbbbbb -set aLabel 0:2 - -set aGuid1 "12e94541-6dbc-11d4-b9c8-0060b0ee281b" - -SetExtStringList D ${aLabel} ${aSetAttr11} ${aSetAttr12} -SetExtStringList D ${aLabel} -g ${aGuid1} ${aSetAttr11} ${aSetAttr12} - -# Close/Open the transaction -NewCommand D - -# Forget the attribute -ForgetAll D ${aLabel} - -# Close/Open the transaction -NewCommand D - -# Undo-Redo-Undo -Undo D -Redo D -Undo D - -# Get a value of the attribute -set IsGood 1 -set aMessage1 "Add TDataStd_ExtStringList attribute: Error" -set aGetAttr1 [GetExtStringList D ${aLabel}] -set aLen1 [llength ${aGetAttr1}] -set aGetAttr2 [GetExtStringList D ${aLabel} ${aGuid1}] -set aLen2 [llength ${aGetAttr2}] - -if { ${aLen1} != ${aLen2}} { - set IsGood 0 - puts "aLen1=${aLen1}" - puts "aLen2=${aLen2}" - puts ${aMessage1} -} - -set aGetAttr11 [lindex ${aGetAttr1} 0] -set aGetAttr21 [lindex ${aGetAttr2} 0] -if { ${aGetAttr11} != ${aGetAttr21} } { - set IsGood 0 - puts "aGetAttr11=${aGetAttr11}" - puts "aGetAttr21=${aGetAttr21}" - puts ${aMessage1} -} -set aGetAttr12 [lindex ${aGetAttr1} 1] -set aGetAttr22 [lindex ${aGetAttr2} 1] -if { ${aGetAttr12} != ${aGetAttr22} } { - set IsGood 0 - puts "aGetAttr12=${aGetAttr12}" - puts "aGetAttr22=${aGetAttr22}" - puts ${aMessage1} -} - -if { ${IsGood} == 0} { - puts "Add TDataStd_ExtStringList attribute: Error" -} else { - puts "Add TDataStd_ExtStringList attribute: OK" -} diff --git a/tests/caf/basic/T6 b/tests/caf/basic/T6 deleted file mode 100644 index a8824d0a25..0000000000 --- a/tests/caf/basic/T6 +++ /dev/null @@ -1,82 +0,0 @@ -#INTERFACE CAF -# Basic attributes -# TDataStd_ExtStringList -# -# Testing attribute: User defined (additional GUID) TDataStd_ExtStringList -# -# Testing command: SetExtStringList -# Testing command: GetExtStringList -# - -puts "caf001-T6" -set QA_DUP 0 - -# Add an attributes to a data framework -set aSetAttr11 xxxx -set aSetAttr12 yyyyy -set aLabel 0:2 - -set aGuid1 "12e94541-6dbc-11d4-b9c8-0060b0ee281b" - -SetExtStringList D ${aLabel} ${aSetAttr11} ${aSetAttr12} -SetExtStringList D ${aLabel} -g ${aGuid1} ${aSetAttr11} ${aSetAttr12} - -# Close/Open the transaction -NewCommand D - -# Forget the attribute -ForgetAll D ${aLabel} - -# Close/Open the transaction -NewCommand D - -# Undo-Redo-Undo -Undo D -Redo D -Undo D - -# Save Document -set aFile ${imagedir}/caf001-T6.cbf -SaveAs D ${aFile}; -Close D - -#Open a document -Open ${aFile} D - -# Get a value of the attribute -set IsGood 1 -set aMessage1 "Add TDataStd_ExtStringList attribute: Error" -set aGetAttr1 [GetExtStringList D ${aLabel}] -set aLen1 [llength ${aGetAttr1}] -set aGetAttr2 [GetExtStringList D ${aLabel} ${aGuid1}] -set aLen2 [llength ${aGetAttr2}] - -if { ${aLen1} != ${aLen2}} { - set IsGood 0 - puts "aLen1=${aLen1}" - puts "aLen2=${aLen2}" - puts ${aMessage1} -} - -set aGetAttr11 [lindex ${aGetAttr1} 0] -set aGetAttr21 [lindex ${aGetAttr2} 0] -if { ${aGetAttr11} != ${aGetAttr21} } { - set IsGood 0 - puts "aGetAttr11=${aGetAttr11}" - puts "aGetAttr21=${aGetAttr21}" - puts ${aMessage1} -} -set aGetAttr12 [lindex ${aGetAttr1} 1] -set aGetAttr22 [lindex ${aGetAttr2} 1] -if { ${aGetAttr12} != ${aGetAttr22} } { - set IsGood 0 - puts "aGetAttr12=${aGetAttr12}" - puts "aGetAttr22=${aGetAttr22}" - puts ${aMessage1} -} - -if { ${IsGood} == 0} { - puts "Add TDataStd_ExtStringList attribute: Error" -} else { - puts "Add TDataStd_ExtStringList attribute: OK" -} diff --git a/tests/caf/basic/T7 b/tests/caf/basic/T7 deleted file mode 100644 index b162e7851d..0000000000 --- a/tests/caf/basic/T7 +++ /dev/null @@ -1,83 +0,0 @@ -#INTERFACE CAF -# Basic attributes -# TDataStd_ExtStringList -# -# Testing attribute: User defined (additional GUID) TDataStd_ExtStringList -# -# Testing command: SetExtStringList -# Testing command: GetExtStringList -# - -puts "caf001-T7" -set QA_DUP 0 - -# Add an attributes to a data framework -set aSetAttr11 xxxx -set aSetAttr12 yyyyy -set aLabel 0:2 - -set aGuid1 "12e94541-6dbc-11d4-b9c8-0060b0ee281b" - -SetExtStringList D ${aLabel} ${aSetAttr11} ${aSetAttr12} -SetExtStringList D ${aLabel} -g ${aGuid1} ${aSetAttr11} ${aSetAttr12} - -# Close/Open the transaction -NewCommand D - -# Forget the attribute -ForgetAll D ${aLabel} - -# Close/Open the transaction -NewCommand D - -# Undo-Redo-Undo -Undo D -Redo D -Undo D - -# Save Document -Format D XmlOcaf -set aFile ${imagedir}/caf001-T7.xml -SaveAs D ${aFile}; -Close D - -#Open a document -Open ${aFile} D - -# Get a value of the attribute -set IsGood 1 -set aMessage1 "Add TDataStd_ExtStringList attribute: Error" -set aGetAttr1 [GetExtStringList D ${aLabel}] -set aLen1 [llength ${aGetAttr1}] -set aGetAttr2 [GetExtStringList D ${aLabel} ${aGuid1}] -set aLen2 [llength ${aGetAttr2}] - -if { ${aLen1} != ${aLen2}} { - set IsGood 0 - puts "aLen1=${aLen1}" - puts "aLen2=${aLen2}" - puts ${aMessage1} -} - -set aGetAttr11 [lindex ${aGetAttr1} 0] -set aGetAttr21 [lindex ${aGetAttr2} 0] -if { ${aGetAttr11} != ${aGetAttr21} } { - set IsGood 0 - puts "aGetAttr11=${aGetAttr11}" - puts "aGetAttr21=${aGetAttr21}" - puts ${aMessage1} -} -set aGetAttr12 [lindex ${aGetAttr1} 1] -set aGetAttr22 [lindex ${aGetAttr2} 1] -if { ${aGetAttr12} != ${aGetAttr22} } { - set IsGood 0 - puts "aGetAttr12=${aGetAttr12}" - puts "aGetAttr22=${aGetAttr22}" - puts ${aMessage1} -} - -if { ${IsGood} == 0} { - puts "Add TDataStd_ExtStringList attribute: Error" -} else { - puts "Add TDataStd_ExtStringList attribute: OK" -} diff --git a/tests/caf/basic/U5 b/tests/caf/basic/U5 deleted file mode 100644 index 166d2eb7d9..0000000000 --- a/tests/caf/basic/U5 +++ /dev/null @@ -1,74 +0,0 @@ -#INTERFACE CAF -# Basic attributes -# TDataStd_BooleanList -# -# Testing attribute: User defined (additional GUID) TDataStd_BooleanList -# -# Testing command: SetBooleanList -# Testing command: GetBooleanList -# - -puts "caf001-U5" -set QA_DUP 0 - -# Add an attribute to a data framework -set aSetAttr11 0 -set aSetAttr12 1 -set aLabel 0:2 - -set aGuid1 "12e94551-6dbc-11d4-b9c8-0060b0ee281b" - -SetBooleanList D ${aLabel} ${aSetAttr11} ${aSetAttr12} -SetBooleanList D ${aLabel} -g ${aGuid1} ${aSetAttr11} ${aSetAttr12} - -# Close/Open the transaction -NewCommand D - -# Forget the attribute -ForgetAll D ${aLabel} - -# Close/Open the transaction -NewCommand D - -# Undo-Redo-Undo -Undo D -Redo D -Undo D - -# Get a value of the attribute -set IsGood 1 -set aMessage1 "Add TDataStd_BooleanList attribute: Error" -set aGetAttr1 [GetBooleanList D ${aLabel}] -set aLen1 [llength ${aGetAttr1}] -set aGetAttr2 [GetBooleanList D ${aLabel} ${aGuid1}] -set aLen2 [llength ${aGetAttr2}] - -if { ${aLen1} != ${aLen2}} { - set IsGood 0 - puts "aLen1=${aLen1}" - puts "aLen2=${aLen2}" - puts ${aMessage1} -} - -set aGetAttr11 [lindex ${aGetAttr1} 0] -set aGetAttr21 [lindex ${aGetAttr2} 0] -if { ${aGetAttr11} != ${aGetAttr21} } { - set IsGood 0 - puts "aGetAttr11=${aGetAttr11}" - puts "aGetAttr21=${aGetAttr21}" - puts ${aMessage1} -} -set aGetAttr12 [lindex ${aGetAttr1} 1] -set aGetAttr22 [lindex ${aGetAttr2} 1] -if { ${aGetAttr12} != ${aGetAttr22} } { - set IsGood 0 - puts "aGetAttr12=${aGetAttr12}" - puts "aGetAttr22=${aGetAttr22}" - puts ${aMessage1} -} - -if { ${IsGood} == 0} { - puts "Add TDataStd_BooleanList attribute: Error" -} else { - puts "Add TDataStd_BooleanList attribute: OK" -} diff --git a/tests/caf/basic/U6 b/tests/caf/basic/U6 deleted file mode 100644 index c11d05a731..0000000000 --- a/tests/caf/basic/U6 +++ /dev/null @@ -1,82 +0,0 @@ -#INTERFACE CAF -# Basic attributes -# TDataStd_BooleanList -# -# Testing attribute: User defined (additional GUID) TDataStd_BooleanList -# -# Testing command: SetBooleanList -# Testing command: GetBooleanList -# - -puts "caf001-U6" -set QA_DUP 0 - -# Add an attributes to a data framework -set aSetAttr11 0 -set aSetAttr12 1 -set aLabel 0:2 - -set aGuid1 "12e94551-6dbc-11d4-b9c8-0060b0ee281b" - -SetBooleanList D ${aLabel} ${aSetAttr11} ${aSetAttr12} -SetBooleanList D ${aLabel} -g ${aGuid1} ${aSetAttr11} ${aSetAttr12} - -# Close/Open the transaction -NewCommand D - -# Forget the attribute -ForgetAll D ${aLabel} - -# Close/Open the transaction -NewCommand D - -# Undo-Redo-Undo -Undo D -Redo D -Undo D - -# Save Document -set aFile ${imagedir}/caf001-U6.cbf -SaveAs D ${aFile}; -Close D - -#Open a document -Open ${aFile} D - -# Get a value of the attribute -set IsGood 1 -set aMessage1 "Add TDataStd_BooleanList attribute: Error" -set aGetAttr1 [GetBooleanList D ${aLabel}] -set aLen1 [llength ${aGetAttr1}] -set aGetAttr2 [GetBooleanList D ${aLabel} ${aGuid1}] -set aLen2 [llength ${aGetAttr2}] - -if { ${aLen1} != ${aLen2}} { - set IsGood 0 - puts "aLen1=${aLen1}" - puts "aLen2=${aLen2}" - puts ${aMessage1} -} - -set aGetAttr11 [lindex ${aGetAttr1} 0] -set aGetAttr21 [lindex ${aGetAttr2} 0] -if { ${aGetAttr11} != ${aGetAttr21} } { - set IsGood 0 - puts "aGetAttr11=${aGetAttr11}" - puts "aGetAttr21=${aGetAttr21}" - puts ${aMessage1} -} -set aGetAttr12 [lindex ${aGetAttr1} 1] -set aGetAttr22 [lindex ${aGetAttr2} 1] -if { ${aGetAttr12} != ${aGetAttr22} } { - set IsGood 0 - puts "aGetAttr12=${aGetAttr12}" - puts "aGetAttr22=${aGetAttr22}" - puts ${aMessage1} -} - -if { ${IsGood} == 0} { - puts "Add TDataStd_BooleanList attribute: Error" -} else { - puts "Add TDataStd_BooleanList attribute: OK" -} diff --git a/tests/caf/basic/U7 b/tests/caf/basic/U7 deleted file mode 100644 index 6681647094..0000000000 --- a/tests/caf/basic/U7 +++ /dev/null @@ -1,83 +0,0 @@ -#INTERFACE CAF -# Basic attributes -# TDataStd_BooleanList -# -# Testing attribute: User defined (additional GUID) TDataStd_BooleanList -# -# Testing command: SetBooleanList -# Testing command: GetBooleanList -# - -puts "caf001-U7" -set QA_DUP 0 - -# Add an attributes to a data framework -set aSetAttr11 0 -set aSetAttr12 1 -set aLabel 0:2 - -set aGuid1 "12e94551-6dbc-11d4-b9c8-0060b0ee281b" - -SetBooleanList D ${aLabel} ${aSetAttr11} ${aSetAttr12} -SetBooleanList D ${aLabel} -g ${aGuid1} ${aSetAttr11} ${aSetAttr12} - -# Close/Open the transaction -NewCommand D - -# Forget the attribute -ForgetAll D ${aLabel} - -# Close/Open the transaction -NewCommand D - -# Undo-Redo-Undo -Undo D -Redo D -Undo D - -# Save Document -Format D XmlOcaf -set aFile ${imagedir}/caf001-U7.xml -SaveAs D ${aFile}; -Close D - -#Open a document -Open ${aFile} D - -# Get a value of the attribute -set IsGood 1 -set aMessage1 "Add TDataStd_BooleanList attribute: Error" -set aGetAttr1 [GetBooleanList D ${aLabel}] -set aLen1 [llength ${aGetAttr1}] -set aGetAttr2 [GetBooleanList D ${aLabel} ${aGuid1}] -set aLen2 [llength ${aGetAttr2}] - -if { ${aLen1} != ${aLen2}} { - set IsGood 0 - puts "aLen1=${aLen1}" - puts "aLen2=${aLen2}" - puts ${aMessage1} -} - -set aGetAttr11 [lindex ${aGetAttr1} 0] -set aGetAttr21 [lindex ${aGetAttr2} 0] -if { ${aGetAttr11} != ${aGetAttr21} } { - set IsGood 0 - puts "aGetAttr11=${aGetAttr11}" - puts "aGetAttr21=${aGetAttr21}" - puts ${aMessage1} -} -set aGetAttr12 [lindex ${aGetAttr1} 1] -set aGetAttr22 [lindex ${aGetAttr2} 1] -if { ${aGetAttr12} != ${aGetAttr22} } { - set IsGood 0 - puts "aGetAttr12=${aGetAttr12}" - puts "aGetAttr22=${aGetAttr22}" - puts ${aMessage1} -} - -if { ${IsGood} == 0} { - puts "Add TDataStd_BooleanList attribute: Error" -} else { - puts "Add TDataStd_BooleanList attribute: OK" -} diff --git a/tests/caf/basic/V5 b/tests/caf/basic/V5 deleted file mode 100644 index 9b40e2aea7..0000000000 --- a/tests/caf/basic/V5 +++ /dev/null @@ -1,74 +0,0 @@ -#INTERFACE CAF -# Basic attributes -# TDataStd_ReferenceList -# -# Testing attribute: User defined (additional GUID) TDataStd_ReferenceList -# -# Testing command: SetReferenceList -# Testing command: GetReferenceList -# - -puts "caf001-V5" -set QA_DUP 0 - -# Add an attribute to a data framework -set aSetAttr11 0:3 -set aSetAttr12 0:4 -set aLabel 0:2 - -set aGuid1 "12e94561-6dbc-11d4-b9c8-0060b0ee281b" - -SetReferenceList D ${aLabel} ${aSetAttr11} ${aSetAttr12} -SetReferenceList D ${aLabel} -g ${aGuid1} ${aSetAttr11} ${aSetAttr12} - -# Close/Open the transaction -NewCommand D - -# Forget the attribute -ForgetAll D ${aLabel} - -# Close/Open the transaction -NewCommand D - -# Undo-Redo-Undo -Undo D -Redo D -Undo D - -# Get a value of the attribute -set IsGood 1 -set aMessage1 "Add TDataStd_ReferenceList attribute: Error" -set aGetAttr1 [GetReferenceList D ${aLabel}] -set aLen1 [llength ${aGetAttr1}] -set aGetAttr2 [GetReferenceList D ${aLabel} ${aGuid1}] -set aLen2 [llength ${aGetAttr2}] - -if { ${aLen1} != ${aLen2}} { - set IsGood 0 - puts "aLen1=${aLen1}" - puts "aLen2=${aLen2}" - puts ${aMessage1} -} - -set aGetAttr11 [lindex ${aGetAttr1} 0] -set aGetAttr21 [lindex ${aGetAttr2} 0] -if { ${aGetAttr11} != ${aGetAttr21} } { - set IsGood 0 - puts "aGetAttr11=${aGetAttr11}" - puts "aGetAttr21=${aGetAttr21}" - puts ${aMessage1} -} -set aGetAttr12 [lindex ${aGetAttr1} 1] -set aGetAttr22 [lindex ${aGetAttr2} 1] -if { ${aGetAttr12} != ${aGetAttr22} } { - set IsGood 0 - puts "aGetAttr12=${aGetAttr12}" - puts "aGetAttr22=${aGetAttr22}" - puts ${aMessage1} -} - -if { ${IsGood} == 0} { - puts "Add TDataStd_ReferenceList attribute: Error" -} else { - puts "Add TDataStd_ReferenceList attribute: OK" -} diff --git a/tests/caf/basic/V6 b/tests/caf/basic/V6 deleted file mode 100644 index ad5ee725da..0000000000 --- a/tests/caf/basic/V6 +++ /dev/null @@ -1,83 +0,0 @@ -#INTERFACE CAF -# Basic attributes -# TDataStd_ReferenceList -# -# Testing attribute: User defined (additional GUID) TDataStd_ReferenceList -# -# Testing command: SetReferenceList -# Testing command: GetReferenceList -# - -puts "caf001-V6" -set QA_DUP 0 - -# Add an attribute to a data framework -set aSetAttr11 0:3 -set aSetAttr12 0:4 -set aLabel 0:2 - -set aGuid1 "12e94561-6dbc-11d4-b9c8-0060b0ee281b" - -SetReferenceList D ${aLabel} ${aSetAttr11} ${aSetAttr12} -SetReferenceList D ${aLabel} -g ${aGuid1} ${aSetAttr11} ${aSetAttr12} - -# Close/Open the transaction -NewCommand D - -# Forget the attribute -ForgetAll D ${aLabel} - -# Close/Open the transaction -NewCommand D - -# Undo-Redo-Undo -Undo D -Redo D -Undo D - -# Save Document -set aFile ${imagedir}/caf001-V6.cbf -SaveAs D ${aFile} -Close D - -#Open a document -Open ${aFile} D - - -# Get a value of the attribute -set IsGood 1 -set aMessage1 "Add TDataStd_ReferenceList attribute: Error" -set aGetAttr1 [GetReferenceList D ${aLabel}] -set aLen1 [llength ${aGetAttr1}] -set aGetAttr2 [GetReferenceList D ${aLabel} ${aGuid1}] -set aLen2 [llength ${aGetAttr2}] - -if { ${aLen1} != ${aLen2}} { - set IsGood 0 - puts "aLen1=${aLen1}" - puts "aLen2=${aLen2}" - puts ${aMessage1} -} - -set aGetAttr11 [lindex ${aGetAttr1} 0] -set aGetAttr21 [lindex ${aGetAttr2} 0] -if { ${aGetAttr11} != ${aGetAttr21} } { - set IsGood 0 - puts "aGetAttr11=${aGetAttr11}" - puts "aGetAttr21=${aGetAttr21}" - puts ${aMessage1} -} -set aGetAttr12 [lindex ${aGetAttr1} 1] -set aGetAttr22 [lindex ${aGetAttr2} 1] -if { ${aGetAttr12} != ${aGetAttr22} } { - set IsGood 0 - puts "aGetAttr12=${aGetAttr12}" - puts "aGetAttr22=${aGetAttr22}" - puts ${aMessage1} -} - -if { ${IsGood} == 0} { - puts "Add TDataStd_ReferenceList attribute: Error" -} else { - puts "Add TDataStd_ReferenceList attribute: OK" -} diff --git a/tests/caf/basic/V7 b/tests/caf/basic/V7 deleted file mode 100644 index 80d72bed51..0000000000 --- a/tests/caf/basic/V7 +++ /dev/null @@ -1,84 +0,0 @@ -#INTERFACE CAF -# Basic attributes -# TDataStd_ReferenceList -# -# Testing attribute: User defined (additional GUID) TDataStd_ReferenceList -# -# Testing command: SetReferenceList -# Testing command: GetReferenceList -# - -puts "caf001-V7" -set QA_DUP 0 - -# Add an attribute to a data framework -set aSetAttr11 0:3 -set aSetAttr12 0:4 -set aLabel 0:2 - -set aGuid1 "12e94561-6dbc-11d4-b9c8-0060b0ee281b" - -SetReferenceList D ${aLabel} ${aSetAttr11} ${aSetAttr12} -SetReferenceList D ${aLabel} -g ${aGuid1} ${aSetAttr11} ${aSetAttr12} - -# Close/Open the transaction -NewCommand D - -# Forget the attribute -ForgetAll D ${aLabel} - -# Close/Open the transaction -NewCommand D - -# Undo-Redo-Undo -Undo D -Redo D -Undo D - -# Save Document -Format D XmlOcaf -set aFile ${imagedir}/caf001-V7.xml -SaveAs D ${aFile} -Close D - -#Open a document -Open ${aFile} D - - -# Get a value of the attribute -set IsGood 1 -set aMessage1 "Add TDataStd_ReferenceList attribute: Error" -set aGetAttr1 [GetReferenceList D ${aLabel}] -set aLen1 [llength ${aGetAttr1}] -set aGetAttr2 [GetReferenceList D ${aLabel} ${aGuid1}] -set aLen2 [llength ${aGetAttr2}] - -if { ${aLen1} != ${aLen2}} { - set IsGood 0 - puts "aLen1=${aLen1}" - puts "aLen2=${aLen2}" - puts ${aMessage1} -} - -set aGetAttr11 [lindex ${aGetAttr1} 0] -set aGetAttr21 [lindex ${aGetAttr2} 0] -if { ${aGetAttr11} != ${aGetAttr21} } { - set IsGood 0 - puts "aGetAttr11=${aGetAttr11}" - puts "aGetAttr21=${aGetAttr21}" - puts ${aMessage1} -} -set aGetAttr12 [lindex ${aGetAttr1} 1] -set aGetAttr22 [lindex ${aGetAttr2} 1] -if { ${aGetAttr12} != ${aGetAttr22} } { - set IsGood 0 - puts "aGetAttr12=${aGetAttr12}" - puts "aGetAttr22=${aGetAttr22}" - puts ${aMessage1} -} - -if { ${IsGood} == 0} { - puts "Add TDataStd_ReferenceList attribute: Error" -} else { - puts "Add TDataStd_ReferenceList attribute: OK" -} diff --git a/tests/caf/basic/Y1 b/tests/caf/basic/Y1 deleted file mode 100644 index 9c1ffaa4b6..0000000000 --- a/tests/caf/basic/Y1 +++ /dev/null @@ -1,78 +0,0 @@ -#INTERFACE CAF -# Persistence functionality -# -# Testing feature: Saving empty labels (BinOcaf format) -# -# Testing command: SaveAs, Open -# - -puts "caf001-Y1" -set QA_DUP 0 - -set Lab1 [Label D 0:1:1] -set Lab2 [Label D 0:1:2] -set Lab3 [Label D 0:1:3] -## set List1 {0:1:1 0:1:2 0:1:3} -## set List2 {0:1:2} - -set aFile1 ${imagedir}/caf001-y1-1.cbf -set aFile2 ${imagedir}/caf001-y1-2.cbf - -#1. Open a new Document in BinOcaf format -# NewDocument D BinOcaf - -#2. Put integer attribute at the label Lab2 -SetInteger D $Lab2 321 -SetReal D $Lab2 871.33 - -#3. Save the Document with flag saveEmptyLabels = 1 -catch {SaveAs D ${aFile1} 1} -if { ![file exists ${aFile1}] } { - puts "There is not ${aFile} file; SaveAs command: Error writing binary file" - puts "Save ERROR" - return -} - -#4. Save the Document with flag saveEmptyLabels = 0 -catch {SaveAs D ${aFile2} 0} -if { ![file exists ${aFile2}] } { - puts "There is not ${aFile} file; SaveAs command: Error writing binary file" - puts "Save ERROR" - return -} - -#5. Open the just saved binary files -Close D -catch {Open ${aFile1} D1} -catch {Open ${aFile2} D2} - - -#5. Get list of child labels of main label (0:1) -set List1 [Children D1 0:1] -set List2 [Children D2 0:1] - -#6. Check length of the list of labels in aFile1 (to be len == 3) -set len1 [llength ${List1}] -if {$len1 != 3} { - puts "ERROR: Incorrect number of saved labels in cbf file, n = $len1" - return -} - -#7. Check length of the list of labels in aFile2 (to be len == 1) -set len2 [llength ${List2}] -if {$len2 != 1} { - puts "ERROR: Incorrect number of saved labels in cbf file, n = $len2" - return -} - -file delete ${aFile1} -file delete ${aFile2} -Close D1 -Close D2 - -puts "Saving empty labels: OK" - - - - - diff --git a/tests/caf/basic/Y2 b/tests/caf/basic/Y2 deleted file mode 100644 index 77dc452952..0000000000 --- a/tests/caf/basic/Y2 +++ /dev/null @@ -1,78 +0,0 @@ -#INTERFACE CAF -# Persistence functionality -# -# Testing feature: Saving empty labels (XmlOcaf format) -# -# Testing command: SaveAs, Open -# - -puts "caf001-Y2" -set QA_DUP 0 - -set Lab1 [Label D 0:1:1] -set Lab2 [Label D 0:1:2] -set Lab3 [Label D 0:1:3] -## set List1 {0:1:1 0:1:2 0:1:3} -## set List2 {0:1:2} - -set aFile1 ${imagedir}/caf001-y1-1.xml -set aFile2 ${imagedir}/caf001-y1-2.xml - -#1. Change Document format to XmlOcaf format -Format D XmlOcaf - -#2. Put integer attribute at the label Lab2 -SetInteger D $Lab2 321 -SetReal D $Lab2 871.33 - -#3. Save the Document with flag saveEmptyLabels = 1 -catch {SaveAs D ${aFile1} 1} -if { ![file exists ${aFile1}] } { - puts "There is not ${aFile} file; SaveAs command: Error writing xml file with empty labels" - puts "Save ERROR" - return -} - -#4. Save the Document with flag saveEmptyLabels = 0 -catch {SaveAs D ${aFile2} 0} -if { ![file exists ${aFile2}] } { - puts "There is not ${aFile} file; SaveAs command: Error writing xml file" - puts "Save ERROR" - return -} - -#5. Open the just saved xml files -Close D -catch {Open ${aFile1} D1} -catch {Open ${aFile2} D2} - - -#5. Get list of child labels of main label (0:1) -set List1 [Children D1 0:1] -set List2 [Children D2 0:1] - -#6. Check length of the list of labels in aFile1 (to be len == 3) -set len1 [llength ${List1}] -if {$len1 != 3} { - puts "ERROR: Incorrect number of saved labels in cbf file, n = $len1" - return -} - -#7. Check length of the list of labels in aFile2 (to be len == 1) -set len2 [llength ${List2}] -if {$len2 != 1} { - puts "ERROR: Incorrect number of saved labels in cbf file, n = $len2" - return -} - -file delete ${aFile1} -file delete ${aFile2} -Close D1 -Close D2 - -puts "Saving empty labels: OK" - - - - - diff --git a/tests/caf/bugs/A1 b/tests/caf/bugs/A1 deleted file mode 100755 index bf0ae15a1a..0000000000 --- a/tests/caf/bugs/A1 +++ /dev/null @@ -1,58 +0,0 @@ -#INTERFACE CAF -puts "================" -puts "OCC1228" -puts "================" -puts "" - -# Basic attributes -# -# Testing attribute: TDataStd_Integer -# -# Testing command: SetInteger -# Testing command: GetInteger -# - -# ANALOG: puts "caf001-A3" - -# Create a new document and set UndoLimit -NewDocument Doc BinOcaf -UndoLimit Doc 100 - -# Open a transaction -NewCommand Doc - -# Add an attribute to a data framework -set aSetAttr1 100 -set aLabel 0:2 -SetInteger Doc ${aLabel} ${aSetAttr1} - -# Close/Open the transaction -NewCommand Doc - -# Save the document -set aFile ${imagedir}/OCC1228-${casename}.cbf -file delete ${aFile} -catch {SaveAs Doc ${aFile}} -if { ![file exists ${aFile}] } { - puts "There is not ${aFile} file; SaveAs command: Error" - puts "OCC1228: ERROR (case 1)" -} -#catch {exec chmod 777 ${aFile}} - -# Restore the document -Close Doc -catch {Open ${aFile} DDoc} - -# Get a value of the attribute -set aGetAttr3 "" -set IsDone [catch {set aGetAttr3 [GetInteger DDoc ${aLabel}]} aResult] -if { ${IsDone} != 0 || - ${aSetAttr1}!=${aGetAttr3} } { - puts ${aResult} - puts "aSetAttr1=${aSetAttr1} aGetAttr3=${aGetAttr3}" - puts "Get a value of TDataStd_Integer attribute from restoring document: Error" - puts "OCC1228: ERROR (case 2)" -} else { - puts "Get a value of TDataStd_Integer attribute from restoring document: OK" - puts "OCC1228: OK" -} diff --git a/tests/caf/bugs/A2 b/tests/caf/bugs/A2 deleted file mode 100755 index 173e237352..0000000000 --- a/tests/caf/bugs/A2 +++ /dev/null @@ -1,58 +0,0 @@ -#INTERFACE CAF -puts "================" -puts "OCC1228" -puts "================" -puts "" - -# Basic attributes -# -# Testing attribute: TDataStd_Real -# -# Testing command: SetReal -# Testing command: GetReal -# - -# ANALOG: puts "caf001-B3" - -# Create a new document and set UndoLimit -NewDocument Doc BinOcaf -UndoLimit Doc 100 - -# Open a transaction -NewCommand Doc - -# Add an attribute to a data framework -set aSetAttr1 100.0 -set aLabel 0:2 -SetReal Doc ${aLabel} ${aSetAttr1} - -# Close/Open the transaction -NewCommand Doc - -# Save the document -set aFile ${imagedir}/OCC1228-${casename}.cbf -file delete ${aFile} -catch {SaveAs Doc ${aFile} } -if { ![file exists ${aFile}] } { - puts "There is not ${aFile} file; SaveAs command: Error" - puts "OCC1228: ERROR (case 1)" -} -#catch {exec chmod 777 ${aFile}} - -# Restore the document -Close Doc -catch {Open ${aFile} DDoc } - -# Get a value of the attribute -set aGetAttr3 "" -set IsDone [catch {set aGetAttr3 [GetReal DDoc ${aLabel}]} aResult] -if { ${IsDone} != 0 || - ${aSetAttr1}!=${aGetAttr3} } { - puts ${aResult} - puts "aSetAttr1=${aSetAttr1} aGetAttr3=${aGetAttr3}" - puts "Get a value of TDataStd_Real attribute from restoring document: Error" - puts "OCC1228: ERROR (case 2)" -} else { - puts "Get a value of TDataStd_Real attribute from restoring document: OK" - puts "OCC1228: OK" -} diff --git a/tests/caf/bugs/A3 b/tests/caf/bugs/A3 deleted file mode 100755 index 3ff9eec160..0000000000 --- a/tests/caf/bugs/A3 +++ /dev/null @@ -1,79 +0,0 @@ -#INTERFACE CAF -puts "================" -puts "OCC1228" -puts "================" -puts "" - -# Basic attributes -# -# Testing attribute: TDataStd_RealArray -# -# Testing command: SetRealArray -# Testing command: GetRealArray -# - -# ANALOG: puts "caf001-C3" -set QA_DUP 0 - -# Create a new document and set UndoLimit -NewDocument Doc BinOcaf -UndoLimit Doc 100 - -# Open a transaction -NewCommand Doc - -# Add an attribute to a data framework -set aFrom1 1 -set aTo1 2 -set aSetAttr11 3. -set aSetAttr12 4. -set aLabel 0:2 -set isDelta 0 -SetRealArray Doc ${aLabel} ${isDelta} ${aFrom1} ${aTo1} ${aSetAttr11} ${aSetAttr12} - -# Close/Open the transaction -NewCommand Doc - -# Save the document -set aFile ${imagedir}/OCC1228-${casename}.cbf -file delete ${aFile} -catch {SaveAs Doc ${aFile}} -if { ![file exists ${aFile}] } { - puts "There is not ${aFile} file; SaveAs command: Error" - puts "OCC1228: ERROR (case 1)" -} -#catch {exec chmod 777 ${aFile}} - -# Restore the document -Close Doc -catch {Open ${aFile} DDoc} - -# Get a value of the attribute -set aGetAttr3 "" -set aMessage3 "Get a value of TDataStd_RealArray attribute from restoring document: Error" -set IsDone [catch {set aGetAttr3 [GetRealArray DDoc ${aLabel}]} aResult] -if { ${IsDone} != 0 } { - puts ${aMessage3} - puts "OCC1228: ERROR (case 2)" -} -set aLen3 [llength ${aGetAttr3}] -if { ${aLen3} != [expr ${aTo1} - ${aFrom1} + 1] } { - puts "aLen3=${aLen3}" - puts ${aMessage3} - puts "OCC1228: ERROR (case 3)" -} -set aGetAttr41 [lindex ${aGetAttr3} 0] -if { ${aSetAttr11} != ${aGetAttr41} } { - puts "aGetAttr41=${aGetAttr41}" - puts ${aMessage3} - puts "OCC1228: ERROR (case 4)" -} -set aGetAttr42 [lindex ${aGetAttr3} 1] -if { ${aSetAttr12} != ${aGetAttr42} } { - puts "aGetAttr42=${aGetAttr42}" - puts ${aMessage3} - puts "OCC1228: ERROR (case 5)" -} else { - puts "Get a value of TDataStd_RealArray attribute from restoring document: OK" - puts "OCC1228: OK" -} diff --git a/tests/caf/bugs/A4 b/tests/caf/bugs/A4 deleted file mode 100755 index ea313d8129..0000000000 --- a/tests/caf/bugs/A4 +++ /dev/null @@ -1,79 +0,0 @@ -#INTERFACE CAF -puts "================" -puts "OCC1228" -puts "================" -puts "" - -# Basic attributes -# -# Testing attribute: TDataStd_IntegerArray -# -# Testing command: SetIntArray -# Testing command: GetIntArray -# - -# ANALOG: puts "caf001-D3" -set QA_DUP 0 - -# Create a new document and set UndoLimit -NewDocument Doc BinOcaf -UndoLimit Doc 100 - -# Open a transaction -NewCommand Doc - -# Add an attribute to a data framework -set aFrom1 1 -set aTo1 2 -set aSetAttr11 3 -set aSetAttr12 4 -set aLabel 0:2 -set isDelta 0 -SetIntArray Doc ${aLabel} ${isDelta} ${aFrom1} ${aTo1} ${aSetAttr11} ${aSetAttr12} - -# Close/Open the transaction -NewCommand Doc - -# Save the document -set aFile ${imagedir}/OCC1228-${casename}.cbf -file delete ${aFile} -catch {SaveAs Doc ${aFile}} -if { ![file exists ${aFile}] } { - puts "There is not ${aFile} file; SaveAs command: Error" - puts "OCC1228: ERROR (case 1)" -} -#catch {exec chmod 777 ${aFile}} - -# Restore the document -Close Doc -catch {Open ${aFile} DDoc} - -# Get a value of the attribute -set aGetAttr3 "" -set aMessage3 "Get a value of TDataStd_IntegerArray attribute from restoring document: Error" -set IsDone [catch {set aGetAttr3 [GetIntArray DDoc ${aLabel}]} aResult] -if { ${IsDone} != 0 } { - puts ${aMessage3} - puts "OCC1228: ERROR (case 2)" -} -set aLen3 [llength ${aGetAttr3}] -if { ${aLen3} != [expr ${aTo1} - ${aFrom1} + 1] } { - puts "aLen3=${aLen3}" - puts ${aMessage3} - puts "OCC1228: ERROR (case 3)" -} -set aGetAttr41 [lindex ${aGetAttr3} 0] -if { ${aSetAttr11} != ${aGetAttr41} } { - puts "aGetAttr41=${aGetAttr41}" - puts ${aMessage3} - puts "OCC1228: ERROR (case 4)" -} -set aGetAttr42 [lindex ${aGetAttr3} 1] -if { ${aSetAttr12} != ${aGetAttr42} } { - puts "aGetAttr42=${aGetAttr42}" - puts ${aMessage3} - puts "OCC1228: ERROR (case 5)" -} else { - puts "Get a value of TDataStd_IntegerArray attribute from restoring document: OK" - puts "OCC1228: OK" -} diff --git a/tests/caf/bugs/A5 b/tests/caf/bugs/A5 deleted file mode 100755 index f5c5d7dd96..0000000000 --- a/tests/caf/bugs/A5 +++ /dev/null @@ -1,59 +0,0 @@ -#INTERFACE CAF -puts "================" -puts "OCC1228" -puts "================" -puts "" - -# Basic attributes -# -# Testing attribute: TDataStd_Name -# -# Testing command: SetName -# Testing command: GetName -# - -# ANALOG: puts "caf001-E3" - -# Create a new document and set UndoLimit -NewDocument Doc BinOcaf -UndoLimit Doc 100 - -# Open a transaction -NewCommand Doc - -# Add an attribute to a data framework -set aSetAttr1 "New Attribute" -set aLabel 0:2 -Label Doc ${aLabel} -SetName Doc ${aLabel} ${aSetAttr1} - -# Close/Open the transaction -NewCommand Doc - -# Save the document -set aFile ${imagedir}/OCC1228-${casename}.cbf -file delete ${aFile} -catch {SaveAs Doc ${aFile}} -if { ![file exists ${aFile}] } { - puts "There is not ${aFile} file; SaveAs command: Error" - puts "OCC1228: ERROR (case 1)" -} -#catch {exec chmod 777 ${aFile}} - -# Restore the document -Close Doc -catch {Open ${aFile} DDoc} - -# Get a value of the attribute -set aGetAttr3 "" -set IsDone [catch {set aGetAttr3 [GetName DDoc ${aLabel}]} aResult] -if { ${IsDone} != 0 || - ${aSetAttr1}!=${aGetAttr3} } { - puts ${aResult} - puts "aSetAttr1=${aSetAttr1} aGetAttr3=${aGetAttr3}" - puts "Get a value of TDataStd_Name attribute from restoring document: Error" - puts "OCC1228: ERROR (case 2)" -} else { - puts "Get a value of TDataStd_Name attribute from restoring document: OK" - puts "OCC1228: OK" -} diff --git a/tests/caf/bugs/A6 b/tests/caf/bugs/A6 deleted file mode 100755 index 4011bc1c1c..0000000000 --- a/tests/caf/bugs/A6 +++ /dev/null @@ -1,58 +0,0 @@ -#INTERFACE CAF -puts "================" -puts "OCC1228" -puts "================" -puts "" - -# Basic attributes -# -# Testing attribute: TDataStd_Comment -# -# Testing command: SetComment -# Testing command: GetComment -# - -# ANALOG: puts "caf001-F3" - -# Create a new document and set UndoLimit -NewDocument Doc BinOcaf -UndoLimit Doc 100 - -# Open a transaction -NewCommand Doc - -# Add an attribute to a data framework -set aSetAttr1 "New Attribute" -set aLabel 0:2 -Label Doc ${aLabel} -SetComment Doc ${aLabel} ${aSetAttr1} - -# Close/Open the transaction -NewCommand Doc - -# Save the document -set aFile ${imagedir}/OCC1228-${casename}.cbf -file delete ${aFile} -catch {SaveAs Doc ${aFile}} -if { ![file exists ${aFile}] } { - puts "There is not ${aFile} file; SaveAs command: Error" -} -#catch {exec chmod 777 ${aFile}} - -# Restore the document -Close Doc -catch {Open ${aFile} DDoc} - -# Get a value of the attribute -set aGetAttr3 "" -set IsDone [catch {set aGetAttr3 [GetComment DDoc ${aLabel}]} aResult] -if { ${IsDone} != 0 || - ${aSetAttr1}!=${aGetAttr3} } { - puts ${aResult} - puts "aSetAttr1=${aSetAttr1} aGetAttr3=${aGetAttr3}" - puts "Get a value of TDataStd_Comment attribute from restoring document: Error" - puts "OCC1228: ERROR (case 2)" -} else { - puts "Get a value of TDataStd_Comment attribute from restoring document: OK" - puts "OCC1228: OK" -} diff --git a/tests/caf/bugs/A7 b/tests/caf/bugs/A7 deleted file mode 100755 index f5738d0de1..0000000000 --- a/tests/caf/bugs/A7 +++ /dev/null @@ -1,89 +0,0 @@ -#INTERFACE CAF -puts "================" -puts "OCC1228" -puts "================" -puts "" - -# Basic attributes -# -# Testing attribute: TDataStd_Point -# -# Testing command: SetPoint -# Testing command: GetPoint -# - -# ANALOG: puts "caf001-G3" - -# Create a new document and set UndoLimit -NewDocument Doc BinOcaf -UndoLimit Doc 100 - -# Open a transaction -NewCommand Doc - -set aTokList { :,} - -# Add an attribute to a data framework -set aSetX1 10 -set aSetY1 20 -set aSetZ1 30 -point aPoint1 ${aSetX1} ${aSetY1} ${aSetZ1} - -set aDumpPoint1 [dump aPoint1] - -# [llength ${aDumpPoint1}] = 10 -# Format of ${aDumpPoint1}: -# *********** Dump of aPoint1 ************* -# Point : 1.000000000000000e+01, 2.000000000000000e+01, 3.000000000000000e+01 - -set X_Point1 [lindex [split [lindex ${aDumpPoint1} 7] ${aTokList}] 0] -set Y_Point1 [lindex [split [lindex ${aDumpPoint1} 8] ${aTokList}] 0] -set Z_Point1 [lindex [split [lindex ${aDumpPoint1} 9] ${aTokList}] 0] - -set aLabel 0:2 -SetPoint Doc ${aLabel} aPoint1 - -# Close/Open the transaction -NewCommand Doc - -# Save the document -set aFile ${imagedir}/OCC1228-${casename}.cbf -file delete ${aFile} -catch {SaveAs Doc ${aFile}} -if { ![file exists ${aFile}] } { - puts "There is not ${aFile} file; SaveAs command: Error" - puts "OCC1228: ERROR (case 1)" -} -#catch {exec chmod 777 ${aFile}} - -# Restore the document -Close Doc -catch {Open ${aFile} DDoc} - -# Get a value of the attribute -set aGetAttr3 "" -set IsDone [catch {set aGetAttr3 [GetPoint DDoc ${aLabel}]} aResult] -if { ${IsDone} != 0 } { - puts ${aResult} - puts "Get a value of TDataStd_Point attribute from restoring document: Error" - puts "OCC1228: ERROR (case 2)" -} -catch {GetPoint DDoc ${aLabel} aPoint5} - -set aDumpPoint5 [dump aPoint5] -set X_Point5 [lindex [split [lindex ${aDumpPoint5} 7] ${aTokList}] 0] -set Y_Point5 [lindex [split [lindex ${aDumpPoint5} 8] ${aTokList}] 0] -set Z_Point5 [lindex [split [lindex ${aDumpPoint5} 9] ${aTokList}] 0] - -if { ${X_Point1} != ${X_Point5} || - ${Y_Point1} != ${Y_Point5} || - ${Z_Point1} != ${Z_Point5} } { - puts "X_Point1=${X_Point1} X_Point5=${X_Point5}" - puts "Y_Point1=${Y_Point1} Y_Point5=${Y_Point5}" - puts "Z_Point1=${Z_Point1} Z_Point5=${Z_Point5}" - puts "Get a value of TDataStd_Point attribute from restoring document: Error" - puts "OCC1228: ERROR (case 3)" -} else { - puts "Get a value of TDataStd_Point attribute from restoring document: OK" - puts "OCC1228: OK" -} diff --git a/tests/caf/bugs/A8 b/tests/caf/bugs/A8 deleted file mode 100755 index 3296db16c0..0000000000 --- a/tests/caf/bugs/A8 +++ /dev/null @@ -1,104 +0,0 @@ -#INTERFACE CAF -puts "================" -puts "OCC1228" -puts "================" -puts "" - -# Basic attributes -# -# Testing attribute: TDataStd_Axis -# -# Testing command: SetAxis -# Testing command: GetAxis -# - -# ANALOG: puts "caf001-H3" - -# Create a new document and set UndoLimit -NewDocument Doc BinOcaf -UndoLimit Doc 100 - -# Open a transaction -NewCommand Doc - -set aTokList { :,} - -# Add an attribute to a data framework -set aSetX1 10 -set aSetY1 20 -set aSetZ1 30 -set aSetDX1 100 -set aSetDY1 200 -set aSetDZ1 300 -line aLine1 ${aSetX1} ${aSetY1} ${aSetZ1} ${aSetDX1} ${aSetDY1} ${aSetDZ1} - -set aDumpLine1 [dump aLine1] - -# [llength ${aDumpLine1}] = 14 -# Format of ${aDumpLine1}: -# *********** Dump of aLine1 ************* -# Line -# Origin :10, 20, 30 -# Axis :0.267261241912424, 0.534522483824849, 0.801783725737273 - -set anOriginX_Line1 [lindex [split [lindex ${aDumpLine1} 7] ${aTokList}] 1] -set anOriginY_Line1 [lindex [split [lindex ${aDumpLine1} 8] ${aTokList}] 0] -set anOriginZ_Line1 [lindex [split [lindex ${aDumpLine1} 9] ${aTokList}] 0] -set anAxisDX_Line1 [lindex [split [lindex ${aDumpLine1} 11] ${aTokList}] 1] -set anAxisDY_Line1 [lindex [split [lindex ${aDumpLine1} 12] ${aTokList}] 0] -set anAxisDZ_Line1 [lindex [split [lindex ${aDumpLine1} 13] ${aTokList}] 0] - -set aLabel 0:2 -SetAxis Doc ${aLabel} aLine1 - -# Close/Open the transaction -NewCommand Doc - -# Save the document -set aFile ${imagedir}/OCC1228-${casename}.cbf -file delete ${aFile} -catch {SaveAs Doc ${aFile}} -if { ![file exists ${aFile}] } { - puts "There is not ${aFile} file; SaveAs command: Error" - puts "OCC1228: ERROR (case 1)" -} -#catch {exec chmod 777 ${aFile}} - -# Restore the document -Close Doc -catch {Open ${aFile} DDoc} - -# Get a value of the attribute -set IsDone [catch {GetAxis DDoc ${aLabel} anAxis3} aResult] -if { ${IsDone} != 0 } { - puts ${aResult} - puts "Get a value of TDataStd_Axis attribute from restoring document: Error" - puts "OCC1228: ERROR (case 2)" -} - -set aDumpAxis3 [dump anAxis3] -set anOriginX_Axis3 [lindex [split [lindex ${aDumpAxis3} 7] ${aTokList}] 1] -set anOriginY_Axis3 [lindex [split [lindex ${aDumpAxis3} 8] ${aTokList}] 0] -set anOriginZ_Axis3 [lindex [split [lindex ${aDumpAxis3} 9] ${aTokList}] 0] -set anAxisDX_Axis3 [lindex [split [lindex ${aDumpAxis3} 11] ${aTokList}] 1] -set anAxisDY_Axis3 [lindex [split [lindex ${aDumpAxis3} 12] ${aTokList}] 0] -set anAxisDZ_Axis3 [lindex [split [lindex ${aDumpAxis3} 13] ${aTokList}] 0] - -if { ${anOriginX_Line1} != ${anOriginX_Axis3} || - ${anOriginY_Line1} != ${anOriginY_Axis3} || - ${anOriginZ_Line1} != ${anOriginZ_Axis3} || - ${anAxisDX_Line1} != ${anAxisDX_Axis3} || - ${anAxisDY_Line1} != ${anAxisDY_Axis3} || - ${anAxisDZ_Line1} != ${anAxisDZ_Axis3} } { - puts "anOriginX_Line1=${anOriginX_Line1} anOriginX_Axis3=${anOriginX_Axis3}" - puts "anOriginY_Line1=${anOriginY_Line1} anOriginY_Axis3=${anOriginY_Axis3}" - puts "anOriginZ_Line1=${anOriginZ_Line1} anOriginZ_Axis3=${anOriginZ_Axis3}" - puts "anAxisDX_Line1=${anAxisDX_Line1} anAxisDX_Axis3=${anAxisDX_Axis3}" - puts "anAxisDY_Line1=${anAxisDY_Line1} anAxisDY_Axis3=${anAxisDY_Axis3}" - puts "anAxisDZ_Line1=${anAxisDZ_Line1} anAxisDZ_Axis3=${anAxisDZ_Axis3}" - puts "Get a value of TDataStd_Axis attribute from restoring document: Error" - puts "OCC1228: ERROR (case 2)" -} else { - puts "Get a value of TDataStd_Axis attribute from restoring document: OK" - puts "OCC1228: OK" -} diff --git a/tests/caf/bugs/A9 b/tests/caf/bugs/A9 deleted file mode 100755 index 9564f88d80..0000000000 --- a/tests/caf/bugs/A9 +++ /dev/null @@ -1,107 +0,0 @@ -#INTERFACE CAF -puts "================" -puts "OCC1228" -puts "================" -puts "" - -# Basic attributes -# -# Testing attribute: TDataStd_Plane -# -# Testing command: SetPlane -# Testing command: GetPlane -# - -# ANALOG: puts "caf001-I3" - -# Create a new document and set UndoLimit -NewDocument Doc BinOcaf -UndoLimit Doc 100 - -# Open a transaction -NewCommand Doc - -set aTokList { :,} - -# Add an attribute to a data framework -set aSetX1 10 -set aSetY1 20 -set aSetZ1 30 -set aSetDX1 -1 -set aSetDY1 0 -set aSetDZ1 0 - -plane aPlane1 ${aSetX1} ${aSetY1} ${aSetZ1} ${aSetDX1} ${aSetDY1} ${aSetDZ1} - -set aDumpPlane1 [dump aPlane1] - -# [llength ${aDumpPlane1}] = 22 -# Format of ${aDumpPlane1}: -# *********** Dump of aPlane1 ************* -# Plane -# Origin :10, 20, 30 -# Axis :-1, 0, 0 -# XAxis :-0, 0, -1 -# YAxis :-0, -1, 0 - -set anOriginX_Plane1 [lindex [split [lindex ${aDumpPlane1} 7] ${aTokList}] 1] -set anOriginY_Plane1 [lindex [split [lindex ${aDumpPlane1} 8] ${aTokList}] 0] -set anOriginZ_Plane1 [lindex [split [lindex ${aDumpPlane1} 9] ${aTokList}] 0] -set anAxisDX_Plane1 [lindex [split [lindex ${aDumpPlane1} 11] ${aTokList}] 1] -set anAxisDY_Plane1 [lindex [split [lindex ${aDumpPlane1} 12] ${aTokList}] 0] -set anAxisDZ_Plane1 [lindex [split [lindex ${aDumpPlane1} 13] ${aTokList}] 0] - -set aLabel 0:2 -SetPlane Doc ${aLabel} aPlane1 - -# Close/Open the transaction -NewCommand Doc - -# Save the document -set aFile ${imagedir}/OCC1228-${casename}.cbf -file delete ${aFile} -catch {SaveAs Doc ${aFile}} -if { ![file exists ${aFile}] } { - puts "There is not ${aFile} file; SaveAs command: Error" - puts "OCC1228: ERROR (case 1)" -} -#catch {exec chmod 777 ${aFile}} - -# Restore the document -Close Doc -catch {Open ${aFile} DDoc} - -# Get a value of the attribute -set IsDone [catch {GetPlane DDoc ${aLabel} aPlane5} aResult] -if { ${IsDone} != 0 } { - puts ${aResult} - puts "Get a value of TDataStd_Plane attribute from restoring document: Error" - puts "OCC1228: ERROR (case 2)" -} - -set aDumpPlane5 [dump aPlane5] -set anOriginX_Plane5 [lindex [split [lindex ${aDumpPlane5} 7] ${aTokList}] 1] -set anOriginY_Plane5 [lindex [split [lindex ${aDumpPlane5} 8] ${aTokList}] 0] -set anOriginZ_Plane5 [lindex [split [lindex ${aDumpPlane5} 9] ${aTokList}] 0] -set anAxisDX_Plane5 [lindex [split [lindex ${aDumpPlane5} 11] ${aTokList}] 1] -set anAxisDY_Plane5 [lindex [split [lindex ${aDumpPlane5} 12] ${aTokList}] 0] -set anAxisDZ_Plane5 [lindex [split [lindex ${aDumpPlane5} 13] ${aTokList}] 0] - -if { ${anOriginX_Plane1} != ${anOriginX_Plane5} || - ${anOriginY_Plane1} != ${anOriginY_Plane5} || - ${anOriginZ_Plane1} != ${anOriginZ_Plane5} || - ${anAxisDX_Plane1} != ${anAxisDX_Plane5} || - ${anAxisDY_Plane1} != ${anAxisDY_Plane5} || - ${anAxisDZ_Plane1} != ${anAxisDZ_Plane5} } { - puts "anOriginX_Plane1=${anOriginX_Plane1} anOriginX_Plane5=${anOriginX_Plane5}" - puts "anOriginY_Plane1=${anOriginY_Plane1} anOriginY_Plane5=${anOriginY_Plane5}" - puts "anOriginZ_Plane1=${anOriginZ_Plane1} anOriginZ_Plane5=${anOriginZ_Plane5}" - puts "anAxisDX_Plane1=${anAxisDX_Plane1} anAxisDX_Plane5=${anAxisDX_Plane5}" - puts "anAxisDY_Plane1=${anAxisDY_Plane1} anAxisDY_Plane5=${anAxisDY_Plane5}" - puts "anAxisDZ_Plane1=${anAxisDZ_Plane1} anAxisDZ_Plane5=${anAxisDZ_Plane5}" - puts "Get a value of TDataStd_Plane attribute from restoring document: Error" - puts "OCC1228: ERROR (case 3)" -} else { - puts "Get a value of TDataStd_Plane attribute from restoring document: OK" - puts "OCC1228: OK" -} diff --git a/tests/caf/bugs/B1 b/tests/caf/bugs/B1 deleted file mode 100755 index 7a39b83aed..0000000000 --- a/tests/caf/bugs/B1 +++ /dev/null @@ -1,64 +0,0 @@ -#INTERFACE CAF -puts "================" -puts "OCC1228" -puts "================" -puts "" - -# Basic attributes -# -# Testing attribute: TDataStd_UAttribute -# -# Testing command: SetUAttribute -# Testing command: GetUAttribute -# - -# ANALOG: puts "caf001-J3" - -# Create a new document and set UndoLimit -NewDocument Doc BinOcaf -UndoLimit Doc 100 - -# Open a transaction -NewCommand Doc - -# Add an attribute to a data framework -set aSetAttr1 "c73bd075-22ee-11d2-acde-080009dc4422" -set aLabel 0:2 -SetUAttribute Doc ${aLabel} ${aSetAttr1} - -# Close/Open the transaction -NewCommand Doc - -# Save the document -set aFile ${imagedir}/OCC1228-${casename}.cbf -file delete ${aFile} -catch {SaveAs Doc ${aFile}} -if { ![file exists ${aFile}] } { - puts "There is not ${aFile} file; SaveAs command: Error" - puts "OCC1228: ERROR (case 1)" -} -#catch {exec chmod 777 ${aFile}} - -# Restore the document -Close Doc -catch {Open ${aFile} DDoc} - -# Get a value of the attribute -set IsDone [catch {GetUAttribute DDoc ${aLabel} ${aSetAttr1}} aResult] -if { ${IsDone} != 0 } { - puts ${aResult} - puts "Get a value of TDataStd_UAttribute attribute from restoring document: Error" - puts "OCC1228: ERROR (case 2)" -} -set aGetAttr3 "" -catch {set aGetAttr3 [GetUAttribute DDoc ${aLabel} ${aSetAttr1}]} - -if { ${aSetAttr1}!=${aGetAttr3} } { - puts "aSetAttr1=${aSetAttr1}" - puts "aGetAttr3=${aGetAttr3}" - puts "Get a value of TDataStd_UAttribute attribute from restoring document: Error" - puts "OCC1228: ERROR (case 3)" -} else { - puts "Get a value of TDataStd_UAttribute attribute from restoring document: OK" - puts "OCC1228: OK" -} diff --git a/tests/caf/bugs/B2 b/tests/caf/bugs/B2 deleted file mode 100755 index 2c59ec5f57..0000000000 --- a/tests/caf/bugs/B2 +++ /dev/null @@ -1,85 +0,0 @@ -#INTERFACE CAF -puts "================" -puts "OCC1228" -puts "================" -puts "" - -# Basic attributes -# -# Testing attribute: TDataStd_UAttribute -# -# Testing command: SetUAttribute -# Testing command: GetUAttribute -# - -# ANALOG: puts "caf001-J6" - -# Create a new document and set UndoLimit -NewDocument Doc BinOcaf -UndoLimit Doc 100 - -# Open a transaction -NewCommand Doc - -# Add an attribute to a data framework -set aSetAttr1 "c73bd075-22ee-11d2-acde-080009dc4422" -set aLabel 0:2 -SetUAttribute Doc ${aLabel} ${aSetAttr1} - -# Add new ID to a label -set aSetAttr2 "c73bd076-22ee-11d2-acde-080009dc4422" -SetUAttribute Doc ${aLabel} ${aSetAttr2} - -# Close/Open the transaction -NewCommand Doc - -# Save the document -set aFile ${imagedir}/OCC1228-${casename}.cbf -file delete ${aFile} -catch {SaveAs Doc ${aFile}} -if { ![file exists ${aFile}] } { - puts "There is not ${aFile} file; SaveAs command: Error" - puts "OCC1228: ERROR (case 1)" -} -#catch {exec chmod 777 ${aFile}} - -# Restore the document -Close Doc -catch {Open ${aFile} DDoc} - -# Get a value of first ID -set IsDone [catch {GetUAttribute DDoc ${aLabel} ${aSetAttr1}} aResult] -if { ${IsDone} != 0 } { - puts ${aResult} - puts "Get a value of TDataStd_UAttribute attribute from restoring document: Error" - puts "OCC1228: ERROR (case 2)" -} -set aGetAttr1 "" -catch {set aGetAttr1 [GetUAttribute DDoc ${aLabel} ${aSetAttr1}]} -if { ${aSetAttr1}!=${aGetAttr1} } { - puts "First ID:" - puts "aSetAttr1=${aSetAttr1}" - puts "aGetAttr1=${aGetAttr1}" - puts "Get a value of TDataStd_UAttribute attribute from restoring document: Error" - puts "OCC1228: ERROR (case 3)" -} - -# Get a value of second ID -set IsDone [catch {GetUAttribute DDoc ${aLabel} ${aSetAttr2}} aResult] -if { ${IsDone} != 0 } { - puts ${aResult} - puts "Get a value of TDataStd_UAttribute attribute from restoring document: Error" - puts "OCC1228: ERROR (case 4)" -} -set aGetAttr2 "" -catch {set aGetAttr2 [GetUAttribute DDoc ${aLabel} ${aSetAttr2}]} -if { ${aSetAttr2}!=${aGetAttr2} } { - puts "Second ID:" - puts "aSetAttr2=${aSetAttr2}" - puts "aGetAttr2=${aGetAttr2}" - puts "Get a value of TDataStd_UAttribute attribute from restoring document: Error" - puts "OCC1228: ERROR (case 5)" -} else { - puts "Get a value of TDataStd_UAttribute attribute from restoring document: OK" - puts "OCC1228: OK" -} diff --git a/tests/caf/bugs/B3 b/tests/caf/bugs/B3 deleted file mode 100755 index ae4bb4168c..0000000000 --- a/tests/caf/bugs/B3 +++ /dev/null @@ -1,83 +0,0 @@ -#INTERFACE CAF -puts "================" -puts "OCC1228" -puts "================" -puts "" - -# Basic attributes -# -# Testing attribute: TDataStd_Shape -# -# Testing command: SetShape -# Testing command: GetShape -# - -# ANALOG: puts "caf001-K3" - -# Create a new document and set UndoLimit -NewDocument Doc BinOcaf -UndoLimit Doc 100 - -# Open a transaction -NewCommand Doc - -# Add an attribute to a data framework -set aSetX1 10 -set aSetY1 20 -set aSetZ1 30 -set aSetDX1 100 -set aSetDY1 200 -set aSetDZ1 300 - -box aBox1 ${aSetX1} ${aSetY1} ${aSetZ1} ${aSetDX1} ${aSetDY1} ${aSetDZ1} - -bounding aBox1 -save X1_Box1 Y1_Box1 Z1_Box1 X2_Box1 Y2_Box1 Z2_Box1 - -set aLabel 0:2 -SetShape Doc ${aLabel} aBox1 - -# Close/Open the transaction -NewCommand Doc - -# Save the document -set aFile ${imagedir}/OCC1228-${casename}.cbf -file delete ${aFile} -catch {SaveAs Doc ${aFile}} -if { ![file exists ${aFile}] } { - puts "There is not ${aFile} file; SaveAs command: Error" - puts "OCC1228: ERROR (case 1)" -} -#catch {exec chmod 777 ${aFile}} - -# Restore the document -Close Doc -catch {Open ${aFile} DDoc} - -# Get a value of the attribute -set IsDone [catch {GetShape DDoc ${aLabel} aBox5} aResult] -if { ${IsDone} != 0 } { - puts ${aResult} - puts "Get a value of TDataStd_Shape attribute from restoring document: Error" - puts "OCC1228: ERROR (case 2)" -} - -bounding aBox5 -save X1_Box5 Y1_Box5 Z1_Box5 X2_Box5 Y2_Box5 Z2_Box5 - -if { [dval X1_Box1] != [dval X1_Box5] || - [dval Y1_Box1] != [dval Y1_Box5] || - [dval Z1_Box1] != [dval Z1_Box5] || - [dval X2_Box1] != [dval X2_Box5] || - [dval Y2_Box1] != [dval Y2_Box5] || - [dval Z2_Box1] != [dval Z2_Box5] } { - puts "X1_Box1=[dval X1_Box1] X1_Box5=[dval X1_Box5]" - puts "Y1_Box1=[dval Y1_Box1] Y1_Box5=[dval Y1_Box5]" - puts "Z1_Box1=[dval Z1_Box1] Z1_Box5=[dval Z1_Box5]" - puts "X2_Box1=[dval X2_Box1] X2_Box5=[dval X2_Box5]" - puts "Y2_Box1=[dval Y2_Box1] Y2_Box5=[dval Y2_Box5]" - puts "Z2_Box1=[dval Z2_Box1] Z2_Box5=[dval Z2_Box5]" - puts "Get a value of TDataStd_Shape attribute from restoring document: Error" - puts "OCC1228: ERROR (case 3)" -} else { - puts "Get a value of TDataStd_Shape attribute from restoring document: OK" - puts "OCC1228: OK" -} diff --git a/tests/caf/bugs/B4 b/tests/caf/bugs/B4 deleted file mode 100755 index c30e718e26..0000000000 --- a/tests/caf/bugs/B4 +++ /dev/null @@ -1,72 +0,0 @@ -#INTERFACE CAF -puts "================" -puts "OCC1228" -puts "================" -puts "" - -# Basic attributes -# -# Testing attribute: TDF_Reference -# -# Testing command: SetReference -# Testing command: GetReference -# - -# ANALOG: puts "caf001-L3" - -# Create a new document and set UndoLimit -NewDocument Doc BinOcaf -UndoLimit Doc 100 - -# Open a transaction -NewCommand Doc - -# Add an attribute to a data framework -set aSetAttr1 100 -set aSetAttr2 200 -set aSetAttr3 300 -set aLabel1 0:2 -set aLabel2 0:3 -set aLabel3 0:4 -set aLabel4 0:5 -SetInteger Doc ${aLabel1} ${aSetAttr1} -SetInteger Doc ${aLabel2} ${aSetAttr2} -SetInteger Doc ${aLabel3} ${aSetAttr3} - -set aReference1 ${aLabel2} -SetReference Doc ${aLabel4} ${aReference1} - -# Close/Open the transaction -NewCommand Doc - -# Save the document -set aFile ${imagedir}/OCC1228-${casename}.cbf -file delete ${aFile} -catch {SaveAs Doc ${aFile}} -if { ![file exists ${aFile}] } { - puts "There is not ${aFile} file; SaveAs command: Error" - puts "OCC1228: ERROR (case 1)" -} -#catch {exec chmod 777 ${aFile}} - -# Restore the document -Close Doc -catch {Open ${aFile} DDoc} - -# Get a value of the attribute -set aReference5 "" -set IsDone [catch {set aReference5 [GetReference DDoc ${aLabel4}]} aResult] -if { ${IsDone} != 0 } { - puts ${aResult} - puts "Get a value of TDF_Reference attribute from restoring document: Error" - puts "OCC1228: ERROR (case 2)" -} - -if { ${aReference1} != ${aReference5} } { - puts "aReference1=${aReference1} aReference5=${aReference5}" - puts "Get a value of TDF_Reference attribute from restoring document: Error" - puts "OCC1228: ERROR (case 3)" -} else { - puts "Get a value of TDF_Reference attribute from restoring document: OK" - puts "OCC1228: OK" -} diff --git a/tests/caf/bugs/B5 b/tests/caf/bugs/B5 deleted file mode 100755 index a76c0393b7..0000000000 --- a/tests/caf/bugs/B5 +++ /dev/null @@ -1,89 +0,0 @@ -#INTERFACE CAF -puts "================" -puts "OCC1228" -puts "================" -puts "" - -# NamedShape -# -# Testing attribute: TNaming_NamedShape -# -# Testing command: GetShape -# - -# ANALOG: puts "caf002-C1" - -# Create a new document and set UndoLimit -NewDocument Doc BinOcaf -UndoLimit Doc 100 - -# Open a transaction -NewCommand Doc - -# Create a box -set aSetX1 10 -set aSetY1 20 -set aSetZ1 30 -set aSetDX1 100 -set aSetDY1 200 -set aSetDZ1 300 - -box aBox1 ${aSetX1} ${aSetY1} ${aSetZ1} ${aSetDX1} ${aSetDY1} ${aSetDZ1} - -bounding aBox1 -save X1_Box1 Y1_Box1 Z1_Box1 X2_Box1 Y2_Box1 Z2_Box1 - -# Create a label -set aLabel 0:2 -Label Doc ${aLabel} - -# Close/Open transaction -NewCommand Doc - -# Set a shape to the label -SetShape Doc ${aLabel} aBox1 - -# Close/Open transaction -NewCommand Doc - -# Save the document -set aFile ${imagedir}/OCC1228-${casename}.cbf -file delete ${aFile} -catch {SaveAs Doc ${aFile}} -#catch {exec chmod 777 ${aFile}} -if { ![file exists ${aFile}] } { - puts "There is not ${aFile} file; SaveAs command: Error" - puts "OCC1228: ERROR (case 1)" -} - -# Restore the document -Close Doc -catch {Open ${aFile} DDoc} - -# Get a shape from the label -set IsDone [catch {GetShape DDoc ${aLabel} aBox3} aResult] -if { ${IsDone} != 0 } { - puts ${aResult} - puts "Get a value of TNaming_NamedShape attribute from restoring document: Error" - puts "OCC1228: ERROR (case 2)" -} - -bounding aBox3 -save X1_Box3 Y1_Box3 Z1_Box3 X2_Box3 Y2_Box3 Z2_Box3 - -if { [dval X1_Box1] != [dval X1_Box3] || - [dval Y1_Box1] != [dval Y1_Box3] || - [dval Z1_Box1] != [dval Z1_Box3] || - [dval X2_Box1] != [dval X2_Box3] || - [dval Y2_Box1] != [dval Y2_Box3] || - [dval Z2_Box1] != [dval Z2_Box3] } { - puts "X1_Box1=[dval X1_Box1] X1_Box3=[dval X1_Box3]" - puts "Y1_Box1=[dval Y1_Box1] Y1_Box3=[dval Y1_Box3]" - puts "Z1_Box1=[dval Z1_Box1] Z1_Box3=[dval Z1_Box3]" - puts "X2_Box1=[dval X2_Box1] X2_Box3=[dval X2_Box3]" - puts "Y2_Box1=[dval Y2_Box1] Y2_Box3=[dval Y2_Box3]" - puts "Z2_Box1=[dval Z2_Box1] Z2_Box3=[dval Z2_Box3]" - puts "Get a value of TNaming_NamedShape attribute from restoring document: Error" - puts "OCC1228: ERROR (case 3)" -} else { - puts "Get a value of TNaming_NamedShape attribute from restoring document: OK" - puts "OCC1228: OK" -} diff --git a/tests/caf/bugs/B7 b/tests/caf/bugs/B7 deleted file mode 100755 index 65973d458b..0000000000 --- a/tests/caf/bugs/B7 +++ /dev/null @@ -1,97 +0,0 @@ -#INTERFACE CAF -puts "================" -puts "OCC1228" -puts "================" -puts "" - -# XLink attributes -# -# Testing attribute: TDocStd_XLink -# -# Testing command: CopyWithLink -# - -# ANALOG: puts "caf004-B3" - -# Create two new documents Doc1, Doc2 -NewDocument Doc1 BinOcaf -NewDocument Doc2 BinOcaf - -# Set UndoLimit for them -UndoLimit Doc1 100 -UndoLimit Doc2 100 - -# Set a shape in Doc1 to label 'SLabel' -set aLabel1 0:2 -Label Doc1 ${aLabel1} -SetName Doc1 ${aLabel1} SLabel - -set aSetX1 10 -set aSetY1 20 -set aSetZ1 30 -set aSetDX1 100 -set aSetDY1 200 -set aSetDZ1 300 - -box aBox1 ${aSetX1} ${aSetY1} ${aSetZ1} ${aSetDX1} ${aSetDY1} ${aSetDZ1} - -bounding aBox1 -save X1_Box1 Y1_Box1 Z1_Box1 X2_Box1 Y2_Box1 Z2_Box1 - -SetShape Doc1 ${aLabel1} aBox1 - -# Create a new label 'TLabel1' in Doc1 -set aLabel2 0:3 -Label Doc1 ${aLabel2} -SetName Doc1 ${aLabel2} TLabel1 - -# Open transaction in Doc1 -NewCommand Doc1 - -# Copy 'SLabel' to the label 'TLabel1' with link -CopyWithLink Doc1 ${aLabel2} Doc1 ${aLabel1} - -# Close/Open transaction -NewCommand Doc1 - -# Save the document -set aFile ${imagedir}/OCC1228-${casename}.cbf -file delete ${aFile} -catch {SaveAs Doc1 ${aFile}} -if { ![file exists ${aFile}] } { - puts "There is not ${aFile} file; SaveAs command: Error" - puts "OCC1228: ERROR (case 1)" -} -#catch {exec chmod 777 ${aFile}} - -# Restore the document -Close Doc1 -catch {Open ${aFile} Doc2} - -# Get a shape from 'TLabel1' of restoring document -set IsDone [catch {GetShape Doc2 ${aLabel2} aBox2} aResult] -if { ${IsDone} != 0 } { - puts ${aResult} - puts "Get a value of TNaming_NamedShape attribute from restoring document: Error" - puts "OCC1228: ERROR (case 2)" -} - -bounding aBox2 -save X1_Box2 Y1_Box2 Z1_Box2 X2_Box2 Y2_Box2 Z2_Box2 - -if { [dval X1_Box1] != [dval X1_Box2] || - [dval Y1_Box1] != [dval Y1_Box2] || - [dval Z1_Box1] != [dval Z1_Box2] || - [dval X2_Box1] != [dval X2_Box2] || - [dval Y2_Box1] != [dval Y2_Box2] || - [dval Z2_Box1] != [dval Z2_Box2] } { - puts "X1_Box1=[dval X1_Box1] X1_Box2=[dval X1_Box2]" - puts "Y1_Box1=[dval Y1_Box1] Y1_Box2=[dval Y1_Box2]" - puts "Z1_Box1=[dval Z1_Box1] Z1_Box2=[dval Z1_Box2]" - puts "X2_Box1=[dval X2_Box1] X2_Box2=[dval X2_Box2]" - puts "Y2_Box1=[dval Y2_Box1] Y2_Box2=[dval Y2_Box2]" - puts "Z2_Box1=[dval Z2_Box1] Z2_Box2=[dval Z2_Box2]" - puts "Get a link between attributes of the same document from restoring document: Error" - puts "OCC1228: ERROR (case 3)" -} else { - puts "Get a link between attributes of the same document from restoring document: OK" - puts "OCC1228: OK" -} diff --git a/tests/caf/bugs/B8 b/tests/caf/bugs/B8 deleted file mode 100755 index 5deaf69870..0000000000 --- a/tests/caf/bugs/B8 +++ /dev/null @@ -1,65 +0,0 @@ -#INTERFACE CAF -puts "================" -puts "OCC1228" -puts "================" -puts "" - -# Tree construction attributes -# -# Testing attribute: TDF_TagSource -# -# Testing command: NewChild -# - -# ANALOG: puts "caf005-A3" - -# Create a new document and set UndoLimit -NewDocument Doc BinOcaf -UndoLimit Doc 100 - -# Open a transaction -NewCommand Doc - -# Add an attribute to a data framework -set aLabel1 0:2 -set aName1 Label1 -Label Doc ${aLabel1} -SetName Doc ${aLabel1} ${aName1} - -set aName11 Label11 -set aChild1 [NewChild Doc ${aLabel1}] -### -set aChild1 0:2:1 -### -SetName Doc ${aChild1} ${aName11} - -# Close/Open the transaction -NewCommand Doc - -# Save the document -set aFile ${imagedir}/OCC1228-${casename}.cbf -file delete ${aFile} -catch {SaveAs Doc ${aFile}} -if { ![file exists ${aFile}] } { - puts "There is not ${aFile} file; SaveAs command: Error" - puts "OCC1228: ERROR (case 1)" -} -#catch {exec chmod 777 ${aFile}} - -# Restore the document -Close Doc -catch {Open ${aFile} DDoc} - -# Get a value of the attribute -set aGetName1 "" -set IsDone [catch {set aGetName1 [GetName DDoc ${aChild1}]} aResult] -if { ${IsDone} != 0 || - ${aName11}!=${aGetName1} } { - puts "aName11=${aName11} aGetName1=${aGetName1}" - puts ${aResult} - puts "Get a value of TDF_TagSource attribute from restoring document: Error" - puts "OCC1228: ERROR (case 2)" -} else { - puts "Get a value of TDF_TagSource attribute from restoring document: OK" - puts "OCC1228: OK" -} diff --git a/tests/caf/bugs/B9 b/tests/caf/bugs/B9 deleted file mode 100755 index e086e357d5..0000000000 --- a/tests/caf/bugs/B9 +++ /dev/null @@ -1,58 +0,0 @@ -#INTERFACE CAF -puts "================" -puts "OCC1228" -puts "================" -puts "" - -# Tree construction attributes -# -# Testing attribute: TDataStd_Directory -# -# Testing command: NewDirectory -# - -# ANALOG: puts "caf005-B3" - -# Create a new document and set UndoLimit -NewDocument Doc BinOcaf -UndoLimit Doc 100 - -# Open a transaction -NewCommand Doc - -# Add an attribute to a data framework -set aLabel1 0:2 -catch {NewDirectory Doc ${aLabel1}} -set aName1 Label1 -SetName Doc ${aLabel1} ${aName1} - -# Close/Open the transaction -NewCommand Doc - -# Save the document -set aFile ${imagedir}/OCC1228-${casename}.cbf -file delete ${aFile} -catch {SaveAs Doc ${aFile}} -if { ![file exists ${aFile}] } { - puts "There is not ${aFile} file; SaveAs command: Error" - puts "OCC1228: ERROR (case 1)" -} -#catch {exec chmod 777 ${aFile}} - -# Restore the document -Close Doc -catch {Open ${aFile} DDoc} - -# Get a value of the attribute -set aGetName1 "" -set IsDone [catch {set aGetName1 [GetName DDoc ${aLabel1}]} aResult] -if { ${IsDone} != 0 || - ${aName1}!=${aGetName1} } { - puts "aName1=${aName1} aGetName1=${aGetName1}" - puts ${aResult} - puts "Get a value of TDataStd_Directory attribute from restoring document: Error" - puts "OCC1228: ERROR (case 2)" -} else { - puts "Get a value of TDataStd_Directory attribute from restoring document: OK" - puts "OCC1228: OK" -} diff --git a/tests/caf/bugs/C1 b/tests/caf/bugs/C1 deleted file mode 100755 index 0d39fcc701..0000000000 --- a/tests/caf/bugs/C1 +++ /dev/null @@ -1,61 +0,0 @@ -#INTERFACE CAF -puts "================" -puts "OCC1228" -puts "================" -puts "" - -# Tree construction attributes -# -# Testing attribute: TDataStd_TreeNode -# -# Testing command: SetNode -# -# Testing command: RootNode -# - -# ANALOG: puts "caf005-C2" - -# Create a new document and set UndoLimit -NewDocument Doc BinOcaf -UndoLimit Doc 100 - -# Open a transaction -NewCommand Doc - -# Add an attribute to a data framework -set aLabel_Root 0:2 -set aName_Root Label_1 -Label Doc ${aLabel_Root} -SetName Doc ${aLabel_Root} ${aName_Root} -SetNode Doc ${aLabel_Root} - -# Close/Open the transaction -NewCommand Doc - -# Save the document -set aFile ${imagedir}/OCC1228-[file tail [info script]].cbf -file delete ${aFile} -catch {SaveAs Doc ${aFile}} -if { ![file exists ${aFile}] } { - puts "There is not ${aFile} file; SaveAs command: Error" - puts "OCC1228: ERROR (case 1)" -} -#catch {exec chmod 777 ${aFile}} - -# Restore the document -Close Doc -catch {Open ${aFile} DDoc} - -# Get a value of the attribute -set aGetLabel_Root "" -set IsDone [catch {set aGetLabel_Root [RootNode DDoc ${aLabel_Root}]} aResult] -if { ${IsDone} != 0 || - ${aLabel_Root}!=${aGetLabel_Root} } { - puts "aLabel_Root=${aLabel_Root} aGetLabel_Root=${aGetLabel_Root}" - puts ${aResult} - puts "Get a value of TDataStd_TreeNode attribute from restoring document: Error" - puts "OCC1228: ERROR (case 2)" -} else { - puts "Get a value of TDataStd_TreeNode attribute from restoring document: OK" - puts "OCC1228: OK" -} diff --git a/tests/caf/bugs/C2 b/tests/caf/bugs/C2 deleted file mode 100755 index 35f3aa72c6..0000000000 --- a/tests/caf/bugs/C2 +++ /dev/null @@ -1,82 +0,0 @@ -#INTERFACE CAF -puts "================" -puts "OCC6493" -puts "================" -puts "" -###################################################### -# No binary persistence for TDataStd_ExtStringArray attribute -###################################################### - -# Basic attributes -# -# Testing attribute: TDataStd_ExtStringArray -# -# Testing command: SetExtStringArray -# Testing command: GetExtStringArray -# - -# ANALOG: puts "caf001-M3" -set QA_DUP 0 - -# Create a new document and set UndoLimit -NewDocument Doc BinOcaf -UndoLimit Doc 100 - -# Open a transaction -NewCommand Doc - -# Add an attribute to a data framework -set aFrom1 1 -set aTo1 2 -set aSetAttr11 "TDataStd" -set aSetAttr12 "ExtStringArray" -set aLabel 0:2 -set isDelta 0 -SetExtStringArray Doc ${aLabel} ${isDelta} ${aFrom1} ${aTo1} ${aSetAttr11} ${aSetAttr12} - -# Close/Open the transaction -NewCommand Doc - -# Save the document -set aFile ${imagedir}/OCC6493-[file tail [info script]].cbf -file delete ${aFile} -catch {SaveAs Doc ${aFile}} -if { ![file exists ${aFile}] } { - puts "There is not ${aFile} file; SaveAs command: Error" - puts "OCC6493: ERROR (case 1)" -} -#catch {exec chmod 777 ${aFile}} - -# Restore the document -Close Doc -catch {Open ${aFile} DDoc} - -# Get a value of the attribute -set aGetAttr3 "" -set aMessage3 "Get a value of TDataStd_ExtStringArray attribute from restoring document: Error" -set IsDone [catch {set aGetAttr3 [GetExtStringArray DDoc ${aLabel}]} aResult] -if { ${IsDone} != 0 } { - puts ${aMessage3} - puts "OCC6493: ERROR (case 2)" -} -set aLen3 [llength ${aGetAttr3}] -if { ${aLen3} != [expr ${aTo1} - ${aFrom1} + 1] } { - puts "aLen3=${aLen3}" - puts ${aMessage3} - puts "OCC6493: ERROR (case 3)" -} -set aGetAttr41 [lindex ${aGetAttr3} 0] -if { ${aSetAttr11} != ${aGetAttr41} } { - puts "aGetAttr41=${aGetAttr41}" - puts ${aMessage3} - puts "OCC6493: ERROR (case 4)" -} -set aGetAttr42 [lindex ${aGetAttr3} 1] -if { ${aSetAttr12} != ${aGetAttr42} } { - puts "aGetAttr42=${aGetAttr42}" - puts ${aMessage3} - puts "OCC6493: ERROR (case 5)" -} else { - puts "Get a value of TDataStd_ExtStringArray attribute from restoring document: OK" - puts "OCC6493: OK" -} diff --git a/tests/caf/bugs/D1 b/tests/caf/bugs/D1 deleted file mode 100755 index 2b0830722e..0000000000 --- a/tests/caf/bugs/D1 +++ /dev/null @@ -1,236 +0,0 @@ -#INTERFACE CAF -puts "================" -puts "bug0023850: Speed-up storage of OCAF document in XML file format" -puts "================" -puts "" -###################################################### -# Speed-up storage of OCAF document in XML file format -###################################################### - -# Create an OCAF document. Use XML as a test storage schema. -NewDocument DOC XmlOcaf - -# Set a long byte array of many-many values. Here it is an array of 10 values. -SetByteArray DOC 0:1 0 1 10 1 2 3 4 5 6 7 8 9 10 - -# Set a list of tree nodes. -SetNode DOC 0:1 -SetNode DOC 0:1:1 -SetNode DOC 0:1:2 -SetNode DOC 0:1:3 -SetNode DOC 0:1:4 -SetNode DOC 0:1:5 -SetNode DOC 0:1:6 -SetNode DOC 0:1:7 -SetNode DOC 0:1:8 -AppendNode DOC 0:1 0:1:1 -AppendNode DOC 0:1 0:1:2 -AppendNode DOC 0:1 0:1:3 -AppendNode DOC 0:1 0:1:4 -AppendNode DOC 0:1 0:1:5 -AppendNode DOC 0:1 0:1:6 -AppendNode DOC 0:1 0:1:7 -AppendNode DOC 0:1 0:1:8 - -# Set an array of integer values. -SetIntArray DOC 0:1 0 1 5 111 222 333 444 555 - -# Set an array of double values (one of them contains 17 digits!) -SetRealArray DOC 0:1 0 1 5 1.12345678987654321 2.2 3.3 4.4 5.5 - -# Set a packed map of integer values. -SetIntPackedMap DOC 0:1 0 1 10 100 1000 10000 - -# Set an array of boolean values. -SetBooleanArray DOC 0:1 1 5 0 0 0 1 1 - -# Set a list of integer values. -SetIntegerList DOC 0:1 1971 1972 1973 1974 1975 - -# Set a list of boolean values. -SetBooleanList DOC 0:1 1 0 0 0 1 - -# Set a list of double values. -SetRealList DOC 0:1 0.98765432123456789e+21 0.98765432123456789e+22 0.98765432123456789e+23 - -set aFile ${imagedir}/bug23850_test.xml -# Save the document on disk. -SaveAs DOC ${aFile} -Close DOC - -# Open the document. -Open ${aFile} DOC - -# Get byte array and check its values. -set bytearray [GetByteArray DOC 0:1] -set bytearray1 [lindex ${bytearray} 0] -set bytearray2 [lindex ${bytearray} 1] -set bytearray3 [lindex ${bytearray} 2] -set bytearray4 [lindex ${bytearray} 3] -set bytearray5 [lindex ${bytearray} 4] -set bytearray6 [lindex ${bytearray} 5] -set bytearray7 [lindex ${bytearray} 6] -set bytearray8 [lindex ${bytearray} 7] -set bytearray9 [lindex ${bytearray} 8] -set bytearray10 [lindex ${bytearray} 9] -if { ${bytearray1} != 1 || - ${bytearray2} != 2 || - ${bytearray3} != 3 || - ${bytearray4} != 4 || - ${bytearray5} != 5 || - ${bytearray6} != 6 || - ${bytearray7} != 7 || - ${bytearray8} != 8 || - ${bytearray9} != 9 || - ${bytearray10} != 10 } { - puts "ByteArray failed..." -} else { - puts "ByteArray is OK" -} - -# Check tree nodes. -set nodes [ChildNodeIterate DOC 0:1 1] -set node1 [lindex ${nodes} 0] -set node2 [lindex ${nodes} 1] -set node3 [lindex ${nodes} 2] -set node4 [lindex ${nodes} 3] -set node5 [lindex ${nodes} 4] -set node6 [lindex ${nodes} 5] -set node7 [lindex ${nodes} 6] -set node8 [lindex ${nodes} 7] -if { ${node1} != "0:1:1" || - ${node2} != "0:1:2" || - ${node3} != "0:1:3" || - ${node4} != "0:1:4" || - ${node5} != "0:1:5" || - ${node6} != "0:1:6" || - ${node7} != "0:1:7" || - ${node8} != "0:1:8" } { - puts "TreeNode failed..." -} else { - puts "TreeNode is OK" -} - -# Check array of integer values. -set intarray [GetIntArray DOC 0:1] -set intarray1 [lindex ${intarray} 0] -set intarray2 [lindex ${intarray} 1] -set intarray3 [lindex ${intarray} 2] -set intarray4 [lindex ${intarray} 3] -set intarray5 [lindex ${intarray} 4] -if { ${intarray1} != 111 || - ${intarray2} != 222 || - ${intarray3} != 333 || - ${intarray4} != 444 || - ${intarray5} != 555 } { - puts "IntegerArray failed..." -} else { - puts "IntegerArray is OK" -} - -# Check array of double values. -# Warning!: It seems TCL uses 16 digits for manipulation with a double values... -set realarray [GetRealArray DOC 0:1] -set realarray1 [lindex ${realarray} 0] -set realarray2 [lindex ${realarray} 1] -set realarray3 [lindex ${realarray} 2] -set realarray4 [lindex ${realarray} 3] -set realarray5 [lindex ${realarray} 4] -if { ${realarray1} != 1.12345678987654321 || - ${realarray2} != 2.2 || - ${realarray3} != 3.3 || - ${realarray4} != 4.4 || - ${realarray5} != 5.5 } { - puts "RealArray failed..." -} else { - puts "RealArray is OK" -} - -# Check packed map of integer values. -set packedintmap [GetIntPackedMap DOC 0:1] -set nb [llength ${packedintmap}] -if { ${nb} != 5 } { - puts "IntPackedMap failed..." -} -set contains1 [lsearch ${packedintmap} 1] -set contains2 [lsearch ${packedintmap} 10] -set contains3 [lsearch ${packedintmap} 100] -set contains4 [lsearch ${packedintmap} 1000] -set contains5 [lsearch ${packedintmap} 10000] -if { ${contains1} == -1 || - ${contains2} == -1 || - ${contains3} == -1 || - ${contains4} == -1 || - ${contains5} == -1 } { - puts "Failed..." -} else { - puts "IntPackedMap is OK" -} - -# Get boolean array and check its values. -set boolarray [GetBooleanArray DOC 0:1] -set boolarray1 [lindex ${boolarray} 0] -set boolarray2 [lindex ${boolarray} 1] -set boolarray3 [lindex ${boolarray} 2] -set boolarray4 [lindex ${boolarray} 3] -set boolarray5 [lindex ${boolarray} 4] -if { ${boolarray1} != 0 || - ${boolarray2} != 0 || - ${boolarray3} != 0 || - ${boolarray4} != 1 || - ${boolarray5} != 1 } { - puts "BoolArray failed..." -} else { - puts "BoolArray is OK" -} - -# Get boolean list and check its values. -set boollist [GetBooleanList DOC 0:1] -set boollist1 [lindex ${boollist} 0] -set boollist2 [lindex ${boollist} 1] -set boollist3 [lindex ${boollist} 2] -set boollist4 [lindex ${boollist} 3] -set boollist5 [lindex ${boollist} 4] -if { ${boollist1} != 1 || - ${boollist2} != 0 || - ${boollist3} != 0 || - ${boollist4} != 0 || - ${boollist5} != 1 } { - puts "BoolList failed..." -} else { - puts "BoolList is OK" -} - -# Get integer list and check its values. -set intlist [GetIntegerList DOC 0:1] -set intlist1 [lindex ${intlist} 0] -set intlist2 [lindex ${intlist} 1] -set intlist3 [lindex ${intlist} 2] -set intlist4 [lindex ${intlist} 3] -set intlist5 [lindex ${intlist} 4] -if { ${intlist1} != 1971 || - ${intlist2} != 1972 || - ${intlist3} != 1973 || - ${intlist4} != 1974 || - ${intlist5} != 1975 } { - puts "IntList failed..." -} else { - puts "IntList is OK" -} - -# Get double list and check its values. -set reallist [GetRealList DOC 0:1] -set reallist1 [lindex ${reallist} 0] -set reallist2 [lindex ${reallist} 1] -set reallist3 [lindex ${reallist} 2] -if { ${reallist1} != 0.98765432123456789e+21 || - ${reallist2} != 0.98765432123456789e+22 || - ${reallist3} != 0.98765432123456789e+23 } { - puts "RealList failed..." -} else { - puts "RealList is OK" -} - -Close DOC -file delete test.xml -puts "bug0023850: OK" diff --git a/tests/caf/bugs/E1 b/tests/caf/bugs/E1 deleted file mode 100644 index 86add8f252..0000000000 --- a/tests/caf/bugs/E1 +++ /dev/null @@ -1,40 +0,0 @@ -puts "================" -puts "bug0028946" -puts "================" -puts "" - -###################################################### -# Checks bug of Undo mechanism -###################################################### - -set aLab [Label D 0:1] - -#1. Add to Main label two numeric attributes -SetInteger D $aLab 1 -SetReal D $aLab 1.5 - -#2. Forget Integer attribute -NewCommand D -ForgetAtt D $aLab 2a96b606-ec8b-11d0-bee7-080009dc3333 - -#3. Set new Integer attribute -SetInteger D $aLab 3 -NewCommand D - -#4. make Undo -set IsGood 1 -if [catch {Undo D}] { - puts "Error during Document Undo" - set IsGood 0 -} - -#5. Check result -if {$IsGood == 1} { - puts "bug0028946: OK" -} else { - puts "bug0028946: ERROR" -} - -#6. Close document -Close D - diff --git a/tests/caf/driver/A2 b/tests/caf/driver/A2 deleted file mode 100755 index 9efcc8603b..0000000000 --- a/tests/caf/driver/A2 +++ /dev/null @@ -1,95 +0,0 @@ -#Drivers' nick-names: -#Box|Sph|Cyl|Cut|Fuse|Prism|Revol|PTxyz|PTALine|PRLine|PMirr|Fillet|Attach|XAttach -# order of functions recomputation should be defined out of the tool (by end user) - -#Commands of transformation: -#PTranslateDXYZ Doc ShapeEntry dx dy dz -#PTranslateAlongLine Doc ShapeEntry Line off -#PRotateRoundLine Doc ShapeEntry Line Angle -#PMirror Doc ShapeEntry PlaneObj - -## Test of transformation functions -AddDriver D Box Attach PTxyz PTALine PRLine PMirr Sph -#1 - create box using more flexible set of commands -NewCommand D -set B2 [AddObject D]; ## add object -set F2 [AddFunction D $B2 Box]; ## add function -BoxDX D $B2 190; ## set arguments of this function -BoxDY D $B2 290 -BoxDZ D $B2 390 -InitLogBook D; ## initialize (clean) internal maps of labels -ComputeFun D $F2; ## compute the function -GetShape D $F2:2 Box2; ## check result -whatis Box2 -GetReference D $B2; ## refers to result NS - - -#2 -NewCommand D -set FTr1 [PTranslateDXYZ D $B2 150 40 90] -ComputeFun D $FTr1; ## function recomputation -GetShape D $FTr1:2 Box2; ## get modified result - -#3 -NewCommand D -explode Box2 F -explode Box2_1 E -set Sel1 [AttachShape D Box2_1_1 ${B2} ${B2} 1]; ## set attachment -set FTr2 [PTranslateAlongLine D $B2 $Sel1 210] -ComputeFun D $FTr2 -GetShape D $FTr2:2 Box3 - -#4 -NewCommand D -explode Box3 F -explode Box3_1 E -set Sel4 [AttachShape D Box3_1_3 ${B2} ${B2} 1]; -set FR1 [PRotateRoundLine D $B2 $Sel4 120] -ComputeFun D $FR1 -GetShape D $FR1:2 Box4 - -#5 -NewCommand D -explode Box4 F -set Sel5 [AttachShape D Box4_3 ${B2} ${B2} 1]; -set FM [PMirror D $B2 $Sel5] -ComputeFun D $FM -GetShape D $FM:2 Box5 - -#6 -NewCommand D -explode Box5 F -explode Box5_1 E -set Sel6 [AttachShape D Box5_1_3 ${B2} ${B2} 1]; -AddDriver D Fillet -set Fill [AddFillet D $B2 25 $Sel6 0] -ComputeFun D $Fill -GetShape D $Fill:2 SF - -#7 -NewCommand D -set SL [TestSingleSelection D $B2 1] -set SL2 [TestMultipleSelection D $B2 0] - -#7 modification -NewCommand D -BoxDX D $B2 290 - -#8 order of recomputation -NewCommand D -InitLogBook D; ## to be initialized before any recomputation of impacted functions set (if attachments are presented) -ComputeFun D $F2; -ComputeFun D $FTr1; -ComputeFun D $Sel1:1 -ComputeFun D $FTr2 -ComputeFun D $Sel4:1 -ComputeFun D $FR1 -ComputeFun D $Sel5:1 -ComputeFun D $FM -ComputeFun D $Sel6:1 -ComputeFun D $Fill -GetShape D $Fill:2 SF-new - -SolveFlatFrom D $SL - -NewCommand D diff --git a/tests/caf/driver/A9 b/tests/caf/driver/A9 deleted file mode 100755 index 696c4dcb1d..0000000000 --- a/tests/caf/driver/A9 +++ /dev/null @@ -1,120 +0,0 @@ -#1 - create Box using short-cut -NewCommand D -AddDriver D Box; ## add box driver to driver table -set B1 [AddBox D 130 140 150]; ## add box -ComputeFun D $B1:1; ## compute box1 function -GetShape D $B1:1:2 Box1; ## check result -whatis Box1 -# refers to result NS -GetReference D $B1; ## check is reference set - - -#2 - create 8 spheres -AddDriver D Cyl Sph Attach XAttach PTxyz PTALine PRLine PMirr Cut Fuse Prism FulRevol SecRevol Fillet -NewCommand D -explode Box1 V -set SPnt1 [AttachShape D Box1_1 ${B1} ${B1} 0]; ## set attachment -set SPnt2 [AttachShape D Box1_2 ${B1} ${B1} 0]; ## set attachment -set SPnt3 [AttachShape D Box1_3 ${B1} ${B1} 0]; ## set attachment -set SPnt4 [AttachShape D Box1_4 ${B1} ${B1} 0]; ## set attachment - -set Sph1 [AddSphere D $SPnt1 25] -ComputeFun D $Sph1:1 -GetShape D $Sph1:1:2 Sp1 - -set Sph2 [AddSphere D $SPnt2 25] -ComputeFun D $Sph2:1 -GetShape D $Sph2:1:2 Sp2 - -set Sph3 [AddSphere D $SPnt3 25] -ComputeFun D $Sph3:1 -GetShape D $Sph3:1:2 Sp3 - -set Sph4 [AddSphere D $SPnt4 25] -ComputeFun D $Sph4:1 -GetShape D $Sph4:1:2 Sp4 -NewCommand D - -#3 Rotate spheres -explode Box1 E -set Sel1 [AttachShape D Box1_1 ${B1} ${B1} 0]; -set FR1 [PRotateRoundLine D $Sph1 $Sel1 120] -ComputeFun D $FR1 -GetShape D $FR1:2 Sp1 - -set Sel2 [AttachShape D Box1_1 ${B1} ${B1} 0]; -set FR2 [PRotateRoundLine D $Sph2 $Sel2 120] -ComputeFun D $FR2 -GetShape D $FR2:2 Sp2 - -set Sel3 [AttachShape D Box1_3 ${B1} ${B1} 0]; -set FR3 [PRotateRoundLine D $Sph3 $Sel3 120] -ComputeFun D $FR3 -GetShape D $FR3:2 Sp3 - -set Sel4 [AttachShape D Box1_3 ${B1} ${B1} 0]; -set FR4 [PRotateRoundLine D $Sph4 $Sel4 120] -ComputeFun D $FR4 -GetShape D $FR4:2 Sp4 -NewCommand D - -#4 Fuse spheres -set FS1 [AddFuse D $B1 $Sph1] -ComputeFun D $FS1 -GetShape D $FS1:2 Box1 - -set FS2 [AddFuse D $B1 $Sph2] -ComputeFun D $FS2 -GetShape D $FS2:2 Box1 - -set FS3 [AddFuse D $B1 $Sph3] -ComputeFun D $FS3 -GetShape D $FS3:2 Box1 - -set FS4 [AddFuse D $B1 $Sph4] -ComputeFun D $FS4 -GetShape D $FS4:2 Box1 - - -#5 test selection -NewCommand D -set SL [TestSingleSelection D $B1 0] -set SL2 [TestMultipleSelection D $B1 0] - -#6 modification -NewCommand D -BoxDX D $B1 210 -BoxDZ D $B1 270 - -#7 recomputation -NewCommand D -InitLogBook D; ## to be initialized before any recomputation of impacted functions set (if attachments are presented) -ComputeFun D $B1:1 -ComputeFun D $SPnt1:1 -ComputeFun D $SPnt2:1 -ComputeFun D $SPnt3:1 -ComputeFun D $SPnt4:1 -ComputeFun D $Sph1:1 -ComputeFun D $Sph2:1 -ComputeFun D $Sph3:1 -ComputeFun D $Sph4:1 -ComputeFun D $Sel1:1 -ComputeFun D $Sel2:1 -ComputeFun D $Sel3:1 -ComputeFun D $Sel4:1 -ComputeFun D $FR1 -ComputeFun D $FR2 -ComputeFun D $FR3 -ComputeFun D $FR4 -ComputeFun D $FS1 -ComputeFun D $FS2 -ComputeFun D $FS3 -ComputeFun D $FS4 -erase -GetShape D $FS4:2 Box1 - - -#recomputation of entities of the TestSelection commands -SolveFlatFrom D $SL -NewCommand D - diff --git a/tests/caf/driver/B2 b/tests/caf/driver/B2 deleted file mode 100755 index e337a72506..0000000000 --- a/tests/caf/driver/B2 +++ /dev/null @@ -1,69 +0,0 @@ -#1 - create Box using short-cut -NewCommand D -AddDriver D Box; ## add box driver to driver table -set B1 [AddBox D 130 140 150]; ## add box -ComputeFun D $B1:1; ## compute box1 function -GetShape D $B1:1:2 Box1; ## check result -whatis Box1 -# refers to result NS -GetReference D $B1; ## check is reference set - - -#2 - create 8 spheres -AddDriver D Cyl Sph Attach XAttach PTxyz PTALine PRLine PMirr Cut Fuse Prism FulRevol SecRevol Fillet -NewCommand D -explode Box1 V -set SPnt1 [AttachShape D Box1_1 ${B1} ${B1} 0]; ## set attachment - -set Sph1 [AddSphere D $SPnt1 250] -ComputeFun D $Sph1:1 -GetShape D $Sph1:1:2 Sp1 - -#3 -NewCommand D -set Sph2 [AddSphere D $SPnt1 30] -ComputeFun D $Sph2:1 -GetShape D $Sph2:1:2 Sp2 -erase Box1 - -#4 -NewCommand D -set FTr2 [PTranslateDXYZ D $Sph2 0 -253 0] -ComputeFun D $FTr2 -GetShape D $Sph2:2:2 Sp2 - - -#5 Fuse spheres -NewCommand D -set FS1 [AddFuse D $Sph1 $Sph2] -ComputeFun D $FS1 -GetShape D $FS1:2 Sp1 - -#6 test selection -NewCommand D -set SL [TestSingleSelection D $Sph1 0] -## Wires defined as UNION (seam edge of each sphere) fail ==> linked with degenerated edges problem -set SL2 [TestMultipleSelection D $Sph1 0] - -#7 modification -NewCommand D -BoxDZ D $B1 270 - -#8 recomputation -NewCommand D -InitLogBook D; ## to be initialized before any recomputation of impacted functions set (if attachments are presented) -ComputeFun D $B1:1 -ComputeFun D $SPnt1:1 -ComputeFun D $Sph1:1 -ComputeFun D $Sph2:1 - -ComputeFun D $FTr2 -ComputeFun D $FS1 -erase -GetShape D $FS1:2 Sp1 - - -#recomputation of entities of the TestSelection commands -SolveFlatFrom D $SL -NewCommand D - diff --git a/tests/caf/driver/B3 b/tests/caf/driver/B3 deleted file mode 100755 index 58b9046a97..0000000000 --- a/tests/caf/driver/B3 +++ /dev/null @@ -1,124 +0,0 @@ -#1 - create Box using short-cut -NewCommand D -AddDriver D Box; ## add box driver to driver table -set B1 [AddBox D 130 140 150]; ## add box -ComputeFun D $B1:1; ## compute box1 function -GetShape D $B1:1:2 Box1; ## check result -whatis Box1 -# refers to result NS -GetReference D $B1; ## check is reference set - - -#2 - create main sphere -AddDriver D Cyl Sph Attach XAttach PTxyz PTALine PRLine PMirr Cut Fuse Prism FulRevol SecRevol Fillet -NewCommand D -explode Box1 V -set SPnt1 [AttachShape D Box1_1 ${B1} ${B1} 0]; ## set attachment -erase Box1 - -set Sph0 [AddSphere D $SPnt1 250] -ComputeFun D $Sph0:1 -GetShape D $Sph0:1:2 Sp0 - -#3 create Sphere1 -NewCommand D -set Sph1 [AddSphere D $SPnt1 30] -ComputeFun D $Sph1:1 -GetShape D $Sph1:1:2 Sp1 - -NewCommand D -set FTr1 [PTranslateDXYZ D $Sph1 0 -251 0] -ComputeFun D $FTr1 -GetShape D $Sph1:2:2 Sp1 - -#4 create Sphere2 -NewCommand D -set Sph2 [AddSphere D $SPnt1 30] -ComputeFun D $Sph2:1 -GetShape D $Sph2:1:2 Sp2 - -set FTr2 [PTranslateDXYZ D $Sph2 0 251 0] -ComputeFun D $FTr2 -GetShape D $Sph2:2:2 Sp2 - -#5 create Sphere3 -NewCommand D -set Sph3 [AddSphere D $SPnt1 30] -ComputeFun D $Sph3:1 -GetShape D $Sph3:1:2 Sp3 - -explode Box1 E -set Sel3 [AttachShape D Box1_1 ${B1} ${B1} 0]; -set FR3 [PRotateRoundLine D $Sph3 $Sel3 120] -ComputeFun D $FR3 -GetShape D $FR3:2 Sp3 - -set FTr3 [PTranslateDXYZ D $Sph3 -251 0 0] -ComputeFun D $FTr3 -GetShape D $Sph3:3:2 Sp3 - -#6 create Sphere4 -NewCommand D -set Sph4 [AddSphere D $SPnt1 30] -ComputeFun D $Sph4:1 -GetShape D $Sph4:1:2 Sp4 - -set FTr4 [PTranslateDXYZ D $Sph4 251 -40 0] -ComputeFun D $FTr4 -GetShape D $Sph4:2:2 Sp4 - -#7 Cut spheres -set Cut1 [AddCut D $Sph0 $Sph1] -ComputeFun D $Cut1 -GetShape D $Cut1:2 Sp0 - -set Cut2 [AddCut D $Sph0 $Sph2] -ComputeFun D $Cut2 -GetShape D $Cut2:2 Sp0 - -set Cut3 [AddCut D $Sph0 $Sph3] -ComputeFun D $Cut3 -GetShape D $Cut3:2 Sp0 - -set Cut4 [AddCut D $Sph0 $Sph4] -ComputeFun D $Cut4 -GetShape D $Cut4:2 Sp0 - - -#5 test selection -NewCommand D -set SL [TestSingleSelection D $Sph0 0] -set SL2 [TestMultipleSelection D $Sph0 0] - -#6 modification -NewCommand D -BoxDZ D $B1 270 - -#7 recomputation -NewCommand D -InitLogBook D; ## to be initialized before any recomputation of impacted functions set (if attachments are presented) -ComputeFun D $B1:1 -ComputeFun D $SPnt1:1 -ComputeFun D $Sph0:1 -ComputeFun D $Sph1:1 -ComputeFun D $FTr1 -ComputeFun D $Sph2:1 -ComputeFun D $FTr2 -ComputeFun D $Sph3:1 -ComputeFun D $Sel3:1 -ComputeFun D $FR3 -ComputeFun D $FTr3 -ComputeFun D $Sph4:1 -ComputeFun D $FTr4 -ComputeFun D $Cut1 -ComputeFun D $Cut2 -ComputeFun D $Cut3 -ComputeFun D $Cut4 -erase -GetShape D $Cut4:2 Sp0 - - -#recomputation of entities of the TestSelection commands -SolveFlatFrom D $SL -NewCommand D - diff --git a/tests/caf/nam/A1 b/tests/caf/nam/A1 deleted file mode 100644 index 7b2769c438..0000000000 --- a/tests/caf/nam/A1 +++ /dev/null @@ -1,100 +0,0 @@ -set Test "TNaming_Builder test" -set IsDone 1 -set TestError "" - -if {[catch {set TestLab}] == 1} { - NewDocument D - set TestLab 0:1 -} - -#################### PRIMITIVE EVOLUTION #################### -box b 100 200 300 -explode b E -if {[catch {BuildNamedShape D $TestLab:1 PRIMITIVE b}] == 1} { - set IsDone 0 - set TestError "$TestError # Can't build solid as primitive" -} -if {[catch {BuildNamedShape D [set TestLab]:1:1 PRIMITIVE b_1}] == 1} { - set IsDone 0 - set TestError "$TestError # Can't build edge as alone primitive" -} -if {[catch {BuildNamedShape D [set TestLab]:1:1 PRIMITIVE b_1 b_2 b_3}] == 1} { - set IsDone 0 - set TestError "$TestError # Can't build several edges as primitive over the old one" -} -if {[catch {BuildNamedShape D [set TestLab]:1:2 PRIMITIVE b_4 b_5 b_6}] == 1} { - set IsDone 0 - set TestError "$TestError # Can't build several edges as primitive" -} - -#################### GENERATED EVOLUTION #################### -box b2 200 300 400 -explode b2 F -if {[catch {BuildNamedShape D $TestLab:2 GENERATED b b2}] == 1} { - set IsDone 0 - set TestError "$TestError # Can't build solid as generation" -} -if {[catch {BuildNamedShape D [set TestLab]:2:1 GENERATED b_1 b2_1}] == 1} { - set IsDone 0 - set TestError "$TestError # Can't build face as alone generation" -} -if {[catch {BuildNamedShape D [set TestLab]:2:2 GENERATED b_2 b2_2 b_2 b2_3 b_3 b2_4}] == 1} { - set IsDone 0 - set TestError "$TestError # Can't build face as generation n:m" -} -if {[catch {BuildNamedShape D [set TestLab]:2:1 GENERATED b_3 b2_1 b_3 b2_3 b_4 b2_4}] == 1} { - set IsDone 0 - set TestError "$TestError # Can't build face as generation n:m to the exists named shape" -} - -#################### MODIFY EVOLUTION #################### -box b3 300 400 500 -explode b3 F -if {[catch {BuildNamedShape D $TestLab:3 MODIFY b2 b3}] == 1} { - set IsDone 0 - set TestError "$TestError # Can't build solid as modification" -} -if {[catch {BuildNamedShape D [set TestLab]:3:1 MODIFY b2_1 b3_1}] == 1} { - set IsDone 0 - set TestError "$TestError # Can't build face as alone modification" -} -if {[catch {BuildNamedShape D [set TestLab]:3:2 MODIFY b2_5 b3_2 b2_2 b3_3 b2_3 b3_4}] == 1} { - set IsDone 0 - set TestError "$TestError # Can't build face as modification n:m" -} -if {[catch {BuildNamedShape D [set TestLab]:3:1 MODIFY b2_3 b3_1 b_3 b3_3 b2_4 b3_4}] == 1} { - set IsDone 0 - set TestError "$TestError # Can't build face as modification n:m to the exists named shape" -} - -#################### DELETE EVOLUTION #################### -if {[catch {BuildNamedShape D $TestLab:4:1 DELETE b3_1}] == 1} { - set IsDone 0 - set TestError "$TestError # Can't delete face" -} -if {[catch {BuildNamedShape D $TestLab:4:1 DELETE b3_1 b3_4}] == 1} { - set IsDone 0 - set TestError "$TestError # Can't delete faces at the same label" -} - -#################### REPLACE EVOLUTION DELETED: TEST REPLACED BY MODIFY #################### -box b4 100 100 100 300 400 500 -explode b4 F -if {[catch {BuildNamedShape D [set TestLab]:5 MODIFY b3 b4}] == 1} { - set IsDone 0 - set TestError "$TestError # Can't build solid as replace" -} -if {[catch {BuildNamedShape D [set TestLab]:5:1 MODIFY b3_2 b4_2 b3_3 b4_3}] == 1} { - set IsDone 0 - set TestError "$TestError # Can't build faces as replace 2:2" -} - -#################### SELECTED #################### -if {[catch {BuildNamedShape D [set TestLab]:6 SELECTED b4 b4}] == 1} { - set IsDone 0 - set TestError "$TestError # Can't build solid selection" -} -if {[catch {BuildNamedShape D [set TestLab]:6:1 SELECTED b4_2 b4_2 b2_5 b2_5}] == 1} { - set IsDone 0 - set TestError "$TestError # Can't build faces selection" -} diff --git a/tests/caf/nam/A2 b/tests/caf/nam/A2 deleted file mode 100644 index be80e640c0..0000000000 --- a/tests/caf/nam/A2 +++ /dev/null @@ -1,129 +0,0 @@ -if {[catch {set TestLab}] == 1} { - NewDocument D - set TestLab 0:1 -} - -set IsDone 1 -source ${scriptdir}/A1 - -if {$IsDone == 0} { - set Test "TNaming_Iterator test" - set IsDone 0 - set TestError " # Can't test iterators because of Builder errors" -} else { - -set Test "TNaming_Iterator test" -set IsDone 1 -set TestError "" - -set labels "1 1:1 1:2 2 2:1 2:2 3 3:1 3:2 4:1 5 5:1 6 6:1" -set myNewShapesOutput "PRIMITIVE 1 PRIMITIVE 3 PRIMITIVE 3 GENERATED 1 GENERATED 3 GENERATED 3 MODIFY 1 MODIFY 3 MODIFY 3 DELETE 0 MODIFY 1 MODIFY 2 SELECTED 1 SELECTED 2" -set myOldShapesOutput "PRIMITIVE 0 PRIMITIVE 0 PRIMITIVE 0 GENERATED 1 GENERATED 3 GENERATED 3 MODIFY 1 MODIFY 3 MODIFY 3 DELETE 2 MODIFY 1 MODIFY 2 SELECTED 1 SELECTED 2" -set myAllNewShapesOutput "3 14 2 2 3 5 1 1 2 0 0 0 0 2" -set myAllOldShapesOutput "0 0 0 1 3 3 2 6 5 0 3 5 3 2" - -set r "" -for {set i 0} {[lindex $labels $i]!=""} {incr i} { - set lab [set TestLab]:[lindex $labels $i] - -#################### Iterator #################### - if {[catch {GetNewShapes D $lab}] == 1} { - set IsDone 0 - set TestError "$TestError # GetNewShapes at label $lab" - } else { - set r [GetNewShapes D $lab] - set oldr "[lindex $myNewShapesOutput [expr $i*2]] [lindex $myNewShapesOutput [expr $i*2+1]]" - if { $r != $oldr } { - set IsDone 0 - set TestError "$TestError # GetNewShapes at label $lab: need $oldr, but got $r" - } - } - -#################### Iterator #################### - if {[catch {GetOldShapes D $lab}] == 1} { - set IsDone 0 - set TestError "$TestError # GetOldShapes at label $lab" - } else { - set r [GetOldShapes D $lab] - set oldr "[lindex $myOldShapesOutput [expr $i*2]] [lindex $myOldShapesOutput [expr $i*2+1]]" - if { $r != $oldr } { - set IsDone 0 - set TestError "$TestError # GetOldShapes at label $lab: need $oldr, but got $r" - } - } - -#################### NewShapesIterator #################### - if {[catch {GetAllNewShapes D $lab}] == 1} { - set IsDone 0 - set TestError "$TestError # GetAllNewShapes at label $lab" - } else { - set r [GetAllNewShapes D $lab] - set oldr "[lindex $myAllNewShapesOutput $i]" - if { $r != $oldr } { - set IsDone 0 - set TestError "$TestError # GetAllNewShapes at label $lab: need $oldr, but got $r" - } - } - -#################### OldShapesIterator #################### - if {[catch {GetAllOldShapes D $lab}] == 1} { - set IsDone 0 - set TestError "$TestError # GetAllOldShapes at label $lab" - } else { - set r [GetAllOldShapes D $lab] - set oldr "[lindex $myAllOldShapesOutput $i]" - if { $r != $oldr } { - set IsDone 0 - set TestError "$TestError # GetAllOldShapes at label $lab: need $oldr, but got $r" - } - } - -} - -#################### SameShapesIterator && NewShapesIterator #################### -set mySame "1 2 2 1 3 2 1 2 1 1 2 1 3 2 1 3 4 3 4 1 2" - -GetAllNewShapes D [set TestLab]:1:1 o -GetAllOldShapes D [set TestLab]:3:1 u - -set shapes "b o_1_1 o_1_2 o_1_3 o_1_4 o_1_5 o_1_6 o_1_7 o_1_8 o_2_1 o_2_2 o_2_3 o_2_4 o_2_5 o_2_6 u_3_1 u_3_2 u_1_1 u_1_2 u_2_1 u_2_2" - -for {set i 0} {[lindex $shapes $i]!=""} {incr i} { - if {[catch {GetSameShapes D [lindex $shapes $i]}] == 1} { - set IsDone 0 - set TestError "$TestError # GetSameShapes D for [lindex $shapes $i]" - } else { if {[lindex $mySame $i] != [llength [GetSameShapes D [lindex $shapes $i]]]} { - set IsDone 0 - set TestError "$TestError # GetSameShapes D for [lindex $shapes $i]: \ - [lindex $mySame $i] != [llength [GetSameShapes D [lindex $shapes $i]]]" - } - } -} - -set myr "u_2_1 o_2_1 u_1_2 u_3_2 u_1_1 u_3_1 u_1_1 o_2_4 u_1_1 o_1_4 u_3_1 o_2_4 u_3_1 o_1_4 o_2_6 o_1_6 o_2_5 o_1_5 o_2_5 o_1_2 o_2_4 o_1_4 o_2_3 o_1_8 o_2_2 o_1_7 o_1_5 o_1_2" - -for {set i 0} {[lindex $myr $i]!=""} {incr i 2} { - if {[IsSameShapes [lindex $myr $i] [lindex $myr [expr $i+1]]]!=1} { - set IsDone 0 - set TestError "$TestError # [lindex $myr $i] and [lindex $myr [expr $i+1]] not equal" - } -} - -for {set i 1} {[lindex $shapes $i]!=""} {incr i} { - for {set j 0} {$j < $i} {incr j} { - if {[IsSameShapes [lindex $shapes $i] [lindex $shapes $j]]==1} { - set r "[lindex $shapes $i] [lindex $shapes $j]" - set yes 0 - for {set k 0} {[lindex $myr $k]!=""} {incr k 2} { - if {[lindex $myr $k] == [lindex $r 0]} {if {[lindex $myr [expr $k+1]] == [lindex $r 1]} {set yes 1}} - if {[lindex $myr $k] == [lindex $r 1]} {if {[lindex $myr [expr $k+1]] == [lindex $r 0]} {set yes 1}} - } - if {$yes == 0} { - set IsDone 0 - set TestError "$TestError # $r not equal" - } - } - } -} - -} diff --git a/tests/caf/nam/A3 b/tests/caf/nam/A3 deleted file mode 100644 index 0190276baf..0000000000 --- a/tests/caf/nam/A3 +++ /dev/null @@ -1,147 +0,0 @@ -set Test "TNaming_Tool test" -set IsDone 1 -set TestError "" - -if {[catch {set TestLab}] == 1} { - NewDocument D - set TestLab 0:1 -} - -#################### make triangle face #################### -vertex v1 0 0 0 -vertex v2 0 100 0 -vertex v3 100 0 0 -line l1 0 0 0 0 1 0 -line l2 0 100 0 1 -1 0 -line l3 100 0 0 -1 0 0 -mkedge e1 l1 v1 v2 -mkedge e2 l2 v2 v3 -mkedge e3 l3 v3 v1 -wire w e1 e2 e3 -plane pl 0 0 1 -mkface f pl w - -#################### load it to the DF #################### -BuildNamedShape D [set TestLab]:1 PRIMITIVE f -for {set a 1} {$a <= 3} {incr a} { - set lab [set TestLab]:1:$a - BuildNamedShape D $lab PRIMITIVE e$a -} - -#################### make prism at face and load #################### -prism p f 0 0 100 -BuildNamedShape D [set TestLab]:2 PRIMITIVE p - -explode p F -set needgenerate "" -set primitivelabel 2 -for {set a 1} {$a <= 5} {incr a} { - set ex [explode p_$a E] - if {[llength $ex] == 4} { - for {set i 1} {$i <= 3} {incr i} { - for {set j 1} {$j <= 3} {incr j} { - if {[IsSameShapes e$i [lindex $ex $j]]==1} { - if {[string compare $needgenerate ""] == 0} {set needgenerate "e$i p_$a"} else {set needgenerate "$needgenerate e$i p_$a"} - } - } - } - } else { - BuildNamedShape D [set TestLab]:2:$primitivelabel PRIMITIVE p_$a - incr primitivelabel - } -} -BuildNamedShape D [set TestLab]:2:1 GENERATED [lindex $needgenerate 0] [lindex $needgenerate 1] [lindex $needgenerate 2] [lindex $needgenerate 3] [lindex $needgenerate 4] [lindex $needgenerate 5] - -#################### make box, cut prism, load #################### -box b 0 0 20 100 100 20 -explode b F -BuildNamedShape D [set TestLab]:3 PRIMITIVE b -for {set a 1} {$a <= 6} {incr a} { - BuildNamedShape D [set TestLab]:3:$a PRIMITIVE b_$a -} - -bcut c p b -BuildNamedShape D [set TestLab]:4 MODIFY p c -explode c F -set needgenerate "" -set needmodify "" -set py "" -set px "" -set pxy "" -set p0 "" -set pz "" - -for {set i 1} {$i<=5} {incr i} { - set center [CenterOfShape p_$i] - if {[lindex $center 0] == 50} { - if {[lindex $center 1] == 50} {set pxy p_$i} else {set px p_$i} - } else {if {[lindex $center 1] == 50} {set py p_$i}} -} -for {set i 1} {$i <= 10} {incr i} { - set center [CenterOfShape c_$i] - if {[lindex $center 0] == 50} { - if {[lindex $center 1] == 50} {set needgenerate "$pxy c_$i $needgenerate"} else { - set needgenerate "$px c_$i $needgenerate"} - } else {if {[lindex $center 1] == 50} {set needgenerate "$py c_$i $needgenerate"} else { - if {[lindex $center 2] == 20} {set needmodify "b_5 c_$i $needmodify"} - if {[lindex $center 2] == 40} {set needmodify "b_6 c_$i $needmodify"} - } - } -} -BuildNamedShape D [set TestLab]:4:1 MODIFY [lindex $needgenerate 0] [lindex $needgenerate 1] [lindex $needgenerate 2] [lindex $needgenerate 3] [lindex $needgenerate 4] [lindex $needgenerate 5] [lindex $needgenerate 6] [lindex $needgenerate 7] [lindex $needgenerate 8] [lindex $needgenerate 9] [lindex $needgenerate 10] [lindex $needgenerate 11] -BuildNamedShape D [set TestLab]:4:2 GENERATED [lindex $needmodify 0] [lindex $needmodify 1] [lindex $needmodify 2] [lindex $needmodify 3] b_1 b_1 - -#################### test TNamig_Tool::NamedShape command #################### -set names "e1 e2 e3 p p_1 p_2 p_3 p_5 b b_1 b_2 b_3 b_4 b_5 b_6 c c_1 c_5 c_4 c_3 c_6 c_10 c_7 c_9 c_8" -set entities "1:1 1:2 1:3 2 2:1 2:1 2:1 2:3 3 3:1 3:2 3:3 3:4 3:5 3:6 4 4:1 4:1 4:2 4:1 4:1 4:1 4:2 2:3 4:1" - -for {set i 0} {[string compare [lindex $names $i] ""] != 0} {incr i} { -# puts "name = [lindex $names $i], entity = [lindex $entities $i]" - set r [NamedShape D [lindex $names $i]] - if {[string compare $r "[set TestLab]:[lindex $entities $i]"] != 0} { -# puts "error" - set IsDone 0 - set TestError "$TestError # NamedShape: need [set TestLab]:[lindex $entities $i] label, got $r" - } -} -#################### test TNaming_Tool::CurrentShape command #################### -set entities "1 1:1 1:2 1:3 2 2:1 2:2 2:3 3 3:1 3:2 3:3 3:4 3:5 3:6 4 4:1 4:2" -# rem: f p_4 c_2 are same, p_5 c_9 are same -set names "c_2 e1 e2 e3 c # p_4 c_9 b b_1 b_2 b_3 b_4 b_5 b_6 c # #" - -for {set i 0} {[string compare [lindex $entities $i] ""] != 0} {incr i} { - CurrentShape D "[set TestLab]:[lindex $entities $i]" r - if {[string compare [lindex $names $i] "#"] == 0} { - set a [explode r F] - if {[expr {([llength $a]!=6 && ($i==5 || $i==16)) || ([llength $a]!=2 && $i==17)}]} { - set IsDone 0 - set TestError "$TestError # CurrentShape shape at [set TestLab]:[lindex $entities $i] has bad compound" - } - } else { - if {[IsSameShapes r [lindex $names $i]]!=1} { - set IsDone 0 - set TestError "$TestError # CurrentShape shape at [set TestLab]:[lindex $entities $i] and [lindex $names $i] is not same" - } - } -} - -#################### test TNaming_Tool::GetShape command #################### -set entities "1 1:1 1:2 1:3 2 2:1 2:2 2:3 3 3:1 3:2 3:3 3:4 3:5 3:6 4 4:1 4:2" -# rem: f p_4 c_2 are same, p_5 c_9 are same -set names "c_2 e1 e2 e3 p # p_4 c_9 b b_1 b_2 b_3 b_4 b_5 b_6 c # #" - -for {set i 0} {[string compare [lindex $entities $i] ""] != 0} {incr i} { - GetShape D "[set TestLab]:[lindex $entities $i]" r - if {[string compare [lindex $names $i] "#"] == 0} { - set a [explode r F] - if {[expr {([llength $a]!=3 && $i==5) || ([llength $a]!=6 && $i==16) || ([llength $a]!=2 && $i==17)}]} { - set IsDone 0 - set TestError "$TestError # GetShape shape at [set TestLab]:[lindex $entities $i] has bad compound" - } - } else { - if {[IsSameShapes r [lindex $names $i]]!=1} { - set IsDone 0 - set TestError "$TestError # GetShape shape at [set TestLab]:[lindex $entities $i] and [lindex $names $i] is not same" - } - } -} diff --git a/tests/caf/nam/A4 b/tests/caf/nam/A4 deleted file mode 100644 index 4e33f0ff01..0000000000 --- a/tests/caf/nam/A4 +++ /dev/null @@ -1,53 +0,0 @@ -set Test "TNaming_Translator test" -set IsDone 1 -set TestError "" - -if {[catch {set TestLab}] == 1} { - NewDocument D - set TestLab 0:1 -} - -#################### make box and it's copy #################### -box b 12 13 14 -set cb [CopyShape b] - -explode b F -if {[llength [explode $cb F]] != 6} { - set IsDone 0 - set TestError "$TestError # Copy of box has bad number of faces" -} - -if {[IsSameShapes b $cb]==1} { - set IsDone 0 - set TestError "$TestError # Box and it's copy are same" -} -for {set i 1} {$i <= 6} {incr i} { - set comp 0 - for {set j 1} {$j <= 6} {incr j} { - if {[IsSameShapes b_$i [set cb]_$j]==1} { - set IsDone 0 - set TestError "$TestError # Subface of copy of box [set cb]_$j] and face b_$i are same" - } - if {[CenterOfShape b_$i] == [CenterOfShape [set cb]_$j]} {incr comp} - } - if {$comp != 1} { - set IsDone 0 - set TestError "$TestError # face b_$i has no twin in the copy subshapes set" - } -} - -#################### translation testing #################### -if {[CenterOfShape b] != [CenterOfShape $cb]} { - set IsDone 0 - set TestError "$TestError # shapes has different location" -} -ttranslate b 50 40 30 -if {[CenterOfShape b] == [CenterOfShape $cb]} { - set IsDone 0 - set TestError "$TestError # shapes has same location after retranslation" -} -set cb [CopyShape b] -if {[CenterOfShape b] != [CenterOfShape $cb]} { - set IsDone 0 - set TestError "$TestError # shapes has different location after retranslation" -} diff --git a/tests/caf/nam/A5 b/tests/caf/nam/A5 deleted file mode 100644 index 73bc37363d..0000000000 --- a/tests/caf/nam/A5 +++ /dev/null @@ -1,98 +0,0 @@ -#################### select shape and check selection procedure #################### -proc Select {lab shape context} { - global D IsDone TestError - upvar 1 $shape myshape $context mycontext - set res "" - if {[string compare $context ""] == 0} { - if {[catch {set res [SelectShape D $lab myshape]}]} { - set IsDone 0 - set TestError "$TestError # SelectShape bad result for args: $lab myshape" - } - } else { - if {[catch {set res [SelectShape D $lab myshape mycontext]}]} { - set IsDone 0 - set TestError "$TestError # SelectShape bad result for args: $lab myshape" - } - } - return [CenterOfShape myshape] -} - -if {[catch {set TestLab}] == 1} { - NewDocument D - set TestLab 0:1 -} - -set IsDone 1 -source ${scriptdir}/A3 -set Test "TNaming_Selector test" -if {$IsDone == 0} { - set TestError " # Can't test iterators because of Tool errors: # $TestError" -} else { - -#################### selection and checking shapes #################### - -### IDENTIFY NAMING -set res1 [Select "[set TestLab]:10:1" f ""] -set res2 [Select "[set TestLab]:10:2" e1 f] -set res3 [Select "[set TestLab]:10:3" e2 ""] -### INTERSECTION NAMING (complex : with GENERATION and IDENTITY) -set res4 [Select "[set TestLab]:10:4" v1 "f"] -explode b E -set res5 [Select "[set TestLab]:10:5" b_1 "b"] -puts [dump $res5] -explode b V -set res6 [Select "[set TestLab]:10:6" b_1 "b"] -explode c E -# labels 7-24 - -if {0} { - -for {set i 1} {$i <= 18} {incr i} { - set res[expr $i+6] [Select "[set TestLab]:10:[expr $i+6]" c_$i "c"] -} -explode c F -# labels 25-32 -for {set i 1} {$i <= 8} {incr i} { - set res[expr $i+24] [Select "[set TestLab]:10:[expr $i+24]" c_$i "c"] -} -#################### simple GENERATION naming #################### -#explode p F -##labels 33-35 -#for {set i 1} {$i <= 3} {incr i} { -# set res[expr $i+32] [Select "[set TestLab]:10:[expr $i+32]" p_$i "p"] -#} -explode c So -set res33 [Select "[set TestLab]:10:33" c_1 c] -set res34 [Select "[set TestLab]:10:34" c_2 c] -####################### simple MODIFUNTIL naming #################### -set res35 [Select "[set TestLab]:10:35" c ""] - -#################### solve selection checking with empty valid map #################### -for {set i 1} {$i <= 35} {incr i} { - if {[catch {SolveSelection D [set TestLab]:10:$i}]} { - set IsDone 0 - set TestError "$TestError # SolveSelection failed for label [set TestLab]:10:$i" - } else { - GetShape D [set TestLab]:10:$i r - if {[string compare [CenterOfShape r] [set res$i]] != 0} { - set IsDone 0 - set TestError "$TestError # SolveSelection result not same for lab $i : [CenterOfShape r] and [set res$i]" - } - } -} -#################### with set valid map #################### - -} - -puts "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" - -if {[catch {SolveSelection D [set TestLab]:10:4 [set TestLab]:1:1}] == 0} { - set IsDone 0 - set TestError "$TestError # SolveSelection is not failed with deficit of valid map (label [set TestLab]:10:4)" -} -#if {[catch {SolveSelection D [set TestLab]:10:4 [set TestLab]:1:1 [set TestLab]:1:3}] == 1} { -# set IsDone 0 -# set TestError "$TestError # SolveSelection failed for good valid map (label [set TestLab]:10:4)" -#} - -} diff --git a/tests/caf/named_shape/A1 b/tests/caf/named_shape/A1 deleted file mode 100755 index 7e90dbd05c..0000000000 --- a/tests/caf/named_shape/A1 +++ /dev/null @@ -1,66 +0,0 @@ -#INTERFACE CAF -# NamedShape -# -# Testing attribute: TNaming_NamedShape -# -# Testing command: SetShape -# - -puts "caf002-A1" - -# Create a box -set aSetX1 10 -set aSetY1 20 -set aSetZ1 30 -set aSetDX1 100 -set aSetDY1 200 -set aSetDZ1 300 - -box aBox1 ${aSetX1} ${aSetY1} ${aSetZ1} ${aSetDX1} ${aSetDY1} ${aSetDZ1} - -bounding aBox1 -save X1_Box1 Y1_Box1 Z1_Box1 X2_Box1 Y2_Box1 Z2_Box1 - -# Create a label -set aLabel 0:2 -Label D ${aLabel} - -# Close/Open transaction -NewCommand D - -# Set a shape to the label -SetShape D ${aLabel} aBox1 - -# Close/Open transaction -NewCommand D - -# Undo -Undo D - -# Get a shape from the label -catch {GetShape D ${aLabel} aBox2} - -# Redo -Redo D - -# Get a shape from the label -GetShape D ${aLabel} aBox3 - -bounding aBox3 -save X1_Box3 Y1_Box3 Z1_Box3 X2_Box3 Y2_Box3 Z2_Box3 - -if { [dval X1_Box1] != [dval X1_Box3] || - [dval Y1_Box1] != [dval Y1_Box3] || - [dval Z1_Box1] != [dval Z1_Box3] || - [dval X2_Box1] != [dval X2_Box3] || - [dval Y2_Box1] != [dval Y2_Box3] || - [dval Z2_Box1] != [dval Z2_Box3] } { - puts "X1_Box1=[dval X1_Box1] X1_Box3=[dval X1_Box3]" - puts "Y1_Box1=[dval Y1_Box1] Y1_Box3=[dval Y1_Box3]" - puts "Z1_Box1=[dval Z1_Box1] Z1_Box3=[dval Z1_Box3]" - puts "X2_Box1=[dval X2_Box1] X2_Box3=[dval X2_Box3]" - puts "Y2_Box1=[dval Y2_Box1] Y2_Box3=[dval Y2_Box3]" - puts "Z2_Box1=[dval Z2_Box1] Z2_Box3=[dval Z2_Box3]" - puts "SetShape command: Error" - return -} - -puts "SetShape command: OK" diff --git a/tests/caf/named_shape/B1 b/tests/caf/named_shape/B1 deleted file mode 100755 index 825941e7ef..0000000000 --- a/tests/caf/named_shape/B1 +++ /dev/null @@ -1,66 +0,0 @@ -#INTERFACE CAF -# NamedShape -# -# Testing attribute: TNaming_NamedShape -# -# Testing command: NewShape -# - -puts "caf002-B1" - -# Create a box -set aSetX1 10 -set aSetY1 20 -set aSetZ1 30 -set aSetDX1 100 -set aSetDY1 200 -set aSetDZ1 300 - -box aBox1 ${aSetX1} ${aSetY1} ${aSetZ1} ${aSetDX1} ${aSetDY1} ${aSetDZ1} - -bounding aBox1 -save X1_Box1 Y1_Box1 Z1_Box1 X2_Box1 Y2_Box1 Z2_Box1 - -# Create a label -set aLabel 0:2 -Label D ${aLabel} - -# Close/Open transaction -NewCommand D - -# Set a shape to the label -NewShape D ${aLabel} aBox1 - -# Close/Open transaction -NewCommand D - -# Undo -Undo D - -# Get a shape from the label -catch {GetShape D ${aLabel} aBox2} - -# Redo -Redo D - -# Get a shape from the label -GetShape D ${aLabel} aBox3 - -bounding aBox3 -save X1_Box3 Y1_Box3 Z1_Box3 X2_Box3 Y2_Box3 Z2_Box3 - -if { [dval X1_Box1] != [dval X1_Box3] || - [dval Y1_Box1] != [dval Y1_Box3] || - [dval Z1_Box1] != [dval Z1_Box3] || - [dval X2_Box1] != [dval X2_Box3] || - [dval Y2_Box1] != [dval Y2_Box3] || - [dval Z2_Box1] != [dval Z2_Box3] } { - puts "X1_Box1=[dval X1_Box1] X1_Box3=[dval X1_Box3]" - puts "Y1_Box1=[dval Y1_Box1] Y1_Box3=[dval Y1_Box3]" - puts "Z1_Box1=[dval Z1_Box1] Z1_Box3=[dval Z1_Box3]" - puts "X2_Box1=[dval X2_Box1] X2_Box3=[dval X2_Box3]" - puts "Y2_Box1=[dval Y2_Box1] Y2_Box3=[dval Y2_Box3]" - puts "Z2_Box1=[dval Z2_Box1] Z2_Box3=[dval Z2_Box3]" - puts "NewShape command: Error" - return -} - -puts "NewShape command: OK" diff --git a/tests/caf/named_shape/C1 b/tests/caf/named_shape/C1 deleted file mode 100755 index 10082e143a..0000000000 --- a/tests/caf/named_shape/C1 +++ /dev/null @@ -1,76 +0,0 @@ -#INTERFACE CAF -# NamedShape -# -# Testing attribute: TNaming_NamedShape -# -# Testing command: GetShape -# - -puts "caf002-C1" - -# Create a box -set aSetX1 10 -set aSetY1 20 -set aSetZ1 30 -set aSetDX1 100 -set aSetDY1 200 -set aSetDZ1 300 - -box aBox1 ${aSetX1} ${aSetY1} ${aSetZ1} ${aSetDX1} ${aSetDY1} ${aSetDZ1} - -bounding aBox1 -save X1_Box1 Y1_Box1 Z1_Box1 X2_Box1 Y2_Box1 Z2_Box1 - -# Create a label -set aLabel 0:2 -Label D ${aLabel} - -# Close/Open transaction -NewCommand D - -# Set a shape to the label -SetShape D ${aLabel} aBox1 - -# Close/Open transaction -NewCommand D - -# Save the document -set aFile ${imagedir}/caf002-C1.cbf -file delete ${aFile} -SaveAs D ${aFile} -#catch {exec chmod 777 ${aFile}} -if { ![file exists ${aFile}] } { - puts "There is not ${aFile} file; SaveAs command: Error" - return -} - -# Restore the document -Close D -Open ${aFile} DD - -# Get a shape from the label -set IsDone [catch {GetShape DD ${aLabel} aBox3} aResult] -if { ${IsDone} != 0 } { - puts ${aResult} - puts "Get a value of TNaming_NamedShape attribute from restoring document: Error" - return -} - -bounding aBox3 -save X1_Box3 Y1_Box3 Z1_Box3 X2_Box3 Y2_Box3 Z2_Box3 - -if { [dval X1_Box1] != [dval X1_Box3] || - [dval Y1_Box1] != [dval Y1_Box3] || - [dval Z1_Box1] != [dval Z1_Box3] || - [dval X2_Box1] != [dval X2_Box3] || - [dval Y2_Box1] != [dval Y2_Box3] || - [dval Z2_Box1] != [dval Z2_Box3] } { - puts "X1_Box1=[dval X1_Box1] X1_Box3=[dval X1_Box3]" - puts "Y1_Box1=[dval Y1_Box1] Y1_Box3=[dval Y1_Box3]" - puts "Z1_Box1=[dval Z1_Box1] Z1_Box3=[dval Z1_Box3]" - puts "X2_Box1=[dval X2_Box1] X2_Box3=[dval X2_Box3]" - puts "Y2_Box1=[dval Y2_Box1] Y2_Box3=[dval Y2_Box3]" - puts "Z2_Box1=[dval Z2_Box1] Z2_Box3=[dval Z2_Box3]" - puts "Get a value of TNaming_NamedShape attribute from restoring document: Error" - return -} - -puts "Get a value of TNaming_NamedShape attribute from restoring document: OK" diff --git a/tests/caf/named_shape/D1 b/tests/caf/named_shape/D1 deleted file mode 100755 index 8fa211cb11..0000000000 --- a/tests/caf/named_shape/D1 +++ /dev/null @@ -1,70 +0,0 @@ -#INTERFACE CAF -# NamedShape -# -# Testing attribute: TNaming_NamedShape -# -# Testing command: SelectGeometry (EDGE) -# - -puts "caf002-D1" -set QA_DUP 0 - -set ter _* -foreach OS [directory [concat aBox1$ter]] { - unset $OS -} - -# Create a box -set aSetX1 10 -set aSetY1 20 -set aSetZ1 30 -set aSetDX1 100 -set aSetDY1 200 -set aSetDZ1 300 - -box aBox1 ${aSetX1} ${aSetY1} ${aSetZ1} ${aSetDX1} ${aSetDY1} ${aSetDZ1} - -# Create a label -set aLabel 0:2 -Label D ${aLabel} - -# Set a shape to the label -ImportShape D ${aLabel} aBox1 - -# Close/Open transaction -NewCommand D - -# Select all the sub-shapes of type -# aType = EDGE -set aType e -explode ${aBox1} ${aType} - -set i 0 -set iSubLabel 1000 -foreach S [directory [concat $aBox1$ter]] { - incr i - incr iSubLabel - puts "SubShape=$S" - - #Memorize a bounding box of the selected sub-shape - bounding ${S} -save X1_Box1 Y1_Box1 Z1_Box1 X2_Box1 Y2_Box1 Z2_Box1 - - # Select a sub-shape - set LABEL [Label D 0:$iSubLabel] - SelectGeometry D ${LABEL} ${S} ${aBox1} - - # Solve selected sub-shape - SolveSelection D ${LABEL} - - # Get selected (and solved) sub-shape - GetShape D ${LABEL} aSubShape - - # Get bounding box - bounding aSubShape -save X1_Box2 Y1_Box2 Z1_Box2 X2_Box2 Y2_Box2 Z2_Box2 - - if {[dval X1_Box1] != [dval X1_Box2] || [dval Y1_Box1] != [dval Y1_Box2] || [dval Z1_Box1] != [dval Z1_Box2] || [dval X2_Box1] != [dval X2_Box2] || [dval Y2_Box1] != [dval Y2_Box2] || [dval Z2_Box1] != [dval Z2_Box2]} { - puts "SelectGeometry command (${i}): Error" - } -} - -puts "SelectGeometry command: OK" diff --git a/tests/caf/named_shape/D2 b/tests/caf/named_shape/D2 deleted file mode 100755 index ff1799d46e..0000000000 --- a/tests/caf/named_shape/D2 +++ /dev/null @@ -1,70 +0,0 @@ -#INTERFACE CAF -# NamedShape -# -# Testing attribute: TNaming_NamedShape -# -# Testing command: SelectGeometry (FACE) -# - -puts "caf002-D2" -set QA_DUP 0 - -set ter _* -foreach OS [directory [concat aBox1$ter]] { - unset $OS -} - -# Create a box -set aSetX1 10 -set aSetY1 20 -set aSetZ1 30 -set aSetDX1 100 -set aSetDY1 200 -set aSetDZ1 300 - -box aBox1 ${aSetX1} ${aSetY1} ${aSetZ1} ${aSetDX1} ${aSetDY1} ${aSetDZ1} - -# Create a label -set aLabel 0:3 -Label D ${aLabel} - -# Set a shape to the label -ImportShape D ${aLabel} aBox1 - -# Close/Open transaction -NewCommand D - -# Select all the sub-shapes of type -# aType = FACE -set aType f -explode ${aBox1} ${aType} - -set i 0 -set iSubLabel 2000 -foreach S [directory [concat $aBox1$ter]] { - incr i - incr iSubLabel - puts "SubShape=$S" - - #Memorize a bounding box of the selected sub-shape - bounding ${S} -save X1_Box1 Y1_Box1 Z1_Box1 X2_Box1 Y2_Box1 Z2_Box1 - - # Select a sub-shape - set LABEL [Label D 0:$iSubLabel] - SelectGeometry D ${LABEL} ${S} ${aBox1} - - # Solve selected sub-shape - SolveSelection D ${LABEL} - - # Get selected (and solved) sub-shape - GetShape D ${LABEL} aSubShape - - # Get bounding box - bounding aSubShape -save X1_Box2 Y1_Box2 Z1_Box2 X2_Box2 Y2_Box2 Z2_Box2 - - if {[dval X1_Box1] != [dval X1_Box2] || [dval Y1_Box1] != [dval Y1_Box2] || [dval Z1_Box1] != [dval Z1_Box2] || [dval X2_Box1] != [dval X2_Box2] || [dval Y2_Box1] != [dval Y2_Box2] || [dval Z2_Box1] != [dval Z2_Box2]} { - puts "SelectGeometry command (${i}): Error" - } -} - -puts "SelectGeometry command: OK" diff --git a/tests/caf/named_shape/D3 b/tests/caf/named_shape/D3 deleted file mode 100755 index bf6d006d0d..0000000000 --- a/tests/caf/named_shape/D3 +++ /dev/null @@ -1,70 +0,0 @@ -#INTERFACE CAF -# NamedShape -# -# Testing attribute: TNaming_NamedShape -# -# Testing command: SelectGeometry (VERTEX) -# - -puts "caf002-D3" -set QA_DUP 0 - -set ter _* -foreach OS [directory [concat aBox1$ter]] { - unset $OS -} - -# Create a box -set aSetX1 10 -set aSetY1 20 -set aSetZ1 30 -set aSetDX1 100 -set aSetDY1 200 -set aSetDZ1 300 - -box aBox1 ${aSetX1} ${aSetY1} ${aSetZ1} ${aSetDX1} ${aSetDY1} ${aSetDZ1} - -# Create a label -set aLabel 0:4 -Label D ${aLabel} - -# Set a shape to the label -ImportShape D ${aLabel} aBox1 - -# Close/Open transaction -NewCommand D - -# Select all the sub-shapes of type -# aType = VERTEX -set aType v -explode ${aBox1} ${aType} - -set i 0 -set iSubLabel 3000 -foreach S [directory [concat $aBox1$ter]] { - incr i - incr iSubLabel - puts "SubShape=$S" - - #Memorize a bounding box of the selected sub-shape - bounding ${S} -save X1_Box1 Y1_Box1 Z1_Box1 X2_Box1 Y2_Box1 Z2_Box1 - - # Select a sub-shape - set LABEL [Label D 0:$iSubLabel] - SelectGeometry D ${LABEL} ${S} ${aBox1} - - # Solve selected sub-shape - SolveSelection D ${LABEL} - - # Get selected (and solved) sub-shape - GetShape D ${LABEL} aSubShape - - # Get bounding box - bounding aSubShape -save X1_Box2 Y1_Box2 Z1_Box2 X2_Box2 Y2_Box2 Z2_Box2 - - if {[dval X1_Box1] != [dval X1_Box2] || [dval Y1_Box1] != [dval Y1_Box2] || [dval Z1_Box1] != [dval Z1_Box2] || [dval X2_Box1] != [dval X2_Box2] || [dval Y2_Box1] != [dval Y2_Box2] || [dval Z2_Box1] != [dval Z2_Box2]} { - puts "SelectGeometry command (${i}): Error" - } -} - -puts "SelectGeometry command: OK" diff --git a/tests/caf/named_shape/D4 b/tests/caf/named_shape/D4 deleted file mode 100644 index 3dc93bb431..0000000000 --- a/tests/caf/named_shape/D4 +++ /dev/null @@ -1,130 +0,0 @@ -# ============= OCAF ============================ -# Naming -# -# Testing purpose: Shape evolution history -# -# Test case: D4 -# -# 1. Create Box B1 -# 2. Create Box B2 -# Translate B2 to -100 400 -130 -# 4. Cut (B1, B2) -# 5. Create Box B3 -# Translate B3 to -100 -20 -130 -# 5. Cut (B1, B3) -# 6. Check descendant of B1 -# 7. CurrentShape of 6 faces of B1 -# =============================================== - -pload ALL -NewDocument D BinOcaf - -AddDriver D Box PTxyz Cut Fuse Prism - -#1 Box1 creation -NewCommand D -set B1 [AddObject D]; ## add object -set F1 [AddFunction D $B1 Box]; ## add function -BoxDX D $B1 190 -BoxDY D $B1 890 -BoxDZ D $B1 290 -InitLogBook D; -ComputeFun D $F1; -## GetShape D $F1:2 Box2; -GetReference D $B1 - -#2 Box2 creation -NewCommand D -set B2 [AddBox D 390 190 490] -ComputeFun D $B2:1 -GetShape D $B2:1:2 Box; -NewCommand D -set FTr1 [PTranslateDXYZ D $B2 -100 400 -130] -ComputeFun D $FTr1 -## GetShape D $B2:2:2 Box - -#3 First cut -NewCommand D -set CS1 [AddCut D $B1 $B2] -ComputeFun D $CS1 -GetShape D $CS1:2 S1 -NewCommand D - -#4 Box3 creation -set B3 [AddBox D 390 490 490] -ComputeFun D $B3:1 -set FTr2 [PTranslateDXYZ D $B3 -100 -20 -130] -ComputeFun D $FTr2 - -#5 Second cut -NewCommand D -set CS2 [AddCut D $B1 $B3] -ComputeFun D $CS2 - -#6 CurrentShape of B1 -CurrentShape D $F1:2 B13 - -GetShape D $F1:2 BB -Descendants D BB -Descendants D BB_new_0 -set info0 [whatis BB_new_0_new_0] -## to be: BB_new_0_new_0 is a shape SOLID FORWARD Modified -if { [regexp "SOLID" $info0] != 1 } { - puts "Error: current descendant of BB is incorrect" -} else { - puts "OK: current descendant of BB is correct" -} - - -#7 CurrentShape of faces of B1 -CurrentShape D $F1:2:1 f1 -set info1 [whatis f1] -## to be: f1 is a shape FACE REVERSED Modified Orientable -if { [regexp "FACE REVERSED" $info1] != 1 } { - puts "Error: current shape of face1 of Box1 is incorrect" -} else { - puts "OK: current shape of face1 of Box1 is correct" -} - -CurrentShape D $F1:2:2 f2 -set info2 [whatis f2] -## to be: f2 is a shape FACE FORWARD Modified Orientable -if { [regexp "FACE FORWARD" $info2] != 1 } { - puts "Error: current shape of face2 of Box1 is incorrect" -} else { - puts "OK: current shape of face2 of Box1 is correct" -} - -CurrentShape D $F1:2:3 f3 -set info3 [whatis f3] -## to be: f3 is a shape FACE FORWARD Modified Orientable -if { [regexp "FACE FORWARD" $info3] != 1 } { - puts "Error: current shape of face3 of Box1 is incorrect" -} else { - puts "OK: current shape of face3 of Box1 is correct" -} -CurrentShape D $F1:2:4 f4 -set info4 [whatis f4] -## to be: f4 is a shape FACE FORWARD Modified Orientable -if { [regexp "FACE FORWARD" $info4] != 1 } { - puts "Error: current shape of face4 of Box1 is incorrect" -} else { - puts "OK: current shape of face4 of Box1 is correct" -} - -CurrentShape D $F1:2:5 f5 -set info5 [whatis f5] -## to be: f5 is a shape FACE REVERSED Modified Orientable -if { [regexp "FACE REVERSED" $info5] != 1 } { - puts "Error: current shape of face5 of Box1 is incorrect" -} else { - puts "OK: current shape of face5 of Box1 is correct" -} -CurrentShape D $F1:2:6 f6 -set info6 [whatis f6] -## to be: f6 is a -if { [regexp "f6 is a" $info6] != 1 } { - puts "Error: current shape of face6 of Box1 is incorrect" -} else { - puts "OK: current shape of face6 of Box1 is correct (deleted)" -} \ No newline at end of file diff --git a/tests/caf/named_shape/E2 b/tests/caf/named_shape/E2 deleted file mode 100755 index 91f1c428fc..0000000000 --- a/tests/caf/named_shape/E2 +++ /dev/null @@ -1,113 +0,0 @@ -# =================== OCAF ====================== -# Naming -# -# Testing purpose: Naming selection mechanism -# -# Test case: E2 (ShapeOrientation is used only for SingleSelection) -# 1. Create Box B2 -# 2. Translate B2 along XYZ -# 3. Translate B2 along Line (edge of B2) -# 4. Rotate B2 around Line (edge of translated B2) -# 5. Mirror B2 relative face of just rotated B2 -# 6. Make fillet on B2 -# 7. Make selection for all sub-shapes -# 8. Recompute modeling functions -# 9. Recompute selections -# =============================================== - -erase -Close D - -NewDocument D BinOcaf - -#Drivers' nick-names: -#Box|Sph|Cyl|Cut|Fuse|Prism|Revol|PTxyz|PTALine|PRLine|PMirr|Fillet|Attach|XAttach -# order of functions recomputation should be defined out of the tool (by end user) - -## Test of transformation functions -AddDriver D Box Attach PTxyz PTALine PRLine PMirr Sph - -#1 - create box using more flexible set of commands -NewCommand D -set B2 [AddObject D]; ## add object -set F2 [AddFunction D $B2 Box]; ## add function -BoxDX D $B2 190; ## set arguments of this function -BoxDY D $B2 290 -BoxDZ D $B2 390 -InitLogBook D; ## initialize (clean) internal maps of labels -ComputeFun D $F2; ## compute the function -GetShape D $F2:2 Box2; ## check result -whatis Box2 -GetReference D $B2; ## refers to result NS - - -#2 -NewCommand D -set FTr1 [PTranslateDXYZ D $B2 150 40 90] -ComputeFun D $FTr1; ## function recomputation -GetShape D $FTr1:2 Box2; ## get modified result - -#3 -NewCommand D -explode Box2 F -explode Box2_1 E -set Sel1 [AttachShape D Box2_1_1 ${B2} ${B2} 1]; ## set attachment -set FTr2 [PTranslateAlongLine D $B2 $Sel1 210] -ComputeFun D $FTr2 -GetShape D $FTr2:2 Box3 - -#4 -NewCommand D -explode Box3 F -explode Box3_1 E -set Sel4 [AttachShape D Box3_1_3 ${B2} ${B2} 1]; -set FR1 [PRotateRoundLine D $B2 $Sel4 120] -ComputeFun D $FR1 -GetShape D $FR1:2 Box4 - -#5 -NewCommand D -explode Box4 F -set Sel5 [AttachShape D Box4_3 ${B2} ${B2} 1]; -set FM [PMirror D $B2 $Sel5] -ComputeFun D $FM -GetShape D $FM:2 Box5 - -#6 -NewCommand D -explode Box5 F -explode Box5_1 E -set Sel6 [AttachShape D Box5_1_3 ${B2} ${B2} 1]; -AddDriver D Fillet -set Fill [AddFillet D $B2 25 $Sel6 0] -ComputeFun D $Fill -GetShape D $Fill:2 SF - -#7 -NewCommand D -set SL [TestSingleSelection D $B2 1] -set SL2 [TestMultipleSelection D $B2 0] - -#7 modification -NewCommand D -BoxDX D $B2 290 - -#8 order of recomputation -NewCommand D -InitLogBook D; ## to be initialized before any recomputation of impacted functions set (if attachments are presented) -ComputeFun D $F2; -ComputeFun D $FTr1; -ComputeFun D $Sel1:1 -ComputeFun D $FTr2 -ComputeFun D $Sel4:1 -ComputeFun D $FR1 -ComputeFun D $Sel5:1 -ComputeFun D $FM -ComputeFun D $Sel6:1 -ComputeFun D $Fill -GetShape D $Fill:2 SF-new - -#9 Recompute selections -SolveFlatFrom D $SL - -NewCommand D diff --git a/tests/caf/named_shape/E9 b/tests/caf/named_shape/E9 deleted file mode 100755 index dbb0eab54c..0000000000 --- a/tests/caf/named_shape/E9 +++ /dev/null @@ -1,143 +0,0 @@ -# ============= OCAF ============================ -# Naming -# -# Testing purpose: Naming selection mechanism -# -# Test case: E9 (ShapeOrientation is not used) -# -# 1. Create Box B1 -# 2. Create 4 spheres ($Sph1 - $Sph4) -# 3. Rotate all spheres around line -# 4. Fuse all spheres with box B1 -# 5. Make selection for all sub-shapes -# 6. Modify B1 -# 7. Recompute modeling functions -# 8. Recompute selections -# =============================================== - -erase -Close D - -NewDocument D BinOcaf -isos 12 - -#1 - create Box using short-cut -NewCommand D -AddDriver D Box; ## add box driver to driver table -set B1 [AddBox D 130 140 150]; ## add box -ComputeFun D $B1:1; ## compute box1 function -GetShape D $B1:1:2 Box1; ## check result -whatis Box1 -# refers to result NS -GetReference D $B1; ## check is reference set - - -#2 - create 4 spheres -AddDriver D Cyl Sph Attach XAttach PTxyz PTALine PRLine PMirr Cut Fuse Prism FulRevol SecRevol Fillet -NewCommand D -explode Box1 V -set SPnt1 [AttachShape D Box1_1 ${B1} ${B1} 0]; ## set attachment -set SPnt2 [AttachShape D Box1_2 ${B1} ${B1} 0]; ## set attachment -set SPnt3 [AttachShape D Box1_3 ${B1} ${B1} 0]; ## set attachment -set SPnt4 [AttachShape D Box1_4 ${B1} ${B1} 0]; ## set attachment - -set Sph1 [AddSphere D $SPnt1 25] -ComputeFun D $Sph1:1 -GetShape D $Sph1:1:2 Sp1 - -set Sph2 [AddSphere D $SPnt2 25] -ComputeFun D $Sph2:1 -GetShape D $Sph2:1:2 Sp2 - -set Sph3 [AddSphere D $SPnt3 25] -ComputeFun D $Sph3:1 -GetShape D $Sph3:1:2 Sp3 - -set Sph4 [AddSphere D $SPnt4 25] -ComputeFun D $Sph4:1 -GetShape D $Sph4:1:2 Sp4 -NewCommand D - -#3 Rotate spheres -explode Box1 E -set Sel1 [AttachShape D Box1_1 ${B1} ${B1} 0]; -set FR1 [PRotateRoundLine D $Sph1 $Sel1 120] -ComputeFun D $FR1 -GetShape D $FR1:2 Sp1 - -set Sel2 [AttachShape D Box1_1 ${B1} ${B1} 0]; -set FR2 [PRotateRoundLine D $Sph2 $Sel2 120] -ComputeFun D $FR2 -GetShape D $FR2:2 Sp2 - -set Sel3 [AttachShape D Box1_3 ${B1} ${B1} 0]; -set FR3 [PRotateRoundLine D $Sph3 $Sel3 120] -ComputeFun D $FR3 -GetShape D $FR3:2 Sp3 - -set Sel4 [AttachShape D Box1_3 ${B1} ${B1} 0]; -set FR4 [PRotateRoundLine D $Sph4 $Sel4 120] -ComputeFun D $FR4 -GetShape D $FR4:2 Sp4 -NewCommand D - -#4 Fuse spheres -set FS1 [AddFuse D $B1 $Sph1] -ComputeFun D $FS1 -GetShape D $FS1:2 Box1 - -set FS2 [AddFuse D $B1 $Sph2] -ComputeFun D $FS2 -GetShape D $FS2:2 Box1 - -set FS3 [AddFuse D $B1 $Sph3] -ComputeFun D $FS3 -GetShape D $FS3:2 Box1 - -set FS4 [AddFuse D $B1 $Sph4] -ComputeFun D $FS4 -GetShape D $FS4:2 Box1 - - -#5 test selection -NewCommand D -set SL [TestSingleSelection D $B1 0] -set SL2 [TestMultipleSelection D $B1 0] - -#6 modification -NewCommand D -BoxDX D $B1 210 -BoxDZ D $B1 270 - -#7 recomputation -NewCommand D -InitLogBook D; ## to be initialized before any recomputation of impacted functions set (if attachments are presented) -ComputeFun D $B1:1 -ComputeFun D $SPnt1:1 -ComputeFun D $SPnt2:1 -ComputeFun D $SPnt3:1 -ComputeFun D $SPnt4:1 -ComputeFun D $Sph1:1 -ComputeFun D $Sph2:1 -ComputeFun D $Sph3:1 -ComputeFun D $Sph4:1 -ComputeFun D $Sel1:1 -ComputeFun D $Sel2:1 -ComputeFun D $Sel3:1 -ComputeFun D $Sel4:1 -ComputeFun D $FR1 -ComputeFun D $FR2 -ComputeFun D $FR3 -ComputeFun D $FR4 -ComputeFun D $FS1 -ComputeFun D $FS2 -ComputeFun D $FS3 -ComputeFun D $FS4 -erase -GetShape D $FS4:2 Box1 - - -#8 recomputation of entities of the TestSelection commands -SolveFlatFrom D $SL -NewCommand D - diff --git a/tests/caf/named_shape/F2 b/tests/caf/named_shape/F2 deleted file mode 100755 index f7bec8fe56..0000000000 --- a/tests/caf/named_shape/F2 +++ /dev/null @@ -1,92 +0,0 @@ -# ============= OCAF ============================ -# Naming -# -# Testing purpose: Naming selection mechanism -# -# Test case: F2 (ShapeOrientation is not used) -# -# 1. Create Box $B1 (Box1) -# 2. Create sphere $Sph1 -# 3. Create sphere $Sph2 -# 4. Translate sphere $Sph2 along XYZ -# 5. Fuse spheres $FS1 = Fuse ($Sph1, $Sph2) -# 6. Make selection for all sub-shapes -# 7. Modify B1 -# 8. Recompute modeling functions -# 9. Recompute selections -# =============================================== - -erase -Close D - -NewDocument D BinOcaf -isos 12 -#1 - create Box using short-cut -NewCommand D -AddDriver D Box; ## add box driver to driver table -set B1 [AddBox D 130 140 150]; ## add box -ComputeFun D $B1:1; ## compute box1 function -GetShape D $B1:1:2 Box1; ## check result -whatis Box1 -# refers to result NS -GetReference D $B1; ## check is reference set - - -#2 - create sphere1 -AddDriver D Cyl Sph Attach XAttach PTxyz PTALine PRLine PMirr Cut Fuse Prism FulRevol SecRevol Fillet -NewCommand D -explode Box1 V -set SPnt1 [AttachShape D Box1_1 ${B1} ${B1} 0]; ## set attachment - -set Sph1 [AddSphere D $SPnt1 250] -ComputeFun D $Sph1:1 -GetShape D $Sph1:1:2 Sp1 - -#3 -NewCommand D -set Sph2 [AddSphere D $SPnt1 30] -ComputeFun D $Sph2:1 -GetShape D $Sph2:1:2 Sp2 -erase Box1 - -#4 -NewCommand D -set FTr2 [PTranslateDXYZ D $Sph2 0 -253 0] -ComputeFun D $FTr2 -GetShape D $Sph2:2:2 Sp2 - - -#5 Fuse spheres -NewCommand D -set FS1 [AddFuse D $Sph1 $Sph2] -ComputeFun D $FS1 -GetShape D $FS1:2 Sp1 - -#6 test selection -NewCommand D -set SL [TestSingleSelection D $Sph1 0] -## Wires defined as UNION (seam edge of each sphere) fail ==> linked with degenerated edges problem -set SL2 [TestMultipleSelection D $Sph1 0] - -#7 modification -NewCommand D -BoxDZ D $B1 270 - -#8 recomputation -NewCommand D -InitLogBook D; ## to be initialized before any recomputation of impacted functions set (if attachments are presented) -ComputeFun D $B1:1 -ComputeFun D $SPnt1:1 -ComputeFun D $Sph1:1 -ComputeFun D $Sph2:1 - -ComputeFun D $FTr2 -ComputeFun D $FS1 -erase -GetShape D $FS1:2 Sp1 - - -#9 recomputation of entities of the TestSelection commands -SolveFlatFrom D $SL -NewCommand D - diff --git a/tests/caf/named_shape/F3 b/tests/caf/named_shape/F3 deleted file mode 100755 index 4599c503b7..0000000000 --- a/tests/caf/named_shape/F3 +++ /dev/null @@ -1,152 +0,0 @@ -# ============= OCAF ============================ -# Naming -# -# Testing purpose: Naming selection mechanism -# -# Test case: F3 (ShapeOrientation is not used) -# -# 1. Create Box $B1 -# 2. Create sphere $Sph0 -# 3. Create sphere $Sph1 and move it along XYZ -# 4. Create sphere $Sph2 and move it along XYZ -# 5. Create sphere $Sph3 and rotate it around line and move after along XYZ -# 6. Create sphere $Sph4 and move it along XYZ -# 7. Cut spheres: $Cut1 = Cut($Sph0, $Sph1) -# $Cut2 = Cut($Sph0, $Sph2) -# $Cut3 = Cut($Sph0, $Sph3) -# $Cut4 = Cut($Sph0, $Sph4) -# 8. Make selection for all sub-shapes -# 9. Modify B2 -# 10. Recompute modeling functions -# 11. Recompute selections -# =============================================== - -erase -Close D - -NewDocument D BinOcaf -isos 12 -#1 - create Box using short-cut -NewCommand D -AddDriver D Box; ## add box driver to driver table -set B1 [AddBox D 130 140 150]; ## add box -ComputeFun D $B1:1; ## compute box1 function -GetShape D $B1:1:2 Box1; ## check result -whatis Box1 -# refers to result NS -GetReference D $B1; ## check is reference set - - -#2 - create main sphere Sp0 -AddDriver D Cyl Sph Attach XAttach PTxyz PTALine PRLine PMirr Cut Fuse Prism FulRevol SecRevol Fillet -NewCommand D -explode Box1 V -set SPnt1 [AttachShape D Box1_1 ${B1} ${B1} 0]; ## set attachment -erase Box1 - -set Sph0 [AddSphere D $SPnt1 250] -ComputeFun D $Sph0:1 -GetShape D $Sph0:1:2 Sp0 - -#3 create Sphere1 -NewCommand D -set Sph1 [AddSphere D $SPnt1 30] -ComputeFun D $Sph1:1 -GetShape D $Sph1:1:2 Sp1 - -NewCommand D -set FTr1 [PTranslateDXYZ D $Sph1 0 -251 0] -ComputeFun D $FTr1 -GetShape D $Sph1:2:2 Sp1 - -#4 create Sphere2 -NewCommand D -set Sph2 [AddSphere D $SPnt1 30] -ComputeFun D $Sph2:1 -GetShape D $Sph2:1:2 Sp2 - -set FTr2 [PTranslateDXYZ D $Sph2 0 251 0] -ComputeFun D $FTr2 -GetShape D $Sph2:2:2 Sp2 - -#5 create Sphere3 -NewCommand D -set Sph3 [AddSphere D $SPnt1 30] -ComputeFun D $Sph3:1 -GetShape D $Sph3:1:2 Sp3 - -explode Box1 E -set Sel3 [AttachShape D Box1_1 ${B1} ${B1} 0]; -set FR3 [PRotateRoundLine D $Sph3 $Sel3 120] -ComputeFun D $FR3 -GetShape D $FR3:2 Sp3 - -set FTr3 [PTranslateDXYZ D $Sph3 -251 0 0] -ComputeFun D $FTr3 -GetShape D $Sph3:3:2 Sp3 - -#6 create Sphere4 -NewCommand D -set Sph4 [AddSphere D $SPnt1 30] -ComputeFun D $Sph4:1 -GetShape D $Sph4:1:2 Sp4 - -set FTr4 [PTranslateDXYZ D $Sph4 251 -40 0] -ComputeFun D $FTr4 -GetShape D $Sph4:2:2 Sp4 - -#7 Cut spheres -set Cut1 [AddCut D $Sph0 $Sph1] -ComputeFun D $Cut1 -GetShape D $Cut1:2 Sp0 - -set Cut2 [AddCut D $Sph0 $Sph2] -ComputeFun D $Cut2 -GetShape D $Cut2:2 Sp0 - -set Cut3 [AddCut D $Sph0 $Sph3] -ComputeFun D $Cut3 -GetShape D $Cut3:2 Sp0 - -set Cut4 [AddCut D $Sph0 $Sph4] -ComputeFun D $Cut4 -GetShape D $Cut4:2 Sp0 - - -#8 test selection -NewCommand D -set SL [TestSingleSelection D $Sph0 0] -set SL2 [TestMultipleSelection D $Sph0 0] - -#9 modification -NewCommand D -BoxDZ D $B1 270 - -#10 recomputation -NewCommand D -InitLogBook D; ## to be initialized before any recomputation of impacted functions set (if attachments are presented) -ComputeFun D $B1:1 -ComputeFun D $SPnt1:1 -ComputeFun D $Sph0:1 -ComputeFun D $Sph1:1 -ComputeFun D $FTr1 -ComputeFun D $Sph2:1 -ComputeFun D $FTr2 -ComputeFun D $Sph3:1 -ComputeFun D $Sel3:1 -ComputeFun D $FR3 -ComputeFun D $FTr3 -ComputeFun D $Sph4:1 -ComputeFun D $FTr4 -ComputeFun D $Cut1 -ComputeFun D $Cut2 -ComputeFun D $Cut3 -ComputeFun D $Cut4 -erase -GetShape D $Cut4:2 Sp0 - - -#11 recomputation of entities of the TestSelection commands -SolveFlatFrom D $SL -NewCommand D - diff --git a/tests/caf/named_shape/F8 b/tests/caf/named_shape/F8 deleted file mode 100755 index 4147563580..0000000000 --- a/tests/caf/named_shape/F8 +++ /dev/null @@ -1,93 +0,0 @@ -# =================== OCAF ====================== -# Naming -# -# Testing purpose: Naming selection mechanism -# (name = FILTERBYNEIGHBOURGS) -# Check type migration -# =============================================== -# Test case: F8 (testing using SelectShape & SolveSelection) -# 1. Create 3 boxes $B1, $B2, $B3 -# 2. $FS1 = Fuse ($B1, $B2) -# 3. $FS2 = Fuse ($B1, $B3) -# 4. Make selections of the face 'fuse2_19' -# 5. Modify B2 -# 6. Recompute -# =============================================== - -set doc d16 -NewDocument $doc BinOcaf -AddDriver $doc Box Fuse Attach - -#1. create 3 boxes -set B1 [AddBox $doc 100 200 350] -set B2 [AddBox $doc 330 330 90] -set B3 [AddBox $doc 60 450 150] -ComputeFun $doc $B1:1 -ComputeFun $doc $B2:1 -ComputeFun $doc $B3:1 - -#2. B1 = fuse (B1, B2) -set FS1 [AddFuse $doc $B1 $B2] -ComputeFun $doc $FS1 - -#3. B1 = fuse (B1, B3) -set FS2 [AddFuse $doc $B1 $B3] -ComputeFun $doc $FS2 -GetShape $doc $FS2:2 fuse2 -explode fuse2 f - - -#4. select fuse2_19 (using SelectShape) -set Sel1 0:2:19 -SelectShape $doc $Sel1 fuse2_19 fuse2 -GetShape $doc $Sel1 f19before -#f19before is face -set info1 [whatis f19before] - - -#5. Modify -BoxDZ $doc $B2 120 - -#6. recompute -ComputeFun $doc $B2:1 -ComputeFun $doc $FS1 -ComputeFun $doc $FS2 -SolveSelection $doc $Sel1 -GetShape $doc $Sel1 f19after -#f19after is face -set info2 [whatis f19after] - -if { [regexp "shape" $info1] != 1 } { - puts "Error : There is not word shape in f19after" -} -if { [regexp "FACE" $info1] != 1 } { - puts "Error : There is not word FACE in f19after" -} -if { [regexp "REVERSED" $info1] != 1 } { - puts "Error : There is not word REVERSED in f19after" -} -if { [regexp "Modified" $info1] != 1 } { - puts "Error : There is not word Modified in f19after" -} -if { [regexp "Orientable" $info1] != 1 } { - puts "Error : There is not word Orientable in f19after" -} - -if { [regexp "shape" $info2] != 1 } { - puts "Error : There is not word shape in f19before" -} -if { [regexp "FACE" $info2] != 1 } { - puts "Error : There is not word FACE in f19before" -} -if { [regexp "REVERSED" $info2] != 1 } { - puts "Error : There is not word REVERSED in f19before" -} -if { [regexp "Modified" $info2] != 1 } { - puts "Error : There is not word Modified in f19before" -} -if { [regexp "Orientable" $info2] != 1 } { - puts "Error : There is not word Orientable in f19before" -} - - - diff --git a/tests/caf/named_shape/F9 b/tests/caf/named_shape/F9 deleted file mode 100755 index 4489ec0916..0000000000 --- a/tests/caf/named_shape/F9 +++ /dev/null @@ -1,93 +0,0 @@ -# =================== OCAF ====================== -# Naming -# -# Testing purpose: Naming selection mechanism -# (name = FILTERBYNEIGHBOURGS) -# Check type migration -# =============================================== -# Test case: F9 (testing using AttachShape & ComputeFun) -# 1. Create 3 boxes $B1, $B2, $B3 -# 2. $FS1 = Fuse ($B1, $B2) -# 3. $FS2 = Fuse ($B1, $B3) -# 4. Make selections of the face 'fuse2_19' -# 5. Modify B2 -# 6. Recompute -# =============================================== - -set doc d16 -NewDocument $doc BinOcaf -AddDriver $doc Box Fuse Attach - -#1.create 3 boxes -set B1 [AddBox $doc 100 200 350] -set B2 [AddBox $doc 330 330 90] -set B3 [AddBox $doc 60 450 150] -ComputeFun $doc $B1:1 -ComputeFun $doc $B2:1 -ComputeFun $doc $B3:1 - -#2. B1 = fuse (B1 B2) -set FS1 [AddFuse $doc $B1 $B2] -ComputeFun $doc $FS1 - -#3. B1 = fuse (B1 B3) -set FS2 [AddFuse $doc $B1 $B3] -ComputeFun $doc $FS2 -GetShape $doc $FS2:2 fuse2 -explode fuse2 f - - - -#4. Select fuse2_19 using Attach -set Sel2 [AttachShape $doc fuse2_19 $B1] -GetShape $doc $Sel2:1:2 nf19before -#nf19before is face -set info1 [whatis nf19before] - - -#5. Modify -BoxDZ $doc $B2 125 - -#6. Recompute - Alternative way of solving -InitLogBook $doc -ComputeFun $doc $B1:1 -ComputeFun $doc $B2:1 -ComputeFun $doc $B3:1 -ComputeFun $doc $FS1 -ComputeFun $doc $FS2 -ComputeFun $doc $Sel2:1 -GetShape $doc $Sel2:1:2 nf19after -#nf19after is face -set info2 [whatis nf19after] - -if { [regexp "shape" $info1] != 1 } { - puts "Error : There is not word shape in nf19after" -} -if { [regexp "FACE" $info1] != 1 } { - puts "Error : There is not word FACE in nf19after" -} -if { [regexp "REVERSED" $info1] != 1 } { - puts "Error : There is not word REVERSED in nf19after" -} -if { [regexp "Modified" $info1] != 1 } { - puts "Error : There is not word Modified in nf19after" -} -if { [regexp "Orientable" $info1] != 1 } { - puts "Error : There is not word Orientable in nf19after" -} - -if { [regexp "shape" $info2] != 1 } { - puts "Error : There is not word shape in nf19before" -} -if { [regexp "FACE" $info2] != 1 } { - puts "Error : There is not word FACE in nf19before" -} -if { [regexp "REVERSED" $info2] != 1 } { - puts "Error : There is not word REVERSED in nf19before" -} -if { [regexp "Modified" $info2] != 1 } { - puts "Error : There is not word Modified in nf19before" -} -if { [regexp "Orientable" $info2] != 1 } { - puts "Error : There is not word Orientable in nf19before" -} \ No newline at end of file diff --git a/tests/caf/progress/A1 b/tests/caf/progress/A1 deleted file mode 100644 index b7e4dd260d..0000000000 --- a/tests/caf/progress/A1 +++ /dev/null @@ -1,35 +0,0 @@ -#INTERFACE CAF -# Message_ProgressIndicator -# -# Testing attribute: TDocStd_Application -# -# Testing command: SaveAs -# - -puts "caf009-A1" - -# Configure XProgress -XProgress +t - -# Create binary document -NewDocument Doc BinOcaf - -# Fill the document by box -box b 1 1 1 -SetShape Doc 0:1 b - -# SaveAs -set output [SaveAs Doc ${imagedir}/${casename}_tmp.cbf] - -# Close the document -Close Doc - -# Test data -set ctr { "0%" "Writing document" "Writing sub tree" "100%" } - -foreach data ${ctr} { - if ![regexp $data $output] { - puts "Error: SaveAs command for binary files: Mismatch data on '$data'" - break; - } -} \ No newline at end of file diff --git a/tests/caf/progress/A2 b/tests/caf/progress/A2 deleted file mode 100644 index 19cbe5ffcc..0000000000 --- a/tests/caf/progress/A2 +++ /dev/null @@ -1,39 +0,0 @@ -#INTERFACE CAF -# Message_ProgressIndicator -# -# Testing attribute: TDocStd_Application -# -# Testing command: SaveAs -# - -puts "caf009-A2" - -# Configure XProgress -XProgress +t - -# Create binary document -NewDocument Doc XmlOcaf - -# Fill the document by box -box b 1 1 1 - -SetShape Doc 0:1 b - -# SaveAs -set output [SaveAs Doc ${imagedir}/${casename}_tmp.xml] - -# Close the document -Close Doc - -# Test data -set ctr { "0%" "Writing sub-tree" "Writing shape section" - "Writing" "Geometry" "2D Curves" "3D Curves" - "Polygons On Triangulation" "Surfaces" - "3D Polygons" "Triangulations" "100%" "Shapes" } - -foreach data ${ctr} { - if ![regexp $data $output] { - puts "Error: SaveAs command for xml files: Mismatch data on '$data'" - break - } -} \ No newline at end of file diff --git a/tests/caf/progress/B1 b/tests/caf/progress/B1 deleted file mode 100644 index d4db14a1e8..0000000000 --- a/tests/caf/progress/B1 +++ /dev/null @@ -1,35 +0,0 @@ -#INTERFACE CAF -# Message_ProgressIndicator -# -# Testing attribute: TDocStd_Application -# -# Testing command: Open -# - -puts "caf009-B1" - -set bDoc [CreateBinDoc] - -# Configure XProgress -XProgress +t - -# Open binary document -if {${bDoc} == "" } { - puts "Error: Open command for binary files: Error, wrong path" - return -} - -set output [Open ${bDoc} Doc] - -# Close the document -Close Doc - -# Test data -set ctr {"0%" "Reading data" "Reading sub tree" "100%" } - -foreach data ${ctr} { - if ![regexp $data $output] { - puts "Error: Open command for binary files: Mismatch data on '$data'" - break - } -} \ No newline at end of file diff --git a/tests/caf/progress/B2 b/tests/caf/progress/B2 deleted file mode 100644 index 5751aa9ec1..0000000000 --- a/tests/caf/progress/B2 +++ /dev/null @@ -1,37 +0,0 @@ -#INTERFACE CAF -# Message_ProgressIndicator -# -# Testing attribute: TDocStd_Application -# -# Testing command: Open -# - -puts "caf009-B2" - -set xDoc [CreateXmlDoc] - -# Configure XProgress -XProgress +t - -# Open xml document -if {${xDoc} == "" } { - puts "Error: Open command for xml files: wrong path" - return -} - -set output [Open ${xDoc} Doc] - -# Close the document -Close Doc - -# Test data -set ctr { "0%" "Reading document" "Reading" "3D Curves" "2D Curves" - "3D Polygons" "Polygons On Triangulation" "Shapes" - "Triangulations" "Surfaces" "Reading sub-tree" "100%" } - -foreach data ${ctr} { - if ![regexp $data $output] { - puts "Error: Open command for xml files: Mismatch data on '$data'" - break - } -} \ No newline at end of file diff --git a/tests/caf/progress/C1 b/tests/caf/progress/C1 deleted file mode 100644 index eca4ea59db..0000000000 --- a/tests/caf/progress/C1 +++ /dev/null @@ -1,41 +0,0 @@ -#INTERFACE CAF -# Message_ProgressIndicator -# -# Testing attribute: TDocStd_Application -# -# Testing command: Save -# - -puts "caf009-C1" - -set bDoc [CreateBinDoc] - -# Open document -if {${bDoc} == "" } { - puts "Save command for binary files: Error, cannot open file" - return -} -Open ${bDoc} Doc - -# Fill the document by another box -box b 1 1 1 -SetShape Doc 0:2 b - -# Configure XProgress -XProgress +t - -# Save -set output [Save Doc] - -# Close the document -Close Doc - -# Test data -set ctr { "0%" "Writing document" "Writing sub tree" "100%" } - -foreach data ${ctr} { - if ![regexp $data $output] { - puts "Error: Save command for binary files: Mismatch data on '$data'" - break - } -} \ No newline at end of file diff --git a/tests/caf/progress/C2 b/tests/caf/progress/C2 deleted file mode 100644 index 32c79b555a..0000000000 --- a/tests/caf/progress/C2 +++ /dev/null @@ -1,43 +0,0 @@ -#INTERFACE CAF -# Message_ProgressIndicator -# -# Testing attribute: TDocStd_Application -# -# Testing command: Save -# - -puts "caf009-C2" - -set xDoc [CreateXmlDoc] - -# Open document -if {${xDoc} == "" } { - puts "Save command for binary files: Error, cannot open file" - return -} -Open ${xDoc} Doc - -# Fill the document by another box -box b 1 1 1 -SetShape Doc 0:2 b - -# Configure XProgress -XProgress +t - -# Save -set output [Save Doc] - -# Close the document -Close Doc - -# Test data -set ctr { "0%" "Writing sub-tree" "Writing shape section" "Polygons On Triangulation" - "3D Polygons" "Locations" "Writing" "Geometry" "2D Curves" - "Triangulations" "3D Curves" "Surfaces" "Shapes" "100%" } - -foreach data ${ctr} { - if ![regexp $data $output] { - puts "Error: Save command for xml files: Mismatch data on '$data'" - break - } -} diff --git a/tests/caf/tree/A1 b/tests/caf/tree/A1 deleted file mode 100755 index fd90ee6884..0000000000 --- a/tests/caf/tree/A1 +++ /dev/null @@ -1,43 +0,0 @@ -#INTERFACE CAF -# Tree construction attributes -# -# Testing attribute: TDF_TagSource -# -# Testing command: NewChild -# - -puts "caf005-A1" - -# Add an attribute to a data framework -set aLabel1 0:2 -set aName1 Label1 -Label D ${aLabel1} -SetName D ${aLabel1} ${aName1} - -set aName11 Label11 -set aChild1 [NewChild D ${aLabel1}] -SetName D ${aChild1} ${aName11} - -# Close/Open the transaction -NewCommand D - -# Forget the attribute -ForgetAll D ${aLabel1} - -# Close/Open the transaction -NewCommand D - -# Undo-Redo-Undo -Undo D -Redo D -Undo D - -# Get a value of the attribute -set aGetName1 [GetName D ${aChild1}] - -if { ${aName11}!=${aGetName1} } { - puts "aName11=${aName11} aGetName1=${aGetName1}" - puts "Add TDF_TagSource attribute: Error" - return -} -puts "Add TDF_TagSource attribute: OK" diff --git a/tests/caf/tree/A2 b/tests/caf/tree/A2 deleted file mode 100755 index 4d0d7e8951..0000000000 --- a/tests/caf/tree/A2 +++ /dev/null @@ -1,41 +0,0 @@ -#INTERFACE CAF -# Tree construction attributes -# -# Testing attribute: TDF_TagSource -# -# Testing command: NewChild -# Testing command: NewTag -# - -puts "caf005-A2" - -set aTokList {:} - -# Add an attribute to a data framework -set aLabel1 0:2 -set aName1 Label1 -SetTagger D ${aLabel1} -SetName D ${aLabel1} ${aName1} - -set aLabel2 0:3 -set aName2 Label2 -SetTagger D ${aLabel2} -SetName D ${aLabel2} ${aName2} - -set aChild1 [NewChild D ${aLabel1}] - -set aTagNumber 4 -for {set i 1} {${i}<${aTagNumber}} {incr i} { - NewTag D ${aLabel2} -} -set aChild2 [NewChild D ${aLabel2}] - -# Get a value of the attribute -set aTag1 [lindex [split ${aChild1} ${aTokList}] 2] -set aTag2 [lindex [split ${aChild2} ${aTokList}] 2] -if { ${aTag1}!=1 || ${aTag2}!=${aTagNumber}} { - puts "aTag1=${aTag1} aTag2=${aTag2} aTagNumber=${aTagNumber}" - puts "Set TDF_TagSource attribute: Error" - return -} -puts "Set TDF_TagSource attribute: OK" diff --git a/tests/caf/tree/A3 b/tests/caf/tree/A3 deleted file mode 100755 index 709e7d8d24..0000000000 --- a/tests/caf/tree/A3 +++ /dev/null @@ -1,50 +0,0 @@ -#INTERFACE CAF -# Tree construction attributes -# -# Testing attribute: TDF_TagSource -# -# Testing command: NewChild -# - -puts "caf005-A3" - -# Add an attribute to a data framework -set aLabel1 0:2 -set aName1 Label1 -Label D ${aLabel1} -SetName D ${aLabel1} ${aName1} - -set aName11 Label11 -set aChild1 [NewChild D ${aLabel1}] -### -set aChild1 0:2:1 -### -SetName D ${aChild1} ${aName11} - -# Close/Open the transaction -NewCommand D - -# Save the document -set aFile ${imagedir}/caf005-A3.cbf -file delete ${aFile} -SaveAs D ${aFile} -if { ![file exists ${aFile}] } { - puts "There is not ${aFile} file; SaveAs command: Error" - return -} -#catch {exec chmod 777 ${aFile}} - -# Restore the document -Close D -Open ${aFile} DD - -# Get a value of the attribute -set IsDone [catch {set aGetName1 [GetName DD ${aChild1}]} aResult] -if { ${IsDone} != 0 || - ${aName11}!=${aGetName1} } { - puts "aName11=${aName11} aGetName1=${aGetName1}" - puts ${aResult} - puts "Get a value of TDF_TagSource attribute from restoring document: Error" - return -} -puts "Get a value of TDF_TagSource attribute from restoring document: OK" diff --git a/tests/caf/tree/B1 b/tests/caf/tree/B1 deleted file mode 100755 index 06ba8c3fad..0000000000 --- a/tests/caf/tree/B1 +++ /dev/null @@ -1,38 +0,0 @@ -#INTERFACE CAF -# Tree construction attributes -# -# Testing attribute: TDataStd_Directory -# -# Testing command: NewDirectory -# - -puts "caf005-B1" - -# Add an attribute to a data framework -set aLabel1 0:2 -NewDirectory D ${aLabel1} -set aName1 Label1 -SetName D ${aLabel1} ${aName1} - -# Close/Open the transaction -NewCommand D - -# Forget the attribute -ForgetAll D ${aLabel1} - -# Close/Open the transaction -NewCommand D - -# Undo-Redo-Undo -Undo D -Redo D -Undo D - -# Get a value of the attribute -set aGetName1 [GetName D ${aLabel1}] -if { ${aName1}!=${aGetName1} } { - puts "aName1=${aName1} aGetName1=${aGetName1}" - puts "New TDataStd_Directory attribute: Error" - return -} -puts "New TDataStd_Directory attribute: OK" diff --git a/tests/caf/tree/B2 b/tests/caf/tree/B2 deleted file mode 100755 index 80d68f132b..0000000000 --- a/tests/caf/tree/B2 +++ /dev/null @@ -1,42 +0,0 @@ -#INTERFACE CAF -# Tree construction attributes -# -# Testing attribute: TDataStd_Directory -# -# Testing command: AddDirectory -# - -puts "caf005-B2" - -# Add an attribute to a data framework -set aLabel1 0:2 -NewDirectory D ${aLabel1} -set aName1 Label1 -SetName D ${aLabel1} ${aName1} -set aSubDirectory [AddDirectory D ${aLabel1}] -set aName2 SubDirectory1 -set aLabel2 [lindex ${aSubDirectory} 0] -SetName D ${aLabel2} ${aName2} - -# Close/Open the transaction -NewCommand D - -# Forget the attribute -ForgetAll D ${aLabel1} - -# Close/Open the transaction -NewCommand D - -# Undo-Redo-Undo -Undo D -Redo D -Undo D - -# Get a value of the attribute -set aGetName2 [GetName D ${aLabel2}] -if { ${aName2}!=${aGetName2} } { - puts "aName2=${aName2} aGetName2=${aGetName2}" - puts "Add TDataStd_Directory attribute: Error" - return -} -puts "Add TDataStd_Directory attribute: OK" diff --git a/tests/caf/tree/B3 b/tests/caf/tree/B3 deleted file mode 100755 index 84bab9be62..0000000000 --- a/tests/caf/tree/B3 +++ /dev/null @@ -1,43 +0,0 @@ -#INTERFACE CAF -# Tree construction attributes -# -# Testing attribute: TDataStd_Directory -# -# Testing command: NewDirectory -# - -puts "caf005-B3" - -# Add an attribute to a data framework -set aLabel1 0:2 -NewDirectory D ${aLabel1} -set aName1 Label1 -SetName D ${aLabel1} ${aName1} - -# Close/Open the transaction -NewCommand D - -# Save the document -set aFile ${imagedir}/caf001-B3.cbf -file delete ${aFile} -SaveAs D ${aFile} -if { ![file exists ${aFile}] } { - puts "There is not ${aFile} file; SaveAs command: Error" - return -} -#catch {exec chmod 777 ${aFile}} - -# Restore the document -Close D -Open ${aFile} DD - -# Get a value of the attribute -set IsDone [catch {set aGetName1 [GetName DD ${aLabel1}]} aResult] -if { ${IsDone} != 0 || - ${aName1}!=${aGetName1} } { - puts "aName1=${aName1} aGetName1=${aGetName1}" - puts ${aResult} - puts "Get a value of TDataStd_Directory attribute from restoring document: Error" - return -} -puts "Get a value of TDataStd_Directory attribute from restoring document: OK" diff --git a/tests/caf/tree/C1 b/tests/caf/tree/C1 deleted file mode 100755 index ec9e8d78a7..0000000000 --- a/tests/caf/tree/C1 +++ /dev/null @@ -1,41 +0,0 @@ -#INTERFACE CAF -# Tree construction attributes -# -# Testing attribute: TDataStd_TreeNode -# -# Testing command: SetNode -# -# Testing command: RootNode -# - -puts "caf005-C1" - -# Add an attribute to a data framework -set aLabel_Root 0:2 -set aName_Root Label_1 -Label D ${aLabel_Root} -SetName D ${aLabel_Root} ${aName_Root} -SetNode D ${aLabel_Root} - -# Close/Open the transaction -NewCommand D - -# Forget the attribute -ForgetAll D ${aLabel_Root} - -# Close/Open the transaction -NewCommand D - -# Undo-Redo-Undo -Undo D -Redo D -Undo D - -# Get a value of the attribute -set aGetLabel_Root [RootNode D ${aLabel_Root}] -if { ${aLabel_Root}!=${aGetLabel_Root} } { - puts "aLabel_Root=${aLabel_Root} aGetLabel_Root=${aGetLabel_Root}" - puts "Set TDataStd_TreeNode attribute: Error" - return -} -puts "Set TDataStd_TreeNode attribute: OK" diff --git a/tests/caf/tree/C2 b/tests/caf/tree/C2 deleted file mode 100755 index 8452f7ac39..0000000000 --- a/tests/caf/tree/C2 +++ /dev/null @@ -1,47 +0,0 @@ -#INTERFACE CAF -# Tree construction attributes -# -# Testing attribute: TDataStd_TreeNode -# -# Testing command: SetNode -# -# Testing command: RootNode -# - -puts "caf005-C2" - -# Add an attribute to a data framework -set aLabel_Root 0:2 -set aName_Root Label_1 -Label D ${aLabel_Root} -SetName D ${aLabel_Root} ${aName_Root} -SetNode D ${aLabel_Root} - -# Close/Open the transaction -NewCommand D - -# Save the document -set aFile ${imagedir}/caf005-C2.cbf -file delete ${aFile} -SaveAs D ${aFile} -if { ![file exists ${aFile}] } { - puts "There is not ${aFile} file; SaveAs command: Error" - return -} -#catch {exec chmod 777 ${aFile}} - -# Restore the document -Close D -Open ${aFile} DD - -# Get a value of the attribute -set aGetLabel_Root "" -set IsDone [catch {set aGetLabel_Root [RootNode DD ${aLabel_Root}]} aResult] -if { ${IsDone} != 0 || - ${aLabel_Root}!=${aGetLabel_Root} } { - puts "aLabel_Root=${aLabel_Root} aGetLabel_Root=${aGetLabel_Root}" - puts ${aResult} - puts "Get a value of TDataStd_TreeNode attribute from restoring document: Error" - return -} -puts "Get a value of TDataStd_TreeNode attribute from restoring document: OK" diff --git a/tests/caf/tree/D1 b/tests/caf/tree/D1 deleted file mode 100755 index 857975d491..0000000000 --- a/tests/caf/tree/D1 +++ /dev/null @@ -1,72 +0,0 @@ -#INTERFACE CAF -# Tree construction attributes -# -# Testing attribute: TDataStd_TreeNode -# -# Testing command: AppendNode -# -# Testing command: SetNode -# Testing command: ChildNodeIterate -# - -puts "caf005-D1" -set QA_DUP 0 - -# Add an attribute to a data framework -set aLabel_Root 0:2 -set aName_Root Label_1 -Label D ${aLabel_Root} -SetName D ${aLabel_Root} ${aName_Root} - -set aName1 Label_1_1 -###set aChild1 [NewChild D ${aLabel_Root}] -set aChild1 0:2:1 -Label D ${aChild1} -SetName D ${aChild1} ${aName1} - -set aName2 Label_1_2 -###set aChild2 [NewChild D ${aLabel_Root}] -set aChild2 0:2:2 -Label D ${aChild2} -SetName D ${aChild2} ${aName2} - -set aName3 Label_1_1_1 -###set aChild3 [NewChild D ${aLabel_Root}] -set aChild3 0:2:3 -Label D ${aChild3} -SetName D ${aChild3} ${aName3} - -SetNode D ${aLabel_Root} -AppendNode D ${aLabel_Root} ${aChild1} -AppendNode D ${aLabel_Root} ${aChild2} -AppendNode D ${aLabel_Root} ${aChild3} - -# Close/Open the transaction -NewCommand D - -# Forget the attribute -ForgetAll D ${aLabel_Root} - -# Close/Open the transaction -NewCommand D - -# Undo-Redo-Undo -Undo D -Redo D -Undo D - -# Get a value of the attribute -set IsDone [catch {set aListChildNodes [ChildNodeIterate D ${aLabel_Root} 1]} aResult] -if { ${IsDone} != 0 } { - puts ${aResult} - puts "Append TDataStd_TreeNode attribute: Error" - return -} -set aListChildNodesLength [llength ${aListChildNodes}] -if { ${aListChildNodesLength}!=[expr 3 + 0]} { - puts "aListChildNodes=${aListChildNodes}" - puts "aListChildNodesLength=${aListChildNodesLength}" - puts "Append TDataStd_TreeNode attribute: Error" - return -} -puts "Append TDataStd_TreeNode attribute: OK" diff --git a/tests/caf/tree/D2 b/tests/caf/tree/D2 deleted file mode 100755 index 54b6e42461..0000000000 --- a/tests/caf/tree/D2 +++ /dev/null @@ -1,85 +0,0 @@ -#INTERFACE CAF -# Tree construction attributes -# -# Testing attribute: TDataStd_TreeNode -# -# Testing command: AppendNode -# -# Testing command: SetNode -# Testing command: ChildNodeIterate -# - -puts "caf005-D2" -set QA_DUP 0 - -# Add an attribute to a data framework -set aLabel_Root 0:2 -set aName_Root Label_1 -Label D ${aLabel_Root} -SetName D ${aLabel_Root} ${aName_Root} - -set aName1 Label_1_1 -###set aChild1 [NewChild D ${aLabel_Root}] -set aChild1 0:2:1 -Label D ${aChild1} -SetName D ${aChild1} ${aName1} - -set aName2 Label_1_2 -###set aChild2 [NewChild D ${aLabel_Root}] -set aChild2 0:2:2 -Label D ${aChild2} -SetName D ${aChild2} ${aName2} - -set aName3 Label_1_1_1 -###set aChild3 [NewChild D ${aLabel_Root}] -set aChild3 0:2:3 -Label D ${aChild3} -SetName D ${aChild3} ${aName3} - -SetNode D ${aLabel_Root} -AppendNode D ${aLabel_Root} ${aChild1} -AppendNode D ${aLabel_Root} ${aChild2} -AppendNode D ${aLabel_Root} ${aChild3} - -# Close/Open the transaction -NewCommand D - -# Forget the attribute -ForgetAll D ${aLabel_Root} - -# Close/Open the transaction -NewCommand D - -# Undo-Redo-Undo -Undo D -Redo D -Undo D - -# Get a value of the attribute -set IsDone [catch {set aListChildNodes [ChildNodeIterate D ${aLabel_Root} 1]} aResult] -if { ${IsDone} != 0 } { - puts ${aResult} - puts "Append TDataStd_TreeNode attribute: Error" - return -} -set aListChildNodesLength [llength ${aListChildNodes}] -if { ${aListChildNodesLength}!=[expr 3 + 0]} { - puts "aListChildNodes=${aListChildNodes}" - puts "aListChildNodesLength=${aListChildNodesLength}" - puts "Append TDataStd_TreeNode attribute: Error" - return -} -set aFirstChildNode [lindex ${aListChildNodes} 0] -set aSecondChildNode [lindex ${aListChildNodes} 1] -set aThirdChildNode [lindex ${aListChildNodes} 2] -if { ${aFirstChildNode}!=${aChild1} || - ${aSecondChildNode}!=${aChild2} || - ${aThirdChildNode}!=${aChild3}} { - puts "aFirstChildNode=${aFirstChildNode} aChild1=${aChild1}" - puts "aSecondChildNode=${aSecondChildNode} aChild2=${aChild2}" - puts "aThirdChildNode=${aThirdChildNode} aChild3=${aChild3}" - puts "Append TDataStd_TreeNode attribute: Error" - return -} - -puts "Append TDataStd_TreeNode attribute: OK" diff --git a/tests/caf/tree/E1 b/tests/caf/tree/E1 deleted file mode 100755 index 18db50dde7..0000000000 --- a/tests/caf/tree/E1 +++ /dev/null @@ -1,74 +0,0 @@ -#INTERFACE CAF -# Tree construction attributes -# -# Testing attribute: TDataStd_TreeNode -# -# Testing command: PrependNode -# -# Testing command: SetNode -# Testing command: AppendNode -# Testing command: ChildNodeIterate -# - -puts "caf005-E1" -set QA_DUP 0 - -# Add an attribute to a data framework -set aLabel_Root 0:2 -set aName_Root Label_1 -Label D ${aLabel_Root} -SetName D ${aLabel_Root} ${aName_Root} - -set aName1 Label_1_1 -###set aChild1 [NewChild D ${aLabel_Root}] -set aChild1 0:2:1 -Label D ${aChild1} -SetName D ${aChild1} ${aName1} - -set aName2 Label_1_2 -###set aChild2 [NewChild D ${aLabel_Root}] -set aChild2 0:2:2 -Label D ${aChild2} -SetName D ${aChild2} ${aName2} - -set aName3 Label_1_1_1 -###set aChild3 [NewChild D ${aLabel_Root}] -set aChild3 0:2:3 -Label D ${aChild3} -SetName D ${aChild3} ${aName3} - -SetNode D ${aLabel_Root} -AppendNode D ${aLabel_Root} ${aChild1} -PrependNode D ${aLabel_Root} ${aChild2} -PrependNode D ${aLabel_Root} ${aChild3} - -# Close/Open the transaction -NewCommand D - -# Forget the attribute -ForgetAll D ${aLabel_Root} - -# Close/Open the transaction -NewCommand D - -# Undo-Redo-Undo -Undo D -Redo D -Undo D - -# Get a value of the attribute -set IsDone [catch {set aListChildNodes [ChildNodeIterate D ${aLabel_Root} 1]} aResult] -if { ${IsDone} != 0 } { - puts ${aResult} - puts "Prepend TDataStd_TreeNode attribute: Error" - return -} -set aListChildNodesLength [llength ${aListChildNodes}] -if { ${aListChildNodesLength}!=[expr 3 + 0]} { - puts "aListChildNodes=${aListChildNodes}" - puts "aListChildNodesLength=${aListChildNodesLength}" - puts "Prepend TDataStd_TreeNode attribute: Error" - return -} - -puts "Prepend TDataStd_TreeNode attribute: OK" diff --git a/tests/caf/tree/E2 b/tests/caf/tree/E2 deleted file mode 100755 index 0fb5773f86..0000000000 --- a/tests/caf/tree/E2 +++ /dev/null @@ -1,86 +0,0 @@ -#INTERFACE CAF -# Tree construction attributes -# -# Testing attribute: TDataStd_TreeNode -# -# Testing command: PrependNode -# -# Testing command: SetNode -# Testing command: AppendNode -# Testing command: ChildNodeIterate -# - -puts "caf005-E2" -set QA_DUP 0 - -# Add an attribute to a data framework -set aLabel_Root 0:2 -set aName_Root Label_1 -Label D ${aLabel_Root} -SetName D ${aLabel_Root} ${aName_Root} - -set aName1 Label_1_1 -###set aChild1 [NewChild D ${aLabel_Root}] -set aChild1 0:2:1 -Label D ${aChild1} -SetName D ${aChild1} ${aName1} - -set aName2 Label_1_2 -###set aChild2 [NewChild D ${aLabel_Root}] -set aChild2 0:2:2 -Label D ${aChild2} -SetName D ${aChild2} ${aName2} - -set aName3 Label_1_1_1 -###set aChild3 [NewChild D ${aLabel_Root}] -set aChild3 0:2:3 -Label D ${aChild3} -SetName D ${aChild3} ${aName3} - -SetNode D ${aLabel_Root} -AppendNode D ${aLabel_Root} ${aChild1} -PrependNode D ${aLabel_Root} ${aChild2} -PrependNode D ${aLabel_Root} ${aChild3} - -# Close/Open the transaction -NewCommand D - -# Forget the attribute -ForgetAll D ${aLabel_Root} - -# Close/Open the transaction -NewCommand D - -# Undo-Redo-Undo -Undo D -Redo D -Undo D - -# Get a value of the attribute -set IsDone [catch {set aListChildNodes [ChildNodeIterate D ${aLabel_Root} 1]} aResult] -if { ${IsDone} != 0 } { - puts ${aResult} - puts "Prepend TDataStd_TreeNode attribute: Error" - return -} -set aListChildNodesLength [llength ${aListChildNodes}] -if { ${aListChildNodesLength}!=[expr 3 + 0]} { - puts "aListChildNodes=${aListChildNodes}" - puts "aListChildNodesLength=${aListChildNodesLength}" - puts "Prepend TDataStd_TreeNode attribute: Error" - return -} -set aFirstChildNode [lindex ${aListChildNodes} 0] -set aSecondChildNode [lindex ${aListChildNodes} 1] -set aThirdChildNode [lindex ${aListChildNodes} 2] -if { ${aFirstChildNode}!=${aChild3} || - ${aSecondChildNode}!=${aChild2} || - ${aThirdChildNode}!=${aChild1}} { - puts "aFirstChildNode=${aFirstChildNode} aChild1=${aChild1}" - puts "aSecondChildNode=${aSecondChildNode} aChild2=${aChild2}" - puts "aThirdChildNode=${aThirdChildNode} aChild3=${aChild3}" - puts "Prepend TDataStd_TreeNode attribute: Error" - return -} - -puts "Prepend TDataStd_TreeNode attribute: OK" diff --git a/tests/caf/tree/F1 b/tests/caf/tree/F1 deleted file mode 100755 index fd7d08b08c..0000000000 --- a/tests/caf/tree/F1 +++ /dev/null @@ -1,75 +0,0 @@ -#INTERFACE CAF -# Tree construction attributes -# -# Testing attribute: TDataStd_TreeNode -# -# Testing command: InsertNodeBefore -# -# Testing command: SetNode -# Testing command: AppendNode -# Testing command: ChildNodeIterate -# - -puts "caf005-F1" -set QA_DUP 0 - -# Add an attribute to a data framework -set aLabel_Root 0:2 -set aName_Root Label_1 -Label D ${aLabel_Root} -SetName D ${aLabel_Root} ${aName_Root} - -set aName1 Label_1_1 -###set aChild1 [NewChild D ${aLabel_Root}] -set aChild1 0:2:1 -Label D ${aChild1} -SetName D ${aChild1} ${aName1} - -set aName2 Label_1_2 -###set aChild2 [NewChild D ${aLabel_Root}] -set aChild2 0:2:2 -Label D ${aChild2} -SetName D ${aChild2} ${aName2} - -set aName3 Label_1_1_1 -###set aChild3 [NewChild D ${aLabel_Root}] -set aChild3 0:2:3 -Label D ${aChild3} -SetName D ${aChild3} ${aName3} - -SetNode D ${aLabel_Root} - -AppendNode D ${aLabel_Root} ${aChild1} -AppendNode D ${aLabel_Root} ${aChild2} -InsertNodeBefore D ${aChild2} ${aChild3} - -# Close/Open the transaction -NewCommand D - -# Forget the attribute -ForgetAll D ${aLabel_Root} - -# Close/Open the transaction -NewCommand D - -# Undo-Redo-Undo -Undo D -Redo D -Undo D - -# Get a value of the attribute -set IsDone [catch {set aListChildNodes [ChildNodeIterate D ${aLabel_Root} 1]} aResult] -if { ${IsDone} != 0 } { - puts ${aResult} - puts "InsertBefore TDataStd_TreeNode attribute: Error" - return -} -set aListChildNodesLength [llength ${aListChildNodes}] -if { ${aListChildNodesLength}!=[expr 3 + 0]} { - puts "aListChildNodes=${aListChildNodes}" - puts "aListChildNodesLength=${aListChildNodesLength}" - puts "InsertBefore TDataStd_TreeNode attribute: Error" - return -} - -puts "InsertBefore TDataStd_TreeNode attribute: OK" diff --git a/tests/caf/tree/F2 b/tests/caf/tree/F2 deleted file mode 100755 index d903fff54d..0000000000 --- a/tests/caf/tree/F2 +++ /dev/null @@ -1,87 +0,0 @@ -#INTERFACE CAF -# Tree construction attributes -# -# Testing attribute: TDataStd_TreeNode -# -# Testing command: InsertNodeBefore -# -# Testing command: SetNode -# Testing command: AppendNode -# Testing command: ChildNodeIterate -# - -puts "caf005-F2" -set QA_DUP 0 - -# Add an attribute to a data framework -set aLabel_Root 0:2 -set aName_Root Label_1 -Label D ${aLabel_Root} -SetName D ${aLabel_Root} ${aName_Root} - -set aName1 Label_1_1 -###set aChild1 [NewChild D ${aLabel_Root}] -set aChild1 0:2:1 -Label D ${aChild1} -SetName D ${aChild1} ${aName1} - -set aName2 Label_1_2 -###set aChild2 [NewChild D ${aLabel_Root}] -set aChild2 0:2:2 -Label D ${aChild2} -SetName D ${aChild2} ${aName2} - -set aName3 Label_1_1_1 -###set aChild3 [NewChild D ${aLabel_Root}] -set aChild3 0:2:3 -Label D ${aChild3} -SetName D ${aChild3} ${aName3} - -SetNode D ${aLabel_Root} - -AppendNode D ${aLabel_Root} ${aChild1} -AppendNode D ${aLabel_Root} ${aChild2} -InsertNodeBefore D ${aChild2} ${aChild3} - -# Close/Open the transaction -NewCommand D - -# Forget the attribute -ForgetAll D ${aLabel_Root} - -# Close/Open the transaction -NewCommand D - -# Undo-Redo-Undo -Undo D -Redo D -Undo D - -# Get a value of the attribute -set IsDone [catch {set aListChildNodes [ChildNodeIterate D ${aLabel_Root} 1]} aResult] -if { ${IsDone} != 0 } { - puts ${aResult} - puts "InsertBefore TDataStd_TreeNode attribute: Error" - return -} -set aListChildNodesLength [llength ${aListChildNodes}] -if { ${aListChildNodesLength}!=[expr 3 + 0]} { - puts "aListChildNodes=${aListChildNodes}" - puts "aListChildNodesLength=${aListChildNodesLength}" - puts "InsertBefore TDataStd_TreeNode attribute: Error" - return -} -set aFirstChildNode [lindex ${aListChildNodes} 0] -set aSecondChildNode [lindex ${aListChildNodes} 1] -set aThirdChildNode [lindex ${aListChildNodes} 2] -if { ${aFirstChildNode}!=${aChild1} || - ${aSecondChildNode}!=${aChild3} || - ${aThirdChildNode}!=${aChild2}} { - puts "aFirstChildNode=${aFirstChildNode} aChild1=${aChild1}" - puts "aSecondChildNode=${aSecondChildNode} aChild3=${aChild3}" - puts "aThirdChildNode=${aThirdChildNode} aChild2=${aChild2}" - puts "InsertBefore TDataStd_TreeNode attribute: Error" - return -} - -puts "InsertBefore TDataStd_TreeNode attribute: OK" diff --git a/tests/caf/tree/G1 b/tests/caf/tree/G1 deleted file mode 100755 index 7a1aa6df0d..0000000000 --- a/tests/caf/tree/G1 +++ /dev/null @@ -1,75 +0,0 @@ -#INTERFACE CAF -# Tree construction attributes -# -# Testing attribute: TDataStd_TreeNode -# -# Testing command: InsertNodeAfter -# -# Testing command: SetNode -# Testing command: AppendNode -# Testing command: ChildNodeIterate -# - -puts "caf005-G1" -set QA_DUP 0 - -# Add an attribute to a data framework -set aLabel_Root 0:2 -set aName_Root Label_1 -Label D ${aLabel_Root} -SetName D ${aLabel_Root} ${aName_Root} - -set aName1 Label_1_1 -###set aChild1 [NewChild D ${aLabel_Root}] -set aChild1 0:2:1 -Label D ${aChild1} -SetName D ${aChild1} ${aName1} - -set aName2 Label_1_2 -###set aChild2 [NewChild D ${aLabel_Root}] -set aChild2 0:2:2 -Label D ${aChild2} -SetName D ${aChild2} ${aName2} - -set aName3 Label_1_1_1 -###set aChild3 [NewChild D ${aLabel_Root}] -set aChild3 0:2:3 -Label D ${aChild3} -SetName D ${aChild3} ${aName3} - -SetNode D ${aLabel_Root} - -AppendNode D ${aLabel_Root} ${aChild1} -AppendNode D ${aLabel_Root} ${aChild2} -InsertNodeAfter D ${aChild1} ${aChild3} - -# Close/Open the transaction -NewCommand D - -# Forget the attribute -ForgetAll D ${aLabel_Root} - -# Close/Open the transaction -NewCommand D - -# Undo-Redo-Undo -Undo D -Redo D -Undo D - -# Get a value of the attribute -set IsDone [catch {set aListChildNodes [ChildNodeIterate D ${aLabel_Root} 1]} aResult] -if { ${IsDone} != 0 } { - puts ${aResult} - puts "InsertAfter TDataStd_TreeNode attribute: Error" - return -} -set aListChildNodesLength [llength ${aListChildNodes}] -if { ${aListChildNodesLength}!=[expr 3 + 0]} { - puts "aListChildNodes=${aListChildNodes}" - puts "aListChildNodesLength=${aListChildNodesLength}" - puts "InsertAfter TDataStd_TreeNode attribute: Error" - return -} - -puts "InsertAfter TDataStd_TreeNode attribute: OK" diff --git a/tests/caf/tree/G2 b/tests/caf/tree/G2 deleted file mode 100755 index 808d8f3e23..0000000000 --- a/tests/caf/tree/G2 +++ /dev/null @@ -1,87 +0,0 @@ -#INTERFACE CAF -# Tree construction attributes -# -# Testing attribute: TDataStd_TreeNode -# -# Testing command: InsertNodeAfter -# -# Testing command: SetNode -# Testing command: AppendNode -# Testing command: ChildNodeIterate -# - -puts "caf005-G2" -set QA_DUP 0 - -# Add an attribute to a data framework -set aLabel_Root 0:2 -set aName_Root Label_1 -Label D ${aLabel_Root} -SetName D ${aLabel_Root} ${aName_Root} - -set aName1 Label_1_1 -###set aChild1 [NewChild D ${aLabel_Root}] -set aChild1 0:2:1 -Label D ${aChild1} -SetName D ${aChild1} ${aName1} - -set aName2 Label_1_2 -###set aChild2 [NewChild D ${aLabel_Root}] -set aChild2 0:2:2 -Label D ${aChild2} -SetName D ${aChild2} ${aName2} - -set aName3 Label_1_1_1 -###set aChild3 [NewChild D ${aLabel_Root}] -set aChild3 0:2:3 -Label D ${aChild3} -SetName D ${aChild3} ${aName3} - -SetNode D ${aLabel_Root} - -AppendNode D ${aLabel_Root} ${aChild1} -AppendNode D ${aLabel_Root} ${aChild2} -InsertNodeAfter D ${aChild1} ${aChild3} - -# Close/Open the transaction -NewCommand D - -# Forget the attribute -ForgetAll D ${aLabel_Root} - -# Close/Open the transaction -NewCommand D - -# Undo-Redo-Undo -Undo D -Redo D -Undo D - -# Get a value of the attribute -set IsDone [catch {set aListChildNodes [ChildNodeIterate D ${aLabel_Root} 1]} aResult] -if { ${IsDone} != 0 } { - puts ${aResult} - puts "InsertAfter TDataStd_TreeNode attribute: Error" - return -} -set aListChildNodesLength [llength ${aListChildNodes}] -if { ${aListChildNodesLength}!=[expr 3 + 0]} { - puts "aListChildNodes=${aListChildNodes}" - puts "aListChildNodesLength=${aListChildNodesLength}" - puts "InsertAfter TDataStd_TreeNode attribute: Error" - return -} -set aFirstChildNode [lindex ${aListChildNodes} 0] -set aSecondChildNode [lindex ${aListChildNodes} 1] -set aThirdChildNode [lindex ${aListChildNodes} 2] -if { ${aFirstChildNode}!=${aChild1} || - ${aSecondChildNode}!=${aChild3} || - ${aThirdChildNode}!=${aChild2}} { - puts "aFirstChildNode=${aFirstChildNode} aChild1=${aChild1}" - puts "aSecondChildNode=${aSecondChildNode} aChild2=${aChild2}" - puts "aThirdChildNode=${aThirdChildNode} aChild3=${aChild3}" - puts "InsertAfter TDataStd_TreeNode attribute: Error" - return -} - -puts "InsertAfter TDataStd_TreeNode attribute: OK" diff --git a/tests/caf/tree/H1 b/tests/caf/tree/H1 deleted file mode 100755 index 7880a19fab..0000000000 --- a/tests/caf/tree/H1 +++ /dev/null @@ -1,76 +0,0 @@ -#INTERFACE CAF -# Tree construction attributes -# -# Testing attribute: TDataStd_TreeNode -# -# Testing command: DetachNode -# -# Testing command: SetNode -# Testing command: AppendNode -# Testing command: ChildNodeIterate -# - -puts "caf005-H1" -set QA_DUP 0 - -# Add an attribute to a data framework -set aLabel_Root 0:2 -set aName_Root Label_1 -Label D ${aLabel_Root} -SetName D ${aLabel_Root} ${aName_Root} - -set aName1 Label_1_1 -###set aChild1 [NewChild D ${aLabel_Root}] -set aChild1 0:2:1 -Label D ${aChild1} -SetName D ${aChild1} ${aName1} - -set aName2 Label_1_2 -###set aChild2 [NewChild D ${aLabel_Root}] -set aChild2 0:2:2 -Label D ${aChild2} -SetName D ${aChild2} ${aName2} - -set aName3 Label_1_1_1 -###set aChild3 [NewChild D ${aLabel_Root}] -set aChild3 0:2:3 -Label D ${aChild3} -SetName D ${aChild3} ${aName3} - -SetNode D ${aLabel_Root} - -AppendNode D ${aLabel_Root} ${aChild1} -AppendNode D ${aLabel_Root} ${aChild2} -AppendNode D ${aLabel_Root} ${aChild3} -DetachNode D ${aChild2} - -# Close/Open the transaction -NewCommand D - -# Forget the attribute -ForgetAll D ${aLabel_Root} - -# Close/Open the transaction -NewCommand D - -# Undo-Redo-Undo -Undo D -Redo D -Undo D - -# Get a value of the attribute -set IsDone [catch {set aListChildNodes [ChildNodeIterate D ${aLabel_Root} 1]} aResult] -if { ${IsDone} != 0 } { - puts ${aResult} - puts "Detach TDataStd_TreeNode attribute: Error" - return -} -set aListChildNodesLength [llength ${aListChildNodes}] -if { ${aListChildNodesLength}!=[expr 2 + 0]} { - puts "aListChildNodes=${aListChildNodes}" - puts "aListChildNodesLength=${aListChildNodesLength}" - puts "Detach TDataStd_TreeNode attribute: Error" - return -} - -puts "Detach TDataStd_TreeNode attribute: OK" diff --git a/tests/caf/tree/H2 b/tests/caf/tree/H2 deleted file mode 100755 index ac371e93d9..0000000000 --- a/tests/caf/tree/H2 +++ /dev/null @@ -1,85 +0,0 @@ -#INTERFACE CAF -# Tree construction attributes -# -# Testing attribute: TDataStd_TreeNode -# -# Testing command: DetachNode -# -# Testing command: SetNode -# Testing command: AppendNode -# Testing command: ChildNodeIterate -# - -puts "caf005-H2" -set QA_DUP 0 - -# Add an attribute to a data framework -set aLabel_Root 0:2 -set aName_Root Label_1 -Label D ${aLabel_Root} -SetName D ${aLabel_Root} ${aName_Root} - -set aName1 Label_1_1 -###set aChild1 [NewChild D ${aLabel_Root}] -set aChild1 0:2:1 -Label D ${aChild1} -SetName D ${aChild1} ${aName1} - -set aName2 Label_1_2 -###set aChild2 [NewChild D ${aLabel_Root}] -set aChild2 0:2:2 -Label D ${aChild2} -SetName D ${aChild2} ${aName2} - -set aName3 Label_1_1_1 -###set aChild3 [NewChild D ${aLabel_Root}] -set aChild3 0:2:3 -Label D ${aChild3} -SetName D ${aChild3} ${aName3} - -SetNode D ${aLabel_Root} - -AppendNode D ${aLabel_Root} ${aChild1} -AppendNode D ${aLabel_Root} ${aChild2} -AppendNode D ${aLabel_Root} ${aChild3} -DetachNode D ${aChild2} - -# Close/Open the transaction -NewCommand D - -# Forget the attribute -ForgetAll D ${aLabel_Root} - -# Close/Open the transaction -NewCommand D - -# Undo-Redo-Undo -Undo D -Redo D -Undo D - -# Get a value of the attribute -set IsDone [catch {set aListChildNodes [ChildNodeIterate D ${aLabel_Root} 1]} aResult] -if { ${IsDone} != 0 } { - puts ${aResult} - puts "Detach TDataStd_TreeNode attribute: Error" - return -} -set aListChildNodesLength [llength ${aListChildNodes}] -if { ${aListChildNodesLength}!=[expr 2 + 0]} { - puts "aListChildNodes=${aListChildNodes}" - puts "aListChildNodesLength=${aListChildNodesLength}" - puts "Detach TDataStd_TreeNode attribute: Error" - return -} -set aFirstChildNode [lindex ${aListChildNodes} 0] -set aSecondChildNode [lindex ${aListChildNodes} 1] -if { ${aFirstChildNode}!=${aChild1} || - ${aSecondChildNode}!=${aChild3}} { - puts "aFirstChildNode=${aFirstChildNode} aChild1=${aChild1}" - puts "aSecondChildNode=${aSecondChildNode} aChild3=${aChild3}" - puts "Detach TDataStd_TreeNode attribute: Error" - return -} - -puts "Detach TDataStd_TreeNode attribute: OK" diff --git a/tests/caf/tree/I1 b/tests/caf/tree/I1 deleted file mode 100755 index f3c237e323..0000000000 --- a/tests/caf/tree/I1 +++ /dev/null @@ -1,101 +0,0 @@ -#INTERFACE CAF -# Tree construction attributes -# -# Testing attribute: TDataStd_TreeNode -# -# Testing command: ChildNodeIterate -# -# Testing command: NewChild -# Testing command: AppendNode -# - -puts "caf005-I1" -set QA_DUP 0 - -# Add an attribute to a data framework -set aLabel_Root 0:2 -set aName_Root Label_1 -Label D ${aLabel_Root} -SetName D ${aLabel_Root} ${aName_Root} - -set aName1 Label_1_1 -###set aChild1 [NewChild D ${aLabel_Root}] -set aChild1 0:2:1 -Label D ${aChild1} -SetName D ${aChild1} ${aName1} - -set aName2 Label_1_2 -###set aChild2 [NewChild D ${aLabel_Root}] -set aChild2 0:2:2 -Label D ${aChild2} -SetName D ${aChild2} ${aName2} - -set aName3 Label_1_1_1 -###set aChild3 [NewChild D ${aLabel_Root}] -set aChild3 0:2:3 -Label D ${aChild3} -SetName D ${aChild3} ${aName3} - -set aName4 Label_1_1_2 -###set aChild4 [NewChild D ${aLabel_Root}] -set aChild4 0:2:4 -Label D ${aChild4} -SetName D ${aChild4} ${aName4} - -set aName5 Label_1_1_3 -###set aChild5 [NewChild D ${aLabel_Root}] -set aChild5 0:2:5 -Label D ${aChild5} -SetName D ${aChild5} ${aName5} - -set aName6 Label_1_2_1 -###set aChild6 [NewChild D ${aLabel_Root}] -set aChild6 0:2:6 -Label D ${aChild6} -SetName D ${aChild6} ${aName6} - -set aName7 Label_1_2_2 -###set aChild7 [NewChild D ${aLabel_Root}] -set aChild7 0:2:7 -Label D ${aChild7} -SetName D ${aChild7} ${aName7} - -SetNode D ${aLabel_Root} -AppendNode D ${aLabel_Root} ${aChild1} -AppendNode D ${aLabel_Root} ${aChild2} -AppendNode D ${aChild1} ${aChild3} -AppendNode D ${aChild1} ${aChild4} -AppendNode D ${aChild1} ${aChild5} -AppendNode D ${aChild2} ${aChild6} -AppendNode D ${aChild2} ${aChild7} - -# Close/Open the transaction -NewCommand D - -# Forget the attribute -ForgetAll D ${aLabel_Root} - -# Close/Open the transaction -NewCommand D - -# Undo-Redo-Undo -Undo D -Redo D -Undo D - -# Get a value of the attribute -set IsDone [catch {set aListChildNodes [ChildNodeIterate D ${aLabel_Root} 0]} aResult] -if { ${IsDone} != 0 } { - puts ${aResult} - puts "ChildNodeIterate Doc TreeNode AllLevels=0 : Error" - return -} -set aListChildNodesLength [llength ${aListChildNodes}] -if { ${aListChildNodesLength}!=[expr 2 + 0]} { - puts "aListChildNodes=${aListChildNodes}" - puts "aListChildNodesLength=${aListChildNodesLength}" - puts "ChildNodeIterate Doc TreeNode AllLevels=0 : Error" - return -} - -puts "ChildNodeIterate Doc TreeNode AllLevels=0 : OK" diff --git a/tests/caf/tree/I2 b/tests/caf/tree/I2 deleted file mode 100755 index c7294b127b..0000000000 --- a/tests/caf/tree/I2 +++ /dev/null @@ -1,110 +0,0 @@ -#INTERFACE CAF -# Tree construction attributes -# -# Testing attribute: TDataStd_TreeNode -# -# Testing command: ChildNodeIterate -# -# Testing command: NewChild -# Testing command: AppendNode -# - -puts "caf005-I2" -set QA_DUP 0 - -# Add an attribute to a data framework -set aLabel_Root 0:2 -set aName_Root Label_1 -Label D ${aLabel_Root} -SetName D ${aLabel_Root} ${aName_Root} - -set aName1 Label_1_1 -###set aChild1 [NewChild D ${aLabel_Root}] -set aChild1 0:2:1 -Label D ${aChild1} -SetName D ${aChild1} ${aName1} - -set aName2 Label_1_2 -###set aChild2 [NewChild D ${aLabel_Root}] -set aChild2 0:2:2 -Label D ${aChild2} -SetName D ${aChild2} ${aName2} - -set aName3 Label_1_1_1 -###set aChild3 [NewChild D ${aLabel_Root}] -set aChild3 0:2:3 -Label D ${aChild3} -SetName D ${aChild3} ${aName3} - -set aName4 Label_1_1_2 -###set aChild4 [NewChild D ${aLabel_Root}] -set aChild4 0:2:4 -Label D ${aChild4} -SetName D ${aChild4} ${aName4} - -set aName5 Label_1_1_3 -###set aChild5 [NewChild D ${aLabel_Root}] -set aChild5 0:2:5 -Label D ${aChild5} -SetName D ${aChild5} ${aName5} - -set aName6 Label_1_2_1 -###set aChild6 [NewChild D ${aLabel_Root}] -set aChild6 0:2:6 -Label D ${aChild6} -SetName D ${aChild6} ${aName6} - -set aName7 Label_1_2_2 -###set aChild7 [NewChild D ${aLabel_Root}] -set aChild7 0:2:7 -Label D ${aChild7} -SetName D ${aChild7} ${aName7} - -SetNode D ${aLabel_Root} -AppendNode D ${aLabel_Root} ${aChild1} -AppendNode D ${aLabel_Root} ${aChild2} -AppendNode D ${aChild1} ${aChild3} -AppendNode D ${aChild1} ${aChild4} -AppendNode D ${aChild1} ${aChild5} -AppendNode D ${aChild2} ${aChild6} -AppendNode D ${aChild2} ${aChild7} - -# Close/Open the transaction -NewCommand D - -# Forget the attribute -ForgetAll D ${aLabel_Root} - -# Close/Open the transaction -NewCommand D - -# Undo-Redo-Undo -Undo D -Redo D -Undo D - -# Get a value of the attribute -set IsDone [catch {set aListChildNodes [ChildNodeIterate D ${aLabel_Root} 0]} aResult] -if { ${IsDone} != 0 } { - puts ${aResult} - puts "ChildNodeIterate Doc TreeNode AllLevels=0 : Error" - return -} -set aListChildNodesLength [llength ${aListChildNodes}] -if { ${aListChildNodesLength}!=[expr 2 + 0]} { - puts "aListChildNodes=${aListChildNodes}" - puts "aListChildNodesLength=${aListChildNodesLength}" - puts "ChildNodeIterate Doc TreeNode AllLevels=0 : Error" - return -} -set aFirstChildNode [lindex ${aListChildNodes} 0] -set aSecondChildNode [lindex ${aListChildNodes} 1] -if { ${aFirstChildNode}!=${aChild1} || - ${aSecondChildNode}!=${aChild2}} { - puts "aFirstChildNode=${aFirstChildNode} aChild1=${aChild1}" - puts "aSecondChildNode=${aSecondChildNode} aChild2=${aChild2}" - puts "ChildNodeIterate Doc TreeNode AllLevels=0 : Error" - return -} - -puts "ChildNodeIterate Doc TreeNode AllLevels=0 : OK" diff --git a/tests/caf/tree/I3 b/tests/caf/tree/I3 deleted file mode 100755 index 333b007da6..0000000000 --- a/tests/caf/tree/I3 +++ /dev/null @@ -1,101 +0,0 @@ -#INTERFACE CAF -# Tree construction attributes -# -# Testing attribute: TDataStd_TreeNode -# -# Testing command: ChildNodeIterate -# -# Testing command: NewChild -# Testing command: AppendNode -# - -puts "caf005-I3" -set QA_DUP 0 - -# Add an attribute to a data framework -set aLabel_Root 0:2 -set aName_Root Label_1 -Label D ${aLabel_Root} -SetName D ${aLabel_Root} ${aName_Root} - -set aName1 Label_1_1 -###set aChild1 [NewChild D ${aLabel_Root}] -set aChild1 0:2:1 -Label D ${aChild1} -SetName D ${aChild1} ${aName1} - -set aName2 Label_1_2 -###set aChild2 [NewChild D ${aLabel_Root}] -set aChild2 0:2:2 -Label D ${aChild2} -SetName D ${aChild2} ${aName2} - -set aName3 Label_1_1_1 -###set aChild3 [NewChild D ${aLabel_Root}] -set aChild3 0:2:3 -Label D ${aChild3} -SetName D ${aChild3} ${aName3} - -set aName4 Label_1_1_2 -###set aChild4 [NewChild D ${aLabel_Root}] -set aChild4 0:2:4 -Label D ${aChild4} -SetName D ${aChild4} ${aName4} - -set aName5 Label_1_1_3 -###set aChild5 [NewChild D ${aLabel_Root}] -set aChild5 0:2:5 -Label D ${aChild5} -SetName D ${aChild5} ${aName5} - -set aName6 Label_1_2_1 -###set aChild6 [NewChild D ${aLabel_Root}] -set aChild6 0:2:6 -Label D ${aChild6} -SetName D ${aChild6} ${aName6} - -set aName7 Label_1_2_2 -###set aChild7 [NewChild D ${aLabel_Root}] -set aChild7 0:2:7 -Label D ${aChild7} -SetName D ${aChild7} ${aName7} - -SetNode D ${aLabel_Root} -AppendNode D ${aLabel_Root} ${aChild1} -AppendNode D ${aLabel_Root} ${aChild2} -AppendNode D ${aChild1} ${aChild3} -AppendNode D ${aChild1} ${aChild4} -AppendNode D ${aChild1} ${aChild5} -AppendNode D ${aChild2} ${aChild6} -AppendNode D ${aChild2} ${aChild7} - -# Close/Open the transaction -NewCommand D - -# Forget the attribute -ForgetAll D ${aLabel_Root} - -# Close/Open the transaction -NewCommand D - -# Undo-Redo-Undo -Undo D -Redo D -Undo D - -# Get a value of the attribute -set IsDone [catch {set aListChildNodes [ChildNodeIterate D ${aLabel_Root} 1]} aResult] -if { ${IsDone} != 0 } { - puts ${aResult} - puts "ChildNodeIterate Doc TreeNode AllLevels=1 : Error" - return -} -set aListChildNodesLength [llength ${aListChildNodes}] -if { ${aListChildNodesLength}!=[expr 7 + 0]} { - puts "aListChildNodes=${aListChildNodes}" - puts "aListChildNodesLength=${aListChildNodesLength}" - puts "ChildNodeIterate Doc TreeNode AllLevels=1 : Error" - return -} - -puts "ChildNodeIterate Doc TreeNode AllLevels=1 : OK" diff --git a/tests/caf/tree/I4 b/tests/caf/tree/I4 deleted file mode 100755 index 8fae156b00..0000000000 --- a/tests/caf/tree/I4 +++ /dev/null @@ -1,125 +0,0 @@ -#INTERFACE CAF -# Tree construction attributes -# -# Testing attribute: TDataStd_TreeNode -# -# Testing command: ChildNodeIterate -# -# Testing command: NewChild -# Testing command: AppendNode -# - -puts "caf005-I4" -set QA_DUP 0 - -# Add an attribute to a data framework -set aLabel_Root 0:2 -set aName_Root Label_1 -Label D ${aLabel_Root} -SetName D ${aLabel_Root} ${aName_Root} - -set aName1 Label_1_1 -###set aChild1 [NewChild D ${aLabel_Root}] -set aChild1 0:2:1 -Label D ${aChild1} -SetName D ${aChild1} ${aName1} - -set aName2 Label_1_2 -###set aChild2 [NewChild D ${aLabel_Root}] -set aChild2 0:2:2 -Label D ${aChild2} -SetName D ${aChild2} ${aName2} - -set aName3 Label_1_1_1 -###set aChild3 [NewChild D ${aLabel_Root}] -set aChild3 0:2:3 -Label D ${aChild3} -SetName D ${aChild3} ${aName3} - -set aName4 Label_1_1_2 -###set aChild4 [NewChild D ${aLabel_Root}] -set aChild4 0:2:4 -Label D ${aChild4} -SetName D ${aChild4} ${aName4} - -set aName5 Label_1_1_3 -###set aChild5 [NewChild D ${aLabel_Root}] -set aChild5 0:2:5 -Label D ${aChild5} -SetName D ${aChild5} ${aName5} - -set aName6 Label_1_2_1 -###set aChild6 [NewChild D ${aLabel_Root}] -set aChild6 0:2:6 -Label D ${aChild6} -SetName D ${aChild6} ${aName6} - -set aName7 Label_1_2_2 -###set aChild7 [NewChild D ${aLabel_Root}] -set aChild7 0:2:7 -Label D ${aChild7} -SetName D ${aChild7} ${aName7} - -SetNode D ${aLabel_Root} -AppendNode D ${aLabel_Root} ${aChild1} -AppendNode D ${aLabel_Root} ${aChild2} -AppendNode D ${aChild1} ${aChild3} -AppendNode D ${aChild1} ${aChild4} -AppendNode D ${aChild1} ${aChild5} -AppendNode D ${aChild2} ${aChild6} -AppendNode D ${aChild2} ${aChild7} - -# Close/Open the transaction -NewCommand D - -# Forget the attribute -ForgetAll D ${aLabel_Root} - -# Close/Open the transaction -NewCommand D - -# Undo-Redo-Undo -Undo D -Redo D -Undo D - -# Get a value of the attribute -set IsDone [catch {set aListChildNodes [ChildNodeIterate D ${aLabel_Root} 1]} aResult] -if { ${IsDone} != 0 } { - puts ${aResult} - puts "ChildNodeIterate Doc TreeNode AllLevels=1 : Error" - return -} -set aListChildNodesLength [llength ${aListChildNodes}] -if { ${aListChildNodesLength}!=[expr 7 + 0]} { - puts "aListChildNodes=${aListChildNodes}" - puts "aListChildNodesLength=${aListChildNodesLength}" - puts "ChildNodeIterate Doc TreeNode AllLevels=1 : Error" - return -} -set aFirstChildNode [lindex ${aListChildNodes} 0] -set aSecondChildNode [lindex ${aListChildNodes} 1] -set aThirdChildNode [lindex ${aListChildNodes} 2] -set aForthChildNode [lindex ${aListChildNodes} 3] -set aFifthChildNode [lindex ${aListChildNodes} 4] -set aSixthChildNode [lindex ${aListChildNodes} 5] -set aSeventhChildNode [lindex ${aListChildNodes} 6] -if { ${aFirstChildNode}!=${aChild1} || - ${aSecondChildNode}!=${aChild3} || - ${aThirdChildNode}!=${aChild4} || - ${aForthChildNode}!=${aChild5} || - ${aFifthChildNode}!=${aChild2} || - ${aSixthChildNode}!=${aChild6} || - ${aSeventhChildNode}!=${aChild7}} { - puts "aFirstChildNode=${aFirstChildNode} aChild1=${aChild1}" - puts "aSecondChildNode=${aSecondChildNode} aChild3=${aChild3}" - puts "aThirdChildNode=${aThirdChildNode} aChild4=${aChild4}" - puts "aForthChildNode=${aForthChildNode} aChild5=${aChild5}" - puts "aFifthChildNode=${aFifthChildNode} aChild2=${aChild2}" - puts "aSixthChildNode=${aSixthChildNode} aChild6=${aChild6}" - puts "aSeventhChildNode=${aSeventhChildNode} aChild=${aChild}" - puts "ChildNodeIterate Doc TreeNode AllLevels=1 : Error" - return -} - -puts "ChildNodeIterate Doc TreeNode AllLevels=1 : OK" diff --git a/tests/caf/tree/J1 b/tests/caf/tree/J1 deleted file mode 100755 index 4120d25799..0000000000 --- a/tests/caf/tree/J1 +++ /dev/null @@ -1,100 +0,0 @@ -#INTERFACE CAF -# Tree construction attributes -# -# Testing attribute: TDataStd_TreeNode -# -# Testing command: InitChildNodeIterator -# Testing command: ChildNodeMore -# -# Testing command: NewChild -# Testing command: AppendNode -# - -puts "caf005-J1" - -# Add an attribute to a data framework -set aLabel_Root 0:2 -set aName_Root Label_1 -Label D ${aLabel_Root} -SetName D ${aLabel_Root} ${aName_Root} - -set aName1 Label_1_1 -###set aChild1 [NewChild D ${aLabel_Root}] -set aChild1 0:2:1 -Label D ${aChild1} -SetName D ${aChild1} ${aName1} - -set aName2 Label_1_2 -###set aChild2 [NewChild D ${aLabel_Root}] -set aChild2 0:2:2 -Label D ${aChild2} -SetName D ${aChild2} ${aName2} - -set aName3 Label_1_1_1 -###set aChild3 [NewChild D ${aLabel_Root}] -set aChild3 0:2:3 -Label D ${aChild3} -SetName D ${aChild3} ${aName3} - -set aName4 Label_1_1_2 -###set aChild4 [NewChild D ${aLabel_Root}] -set aChild4 0:2:4 -Label D ${aChild4} -SetName D ${aChild4} ${aName4} - -set aName5 Label_1_1_3 -###set aChild5 [NewChild D ${aLabel_Root}] -set aChild5 0:2:5 -Label D ${aChild5} -SetName D ${aChild5} ${aName5} - -set aName6 Label_1_2_1 -###set aChild6 [NewChild D ${aLabel_Root}] -set aChild6 0:2:6 -Label D ${aChild6} -SetName D ${aChild6} ${aName6} - -set aName7 Label_1_2_2 -###set aChild7 [NewChild D ${aLabel_Root}] -set aChild7 0:2:7 -Label D ${aChild7} -SetName D ${aChild7} ${aName7} - -SetNode D ${aLabel_Root} -AppendNode D ${aLabel_Root} ${aChild1} -AppendNode D ${aLabel_Root} ${aChild2} -AppendNode D ${aChild1} ${aChild3} -AppendNode D ${aChild1} ${aChild4} -AppendNode D ${aChild1} ${aChild5} -AppendNode D ${aChild2} ${aChild6} -AppendNode D ${aChild2} ${aChild7} - -# Close/Open the transaction -NewCommand D - -# Forget the attribute -ForgetAll D ${aLabel_Root} - -# Close/Open the transaction -NewCommand D - -# Undo-Redo-Undo -Undo D -Redo D -Undo D - -# Get a value of the attribute -set IsDone [catch {InitChildNodeIterator D ${aLabel_Root} 1} aResult] -if { ${IsDone} != 0 } { - puts ${aResult} - puts "InitChildNodeIterator Doc TreeNode AllLevels=1 : Error" - return -} -set aMore [ChildNodeMore] -set aMore [lindex ${aMore} 0] -if { ${aMore}!= "TRUE" && ${aMore}!= "TRUETRUE" } { - puts "aMore=${aMore}" - puts "InitChildNodeIterator Doc TreeNode AllLevels=1 : Error" - return -} -puts "InitChildNodeIterator Doc TreeNode AllLevels=1 : OK" diff --git a/tests/caf/tree/J2 b/tests/caf/tree/J2 deleted file mode 100755 index d83352070d..0000000000 --- a/tests/caf/tree/J2 +++ /dev/null @@ -1,100 +0,0 @@ -#INTERFACE CAF -# Tree construction attributes -# -# Testing attribute: TDataStd_TreeNode -# -# Testing command: InitChildNodeIterator -# Testing command: ChildNodeMore -# -# Testing command: NewChild -# Testing command: AppendNode -# - -puts "caf005-J2" - -# Add an attribute to a data framework -set aLabel_Root 0:2 -set aName_Root Label_1 -Label D ${aLabel_Root} -SetName D ${aLabel_Root} ${aName_Root} - -set aName1 Label_1_1 -###set aChild1 [NewChild D ${aLabel_Root}] -set aChild1 0:2:1 -Label D ${aChild1} -SetName D ${aChild1} ${aName1} - -set aName2 Label_1_2 -###set aChild2 [NewChild D ${aLabel_Root}] -set aChild2 0:2:2 -Label D ${aChild2} -SetName D ${aChild2} ${aName2} - -set aName3 Label_1_1_1 -###set aChild3 [NewChild D ${aLabel_Root}] -set aChild3 0:2:3 -Label D ${aChild3} -SetName D ${aChild3} ${aName3} - -set aName4 Label_1_1_2 -###set aChild4 [NewChild D ${aLabel_Root}] -set aChild4 0:2:4 -Label D ${aChild4} -SetName D ${aChild4} ${aName4} - -set aName5 Label_1_1_3 -###set aChild5 [NewChild D ${aLabel_Root}] -set aChild5 0:2:5 -Label D ${aChild5} -SetName D ${aChild5} ${aName5} - -set aName6 Label_1_2_1 -###set aChild6 [NewChild D ${aLabel_Root}] -set aChild6 0:2:6 -Label D ${aChild6} -SetName D ${aChild6} ${aName6} - -set aName7 Label_1_2_2 -###set aChild7 [NewChild D ${aLabel_Root}] -set aChild7 0:2:7 -Label D ${aChild7} -SetName D ${aChild7} ${aName7} - -SetNode D ${aLabel_Root} -AppendNode D ${aLabel_Root} ${aChild1} -AppendNode D ${aLabel_Root} ${aChild2} -AppendNode D ${aChild1} ${aChild3} -AppendNode D ${aChild1} ${aChild4} -AppendNode D ${aChild1} ${aChild5} -AppendNode D ${aChild2} ${aChild6} -AppendNode D ${aChild2} ${aChild7} - -# Close/Open the transaction -NewCommand D - -# Forget the attribute -ForgetAll D ${aLabel_Root} - -# Close/Open the transaction -NewCommand D - -# Undo-Redo-Undo -Undo D -Redo D -Undo D - -# Get a value of the attribute -set IsDone [catch {InitChildNodeIterator D ${aLabel_Root} 0} aResult] -if { ${IsDone} != 0 } { - puts ${aResult} - puts "InitChildNodeIterator Doc TreeNode AllLevels=0 : Error" - return -} -set aMore [ChildNodeMore] -set aMore [lindex ${aMore} 0] -if { ${aMore} !="TRUE" && ${aMore} !="TRUETRUE" } { - puts "aMore=${aMore}" - puts "InitChildNodeIterator Doc TreeNode AllLevels=0 : Error" - return -} -puts "InitChildNodeIterator Doc TreeNode AllLevels=0 : OK" diff --git a/tests/caf/tree/K1 b/tests/caf/tree/K1 deleted file mode 100755 index f06cca9c29..0000000000 --- a/tests/caf/tree/K1 +++ /dev/null @@ -1,109 +0,0 @@ -#INTERFACE CAF -# Tree construction attributes -# -# Testing attribute: TDataStd_TreeNode -# -# Testing command: ChildNodeNext -# -# Testing command: NewChild -# Testing command: AppendNode -# Testing command: InitChildNodeIterator -# Testing command: ChildNodeMore -# - -puts "caf005-K1" - -# Add an attribute to a data framework -set aLabel_Root 0:2 -set aName_Root Label_1 -Label D ${aLabel_Root} -SetName D ${aLabel_Root} ${aName_Root} - -set aName1 Label_1_1 -###set aChild1 [NewChild D ${aLabel_Root}] -set aChild1 0:2:1 -Label D ${aChild1} -SetName D ${aChild1} ${aName1} - -set aName2 Label_1_2 -###set aChild2 [NewChild D ${aLabel_Root}] -set aChild2 0:2:2 -Label D ${aChild2} -SetName D ${aChild2} ${aName2} - -set aName3 Label_1_1_1 -###set aChild3 [NewChild D ${aLabel_Root}] -set aChild3 0:2:3 -Label D ${aChild3} -SetName D ${aChild3} ${aName3} - -set aName4 Label_1_1_2 -###set aChild4 [NewChild D ${aLabel_Root}] -set aChild4 0:2:4 -Label D ${aChild4} -SetName D ${aChild4} ${aName4} - -set aName5 Label_1_1_3 -###set aChild5 [NewChild D ${aLabel_Root}] -set aChild5 0:2:5 -Label D ${aChild5} -SetName D ${aChild5} ${aName5} - -set aName6 Label_1_2_1 -###set aChild6 [NewChild D ${aLabel_Root}] -set aChild6 0:2:6 -Label D ${aChild6} -SetName D ${aChild6} ${aName6} - -set aName7 Label_1_2_2 -###set aChild7 [NewChild D ${aLabel_Root}] -set aChild7 0:2:7 -Label D ${aChild7} -SetName D ${aChild7} ${aName7} - -SetNode D ${aLabel_Root} -AppendNode D ${aLabel_Root} ${aChild1} -AppendNode D ${aLabel_Root} ${aChild2} -AppendNode D ${aChild1} ${aChild3} -AppendNode D ${aChild1} ${aChild4} -AppendNode D ${aChild1} ${aChild5} -AppendNode D ${aChild2} ${aChild6} -AppendNode D ${aChild2} ${aChild7} - -# Close/Open the transaction -NewCommand D - -# Forget the attribute -ForgetAll D ${aLabel_Root} - -# Close/Open the transaction -NewCommand D - -# Undo-Redo-Undo -Undo D -Redo D -Undo D - -# Get a value of the attribute -set IsDone [catch {InitChildNodeIterator D ${aLabel_Root} 1} aResult] -if { ${IsDone} != 0 } { - puts ${aResult} - puts "ChildNodeNext for InitChildNodeIterator Doc TreeNode AllLevels=1 : Error" - return -} -set aChildNumber 0 -for {set i 1} {${i}<=10} {incr i} { - set aMore [ChildNodeMore] - set aMore [lindex ${aMore} 0] - if { ${aMore}=="TRUE" || ${aMore}=="TRUETRUE" } { - ChildNodeNext - incr aChildNumber - } -} - -if { ${aChildNumber}!=7} { - puts "aChildNumber=${aChildNumber}" - puts "ChildNodeNext for InitChildNodeIterator Doc TreeNode AllLevels=1 : Error" - return -} -puts "ChildNodeNext for InitChildNodeIterator Doc TreeNode AllLevels=1 : OK" diff --git a/tests/caf/tree/K2 b/tests/caf/tree/K2 deleted file mode 100755 index b04ba40904..0000000000 --- a/tests/caf/tree/K2 +++ /dev/null @@ -1,109 +0,0 @@ -#INTERFACE CAF -# Tree construction attributes -# -# Testing attribute: TDataStd_TreeNode -# -# Testing command: ChildNodeNext -# -# Testing command: NewChild -# Testing command: AppendNode -# Testing command: InitChildNodeIterator -# Testing command: ChildNodeMore -# - -puts "caf005-K2" - -# Add an attribute to a data framework -set aLabel_Root 0:2 -set aName_Root Label_1 -Label D ${aLabel_Root} -SetName D ${aLabel_Root} ${aName_Root} - -set aName1 Label_1_1 -###set aChild1 [NewChild D ${aLabel_Root}] -set aChild1 0:2:1 -Label D ${aChild1} -SetName D ${aChild1} ${aName1} - -set aName2 Label_1_2 -###set aChild2 [NewChild D ${aLabel_Root}] -set aChild2 0:2:2 -Label D ${aChild2} -SetName D ${aChild2} ${aName2} - -set aName3 Label_1_1_1 -###set aChild3 [NewChild D ${aLabel_Root}] -set aChild3 0:2:3 -Label D ${aChild3} -SetName D ${aChild3} ${aName3} - -set aName4 Label_1_1_2 -###set aChild4 [NewChild D ${aLabel_Root}] -set aChild4 0:2:4 -Label D ${aChild4} -SetName D ${aChild4} ${aName4} - -set aName5 Label_1_1_3 -###set aChild5 [NewChild D ${aLabel_Root}] -set aChild5 0:2:5 -Label D ${aChild5} -SetName D ${aChild5} ${aName5} - -set aName6 Label_1_2_1 -###set aChild6 [NewChild D ${aLabel_Root}] -set aChild6 0:2:6 -Label D ${aChild6} -SetName D ${aChild6} ${aName6} - -set aName7 Label_1_2_2 -###set aChild7 [NewChild D ${aLabel_Root}] -set aChild7 0:2:7 -Label D ${aChild7} -SetName D ${aChild7} ${aName7} - -SetNode D ${aLabel_Root} -AppendNode D ${aLabel_Root} ${aChild1} -AppendNode D ${aLabel_Root} ${aChild2} -AppendNode D ${aChild1} ${aChild3} -AppendNode D ${aChild1} ${aChild4} -AppendNode D ${aChild1} ${aChild5} -AppendNode D ${aChild2} ${aChild6} -AppendNode D ${aChild2} ${aChild7} - -# Close/Open the transaction -NewCommand D - -# Forget the attribute -ForgetAll D ${aLabel_Root} - -# Close/Open the transaction -NewCommand D - -# Undo-Redo-Undo -Undo D -Redo D -Undo D - -# Get a value of the attribute -set IsDone [catch {InitChildNodeIterator D ${aLabel_Root} 0} aResult] -if { ${IsDone} != 0 } { - puts ${aResult} - puts "ChildNodeNext for InitChildNodeIterator Doc TreeNode AllLevels=0 : Error" - return -} -set aChildNumber 0 -for {set i 1} {${i}<=10} {incr i} { - set aMore [ChildNodeMore] - set aMore [lindex ${aMore} 0] - if { ${aMore}=="TRUE" || ${aMore}=="TRUETRUE"} { - ChildNodeNext - incr aChildNumber - } -} - -if { ${aChildNumber}!=2} { - puts "aChildNumber=${aChildNumber}" - puts "ChildNodeNext for InitChildNodeIterator Doc TreeNode AllLevels=0 : Error" - return -} -puts "ChildNodeNext for InitChildNodeIterator Doc TreeNode AllLevels=0 : OK" diff --git a/tests/caf/tree/L1 b/tests/caf/tree/L1 deleted file mode 100755 index a1e46b63a5..0000000000 --- a/tests/caf/tree/L1 +++ /dev/null @@ -1,124 +0,0 @@ -#INTERFACE CAF -# Tree construction attributes -# -# Testing attribute: TDataStd_TreeNode -# -# Testing command: ChildNodeValue -# -# Testing command: NewChild -# Testing command: AppendNode -# Testing command: InitChildNodeIterator -# Testing command: ChildNodeMore -# Testing command: ChildNodeNext -# - -puts "caf005-L1" -set QA_DUP 0 - -# Add an attribute to a data framework -set aLabel_Root 0:2 -set aName_Root Label_1 -Label D ${aLabel_Root} -SetName D ${aLabel_Root} ${aName_Root} - -set aName1 Label_1_1 -###set aChild1 [NewChild D ${aLabel_Root}] -set aChild1 0:2:1 -Label D ${aChild1} -SetName D ${aChild1} ${aName1} - -set aName2 Label_1_2 -###set aChild2 [NewChild D ${aLabel_Root}] -set aChild2 0:2:2 -Label D ${aChild2} -SetName D ${aChild2} ${aName2} - -set aName3 Label_1_1_1 -###set aChild3 [NewChild D ${aLabel_Root}] -set aChild3 0:2:3 -Label D ${aChild3} -SetName D ${aChild3} ${aName3} - -set aName4 Label_1_1_2 -###set aChild4 [NewChild D ${aLabel_Root}] -set aChild4 0:2:4 -Label D ${aChild4} -SetName D ${aChild4} ${aName4} - -set aName5 Label_1_1_3 -###set aChild5 [NewChild D ${aLabel_Root}] -set aChild5 0:2:5 -Label D ${aChild5} -SetName D ${aChild5} ${aName5} - -set aName6 Label_1_2_1 -###set aChild6 [NewChild D ${aLabel_Root}] -set aChild6 0:2:6 -Label D ${aChild6} -SetName D ${aChild6} ${aName6} - -set aName7 Label_1_2_2 -###set aChild7 [NewChild D ${aLabel_Root}] -set aChild7 0:2:7 -Label D ${aChild7} -SetName D ${aChild7} ${aName7} - -SetNode D ${aLabel_Root} -AppendNode D ${aLabel_Root} ${aChild1} -AppendNode D ${aLabel_Root} ${aChild2} -AppendNode D ${aChild1} ${aChild3} -AppendNode D ${aChild1} ${aChild4} -AppendNode D ${aChild1} ${aChild5} -AppendNode D ${aChild2} ${aChild6} -AppendNode D ${aChild2} ${aChild7} - -# Close/Open the transaction -NewCommand D - -# Forget the attribute -ForgetAll D ${aLabel_Root} - -# Close/Open the transaction -NewCommand D - -# Undo-Redo-Undo -Undo D -Redo D -Undo D - -# Get a value of the attribute -set IsDone [catch {InitChildNodeIterator D ${aLabel_Root} 0} aResult] -if { ${IsDone} != 0 } { - puts ${aResult} - puts "ChildNodeValue for InitChildNodeIterator Doc TreeNode AllLevels=0 : Error" - return -} -set aChildNumber 0 -set aChildNodeList {} -for {set i 1} {${i}<=10} {incr i} { - set aMore [ChildNodeMore] - set aMore [lindex ${aMore} 0] - if { ${aMore}=="TRUE"} { - set aChildNodeValue [ChildNodeValue] - set aChildNodeList [concat ${aChildNodeList} ${aChildNodeValue}] - ChildNodeNext - incr aChildNumber - } -} - -if { ${aChildNumber}!=2} { - puts "aChildNumber=${aChildNumber}" - puts "ChildNodeNext for InitChildNodeIterator Doc TreeNode AllLevels=0 : Error" - return -} - -set aFirstChildNode [lindex ${aChildNodeList} 0] -set aSecondChildNode [lindex ${aChildNodeList} 1] -if { ${aFirstChildNode}!=${aChild1} || - ${aSecondChildNode}!=${aChild2}} { - puts "aFirstChildNode=${aFirstChildNode} aChild1=${aChild1}" - puts "aSecondChildNode=${aSecondChildNode} aChild2=${aChild2}" - puts "ChildNodeValue for InitChildNodeIterator Doc TreeNode AllLevels=0 : Error" - return -} -puts "ChildNodeValue for InitChildNodeIterator Doc TreeNode AllLevels=0 : OK" diff --git a/tests/caf/tree/L2 b/tests/caf/tree/L2 deleted file mode 100755 index 7613391b7f..0000000000 --- a/tests/caf/tree/L2 +++ /dev/null @@ -1,140 +0,0 @@ -#INTERFACE CAF -# Tree construction attributes -# -# Testing attribute: TDataStd_TreeNode -# -# Testing command: ChildNodeValue -# -# Testing command: NewChild -# Testing command: AppendNode -# Testing command: InitChildNodeIterator -# Testing command: ChildNodeMore -# Testing command: ChildNodeNext -# - -puts "caf005-L2" -set QA_DUP 0 - -# Add an attribute to a data framework -set aLabel_Root 0:2 -set aName_Root Label_1 -Label D ${aLabel_Root} -SetName D ${aLabel_Root} ${aName_Root} - -set aName1 Label_1_1 -###set aChild1 [NewChild D ${aLabel_Root}] -set aChild1 0:2:1 -Label D ${aChild1} -SetName D ${aChild1} ${aName1} - -set aName2 Label_1_2 -###set aChild2 [NewChild D ${aLabel_Root}] -set aChild2 0:2:2 -Label D ${aChild2} -SetName D ${aChild2} ${aName2} - -set aName3 Label_1_1_1 -###set aChild3 [NewChild D ${aLabel_Root}] -set aChild3 0:2:3 -Label D ${aChild3} -SetName D ${aChild3} ${aName3} - -set aName4 Label_1_1_2 -###set aChild4 [NewChild D ${aLabel_Root}] -set aChild4 0:2:4 -Label D ${aChild4} -SetName D ${aChild4} ${aName4} - -set aName5 Label_1_1_3 -###set aChild5 [NewChild D ${aLabel_Root}] -set aChild5 0:2:5 -Label D ${aChild5} -SetName D ${aChild5} ${aName5} - -set aName6 Label_1_2_1 -###set aChild6 [NewChild D ${aLabel_Root}] -set aChild6 0:2:6 -Label D ${aChild6} -SetName D ${aChild6} ${aName6} - -set aName7 Label_1_2_2 -###set aChild7 [NewChild D ${aLabel_Root}] -set aChild7 0:2:7 -Label D ${aChild7} -SetName D ${aChild7} ${aName7} - -SetNode D ${aLabel_Root} -AppendNode D ${aLabel_Root} ${aChild1} -AppendNode D ${aLabel_Root} ${aChild2} -AppendNode D ${aChild1} ${aChild3} -AppendNode D ${aChild1} ${aChild4} -AppendNode D ${aChild1} ${aChild5} -AppendNode D ${aChild2} ${aChild6} -AppendNode D ${aChild2} ${aChild7} - -# Close/Open the transaction -NewCommand D - -# Forget the attribute -ForgetAll D ${aLabel_Root} - -# Close/Open the transaction -NewCommand D - -# Undo-Redo-Undo -Undo D -Redo D -Undo D - -# Get a value of the attribute -set IsDone [catch {InitChildNodeIterator D ${aLabel_Root} 1} aResult] -if { ${IsDone} != 0 } { - puts ${aResult} - puts "ChildNodeNext for InitChildNodeIterator Doc TreeNode AllLevels=1 : Error" - return -} -set aChildNumber 0 -set aChildNodeList {} -for {set i 1} {${i}<=10} {incr i} { - set aMore [ChildNodeMore] - set aMore [lindex ${aMore} 0] - if { ${aMore}=="TRUE"} { - set aChildNodeValue [ChildNodeValue] - set aChildNodeList [concat ${aChildNodeList} ${aChildNodeValue}] - ChildNodeNext - incr aChildNumber - } -} - -if { ${aChildNumber}!=7} { - puts "aChildNumber=${aChildNumber}" - puts "ChildNodeNext for InitChildNodeIterator Doc TreeNode AllLevels=1 : Error" - return -} - -set aFirstChildNode [lindex ${aChildNodeList} 0] -set aSecondChildNode [lindex ${aChildNodeList} 1] -set aThirdChildNode [lindex ${aChildNodeList} 2] -set aForthChildNode [lindex ${aChildNodeList} 3] -set aFifthChildNode [lindex ${aChildNodeList} 4] -set aSixthChildNode [lindex ${aChildNodeList} 5] -set aSeventhChildNode [lindex ${aChildNodeList} 6] -if { ${aFirstChildNode}!=${aChild1} || - ${aSecondChildNode}!=${aChild3} || - ${aThirdChildNode}!=${aChild4} || - ${aForthChildNode}!=${aChild5} || - ${aFifthChildNode}!=${aChild2} || - ${aSixthChildNode}!=${aChild6} || - ${aSeventhChildNode}!=${aChild7}} { - puts "aFirstChildNode=${aFirstChildNode} aChild1=${aChild1}" - puts "aSecondChildNode=${aSecondChildNode} aChild3=${aChild3}" - puts "aThirdChildNode=${aThirdChildNode} aChild4=${aChild4}" - puts "aForthChildNode=${aForthChildNode} aChild5=${aChild5}" - puts "aFifthChildNode=${aFifthChildNode} aChild2=${aChild2}" - puts "aSixthChildNode=${aSixthChildNode} aChild6=${aChild6}" - puts "aSeventhChildNode=${aSeventhChildNode} aChild7=${aChild7}" - puts "ChildNodeValue for InitChildNodeIterator Doc TreeNode AllLevels=1 : Error" - return -} - -puts "ChildNodeValue for InitChildNodeIterator Doc TreeNode AllLevels=1 : OK" diff --git a/tests/caf/tree/M1 b/tests/caf/tree/M1 deleted file mode 100755 index 42653a4c49..0000000000 --- a/tests/caf/tree/M1 +++ /dev/null @@ -1,133 +0,0 @@ -#INTERFACE CAF -# Tree construction attributes -# -# Testing attribute: TDataStd_TreeNode -# -# Testing command: ChildNodeNextBrother -# -# Testing command: NewChild -# Testing command: AppendNode -# Testing command: InitChildNodeIterator -# Testing command: ChildNodeMore -# Testing command: ChildNodeNext -# Testing command: ChildNodeValue -# - -puts "caf005-M1" - -# Add an attribute to a data framework -set aLabel_Root 0:2 -set aName_Root Label_1 -Label D ${aLabel_Root} -SetName D ${aLabel_Root} ${aName_Root} - -set aName1 Label_1_1 -###set aChild1 [NewChild D ${aLabel_Root}] -set aChild1 0:2:1 -Label D ${aChild1} -SetName D ${aChild1} ${aName1} - -set aName2 Label_1_2 -###set aChild2 [NewChild D ${aLabel_Root}] -set aChild2 0:2:2 -Label D ${aChild2} -SetName D ${aChild2} ${aName2} - -set aName3 Label_1_1_1 -###set aChild3 [NewChild D ${aLabel_Root}] -set aChild3 0:2:3 -Label D ${aChild3} -SetName D ${aChild3} ${aName3} - -set aName4 Label_1_1_2 -###set aChild4 [NewChild D ${aLabel_Root}] -set aChild4 0:2:4 -Label D ${aChild4} -SetName D ${aChild4} ${aName4} - -set aName5 Label_1_1_3 -###set aChild5 [NewChild D ${aLabel_Root}] -set aChild5 0:2:5 -Label D ${aChild5} -SetName D ${aChild5} ${aName5} - -set aName6 Label_1_2_1 -###set aChild6 [NewChild D ${aLabel_Root}] -set aChild6 0:2:6 -Label D ${aChild6} -SetName D ${aChild6} ${aName6} - -set aName7 Label_1_2_2 -###set aChild7 [NewChild D ${aLabel_Root}] -set aChild7 0:2:7 -Label D ${aChild7} -SetName D ${aChild7} ${aName7} - -set aName8 Label_1_2_2_1 -###set aChild8 [NewChild D ${aLabel_Root}] -set aChild8 0:2:8 -Label D ${aChild8} -SetName D ${aChild8} ${aName8} - -set aName9 Label_1_2_2_2 -###set aChild9 [NewChild D ${aLabel_Root}] -set aChild9 0:2:9 -Label D ${aChild9} -SetName D ${aChild9} ${aName9} - -SetNode D ${aLabel_Root} -AppendNode D ${aLabel_Root} ${aChild1} -AppendNode D ${aLabel_Root} ${aChild2} -AppendNode D ${aChild1} ${aChild3} -AppendNode D ${aChild1} ${aChild4} -AppendNode D ${aChild1} ${aChild5} -AppendNode D ${aChild2} ${aChild6} -AppendNode D ${aChild2} ${aChild7} -AppendNode D ${aChild4} ${aChild8} -AppendNode D ${aChild4} ${aChild9} - -# Close/Open the transaction -NewCommand D - -# Forget the attribute -ForgetAll D ${aLabel_Root} - -# Close/Open the transaction -NewCommand D - -# Undo-Redo-Undo -Undo D -Redo D -Undo D - -# Get a value of the attribute -set IsDone [catch {InitChildNodeIterator D ${aLabel_Root} 1} aResult] -if { ${IsDone} != 0 } { - puts ${aResult} - puts "ChildNodeNextBrother for InitChildNodeIterator Doc TreeNode AllLevels=1 : Error" - return -} -for {set i 1} {${i}<=3} {incr i} { - ChildNodeNext -} -ChildNodeNextBrother -set aFirstBrotherNode [ChildNodeValue] -set aFirstBrotherNode [lindex ${aFirstBrotherNode} 0] -ChildNodeNextBrother -set aSecondBrotherNode [ChildNodeValue] -set aSecondBrotherNode [lindex ${aSecondBrotherNode} 0] -ChildNodeNextBrother -set aThirdBrotherNode [ChildNodeValue] -set aThirdBrotherNode [lindex ${aThirdBrotherNode} 0] - -if {[string first ${aChild9} ${aFirstBrotherNode}] != 0 || - [string first ${aChild5} ${aSecondBrotherNode}] != 0 || - [string first ${aChild2} ${aThirdBrotherNode}] != 0} { - puts "aFirstBrotherNode=${aFirstBrotherNode} aChild9=${aChild9}" - puts "aSecondBrotherNode=${aSecondBrotherNode} aChild5=${aChild5}" - puts "aThirdBrotherNode=${aThirdBrotherNode} aChild2=${aChild2}" - puts "ChildNodeNextBrother for InitChildNodeIterator Doc TreeNode AllLevels=1 : Error" - return -} - -puts "ChildNodeNextBrother for InitChildNodeIterator Doc TreeNode AllLevels=1 : OK" diff --git a/tests/caf/tree/M2 b/tests/caf/tree/M2 deleted file mode 100755 index 2061af0eb5..0000000000 --- a/tests/caf/tree/M2 +++ /dev/null @@ -1,132 +0,0 @@ -#INTERFACE CAF -# Tree construction attributes -# -# Testing attribute: TDataStd_TreeNode -# -# Testing command: ChildNodeNextBrother -# -# Testing command: NewChild -# Testing command: AppendNode -# Testing command: InitChildNodeIterator -# Testing command: ChildNodeMore -# Testing command: ChildNodeNext -# Testing command: ChildNodeValue -# - -puts "caf005-M2" - -# Add an attribute to a data framework -set aLabel_Root 0:2 -set aName_Root Label_1 -Label D ${aLabel_Root} -SetName D ${aLabel_Root} ${aName_Root} - -set aName1 Label_1_1 -###set aChild1 [NewChild D ${aLabel_Root}] -set aChild1 0:2:1 -Label D ${aChild1} -SetName D ${aChild1} ${aName1} - -set aName2 Label_1_2 -###set aChild2 [NewChild D ${aLabel_Root}] -set aChild2 0:2:2 -Label D ${aChild2} -SetName D ${aChild2} ${aName2} - -set aName3 Label_1_1_1 -###set aChild3 [NewChild D ${aLabel_Root}] -set aChild3 0:2:3 -Label D ${aChild3} -SetName D ${aChild3} ${aName3} - -set aName4 Label_1_1_2 -###set aChild4 [NewChild D ${aLabel_Root}] -set aChild4 0:2:4 -Label D ${aChild4} -SetName D ${aChild4} ${aName4} - -set aName5 Label_1_1_3 -###set aChild5 [NewChild D ${aLabel_Root}] -set aChild5 0:2:5 -Label D ${aChild5} -SetName D ${aChild5} ${aName5} - -set aName6 Label_1_2_1 -###set aChild6 [NewChild D ${aLabel_Root}] -set aChild6 0:2:6 -Label D ${aChild6} -SetName D ${aChild6} ${aName6} - -set aName7 Label_1_2_2 -###set aChild7 [NewChild D ${aLabel_Root}] -set aChild7 0:2:7 -Label D ${aChild7} -SetName D ${aChild7} ${aName7} - -set aName8 Label_1_2_2_1 -###set aChild8 [NewChild D ${aLabel_Root}] -set aChild8 0:2:8 -Label D ${aChild8} -SetName D ${aChild8} ${aName8} - -set aName9 Label_1_2_2_2 -###set aChild9 [NewChild D ${aLabel_Root}] -set aChild9 0:2:9 -Label D ${aChild9} -SetName D ${aChild9} ${aName9} - -set aName10 Label_1_3 -###set aChild10 [NewChild D ${aLabel_Root}] -set aChild10 0:2:10 -Label D ${aChild10} -SetName D ${aChild10} ${aName10} - -SetNode D ${aLabel_Root} -AppendNode D ${aLabel_Root} ${aChild1} -AppendNode D ${aLabel_Root} ${aChild2} -AppendNode D ${aChild1} ${aChild3} -AppendNode D ${aChild1} ${aChild4} -AppendNode D ${aChild1} ${aChild5} -AppendNode D ${aChild2} ${aChild6} -AppendNode D ${aChild2} ${aChild7} -AppendNode D ${aChild4} ${aChild8} -AppendNode D ${aChild4} ${aChild9} -AppendNode D ${aLabel_Root} ${aChild10} - -# Close/Open the transaction -NewCommand D - -# Forget the attribute -ForgetAll D ${aLabel_Root} - -# Close/Open the transaction -NewCommand D - -# Undo-Redo-Undo -Undo D -Redo D -Undo D - -# Get a value of the attribute -set IsDone [catch {InitChildNodeIterator D ${aLabel_Root} 0} aResult] -if { ${IsDone} != 0 } { - puts ${aResult} - puts "ChildNodeNextBrother for InitChildNodeIterator Doc TreeNode AllLevels=0 : Error" - return -} -ChildNodeNextBrother -set aFirstBrotherNode [ChildNodeValue] -set aFirstBrotherNode [lindex ${aFirstBrotherNode} 0] -ChildNodeNextBrother -set aSecondBrotherNode [ChildNodeValue] -set aSecondBrotherNode [lindex ${aSecondBrotherNode} 0] - -if { [string first ${aChild2} ${aFirstBrotherNode}] != 0 || - [string first ${aChild10} ${aSecondBrotherNode}] != 0} { - puts "aFirstBrotherNode=${aFirstBrotherNode} aChild2=${aChild2}" - puts "aSecondBrotherNode=${aSecondBrotherNode} aChild10=${aChild10}" - puts "ChildNodeNextBrother for InitChildNodeIterator Doc TreeNode AllLevels=0 : Error" - return -} - -puts "ChildNodeNextBrother for InitChildNodeIterator Doc TreeNode AllLevels=0 : OK" diff --git a/tests/caf/xlink/A1 b/tests/caf/xlink/A1 deleted file mode 100755 index 46fb552e96..0000000000 --- a/tests/caf/xlink/A1 +++ /dev/null @@ -1,78 +0,0 @@ -#INTERFACE CAF -# XLink attributes -# -# Testing attribute: TDocStd_XLink -# -# Testing command: Copy -# - -puts "caf004-A1" - -# Create two new documents Doc1, Doc2 -NewDocument Doc1 BinOcaf -NewDocument Doc2 BinOcaf - -# Set UndoLimit for them -UndoLimit Doc1 100 -UndoLimit Doc2 100 - -# Set a shape in Doc1 to label 'SLabel' -set aLabel1 0:2 -Label Doc1 ${aLabel1} -SetName Doc1 ${aLabel1} SLabel - -set aSetX1 10 -set aSetY1 20 -set aSetZ1 30 -set aSetDX1 100 -set aSetDY1 200 -set aSetDZ1 300 - -box aBox1 ${aSetX1} ${aSetY1} ${aSetZ1} ${aSetDX1} ${aSetDY1} ${aSetDZ1} - -bounding aBox1 -save X1_Box1 Y1_Box1 Z1_Box1 X2_Box1 Y2_Box1 Z2_Box1 - -SetShape Doc1 ${aLabel1} aBox1 - -# Create a new label 'TLabel1' in Doc1 -set aLabel2 0:3 -Label Doc1 ${aLabel2} -SetName Doc1 ${aLabel2} TLabel1 - -# Open transaction in Doc1 -NewCommand Doc1 - -# Copy 'SLabel' to the label 'TLabel1' without link -Copy Doc1 ${aLabel2} Doc1 ${aLabel1} - -# Close/Open transaction -NewCommand Doc1 - -# Undo Doc1 -Undo Doc1 - -# Redo Doc1 -Redo Doc1 - -# Get a shape from 'TLabel1' -GetShape Doc1 ${aLabel2} aBox2 - -bounding aBox2 -save X1_Box2 Y1_Box2 Z1_Box2 X2_Box2 Y2_Box2 Z2_Box2 - -if { [dval X1_Box1] != [dval X1_Box2] || - [dval Y1_Box1] != [dval Y1_Box2] || - [dval Z1_Box1] != [dval Z1_Box2] || - [dval X2_Box1] != [dval X2_Box2] || - [dval Y2_Box1] != [dval Y2_Box2] || - [dval Z2_Box1] != [dval Z2_Box2] } { - puts "X1_Box1=[dval X1_Box1] X1_Box2=[dval X1_Box2]" - puts "Y1_Box1=[dval Y1_Box1] Y1_Box2=[dval Y1_Box2]" - puts "Z1_Box1=[dval Z1_Box1] Z1_Box2=[dval Z1_Box2]" - puts "X2_Box1=[dval X2_Box1] X2_Box2=[dval X2_Box2]" - puts "Y2_Box1=[dval Y2_Box1] Y2_Box2=[dval Y2_Box2]" - puts "Z2_Box1=[dval Z2_Box1] Z2_Box2=[dval Z2_Box2]" - puts "Copy attributes of the same document: Error" - return -} - -puts "Copy attributes of the same document: OK" diff --git a/tests/caf/xlink/A2 b/tests/caf/xlink/A2 deleted file mode 100755 index 53539ae27a..0000000000 --- a/tests/caf/xlink/A2 +++ /dev/null @@ -1,78 +0,0 @@ -#INTERFACE CAF -# XLink attributes -# -# Testing attribute: TDocStd_XLink -# -# Testing command: Copy -# - -puts "caf004-A2" - -# Create two new documents Doc1, Doc2 -NewDocument Doc1 BinOcaf -NewDocument Doc2 BinOcaf - -# Set UndoLimit for them -UndoLimit Doc1 100 -UndoLimit Doc2 100 - -# Set a shape in Doc1 to label 'SLabel' -set aLabel1 0:2 -Label Doc1 ${aLabel1} -SetName Doc1 ${aLabel1} SLabel - -set aSetX1 10 -set aSetY1 20 -set aSetZ1 30 -set aSetDX1 100 -set aSetDY1 200 -set aSetDZ1 300 - -box aBox1 ${aSetX1} ${aSetY1} ${aSetZ1} ${aSetDX1} ${aSetDY1} ${aSetDZ1} - -bounding aBox1 -save X1_Box1 Y1_Box1 Z1_Box1 X2_Box1 Y2_Box1 Z2_Box1 - -SetShape Doc1 ${aLabel1} aBox1 - -# Create a new label 'TLabel1' in Doc2 -set aLabel2 0:3 -Label Doc2 ${aLabel2} -SetName Doc2 ${aLabel2} TLabel1 - -# Open transaction in Doc2 -NewCommand Doc2 - -# Copy 'SLabel' to the label 'TLabel1' without link -Copy Doc2 ${aLabel2} Doc1 ${aLabel1} - -# Close/Open transaction in Doc2 -NewCommand Doc2 - -# Undo Doc2 -Undo Doc2 - -# Redo Doc2 -Redo Doc2 - -# Get a shape from 'TLabel1' -GetShape Doc2 ${aLabel2} aBox2 - -bounding aBox2 -save X1_Box2 Y1_Box2 Z1_Box2 X2_Box2 Y2_Box2 Z2_Box2 - -if { [dval X1_Box1] != [dval X1_Box2] || - [dval Y1_Box1] != [dval Y1_Box2] || - [dval Z1_Box1] != [dval Z1_Box2] || - [dval X2_Box1] != [dval X2_Box2] || - [dval Y2_Box1] != [dval Y2_Box2] || - [dval Z2_Box1] != [dval Z2_Box2] } { - puts "X1_Box1=[dval X1_Box1] X1_Box2=[dval X1_Box2]" - puts "Y1_Box1=[dval Y1_Box1] Y1_Box2=[dval Y1_Box2]" - puts "Z1_Box1=[dval Z1_Box1] Z1_Box2=[dval Z1_Box2]" - puts "X2_Box1=[dval X2_Box1] X2_Box2=[dval X2_Box2]" - puts "Y2_Box1=[dval Y2_Box1] Y2_Box2=[dval Y2_Box2]" - puts "Z2_Box1=[dval Z2_Box1] Z2_Box2=[dval Z2_Box2]" - puts "Copy attributes to another document: Error" - return -} - -puts "Copy attributes to another document: OK" diff --git a/tests/caf/xlink/B1 b/tests/caf/xlink/B1 deleted file mode 100755 index 728d94766f..0000000000 --- a/tests/caf/xlink/B1 +++ /dev/null @@ -1,78 +0,0 @@ -#INTERFACE CAF -# XLink attributes -# -# Testing attribute: TDocStd_XLink -# -# Testing command: CopyWithLink -# - -puts "caf004-B1" - -# Create two new documents Doc1, Doc2 -NewDocument Doc1 BinOcaf -NewDocument Doc2 BinOcaf - -# Set UndoLimit for them -UndoLimit Doc1 100 -UndoLimit Doc2 100 - -# Set a shape in Doc1 to label 'SLabel' -set aLabel1 0:2 -Label Doc1 ${aLabel1} -SetName Doc1 ${aLabel1} SLabel - -set aSetX1 10 -set aSetY1 20 -set aSetZ1 30 -set aSetDX1 100 -set aSetDY1 200 -set aSetDZ1 300 - -box aBox1 ${aSetX1} ${aSetY1} ${aSetZ1} ${aSetDX1} ${aSetDY1} ${aSetDZ1} - -bounding aBox1 -save X1_Box1 Y1_Box1 Z1_Box1 X2_Box1 Y2_Box1 Z2_Box1 - -SetShape Doc1 ${aLabel1} aBox1 - -# Create a new label 'TLabel1' in Doc1 -set aLabel2 0:3 -Label Doc1 ${aLabel2} -SetName Doc1 ${aLabel2} TLabel1 - -# Open transaction in Doc1 -NewCommand Doc1 - -# Copy 'SLabel' to the label 'TLabel1' with link -CopyWithLink Doc1 ${aLabel2} Doc1 ${aLabel1} - -# Close/Open transaction -NewCommand Doc1 - -# Undo Doc1 -Undo Doc1 - -# Redo Doc1 -Redo Doc1 - -# Get a shape from 'TLabel1' -GetShape Doc1 ${aLabel2} aBox2 - -bounding aBox2 -save X1_Box2 Y1_Box2 Z1_Box2 X2_Box2 Y2_Box2 Z2_Box2 - -if { [dval X1_Box1] != [dval X1_Box2] || - [dval Y1_Box1] != [dval Y1_Box2] || - [dval Z1_Box1] != [dval Z1_Box2] || - [dval X2_Box1] != [dval X2_Box2] || - [dval Y2_Box1] != [dval Y2_Box2] || - [dval Z2_Box1] != [dval Z2_Box2] } { - puts "X1_Box1=[dval X1_Box1] X1_Box2=[dval X1_Box2]" - puts "Y1_Box1=[dval Y1_Box1] Y1_Box2=[dval Y1_Box2]" - puts "Z1_Box1=[dval Z1_Box1] Z1_Box2=[dval Z1_Box2]" - puts "X2_Box1=[dval X2_Box1] X2_Box2=[dval X2_Box2]" - puts "Y2_Box1=[dval Y2_Box1] Y2_Box2=[dval Y2_Box2]" - puts "Z2_Box1=[dval Z2_Box1] Z2_Box2=[dval Z2_Box2]" - puts "Set a link between attributes of the same document: Error" - return -} - -puts "Set a link between attributes of the same document: OK" diff --git a/tests/caf/xlink/B2 b/tests/caf/xlink/B2 deleted file mode 100755 index e39cabddcf..0000000000 --- a/tests/caf/xlink/B2 +++ /dev/null @@ -1,83 +0,0 @@ -#INTERFACE CAF -# XLink attributes -# -# Testing attribute: TDocStd_XLink -# -# Testing command: CopyWithLink -# - -puts "caf004-B2" - -# Create two new documents Doc1, Doc2 -NewDocument Doc1 BinOcaf -NewDocument Doc2 BinOcaf - -# Set UndoLimit for them -UndoLimit Doc1 100 -UndoLimit Doc2 100 - -# Set a shape in Doc1 to label 'SLabel' -set aLabel1 0:2 -Label Doc1 ${aLabel1} -SetName Doc1 ${aLabel1} SLabel - -set aSetX1 10 -set aSetY1 20 -set aSetZ1 30 -set aSetDX1 100 -set aSetDY1 200 -set aSetDZ1 300 - -box aBox1 ${aSetX1} ${aSetY1} ${aSetZ1} ${aSetDX1} ${aSetDY1} ${aSetDZ1} - -bounding aBox1 -save X1_Box1 Y1_Box1 Z1_Box1 X2_Box1 Y2_Box1 Z2_Box1 - -SetShape Doc1 ${aLabel1} aBox1 - -# Create a new label 'TLabel1' in Doc1 -set aLabel2 0:3 -Label Doc1 ${aLabel2} -SetName Doc1 ${aLabel2} TLabel1 - -# Open transaction in Doc1 -NewCommand Doc1 - -# Copy 'SLabel' to the label 'TLabel1' with link -CopyWithLink Doc1 ${aLabel2} Doc1 ${aLabel1} - -# Close/Open transaction -NewCommand Doc1 - -# Set new shape in Doc1 to label 'SLabel' -set aRadius 60 -psphere aSphere ${aRadius} -SetShape Doc1 ${aLabel1} aSphere - -# Undo Doc1 -Undo Doc1 - -# Redo Doc1 -Redo Doc1 - -# Get a shape from 'TLabel1' -GetShape Doc1 ${aLabel2} aBox2 - -bounding aBox2 -save X1_Box2 Y1_Box2 Z1_Box2 X2_Box2 Y2_Box2 Z2_Box2 - -if { [dval X1_Box1] != [dval X1_Box2] || - [dval Y1_Box1] != [dval Y1_Box2] || - [dval Z1_Box1] != [dval Z1_Box2] || - [dval X2_Box1] != [dval X2_Box2] || - [dval Y2_Box1] != [dval Y2_Box2] || - [dval Z2_Box1] != [dval Z2_Box2] } { - puts "X1_Box1=[dval X1_Box1] X1_Box2=[dval X1_Box2]" - puts "Y1_Box1=[dval Y1_Box1] Y1_Box2=[dval Y1_Box2]" - puts "Z1_Box1=[dval Z1_Box1] Z1_Box2=[dval Z1_Box2]" - puts "X2_Box1=[dval X2_Box1] X2_Box2=[dval X2_Box2]" - puts "Y2_Box1=[dval Y2_Box1] Y2_Box2=[dval Y2_Box2]" - puts "Z2_Box1=[dval Z2_Box1] Z2_Box2=[dval Z2_Box2]" - puts "Set a link between attributes of the same document: Error" - return -} - -puts "Set a link between attributes of the same document: OK" diff --git a/tests/caf/xlink/B3 b/tests/caf/xlink/B3 deleted file mode 100755 index 00925d4aaf..0000000000 --- a/tests/caf/xlink/B3 +++ /dev/null @@ -1,91 +0,0 @@ -#INTERFACE CAF -# XLink attributes -# -# Testing attribute: TDocStd_XLink -# -# Testing command: CopyWithLink -# - -puts "caf004-B3" - -# Create two new documents Doc1, Doc2 -NewDocument Doc1 BinOcaf -NewDocument Doc2 BinOcaf - -# Set UndoLimit for them -UndoLimit Doc1 100 -UndoLimit Doc2 100 - -# Set a shape in Doc1 to label 'SLabel' -set aLabel1 0:2 -Label Doc1 ${aLabel1} -SetName Doc1 ${aLabel1} SLabel - -set aSetX1 10 -set aSetY1 20 -set aSetZ1 30 -set aSetDX1 100 -set aSetDY1 200 -set aSetDZ1 300 - -box aBox1 ${aSetX1} ${aSetY1} ${aSetZ1} ${aSetDX1} ${aSetDY1} ${aSetDZ1} - -bounding aBox1 -save X1_Box1 Y1_Box1 Z1_Box1 X2_Box1 Y2_Box1 Z2_Box1 - -SetShape Doc1 ${aLabel1} aBox1 - -# Create a new label 'TLabel1' in Doc1 -set aLabel2 0:3 -Label Doc1 ${aLabel2} -SetName Doc1 ${aLabel2} TLabel1 - -# Open transaction in Doc1 -NewCommand Doc1 - -# Copy 'SLabel' to the label 'TLabel1' with link -CopyWithLink Doc1 ${aLabel2} Doc1 ${aLabel1} - -# Close/Open transaction -NewCommand Doc1 - -# Save the document -set aFile ${imagedir}/caf004-B3.cbf -file delete ${aFile} -SaveAs Doc1 ${aFile} -if { ![file exists ${aFile}] } { - puts "There is not ${aFile} file; SaveAs command: Error" - return -} -#catch {exec chmod 777 ${aFile}} - -# Restore the document -Close Doc1 -Open ${aFile} Doc2 - -# Get a shape from 'TLabel1' of restoring document -set IsDone [catch {GetShape Doc2 ${aLabel2} aBox2} aResult] -if { ${IsDone} != 0 } { - puts ${aResult} - puts "Get a value of TNaming_NamedShape attribute from restoring document: Error" - return -} - -bounding aBox2 -save X1_Box2 Y1_Box2 Z1_Box2 X2_Box2 Y2_Box2 Z2_Box2 - -if { [dval X1_Box1] != [dval X1_Box2] || - [dval Y1_Box1] != [dval Y1_Box2] || - [dval Z1_Box1] != [dval Z1_Box2] || - [dval X2_Box1] != [dval X2_Box2] || - [dval Y2_Box1] != [dval Y2_Box2] || - [dval Z2_Box1] != [dval Z2_Box2] } { - puts "X1_Box1=[dval X1_Box1] X1_Box2=[dval X1_Box2]" - puts "Y1_Box1=[dval Y1_Box1] Y1_Box2=[dval Y1_Box2]" - puts "Z1_Box1=[dval Z1_Box1] Z1_Box2=[dval Z1_Box2]" - puts "X2_Box1=[dval X2_Box1] X2_Box2=[dval X2_Box2]" - puts "Y2_Box1=[dval Y2_Box1] Y2_Box2=[dval Y2_Box2]" - puts "Z2_Box1=[dval Z2_Box1] Z2_Box2=[dval Z2_Box2]" - puts "Get a link between attributes of the same document from restoring document: Error" - return -} - -puts "Get a link between attributes of the same document from restoring document: OK" diff --git a/tests/caf/xlink/B4 b/tests/caf/xlink/B4 deleted file mode 100755 index ff834a567e..0000000000 --- a/tests/caf/xlink/B4 +++ /dev/null @@ -1,78 +0,0 @@ -#INTERFACE CAF -# XLink attributes -# -# Testing attribute: TDocStd_XLink -# -# Testing command: CopyWithLink -# - -puts "caf004-B4" - -# Create two new documents Doc1, Doc2 -NewDocument Doc1 BinOcaf -NewDocument Doc2 BinOcaf - -# Set UndoLimit for them -UndoLimit Doc1 100 -UndoLimit Doc2 100 - -# Set a shape in Doc1 to label 'SLabel' -set aLabel1 0:2 -Label Doc1 ${aLabel1} -SetName Doc1 ${aLabel1} SLabel - -set aSetX1 10 -set aSetY1 20 -set aSetZ1 30 -set aSetDX1 100 -set aSetDY1 200 -set aSetDZ1 300 - -box aBox1 ${aSetX1} ${aSetY1} ${aSetZ1} ${aSetDX1} ${aSetDY1} ${aSetDZ1} - -bounding aBox1 -save X1_Box1 Y1_Box1 Z1_Box1 X2_Box1 Y2_Box1 Z2_Box1 - -SetShape Doc1 ${aLabel1} aBox1 - -# Create a new label 'TLabel1' in Doc2 -set aLabel2 0:3 -Label Doc2 ${aLabel2} -SetName Doc2 ${aLabel2} TLabel1 - -# Open transaction in Doc2 -NewCommand Doc2 - -# Copy 'SLabel' to the label 'TLabel1' with link -CopyWithLink Doc2 ${aLabel2} Doc1 ${aLabel1} - -# Close/Open transaction in Doc2 -NewCommand Doc2 - -# Undo Doc2 -Undo Doc2 - -# Redo Doc2 -Redo Doc2 - -# Get a shape from 'TLabel1' -GetShape Doc2 ${aLabel2} aBox2 - -bounding aBox2 -save X1_Box2 Y1_Box2 Z1_Box2 X2_Box2 Y2_Box2 Z2_Box2 - -if { [dval X1_Box1] != [dval X1_Box2] || - [dval Y1_Box1] != [dval Y1_Box2] || - [dval Z1_Box1] != [dval Z1_Box2] || - [dval X2_Box1] != [dval X2_Box2] || - [dval Y2_Box1] != [dval Y2_Box2] || - [dval Z2_Box1] != [dval Z2_Box2] } { - puts "X1_Box1=[dval X1_Box1] X1_Box2=[dval X1_Box2]" - puts "Y1_Box1=[dval Y1_Box1] Y1_Box2=[dval Y1_Box2]" - puts "Z1_Box1=[dval Z1_Box1] Z1_Box2=[dval Z1_Box2]" - puts "X2_Box1=[dval X2_Box1] X2_Box2=[dval X2_Box2]" - puts "Y2_Box1=[dval Y2_Box1] Y2_Box2=[dval Y2_Box2]" - puts "Z2_Box1=[dval Z2_Box1] Z2_Box2=[dval Z2_Box2]" - puts "Set a link between attributes of another document: Error" - return -} - -puts "Set a link between attributes of another document: OK" diff --git a/tests/caf/xlink/B5 b/tests/caf/xlink/B5 deleted file mode 100755 index 0e76b638fb..0000000000 --- a/tests/caf/xlink/B5 +++ /dev/null @@ -1,83 +0,0 @@ -#INTERFACE CAF -# XLink attributes -# -# Testing attribute: TDocStd_XLink -# -# Testing command: CopyWithLink -# - -puts "caf004-CIN001_b5.rle" - -# Create two new documents Doc1, Doc2 -NewDocument Doc1 BinOcaf -NewDocument Doc2 BinOcaf - -# Set UndoLimit for them -UndoLimit Doc1 100 -UndoLimit Doc2 100 - -# Set a shape in Doc1 to label 'SLabel' -set aLabel1 0:2 -Label Doc1 ${aLabel1} -SetName Doc1 ${aLabel1} SLabel - -set aSetX1 10 -set aSetY1 20 -set aSetZ1 30 -set aSetDX1 100 -set aSetDY1 200 -set aSetDZ1 300 - -box aBox1 ${aSetX1} ${aSetY1} ${aSetZ1} ${aSetDX1} ${aSetDY1} ${aSetDZ1} - -bounding aBox1 -save X1_Box1 Y1_Box1 Z1_Box1 X2_Box1 Y2_Box1 Z2_Box1 - -SetShape Doc1 ${aLabel1} aBox1 - -# Create a new label 'TLabel1' in Doc2 -set aLabel2 0:3 -Label Doc2 ${aLabel2} -SetName Doc2 ${aLabel2} TLabel1 - -# Open transaction in Doc2 -NewCommand Doc2 - -# Copy 'SLabel' to the label 'TLabel1' with link -CopyWithLink Doc2 ${aLabel2} Doc1 ${aLabel1} - -# Close/Open transaction -NewCommand Doc1 - -# Set new shape in Doc1 to label 'SLabel' -set aRadius 70 -psphere aSphere ${aRadius} -SetShape Doc1 ${aLabel1} aSphere - -# Undo Doc1 -Undo Doc1 - -# Redo Doc1 -Redo Doc1 - -# Get a shape from 'TLabel1' -GetShape Doc2 ${aLabel2} aBox2 - -bounding aBox2 -save X1_Box2 Y1_Box2 Z1_Box2 X2_Box2 Y2_Box2 Z2_Box2 - -if { [dval X1_Box1] != [dval X1_Box2] || - [dval Y1_Box1] != [dval Y1_Box2] || - [dval Z1_Box1] != [dval Z1_Box2] || - [dval X2_Box1] != [dval X2_Box2] || - [dval Y2_Box1] != [dval Y2_Box2] || - [dval Z2_Box1] != [dval Z2_Box2] } { - puts "X1_Box1=[dval X1_Box1] X1_Box2=[dval X1_Box2]" - puts "Y1_Box1=[dval Y1_Box1] Y1_Box2=[dval Y1_Box2]" - puts "Z1_Box1=[dval Z1_Box1] Z1_Box2=[dval Z1_Box2]" - puts "X2_Box1=[dval X2_Box1] X2_Box2=[dval X2_Box2]" - puts "Y2_Box1=[dval Y2_Box1] Y2_Box2=[dval Y2_Box2]" - puts "Z2_Box1=[dval Z2_Box1] Z2_Box2=[dval Z2_Box2]" - puts "Set a link between attributes of the same document: Error" - return -} - -puts "Set a link between attributes of the same document: OK" diff --git a/tests/caf/xlink/C1 b/tests/caf/xlink/C1 deleted file mode 100755 index 3e9fa5355f..0000000000 --- a/tests/caf/xlink/C1 +++ /dev/null @@ -1,89 +0,0 @@ -#INTERFACE CAF -# XLink attributes -# -# Testing attribute: TDocStd_XLink -# -# Testing command: UpdateXLinks -# - -puts "caf004-C1" - -# 1. Create two new documents Doc1, Doc2 -NewDocument Doc1 BinOcaf -NewDocument Doc2 BinOcaf - -# 2. Set UndoLimit for them -UndoLimit Doc1 100 -UndoLimit Doc2 100 - -# 3. Set a shape in Doc1 to label 'SLabel' -set aLabel1 0:2 -Label Doc1 ${aLabel1} -SetName Doc1 ${aLabel1} SLabel - -set aSetX1 10 -set aSetY1 20 -set aSetZ1 30 -set aSetDX1 100 -set aSetDY1 200 -set aSetDZ1 300 - -box aBox1 ${aSetX1} ${aSetY1} ${aSetZ1} ${aSetDX1} ${aSetDY1} ${aSetDZ1} - -bounding aBox1 -save X1_Box1 Y1_Box1 Z1_Box1 X2_Box1 Y2_Box1 Z2_Box1 - -SetShape Doc1 ${aLabel1} aBox1 - -# 4. Create a new label 'TLabel1' in Doc1 -set aLabel2 0:3 -Label Doc1 ${aLabel2} -SetName Doc1 ${aLabel2} TLabel1 - -# 5. Open transaction in Doc1 -NewCommand Doc1 - -# 6. Copy 'SLabel' to the label 'TLabel1' with link -CopyWithLink Doc1 ${aLabel2} Doc1 ${aLabel1} - -# 7. Close/Open transaction -NewCommand Doc1 - -# 8. Set new shape in Doc1 to label 'SLabel' -set aRadius 70 -psphere aSphere ${aRadius} -SetShape Doc1 ${aLabel2} aSphere - -# 10. Update link in Doc1 -UpdateXLinks Doc1 ${aLabel2} - -# 7. Close/Open transaction -NewCommand Doc1 - -# 9. Undo Doc1 -Undo Doc1 - -# 10. Redo Doc1 -Redo Doc1 - -# 11. Get a shape from 'TLabel1' -GetShape Doc1 ${aLabel2} aBox2 - -bounding aBox2 -save X1_Box2 Y1_Box2 Z1_Box2 X2_Box2 Y2_Box2 Z2_Box2 - -if { [dval X1_Box1] == [dval X1_Box2] || - [dval Y1_Box1] == [dval Y1_Box2] || - [dval Z1_Box1] == [dval Z1_Box2] || - [dval X2_Box1] == [dval X2_Box2] || - [dval Y2_Box1] == [dval Y2_Box2] || - [dval Z2_Box1] == [dval Z2_Box2] } { - puts "X1_Box1=[dval X1_Box1] X1_Box2=[dval X1_Box2]" - puts "Y1_Box1=[dval Y1_Box1] Y1_Box2=[dval Y1_Box2]" - puts "Z1_Box1=[dval Z1_Box1] Z1_Box2=[dval Z1_Box2]" - puts "X2_Box1=[dval X2_Box1] X2_Box2=[dval X2_Box2]" - puts "Y2_Box1=[dval Y2_Box1] Y2_Box2=[dval Y2_Box2]" - puts "Z2_Box1=[dval Z2_Box1] Z2_Box2=[dval Z2_Box2]" - puts "Updating a link between attributes of the same document: Error" - return -} - -puts "Updating a link between attributes of the same document: OK" diff --git a/tests/caf/xlink/D1 b/tests/caf/xlink/D1 deleted file mode 100755 index ea3f1da4aa..0000000000 --- a/tests/caf/xlink/D1 +++ /dev/null @@ -1,89 +0,0 @@ -#INTERFACE CAF -# XLink attributes -# -# Testing attribute: TDocStd_XLink -# -# Testing command: UpdateLink -# - -puts "caf004-D1" - -# Create two new documents Doc1, Doc2 -NewDocument Doc1 BinOcaf -NewDocument Doc2 BinOcaf - -# Set UndoLimit for them -UndoLimit Doc1 100 -UndoLimit Doc2 100 - -# Set a shape in Doc1 to label 'SLabel' -set aLabel1 0:2 -Label Doc1 ${aLabel1} -SetName Doc1 ${aLabel1} SLabel - -set aSetX1 10 -set aSetY1 20 -set aSetZ1 30 -set aSetDX1 100 -set aSetDY1 200 -set aSetDZ1 300 - -box aBox1 ${aSetX1} ${aSetY1} ${aSetZ1} ${aSetDX1} ${aSetDY1} ${aSetDZ1} - -bounding aBox1 -save X1_Box1 Y1_Box1 Z1_Box1 X2_Box1 Y2_Box1 Z2_Box1 - -SetShape Doc1 ${aLabel1} aBox1 - -# Create a new label 'TLabel1' in Doc2 -set aLabel2 0:3 -Label Doc2 ${aLabel2} -SetName Doc2 ${aLabel2} TLabel1 - -# Open transaction in Doc2 -NewCommand Doc2 - -# Copy 'SLabel' to the label 'TLabel1' with link -CopyWithLink Doc2 ${aLabel2} Doc1 ${aLabel1} - -# Close/Open transaction in Doc2 -NewCommand Doc2 - -# Set new shape in Doc1 to label 'SLabel' -set aRadius 70 -psphere aSphere ${aRadius} -SetShape Doc1 ${aLabel1} aSphere - -# Update link in Doc2 -UpdateLink Doc2 ${aLabel2} - -# Close/Open transaction in Doc2 -NewCommand Doc2 - -# Undo Doc2 -Undo Doc2 - -# Redo Doc2 -Redo Doc2 - -# Get a shape from 'TLabel1' -GetShape Doc2 ${aLabel2} aBox2 - -bounding aBox2 -save X1_Box2 Y1_Box2 Z1_Box2 X2_Box2 Y2_Box2 Z2_Box2 - -if { [dval X1_Box1] == [dval X1_Box2] || - [dval Y1_Box1] == [dval Y1_Box2] || - [dval Z1_Box1] == [dval Z1_Box2] || - [dval X2_Box1] == [dval X2_Box2] || - [dval Y2_Box1] == [dval Y2_Box2] || - [dval Z2_Box1] == [dval Z2_Box2] } { - puts "X1_Box1=[dval X1_Box1] X1_Box2=[dval X1_Box2]" - puts "Y1_Box1=[dval Y1_Box1] Y1_Box2=[dval Y1_Box2]" - puts "Z1_Box1=[dval Z1_Box1] Z1_Box2=[dval Z1_Box2]" - puts "X2_Box1=[dval X2_Box1] X2_Box2=[dval X2_Box2]" - puts "Y2_Box1=[dval Y2_Box1] Y2_Box2=[dval Y2_Box2]" - puts "Z2_Box1=[dval Z2_Box1] Z2_Box2=[dval Z2_Box2]" - puts "Updating a link between attributes of the same document: Error" - return -} - -puts "Updating a link between attributes of the same document: OK" diff --git a/tests/caf/xlink/D2 b/tests/caf/xlink/D2 deleted file mode 100755 index 5a574c9ab3..0000000000 --- a/tests/caf/xlink/D2 +++ /dev/null @@ -1,138 +0,0 @@ -#INTERFACE CAF -# XLink attributes -# -# Testing attribute: TDocStd_XLink -# -# Testing command: UpdateLink -# - -puts "caf004-D2" - -# Create two new documents Doc1, Doc2 -NewDocument Doc1 BinOcaf -NewDocument Doc2 BinOcaf - -# Set UndoLimit for them -UndoLimit Doc1 100 -UndoLimit Doc2 100 - -# Set a shape in Doc1 to label 'SLabel' -set aLabel1 0:2 -Label Doc1 ${aLabel1} -SetName Doc1 ${aLabel1} SLabel - -set aSetX1 10 -set aSetY1 20 -set aSetZ1 30 -set aSetDX1 100 -set aSetDY1 200 -set aSetDZ1 300 - -box aBox1 ${aSetX1} ${aSetY1} ${aSetZ1} ${aSetDX1} ${aSetDY1} ${aSetDZ1} - -bounding aBox1 -save X1_Box1 Y1_Box1 Z1_Box1 X2_Box1 Y2_Box1 Z2_Box1 - -SetShape Doc1 ${aLabel1} aBox1 - -# Set a shape in Doc1 to label 'S2Label' -set aLabel12 0:22 -Label Doc1 ${aLabel12} -SetName Doc1 ${aLabel12} S2Label - -set aSetX12 210 -set aSetY12 220 -set aSetZ12 230 -set aSetDX12 2100 -set aSetDY12 2200 -set aSetDZ12 2300 - -box aBox12 ${aSetX12} ${aSetY12} ${aSetZ12} ${aSetDX12} ${aSetDY12} ${aSetDZ12} - -bounding aBox12 -save X1_Box12 Y1_Box12 Z1_Box12 X2_Box12 Y2_Box12 Z2_Box12 - -SetShape Doc1 ${aLabel12} aBox12 - -# Create a new label 'TLabel1' in Doc2 -set aLabel2 0:3 -Label Doc2 ${aLabel2} -SetName Doc2 ${aLabel2} TLabel1 - -# Create a new label 'T2Label1' in Doc2 -set aLabel22 0:32 -Label Doc2 ${aLabel22} -SetName Doc2 ${aLabel22} T2Label1 - -# Open transaction in Doc2 -NewCommand Doc2 - -# Copy 'SLabel' to the label 'TLabel1' with link -CopyWithLink Doc2 ${aLabel2} Doc1 ${aLabel1} - -# Copy 'S2Label' to the label 'T2Label1' with link -CopyWithLink Doc2 ${aLabel22} Doc1 ${aLabel12} - -# Close/Open transaction in Doc2 -NewCommand Doc2 - -# Set new shape in Doc1 to label 'SLabel' -set aRadius 70 -psphere aSphere ${aRadius} -SetShape Doc1 ${aLabel1} aSphere - -# Set new shape in Doc1 to label 'SLabel' -set aRadius 270 -psphere aSphere ${aRadius} -SetShape Doc1 ${aLabel12} aSphere - -# Update all links in Doc2 -UpdateLink Doc2 - -# Close/Open transaction in Doc2 -NewCommand Doc2 - -# Undo Doc2 -Undo Doc2 - -# Redo Doc2 -Redo Doc2 - -# Get a shape from 'TLabel1' -GetShape Doc2 ${aLabel2} aBox2 - -bounding aBox2 -save X1_Box2 Y1_Box2 Z1_Box2 X2_Box2 Y2_Box2 Z2_Box2 - -# Get a shape from 'T2Label1' -GetShape Doc2 ${aLabel22} aBox22 - -bounding aBox22 -save X1_Box22 Y1_Box22 Z1_Box22 X2_Box22 Y2_Box22 Z2_Box22 - -if { [dval X1_Box1] == [dval X1_Box2] || - [dval Y1_Box1] == [dval Y1_Box2] || - [dval Z1_Box1] == [dval Z1_Box2] || - [dval X2_Box1] == [dval X2_Box2] || - [dval Y2_Box1] == [dval Y2_Box2] || - [dval Z2_Box1] == [dval Z2_Box2] || - - [dval X1_Box12] == [dval X1_Box22] || - [dval Y1_Box12] == [dval Y1_Box22] || - [dval Z1_Box12] == [dval Z1_Box22] || - [dval X2_Box12] == [dval X2_Box22] || - [dval Y2_Box12] == [dval Y2_Box22] || - [dval Z2_Box12] == [dval Z2_Box22] || - - [dval X1_Box2] == [dval X1_Box22] || - [dval Y1_Box2] == [dval Y1_Box22] || - [dval Z1_Box2] == [dval Z1_Box22] || - [dval X2_Box2] == [dval X2_Box22] || - [dval Y2_Box2] == [dval Y2_Box22] || - [dval Z2_Box2] == [dval Z2_Box22] } { - - puts "X1_Box1=[dval X1_Box1] Y1_Box1=[dval Y1_Box1] Z1_Box1=[dval Z1_Box1] X2_Box1=[dval X2_Box1] Y2_Box1=[dval Y2_Box1] Z2_Box1=[dval Z2_Box1]" - puts "X1_Box2=[dval X1_Box2] Y1_Box2=[dval Y1_Box2] Z1_Box2=[dval Z1_Box2] X2_Box2=[dval X2_Box2] Y2_Box2=[dval Y2_Box2] Z2_Box2=[dval Z2_Box2]" - puts "X1_Box12=[dval X1_Box12] Y1_Box12=[dval Y1_Box12] Z1_Box12=[dval Z1_Box12] X2_Box12=[dval X2_Box12] Y2_Box12=[dval Y2_Box12] Z2_Box12=[dval Z2_Box12]" - puts "X1_Box22=[dval X1_Box22] Y1_Box22=[dval Y1_Box22] Z1_Box22=[dval Z1_Box22] X2_Box22=[dval X2_Box22] Y2_Box22=[dval Y2_Box22] Z2_Box22=[dval Z2_Box22]" - puts "Updating all links between attributes of the same document: Error" - return -} - -puts "Updating all links between attributes of the same document: OK" diff --git a/tests/cr/approx/A1 b/tests/cr/approx/A1 deleted file mode 100644 index f449dafb29..0000000000 --- a/tests/cr/approx/A1 +++ /dev/null @@ -1,12 +0,0 @@ -polyline w 0 0 0 1 0 0 1 1 0 0 1 0 0 0 0 -getanasurf res w pln 1.e-3 -if {[isdraw res]} { - set log [dump res] - if { [regexp {Plane} $log ] != 1 } { - puts "Error: surface is not a plane" - } -} else { - puts "Error: required surface is not got" -} - - diff --git a/tests/cr/approx/A2 b/tests/cr/approx/A2 deleted file mode 100644 index 5ac2f8f5c0..0000000000 --- a/tests/cr/approx/A2 +++ /dev/null @@ -1,15 +0,0 @@ -cylinder cyl 0 0 0 1 1 1 1 -mkface f cyl 0 2 0 1 -explode f w -nurbsconvert w f_1 -cylinder cyl 0.1 0.1 0.1 1 1 1 .9 -getanasurf res w cyl 1.e-3 cyl -if {[isdraw res]} { - set log [dump res] - if { [regexp {CylindricalSurface} $log ] != 1 } { - puts "Error: surface is not a cylindrical surface" - } -} else { - puts "Error: required surface is not got" -} - diff --git a/tests/cr/approx/A3 b/tests/cr/approx/A3 deleted file mode 100644 index f59b3c6305..0000000000 --- a/tests/cr/approx/A3 +++ /dev/null @@ -1,15 +0,0 @@ -plane pl 0 0 0 1 1 1 -pcone con pl 2 1 3 60 -explode con w -nurbsconvert w con_1 -cone con 0.1 .1 .1 1 1 1 -17 1.9 -getanasurf res w con 1.e-3 con -if {[isdraw res]} { - set log [dump res] - if { [regexp {ConicalSurface} $log ] != 1 } { - puts "Error: surface is not a conical surface" - } -} else { - puts "Error: required surface is not got" -} - diff --git a/tests/cr/approx/A4 b/tests/cr/approx/A4 deleted file mode 100644 index d1c3384f30..0000000000 --- a/tests/cr/approx/A4 +++ /dev/null @@ -1,16 +0,0 @@ -sphere sph 1 -mkface f sph 0 2 0 pi/2 -explode f w -nurbsconvert w f_1 -sphere sph 0.1 0.1 0.1 1 -getanasurf res w sph 1.e-3 sph -if {[isdraw res]} { - set log [dump res] - if { [regexp {SphericalSurface} $log ] != 1 } { - puts "Error: surface is not a spherical surface" - } -} else { - puts "Error: required surface is not got" -} - - diff --git a/tests/cr/base/A1 b/tests/cr/base/A1 deleted file mode 100644 index 4de2c8d7bb..0000000000 --- a/tests/cr/base/A1 +++ /dev/null @@ -1,13 +0,0 @@ -beziercurve bz 3 0 0 0 .5 .5e-3 0 1 0 0 -mkedge e bz -getanacurve c e lin 1.e-3 -if {[isdraw c]} { - set log [dump c] - if { [regexp {Line} $log ] != 1 } { - puts "Error: curve is not a line" - } -} else { - puts "Error: required curve is not got" -} - - diff --git a/tests/cr/base/A2 b/tests/cr/base/A2 deleted file mode 100644 index 5f66a23ee4..0000000000 --- a/tests/cr/base/A2 +++ /dev/null @@ -1,12 +0,0 @@ -beziercurve bz 3 0 0 0 .5 .5e-3 0 1 0 0 -mkedge e bz -getanacurve c e cir 1.e-3 -if {[isdraw c]} { - set log [dump c] - if { [regexp {Circle} $log ] != 1 } { - puts "Error: curve is not a circle" - } -} else { - puts "Error: required curve is not got" -} - diff --git a/tests/cr/base/A3 b/tests/cr/base/A3 deleted file mode 100644 index 97d6e1ec5d..0000000000 --- a/tests/cr/base/A3 +++ /dev/null @@ -1,13 +0,0 @@ -ellipse bz 0 0 0 0 0 1 1 .5 -convert bz bz -mkedge e bz -getanacurve c e ell 1.e-7 -if {[isdraw c]} { - set log [dump c] - if { [regexp {Ellipse} $log ] != 1 } { - puts "Error: curve is not an ellipse" - } -} else { - puts "Error: required curve is not got" -} - diff --git a/tests/cr/base/A4 b/tests/cr/base/A4 deleted file mode 100644 index 76c26f34b4..0000000000 --- a/tests/cr/base/A4 +++ /dev/null @@ -1,15 +0,0 @@ -beziercurve bz 3 0 0 0 .5 .5e-6 0 1 0 0 -mkedge e1 bz 0 .3 -mkedge e2 bz .3 0.7 -mkedge e3 bz .7 1. -wire w e1 e2 e3 -getanacurve c w lin 1.e-3 -if {[isdraw c]} { - set log [dump c] - if { [regexp {Line} $log ] != 1 } { - puts "Error: curve is not a line" - } -} else { - puts "Error: required curve is not got" -} - diff --git a/tests/cr/base/A5 b/tests/cr/base/A5 deleted file mode 100644 index 7323a6221a..0000000000 --- a/tests/cr/base/A5 +++ /dev/null @@ -1,15 +0,0 @@ -circle bz 0 0 0 0 0 1 1 -convert bz bz -mkedge e1 bz 0 1 -mkedge e2 bz 1 2.5 -mkedge e3 bz 2.5 6 -wire w e1 e2 e3 -getanacurve c w cir 1.e-7 -if {[isdraw c]} { - set log [dump c] - if { [regexp {Circle} $log ] != 1 } { - puts "Error: curve is not a circle" - } -} else { - puts "Error: required curve is not got" -} diff --git a/tests/cr/base/A6 b/tests/cr/base/A6 deleted file mode 100644 index dabfd08c3e..0000000000 --- a/tests/cr/base/A6 +++ /dev/null @@ -1,15 +0,0 @@ -ellipse bz 0 0 0 0 0 1 1 .5 -convert bz bz -mkedge e1 bz 0 1 -mkedge e2 bz 1 2.5 -mkedge e3 bz 2.5 6 -wire w e1 e2 e3 -getanacurve c w ell 1.e-7 -if {[isdraw c]} { - set log [dump c] - if { [regexp {Ellipse} $log ] != 1 } { - puts "Error: curve is not an ellipse" - } -} else { - puts "Error: required curve is not got" -} diff --git a/tests/cr/base/B1 b/tests/cr/base/B1 deleted file mode 100644 index 87498c8809..0000000000 --- a/tests/cr/base/B1 +++ /dev/null @@ -1,15 +0,0 @@ -plane surf -trim surf surf -1 1 -1 1 -convert surf surf -mkface f surf -getanasurf asurf f pln 1.e-7 -if {[isdraw asurf]} { - set log [dump asurf] - if { [regexp {Plane} $log ] != 1 } { - puts "Error: surface is not a plane" - } -} else { - puts "Error: required surface is not got" -} - - diff --git a/tests/cr/base/B10 b/tests/cr/base/B10 deleted file mode 100644 index b890b67b29..0000000000 --- a/tests/cr/base/B10 +++ /dev/null @@ -1,18 +0,0 @@ -cylinder surf 1 -trimv surf surf -10 10 -plane pp 0 0 0 1 0 1 -intersect ii surf pp -extsurf surf ii 0 0 1 -trimv surf surf -1 1 -convert surf surf -mkface f surf -getanasurf asurf f cyl 1.e-7 -if {[isdraw asurf]} { - set log [dump asurf] - if { [regexp {CylindricalSurface} $log ] != 1 } { - puts "Error: surface is not a cylindrical surface" - } -} else { - puts "Error: required surface is not got" -} - diff --git a/tests/cr/base/B2 b/tests/cr/base/B2 deleted file mode 100644 index 312e25ab4b..0000000000 --- a/tests/cr/base/B2 +++ /dev/null @@ -1,14 +0,0 @@ -cylinder surf 1 -trimv surf surf -1 1 -convert surf surf -mkface f surf -getanasurf asurf f cyl 1.e-7 -if {[isdraw asurf]} { - set log [dump asurf] - if { [regexp {CylindricalSurface} $log ] != 1 } { - puts "Error: surface is not a cylindrical surface" - } -} else { - puts "Error: required surface is not got" -} - diff --git a/tests/cr/base/B3 b/tests/cr/base/B3 deleted file mode 100644 index ce1e30b4b1..0000000000 --- a/tests/cr/base/B3 +++ /dev/null @@ -1,13 +0,0 @@ -cone surf 30 0 -trimv surf surf -1 0 -convert surf surf -mkface f surf -getanasurf asurf f con 1.e-7 -if {[isdraw asurf]} { - set log [dump asurf] - if { [regexp {ConicalSurface} $log ] != 1 } { - puts "Error: surface is not a conical surface" - } -} else { - puts "Error: required surface is not got" -} diff --git a/tests/cr/base/B4 b/tests/cr/base/B4 deleted file mode 100644 index 7259721402..0000000000 --- a/tests/cr/base/B4 +++ /dev/null @@ -1,12 +0,0 @@ -sphere surf 1 -convert surf surf -mkface f surf -getanasurf asurf f sph 1.e-7 -if {[isdraw asurf]} { - set log [dump asurf] - if { [regexp {SphericalSurface} $log ] != 1 } { - puts "Error: surface is not a spherical surface" - } -} else { - puts "Error: required surface is not got" -} diff --git a/tests/cr/base/B5 b/tests/cr/base/B5 deleted file mode 100644 index 58c4d5b223..0000000000 --- a/tests/cr/base/B5 +++ /dev/null @@ -1,25 +0,0 @@ -plane surf -trim surf1 surf -1 0 -1 0 -convert surf1 surf1 -mkface f1 surf1 -trim surf2 surf -1 0 0 1 -convert surf2 surf2 -mkface f2 surf2 -trim surf3 surf 0 1 0 1 -convert surf3 surf3 -mkface f3 surf3 -trim surf4 surf 0 1 -1 0 -convert surf4 surf4 -mkface f4 surf4 -sewing sh f1 f2 f3 f4 -getanasurf asurf sh pln 1.e-7 -if {[isdraw asurf]} { - set log [dump asurf] - if { [regexp {Plane} $log ] != 1 } { - puts "Error: surface is not a plane" - } -} else { - puts "Error: required surface is not got" -} - - diff --git a/tests/cr/base/B6 b/tests/cr/base/B6 deleted file mode 100644 index db670f3a5d..0000000000 --- a/tests/cr/base/B6 +++ /dev/null @@ -1,25 +0,0 @@ -cylinder surf 1 -trim surf1 surf 0 3 -1 0 -convert surf1 surf1 -mkface f1 surf1 -trim surf2 surf 0 3 0 1 -convert surf2 surf2 -mkface f2 surf2 -trim surf3 surf 3 6 0 1 -convert surf3 surf3 -mkface f3 surf3 -trim surf4 surf 3 6 -1 0 -convert surf4 surf4 -mkface f4 surf4 -sewing sh f1 f2 f3 f4 -getanasurf asurf sh cyl 1.e-7 -if {[isdraw asurf]} { - set log [dump asurf] - if { [regexp {CylindricalSurface} $log ] != 1 } { - puts "Error: surface is not a cylindrical surface" - } -} else { - puts "Error: required surface is not got" -} - - diff --git a/tests/cr/base/B7 b/tests/cr/base/B7 deleted file mode 100644 index 2c2d5f2fc4..0000000000 --- a/tests/cr/base/B7 +++ /dev/null @@ -1,25 +0,0 @@ -cone surf 30 0 -trim surf1 surf 0 3 0 1 -convert surf1 surf1 -mkface f1 surf1 -trim surf2 surf 0 3 1 2 -convert surf2 surf2 -mkface f2 surf2 -trim surf3 surf 3 6 1 2 -convert surf3 surf3 -mkface f3 surf3 -trim surf4 surf 3 6 0 1 -convert surf4 surf4 -mkface f4 surf4 -sewing sh f1 f2 f3 f4 -getanasurf asurf sh con 1.e-7 -if {[isdraw asurf]} { - set log [dump asurf] - if { [regexp {ConicalSurface} $log ] != 1 } { - puts "Error: surface is not a conical surface" - } -} else { - puts "Error: required surface is not got" -} - - diff --git a/tests/cr/base/B8 b/tests/cr/base/B8 deleted file mode 100644 index 64e69c9959..0000000000 --- a/tests/cr/base/B8 +++ /dev/null @@ -1,25 +0,0 @@ -sphere surf 1 -trim surf1 surf 0 3 -1.5 0 -convert surf1 surf1 -mkface f1 surf1 -trim surf2 surf 0 3 0 1.5 -convert surf2 surf2 -mkface f2 surf2 -trim surf3 surf 3 6 0 1.5 -convert surf3 surf3 -mkface f3 surf3 -trim surf4 surf 3 6 -1.5 0 -convert surf4 surf4 -mkface f4 surf4 -sewing sh f1 f2 f3 f4 -getanasurf asurf sh sph 1.e-7 -if {[isdraw asurf]} { - set log [dump asurf] - if { [regexp {SphericalSurface} $log ] != 1 } { - puts "Error: surface is not a spherical surface" - } -} else { - puts "Error: required surface is not got" -} - - diff --git a/tests/cr/base/B9 b/tests/cr/base/B9 deleted file mode 100644 index 195c30074a..0000000000 --- a/tests/cr/base/B9 +++ /dev/null @@ -1,40 +0,0 @@ -cylinder surf 1 -trim surf1 surf 0 1 -1 1 -convert surf1 surf1 -mkface f1 surf1 -trim surf2 surf 1 2 -1 1 -convert surf2 surf2 -mkface f2 surf2 -trim surf3 surf 2 3 -1 1 -convert surf3 surf3 -mkface f3 surf3 -trim surf4 surf 3 4 -1 1 -convert surf4 surf4 -mkface f4 surf4 -sewing sh f1 f2 f3 f4 -cylinder cyl 0 0 -2.5 1 0 0 3 -trimv cyl1 cyl -2 2 -mkface fcyl cyl1 -nurbsconvert fcyl fcyl -bsection ss fcyl sh -explode ss e -shape w w -add ss_1 w -add ss_2 w -add ss_3 w -add ss_4 w -add ss_5 w -getanasurf asurf w cyl 1.e-7 cyl -if {[isdraw asurf]} { - set log [dump asurf] - if { [regexp {CylindricalSurface} $log ] != 1 } { - puts "Error: surface is not a cylindrical surface" - } - if { [regexp {Radius :3} $log ] != 1 } { - puts "Error: surface is not a sample surface" - } -} else { - puts "Error: required surface is not got" -} - - diff --git a/tests/de_mesh/gltf_read/boxinterleaved b/tests/de_mesh/gltf_read/boxinterleaved deleted file mode 100644 index 6d13c7f1ec..0000000000 --- a/tests/de_mesh/gltf_read/boxinterleaved +++ /dev/null @@ -1,45 +0,0 @@ -puts "========" -puts "0031332: Data Exchange - RWGltf_CafReader ignores bufferView.byteStride within glTF 2.0" -puts "========" - -# glTF file content -set cubeGltf { -{ -"asset": {"generator": "","version": "2.0"}, -"scene": 0, -"scenes": [{"nodes": [0]}], -"nodes": [{"children": [1],"matrix": [1.0,0.0,0.0,0.0,0.0,0.0,-1.0,0.0,0.0,1.0,0.0,0.0,0.0,0.0,0.0,1.0]},{"mesh": 0}], -"meshes": [{"primitives": [{"attributes": {"NORMAL": 1,"POSITION": 2},"indices": 0,"mode": 4,"material": 0}],"name": "Mesh"}], -"accessors": [ -{"bufferView": 0,"byteOffset": 0, "componentType": 5123,"count": 36,"max": [23],"min": [0],"type": "SCALAR"}, -{"bufferView": 1,"byteOffset": 0, "componentType": 5126,"count": 24,"max": [1.0,1.0,1.0],"min": [-1.0,-1.0,-1.0],"type": "VEC3"}, -{"bufferView": 1,"byteOffset": 12,"componentType": 5126,"count": 24,"max": [0.5,0.5,0.5],"min": [-0.5,-0.5,-0.5],"type": "VEC3"} -], -"materials": [{"pbrMetallicRoughness": {"baseColorFactor": [0.800000011920929,0.0,0.0,1.0]}}], -"bufferViews": [ -{"buffer": 0,"byteOffset": 576,"byteLength": 72,"target": 34963}, -{"buffer": 0,"byteOffset": 0, "byteLength": 576,"byteStride": 24,"target": 34962} -], -"buffers": [{"byteLength": 648,"uri": "data:application/octet-stream;base64,AAAAAAAAAAAAAIA/AAAAvwAAAL8AAAA/AAAAAAAAAAAAAIA/AAAAPwAAAL8AAAA/AAAAAAAAAAAAAIA/AAAAvwAAAD8AAAA/AAAAAAAAAAAAAIA/AAAAPwAAAD8AAAA/AAAAAAAAgL8AAAAAAAAAPwAAAL8AAAA/AAAAAAAAgL8AAAAAAAAAvwAAAL8AAAA/AAAAAAAAgL8AAAAAAAAAPwAAAL8AAAC/AAAAAAAAgL8AAAAAAAAAvwAAAL8AAAC/AACAPwAAAAAAAAAAAAAAPwAAAD8AAAA/AACAPwAAAAAAAAAAAAAAPwAAAL8AAAA/AACAPwAAAAAAAAAAAAAAPwAAAD8AAAC/AACAPwAAAAAAAAAAAAAAPwAAAL8AAAC/AAAAAAAAgD8AAAAAAAAAvwAAAD8AAAA/AAAAAAAAgD8AAAAAAAAAPwAAAD8AAAA/AAAAAAAAgD8AAAAAAAAAvwAAAD8AAAC/AAAAAAAAgD8AAAAAAAAAPwAAAD8AAAC/AACAvwAAAAAAAAAAAAAAvwAAAL8AAAA/AACAvwAAAAAAAAAAAAAAvwAAAD8AAAA/AACAvwAAAAAAAAAAAAAAvwAAAL8AAAC/AACAvwAAAAAAAAAAAAAAvwAAAD8AAAC/AAAAAAAAAAAAAIC/AAAAvwAAAL8AAAC/AAAAAAAAAAAAAIC/AAAAvwAAAD8AAAC/AAAAAAAAAAAAAIC/AAAAPwAAAL8AAAC/AAAAAAAAAAAAAIC/AAAAPwAAAD8AAAC/AAABAAIAAwACAAEABAAFAAYABwAGAAUACAAJAAoACwAKAAkADAANAA4ADwAOAA0AEAARABIAEwASABEAFAAVABYAFwAWABUA"}] -} -} - -set fd [open ${imagedir}/${casename}.gltf w] -fconfigure $fd -translation lf -puts $fd $cubeGltf -close $fd - -ReadGltf D ${imagedir}/${casename}.gltf -XGetOneShape s D -checknbshapes s -face 1 -compound 1 -checktrinfo s -tri 12 -nod 24 - -set THE_REF_DUMP { -INSTANCE COMPOUND 0:1:1:1 (refers to 0:1:1:2) "Mesh" -PART COMPOUND 0:1:1:2 "Mesh" - FACE 0:1:1:2:1 - -Free Shapes: 1 -INSTANCE COMPOUND 0:1:1:1 (refers to 0:1:1:2) "Mesh" -} -checkXDump D $THE_REF_DUMP diff --git a/tests/de_mesh/gltf_read/cubeemb b/tests/de_mesh/gltf_read/cubeemb deleted file mode 100644 index 9a9cc0fe51..0000000000 --- a/tests/de_mesh/gltf_read/cubeemb +++ /dev/null @@ -1,53 +0,0 @@ -puts "========" -puts "0031312: Data Exchange - RWGltf_CafReader fails reading texture embedded into base64 bufferView" -puts "========" - -# glTF file content -set cubeGltf { -{ -"asset":{"generator":"","version":"2.0"}, -"scene":0, -"scenes":[{"name":"Scene","nodes":[0]}], -"nodes":[{"mesh":0,"name":"Cube"}], -"materials":[{"name":"Material","pbrMetallicRoughness":{"baseColorTexture":{"index":0,"texCoord":0},"metallicFactor":0,"roughnessFactor":0.4}}], -"meshes":[{"name":"Cube","primitives":[{"attributes":{"POSITION":0,"NORMAL":1,"TEXCOORD_0":2},"indices":3,"material":0}]}], -"textures":[{"source":0}], -"images":[{"bufferView":4,"mimeType":"image/jpeg","name":"UVGrid"}], -"accessors":[ -{"bufferView":0,"componentType":5126,"count":24,"type":"VEC3"}, -{"bufferView":1,"componentType":5126,"count":24,"type":"VEC3"}, -{"bufferView":2,"componentType":5126,"count":24,"type":"VEC2"}, -{"bufferView":3,"componentType":5123,"count":36,"type":"SCALAR"} -], -"bufferViews":[ -{"buffer":0,"byteLength":288,"byteOffset":0}, -{"buffer":0,"byteLength":288,"byteOffset":288}, -{"buffer":0,"byteLength":192,"byteOffset":576}, -{"buffer":0,"byteLength":72,"byteOffset":768}, -{"buffer":0,"byteLength":2870,"byteOffset":840} -], -"buffers":[{ -"byteLength":3712, -"uri":"data:application/octet-stream;base64,AACAPwAAgD8AAIA/AACAPwAAgD8AAIC/AACAvwAAgD8AAIC/AACAvwAAgD8AAIA/AACAvwAAgD8AAIA/AACAvwAAgL8AAIA/AACAPwAAgL8AAIA/AACAPwAAgD8AAIA/AACAvwAAgD8AAIC/AACAvwAAgL8AAIC/AACAvwAAgL8AAIA/AACAvwAAgD8AAIA/AACAvwAAgL8AAIA/AACAvwAAgL8AAIC/AACAPwAAgL8AAIC/AACAPwAAgL8AAIA/AACAPwAAgD8AAIA/AACAPwAAgL8AAIA/AACAPwAAgL8AAIC/AACAPwAAgD8AAIC/AACAPwAAgD8AAIC/AACAPwAAgL8AAIC/AACAvwAAgL8AAIC/AACAvwAAgD8AAIC/AAAAAAAAgD8AAAAAAAAAAAAAgD8AAAAAAAAAAAAAgD8AAAAAAAAAAAAAgD8AAAAAAAAAAAAAAAAAAIA/AAAAAAAAAAAAAIA/AAAAAAAAAAAAAIA/AAAAAAAAAAAAAIA/AACAvwAAAAAAAAAAAACAvwAAAAAAAAAAAACAvwAAAAAAAAAAAACAvwAAAAAAAAAAAAAAAAAAgL8AAACAAAAAAAAAgL8AAACAAAAAAAAAgL8AAACAAAAAAAAAgL8AAACAAACAPwAAAAAAAAAAAACAPwAAAAAAAAAAAACAPwAAAAAAAAAAAACAPwAAAAAAAAAAAAAAAAAAAAAAAIC/AAAAAAAAAAAAAIC/AAAAAAAAAAAAAIC/AAAAAAAAAAAAAIC/AAAgPwAAgD4AACA/AAAAPwAAYD8AAAA/AABgPwAAgD4AACA/AAAAAAAAwD4AAAAAAADAPgAAgD4AACA/AACAPgAAID8AAEA/AADAPgAAQD8AAMA+AACAPwAAID8AAIA/AAAAPgAAgD4AAAA+AAAAPwAAwD4AAAA/AADAPgAAgD4AACA/AACAPgAAwD4AAIA+AADAPgAAAD8AACA/AAAAPwAAID8AAAA/AADAPgAAAD8AAMA+AABAPwAAID8AAEA/AAABAAIAAAACAAMABAAFAAYABAAGAAcACAAJAAoACAAKAAsADAANAA4ADAAOAA8AEAARABIAEAASABMAFAAVABYAFAAWABcA/9j/4AAQSkZJRgABAQAAAQABAAD/4QAMTmVvR2VvAAAAWv/bAEMAAwICAwICAwMDAwQDAwQFCAUFBAQFCgcHBggMCgwMCwoLCw0OEhANDhEOCwsQFhARExQVFRUMDxcYFhQYEhQVFP/bAEMBAwQEBQQFCQUFCRQNCw0UFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFP/AABEIAIAAgAMBIgACEQEDEQH/xAAfAAABBQEBAQEBAQAAAAAAAAAAAQIDBAUGBwgJCgv/xAC1EAACAQMDAgQDBQUEBAAAAX0BAgMABBEFEiExQQYTUWEHInEUMoGRoQgjQrHBFVLR8CQzYnKCCQoWFxgZGiUmJygpKjQ1Njc4OTpDREVGR0hJSlNUVVZXWFlaY2RlZmdoaWpzdHV2d3h5eoOEhYaHiImKkpOUlZaXmJmaoqOkpaanqKmqsrO0tba3uLm6wsPExcbHyMnK0tPU1dbX2Nna4eLj5OXm5+jp6vHy8/T19vf4+fr/xAAfAQADAQEBAQEBAQEBAAAAAAAAAQIDBAUGBwgJCgv/xAC1EQACAQIEBAMEBwUEBAABAncAAQIDEQQFITEGEkFRB2FxEyIygQgUQpGhscEJIzNS8BVictEKFiQ04SXxFxgZGiYnKCkqNTY3ODk6Q0RFRkdISUpTVFVWV1hZWmNkZWZnaGlqc3R1dnd4eXqCg4SFhoeIiYqSk5SVlpeYmZqio6Slpqeoqaqys7S1tre4ubrCw8TFxsfIycrS09TV1tfY2dri4+Tl5ufo6ery8/T19vf4+fr/2gAMAwEAAhEDEQA/APlSiirem6TfazO0NhZ3F9Mq7zHbRNIwXIGcAHjJHPvSbUVdsic404uU3ZLqypRWz4p8LX3hTVbi1ure4SFZpIoLiaBo1uFRsb1z1BGDwT1FY1TCcakVODumZ0K9PE041qMrxlqmj7moop8UEk7FYo2kYDOEBJxROcacXKbsl1Zs2krsZRU95ZyWUzI6sFDEKzKQGAPUVBUUa1PEU41aUrxeqaJhOM4qUXdM+GaKKvaRoWpeILlrfS9PutSuFQyNFZwNK4UEAsQoJxkgZ9xVznGnFym7JdWaJOTsijRXQ+NvBOpeB9burG+tbqO3S4mhtru4tmhS6VGxvTPBBG08E/eHNc9UUa1PEU41aUrxeqaKnCVOTjJWaPuaiiq19qNppkQlvLqG0iLbQ88gRSeuMnvwfyrVtJXYQhOpJQgrt9FqyzRWX4f8QWniLT4bi3mhaVokklgilDtCWGdrY6HqOQOhrUqYTjOKlF3TNa9CrhasqNaPLKOjTPhmiiirOct6tqUus6reX8yos11M87rGCFDMxYgZJ4yaqUUUklFJLYiEI04qEFZLRH3NRRRTLHzymeaSVgAzsWOOmSaZRRUQhGnFQirJaISSirI+GaKKKsZe13V5vEGt6hqlwqJcX1xJcyLECEDOxYgAknGT3JqjRRUQhGnFQirJaIbbk7s+5qKKKsRW06xj0zT7WziLNFbxLChc5YhQAM+/FWaKKSSirIuc5VJuc3dvV+oUUU+KCSdisUbSMBnCAk4qZzjTi5TdkurM20ldjKKnvLOSymZHVgoYhWZSAwB6ioKijWp4inGrSleL1TRMJxnFSi7pnwzRRV7SNC1LxBctb6Xp91qVwqGRorOBpXCggFiFBOMkDPuKuc404uU3ZLqzRJydkUaK6Hxt4J1LwPrd1Y31rdR26XE0Ntd3Fs0KXSo2N6Z4II2ngn7w5rnqijWp4inGrSleL1TRU4SpycZKzR9zUUVWvtRtNMiEt5dQ2kRbaHnkCKT1xk9+D+VatpK7CEJ1JKEFdvotWWaKy/D/AIgtPEWnw3FvNC0rRJJLBFKHaEsM7Wx0PUcgdDWpUwnGcVKLuma16FXC1ZUa0eWUdGmfDNFFXtI0LUvEFy1vpen3WpXCoZGis4GlcKCAWIUE4yQM+4onONOLlN2S6swScnZFGiuh8beCdS8D63dWN9a3UdulxNDbXdxbNCl0qNjemeCCNp4J+8Oa56oo1qeIpxq0pXi9U0VOEqcnGSs0fc1FFFbED55TPNJKwAZ2LHHTJNMooqIQjTioRVktEJJRVkfDNFFFWMva7q83iDW9Q1S4VEuL64kuZFiBCBnYsQASTjJ7k1RooqIQjTioRVktENtyd2fc1FFFWIradYx6Zp9rZxFmit4lhQucsQoAGffirNFFJJRVkXOcqk3Obu3q/U+GaKKKZBe13V5vEGt6hqlwqJcX1xJcyLECEDOxYgAknGT3JqjRRUQhGnFQirJaIbbk7sKKKvaRoWpeILlrfS9PutSuFQyNFZwNK4UEAsQoJxkgZ9xROcacXKbsl1YJOTsijRXQ+NvBOpeB9burG+tbqO3S4mhtru4tmhS6VGxvTPBBG08E/eHNc9UUa1PEU41aUrxeqaKnCVOTjJWaPuaiiq19qNppkQlvLqG0iLbQ88gRSeuMnvwfyrVtJXYQhOpJQgrt9FqyzRWX4f8AEFp4i0+G4t5oWlaJJJYIpQ7Qlhna2Oh6jkDoa1KmE4zipRd0zWvQq4WrKjWjyyjo0z4Zooq9pGhal4guWt9L0+61K4VDI0VnA0rhQQCxCgnGSBn3FE5xpxcpuyXVmCTk7Io0V0PjbwTqXgfW7qxvrW6jt0uJoba7uLZoUulRsb0zwQRtPBP3hzXPVFGtTxFONWlK8XqmipwlTk4yVmj7moop8UEk7FYo2kYDOEBJxVznGnFym7JdWZtpK7GUVPeWcllMyOrBQxCsykBgD1FQVFGtTxFONWlK8XqmiYTjOKlF3TPhmiiitiy9rurzeINb1DVLhUS4vriS5kWIEIGdixABJOMnuTVGiiohCNOKhFWS0Q23J3Z9zUUUVYitp1jHpmn2tnEWaK3iWFC5yxCgAZ9+Ks0UUklFWRc5yqTc5u7er9T4ZooopkF7XdXm8Qa3qGqXColxfXElzIsQIQM7FiACScZPcmqNFFRCEacVCKslohtuTuz7moooqxD55TPNJKwAZ2LHHTJNMooqIQjTioRVktEJJRVkFFFVr7UbTTIhLeXUNpEW2h55Aik9cZPfg/lVNpK7NIQnUkoQV2+i1ZZorL8P+ILTxFp8NxbzQtK0SSSwRSh2hLDO1sdD1HIHQ1qVMJxnFSi7pmtehVwtWVGtHllHRpnwzRRV7SNC1LxBctb6Xp91qVwqGRorOBpXCggFiFBOMkDPuKJzjTi5TdkurMEnJ2RRorofG3gnUvA+t3VjfWt1HbpcTQ213cWzQpdKjY3pnggjaeCfvDmueqKNaniKcatKV4vVNFThKnJxkrNH3NRRT4oJJ2KxRtIwGcICTirnONOLlN2S6szbSV2Moqe8s5LKZkdWChiFZlIDAHqKgqKNaniKcatKV4vVNEwnGcVKLumfDNFFW9N0m+1mdobCzuL6ZV3mO2iaRguQM4APGSOfetW1FXbCc404uU3ZLqypRWz4p8LX3hTVbi1ure4SFZpIoLiaBo1uFRsb1z1BGDwT1FY1TCcakVODumZ0K9PE041qMrxlqmj7moooqzcradYx6Zp9rZxFmit4lhQucsQoAGffirNFFJJRVkXOcqk3Obu3q/U+GaKKKZBe13V5vEGt6hqlwqJcX1xJcyLECEDOxYgAknGT3JqjRRUQhGnFQirJaIbbk7s+5qKKKsQ+eUzzSSsAGdixx0yTTKKKiEI04qEVZLRCSUVZHwzRRRVjLeralLrOq3l/MqLNdTPO6xghQzMWIGSeMmqlFFJJRSS2IhCNOKhBWS0R/9kAAA==" -}] -} -} - -set fd [open ${imagedir}/${casename}.gltf w] -fconfigure $fd -translation lf -puts $fd $cubeGltf -close $fd - -ReadGltf D ${imagedir}/${casename}.gltf -XGetOneShape s D -checknbshapes s -face 1 -compound 0 -checktrinfo s -tri 12 -nod 24 - -set THE_REF_DUMP { -INSTANCE FACE 0:1:1:1 (refers to 0:1:1:2) "Cube" -PART FACE 0:1:1:2 "Cube" - -Free Shapes: 1 -INSTANCE FACE 0:1:1:1 (refers to 0:1:1:2) "Cube" -} -checkXDump D $THE_REF_DUMP diff --git a/tests/de_mesh/shape_write_stl/B1 b/tests/de_mesh/shape_write_stl/B1 deleted file mode 100644 index 4ecf0c097a..0000000000 --- a/tests/de_mesh/shape_write_stl/B1 +++ /dev/null @@ -1,36 +0,0 @@ -sphere s 10 -tessellate result s 100 100 -XProgress +t -set aTmpFile "$imagedir/${casename}.stl" -set out [writestl result "$aTmpFile"] -file delete "$aTmpFile" - -set expected { - {Progress: 0%} - {Progress: 5% Triangles: 1000 / 20000} - {Progress: 10% Triangles: 2000 / 20000} - {Progress: 15% Triangles: 3000 / 20000} - {Progress: 20% Triangles: 4000 / 20000} - {Progress: 25% Triangles: 5000 / 20000} - {Progress: 30% Triangles: 6000 / 20000} - {Progress: 35% Triangles: 7000 / 20000} - {Progress: 40% Triangles: 8000 / 20000} - {Progress: 45% Triangles: 9000 / 20000} - {Progress: 50% Triangles: 10000 / 20000} - {Progress: 55% Triangles: 11000 / 20000} - {Progress: 60% Triangles: 12000 / 20000} - {Progress: 65% Triangles: 13000 / 20000} - {Progress: 70% Triangles: 14000 / 20000} - {Progress: 75% Triangles: 15000 / 20000} - {Progress: 80% Triangles: 16000 / 20000} - {Progress: 85% Triangles: 17000 / 20000} - {Progress: 90% Triangles: 18000 / 20000} - {Progress: 95% Triangles: 19000 / 20000} - {Progress: 100% Triangles: 20000 / 20000} -} - -if { [string compare [string trim $out] [join $expected "\n"]] } { - puts "Error: output (see above) does not match expected one:" - puts "[join $expected "\n"]" - puts "" -} diff --git a/tests/de_mesh/step_read/B1 b/tests/de_mesh/step_read/B1 deleted file mode 100644 index 075dd878b2..0000000000 --- a/tests/de_mesh/step_read/B1 +++ /dev/null @@ -1,16 +0,0 @@ - -box S -min -5 -5 -5 -max 5 5 5 - -incmesh S 0.1 - -stepwrite a S "${imagedir}/${casename}.stp" - -param read.step.tessellated OnNoBRep - -ReadStep D "${imagedir}/${casename}.stp" - -XGetOneShape S D - -set nb_faces 6 -set nb_nodes 0 -set nb_triangles 0 diff --git a/tests/de_mesh/step_write/B1 b/tests/de_mesh/step_write/B1 deleted file mode 100644 index 2fe5b3973b..0000000000 --- a/tests/de_mesh/step_write/B1 +++ /dev/null @@ -1,9 +0,0 @@ - -# simple meshed box (mesh + brep) - -box S 1 1 1 -incmesh S 0.1 - -set nb_faces 6 -set nb_nodes 24 -set nb_triangles 12 diff --git a/tests/de_mesh/step_write/B2 b/tests/de_mesh/step_write/B2 deleted file mode 100644 index badc7685cd..0000000000 --- a/tests/de_mesh/step_write/B2 +++ /dev/null @@ -1,13 +0,0 @@ - -# simple meshed box with void (mesh + brep) - -box b1 -min -5 -5 -5 -max 5 5 5 -box b2 -min -3 -3 -3 -max 3 3 3 - -bcut S b1 b2 - -incmesh S 0.1 - -set nb_faces 12 -set nb_nodes 48 -set nb_triangles 24 diff --git a/tests/de_mesh/step_write/C1 b/tests/de_mesh/step_write/C1 deleted file mode 100644 index efc9869359..0000000000 --- a/tests/de_mesh/step_write/C1 +++ /dev/null @@ -1,10 +0,0 @@ - -# simple meshed box (mesh without brep) - -box S 1 1 1 -incmesh S 0.1 -tclean -geom S - -set nb_faces 6 -set nb_nodes 24 -set nb_triangles 12 diff --git a/tests/de_mesh/step_write/C2 b/tests/de_mesh/step_write/C2 deleted file mode 100644 index 8b67153803..0000000000 --- a/tests/de_mesh/step_write/C2 +++ /dev/null @@ -1,11 +0,0 @@ - -# simple meshed box (mesh with brep) - -param write.step.tessellated OnNoBRep - -box S 1 1 1 -incmesh S 0.1 - -set nb_faces 6 -set nb_nodes 0 -set nb_triangles 0 diff --git a/tests/de_mesh/stl_read/D1 b/tests/de_mesh/stl_read/D1 deleted file mode 100644 index 42d946697d..0000000000 --- a/tests/de_mesh/stl_read/D1 +++ /dev/null @@ -1,91 +0,0 @@ -puts "\n#======================================================================" -puts "# Check reading empty or small STL files" -puts "#======================================================================\n" - -set minimal_ascii_stl {solid -facet normal 0 0 1 -outer loop -vertex 0 0 0 -vertex 1 0 0 -vertex 0 1 0 -endloop -endfacet -endsolid} - -puts "\n#======================================================================" -puts "# Ascii file with single facet, CRLF" -puts "#======================================================================" -set fd [open ${imagedir}/${casename}_one_ascii_dos.stl w] -fconfigure $fd -translation crlf -puts $fd $minimal_ascii_stl -close $fd -readstl res_one_ascii_dos ${imagedir}/${casename}_one_ascii_dos.stl -brep -checknbshapes res_one_ascii_dos -face 1 - -puts "\n#======================================================================" -puts "# Ascii file with single facet, LF" -puts "#======================================================================" -set fd [open ${imagedir}/${casename}_one_ascii_unix.stl w] -fconfigure $fd -translation lf -puts $fd $minimal_ascii_stl -close $fd -readstl res_one_ascii_unix ${imagedir}/${casename}_one_ascii_unix.stl -brep -checknbshapes res_one_ascii_unix -face 1 - -puts "\n#======================================================================" -puts "# Ascii file with single facet, LF, no EOL at the last line" -puts "#======================================================================" -set fd [open ${imagedir}/${casename}_one_ascii_noeol.stl w] -fconfigure $fd -translation lf -puts -nonewline $fd $minimal_ascii_stl -close $fd -readstl res_one_ascii_noeol ${imagedir}/${casename}_one_ascii_noeol.stl -brep -checknbshapes res_one_ascii_noeol -face 1 - -puts "\n#======================================================================" -puts "# Ascii file with no facets, CRLF" -puts "#======================================================================" -set fd [open ${imagedir}/${casename}_zero_ascii_dos.stl w] -fconfigure $fd -translation crlf -puts $fd "solid \nendsolid" -close $fd -readstl res_zero_ascii_dos ${imagedir}/${casename}_zero_ascii_dos.stl -brep - -puts "\n#======================================================================" -puts "# Ascii file with no facets, LF" -puts "#======================================================================" -set fd [open ${imagedir}/${casename}_zero_ascii_unix.stl w] -fconfigure $fd -translation lf -puts $fd "solid \nendsolid" -close $fd -readstl res_zero_ascii_unix ${imagedir}/${casename}_zero_ascii_unix.stl -brep - -puts "\n#======================================================================" -puts "# Binary file with single facet" -puts "#======================================================================" -set fd [open ${imagedir}/${casename}_one_binary.stl w] -fconfigure $fd -translation binary -puts -nonewline $fd "stl [string repeat { } 76]" -puts -nonewline $fd [binary format if3f3f3f3t 1 {0 0 1} {0 0 0} {1 0 0} {0 1 0} 0] -close $fd -readstl res_one_binary ${imagedir}/${casename}_one_binary.stl -brep -checknbshapes res_one_binary -face 1 - -puts "\n#======================================================================" -puts "# Binary file with no facets -- will be treated as Ascii and generate e r r o r" -puts "#======================================================================" -puts "REQUIRED ALL: Error: premature end of file" -set fd [open ${imagedir}/${casename}_zero_binary.stl w] -fconfigure $fd -translation binary -puts -nonewline $fd "stl [string repeat { } 76][binary format i 0]" -close $fd -readstl res_zero_binary ${imagedir}/${casename}_zero_binary.stl -brep - -puts "\n#======================================================================" -puts "# Empty file" -puts "#======================================================================" -puts "REQUIRED ALL: Error: premature end of file" -set fd [open ${imagedir}/${casename}_empty.stl w] -close $fd -readstl res_empty ${imagedir}/${casename}_empty.stl -brep - diff --git a/tests/de_wrapper/brep/A1 b/tests/de_wrapper/brep/A1 deleted file mode 100644 index fa788f5b60..0000000000 --- a/tests/de_wrapper/brep/A1 +++ /dev/null @@ -1,16 +0,0 @@ -puts "============" -puts "0032821: DEWrapper - Implementation of a common toolkit for importing and exporting CAD files" -puts "============" -puts "" - -readbrep ${filename} S_First - -set file_path ${imagedir}/${casename}.brep - -writebrep S_First $file_path - -readfile S_Second $file_path - -checknbshapes S_Second -ref [nbshapes S_First] - -file delete $file_path diff --git a/tests/de_wrapper/brep/A2 b/tests/de_wrapper/brep/A2 deleted file mode 100644 index 295ed9ceb5..0000000000 --- a/tests/de_wrapper/brep/A2 +++ /dev/null @@ -1,22 +0,0 @@ -puts "============" -puts "0032821: DEWrapper - Implementation of a common toolkit for importing and exporting CAD files" -puts "============" -puts "" - -catch { Close D_First } -catch { Close D_Second } - -readbrep ${filename} S_First -XNewDoc D_First -XAddShape D_First S_First - -set file_path ${imagedir}/${casename}.brep - -WriteFile D_First $file_path - -readbrep ${filename} S_Second - -checknbshapes S_Second -ref [nbshapes S_First] - -file delete $file_path -Close D_First diff --git a/tests/de_wrapper/brep/A3 b/tests/de_wrapper/brep/A3 deleted file mode 100644 index 8e99b07aa4..0000000000 --- a/tests/de_wrapper/brep/A3 +++ /dev/null @@ -1,20 +0,0 @@ -puts "============" -puts "0032821: DEWrapper - Implementation of a common toolkit for importing and exporting CAD files" -puts "============" -puts "" - -catch { Close D_First } - -readbrep ${filename} S_First - -set file_path ${imagedir}/${casename}.brep - -writefile S_First $file_path - -ReadFile D_First $file_path -XGetOneShape S_Second D_First - -checknbshapes S_Second -ref [nbshapes S_First] - -file delete $file_path -Close D_First diff --git a/tests/de_wrapper/brep/A4 b/tests/de_wrapper/brep/A4 deleted file mode 100644 index acf66c29eb..0000000000 --- a/tests/de_wrapper/brep/A4 +++ /dev/null @@ -1,16 +0,0 @@ -puts "============" -puts "0032821: DEWrapper - Implementation of a common toolkit for importing and exporting CAD files" -puts "============" -puts "" - -readfile S_First ${filename} - -set file_path ${imagedir}/${casename}.brep - -writefile S_First $file_path - -readfile S_Second $file_path - -checknbshapes S_Second -ref [nbshapes S_First] - -file delete $file_path diff --git a/tests/de_wrapper/configuration/A1 b/tests/de_wrapper/configuration/A1 deleted file mode 100644 index ecbe3af5a0..0000000000 --- a/tests/de_wrapper/configuration/A1 +++ /dev/null @@ -1,15 +0,0 @@ -puts "============" -puts "0032821: DEWrapper - Implementation of a common toolkit for importing and exporting CAD files" -puts "============" -puts "" - -# Checking the stability of ability to change the configuration's values -set old_conf [DumpConfiguration] - -set res_conf [changeconf "1" "$old_conf"] - -LoadConfiguration ${res_conf} -set new_conf [DumpConfiguration] - -CompareConfiguration ${res_conf} ${new_conf} - diff --git a/tests/de_wrapper/configuration/A2 b/tests/de_wrapper/configuration/A2 deleted file mode 100644 index d30688a031..0000000000 --- a/tests/de_wrapper/configuration/A2 +++ /dev/null @@ -1,15 +0,0 @@ -puts "============" -puts "0032821: DEWrapper - Implementation of a common toolkit for importing and exporting CAD files" -puts "============" -puts "" - -# Checking the stability of ability to change the configuration's values -set old_conf [DumpConfiguration] - -set res_conf [changeconf "0" "$old_conf"] - -LoadConfiguration ${res_conf} -set new_conf [DumpConfiguration] - -CompareConfiguration ${res_conf} ${new_conf} - diff --git a/tests/de_wrapper/configuration/A3 b/tests/de_wrapper/configuration/A3 deleted file mode 100644 index 27c47402eb..0000000000 --- a/tests/de_wrapper/configuration/A3 +++ /dev/null @@ -1,269 +0,0 @@ -puts "============" -puts "0032821: DEWrapper - Implementation of a common toolkit for importing and exporting CAD files" -puts "============" -puts "" - -# Checking the stability of the initial configuration -set ref_conf " -global.priority.VRML : OCC -global.priority.IGES : OCC -global.priority.OBJ : OCC -global.priority.GLTF : OCC -global.priority.PLY : OCC -global.priority.XCAF : OCC -global.priority.STEP : OCC -global.priority.STL : OCC -global.priority.BREP : OCC -global.general.length.unit : 1 -global.general.system.unit : 1 -provider.VRML.OCC.read.file.unit : 1 -provider.VRML.OCC.read.file.coordinate.system : 1 -provider.VRML.OCC.read.system.coordinate.system : 0 -provider.VRML.OCC.read.fill.incomplete : 1 -provider.VRML.OCC.writer.version : 2 -provider.VRML.OCC.write.representation.type : 1 -provider.IGES.OCC.read.iges.bspline.continuity : 1 -provider.IGES.OCC.read.precision.mode : 0 -provider.IGES.OCC.read.precision.val : 0.0001 -provider.IGES.OCC.read.maxprecision.mode : 0 -provider.IGES.OCC.read.maxprecision.val : 1 -provider.IGES.OCC.read.stdsameparameter.mode : 0 -provider.IGES.OCC.read.surfacecurve.mode : 0 -provider.IGES.OCC.read.encoderegularity.angle : 0.572958 -provider.IGES.OCC.read.bspline.approxd1.mode : 0 -provider.IGES.OCC.read.fau_lty.entities : 0 -provider.IGES.OCC.read.onlyvisible : 0 -provider.IGES.OCC.read.color : 1 -provider.IGES.OCC.read.name : 1 -provider.IGES.OCC.read.layer : 1 -provider.IGES.OCC.write.brep.mode : 0 -provider.IGES.OCC.write.convertsurface.mode : 0 -provider.IGES.OCC.write.header.author : -provider.IGES.OCC.write.header.company : -provider.IGES.OCC.write.header.product : -provider.IGES.OCC.write.header.receiver : -provider.IGES.OCC.write.precision.mode : 0 -provider.IGES.OCC.write.precision.val : 0.0001 -provider.IGES.OCC.write.plane.mode : 0 -provider.IGES.OCC.write.offset : 0 -provider.IGES.OCC.write.color : 1 -provider.IGES.OCC.write.name : 1 -provider.IGES.OCC.write.layer : 1 -provider.IGES.OCC.healing.tolerance3d : 1e-06 -provider.IGES.OCC.healing.max.tolerance3d : 1 -provider.IGES.OCC.healing.min.tolerance3d : 1e-07 -provider.IGES.OCC.healing.free.shell : -1 -provider.IGES.OCC.healing.free.face : -1 -provider.IGES.OCC.healing.free.wire : -1 -provider.IGES.OCC.healing.same.parameter : -1 -provider.IGES.OCC.healing.solid : -1 -provider.IGES.OCC.healing.shell.orientation : -1 -provider.IGES.OCC.healing.create.open.solid : 1 -provider.IGES.OCC.healing.shell : -1 -provider.IGES.OCC.healing.face.orientation : -1 -provider.IGES.OCC.healing.face : -1 -provider.IGES.OCC.healing.wire : -1 -provider.IGES.OCC.healing.orientation : -1 -provider.IGES.OCC.healing.add.natural.bound : -1 -provider.IGES.OCC.healing.missing.seam : -1 -provider.IGES.OCC.healing.small.area.wire : -1 -provider.IGES.OCC.healing.remove.small.area.face : -1 -provider.IGES.OCC.healing.intersecting.wires : -1 -provider.IGES.OCC.healing.loop.wires : -1 -provider.IGES.OCC.healing.split.face : -1 -provider.IGES.OCC.healing.auto.correct.precision : 1 -provider.IGES.OCC.healing.modify.topology : 0 -provider.IGES.OCC.healing.modify.geometry : 1 -provider.IGES.OCC.healing.closed.wire : 1 -provider.IGES.OCC.healing.preference.pcurve : 1 -provider.IGES.OCC.healing.reorder.edges : -1 -provider.IGES.OCC.healing.remove.small.edges : -1 -provider.IGES.OCC.healing.connected.edges : -1 -provider.IGES.OCC.healing.edge.curves : -1 -provider.IGES.OCC.healing.add.degenerated.edges : -1 -provider.IGES.OCC.healing.add.lacking.edges : -1 -provider.IGES.OCC.healing.selfintersection : -1 -provider.IGES.OCC.healing.remove.loop : -1 -provider.IGES.OCC.healing.reversed2d : -1 -provider.IGES.OCC.healing.remove.pcurve : -1 -provider.IGES.OCC.healing.remove.curve3d : -1 -provider.IGES.OCC.healing.add.pcurve : -1 -provider.IGES.OCC.healing.add.curve3d : -1 -provider.IGES.OCC.healing.correct.order.in.seam : -1 -provider.IGES.OCC.healing.shifted : -1 -provider.IGES.OCC.healing.edge.same.parameter : 0 -provider.IGES.OCC.healing.notched.edges : -1 -provider.IGES.OCC.healing.tail : -1 -provider.IGES.OCC.healing.max.tail.angle : -1 -provider.IGES.OCC.healing.max.tail.width : -1 -provider.IGES.OCC.healing.selfintersecting.edge : -1 -provider.IGES.OCC.healing.intersecting.edges : -1 -provider.IGES.OCC.healing.nonadjacent.intersecting.edges : -1 -provider.IGES.OCC.healing.vertex.position : 0 -provider.IGES.OCC.healing.vertex.tolerance : -1 -provider.OBJ.OCC.file.length.unit : 1 -provider.OBJ.OCC.system.cs : 0 -provider.OBJ.OCC.file.cs : 1 -provider.OBJ.OCC.read.single.precision : 0 -provider.OBJ.OCC.read.create.shapes : 0 -provider.OBJ.OCC.read.root.prefix : -provider.OBJ.OCC.read.fill.doc : 1 -provider.OBJ.OCC.read.fill.incomplete : 1 -provider.OBJ.OCC.read.memory.limit.mib : -1 -provider.OBJ.OCC.write.comment : -provider.OBJ.OCC.write.author : -provider.GLTF.OCC.file.length.unit : 1 -provider.GLTF.OCC.system.cs : 0 -provider.GLTF.OCC.file.cs : 1 -provider.GLTF.OCC.read.single.precision : 1 -provider.GLTF.OCC.read.create.shapes : 0 -provider.GLTF.OCC.read.root.prefix : -provider.GLTF.OCC.read.fill.doc : 1 -provider.GLTF.OCC.read.fill.incomplete : 1 -provider.GLTF.OCC.read.memory.limit.mib : -1 -provider.GLTF.OCC.read.parallel : 0 -provider.GLTF.OCC.read.skip.empty.nodes : 1 -provider.GLTF.OCC.read.load.all.scenes : 0 -provider.GLTF.OCC.read.use.mesh.name.as.fallback : 1 -provider.GLTF.OCC.read.skip.late.data.loading : 0 -provider.GLTF.OCC.read.keep.late.data : 1 -provider.GLTF.OCC.read.print.debug.message : 0 -provider.GLTF.OCC.read.apply.scale : 1 -provider.GLTF.OCC.write.comment : -provider.GLTF.OCC.write.author : -provider.GLTF.OCC.write.trsf.format : 0 -provider.GLTF.OCC.write.node.name.format : 3 -provider.GLTF.OCC.write.mesh.name.format : 1 -provider.GLTF.OCC.write.forced.uv.export : 0 -provider.GLTF.OCC.write.embed.textures.in.glb : 1 -provider.GLTF.OCC.write.merge.faces : 0 -provider.GLTF.OCC.write.split.indices16 : 0 -provider.PLY.OCC.file.length.unit : 1 -provider.PLY.OCC.system.cs : 0 -provider.PLY.OCC.file.cs : 1 -provider.PLY.OCC.write.normals : 1 -provider.PLY.OCC.write.colors : 1 -provider.PLY.OCC.write.tex.coords : 0 -provider.PLY.OCC.write.part.id : 1 -provider.PLY.OCC.write.face.id : 0 -provider.PLY.OCC.write.comment : -provider.PLY.OCC.write.author : -provider.XCAF.OCC.read.append.mode : 0 -provider.XCAF.OCC.read.skip.values : -provider.XCAF.OCC.read.values : -provider.STEP.OCC.read.iges.bspline.continuity : 1 -provider.STEP.OCC.read.precision.mode : 0 -provider.STEP.OCC.read.precision.val : 0.0001 -provider.STEP.OCC.read.maxprecision.mode : 0 -provider.STEP.OCC.read.maxprecision.val : 1 -provider.STEP.OCC.read.stdsameparameter.mode : 0 -provider.STEP.OCC.read.surfacecurve.mode : 0 -provider.STEP.OCC.read.encoderegularity.angle : 0.572958 -provider.STEP.OCC.angleunit.mode : 0 -provider.STEP.OCC.read.product.mode : 1 -provider.STEP.OCC.read.product.context : 1 -provider.STEP.OCC.read.shape.repr : 1 -provider.STEP.OCC.read.tessellated : 1 -provider.STEP.OCC.read.assembly.level : 1 -provider.STEP.OCC.read.shape.relationship : 1 -provider.STEP.OCC.read.shape.aspect : 1 -provider.STEP.OCC.read.constructivegeom.relationship : 0 -provider.STEP.OCC.read.stepcaf.subshapes.name : 0 -provider.STEP.OCC.read.codepage : 4 -provider.STEP.OCC.read.nonmanifold : 0 -provider.STEP.OCC.read.ideas : 0 -provider.STEP.OCC.read.all.shapes : 0 -provider.STEP.OCC.read.root.transformation : 1 -provider.STEP.OCC.read.color : 1 -provider.STEP.OCC.read.name : 1 -provider.STEP.OCC.read.layer : 1 -provider.STEP.OCC.read.props : 1 -provider.STEP.OCC.read.metadata : 1 -provider.STEP.OCC.read.productmetadata : 0 -provider.STEP.OCC.write.precision.mode : 0 -provider.STEP.OCC.write.precision.val : 0.0001 -provider.STEP.OCC.write.assembly : 2 -provider.STEP.OCC.write.schema : 4 -provider.STEP.OCC.write.tessellated : 2 -provider.STEP.OCC.write.product.name : -provider.STEP.OCC.write.surfacecurve.mode : 1 -provider.STEP.OCC.write.unit : 2 -provider.STEP.OCC.write.vertex.mode : 0 -provider.STEP.OCC.write.stepcaf.subshapes.name : 0 -provider.STEP.OCC.write.color : 1 -provider.STEP.OCC.write.nonmanifold : 0 -provider.STEP.OCC.write.name : 1 -provider.STEP.OCC.write.layer : 1 -provider.STEP.OCC.write.material : 1 -provider.STEP.OCC.write.vismaterial : 0 -provider.STEP.OCC.write.metadata : 1 -provider.STEP.OCC.write.props : 1 -provider.STEP.OCC.write.model.type : 0 -provider.STEP.OCC.write.cleanduplicates : 0 -provider.STEP.OCC.write.scaling.trsf : 1 -provider.STEP.OCC.healing.tolerance3d : 1e-06 -provider.STEP.OCC.healing.max.tolerance3d : 1 -provider.STEP.OCC.healing.min.tolerance3d : 1e-07 -provider.STEP.OCC.healing.free.shell : -1 -provider.STEP.OCC.healing.free.face : -1 -provider.STEP.OCC.healing.free.wire : -1 -provider.STEP.OCC.healing.same.parameter : -1 -provider.STEP.OCC.healing.solid : -1 -provider.STEP.OCC.healing.shell.orientation : -1 -provider.STEP.OCC.healing.create.open.solid : 0 -provider.STEP.OCC.healing.shell : -1 -provider.STEP.OCC.healing.face.orientation : -1 -provider.STEP.OCC.healing.face : -1 -provider.STEP.OCC.healing.wire : -1 -provider.STEP.OCC.healing.orientation : -1 -provider.STEP.OCC.healing.add.natural.bound : -1 -provider.STEP.OCC.healing.missing.seam : -1 -provider.STEP.OCC.healing.small.area.wire : -1 -provider.STEP.OCC.healing.remove.small.area.face : -1 -provider.STEP.OCC.healing.intersecting.wires : -1 -provider.STEP.OCC.healing.loop.wires : -1 -provider.STEP.OCC.healing.split.face : -1 -provider.STEP.OCC.healing.auto.correct.precision : 1 -provider.STEP.OCC.healing.modify.topology : 0 -provider.STEP.OCC.healing.modify.geometry : 1 -provider.STEP.OCC.healing.closed.wire : 1 -provider.STEP.OCC.healing.preference.pcurve : 1 -provider.STEP.OCC.healing.reorder.edges : -1 -provider.STEP.OCC.healing.remove.small.edges : -1 -provider.STEP.OCC.healing.connected.edges : -1 -provider.STEP.OCC.healing.edge.curves : -1 -provider.STEP.OCC.healing.add.degenerated.edges : -1 -provider.STEP.OCC.healing.add.lacking.edges : -1 -provider.STEP.OCC.healing.selfintersection : -1 -provider.STEP.OCC.healing.remove.loop : -1 -provider.STEP.OCC.healing.reversed2d : -1 -provider.STEP.OCC.healing.remove.pcurve : -1 -provider.STEP.OCC.healing.remove.curve3d : -1 -provider.STEP.OCC.healing.add.pcurve : -1 -provider.STEP.OCC.healing.add.curve3d : -1 -provider.STEP.OCC.healing.correct.order.in.seam : -1 -provider.STEP.OCC.healing.shifted : -1 -provider.STEP.OCC.healing.edge.same.parameter : 0 -provider.STEP.OCC.healing.notched.edges : -1 -provider.STEP.OCC.healing.tail : 0 -provider.STEP.OCC.healing.max.tail.angle : 0 -provider.STEP.OCC.healing.max.tail.width : -1 -provider.STEP.OCC.healing.selfintersecting.edge : -1 -provider.STEP.OCC.healing.intersecting.edges : -1 -provider.STEP.OCC.healing.nonadjacent.intersecting.edges : -1 -provider.STEP.OCC.healing.vertex.position : 0 -provider.STEP.OCC.healing.vertex.tolerance : -1 -provider.STL.OCC.read.merge.angle : 90 -provider.STL.OCC.read.brep : 0 -provider.STL.OCC.write.ascii : 1 -provider.BREP.OCC.write.binary : 1 -provider.BREP.OCC.write.version.binary : 4 -provider.BREP.OCC.write.version.ascii : 3 -provider.BREP.OCC.write.triangles : 1 -provider.BREP.OCC.write.normals : 1 - -" - -set dump_conf [DumpConfiguration] - -CompareConfiguration $ref_conf $dump_conf diff --git a/tests/de_wrapper/configuration/A4 b/tests/de_wrapper/configuration/A4 deleted file mode 100644 index ad001886fb..0000000000 --- a/tests/de_wrapper/configuration/A4 +++ /dev/null @@ -1,204 +0,0 @@ -puts "============" -puts "0032821: DEWrapper - Implementation of a common toolkit for importing and exporting CAD files" -puts "============" -puts "" - -# Checking the dumping resource for the two format only -set conf_ref " -global.priority.VRML : OCC -global.priority.IGES : OCC -global.priority.OBJ : OCC -global.priority.GLTF : OCC -global.priority.PLY : OCC -global.priority.XCAF : OCC -global.priority.STEP : OCC -global.priority.STL : OCC -global.priority.BREP : OCC -global.general.length.unit : 1 -global.general.system.unit : 1 -provider.IGES.OCC.read.iges.bspline.continuity : 1 -provider.IGES.OCC.read.precision.mode : 0 -provider.IGES.OCC.read.precision.val : 0.0001 -provider.IGES.OCC.read.maxprecision.mode : 0 -provider.IGES.OCC.read.maxprecision.val : 1 -provider.IGES.OCC.read.stdsameparameter.mode : 0 -provider.IGES.OCC.read.surfacecurve.mode : 0 -provider.IGES.OCC.read.encoderegularity.angle : 0.572958 -provider.IGES.OCC.read.bspline.approxd1.mode : 0 -provider.IGES.OCC.read.fau_lty.entities : 0 -provider.IGES.OCC.read.onlyvisible : 0 -provider.IGES.OCC.read.color : 1 -provider.IGES.OCC.read.name : 1 -provider.IGES.OCC.read.layer : 1 -provider.IGES.OCC.write.brep.mode : 0 -provider.IGES.OCC.write.convertsurface.mode : 0 -provider.IGES.OCC.write.header.author : -provider.IGES.OCC.write.header.company : -provider.IGES.OCC.write.header.product : -provider.IGES.OCC.write.header.receiver : -provider.IGES.OCC.write.precision.mode : 0 -provider.IGES.OCC.write.precision.val : 0.0001 -provider.IGES.OCC.write.plane.mode : 0 -provider.IGES.OCC.write.offset : 0 -provider.IGES.OCC.write.color : 1 -provider.IGES.OCC.write.name : 1 -provider.IGES.OCC.write.layer : 1 -provider.IGES.OCC.healing.tolerance3d : 1e-06 -provider.IGES.OCC.healing.max.tolerance3d : 1 -provider.IGES.OCC.healing.min.tolerance3d : 1e-07 -provider.IGES.OCC.healing.free.shell : -1 -provider.IGES.OCC.healing.free.face : -1 -provider.IGES.OCC.healing.free.wire : -1 -provider.IGES.OCC.healing.same.parameter : -1 -provider.IGES.OCC.healing.solid : -1 -provider.IGES.OCC.healing.shell.orientation : -1 -provider.IGES.OCC.healing.create.open.solid : 1 -provider.IGES.OCC.healing.shell : -1 -provider.IGES.OCC.healing.face.orientation : -1 -provider.IGES.OCC.healing.face : -1 -provider.IGES.OCC.healing.wire : -1 -provider.IGES.OCC.healing.orientation : -1 -provider.IGES.OCC.healing.add.natural.bound : -1 -provider.IGES.OCC.healing.missing.seam : -1 -provider.IGES.OCC.healing.small.area.wire : -1 -provider.IGES.OCC.healing.remove.small.area.face : -1 -provider.IGES.OCC.healing.intersecting.wires : -1 -provider.IGES.OCC.healing.loop.wires : -1 -provider.IGES.OCC.healing.split.face : -1 -provider.IGES.OCC.healing.auto.correct.precision : 1 -provider.IGES.OCC.healing.modify.topology : 0 -provider.IGES.OCC.healing.modify.geometry : 1 -provider.IGES.OCC.healing.closed.wire : 1 -provider.IGES.OCC.healing.preference.pcurve : 1 -provider.IGES.OCC.healing.reorder.edges : -1 -provider.IGES.OCC.healing.remove.small.edges : -1 -provider.IGES.OCC.healing.connected.edges : -1 -provider.IGES.OCC.healing.edge.curves : -1 -provider.IGES.OCC.healing.add.degenerated.edges : -1 -provider.IGES.OCC.healing.add.lacking.edges : -1 -provider.IGES.OCC.healing.selfintersection : -1 -provider.IGES.OCC.healing.remove.loop : -1 -provider.IGES.OCC.healing.reversed2d : -1 -provider.IGES.OCC.healing.remove.pcurve : -1 -provider.IGES.OCC.healing.remove.curve3d : -1 -provider.IGES.OCC.healing.add.pcurve : -1 -provider.IGES.OCC.healing.add.curve3d : -1 -provider.IGES.OCC.healing.correct.order.in.seam : -1 -provider.IGES.OCC.healing.shifted : -1 -provider.IGES.OCC.healing.edge.same.parameter : 0 -provider.IGES.OCC.healing.notched.edges : -1 -provider.IGES.OCC.healing.tail : -1 -provider.IGES.OCC.healing.max.tail.angle : -1 -provider.IGES.OCC.healing.max.tail.width : -1 -provider.IGES.OCC.healing.selfintersecting.edge : -1 -provider.IGES.OCC.healing.intersecting.edges : -1 -provider.IGES.OCC.healing.nonadjacent.intersecting.edges : -1 -provider.IGES.OCC.healing.vertex.position : 0 -provider.IGES.OCC.healing.vertex.tolerance : -1 -provider.STEP.OCC.read.iges.bspline.continuity : 1 -provider.STEP.OCC.read.precision.mode : 0 -provider.STEP.OCC.read.precision.val : 0.0001 -provider.STEP.OCC.read.maxprecision.mode : 0 -provider.STEP.OCC.read.maxprecision.val : 1 -provider.STEP.OCC.read.stdsameparameter.mode : 0 -provider.STEP.OCC.read.surfacecurve.mode : 0 -provider.STEP.OCC.read.encoderegularity.angle : 0.572958 -provider.STEP.OCC.angleunit.mode : 0 -provider.STEP.OCC.read.product.mode : 1 -provider.STEP.OCC.read.product.context : 1 -provider.STEP.OCC.read.shape.repr : 1 -provider.STEP.OCC.read.tessellated : 1 -provider.STEP.OCC.read.assembly.level : 1 -provider.STEP.OCC.read.shape.relationship : 1 -provider.STEP.OCC.read.shape.aspect : 1 -provider.STEP.OCC.read.constructivegeom.relationship : 0 -provider.STEP.OCC.read.stepcaf.subshapes.name : 0 -provider.STEP.OCC.read.codepage : 4 -provider.STEP.OCC.read.nonmanifold : 0 -provider.STEP.OCC.read.ideas : 0 -provider.STEP.OCC.read.all.shapes : 0 -provider.STEP.OCC.read.root.transformation : 1 -provider.STEP.OCC.read.color : 1 -provider.STEP.OCC.read.name : 1 -provider.STEP.OCC.read.layer : 1 -provider.STEP.OCC.read.props : 1 -provider.STEP.OCC.read.metadata : 1 -provider.STEP.OCC.read.productmetadata : 0 -provider.STEP.OCC.write.precision.mode : 0 -provider.STEP.OCC.write.precision.val : 0.0001 -provider.STEP.OCC.write.assembly : 2 -provider.STEP.OCC.write.schema : 4 -provider.STEP.OCC.write.tessellated : 2 -provider.STEP.OCC.write.product.name : -provider.STEP.OCC.write.surfacecurve.mode : 1 -provider.STEP.OCC.write.unit : 2 -provider.STEP.OCC.write.vertex.mode : 0 -provider.STEP.OCC.write.stepcaf.subshapes.name : 0 -provider.STEP.OCC.write.color : 1 -provider.STEP.OCC.write.nonmanifold : 0 -provider.STEP.OCC.write.name : 1 -provider.STEP.OCC.write.layer : 1 -provider.STEP.OCC.write.props : 1 -provider.STEP.OCC.write.material : 1 -provider.STEP.OCC.write.vismaterial : 0 -provider.STEP.OCC.write.metadata : 1 -provider.STEP.OCC.write.model.type : 0 -provider.STEP.OCC.write.cleanduplicates : 0 -provider.STEP.OCC.write.scaling.trsf : 1 -provider.STEP.OCC.healing.tolerance3d : 1e-06 -provider.STEP.OCC.healing.max.tolerance3d : 1 -provider.STEP.OCC.healing.min.tolerance3d : 1e-07 -provider.STEP.OCC.healing.free.shell : -1 -provider.STEP.OCC.healing.free.face : -1 -provider.STEP.OCC.healing.free.wire : -1 -provider.STEP.OCC.healing.same.parameter : -1 -provider.STEP.OCC.healing.solid : -1 -provider.STEP.OCC.healing.shell.orientation : -1 -provider.STEP.OCC.healing.create.open.solid : 0 -provider.STEP.OCC.healing.shell : -1 -provider.STEP.OCC.healing.face.orientation : -1 -provider.STEP.OCC.healing.face : -1 -provider.STEP.OCC.healing.wire : -1 -provider.STEP.OCC.healing.orientation : -1 -provider.STEP.OCC.healing.add.natural.bound : -1 -provider.STEP.OCC.healing.missing.seam : -1 -provider.STEP.OCC.healing.small.area.wire : -1 -provider.STEP.OCC.healing.remove.small.area.face : -1 -provider.STEP.OCC.healing.intersecting.wires : -1 -provider.STEP.OCC.healing.loop.wires : -1 -provider.STEP.OCC.healing.split.face : -1 -provider.STEP.OCC.healing.auto.correct.precision : 1 -provider.STEP.OCC.healing.modify.topology : 0 -provider.STEP.OCC.healing.modify.geometry : 1 -provider.STEP.OCC.healing.closed.wire : 1 -provider.STEP.OCC.healing.preference.pcurve : 1 -provider.STEP.OCC.healing.reorder.edges : -1 -provider.STEP.OCC.healing.remove.small.edges : -1 -provider.STEP.OCC.healing.connected.edges : -1 -provider.STEP.OCC.healing.edge.curves : -1 -provider.STEP.OCC.healing.add.degenerated.edges : -1 -provider.STEP.OCC.healing.add.lacking.edges : -1 -provider.STEP.OCC.healing.selfintersection : -1 -provider.STEP.OCC.healing.remove.loop : -1 -provider.STEP.OCC.healing.reversed2d : -1 -provider.STEP.OCC.healing.remove.pcurve : -1 -provider.STEP.OCC.healing.remove.curve3d : -1 -provider.STEP.OCC.healing.add.pcurve : -1 -provider.STEP.OCC.healing.add.curve3d : -1 -provider.STEP.OCC.healing.correct.order.in.seam : -1 -provider.STEP.OCC.healing.shifted : -1 -provider.STEP.OCC.healing.edge.same.parameter : 0 -provider.STEP.OCC.healing.notched.edges : -1 -provider.STEP.OCC.healing.tail : 0 -provider.STEP.OCC.healing.max.tail.angle : 0 -provider.STEP.OCC.healing.max.tail.width : -1 -provider.STEP.OCC.healing.selfintersecting.edge : -1 -provider.STEP.OCC.healing.intersecting.edges : -1 -provider.STEP.OCC.healing.nonadjacent.intersecting.edges : -1 -provider.STEP.OCC.healing.vertex.position : 0 -provider.STEP.OCC.healing.vertex.tolerance : -1 -" - -set conf [DumpConfiguration -vendor OCC -format STEP IGES] - -CompareConfiguration ${conf_ref} ${conf} diff --git a/tests/de_wrapper/configuration/A5 b/tests/de_wrapper/configuration/A5 deleted file mode 100644 index e4621026c5..0000000000 --- a/tests/de_wrapper/configuration/A5 +++ /dev/null @@ -1,13 +0,0 @@ -puts "============" -puts "0032821: DEWrapper - Implementation of a common toolkit for importing and exporting CAD files" -puts "============" -puts "" - -# Checking the stability of ability to change the configuration's values -set old_conf [DumpConfiguration] - -LoadConfiguration "" - -set new_conf [DumpConfiguration] - -CompareConfiguration ${old_conf} ${new_conf} diff --git a/tests/de_wrapper/stl/A1 b/tests/de_wrapper/stl/A1 deleted file mode 100644 index abc2828e83..0000000000 --- a/tests/de_wrapper/stl/A1 +++ /dev/null @@ -1,16 +0,0 @@ -puts "============" -puts "0032821: DEWrapper - Implementation of a common toolkit for importing and exporting CAD files" -puts "============" -puts "" - -readstl S_First ${filename} - -set file_path ${imagedir}/${casename}.stl - -writestl S_First $file_path - -readfile S_Second $file_path - -checktrinfo S_Second -ref [trinfo S_First] - -file delete $file_path diff --git a/tests/de_wrapper/stl/A2 b/tests/de_wrapper/stl/A2 deleted file mode 100644 index ea55b799eb..0000000000 --- a/tests/de_wrapper/stl/A2 +++ /dev/null @@ -1,24 +0,0 @@ -puts "============" -puts "0032821: DEWrapper - Implementation of a common toolkit for importing and exporting CAD files" -puts "============" -puts "" - -catch { Close D_First } -catch { Close D_Second } - -readstl S_First ${filename} -XNewDoc D_First -XNewDoc D_Second -XAddShape D_First S_First - -set file_path ${imagedir}/${casename}.stl - -WriteFile D_First $file_path -conf "provider.STL.OCC.AsciiFlag : 2 " - -readstl S_Second $file_path - -checktrinfo S_Second -ref [trinfo S_First] - -file delete $file_path -Close D_First -Close D_Second diff --git a/tests/de_wrapper/stl/A3 b/tests/de_wrapper/stl/A3 deleted file mode 100644 index a96b9823bc..0000000000 --- a/tests/de_wrapper/stl/A3 +++ /dev/null @@ -1,20 +0,0 @@ -puts "============" -puts "0032821: DEWrapper - Implementation of a common toolkit for importing and exporting CAD files" -puts "============" -puts "" - -catch { Close D_First } - -readstl S_First ${filename} - -set file_path ${imagedir}/${casename}.stl - -writefile S_First $file_path -conf "provider.STL.OCC.AsciiFlag : 2 " - -ReadFile D_First $file_path -XGetOneShape S_Second D_First - -checktrinfo S_Second -ref [trinfo S_First] - -file delete $file_path -Close D_First diff --git a/tests/de_wrapper/stl/A4 b/tests/de_wrapper/stl/A4 deleted file mode 100644 index 23e120a00a..0000000000 --- a/tests/de_wrapper/stl/A4 +++ /dev/null @@ -1,16 +0,0 @@ -puts "============" -puts "0032821: DEWrapper - Implementation of a common toolkit for importing and exporting CAD files" -puts "============" -puts "" - -readfile S_First ${filename} - -set file_path ${imagedir}/${casename}.stl - -writefile S_First $file_path -conf "provider.STL.OCC.AsciiFlag : 2 " - -readfile S_Second $file_path - -checktrinfo S_Second -ref [trinfo S_First] - -file delete $file_path diff --git a/tests/de_wrapper/vrml/A1 b/tests/de_wrapper/vrml/A1 deleted file mode 100644 index e9c8552943..0000000000 --- a/tests/de_wrapper/vrml/A1 +++ /dev/null @@ -1,21 +0,0 @@ -puts "============" -puts "0032821: DEWrapper - Implementation of a common toolkit for importing and exporting CAD files" -puts "============" -puts "" - -catch { Close D_First } - -loadvrml S_First ${filename} -XNewDoc D_First -XAddShape D_First S_First - -set file_path ${imagedir}/${casename}.vrml - -WriteVrml D_First $file_path - -readfile S_Second $file_path - -checktrinfo S_Second -ref [trinfo S_First] - -file delete $file_path -Close D_First diff --git a/tests/de_wrapper/vrml/A2 b/tests/de_wrapper/vrml/A2 deleted file mode 100644 index 36a6ab6800..0000000000 --- a/tests/de_wrapper/vrml/A2 +++ /dev/null @@ -1,21 +0,0 @@ -puts "============" -puts "0032821: DEWrapper - Implementation of a common toolkit for importing and exporting CAD files" -puts "============" -puts "" - -catch { Close D_First } - -loadvrml S_First ${filename} -XNewDoc D_First -XAddShape D_First S_First - -set file_path ${imagedir}/${casename}.wrl - -WriteFile D_First $file_path -conf "provider.VRML.OCC.RepresentationType : 2 " - -loadvrml S_Second $file_path - -checktrinfo S_Second -ref [trinfo S_First] - -file delete $file_path -Close D_First diff --git a/tests/de_wrapper/vrml/A3 b/tests/de_wrapper/vrml/A3 deleted file mode 100644 index 581ca8c808..0000000000 --- a/tests/de_wrapper/vrml/A3 +++ /dev/null @@ -1,16 +0,0 @@ -puts "============" -puts "0032821: DEWrapper - Implementation of a common toolkit for importing and exporting CAD files" -puts "============" -puts "" - -loadvrml S_First ${filename} - -set file_path ${imagedir}/${casename}.wrl - -writefile S_First $file_path -conf "provider.VRML.OCC.RepresentationType : 2 " - -loadvrml S_Second $file_path - -checktrinfo S_Second -ref [trinfo S_First] - -file delete $file_path diff --git a/tests/de_wrapper/vrml/A4 b/tests/de_wrapper/vrml/A4 deleted file mode 100644 index 2091c18f61..0000000000 --- a/tests/de_wrapper/vrml/A4 +++ /dev/null @@ -1,16 +0,0 @@ -puts "============" -puts "0032821: DEWrapper - Implementation of a common toolkit for importing and exporting CAD files" -puts "============" -puts "" - -readfile S_First ${filename} - -set file_path ${imagedir}/${casename}.wrl - -writefile S_First $file_path -conf "provider.VRML.OCC.RepresentationType : 2 " - -readfile S_Second $file_path - -checktrinfo S_Second -ref [trinfo S_First] - -file delete $file_path diff --git a/tests/demo/draw/binpersist_1 b/tests/demo/draw/binpersist_1 deleted file mode 100644 index a88cfa676d..0000000000 --- a/tests/demo/draw/binpersist_1 +++ /dev/null @@ -1,25 +0,0 @@ -# test binsave and binrestore commands - -pload TOPTEST - -set file $imagedir/${casename}.bin - -box b 10 20 30 100 200 300 - -if [regexp "Cannot write to the file $file" [binsave b $file]] { - puts "Error: binsave" -} elseif [regexp "Cannot read from the file $file" [binrestore $file bb]] { - puts "Error: binrestore" -} else { - file delete $file - if {[bounding b -dump] != [bounding bb -dump]} { - puts "Error: restored shape has another bounding box" - } - checkshape bb - checknbshapes bb -ref [nbshapes b] - checkprops bb -l 4800 - checkprops bb -s 220000 - checkprops bb -v 6000000 -} - -puts "TEST COMPLETED" diff --git a/tests/gdt/dimensions/A1 b/tests/gdt/dimensions/A1 deleted file mode 100644 index 7113e61162..0000000000 --- a/tests/gdt/dimensions/A1 +++ /dev/null @@ -1,14 +0,0 @@ - -box b 10 10 10 -explode b -explode b_1 - -NewDocument D -XAddShape D b -XAddDimension D b_1_1 -#0:1:4:1 -XSetDimensionType D 0:1:4:1 14 -XSetDimensionValue D 0:1:4:1 1.5 - -set c_value "1.5" -set c_type "Size_CurveLength" \ No newline at end of file diff --git a/tests/gdt/dimensions/A2 b/tests/gdt/dimensions/A2 deleted file mode 100644 index 9094c6e858..0000000000 --- a/tests/gdt/dimensions/A2 +++ /dev/null @@ -1,16 +0,0 @@ - -box b 10 10 10 -explode b -explode b_1 - -NewDocument D -XAddShape D b -XAddDimension D b_1_1 -#0:1:4:1 -XSetDimensionType D 0:1:4:1 15 -XSetDimensionValue D 0:1:4:1 2.5 -XSetDimensionQualifier D 0:1:4:1 2 - -set c_value "2.5" -set c_type "Size_Diameter" -set c_qalif "Max" \ No newline at end of file diff --git a/tests/gdt/dimensions/A3 b/tests/gdt/dimensions/A3 deleted file mode 100644 index f005a9a2ca..0000000000 --- a/tests/gdt/dimensions/A3 +++ /dev/null @@ -1,15 +0,0 @@ - -box b 10 10 10 -explode b -explode b_1 - -NewDocument D -XAddShape D b -XAddDimension D b_1_1 - -#0:1:4:1 -XSetDimensionType D 0:1:4:1 14 -XSetDimensionRange D 0:1:4:1 1.5 2.5 - -set c_range "lower 1.5 upper 2.5" -set c_type "Size_CurveLength" \ No newline at end of file diff --git a/tests/gdt/dimensions/A4 b/tests/gdt/dimensions/A4 deleted file mode 100644 index ad0cc80e29..0000000000 --- a/tests/gdt/dimensions/A4 +++ /dev/null @@ -1,20 +0,0 @@ - -box b 10 10 10 -explode b -explode b_1 - -NewDocument D -XAddShape D b -XAddDimension D b_1_1 -#0:1:4:1 -XSetDimensionType D 0:1:4:1 15 -XSetDimensionValue D 0:1:4:1 2.5 -XSetDimensionClassOfTol D 0:1:4:1 1 8 7 -XSetDimensionNbOfDecimalPlaces D 0:1:4:1 3 3 -XAddDimensionModifiers D 0:1:4:1 14 0 - -set c_value "2.5" -set c_type "Size_Diameter" -set c_class "f6" -set c_d "3.3" -set c_mod "AverageSize, ControlledRadius" \ No newline at end of file diff --git a/tests/gdt/dimensions/A5 b/tests/gdt/dimensions/A5 deleted file mode 100644 index edd83c240c..0000000000 --- a/tests/gdt/dimensions/A5 +++ /dev/null @@ -1,24 +0,0 @@ - -box b 10 10 10 -box b1 20 20 20 30 30 30 -explode b -explode b_1 -explode b1 -explode b1_1 - -NewDocument D -XAddShape D b -XAddShape D b1 -XAddDimension D b_1_1 b1_1_1 -#0:1:4:1 -XSetDimensionType D 0:1:4:1 2 -XSetDimensionValue D 0:1:4:1 6 -XSetDimensionPlusMinusTol D 0:1:4:1 -0.001 0.002 -vertex v1 10 10 10 -vertex v2 20 20 20 -XSetDimensionPoints D 0:1:4:1 v1 v2 - -set c_value "6" -set c_type "Location_LinearDistance" -set c_pnts "10;10;10 20;20;20" -set c_plusminus "lower -0.001 upper 0.002" \ No newline at end of file diff --git a/tests/gdt/dimensions/A6 b/tests/gdt/dimensions/A6 deleted file mode 100644 index 35f972c698..0000000000 --- a/tests/gdt/dimensions/A6 +++ /dev/null @@ -1,22 +0,0 @@ - -box b 10 10 10 -box b1 20 20 20 30 30 30 -explode b -explode b_1 -explode b1 -explode b1_1 - -NewDocument D -XAddShape D b -XAddShape D b1 -XAddDimension D b_1_1 b1_1_1 -#0:1:4:1 -XSetDimensionType D 0:1:4:1 12 -XSetDimensionValue D 0:1:4:1 6 -XSetDimensionPlusMinusTol D 0:1:4:1 -0.001 0.002 -XSetDimensionDir D 0:1:4:1 1 1 0 - -set c_value "6" -set c_type "Location_Oriented" -set c_plusminus "lower -0.001 upper 0.002" -set c_dir "0.70710678118654757;0.70710678118654757;0" diff --git a/tests/gdt/dimensions/A7 b/tests/gdt/dimensions/A7 deleted file mode 100644 index 4522ba3aae..0000000000 --- a/tests/gdt/dimensions/A7 +++ /dev/null @@ -1,33 +0,0 @@ -# test text descriptions -box b 10 10 10 -explode b e - -NewDocument D_init -XAddShape D_init b -XAddDimension D_init b_1 -#0:1:4:1 -XSetDimensionType D_init 0:1:4:1 14 -XSetDimensionValue D_init 0:1:4:1 10 -XAddDimensionDescr D_init 0:1:4:1 description1 -XAddDimensionDescr D_init 0:1:4:1 description2 name2 -# Export -set isOK 1 -if { [catch { WriteStep D_init $imagedir/${casename}_D_init.stp } catch_result] } { - puts "Error: File was not written - exception" - set isOK 0 - } -# Import -if {$isOK} { - if { [catch { ReadStep D $imagedir/${casename}_D_init.stp } catch_result] } { - puts "Error: File was not read - exception" - set isOK 0 - } - } -# Reference data -if {$isOK} { -set c_value "10" -set c_type "Size_CurveLength" -set c_descr {name: description: description1 -name: name2 description: description2 -} -} diff --git a/tests/gdt/dimensions/A8 b/tests/gdt/dimensions/A8 deleted file mode 100644 index fffe3f7b51..0000000000 --- a/tests/gdt/dimensions/A8 +++ /dev/null @@ -1,38 +0,0 @@ -# test annotation plane -box b 10 10 10 -explode b e - -NewDocument D_init -XAddShape D_init b -XAddDimension D_init b_1 -#0:1:4:1 -XSetDimensionType D_init 0:1:4:1 14 -XSetDimensionValue D_init 0:1:4:1 10 -XSetGDTPosition D_init 0:1:4:1 -5 0 7 -1 0 0 0 1 0 -# Presentation -line l -5 0 0 0 0 1 -mkedge prs l 0 10 -XSetGDTPresentation D_init 0:1:4:1 prs presentation -# Export -set isOK 1 -set filename $imagedir/${casename}_D_init.stp -if { [catch { WriteStep D_init $filename } catch_result] } { - puts "Error: File was not written - exception" - set isOK 0 - } -# Import -if {$isOK} { - if { [catch { ReadStep D $filename } catch_result] } { - puts "Error: File was not read - exception" - set isOK 0 - } - } -# Reference data -if {$isOK} { -set c_value "10" -set c_type "Size_CurveLength" -set c_pos {position: -5 0 7 -normal: -1 0 0 -x_direction: 0 1 0 -} -} diff --git a/tests/gdt/dimensions/A9 b/tests/gdt/dimensions/A9 deleted file mode 100644 index 7daba042c4..0000000000 --- a/tests/gdt/dimensions/A9 +++ /dev/null @@ -1,35 +0,0 @@ -# test connection points -box b 10 10 10 -explode b e - -NewDocument D_init -XAddShape D_init b -XAddDimension D_init b_1 b_2 -#0:1:4:1 -XSetDimensionType D_init 0:1:4:1 2 -XSetDimensionValue D_init 0:1:4:1 10 -# Connection points -vertex v1 1 0 0 -vertex v2 9 0 0 -XSetDimensionPoints D_init 0:1:4:1 v1 v2 - -# Export -set isOK 1 -set filename $imagedir/${casename}_D_init.stp -if { [catch { WriteStep D_init $filename } catch_result] } { - puts "Error: File was not written - exception" - set isOK 0 - } -# Import -if {$isOK} { - if { [catch { ReadStep D $filename } catch_result] } { - puts "Error: File was not read - exception" - set isOK 0 - } - } -# Reference data -if {$isOK} { - set c_value "10" - set c_type "Location_LinearDistance" - set c_pnts "1;0;0 9;0;0" -} diff --git a/tests/gdt/notes/A1 b/tests/gdt/notes/A1 deleted file mode 100644 index 67316e0662..0000000000 --- a/tests/gdt/notes/A1 +++ /dev/null @@ -1,5 +0,0 @@ - -# expected results -set nb_annotations_result 0 -set nb_notes_result 0 -set nb_orphan_result 0 diff --git a/tests/gdt/notes/A2 b/tests/gdt/notes/A2 deleted file mode 100644 index a9b0e61e4c..0000000000 --- a/tests/gdt/notes/A2 +++ /dev/null @@ -1,13 +0,0 @@ - -# create comment note -set comment [XNoteCreateComment D "Hello, World!" --user "The user" --time [clock format [clock seconds] -format "%Y-%m-%dT%H:%M:%S"]] -XNoteDump D ${comment} - -# create balloon note -set balloon [XNoteCreateComment D "Hello, Everyone!" --user "The user" --time [clock format [clock seconds] -format "%Y-%m-%dT%H:%M:%S"]] -XNoteDump D ${balloon} - -# expected results -set nb_annotations_result 0 -set nb_notes_result 2 -set nb_orphan_result 2 diff --git a/tests/gdt/notes/A3 b/tests/gdt/notes/A3 deleted file mode 100644 index d51374cdb4..0000000000 --- a/tests/gdt/notes/A3 +++ /dev/null @@ -1,9 +0,0 @@ - -# create binary note -set data [XNoteCreateBinData D "Binary data" --data "abcdefghijklmnopqrstuvwxyz" --user "The user" --time [clock format [clock seconds] -format "%Y-%m-%dT%H:%M:%S"]] -XNoteDump D ${data} - -# expected results -set nb_annotations_result 0 -set nb_notes_result 1 -set nb_orphan_result 1 diff --git a/tests/gdt/notes/A4 b/tests/gdt/notes/A4 deleted file mode 100644 index ed25fabadc..0000000000 --- a/tests/gdt/notes/A4 +++ /dev/null @@ -1,16 +0,0 @@ - -# create comment note -set comment [XNoteCreateComment D "Hello, World!" --user "The user" --time [clock format [clock seconds] -format "%Y-%m-%dT%H:%M:%S"]] -XNoteDump D ${comment} - -# create balloon note -set balloon [XNoteCreateComment D "Hello, Everyone!" --user "The user" --time [clock format [clock seconds] -format "%Y-%m-%dT%H:%M:%S"]] -XNoteDump D ${balloon} - -# delete comment note -XNoteDelete D ${comment} - -# expected results -set nb_annotations_result 0 -set nb_notes_result 1 -set nb_orphan_result 1 diff --git a/tests/gdt/notes/A5 b/tests/gdt/notes/A5 deleted file mode 100644 index 08e910c21a..0000000000 --- a/tests/gdt/notes/A5 +++ /dev/null @@ -1,16 +0,0 @@ - -# create comment note -set comment [XNoteCreateComment D "Hello, World!" --user "The user" --time [clock format [clock seconds] -format "%Y-%m-%dT%H:%M:%S"]] -XNoteDump D ${comment} - -# create balloon note -set balloon [XNoteCreateComment D "Hello, Everyone!" --user "The user" --time [clock format [clock seconds] -format "%Y-%m-%dT%H:%M:%S"]] -XNoteDump D ${balloon} - -# delete comment note -XNoteDeleteAll D - -# expected results -set nb_annotations_result 0 -set nb_notes_result 0 -set nb_orphan_result 0 diff --git a/tests/gdt/notes/B1 b/tests/gdt/notes/B1 deleted file mode 100644 index 6b2d952beb..0000000000 --- a/tests/gdt/notes/B1 +++ /dev/null @@ -1,25 +0,0 @@ - -# create comment note -set comment [XNoteCreateComment D "Hello, World!" --user "The user" --time [clock format [clock seconds] -format "%Y-%m-%dT%H:%M:%S"]] -XNoteDump D ${comment} - -# annotate box_1 -set assemblyItemId [XNoteRefDump D [XNoteAdd D ${comment} ${box_1}]] - -# annotate box_2 -XNoteRefDump D [XNoteAdd D ${comment} ${box_2}] - -# list annotations -XNoteAnnotations D - -# expected results -set nb_annotations_result 2 -set nb_notes_result 1 -set nb_orphan_result 0 - -# check the assembly item id -if {[regexp "Item : ${box_1}" ${assemblyItemId}]} { - puts "OK : assembly item id" -} else { - puts "Error : wrong assembly item id" -} diff --git a/tests/gdt/notes/B2 b/tests/gdt/notes/B2 deleted file mode 100644 index 7172784bd9..0000000000 --- a/tests/gdt/notes/B2 +++ /dev/null @@ -1,22 +0,0 @@ - -# create comment_1 note -set comment_1 [XNoteCreateComment D "Hello, World!" --user "The user" --time [clock format [clock seconds] -format "%Y-%m-%dT%H:%M:%S"]] -XNoteDump D ${comment_1} - -# create comment_2 note -set comment_2 [XNoteCreateComment D "Hello, Everyone!" --user "The user" --time [clock format [clock seconds] -format "%Y-%m-%dT%H:%M:%S"]] -XNoteDump D ${comment_2} - -# annotate box_1 -XNoteRefDump D [XNoteAdd D ${comment_1} ${box_1}] - -# annotate box_2 -XNoteRefDump D [XNoteAdd D ${comment_2} ${box_2}] - -# list annotations -XNoteAnnotations D - -# expected results -set nb_annotations_result 2 -set nb_notes_result 2 -set nb_orphan_result 0 diff --git a/tests/gdt/notes/B3 b/tests/gdt/notes/B3 deleted file mode 100644 index d3990ebc12..0000000000 --- a/tests/gdt/notes/B3 +++ /dev/null @@ -1,25 +0,0 @@ - -# create comment_1 note -set comment_1 [XNoteCreateComment D "Hello, World!" --user "The user" --time [clock format [clock seconds] -format "%Y-%m-%dT%H:%M:%S"]] -XNoteDump D ${comment_1} - -# create comment_2 note -set comment_2 [XNoteCreateComment D "Hello, Everyone!" --user "The user" --time [clock format [clock seconds] -format "%Y-%m-%dT%H:%M:%S"]] -XNoteDump D ${comment_2} - -# annotate box_1 -XNoteRefDump D [XNoteAdd D ${comment_1} ${box_1}] - -# annotate box_2 -XNoteRefDump D [XNoteAdd D ${comment_1} ${box_2}] - -# list annotations -XNoteAnnotations D - -# delete orphan notes -XNoteDeleteOrphan D - -# expected results -set nb_annotations_result 2 -set nb_notes_result 1 -set nb_orphan_result 0 diff --git a/tests/gdt/notes/B4 b/tests/gdt/notes/B4 deleted file mode 100644 index 2adfe3f1cc..0000000000 --- a/tests/gdt/notes/B4 +++ /dev/null @@ -1,22 +0,0 @@ - -# create comment_1 note -set comment_1 [XNoteCreateComment D "Hello, World!" --user "The user" --time [clock format [clock seconds] -format "%Y-%m-%dT%H:%M:%S"]] -XNoteDump D ${comment_1} - -# create comment_2 note -set comment_2 [XNoteCreateComment D "Hello, Everyone!" --user "The user" --time [clock format [clock seconds] -format "%Y-%m-%dT%H:%M:%S"]] -XNoteDump D ${comment_2} - -# annotate box_1 -XNoteRefDump D [XNoteAdd D ${comment_1} ${box_1}] - -# annotate box_1 -XNoteRefDump D [XNoteAdd D ${comment_2} ${box_1}] - -# list annotations -XNoteAnnotations D - -# expected results -set nb_annotations_result 1 -set nb_notes_result 2 -set nb_orphan_result 0 diff --git a/tests/gdt/notes/B5 b/tests/gdt/notes/B5 deleted file mode 100644 index 43f9866d93..0000000000 --- a/tests/gdt/notes/B5 +++ /dev/null @@ -1,15 +0,0 @@ - -# create comment note -set comment [XNoteCreateComment D "Hello, World!" --user "The user" --time [clock format [clock seconds] -format "%Y-%m-%dT%H:%M:%S"]] -XNoteDump D ${comment} - -# annotate box_1 attribute -XNoteRefDump D [XNoteAdd D ${comment} ${box_1} --attr ${guid}] - -# list annotations -XNoteAnnotations D - -# expected results -set nb_annotations_result 1 -set nb_notes_result 1 -set nb_orphan_result 0 diff --git a/tests/gdt/notes/B6 b/tests/gdt/notes/B6 deleted file mode 100644 index 92f81cd941..0000000000 --- a/tests/gdt/notes/B6 +++ /dev/null @@ -1,18 +0,0 @@ - -# create comment note -set comment [XNoteCreateComment D "Hello, World!" --user "The user" --time [clock format [clock seconds] -format "%Y-%m-%dT%H:%M:%S"]] -XNoteDump D ${comment} - -# annotate box_1 -XNoteRefDump D [XNoteAdd D ${comment} ${box_1}] - -# annotate box_1 attribute -XNoteRefDump D [XNoteAdd D ${comment} ${box_1} --attr ${guid}] - -# list annotations -XNoteAnnotations D - -# expected results -set nb_annotations_result 2 -set nb_notes_result 1 -set nb_orphan_result 0 diff --git a/tests/gdt/notes/B7 b/tests/gdt/notes/B7 deleted file mode 100644 index a6b102691f..0000000000 --- a/tests/gdt/notes/B7 +++ /dev/null @@ -1,21 +0,0 @@ - -# create comment note -set comment [XNoteCreateComment D "Hello, World!" --user "The user" --time [clock format [clock seconds] -format "%Y-%m-%dT%H:%M:%S"]] -XNoteDump D ${comment} - -# annotate box_1 -XNoteRefDump D [XNoteAdd D ${comment} ${box_1}] - -# annotate box_1 attribute -XNoteRefDump D [XNoteAdd D ${comment} ${box_1} --attr ${guid}] - -# annotate box_1 subshape 1 -XNoteRefDump D [XNoteAdd D ${comment} ${box_1} --subshape 1] - -# list annotations -XNoteAnnotations D - -# expected results -set nb_annotations_result 3 -set nb_notes_result 1 -set nb_orphan_result 0 diff --git a/tests/gdt/notes/C1 b/tests/gdt/notes/C1 deleted file mode 100644 index cb85e0552a..0000000000 --- a/tests/gdt/notes/C1 +++ /dev/null @@ -1,24 +0,0 @@ - -# create comment note -set comment [XNoteCreateComment D "Hello, World!" --user "The user" --time [clock format [clock seconds] -format "%Y-%m-%dT%H:%M:%S"]] -XNoteDump D ${comment} - -# annotate box_1 -XNoteRefDump D [XNoteAdd D ${comment} ${box_1}] - -# annotate box_2 -XNoteRefDump D [XNoteAdd D ${comment} ${box_2}] - -# list annotations -XNoteAnnotations D - -# delete note -XNoteDelete D ${comment} - -# list annotations -XNoteAnnotations D - -# expected results -set nb_annotations_result 0 -set nb_notes_result 0 -set nb_orphan_result 0 diff --git a/tests/gdt/notes/C2 b/tests/gdt/notes/C2 deleted file mode 100644 index e8be62e537..0000000000 --- a/tests/gdt/notes/C2 +++ /dev/null @@ -1,28 +0,0 @@ - -# create comment_1 note -set comment_1 [XNoteCreateComment D "Hello, World!" --user "The user" --time [clock format [clock seconds] -format "%Y-%m-%dT%H:%M:%S"]] -XNoteDump D ${comment_1} - -# create comment_2 note -set comment_2 [XNoteCreateComment D "Hello, World!" --user "The user" --time [clock format [clock seconds] -format "%Y-%m-%dT%H:%M:%S"]] -XNoteDump D ${comment_2} - -# annotate box_1 -XNoteRefDump D [XNoteAdd D ${comment_1} ${box_1}] - -# annotate box_2 -XNoteRefDump D [XNoteAdd D ${comment_2} ${box_2}] - -# list annotations -XNoteAnnotations D - -# delete comment_1 note -XNoteDelete D ${comment_1} - -# list annotations -XNoteAnnotations D - -# expected results -set nb_annotations_result 1 -set nb_notes_result 1 -set nb_orphan_result 0 diff --git a/tests/gdt/notes/C3 b/tests/gdt/notes/C3 deleted file mode 100644 index 37d47964ae..0000000000 --- a/tests/gdt/notes/C3 +++ /dev/null @@ -1,28 +0,0 @@ - -# create comment_1 note -set comment_1 [XNoteCreateComment D "Hello, World!" --user "The user" --time [clock format [clock seconds] -format "%Y-%m-%dT%H:%M:%S"]] -XNoteDump D ${comment_1} - -# create comment_2 note -set comment_2 [XNoteCreateComment D "Hello, World!" --user "The user" --time [clock format [clock seconds] -format "%Y-%m-%dT%H:%M:%S"]] -XNoteDump D ${comment_2} - -# annotate box_1 -XNoteRefDump D [XNoteAdd D ${comment_1} ${box_1}] - -# annotate box_2 -XNoteRefDump D [XNoteAdd D ${comment_2} ${box_2}] - -# list annotations -XNoteAnnotations D - -# remove comment_1 annotation -XNoteRemove D ${box_1} ${comment_1} - -# list annotations -XNoteAnnotations D - -# expected results -set nb_annotations_result 1 -set nb_notes_result 2 -set nb_orphan_result 1 diff --git a/tests/gdt/notes/C4 b/tests/gdt/notes/C4 deleted file mode 100644 index 6b8b466685..0000000000 --- a/tests/gdt/notes/C4 +++ /dev/null @@ -1,27 +0,0 @@ - -# create comment note -set comment [XNoteCreateComment D "Hello, World!" --user "The user" --time [clock format [clock seconds] -format "%Y-%m-%dT%H:%M:%S"]] -XNoteDump D ${comment} - -# annotate box_1 -XNoteRefDump D [XNoteAdd D ${comment} ${box_1}] - -# annotate box_1 attribute -XNoteRefDump D [XNoteAdd D ${comment} ${box_1} --attr ${guid}] - -# annotate box_1 subshape 1 -XNoteRefDump D [XNoteAdd D ${comment} ${box_1} --subshape 1] - -# list annotations -XNoteAnnotations D - -# remove attribute annotation -XNoteRemove D ${box_1} ${comment} --attr ${guid} - -# remove subshape annotation -XNoteRemove D ${box_1} ${comment} --subshape 1 - -# expected results -set nb_annotations_result 1 -set nb_notes_result 1 -set nb_orphan_result 0 diff --git a/tests/gdt/notes/C5 b/tests/gdt/notes/C5 deleted file mode 100644 index 8031a12c04..0000000000 --- a/tests/gdt/notes/C5 +++ /dev/null @@ -1,29 +0,0 @@ - -# create comment_1 note -set comment_1 [XNoteCreateComment D "Hello, World!" --user "The user" --time [clock format [clock seconds] -format "%Y-%m-%dT%H:%M:%S"]] -XNoteDump D ${comment_1} - -# create comment_2 note -set comment_2 [XNoteCreateComment D "Hello, Everyone!" --user "The user" --time [clock format [clock seconds] -format "%Y-%m-%dT%H:%M:%S"]] -XNoteDump D ${comment_2} - -# annotate box_1 -XNoteRefDump D [XNoteAdd D ${comment_1} ${box_1}] - -# annotate box_1 attribute -XNoteRefDump D [XNoteAdd D ${comment_1} ${box_1} --attr ${guid}] -XNoteRefDump D [XNoteAdd D ${comment_2} ${box_1} --attr ${guid}] - -# annotate box_1 subshape 1 -XNoteRefDump D [XNoteAdd D ${comment_1} ${box_1} --subshape 1] - -# list annotations -XNoteAnnotations D - -# remove all attribute annotations -XNoteRemoveAll D ${box_1} --attr ${guid} - -# expected results -set nb_annotations_result 2 -set nb_notes_result 2 -set nb_orphan_result 1 diff --git a/tests/gdt/notes/C6 b/tests/gdt/notes/C6 deleted file mode 100644 index 4c3e71ace9..0000000000 --- a/tests/gdt/notes/C6 +++ /dev/null @@ -1,29 +0,0 @@ - -# create comment_1 note -set comment_1 [XNoteCreateComment D "Hello, World!" --user "The user" --time [clock format [clock seconds] -format "%Y-%m-%dT%H:%M:%S"]] -XNoteDump D ${comment_1} - -# create comment_2 note -set comment_2 [XNoteCreateComment D "Hello, Everyone!" --user "The user" --time [clock format [clock seconds] -format "%Y-%m-%dT%H:%M:%S"]] -XNoteDump D ${comment_2} - -# annotate box_1 -XNoteRefDump D [XNoteAdd D ${comment_1} ${box_1}] - -# annotate box_1 attribute -XNoteRefDump D [XNoteAdd D ${comment_1} ${box_1} --attr ${guid}] - -# annotate box_1 subshape 1 -XNoteRefDump D [XNoteAdd D ${comment_1} ${box_1} --subshape 1] -XNoteRefDump D [XNoteAdd D ${comment_2} ${box_1} --subshape 1] - -# list annotations -XNoteAnnotations D - -# remove all attribute annotations -XNoteRemoveAll D ${box_1} --subshape 1 - -# expected results -set nb_annotations_result 2 -set nb_notes_result 2 -set nb_orphan_result 1 diff --git a/tests/gdt/notes/C7 b/tests/gdt/notes/C7 deleted file mode 100644 index 0aa7749492..0000000000 --- a/tests/gdt/notes/C7 +++ /dev/null @@ -1,31 +0,0 @@ - -# create comment_1 note -set comment_1 [XNoteCreateComment D "Hello, World!" --user "The user" --time [clock format [clock seconds] -format "%Y-%m-%dT%H:%M:%S"]] -XNoteDump D ${comment_1} - -# create comment_2 note -set comment_2 [XNoteCreateComment D "Hello, Everyone!" --user "The user" --time [clock format [clock seconds] -format "%Y-%m-%dT%H:%M:%S"]] -XNoteDump D ${comment_2} - -# annotate box_1 -XNoteRefDump D [XNoteAdd D ${comment_1} ${box_1}] -XNoteRefDump D [XNoteAdd D ${comment_2} ${box_1}] - -# annotate box_1 attribute -XNoteRefDump D [XNoteAdd D ${comment_1} ${box_1} --attr ${guid}] -XNoteRefDump D [XNoteAdd D ${comment_2} ${box_1} --attr ${guid}] - -# annotate box_1 subshape 1 -XNoteRefDump D [XNoteAdd D ${comment_1} ${box_1} --subshape 1] -XNoteRefDump D [XNoteAdd D ${comment_2} ${box_1} --subshape 1] - -# list annotations -XNoteAnnotations D - -# remove all box annotations -XNoteRemoveAll D ${box_1} - -# expected results -set nb_annotations_result 2 -set nb_notes_result 2 -set nb_orphan_result 0 diff --git a/tests/gdt/notes/C8 b/tests/gdt/notes/C8 deleted file mode 100644 index 85f41d9014..0000000000 --- a/tests/gdt/notes/C8 +++ /dev/null @@ -1,33 +0,0 @@ - -# create comment_1 note -set comment_1 [XNoteCreateComment D "Hello, World!" --user "The user" --time [clock format [clock seconds] -format "%Y-%m-%dT%H:%M:%S"]] -XNoteDump D ${comment_1} - -# create comment_2 note -set comment_2 [XNoteCreateComment D "Hello, Everyone!" --user "The user" --time [clock format [clock seconds] -format "%Y-%m-%dT%H:%M:%S"]] -XNoteDump D ${comment_2} - -# annotate box_1 -XNoteRefDump D [XNoteAdd D ${comment_1} ${box_1}] -XNoteRefDump D [XNoteAdd D ${comment_2} ${box_1}] - -# annotate box_1 attribute -XNoteRefDump D [XNoteAdd D ${comment_1} ${box_1} --attr ${guid}] -XNoteRefDump D [XNoteAdd D ${comment_2} ${box_1} --attr ${guid}] - -# annotate box_1 subshape 1 -XNoteRefDump D [XNoteAdd D ${comment_1} ${box_1} --subshape 1] -XNoteRefDump D [XNoteAdd D ${comment_2} ${box_1} --subshape 1] - -# list annotations -XNoteAnnotations D - -# remove all box annotations -XNoteRemoveAll D ${box_1} -XNoteRemoveAll D ${box_1} --attr ${guid} -XNoteRemoveAll D ${box_1} --subshape 1 - -# expected results -set nb_annotations_result 0 -set nb_notes_result 2 -set nb_orphan_result 2 diff --git a/tests/gdt/notes/C9 b/tests/gdt/notes/C9 deleted file mode 100644 index 8b7a49fb19..0000000000 --- a/tests/gdt/notes/C9 +++ /dev/null @@ -1,33 +0,0 @@ - -# create comment_1 note -set comment_1 [XNoteCreateComment D "Hello, World!" --user "The user" --time [clock format [clock seconds] -format "%Y-%m-%dT%H:%M:%S"]] -XNoteDump D ${comment_1} - -# create comment_2 note -set comment_2 [XNoteCreateComment D "Hello, Everyone!" --user "The user" --time [clock format [clock seconds] -format "%Y-%m-%dT%H:%M:%S"]] -XNoteDump D ${comment_2} - -# annotate box_1 -XNoteRefDump D [XNoteAdd D ${comment_1} ${box_1}] -XNoteRefDump D [XNoteAdd D ${comment_2} ${box_1}] - -# annotate box_1 attribute -XNoteRefDump D [XNoteAdd D ${comment_1} ${box_1} --attr ${guid}] -XNoteRefDump D [XNoteAdd D ${comment_2} ${box_1} --attr ${guid}] - -# annotate box_1 subshape 1 -XNoteRefDump D [XNoteAdd D ${comment_1} ${box_1} --subshape 1] -XNoteRefDump D [XNoteAdd D ${comment_2} ${box_1} --subshape 1] - -# list annotations -XNoteAnnotations D - -# remove all box annotations -XNoteRemoveAll D ${box_1} --del-orphan -XNoteRemoveAll D ${box_1} --attr ${guid} --del-orphan -XNoteRemoveAll D ${box_1} --subshape 1 --del-orphan - -# expected results -set nb_annotations_result 0 -set nb_notes_result 0 -set nb_orphan_result 0 diff --git a/tests/gdt/notes/D1 b/tests/gdt/notes/D1 deleted file mode 100644 index 49bf36c6df..0000000000 --- a/tests/gdt/notes/D1 +++ /dev/null @@ -1,51 +0,0 @@ - -# create comment_1 note -set comment_1 [XNoteCreateComment D "Hello, World!" --user "The user" --time [clock format [clock seconds] -format "%Y-%m-%dT%H:%M:%S"]] -XNoteDump D ${comment_1} - -# create comment_2 note -set comment_2 [XNoteCreateComment D "Hello, Everyone!" --user "The user" --time [clock format [clock seconds] -format "%Y-%m-%dT%H:%M:%S"]] -XNoteDump D ${comment_2} - -# annotate box_1 -set annotated_1 [XNoteAdd D ${comment_1} ${box_1}] -set annotated_2 [XNoteAdd D ${comment_2} ${box_1}] -if {${annotated_1} != ${annotated_2}} { - puts "Error : item annotation labels (${annotated_1} and ${annotated_2}) must be equal not equal." -} - -# annotate box_1 attribute -set annotated_1_attr [XNoteAdd D ${comment_1} ${box_1} --attr ${guid}] -set annotated_2_attr [XNoteAdd D ${comment_2} ${box_1} --attr ${guid}] -if {${annotated_1_attr} != ${annotated_2_attr}} { - puts "Error : item's attribute annotation labels (${annotated_1_attr} and ${annotated_2_attr}) must be equal not equal." -} - -# annotate box_1 subshape 1 -set annotated_1_subshape [XNoteAdd D ${comment_1} ${box_1} --subshape 1] -set annotated_2_subshape [XNoteAdd D ${comment_2} ${box_1} --subshape 1] -if {${annotated_1_subshape} != ${annotated_2_subshape}} { - puts "Error : item's subshape annotation labels (${annotated_1_subshape} and ${annotated_2_subshape}) must be equal not equal." -} - -# find annotations -set annotated_found [XNoteFindAnnotated D ${box_1}] -if {${annotated_1} != ${annotated_found}} { - puts "Error : ${annotated_1} is expected to found instead of ${annotated_found}" -} -set annotated_attr_found [XNoteFindAnnotated D ${box_1} --attr ${guid}] -if {${annotated_1_attr} != ${annotated_attr_found}} { - puts "Error : ${annotated_1_attr} is expected to found instead of ${annotated_attr_found}" -} -set annotated_subshape_found [XNoteFindAnnotated D ${box_1} --subshape 1] -if {${annotated_1_subshape} != ${annotated_subshape_found}} { - puts "Error : ${annotated_1_subshape} is expected to found instead of ${annotated_subshape_found}" -} - -# list annotations -XNoteAnnotations D - -# expected results -set nb_annotations_result 3 -set nb_notes_result 2 -set nb_orphan_result 0 diff --git a/tests/gdt/tolerances/A1 b/tests/gdt/tolerances/A1 deleted file mode 100644 index 8e0ad28071..0000000000 --- a/tests/gdt/tolerances/A1 +++ /dev/null @@ -1,35 +0,0 @@ - -box b 10 10 10 -explode b -explode b_1 - -NewDocument D -XAddShape D b -XAddGeomTolerance D b_1_1 -XAddDatum D b_1_2 -#0:1:4:1 -#0:1:4:2 -XSetDatumName D 0:1:4:2 A -XAddDatumModifier D 0:1:4:2 10 -XSetDatumPosition D 0:1:4:2 1 -XSetDatum D 0:1:4:2 0:1:4:1 -XSetToleranceValue D 0:1:4:1 0.5 -XSetTypeOfTolerance D 0:1:4:1 1 -XSetTypeOfToleranceValue D 0:1:4:1 1 -XSetTolMaterialReq D 0:1:4:1 1 -XSetTolZoneMod D 0:1:4:1 1 -XSetTolZoneModValue D 0:1:4:1 1 -XAddTolModifier D 0:1:4:1 6 1 -XSetTolMaxValue D 0:1:4:1 1.5 - -set c_dname "A" -set c_dmod "DistanceVariable" -set c_val "0.5" -set c_type "Angularity" -set c_typev "Diameter" -set c_mat "M" -set c_zone "P" -set c_zonev "1" -set c_mod "Major_Diameter, Common_Zone" -set c_max "1.5" - diff --git a/tests/gdt/tolerances/A2 b/tests/gdt/tolerances/A2 deleted file mode 100644 index cecdf42ce8..0000000000 --- a/tests/gdt/tolerances/A2 +++ /dev/null @@ -1,28 +0,0 @@ - -box b 10 10 10 -explode b -explode b_1 - -NewDocument D -XAddShape D b -XAddGeomTolerance D b_1_1 -XAddDatum D b_1_2 -XAddDatum D b_1_3 -#0:1:4:1 -#0:1:4:2 -#0:1:4:3 -XSetDatumName D 0:1:4:2 A -XSetDatumPosition D 0:1:4:2 1 -XSetDatumName D 0:1:4:3 B -XSetDatumPosition D 0:1:4:3 2 -XAddDatumModifier D 0:1:4:2 10 -XSetDatum D 0:1:4:2 0:1:4:1 -XSetDatum D 0:1:4:3 0:1:4:1 -XSetToleranceValue D 0:1:4:1 0.5 - - -set c_dname "A" -set c_dmod "DistanceVariable" -set c_val "0.5" - - diff --git a/tests/geometry/circ2d3Tan/CircleCircleCircle_11 b/tests/geometry/circ2d3Tan/CircleCircleCircle_11 deleted file mode 100644 index e5996c0e28..0000000000 --- a/tests/geometry/circ2d3Tan/CircleCircleCircle_11 +++ /dev/null @@ -1,13 +0,0 @@ -qcircle c1 0 0 50 -qcircle c2 20 0 10 -qcircle c3 0 20 10 -circ2d3Tan tan1 c1 c2 c3 - -checklength tan1_1 -l 168.36566348025758 -checklength tan1_2 -l 244.52937099154383 -checklength tan1_3 -l 131.42863607625242 -checklength tan1_4 -l 182.73062928272694 -checklength tan1_5 -l 182.7306292827268 -checklength tan1_6 -l 131.42863607625236 -checklength tan1_7 -l 94.936311385359318 -checklength tan1_8 -l 178.56704904481091 diff --git a/tests/geometry/circ2d3Tan/CircleCirclePoint_11 b/tests/geometry/circ2d3Tan/CircleCirclePoint_11 deleted file mode 100644 index 994fb7033b..0000000000 --- a/tests/geometry/circ2d3Tan/CircleCirclePoint_11 +++ /dev/null @@ -1,7 +0,0 @@ -qcircle c1 0 0 10 -qcircle c2 30 0 20 -point p1 10 10 -circ2d3Tan tan1 c1 c2 p1 - -checklength tan1_1 -l 13.802267767659149 -checklength tan1_2 -l 80.445511840034683 diff --git a/tests/geometry/circ2d3Tan/CircleCirclePoint_12 b/tests/geometry/circ2d3Tan/CircleCirclePoint_12 deleted file mode 100644 index 841e26deb2..0000000000 --- a/tests/geometry/circ2d3Tan/CircleCirclePoint_12 +++ /dev/null @@ -1,8 +0,0 @@ -qcircle c1 0 0 10 -qcircle c2 30 0 20 -point p1 7 30 -circ2d3Tan tan1 c1 c2 p1 - -checklength tan1_1 -l 951.90257403770727 -checklength tan1_2 -l 66.177052461460107 -checklength tan1_3 -l 190.20396243259333 diff --git a/tests/geometry/circ2d3Tan/CircleCirclePoint_14 b/tests/geometry/circ2d3Tan/CircleCirclePoint_14 deleted file mode 100644 index 508cd0cce5..0000000000 --- a/tests/geometry/circ2d3Tan/CircleCirclePoint_14 +++ /dev/null @@ -1,8 +0,0 @@ -qcircle c1 0 0 10 -qcircle c2 30 0 20 -point p1 30 -20 -circ2d3Tan tan1 c1 c2 p1 - -checklength tan1_1 -l 125.6637061435916 -checklength tan1_2 -l 376.99111854338514 -checklength tan1_3 -l 376.99111854338514 diff --git a/tests/geometry/circ2d3Tan/CircleLinLin_11 b/tests/geometry/circ2d3Tan/CircleLinLin_11 deleted file mode 100644 index b731ad3b21..0000000000 --- a/tests/geometry/circ2d3Tan/CircleLinLin_11 +++ /dev/null @@ -1,9 +0,0 @@ -qcircle c1 0 120 20 -qline l1 0 0 10 20 -qline l2 0 0 10 -40 -circ2d3Tan tan1 c1 l1 l2 - -checklength tan1_1 -l 461.86006847878718 -checklength tan1_2 -l 163.75801021417183 -checklength tan1_3 -l 321.80336707682847 -checklength tan1_4 -l 235.02950419226329 diff --git a/tests/geometry/circ2d3Tan/CirclePointPoint_11 b/tests/geometry/circ2d3Tan/CirclePointPoint_11 deleted file mode 100644 index 047a2c63aa..0000000000 --- a/tests/geometry/circ2d3Tan/CirclePointPoint_11 +++ /dev/null @@ -1,7 +0,0 @@ -qcircle c1 0 0 10 -point p1 20 0 -point p2 15 5 -circ2d3Tan tan1 c1 p1 p2 - -checklength tan1_1 -l 157.07963267948966 -checklength tan1_2 -l 31.415926535897931 diff --git a/tests/geometry/circ2d3Tan/CirclePointPoint_12 b/tests/geometry/circ2d3Tan/CirclePointPoint_12 deleted file mode 100644 index e4e9dec55a..0000000000 --- a/tests/geometry/circ2d3Tan/CirclePointPoint_12 +++ /dev/null @@ -1,6 +0,0 @@ -qcircle c1 0 0 10 -point p1 20 0 -point p2 10 0 - -set log [circ2d3Tan tan1 c1 p1 p2] -if {[llength $log]} {puts "Error:Incorrect circle is created"} diff --git a/tests/geometry/circ2d3Tan/CirclePointPoint_13 b/tests/geometry/circ2d3Tan/CirclePointPoint_13 deleted file mode 100644 index 91e630ddaf..0000000000 --- a/tests/geometry/circ2d3Tan/CirclePointPoint_13 +++ /dev/null @@ -1,7 +0,0 @@ -qcircle c1 0 0 10 -point p1 20 0 -point p2 0 10 -circ2d3Tan tan1 c1 p1 p2 - -checklength tan1_1 -l 157.07963267948978 -checklength tan1_2 -l 157.07963267948978 diff --git a/tests/geometry/circ2d3Tan/CirclePointPoint_14 b/tests/geometry/circ2d3Tan/CirclePointPoint_14 deleted file mode 100644 index cb9edda1e4..0000000000 --- a/tests/geometry/circ2d3Tan/CirclePointPoint_14 +++ /dev/null @@ -1,6 +0,0 @@ -qcircle c1 0 0 10 -point p1 20 0 -point p2 5 5 - -set log [circ2d3Tan tan1 c1 p1 p2] -if {[llength $log]} {puts "Error:Incorrect circle is created"} diff --git a/tests/geometry/circ2d3Tan/CirclePointPoint_15 b/tests/geometry/circ2d3Tan/CirclePointPoint_15 deleted file mode 100644 index 02eea2df2b..0000000000 --- a/tests/geometry/circ2d3Tan/CirclePointPoint_15 +++ /dev/null @@ -1,7 +0,0 @@ -qcircle c1 0 0 10 -point p1 20 0 -point p2 -20 0 -circ2d3Tan tan1 c1 p1 p2 - -checklength tan1_1 -l 157.07963267948966 -checklength tan1_2 -l 157.07963267948966 diff --git a/tests/geometry/circ2d3Tan/CirclePointPoint_21 b/tests/geometry/circ2d3Tan/CirclePointPoint_21 deleted file mode 100644 index 705b119b63..0000000000 --- a/tests/geometry/circ2d3Tan/CirclePointPoint_21 +++ /dev/null @@ -1,7 +0,0 @@ -qcircle c1 0 0 10 -point p1 5 0 -point p2 0 5 -circ2d3Tan tan1 c1 p1 p2 - -checklength tan1_1 -l 45.424379479936995 -checklength tan1_2 -l 26.383452602115419 diff --git a/tests/geometry/circ2d3Tan/CirclePointPoint_22 b/tests/geometry/circ2d3Tan/CirclePointPoint_22 deleted file mode 100644 index b65b8defb9..0000000000 --- a/tests/geometry/circ2d3Tan/CirclePointPoint_22 +++ /dev/null @@ -1,7 +0,0 @@ -qcircle c1 0 0 10 -point p1 5 0 -point p2 0 0 -circ2d3Tan tan1 c1 p1 p2 - -checklength tan1_1 -l 31.415926535897931 -checklength tan1_2 -l 31.415926535897931 diff --git a/tests/geometry/circ2d3Tan/CirclePointPoint_24 b/tests/geometry/circ2d3Tan/CirclePointPoint_24 deleted file mode 100644 index daad0d9765..0000000000 --- a/tests/geometry/circ2d3Tan/CirclePointPoint_24 +++ /dev/null @@ -1,6 +0,0 @@ -qcircle c1 0 0 10 -point p1 5 0 -point p2 0 10 -circ2d3Tan tan1 c1 p1 p2 - -checklength tan1_1 -l 39.269908169872416 diff --git a/tests/geometry/circ2d3Tan/CirclePointPoint_31 b/tests/geometry/circ2d3Tan/CirclePointPoint_31 deleted file mode 100644 index c937be9968..0000000000 --- a/tests/geometry/circ2d3Tan/CirclePointPoint_31 +++ /dev/null @@ -1,6 +0,0 @@ -qcircle c1 0 0 10 -point p1 10 0 -point p2 0 10 -circ2d3Tan tan1 c1 p1 p2 - -checklength tan1_1 -l 62.831853071795862 diff --git a/tests/geometry/circ2d3Tan/LinLinLin_11 b/tests/geometry/circ2d3Tan/LinLinLin_11 deleted file mode 100644 index 688602c39d..0000000000 --- a/tests/geometry/circ2d3Tan/LinLinLin_11 +++ /dev/null @@ -1,9 +0,0 @@ -qline l1 0 0 10 20 -qline l2 0 0 10 -40 -qline l3 160 0 -40 10 -circ2d3Tan tan1 l1 l2 l3 - -checklength tan1_1 -l 213.09795279419643 -checklength tan1_2 -l 284.90187851033369 -checklength tan1_3 -l 131.38343888467227 -checklength tan1_4 -l 63.235238531994284 diff --git a/tests/geometry/circ2d3Tan/LinLinPoint_11 b/tests/geometry/circ2d3Tan/LinLinPoint_11 deleted file mode 100644 index 297c7395b9..0000000000 --- a/tests/geometry/circ2d3Tan/LinLinPoint_11 +++ /dev/null @@ -1,7 +0,0 @@ -qline l1 0 0 10 20 -qline l2 0 0 10 -40 -point p1 10 80 -circ2d3Tan tan1 l1 l2 p1 - -checklength tan1_1 -l 269.03484941268533 -checklength tan1_2 -l 130.52381207643296 diff --git a/tests/geometry/circ2d3Tan/LinPointPoint_11 b/tests/geometry/circ2d3Tan/LinPointPoint_11 deleted file mode 100644 index 0381da1ca3..0000000000 --- a/tests/geometry/circ2d3Tan/LinPointPoint_11 +++ /dev/null @@ -1,7 +0,0 @@ -qline l1 0 0 10 20 -point p1 10 10 -point p2 100 10 -circ2d3Tan tan1 l1 p1 p2 - -checklength tan1_1 -l 419.71016104587477 -checklength tan1_2 -l 282.77131205819785 diff --git a/tests/geometry/circ2d3Tan/PointPointPoint_11 b/tests/geometry/circ2d3Tan/PointPointPoint_11 deleted file mode 100644 index b9590cc44e..0000000000 --- a/tests/geometry/circ2d3Tan/PointPointPoint_11 +++ /dev/null @@ -1,6 +0,0 @@ -point p1 0 50 -point p2 30 20 -point p3 150 150 -circ2d3Tan tan1 p1 p2 p3 - -checklength tan1_1 -l 566.81157580298293 diff --git a/tests/lowalgos/2dgcc/buc60607_1 b/tests/lowalgos/2dgcc/buc60607_1 deleted file mode 100644 index e0b9acbf7f..0000000000 --- a/tests/lowalgos/2dgcc/buc60607_1 +++ /dev/null @@ -1,12 +0,0 @@ -puts "=======================" -puts "BUC60607" -puts "It takes visual check for this BUC" -puts "=======================" - -set len_ch 2513 - -point p 1600 300 -line l 0 500 2000 500 -cirtang c -p p -c l -r 400 -checklength c_1 -l 2513.2741228718346 -checklength c_2 -l 2513.2741228718346 \ No newline at end of file diff --git a/tests/lowalgos/2dgcc/buc60607_2 b/tests/lowalgos/2dgcc/buc60607_2 deleted file mode 100644 index cc9af484ff..0000000000 --- a/tests/lowalgos/2dgcc/buc60607_2 +++ /dev/null @@ -1,8 +0,0 @@ -puts "=======================" -puts "BUC60607" -puts "It takes visual check for this BUC" -puts "=======================" - -point p 1600 300 -line l 0 500 2000 500 -cirtang c1 -p p -c l -r 200 diff --git a/tests/lowalgos/2dgcc/buc60607_3 b/tests/lowalgos/2dgcc/buc60607_3 deleted file mode 100644 index b23daa28c2..0000000000 --- a/tests/lowalgos/2dgcc/buc60607_3 +++ /dev/null @@ -1,8 +0,0 @@ -puts "=======================" -puts "BUC60607" -puts "It takes visual check for this BUC" -puts "=======================" - -point p2 1400 1400 -line l2 3000 1700 1000 1550 -cirtang c3 -p p2 -c l2 -r 300 diff --git a/tests/lowalgos/2dgcc/buc60607_4 b/tests/lowalgos/2dgcc/buc60607_4 deleted file mode 100644 index 85c033ebb2..0000000000 --- a/tests/lowalgos/2dgcc/buc60607_4 +++ /dev/null @@ -1,8 +0,0 @@ -puts "=======================" -puts "BUC60607" -puts "It takes visual check for this BUC" -puts "=======================" - -point p2 1400 1400 -line l2 3000 1700 1000 1550 -cirtang result -p p2 -c l2 -r 150 diff --git a/tests/lowalgos/2dgcc/buc60618 b/tests/lowalgos/2dgcc/buc60618 deleted file mode 100644 index 17b68cf99c..0000000000 --- a/tests/lowalgos/2dgcc/buc60618 +++ /dev/null @@ -1,21 +0,0 @@ -puts "==================================" -puts "BUC60618" -puts "==================================" -puts "There was a problem filter of solutions. Several solutions were skipped." -puts "" -puts "It takes visual check for this BUG" -puts "==================================" -puts "" - -circle c1 0 0 100 -circle c2 500 -400 300 -circle c3 300 200 200 -cirtang result -c c1 -c c2 -c c3 -checklength result_1 -l 3568.9587306060739 -checklength result_2 -l 9964.7111736227271 -checklength result_3 -l 2082.9371204466097 -checklength result_4 -l 32696.069757517998 -checklength result_5 -l 1681.9298517645602 -checklength result_6 -l 3097.3731840080009 -checklength result_7 -l 1545.2428620020787 -checklength result_8 -l 772.26646380656518 \ No newline at end of file diff --git a/tests/lowalgos/2dgcc/buc60622_1 b/tests/lowalgos/2dgcc/buc60622_1 deleted file mode 100644 index 846561d72e..0000000000 --- a/tests/lowalgos/2dgcc/buc60622_1 +++ /dev/null @@ -1,14 +0,0 @@ -puts "==========" -puts "BUC60622" -puts "==========" -puts "" -puts "==================================" -puts "It takes visual check for this BUG" -puts "==================================" -puts "" - -circle c1 2900 800 500 -circle c2 2900 900 400 -circle c3 2900 1000 300 -catch {cirtang result -c c1 -c c2 -c c3} - diff --git a/tests/lowalgos/2dgcc/buc60622_2 b/tests/lowalgos/2dgcc/buc60622_2 deleted file mode 100644 index 1a6b3fed6c..0000000000 --- a/tests/lowalgos/2dgcc/buc60622_2 +++ /dev/null @@ -1,17 +0,0 @@ -puts "==================================" -puts "BUC60622" -puts "==================================" -puts "There was an infinity of solutions and also c1, c2 and c3 are solutions" -puts "" -puts "It takes visual check for this BUG" -puts "==================================" -puts "" - -circle c1 500 1800 500 -circle c2 500 1900 400 -circle c3 700 1900 200 -cirtang result -c c1 -c c2 -c c3 - -checklength result_1 -l 2513.2741228703289 -checklength result_2 -l 837.75804095727631 -checklength result_3 -l 279.2526803190928 \ No newline at end of file diff --git a/tests/lowalgos/2dgcc/buc60622_3 b/tests/lowalgos/2dgcc/buc60622_3 deleted file mode 100644 index 6dfa2026c8..0000000000 --- a/tests/lowalgos/2dgcc/buc60622_3 +++ /dev/null @@ -1,19 +0,0 @@ -puts "==================================" -puts "BUC60622" -puts "==================================" -puts "There was an infinity of solutions and also c1, c2 and c3 are solutions" -puts "" -puts "It takes visual check for this BUG" -puts "==================================" -puts "" - -circle c3 500 3000 250 -circle c2 375 3000 125 -circle c1 625 3000 125 -cirtang result -c c1 -c c2 -c c3 - -checklength result_1 -l 1570.7963267948965 -checklength result_2 -l 785.39816339744868 -checklength result_3 -l 785.39816339744823 -checklength result_4 -l 523.59877559829806 -checklength result_5 -l 523.59877559829806 \ No newline at end of file diff --git a/tests/lowalgos/2dgcc/buc60941 b/tests/lowalgos/2dgcc/buc60941 deleted file mode 100644 index 94a101a569..0000000000 --- a/tests/lowalgos/2dgcc/buc60941 +++ /dev/null @@ -1,20 +0,0 @@ -puts "========" -puts "BUC60941" -puts "========" -puts "" -############################################################ -## When try to use Geom2dGcc_Circ2d2TanRad with two curves it rise exception. -############################################################ - -circle curve_1 1.79356127430613 -11.9148900515605 12.0491272292007 - -set poles { { 0 0 1 } { -2.14533906935467 4.92056269221697 1 } { -0.537398638327716 10.0937503357781 1 } { 10.3564232507092 8.73929826869582 1 } { 16.6366922939454 3.11858911810943 1 } { 16.39 -0.262 1 } } -set knots { { 0 4 } { 8.6971225126475 1 } { 16.903955884905 1 } { 28.0087167558108 4 } } - -eval 2dbsplinecurve curve_2 3 [ llength $knots ] [ join $knots ] [ join $poles ] - -if [catch {cirtang result -c curve_1 -c curve_2 -r 2} catch_result] { - puts "Faulty BUC60941: function cirtang works wrongly" -} else { - puts "BUC60941 OK: function cirtang works properly" -} diff --git a/tests/lowalgos/2dgcc/bug29694 b/tests/lowalgos/2dgcc/bug29694 deleted file mode 100644 index 7b147515c8..0000000000 --- a/tests/lowalgos/2dgcc/bug29694 +++ /dev/null @@ -1,18 +0,0 @@ -puts "========" -puts "0029694: Geom2dGcc_Circ2dTanCenGeo crash" -puts "========" -puts "" - -point pp 1 1 -2dbsplinecurve cc 1 2 0 2 1 2 -10 -5 1 10 -5 1 - -if { ![regexp {Solution of type C-P is} [cirtang result -p pp -c cc] ] } { - puts "Error: Cannot find any solution" -} - -regexp "Center\\s*:\\s*(\[-0-9.+eE\]+)\\s*,\\s*(\[-0-9.+eE\]+)\\s*" [dump result_1] full pcx pcy - -checkreal CenterX $pcx 1.0 1.0e-7 0 -checkreal CenterX $pcy 1.0 1.0e-7 0 - -checkdump result_1 -name Radius -ref 6 diff --git a/tests/lowalgos/2dinter/bug23706_4 b/tests/lowalgos/2dinter/bug23706_4 deleted file mode 100644 index e84fa2b97c..0000000000 --- a/tests/lowalgos/2dinter/bug23706_4 +++ /dev/null @@ -1,37 +0,0 @@ -puts "============" -puts "OCC23706" -puts "============" -puts "" -######################################################################### -# Cannot project point on curve -######################################################################### - -2dbsplinecurve c1 2 5 0 3 0.2 1 0.3 1 0.4 1 0.5 3 2 0 1 3 -1 1 5 5 1 5 5 1 6 8 1 4 7 1 -2dbsplinecurve c3 2 4 1 3 2 1 3 1 5 3 6 3 1 5.001 5.01 1 5.001 5.01 1 3 9 1 2 11 1 -set info [2dintersect c1 c3] - -if { [regexp "Intersection point 1" $info] != 1 } { - puts "Error : Intersection should have two points" -} else { - regexp {Intersection point 1 +: +([-0-9.+eE]+)} $info full p11t - regexp {Intersection point 1 +: +[-0-9.+eE]+ +([-0-9.+eE]+)} $info full p12t -} - -if { [regexp "Intersection point 2" $info] != 1 } { - puts "Error : Intersection should have two points" -} else { - regexp {Intersection point 2 +: +([-0-9.+eE]+)} $info full p21t - regexp {Intersection point 2 +: +[-0-9.+eE]+ +([-0-9.+eE]+)} $info full p22t -} - -set p11 [expr round($p11t*10000)] -set p12 [expr round($p12t*10000)] -set p21 [expr round($p21t*10000)] -set p22 [expr round($p22t*10000)] - -if { ${p11} != 50024 || ${p12} != 50072 || ${p21} != 40024 || ${p22} != 70012 } { - puts "Error : Points of intersection have wrong coordinates" -} else { - puts "OK: Points of intersection are right" -} - diff --git a/tests/lowalgos/2dinter/bug23706_5 b/tests/lowalgos/2dinter/bug23706_5 deleted file mode 100644 index 19d169fb6b..0000000000 --- a/tests/lowalgos/2dinter/bug23706_5 +++ /dev/null @@ -1,34 +0,0 @@ -puts "============" -puts "OCC23706" -puts "============" -puts "" -######################################################################### -# Cannot project point on curve -######################################################################### - -2dbsplinecurve c1 2 5 0 3 0.2 1 0.3 1 0.4 1 0.5 3 2 0 1 3 -1 1 5 5 1 5 5 1 6 8 1 4 7 1 -2dbsplinecurve c2 2 4 1 3 2 1 3 1 5 3 6 3 1 5 5 1 5 5 1 3 9 1 2 11 1 -set info [2dintersect c1 c2] - -if { [regexp "Intersection point 1" $info] != 1 } { - puts "Error : Intersection should have two points" -} else { - regexp {Intersection point 1 +: +([-0-9.+eE]+)} $info full p11 - regexp {Intersection point 1 +: +[-0-9.+eE]+ +([-0-9.+eE]+)} $info full p12 -} - -if { [regexp "Intersection point 2" $info] != 1 } { - puts "Error : Intersection should have two points" -} else { - regexp {Intersection point 2 +: +([-0-9.+eE]+)} $info full p21t - regexp {Intersection point 2 +: +[-0-9.+eE]+ +([-0-9.+eE]+)} $info full p22t -} - -set p21 [expr int($p21t)] -set p22 [expr int($p22t)] - -if { ${p11} != 5 || ${p12} != 5 || ${p21} != 4 || ${p22} != 7 } { - puts "Error : Points of intersection have wrong coordinates" -} else { - puts "OK: Points of intersection are right" -} diff --git a/tests/lowalgos/2dinter/bug29162 b/tests/lowalgos/2dinter/bug29162 deleted file mode 100644 index f001945729..0000000000 --- a/tests/lowalgos/2dinter/bug29162 +++ /dev/null @@ -1,22 +0,0 @@ -puts "========" -puts "OCC29162" -puts "========" -puts "" -################################################## -# Geom2dInt_GInter algorithm does not find -# intersection of ellipse and line -################################################## - -ellipse e -610.348096534595 -710.720096056787 0.999999902285153 0.000442074298181498 15.0066332711999 0.291884102212871 -trim e e 3.09462291909258 9.37780822627216 - -line l -625.34430362036 -680.713463264921 -0.000252749178714602 -0.999999968058926 -trim l l 0 30.0132665523925 - -set cx 0 -set cy 0 - -regexp {Intersection point 1 : ([-0-9.+eE]+) ([-0-9.+eE]+)} [2dintersect e l ] full cx cy -checkreal n1 $cx -625.35188801291508 1.e-7 1.e-7 -checkreal n2 $cy -710.72104765746838 1.e-7 1.e-7 - diff --git a/tests/lowalgos/bnd/bug30292 b/tests/lowalgos/bnd/bug30292 deleted file mode 100644 index 4bc136f9eb..0000000000 --- a/tests/lowalgos/bnd/bug30292 +++ /dev/null @@ -1,68 +0,0 @@ -puts "========" -puts "0030292: Modeling Algorithms - BRepBndLib should avoid using Poly_Polygon3D when called with useTriangulation set to false" -puts "========" -puts "" - -## geometric edge without any discrete representations - -circle c 0 0 0 1 -mkedge e c -set res1 [bounding e] -set res2 [bounding e -noTriangulation] -if {$res1 != $res2} { - puts "Error: bounding boxes are different for geometric edge" -} - -## geometric edge with polygon 3d - -incmesh e 0.1 -set res1_ref "-1.1000000999999999 -1.0927089740980542 -0.10000010000000001 1.1000000999999999 1.092708974098054 0.10000010000000001" -set res2_ref "-1.0000001000000001 -1.0000001000000001 -9.9999999999999995e-08 1.0000001000000001 1.0000001000000001 9.9999999999999995e-08" -unset res1 -set res1 [bounding e] -foreach dd $res1 { - if ![regexp $dd $res1_ref] { - puts "Error: bounding box is wrong" - } -} -unset res2 -set res2 [bounding e -noTriangulation] -foreach dd $res2 { - if ![regexp $dd $res2_ref] { - puts "Error: bounding box is wrong" - } -} - -## geometric edge with polygon on triangulation - -pcylinder cyl 1 1 -incmesh cyl 0.1 -explode cyl e -renamevar cyl_3 e -unset res1 -set res1 [bounding e] -foreach dd $res1 { - if ![regexp $dd $res1_ref] { - puts "Error: bounding box is wrong" - } -} -unset res2 -set res2 [bounding e -noTriangulation] -foreach dd $res2 { - if ![regexp $dd $res2_ref] { - puts "Error: bounding box is wrong" - } -} - -## not geometric edge with polygon 3d - -polygon3d pol3d 5 1 0 0 0 1 0 -1 0 0 0 -1 0 1 0 0 -mkedge e pol3d -unset res1 -set res1 [bounding e] -unset res2 -set res2 [bounding e -noTriangulation] -if {$res1 != $res2} { - puts "Error: bounding boxes are different for not geometric edge" -} - diff --git a/tests/lowalgos/bvh/bug30655_1 b/tests/lowalgos/bvh/bug30655_1 deleted file mode 100644 index e97f399408..0000000000 --- a/tests/lowalgos/bvh/bug30655_1 +++ /dev/null @@ -1,58 +0,0 @@ -puts "=======" -puts "0030655: Modeling Data - Provide interfaces for selection of the elements from BVH tree" -puts "=======" -puts "" - -pload QAcommands - -box b 10 10 10 - -# select elements interfering with each vertex (must be one vertex (itself), three edges and three faces - 7 in total) -foreach v [explode b v] { - QABVH_ShapeSelect r_$v b $v - QABVH_ShapeSelect rv_$v b $v -void - - if { [llength [explode r_$v]] != 7} { - puts "Error: incorrect selection" - } - - checknbshapes rv_$v -ref [nbshapes r_$v] - checkprops rv_$v -equal r_$v -} - -# select elements interfering with each edge (must be two vertices, five edges and four faces - 11 in total) -foreach e [explode b e] { - QABVH_ShapeSelect r_$e b $e - QABVH_ShapeSelect rv_$e b $e -void - - if { [llength [explode r_$e]] != 11} { - puts "Error: incorrect selection" - } - - checknbshapes rv_$e -ref [nbshapes r_$e] - checkprops rv_$e -equal r_$e -} - -# select elements interfering with each face (must be ffour vertices, eight edges and five faces - 17 in total) -foreach f [explode b f] { - QABVH_ShapeSelect r_$f b $f - QABVH_ShapeSelect rv_$f b $f -void - - if { [llength [explode r_$f]] != 17} { - puts "Error: incorrect selection" - } - - checknbshapes rv_$f -ref [nbshapes r_$f] - checkprops rv_$f -equal r_$f -} - -# intersect the box with itself - select all interfering pairs (8 * 7 + 12 * 11 + 6 * 17 = 290) -QABVH_PairSelect r b b -QABVH_PairSelect rv b b -void - -if { [llength [explode r]] != 290} { - puts "Error: incorrect selection" -} - -checknbshapes rv -ref [nbshapes r] -checkprops rv -equal r diff --git a/tests/lowalgos/bvh/bug30655_2 b/tests/lowalgos/bvh/bug30655_2 deleted file mode 100644 index 7f057e4e8b..0000000000 --- a/tests/lowalgos/bvh/bug30655_2 +++ /dev/null @@ -1,16 +0,0 @@ -puts "=======" -puts "0030655: Modeling Data - Provide interfaces for selection of the elements from BVH tree" -puts "=======" -puts "" - -pload QAcommands - -box b1 10 10 10 -box b2 20 0 0 10 10 10 - -incmesh b1 0.1 -incmesh b2 0.1 - -regexp {Distance ([-0-9.+eE]*)} [QABVH_PairDistance b1 b2] full dist - -checkreal "Distance" $dist 10 0 1.e-2 diff --git a/tests/lowalgos/bvh/bug30655_3 b/tests/lowalgos/bvh/bug30655_3 deleted file mode 100644 index 101bd3222b..0000000000 --- a/tests/lowalgos/bvh/bug30655_3 +++ /dev/null @@ -1,21 +0,0 @@ -puts "=======" -puts "0030655: Modeling Data - Provide interfaces for selection of the elements from BVH tree" -puts "=======" -puts "" - -pload QAcommands - -psphere s1 100 -psphere s2 110 -ttranslate s2 150 150 150 - -incmesh s1 0.01 -incmesh s2 0.01 - -dchrono stime start -regexp {Distance ([-0-9.+eE]*)} [QABVH_PairDistance s1 s2] full dist -dchrono stime stop counter MESH_MESH_DISTANCE - -distmini d s1 s2 - -checkreal "Distance" $dist [dval d_val] 0 1.e-2 diff --git a/tests/lowalgos/bvh/bug30655_4 b/tests/lowalgos/bvh/bug30655_4 deleted file mode 100644 index 054e65ccf3..0000000000 --- a/tests/lowalgos/bvh/bug30655_4 +++ /dev/null @@ -1,13 +0,0 @@ -puts "=======" -puts "0030655: Modeling Data - Provide interfaces for selection of the elements from BVH tree" -puts "=======" -puts "" - -pload QAcommands - -box b 10 10 10 -incmesh b 0.1 - -# test the work of distance field -QABVH_DistanceField b 2 - diff --git a/tests/lowalgos/extcc/bug29712_10 b/tests/lowalgos/extcc/bug29712_10 deleted file mode 100644 index 1d7d4f1176..0000000000 --- a/tests/lowalgos/extcc/bug29712_10 +++ /dev/null @@ -1,33 +0,0 @@ -puts "========" -puts "OCC29712" -puts "========" -puts "" -################################################# -# Extrema algorithm raises exception -################################################# - -# Curves c1 and c2 lie on parallel lines. -# However, they are bounded (trimmed) curves -# and are shifted relatively to each other. So, -# there exists single perpendicular only. - -line c1 1 0 0 0 0 1 -line c2 5 0 0 0 0 1 -trim c1 c1 -1.0e100 5 -trim c2 c2 5 20 - -foreach a [ directory ext_* ] { unset $a } -extrema c1 c2 -if { [llength [ directory ext_* ] ] != 1 } { - puts "Error: Wrong number of solutions (c1 c2)" -} - -checklength ext_1 -l 4.0 -eps 2.0e-8 - -foreach a [ directory ext_* ] { unset $a } -extrema c2 c1 -if { [llength [ directory ext_* ] ] != 1 } { - puts "Error: Wrong number of solutions (c1 c2)" -} - -checklength ext_1 -l 4.0 -eps 2.0e-8 \ No newline at end of file diff --git a/tests/lowalgos/extcc/bug29712_11 b/tests/lowalgos/extcc/bug29712_11 deleted file mode 100644 index 0bd17d5e0f..0000000000 --- a/tests/lowalgos/extcc/bug29712_11 +++ /dev/null @@ -1,33 +0,0 @@ -puts "========" -puts "OCC29712" -puts "========" -puts "" -################################################# -# Extrema algorithm raises exception -################################################# - -# Curves c1 and c2 lie on parallel lines. -# However, they are bounded (trimmed) curves -# and are shifted relatively to each other. So, -# there exists single perpendicular only. - -line c1 1 0 0 0 0 1 -line c2 5 0 0 0 0 -1 -trim c1 c1 0 3 -trim c2 c2 -9.9e-8 1.0e100 - -foreach a [ directory ext_* ] { unset $a } -extrema c1 c2 -if { [llength [ directory ext_* ] ] != 1 } { - puts "Error: Wrong number of solutions (c1 c2)" -} - -checklength ext_1 -l 4.0 -eps 2.0e-8 - -foreach a [ directory ext_* ] { unset $a } -extrema c2 c1 -if { [llength [ directory ext_* ] ] != 1 } { - puts "Error: Wrong number of solutions (c1 c2)" -} - -checklength ext_1 -l 4.0 -eps 2.0e-8 \ No newline at end of file diff --git a/tests/lowalgos/extcc/bug29712_12 b/tests/lowalgos/extcc/bug29712_12 deleted file mode 100644 index a869688c41..0000000000 --- a/tests/lowalgos/extcc/bug29712_12 +++ /dev/null @@ -1,33 +0,0 @@ -puts "========" -puts "OCC29712" -puts "========" -puts "" -################################################# -# Extrema algorithm raises exception -################################################# - -# Curves c1 and c2 lie on parallel lines. -# However, they are bounded (trimmed) curves -# and are shifted relatively to each other. So, -# there exists single perpendicular only. - -line c1 0 0 0 1 0 0 -line c2 0 4 0 -1 0 0 -trim c1 c1 0 1 -trim c2 c2 -2 -1 - -foreach a [ directory ext_* ] { unset $a } -extrema c1 c2 -if { [llength [ directory ext_* ] ] != 1 } { - puts "Error: Wrong number of solutions (c1 c2)" -} - -checklength ext_1 -l 4.0 -eps 2.0e-8 - -foreach a [ directory ext_* ] { unset $a } -extrema c2 c1 -if { [llength [ directory ext_* ] ] != 1 } { - puts "Error: Wrong number of solutions (c1 c2)" -} - -checklength ext_1 -l 4.0 -eps 2.0e-8 diff --git a/tests/lowalgos/extcc/bug29712_13 b/tests/lowalgos/extcc/bug29712_13 deleted file mode 100644 index 3e54f3fd65..0000000000 --- a/tests/lowalgos/extcc/bug29712_13 +++ /dev/null @@ -1,35 +0,0 @@ -puts "========" -puts "OCC29712" -puts "========" -puts "" -################################################# -# Extrema algorithm raises exception -################################################# - -# Curves c1 and c2 are concentric circles. -# However, they are bounded (trimmed) curves -# and are shifted relatively to each other. - -set ExpDist 150.0 - -circle c1 0 0 0 0 0 1 100 -circle c2 0 0 0 0 0 1 50 -trim c1 c1 0 3 -trim c2 c2 4 6 - -extrema c1 c2 - -if { ![isdraw ext_1 ] } { - puts "Error in Extrema-algorithm" -} else { - puts "Extrema-algorithm works properly" -} - -renamevar ext_1 e1 -extrema c2 c1 - -if { ![isdraw ext_1 ] } { - puts "Error in Extrema-algorithm" -} else { - puts "Extrema-algorithm works properly" -} diff --git a/tests/lowalgos/extcc/bug29712_14 b/tests/lowalgos/extcc/bug29712_14 deleted file mode 100644 index ae82499d70..0000000000 --- a/tests/lowalgos/extcc/bug29712_14 +++ /dev/null @@ -1,24 +0,0 @@ -puts "========" -puts "OCC29712" -puts "========" -puts "" -################################################# -# Extrema algorithm raises exception -################################################# - -# Curves c1 and c2 are concentric circles. -# However, they are bounded (trimmed) curves -# and are shifted relatively to each other. - -set ExpDist 50.0 - -circle c1 0 0 0 0 0 1 100 -circle c2 0 0 0 0 0 1 50 -trim c1 c1 0 3 -trim c2 c2 -8.1 -6.1 - -regexp {Infinite number of extremas, distance = +([-0-9.+eE]+)} [extrema c1 c2] full aDist1 -checkreal Distance $aDist1 $ExpDist 1.0e-7 0.0 - -regexp {Infinite number of extremas, distance = +([-0-9.+eE]+)} [extrema c2 c1] full aDist2 -checkreal Distance $aDist2 $ExpDist 1.0e-7 0.0 diff --git a/tests/lowalgos/extcc/bug29712_15 b/tests/lowalgos/extcc/bug29712_15 deleted file mode 100644 index 57043bdc69..0000000000 --- a/tests/lowalgos/extcc/bug29712_15 +++ /dev/null @@ -1,24 +0,0 @@ -puts "========" -puts "OCC29712" -puts "========" -puts "" -################################################# -# Extrema algorithm raises exception -################################################# - -# Curves c1 and c2 are concentric circles. -# However, they are bounded (trimmed) curves -# and are shifted relatively to each other. - -set ExpDist 50.0 - -circle c1 0 0 0 0 0 1 100 -circle c2 0 0 0 0 0 1 50 -trim c1 c1 0 3 -trim c2 c2 -1.9 0.1 - -regexp {Infinite number of extremas, distance = +([-0-9.+eE]+)} [extrema c1 c2] full aDist1 -checkreal Distance $aDist1 $ExpDist 1.0e-7 0.0 - -regexp {Infinite number of extremas, distance = +([-0-9.+eE]+)} [extrema c2 c1] full aDist2 -checkreal Distance $aDist2 $ExpDist 1.0e-7 0.0 diff --git a/tests/lowalgos/extcc/bug29712_16 b/tests/lowalgos/extcc/bug29712_16 deleted file mode 100644 index 88324c0479..0000000000 --- a/tests/lowalgos/extcc/bug29712_16 +++ /dev/null @@ -1,45 +0,0 @@ -puts "========" -puts "OCC29712" -puts "========" -puts "" -################################################# -# Extrema algorithm raises exception -################################################# - -# Curves c1 and c2 are concentric circles. -# However, they are bounded (trimmed) curves -# and are shifted relatively to each other. -# So, there are two parallel arcs with distance 150 -# and one pair of points with distance 50. Extrema -# algorithm must return minimal distance (50) and -# not infinite solution - -set ExpDist 50.0 - -circle c1 0 0 0 0 0 1 100 -circle c2 0 0 0 0 0 1 50 -trim c1 c1 0 3 -trim c2 c2 -2.0 0.0 - -foreach a [ directory ext_* ] { unset $a } -if { [regexp {Infinite} [extrema c1 c2]] } { - puts "Error: Extrema (c1 c2) returned infinite number of solution" -} - -if { [llength [ directory ext_* ] ] != 1 } { - puts "Error: Wrong number of solutions (c1 c2)" -} - -checklength ext_1 -l $ExpDist - -foreach a [ directory ext_* ] { unset $a } -if { [regexp {Infinite} [extrema c2 c1]] } { - puts "Error: Extrema (c2 c1) returned infinite number of solution" -} - -if { [llength [ directory ext_* ] ] != 1 } { - puts "Error: Wrong number of solutions (c2 c1)" -} - -checklength ext_1 -l $ExpDist - diff --git a/tests/lowalgos/extcc/bug29712_17 b/tests/lowalgos/extcc/bug29712_17 deleted file mode 100644 index 71f90ee188..0000000000 --- a/tests/lowalgos/extcc/bug29712_17 +++ /dev/null @@ -1,24 +0,0 @@ -puts "========" -puts "OCC29712" -puts "========" -puts "" -################################################# -# Extrema algorithm raises exception -################################################# - -# Curves c1 and c2 are concentric circles. -# However, they are bounded (trimmed) curves -# and are shifted relatively to each other. - -set ExpDist 50.0 - -circle c1 0 0 0 0 0 1 100 -circle c2 0 0 0 0 0 1 50 -trim c1 c1 0 3 -trim c2 c2 -3.6 -1.6 - -regexp {Infinite number of extremas, distance = +([-0-9.+eE]+)} [extrema c1 c2] full aDist1 -checkreal Distance $aDist1 $ExpDist 1.0e-7 0.0 - -regexp {Infinite number of extremas, distance = +([-0-9.+eE]+)} [extrema c2 c1] full aDist2 -checkreal Distance $aDist2 $ExpDist 1.0e-7 0.0 diff --git a/tests/lowalgos/extcc/bug29712_18 b/tests/lowalgos/extcc/bug29712_18 deleted file mode 100644 index 61b29c9fe0..0000000000 --- a/tests/lowalgos/extcc/bug29712_18 +++ /dev/null @@ -1,24 +0,0 @@ -puts "========" -puts "OCC29712" -puts "========" -puts "" -################################################# -# Extrema algorithm raises exception -################################################# - -# Curves c1 and c2 are concentric circles. -# However, they are bounded (trimmed) curves -# and are shifted relatively to each other. - -set ExpDist 50.0 - -circle c1 0 0 0 0 0 1 100 -circle c2 0 0 0 0 0 1 50 -trim c1 c1 0 3 -trim c2 c2 -3.5 -1.5 - -regexp {Infinite number of extremas, distance = +([-0-9.+eE]+)} [extrema c1 c2] full aDist1 -checkreal Distance $aDist1 $ExpDist 1.0e-7 0.0 - -regexp {Infinite number of extremas, distance = +([-0-9.+eE]+)} [extrema c2 c1] full aDist2 -checkreal Distance $aDist2 $ExpDist 1.0e-7 0.0 diff --git a/tests/lowalgos/extcc/bug29712_19 b/tests/lowalgos/extcc/bug29712_19 deleted file mode 100644 index c03b7c27c0..0000000000 --- a/tests/lowalgos/extcc/bug29712_19 +++ /dev/null @@ -1,24 +0,0 @@ -puts "========" -puts "OCC29712" -puts "========" -puts "" -################################################# -# Extrema algorithm raises exception -################################################# - -# Curves c1 and c2 are concentric circles. -# However, they are bounded (trimmed) curves -# and are shifted relatively to each other. - -set ExpDist 50.0 - -circle c1 0 0 0 0 0 1 100 -circle c2 0 0 0 0 0 1 50 -trim c1 c1 0 3 -trim c2 c2 -3.4 -1.4 - -regexp {Infinite number of extremas, distance = +([-0-9.+eE]+)} [extrema c1 c2] full aDist1 -checkreal Distance $aDist1 $ExpDist 1.0e-7 0.0 - -regexp {Infinite number of extremas, distance = +([-0-9.+eE]+)} [extrema c2 c1] full aDist2 -checkreal Distance $aDist2 $ExpDist 1.0e-7 0.0 diff --git a/tests/lowalgos/extcc/bug29712_2 b/tests/lowalgos/extcc/bug29712_2 deleted file mode 100644 index 0ea43f96d7..0000000000 --- a/tests/lowalgos/extcc/bug29712_2 +++ /dev/null @@ -1,19 +0,0 @@ -puts "========" -puts "OCC29712" -puts "========" -puts "" -################################################# -# Extrema algorithm raises exception -################################################# - -# Curves c1 and c2 lie on parallel lines. -# However, they are bounded (B-spline) curves -# and are shifted relatively to each other. So, -# perpendicular between these curves does not exist but -# extrema must be found as in case "Not-parallel". - -bsplinecurve c1 1 2 0 2 1 2 0 0 0 1 1 0 0 1 -bsplinecurve c2 1 2 0 2 1 2 3 4 0 1 4 4 0 1 - -extrema c1 c2 -checklength ext_1 -l [expr sqrt(20)] -eps 2.0e-8 diff --git a/tests/lowalgos/extcc/bug29712_20 b/tests/lowalgos/extcc/bug29712_20 deleted file mode 100644 index 1107f9c66d..0000000000 --- a/tests/lowalgos/extcc/bug29712_20 +++ /dev/null @@ -1,24 +0,0 @@ -puts "========" -puts "OCC29712" -puts "========" -puts "" -################################################# -# Extrema algorithm raises exception -################################################# - -# Curves c1 and c2 are concentric circles. -# However, they are bounded (trimmed) curves -# and are shifted relatively to each other. - -set ExpDist 50.0 - -circle c1 0 0 0 0 0 1 100 -circle c2 0 0 0 0 0 1 50 -trim c1 c1 0 3 -trim c2 c2 -3.3 -1.3 - -regexp {Infinite number of extremas, distance = +([-0-9.+eE]+)} [extrema c1 c2] full aDist1 -checkreal Distance $aDist1 $ExpDist 1.0e-7 0.0 - -regexp {Infinite number of extremas, distance = +([-0-9.+eE]+)} [extrema c2 c1] full aDist2 -checkreal Distance $aDist2 $ExpDist 1.0e-7 0.0 diff --git a/tests/lowalgos/extcc/bug29712_21 b/tests/lowalgos/extcc/bug29712_21 deleted file mode 100644 index 569a0687c4..0000000000 --- a/tests/lowalgos/extcc/bug29712_21 +++ /dev/null @@ -1,35 +0,0 @@ -puts "========" -puts "OCC29712" -puts "========" -puts "" -################################################# -# Extrema algorithm raises exception -################################################# - -# Curves c1 and c2 are concentric circles. -# However, they are bounded (trimmed) curves -# and are shifted relatively to each other. - -set ExpDist 150.0 - -circle c1 0 0 0 0 0 1 100 -circle c2 0 0 0 0 0 1 50 -trim c1 c1 0 3 -trim c2 c2 -3.2 -1.2 - -extrema c1 c2 - -if { ![isdraw ext_1 ] } { - puts "Error in Extrema-algorithm" -} else { - puts "Extrema-algorithm works properly" -} - -renamevar ext_1 e1 -extrema c2 c1 - -if { ![isdraw ext_1 ] } { - puts "Error in Extrema-algorithm" -} else { - puts "Extrema-algorithm works properly" -} \ No newline at end of file diff --git a/tests/lowalgos/extcc/bug29712_22 b/tests/lowalgos/extcc/bug29712_22 deleted file mode 100644 index b9e5d07333..0000000000 --- a/tests/lowalgos/extcc/bug29712_22 +++ /dev/null @@ -1,33 +0,0 @@ -puts "========" -puts "OCC29712" -puts "========" -puts "" -################################################# -# Extrema algorithm raises exception -################################################# - -# Curves c1 and c2 are concentric circles. -# However, they are bounded (trimmed) curves -# and are shifted relatively to each other. - -circle c1 0 0 0 0 0 1 100 -circle c2 0 0 0 0 0 1 50 -trim c1 c1 0 3 -trim c2 c2 -3.1 -1.1 - -extrema c1 c2 - -if { ![isdraw ext_1 ] } { - puts "Error in Extrema-algorithm" -} else { - puts "Extrema-algorithm works properly" -} - -renamevar ext_1 e1 -extrema c2 c1 - -if { ![isdraw ext_1 ] } { - puts "Error in Extrema-algorithm" -} else { - puts "Extrema-algorithm works properly" -} diff --git a/tests/lowalgos/extcc/bug29712_23 b/tests/lowalgos/extcc/bug29712_23 deleted file mode 100644 index db9e5b10b7..0000000000 --- a/tests/lowalgos/extcc/bug29712_23 +++ /dev/null @@ -1,24 +0,0 @@ -puts "========" -puts "OCC29712" -puts "========" -puts "" -################################################# -# Extrema algorithm raises exception -################################################# - -# Curves c1 and c2 are concentric circles. -# However, they are bounded (trimmed) curves -# and are shifted relatively to each other. - -set ExpDist 50.0 - -circle c1 0 0 0 0 0 1 100 -circle c2 0 0 0 0 0 1 50 -trim c1 c1 0 3 -trim c2 c2 -9.6 -7.6 - -regexp {Infinite number of extremas, distance = +([-0-9.+eE]+)} [extrema c1 c2] full aDist1 -checkreal Distance $aDist1 $ExpDist 1.0e-7 0.0 - -regexp {Infinite number of extremas, distance = +([-0-9.+eE]+)} [extrema c2 c1] full aDist2 -checkreal Distance $aDist2 $ExpDist 1.0e-7 0.0 diff --git a/tests/lowalgos/extcc/bug29712_24 b/tests/lowalgos/extcc/bug29712_24 deleted file mode 100644 index 7c0e22d63f..0000000000 --- a/tests/lowalgos/extcc/bug29712_24 +++ /dev/null @@ -1,34 +0,0 @@ -puts "========" -puts "OCC29712" -puts "========" -puts "" -################################################# -# Extrema algorithm raises exception -################################################# - -# Curves c1 and c2 are concentric circles. -# However, they are bounded (trimmed) curves -# and are shifted relatively to each other. - - -circle c1 0 0 0 0 0 1 100 -circle c2 0 0 0 0 0 1 50 -trim c1 c1 0 3 -trim c2 c2 -9.5 -7.5 - -extrema c1 c2 - -if { ![isdraw ext_1 ] } { - puts "Error in Extrema-algorithm" -} else { - puts "Extrema-algorithm works properly" -} - -renamevar ext_1 e1 -extrema c2 c1 - -if { ![isdraw ext_1 ] } { - puts "Error in Extrema-algorithm" -} else { - puts "Extrema-algorithm works properly" -} diff --git a/tests/lowalgos/extcc/bug29712_25 b/tests/lowalgos/extcc/bug29712_25 deleted file mode 100644 index 1503119687..0000000000 --- a/tests/lowalgos/extcc/bug29712_25 +++ /dev/null @@ -1,35 +0,0 @@ -puts "========" -puts "OCC29712" -puts "========" -puts "" -################################################# -# Extrema algorithm raises exception -################################################# - -# Curves c1 and c2 are concentric circles. -# However, they are bounded (trimmed) curves -# and are shifted relatively to each other. - -set ExpDist 150.0 - -circle c1 0 0 0 0 0 1 100 -circle c2 0 0 0 0 0 1 50 -trim c1 c1 0 3 -trim c2 c2 -8.3 -6.3 - -extrema c1 c2 - -if { ![isdraw ext_1 ] } { - puts "Error in Extrema-algorithm" -} else { - puts "Extrema-algorithm works properly" -} - -renamevar ext_1 e1 -extrema c2 c1 - -if { ![isdraw ext_1 ] } { - puts "Error in Extrema-algorithm" -} else { - puts "Extrema-algorithm works properly" -} diff --git a/tests/lowalgos/extcc/bug29712_26 b/tests/lowalgos/extcc/bug29712_26 deleted file mode 100644 index 9f0cf23d2a..0000000000 --- a/tests/lowalgos/extcc/bug29712_26 +++ /dev/null @@ -1,24 +0,0 @@ -puts "========" -puts "OCC29712" -puts "========" -puts "" -################################################# -# Extrema algorithm raises exception -################################################# - -# Curves c1 and c2 are concentric circles. -# However, they are bounded (trimmed) curves -# and are shifted relatively to each other. - -set ExpDist 50.0 - -circle c1 0 0 0 0 0 1 100 -circle c2 0 0 0 0 0 1 50 -trim c1 c1 0 3 -trim c2 c2 -8.2 -6.2 - -regexp {Infinite number of extremas, distance = +([-0-9.+eE]+)} [extrema c1 c2] full aDist1 -checkreal Distance $aDist1 $ExpDist 1.0e-7 0.0 - -regexp {Infinite number of extremas, distance = +([-0-9.+eE]+)} [extrema c2 c1] full aDist2 -checkreal Distance $aDist2 $ExpDist 1.0e-7 0.0 diff --git a/tests/lowalgos/extcc/bug29712_27 b/tests/lowalgos/extcc/bug29712_27 deleted file mode 100644 index 30cb914100..0000000000 --- a/tests/lowalgos/extcc/bug29712_27 +++ /dev/null @@ -1,24 +0,0 @@ -puts "========" -puts "OCC29712" -puts "========" -puts "" -################################################# -# Extrema algorithm raises exception -################################################# - -# Curves c1 and c2 are concentric circles. -# However, they are bounded (trimmed) curves -# and are shifted relatively to each other. - -set ExpDist 50.0 - -circle c1 0 0 0 0 0 1 100 -circle c2 0 0 0 0 0 1 50 -trim c1 c1 0 3 -trim c2 c2 0 2 - -regexp {Infinite number of extremas, distance = +([-0-9.+eE]+)} [extrema c1 c2] full aDist1 -checkreal Distance $aDist1 $ExpDist 1.0e-7 0.0 - -regexp {Infinite number of extremas, distance = +([-0-9.+eE]+)} [extrema c2 c1] full aDist2 -checkreal Distance $aDist2 $ExpDist 1.0e-7 0.0 diff --git a/tests/lowalgos/extcc/bug29712_28 b/tests/lowalgos/extcc/bug29712_28 deleted file mode 100644 index 7246b9d64d..0000000000 --- a/tests/lowalgos/extcc/bug29712_28 +++ /dev/null @@ -1,40 +0,0 @@ -puts "========" -puts "OCC29712" -puts "========" -puts "" -################################################# -# Extrema algorithm raises exception -################################################# - -# Curves c1 and c2 are concentric circles. -# However, they are bounded (trimmed) curves -# and are shifted relatively to each other. - -set ExpDist 50.0 - -circle c1 0 0 0 0 0 1 100 -circle c2 0 0 0 0 0 1 50 -trim c1 c1 0 3 -trim c2 c2 3 5 - -foreach a [ directory ext_* ] { unset $a } -if { [regexp {Infinite} [extrema c1 c2]] } { - puts "Error: Extrema (c1 c2) returned infinite number of solution" -} - -if { [llength [ directory ext_* ] ] != 1 } { - puts "Error: Wrong number of solutions (c1 c2)" -} - -checklength ext_1 -l $ExpDist - -foreach a [ directory ext_* ] { unset $a } -if { [regexp {Infinite} [extrema c2 c1]] } { - puts "Error: Extrema (c2 c1) returned infinite number of solution" -} - -if { [llength [ directory ext_* ] ] != 1 } { - puts "Error: Wrong number of solutions (c2 c1)" -} - -checklength ext_1 -l $ExpDist diff --git a/tests/lowalgos/extcc/bug29712_29 b/tests/lowalgos/extcc/bug29712_29 deleted file mode 100644 index eeb9d4efa3..0000000000 --- a/tests/lowalgos/extcc/bug29712_29 +++ /dev/null @@ -1,34 +0,0 @@ -puts "========" -puts "OCC29712" -puts "========" -puts "" -################################################# -# Extrema algorithm raises exception -################################################# - -# Curves c1 and c2 are concentric circles. -# However, they are bounded (trimmed) curves -# and are shifted relatively to each other. - - -circle c1 0 0 0 0 0 1 100 -circle c2 0 0 0 0 0 1 50 -trim c1 c1 0 3 -trim c2 c2 3.1 5.1 - -extrema c1 c2 - -if { ![isdraw ext_1 ] } { - puts "Error in Extrema-algorithm" -} else { - puts "Extrema-algorithm works properly" -} - -renamevar ext_1 e1 -extrema c2 c1 - -if { ![isdraw ext_1 ] } { - puts "Error in Extrema-algorithm" -} else { - puts "Extrema-algorithm works properly" -} diff --git a/tests/lowalgos/extcc/bug29712_3 b/tests/lowalgos/extcc/bug29712_3 deleted file mode 100644 index e996370645..0000000000 --- a/tests/lowalgos/extcc/bug29712_3 +++ /dev/null @@ -1,35 +0,0 @@ -puts "========" -puts "OCC29712" -puts "========" -puts "" -################################################# -# Extrema algorithm raises exception -################################################# - -# Curves c1 and c2 lie on parallel lines. -# However, they are bounded (trimmed) curves -# and are shifted relatively to each other. So, -# perpendicular between these curves does not exist. - -line c1 0 0 0 1 0 0 -line c2 3 4 0 1 0 0 - -trim c1 c1 0 1 -trim c2 c2 0 1 - -extrema c1 c2 - -if { ![isdraw ext_1 ] } { - puts "Error in Extrema-algorithm" -} else { - puts "Extrema-algorithm works properly" -} - -renamevar ext_1 e1 -extrema c2 c1 - -if { ![isdraw ext_1 ] } { - puts "Error in Extrema-algorithm" -} else { - puts "Extrema-algorithm works properly" -} diff --git a/tests/lowalgos/extcc/bug29712_30 b/tests/lowalgos/extcc/bug29712_30 deleted file mode 100644 index cb25e69f33..0000000000 --- a/tests/lowalgos/extcc/bug29712_30 +++ /dev/null @@ -1,24 +0,0 @@ -puts "========" -puts "OCC29712" -puts "========" -puts "" -################################################# -# Extrema algorithm raises exception -################################################# - -# Curves c1 and c2 are concentric circles. -# However, they are bounded (trimmed) curves -# and are shifted relatively to each other. - -set ExpDist 50.0 - -circle c1 0 0 0 0 0 1 100 -circle c2 0 0 0 0 0 1 50 -trim c1 c1 0 3 -trim c2 c2 4.3 6.3 - -regexp {Infinite number of extremas, distance = +([-0-9.+eE]+)} [extrema c1 c2] full aDist1 -checkreal Distance $aDist1 $ExpDist 1.0e-7 0.0 - -regexp {Infinite number of extremas, distance = +([-0-9.+eE]+)} [extrema c2 c1] full aDist2 -checkreal Distance $aDist2 $ExpDist 1.0e-7 0.0 diff --git a/tests/lowalgos/extcc/bug29712_31 b/tests/lowalgos/extcc/bug29712_31 deleted file mode 100644 index aa03a2095e..0000000000 --- a/tests/lowalgos/extcc/bug29712_31 +++ /dev/null @@ -1,24 +0,0 @@ -puts "========" -puts "OCC29712" -puts "========" -puts "" -################################################# -# Extrema algorithm raises exception -################################################# - -# Curves c1 and c2 are concentric circles. -# However, they are bounded (trimmed) curves -# and are shifted relatively to each other. - -set ExpDist 50.0 - -circle c1 0 0 0 0 0 1 100 -circle c2 0 0 0 0 0 1 50 -trim c1 c1 0 pi -trim c2 c2 -9.5 -7.5 - -regexp {Infinite number of extremas, distance = +([-0-9.+eE]+)} [extrema c1 c2] full aDist1 -checkreal Distance $aDist1 $ExpDist 1.0e-7 0.0 - -regexp {Infinite number of extremas, distance = +([-0-9.+eE]+)} [extrema c2 c1] full aDist2 -checkreal Distance $aDist2 $ExpDist 1.0e-7 0.0 diff --git a/tests/lowalgos/extcc/bug29712_32 b/tests/lowalgos/extcc/bug29712_32 deleted file mode 100644 index 53a41faeb9..0000000000 --- a/tests/lowalgos/extcc/bug29712_32 +++ /dev/null @@ -1,35 +0,0 @@ -puts "========" -puts "OCC29712" -puts "========" -puts "" -################################################# -# Extrema algorithm raises exception -################################################# - -# Curves c1 and c2 are concentric circles. -# However, they are bounded (trimmed) curves -# and are shifted relatively to each other. - -set ExpDist 150.0 - -circle c1 0 0 0 0 0 1 100 -circle c2 0 0 0 0 0 1 50 -trim c1 c1 0 pi -trim c2 c2 -9.4 -7.4 - -extrema c1 c2 - -if { ![isdraw ext_1 ] } { - puts "Error in Extrema-algorithm" -} else { - puts "Extrema-algorithm works properly" -} - -renamevar ext_1 e1 -extrema c2 c1 - -if { ![isdraw ext_1 ] } { - puts "Error in Extrema-algorithm" -} else { - puts "Extrema-algorithm works properly" -} diff --git a/tests/lowalgos/extcc/bug29712_33 b/tests/lowalgos/extcc/bug29712_33 deleted file mode 100644 index eef4a02976..0000000000 --- a/tests/lowalgos/extcc/bug29712_33 +++ /dev/null @@ -1,24 +0,0 @@ -puts "========" -puts "OCC29712" -puts "========" -puts "" -################################################# -# Extrema algorithm raises exception -################################################# - -# Curves c1 and c2 are concentric circles. -# However, they are bounded (trimmed) curves -# and are shifted relatively to each other. - -set ExpDist 50.0 - -circle c1 0 0 0 0 0 1 100 -circle c2 0 0 0 0 0 1 50 -trim c1 c1 0 pi -trim c2 c2 0.0 2.0 - -regexp {Infinite number of extremas, distance = +([-0-9.+eE]+)} [extrema c1 c2] full aDist1 -checkreal Distance $aDist1 $ExpDist 1.0e-7 0.0 - -regexp {Infinite number of extremas, distance = +([-0-9.+eE]+)} [extrema c2 c1] full aDist2 -checkreal Distance $aDist2 $ExpDist 1.0e-7 0.0 \ No newline at end of file diff --git a/tests/lowalgos/extcc/bug29712_36 b/tests/lowalgos/extcc/bug29712_36 deleted file mode 100644 index ab4291f674..0000000000 --- a/tests/lowalgos/extcc/bug29712_36 +++ /dev/null @@ -1,24 +0,0 @@ -puts "========" -puts "OCC29712" -puts "========" -puts "" -################################################# -# Extrema algorithm raises exception -################################################# - -# Curves c1 and c2 are concentric circles. -# However, they are bounded (trimmed) curves -# and are shifted relatively to each other. - -set ExpDist 50.0 - -circle c1 0 0 0 0 0 1 100 -circle c2 0 0 0 0 0 1 50 -trim c1 c1 0 2*pi -trim c2 c2 -12.0 -10.0 - -regexp {Infinite number of extremas, distance = +([-0-9.+eE]+)} [extrema c1 c2] full aDist1 -checkreal Distance $aDist1 $ExpDist 1.0e-7 0.0 - -regexp {Infinite number of extremas, distance = +([-0-9.+eE]+)} [extrema c2 c1] full aDist2 -checkreal Distance $aDist2 $ExpDist 1.0e-7 0.0 \ No newline at end of file diff --git a/tests/lowalgos/extcc/bug29712_37 b/tests/lowalgos/extcc/bug29712_37 deleted file mode 100644 index f9efb64981..0000000000 --- a/tests/lowalgos/extcc/bug29712_37 +++ /dev/null @@ -1,37 +0,0 @@ -puts "========" -puts "OCC29712" -puts "========" -puts "" -################################################# -# Extrema algorithm raises exception -################################################# - -# Curves c1 and c2 are concentric circles. -# However, they are bounded (trimmed) curves -# and are shifted relatively to each other. - -set ExpDist 150.0 - -circle c1 0 0 0 0 0 1 100 -lmirror c1 0 0 0 1 0 0 -circle c2 0 0 0 0 0 1 50 -trim c1 c1 3 6.5 -trim c2 c2 4 6 - -extrema c1 c2 - -if { ![isdraw ext_1 ] } { - puts "Error in Extrema-algorithm" -} else { - puts "Extrema-algorithm works properly" -} - -renamevar ext_1 e1 -extrema c2 c1 - -if { ![isdraw ext_1 ] } { - puts "Error in Extrema-algorithm" -} else { - puts "Extrema-algorithm works properly" -} - diff --git a/tests/lowalgos/extcc/bug29712_38 b/tests/lowalgos/extcc/bug29712_38 deleted file mode 100644 index 96d3b987d2..0000000000 --- a/tests/lowalgos/extcc/bug29712_38 +++ /dev/null @@ -1,25 +0,0 @@ -puts "========" -puts "OCC29712" -puts "========" -puts "" -################################################# -# Extrema algorithm raises exception -################################################# - -# Curves c1 and c2 are concentric circles. -# However, they are bounded (trimmed) curves -# and are shifted relatively to each other. - -set ExpDist 50.0 - -circle c1 0 0 0 0 0 1 100 -lmirror c1 0 0 0 1 0 0 -circle c2 0 0 0 0 0 1 50 -trim c1 c1 0 4 -trim c2 c2 4 6 - -regexp {Infinite number of extremas, distance = +([-0-9.+eE]+)} [extrema c1 c2] full aDist1 -checkreal Distance $aDist1 $ExpDist 1.0e-7 0.0 - -regexp {Infinite number of extremas, distance = +([-0-9.+eE]+)} [extrema c2 c1] full aDist2 -checkreal Distance $aDist2 $ExpDist 1.0e-7 0.0 diff --git a/tests/lowalgos/extcc/bug29712_39 b/tests/lowalgos/extcc/bug29712_39 deleted file mode 100644 index 9c3a6f2d79..0000000000 --- a/tests/lowalgos/extcc/bug29712_39 +++ /dev/null @@ -1,19 +0,0 @@ -puts "========" -puts "OCC29712" -puts "========" -puts "" -################################################# -# Extrema algorithm raises exception -################################################# - -set ExpDist 5 - -circle c1 0 0 0 0 0 1 5 -line c2 0 0 0 0 0 1 -trim c2 c2 -1 1 - -regexp {Infinite number of extremas, distance = +([-0-9.+eE]+)} [extrema c1 c2] full aDist1 -checkreal Distance $aDist1 $ExpDist 1.0e-7 0.0 - -regexp {Infinite number of extremas, distance = +([-0-9.+eE]+)} [extrema c2 c1] full aDist2 -checkreal Distance $aDist2 $ExpDist 1.0e-7 0.0 diff --git a/tests/lowalgos/extcc/bug29712_4 b/tests/lowalgos/extcc/bug29712_4 deleted file mode 100644 index e446c580c7..0000000000 --- a/tests/lowalgos/extcc/bug29712_4 +++ /dev/null @@ -1,21 +0,0 @@ -puts "========" -puts "OCC29712" -puts "========" -puts "" -################################################# -# Extrema algorithm raises exception -################################################# - -# Extrema between parallel lines - -line c1 0 0 0 1 0 0 -line c2 0 4 0 1 0 0 - -trim c1 c1 0 1 -trim c2 c2 0 1 - -regexp {Infinite number of extremas, distance = +([-0-9.+eE]+)} [extrema c1 c2] full aDist1 -checkreal Distance $aDist1 4.0 0.0 2.0e-8 - -regexp {Infinite number of extremas, distance = +([-0-9.+eE]+)} [extrema c2 c1] full aDist2 -checkreal Distance $aDist2 4.0 0.0 2.0e-8 diff --git a/tests/lowalgos/extcc/bug29712_40 b/tests/lowalgos/extcc/bug29712_40 deleted file mode 100644 index a648fb5560..0000000000 --- a/tests/lowalgos/extcc/bug29712_40 +++ /dev/null @@ -1,19 +0,0 @@ -puts "========" -puts "OCC29712" -puts "========" -puts "" -################################################# -# Extrema algorithm raises exception -################################################# - -set ExpDist 5 - -circle c1 0 0 0 0 0 1 5 -line c2 0 0 0 0 0 1 -trim c2 c2 -1 -5e-8 - -regexp {Infinite number of extremas, distance = +([-0-9.+eE]+)} [extrema c1 c2] full aDist1 -checkreal Distance $aDist1 $ExpDist 1.0e-7 0.0 - -regexp {Infinite number of extremas, distance = +([-0-9.+eE]+)} [extrema c2 c1] full aDist2 -checkreal Distance $aDist2 $ExpDist 1.0e-7 0.0 diff --git a/tests/lowalgos/extcc/bug29712_41 b/tests/lowalgos/extcc/bug29712_41 deleted file mode 100644 index 9950478a55..0000000000 --- a/tests/lowalgos/extcc/bug29712_41 +++ /dev/null @@ -1,19 +0,0 @@ -puts "========" -puts "OCC29712" -puts "========" -puts "" -################################################# -# Extrema algorithm raises exception -################################################# - -set ExpDist 5 - -circle c1 0 0 0 0 0 1 5 -line c2 0 0 0 0 0 1 -trim c2 c2 3e-8 1 - -regexp {Infinite number of extremas, distance = +([-0-9.+eE]+)} [extrema c1 c2] full aDist1 -checkreal Distance $aDist1 $ExpDist 1.0e-7 0.0 - -regexp {Infinite number of extremas, distance = +([-0-9.+eE]+)} [extrema c2 c1] full aDist2 -checkreal Distance $aDist2 $ExpDist 1.0e-7 0.0 diff --git a/tests/lowalgos/extcc/bug29712_42 b/tests/lowalgos/extcc/bug29712_42 deleted file mode 100644 index 478d2a8bce..0000000000 --- a/tests/lowalgos/extcc/bug29712_42 +++ /dev/null @@ -1,25 +0,0 @@ -puts "========" -puts "OCC29712" -puts "========" -puts "" -################################################# -# Extrema algorithm raises exception -################################################# - -set ExpDist 5 - -circle c1 0 0 0 0 0 1 5 -line c2 0 0 0 0 0 1 -trim c2 c2 2e-7 1 - -if { ![regexp {No solutions!} [extrema c1 c2] ] } { - puts "Error in Extrema-algorithm" -} else { - puts "Extrema-algorithm works properly" -} - -if { ![regexp {No solutions!} [extrema c2 c1] ] } { - puts "Error in Extrema-algorithm" -} else { - puts "Extrema-algorithm works properly" -} diff --git a/tests/lowalgos/extcc/bug29712_43 b/tests/lowalgos/extcc/bug29712_43 deleted file mode 100644 index 4a9d7da486..0000000000 --- a/tests/lowalgos/extcc/bug29712_43 +++ /dev/null @@ -1,25 +0,0 @@ -puts "========" -puts "OCC29712" -puts "========" -puts "" -################################################# -# Extrema algorithm raises exception -################################################# - -set ExpDist 5 - -circle c1 0 0 0 0 0 1 5 -line c2 0 0 0 0 0 1 -trim c2 c2 -1.5e-7 -1 - -if { ![regexp {No solutions!} [extrema c1 c2] ] } { - puts "Error in Extrema-algorithm" -} else { - puts "Extrema-algorithm works properly" -} - -if { ![regexp {No solutions!} [extrema c2 c1] ] } { - puts "Error in Extrema-algorithm" -} else { - puts "Extrema-algorithm works properly" -} diff --git a/tests/lowalgos/extcc/bug29712_5 b/tests/lowalgos/extcc/bug29712_5 deleted file mode 100644 index c43d75dd96..0000000000 --- a/tests/lowalgos/extcc/bug29712_5 +++ /dev/null @@ -1,34 +0,0 @@ -puts "========" -puts "OCC29712" -puts "========" -puts "" -################################################# -# Extrema algorithm raises exception -################################################# - -# Curves c1 and c2 lie on parallel lines. -# However, they are bounded (trimmed) curves -# and are shifted relatively to each other. So, -# perpendicular between these curves does not exist. - -line c1 1 0 0 0 0 1 -line c2 5 0 0 0 0 1 -trim c1 c1 -1.0e100 5 -trim c2 c2 10 20 - -extrema c1 c2 - -if { ![isdraw ext_1 ] } { - puts "Error in Extrema-algorithm" -} else { - puts "Extrema-algorithm works properly" -} - -renamevar ext_1 e1 -extrema c2 c1 - -if { ![isdraw ext_1 ] } { - puts "Error in Extrema-algorithm" -} else { - puts "Extrema-algorithm works properly" -} \ No newline at end of file diff --git a/tests/lowalgos/extcc/bug29712_6 b/tests/lowalgos/extcc/bug29712_6 deleted file mode 100644 index 18d66b1c55..0000000000 --- a/tests/lowalgos/extcc/bug29712_6 +++ /dev/null @@ -1,18 +0,0 @@ -puts "========" -puts "OCC29712" -puts "========" -puts "" -################################################# -# Extrema algorithm raises exception -################################################# - -# Extrema between parallel lines - -line c1 1 2 3 0 1 0 -line c2 10 9 8 0 1 0 - -regexp {Infinite number of extremas, distance = +([-0-9.+eE]+)} [extrema c1 c2] full aDist1 -checkreal Distance $aDist1 [expr sqrt(106.0)] 0.0 1.0e-8 - -regexp {Infinite number of extremas, distance = +([-0-9.+eE]+)} [extrema c2 c1] full aDist2 -checkreal Distance $aDist2 [expr sqrt(106.0)] 0.0 1.0e-8 diff --git a/tests/lowalgos/extcc/bug29712_7 b/tests/lowalgos/extcc/bug29712_7 deleted file mode 100644 index 505565ca72..0000000000 --- a/tests/lowalgos/extcc/bug29712_7 +++ /dev/null @@ -1,19 +0,0 @@ -puts "========" -puts "OCC29712" -puts "========" -puts "" -################################################# -# Extrema algorithm raises exception -################################################# - -# Extrema between parallel lines - -line c1 1 2 3 0 1 0 -line c2 10 9 8 0 1 0 -trim c2 c2 -1 2 - -regexp {Infinite number of extremas, distance = +([-0-9.+eE]+)} [extrema c1 c2] full aDist1 -checkreal Distance $aDist1 [expr sqrt(106.0)] 0.0 1.0e-8 - -regexp {Infinite number of extremas, distance = +([-0-9.+eE]+)} [extrema c2 c1] full aDist2 -checkreal Distance $aDist2 [expr sqrt(106.0)] 0.0 1.0e-8 diff --git a/tests/lowalgos/extcc/bug29712_8 b/tests/lowalgos/extcc/bug29712_8 deleted file mode 100644 index 9f7f325756..0000000000 --- a/tests/lowalgos/extcc/bug29712_8 +++ /dev/null @@ -1,19 +0,0 @@ -puts "========" -puts "OCC29712" -puts "========" -puts "" -################################################# -# Extrema algorithm raises exception -################################################# - -# Extrema between parallel lines - -line c1 1 2 3 0 1 0 -line c2 10 9 8 0 1 0 -trim c1 c1 -100 200 - -regexp {Infinite number of extremas, distance = +([-0-9.+eE]+)} [extrema c1 c2] full aDist1 -checkreal Distance $aDist1 [expr sqrt(106.0)] 0.0 1.0e-8 - -regexp {Infinite number of extremas, distance = +([-0-9.+eE]+)} [extrema c2 c1] full aDist2 -checkreal Distance $aDist2 [expr sqrt(106.0)] 0.0 1.0e-8 diff --git a/tests/lowalgos/extcc/bug29712_9 b/tests/lowalgos/extcc/bug29712_9 deleted file mode 100644 index 45fd11caca..0000000000 --- a/tests/lowalgos/extcc/bug29712_9 +++ /dev/null @@ -1,20 +0,0 @@ -puts "========" -puts "OCC29712" -puts "========" -puts "" -################################################# -# Extrema algorithm raises exception -################################################# - -# Extrema between parallel lines - -line c1 1 0 0 0 0 -1 -line c2 5 0 0 0 0 1 -trim c1 c1 -5 2 -trim c2 c2 -1.0e100 9.9e-8 - -regexp {Infinite number of extremas, distance = +([-0-9.+eE]+)} [extrema c1 c2] full aDist1 -checkreal Distance $aDist1 4.0 0.0 1.0e-8 - -regexp {Infinite number of extremas, distance = +([-0-9.+eE]+)} [extrema c2 c1] full aDist2 -checkreal Distance $aDist2 4.0 0.0 1.0e-8 \ No newline at end of file diff --git a/tests/lowalgos/extcs/bug29426_1 b/tests/lowalgos/extcs/bug29426_1 deleted file mode 100644 index d8146b216d..0000000000 --- a/tests/lowalgos/extcs/bug29426_1 +++ /dev/null @@ -1,18 +0,0 @@ -puts "========" -puts "OCC29426" -puts "========" -puts "" -######################################## -# Extrema algorithm fails to find minimal distance between Circle and Sphere -######################################## - - -circle c 3.59679185933224e-016 11.6635040382361 -3.23970209548358 -3.67401855705945e-017 -0.943656647634893 0.330926172090505 -2.2723161366922e-016 0.330926172090505 0.943656647634893 1.30000000000039 -sphere s 0 2.425 0 0 1 0 1 -0 0 9.876 - -set log [extrema c s] - -if {![regexp "Point" $log]} { - set ext_dist [lindex [length ext_1] end] - checkreal "Circle/Sphere min distance" $ext_dist 0. 1.e-10 1.e-10 -} diff --git a/tests/lowalgos/extcs/bug29426_2 b/tests/lowalgos/extcs/bug29426_2 deleted file mode 100644 index 82155b225f..0000000000 --- a/tests/lowalgos/extcs/bug29426_2 +++ /dev/null @@ -1,17 +0,0 @@ -puts "========" -puts "OCC29426" -puts "========" -puts "" -######################################## -# Extrema algorithm fails to find minimal distance between Circle and Sphere -######################################## - -circle c 3.53600008984273e-016 11.5073628633636 -3.18494573739955 -3.67401855705945e-017 -0.943656647634893 0.330926172090505 -2.2723161366922e-016 0.330926172090505 0.943656647634893 1.30000000000039 -sphere s 0 2.425 0 0 1 0 1 -0 0 9.712 - -set log [extrema c s] - -if {![regexp "Point" $log]} { - set ext_dist [lindex [length ext_1] end] - checkreal "Circle/Sphere min distance" $ext_dist 0. 1.e-10 1.e-10 -} diff --git a/tests/lowalgos/extcs/circ_sph_inter b/tests/lowalgos/extcs/circ_sph_inter deleted file mode 100644 index 7fe93a5cba..0000000000 --- a/tests/lowalgos/extcs/circ_sph_inter +++ /dev/null @@ -1,127 +0,0 @@ -puts "=======================" -puts "Test for Circle/Sphere extrema algorithm" -puts "Intersection case (two intersection points should be found" -puts "=======================" -puts "" - -# Make sphere -set x0 0. -set y0 0. -set z0 0. -set sph_radius 10. -sphere s $x0 $y0 $z0 $sph_radius - -# All circles will be to connect the two points - one inside the sphere, another - outside. -# Such circle will definitely intersect the initial sphere in two points. -# The points to make the circle will taken two spheres - with smaller and bigger radius. - -# Set the number of iterations (number of pairs of spheres) -set nbpairs 2 - -# Set ratio to increase/decrease the radius if additional spheres -set ratio_radius 2. - -# Number of sampling points on the spheres -set nbsamples 5 - -# Number of circles rotations -set nbsteps 5 -set angle [expr 180. / $nbsteps] - -# Iteration step -set iStep 1 - -for {set i 1} {$i <= $nbpairs} {incr i} { - # Define the radius for spheres - set s_in_radius [expr $sph_radius / ($i * $ratio_radius)] - set s_out_radius [expr $sph_radius * ($i * $ratio_radius)] - - # Make the spheres - sphere s_in $x0 $y0 $z0 $s_in_radius - sphere s_out $x0 $y0 $z0 $s_out_radius - - # Make the sampling of the spheres - - # spheres are the same, so there is no difference from which one to take the parameters - bounds s_in umin umax vmin vmax - set du [dval (umax-umin)/$nbsteps] - set dv [dval (vmax-vmin)/$nbsteps] - - for {set u1 1} {$u1 <= $nbsamples} {incr u1} { - for {set v1 1} {$v1 <= $nbsamples} {incr v1} { - - # point on inner sphere - svalue s_in [dval umin+$u1*$du] [dval vmin+$v1*$dv] x1 y1 z1 - - for {set u2 1} {$u2 <= $nbsamples} {incr u2} { - for {set v2 1} {$v2 <= $nbsamples} {incr v2} { - - # point on outer sphere - svalue s_out [dval umin+$u2*$du] [dval vmin+$v2*$dv] x2 y2 z2 - - # rotation direction - set dx [dval x2-x1] - set dy [dval y2-y1] - set dz [dval z2-z1] - - # center of the circle - set xc [dval (x1+x2)/2.] - set yc [dval (y1+y2)/2.] - set zc [dval (z1+z2)/2.] - - # compute radius for circle - set cir_radius [expr sqrt($dx*$dx + $dy*$dy + $dz*$dz) / 2.] - - # make plane to get its XAxis - plane p $xc $yc $zc $dx $dy $dz - - regexp {XAxis :([-0-9.+eE]*), ([-0-9.+eE]*), ([-0-9.+eE]*)} [dump p] full dxx dxy dxz - - circle c $xc $yc $zc $dxx $dxy $dxz $cir_radius - - # make rotation - copy c c_rotated - for {set j 1} {$j <= $nbsteps} {incr j} { - rotate c_rotated $xc $yc $zc $dx $dy $dz $angle - - set log [extrema c_rotated s] - - # save each circle if necessary - # copy c_rotated c_$iStep - - set isfound1 0 - set isfound2 0 - - if {[regexp "ext_1" $log]} { - set ext_dist [lindex [length ext_1] end] - checkreal "Step $iStep, min distance 1" $ext_dist 0 1.e-7 1.e-7 - set isfound1 1 - } - - if {[regexp "ext_2" $log]} { - set ext_dist [lindex [length ext_2] end] - checkreal "Step $iStep, min distance 2" $ext_dist 0 1.e-7 1.e-7 - set isfound2 1 - } - - if {[regexp "Extrema 1 is point" $log]} { - puts "Check of Step $iStep, min distance 1 OK" - set isfound1 1 - } - - if {[regexp "Extrema 2 is point" $log]} { - puts "Check of Step $iStep, min distance 2 OK" - set isfound2 1 - } - - if {$isfound1 == 0 || $isfound2 == 0} { - puts "Error: Extrema has not detected the intersection case on step $iStep" - } - - incr iStep - } - } - } - } - } -} diff --git a/tests/lowalgos/extcs/circ_sph_nointer b/tests/lowalgos/extcs/circ_sph_nointer deleted file mode 100644 index 413126064f..0000000000 --- a/tests/lowalgos/extcs/circ_sph_nointer +++ /dev/null @@ -1,160 +0,0 @@ -puts "=======================" -puts "Test for Circle/Sphere extrema algorithm" -puts "No intersection cases - one minimum solution should be found" -puts "=======================" -puts "" - -# Make sphere -set x0 0. -set y0 0. -set z0 0. -set sph_radius 10. -sphere s $x0 $y0 $z0 $sph_radius - -# The circles will be made on the distance from the surface -# as intersection of pairs of inner and outer spheres with the plane - -# Set the number of iterations -set nbstep 5 -# Rotation angle -set angle [expr 180. / $nbstep] - -# Set the number of Inner/Outer spheres in one direction -set nbpairs 1 -# Set the delta for the radius of inner circle -set delta_radius [expr $sph_radius * 0.9 / (2 * $nbpairs)] - -# Step for sampling of the circle -set dt [expr [dval 2*pi] / $nbstep] - -# Iteration step -set iStep 1 - -for {set i 1} {$i <= $nbpairs} {incr i} { - # Define the inner circle - set circ_radius [expr $i * $delta_radius] - circle c $x0 $y0 $z0 0 0 1 $circ_radius - - set diff [expr $sph_radius - $circ_radius] - - # Distance between inner sphere on circle and initial sphere - set real_dist [expr $sph_radius - 2*$circ_radius] - - # Circle will be rotated around the line - line rotation_line $x0 $y0 $z0 1 0 0 - - # Line rotation - for {set j 1} {$j <= $nbstep} {incr j} { - rotate rotation_line $x0 $y0 $z0 0 0 1 $angle - - # Get direction for circle's rotation - regexp {Axis :([-0-9.+eE]*), ([-0-9.+eE]*), ([-0-9.+eE]*)} [dump rotation_line] full dx dy dz - - # Circle rotation - copy c c_rotated - for {set k 1} {$k <= $nbstep} {incr k} { - rotate c_rotated 0 0 0 $dx $dy $dz $angle - - # Sampling of the circle - for {set n 1} {$n <= $nbstep} {incr n} { - cvalue c_rotated $n*$dt x1 y1 z1 - - set x1 [dval x1] - set y1 [dval y1] - set z1 [dval z1] - - # Normalize the vector - set dtx [expr ($x1 - $x0) / $circ_radius] - set dty [expr ($y1 - $y0) / $circ_radius] - set dtz [expr ($z1 - $z0) / $circ_radius] - - # Create inner and outer spheres - set iC 1 - - repeat 2 { - sphere s_to_int $x1 $y1 $z1 $circ_radius - - # Define the point closest to the initial sphere - set x_sol [expr $x1 + $iC * $circ_radius * $dtx] - set y_sol [expr $y1 + $iC * $circ_radius * $dty] - set z_sol [expr $z1 + $iC * $circ_radius * $dtz] - - - # Intersect the sphere with the plane originated in closes point - - # Make the sampling of the sphere to define section plane's direction - - bounds s_to_int umin umax vmin vmax - - set du [dval (umax-umin)/$nbstep] - set dv [dval (vmax-vmin)/$nbstep] - - for {set u 1} {$u <= $nbstep} {incr u} { - for {set v 1} {$v <= $nbstep} {incr v} { - - # Get point on surface - svalue s_to_int [dval umin+$u*$du] [dval vmin+$v*$dv] xs ys zs - - # Check that it is not the same point - set sqdist [dval (xs-$x_sol)*(xs-$x_sol)+(ys-$y_sol)*(ys-$y_sol)+(zs-$z_sol)*(zs-$z_sol)] - if {$sqdist < 1.e-16} { - # Skip the sampling point - continue; - } - - # Create the intersection plane - plane p_int $x_sol $y_sol $z_sol [dval xs-$x_sol] [dval ys-$y_sol] [dval zs-$z_sol] - # Intersect the sphere by plane to obtain the circle - foreach c_int [intersect c_inter s_to_int p_int] { - - # Check if the circle contains the point - if {![regexp "Point on curve" [proj $c_int $x_sol $y_sol $z_sol]]} { - if {[lindex [length ext_1] end] >= 1.e-7} { - # run extrema - one of the ends of the curve should be the solution - set log [extrema $c_int s 1] - if {[regexp "prm_1_1" $log]} { - # get parameters of the curve - bounds $c_int fp lp - if {[dval prm_1_1-fp] > 1.e-7 && [dval lp-prm_1_1] > 1.e-7} { - puts "Error: Extrema has failed to find the minimal distance on step $iStep" - } - } else { - puts "Error: Extrema has failed to find the minimal distance on step $iStep" - } - - # save each circle if necessary - # copy $c_int c_$iStep - - incr iStep - continue - } - } - - # Make extrema computation - set log [extrema $c_int s] - - # save each circle if necessary - # copy $c_int c_$iStep - - if {![regexp "ext_1" $log]} { - puts "Error: Extrema has failed to find the minimal distance on step $iStep" - } else { - set ext_dist [lindex [length ext_1] end] - checkreal "Step $iStep, min distance " $ext_dist $real_dist 1.e-7 1.e-7 - } - incr iStep - } - } - } - - # prepare for the outer sphere - set x1 [expr $x1 + 2 * $diff * $dtx] - set y1 [expr $y1 + 2 * $diff * $dty] - set z1 [expr $z1 + 2 * $diff * $dtz] - - set iC -1 - } - } - } - } -} diff --git a/tests/lowalgos/extcs/circ_sph_parallel b/tests/lowalgos/extcs/circ_sph_parallel deleted file mode 100644 index 8625e04caf..0000000000 --- a/tests/lowalgos/extcs/circ_sph_parallel +++ /dev/null @@ -1,82 +0,0 @@ -puts "=======================" -puts "Test for Circle/Sphere extrema algorithm" -puts "Parallel case (center of sphere is on the circle's axis)" -puts "=======================" -puts "" - -# Make sphere -set x0 0. -set y0 0. -set z0 0. -set sph_radius 10. -sphere s $x0 $y0 $z0 $sph_radius - -# Initially the circle will be made at the same place as sphere with different radius -# and will be rotated and shifted many times. -# The distance between circle and sphere is a Abs(sqrt(centers_dist^2 + circ_radius^2) - sph_radius) - -# Number of different radius of initial circle -set nb_radius 7 -# Number of circle's rotations -set nbstep 8 -set angle [expr 180. / $nbstep] - -# Define the shift -set shift_start -3 -set shift_end 3 -set shift 4 - -# Iteration step -set iStep 1 - -for {set i 1} {$i < $nb_radius} {incr i} { - set circ_radius [expr $i*2.] - circle c $x0 $y0 $z0 0 0 1 $circ_radius - - # Circle will be rotated around the line - line rotation_line $x0 $y0 $z0 1 0 0 - # Line rotation - for {set j 1} {$j <= $nbstep} {incr j} { - rotate rotation_line $x0 $y0 $z0 0 0 1 $angle - - # Get direction for circle's rotation - regexp {Axis :([-0-9.+eE]*), ([-0-9.+eE]*), ([-0-9.+eE]*)} [dump rotation_line] full dx dy dz - - # Circle rotation - copy c c_rotated - for {set k 1} {$k <= $nbstep} {incr k} { - rotate c_rotated $x0 $y0 $z0 $dx $dy $dz $angle - - # Add shift of the circle along its own axis - - # Get shift direction - regexp {Axis :([-0-9.+eE]*), ([-0-9.+eE]*), ([-0-9.+eE]*)} [dump c_rotated] full dcx dcy dcz - - set dcx [expr $shift*$dcx] - set dcy [expr $shift*$dcy] - set dcz [expr $shift*$dcz] - - # Make the shift - for {set t $shift_start} {$t <= $shift_end} {incr t} { - copy c_rotated c_shifted - translate c_shifted $t*$dcx $t*$dcy $t*$dcz - - set log [extrema c_shifted s] - - # save each circle if necessary - # copy c_shifted c_$iStep - - if {![regexp "Infinite number of extremas" $log]} { - puts "Error: Extrema has not detected the parallel case on step $iStep" - } else { - regexp {Center :([-0-9.+eE]*), ([-0-9.+eE]*), ([-0-9.+eE]*)} [dump c_shifted] full x y z - set centers_dist [expr sqrt($x*$x + $y*$y + $z*$z)] - set real_dist [expr abs(sqrt($centers_dist*$centers_dist + $circ_radius*$circ_radius) - $sph_radius)] - set ext_dist [lindex $log end] - checkreal "Step $iStep, min distance " $ext_dist $real_dist 1.e-7 1.e-7 - } - incr iStep - } - } - } -} diff --git a/tests/lowalgos/extcs/circ_sph_touch b/tests/lowalgos/extcs/circ_sph_touch deleted file mode 100644 index d4483a4a01..0000000000 --- a/tests/lowalgos/extcs/circ_sph_touch +++ /dev/null @@ -1,93 +0,0 @@ -puts "=======================" -puts "Test for Circle/Sphere extrema algorithm" -puts "Touch case (circle is just touching the sphere)" -puts "=======================" -puts "" - -# Make sphere -set x0 0. -set y0 0. -set z0 0. -set sph_radius 10. -sphere s $x0 $y0 $z0 $sph_radius - -# Initially the circle will be made at the same place as sphere with different radius -# and will shifted many times to touch the sphere. -# The distance should always be close to zero. - -# Number of different radius of initial circle -set nb_radius 7 -# Number of circle's rotations -set nbstep 8 -set angle [expr 180. / $nbstep] - -# Iteration step -set iStep 1 - -for {set i 1} {$i < $nb_radius} {incr i} { - set circ_radius [expr $i*2.] - if {$circ_radius == $sph_radius} { - set circ_radius [expr $circ_radius + 0.1] - } - circle c $x0 $y0 $z0 0 0 1 $circ_radius - - # Circle will be rotated around the line - line rotation_line $x0 $y0 $z0 1 0 0 - # Line rotation - for {set j 1} {$j <= $nbstep} {incr j} { - rotate rotation_line $x0 $y0 $z0 0 0 1 $angle - - # Get direction for circle's rotation - regexp {Axis :([-0-9.+eE]*), ([-0-9.+eE]*), ([-0-9.+eE]*)} [dump rotation_line] full dx dy dz - - # Circle rotation - copy c c_rotated - for {set k 1} {$k <= $nbstep} {incr k} { - rotate c_rotated $x0 $y0 $z0 $dx $dy $dz $angle - - # Get translation axis for the circle - regexp {XAxis :([-0-9.+eE]*), ([-0-9.+eE]*), ([-0-9.+eE]*)} [dump c_rotated] full dxx dxy dxz - - # Get rotation plane for translation line - regexp {YAxis :([-0-9.+eE]*), ([-0-9.+eE]*), ([-0-9.+eE]*)} [dump c_rotated] full dyx dyy dyz - - line translation_line $x0 $y0 $z0 $dxx $dxy $dxz - - for {set n 1} {$n <= $nbstep} {incr n} { - rotate translation_line $x0 $y0 $z0 $dyx $dyy $dyz $angle - - # Get direction for circle's translation - regexp {Axis :([-0-9.+eE]*), ([-0-9.+eE]*), ([-0-9.+eE]*)} [dump translation_line] full dtx dty dtz - - # Circle's translation - copy c_rotated c_shifted - translate c_shifted $sph_radius*$dtx $sph_radius*$dty $sph_radius*$dtz - - # Shift circle to touch sphere - set shift -1 - repeat 2 { - copy c_shifted c_touch - translate c_touch $shift*$circ_radius*$dxx $shift*$circ_radius*$dxy $shift*$circ_radius*$dxz - - set log [extrema c_touch s] - - # save each circle if necessary - # copy c_touch c_$iStep - - if {![regexp "ext_1" $log]} { - if {![regexp "Extrema 1 is point" $log]} { - puts "Error: Extrema has not detected the touching case on step $iStep" - } else { - puts "Check of Step $iStep, min distance OK" - } - } else { - set ext_dist [lindex [length ext_1] end] - checkreal "Step $iStep, min distance " $ext_dist 0 1.e-7 1.e-7 - } - incr iStep - set shift 1 - } - } - } - } -} diff --git a/tests/lowalgos/extss/bug29712_44 b/tests/lowalgos/extss/bug29712_44 deleted file mode 100644 index e12fea2899..0000000000 --- a/tests/lowalgos/extss/bug29712_44 +++ /dev/null @@ -1,20 +0,0 @@ -puts "========" -puts "OCC29712" -puts "========" -puts "" -################################################# -# Extrema algorithm raises exception -################################################# - -# Planes s1 and s2 are parallel. - -set ExpDist 10.0 - -plane s1 0 0 0 0 0 1 -plane s2 0 0 10 0 0 1 - -regexp {Infinite number of extremas, distance = +([-0-9.+eE]+)} [extrema s1 s1] full aDist1 -checkreal Distance $aDist1 $ExpDist 1.0e-7 0.0 - -regexp {Infinite number of extremas, distance = +([-0-9.+eE]+)} [extrema s2 s2] full aDist2 -checkreal Distance $aDist2 $ExpDist 1.0e-7 0.0 diff --git a/tests/lowalgos/intcs/bug26979 b/tests/lowalgos/intcs/bug26979 deleted file mode 100644 index 43d21fcc6e..0000000000 --- a/tests/lowalgos/intcs/bug26979 +++ /dev/null @@ -1,39 +0,0 @@ -puts "================" -puts "0026979: Modeling Algorithms - Parabola curve intersection with variety of surfaces produces incorrect results" -puts "================" -puts "" - -set BugNumber OCC26979 - -parabola c -5.0 -1.0 0.25 0 0 1 0.25 -trim c c 0 1000 - -beziersurf bz 3 3 -4 0 -1 -4 1 0 -4 0 1 -3 1 -1 -3 2 0 -3 1 1 -2 0 -1 -2 1 0 -2 0 1 - -bsplinesurf bs \ -1 5 0 1 1 1 2 1 3 1 4 1 \ -1 5 0 1 1 1 2 1 3 1 4 1 \ --3 0.5 -1 1 -2 0.5 0 1 -3 0.5 1 1 \ --2 1.5 -1 1 -1 1.5 0 1 -2 1.5 1 1 \ --3 2.5 -1 1 -2 2.5 0 1 -3 2.5 1 1 - -torus tor 3 1 - -circle c1 0 0 0 4 -trim c1 c1 -3.5 1 -extsurf ext c1 0 0 1 - -circle c2 0 0 0 0 -1 0 1 0 0 3 -trim c2 c2 -pi/2 pi/2 -revsurf rev c2 0 0 0 0 0 1 - -# intersect all surfaces -set surfaces [list bz bs tor ext rev] -foreach s $surfaces { - set num [llength [intersect result $c $s 1e-7]]; - if {$num == 0} { - puts "Faulty ${BugNumber}: no intersection point is got" - } else { - puts "OK ${BugNumber}"; - } -} \ No newline at end of file diff --git a/tests/lowalgos/intss/bug23644 b/tests/lowalgos/intss/bug23644 deleted file mode 100644 index b4fd0ca772..0000000000 --- a/tests/lowalgos/intss/bug23644 +++ /dev/null @@ -1,20 +0,0 @@ -puts "========" -puts "CR23644" -puts "========" - -########################################## -## Intersection between coaxial cones produces exception -########################################## - -pcone cn1 10 0 20 -pcone cn2 20 0 20 -explode cn1 f -explode cn2 f -copy cn1_1 f1 -copy cn2_1 f2 - -if [catch {bopcurves f1 f2} BOPLog] { - if { [regexp "Tolerance Reached=0\n has no 3d curve" ${BOPLog}] != 1 } { - puts "CR23644: Error" - } -} diff --git a/tests/lowalgos/intss/bug24313 b/tests/lowalgos/intss/bug24313 deleted file mode 100644 index 5a279888cc..0000000000 --- a/tests/lowalgos/intss/bug24313 +++ /dev/null @@ -1,14 +0,0 @@ -puts "============" -puts "OCC24313" -puts "============" -puts "" -####################################################################### -# BRepAlgoAPI_Section and IntTools_FaceFace aren't written to handle Geom_SurfaceOfLinearExtrusion -####################################################################### - -circle c 0 0 0 0 0 1 1 0 0 100 -extsurf s1 c 0 0 1 -plane s2 0 0 0 1 0 0 0 1 0 -mkface b1 s1 -mkface b2 s2 -bopcurves b1 b2 diff --git a/tests/lowalgos/intss/bug24418_2 b/tests/lowalgos/intss/bug24418_2 deleted file mode 100644 index 586ba445dc..0000000000 --- a/tests/lowalgos/intss/bug24418_2 +++ /dev/null @@ -1,26 +0,0 @@ -##puts "TODO OCC24418 ALL: Error in ii_1: T=" - -puts "========" -puts "OCC24418" -puts "========" -puts "" -############################################################ -# Wrong section curves when intersecting analytical surfaces -############################################################ - -ptorus b1 25 24 90 -plane p 20 20 10 0 0 1 -pcone b2 p 10 8 40 -explode b1 f; copy b1_1 b1 -explode b2 f; copy b2_1 b2 -mksurface s1 b1 -mksurface s2 b2 -trimu s1t s1 0 1.5707963267948966 -trimv s2t s2 0 40.049968789001575 - -intersect ii s1t s2t - -bounds ii_1 u1 u2 - -xdistcs ii_1 s1 u1 u2 10 2.0e-7 -xdistcs ii_1 s2 u1 u2 10 2.0e-7 diff --git a/tests/lowalgos/intss/bug25782_2 b/tests/lowalgos/intss/bug25782_2 deleted file mode 100644 index a54a2915f8..0000000000 --- a/tests/lowalgos/intss/bug25782_2 +++ /dev/null @@ -1,51 +0,0 @@ -puts "========" -puts "OCC25782" -puts "========" -puts "" -###################################################### -# The result of intersection between two cylinders is incorrect -###################################################### - -set GoodNbCurv 2 - -cylinder s1 0 0 0 12 35 47 5 -cylinder s2 3 2 8 12 35 47 4 - -set bug_info [intersect res s1 s2] - -set che [whatis res] -set ind [string first "3d curve" $che] -if {${ind} >= 0} { - #Only variable "res" exists - - copy res res_1 -} - -if {[llength ${bug_info}] != $GoodNbCurv} { - puts "Error: The result of intersection between two cylinders is incorrect" -} - -set Tolerance 1.e-7 -set D_good 0. -set Limit_Tol 1.0e-7 - -set ic 1 -set AllowRepeate 1 -while { $AllowRepeate != 0 } { - set che [whatis res_$ic] - set ind [string first "3d curve" $che] - if {${ind} < 0} { - set AllowRepeate 0 - } else { - if { [regexp {\*\*\nLine} [dump res_$ic]] } { - #puts "OK : Correct intersection" - } else { - puts "Error : Bad intersection" - } - - xdistcs res_$ic s1 0 100 10 1e-7 - xdistcs res_$ic s2 0 100 10 1e-7 - - incr ic - } -} diff --git a/tests/lowalgos/intss/bug32850 b/tests/lowalgos/intss/bug32850 deleted file mode 100644 index 8312243c35..0000000000 --- a/tests/lowalgos/intss/bug32850 +++ /dev/null @@ -1,19 +0,0 @@ -puts "========" -puts "0032850: Modeling Algorithms - Surface Surface Intersect Lost one line" -puts "========" -puts "" - -cylinder s1 25.8071575178163 0 -373.974517822281 0 1 0 -1.73024882663956e-06 0 0.999999999998503 408.974517822893 -trim s1 s1 0 0.0225015452057227 -146.010003766057 2146.01000376606 -cylinder s2 0 1974.19284248218 -373.974517822281 1 0 0 -0 1.73024882663956e-06 0.999999999998503 408.974517822893 -trim s2 s2 0 0.0225015452057227 -146.010003766057 946.010003766057 -mkface f1 s1; -mkface f2 s2; -set log [bopcurves f1 f2] -regexp {Tolerance Reached=+([-0-9.+eE]+)\n+([-0-9.+eE]+)} $log full Toler NbCurv -if {$NbCurv != 4} { - puts "Error: Number of curves is wrong" -} -if { $Toler > 1.0e-12} { - puts "Error: Big tolerance value" -} \ No newline at end of file diff --git a/tests/lowalgos/intss/bug33244 b/tests/lowalgos/intss/bug33244 deleted file mode 100644 index 8a571926a0..0000000000 --- a/tests/lowalgos/intss/bug33244 +++ /dev/null @@ -1,48 +0,0 @@ - -puts "============" -puts "0033244: Modeling Algorithms - Surface-surface intersection produces the double curves" -puts "============" -puts "" - - -set PI180 0.017453292519943295 - -set x -1.11630646267172 -set y -4.54487349779333 -set z 13.2493435203532 -set dx -1.05794851588922e-07 -set dy -1.39278337794573e-08 -set dz 0.999999999999994 -set ux 0.999999999999994 -set uy 5.91645678915759e-31 -set uz 1.05794851588922e-07 -set semi-angle [expr 0.785398163360967 / ${PI180}] -set radius 0.560000000061149 - -cone s1 ${x} ${y} ${z} ${dx} ${dy} ${dz} ${semi-angle} ${radius} - -set x -2.08647872350287e-07 -set y -5.78732475509323 -set z 13.2493436211 -set dx -1.05794850062242e-07 -set dy -1.39278350756825e-08 -set dz 0.999999999999994 -set ux 0.999999999999995 -set uy 0 -set uz 1.05794850062242e-07 -set semi-angle [expr 0.785398163396248 / ${PI180}] -set radius 0.785398163396248 - -cone s2 ${x} ${y} ${z} ${dx} ${dy} ${dz} ${semi-angle} ${radius} - -intersect ii s1 s2 -if { ![isdraw ii_1] || ![isdraw ii_2] || [isdraw ii_3] } { - puts "ERROR. Intersection is wrong" -} - -intersect jj s2 s1 -if { ![isdraw jj_1] || ![isdraw jj_2] || [isdraw jj_3] } { - puts "ERROR. Intersection is wrong" -} - - diff --git a/tests/lowalgos/progress/A1 b/tests/lowalgos/progress/A1 deleted file mode 100644 index cd35900c6b..0000000000 --- a/tests/lowalgos/progress/A1 +++ /dev/null @@ -1,33 +0,0 @@ -puts "========" -puts "0031190: Modeling Algorithms - progress indication in GeomPlate is inconsistent" -puts "========" - -plane p -trim p p -1 3 -1 3 -mkface p p - -beziercurve c1 3 0 0 0 1 0 1 2 0 0 -mkedge e1 c1 -tcopy e1 e2 -tcopy e1 e3 - -ttranslate e2 0 2 0 -trotate e3 0 0 0 0 0 1 90 -tcopy e3 e4 -ttranslate e4 2 0 0 - -# Configure XProgress -XProgress +t - -# create the surface -set output [gplate r1 4 0 p e1 0 e2 0 e3 0 e4 0] - -# Test data -set ctr {"0%" "Calculating the surface filled" "Plate_Plate::SolveTI1()" "math_Gauss LU_Decompose" "100%" } - -foreach data ${ctr} { - if ![regexp $data $output] { - puts "Error: gplate command: Mismatch data on '$data'" - break - } -} diff --git a/tests/lowalgos/progress/A2 b/tests/lowalgos/progress/A2 deleted file mode 100644 index d5dad05917..0000000000 --- a/tests/lowalgos/progress/A2 +++ /dev/null @@ -1,30 +0,0 @@ -puts "========" -puts "0031190: Modeling Algorithms - progress indication in GeomPlate is inconsistent" -puts "========" - -beziercurve c1 3 0 0 0 1 0 1 2 0 0 -mkedge e1 c1 -tcopy e1 e2 -ttranslate e2 0 2 0 - -beziercurve c2 3 0 0 0 0 1 2 0 2 0 -mkedge e3 c2 -tcopy e3 e4 -ttranslate e4 2 0 0 - -# Configure XProgress -XProgress +t - -# create the surface -set output [gplate r1 4 0 e1 0 e2 0 e3 0 e4 0] - -# Test data -set ctr {"0%" "Calculating the surface filled" "ComputeSurfInit" - "Plate_Plate::SolveTI1()" "math_Gauss LU_Decompose" "100%" } - -foreach data ${ctr} { - if ![regexp $data $output] { - puts "Error: gplate command: Mismatch data on '$data'" - break - } -} diff --git a/tests/lowalgos/progress/A3 b/tests/lowalgos/progress/A3 deleted file mode 100644 index 43934a8d5a..0000000000 --- a/tests/lowalgos/progress/A3 +++ /dev/null @@ -1,40 +0,0 @@ -puts "========" -puts "0031190: Modeling Algorithms - progress indication in GeomPlate is inconsistent" -puts "========" - -# Generate control points -set points {} -set i 0 -for {set j 0} {$j < 300} {incr j; incr i} { - point p$i $j 0 0 - lappend points p$i -} -for {set j 1} {$j < 300} {incr j; incr i} { - point p$i 0 $j 0 - lappend points p$i -} -for {set j 0} {$j < 300} {incr j; incr i} { - point p$i 300 $j 0 - lappend points p$i -} - -for {set j 0} {$j < 301} {incr j; incr i} { - point p$i $j 300 0 - lappend points p$i -} - -# Configure XProgress -XProgress +t - -# create the surface -set output [eval gplate res 0 [llength $points] $points] - -# Test data -set ctr {"0%" "Calculating the surface filled" "Plate_Plate::SolveTI1()" "math_Gauss LU_Decompose" "100%" } - -foreach data ${ctr} { - if ![regexp $data $output] { - puts "Error: gplate command: Mismatch data on '$data'" - break - } -} diff --git a/tests/lowalgos/progress/A4 b/tests/lowalgos/progress/A4 deleted file mode 100644 index 72de53d863..0000000000 --- a/tests/lowalgos/progress/A4 +++ /dev/null @@ -1,27 +0,0 @@ -puts "========" -puts "0031190: Modeling Algorithms - progress indication in GeomPlate is inconsistent" -puts "========" - -# Generate control points -set n 100 -set l {} -for {set i 0} {$i < $n} {incr i} { - point p$i [dval sin(2.*pi*$i/$n)] [dval cos(2.*pi*$i/$n)] [expr abs(1-2.*$i/$n)] - lappend l p$i -} - -# Configure XProgress -XProgress +t - -# create the surface -set output [eval gplate r 0 [llength $l] $l] - -# Test data -set ctr {"0%" "Calculating the surface filled" "Plate_Plate::SolveTI1()" "math_Gauss LU_Decompose" "100%" } - -foreach data ${ctr} { - if ![regexp $data $output] { - puts "Error: gplate command: Mismatch data on '$data'" - break - } -} diff --git a/tests/lowalgos/proximity/A1 b/tests/lowalgos/proximity/A1 deleted file mode 100644 index 2a7025c155..0000000000 --- a/tests/lowalgos/proximity/A1 +++ /dev/null @@ -1,24 +0,0 @@ -puts "============" -puts "0033017: Implement an algorithm to find a proximity between a pair of shapes" -puts "===========" -puts "" - -circle c 0 0 0 1 0 0 5 -mkedge e1 c pi/2 pi -mkedge e2 c -pi/2 0 -incmesh e1 1.e-3 -incmesh e2 1.e-3 - -set log [proximity e1 e2 -value -profile] - -regexp {Proximity value: ([0-9+-.eE]*)} $log full val -set tol 1.e-3 -set expected 10.0 - -regexp {Status of ProxPnt1 on ([A-Za-z0-9._-]*) : ([A-Za-z]*)} $log full val1 val2 -set status1 ${val2} -set expected_status1 Middle - -regexp {Status of ProxPnt2 on ([A-Za-z0-9._-]*) : ([A-Za-z]*)} $log full val1 val2 -set status2 ${val2} -set expected_status2 Middle \ No newline at end of file diff --git a/tests/lowalgos/proximity/A2 b/tests/lowalgos/proximity/A2 deleted file mode 100644 index 61a92c1112..0000000000 --- a/tests/lowalgos/proximity/A2 +++ /dev/null @@ -1,26 +0,0 @@ -puts "============" -puts "0033017: Implement an algorithm to find a proximity between a pair of shapes" -puts "===========" -puts "" - -circle c1 0 0 0 1 0 0 1 -mkedge e1 c1 -incmesh e1 1.e-3 - -circle c2 0 0 0 0 1 0 1 -mkedge e2 c2 -incmesh e2 1.e-3 - -set log [proximity e1 e2 -value -profile] -regexp {Proximity value: ([0-9+-.eE]*)} $log full val; - -set tol 1.e-3 -set expected 2.0 - -regexp {Status of ProxPnt1 on ([A-Za-z0-9._-]*) : ([A-Za-z]*)} $log full val1 val2 -set status1 ${val2} -set expected_status1 Middle - -regexp {Status of ProxPnt2 on ([A-Za-z0-9._-]*) : ([A-Za-z]*)} $log full val1 val2 -set status2 ${val2} -set expected_status2 Middle \ No newline at end of file diff --git a/tests/lowalgos/proximity/A3 b/tests/lowalgos/proximity/A3 deleted file mode 100644 index f878329398..0000000000 --- a/tests/lowalgos/proximity/A3 +++ /dev/null @@ -1,28 +0,0 @@ -puts "============" -puts "0033017: Implement an algorithm to find a proximity between a pair of shapes" -puts "===========" -puts "" - -circle c1 0 -1 0 1 0 0 1 -trim c1 c1 -pi 0 -mkedge e1 c1 -incmesh e1 1.e-3 - -circle c2 0 1 0 1 0 0 1 -trim c2 c2 0 pi -mkedge e2 c2 -incmesh e2 1.e-3 - -set log [proximity e1 e2 -value -profile] -regexp {Proximity value: ([0-9+-.eE]*)} $log full val; - -set tol 1.e-3 -set expected [expr {sqrt(5.0) - 1.}] - -regexp {Status of ProxPnt1 on ([A-Za-z0-9._-]*) : ([A-Za-z]*)} $log full val1 val2 -set status1 ${val2} -set expected_status1 Middle - -regexp {Status of ProxPnt2 on ([A-Za-z0-9._-]*) : ([A-Za-z]*)} $log full val1 val2 -set status2 ${val2} -set expected_status2 Border \ No newline at end of file diff --git a/tests/lowalgos/proximity/A4 b/tests/lowalgos/proximity/A4 deleted file mode 100644 index 29c72fdc9e..0000000000 --- a/tests/lowalgos/proximity/A4 +++ /dev/null @@ -1,26 +0,0 @@ -puts "============" -puts "0033017: Implement an algorithm to find a proximity between a pair of shapes" -puts "===========" -puts "" - -circle c1 0 0 0 1 0 0 1 -mkedge e1 c1 -incmesh e1 1.e-3 - -circle c2 0 0 0 -1 0.5 0 1 -mkedge e2 c2 -incmesh e2 1.e-3 - -set log [proximity e1 e2 -value -profile] -regexp {Proximity value: ([0-9+-.eE]*)} $log full val; - -set tol 1.e-3 -set expected 2.0 - -regexp {Status of ProxPnt1 on ([A-Za-z0-9._-]*) : ([A-Za-z]*)} $log full val1 val2 -set status1 ${val2} -set expected_status1 Middle - -regexp {Status of ProxPnt2 on ([A-Za-z0-9._-]*) : ([A-Za-z]*)} $log full val1 val2 -set status2 ${val2} -set expected_status2 Middle \ No newline at end of file diff --git a/tests/lowalgos/proximity/A5 b/tests/lowalgos/proximity/A5 deleted file mode 100644 index 19a1daed9a..0000000000 --- a/tests/lowalgos/proximity/A5 +++ /dev/null @@ -1,31 +0,0 @@ -puts "============" -puts "0033017: Implement an algorithm to find a proximity between a pair of shapes" -puts "===========" -puts "" - -circle c1 0 0 0 1 0 0 1 -trim c1 c1 -pi/2. pi/2. -mkedge e1 c1 -incmesh e1 1.e-3 - -circle c2 0 0 0 1 0.5 0 1 -trim c2 c2 0 pi -mkedge e2 c2 -incmesh e2 1.e-3 - -set log [proximity e1 e2 -value -profile] -regexp {Proximity value: ([0-9+-.eE]*)} $log full val; - -set tol 1.e-3 -explode e1 v -explode e2 v -distmini d e1_1 e2_1 -regexp {([-0-9.+eE]+)$} [dump d_val] full expected - -regexp {Status of ProxPnt1 on ([A-Za-z0-9._-]*) : ([A-Za-z]*)} $log full val1 val2 -set status1 ${val2} -set expected_status1 Middle - -regexp {Status of ProxPnt2 on ([A-Za-z0-9._-]*) : ([A-Za-z]*)} $log full val1 val2 -set status2 ${val2} -set expected_status2 Border \ No newline at end of file diff --git a/tests/lowalgos/proximity/B1 b/tests/lowalgos/proximity/B1 deleted file mode 100644 index 68d434859b..0000000000 --- a/tests/lowalgos/proximity/B1 +++ /dev/null @@ -1,28 +0,0 @@ -puts "============" -puts "0033017: Implement an algorithm to find a proximity between a pair of shapes" -puts "===========" -puts "" - -plane p1 0 0 0 0 0 1 -trim p1 p1 -1 1 -1 1 -mkface f1 p1 -incmesh f1 1.e-1 - -plane p2 0 0 1 0 0 1 -trim p2 p2 -1 1 -1 1 -mkface f2 p2 -incmesh f2 1.e-1 - -set log [proximity f1 f2 -value -profile] -regexp {Proximity value: ([0-9+-.eE]*)} $log full val; - -set tol 1.e-3 -set expected 1.0 - -regexp {Status of ProxPnt1 on ([A-Za-z0-9._-]*) : ([A-Za-z]*)} $log full val1 val2 -set status1 ${val2} -set expected_status1 Border - -regexp {Status of ProxPnt2 on ([A-Za-z0-9._-]*) : ([A-Za-z]*)} $log full val1 val2 -set status2 ${val2} -set expected_status2 Border \ No newline at end of file diff --git a/tests/lowalgos/proximity/B2 b/tests/lowalgos/proximity/B2 deleted file mode 100644 index aff0e9a10b..0000000000 --- a/tests/lowalgos/proximity/B2 +++ /dev/null @@ -1,28 +0,0 @@ -puts "============" -puts "0033017: Implement an algorithm to find a proximity between a pair of shapes" -puts "===========" -puts "" - -plane p1 0 0 0 0 0 1 -trim p1 p1 -1 1 -1 1 -mkface f1 p1 -incmesh f1 1.e-1 - -plane p2 0 0 1 -1 0 0 -trim p2 p2 -1 1 -1 1 -mkface f2 p2 -incmesh f2 1.e-1 - -set log [proximity f1 f2 -value -profile] -regexp {Proximity value: ([0-9+-.eE]*)} $log full val; - -set tol 1.e-3 -set expected 1.0 - -regexp {Status of ProxPnt1 on ([A-Za-z0-9._-]*) : ([A-Za-z]*)} $log full val1 val2 -set status1 ${val2} -set expected_status1 Border - -regexp {Status of ProxPnt2 on ([A-Za-z0-9._-]*) : ([A-Za-z]*)} $log full val1 val2 -set status2 ${val2} -set expected_status2 Border \ No newline at end of file diff --git a/tests/lowalgos/proximity/B3 b/tests/lowalgos/proximity/B3 deleted file mode 100644 index 67f0c62a6f..0000000000 --- a/tests/lowalgos/proximity/B3 +++ /dev/null @@ -1,28 +0,0 @@ -puts "============" -puts "0033017: Implement an algorithm to find a proximity between a pair of shapes" -puts "===========" -puts "" - -plane p1 0 0 0 0 0 1 -trim p1 p1 -1 1 -1 1 -mkface f1 p1 -incmesh f1 1.e-1 - -plane p2 0 0 0 -1 0 0 -trim p2 p2 -1 1 -1 1 -mkface f2 p2 -incmesh f2 1.e-1 - -set log [proximity f1 f2 -value -profile] -regexp {Proximity value: ([0-9+-.eE]*)} $log full val; - -set tol 1.e-3 -set expected 1.0 - -regexp {Status of ProxPnt1 on ([A-Za-z0-9._-]*) : ([A-Za-z]*)} $log full val1 val2 -set status1 ${val2} -set expected_status1 Border - -regexp {Status of ProxPnt2 on ([A-Za-z0-9._-]*) : ([A-Za-z]*)} $log full val1 val2 -set status2 ${val2} -set expected_status2 Border \ No newline at end of file diff --git a/tests/lowalgos/proximity/B4 b/tests/lowalgos/proximity/B4 deleted file mode 100644 index 1250bbf6fb..0000000000 --- a/tests/lowalgos/proximity/B4 +++ /dev/null @@ -1,28 +0,0 @@ -puts "============" -puts "0033017: Implement an algorithm to find a proximity between a pair of shapes" -puts "===========" -puts "" - -plane p1 0 0 0 0 0 1 -trim p1 p1 -1 1 -1 1 -mkface f1 p1 -incmesh f1 1.e-1 - -plane p2 0 0 0.5 -1 0 0 -trim p2 p2 -1 1 -1 1 -mkface f2 p2 -incmesh f2 1.e-1 - -set log [proximity f1 f2 -value -profile] -regexp {Proximity value: ([0-9+-.eE]*)} $log full val; - -set tol 1.e-3 -set expected 1.0 - -regexp {Status of ProxPnt1 on ([A-Za-z0-9._-]*) : ([A-Za-z]*)} $log full val1 val2 -set status1 ${val2} -set expected_status1 Border - -regexp {Status of ProxPnt2 on ([A-Za-z0-9._-]*) : ([A-Za-z]*)} $log full val1 val2 -set status2 ${val2} -set expected_status2 Border \ No newline at end of file diff --git a/tests/lowalgos/proximity/B5 b/tests/lowalgos/proximity/B5 deleted file mode 100644 index 048d1834b9..0000000000 --- a/tests/lowalgos/proximity/B5 +++ /dev/null @@ -1,27 +0,0 @@ -puts "============" -puts "0033017: Implement an algorithm to find a proximity between a pair of shapes" -puts "===========" -puts "" - -plane p1 0 0 0 0 0 1 -trim p1 p1 -1 1 -1 1 -mkface f1 p1 -incmesh f1 1.e-3 - -polyline f2 -1 -1 1 -1 1 1 1 1 2 1 -1 2 -1 -1 1 -mkplane f2 f2 -incmesh f2 1.e-3 - -set log [proximity f1 f2 -value -profile] -regexp {Proximity value: ([0-9+-.eE]*)} $log full val; - -set tol 1.e-3 -set expected [expr {0.8 * sqrt(5.0)}] - -regexp {Status of ProxPnt1 on ([A-Za-z0-9._-]*) : ([A-Za-z]*)} $log full val1 val2 -set status1 ${val2} -set expected_status1 Border - -regexp {Status of ProxPnt2 on ([A-Za-z0-9._-]*) : ([A-Za-z]*)} $log full val1 val2 -set status2 ${val2} -set expected_status2 Border \ No newline at end of file diff --git a/tests/lowalgos/proximity/C1 b/tests/lowalgos/proximity/C1 deleted file mode 100644 index 457512464c..0000000000 --- a/tests/lowalgos/proximity/C1 +++ /dev/null @@ -1,29 +0,0 @@ -puts "============" -puts "0033017: Implement an algorithm to find a proximity between a pair of shapes" -puts "===========" -puts "" - -plane p1 0 0 0 0 0 1 -trim p1 p1 -1 1 -1 1 -mkface f1 p1 -incmesh f1 1.e-3 - -dset lo pi/2. la 0. -cylinder cy1 0 0 0 cos(la)*cos(lo) cos(la)*sin(lo) sin(la) 0.1 -trimv cy1 cy1 0 1 -mkface fcy1 cy1 -incmesh fcy1 1.e-3 - -set log [proximity f1 fcy1 -value -profile] -regexp {Proximity value: ([0-9+-.eE]*)} $log full val; - -set tol 1.e-3 -set expected 0.1 - -regexp {Status of ProxPnt1 on ([A-Za-z0-9._-]*) : ([A-Za-z]*)} $log full val1 val2 -set status1 ${val2} -set expected_status1 Middle - -regexp {Status of ProxPnt2 on ([A-Za-z0-9._-]*) : ([A-Za-z]*)} $log full val1 val2 -set status2 ${val2} -set expected_status2 Border \ No newline at end of file diff --git a/tests/lowalgos/proximity/C2 b/tests/lowalgos/proximity/C2 deleted file mode 100644 index 2920e41c82..0000000000 --- a/tests/lowalgos/proximity/C2 +++ /dev/null @@ -1,29 +0,0 @@ -puts "============" -puts "0033017: Implement an algorithm to find a proximity between a pair of shapes" -puts "===========" -puts "" - -plane p1 0 0 0 0 0 1 -trim p1 p1 -2 2 -2 2 -mkface f1 p1 -incmesh f1 1.e-3 - -dset lo pi/2. la pi/4. -cylinder cy1 0 0 1 cos(la)*cos(lo) cos(la)*sin(lo) sin(la) 0.1 -trimv cy1 cy1 0 1 -mkface fcy1 cy1 -incmesh fcy1 1.e-3 - -set log [proximity f1 fcy1 -value -profile] -regexp {Proximity value: ([0-9+-.eE]*)} $log full val; - -set tol 1.e-3 -set expected [expr {1. + 1.1 * sqrt(2.)/2.}] - -regexp {Status of ProxPnt1 on ([A-Za-z0-9._-]*) : ([A-Za-z]*)} $log full val1 val2 -set status1 ${val2} -set expected_status1 Middle - -regexp {Status of ProxPnt2 on ([A-Za-z0-9._-]*) : ([A-Za-z]*)} $log full val1 val2 -set status2 ${val2} -set expected_status2 Border \ No newline at end of file diff --git a/tests/lowalgos/proximity/C3 b/tests/lowalgos/proximity/C3 deleted file mode 100644 index 9323eb8574..0000000000 --- a/tests/lowalgos/proximity/C3 +++ /dev/null @@ -1,28 +0,0 @@ -puts "============" -puts "0033017: Implement an algorithm to find a proximity between a pair of shapes" -puts "===========" -puts "" - -cylinder cy1 0 0 1 1 0 0 0.1 -trimv cy1 cy1 0 1 -mkface fcy1 cy1 -incmesh fcy1 1.e-3 - -cylinder cy2 0 0 0 1 0 0 0.1 -trimv cy2 cy2 0 1 -mkface fcy2 cy2 -incmesh fcy2 1.e-3 - -set log [proximity fcy1 fcy2 -value -profile] -regexp {Proximity value: ([0-9+-.eE]*)} $log full val; - -set tol 1.e-3 -set expected 1.0 - -regexp {Status of ProxPnt1 on ([A-Za-z0-9._-]*) : ([A-Za-z]*)} $log full val1 val2 -set status1 ${val2} -set expected_status1 Border - -regexp {Status of ProxPnt2 on ([A-Za-z0-9._-]*) : ([A-Za-z]*)} $log full val1 val2 -set status2 ${val2} -set expected_status2 Border \ No newline at end of file diff --git a/tests/lowalgos/proximity/C4 b/tests/lowalgos/proximity/C4 deleted file mode 100644 index acbaf9ff78..0000000000 --- a/tests/lowalgos/proximity/C4 +++ /dev/null @@ -1,28 +0,0 @@ -puts "============" -puts "0033017: Implement an algorithm to find a proximity between a pair of shapes" -puts "===========" -puts "" - -cylinder cy1 0 0 1 1 0 0 0.1 -trim cy1 cy1 -pi/2. pi/2. 0 1 -mkface fcy1 cy1 -incmesh fcy1 1.e-5 - -cylinder cy2 0 0 0 1 0 0 0.1 -trim cy2 cy2 pi/2. -pi/2. 0 1 -mkface fcy2 cy2 -incmesh fcy2 1.e-5 - -set log [proximity fcy1 fcy2 -value -profile] -regexp {Proximity value: ([0-9+-.eE]*)} $log full val; - -set tol 1.e-3 -set expected 1.2 - -regexp {Status of ProxPnt1 on ([A-Za-z0-9._-]*) : ([A-Za-z]*)} $log full val1 val2 -set status1 ${val2} -set expected_status1 Border - -regexp {Status of ProxPnt2 on ([A-Za-z0-9._-]*) : ([A-Za-z]*)} $log full val1 val2 -set status2 ${val2} -set expected_status2 Border \ No newline at end of file diff --git a/tests/lowalgos/proximity/D1 b/tests/lowalgos/proximity/D1 deleted file mode 100644 index 2e8dccc185..0000000000 --- a/tests/lowalgos/proximity/D1 +++ /dev/null @@ -1,28 +0,0 @@ -puts "============" -puts "0033017: Implement an algorithm to find a proximity between a pair of shapes" -puts "===========" -puts "" - -sphere s1 0 1 0 0 0 1 1 -trimu s1 s1 0 pi -mkface fs1 s1 -incmesh fs1 1e-3 - -sphere s2 0 -1 0 0 0 1 1 -trimu s2 s2 -pi 0 -mkface fs2 s2 -incmesh fs2 1e-3 - -set log [proximity fs1 fs2 -value -profile] -regexp {Proximity value: ([0-9+-.eE]*)} $log full val; - -set tol 1.e-2 -set expected 4.0 - -regexp {Status of ProxPnt1 on ([A-Za-z0-9._-]*) : ([A-Za-z]*)} $log full val1 val2 -set status1 ${val2} -set expected_status1 Middle - -regexp {Status of ProxPnt2 on ([A-Za-z0-9._-]*) : ([A-Za-z]*)} $log full val1 val2 -set status2 ${val2} -set expected_status2 Middle \ No newline at end of file diff --git a/tests/lowalgos/proximity/D2 b/tests/lowalgos/proximity/D2 deleted file mode 100644 index 0c19db3fbb..0000000000 --- a/tests/lowalgos/proximity/D2 +++ /dev/null @@ -1,26 +0,0 @@ -puts "============" -puts "0033017: Implement an algorithm to find a proximity between a pair of shapes" -puts "===========" -puts "" - -sphere s1 0 1 0 0 0 1 1 -mkface fs1 s1 -incmesh fs1 1e-3 - -sphere s2 0 -1 0 0 0 1 1 -mkface fs2 s2 -incmesh fs2 1e-3 - -set log [proximity fs1 fs2 -value -profile] -regexp {Proximity value: ([0-9+-.eE]*)} $log full val; - -set tol 1.e-2 -set expected 4.0 - -regexp {Status of ProxPnt1 on ([A-Za-z0-9._-]*) : ([A-Za-z]*)} $log full val1 val2 -set status1 ${val2} -set expected_status1 Middle - -regexp {Status of ProxPnt2 on ([A-Za-z0-9._-]*) : ([A-Za-z]*)} $log full val1 val2 -set status2 ${val2} -set expected_status2 Middle \ No newline at end of file diff --git a/tests/lowalgos/proximity/D3 b/tests/lowalgos/proximity/D3 deleted file mode 100644 index 8a3704cb1f..0000000000 --- a/tests/lowalgos/proximity/D3 +++ /dev/null @@ -1,33 +0,0 @@ -puts "============" -puts "0033017: Implement an algorithm to find a proximity between a pair of shapes" -puts "===========" -puts "" - -sphere s1 0 1 0 0 0 1 1 -trimu s1_1 s1 0 0.5*pi -trimu s1_2 s1 0.5*pi pi - -mkface fs1_1 s1_1 -mkface fs1_2 s1_2 -compound fs1_1 fs1_2 fs1 -incmesh fs1 1e-3 - -plane p1 0 0 0 0 1 0 -trim p1 p1 -2 2 -2 2 -mkface f2 p1 -incmesh f2 0.001 - -set log [proximity fs1 f2 -value -profile] - -regexp {Proximity value: ([0-9+-.eE]*)} $log full val; - -set tol 1.e-2 -set expected 2.0 - -regexp {Status of ProxPnt1 on ([A-Za-z0-9._-]*) : ([A-Za-z]*)} $log full val1 val2 -set status1 ${val2} -set expected_status1 Border - -regexp {Status of ProxPnt2 on ([A-Za-z0-9._-]*) : ([A-Za-z]*)} $log full val1 val2 -set status2 ${val2} -set expected_status2 Middle \ No newline at end of file diff --git a/tests/lowalgos/proximity/D4 b/tests/lowalgos/proximity/D4 deleted file mode 100644 index c463310b87..0000000000 --- a/tests/lowalgos/proximity/D4 +++ /dev/null @@ -1,29 +0,0 @@ -puts "============" -puts "0033144: Modeling Algorithms - Wrong result of Shape Proximity" -puts "===========" -puts "" - -sphere s1 0 1 0 0 0 1 1 -trimu s1 s1 0 pi -mkface fs1 s1 -incmesh fs1 1e-3 - -plane p1 0 0 0 0 1 0 -trim p1 p1 -1 1 -1 1 -mkface f2 p1 -incmesh f2 1e-3 - -set log [proximity fs1 f2 -value -profile] - -regexp {Proximity value: ([0-9+-.eE]*)} $log full val; - -set tol 1.e-2 -set expected 2.0 - -regexp {Status of ProxPnt1 on ([A-Za-z0-9._-]*) : ([A-Za-z]*)} $log full val1 val2 -set status1 ${val2} -set expected_status1 Middle - -regexp {Status of ProxPnt2 on ([A-Za-z0-9._-]*) : ([A-Za-z]*)} $log full val1 val2 -set status2 ${val2} -set expected_status2 Middle \ No newline at end of file diff --git a/tests/lowalgos/proximity/E1 b/tests/lowalgos/proximity/E1 deleted file mode 100644 index 0997c1139d..0000000000 --- a/tests/lowalgos/proximity/E1 +++ /dev/null @@ -1,30 +0,0 @@ -puts "============" -puts "0033017: Implement an algorithm to find a proximity between a pair of shapes" -puts "===========" -puts "" - -beziercurve bc1 7 10 84 0 54 96 0 145 146 0 167 167 0 185 212 0 187 234 0 176 302 0 -beziercurve bc2 8 120 72 0 170 87 0 227 118 0 238 126 0 243 157 0 203 216 0 134 281 0 94 324 0 - -mkedge e1 bc1 -mkedge e2 bc2 - -incmesh e1 1.e-3 -incmesh e2 1.e-3 - -set log [proximity e1 e2 -value -profile] -regexp {Proximity value: ([0-9+-.eE]*)} $log full val; - -set tol 1.e-3 -explode e1 v -explode e2 v -distmini d e1_2 e2_2 -regexp {([-0-9.+eE]+)$} [dump d_val] full expected - -regexp {Status of ProxPnt1 on ([A-Za-z0-9._-]*) : ([A-Za-z]*)} $log full val1 val2 -set status1 ${val2} -set expected_status1 Border - -regexp {Status of ProxPnt2 on ([A-Za-z0-9._-]*) : ([A-Za-z]*)} $log full val1 val2 -set status2 ${val2} -set expected_status2 Border \ No newline at end of file diff --git a/tests/lowalgos/proximity/E2 b/tests/lowalgos/proximity/E2 deleted file mode 100644 index ffdd658156..0000000000 --- a/tests/lowalgos/proximity/E2 +++ /dev/null @@ -1,27 +0,0 @@ -puts "============" -puts "0033017: Implement an algorithm to find a proximity between a pair of shapes" -puts "===========" -puts "" - -beziercurve bc1 6 54 96 0 145 146 0 167 167 0 185 212 0 187 234 0 176 302 0 -beziercurve bc2 7 120 72 0 170 87 0 227 118 0 238 126 0 243 157 0 203 216 0 134 281 0 - -mkedge e1 bc1 -mkedge e2 bc2 - -incmesh e1 1.e-3 -incmesh e2 1.e-3 - -set log [proximity e1 e2 -value -profile] -regexp {Proximity value: ([0-9+-.eE]*)} $log full val; - -set tol 1.e-3 -set expected 76.34 - -regexp {Status of ProxPnt1 on ([A-Za-z0-9._-]*) : ([A-Za-z]*)} $log full val1 val2 -set status1 ${val2} -set expected_status1 Middle - -regexp {Status of ProxPnt2 on ([A-Za-z0-9._-]*) : ([A-Za-z]*)} $log full val1 val2 -set status2 ${val2} -set expected_status2 Middle \ No newline at end of file diff --git a/tests/perf/de/bug29830_3 b/tests/perf/de/bug29830_3 deleted file mode 100644 index fff4e1f659..0000000000 --- a/tests/perf/de/bug29830_3 +++ /dev/null @@ -1,27 +0,0 @@ -puts "========" -puts "0029830: Data Exchange, STEPCAFControl_Reader poor performance - quadratic dependence" -puts "========" -puts "Test on stack overflow during destructing the STEP model" - -set ncomp 1000 - -box a 1 1 1 -shape co C -for {set i 0} {$i < $ncomp} {incr i} { - tcopy a a1 - add a1 co -} -if [info exists D] {Close D} -XNewDoc D -XAddShape D co - -puts "Writing STEP model" -set aTmpFile ${imagedir}/${casename}_tmp.stp -WriteStep D $aTmpFile -Close D - -puts "Destructing model" -#crash -newmodel - -file delete -force $aTmpFile diff --git a/tests/pipe/bugs/bug24909_2 b/tests/pipe/bugs/bug24909_2 deleted file mode 100755 index 215b2539d9..0000000000 --- a/tests/pipe/bugs/bug24909_2 +++ /dev/null @@ -1,25 +0,0 @@ -puts "TODO ?OCC24909 ALL: An exception was caught" -puts "TODO ?OCC24909 ALL: TEST INCOMPLETE" -puts "TODO ?OCC24909 ALL: Tcl Exception: Buildsweep : Not Done" - -puts "========" -puts "0024909: S I G S E G V in buildsweep" -puts "========" -puts "" - -circle c1 0 0 0 40 -mkedge e1 c1 -wire w1 e1 -tcopy w1 Sketch002 -tcopy w1 Sketch001 -renamevar w1 Sketch -trotate Sketch 0 0 0 0. 1. 0. 90 -ttranslate Sketch 0. 0. 75. -trotate Sketch001 0 0 0 0. 1. 0. 90 -ttranslate Sketch001 0. 0. -75. -ttranslate Sketch002 50. 0. 0. -mksweep Sketch002 -setsweep -CF -addsweep Sketch001 -addsweep Sketch -buildsweep Sweep diff --git a/tests/v3d/colors/begin b/tests/v3d/colors/begin deleted file mode 100644 index ce5f55fcd4..0000000000 --- a/tests/v3d/colors/begin +++ /dev/null @@ -1,7 +0,0 @@ -# Auxiliary procedure to compare triplet of numbers -# against reference values, with tolerance -proc check3reals {name value1 value2 value3 ref1 ref2 ref3 tol} { - checkreal "${name}, component 1" $value1 $ref1 $tol 1e-6 - checkreal "${name}, component 2" $value2 $ref2 $tol 1e-6 - checkreal "${name}, component 3" $value3 $ref3 $tol 1e-6 -} diff --git a/tests/v3d/colors/de2000 b/tests/v3d/colors/de2000 deleted file mode 100644 index 28272d1c83..0000000000 --- a/tests/v3d/colors/de2000 +++ /dev/null @@ -1,60 +0,0 @@ -# Check calculation of CIE Ddlta E 2000 color difference - -pload VISUALIZATION - -# Reference data are obtained using online calculator -# http://brucelindbloom.com/index.html?ColorDifferenceCalc.html -# or -# https://cielab.xyz/ -# Second one also shows color and reports if it is out of RGB gamut. -# -# Note that values out of RGB gamut would be amended during -# conversion to RGB and thus the result would be different! -# -# Samples aimed at testing discontinuity of CIEDE2000 -# formula are very sensitive to accuracy, we need higher tolerance -# because conversion is done via RGB floats and loses precision. -# -# Format: { {L1 a1 b1} {L2 a2 b2} expected_diff [tolerance] } -set lab_diff_samples { - { # synthetic color pairs } - { {0 0 0} {50 0 0} 36.519268 } - { {50 0 0} {100 0 0} 36.519268 } - { {0 0 0} {100 0 0} 100. } - { {20 10 10} {80 10 10} 60. } - { {50 0 0} {50 0 50} 23.529412 } - { {50 60 60} {50 60 0} 28.016927 } - { {30 30 40} {30 30 -60} 44.606253 } - - { # discontinuity of CIEDE2000 formula } - { {30 50.00 40} {20 -10 -8} 39.105394 0.001 } - { {30 50.01 40} {20 -10 -8} 43.53247 0.001 } - { {20 30.00 30.01} {60 -10 -10} 49.416742 0.05 } - { {20 30.01 30.00} {60 -10 -10} 52.448227 0.05 } - - { # randomly generated data } - { {73.4450 34.9839 -24.6753} {87.6216 -18.4863 57.8838} 62.402500 } - { {93.6166 -27.3677 29.3893} {46.9191 12.3400 -27.5948} 54.640034 } - { {53.9062 61.0929 -51.7583} {65.5157 26.3376 -37.0512} 15.679046 } - { {83.6996 9.3358 -24.5571} {93.2268 -3.8589 3.5217} 23.158692 } - { {64.8053 -27.3177 -8.9602} {65.8225 37.3192 -38.1465} 34.670514 } - { {94.7633 -19.7915 69.2787} {90.9238 -16.7535 4.1936} 26.093024 } - { {85.4699 5.6078 -11.1083} {67.9455 -28.4536 7.8808} 31.115070 } - { {83.5473 -15.7170 8.3546} {81.3193 -37.2851 57.7090} 19.696753 } - { {75.7406 -12.0785 -12.3505} {80.0810 -54.8591 52.1739} 35.834099 } - { {62.8209 32.1209 16.9113} {82.1106 25.0843 -7.9416} 21.178519 } -} - -foreach sample $lab_diff_samples { - set lab1 [lindex $sample 0] - if { $lab1 == "#" } continue - set lab2 [lindex $sample 1] - set dref [lindex $sample 2] - set diff [vcolordiff {*}[vcolorconvert from lab {*}$lab1] {*}[vcolorconvert from lab {*}$lab2]] - - # use tolerance 1e-4 except if other value is defined in sample data - set tol [lindex $sample 3] - if { $tol == "" } { set tol 1e-4 } - - checkreal "CIEDE2000 diff of Lab colors ($lab1) and ($lab2)" $diff $dref $tol 1e-6 -} diff --git a/tests/v3d/colors/de2000_sharma b/tests/v3d/colors/de2000_sharma deleted file mode 100644 index e33a899e94..0000000000 --- a/tests/v3d/colors/de2000_sharma +++ /dev/null @@ -1,70 +0,0 @@ -# Check calculation of CIE Ddlta E 2000 color difference - -pload VISUALIZATION - -# Reference data taken from -# "The CIEDE2000 Color-Difference Formula: Implementation Notes, -# Supplementary Test Data, and Mathematical Observations", -# G. Sharma, W. Wu, E. N. Dalal, -# Color Research and Application, vol. 30. No. 1, pp. 21-30, February 2005 -# http://www2.ece.rochester.edu/~gsharma/ciede2000/ -# -# Note: samples 1 to 6 and 28 are commented because the colors -# are out of RGB gamut. -# Samples 10 and 15 are aimed at testing discontinuity of CIEDE2000 -# formula and so are very sensitive to accuracy, we need higher tolerance -# because conversion is done via RGB floats and loses precision. -# -# Format: L1 a1 b1 L2 a2 b2 expected_diff [tolerance] -set lab_diff_samples { -# 50.0000 2.6772 -79.7751 50.0000 0.0000 -82.7485 2.0425 -# 50.0000 3.1571 -77.2803 50.0000 0.0000 -82.7485 2.8615 -# 50.0000 2.8361 -74.0200 50.0000 0.0000 -82.7485 3.4412 -# 50.0000 -1.3802 -84.2814 50.0000 0.0000 -82.7485 1.0000 -# 50.0000 -1.1848 -84.8006 50.0000 0.0000 -82.7485 1.0000 -# 50.0000 -0.9009 -85.5211 50.0000 0.0000 -82.7485 1.0000 -50.0000 0.0000 0.0000 50.0000 -1.0000 2.0000 2.3669 -50.0000 -1.0000 2.0000 50.0000 0.0000 0.0000 2.3669 -50.0000 2.4900 -0.0010 50.0000 -2.4900 0.0009 7.1792 -50.0000 2.4900 -0.0010 50.0000 -2.4900 0.0010 7.1792 0.05 -50.0000 2.4900 -0.0010 50.0000 -2.4900 0.0011 7.2195 -50.0000 2.4900 -0.0010 50.0000 -2.4900 0.0012 7.2195 -50.0000 -0.0010 2.4900 50.0000 0.0009 -2.4900 4.8045 -50.0000 -0.0010 2.4900 50.0000 0.0010 -2.4900 4.8045 -50.0000 -0.0010 2.4900 50.0000 0.0011 -2.4900 4.7461 0.06 -50.0000 2.5000 0.0000 50.0000 0.0000 -2.5000 4.3065 -50.0000 2.5000 0.0000 73.0000 25.0000 -18.0000 27.1492 -50.0000 2.5000 0.0000 61.0000 -5.0000 29.0000 22.8977 -50.0000 2.5000 0.0000 56.0000 -27.0000 -3.0000 31.9030 -50.0000 2.5000 0.0000 58.0000 24.0000 15.0000 19.4535 -50.0000 2.5000 0.0000 50.0000 3.1736 0.5854 1.0000 -50.0000 2.5000 0.0000 50.0000 3.2972 0.0000 1.0000 -50.0000 2.5000 0.0000 50.0000 1.8634 0.5757 1.0000 -50.0000 2.5000 0.0000 50.0000 3.2592 0.3350 1.0000 -60.2574 -34.0099 36.2677 60.4626 -34.1751 39.4387 1.2644 -63.0109 -31.0961 -5.8663 62.8187 -29.7946 -4.0864 1.2630 -61.2901 3.7196 -5.3901 61.4292 2.2480 -4.9620 1.8731 -# 35.0831 -44.1164 3.7933 35.0232 -40.0716 1.5901 1.8645 -22.7233 20.0904 -46.6940 23.0331 14.9730 -42.5619 2.0373 -36.4612 47.8580 18.3852 36.2715 50.5065 21.2231 1.4146 -90.8027 -2.0831 1.4410 91.1528 -1.6435 0.0447 1.4441 -90.9257 -0.5406 -0.9208 88.6381 -0.8985 -0.7239 1.5381 -6.7747 -0.2908 -2.4247 5.8714 -0.0985 -2.2286 0.6377 -2.0776 0.0795 -1.1350 0.9033 -0.0636 -0.5514 0.9082 -} - -set index -1 -foreach sample [split $lab_diff_samples \n] { - incr index - set lab1 [lrange $sample 0 2] - if { [lindex $lab1 0] == "#" || $lab1 == "" } continue - set lab2 [lrange $sample 3 5] - set dref [lindex $sample 6] - set diff [vcolordiff {*}[vcolorconvert from lab {*}$lab1] {*}[vcolorconvert from lab {*}$lab2]] - - # use tolerance 1e-3 except if other value is defined in sample data - set tol [lindex $sample 7] - if { $tol == "" } { set tol 1e-3 } - - checkreal "Sample $index: Lab ($lab1) and ($lab2), diff" $diff $dref $tol 1e-6 -} diff --git a/tests/v3d/colors/rgb2lab b/tests/v3d/colors/rgb2lab deleted file mode 100644 index df5e7bf0c6..0000000000 --- a/tests/v3d/colors/rgb2lab +++ /dev/null @@ -1,39 +0,0 @@ -# Check conversion of RGB colors to CIE Lab color space - -pload VISUALIZATION - -# Samples are obtained (with Ref. White D65, Gamma = 1 for linear RGB) using -# http://brucelindbloom.com/index.html?ColorCalculator.html -set rgb_to_lab_samples { - { # black, white, 50% gray } - { {0 0 0} {0 0 0} } - { {1 1 1} {100 0 0} } - { {0.5 0.5 0.5} {76.0693 0 0} } - - { # pure colors } - { {1 0 0} {53.2408 80.0925 67.2032} } - { {0 1 0} {87.7347 -86.1827 83.1793} } - { {0 0 1} {32.2970 79.1875 -107.8602} } - { {0 1 1} {91.1132 -48.0875 -14.1312} } - { {1 1 0} {97.1393 -21.5537 94.4780} } - { {1 0 1} {60.3242 98.2343 -60.8249} } - - { # shades of pure red } - { {0.1 0 0} {16.1387 37.1756 25.0600} } - { {0.3 0 0} {30.3521 53.6166 44.0349} } - { {0.5 0 0} {38.9565 63.5695 53.3392} } - { {0.7 0 0} {45.4792 71.1144 59.6700} } - { {0.9 0 0} {50.8512 77.3285 64.8840} } - - { # random colors } - { {0.3 0.5 0.9} {75.2228 0.7560 -31.8425} } -} - -foreach sample $rgb_to_lab_samples { - set rgb [lindex $sample 0] - if { $rgb == "#" } continue - - set ref [lindex $sample 1] - set lab [vcolorconvert to lab {*}$rgb] - check3reals "RGB ($rgb) to Lab" {*}$lab {*}$ref 1e-4 -} diff --git a/tests/v3d/colors/rgb2lch b/tests/v3d/colors/rgb2lch deleted file mode 100644 index 560ac4ad24..0000000000 --- a/tests/v3d/colors/rgb2lch +++ /dev/null @@ -1,40 +0,0 @@ -# Check conversion of RGB colors to CIE Lch color space - -pload VISUALIZATION - -# Samples are obtained (with Ref. White D65, Gamma = 1 for linear RGB) using -# http://brucelindbloom.com/index.html?ColorCalculator.html -# Note that for c = 0 we have h = 0 (not 270 as in the above link) -set rgb_to_lch_samples { - { # black, white, 50% gray } - { {0 0 0} {0 0 0} } - { {1 1 1} {100 0 0} } - { {0.5 0.5 0.5} {76.0693 0 0} } - - { # pure colors } - { {1 0 0} {53.2408 104.5518 39.9990} } - { {0 1 0} {87.7347 119.7759 136.0160} } - { {0 0 1} {32.2970 133.8076 306.2849} } - { {0 1 1} {91.1132 50.1209 196.3762} } - { {1 1 0} {97.1393 96.9054 102.8512} } - { {1 0 1} {60.3242 115.5407 328.2350} } - - { # shades of pure red } - { {0.1 0 0} {16.1387 44.8334 33.9838} } - { {0.3 0 0} {30.3521 69.3816 39.3960} } - { {0.5 0 0} {38.9565 82.9828 39.9990} } - { {0.7 0 0} {45.4792 92.8320 39.9990} } - { {0.9 0 0} {50.8512 100.9436 39.9990} } - - { # random colors } - { {0.3 0.5 0.9} {75.2228 31.8514 271.3601} } -} - -foreach sample $rgb_to_lch_samples { - set rgb [lindex $sample 0] - if { $rgb == "#" } continue - - set ref [lindex $sample 1] - set lch [vcolorconvert to lch {*}$rgb] - check3reals "RGB ($rgb) to Lch" {*}$lch {*}$ref 1e-4 -} diff --git a/tests/v3d/colors/stability b/tests/v3d/colors/stability deleted file mode 100644 index 2e6e1bda70..0000000000 --- a/tests/v3d/colors/stability +++ /dev/null @@ -1,18 +0,0 @@ -# Check stability of conversion of RGB colors to CIE Lab and Lch -# color spaces and back on random colors - -pload VISUALIZATION - -# check color diff on random colors -for {set i 1} {$i < 1000} {incr i} { - set rgb "[expr rand()] [expr rand()] [expr rand()]" - - set lab [vcolorconvert to lab {*}$rgb] - set lch [vcolorconvert to lch {*}$rgb] - - set rgb_lab [vcolorconvert from lab {*}$lab] - set rgb_lch [vcolorconvert from lch {*}$lch] - - check3reals "RGB ($rgb) to Lab and back" {*}$rgb_lab {*}$rgb 1e-4 - check3reals "RGB ($rgb) to Lch and back" {*}$rgb_lch {*}$rgb 1e-4 -} diff --git a/tests/xml/data/ocaf/A1 b/tests/xml/data/ocaf/A1 deleted file mode 100644 index acc7052438..0000000000 --- a/tests/xml/data/ocaf/A1 +++ /dev/null @@ -1,24 +0,0 @@ -set aTestName "caf001-A3" - -# Add an attribute to a data framework -set aSetAttr1 100 -set aLabel 0:2 -SetInteger D ${aLabel} ${aSetAttr1} - -# Close/Open the transaction -NewCommand D - -# Save the document -set aFile $WorkDirectory/${aTestName}.${FileSuffix} - -SaveToFile D $aFile - -# Restore the document -Close D -Open ${aFile} DD - -# Get a value of the attribute -set IsDone [catch {set aGetAttr3 [GetInteger DD ${aLabel}]} aResult] -if { ${IsDone} != 0 || ${aSetAttr1}!=${aGetAttr3} } { - puts "Error : Get a value of TDataStd_Integer attribute from restoring document" -} diff --git a/tests/xml/data/ocaf/A2 b/tests/xml/data/ocaf/A2 deleted file mode 100644 index 3cbdf38a04..0000000000 --- a/tests/xml/data/ocaf/A2 +++ /dev/null @@ -1,25 +0,0 @@ -set aTestName "caf001-B3" -puts $aTestName - -# Add an attribute to a data framework -set aSetAttr1 100.0 -set aLabel 0:2 -SetReal D ${aLabel} ${aSetAttr1} - -# Close/Open the transaction -NewCommand D - -# Save the document -set aFile $WorkDirectory/${aTestName}.${FileSuffix} - -SaveToFile D $aFile - -# Restore the document -Close D -Open ${aFile} DD - -# Get a value of the attribute -set IsDone [catch {set aGetAttr3 [GetReal DD ${aLabel}]} aResult] -if { ${IsDone} != 0 || ${aSetAttr1}!=${aGetAttr3} } { - puts "Error : Get a value of TDataStd_Real attribute from restoring document" -} diff --git a/tests/xml/data/ocaf/A3 b/tests/xml/data/ocaf/A3 deleted file mode 100644 index 21c36ee422..0000000000 --- a/tests/xml/data/ocaf/A3 +++ /dev/null @@ -1,45 +0,0 @@ -set aTestName "caf001-C3" -puts $aTestName - -set QA_DUP 0 - -# Add an attribute to a data framework -set aFrom1 1 -set aTo1 2 -set aSetAttr11 3. -set aSetAttr12 4. -set aLabel 0:2 -set isDelta 0 -SetRealArray D ${aLabel} ${isDelta} ${aFrom1} ${aTo1} ${aSetAttr11} ${aSetAttr12} - -# Close/Open the transaction -NewCommand D - -# Save the document -set aFile $WorkDirectory/${aTestName}.${FileSuffix} - -SaveToFile D $aFile - -# Restore the document -Close D -Open ${aFile} DD - -# Get a value of the attribute - -set IsDone [catch {set aGetAttr3 [GetRealArray DD ${aLabel}]} aResult] -if { ${IsDone} != 0 } { - puts "Error : Get a value of TDataStd_RealArray attribute from restoring document" -} else { - set aLen3 [llength ${aGetAttr3}] - if { ${aLen3} != [expr ${aTo1} - ${aFrom1} + 1] } { - puts "Error : Get a value of TDataStd_RealArray attribute from restoring document" - } - set aGetAttr41 [lindex ${aGetAttr3} 0] - if { ${aSetAttr11} != ${aGetAttr41} } { - puts "Error : Get a value of TDataStd_RealArray attribute from restoring document" - } - set aGetAttr42 [lindex ${aGetAttr3} 1] - if { ${aSetAttr12} != ${aGetAttr42} } { - puts "Error : Get a value of TDataStd_RealArray attribute from restoring document" - } -} \ No newline at end of file diff --git a/tests/xml/data/ocaf/A4 b/tests/xml/data/ocaf/A4 deleted file mode 100644 index 9452782678..0000000000 --- a/tests/xml/data/ocaf/A4 +++ /dev/null @@ -1,45 +0,0 @@ -set aTestName "caf001-D3" -puts ${aTestName} - -set QA_DUP 0 - -# Add an attribute to a data framework -set aFrom1 1 -set aTo1 2 -set aSetAttr11 3 -set aSetAttr12 4 -set aLabel 0:2 -set isDelta 0 -SetIntArray D ${aLabel} ${isDelta} ${aFrom1} ${aTo1} ${aSetAttr11} ${aSetAttr12} - -# Close/Open the transaction -NewCommand D - -# Save the document -set aFile $WorkDirectory/${aTestName}.${FileSuffix} - -SaveToFile D $aFile - -# Restore the document -Close D -Open ${aFile} DD - -# Get a value of the attribute - -set IsDone [catch {set aGetAttr3 [GetIntArray DD ${aLabel}]} aResult] -if { ${IsDone} != 0 } { - puts "Error : Get a value of TDataStd_IntegerArray attribute from restoring document" -} else { - set aLen3 [llength ${aGetAttr3}] - if { ${aLen3} != [expr ${aTo1} - ${aFrom1} + 1] } { - puts "Error : Get a value of TDataStd_IntegerArray attribute from restoring document" - } - set aGetAttr41 [lindex ${aGetAttr3} 0] - if { ${aSetAttr11} != ${aGetAttr41} } { - puts "Error : Get a value of TDataStd_IntegerArray attribute from restoring document" - } - set aGetAttr42 [lindex ${aGetAttr3} 1] - if { ${aSetAttr12} != ${aGetAttr42} } { - puts "Error : Get a value of TDataStd_IntegerArray attribute from restoring document" - } -} diff --git a/tests/xml/data/ocaf/A5 b/tests/xml/data/ocaf/A5 deleted file mode 100644 index 5bfc9ab4cf..0000000000 --- a/tests/xml/data/ocaf/A5 +++ /dev/null @@ -1,26 +0,0 @@ -set aTestName "caf001-E3" -puts ${aTestName} - -# Add an attribute to a data framework -set aSetAttr1 "New Attribute" -set aLabel 0:2 -Label D ${aLabel} -SetName D ${aLabel} ${aSetAttr1} - -# Close/Open the transaction -NewCommand D - -# Save the document -set aFile $WorkDirectory/${aTestName}.${FileSuffix} - -SaveToFile D $aFile - -# Restore the document -Close D -Open ${aFile} DD - -# Get a value of the attribute -set IsDone [catch {set aGetAttr3 [GetName DD ${aLabel}]} aResult] -if { ${IsDone} != 0 || ${aSetAttr1}!=${aGetAttr3} } { - puts "Error : Get a value of TDataStd_Name attribute from restoring document" -} diff --git a/tests/xml/data/ocaf/A6 b/tests/xml/data/ocaf/A6 deleted file mode 100644 index bdf3fe9370..0000000000 --- a/tests/xml/data/ocaf/A6 +++ /dev/null @@ -1,26 +0,0 @@ -set aTestName "caf001-F3" -puts ${aTestName} - -# Add an attribute to a data framework -set aSetAttr1 "New Attribute" -set aLabel 0:2 -Label D ${aLabel} -SetComment D ${aLabel} ${aSetAttr1} - -# Close/Open the transaction -NewCommand D - -# Save the document -set aFile $WorkDirectory/${aTestName}.${FileSuffix} - -SaveToFile D $aFile - -# Restore the document -Close D -Open ${aFile} DD - -# Get a value of the attribute -set IsDone [catch {set aGetAttr3 [GetComment DD ${aLabel}]} aResult] -if { ${IsDone} != 0 || ${aSetAttr1}!=${aGetAttr3} } { - puts "Error : Get a value of TDataStd_Comment attribute from restoring document" -} diff --git a/tests/xml/data/ocaf/A7 b/tests/xml/data/ocaf/A7 deleted file mode 100644 index c44b1a391d..0000000000 --- a/tests/xml/data/ocaf/A7 +++ /dev/null @@ -1,49 +0,0 @@ -set aTestName "caf001-G3" -puts ${aTestName} - -set aTokList { :,} - -# Add an attribute to a data framework -set aSetX1 10 -set aSetY1 20 -set aSetZ1 30 -point aPoint1 ${aSetX1} ${aSetY1} ${aSetZ1} - -set aDumpPoint1 [dump aPoint1] - -regexp {Point : ([-0-9.+eE]+), ([-0-9.+eE]+), ([-0-9.+eE]+)} ${aDumpPoint1} full X_Point1 Y_Point1 Z_Point1 - -set aLabel 0:2 -SetPoint D ${aLabel} aPoint1 - -# Close/Open the transaction -NewCommand D - -# Save the document -set aFile $WorkDirectory/${aTestName}.${FileSuffix} - -SaveToFile D $aFile - -# Restore the document -Close D -Open ${aFile} DD - -# Get a value of the attribute -set IsDone [catch {set aGetAttr3 [GetPoint DD ${aLabel}]} aResult] -if { ${IsDone} != 0 } { - puts "Error : Get a value of TDataStd_Point attribute from restoring document" -} else { - GetPoint DD ${aLabel} aPoint5 - - set aDumpPoint5 [dump aPoint5] - regexp {Point : ([-0-9.+eE]+), ([-0-9.+eE]+), ([-0-9.+eE]+)} ${aDumpPoint5} full X_Point5 Y_Point5 Z_Point5 - - if { ${X_Point1} != ${X_Point5} || - ${Y_Point1} != ${Y_Point5} || - ${Z_Point1} != ${Z_Point5} } { - puts "X_Point1=${X_Point1} X_Point5=${X_Point5}" - puts "Y_Point1=${Y_Point1} Y_Point5=${Y_Point5}" - puts "Z_Point1=${Z_Point1} Z_Point5=${Z_Point5}" - puts "Error : Get a value of TDataStd_Point attribute from restoring document" - } -} diff --git a/tests/xml/data/ocaf/A8 b/tests/xml/data/ocaf/A8 deleted file mode 100644 index c591f64b9d..0000000000 --- a/tests/xml/data/ocaf/A8 +++ /dev/null @@ -1,53 +0,0 @@ -set aTestName "caf001-H3" -puts ${aTestName} - -set aTokList { :,} - -# Add an attribute to a data framework -set aSetX1 10 -set aSetY1 20 -set aSetZ1 30 -set aSetDX1 100 -set aSetDY1 200 -set aSetDZ1 300 -line aLine1 ${aSetX1} ${aSetY1} ${aSetZ1} ${aSetDX1} ${aSetDY1} ${aSetDZ1} - -set aDumpLine1 [dump aLine1] - -regexp {Origin[ \t]*:([-0-9.+eE]+), ([-0-9.+eE]+), ([-0-9.+eE]+)} ${aDumpLine1} full anOriginX_Line1 anOriginY_Line1 anOriginZ_Line1 -regexp {Axis[ \t]*:([-0-9.+eE]+), ([-0-9.+eE]+), ([-0-9.+eE]+)} ${aDumpLine1} full anAxisDX_Line1 anAxisDY_Line1 anAxisDZ_Line1 - -set aLabel 0:2 -SetAxis D ${aLabel} aLine1 - -# Close/Open the transaction -NewCommand D - -# Save the document -set aFile $WorkDirectory/${aTestName}.${FileSuffix} - -SaveToFile D $aFile - -# Restore the document -Close D -Open ${aFile} DD - -# Get a value of the attribute -set IsDone [catch {GetAxis DD ${aLabel} anAxis3} aResult] -if { ${IsDone} != 0 } { - puts "Error : Get a value of TDataStd_Axis attribute from restoring document" -} else { - - set aDumpAxis3 [dump anAxis3] - regexp {Origin[ \t]*:([-0-9.+eE]+), ([-0-9.+eE]+), ([-0-9.+eE]+)} ${aDumpAxis3} full anOriginX_Line3 anOriginY_Line3 anOriginZ_Line3 - regexp {Axis[ \t]*:([-0-9.+eE]+), ([-0-9.+eE]+), ([-0-9.+eE]+)} ${aDumpAxis3} full anAxisDX_Line3 anAxisDY_Line3 anAxisDZ_Line3 - - if { ${anOriginX_Line1} != ${anOriginX_Line3} || - ${anOriginY_Line1} != ${anOriginY_Line3} || - ${anOriginZ_Line1} != ${anOriginZ_Line3} || - ${anAxisDX_Line1} != ${anAxisDX_Line3} || - ${anAxisDY_Line1} != ${anAxisDY_Line3} || - ${anAxisDZ_Line1} != ${anAxisDZ_Line3} } { - puts "Error : Get a value of TDataStd_Axis attribute from restoring document" - } -} diff --git a/tests/xml/data/ocaf/A9 b/tests/xml/data/ocaf/A9 deleted file mode 100644 index 60efd3d754..0000000000 --- a/tests/xml/data/ocaf/A9 +++ /dev/null @@ -1,61 +0,0 @@ -set aTestName "caf001-I3" -puts ${aTestName} - -set aTokList { :,} - -# Add an attribute to a data framework -set aSetX1 10 -set aSetY1 20 -set aSetZ1 30 -set aSetDX1 -1 -set aSetDY1 0 -set aSetDZ1 0 - -plane aPlane1 ${aSetX1} ${aSetY1} ${aSetZ1} ${aSetDX1} ${aSetDY1} ${aSetDZ1} - -set aDumpPlane1 [dump aPlane1] - -regexp {Origin[ \t]*:([-0-9.+eE]+), ([-0-9.+eE]+), ([-0-9.+eE]+)} ${aDumpPlane1} full anOriginX_Plane1 anOriginY_Plane1 anOriginZ_Plane1 -regexp {Axis[ \t]*:([-0-9.+eE]+), ([-0-9.+eE]+), ([-0-9.+eE]+)} ${aDumpPlane1} full anAxisDX_Plane1 anAxisDY_Plane1 anAxisDZ_Plane1 - -set aLabel 0:2 -SetPlane D ${aLabel} aPlane1 - -# Close/Open the transaction -NewCommand D - -# Save the document -set aFile $WorkDirectory/${aTestName}.${FileSuffix} - -SaveToFile D $aFile - -# Restore the document -Close D -Open ${aFile} DD - -# Get a value of the attribute -set IsDone [catch {GetPlane DD ${aLabel} aPlane5} aResult] -if { ${IsDone} != 0 } { - puts "Error : Get a value of TDataStd_Plane attribute from restoring document" -} else { - - set aDumpPlane5 [dump aPlane5] - - regexp {Origin[ \t]*:([-0-9.+eE]+), ([-0-9.+eE]+), ([-0-9.+eE]+)} ${aDumpPlane5} full anOriginX_Plane5 anOriginY_Plane5 anOriginZ_Plane5 - regexp {Axis[ \t]*:([-0-9.+eE]+), ([-0-9.+eE]+), ([-0-9.+eE]+)} ${aDumpPlane5} full anAxisDX_Plane5 anAxisDY_Plane5 anAxisDZ_Plane5 - - if { ${anOriginX_Plane1} != ${anOriginX_Plane5} || - ${anOriginY_Plane1} != ${anOriginY_Plane5} || - ${anOriginZ_Plane1} != ${anOriginZ_Plane5} || - ${anAxisDX_Plane1} != ${anAxisDX_Plane5} || - ${anAxisDY_Plane1} != ${anAxisDY_Plane5} || - ${anAxisDZ_Plane1} != ${anAxisDZ_Plane5} } { - puts "anOriginX_Plane1=${anOriginX_Plane1} anOriginX_Plane5=${anOriginX_Plane5}" - puts "anOriginY_Plane1=${anOriginY_Plane1} anOriginY_Plane5=${anOriginY_Plane5}" - puts "anOriginZ_Plane1=${anOriginZ_Plane1} anOriginZ_Plane5=${anOriginZ_Plane5}" - puts "anAxisDX_Plane1=${anAxisDX_Plane1} anAxisDX_Plane5=${anAxisDX_Plane5}" - puts "anAxisDY_Plane1=${anAxisDY_Plane1} anAxisDY_Plane5=${anAxisDY_Plane5}" - puts "anAxisDZ_Plane1=${anAxisDZ_Plane1} anAxisDZ_Plane5=${anAxisDZ_Plane5}" - puts "Error : Get a value of TDataStd_Plane attribute from restoring document" - } -} diff --git a/tests/xml/data/ocaf/B1 b/tests/xml/data/ocaf/B1 deleted file mode 100644 index 3b1b62a50a..0000000000 --- a/tests/xml/data/ocaf/B1 +++ /dev/null @@ -1,31 +0,0 @@ -set aTestName "caf001-J3" -puts ${aTestName} - -# Add an attribute to a data framework -set aSetAttr1 "c73bd075-22ee-11d2-acde-080009dc4422" -set aLabel 0:2 -SetUAttribute D ${aLabel} ${aSetAttr1} - -# Close/Open the transaction -NewCommand D - -# Save the document -set aFile $WorkDirectory/${aTestName}.${FileSuffix} - -SaveToFile D $aFile - -# Restore the document -Close D -Open ${aFile} DD - -# Get a value of the attribute -set IsDone [catch {GetUAttribute DD ${aLabel} ${aSetAttr1}} aResult] -if { ${IsDone} != 0 } { - puts "Error : Get a value of TDataStd_UAttribute attribute from restoring document" -} else { - set aGetAttr3 [GetUAttribute DD ${aLabel} ${aSetAttr1}] - - if { ${aSetAttr1}!=${aGetAttr3} } { - puts "Error : Get a value of TDataStd_UAttribute attribute from restoring document" - } -} \ No newline at end of file diff --git a/tests/xml/data/ocaf/B2 b/tests/xml/data/ocaf/B2 deleted file mode 100644 index aa0cf24186..0000000000 --- a/tests/xml/data/ocaf/B2 +++ /dev/null @@ -1,44 +0,0 @@ -set aTestName "caf001-J6" -puts ${aTestName} - -# Add an attribute to a data framework -set aSetAttr1 "c73bd075-22ee-11d2-acde-080009dc4422" -set aLabel 0:2 -SetUAttribute D ${aLabel} ${aSetAttr1} - -# Add new ID to a label -set aSetAttr2 "c73bd076-22ee-11d2-acde-080009dc4422" -SetUAttribute D ${aLabel} ${aSetAttr2} - -# Close/Open the transaction -NewCommand D - -# Save the document -set aFile $WorkDirectory/${aTestName}.${FileSuffix} - -SaveToFile D $aFile - -# Restore the document -Close D -Open ${aFile} DD - -# Get a value of first ID -set IsDone [catch {GetUAttribute DD ${aLabel} ${aSetAttr1}} aResult] -if { ${IsDone} != 0 } { - puts "Error : Get a value of TDataStd_UAttribute attribute from restoring document" -} else { - set aGetAttr1 [GetUAttribute DD ${aLabel} ${aSetAttr1}] - if { ${aSetAttr1}!=${aGetAttr1} } { - puts "Error : Get a value of TDataStd_UAttribute attribute from restoring document" - } -} -# Get a value of second ID -set IsDone [catch {GetUAttribute DD ${aLabel} ${aSetAttr2}} aResult] -if { ${IsDone} != 0 } { - puts "Error : Get a value of TDataStd_UAttribute attribute from restoring document" -} else { - set aGetAttr2 [GetUAttribute DD ${aLabel} ${aSetAttr2}] - if { ${aSetAttr2}!=${aGetAttr2} } { - puts "Error : Get a value of TDataStd_UAttribute attribute from restoring document" - } -} diff --git a/tests/xml/data/ocaf/B3 b/tests/xml/data/ocaf/B3 deleted file mode 100644 index 77a27bec67..0000000000 --- a/tests/xml/data/ocaf/B3 +++ /dev/null @@ -1,52 +0,0 @@ -set aTestName "caf001-K3" -puts ${aTestName} - -# Add an attribute to a data framework -set aSetX1 10 -set aSetY1 20 -set aSetZ1 30 -set aSetDX1 100 -set aSetDY1 200 -set aSetDZ1 300 - -box aBox1 ${aSetX1} ${aSetY1} ${aSetZ1} ${aSetDX1} ${aSetDY1} ${aSetDZ1} - -bounding aBox1 -save X1_Box1 Y1_Box1 Z1_Box1 X2_Box1 Y2_Box1 Z2_Box1 - -set aLabel 0:2 -SetShape D ${aLabel} aBox1 - -# Close/Open the transaction -NewCommand D - -# Save the document -set aFile $WorkDirectory/${aTestName}.${FileSuffix} - -SaveToFile D $aFile - -# Restore the document -Close D -Open ${aFile} DD - -# Get a value of the attribute -set IsDone [catch {GetShape DD ${aLabel} aBox5} aResult] -if { ${IsDone} != 0 } { - puts "Error : Get a value of TDataStd_Shape attribute from restoring document" -} else { - bounding aBox5 -save X1_Box5 Y1_Box5 Z1_Box5 X2_Box5 Y2_Box5 Z2_Box5 - -if { [dval X1_Box1] != [dval X1_Box5] || - [dval Y1_Box1] != [dval Y1_Box5] || - [dval Z1_Box1] != [dval Z1_Box5] || - [dval X2_Box1] != [dval X2_Box5] || - [dval Y2_Box1] != [dval Y2_Box5] || - [dval Z2_Box1] != [dval Z2_Box5] } { - puts "X1_Box1=[dval X1_Box1] X1_Box5=[dval X1_Box5]" - puts "Y1_Box1=[dval Y1_Box1] Y1_Box5=[dval Y1_Box5]" - puts "Z1_Box1=[dval Z1_Box1] Z1_Box5=[dval Z1_Box5]" - puts "X2_Box1=[dval X2_Box1] X2_Box5=[dval X2_Box5]" - puts "Y2_Box1=[dval Y2_Box1] Y2_Box5=[dval Y2_Box5]" - puts "Z2_Box1=[dval Z2_Box1] Z2_Box5=[dval Z2_Box5]" - puts "Error : et a value of TDataStd_Shape attribute from restoring document" - } -} diff --git a/tests/xml/data/ocaf/B4 b/tests/xml/data/ocaf/B4 deleted file mode 100644 index e1b0fb1027..0000000000 --- a/tests/xml/data/ocaf/B4 +++ /dev/null @@ -1,55 +0,0 @@ -set aTestName "caf001-L3" -puts $aTestName -set LabelsList [list \ - 0:3 \ - 0:2076534922:524398634:912349856 \ - 0:3:9283:12:1:9843:46793:321 \ - 0:4:81245034:321:1:1:1:345:8542:1:90:6453 \ - 0:5:8:4:2:213:3242:123456789:987654321 \ - 0:2:15:123:31214:452398:421:3:2:1:3:1:2:9:10:2:1:1:4 \ - 0:2:2:1:1:1:3:1:2:1:34:1:2:4:1:5:4:1:9:3:1:2:1:8:2:3:1:9:5:2:7 \ - 0:2:9] -# Add an attribute to a data framework -set i "0" -set ref [lindex $LabelsList end] -SetInteger D $ref $i -foreach Label $LabelsList { - set i [expr "$i + 1"] - SetInteger D $Label $i - SetReference D $Label $ref - set ref $Label -} - -# Close/Open the transaction -NewCommand D - -# Save the document -set aFile $WorkDirectory/${aTestName}.${FileSuffix} - -SaveToFile D $aFile - -# Restore the document -Close D -Open $aFile DD - -# Check the restored values - -set ListLen [llength $LabelsList] -set i $ListLen -foreach Label $LabelsList { - set IsDone [catch { set aRef [GetReference DD $Label] } aResult] - if ${IsDone} { - puts "Error : Get a TDF_Reference attribute from restored document" - } - set IsDone [catch { set anInt [GetInteger DD $aRef] } aResult] - if ${IsDone} { - puts "Error : Get the integer under the referenced label from restored document" - } - if { $anInt == $i } { - puts "Comparison OK for ref $aRef on $Label: $anInt = $i" - } else { - puts "Error : $anInt != $i : wrong integer value restored" - } - set i [expr "($i + 1) % $ListLen"] -} - diff --git a/tests/xml/data/ocaf/B5 b/tests/xml/data/ocaf/B5 deleted file mode 100644 index 54b389a719..0000000000 --- a/tests/xml/data/ocaf/B5 +++ /dev/null @@ -1,61 +0,0 @@ -set aTestName "caf002-C1" -puts ${aTestName} - -# Create a box -set aSetX1 10 -set aSetY1 20 -set aSetZ1 30 -set aSetDX1 100 -set aSetDY1 200 -set aSetDZ1 300 - -box aBox1 ${aSetX1} ${aSetY1} ${aSetZ1} ${aSetDX1} ${aSetDY1} ${aSetDZ1} - -bounding aBox1 -save X1_Box1 Y1_Box1 Z1_Box1 X2_Box1 Y2_Box1 Z2_Box1 - -# Create a label -set aLabel 0:2 -Label D ${aLabel} - -# Close/Open transaction -NewCommand D - -# Set a shape to the label -SetShape D ${aLabel} aBox1 - -# Close/Open transaction -NewCommand D - -# Save the document -set aFile $WorkDirectory/${aTestName}.${FileSuffix} - -SaveToFile D $aFile - -# Restore the document -Close D -Open ${aFile} DD - -# Get a shape from the label -set IsDone [catch {GetShape DD ${aLabel} aBox3} aResult] -if { ${IsDone} != 0 } { - puts ${aResult} - puts "Error : Get a value of TNaming_NamedShape attribute from restoring document" -} else { - bounding aBox3 -save X1_Box3 Y1_Box3 Z1_Box3 X2_Box3 Y2_Box3 Z2_Box3 - -if { [dval X1_Box1] != [dval X1_Box3] || - [dval Y1_Box1] != [dval Y1_Box3] || - [dval Z1_Box1] != [dval Z1_Box3] || - [dval X2_Box1] != [dval X2_Box3] || - [dval Y2_Box1] != [dval Y2_Box3] || - [dval Z2_Box1] != [dval Z2_Box3] } { - puts "X1_Box1=[dval X1_Box1] X1_Box3=[dval X1_Box3]" - puts "Y1_Box1=[dval Y1_Box1] Y1_Box3=[dval Y1_Box3]" - puts "Z1_Box1=[dval Z1_Box1] Z1_Box3=[dval Z1_Box3]" - puts "X2_Box1=[dval X2_Box1] X2_Box3=[dval X2_Box3]" - puts "Y2_Box1=[dval Y2_Box1] Y2_Box3=[dval Y2_Box3]" - puts "Z2_Box1=[dval Z2_Box1] Z2_Box3=[dval Z2_Box3]" - puts "Error : Get a value of TNaming_NamedShape attribute from restoring document" - } -} - diff --git a/tests/xml/data/ocaf/B7 b/tests/xml/data/ocaf/B7 deleted file mode 100644 index 1d27abad19..0000000000 --- a/tests/xml/data/ocaf/B7 +++ /dev/null @@ -1,79 +0,0 @@ -set aTestName "caf004-B3" -puts ${aTestName} - -# Create two new documents Doc1, Doc2 -set FileFormat "BinOcaf" -if { $FileSuffix == "xml" } { - set FileFormat "XmlOcaf" -} -NewDocument Doc1 $FileFormat -NewDocument Doc2 $FileFormat - -# Set UndoLimit for them -UndoLimit Doc1 100 -UndoLimit Doc2 100 - -# Set a shape in Doc1 to label 'SLabel' -set aLabel1 0:2 -Label Doc1 ${aLabel1} -SetName Doc1 ${aLabel1} SLabel - -set aSetX1 10 -set aSetY1 20 -set aSetZ1 30 -set aSetDX1 100 -set aSetDY1 200 -set aSetDZ1 300 - -box aBox1 ${aSetX1} ${aSetY1} ${aSetZ1} ${aSetDX1} ${aSetDY1} ${aSetDZ1} - -bounding aBox1 -save X1_Box1 Y1_Box1 Z1_Box1 X2_Box1 Y2_Box1 Z2_Box1 - -SetShape Doc1 ${aLabel1} aBox1 - -# Create a new label 'TLabel1' in Doc1 -set aLabel2 0:3 -Label Doc1 ${aLabel2} -SetName Doc1 ${aLabel2} TLabel1 - -# Open transaction in Doc1 -NewCommand Doc1 - -# Copy 'SLabel' to the label 'TLabel1' with link -CopyWithLink Doc1 ${aLabel2} Doc1 ${aLabel1} - -# Close/Open transaction -NewCommand Doc1 - -# Save the document -set aFile $WorkDirectory/${aTestName}.${FileSuffix} - -SaveToFile Doc1 $aFile - -# Restore the document -Close Doc1 -Open ${aFile} Doc2 - -# Get a shape from 'TLabel1' of restoring document -set IsDone [catch {GetShape Doc2 ${aLabel2} aBox2} aResult] -if { ${IsDone} != 0 } { - puts "Error : Get a value of TNaming_NamedShape attribute from restoring document" -} else { - bounding aBox2 -save X1_Box2 Y1_Box2 Z1_Box2 X2_Box2 Y2_Box2 Z2_Box2 - -if { [dval X1_Box1] != [dval X1_Box2] || - [dval Y1_Box1] != [dval Y1_Box2] || - [dval Z1_Box1] != [dval Z1_Box2] || - [dval X2_Box1] != [dval X2_Box2] || - [dval Y2_Box1] != [dval Y2_Box2] || - [dval Z2_Box1] != [dval Z2_Box2] } { - puts "X1_Box1=[dval X1_Box1] X1_Box2=[dval X1_Box2]" - puts "Y1_Box1=[dval Y1_Box1] Y1_Box2=[dval Y1_Box2]" - puts "Z1_Box1=[dval Z1_Box1] Z1_Box2=[dval Z1_Box2]" - puts "X2_Box1=[dval X2_Box1] X2_Box2=[dval X2_Box2]" - puts "Y2_Box1=[dval Y2_Box1] Y2_Box2=[dval Y2_Box2]" - puts "Z2_Box1=[dval Z2_Box1] Z2_Box2=[dval Z2_Box2]" - puts "Error : Get a link between attributes of the same document from restoring document" - } -} - diff --git a/tests/xml/data/ocaf/B8 b/tests/xml/data/ocaf/B8 deleted file mode 100644 index dcb19daf3c..0000000000 --- a/tests/xml/data/ocaf/B8 +++ /dev/null @@ -1,35 +0,0 @@ -set aTestName "caf005-A3" -puts ${aTestName} - -# Add an attribute to a data framework -set aLabel1 0:2 -set aName1 Label1 -Label D ${aLabel1} -SetName D ${aLabel1} ${aName1} - -set aName11 Label11 -set aChild1 [NewChild D ${aLabel1}] -set aChild1 0:2:1 -SetName D ${aChild1} ${aName11} - -# Close/Open the transaction -NewCommand D - -# Save the document -set aFile $WorkDirectory/${aTestName}.${FileSuffix} - -SaveToFile D $aFile - -# Restore the document -Close D -Open ${aFile} DD - -# Get a value of the attribute -set IsDone [catch {set aNewTag [NewTag DD 0:2]} aResult] -if { ${IsDone} != 0 } { - puts "Error : Get a value of TDF_TagSource attribute from restoring document" -} else { - if { ${aNewTag} != 2 } { - puts "Error : Get a value of TDF_TagSource attribute from restoring document" - } -} diff --git a/tests/xml/data/ocaf/B9 b/tests/xml/data/ocaf/B9 deleted file mode 100644 index 50e9db5092..0000000000 --- a/tests/xml/data/ocaf/B9 +++ /dev/null @@ -1,26 +0,0 @@ -set aTestName "caf005-B3" -puts ${aTestName} - -# Add an attribute to a data framework -set aLabel1 0:2 -NewDirectory D ${aLabel1} -set aName1 Label1 -SetName D ${aLabel1} ${aName1} - -# Close/Open the transaction -NewCommand D - -# Save the document -set aFile $WorkDirectory/${aTestName}.${FileSuffix} - -SaveToFile D $aFile - -# Restore the document -Close D -Open ${aFile} DD - -# Get a value of the attribute -set IsDone [catch {set aGetName1 [GetName DD ${aLabel1}]} aResult] -if { ${IsDone} != 0 || ${aName1}!=${aGetName1} } { - puts "Error : Get a value of TDataStd_Directory attribute from restoring document" -} diff --git a/tests/xml/data/ocaf/C1 b/tests/xml/data/ocaf/C1 deleted file mode 100644 index b7fda4c156..0000000000 --- a/tests/xml/data/ocaf/C1 +++ /dev/null @@ -1,45 +0,0 @@ -set aTestName "caf005-C2" -puts ${aTestName} - -# Add an attribute to a data framework -set aName_Root Label_1 -set aLabel_Root 0:2 -Label D ${aLabel_Root} - -SetName D ${aLabel_Root} ${aName_Root} - -SetNode D ${aLabel_Root} - -Label D 0:7 -Label D 0:8 -Label D 0:9 - -SetNode D 0:7 -SetNode D 0:8 -SetNode D 0:9 - -AppendNode D ${aLabel_Root} 0:7 -AppendNode D ${aLabel_Root} 0:8 -AppendNode D ${aLabel_Root} 0:9 - -# Close/Open the transaction -NewCommand D - -# Save result for check after retrieval -set dump1 [ChildNodeIterate D ${aLabel_Root} 0] - -# Save the document -set aFile $WorkDirectory/${aTestName}.${FileSuffix} - -SaveToFile D $aFile - -# Restore the document -Close D -Open ${aFile} DD - -# Get a value of the attribute -set aGetLabel_Root "" -set IsDone [catch {set dump2 [ChildNodeIterate DD ${aLabel_Root} 0]} aResult] -if { ${IsDone} != 0 || ${dump1} != ${dump2} } { - puts "Error : Get a value of TDataStd_TreeNode attribute from restoring document" -} diff --git a/tests/xml/data/ocaf/C2 b/tests/xml/data/ocaf/C2 deleted file mode 100644 index f6baedf877..0000000000 --- a/tests/xml/data/ocaf/C2 +++ /dev/null @@ -1,67 +0,0 @@ -set aTestName "caf100-A1" -puts ${aTestName} - -# Create a box -set aSetX1 10 -set aSetY1 20 -set aSetZ1 30 -set aSetDX1 100 -set aSetDY1 200 -set aSetDZ1 300 - -box aBox1 ${aSetX1} ${aSetY1} ${aSetZ1} ${aSetDX1} ${aSetDY1} ${aSetDZ1} - -# Create a label -set aLabel 0:2 -Label D ${aLabel} - -# Close/Open transaction -NewCommand D - -# Set a shape to the label -SetShape D ${aLabel} aBox1 - -# Close/Open transaction -NewCommand D - -# Set a real attribute -set aRLabel 0:1:1 -Label D ${aRLabel} -SetReal D ${aRLabel} 123.456789 - -# Set a constraint -set aCLabel 0:3 -Label D ${aCLabel} -SetConstraint D ${aCLabel} "tan" ${aLabel} -SetConstraint D ${aCLabel} "plane" ${aLabel} -SetConstraint D ${aCLabel} "value" ${aRLabel} - -# Save dump before storing -set dump_before [GetConstraint D ${aCLabel}] -puts "dump_before = ${dump_before}" - -# Save the document -set aFile $WorkDirectory/${aTestName}.${FileSuffix} - -SaveToFile D $aFile - -# Restore the document -Close D -Open ${aFile} DD - -# Get a shape from the label -set IsDone [catch {GetConstraint DD ${aCLabel}} aResult] -if { ${IsDone} != 0 } { - puts "Error : Get a value of TDataStd_Constraint attribute from restoring document" -} else { - puts "aResult = ${aResult}" - - # Save dump after retrieving - set dump_after [GetConstraint DD ${aCLabel}] - puts "dump_after = ${dump_after}" - - if { ${dump_before} != ${dump_after} } { - puts "dump_after = ${dump_after} while dump_before = ${dump_before}" - puts "Error : Get a value of TDataStd_Constraint attribute from restoring document" - } -} diff --git a/tests/xml/data/ocaf/C3 b/tests/xml/data/ocaf/C3 deleted file mode 100644 index 1f9c69b35d..0000000000 --- a/tests/xml/data/ocaf/C3 +++ /dev/null @@ -1,42 +0,0 @@ -set aTestName "caf100-B1" -puts ${aTestName} - -box aBox1 10 20 30 100 200 300 - -# Create a label -set aLabel 0:2 -Label D ${aLabel} - -# Close/Open transaction -NewCommand D - -# Set a Geometry -set asettype "pnt" -SetGeometry D ${aLabel} ${asettype} aBox1 - -# Close/Open transaction -NewCommand D - -# Save the document -set aFile $WorkDirectory/${aTestName}.${FileSuffix} - -SaveToFile D $aFile - -# Restore the document -Close D -Open ${aFile} DD - -# Get a geometry type from the label -set IsDone [catch {GetGeometryType DD ${aLabel}} aResult] -if { ${IsDone} != 0 } { - puts "Error : Get a value of TDataStd_Geometry attribute from restoring document" -} else { - - # Check the type - set atype [GetGeometryType DD ${aLabel}] - puts "atype = ${atype}" - - if { ${atype} != ${asettype} } { - puts "Error : Get a value of TDataStd_Geometry attribute from restoring document" - } -} diff --git a/tests/xml/data/ocaf/C4 b/tests/xml/data/ocaf/C4 deleted file mode 100644 index 96d0d8a65f..0000000000 --- a/tests/xml/data/ocaf/C4 +++ /dev/null @@ -1,36 +0,0 @@ -set aTestName "caf100-C1" -puts ${aTestName} - -box ab 10 20 777 -NewShape D 0:1 ab - -# Close/Open transaction -NewCommand D - -# Create a label -set aLabel 0:1:1 - -# Set a Naming attribute -SelectShape D ${aLabel} ab - -# Close/Open transaction -NewCommand D - -# Dump selection to check result -DumpSelection D ${aLabel} - -# Save the document -set aFile $WorkDirectory/${aTestName}.${FileSuffix} - -SaveToFile D $aFile - -# Restore the document -Close D -Open ${aFile} DD - -# Check the result -set IsDone [catch {DumpSelection DD ${aLabel}} aResult] -if { ${IsDone} != 0 } { - puts "Error : Get a value of TNaming_Naming attribute from restoring document" -} - diff --git a/tests/xml/data/ocaf/C5 b/tests/xml/data/ocaf/C5 deleted file mode 100644 index 2c81ef1418..0000000000 --- a/tests/xml/data/ocaf/C5 +++ /dev/null @@ -1,62 +0,0 @@ -set aTestName "caf100-D1" -puts ${aTestName} - -# Create a box -box aBox1 10 20 30 100 200 300 - -# Close/Open transaction -NewCommand D - -# Set a shape to the label -set aBLabel 0:2 -Label D ${aBLabel} -SetShape D ${aBLabel} aBox1 - -# Close/Open transaction -NewCommand D - -# Set a real attribute -set aRLabel 0:3 -Label D ${aRLabel} -SetReal D ${aRLabel} 123.456789 - -# Set an integer attribute -set anILabel 0:4 -Label D ${anILabel} -SetInteger D ${anILabel} 123456789 - -# Set a signature -set signature 1 - -# Set a pattern -set aCLabel 0:1:1 -Label D ${aCLabel} -SetPattern D ${aCLabel} ${signature} ${aBLabel} ${aRLabel} ${anILabel} - -# Save dump before storing -set dump_before [DumpPattern D ${aCLabel}] -puts "dump_before = ${dump_before}" - -# Save the document -set aFile $WorkDirectory/${aTestName}.${FileSuffix} - -SaveToFile D $aFile - -# Restore the document -Close D -Open ${aFile} DD - -# Get a shape from the label -set IsDone [catch {DumpPattern DD ${aCLabel}} aResult] -if { ${IsDone} != 0 } { - puts "Error : Get a value of TDataStd_PatternStd attribute from restoring document" -} else { - - # Save dump after retrieving - set dump_after [DumpPattern DD ${aCLabel}] - puts "dump_after = ${dump_after}" - - if { ${dump_before} != ${dump_after} } { - puts "Error : Get a value of TDataStd_PatternStd attribute from restoring document" - } -} diff --git a/tests/xml/data/ocaf/C6 b/tests/xml/data/ocaf/C6 deleted file mode 100644 index a08d188dc1..0000000000 --- a/tests/xml/data/ocaf/C6 +++ /dev/null @@ -1,37 +0,0 @@ -set aTestName "caf100-F1" -puts ${aTestName} - -# Set a driver guid -set driverGuid "5b35ca00-5b78-11d1-8940-080009dc3333" - -# Set a failure -set failureNb 13 - -# Set a function attribute -set aCLabel 0:1:1 -Label D ${aCLabel} -SetFunction D ${aCLabel} ${driverGuid} ${failureNb} - -# Save the document -set aFile ${WorkDirectory}/${aTestName}.${FileSuffix} - -SaveToFile D $aFile - -# Restore the document -Close D -Open ${aFile} DD - -# Get a variable from the label -set IsDone [catch {GetFunction DD ${aCLabel} driverGuid2 failureNb2} aResult] -if { ${IsDone} != 0 } { - puts "Error : Get a value of TFunction_Function attribute from restoring document" -} else { - - if { ${failureNb2} != ${failureNb} } { - puts "Error : Get a value of TFunction_Function attribute from restoring document" - } - - if { ${driverGuid2} != ${driverGuid} } { - puts "Error : Get a value of TFunction_Function attribute from restoring document" - } -} diff --git a/tests/xml/data/ocaf/C7 b/tests/xml/data/ocaf/C7 deleted file mode 100644 index 217da9d51b..0000000000 --- a/tests/xml/data/ocaf/C7 +++ /dev/null @@ -1,32 +0,0 @@ -set aTestName "caf100-P1" -puts ${aTestName} - -# Set a coordinates -set X 123.456 -set Y 789.012 -set Z 345.678 - -# Set a position attribute -set aCLabel 0:1:1 -Label D ${aCLabel} -SetPosition D ${aCLabel} ${X} ${Y} ${Z} - -# Save the document -set aFile ${WorkDirectory}/${aTestName}.${FileSuffix} - -SaveToFile D $aFile - -# Restore the document -Close D -Open ${aFile} DD - -# Get a variable from the label -set IsDone [catch {GetPosition DD ${aCLabel} X2 Y2 Z2} aResult] -if { ${IsDone} != 0 } { - puts "Error : Get a value of TPrsStd_Position attribute from restoring document" -} else { - - if { ${X2} != ${X} || ${Y2} != ${Y} || ${Z2} != ${Z}} { - puts "Error : Get a value of TPrsStd_Position attribute from restoring document" - } -} diff --git a/tests/xml/data/ocaf/C8 b/tests/xml/data/ocaf/C8 deleted file mode 100644 index b9796022bb..0000000000 --- a/tests/xml/data/ocaf/C8 +++ /dev/null @@ -1,46 +0,0 @@ -set aTestName "caf100-R1" -puts ${aTestName} - -# Set a variables -set aV1Label 0:1:1 -set aV2Label 0:1:2 -set aV3Label 0:1:3 - -Label D ${aV1Label} -Label D ${aV2Label} -Label D ${aV3Label} - -SetVariable D ${aV1Label} 1 "N" -SetVariable D ${aV2Label} 0 "kg" -SetVariable D ${aV3Label} 0 "m/s2" - -# Set an expression -set expression "f = m*a" - -# Set a relation -set aRLabel 0:1:13 -Label D ${aRLabel} -SetRelation D ${aRLabel} $expression $aV1Label $aV2Label $aV3Label - -# Save a result for check after retrieval -set dump_before [DumpRelation D ${aRLabel}] - -# Save the document -set aFile $WorkDirectory/${aTestName}.${FileSuffix} - -SaveToFile D $aFile - -# Restore the document -Close D -Open ${aFile} DD - -# Get a variable from the label -set IsDone [catch {set dump_after [DumpRelation DD ${aRLabel}]} aResult] -if { ${IsDone} != 0 } { - puts "Error : Get a value of TDataStd_Relation attribute from restoring document" -} else { - - if { ${dump_after} != ${dump_before} } { - puts "Error : Get a value of TDataStd_Relation attribute from restoring document" - } -} diff --git a/tests/xml/data/ocaf/C9 b/tests/xml/data/ocaf/C9 deleted file mode 100644 index ee7f50779d..0000000000 --- a/tests/xml/data/ocaf/C9 +++ /dev/null @@ -1,38 +0,0 @@ -set aTestName "caf100-V1" -puts ${aTestName} - -# Set isConstant -set isConstant 1 - -# Set a units -set units "kg/m3" - -# Set a variable -set aCLabel 0:1:1 -Label D ${aCLabel} -SetVariable D ${aCLabel} ${isConstant} ${units} - -# Save the document -set aFile $WorkDirectory/${aTestName}.${FileSuffix} - -SaveToFile D $aFile - -# Restore the document -Close D -Open ${aFile} DD - -# Get a variable from the label -set IsDone [catch {GetVariable DD ${aCLabel} isC2 units2} aResult] -if { ${IsDone} != 0 } { - puts "Error : Get a value of TDataStd_Variable attribute from restoring document" -} else { - - if { ${isC2} != ${isConstant} } { - puts "Error : Get a value of TDataStd_Variable attribute from restoring document" - } - - if { ${units2} != ${units} } { - puts "Error : Get a value of TDataStd_Variable attribute from restoring document" - } -} - diff --git a/tests/xml/data/ocaf/D1 b/tests/xml/data/ocaf/D1 deleted file mode 100644 index b7ca6489ad..0000000000 --- a/tests/xml/data/ocaf/D1 +++ /dev/null @@ -1,41 +0,0 @@ -set aTestName "caf001-E3" -puts ${aTestName} -set LabelsList { \ - { 0:11 "Tu sais je n'ai jamais t aussi hereux que ce matin-l" } \ - { 0:12 "\"Tu sais je n'ai jamais t aussi hereux que ce matin-l\"" } \ - { 0:13 "" } \ - { 0:14 "Tu m'as dit \"J'ai rendez-vous dans un sous-sol avec des fous" } \ - { 0:15 "\"Tu m'as dit \"J'ai rendez-vous dans un sous-sol avec des fous\"" } \ - { 0:16 "Il dans ce monde triste" } \ -} - -# Add an attribute to a data framework -foreach Label $LabelsList { - Label D [lindex $Label 0] - SetName D [lindex $Label 0] [lindex $Label 1] -} - -# Close/Open the transaction -NewCommand D - -# Save the document -set aFile $WorkDirectory/${aTestName}.${FileSuffix} - -SaveToFile D $aFile - -# Restore the document -Close D -Open ${aFile} DD - -# Check the restored values - -foreach Label $LabelsList { - set IsDone [catch { set aGetAttr [GetName DD [lindex $Label 0]] } aResult] - if $IsDone { - puts "Error : Get a TDataStd_Name attribute from restored document" - } else { - if [string compare $aGetAttr [lindex $Label 1]] { - puts "Error : different strings" - } - } -} diff --git a/tests/xml/data/ocaf/D2 b/tests/xml/data/ocaf/D2 deleted file mode 100644 index afaa41c274..0000000000 --- a/tests/xml/data/ocaf/D2 +++ /dev/null @@ -1,57 +0,0 @@ -set aTestName "caf001-L3" -puts $aTestName -set LabelsList [list \ - 0:3 \ - 0:2076534922:524398634:912349856 \ - 0:3:9283:12:1:9843:46793:321 \ - 0:4:81245034:321:1:1:1:345:8542:1:90:6453 \ - 0:5:8:4:2:213:3242:123456789:987654321 \ - 0:2:15:123:31214:452398:421:3:2:1:3:1:2:9:10:2:1:1:4 \ - 0:2:2:1:1:1:3:1:2:1:34:1:2:4:1:5:4:1:9:3:1:2:1:8:2:3:1:9:5:2:7 \ - 0:2:9] - -# Add an attribute to a data framework - -set i "0" -set ref [lindex $LabelsList end] -SetInteger D $ref $i -foreach Label $LabelsList { - set i [expr "$i + 1"] - SetInteger D $Label $i - SetReference D $Label $ref - set ref $Label -} - -# Close/Open the transaction -NewCommand D - -# Save the document -set aFile $WorkDirectory/${aTestName}.${FileSuffix} - -SaveToFile D $aFile - -# Restore the document -Close D -Open $aFile DD - -# Check the restored values - -set ListLen [llength $LabelsList] -set i $ListLen -foreach Label $LabelsList { - set IsDone [catch { set aRef [GetReference DD $Label] } aResult] - if ${IsDone} { - puts "Error : Get a TDF_Reference attribute from restored document" - } - set IsDone [catch { set anInt [GetInteger DD $aRef] } aResult] - if ${IsDone} { - puts "Error : Get the integer under the referenced label from restored document" - } - if { $anInt == $i } { - puts "Comparison OK for ref $aRef on $Label: $anInt = $i" - } else { - puts "Error : comparison $anInt != $i : wrong integer value restored" - } - set i [expr "($i + 1) % $ListLen"] -} - diff --git a/tests/xml/data/ocaf/D3 b/tests/xml/data/ocaf/D3 deleted file mode 100644 index fcadececc1..0000000000 --- a/tests/xml/data/ocaf/D3 +++ /dev/null @@ -1,46 +0,0 @@ -set aTestName "caf100-R1" -puts ${aTestName} - -# Set a variables -set aV1Label 0:1:1 -set aV2Label 0:1:2 -set aV3Label 0:1:3 - -Label D ${aV1Label} -Label D ${aV2Label} -Label D ${aV3Label} - -SetVariable D ${aV1Label} 1 "N" -SetVariable D ${aV2Label} 0 "kg" -SetVariable D ${aV3Label} 0 "µ/s²" - -# Set an expression -set expression "f = m*a" - -# Set a relation -set aRLabel 0:1:13 -Label D ${aRLabel} -SetRelation D ${aRLabel} $expression $aV1Label $aV2Label $aV3Label - -# Save a result for check after retrieval -set dump_before [DumpRelation D ${aRLabel}] - -# Save the document -set aFile $WorkDirectory/${aTestName}.${FileSuffix} - -SaveToFile D $aFile - -# Restore the document -Close D -Open ${aFile} DD - -# Get a variable from the label -set IsDone [catch {set dump_after [DumpRelation DD ${aRLabel}]} aResult] -if { ${IsDone} != 0 } { - puts "Error : Get a value of TDataStd_Relation attribute from restoring document" -} else { - - if { ${dump_after} != ${dump_before} } { - puts "Error : Get a value of TDataStd_Relation attribute from restoring document" - } -} diff --git a/tests/xml/data/ocaf/D4 b/tests/xml/data/ocaf/D4 deleted file mode 100644 index f7505af02d..0000000000 --- a/tests/xml/data/ocaf/D4 +++ /dev/null @@ -1,46 +0,0 @@ -set aTestName "xml001-D5" -puts ${aTestName} - -set QA_DUP 0 - -# Add an attribute to a data framework -set aFrom1 1 -set aTo1 1 -set aSetAttr11 3 -set aSetAttr12 4 -set aLabel 0:2 -set isDelta 0 -SetIntArray D ${aLabel} ${isDelta} ${aFrom1} ${aTo1} ${aSetAttr11} ${aSetAttr12} - -# Close/Open the transaction -NewCommand D - -# Save the document -set aFile $WorkDirectory/${aTestName}.${FileSuffix} - -SaveToFile D $aFile - -# Restore the document -Close D -Open ${aFile} DD - -# Get a value of the attribute -set IsGood 1 -set IsDone [catch {set aGetAttr3 [GetIntArray DD ${aLabel}]} aResult] -if { ${IsDone} != 0 } { - set IsGood 0 - puts "Error : Get a value of TDataStd_IntegerArray attribute from restoring document" -} -set aLen3 [llength ${aGetAttr3}] -if { ${aLen3} != [expr ${aTo1} - ${aFrom1} + 1] } { - set IsGood 0 - puts "Error : Get a value of TDataStd_IntegerArray attribute from restoring document" -} -set aGetAttr41 [lindex ${aGetAttr3} 0] -if { ${aSetAttr11} != ${aGetAttr41} } { - set IsGood 0 - puts "Error : Get a value of TDataStd_IntegerArray attribute from restoring document" -} -if { ${IsGood} == 0} { - puts "Error : Get a value of TDataStd_IntegerArray attribute from restoring document" -} diff --git a/tests/xml/data/ocaf/D5 b/tests/xml/data/ocaf/D5 deleted file mode 100644 index 15309d7eee..0000000000 --- a/tests/xml/data/ocaf/D5 +++ /dev/null @@ -1,47 +0,0 @@ -set aTestName "xml001-D6" -puts $aTestName - -set QA_DUP 0 - -# Add an attribute to a data framework -set aFrom1 1 -set aTo1 1 -set aSetAttr11 3. -set aSetAttr12 4. -set aLabel 0:2 -set isDelta 0 -SetRealArray D ${aLabel} ${isDelta} ${aFrom1} ${aTo1} ${aSetAttr11} ${aSetAttr12} - -# Close/Open the transaction -NewCommand D - -# Save the document -set aFile $WorkDirectory/${aTestName}.${FileSuffix} - -SaveToFile D $aFile - -# Restore the document -Close D -Open ${aFile} DD - -# Get a value of the attribute -set IsGood 1 -set IsDone [catch {set aGetAttr3 [GetRealArray DD ${aLabel}]} aResult] -if { ${IsDone} != 0 } { - set IsGood 0 - puts "Error : Get a value of TDataStd_RealArray attribute from restoring document" -} -set aLen3 [llength ${aGetAttr3}] -if { ${aLen3} != [expr ${aTo1} - ${aFrom1} + 1] } { - set IsGood 0 - puts "Error : Get a value of TDataStd_RealArray attribute from restoring document" -} -set aGetAttr41 [lindex ${aGetAttr3} 0] -if { ${aSetAttr11} != ${aGetAttr41} } { - set IsGood 0 - puts "Error : Get a value of TDataStd_RealArray attribute from restoring document" -} -if { ${IsGood} == 0} { - puts "Get a value of TDataStd_RealArray attribute from restoring document: Error" -} - diff --git a/tests/xml/data/ocaf/D6 b/tests/xml/data/ocaf/D6 deleted file mode 100644 index f6a43549c0..0000000000 --- a/tests/xml/data/ocaf/D6 +++ /dev/null @@ -1,41 +0,0 @@ -puts "============" -puts "OCC16497" -puts "============" -puts "" -####################################################################### -# XML OCAF storage of document on disk looses "0" in "00", "000", etc. -####################################################################### - -set BugNumber OCC16497 - -set aTestName "xml001-D7" -puts ${aTestName} - -# Add an attribute to a data framework -set aSetAttr1 "00" -set aLabel 0:2 -Label D ${aLabel} -SetName D ${aLabel} ${aSetAttr1} - -# Close/Open the transaction -NewCommand D - -# Save the document -set aFile $WorkDirectory/${aTestName}.${FileSuffix} - -SaveToFile D $aFile - -if { ![file exists ${aFile}] } { - puts "There is not ${aFile} file; SaveAs command: Error" - puts "Error : ${BugNumber} (case 1)" -} - -# Restore the document -Close D -Open ${aFile} DD - -# Get a value of the attribute -set IsDone [catch {set aGetAttr3 [GetName DD ${aLabel}]} aResult] -if { ${IsDone} != 0 || ${aSetAttr1}!=${aGetAttr3} } { - puts "Error : Get a value of TDataStd_Name attribute from restoring document ${BugNumber}" -} diff --git a/tests/xml/data/xcaf/A1 b/tests/xml/data/xcaf/A1 deleted file mode 100644 index dc77004a3e..0000000000 --- a/tests/xml/data/xcaf/A1 +++ /dev/null @@ -1,33 +0,0 @@ -set aTestName "xcaf200-A1" -puts $aTestName - -# Add an attribute to a data framework -set aLabel 0:1:1:1 -Label D $aLabel -set aValue 13.777 -XSetArea D $aLabel $aValue - -# Close/Open the transaction -NewCommand D - -# save result for check after retrieval -set area_before [XGetArea D $aLabel] -if { ${area_before} != ${aValue} } { - puts "Error : XSetArea or XGetArea" -} else { - - # Save the document - set aFile $WorkDirectory/${aTestName}.${FileSuffix} - - SaveToFile D $aFile - - # Restore the document - Close D - Open ${aFile} DD - - # Get a value of the attribute - set IsDone [catch {set area_after [XGetArea DD $aLabel]} aResult] - if { ${IsDone} != 0 || ${area_after} != ${area_before} } { - puts "Error : Get a value of XCAFDoc_Area attribute from restoring document" - } -} diff --git a/tests/xml/data/xcaf/A4 b/tests/xml/data/xcaf/A4 deleted file mode 100644 index 85c9b1f3b5..0000000000 --- a/tests/xml/data/xcaf/A4 +++ /dev/null @@ -1,26 +0,0 @@ -set aTestName "xcaf200-C1" -puts $aTestName - -# Add an attribute to a data framework -set aLabel [XAddColor D 0.3 0.3 0.3] - -# Close/Open the transaction -NewCommand D - -# save result for check after retrieval -set color_before [XGetColor D $aLabel] - -# Save the document -set aFile $WorkDirectory/${aTestName}.${FileSuffix} - -SaveToFile D $aFile - -# Restore the document -Close D -Open ${aFile} DD - -# Get a value of the attribute -set IsDone [catch {set color_after [XGetColor DD $aLabel]} aResult] -if { ${IsDone} != 0 || ${color_after} != ${color_before} } { - puts "Error : Get a value of XCAFDoc_Color attribute from restoring document" -} diff --git a/tests/xml/data/xcaf/A5 b/tests/xml/data/xcaf/A5 deleted file mode 100644 index 0a56cd0f40..0000000000 --- a/tests/xml/data/xcaf/A5 +++ /dev/null @@ -1,25 +0,0 @@ -set aTestName "xcaf200-D1" -puts $aTestName - -# Add an attribute to a data framework -set aLabel 0:1:1:1 -Label D $aLabel -set coords_before [XSetCentroid D $aLabel 12.34 56.78 90.12] - -# Close/Open the transaction -NewCommand D - -# Save the document -set aFile $WorkDirectory/${aTestName}.${FileSuffix} - -SaveToFile D $aFile - -# Restore the document -Close D -Open ${aFile} DD - -# Get a value of the attribute -set IsDone [catch {set coords_after [XGetCentroid DD $aLabel]} aResult] -if { ${IsDone} != 0 || ${coords_after} != ${coords_before} } { - puts "Error : Get a value of XCAFDoc_Centroid attribute from restoring document" -} diff --git a/tests/xml/data/xcaf/A6 b/tests/xml/data/xcaf/A6 deleted file mode 100644 index 91567e0b13..0000000000 --- a/tests/xml/data/xcaf/A6 +++ /dev/null @@ -1,41 +0,0 @@ -puts "============" -puts "OCC16497" -puts "============" -puts "" -####################################################################### -# XML OCAF storage of document on disk looses "0" in "00", "000", etc. -####################################################################### - -set BugNumber OCC16497 - -set aTestName "xml001-D7" -puts ${aTestName} - -# Add an attribute to a data framework -set aSetAttr1 "00" -set aLabel 0:2 -Label D ${aLabel} -SetName D ${aLabel} ${aSetAttr1} - -# Close/Open the transaction -NewCommand D - -# Save the document -set aFile $WorkDirectory/${aTestName}.${FileSuffix} - -SaveToFile D $aFile - -if { ![file exists ${aFile}] } { - puts "Error : ${BugNumber} (case 1)" -} - -# Restore the document -Close D -Open ${aFile} DD - -# Get a value of the attribute -set IsDone [catch {set aGetAttr3 [GetName DD ${aLabel}]} aResult] -puts "aSetAttr1=${aSetAttr1} aGetAttr3=${aGetAttr3}" -if { ${IsDone} != 0 || ${aSetAttr1}!=${aGetAttr3} } { - puts "Error : Get a value of TDataStd_Name attribute from restoring document ${BugNumber}" -} diff --git a/tests/xml/data/xcaf/A7 b/tests/xml/data/xcaf/A7 deleted file mode 100644 index 599c33d672..0000000000 --- a/tests/xml/data/xcaf/A7 +++ /dev/null @@ -1,29 +0,0 @@ -set aTestName "xcaf200-G1" -puts $aTestName - -box aBox 10 20 30 - -# Add an attribute to a data framework -set aShLabel [XAddShape D aBox] -set layer_before "Layer_1" -set aLaLabel [XAddLayer D ${layer_before}] -XSetLinkLayer D $aShLabel $aLaLabel - -# Close/Open the transaction -NewCommand D -set layer_before [XGetLayers D $aShLabel] - -# Save the document -set aFile $WorkDirectory/${aTestName}.${FileSuffix} - -SaveToFile D $aFile - -# Restore the document -Close D -Open ${aFile} DD - -# Get a value of the attribute -set IsDone [catch {set layer_after [XGetLayers DD $aShLabel]} aResult] -if { ${IsDone} != 0 || ${layer_after} != ${layer_before} } { - puts "Error : Get a value of XCAFDoc_GraphNode attribute from restoring document" -} diff --git a/tests/xml/data/xcaf/A8 b/tests/xml/data/xcaf/A8 deleted file mode 100644 index a2cb33b11b..0000000000 --- a/tests/xml/data/xcaf/A8 +++ /dev/null @@ -1,30 +0,0 @@ -set aTestName "xcaf200-L1" -puts $aTestName - -# Add an attribute to a data framework -set aLabel [XNewShape D] -box aB 10 20 30 -ttranslate aB 333 777 13 -XAddComponent D $aLabel aB -set aLabel ${aLabel}:1 - -# Close/Open the transaction -NewCommand D - -# save result for check after retrieval -set location_before [XDumpLocation D $aLabel] - -# Save the document -set aFile $WorkDirectory/${aTestName}.${FileSuffix} - -SaveToFile D $aFile - -# Restore the document -Close D -Open ${aFile} DD - -# Get a value of the attribute -set IsDone [catch {set location_after [XDumpLocation DD $aLabel]} aResult] -if { ${IsDone} != 0 || ${location_after} != ${location_before} } { - puts "Error : Get a value of XCAFDoc_Location attribute from restoring document" -} diff --git a/tests/xml/data/xcaf/A9 b/tests/xml/data/xcaf/A9 deleted file mode 100644 index bb6982ac2e..0000000000 --- a/tests/xml/data/xcaf/A9 +++ /dev/null @@ -1,33 +0,0 @@ -set aTestName "xcaf200-V1" -puts $aTestName - -# Add an attribute to a data framework -set aLabel 0:1:1:1 -Label D $aLabel -set aValue 13.777 -XSetVolume D $aLabel $aValue - -# Close/Open the transaction -NewCommand D - -# save result for check after retrieval -set vol_before [XGetVolume D $aLabel] -if { ${vol_before} != ${aValue} } { - puts "Error : XSetVolume or XGetVolume" -} else { - - # Save the document - set aFile $WorkDirectory/${aTestName}.${FileSuffix} - - SaveToFile D $aFile - - # Restore the document - Close D - Open ${aFile} DD - - # Get a value of the attribute - set IsDone [catch {set vol_after [XGetVolume DD $aLabel]} aResult] - if { ${IsDone} != 0 || ${vol_after} != ${vol_before} } { - puts "Error : Get a value of XCAFDoc_Volume attribute from restoring document" - } -}