+int ParseName(const std::string& theSubShapeName, std::list<std::string>& theList)
+{
+ std::string aName = theSubShapeName;
+ std::string aLastName;
+ int n1(0), n2(0); // n1 - start position, n2 - position of the delimiter
+ while ((n2 = aName.find('|', n1)) != std::string::npos) {
+ const std::string aName1 = aName.substr(n1, n2 - n1); //name of face
+ theList.push_back(aName1);
+ n1 = n2 + 1;
+ aLastName = aName.substr(n1);
+ }
+ if(!aLastName.empty())
+ theList.push_back(aLastName);
+ return theList.size();
+}
+
+const TopoDS_Shape findCommonShape(const TopAbs_ShapeEnum theType, const TopTools_ListOfShape& theList)
+{
+ TopoDS_Shape aShape;
+ std::vector<TopTools_MapOfShape> aVec;
+ TopTools_MapOfShape aMap1, aMap2, aMap3, aMap4;
+ if(theList.Extent() > 1) {
+ aVec.push_back(aMap1);
+ aVec.push_back(aMap2);
+ }
+ if(theList.Extent() > 2)
+ aVec.push_back(aMap3);
+ if(theList.Extent() == 4)
+ aVec.push_back(aMap4);
+
+ //fill maps
+ TopTools_ListIteratorOfListOfShape it(theList);
+ for(int i = 0;it.More();it.Next(),i++) {
+ const TopoDS_Shape& aFace = it.Value();
+ if(i < 2) {
+ TopExp_Explorer anExp (aFace, theType);
+ for(;anExp.More();anExp.Next()) {
+ const TopoDS_Shape& anEdge = anExp.Current();
+ if (!anEdge.IsNull())
+ aVec[i].Add(anExp.Current());
+ }
+ } else {
+ TopExp_Explorer anExp (aFace, TopAbs_VERTEX);
+ for(;anExp.More();anExp.Next()) {
+ const TopoDS_Shape& aVertex = anExp.Current();
+ if (!aVertex.IsNull())
+ aVec[i].Add(anExp.Current());
+ }
+ }
+ }
+ //trivial case: 2 faces
+ TopTools_ListOfShape aList;
+ TopTools_MapIteratorOfMapOfShape it2(aVec[0]);
+ for(;it2.More();it2.Next()) {
+ if(aVec[1].Contains(it2.Key())) {
+ aShape = it2.Key();
+ if(theList.Extent() == 2)
+ break;
+ else
+ aList.Append(it2.Key());
+ }
+ }
+ if(aList.Extent() && aVec.size() > 3) {// list of common edges ==> search ny neighbors
+ if(aVec[2].Extent() && aVec[3].Extent()) {
+ TopTools_ListIteratorOfListOfShape it(aList);
+ for(;it.More();it.Next()) {
+ const TopoDS_Shape& aCand = it.Value();
+ // not yet completelly implemented, to be rechecked
+ TopoDS_Vertex aV1, aV2;
+ TopExp::Vertices(TopoDS::Edge(aCand), aV1, aV2);
+ int aNum(0);
+ if(aVec[2].Contains(aV1)) aNum++;
+ else if(aVec[2].Contains(aV2)) aNum++;
+ if(aVec[3].Contains(aV1)) aNum++;
+ else if(aVec[3].Contains(aV2)) aNum++;
+ if(aNum == 2) {
+ aShape = aCand;
+ break;
+ }
+ }
+ }
+ }
+
+ if(aList.Extent() && aVec.size() == 3) {
+
+ TopTools_ListIteratorOfListOfShape it(aList);
+ for(;it.More();it.Next()) {
+ const TopoDS_Shape& aCand = it.Value();
+ if(aVec[2].Contains(aCand)) {
+ aShape = aCand;
+ break;
+ }
+ }
+ }
+ return aShape;
+}
+
+std::string getContextName(const std::string& theSubShapeName)