1 # Copyright (C) 2014-2020 CEA/DEN, EDF R&D
3 # This library is free software; you can redistribute it and/or
4 # modify it under the terms of the GNU Lesser General Public
5 # License as published by the Free Software Foundation; either
6 # version 2.1 of the License, or (at your option) any later version.
8 # This library is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 # Lesser General Public License for more details.
13 # You should have received a copy of the GNU Lesser General Public
14 # License along with this library; if not, write to the Free Software
15 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 from salome.shaper import model
23 from salome.shaper import geom
25 from TestSketcher import SketcherTestCase
27 class SketcherAddArc(SketcherTestCase):
28 def test_arc_by_coords(self):
29 arc = self.sketch.addArc(0, 1, 0, 0, 1, 1, False)
31 self.assertEqual(arc.startPoint().x(), 0)
32 self.assertEqual(arc.startPoint().y(), 0)
34 def test_arc_by_points(self):
35 center = geom.Pnt2d(0, 1)
36 start = geom.Pnt2d(0, 0)
37 end = geom.Pnt2d(1, 1)
38 arc = self.sketch.addArc(center, start, end, False)
40 self.assertEqual(arc.startPoint().x(), 0)
41 self.assertEqual(arc.startPoint().y(), 0)
43 def test_modify_arc(self):
44 # Note: arc will modify startPoint and endPoint to be in circle
45 arc = self.sketch.addArc(0, 1, 0, 0, 1, 1, False)
46 arc.setByCenterStartEnd(0, 0, 1, 1, -1, -1, False)
48 self.assertEqual(arc.center().x(), 0)
49 self.assertEqual(arc.center().y(), 0)
50 self.assertEqual(arc.startPoint().x(), 1)
51 self.assertEqual(arc.startPoint().y(), 1)
52 self.assertEqual(arc.endPoint().x(), -1)
53 self.assertEqual(arc.endPoint().y(), -1)
56 if __name__ == "__main__":
57 test_program = unittest.main(verbosity=2, exit=False)
58 assert test_program.result.wasSuccessful(), "Test failed"