return true;
}
-
-//---------------------------------------------------------
-// #define USE_DEBUG
-// #define DEBUG
-// static const char *dbg_class = "FeaturesPlugin_ValidatorSewingSelection";
-// #include "MBDebug.h"
-// #include "MBModel.h"
-// #include "MBGeom.h"
-//---------------------------------------------------------
-
//==================================================================================================
bool FeaturesPlugin_ValidatorSewingSelection::isValid(const AttributePtr& theAttribute,
const std::list<std::string>& theArguments,
Events_InfoMessage& theError) const
{
- // DBG_FUN();
- // ARG(theAttribute);
-
AttributeSelectionListPtr anAttrSelectionList =
std::dynamic_pointer_cast<ModelAPI_AttributeSelectionList>(theAttribute);
if (!anAttrSelectionList.get()) {
}
- // MSGEL("...selection is VALID.");
return true;
}
<translation>Le résultat est vide</translation>
</message>
</context>
- <context>
- <name></name>
- <message>
- </message>
- </context>
</TS>
--- /dev/null
+# 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
+# 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
+from GeomAPI import GeomAPI_Shape
+
+aShapeTypes = {
+ GeomAPI_Shape.SOLID: "GeomAPI_Shape.SOLID",
+ GeomAPI_Shape.FACE: "GeomAPI_Shape.FACE",
+ GeomAPI_Shape.EDGE: "GeomAPI_Shape.EDGE",
+ GeomAPI_Shape.VERTEX: "GeomAPI_Shape.VERTEX"}
+
+def testNbUniqueSubShapes(theFeature, theShapeType, theExpectedNbSubShapes):
+ """ Tests number of unique feature sub-shapes of passed type for each result.
+ :param theFeature: feature to test.
+ :param theShapeType: shape type of sub-shapes to test.
+ :param theExpectedNbSubShapes: list of sub-shapes numbers. Size of list should be equal to len(theFeature.results()).
+ """
+ aResults = theFeature.feature().results()
+ aNbResults = len(aResults)
+ aListSize = len(theExpectedNbSubShapes)
+ assert (aNbResults == aListSize), "Number of results: {} not equal to list size: {}.".format(aNbResults, aListSize)
+ for anIndex in range(0, aNbResults):
+ aNbResultSubShapes = 0
+ anExpectedNbSubShapes = theExpectedNbSubShapes[anIndex]
+ aNbResultSubShapes = aResults[anIndex].shape().subShapes(theShapeType, True).size()
+ assert (aNbResultSubShapes == anExpectedNbSubShapes), "Number of sub-shapes of type {} for result[{}]: {}. Expected: {}.".format(aShapeTypes[theShapeType], anIndex, aNbResultSubShapes, anExpectedNbSubShapes)
+
+def testResults(theFeature,theModel,NbRes,NbSubRes,NbShell,NbFace,NbEdge,NbVertex):
+ """ Tests numbers of unique sub-shapes in the results
+ """
+ aResults = theFeature.feature().results()
+ aNbResults = len(aResults)
+ assert (aNbResults == NbRes), "Number of results: {} not equal to {}}.".format(aNbResults, NbRes)
+ theModel.testNbSubResults(theFeature, NbSubRes)
+ testNbUniqueSubShapes(theFeature, GeomAPI_Shape.SHELL, NbShell)
+ testNbUniqueSubShapes(theFeature, GeomAPI_Shape.FACE, NbFace)
+ testNbUniqueSubShapes(theFeature, GeomAPI_Shape.EDGE, NbEdge)
+ testNbUniqueSubShapes(theFeature, GeomAPI_Shape.VERTEX, NbVertex)
+
+# Create document
+model.begin()
+partSet = model.moduleDocument()
+Part_1 = model.addPart(partSet)
+Part_1_doc = Part_1.document()
+Param_dx = model.addParameter(Part_1_doc, "dx", '10')
+Param_alfa = model.addParameter(Part_1_doc, "alfa", '90')
+
+# =============================================================================
+# Test 1. Sew two shells with a single common edge
+# =============================================================================
+Box_1 = model.addBox(Part_1_doc, 10, 10, 10)
+Box_2 = model.addBox(Part_1_doc, 10, 10, 10)
+Translation_1 = model.addTranslation(Part_1_doc, [model.selection("SOLID", "Box_2_1")], axis = model.selection("EDGE", "PartSet/OX"), distance = "dx", keepSubResults = True)
+Rotation_1 = model.addRotation(Part_1_doc, [model.selection("SOLID", "Translation_1_1")], axis = model.selection("EDGE", "[Box_1_1/Front][Box_1_1/Right]"), angle = "alfa", keepSubResults = True)
+
+Shell_1_objects = [model.selection("FACE", "Box_1_1/Top"),
+ model.selection("FACE", "Box_1_1/Left"),
+ model.selection("FACE", "Box_1_1/Right"),
+ model.selection("FACE", "Box_1_1/Back"),
+ model.selection("FACE", "Box_1_1/Bottom")]
+Shell_1 = model.addShell(Part_1_doc, Shell_1_objects)
+
+Shell_2_objects = [model.selection("FACE", "Rotation_1_1/MF:Rotated&Box_2_1/Top"),
+ model.selection("FACE", "Rotation_1_1/MF:Rotated&Box_2_1/Left"),
+ model.selection("FACE", "Rotation_1_1/MF:Rotated&Box_2_1/Front"),
+ model.selection("FACE", "Rotation_1_1/MF:Rotated&Box_2_1/Right"),
+ model.selection("FACE", "Rotation_1_1/MF:Rotated&Box_2_1/Bottom")]
+Shell_2 = model.addShell(Part_1_doc, Shell_2_objects)
+model.do()
+
+Sewing_1 = model.addSewing(Part_1_doc, [model.selection("SHELL", "Shell_2_1"), model.selection("SHELL", "Shell_1_1")], 1e-07, allowNonManifold = False, alwaysCreateResult = True)
+model.end()
+
+# sewing successful
+testResults(Sewing_1, model, 1, [0], [1], [10], [23], [14])
+
+# =============================================================================
+# Test 2. Sew two shells with four common edges
+# =============================================================================
+model.undo()
+model.begin()
+Param_alfa.setValue(0)
+model.do()
+
+Sewing_2 = model.addSewing(Part_1_doc, [model.selection("SHELL", "Shell_2_1"), model.selection("SHELL", "Shell_1_1")], 1e-07, allowNonManifold = False, alwaysCreateResult = True)
+model.end()
+
+# sewing successful
+testResults(Sewing_2, model, 1, [0], [1], [10], [20], [12])
+
+# =============================================================================
+# Test 3. Sew two slightly disconnected shells
+# =============================================================================
+model.undo()
+model.begin()
+Param_dx.setValue(10.0001)
+model.do()
+
+Sewing_3 = model.addSewing(Part_1_doc, [model.selection("SHELL", "Shell_2_1"), model.selection("SHELL", "Shell_1_1")], 1e-07, allowNonManifold = False, alwaysCreateResult = True)
+model.end()
+
+# no sewing done (result is a compound with the two input shells)
+testResults(Sewing_3, model, 1, [2], [2], [10], [24], [16])
+
+# =============================================================================
+# Test 4. Sew two slightly disconnected shells with larger tolerance
+# =============================================================================
+model.undo()
+model.begin()
+Param_dx.setValue(10.0001)
+model.do()
+
+Sewing_4 = model.addSewing(Part_1_doc, [model.selection("SHELL", "Shell_2_1"), model.selection("SHELL", "Shell_1_1")], 1e-04, allowNonManifold = False, alwaysCreateResult = True)
+model.end()
+
+# sewing successful
+testResults(Sewing_4, model, 1, [0], [1], [10], [20], [12])
--- /dev/null
+# 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
+# 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
+from GeomAPI import GeomAPI_Shape
+
+aShapeTypes = {
+ GeomAPI_Shape.SOLID: "GeomAPI_Shape.SOLID",
+ GeomAPI_Shape.FACE: "GeomAPI_Shape.FACE",
+ GeomAPI_Shape.EDGE: "GeomAPI_Shape.EDGE",
+ GeomAPI_Shape.VERTEX: "GeomAPI_Shape.VERTEX"}
+
+def testNbUniqueSubShapes(theFeature, theShapeType, theExpectedNbSubShapes):
+ """ Tests number of unique feature sub-shapes of passed type for each result.
+ :param theFeature: feature to test.
+ :param theShapeType: shape type of sub-shapes to test.
+ :param theExpectedNbSubShapes: list of sub-shapes numbers. Size of list should be equal to len(theFeature.results()).
+ """
+ aResults = theFeature.feature().results()
+ aNbResults = len(aResults)
+ aListSize = len(theExpectedNbSubShapes)
+ assert (aNbResults == aListSize), "Number of results: {} not equal to list size: {}.".format(aNbResults, aListSize)
+ for anIndex in range(0, aNbResults):
+ aNbResultSubShapes = 0
+ anExpectedNbSubShapes = theExpectedNbSubShapes[anIndex]
+ aNbResultSubShapes = aResults[anIndex].shape().subShapes(theShapeType, True).size()
+ assert (aNbResultSubShapes == anExpectedNbSubShapes), "Number of sub-shapes of type {} for result[{}]: {}. Expected: {}.".format(aShapeTypes[theShapeType], anIndex, aNbResultSubShapes, anExpectedNbSubShapes)
+
+def testResults(theFeature,theModel,NbRes,NbSubRes,NbShell,NbFace,NbEdge,NbVertex):
+ """ Tests numbers of unique sub-shapes in the results
+ """
+ aResults = theFeature.feature().results()
+ aNbResults = len(aResults)
+ assert (aNbResults == NbRes), "Number of results: {} not equal to {}}.".format(aNbResults, NbRes)
+ theModel.testNbSubResults(theFeature, NbSubRes)
+ testNbUniqueSubShapes(theFeature, GeomAPI_Shape.SHELL, NbShell)
+ testNbUniqueSubShapes(theFeature, GeomAPI_Shape.FACE, NbFace)
+ testNbUniqueSubShapes(theFeature, GeomAPI_Shape.EDGE, NbEdge)
+ testNbUniqueSubShapes(theFeature, GeomAPI_Shape.VERTEX, NbVertex)
+
+# Create document
+model.begin()
+partSet = model.moduleDocument()
+Part_1 = model.addPart(partSet)
+Part_1_doc = Part_1.document()
+Param_dx = model.addParameter(Part_1_doc, "dx", '10')
+Param_alfa = model.addParameter(Part_1_doc, "alfa", '90')
+
+# =============================================================================
+# Test 1. Sew two shells with a single common edge
+# =============================================================================
+Box_1 = model.addBox(Part_1_doc, 10, 10, 10)
+Box_2 = model.addBox(Part_1_doc, 10, 10, 10)
+Vertex_1 = model.selection("VERTEX", "[Box_1_1/Back][Box_1_1/Left][Box_1_1/Bottom]")
+Vertex_2 = model.selection("VERTEX", "[Box_1_1/Front][Box_1_1/Left][Box_1_1/Top]")
+Translation_1 = model.addTranslation(Part_1_doc, [model.selection("SOLID", "Box_2_1")], startPoint = Vertex_1, endPoint = Vertex_2, keepSubResults = True)
+
+Shell_1_objects = [model.selection("FACE", "Box_1_1/Top"), model.selection("FACE", "Box_1_1/Front")]
+Shell_1 = model.addShell(Part_1_doc, Shell_1_objects)
+
+Shell_2_objects = [model.selection("FACE", "Translation_1_1/MF:Translated&Box_2_1/Back"), model.selection("FACE", "Translation_1_1/MF:Translated&Box_2_1/Bottom")]
+Shell_2 = model.addShell(Part_1_doc, Shell_2_objects)
+model.do()
+
+Sewing_1 = model.addSewing(Part_1_doc, [model.selection("SHELL", "Shell_2_1"), model.selection("SHELL", "Shell_1_1")], 1e-07, allowNonManifold = False, alwaysCreateResult = True)
+model.end()
+
+# sewing failed (result is a compound with the two input shells)
+testResults(Sewing_1, model, 1, [2], [2], [4], [14], [12])
+
+# =============================================================================
+# Test 2. Sew the same two shells allowing non-manifold results
+# =============================================================================
+model.undo()
+model.begin()
+
+Sewing_2 = model.addSewing(Part_1_doc, [model.selection("SHELL", "Shell_2_1"), model.selection("SHELL", "Shell_1_1")], 1e-07, allowNonManifold = True, alwaysCreateResult = True)
+model.end()
+
+# sewing successful
+testResults(Sewing_2, model, 1, [0], [1], [4], [13], [10])
revolutionFeature.rst
revolutionFuseFeature.rst
rotationFeature.rst
+ sewingFeature.rst
symmetryFeature.rst
transformationFeature.rst
translationFeature.rst
--- /dev/null
+
+ .. _tui_create_sewing:
+
+Create Sewing
+=============
+
+.. literalinclude:: examples/sewing.py
+ :linenos:
+ :language: python
+
+:download:`Download this script <examples/sewing.py>`
+
--- /dev/null
+from salome.shaper import model
+
+model.begin()
+partSet = model.moduleDocument()
+Part_1 = model.addPart(partSet)
+Part_1_doc = Part_1.document()
+model.addParameter(Part_1_doc, "dx", '10')
+model.addParameter(Part_1_doc, "alfa", '90')
+
+Box_1 = model.addBox(Part_1_doc, 10, 10, 10)
+Box_2 = model.addBox(Part_1_doc, 10, 10, 10)
+Translation_1 = model.addTranslation(Part_1_doc, [model.selection("SOLID", "Box_2_1")], axis = model.selection("EDGE", "PartSet/OX"), distance = "dx", keepSubResults = True)
+Rotation_1 = model.addRotation(Part_1_doc, [model.selection("SOLID", "Translation_1_1")], axis = model.selection("EDGE", "[Box_1_1/Front][Box_1_1/Right]"), angle = "alfa", keepSubResults = True)
+
+Shell_1_objects = [model.selection("FACE", "Box_1_1/Top"),
+ model.selection("FACE", "Box_1_1/Left"),
+ model.selection("FACE", "Box_1_1/Right"),
+ model.selection("FACE", "Box_1_1/Back"),
+ model.selection("FACE", "Box_1_1/Bottom")]
+Shell_1 = model.addShell(Part_1_doc, Shell_1_objects)
+
+Shell_2_objects = [model.selection("FACE", "Rotation_1_1/MF:Rotated&Box_2_1/Top"),
+ model.selection("FACE", "Rotation_1_1/MF:Rotated&Box_2_1/Left"),
+ model.selection("FACE", "Rotation_1_1/MF:Rotated&Box_2_1/Front"),
+ model.selection("FACE", "Rotation_1_1/MF:Rotated&Box_2_1/Right"),
+ model.selection("FACE", "Rotation_1_1/MF:Rotated&Box_2_1/Bottom")]
+Shell_2 = model.addShell(Part_1_doc, Shell_2_objects)
+
+Sewing_1 = model.addSewing(Part_1_doc, [model.selection("SHELL", "Shell_2_1"), model.selection("SHELL", "Shell_1_1")], 1e-07, allowNonManifold = False, alwaysCreateResult = True)
+
+model.end()
--- /dev/null
+.. |sewing_btn.icon| image:: images/sewing_btn.png
+
+.. _featureSewing:
+
+Sewing
+======
+
+Sewing feature unites several faces (possibly contained in a shell, solid or compound)
+into one shell. Geometrically coincident (within a specified tolerance) edges (or parts
+of edges) of different faces are replaced by one edge thus producing a shell or faces
+with shared boundaries.
+
+To perform the Sewing in the active part:
+
+#. select in the Main Menu *Features - > Sewing* item or
+#. click |sewing_btn.icon| **Sewing** button in the toolbar
+
+The following property panel will be opened:
+
+.. figure:: images/Sewing.png
+ :align: center
+
+ **Sewing feature**
+
+Input fields:
+
+- **Objects** contains a list of objects selected in the Object Browser or in the Viewer, which will be sewn.
+- **Tolerance** defines the tolerance to use for the Sewing operation.
+- **Allow Non-Manifold** allows to create non-manifold shapes, if checked.
+- **Always create a result** allows to always create a result shape, even if there was nothing sewn.
+
+**TUI Command**:
+
+.. py:function:: model.addSewing(Part_doc, objects, tolerance, allowNonManifold, createResult)
+
+ :param part: The current part object.
+ :param list: A list of objects.
+ :param real: The tolerance value to be used for the sewing.
+ :param boolean: Defines whether to allow non-manifold results.
+ :param boolean: Defines whether to always create a result.
+ :return: Created object.
+
+Result
+""""""
+
+The Result of the operation will be a shape with all coincident edges being united:
+
+
+**See Also** a sample TUI Script of :ref:`tui_create_sewing` operation.
<groupbox>
<doublevalue id="tolerance"
label="Tolerance"
- min="1.0e-8"
- max="1"
+ min="1.0e-7"
+ step="1.0e-7"
default="1.0e-7"
tooltip="Tolerance"/>
- <!-- validator id="GeomValidators_Positive"/ -->
</groupbox>
<boolvalue id="allow_non_manifold" label="Allow Non-Manifold" default="false" tooltip="Allow the creation of non-manifold results"/>
<boolvalue id="always_create_result" label="Always create a result" default="true" tooltip="Always create a result, even if nothing is sewn"/>
Test23885.py
TestNormalToFace.py
TestLoft.py
+ TestSewing_Manifold.py
+ TestSewing_NonManifold.py
)
SET(TEST_NAMES_SEQ
class GeomAlgoAPI_Sewing : public GeomAlgoAPI_MakeShape
{
public:
- /// Constructor.
+ /// Constructor (used by MakeShell).
+ /// \param[in] theShapes list of selected shapes.
GEOMALGOAPI_EXPORT GeomAlgoAPI_Sewing(const ListOfShape& theShapes);
- /// Constructor with additional arguments
+ /// Constructor with additional arguments (used by Sewing feature)
+ /// \param[in] theShapes list of selected shapes.
+ /// \param[in] theAllowNonManifold if True, non-manifold results are allowed.
+ /// \param[in] theTolerance tolerance value used for the sewing operation.
GEOMALGOAPI_EXPORT GeomAlgoAPI_Sewing(const ListOfShape& theShapes, const bool theAllowNonManifold, const double theTolerance);
/// \return the list of shapes modified from the shape \a theShape.
ListOfShape& theHistory);
protected:
- bool myBuildShell;
+ bool myBuildShell; // whether algorithm is used by MakeShell or by Sewing
private:
/// Builds resulting shape.