# -*- coding: utf-8 -*-
+from GeomAPI import *
from SketchAPI import *
from salome.shaper import model
model.addParameter(Part_1_doc, "haut_ext_tuyau", "5")
model.addParameter(Part_1_doc, "haut_int_tuyau", "14")
Param_Diam = model.addParameter(Part_1_doc, "diam_tuyau", "10")
-
Revolution_1 = model.addRevolution(Part_1_doc, [], model.selection("EDGE", "PartSet/OZ"), 90, 0)
Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOZ"))
SketchProjection_1 = Sketch_1.addProjection(model.selection("VERTEX", "PartSet/Origin"), False)
Extrusion_1.setNestedSketch(Sketch_2)
Fill_1 = model.addFill(Part_1_doc, [model.selection("SOLID", "Revolution_1_1")], [model.selection("SOLID", "Extrusion_1_1")])
Point_2 = model.addPoint(Part_1_doc, "x", "y", "-z")
-Axis_4 = model.addAxis(Part_1_doc, model.selection("VERTEX", "Point_1"), model.selection("VERTEX", "[Fill_1_1_2/Modified_Face&Sketch_2/SketchLine_4&Revolution_1_1/From_Face][Fill_1_1_2/Modified_Face&Extrusion_1_1/To_Face&Sketch_1/SketchLine_3][Fill_1_1_2/Modified_Face&Sketch_2/SketchLine_5&Revolution_1_1/To_Face]"))
+Axis_4 = model.addAxis(Part_1_doc, model.selection("VERTEX", "Point_1"), model.selection("VERTEX", "[Fill_1_1_2/Modified_Face&Sketch_2/SketchLine_5&Revolution_1_1/To_Face][Fill_1_1_2/Modified_Face&Sketch_2/SketchLine_4&Revolution_1_1/From_Face][Fill_1_1_2/Modified_Face&Extrusion_1_1/To_Face&Sketch_1/SketchLine_3]"))
Plane_4 = model.addPlane(Part_1_doc, model.selection("EDGE", "Axis_1"), model.selection("VERTEX", "Point_1"), True)
Plane_5 = model.addPlane(Part_1_doc, model.selection("FACE", "Plane_1"), "haut_ext_tuyau", True)
Plane_5.result().setName("Plane_2 arrivee tuyau")
-Plane_6 = model.addPlane(Part_1_doc, model.selection("FACE", "Extrusion_1_1/Generated_Face&Sketch_2/SketchLine_6"), model.selection("EDGE", "[Extrusion_1_1/From_Face][Extrusion_1_1/Generated_Face&Sketch_2/SketchLine_6]"), 45)
+Plane_6 = model.addPlane(Part_1_doc, model.selection("FACE", "Extrusion_1_1/Generated_Face&Sketch_2/SketchLine_6"), model.selection("EDGE", "[Extrusion_1_1/Generated_Face&Sketch_2/SketchLine_6][Extrusion_1_1/From_Face]"), 45)
Plane_7 = model.addPlane(Part_1_doc, model.selection("FACE", "Extrusion_1_1/Generated_Face&Sketch_2/SketchLine_7"), model.selection("EDGE", "[Extrusion_1_1/Generated_Face&Sketch_2/SketchLine_7][Extrusion_1_1/From_Face]"), 45)
-Plane_8 = model.addPlane(Part_1_doc, model.selection("FACE", "Extrusion_1_1/Generated_Face&Sketch_2/SketchLine_7"), model.selection("EDGE", "[Extrusion_1_1/Generated_Face&Sketch_2/SketchLine_7][Extrusion_1_1/Generated_Face&Sketch_2/SketchLine_6]"), "90+45")
+Plane_8 = model.addPlane(Part_1_doc, model.selection("FACE", "Extrusion_1_1/Generated_Face&Sketch_2/SketchLine_7"), model.selection("EDGE", "[Extrusion_1_1/Generated_Face&Sketch_2/SketchLine_6][Extrusion_1_1/Generated_Face&Sketch_2/SketchLine_7]"), "90+45")
Fill_2 = model.addFill(Part_1_doc, [model.selection("SOLID", "Fill_1_1_1")], [model.selection("FACE", "Plane_5")])
Fill_3 = model.addFill(Part_1_doc, [model.selection("SOLID", "Fill_2_1_2")], [model.selection("FACE", "Plane_3")])
Fill_4 = model.addFill(Part_1_doc, [model.selection("SOLID", "Fill_3_1_2")], [model.selection("FACE", "Plane_4")])
Extrusion_2_objects = [model.selection("FACE", "Sketch_3/Face-SketchCircle_1_2f-SketchLine_14r-SketchLine_11f-SketchLine_16r"), model.selection("FACE", "Sketch_3/Face-SketchCircle_1_2f-SketchCircle_1_2f-SketchLine_17r-SketchLine_10f-SketchLine_14f"), model.selection("FACE", "Sketch_3/Face-SketchCircle_1_2f-SketchLine_15r-SketchLine_13f-SketchLine_17f"), model.selection("FACE", "Sketch_3/Face-SketchCircle_1_2f-SketchLine_16f-SketchLine_12f-SketchLine_15f")]
Extrusion_2 = model.addExtrusion(Part_1_doc, Extrusion_2_objects, model.selection(), 10, 0)
Extrusion_3 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_3/Face-SketchLine_13r-SketchLine_12r-SketchLine_11r-SketchLine_10r")], model.selection(), "haut_int_tuyau", 0)
-Sketch_4 = model.addSketch(Part_1_doc, model.selection("FACE", "Extrusion_2_1/To_Face_3"))
-SketchProjection_6 = Sketch_4.addProjection(model.selection("VERTEX", "[Extrusion_2_1_3/Generated_Face&Sketch_3/SketchCircle_1_2&weak_name_1][Extrusion_2_1/To_Face_3][Extrusion_2_1_3/Generated_Face&Sketch_3/SketchLine_15]"), False)
+Sketch_4 = model.addSketch(Part_1_doc, model.selection("FACE", "Extrusion_2_1_3/To_Face"))
+SketchProjection_6 = Sketch_4.addProjection(model.selection("VERTEX", "[Extrusion_2_1_3/Generated_Face&Sketch_3/SketchCircle_1_2][Extrusion_2_1_3/Generated_Face&Sketch_3/SketchLine_15][Extrusion_2_1_3/To_Face]"), False)
SketchPoint_3 = SketchProjection_6.createdFeature()
-SketchProjection_7 = Sketch_4.addProjection(model.selection("VERTEX", "[Extrusion_2_1/To_Face_2][Extrusion_2_1_3/Generated_Face&Sketch_3/SketchLine_17][Extrusion_2_1_3/Generated_Face&Sketch_3/SketchCircle_1_2&weak_name_2]"), False)
+SketchProjection_7 = Sketch_4.addProjection(model.selection("VERTEX", "[Extrusion_2_1_2/Generated_Face&Sketch_3/SketchCircle_1_2&weak_name_1][Extrusion_2_1_2/Generated_Face&Sketch_3/SketchLine_17][Extrusion_2_1_2/To_Face]"), False)
SketchPoint_4 = SketchProjection_7.createdFeature()
SketchArc_2 = Sketch_4.addArc(0, 0, -7.071067811865476, -7.071067811865472, 7.071067811865476, 7.071067811865472, True)
SketchConstraintCoincidence_26 = Sketch_4.setCoincident(SketchPoint_3.result(), SketchArc_2.startPoint())
SketchLine_18 = Sketch_4.addLine(7.071067811865476, 7.071067811865472, -7.071067811865476, -7.071067811865472)
SketchConstraintCoincidence_28 = Sketch_4.setCoincident(SketchArc_2.endPoint(), SketchLine_18.startPoint())
SketchConstraintCoincidence_29 = Sketch_4.setCoincident(SketchAPI_Point(SketchPoint_3).coordinates(), SketchLine_18.endPoint())
-SketchProjection_8 = Sketch_4.addProjection(model.selection("VERTEX", "[Extrusion_2_1_3/Generated_Face&Sketch_3/SketchCircle_1_2&weak_name_5][Extrusion_2_1/To_Face_1][Extrusion_2_1_3/Generated_Face&Sketch_3/SketchLine_14]"), False)
+SketchProjection_8 = Sketch_4.addProjection(model.selection("VERTEX", "[Extrusion_2_1_1/Generated_Face&Sketch_3/SketchCircle_1_2][Extrusion_2_1_1/Generated_Face&Sketch_3/SketchLine_14][Extrusion_2_1_1/To_Face]"), False)
SketchPoint_5 = SketchProjection_8.createdFeature()
SketchConstraintCoincidence_30 = Sketch_4.setCoincident(SketchArc_2.endPoint(), SketchAPI_Point(SketchPoint_5).coordinates())
model.do()
Revolution_2 = model.addRevolution(Part_1_doc, [model.selection("FACE", "Sketch_4/Face-SketchArc_2_2f-SketchLine_18r")], model.selection("EDGE", "Sketch_4/SketchLine_18"), 0, 180)
Cut_1 = model.addCut(Part_1_doc, [model.selection("SOLID", "Revolution_2_1")], [model.selection("SOLID", "Extrusion_3_1")])
Cut_1.result().setName("demi-sphere")
-Plane_9 = model.addPlane(Part_1_doc, model.selection("VERTEX", "[Extrusion_2_1_3/Generated_Face&Sketch_3/SketchLine_11][Extrusion_2_1/From_Face_1][Extrusion_2_1_3/Generated_Face&Sketch_3/SketchLine_16]"), model.selection("VERTEX", "[Extrusion_2_1_3/Generated_Face&Sketch_3/SketchLine_11][Extrusion_2_1_3/Generated_Face&Sketch_3/SketchLine_16][Extrusion_2_1/To_Face_1]"), model.selection("VERTEX", "[Extrusion_2_1_3/Generated_Face&Sketch_3/SketchCircle_1_2&weak_name_5][Extrusion_2_1_3/Generated_Face&Sketch_3/SketchLine_16][Extrusion_2_1/To_Face_1]"))
-Plane_10 = model.addPlane(Part_1_doc, model.selection("VERTEX", "[Extrusion_2_1_3/Generated_Face&Sketch_3/SketchLine_11][Extrusion_2_1/To_Face_1][Extrusion_2_1_3/Generated_Face&Sketch_3/SketchLine_14]"), model.selection("VERTEX", "[Extrusion_2_1_3/Generated_Face&Sketch_3/SketchCircle_1_2&weak_name_5][Extrusion_2_1/To_Face_1][Extrusion_2_1_3/Generated_Face&Sketch_3/SketchLine_14]"), model.selection("VERTEX", "[Extrusion_2_1/From_Face_1][Extrusion_2_1_3/Generated_Face&Sketch_3/SketchCircle_1_2&weak_name_5][Extrusion_2_1_3/Generated_Face&Sketch_3/SketchLine_14]"))
-Plane_11 = model.addPlane(Part_1_doc, model.selection("VERTEX", "[Extrusion_2_1/To_Face_2][Extrusion_2_1_3/Generated_Face&Sketch_3/SketchLine_17][Extrusion_2_1_3/Generated_Face&Sketch_3/SketchCircle_1_2&weak_name_2]"), model.selection("VERTEX", "[Extrusion_2_1_3/Generated_Face&Sketch_3/SketchLine_10][Extrusion_2_1/To_Face_2][Extrusion_2_1_3/Generated_Face&Sketch_3/SketchLine_17]"), model.selection("VERTEX", "[Extrusion_2_1/From_Face_2][Extrusion_2_1_3/Generated_Face&Sketch_3/SketchLine_17][Extrusion_2_1_3/Generated_Face&Sketch_3/SketchCircle_1_2&weak_name_2]"))
-Plane_12 = model.addPlane(Part_1_doc, model.selection("VERTEX", "[Extrusion_2_1/To_Face_3][Extrusion_2_1_3/Generated_Face&Sketch_3/SketchLine_15][Extrusion_2_1_3/Generated_Face&Sketch_3/SketchLine_13]"), model.selection("VERTEX", "[Extrusion_2_1_3/Generated_Face&Sketch_3/SketchCircle_1_2&weak_name_1][Extrusion_2_1/To_Face_3][Extrusion_2_1_3/Generated_Face&Sketch_3/SketchLine_15]"), model.selection("VERTEX", "[Extrusion_2_1_3/Generated_Face&Sketch_3/SketchCircle_1_2&weak_name_1][Extrusion_2_1_3/Generated_Face&Sketch_3/SketchLine_15][Extrusion_2_1/From_Face_3]"))
+Plane_9 = model.addPlane(Part_1_doc, model.selection("VERTEX", "[Extrusion_2_1_1/Generated_Face&Sketch_3/SketchLine_11][Extrusion_2_1_1/Generated_Face&Sketch_3/SketchLine_16][Extrusion_2_1_1/From_Face]"), model.selection("VERTEX", "[Extrusion_2_1_1/Generated_Face&Sketch_3/SketchLine_11][Extrusion_2_1_1/Generated_Face&Sketch_3/SketchLine_16][Extrusion_2_1_1/To_Face]"), model.selection("VERTEX", "[Extrusion_2_1_1/Generated_Face&Sketch_3/SketchCircle_1_2][Extrusion_2_1_1/Generated_Face&Sketch_3/SketchLine_16][Extrusion_2_1_1/To_Face]"))
+Plane_10 = model.addPlane(Part_1_doc, model.selection("VERTEX", "[Extrusion_2_1_1/Generated_Face&Sketch_3/SketchLine_14][Extrusion_2_1_1/Generated_Face&Sketch_3/SketchLine_11][Extrusion_2_1_1/To_Face]"), model.selection("VERTEX", "[Extrusion_2_1_1/Generated_Face&Sketch_3/SketchCircle_1_2][Extrusion_2_1_1/Generated_Face&Sketch_3/SketchLine_14][Extrusion_2_1_1/To_Face]"), model.selection("VERTEX", "[Extrusion_2_1_1/Generated_Face&Sketch_3/SketchCircle_1_2][Extrusion_2_1_1/Generated_Face&Sketch_3/SketchLine_14][Extrusion_2_1_1/From_Face]"))
+Plane_11 = model.addPlane(Part_1_doc, model.selection("VERTEX", "[Extrusion_2_1_2/Generated_Face&Sketch_3/SketchCircle_1_2&weak_name_1][Extrusion_2_1_2/Generated_Face&Sketch_3/SketchLine_17][Extrusion_2_1_2/To_Face]"), model.selection("VERTEX", "[Extrusion_2_1_2/Generated_Face&Sketch_3/SketchLine_17][Extrusion_2_1_2/Generated_Face&Sketch_3/SketchLine_10][Extrusion_2_1_2/To_Face]"), model.selection("VERTEX", "[Extrusion_2_1_2/Generated_Face&Sketch_3/SketchCircle_1_2&weak_name_1][Extrusion_2_1_2/Generated_Face&Sketch_3/SketchLine_17][Extrusion_2_1_2/From_Face]"))
+Plane_12 = model.addPlane(Part_1_doc, model.selection("VERTEX", "[Extrusion_2_1_3/Generated_Face&Sketch_3/SketchLine_15][Extrusion_2_1_3/Generated_Face&Sketch_3/SketchLine_13][Extrusion_2_1_3/To_Face]"), model.selection("VERTEX", "[Extrusion_2_1_3/Generated_Face&Sketch_3/SketchCircle_1_2][Extrusion_2_1_3/Generated_Face&Sketch_3/SketchLine_15][Extrusion_2_1_3/To_Face]"), model.selection("VERTEX", "[Extrusion_2_1_3/Generated_Face&Sketch_3/SketchCircle_1_2][Extrusion_2_1_3/Generated_Face&Sketch_3/SketchLine_15][Extrusion_2_1_3/From_Face]"))
Recover_1 = model.addRecover(Part_1_doc, Cut_1, [Extrusion_3.result()])
Plane_13 = model.addPlane(Part_1_doc, model.selection("FACE", "Recover_1_1/Shape_4"), model.selection("EDGE", "[Recover_1_1/Shape_4][Recover_1_1/Shape_6]"), "90+45")
-Plane_14 = model.addPlane(Part_1_doc, model.selection("FACE", "Recover_1_1/Shape_1"), model.selection("EDGE", "[Recover_1_1/Shape_6][Recover_1_1/Shape_1]"), "90+45")
-Plane_15 = model.addPlane(Part_1_doc, model.selection("FACE", "Recover_1_1/Shape_2"), model.selection("EDGE", "[Recover_1_1/Shape_6][Recover_1_1/Shape_2]"), "90+45")
-Plane_16 = model.addPlane(Part_1_doc, model.selection("FACE", "Recover_1_1/Shape_6"), model.selection("EDGE", "[Recover_1_1/Shape_6][Recover_1_1/Shape_3]"), 45)
+Plane_14 = model.addPlane(Part_1_doc, model.selection("FACE", "Recover_1_1/Shape_1"), model.selection("EDGE", "[Recover_1_1/Shape_1][Recover_1_1/Shape_6]"), "90+45")
+Plane_15 = model.addPlane(Part_1_doc, model.selection("FACE", "Recover_1_1/Shape_2"), model.selection("EDGE", "[Recover_1_1/Shape_2][Recover_1_1/Shape_6]"), "90+45")
+Plane_16 = model.addPlane(Part_1_doc, model.selection("FACE", "Recover_1_1/Shape_6"), model.selection("EDGE", "[Recover_1_1/Shape_3][Recover_1_1/Shape_6]"), 45)
Fill_5_objects_2 = [model.selection("FACE", "Plane_6"), model.selection("FACE", "Plane_7"), model.selection("FACE", "Plane_8"), model.selection("FACE", "Plane_9"), model.selection("FACE", "Plane_10"), model.selection("FACE", "Plane_11"), model.selection("FACE", "Plane_12"), model.selection("FACE", "Plane_13")]
Fill_5 = model.addFill(Part_1_doc, [model.selection("SOLID", "demi-sphere")], Fill_5_objects_2)
Fill_5.result().subResult(0).setName("Fill_5_1_1")
#include <TNaming_Tool.hxx>
#include <TNaming_Builder.hxx>
#include <TNaming_SameShapeIterator.hxx>
+#include <TNaming_NewShapeIterator.hxx>
#include <TNaming_Iterator.hxx>
#include <TDataStd_Integer.hxx>
#include <TDataStd_UAttribute.hxx>
}
}
}
+ if (theAnyValue) { // only for neighbours for now
+ // try to find modification of sub-shapes: the best number of matches
+ std::map<ResultPtr, int> aMatches; // result -> number of matches of shapes to find the best
+ TDF_Label aResLab = std::dynamic_pointer_cast<Model_Data>(aResult->data())->shapeLab();
+ TDF_ChildIDIterator aModifIter(aResLab, TNaming_NamedShape::GetID());
+ for(; aModifIter.More(); aModifIter.Next()) {
+ Handle(TNaming_NamedShape) aNS = Handle(TNaming_NamedShape)::DownCast(aModifIter.Value());
+ if (aNS->Evolution() == TNaming_MODIFY || aNS->Evolution() == TNaming_GENERATED) {
+ for(TNaming_Iterator aNSIter(aNS); aNSIter.More(); aNSIter.Next()) {
+ TNaming_NewShapeIterator aNewIter(aNSIter.NewShape(), aNS->Label());
+ for(; aNewIter.More(); aNewIter.Next()) {
+ TDF_Label aLab = aNewIter.Label();
+ if (isLater(aLab, aNS->Label()) && isLater(selectionLabel(), aLab)) {
+ ResultPtr aRes = aDoc->resultByLab(aLab);
+ if (aRes.get()) {
+ if (aMatches.find(aRes) == aMatches.end())
+ aMatches[aRes] = 0;
+ aMatches[aRes]++; // found result, add matches
+ }
+ }
+ }
+ }
+ }
+ }
+ // searching for the best result-candidate
+ int aBest = 0;
+ ResultPtr aBestResult;
+ std::map<ResultPtr, int>::iterator aMatchIter = aMatches.begin();
+ for(; aMatchIter != aMatches.end(); aMatchIter++) {
+ if (aMatchIter->second > aBest) {
+ aBest = aMatchIter->second;
+ aBestResult = aMatchIter->first;
+ }
+ }
+ if (aBestResult.get()) {
+ aResult = aBestResult;
+ aFindNewContext = true;
+ continue;
+ }
+ }
+
+
// TestFillWireVertex.py - sketch constructions for wire may participate too
//if (aResult->groupName() == ModelAPI_ResultBody::group()) {
// try to search newer context by the concealment references