]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Created a unit-test and user manual for the sketch drawer
authormpv <mpv@opencascade.com>
Thu, 29 Nov 2018 08:55:17 +0000 (11:55 +0300)
committermpv <mpv@opencascade.com>
Thu, 29 Nov 2018 08:55:17 +0000 (11:55 +0300)
src/SketchPlugin/CMakeLists.txt
src/SketchPlugin/SketchPlugin_SketchDrawer.cpp
src/SketchPlugin/Test/TestSketchDrawer.py [new file with mode: 0644]
src/SketchPlugin/doc/SketchPlugin.rst
src/SketchPlugin/doc/images/SketchDrawer.png [new file with mode: 0644]
src/SketchPlugin/doc/images/SketchDrawer_panel.png [new file with mode: 0644]
src/SketchPlugin/doc/images/SketchDrawer_res.png [new file with mode: 0644]
src/SketchPlugin/doc/sketchDrawer.rst [new file with mode: 0644]

index d0c9f5f33b2d5bf00d59aae975be2ca29989ba26..8a17e7fed0b7c325e8922e8a77fa1da1278d03bd 100644 (file)
@@ -267,6 +267,7 @@ ADD_UNIT_TESTS(
   TestTrimCircleAndArc01.py
   TestTrimLine01.py
   TestTrimLine02.py
+  TestSketchDrawer.py
 )
 
 if(${SKETCHER_CHANGE_RADIUS_WHEN_MOVE})
index 43f3f49a7ff8e9167e7bbbe0cd565a23fe36aba9..cc3b90f903128102b639dae17f47ccb719e56818 100644 (file)
@@ -90,13 +90,6 @@ void SketchPlugin_SketchDrawer::execute()
   DocumentPtr aMyDoc = document();
   std::shared_ptr<SketchPlugin_Sketch> aSketch =
     std::dynamic_pointer_cast<SketchPlugin_Sketch>(aMyDoc->addFeature(SketchPlugin_Sketch::ID()));
-  /*if (aPlaneContext->groupName() == ModelAPI_ResultConstruction::group()) { // by coordinates
-    std::dynamic_pointer_cast<GeomDataAPI_Point>(
-      aSketch->attribute(SketchPlugin_Sketch::ORIGIN_ID()))->setValue(aPlane->location());
-    std::dynamic_pointer_cast<GeomDataAPI_Dir>(
-      aSketch->attribute(SketchPlugin_Sketch::NORM_ID()))->setValue(aPlane->direction());
-
-  } else {*/
   // by selection of plane
   aSketch->selection(SketchPlugin_SketchEntity::EXTERNAL_ID())->
     setValue(selection(PLANE_ID())->context(), aPlaneShape);
diff --git a/src/SketchPlugin/Test/TestSketchDrawer.py b/src/SketchPlugin/Test/TestSketchDrawer.py
new file mode 100644 (file)
index 0000000..b90c948
--- /dev/null
@@ -0,0 +1,62 @@
+# -*- coding: utf-8 -*-
+
+from SketchAPI import *
+
+from salome.shaper import model
+
+model.begin()
+partSet = model.moduleDocument()
+Part_1 = model.addPart(partSet)
+Part_1_doc = Part_1.document()
+Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOY"))
+SketchLine_1 = Sketch_1.addLine(-14.48008258397498, -13.79591274114419, 5.519917416025022, -13.79591274114419)
+SketchLine_2 = Sketch_1.addLine(10.51991741602502, -8.795912741144186, 10.51991741602502, 18.20408725885581)
+SketchLine_3 = Sketch_1.addLine(10.51991741602502, 18.20408725885581, -14.48008258397498, 13.79591274114419)
+SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchLine_2.endPoint(), SketchLine_3.startPoint())
+SketchConstraintCoincidence_1.setName("SketchConstraintCoincidence_2")
+SketchLine_4 = Sketch_1.addLine(-14.48008258397498, 13.79591274114419, -14.48008258397498, -13.79591274114419)
+SketchConstraintCoincidence_2 = Sketch_1.setCoincident(SketchLine_3.endPoint(), SketchLine_4.startPoint())
+SketchConstraintCoincidence_2.setName("SketchConstraintCoincidence_3")
+SketchConstraintCoincidence_3 = Sketch_1.setCoincident(SketchLine_1.startPoint(), SketchLine_4.endPoint())
+SketchConstraintCoincidence_3.setName("SketchConstraintCoincidence_4")
+SketchArc_1 = Sketch_1.addArc(5.519917416025022, -8.795912741144186, 5.519917416025022, -13.79591274114419, 10.51991741602502, -8.795912741144186, False)
+SketchConstraintCoincidence_4 = Sketch_1.setCoincident(SketchArc_1.startPoint(), SketchLine_1.endPoint())
+SketchConstraintCoincidence_4.setName("SketchConstraintCoincidence_5")
+SketchConstraintCoincidence_5 = Sketch_1.setCoincident(SketchArc_1.endPoint(), SketchLine_2.startPoint())
+SketchConstraintCoincidence_5.setName("SketchConstraintCoincidence_6")
+SketchConstraintTangent_1 = Sketch_1.setTangent(SketchArc_1.results()[1], SketchLine_1.result())
+SketchConstraintTangent_2 = Sketch_1.setTangent(SketchArc_1.results()[1], SketchLine_2.result())
+SketchCircle_1 = Sketch_1.addCircle(0, 0, 5)
+SketchConstraintHorizontal_1 = Sketch_1.setHorizontal(SketchLine_1.result())
+SketchConstraintVertical_1 = Sketch_1.setVertical(SketchLine_2.result())
+SketchConstraintAngle_1 = Sketch_1.setAngle(SketchLine_4.result(), SketchLine_3.result(), 100)
+SketchConstraintLength_1 = Sketch_1.setLength(SketchLine_2.result(), 27)
+SketchConstraintDistance_1 = Sketch_1.setDistance(SketchLine_1.startPoint(), SketchLine_2.result(), 25, True)
+SketchConstraintRadius_1 = Sketch_1.setRadius(SketchArc_1.results()[1], 5)
+SketchConstraintPerpendicular_1 = Sketch_1.setPerpendicular(SketchLine_1.result(), SketchLine_4.result())
+SketchConstraintDistance_2 = Sketch_1.setDistance(SketchLine_4.startPoint(), SketchCircle_1.center(), 20, True)
+SketchConstraintDistance_3 = Sketch_1.setDistance(SketchLine_4.endPoint(), SketchCircle_1.center(), 20, True)
+SketchProjection_1 = Sketch_1.addProjection(model.selection("VERTEX", "PartSet/Origin"), False)
+SketchPoint_1 = SketchProjection_1.createdFeature()
+SketchConstraintCoincidence_6 = Sketch_1.setCoincident(SketchAPI_Point(SketchPoint_1).coordinates(), SketchCircle_1.center())
+SketchConstraintCoincidence_6.setName("SketchConstraintCoincidence_7")
+SketchConstraintRadius_2 = Sketch_1.setRadius(SketchCircle_1.results()[1], 5)
+model.do()
+Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchLine_1r-SketchArc_1_2f-SketchLine_2f-SketchLine_3f-SketchLine_4f-SketchCircle_1_2r")], model.selection(), 10, 0)
+model.do()
+# create a drawer feature of the extrusion and upper face
+Drawer = Part_1_doc.addFeature("SketchDrawer")
+Drawer.selection("base_shape").setValue(Extrusion_1.feature(), None)
+PlaneSelection = model.selection("FACE", "Extrusion_1_1/To_Face")
+PlaneSelection.fillAttribute(Drawer.selection("plane"))
+model.end()
+
+# check that a sketch is created with valid elements
+assert(Part_1_doc.size("Construction") == 2) # two sketches: base of extrusion and this new one
+
+from ModelAPI import *
+aFactory = ModelAPI_Session.get().validators()
+
+Sketch = objectToFeature(Part_1_doc.object("Features", 2)) # created sketch feature
+assert(aFactory.validate(Sketch))
+assert(len(Sketch.results()) == 1)
index fd95d68e97bc450310b7a027f0f2bc4b4db0b0ea..627ca479a579a2cbff2b742226fa3d06b2be60db 100644 (file)
@@ -154,3 +154,4 @@ The plug-in includes the following operations:
    mirrorFeature.rst
    translationFeature.rst
    rotationFeature.rst
+   sketchDrawer.rst
diff --git a/src/SketchPlugin/doc/images/SketchDrawer.png b/src/SketchPlugin/doc/images/SketchDrawer.png
new file mode 100644 (file)
index 0000000..e3f53d1
Binary files /dev/null and b/src/SketchPlugin/doc/images/SketchDrawer.png differ
diff --git a/src/SketchPlugin/doc/images/SketchDrawer_panel.png b/src/SketchPlugin/doc/images/SketchDrawer_panel.png
new file mode 100644 (file)
index 0000000..8b78650
Binary files /dev/null and b/src/SketchPlugin/doc/images/SketchDrawer_panel.png differ
diff --git a/src/SketchPlugin/doc/images/SketchDrawer_res.png b/src/SketchPlugin/doc/images/SketchDrawer_res.png
new file mode 100644 (file)
index 0000000..b746e4e
Binary files /dev/null and b/src/SketchPlugin/doc/images/SketchDrawer_res.png differ
diff --git a/src/SketchPlugin/doc/sketchDrawer.rst b/src/SketchPlugin/doc/sketchDrawer.rst
new file mode 100644 (file)
index 0000000..20bb2eb
--- /dev/null
@@ -0,0 +1,53 @@
+  .. _create_sketch_drawer:
+
+Sketch Drawer
+=========
+
+Sketch Drawer featrure is a macro-feature, i.e. it is removed after its execution.
+It allows simplify creation of sketches basing on existing models without referencing to
+these models.
+
+For an example, to create a sketch on exising STEP file model planar face
+and then remove the original model, to keep only the sketch with copy of contour. So, to be
+able to remove the initial model, there are no references created by this feature.
+
+To add a new Sketch Drawing:
+
+#. select in the Main Menu *Macros - > Sketch drawer* item  or
+#. click **Sketch drawer** button in Macros toolbar:
+
+.. image:: images/SketchDrawer.png
+   :align: center
+
+.. centered::
+   **Sketch drawer**  button
+
+The following property panel appears:
+
+.. image:: images/SketchDrawer_panel.png
+  :align: center
+
+.. centered::
+   Sketch drawer
+
+Click in the view once to set the whole original model, then click a second time to set the
+plane or planar face - a base of sketch. This can be plane on the original model.
+On Apply button press the new sketch will be created in the Object Browser tree.
+
+Result
+""""""
+
+A resulting sketch will contain linear and circular edges as well as circular arcs corresponding to the
+original model edges that lay in the sketch plane. Other types of edges are not supported.
+
+Radius, length, vertical, horizontal and points-coincidence constraints will be created
+automatically where it is possible. The resulting sketch may be overconstrained or not fully
+constrained. So, it is just a helper for the sketch creation, not universal tool. After this
+sketch creation normally user must edit this sketch to input reasonable constraints and
+parametrization, or remove not needed constraints or sketch lements.
+
+.. image:: images/SketchDrawer_res.png
+          :align: center
+
+.. centered::
+   Drawn sketch