Salome HOME
Issue #1366: Remove Sub-Shapes feature added.
[modules/shaper.git] / src / Model / Model_SelectionNaming.cpp
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
2
3 // File:        Model_SelectionNaming.cpp
4 // Created:     11 Aug 2015
5 // Author:      Mikhail PONIKAROV
6
7 #include "Model_SelectionNaming.h"
8 #include "Model_Document.h"
9 #include <ModelAPI_Feature.h>
10 #include <Events_Error.h>
11
12 #include <TopoDS_Iterator.hxx>
13 #include <TopoDS.hxx>
14 #include <TopoDS_Compound.hxx>
15 #include <TopExp.hxx>
16 #include <TopExp_Explorer.hxx>
17 #include <TopTools_ListOfShape.hxx>
18 #include <TopTools_MapOfShape.hxx>
19 #include <TopTools_IndexedMapOfShape.hxx>
20 #include <TopTools_ListIteratorOfListOfShape.hxx>
21 #include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
22 #include <TopTools_MapIteratorOfMapOfShape.hxx>
23 #include <BRep_Builder.hxx>
24 #include <TNaming_Iterator.hxx>
25 #include <TNaming_Tool.hxx>
26 #include <TNaming_NamedShape.hxx>
27 #include <TNaming_Localizer.hxx>
28 #include <TDataStd_Name.hxx>
29
30 #ifdef DEB_NAMING
31 #include <BRepTools.hxx>
32 #endif
33
34 Model_SelectionNaming::Model_SelectionNaming(TDF_Label theSelectionLab)
35 {
36   myLab = theSelectionLab;
37 }
38
39
40 std::string Model_SelectionNaming::getShapeName(
41   std::shared_ptr<Model_Document> theDoc, const TopoDS_Shape& theShape)
42 {
43   std::string aName;
44   // check if the subShape is already in DF
45   Handle(TNaming_NamedShape) aNS = TNaming_Tool::NamedShape(theShape, myLab);
46   Handle(TDataStd_Name) anAttr;
47   if(!aNS.IsNull() && !aNS->IsEmpty()) { // in the document    
48     if(aNS->Label().FindAttribute(TDataStd_Name::GetID(), anAttr)) {
49       aName = TCollection_AsciiString(anAttr->Get()).ToCString();
50       if(!aName.empty()) {          
51         const TDF_Label& aLabel = theDoc->findNamingName(aName);
52         /* MPV: the same shape with the same name may be duplicated on different labels (selection of the same construction object)
53         if(!aLabel.IsEqual(aNS->Label())) {
54         //aName.erase(); //something is wrong, to be checked!!!
55         aName += "_SomethingWrong";
56         return aName;
57         }*/
58
59         static const std::string aPostFix("_");
60         TNaming_Iterator anItL(aNS);
61         for(int i = 1; anItL.More(); anItL.Next(), i++) {
62           if(anItL.NewShape() == theShape) {
63             aName += aPostFix;
64             aName += TCollection_AsciiString (i).ToCString();
65             break;
66           }
67         }
68       } 
69     }
70   }
71   return aName;
72 }
73
74
75
76 bool isTrivial (const TopTools_ListOfShape& theAncestors, TopTools_IndexedMapOfShape& theSMap)
77 {
78   // a trivial case: F1 & F2,  aNumber = 1, i.e. intersection gives 1 edge.
79   TopoDS_Compound aCmp;
80   BRep_Builder BB;
81   BB.MakeCompound(aCmp);
82   TopTools_ListIteratorOfListOfShape it(theAncestors);
83   for(;it.More();it.Next()) {
84     BB.Add(aCmp, it.Value());
85     theSMap.Add(it.Value());
86   }
87   int aNumber(0);
88   TopTools_IndexedDataMapOfShapeListOfShape aMap2;
89   TopExp::MapShapesAndAncestors(aCmp, TopAbs_EDGE, TopAbs_FACE, aMap2);
90   for (int i = 1; i <= aMap2.Extent(); i++) {
91     const TopoDS_Shape& aKey = aMap2.FindKey(i);
92     const TopTools_ListOfShape& anAncestors = aMap2.FindFromIndex(i);
93     if(anAncestors.Extent() > 1) aNumber++;
94   }
95   if(aNumber > 1) return false;
96   return true;
97 }
98
99 std::string Model_SelectionNaming::namingName(ResultPtr& theContext,
100   std::shared_ptr<GeomAPI_Shape> theSubSh, const std::string& theDefaultName)
101 {
102   std::string aName("Undefined name");
103   if(!theContext.get() || theContext->shape()->isNull()) 
104     return !theDefaultName.empty() ? theDefaultName : aName;
105   if (!theSubSh.get() || theSubSh->isNull()) { // no subshape, so just the whole feature name
106     return theContext->data()->name();
107   }
108   TopoDS_Shape aSubShape = theSubSh->impl<TopoDS_Shape>();
109   TopoDS_Shape aContext  = theContext->shape()->impl<TopoDS_Shape>();
110 #ifdef DEB_NAMING
111   if(aSubShape.ShapeType() == TopAbs_COMPOUND) {
112     BRepTools::Write(aSubShape, "Selection.brep");
113     BRepTools::Write(aContext, "Context.brep");
114   }
115 #endif
116   std::shared_ptr<Model_Document> aDoc = 
117     std::dynamic_pointer_cast<Model_Document>(theContext->document());
118
119   // check if the subShape is already in DF
120   aName = getShapeName(aDoc, aSubShape);
121   if(aName.empty() ) { // not in the document!
122     TopAbs_ShapeEnum aType = aSubShape.ShapeType();
123     switch (aType) {
124     case TopAbs_FACE:
125       // the Face should be in DF. If it is not the case, it is an error ==> to be debugged             
126       break;
127     case TopAbs_EDGE:
128       {
129         // name structure: F1 | F2 [| F3 | F4], where F1 & F2 the faces which gives the Edge in trivial case
130         // if it is not atrivial case we use localization by neighbours. F3 & F4 - neighbour faces      
131         if (BRep_Tool::Degenerated(TopoDS::Edge(aSubShape))) {
132           aName = "Degenerated_Edge";
133           break;
134         }    
135         TopTools_IndexedDataMapOfShapeListOfShape aMap;
136         TopExp::MapShapesAndAncestors(aContext, TopAbs_EDGE, TopAbs_FACE, aMap);
137         TopTools_IndexedMapOfShape aSMap; // map for ancestors of the sub-shape
138         bool isTrivialCase(true);
139         if(aMap.Contains(aSubShape)) {
140           const TopTools_ListOfShape& anAncestors = aMap.FindFromKey(aSubShape);
141           // check that it is not a trivial case (F1 & F2: aNumber = 1)
142           isTrivialCase = isTrivial(anAncestors, aSMap);                
143         } else 
144           break;
145         TopTools_ListOfShape aListOfNbs;
146         if(!isTrivialCase) { // find Neighbors
147           TNaming_Localizer aLocalizer;
148           TopTools_MapOfShape aMap3;
149           aLocalizer.FindNeighbourg(aContext, aSubShape, aMap3);
150           //int n = aMap3.Extent();
151           TopTools_MapIteratorOfMapOfShape it(aMap3);
152           for(;it.More();it.Next()) {
153             const TopoDS_Shape& aNbShape = it.Key(); // neighbor edge
154             //TopAbs_ShapeEnum aType = aNbShape.ShapeType();
155             const TopTools_ListOfShape& aList  = aMap.FindFromKey(aNbShape);
156             TopTools_ListIteratorOfListOfShape it2(aList);
157             for(;it2.More();it2.Next()) {
158               if(aSMap.Contains(it2.Value())) continue; // skip this Face
159               aListOfNbs.Append(it2.Value());
160             }
161           }
162         }  // else a trivial case
163
164         // build name of the sub-shape Edge
165         for(int i=1; i <= aSMap.Extent(); i++) {
166           const TopoDS_Shape& aFace = aSMap.FindKey(i);
167           std::string aFaceName = getShapeName(aDoc, aFace);
168           if(i == 1)
169             aName = aFaceName;
170           else 
171             aName += "&" + aFaceName;
172         }
173         TopTools_ListIteratorOfListOfShape itl(aListOfNbs);
174         for (;itl.More();itl.Next()) {
175           std::string aFaceName = getShapeName(aDoc, itl.Value());
176           aName += "&" + aFaceName;
177         }                 
178       }
179       break;
180
181     case TopAbs_VERTEX:
182       // name structure (Monifold Topology): 
183       // 1) F1 | F2 | F3 - intersection of 3 faces defines a vertex - trivial case.
184       // 2) F1 | F2 | F3 [|F4 [|Fn]] - redundant definition, but it should be kept as is to obtain safe recomputation
185       // 2) F1 | F2      - intersection of 2 faces definses a vertex - applicable for case
186       //                   when 1 faces is cylindrical, conical, spherical or revolution and etc.
187       // 3) E1 | E2 | E3 - intersection of 3 edges defines a vertex - when we have case of a shell
188       //                   or compound of 2 open faces.
189       // 4) E1 | E2      - intesection of 2 edges defines a vertex - when we have a case of 
190       //                   two independent edges (wire or compound)
191       // implemented 2 first cases
192       {
193         TopTools_IndexedDataMapOfShapeListOfShape aMap;
194         TopExp::MapShapesAndAncestors(aContext, TopAbs_VERTEX, TopAbs_FACE, aMap);
195         const TopTools_ListOfShape& aList2  = aMap.FindFromKey(aSubShape);
196         TopTools_ListOfShape aList;
197         TopTools_MapOfShape aFMap;
198         // fix is below
199         TopTools_ListIteratorOfListOfShape itl2(aList2);
200         for (int i = 1;itl2.More();itl2.Next(),i++) {
201           if(aFMap.Add(itl2.Value()))
202             aList.Append(itl2.Value());
203         }
204         int n = aList.Extent();
205         bool isByFaces = n >= 3;
206         if(!isByFaces) { // open topology case or Compound case => via edges
207           TopTools_IndexedDataMapOfShapeListOfShape aMap;
208           TopExp::MapShapesAndAncestors(aContext, TopAbs_VERTEX, TopAbs_EDGE, aMap);
209           const TopTools_ListOfShape& aList22  = aMap.FindFromKey(aSubShape);
210           if(aList22.Extent() >= 2)  { // regular solution
211
212             // bug! duplication; fix is below
213             aFMap.Clear();
214             TopTools_ListOfShape aListE;
215             TopTools_ListIteratorOfListOfShape itl2(aList22);
216             for (int i = 1;itl2.More();itl2.Next(),i++) {
217               if(aFMap.Add(itl2.Value()))
218                 aListE.Append(itl2.Value());
219             }
220             n = aListE.Extent();
221             TopTools_ListIteratorOfListOfShape itl(aListE);
222             for (int i = 1;itl.More();itl.Next(),i++) {
223               const TopoDS_Shape& anEdge = itl.Value();
224               std::string anEdgeName = getShapeName(aDoc, anEdge);
225               if (anEdgeName.empty()) { // edge is not in DS, trying by faces anyway
226                 isByFaces = true;
227                 aName.clear();
228                 break;
229               }
230               if(i == 1)
231                 aName = anEdgeName;
232               else 
233                 aName += "&" + anEdgeName;
234             }
235           }//reg
236           else { // dangle vertex: if(aList22.Extent() == 1)
237             //it should be already in DF
238           }
239         } 
240         if (isByFaces) {
241           TopTools_ListIteratorOfListOfShape itl(aList);
242           for (int i = 1;itl.More();itl.Next(),i++) {
243             const TopoDS_Shape& aFace = itl.Value();
244             std::string aFaceName = getShapeName(aDoc, aFace);
245             if(i == 1)
246               aName = aFaceName;
247             else 
248               aName += "&" + aFaceName;
249           }
250         }
251       }
252       break;
253     }
254     // register name                    
255     // aDoc->addNamingName(selectionLabel(), aName);
256     // the selected sub-shape will not be shared and as result it will not require registration
257   }
258   return aName;
259 }
260
261 TopAbs_ShapeEnum translateType (const std::string& theType)
262 {
263   // map from the textual shape types to OCCT enumeration
264   static std::map<std::string, TopAbs_ShapeEnum> aShapeTypes;
265
266   if(aShapeTypes.size() == 0) {
267     aShapeTypes["compound"]   = TopAbs_COMPOUND;
268     aShapeTypes["compounds"]  = TopAbs_COMPOUND;
269     aShapeTypes["compsolid"]  = TopAbs_COMPSOLID;
270     aShapeTypes["compsolids"] = TopAbs_COMPSOLID;
271     aShapeTypes["solid"]      = TopAbs_SOLID;
272     aShapeTypes["solids"]     = TopAbs_SOLID;
273     aShapeTypes["shell"]      = TopAbs_SHELL;
274     aShapeTypes["shells"]     = TopAbs_SHELL;
275     aShapeTypes["face"]       = TopAbs_FACE;
276     aShapeTypes["faces"]      = TopAbs_FACE;
277     aShapeTypes["wire"]       = TopAbs_WIRE;
278     aShapeTypes["wires"]      = TopAbs_WIRE;
279     aShapeTypes["edge"]       = TopAbs_EDGE;
280     aShapeTypes["edges"]      = TopAbs_EDGE;
281     aShapeTypes["vertex"]     = TopAbs_VERTEX;
282     aShapeTypes["vertices"]   = TopAbs_VERTEX;
283     aShapeTypes["COMPOUND"]   = TopAbs_COMPOUND;
284     aShapeTypes["COMPOUNDS"]  = TopAbs_COMPOUND;
285     aShapeTypes["COMPSOLID"]  = TopAbs_COMPSOLID;
286     aShapeTypes["COMPSOLIDS"] = TopAbs_COMPSOLID;
287     aShapeTypes["SOLID"]      = TopAbs_SOLID;
288     aShapeTypes["SOLIDS"]     = TopAbs_SOLID;
289     aShapeTypes["SHELL"]      = TopAbs_SHELL;
290     aShapeTypes["SHELLS"]     = TopAbs_SHELL;
291     aShapeTypes["FACE"]       = TopAbs_FACE;
292     aShapeTypes["FACES"]      = TopAbs_FACE;
293     aShapeTypes["WIRE"]       = TopAbs_WIRE;
294     aShapeTypes["WIRES"]      = TopAbs_WIRE;
295     aShapeTypes["EDGE"]       = TopAbs_EDGE;
296     aShapeTypes["EDGES"]      = TopAbs_EDGE;
297     aShapeTypes["VERTEX"]     = TopAbs_VERTEX;
298     aShapeTypes["VERTICES"]   = TopAbs_VERTEX;
299   }
300   if (aShapeTypes.find(theType) != aShapeTypes.end())
301     return aShapeTypes[theType];
302   Events_Error::send("Shape type defined in XML is not implemented!");
303   return TopAbs_SHAPE;
304 }
305
306 const TopoDS_Shape getShapeFromNS(
307   const std::string& theSubShapeName, Handle(TNaming_NamedShape) theNS)
308 {
309   TopoDS_Shape aSelection;
310   std::string::size_type n = theSubShapeName.rfind('/');                        
311   if (n == std::string::npos) n = 0;
312   std::string aSubString = theSubShapeName.substr(n + 1);
313   n = aSubString.rfind('_');
314   if (n == std::string::npos) return aSelection;
315   aSubString = aSubString.substr(n+1);
316   int indx = atoi(aSubString.c_str());
317
318   TNaming_Iterator anItL(theNS);
319   for(int i = 1; anItL.More(); anItL.Next(), i++) {
320     if (i == indx) {
321       return anItL.NewShape();
322     }
323   }
324   return aSelection;    
325 }
326
327 const TopoDS_Shape findFaceByName(
328   const std::string& theSubShapeName, std::shared_ptr<Model_Document> theDoc)
329 {
330   TopoDS_Shape aFace;
331   std::string::size_type n, nb = theSubShapeName.rfind('/');                    
332   if (nb == std::string::npos) nb = 0;
333   std::string aSubString = theSubShapeName.substr(nb + 1);
334   n = aSubString.rfind('_');
335   if (n != std::string::npos) {
336     std::string aSubStr2 = aSubString.substr(0, n);
337     aSubString  = theSubShapeName.substr(0, nb + 1);
338     aSubString = aSubString + aSubStr2; 
339   } else
340     aSubString = theSubShapeName;
341
342   const TDF_Label& aLabel = theDoc->findNamingName(aSubString);
343   if(aLabel.IsNull()) return aFace;
344   Handle(TNaming_NamedShape) aNS;
345   if(aLabel.FindAttribute(TNaming_NamedShape::GetID(), aNS)) {
346     aFace = getShapeFromNS(theSubShapeName, aNS);
347   }
348   return aFace;
349 }
350
351 size_t ParseName(const std::string& theSubShapeName,   std::list<std::string>& theList)
352 {
353   std::string aName = theSubShapeName;
354   std::string aLastName;
355   size_t n1(0), n2(0); // n1 - start position, n2 - position of the delimiter
356   while ((n2 = aName.find('&', n1)) != std::string::npos) {
357     const std::string aName1 = aName.substr(n1, n2 - n1); //name of face
358     theList.push_back(aName1);  
359     n1 = n2 + 1;
360     aLastName = aName.substr(n1);
361   }
362   if(!aLastName.empty())
363     theList.push_back(aLastName);
364   return theList.size();
365 }
366
367 const TopoDS_Shape findCommonShape(
368   const TopAbs_ShapeEnum theType, const TopTools_ListOfShape& theList)
369 {
370   TopoDS_Shape aShape;
371   std::vector<TopTools_MapOfShape> aVec;
372   TopTools_MapOfShape aMap1, aMap2, aMap3, aMap4;
373   if(theList.Extent() > 1) {
374     aVec.push_back(aMap1);
375     aVec.push_back(aMap2);
376   }
377   if(theList.Extent() > 2)
378     aVec.push_back(aMap3);
379   if(theList.Extent() == 4)
380     aVec.push_back(aMap4);
381
382   //fill maps
383   TopTools_ListIteratorOfListOfShape it(theList);
384   for(int i = 0;it.More();it.Next(),i++) {
385     const TopoDS_Shape& aFace = it.Value();             
386     if(i < 2) {
387       TopExp_Explorer anExp (aFace, theType);
388       for(;anExp.More();anExp.Next()) {
389         const TopoDS_Shape& anEdge = anExp.Current();
390         if (!anEdge.IsNull())
391           aVec[i].Add(anExp.Current());
392       }
393     } else {
394       TopExp_Explorer anExp (aFace, TopAbs_VERTEX);
395       for(;anExp.More();anExp.Next()) {
396         const TopoDS_Shape& aVertex = anExp.Current();
397         if (!aVertex.IsNull())
398           aVec[i].Add(anExp.Current());
399       }
400     }
401   }
402   //trivial case: 2 faces
403   TopTools_ListOfShape aList;
404   TopTools_MapIteratorOfMapOfShape it2(aVec[0]);
405   for(;it2.More();it2.Next()) {
406     if(aVec[1].Contains(it2.Key())) {
407       aShape = it2.Key();
408       if(theList.Extent() == 2)
409         break;
410       else 
411         aList.Append(it2.Key());
412     }
413   }
414   if(aList.Extent() && aVec.size() > 3) {// list of common edges ==> search ny neighbors 
415     if(aVec[2].Extent() && aVec[3].Extent()) {
416       TopTools_ListIteratorOfListOfShape it(aList);
417       for(;it.More();it.Next()) {
418         const TopoDS_Shape& aCand = it.Value();
419         // not yet completelly implemented, to be rechecked
420         TopoDS_Vertex aV1, aV2;
421         TopExp::Vertices(TopoDS::Edge(aCand), aV1, aV2);
422         int aNum(0);
423         if(aVec[2].Contains(aV1)) aNum++;
424         else if(aVec[2].Contains(aV2)) aNum++;
425         if(aVec[3].Contains(aV1)) aNum++;
426         else if(aVec[3].Contains(aV2)) aNum++;
427         if(aNum == 2) {
428           aShape = aCand;
429           break;
430         }
431       }
432     }
433   }
434
435   if(aList.Extent() && aVec.size() == 3) {
436
437     TopTools_ListIteratorOfListOfShape it(aList);
438     for(;it.More();it.Next()) {
439       const TopoDS_Shape& aCand = it.Value();
440       if(aVec[2].Contains(aCand)) {
441         aShape = aCand;
442         break;
443       }
444     }
445   }
446   return aShape;
447 }
448
449 std::string getContextName(const std::string& theSubShapeName)
450 {
451   std::string aName;
452   std::string::size_type n = theSubShapeName.find('/');                 
453   if (n == std::string::npos) return aName;
454   aName = theSubShapeName.substr(0, n);
455   return aName;
456 }
457
458 // type ::= COMP | COMS | SOLD | SHEL | FACE | WIRE | EDGE | VERT
459 bool Model_SelectionNaming::selectSubShape(const std::string& theType, 
460   const std::string& theSubShapeName, std::shared_ptr<Model_Document> theDoc,
461   std::shared_ptr<GeomAPI_Shape>& theShapeToBeSelected, std::shared_ptr<ModelAPI_Result>& theCont)
462 {
463   if(theSubShapeName.empty() || theType.empty()) return false;
464   TopAbs_ShapeEnum aType = translateType(theType);
465   std::string aContName = getContextName(theSubShapeName);
466   if(aContName.empty()) return false;
467   ResultPtr aCont = theDoc->findByName(aContName);
468   if(!aCont.get() || aCont->shape()->isNull()) return false;
469   TopoDS_Shape aContext  = aCont->shape()->impl<TopoDS_Shape>();
470   TopAbs_ShapeEnum aContType = aContext.ShapeType();
471   if(aType <= aContType) return false; // not applicable
472
473
474   TopoDS_Shape aSelection;
475   switch (aType) 
476   {
477   case TopAbs_COMPOUND:
478     break;
479   case TopAbs_COMPSOLID:
480     break;
481   case TopAbs_SOLID:
482     break;
483   case TopAbs_SHELL:
484     break;
485   case TopAbs_FACE:
486     {
487       const TopoDS_Shape aSelection = findFaceByName(theSubShapeName, theDoc);
488       if(!aSelection.IsNull()) {// Select it
489         std::shared_ptr<GeomAPI_Shape> aShapeToBeSelected(new GeomAPI_Shape());
490         aShapeToBeSelected->setImpl(new TopoDS_Shape(aSelection));
491         theShapeToBeSelected = aShapeToBeSelected;
492         theCont = aCont;
493         return true;
494       }
495     }
496     break;
497   case TopAbs_WIRE:
498     break;
499   case TopAbs_EDGE:
500     {  
501       TopoDS_Shape aSelection;// = findFaceByName(theSubShapeName, aDoc);
502       const TDF_Label& aLabel = theDoc->findNamingName(theSubShapeName);
503       if(!aLabel.IsNull()) {
504         Handle(TNaming_NamedShape) aNS;
505         if(aLabel.FindAttribute(TNaming_NamedShape::GetID(), aNS)) {
506           aSelection = getShapeFromNS(theSubShapeName, aNS);
507         }
508       }
509       if(aSelection.IsNull()) {
510         std::list<std::string> aListofNames;
511         size_t n = ParseName(theSubShapeName, aListofNames);
512         if(n > 1 && n < 5) {
513           TopTools_ListOfShape aList;
514           std::list<std::string>::iterator it =aListofNames.begin();
515           for(;it != aListofNames.end();it++){
516             const TopoDS_Shape aFace = findFaceByName(*it, theDoc);
517             aList.Append(aFace);                
518           }
519           aSelection = findCommonShape(TopAbs_EDGE, aList);
520         }
521       }
522       if(!aSelection.IsNull()) {// Select it
523         std::shared_ptr<GeomAPI_Shape> aShapeToBeSelected(new GeomAPI_Shape());
524         aShapeToBeSelected->setImpl(new TopoDS_Shape(aSelection));
525         theShapeToBeSelected = aShapeToBeSelected;
526         theCont = aCont;
527         return true;
528       }
529     }
530     break;
531   case TopAbs_VERTEX:
532     {
533       TopoDS_Shape aSelection;
534       const TDF_Label& aLabel = theDoc->findNamingName(theSubShapeName);
535       if(!aLabel.IsNull()) {
536         Handle(TNaming_NamedShape) aNS;
537         if(aLabel.FindAttribute(TNaming_NamedShape::GetID(), aNS)) {
538           aSelection = getShapeFromNS(theSubShapeName, aNS);
539         }
540       }
541       if(aSelection.IsNull()) {
542         std::list<std::string> aListofNames;
543         size_t n = ParseName(theSubShapeName, aListofNames);
544         if(n > 1 && n < 4) { // 2 || 3
545           TopTools_ListOfShape aList;
546           std::list<std::string>::iterator it = aListofNames.begin();
547           for(; it != aListofNames.end(); it++){
548             const TopoDS_Shape aFace = findFaceByName(*it, theDoc);
549             if(!aFace.IsNull())
550               aList.Append(aFace);              
551           }
552           aSelection = findCommonShape(TopAbs_VERTEX, aList);
553         }
554       }
555       if(!aSelection.IsNull()) {// Select it
556         std::shared_ptr<GeomAPI_Shape> aShapeToBeSelected(new GeomAPI_Shape());
557         aShapeToBeSelected->setImpl(new TopoDS_Shape(aSelection));
558         theShapeToBeSelected = aShapeToBeSelected;
559         theCont = aCont;
560         return true;
561       }
562     }
563     break;
564   default: //TopAbs_SHAPE
565     return false;
566   }
567   return false;
568 }
569