Translation_2 = model.addTranslation(Part_1_doc, [model.selection("FACE", "Recover_2_1")], model.selection("VERTEX", "Sketch_3/SketchLine_11_EndVertex"), model.selection("VERTEX", "Sketch_1/SketchLine_3_EndVertex"))
LinearCopy_3 = model.addMultiTranslation(Part_1_doc, [model.selection("FACE", "Translation_2_1")], model.selection("EDGE", "PartSet/OX"), "length_assemblage", 4)
Recover_3 = model.addRecover(Part_1_doc, LinearCopy_1, [Face_5.result()])
-Translation_3 = model.addTranslation(Part_1_doc, [model.selection("FACE", "Recover_3_1")], model.selection("VERTEX", "Sketch_1/SketchLine_7_EndVertex"), model.selection("VERTEX", "[LinearCopy_3_1_1/ME:Translated_Edge&Recover_2_1/Shape_4][LinearCopy_3_1_1/ME:Translated_Edge&Recover_2_1/Shape_1]"))
+Translation_3 = model.addTranslation(Part_1_doc, [model.selection("FACE", "Recover_3_1")], model.selection("VERTEX", "Sketch_1/SketchLine_7_EndVertex"), model.selection("VERTEX", "[LinearCopy_3_1_1/ME:Translated_Edge&Face_5_1/Edge_1]e[LinearCopy_3_1_1/ME:Translated_Edge&Face_5_1/Edge_4]e"))
LinearCopy_4 = model.addMultiTranslation(Part_1_doc, [model.selection("FACE", "Translation_3_1")], model.selection("EDGE", "PartSet/OX"), "length_assemblage", 3)
Recover_4 = model.addRecover(Part_1_doc, LinearCopy_1, [Face_5.result()])
Translation_4 = model.addTranslation(Part_1_doc, [model.selection("FACE", "Recover_4_1")], model.selection("VERTEX", "Sketch_1/SketchLine_7_EndVertex"), model.selection("VERTEX", "Sketch_1/SketchLine_1_StartVertex"))
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_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)
+Plane_13 = model.addPlane(Part_1_doc, model.selection("FACE", "Recover_1_1/Modified_Face&Sketch_3/SketchLine_10"), model.selection("EDGE", "[Recover_1_1/Modified_Face&Sketch_3/SketchLine_10][Recover_1_1/Modified_Face&Extrusion_3_1/To_Face]"), "90+45")
+Plane_14 = model.addPlane(Part_1_doc, model.selection("FACE", "Recover_1_1/Modified_Face&Sketch_3/SketchLine_13"), model.selection("EDGE", "[Recover_1_1/Modified_Face&Sketch_3/SketchLine_13][Recover_1_1/Modified_Face&Extrusion_3_1/To_Face]"), "90+45")
+Plane_15 = model.addPlane(Part_1_doc, model.selection("FACE", "Recover_1_1/Modified_Face&Sketch_3/SketchLine_12"), model.selection("EDGE", "[Recover_1_1/Modified_Face&Sketch_3/SketchLine_12][Recover_1_1/Modified_Face&Extrusion_3_1/To_Face]"), "90+45")
+Plane_16 = model.addPlane(Part_1_doc, model.selection("FACE", "Recover_1_1/Modified_Face&Extrusion_3_1/To_Face"), model.selection("EDGE", "[Recover_1_1/Modified_Face&Sketch_3/SketchLine_11][Recover_1_1/Modified_Face&Extrusion_3_1/To_Face]"), 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")
model.end()
+# too long
#assert(model.checkPythonDump())
Translation_2 = model.addTranslation(Part_1_doc, [model.selection("FACE", "Recover_2_1")], model.selection("VERTEX", "Sketch_3/SketchLine_11_EndVertex"), model.selection("VERTEX", "Sketch_1/SketchLine_3_EndVertex"))
LinearCopy_3 = model.addMultiTranslation(Part_1_doc, [model.selection("FACE", "Translation_2_1")], model.selection("EDGE", "PartSet/OX"), "length_assemblage", 4)
Recover_3 = model.addRecover(Part_1_doc, LinearCopy_1, [Face_5.result()])
-Translation_3 = model.addTranslation(Part_1_doc, [model.selection("FACE", "Recover_3_1")], model.selection("VERTEX", "Sketch_1/SketchLine_7_EndVertex"), model.selection("VERTEX", "[LinearCopy_3_1_1/ME:Translated_Edge&Recover_2_1/Shape_4][LinearCopy_3_1_1/ME:Translated_Edge&Recover_2_1/Shape_1]"))
+Translation_3 = model.addTranslation(Part_1_doc, [model.selection("FACE", "Recover_3_1")], model.selection("VERTEX", "Sketch_1/SketchLine_7_EndVertex"), model.selection("VERTEX", "[LinearCopy_3_1_1/ME:Translated_Edge&Face_5_1/Edge_1]e[LinearCopy_3_1_1/ME:Translated_Edge&Face_5_1/Edge_4]e"))
LinearCopy_4 = model.addMultiTranslation(Part_1_doc, [model.selection("FACE", "Translation_3_1")], model.selection("EDGE", "PartSet/OX"), "length_assemblage", 3)
Recover_4 = model.addRecover(Part_1_doc, LinearCopy_1, [Face_5.result()])
Translation_4 = model.addTranslation(Part_1_doc, [model.selection("FACE", "Recover_4_1")], model.selection("VERTEX", "Sketch_1/SketchLine_7_EndVertex"), model.selection("VERTEX", "Sketch_1/SketchLine_1_StartVertex"))
Translation_2 = model.addTranslation(Part_1_doc, [model.selection("FACE", "Recover_2_1")], model.selection("VERTEX", "Sketch_3/SketchLine_11_EndVertex"), model.selection("VERTEX", "Sketch_1/SketchLine_3_EndVertex"))
LinearCopy_3 = model.addMultiTranslation(Part_1_doc, [model.selection("FACE", "Translation_2_1")], model.selection("EDGE", "PartSet/OX"), "length_assemblage", 4)
Recover_3 = model.addRecover(Part_1_doc, LinearCopy_1, [Face_5.result()])
-Translation_3 = model.addTranslation(Part_1_doc, [model.selection("FACE", "Recover_3_1")], model.selection("VERTEX", "Sketch_1/SketchLine_7_EndVertex"), model.selection("VERTEX", "[LinearCopy_3_1_1/ME:Translated_Edge&Recover_2_1/Shape_1][LinearCopy_3_1_1/ME:Translated_Edge&Recover_2_1/Shape_4]"))
+Translation_3 = model.addTranslation(Part_1_doc, [model.selection("FACE", "Recover_3_1")], model.selection("VERTEX", "Sketch_1/SketchLine_7_EndVertex"), model.selection("VERTEX", "[LinearCopy_3_1_1/ME:Translated_Edge&Face_5_1/Edge_1]e[LinearCopy_3_1_1/ME:Translated_Edge&Face_5_1/Edge_4]e"))
LinearCopy_4 = model.addMultiTranslation(Part_1_doc, [model.selection("FACE", "Translation_3_1")], model.selection("EDGE", "PartSet/OX"), "length_assemblage", 3)
Recover_4 = model.addRecover(Part_1_doc, LinearCopy_1, [Face_5.result()])
Translation_4 = model.addTranslation(Part_1_doc, [model.selection("FACE", "Recover_4_1")], model.selection("VERTEX", "Sketch_1/SketchLine_7_EndVertex"), model.selection("VERTEX", "Sketch_1/SketchLine_1_StartVertex"))
#include <TDataStd_ReferenceArray.hxx>
#include <TDataStd_IntegerArray.hxx>
#include <TDataStd_Name.hxx>
+#include <TDataStd_UAttribute.hxx>
#include <list>
static const Standard_GUID kLEVELS_ARRAY("ee4c4b45-e859-4e86-aa4f-6eac68e0ca1f");
// weak index (integer) of the sub-shape
static const Standard_GUID kWEAK_INDEX("e9373a61-cabc-4ee8-aabf-aea47c62ed87");
+// geometrical naming indicator
+static const Standard_GUID kGEOMETRICAL_NAMING("a5322d02-50fb-43ed-9255-75c7b93f6657");
+
+// string identifier of the weak name in modification or intersection types of algorithm
+static const std::string kWEAK_NAME_IDENTIFIER = "weak_name_";
+// string identifier of the pure weak name algorithm
+static const std::string kPUREWEAK_NAME_IDENTIFIER = "_weak_name_";
+
Selector_Selector::Selector_Selector(TDF_Label theLab) : myLab(theLab)
{
}
bool Selector_Selector::select(const TopoDS_Shape theContext, const TopoDS_Shape theValue,
- const bool theUseNeighbors, const bool theUseIntersections)
+ const bool theGeometricalNaming, const bool theUseNeighbors, const bool theUseIntersections)
{
if (theValue.IsNull() || theContext.IsNull())
return false;
+ myGeometricalNaming = theGeometricalNaming;
// check the value shape can be named as it is, or it is needed to construct it from the
// higher level shapes (like a box vertex by faces that form this vertex)
bool aIsFound = TNaming_Tool::HasLabel(myLab, theValue);
aSelectionType == TopAbs_SHELL || aSelectionType == TopAbs_WIRE)
{ // iterate all sub-shapes and select them on sublabels
for(TopoDS_Iterator aSubIter(theValue); aSubIter.More(); aSubIter.Next()) {
- if (!selectBySubSelector(
- theContext, aSubIter.Value(), theUseNeighbors, theUseIntersections)) {
+ if (!selectBySubSelector(theContext, aSubIter.Value(),
+ theGeometricalNaming, theUseNeighbors, theUseIntersections)) {
return false; // if some selector is failed, everything is failed
}
}
mySubSelList.clear();
TopoDS_ListOfShape::Iterator anInt(anIntList);
for (; anInt.More(); anInt.Next()) {
- if (!selectBySubSelector(theContext, anInt.Value(), theUseNeighbors, false)) {
+ if (!selectBySubSelector(theContext, anInt.Value(),
+ theGeometricalNaming, theUseNeighbors, false)) {
break; // if some selector is failed, stop and search another solution
}
}
// check which can be named correctly, without "by neighbors" type
Selector_Selector aSelector(myLab.FindChild(1));
aSelector.setBaseDocument(myBaseDocumentLab);
- if (aSelector.select(theContext, aNewNBShape, false, false)) { // add to list of good NBs
+ if (aSelector.select(theContext, aNewNBShape, theGeometricalNaming, false, false)) {
+ // add to list of good NBs
aNBs.push_back(std::pair<TopoDS_Shape, int>(aNewNBShape, aLevel));
}
}
if (!aResult.IsNull() && aResult.IsSame(theValue)) {
std::list<std::pair<TopoDS_Shape, int> >::iterator aNBIter = aNBs.begin();
for(; aNBIter != aNBs.end(); aNBIter++) {
- if (!selectBySubSelector(theContext, aNBIter->first, false, false)) {
+ if (!selectBySubSelector(theContext, aNBIter->first,
+ theGeometricalNaming, false, false)) {
return false; // something is wrong because before this selection was ok
}
myNBLevel.push_back(aNBIter->second);
mySubSelList.clear();
TopoDS_ListOfShape::Iterator anInt(aLastIntersectors);
for (; anInt.More(); anInt.Next()) {
- if (!selectBySubSelector(
- theContext, anInt.Value(), theUseNeighbors, theUseIntersections)) {
+ if (!selectBySubSelector(theContext, anInt.Value(),
+ theGeometricalNaming, theUseNeighbors, theUseIntersections)) {
break; // if some selector is failed, stop and search another solution
}
}
Selector_Selector aSelector(myLab.FindChild(1));
if (!myBaseDocumentLab.IsNull())
aSelector.setBaseDocument(myBaseDocumentLab);
- if (aSelector.select(theContext, aNewNBShape, false)) {// add to list of good NBs
+ if (aSelector.select(theContext, aNewNBShape, theGeometricalNaming, false)) {
+ // add to list of good NBs
aNBs.push_back(std::pair<TopoDS_Shape, int>(aNewNBShape, aLevel));
}
}
if (!aResult.IsNull() && aResult.IsSame(theValue)) {
std::list<std::pair<TopoDS_Shape, int> >::iterator aNBIter = aNBs.begin();
for(; aNBIter != aNBs.end(); aNBIter++) {
- if (!selectBySubSelector(
- theContext, aNBIter->first, theUseNeighbors, theUseIntersections)) {
+ if (!selectBySubSelector(theContext, aNBIter->first,
+ theGeometricalNaming, theUseNeighbors, theUseIntersections)) {
return false; // something is wrong because before this selection was ok
}
myNBLevel.push_back(aNBIter->second);
{
myLab.ForgetAllAttributes(true); // remove old naming data
TDataStd_Integer::Set(myLab, kSEL_TYPE, (int)myType);
+ if (myGeometricalNaming)
+ TDataStd_UAttribute::Set(myLab, kGEOMETRICAL_NAMING);
switch(myType) {
case SELTYPE_CONTAINER:
case SELTYPE_INTERSECT: {
Handle(TDataStd_Integer) aTypeAttr;
if (!myLab.FindAttribute(kSEL_TYPE, aTypeAttr))
return false;
+ myGeometricalNaming = myLab.IsAttribute(kGEOMETRICAL_NAMING);
myType = Selector_Type(aTypeAttr->Get());
switch(myType) {
case SELTYPE_CONTAINER:
return TopoDS_Shape(); // empty, error shape
}
-static const std::string kWEAK_NAME_IDENTIFIER = "weak_name_";
-static const std::string kPUREWEAK_NAME_IDENTIFIER = "_weak_name_";
-
std::string Selector_Selector::name(Selector_NameGenerator* theNameGenerator) {
switch(myType) {
case SELTYPE_CONTAINER:
TDF_Label Selector_Selector::restoreByName(
std::string theName, const TopAbs_ShapeEnum theShapeType,
- Selector_NameGenerator* theNameGenerator)
+ Selector_NameGenerator* theNameGenerator, const bool theGeometricalNaming)
{
+ myGeometricalNaming = theGeometricalNaming;
if (theName[0] == '[') { // intersection or container
switch(theShapeType) {
case TopAbs_COMPOUND:
}
mySubSelList.push_back(Selector_Selector(myLab.FindChild(int(mySubSelList.size()) + 1)));
mySubSelList.back().setBaseDocument(myBaseDocumentLab);
- TDF_Label aSubContext =
- mySubSelList.back().restoreByName(aSubStr, aSubShapeType, theNameGenerator);
+ TDF_Label aSubContext = mySubSelList.back().restoreByName(
+ aSubStr, aSubShapeType, theNameGenerator, theGeometricalNaming);
if (aSubContext.IsNull())
return aSubContext; // invalid sub-selection parsing
if (!aContext.IsNull() && !aContext.IsEqual(aSubContext)) {
std::string aSubStr = theName.substr(aStart + 1, anEndPos - aStart - 1);
mySubSelList.push_back(Selector_Selector(myLab.FindChild(int(mySubSelList.size()) + 1)));
mySubSelList.back().setBaseDocument(myBaseDocumentLab);
- TDF_Label aSubContext =
- mySubSelList.back().restoreByName(aSubStr, theShapeType, theNameGenerator);
+ TDF_Label aSubContext = mySubSelList.back().restoreByName(
+ aSubStr, theShapeType, theNameGenerator, theGeometricalNaming);
if (aSubContext.IsNull())
return aSubContext; // invalid sub-selection parsing
if (!aContext.IsNull() && !aContext.IsEqual(aSubContext)) {
return TDF_Label();
}
-bool Selector_Selector::selectBySubSelector(
- const TopoDS_Shape theContext, const TopoDS_Shape theValue,
+bool Selector_Selector::selectBySubSelector(const TopoDS_Shape theContext,
+ const TopoDS_Shape theValue, const bool theGeometricalNaming,
const bool theUseNeighbors, const bool theUseIntersections)
{
mySubSelList.push_back(Selector_Selector(myLab.FindChild(int(mySubSelList.size()) + 1)));
if (!myBaseDocumentLab.IsNull())
mySubSelList.back().setBaseDocument(myBaseDocumentLab);
- if (!mySubSelList.back().select(theContext, theValue, theUseNeighbors, theUseIntersections)) {
+ if (!mySubSelList.back().select(theContext, theValue,
+ theGeometricalNaming, theUseNeighbors, theUseIntersections)) {
mySubSelList.clear(); // if one of the selector is failed, all become invalid
return false;
}
TDF_Label myBaseDocumentLab; ///< an access-label to the document that may contain initial shapes
- public:
+ bool myGeometricalNaming; ///< flag that indicates that geometrical naming selection is enabled
+
+public:
/// Initializes selector on the label
- SELECTOR_EXPORT Selector_Selector(TDF_Label theLab);
+ SELECTOR_EXPORT Selector_Selector(TDF_Label theLab);
/// Returns label of this selector
- SELECTOR_EXPORT TDF_Label label();
+ SELECTOR_EXPORT TDF_Label label();
- /// Sets the base document access label.
- SELECTOR_EXPORT void setBaseDocument(const TDF_Label theAccess);
+ /// Sets the base document access label.
+ SELECTOR_EXPORT void setBaseDocument(const TDF_Label theAccess);
/// Initializes the selector structure on the label.
/// Stores the name data to restore after modification.
- SELECTOR_EXPORT bool select(const TopoDS_Shape theContext, const TopoDS_Shape theValue,
- const bool theUseNeighbors = true, const bool theUseIntersections = true);
+ /// \param theContext whole shape that contains the selected sub-shape
+ /// \param theValue selected subshape
+ /// \param theGeometricalNaming treats selection with equal surfaces as one
+ /// \param theUseNeighbors enables searching algorithm by neighbors
+ /// \param theUseIntersections enables searching algorithm by intersection of higher level shapes
+ SELECTOR_EXPORT bool select(const TopoDS_Shape theContext, const TopoDS_Shape theValue,
+ const bool theGeometricalNaming = false,
+ const bool theUseNeighbors = true, const bool theUseIntersections = true);
/// Stores the name to the label and sub-labels tree
- SELECTOR_EXPORT void store();
+ SELECTOR_EXPORT void store();
/// Restores the selected shape by the topological naming kept in the data structure
/// Returns true if it can restore structure correctly
- SELECTOR_EXPORT bool restore();
+ SELECTOR_EXPORT bool restore();
- /// Restores the selected shape by the topological name string.
- /// Returns not empty label of the context.
- SELECTOR_EXPORT TDF_Label restoreByName(
- std::string theName, const TopAbs_ShapeEnum theShapeType,
- Selector_NameGenerator* theNameGenerator);
+ /// Restores the selected shape by the topological name string.
+ /// Returns not empty label of the context.
+ SELECTOR_EXPORT TDF_Label restoreByName(
+ std::string theName, const TopAbs_ShapeEnum theShapeType,
+ Selector_NameGenerator* theNameGenerator, const bool theGeometricalNaming = false);
/// Updates the current shape by the stored topological name
- SELECTOR_EXPORT bool solve(const TopoDS_Shape& theContext);
+ SELECTOR_EXPORT bool solve(const TopoDS_Shape& theContext);
- /// Returns the current sub-shape value (null if can not resolve)
- SELECTOR_EXPORT TopoDS_Shape value();
+ /// Returns the current sub-shape value (null if can not resolve)
+ SELECTOR_EXPORT TopoDS_Shape value();
- /// Returns the naming name of the selection
- SELECTOR_EXPORT std::string name(Selector_NameGenerator* theNameGenerator);
+ /// Returns the naming name of the selection
+ SELECTOR_EXPORT std::string name(Selector_NameGenerator* theNameGenerator);
private:
/// Create and keep in the list the sub-selector that select the given value.
/// Returns true if selection is correct.
bool selectBySubSelector(const TopoDS_Shape theContext, const TopoDS_Shape theValue,
- const bool theUseNeighbors = true, const bool theUseIntersections = true);
+ const bool theGeometricalNaming = false, const bool theUseNeighbors = true,
+ const bool theUseIntersections = true);
/// Searches the final shapes presented in all results from bases basing on modification fields
void findModificationResult(TopoDS_ListOfShape& theCommon);
};