From: azv Date: Mon, 16 Sep 2019 04:05:44 +0000 (+0300) Subject: Extrusion: fix error with offset plane. Make Extrusion CUT and FUSE be able to be... X-Git-Tag: VEDF2019Lot4_1~1 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=a5353bf7fb7f2084701097330df01b0d15b13769;p=modules%2Fshaper.git Extrusion: fix error with offset plane. Make Extrusion CUT and FUSE be able to be bounded by faces. --- diff --git a/src/FeaturesPlugin/CMakeLists.txt b/src/FeaturesPlugin/CMakeLists.txt index 8a255d679..6bf8e45d5 100644 --- a/src/FeaturesPlugin/CMakeLists.txt +++ b/src/FeaturesPlugin/CMakeLists.txt @@ -176,6 +176,7 @@ ADD_UNIT_TESTS(TestExtrusion.py TestExtrusionCut.py TestExtrusionCut_BySize.py TestExtrusionCut_ByPlanesAndOffsets.py + TestExtrusionCut_ByFaces.py TestExtrusionFuse.py TestExtrusionFuse_BySize.py TestExtrusionFuse_ByPlanesAndOffsets.py diff --git a/src/FeaturesPlugin/Test/TestExtrusionCut_ByFaces.py b/src/FeaturesPlugin/Test/TestExtrusionCut_ByFaces.py new file mode 100644 index 000000000..ef51f275b --- /dev/null +++ b/src/FeaturesPlugin/Test/TestExtrusionCut_ByFaces.py @@ -0,0 +1,150 @@ +# Copyright (C) 2014-2019 CEA/DEN, EDF R&D +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +# + +from salome.shaper import model + +model.begin() +partSet = model.moduleDocument() +Part_1 = model.addPart(partSet) +Part_1_doc = Part_1.document() +Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOY")) +SketchLine_1 = Sketch_1.addLine(25, 0, 0, 0) +SketchProjection_1 = Sketch_1.addProjection(model.selection("VERTEX", "PartSet/Origin"), False) +SketchPoint_1 = SketchProjection_1.createdFeature() +SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchPoint_1.result()) +SketchLine_2 = Sketch_1.addLine(0, 0, 0, 200) +SketchLine_3 = Sketch_1.addLine(0, 200, 25, 200) +SketchLine_3.setAuxiliary(True) +SketchLine_4 = Sketch_1.addLine(25, 200, 25, 0) +SketchConstraintCoincidence_2 = Sketch_1.setCoincident(SketchLine_4.endPoint(), SketchLine_1.startPoint()) +SketchConstraintCoincidence_3 = Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchLine_2.startPoint()) +SketchConstraintCoincidence_4 = Sketch_1.setCoincident(SketchLine_2.endPoint(), SketchLine_3.startPoint()) +SketchConstraintCoincidence_5 = Sketch_1.setCoincident(SketchLine_3.endPoint(), SketchLine_4.startPoint()) +SketchConstraintHorizontal_1 = Sketch_1.setHorizontal(SketchLine_1.result()) +SketchConstraintVertical_1 = Sketch_1.setVertical(SketchLine_2.result()) +SketchConstraintHorizontal_2 = Sketch_1.setHorizontal(SketchLine_3.result()) +SketchConstraintVertical_2 = Sketch_1.setVertical(SketchLine_4.result()) +SketchConstraintLength_1 = Sketch_1.setLength(SketchLine_2.result(), 200) +SketchConstraintLength_2 = Sketch_1.setLength(SketchLine_1.result(), 25) +SketchLine_5 = Sketch_1.addLine(125, 243.301270189222, -25, 243.3012701892219) +SketchLine_5.setAuxiliary(True) +SketchLine_6 = Sketch_1.addLine(-25, 243.3012701892219, 0, 200) +SketchLine_6.setAuxiliary(True) +SketchConstraintCoincidence_6 = Sketch_1.setCoincident(SketchLine_5.endPoint(), SketchLine_6.startPoint()) +SketchConstraintCoincidence_7 = Sketch_1.setCoincident(SketchLine_2.endPoint(), SketchLine_6.endPoint()) +SketchLine_7 = Sketch_1.addLine(0, 200, 0, 350) +SketchLine_7.setAuxiliary(True) +SketchConstraintCoincidence_8 = Sketch_1.setCoincident(SketchLine_2.endPoint(), SketchLine_7.startPoint()) +SketchConstraintHorizontal_3 = Sketch_1.setHorizontal(SketchLine_5.result()) +SketchConstraintPerpendicular_1 = Sketch_1.setPerpendicular(SketchLine_5.result(), SketchLine_7.result()) +SketchConstraintAngle_1 = Sketch_1.setAngle(SketchLine_7.result(), SketchLine_6.result(), 30) +SketchLine_8 = Sketch_1.addLine(-25, 243.3012701892219, 29.37846722219903, 268.6583658936639) +SketchConstraintCoincidence_9 = Sketch_1.setCoincident(SketchLine_5.endPoint(), SketchLine_8.startPoint()) +SketchLine_9 = Sketch_1.addLine(29.37846722219903, 268.6583658936639, 14.58682806127452, 300.3791384399466) +SketchConstraintCoincidence_10 = Sketch_1.setCoincident(SketchLine_8.endPoint(), SketchLine_9.startPoint()) +SketchConstraintPerpendicular_2 = Sketch_1.setPerpendicular(SketchLine_8.result(), SketchLine_9.result()) +SketchConstraintLength_3 = Sketch_1.setLength(SketchLine_6.result(), 50) +SketchConstraintLength_4 = Sketch_1.setLength(SketchLine_8.result(), 60) +SketchConstraintAngle_2 = Sketch_1.setAngle(SketchLine_5.result(), SketchLine_8.result(), 25) +SketchConstraintLength_5 = Sketch_1.setLength(SketchLine_9.result(), 35) +SketchLine_10 = Sketch_1.addLine(23.03919329608853, 282.2529826992136, 36.18065620811996, 288.3809474944538) +SketchLine_10.setAuxiliary(True) +SketchConstraintCoincidence_11 = Sketch_1.setCoincident(SketchLine_10.startPoint(), SketchLine_9.result()) +SketchLine_11 = Sketch_1.addLine(36.18065620811996, 288.3809474944538, 48.85920406034094, 261.1917138833543) +SketchLine_11.setAuxiliary(True) +SketchConstraintCoincidence_12 = Sketch_1.setCoincident(SketchLine_10.endPoint(), SketchLine_11.startPoint()) +SketchConstraintPerpendicular_3 = Sketch_1.setPerpendicular(SketchLine_10.result(), SketchLine_11.result()) +SketchConstraintPerpendicular_4 = Sketch_1.setPerpendicular(SketchLine_9.result(), SketchLine_10.result()) +SketchConstraintLength_6 = Sketch_1.setLength(SketchLine_11.result(), 30) +SketchConstraintLength_7 = Sketch_1.setLength(SketchLine_10.result(), 14.5) +SketchConstraintDistance_1 = Sketch_1.setDistance(SketchLine_9.endPoint(), SketchLine_10.startPoint(), 20, True) +SketchArc_1 = Sketch_1.addArc(4.697206021778518, 257.149304782984, 14.58682806127452, 300.3791384399466, 48.85920406034094, 261.1917138833543, True) +SketchConstraintCoincidence_13 = Sketch_1.setCoincident(SketchLine_9.endPoint(), SketchArc_1.startPoint()) +SketchConstraintCoincidence_14 = Sketch_1.setCoincident(SketchLine_11.endPoint(), SketchArc_1.endPoint()) +SketchConstraintCoincidence_15 = Sketch_1.setCoincident(SketchLine_10.endPoint(), SketchArc_1.results()[1]) +SketchArc_2 = Sketch_1.addArc(0.1512256873309691, 256.7331845326764, 48.85920406034094, 261.1917138833543, 34.14802119649147, 221.5683791690064, True) +SketchConstraintCoincidence_16 = Sketch_1.setCoincident(SketchLine_11.endPoint(), SketchArc_2.startPoint()) +SketchConstraintTangent_1 = Sketch_1.setTangent(SketchArc_2.results()[1], SketchArc_1.results()[1]) +SketchArc_3 = Sketch_1.addArc(-71.98457930083825, 187.3071972226404, 0, 200, -25, 243.3012701892219, False) +SketchConstraintCoincidence_17 = Sketch_1.setCoincident(SketchLine_2.endPoint(), SketchArc_3.startPoint()) +SketchConstraintCoincidence_18 = Sketch_1.setCoincident(SketchLine_5.endPoint(), SketchArc_3.endPoint()) +SketchLine_12 = Sketch_1.addLine(-25, 243.301270189222, 0, 222.3237794097899) +SketchLine_12.setAuxiliary(True) +SketchConstraintCoincidence_19 = Sketch_1.setCoincident(SketchLine_5.endPoint(), SketchLine_12.startPoint()) +SketchConstraintCoincidence_20 = Sketch_1.setCoincident(SketchLine_12.endPoint(), SketchLine_7.result()) +SketchConstraintTangent_2 = Sketch_1.setTangent(SketchArc_3.results()[1], SketchLine_12.result()) +SketchConstraintAngle_3 = Sketch_1.setAngle(SketchLine_6.result(), SketchLine_12.result(), 20) +SketchArc_4 = Sketch_1.addArc(55, 200, 34.14802119649147, 221.5683791690064, 25, 200, False) +SketchConstraintCoincidence_21 = Sketch_1.setCoincident(SketchArc_2.endPoint(), SketchArc_4.startPoint()) +SketchConstraintTangent_3 = Sketch_1.setTangent(SketchArc_2.results()[1], SketchArc_4.results()[1]) +SketchConstraintCoincidence_22 = Sketch_1.setCoincident(SketchArc_4.endPoint(), SketchLine_4.startPoint()) +SketchConstraintTangent_4 = Sketch_1.setTangent(SketchLine_4.result(), SketchArc_4.results()[1]) +SketchConstraintRadius_1 = Sketch_1.setRadius(SketchArc_4.results()[1], 30) +SketchLine_13 = Sketch_1.addLine(-7.179200577043265, 240.5774662449659, 15.47849409887298, 251.1429227884834) +SketchLine_14 = Sketch_1.addLine(15.47849409887298, 251.1429227884834, 26.04395064239047, 228.4852281125672) +SketchConstraintCoincidence_23 = Sketch_1.setCoincident(SketchLine_13.endPoint(), SketchLine_14.startPoint()) +SketchLine_15 = Sketch_1.addLine(26.04395064239047, 228.4852281125672, 3.386255966474217, 217.9197715690497) +SketchConstraintCoincidence_24 = Sketch_1.setCoincident(SketchLine_14.endPoint(), SketchLine_15.startPoint()) +SketchLine_16 = Sketch_1.addLine(3.386255966474217, 217.9197715690497, -7.179200577043265, 240.5774662449659) +SketchConstraintCoincidence_25 = Sketch_1.setCoincident(SketchLine_15.endPoint(), SketchLine_16.startPoint()) +SketchConstraintCoincidence_26 = Sketch_1.setCoincident(SketchLine_13.startPoint(), SketchLine_16.endPoint()) +SketchConstraintParallel_1 = Sketch_1.setParallel(SketchLine_13.result(), SketchLine_15.result()) +SketchConstraintParallel_2 = Sketch_1.setParallel(SketchLine_16.result(), SketchLine_14.result()) +SketchConstraintPerpendicular_5 = Sketch_1.setPerpendicular(SketchLine_13.result(), SketchLine_14.result()) +SketchConstraintParallel_3 = Sketch_1.setParallel(SketchLine_13.result(), SketchLine_8.result()) +SketchConstraintEqual_1 = Sketch_1.setEqual(SketchLine_15.result(), SketchLine_14.result()) +SketchConstraintLength_8 = Sketch_1.setLength(SketchLine_13.result(), 25) +SketchConstraintDistance_2 = Sketch_1.setDistance(SketchLine_8.result(), SketchLine_16.endPoint(), 10, True) +SketchConstraintDistance_3 = Sketch_1.setDistance(SketchArc_3.endPoint(), SketchLine_16.result(), 15, True) +SketchConstraintLength_9 = Sketch_1.setLength(SketchLine_5.result(), 150) +SketchConstraintLength_10 = Sketch_1.setLength(SketchLine_7.result(), 150) +model.do() +Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchLine_4r-SketchArc_4_2r-SketchArc_2_2f-SketchArc_1_2f-SketchLine_9r-SketchLine_8r-SketchArc_3_2r-SketchLine_2r-SketchLine_1r-SketchLine_13f-SketchLine_14f-SketchLine_15f-SketchLine_16f")], model.selection(), 10, 0) +Sketch_2 = model.addSketch(Part_1_doc, model.selection("FACE", "Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_14")) +SketchLine_17 = Sketch_2.addLine(-221.0712923119171, 10, -196.0712923119172, 0) +SketchLine_17.setAuxiliary(True) +SketchProjection_2 = Sketch_2.addProjection(model.selection("VERTEX", "[Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_13][Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_14][Extrusion_1_1/To_Face]"), False) +SketchPoint_2 = SketchProjection_2.createdFeature() +SketchConstraintCoincidence_27 = Sketch_2.setCoincident(SketchLine_17.startPoint(), SketchPoint_2.result()) +SketchProjection_3 = Sketch_2.addProjection(model.selection("VERTEX", "[Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_14][Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_15][Extrusion_1_1/From_Face]"), False) +SketchPoint_3 = SketchProjection_3.createdFeature() +SketchConstraintCoincidence_28 = Sketch_2.setCoincident(SketchLine_17.endPoint(), SketchPoint_3.result()) +SketchCircle_1 = Sketch_2.addCircle(-208.5712923119172, 5, 4) +SketchConstraintCoincidence_29 = Sketch_2.setCoincident(SketchLine_17.result(), SketchCircle_1.center()) +SketchConstraintMiddle_1 = Sketch_2.setMiddlePoint(SketchCircle_1.center(), SketchLine_17.result()) +SketchConstraintRadius_2 = Sketch_2.setRadius(SketchCircle_1.results()[1], 4) +model.do() +ExtrusionCut_1 = model.addExtrusionCut(Part_1_doc, [model.selection("WIRE", "Sketch_2/Face-SketchCircle_1_2f_wire")], model.selection(), model.selection("FACE", "Extrusion_1_1/Generated_Face&Sketch_1/SketchArc_3_2"), 0, model.selection(), 5, [model.selection("SOLID", "Extrusion_1_1")]) +model.do() + +from GeomAPI import GeomAPI_Shape + +model.testNbResults(ExtrusionCut_1, 1) +model.testNbSubResults(ExtrusionCut_1, [0]) +model.testNbSubShapes(ExtrusionCut_1, GeomAPI_Shape.SOLID, [1]) +model.testNbSubShapes(ExtrusionCut_1, GeomAPI_Shape.FACE, [18]) +model.testNbSubShapes(ExtrusionCut_1, GeomAPI_Shape.EDGE, [90]) +model.testNbSubShapes(ExtrusionCut_1, GeomAPI_Shape.VERTEX, [180]) +model.testResultsVolumes(ExtrusionCut_1, [78707.15553129233]) + +model.testHaveNamingSubshapes(ExtrusionCut_1, model, Part_1_doc) + +model.end() + +assert(model.checkPythonDump()) diff --git a/src/FeaturesPlugin/Test/TestExtrusion_ByFaces01.py b/src/FeaturesPlugin/Test/TestExtrusion_ByFaces01.py index c7b08bb94..11dcce3cb 100644 --- a/src/FeaturesPlugin/Test/TestExtrusion_ByFaces01.py +++ b/src/FeaturesPlugin/Test/TestExtrusion_ByFaces01.py @@ -109,7 +109,7 @@ model.testNbSubShapes(Extrusion_1, GeomAPI_Shape.FACE, [6]) model.testResultsVolumes(Extrusion_1, [57985.85]) # offset "From" face -ParamFrom.setValue(-20) +ParamFrom.setValue(20) model.do() model.testNbResults(Extrusion_1, 1) model.testNbSubResults(Extrusion_1, [0]) @@ -117,7 +117,7 @@ model.testNbSubShapes(Extrusion_1, GeomAPI_Shape.SOLID, [1]) model.testNbSubShapes(Extrusion_1, GeomAPI_Shape.FACE, [6]) model.testResultsVolumes(Extrusion_1, [37985.85]) -ParamFrom.setValue(20) +ParamFrom.setValue(-20) model.do() model.testNbResults(Extrusion_1, 1) model.testNbSubResults(Extrusion_1, [0]) diff --git a/src/FeaturesPlugin/Test/TestExtrusion_ByFaces02.py b/src/FeaturesPlugin/Test/TestExtrusion_ByFaces02.py index a55c34e6d..5444ef5c4 100644 --- a/src/FeaturesPlugin/Test/TestExtrusion_ByFaces02.py +++ b/src/FeaturesPlugin/Test/TestExtrusion_ByFaces02.py @@ -99,7 +99,7 @@ model.testNbSubShapes(Extrusion_1, GeomAPI_Shape.FACE, [6]) model.testResultsVolumes(Extrusion_1, [107985.85]) # offset "From" face -ParamFrom.setValue(-20) +ParamFrom.setValue(20) model.do() model.testNbResults(Extrusion_1, 1) model.testNbSubResults(Extrusion_1, [0]) @@ -107,7 +107,7 @@ model.testNbSubShapes(Extrusion_1, GeomAPI_Shape.SOLID, [1]) model.testNbSubShapes(Extrusion_1, GeomAPI_Shape.FACE, [6]) model.testResultsVolumes(Extrusion_1, [87985.85]) -ParamFrom.setValue(20) +ParamFrom.setValue(-20) model.do() model.testNbResults(Extrusion_1, 1) model.testNbSubResults(Extrusion_1, [0]) diff --git a/src/FeaturesPlugin/Test/TestExtrusion_ByFaces03.py b/src/FeaturesPlugin/Test/TestExtrusion_ByFaces03.py index 83608d6ed..af9a6c6a3 100644 --- a/src/FeaturesPlugin/Test/TestExtrusion_ByFaces03.py +++ b/src/FeaturesPlugin/Test/TestExtrusion_ByFaces03.py @@ -129,7 +129,7 @@ model.testNbSubShapes(Extrusion_1, GeomAPI_Shape.VERTEX, [44]) model.testResultsVolumes(Extrusion_1, [119535.04]) # offset "From" face -ParamFrom.setValue(-20) +ParamFrom.setValue(20) model.do() model.testNbResults(Extrusion_1, 1) model.testNbSubResults(Extrusion_1, [0]) @@ -137,7 +137,7 @@ model.testNbSubShapes(Extrusion_1, GeomAPI_Shape.SOLID, [1]) model.testNbSubShapes(Extrusion_1, GeomAPI_Shape.FACE, [5]) model.testResultsVolumes(Extrusion_1, [84126.377]) -ParamFrom.setValue(20) +ParamFrom.setValue(-20) model.do() model.testNbResults(Extrusion_1, 1) model.testNbSubResults(Extrusion_1, [0]) diff --git a/src/FeaturesPlugin/Test/TestExtrusion_ByFaces04.py b/src/FeaturesPlugin/Test/TestExtrusion_ByFaces04.py index 7e8a0eb9d..ef7c71136 100644 --- a/src/FeaturesPlugin/Test/TestExtrusion_ByFaces04.py +++ b/src/FeaturesPlugin/Test/TestExtrusion_ByFaces04.py @@ -101,7 +101,7 @@ model.testNbSubShapes(Extrusion_1, GeomAPI_Shape.VERTEX, [44]) model.testResultsVolumes(Extrusion_1, [105008.93]) # offset "From" face -ParamFrom.setValue(-20) +ParamFrom.setValue(20) model.do() model.testNbResults(Extrusion_1, 1) model.testNbSubResults(Extrusion_1, [0]) @@ -110,7 +110,7 @@ model.testNbSubShapes(Extrusion_1, GeomAPI_Shape.FACE, [5]) model.testResultsVolumes(Extrusion_1, [179594.5]) # check failure -ParamFrom.setValue(20) +ParamFrom.setValue(-20) model.do() assert(Extrusion_1.feature().error() != "") diff --git a/src/FeaturesPlugin/Test/TestExtrusion_ByFaces05.py b/src/FeaturesPlugin/Test/TestExtrusion_ByFaces05.py index fff109f06..8715c1ecb 100644 --- a/src/FeaturesPlugin/Test/TestExtrusion_ByFaces05.py +++ b/src/FeaturesPlugin/Test/TestExtrusion_ByFaces05.py @@ -134,7 +134,7 @@ model.testNbSubShapes(Extrusion_1, GeomAPI_Shape.VERTEX, [32]) model.testResultsVolumes(Extrusion_1, [7626.2279286]) # offset "From" face -ParamFrom.setValue(-20) +ParamFrom.setValue(20) model.do() model.testNbResults(Extrusion_1, 1) model.testNbSubResults(Extrusion_1, [2]) @@ -144,7 +144,7 @@ model.testNbSubShapes(Extrusion_1, GeomAPI_Shape.EDGE, [20]) model.testNbSubShapes(Extrusion_1, GeomAPI_Shape.VERTEX, [40]) model.testResultsVolumes(Extrusion_1, [21514.8965]) -ParamFrom.setValue(20) +ParamFrom.setValue(-20) model.do() model.testNbResults(Extrusion_1, 1) model.testNbSubResults(Extrusion_1, [2]) diff --git a/src/FeaturesPlugin/Test/TestExtrusion_ByFaces06.py b/src/FeaturesPlugin/Test/TestExtrusion_ByFaces06.py index 095c96796..0fd7070e7 100644 --- a/src/FeaturesPlugin/Test/TestExtrusion_ByFaces06.py +++ b/src/FeaturesPlugin/Test/TestExtrusion_ByFaces06.py @@ -92,7 +92,7 @@ model.testNbSubShapes(Extrusion_1, GeomAPI_Shape.VERTEX, [40]) model.testResultsVolumes(Extrusion_1, [31501.9671234]) # offset "From" face -ParamFrom.setValue(-20) +ParamFrom.setValue(20) model.do() model.testNbResults(Extrusion_1, 1) model.testNbSubResults(Extrusion_1, [0]) @@ -100,7 +100,7 @@ model.testNbSubShapes(Extrusion_1, GeomAPI_Shape.SOLID, [1]) model.testNbSubShapes(Extrusion_1, GeomAPI_Shape.FACE, [5]) model.testResultsVolumes(Extrusion_1, [18737.752452]) -ParamFrom.setValue(20) +ParamFrom.setValue(-20) model.do() model.testNbResults(Extrusion_1, 1) model.testNbSubResults(Extrusion_1, [0]) diff --git a/src/FeaturesPlugin/Test/TestExtrusion_ByFaces07.py b/src/FeaturesPlugin/Test/TestExtrusion_ByFaces07.py index 0318fcd13..a3bbdee05 100644 --- a/src/FeaturesPlugin/Test/TestExtrusion_ByFaces07.py +++ b/src/FeaturesPlugin/Test/TestExtrusion_ByFaces07.py @@ -120,7 +120,7 @@ model.testNbSubShapes(Extrusion_1, GeomAPI_Shape.VERTEX, [96]) model.testResultsVolumes(Extrusion_1, [57985.85]) # offset "From" face -ParamFrom.setValue(-20) +ParamFrom.setValue(20) model.do() model.testNbResults(Extrusion_1, 1) model.testNbSubResults(Extrusion_1, [2]) @@ -128,7 +128,7 @@ model.testNbSubShapes(Extrusion_1, GeomAPI_Shape.SOLID, [2]) model.testNbSubShapes(Extrusion_1, GeomAPI_Shape.FACE, [12]) model.testResultsVolumes(Extrusion_1, [37985.85]) -ParamFrom.setValue(20) +ParamFrom.setValue(-20) model.do() model.testNbResults(Extrusion_1, 1) model.testNbSubResults(Extrusion_1, [2]) diff --git a/src/FeaturesPlugin/Test/TestExtrusion_ByFaces08.py b/src/FeaturesPlugin/Test/TestExtrusion_ByFaces08.py index 18ce0b442..72726ad98 100644 --- a/src/FeaturesPlugin/Test/TestExtrusion_ByFaces08.py +++ b/src/FeaturesPlugin/Test/TestExtrusion_ByFaces08.py @@ -104,7 +104,7 @@ model.testNbSubShapes(Extrusion_1, GeomAPI_Shape.FACE, [12]) model.testResultsVolumes(Extrusion_1, [107985.85]) # offset "From" face -ParamFrom.setValue(-20) +ParamFrom.setValue(20) model.do() model.testNbResults(Extrusion_1, 1) model.testNbSubResults(Extrusion_1, [2]) @@ -112,7 +112,7 @@ model.testNbSubShapes(Extrusion_1, GeomAPI_Shape.SOLID, [2]) model.testNbSubShapes(Extrusion_1, GeomAPI_Shape.FACE, [12]) model.testResultsVolumes(Extrusion_1, [87985.85]) -ParamFrom.setValue(20) +ParamFrom.setValue(-20) model.do() model.testNbResults(Extrusion_1, 1) model.testNbSubResults(Extrusion_1, [2]) diff --git a/src/FeaturesPlugin/Test/TestExtrusion_ByFaces09.py b/src/FeaturesPlugin/Test/TestExtrusion_ByFaces09.py index da81086ad..ada092a9f 100644 --- a/src/FeaturesPlugin/Test/TestExtrusion_ByFaces09.py +++ b/src/FeaturesPlugin/Test/TestExtrusion_ByFaces09.py @@ -132,7 +132,7 @@ model.testNbSubShapes(Extrusion_1, GeomAPI_Shape.VERTEX, [68]) model.testResultsVolumes(Extrusion_1, [119535.04]) # offset "From" face -ParamFrom.setValue(-20) +ParamFrom.setValue(20) model.do() model.testNbResults(Extrusion_1, 1) model.testNbSubResults(Extrusion_1, [2]) @@ -140,7 +140,7 @@ model.testNbSubShapes(Extrusion_1, GeomAPI_Shape.SOLID, [2]) model.testNbSubShapes(Extrusion_1, GeomAPI_Shape.FACE, [9]) model.testResultsVolumes(Extrusion_1, [84126.377]) -ParamFrom.setValue(20) +ParamFrom.setValue(-20) model.do() model.testNbResults(Extrusion_1, 1) model.testNbSubResults(Extrusion_1, [2]) diff --git a/src/FeaturesPlugin/Test/TestExtrusion_ByFaces10.py b/src/FeaturesPlugin/Test/TestExtrusion_ByFaces10.py index e618ca61c..024dd08aa 100644 --- a/src/FeaturesPlugin/Test/TestExtrusion_ByFaces10.py +++ b/src/FeaturesPlugin/Test/TestExtrusion_ByFaces10.py @@ -105,7 +105,7 @@ model.testNbSubShapes(Extrusion_1, GeomAPI_Shape.VERTEX, [80]) model.testResultsVolumes(Extrusion_1, [105008.93]) # offset "From" face -ParamFrom.setValue(-20) +ParamFrom.setValue(20) model.do() model.testNbResults(Extrusion_1, 1) model.testNbSubResults(Extrusion_1, [2]) @@ -114,7 +114,7 @@ model.testNbSubShapes(Extrusion_1, GeomAPI_Shape.FACE, [10]) model.testResultsVolumes(Extrusion_1, [179594.5]) # check failure -ParamFrom.setValue(20) +ParamFrom.setValue(-20) model.do() assert(Extrusion_1.feature().error() != "") diff --git a/src/FeaturesPlugin/Test/TestExtrusion_ByFaces11.py b/src/FeaturesPlugin/Test/TestExtrusion_ByFaces11.py index f66471f5b..8156d5230 100644 --- a/src/FeaturesPlugin/Test/TestExtrusion_ByFaces11.py +++ b/src/FeaturesPlugin/Test/TestExtrusion_ByFaces11.py @@ -139,7 +139,7 @@ model.testNbSubShapes(Extrusion_1, GeomAPI_Shape.VERTEX, [128]) model.testResultsVolumes(Extrusion_1, [7626.2279286]) # offset "From" face -ParamFrom.setValue(-20) +ParamFrom.setValue(20) model.do() model.testNbResults(Extrusion_1, 1) model.testNbSubResults(Extrusion_1, [2]) @@ -149,7 +149,7 @@ model.testNbSubShapes(Extrusion_1, GeomAPI_Shape.EDGE, [68]) model.testNbSubShapes(Extrusion_1, GeomAPI_Shape.VERTEX, [136]) model.testResultsVolumes(Extrusion_1, [21514.8965]) -ParamFrom.setValue(20) +ParamFrom.setValue(-20) model.do() model.testNbResults(Extrusion_1, 1) model.testNbSubResults(Extrusion_1, [2]) diff --git a/src/FeaturesPlugin/Test/TestExtrusion_ByFaces12.py b/src/FeaturesPlugin/Test/TestExtrusion_ByFaces12.py index 5473797ac..7cf8233a6 100644 --- a/src/FeaturesPlugin/Test/TestExtrusion_ByFaces12.py +++ b/src/FeaturesPlugin/Test/TestExtrusion_ByFaces12.py @@ -97,7 +97,7 @@ model.testNbSubShapes(Extrusion_1, GeomAPI_Shape.VERTEX, [64]) model.testResultsVolumes(Extrusion_1, [31501.9671234]) # offset "From" face -ParamFrom.setValue(-20) +ParamFrom.setValue(20) model.do() model.testNbResults(Extrusion_1, 1) model.testNbSubResults(Extrusion_1, [2]) @@ -105,7 +105,7 @@ model.testNbSubShapes(Extrusion_1, GeomAPI_Shape.SOLID, [2]) model.testNbSubShapes(Extrusion_1, GeomAPI_Shape.FACE, [9]) model.testResultsVolumes(Extrusion_1, [18737.752452]) -ParamFrom.setValue(20) +ParamFrom.setValue(-20) model.do() model.testNbResults(Extrusion_1, 1) model.testNbSubResults(Extrusion_1, [2]) diff --git a/src/FeaturesPlugin/Test/TestExtrusion_ByFaces13.py b/src/FeaturesPlugin/Test/TestExtrusion_ByFaces13.py index 710db14d5..3575f1bb7 100644 --- a/src/FeaturesPlugin/Test/TestExtrusion_ByFaces13.py +++ b/src/FeaturesPlugin/Test/TestExtrusion_ByFaces13.py @@ -101,7 +101,7 @@ model.testNbSubShapes(Extrusion_1, GeomAPI_Shape.VERTEX, [8, 8, 8, 8]) model.testResultsVolumes(Extrusion_1, [2899.292521, 1039.2304845, 2899.292521, 1131.3708499]) # offset "From" face -ParamFrom.setValue(-20) +ParamFrom.setValue(20) model.do() model.testNbResults(Extrusion_1, 4) model.testNbSubResults(Extrusion_1, [0, 0, 0, 0]) @@ -111,7 +111,7 @@ model.testNbSubShapes(Extrusion_1, GeomAPI_Shape.EDGE, [4, 4, 4, 4]) model.testNbSubShapes(Extrusion_1, GeomAPI_Shape.VERTEX, [8, 8, 8, 8]) model.testResultsVolumes(Extrusion_1, [3899.292521, 1439.2304845, 3899.292521, 1531.3708499]) -ParamFrom.setValue(20) +ParamFrom.setValue(-20) model.do() model.testNbResults(Extrusion_1, 4) model.testNbSubResults(Extrusion_1, [0, 0, 0, 0]) diff --git a/src/FeaturesPlugin/Test/TestExtrusion_ByFaces14.py b/src/FeaturesPlugin/Test/TestExtrusion_ByFaces14.py index 7f8348c69..21789d9a8 100644 --- a/src/FeaturesPlugin/Test/TestExtrusion_ByFaces14.py +++ b/src/FeaturesPlugin/Test/TestExtrusion_ByFaces14.py @@ -102,7 +102,7 @@ model.testNbSubShapes(Extrusion_1, GeomAPI_Shape.VERTEX, [8, 8, 8, 8]) model.testResultsVolumes(Extrusion_1, [5399.2925211, 2039.2304845, 5399.2925212, 2131.37085]) # offset "From" face -ParamFrom.setValue(-20) +ParamFrom.setValue(20) model.do() model.testNbResults(Extrusion_1, 4) model.testNbSubResults(Extrusion_1, [0, 0, 0, 0]) @@ -112,7 +112,7 @@ model.testNbSubShapes(Extrusion_1, GeomAPI_Shape.EDGE, [4, 4, 4, 4]) model.testNbSubShapes(Extrusion_1, GeomAPI_Shape.VERTEX, [8, 8, 8, 8]) model.testResultsVolumes(Extrusion_1, [6399.2925211, 2439.2304845, 6399.2925212, 2531.37085]) -ParamFrom.setValue(20) +ParamFrom.setValue(-20) model.do() model.testNbResults(Extrusion_1, 4) model.testNbSubResults(Extrusion_1, [0, 0, 0, 0]) diff --git a/src/FeaturesPlugin/Test/TestExtrusion_ByFaces15.py b/src/FeaturesPlugin/Test/TestExtrusion_ByFaces15.py index a65ebacda..edb34500c 100644 --- a/src/FeaturesPlugin/Test/TestExtrusion_ByFaces15.py +++ b/src/FeaturesPlugin/Test/TestExtrusion_ByFaces15.py @@ -138,7 +138,7 @@ model.testNbSubShapes(Extrusion_1, GeomAPI_Shape.VERTEX, [8, 8, 12]) model.testResultsVolumes(Extrusion_1, [2295.81450653, 2295.81450653, 5527.16645028]) # offset "From" face -ParamFrom.setValue(-20) +ParamFrom.setValue(20) model.do() model.testNbResults(Extrusion_1, 3) model.testNbSubResults(Extrusion_1, [0, 0, 0]) @@ -148,7 +148,7 @@ model.testNbSubShapes(Extrusion_1, GeomAPI_Shape.EDGE, [4, 4, 6]) model.testNbSubShapes(Extrusion_1, GeomAPI_Shape.VERTEX, [8, 8, 12]) model.testResultsVolumes(Extrusion_1, [1595.81450653, 1595.81450653, 3814.47306888]) -ParamFrom.setValue(20) +ParamFrom.setValue(-20) model.do() model.testNbResults(Extrusion_1, 3) model.testNbSubResults(Extrusion_1, [0, 0, 0]) diff --git a/src/FeaturesPlugin/Test/TestExtrusion_ByFaces16.py b/src/FeaturesPlugin/Test/TestExtrusion_ByFaces16.py index bd18ce050..8436dbc9d 100644 --- a/src/FeaturesPlugin/Test/TestExtrusion_ByFaces16.py +++ b/src/FeaturesPlugin/Test/TestExtrusion_ByFaces16.py @@ -104,7 +104,7 @@ model.testNbSubShapes(Extrusion_1, GeomAPI_Shape.VERTEX, [8, 8, 12]) model.testResultsVolumes(Extrusion_1, [1708.843326299, 1708.843325768, 1895.559443038]) # offset "From" face -ParamFrom.setValue(-20) +ParamFrom.setValue(20) model.do() model.testNbResults(Extrusion_1, 3) model.testNbSubResults(Extrusion_1, [0, 0, 0]) @@ -115,12 +115,12 @@ model.testNbSubShapes(Extrusion_1, GeomAPI_Shape.VERTEX, [8, 8, 12]) model.testResultsVolumes(Extrusion_1, [2915.069101129, 2915.069100598, 4138.27332218]) # check failure -ParamFrom.setValue(20) +ParamFrom.setValue(-20) model.do() assert(Extrusion_1.feature().error() != "") # revert failure -ParamFrom.setValue(10) +ParamFrom.setValue(-10) model.do() model.testNbResults(Extrusion_1, 3) model.testNbSubResults(Extrusion_1, [0, 0, 0]) diff --git a/src/FeaturesPlugin/Test/TestExtrusion_ByFaces17.py b/src/FeaturesPlugin/Test/TestExtrusion_ByFaces17.py index fd8effa21..3ec3accb8 100644 --- a/src/FeaturesPlugin/Test/TestExtrusion_ByFaces17.py +++ b/src/FeaturesPlugin/Test/TestExtrusion_ByFaces17.py @@ -135,7 +135,7 @@ model.testNbSubShapes(Extrusion_1, GeomAPI_Shape.VERTEX, [20]) model.testResultsVolumes(Extrusion_1, [1504.36096473]) # offset "From" face -ParamFrom.setValue(-20) +ParamFrom.setValue(20) model.do() model.testNbResults(Extrusion_1, 1) model.testNbSubResults(Extrusion_1, [2]) @@ -145,7 +145,7 @@ model.testNbSubShapes(Extrusion_1, GeomAPI_Shape.EDGE, [12]) model.testNbSubShapes(Extrusion_1, GeomAPI_Shape.VERTEX, [24]) model.testResultsVolumes(Extrusion_1, [4336.142699]) -ParamFrom.setValue(20) +ParamFrom.setValue(-20) model.do() model.testNbResults(Extrusion_1, 1) model.testNbSubResults(Extrusion_1, [2]) diff --git a/src/FeaturesPlugin/Test/TestExtrusion_ByFaces18.py b/src/FeaturesPlugin/Test/TestExtrusion_ByFaces18.py index 2edfe7af7..8e86fe859 100644 --- a/src/FeaturesPlugin/Test/TestExtrusion_ByFaces18.py +++ b/src/FeaturesPlugin/Test/TestExtrusion_ByFaces18.py @@ -97,7 +97,7 @@ model.testNbSubShapes(Extrusion_1, GeomAPI_Shape.VERTEX, [8, 8, 10]) model.testResultsVolumes(Extrusion_1, [1314.8586588, 1022.169915122, 2601.32913399]) # offset "From" face -ParamFrom.setValue(-20) +ParamFrom.setValue(20) model.do() model.testNbResults(Extrusion_1, 3) model.testNbSubResults(Extrusion_1, [0, 0, 0]) @@ -105,7 +105,7 @@ model.testNbSubShapes(Extrusion_1, GeomAPI_Shape.SOLID, [0, 0, 0]) model.testNbSubShapes(Extrusion_1, GeomAPI_Shape.FACE, [1, 1, 1]) model.testResultsVolumes(Extrusion_1, [825.71966141, 533.030917699, 1551.6191757579]) -ParamFrom.setValue(20) +ParamFrom.setValue(-20) model.do() model.testNbResults(Extrusion_1, 3) model.testNbSubResults(Extrusion_1, [0, 0, 0]) diff --git a/src/FeaturesPlugin/Test/TestExtrusion_ByFaces19.py b/src/FeaturesPlugin/Test/TestExtrusion_ByFaces19.py index 68584bc5c..9abd1ca35 100644 --- a/src/FeaturesPlugin/Test/TestExtrusion_ByFaces19.py +++ b/src/FeaturesPlugin/Test/TestExtrusion_ByFaces19.py @@ -117,7 +117,7 @@ model.testNbSubShapes(Extrusion_1, GeomAPI_Shape.VERTEX, [32]) model.testResultsVolumes(Extrusion_1, [7969.186376787]) # offset "From" face -ParamFrom.setValue(-20) +ParamFrom.setValue(20) model.do() model.testNbResults(Extrusion_1, 1) model.testNbSubResults(Extrusion_1, [0]) @@ -127,7 +127,7 @@ model.testNbSubShapes(Extrusion_1, GeomAPI_Shape.EDGE, [16]) model.testNbSubShapes(Extrusion_1, GeomAPI_Shape.VERTEX, [32]) model.testResultsVolumes(Extrusion_1, [10769.186376787]) -ParamFrom.setValue(20) +ParamFrom.setValue(-20) model.do() model.testNbResults(Extrusion_1, 1) model.testNbSubResults(Extrusion_1, [0]) diff --git a/src/FeaturesPlugin/extrusioncut_widget.xml b/src/FeaturesPlugin/extrusioncut_widget.xml index 96079ccbd..dc6c9539e 100644 --- a/src/FeaturesPlugin/extrusioncut_widget.xml +++ b/src/FeaturesPlugin/extrusioncut_widget.xml @@ -49,16 +49,16 @@ - + - + - + - + - + - + #include #include +#include +#include #include #include #include @@ -203,20 +205,35 @@ std::shared_ptr GeomAPI_Face::getPlane() const Handle(Geom_Surface) aSurf = BRep_Tool::Surface(aFace); if (aSurf.IsNull()) return aResult; // no surface - GeomLib_IsPlanarSurface isPlanar(aSurf); - if(!isPlanar.IsPlanar()) { - return aResult; + GeomLib_IsPlanarSurface isPlanarSurf(aSurf); + gp_Pln aPln; + bool isPlanar = false; + if (isPlanarSurf.IsPlanar()) { + aPln = isPlanarSurf.Plan(); + isPlanar = true; } - gp_Pln aPln = isPlanar.Plan(); - double aA, aB, aC, aD; - aPln.Coefficients(aA, aB, aC, aD); - if (aFace.Orientation() == TopAbs_REVERSED) { - aA = -aA; - aB = -aB; - aC = -aC; - aD = -aD; + else if (aSurf->IsKind(STANDARD_TYPE(Geom_OffsetSurface))) { + Handle(Geom_OffsetSurface) anOffsetSurf = Handle(Geom_OffsetSurface)::DownCast(aSurf); + Handle(Geom_Surface) aBasisSurf = anOffsetSurf->BasisSurface(); + if (aBasisSurf->IsKind(STANDARD_TYPE(Geom_Plane))) { + aPln = Handle(Geom_Plane)::DownCast(aBasisSurf)->Pln(); + gp_Vec aTranslation(aPln.Axis().Direction().XYZ() * anOffsetSurf->Offset()); + aPln.Translate(aTranslation); + isPlanar = true; + } + } + + if (isPlanar) { + double aA, aB, aC, aD; + aPln.Coefficients(aA, aB, aC, aD); + if (aFace.Orientation() == TopAbs_REVERSED) { + aA = -aA; + aB = -aB; + aC = -aC; + aD = -aD; + } + aResult = std::shared_ptr(new GeomAPI_Pln(aA, aB, aC, aD)); } - aResult = std::shared_ptr(new GeomAPI_Pln(aA, aB, aC, aD)); return aResult; } diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_Prism.cpp b/src/GeomAlgoAPI/GeomAlgoAPI_Prism.cpp index cc1ff67b2..a4b9d1b3f 100644 --- a/src/GeomAlgoAPI/GeomAlgoAPI_Prism.cpp +++ b/src/GeomAlgoAPI/GeomAlgoAPI_Prism.cpp @@ -537,7 +537,7 @@ void GeomAlgoAPI_Prism::buildByFaces(const GeomShapePtr theBaseShape gp_Vec anExtVec = theDirection->impl(); // Moving prism bounding faces according to "from" and "to" sizes. - GeomShapePtr aBoundingFromShape = buildOffset(theFromShape, theFromSize, theDirection, *this); + GeomShapePtr aBoundingFromShape = buildOffset(theFromShape, -theFromSize, theDirection, *this); GeomShapePtr aBoundingToShape = buildOffset(theToShape, theToSize, theDirection, *this); // Bounding box for shapes used in prism building.