Test20245_2.py
Test20245_3.py
Test20247.py
+ TestLoft.py
)
}
}
}
-/*=================================================================================================
-GeomShapePtr FeaturesPlugin_Loft::getShape(const std::string& anID)
-{
- AttributeSelectionPtr theSelection = selection(anID);
- if (!theSelection.get()) {
- setError("Error: One of the selected base objects is empty.");
- return;
- }
-
- GeomShapePtr aShape = theSelection->value();
-
- if (aShape.get() && !aShape->isNull()) {
- std::cout<<"C'est un shape"<<std::endl;
- return aShape;
- } else {
- // This may be the whole sketch result selected, check and get faces.
- ResultConstructionPtr aConstruction =
- std::dynamic_pointer_cast<ModelAPI_ResultConstruction>(theSelection->context());
- if(!aConstruction.get()) {
- setError("Error: One of selected sketches does not have results.");
- return;
- }
- int aFacesNum = aConstruction->facesNum();
- if(aFacesNum == 0) {
- // Probably it can be construction.
- aShape = aConstruction->shape();
- if(aShape.get() && !aShape->isNull()) {
- std::cout<<"C'est un aConstruction"<<std::endl;
- return aShape;
- }
- } else {
- setError("Error: One of the selected base objects is not vaidated");
- return;
- }
- }
-}
-*/
//=================================================================================================
GeomEdgePtr FeaturesPlugin_Loft::toEdge(const GeomShapePtr& theShape)
return anEdge;
}
-
-/*==================================================================================================
-void FeaturesPlugin_Loft::storeResult(const std::shared_ptr<GeomAPI_Shape> theFirstShape,
- const std::shared_ptr<GeomAPI_Shape> theSecondShape,
- const std::shared_ptr<GeomAlgoAPI_Loft> theLoftAlgo,
- const int theResultIndex)
-{
- // Create result body.
- ResultBodyPtr aResultBody = document()->createBody(data(), theResultIndex);
-
- // Store generated shape.
- aResultBody->storeGenerated(theFirstShape, theLoftAlgo->shape());
- aResultBody->storeGenerated(theSecondShape, theLoftAlgo->shape());
-
- // Store generated edges/faces.
- GeomAPI_Shape::ShapeType aBaseShapeType = theFirstShape->shapeType();
- GeomAPI_Shape::ShapeType aShapeTypeToExplode = GeomAPI_Shape::SHAPE;
-
- switch(aBaseShapeType) {
- case GeomAPI_Shape::VERTEX: {
- aShapeTypeToExplode = GeomAPI_Shape::VERTEX;
- break;
- }
- case GeomAPI_Shape::EDGE:
- case GeomAPI_Shape::WIRE: {
- std::shared_ptr<GeomAPI_Vertex> aV1, aV2;
- GeomAlgoAPI_ShapeTools::findBounds(theFirstShape, aV1, aV2);
- ListOfShape aV1History, aV2History;
- theLoftAlgo->generated(aV1, aV1History);
- theLoftAlgo->generated(aV2, aV2History);
- if(!aV1History.empty()) {
- aResultBody->generated(aV1, aV1History.front());
- }
- if(!aV2History.empty()) {
- aResultBody->generated(aV2, aV2History.front());
- }
- GeomAlgoAPI_ShapeTools::findBounds(theSecondShape, aV1, aV2);
- theLoftAlgo->generated(aV1, aV1History);
- theLoftAlgo->generated(aV2, aV2History);
- if(!aV1History.empty()) {
- aResultBody->generated(aV1, aV1History.front());
- }
- if(!aV2History.empty()) {
- aResultBody->generated(aV2, aV2History.front());
- }
- }
- case GeomAPI_Shape::FACE:
- case GeomAPI_Shape::SHELL: {
- aShapeTypeToExplode = GeomAPI_Shape::EDGE;
- break;
- }
- case GeomAPI_Shape::COMPOUND: {
- aShapeTypeToExplode = GeomAPI_Shape::COMPOUND;
- break;
- }
- default:
- return; // unsupported type of shape
- }
-
- if(aShapeTypeToExplode == GeomAPI_Shape::VERTEX ||
- aShapeTypeToExplode == GeomAPI_Shape::COMPOUND) {
- aResultBody->loadGeneratedShapes(theLoftAlgo, theFirstShape, GeomAPI_Shape::VERTEX);
- aResultBody->loadGeneratedShapes(theLoftAlgo, theSecondShape, GeomAPI_Shape::VERTEX);
- }
- if(aShapeTypeToExplode == GeomAPI_Shape::EDGE ||
- aShapeTypeToExplode == GeomAPI_Shape::COMPOUND) {
- aResultBody->loadGeneratedShapes(theLoftAlgo, theFirstShape, GeomAPI_Shape::EDGE);
- aResultBody->loadGeneratedShapes(theLoftAlgo, theSecondShape, GeomAPI_Shape::EDGE);
- }
-
- // Store from shapes.
- storeShapes(aResultBody, aBaseShapeType, theLoftAlgo->fromShapes(), "From_");
-
- // Store to shapes.
- storeShapes(aResultBody, aBaseShapeType, theLoftAlgo->toShapes(), "To_");
-
- setResult(aResultBody, theResultIndex);
-}
-
-//==================================================================================================
-void FeaturesPlugin_Loft::storeShapes(ResultBodyPtr theResultBody,
- const GeomAPI_Shape::ShapeType theBaseShapeType,
- const ListOfShape& theShapes,
- const std::string theName)
-{
- GeomAPI_Shape::ShapeType aShapeTypeToExplore = GeomAPI_Shape::FACE;
- std::string aShapeTypeStr = "Face";
- switch(theBaseShapeType) {
- case GeomAPI_Shape::VERTEX: {
- aShapeTypeToExplore = GeomAPI_Shape::VERTEX;
- aShapeTypeStr = "Vertex";
- break;
- }
- case GeomAPI_Shape::EDGE:
- case GeomAPI_Shape::WIRE: {
- aShapeTypeToExplore = GeomAPI_Shape::EDGE;
- aShapeTypeStr = "Edge";
- break;
- }
- case GeomAPI_Shape::FACE:
- case GeomAPI_Shape::SHELL: {
- aShapeTypeToExplore = GeomAPI_Shape::FACE;
- aShapeTypeStr = "Face";
- break;
- }
- case GeomAPI_Shape::COMPOUND: {
- aShapeTypeToExplore = GeomAPI_Shape::COMPOUND;
- break;
- }
- default:
- return; // unsupported type of shape
- }
-
- // Store shapes.
- int aShapeIndex = 1;
- int aFaceIndex = 1;
- for(ListOfShape::const_iterator anIt = theShapes.cbegin(); anIt != theShapes.cend(); ++anIt) {
- GeomShapePtr aShape = *anIt;
-
- if(aShapeTypeToExplore == GeomAPI_Shape::COMPOUND) {
- std::string aName = theName + (aShape->shapeType() == GeomAPI_Shape::EDGE ? "Edge" : "Face");
- storeSubShapeTT(theResultBody, aShape,
- aShape->shapeType(),
- aName,
- aShape->shapeType() == GeomAPI_Shape::EDGE ? aShapeIndex : aFaceIndex);
- } else {
- std::string aName = theName + aShapeTypeStr;
- storeSubShapeTT(theResultBody, aShape, aShapeTypeToExplore, aName, aShapeIndex);
- }
- }
-}
-
-//==================================================================================================
-void storeSubShapeTT(ResultBodyPtr theResultBody,
- const GeomShapePtr theShape,
- const GeomAPI_Shape::ShapeType theType,
- const std::string theName,
- int& theShapeIndex)
-{
- for(GeomAPI_ShapeExplorer anExp(theShape, theType); anExp.more(); anExp.next()) {
- GeomShapePtr aSubShape = anExp.current();
- std::ostringstream aStr;
- aStr << theName << "_" << theShapeIndex++;
- theResultBody->generated(aSubShape, aStr.str());
- }
-}
-*/
\ No newline at end of file
<source>Pipe</source>
<translation>Tuyau</translation>
</message>
+ <message>
+ <source>Loft</source>
+ <translation>Lissage</translation>
+ </message>
<message>
<source>Recover</source>
<translation>Récupérer</translation>
</message>
</context>
+ <!-- Loft -->
+ <context>
+ <name>Loft</name>
+ <message>
+ <source>Loft</source>
+ <translation>Lissage</translation>
+ </message>
+ </context>
+ <context>
+ <name>Loft:first_object</name>
+ <message>
+ <source>First object:</source>
+ <translation>Premier objet:</translation>
+ </message>
+ </context>
+ <context>
+ <name>Loft:second_object</name>
+ <message>
+ <source>Second object:</source>
+ <translation>Deuxième objet:</translation>
+ </message>
+ </context>
<!-- Recover -->
<context>
<name>Recover</name>
--- /dev/null
+# Copyright (C) 2018-2020 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
+
+model.begin()
+partSet = model.moduleDocument()
+
+### Create Part
+Part_1 = model.addPart(partSet)
+Part_1_doc = Part_1.document()
+
+### Create Sketch
+Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOY"))
+
+### Create SketchLine
+SketchLine_1 = Sketch_1.addLine(65.56914119359536, 34.84279475982533, -62.33478893740904, 34.84279475982533)
+
+### Create SketchLine
+SketchLine_2 = Sketch_1.addLine(-62.33478893740904, 34.84279475982533, -62.33478893740904, -28.08005822416302)
+
+### Create SketchLine
+SketchLine_3 = Sketch_1.addLine(-62.33478893740904, -28.08005822416302, 65.56914119359536, -28.08005822416302)
+
+### Create SketchLine
+SketchLine_4 = Sketch_1.addLine(65.56914119359536, -28.08005822416302, 65.56914119359536, 34.84279475982533)
+Sketch_1.setCoincident(SketchLine_4.endPoint(), SketchLine_1.startPoint())
+Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchLine_2.startPoint())
+Sketch_1.setCoincident(SketchLine_2.endPoint(), SketchLine_3.startPoint())
+Sketch_1.setCoincident(SketchLine_3.endPoint(), SketchLine_4.startPoint())
+Sketch_1.setHorizontal(SketchLine_1.result())
+Sketch_1.setVertical(SketchLine_2.result())
+Sketch_1.setHorizontal(SketchLine_3.result())
+Sketch_1.setVertical(SketchLine_4.result())
+model.do()
+
+### Create Plane
+Plane_4 = model.addPlane(Part_1_doc, model.selection("EDGE", "Sketch_1/SketchLine_4"), model.selection("VERTEX", "Sketch_1/SketchLine_3_StartVertex"), False)
+
+### Create Plane
+Plane_5 = model.addPlane(Part_1_doc, model.selection("FACE", "Sketch_1/Face-SketchLine_1r-SketchLine_2f-SketchLine_3f-SketchLine_4f"), 100, False)
+
+### Create Sketch
+Sketch_2 = model.addSketch(Part_1_doc, model.defaultPlane("YOZ"))
+
+### Create SketchCircle
+SketchCircle_1 = Sketch_2.addCircle(60.9581866489876, 39.76685108527785, 26.86156014153439)
+model.do()
+
+### Create Plane
+Plane_6 = model.addPlane(Part_1_doc, model.selection("FACE", "Sketch_2/Face-SketchCircle_1_2r"), 100, False)
+
+### Create Box
+Box_1 = model.addBox(Part_1_doc, 10, 10, 10)
+
+### Create Box
+Box_2 = model.addBox(Part_1_doc, 10, 10, 10)
+
+### Create Translation
+Translation_1 = model.addTranslation(Part_1_doc, [model.selection("COMPOUND", "all-in-Box_2")], axis = model.selection("EDGE", "PartSet/OY"), distance = 100, keepSubResults = True)
+
+### Create Wire
+Wire_1_objects = [model.selection("EDGE", "[Box_1_1/Front][Box_1_1/Right]"),
+ model.selection("EDGE", "[Box_1_1/Right][Box_1_1/Top]"),
+ model.selection("EDGE", "[Box_1_1/Back][Box_1_1/Right]"),
+ model.selection("EDGE", "[Box_1_1/Right][Box_1_1/Bottom]")]
+Wire_1 = model.addWire(Part_1_doc, Wire_1_objects, False)
+
+### Create Wire
+Wire_2_objects = [model.selection("EDGE", "[Translation_1_1_1/MF:Translated&Box_2_1/Left][Translation_1_1_1/MF:Translated&Box_2_1/Top]"),
+ model.selection("EDGE", "[Translation_1_1_1/MF:Translated&Box_2_1/Front][Translation_1_1_1/MF:Translated&Box_2_1/Left]"),
+ model.selection("EDGE", "[Translation_1_1_1/MF:Translated&Box_2_1/Left][Translation_1_1_1/MF:Translated&Box_2_1/Bottom]"),
+ model.selection("EDGE", "[Translation_1_1_1/MF:Translated&Box_2_1/Back][Translation_1_1_1/MF:Translated&Box_2_1/Left]")]
+Wire_2 = model.addWire(Part_1_doc, Wire_2_objects, False)
+
+### Create Box
+Box_3 = model.addBox(Part_1_doc, 10, 10, 10)
+
+### Create Wire
+Wire_3 = model.addWire(Part_1_doc, [model.selection("EDGE", "[Box_3_1/Left][Box_3_1/Top]"), model.selection("EDGE", "[Box_3_1/Front][Box_3_1/Left]")], False)
+
+### Create Box
+Box_4 = model.addBox(Part_1_doc, 10, 10, 10)
+
+### Create Translation
+Translation_2 = model.addTranslation(Part_1_doc, [model.selection("COMPOUND", "all-in-Box_4")], axis = model.selection("EDGE", "PartSet/OY"), distance = 40, keepSubResults = True)
+
+### Create Wire
+Wire_4 = model.addWire(Part_1_doc, [model.selection("EDGE", "[Translation_2_1_1/MF:Translated&Box_4_1/Left][Translation_2_1_1/MF:Translated&Box_4_1/Top]"), model.selection("EDGE", "[Translation_2_1_1/MF:Translated&Box_4_1/Front][Translation_2_1_1/MF:Translated&Box_4_1/Left]")], False)
+
+### Create Loft
+Loft_1 = model.addLoft(Part_1_doc, model.selection("FACE", "Plane_2"), model.selection("FACE", "Plane_1"))
+
+### Create Loft
+Loft_2 = model.addLoft(Part_1_doc, model.selection("WIRE", "Wire_2_1"), model.selection("WIRE", "Wire_1_1"))
+
+### Create Loft
+Loft_3 = model.addLoft(Part_1_doc, model.selection("WIRE", "Wire_3_1"), model.selection("WIRE", "Wire_4_1"))
+
+### Create Loft
+Loft_4 = model.addLoft(Part_1_doc, model.selection("EDGE", "Sketch_1/SketchLine_2"), model.selection("EDGE", "Sketch_1/SketchLine_4"))
+
+model.end()
+
+from GeomAPI import GeomAPI_Shape
+
+#test loft with two face
+model.testNbResults(Loft_1, 1)
+model.testNbSubResults(Loft_1, [0])
+model.testNbSubShapes(Loft_1, GeomAPI_Shape.SOLID, [1])
+
+
+#test loft with two wire
+model.testNbResults(Loft_2, 1)
+model.testNbSubResults(Loft_2, [0])
+model.testNbSubShapes(Loft_2, GeomAPI_Shape.SHELL, [1])
+
+#test loft with two wire
+model.testNbResults(Loft_3, 1)
+model.testNbSubResults(Loft_3, [0])
+model.testNbSubShapes(Loft_3, GeomAPI_Shape.SHELL, [1])
+
+#test loft with two edge
+model.testNbResults(Loft_4, 1)
+model.testNbSubResults(Loft_4, [0])
+model.testNbSubShapes(Loft_4, GeomAPI_Shape.FACE, [1])
+
fuseFeatureFaces.rst
importResultFeature.rst
linearCopyFeature.rst
+ loftFeature.rst
measurementFeature.rst
pipeFeature.rst
placementFeature.rst
--- /dev/null
+
+ .. _tui_loft:
+
+loft
+====
+
+.. literalinclude:: examples/loft.py
+ :linenos:
+ :language: python
+
+:download:`Download this script <examples/loft.py>`
--- /dev/null
+from SketchAPI import *
+
+from salome.shaper import model
+
+model.begin()
+partSet = model.moduleDocument()
+
+### Create Part
+Part_1 = model.addPart(partSet)
+Part_1_doc = Part_1.document()
+
+### Create Sketch
+Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOY"))
+
+### Create SketchLine
+SketchLine_1 = Sketch_1.addLine(65.56914119359536, 34.84279475982533, -62.33478893740904, 34.84279475982533)
+
+### Create SketchLine
+SketchLine_2 = Sketch_1.addLine(-62.33478893740904, 34.84279475982533, -62.33478893740904, -28.08005822416302)
+
+### Create SketchLine
+SketchLine_3 = Sketch_1.addLine(-62.33478893740904, -28.08005822416302, 65.56914119359536, -28.08005822416302)
+
+### Create SketchLine
+SketchLine_4 = Sketch_1.addLine(65.56914119359536, -28.08005822416302, 65.56914119359536, 34.84279475982533)
+Sketch_1.setCoincident(SketchLine_4.endPoint(), SketchLine_1.startPoint())
+Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchLine_2.startPoint())
+Sketch_1.setCoincident(SketchLine_2.endPoint(), SketchLine_3.startPoint())
+Sketch_1.setCoincident(SketchLine_3.endPoint(), SketchLine_4.startPoint())
+Sketch_1.setHorizontal(SketchLine_1.result())
+Sketch_1.setVertical(SketchLine_2.result())
+Sketch_1.setHorizontal(SketchLine_3.result())
+Sketch_1.setVertical(SketchLine_4.result())
+model.do()
+
+### Create Plane
+Plane_1 = model.addPlane(Part_1_doc, model.selection("EDGE", "Sketch_1/SketchLine_4"), model.selection("VERTEX", "Sketch_1/SketchLine_3_StartVertex"), False)
+
+### Create Plane
+Plane_2 = model.addPlane(Part_1_doc, model.selection("FACE", "Sketch_1/Face-SketchLine_1r-SketchLine_2f-SketchLine_3f-SketchLine_4f"), 100, False)
+
+### Create Loft
+Loft_1 = model.addLoft(Part_1_doc, model.selection("FACE", "Plane_1"), model.selection("FACE", "Plane_2"))
+
+model.end()
--- /dev/null
+.. |loft.icon| image:: images/loft.png
+
+Loft
+====
+
+**Loft** feature is used to create a face, shell or a solid shape from two or more objects.
+The two objects can be edges, wires or faces.
+
+To create a Loft in the active part:
+
+#. select in the Main Menu *Features - > Loft* item or
+#. click |loft.icon| **Loft** button in the toolbar
+
+The following property panel appears.
+
+.. figure:: images/loftPropertyPanel.png
+ :align: center
+
+ Loft property panel
+
+Input fields:
+
+- **First object** defines the first shape (edge, wire, face) selected in 3D OCC viewer or object browser;
+- **Second object** defines the second shape (edge, wire, face) selected in 3D OCC viewer or object browser;
+
+**TUI Command**:
+
+.. py:function:: model.addLoft(Part_doc, [shape], [shape])
+
+ :param part: The current part object.
+ :param object: A shape in format *model.selection(TYPE, shape)*.
+ :param object: A shape in format *model.selection(TYPE, shape)*.
+ :return: Created object.
+
+Result
+""""""
+
+Result of loft between two faces.
+
+.. figure:: images/resultLoft.png
+ :align: center
+
+ Loft between two faces
+
+**See Also** a sample TUI Script of :ref:`tui_loft` operation.
\ No newline at end of file
label="First object:"
tooltip="Select a object"
shape_types="edge face wire"
+ concealment="true"
default="">
<validator id="GeomValidators_ShapeType" parameters="line,edge,wire,face,shell"/>
</shape_selector>
label="Second object:"
tooltip="Select a object"
shape_types="edge face wire"
+ concealment="true"
default="">
<validator id="GeomValidators_ShapeType" parameters="line,edge,wire,face,shell"/>
</shape_selector>
<source path="pipe_widget.xml"/>
</feature>
<feature id="Loft" title="Loft" tooltip="Generates a shape xwith two elements"
- icon="icons/Features/loft.png" helpfile="pipeFeature.html">
+ icon="icons/Features/loft.png" helpfile="loftFeature.html">
<source path="loft_widget.xml"/>
</feature>
</group>