From: Clarisse Genrault Date: Thu, 23 Mar 2017 09:10:57 +0000 (+0100) Subject: Add tests. X-Git-Tag: V_2.7.0~199 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=4a80bb33cc89d29a22866dcf7e9b94b885cc6cfb;p=modules%2Fshaper.git Add tests. --- diff --git a/test.API/SHAPER/GDML/TestAPI_ConeSegment.py b/test.API/SHAPER/GDML/TestAPI_ConeSegment.py index 219cb9e09..0d52f56fe 100644 --- a/test.API/SHAPER/GDML/TestAPI_ConeSegment.py +++ b/test.API/SHAPER/GDML/TestAPI_ConeSegment.py @@ -1,7 +1,9 @@ -""" -Test case for GDML Cone Segment feature. -Written on Shape API. -""" +# Copyright (C) 2014-2016 CEA/DEN, EDF R&D + +# File: TestAPI_Box.py +# Created: 29 Nov 2016 +# Author: Clarisse Genrault (CEA) + from GeomAlgoAPI import GeomAlgoAPI_ShapeAPI as shaperpy from GeomAlgoAPI import GeomAlgoAPI_Exception as myExcept from GeomAPI import GeomAPI_Pnt as pnt @@ -52,4 +54,4 @@ except myExcept,ec: try : CS15 = shaperpy.makeConeSegment(7.,11.,5.,8.,12.,45.,450.) except myExcept,ec: - assert(ec.what() == "Cone Segment builder :: deltaphi is larger than 360 degree.") + assert(ec.what() == "Cone Segment builder :: deltaphi is larger than 360 degree.") \ No newline at end of file diff --git a/test.API/SHAPER/GDML/TestConeSegment.py b/test.API/SHAPER/GDML/TestConeSegment.py index f96a7574d..dfdb96d0d 100644 --- a/test.API/SHAPER/GDML/TestConeSegment.py +++ b/test.API/SHAPER/GDML/TestConeSegment.py @@ -18,7 +18,6 @@ model.addParameter(Part_1_doc, "z", "12") model.addParameter(Part_1_doc, "startphi", "0") model.addParameter(Part_1_doc, "deltaphi", "270") -# Tests CS1 = model.addConeSegment(Part_1_doc, 7, 11, 5, 8, 12, 0 , 270) CS2 = model.addConeSegment(Part_1_doc, 5, 10, 7, 15, 15, 45 , 180) CS3 = model.addConeSegment(Part_1_doc, 5, 10, 7, 15, 15, -45 , 180) diff --git a/test.API/SHAPER/Primitives/TestAPI_Box.py b/test.API/SHAPER/Primitives/TestAPI_Box.py index 5c73e24e5..26e6bb298 100644 --- a/test.API/SHAPER/Primitives/TestAPI_Box.py +++ b/test.API/SHAPER/Primitives/TestAPI_Box.py @@ -1,7 +1,9 @@ -""" -Test case for Primitive Box feature. -Written on Shape API. -""" +# Copyright (C) 2014-2016 CEA/DEN, EDF R&D + +# File: TestAPI_Box.py +# Created: 16 Sept 2016 +# Author: Clarisse Genrault (CEA) + from GeomAlgoAPI import GeomAlgoAPI_ShapeAPI as shaperpy from GeomAlgoAPI import GeomAlgoAPI_Exception as myExcept from GeomAPI import GeomAPI_Pnt as pnt @@ -11,37 +13,31 @@ Box_1 = shaperpy.makeBox(10.,10.,10.) try : Box_2 = shaperpy.makeBox(0.,10.,10.) - except myExcept,ec: assert(ec.what() == "Box builder with dimensions :: Dx is null or negative.") try : Box_3 = shaperpy.makeBox(10.,0.,10.) - except myExcept,ec: assert(ec.what() == "Box builder with dimensions :: Dy is null or negative.") try : Box_4 = shaperpy.makeBox(10.,10.,0.) - except myExcept,ec: assert(ec.what() == "Box builder with dimensions :: Dz is null or negative.") try : Box_5 = shaperpy.makeBox(-10.,10.,10.) - except myExcept,ec: assert(ec.what() == "Box builder with dimensions :: Dx is null or negative.") try : Box_6 = shaperpy.makeBox(10.,-10.,10.) - except myExcept,ec: assert(ec.what() == "Box builder with dimensions :: Dy is null or negative.") try : Box_7 = shaperpy.makeBox(10.,10.,-10.) - except myExcept,ec: assert(ec.what() == "Box builder with dimensions :: Dz is null or negative.") @@ -52,40 +48,33 @@ Box_8 = shaperpy.makeBox(pnt1,pnt2) try : Box_9 = shaperpy.makeBox(pnt1,pnt1) - except myExcept,ec: assert(ec.what() == "Box builder with points :: the distance between the two points is null.") try : pnt3 = pnt(0.,50.,50.) Box_10 = shaperpy.makeBox(pnt1,pnt3) - except myExcept,ec: assert(ec.what() == "Box builder with points :: the points belong both to one of the OXY, OYZ or OZX planes.") try : pnt4 = pnt(50.,0.,50.) Box_11 = shaperpy.makeBox(pnt1,pnt4) - except myExcept,ec: assert(ec.what() == "Box builder with points :: the points belong both to one of the OXY, OYZ or OZX planes.") try : pnt5 = pnt(50.,50.,0.) Box_12 = shaperpy.makeBox(pnt1,pnt5) - except myExcept,ec: assert(ec.what() == "Box builder with points :: the points belong both to one of the OXY, OYZ or OZX planes.") try : Box_13 = shaperpy.makeBox(None, pnt2) - except myExcept,ec: assert(ec.what() == "Box builder with points :: the first point is not valid.") try : Box_14 = shaperpy.makeBox(pnt2, None) - except myExcept,ec: - assert(ec.what() == "Box builder with points :: the second point is not valid.") - + assert(ec.what() == "Box builder with points :: the second point is not valid.") \ No newline at end of file diff --git a/test.API/SHAPER/Primitives/TestAPI_Cylinder.py b/test.API/SHAPER/Primitives/TestAPI_Cylinder.py index 50a4b877d..fa01d3061 100644 --- a/test.API/SHAPER/Primitives/TestAPI_Cylinder.py +++ b/test.API/SHAPER/Primitives/TestAPI_Cylinder.py @@ -8,34 +8,104 @@ from GeomAlgoAPI import GeomAlgoAPI_ShapeAPI as shaperpy from GeomAlgoAPI import GeomAlgoAPI_Exception as myExcept from GeomAlgoAPI import GeomAlgoAPI_EdgeBuilder as edgeBuilder from GeomAPI import GeomAPI_Pnt as pnt +from GeomAPI import GeomAPI_Ax1 as axis +from GeomAPI import GeomAPI_Dir as direction -aPoint = pnt(10.,5.,0.) -anEdge = edgeBuilder.line(1.,0.,0.) +# Points +pnt1 = pnt(0., 0., 0.) +pnt2 = pnt(10., 10., 10.) -# Create a cylinder -try : - cylinder1 = shaperpy.makeCylinder(5., 20.) - +# Axis +yDir = direction(0.,10.,0.) +ax1 = axis(pnt1, yDir) + +# Edges +edgx = edgeBuilder.line(1., 0., 0.) +edgy = edgeBuilder.line(0., 1., 0.) +edgz = edgeBuilder.line(0., 0., 1.) +edg1 = edgeBuilder.line(0., 10., 0.) +edgaxis = edgeBuilder.line(ax1.dir().x(), ax1.dir().y(), ax1.dir().z()) + +Cylinder_1 = shaperpy.makeCylinder(5., 10.) +Cylinder_2 = shaperpy.makeCylinder(pnt2, edgx, 5., 10.) +Cylinder_3 = shaperpy.makeCylinder(pnt2, edg1, 7., 12.) + +try: + Cylinder_4 = shaperpy.makeCylinder(0., 10.) +except myExcept,ec: + assert(ec.what() == "Cylinder builder :: radius is negative or null.") + +try: + Cylinder_5 = shaperpy.makeCylinder(-5., 10.) +except myExcept,ec: + assert(ec.what() == "Cylinder builder :: radius is negative or null.") + +try: + Cylinder_6 = shaperpy.makeCylinder(5., 0.) +except myExcept,ec: + assert(ec.what() == "Cylinder builder :: height is negative or null.") + +try: + Cylinder_7 = shaperpy.makeCylinder(5., -10.) +except myExcept,ec: + assert(ec.what() == "Cylinder builder :: height is negative or null.") + +try: + Cylinder_8 = shaperpy.makeCylinder(None, edgz, 5., 10.) +except myExcept,ec: + assert(ec.what() == "Cylinder builder :: the base point is not valid.") + +try: + Cylinder_9 = shaperpy.makeCylinder(pnt1, None, 5., 10.) +except myExcept,ec: + assert(ec.what() == "Cylinder builder :: the axis is not valid.") + +Cylinder_14 = shaperpy.makeCylinder(5., 10., 45.) +Cylinder_15 = shaperpy.makeCylinder(pnt2, edgx, 5., 10., 90.) +Cylinder_16 = shaperpy.makeCylinder(pnt2, edgaxis, 7., 12., 120.) +Cylinder_17 = shaperpy.makeCylinder(pnt2, edgy, 5., 10., 360.) + +try: + Cylinder_18 = shaperpy.makeCylinder(0., 10., 45.) +except myExcept,ec: + assert(ec.what() == "Cylinder builder :: radius is negative or null.") + +try: + Cylinder_19 = shaperpy.makeCylinder(-5., 10., 45.) +except myExcept,ec: + assert(ec.what() == "Cylinder builder :: radius is negative or null.") + +try: + Cylinder_20 = shaperpy.makeCylinder(5., 0., 45.) +except myExcept,ec: + assert(ec.what() == "Cylinder builder :: height is negative or null.") + +try: + Cylinder_21 = shaperpy.makeCylinder(5., -10., 45.) +except myExcept,ec: + assert(ec.what() == "Cylinder builder :: height is negative or null.") + +try: + Cylinder_22 = shaperpy.makeCylinder(5., 10., 0.) except myExcept,ec: - print ec.what() + assert(ec.what() == "Cylinder builder :: angle is negative or null.") -# Create a cylinder -try : - cylinder2 = shaperpy.makeCylinder(5., 20., 100.) - +try: + Cylinder_23 = shaperpy.makeCylinder(5., 10., -45.) except myExcept,ec: - print ec.what() - -# Create a cylinder -try : - cylinder3 = shaperpy.makeCylinder(aPoint, anEdge, 5., 20.) - + assert(ec.what() == "Cylinder builder :: angle is negative or null.") + +try: + Cylinder_24 = shaperpy.makeCylinder(5., 10., 450.) except myExcept,ec: - print ec.what() - -# Create a cylinder -try : - cylinder4 = shaperpy.makeCylinder(aPoint, anEdge, 5., 20., 180.) - + assert(ec.what() == "Cylinder builder :: angle greater than 360 degrees.") + +try: + Cylinder_25 = shaperpy.makeCylinder(None, edgz, 5., 10., 90.) +except myExcept,ec: + assert(ec.what() == "Cylinder builder :: the base point is not valid.") + +try: + Cylinder_26 = shaperpy.makeCylinder(pnt1, None, 5., 10., 90.) except myExcept,ec: - print ec.what() \ No newline at end of file + assert(ec.what() == "Cylinder builder :: the axis is not valid.") \ No newline at end of file diff --git a/test.API/SHAPER/Primitives/TestBox.py b/test.API/SHAPER/Primitives/TestBox.py index 5fc71ca16..c9ef57584 100644 --- a/test.API/SHAPER/Primitives/TestBox.py +++ b/test.API/SHAPER/Primitives/TestBox.py @@ -43,8 +43,8 @@ Extrusion_2 = model.addExtrusion(Part_1_doc, [model.selection("COMPOUND", "Sketc # Parameters model.addParameter(Part_1_doc, "dx", "10") -model.addParameter(Part_1_doc, "dy", "10") -model.addParameter(Part_1_doc, "dz", "10") +model.addParameter(Part_1_doc, "dy", "25") +model.addParameter(Part_1_doc, "dz", "15") # Tests Box_1 = model.addBox(Part_1_doc, 10, 10, 10) diff --git a/test.API/SHAPER/Primitives/TestCylinder.py b/test.API/SHAPER/Primitives/TestCylinder.py index 38e6d260b..b1afa6e61 100644 --- a/test.API/SHAPER/Primitives/TestCylinder.py +++ b/test.API/SHAPER/Primitives/TestCylinder.py @@ -2,43 +2,220 @@ Test case for Primitive Cylinder feature. Written on High API. """ -from ModelAPI import * -from GeomAPI import * +#from ModelAPI import * from salome.shaper import model -# Get session -aSession = ModelAPI_Session.get() - -# Create a part -aDocument = aSession.activeDocument() -aSession.startOperation() -model.addPart(aDocument) -aDocument = aSession.activeDocument() -aSession.finishOperation() - -aSession.startOperation() -aBasePoint = model.addPoint(aDocument, 0, 0, 0).result() -anAxis = model.addAxis(aDocument, 10, 0, 0).result() -aSession.finishOperation() - -aSession.startOperation() -aCylinder1 = model.addCylinder(aDocument, aBasePoint, anAxis, 5., 20.) -assert (aCylinder1 is not None) -aSession.finishOperation() - -aSession.startOperation() -aCylinder2 = model.addCylinder(aDocument, aBasePoint, anAxis, 5., 20., 100.) -assert (aCylinder2 is not None) -aSession.finishOperation() - -aSession.startOperation() -aCylinder3 = model.addCylinder(aDocument, 5., 20.) -assert (aCylinder3 is not None) -aSession.finishOperation() - -aSession.startOperation() -aCylinder4 = model.addCylinder(aDocument, 5., 20., 100.) -assert (aCylinder4 is not None) -aSession.finishOperation() +model.begin() +partSet = model.moduleDocument() +Part_1 = model.addPart(partSet) +Part_1_doc = Part_1.document() +# Init +Point_1 = model.addPoint(Part_1_doc, 10, 10, 10).result() +Vertex_1 = model.addVertex(Part_1_doc, [model.selection("VERTEX", "Point_1")]) + +# Sketch +Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOY")) +SketchLine_1 = Sketch_1.addLine(40.1917811348149, 87.63526969661267, 92.63493386188256, 31.1341153558487) +SketchLine_2 = Sketch_1.addLine(92.63493386188256, 31.1341153558487, 44.70109718071649, 32.40093347950982) +SketchLine_3 = Sketch_1.addLine(44.70109718071649, 32.40093347950982, 40.1917811348149, 87.63526969661267) +SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchLine_2.startPoint()) +SketchConstraintCoincidence_2 = Sketch_1.setCoincident(SketchLine_2.endPoint(), SketchLine_3.startPoint()) +SketchConstraintCoincidence_3 = Sketch_1.setCoincident(SketchLine_1.startPoint(), SketchLine_3.endPoint()) + +# Extrusion +Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchLine_1f-SketchLine_2f-SketchLine_3f")], model.selection(), 100, 0) +Extrusion_2 = model.addExtrusion(Part_1_doc, [model.selection("WIRE", "Sketch_1/Wire-SketchLine_1f-SketchLine_2f-SketchLine_3f")], model.selection(), 100, 0) + +# Edge +Edge_1 = model.addEdge(Part_1_doc, [model.selection("EDGE", "Sketch_1/Edge-SketchLine_2")]) +Edge_2 = model.addEdge(Part_1_doc, [model.selection("EDGE", "Sketch_1/Edge-SketchLine_3")]) + +# Axis +Axis_1 = model.addAxis(Part_1_doc, 0, 10, 0) + +# Parameters +model.addParameter(Part_1_doc, "r", "6") +model.addParameter(Part_1_doc, "h", "20") + +model.addParameter(Part_1_doc, "r2", "6") +model.addParameter(Part_1_doc, "h2", "15") +model.addParameter(Part_1_doc, "angle", "270") + +#Tests +Cylinder_1 = model.addCylinder(Part_1_doc, 5, 10) +Cylinder_2 = model.addCylinder(Part_1_doc, model.selection("VERTEX", "Point_1"), model.selection("EDGE", "PartSet/OX"), 5, 10) +Cylinder_3 = model.addCylinder(Part_1_doc, model.selection("VERTEX", "Point_1"), model.selection("EDGE", "Axis_1"), 7, 12) +Cylinder_4 = model.addCylinder(Part_1_doc, 0, 10) +Cylinder_5 = model.addCylinder(Part_1_doc, -5, 10) +Cylinder_6 = model.addCylinder(Part_1_doc, 5, 0) +Cylinder_7 = model.addCylinder(Part_1_doc, 5, -10) +Cylinder_8 = model.addCylinder(Part_1_doc, model.selection("VERTEX", "InvalidName"), model.selection("EDGE", "PartSet/OX"), 5, 10) +Cylinder_9 = model.addCylinder(Part_1_doc, model.selection("VERTEX", "PartSet/Origin"), model.selection("EDGE", "InvalidName"), 5, 10) +Cylinder_10 = model.addCylinder(Part_1_doc, model.selection("VERTEX", "Sketch_1/Vertex-SketchLine_3s-SketchLine_2e"), model.selection("EDGE", "Sketch_1/Edge-SketchLine_3"), 50, 120) +Cylinder_11 = model.addCylinder(Part_1_doc, model.selection("VERTEX", "Vertex_1_1"), model.selection("EDGE", "Edge_1_1"), 60, 100) +Cylinder_12 = model.addCylinder(Part_1_doc, model.selection("VERTEX", "Extrusion_1_1/Generated_Face_5&Extrusion_1_1/Generated_Face_1&Extrusion_1_1/To_Face_1"), model.selection("EDGE", "Extrusion_1_1/Generated_Face_3&Extrusion_1_1/To_Face_1"), 5, 10) +Cylinder_13 = model.addCylinder(Part_1_doc, "r", "h") +Cylinder_14 = model.addCylinder(Part_1_doc, 5, 10, 45) +Cylinder_15 = model.addCylinder(Part_1_doc, model.selection("VERTEX", "Point_1"), model.selection("EDGE", "PartSet/OX"), 5, 10, 90) +Cylinder_16 = model.addCylinder(Part_1_doc, model.selection("VERTEX", "Point_1"), model.selection("EDGE", "Axis_1"), 7, 12, 120) +Cylinder_17 = model.addCylinder(Part_1_doc, model.selection("VERTEX", "Point_1"), model.selection("EDGE", "PartSet/OY"), 5, 10, 360) +Cylinder_18 = model.addCylinder(Part_1_doc, 0, 10, 45) +Cylinder_19 = model.addCylinder(Part_1_doc, -5, 10, 45) +Cylinder_20 = model.addCylinder(Part_1_doc, 5, 0, 45) +Cylinder_21 = model.addCylinder(Part_1_doc, 5, -10, 45) +Cylinder_22 = model.addCylinder(Part_1_doc, 5, 10, 0) +Cylinder_23 = model.addCylinder(Part_1_doc, 5, 10, -45) +Cylinder_24 = model.addCylinder(Part_1_doc, 5, 10, 450) +Cylinder_25 = model.addCylinder(Part_1_doc, model.selection("VERTEX", "InvalidName"), model.selection("EDGE", "PartSet/OX"), 5, 10, 90) +Cylinder_26 = model.addCylinder(Part_1_doc, model.selection("VERTEX", "PartSet/Origin"), model.selection("EDGE", "InvalidName"), 5, 10, 90) +Cylinder_27 = model.addCylinder(Part_1_doc, model.selection("VERTEX", "Sketch_1/Vertex-SketchLine_2s-SketchLine_1e"), model.selection("EDGE", "Sketch_1/Edge-SketchLine_3"), 50, 120, 90) +Cylinder_28 = model.addCylinder(Part_1_doc, model.selection("VERTEX", "Vertex_1_1"), model.selection("EDGE", "Edge_2_1"), 60, 100, 180) +Cylinder_29 = model.addCylinder(Part_1_doc, model.selection("VERTEX", "Extrusion_2_1/Generated_Face_5&Extrusion_1_1/Generated_Face_4&Extrusion_1_1/To_Face_1"), model.selection("EDGE", "Extrusion_2_1/Generated_Face_2&Extrusion_2_1/To_Face_1"), 5, 10, 120) +Cylinder_30 = model.addCylinder(Part_1_doc, "r2", "h2", "angle") + +model.do() +model.end() + +# Checks +from GeomAPI import GeomAPI_Shape + +model.testNbResults(Cylinder_1, 1) +model.testNbSubResults(Cylinder_1, [0]) +model.testNbSubShapes(Cylinder_1, GeomAPI_Shape.SOLID, [1]) +model.testNbSubShapes(Cylinder_1, GeomAPI_Shape.FACE, [3]) +model.testHaveNamingFaces(Cylinder_1, model, Part_1_doc) + +model.testNbResults(Cylinder_2, 1) +model.testNbSubResults(Cylinder_2, [0]) +model.testNbSubShapes(Cylinder_2, GeomAPI_Shape.SOLID, [1]) +model.testNbSubShapes(Cylinder_2, GeomAPI_Shape.FACE, [3]) +model.testHaveNamingFaces(Cylinder_2, model, Part_1_doc) + +model.testNbResults(Cylinder_3, 1) +model.testNbSubResults(Cylinder_3, [0]) +model.testNbSubShapes(Cylinder_3, GeomAPI_Shape.SOLID, [1]) +model.testNbSubShapes(Cylinder_3, GeomAPI_Shape.FACE, [3]) +model.testHaveNamingFaces(Cylinder_3, model, Part_1_doc) + +model.testNbResults(Cylinder_10, 1) +model.testNbSubResults(Cylinder_10, [0]) +model.testNbSubShapes(Cylinder_10, GeomAPI_Shape.SOLID, [1]) +model.testNbSubShapes(Cylinder_10, GeomAPI_Shape.FACE, [3]) +model.testHaveNamingFaces(Cylinder_10, model, Part_1_doc) + +model.testNbResults(Cylinder_11, 1) +model.testNbSubResults(Cylinder_11, [0]) +model.testNbSubShapes(Cylinder_11, GeomAPI_Shape.SOLID, [1]) +model.testNbSubShapes(Cylinder_11, GeomAPI_Shape.FACE, [3]) +model.testHaveNamingFaces(Cylinder_11, model, Part_1_doc) + +model.testNbResults(Cylinder_12, 1) +model.testNbSubResults(Cylinder_12, [0]) +model.testNbSubShapes(Cylinder_12, GeomAPI_Shape.SOLID, [1]) +model.testNbSubShapes(Cylinder_12, GeomAPI_Shape.FACE, [3]) +model.testHaveNamingFaces(Cylinder_12, model, Part_1_doc) + +model.testNbResults(Cylinder_13, 1) +model.testNbSubResults(Cylinder_13, [0]) +model.testNbSubShapes(Cylinder_13, GeomAPI_Shape.SOLID, [1]) +model.testNbSubShapes(Cylinder_13, GeomAPI_Shape.FACE, [3]) +model.testHaveNamingFaces(Cylinder_13, model, Part_1_doc) + +model.testNbResults(Cylinder_14, 1) +model.testNbSubResults(Cylinder_14, [0]) +model.testNbSubShapes(Cylinder_14, GeomAPI_Shape.SOLID, [1]) +model.testNbSubShapes(Cylinder_14, GeomAPI_Shape.FACE, [5]) +model.testHaveNamingFaces(Cylinder_14, model, Part_1_doc) + +model.testNbResults(Cylinder_15, 1) +model.testNbSubResults(Cylinder_15, [0]) +model.testNbSubShapes(Cylinder_15, GeomAPI_Shape.SOLID, [1]) +model.testNbSubShapes(Cylinder_15, GeomAPI_Shape.FACE, [5]) +model.testHaveNamingFaces(Cylinder_15, model, Part_1_doc) + +model.testNbResults(Cylinder_16, 1) +model.testNbSubResults(Cylinder_16, [0]) +model.testNbSubShapes(Cylinder_16, GeomAPI_Shape.SOLID, [1]) +model.testNbSubShapes(Cylinder_16, GeomAPI_Shape.FACE, [5]) +model.testHaveNamingFaces(Cylinder_16, model, Part_1_doc) + +model.testNbResults(Cylinder_17, 1) +model.testNbSubResults(Cylinder_17, [0]) +model.testNbSubShapes(Cylinder_17, GeomAPI_Shape.SOLID, [1]) +model.testNbSubShapes(Cylinder_17, GeomAPI_Shape.FACE, [3]) +model.testHaveNamingFaces(Cylinder_17, model, Part_1_doc) + +model.testNbResults(Cylinder_27, 1) +model.testNbSubResults(Cylinder_27, [0]) +model.testNbSubShapes(Cylinder_27, GeomAPI_Shape.SOLID, [1]) +model.testNbSubShapes(Cylinder_27, GeomAPI_Shape.FACE, [5]) +model.testHaveNamingFaces(Cylinder_27, model, Part_1_doc) + +model.testNbResults(Cylinder_28, 1) +model.testNbSubResults(Cylinder_28, [0]) +model.testNbSubShapes(Cylinder_28, GeomAPI_Shape.SOLID, [1]) +model.testNbSubShapes(Cylinder_28, GeomAPI_Shape.FACE, [5]) +model.testHaveNamingFaces(Cylinder_28, model, Part_1_doc) + +model.testNbResults(Cylinder_29, 1) +model.testNbSubResults(Cylinder_29, [0]) +model.testNbSubShapes(Cylinder_29, GeomAPI_Shape.SOLID, [1]) +model.testNbSubShapes(Cylinder_29, GeomAPI_Shape.FACE, [5]) +model.testHaveNamingFaces(Cylinder_29, model, Part_1_doc) + +model.testNbResults(Cylinder_30, 1) +model.testNbSubResults(Cylinder_30, [0]) +model.testNbSubShapes(Cylinder_30, GeomAPI_Shape.SOLID, [1]) +model.testNbSubShapes(Cylinder_30, GeomAPI_Shape.FACE, [5]) +model.testHaveNamingFaces(Cylinder_30, model, Part_1_doc) + +model.testNbResults(Cylinder_4, 0) +assert(Cylinder_4.feature().error() == "Cylinder builder :: radius is negative or null.") + +model.testNbResults(Cylinder_5, 0) +assert(Cylinder_5.feature().error() == "Cylinder builder :: radius is negative or null.") + +model.testNbResults(Cylinder_6, 0) +assert(Cylinder_6.feature().error() == "Cylinder builder :: height is negative or null.") + +model.testNbResults(Cylinder_7, 0) +assert(Cylinder_7.feature().error() == "Cylinder builder :: height is negative or null.") + +# To uncomment when #2044 will be performed. +#model.testNbResults(Cylinder_8, 0) +#assert(Cylinder_8.feature().error() == "Attribute \"base_point\" is not initialized") + +# To uncomment when #2044 will be performed. +#model.testNbResults(Cylinder_9, 0) +#assert(Cylinder_9.feature().error() == "Attribute \"axis\" is not initialized") + +model.testNbResults(Cylinder_18, 0) +assert(Cylinder_18.feature().error() == "Cylinder builder :: radius is negative or null.") + +model.testNbResults(Cylinder_19, 0) +assert(Cylinder_19.feature().error() == "Cylinder builder :: radius is negative or null.") + +model.testNbResults(Cylinder_20, 0) +assert(Cylinder_20.feature().error() == "Cylinder builder :: height is negative or null.") + +model.testNbResults(Cylinder_21, 0) +assert(Cylinder_21.feature().error() == "Cylinder builder :: height is negative or null.") + +model.testNbResults(Cylinder_22, 0) +assert(Cylinder_22.feature().error() == "Cylinder builder :: angle is negative or null.") + +model.testNbResults(Cylinder_23, 0) +assert(Cylinder_23.feature().error() == "Cylinder builder :: angle is negative or null.") + +model.testNbResults(Cylinder_24, 0) +assert(Cylinder_24.feature().error() == "Cylinder builder :: angle greater than 360 degrees.") + +# To uncomment when #2044 will be performed. +#model.testNbResults(Cylinder_25, 0) +#assert(Cylinder_25.feature().error() == "Attribute \"base_point\" is not initialized") + +# To uncomment when #2044 will be performed. +#model.testNbResults(Cylinder_26, 0) +#assert(Cylinder_26.feature().error() == "Attribute \"axis\" is not initialized") diff --git a/test.API/SHAPER/Transformations/TestAPI_MultiTranslation.py b/test.API/SHAPER/Transformations/TestAPI_MultiTranslation.py new file mode 100644 index 000000000..5cbbad138 --- /dev/null +++ b/test.API/SHAPER/Transformations/TestAPI_MultiTranslation.py @@ -0,0 +1,61 @@ +# Copyright (C) 2014-201x CEA/DEN, EDF R&D + +# File: TestAPI_MultiTranslation.py +# Created: 17 Mar 2017 +# Author: Sylvain Chouteau (Alyotech) + +from GeomAlgoAPI import GeomAlgoAPI_ShapeAPI as shaperpy +from GeomAlgoAPI import GeomAlgoAPI_Exception as myExcept +from GeomAPI import GeomAPI_Ax1 as axis, GeomAPI_Pnt as pnt, GeomAPI_Dir as direction + +# Create Boxes +Box_1 = shaperpy.makeBox(10.,10.,10.) +Box_2 = shaperpy.makeBox(10.,10.,10.) +Box_3 = shaperpy.makeBox(10.,10.,10.) +Box_4 = shaperpy.makeBox(10.,10.,10.) +Box_5 = shaperpy.makeBox(10.,10.,10.) +Box_6 = shaperpy.makeBox(10.,10.,10.) +Box_7 = shaperpy.makeBox(10.,10.,10.) +Box_8 = shaperpy.makeBox(10.,10.,10.) + +# Points +pntOrigin = pnt(0.,0.,0.) +pnt1 = pnt(10.,0.,0.) +pnt2 = pnt(10.,10.,0.) + +# Axis +xDir = direction(10., 0., 0.) +ax1 = axis(pntOrigin, xDir) + +yDir = direction(0., 10., 0.) +ax2 = axis(pntOrigin, yDir) + + +# Create MultiTranslations +MultiTranslation_1 = shaperpy.makeMultiTranslation(Box_1, ax1, 15., 5) +MultiTranslation_2 = shaperpy.makeMultiTranslation(Box_2, ax1, -15., 5) + +try: + MultiTranslation_3 = shaperpy.makeMultiTranslation(Box_3, ax1, 15., -2) +except myExcept,ec: + assert(ec.what() == "Multitranslation builder :: the number of copies for the first direction is null or negative.") + +MultiTranslation_5 = shaperpy.makeMultiTranslation(Box_5, ax1, 10., 5, ax2, 10., 5) +MultiTranslation_6 = shaperpy.makeMultiTranslation(Box_6, ax1, 15., 5, ax2, -10., 5) + +# Tests en erreur +#try: +# MultiTranslation_4 = shaperpy.makeMultiTranslation(Box_4, None, 15., 2) +#except myExcept,ec: +# assert(ec.what() == "Multitranslation builder :: the first axis is not valid.") + +# Pas d'exception levee alors qu'une devrait y en avoir une +try: + MultiTranslation_7 = shaperpy.makeMultiTranslation(Box_7, ax1, 15., 5, ax2, 10., -2) +except myExcept,ec: + assert(ec.what() == "Multitranslation builder :: the number of copies for the second direction is null or negative.") + +#try: +# MultiTranslation_8 = shaperpy.makeMultiTranslation(Box_8, ax1, 15., 5, None, 10., 5) +#except myExcept,ec: +# assert(ec.what() == "Multitranslation builder :: the second axis is not valid.") diff --git a/test.API/SHAPER/Transformations/TestAPI_Rotation.py b/test.API/SHAPER/Transformations/TestAPI_Rotation.py new file mode 100644 index 000000000..9f43b6452 --- /dev/null +++ b/test.API/SHAPER/Transformations/TestAPI_Rotation.py @@ -0,0 +1,101 @@ +# Copyright (C) 2014-201x CEA/DEN, EDF R&D + +# File: TestAPI_Rotation.py +# Created: 17 Mar 2017 +# Author: Sylvain Chouteau (Alyotech) + +from GeomAlgoAPI import GeomAlgoAPI_ShapeAPI as shaperpy +from GeomAlgoAPI import GeomAlgoAPI_Exception as myExcept +from GeomAPI import GeomAPI_Ax1 as axis, GeomAPI_Pnt as pnt, GeomAPI_Dir as direction + +# Create Boxes +Box_1 = shaperpy.makeBox(10.,10.,10.) +Box_2 = shaperpy.makeBox(10.,10.,10.) +Box_3 = shaperpy.makeBox(10.,10.,10.) +Box_4 = shaperpy.makeBox(10.,10.,10.) +Box_5 = shaperpy.makeBox(10.,10.,10.) +Box_6 = shaperpy.makeBox(10.,10.,10.) +Box_7 = shaperpy.makeBox(10.,10.,10.) +Box_8 = shaperpy.makeBox(10.,10.,10.) +Box_9 = shaperpy.makeBox(10.,10.,10.) +Box_10 = shaperpy.makeBox(10.,10.,10.) +Box_11 = shaperpy.makeBox(10.,10.,10.) +Box_12 = shaperpy.makeBox(10.,10.,10.) +Box_13 = shaperpy.makeBox(10.,10.,10.) +Box_14 = shaperpy.makeBox(10.,10.,10.) +Box_15 = shaperpy.makeBox(10.,10.,10.) + +# Points +pntOrigin = pnt(0.,0.,0.) +pnt1 = pnt(20.,0.,0.) +pnt2 = pnt(20.,20.,0.) +pnt3 = pnt(-10.,0.,0.) + +# Axis +zDir = direction(0., 0., 10.) +ax1 = axis(pntOrigin, zDir) + + +# Create Rotations +Rotation_1 = shaperpy.makeRotation(Box_1, ax1, 45) +Rotation_2 = shaperpy.makeRotation(Box_2, ax1, 0) +Rotation_3 = shaperpy.makeRotation(Box_3, ax1, 360) +Rotation_4 = shaperpy.makeRotation(Box_4, ax1, -360) + +try: + Rotation_5 = shaperpy.makeRotation(Box_5, ax1, 450) +except myExcept,ec: + assert(ec.what() == "Rotation builder :: angle greater than 360 degrees.") + +try: + Rotation_6 = shaperpy.makeRotation(Box_6, ax1, -450) +except myExcept,ec: + assert(ec.what() == "Rotation builder :: angle smaller than -360 degrees.") + +try: + Rotation_7 = shaperpy.makeRotation(Box_7, None, 180) +except myExcept,ec: + assert(ec.what() == "Rotation builder :: axis is not valid.") + +try: + Rotation_8 = shaperpy.makeRotation(None, ax1, 180) +except myExcept,ec: + assert(ec.what() == "Rotation builder :: source shape is not valid.") + +Rotation_9 = shaperpy.makeRotation(Box_8, pntOrigin, pnt1, pnt2) +Rotation_10 = shaperpy.makeRotation(Box_9, pnt3, pnt1, pnt2) + +try: + Rotation_11 = shaperpy.makeRotation(Box_10, pnt3, pnt1, pnt1) +except myExcept,ec: + assert(ec.what() == "Rotation builder :: start point and end point coincide.") + +try: + Rotation_12 = shaperpy.makeRotation(Box_11, pnt3, pnt3, pnt1) +except myExcept,ec: + assert(ec.what() == "Rotation builder :: center point and start point coincide.") + +try: + Rotation_13 = shaperpy.makeRotation(Box_12, pnt3, pnt1, pnt3) +except myExcept,ec: + assert(ec.what() == "Rotation builder :: center point and end point coincide.") + +try: + Rotation_14 = shaperpy.makeRotation(Box_13, pntOrigin, pnt1, None) +except myExcept,ec: + assert(ec.what() == "Rotation builder :: end point is not valid.") + +try: + Rotation_15 = shaperpy.makeRotation(Box_14, None, pnt3, pnt2) +except myExcept,ec: + assert(ec.what() == "Rotation builder :: center point is not valid.") + +try: + Rotation_16 = shaperpy.makeRotation(Box_15, pntOrigin, None, pnt1) +except myExcept,ec: + assert(ec.what() == "Rotation builder :: start point is not valid.") + +try: + Rotation_17 = shaperpy.makeRotation(None, pntOrigin, pnt3, pnt2) +except myExcept,ec: + assert(ec.what() == "Rotation builder :: source shape is not valid.") diff --git a/test.API/SHAPER/Transformations/TestAPI_Scale.py b/test.API/SHAPER/Transformations/TestAPI_Scale.py index a60134807..68a6d8486 100644 --- a/test.API/SHAPER/Transformations/TestAPI_Scale.py +++ b/test.API/SHAPER/Transformations/TestAPI_Scale.py @@ -8,25 +8,59 @@ from GeomAlgoAPI import GeomAlgoAPI_ShapeAPI as shaperpy from GeomAlgoAPI import GeomAlgoAPI_Exception as myExcept from GeomAPI import GeomAPI_Pnt as pnt -# Create a box +# Create Boxes +Box_1 = shaperpy.makeBox(10.,10.,10.) +Box_2 = shaperpy.makeBox(10.,10.,10.) +Box_3 = shaperpy.makeBox(10.,10.,10.) +Box_4 = shaperpy.makeBox(10.,10.,10.) +Box_5 = shaperpy.makeBox(10.,10.,10.) +Box_6 = shaperpy.makeBox(10.,10.,10.) +Box_7 = shaperpy.makeBox(10.,10.,10.) +Box_8 = shaperpy.makeBox(10.,10.,10.) +Box_9 = shaperpy.makeBox(10.,10.,10.) +Box_10 = shaperpy.makeBox(10.,10.,10.) +Box_11 = shaperpy.makeBox(10.,10.,10.) +Box_12 = shaperpy.makeBox(10.,10.,10.) + +# Create Points +pntOrigin = pnt(0., 0., 0.) +pnt1 = pnt(-10., -10., -10.) + + +# Create Scales +Scale_1 = shaperpy.makeScale(Box_1, pntOrigin, 2.) +Scale_2 = shaperpy.makeScale(Box_2, pnt1, 2.) try : - box1 = shaperpy.makeBox(10.,10.,10.) - box2 = shaperpy.makeBox(10.,10.,10.) - centerPoint = pnt(20.,20.,0.) - -except myExcept, ec: - print ec.what() - -# Perfom a scale by a factor. + Scale_6 = shaperpy.makeScale(Box_3, pntOrigin, 0) +except myExcept,ec : + assert(ec.what() == "Scale builder :: the scale factor is null.") + +Scale_7 = shaperpy.makeScale(Box_4, pntOrigin, -3.) + try : - scale1 = shaperpy.makeScale(box1,centerPoint, -1.6) - -except myExcept, ec: - print ec.what() + Scale_8 = shaperpy.makeScale(Box_5, None, 2.) +except myExcept,ec : + assert(ec.what() == "Scale builder :: center point is not valid.") + +Scale_9 = shaperpy.makeScale(Box_6, pntOrigin, 2., 3., 1.) +Scale_10 = shaperpy.makeScale(Box_7, pnt1, 2., 3., 1.) + +try : + Scale_14 = shaperpy.makeScale(Box_8, pntOrigin, 0., 3., 1.) +except myExcept,ec : + assert(ec.what() == "Scale builder :: the scale factor in X is null.") +try : + Scale_15 = shaperpy.makeScale(Box_9, pntOrigin, 2., 0., 1.) +except myExcept,ec : + assert(ec.what() == "Scale builder :: the scale factor in Y is null.") +try : + Scale_16 = shaperpy.makeScale(Box_10, pntOrigin, 2., 3., 0.) +except myExcept,ec : + assert(ec.what() == "Scale builder :: the scale factor in Z is null.") + +Scale_17 = shaperpy.makeScale(Box_11, pntOrigin, -2., -3., 0.5) -# Perfom a scale by dimensions. try : - scale2 = shaperpy.makeScale(box2,centerPoint, 2, -0.5, 1.3) - -except myExcept, ec: - print ec.what() + Scale_18 = shaperpy.makeScale(Box_12, None, 2., 3., 1.) +except myExcept,ec : + assert(ec.what() == "Scale builder :: center point is not valid.") \ No newline at end of file diff --git a/test.API/SHAPER/Transformations/TestAPI_Symmetry.py b/test.API/SHAPER/Transformations/TestAPI_Symmetry.py index 409d39863..4eed9bf03 100644 --- a/test.API/SHAPER/Transformations/TestAPI_Symmetry.py +++ b/test.API/SHAPER/Transformations/TestAPI_Symmetry.py @@ -3,46 +3,55 @@ # File: TestAPI_Symmetry.py # Created: 15 Nov 2016 # Author: Clarisse Genrault (CEA) - from GeomAlgoAPI import GeomAlgoAPI_ShapeAPI as shaperpy from GeomAlgoAPI import GeomAlgoAPI_Exception as myExcept -from GeomAPI import GeomAPI_Ax1 as axis -from GeomAPI import GeomAPI_Ax2 as plane from GeomAPI import GeomAPI_Pnt as pnt from GeomAPI import GeomAPI_Dir as direction +from GeomAPI import GeomAPI_Ax1 as axis +from GeomAPI import GeomAPI_Ax2 as plane -# Create a box -try : - box1 = shaperpy.makeBox(10.,10.,10.) - box2 = shaperpy.makeBox(10.,10.,10.) - box3 = shaperpy.makeBox(10.,10.,10.) - -except myExcept, ec: - print ec.what() - -# Perfom a symmetry by a point. -try : - origin = pnt(0.,0.,0.) - symmetry1 = shaperpy.makeSymmetry(box1,origin) - -except myExcept, ec: - print ec.what() +# Create boxes +Box_1 = shaperpy.makeBox(10., 10., 10.) +Box_2 = shaperpy.makeBox(10., 10., 10.) +Box_3 = shaperpy.makeBox(10., 10., 10.) +Box_4 = shaperpy.makeBox(10., 10., 10.) +Box_5 = shaperpy.makeBox(10., 10., 10.) +Box_6 = shaperpy.makeBox(10., 10., 10.) +Box_7 = shaperpy.makeBox(10., 10., 10.) +Box_8 = shaperpy.makeBox(10., 10., 10.) +Box_9 = shaperpy.makeBox(10., 10., 10.) +Box_10 = shaperpy.makeBox(10., 10., 10.) +Box_11 = shaperpy.makeBox(10., 10., 10.) +Box_12 = shaperpy.makeBox(10., 10., 10.) +Box_13 = shaperpy.makeBox(10., 10., 10.) +Box_14 = shaperpy.makeBox(10., 10., 10.) +Box_15 = shaperpy.makeBox(10., 10., 10.) +Box_16 = shaperpy.makeBox(10., 10., 10.) +Box_17 = shaperpy.makeBox(10., 10., 10.) +Box_18 = shaperpy.makeBox(10., 10., 10.) + +# Create points +origin = pnt(0., 0., 0.) +pnt1 = pnt(-10., -10., -10) + +# Create Axis +dirZ = direction(0., 0., 10.) +axZ = axis(origin, dirZ) + +dir1 = direction(10., 10., 10.) +ax1 = axis(origin, dir1) + +# Create Planes +planeXOY = plane(origin, dirZ) + +Symmetry_1 = shaperpy.makeSymmetry(Box_1, origin) +Symmetry_2 = shaperpy.makeSymmetry(Box_2, pnt1) -# Perfom a symmetry by an axis. -try : - xDir = direction(1.,0.,0.) - xAxis = axis(origin, xDir) - translation2 = shaperpy.makeSymmetry(box2,xAxis) - -except myExcept, ec: - print ec.what() - -# Perfom a symmetry by a plane. try : - pnt1 = pnt(0.,0.,10.) - pnt2 = pnt(10.,0.,10.) - aPlane = plane(origin, xDir) - translation3 = shaperpy.makeSymmetry(box3,aPlane) - -except myExcept, ec: - print ec.what() + Symmetry_6 = shaperpy.makeSymmetry(Box_2, None) +except myExcept,ec : + assert(ec.what() == "Symmetry builder :: point is not valid.") + +Symmetry_7 = shaperpy.makeSymmetry(Box_7, axZ) +Symmetry_8 = shaperpy.makeSymmetry(Box_8, ax1) +Symmetry_13 = shaperpy.makeSymmetry(Box_13, planeXOY) diff --git a/test.API/SHAPER/Transformations/TestAPI_Translation.py b/test.API/SHAPER/Transformations/TestAPI_Translation.py index b3933912e..603a14c88 100644 --- a/test.API/SHAPER/Transformations/TestAPI_Translation.py +++ b/test.API/SHAPER/Transformations/TestAPI_Translation.py @@ -10,35 +10,97 @@ from GeomAPI import GeomAPI_Ax1 as axis from GeomAPI import GeomAPI_Pnt as pnt from GeomAPI import GeomAPI_Dir as direction -# Create a box -try : - box = shaperpy.makeBox(10.,10.,10.) - -except myExcept, ec: - print ec.what() - -# Perfom a translation with an axis and a distance. -try : - origin = pnt(0.,0.,0.) - xDir = direction(1.,0.,0.) - xAxis = axis(origin, xDir) - translation1 = shaperpy.makeTranslation(box,xAxis,15.) - -except myExcept, ec: - print ec.what() - -# Perfom a translation with dimensions. -try : - translation2 = shaperpy.makeTranslation(box,10,0,0) - -except myExcept, ec: - print ec.what() - -# Perfom a translation with two points. -try : - pnt1 = pnt(10.,0.,0.) - pnt2 = pnt(10.,15.,0.) - translation3 = shaperpy.makeTranslation(box,pnt1,pnt2) - -except myExcept, ec: - print ec.what() +# Points +pntOrigin = pnt(0.,0.,0.) +pnt1 = pnt(10.,0.,0.) +pnt2 = pnt(10.,10.,0.) + +# Axis +xDir = direction(10., 0., 0.) +ax1 = axis(pntOrigin, xDir) + +yDir = direction(0., 10., 0.) +ax2 = axis(pntOrigin, yDir) + +zDir = direction(0., 0., 10.) +ax3 = axis(pntOrigin, zDir) + +dir1 = direction(10., 10., 10.) +ax4 = axis(pntOrigin, dir1) + +# Boxes +Box_1 = shaperpy.makeBox(10., 20., 10.) +Box_2 = shaperpy.makeBox(10., 20., 10.) +Box_3 = shaperpy.makeBox(10., 20., 10.) +Box_4 = shaperpy.makeBox(10., 20., 10.) +Box_5 = shaperpy.makeBox(10., 20., 10.) +Box_6 = shaperpy.makeBox(10., 20., 10.) +Box_7 = shaperpy.makeBox(10., 20., 10.) +Box_8 = shaperpy.makeBox(10., 20., 10.) +Box_9 = shaperpy.makeBox(10., 20., 10.) +Box_10 = shaperpy.makeBox(10., 20., 10.) +Box_11 = shaperpy.makeBox(10., 20., 10.) +Box_12 = shaperpy.makeBox(10., 20., 10.) +Box_13 = shaperpy.makeBox(10., 20., 10.) +Box_14 = shaperpy.makeBox(10., 20., 10.) +Box_15 = shaperpy.makeBox(10., 20., 10.) +Box_16 = shaperpy.makeBox(10., 20., 10.) +Box_17 = shaperpy.makeBox(10., 20., 10.) +Box_18 = shaperpy.makeBox(10., 20., 10.) + +#Translations "By an axis and a distance" +Translation_1 = shaperpy.makeTranslation(Box_1, ax1, 15.) +Translation_2 = shaperpy.makeTranslation(Box_2, ax1, 0.) +Translation_3 = shaperpy.makeTranslation(Box_3, ax1, -15.) + +try: + Translation_4 = shaperpy.makeTranslation(Box_4, None, 15.) +except myExcept,ec: + assert(ec.what() == "Translation builder :: axis is not valid.") + +Translation_9 = shaperpy.makeTranslation(Box_5, ax4, 15.) + +MultiTranslation_1 = shaperpy.makeMultiTranslation(Box_6, ax1, 15., 3, ax2, 15., 3) +Translation_10 = shaperpy.makeTranslation(MultiTranslation_1, ax3, 15.) + +MultiTranslation_2 = shaperpy.makeMultiTranslation(Box_7, ax1, 15., 3, ax2, 15., 3) +Translation_11 = shaperpy.makeTranslation(MultiTranslation_2, ax3, 0.) + +MultiTranslation_3 = shaperpy.makeMultiTranslation(Box_8, ax1, 15., 3, ax2, 15., 3) +Translation_12 = shaperpy.makeTranslation(MultiTranslation_3, ax3, -15.) + +MultiTranslation_4 = shaperpy.makeMultiTranslation(Box_9, ax1, 15., 3, ax2, 15., 3) +try: + Translation_13 = shaperpy.makeTranslation(MultiTranslation_4, None, 15.) +except myExcept,ec: + assert(ec.what() == "Translation builder :: axis is not valid.") + +MultiTranslation_5 = shaperpy.makeMultiTranslation(Box_10, ax1, 15., 3, ax2, 15., 3) +Translation_18 = shaperpy.makeTranslation(MultiTranslation_5, ax4, 15.) + +# Translations "By dimensions in X, in Y and in Z" +Translation_91 = shaperpy.makeTranslation(Box_11, 10., 20., 15.) +Translation_92 = shaperpy.makeTranslation(Box_11, 0., 20., 15.) +Translation_93 = shaperpy.makeTranslation(Box_11, 10., 0., 15.) +Translation_94 = shaperpy.makeTranslation(Box_11, 10., 20., 0.) +Translation_95 = shaperpy.makeTranslation(Box_11, -10., 20., 15.) +Translation_96 = shaperpy.makeTranslation(Box_11, 10., -20., 15.) +Translation_97 = shaperpy.makeTranslation(Box_11, 10., 20., -15.) + +# Translations "By two points" +Translation_99 = shaperpy.makeTranslation(Box_11, pnt1, pnt2) + +try: + Translation_100 = shaperpy.makeTranslation(Box_11, pnt1, pnt1) +except myExcept,ec: + assert(ec.what() == "Translation builder :: start point and end point coincide.") + +try: + Translation_101 = shaperpy.makeTranslation(Box_11, None, pnt1) +except myExcept,ec: + assert(ec.what() == "Translation builder :: start point is not valid.") + +try: + Translation_102 = shaperpy.makeTranslation(Box_11, pnt1, None) +except myExcept,ec: + assert(ec.what() == "Translation builder :: end point is not valid.") \ No newline at end of file diff --git a/test.API/SHAPER/Transformations/TestMultiTranslation.py b/test.API/SHAPER/Transformations/TestMultiTranslation.py new file mode 100644 index 000000000..f6e56a82c --- /dev/null +++ b/test.API/SHAPER/Transformations/TestMultiTranslation.py @@ -0,0 +1,158 @@ +""" +Test case for MultiTranslation feature. +Written on High API. +""" +from salome.shaper import model + +model.begin() +partSet = model.moduleDocument() +Part_1 = model.addPart(partSet) +Part_1_doc = Part_1.document() + +# Create Boxes +Box_1 = model.addBox(Part_1_doc, 10, 10, 10) +Box_2 = model.addBox(Part_1_doc, 10, 10, 10) +Box_3 = model.addBox(Part_1_doc, 10, 10, 10) +Box_4 = model.addBox(Part_1_doc, 10, 10, 10) +Box_5 = model.addBox(Part_1_doc, 10, 10, 10) +Box_6 = model.addBox(Part_1_doc, 10, 10, 10) +Box_7 = model.addBox(Part_1_doc, 10, 10, 10) +Box_8 = model.addBox(Part_1_doc, 10, 10, 10) +Box_9 = model.addBox(Part_1_doc, 10, 10, 10) + +# Create Sketches +# Sketch contenant un contour ferme de 3 lignes +Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOY")) +SketchLine_1 = Sketch_1.addLine(20.57127738485033, 88.55774147773481, -110.037034305799, -25.45393392073257) +SketchLine_2 = Sketch_1.addLine(-110.037034305799, -25.45393392073257, 49.43499267560162, -77.40862144408482) +SketchLine_3 = Sketch_1.addLine(49.43499267560162, -77.40862144408482, 68.1964076145899, 55.3644688933709) +SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchLine_2.startPoint()) +SketchConstraintCoincidence_2 = Sketch_1.setCoincident(SketchLine_2.endPoint(), SketchLine_3.startPoint()) + +# Sketch creer sur la face de la box confondue avec le plan XOZ contenant un cercle inclus dans la face de la box +Sketch_2 = model.addSketch(Part_1_doc, model.selection("FACE", "Box_9_1/Left")) +SketchCircle_1 = Sketch_2.addCircle(3.420516499282639, 6.702654232424678, 2.660489383382409) +model.do() + +# Create Wire & Extrusion +Wire_1 = model.addWire(Part_1_doc, [model.selection("EDGE", "Sketch_1/Edge-SketchLine_2"), model.selection("EDGE", "Sketch_1/Edge-SketchLine_1"), model.selection("EDGE", "Sketch_1/Edge-SketchLine_3")]) +Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("WIRE", "Wire_1_1")], model.selection("EDGE", "PartSet/OZ"), 50, 0) + +# Revolution of the circle +Revolution_1 = model.addRevolution(Part_1_doc, [model.selection("WIRE", "Sketch_2/Wire-SketchCircle_1_2f")], model.selection("EDGE", "PartSet/OZ"), 360, 0) + +# Create MultiTranslations +MultiTranslation_1 = model.addMultiTranslation(Part_1_doc, [model.selection("SOLID", "Box_1_1")], model.selection("EDGE", "PartSet/OX"), 15, 5) +MultiTranslation_2 = model.addMultiTranslation(Part_1_doc, [model.selection("SOLID", "Box_2_1")], model.selection("EDGE", "PartSet/OX"), -15, 5) +MultiTranslation_3 = model.addMultiTranslation(Part_1_doc, [model.selection("SOLID", "Box_3_1")], model.selection("EDGE", "PartSet/OX"), 15, -2) +MultiTranslation_4 = model.addMultiTranslation(Part_1_doc, [model.selection("SOLID", "Box_4_1")], model.selection("EDGE", "InvalidName"), 15, -2) +MultiTranslation_5 = model.addMultiTranslation(Part_1_doc, [model.selection("SOLID", "Box_5_1")], model.selection("EDGE", "PartSet/OX"), 10, 5, model.selection("EDGE", "PartSet/OY"), 10, 5) +MultiTranslation_6 = model.addMultiTranslation(Part_1_doc, [model.selection("SOLID", "Box_6_1")], model.selection("EDGE", "PartSet/OX"), 10, 5, model.selection("EDGE", "PartSet/OY"), -10, 5) +MultiTranslation_7 = model.addMultiTranslation(Part_1_doc, [model.selection("SOLID", "Box_7_1")], model.selection("EDGE", "PartSet/OX"), 10, 5, model.selection("EDGE", "PartSet/OY"), 10, -2) +MultiTranslation_8 = model.addMultiTranslation(Part_1_doc, [model.selection("SOLID", "Box_8_1")], model.selection("EDGE", "PartSet/OX"), 10, 5, model.selection("EDGE", "InvalidName"), 10, 5) +MultiTranslation_9 = model.addMultiTranslation(Part_1_doc, [model.selection("SHELL", "Extrusion_1_1")], model.selection("EDGE", "PartSet/OZ"), 50, 10) +MultiTranslation_10 = model.addMultiTranslation(Part_1_doc, [model.selection("SOLID", "Revolution_1_1"), model.selection("SOLID", "Box_9_1")], model.selection("EDGE", "PartSet/OY"), 20, 3) + +model.do() +model.end() + + + +# Checks +from GeomAPI import GeomAPI_Shape, GeomAPI_ShapeExplorer +from GeomAlgoAPI import * + +model.testNbResults(MultiTranslation_1, 1) +model.testNbSubResults(MultiTranslation_1, [5]) +model.testNbSubShapes(MultiTranslation_1, GeomAPI_Shape.COMPOUND, [1]) +model.testNbSubShapes(MultiTranslation_1, GeomAPI_Shape.SOLID, [5]) +model.testNbSubShapes(MultiTranslation_1, GeomAPI_Shape.FACE, [30]) +model.testHaveNamingFaces(MultiTranslation_1, model, Part_1_doc) + +model.testNbResults(MultiTranslation_2, 1) +model.testNbSubResults(MultiTranslation_2, [5]) +model.testNbSubShapes(MultiTranslation_2, GeomAPI_Shape.COMPOUND, [1]) +model.testNbSubShapes(MultiTranslation_2, GeomAPI_Shape.SOLID, [5]) +model.testNbSubShapes(MultiTranslation_2, GeomAPI_Shape.FACE, [30]) +model.testHaveNamingFaces(MultiTranslation_2, model, Part_1_doc) + +model.testNbResults(MultiTranslation_5, 1) +model.testNbSubResults(MultiTranslation_5, [25]) +model.testNbSubShapes(MultiTranslation_5, GeomAPI_Shape.COMPOUND, [1]) +model.testNbSubShapes(MultiTranslation_5, GeomAPI_Shape.SOLID, [25]) +model.testNbSubShapes(MultiTranslation_5, GeomAPI_Shape.FACE, [150]) +model.testHaveNamingFaces(MultiTranslation_5, model, Part_1_doc) + +model.testNbResults(MultiTranslation_6, 1) +model.testNbSubResults(MultiTranslation_6, [25]) +model.testNbSubShapes(MultiTranslation_6, GeomAPI_Shape.COMPOUND, [1]) +model.testNbSubShapes(MultiTranslation_6, GeomAPI_Shape.SOLID, [25]) +model.testNbSubShapes(MultiTranslation_6, GeomAPI_Shape.FACE, [150]) +model.testHaveNamingFaces(MultiTranslation_6, model, Part_1_doc) + +#################################################################################################### +# Test of MultiTranslation 10 +model.testNbResults(MultiTranslation_10, 2) +model.testNbSubResults(MultiTranslation_10, [3, 3]) + +def testSubResult(theFeature, theModel, thePartDoc, resultIndex, nbSolidsExpected, nbFacesExpected): + result = theFeature.results()[resultIndex].resultSubShapePair()[0] + shape = result.shape() + shapeExplorer = GeomAPI_ShapeExplorer(shape, GeomAPI_Shape.SOLID) + nbSolids = 0 + while shapeExplorer.more(): + nbSolids += 1 + shapeExplorer.next() + assert(nbSolids == nbSolidsExpected) + + shapeExplorer = GeomAPI_ShapeExplorer(shape, GeomAPI_Shape.FACE) + nbFaces = 0 + selectionList = [] + while shapeExplorer.more(): + nbFaces += 1 + selection = theModel.selection(result, shapeExplorer.current()) # First argument should be result/sub-result, second is sub-shape on this result/sub-result + selectionList.append(selection) + shapeExplorer.next() + assert(nbFaces == nbFacesExpected) + # Create group with this selection list + Group_1 = theModel.addGroup(thePartDoc, selectionList) + theModel.do() + theModel.end() + + # Now you can check that all selected shapes in group have right shape type and name. + groupFeature = Group_1.feature() + groupSelectionList = groupFeature.selectionList("group_list") + theModel.end() + assert(groupSelectionList.size() == len(selectionList)) + for index in range(0, groupSelectionList.size()): + attrSelection = groupSelectionList.value(index) + shape = attrSelection.value() + name = attrSelection.namingName() + assert(shape.isFace()) + assert(name != ""), "String empty" + +testSubResult(MultiTranslation_10, model, Part_1_doc, 0, 3, 3) +testSubResult(MultiTranslation_10, model, Part_1_doc, 1, 3, 18) +#################################################################################################### + +model.testNbResults(MultiTranslation_3, 0) +assert(MultiTranslation_3.feature().error() == 'Multitranslation builder :: the number of copies for the first direction is null or negative.') + +model.testNbResults(MultiTranslation_4, 0) +assert(MultiTranslation_4.feature().error() == 'Attribute "axis_first_dir" is not initialized.') + +model.testNbResults(MultiTranslation_7, 0) +assert(MultiTranslation_7.feature().error() == 'Multitranslation builder :: the number of copies for the second direction is null or negative.') + +model.testNbResults(MultiTranslation_8, 0) +assert(MultiTranslation_8.feature().error() == 'Attribute "axis_second_dir" is not initialized.') + + +# Multitranslation en erreur +#model.testNbResults(MultiTranslation_9, 1) +#model.testNbSubResults(MultiTranslation_9, [10]) +#model.testNbSubShapes(MultiTranslation_9, GeomAPI_Shape.COMPOUND, [1]) +#model.testNbSubShapes(MultiTranslation_9, GeomAPI_Shape.SOLID, [0]) +#model.testNbSubShapes(MultiTranslation_9, GeomAPI_Shape.SHELL, [10]) +#model.testNbSubShapes(MultiTranslation_9, GeomAPI_Shape.FACE, [30]) +#model.testHaveNamingFaces(MultiTranslation_9, model, Part_1_doc) \ No newline at end of file diff --git a/test.API/SHAPER/Transformations/TestRotation.py b/test.API/SHAPER/Transformations/TestRotation.py new file mode 100644 index 000000000..3af1988cc --- /dev/null +++ b/test.API/SHAPER/Transformations/TestRotation.py @@ -0,0 +1,156 @@ +""" +Test case for Rotation feature. +Written on High API. +""" +from salome.shaper import model + +model.begin() +partSet = model.moduleDocument() +Part_1 = model.addPart(partSet) +Part_1_doc = Part_1.document() + +# Create Boxes +Box_1 = model.addBox(Part_1_doc, 10, 10, 10) +Box_2 = model.addBox(Part_1_doc, 10, 10, 10) +Box_3 = model.addBox(Part_1_doc, 10, 10, 10) +Box_4 = model.addBox(Part_1_doc, 10, 10, 10) +Box_5 = model.addBox(Part_1_doc, 10, 10, 10) +Box_6 = model.addBox(Part_1_doc, 10, 10, 10) +Box_7 = model.addBox(Part_1_doc, 10, 10, 10) +Box_8 = model.addBox(Part_1_doc, 10, 10, 10) +Box_9 = model.addBox(Part_1_doc, 10, 10, 10) +Box_10 = model.addBox(Part_1_doc, 10, 10, 10) +Box_11 = model.addBox(Part_1_doc, 10, 10, 10) +Box_12 = model.addBox(Part_1_doc, 10, 10, 10) +Box_13 = model.addBox(Part_1_doc, 10, 10, 10) +Box_14 = model.addBox(Part_1_doc, 10, 10, 10) +Box_15 = model.addBox(Part_1_doc, 10, 10, 10) + +# Create Points +Point_1 = model.addPoint(Part_1_doc, 20, 0, 0) +Point_2 = model.addPoint(Part_1_doc, 20, 20, 0) +Point_3 = model.addPoint(Part_1_doc, -10, 0, 0) + +# Create Parts +Part_2 = model.addPart(partSet) +Part_2_doc = Part_2.document() +Box_16 = model.addBox(Part_2_doc, 10, 10, 10) +Cylinder_1 = model.addCylinder(Part_2_doc, model.selection("VERTEX", "PartSet/Origin"), model.selection("EDGE", "PartSet/OZ"), 5, 10) + +Part_3 = model.addPart(partSet) +Part_3_doc = Part_3.document() +Box_17 = model.addBox(Part_3_doc, 10, 10, 10) +Cylinder_1 = model.addCylinder(Part_3_doc, model.selection("VERTEX", "PartSet/Origin"), model.selection("EDGE", "PartSet/OZ"), 5, 10) +Point_4 = model.addPoint(partSet, -10, 0, 0) +Point_5 = model.addPoint(partSet, 20, 20, 0) + +model.do() + +# Create Rotations +Rotation_1 = model.addRotation(Part_1_doc, [model.selection("SOLID", "Box_1_1")], model.selection("EDGE", "PartSet/OZ"), 45) +Rotation_2 = model.addRotation(Part_1_doc, [model.selection("SOLID", "Box_2_1")], model.selection("EDGE", "PartSet/OZ"), 0) +Rotation_3 = model.addRotation(Part_1_doc, [model.selection("SOLID", "Box_3_1")], model.selection("EDGE", "PartSet/OZ"), 360) +Rotation_4 = model.addRotation(Part_1_doc, [model.selection("SOLID", "Box_4_1")], model.selection("EDGE", "PartSet/OZ"), -360) +Rotation_5 = model.addRotation(Part_1_doc, [model.selection("SOLID", "Box_5_1")], model.selection("EDGE", "PartSet/OZ"), 450) +Rotation_6 = model.addRotation(Part_1_doc, [model.selection("SOLID", "Box_6_1")], model.selection("EDGE", "PartSet/OZ"), -450) +Rotation_7 = model.addRotation(Part_1_doc, [model.selection("SOLID", "Box_7_1")], model.selection("EDGE", "InvalidName"), 180) + +Rotation_9 = model.addRotation(Part_1_doc, [model.selection("SOLID", "Box_8_1")], model.selection("VERTEX", "PartSet/Origin"), model.selection("VERTEX", "Point_1"), model.selection("VERTEX", "Point_2")) +Rotation_10 = model.addRotation(Part_1_doc, [model.selection("SOLID", "Box_9_1")], model.selection("VERTEX", "Point_3"), model.selection("VERTEX", "Point_1"), model.selection("VERTEX", "Point_2")) +Rotation_11 = model.addRotation(Part_1_doc, [model.selection("SOLID", "Box_10_1")], model.selection("VERTEX", "Point_3"), model.selection("VERTEX", "Point_1"), model.selection("VERTEX", "Point_1")) +Rotation_12 = model.addRotation(Part_1_doc, [model.selection("SOLID", "Box_11_1")], model.selection("VERTEX", "Point_3"), model.selection("VERTEX", "Point_3"), model.selection("VERTEX", "Point_1")) +Rotation_13 = model.addRotation(Part_1_doc, [model.selection("SOLID", "Box_12_1")], model.selection("VERTEX", "Point_3"), model.selection("VERTEX", "Point_1"), model.selection("VERTEX", "Point_3")) +Rotation_14 = model.addRotation(Part_1_doc, [model.selection("SOLID", "Box_13_1")], model.selection("VERTEX", "PartSet/Origin"), model.selection("VERTEX", "Point_1"), model.selection("VERTEX", "InvalidName")) +Rotation_15 = model.addRotation(Part_1_doc, [model.selection("SOLID", "Box_14_1")], model.selection("VERTEX", "InvalidName"), model.selection("VERTEX", "Point_3"), model.selection("VERTEX", "Point_2")) +Rotation_16 = model.addRotation(Part_1_doc, [model.selection("SOLID", "Box_15_1")], model.selection("VERTEX", "PartSet/Origin"), model.selection("VERTEX", "InvalidName"), model.selection("VERTEX", "Point_1")) + +Rotation_18 = model.addRotation(partSet, [model.selection("COMPOUND", "Part_2/")], model.selection("EDGE", "OY"), 90) +Rotation_19 = model.addRotation(partSet, [model.selection("COMPOUND", "Part_3/")], model.selection("VERTEX", "Origin"), model.selection("VERTEX", "Point_2"), model.selection("VERTEX", "Point_3")) + +model.do() +model.end() + +# Checks +from GeomAPI import GeomAPI_Shape + +model.testNbResults(Rotation_1, 1) +model.testNbSubResults(Rotation_1, [0]) +model.testNbSubShapes(Rotation_1, GeomAPI_Shape.SOLID, [1]) +model.testNbSubShapes(Rotation_1, GeomAPI_Shape.FACE, [6]) +model.testHaveNamingFaces(Rotation_1, model, Part_1_doc) + +model.testNbResults(Rotation_2, 1) +model.testNbSubResults(Rotation_2, [0]) +model.testNbSubShapes(Rotation_2, GeomAPI_Shape.SOLID, [1]) +model.testNbSubShapes(Rotation_2, GeomAPI_Shape.FACE, [6]) +model.testHaveNamingFaces(Rotation_2, model, Part_1_doc) + +model.testNbResults(Rotation_3, 1) +model.testNbSubResults(Rotation_3, [0]) +model.testNbSubShapes(Rotation_3, GeomAPI_Shape.SOLID, [1]) +model.testNbSubShapes(Rotation_3, GeomAPI_Shape.FACE, [6]) +model.testHaveNamingFaces(Rotation_3, model, Part_1_doc) + +model.testNbResults(Rotation_4, 1) +model.testNbSubResults(Rotation_4, [0]) +model.testNbSubShapes(Rotation_4, GeomAPI_Shape.SOLID, [1]) +model.testNbSubShapes(Rotation_4, GeomAPI_Shape.FACE, [6]) +model.testHaveNamingFaces(Rotation_4, model, Part_1_doc) + +model.testNbResults(Rotation_9, 1) +model.testNbSubResults(Rotation_9, [0]) +model.testNbSubShapes(Rotation_9, GeomAPI_Shape.SOLID, [1]) +model.testNbSubShapes(Rotation_9, GeomAPI_Shape.FACE, [6]) +model.testHaveNamingFaces(Rotation_9, model, Part_1_doc) + +model.testNbResults(Rotation_10, 1) +model.testNbSubResults(Rotation_10, [0]) +model.testNbSubShapes(Rotation_10, GeomAPI_Shape.SOLID, [1]) +model.testNbSubShapes(Rotation_10, GeomAPI_Shape.FACE, [6]) +model.testHaveNamingFaces(Rotation_10, model, Part_1_doc) + +model.testNbResults(Rotation_18, 1) +model.testNbSubResults(Rotation_18, [0]) + +model.testNbResults(Rotation_19, 1) +model.testNbSubResults(Rotation_19, [0]) + + +model.testNbResults(Rotation_5, 0) +assert(Rotation_5.feature().error() == 'Rotation builder :: angle greater than 360 degrees.') + +model.testNbResults(Rotation_6, 0) +assert(Rotation_6.feature().error() == 'Rotation builder :: angle smaller than -360 degrees.') + +model.testNbResults(Rotation_7, 0) +assert(Rotation_7.feature().error() == 'Attribute "axis_object" is not initialized.') + +model.testNbResults(Rotation_11, 0) +assert(Rotation_11.feature().error() == "The feature uses equal shapes.") + +model.testNbResults(Rotation_12, 0) +assert(Rotation_12.feature().error() == "The feature uses equal shapes.") + +model.testNbResults(Rotation_13, 0) +assert(Rotation_13.feature().error() == "The feature uses equal shapes.") + +model.testNbResults(Rotation_14, 0) +assert(Rotation_14.feature().error() == 'Attribute "end_point" is not initialized.') + +model.testNbResults(Rotation_15, 0) +assert(Rotation_15.feature().error() == 'Attribute "center_point" is not initialized.') + +model.testNbResults(Rotation_16, 0) +assert(Rotation_16.feature().error() == 'Attribute "start_point" is not initialized.') + + + + +#Rotation_8 = model.addRotation(Part_1_doc, [model.selection("SOLID", "InvalidName")], model.selection("EDGE", "PartSet/OZ"), 180) +#Rotation_17 = model.addRotation(Part_1_doc, [model.selection("SOLID", "InvalidName")], model.selection("VERTEX", "PartSet/Origin"), model.selection("VERTEX", "Point_3"), model.selection("VERTEX", "Point_2")) + +#model.testNbResults(Rotation_8, 0) +#assert(Rotation_8.feature().error() == 'Attribute "main_object" is not initialized.') + +#model.testNbResults(Rotation_17, 0) +#assert(Rotation_17.feature().error() == 'Attribute "main_object" is not initialized.') \ No newline at end of file diff --git a/test.API/SHAPER/Transformations/TestScale.py b/test.API/SHAPER/Transformations/TestScale.py index f0a33e077..94e033664 100644 --- a/test.API/SHAPER/Transformations/TestScale.py +++ b/test.API/SHAPER/Transformations/TestScale.py @@ -2,36 +2,183 @@ Test case for Scale feature. Written on High API. """ -from ModelAPI import * -from GeomAPI import * - from salome.shaper import model -# Get session -aSession = ModelAPI_Session.get() - -# Create a part -aDocument = aSession.activeDocument() -aSession.startOperation() -model.addPart(aDocument) -aDocument = aSession.activeDocument() -aSession.finishOperation() - -# Create a box -aSession.startOperation() -aCenterPoint = model.addPoint(aDocument, 20, 20, 0).result() -aBox1 = model.addBox(aDocument, 10, 10, 10) -aBox2 = model.addBox(aDocument, 10, 10, 10) -aSession.finishOperation() - -# Perform a symmetry by a point -aSession.startOperation() -aScale1 = model.addScale(aDocument, [model.selection("SOLID", "Box_1_1")], aCenterPoint, 2.0).result() -aSession.finishOperation() -assert (aScale1 is not None) - -# Perform a symmetry by an axis -aSession.startOperation() -aScale2 = model.addScale(aDocument, [model.selection("SOLID", "Box_2_1")], aCenterPoint, -0.5, 2, 3.7).result() -aSession.finishOperation() -assert (aScale2 is not None) \ No newline at end of file +model.begin() +partSet = model.moduleDocument() +Part_1 = model.addPart(partSet) +Part_1_doc = Part_1.document() + +# Create Boxes +Box_1 = model.addBox(Part_1_doc, 10, 10, 10) +Box_2 = model.addBox(Part_1_doc, 10, 10, 10) +Box_3 = model.addBox(Part_1_doc, 10, 10, 10) +Box_4 = model.addBox(Part_1_doc, 10, 10, 10) +Box_5 = model.addBox(Part_1_doc, 10, 10, 10) +Box_6 = model.addBox(Part_1_doc, 10, 10, 10) +Box_7 = model.addBox(Part_1_doc, 10, 10, 10) +Box_8 = model.addBox(Part_1_doc, 10, 10, 10) +Box_9 = model.addBox(Part_1_doc, 10, 10, 10) +Box_10 = model.addBox(Part_1_doc, 10, 10, 10) +Box_11 = model.addBox(Part_1_doc, 10, 10, 10) +Box_12 = model.addBox(Part_1_doc, 10, 10, 10) +Box_13 = model.addBox(Part_1_doc, 10, 10, 10) +Box_14 = model.addBox(Part_1_doc, 10, 10, 10) +Box_15 = model.addBox(Part_1_doc, 10, 10, 10) +Box_16 = model.addBox(Part_1_doc, 10, 10, 10) +Box_17 = model.addBox(Part_1_doc, 10, 10, 10) +Box_18 = model.addBox(Part_1_doc, 10, 10, 10) + +# Create Sketches +Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOY")) +SketchLine_1 = Sketch_1.addLine(11.50379459310504, -12.39258082761096, 58.75227313132206, 54.23988890577205) + +Sketch_2 = model.addSketch(Part_1_doc, model.defaultPlane("XOY")) +SketchLine_2 = Sketch_2.addLine(41.58300156386008, 83.65088639460937, -69.84532559339473, 11.87498196448581) +SketchLine_3 = Sketch_2.addLine(-69.84532559339473, 11.87498196448581, -47.25850252097817, -30.78901717230093) +SketchLine_4 = Sketch_2.addLine(-47.25850252097817, -30.78901717230093, 108.3396119778911, -36.812169991612) +SketchLine_5 = Sketch_2.addLine(108.3396119778911, -36.812169991612, 35.05791934293975, 16.39234657896911) +SketchLine_6 = Sketch_2.addLine(35.05791934293975, 16.39234657896911, 41.58300156386008, 83.65088639460937) +SketchConstraintCoincidence_1 = Sketch_2.setCoincident(SketchLine_2.endPoint(), SketchLine_3.startPoint()) +SketchConstraintCoincidence_2 = Sketch_2.setCoincident(SketchLine_3.endPoint(), SketchLine_4.startPoint()) +SketchConstraintCoincidence_3 = Sketch_2.setCoincident(SketchLine_4.endPoint(), SketchLine_5.startPoint()) +SketchConstraintCoincidence_4 = Sketch_2.setCoincident(SketchLine_5.endPoint(), SketchLine_6.startPoint()) +SketchConstraintCoincidence_5 = Sketch_2.setCoincident(SketchLine_2.startPoint(), SketchLine_6.endPoint()) +model.do() + +# Create Points +Point_1 = model.addPoint(Part_1_doc, -10, -10, -10) + +# Create Vertexes +Vertex_1 = model.addVertex(Part_1_doc, [model.selection("VERTEX", "Sketch_1/Vertex-SketchLine_1e")]) + +# Create Wire & Extrusion +Wire_1 = model.addWire(Part_1_doc, [model.selection("WIRE", "Sketch_2/Wire-SketchLine_2f-SketchLine_3f-SketchLine_4f-SketchLine_5f-SketchLine_6f")]) +Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("WIRE", "Wire_1_1")], model.selection(), 50, 0) + +# Create Scales +Scale_1 = model.addScale(Part_1_doc, [model.selection("SOLID", "Box_1_1")] , model.selection("VERTEX", "PartSet/Origin"), 2) +Scale_2 = model.addScale(Part_1_doc, [model.selection("SOLID", "Box_2_1")] , model.selection("VERTEX", "Point_1"), 2) +Scale_3 = model.addScale(Part_1_doc, [model.selection("SOLID", "Box_3_1")] , model.selection("VERTEX", "Box_3_1/Back&Box_3_1/Left&Box_3_1/Top"), 2) +Scale_4 = model.addScale(Part_1_doc, [model.selection("SOLID", "Box_4_1")] , model.selection("VERTEX", "Sketch_1/Vertex-SketchLine_1e"), 2) +Scale_5 = model.addScale(Part_1_doc, [model.selection("SOLID", "Box_5_1")] , model.selection("VERTEX", "Vertex_1_1"), 2) +Scale_6 = model.addScale(Part_1_doc, [model.selection("SOLID", "Box_6_1")] , model.selection("VERTEX", "PartSet/Origin"), 0) +Scale_7 = model.addScale(Part_1_doc, [model.selection("SOLID", "Box_7_1")] , model.selection("VERTEX", "PartSet/Origin"), -3) +Scale_8 = model.addScale(Part_1_doc, [model.selection("SOLID", "Box_8_1")] , model.selection("VERTEX", "InvalidName"), 2) +Scale_9 = model.addScale(Part_1_doc, [model.selection("SOLID", "Box_9_1")] , model.selection("VERTEX", "PartSet/Origin"), 2 , 3, 1) +Scale_10 = model.addScale(Part_1_doc, [model.selection("SOLID", "Box_10_1")] , model.selection("VERTEX", "Point_1"), 2 , 3, 1) +Scale_11 = model.addScale(Part_1_doc, [model.selection("SOLID", "Box_11_1")] , model.selection("VERTEX", "Box_11_1/Back&Box_11_1/Right&Box_11_1/Top"), 2 , 3, 1) +Scale_12 = model.addScale(Part_1_doc, [model.selection("SOLID", "Box_12_1")] , model.selection("VERTEX", "Sketch_1/Vertex-SketchLine_1e"), 2 , 3, 1) +Scale_13 = model.addScale(Part_1_doc, [model.selection("SOLID", "Box_13_1")] , model.selection("VERTEX", "Vertex_1_1"), 2 , 3, 1) +Scale_14 = model.addScale(Part_1_doc, [model.selection("SOLID", "Box_14_1")] , model.selection("VERTEX", "PartSet/Origin"), 0 , 3, 1) +Scale_15 = model.addScale(Part_1_doc, [model.selection("SOLID", "Box_15_1")] , model.selection("VERTEX", "PartSet/Origin"), 2 , 0, 1) +Scale_16 = model.addScale(Part_1_doc, [model.selection("SOLID", "Box_16_1")] , model.selection("VERTEX", "PartSet/Origin"), 2 , 3, 0) +Scale_17 = model.addScale(Part_1_doc, [model.selection("SOLID", "Box_17_1")] , model.selection("VERTEX", "PartSet/Origin"), -2 , -3, -0.5) +Scale_18 = model.addScale(Part_1_doc, [model.selection("SOLID", "Box_18_1")] , model.selection("VERTEX", "InvalidName"), 2 , 3, 1) +Scale_19 = model.addScale(Part_1_doc, [model.selection("SHELL", "Extrusion_1_1")] , model.selection("VERTEX", "PartSet/Origin"), 5) + +model.do() +model.end() + + +# Checks +from GeomAPI import GeomAPI_Shape + +model.testNbResults(Scale_1, 1) +model.testNbSubResults(Scale_1, [0]) +model.testNbSubShapes(Scale_1, GeomAPI_Shape.SOLID, [1]) +model.testNbSubShapes(Scale_1, GeomAPI_Shape.FACE, [6]) +model.testHaveNamingFaces(Scale_1, model, Part_1_doc) + +model.testNbResults(Scale_2, 1) +model.testNbSubResults(Scale_2, [0]) +model.testNbSubShapes(Scale_2, GeomAPI_Shape.SOLID, [1]) +model.testNbSubShapes(Scale_2, GeomAPI_Shape.FACE, [6]) +model.testHaveNamingFaces(Scale_2, model, Part_1_doc) + +model.testNbResults(Scale_3, 1) +model.testNbSubResults(Scale_3, [0]) +model.testNbSubShapes(Scale_3, GeomAPI_Shape.SOLID, [1]) +model.testNbSubShapes(Scale_3, GeomAPI_Shape.FACE, [6]) +model.testHaveNamingFaces(Scale_3, model, Part_1_doc) + +model.testNbResults(Scale_4, 1) +model.testNbSubResults(Scale_4, [0]) +model.testNbSubShapes(Scale_4, GeomAPI_Shape.SOLID, [1]) +model.testNbSubShapes(Scale_4, GeomAPI_Shape.FACE, [6]) +model.testHaveNamingFaces(Scale_4, model, Part_1_doc) + +model.testNbResults(Scale_5, 1) +model.testNbSubResults(Scale_5, [0]) +model.testNbSubShapes(Scale_5, GeomAPI_Shape.SOLID, [1]) +model.testNbSubShapes(Scale_5, GeomAPI_Shape.FACE, [6]) +model.testHaveNamingFaces(Scale_5, model, Part_1_doc) + +model.testNbResults(Scale_7, 1) +model.testNbSubResults(Scale_7, [0]) +model.testNbSubShapes(Scale_7, GeomAPI_Shape.SOLID, [1]) +model.testNbSubShapes(Scale_7, GeomAPI_Shape.FACE, [6]) +model.testHaveNamingFaces(Scale_7, model, Part_1_doc) + +model.testNbResults(Scale_9, 1) +model.testNbSubResults(Scale_9, [0]) +model.testNbSubShapes(Scale_9, GeomAPI_Shape.SOLID, [1]) +model.testNbSubShapes(Scale_9, GeomAPI_Shape.FACE, [6]) +model.testHaveNamingFaces(Scale_9, model, Part_1_doc) + +model.testNbResults(Scale_10, 1) +model.testNbSubResults(Scale_10, [0]) +model.testNbSubShapes(Scale_10, GeomAPI_Shape.SOLID, [1]) +model.testNbSubShapes(Scale_10, GeomAPI_Shape.FACE, [6]) +model.testHaveNamingFaces(Scale_10, model, Part_1_doc) + +model.testNbResults(Scale_11, 1) +model.testNbSubResults(Scale_11, [0]) +model.testNbSubShapes(Scale_11, GeomAPI_Shape.SOLID, [1]) +model.testNbSubShapes(Scale_11, GeomAPI_Shape.FACE, [6]) +model.testHaveNamingFaces(Scale_11, model, Part_1_doc) + +model.testNbResults(Scale_12, 1) +model.testNbSubResults(Scale_12, [0]) +model.testNbSubShapes(Scale_12, GeomAPI_Shape.SOLID, [1]) +model.testNbSubShapes(Scale_12, GeomAPI_Shape.FACE, [6]) +model.testHaveNamingFaces(Scale_12, model, Part_1_doc) + +model.testNbResults(Scale_13, 1) +model.testNbSubResults(Scale_13, [0]) +model.testNbSubShapes(Scale_13, GeomAPI_Shape.SOLID, [1]) +model.testNbSubShapes(Scale_13, GeomAPI_Shape.FACE, [6]) +model.testHaveNamingFaces(Scale_13, model, Part_1_doc) + +model.testNbResults(Scale_17, 1) +model.testNbSubResults(Scale_17, [0]) +model.testNbSubShapes(Scale_17, GeomAPI_Shape.SOLID, [1]) +model.testNbSubShapes(Scale_17, GeomAPI_Shape.FACE, [6]) +model.testHaveNamingFaces(Scale_17, model, Part_1_doc) + + +model.testNbResults(Scale_6, 0) +assert(Scale_6.feature().error() == 'Scale builder :: the scale factor is null.') + +model.testNbResults(Scale_8, 0) +assert(Scale_8.feature().error() == 'Attribute "center_point" is not initialized.') + +model.testNbResults(Scale_14, 0) +assert(Scale_14.feature().error() == 'Scale builder :: the scale factor in X is null.') + +model.testNbResults(Scale_15, 0) +assert(Scale_15.feature().error() == 'Scale builder :: the scale factor in Y is null.') + +model.testNbResults(Scale_16, 0) +assert(Scale_16.feature().error() == 'Scale builder :: the scale factor in Z is null.') + +model.testNbResults(Scale_18, 0) +assert(Scale_18.feature().error() == 'Attribute "center_point" is not initialized.') + +# To uncomment when #2046 will be performed +#model.testNbResults(Scale_19, 1) +#model.testNbSubResults(Scale_19, [0]) +#model.testNbSubShapes(Scale_19, GeomAPI_Shape.SHELL, [1]) +#model.testNbSubShapes(Scale_19, GeomAPI_Shape.SOLID, [0]) +#model.testNbSubShapes(Scale_19, GeomAPI_Shape.FACE, [5]) +#model.testHaveNamingFaces(Scale_19, model, Part_1_doc) \ No newline at end of file diff --git a/test.API/SHAPER/Transformations/TestSymmetry.py b/test.API/SHAPER/Transformations/TestSymmetry.py index 97aca11e8..4d5703cc3 100644 --- a/test.API/SHAPER/Transformations/TestSymmetry.py +++ b/test.API/SHAPER/Transformations/TestSymmetry.py @@ -2,46 +2,212 @@ Test case for Symmetry feature. Written on High API. """ -from ModelAPI import * -from GeomAPI import * - from salome.shaper import model -# Get session -aSession = ModelAPI_Session.get() - -# Create a part -aDocument = aSession.activeDocument() -aSession.startOperation() -model.addPart(aDocument) -aDocument = aSession.activeDocument() -aSession.finishOperation() - -# Create a box -aSession.startOperation() -aBox1 = model.addBox(aDocument, 10, 10, 10) -aBox2 = model.addBox(aDocument, 10, 10, 10) -aBox3 = model.addBox(aDocument, 10, 10, 10) -aSession.finishOperation() - -# Perform a symmetry by a point -aSession.startOperation() -aPoint = model.addPoint(aDocument, 0, 0, 0).result() -aSymmetry1 = model.addSymmetry(aDocument, [model.selection("SOLID", "Box_1_1")], aPoint).result() -aSession.finishOperation() -assert (aSymmetry1 is not None) - -# Perform a symmetry by an axis -aSession.startOperation() -anAxis = model.addAxis(aDocument, 10, 0, 0).result() -aSymmetry2 = model.addSymmetry(aDocument, [model.selection("SOLID", "Box_2_1")], anAxis).result() -aSession.finishOperation() -assert (aSymmetry2 is not None) - -# Perform a symmetry by a plane -aSession.startOperation() -aPoint1 = model.addPoint(aDocument, 0, 0, 0).result() -aPoint2 = model.addPoint(aDocument, 10, 10, 0).result() -aSymmetry3 = model.addSymmetry(aDocument, [model.selection("SOLID", "Box_3_1")], model.selection("FACE", "Box_3_1/Top")).result() -aSession.finishOperation() -assert (aSymmetry3 is not None) \ No newline at end of file +model.begin() +partSet = model.moduleDocument() +Part_1 = model.addPart(partSet) +Part_1_doc = Part_1.document() + +# Boxes +Box_1 = model.addBox(Part_1_doc, 10, 10, 10) +Box_2 = model.addBox(Part_1_doc, 10, 10, 10) +Box_3 = model.addBox(Part_1_doc, 10, 10, 10) +Box_4 = model.addBox(Part_1_doc, 10, 10, 10) +Box_5 = model.addBox(Part_1_doc, 10, 10, 10) +Box_6 = model.addBox(Part_1_doc, 10, 10, 10) +Box_7 = model.addBox(Part_1_doc, 10, 10, 10) +Box_8 = model.addBox(Part_1_doc, 10, 10, 10) +Box_9 = model.addBox(Part_1_doc, 10, 10, 10) +Box_10 = model.addBox(Part_1_doc, 10, 10, 10) +Box_11 = model.addBox(Part_1_doc, 10, 10, 10) +Box_12 = model.addBox(Part_1_doc, 10, 10, 10) +Box_13 = model.addBox(Part_1_doc, 10, 10, 10) +Box_14 = model.addBox(Part_1_doc, 10, 10, 10) +Box_15 = model.addBox(Part_1_doc, 10, 10, 10) +Box_16 = model.addBox(Part_1_doc, 10, 10, 10) +Box_17 = model.addBox(Part_1_doc, 10, 10, 10) + +# Points +Point_1 = model.addPoint(Part_1_doc, -10, -10, -10) + +# Axes +Axis_1 = model.addAxis(Part_1_doc, 10, 10, 20) + +# Sketches +# Sketch comportant une ligne n'ayant dont les extremites ne coincident pas avec l'origine +Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOY")) +SketchLine_1 = Sketch_1.addLine(-60.61265429508839, -83.21124437581197, 133.0036727560886, 114.0582209216138) + +# Sketch comportant une contour ferme de 4 lignes +Sketch_2 = model.addSketch(Part_1_doc, model.defaultPlane("XOY")) +SketchLine_2 = Sketch_2.addLine(82.71019756173548, 167.8442841418389, -114.8596207554555, -2.66979472427181) +SketchLine_3 = Sketch_2.addLine(-114.8596207554555, -2.66979472427181, 102.2154980962352, -58.03968011252918) +SketchLine_4 = Sketch_2.addLine(102.2154980962352, -58.03968011252918, 240.6402115668787, 65.28415552495312) +SketchLine_5 = Sketch_2.addLine(240.6402115668787, 65.28415552495312, 82.71019756173548, 167.8442841418389) +SketchConstraintCoincidence_1 = Sketch_2.setCoincident(SketchLine_2.endPoint(), SketchLine_3.startPoint()) +SketchConstraintCoincidence_2 = Sketch_2.setCoincident(SketchLine_3.endPoint(), SketchLine_4.startPoint()) +SketchConstraintCoincidence_3 = Sketch_2.setCoincident(SketchLine_4.endPoint(), SketchLine_5.startPoint()) +SketchConstraintCoincidence_4 = Sketch_2.setCoincident(SketchLine_2.startPoint(), SketchLine_5.endPoint()) + +# Sketch comportant un contour ferme de 5 lignes +Sketch_3 = model.addSketch(Part_1_doc, model.defaultPlane("XOY")) +SketchLine_6 = Sketch_3.addLine(26.85462764597397, 67.26291526312015, -53.39765785606262, 39.86755675840885) +SketchLine_7 = Sketch_3.addLine(-53.39765785606262, 39.86755675840885, -33.73745939974039, -8.799491879372397) +SketchLine_8 = Sketch_3.addLine(-33.73745939974039, -8.799491879372397, 33.30059435296487, -32.6495686952387) +SketchLine_9 = Sketch_3.addLine(33.30059435296487, -32.6495686952387, 19.44176593293446, 18.5958666253389) +SketchLine_10 = Sketch_3.addLine(19.44176593293446, 18.5958666253389, 26.85462764597397, 67.26291526312015) +SketchConstraintCoincidence_1 = Sketch_3.setCoincident(SketchLine_6.endPoint(), SketchLine_7.startPoint()) +SketchConstraintCoincidence_2 = Sketch_3.setCoincident(SketchLine_7.endPoint(), SketchLine_8.startPoint()) +SketchConstraintCoincidence_3 = Sketch_3.setCoincident(SketchLine_8.endPoint(), SketchLine_9.startPoint()) +SketchConstraintCoincidence_4 = Sketch_3.setCoincident(SketchLine_9.endPoint(), SketchLine_10.startPoint()) +SketchConstraintCoincidence_5 = Sketch_3.setCoincident(SketchLine_6.startPoint(), SketchLine_10.endPoint()) + +model.do() + +# Vertexes +Vertex_1 = model.addVertex(Part_1_doc, [model.selection("VERTEX", "Sketch_1/Vertex-SketchLine_1e")]) + +# Edges +Edge_1 = model.addEdge(Part_1_doc, [model.selection("EDGE", "Sketch_1/Edge-SketchLine_1")]) + +# Wire & Extrusion +Wire_1 = model.addWire(Part_1_doc, [model.selection("WIRE", "Sketch_3/Wire-SketchLine_6f-SketchLine_7f-SketchLine_8f-SketchLine_9f-SketchLine_10f")]) +Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("WIRE", "Wire_1_1")], model.selection(), 50, 0) + +# Planes +Plane_1 = model.addPlane(Part_1_doc, model.selection("FACE", "Box_14_1/Top"), 10, False) +Plane_2 = model.addPlane(Part_1_doc, model.selection("FACE", "PartSet/XOZ"), 40, False) + +# Faces +Face_1 = model.addFace(Part_1_doc, [model.selection("WIRE", "Sketch_2/Wire-SketchLine_2f-SketchLine_3f-SketchLine_4f-SketchLine_5f")]) + + +# Symmetries +Symmetry_1 = model.addSymmetry(Part_1_doc, [model.selection("SOLID", "Box_1_1")], model.selection("VERTEX", "PartSet/Origin")) +Symmetry_2 = model.addSymmetry(Part_1_doc, [model.selection("SOLID", "Box_2_1")], model.selection("VERTEX", "Point_1")) +Symmetry_3 = model.addSymmetry(Part_1_doc, [model.selection("SOLID", "Box_3_1")], model.selection("VERTEX", "Box_3_1/Front&Box_3_1/Right&Box_3_1/Top")) +Symmetry_4 = model.addSymmetry(Part_1_doc, [model.selection("SOLID", "Box_4_1")], model.selection("VERTEX", "Sketch_1/Vertex-SketchLine_1e")) +Symmetry_5 = model.addSymmetry(Part_1_doc, [model.selection("SOLID", "Box_5_1")], model.selection("VERTEX", "Vertex_1_1")) +Symmetry_6 = model.addSymmetry(Part_1_doc, [model.selection("SOLID", "Box_6_1")], model.selection("VERTEX", "InvalidName")) + +Symmetry_7 = model.addSymmetry(Part_1_doc, [model.selection("SOLID", "Box_7_1")], model.selection("EDGE", "PartSet/OZ")) +Symmetry_8 = model.addSymmetry(Part_1_doc, [model.selection("SOLID", "Box_8_1")], model.selection("EDGE", "Axis_1")) +Symmetry_9 = model.addSymmetry(Part_1_doc, [model.selection("SOLID", "Box_9_1")], model.selection("EDGE", "Box_9_1/Front&Box_9_1/Top")) +Symmetry_10 = model.addSymmetry(Part_1_doc, [model.selection("SOLID", "Box_10_1")], model.selection("EDGE", "Sketch_1/Edge-SketchLine_1")) +Symmetry_11 = model.addSymmetry(Part_1_doc, [model.selection("SOLID", "Box_11_1")], model.selection("EDGE", "Edge_1_1")) +Symmetry_12 = model.addSymmetry(Part_1_doc, [model.selection("SOLID", "Box_12_1")], model.selection("EDGE", "InvalidName")) + +Symmetry_13 = model.addSymmetry(Part_1_doc, [model.selection("SOLID", "Box_13_1")], model.selection("FACE", "PartSet/XOY")) +Symmetry_14 = model.addSymmetry(Part_1_doc, [model.selection("SOLID", "Box_14_1")], model.selection("FACE", "Plane_1")) +Symmetry_15 = model.addSymmetry(Part_1_doc, [model.selection("SOLID", "Box_15_1")], model.selection("FACE", "Box_15_1/Front")) +Symmetry_16 = model.addSymmetry(Part_1_doc, [model.selection("SOLID", "Box_16_1")], model.selection("FACE", "Face_1_1")) +Symmetry_17 = model.addSymmetry(Part_1_doc, [model.selection("SOLID", "Box_17_1")], model.selection("FACE", "InvalidName")) +Symmetry_18 = model.addSymmetry(Part_1_doc, [model.selection("SHELL", "Extrusion_1_1")], model.selection("FACE", "Plane_2")) + +model.do() +model.end() + +# Checks +from GeomAPI import GeomAPI_Shape + +model.testNbResults(Symmetry_1, 1) +model.testNbSubResults(Symmetry_1, [0]) +model.testNbSubShapes(Symmetry_1, GeomAPI_Shape.SOLID, [1]) +model.testNbSubShapes(Symmetry_1, GeomAPI_Shape.FACE, [6]) +model.testHaveNamingFaces(Symmetry_1, model, Part_1_doc) + +model.testNbResults(Symmetry_2, 1) +model.testNbSubResults(Symmetry_2, [0]) +model.testNbSubShapes(Symmetry_2, GeomAPI_Shape.SOLID, [1]) +model.testNbSubShapes(Symmetry_2, GeomAPI_Shape.FACE, [6]) +model.testHaveNamingFaces(Symmetry_2, model, Part_1_doc) + +model.testNbResults(Symmetry_3, 1) +model.testNbSubResults(Symmetry_3, [0]) +model.testNbSubShapes(Symmetry_3, GeomAPI_Shape.SOLID, [1]) +model.testNbSubShapes(Symmetry_3, GeomAPI_Shape.FACE, [6]) +model.testHaveNamingFaces(Symmetry_3, model, Part_1_doc) + +model.testNbResults(Symmetry_4, 1) +model.testNbSubResults(Symmetry_4, [0]) +model.testNbSubShapes(Symmetry_4, GeomAPI_Shape.SOLID, [1]) +model.testNbSubShapes(Symmetry_4, GeomAPI_Shape.FACE, [6]) +model.testHaveNamingFaces(Symmetry_4, model, Part_1_doc) + +model.testNbResults(Symmetry_5, 1) +model.testNbSubResults(Symmetry_5, [0]) +model.testNbSubShapes(Symmetry_5, GeomAPI_Shape.SOLID, [1]) +model.testNbSubShapes(Symmetry_5, GeomAPI_Shape.FACE, [6]) +model.testHaveNamingFaces(Symmetry_5, model, Part_1_doc) + +model.testNbResults(Symmetry_7, 1) +model.testNbSubResults(Symmetry_7, [0]) +model.testNbSubShapes(Symmetry_7, GeomAPI_Shape.SOLID, [1]) +model.testNbSubShapes(Symmetry_7, GeomAPI_Shape.FACE, [6]) +model.testHaveNamingFaces(Symmetry_7, model, Part_1_doc) + +model.testNbResults(Symmetry_8, 1) +model.testNbSubResults(Symmetry_8, [0]) +model.testNbSubShapes(Symmetry_8, GeomAPI_Shape.SOLID, [1]) +model.testNbSubShapes(Symmetry_8, GeomAPI_Shape.FACE, [6]) +model.testHaveNamingFaces(Symmetry_8, model, Part_1_doc) + +model.testNbResults(Symmetry_9, 1) +model.testNbSubResults(Symmetry_9, [0]) +model.testNbSubShapes(Symmetry_9, GeomAPI_Shape.SOLID, [1]) +model.testNbSubShapes(Symmetry_9, GeomAPI_Shape.FACE, [6]) +model.testHaveNamingFaces(Symmetry_9, model, Part_1_doc) + +model.testNbResults(Symmetry_10, 1) +model.testNbSubResults(Symmetry_10, [0]) +model.testNbSubShapes(Symmetry_10, GeomAPI_Shape.SOLID, [1]) +model.testNbSubShapes(Symmetry_10, GeomAPI_Shape.FACE, [6]) +model.testHaveNamingFaces(Symmetry_10, model, Part_1_doc) + +model.testNbResults(Symmetry_11, 1) +model.testNbSubResults(Symmetry_11, [0]) +model.testNbSubShapes(Symmetry_11, GeomAPI_Shape.SOLID, [1]) +model.testNbSubShapes(Symmetry_11, GeomAPI_Shape.FACE, [6]) +model.testHaveNamingFaces(Symmetry_11, model, Part_1_doc) + +model.testNbResults(Symmetry_13, 1) +model.testNbSubResults(Symmetry_13, [0]) +model.testNbSubShapes(Symmetry_13, GeomAPI_Shape.SOLID, [1]) +model.testNbSubShapes(Symmetry_13, GeomAPI_Shape.FACE, [6]) +model.testHaveNamingFaces(Symmetry_13, model, Part_1_doc) + +model.testNbResults(Symmetry_14, 1) +model.testNbSubResults(Symmetry_14, [0]) +model.testNbSubShapes(Symmetry_14, GeomAPI_Shape.SOLID, [1]) +model.testNbSubShapes(Symmetry_14, GeomAPI_Shape.FACE, [6]) +model.testHaveNamingFaces(Symmetry_14, model, Part_1_doc) + +model.testNbResults(Symmetry_15, 1) +model.testNbSubResults(Symmetry_15, [0]) +model.testNbSubShapes(Symmetry_15, GeomAPI_Shape.SOLID, [1]) +model.testNbSubShapes(Symmetry_15, GeomAPI_Shape.FACE, [6]) +model.testHaveNamingFaces(Symmetry_15, model, Part_1_doc) + +model.testNbResults(Symmetry_16, 1) +model.testNbSubResults(Symmetry_16, [0]) +model.testNbSubShapes(Symmetry_16, GeomAPI_Shape.SOLID, [1]) +model.testNbSubShapes(Symmetry_16, GeomAPI_Shape.FACE, [6]) +model.testHaveNamingFaces(Symmetry_16, model, Part_1_doc) + +model.testNbResults(Symmetry_6, 0) +assert(Symmetry_6.feature().error() == 'Attribute "point_object" is not initialized.') + +model.testNbResults(Symmetry_12, 0) +assert(Symmetry_12.feature().error() == 'Attribute "axis_object" is not initialized.') + +model.testNbResults(Symmetry_17, 0) +assert(Symmetry_17.feature().error() == 'Attribute "plane_object" is not initialized.') + +# To uncomment when #2046 will be performed +#model.testNbResults(Symmetry_18, 1) +#model.testNbSubResults(Symmetry_18, [0]) +#model.testNbSubShapes(Symmetry_18, GeomAPI_Shape.SOLID, [0]) +#model.testNbSubShapes(Symmetry_18, GeomAPI_Shape.SHELL, [1]) +#model.testNbSubShapes(Symmetry_18, GeomAPI_Shape.FACE, [5]) +#model.testHaveNamingFaces(Symmetry_18, model, Part_1_doc) \ No newline at end of file diff --git a/test.API/SHAPER/Transformations/TestTranslation_1.py b/test.API/SHAPER/Transformations/TestTranslation_1.py new file mode 100644 index 000000000..bcca30ef5 --- /dev/null +++ b/test.API/SHAPER/Transformations/TestTranslation_1.py @@ -0,0 +1,358 @@ +""" +Test case for Translation feature. +Written on High API. +""" +from salome.shaper import model + +model.begin() +partSet = model.moduleDocument() +Part_1 = model.addPart(partSet) +Part_1_doc = Part_1.document() + +# Boxes +Box_1 = model.addBox(Part_1_doc, 10, 20, 10) +Box_2 = model.addBox(Part_1_doc, 10, 20, 10) +Box_3 = model.addBox(Part_1_doc, 10, 20, 10) +Box_4 = model.addBox(Part_1_doc, 10, 20, 10) +Box_5 = model.addBox(Part_1_doc, 10, 20, 10) +Box_6 = model.addBox(Part_1_doc, 10, 20, 10) +Box_7 = model.addBox(Part_1_doc, 10, 20, 10) +Box_8 = model.addBox(Part_1_doc, 10, 20, 10) +Box_9 = model.addBox(Part_1_doc, 10, 20, 10) +Box_10 = model.addBox(Part_1_doc, 10, 20, 10) +Box_11 = model.addBox(Part_1_doc, 10, 20, 10) +Box_12 = model.addBox(Part_1_doc, 10, 20, 10) +Box_13 = model.addBox(Part_1_doc, 10, 20, 10) +Box_14 = model.addBox(Part_1_doc, 10, 20, 10) +Box_15 = model.addBox(Part_1_doc, 10, 20, 10) +Box_16 = model.addBox(Part_1_doc, 10, 20, 10) +Box_17 = model.addBox(Part_1_doc, 10, 20, 10) +Box_18 = model.addBox(Part_1_doc, 10, 20, 10) + +Part_2 = model.addPart(partSet) +Part_2_doc = Part_2.document() +Box_19 = model.addBox(Part_2_doc, 10, 20, 10) + +Part_3 = model.addPart(partSet) +Part_3_doc = Part_3.document() +Box_20 = model.addBox(Part_3_doc, 10, 20, 10) + +Part_4 = model.addPart(partSet) +Part_4_doc = Part_4.document() +Box_21 = model.addBox(Part_4_doc, 10, 20, 10) + +Part_5 = model.addPart(partSet) +Part_5_doc = Part_5.document() +Box_22 = model.addBox(Part_5_doc, 10, 20, 10) + +Part_6 = model.addPart(partSet) +Part_6_doc = Part_6.document() +Box_23 = model.addBox(Part_6_doc, 10, 20, 10) + +Part_7 = model.addPart(partSet) +Part_7_doc = Part_7.document() +Box_24 = model.addBox(Part_7_doc, 10, 20, 10) + +Part_8 = model.addPart(partSet) +Part_8_doc = Part_8.document() +Box_25 = model.addBox(Part_8_doc, 10, 20, 10) + +Part_9 = model.addPart(partSet) +Part_9_doc = Part_9.document() +Box_26 = model.addBox(Part_9_doc, 10, 20, 10) + +#################### +# Sketches +# Sketch contenant un triangle +Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOY")) +SketchLine_1 = Sketch_1.addLine(105.8795836373178, 106.9780351893485, -55.30451701345322, -118.6797057217308) +SketchLine_2 = Sketch_1.addLine(-55.30451701345322, -118.6797057217308, -134.9484255703047, 86.11891628160174) +SketchLine_3 = Sketch_1.addLine(-134.9484255703047, 86.11891628160174, 105.8795836373178, 106.9780351893485) +SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchLine_2.startPoint()) +SketchConstraintCoincidence_2 = Sketch_1.setCoincident(SketchLine_2.endPoint(), SketchLine_3.startPoint()) +SketchConstraintCoincidence_3 = Sketch_1.setCoincident(SketchLine_1.startPoint(), SketchLine_3.endPoint()) + +# Sketch contenant un cercle et une ligne droite ne coupant pas le cercle, tous deux contenus dans l'une des faces de la box 1 +Sketch_2 = model.addSketch(Part_2_doc, model.selection("FACE", "Box_1_1/Top")) +SketchCircle_1 = Sketch_2.addCircle(3.625538020086079, 17.57352941176471, 2.190441696184978) +SketchLine_4 = Sketch_2.addLine(2.442711482557598, 6.454964041059345, 8.035432938365913, 18.18483116518828) + +# Sketch contenant un cercle et une ligne droite ne coupant pas le cercle, tous deux contenus dans l'une des faces de la box 1 +Sketch_3 = model.addSketch(Part_1_doc, model.selection("FACE", "Box_1_1/Top")) +SketchCircle_2 = Sketch_3.addCircle(3.625538020086079, 17.57352941176471, 2.190441696184978) +SketchLine_5 = Sketch_3.addLine(2.442711482557598, 6.454964041059345, 8.035432938365913, 18.18483116518828) + +# Sketch contenant un cercle et une ligne droite ne coupant pas le cercle, tous deux contenus dans l'une des faces de la box 1 +Sketch_4 = model.addSketch(Part_3_doc, model.selection("FACE", "Box_1_1/Top")) +SketchCircle_3 = Sketch_4.addCircle(3.625538020086079, 17.57352941176471, 2.190441696184978) +SketchLine_6 = Sketch_4.addLine(2.442711482557598, 6.454964041059345, 8.035432938365913, 18.18483116518828) + +# Sketch contenant un cercle et une ligne droite ne coupant pas le cercle, tous deux contenus dans l'une des faces de la box 1 +Sketch_5 = model.addSketch(Part_4_doc, model.selection("FACE", "Box_1_1/Top")) +SketchCircle_4 = Sketch_5.addCircle(3.625538020086079, 17.57352941176471, 2.190441696184978) +SketchLine_7 = Sketch_5.addLine(2.442711482557598, 6.454964041059345, 8.035432938365913, 18.18483116518828) + +# Sketch contenant un cercle et une ligne droite ne coupant pas le cercle, tous deux contenus dans l'une des faces de la box 1 +Sketch_6 = model.addSketch(Part_5_doc, model.selection("FACE", "Box_1_1/Top")) +SketchCircle_5 = Sketch_6.addCircle(3.625538020086079, 17.57352941176471, 2.190441696184978) +SketchLine_8 = Sketch_6.addLine(2.442711482557598, 6.454964041059345, 8.035432938365913, 18.18483116518828) + +# Sketch contenant un cercle et une ligne droite ne coupant pas le cercle, tous deux contenus dans l'une des faces de la box 1 +Sketch_7 = model.addSketch(Part_6_doc, model.selection("FACE", "Box_1_1/Top")) +SketchCircle_6 = Sketch_7.addCircle(3.625538020086079, 17.57352941176471, 2.190441696184978) +SketchLine_9 = Sketch_7.addLine(2.442711482557598, 6.454964041059345, 8.035432938365913, 18.18483116518828) + +# Sketch contenant un cercle et une ligne droite ne coupant pas le cercle, tous deux contenus dans l'une des faces de la box 1 +Sketch_8 = model.addSketch(Part_7_doc, model.selection("FACE", "Box_1_1/Top")) +SketchCircle_7 = Sketch_8.addCircle(3.625538020086079, 17.57352941176471, 2.190441696184978) +SketchLine_10 = Sketch_8.addLine(2.442711482557598, 6.454964041059345, 8.035432938365913, 18.18483116518828) + +# Sketch contenant un cercle et une ligne droite ne coupant pas le cercle, tous deux contenus dans l'une des faces de la box 1 +Sketch_9 = model.addSketch(Part_8_doc, model.selection("FACE", "Box_1_1/Top")) +SketchCircle_8 = Sketch_9.addCircle(3.625538020086079, 17.57352941176471, 2.190441696184978) +SketchLine_11 = Sketch_9.addLine(2.442711482557598, 6.454964041059345, 8.035432938365913, 18.18483116518828) + +# Sketch contenant un cercle et une ligne droite ne coupant pas le cercle, tous deux contenus dans l'une des faces de la box 1 +Sketch_10 = model.addSketch(Part_9_doc, model.selection("FACE", "Box_1_1/Top")) +SketchCircle_9 = Sketch_10.addCircle(3.625538020086079, 17.57352941176471, 2.190441696184978) +SketchLine_12 = Sketch_10.addLine(2.442711482557598, 6.454964041059345, 8.035432938365913, 18.18483116518828) + +model.do() + +# Extrusions +Extrusion_1 = model.addExtrusion(Part_2_doc, [model.selection("WIRE", "Sketch_1/Wire-SketchCircle_1_2f")], model.selection(), 15, 0) +Extrusion_2 = model.addExtrusion(Part_1_doc, [model.selection("WIRE", "Sketch_2/Wire-SketchCircle_1_2f")], model.selection(), 15, 0) +Extrusion_3 = model.addExtrusion(Part_3_doc, [model.selection("WIRE", "Sketch_1/Wire-SketchCircle_1_2f")], model.selection(), 15, 0) +Extrusion_4 = model.addExtrusion(Part_4_doc, [model.selection("WIRE", "Sketch_1/Wire-SketchCircle_1_2f")], model.selection(), 15, 0) +Extrusion_5 = model.addExtrusion(Part_5_doc, [model.selection("WIRE", "Sketch_1/Wire-SketchCircle_1_2f")], model.selection(), 15, 0) +Extrusion_6 = model.addExtrusion(Part_6_doc, [model.selection("WIRE", "Sketch_1/Wire-SketchCircle_1_2f")], model.selection(), 15, 0) +Extrusion_7 = model.addExtrusion(Part_7_doc, [model.selection("WIRE", "Sketch_1/Wire-SketchCircle_1_2f")], model.selection(), 15, 0) +Extrusion_8 = model.addExtrusion(Part_8_doc, [model.selection("WIRE", "Sketch_1/Wire-SketchCircle_1_2f")], model.selection(), 15, 0) +Extrusion_9 = model.addExtrusion(Part_9_doc, [model.selection("WIRE", "Sketch_1/Wire-SketchCircle_1_2f")], model.selection(), 15, 0) + +# Edges +Edge_1 = model.addEdge(Part_1_doc, [model.selection("EDGE", "Sketch_1/Edge-SketchLine_2")]) +Edge_2 = model.addEdge(Part_7_doc, [model.selection("EDGE", "Sketch_1/Edge-SketchLine_1")]) + +# Axis +Axis_1 = model.addAxis(partSet, 10, 10, 10) + +# Parameters +model.addParameter(partSet, "d", "15") + +# Multitranslations +MultiTranslation_1 = model.addMultiTranslation(Part_1_doc, [model.selection("SOLID", "Box_10_1")], model.selection("EDGE", "PartSet/OX"), 15, 3, model.selection("EDGE", "PartSet/OY"), 15, 3) +MultiTranslation_2 = model.addMultiTranslation(Part_1_doc, [model.selection("SOLID", "Box_11_1")], model.selection("EDGE", "PartSet/OX"), 15, 3, model.selection("EDGE", "PartSet/OY"), 15, 3) +MultiTranslation_3 = model.addMultiTranslation(Part_1_doc, [model.selection("SOLID", "Box_12_1")], model.selection("EDGE", "PartSet/OX"), 15, 3, model.selection("EDGE", "PartSet/OY"), 15, 3) +MultiTranslation_4 = model.addMultiTranslation(Part_1_doc, [model.selection("SOLID", "Box_13_1")], model.selection("EDGE", "PartSet/OX"), 15, 3, model.selection("EDGE", "PartSet/OY"), 15, 3) +MultiTranslation_5 = model.addMultiTranslation(Part_1_doc, [model.selection("SOLID", "Box_14_1")], model.selection("EDGE", "PartSet/OX"), 15, 3, model.selection("EDGE", "PartSet/OY"), 15, 3) +MultiTranslation_6 = model.addMultiTranslation(Part_1_doc, [model.selection("SOLID", "Box_15_1")], model.selection("EDGE", "PartSet/OX"), 15, 3, model.selection("EDGE", "PartSet/OY"), 15, 3) +MultiTranslation_7 = model.addMultiTranslation(Part_1_doc, [model.selection("SOLID", "Box_16_1")], model.selection("EDGE", "PartSet/OX"), 15, 3, model.selection("EDGE", "PartSet/OY"), 15, 3) +MultiTranslation_8 = model.addMultiTranslation(Part_1_doc, [model.selection("SOLID", "Box_17_1")], model.selection("EDGE", "PartSet/OX"), 15, 3, model.selection("EDGE", "PartSet/OY"), 15, 3) +MultiTranslation_9 = model.addMultiTranslation(Part_1_doc, [model.selection("SOLID", "Box_18_1")], model.selection("EDGE", "PartSet/OX"), 15, 3, model.selection("EDGE", "PartSet/OY"), 15, 3) + +# Translations +Translation_1 = model.addTranslation(Part_1_doc, [model.selection("SOLID", "Box_1_1")], model.selection("EDGE", "PartSet/OX"), 15) +Translation_2 = model.addTranslation(Part_1_doc, [model.selection("SOLID", "Box_2_1")], model.selection("EDGE", "PartSet/OX"), 0) +Translation_3 = model.addTranslation(Part_1_doc, [model.selection("SOLID", "Box_3_1")], model.selection("EDGE", "PartSet/OX"), -15) +Translation_4 = model.addTranslation(Part_1_doc, [model.selection("SOLID", "Box_4_1")], model.selection("EDGE", "InvalidName"), 15) +Translation_5 = model.addTranslation(Part_1_doc, [model.selection("SOLID", "Box_5_1")], model.selection("EDGE", "PartSet/OY"), "d") +Translation_6 = model.addTranslation(Part_1_doc, [model.selection("SOLID", "Box_6_1")], model.selection("EDGE", "Sketch_1/Edge-SketchLine_3"), 15) +Translation_7 = model.addTranslation(Part_1_doc, [model.selection("SOLID", "Box_7_1")], model.selection("EDGE", "Edge_1_1"), 15) +Translation_8 = model.addTranslation(Part_1_doc, [model.selection("SOLID", "Box_8_1")], model.selection("EDGE", "Box_8_1/Right&Box_8_1/Top"), 15) +Translation_9 = model.addTranslation(Part_1_doc, [model.selection("SOLID", "Box_9_1")], model.selection("EDGE", "PartSet/Axis_4"), 15) +Translation_10 = model.addTranslation(Part_1_doc, [model.selection("COMPOUND", "MultiTranslation_1_1")], model.selection("EDGE", "PartSet/OZ"), 15) +Translation_11 = model.addTranslation(Part_1_doc, [model.selection("COMPOUND", "MultiTranslation_2_1")], model.selection("EDGE", "PartSet/OZ"), 0) +Translation_12 = model.addTranslation(Part_1_doc, [model.selection("COMPOUND", "MultiTranslation_3_1")], model.selection("EDGE", "PartSet/OZ"), -15) +Translation_13 = model.addTranslation(Part_1_doc, [model.selection("COMPOUND", "MultiTranslation_4_1")], model.selection("EDGE", "InvalidName"), 15) +Translation_14 = model.addTranslation(Part_1_doc, [model.selection("COMPOUND", "MultiTranslation_5_1")], model.selection("EDGE", "PartSet/OZ"), "d") +Translation_15 = model.addTranslation(Part_1_doc, [model.selection("COMPOUND", "MultiTranslation_6_1")], model.selection("EDGE", "Sketch_1/Edge-SketchLine_2"), 50) +Translation_16 = model.addTranslation(Part_1_doc, [model.selection("COMPOUND", "MultiTranslation_7_1")], model.selection("EDGE", "Edge_1_1"), 50) +Translation_17 = model.addTranslation(Part_1_doc, [model.selection("COMPOUND", "MultiTranslation_8_1")], model.selection("EDGE", "MultiTranslation_8_1/Translated_Edge_8_8"), 50) +Translation_18 = model.addTranslation(Part_1_doc, [model.selection("COMPOUND", "MultiTranslation_9_1")], model.selection("EDGE", "PartSet/Axis_4"), 50) +Translation_19 = model.addTranslation(partSet, [model.selection("COMPOUND", "Part_2/")], model.selection("EDGE", "OX"), 15) +Translation_20 = model.addTranslation(partSet, [model.selection("COMPOUND", "Part_3/")], model.selection("EDGE", "OX"), 0) +Translation_21 = model.addTranslation(partSet, [model.selection("COMPOUND", "Part_4/")], model.selection("EDGE", "OX"), -15) +Translation_22 = model.addTranslation(partSet, [model.selection("COMPOUND", "Part_5/")], model.selection("EDGE", "InvalidName"), 15) +Translation_23 = model.addTranslation(partSet, [model.selection("COMPOUND", "Part_6/")], model.selection("EDGE", "OX"), "d") +Translation_24 = model.addTranslation(partSet, [model.selection("COMPOUND", "Part_7/")], model.selection("EDGE", "Part_7/Edge_1_1"), 15) +Translation_25 = model.addTranslation(partSet, [model.selection("COMPOUND", "Part_8/")], model.selection("EDGE", "Part_8/Box_1_1/Front&Box_1_1/Left"), 15) +Translation_26 = model.addTranslation(partSet, [model.selection("COMPOUND", "Part_9/")], model.selection("EDGE", "Axis_4"), 15) +model.do() +model.end() + +# Checks +from GeomAPI import GeomAPI_Shape + +model.testNbResults(Translation_1, 1) +model.testNbSubResults(Translation_1, [0]) +model.testNbSubShapes(Translation_1, GeomAPI_Shape.SOLID, [1]) +model.testNbSubShapes(Translation_1, GeomAPI_Shape.FACE, [6]) +model.testHaveNamingFaces(Translation_1, model, Part_1_doc) + +model.testNbResults(Translation_2, 1) +model.testNbSubResults(Translation_2, [0]) +model.testNbSubShapes(Translation_2, GeomAPI_Shape.SOLID, [1]) +model.testNbSubShapes(Translation_2, GeomAPI_Shape.FACE, [6]) +model.testHaveNamingFaces(Translation_2, model, Part_1_doc) + +model.testNbResults(Translation_3, 1) +model.testNbSubResults(Translation_3, [0]) +model.testNbSubShapes(Translation_3, GeomAPI_Shape.SOLID, [1]) +model.testNbSubShapes(Translation_3, GeomAPI_Shape.FACE, [6]) +model.testHaveNamingFaces(Translation_3, model, Part_1_doc) + +model.testNbResults(Translation_5, 1) +model.testNbSubResults(Translation_5, [0]) +model.testNbSubShapes(Translation_5, GeomAPI_Shape.SOLID, [1]) +model.testNbSubShapes(Translation_5, GeomAPI_Shape.FACE, [6]) +model.testHaveNamingFaces(Translation_5, model, Part_1_doc) + +model.testNbResults(Translation_6, 1) +model.testNbSubResults(Translation_6, [0]) +model.testNbSubShapes(Translation_6, GeomAPI_Shape.SOLID, [1]) +model.testNbSubShapes(Translation_6, GeomAPI_Shape.FACE, [6]) +model.testHaveNamingFaces(Translation_6, model, Part_1_doc) + +model.testNbResults(Translation_7, 1) +model.testNbSubResults(Translation_7, [0]) +model.testNbSubShapes(Translation_7, GeomAPI_Shape.SOLID, [1]) +model.testNbSubShapes(Translation_7, GeomAPI_Shape.FACE, [6]) +model.testHaveNamingFaces(Translation_7, model, Part_1_doc) + +model.testNbResults(Translation_8, 1) +model.testNbSubResults(Translation_8, [0]) +model.testNbSubShapes(Translation_8, GeomAPI_Shape.SOLID, [1]) +model.testNbSubShapes(Translation_8, GeomAPI_Shape.FACE, [6]) +model.testHaveNamingFaces(Translation_8, model, Part_1_doc) + +model.testNbResults(Translation_9, 1) +model.testNbSubResults(Translation_9, [0]) +model.testNbSubShapes(Translation_9, GeomAPI_Shape.SOLID, [1]) +model.testNbSubShapes(Translation_9, GeomAPI_Shape.FACE, [6]) +model.testHaveNamingFaces(Translation_9, model, Part_1_doc) + +model.testNbResults(Translation_10, 1) +model.testNbSubResults(Translation_10, [9]) +model.testNbSubShapes(Translation_10, GeomAPI_Shape.COMPOUND, [1]) +model.testNbSubShapes(Translation_10, GeomAPI_Shape.SOLID, [9]) +model.testNbSubShapes(Translation_10, GeomAPI_Shape.FACE, [54]) +model.testHaveNamingFaces(Translation_10, model, Part_1_doc) + +model.testNbResults(Translation_11, 1) +model.testNbSubResults(Translation_11, [9]) +model.testNbSubShapes(Translation_11, GeomAPI_Shape.COMPOUND, [1]) +model.testNbSubShapes(Translation_11, GeomAPI_Shape.SOLID, [9]) +model.testNbSubShapes(Translation_11, GeomAPI_Shape.FACE, [54]) +model.testHaveNamingFaces(Translation_11, model, Part_1_doc) + +model.testNbResults(Translation_12, 1) +model.testNbSubResults(Translation_12, [9]) +model.testNbSubShapes(Translation_12, GeomAPI_Shape.COMPOUND, [1]) +model.testNbSubShapes(Translation_12, GeomAPI_Shape.SOLID, [9]) +model.testNbSubShapes(Translation_12, GeomAPI_Shape.FACE, [54]) +model.testHaveNamingFaces(Translation_12, model, Part_1_doc) + +model.testNbResults(Translation_14, 1) +model.testNbSubResults(Translation_14, [9]) +model.testNbSubShapes(Translation_14, GeomAPI_Shape.COMPOUND, [1]) +model.testNbSubShapes(Translation_14, GeomAPI_Shape.SOLID, [9]) +model.testNbSubShapes(Translation_14, GeomAPI_Shape.FACE, [54]) +model.testHaveNamingFaces(Translation_14, model, Part_1_doc) + +model.testNbResults(Translation_15, 1) +model.testNbSubResults(Translation_15, [9]) +model.testNbSubShapes(Translation_15, GeomAPI_Shape.COMPOUND, [1]) +model.testNbSubShapes(Translation_15, GeomAPI_Shape.SOLID, [9]) +model.testNbSubShapes(Translation_15, GeomAPI_Shape.FACE, [54]) +model.testHaveNamingFaces(Translation_15, model, Part_1_doc) + +model.testNbResults(Translation_16, 1) +model.testNbSubResults(Translation_16, [9]) +model.testNbSubShapes(Translation_16, GeomAPI_Shape.COMPOUND, [1]) +model.testNbSubShapes(Translation_16, GeomAPI_Shape.SOLID, [9]) +model.testNbSubShapes(Translation_16, GeomAPI_Shape.FACE, [54]) +model.testHaveNamingFaces(Translation_16, model, Part_1_doc) + +model.testNbResults(Translation_17, 1) +model.testNbSubResults(Translation_17, [9]) +model.testNbSubShapes(Translation_17, GeomAPI_Shape.COMPOUND, [1]) +model.testNbSubShapes(Translation_17, GeomAPI_Shape.SOLID, [9]) +model.testNbSubShapes(Translation_17, GeomAPI_Shape.FACE, [54]) +model.testHaveNamingFaces(Translation_17, model, Part_1_doc) + +model.testNbResults(Translation_18, 1) +model.testNbSubResults(Translation_18, [9]) +model.testNbSubShapes(Translation_18, GeomAPI_Shape.COMPOUND, [1]) +model.testNbSubShapes(Translation_18, GeomAPI_Shape.SOLID, [9]) +model.testNbSubShapes(Translation_18, GeomAPI_Shape.FACE, [54]) +model.testHaveNamingFaces(Translation_18, model, Part_1_doc) + +model.testNbResults(Translation_4, 0) +assert(Translation_4.feature().error() == 'Attribute "axis_object" is not initialized.') + +model.testNbResults(Translation_13, 0) +assert(Translation_13.feature().error() == 'Attribute "axis_object" is not initialized.') + +model.testNbResults(Translation_22, 0) +assert(Translation_22.feature().error() == 'Attribute "axis_object" is not initialized.') + +# See what we can check on a part +model.testNbResults(Translation_19, 1) +#model.testNbSubResults(Translation_19, [0]) +#model.testNbSubShapes(Translation_19, GeomAPI_Shape.COMPOUND, [1]) +#model.testNbSubShapes(Translation_19, GeomAPI_Shape.SOLID, [2]) +#model.testNbSubShapes(Translation_19, GeomAPI_Shape.FACE, [9]) +#model.testHaveNamingFaces(Translation_19, model, Part_2_doc) + +# See what we can check on a part +model.testNbResults(Translation_20, 1) +#model.testNbSubResults(Translation_20, [0]) +#model.testNbSubShapes(Translation_20, GeomAPI_Shape.COMPOUND, [1]) +#model.testNbSubShapes(Translation_20, GeomAPI_Shape.SOLID, [2]) +#model.testNbSubShapes(Translation_20, GeomAPI_Shape.FACE, [9]) +#model.testHaveNamingFaces(Translation_20, model, Part_3_doc) + +# See what we can check on a part +model.testNbResults(Translation_21, 1) +#model.testNbSubResults(Translation_21, [0]) +#model.testNbSubShapes(Translation_21, GeomAPI_Shape.COMPOUND, [1]) +#model.testNbSubShapes(Translation_21, GeomAPI_Shape.SOLID, [2]) +#model.testNbSubShapes(Translation_21, GeomAPI_Shape.FACE, [9]) +#model.testHaveNamingFaces(Translation_21, model, Part_4_doc) + +# See what we can check on a part +model.testNbResults(Translation_23, 1) +#model.testNbSubResults(Translation_23, [0]) +#model.testNbSubShapes(Translation_23, GeomAPI_Shape.COMPOUND, [1]) +#model.testNbSubShapes(Translation_23, GeomAPI_Shape.SOLID, [2]) +#model.testNbSubShapes(Translation_23, GeomAPI_Shape.FACE, [9]) +#model.testHaveNamingFaces(Translation_23, model, Part_6_doc) + +# See what we can check on a part +#model.testNbResults(Translation_24, 1) +#model.testNbSubResults(Translation_24, [0]) +#model.testNbSubShapes(Translation_24, GeomAPI_Shape.COMPOUND, [1]) +#model.testNbSubShapes(Translation_24, GeomAPI_Shape.SOLID, [2]) +#model.testNbSubShapes(Translation_24, GeomAPI_Shape.FACE, [9]) +#model.testNbSubShapes(Translation_24, GeomAPI_Shape.SOLID, [3]) +#model.testNbSubShapes(Translation_24, GeomAPI_Shape.FACE, [18]) +#model.testHaveNamingFaces(Translation_24, model, Part_7_doc) + +# See what we can check on a part +#model.testNbResults(Translation_25, 1) +#model.testNbSubResults(Translation_25, [0]) +#model.testNbSubShapes(Translation_25, GeomAPI_Shape.COMPOUND, [1]) +#model.testNbSubShapes(Translation_25, GeomAPI_Shape.SOLID, [2]) +#model.testNbSubShapes(Translation_25, GeomAPI_Shape.FACE, [9]) +#model.testNbSubShapes(Translation_25, GeomAPI_Shape.SOLID, [3]) +#model.testNbSubShapes(Translation_25, GeomAPI_Shape.FACE, [18]) +#model.testHaveNamingFaces(Translation_25, model, Part_8_doc) + +# See what we can check on a part +model.testNbResults(Translation_26, 1) +#model.testNbSubResults(Translation_26, [0]) +#model.testNbSubShapes(Translation_26, GeomAPI_Shape.COMPOUND, [1]) +#model.testNbSubShapes(Translation_26, GeomAPI_Shape.SOLID, [2]) +#model.testNbSubShapes(Translation_26, GeomAPI_Shape.FACE, [9]) +#model.testHaveNamingFaces(Translation_26, model, Part_9_doc) \ No newline at end of file diff --git a/test.API/SHAPER/Transformations/TestTranslation_2.py b/test.API/SHAPER/Transformations/TestTranslation_2.py new file mode 100644 index 000000000..f98031e4b --- /dev/null +++ b/test.API/SHAPER/Transformations/TestTranslation_2.py @@ -0,0 +1,328 @@ +""" +Test case for Translation feature. +Written on High API. +""" +from salome.shaper import model + +model.begin() +partSet = model.moduleDocument() +Part_1 = model.addPart(partSet) +Part_1_doc = Part_1.document() + +# Boxes +Box_1 = model.addBox(Part_1_doc, 10, 10, 10) +Box_2 = model.addBox(Part_1_doc, 10, 10, 10) +Box_3 = model.addBox(Part_1_doc, 10, 10, 10) +Box_4 = model.addBox(Part_1_doc, 10, 10, 10) +Box_5 = model.addBox(Part_1_doc, 10, 10, 10) +Box_6 = model.addBox(Part_1_doc, 10, 10, 10) +Box_7 = model.addBox(Part_1_doc, 10, 10, 10) +Box_8 = model.addBox(Part_1_doc, 10, 10, 10) +Box_9 = model.addBox(Part_1_doc, 10, 10, 10) +Box_10 = model.addBox(Part_1_doc, 10, 10, 10) +Box_11 = model.addBox(Part_1_doc, 10, 10, 10) +Box_12 = model.addBox(Part_1_doc, 10, 10, 10) +Box_13 = model.addBox(Part_1_doc, 10, 10, 10) +Box_14 = model.addBox(Part_1_doc, 10, 10, 10) +Box_15 = model.addBox(Part_1_doc, 10, 10, 10) +Box_16 = model.addBox(Part_1_doc, 10, 10, 10) +Box_17 = model.addBox(Part_1_doc, 10, 10, 10) +Box_18 = model.addBox(Part_1_doc, 10, 10, 10) +Box_19 = model.addBox(Part_1_doc, 10, 10, 10) +Box_20 = model.addBox(Part_1_doc, 10, 10, 10) +Box_21 = model.addBox(Part_1_doc, 10, 10, 10) +Box_22 = model.addBox(Part_1_doc, 10, 10, 10) +Box_23 = model.addBox(Part_1_doc, 10, 10, 10) +Box_24 = model.addBox(Part_1_doc, 10, 10, 10) +Box_25 = model.addBox(Part_1_doc, 10, 10, 10) +Box_26 = model.addBox(Part_1_doc, 10, 10, 10) +Box_27 = model.addBox(Part_1_doc, 10, 10, 10) +Box_28 = model.addBox(Part_1_doc, 10, 10, 10) +Box_29 = model.addBox(Part_1_doc, 10, 10, 10) +Box_30 = model.addBox(Part_1_doc, 10, 10, 10) +Box_31 = model.addBox(Part_1_doc, 10, 10, 10) +Box_32 = model.addBox(Part_1_doc, 10, 10, 10) +Box_33 = model.addBox(Part_1_doc, 10, 10, 10) +Box_34 = model.addBox(Part_1_doc, 10, 10, 10) +Box_35 = model.addBox(Part_1_doc, 10, 10, 10) +Box_36 = model.addBox(Part_1_doc, 10, 10, 10) + +#################### +# Sketches +# Sketch contenant un triangle +Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOY")) +SketchLine_1 = Sketch_1.addLine(105.8795836373178, 106.9780351893485, -55.30451701345322, -118.6797057217308) +SketchLine_2 = Sketch_1.addLine(-55.30451701345322, -118.6797057217308, -134.9484255703047, 86.11891628160174) +SketchLine_3 = Sketch_1.addLine(-134.9484255703047, 86.11891628160174, 105.8795836373178, 106.9780351893485) +SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchLine_2.startPoint()) +SketchConstraintCoincidence_2 = Sketch_1.setCoincident(SketchLine_2.endPoint(), SketchLine_3.startPoint()) +SketchConstraintCoincidence_3 = Sketch_1.setCoincident(SketchLine_1.startPoint(), SketchLine_3.endPoint()) + +model.do() + +# Edges +Edge_1 = model.addEdge(Part_1_doc, [model.selection("EDGE", "Sketch_1/Edge-SketchLine_2")]) + +# Axis +Axis_1 = model.addAxis(Part_1_doc, 10, 10, 10) + +# Parameters +model.addParameter(Part_1_doc, "d", "15") + +# Translation 27 +Translation_27_1 = model.addTranslation(Part_1_doc, [model.selection("SOLID", "Box_1_1")], model.selection("EDGE", "PartSet/OX"), 5) +Intersection_1 = model.addIntersection(Part_1_doc, [model.selection("SOLID", "Box_2_1")], [model.selection("SOLID", "Translation_1_1")]) +Translation_27 = model.addTranslation(Part_1_doc, [model.selection("COMPOUND", "Intersection_1_1")], model.selection("EDGE", "PartSet/OX"), 15) + +# Translation 28 +Translation_28_1 = model.addTranslation(Part_1_doc, [model.selection("SOLID", "Box_3_1")], model.selection("EDGE", "PartSet/OX"), 5) +Intersection_2 = model.addIntersection(Part_1_doc, [model.selection("SOLID", "Box_4_1")], [model.selection("SOLID", "Translation_3_1")]) +Translation_28 = model.addTranslation(Part_1_doc, [model.selection("COMPOUND", "Intersection_2_1")], model.selection("EDGE", "PartSet/OX"), 0) + +# Translation 29 +Translation_29_1 = model.addTranslation(Part_1_doc, [model.selection("SOLID", "Box_5_1")], model.selection("EDGE", "PartSet/OX"), 5) +Intersection_3 = model.addIntersection(Part_1_doc, [model.selection("SOLID", "Box_6_1")], [model.selection("SOLID", "Translation_5_1")]) +Translation_29 = model.addTranslation(Part_1_doc, [model.selection("COMPOUND", "Intersection_3_1")], model.selection("EDGE", "PartSet/OX"), -15) + +# Translation 30 +Translation_30_1 = model.addTranslation(Part_1_doc, [model.selection("SOLID", "Box_7_1")], model.selection("EDGE", "PartSet/OX"), 5) +Intersection_4 = model.addIntersection(Part_1_doc, [model.selection("SOLID", "Box_8_1")], [model.selection("SOLID", "Translation_7_1")]) +Translation_30 = model.addTranslation(Part_1_doc, [model.selection("COMPOUND", "Intersection_4_1")], model.selection("EDGE", "InvalidName"), -15) + +# Translation 31 +Translation_31_1 = model.addTranslation(Part_1_doc, [model.selection("SOLID", "Box_9_1")], model.selection("EDGE", "PartSet/OX"), 5) +Intersection_5 = model.addIntersection(Part_1_doc, [model.selection("SOLID", "Box_10_1")], [model.selection("SOLID", "Translation_9_1")]) +Translation_31 = model.addTranslation(Part_1_doc, [model.selection("COMPOUND", "Intersection_5_1")], model.selection("EDGE", "PartSet/OY"), "d") + +# Translation 32 +Translation_32_1 = model.addTranslation(Part_1_doc, [model.selection("SOLID", "Box_11_1")], model.selection("EDGE", "PartSet/OX"), 5) +Intersection_6 = model.addIntersection(Part_1_doc, [model.selection("SOLID", "Box_12_1")], [model.selection("SOLID", "Translation_11_1")]) +Translation_32 = model.addTranslation(Part_1_doc, [model.selection("COMPOUND", "Intersection_6_1")], model.selection("EDGE", "Sketch_1/Edge-SketchLine_1"), 15) + +# Translation 33 +Translation_33_1 = model.addTranslation(Part_1_doc, [model.selection("SOLID", "Box_13_1")], model.selection("EDGE", "PartSet/OX"), 5) +Intersection_7 = model.addIntersection(Part_1_doc, [model.selection("SOLID", "Box_14_1")], [model.selection("SOLID", "Translation_13_1")]) +Translation_33 = model.addTranslation(Part_1_doc, [model.selection("COMPOUND", "Intersection_7_1")], model.selection("EDGE", "Edge_1_1"), 15) + +# Translation 34 +Translation_34_1 = model.addTranslation(Part_1_doc, [model.selection("SOLID", "Box_15_1")], model.selection("EDGE", "PartSet/OX"), 5) +Intersection_8 = model.addIntersection(Part_1_doc, [model.selection("SOLID", "Box_16_1")], [model.selection("SOLID", "Translation_15_1")]) +Translation_34 = model.addTranslation(Part_1_doc, [model.selection("COMPOUND", "Intersection_8_1")], model.selection("EDGE", "Intersection_8_1_6"), 15) + +# Translation 35 +Translation_35_1 = model.addTranslation(Part_1_doc, [model.selection("SOLID", "Box_17_1")], model.selection("EDGE", "PartSet/OX"), 5) +Intersection_9 = model.addIntersection(Part_1_doc, [model.selection("SOLID", "Box_18_1")], [model.selection("SOLID", "Translation_17_1")]) +Translation_35 = model.addTranslation(Part_1_doc, [model.selection("COMPOUND", "Intersection_9_1")], model.selection("EDGE", "Axis_1"), 15) + +#Translation 36 +Translation_36_1 = model.addTranslation(Part_1_doc, [model.selection("SOLID", "Box_19_1")], model.selection("EDGE", "PartSet/OX"), 5) +Partition_1 = model.addPartition(Part_1_doc, [model.selection("SOLID", "Box_20_1"), model.selection("SOLID", "Translation_19_1")]) +Translation_36 = model.addTranslation(Part_1_doc, [model.selection("COMPSOLID", "Partition_1_1")], model.selection("EDGE", "PartSet/OX"), 15) + +## Translation 37 +Translation_37_1 = model.addTranslation(Part_1_doc, [model.selection("SOLID", "Box_21_1")], model.selection("EDGE", "PartSet/OX"), 5) +Partition_2 = model.addPartition(Part_1_doc, [model.selection("SOLID", "Box_22_1"), model.selection("SOLID", "Translation_21_1")]) +Translation_37 = model.addTranslation(Part_1_doc, [model.selection("COMPSOLID", "Partition_2_1")], model.selection("EDGE", "PartSet/OX"), 0) + +## Translation 38 +Translation_38_1 = model.addTranslation(Part_1_doc, [model.selection("SOLID", "Box_23_1")], model.selection("EDGE", "PartSet/OX"), 5) +Partition_3 = model.addPartition(Part_1_doc, [model.selection("SOLID", "Box_24_1"), model.selection("SOLID", "Translation_23_1")]) +Translation_38 = model.addTranslation(Part_1_doc, [model.selection("COMPSOLID", "Partition_3_1")], model.selection("EDGE", "PartSet/OX"), 0) + +## Translation 39 +Translation_39_1 = model.addTranslation(Part_1_doc, [model.selection("SOLID", "Box_25_1")], model.selection("EDGE", "PartSet/OX"), 5) +Partition_4 = model.addPartition(Part_1_doc, [model.selection("SOLID", "Box_26_1"), model.selection("SOLID", "Translation_25_1")]) +Translation_39 = model.addTranslation(Part_1_doc, [model.selection("COMPSOLID", "Partition_4_1")], model.selection("EDGE", "InvalidName"), 0) + +## Translation 40 +Translation_40_1 = model.addTranslation(Part_1_doc, [model.selection("SOLID", "Box_27_1")], model.selection("EDGE", "PartSet/OX"), 5) +Partition_5 = model.addPartition(Part_1_doc, [model.selection("SOLID", "Box_28_1"), model.selection("SOLID", "Translation_27_1")]) +Translation_40 = model.addTranslation(Part_1_doc, [model.selection("COMPSOLID", "Partition_5_1")], model.selection("EDGE", "PartSet/OX"), "d") + +# Translation 41 +Translation_41_1 = model.addTranslation(Part_1_doc, [model.selection("SOLID", "Box_29_1")], model.selection("EDGE", "PartSet/OX"), 5) +Partition_6 = model.addPartition(Part_1_doc, [model.selection("SOLID", "Box_30_1"), model.selection("SOLID", "Translation_29_1")]) +Translation_41 = model.addTranslation(Part_1_doc, [model.selection("COMPSOLID", "Partition_6_1")], model.selection("EDGE", "Sketch_1/Edge-SketchLine_1"), 15) + +# Translateion 42 +Translation_42_1 = model.addTranslation(Part_1_doc, [model.selection("SOLID", "Box_31_1")], model.selection("EDGE", "PartSet/OX"), 5) +Partition_7 = model.addPartition(Part_1_doc, [model.selection("SOLID", "Box_32_1"), model.selection("SOLID", "Translation_31_1")]) +Translation_42 = model.addTranslation(Part_1_doc, [model.selection("COMPSOLID", "Partition_7_1")], model.selection("EDGE", "Edge_1_1"), 15) + +# Translation 43 +Translation_43_1 = model.addTranslation(Part_1_doc, [model.selection("SOLID", "Box_33_1")], model.selection("EDGE", "PartSet/OX"), 5) +Partition_8 = model.addPartition(Part_1_doc, [model.selection("SOLID", "Box_34_1"), model.selection("SOLID", "Translation_33_1")]) +Translation_43 = model.addTranslation(Part_1_doc, [model.selection("COMPSOLID", "Partition_8_1")], model.selection("EDGE", "Partition_8_1/Modified_Face_1_1_1&Partition_8_1/Modified_Face_1_9_1"), 15) + +# Translation 44 +Translation_44_1 = model.addTranslation(Part_1_doc, [model.selection("SOLID", "Box_35_1")], model.selection("EDGE", "PartSet/OX"), 5) +Partition_9 = model.addPartition(Part_1_doc, [model.selection("SOLID", "Box_36_1"), model.selection("SOLID", "Translation_35_1")]) +Translation_44 = model.addTranslation(Part_1_doc, [model.selection("COMPSOLID", "Partition_9_1")], model.selection("EDGE", "Axis_1"), 15) +model.do() +model.end() + + +# Checks +from GeomAPI import GeomAPI_Shape +from GeomAPI import GeomAPI_ShapeExplorer + +def testHaveNamingEdges(theFeature, theModel, thePartDoc) : + """ Tests if all faces of result have a name + :param theFeature: feature to test. + """ + # Get feature result/sub-result + aResult = theFeature.results()[0].resultSubShapePair()[0] + # Get result/sub-result shape + shape = aResult.shape() + # Create shape explorer with desired shape type + shapeExplorer = GeomAPI_ShapeExplorer(shape, GeomAPI_Shape.EDGE) + # Create list, and store selections in it + selectionList = [] + while shapeExplorer.more(): + selection = theModel.selection(aResult, shapeExplorer.current()) # First argument should be result/sub-result, second is sub-shape on this result/sub-result + selectionList.append(selection) + shapeExplorer.next() + # Create group with this selection list + Group_1 = theModel.addGroup(thePartDoc, selectionList) + theModel.do() + theModel.end() + + # Now you can check that all selected shapes in group have right shape type and name. + groupFeature = Group_1.feature() + groupSelectionList = groupFeature.selectionList("group_list") + theModel.end() + assert(groupSelectionList.size() == len(selectionList)) + for index in range(0, groupSelectionList.size()): + attrSelection = groupSelectionList.value(index) + shape = attrSelection.value() + name = attrSelection.namingName() + assert(shape.isEdge()) + assert(name != ""), "String empty" + +# Translation 27 +model.testNbResults(Translation_27, 1) +model.testNbSubResults(Translation_27, [12]) +model.testNbSubShapes(Translation_27, GeomAPI_Shape.SOLID, [0]) +model.testNbSubShapes(Translation_27, GeomAPI_Shape.EDGE, [12]) +testHaveNamingEdges(Translation_27, model, Part_1_doc) + +# Translation 28 +model.testNbResults(Translation_28, 1) +model.testNbSubResults(Translation_28, [12]) +model.testNbSubShapes(Translation_28, GeomAPI_Shape.SOLID, [0]) +model.testNbSubShapes(Translation_28, GeomAPI_Shape.EDGE, [12]) +testHaveNamingEdges(Translation_28, model, Part_1_doc) + +# Translation 29 +model.testNbResults(Translation_29, 1) +model.testNbSubResults(Translation_29, [12]) +model.testNbSubShapes(Translation_29, GeomAPI_Shape.SOLID, [0]) +model.testNbSubShapes(Translation_29, GeomAPI_Shape.EDGE, [12]) +testHaveNamingEdges(Translation_29, model, Part_1_doc) + +# Translation 31 +model.testNbResults(Translation_31, 1) +model.testNbSubResults(Translation_31, [12]) +model.testNbSubShapes(Translation_31, GeomAPI_Shape.SOLID, [0]) +model.testNbSubShapes(Translation_31, GeomAPI_Shape.EDGE, [12]) +testHaveNamingEdges(Translation_31, model, Part_1_doc) + +# Translation 32 +model.testNbResults(Translation_32, 1) +model.testNbSubResults(Translation_32, [12]) +model.testNbSubShapes(Translation_32, GeomAPI_Shape.SOLID, [0]) +model.testNbSubShapes(Translation_32, GeomAPI_Shape.EDGE, [12]) +testHaveNamingEdges(Translation_32, model, Part_1_doc) + +# Translation 33 +model.testNbResults(Translation_33, 1) +model.testNbSubResults(Translation_33, [12]) +model.testNbSubShapes(Translation_33, GeomAPI_Shape.SOLID, [0]) +model.testNbSubShapes(Translation_33, GeomAPI_Shape.EDGE, [12]) +testHaveNamingEdges(Translation_33, model, Part_1_doc) + +# Translation 34 +model.testNbResults(Translation_34, 1) +model.testNbSubResults(Translation_34, [12]) +model.testNbSubShapes(Translation_34, GeomAPI_Shape.SOLID, [0]) +model.testNbSubShapes(Translation_34, GeomAPI_Shape.EDGE, [12]) +testHaveNamingEdges(Translation_34, model, Part_1_doc) + +# Translation 35 +model.testNbResults(Translation_35, 1) +model.testNbSubResults(Translation_35, [12]) +model.testNbSubShapes(Translation_35, GeomAPI_Shape.SOLID, [0]) +model.testNbSubShapes(Translation_35, GeomAPI_Shape.EDGE, [12]) +testHaveNamingEdges(Translation_35, model, Part_1_doc) + +# Translation 36 +model.testNbResults(Translation_36, 1) +model.testNbSubResults(Translation_36, [3]) +model.testNbSubShapes(Translation_36, GeomAPI_Shape.COMPSOLID, [1]) +model.testNbSubShapes(Translation_36, GeomAPI_Shape.SOLID, [3]) +model.testNbSubShapes(Translation_36, GeomAPI_Shape.FACE, [18]) +model.testHaveNamingFaces(Translation_36, model, Part_1_doc) + +# Translation 37 +model.testNbResults(Translation_37, 1) +model.testNbSubResults(Translation_37, [3]) +model.testNbSubShapes(Translation_37, GeomAPI_Shape.COMPSOLID, [1]) +model.testNbSubShapes(Translation_37, GeomAPI_Shape.SOLID, [3]) +model.testNbSubShapes(Translation_37, GeomAPI_Shape.FACE, [18]) +model.testHaveNamingFaces(Translation_37, model, Part_1_doc) + +# Translation 38 +model.testNbResults(Translation_38, 1) +model.testNbSubResults(Translation_38, [3]) +model.testNbSubShapes(Translation_38, GeomAPI_Shape.COMPSOLID, [1]) +model.testNbSubShapes(Translation_38, GeomAPI_Shape.SOLID, [3]) +model.testNbSubShapes(Translation_38, GeomAPI_Shape.FACE, [18]) +model.testHaveNamingFaces(Translation_38, model, Part_1_doc) + +# Translation 40 +model.testNbResults(Translation_40, 1) +model.testNbSubResults(Translation_40, [3]) +model.testNbSubShapes(Translation_40, GeomAPI_Shape.COMPSOLID, [1]) +model.testNbSubShapes(Translation_40, GeomAPI_Shape.SOLID, [3]) +model.testNbSubShapes(Translation_40, GeomAPI_Shape.FACE, [18]) +model.testHaveNamingFaces(Translation_40, model, Part_1_doc) + +# Translation 41 +model.testNbResults(Translation_41, 1) +model.testNbSubResults(Translation_41, [3]) +model.testNbSubShapes(Translation_41, GeomAPI_Shape.COMPSOLID, [1]) +model.testNbSubShapes(Translation_41, GeomAPI_Shape.SOLID, [3]) +model.testNbSubShapes(Translation_41, GeomAPI_Shape.FACE, [18]) +model.testHaveNamingFaces(Translation_41, model, Part_1_doc) + +# Translation 42 +model.testNbResults(Translation_42, 1) +model.testNbSubResults(Translation_42, [3]) +model.testNbSubShapes(Translation_42, GeomAPI_Shape.COMPSOLID, [1]) +model.testNbSubShapes(Translation_42, GeomAPI_Shape.SOLID, [3]) +model.testNbSubShapes(Translation_42, GeomAPI_Shape.FACE, [18]) +model.testHaveNamingFaces(Translation_42, model, Part_1_doc) + +# Translation 43 +model.testNbResults(Translation_43, 1) +model.testNbSubResults(Translation_43, [3]) +model.testNbSubShapes(Translation_43, GeomAPI_Shape.COMPSOLID, [1]) +model.testNbSubShapes(Translation_43, GeomAPI_Shape.SOLID, [3]) +model.testNbSubShapes(Translation_43, GeomAPI_Shape.FACE, [18]) +model.testHaveNamingFaces(Translation_43, model, Part_1_doc) + +# Translation 44 +model.testNbResults(Translation_44, 1) +model.testNbSubResults(Translation_44, [3]) +model.testNbSubShapes(Translation_44, GeomAPI_Shape.COMPSOLID, [1]) +model.testNbSubShapes(Translation_44, GeomAPI_Shape.SOLID, [3]) +model.testNbSubShapes(Translation_44, GeomAPI_Shape.FACE, [18]) +model.testHaveNamingFaces(Translation_44, model, Part_1_doc) + +# Translation 30 +model.testNbResults(Translation_30, 0) +assert(Translation_30.feature().error() == 'Attribute "axis_object" is not initialized.') + +# Translation 39 +model.testNbResults(Translation_39, 0) +assert(Translation_39.feature().error() == 'Attribute "axis_object" is not initialized.') \ No newline at end of file diff --git a/test.API/SHAPER/Transformations/TestTranslation_3.py b/test.API/SHAPER/Transformations/TestTranslation_3.py new file mode 100644 index 000000000..1257473e6 --- /dev/null +++ b/test.API/SHAPER/Transformations/TestTranslation_3.py @@ -0,0 +1,502 @@ +""" +Test case for Translation feature. +Written on High API. +""" +from salome.shaper import model + +model.begin() +partSet = model.moduleDocument() +Part_1 = model.addPart(partSet) +Part_1_doc = Part_1.document() + +# Boxes +Box_1 = model.addBox(Part_1_doc, 10, 20, 10) + +#################### +# Sketches +# Sketch contenant un triangle +Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOY")) +SketchLine_1 = Sketch_1.addLine(105.8795836373178, 106.9780351893485, -55.30451701345322, -118.6797057217308) +SketchLine_2 = Sketch_1.addLine(-55.30451701345322, -118.6797057217308, -134.9484255703047, 86.11891628160174) +SketchLine_3 = Sketch_1.addLine(-134.9484255703047, 86.11891628160174, 105.8795836373178, 106.9780351893485) +SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchLine_2.startPoint()) +SketchConstraintCoincidence_2 = Sketch_1.setCoincident(SketchLine_2.endPoint(), SketchLine_3.startPoint()) +SketchConstraintCoincidence_3 = Sketch_1.setCoincident(SketchLine_1.startPoint(), SketchLine_3.endPoint()) + +# Sketch contenant un cercle et une ligne droite ne coupant pas le cercle, tous deux contenus dans l'une des faces de la box 1 +Sketch_2 = model.addSketch(Part_1_doc, model.selection("FACE", "Box_1_1/Top")) +SketchCircle_1 = Sketch_2.addCircle(3.625538020086079, 17.57352941176471, 2.190441696184978) +SketchLine_4 = Sketch_2.addLine(2.442711482557598, 6.454964041059345, 8.035432938365913, 18.18483116518828) + +# Sketch contenant une ligne droite +Sketch_3 = model.addSketch(Part_1_doc, model.defaultPlane("XOY")) +SketchLine_5 = Sketch_3.addLine(-42.70592498087446, -19.7671890801643, 76.68536514422158, 72.47712556405142) + +# Sketch contenant 2 lignes droites independantes +Sketch_4 = model.addSketch(Part_1_doc, model.defaultPlane("XOY")) +SketchLine_6 = Sketch_4.addLine(64.56241032998567, 126.9727403156384, -187.948350071736, -65.2797704447633) +SketchLine_7 = Sketch_4.addLine(147.7761836441895, 78.19225251076045, 2.869440459110503, -194.4045911047346) + +# Sketch contenant un triangle et une ligne droite sans contact avec le triangle +Sketch_5 = model.addSketch(Part_1_doc, model.defaultPlane("XOY")) +SketchLine_8 = Sketch_5.addLine(43.04160688665702, 82.49641319942614, -63.12769010043041, -3.586800573888105) +SketchLine_9 = Sketch_5.addLine(-63.12769010043041, -3.586800573888105, 60.25824964132004, -45.19368723098994) +SketchLine_10 = Sketch_5.addLine(60.25824964132004, -45.19368723098994, 43.04160688665702, 82.49641319942614) +SketchConstraintCoincidence_4 = Sketch_5.setCoincident(SketchLine_8.endPoint(), SketchLine_9.startPoint()) +SketchConstraintCoincidence_5 = Sketch_5.setCoincident(SketchLine_9.endPoint(), SketchLine_10.startPoint()) +SketchConstraintCoincidence_6 = Sketch_5.setCoincident(SketchLine_8.startPoint(), SketchLine_10.endPoint()) +SketchLine_11 = Sketch_5.addLine(-129.0707731585723, -64.87131938806517, -62.80680259595319, 54.77196079444149) + +# Sketch contenant deux triangles ayant un cote en commun +Sketch_6 = model.addSketch(Part_1_doc, model.defaultPlane("XOY")) +SketchLine_12 = Sketch_6.addLine(31.56384505021527, 81.06169296987088, -80.3443328550933, -15.06456241033) +SketchLine_13 = Sketch_6.addLine(-80.3443328550933, -15.06456241033, 58.82352941176466, -35.15064562410331) +SketchLine_14 = Sketch_6.addLine(58.82352941176466, -35.15064562410331, 31.56384505021527, 81.06169296987088) +SketchLine_15 = Sketch_6.addLine(31.56384505021527, 81.06169296987088, 159.2539454806312, 40.88952654232425) +SketchLine_16 = Sketch_6.addLine(159.2539454806312, 40.88952654232425, 58.82352941176466, -35.15064562410331) +SketchConstraintCoincidence_7 = Sketch_6.setCoincident(SketchLine_12.endPoint(), SketchLine_13.startPoint()) +SketchConstraintCoincidence_8 = Sketch_6.setCoincident(SketchLine_13.endPoint(), SketchLine_14.startPoint()) +SketchConstraintCoincidence_9 = Sketch_6.setCoincident(SketchLine_12.startPoint(), SketchLine_14.endPoint()) +SketchConstraintCoincidence_10 = Sketch_6.setCoincident(SketchLine_12.startPoint(), SketchLine_15.startPoint()) +SketchConstraintCoincidence_11 = Sketch_6.setCoincident(SketchLine_15.endPoint(), SketchLine_16.startPoint()) +SketchConstraintCoincidence_12 = Sketch_6.setCoincident(SketchLine_13.endPoint(), SketchLine_16.endPoint()) + +# Sketch contenant deux triangles ayant un cote en commun et une ligne droite ne coupant aucun des 2 triangles +Sketch_7 = model.addSketch(Part_1_doc, model.defaultPlane("XOY")) +SketchLine_17 = Sketch_7.addLine(17.21664275466276, 98.27833572453372, -144.906743185079, -46.6284074605452) +SketchLine_18 = Sketch_7.addLine(-144.906743185079, -46.6284074605452, 143.4720229555236, -105.4519368723099) +SketchLine_19 = Sketch_7.addLine(143.4720229555236, -105.4519368723099, 17.21664275466276, 98.27833572453372) +SketchLine_20 = Sketch_7.addLine(17.21664275466276, 98.27833572453372, 272.5968436154949, 99.71305595408899) +SketchLine_21 = Sketch_7.addLine(272.5968436154949, 99.71305595408899, 143.4720229555236, -105.4519368723099) +SketchConstraintCoincidence_13 = Sketch_7.setCoincident(SketchLine_17.endPoint(), SketchLine_18.startPoint()) +SketchConstraintCoincidence_14 = Sketch_7.setCoincident(SketchLine_18.endPoint(), SketchLine_19.startPoint()) +SketchConstraintCoincidence_15 = Sketch_7.setCoincident(SketchLine_17.startPoint(), SketchLine_19.endPoint()) +SketchConstraintCoincidence_16 = Sketch_7.setCoincident(SketchLine_17.startPoint(), SketchLine_20.startPoint()) +SketchConstraintCoincidence_17 = Sketch_7.setCoincident(SketchLine_20.endPoint(), SketchLine_21.startPoint()) +SketchConstraintCoincidence_18 = Sketch_7.setCoincident(SketchLine_18.endPoint(), SketchLine_21.endPoint()) +SketchLine_22 = Sketch_7.addLine(-190.8177905308465, 62.41032998565277, -307.0301291248207, -188.6657101865136) + +# Sketch contenant un cercle +Sketch_8 = model.addSketch(Part_1_doc, model.selection("FACE", "Box_1_1/Front")) +SketchCircle_2 = Sketch_8.addCircle(5.043472022955523, 6.180989956958394, 2.65480068754944) + +model.do() + +# Extrusions +Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("WIRE", "Sketch_2/Wire-SketchCircle_1_2f")], model.selection(), 15, 0) +Extrusion_2 = model.addExtrusion(Part_1_doc, [model.selection("WIRE", "Sketch_8/Wire-SketchCircle_2_2f")], model.selection(), 15, 0) + +# Edges +Edge_1 = model.addEdge(Part_1_doc, [model.selection("EDGE", "Sketch_1/Edge-SketchLine_2")]) +Edge_2 = model.addEdge(Part_1_doc, [model.selection("EDGE", "Sketch_3/Edge-SketchLine_5")]) +Edge_3 = model.addEdge(Part_1_doc, [model.selection("EDGE", "Sketch_3/Edge-SketchLine_5")]) +Edge_4 = model.addEdge(Part_1_doc, [model.selection("EDGE", "Sketch_3/Edge-SketchLine_5")]) +Edge_5 = model.addEdge(Part_1_doc, [model.selection("EDGE", "Sketch_3/Edge-SketchLine_5")]) +Edge_6 = model.addEdge(Part_1_doc, [model.selection("EDGE", "Sketch_3/Edge-SketchLine_5")]) +Edge_7 = model.addEdge(Part_1_doc, [model.selection("EDGE", "Sketch_4/Edge-SketchLine_7")]) +Edge_8 = model.addEdge(Part_1_doc, [model.selection("EDGE", "Sketch_4/Edge-SketchLine_6")]) +Edge_9 = model.addEdge(Part_1_doc, [model.selection("EDGE", "Sketch_4/Edge-SketchLine_7")]) +Edge_10 = model.addEdge(Part_1_doc, [model.selection("EDGE", "Sketch_4/Edge-SketchLine_7")]) +Edge_11 = model.addEdge(Part_1_doc, [model.selection("EDGE", "Sketch_5/Edge-SketchLine_11")]) +Edge_12 = model.addEdge(Part_1_doc, [model.selection("EDGE", "Sketch_7/Edge-SketchLine_22")]) + +# Axis +Axis_1 = model.addAxis(Part_1_doc, 10, 10, 10) + +# Vertex +Vertex_1 = model.addVertex(Part_1_doc, [model.selection("VERTEX", "Sketch_3/Vertex-SketchLine_5e")]) +Vertex_2 = model.addVertex(Part_1_doc, [model.selection("VERTEX", "Sketch_3/Vertex-SketchLine_5e")]) +Vertex_3 = model.addVertex(Part_1_doc, [model.selection("VERTEX", "Sketch_3/Vertex-SketchLine_5e")]) +Vertex_4 = model.addVertex(Part_1_doc, [model.selection("VERTEX", "Sketch_3/Vertex-SketchLine_5e")]) +Vertex_5 = model.addVertex(Part_1_doc, [model.selection("VERTEX", "Sketch_3/Vertex-SketchLine_5e")]) +Vertex_6 = model.addVertex(Part_1_doc, [model.selection("VERTEX", "Sketch_3/Vertex-SketchLine_5e")]) +Vertex_7 = model.addVertex(Part_1_doc, [model.selection("VERTEX", "Sketch_3/Vertex-SketchLine_5e")]) +Vertex_8 = model.addVertex(Part_1_doc, [model.selection("VERTEX", "Sketch_3/Vertex-SketchLine_5e")]) +Vertex_9 = model.addVertex(Part_1_doc, [model.selection("VERTEX", "Sketch_3/Vertex-SketchLine_5e")]) + +# Wires +Wire_1 = model.addWire(Part_1_doc, [model.selection("WIRE", "Sketch_1/Wire-SketchLine_1f-SketchLine_2f-SketchLine_3f")]) +Wire_2 = model.addWire(Part_1_doc, [model.selection("WIRE", "Sketch_1/Wire-SketchLine_1f-SketchLine_2f-SketchLine_3f")]) +Wire_3 = model.addWire(Part_1_doc, [model.selection("WIRE", "Sketch_1/Wire-SketchLine_1f-SketchLine_2f-SketchLine_3f")]) +Wire_4 = model.addWire(Part_1_doc, [model.selection("WIRE", "Sketch_1/Wire-SketchLine_1f-SketchLine_2f-SketchLine_3f")]) +Wire_5 = model.addWire(Part_1_doc, [model.selection("WIRE", "Sketch_1/Wire-SketchLine_1f-SketchLine_2f-SketchLine_3f")]) +Wire_6 = model.addWire(Part_1_doc, [model.selection("WIRE", "Sketch_5/Wire-SketchLine_8f-SketchLine_9f-SketchLine_10f")]) +Wire_7 = model.addWire(Part_1_doc, [model.selection("WIRE", "Sketch_5/Wire-SketchLine_8f-SketchLine_9f-SketchLine_10f")]) +Wire_8 = model.addWire(Part_1_doc, [model.selection("WIRE", "Sketch_1/Wire-SketchLine_1f-SketchLine_2f-SketchLine_3f")]) +Wire_9 = model.addWire(Part_1_doc, [model.selection("WIRE", "Sketch_1/Wire-SketchLine_1f-SketchLine_2f-SketchLine_3f")]) + +# Faces +Face_1 = model.addFace(Part_1_doc, [model.selection("WIRE", "Sketch_1/Wire-SketchLine_1f-SketchLine_2f-SketchLine_3f")]) +Face_2 = model.addFace(Part_1_doc, [model.selection("WIRE", "Sketch_1/Wire-SketchLine_1f-SketchLine_2f-SketchLine_3f")]) +Face_3 = model.addFace(Part_1_doc, [model.selection("WIRE", "Sketch_1/Wire-SketchLine_1f-SketchLine_2f-SketchLine_3f")]) +Face_4 = model.addFace(Part_1_doc, [model.selection("WIRE", "Sketch_1/Wire-SketchLine_1f-SketchLine_2f-SketchLine_3f")]) +Face_5 = model.addFace(Part_1_doc, [model.selection("WIRE", "Sketch_1/Wire-SketchLine_1f-SketchLine_2f-SketchLine_3f")]) +Face_6 = model.addFace(Part_1_doc, [model.selection("WIRE", "Sketch_5/Wire-SketchLine_8f-SketchLine_9f-SketchLine_10f")]) +Face_7 = model.addFace(Part_1_doc, [model.selection("WIRE", "Sketch_5/Wire-SketchLine_8f-SketchLine_9f-SketchLine_10f")]) +Face_8 = model.addFace(Part_1_doc, [model.selection("WIRE", "Sketch_1/Wire-SketchLine_1f-SketchLine_2f-SketchLine_3f")]) +Face_9 = model.addFace(Part_1_doc, [model.selection("WIRE", "Sketch_1/Wire-SketchLine_1f-SketchLine_2f-SketchLine_3f")]) +Face_10 = model.addFace(Part_1_doc, [model.selection("WIRE", "Sketch_6/Wire-SketchLine_12f-SketchLine_13f-SketchLine_14f")]) +Face_11 = model.addFace(Part_1_doc, [model.selection("WIRE", "Sketch_6/Wire-SketchLine_14r-SketchLine_15r-SketchLine_16r")]) +Face_12 = model.addFace(Part_1_doc, [model.selection("WIRE", "Sketch_7/Wire-SketchLine_17f-SketchLine_18f-SketchLine_19f")]) +Face_13 = model.addFace(Part_1_doc, [model.selection("WIRE", "Sketch_7/Wire-SketchLine_19r-SketchLine_20r-SketchLine_21r")]) + +# Shells +Shell_1 = model.addShell(Part_1_doc, [model.selection("FACE", "Face_10_1"), model.selection("FACE", "Face_11_1")]) +Shell_2 = model.addShell(Part_1_doc, [model.selection("FACE", "Face_10_1"), model.selection("FACE", "Face_11_1")]) +Shell_3 = model.addShell(Part_1_doc, [model.selection("FACE", "Face_10_1"), model.selection("FACE", "Face_11_1")]) +Shell_4 = model.addShell(Part_1_doc, [model.selection("FACE", "Face_10_1"), model.selection("FACE", "Face_11_1")]) +Shell_5 = model.addShell(Part_1_doc, [model.selection("FACE", "Face_10_1"), model.selection("FACE", "Face_11_1")]) +Shell_6 = model.addShell(Part_1_doc, [model.selection("FACE", "Face_12_1"), model.selection("FACE", "Face_13_1")]) +Shell_7 = model.addShell(Part_1_doc, [model.selection("FACE", "Face_12_1"), model.selection("FACE", "Face_13_1")]) +Shell_8 = model.addShell(Part_1_doc, [model.selection("FACE", "Face_10_1"), model.selection("FACE", "Face_11_1")]) +Shell_9 = model.addShell(Part_1_doc, [model.selection("FACE", "Face_10_1"), model.selection("FACE", "Face_11_1")]) + +# Parameters +model.addParameter(Part_1_doc, "d", "15") + +# Translations +Translation_45 = model.addTranslation(Part_1_doc, [model.selection("VERTEX", "Vertex_1_1")], model.selection("EDGE", "PartSet/OX"), 15) +Translation_46 = model.addTranslation(Part_1_doc, [model.selection("VERTEX", "Vertex_2_1")], model.selection("EDGE", "PartSet/OX"), 0) +Translation_47 = model.addTranslation(Part_1_doc, [model.selection("VERTEX", "Vertex_3_1")], model.selection("EDGE", "PartSet/OX"), -15) +Translation_48 = model.addTranslation(Part_1_doc, [model.selection("VERTEX", "Vertex_4_1")], model.selection("EDGE", "InvalidName"), 15) +Translation_49 = model.addTranslation(Part_1_doc, [model.selection("VERTEX", "Vertex_5_1")], model.selection("EDGE", "PartSet/OX"), "d") +Translation_50 = model.addTranslation(Part_1_doc, [model.selection("VERTEX", "Vertex_6_1")], model.selection("EDGE", "Sketch_3/Edge-SketchLine_5"), 15) +Translation_51 = model.addTranslation(Part_1_doc, [model.selection("VERTEX", "Vertex_7_1")], model.selection("EDGE", "Edge_2_1"), 15) +Translation_52 = model.addTranslation(Part_1_doc, [model.selection("VERTEX", "Vertex_8_1")], model.selection("EDGE", "Box_1_1/Back&Box_1_1/Right"), 15) +Translation_53 = model.addTranslation(Part_1_doc, [model.selection("VERTEX", "Vertex_9_1")], model.selection("EDGE", "Axis_1"), 15) +Translation_54 = model.addTranslation(Part_1_doc, [model.selection("EDGE", "Edge_2_1")], model.selection("EDGE", "PartSet/OX"), 15) +Translation_55 = model.addTranslation(Part_1_doc, [model.selection("EDGE", "Edge_3_1")], model.selection("EDGE", "PartSet/OX"), 0) +Translation_56 = model.addTranslation(Part_1_doc, [model.selection("EDGE", "Edge_4_1")], model.selection("EDGE", "PartSet/OX"), -15) +Translation_57 = model.addTranslation(Part_1_doc, [model.selection("EDGE", "Edge_5_1")], model.selection("EDGE", "InvalidName"), 15) +Translation_58 = model.addTranslation(Part_1_doc, [model.selection("EDGE", "Edge_6_1")], model.selection("EDGE", "PartSet/OY"), "d") +Translation_59 = model.addTranslation(Part_1_doc, [model.selection("EDGE", "Edge_7_1")], model.selection("EDGE", "Sketch_4/Edge-SketchLine_6"), 15) +Translation_60 = model.addTranslation(Part_1_doc, [model.selection("EDGE", "Edge_8_1")], model.selection("EDGE", "Edge_9_1"), 15) +Translation_61 = model.addTranslation(Part_1_doc, [model.selection("EDGE", "Edge_9_1")], model.selection("EDGE", "Box_1_1/Front&Box_1_1/Right"), 15) +Translation_62 = model.addTranslation(Part_1_doc, [model.selection("EDGE", "Edge_10_1")], model.selection("EDGE", "Axis_1"), 15) +Translation_63 = model.addTranslation(Part_1_doc, [model.selection("WIRE", "Wire_1_1")], model.selection("EDGE", "PartSet/OX"), 15) +Translation_64 = model.addTranslation(Part_1_doc, [model.selection("WIRE", "Wire_2_1")], model.selection("EDGE", "PartSet/OX"), 0) +Translation_65 = model.addTranslation(Part_1_doc, [model.selection("WIRE", "Wire_3_1")], model.selection("EDGE", "PartSet/OX"), -15) +Translation_66 = model.addTranslation(Part_1_doc, [model.selection("WIRE", "Wire_4_1")], model.selection("EDGE", "InvalidName"), 15) +Translation_67 = model.addTranslation(Part_1_doc, [model.selection("WIRE", "Wire_5_1")], model.selection("EDGE", "PartSet/OY"), "d") +Translation_68 = model.addTranslation(Part_1_doc, [model.selection("WIRE", "Wire_6_1")], model.selection("EDGE", "Sketch_5/Edge-SketchLine_11"), 15) +Translation_69 = model.addTranslation(Part_1_doc, [model.selection("WIRE", "Wire_7_1")], model.selection("EDGE", "Edge_11_1"), 15) +Translation_70 = model.addTranslation(Part_1_doc, [model.selection("WIRE", "Wire_8_1")], model.selection("EDGE", "Box_1_1/Back&Box_1_1/Right"), 15) +Translation_71 = model.addTranslation(Part_1_doc, [model.selection("WIRE", "Wire_9_1")], model.selection("EDGE", "Axis_1"), 15) +Translation_72 = model.addTranslation(Part_1_doc, [model.selection("FACE", "Face_1_1")], model.selection("EDGE", "PartSet/OX"), 15) +Translation_73 = model.addTranslation(Part_1_doc, [model.selection("FACE", "Face_2_1")], model.selection("EDGE", "PartSet/OX"), 0) +Translation_74 = model.addTranslation(Part_1_doc, [model.selection("FACE", "Face_3_1")], model.selection("EDGE", "PartSet/OX"), -15) +Translation_75 = model.addTranslation(Part_1_doc, [model.selection("FACE", "Face_4_1")], model.selection("EDGE", "InvalidName"), -15) +Translation_76 = model.addTranslation(Part_1_doc, [model.selection("FACE", "Face_5_1")], model.selection("EDGE", "PartSet/OX"), "d") +Translation_77 = model.addTranslation(Part_1_doc, [model.selection("FACE", "Face_6_1")], model.selection("EDGE", "Sketch_5/Edge-SketchLine_11"), 15) +Translation_78 = model.addTranslation(Part_1_doc, [model.selection("FACE", "Face_7_1")], model.selection("EDGE", "Edge_11_1"), 15) +Translation_79 = model.addTranslation(Part_1_doc, [model.selection("FACE", "Face_8_1")], model.selection("EDGE", "Box_1_1/Front&Box_1_1/Right"), 15) +Translation_80 = model.addTranslation(Part_1_doc, [model.selection("FACE", "Face_9_1")], model.selection("EDGE", "Axis_1"), 15) +Translation_81 = model.addTranslation(Part_1_doc, [model.selection("SHELL", "Shell_1_1")], model.selection("EDGE", "PartSet/OX"), 15) +Translation_82 = model.addTranslation(Part_1_doc, [model.selection("SHELL", "Shell_2_1")], model.selection("EDGE", "PartSet/OX"), 0) +Translation_83 = model.addTranslation(Part_1_doc, [model.selection("SHELL", "Shell_3_1")], model.selection("EDGE", "PartSet/OX"), -15) +Translation_84 = model.addTranslation(Part_1_doc, [model.selection("SHELL", "Shell_4_1")], model.selection("EDGE", "InvalidName"), 15) +Translation_85 = model.addTranslation(Part_1_doc, [model.selection("SHELL", "Shell_5_1")], model.selection("EDGE", "PartSet/OX"), "d") +Translation_86 = model.addTranslation(Part_1_doc, [model.selection("SHELL", "Shell_6_1")], model.selection("EDGE", "Sketch_7/Edge-SketchLine_22"), 15) +Translation_87 = model.addTranslation(Part_1_doc, [model.selection("SHELL", "Shell_7_1")], model.selection("EDGE", "Edge_12_1"), 15) +Translation_88 = model.addTranslation(Part_1_doc, [model.selection("SHELL", "Shell_8_1")], model.selection("EDGE", "Box_1_1/Front&Box_1_1/Right"), 15) +Translation_89 = model.addTranslation(Part_1_doc, [model.selection("SHELL", "Shell_9_1")], model.selection("EDGE", "Axis_1"), 15) +Translation_90 = model.addTranslation(Part_1_doc, [model.selection("SOLID", "Box_1_1"), model.selection("SOLID", "Extrusion_2_1")], model.selection("EDGE", "PartSet/OY"), 15) +model.do() +model.end() + +# Checks +from GeomAPI import GeomAPI_Shape + +model.testNbResults(Translation_45, 1) +model.testNbSubResults(Translation_45, [0]) +model.testNbSubShapes(Translation_45, GeomAPI_Shape.COMPSOLID, [0]) +model.testNbSubShapes(Translation_45, GeomAPI_Shape.SOLID, [0]) +model.testNbSubShapes(Translation_45, GeomAPI_Shape.FACE, [0]) +model.testNbSubShapes(Translation_45, GeomAPI_Shape.VERTEX, [1]) +model.testHaveNamingFaces(Translation_45, model, Part_1_doc) + +model.testNbResults(Translation_46, 1) +model.testNbSubResults(Translation_46, [0]) +model.testNbSubShapes(Translation_46, GeomAPI_Shape.COMPSOLID, [0]) +model.testNbSubShapes(Translation_46, GeomAPI_Shape.SOLID, [0]) +model.testNbSubShapes(Translation_46, GeomAPI_Shape.FACE, [0]) +model.testNbSubShapes(Translation_46, GeomAPI_Shape.VERTEX, [1]) +model.testHaveNamingFaces(Translation_46, model, Part_1_doc) + +model.testNbResults(Translation_47, 1) +model.testNbSubResults(Translation_47, [0]) +model.testNbSubShapes(Translation_47, GeomAPI_Shape.COMPSOLID, [0]) +model.testNbSubShapes(Translation_47, GeomAPI_Shape.SOLID, [0]) +model.testNbSubShapes(Translation_47, GeomAPI_Shape.FACE, [0]) +model.testNbSubShapes(Translation_47, GeomAPI_Shape.VERTEX, [1]) +model.testHaveNamingFaces(Translation_47, model, Part_1_doc) + +model.testNbResults(Translation_49, 1) +model.testNbSubResults(Translation_49, [0]) +model.testNbSubShapes(Translation_49, GeomAPI_Shape.COMPSOLID, [0]) +model.testNbSubShapes(Translation_49, GeomAPI_Shape.SOLID, [0]) +model.testNbSubShapes(Translation_49, GeomAPI_Shape.FACE, [0]) +model.testNbSubShapes(Translation_49, GeomAPI_Shape.VERTEX, [1]) +model.testHaveNamingFaces(Translation_49, model, Part_1_doc) + +model.testNbResults(Translation_50, 1) +model.testNbSubResults(Translation_50, [0]) +model.testNbSubShapes(Translation_50, GeomAPI_Shape.COMPSOLID, [0]) +model.testNbSubShapes(Translation_50, GeomAPI_Shape.SOLID, [0]) +model.testNbSubShapes(Translation_50, GeomAPI_Shape.FACE, [0]) +model.testNbSubShapes(Translation_50, GeomAPI_Shape.VERTEX, [1]) +model.testHaveNamingFaces(Translation_50, model, Part_1_doc) + +model.testNbResults(Translation_51, 1) +model.testNbSubResults(Translation_51, [0]) +model.testNbSubShapes(Translation_51, GeomAPI_Shape.COMPSOLID, [0]) +model.testNbSubShapes(Translation_51, GeomAPI_Shape.SOLID, [0]) +model.testNbSubShapes(Translation_51, GeomAPI_Shape.FACE, [0]) +model.testNbSubShapes(Translation_51, GeomAPI_Shape.VERTEX, [1]) +model.testHaveNamingFaces(Translation_51, model, Part_1_doc) + +model.testNbResults(Translation_52, 1) +model.testNbSubResults(Translation_52, [0]) +model.testNbSubShapes(Translation_52, GeomAPI_Shape.COMPSOLID, [0]) +model.testNbSubShapes(Translation_52, GeomAPI_Shape.SOLID, [0]) +model.testNbSubShapes(Translation_52, GeomAPI_Shape.FACE, [0]) +model.testNbSubShapes(Translation_52, GeomAPI_Shape.VERTEX, [1]) +model.testHaveNamingFaces(Translation_52, model, Part_1_doc) + +model.testNbResults(Translation_53, 1) +model.testNbSubResults(Translation_53, [0]) +model.testNbSubShapes(Translation_53, GeomAPI_Shape.COMPSOLID, [0]) +model.testNbSubShapes(Translation_53, GeomAPI_Shape.SOLID, [0]) +model.testNbSubShapes(Translation_53, GeomAPI_Shape.FACE, [0]) +model.testNbSubShapes(Translation_53, GeomAPI_Shape.VERTEX, [1]) +model.testHaveNamingFaces(Translation_53, model, Part_1_doc) + +model.testNbResults(Translation_54, 1) +model.testNbSubResults(Translation_54, [0]) +model.testNbSubShapes(Translation_54, GeomAPI_Shape.SOLID, [0]) +model.testNbSubShapes(Translation_54, GeomAPI_Shape.FACE, [0]) +model.testNbSubShapes(Translation_54, GeomAPI_Shape.EDGE, [1]) +model.testHaveNamingFaces(Translation_54, model, Part_1_doc) + +model.testNbResults(Translation_55, 1) +model.testNbSubResults(Translation_55, [0]) +model.testNbSubShapes(Translation_55, GeomAPI_Shape.SOLID, [0]) +model.testNbSubShapes(Translation_55, GeomAPI_Shape.FACE, [0]) +model.testNbSubShapes(Translation_55, GeomAPI_Shape.EDGE, [1]) +model.testHaveNamingFaces(Translation_55, model, Part_1_doc) + +model.testNbResults(Translation_56, 1) +model.testNbSubResults(Translation_56, [0]) +model.testNbSubShapes(Translation_56, GeomAPI_Shape.SOLID, [0]) +model.testNbSubShapes(Translation_56, GeomAPI_Shape.FACE, [0]) +model.testNbSubShapes(Translation_56, GeomAPI_Shape.EDGE, [1]) +model.testHaveNamingFaces(Translation_56, model, Part_1_doc) + +model.testNbResults(Translation_58, 1) +model.testNbSubResults(Translation_58, [0]) +model.testNbSubShapes(Translation_58, GeomAPI_Shape.SOLID, [0]) +model.testNbSubShapes(Translation_58, GeomAPI_Shape.FACE, [0]) +model.testNbSubShapes(Translation_58, GeomAPI_Shape.EDGE, [1]) +model.testHaveNamingFaces(Translation_58, model, Part_1_doc) + +model.testNbResults(Translation_59, 1) +model.testNbSubResults(Translation_59, [0]) +model.testNbSubShapes(Translation_59, GeomAPI_Shape.SOLID, [0]) +model.testNbSubShapes(Translation_59, GeomAPI_Shape.FACE, [0]) +model.testNbSubShapes(Translation_59, GeomAPI_Shape.EDGE, [1]) +model.testHaveNamingFaces(Translation_59, model, Part_1_doc) + +model.testNbResults(Translation_60, 1) +model.testNbSubResults(Translation_60, [0]) +model.testNbSubShapes(Translation_60, GeomAPI_Shape.SOLID, [0]) +model.testNbSubShapes(Translation_60, GeomAPI_Shape.FACE, [0]) +model.testNbSubShapes(Translation_60, GeomAPI_Shape.EDGE, [1]) +model.testHaveNamingFaces(Translation_60, model, Part_1_doc) + +model.testNbResults(Translation_61, 1) +model.testNbSubResults(Translation_61, [0]) +model.testNbSubShapes(Translation_61, GeomAPI_Shape.SOLID, [0]) +model.testNbSubShapes(Translation_61, GeomAPI_Shape.FACE, [0]) +model.testNbSubShapes(Translation_61, GeomAPI_Shape.EDGE, [1]) +model.testHaveNamingFaces(Translation_61, model, Part_1_doc) + +model.testNbResults(Translation_62, 1) +model.testNbSubResults(Translation_62, [0]) +model.testNbSubShapes(Translation_62, GeomAPI_Shape.SOLID, [0]) +model.testNbSubShapes(Translation_62, GeomAPI_Shape.FACE, [0]) +model.testNbSubShapes(Translation_62, GeomAPI_Shape.EDGE, [1]) +model.testHaveNamingFaces(Translation_62, model, Part_1_doc) + +model.testNbResults(Translation_63, 1) +model.testNbSubResults(Translation_63, [0]) +model.testNbSubShapes(Translation_63, GeomAPI_Shape.SOLID, [0]) +model.testNbSubShapes(Translation_63, GeomAPI_Shape.FACE, [0]) +model.testNbSubShapes(Translation_63, GeomAPI_Shape.WIRE, [1]) +model.testHaveNamingFaces(Translation_63, model, Part_1_doc) + +model.testNbResults(Translation_64, 1) +model.testNbSubResults(Translation_64, [0]) +model.testNbSubShapes(Translation_64, GeomAPI_Shape.SOLID, [0]) +model.testNbSubShapes(Translation_64, GeomAPI_Shape.FACE, [0]) +model.testNbSubShapes(Translation_64, GeomAPI_Shape.WIRE, [1]) +model.testHaveNamingFaces(Translation_64, model, Part_1_doc) + +model.testNbResults(Translation_65, 1) +model.testNbSubResults(Translation_65, [0]) +model.testNbSubShapes(Translation_65, GeomAPI_Shape.SOLID, [0]) +model.testNbSubShapes(Translation_65, GeomAPI_Shape.FACE, [0]) +model.testNbSubShapes(Translation_65, GeomAPI_Shape.WIRE, [1]) +model.testHaveNamingFaces(Translation_65, model, Part_1_doc) + +model.testNbResults(Translation_67, 1) +model.testNbSubResults(Translation_67, [0]) +model.testNbSubShapes(Translation_67, GeomAPI_Shape.SOLID, [0]) +model.testNbSubShapes(Translation_67, GeomAPI_Shape.FACE, [0]) +model.testNbSubShapes(Translation_67, GeomAPI_Shape.WIRE, [1]) +model.testHaveNamingFaces(Translation_67, model, Part_1_doc) + +model.testNbResults(Translation_68, 1) +model.testNbSubResults(Translation_68, [0]) +model.testNbSubShapes(Translation_68, GeomAPI_Shape.SOLID, [0]) +model.testNbSubShapes(Translation_68, GeomAPI_Shape.FACE, [0]) +model.testNbSubShapes(Translation_68, GeomAPI_Shape.WIRE, [1]) +model.testHaveNamingFaces(Translation_68, model, Part_1_doc) + +model.testNbResults(Translation_69, 1) +model.testNbSubResults(Translation_69, [0]) +model.testNbSubShapes(Translation_69, GeomAPI_Shape.SOLID, [0]) +model.testNbSubShapes(Translation_69, GeomAPI_Shape.FACE, [0]) +model.testNbSubShapes(Translation_69, GeomAPI_Shape.WIRE, [1]) +model.testHaveNamingFaces(Translation_69, model, Part_1_doc) + +model.testNbResults(Translation_70, 1) +model.testNbSubResults(Translation_70, [0]) +model.testNbSubShapes(Translation_70, GeomAPI_Shape.SOLID, [0]) +model.testNbSubShapes(Translation_70, GeomAPI_Shape.FACE, [0]) +model.testNbSubShapes(Translation_70, GeomAPI_Shape.WIRE, [1]) +model.testHaveNamingFaces(Translation_70, model, Part_1_doc) + +model.testNbResults(Translation_71, 1) +model.testNbSubResults(Translation_71, [0]) +model.testNbSubShapes(Translation_71, GeomAPI_Shape.SOLID, [0]) +model.testNbSubShapes(Translation_71, GeomAPI_Shape.FACE, [0]) +model.testNbSubShapes(Translation_71, GeomAPI_Shape.WIRE, [1]) +model.testHaveNamingFaces(Translation_71, model, Part_1_doc) + +model.testNbResults(Translation_72, 1) +model.testNbSubResults(Translation_72, [0]) +model.testNbSubShapes(Translation_72, GeomAPI_Shape.SOLID, [0]) +model.testNbSubShapes(Translation_72, GeomAPI_Shape.FACE, [1]) +model.testHaveNamingFaces(Translation_72, model, Part_1_doc) + +model.testNbResults(Translation_73, 1) +model.testNbSubResults(Translation_73, [0]) +model.testNbSubShapes(Translation_73, GeomAPI_Shape.SOLID, [0]) +model.testNbSubShapes(Translation_73, GeomAPI_Shape.FACE, [1]) +model.testHaveNamingFaces(Translation_73, model, Part_1_doc) + +model.testNbResults(Translation_74, 1) +model.testNbSubResults(Translation_74, [0]) +model.testNbSubShapes(Translation_74, GeomAPI_Shape.SOLID, [0]) +model.testNbSubShapes(Translation_74, GeomAPI_Shape.FACE, [1]) +model.testHaveNamingFaces(Translation_74, model, Part_1_doc) + +model.testNbResults(Translation_76, 1) +model.testNbSubResults(Translation_76, [0]) +model.testNbSubShapes(Translation_76, GeomAPI_Shape.SOLID, [0]) +model.testNbSubShapes(Translation_76, GeomAPI_Shape.FACE, [1]) +model.testHaveNamingFaces(Translation_76, model, Part_1_doc) + +model.testNbResults(Translation_77, 1) +model.testNbSubResults(Translation_77, [0]) +model.testNbSubShapes(Translation_77, GeomAPI_Shape.SOLID, [0]) +model.testNbSubShapes(Translation_77, GeomAPI_Shape.FACE, [1]) +model.testHaveNamingFaces(Translation_77, model, Part_1_doc) + +model.testNbResults(Translation_78, 1) +model.testNbSubResults(Translation_78, [0]) +model.testNbSubShapes(Translation_78, GeomAPI_Shape.SOLID, [0]) +model.testNbSubShapes(Translation_78, GeomAPI_Shape.FACE, [1]) +model.testHaveNamingFaces(Translation_78, model, Part_1_doc) + +model.testNbResults(Translation_79, 1) +model.testNbSubResults(Translation_79, [0]) +model.testNbSubShapes(Translation_79, GeomAPI_Shape.SOLID, [0]) +model.testNbSubShapes(Translation_79, GeomAPI_Shape.FACE, [1]) +model.testHaveNamingFaces(Translation_79, model, Part_1_doc) + +model.testNbResults(Translation_80, 1) +model.testNbSubResults(Translation_80, [0]) +model.testNbSubShapes(Translation_80, GeomAPI_Shape.SOLID, [0]) +model.testNbSubShapes(Translation_80, GeomAPI_Shape.FACE, [1]) +model.testHaveNamingFaces(Translation_80, model, Part_1_doc) + +model.testNbResults(Translation_81, 1) +model.testNbSubResults(Translation_81, [0]) +model.testNbSubShapes(Translation_81, GeomAPI_Shape.SOLID, [0]) +model.testNbSubShapes(Translation_81, GeomAPI_Shape.FACE, [2]) +model.testNbSubShapes(Translation_81, GeomAPI_Shape.SHELL, [1]) + +model.testNbResults(Translation_82, 1) +model.testNbSubResults(Translation_82, [0]) +model.testNbSubShapes(Translation_82, GeomAPI_Shape.SOLID, [0]) +model.testNbSubShapes(Translation_82, GeomAPI_Shape.FACE, [2]) +model.testNbSubShapes(Translation_82, GeomAPI_Shape.SHELL, [1]) + +model.testNbResults(Translation_83, 1) +model.testNbSubResults(Translation_83, [0]) +model.testNbSubShapes(Translation_83, GeomAPI_Shape.SOLID, [0]) +model.testNbSubShapes(Translation_83, GeomAPI_Shape.FACE, [2]) +model.testNbSubShapes(Translation_83, GeomAPI_Shape.SHELL, [1]) + +model.testNbResults(Translation_85, 1) +model.testNbSubResults(Translation_85, [0]) +model.testNbSubShapes(Translation_85, GeomAPI_Shape.SOLID, [0]) +model.testNbSubShapes(Translation_85, GeomAPI_Shape.FACE, [2]) +model.testNbSubShapes(Translation_85, GeomAPI_Shape.SHELL, [1]) + +model.testNbResults(Translation_86, 1) +model.testNbSubResults(Translation_86, [0]) +model.testNbSubShapes(Translation_86, GeomAPI_Shape.SOLID, [0]) +model.testNbSubShapes(Translation_86, GeomAPI_Shape.FACE, [2]) +model.testNbSubShapes(Translation_86, GeomAPI_Shape.SHELL, [1]) + +model.testNbResults(Translation_87, 1) +model.testNbSubResults(Translation_87, [0]) +model.testNbSubShapes(Translation_87, GeomAPI_Shape.SOLID, [0]) +model.testNbSubShapes(Translation_87, GeomAPI_Shape.FACE, [2]) +model.testNbSubShapes(Translation_87, GeomAPI_Shape.SHELL, [1]) + +model.testNbResults(Translation_88, 1) +model.testNbSubResults(Translation_88, [0]) +model.testNbSubShapes(Translation_88, GeomAPI_Shape.SOLID, [0]) +model.testNbSubShapes(Translation_88, GeomAPI_Shape.FACE, [2]) +model.testNbSubShapes(Translation_88, GeomAPI_Shape.SHELL, [1]) + +model.testNbResults(Translation_89, 1) +model.testNbSubResults(Translation_89, [0]) +model.testNbSubShapes(Translation_89, GeomAPI_Shape.SOLID, [0]) +model.testNbSubShapes(Translation_89, GeomAPI_Shape.FACE, [2]) +model.testNbSubShapes(Translation_89, GeomAPI_Shape.SHELL, [1]) + +model.testNbResults(Translation_90, 2) +model.testNbSubResults(Translation_90, [0, 0]) +model.testNbSubShapes(Translation_90, GeomAPI_Shape.SOLID, [1, 1]) +model.testNbSubShapes(Translation_90, GeomAPI_Shape.FACE, [6, 3]) +model.testHaveNamingFaces(Translation_90, model, Part_1_doc) + + +model.testNbResults(Translation_48, 0) +assert(Translation_48.feature().error() == 'Attribute "axis_object" is not initialized.') + +model.testNbResults(Translation_57, 0) +assert(Translation_57.feature().error() == 'Attribute "axis_object" is not initialized.') + +model.testNbResults(Translation_66, 0) +assert(Translation_66.feature().error() == 'Attribute "axis_object" is not initialized.') + +model.testNbResults(Translation_75, 0) +assert(Translation_75.feature().error() == 'Attribute "axis_object" is not initialized.') + +model.testNbResults(Translation_84, 0) +assert(Translation_84.feature().error() == 'Attribute "axis_object" is not initialized.') \ No newline at end of file diff --git a/test.API/SHAPER/Transformations/TestTranslation_4.py b/test.API/SHAPER/Transformations/TestTranslation_4.py new file mode 100644 index 000000000..3a1b45b29 --- /dev/null +++ b/test.API/SHAPER/Transformations/TestTranslation_4.py @@ -0,0 +1,88 @@ +""" +Test case for Translation feature. +Written on High API. +""" +from salome.shaper import model + +model.begin() +partSet = model.moduleDocument() +Part_1 = model.addPart(partSet) +Part_1_doc = Part_1.document() + +# Boxes +Box_1 = model.addBox(Part_1_doc, 10, 20, 10) +Box_2 = model.addBox(Part_1_doc, 10, 20, 10) +Box_3 = model.addBox(Part_1_doc, 10, 20, 10) +Box_4 = model.addBox(Part_1_doc, 10, 20, 10) +Box_5 = model.addBox(Part_1_doc, 10, 20, 10) +Box_6 = model.addBox(Part_1_doc, 10, 20, 10) +Box_7 = model.addBox(Part_1_doc, 10, 20, 10) +Box_8 = model.addBox(Part_1_doc, 10, 20, 10) + +# Parameters +model.addParameter(Part_1_doc, "dx", "10") +model.addParameter(Part_1_doc, "dy", "15") +model.addParameter(Part_1_doc, "dz", "-5") + +# Translations +Translation_91 = model.addTranslation(Part_1_doc, [model.selection("SOLID", "Box_1_1")], 10, 20, 15) +Translation_92 = model.addTranslation(Part_1_doc, [model.selection("SOLID", "Box_2_1")], 0, 20, 15) +Translation_93 = model.addTranslation(Part_1_doc, [model.selection("SOLID", "Box_3_1")], 10, 0, 15) +Translation_94 = model.addTranslation(Part_1_doc, [model.selection("SOLID", "Box_4_1")], 10, 20, 0) +Translation_95 = model.addTranslation(Part_1_doc, [model.selection("SOLID", "Box_5_1")], -10, 20, 15) +Translation_96 = model.addTranslation(Part_1_doc, [model.selection("SOLID", "Box_6_1")], 10, -20, 15) +Translation_97 = model.addTranslation(Part_1_doc, [model.selection("SOLID", "Box_7_1")], 10, 20, -15) +Translation_98 = model.addTranslation(Part_1_doc, [model.selection("SOLID", "Box_8_1")], "dx", "dy", "dz") +model.do() +model.end() + +# Checks +from GeomAPI import GeomAPI_Shape + +model.testNbResults(Translation_91, 1) +model.testNbSubResults(Translation_91, [0]) +model.testNbSubShapes(Translation_91, GeomAPI_Shape.SOLID, [1]) +model.testNbSubShapes(Translation_91, GeomAPI_Shape.FACE, [6]) +model.testHaveNamingFaces(Translation_91, model, Part_1_doc) + +model.testNbResults(Translation_92, 1) +model.testNbSubResults(Translation_92, [0]) +model.testNbSubShapes(Translation_92, GeomAPI_Shape.SOLID, [1]) +model.testNbSubShapes(Translation_92, GeomAPI_Shape.FACE, [6]) +model.testHaveNamingFaces(Translation_92, model, Part_1_doc) + +model.testNbResults(Translation_93, 1) +model.testNbSubResults(Translation_93, [0]) +model.testNbSubShapes(Translation_93, GeomAPI_Shape.SOLID, [1]) +model.testNbSubShapes(Translation_93, GeomAPI_Shape.FACE, [6]) +model.testHaveNamingFaces(Translation_93, model, Part_1_doc) + +model.testNbResults(Translation_94, 1) +model.testNbSubResults(Translation_94, [0]) +model.testNbSubShapes(Translation_94, GeomAPI_Shape.SOLID, [1]) +model.testNbSubShapes(Translation_94, GeomAPI_Shape.FACE, [6]) +model.testHaveNamingFaces(Translation_94, model, Part_1_doc) + +model.testNbResults(Translation_95, 1) +model.testNbSubResults(Translation_95, [0]) +model.testNbSubShapes(Translation_95, GeomAPI_Shape.SOLID, [1]) +model.testNbSubShapes(Translation_95, GeomAPI_Shape.FACE, [6]) +model.testHaveNamingFaces(Translation_95, model, Part_1_doc) + +model.testNbResults(Translation_96, 1) +model.testNbSubResults(Translation_96, [0]) +model.testNbSubShapes(Translation_96, GeomAPI_Shape.SOLID, [1]) +model.testNbSubShapes(Translation_96, GeomAPI_Shape.FACE, [6]) +model.testHaveNamingFaces(Translation_96, model, Part_1_doc) + +model.testNbResults(Translation_97, 1) +model.testNbSubResults(Translation_97, [0]) +model.testNbSubShapes(Translation_97, GeomAPI_Shape.SOLID, [1]) +model.testNbSubShapes(Translation_97, GeomAPI_Shape.FACE, [6]) +model.testHaveNamingFaces(Translation_97, model, Part_1_doc) + +model.testNbResults(Translation_98, 1) +model.testNbSubResults(Translation_98, [0]) +model.testNbSubShapes(Translation_98, GeomAPI_Shape.SOLID, [1]) +model.testNbSubShapes(Translation_98, GeomAPI_Shape.FACE, [6]) +model.testHaveNamingFaces(Translation_98, model, Part_1_doc) \ No newline at end of file diff --git a/test.API/SHAPER/Transformations/TestTranslation_5.py b/test.API/SHAPER/Transformations/TestTranslation_5.py new file mode 100644 index 000000000..ed0351778 --- /dev/null +++ b/test.API/SHAPER/Transformations/TestTranslation_5.py @@ -0,0 +1,82 @@ +""" +Test case for Translation feature. +Written on High API. +""" +from salome.shaper import model + +model.begin() +partSet = model.moduleDocument() +Part_1 = model.addPart(partSet) +Part_1_doc = Part_1.document() + +# Boxes +Box_1 = model.addBox(Part_1_doc, 10, 20, 10) +Box_2 = model.addBox(Part_1_doc, 10, 20, 10) +Box_3 = model.addBox(Part_1_doc, 10, 20, 10) +Box_4 = model.addBox(Part_1_doc, 10, 20, 10) + +# Sketches +Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOY")) +SketchLine_1 = Sketch_1.addLine(47.23370043826552, 82.68004022993115, -80.41547074975036, -6.189635913624215) +SketchLine_2 = Sketch_1.addLine(-80.41547074975036, -6.189635913624215, 57.33252727276048, -26.79124265599387) +SketchLine_3 = Sketch_1.addLine(57.33252727276048, -26.79124265599387, 47.23370043826552, 82.68004022993115) +SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchLine_2.startPoint()) +SketchConstraintCoincidence_2 = Sketch_1.setCoincident(SketchLine_2.endPoint(), SketchLine_3.startPoint()) +SketchConstraintCoincidence_3 = Sketch_1.setCoincident(SketchLine_1.startPoint(), SketchLine_3.endPoint()) +model.do() + +# Points +Point_1 = model.addPoint(Part_1_doc, 10, 0, 0) +Point_2 = model.addPoint(Part_1_doc, 10, 10, 0) + +# Vertex +Vertex_1 = model.addVertex(Part_1_doc, [model.selection("VERTEX", "Sketch_1/Vertex-SketchLine_1s-SketchLine_3e")]) +Vertex_2 = model.addVertex(Part_1_doc, [model.selection("VERTEX", "Sketch_1/Vertex-SketchLine_2s-SketchLine_1e")]) + +# Translations +Translation_99 = model.addTranslation(Part_1_doc, [model.selection("SOLID", "Box_1_1")], model.selection("VERTEX", "Point_1"), model.selection("VERTEX", "Point_2")) +Translation_100 = model.addTranslation(Part_1_doc, [model.selection("SOLID", "Box_1_1")], model.selection("VERTEX", "Point_1"), model.selection("VERTEX", "Point_1")) +Translation_101 = model.addTranslation(Part_1_doc, [model.selection("SOLID", "Box_1_1")], model.selection("VERTEX", "InvalidName"), model.selection("VERTEX", "Point_1")) +Translation_102 = model.addTranslation(Part_1_doc, [model.selection("SOLID", "Box_1_1")], model.selection("VERTEX", "Point_1"), model.selection("VERTEX", "InvalidName")) +Translation_103 = model.addTranslation(Part_1_doc, [model.selection("SOLID", "Box_2_1")], model.selection("VERTEX", "Sketch_1/Vertex-SketchLine_1s-SketchLine_3e"), model.selection("VERTEX", "Sketch_1/Vertex-SketchLine_2s-SketchLine_1e")) +Translation_104 = model.addTranslation(Part_1_doc, [model.selection("SOLID", "Box_3_1")], model.selection("VERTEX", "Vertex_1_1"), model.selection("VERTEX", "Vertex_2_1")) +Translation_105 = model.addTranslation(Part_1_doc, [model.selection("SOLID", "Box_4_1")], model.selection("VERTEX", "Box_4_1/Back&Box_4_1/Left&Box_4_1/Bottom"), model.selection("VERTEX", "Box_4_1/Front&Box_4_1/Right&Box_4_1/Top")) +model.do() +model.end() + +# Checks +from GeomAPI import GeomAPI_Shape + +model.testNbResults(Translation_99, 1) +model.testNbSubResults(Translation_99, [0]) +model.testNbSubShapes(Translation_99, GeomAPI_Shape.SOLID, [1]) +model.testNbSubShapes(Translation_99, GeomAPI_Shape.FACE, [6]) +model.testHaveNamingFaces(Translation_99, model, Part_1_doc) + +model.testNbResults(Translation_103, 1) +model.testNbSubResults(Translation_103, [0]) +model.testNbSubShapes(Translation_103, GeomAPI_Shape.SOLID, [1]) +model.testNbSubShapes(Translation_103, GeomAPI_Shape.FACE, [6]) +model.testHaveNamingFaces(Translation_103, model, Part_1_doc) + +model.testNbResults(Translation_104, 1) +model.testNbSubResults(Translation_104, [0]) +model.testNbSubShapes(Translation_104, GeomAPI_Shape.SOLID, [1]) +model.testNbSubShapes(Translation_104, GeomAPI_Shape.FACE, [6]) +model.testHaveNamingFaces(Translation_104, model, Part_1_doc) + +model.testNbResults(Translation_105, 1) +model.testNbSubResults(Translation_105, [0]) +model.testNbSubShapes(Translation_105, GeomAPI_Shape.SOLID, [1]) +model.testNbSubShapes(Translation_105, GeomAPI_Shape.FACE, [6]) +model.testHaveNamingFaces(Translation_105, model, Part_1_doc) + + +model.testNbResults(Translation_100, 0) +assert(Translation_100.feature().error() == 'The feature uses equal shapes.') + +model.testNbResults(Translation_101, 0) +assert(Translation_101.feature().error() == 'Attribute "start_point" is not initialized.') + +model.testNbResults(Translation_102, 0) +assert(Translation_102.feature().error() == 'Attribute "end_point" is not initialized.') \ No newline at end of file