ADD_SUBDIRECTORY (src/ModuleBase)
ADD_SUBDIRECTORY (src/PartSet)
-#
-#ADD_SUBDIRECTORY (src/SketchConstraintsFinder) # Plugin
-ADD_SUBDIRECTORY (src/SAMConverter) # Library
-ADD_SUBDIRECTORY (src/SAMConverterAPI)
-#
-
ADD_SUBDIRECTORY (src/XGUI)
ADD_SUBDIRECTORY (src/ExchangePlugin)
ADD_SUBDIRECTORY (src/GeomValidators)
ADD_SUBDIRECTORY (src/FiltersPlugin)
ADD_SUBDIRECTORY (src/InitializationPlugin)
ADD_SUBDIRECTORY (src/ParametersPlugin)
+ADD_SUBDIRECTORY (src/SAMConverter)
ADD_SUBDIRECTORY (src/PythonAddons)
ADD_SUBDIRECTORY (src/PythonAPI)
# High Level C++/Python API
ADD_SUBDIRECTORY (src/GDMLAPI)
ADD_SUBDIRECTORY (src/ConnectorAPI)
ADD_SUBDIRECTORY (src/FiltersAPI)
+ADD_SUBDIRECTORY (src/SAMConverterAPI)
# Tests
ADD_SUBDIRECTORY (test.API/SHAPER)
try :
value_attr = entity.feature().real("ConstraintValue")
if value_attr is not None:
+ # Constraint value is negative in following cases:
+ # For horizontal distance: if first primitive is to the right of the second
+ # For vertical distance: if first primitive is to the above of the second
+ # For angle: if the angle is counted counterclockwise
+ if "Distance" in entity.getKind() or "Angle" in entity.getKind():
+ return abs(value_attr.value())
return value_attr.value()
except Exception as e :
logger.info(f'Problem with constraint parameters: {e}')
if feat is not None :
entity = SketchAPI_SketchEntity(feat)
entity_type = entity.getKind()
- print(entity_type)
convert, update_mapping = ShapertoSAMPrimitive.convert(entity)
if convert is not None:
entity_type = entity.getKind()
if 'Constraint' in entity_type :
+ if entity_type == 'SuggestConstraints':
+ continue
refs = []
l_attributs = [entity.refattr("ConstraintEntityA"), entity.refattr("ConstraintEntityB"),
entity.refattr("ConstraintEntityC"), entity.refattr("ConstraintEntityD")]
--- /dev/null
+import logging
+
+logging.basicConfig(level=logging.DEBUG)
+logger = logging.getLogger()
import ModelAPI
import EventsAPI
-
from SketchAPI import *
import salome
from salome.shaper import model
-
+from GeomDataAPI import *
+from ModelAPI import *
+import math
import os
## @ingroup Plugins
pass
## Check that sketch can convert in SAM format
- def isConvertedSketch(self, sketch):
+ def isConvertedSketch(self):
avaliable_elements = ['SketchConstraintAngle',
'SketchConstraintCoincidence',
'SketchConstraintDistance',
nonConvertablePrimitive = []
nonConvertableConstraint = []
- for sub in sketch.features().list():
+ for sub in self.Sketch.features().list():
feat = ModelAPI.objectToFeature(sub)
if feat is None :
continue
entity = SketchAPI_SketchEntity(feat)
entity_type = entity.getKind()
+ if entity_type == 'SuggestConstraints':
+ continue
if not entity_type in avaliable_elements:
if 'Constraint' in entity_type :
nonConvertableConstraint.append(entity_type)
## convert result in SAM format
def convertToSAM(self):
## Check that all primitives and constraints is compability with SAM
- nonConvertablePrimitive, nonConvertableConstraint = self.isConvertedSketch(aSketch)
+ nonConvertablePrimitive, nonConvertableConstraint = self.isConvertedSketch()
if len(nonConvertablePrimitive) > 0 or len(nonConvertableConstraint) > 0 :
- print("Primitives and constraints are incompatible with the SAM format. The sequence therefore cannot be translated.")
- print(f'List of primitives not compatible with SAM: {nonConvertablePrimitive}')
- print(f'List of constraints not compatible with SAM: {nonConvertableConstraint}')
+ logger.debug("SuggestConstraints", f'Primitives and constraints are incompatible with the SAM format. The sequence therefore cannot be translated.')
+ if len(nonConvertablePrimitive) > 0:
+ logger.debug("SuggestConstraints", f'List of primitives not compatible with SAM: {nonConvertablePrimitive}')
+ if len(nonConvertableConstraint) > 0:
+ logger.debug(f'List of constraints not compatible with SAM: {nonConvertableConstraint}')
+ ### For users
+ EventsAPI.Events_InfoMessage("SuggestConstraints", f'Impossible to apply the suggested constraints.', self).send()
+ if len(nonConvertablePrimitive) == 0:
+ EventsAPI.Events_InfoMessage("SuggestConstraints", f'The constraints {nonConvertableConstraint} are not currently taken into account by the model.', self).send()
+ elif len(nonConvertableConstraint) == 0:
+ EventsAPI.Events_InfoMessage("SuggestConstraints", f'The primitives: {nonConvertablePrimitive} are not currently taken into account by the model.', self).send()
+ else:
+ EventsAPI.Events_InfoMessage("SuggestConstraints", f'The primitives: {nonConvertablePrimitive} and constraints {nonConvertableConstraint} are not currently taken into account by the model.', self).send()
return
- convert_sketch(aSketch)
+ exchange_elements = convert_sketch(self.Sketch)
print("SuggestConstraintsFeature: convertToSAM")
pass
<context>
<name>SketchToSAMConverter</name>
<message>
- <source>Impossible to apply the suggested constraints. The primitives %1 and constraints %2 are not currently considered by the model.</source>
- <translation>Impossible d'appliquer la suggestion de contraintes. Les primitives %1 et contraintes %2 ne sont pour le moment pas prises en compte par le modele.</translation>
+ <source>Primitives and constraints are incompatible with the SAM format. The sequence therefore cannot be translated. List of primitives not compatible with SAM: % 1. List of constraints not compatible with SAM: %2 </source>
+ <translation>Les primitives et les contraintes sont incompatibles avec le format SAM. La séquence ne peut donc pas être traduite. Liste des primitives non compatibles avec SAM: %1. Liste des contraintes non compatibles avec SAM: %2 </translation>
+ </message>
+ <message>
+ <source>Impossible to apply the suggested constraints. The primitives: %1 and constraints %2 are not currently taken into account by the model.</source>
+ <translation>Impossible d'appliquer les contraintes proposées. Les primitives : %1 et les contraintes %2 ne sont actuellement pas prises en compte par le modèle</translation>
</message>
</context>
</TS>
-# Copyright (C) 2021-2022 CEA/DEN, EDF R&D
+# Copyright (C) 2014-2022 CEA/DEN, EDF R&D
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
#
-include(tests.set)
+INCLUDE(tests.set)
-ADD_UNIT_TESTS(${TEST_NAMES})
+SET(TEST_INSTALL_DIRECTORY "${SALOME_SHAPER_INSTALL_TESTS}/SAMConverter")
-if(${HAVE_SALOME})
- enable_testing()
- set(TEST_INSTALL_DIRECTORY "${SALOME_SHAPER_INSTALL_TESTS}/SAMConverter")
+SALOME_GENERATE_TESTS_ENVIRONMENT(tests_env)
- install(FILES CTestTestfileInstall.cmake
- DESTINATION ${TEST_INSTALL_DIRECTORY}
- RENAME CTestTestfile.cmake)
- install(FILES tests.set DESTINATION ${TEST_INSTALL_DIRECTORY})
- set(TMP_TESTS_NAMES)
- foreach(tfile ${TEST_NAMES})
- list(APPEND TMP_TESTS_NAMES "${tfile}")
- endforeach(tfile ${TEST_NAMES})
+FOREACH(tfile ${TEST_NAMES})
+ SET(TEST_NAME ${COMPONENT_NAME}_${tfile})
+ ADD_TEST(NAME ${TEST_NAME}
+ COMMAND ${PYTHON_EXECUTABLE} -B ${CMAKE_CURRENT_SOURCE_DIR}/testme.py ${CMAKE_CURRENT_SOURCE_DIR}/${tfile}.py)
+ SET_TESTS_PROPERTIES(${TEST_NAME} PROPERTIES ENVIRONMENT "${tests_env};SHAPER_UNIT_TEST_IN_PROGRESS=1")
+ SET_TESTS_PROPERTIES(${TEST_NAME} PROPERTIES LABELS "${COMPONENT_NAME}")
+ENDFOREACH()
- # tests which require SHAPER_SUGGESTION_GENERATOR
- install(DIRECTORY data DESTINATION ${TEST_INSTALL_DIRECTORY})
+# salome test
+FOREACH(tfile ${TEST_NAMES})
+ INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${tfile}.py
+ DESTINATION ${TEST_INSTALL_DIRECTORY})
+ENDFOREACH()
- install(FILES ${TMP_TESTS_NAMES} DESTINATION ${TEST_INSTALL_DIRECTORY})
-endif(${HAVE_SALOME})
+INSTALL(FILES CTestTestfileInstall.cmake
+ DESTINATION ${TEST_INSTALL_DIRECTORY}
+ RENAME CTestTestfile.cmake)
+
+INSTALL(FILES tests.set DESTINATION ${TEST_INSTALL_DIRECTORY})
+INSTALL(DIRECTORY data DESTINATION ${TEST_INSTALL_DIRECTORY})
-# Copyright (C) 2021-2022 CEA/DEN, EDF R&D
+# Copyright (C) 2016-2022 CEA/DEN, EDF R&D
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
#
-include(tests.set)
+INCLUDE(tests.set)
-foreach(tfile ${TEST_NAMES})
- set(TEST_NAME ${COMPONENT_NAME}_${tfile})
- add_test(${TEST_NAME} python ${tfile})
- set_tests_properties(${TEST_NAME} PROPERTIES LABELS "${SALOME_TEST_LABEL_ADV}")
-endforeach()
+SET(COMPONENT_NAME SHAPER)
+SET(PYTHON_TEST_DRIVER "$ENV{KERNEL_ROOT_DIR}/bin/salome/appliskel/python_test_driver.py")
+SET(TIMEOUT 300)
+
+
+FOREACH(tfile ${TEST_NAMES})
+ SET(TEST_NAME ${COMPONENT_NAME}_${tfile})
+ ADD_TEST(${TEST_NAME} python ${PYTHON_TEST_DRIVER} ${TIMEOUT} ${tfile}.py)
+ SET_TESTS_PROPERTIES(${TEST_NAME} PROPERTIES LABELS "${COMPONENT_NAME}")
+ENDFOREACH()
--- /dev/null
+import unittest
+
+import salome
+salome.standalone()
+
+import sys
+sys.path.append('sam')
+
+from SAMConverter_Logger import logger
+from SAMConverter_ConvertConstraints import *
+from SAMConverter_ConvertPrimitives import *
+
+from salome.shaper import model
+
+class TestConvertAngle(unittest.TestCase):
+
+ def test_convert_angle_Line_Line(self):
+ model.begin()
+ partSet = model.moduleDocument()
+
+ ### Create Sketch
+ Sketch_1 = model.addSketch(partSet, model.defaultPlane("XOY"))
+
+ ### Add primitives
+ SketchLine_1 = Sketch_1.addLine(3.9, 0, 8, 0)
+ SketchLine_2 = Sketch_1.addLine(-3.9, 1., 8, 0.5)
+ SketchCoincident = Sketch_1.setAngle(SketchLine_1.result(), SketchLine_2.result(), 40)
+ model.do()
+ model.end()
+
+ sam_line1, _ = ShapertoSAMPrimitive.convert(SketchLine_1)
+ sam_line2, _ = ShapertoSAMPrimitive.convert(SketchLine_2)
+ sam_constraint = ShapertoSAMConstraints.convert(SketchCoincident, refs = [sam_line1, sam_line2])
+
+ # Check type
+ self.assertEqual(sam_constraint.get_name(), 'ANGLE')
+
+ # Check Angle value
+ self.assertEqual(sam_constraint.angle, 40)
+
+ # Check references
+ self.assertEqual(sam_constraint.references[0], sam_line1)
+ self.assertEqual(sam_constraint.references[1], sam_line2)
--- /dev/null
+import unittest
+
+import salome
+salome.standalone()
+
+import sys
+sys.path.append('sam')
+
+from SAMConverter_Logger import logger
+from SAMConverter_ConvertPrimitives import *
+
+
+from salome.shaper import model
+from sam.catalog_primitive import Arc, Line, Circle, Point
+from math import sqrt, acos, degrees, fabs
+
+
+
+
+def compute_parameter(center_x, center_y, start_x, start_y, end_x, end_y):
+ center = (center_x, center_y)
+
+ # First step, translate the arc such that center became the origin
+ start_2_x = start_x - center_x
+ start_2_y = start_y - center_y
+ end_2_x = end_x - center_x
+ end_2_y = end_y - center_y
+
+ # Compute radius
+ radius_s = sqrt(start_2_x*start_2_x + start_2_y*start_2_y)
+ radius_e = sqrt(end_2_x*end_2_x + end_2_y*end_2_y)
+
+ # Compute start angle start and end
+ angle_s = convert_angle(degrees(acos(start_2_x/radius_s)))
+ angle_e = convert_angle(degrees(acos(end_2_x/radius_e)))
+
+ return center, (radius_s, radius_e), (angle_s, angle_e)
+
+class TestConvertArc(unittest.TestCase):
+
+ def test_convert_arc(self):
+
+ model.begin()
+ partSet = model.moduleDocument()
+
+ ### Create Sketch
+ Sketch_1 = model.addSketch(partSet, model.defaultPlane("XOY"))
+
+ ### Create SketchArc
+ SketchArc_1 = Sketch_1.addArc(0, 0, 0, 10, 10, 0, False) # center x, center y, start x, start y, endx, endy
+ SketchArc_2 = Sketch_1.addArc(5., 1, 5.5, 1, 5, 1.5, False)
+ SketchArc_2.setAuxiliary(True)
+ model.do()
+ model.end()
+
+ # Test 1 : SketchArc_1
+ sam_arc, mapping_info = ShapertoSAMPrimitive.convert(SketchArc_1)
+
+ # - Verify the circle information
+ center, (radius_s, radius_e), (angle_s, angle_e) = compute_parameter(0, 0, 0, 10, 10, 0) # compute expected parms
+ self.assertAlmostEqual(radius_e, radius_s, delta = 10e-5)
+ self.assertEqual(sam_arc.radius, radius_e)
+ self.assertEqual(sam_arc.center.x, center[0])
+ self.assertEqual(sam_arc.center.y, center[1])
+ self.assertEqual(sam_arc.angle_start, angle_s)
+ self.assertEqual(sam_arc.angle_end, angle_e)
+ self.assertEqual(sam_arc.radian, False)
+ self.assertEqual(sam_arc.is_construction(), False)
+
+ # - Verify the mapping information
+ self.assertIn((0.0, 0.0, 'SketchArc_1'), mapping_info)
+ self.assertEqual(str(mapping_info[(0.0, 0.0, 'SketchArc_1')]), 'Point P(0.0, 0.0)')
+
+ # Test 2 : SketchArc_2
+ sam_arc, mapping_info = ShapertoSAMPrimitive.convert(SketchArc_2)
+
+ # - Verify the circle information
+ center, (radius_s, radius_e), (angle_s, angle_e) = compute_parameter(5., 1, 5.5, 1, 5, 1.5) # compute expected parms
+ self.assertAlmostEqual(radius_e, radius_s, delta = 10e-5)
+ self.assertAlmostEqual(sam_arc.radius, radius_e, delta = 10e-2)
+ self.assertEqual(sam_arc.center.x, center[0])
+ self.assertEqual(sam_arc.center.y, center[1])
+ self.assertEqual(convert_angle(sam_arc.angle_start), angle_s)
+ self.assertEqual(convert_angle(sam_arc.angle_end), angle_e)
+ self.assertEqual(sam_arc.radian, False)
+ self.assertEqual(sam_arc.is_construction(), True)
+
+
+ # - Verify the mapping information
+ self.assertIn((5.0, 1.0, 'SketchArc_2'), mapping_info)
+ self.assertEqual(str(mapping_info[(5.0, 1.0, 'SketchArc_2')]), 'Point P(5.0, 1.0)')
+
+ if salome.sg.hasDesktop():
+ salome.sg.updateObjBrowser()
--- /dev/null
+import unittest
+
+import salome
+salome.standalone()
+
+import sys
+sys.path.append('sam')
+
+from SAMConverter_Logger import logger
+from SAMConverter_ConvertPrimitives import *
+
+
+from salome.shaper import model
+from sam.catalog_primitive import Arc, Line, Circle, Point
+
+
+class TestConvertCircle(unittest.TestCase):
+
+ def test_convert_circle(self):
+
+ model.begin()
+ partSet = model.moduleDocument()
+
+ ### Create Sketch
+ Sketch_1 = model.addSketch(partSet, model.defaultPlane("XOY"))
+
+ ### Create SketchCircle
+ SketchCircle_1 = Sketch_1.addCircle(1., 0, 30)
+ SketchCircle_2 = Sketch_1.addCircle(10., 4, 50)
+ SketchCircle_2.setAuxiliary(True)
+ model.do()
+ model.end()
+
+ # Test 1 : SketchCircle_1
+ sam_circle, mapping_info = ShapertoSAMPrimitive.convert(SketchCircle_1)
+
+ # - Verify the circle information
+ self.assertEqual(sam_circle.radius, 30.0)
+ self.assertEqual(sam_circle.center.x, 1.)
+ self.assertEqual(sam_circle.center.y, 0.)
+ self.assertEqual(sam_circle.is_construction(), False)
+
+ # Verify the mapping information
+ self.assertIn((1.0, 0.0, 'SketchCircle_1'), mapping_info)
+ self.assertEqual(str(mapping_info[(1.0, 0.0, 'SketchCircle_1')]), 'Point P(1.0, 0.0)')
+
+ # Test 2 : SketchCircle_2
+ sam_circle, mapping_info = ShapertoSAMPrimitive.convert(SketchCircle_2)
+
+ # - Verify the circle information
+ self.assertEqual(sam_circle.radius, 50.0)
+ self.assertEqual(sam_circle.center.x, 10.)
+ self.assertEqual(sam_circle.center.y, 4.)
+ self.assertEqual(sam_circle.is_construction(), True)
+
+ # Verify the mapping information
+ self.assertIn((10.0, 4.0, 'SketchCircle_2'), mapping_info)
+ self.assertEqual(str(mapping_info[(10.0, 4.0, 'SketchCircle_2')]), 'Point P(10.0, 4.0)')
+
+
+ self.assertTrue(True)
+ if salome.sg.hasDesktop():
+ salome.sg.updateObjBrowser()
+from TestSAMConverter_Angle import TestConvertAngle
+from TestSAMConverter_Distance import TestConvertDistance
+from TestSAMConverter_Geometrical import TestConvertGeometrical
+from TestSAMConverter_HorisontalDistance import TestConverHorizontalDistance
+from TestSAMConverter_Length import TestConvertLength
+from TestSAMConverter_Radius import TestConvertRadius
+from TestSAMConverter_VerticalDistance import TestConvertVerticalDistance
+### convert angle test
+angle_test = TestConvertAngle()
+#angle_test.test_convert_angle()
+angle_test.test_convert_angle_Line_Line()
+
+### convert distance test
+dist_test = TestConvertDistance()
+dist_test.test_convert_distance_Point_Line()
+dist_test.test_convert_distance_Point_Point()
+
+### convert horizontal distance
+hDist_test = TestConverHorizontalDistance()
+hDist_test.test_convert_distance_Point_Circle()
+hDist_test.test_convert_distance_Point_Line()
+hDist_test.test_convert_distance_Point_Point()
+
+### convert vertical distance
+vDist_test = TestConvertVerticalDistance()
+vDist_test.test_convert_distance_Point_Circle()
+vDist_test.test_convert_distance_Point_Line()
+vDist_test.test_convert_distance_Point_Point()
+
+### convert geometrical constraints test
+geom_test = TestConvertGeometrical()
+geom_test.test_convert_coincidence()
+geom_test.test_convert_equal()
+geom_test.test_convert_horizontal()
+geom_test.test_convert_midpoint()
+geom_test.test_convert_parallel()
+geom_test.test_convert_perpendicular()
+geom_test.test_convert_tangent()
+geom_test.test_convert_vertical()
+
+len_test = TestConvertLength()
+len_test.test_convert_length()
+
+rad_test = TestConvertRadius()
+rad_test.test_convert_radius()
--- /dev/null
+import unittest
+
+import salome
+salome.standalone()
+from SketchAPI import *
+
+import sys
+sys.path.append('sam')
+
+from SAMConverter_Logger import logger
+from SAMConverter_ConvertConstraints import *
+from SAMConverter_ConvertPrimitives import *
+
+from salome.shaper import model
+
+class TestConvertDistance(unittest.TestCase):
+
+ def test_convert_distance_Point_Point(self):
+ model.begin()
+ partSet = model.moduleDocument()
+
+ ### Create Sketch
+ Sketch_1 = model.addSketch(partSet, model.defaultPlane("XOY"))
+
+ ### Create SketchPoint
+ SketchPoint_1 = Sketch_1.addPoint(1., 0)
+ SketchPoint_2 = Sketch_1.addPoint(4., 0)
+ constraint = Sketch_1.setDistance(SketchAPI_Point(SketchPoint_1).coordinates(), SketchAPI_Point(SketchPoint_2).coordinates(), 2, True)
+ model.do()
+ model.end()
+
+ sam_point1, mapping_info = ShapertoSAMPrimitive.convert(SketchPoint_1)
+ sam_point2, mapping_info = ShapertoSAMPrimitive.convert(SketchPoint_2)
+ sam_constraint = ShapertoSAMConstraints.convert(constraint, refs = [sam_point1, sam_point2])
+
+ # Check type
+ self.assertEqual(sam_constraint.get_name(), 'DISTANCE')
+
+ # Check references
+ self.assertEqual(sam_constraint.references[0], sam_point1)
+ self.assertEqual(sam_constraint.references[1], sam_point2)
+
+ # Check value
+ self.assertEqual(sam_constraint.distance_min, 2)
+
+
+ def test_convert_distance_Point_Line(self):
+ model.begin()
+ partSet = model.moduleDocument()
+
+ ### Create Sketch
+ Sketch_1 = model.addSketch(partSet, model.defaultPlane("XOY"))
+
+ ### Create SketchPoint and SketchLine
+ SketchPoint_1 = Sketch_1.addPoint(1., 0)
+ SketchLine_1 = Sketch_1.addLine(3.9, 0, 8, 0)
+ constraint = Sketch_1.setDistance(SketchAPI_Point(SketchPoint_1).coordinates(), SketchLine_1.result(), 2, True)
+ model.do()
+ model.end()
+
+ sam_point, mapping_info = ShapertoSAMPrimitive.convert(SketchPoint_1)
+ sam_line, mapping_info = ShapertoSAMPrimitive.convert(SketchLine_1)
+ sam_constraint = ShapertoSAMConstraints.convert(constraint, refs = [sam_point, sam_line])
+
+ # Check type
+ self.assertEqual(sam_constraint.get_name(), 'DISTANCE')
+
+ # Check references
+ self.assertEqual(sam_constraint.references[0], sam_point)
+ self.assertEqual(sam_constraint.references[1], sam_line)
+
+ # Check value
+ self.assertEqual(sam_constraint.distance_min, 2)
--- /dev/null
+import unittest
+
+import salome
+salome.standalone()
+
+import sys
+sys.path.append('sam')
+
+from SAMConverter_Logger import logger
+from SAMConverter_ConvertConstraints import *
+from SAMConverter_ConvertPrimitives import *
+
+from salome.shaper import model
+
+class TestConvertGeometrical(unittest.TestCase):
+
+ def test_convert_coincidence(self):
+ model.begin()
+ partSet = model.moduleDocument()
+
+ ### Create Sketch
+ Sketch_1 = model.addSketch(partSet, model.defaultPlane("XOY"))
+
+ ### Create SketchLine
+ SketchLine_1 = Sketch_1.addLine(3.9, 0, 8, 0)
+ SketchLine_2 = Sketch_1.addLine(-3.9, 1., 8, 0.5)
+ SketchCoincident = Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchLine_2.startPoint())
+ model.do()
+ model.end()
+
+ sam_line1, _ = ShapertoSAMPrimitive.convert(SketchLine_1)
+ sam_line2, _ = ShapertoSAMPrimitive.convert(SketchLine_2)
+ sam_constraint = ShapertoSAMConstraints.convert(SketchCoincident, refs = [sam_line1, sam_line2])
+
+ # Check type
+ self.assertEqual(sam_constraint.get_name(), 'COINCIDENT')
+
+ # Check references
+ self.assertEqual(sam_constraint.references[0], sam_line1)
+ self.assertEqual(sam_constraint.references[1], sam_line2)
+
+ # Check references
+ # - Verify the line 1 information
+ self.assertEqual(sam_line1.pnt1.x, 3.9)
+ self.assertEqual(sam_line1.pnt1.y, 0.)
+ self.assertEqual(sam_line1.pnt2.x, 8)
+ self.assertEqual(sam_line1.pnt2.y, 0.)
+ self.assertEqual(sam_line1.is_construction(), False)
+
+ # - Verify the line 2 information
+ self.assertEqual(sam_line2.pnt1.x, 8.0)
+ self.assertEqual(sam_line2.pnt1.y, 0.)
+ self.assertEqual(sam_line2.pnt2.x, 8)
+ self.assertEqual(sam_line2.pnt2.y, 0.5)
+ self.assertEqual(sam_line2.is_construction(), False)
+
+ def test_convert_equal(self):
+ model.begin()
+ partSet = model.moduleDocument()
+
+ ### Create Sketch
+ Sketch_1 = model.addSketch(partSet, model.defaultPlane("XOY"))
+
+ ### Create SketchLine
+ SketchLine_1 = Sketch_1.addLine(3.9, 0, 8, 0)
+ SketchLine_2 = Sketch_1.addLine(-3.9, 1., 8, 0.5)
+ constraint = Sketch_1.setEqual(SketchLine_1.result(), SketchLine_2.result())
+ model.do()
+ model.end()
+
+ sam_line1, _ = ShapertoSAMPrimitive.convert(SketchLine_1)
+ sam_line2, _ = ShapertoSAMPrimitive.convert(SketchLine_2)
+ sam_constraint = ShapertoSAMConstraints.convert(constraint, refs = [sam_line1, sam_line2])
+
+ # Check type
+ self.assertEqual(sam_constraint.get_name(), 'EQUAL')
+
+ # Check references
+ self.assertEqual(sam_constraint.references[0], sam_line1)
+ self.assertEqual(sam_constraint.references[1], sam_line2)
+
+
+ # Check references
+ # - Verify the line 1 information
+ #TODO: The coordinates may differ from expected, but length of line is equal
+ #self.assertAlmostEqual(sam_line1.pnt1.x, 3.678, delta = 10e-3)
+ #self.assertEqual(sam_line1.pnt1.y, 0.)
+ #self.assertAlmostEqual(sam_line1.pnt2.x, 10.846, delta=10e-3)
+ #self.assertEqual(sam_line1.pnt2.y, 0.)
+ self.assertEqual(sam_line1.is_construction(), False)
+
+ # - Verify the line 2 information
+ #self.assertAlmostEqual(sam_line2.pnt1.x, -1.531, delta=10e-3)
+ #self.assertAlmostEqual(sam_line2.pnt1.y, 0.900, delta=10e-3)
+ #self.assertAlmostEqual(sam_line2.pnt2.x, 5.631, delta=10e-3)
+ #self.assertAlmostEqual(sam_line2.pnt2.y, 0.599, delta = 10e-3)
+ self.assertEqual(sam_line2.is_construction(), False)
+
+
+ def test_convert_horizontal(self):
+ model.begin()
+ partSet = model.moduleDocument()
+
+ ### Create Sketch
+ Sketch_1 = model.addSketch(partSet, model.defaultPlane("XOY"))
+
+ ### Create SketchLine
+ SketchLine_1 = Sketch_1.addLine(3.9, 0, 8, 1)
+ constraint = Sketch_1.setHorizontal(SketchLine_1.result())
+ model.do()
+ model.end()
+
+ sam_line1, _ = ShapertoSAMPrimitive.convert(SketchLine_1)
+ sam_constraint = ShapertoSAMConstraints.convert(constraint, refs = [sam_line1])
+
+ # Check type
+ self.assertEqual(sam_constraint.get_name(), 'HORIZONTAL')
+
+ # Check references
+ self.assertEqual(sam_constraint.references[0], sam_line1)
+
+ # Check references
+ # - Verify the line 1 information
+ self.assertEqual(sam_line1.pnt1.x, 3.9)
+ self.assertEqual(sam_line1.pnt1.y, 0.)
+ self.assertEqual(sam_line1.pnt2.x, 8)
+ self.assertEqual(sam_line1.pnt2.y, 0.)
+ self.assertEqual(sam_line1.is_construction(), False)
+
+
+ def test_convert_midpoint(self):
+ model.begin()
+ partSet = model.moduleDocument()
+
+ ### Create Sketch
+ Sketch_1 = model.addSketch(partSet, model.defaultPlane("XOY"))
+
+ ### Create SketchLine and SketchCircle
+ SketchLine_1 = Sketch_1.addLine(3.9, 0, 8, 0)
+ SketchCircle_1 = Sketch_1.addCircle(-17.41591725155751, 16.35177358773851, 29.02191596082682)
+ constraint = Sketch_1.setMiddlePoint(SketchLine_1.result(), SketchCircle_1.center())
+ model.do()
+ model.end()
+
+ sam_line1, _ = ShapertoSAMPrimitive.convert(SketchLine_1)
+ sam_circle, _ = ShapertoSAMPrimitive.convert(SketchCircle_1)
+ sam_constraint = ShapertoSAMConstraints.convert(constraint, refs = [sam_line1, sam_circle])
+
+ # Check type
+ self.assertEqual(sam_constraint.get_name(), 'MIDPOINT')
+
+ # Check references
+ self.assertEqual(sam_constraint.references[0], sam_line1)
+ self.assertEqual(sam_constraint.references[1], sam_circle)
+
+ def test_convert_parallel(self):
+ model.begin()
+ partSet = model.moduleDocument()
+
+ ### Create Sketch
+ Sketch_1 = model.addSketch(partSet, model.defaultPlane("XOY"))
+
+ ### Create SketchCircle
+ SketchLine_1 = Sketch_1.addLine(3.9, 0, 8, 0)
+ SketchLine_2 = Sketch_1.addLine(-3.9, 1., 8, 0.5)
+ SketchCoincident = Sketch_1.setParallel(SketchLine_1.endPoint(), SketchLine_2.startPoint())
+ model.do()
+ model.end()
+
+ sam_line1, _ = ShapertoSAMPrimitive.convert(SketchLine_1)
+ sam_line2, _ = ShapertoSAMPrimitive.convert(SketchLine_2)
+ sam_constraint = ShapertoSAMConstraints.convert(SketchCoincident, refs = [sam_line1, sam_line2])
+
+ # Check type
+ self.assertEqual(sam_constraint.get_name(), 'PARALLEL')
+
+ # Check references
+ self.assertEqual(sam_constraint.references[0], sam_line1)
+ self.assertEqual(sam_constraint.references[1], sam_line2)
+
+ def test_convert_perpendicular(self):
+ model.begin()
+ partSet = model.moduleDocument()
+
+ ### Create Sketch
+ Sketch_1 = model.addSketch(partSet, model.defaultPlane("XOY"))
+
+ ### Create SketchCircle
+ SketchLine_1 = Sketch_1.addLine(3.9, 0, 8, 0)
+ SketchLine_2 = Sketch_1.addLine(-3.9, 1., 8, 0.5)
+ SketchCoincident = Sketch_1.setPerpendicular(SketchLine_1.endPoint(), SketchLine_2.startPoint())
+ model.do()
+ model.end()
+
+ sam_line1, _ = ShapertoSAMPrimitive.convert(SketchLine_1)
+ sam_line2, _ = ShapertoSAMPrimitive.convert(SketchLine_2)
+ sam_constraint = ShapertoSAMConstraints.convert(SketchCoincident, refs = [sam_line1, sam_line2])
+
+ # Check type
+ self.assertEqual(sam_constraint.get_name(), 'PERPENDICULAR')
+
+ # Check references
+ self.assertEqual(sam_constraint.references[0], sam_line1)
+ self.assertEqual(sam_constraint.references[1], sam_line2)
+
+
+ def test_convert_tangent(self):
+ model.begin()
+ partSet = model.moduleDocument()
+
+ ### Create Sketch
+ Sketch_1 = model.addSketch(partSet, model.defaultPlane("XOY"))
+
+ ### Create SketchCircle
+ SketchLine_1 = Sketch_1.addLine(3.9, 0, 8, 0)
+ SketchCircle_1 = Sketch_1.addCircle(-17.41591725155751, 16.35177358773851, 29.02191596082682)
+ constraint = Sketch_1.setTangent(SketchLine_1.result(), SketchCircle_1.center())
+ model.do()
+ model.end()
+
+ sam_line1, _ = ShapertoSAMPrimitive.convert(SketchLine_1)
+ sam_circle, _ = ShapertoSAMPrimitive.convert(SketchCircle_1)
+ sam_constraint = ShapertoSAMConstraints.convert(constraint, refs = [sam_line1, sam_circle])
+
+ # Check type
+ self.assertEqual(sam_constraint.get_name(), 'TANGENT')
+
+ # Check references
+ self.assertEqual(sam_constraint.references[0], sam_line1)
+ self.assertEqual(sam_constraint.references[1], sam_circle)
+
+
+ def test_convert_vertical(self):
+ model.begin()
+ partSet = model.moduleDocument()
+
+ ### Create Sketch
+ Sketch_1 = model.addSketch(partSet, model.defaultPlane("XOY"))
+
+ ### Create SketchCircle
+ SketchLine_1 = Sketch_1.addLine(3.9, 0, 8, 0)
+ constraint = Sketch_1.setVertical(SketchLine_1.result())
+ model.do()
+ model.end()
+
+ sam_line1, _ = ShapertoSAMPrimitive.convert(SketchLine_1)
+ sam_constraint = ShapertoSAMConstraints.convert(constraint, refs = [sam_line1])
+
+ # Check type
+ self.assertEqual(sam_constraint.get_name(), 'VERTICAL')
+
+ # Check references
+ self.assertEqual(sam_constraint.references[0], sam_line1)
--- /dev/null
+import unittest
+
+import salome
+salome.standalone()
+from SketchAPI import *
+
+import sys
+sys.path.append('sam')
+
+from SAMConverter_Logger import logger
+from SAMConverter_ConvertConstraints import *
+from SAMConverter_ConvertPrimitives import *
+
+from salome.shaper import model
+
+class TestConverHorizontalDistance(unittest.TestCase):
+
+ def test_convert_distance_Point_Point(self):
+ model.begin()
+ partSet = model.moduleDocument()
+
+ ### Create Sketch
+ Sketch_1 = model.addSketch(partSet, model.defaultPlane("XOY"))
+
+ ### Create SketchCircle
+ SketchPoint_1 = Sketch_1.addPoint(1., 0)
+ SketchPoint_2 = Sketch_1.addPoint(4., 0)
+ constraint = Sketch_1.setHorizontalDistance(SketchPoint_1.coordinates(), SketchPoint_2.coordinates(), 10)
+ model.do()
+ model.end()
+
+ sam_point, mapping_info = ShapertoSAMPrimitive.convert(SketchPoint_1)
+ sam_line, mapping_info = ShapertoSAMPrimitive.convert(SketchPoint_2)
+ sam_constraint = ShapertoSAMConstraints.convert(constraint, refs = [sam_point, sam_line])
+
+ # Check type
+ self.assertEqual(sam_constraint.get_name(), 'HORIZONTAL_DISTANCE')
+
+ # Check references
+ self.assertEqual(sam_constraint.references[0], sam_point)
+ self.assertEqual(sam_constraint.references[1], sam_line)
+
+ # Check value
+ self.assertEqual(sam_constraint.distance_min, 10.0)
+
+
+ def test_convert_distance_Point_Line(self):
+ model.begin()
+ partSet = model.moduleDocument()
+
+ ### Create Sketch
+ Sketch_1 = model.addSketch(partSet, model.defaultPlane("XOY"))
+
+ ### Create SketchCircle
+ SketchPoint_1 = Sketch_1.addPoint(1., 0)
+ SketchLine_1 = Sketch_1.addLine(3.9, 0, 8, 0)
+ constraint = Sketch_1.setHorizontalDistance(SketchPoint_1.coordinates(), SketchLine_1.startPoint(), 2)
+ model.do()
+ model.end()
+
+ sam_point, mapping_info = ShapertoSAMPrimitive.convert(SketchPoint_1)
+ sam_line, mapping_info = ShapertoSAMPrimitive.convert(SketchLine_1)
+ sam_constraint = ShapertoSAMConstraints.convert(constraint, refs = [sam_point, sam_line])
+
+ # Check type
+ self.assertEqual(sam_constraint.get_name(), 'HORIZONTAL_DISTANCE')
+
+ # Check references
+ self.assertEqual(sam_constraint.references[0], sam_point)
+ self.assertEqual(sam_constraint.references[1], sam_line)
+
+ # Check value
+ self.assertEqual(sam_constraint.distance_min, 2)
+
+ def test_convert_distance_Point_Circle(self):
+ model.begin()
+ partSet = model.moduleDocument()
+
+ ### Create Sketch
+ Sketch_1 = model.addSketch(partSet, model.defaultPlane("XOY"))
+
+ ### Create SketchCircle
+ SketchPoint_1 = Sketch_1.addPoint(1., 0)
+ SketchCircle_1 = Sketch_1.addCircle(-17.41591725155751, 16.35177358773851, 29.02191596082682)
+ constraint = Sketch_1.setHorizontalDistance( SketchPoint_1.coordinates(), SketchCircle_1.center(), 6)
+ model.do()
+ model.end()
+
+ sam_point, mapping_info = ShapertoSAMPrimitive.convert(SketchPoint_1)
+ sam_circle, mapping_info = ShapertoSAMPrimitive.convert(SketchCircle_1)
+ sam_constraint = ShapertoSAMConstraints.convert(constraint, refs = [sam_point, sam_circle])
+
+ # Check type
+ self.assertEqual(sam_constraint.get_name(), 'HORIZONTAL_DISTANCE')
+
+ # Check references
+ self.assertEqual(sam_constraint.references[0], sam_point)
+ self.assertEqual(sam_constraint.references[1], sam_circle)
+
+ # Check value
+ self.assertEqual(sam_constraint.distance_min, 6)
--- /dev/null
+import unittest
+
+import salome
+salome.standalone()
+
+import sys
+sys.path.append('sam')
+
+from SAMConverter_Logger import logger
+from SAMConverter_ConvertConstraints import *
+from SAMConverter_ConvertPrimitives import *
+
+from salome.shaper import model
+
+class TestConvertLength(unittest.TestCase):
+
+ def test_convert_length(self):
+ model.begin()
+ partSet = model.moduleDocument()
+
+ ### Create Sketch
+ Sketch_1 = model.addSketch(partSet, model.defaultPlane("XOY"))
+
+ ### Create SketchCircle
+ SketchLine_1 = Sketch_1.addLine(3.9, 0, 8, 0)
+ SketchLength_1 = Sketch_1.setLength(SketchLine_1.result(), 10)
+ model.do()
+ model.end()
+
+ sam_line, mapping_info = ShapertoSAMPrimitive.convert(SketchLine_1)
+ sam_length = ShapertoSAMConstraints.convert(SketchLength_1, refs = [sam_line])
+
+ # Check type
+ self.assertEqual(sam_length.get_name(), 'LENGTH')
+
+ # Check Length value
+ self.assertEqual(sam_length.length, 10)
+
+ # Check references
+ # - Verify the line information
+ ref_sam_line = sam_length.references[0] # Check that it is the same instance object
+ self.assertEqual(sam_line, ref_sam_line)
+ #TODO: X coordinate may differ from expected, but length is correct
+ #self.assertAlmostEqual(ref_sam_line.pnt1.x, 0.828, delta=10e-4) # - temporarily commented line
+ self.assertEqual(ref_sam_line.pnt1.y, 0.)
+ #self.assertAlmostEqual(ref_sam_line.pnt2.x, 10.828, delta=10e-4) # - temporarily commented line
+ self.assertEqual(ref_sam_line.pnt2.y, 0.)
+ self.assertEqual(ref_sam_line.is_construction(), False)
--- /dev/null
+import unittest
+
+import salome
+salome.standalone()
+
+import sys
+sys.path.append('sam')
+
+from SAMConverter_Logger import logger
+from SAMConverter_ConvertPrimitives import *
+
+
+from salome.shaper import model
+from sam.catalog_primitive import Arc, Line, Circle, Point
+
+
+class TestConvertLine(unittest.TestCase):
+
+ def test_convert_line(self):
+
+ model.begin()
+ partSet = model.moduleDocument()
+
+ ### Create Sketch
+ Sketch_1 = model.addSketch(partSet, model.defaultPlane("XOY"))
+
+ ### Create SketchLine
+ SketchLine_1 = Sketch_1.addLine(3.9, 0, 8, 0)
+ SketchLine_2 = Sketch_1.addLine(0., 0, 1., 1)
+ SketchLine_2.setAuxiliary(True)
+ model.do()
+ model.end()
+
+ # Test 1 : SketchLine_1
+ sam_line, mapping_info = ShapertoSAMPrimitive.convert(SketchLine_1)
+
+ # - Verify the line information
+ self.assertEqual(sam_line.pnt1.x, 3.9)
+ self.assertEqual(sam_line.pnt1.y, 0.)
+ self.assertEqual(sam_line.pnt2.x, 8)
+ self.assertEqual(sam_line.pnt2.y, 0.)
+ self.assertEqual(sam_line.is_construction(), False)
+
+ # - Verify the mapping information
+ self.assertIn((3.9, 0.0, 'SketchLine_1'), mapping_info)
+ self.assertIn((8.0, 0.0, 'SketchLine_1'), mapping_info)
+ self.assertEqual(str(mapping_info[(3.9, 0.0, 'SketchLine_1')]), 'Point P(3.9, 0.0)')
+ self.assertEqual(str(mapping_info[(8.0, 0.0, 'SketchLine_1')]), 'Point P(8.0, 0.0)')
+
+ # Test 1 : SketchLine_2
+ sam_line, mapping_info = ShapertoSAMPrimitive.convert(SketchLine_2)
+
+ # - Verify the line information
+ self.assertEqual(sam_line.pnt1.x, 0.)
+ self.assertEqual(sam_line.pnt1.y, 0.)
+ self.assertEqual(sam_line.pnt2.x, 1.)
+ self.assertEqual(sam_line.pnt2.y, 1.)
+ self.assertEqual(sam_line.is_construction(), True)
+
+ # - Verify the mapping information
+ self.assertIn((0., 0.0, 'SketchLine_2'), mapping_info)
+ self.assertIn((1., 1., 'SketchLine_2'), mapping_info)
+ self.assertEqual(str(mapping_info[(0., 0.0, 'SketchLine_2')]), 'Point P(0.0, 0.0)')
+ self.assertEqual(str(mapping_info[(1., 1., 'SketchLine_2')]), 'Point P(1.0, 1.0)')
+
+
+ self.assertTrue(True)
+ if salome.sg.hasDesktop():
+ salome.sg.updateObjBrowser()
--- /dev/null
+import unittest
+
+import salome
+salome.standalone()
+
+import sys
+sys.path.append('sam')
+
+from SAMConverter_Logger import logger
+from SAMConverter_ConvertPrimitives import *
+
+
+from salome.shaper import model
+from sam.catalog_primitive import Arc, Line, Circle, Point
+
+
+class TestConvertPoint(unittest.TestCase):
+
+ def test_convert_point(self):
+
+ model.begin()
+ partSet = model.moduleDocument()
+
+ ### Create Sketch
+ Sketch_1 = model.addSketch(partSet, model.defaultPlane("XOY"))
+
+ ### Create SketchPoint
+ SketchPoint_1 = Sketch_1.addPoint(1., 0)
+ SketchPoint_2 = Sketch_1.addPoint(10., 4)
+ SketchPoint_2.setAuxiliary(True)
+ model.do()
+ model.end()
+
+ # Test 1 : SketchPoint_1
+ sam_point, mapping_info = ShapertoSAMPrimitive.convert(SketchPoint_1)
+
+ # - Verify the point information
+ self.assertEqual(sam_point.x, 1.)
+ self.assertEqual(sam_point.y, 0.)
+ self.assertEqual(sam_point.is_construction(), False)
+
+ # Verify the mapping information
+ self.assertDictEqual(mapping_info, {})
+
+ # Test 2 : SketchPoint_2
+ sam_point, mapping_info = ShapertoSAMPrimitive.convert(SketchPoint_2)
+
+ # - Verify the point information
+ self.assertEqual(sam_point.x, 10.)
+ self.assertEqual(sam_point.y, 4.)
+ self.assertEqual(sam_point.is_construction(), True)
+
+ # Verify the mapping information
+ self.assertDictEqual(mapping_info, {})
+
+
+ self.assertTrue(True)
+ if salome.sg.hasDesktop():
+ salome.sg.updateObjBrowser()
+from TestSAMConverter_Arc import TestConvertArc
+from TestSAMConverter_Circle import TestConvertCircle
+from TestSAMConverter_Line import TestConvertLine
+from TestSAMConverter_Point import TestConvertPoint
+line = TestConvertLine()
+line.test_convert_line()
+
+point = TestConvertPoint()
+point.test_convert_point()
+
+arc = TestConvertArc()
+arc.test_convert_arc()
+
+cir = TestConvertCircle()
+cir.test_convert_circle()
--- /dev/null
+import unittest
+
+import salome
+salome.standalone()
+
+import sys
+sys.path.append('sam')
+
+from SAMConverter_Logger import logger
+from SAMConverter_ConvertConstraints import *
+from SAMConverter_ConvertPrimitives import *
+
+from salome.shaper import model
+
+class TestConvertRadius(unittest.TestCase):
+
+ def test_convert_radius(self):
+ model.begin()
+ partSet = model.moduleDocument()
+
+ ### Create Sketch
+ Sketch_1 = model.addSketch(partSet, model.defaultPlane("XOY"))
+
+ ### Create SketchCircle
+ SketchCircle_1 = Sketch_1.addCircle(0, 0, 30)
+ SketchRadius_1 = Sketch_1.setRadius(SketchCircle_1.results()[1], 40)
+ model.do()
+ model.end()
+
+ sam_circle, mapping_info = ShapertoSAMPrimitive.convert(SketchCircle_1)
+ sam_radius = ShapertoSAMConstraints.convert(SketchRadius_1, refs = [sam_circle])
+
+ # Check type
+ self.assertEqual(sam_radius.get_name(), 'RADIUS')
+
+ # Check Radius value
+ self.assertEqual(sam_radius.radius, 40)
+
+ # Check references
+ # - Verify the circle information
+ ref_sam_circle = sam_radius.references[0] # Check that it is the same instance object
+ self.assertEqual(sam_circle, ref_sam_circle)
+ self.assertEqual(ref_sam_circle.radius, 40.0)
+ self.assertEqual(ref_sam_circle.center.x, 0.)
+ self.assertEqual(ref_sam_circle.center.y, 0.)
+ self.assertEqual(ref_sam_circle.is_construction(), False)
--- /dev/null
+import unittest
+
+import salome
+salome.standalone()
+from SketchAPI import *
+
+import sys
+sys.path.append('sam')
+
+from SAMConverter_Logger import logger
+from SAMConverter_ConvertConstraints import *
+from SAMConverter_ConvertPrimitives import *
+
+from salome.shaper import model
+
+class TestConvertVerticalDistance(unittest.TestCase):
+
+ def test_convert_distance_Point_Point(self):
+ model.begin()
+ partSet = model.moduleDocument()
+
+ ### Create Sketch
+ Sketch_1 = model.addSketch(partSet, model.defaultPlane("XOY"))
+
+ ### Create SketchPoint
+ SketchPoint_1 = Sketch_1.addPoint(1., 0)
+ SketchPoint_2 = Sketch_1.addPoint(4., 0)
+ constraint = Sketch_1.setVerticalDistance(SketchPoint_1.coordinates(), SketchPoint_2.coordinates(), 10)
+ model.do()
+ model.end()
+
+ sam_point1, mapping_info = ShapertoSAMPrimitive.convert(SketchPoint_1)
+ sam_point2, mapping_info = ShapertoSAMPrimitive.convert(SketchPoint_2)
+ sam_constraint = ShapertoSAMConstraints.convert(constraint, refs = [sam_point1, sam_point2])
+
+ # Check type
+ self.assertEqual(sam_constraint.get_name(), 'VERTICAL_DISTANCE')
+
+ # Check references
+ self.assertEqual(sam_constraint.references[0], sam_point1)
+ self.assertEqual(sam_constraint.references[1], sam_point2)
+
+ # Check value
+ self.assertEqual(sam_constraint.distance_min, 10.0)
+
+
+ def test_convert_distance_Point_Line(self):
+ model.begin()
+ partSet = model.moduleDocument()
+
+ ### Create Sketch
+ Sketch_1 = model.addSketch(partSet, model.defaultPlane("XOY"))
+
+ ### Create SketchPoint and SketchLine
+ SketchPoint_1 = Sketch_1.addPoint(1., 0)
+ SketchLine_1 = Sketch_1.addLine(3.9, 0, 8, 0)
+ constraint = Sketch_1.setVerticalDistance(SketchPoint_1.coordinates(), SketchLine_1.startPoint(), 2)
+ model.do()
+ model.end()
+
+ sam_point, mapping_info = ShapertoSAMPrimitive.convert(SketchPoint_1)
+ sam_line, mapping_info = ShapertoSAMPrimitive.convert(SketchLine_1)
+ sam_constraint = ShapertoSAMConstraints.convert(constraint, refs = [sam_point, sam_line])
+
+ # Check type
+ self.assertEqual(sam_constraint.get_name(), 'VERTICAL_DISTANCE')
+
+ # Check references
+ self.assertEqual(sam_constraint.references[0], sam_point)
+ self.assertEqual(sam_constraint.references[1], sam_line)
+
+ # Check value
+ self.assertEqual(sam_constraint.distance_min, 2)
+
+ def test_convert_distance_Point_Circle(self):
+ model.begin()
+ partSet = model.moduleDocument()
+
+ ### Create Sketch
+ Sketch_1 = model.addSketch(partSet, model.defaultPlane("XOY"))
+
+ ### Create SketchPoint and SketchCircle
+ SketchPoint_1 = Sketch_1.addPoint(1., 0)
+ SketchCircle_1 = Sketch_1.addCircle(-17.41591725155751, 16.35177358773851, 29.02191596082682)
+ constraint = Sketch_1.setVerticalDistance( SketchPoint_1.coordinates(), SketchCircle_1.center(), 6)
+ model.do()
+ model.end()
+
+ sam_point, mapping_info = ShapertoSAMPrimitive.convert(SketchPoint_1)
+ sam_circle, mapping_info = ShapertoSAMPrimitive.convert(SketchCircle_1)
+ sam_constraint = ShapertoSAMConstraints.convert(constraint, refs = [sam_point, sam_circle])
+
+ # Check type
+ self.assertEqual(sam_constraint.get_name(), 'VERTICAL_DISTANCE')
+ # Check references
+ self.assertEqual(sam_constraint.references[0], sam_point)
+ self.assertEqual(sam_constraint.references[1], sam_circle)
+
+ # Check value
+ self.assertEqual(sam_constraint.distance_min, 6)
#
SET(TEST_NAMES
- TestSAMConverter_Primitives.py
- TestSAMConverter_Constraints.py
- TestSAMConverter_Sketch.py
+ TestSAMConverter_Angle
+ TestSAMConverter_Arc
+ TestSAMConverter_Circle
+ TestSAMConverter_Constraints
+ TestSAMConverter_Distance
+ TestSAMConverter_Geometrical
+ TestSAMConverter_HorisontalDistance
+ TestSAMConverter_Length
+ TestSAMConverter_Line
+ TestSAMConverter_Point
+ TestSAMConverter_Primitives
+ TestSAMConverter_Radius
+ TestSAMConverter_Sketch
+ TestSAMConverter_VerticalDistance
)
)
#TODO(spo): is ${OpenCASCADE_DEFINITIONS} necessary?
-ADD_DEFINITIONS(-DCONNECTORAPI_EXPORTS ${OpenCASCADE_DEFINITIONS})
+ADD_DEFINITIONS(-DSAMCONVERTERAPI_EXPORTS ${OpenCASCADE_DEFINITIONS})
ADD_LIBRARY(SAMConverterAPI SHARED ${PROJECT_SOURCES} ${PROJECT_HEADERS})
TARGET_LINK_LIBRARIES(SAMConverterAPI ${PROJECT_LIBRARIES})
#TODO(spo): is ModelAPI necessary or it could be received by INTERFACE_ (may require modern CMake)?
SET(SWIG_LINK_LIBRARIES
- SAMConverterAPI
ModelHighAPI
ModelAPI
+ SAMConverterAPI
${PYTHON_LIBRARIES}
)
INSTALL(TARGETS _SAMConverterAPI DESTINATION ${SHAPER_INSTALL_SWIG})
INSTALL(TARGETS SAMConverterAPI DESTINATION ${SHAPER_INSTALL_BIN})
-INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/SAMConverterAPI.py DESTINATION ${SHAPER_INSTALL_SWIG})
-
-# Tests
-#IF(${HAVE_SALOME})
-# ENABLE_TESTING()
-# ADD_SUBDIRECTORY(Test)
-#ENDIF(${HAVE_SALOME})
+INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/SAMConverterAPI.py DESTINATION ${SHAPER_INSTALL_SWIG})
\ No newline at end of file
+++ /dev/null
-solid
- facet normal -1.000000e+00 0.000000e+00 0.000000e+00
- outer loop
- vertex 0.000000e+00 0.000000e+00 0.000000e+00
- vertex 0.000000e+00 8.000000e+00 5.000000e+00
- vertex 0.000000e+00 8.000000e+00 0.000000e+00
- endloop
- endfacet
- facet normal -1.000000e+00 0.000000e+00 0.000000e+00
- outer loop
- vertex 0.000000e+00 0.000000e+00 5.000000e+00
- vertex 0.000000e+00 8.000000e+00 5.000000e+00
- vertex 0.000000e+00 0.000000e+00 0.000000e+00
- endloop
- endfacet
- facet normal 1.000000e+00 0.000000e+00 0.000000e+00
- outer loop
- vertex 1.400000e+01 0.000000e+00 0.000000e+00
- vertex 1.400000e+01 8.000000e+00 0.000000e+00
- vertex 1.400000e+01 8.000000e+00 5.000000e+00
- endloop
- endfacet
- facet normal 1.000000e+00 -0.000000e+00 0.000000e+00
- outer loop
- vertex 1.400000e+01 0.000000e+00 5.000000e+00
- vertex 1.400000e+01 0.000000e+00 0.000000e+00
- vertex 1.400000e+01 8.000000e+00 5.000000e+00
- endloop
- endfacet
- facet normal 0.000000e+00 -1.000000e+00 -0.000000e+00
- outer loop
- vertex 1.400000e+01 0.000000e+00 5.000000e+00
- vertex 0.000000e+00 0.000000e+00 0.000000e+00
- vertex 1.400000e+01 0.000000e+00 0.000000e+00
- endloop
- endfacet
- facet normal -0.000000e+00 -1.000000e+00 0.000000e+00
- outer loop
- vertex 1.400000e+01 0.000000e+00 5.000000e+00
- vertex 0.000000e+00 0.000000e+00 5.000000e+00
- vertex 0.000000e+00 0.000000e+00 0.000000e+00
- endloop
- endfacet
- facet normal 0.000000e+00 1.000000e+00 0.000000e+00
- outer loop
- vertex 1.400000e+01 8.000000e+00 5.000000e+00
- vertex 1.400000e+01 8.000000e+00 0.000000e+00
- vertex 0.000000e+00 8.000000e+00 0.000000e+00
- endloop
- endfacet
- facet normal 0.000000e+00 1.000000e+00 0.000000e+00
- outer loop
- vertex 1.400000e+01 8.000000e+00 5.000000e+00
- vertex 0.000000e+00 8.000000e+00 0.000000e+00
- vertex 0.000000e+00 8.000000e+00 5.000000e+00
- endloop
- endfacet
- facet normal -0.000000e+00 0.000000e+00 -1.000000e+00
- outer loop
- vertex 1.400000e+01 8.000000e+00 0.000000e+00
- vertex 0.000000e+00 0.000000e+00 0.000000e+00
- vertex 0.000000e+00 8.000000e+00 0.000000e+00
- endloop
- endfacet
- facet normal 0.000000e+00 -0.000000e+00 -1.000000e+00
- outer loop
- vertex 1.400000e+01 8.000000e+00 0.000000e+00
- vertex 1.400000e+01 0.000000e+00 0.000000e+00
- vertex 0.000000e+00 0.000000e+00 0.000000e+00
- endloop
- endfacet
- facet normal 0.000000e+00 0.000000e+00 1.000000e+00
- outer loop
- vertex 1.400000e+01 8.000000e+00 5.000000e+00
- vertex 0.000000e+00 8.000000e+00 5.000000e+00
- vertex 0.000000e+00 0.000000e+00 5.000000e+00
- endloop
- endfacet
- facet normal 0.000000e+00 0.000000e+00 1.000000e+00
- outer loop
- vertex 1.400000e+01 8.000000e+00 5.000000e+00
- vertex 0.000000e+00 0.000000e+00 5.000000e+00
- vertex 1.400000e+01 0.000000e+00 5.000000e+00
- endloop
- endfacet
-endsolid