X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2FSketchPlugin%2FTest%2FTestSplit.py;h=f2880d40320bf2a5a227fc0fdd5bea9fb55da7a5;hb=50a8df0c6a66da8067b16155e5ae39f8f26a7ebc;hp=6cc31d3a0583a1d0d4b4f7d19b3477ded90918b4;hpb=7400411d1b1805f3a86440d5dd580a212a6a13e4;p=modules%2Fshaper.git diff --git a/src/SketchPlugin/Test/TestSplit.py b/src/SketchPlugin/Test/TestSplit.py index 6cc31d3a0..f2880d403 100644 --- a/src/SketchPlugin/Test/TestSplit.py +++ b/src/SketchPlugin/Test/TestSplit.py @@ -1,6 +1,27 @@ -import model +# Copyright (C) 2014-2020 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 from ModelAPI import * +from ModelGeomAlgo import ModelGeomAlgo_Point2D +from salome.shaper import geom SketchPointId = 'SketchPoint' SketchLineId = 'SketchLine' @@ -18,8 +39,9 @@ Part_1_doc = Part_1.document() Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOY")) SketchLine_1 = Sketch_1.addLine(0, 50, 100, 50) SketchPoint_1 = Sketch_1.addPoint(50, 50) -SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchPoint_1.coordinates(), SketchLine_1.result()[0]) -Sketch_1.addSplit(SketchLine_1, SketchPoint_1.coordinates(), SketchLine_1.endPoint()) +SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchPoint_1.coordinates(), SketchLine_1.result()) +GeomPoint = geom.Pnt2d(20, 50) +Sketch_1.addSplit(SketchLine_1, GeomPoint) model.do() Sketch_1_feature = featureToCompositeFeature(Sketch_1.feature()) @@ -29,8 +51,8 @@ for index in range(Sketch_1_feature.numberOfSubs()): assert(idList.count(SketchLineId) == 2) assert(idList.count(SketchPointId) == 1) -assert(idList.count(SketchConstraintCoincidenceId) == 2) -assert(idList.count(SketchConstraintParallelId) == 1) +assert(idList.count(SketchConstraintCoincidenceId) == 3) +assert(idList.count(SketchConstraintParallelId) == 0) # Test end # Test split on line with two points @@ -38,9 +60,10 @@ Sketch_2 = model.addSketch(Part_1_doc, model.defaultPlane("XOY")) SketchLine_2_1 = Sketch_2.addLine(0, 50, 100, 50) SketchPoint_2_1 = Sketch_2.addPoint(25, 50) SketchPoint_2_2 = Sketch_2.addPoint(75, 50) -SketchConstraintCoincidence_2_1 = Sketch_2.setCoincident(SketchPoint_2_1.coordinates(), SketchLine_2_1.result()[0]) -SketchConstraintCoincidence_2_2 = Sketch_2.setCoincident(SketchPoint_2_2.coordinates(), SketchLine_2_1.result()[0]) -Sketch_2.addSplit(SketchLine_2_1, SketchPoint_2_1.coordinates(), SketchPoint_2_2.coordinates()) +SketchConstraintCoincidence_2_1 = Sketch_2.setCoincident(SketchPoint_2_1.coordinates(), SketchLine_2_1.result()) +SketchConstraintCoincidence_2_2 = Sketch_2.setCoincident(SketchPoint_2_2.coordinates(), SketchLine_2_1.result()) +GeomPoint = geom.Pnt2d(40, 50) +Sketch_2.addSplit(SketchLine_2_1, GeomPoint) model.do() Sketch_2_feature = featureToCompositeFeature(Sketch_2.feature()) @@ -50,8 +73,8 @@ for index in range(Sketch_2_feature.numberOfSubs()): assert(idList.count(SketchLineId) == 3) assert(idList.count(SketchPointId) == 2) -assert(idList.count(SketchConstraintCoincidenceId) == 4) -assert(idList.count(SketchConstraintParallelId) == 2) +assert(idList.count(SketchConstraintCoincidenceId) == 6) +assert(idList.count(SketchConstraintParallelId) == 0) # Test end # Test split on circle with two points @@ -59,9 +82,10 @@ Sketch_3 = model.addSketch(Part_1_doc, model.defaultPlane("XOY")) SketchCircle_3_1 = Sketch_3.addCircle(50, 50, 50) SketchPoint_3_1 = Sketch_3.addPoint(50, 0) SketchPoint_3_2 = Sketch_3.addPoint(50, 100) -SketchConstraintCoincidence_3_1 = Sketch_3.setCoincident(SketchPoint_3_1.coordinates(), SketchCircle_3_1.result()[0]) -SketchConstraintCoincidence_3_2 = Sketch_3.setCoincident(SketchPoint_3_2.coordinates(), SketchCircle_3_1.result()[0]) -Sketch_3.addSplit(SketchCircle_3_1, SketchPoint_3_1.coordinates(), SketchPoint_3_2.coordinates()) +SketchConstraintCoincidence_3_1 = Sketch_3.setCoincident(SketchPoint_3_1.coordinates(), SketchCircle_3_1.results()[1]) +SketchConstraintCoincidence_3_2 = Sketch_3.setCoincident(SketchPoint_3_2.coordinates(), SketchCircle_3_1.results()[1]) +GeomPoint = geom.Pnt2d(0, 50) +Sketch_3.addSplit(SketchCircle_3_1, GeomPoint) model.do() Sketch_3_feature = featureToCompositeFeature(Sketch_3.feature()) @@ -71,19 +95,24 @@ for index in range(Sketch_3_feature.numberOfSubs()): assert(idList.count(SketchArcId) == 2) assert(idList.count(SketchPointId) == 2) -assert(idList.count(SketchConstraintCoincidenceId) == 2) -assert(idList.count(SketchConstraintTangentId) == 1) +assert(idList.count(SketchConstraintCoincidenceId) == 6) +assert(idList.count(SketchConstraintTangentId) == 0) # Test end # Test split on arc with one point Sketch_4 = model.addSketch(Part_1_doc, model.defaultPlane("XOY")) -SketchArc_4_1 = Sketch_4.addArc(50, 50, 0, 50, 100, 50, True) +SketchArc_4_1 = Sketch_4.addArc(50, 50, 50, 0, 0, 50, False) Sketch_4.setFixed(SketchArc_4_1.startPoint()) Sketch_4.setFixed(SketchArc_4_1.endPoint()) Sketch_4.setRadius(SketchArc_4_1, 50) SketchPoint_4_1 = Sketch_4.addPoint(50, 100) -SketchConstraintCoincidence_4_1 = Sketch_4.setCoincident(SketchPoint_4_1.coordinates(), SketchArc_4_1.result()[0]) -Sketch_4.addSplit(SketchArc_4_1, SketchPoint_4_1.coordinates(), SketchArc_4_1.endPoint()) +SketchConstraintCoincidence_4_1 = Sketch_4.setCoincident(SketchPoint_4_1.coordinates(), SketchArc_4_1.results()[1]) +# prepare point on circle +SketchLine_intersecting = Sketch_4.addLine(0, 100, 50, 50) +Intersection_Point = ModelGeomAlgo_Point2D.getSetOfPntIntersectedShape(SketchArc_4_1.feature(), FeatureList([SketchLine_intersecting.feature()])) +removeFeaturesAndReferences(FeatureSet([SketchLine_intersecting.feature()])) +Intersection_GeomPoint = Intersection_Point[0] +Sketch_4.addSplit(SketchArc_4_1, Sketch_1.to2D(Intersection_GeomPoint)) model.do() Sketch_4_feature = featureToCompositeFeature(Sketch_4.feature()) @@ -93,22 +122,24 @@ for index in range(Sketch_4_feature.numberOfSubs()): assert(idList.count(SketchArcId) == 2) assert(idList.count(SketchPointId) == 1) -assert(idList.count(SketchConstraintCoincidenceId) == 2) -assert(idList.count(SketchConstraintEqualId) == 1) -assert(idList.count(SketchConstraintTangentId) == 1) +assert(idList.count(SketchConstraintCoincidenceId) == 3) +assert(idList.count(SketchConstraintEqualId) == 0) +assert(idList.count(SketchConstraintTangentId) == 0) # Test end # Test split on arc with two points Sketch_5 = model.addSketch(Part_1_doc, model.defaultPlane("XOY")) -SketchArc_5_1 = Sketch_5.addArc(50, 50, 0, 50, 100, 50, True) +SketchArc_5_1 = Sketch_5.addArc(50, 50, 93.30127018922, 75, 0, 50, False) Sketch_5.setFixed(SketchArc_5_1.startPoint()) Sketch_5.setFixed(SketchArc_5_1.endPoint()) Sketch_5.setRadius(SketchArc_5_1, 50) -SketchPoint_5_1 = Sketch_5.addPoint(25, 93.301270189222) -SketchPoint_5_2 = Sketch_5.addPoint(75, 93.301270189222) -SketchConstraintCoincidence_5_1 = Sketch_5.setCoincident(SketchPoint_5_1.coordinates(), SketchArc_5_1.result()[0]) -SketchConstraintCoincidence_5_1 = Sketch_5.setCoincident(SketchPoint_5_2.coordinates(), SketchArc_5_1.result()[0]) -Sketch_5.addSplit(SketchArc_5_1, SketchPoint_5_1.coordinates(), SketchPoint_5_2.coordinates()) +SketchLine_5_1 = Sketch_5.addLine(25, 93.301270189222, 75, 93.301270189222) +SketchConstraintCoincidence_5_1 = Sketch_5.setCoincident(SketchLine_5_1.startPoint(), SketchArc_5_1.results()[1]) +SketchConstraintCoincidence_5_2 = Sketch_5.setCoincident(SketchLine_5_1.endPoint(), SketchArc_5_1.results()[1]) +SketchConstraintHorizontal_5_1 = Sketch_5.setHorizontal(SketchLine_5_1.result()) +SketchConstraintLength_5_1 = Sketch_5.setLength(SketchLine_5_1.result(), 50) +GeomPoint = geom.Pnt2d(50, 100) +Sketch_5.addSplit(SketchArc_5_1, GeomPoint) model.do() Sketch_5_feature = featureToCompositeFeature(Sketch_5.feature()) @@ -117,10 +148,10 @@ for index in range(Sketch_5_feature.numberOfSubs()): idList.append(Sketch_5_feature.subFeature(index).getKind()) assert(idList.count(SketchArcId) == 3) -assert(idList.count(SketchPointId) == 2) -assert(idList.count(SketchConstraintCoincidenceId) == 4) -assert(idList.count(SketchConstraintEqualId) == 2) -assert(idList.count(SketchConstraintTangentId) == 2) +assert(idList.count(SketchPointId) == 0) +assert(idList.count(SketchConstraintCoincidenceId) == 6) +assert(idList.count(SketchConstraintEqualId) == 0) +assert(idList.count(SketchConstraintTangentId) == 0) # Test end model.end()