From: Clarisse Genrault Date: Mon, 20 Feb 2017 15:14:15 +0000 (+0100) Subject: Transfer of tests (Primitives, Transfotmation and GDML). X-Git-Tag: V_2.7.0~276 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=dd0b46599739f3596d18a18b1f23f5290754e73c;p=modules%2Fshaper.git Transfer of tests (Primitives, Transfotmation and GDML). --- diff --git a/src/FeaturesAPI/Test/APIParam_Scale.py b/src/FeaturesAPI/Test/APIParam_Scale.py deleted file mode 100644 index f0a33e077..000000000 --- a/src/FeaturesAPI/Test/APIParam_Scale.py +++ /dev/null @@ -1,37 +0,0 @@ -""" -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 diff --git a/src/FeaturesAPI/Test/APIParam_Symmetry.py b/src/FeaturesAPI/Test/APIParam_Symmetry.py deleted file mode 100644 index 97aca11e8..000000000 --- a/src/FeaturesAPI/Test/APIParam_Symmetry.py +++ /dev/null @@ -1,47 +0,0 @@ -""" -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 diff --git a/src/FeaturesAPI/Test/APIParam_Translation.py b/src/FeaturesAPI/Test/APIParam_Translation.py deleted file mode 100644 index 85657d32f..000000000 --- a/src/FeaturesAPI/Test/APIParam_Translation.py +++ /dev/null @@ -1,43 +0,0 @@ -""" -Test case for Translation 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() -aBox = model.addBox(aDocument, 10, 10, 10) - -# Perform a translation by an axis and a distance -aSession.startOperation() -aTranslation1 = model.addTranslation(aDocument, [model.selection("SOLID", "Box_1_1")], model.selection("EDGE", "Box_1_1/Front&Box_1_1/Bottom"), 20).result() -aSession.finishOperation() -assert (aTranslation1 is not None) - -# Perform a translation by DX, DY, DZ vector -aSession.startOperation() -aTranslation2 = model.addTranslation(aDocument, [model.selection("SOLID", "Box_1_1")], 10, 10, 10).result() -aSession.finishOperation() -assert (aTranslation2 is not None) - -# Perform a translation by two points -aSession.startOperation() -aPoint1 = model.addPoint(aDocument, 0, 0, 0).result() -aPoint2 = model.addPoint(aDocument, 10, 10, 0).result() -aTranslation3 = model.addTranslation(aDocument, [model.selection("SOLID", "Box_1_1")], aPoint1, aPoint2).result() -aSession.finishOperation() -assert (aTranslation3 is not None) diff --git a/src/GDMLAPI/Test/TestConeSegment.py b/src/GDMLAPI/Test/TestConeSegment.py deleted file mode 100644 index d58b45ad6..000000000 --- a/src/GDMLAPI/Test/TestConeSegment.py +++ /dev/null @@ -1,106 +0,0 @@ -""" -Test case for GDML Primitive Cone Segment 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 several "cone segment" -aSession.startOperation() -aCS1 = model.addConeSegment(aDocument,7.,11.,5.,8.,12.,0.,270.).result() -aSession.finishOperation() -assert (aCS1 is not None) - -aSession.startOperation() -aCS2 = model.addConeSegment(aDocument,5.,10.,7.,15.,15.,45.,180.).result() -aSession.finishOperation() -assert (aCS2 is not None) - -aSession.startOperation() -aCS3 = model.addConeSegment(aDocument,5.,10.,7.,15.,15.,-45.,180.).result() -aSession.finishOperation() -assert (aCS3 is not None) - -aSession.startOperation() -aCS4 = model.addConeSegment(aDocument,0.,10.,2.,7.,3.,0.,270.).result() -aSession.finishOperation() -assert (aCS4 is not None) - -aSession.startOperation() -aCS5 = model.addConeSegment(aDocument,5.,8.,0.,6.,10.,45.,270.).result() -aSession.finishOperation() -assert (aCS5 is not None) - -aSession.startOperation() -aCS6 = model.addConeSegment(aDocument,0.,6.,0.,4.,17.,0.,270.).result() -aSession.finishOperation() -assert (aCS6 is not None) - -aSession.startOperation() -aCS7 = model.addConeSegment(aDocument,7.,11.,5.,8.,12.,0.,360.).result() -aSession.finishOperation() -assert (aCS7 is not None) - -aSession.startOperation() -aCS8 = model.addConeSegment(aDocument,-5.,11.,5.,8.,12.,0.,270.) -aSession.finishOperation() -assert (len(aCS8.results()) == 0) - -aSession.startOperation() -aCS9 = model.addConeSegment(aDocument,11.,7.,5.,8.,12.,0.,270.) -aSession.finishOperation() -assert (len(aCS9.results()) == 0) - -aSession.startOperation() -aCS10 = model.addConeSegment(aDocument,7.,11.,8.,5.,12.,0.,270.) -aSession.finishOperation() -assert (len(aCS10.results()) == 0) - -aSession.startOperation() -aCS11 = model.addConeSegment(aDocument,7.,11.,-3.,5.,12.,0.,270.) -aSession.finishOperation() -assert (len(aCS11.results()) == 0) - -aSession.startOperation() -aCS12 = model.addConeSegment(aDocument,7.,11.,5.,8.,0.,0.,270.) -aSession.finishOperation() -assert (len(aCS12.results()) == 0) - -aSession.startOperation() -aCS13 = model.addConeSegment(aDocument,7.,11.,5.,8.,-10.,0.,270.) -aSession.finishOperation() -assert (len(aCS13.results()) == 0) - -aSession.startOperation() -aCS14 = model.addConeSegment(aDocument,7.,11.,5.,8.,12.,-45.,-45.) -aSession.finishOperation() -assert (len(aCS14.results()) == 0) - -aSession.startOperation() -aCS15 = model.addConeSegment(aDocument,7.,11.,5.,8.,12.,45.,450.) -aSession.finishOperation() -assert (len(aCS15.results()) == 0) - -aSession.startOperation() -model.addParameter(aDocument,"rmin1","7.") -model.addParameter(aDocument,"rmax1","11.") -model.addParameter(aDocument,"rmin2","5.") -model.addParameter(aDocument,"rmax2","8.") -model.addParameter(aDocument,"z","12.") -model.addParameter(aDocument,"startphi","0.") -model.addParameter(aDocument,"deltaphi","270.") -aCS16 = model.addConeSegment(aDocument,"rmin1","rmax1","rmin2","rmax2","z","startphi","deltaphi").result() -aSession.finishOperation() -assert (aCS16 is not None) diff --git a/src/GeomAlgoAPI/Test/TestAPI_Box.py b/src/GeomAlgoAPI/Test/TestAPI_Box.py deleted file mode 100644 index c3d445d5f..000000000 --- a/src/GeomAlgoAPI/Test/TestAPI_Box.py +++ /dev/null @@ -1,121 +0,0 @@ -# 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 - -# Create a box with dimensions -try : - box1 = shaperpy.makeBox(10.,10.,10.) - print "box1 : ok" - -except myExcept,ec: - print "box1 : ko (" + ec.what() + ")" - -try : - box2 = shaperpy.makeBox(0.,10.,10.) - print "box2 : ok" - -except myExcept,ec: - print "box2 : ko (" + ec.what() + ")" - -try : - box3 = shaperpy.makeBox(10.,0.,10.) - print "box3 : ok" - -except myExcept,ec: - print "box3 : ko (" + ec.what() + ")" - -try : - box4 = shaperpy.makeBox(10.,10.,0.) - print "box4 : ok" - -except myExcept,ec: - print "box4 : ko (" + ec.what() + ")" - -try : - box5 = shaperpy.makeBox(-10.,10.,10.) - print "box5 : ok" - -except myExcept,ec: - print "box5 : ko (" + ec.what() + ")" - -try : - box6 = shaperpy.makeBox(10.,-10.,10.) - print "box6 : ok" - -except myExcept,ec: - print "box6 : ko (" + ec.what() + ")" - -try : - box7 = shaperpy.makeBox(10.,10.,-10.) - print "box7 : ok" - -except myExcept,ec: - print "box7 : ko (" + ec.what() + ")" - -# Create a box with two points defining the diagonal -try : - pnt1 = pnt(0.,0.,0.) - pnt2 = pnt(50.,50.,50.) - box8 = shaperpy.makeBox(pnt1,pnt2) - print "box8 : ok" - -except myExcept,ec: - print "box8 : ko (" + ec.what() + ")" - -try : - pnt1 = pnt(0.,0.,0.) - box9 = shaperpy.makeBox(pnt1,pnt1) - print "box9 : ok" - -except myExcept,ec: - print "box9 : ko (" + ec.what() + ")" - -try : - pnt1 = pnt(0.,0.,0.) - pnt2 = pnt(0.,50.,50.) - box10 = shaperpy.makeBox(pnt1,pnt2) - print "box10 : ok" - -except myExcept,ec: - print "box10 : ko (" + ec.what() + ")" - -try : - pnt1 = pnt(0.,0.,0.) - pnt2 = pnt(50.,0.,50.) - box11 = shaperpy.makeBox(pnt1,pnt2) - print "box11 : ok" - -except myExcept,ec: - print "box11 : ko (" + ec.what() + ")" - -try : - pnt1 = pnt(0.,0.,0.) - pnt2 = pnt(50.,50.,0.) - box12 = shaperpy.makeBox(pnt1,pnt2) - print "box12 : ok" - -except myExcept,ec: - print "box12 : ko (" + ec.what() + ")" - -try : - pnt1 = pnt(50.,50.,50.) - box13 = shaperpy.makeBox(pnt1,None) - print "box13 : ok" - -except myExcept,ec: - print "box13 : ko (" + ec.what() + ")" - -try : - pnt2 = pnt(50.,50.,50.) - box14 = shaperpy.makeBox(None,pnt2) - print "box14 : ok" - -except myExcept,ec: - print "box14 : ko (" + ec.what() + ")" - diff --git a/src/GeomAlgoAPI/Test/TestAPI_Cylinder.py b/src/GeomAlgoAPI/Test/TestAPI_Cylinder.py deleted file mode 100644 index 50a4b877d..000000000 --- a/src/GeomAlgoAPI/Test/TestAPI_Cylinder.py +++ /dev/null @@ -1,41 +0,0 @@ -# Copyright (C) 2014-201x CEA/DEN, EDF R&D - -# File: TestAPI_Cylinder.py -# Created: 13 Jan 2017 -# Author: Clarisse Genrault (CEA) - -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 - -aPoint = pnt(10.,5.,0.) -anEdge = edgeBuilder.line(1.,0.,0.) - -# Create a cylinder -try : - cylinder1 = shaperpy.makeCylinder(5., 20.) - -except myExcept,ec: - print ec.what() - -# Create a cylinder -try : - cylinder2 = shaperpy.makeCylinder(5., 20., 100.) - -except myExcept,ec: - print ec.what() - -# Create a cylinder -try : - cylinder3 = shaperpy.makeCylinder(aPoint, anEdge, 5., 20.) - -except myExcept,ec: - print ec.what() - -# Create a cylinder -try : - cylinder4 = shaperpy.makeCylinder(aPoint, anEdge, 5., 20., 180.) - -except myExcept,ec: - print ec.what() \ No newline at end of file diff --git a/src/GeomAlgoAPI/Test/TestAPI_GDMLConeSegment.py b/src/GeomAlgoAPI/Test/TestAPI_GDMLConeSegment.py deleted file mode 100644 index 59a58dde3..000000000 --- a/src/GeomAlgoAPI/Test/TestAPI_GDMLConeSegment.py +++ /dev/null @@ -1,85 +0,0 @@ -# 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 - -# Create several "cone segment" -try : - CS1 = shaperpy.makeConeSegment(7.,11.,5.,8.,12.,0.,270.) -except myExcept,ec: - print ec.what() - -try : - CS2 = shaperpy.makeConeSegment(5.,10.,7.,15.,15.,45.,180.) -except myExcept,ec: - print ec.what() - -try : - CS3 = shaperpy.makeConeSegment(5.,10.,7.,15.,15.,-45.,180.) -except myExcept,ec: - print ec.what() - -try : - CS4 = shaperpy.makeConeSegment(0.,10.,2.,7.,3.,0.,270.) -except myExcept,ec: - print ec.what() - -try : - CS5 = shaperpy.makeConeSegment(5.,8.,0.,6.,10.,45.,270.) -except myExcept,ec: - print ec.what() - -try : - CS6 = shaperpy.makeConeSegment(0.,6.,0.,4.,17.,0.,270.) -except myExcept,ec: - print ec.what() - -try : - CS7 = shaperpy.makeConeSegment(7.,11.,5.,8.,12.,0.,360.) -except myExcept,ec: - print ec.what() - -try : - CS8 = shaperpy.makeConeSegment(-5.,11.,5.,8.,12.,0.,270.) -except myExcept,ec: - print ec.what() - -try : - CS9 = shaperpy.makeConeSegment(11.,7.,5.,8.,12.,0.,270.) -except myExcept,ec: - print ec.what() - -try : - CS10 = shaperpy.makeConeSegment(7.,11.,8.,5.,12.,0.,270.) -except myExcept,ec: - print ec.what() - -try : - CS11 = shaperpy.makeConeSegment(7.,11.,-3.,5.,12.,0.,270.) -except myExcept,ec: - print ec.what() - -try : - CS12 = shaperpy.makeConeSegment(7.,11.,5.,8.,0.,0.,270.) -except myExcept,ec: - print ec.what() - -try : - CS13 = shaperpy.makeConeSegment(7.,11.,5.,8.,-10.,0.,270.) -except myExcept,ec: - print ec.what() - -try : - CS14 = shaperpy.makeConeSegment(7.,11.,5.,8.,12.,-45.,-45.) -except myExcept,ec: - print ec.what() - -try : - CS15 = shaperpy.makeConeSegment(7.,11.,5.,8.,12.,45.,450.) -except myExcept,ec: - print ec.what() \ No newline at end of file diff --git a/src/GeomAlgoAPI/Test/TestAPI_Scale.py b/src/GeomAlgoAPI/Test/TestAPI_Scale.py deleted file mode 100644 index a60134807..000000000 --- a/src/GeomAlgoAPI/Test/TestAPI_Scale.py +++ /dev/null @@ -1,32 +0,0 @@ -# Copyright (C) 2014-201x CEA/DEN, EDF R&D - -# File: TestAPI_Scale.py -# Created: 25 Jan 2017 -# 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 - -# Create a box -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. -try : - scale1 = shaperpy.makeScale(box1,centerPoint, -1.6) - -except myExcept, ec: - print ec.what() - -# Perfom a scale by dimensions. -try : - scale2 = shaperpy.makeScale(box2,centerPoint, 2, -0.5, 1.3) - -except myExcept, ec: - print ec.what() diff --git a/src/GeomAlgoAPI/Test/TestAPI_Symmetry.py b/src/GeomAlgoAPI/Test/TestAPI_Symmetry.py deleted file mode 100644 index 409d39863..000000000 --- a/src/GeomAlgoAPI/Test/TestAPI_Symmetry.py +++ /dev/null @@ -1,48 +0,0 @@ -# Copyright (C) 2014-2016 CEA/DEN, EDF R&D - -# 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 - -# 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() - -# 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() diff --git a/src/GeomAlgoAPI/Test/TestAPI_Translation.py b/src/GeomAlgoAPI/Test/TestAPI_Translation.py deleted file mode 100644 index b3933912e..000000000 --- a/src/GeomAlgoAPI/Test/TestAPI_Translation.py +++ /dev/null @@ -1,44 +0,0 @@ -# Copyright (C) 2014-2016 CEA/DEN, EDF R&D - -# File: TestAPI_Translation.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_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() diff --git a/src/PrimitivesAPI/Test/TestBox.py b/src/PrimitivesAPI/Test/TestBox.py deleted file mode 100644 index bc80102aa..000000000 --- a/src/PrimitivesAPI/Test/TestBox.py +++ /dev/null @@ -1,171 +0,0 @@ -""" -Test case for Primitive Box 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 with dimensions -aSession.startOperation() -aBox1 = model.addBox(aDocument, 10, 10, 10) -model.testNbResults(aBox1, 1) -model.testNbSubShapes(aBox1, GeomAPI_Shape.SOLID, [1]) -model.testNbSubShapes(aBox1, GeomAPI_Shape.FACE, [6]) -print "box1 : ok" -aSession.finishOperation() - -aSession.startOperation() -aBox2 = model.addBox(aDocument, 0, 10, 10) -model.testNbResults(aBox2, 0) -print "box2 : ko (" + aBox2.feature().error() + ")" -aSession.finishOperation() - -aSession.startOperation() -aBox3 = model.addBox(aDocument, 10, 0, 10) -model.testNbResults(aBox3, 0) -print "box3 : ko (" + aBox3.feature().error() + ")" -aSession.finishOperation() - -aSession.startOperation() -aBox4 = model.addBox(aDocument, 10, 10, 0) -model.testNbResults(aBox4, 0) -print "box4 : ko (" + aBox4.feature().error() + ")" -aSession.finishOperation() - -aSession.startOperation() -aBox5 = model.addBox(aDocument, -10, 10, 10) -model.testNbResults(aBox5, 0) -print "box5 : ko (" + aBox5.feature().error() + ")" -aSession.finishOperation() - -aSession.startOperation() -aBox6 = model.addBox(aDocument, 10, -10, 10) -model.testNbResults(aBox6, 0) -print "box6 : ko (" + aBox6.feature().error() + ")" -aSession.finishOperation() - -aSession.startOperation() -aBox7 = model.addBox(aDocument, 10, 10, -10) -model.testNbResults(aBox7, 0) -print "box7 : ko (" + aBox7.feature().error() + ")" -aSession.finishOperation() - -# Create a box with 2 points -aSession.startOperation() -aPoint1 = model.addPoint(aDocument, 0, 0, 0).result() -aPoint2 = model.addPoint(aDocument, 50, 50, 50).result() -aBox8 = model.addBox(aDocument, aPoint1, aPoint2) -model.testNbResults(aBox8, 1) -model.testNbSubShapes(aBox8, GeomAPI_Shape.SOLID, [1]) -model.testNbSubShapes(aBox8, GeomAPI_Shape.FACE, [6]) -print "box8 : ok" -aSession.finishOperation() - -aSession.startOperation() -aPoint1 = model.addPoint(aDocument, 0, 0, 0).result() -aBox9 = model.addBox(aDocument, aPoint1, aPoint1) -model.testNbResults(aBox9, 0) -print "box9 : ko (" + aBox9.feature().error() + ")" -aSession.finishOperation() - -aSession.startOperation() -aPoint1 = model.addPoint(aDocument, 0, 0, 0).result() -aPoint2 = model.addPoint(aDocument, 0, 50, 50).result() -aBox10 = model.addBox(aDocument, aPoint1, aPoint2) -model.testNbResults(aBox10, 0) -print "box10 : ko (" + aBox10.feature().error() + ")" -aSession.finishOperation() - -aSession.startOperation() -aPoint1 = model.addPoint(aDocument, 0, 0, 0).result() -aPoint2 = model.addPoint(aDocument, 50, 0, 50).result() -aBox11 = model.addBox(aDocument, aPoint1, aPoint2) -model.testNbResults(aBox11, 0) -print "box11 : ko (" + aBox11.feature().error() + ")" -aSession.finishOperation() - -aSession.startOperation() -aPoint1 = model.addPoint(aDocument, 0, 0, 0).result() -aPoint2 = model.addPoint(aDocument, 50, 50, 0).result() -aBox12 = model.addBox(aDocument, aPoint1, aPoint2) -model.testNbResults(aBox12, 0) -print "box12 : ko (" + aBox12.feature().error() + ")" -aSession.finishOperation() - -aSession.startOperation() -aPoint1 = model.selection("VERTEX", "point1") -aPoint2 = model.addPoint(aDocument, 50, 50, 0).result() -aBox13 = model.addBox(aDocument, aPoint1, aPoint2) -model.testNbResults(aBox13, 0) -print "box13 : ko (" + aBox13.feature().error() + ")" -aSession.finishOperation() - -aSession.startOperation() -aPoint1 = model.addPoint(aDocument, 0, 0, 0).result() -aPoint2 = model.selection("VERTEX", "point2") -aBox14 = model.addBox(aDocument, aPoint1, aPoint2) -model.testNbResults(aBox14, 0) -print "box14 : ko (" + aBox14.feature().error() + ")" -aSession.finishOperation() - -aSession.startOperation() -Sketch_1 = model.addSketch(aDocument, model.defaultPlane("XOY")) -Sketch_2 = model.addSketch(aDocument, model.defaultPlane("YOZ")) -SketchLine_1 = Sketch_1.addLine(20, 10, 40, 10) -SketchLine_2 = Sketch_1.addLine(40, 10, 40, 20) -SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchLine_2.startPoint()) -SketchLine_3 = Sketch_1.addLine(40, 20, 20, 20) -SketchLine_4 = Sketch_1.addLine(20, 20, 20, 10) -SketchConstraintCoincidence_3 = Sketch_1.setCoincident(SketchLine_3.endPoint(), SketchLine_4.startPoint()) -SketchConstraintCoincidence_4 = Sketch_1.setCoincident(SketchLine_1.startPoint(), SketchLine_4.endPoint()) -SketchLine_5 = Sketch_2.addLine(20, 10, 40, 10) -SketchLine_6 = Sketch_2.addLine(40, 10, 40, 20) -SketchConstraintCoincidence_1 = Sketch_2.setCoincident(SketchLine_5.endPoint(), SketchLine_6.startPoint()) -SketchLine_7 = Sketch_2.addLine(40, 20, 20, 20) -SketchLine_8 = Sketch_2.addLine(20, 20, 20, 10) -SketchConstraintCoincidence_3 = Sketch_2.setCoincident(SketchLine_7.endPoint(), SketchLine_8.startPoint()) -SketchConstraintCoincidence_4 = Sketch_2.setCoincident(SketchLine_5.startPoint(), SketchLine_8.endPoint()) -aSession.finishOperation() - -aSession.startOperation() -aBox15 = model.addBox(aDocument, model.selection("VERTEX", "Sketch_1/Vertex-SketchLine_1s-SketchLine_4e"), - model.selection("VERTEX", "Sketch_2/Vertex-SketchLine_7s-SketchLine_6e")) - -model.testNbResults(aBox15, 1) -model.testNbSubShapes(aBox15, GeomAPI_Shape.SOLID, [1]) -model.testNbSubShapes(aBox15, GeomAPI_Shape.FACE, [6]) -print "box15 : ok" -aSession.finishOperation() - -aSession.startOperation() -Extrusion_1 = model.addExtrusion(aDocument, [model.selection("COMPOUND", "Sketch_1")], model.selection("EDGE", "PartSet/OZ"), 100, 0) -Extrusion_2 = model.addExtrusion(aDocument, [model.selection("COMPOUND", "Sketch_2")], model.selection("EDGE", "PartSet/OX"), 100, 0) -aBox16 = model.addBox(aDocument, model.selection("VERTEX", "Extrusion_1_1/Generated_Face_3&Extrusion_1_1/Generated_Face_2&Extrusion_1_1/To_Face_1"), - model.selection("VERTEX", "Extrusion_2_1/Generated_Face_2&Extrusion_2_1/Generated_Face_1&Extrusion_2_1/To_Face_1")) -model.testNbResults(aBox16, 1) -model.testNbSubShapes(aBox16, GeomAPI_Shape.SOLID, [1]) -model.testNbSubShapes(aBox16, GeomAPI_Shape.FACE, [6]) -print "box16 : ok" -aSession.finishOperation() - -aSession.startOperation() -Vertex_1 = model.addVertex(aDocument, [model.selection("VERTEX", "Sketch_1/Vertex-SketchLine_1s-SketchLine_4e")]) -Vertex_2 = model.addVertex(aDocument, [model.selection("VERTEX", "Sketch_2/Vertex-SketchLine_7s-SketchLine_6e")]) -aBox17 = model.addBox(aDocument, model.selection("VERTEX", "Vertex_1_1"), model.selection("VERTEX", "Vertex_2_1")) -model.testNbResults(aBox17, 1) -model.testNbSubShapes(aBox17, GeomAPI_Shape.SOLID, [1]) -model.testNbSubShapes(aBox17, GeomAPI_Shape.FACE, [6]) -print "box17 : ok" -aSession.finishOperation() diff --git a/src/PrimitivesAPI/Test/TestCylinder.py b/src/PrimitivesAPI/Test/TestCylinder.py deleted file mode 100644 index 38e6d260b..000000000 --- a/src/PrimitivesAPI/Test/TestCylinder.py +++ /dev/null @@ -1,44 +0,0 @@ -""" -Test case for Primitive Cylinder 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() - -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() - diff --git a/test.API/SHAPER/GDML/TestAPI_ConeSegment.py b/test.API/SHAPER/GDML/TestAPI_ConeSegment.py new file mode 100644 index 000000000..59a58dde3 --- /dev/null +++ b/test.API/SHAPER/GDML/TestAPI_ConeSegment.py @@ -0,0 +1,85 @@ +# 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 + +# Create several "cone segment" +try : + CS1 = shaperpy.makeConeSegment(7.,11.,5.,8.,12.,0.,270.) +except myExcept,ec: + print ec.what() + +try : + CS2 = shaperpy.makeConeSegment(5.,10.,7.,15.,15.,45.,180.) +except myExcept,ec: + print ec.what() + +try : + CS3 = shaperpy.makeConeSegment(5.,10.,7.,15.,15.,-45.,180.) +except myExcept,ec: + print ec.what() + +try : + CS4 = shaperpy.makeConeSegment(0.,10.,2.,7.,3.,0.,270.) +except myExcept,ec: + print ec.what() + +try : + CS5 = shaperpy.makeConeSegment(5.,8.,0.,6.,10.,45.,270.) +except myExcept,ec: + print ec.what() + +try : + CS6 = shaperpy.makeConeSegment(0.,6.,0.,4.,17.,0.,270.) +except myExcept,ec: + print ec.what() + +try : + CS7 = shaperpy.makeConeSegment(7.,11.,5.,8.,12.,0.,360.) +except myExcept,ec: + print ec.what() + +try : + CS8 = shaperpy.makeConeSegment(-5.,11.,5.,8.,12.,0.,270.) +except myExcept,ec: + print ec.what() + +try : + CS9 = shaperpy.makeConeSegment(11.,7.,5.,8.,12.,0.,270.) +except myExcept,ec: + print ec.what() + +try : + CS10 = shaperpy.makeConeSegment(7.,11.,8.,5.,12.,0.,270.) +except myExcept,ec: + print ec.what() + +try : + CS11 = shaperpy.makeConeSegment(7.,11.,-3.,5.,12.,0.,270.) +except myExcept,ec: + print ec.what() + +try : + CS12 = shaperpy.makeConeSegment(7.,11.,5.,8.,0.,0.,270.) +except myExcept,ec: + print ec.what() + +try : + CS13 = shaperpy.makeConeSegment(7.,11.,5.,8.,-10.,0.,270.) +except myExcept,ec: + print ec.what() + +try : + CS14 = shaperpy.makeConeSegment(7.,11.,5.,8.,12.,-45.,-45.) +except myExcept,ec: + print ec.what() + +try : + CS15 = shaperpy.makeConeSegment(7.,11.,5.,8.,12.,45.,450.) +except myExcept,ec: + print ec.what() \ No newline at end of file diff --git a/test.API/SHAPER/GDML/TestConeSegment.py b/test.API/SHAPER/GDML/TestConeSegment.py new file mode 100644 index 000000000..d58b45ad6 --- /dev/null +++ b/test.API/SHAPER/GDML/TestConeSegment.py @@ -0,0 +1,106 @@ +""" +Test case for GDML Primitive Cone Segment 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 several "cone segment" +aSession.startOperation() +aCS1 = model.addConeSegment(aDocument,7.,11.,5.,8.,12.,0.,270.).result() +aSession.finishOperation() +assert (aCS1 is not None) + +aSession.startOperation() +aCS2 = model.addConeSegment(aDocument,5.,10.,7.,15.,15.,45.,180.).result() +aSession.finishOperation() +assert (aCS2 is not None) + +aSession.startOperation() +aCS3 = model.addConeSegment(aDocument,5.,10.,7.,15.,15.,-45.,180.).result() +aSession.finishOperation() +assert (aCS3 is not None) + +aSession.startOperation() +aCS4 = model.addConeSegment(aDocument,0.,10.,2.,7.,3.,0.,270.).result() +aSession.finishOperation() +assert (aCS4 is not None) + +aSession.startOperation() +aCS5 = model.addConeSegment(aDocument,5.,8.,0.,6.,10.,45.,270.).result() +aSession.finishOperation() +assert (aCS5 is not None) + +aSession.startOperation() +aCS6 = model.addConeSegment(aDocument,0.,6.,0.,4.,17.,0.,270.).result() +aSession.finishOperation() +assert (aCS6 is not None) + +aSession.startOperation() +aCS7 = model.addConeSegment(aDocument,7.,11.,5.,8.,12.,0.,360.).result() +aSession.finishOperation() +assert (aCS7 is not None) + +aSession.startOperation() +aCS8 = model.addConeSegment(aDocument,-5.,11.,5.,8.,12.,0.,270.) +aSession.finishOperation() +assert (len(aCS8.results()) == 0) + +aSession.startOperation() +aCS9 = model.addConeSegment(aDocument,11.,7.,5.,8.,12.,0.,270.) +aSession.finishOperation() +assert (len(aCS9.results()) == 0) + +aSession.startOperation() +aCS10 = model.addConeSegment(aDocument,7.,11.,8.,5.,12.,0.,270.) +aSession.finishOperation() +assert (len(aCS10.results()) == 0) + +aSession.startOperation() +aCS11 = model.addConeSegment(aDocument,7.,11.,-3.,5.,12.,0.,270.) +aSession.finishOperation() +assert (len(aCS11.results()) == 0) + +aSession.startOperation() +aCS12 = model.addConeSegment(aDocument,7.,11.,5.,8.,0.,0.,270.) +aSession.finishOperation() +assert (len(aCS12.results()) == 0) + +aSession.startOperation() +aCS13 = model.addConeSegment(aDocument,7.,11.,5.,8.,-10.,0.,270.) +aSession.finishOperation() +assert (len(aCS13.results()) == 0) + +aSession.startOperation() +aCS14 = model.addConeSegment(aDocument,7.,11.,5.,8.,12.,-45.,-45.) +aSession.finishOperation() +assert (len(aCS14.results()) == 0) + +aSession.startOperation() +aCS15 = model.addConeSegment(aDocument,7.,11.,5.,8.,12.,45.,450.) +aSession.finishOperation() +assert (len(aCS15.results()) == 0) + +aSession.startOperation() +model.addParameter(aDocument,"rmin1","7.") +model.addParameter(aDocument,"rmax1","11.") +model.addParameter(aDocument,"rmin2","5.") +model.addParameter(aDocument,"rmax2","8.") +model.addParameter(aDocument,"z","12.") +model.addParameter(aDocument,"startphi","0.") +model.addParameter(aDocument,"deltaphi","270.") +aCS16 = model.addConeSegment(aDocument,"rmin1","rmax1","rmin2","rmax2","z","startphi","deltaphi").result() +aSession.finishOperation() +assert (aCS16 is not None) diff --git a/test.API/SHAPER/Primitives/TestAPI_Box.py b/test.API/SHAPER/Primitives/TestAPI_Box.py new file mode 100644 index 000000000..c3d445d5f --- /dev/null +++ b/test.API/SHAPER/Primitives/TestAPI_Box.py @@ -0,0 +1,121 @@ +# 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 + +# Create a box with dimensions +try : + box1 = shaperpy.makeBox(10.,10.,10.) + print "box1 : ok" + +except myExcept,ec: + print "box1 : ko (" + ec.what() + ")" + +try : + box2 = shaperpy.makeBox(0.,10.,10.) + print "box2 : ok" + +except myExcept,ec: + print "box2 : ko (" + ec.what() + ")" + +try : + box3 = shaperpy.makeBox(10.,0.,10.) + print "box3 : ok" + +except myExcept,ec: + print "box3 : ko (" + ec.what() + ")" + +try : + box4 = shaperpy.makeBox(10.,10.,0.) + print "box4 : ok" + +except myExcept,ec: + print "box4 : ko (" + ec.what() + ")" + +try : + box5 = shaperpy.makeBox(-10.,10.,10.) + print "box5 : ok" + +except myExcept,ec: + print "box5 : ko (" + ec.what() + ")" + +try : + box6 = shaperpy.makeBox(10.,-10.,10.) + print "box6 : ok" + +except myExcept,ec: + print "box6 : ko (" + ec.what() + ")" + +try : + box7 = shaperpy.makeBox(10.,10.,-10.) + print "box7 : ok" + +except myExcept,ec: + print "box7 : ko (" + ec.what() + ")" + +# Create a box with two points defining the diagonal +try : + pnt1 = pnt(0.,0.,0.) + pnt2 = pnt(50.,50.,50.) + box8 = shaperpy.makeBox(pnt1,pnt2) + print "box8 : ok" + +except myExcept,ec: + print "box8 : ko (" + ec.what() + ")" + +try : + pnt1 = pnt(0.,0.,0.) + box9 = shaperpy.makeBox(pnt1,pnt1) + print "box9 : ok" + +except myExcept,ec: + print "box9 : ko (" + ec.what() + ")" + +try : + pnt1 = pnt(0.,0.,0.) + pnt2 = pnt(0.,50.,50.) + box10 = shaperpy.makeBox(pnt1,pnt2) + print "box10 : ok" + +except myExcept,ec: + print "box10 : ko (" + ec.what() + ")" + +try : + pnt1 = pnt(0.,0.,0.) + pnt2 = pnt(50.,0.,50.) + box11 = shaperpy.makeBox(pnt1,pnt2) + print "box11 : ok" + +except myExcept,ec: + print "box11 : ko (" + ec.what() + ")" + +try : + pnt1 = pnt(0.,0.,0.) + pnt2 = pnt(50.,50.,0.) + box12 = shaperpy.makeBox(pnt1,pnt2) + print "box12 : ok" + +except myExcept,ec: + print "box12 : ko (" + ec.what() + ")" + +try : + pnt1 = pnt(50.,50.,50.) + box13 = shaperpy.makeBox(pnt1,None) + print "box13 : ok" + +except myExcept,ec: + print "box13 : ko (" + ec.what() + ")" + +try : + pnt2 = pnt(50.,50.,50.) + box14 = shaperpy.makeBox(None,pnt2) + print "box14 : ok" + +except myExcept,ec: + print "box14 : ko (" + ec.what() + ")" + diff --git a/test.API/SHAPER/Primitives/TestAPI_Cylinder.py b/test.API/SHAPER/Primitives/TestAPI_Cylinder.py new file mode 100644 index 000000000..50a4b877d --- /dev/null +++ b/test.API/SHAPER/Primitives/TestAPI_Cylinder.py @@ -0,0 +1,41 @@ +# Copyright (C) 2014-201x CEA/DEN, EDF R&D + +# File: TestAPI_Cylinder.py +# Created: 13 Jan 2017 +# Author: Clarisse Genrault (CEA) + +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 + +aPoint = pnt(10.,5.,0.) +anEdge = edgeBuilder.line(1.,0.,0.) + +# Create a cylinder +try : + cylinder1 = shaperpy.makeCylinder(5., 20.) + +except myExcept,ec: + print ec.what() + +# Create a cylinder +try : + cylinder2 = shaperpy.makeCylinder(5., 20., 100.) + +except myExcept,ec: + print ec.what() + +# Create a cylinder +try : + cylinder3 = shaperpy.makeCylinder(aPoint, anEdge, 5., 20.) + +except myExcept,ec: + print ec.what() + +# Create a cylinder +try : + cylinder4 = shaperpy.makeCylinder(aPoint, anEdge, 5., 20., 180.) + +except myExcept,ec: + print ec.what() \ No newline at end of file diff --git a/test.API/SHAPER/Primitives/TestBox.py b/test.API/SHAPER/Primitives/TestBox.py new file mode 100644 index 000000000..bc80102aa --- /dev/null +++ b/test.API/SHAPER/Primitives/TestBox.py @@ -0,0 +1,171 @@ +""" +Test case for Primitive Box 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 with dimensions +aSession.startOperation() +aBox1 = model.addBox(aDocument, 10, 10, 10) +model.testNbResults(aBox1, 1) +model.testNbSubShapes(aBox1, GeomAPI_Shape.SOLID, [1]) +model.testNbSubShapes(aBox1, GeomAPI_Shape.FACE, [6]) +print "box1 : ok" +aSession.finishOperation() + +aSession.startOperation() +aBox2 = model.addBox(aDocument, 0, 10, 10) +model.testNbResults(aBox2, 0) +print "box2 : ko (" + aBox2.feature().error() + ")" +aSession.finishOperation() + +aSession.startOperation() +aBox3 = model.addBox(aDocument, 10, 0, 10) +model.testNbResults(aBox3, 0) +print "box3 : ko (" + aBox3.feature().error() + ")" +aSession.finishOperation() + +aSession.startOperation() +aBox4 = model.addBox(aDocument, 10, 10, 0) +model.testNbResults(aBox4, 0) +print "box4 : ko (" + aBox4.feature().error() + ")" +aSession.finishOperation() + +aSession.startOperation() +aBox5 = model.addBox(aDocument, -10, 10, 10) +model.testNbResults(aBox5, 0) +print "box5 : ko (" + aBox5.feature().error() + ")" +aSession.finishOperation() + +aSession.startOperation() +aBox6 = model.addBox(aDocument, 10, -10, 10) +model.testNbResults(aBox6, 0) +print "box6 : ko (" + aBox6.feature().error() + ")" +aSession.finishOperation() + +aSession.startOperation() +aBox7 = model.addBox(aDocument, 10, 10, -10) +model.testNbResults(aBox7, 0) +print "box7 : ko (" + aBox7.feature().error() + ")" +aSession.finishOperation() + +# Create a box with 2 points +aSession.startOperation() +aPoint1 = model.addPoint(aDocument, 0, 0, 0).result() +aPoint2 = model.addPoint(aDocument, 50, 50, 50).result() +aBox8 = model.addBox(aDocument, aPoint1, aPoint2) +model.testNbResults(aBox8, 1) +model.testNbSubShapes(aBox8, GeomAPI_Shape.SOLID, [1]) +model.testNbSubShapes(aBox8, GeomAPI_Shape.FACE, [6]) +print "box8 : ok" +aSession.finishOperation() + +aSession.startOperation() +aPoint1 = model.addPoint(aDocument, 0, 0, 0).result() +aBox9 = model.addBox(aDocument, aPoint1, aPoint1) +model.testNbResults(aBox9, 0) +print "box9 : ko (" + aBox9.feature().error() + ")" +aSession.finishOperation() + +aSession.startOperation() +aPoint1 = model.addPoint(aDocument, 0, 0, 0).result() +aPoint2 = model.addPoint(aDocument, 0, 50, 50).result() +aBox10 = model.addBox(aDocument, aPoint1, aPoint2) +model.testNbResults(aBox10, 0) +print "box10 : ko (" + aBox10.feature().error() + ")" +aSession.finishOperation() + +aSession.startOperation() +aPoint1 = model.addPoint(aDocument, 0, 0, 0).result() +aPoint2 = model.addPoint(aDocument, 50, 0, 50).result() +aBox11 = model.addBox(aDocument, aPoint1, aPoint2) +model.testNbResults(aBox11, 0) +print "box11 : ko (" + aBox11.feature().error() + ")" +aSession.finishOperation() + +aSession.startOperation() +aPoint1 = model.addPoint(aDocument, 0, 0, 0).result() +aPoint2 = model.addPoint(aDocument, 50, 50, 0).result() +aBox12 = model.addBox(aDocument, aPoint1, aPoint2) +model.testNbResults(aBox12, 0) +print "box12 : ko (" + aBox12.feature().error() + ")" +aSession.finishOperation() + +aSession.startOperation() +aPoint1 = model.selection("VERTEX", "point1") +aPoint2 = model.addPoint(aDocument, 50, 50, 0).result() +aBox13 = model.addBox(aDocument, aPoint1, aPoint2) +model.testNbResults(aBox13, 0) +print "box13 : ko (" + aBox13.feature().error() + ")" +aSession.finishOperation() + +aSession.startOperation() +aPoint1 = model.addPoint(aDocument, 0, 0, 0).result() +aPoint2 = model.selection("VERTEX", "point2") +aBox14 = model.addBox(aDocument, aPoint1, aPoint2) +model.testNbResults(aBox14, 0) +print "box14 : ko (" + aBox14.feature().error() + ")" +aSession.finishOperation() + +aSession.startOperation() +Sketch_1 = model.addSketch(aDocument, model.defaultPlane("XOY")) +Sketch_2 = model.addSketch(aDocument, model.defaultPlane("YOZ")) +SketchLine_1 = Sketch_1.addLine(20, 10, 40, 10) +SketchLine_2 = Sketch_1.addLine(40, 10, 40, 20) +SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchLine_2.startPoint()) +SketchLine_3 = Sketch_1.addLine(40, 20, 20, 20) +SketchLine_4 = Sketch_1.addLine(20, 20, 20, 10) +SketchConstraintCoincidence_3 = Sketch_1.setCoincident(SketchLine_3.endPoint(), SketchLine_4.startPoint()) +SketchConstraintCoincidence_4 = Sketch_1.setCoincident(SketchLine_1.startPoint(), SketchLine_4.endPoint()) +SketchLine_5 = Sketch_2.addLine(20, 10, 40, 10) +SketchLine_6 = Sketch_2.addLine(40, 10, 40, 20) +SketchConstraintCoincidence_1 = Sketch_2.setCoincident(SketchLine_5.endPoint(), SketchLine_6.startPoint()) +SketchLine_7 = Sketch_2.addLine(40, 20, 20, 20) +SketchLine_8 = Sketch_2.addLine(20, 20, 20, 10) +SketchConstraintCoincidence_3 = Sketch_2.setCoincident(SketchLine_7.endPoint(), SketchLine_8.startPoint()) +SketchConstraintCoincidence_4 = Sketch_2.setCoincident(SketchLine_5.startPoint(), SketchLine_8.endPoint()) +aSession.finishOperation() + +aSession.startOperation() +aBox15 = model.addBox(aDocument, model.selection("VERTEX", "Sketch_1/Vertex-SketchLine_1s-SketchLine_4e"), + model.selection("VERTEX", "Sketch_2/Vertex-SketchLine_7s-SketchLine_6e")) + +model.testNbResults(aBox15, 1) +model.testNbSubShapes(aBox15, GeomAPI_Shape.SOLID, [1]) +model.testNbSubShapes(aBox15, GeomAPI_Shape.FACE, [6]) +print "box15 : ok" +aSession.finishOperation() + +aSession.startOperation() +Extrusion_1 = model.addExtrusion(aDocument, [model.selection("COMPOUND", "Sketch_1")], model.selection("EDGE", "PartSet/OZ"), 100, 0) +Extrusion_2 = model.addExtrusion(aDocument, [model.selection("COMPOUND", "Sketch_2")], model.selection("EDGE", "PartSet/OX"), 100, 0) +aBox16 = model.addBox(aDocument, model.selection("VERTEX", "Extrusion_1_1/Generated_Face_3&Extrusion_1_1/Generated_Face_2&Extrusion_1_1/To_Face_1"), + model.selection("VERTEX", "Extrusion_2_1/Generated_Face_2&Extrusion_2_1/Generated_Face_1&Extrusion_2_1/To_Face_1")) +model.testNbResults(aBox16, 1) +model.testNbSubShapes(aBox16, GeomAPI_Shape.SOLID, [1]) +model.testNbSubShapes(aBox16, GeomAPI_Shape.FACE, [6]) +print "box16 : ok" +aSession.finishOperation() + +aSession.startOperation() +Vertex_1 = model.addVertex(aDocument, [model.selection("VERTEX", "Sketch_1/Vertex-SketchLine_1s-SketchLine_4e")]) +Vertex_2 = model.addVertex(aDocument, [model.selection("VERTEX", "Sketch_2/Vertex-SketchLine_7s-SketchLine_6e")]) +aBox17 = model.addBox(aDocument, model.selection("VERTEX", "Vertex_1_1"), model.selection("VERTEX", "Vertex_2_1")) +model.testNbResults(aBox17, 1) +model.testNbSubShapes(aBox17, GeomAPI_Shape.SOLID, [1]) +model.testNbSubShapes(aBox17, GeomAPI_Shape.FACE, [6]) +print "box17 : ok" +aSession.finishOperation() diff --git a/test.API/SHAPER/Primitives/TestCylinder.py b/test.API/SHAPER/Primitives/TestCylinder.py new file mode 100644 index 000000000..38e6d260b --- /dev/null +++ b/test.API/SHAPER/Primitives/TestCylinder.py @@ -0,0 +1,44 @@ +""" +Test case for Primitive Cylinder 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() + +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() + diff --git a/test.API/SHAPER/Transformations/TestAPI_Scale.py b/test.API/SHAPER/Transformations/TestAPI_Scale.py new file mode 100644 index 000000000..a60134807 --- /dev/null +++ b/test.API/SHAPER/Transformations/TestAPI_Scale.py @@ -0,0 +1,32 @@ +# Copyright (C) 2014-201x CEA/DEN, EDF R&D + +# File: TestAPI_Scale.py +# Created: 25 Jan 2017 +# 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 + +# Create a box +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. +try : + scale1 = shaperpy.makeScale(box1,centerPoint, -1.6) + +except myExcept, ec: + print ec.what() + +# Perfom a scale by dimensions. +try : + scale2 = shaperpy.makeScale(box2,centerPoint, 2, -0.5, 1.3) + +except myExcept, ec: + print ec.what() diff --git a/test.API/SHAPER/Transformations/TestAPI_Symmetry.py b/test.API/SHAPER/Transformations/TestAPI_Symmetry.py new file mode 100644 index 000000000..409d39863 --- /dev/null +++ b/test.API/SHAPER/Transformations/TestAPI_Symmetry.py @@ -0,0 +1,48 @@ +# Copyright (C) 2014-2016 CEA/DEN, EDF R&D + +# 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 + +# 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() + +# 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() diff --git a/test.API/SHAPER/Transformations/TestAPI_Translation.py b/test.API/SHAPER/Transformations/TestAPI_Translation.py new file mode 100644 index 000000000..b3933912e --- /dev/null +++ b/test.API/SHAPER/Transformations/TestAPI_Translation.py @@ -0,0 +1,44 @@ +# Copyright (C) 2014-2016 CEA/DEN, EDF R&D + +# File: TestAPI_Translation.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_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() diff --git a/test.API/SHAPER/Transformations/TestScale.py b/test.API/SHAPER/Transformations/TestScale.py new file mode 100644 index 000000000..f0a33e077 --- /dev/null +++ b/test.API/SHAPER/Transformations/TestScale.py @@ -0,0 +1,37 @@ +""" +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 diff --git a/test.API/SHAPER/Transformations/TestSymmetry.py b/test.API/SHAPER/Transformations/TestSymmetry.py new file mode 100644 index 000000000..97aca11e8 --- /dev/null +++ b/test.API/SHAPER/Transformations/TestSymmetry.py @@ -0,0 +1,47 @@ +""" +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 diff --git a/test.API/SHAPER/Transformations/TestTranslation.py b/test.API/SHAPER/Transformations/TestTranslation.py new file mode 100644 index 000000000..85657d32f --- /dev/null +++ b/test.API/SHAPER/Transformations/TestTranslation.py @@ -0,0 +1,43 @@ +""" +Test case for Translation 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() +aBox = model.addBox(aDocument, 10, 10, 10) + +# Perform a translation by an axis and a distance +aSession.startOperation() +aTranslation1 = model.addTranslation(aDocument, [model.selection("SOLID", "Box_1_1")], model.selection("EDGE", "Box_1_1/Front&Box_1_1/Bottom"), 20).result() +aSession.finishOperation() +assert (aTranslation1 is not None) + +# Perform a translation by DX, DY, DZ vector +aSession.startOperation() +aTranslation2 = model.addTranslation(aDocument, [model.selection("SOLID", "Box_1_1")], 10, 10, 10).result() +aSession.finishOperation() +assert (aTranslation2 is not None) + +# Perform a translation by two points +aSession.startOperation() +aPoint1 = model.addPoint(aDocument, 0, 0, 0).result() +aPoint2 = model.addPoint(aDocument, 10, 10, 0).result() +aTranslation3 = model.addTranslation(aDocument, [model.selection("SOLID", "Box_1_1")], aPoint1, aPoint2).result() +aSession.finishOperation() +assert (aTranslation3 is not None)