//==================================================================================================
void FeaturesAPI_RevolutionBoolean::setPlanesAndOffsets(const ModelHighAPI_Selection& theToObject,
const ModelHighAPI_Double& theToOffset,
- const ModelHighAPI_Selection& theFromObject,
+ const ModelHighAPI_Selection& theFromObject,
const ModelHighAPI_Double& theFromOffset)
{
fillAttribute(FeaturesPlugin_Revolution::CREATION_METHOD_BY_PLANES(), mycreationMethod);
theDumper << ", " << anAttrToObject << ", " << anAttrToOffset <<
", " << anAttrFromObject << ", " << anAttrFromOffset;
+ } else {
+ // Through All
}
AttributeSelectionListPtr anAttrBoolObjects =
initialize();
}
+//==================================================================================================
+FeaturesAPI_RevolutionCut::FeaturesAPI_RevolutionCut(
+ const std::shared_ptr<ModelAPI_Feature>& theFeature,
+ const std::list<ModelHighAPI_Selection>& theBaseObjects,
+ const ModelHighAPI_Selection& theAxis,
+ const std::list<ModelHighAPI_Selection>& theBooleanObjects)
+: FeaturesAPI_RevolutionBoolean(theFeature)
+{
+ if(initialize()) {
+ fillAttribute(theBaseObjects, mybaseObjects);
+ fillAttribute(theAxis, myaxis);
+ fillAttribute(FeaturesPlugin_Revolution::CREATION_METHOD_THROUGH_ALL(), mycreationMethod);
+ setBooleanObjects(theBooleanObjects);
+ }
+}
+
//==================================================================================================
FeaturesAPI_RevolutionCut::FeaturesAPI_RevolutionCut(
const std::shared_ptr<ModelAPI_Feature>& theFeature,
}
}
+//==================================================================================================
+RevolutionCutPtr addRevolutionCut(const std::shared_ptr<ModelAPI_Document>& thePart,
+ const std::list<ModelHighAPI_Selection>& theBaseObjects,
+ const ModelHighAPI_Selection& theAxis,
+ const std::list<ModelHighAPI_Selection>& theBooleanObjects)
+{
+ std::shared_ptr<ModelAPI_Feature> aFeature =
+ thePart->addFeature(FeaturesPlugin_RevolutionCut::ID());
+ return RevolutionCutPtr(new FeaturesAPI_RevolutionCut(aFeature, theBaseObjects,
+ theAxis, theBooleanObjects));
+}
+
//==================================================================================================
RevolutionCutPtr addRevolutionCut(const std::shared_ptr<ModelAPI_Document>& thePart,
const std::list<ModelHighAPI_Selection>& theBaseObjects,
initialize();
}
+//==================================================================================================
+FeaturesAPI_RevolutionFuse::FeaturesAPI_RevolutionFuse(
+ const std::shared_ptr<ModelAPI_Feature>& theFeature,
+ const std::list<ModelHighAPI_Selection>& theBaseObjects,
+ const ModelHighAPI_Selection& theAxis,
+ const std::list<ModelHighAPI_Selection>& theBooleanObjects)
+: FeaturesAPI_RevolutionBoolean(theFeature)
+{
+ if(initialize()) {
+ fillAttribute(theBaseObjects, mybaseObjects);
+ fillAttribute(theAxis, myaxis);
+ fillAttribute(FeaturesPlugin_Revolution::CREATION_METHOD_THROUGH_ALL(), mycreationMethod);
+ setBooleanObjects(theBooleanObjects);
+ }
+}
+
//==================================================================================================
FeaturesAPI_RevolutionFuse::FeaturesAPI_RevolutionFuse(
const std::shared_ptr<ModelAPI_Feature>& theFeature,
}
}
+//==================================================================================================
+RevolutionFusePtr addRevolutionFuse(const std::shared_ptr<ModelAPI_Document>& thePart,
+ const std::list<ModelHighAPI_Selection>& theBaseObjects,
+ const ModelHighAPI_Selection& theAxis,
+ const std::list<ModelHighAPI_Selection>& theBooleanObjects)
+{
+ std::shared_ptr<ModelAPI_Feature> aFeature =
+ thePart->addFeature(FeaturesPlugin_RevolutionFuse::ID());
+ return RevolutionFusePtr(new FeaturesAPI_RevolutionFuse(aFeature, theBaseObjects,
+ theAxis, theBooleanObjects));
+}
+
//==================================================================================================
RevolutionFusePtr addRevolutionFuse(const std::shared_ptr<ModelAPI_Document>& thePart,
const std::list<ModelHighAPI_Selection>& theBaseObjects,
FEATURESAPI_EXPORT
explicit FeaturesAPI_RevolutionCut(const std::shared_ptr<ModelAPI_Feature>& theFeature);
+ /// Constructor with values.
+ FEATURESAPI_EXPORT
+ explicit FeaturesAPI_RevolutionCut(const std::shared_ptr<ModelAPI_Feature>& theFeature,
+ const std::list<ModelHighAPI_Selection>& theBaseObjects,
+ const ModelHighAPI_Selection& theAxis,
+ const std::list<ModelHighAPI_Selection>& theBooleanObjects);
+
/// Constructor with values.
FEATURESAPI_EXPORT
explicit FeaturesAPI_RevolutionCut(const std::shared_ptr<ModelAPI_Feature>& theFeature,
/// Pointer on RevolutionCut object.
typedef std::shared_ptr<FeaturesAPI_RevolutionCut> RevolutionCutPtr;
+/// \ingroup CPPHighAPI
+/// \brief Create RevolutionCut feature.
+FEATURESAPI_EXPORT
+RevolutionCutPtr addRevolutionCut(const std::shared_ptr<ModelAPI_Document>& thePart,
+ const std::list<ModelHighAPI_Selection>& theBaseObjects,
+ const ModelHighAPI_Selection& theAxis,
+ const std::list<ModelHighAPI_Selection>& theBooleanObjects);
+
/// \ingroup CPPHighAPI
/// \brief Create RevolutionCut feature.
FEATURESAPI_EXPORT
FEATURESAPI_EXPORT
explicit FeaturesAPI_RevolutionFuse(const std::shared_ptr<ModelAPI_Feature>& theFeature);
+ /// Constructor with values.
+ FEATURESAPI_EXPORT
+ explicit FeaturesAPI_RevolutionFuse(const std::shared_ptr<ModelAPI_Feature>& theFeature,
+ const std::list<ModelHighAPI_Selection>& theBaseObjects,
+ const ModelHighAPI_Selection& theAxis,
+ const std::list<ModelHighAPI_Selection>& theBooleanObjects);
+
/// Constructor with values.
FEATURESAPI_EXPORT
explicit FeaturesAPI_RevolutionFuse(const std::shared_ptr<ModelAPI_Feature>& theFeature,
/// Pointer on RevolutionFuse object.
typedef std::shared_ptr<FeaturesAPI_RevolutionFuse> RevolutionFusePtr;
+/// \ingroup CPPHighAPI
+/// \brief Create RevolutionFuse feature.
+FEATURESAPI_EXPORT
+RevolutionFusePtr addRevolutionFuse(const std::shared_ptr<ModelAPI_Document>& thePart,
+ const std::list<ModelHighAPI_Selection>& theBaseObjects,
+ const ModelHighAPI_Selection& theAxis,
+ const std::list<ModelHighAPI_Selection>& theBooleanObjects);
+
/// \ingroup CPPHighAPI
/// \brief Create RevolutionFuse feature.
FEATURESAPI_EXPORT
TestRevolutionCut.py
TestRevolutionCut_ByAngle.py
TestRevolutionCut_ByPlanesAndOffsets.py
+ TestRevolutionCut_ThroughAll.py
TestRevolutionFuse.py
TestRevolutionFuse_ByAngle.py
TestRevolutionFuse_ByPlanesAndOffsets.py
+ TestRevolutionFuse_ThroughAll.py
TestCompositeFeaturesOnCompSolids.py
TestPartition.py
TestPartition_ErrorMsg.py
double aToAngle = 0.0;
double aFromAngle = 0.0;
- if(string(CREATION_METHOD())->value() == CREATION_METHOD_BY_ANGLES()) {
+ if (string(CREATION_METHOD())->value() == CREATION_METHOD_BY_ANGLES()) {
aToAngle = real(TO_ANGLE_ID())->value();
aFromAngle = real(FROM_ANGLE_ID())->value();
- } else {
+ } else if (string(CREATION_METHOD())->value() == CREATION_METHOD_BY_PLANES()) {
aToAngle = real(TO_OFFSET_ID())->value();
aFromAngle = real(FROM_OFFSET_ID())->value();
+ } else if (string(CREATION_METHOD())->value() == CREATION_METHOD_THROUGH_ALL()) {
+ aToAngle = 360.0;
+ aFromAngle = 0.0;
+ } else {
}
// Getting bounding planes.
return MY_CREATION_METHOD_ID;
}
+ /// Attribute name for creation method.
+ inline static const std::string& CREATION_METHOD_THROUGH_ALL()
+ {
+ static const std::string MY_CREATION_METHOD_ID("ThroughAll");
+ return MY_CREATION_METHOD_ID;
+ }
+
/// Attribute name for creation method.
inline static const std::string& CREATION_METHOD_BY_ANGLES()
{
--- /dev/null
+# Copyright (C) 2018-2019 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
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+#
+
+from salome.shaper import model
+
+import math
+
+def checkMiddlePoint(shape, x, y, z, tolerance = 1.e-7):
+ assert(shape is not None)
+ middlePoint = shape.middlePoint()
+ assert(math.fabs(middlePoint.x() - x) < tolerance), "{} != {}".format(middlePoint.x(), x)
+ assert(math.fabs(middlePoint.y() - y) < tolerance), "{} != {}".format(middlePoint.y(), y)
+ assert(math.fabs(middlePoint.z() - z) < tolerance), "{} != {}".format(middlePoint.z(), z)
+
+model.begin()
+partSet = model.moduleDocument()
+Part_1 = model.addPart(partSet)
+Part_1_doc = Part_1.document()
+
+Box_1 = model.addBox(Part_1_doc, 10, 10, 10)
+Cylinder_1 = model.addCylinder(Part_1_doc, model.selection("VERTEX", "PartSet/Origin"), model.selection("EDGE", "PartSet/OZ"), 2, 10)
+Translation_1 = model.addTranslation(Part_1_doc, [model.selection("SOLID", "Cylinder_1_1")], 5, 5, 0)
+
+RevolutionCut_1 = model.addRevolutionCut(Part_1_doc, [], model.selection("EDGE", "[Box_1_1/Front][Box_1_1/Top]"), [model.selection("SOLID", "Box_1_1")])
+
+Sketch_1 = model.addSketch(Part_1_doc, model.selection("FACE", "Translation_1_1/MF:Translated&Cylinder_1_1/Face_2"))
+SketchProjection_1 = Sketch_1.addProjection(model.selection("VERTEX", "[Translation_1_1/MF:Translated&Cylinder_1_1/Face_1][Translation_1_1/MF:Translated&Cylinder_1_1/Face_2]__cc"), False)
+SketchPoint_1 = SketchProjection_1.createdFeature()
+SketchProjection_2 = Sketch_1.addProjection(model.selection("EDGE", "[Translation_1_1/MF:Translated&Cylinder_1_1/Face_1][Translation_1_1/MF:Translated&Cylinder_1_1/Face_2]"), False)
+SketchCircle_1 = SketchProjection_2.createdFeature()
+SketchCircle_2 = Sketch_1.addCircle(5, 5, 2)
+SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchPoint_1.result(), SketchCircle_2.center())
+SketchConstraintTangent_1 = Sketch_1.setTangent(SketchCircle_1.results()[1], SketchCircle_2.results()[1])
+
+RevolutionCut_1.setNestedSketch(Sketch_1)
+
+model.do()
+
+Shape = RevolutionCut_1.results()[0].resultSubShapePair()[0].shape()
+checkMiddlePoint(Shape, 5.13562827, 5.0, 5.13562827)
+
+model.end()
+
+assert(model.checkPythonDump())
--- /dev/null
+# Copyright (C) 2018-2019 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
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+#
+
+from salome.shaper import model
+
+import math
+
+def checkMiddlePoint(shape, x, y, z, tolerance = 1.e-7):
+ assert(shape is not None)
+ middlePoint = shape.middlePoint()
+ assert(math.fabs(middlePoint.x() - x) < tolerance), "{} != {}".format(middlePoint.x(), x)
+ assert(math.fabs(middlePoint.y() - y) < tolerance), "{} != {}".format(middlePoint.y(), y)
+ assert(math.fabs(middlePoint.z() - z) < tolerance), "{} != {}".format(middlePoint.z(), z)
+
+model.begin()
+partSet = model.moduleDocument()
+Part_1 = model.addPart(partSet)
+Part_1_doc = Part_1.document()
+
+Box_1 = model.addBox(Part_1_doc, 10, 10, 10)
+Cylinder_1 = model.addCylinder(Part_1_doc, model.selection("VERTEX", "PartSet/Origin"), model.selection("EDGE", "PartSet/OZ"), 2, 10)
+Translation_1 = model.addTranslation(Part_1_doc, [model.selection("SOLID", "Cylinder_1_1")], 5, 5, 0)
+
+RevolutionFuse_1 = model.addRevolutionFuse(Part_1_doc, [], model.selection("EDGE", "[Box_1_1/Front][Box_1_1/Top]"), [model.selection("SOLID", "Box_1_1")])
+
+Sketch_1 = model.addSketch(Part_1_doc, model.selection("FACE", "Translation_1_1/MF:Translated&Cylinder_1_1/Face_2"))
+SketchProjection_1 = Sketch_1.addProjection(model.selection("VERTEX", "[Translation_1_1/MF:Translated&Cylinder_1_1/Face_1][Translation_1_1/MF:Translated&Cylinder_1_1/Face_2]__cc"), False)
+SketchPoint_1 = SketchProjection_1.createdFeature()
+SketchProjection_2 = Sketch_1.addProjection(model.selection("EDGE", "[Translation_1_1/MF:Translated&Cylinder_1_1/Face_1][Translation_1_1/MF:Translated&Cylinder_1_1/Face_2]"), False)
+SketchCircle_1 = SketchProjection_2.createdFeature()
+SketchCircle_2 = Sketch_1.addCircle(5, 5, 2)
+SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchPoint_1.result(), SketchCircle_2.center())
+SketchConstraintTangent_1 = Sketch_1.setTangent(SketchCircle_1.results()[1], SketchCircle_2.results()[1])
+
+RevolutionFuse_1.setNestedSketch(Sketch_1)
+
+model.do()
+
+Shape = RevolutionFuse_1.results()[0].resultSubShapePair()[0].shape()
+checkMiddlePoint(Shape, 7.01705635, 5.0, 7.01705635)
+
+model.end()
+
+assert(model.checkPythonDump())
--- /dev/null
+
+ .. _tui_create_revolution_cut_through_all:
+
+Create Revolution Cut by 360 degrees
+====================================
+
+.. literalinclude:: examples/revolution_cut_through_all.py
+ :linenos:
+ :language: python
+
+:download:`Download this script <examples/revolution_cut_through_all.py>`
+
--- /dev/null
+
+ .. _tui_create_revolution_fuse_through_all:
+
+Create Revolution Fuse by 360 degrees
+=====================================
+
+.. literalinclude:: examples/revolution_fuse_through_all.py
+ :linenos:
+ :language: python
+
+:download:`Download this script <examples/revolution_fuse_through_all.py>`
+
--- /dev/null
+from salome.shaper import model
+
+model.begin()
+partSet = model.moduleDocument()
+Part_1 = model.addPart(partSet)
+Part_1_doc = Part_1.document()
+Box_1 = model.addBox(Part_1_doc, 10, 10, 10)
+Sketch_1 = model.addSketch(Part_1_doc, model.selection("FACE", "Box_1_1/Top"))
+SketchCircle_1 = Sketch_1.addCircle(5, 5, 2.5)
+model.do()
+RevolutionCut_1 = model.addRevolutionCut(Part_1_doc, [model.selection("COMPOUND", "Sketch_1")], model.selection("EDGE", "[Box_1_1/Front][Box_1_1/Top]"), [model.selection("SOLID", "Box_1_1")])
+model.do()
+model.end()
--- /dev/null
+from salome.shaper import model
+
+model.begin()
+partSet = model.moduleDocument()
+Part_1 = model.addPart(partSet)
+Part_1_doc = Part_1.document()
+Box_1 = model.addBox(Part_1_doc, 10, 10, 10)
+Sketch_1 = model.addSketch(Part_1_doc, model.selection("FACE", "Box_1_1/Top"))
+SketchCircle_1 = Sketch_1.addCircle(5, 5, 2.5)
+model.do()
+RevolutionFuse_1 = model.addRevolutionFuse(Part_1_doc, [model.selection("COMPOUND", "Sketch_1")], model.selection("EDGE", "[Box_1_1/Front][Box_1_1/Top]"), [model.selection("SOLID", "Box_1_1")])
+model.do()
+model.end()
.. centered::
Start sketch
-There are two variants of the property panel for Revolution Cut depending on the chosen option:
+There are three variants of the property panel for Revolution Cut depending on the chosen option:
.. image:: images/revolution_by_angles.png
:align: left
:align: left
**By Bounding Planes** revolves objects by specifying bounding planes and angles.
+.. image:: images/revolution_through_all.png
+ :align: left
+**Through All** revolves objects by 360 degrees.
+
By angles
--------
.. centered::
**Revolution Cut created**
-**See Also** a sample TUI Script of :ref:`tui_create_revolution_cut_by_bounding_planes` operation.
\ No newline at end of file
+**See Also** a sample TUI Script of :ref:`tui_create_revolution_cut_by_bounding_planes` operation.
+
+Through all
+--------
+
+.. image:: images/RevolutionCut3.png
+ :align: center
+
+.. centered::
+ Revolution Cut: revolving through all the space
+
+- **Base objects** - contains a list of objects selected in the Object Browser or in the Viewer, which will be revolved.
+- **Axis** - axis of revolution.
+- **Cut from** - contains a list of objects which will but cut with the result of revolution.
+
+**TUI Commands**:
+
+.. py:function:: model.addRevolutionCut(part, objectsToRevolve, axis, objectToCut)
+
+ :param part: The current part object.
+ :param list: A list of objects for revolution.
+ :param object: An axis.
+ :param list: A list of objects to cut from.
+ :return: Created object.
+
+Result
+""""""
+
+The Result of the operation will be a revolved shape:
+
+.. image:: images/revolution_cut_through_all_result.png
+ :align: center
+
+.. centered::
+ **Revolution Cut created**
+
+**See Also** a sample TUI Script of :ref:`tui_create_revolution_cut_through_all` operation.
.. centered::
Start sketch
-There are two variants of the property panel for Revolution Fuse depending on the chosen option:
+There are three variants of the property panel for Revolution Fuse depending on the chosen option:
.. image:: images/revolution_by_angles.png
:align: left
:align: left
**By Bounding Planes** revolves objects by specifying bounding planes and angles.
+.. image:: images/revolution_through_all.png
+ :align: left
+**Through All** revolves objects by 360 degrees.
+
By angles
--------
.. centered::
**Revolution Fuse created**
-**See Also** a sample TUI Script of :ref:`tui_create_revolution_fuse_by_bounding_planes` operation.
\ No newline at end of file
+**See Also** a sample TUI Script of :ref:`tui_create_revolution_fuse_by_bounding_planes` operation.
+
+Through All
+-----------
+
+.. image:: images/RevolutionFuse3.png
+ :align: center
+
+.. centered::
+ Revolution Fuse: definition by bounding planes
+
+- **Base objects** - contains a list of objects selected in the Object Browser or in the Viewer, which will be revolved.
+- **Axis** - axis of revolution.
+- **Fuse with** - contains a list of objects which will be fused with the result of revolution.
+
+**TUI Command**:
+
+.. py:function:: model.addRevolutionFuse(part, objectsToRevolve, axis, objectToFuse)
+
+ :param part: The current part object.
+ :param list: A list of objects for revolution.
+ :param object: An axis.
+ :param list: A list of objects to fuse with.
+ :return: Created object.
+
+Result
+""""""
+
+The Result of the operation will be a revolved shape:
+
+.. image:: images/revolution_fuse_through_all_result.png
+ :align: center
+
+.. centered::
+ **Revolution Fuse created**
+
+**See Also** a sample TUI Script of :ref:`tui_create_revolution_fuse_through_all` operation.
</doublevalue>
</groupbox>
</box>
+ <box id="ThroughAll" title="Through all" icon="icons/Features/revol_throughall_32x32.png">
+ </box>
</toolbox>
</groupbox>
<multi_selector id="main_objects"
</doublevalue>
</groupbox>
</box>
+ <box id="ThroughAll" title="Through all" icon="icons/Features/revol_throughall_32x32.png">
+ </box>
</toolbox>
</groupbox>
<multi_selector id="main_objects"
if(theFeature->string(*anIt)) {
aSelectedMethod = theFeature->string(*anIt)->value();
}
+ if (aSelectedMethod == "ThroughAll") return true;
anIt++;
std::string aCreationMethod = *anIt;
anIt++;