]> SALOME platform Git repositories - modules/shaper.git/blob - src/Model/Model_SelectionNaming.cpp
Salome HOME
5ed01d28b113ba372f6f8e385e5d2ca71bc1edaa
[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 /*                for (int i = 1; i <= aMap.Extent(); i++) {
140                         const TopoDS_Shape& aKey = aMap.FindKey(i);
141                         //if (aKey.IsNotEqual(aSubShape)) continue; // find exactly the selected key
142                         if (aKey.IsSame(aSubShape)) continue;
143             const TopTools_ListOfShape& anAncestors = aMap.FindFromIndex(i);
144                         // check that it is not a trivial case (F1 & F2: aNumber = 1)
145                         isTrivialCase = isTrivial(anAncestors, aSMap);                  
146                         break;
147                   }*/
148                   if(aMap.Contains(aSubShape)) {
149                         const TopTools_ListOfShape& anAncestors = aMap.FindFromKey(aSubShape);
150                         // check that it is not a trivial case (F1 & F2: aNumber = 1)
151                         isTrivialCase = isTrivial(anAncestors, aSMap);          
152                   } else 
153                           break;
154                   TopTools_ListOfShape aListOfNbs;
155                   if(!isTrivialCase) { // find Neighbors
156                         TNaming_Localizer aLocalizer;
157                         TopTools_MapOfShape aMap3;
158                         aLocalizer.FindNeighbourg(aContext, aSubShape, aMap3);
159                         //int n = aMap3.Extent();
160                         TopTools_MapIteratorOfMapOfShape it(aMap3);
161                         for(;it.More();it.Next()) {
162                           const TopoDS_Shape& aNbShape = it.Key(); // neighbor edge
163                           //TopAbs_ShapeEnum aType = aNbShape.ShapeType();
164                           const TopTools_ListOfShape& aList  = aMap.FindFromKey(aNbShape);
165                           TopTools_ListIteratorOfListOfShape it2(aList);
166                           for(;it2.More();it2.Next()) {
167                                 if(aSMap.Contains(it2.Value())) continue; // skip this Face
168                                 aListOfNbs.Append(it2.Value());
169                           }
170                         }
171                   }  // else a trivial case
172                   
173                   // build name of the sub-shape Edge
174                   for(int i=1; i <= aSMap.Extent(); i++) {
175                         const TopoDS_Shape& aFace = aSMap.FindKey(i);
176                         std::string aFaceName = getShapeName(aDoc, aFace);
177                         if(i == 1)
178                           aName = aFaceName;
179                         else 
180                           aName += "|" + aFaceName;
181                   }
182                   TopTools_ListIteratorOfListOfShape itl(aListOfNbs);
183                   for (;itl.More();itl.Next()) {
184                         std::string aFaceName = getShapeName(aDoc, itl.Value());
185                         aName += "|" + aFaceName;
186                   }               
187                   }
188                   break;
189
190     case TopAbs_VERTEX:
191       // name structure (Monifold Topology): 
192       // 1) F1 | F2 | F3 - intersection of 3 faces defines a vertex - trivial case.
193       // 2) F1 | F2 | F3 [|F4 [|Fn]] - redundant definition, but it should be kept as is to obtain safe recomputation
194       // 2) F1 | F2      - intersection of 2 faces definses a vertex - applicable for case
195       //                   when 1 faces is cylindrical, conical, spherical or revolution and etc.
196       // 3) E1 | E2 | E3 - intersection of 3 edges defines a vertex - when we have case of a shell
197       //                   or compound of 2 open faces.
198       // 4) E1 | E2      - intesection of 2 edges defines a vertex - when we have a case of 
199       //                   two independent edges (wire or compound)
200       // implemented 2 first cases
201       {
202         TopTools_IndexedDataMapOfShapeListOfShape aMap;
203         TopExp::MapShapesAndAncestors(aContext, TopAbs_VERTEX, TopAbs_FACE, aMap);
204         const TopTools_ListOfShape& aList2  = aMap.FindFromKey(aSubShape);
205         TopTools_ListOfShape aList;
206         TopTools_MapOfShape aFMap;
207         //int n = aList2.Extent(); //bug! duplication
208         // fix is below
209         TopTools_ListIteratorOfListOfShape itl2(aList2);
210         for (int i = 1;itl2.More();itl2.Next(),i++) {
211           if(aFMap.Add(itl2.Value()))
212             aList.Append(itl2.Value());
213         }
214         //n = aList.Extent();
215         int n = aList.Extent();
216         if(n < 3) { // open topology case or Compound case => via edges
217           TopTools_IndexedDataMapOfShapeListOfShape aMap;
218           TopExp::MapShapesAndAncestors(aContext, TopAbs_VERTEX, TopAbs_EDGE, aMap);
219           const TopTools_ListOfShape& aList22  = aMap.FindFromKey(aSubShape);
220           if(aList22.Extent() >= 2)  { // regular solution
221
222             // bug! duplication; fix is below
223             aFMap.Clear();
224             TopTools_ListOfShape aListE;
225             TopTools_ListIteratorOfListOfShape itl2(aList22);
226             for (int i = 1;itl2.More();itl2.Next(),i++) {
227               if(aFMap.Add(itl2.Value()))
228                 aListE.Append(itl2.Value());
229             }
230             n = aListE.Extent();
231             TopTools_ListIteratorOfListOfShape itl(aListE);
232             for (int i = 1;itl.More();itl.Next(),i++) {
233               const TopoDS_Shape& anEdge = itl.Value();
234               std::string anEdgeName = getShapeName(aDoc, anEdge);
235               if(i == 1)
236                 aName = anEdgeName;
237               else 
238                 aName += "|" + anEdgeName;
239             }
240           }//reg
241           else { // dangle vertex: if(aList22.Extent() == 1)
242             //it should be already in DF
243           }
244         } 
245         else {
246           TopTools_ListIteratorOfListOfShape itl(aList);
247           for (int i = 1;itl.More();itl.Next(),i++) {
248             const TopoDS_Shape& aFace = itl.Value();
249             std::string aFaceName = getShapeName(aDoc, aFace);
250             if(i == 1)
251               aName = aFaceName;
252             else 
253               aName += "|" + aFaceName;
254           }
255         }
256       }
257       break;
258     }
259     // register name                    
260     // aDoc->addNamingName(selectionLabel(), aName);
261     // the selected sub-shape will not be shared and as result it will not require registration
262   }
263   return aName;
264 }
265
266 TopAbs_ShapeEnum translateType (const std::string& theType)
267 {
268   // map from the textual shape types to OCCT enumeration
269   static std::map<std::string, TopAbs_ShapeEnum> MyShapeTypes;
270   if (MyShapeTypes.size() == 0) {
271     MyShapeTypes["face"] = TopAbs_FACE;
272     MyShapeTypes["faces"] = TopAbs_FACE;
273     MyShapeTypes["vertex"] = TopAbs_VERTEX;
274     MyShapeTypes["vertices"] = TopAbs_VERTEX;
275     MyShapeTypes["wire"] = TopAbs_WIRE;
276     MyShapeTypes["edge"] = TopAbs_EDGE;
277     MyShapeTypes["edges"] = TopAbs_EDGE;
278     MyShapeTypes["shell"] = TopAbs_SHELL;
279     MyShapeTypes["solid"] = TopAbs_SOLID;
280     MyShapeTypes["solids"] = TopAbs_SOLID;
281     MyShapeTypes["FACE"] = TopAbs_FACE;
282     MyShapeTypes["FACES"] = TopAbs_FACE;
283     MyShapeTypes["VERTEX"] = TopAbs_VERTEX;
284     MyShapeTypes["VERTICES"] = TopAbs_VERTEX;
285     MyShapeTypes["WIRE"] = TopAbs_WIRE;
286     MyShapeTypes["EDGE"] = TopAbs_EDGE;
287     MyShapeTypes["EDGES"] = TopAbs_EDGE;
288     MyShapeTypes["SHELL"] = TopAbs_SHELL;
289     MyShapeTypes["SOLID"] = TopAbs_SOLID;
290     MyShapeTypes["SOLIDS"] = TopAbs_SOLID;
291   }
292   if (MyShapeTypes.find(theType) != MyShapeTypes.end())
293     return MyShapeTypes[theType];
294   Events_Error::send("Shape type defined in XML is not implemented!");
295   return TopAbs_SHAPE;
296 }
297
298 const TopoDS_Shape getShapeFromNS(
299   const std::string& theSubShapeName, Handle(TNaming_NamedShape) theNS)
300 {
301   TopoDS_Shape aSelection;
302   std::string::size_type n = theSubShapeName.rfind('/');                        
303   if (n == std::string::npos) n = 0;
304   std::string aSubString = theSubShapeName.substr(n + 1);
305   n = aSubString.rfind('_');
306   if (n == std::string::npos) return aSelection;
307   aSubString = aSubString.substr(n+1);
308   int indx = atoi(aSubString.c_str());
309
310   TNaming_Iterator anItL(theNS);
311   for(int i = 1; anItL.More(); anItL.Next(), i++) {
312     if (i == indx) {
313       return anItL.NewShape();
314     }
315   }
316   return aSelection;    
317 }
318
319 const TopoDS_Shape findFaceByName(
320   const std::string& theSubShapeName, std::shared_ptr<Model_Document> theDoc)
321 {
322   TopoDS_Shape aFace;
323   std::string::size_type n, nb = theSubShapeName.rfind('/');                    
324   if (nb == std::string::npos) nb = 0;
325   std::string aSubString = theSubShapeName.substr(nb + 1);
326   n = aSubString.rfind('_');
327   if (n != std::string::npos) {
328     std::string aSubStr2 = aSubString.substr(0, n);
329     aSubString  = theSubShapeName.substr(0, nb + 1);
330     aSubString = aSubString + aSubStr2; 
331   } else
332     aSubString = theSubShapeName;
333
334   const TDF_Label& aLabel = theDoc->findNamingName(aSubString);
335   if(aLabel.IsNull()) return aFace;
336   Handle(TNaming_NamedShape) aNS;
337   if(aLabel.FindAttribute(TNaming_NamedShape::GetID(), aNS)) {
338     aFace = getShapeFromNS(theSubShapeName, aNS);
339   }
340   return aFace;
341 }
342
343 int ParseName(const std::string& theSubShapeName,   std::list<std::string>& theList)
344 {
345   std::string aName = theSubShapeName;
346   std::string aLastName;
347   int n1(0), n2(0); // n1 - start position, n2 - position of the delimiter
348   while ((n2 = aName.find('|', n1)) != std::string::npos) {
349     const std::string aName1 = aName.substr(n1, n2 - n1); //name of face
350     theList.push_back(aName1);  
351     n1 = n2 + 1;
352     aLastName = aName.substr(n1);
353   }
354   if(!aLastName.empty())
355     theList.push_back(aLastName);
356   return theList.size();
357 }
358
359 const TopoDS_Shape findCommonShape(
360   const TopAbs_ShapeEnum theType, const TopTools_ListOfShape& theList)
361 {
362   TopoDS_Shape aShape;
363   std::vector<TopTools_MapOfShape> aVec;
364   TopTools_MapOfShape aMap1, aMap2, aMap3, aMap4;
365   if(theList.Extent() > 1) {
366     aVec.push_back(aMap1);
367     aVec.push_back(aMap2);
368   }
369   if(theList.Extent() > 2)
370     aVec.push_back(aMap3);
371   if(theList.Extent() == 4)
372     aVec.push_back(aMap4);
373
374   //fill maps
375   TopTools_ListIteratorOfListOfShape it(theList);
376   for(int i = 0;it.More();it.Next(),i++) {
377     const TopoDS_Shape& aFace = it.Value();             
378     if(i < 2) {
379       TopExp_Explorer anExp (aFace, theType);
380       for(;anExp.More();anExp.Next()) {
381         const TopoDS_Shape& anEdge = anExp.Current();
382         if (!anEdge.IsNull())
383           aVec[i].Add(anExp.Current());
384       }
385     } else {
386       TopExp_Explorer anExp (aFace, TopAbs_VERTEX);
387       for(;anExp.More();anExp.Next()) {
388         const TopoDS_Shape& aVertex = anExp.Current();
389         if (!aVertex.IsNull())
390           aVec[i].Add(anExp.Current());
391       }
392     }
393   }
394   //trivial case: 2 faces
395   TopTools_ListOfShape aList;
396   TopTools_MapIteratorOfMapOfShape it2(aVec[0]);
397   for(;it2.More();it2.Next()) {
398     if(aVec[1].Contains(it2.Key())) {
399       aShape = it2.Key();
400       if(theList.Extent() == 2)
401         break;
402       else 
403         aList.Append(it2.Key());
404     }
405   }
406   if(aList.Extent() && aVec.size() > 3) {// list of common edges ==> search ny neighbors 
407     if(aVec[2].Extent() && aVec[3].Extent()) {
408       TopTools_ListIteratorOfListOfShape it(aList);
409       for(;it.More();it.Next()) {
410         const TopoDS_Shape& aCand = it.Value();
411         // not yet completelly implemented, to be rechecked
412         TopoDS_Vertex aV1, aV2;
413         TopExp::Vertices(TopoDS::Edge(aCand), aV1, aV2);
414         int aNum(0);
415         if(aVec[2].Contains(aV1)) aNum++;
416         else if(aVec[2].Contains(aV2)) aNum++;
417         if(aVec[3].Contains(aV1)) aNum++;
418         else if(aVec[3].Contains(aV2)) aNum++;
419         if(aNum == 2) {
420           aShape = aCand;
421           break;
422         }
423       }
424     }
425   }
426
427   if(aList.Extent() && aVec.size() == 3) {
428
429     TopTools_ListIteratorOfListOfShape it(aList);
430     for(;it.More();it.Next()) {
431       const TopoDS_Shape& aCand = it.Value();
432       if(aVec[2].Contains(aCand)) {
433         aShape = aCand;
434         break;
435       }
436     }
437   }
438   return aShape;
439 }
440
441 std::string getContextName(const std::string& theSubShapeName)
442 {
443   std::string aName;
444   std::string::size_type n = theSubShapeName.find('/');                 
445   if (n == std::string::npos) return aName;
446   aName = theSubShapeName.substr(0, n);
447   return aName;
448 }
449
450 // type ::= COMP | COMS | SOLD | SHEL | FACE | WIRE | EDGE | VERT
451 bool Model_SelectionNaming::selectSubShape(const std::string& theType, 
452   const std::string& theSubShapeName, std::shared_ptr<Model_Document> theDoc,
453   std::shared_ptr<GeomAPI_Shape>& theShapeToBeSelected, std::shared_ptr<ModelAPI_Result>& theCont)
454 {
455   if(theSubShapeName.empty() || theType.empty()) return false;
456   TopAbs_ShapeEnum aType = translateType(theType);
457   std::string aContName = getContextName(theSubShapeName);
458   if(aContName.empty()) return false;
459   ResultPtr aCont = theDoc->findByName(aContName);
460   if(!aCont.get() || aCont->shape()->isNull()) return false;
461   TopoDS_Shape aContext  = aCont->shape()->impl<TopoDS_Shape>();
462   TopAbs_ShapeEnum aContType = aContext.ShapeType();
463   if(aType <= aContType) return false; // not applicable
464
465
466   TopoDS_Shape aSelection;
467   switch (aType) 
468   {
469   case TopAbs_COMPOUND:
470     break;
471   case TopAbs_COMPSOLID:
472     break;
473   case TopAbs_SOLID:
474     break;
475   case TopAbs_SHELL:
476     break;
477   case TopAbs_FACE:
478     {
479       const TopoDS_Shape aSelection = findFaceByName(theSubShapeName, theDoc);
480       if(!aSelection.IsNull()) {// Select it
481         std::shared_ptr<GeomAPI_Shape> aShapeToBeSelected(new GeomAPI_Shape());
482         aShapeToBeSelected->setImpl(new TopoDS_Shape(aSelection));
483         theShapeToBeSelected = aShapeToBeSelected;
484         theCont = aCont;
485         return true;
486       }
487     }
488     break;
489   case TopAbs_WIRE:
490     break;
491   case TopAbs_EDGE:
492     {  
493       TopoDS_Shape aSelection;// = findFaceByName(theSubShapeName, aDoc);
494       const TDF_Label& aLabel = theDoc->findNamingName(theSubShapeName);
495       if(!aLabel.IsNull()) {
496         Handle(TNaming_NamedShape) aNS;
497         if(aLabel.FindAttribute(TNaming_NamedShape::GetID(), aNS)) {
498           aSelection = getShapeFromNS(theSubShapeName, aNS);
499         }
500       }
501       if(aSelection.IsNull()) {
502         std::list<std::string> aListofNames;
503         int n = ParseName(theSubShapeName, aListofNames);
504         if(n > 1 && n < 5) {
505           TopTools_ListOfShape aList;
506           std::list<std::string>::iterator it =aListofNames.begin();
507           for(;it != aListofNames.end();it++){
508             const TopoDS_Shape aFace = findFaceByName(*it, theDoc);
509             aList.Append(aFace);                
510           }
511           aSelection = findCommonShape(TopAbs_EDGE, aList);
512         }
513       }
514       if(!aSelection.IsNull()) {// Select it
515         std::shared_ptr<GeomAPI_Shape> aShapeToBeSelected(new GeomAPI_Shape());
516         aShapeToBeSelected->setImpl(new TopoDS_Shape(aSelection));
517         theShapeToBeSelected = aShapeToBeSelected;
518         theCont = aCont;
519         return true;
520       }
521     }
522     break;
523   case TopAbs_VERTEX:
524     {
525       TopoDS_Shape aSelection;
526       const TDF_Label& aLabel = theDoc->findNamingName(theSubShapeName);
527       if(!aLabel.IsNull()) {
528         Handle(TNaming_NamedShape) aNS;
529         if(aLabel.FindAttribute(TNaming_NamedShape::GetID(), aNS)) {
530           aSelection = getShapeFromNS(theSubShapeName, aNS);
531         }
532       }
533       if(aSelection.IsNull()) {
534         std::list<std::string> aListofNames;
535         int n = ParseName(theSubShapeName, aListofNames);
536         if(n > 1 && n < 4) { // 2 || 3
537           TopTools_ListOfShape aList;
538           std::list<std::string>::iterator it = aListofNames.begin();
539           for(; it != aListofNames.end(); it++){
540             const TopoDS_Shape aFace = findFaceByName(*it, theDoc);
541             if(!aFace.IsNull())
542               aList.Append(aFace);              
543           }
544           aSelection = findCommonShape(TopAbs_VERTEX, aList);
545         }
546       }
547       if(!aSelection.IsNull()) {// Select it
548         std::shared_ptr<GeomAPI_Shape> aShapeToBeSelected(new GeomAPI_Shape());
549         aShapeToBeSelected->setImpl(new TopoDS_Shape(aSelection));
550         theShapeToBeSelected = aShapeToBeSelected;
551         theCont = aCont;
552         return true;
553       }
554     }
555     break;
556   default: //TopAbs_SHAPE
557     return false;
558   }
559   return false;
560 }
561